Skip to content

feat(pacquet): port runtime command - #12571

Merged
zkochan merged 5 commits into
mainfrom
port-runtime
Jun 22, 2026
Merged

zkochan merged 5 commits into
mainfrom
port-runtime

Conversation

@zkochan

@zkochan zkochan commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Ports the existing pnpm runtime command surface to pacquet:

  • adds pacquet runtime and the rt alias with runtime set <name> <version>
  • routes local runtime installs through the existing add pipeline as <name>@runtime:<version>
  • defaults to devEngines.runtime, supports --save-prod for engines.runtime, and preserves --save-dev precedence
  • adds manifest writeback from internal runtime:<version> dependency entries back to devEngines.runtime / engines.runtime
  • parses --global but rejects it because pacquet global package management has not been ported yet

No changeset is included because this is a pacquet-only Rust port and does not change a published TypeScript package.

Squash Commit Body

Port the runtime command to pacquet by adding a runtime/rt CLI entry and routing runtime set <name> <version> through the existing add pipeline as <name>@runtime:<version>.

The command matches pnpm's local save behavior: devEngines.runtime is the default, --save-prod targets engines.runtime, and --save-dev wins when both flags are present. The global path is parsed but rejected because pacquet does not yet support global package management, matching the existing update/outdated global boundary.

Add the manifest writer conversion that folds runtime:<version> dependencies back into devEngines.runtime and engines.runtime before saving, complementing the existing read-time conversion used by install and lockfile checks.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port, or the description notes what still needs porting.
  • Added or updated tests.

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a runtime CLI subcommand (alias: rt) to manage runtimes and versions with --save-dev / --save-prod.
  • Improvements

    • Runtime runs now participate in the standard “Done in …” reporting footer.
    • Empty runtime specs and empty Node selectors now resolve to “latest”.
  • Bug Fixes

    • Removing a runtime dependency now also prunes its corresponding devEngines.runtime / engines.runtime entry, including correct handling for arrays.
  • Tests

    • Expanded coverage for CLI parsing, manifest conversion/persistence, and resolver normalization.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4f18ea6-0e27-4289-94ef-58b0c4eaa489

📥 Commits

Reviewing files that changed from the base of the PR and between 25e225d and 94b9fad.

📒 Files selected for processing (2)
  • pnpm11/workspace/project-manifest-reader/src/index.ts
  • pnpm11/workspace/project-manifest-reader/test/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm11/workspace/project-manifest-reader/src/index.ts

📝 Walkthrough

Walkthrough

Adds a pnpm runtime set CLI subcommand (alias rt) that pins a named runtime package at major version under devDependencies or dependencies. Also adds convert_dependencies_to_engines_runtime to PackageManifest::save, which rewrites runtime:<version> dependency entries back into devEngines.runtime/engines.runtime in the serialized package.json. Mirrors this logic in TypeScript-based manifest readers with removal behavior for deleted dependencies. Runtime resolvers (Bun, Deno, Node) now normalize empty runtime version specs to "latest". Package-manager operations updated to log the exact written manifest values.

Changes

Runtime subcommand, manifest conversion, and resolver normalization

Layer / File(s) Summary
RuntimeArgs contract, validation, and set_request parsing
pacquet/crates/cli/src/cli_args/runtime.rs, pacquet/crates/cli/src/cli_args/runtime/tests.rs
Defines RuntimeArgs with --global, --save-dev, --save-prod flags and a free-form params vector; defines RuntimeError (missing/unknown subcommand, missing runtime name, global unsupported) and internal RuntimeSetRequest; implements reject_unsupported_global validation, set_request parsing that formats package_name as {runtime}@runtime:{version}, and async run method calling add_package with PinnedVersion::Major; all behaviors are unit-tested.
CLI command enum variant, dispatch, and install-family wiring
pacquet/crates/cli/src/cli_args.rs, pacquet/crates/cli/src/cli_args/tests.rs
Exports the runtime module, adds the Runtime(RuntimeArgs) variant with visible alias rt to CliCommand, extends is_install_family to include Runtime, adds the CliCommand::Runtime dispatch arm calling reject_unsupported_global then run, and validates CLI parsing of the rt alias and -P/-g flags.
Rust: PackageManifest save and runtime-to-engines conversion
pacquet/crates/package-manifest/src/lib.rs, pacquet/crates/package-manifest/src/tests.rs
Refactors PackageManifest::save to use save_and_get_written_value method that clones and transforms the manifest before serializing; adds public convert_dependencies_to_engines_runtime and internal helpers to fold runtime:<version> entries into devEngines.runtime/engines.runtime with onFail: "download", handling missing, null, object, and array cases; unit tests cover all upsert shapes, save-time reification, pruning on removal, and failure preservation.
Add/remove/update integration with save_and_get_written_value
pacquet/crates/package-manager/src/add.rs, pacquet/crates/package-manager/src/remove.rs, pacquet/crates/package-manager/src/update.rs
Updates manifest persistence across Add::run, Remove::run, and Update::run to call save_and_get_written_value() instead of save(), capturing the exact written value and using it in subsequent PackageManifestMessage::Updated log events; ensures logged manifests match disk state.
Bun resolver empty runtime spec normalization
pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs, pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver/tests.rs
Adds normalize_runtime_spec helper to map empty version specs to "latest"; updates resolve_impl and resolve_latest_impl to normalize before downstream resolution; adds CapturingResolver test double to verify normalization behavior.
Deno resolver empty runtime spec normalization
pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs, pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver/tests.rs
Adds normalize_runtime_spec helper to map empty version specs to "latest"; updates resolve_impl and resolve_latest_impl to normalize before npm delegation; adds CapturingResolver test double to verify normalization behavior.
Node resolver empty runtime spec normalization
pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs, pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version/tests.rs
Updates documentation and adds is_latest_selector helper to treat empty string the same as "latest"; updates resolve_node_version and resolve_node_versions to use the helper; adds test verifying empty selector picks the latest version.
TypeScript: project-manifest-reader runtime-to-engines conversion and removal
pnpm11/workspace/project-manifest-reader/src/index.ts, pnpm11/workspace/project-manifest-reader/test/index.ts
Mirrors the Rust manifest conversion logic in TypeScript. Adds removal behavior: when a runtime dependency entry is deleted from dependencies or devDependencies, the corresponding managed engines.runtime or devEngines.runtime entry (identified by matching name, onFail: "download", and truthy version) is also removed. Implements removeManagedRuntimeEntry helper handling both single-object and array shapes. Test coverage verifies removal clears single objects and filters array entries while preserving unrelated runtimes.
Release notes for runtime dependency management
.changeset/prune-runtime-engine-removals.md
Adds a new Changesets entry documenting patch-level updates for @pnpm/workspace.project-manifest-reader and pnpm, describing the behavior change: when a runtime dependency is removed, the corresponding devEngines.runtime or engines.runtime entry—previously materialized from that dependency—is also removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat(pacquet): port runtime command' clearly and concisely describes the main change—porting the runtime command to pacquet. It is specific, follows conventional commit conventions, and accurately reflects the primary objective of the changeset.
Description check ✅ Passed The PR description comprehensively covers all required template sections: a detailed summary explaining what was changed and why, a thorough squash commit body with rationale and design decisions, and a completed checklist confirming implementation and testing. It provides sufficient context for reviewers to understand the changes and their implications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 port-runtime

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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 and usage tips.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

feat(pacquet): port pnpm runtime command to Rust CLI
✨ Enhancement 🕐 20-40 Minutes

Grey Divider

Description

• Adds pacquet runtime (alias rt) with runtime set   subcommand, routing through the existing
 add_package pipeline as @runtime:.
• Implements save-target logic: devEngines.runtime by default, engines.runtime with
 --save-prod, --save-dev wins when both flags are present; --global is parsed but rejected with
 a clear error.
• Adds convert_dependencies_to_engines_runtime writer function to PackageManifest::save, folding
 in-memory runtime: dependency entries back into devEngines.runtime / engines.runtime on disk.
Diagram

graph TD
    CLI["CLI Entry\ncli_args.rs"] --> RT["runtime.rs\nRuntimeArgs"]
    RT -->|"reject_unsupported_global"| ERR["RuntimeError"]
    RT -->|"add_package pipeline"| ADD["add.rs\nadd_package"]
    ADD --> PM["PackageManifest\n.save()"]
    PM --> CONV["convert_dependencies_to_engines_runtime"]
    CONV --> JSON[("package.json\non disk")]

    subgraph Legend
      direction LR
      _mod["Module"] ~~~ _fn(["Function"]) ~~~ _db[("File")]
    end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Reject missing version spec
  • ➕ Matches pnpm TypeScript behavior more closely
  • ➕ Avoids a potentially unresolvable runtime: specifier reaching the resolver
  • ➖ Slightly more restrictive than the current implementation
  • ➖ Would require a new RuntimeError variant and test update
2. Dedicated runtime install pipeline (not reusing add_package)
  • ➕ Could add runtime-specific resolution logic without touching the add path
  • ➖ Significant code duplication
  • ➖ No benefit given the current add pipeline already handles runtime: specifiers

Recommendation: The PR's approach of reusing add_package is correct and keeps the runtime command thin. One design point worth considering: the version spec is silently defaulted to an empty string when omitted (node@runtime:), which may produce a confusing lockfile entry. pnpm's TypeScript implementation raises an error for a missing version. The current approach is permissive by design (the PR notes it), but reviewers should confirm the resolver handles an empty version spec gracefully.

Files changed (6) +464 / -3

Enhancement (3) +240 / -2
cli_args.rsRegister Runtime command in CLI dispatcher +21/-1

Register Runtime command in CLI dispatcher

• Adds the 'runtime' module import, registers 'Runtime(RuntimeArgs)' as a 'CliCommand' variant with the 'rt' visible alias, includes 'Runtime' in the 'is_install_family' match arm, and dispatches it through the reporter-typed async pipeline with a 'reject_unsupported_global' guard.

pacquet/crates/cli/src/cli_args.rs

runtime.rsImplement RuntimeArgs and runtime set subcommand +111/-0

Implement RuntimeArgs and runtime set subcommand

• Defines 'RuntimeArgs' (clap struct with '--global', '--save-dev', '--save-prod', and positional 'params'), 'RuntimeError' variants, and 'RuntimeSetRequest'. The 'run' method delegates to 'add_package' with the package name formatted as '<name>@runtime:<version>'. Save-target precedence: '--save-dev' wins, then '--save-prod', defaulting to 'DependencyGroup::Dev'.

pacquet/crates/cli/src/cli_args/runtime.rs

lib.rsAdd manifest writer hook to convert runtime deps back to devEngines/engines +108/-1

Add manifest writer hook to convert runtime deps back to devEngines/engines

• Introduces 'convert_dependencies_to_engines_runtime' (public), 'upsert_runtime_entry', 'ensure_object_field', and 'merge_runtime_entry' (private helpers). 'PackageManifest::save' now clones the in-memory value, runs the writer hook for both 'devDependencies→devEngines' and 'dependencies→engines', then serializes the transformed value — keeping the on-disk manifest in the 'devEngines.runtime' / 'engines.runtime' format.

pacquet/crates/package-manifest/src/lib.rs

Tests (3) +224 / -1
tests.rsUnit tests for RuntimeArgs.set_request and global rejection +76/-0

Unit tests for RuntimeArgs.set_request and global rejection

• Covers default dev-group save, '--save-prod' override, '--save-dev' precedence over '--save-prod', missing version spec, deno runtime, missing subcommand, unknown subcommand, missing runtime name, and global flag rejection — 8 test cases in total.

pacquet/crates/cli/src/cli_args/runtime/tests.rs

tests.rsIntegration tests for runtime CLI alias and flag parsing +24/-0

Integration tests for runtime CLI alias and flag parsing

• Adds two parse-level tests: one verifying the 'rt' alias with '-P' flag sets 'save_prod' and captures params correctly, and one verifying '-g' after positional params sets 'global'.

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

tests.rsTests for convert_dependencies_to_engines_runtime and save writeback +124/-1

Tests for convert_dependencies_to_engines_runtime and save writeback

• Adds four tests: writing a fresh 'devEngines.runtime' entry, updating an existing single-runtime entry, promoting a mismatched single entry to an array, and an end-to-end 'save' test verifying both 'devEngines' and 'engines' are written correctly while the dependency fields are cleared.

pacquet/crates/package-manifest/src/tests.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

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

Inline comments:
In `@pacquet/crates/cli/src/cli_args/runtime.rs`:
- Around line 84-106: The set_request function currently accepts any runtime
name without validation and ignores extra positional arguments beyond the
expected three parameters (subcommand, runtime_name, version_spec). Add
validation to ensure only supported runtime names are accepted by checking
runtime_name against a predefined list of valid runtimes, and add a check to
reject invocations with extra positional arguments (when params.len() > 3) by
returning an appropriate RuntimeError for arity mismatch. This ensures type-safe
command invocation and prevents creation of invalid runtime dependency specs
that cannot round-trip into the manifest.

In `@pacquet/crates/package-manifest/src/lib.rs`:
- Around line 156-161: The `save` method creates and truncates the file on line
157 before performing conversions and serialization that could fail. If
conversion_dependencies_to_engines_runtime or serde_json::to_string_pretty
return an error, the original file contents are already destroyed. Move the
fs::File::create call to after all conversion and serialization operations
complete successfully, so the file is only truncated when we are certain the new
contents are ready to be written. Perform the conversions and
serde_json::to_string_pretty first, then create the file and write the contents
only after all operations succeed.

In `@pacquet/crates/package-manifest/src/tests.rs`:
- Around line 399-432: Add a new regression test function that verifies failed
save() operations preserve existing file contents. Create a test that sets up a
PackageManifest with conditions that will cause conversion to fail (such as an
invalid devEngines shape combined with a runtime: dependency), invoke save() and
assert it returns an Err, then read the file from disk and verify the file
contents remain unchanged from their state before the failed save attempt was
made.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d25d50d6-b3f3-473d-aa33-f1c780ded7a4

📥 Commits

Reviewing files that changed from the base of the PR and between 886fe57 and 5533df5.

📒 Files selected for processing (6)
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/runtime.rs
  • pacquet/crates/cli/src/cli_args/runtime/tests.rs
  • pacquet/crates/cli/src/cli_args/tests.rs
  • pacquet/crates/package-manifest/src/lib.rs
  • pacquet/crates/package-manifest/src/tests.rs

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Empty runtime not pruned 🐞 Bug ≡ Correctness
Description
isManagedRuntimeEntry treats version: "" as unmanaged via Boolean(runtime.version), so when a
dependency spec is runtime: (empty selector meaning “latest”), removing that dependency will not
prune the corresponding devEngines.runtime/engines.runtime entry. This leaves stale runtime
entries in package.json, contradicting the PR’s intended “removal prunes materialized runtime
entries” behavior for empty selectors too.
Code

pnpm11/workspace/project-manifest-reader/src/index.ts[R306-308]

+function isManagedRuntimeEntry (runtime: EngineDependency, runtimeName: string): boolean {
+  return runtime.name === runtimeName && runtime.onFail === 'download' && Boolean(runtime.version)
+}
Evidence
The writer hook explicitly derives version by stripping runtime:; for a runtime: dependency
this yields "", and the pruning path only deletes entries considered “managed.” The current
managed predicate excludes empty strings, even though the Rust side of this PR treats empty
selectors as “latest,” making empty selectors valid and expected.

pnpm11/workspace/project-manifest-reader/src/index.ts[244-285]
pnpm11/workspace/project-manifest-reader/src/index.ts[288-308]
pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[75-155]
pacquet/crates/package-manifest/src/lib.rs[424-445]

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

## Issue description
`isManagedRuntimeEntry()` currently uses `Boolean(runtime.version)`, which evaluates to `false` for an empty string. But this PR introduces/relies on empty runtime selectors (`runtime:`) being meaningful (interpreted as “latest”). As a result, managed runtime entries with `version: ""` are not pruned when the corresponding runtime dependency is removed.
### Issue Context
- `convertDependenciesToEnginesRuntime()` can produce `version === ""` when the dependency is `runtime:`.
- `removeManagedRuntimeEntry()` relies on `isManagedRuntimeEntry()`; with the current predicate, empty-version entries are never removed.
### Fix
- Update `isManagedRuntimeEntry()` to consider an empty string version as managed (e.g. `typeof runtime.version === 'string'` instead of `Boolean(runtime.version)`).
- Add a regression test in `pnpm11/workspace/project-manifest-reader/test/index.ts` covering a `runtime:` (empty) dependency being removed and verifying `devEngines.runtime` is pruned.
### Fix Focus Areas
- pnpm11/workspace/project-manifest-reader/src/index.ts[244-308]
- pnpm11/workspace/project-manifest-reader/test/index.ts[99-148]

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


2. Manifest event diverges disk 🐞 Bug ≡ Correctness
Description
PackageManifest::save() now writes a converted clone (folding runtime: deps into
devEngines.runtime/engines.runtime) but does not update self.value, so post-save code that
emits/uses manifest.value() can report a manifest that does not match the on-disk package.json.
This is user-visible via PackageManifestMessage::Updated emissions after add/remove/update (and
now runtime set), and can mislead any downstream consumer relying on that event as “what was
written.”
Code

pacquet/crates/package-manifest/src/lib.rs[R157-163]

+        let mut value = self.value.clone();
+        convert_dependencies_to_engines_runtime(&mut value, "devDependencies", "devEngines")?;
+        convert_dependencies_to_engines_runtime(&mut value, "dependencies", "engines")?;
+        let contents = serde_json::to_string_pretty(&value)?;
let mut file = fs::File::create(&self.path)?;
-        let contents = serde_json::to_string_pretty(&self.value)?;
file.write_all(contents.as_bytes())?;
Ok(())
Evidence
save() now serializes a converted clone (value) rather than self.value, but callers emit
manifest.value() after saving; since read_from_file() also applies the inverse conversion into
memory, this guarantees a post-save mismatch between the emitted “updated” manifest and the file
that was written.

pacquet/crates/package-manifest/src/lib.rs[156-164]
pacquet/crates/package-manifest/src/lib.rs[99-104]
pacquet/crates/package-manager/src/add.rs[305-330]
pacquet/crates/package-manager/src/remove.rs[142-156]
pacquet/crates/package-manager/src/update.rs[570-585]

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

## Issue description
`PackageManifest::save()` writes a transformed clone of the manifest (dependency → engines.runtime folding) but leaves `self.value` unchanged. Callers emit `PackageManifestMessage::Updated { updated: manifest.value().clone() }` after saving, so the emitted “updated” manifest can differ from what was actually persisted to disk.
### Issue Context
- `read_from_file()` already rewrites `devEngines/engines` into `*Dependencies` in-memory, so `PackageManifest::value()` is intentionally a “reified” view.
- With the new writer hook, the divergence becomes concrete after save: disk is engines-form, memory stays dependency-form.
### Fix Focus Areas
Pick one consistent contract and implement it end-to-end:
- Option A (minimal API churn): keep `self.value` as the internal/reified view, but make the *event payload* match the *written* manifest by emitting a converted clone (same conversion `save()` applies) instead of `manifest.value()`.
- Option B (stronger): introduce a `save_with_writeback(&mut self) -> Result<()>` (or `save_and_return_written_value(&self) -> Result<Value>`) so callers can both persist and emit the exact written JSON.
#### Fix Focus Areas (paths/lines)
- pacquet/crates/package-manifest/src/lib.rs[156-164]
- pacquet/crates/package-manifest/src/lib.rs[99-104]
- pacquet/crates/package-manager/src/add.rs[305-330]
- pacquet/crates/package-manager/src/remove.rs[142-156]
- pacquet/crates/package-manager/src/update.rs[570-585]

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


3. Runtime name not validated 🐞 Bug ≡ Correctness
Description
RuntimeArgs::set_request accepts any ` and constructs {name}@runtime:{spec}` without enforcing
the supported runtime allowlist, so unsupported names get routed through the normal add pipeline and
written into manifests/lockfiles. The runtime resolver/dep-path logic only recognizes
node|deno|bun, so other names will not be treated as runtimes and will mis-resolve or fail later.
Code

pacquet/crates/cli/src/cli_args/runtime.rs[R91-105]

+        let runtime_name = self
+            .params
+            .get(1)
+            .map(|name| name.trim())
+            .filter(|name| !name.is_empty())
+            .ok_or(RuntimeError::MissingRuntimeName)?;
+        let version_spec = self.params.get(2).map_or("", |version| version.trim());
+        let dependency_group = if self.save_dev || !self.save_prod {
+            DependencyGroup::Dev
+        } else {
+            DependencyGroup::Prod
+        };
+        Ok(RuntimeSetRequest {
+            package_name: format!("{runtime_name}@runtime:{version_spec}"),
+            dependency_group,
Evidence
The runtime CLI constructs the runtime dependency string from an unvalidated name, but runtime
resolution is only implemented for three specific aliases (node/deno/bun) and runtime depPath
detection is also restricted to those three, so any other runtime name cannot behave as intended and
will mis-resolve or fail downstream.

pacquet/crates/cli/src/cli_args/runtime.rs[84-106]
pacquet/crates/package-manifest/src/lib.rs[315-318]
pacquet/crates/deps-path/src/is_runtime_dep_path.rs[1-17]
pacquet/crates/engine-runtime-node-resolver/src/node_resolver.rs[258-266]
pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[75-83]

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

## Issue description
`pacquet runtime set <name> <version>` should only accept the runtime names that pacquet actually supports (`node`, `deno`, `bun`). Today, `RuntimeArgs::set_request` uses the raw `<name>` to build a dependency spec (`{name}@runtime:{version}`) without validating it.
This allows unsupported names to proceed into the add/install pipeline, producing manifest entries that are *not* resolvable by the runtime resolvers (which only engage for `node|deno|bun`) and are also not recognized as runtime depPaths by the byte-level runtime checks.
## Issue Context
- Supported runtime names are hard-coded elsewhere as `node`, `deno`, `bun`.
- Runtime resolvers only trigger when `WantedDependency.alias` matches the expected runtime name.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/runtime.rs[84-106]
## Suggested fix
- Add an allowlist check after parsing `runtime_name` and before constructing `package_name`.
- Introduce a dedicated error variant (e.g. `UnsupportedRuntimeName { name: String }`) so the user gets a clear message like "Unsupported runtime: <name>. Supported: node, deno, bun".
- Add/adjust unit tests to cover rejection of unsupported names (e.g. `python`, `@scope/node`).

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


View more (1)
4. Empty runtime selector breaks ✓ Resolved 🐞 Bug ≡ Correctness
Description
RuntimeArgs::set_request builds @runtime: when `` is omitted, but the runtime resolvers
interpret the empty selector literally and error because only "latest" is special-cased. This
makes pacquet runtime set node (and any manifest that contains runtime: with an empty body) fail
during resolution with NODEJS_VERSION_NOT_FOUND for an empty spec.
Code

pacquet/crates/cli/src/cli_args/runtime.rs[R97-105]

+        let version_spec = self.params.get(2).map_or("", |version| version.trim());
+        let dependency_group = if self.save_dev || !self.save_prod {
+            DependencyGroup::Dev
+        } else {
+            DependencyGroup::Prod
+        };
+        Ok(RuntimeSetRequest {
+            package_name: format!("{runtime_name}@runtime:{version_spec}"),
+            dependency_group,
Evidence
The CLI builds node@runtime: when no version is provided, but the Node resolver passes the
resulting empty selector through parse_node_specifier into resolve_node_version, which only
treats "latest" specially; an empty string therefore yields no satisfying version and triggers a
VersionNotFound error.

pacquet/crates/cli/src/cli_args/runtime.rs[84-107]
pacquet/crates/engine-runtime-node-resolver/src/parse_node_specifier.rs[39-78]
pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[75-86]
pacquet/crates/engine-runtime-node-resolver/src/node_resolver.rs[144-155]

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

## Issue description
`pacquet runtime set <name>` (no version) currently constructs `<name>@runtime:` and proceeds into the install/add pipeline, but the runtime resolvers do not normalize an empty `runtime:` selector to `latest`, causing resolution to fail.
## Issue Context
- The CLI explicitly allows a missing version and constructs `node@runtime:`.
- The Node runtime resolver ultimately calls `resolve_node_version(version_specifier)` which only handles the literal string `"latest"` as a default.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/runtime.rs[84-106]
- pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[75-86]
- pacquet/crates/engine-runtime-node-resolver/src/node_resolver.rs[144-155]
- pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[90-125]
- pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs[90-118]
## Suggested fix
Prefer fixing this at the resolver layer for parity with pnpm’s `node@runtime:` shape:
- In `resolve_node_version(...)`, treat `version_spec.is_empty()` the same as `version_spec == "latest"`.
- In bun/deno runtime resolvers, if the stripped `version_spec` is empty, substitute `"latest"` before delegating to the npm resolver.
This keeps accepting `node@runtime:` while making it resolve to the latest runtime successfully.

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



Remediation recommended

5. Runtime ignores supportedArchitectures 🐞 Bug ≡ Correctness ⭐ New
Description
RuntimeArgs::run routes through the shared add_package install pipeline but hardcodes
supported_architectures=None, ignoring Config::supported_architectures loaded from
pnpm-workspace.yaml. This makes pacquet runtime set diverge from pacquet add/install behavior
and can change optional-dependency installability decisions and downstream lockfile/manifest
outcomes for repos that use supportedArchitectures.
Code

pacquet/crates/cli/src/cli_args/runtime.rs[R70-80]

+    pub async fn run<Reporter: self::Reporter + 'static>(self, state: State) -> miette::Result<()> {
+        let request = self.set_request()?;
+        add_package::<Reporter, _, _>(
+            state,
+            &request.package_name,
+            PinnedVersion::Major,
+            None,
+            false,
+            None,
+            || std::iter::once(request.dependency_group),
+        )
Evidence
The runtime command currently passes supported_architectures as None, while the existing add
command explicitly merges and forwards state.config.supported_architectures into the same
add_package helper; the install pipeline documents that this value must be supplied by the CLI
layer and comes from pnpm-workspace.yaml.

pacquet/crates/cli/src/cli_args/runtime.rs[69-82]
pacquet/crates/cli/src/cli_args/add.rs[143-175]
pacquet/crates/config/src/lib.rs[1191-1202]
pacquet/crates/package-manager/src/install.rs[172-187]

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

## Issue description
`pacquet runtime set` calls `add_package(...)` with `supported_architectures` hardcoded to `None`, which bypasses the `pnpm-workspace.yaml`-derived `Config::supported_architectures` that other install-family commands thread into the install pipeline.

## Issue Context
The install pipeline treats `supported_architectures=None` as “host triple only”. For parity with `add/install`, the runtime command should pass the config-derived value (and any CLI overrides if you later add them).

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/runtime.rs[69-82]
- pacquet/crates/cli/src/cli_args/add.rs[143-175]
- pacquet/crates/config/src/lib.rs[1191-1202]
- pacquet/crates/package-manager/src/install.rs[172-187]

## Suggested change
In `RuntimeArgs::run`, compute `let supported_architectures = state.config.supported_architectures.clone();` (or the same merge pattern used by `AddArgs` if you later add per-axis flags) and pass it to `add_package` instead of `None`.

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


6. Silent runtime entry pruning 🐞 Bug ≡ Correctness
Description
convert_dependencies_to_engines_runtime calls remove_managed_runtime_entry whenever it can’t
read a runtime: entry from devDependencies/dependencies, including when those fields exist but
are not JSON objects. This can silently delete devEngines.runtime/engines.runtime entries on
save for malformed manifests instead of failing fast on the invalid dependency-map shape.
Code

pacquet/crates/package-manifest/src/lib.rs[R405-419]

+    for runtime_name in RUNTIME_NAMES {
+        let version = manifest
+            .get(deps_field)
+            .and_then(|deps| deps.get(runtime_name))
+            .and_then(Value::as_str)
+            .and_then(|dep| dep.strip_prefix("runtime:"))
+            .map(str::to_string);
+        if let Some(version) = version {
+            upsert_runtime_entry(manifest, engines_field, runtime_name, &version)?;
+            if let Some(deps) = manifest.get_mut(deps_field).and_then(Value::as_object_mut) {
+                deps.remove(runtime_name);
+            }
+        } else {
+            remove_managed_runtime_entry(manifest, engines_field, runtime_name);
+        }
Evidence
The save-time folding logic prunes managed runtime entries whenever it cannot extract a runtime:
dependency string; when the deps field is not an object, the lookup yields None and the prune
branch runs. Separately, read-time reification bails out early when the deps field is non-object,
making it possible for a malformed manifest to retain a managed runtime entry in memory and then
lose it on save.

pacquet/crates/package-manifest/src/lib.rs[99-104]
pacquet/crates/package-manifest/src/lib.rs[383-387]
pacquet/crates/package-manifest/src/lib.rs[400-420]

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

## Issue description
`convert_dependencies_to_engines_runtime` treats “can’t read runtime dep” the same as “runtime dep removed”, and will prune a managed `devEngines.runtime`/`engines.runtime` entry even when the dependency map field exists but is malformed (e.g. `devDependencies: []` or `"oops"`). This causes silent data loss on save.
## Issue Context
- Read-time reification (`convert_engines_runtime_to_dependencies`) already bails out when the deps field is not an object, so a malformed `devDependencies`/`dependencies` can leave `*Engines.runtime` intact in memory.
- The new save-time folding (`convert_dependencies_to_engines_runtime`) will then interpret the missing/unreadable runtime dependency as “removed” and prune the runtime entry.
## Fix Focus Areas
- pacquet/crates/package-manifest/src/lib.rs[400-422]
- pacquet/crates/package-manifest/src/lib.rs[383-387]
## Proposed fix
1. In `convert_dependencies_to_engines_runtime`, add a shape guard for `deps_field`:
- If `manifest.get(deps_field)` is `Some(v)` and `!v.is_object()`, return `Err(PackageManifestError::InvalidAttribute(...))`.
- This prevents the save path from silently deleting managed runtime entries when it cannot reliably determine whether the dependency was removed.
2. Add a unit test covering a malformed deps field, e.g.:
- Start with a manifest containing `devEngines.runtime` set to a managed entry and `devDependencies` set to a non-object.
- Assert `save()` (or `save_and_get_written_value()`) returns `InvalidAttribute` and does not rewrite the on-disk file.

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


7. Whitespace runtime spec not normalized 🐞 Bug ≡ Correctness
Description
runtime: selectors are only normalized when the selector is exactly empty; whitespace-only
selectors (e.g. "runtime: ") are preserved during manifest writeback and then treated as a
non-empty selector by runtime resolvers, leading to “no version found” resolution failures. This can
break installs for hand-edited package.json entries (or existing malformed data) despite the PR’s
intent that “empty means latest”.
Code

pacquet/crates/package-manifest/src/lib.rs[R406-412]

+        let Some(version) = manifest
+            .get(deps_field)
+            .and_then(|deps| deps.get(runtime_name))
+            .and_then(Value::as_str)
+            .and_then(|dep| dep.strip_prefix("runtime:"))
+            .map(str::to_string)
+        else {
Evidence
The manifest writeback hook copies the substring after runtime: verbatim (no trim), so
whitespace-only selectors can be persisted into engines.runtime.version. Resolver normalization
added in this PR only special-cases the empty string, and the resolver-side prefix stripping also
does not trim, so a whitespace selector will flow through as a non-empty selector and be parsed as a
range/tag instead of latest.

pacquet/crates/package-manifest/src/lib.rs[393-419]
pacquet/crates/package-manifest/src/lib.rs[340-376]
pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs[170-179]
pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[177-186]
pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[153-155]

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

## Issue description
Whitespace-only runtime selectors (e.g. `"runtime: "`) are currently treated as meaningful selectors instead of being normalized to `latest`. This can cause runtime resolution to fail even though empty/omitted selectors are intended to mean `latest`.
### Issue Context
- The manifest writer hook extracts the substring after `runtime:` without trimming, so a user-authored value like `"runtime: "` becomes a version string containing spaces.
- The runtime resolvers’ normalization only checks `is_empty()` and does not treat whitespace-only selectors as empty.
### Fix Focus Areas
- pacquet/crates/package-manifest/src/lib.rs[405-419]
- pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs[170-179]
- pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[177-186]
- pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[153-155]
### Suggested fix
1. Trim the selector after stripping `runtime:` in `convert_dependencies_to_engines_runtime` (e.g. `let version = dep.strip_prefix("runtime:").map(str::trim) ...`).
2. Also harden resolver-side normalization by treating `version_spec.trim().is_empty()` as `latest` (so both CLI- and manifest-sourced values behave consistently).
3. Add a focused test for `"runtime: "` (space) behaving like empty and resolving as `latest`.

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



Informational

8. Wrong CLI name in error 🐞 Bug ⚙ Maintainability
Description
RuntimeError::MissingRuntimeName tells users to run pnpm runtime set ... even though this command
surface is pacquet runtime set ..., making the copy/paste guidance incorrect. This is user-visible
whenever pacquet runtime set is invoked without a runtime name.
Code

pacquet/crates/cli/src/cli_args/runtime.rs[R42-46]

+    #[display(
+        r#""pnpm runtime set <name> <version>" requires a runtime name (e.g. node, deno, bun)"#
+    )]
+    #[diagnostic(code(ERR_PNPM_MISSING_RUNTIME_NAME))]
+    MissingRuntimeName,
Evidence
The newly added display string explicitly references pnpm runtime set ... inside the pacquet
runtime command implementation.

pacquet/crates/cli/src/cli_args/runtime.rs[42-46]

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

## Issue description
`RuntimeError::MissingRuntimeName` hard-codes the wrong command name (`pnpm runtime set ...`) even though this is the `pacquet runtime` command, which can confuse users.
## Issue Context
This string is part of the newly added runtime CLI surface.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/runtime.rs[42-46]

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


9. Full JSON clone on save 🐞 Bug ➹ Performance
Description
PackageManifest::save() now clones the entire manifest JSON (self.value.clone()) to apply
runtime folding, adding extra allocation/copy work on common mutation paths
(add/remove/update/runtime set). This is likely small for typical manifests, but it is unconditional
and on the hot path for repeated operations.
Code

pacquet/crates/package-manifest/src/lib.rs[R157-160]

+        let mut value = self.value.clone();
+        convert_dependencies_to_engines_runtime(&mut value, "devDependencies", "devEngines")?;
+        convert_dependencies_to_engines_runtime(&mut value, "dependencies", "engines")?;
+        let contents = serde_json::to_string_pretty(&value)?;
Evidence
The new implementation explicitly deep-clones self.value before any conversion/serialization, and
save() is invoked after add/remove/update operations, so the additional clone runs on common
flows.

pacquet/crates/package-manifest/src/lib.rs[156-164]
pacquet/crates/package-manager/src/add.rs[305-306]
pacquet/crates/package-manager/src/remove.rs[142-143]
pacquet/crates/package-manager/src/update.rs[570-572]

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

## Issue description
`PackageManifest::save()` clones the entire `serde_json::Value` to apply runtime folding before serialization. This adds extra allocations proportional to manifest size on every save.
### Issue Context
The clone was introduced to avoid mutating the in-memory (reified) representation. If the project decides to keep that invariant, you can still reduce work by cloning only the touched subtrees (`devDependencies`, `dependencies`, `devEngines`, `engines`) or by producing a derived “written view” for serialization/eventing.
### Fix Focus Areas
- Consider returning the written `Value` from `save()` (or a helper) so the conversion is computed once and reused for both serialization and event emission.
- If keeping `&self`, consider a targeted clone strategy: construct `value` by shallow-cloning the root object and only deep-cloning the dependency/engine fields that will be modified.
#### Fix Focus Areas (paths/lines)
- pacquet/crates/package-manifest/src/lib.rs[156-164]

ⓘ 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 94b9fad

Results up to commit 94b9fad


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


Action required
1. Empty runtime not pruned 🐞 Bug ≡ Correctness
Description
isManagedRuntimeEntry treats version: "" as unmanaged via Boolean(runtime.version), so when a
dependency spec is runtime: (empty selector meaning “latest”), removing that dependency will not
prune the corresponding devEngines.runtime/engines.runtime entry. This leaves stale runtime
entries in package.json, contradicting the PR’s intended “removal prunes materialized runtime
entries” behavior for empty selectors too.
Code

pnpm11/workspace/project-manifest-reader/src/index.ts[R306-308]

+function isManagedRuntimeEntry (runtime: EngineDependency, runtimeName: string): boolean {
+  return runtime.name === runtimeName && runtime.onFail === 'download' && Boolean(runtime.version)
+}
Evidence
The writer hook explicitly derives version by stripping runtime:; for a runtime: dependency
this yields "", and the pruning path only deletes entries considered “managed.” The current
managed predicate excludes empty strings, even though the Rust side of this PR treats empty
selectors as “latest,” making empty selectors valid and expected.

pnpm11/workspace/project-manifest-reader/src/index.ts[244-285]
pnpm11/workspace/project-manifest-reader/src/index.ts[288-308]
pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[75-155]
pacquet/crates/package-manifest/src/lib.rs[424-445]

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

## Issue description
`isManagedRuntimeEntry()` currently uses `Boolean(runtime.version)`, which evaluates to `false` for an empty string. But this PR introduces/relies on empty runtime selectors (`runtime:`) being meaningful (interpreted as “latest”). As a result, managed runtime entries with `version: ""` are not pruned when the corresponding runtime dependency is removed.
### Issue Context
- `convertDependenciesToEnginesRuntime()` can produce `version === ""` when the dependency is `runtime:`.
- `removeManagedRuntimeEntry()` relies on `isManagedRuntimeEntry()`; with the current predicate, empty-version entries are never removed.
### Fix
- Update `isManagedRuntimeEntry()` to consider an empty string version as managed (e.g. `typeof runtime.version === 'string'` instead of `Boolean(runtime.version)`).
- Add a regression test in `pnpm11/workspace/project-manifest-reader/test/index.ts` covering a `runtime:` (empty) dependency being removed and verifying `devEngines.runtime` is pruned.
### Fix Focus Areas
- pnpm11/workspace/project-manifest-reader/src/index.ts[244-308]
- pnpm11/workspace/project-manifest-reader/test/index.ts[99-148]

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


2. Manifest event diverges disk 🐞 Bug ≡ Correctness
Description
PackageManifest::save() now writes a converted clone (folding runtime: deps into
devEngines.runtime/engines.runtime) but does not update self.value, so post-save code that
emits/uses manifest.value() can report a manifest that does not match the on-disk package.json.
This is user-visible via PackageManifestMessage::Updated emissions after add/remove/update (and
now runtime set), and can mislead any downstream consumer relying on that event as “what was
written.”
Code

pacquet/crates/package-manifest/src/lib.rs[R157-163]

+        let mut value = self.value.clone();
+        convert_dependencies_to_engines_runtime(&mut value, "devDependencies", "devEngines")?;
+        convert_dependencies_to_engines_runtime(&mut value, "dependencies", "engines")?;
+        let contents = serde_json::to_string_pretty(&value)?;
let mut file = fs::File::create(&self.path)?;
-        let contents = serde_json::to_string_pretty(&self.value)?;
file.write_all(contents.as_bytes())?;
Ok(())
Evidence
save() now serializes a converted clone (value) rather than self.value, but callers emit
manifest.value() after saving; since read_from_file() also applies the inverse conversion into
memory, this guarantees a post-save mismatch between the emitted “updated” manifest and the file
that was written.

pacquet/crates/package-manifest/src/lib.rs[156-164]
pacquet/crates/package-manifest/src/lib.rs[99-104]
pacquet/crates/package-manager/src/add.rs[305-330]
pacquet/crates/package-manager/src/remove.rs[142-156]
pacquet/crates/package-manager/src/update.rs[570-585]

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

## Issue description
`PackageManifest::save()` writes a transformed clone of the manifest (dependency → engines.runtime folding) but leaves `self.value` unchanged. Callers emit `PackageManifestMessage::Updated { updated: manifest.value().clone() }` after saving, so the emitted “updated” manifest can differ from what was actually persisted to disk.
### Issue Context
- `read_from_file()` already rewrites `devEngines/engines` into `*Dependencies` in-memory, so `PackageManifest::value()` is intentionally a “reified” view.
- With the new writer hook, the divergence becomes concrete after save: disk is engines-form, memory stays dependency-form.
### Fix Focus Areas
Pick one consistent contract and implement it end-to-end:
- Option A (minimal API churn): keep `self.value` as the internal/reified view, but make the *event payload* match the *written* manifest by emitting a converted clone (same conversion `save()` applies) instead of `manifest.value()`.
- Option B (stronger): introduce a `save_with_writeback(&mut self) -> Result<()>` (or `save_and_return_written_value(&self) -> Result<Value>`) so callers can both persist and emit the exact written JSON.
#### Fix Focus Areas (paths/lines)
- pacquet/crates/package-manifest/src/lib.rs[156-164]
- pacquet/crates/package-manifest/src/lib.rs[99-104]
- pacquet/crates/package-manager/src/add.rs[305-330]
- pacquet/crates/package-manager/src/remove.rs[142-156]
- pacquet/crates/package-manager/src/update.rs[570-585]

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


3. Runtime name not validated 🐞 Bug ≡ Correctness
Description
RuntimeArgs::set_request accepts any ` and constructs {name}@runtime:{spec}` without enforcing
the supported runtime allowlist, so unsupported names get routed through the normal add pipeline and
written into manifests/lockfiles. The runtime resolver/dep-path logic only recognizes
node|deno|bun, so other names will not be treated as runtimes and will mis-resolve or fail later.
Code

pacquet/crates/cli/src/cli_args/runtime.rs[R91-105]

+        let runtime_name = self
+            .params
+            .get(1)
+            .map(|name| name.trim())
+            .filter(|name| !name.is_empty())
+            .ok_or(RuntimeError::MissingRuntimeName)?;
+        let version_spec = self.params.get(2).map_or("", |version| version.trim());
+        let dependency_group = if self.save_dev || !self.save_prod {
+            DependencyGroup::Dev
+        } else {
+            DependencyGroup::Prod
+        };
+        Ok(RuntimeSetRequest {
+            package_name: format!("{runtime_name}@runtime:{version_spec}"),
+            dependency_group,
Evidence
The runtime CLI constructs the runtime dependency string from an unvalidated name, but runtime
resolution is only implemented for three specific aliases (node/deno/bun) and runtime depPath
detection is also restricted to those three, so any other runtime name cannot behave as intended and
will mis-resolve or fail downstream.

pacquet/crates/cli/src/cli_args/runtime.rs[84-106]
pacquet/crates/package-manifest/src/lib.rs[315-318]
pacquet/crates/deps-path/src/is_runtime_dep_path.rs[1-17]
pacquet/crates/engine-runtime-node-resolver/src/node_resolver.rs[258-266]
pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[75-83]

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

## Issue description
`pacquet runtime set <name> <version>` should only accept the runtime names that pacquet actually supports (`node`, `deno`, `bun`). Today, `RuntimeArgs::set_request` uses the raw `<name>` to build a dependency spec (`{name}@runtime:{version}`) without validating it.
This allows unsupported names to proceed into the add/install pipeline, producing manifest entries that are *not* resolvable by the runtime resolvers (which only engage for `node|deno|bun`) and are also not recognized as runtime depPaths by the byte-level runtime checks.
## Issue Context
- Supported runtime names are hard-coded elsewhere as `node`, `deno`, `bun`.
- Runtime resolvers only trigger when `WantedDependency.alias` matches the expected runtime name.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/runtime.rs[84-106]
## Suggested fix
- Add an allowlist check after parsing `runtime_name` and before constructing `package_name`.
- Introduce a dedicated error variant (e.g. `UnsupportedRuntimeName { name: String }`) so the user gets a clear message like "Unsupported runtime: <name>. Supported: node, deno, bun".
- Add/adjust unit tests to cover rejection of unsupported names (e.g. `python`, `@scope/node`).

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


View more (1)
4. Empty runtime selector breaks ✓ Resolved 🐞 Bug ≡ Correctness
Description
RuntimeArgs::set_request builds @runtime: when `` is omitted, but the runtime resolvers
interpret the empty selector literally and error because only "latest" is special-cased. This
makes pacquet runtime set node (and any manifest that contains runtime: with an empty body) fail
during resolution with NODEJS_VERSION_NOT_FOUND for an empty spec.
Code

pacquet/crates/cli/src/cli_args/runtime.rs[R97-105]

+        let version_spec = self.params.get(2).map_or("", |version| version.trim());
+        let dependency_group = if self.save_dev || !self.save_prod {
+            DependencyGroup::Dev
+        } else {
+            DependencyGroup::Prod
+        };
+        Ok(RuntimeSetRequest {
+            package_name: format!("{runtime_name}@runtime:{version_spec}"),
+            dependency_group,
Evidence
The CLI builds node@runtime: when no version is provided, but the Node resolver passes the
resulting empty selector through parse_node_specifier into resolve_node_version, which only
treats "latest" specially; an empty string therefore yields no satisfying version and triggers a
VersionNotFound error.

pacquet/crates/cli/src/cli_args/runtime.rs[84-107]
pacquet/crates/engine-runtime-node-resolver/src/parse_node_specifier.rs[39-78]
pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[75-86]
pacquet/crates/engine-runtime-node-resolver/src/node_resolver.rs[144-155]

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

## Issue description
`pacquet runtime set <name>` (no version) currently constructs `<name>@runtime:` and proceeds into the install/add pipeline, but the runtime resolvers do not normalize an empty `runtime:` selector to `latest`, causing resolution to fail.
## Issue Context
- The CLI explicitly allows a missing version and constructs `node@runtime:`.
- The Node runtime resolver ultimately calls `resolve_node_version(version_specifier)` which only handles the literal string `"latest"` as a default.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/runtime.rs[84-106]
- pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[75-86]
- pacquet/crates/engine-runtime-node-resolver/src/node_resolver.rs[144-155]
- pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[90-125]
- pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs[90-118]
## Suggested fix
Prefer fixing this at the resolver layer for parity with pnpm’s `node@runtime:` shape:
- In `resolve_node_version(...)`, treat `version_spec.is_empty()` the same as `version_spec == "latest"`.
- In bun/deno runtime resolvers, if the stripped `version_spec` is empty, substitute `"latest"` before delegating to the npm resolver.
This keeps accepting `node@runtime:` while making it resolve to the latest runtime successfully.

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



Remediation recommended
5. Silent runtime entry pruning 🐞 Bug ≡ Correctness
Description
convert_dependencies_to_engines_runtime calls remove_managed_runtime_entry whenever it can’t
read a runtime: entry from devDependencies/dependencies, including when those fields exist but
are not JSON objects. This can silently delete devEngines.runtime/engines.runtime entries on
save for malformed manifests instead of failing fast on the invalid dependency-map shape.
Code

pacquet/crates/package-manifest/src/lib.rs[R405-419]

+    for runtime_name in RUNTIME_NAMES {
+        let version = manifest
+            .get(deps_field)
+            .and_then(|deps| deps.get(runtime_name))
+            .and_then(Value::as_str)
+            .and_then(|dep| dep.strip_prefix("runtime:"))
+            .map(str::to_string);
+        if let Some(version) = version {
+            upsert_runtime_entry(manifest, engines_field, runtime_name, &version)?;
+            if let Some(deps) = manifest.get_mut(deps_field).and_then(Value::as_object_mut) {
+                deps.remove(runtime_name);
+            }
+        } else {
+            remove_managed_runtime_entry(manifest, engines_field, runtime_name);
+        }
Evidence
The save-time folding logic prunes managed runtime entries whenever it cannot extract a runtime:
dependency string; when the deps field is not an object, the lookup yields None and the prune
branch runs. Separately, read-time reification bails out early when the deps field is non-object,
making it possible for a malformed manifest to retain a managed runtime entry in memory and then
lose it on save.

pacquet/crates/package-manifest/src/lib.rs[99-104]
pacquet/crates/package-manifest/src/lib.rs[383-387]
pacquet/crates/package-manifest/src/lib.rs[400-420]

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

## Issue description
`convert_dependencies_to_engines_runtime` treats “can’t read runtime dep” the same as “runtime dep removed”, and will prune a managed `devEngines.runtime`/`engines.runtime` entry even when the dependency map field exists but is malformed (e.g. `devDependencies: []` or `"oops"`). This causes silent data loss on save.
## Issue Context
- Read-time reification (`convert_engines_runtime_to_dependencies`) already bails out when the deps field is not an object, so a malformed `devDependencies`/`dependencies` can leave `*Engines.runtime` intact in memory.
- The new save-time folding (`convert_dependencies_to_engines_runtime`) will then interpret the missing/unreadable runtime dependency as “removed” and prune the runtime entry.
## Fix Focus Areas
- pacquet/crates/package-manifest/src/lib.rs[400-422]
- pacquet/crates/package-manifest/src/lib.rs[383-387]
## Proposed fix
1. In `convert_dependencies_to_engines_runtime`, add a shape guard for `deps_field`:
- If `manifest.get(deps_field)` is `Some(v)` and `!v.is_object()`, return `Err(PackageManifestError::InvalidAttribute(...))`.
- This prevents the save path from silently deleting managed runtime entries when it cannot reliably determine whether the dependency was removed.
2. Add a unit test covering a malformed deps field, e.g.:
- Start with a manifest containing `devEngines.runtime` set to a managed entry and `devDependencies` set to a non-object.
- Assert `save()` (or `save_and_get_written_value()`) returns `InvalidAttribute` and does not rewrite the on-disk file.

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


6. Whitespace runtime spec not normalized 🐞 Bug ≡ Correctness
Description
runtime: selectors are only normalized when the selector is exactly empty; whitespace-only
selectors (e.g. "runtime: ") are preserved during manifest writeback and then treated as a
non-empty selector by runtime resolvers, leading to “no version found” resolution failures. This can
break installs for hand-edited package.json entries (or existing malformed data) despite the PR’s
intent that “empty means latest”.
Code

pacquet/crates/package-manifest/src/lib.rs[R406-412]

+        let Some(version) = manifest
+            .get(deps_field)
+            .and_then(|deps| deps.get(runtime_name))
+            .and_then(Value::as_str)
+            .and_then(|dep| dep.strip_prefix("runtime:"))
+            .map(str::to_string)
+        else {
Evidence
The manifest writeback hook copies the substring after runtime: verbatim (no trim), so
whitespace-only selectors can be persisted into engines.runtime.version. Resolver normalization
added in this PR only special-cases the empty string, and the resolver-side prefix stripping also
does not trim, so a whitespace selector will flow through as a non-empty selector and be parsed as a
range/tag instead of latest.

pacquet/crates/package-manifest/src/lib.rs[393-419]
pacquet/crates/package-manifest/src/lib.rs[340-376]
pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs[170-179]
pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[177-186]
pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[153-155]

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

## Issue description
Whitespace-only runtime selectors (e.g. `"runtime: "`) are currently treated as meaningful selectors instead of being normalized to `latest`. This can cause runtime resolution to fail even though empty/omitted selectors are intended to mean `latest`.
### Issue Context
- The manifest writer hook extracts the substring after `runtime:` without trimming, so a user-authored value like `"runtime: "` becomes a version string containing spaces.
- The runtime resolvers’ normalization only checks `is_empty()` and does not treat whitespace-only selectors as empty.
### Fix Focus Areas
- pacquet/crates/package-manifest/src/lib.rs[405-419]
- pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs[170-179]
- pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs[177-186]
- pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs[153-155]
### Suggested fix
1. Trim the selector after stripping `runtime:` in `...

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5533df5

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.00      4.9±0.10ms   878.0 KB/sec    1.00      4.9±0.41ms   881.8 KB/sec

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
pacquet/crates/package-manifest/src/lib.rs (1)

393-399: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Document the mutation and error contract.

This public writer hook mutates manifest, removes consumed dependency entries, and can return InvalidAttribute; the doc comment should state those postconditions/error cases.

♻️ Proposed doc update
 /// Mirrors upstream's `convertDependenciesToEnginesRuntime` writer hook in
 /// `workspace/project-manifest-reader`: the in-memory dependency form drives
 /// resolution and lockfile checks, while the on-disk manifest keeps the
 /// `devEngines.runtime` / `engines.runtime` contract.
+///
+/// On success, consumed `runtime:<version>` entries are removed from
+/// `deps_field`. Returns `InvalidAttribute` when the manifest root, the
+/// target engines field, or a matching runtime entry has an unsupported shape.

As per coding guidelines, "Doc comments (///, //!) document the contract including preconditions, postconditions, panics, and the reason the function exists."

🤖 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 `@pacquet/crates/package-manifest/src/lib.rs` around lines 393 - 399, The doc
comment for the public writer hook function that converts runtime dependencies
back into devEngines.runtime/engines.runtime is missing critical contract
information. Update the doc comment to explicitly document that the function
mutates the manifest parameter, specify that consumed dependency entries are
removed from the manifest, and document that it can return an InvalidAttribute
error case. This should be added to the existing doc comment that currently
describes the purpose and mirrors the upstream function behavior.

Source: Coding guidelines

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

Inline comments:
In `@pacquet/crates/package-manifest/src/lib.rs`:
- Around line 405-418: The code in the loop over RUNTIME_NAMES handles upserts
but does not properly clean up stale engines entries when runtime dependencies
are removed. When a runtime dependency with the "runtime:" prefix is removed via
deps.remove(runtime_name), the corresponding engines field entry (from either
engines_field or devEngines) is left untouched in the manifest, causing the
entry to persist and be re-added on the next read. After removing the runtime
dependency key from the dependency map, also remove the corresponding runtime
entry from the engines field by calling an appropriate remove operation on the
engines_field in the manifest to ensure consistency between the dependency map
and the engines field.

---

Nitpick comments:
In `@pacquet/crates/package-manifest/src/lib.rs`:
- Around line 393-399: The doc comment for the public writer hook function that
converts runtime dependencies back into devEngines.runtime/engines.runtime is
missing critical contract information. Update the doc comment to explicitly
document that the function mutates the manifest parameter, specify that consumed
dependency entries are removed from the manifest, and document that it can
return an InvalidAttribute error case. This should be added to the existing doc
comment that currently describes the purpose and mirrors the upstream function
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b640157-7e54-437e-b0f6-cde11a92945b

📥 Commits

Reviewing files that changed from the base of the PR and between d19da00 and a91c803.

📒 Files selected for processing (15)
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/runtime.rs
  • pacquet/crates/cli/src/cli_args/runtime/tests.rs
  • pacquet/crates/cli/src/cli_args/tests.rs
  • pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs
  • pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver/tests.rs
  • pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs
  • pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver/tests.rs
  • pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs
  • pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version/tests.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manifest/src/lib.rs
  • pacquet/crates/package-manifest/src/tests.rs
🚧 Files skipped from review as they are similar to previous changes (11)
  • pacquet/crates/cli/src/cli_args/tests.rs
  • pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rs
  • pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver/tests.rs
  • pacquet/crates/engine-runtime-bun-resolver/src/bun_resolver/tests.rs
  • pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rs
  • pacquet/crates/cli/src/cli_args/runtime.rs
  • pacquet/crates/cli/src/cli_args/runtime/tests.rs
  • pacquet/crates/package-manifest/src/tests.rs
  • pacquet/crates/engine-runtime-node-resolver/src/resolve_node_version/tests.rs
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: Rust CI / Test / macos
  • GitHub Check: Rust CI / Test / ubuntu
  • GitHub Check: Rust CI / Clippy
  • GitHub Check: Code Coverage
  • GitHub Check: Run benchmark on ubuntu-latest
🧰 Additional context used
📓 Path-based instructions (1)
pacquet/**/*.rs

📄 CodeRabbit inference engine (pacquet/AGENTS.md)

pacquet/**/*.rs: Declare a newtype wrapper for branded string types rather than collapsing into plain String or &str. Give the type its own struct so misuse is a type error.
If upstream always validates before construction of a branded string type, validate too. Wrap must construct only via TryFrom<String> and/or FromStr. Do not provide an infallible public constructor.
If upstream never validates a branded string type, just brand for type-safety by exposing an infallible From<String> (and From<&str> when convenient).
If upstream occasionally constructs a branded string type without validation, expose from_str_unchecked as an escape hatch while keeping the validating constructor as the default.
Match upstream serde behavior for branded types crossing JSON, YAML, or INI boundaries by using #[serde(try_from = "String")] for deserialization and #[serde(into = "String")] for serialization.
Derive simple conversions with derive_more for branded string wrappers using #[derive(derive_more::From)] and #[derive(derive_more::Into)] rather than handwriting impl blocks.
String-literal unions in upstream code should become Rust enums, not newtype wrappers, since the set of valid values is closed.
Template literal types in upstream code should be treated as branded string types with the same validation discipline: use a newtype wrapper with validation.
Warnings are errors with --deny warnings in lint. Do not silence them with #[allow(...)] unless there is a specific, justified reason.
Tests must not be tolerant of missing build/runtime environment by silently returning early when a tool isn't found. Let the test panic when required tools are absent.
No star imports inside module bodies. Write use super::{Foo, bar} instead of use super::*; for modules you control. External-crate preludes like use rayon::prelude::*; and root-of-module re-exports remain allowed.
Doc comments (///, //!) document the contract including preconditions, postcondi...

Files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
  • pacquet/crates/package-manifest/src/lib.rs
🧠 Learnings (7)
📚 Learning: 2026-05-20T19:40:55.051Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11774
File: pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs:0-0
Timestamp: 2026-05-20T19:40:55.051Z
Learning: In the pacquet Rust code, ensure the semver implementation uses the `node-semver` crate (not `nodejs-semver`). `node-semver`’s public API does not include a `satisfies_with_prerelease`-style method; prerelease-tolerant matching should be implemented inline by first calling `Range::satisfies`, and when it rejects a prerelease version, retry matching against a stripped `MAJOR.MINOR.PATCH` base of the prerelease version.

Applied to files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
  • pacquet/crates/package-manifest/src/lib.rs
📚 Learning: 2026-05-22T00:08:44.646Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11837
File: pacquet/crates/resolving-npm-resolver/src/pick_package.rs:33-51
Timestamp: 2026-05-22T00:08:44.646Z
Learning: In the pnpm/pnpm repo’s pacquet Rust crates, do not flag Unicode ellipsis characters (U+2026, `…`) in Rust doc comments (`///` / `/** */`) as a lint violation. The pacquet crate’s `dylint.toml` only enables `perfectionist::derive_ordering`, and the Dylint `unicode-ellipsis` rule is not enabled for this project—so `…` in doc comments is an intentional, repo-consistent style.

Applied to files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
  • pacquet/crates/package-manifest/src/lib.rs
📚 Learning: 2026-05-20T23:07:58.444Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11784
File: pacquet/crates/resolving-deps-resolver/src/hoist_peers.rs:120-133
Timestamp: 2026-05-20T23:07:58.444Z
Learning: When reviewing code in this pacquet Rust port, follow the upstream pnpm compatibility rule: only match pnpm’s behavior exactly. Do not propose review changes that intentionally deviate from pnpm’s documented/observed behavior, even if pnpm appears buggy. If you identify a real bug in pnpm behavior, the review should prioritize fixing it upstream in pnpm first, and avoid implementing a pnpm-behavior workaround here unless the same fix has already landed upstream.

Applied to files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
  • pacquet/crates/package-manifest/src/lib.rs
📚 Learning: 2026-06-06T18:58:37.156Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 12243
File: pacquet/crates/package-manager/src/install_package_by_snapshot.rs:319-322
Timestamp: 2026-06-06T18:58:37.156Z
Learning: When reviewing Rust code, do not assume `matches!(expr, Pattern(_))` will move out of `expr` if `Pattern(_)` contains no by-value bindings. `matches!` desugars to a `match` that auto-borrows the scrutinee for discrimination, so even if `expr` is a non-`Copy` value behind a shared reference (e.g., `&T`), the macro should not move-out of the borrowed data purely due to `matches!`. Treat `matches!(&expr, Pattern(_))` as a readability/clarity improvement, not a correctness requirement. Only flag potential move-out-of-borrow risks when the pattern includes by-value bindings that would require moving the matched value.

Applied to files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
  • pacquet/crates/package-manifest/src/lib.rs
📚 Learning: 2026-06-12T20:41:57.558Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 12364
File: pacquet/crates/package-manager/src/install/tests.rs:5717-5717
Timestamp: 2026-06-12T20:41:57.558Z
Learning: In the pnpm/pnpm Rust workspace (toolchain Rust 1.95.0), keep using `std::time::Duration::from_mins(...)` and `std::time::Duration::from_hours(...)` as-is. Do not flag these as invalid or suggest replacing them with `Duration::from_secs(...)`, because Clippy’s `clippy::duration_suboptimal_units` lint is denied by `-D warnings` in CI, and changing to seconds may trigger CI failures.

Applied to files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
  • pacquet/crates/package-manifest/src/lib.rs
📚 Learning: 2026-06-12T07:04:03.703Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 12227
File: pacquet/crates/package-manager/src/install.rs:708-719
Timestamp: 2026-06-12T07:04:03.703Z
Learning: In this pnpm-based repo’s package-manager Rust code, `ThrottledClient` uses a two-class semaphore scheduling policy (“reserved half” for tarball/download work and a higher-priority “latency class” for lockfile-verification metadata fetches). Therefore, when reviewing, do NOT flag reuse of the same `Arc<ThrottledClient>` for both downloads and verification as a budget/contention issue—this reuse is intentional and handled by the internal two-class “reserved permits” design. Creating a separate client instance would break the EMFILE guard behavior that relies on shared throttling.

Applied to files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
📚 Learning: 2026-06-16T00:37:05.024Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 12436
File: pacquet/crates/package-manager/src/install.rs:254-270
Timestamp: 2026-06-16T00:37:05.024Z
Learning: When reviewing the pacquet Rust port (package-manager crate), ensure any diagnostic `help`/message text included in error variants (e.g., `ERR_PNPM_*` codes) matches pnpm upstream error message strings verbatim. This includes user-facing strings and any pnpm-specific presentation (error code naming, `pnpm:*` log channels, pnpm user-agent expectations, etc.). If the help text references a command that is not yet implemented in pacquet (e.g., `approve-builds`), do not flag that as a review issue—porting/implementing the missing command is tracked separately; keep the user-facing message consistent with pnpm.

Applied to files:

  • pacquet/crates/package-manager/src/update.rs
  • pacquet/crates/package-manager/src/add.rs
  • pacquet/crates/package-manager/src/remove.rs
🔇 Additional comments (5)
pacquet/crates/package-manifest/src/lib.rs (2)

156-167: LGTM!


423-495: LGTM!

pacquet/crates/package-manager/src/add.rs (1)

305-329: LGTM!

pacquet/crates/package-manager/src/remove.rs (1)

142-155: LGTM!

pacquet/crates/package-manager/src/update.rs (1)

570-582: LGTM!

@codecov-commenter

codecov-commenter commented Jun 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.60870% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.04%. Comparing base (bae694f) to head (94b9fad).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pacquet/crates/cli/src/cli_args/runtime.rs 65.78% 13 Missing ⚠️
pacquet/crates/package-manifest/src/lib.rs 91.22% 10 Missing ⚠️
pacquet/crates/cli/src/cli_args.rs 37.50% 5 Missing ⚠️
...es/engine-runtime-bun-resolver/src/bun_resolver.rs 66.66% 2 Missing ⚠️
.../engine-runtime-deno-resolver/src/deno_resolver.rs 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12571      +/-   ##
==========================================
+ Coverage   87.99%   88.04%   +0.04%     
==========================================
  Files         324      326       +2     
  Lines       45693    46325     +632     
==========================================
+ Hits        40209    40786     +577     
- Misses       5484     5539      +55     

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@pnpm11/workspace/project-manifest-reader/src/index.ts`:
- Around line 306-307: The isManagedRuntimeEntry function incorrectly uses
Boolean(runtime.version) to check for version presence, which treats empty
strings as falsy and creates a mismatch with pacquet's Rust implementation that
treats any present string version as managed. Replace the
Boolean(runtime.version) check with a condition that properly validates the
presence of a version value (such as checking runtime.version !== undefined and
runtime.version !== null, or using typeof runtime.version === 'string') to
ensure alignment with pacquet's contract for managed runtime entry detection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 166cae25-c6b8-4109-aa48-827699b4d605

📥 Commits

Reviewing files that changed from the base of the PR and between a91c803 and 25e225d.

📒 Files selected for processing (5)
  • .changeset/prune-runtime-engine-removals.md
  • pacquet/crates/package-manifest/src/lib.rs
  • pacquet/crates/package-manifest/src/tests.rs
  • pnpm11/workspace/project-manifest-reader/src/index.ts
  • pnpm11/workspace/project-manifest-reader/test/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • pacquet/crates/package-manifest/src/tests.rs
  • pacquet/crates/package-manifest/src/lib.rs

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 25e225d

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 25e225d

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 22, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 94b9fad

@zkochan
zkochan merged commit 0ec878d into main Jun 22, 2026
32 of 33 checks passed
@zkochan
zkochan deleted the port-runtime branch June 22, 2026 12:25
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 94b9fad

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

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants