Skip to content

fix(skill): make /understand work on Windows + pnpm 10#124

Merged
Lum1104 merged 1 commit into
Lum1104:mainfrom
tipich:fix/windows-pnpm10-compat
May 10, 2026
Merged

fix(skill): make /understand work on Windows + pnpm 10#124
Lum1104 merged 1 commit into
Lum1104:mainfrom
tipich:fix/windows-pnpm10-compat

Conversation

@tipich
Copy link
Copy Markdown
Contributor

@tipich tipich commented May 6, 2026

Summary

Fixes two bugs that block /understand from running properly on common modern dev setups (Windows + pnpm 10):

  1. extract-structure.mjs:34,37 — Windows ESM URL bug. await import() was called with raw absolute paths returned by require.resolve() and path.resolve(). On Windows those start with C:\..., which Node 24's ESM loader parses as URL scheme C: and rejects with ERR_UNSUPPORTED_ESM_URL_SCHEME. Wrap both with pathToFileURL().href so the loader receives a proper file:// URL. POSIX systems are unaffected (their absolute paths start with /, which Node ESM accepts).

  2. pnpm.onlyBuiltDependencies missing from package.json. pnpm 10 (released ~2024-09) changed the default to block all postinstall scripts unless explicitly approved. Without this allowlist, pnpm install skips the native build for tree-sitter parsers, esbuild, and sharp — which means registry.analyzeFile() returns undefined and any code path that calls it (including buildFingerprintStore) crashes. Cross-platform issue, not Windows-specific.

Why both matter

Without these, on a clean Windows + pnpm 10 install:

  • file-analyzer subagents can't run extract-structure.mjs → fall back to manual file reads → importMap stays empty across all batches → assemble-reviewer has to grep-recover hundreds of cross-batch edges by hand
  • buildFingerprintStore crashes → no fingerprints.json baseline gets generated → the incremental update path described in SKILL.md Phase 0 step 7 doesn't work at all, every /understand is a full rebuild

Verification

End-to-end on a 1190-file Laravel codebase:

  • After fix feat(agents): script-augmented two-phase architecture #1: extract-structure.mjs resolves @understand-anything/core cleanly via pathToFileURL
  • After fix Diff Mode #2: tree-sitter PHP parser ships during pnpm install (visible node-gyp-build Done lines)
  • buildFingerprintStore(ROOT, 1190 files, registry, hash) builds the baseline in 1.56s
  • extractFileFingerprint correctly extracts 18 typed functions from Booking.php
  • Synthetic change detection correctly classifies whitespace-only diff as COSMETIC and added-method diff as STRUCTURAL

Test plan

  • Smoke /understand on a small Windows project to confirm extract-structure no longer falls back
  • Confirm pnpm install on a fresh Windows + pnpm 10 clone produces compiled tree-sitter parsers without manual pnpm approve-builds
  • Confirm buildFingerprintStore no longer crashes when called per the pattern in SKILL.md Phase 7 step 2.5

🤖 Generated with Claude Code

Two bugs blocked /understand from running properly:

1. extract-structure.mjs:34,37 — `await import()` was called with raw
   absolute paths returned by `require.resolve()` and `path.resolve()`.
   On Windows those start with "C:\..." which Node 24's ESM loader
   parses as URL scheme "C:" and rejects with
   ERR_UNSUPPORTED_ESM_URL_SCHEME. Wrap both with `pathToFileURL().href`
   so the loader receives a proper file:// URL.

2. tree-sitter native build scripts were skipped at install time
   because pnpm 10 blocks postinstall scripts by default. Added the
   parser packages plus esbuild and sharp to `pnpm.onlyBuiltDependencies`
   so they compile during `pnpm install` and `analyzeFile` / fingerprint
   generation actually work.

Without these, file-analyzer subagents fall back to direct file reads
and the importMap stays empty across all batches, which forces
assemble-reviewer to grep-recover hundreds of cross-batch edges by
hand. They also block the incremental update path entirely because
fingerprint generation crashes inside `buildFingerprintStore`.

Verified end-to-end on a 1190-file Laravel codebase: tree-sitter PHP
parses Booking.php into 18 typed functions, fingerprint baseline
builds in 1.56s, change detection correctly classifies cosmetic
vs structural diffs.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@tipich tipich force-pushed the fix/windows-pnpm10-compat branch from c2e4c75 to 366368f Compare May 8, 2026 10:49
@Lum1104
Copy link
Copy Markdown
Owner

Lum1104 commented May 10, 2026

@codex review this

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

2 participants