fix: discover pnpm 11 isolated global package roots #207
main fromrefs/pull/207/head·opened 🎯 Changes#
Fixes #206, reported by @KATT.
list --global / --global-only found nothing for packages installed globally with pnpm 11, while local scanning worked (packageJsonReadCount: 0 in debug). pnpm 11's global layout is isolated: pnpm root -g entries are symlinks into a .pnpm virtual store, and each package's dependencies live in additional roots inside that store rather than one flat node_modules, so single-root scanning read nothing.
This teaches global discovery to resolve pnpm's isolated layout: symlinked roots are followed and the store's package roots are included as additional scan roots, while npm/yarn flat layouts keep working unchanged. Nine new tests cover multi-root global discovery with temp-dir fixtures mimicking pnpm 11's layout plus the npm flat layout (no dependency on a real global install); 12 tests fail without the fix, and the full suite has zero new failures vs main.
(Apologies for initially dropping the template.)
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
- New Features
- Improved discovery of globally installed intent packages across multiple
node_modulesroots. - Added support for delimiter-separated global module paths via configuration.
- Enhanced compatibility with pnpm isolated global installation layouts (pnpm 10/11).
- Improved discovery of globally installed intent packages across multiple
- Bug Fixes
- Global module path detection now correctly derives and represents multiple candidate roots, avoiding missed/incorrect scanning.
- Added safer handling when configured roots are empty.
- Tests
- Expanded coverage for multi-root detection, delimiter parsing, pnpm layout parsing, malformed inputs, and deduplication.
- 1
🧹 Nitpick comments (1)
packages/intent/tests/global-node-modules.test.ts (1)
138-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover automatic pnpm discovery.
This test sets the override, so it never exercises
pnpm ls -g --json --depth 0. Add a mocked command/shim test for parsed roots and fallback behavior.🤖 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 `@packages/intent/tests/global-node-modules.test.ts` around lines 138 - 148, Add coverage for the automatic pnpm discovery path in detectGlobalNodeModules by removing the INTENT_GLOBAL_NODE_MODULES override for that test and mocking the pnpm ls -g --json --depth 0 command or shim. Assert parsed global module roots and add a case verifying the existing fallback behavior when the command fails or returns unusable output.🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@packages/intent/tests/global-node-modules.test.ts`: - Around line 138-148: Add coverage for the automatic pnpm discovery path in detectGlobalNodeModules by removing the INTENT_GLOBAL_NODE_MODULES override for that test and mocking the pnpm ls -g --json --depth 0 command or shim. Assert parsed global module roots and add a case verifying the existing fallback behavior when the command fails or returns unusable output.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
16610cb9-e320-4162-a4c5-4bb96c6dd2c6📥 Commits
Reviewing files that changed from the base of the PR and between 3e8f4af35cb2ee6ceec46017fae1a6a8f6cf05d9 and 5fd0ce33d3a8487bc5057521768c1c22e17f00c1.
📒 Files selected for processing (6)
packages/intent/src/discovery/register.tspackages/intent/src/discovery/scanner.tspackages/intent/src/shared/types.tspackages/intent/src/shared/utils.tspackages/intent/tests/global-node-modules.test.tspackages/intent/tests/scanner.test.ts
Please refrain from removing the PR template when submitting a PR. It is there for a reason.
Sorry about that, template restored. Also added the changeset the template asks for and ran pnpm run test:pr (all targets green, including the eslint findings the type changes surfaced in staleness.test.ts, fixed in 238fcf7).
Mohith26(GitHub profile, opens in a new tab) linked this to fix #206
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Global
node_modulesdetection now supports multiple roots, parses pnpm global package paths, accepts delimiter-separated environment overrides, and scans every configured root with coverage for pnpm, npm-style, and aliased layouts.Changes#
Global node_modules discovery
packages/intent/src/shared/types.ts,packages/intent/src/shared/utils.ts,packages/intent/tests/global-node-modules.test.ts,.changeset/global-pnpm-skill-discovery.md,packages/intent/tests/staleness.test.tspackages/intent/src/discovery/scanner.tspackages/intent/src/discovery/register.ts,packages/intent/tests/scanner.test.tsEstimated code review effort: 3 (Moderate) | ~25 minutes
Sequence Diagram(s)#
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#206by supporting multiple global roots, pnpm's isolated layout, and delimiter-separated INTENT_GLOBAL_NODE_MODULES.✨ 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.
❤️ Share