Skip to content

fix(pacquet): align licenses with TypeScript pnpm - #13441

Merged
zkochan merged 3 commits into
mainfrom
fix-13438
Jul 27, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix-13438

Conversation

@zkochan

@zkochan zkochan commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • scan every importer in a workspace for pnpm licenses list, matching the TypeScript CLI's default scope
  • exclude optional packages that do not support the effective host or configured supportedArchitectures, including constraints inferred from platform package names
  • render the (dev) classification for development-only dependencies
  • verify the reported Prisma lockfile produces the same 1,177 normalized package names as TypeScript pnpm

Fixes #13438.

Squash Commit Body

Pacquet's licenses command scanned only the active workspace importer unless recursive mode was explicitly selected. TypeScript pnpm scans every lockfile importer by default, so large workspaces lost dependencies that were reachable only from other projects.

Collect dependencies from every importer in the default mode and filter unsupported optional package subtrees with the same declared and package-name-inferred platform constraints used during installation. Preserve dependency-group priority while walking the graph and render development-only packages with the same `(dev)` suffix as TypeScript pnpm.

Fixes pnpm/pnpm#13438.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

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


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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed pnpm licenses list to aggregate dependencies from every workspace project and label each entry by dependency type (prod, optional, dev).
    • Excluded license entries for packages not supported on the current platform and improved how dev-only items are displayed in table output.
    • Sanitized long-form “Details” output for cleaner, safer rendering.
  • Tests
    • Added tests covering dependency collection, dependency-type classification, and dev-only package name formatting.

Copilot AI review requested due to automatic review settings July 27, 2026 20:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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: e83bc556-7339-4394-b68a-9e59e9fb683f

📥 Commits

Reviewing files that changed from the base of the PR and between 427ce72 and 7e586f5.

📒 Files selected for processing (2)
  • pnpm/crates/cli/src/cli_args/licenses.rs
  • pnpm/crates/cli/src/cli_args/licenses/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/cli/src/cli_args/licenses/tests.rs
  • pnpm/crates/cli/src/cli_args/licenses.rs

📝 Walkthrough

Walkthrough

The Rust pnpm licenses list implementation now collects dependencies across selected workspace importers, filters unsupported platform packages, tracks production/optional/development classification, and renders development dependencies with a (dev) suffix.

Changes

License dependency reporting

Layer / File(s) Summary
Dependency collection and platform filtering
pnpm/crates/cli/src/cli_args/licenses.rs, pnpm/crates/cli/src/cli_args/licenses/tests.rs
Dependency traversal was extracted into collect_dependencies, which returns dependency kinds and filters unsupported platform subtrees using package metadata and host settings.
License output classification and validation
pnpm/crates/cli/src/cli_args/licenses.rs, pnpm/crates/cli/src/cli_args/licenses/tests.rs, .changeset/fuzzy-dodos-report.md
License entries retain dependency classification, development packages render with a dimmed (dev) suffix, details are sanitized, and tests cover traversal, filtering, classification, and formatting.

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

Sequence Diagram(s)

sequenceDiagram
  participant LicensesArgs
  participant collect_dependencies
  participant Lockfile
  participant LicenseOutput
  LicensesArgs->>collect_dependencies: selected importers and include options
  collect_dependencies->>Lockfile: traverse dependency snapshots
  Lockfile-->>collect_dependencies: package keys and platform metadata
  collect_dependencies-->>LicensesArgs: dependency kinds
  LicensesArgs->>LicenseOutput: build and render license entries
  LicenseOutput-->>LicensesArgs: dev packages with "(dev)" suffix
Loading

Assessment against linked issues

Objective Addressed Explanation
[#13438] Report the same dependency set as TypeScript pnpm, including workspace dependencies and excluding unsupported platform packages. ✅
[#13438] Preserve production/development classification and license output data. ✅

Possibly related PRs

  • pnpm/pnpm#13090: Both changes update Rust license dependency classification and output handling.
  • pnpm/pnpm#13427: Both changes intersect on sanitization of rendered license details.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13438

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix pacquet licenses list to match TypeScript pnpm scope and filtering

🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Scan all workspace importers by default when collecting license dependencies.
• Filter out unsupported optional platform packages (including name-inferred constraints).
• Render development-only dependencies with a (dev) suffix to match pnpm.
Diagram

graph TD
  A["pnpm licenses list"] --> B["Lockfile importers"] --> C["collect_dependencies()"] --> D{"Platform supported?"}
  D -->|"yes"| E["LicenseInfo grouped"] --> F["Table/JSON output"]
  D -->|"no"| X["Skip optional subtree"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract shared dependency-walk helper (licenses + SBOM)
  • ➕ Reduces duplication/drift between commands that traverse lockfile graphs
  • ➕ Centralizes platform/architecture filtering rules and host-detection wiring
  • ➖ Requires refactor across multiple modules; larger surface area for regressions
  • ➖ May be harder to land quickly as a targeted bug fix
2. Add a flag for 'scan all importers' instead of changing default
  • ➕ Lower risk of surprising existing users relying on current default behavior
  • ➕ Keeps backward compatibility while offering TypeScript-parity mode
  • ➖ Does not align with pnpm/TypeScript default behavior that users expect
  • ➖ Would leave Rust pnpm licenses list reports a different dependency set #13438 effectively unresolved in default usage

Recommendation: The PR’s approach is the right default: it matches TypeScript pnpm’s effective scope (all importers) and applies installability rules to optional platform packages, which prevents reporting dependencies that are unreachable on the host. Consider a follow-up refactor to share the traversal/filtering logic with other lockfile-walking commands to reduce future divergence.

Files changed (3) +233 / -83

Bug fix (1) +136 / -82
licenses.rsScan all importers, filter unsupported optional packages, and render (dev) suffix +136/-82

Scan all importers, filter unsupported optional packages, and render (dev) suffix

• Changes default dependency collection to include all lockfile importers (not just the active project) and extracts traversal into 'collect_dependencies()'. Adds platform/architecture filtering for optional packages (including name-inferred constraints) and tracks dependency group priority to render development-only packages with a dimmed '(dev)' suffix in table output.

pnpm/crates/cli/src/cli_args/licenses.rs

Tests (1) +92 / -1
tests.rsAdd tests for importer-wide collection, platform filtering, and dev rendering +92/-1

Add tests for importer-wide collection, platform filtering, and dev rendering

• Introduces a lockfile-based unit test ensuring dependencies are collected from every importer while unsupported optional subtrees are excluded. Adds a focused test verifying '(dev)' suffix rendering for development-only dependencies.

pnpm/crates/cli/src/cli_args/licenses/tests.rs

Documentation (1) +5 / -0
fuzzy-dodos-report.mdAdd changeset for pacquet licenses behavior fix +5/-0

Add changeset for pacquet licenses behavior fix

• Adds a patch changeset describing the corrected 'pnpm licenses list' behavior: scanning all workspace projects, filtering unsupported platform packages, and marking dev dependencies.

.changeset/fuzzy-dodos-report.md

@greptile-apps

greptile-apps Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

The prior platform-filtering defect is fixed because filtering is now restricted to snapshots marked optional, while required platform-constrained packages and their transitive dependencies remain in the report; no blocking failure remains.

Reviews (3): Last reviewed commit: "fix(cli): harden licenses terminal outpu..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     12.4±0.39ms    30.2 MB/sec    1.13     14.0±0.21ms    26.8 MB/sec
packument/parse                                  1.00     41.9±1.22µs  1583.6 MB/sec    1.11     46.5±1.09µs  1427.5 MB/sec
tarball/download_dependency                      1.11      3.5±0.40ms  1228.4 KB/sec    1.00      3.2±0.25ms  1367.8 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   204.1±12.38ms 78.4 KElem/sec    1.27   258.7±17.06ms 61.8 KElem/sec

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

codecov-commenter commented Jul 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.99099% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.64%. Comparing base (bcd0b3c) to head (7e586f5).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/licenses.rs 90.99% 10 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13441   +/-   ##
=======================================
  Coverage   87.64%   87.64%           
=======================================
  Files         545      545           
  Lines       93897    93978   +81     
=======================================
+ Hits        82292    82367   +75     
- Misses      11605    11611    +6     

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

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Missing (optional) package suffix 📘 Rule violation ⌂ Architecture ⭐ New
Description
render_package_name does not render the (optional) classification for BelongsTo::Optional,
which makes pnpm licenses list output diverge from pnpm TypeScript behavior. This is a
user-visible mismatch (optional deps are displayed without the expected marker).
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R420-425]

+    let name = sanitize_inline(&info.name);
+    let suffix = match info.belongs_to {
+        BelongsTo::Prod | BelongsTo::Optional => return name.into_owned(),
+        BelongsTo::Dev => "(dev)",
+    };
+    format!("{} {}", name, suffix.if_supports_color(Stream::Stdout, |text| text.dimmed()))
Relevance

⭐⭐⭐ High

Small user-visible CLI parity fix; repo frequently accepts Rust↔TS behavior-sync adjustments.

PR-#12789
PR-#13203

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
In the Rust implementation, BelongsTo::Optional is treated the same as BelongsTo::Prod, so no
(optional) marker is ever shown. pnpm TypeScript’s licenses output explicitly renders (optional)
for optional dependencies, so the current Rust behavior is not in sync.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm/crates/cli/src/cli_args/licenses.rs[420-425]
pnpm11/deps/compliance/commands/src/licenses/outputRenderer.ts[20-28]

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

## Issue description
`render_package_name` currently returns the raw package name for `BelongsTo::Optional`, but pnpm TypeScript renders an `(optional)` suffix (dimmed) for optional dependencies. This creates a user-visible output divergence.

## Issue Context
The PR aims to align pacquet’s `licenses` output with pnpm TypeScript, including dependency classification markers.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[420-425]

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


2. Optional filter needs metadata 🐞 Bug ≡ Correctness
Description
collect_dependencies only applies the new platform-compatibility filter when a matching
lockfile.packages metadata row exists; if packages is None or missing the key, unsupported
optional packages (including ones inferable from platform-specific names) will not be filtered and
will be reported.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R363-371]

+        if snapshot.is_some_and(|snapshot| snapshot.optional)
+            && package.is_some_and(|package| {
+                let declared = WantedPlatformRef {
+                    os: package.os.as_deref(),
+                    cpu: package.cpu.as_deref(),
+                    libc: package.libc.as_deref(),
+                };
+                let inferred = inferred_platform(&key.name.to_string(), declared);
+                let wanted = inferred.as_ref().map_or(declared, |platform| WantedPlatformRef {
Relevance

⭐⭐⭐ High

Likely bug: platform inference can work without packages metadata; parity-driven fixes are commonly
accepted.

PR-#13006
PR-#12789

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR’s filter is conditioned on package.is_some_and(...), but Lockfile.packages is optional,
and inferred_platform can infer platform constraints from the package name even when declared
os/cpu/libc are absent. Therefore, when metadata is missing, unsupported optional packages bypass
the filter and remain included.

pnpm/crates/cli/src/cli_args/licenses.rs[360-386]
pnpm/crates/lockfile/src/lib.rs[92-177]
pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[85-99]
pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[49-60]

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

## Issue description
`collect_dependencies` gates platform filtering behind `package.is_some_and(...)`. When `lockfile.packages` is `None` (or lacks an entry for the current key), the filter is skipped entirely, even though platform inference can be performed from the package name alone.

## Issue Context
- `Lockfile.packages` is an `Option<...>` and can legitimately be absent.
- The installability helper `inferred_platform(name, declared)` works when `declared` is all-`None` (it can infer from `name`).

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[363-384]

## Suggested change
- Remove the `package.is_some_and(...)` gating.
- Compute `declared` from `package` when present, otherwise use `WantedPlatformRef { os: None, cpu: None, libc: None }`.
- Run `inferred_platform(name, declared)` regardless, then evaluate `platform_is_supported(...)` and skip when unsupported.
- Add/adjust a regression test to cover a lockfile with `packages:` omitted (or missing the specific package entry) where an optional platform-specific name must still be filtered.

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


3. Flaky colorized test ✓ Resolved 🐞 Bug ☼ Reliability
Description
The new renders_dev_classification test asserts an exact string, but render_package_name
conditionally emits ANSI styling when color is supported; CI env vars (e.g. CLICOLOR_FORCE) can
change the output and break the test. This can cause environment-dependent failures unrelated to
functionality.
Code

pnpm/crates/cli/src/cli_args/licenses/tests.rs[R145-158]

+fn renders_dev_classification() {
+    let info = LicenseInfo {
+        name: "dev-only".to_string(),
+        versions: vec!["1.0.0".to_string()],
+        paths: Vec::new(),
+        license: "MIT".to_string(),
+        belongs_to: BelongsTo::Dev,
+        author: None,
+        homepage: None,
+        description: None,
+    };
+
+    assert_eq!(render_package_name(&info), "dev-only (dev)");
+}
Relevance

⭐⭐⭐ High

They actively harden color-related tests to avoid environment/global-color flakiness.

PR-#13227

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test compares against a plain string while the implementation uses if_supports_color(...) to
optionally apply styling, making output dependent on runtime environment/TTY detection.

pnpm/crates/cli/src/cli_args/licenses/tests.rs[145-158]
pnpm/crates/cli/src/cli_args/licenses.rs[416-422]

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

### Issue description
The test assumes `render_package_name()` returns a non-colored string, but the implementation conditionally colorizes `(dev)` depending on environment/stream detection.

### Issue Context
This creates CI fragility when color is forced or detected differently across runners.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses/tests.rs[145-158]
- pnpm/crates/cli/src/cli_args/licenses.rs[416-422]

### Suggested fix options
1) In the test, strip ANSI escape sequences from the rendered string before asserting.
2) Or, force a deterministic color mode for the duration of the test using `owo_colors::set_override(false)` with an RAII guard + a `static` mutex (to avoid leaking global state across parallel tests).
3) Or, refactor `render_package_name` to accept a "color enabled" flag and test both branches explicitly.

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


View more (3)
4. collect_dependencies uses String IDs ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
collect_dependencies takes importer_ids as IntoIterator<Item = String>, forcing owned
Strings even though the function only reads the IDs. This violates the preference for borrowed
parameter types and can introduce avoidable allocations/copies at call sites.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R314-317]

+fn collect_dependencies(
+    lockfile: &Lockfile,
+    importer_ids: impl IntoIterator<Item = String>,
+    include: Include,
Relevance

⭐⭐⭐ High

Minor signature tweak to avoid forced String allocations aligns with past allocation-avoidance
feedback.

PR-#13300

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2254729 requires preferring borrowed/general parameter types when ownership is not
needed. The function signature currently requires String items for importer_ids, even though the
IDs are only read for map lookups.

Rule 2254729: Prefer general borrowed parameter types (&str, &Path) over owned or specific types when no extra copies are required
pnpm/crates/cli/src/cli_args/licenses.rs[314-317]

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

## Issue description
`collect_dependencies` unnecessarily requires owned `String` importer IDs.

## Issue Context
The function only uses importer IDs for lookups (`lockfile.importers.get(...)`) and does not store them, so it can accept a borrowed/general type (e.g., `AsRef<str>` / `Borrow<str>`) to avoid forcing allocations.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[314-329]

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


5. Terminal escape injection ✓ Resolved 🐞 Bug ⛨ Security
Description
pnpm licenses list --long prints manifest-derived strings
(author/description/homepage/license/name) into a table without stripping control/format characters,
enabling terminal escape/control-sequence injection from attacker-controlled package manifests. This
PR increases exposure by scanning every workspace importer by default, so any workspace project’s
dependencies can reach this output surface.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R288-292]

        for info in all_packages {
-            let mut row = vec![info.name.clone(), info.license.clone()];
+            let mut row = vec![render_package_name(info), info.license.clone()];
            if self.long {
                let mut details = Vec::new();
                if let Some(author) = &info.author {
Relevance

⭐⭐⭐ High

Repo has accepted sanitizing untrusted CLI output to prevent escape/control-sequence injection.

PR-#13287

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
licenses builds table rows from package.json fields and prints them directly, but unlike other
CLI outputs it does not call the repo’s sanitize/sanitize_inline helpers before sending
attacker-controlled text to the terminal.

pnpm/crates/cli/src/cli_args/licenses.rs[288-304]
pnpm/crates/cli/src/cli_args/sanitize.rs[7-34]
pnpm/crates/cli/src/cli_args/outdated.rs[1016-1023]

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

### Issue description
`licenses list` renders attacker-controlled manifest fields directly into terminal output. Control/format characters (including ANSI escape sequences) can spoof or conceal output when users run `pnpm licenses list --long`.

### Issue Context
The repo already has sanitizers (`sanitize_inline` for single-line fields and `sanitize` for multi-line) used in other CLI outputs; `licenses` should use the same output-boundary hardening.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[288-304]
- pnpm/crates/cli/src/cli_args/sanitize.rs[7-34]

### Suggested fix
- Apply `sanitize_inline(...)` to single-line cells like package name and license.
- Apply `sanitize(...)` (allows `\n`/`\t`) to multi-line `Details` content before `details.join("\n")` is pushed into the table.
- Keep JSON output unchanged (or, if desired, add a separate sanitization option only for terminal output).

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


6. collect_dependencies mismatches pnpm filtering 📘 Rule violation ⌂ Architecture
Description
collect_dependencies only skips unsupported subtrees when snapshot.optional is true, so
non-optional packages with incompatible os/cpu/libc are still included. pnpm TypeScript’s license
scanner drops any dependency that is not installable on the evaluated platform, which can lead to
user-visible output divergence between pnpm and pacquet.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R363-384]

+        if snapshot.is_some_and(|snapshot| snapshot.optional)
+            && package.is_some_and(|package| {
+                let declared = WantedPlatformRef {
+                    os: package.os.as_deref(),
+                    cpu: package.cpu.as_deref(),
+                    libc: package.libc.as_deref(),
+                };
+                let inferred = inferred_platform(&key.name.to_string(), declared);
+                let wanted = inferred.as_ref().map_or(declared, |platform| WantedPlatformRef {
+                    os: platform.os.as_deref(),
+                    cpu: platform.cpu.as_deref(),
+                    libc: platform.libc.as_deref(),
+                });
+                !platform_is_supported(
+                    wanted,
+                    supported_architectures,
+                    current_os,
+                    current_cpu,
+                    current_libc,
+                )
+            })
+        {
Relevance

⭐⭐ Medium

Parity issues usually accepted, but PR intent mentions only optional filtering; non-optional
behavior change uncertain.

PR-#13006
PR-#12789

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Rust filter is guarded by snapshot.optional, so incompatible non-optional packages are not
filtered. The TypeScript license scanner excludes any dependency when packageIsInstallable is not
truthy; for non-optional incompatible packages packageIsInstallable returns null, so they are
excluded, creating a behavior mismatch unless Rust does the same.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm/crates/cli/src/cli_args/licenses.rs[360-386]
pnpm11/deps/compliance/license-scanner/src/lockfileToLicenseNodeTree.ts[57-72]
pnpm11/config/package-is-installable/src/index.ts[51-90]

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

## Issue description
`collect_dependencies` currently filters out unsupported packages only when the snapshot is marked `optional`. In pnpm TypeScript, the licenses scanner excludes any dependency that is not installable on the evaluated platform (including non-optional ones), so pacquet can report extra packages.

## Issue Context
In TypeScript license scanning, `packageIsInstallable(...)` returns `false` for unsupported optional deps and `null` for unsupported non-optional deps; the scanner drops the dependency for any falsy result. The Rust logic should match that observable behavior to avoid cross-stack divergence.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[360-386]
- pnpm/crates/cli/src/cli_args/licenses/tests.rs[73-156]

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



Informational

7. Wasted name allocation ✓ Resolved 🐞 Bug ➹ Performance
Description
collect_dependencies allocates key.name.to_string() when calling inferred_platform(...), even
though inference immediately returns None when all declared os/cpu/libc fields are present. This
adds avoidable allocations in the new dependency walk, especially for optional packages with
fully-declared platform constraints.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R364-373]

+        if package.is_some_and(|package| {
+            let declared = WantedPlatformRef {
+                os: package.os.as_deref(),
+                cpu: package.cpu.as_deref(),
+                libc: package.libc.as_deref(),
+            };
+            let inferred: Option<WantedPlatform>;
+            let wanted = if snapshot.is_some_and(|snapshot| snapshot.optional) {
+                inferred = inferred_platform(&key.name.to_string(), declared);
+                inferred.as_ref().map_or(declared, |platform| WantedPlatformRef {
Relevance

⭐⭐ Medium

Perf nit is plausible but requires refactor/signature changes; acceptance uncertain without close
precedent.

PR-#13300

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The call site unconditionally allocates a name String before calling inferred_platform, but
inferred_platform explicitly short-circuits when all three declared axes are present.

pnpm/crates/cli/src/cli_args/licenses.rs[364-373]
pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[85-88]

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

### Issue description
`collect_dependencies()` calls `inferred_platform(&key.name.to_string(), declared)` inside the optional-snapshot branch. `inferred_platform()` returns `None` when `os/cpu/libc` are all present, so the package-name `String` allocation is wasted in that case.

### Issue Context
This is a minor but easy optimization in a path that now scans all importers by default.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[364-381]
- pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[85-88]

### Suggested fix
- Before calling `inferred_platform`, check whether any of `declared.os/cpu/libc` is `None`; only allocate the name string and call inference when at least one is missing.
- Keep behavior identical when inference is needed (still infer from name for optional snapshots with incomplete declarations).

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


8. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset front-matter only bumps pacquet and does not declare a pnpm bump. This
violates the changeset policy requiring an explicit pnpm package entry with a valid bump type.
Code

.changeset/fuzzy-dodos-report.md[R1-3]

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

⭐ Low

Team has rejected adding a pnpm bump for pacquet-only changesets in similar cases.

PR-#13347

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each changeset to include an explicit pnpm entry with a valid
bump type. The added changeset front-matter lists only pacquet and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/fuzzy-dodos-report.md[1-3]

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

## Issue description
The changeset front-matter is missing an entry for the `pnpm` package.

## Issue Context
Compliance requires changesets to explicitly declare the `pnpm` package and a valid bump type (`patch`/`minor`/`major`). The current changeset only includes `pacquet`.

## Fix Focus Areas
- .changeset/fuzzy-dodos-report.md[1-3]

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

Results up to commit 9e4dffb ⚖️ Balanced


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


Remediation recommended
1. Terminal escape injection ✓ Resolved 🐞 Bug ⛨ Security
Description
pnpm licenses list --long prints manifest-derived strings
(author/description/homepage/license/name) into a table without stripping control/format characters,
enabling terminal escape/control-sequence injection from attacker-controlled package manifests. This
PR increases exposure by scanning every workspace importer by default, so any workspace project’s
dependencies can reach this output surface.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R288-292]

        for info in all_packages {
-            let mut row = vec![info.name.clone(), info.license.clone()];
+            let mut row = vec![render_package_name(info), info.license.clone()];
            if self.long {
                let mut details = Vec::new();
                if let Some(author) = &info.author {
Relevance

⭐⭐⭐ High

Repo has accepted sanitizing untrusted CLI output to prevent escape/control-sequence injection.

PR-#13287

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
licenses builds table rows from package.json fields and prints them directly, but unlike other
CLI outputs it does not call the repo’s sanitize/sanitize_inline helpers before sending
attacker-controlled text to the terminal.

pnpm/crates/cli/src/cli_args/licenses.rs[288-304]
pnpm/crates/cli/src/cli_args/sanitize.rs[7-34]
pnpm/crates/cli/src/cli_args/outdated.rs[1016-1023]

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

### Issue description
`licenses list` renders attacker-controlled manifest fields directly into terminal output. Control/format characters (including ANSI escape sequences) can spoof or conceal output when users run `pnpm licenses list --long`.

### Issue Context
The repo already has sanitizers (`sanitize_inline` for single-line fields and `sanitize` for multi-line) used in other CLI outputs; `licenses` should use the same output-boundary hardening.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[288-304]
- pnpm/crates/cli/src/cli_args/sanitize.rs[7-34]

### Suggested fix
- Apply `sanitize_inline(...)` to single-line cells like package name and license.
- Apply `sanitize(...)` (allows `\n`/`\t`) to multi-line `Details` content before `details.join("\n")` is pushed into the table.
- Keep JSON output unchanged (or, if desired, add a separate sanitization option only for terminal output).

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


2. collect_dependencies uses String IDs ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
collect_dependencies takes importer_ids as IntoIterator<Item = String>, forcing owned
Strings even though the function only reads the IDs. This violates the preference for borrowed
parameter types and can introduce avoidable allocations/copies at call sites.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R314-317]

+fn collect_dependencies(
+    lockfile: &Lockfile,
+    importer_ids: impl IntoIterator<Item = String>,
+    include: Include,
Relevance

⭐⭐⭐ High

Minor signature tweak to avoid forced String allocations aligns with past allocation-avoidance
feedback.

PR-#13300

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2254729 requires preferring borrowed/general parameter types when ownership is not
needed. The function signature currently requires String items for importer_ids, even though the
IDs are only read for map lookups.

Rule 2254729: Prefer general borrowed parameter types (&str, &Path) over owned or specific types when no extra copies are required
pnpm/crates/cli/src/cli_args/licenses.rs[314-317]

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

## Issue description
`collect_dependencies` unnecessarily requires owned `String` importer IDs.

## Issue Context
The function only uses importer IDs for lookups (`lockfile.importers.get(...)`) and does not store them, so it can accept a borrowed/general type (e.g., `AsRef<str>` / `Borrow<str>`) to avoid forcing allocations.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[314-329]

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


3. Flaky colorized test ✓ Resolved 🐞 Bug ☼ Reliability
Description
The new renders_dev_classification test asserts an exact string, but render_package_name
conditionally emits ANSI styling when color is supported; CI env vars (e.g. CLICOLOR_FORCE) can
change the output and break the test. This can cause environment-dependent failures unrelated to
functionality.
Code

pnpm/crates/cli/src/cli_args/licenses/tests.rs[R145-158]

+fn renders_dev_classification() {
+    let info = LicenseInfo {
+        name: "dev-only".to_string(),
+        versions: vec!["1.0.0".to_string()],
+        paths: Vec::new(),
+        license: "MIT".to_string(),
+        belongs_to: BelongsTo::Dev,
+        author: None,
+        homepage: None,
+        description: None,
+    };
+
+    assert_eq!(render_package_name(&info), "dev-only (dev)");
+}
Relevance

⭐⭐⭐ High

They actively harden color-related tests to avoid environment/global-color flakiness.

PR-#13227

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test compares against a plain string while the implementation uses if_supports_color(...) to
optionally apply styling, making output dependent on runtime environment/TTY detection.

pnpm/crates/cli/src/cli_args/licenses/tests.rs[145-158]
pnpm/crates/cli/src/cli_args/licenses.rs[416-422]

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

### Issue description
The test assumes `render_package_name()` returns a non-colored string, but the implementation conditionally colorizes `(dev)` depending on environment/stream detection.

### Issue Context
This creates CI fragility when color is forced or detected differently across runners.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses/tests.rs[145-158]
- pnpm/crates/cli/src/cli_args/licenses.rs[416-422]

### Suggested fix options
1) In the test, strip ANSI escape sequences from the rendered string before asserting.
2) Or, force a deterministic color mode for the duration of the test using `owo_colors::set_override(false)` with an RAII guard + a `static` mutex (to avoid leaking global state across parallel tests).
3) Or, refactor `render_package_name` to accept a "color enabled" flag and test both branches explicitly.

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



Informational
4. Wasted name allocation ✓ Resolved 🐞 Bug ➹ Performance
Description
collect_dependencies allocates key.name.to_string() when calling inferred_platform(...), even
though inference immediately returns None when all declared os/cpu/libc fields are present. This
adds avoidable allocations in the new dependency walk, especially for optional packages with
fully-declared platform constraints.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R364-373]

+        if package.is_some_and(|package| {
+            let declared = WantedPlatformRef {
+                os: package.os.as_deref(),
+                cpu: package.cpu.as_deref(),
+                libc: package.libc.as_deref(),
+            };
+            let inferred: Option<WantedPlatform>;
+            let wanted = if snapshot.is_some_and(|snapshot| snapshot.optional) {
+                inferred = inferred_platform(&key.name.to_string(), declared);
+                inferred.as_ref().map_or(declared, |platform| WantedPlatformRef {
Relevance

⭐⭐ Medium

Perf nit is plausible but requires refactor/signature changes; acceptance uncertain without close
precedent.

PR-#13300

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The call site unconditionally allocates a name String before calling inferred_platform, but
inferred_platform explicitly short-circuits when all three declared axes are present.

pnpm/crates/cli/src/cli_args/licenses.rs[364-373]
pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[85-88]

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

### Issue description
`collect_dependencies()` calls `inferred_platform(&key.name.to_string(), declared)` inside the optional-snapshot branch. `inferred_platform()` returns `None` when `os/cpu/libc` are all present, so the package-name `String` allocation is wasted in that case.

### Issue Context
This is a minor but easy optimization in a path that now scans all importers by default.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[364-381]
- pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[85-88]

### Suggested fix
- Before calling `inferred_platform`, check whether any of `declared.os/cpu/libc` is `None`; only allocate the name string and call inference when at least one is missing.
- Keep behavior identical when inference is needed (still infer from name for optional snapshots with incomplete declarations).

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


5. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset front-matter only bumps pacquet and does not declare a pnpm bump. This
violates the changeset policy requiring an explicit pnpm package entry with a valid bump type.
Code

.changeset/fuzzy-dodos-report.md[R1-3]

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

⭐ Low

Team has rejected adding a pnpm bump for pacquet-only changesets in similar cases.

PR-#13347

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each changeset to include an explicit pnpm entry with a valid
bump type. The added changeset front-matter lists only pacquet and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/fuzzy-dodos-report.md[1-3]

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

## Issue description
The changeset front-matter is missing an entry for the `pnpm` package.

## Issue Context
Compliance requires changesets to explicitly declare the `pnpm` package and a valid bump type (`patch`/`minor`/`major`). The current changeset only includes `pacquet`.

## Fix Focus Areas
- .changeset/fuzzy-dodos-report.md[1-3]

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


Results up to commit 427ce72 ⚖️ Balanced


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


Remediation recommended
1. Optional filter needs metadata 🐞 Bug ≡ Correctness
Description
collect_dependencies only applies the new platform-compatibility filter when a matching
lockfile.packages metadata row exists; if packages is None or missing the key, unsupported
optional packages (including ones inferable from platform-specific names) will not be filtered and
will be reported.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R363-371]

+        if snapshot.is_some_and(|snapshot| snapshot.optional)
+            && package.is_some_and(|package| {
+                let declared = WantedPlatformRef {
+                    os: package.os.as_deref(),
+                    cpu: package.cpu.as_deref(),
+                    libc: package.libc.as_deref(),
+                };
+                let inferred = inferred_platform(&key.name.to_string(), declared);
+                let wanted = inferred.as_ref().map_or(declared, |platform| WantedPlatformRef {
Relevance

⭐⭐⭐ High

Likely bug: platform inference can work without packages metadata; parity-driven fixes are commonly
accepted.

PR-#13006
PR-#12789

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR’s filter is conditioned on package.is_some_and(...), but Lockfile.packages is optional,
and inferred_platform can infer platform constraints from the package name even when declared
os/cpu/libc are absent. Therefore, when metadata is missing, unsupported optional packages bypass
the filter and remain included.

pnpm/crates/cli/src/cli_args/licenses.rs[360-386]
pnpm/crates/lockfile/src/lib.rs[92-177]
pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[85-99]
pnpm/crates/package-is-installable/src/infer_platform_from_package_name.rs[49-60]

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

## Issue description
`collect_dependencies` gates platform filtering behind `package.is_some_and(...)`. When `lockfile.packages` is `None` (or lacks an entry for the current key), the filter is skipped entirely, even though platform inference can be performed from the package name alone.

## Issue Context
- `Lockfile.packages` is an `Option<...>` and can legitimately be absent.
- The installability helper `inferred_platform(name, declared)` works when `declared` is all-`None` (it can infer from `name`).

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[363-384]

## Suggested change
- Remove the `package.is_some_and(...)` gating.
- Compute `declared` from `package` when present, otherwise use `WantedPlatformRef { os: None, cpu: None, libc: None }`.
- Run `inferred_platform(name, declared)` regardless, then evaluate `platform_is_supported(...)` and skip when unsupported.
- Add/adjust a regression test to cover a lockfile with `packages:` omitted (or missing the specific package entry) where an optional platform-specific name must still be filtered.

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


2. collect_dependencies mismatches pnpm filtering 📘 Rule violation ⌂ Architecture
Description
collect_dependencies only skips unsupported subtrees when snapshot.optional is true, so
non-optional packages with incompatible os/cpu/libc are still included. pnpm TypeScript’s license
scanner drops any dependency that is not installable on the evaluated platform, which can lead to
user-visible output divergence between pnpm and pacquet.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R363-384]

+        if snapshot.is_some_and(|snapshot| snapshot.optional)
+            && package.is_some_and(|package| {
+                let declared = WantedPlatformRef {
+                    os: package.os.as_deref(),
+                    cpu: package.cpu.as_deref(),
+                    libc: package.libc.as_deref(),
+                };
+                let inferred = inferred_platform(&key.name.to_string(), declared);
+                let wanted = inferred.as_ref().map_or(declared, |platform| WantedPlatformRef {
+                    os: platform.os.as_deref(),
+                    cpu: platform.cpu.as_deref(),
+                    libc: platform.libc.as_deref(),
+                });
+                !platform_is_supported(
+                    wanted,
+                    supported_architectures,
+                    current_os,
+                    current_cpu,
+                    current_libc,
+                )
+            })
+        {
Relevance

⭐⭐ Medium

Parity issues usually accepted, but PR intent mentions only optional filtering; non-optional
behavior change uncertain.

PR-#13006
PR-#12789

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Rust filter is guarded by snapshot.optional, so incompatible non-optional packages are not
filtered. The TypeScript license scanner excludes any dependency when packageIsInstallable is not
truthy; for non-optional incompatible packages packageIsInstallable returns null, so they are
excluded, creating a behavior mismatch unless Rust does the same.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
Rule 713429: Pacquet must not introduce new user-visible behavior beyond pnpm
pnpm/crates/cli/src/cli_args/licenses.rs[360-386]
pnpm11/deps/compliance/license-scanner/src/lockfileToLicenseNodeTree.ts[57-72]
pnpm11/config/package-is-installable/src/index.ts[51-90]

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

## Issue description
`collect_dependencies` currently filters out unsupported packages only when the snapshot is marked `optional`. In pnpm TypeScript, the licenses scanner excludes any dependency that is not installable on the evaluated platform (including non-optional ones), so pacquet can report extra packages.

## Issue Context
In TypeScript license scanning, `packageIsInstallable(...)` returns `false` for unsupported optional deps and `null` for unsupported non-optional deps; the scanner drops the dependency for any falsy result. The Rust logic should match that observable behavior to avoid cross-stack divergence.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[360-386]
- pnpm/crates/cli/src/cli_args/licenses/tests.rs[73-156]

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


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings July 27, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 427ce72

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Copilot AI review requested due to automatic review settings July 27, 2026 20:26
@zkochan

zkochan commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

Addressed Qodo’s applicable follow-ups in 7e586f5593:

  • made the colorized (dev) assertion environment-independent;
  • accepted borrowed importer IDs and avoided unnecessary package-name allocation;
  • sanitized manifest-derived fields at the terminal-output boundary while leaving JSON unchanged.

The suggested pnpm changeset entry was intentionally not added: this is a Rust-only pacquet change, and the repository instructions require such changesets to target pacquet without the TypeScript pnpm package.


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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7e586f5

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit 81411d3 into main Jul 27, 2026
32 checks passed
@zkochan
zkochan deleted the fix-13438 branch July 27, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust pnpm licenses list reports a different dependency set

3 participants