Repository navigation
fix(cli): relink dangling agent instruction symlinks instead of crashing - #3544
Merged
Merged
Conversation
getExistingPathKind used fs.existsSync, which follows symlinks, so a dangling CLAUDE.md symlink was reported as missing. tryLinkTargetToAgents then called symlink() over it and vp migrate/create crashed with an uncaught EEXIST. Use lstat so the dangling link takes the existing symlink branch and is relinked to AGENTS.md. The in-memory fs in agent.spec.ts now follows symlinks in existsSync, throws EEXIST from symlink() over an existing path and sets error codes, matching node:fs.
fengmk2
force-pushed
the
fix/agent-dangling-symlink
branch
from
November 23, 2026 06:03
42d80d4 to
56cbf75
Compare
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.
vp migrate --agent agents,claude(andvp createwith the same targets) crashes with an uncaughtEEXISTwhenCLAUDE.mdis a dangling symlink, for example one that points at a shared file that isn't checked out:getExistingPathKindinpackages/cli/src/utils/agent.tschecksfs.existsSyncfirst.existsSyncfollows symlinks, so a dangling link counts asmissing.tryLinkTargetToAgentsthen callsfsPromises.symlink()over the existing link, and onlyEPERMis caught.This PR uses
lstatinstead, so a dangling link takes the existingsymlinkbranch: it is unlinked and relinked toAGENTS.md, the same as a link that points somewhere else.The in-memory fs in
agent.spec.tsdidn't matchnode:fshere: itsexistsSyncdidn't follow links and itssymlink()silently overwrote an existing path. It now follows links inexistsSync, throwsEEXISTfromsymlink()over an existing path, and setscode: 'ENOENT'on its not-found errors. The new test "relinks a dangling agent file symlink to AGENTS.md" fails withEEXISTbefore the fix and passes after it. I also ranwriteAgentInstructionsagainst a real temp directory with a danglingCLAUDE.mdlink: before the fix it throwsEEXIST, after itCLAUDE.mdlinks toAGENTS.md.Validation (macOS arm64, Node 24.22.3). I couldn't build the monorepo locally (no Rust toolchain,
rolldown/vitenot synced), so I ran the checks with the publishedvite-plus@1.7.0toolchain against this checkout:vp test run packages/cli/src: no new failures. The failing files are the same as on unmodifiedmainin this setup, because of missing workspace builds (for example@voidzero-dev/vite-task-client) andvi.spyOnon the npm build of@voidzero-dev/vite-plus-prompts. Those failures are unrelated to this change.vp fmt --checkandvp lint --type-aware --type-checkon the changed files: clean.🤖 Generated with Claude Code