Skip to content

Commit b66f338

Browse files
authored
fix(skills): use stable logical node_modules path for skills symlink (#718)
Before: symlink target resolved to pnpm's content-addressable path like `../../node_modules/.pnpm/vite-plus@0.1.1_.../node_modules/vite-plus/skills/vite-plus` After: symlink target uses the stable logical path `../../node_modules/vite-plus/skills/vite-plus` Falls back to the resolved path when the logical path doesn't exist or points to a different location.
1 parent 72b33f7 commit b66f338

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/cli/src/utils/skills.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {
55
readFileSync,
66
readdirSync,
77
readlinkSync,
8+
realpathSync,
89
symlinkSync,
910
} from 'node:fs';
1011
import { join, relative } from 'node:path';
1112

1213
import * as prompts from '@voidzero-dev/vite-plus-prompts';
1314

1415
import { type AgentConfig } from './agent.js';
16+
import { VITE_PLUS_NAME } from './constants.js';
1517
import { pkgRoot } from './path.js';
1618

1719
interface SkillInfo {
@@ -109,8 +111,23 @@ function linkSkills(
109111
return linked;
110112
}
111113

114+
function getStableSkillsDir(root: string): string {
115+
const resolvedSkillsDir = join(pkgRoot, 'skills');
116+
// Prefer the logical node_modules path for a cleaner, stable symlink
117+
// (avoids pnpm's versioned .pnpm/pkg@version/... real path)
118+
const logicalSkillsDir = join(root, 'node_modules', VITE_PLUS_NAME, 'skills');
119+
try {
120+
if (realpathSync(logicalSkillsDir) === realpathSync(resolvedSkillsDir)) {
121+
return logicalSkillsDir;
122+
}
123+
} catch {
124+
// Fall through to resolved path
125+
}
126+
return resolvedSkillsDir;
127+
}
128+
112129
export function linkSkillsForSpecificAgents(root: string, agentConfigs: AgentConfig[]): number {
113-
const skillsDir = join(pkgRoot, 'skills');
130+
const skillsDir = getStableSkillsDir(root);
114131
const skills = parseSkills(skillsDir);
115132
if (skills.length === 0) {
116133
return 0;

0 commit comments

Comments
 (0)