Skip to content

fix(add): support multiple package selectors - #12995

Merged
zkochan merged 2 commits into
pnpm:mainfrom
YESHYUNGSEOK:fix/pacquet-add-multiple-packages
Jul 16, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
YESHYUNGSEOK:fix/pacquet-add-multiple-packages

Conversation

@YESHYUNGSEOK

@YESHYUNGSEOK YESHYUNGSEOK commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Pacquet's add command now accepts every package selector supplied in one invocation for regular, global, and configuration-dependency installs.

The command validates the complete selector list before initializing installation state, batches manifest updates, and performs one install/save operation. The workspace manifest writer now also supports applying multiple configuration-dependency updates atomically.

The TypeScript CLI already supports multiple package selectors, so this change brings the Rust CLI to parity. No TypeScript changes are required.

Squash Commit Body

Pacquet collected trailing add arguments but only forwarded the first package selector. Carry the full selector list through regular, global, and configuration-dependency dispatch paths.

Parse and validate all configuration-dependency selectors before initializing installation state so an invalid later selector cannot leave partial filesystem changes. Batch dependency and workspace-manifest updates and persist each result once per command.

Add integration and unit coverage for multi-selector regular adds, configuration-dependency adds, validation atomicity, and batched workspace-manifest writes.

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.

Written by an agent (Codex, GPT-5).


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • pacquet add now accepts multiple package selectors in a single command and installs them together.
    • Global installs (-g) support batched additions for all selected packages.
    • pacquet add --config can record multiple config dependencies in one run, updating the workspace manifest and related lockfile artifacts.
  • Bug Fixes
    • Invalid package selectors now fail safely without creating partial files, lockfiles, workspace manifests, or node_modules installations.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

pacquet add now accepts multiple package selectors in one command. CLI, global installs, package resolution, configuration dependencies, workspace manifest updates, lockfile handling, installation, and integration tests were updated for batched operations.

Changes

Multi-package add flow

Layer / File(s) Summary
CLI batch wiring
pnpm/crates/cli/src/cli_args/add.rs, pnpm/crates/cli/src/cli_args/dispatch_install.rs, pnpm/crates/cli/src/cli_args/global.rs
CLI arguments now hold multiple selectors, forward parsed configuration dependencies, and use batched regular and global install paths while retaining a single-package adapter.
Package resolution and installation
pnpm/crates/package-manager/src/add.rs, pnpm/crates/package-manager/src/add/tests.rs, pnpm/crates/cli/tests/add.rs
Each selector is resolved and applied across dependency groups, catalog updates are aggregated, and multi-selector installation is validated through manifest, lockfile, and node_modules assertions.
Configuration dependency batching
pnpm/crates/cli/src/config_deps.rs, pnpm/crates/workspace-manifest-writer/src/lib.rs, pnpm/crates/workspace-manifest-writer/src/tests.rs, pnpm/crates/cli/tests/config_dependencies.rs
Configuration dependencies are resolved, installed, and persisted in batches, with coverage for successful multi-selector operations and validation failures before file creation.
Release metadata
.changeset/pacquet-add-multiple-packages.md
A patch changeset records multi-selector support for pacquet add.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant AddArgs
  participant PackageManagerAdd
  participant WorkspaceManifest
  participant Install
  CLI->>AddArgs: parse multiple selectors
  AddArgs->>PackageManagerAdd: pass package_names
  PackageManagerAdd->>WorkspaceManifest: write dependencies and catalogs
  PackageManagerAdd->>Install: install resolved dependency groups
  Install-->>CLI: complete batched add
Loading

Possibly related issues

  • pnpm/pnpm#11633 — Concerns extending pacquet’s add command to support multiple package selectors.

Suggested labels: product: pacquet

Suggested reviewers: zkochan, zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov-commenter

codecov-commenter commented Jul 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.65%. Comparing base (33532b6) to head (d4d7d5c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/package-manager/src/add.rs 92.50% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12995      +/-   ##
==========================================
+ Coverage   85.63%   85.65%   +0.02%     
==========================================
  Files         500      500              
  Lines       80138    80233      +95     
==========================================
+ Hits        68624    68723      +99     
+ Misses      11514    11510       -4     

☔ 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 commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 98a5e819d4ed

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

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.850 ± 0.148 2.543 3.014 1.79 ± 0.22
pacquet@main 2.727 ± 0.130 2.574 2.925 1.71 ± 0.20
pnpr@HEAD 1.595 ± 0.176 1.399 1.841 1.00
pnpr@main 1.618 ± 0.172 1.428 1.915 1.01 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.8501645611,
      "stddev": 0.14839380548000689,
      "median": 2.9099849013000005,
      "user": 2.60239626,
      "system": 2.0167037199999998,
      "min": 2.5428662778000004,
      "max": 3.0136688058,
      "times": [
        2.8811699568000004,
        2.6748804148,
        2.7419080498,
        2.5428662778000004,
        2.9315181878000005,
        2.9395743058000003,
        2.8884516148,
        3.0136688058,
        2.9441037928000005,
        2.9435042048000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.7268249313000004,
      "stddev": 0.12975165644140998,
      "median": 2.6924129533000003,
      "user": 2.64384086,
      "system": 2.0245931199999996,
      "min": 2.5739491748000005,
      "max": 2.9250707578000004,
      "times": [
        2.7017523308,
        2.6322105908,
        2.5857926858,
        2.9250707578000004,
        2.6372530918000003,
        2.7695943838000003,
        2.5739491748000005,
        2.8595078838000005,
        2.9000448378000003,
        2.6830735758000004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5952526607000002,
      "stddev": 0.17558965607236107,
      "median": 1.5758904843000001,
      "user": 1.6533293599999996,
      "system": 1.6064664199999998,
      "min": 1.3988484858,
      "max": 1.8409763728,
      "times": [
        1.8409763728,
        1.7555788178,
        1.8085344908,
        1.4263755838,
        1.5688917098000001,
        1.5828892588,
        1.7275745328,
        1.4174704718,
        1.4253868828,
        1.3988484858
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.617947332,
      "stddev": 0.1722240167869847,
      "median": 1.6001720287999999,
      "user": 1.6720412599999996,
      "system": 1.53905922,
      "min": 1.4277770567999999,
      "max": 1.9149929808,
      "times": [
        1.4692157478,
        1.7583710388,
        1.4368369508,
        1.4935884528,
        1.4968125838,
        1.9149929808,
        1.7162246018,
        1.4277770567999999,
        1.7035314738,
        1.7621224328
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 249.2 ± 22.7 221.8 291.2 1.07 ± 0.15
pacquet@main 232.0 ± 24.5 203.0 277.4 1.00
pnpr@HEAD 253.2 ± 19.9 230.5 294.3 1.09 ± 0.14
pnpr@main 282.3 ± 22.9 250.8 325.9 1.22 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24916001148000003,
      "stddev": 0.022706150195343916,
      "median": 0.24770862588000003,
      "user": 0.23143788,
      "system": 0.6629506599999999,
      "min": 0.22179496438000001,
      "max": 0.29122166738,
      "times": [
        0.22179496438000001,
        0.22700256638000002,
        0.22314151438000002,
        0.24615853838,
        0.25478424837999997,
        0.24925871338000002,
        0.24599456138,
        0.25331320438,
        0.29122166738,
        0.27893013637999997
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.23199604358,
      "stddev": 0.02449214127182562,
      "median": 0.22615432088000004,
      "user": 0.19644898000000002,
      "system": 0.6513330599999999,
      "min": 0.20295558738000002,
      "max": 0.27737915537999996,
      "times": [
        0.21611174338000003,
        0.21481050138000002,
        0.20295558738000002,
        0.20971843538,
        0.22702982838000002,
        0.22527881338000003,
        0.23323831438,
        0.27737915537999996,
        0.26560960138,
        0.24782845538
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.25318840018,
      "stddev": 0.019936238918184804,
      "median": 0.25219599588,
      "user": 0.22389958000000004,
      "system": 0.6295308599999999,
      "min": 0.23053495038000002,
      "max": 0.29427223537999997,
      "times": [
        0.23169115238000001,
        0.23750378638000003,
        0.23882044038000003,
        0.29427223537999997,
        0.25506569738,
        0.24932629438,
        0.26048870938,
        0.26835156237999996,
        0.26582917338,
        0.23053495038000002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.28233484597999997,
      "stddev": 0.02290014450954656,
      "median": 0.27726068787999997,
      "user": 0.26183888,
      "system": 0.6733907599999999,
      "min": 0.25084370938,
      "max": 0.32590478738,
      "times": [
        0.29322686838,
        0.25084370938,
        0.29032050938,
        0.25966845237999997,
        0.27052390038,
        0.28018436937999996,
        0.27433700637999997,
        0.30956592637999997,
        0.32590478738,
        0.26877293038
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.839 ± 0.032 2.790 2.900 1.74 ± 0.14
pacquet@main 2.876 ± 0.044 2.806 2.933 1.76 ± 0.14
pnpr@HEAD 1.635 ± 0.128 1.460 1.878 1.00
pnpr@main 1.769 ± 0.193 1.472 1.974 1.08 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.8394211649,
      "stddev": 0.03197016247411597,
      "median": 2.8419584027000004,
      "user": 2.2689563799999997,
      "system": 1.7167278,
      "min": 2.7904880522,
      "max": 2.8998075772000003,
      "times": [
        2.8493158992,
        2.8467578202,
        2.8998075772000003,
        2.8711697932,
        2.8472222132000002,
        2.8302350862,
        2.7904880522,
        2.8371589852000003,
        2.8001778402,
        2.8218783822
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.8756136393000005,
      "stddev": 0.04365742769137125,
      "median": 2.8770433147000003,
      "user": 2.4996284799999997,
      "system": 1.7919832,
      "min": 2.8056908362,
      "max": 2.9326013412000003,
      "times": [
        2.8709498142000003,
        2.8056908362,
        2.8651377152000004,
        2.8831368152000003,
        2.9244996522,
        2.9326013412000003,
        2.9070750662,
        2.8137931492000003,
        2.9051335582,
        2.8481184452
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6350228294,
      "stddev": 0.12800207534515065,
      "median": 1.6425686262,
      "user": 1.61147088,
      "system": 1.5478576,
      "min": 1.4598223552,
      "max": 1.8781209572000002,
      "times": [
        1.7117414342000001,
        1.5543037342000001,
        1.4598223552,
        1.8781209572000002,
        1.7254522952000002,
        1.6452908982,
        1.5581497282,
        1.6398463542000001,
        1.4730575772,
        1.7044429602000002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.7688067380999999,
      "stddev": 0.19340923880989375,
      "median": 1.8378369527,
      "user": 1.58069608,
      "system": 1.540982,
      "min": 1.4715721472,
      "max": 1.9742189342,
      "times": [
        1.9502878302000002,
        1.9742189342,
        1.9467407872,
        1.8543632132,
        1.5925787232000002,
        1.9026125622000003,
        1.4963054482000002,
        1.4715721472,
        1.6780770432,
        1.8213106922000002
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 660.7 ± 12.4 640.4 675.9 2.30 ± 0.12
pacquet@main 691.8 ± 39.2 639.4 754.0 2.41 ± 0.18
pnpr@HEAD 287.6 ± 13.7 265.1 311.3 1.00
pnpr@main 311.3 ± 13.7 297.6 335.5 1.08 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6607440654600001,
      "stddev": 0.012384619683788779,
      "median": 0.6592902218600001,
      "user": 0.84506464,
      "system": 0.8121112199999999,
      "min": 0.6403781848600001,
      "max": 0.67590831086,
      "times": [
        0.67590831086,
        0.6720464968600001,
        0.6559883878600001,
        0.67125468986,
        0.6519843808600001,
        0.6743483068600001,
        0.6403781848600001,
        0.6469514528600001,
        0.66233818986,
        0.6562422538600001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6918114880600001,
      "stddev": 0.039167059600144286,
      "median": 0.69782556486,
      "user": 0.9024287400000001,
      "system": 0.86904662,
      "min": 0.6393874358600001,
      "max": 0.75399272786,
      "times": [
        0.6393874358600001,
        0.6511427118600001,
        0.66165257986,
        0.6504172218600001,
        0.6938445318600001,
        0.7147283548600001,
        0.75399272786,
        0.7273133008600001,
        0.7018065978600001,
        0.7238294178600001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28755043976,
      "stddev": 0.013740851020363393,
      "median": 0.28681853236,
      "user": 0.23455524,
      "system": 0.60360552,
      "min": 0.26513130886,
      "max": 0.31130692586,
      "times": [
        0.29900660086,
        0.29677909886,
        0.28435316686,
        0.28290139386,
        0.26922122086,
        0.28928389786,
        0.26513130886,
        0.29335221886,
        0.31130692586,
        0.28416856486
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.31134151645999997,
      "stddev": 0.01366971298923503,
      "median": 0.30731132435999997,
      "user": 0.24828333999999996,
      "system": 0.65118042,
      "min": 0.29764572386,
      "max": 0.33547148986,
      "times": [
        0.30980698486,
        0.30481566386,
        0.30065784286,
        0.29764572386,
        0.31245000586,
        0.30460860086,
        0.33547148986,
        0.33465703886,
        0.31435345786,
        0.29894835586
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.921 ± 0.049 1.853 2.014 7.46 ± 0.49
pacquet@main 1.861 ± 0.024 1.829 1.899 7.23 ± 0.45
pnpr@HEAD 0.269 ± 0.010 0.256 0.290 1.04 ± 0.07
pnpr@main 0.257 ± 0.016 0.231 0.280 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9207235294,
      "stddev": 0.048898908845778084,
      "median": 1.9092788607000002,
      "user": 1.0691165200000001,
      "system": 0.8477987199999999,
      "min": 1.8530003862000002,
      "max": 2.0135149992,
      "times": [
        2.0135149992,
        1.9020850072000002,
        1.8530003862000002,
        1.8856667582000002,
        1.9156971762000001,
        1.9398136312,
        1.8750687852,
        1.9810410052,
        1.9028605452,
        1.9384870002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.8609754872000004,
      "stddev": 0.023758484275104238,
      "median": 1.8567468807000003,
      "user": 0.99708732,
      "system": 0.79195862,
      "min": 1.8294598142,
      "max": 1.8994421332000002,
      "times": [
        1.8589180222000001,
        1.8778642342000003,
        1.8752404242,
        1.8444768872000001,
        1.8294598142,
        1.8394017712000001,
        1.8994421332000002,
        1.8906854062,
        1.8396904402000003,
        1.8545757392000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26873541509999993,
      "stddev": 0.01018548134920109,
      "median": 0.2680435007,
      "user": 0.18948671999999997,
      "system": 0.54515172,
      "min": 0.2562445922,
      "max": 0.2901289292,
      "times": [
        0.2587591312,
        0.27495245220000003,
        0.27109724820000003,
        0.2637353862,
        0.2690945212,
        0.25958863320000003,
        0.2669924802,
        0.27676077720000003,
        0.2901289292,
        0.2562445922
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.2573308808,
      "stddev": 0.01562288417269523,
      "median": 0.2577002537,
      "user": 0.19600402,
      "system": 0.53583582,
      "min": 0.2310427442,
      "max": 0.2795372912,
      "times": [
        0.2310427442,
        0.2390324402,
        0.2590355122,
        0.2691029832,
        0.2795372912,
        0.2563649952,
        0.2493606632,
        0.2714528582,
        0.2707083632,
        0.2476709572
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 350.2 ± 8.8 333.4 359.7 4.00 ± 0.16
pacquet@main 438.8 ± 84.0 342.7 576.6 5.01 ± 0.97
pnpr@HEAD 87.6 ± 2.9 82.7 92.7 1.00
pnpr@main 88.7 ± 3.4 82.9 95.0 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35016852006000004,
      "stddev": 0.008775905507127589,
      "median": 0.35138950726,
      "user": 0.33846273999999993,
      "system": 0.08294458000000002,
      "min": 0.33342819426000003,
      "max": 0.35974739226,
      "times": [
        0.33995855926,
        0.34564391226,
        0.35927516826,
        0.33342819426000003,
        0.35198691826,
        0.34716634526,
        0.35079209626,
        0.35442515726,
        0.35974739226,
        0.35926145726000003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.43884483646000005,
      "stddev": 0.08400049500515559,
      "median": 0.44207565276000005,
      "user": 0.42107313999999996,
      "system": 0.10682867999999998,
      "min": 0.34269639826000003,
      "max": 0.57660492726,
      "times": [
        0.38166123326,
        0.42820656926,
        0.45594473626000004,
        0.45909284726,
        0.49116007026,
        0.57660492726,
        0.5521308192600001,
        0.34848298226,
        0.34269639826000003,
        0.35246778126
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08759564819939394,
      "stddev": 0.0028619841535162164,
      "median": 0.08715458826000001,
      "user": 0.01787132484848485,
      "system": 0.013219022424242425,
      "min": 0.08273523326000001,
      "max": 0.09271298026000001,
      "times": [
        0.08503138426000001,
        0.08820975326000001,
        0.08715458826000001,
        0.08406327726000001,
        0.08321241526,
        0.08865930126,
        0.09167828826,
        0.08862243226000001,
        0.08273523326000001,
        0.08534773726000001,
        0.08750148926000001,
        0.08667566426000001,
        0.08954973926000001,
        0.08492714726,
        0.08495814726,
        0.08645265726000001,
        0.08281686626000001,
        0.08469960526,
        0.09130625926000001,
        0.08936427926000001,
        0.08678078626,
        0.08699371126000001,
        0.08987856526000002,
        0.09103170926000001,
        0.09271298026000001,
        0.08622908926,
        0.08645760326000002,
        0.09025755926000001,
        0.08983046126000001,
        0.08546859626000002,
        0.09210873626,
        0.09241161226000001,
        0.08752871526000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08873393022969699,
      "stddev": 0.0033673260761261257,
      "median": 0.08972648726000002,
      "user": 0.019446052121212122,
      "system": 0.013034089696969698,
      "min": 0.08293570126000001,
      "max": 0.09504747326000001,
      "times": [
        0.08402655526000001,
        0.09213903526000002,
        0.08385933926000001,
        0.08654554626000001,
        0.08293570126000001,
        0.08575268826000002,
        0.09165345226,
        0.08747728126000001,
        0.08864722426,
        0.09504747326000001,
        0.08879042226000002,
        0.08513060126000001,
        0.09082262426000001,
        0.08497363426000001,
        0.09026724726,
        0.09025885026000001,
        0.09117517126,
        0.09023338726,
        0.08296481526,
        0.08403191726,
        0.09407550826000001,
        0.09186634826000001,
        0.08421484626,
        0.09256396726,
        0.08972648726000002,
        0.08760806726,
        0.08982265326000001,
        0.09065570626000001,
        0.09157914926,
        0.08852481226000002,
        0.09260563926000001,
        0.09058778326000001,
        0.08765576226
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.608 ± 0.142 4.452 4.881 1.28 ± 0.05
pacquet@main 4.597 ± 0.167 4.437 4.951 1.28 ± 0.05
pnpr@HEAD 3.592 ± 0.080 3.497 3.737 1.00
pnpr@main 3.676 ± 0.171 3.554 4.050 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.608291044,
      "stddev": 0.1423430511641906,
      "median": 4.5581302754,
      "user": 2.15521472,
      "system": 1.60432772,
      "min": 4.4523633989,
      "max": 4.8813933959,
      "times": [
        4.8813933959,
        4.4523633989,
        4.6653834729,
        4.6744117769,
        4.7921699149000005,
        4.4752446989,
        4.4948929069000005,
        4.5725108599,
        4.530790323900001,
        4.5437496909
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.5973768101,
      "stddev": 0.1672592802780101,
      "median": 4.534758093400001,
      "user": 2.31860642,
      "system": 1.7187776200000002,
      "min": 4.4374500399,
      "max": 4.9506938679,
      "times": [
        4.6138356089000006,
        4.5764379659,
        4.5371447029,
        4.9506938679,
        4.5166839429,
        4.840741915900001,
        4.511172843900001,
        4.457235728900001,
        4.4374500399,
        4.5323714839
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5918256452999997,
      "stddev": 0.08042838824962363,
      "median": 3.5788688569,
      "user": 1.73321702,
      "system": 1.6191804199999997,
      "min": 3.4968057149,
      "max": 3.7372048879,
      "times": [
        3.7372048879,
        3.5383670448999998,
        3.4968057149,
        3.7098017038999997,
        3.5067487369,
        3.5542475379,
        3.6034901758999998,
        3.6127100668999996,
        3.6090142519,
        3.5498663319
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.6764129110999995,
      "stddev": 0.1713236736463684,
      "median": 3.6017008054,
      "user": 1.99744442,
      "system": 1.7894986199999998,
      "min": 3.5538123359,
      "max": 4.049588146900001,
      "times": [
        3.5909691739,
        3.5831338529,
        3.6022241469,
        3.6011774639,
        3.6280602009,
        3.5538123359,
        3.5811750359,
        3.6339505369,
        3.9400382169,
        4.049588146900001
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12995
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,839.42 ms
(-16.90%)Baseline: 3,417.05 ms
4,100.46 ms
(69.25%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,920.72 ms
(-20.76%)Baseline: 2,423.80 ms
2,908.56 ms
(66.04%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
660.74 ms
(-32.04%)Baseline: 972.19 ms
1,166.63 ms
(56.64%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
350.17 ms
(-29.64%)Baseline: 497.67 ms
597.20 ms
(58.63%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,850.16 ms
(-8.60%)Baseline: 3,118.20 ms
3,741.84 ms
(76.17%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,608.29 ms
(-18.58%)Baseline: 5,659.61 ms
6,791.54 ms
(67.85%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
249.16 ms
(-40.00%)Baseline: 415.27 ms
498.33 ms
(50.00%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12995
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,635.02 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
268.74 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
287.55 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
87.60 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,595.25 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,591.83 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
253.19 ms
🐰 View full continuous benchmarking report in Bencher

@YESHYUNGSEOK
YESHYUNGSEOK force-pushed the fix/pacquet-add-multiple-packages branch from 38b2004 to 6722caa Compare July 16, 2026 00:01
@YESHYUNGSEOK
YESHYUNGSEOK marked this pull request as ready for review July 16, 2026 01:35
@YESHYUNGSEOK
YESHYUNGSEOK requested a review from zkochan as a code owner July 16, 2026 01:35
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@greptile-apps

greptile-apps Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge; the change is well-scoped and the pre-validation-before-init ordering is a correctness improvement over the prior behavior.

The refactoring is clean — validation happens before any filesystem side-effects, manifest updates are batched, and the workspace-manifest writer reads/writes the YAML file at most once per command. All three install paths (regular, global, config) are consistently updated and covered by new integration tests.

No files require special attention.

Reviews (3): Last reviewed commit: "refactor(cli): tighten the multi-selecto..." | Re-trigger Greptile

Comment thread pnpm/crates/cli/src/cli_args/add.rs Resolved
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 16, 2026
@zkochan
zkochan force-pushed the fix/pacquet-add-multiple-packages branch from 6722caa to 98a5e81 Compare July 16, 2026 21:14
@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Changeset missing pnpm entry ✗ Dismissed 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and does not include a pnpm entry. This
violates the requirement that changesets explicitly declare the pnpm package with a valid bump
type.
Code

.changeset/pacquet-add-multiple-packages.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
Compliance ID 713436 requires changeset front-matter to include an explicit pnpm entry with a
valid bump type. The added changeset front-matter declares only "pacquet": patch, omitting pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-add-multiple-packages.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 front-matter is missing a `pnpm` entry. Per the compliance checklist, changesets must explicitly include `pnpm` with a valid bump type (`patch`/`minor`/`major`).

## Issue Context
This PR adds a new changeset at `.changeset/pacquet-add-multiple-packages.md`, but it only declares `"pacquet": patch`.

## Fix Focus Areas
- .changeset/pacquet-add-multiple-packages.md[1-3]

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



Remediation recommended

2. Registry map rebuilt per selector 🐞 Bug ➹ Performance
Description
Add::run now resolves selectors in a loop, and resolve_added_dependency rebuilds a HashMap
from config.resolved_registries() for each brand-new selector that has no explicit spec and no
existing manifest entry. With multi-selector adds this causes avoidable repeated allocations/clones
on the add hot path and scales with the number of selectors.
Code

pnpm/crates/package-manager/src/add.rs[R369-371]

+                    let registries: std::collections::HashMap<String, String> =
+                        config.resolved_registries().into_iter().collect();
+                    let registry = pick_registry_for_package(&registries, package_name, None);
Evidence
The new multi-selector path loops over package_names and calls resolve_added_dependency per
selector; inside that helper, the no-explicit-spec/no-prev-entry branch rebuilds a registry
HashMap each time by calling Config::resolved_registries(), which itself clones the registry
map.

pnpm/crates/package-manager/src/add.rs[164-187]
pnpm/crates/package-manager/src/add.rs[344-385]
pnpm/crates/config/src/lib.rs[1725-1732]

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

### Issue description
Multi-selector `add` resolves each selector individually. In `resolve_added_dependency`, the `(None, None)` branch rebuilds a `HashMap` via `config.resolved_registries().into_iter().collect()` per selector. This is redundant work that becomes more visible now that a single `add` can contain many selectors.

### Issue Context
- The repeated rebuild is only triggered for selectors where `explicit_spec` is `None` and the dependency is not already present in the targeted dependency groups.
- `Config::resolved_registries()` clones the internal map each call.

### Fix Focus Areas
- pnpm/crates/package-manager/src/add.rs[164-187]
- pnpm/crates/package-manager/src/add.rs[344-385]
- pnpm/crates/config/src/lib.rs[1725-1732]

### Suggested approach
1. In `Add::run`, compute `let registries: HashMap<String, String> = config.resolved_registries().into_iter().collect();` once.
2. Thread `&registries` into `resolve_added_dependency` (and into any helper it calls that currently rebuilds registries).
3. Use `pick_registry_for_package(&registries, package_name, None)` without rebuilding the map per selector.

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



Informational

3. Overstated validation guarantee 🐞 Bug ⚙ Maintainability ⭐ New
Description
The new doc comment on parse_config_dependencies implies that running it before State::init
prevents “invalid selectors” from leaving a half-created project, but the function only ensures a
valid package name/alias is present and does not validate specifier resolvability. Additionally,
State::init does not always scaffold package.json to disk (e.g., workspace-root missing
manifest), so the described side effect is conditional.
Code

pnpm/crates/cli/src/cli_args/add.rs[R126-132]

+    /// The `--config` selectors parsed into the `name → specifier` pairs to
+    /// record, or `None` when `--config` was not passed.
+    ///
+    /// Callers must run this *before* [`State::init`]: that scaffolds a
+    /// `package.json` on disk, so rejecting an invalid selector afterwards
+    /// would leave a half-created project behind. A version-less selector
+    /// resolves the `latest` tag, matching the default `add` behavior.
Evidence
The cited comment claims pre-State::init parsing avoids leaving a half-created project, but
State::init only scaffolds/writes a manifest in some cases, and the selector parsing used here
only validates the package-name portion (alias) while preserving the specifier as-is.

pnpm/crates/cli/src/cli_args/add.rs[126-132]
pnpm/crates/cli/src/state.rs[113-129]
pnpm/crates/resolving-parse-wanted-dependency/src/lib.rs[9-51]

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

### Issue description
`parse_config_dependencies`’s doc comment currently reads as if it fully validates selectors (and that `State::init` always writes/scaffolds `package.json`), but the code only enforces that the selector has a valid package name/alias and leaves the specifier untouched.

### Issue Context
- `State::init` can avoid writing `package.json` when `config.workspace_dir.is_some()` and the root manifest is missing.
- `parse_wanted_dependency` only splits `(alias, bare_specifier)` and does not validate whether `bare_specifier` is resolvable.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/add.rs[126-132]

### Proposed fix
Update the comment to precisely describe what is validated (e.g., “reject selectors that do not contain a valid package name/alias before `State::init`”) and avoid implying full selector validation/atomicity or unconditional on-disk scaffolding.

ⓘ 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 d4d7d5c

Results up to commit 98a5e81


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


Action required
1. Changeset missing pnpm entry ✗ Dismissed 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and does not include a pnpm entry. This
violates the requirement that changesets explicitly declare the pnpm package with a valid bump
type.
Code

.changeset/pacquet-add-multiple-packages.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
Compliance ID 713436 requires changeset front-matter to include an explicit pnpm entry with a
valid bump type. The added changeset front-matter declares only "pacquet": patch, omitting pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-add-multiple-packages.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 front-matter is missing a `pnpm` entry. Per the compliance checklist, changesets must explicitly include `pnpm` with a valid bump type (`patch`/`minor`/`major`).

## Issue Context
This PR adds a new changeset at `.changeset/pacquet-add-multiple-packages.md`, but it only declares `"pacquet": patch`.

## Fix Focus Areas
- .changeset/pacquet-add-multiple-packages.md[1-3]

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



Remediation recommended
2. Registry map rebuilt per selector 🐞 Bug ➹ Performance
Description
Add::run now resolves selectors in a loop, and resolve_added_dependency rebuilds a HashMap
from config.resolved_registries() for each brand-new selector that has no explicit spec and no
existing manifest entry. With multi-selector adds this causes avoidable repeated allocations/clones
on the add hot path and scales with the number of selectors.
Code

pnpm/crates/package-manager/src/add.rs[R369-371]

+                    let registries: std::collections::HashMap<String, String> =
+                        config.resolved_registries().into_iter().collect();
+                    let registry = pick_registry_for_package(&registries, package_name, None);
Evidence
The new multi-selector path loops over package_names and calls resolve_added_dependency per
selector; inside that helper, the no-explicit-spec/no-prev-entry branch rebuilds a registry
HashMap each time by calling Config::resolved_registries(), which itself clones the registry
map.

pnpm/crates/package-manager/src/add.rs[164-187]
pnpm/crates/package-manager/src/add.rs[344-385]
pnpm/crates/config/src/lib.rs[1725-1732]

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

### Issue description
Multi-selector `add` resolves each selector individually. In `resolve_added_dependency`, the `(None, None)` branch rebuilds a `HashMap` via `config.resolved_registries().into_iter().collect()` per selector. This is redundant work that becomes more visible now that a single `add` can contain many selectors.

### Issue Context
- The repeated rebuild is only triggered for selectors where `explicit_spec` is `None` and the dependency is not already present in the targeted dependency groups.
- `Config::resolved_registries()` clones the internal map each call.

### Fix Focus Areas
- pnpm/crates/package-manager/src/add.rs[164-187]
- pnpm/crates/package-manager/src/add.rs[344-385]
- pnpm/crates/config/src/lib.rs[1725-1732]

### Suggested approach
1. In `Add::run`, compute `let registries: HashMap<String, String> = config.resolved_registries().into_iter().collect();` once.
2. Thread `&registries` into `resolve_added_dependency` (and into any helper it calls that currently rebuilds registries).
3. Use `pick_registry_for_package(&registries, package_name, None)` without rebuilding the map per selector.

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

Route `add --config` on the parsed selector map itself instead of
re-checking the `--config` flag and unwrapping the map, so the flag and
the map cannot drift into a panic. Record why the parse has to precede
`State::init`: it scaffolds a `package.json`, so a selector rejected
afterwards would strand a half-created project.

Drop `set_config_dependency`, which lost its last production caller when
`add --config` moved to the batched writer, and let the single-entry test
helper call the batched writer directly.

Assert the batched write's exact file contents rather than per-fragment
containment, matching the sibling tests and pinning the sorted block order
the fragment assertions hid.

Restore the dlx rationale on `add_package`'s doc comment.

@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/workspace-manifest-writer/src/lib.rs (1)

137-139: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Move implementation rationale to regular comments.

As per path instructions for pnpm/CODE_STYLE_GUIDE.md, doc comments (///) should be used strictly for API contracts, while implementation rationale must go in regular comments (//). The explanation of how pnpm add --config uses this function and handles the lockfile is implementation rationale.

♻️ Proposed refactor
-/// and writing the file at most once. Used by `pnpm add --config`; the
-/// resolved integrity is recorded separately in the env lockfile, so only
-/// the clean specifier is written here.
+/// and writing the file at most once.
+// Used by `pnpm add --config`; the resolved integrity is recorded separately
+// in the env lockfile, so only the clean specifier is written here.
🤖 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/workspace-manifest-writer/src/lib.rs` around lines 137 - 139,
Convert the implementation-rationale documentation immediately above the
relevant workspace manifest writer function to regular comments using // instead
of ///. Preserve the explanation about pnpm add --config, single-write behavior,
and separate integrity recording, while leaving any API-contract documentation
unchanged.

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.

Nitpick comments:
In `@pnpm/crates/workspace-manifest-writer/src/lib.rs`:
- Around line 137-139: Convert the implementation-rationale documentation
immediately above the relevant workspace manifest writer function to regular
comments using // instead of ///. Preserve the explanation about pnpm add
--config, single-write behavior, and separate integrity recording, while leaving
any API-contract documentation unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 827d1224-3a87-466a-bde8-4366e64edf0a

📥 Commits

Reviewing files that changed from the base of the PR and between 98a5e81 and d4d7d5c.

📒 Files selected for processing (3)
  • pnpm/crates/cli/src/cli_args/add.rs
  • pnpm/crates/workspace-manifest-writer/src/lib.rs
  • pnpm/crates/workspace-manifest-writer/src/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/workspace-manifest-writer/src/tests.rs
  • pnpm/crates/cli/src/cli_args/add.rs

@qodo-code-review

Copy link
Copy Markdown

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

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@zkochan
zkochan merged commit 27646a0 into pnpm:main Jul 16, 2026
35 checks passed
MannXo added a commit to MannXo/pnpm that referenced this pull request Jul 17, 2026
… from Add

list_dependency_groups existed only because the dependency-group list
used to be consumed more than once. pnpm#12995 collapsed that to a
single collect-and-reuse, so the Fn() -> DependencyGroupList closure
indirection no longer buys anything: take dependency_groups directly
instead.

Threads the same simplification through add_package/add_packages and
their five call sites (add, global, dlx, runtime,
self_update/install_pnpm), each of which drops a trivial
closure/std::iter::once wrapper for a plain value or array literal.

Pure internal refactor: no user-visible behavior change, so no
changeset and no TypeScript counterpart.

Closes pnpm#13088

Co-Authored-By: Claude Sonnet 5 <[email protected]>
zkochan pushed a commit that referenced this pull request Jul 18, 2026
… from Add (#13107)

refactor(add): drop the vestigial Fn() -> DependencyGroupList generic from Add

list_dependency_groups existed only because the dependency-group list
used to be consumed more than once. #12995 collapsed that to a
single collect-and-reuse, so the Fn() -> DependencyGroupList closure
indirection no longer buys anything: take dependency_groups directly
instead.

Threads the same simplification through add_package/add_packages and
their five call sites (add, global, dlx, runtime,
self_update/install_pnpm), each of which drops a trivial
closure/std::iter::once wrapper for a plain value or array literal.

Pure internal refactor: no user-visible behavior change, so no
changeset and no TypeScript counterpart.

Closes #13088
@coderabbitai coderabbitai Bot mentioned this pull request Jul 27, 2026
3 tasks done
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.

3 participants