Repository navigation
feat(cli): implement the access command for both pnpm and pacquet - #12816
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:
📝 WalkthroughWalkthroughThis PR adds a new ChangesTypeScript pnpm access command
Rust pacquet access command
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant pnpmCLI as pnpm CLI
participant AccessHandler as access.handler
participant Registry
User->>pnpmCLI: pnpm access set status=public pkg
pnpmCLI->>AccessHandler: handler(opts, params)
AccessHandler->>AccessHandler: validate subcommand and args
AccessHandler->>Registry: POST /pkg/access
Registry-->>AccessHandler: success or error response
AccessHandler-->>pnpmCLI: confirmation string or thrown error
pnpmCLI-->>User: printed output
sequenceDiagram
participant User
participant AccessArgs
participant Registry
User->>AccessArgs: run(config)
AccessArgs->>AccessArgs: build_access_context
AccessArgs->>Registry: HTTP request for list/get/set/grant/revoke
Registry-->>AccessArgs: response or error
AccessArgs-->>User: formatted result
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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(cli): add
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
51 rules 1.
|
|
Code review by qodo was updated up to the latest commit bc4ca8b |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12816 +/- ##
==========================================
- Coverage 85.80% 85.34% -0.47%
==========================================
Files 448 449 +1
Lines 69402 69951 +549
==========================================
+ Hits 59552 59697 +145
- Misses 9850 10254 +404 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (6)
pnpm11/registry-access/commands/src/access.ts (2)
368-373: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueError message omits "restricted" as an accepted value; redundant ternary on return.
Line 370's error message says
Must be "public" or "private", but line 369 also silently accepts"restricted". Separately, line 405's ternary is redundant sincenormalizedAccessis already only'public'or'restricted'.♻️ Suggested cleanup
- return `${packageName}: ${normalizedAccess === 'public' ? 'public' : 'restricted'}` + return `${packageName}: ${normalizedAccess}`Also applies to: 405-405
🤖 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 `@pnpm11/registry-access/commands/src/access.ts` around lines 368 - 373, Update access.ts so the validation in the access command matches the accepted values: the PnpmError in the status parsing branch should mention "restricted" alongside "public" and "private", and the normalization logic in accessValue handling should be simplified so the result is assigned directly without the redundant ternary. Use the accessValue and normalizedAccess logic in the access command as the place to make both fixes.
349-357: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicate
package: ${packageName}line across both branches.The line is pushed identically in both the
ifandelsebranches; hoist it above the conditional.♻️ Suggested simplification
const lines: string[] = [] - if (data.access) { - lines.push(`package: ${packageName}`) - lines.push(`access: ${data.access}`) - } else { - lines.push(`package: ${packageName}`) - lines.push('access: public') - } + lines.push(`package: ${packageName}`) + lines.push(`access: ${data.access ?? 'public'}`) return lines.join('\n')🤖 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 `@pnpm11/registry-access/commands/src/access.ts` around lines 349 - 357, The access output builder repeats the same `package: ${packageName}` push in both branches, so simplify `access.ts` by hoisting that line before the `if (data.access)` conditional in the `lines` construction logic. Keep the existing `data.access` handling in place for `access:` vs `access: public`, but remove the duplicated package entry from the `if`/`else` blocks.pnpm11/registry-access/commands/test/access.ts (1)
9-453: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSolid coverage; a few gaps worth adding.
Missing tests: default self-listing (
['list', 'packages']with no entity →-/-/package?format=cli), thegetStatuspublic-fallback branch whendata.accessis absent, and the missing-packageNamevalidation paths forgrant/revoke.🤖 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 `@pnpm11/registry-access/commands/test/access.ts` around lines 9 - 453, Add tests in the access command spec to cover the missing branches: verify `listPackages` with no entity defaults to self lookup and hits the `-/-/package?format=cli` endpoint, verify `getStatus` falls back correctly when `data.access` is absent, and add missing validation cases for `grant` and `revoke` when `packageName` is omitted. Use the existing `access.handler`, `getStatus`, `list packages`, `grant`, and `revoke` test patterns to locate the right assertions and keep the new cases aligned with the current mock-agent setup.pacquet/crates/cli/src/cli_args/access/tests.rs (3)
1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid star import in test module.
As per path instructions, pacquet's CODE_STYLE_GUIDE.md states to "avoid star imports in normal modules (tests included)".
use super::*;should be replaced with explicit imports of the symbols actually used (AccessArgs,Config,normalize_registry_url,escaped_package_name).♻️ Suggested fix
-use super::*; +use super::{AccessArgs, Config, escaped_package_name, normalize_registry_url};🤖 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/cli/src/cli_args/access/tests.rs` at line 1, The test module currently uses a star import via the top-level import in access/tests.rs, which violates the code style rule to avoid wildcard imports. Replace the blanket import with explicit imports for only the symbols used in this test module, namely AccessArgs, Config, normalize_registry_url, and escaped_package_name, so the test stays clear and aligned with CODE_STYLE_GUIDE.md.Source: Path instructions
1-266: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftNo HTTP-level (fixture/mocked-registry) tests, and no coverage of the
ls/ls-packages/ls-collaboratorsdispatch paths.Coverage here is limited to parsing/validation errors that never reach the network. None of
list_packages,list_collaborators,get_status,set_status,set_mfa,grant_access, orrevoke_access's actual request/response handling (success paths, 401/403/404/422 mapping, JSON output mode) is exercised, and thels/ls-packages/ls-collaboratorsforms flagged inaccess.rshave no regression test that would have caught the bug. Per pacquet AGENTS.md, tests spanning both stacks should stay aligned, and REVIEW_GUIDE.md calls for regression tests that fail without the fix.🤖 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/cli/src/cli_args/access/tests.rs` around lines 1 - 266, Add regression coverage in the access tests by exercising the real dispatch paths in AccessArgs::run, not just validation errors. Include mocked-registry/HTTP-level cases for list_packages, list_collaborators, get_status, set_status, set_mfa, grant_access, and revoke_access, and verify success plus response/error mapping (401/403/404/422 and JSON mode). Also add explicit tests for the ls, ls-packages, and ls-collaborators aliases in access.rs so the dispatch bug is caught if it regresses.Source: Path instructions
3-265: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing logging before non-
assert_eq!assertions.As per path instructions, pacquet's CODE_STYLE_GUIDE.md testing convention says to "log before non-assert_eq! assertions; avoid redundant logging for simple scalar assert_eq!." Every test here uses
assert!(err_str.contains(...))(notassert_eq!) without first loggingerr_str, so a failure won't show the actual error string in test output.♻️ Example fix pattern (repeat per test)
let err_str = format!("{err:?}"); + dbg!(&err_str); assert!(err_str.contains("ERR_PNPM_ACCESS_SUBCOMMAND_REQUIRED"));🤖 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/cli/src/cli_args/access/tests.rs` around lines 3 - 265, The tests in AccessArgs are missing the required logging before non-assert_eq! assertions, so failures won’t print the actual error string. In each test that uses err_str and assert!(err_str.contains(...)), add a log statement for err_str immediately before the assertion, following the existing test convention in this file. Keep the existing assert_eq! tests unchanged, and update the affected AccessArgs test cases consistently so the failure context is visible for ERR_PNPM_ACCESS_* checks.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pacquet/crates/cli/src/cli_args/access.rs`:
- Around line 816-833: The `fetch_error_from_response` helper has a dead
`StatusCode::NOT_FOUND` branch because both the 404 path and the fallback return
the same `AccessError::RegistryFetchFailed` value. Either remove the redundant
conditional and keep a single վերադարձ path in `fetch_error_from_response`, or,
if 404 is meant to be handled differently, update that branch to construct a
distinct error/message before returning it so the check has an effect.
- Around line 199-291: The `AccessArgs::run` subcommand parsing currently treats
`ls <arg>` as `list_packages`, which incorrectly accepts unsupported forms like
`ls collaborators`. Update the `match` on `(first.as_str(), second.as_deref())`
so `ls` only maps to `list_packages` for `ls` and `ls packages`, and route any
other `ls <arg>` input through the existing unknown-subcommand error path. Keep
the change localized in `AccessArgs::run` and preserve the current handling for
`list`, `get`, `set`, `public`, `restricted`, `grant`, and `revoke`.
- Around line 835-852: The 404 branch in write_error_from_response is dropping
the real package identifier by always constructing AccessError::PackageNotFound
with "unknown". Update the helper signature to accept package_name and pass it
through from the access command call sites so the NotFound path preserves the
actual package name. Keep the existing handling for the other status codes
unchanged.
In `@pacquet/crates/cli/src/cli_args/cli_command.rs`:
- Around line 130-132: Remove the extra visible alias from the
CliCommand::Access variant in cli_command.rs so the Rust CLI matches the TS
command surface. Update the Access enum entry to keep only the primary access
command and delete the accesses alias, ensuring clap registration stays aligned
with pnpm parity.
In `@pnpm11/registry-access/commands/src/access.ts`:
- Line 159: The default registry URL is hardcoded and duplicated across multiple
access command paths, so centralize it instead of repeating the literal in each
call site. Add a shared helper such as getRegistries in access.ts that returns
opts.registries or the default registry from configurable command/config inputs,
then update listPackages, listOwnPackages, listEntityPackages,
listCollaborators, getStatus, setStatus, setMfa, grantAccess, and revokeAccess
to use that helper and remove all inline fallbacks to the npm registry URL.
- Around line 188-251: The helper functions `listOwnPackages`,
`listEntityPackages`, and `fetchListResponse` take too many positional
parameters and should be refactored to use an options object for the shared
`registries`/`fetchFromRegistry`/`authHeader`/`jsonMode` bundle. Update the call
sites to pass a single options parameter, and adjust each function signature and
internal references accordingly while preserving the existing behavior and
URL-building logic. Apply the same consolidation pattern consistently across the
three functions so they stay within the argument guideline.
- Around line 552-555: The escapePackageName helper currently lets
npa(packageName) throw a raw parser error for malformed user input. Update
escapePackageName in access.ts to catch npa failures and rethrow them as a
PnpmError with the access command’s standard error handling, so all access
subcommands that use this helper keep the expected PnpmError contract. Keep the
fix localized to escapePackageName and preserve the existing
escapedName/encodeURIComponent fallback behavior for valid package names.
---
Nitpick comments:
In `@pacquet/crates/cli/src/cli_args/access/tests.rs`:
- Line 1: The test module currently uses a star import via the top-level import
in access/tests.rs, which violates the code style rule to avoid wildcard
imports. Replace the blanket import with explicit imports for only the symbols
used in this test module, namely AccessArgs, Config, normalize_registry_url, and
escaped_package_name, so the test stays clear and aligned with
CODE_STYLE_GUIDE.md.
- Around line 1-266: Add regression coverage in the access tests by exercising
the real dispatch paths in AccessArgs::run, not just validation errors. Include
mocked-registry/HTTP-level cases for list_packages, list_collaborators,
get_status, set_status, set_mfa, grant_access, and revoke_access, and verify
success plus response/error mapping (401/403/404/422 and JSON mode). Also add
explicit tests for the ls, ls-packages, and ls-collaborators aliases in
access.rs so the dispatch bug is caught if it regresses.
- Around line 3-265: The tests in AccessArgs are missing the required logging
before non-assert_eq! assertions, so failures won’t print the actual error
string. In each test that uses err_str and assert!(err_str.contains(...)), add a
log statement for err_str immediately before the assertion, following the
existing test convention in this file. Keep the existing assert_eq! tests
unchanged, and update the affected AccessArgs test cases consistently so the
failure context is visible for ERR_PNPM_ACCESS_* checks.
In `@pnpm11/registry-access/commands/src/access.ts`:
- Around line 368-373: Update access.ts so the validation in the access command
matches the accepted values: the PnpmError in the status parsing branch should
mention "restricted" alongside "public" and "private", and the normalization
logic in accessValue handling should be simplified so the result is assigned
directly without the redundant ternary. Use the accessValue and normalizedAccess
logic in the access command as the place to make both fixes.
- Around line 349-357: The access output builder repeats the same `package:
${packageName}` push in both branches, so simplify `access.ts` by hoisting that
line before the `if (data.access)` conditional in the `lines` construction
logic. Keep the existing `data.access` handling in place for `access:` vs
`access: public`, but remove the duplicated package entry from the `if`/`else`
blocks.
In `@pnpm11/registry-access/commands/test/access.ts`:
- Around line 9-453: Add tests in the access command spec to cover the missing
branches: verify `listPackages` with no entity defaults to self lookup and hits
the `-/-/package?format=cli` endpoint, verify `getStatus` falls back correctly
when `data.access` is absent, and add missing validation cases for `grant` and
`revoke` when `packageName` is omitted. Use the existing `access.handler`,
`getStatus`, `list packages`, `grant`, and `revoke` test patterns to locate the
right assertions and keep the new cases aligned with the current mock-agent
setup.
🪄 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: 433a7ea5-48f1-42fb-b0f1-493bfa1227fb
📒 Files selected for processing (13)
.changeset/access-command.mdpacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/access.rspacquet/crates/cli/src/cli_args/access/tests.rspacquet/crates/cli/src/cli_args/cli_command.rspacquet/crates/cli/src/cli_args/dispatch.rspacquet/crates/cli/src/cli_args/dispatch_query.rspnpm11/pnpm/src/cmd/index.tspnpm11/pnpm/src/cmd/notImplemented.tspnpm11/pnpm/test/cli.tspnpm11/registry-access/commands/src/access.tspnpm11/registry-access/commands/src/index.tspnpm11/registry-access/commands/test/access.ts
💤 Files with no reviewable changes (1)
- pnpm11/pnpm/src/cmd/notImplemented.ts
|
Code review by qodo was updated up to the latest commit e7f4505 |
|
Code review by qodo was updated up to the latest commit 03944f6 |
|
Code review by qodo was updated up to the latest commit 03944f6 |
|
Code review by qodo was updated up to the latest commit 0247fac |
|
Code review by qodo was updated up to the latest commit 0247fac |
|
Code review by qodo was updated up to the latest commit 19c132f |
| let registry = | ||
| args.registry.as_deref().map_or_else(|| config.registry.clone(), normalize_registry_url); | ||
|
|
||
| Ok(AccessContext { | ||
| config, | ||
| http_client: build_http_client(config)?, | ||
| retry_opts: RetryOpts { | ||
| retries: config.fetch_retries, | ||
| factor: config.fetch_retry_factor, | ||
| min_timeout: Duration::from_millis(config.fetch_retry_mintimeout), | ||
| max_timeout: Duration::from_millis(config.fetch_retry_maxtimeout), | ||
| }, | ||
| registry, | ||
| json: args.json, | ||
| otp: args.otp.clone(), | ||
| }) |
There was a problem hiding this comment.
2. Scoped registries ignored 🐞 Bug ≡ Correctness
The pacquet access command builds all request URLs from a single context.registry (config default or --registry) and never consults config.resolved_registries() / per-scope routes. This breaks access operations for packages hosted on scoped registries (@scope:registry), unlike other pacquet registry commands that route per package.
Agent Prompt
### Issue description
`AccessContext` stores only a single `registry` string and all subcommands construct URLs from it. This ignores pacquet’s scoped registry map (`config.resolved_registries()`), so access operations for packages that should route to `registries["@scope"]` will be sent to the wrong registry.
### Issue Context
Other pacquet registry commands (e.g. `dist-tag`) already build a registries map via `config.resolved_registries()` and then pick the correct registry per package using `pick_registry_for_package`.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/access.rs[191-304]
- pacquet/crates/cli/src/cli_args/access.rs[484-563]
- pacquet/crates/cli/src/cli_args/dist_tag.rs[193-220]
### Suggested fix
- Change `AccessContext` to store `registries: HashMap<String, String>` (from `config.resolved_registries()`), and if `--registry` is set, override `registries["default"]` (same pattern as `dist-tag`).
- For per-package subcommands (`list_collaborators`, `get_status`, `set_status`, `set_mfa`, `grant`, `revoke`), compute `registry_url = pick_registry_for_package(&context.registries, package_name, None)` and build URLs/auth headers from that.
- For team/org listing (`list packages <scope>` / `<scope:team>`), pick the registry based on the scope key `"@{scope}"` when present, else fall back to `default`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 19c132f |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.097978144440001,
"stddev": 0.11799254391220046,
"median": 4.06286305574,
"user": 3.99673424,
"system": 3.4114751400000003,
"min": 3.9422468467400003,
"max": 4.32921602774,
"times": [
4.12256620574,
4.05695437874,
4.32921602774,
3.9422468467400003,
4.0517488547400005,
3.95600930274,
4.06877173274,
4.21243622174,
4.1834806567400005,
4.05635121674
]
},
{
"command": "pacquet@main",
"mean": 4.05907661504,
"stddev": 0.11095960650627094,
"median": 4.01407544724,
"user": 3.9142826399999997,
"system": 3.4117087399999995,
"min": 3.93954513174,
"max": 4.26943348774,
"times": [
3.95502531174,
4.13000596174,
3.99029926074,
4.00296451474,
4.02518637974,
3.93954513174,
4.26943348774,
4.20830111074,
4.07949045074,
3.99051454074
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1017497884400003,
"stddev": 0.1072150608690269,
"median": 2.05925988824,
"user": 2.73751224,
"system": 2.8970384399999998,
"min": 2.00418509174,
"max": 2.31208729174,
"times": [
2.2415450747400003,
2.00699576974,
2.17701197374,
2.02937181674,
2.0644987877400003,
2.31208729174,
2.10712568474,
2.0206554047400003,
2.00418509174,
2.05402098874
]
},
{
"command": "pnpr@main",
"mean": 2.1277883153399997,
"stddev": 0.1337066422274206,
"median": 2.09245424124,
"user": 2.73090944,
"system": 2.91419444,
"min": 1.9679992637400001,
"max": 2.3427370827400003,
"times": [
2.02972863874,
1.9679992637400001,
2.3427370827400003,
1.9982519997400001,
2.06688664174,
2.31662181974,
2.16126981874,
2.03338148874,
2.11802184074,
2.24298455874
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6457191879799999,
"stddev": 0.014109631521584589,
"median": 0.64390330978,
"user": 0.37460346,
"system": 1.3213117399999998,
"min": 0.62813164728,
"max": 0.66884652328,
"times": [
0.62813164728,
0.63424433428,
0.6283905212800001,
0.66265185128,
0.66884652328,
0.6394691032800001,
0.64800143128,
0.63980518828,
0.65684170828,
0.65080957128
]
},
{
"command": "pacquet@main",
"mean": 0.74547750858,
"stddev": 0.06773671234228641,
"median": 0.7239161992800001,
"user": 0.39049366,
"system": 1.38757844,
"min": 0.70617976228,
"max": 0.93403875028,
"times": [
0.72967105728,
0.71594798728,
0.72308714228,
0.75564955828,
0.7095121802800001,
0.70617976228,
0.71985284928,
0.73609054228,
0.7247452562800001,
0.93403875028
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7237917621800001,
"stddev": 0.06886779919102803,
"median": 0.70280107128,
"user": 0.39236336,
"system": 1.35307094,
"min": 0.68178192128,
"max": 0.9149055582800001,
"times": [
0.68537406828,
0.69538089228,
0.70275908528,
0.68178192128,
0.70781403028,
0.7122691022800001,
0.69788293528,
0.7028430572800001,
0.9149055582800001,
0.73690697128
]
},
{
"command": "pnpr@main",
"mean": 0.71340337028,
"stddev": 0.05880938609392044,
"median": 0.6979957642800001,
"user": 0.39434096,
"system": 1.34926664,
"min": 0.67761364028,
"max": 0.87774834428,
"times": [
0.70931449928,
0.69800002228,
0.67761364028,
0.70163317928,
0.68668232828,
0.6819436492800001,
0.69101531628,
0.87774834428,
0.71209121728,
0.6979915062800001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.266241044100001,
"stddev": 0.03165752126346309,
"median": 4.261551122,
"user": 3.8647984200000005,
"system": 3.2951895799999997,
"min": 4.2221027505,
"max": 4.328801177500001,
"times": [
4.328801177500001,
4.2981155565,
4.2542367175,
4.274939740500001,
4.2393835515000005,
4.2688655265,
4.2470022505000005,
4.2846996155,
4.2221027505,
4.244263554500001
]
},
{
"command": "pacquet@main",
"mean": 4.232511811499999,
"stddev": 0.03601387526304319,
"median": 4.235146050500001,
"user": 3.85777842,
"system": 3.2372632799999996,
"min": 4.1809513755,
"max": 4.2736530915,
"times": [
4.1809513755,
4.2661604805,
4.251017351500001,
4.2014081835,
4.2736530915,
4.2735062065000005,
4.259948528500001,
4.2192747495,
4.2068363235,
4.192361824500001
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1663522772,
"stddev": 0.168858660843664,
"median": 2.0984328239999996,
"user": 2.5732368200000004,
"system": 2.81429088,
"min": 1.9707050604999998,
"max": 2.4108871874999998,
"times": [
1.9707050604999998,
2.0702570195,
2.0064956805,
2.1082196735,
2.3266772435,
2.4081216725,
2.0175307284999997,
2.4108871874999998,
2.2559825315,
2.0886459745
]
},
{
"command": "pnpr@main",
"mean": 2.1146014608000003,
"stddev": 0.09101015083033628,
"median": 2.1189585634999997,
"user": 2.57416912,
"system": 2.81224818,
"min": 1.9537379735,
"max": 2.2780500815,
"times": [
2.1090241525,
2.2053443914999997,
2.1605853515,
2.1233326235,
2.1228953675,
1.9537379735,
2.0394074585,
2.1150217595,
2.0386154485,
2.2780500815
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.3868032276600002,
"stddev": 0.013717822765301297,
"median": 1.3838608684600002,
"user": 1.33986296,
"system": 1.6919989599999998,
"min": 1.36504167746,
"max": 1.40311621146,
"times": [
1.40311621146,
1.3990919674600002,
1.40143059946,
1.37205191946,
1.4017291734600001,
1.3839954324600001,
1.3808048344600001,
1.37704415646,
1.3837263044600001,
1.36504167746
]
},
{
"command": "pacquet@main",
"mean": 1.4176259149600001,
"stddev": 0.026381162683571307,
"median": 1.4166004449600003,
"user": 1.38369226,
"system": 1.6912929599999997,
"min": 1.38309941546,
"max": 1.46088295246,
"times": [
1.38512108046,
1.46088295246,
1.44303704146,
1.4233267544600001,
1.43197465146,
1.39872202646,
1.44048175046,
1.3997393414600001,
1.4098741354600002,
1.38309941546
]
},
{
"command": "pnpr@HEAD",
"mean": 0.65923588596,
"stddev": 0.008829869974675374,
"median": 0.6602941479600001,
"user": 0.34245826,
"system": 1.26587906,
"min": 0.6446556024600001,
"max": 0.6742827884600001,
"times": [
0.65220347046,
0.6446556024600001,
0.6577030384600001,
0.6742827884600001,
0.6604598464600001,
0.66012844946,
0.6605528464600001,
0.6624490544600001,
0.6698485714600001,
0.65007519146
]
},
{
"command": "pnpr@main",
"mean": 0.6447401422600001,
"stddev": 0.003653340845044923,
"median": 0.6439806569600001,
"user": 0.34303876,
"system": 1.25611816,
"min": 0.6397439024600001,
"max": 0.6500750234600001,
"times": [
0.6426496434600001,
0.6449081414600001,
0.6427353784600001,
0.64305317246,
0.6406387154600001,
0.6498860364600001,
0.6481170994600001,
0.6455943094600001,
0.6397439024600001,
0.6500750234600001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0740343566599995,
"stddev": 0.034049522679091455,
"median": 3.06251292376,
"user": 1.7956357,
"system": 1.9946665999999997,
"min": 3.0352612947599997,
"max": 3.14417173376,
"times": [
3.05404948576,
3.06226901476,
3.0550209327599998,
3.04555778276,
3.06275683276,
3.0734315577599998,
3.11785045976,
3.0352612947599997,
3.14417173376,
3.0899744717599997
]
},
{
"command": "pacquet@main",
"mean": 3.09812217936,
"stddev": 0.031122000993982497,
"median": 3.09153239826,
"user": 1.7952073000000002,
"system": 2.0194403,
"min": 3.05643929776,
"max": 3.17751966676,
"times": [
3.0907762767599998,
3.09946437876,
3.0891643537599998,
3.08676409876,
3.1097834507599997,
3.08271203276,
3.09630971776,
3.09228851976,
3.17751966676,
3.05643929776
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6556601531600001,
"stddev": 0.011651203692996314,
"median": 0.65158901626,
"user": 0.3421227,
"system": 1.2672759999999998,
"min": 0.64050826076,
"max": 0.6731948467600001,
"times": [
0.64050826076,
0.66436481776,
0.64132305176,
0.65039761076,
0.6506777517600001,
0.6483589887600001,
0.66820351276,
0.66707240976,
0.65250028076,
0.6731948467600001
]
},
{
"command": "pnpr@main",
"mean": 0.6565057216600001,
"stddev": 0.007348436987152904,
"median": 0.65477339176,
"user": 0.35175769999999995,
"system": 1.2651849,
"min": 0.64891924576,
"max": 0.67437685776,
"times": [
0.64911706276,
0.66165982376,
0.64891924576,
0.67437685776,
0.65388540476,
0.65554101276,
0.6571223927600001,
0.65296238376,
0.65400577076,
0.65746726176
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6752344482000001,
"stddev": 0.012809110458163376,
"median": 0.6700462891000001,
"user": 0.6339931200000001,
"system": 0.15394416,
"min": 0.6631468206000001,
"max": 0.6998729246000001,
"times": [
0.6998729246000001,
0.6673961986000001,
0.6726963796000001,
0.6655095306000001,
0.6631468206000001,
0.6892108796,
0.6829658476,
0.6830916866000001,
0.6632611666,
0.6651930476000001
]
},
{
"command": "pacquet@main",
"mean": 0.6757341656000001,
"stddev": 0.009330102962832534,
"median": 0.6764903096000001,
"user": 0.63363972,
"system": 0.15340826000000002,
"min": 0.6604198446,
"max": 0.6924797876000001,
"times": [
0.6729848766000001,
0.6740989686000001,
0.6650338376,
0.6695555076,
0.6604198446,
0.6819626196,
0.6788816506,
0.6820208466000001,
0.6924797876000001,
0.6799037166
]
},
{
"command": "pnpr@HEAD",
"mean": 0.1122326887666667,
"stddev": 0.0006461353662937328,
"median": 0.11230579010000001,
"user": 0.02754290333333333,
"system": 0.021294593333333334,
"min": 0.11058630760000002,
"max": 0.11325104960000001,
"times": [
0.11203847860000002,
0.11247648660000001,
0.1121570166,
0.11225372160000001,
0.11146108560000001,
0.11316432960000002,
0.11210794860000001,
0.11165294960000001,
0.11241920060000002,
0.11270912660000001,
0.11199204860000002,
0.11166044060000001,
0.1122863406,
0.11255162860000001,
0.11235792260000001,
0.11325104960000001,
0.11058630760000002,
0.11260817860000001,
0.1129256316,
0.11102979360000001,
0.11232523960000002,
0.1126559356,
0.11181941460000001,
0.11309425460000001
]
},
{
"command": "pnpr@main",
"mean": 0.11004554936000002,
"stddev": 0.0023121852267261934,
"median": 0.1112943806,
"user": 0.02758096000000001,
"system": 0.02125278,
"min": 0.10721576860000001,
"max": 0.11300745360000002,
"times": [
0.10742067160000002,
0.11183784760000001,
0.10721576860000001,
0.10734668060000001,
0.10726282960000001,
0.10765930060000001,
0.1112943806,
0.10736562960000001,
0.11300745360000002,
0.11149650860000002,
0.10729377160000002,
0.11271147460000001,
0.11172236960000001,
0.11189333660000002,
0.10796642760000001,
0.11126737060000001,
0.10819064460000001,
0.11243792460000002,
0.10755545460000002,
0.11201312560000001,
0.11186507860000001,
0.10763964660000001,
0.11273718360000001,
0.11224970660000001,
0.11168814760000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.77368143734,
"stddev": 0.07289331560137209,
"median": 6.74725849224,
"user": 4.1958851,
"system": 3.6539015399999997,
"min": 6.68823319424,
"max": 6.90787309224,
"times": [
6.85959446124,
6.73133741824,
6.7150284322400005,
6.75417429624,
6.68823319424,
6.7324490182400005,
6.74321366124,
6.90787309224,
6.8536074762400006,
6.75130332324
]
},
{
"command": "pacquet@main",
"mean": 6.873889363340001,
"stddev": 0.11133131460032494,
"median": 6.9104037182399995,
"user": 4.1275733,
"system": 3.62402864,
"min": 6.70325597524,
"max": 7.040486688240001,
"times": [
6.921530321240001,
6.90686676524,
6.94683645224,
6.91394067124,
6.95468470824,
7.040486688240001,
6.76589820424,
6.71199817824,
6.87339566924,
6.70325597524
]
},
{
"command": "pnpr@HEAD",
"mean": 4.94221442154,
"stddev": 0.12178958671822723,
"median": 4.9464434952400005,
"user": 2.8588229000000003,
"system": 3.0962908399999995,
"min": 4.74030438724,
"max": 5.10165818924,
"times": [
5.10165818924,
4.80549409724,
4.92400494424,
5.09155954324,
4.977742027240001,
4.9594508932400005,
4.83394804324,
4.93343609724,
5.0545459932400005,
4.74030438724
]
},
{
"command": "pnpr@main",
"mean": 4.93439178164,
"stddev": 0.073931450678143,
"median": 4.92560903774,
"user": 2.8517826,
"system": 3.13049654,
"min": 4.7999686312400005,
"max": 5.03700427024,
"times": [
5.03700427024,
5.03462619524,
4.97561733424,
4.87922123724,
4.8899072422400005,
4.97991510024,
4.93448815424,
4.89643973024,
4.7999686312400005,
4.91672992124
]
}
]
} |
|
Code review by qodo was updated up to the latest commit 9bc6fab |
|
Code review by qodo was updated up to the latest commit adba1b7 |
|
Code review by qodo was updated up to the latest commit 92353a4 |
| let url = match (entity_type, entity) { | ||
| (Some("team"), Some(team_str)) => { | ||
| let parts: Vec<&str> = team_str.splitn(2, ':').collect(); | ||
| let scope = parts[0].strip_prefix('@').unwrap_or(parts[0]); | ||
| let team = parts.get(1).unwrap_or(&""); | ||
| let team_path = if team.is_empty() { | ||
| String::new() | ||
| } else { | ||
| format!("{}/", encode_uri_component(team)) | ||
| }; | ||
| format!( | ||
| "{}-/team/{}{}package?format=cli", | ||
| normalize_registry_url(&context.registry), | ||
| encode_uri_component(scope), | ||
| team_path, | ||
| ) |
There was a problem hiding this comment.
1. Team list url malformed 🐞 Bug ≡ Correctness
pacquet’s access list packages team path concatenates the encoded scope directly with the encoded team segment without a /, producing /-/team/<scope><team>/package?format=cli instead of /-/team/<scope>/<team>/package?format=cli. This breaks pnpm access list packages <scope:team> for valid inputs and can send requests to an unintended endpoint.
Agent Prompt
## Issue description
In `pacquet`’s `list_packages()` implementation for team entities, the URL format string is missing a `/` separator between the scope and team path segments, so requests for `scope:team` are constructed incorrectly and likely fail.
## Issue Context
Current code builds:
`.../-/team/{scope}{team}/package?format=cli`
when it should be:
`.../-/team/{scope}/{team}/package?format=cli`
This affects the core `access list packages <scope:team>` workflow.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/access.rs[334-350]
## Implementation notes
- Simplify the URL construction to avoid the `team_path` concatenation bug, e.g.:
- `format!("{}-/team/{}/{}/package?format=cli", base, scope_enc, team_enc)`
- Add validation for `scope:team` ensuring both parts are non-empty; if invalid, return a dedicated `AccessError` (recommended) rather than constructing a malformed URL.
- Add a unit test that asserts the generated URL/path for a team list request contains `/-/team/<scope>/<team>/package?format=cli`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 92353a4 |
92353a4 to
2f4493e
Compare
2f4493e to
a876773
Compare
- Remove duplicate dlx_resolves_caller_catalog_references_in_overrides test in dlx.rs - Remove duplicate function definitions in installability.rs from rebase artifact - Fix C1 sanitize fast-path in sanitize.rs: use chars().any() for full detection - Fix OTP redirect leak on TS side in fetchFromRegistry.ts: always delete npm-otp
a876773 to
90bbc23
Compare

Summary
This PR implements the
pnpm accesscommand in both the TypeScript pnpm CLI and the Rust pacquet port, providing full registry access management following npm'snpm accessparadigm. The command supports listing packages and collaborators, getting and setting package visibility status and MFA requirements, and granting or revoking team access to packages.Squash Commit Body
Checklist
The change is implemented in both the TypeScript CLI and the Rust pacquet port. A changeset was added (feat for both @pnpm/registry-access.commands and pnpm). Added tests for the TypeScript handler (mock agent) and Rust parameter validation and error handling. Documentation was not updated as part of this PR.
Summary by CodeRabbit
pnpm accesscommand to manage registry package visibility and team access.--jsonoutput and--otpfor MFA-protected operations; deprecatedpublic/restrictedforms are mapped to the canonical status setting.