GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(cli): relink dangling agent instruction symlinks instead of crashing by thejesh23 · Pull Request #3544 · voidzero-dev/vite-plus

fix(cli): relink dangling agent instruction symlinks instead of crashing #3544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
fengmk2 merged 2 commits into voidzero-dev:main from thejesh23:fix/agent-dangling-symlink
Nov 23, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(cli): relink dangling agent instruction symlinks instead of crashing #3544

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
8a1ad29
fix(cli): relink dangling agent instruction symlinks instead of crashing
thejesh23 Nov 22, 2026
56cbf75
test(migrate): cover dangling Claude instruction symlinks
fengmk2 Nov 23, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

13 changes: 13 additions & 0 deletions 13 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_agent_claude/snapshots.toml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ steps = [
{ argv = ["vp", "migrate", "--agent", "claude", "--no-interactive"], comment = "migration with --agent claude should write CLAUDE.md", continue-on-failure = true },
{ argv = ["vpt", "grep-file", "CLAUDE.md", "<!--VITE PLUS START-->"], comment = "CLAUDE.md was created with the Vite+ agent block", continue-on-failure = true },
]

[[case]]
name = "relink_dangling_claude_symlink"
vp = "global"
# Creating a file symlink can require elevated privileges on Windows.
skip-platforms = ["windows"]
comment = "When both agent files are selected, migration repairs a dangling CLAUDE.md link."
steps = [
{ argv = ["node", "-e", "require('node:fs').symlinkSync('missing.md', 'CLAUDE.md')"], snapshot = false },
["vp", "migrate", "--agent", "agents,claude", "--no-interactive", "--no-hooks", "--no-editor"],
["node", "-p", "require('node:fs').readlinkSync('CLAUDE.md')"],
["vpt", "grep-file", "CLAUDE.md", "<!--VITE PLUS START-->"],
]
28 changes: 28 additions & 0 deletions 28 ...ots/fixtures/migration_agent_claude/snapshots/relink_dangling_claude_symlink.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# relink_dangling_claude_symlink

When both agent files are selected, migration repairs a dangling CLAUDE.md link.

## `node -e 'require('\''node:fs'\'').symlinkSync('\''missing.md'\'', '\''CLAUDE.md'\'')'`


## `vp migrate --agent agents,claude --no-interactive --no-hooks --no-editor`

```
VITE+ - The Unified Toolchain for the Web

◇ Migrated . to Vite+ <version>
• Node <version> pnpm <version>
• 1 config update applied, 1 file had imports rewritten
```

## `node -p require('node:fs').readlinkSync('CLAUDE.md')`

```
AGENTS.md
```

## `vpt grep-file CLAUDE.md '<'\!'--VITE PLUS START-->'`

```
CLAUDE.md: found "<!--VITE PLUS START-->"
```
47 changes: 40 additions & 7 deletions 47 packages/cli/src/utils/__tests__/agent.spec.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ type MockNode =
| { kind: 'file'; content: string }
| { kind: 'symlink'; target: string };

function enoent(filePath: fs.PathLike) {
return Object.assign(new Error(`ENOENT: no such file "${String(filePath)}"`), { code: 'ENOENT' });
}

class InMemoryFs {
private readonly nodes = new Map<string, MockNode>();

constructor() {
this.ensureDirectory(path.parse(process.cwd()).root);
}

// Like fs.existsSync, follows symlinks: a dangling symlink does not exist.
existsSync(filePath: fs.PathLike): boolean {
return this.nodes.has(this.normalize(filePath));
try {
this.resolvePath(filePath);
return true;
} catch {
return false;
}
}

lstatSync(filePath: fs.PathLike): fs.Stats {
Expand All @@ -58,7 +68,7 @@ class InMemoryFs {
const resolvedPath = this.resolvePath(filePath);
const node = this.nodes.get(resolvedPath);
if (!node || node.kind !== 'file') {
throw new Error(`ENOENT: no such file "${String(filePath)}"`);
throw enoent(filePath);
}
return node.content;
}
Expand Down Expand Up @@ -89,6 +99,11 @@ class InMemoryFs {

async symlink(target: string, filePath: fs.PathLike): Promise<void> {
const normalizedPath = this.normalize(filePath);
if (this.nodes.has(normalizedPath)) {
throw Object.assign(new Error(`EEXIST: file already exists "${String(filePath)}"`), {
code: 'EEXIST',
});
}
this.ensureDirectory(path.dirname(normalizedPath));
this.nodes.set(normalizedPath, { kind: 'symlink', target });
}
Expand All @@ -104,7 +119,7 @@ class InMemoryFs {
async unlink(filePath: fs.PathLike): Promise<void> {
const normalizedPath = this.normalize(filePath);
if (!this.nodes.has(normalizedPath)) {
throw new Error(`ENOENT: no such file "${String(filePath)}"`);
throw enoent(filePath);
}
this.nodes.delete(normalizedPath);
}
Expand All @@ -113,7 +128,7 @@ class InMemoryFs {
const resolvedPath = this.resolvePath(filePath);
const node = this.nodes.get(resolvedPath);
if (!node || node.kind !== 'file') {
throw new Error(`ENOENT: no such file "${String(filePath)}"`);
throw enoent(filePath);
}
return node.content;
}
Expand Down Expand Up @@ -142,7 +157,7 @@ class InMemoryFs {
const normalizedPath = this.normalize(filePath);
const node = this.nodes.get(normalizedPath);
if (!node) {
throw new Error(`ENOENT: no such file "${String(filePath)}"`);
throw enoent(filePath);
}
return node;
}
Expand Down Expand Up @@ -174,7 +189,7 @@ class InMemoryFs {
while (true) {
const node = this.nodes.get(current);
if (!node) {
throw new Error(`ENOENT: no such file "${String(filePath)}"`);
throw enoent(filePath);
}
if (node.kind !== 'symlink') {
return current;
Expand Down Expand Up @@ -390,9 +405,10 @@ describe('detectExistingAgentTargetPaths', () => {

it('ignores symlinked agent files', async () => {
const dir = await createProjectDir();
await mockFs.writeFile(path.join(dir, 'AGENTS.md'), '# Agents');
await mockFs.symlink('AGENTS.md', path.join(dir, 'CLAUDE.md'));

expect(detectExistingAgentTargetPaths(dir)).toBeUndefined();
expect(detectExistingAgentTargetPaths(dir)).toEqual(['AGENTS.md']);
});
});

Expand Down Expand Up @@ -479,6 +495,23 @@ describe('writeAgentInstructions symlink behavior', () => {
);
});

it('relinks a dangling agent file symlink to AGENTS.md', async () => {
const dir = await createProjectDir();
const claudePath = path.join(dir, 'CLAUDE.md');
await mockFs.symlink(path.join('..', 'shared', 'CLAUDE.md'), claudePath);
expect(mockFs.existsSync(claudePath)).toBe(false);

await writeAgentInstructions({
projectRoot: dir,
targetPaths: ['AGENTS.md', 'CLAUDE.md'],
interactive: false,
});

expect(mockFs.isSymlink(claudePath)).toBe(true);
expect(mockFs.readlinkSync(claudePath)).toBe('AGENTS.md');
expect(await mockFs.readText(claudePath)).toContain('template block');
});

it('does not replace existing non-symlink files with symlinks', async () => {
const dir = await createProjectDir();
const existingClaude = path.join(dir, 'CLAUDE.md');
Expand Down
11 changes: 9 additions & 2 deletions 11 packages/cli/src/utils/agent.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,17 @@ async function tryLinkTargetToAgents(projectRoot: string, targetPath: string, si
}

async function getExistingPathKind(filePath: string) {
if (!fs.existsSync(filePath)) {
// lstat rather than existsSync: existsSync follows symlinks, so it reports a
// dangling symlink as missing and the later symlink() call fails with EEXIST.
const stat = await fsPromises.lstat(filePath).catch((err: NodeJS.ErrnoException) => {
if (err.code === 'ENOENT') {
return undefined;
}
throw err;
});
if (!stat) {
return 'missing' as const;
}
const stat = await fsPromises.lstat(filePath);
return stat.isSymbolicLink() ? ('symlink' as const) : ('file' as const);
}

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.