Skip to content

fix(cli): forward the argument separator to the script - #13303

Closed
zkochan wants to merge 1 commit into
mainfrom
fix-13295-run-separator
Closed

zkochan wants to merge 1 commit into
mainfrom
fix-13295-run-separator

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

pnpm run <script> -- <args> dropped the --, so the program a script invokes read the following tokens as its own options. The reported case turns a working command into a hard failure:

$ pnpm run show -- --other=1        # script: node -e "…"

pnpm:    $ node -e "…" -- --other=1   →  ARGS:["--other=1"]        exit 0
pacquet: $ node -e "…" --other=1      →  node: bad option: --other=1  exit 9

The loss is at parse time, not in the executor: clap treats the first -- as its own escape token and removes it. run is exposed because its script name is a separate single-value positional — once that is consumed, clap is no longer mid-positional and the next -- is taken as the escape. exec collects its whole command into one trailing_var_arg positional, which is why it was never affected, and why a separator that follows an argument (pnpm run build x -- y) already survived.

This restores it in argv space, where the neighbouring shorthands and flag_relocation passes already normalize argv for clap: write a second -- at that position, so the token clap consumes is the inserted one and the user's own separator reaches the script.

stop and restart pass script arguments through the same shape and are covered too.

Verified against the TypeScript CLI

Every form checked by running both binaries against a script that prints its own argv (node args.js → OUT:[…]):

invocation pnpm pacquet before pacquet after
run mytask -- --other=1 ["--","--other=1"] ["--other=1"] ["--","--other=1"]
run mytask -- -x a ["--","-x","a"] ["-x","a"] ["--","-x","a"]
run mytask x -- y ["x","--","y"] ["x","--","y"] ["x","--","y"]
run mytask -- x -- y ["--","x","--","y"] ["x","--","y"] ["--","x","--","y"]
run mytask a b ["a","b"] ["a","b"] ["a","b"]
mytask -- --other=1 ["--","--other=1"] ["--","--other=1"] ["--","--other=1"]
stop -- --other=1 ["--","--other=1"] ["--other=1"] ["--","--other=1"]
stop x -- y ["x","--","y"] ["x","--","y"] ["x","--","y"]

Tests

Unit tests cover the argv transformation (leading separator doubled, non-leading left alone, options stepped over, non-script commands untouched, pnpm run with no script name untouched). Two integration tests assert on the arguments the script receives rather than on the echoed command line — that is what catches the separator going missing. I confirmed run_forwards_the_argument_separator_to_the_script fails when the pass is disabled, and that run_keeps_a_separator_that_follows_an_argument still passes then, so it genuinely pins the "don't double it" half.

Not included

pnpm test and pnpm start accept no trailing arguments at all — pnpm test --watch fails with a usage error. That is a different defect (arguments not accepted, rather than the separator dropped) and is filed as #13301. script_separator.rs notes the two commands so whoever implements it knows to extend the list.

Closes #13295

Squash Commit Body

pnpm appends every token after a script's name to the script, the `--`
included, so the program the script invokes reads what follows as operands.
clap instead treats the first `--` as its own escape and drops it:

    $ pnpm run show -- --other=1
    pnpm:    node -e "…" -- --other=1   -> ARGS:["--other=1"]
    pacquet: node -e "…" --other=1      -> node: bad option: --other=1

Only the separator in the first argument position is affected. clap keeps
later ones as ordinary values, because a trailing-var-arg positional that
has started taking values no longer treats `--` as an escape — the same
reason `exec`, whose whole command is one such positional, never lost it.

Preserve it in argv space, the way the neighbouring shorthand and
flag-relocation passes already normalize argv for clap: write a second
`--` at that position so the token clap consumes is the inserted one.
`stop` and `restart` take script arguments through the same shape and are
covered too; `test` and `start` accept no trailing arguments at all, which
is pnpm/pnpm#13301.

Closes pnpm/pnpm#13295

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • 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.
  • Updated the documentation if needed.

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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed pnpm run, pnpm stop, and pnpm restart so -- is correctly forwarded to the underlying script.
    • Arguments after -- are no longer incorrectly interpreted as options by the package manager or executed command.
    • Preserved expected behavior when -- appears as a regular script argument.
  • Tests

    • Added coverage for argument forwarding across supported script commands and command-line layouts.

pnpm appends every token after a script's name to the script, the `--`
included, so the program the script invokes reads what follows as operands.
clap instead treats the first `--` as its own escape and drops it:

    $ pnpm run show -- --other=1
    pnpm:    node -e "…" -- --other=1   -> ARGS:["--other=1"]
    pacquet: node -e "…" --other=1      -> node: bad option: --other=1

Only the separator in the first argument position is affected. clap keeps
later ones as ordinary values, because a trailing-var-arg positional that
has started taking values no longer treats `--` as an escape — the same
reason `exec`, whose whole command is one such positional, never lost it.

Preserve it in argv space, the way the neighbouring shorthand and
flag-relocation passes already normalize argv for clap: write a second
`--` at that position so the token clap consumes is the inserted one.
`stop` and `restart` take script arguments through the same shape and are
covered too; `test` and `start` accept no trailing arguments at all, which
is #13301.

Closes #13295

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

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 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI now preserves -- between script names and script arguments by transforming argv before clap parsing. Coverage includes run, stop, and restart layouts, plus unit and Unix integration tests verifying separator forwarding.

Changes

Script separator forwarding

Layer / File(s) Summary
CLI argv preservation
pnpm/crates/cli/src/lib.rs, pnpm/crates/cli/src/script_separator.rs
Registers separator handling before clap matching, locates script arguments across supported command layouts, and inserts a clap escape separator while retaining the user-provided separator for the script.
Separator regression coverage
pnpm/crates/cli/src/script_separator/tests.rs, pnpm/crates/cli/tests/run.rs, .changeset/pacquet-run-argument-separator.md
Tests command variants and verifies that executed scripts receive the expected -- arguments. Documents the behavior change.

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

Assessment against linked issues

Objective Addressed Explanation
Preserve -- for pnpm run <script> -- <args> so script arguments reach the underlying program [#13295] ✅
Keep pnpm exec unaffected [#13295] ✅

Out-of-scope changes

Code Change Explanation
Apply separator preservation to stop and restart (pnpm/crates/cli/src/script_separator.rs:19-64) Issue #13295 scopes the defect to run; the linked issue explicitly states that exec is unaffected and does not require changes to stop or restart.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as run_cli
  participant Preserver as preserve_script_separator
  participant Clap as clap
  participant Script as executed script
  CLI->>Preserver: transform command argv
  Preserver->>Clap: provide inserted escape separator
  Clap->>Script: forward user-provided separator and arguments
Loading

Possibly related issues

  • pnpm/pnpm#13302 — Addresses related pre-clap argv boundary handling for script commands.

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-13295-run-separator

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

Fix pnpm run/stop/restart to preserve -- script argument separator

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Preserve a leading -- after script name so scripts receive the separator token.
• Add an argv normalization pass integrated into the CLI pre-clap pipeline.
• Add unit + integration coverage asserting on arguments received by scripts.
Diagram

graph TD
  A["Raw argv"] --> B["shorthands"] --> C["flag relocation"] --> D["script separator"] --> E["clap parse"] --> F["CliArgs"] --> G["run/stop/restart executor"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Change clap command shape (e.g., trailing var arg for script args)
  • ➕ Potentially avoids argv mutation by making clap treat -- as value
  • ➖ Harder to model because run has a single-value script name positional before trailing args
  • ➖ Risk of changing other clap parsing semantics (options vs positionals) across commands
2. Manual post-parse reconstruction of script argv (reinsert `--` when missing)
  • ➕ Keeps clap input untouched; logic applied only for script execution
  • ➖ Requires reliably detecting when clap consumed the separator, which is brittle across command variants
  • ➖ Spreads separator-specific semantics into executors instead of a single argv-normalization place
3. Custom mini-parser for `run/stop/restart` before clap
  • ➕ Full control over separator handling and script argv boundaries
  • ➖ Duplicates parsing responsibilities already handled by clap and existing normalization passes
  • ➖ Higher maintenance burden and risk of drift vs other commands

Recommendation: Current approach (argv-space normalization that duplicates a leading --) is the best tradeoff: it’s localized, consistent with existing shorthands/flag-relocation passes, and keeps clap + executors mostly unchanged while matching pnpm’s semantics.

Files changed (5) +243 / -0

Bug fix (2) +107 / -0
lib.rsWire new script-separator argv normalization into CLI startup +4/-0

Wire new script-separator argv normalization into CLI startup

• Registers the new 'script_separator' module and runs 'preserve_script_separator' after flag relocation but before clap parsing. Ensures the separator preservation happens in the same pre-clap normalization phase as other argv fixes.

pnpm/crates/cli/src/lib.rs

script_separator.rsImplement argv pass to preserve leading '--' for script commands +103/-0

Implement argv pass to preserve leading '--' for script commands

• Introduces 'preserve_script_separator' to detect 'run/stop/restart' and duplicate a leading '--' after the script name so clap consumes the inserted token instead of the user’s. Includes token-walking logic that skips global/subcommand options and their values while locating the relevant separator.

pnpm/crates/cli/src/script_separator.rs

Tests (2) +131 / -0
tests.rsUnit tests for separator-preservation argv transformation +73/-0

Unit tests for separator-preservation argv transformation

• Adds focused tests covering: doubling only a leading separator, leaving later separators intact, stepping over options (including global ones), handling 'stop/restart', and ensuring non-script commands and missing-script 'run' remain unchanged.

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

run.rsIntegration tests asserting script-received argv preserves '--' +58/-0

Integration tests asserting script-received argv preserves '--'

• Adds Unix-only integration tests that run a script which records its received arguments to a file. Verifies 'run <script> -- ...' forwards a literal '--' token, and that a separator after an argument is not doubled.

pnpm/crates/cli/tests/run.rs

Documentation (1) +5 / -0
pacquet-run-argument-separator.mdAdd changeset documenting '--' forwarding fix for run/stop/restart +5/-0

Add changeset documenting '--' forwarding fix for run/stop/restart

• Adds a patch changeset describing that 'pnpm run <script> -- <args>' now forwards the '--' separator to the script. Notes the prior failure mode where downstream programs interpreted flags as their own options.

.changeset/pacquet-run-argument-separator.md

@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.

🧹 Nitpick comments (1)
pnpm/crates/cli/src/script_separator.rs (1)

23-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use regular comments for private implementation and test rationale.

  • pnpm/crates/cli/src/script_separator.rs#L23-L30: Change /// to // for the private command tables.
  • pnpm/crates/cli/tests/run.rs#L666-L671: Change the private test rationale to a regular comment.
  • pnpm/crates/cli/tests/run.rs#L697-L698: Change the private test rationale to a regular comment.

As per coding guidelines, rustdoc comments are for public API contracts, while implementation rationale uses regular comments.

🤖 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/src/script_separator.rs` around lines 23 - 30, Replace the
rustdoc comments with regular comments for the private command tables
SCRIPT_COMMANDS and TAKES_SCRIPT_NAME in
pnpm/crates/cli/src/script_separator.rs:23-30, and for the private test
rationale comments in pnpm/crates/cli/tests/run.rs:666-671 and
pnpm/crates/cli/tests/run.rs:697-698; preserve all comment text and behavior.

Sources: Coding guidelines, 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.

Nitpick comments:
In `@pnpm/crates/cli/src/script_separator.rs`:
- Around line 23-30: Replace the rustdoc comments with regular comments for the
private command tables SCRIPT_COMMANDS and TAKES_SCRIPT_NAME in
pnpm/crates/cli/src/script_separator.rs:23-30, and for the private test
rationale comments in pnpm/crates/cli/tests/run.rs:666-671 and
pnpm/crates/cli/tests/run.rs:697-698; preserve all comment text and behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 33fcff5e-671a-452e-974a-319a02f0696e

📥 Commits

Reviewing files that changed from the base of the PR and between 9675da4 and d9e34ef.

📒 Files selected for processing (5)
  • .changeset/pacquet-run-argument-separator.md
  • pnpm/crates/cli/src/lib.rs
  • pnpm/crates/cli/src/script_separator.rs
  • pnpm/crates/cli/src/script_separator/tests.rs
  • pnpm/crates/cli/tests/run.rs

@github-actions

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.01     10.6±0.16ms    35.4 MB/sec    1.00     10.4±0.16ms    35.9 MB/sec
packument/parse                1.02     36.7±0.74µs  1806.6 MB/sec    1.00     36.0±0.58µs  1840.4 MB/sec
tarball/download_dependency    1.00      2.8±0.10ms  1573.9 KB/sec    1.01      2.8±0.12ms  1565.5 KB/sec

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Redundant ArgTable rebuilds 🐞 Bug ➹ Performance
Description
run_cli() now runs script_separator::preserve_script_separator(), which rebuilds
ArgTable::top_level() and ArgTable::subcommand_union() even though identical tables were already
constructed in the immediately preceding shorthands and flag-relocation passes. This adds avoidable
CPU work to every CLI invocation (including non-script commands) during startup parsing.
Code

pnpm/crates/cli/src/lib.rs[R68-70]

+    // pnpm gives a script every token after its name, `--` included; clap
+    // would eat that `--` as its own escape. See `script_separator`.
+    let argv = script_separator::preserve_script_separator(&command, argv);
Relevance

⭐⭐ Medium

Perf/micro-optimization request; team sometimes rejects “avoid extra work” refactors without strong
need.

PR-#13150

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The CLI startup sequence now includes a third argv-normalization pass, and each of the three passes
constructs ArgTable::top_level() and ArgTable::subcommand_union(), which iterates all
subcommands and their arguments; this is redundant work introduced by this PR.

pnpm/crates/cli/src/lib.rs[59-70]
pnpm/crates/cli/src/shorthands.rs[29-32]
pnpm/crates/cli/src/flag_relocation.rs[76-79]
pnpm/crates/cli/src/script_separator.rs[32-35]
pnpm/crates/cli/src/flag_relocation.rs[185-191]

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

## Issue description
`preserve_script_separator()` constructs fresh `ArgTable` instances by walking the clap command/subcommand argument graph, but `expand_universal_shorthands()` and `relocate_pre_subcommand_flags()` already do the same work. This repeats the same traversal 3× during CLI startup.

## Issue Context
This is on the synchronous startup path for every pacquet invocation (`run_cli()`), so even small amounts of extra work can accumulate. The new script-separator behavior is correct; the issue is the redundant recomputation.

## Fix Focus Areas
- pnpm/crates/cli/src/lib.rs[59-70]
- pnpm/crates/cli/src/script_separator.rs[32-35]
- pnpm/crates/cli/src/shorthands.rs[29-32]
- pnpm/crates/cli/src/flag_relocation.rs[76-79]

## Implementation sketch
- Build `ArgTable::top_level(&command)` and `ArgTable::subcommand_union(&command)` once in `run_cli()` and pass references into:
 - `expand_universal_shorthands(...)`
 - `relocate_pre_subcommand_flags(...)`
 - `preserve_script_separator(...)`
- Alternatively, introduce a small shared struct (e.g. `ArgTables { top_level, subcommand_union }`) and pass that through the normalization pipeline.
- Keep the existing early-return logic in `preserve_script_separator()`, but avoid paying the table-construction cost before deciding whether the subcommand is relevant.

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



Informational

2. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset front-matter only declares a pacquet bump and omits pnpm, which violates the
requirement that changesets explicitly include a pnpm entry with a valid bump type. This can cause
the pnpm release tooling to miss or misclassify the intended version bump.
Code

.changeset/pacquet-run-argument-separator.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Close precedents show adding required pnpm entry to pacquet-only changesets is repeatedly
rejected.

PR-#12981
PR-#12991
PR-#13117

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to include an entry for the pnpm package
with a valid bump type. The added changeset front-matter contains only "pacquet": patch and no
pnpm entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-run-argument-separator.md[1-3]

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

## Issue description
The changeset `.changeset/pacquet-run-argument-separator.md` does not include a `pnpm` entry in its front-matter, but the compliance rule requires that changesets explicitly declare `pnpm` with a valid bump type (`patch`/`minor`/`major`).

## Issue Context
This PR introduces a user-visible CLI behavior fix and already adds a changeset, but the front-matter currently only lists `pacquet`.

## Fix Focus Areas
- .changeset/pacquet-run-argument-separator.md[1-3]

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


Grey Divider

Qodo Logo

@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5

This PR should not merge until separators following option-shaped script arguments are left unchanged.

The new scanner does not recognize that a hyphenated token after the script name has already started the trailing argument vector, so it can insert an additional separator and alter the script’s argv.

Files Needing Attention: pnpm/crates/cli/src/script_separator.rs

Reviews (1): Last reviewed commit: "fix(cli): forward the argument separator..." | Re-trigger Greptile

Comment on lines +80 to +89
if let Some(rest) = token.strip_prefix("--") {
let (name, has_inline_value) =
rest.split_once('=').map_or((rest, false), |(name, _)| (name, true));
let consumes_value = top_level
.long_consumes_value(name)
.or_else(|| subcommand_union.long_consumes_value(name))
.unwrap_or(false);
index += token_width(consumes_value, has_inline_value);
} else if let Some(rest) = token.strip_prefix('-').filter(|rest| !rest.is_empty()) {
let short = rest.chars().next().expect("checked non-empty");

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.

P1 Later separator gets duplicated

When an option-shaped token is the script’s first argument, such as pnpm run build --flag -- value, next_token skips that valid trailing argument and treats the later separator as leading, causing the script to receive an extra -- and changing its argv.

@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.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.07692% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.02%. Comparing base (069bc0f) to head (d9e34ef).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/script_separator.rs 98.03% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13303      +/-   ##
==========================================
+ Coverage   86.96%   87.02%   +0.05%     
==========================================
  Files         530      532       +2     
  Lines       90954    91494     +540     
==========================================
+ Hits        79099    79621     +522     
- Misses      11855    11873      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: d9e34ef9fb2d

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.480 ± 0.157 2.352 2.751 1.64 ± 0.20
pacquet@main 2.566 ± 0.131 2.353 2.758 1.70 ± 0.19
pnpr@HEAD 1.596 ± 0.142 1.405 1.774 1.06 ± 0.14
pnpr@main 1.510 ± 0.154 1.351 1.762 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4799319895800003,
      "stddev": 0.15747520029590156,
      "median": 2.3917111994800004,
      "user": 1.5359181799999997,
      "system": 1.2921285999999998,
      "min": 2.35226426548,
      "max": 2.75101741248,
      "times": [
        2.38498351648,
        2.44095278248,
        2.38281662948,
        2.35226426548,
        2.3726034614800002,
        2.74784531448,
        2.75101741248,
        2.59250188348,
        2.3984388824800003,
        2.37589574748
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.56553315518,
      "stddev": 0.13078709346542777,
      "median": 2.54558781898,
      "user": 1.54598738,
      "system": 1.306613,
      "min": 2.35305446948,
      "max": 2.7576015124800004,
      "times": [
        2.67835905648,
        2.66129362648,
        2.52388374148,
        2.43719266248,
        2.53952902948,
        2.7576015124800004,
        2.45249105848,
        2.70027978648,
        2.55164660848,
        2.35305446948
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.59625822318,
      "stddev": 0.14232208944604058,
      "median": 1.63966027048,
      "user": 1.05873718,
      "system": 1.1371481,
      "min": 1.40513550948,
      "max": 1.7742677174800001,
      "times": [
        1.4506974784800002,
        1.7041838174800001,
        1.76287156348,
        1.6331319664800001,
        1.4290773384800002,
        1.47590519948,
        1.40513550948,
        1.68112306648,
        1.7742677174800001,
        1.64618857448
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.51033518358,
      "stddev": 0.1539341148878107,
      "median": 1.4617685699800003,
      "user": 1.05609548,
      "system": 1.1151617,
      "min": 1.3514630594800001,
      "max": 1.7623643504800002,
      "times": [
        1.3858274294800002,
        1.4891457524800003,
        1.53444042948,
        1.3514630594800001,
        1.43439138748,
        1.6627949294800002,
        1.37259638848,
        1.7623643504800002,
        1.3878806844800002,
        1.72244742448
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 252.5 ± 7.4 243.8 266.0 1.00
pacquet@main 257.0 ± 5.7 250.2 267.9 1.02 ± 0.04
pnpr@HEAD 269.9 ± 6.4 261.7 280.5 1.07 ± 0.04
pnpr@main 268.0 ± 5.4 260.3 276.9 1.06 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25254533404,
      "stddev": 0.007395201202495003,
      "median": 0.25138778774000003,
      "user": 0.20592497999999998,
      "system": 0.51584186,
      "min": 0.24380452374,
      "max": 0.26603443974,
      "times": [
        0.24380452374,
        0.25381466774,
        0.25265699074000003,
        0.24691400474000003,
        0.25976520374,
        0.26020104474,
        0.24588150174,
        0.25011858474000004,
        0.24626237874,
        0.26603443974
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25695951164,
      "stddev": 0.005660673032140107,
      "median": 0.25642030124000004,
      "user": 0.20939037999999996,
      "system": 0.51900666,
      "min": 0.25023962174000003,
      "max": 0.26790210474000004,
      "times": [
        0.25116542374,
        0.25693794474000003,
        0.26119683874,
        0.26039049974,
        0.25023962174000003,
        0.26790210474000004,
        0.25038656874000004,
        0.25590265774000004,
        0.26044454274,
        0.25502891374000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26992545514000005,
      "stddev": 0.006361785878832161,
      "median": 0.26835924474,
      "user": 0.21958487999999998,
      "system": 0.52832526,
      "min": 0.26169966474,
      "max": 0.28053568474,
      "times": [
        0.26891832674,
        0.26575575574,
        0.27628188074000004,
        0.26169966474,
        0.27037982574,
        0.26780016274,
        0.28053568474,
        0.26396343374000003,
        0.27815096674,
        0.26576884974000003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.26799158554,
      "stddev": 0.005424464127629831,
      "median": 0.26751280174000003,
      "user": 0.21036267999999997,
      "system": 0.53199346,
      "min": 0.26027244774,
      "max": 0.27689839074,
      "times": [
        0.27195778474000004,
        0.27238473874,
        0.26027244774,
        0.26143248174,
        0.26694406074,
        0.27266314274000003,
        0.27689839074,
        0.26575149774,
        0.26808154274,
        0.26352976774000003
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.780 ± 0.014 2.760 2.800 1.78 ± 0.20
pacquet@main 2.773 ± 0.015 2.752 2.798 1.78 ± 0.20
pnpr@HEAD 1.609 ± 0.107 1.456 1.769 1.03 ± 0.13
pnpr@main 1.558 ± 0.172 1.423 1.861 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7803334053,
      "stddev": 0.013687758452649555,
      "median": 2.779842376,
      "user": 1.7043607600000001,
      "system": 1.30627712,
      "min": 2.7596878124999997,
      "max": 2.7995207614999997,
      "times": [
        2.7652716004999998,
        2.7995207614999997,
        2.7817946785,
        2.7673537855,
        2.7985794105,
        2.7778900735,
        2.7596878124999997,
        2.7761348805,
        2.7897289415,
        2.7873721084999996
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.7725696735999996,
      "stddev": 0.015381784510168766,
      "median": 2.7689435435,
      "user": 1.74490556,
      "system": 1.2784935199999998,
      "min": 2.7523299435,
      "max": 2.7977916085,
      "times": [
        2.7585705414999997,
        2.7894891625,
        2.7745822904999997,
        2.7782336085,
        2.7880169515,
        2.7631008825,
        2.7977916085,
        2.7633047965,
        2.7523299435,
        2.7602769504999998
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6091078936000003,
      "stddev": 0.10705819443170744,
      "median": 1.6138099870000002,
      "user": 1.00793746,
      "system": 1.1264069200000002,
      "min": 1.4564397275,
      "max": 1.7685575005,
      "times": [
        1.5335575065,
        1.7685575005,
        1.5063604584999999,
        1.5109592085,
        1.5725020375,
        1.7201261955,
        1.7120545815000001,
        1.6554037835,
        1.4564397275,
        1.6551179365000002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5578355761,
      "stddev": 0.1719358941445709,
      "median": 1.4684427405,
      "user": 1.0614204600000001,
      "system": 1.1110642199999998,
      "min": 1.4226809185,
      "max": 1.8605440085,
      "times": [
        1.4239201295000001,
        1.4226809185,
        1.6943181605000002,
        1.4414406355,
        1.4780715375,
        1.5441780315,
        1.8272871925,
        1.8605440085,
        1.4588139435,
        1.4271012035000001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 586.2 ± 7.2 569.3 595.0 1.95 ± 0.04
pacquet@main 575.6 ± 11.9 563.2 603.5 1.91 ± 0.05
pnpr@HEAD 300.8 ± 4.9 291.7 308.3 1.00
pnpr@main 308.3 ± 4.9 301.3 315.2 1.03 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.58622929958,
      "stddev": 0.0072308788480290485,
      "median": 0.5861946703800001,
      "user": 0.7188079999999999,
      "system": 0.68276842,
      "min": 0.56928412238,
      "max": 0.59498767038,
      "times": [
        0.59127102838,
        0.59237451438,
        0.58452685338,
        0.59498767038,
        0.58586780538,
        0.58652153538,
        0.58522023738,
        0.59055712638,
        0.58168210238,
        0.56928412238
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5756006004800001,
      "stddev": 0.01193430480934997,
      "median": 0.57266727588,
      "user": 0.6894335,
      "system": 0.6707885199999999,
      "min": 0.56318606238,
      "max": 0.60352547838,
      "times": [
        0.58554111038,
        0.57246530538,
        0.56802425238,
        0.56794300038,
        0.57810864238,
        0.60352547838,
        0.56318606238,
        0.57286924638,
        0.56561490138,
        0.57872800538
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3007565280800001,
      "stddev": 0.004935804782758836,
      "median": 0.30066161538,
      "user": 0.19438869999999997,
      "system": 0.51962062,
      "min": 0.29171602338,
      "max": 0.30829657138000005,
      "times": [
        0.30128151638000006,
        0.30674735838000006,
        0.30004171438000005,
        0.29171602338,
        0.30338352038000005,
        0.29990825438,
        0.29575895938,
        0.30254146538000004,
        0.30829657138000005,
        0.29788989738000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30832383238000005,
      "stddev": 0.0049408348033697725,
      "median": 0.30789676538,
      "user": 0.19485009999999997,
      "system": 0.53830592,
      "min": 0.30126429438,
      "max": 0.31521938438,
      "times": [
        0.31376710138,
        0.30489981238,
        0.31164580238000006,
        0.30561891538,
        0.31521938438,
        0.31017461538,
        0.30126429438,
        0.30332188338000005,
        0.31278275138000006,
        0.30454376338000005
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.909 ± 0.009 1.894 1.918 6.36 ± 0.14
pacquet@main 1.909 ± 0.010 1.892 1.924 6.36 ± 0.15
pnpr@HEAD 0.300 ± 0.007 0.290 0.310 1.00
pnpr@main 0.306 ± 0.004 0.300 0.312 1.02 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9085260147600003,
      "stddev": 0.008661516394618913,
      "median": 1.90984379286,
      "user": 0.9416520599999998,
      "system": 0.73912958,
      "min": 1.8935894798600001,
      "max": 1.91813606986,
      "times": [
        1.91813606986,
        1.90655316386,
        1.9160971238600002,
        1.9060391968600001,
        1.90230789686,
        1.89752358786,
        1.8935894798600001,
        1.9131344218600002,
        1.91508313686,
        1.9167960698600002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.9091347090600004,
      "stddev": 0.010201059135156622,
      "median": 1.90885295586,
      "user": 0.9267155600000001,
      "system": 0.76774168,
      "min": 1.89248722586,
      "max": 1.92357007286,
      "times": [
        1.89248722586,
        1.90957232186,
        1.92006343486,
        1.9176012938600002,
        1.89924236786,
        1.90813358986,
        1.9161863548600002,
        1.92357007286,
        1.89939847986,
        1.90509194886
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29995101166000004,
      "stddev": 0.0066934913285807696,
      "median": 0.30049277936,
      "user": 0.18694726,
      "system": 0.53481168,
      "min": 0.28962228286,
      "max": 0.30975972786,
      "times": [
        0.29391381486,
        0.28962228286,
        0.30093337786,
        0.30379679186,
        0.29115614786,
        0.30005218086,
        0.30423386486000004,
        0.30711835086,
        0.30975972786,
        0.29892357686000004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.3055577114600001,
      "stddev": 0.004201284145571433,
      "median": 0.30661965286000004,
      "user": 0.19704335999999997,
      "system": 0.53945758,
      "min": 0.30008659486,
      "max": 0.31211907686,
      "times": [
        0.30675472686,
        0.30200075486,
        0.30648457886,
        0.30888348986,
        0.30008659486,
        0.30182821086,
        0.30029947586,
        0.30893484786000003,
        0.30818535786,
        0.31211907686
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 362.4 ± 7.9 354.3 383.6 4.17 ± 0.12
pacquet@main 358.2 ± 5.8 346.8 364.5 4.12 ± 0.10
pnpr@HEAD 87.0 ± 1.7 83.8 89.8 1.00 ± 0.03
pnpr@main 87.0 ± 1.6 82.4 89.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.36236037854,
      "stddev": 0.007937820330306091,
      "median": 0.36117519644000007,
      "user": 0.35501473999999994,
      "system": 0.054260199999999995,
      "min": 0.35426916244,
      "max": 0.38358567244,
      "times": [
        0.38358567244,
        0.35426916244,
        0.36220252344000003,
        0.36046893344000003,
        0.36188145944000005,
        0.36300524344,
        0.36197202944,
        0.35987095844000005,
        0.35982483144000005,
        0.35652297144000006
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.35817569374,
      "stddev": 0.005840557115614418,
      "median": 0.35884610544000006,
      "user": 0.35507414,
      "system": 0.050568199999999994,
      "min": 0.34684877544000003,
      "max": 0.36447901444,
      "times": [
        0.35612101544,
        0.36275894044,
        0.36273200944000006,
        0.36429918744,
        0.35526523544000005,
        0.35775909644000004,
        0.35993311444000003,
        0.35156054844,
        0.34684877544000003,
        0.36447901444
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08704623438117651,
      "stddev": 0.0016591069436966992,
      "median": 0.08681666594000001,
      "user": 0.019764151764705883,
      "system": 0.009487814705882353,
      "min": 0.08379810844,
      "max": 0.08981027644,
      "times": [
        0.08379810844,
        0.08774528244,
        0.08667484844000001,
        0.08749268744000001,
        0.08967583344,
        0.08540254644,
        0.08679450444,
        0.08661073844,
        0.08465036244,
        0.08683882744,
        0.08759344644,
        0.08626135144000001,
        0.08834042144,
        0.08842997944,
        0.08504210744,
        0.08981027644,
        0.08617740444000001,
        0.08737811144,
        0.08626811444,
        0.08383969644,
        0.08942700544,
        0.08656333944,
        0.08866482244,
        0.08747878044,
        0.08490384844,
        0.08919037044,
        0.08597175644,
        0.08964188044,
        0.08554581544,
        0.08785838544,
        0.08608450944,
        0.08952235444000001,
        0.08670197944000001,
        0.08719247244
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08699432886424241,
      "stddev": 0.001610740977368783,
      "median": 0.08714380144,
      "user": 0.02018413393939394,
      "system": 0.00881660303030303,
      "min": 0.08240648144,
      "max": 0.08994986944,
      "times": [
        0.08579909244,
        0.08711378544000001,
        0.08762386444,
        0.08709143244,
        0.08859417044000001,
        0.08615613344,
        0.08812309344000001,
        0.08718804444,
        0.08785170244,
        0.08688213844,
        0.08782057344000001,
        0.08714380144,
        0.08735426644000001,
        0.08806507344,
        0.08834144344,
        0.08636672944,
        0.08681132644,
        0.08713607744,
        0.08254697444,
        0.08789400244000001,
        0.08736023844,
        0.08766391944,
        0.08701192244,
        0.08845499744,
        0.08659741444,
        0.08703538744,
        0.08240648144,
        0.08740444144000001,
        0.08825672344,
        0.08677307444,
        0.08706810844,
        0.08292654844,
        0.08994986944
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.535 ± 0.152 4.424 4.841 1.29 ± 0.06
pacquet@main 4.519 ± 0.082 4.450 4.721 1.29 ± 0.05
pnpr@HEAD 3.550 ± 0.149 3.426 3.891 1.01 ± 0.05
pnpr@main 3.510 ± 0.107 3.436 3.806 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.535090998459999,
      "stddev": 0.1522900067772248,
      "median": 4.46933875166,
      "user": 1.73372232,
      "system": 1.36148524,
      "min": 4.424064898659999,
      "max": 4.841420879659999,
      "times": [
        4.44823738466,
        4.424064898659999,
        4.79426619966,
        4.47023016866,
        4.52478023866,
        4.44418373866,
        4.4684473346599995,
        4.841420879659999,
        4.438212097659999,
        4.4970670436599995
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.51945584816,
      "stddev": 0.08246737675950762,
      "median": 4.48226146116,
      "user": 1.7528317200000003,
      "system": 1.33757184,
      "min": 4.44966648666,
      "max": 4.72090729266,
      "times": [
        4.72090729266,
        4.47759693866,
        4.44966648666,
        4.461670734659999,
        4.5726402426599995,
        4.48692598366,
        4.531319121659999,
        4.46165439466,
        4.556536718659999,
        4.475640567659999
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5502447363600007,
      "stddev": 0.1492276553565166,
      "median": 3.50952581816,
      "user": 1.15382882,
      "system": 1.2464418399999997,
      "min": 3.42554392566,
      "max": 3.89141556566,
      "times": [
        3.49518119066,
        3.5567771886600004,
        3.44183365066,
        3.45020042866,
        3.89141556566,
        3.5319142076600003,
        3.4532617346600003,
        3.7324490256600003,
        3.52387044566,
        3.42554392566
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.51043751686,
      "stddev": 0.10721528420290423,
      "median": 3.4799268156600003,
      "user": 1.23041322,
      "system": 1.2047629399999997,
      "min": 3.43637833366,
      "max": 3.80568143066,
      "times": [
        3.5195858216600002,
        3.46483008166,
        3.45047367366,
        3.43637833366,
        3.4896607516600002,
        3.80568143066,
        3.49515264766,
        3.4580669946600002,
        3.4701928796600003,
        3.51435255366
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13303
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,759.69 ms
(-3.32%)Baseline: 2,854.37 ms
3,425.24 ms
(80.57%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,893.59 ms
(-5.66%)Baseline: 2,007.26 ms
2,408.72 ms
(78.61%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
569.28 ms
(-15.20%)Baseline: 671.35 ms
805.62 ms
(70.66%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
354.27 ms
(-15.14%)Baseline: 417.46 ms
500.96 ms
(70.72%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,352.26 ms
(-3.27%)Baseline: 2,431.74 ms
2,918.09 ms
(80.61%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,424.06 ms
(-2.39%)Baseline: 4,532.18 ms
5,438.61 ms
(81.35%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
243.80 ms
(-14.06%)Baseline: 283.71 ms
340.45 ms
(71.61%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13303
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,456.44 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
289.62 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
291.72 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
83.80 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,405.14 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,425.54 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
261.70 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Superseded by #13300, which landed the same fix with a better mechanism. Closing.

That PR fixes the root cause structurally — giving run the single trailing_var_arg shape that exec / dlx / with already have — where this PR papered over it in argv space by inserting a second -- for clap to eat. Two consequences of that difference matter:

  • It fixes strictly more. Because parsing now stops at the script name, pnpm run show -s and pnpm run show --if-present forward those tokens to the script instead of matching pnpm's own flags. My argv pass could not fix those at all — I had noted them as a follow-up rather than solved them.
  • It has no edge case to get wrong. Greptile caught this PR duplicating a later separator when the script's first argument was option-shaped (pnpm run build --flag -- value → ["--flag","--","--","value"]). I had corrected that locally, but the structural fix never has the question to answer.

I picked argv pre-processing over restructuring RunArgs because the struct is built in six places and I judged the ripple too wide for a bug fix. That was the wrong call: the ripple was the fix.

Still open after #13300

stop keeps all three divergences, verified against pnpm11/pnpm/dist/pnpm.mjs on ebb6e6b968:

invocation pnpm pacquet
pnpm stop -- --other=1 ["--","--other=1"] ["--other=1"]
pnpm stop --if-present -- y ["--if-present","--","y"] ["y"]
pnpm stop -s ["-s"] []

StopArgs still declares args as a trailing_var_arg vec that pnpm's own flags are parsed ahead of, so it needs the same treatment run just got. I'll follow up with that unless you have it in hand.

pnpm test / pnpm start accept no trailing arguments at all — that is #13301, still open.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pacquet: pnpm run <script> -- <args> drops the -- separator, so script arguments hit the underlying program

3 participants