fix(installer): stop swapping symlinked config files for detached copies (shared AGENTS.md setups) - #1503
Open
meganemura wants to merge 1 commit into
Conversation
…ies (shared AGENTS.md setups) atomicWriteFileSync landed its temp file on the destination via renameSync, which replaces a symlink itself rather than its target. Setups that symlink one shared instructions file into each agent's expected location (~/.claude/CLAUDE.md -> ~/AGENTS.md, ~/.codex/AGENTS.md -> ~/AGENTS.md, ...), and dotfiles-managed configs, silently lost the link: the file became a detached regular-file copy, and later edits to the shared source never reached the file the agent actually reads. Resolve the symlink chain first (manually — realpathSync throws on dangling links, and creating a dangling link's target must keep working) and run the temp-file-plus-rename against the real target, keeping the write atomic on the target's own filesystem. When several selected agents point at the same shared file, the marker-based upsert dedupes across them: the guidance block is written exactly once. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
meganemura
force-pushed
the
fix/installer-stop-swapping-symlinked-configs
branch
from
August 8, 2026 01:45
044b342 to
eff3500
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.
Summary
codegraph installbreaks symlinked config files. The installer writes a temp file and then renames it onto the destination. Butrenamereplaces the symlink itself, not the file it points to. So the symlink turns into a plain copy.This hurts setups that share one
AGENTS.mdacross agents:After install, the link is gone, and edits to the shared file no longer reach the agent. Dotfiles-managed configs break the same way.
The fix: resolve the symlink first, then write to the real file. The write stays atomic (temp file + rename in the target's own directory). All installer writes go through this one helper, so JSON, TOML, and markdown files are all covered. If several agents link to the same shared file, the block is written only once; the other installs report
unchanged.Relationship to #433
@0x1306a94 found this problem first and proposed the same core fix in #433 — full credit to them. This PR differs in three ways:
upsertInstructionsEntrywith the real markers) and include the shared-AGENTS.mdcase. A CHANGELOG entry is included, crediting fix(installer): preserve symlinks when writing agent config files #433.Test plan
npx vitest run __tests__/installer-targets.test.ts— all pass (6 new symlink tests), macOStsc --noEmitclean🤖 Generated with Claude Code