Skip to content
Source
Sign inSign up
TanStack/intent

fix: point nested dependency variant skills at their own copy #346

Openitsfaqih(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/346/headopened

Showing 4 changed files with 52 additions and 5 deletions (loading 1).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/nested-variant-skill-path.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/intent': patch
+---
+​
+Fix `intent load` for a skill that ships in a nested copy of a dependency. When a workspace package such as `packages/bar` installed its own version of `@tanstack/query`, and the root `node_modules/@tanstack/query` was a different copy, `list` showed the nested skill but `load` looked for it under `node_modules/@tanstack/query/...` and failed. Intent now uses the `node_modules/<name>/...` path only when that entry is the same copy. Otherwise it reports the project-relative path, such as `packages/bar/node_modules/@tanstack/query/skills/fetching/SKILL.md`. Hoisted installs and pnpm or bun symlinks to the same copy keep their `node_modules/<name>/...` paths.
12 additions and 5 deletionspackages/intent/src/skills/paths.tsModified
View file
@@ -1,4 +1,4 @@
-import { existsSync } from 'node:fs'
+import { realpathSync } from 'node:fs'
import { join, relative } from 'node:path'
import { toPosixPath } from '../shared/utils.js'
import { formatIntentCommand } from '../shared/command-runner.js'
@@ -52,12 +52,19 @@
}): void {
const topLevelPackageRoot =
packageName !== '' ? join(projectRoot, 'node_modules', packageName) : ''
- const hasStableSymlink =
- topLevelPackageRoot !== '' &&
- (packageRoot === topLevelPackageRoot || existsSync(topLevelPackageRoot))
+ let matchesTopLevelEntry: boolean
+ try {
+ matchesTopLevelEntry =
+ topLevelPackageRoot !== '' &&
+ (packageRoot === topLevelPackageRoot ||
+ realpathSync.native(topLevelPackageRoot) ===
+ realpathSync.native(packageRoot))
+ } catch {
+ matchesTopLevelEntry = false