Skip to content

feat(cli): support the --workspace-root (-w) flag - #13281

Merged
zkochan merged 7 commits into
mainfrom
fix-13031
Jul 25, 2026
Merged

zkochan merged 7 commits into
mainfrom
fix-13031

Conversation

@zkochan

@zkochan zkochan commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Summary

pnpm add -D <pkg> <pkg> -w from a workspace subdirectory failed on the Rust CLI with a raw clap error, because -w / --workspace-root was not declared at all:

$ pnpm add -D oxlint@latest oxfmt@latest oxlint-tsgolint@latest -w
error: unexpected argument '-w' found

(The multiple-selector half of the original report was already fixed by #12995; -w was the remaining gap.)

This PR adds the flag, matching what pnpm's CLI arg pass does with it:

  • it points --dir at the workspace root, so a non-recursive command such as add writes to the root package.json;
  • under --recursive it appends a {<workspace-root>} inclusion selector to the --filter / --filter-prod list — the inverse of the !{<workspace-root>} auto-exclusion an unfiltered recursive run / exec / add / test already applies. Note the selector is appended, not substituted, exactly as pnpm does it: an unfiltered -r -w runs the root alone, while -r -w --filter project-1 runs the root and project-1 (pnpm v11.17.0 reports Scope: 2 of 3 workspace projects for that command). Both cases have a regression test;
  • --global and "not inside a workspace" are rejected with pnpm's ERR_PNPM_OPTIONS_CONFLICT / ERR_PNPM_NOT_IN_WORKSPACE codes and messages. A --dir that does not exist is not an error under -w: pnpm's findWorkspaceDir falls back to the given path when fs.realpath fails and walks it lexically, so the redirect to the workspace root still happens — verified against pnpm v11.17.0 and covered by a test.

Verified against the exact reproduction in the issue: all three packages land in the root manifest, packages/a/package.json is untouched, and both importers stay in the lockfile.

TypeScript CLI: no change needed — it already implements --workspace-root (cli/parse-cli-args, pnpm/src/main.ts). This is a pacquet-only parity gap, so the changeset targets pacquet alone.

Closes #13031

Squash Commit Body

pnpm parses `--workspace-root` in its CLI arg pass: it points `--dir` at
the workspace root, and under `--recursive` it pushes a `{<root>}`
inclusion selector so the run narrows to the root project. pacquet
surfaced neither, so the `pnpm add -D <pkg> <pkg> -w` form from a
workspace subdirectory died in clap with `unexpected argument '-w'
found`.

Declare `-w` as a CLI-wide flag, apply the `--dir` redirect between the
`--filter` and recursive-by-default promotions (where pnpm applies it),
and thread it into `Config` alongside the other CLI-only selectors.
`AutoExcludeRoot::root_exclusion` becomes `root_selector`: under
`--workspace-root` it returns the `{<root>}` inclusion for every
recursive command, otherwise the existing `run` / `exec` / `add` /
`test` `!{<root>}` exclusion.

`--global` and a missing workspace are rejected with pnpm's
`ERR_PNPM_OPTIONS_CONFLICT` / `ERR_PNPM_NOT_IN_WORKSPACE` codes and
messages. `CliCommand::is_global` reassembles pnpm's CLI-wide
`--global` view from the per-subcommand flags pacquet declares.

Closes pnpm/pnpm#13031

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
    TypeScript CLI already had --workspace-root; nothing to port.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
    Parsing / redirect / conflict / not-in-workspace unit tests, plus e2e tests for add -w from a subdir and -r -w run.

Written by an agent (Claude Code, claude-opus-5).

Summary by CodeRabbit

  • New Features

    • Added the --workspace-root (-w) option to run commands against the workspace root project.
    • pnpm add -w now correctly updates the root package.json when invoked from a workspace subdirectory.
    • Recursive commands (-r) with -w can select only the root project or include it alongside filtered projects.
  • Bug Fixes

    • Improved behavior when -w is used with --dir (including nonexistent paths).
    • Added clear errors when used outside a workspace or combined with global operations (--global).

Copilot AI review requested due to automatic review settings July 24, 2026 23:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cc7ae58e-fc51-48be-af45-29c5c1ed8790

📥 Commits

Reviewing files that changed from the base of the PR and between 1887b73 and 9a07a02.

📒 Files selected for processing (6)
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/src/cli_args/recursive.rs
  • pnpm/crates/cli/src/cli_args/tests.rs
  • pnpm/crates/cli/tests/add.rs
  • pnpm/crates/cli/tests/run_recursive.rs
  • pnpm/crates/config/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/tests/run_recursive.rs
  • pnpm/crates/cli/src/cli_args/recursive.rs
  • pnpm/crates/cli/tests/add.rs
  • pnpm/crates/cli/src/cli_args/tests.rs

📝 Walkthrough

Walkthrough

Adds --workspace-root (-w) to target the workspace root from a subdirectory, reject global usage, propagate the setting into configuration, and restrict recursive commands to the root project. CLI, unit, integration, and changeset coverage are included.

Changes

Workspace root selection

Layer / File(s) Summary
CLI flag validation and root resolution
pnpm/crates/cli/src/cli_args/cli_command.rs, pnpm/crates/cli/src/cli_args/config.rs, pnpm/crates/cli/src/lib.rs, pnpm/crates/cli/src/cli_args/tests.rs
Adds --workspace-root/-w, resolves the workspace root, rejects --global, and tests parsing, resolution, and error cases.
Root-only recursive selection
pnpm/crates/config/src/lib.rs, pnpm/crates/cli/src/cli_args/dispatch.rs, pnpm/crates/cli/src/cli_args/recursive.rs, pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
Propagates workspace_root into configuration and uses an inclusion selector to restrict recursive selection to the workspace root.
Command integration and coverage
pnpm/crates/cli/tests/add.rs, pnpm/crates/cli/tests/run_recursive.rs, .changeset/pacquet-workspace-root-flag.md
Tests root-manifest dependency writes and filtered or root-only recursive execution, and documents the flag constraints.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CliArgs
  participant WorkspaceDiscovery
  participant Config
  participant RecursiveSelector
  CliArgs->>WorkspaceDiscovery: Resolve workspace root from --dir
  WorkspaceDiscovery-->>CliArgs: Return root directory
  CliArgs->>Config: Set workspace_root and resolved directory
  Config->>RecursiveSelector: Apply root selector
  RecursiveSelector-->>CliArgs: Select root project
Loading

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13031

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

feat(cli): support --workspace-root (-w) in pacquet CLI

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add global --workspace-root/-w flag to run commands against the workspace root project.
• Redirect --dir to the workspace root and adjust recursive selectors to include only root.
• Reject invalid usages (--global, outside workspace) with pnpm-compatible error codes and add
 tests.
Diagram

graph TD
  U((User CLI)) --> A["CliArgs (clap)"] --> D{"-w?"} -->|no| C["Existing CLI flow"] --> R["Recursive selection"] --> X["Command execution"]
  D -->|yes| W["Find workspace root"] --> S["Set --dir = root"] --> CFG["Config.workspace_root"] --> R
  R --> SEL["Root selector: {root} or !{root}"] --> X
  subgraph Legend
    direction LR
    _u((User)) ~~~ _p["Process"] ~~~ _d{"Decision"}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use clap conflicts/requirements instead of custom validation
  • ➕ Less custom error plumbing; relies on clap's built-in option validation
  • ➖ Harder to match pnpm’s specific ERR_PNPM_* codes/messages
  • ➖ Doesn’t cover the "must be inside a workspace" constraint cleanly without additional runtime checks anyway
2. Model `-w` purely as a recursive selector (no `--dir` redirect)
  • ➕ Simplifies behavior to only affect recursive project selection
  • ➖ Breaks pnpm parity for non-recursive commands like add (root package.json should be targeted)
  • ➖ Would not fix the original subdir pnpm add ... -w behavior end-to-end
3. Detect workspace root later (during command dispatch) rather than in arg pass
  • ➕ Keeps CliArgs immutable and centralizes workspace logic in dispatch
  • ➖ Diverges from pnpm’s ordering (matters relative to recursive/filter promotion)
  • ➖ More risk of subtle differences if some code reads --dir before adjustment

Recommendation: Keep the PR’s approach: apply --workspace-root in the same phase/order pnpm does (after filter-driven recursive promotion, before anything consumes --dir), and thread a dedicated workspace_root bit into config for recursive selector behavior. This best preserves pnpm parity while keeping the selector logic explicit and testable.

Files changed (11) +350 / -31

Enhancement (6) +132 / -30
cli_command.rsDeclare global '--workspace-root' flag and implement dir-redirect + errors +65/-0

Declare global '--workspace-root' flag and implement dir-redirect + errors

• Adds 'workspace_root: bool' as a global clap flag and implements 'apply_workspace_root()' to canonicalize '--dir', locate the workspace root, and redirect execution to it. Introduces 'WorkspaceRootError' with pnpm-compatible diagnostic codes and adds 'CliCommand::is_global()' to detect global-mode conflicts across subcommands.

pnpm/crates/cli/src/cli_args/cli_command.rs

config.rsExpose Config subcommand '--global' detection for CLI-wide checks +13/-0

Expose Config subcommand '--global' detection for CLI-wide checks

• Adds 'ConfigArgs::is_global()' to detect explicit '--global/-g' usage in 'config' subcommands, enabling consistent CLI-wide '--global' conflict checks.

pnpm/crates/cli/src/cli_args/config.rs

dispatch.rsThread 'workspace_root' through CLI→Config overrides +7/-4

Thread 'workspace_root' through CLI→Config overrides

• Includes the new 'workspace_root' flag when constructing config overrides, aligning it with other CLI-only selectors ('recursive', 'filter', 'filter_prod').

pnpm/crates/cli/src/cli_args/dispatch.rs

recursive.rsSwitch root include/exclude selector logic based on '--workspace-root' +39/-26

Switch root include/exclude selector logic based on '--workspace-root'

• Renames and generalizes the root augmentation from 'root_exclusion' to 'root_selector', returning '{root}' inclusion when 'workspace_root' is set and preserving '!{root}' auto-exclusion otherwise. Extracts 'relative_workspace_dir()' helper and updates selector application plumbing accordingly.

pnpm/crates/cli/src/cli_args/recursive.rs

lib.rsApply workspace-root redirect during CLI initialization +1/-0

Apply workspace-root redirect during CLI initialization

• Invokes 'args.apply_workspace_root()?' after filter-driven recursive promotion and before recursive-by-default promotion, matching pnpm’s option processing order.

pnpm/crates/cli/src/lib.rs

lib.rsAdd 'workspace_root' to shared Config model +7/-0

Add 'workspace_root' to shared Config model

• Extends 'Config' with a CLI-only 'workspace_root: bool' field and documents its semantics (dir redirect + recursive narrowing).

pnpm/crates/config/src/lib.rs

Tests (4) +213 / -1
tests.rsAdd unit tests for parsing and validation of '--workspace-root' +92/-1

Add unit tests for parsing and validation of '--workspace-root'

• Adds a workspace fixture and tests that '-w' parses globally, redirects '--dir' to the workspace root, is a no-op when absent, conflicts with '--global', and errors outside a workspace.

pnpm/crates/cli/src/cli_args/tests.rs

add.rsIntegration test: 'add -w' from subdir writes to root manifest +80/-0

Integration test: 'add -w' from subdir writes to root manifest

• Adds an end-to-end test reproducing pnpm/pnpm#13031: running 'add -D ... -w' from a workspace member directory updates the root 'package.json' and leaves the member manifest untouched.

pnpm/crates/cli/tests/add.rs

run_recursive.rsIntegration test: '-r -w run' selects only root project +40/-0

Integration test: '-r -w run' selects only root project

• Adds an end-to-end test asserting that recursive runs with '--workspace-root' execute only the root project (inverse of the default root auto-exclusion for unfiltered recursive 'run').

pnpm/crates/cli/tests/run_recursive.rs

tests.rsUpdate test config construction for new Config field +1/-0

Update test config construction for new Config field

• Initializes 'workspace_root: false' in test helper config creation to satisfy the extended 'Config' struct.

pnpm/crates/package-manager/src/install_package_from_registry/tests.rs

Documentation (1) +5 / -0
pacquet-workspace-root-flag.mdAdd changeset entry documenting '--workspace-root' flag behavior +5/-0

Add changeset entry documenting '--workspace-root' flag behavior

• Introduces a pacquet patch changeset describing the new '-w/--workspace-root' flag, including subdir 'add' behavior, recursive narrowing, and option constraints.

.changeset/pacquet-workspace-root-flag.md

@greptile-apps

greptile-apps Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge because no blocking failures eligible for this follow-up review remain.

No blocking failure remains.

Reviews (8): Last reviewed commit: "test(cli): pin --global conflict per sub..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/cli/src/cli_args/recursive.rs`:
- Around line 423-426: Update the selector construction in the recursive
argument handling to make workspace_root take precedence over all explicit
filters: when set, use only the root selector and ignore both filters and
filter_prod; otherwise preserve existing filter selection behavior. Add a
regression test covering -r -w with an explicit project filter and assert that
execution targets only the workspace root.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dc34e9dd-ed32-457c-978d-d92e150f7986

📥 Commits

Reviewing files that changed from the base of the PR and between d47ab91 and 4d400e7.

📒 Files selected for processing (11)
  • .changeset/pacquet-workspace-root-flag.md
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/src/cli_args/config.rs
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/recursive.rs
  • pnpm/crates/cli/src/cli_args/tests.rs
  • pnpm/crates/cli/src/lib.rs
  • pnpm/crates/cli/tests/add.rs
  • pnpm/crates/cli/tests/run_recursive.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs

@qodo-code-review

qodo-code-review Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Relative dir fallback remains 🐞 Bug ☼ Reliability ⭐ New
Description
absolute_dir() returns the original relative --dir when std::env::current_dir() fails,
contradicting its contract and allowing workspace discovery to run on a relative ancestor walk. In
that state, find_workspace_dir() may probe for pnpm-workspace.yaml relative to the process
working directory (via the "" ancestor) or emit misleading “not in workspace” errors instead of
failing clearly.
Code

pnpm/crates/cli/src/cli_args/cli_command.rs[R351-360]

+/// `path` resolved against the process cwd, without requiring it to exist.
+/// The workspace-manifest walk climbs `Path::ancestors`, which a bare
+/// relative path runs out of at `""` — the resulting empty workspace dir
+/// would then fail to canonicalize downstream.
+fn absolute_dir(path: &Path) -> PathBuf {
+    if path.is_absolute() {
+        return path.to_path_buf();
+    }
+    std::env::current_dir().map_or_else(|_| path.to_path_buf(), |cwd| cwd.join(path))
+}
Relevance

⭐⭐ Medium

Behavior change: making cwd failures fatal/strict may be debated; team previously rejected
propagating workspace-finder errors.

PR-#13202

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The implementation explicitly falls back to returning a relative PathBuf when current_dir()
fails, despite the comment stating the goal is to avoid Path::ancestors() hitting "". Workspace
root discovery then walks cwd.ancestors() and joins pnpm-workspace.yaml at each ancestor, which
for a relative cwd can include probing from an empty/relative ancestor.

pnpm/crates/cli/src/cli_args/cli_command.rs[351-360]
pnpm/crates/workspace/src/root_finder.rs[105-132]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`absolute_dir()` is intended to make a relative `--dir` safe for `Path::ancestors()` walking (avoid reaching the `""` ancestor), but when `std::env::current_dir()` fails it silently returns the relative input unchanged. That defeats the purpose and can cause incorrect workspace discovery behavior.

### Issue Context
- `CliArgs::apply_workspace_root()` uses `absolute_dir()` when canonicalization fails, including for non-existent dirs.
- `pacquet_workspace::find_workspace_dir()` walks `cwd.ancestors()` and checks for `pnpm-workspace.yaml` at each level; for a relative path, `ancestors()` includes `""`, making the final probe relative.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/cli_command.rs[351-360]

### Suggested fix
- Change `absolute_dir` to return `Result<PathBuf, std::io::Error>` (or a dedicated error type) and **error out** if `current_dir()` fails for a relative path (there is no safe/meaningful absolute fallback).
- Add a `WorkspaceRootError` variant for “failed to resolve current dir” and surface a clear diagnostic, instead of silently continuing with a relative path.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Symlink redirects workspace root 🐞 Bug ⛨ Security
Description
CliArgs::apply_workspace_root() canonicalizes --dir (resolving symlinks) before walking
ancestors to find pnpm-workspace.yaml, so -w may resolve a different workspace root than the
lexical path the user passed. In a repo containing a symlinked subdirectory, this can redirect -w
to operate on a different workspace (potentially outside the repo), unexpectedly expanding where
manifests/lockfiles get read/written.
Code

pnpm/crates/cli/src/cli_args/cli_command.rs[R280-286]

+        let dir = dunce::canonicalize(&self.dir).map_err(|source| {
+            WorkspaceRootError::CanonicalizeDir { path: self.dir.clone(), source }
+        })?;
+        let workspace_dir = pacquet_workspace::find_workspace_dir(&dir)
+            .map_err(WorkspaceRootError::FindWorkspaceDir)?
+            .ok_or(WorkspaceRootError::NotInWorkspace)?;
+        self.dir = workspace_dir;
Relevance

⭐⭐ Medium

Team often accepts path/symlink hardening, but changing workspace-root resolution semantics is
behaviorally risky; no close precedent.

PR-#13178
PR-#13059

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new apply_workspace_root resolves --dir with dunce::canonicalize before calling
find_workspace_dir, so the ancestor walk runs on the symlink target path rather than the user’s
lexical path. find_workspace_dir_by_walk discovers the workspace root by iterating
cwd.ancestors() and checking for pnpm-workspace.yaml, making the chosen workspace dependent on
the pre-walk canonicalization behavior.

pnpm/crates/cli/src/cli_args/cli_command.rs[261-287]
pnpm/crates/workspace/src/root_finder.rs[59-110]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`--workspace-root` currently resolves `--dir` via `dunce::canonicalize`, which follows symlinks. Workspace discovery then walks `ancestors()` of the resolved path, so a symlinked `--dir` can cause the workspace root to be discovered outside the expected lexical project tree.

This is an integrity/security footgun for workspaces that contain symlinks (including symlinks checked into a repo): `pacquet ... -w -C <symlinked-path>` may redirect operations to an unexpected workspace root.

### Issue Context
`find_workspace_dir` discovers the workspace by walking `cwd.ancestors()` and checking for `pnpm-workspace.yaml` at each level.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/cli_command.rs[261-287]

### Suggested fix approach
- Replace `dunce::canonicalize(&self.dir)` with an *absolute, lexically-normalized* path computation that does **not** resolve symlinks (e.g., `current_dir().join(self.dir)` + a lexical `.`/`..` normalizer).
- Alternatively, perform the upward walk starting from the absolute-but-not-canonicalized path (preserving symlink segments) while still keeping the existing “uncanonicalizable dir” error behavior (i.e., still validate existence/access separately if needed).
- Add a regression test: create a workspace with a member directory that is a symlink to another temp directory containing a different `pnpm-workspace.yaml`, then assert `-w` does not redirect to the symlink target’s workspace unexpectedly (or document that it does, if that’s the intended policy).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Root selector delimiter break 🐞 Bug ≡ Correctness
Description
AutoExcludeRoot::root_selector() builds a {<relative-path>} selector by string formatting, but
the selector parser cannot represent paths whose relative form contains a } character. In such
cases, --recursive --workspace-root may end up selecting no projects (becoming a no-op) rather
than pinning the run to the root project.
Code

pnpm/crates/cli/src/cli_args/recursive.rs[R465-471]

+    fn root_selector(&self, config: &Config, prefix: &Path) -> Option<String> {
+        // `--workspace-root` pins the run to the root project, for every
+        // recursive command — unlike the exclusion below, it is not gated
+        // on the command being `run` / `exec` / `add` / `test`.
+        if config.workspace_root {
+            return Some(format!("{{{}}}", relative_workspace_dir(config, prefix)));
+        }
Relevance

⭐⭐ Medium

Edge-case path containing '}' seems rare; no clear precedent on escaping/encoding selector braces.

PR-#12914

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Rust CLI generates a {...} selector from a relative filesystem path, but
parse_project_selector’s brace parsing uses the first } as the close delimiter and rejects
malformed groups; if the inner path contains }, the match fails and parsing falls back to treating
the whole string as a name pattern.

pnpm/crates/cli/src/cli_args/recursive.rs[459-471]
pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[62-89]
pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[153-177]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`--workspace-root` currently narrows recursive selection by appending a string selector like `{<relpath>}`. The selector grammar cannot encode all filesystem paths (notably paths containing `}`), so selection can silently fail.

### Issue Context
The `{...}` selector is parsed by `parse_project_selector()`, which treats `}` as a hard terminator for the brace group. If the computed relative path contains `}`, parsing falls back to a name-pattern selector (likely matching nothing), so the run selects no projects.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/recursive.rs[459-506]
- pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[62-89]
- pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[153-177]

### Suggested fix
Prefer constructing the root selection without going through the string selector grammar:
- Option A (best): change the selection plumbing so `select_recursive_projects` can accept an already-parsed `ProjectSelector` (or a `PathBuf` root override) and append it directly.
- Option B: detect unsupported characters in `relative_workspace_dir()` output (e.g. `}`) and return a dedicated, explicit CLI error instead of silently selecting nothing.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

4. Workspace-root hides dir errors ✓ Resolved 🐞 Bug ☼ Reliability
Description
CliArgs::apply_workspace_root() suppresses canonicalize(--dir) failures and continues workspace
discovery using the original path, which can mask an underlying path/IO problem as
ERR_PNPM_NOT_IN_WORKSPACE. This makes failures harder to diagnose and can return the wrong error
for invalid/inaccessible --dir values.
Code

pnpm/crates/cli/src/cli_args/cli_command.rs[R277-280]

+        let dir = dunce::canonicalize(&self.dir).unwrap_or_else(|_| self.dir.clone());
+        let workspace_dir = pacquet_workspace::find_workspace_dir(&dir)
+            .map_err(WorkspaceRootError::FindWorkspaceDir)?
+            .ok_or(WorkspaceRootError::NotInWorkspace)?;
Relevance

⭐ Low

Close precedent: team rejected propagating workspace discovery errors instead of treating them as
“not in workspace”.

PR-#13202

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
apply_workspace_root() explicitly drops canonicalization errors, while workspace discovery is
implemented as an ancestor walk over the provided path. Elsewhere (dispatch), --dir
canonicalization failures are treated as real errors with context, highlighting the inconsistency
and the risk of masking IO/path failures.

pnpm/crates/cli/src/cli_args/cli_command.rs[261-283]
pnpm/crates/workspace/src/root_finder.rs[105-132]
pnpm/crates/cli/src/cli_args/dispatch.rs[162-172]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`apply_workspace_root()` currently uses `dunce::canonicalize(&self.dir).unwrap_or_else(|_| self.dir.clone())`, which hides canonicalization failures and can surface a misleading `NotInWorkspace` error.

### Issue Context
Workspace discovery walks `cwd.ancestors()`; feeding it an unresolved/relative/invalid path (after hiding canonicalize errors) can change the observed ancestors and/or misclassify the failure.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/cli_command.rs[261-283]
- pnpm/crates/workspace/src/root_finder.rs[105-132]
- pnpm/crates/cli/src/cli_args/dispatch.rs[162-172]

### Suggested fix
Add a `WorkspaceRootError::CanonicalizeDir` variant (or reuse an existing error wrapper) and return it when canonicalization fails, similar to dispatch’s `--dir` canonicalization error handling. This preserves the real failure cause instead of converting it into `NotInWorkspace`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 9a07a02

Results up to commit 4d400e7 ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Root selector delimiter break 🐞 Bug ≡ Correctness
Description
AutoExcludeRoot::root_selector() builds a {<relative-path>} selector by string formatting, but
the selector parser cannot represent paths whose relative form contains a } character. In such
cases, --recursive --workspace-root may end up selecting no projects (becoming a no-op) rather
than pinning the run to the root project.
Code

pnpm/crates/cli/src/cli_args/recursive.rs[R465-471]

+    fn root_selector(&self, config: &Config, prefix: &Path) -> Option<String> {
+        // `--workspace-root` pins the run to the root project, for every
+        // recursive command — unlike the exclusion below, it is not gated
+        // on the command being `run` / `exec` / `add` / `test`.
+        if config.workspace_root {
+            return Some(format!("{{{}}}", relative_workspace_dir(config, prefix)));
+        }
Relevance

⭐⭐ Medium

Edge-case path containing '}' seems rare; no clear precedent on escaping/encoding selector braces.

PR-#12914

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Rust CLI generates a {...} selector from a relative filesystem path, but
parse_project_selector’s brace parsing uses the first } as the close delimiter and rejects
malformed groups; if the inner path contains }, the match fails and parsing falls back to treating
the whole string as a name pattern.

pnpm/crates/cli/src/cli_args/recursive.rs[459-471]
pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[62-89]
pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[153-177]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`--workspace-root` currently narrows recursive selection by appending a string selector like `{<relpath>}`. The selector grammar cannot encode all filesystem paths (notably paths containing `}`), so selection can silently fail.

### Issue Context
The `{...}` selector is parsed by `parse_project_selector()`, which treats `}` as a hard terminator for the brace group. If the computed relative path contains `}`, parsing falls back to a name-pattern selector (likely matching nothing), so the run selects no projects.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/recursive.rs[459-506]
- pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[62-89]
- pnpm/crates/workspace-projects-filter/src/parse_project_selector.rs[153-177]

### Suggested fix
Prefer constructing the root selection without going through the string selector grammar:
- Option A (best): change the selection plumbing so `select_recursive_projects` can accept an already-parsed `ProjectSelector` (or a `PathBuf` root override) and append it directly.
- Option B: detect unsupported characters in `relative_workspace_dir()` output (e.g. `}`) and return a dedicated, explicit CLI error instead of silently selecting nothing.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
2. Workspace-root hides dir errors ✓ Resolved 🐞 Bug ☼ Reliability
Description
CliArgs::apply_workspace_root() suppresses canonicalize(--dir) failures and continues workspace
discovery using the original path, which can mask an underlying path/IO problem as
ERR_PNPM_NOT_IN_WORKSPACE. This makes failures harder to diagnose and can return the wrong error
for invalid/inaccessible --dir values.
Code

pnpm/crates/cli/src/cli_args/cli_command.rs[R277-280]

+        let dir = dunce::canonicalize(&self.dir).unwrap_or_else(|_| self.dir.clone());
+        let workspace_dir = pacquet_workspace::find_workspace_dir(&dir)
+            .map_err(WorkspaceRootError::FindWorkspaceDir)?
+            .ok_or(WorkspaceRootError::NotInWorkspace)?;
Relevance

⭐ Low

Close precedent: team rejected propagating workspace discovery errors instead of treating them as
“not in workspace”.

PR-#13202

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
apply_workspace_root() explicitly drops canonicalization errors, while workspace discovery is
implemented as an ancestor walk over the provided path. Elsewhere (dispatch), --dir
canonicalization failures are treated as real errors with context, highlighting the inconsistency
and the risk of masking IO/path failures.

pnpm/crates/cli/src/cli_args/cli_command.rs[261-283]
pnpm/crates/workspace/src/root_finder.rs[105-132]
pnpm/crates/cli/src/cli_args/dispatch.rs[162-172]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`apply_workspace_root()` currently uses `dunce::canonicalize(&self.dir).unwrap_or_else(|_| self.dir.clone())`, which hides canonicalization failures and can surface a misleading `NotInWorkspace` error.

### Issue Context
Workspace discovery walks `cwd.ancestors()`; feeding it an unresolved/relative/invalid path (after hiding canonicalize errors) can change the observed ancestors and/or misclassify the failure.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/cli_command.rs[261-283]
- pnpm/crates/workspace/src/root_finder.rs[105-132]
- pnpm/crates/cli/src/cli_args/dispatch.rs[162-172]

### Suggested fix
Add a `WorkspaceRootError::CanonicalizeDir` variant (or reuse an existing error wrapper) and return it when canonicalization fails, similar to dispatch’s `--dir` canonicalization error handling. This preserves the real failure cause instead of converting it into `NotInWorkspace`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 17bc527 ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Symlink redirects workspace root 🐞 Bug ⛨ Security
Description
CliArgs::apply_workspace_root() canonicalizes --dir (resolving symlinks) before walking
ancestors to find pnpm-workspace.yaml, so -w may resolve a different workspace root than the
lexical path the user passed. In a repo containing a symlinked subdirectory, this can redirect -w
to operate on a different workspace (potentially outside the repo), unexpectedly expanding where
manifests/lockfiles get read/written.
Code

pnpm/crates/cli/src/cli_args/cli_command.rs[R280-286]

+        let dir = dunce::canonicalize(&self.dir).map_err(|source| {
+            WorkspaceRootError::CanonicalizeDir { path: self.dir.clone(), source }
+        })?;
+        let workspace_dir = pacquet_workspace::find_workspace_dir(&dir)
+            .map_err(WorkspaceRootError::FindWorkspaceDir)?
+            .ok_or(WorkspaceRootError::NotInWorkspace)?;
+        self.dir = workspace_dir;
Relevance

⭐⭐ Medium

Team often accepts path/symlink hardening, but changing workspace-root resolution semantics is
behaviorally risky; no close precedent.

PR-#13178
PR-#13059

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new apply_workspace_root resolves --dir with dunce::canonicalize before calling
find_workspace_dir, so the ancestor walk runs on the symlink target path rather than the user’s
lexical path. find_workspace_dir_by_walk discovers the workspace root by iterating
cwd.ancestors() and checking for pnpm-workspace.yaml, making the chosen workspace dependent on
the pre-walk canonicalization behavior.

pnpm/crates/cli/src/cli_args/cli_command.rs[261-287]
pnpm/crates/workspace/src/root_finder.rs[59-110]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`--workspace-root` currently resolves `--dir` via `dunce::canonicalize`, which follows symlinks. Workspace discovery then walks `ancestors()` of the resolved path, so a symlinked `--dir` can cause the workspace root to be discovered outside the expected lexical project tree.

This is an integrity/security footgun for workspaces that contain symlinks (including symlinks checked into a repo): `pacquet ... -w -C <symlinked-path>` may redirect operations to an unexpected workspace root.

### Issue Context
`find_workspace_dir` discovers the workspace by walking `cwd.ancestors()` and checking for `pnpm-workspace.yaml` at each level.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/cli_command.rs[261-287]

### Suggested fix approach
- Replace `dunce::canonicalize(&self.dir)` with an *absolute, lexically-normalized* path computation that does **not** resolve symlinks (e.g., `current_dir().join(self.dir)` + a lexical `.`/`..` normalizer).
- Alternatively, perform the upward walk starting from the absolute-but-not-canonicalized path (preserving symlink segments) while still keeping the existing “uncanonicalizable dir” error behavior (i.e., still validate existence/access separately if needed).
- Add a regression test: create a workspace with a member directory that is a symlink to another temp directory containing a different `pnpm-workspace.yaml`, then assert `-w` does not redirect to the symlink target’s workspace unexpectedly (or document that it does, if that’s the intended policy).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings July 25, 2026 00:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Thanks — one finding fixed, one skipped with a reason.

2. "Workspace-root hides dir errors" — fixed in 203a6f4

Agreed, and the inconsistency you point at with dispatch.rs is the clinching argument: without -w, an unusable --dir already fails with canonicalizing the --dir argument: <path>, so under -w it should not turn into ERR_PNPM_NOT_IN_WORKSPACE and send the user looking for a missing pnpm-workspace.yaml. apply_workspace_root now propagates the failure as a CanonicalizeDir variant carrying the path and the io::Error source:

$ pnpm --dir ./packages/nope add foo -w
Error: ERR_PNPM_CANONICALIZE_DIR

  × canonicalizing the `--dir` argument: /tmp/ws/packages/nope: No such file or directory (os error 2)
  ╰─▶ No such file or directory (os error 2)

Covered by workspace_root_reports_an_uncanonicalizable_dir.

1. "Root selector delimiter break" — skipping, not introduced here

Real, but pre-existing and not specific to --workspace-root. The !{<workspace-root>} auto-exclusion that recursive run / exec / add / test already applied built its selector by the same format! — this PR only extracted that shared code into relative_workspace_dir() and added the inclusion arm beside it. A workspace root whose path contains } was already unselectable before this branch.

It is also what the TypeScript CLI does, so it is not a divergence:

filters.push({ filter: `!{${relativeWSDirPath()}}`, followProdDepsOnly: ... })

Under this repo's parity rule a bug present in both stacks gets fixed in both, and your Option A (teaching select_recursive_projects to accept an already-parsed ProjectSelector / root-path override) is the right shape for that — but it touches the selector plumbing on both sides and belongs in its own PR rather than riding along with a flag addition. Option B (erroring on a } in the path) I'd rather not do: it would reject a workspace the TypeScript CLI accepts for every recursive command, not just under -w.


Written by an agent (Claude Code, claude-opus-5).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 203a6f4

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pnpm/crates/cli/tests/run_recursive.rs (1)

328-348: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exercise the workspace-root selector from a project subdirectory.

CommandTempCwd::init() starts pacquet in the workspace root, so these cases only cover root-relative selection. Add one regression that invokes --dir workspace/project-1 while asserting root-ran.txt is created and workspace/project-{1,2}/ran.txt are absent.

Apply the same coverage path to the -w --filter variant as well.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/cli/tests/run_recursive.rs` around lines 328 - 348, Extend the
recursive workspace-root selection tests around
recursive_run_workspace_root_selects_only_the_root_project to invoke pacquet
with --dir workspace/project-1, then assert root-ran.txt is created while
workspace/project-1/ran.txt and workspace/project-2/ran.txt are absent. Add
equivalent subdirectory coverage for the -w --filter variant, preserving the
existing root-selection assertions.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@pnpm/crates/cli/tests/run_recursive.rs`:
- Around line 328-348: Extend the recursive workspace-root selection tests
around recursive_run_workspace_root_selects_only_the_root_project to invoke
pacquet with --dir workspace/project-1, then assert root-ran.txt is created
while workspace/project-1/ran.txt and workspace/project-2/ran.txt are absent.
Add equivalent subdirectory coverage for the -w --filter variant, preserving the
existing root-selection assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ad575839-0be0-49b5-b665-c6401a6825ee

📥 Commits

Reviewing files that changed from the base of the PR and between 4d400e7 and 203a6f4.

📒 Files selected for processing (4)
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/src/cli_args/recursive.rs
  • pnpm/crates/cli/src/cli_args/tests.rs
  • pnpm/crates/cli/tests/run_recursive.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/cli/src/cli_args/tests.rs
  • pnpm/crates/cli/src/cli_args/recursive.rs

Copilot AI review requested due to automatic review settings July 25, 2026 00:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Good catch on the coverage gap — done in b8a8e93, though not quite the way you framed it.

Rather than add two more near-duplicate tests, I folded both recursive --workspace-root cases into one helper parameterized over the starting --dir, so each asserts the same selection from project-1 as from the workspace root:

const WORKSPACE_ROOT_START_DIRS: [&str; 2] = [".", "project-1"];

One correction to the premise, which I only found by testing it. I'd initially written that the member-dir case guards the --dir redirect, since {<workspace-root>} anchors against --dir. That's wrong: with self.dir = workspace_dir removed, the selector becomes {..} from project-1, which still resolves to the workspace root — both cases still passed. So the member-dir path does not discriminate the redirect on its own, and I fixed the comment that claimed it did.

What the cases do guard, verified by breaking it: stubbing out the config.workspace_root arm of root_selector fails both, from both start dirs. The member-dir iteration is end-to-end scenario coverage — redirect, manifest discovery, script lookup all holding when the command starts inside a member, which is the #13031 scenario — rather than selector-anchoring coverage.

The add side of the subdirectory path was already covered by add_workspace_root_saves_to_the_root_manifest_from_a_subdir, which runs with --dir packages/a.


Written by an agent (Claude Code, claude-opus-5).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit b8a8e93

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

zkochan and others added 3 commits July 25, 2026 02:20
pnpm parses `--workspace-root` in its CLI arg pass: it points `--dir` at
the workspace root, and under `--recursive` it pushes a `{<root>}`
inclusion selector so the run narrows to the root project. pacquet
surfaced neither, so the `pnpm add -D <pkg> <pkg> -w` form from a
workspace subdirectory died in clap with `unexpected argument '-w'
found`.

Declare `-w` as a CLI-wide flag, apply the `--dir` redirect between the
`--filter` and recursive-by-default promotions (where pnpm applies it),
and thread it into `Config` alongside the other CLI-only selectors.
`AutoExcludeRoot::root_exclusion` becomes `root_selector`: under
`--workspace-root` it returns the `{<root>}` inclusion for every
recursive command, otherwise the existing `run` / `exec` / `add` /
`test` `!{<root>}` exclusion.

`--global` and a missing workspace are rejected with pnpm's
`ERR_PNPM_OPTIONS_CONFLICT` / `ERR_PNPM_NOT_IN_WORKSPACE` codes and
messages. `CliCommand::is_global` reassembles pnpm's CLI-wide
`--global` view from the per-subcommand flags pacquet declares.

Closes #13031

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`apply_workspace_root` swallowed the `--dir` canonicalization failure and
walked the unresolved path instead, so a `--dir` that does not exist
surfaced as `ERR_PNPM_NOT_IN_WORKSPACE` — pointing at the wrong thing,
and inconsistent with dispatch, which reports the same failure with
context. `-w` no longer changes which error an unusable `--dir` produces.

Also pin the recursive selector semantics with a test: `--workspace-root`
appends `{<root>}` to the `--filter` selection rather than replacing it,
so `-r -w --filter <name>` runs the root *and* the filtered project.
That matches pnpm, which pushes the selector onto the same filter list
(`Scope: 2 of 3 workspace projects` for a three-project workspace), and
the doc comments no longer describe the flag as pinning the selection.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The recursive `--workspace-root` cases only ran from the workspace root,
while the flag exists to be used from a member project. Fold the two
cases into one helper parameterized over the starting `--dir` so each
asserts the same selection from a member as from the root.

Starting from a member does not discriminate the `--dir` redirect on its
own: with the redirect removed the selector becomes `{..}`, which still
resolves to the workspace root, so both cases still pass. What it does
cover is the whole path — redirect, manifest discovery, script lookup —
holding when the command starts inside a member. Breaking the inclusion
arm of `root_selector` fails both cases, which is the regression they
guard.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 25, 2026 00:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.7±0.03ms    32.0 MB/sec    1.01     11.8±0.03ms    31.8 MB/sec
packument/parse                1.00     38.5±0.09µs  1722.4 MB/sec    1.01     39.1±0.06µs  1697.0 MB/sec
tarball/download_dependency    1.00      2.3±0.06ms  1880.7 KB/sec    1.00      2.3±0.17ms  1885.8 KB/sec

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 17bc527

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings July 25, 2026 00:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Took the one point that held and am declining the rest.

Applied (1e600ee): the write_workspace_with_local_fixtures doc did narrate its own body — it listed the files it writes. Trimmed to just the rationale (file: specs let a -w add run without the registry).

Declining the /// → // conversions. The guideline being cited says doc comments are for item contracts and that implementation rationale belongs in // — not that private items and tests may not have doc comments. The crate's established convention is the opposite of the suggestion:

  • pnpm/crates/cli/tests/add.rs on main has 59 /// lines, on private helpers and #[test] fns alike (e.g. /// Regression test for the Tag release operator's invocation (pnpm/pnpm#13242).).
  • pnpm/crates/cli/tests/run_recursive.rs has 137.
  • Every private helper in cli_args/recursive.rs that I did not touch — build_graph, filter_against, is_root_only_patterns — is documented with ///, including the root_exclusion this PR renamed.

Converting only the lines this PR happens to touch would make the diff inconsistent with its own files. Each retained comment also carries a non-obvious why rather than restating the code:

  • CliCommand::is_global — why the method exists at all: pnpm parses --global as one CLI-wide option, pacquet declares it per subcommand, so this reassembles the CLI-wide view.
  • workspace_fixture — why the canonicalized path is returned (temp dirs are symlinks on some platforms, so a --dir redirect wouldn't compare equal).
  • the two -w parity tests — why the behavior is what it is, which is what stops the pnpm-diverging version from being reintroduced. That rationale earned its keep this round: it is exactly what two of the findings on this PR proposed to undo.

The remaining test-name overlap is a single line carrying the issue reference (pnpm/pnpm#13031), which I'd rather keep than the bare name.


Written by an agent (Claude Code, claude-opus-5).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 1e600ee

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 1e600ee04902

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.655 ± 0.128 2.360 2.805 1.72 ± 0.15
pacquet@main 2.476 ± 0.132 2.357 2.693 1.61 ± 0.15
pnpr@HEAD 1.551 ± 0.154 1.354 1.772 1.01 ± 0.12
pnpr@main 1.541 ± 0.115 1.391 1.675 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6550155167,
      "stddev": 0.12791128250488992,
      "median": 2.6740666430999998,
      "user": 1.5638215,
      "system": 1.30934514,
      "min": 2.3601578451,
      "max": 2.8046030200999996,
      "times": [
        2.8046030200999996,
        2.6278348681,
        2.3601578451,
        2.7484228891,
        2.6901333461,
        2.5782110421,
        2.5916342571,
        2.6579999401,
        2.7668946010999997,
        2.7242633581
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.4764578476,
      "stddev": 0.13242615396282165,
      "median": 2.4002592771,
      "user": 1.6108383,
      "system": 1.33425224,
      "min": 2.3566909360999997,
      "max": 2.6926187511,
      "times": [
        2.3800233841,
        2.6605348480999997,
        2.4196423911,
        2.5212302570999996,
        2.6085958061,
        2.3729625601,
        2.6926187511,
        2.3714033790999998,
        2.3808761631,
        2.3566909360999997
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5507707730000004,
      "stddev": 0.15387060287078208,
      "median": 1.4923442676,
      "user": 1.0562239,
      "system": 1.2139759399999999,
      "min": 1.3537833081000001,
      "max": 1.7723217001000002,
      "times": [
        1.4390515261,
        1.7022854751,
        1.6591839971000002,
        1.4974389741,
        1.4872495611,
        1.4028581681,
        1.3537833081000001,
        1.7723217001000002,
        1.7467950101000003,
        1.4467400101
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5412756347000003,
      "stddev": 0.11501689748336755,
      "median": 1.5641483056,
      "user": 1.0603431,
      "system": 1.19840664,
      "min": 1.3906240961,
      "max": 1.6754937091000002,
      "times": [
        1.3906240961,
        1.5751954731000002,
        1.4817138651000001,
        1.5531011381,
        1.4072539241000002,
        1.5955251881,
        1.6707471991000002,
        1.6650700511,
        1.3980317031,
        1.6754937091000002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 257.9 ± 6.1 247.8 266.5 1.01 ± 0.04
pacquet@main 255.3 ± 6.8 242.8 263.2 1.00
pnpr@HEAD 274.5 ± 32.0 253.3 361.4 1.08 ± 0.13
pnpr@main 279.5 ± 6.9 270.5 291.3 1.10 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25792509816000003,
      "stddev": 0.006069610183273688,
      "median": 0.25795487226,
      "user": 0.20954378,
      "system": 0.5273716399999999,
      "min": 0.24781798476000003,
      "max": 0.26649985876000004,
      "times": [
        0.26246678576000004,
        0.25141994676,
        0.25455582476000005,
        0.25668943976,
        0.26486926576,
        0.25397314176,
        0.24781798476000003,
        0.25922030476,
        0.26173842876000003,
        0.26649985876000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25525323726,
      "stddev": 0.006835731755646036,
      "median": 0.25568729126,
      "user": 0.21089648,
      "system": 0.53394414,
      "min": 0.24280196476000002,
      "max": 0.26317887076,
      "times": [
        0.24736270076000003,
        0.25700282376,
        0.26108267676,
        0.25418218276000004,
        0.26239833576000005,
        0.25005798676,
        0.26009307176,
        0.26317887076,
        0.25437175876,
        0.24280196476000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27447622706,
      "stddev": 0.03202298998526718,
      "median": 0.26603453626000007,
      "user": 0.23523547999999997,
      "system": 0.52713394,
      "min": 0.25329377676000003,
      "max": 0.36139961976,
      "times": [
        0.26656707576000005,
        0.28099879676,
        0.25668633076,
        0.25572452676,
        0.25329377676000003,
        0.25521984876000003,
        0.26550199676,
        0.27434082876000004,
        0.36139961976,
        0.27502946976000003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.2795400148600001,
      "stddev": 0.006908929474328707,
      "median": 0.28042259676000003,
      "user": 0.22438837999999994,
      "system": 0.54608394,
      "min": 0.27052153276,
      "max": 0.29132199276000004,
      "times": [
        0.28350026976000003,
        0.29132199276000004,
        0.28307491176000005,
        0.27660539576000004,
        0.28322378176,
        0.27052153276,
        0.27777028176,
        0.27258656676000004,
        0.28564333976,
        0.27115207576
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.785 ± 0.017 2.757 2.817 1.77 ± 0.18
pacquet@main 2.787 ± 0.035 2.736 2.853 1.77 ± 0.18
pnpr@HEAD 1.657 ± 0.184 1.440 1.967 1.06 ± 0.16
pnpr@main 1.570 ± 0.158 1.427 1.872 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.78544190916,
      "stddev": 0.01730247535534297,
      "median": 2.7866891665599995,
      "user": 1.78783712,
      "system": 1.3511924,
      "min": 2.75670365456,
      "max": 2.81656534056,
      "times": [
        2.79029899656,
        2.7947187685599997,
        2.76596363656,
        2.7876678885599997,
        2.80058090756,
        2.78571044456,
        2.7722359005599997,
        2.75670365456,
        2.7839735535599996,
        2.81656534056
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.7869771640599996,
      "stddev": 0.034992410016748056,
      "median": 2.77911333556,
      "user": 1.7737336199999998,
      "system": 1.336711,
      "min": 2.7363568305599997,
      "max": 2.8526593975599996,
      "times": [
        2.79085090356,
        2.83245476756,
        2.8064555365599997,
        2.8526593975599996,
        2.78065753256,
        2.7631286995599997,
        2.7638472685599997,
        2.7363568305599997,
        2.76579156556,
        2.77756913856
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.65694032376,
      "stddev": 0.18433106209913105,
      "median": 1.6316476075600002,
      "user": 1.07797352,
      "system": 1.2414329,
      "min": 1.43960722956,
      "max": 1.9666940745600001,
      "times": [
        1.46866202356,
        1.6890883595600001,
        1.9666940745600001,
        1.7864548855600002,
        1.8028107395600002,
        1.57357645256,
        1.44277086356,
        1.5742068555600002,
        1.8255317535600002,
        1.43960722956
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5704806816599999,
      "stddev": 0.157616736815579,
      "median": 1.5058918290599999,
      "user": 1.09305272,
      "system": 1.1626301,
      "min": 1.42671407556,
      "max": 1.8720625345600002,
      "times": [
        1.50616976556,
        1.4303074395600002,
        1.8149204255600002,
        1.6565159745600002,
        1.42671407556,
        1.48929478056,
        1.50561389256,
        1.52087471156,
        1.48233321656,
        1.8720625345600002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 637.7 ± 25.0 604.4 671.8 2.08 ± 0.10
pacquet@main 598.3 ± 47.7 556.6 725.5 1.96 ± 0.17
pnpr@HEAD 306.0 ± 9.1 294.5 317.8 1.00
pnpr@main 322.7 ± 8.1 312.4 338.0 1.05 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6377376554199998,
      "stddev": 0.024950382739157822,
      "median": 0.6444320001199999,
      "user": 0.78711726,
      "system": 0.69463436,
      "min": 0.60439003462,
      "max": 0.67183812362,
      "times": [
        0.66439860162,
        0.6451812716199999,
        0.64707525462,
        0.67183812362,
        0.65831706962,
        0.62929231462,
        0.60439003462,
        0.60499290562,
        0.60820824962,
        0.64368272862
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.59829271102,
      "stddev": 0.047718295185790856,
      "median": 0.59022445262,
      "user": 0.7298072600000001,
      "system": 0.66863216,
      "min": 0.55661874162,
      "max": 0.72548576362,
      "times": [
        0.59476095562,
        0.59298379062,
        0.58746511462,
        0.57211077162,
        0.56969735262,
        0.72548576362,
        0.55661874162,
        0.60839415862,
        0.60489849862,
        0.57051196262
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30601121412,
      "stddev": 0.009075486860824504,
      "median": 0.30654622762000006,
      "user": 0.20779606,
      "system": 0.5223246600000001,
      "min": 0.29447213662000005,
      "max": 0.31777285062000005,
      "times": [
        0.31777285062000005,
        0.31081626562000003,
        0.29955225962000004,
        0.29447213662000005,
        0.29591104562000003,
        0.31730828762,
        0.30879037362,
        0.29652821462,
        0.31465862562,
        0.30430208162000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.32266848802000003,
      "stddev": 0.008107159488188062,
      "median": 0.32072721362,
      "user": 0.21418435999999996,
      "system": 0.54978966,
      "min": 0.31238898862000003,
      "max": 0.33799196762000006,
      "times": [
        0.31828787962000005,
        0.32603547862000004,
        0.31690705062,
        0.31238898862000003,
        0.31973234762,
        0.33799196762000006,
        0.32182759662000004,
        0.33473550162000004,
        0.32172207962000005,
        0.31705598962000003
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.964 ± 0.043 1.926 2.076 6.65 ± 0.20
pacquet@main 1.913 ± 0.014 1.889 1.934 6.48 ± 0.14
pnpr@HEAD 0.295 ± 0.006 0.285 0.305 1.00
pnpr@main 0.311 ± 0.007 0.301 0.326 1.05 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.963722705,
      "stddev": 0.0428418113232632,
      "median": 1.9515746853000002,
      "user": 1.0368162,
      "system": 0.7696482,
      "min": 1.9257668308000002,
      "max": 2.0756338968,
      "times": [
        1.9660167768,
        1.9436917748,
        1.9446223788,
        1.9630484308000002,
        1.9257668308000002,
        1.9319416798,
        1.9833559108,
        2.0756338968,
        1.9583422848,
        1.9448070858000002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.9131928731999999,
      "stddev": 0.01351692427213345,
      "median": 1.9128934263000001,
      "user": 0.9644486999999999,
      "system": 0.7431092000000001,
      "min": 1.8891082638,
      "max": 1.9339151758000002,
      "times": [
        1.9246241388,
        1.9269396828,
        1.9193314158,
        1.9105316148,
        1.9073013028,
        1.9032218778,
        1.8891082638,
        1.9017000218,
        1.9152552378,
        1.9339151758000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29545281700000003,
      "stddev": 0.00606439152127806,
      "median": 0.2969094588,
      "user": 0.1903279,
      "system": 0.4912800999999999,
      "min": 0.2846039238,
      "max": 0.30487932980000004,
      "times": [
        0.2989901988,
        0.29242973780000003,
        0.2950147698,
        0.30487932980000004,
        0.29760749280000004,
        0.2997993668,
        0.2962114248,
        0.29801834580000003,
        0.2846039238,
        0.2869735798
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.3113332331,
      "stddev": 0.0066463340659391155,
      "median": 0.3104100033,
      "user": 0.215197,
      "system": 0.5436356,
      "min": 0.3008926878,
      "max": 0.32585499980000004,
      "times": [
        0.3144869878,
        0.30899825880000004,
        0.30687169880000004,
        0.3069935668,
        0.3008926878,
        0.3158235958,
        0.32585499980000004,
        0.31019553580000003,
        0.3106244708,
        0.31259052880000004
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 375.1 ± 25.8 343.7 428.3 4.35 ± 0.32
pacquet@main 365.9 ± 9.7 349.8 378.2 4.24 ± 0.16
pnpr@HEAD 86.2 ± 2.3 81.9 90.3 1.00
pnpr@main 87.2 ± 0.9 84.9 88.3 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.37507816128,
      "stddev": 0.025788626410388354,
      "median": 0.37409759268000004,
      "user": 0.36729910000000004,
      "system": 0.060870539999999994,
      "min": 0.34366684468,
      "max": 0.42832236568000004,
      "times": [
        0.42832236568000004,
        0.39448125868000006,
        0.39459601068000005,
        0.36265932668000006,
        0.3784188666800001,
        0.34892559068000006,
        0.37407470468000004,
        0.37412048068000003,
        0.35151616368000005,
        0.34366684468
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.3658855810800001,
      "stddev": 0.009657802693326915,
      "median": 0.36641031268,
      "user": 0.3573326,
      "system": 0.057653640000000006,
      "min": 0.34977292368000007,
      "max": 0.3782355726800001,
      "times": [
        0.34977292368000007,
        0.35094050368000007,
        0.3782355726800001,
        0.37595047468000004,
        0.36941965968000007,
        0.36629179068000006,
        0.36444599668000005,
        0.37465171768000005,
        0.36652883468,
        0.36261833668000004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08620611496125,
      "stddev": 0.0023329054468315268,
      "median": 0.08679725868,
      "user": 0.019734906249999996,
      "system": 0.009692866875,
      "min": 0.08185144368000001,
      "max": 0.09028334568,
      "times": [
        0.08945033268000001,
        0.08500620368,
        0.08987279468,
        0.08877405368,
        0.08654073268000001,
        0.08969814668000001,
        0.08595373068,
        0.08758720568,
        0.08559592068,
        0.08194858568,
        0.08324251368,
        0.08730332368,
        0.08685565268,
        0.08322890768,
        0.08754983568000001,
        0.08720563968,
        0.08723326268,
        0.08221401368,
        0.08436925768,
        0.08672840568000001,
        0.08721233268,
        0.08692785868000001,
        0.08753716168,
        0.08673886468,
        0.08691791968000001,
        0.09028334568,
        0.08707575668,
        0.08541454968000001,
        0.08621466068,
        0.08185144368000001,
        0.08302564668000001,
        0.08303761868000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08719352880121213,
      "stddev": 0.0008524595104409554,
      "median": 0.08721319468000001,
      "user": 0.01942263636363636,
      "system": 0.01050655393939394,
      "min": 0.08485335668,
      "max": 0.08829338168,
      "times": [
        0.08583759368,
        0.08829338168,
        0.08724550468,
        0.08654540168000001,
        0.08630860668000001,
        0.08721319468000001,
        0.08734387868,
        0.08667023568,
        0.08678179468000001,
        0.08710710568,
        0.08707636768,
        0.08765407168,
        0.08756770968000001,
        0.08718294768000001,
        0.08767453068,
        0.08527259268000001,
        0.08788209968,
        0.08708789968000001,
        0.08785781368000001,
        0.08822121668,
        0.08703457968,
        0.08678909868000001,
        0.08666020668,
        0.08783326868,
        0.08716107668,
        0.08828909268,
        0.08608198168,
        0.08813452268000001,
        0.08772413368000001,
        0.08822061468,
        0.08752461868,
        0.08485335668,
        0.08825595168
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.555 ± 0.138 4.439 4.810 1.28 ± 0.05
pacquet@main 4.563 ± 0.132 4.459 4.856 1.29 ± 0.05
pnpr@HEAD 3.550 ± 0.083 3.449 3.717 1.00
pnpr@main 3.569 ± 0.124 3.455 3.778 1.01 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.554857967219999,
      "stddev": 0.13795111791217968,
      "median": 4.49197866982,
      "user": 1.92294858,
      "system": 1.4751998,
      "min": 4.43945253482,
      "max": 4.80962164282,
      "times": [
        4.45231050582,
        4.46211957482,
        4.43945253482,
        4.57857130182,
        4.6024072578199995,
        4.45334514282,
        4.77664935182,
        4.52183776482,
        4.80962164282,
        4.45226459482
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.56300351092,
      "stddev": 0.1315751955883205,
      "median": 4.51035723682,
      "user": 1.9450809799999995,
      "system": 1.4798079,
      "min": 4.45870255382,
      "max": 4.8558430998199995,
      "times": [
        4.51827885682,
        4.65771402682,
        4.51905646382,
        4.8558430998199995,
        4.49180042982,
        4.50243561682,
        4.69745841182,
        4.46394767682,
        4.45870255382,
        4.46479797282
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.55030827152,
      "stddev": 0.08346849346685316,
      "median": 3.53679559282,
      "user": 1.26243358,
      "system": 1.3148723999999998,
      "min": 3.4489697438199998,
      "max": 3.71690668882,
      "times": [
        3.5576868248199998,
        3.71690668882,
        3.53985152882,
        3.53677330182,
        3.67399205782,
        3.51277160782,
        3.4489697438199998,
        3.53681788382,
        3.48311984182,
        3.49619323582
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5685199626199995,
      "stddev": 0.12425720327080687,
      "median": 3.4979049883199997,
      "user": 1.30748848,
      "system": 1.2866431,
      "min": 3.4547931518199997,
      "max": 3.77848968782,
      "times": [
        3.4547931518199997,
        3.65213529382,
        3.4686358398199997,
        3.75380913982,
        3.5064338138199997,
        3.47143423082,
        3.4893761628199997,
        3.62829231982,
        3.77848968782,
        3.48179998582
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13281
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,756.70 ms
(-5.04%)Baseline: 2,903.06 ms
3,483.68 ms
(79.13%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,925.77 ms
(-6.11%)Baseline: 2,051.19 ms
2,461.43 ms
(78.24%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
604.39 ms
(-14.45%)Baseline: 706.44 ms
847.73 ms
(71.30%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
343.67 ms
(-21.45%)Baseline: 437.50 ms
525.00 ms
(65.46%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,360.16 ms
(-4.02%)Baseline: 2,459.07 ms
2,950.89 ms
(79.98%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,439.45 ms
(-2.47%)Baseline: 4,552.00 ms
5,462.40 ms
(81.27%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
247.82 ms
(-17.35%)Baseline: 299.83 ms
359.79 ms
(68.88%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13281
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,439.61 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
284.60 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
294.47 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
81.85 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,353.78 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,448.97 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
253.29 ms
🐰 View full continuous benchmarking report in Bencher

…laced

`is_global` reassembles pnpm's CLI-wide `--global` from eleven
per-subcommand flags, but only `add` was tested — the doc comment
described the rest instead of asserting it. Drive the conflict check from
a table of every subcommand declaring the flag, plus a counter-case that
subcommands without it still accept `-w`. Dropping any arm of `is_global`
now fails with that subcommand named.

The table also records that `approve-builds` declares `--global` with no
`-g` short form, unlike its peers.

With behavior asserted, the comments describing it are redundant: cut 40
lines of prose that restated test names, listed helper bodies, or repeated
the same pnpm-parity rationale in three places. What stays is what no test
can express — the call-ordering contract, why the real-path resolution
exists (case-insensitive filesystems), and the one canonical note that the
root selector is additive rather than an override.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 25, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9a07a02

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit a8a2325 into main Jul 25, 2026
32 checks passed
@zkochan
zkochan deleted the fix-13031 branch July 25, 2026 09:21
zkochan added a commit that referenced this pull request Jul 25, 2026
…kspace (#13297)

`pnpm --dir ../../elsewhere add -w foo` from inside a workspace added to
that workspace's root instead of failing, when `../../elsewhere` did not
exist. pnpm reports ERR_PNPM_NOT_IN_WORKSPACE.

`apply_workspace_root` falls back to `std::path::absolute` when the `--dir`
cannot be canonicalized, which is what keeps a nonexistent `--dir` inside
the workspace working. On Unix that leaves `..` components in place, and
`find_workspace_dir` walks ancestors lexically — so the walk climbed back
up through the very `..` components that had taken it out of the workspace
and found the workspace it had just left.

Resolve `..` in the fallback with `pacquet_fs::lexical_normalize` (the
existing filesystem-free normalizer) before the walk. A nonexistent `--dir`
that stays inside the workspace still resolves to the root, and an existing
directory outside it still errors — both already covered by tests.

Found by CodeRabbit on #13294, a duplicate of #13281
closed in favor of it; the finding applies to the merged implementation.
Verified against the TypeScript CLI: all three `--dir` shapes now agree.
@coderabbitai coderabbitai Bot mentioned this pull request Jul 25, 2026
3 tasks done
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…kspace (pnpm#13297)

`pnpm --dir ../../elsewhere add -w foo` from inside a workspace added to
that workspace's root instead of failing, when `../../elsewhere` did not
exist. pnpm reports ERR_PNPM_NOT_IN_WORKSPACE.

`apply_workspace_root` falls back to `std::path::absolute` when the `--dir`
cannot be canonicalized, which is what keeps a nonexistent `--dir` inside
the workspace working. On Unix that leaves `..` components in place, and
`find_workspace_dir` walks ancestors lexically — so the walk climbed back
up through the very `..` components that had taken it out of the workspace
and found the workspace it had just left.

Resolve `..` in the fallback with `pacquet_fs::lexical_normalize` (the
existing filesystem-free normalizer) before the walk. A nonexistent `--dir`
that stays inside the workspace still resolves to the root, and an existing
directory outside it still errors — both already covered by tests.

Found by CodeRabbit on pnpm#13294, a duplicate of pnpm#13281
closed in favor of it; the finding applies to the merged implementation.
Verified against the TypeScript CLI: all three `--dir` shapes now agree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 12: adding multiple packages is failing

3 participants