Skip to content

fix: discover pnpm 11 isolated global package roots - #207

Open
Mohith26 wants to merge 4 commits into
TanStack:mainfrom
Mohith26:fix/global-pnpm-skill-discovery
Open

fix: discover pnpm 11 isolated global package roots#207
Mohith26 wants to merge 4 commits into
TanStack:mainfrom
Mohith26:fix/global-pnpm-skill-discovery

Conversation

@Mohith26

@Mohith26 Mohith26 commented Jul 29, 2026

Copy link
Copy Markdown

🎯 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_modules roots.
    • Added support for delimiter-separated global module paths via configuration.
    • Enhanced compatibility with pnpm isolated global installation layouts (pnpm 10/11).
  • 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.

Mohith26 added 2 commits July 28, 2026 21:34
pnpm 11 installs each global package into its own isolated directory
(<global>/<dir>/node_modules/<pkg>), so `pnpm root -g` no longer points
at a scannable node_modules dir and `list --global` came back empty.

Global detection now asks pnpm for resolved package paths via
`pnpm ls -g --json --depth 0` and derives the set of node_modules roots
(deduped; collapses to the single root on pnpm <= 10), keeping
`pnpm root -g` plus the npm/yarn commands as fallbacks. The scanner
scans every detected root, and INTENT_GLOBAL_NODE_MODULES accepts a
path.delimiter-separated list of roots.

Fixes TanStack#206
Scanner tests exercise temp-dir fixtures for the pnpm 11 isolated
global layout (several roots via a path-list override, deduped when
two roots alias the same directory) and the npm-style single global
root. Unit tests cover parsePnpmGlobalLsRoots fixture output for the
pnpm 11 and pnpm 10 layouts plus the INTENT_GLOBAL_NODE_MODULES
path-list parsing.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Global node_modules detection 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

Layer / File(s) Summary
Global path detection and contracts
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.ts
Global scan targets support path arrays; utilities split environment overrides, parse pnpm global metadata, return multiple roots, and test malformed, empty, and multi-root inputs.
Global scanner path wiring
packages/intent/src/discovery/scanner.ts
Scanner initialization and fallback detection populate global path arrays and associated detection, existence, and source fields.
Multi-root scanning and integration validation
packages/intent/src/discovery/register.ts, packages/intent/tests/scanner.test.ts
Global scanning iterates configured roots, with tests covering isolated pnpm roots, a single global root, and aliased roots that deduplicate discovered packages.

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

Sequence Diagram(s)

sequenceDiagram
  participant scanForIntents
  participant detectGlobalNodeModules
  participant nodeModules.global
  participant scanTarget
  participant scanNodeModulesDir
  scanForIntents->>detectGlobalNodeModules: resolve global node_modules roots
  detectGlobalNodeModules-->>nodeModules.global: return paths and source
  nodeModules.global->>scanTarget: provide configured roots
  scanTarget->>scanNodeModulesDir: scan each root
  scanNodeModulesDir-->>scanForIntents: return discovered global packages
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The staleness.test.ts fetch mock tweak is unrelated to pnpm global discovery and looks out of scope for this fix. Move the staleness test mock adjustment to a separate PR unless it is required for this pnpm global discovery change.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #206 by supporting multiple global roots, pnpm's isolated layout, and delimiter-separated INTENT_GLOBAL_NODE_MODULES.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main change: discovering pnpm 11 isolated global package roots.
Description check ✅ Passed The description follows the template and includes the required changes, checklist, and release impact sections.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/intent/tests/global-node-modules.test.ts (1)

138-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover 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 3e8f4af and 5fd0ce3.

📒 Files selected for processing (6)
  • packages/intent/src/discovery/register.ts
  • packages/intent/src/discovery/scanner.ts
  • packages/intent/src/shared/types.ts
  • packages/intent/src/shared/utils.ts
  • packages/intent/tests/global-node-modules.test.ts
  • packages/intent/tests/scanner.test.ts

@LadyBluenotes

Copy link
Copy Markdown
Member

Please refrain from removing the PR template when submitting a PR. It is there for a reason.

@Mohith26

Copy link
Copy Markdown
Author

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

list --global finds nothing when packages are installed globally with pnpm 11

2 participants