Repository navigation
feat(pacquet): port runtime command - #12571
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a ChangesRuntime subcommand, manifest conversion, and resolver normalization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~28 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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
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. Comment |
PR Summary by Qodofeat(pacquet): port pnpm runtime command to Rust CLI Description
Diagram
High-Level Assessment
Files changed (6)
|
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
pacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/runtime.rspacquet/crates/cli/src/cli_args/runtime/tests.rspacquet/crates/cli/src/cli_args/tests.rspacquet/crates/package-manifest/src/lib.rspacquet/crates/package-manifest/src/tests.rs
Code Review by Qodo
1. Empty runtime not pruned
|
|
Code review by qodo was updated up to the latest commit 5533df5 |
|
Code review by qodo was updated up to the latest commit d19da00 |
1 similar comment
|
Code review by qodo was updated up to the latest commit d19da00 |
|
Code review by qodo was updated up to the latest commit a91c803 |
Micro-Benchmark ResultsLinux |
|
Code review by qodo was updated up to the latest commit a91c803 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pacquet/crates/package-manifest/src/lib.rs (1)
393-399: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winDocument the mutation and error contract.
This public writer hook mutates
manifest, removes consumed dependency entries, and can returnInvalidAttribute; 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
📒 Files selected for processing (15)
pacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/runtime.rspacquet/crates/cli/src/cli_args/runtime/tests.rspacquet/crates/cli/src/cli_args/tests.rspacquet/crates/engine-runtime-bun-resolver/src/bun_resolver.rspacquet/crates/engine-runtime-bun-resolver/src/bun_resolver/tests.rspacquet/crates/engine-runtime-deno-resolver/src/deno_resolver.rspacquet/crates/engine-runtime-deno-resolver/src/deno_resolver/tests.rspacquet/crates/engine-runtime-node-resolver/src/resolve_node_version.rspacquet/crates/engine-runtime-node-resolver/src/resolve_node_version/tests.rspacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/remove.rspacquet/crates/package-manager/src/update.rspacquet/crates/package-manifest/src/lib.rspacquet/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 plainStringor&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 viaTryFrom<String>and/orFromStr. Do not provide an infallible public constructor.
If upstream never validates a branded string type, just brand for type-safety by exposing an infallibleFrom<String>(andFrom<&str>when convenient).
If upstream occasionally constructs a branded string type without validation, exposefrom_str_uncheckedas 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 withderive_morefor 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 Rustenums, 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 warningsin 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. Writeuse super::{Foo, bar}instead ofuse super::*;for modules you control. External-crate preludes likeuse 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.rspacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/remove.rspacquet/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.rspacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/remove.rspacquet/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.rspacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/remove.rspacquet/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.rspacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/remove.rspacquet/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.rspacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/remove.rspacquet/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.rspacquet/crates/package-manager/src/add.rspacquet/crates/package-manager/src/remove.rspacquet/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.rspacquet/crates/package-manager/src/add.rspacquet/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.rspacquet/crates/package-manager/src/add.rspacquet/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 Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
.changeset/prune-runtime-engine-removals.mdpacquet/crates/package-manifest/src/lib.rspacquet/crates/package-manifest/src/tests.rspnpm11/workspace/project-manifest-reader/src/index.tspnpm11/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
|
Code review by qodo was updated up to the latest commit 25e225d |
1 similar comment
|
Code review by qodo was updated up to the latest commit 25e225d |
|
Code review by qodo was updated up to the latest commit 94b9fad |
|
Code review by qodo was updated up to the latest commit 94b9fad |
Summary
Ports the existing pnpm runtime command surface to pacquet:
pacquet runtimeand thertalias withruntime set <name> <version><name>@runtime:<version>devEngines.runtime, supports--save-prodforengines.runtime, and preserves--save-devprecedenceruntime:<version>dependency entries back todevEngines.runtime/engines.runtime--globalbut rejects it because pacquet global package management has not been ported yetNo changeset is included because this is a pacquet-only Rust port and does not change a published TypeScript package.
Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.Written by an agent (Codex, GPT-5).
Summary by CodeRabbit
Release Notes
New Features
runtimeCLI subcommand (alias:rt) to manage runtimes and versions with--save-dev/--save-prod.Improvements
Bug Fixes
devEngines.runtime/engines.runtimeentry, including correct handling for arrays.Tests