Skip to content
Source
Sign inSign up
TanStack/intent

fix: discover pnpm 11 isolated global package roots #207

OpenMohith26(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/207/headopened

🎯 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.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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
      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Out of Scope Changes check⚠️ WarningThe 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 nameStatusExplanation
      Linked Issues check✅ PassedThe changes address #206 by supporting multiple global roots, pnpm's isolated layout, and delimiter-separated INTENT_GLOBAL_NODE_MODULES.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      Title check✅ PassedThe title clearly summarizes the main change: discovering pnpm 11 isolated global package roots.
      Description check✅ PassedThe 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.
    2. 🧹 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 3e8f4af35cb2ee6ceec46017fae1a6a8f6cf05d9 and 5fd0ce33d3a8487bc5057521768c1c22e17f00c1.

      📒 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
    3. Please refrain from removing the PR template when submitting a PR. It is there for a reason.

    4. 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 in to join this conversation.