fix: discover transitive deps with skills and handle shim import errors#46
Merged
KyleAMathews merged 3 commits intomainfrom Mar 7, 2026
Merged
Conversation
The scanner only checked top-level node_modules, missing transitive dependencies with skills in non-hoisted layouts (pnpm). Add Phase 2 dependency walking that resolves packages through the pnpm virtual store using realpathSync. Also fix the library shim to catch ERR_MODULE_NOT_FOUND gracefully when @tanstack/intent isn't installed, and update all docs to use @latest to avoid the local binary conflict. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merged
commit: |
LadyBluenotes
approved these changes
Mar 7, 2026
This was referenced Mar 7, 2026
Merged
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix two bugs: the scanner misses transitive dependencies with skills in non-hoisted layouts (pnpm), and
bunx @tanstack/intent installfails when a library'sintentshim shadows the real package binary.Root Cause
Transitive deps not found:
scanForIntentsonly reads top-levelnode_modules/entries. In pnpm, only direct dependencies are symlinked there — transitive deps like@tanstack/db(a dependency of@tanstack/react-db) live in.pnpm/and are invisible to the flat scan.Shim import failure: Libraries ship a
bin/intent.mjsshim that doesawait import('@tanstack/intent/intent-library'). When a user runsbunx @tanstack/intent(without@latest), bun finds the localintentbinary from the shim and runs it instead of downloading@tanstack/intent. The import then fails because@tanstack/intentisn't a project dependency.Approach
Transitive dependency walking
Added a Phase 2 to
scanForIntentsthat walks the dependency tree after the initial flat scan. A newresolveDepDirutility resolves packages by:node_modules/(handles hoisted layouts — npm, yarn, bun)realpathSyncto navigate the pnpm virtual store: from a package's real path, walk up by the number of segments in its name to reach the enclosingnode_modules/, then find the dep as a siblingThe same
resolveDepDirwas also applied tolibrary-scanner.tsso the library shim'sintent listalso finds non-hoisted deps.A
tryRegisterhelper was extracted to share the package registration logic (read package.json → validate intent → discover skills → push) between Phase 1 and Phase 2, eliminating ~40 lines of duplication.Shim error handling
Updated the shim template to wrap the import in a try/catch. On
ERR_MODULE_NOT_FOUND, it prints a clear message suggestingnpm add -D @tanstack/intentornpx @tanstack/intent@latest list.Documentation
All
npx @tanstack/intentcommands in README and docs now use@latestto avoid the local binary conflict.Key Invariants
walkVisitedset prevents infinite recursion on circular depsfoundNamesset (shared viatryRegister) prevents duplicate package entriesresolveDepDirreturnsnull(not found) only for ENOENT/ENOTDIR; other errors are loggedNon-goals
Verification
Files changed
src/utils.tsgetDepsandresolveDepDirshared utilitiessrc/scanner.tstryRegisterextraction, proper error handlingsrc/library-scanner.tsgetDepsandresolveDepDir(removed local duplicate)src/setup.tssrc/index.tssrc/cli.ts@latestin scaffold README suggestionREADME.md@latestdocs/overview.md@latestscripts/validate-skills.ts🤖 Generated with Claude Code