Skip to content

fix(installer): preserve symlinks when writing agent config files - #433

Open
0x1306a94 wants to merge 1 commit into
colbymchenry:mainfrom
0x1306a94:fix/symlink-preservation-in-installer
Open

fix(installer): preserve symlinks when writing agent config files#433
0x1306a94 wants to merge 1 commit into
colbymchenry:mainfrom
0x1306a94:fix/symlink-preservation-in-installer

Conversation

@0x1306a94

@0x1306a94 0x1306a94 commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • atomicWriteFileSync uses a write-tmp-then-rename pattern, which replaces the directory entry (inode) and breaks symlinks
  • Added resolveSymlink() helper that checks lstatSync + isSymbolicLink() and resolves via realpathSync (with manual readlinkSync fallback for dangling symlinks)
  • atomicWriteFileSync and removeMarkedSection now resolve symlinks before writing/unlinking, so shared AGENTS.md CLAUDE.md via symlink survives reinstall

Motivation

Users may share a single AGENTS.md across multiple agents via symlinks:

ln -sf ~/AGENTS.md ~/.claude/CLAUDE.md
ln -sf ~/AGENTS.md ~/.codex/AGENTS.md

Previously, running codegraph install --target claude,codex --yes would replace these symlinks with regular files, breaking the shared setup. This fix ensures symlinks are followed and the real target file is written to.

Test plan

  • 6 new symlink tests pass: write-through-symlink, marked section replace/remove through symlink, dangling symlink creation, non-symlink normal path
  • All 88 installer-targets tests pass with no regressions

@0x1306a94
0x1306a94 force-pushed the fix/symlink-preservation-in-installer branch 3 times, most recently from f5deed0 to e2ad925 Compare May 28, 2026 09:40
@0x1306a94

Copy link
Copy Markdown
Contributor Author

@colbymchenry

@0x1306a94
0x1306a94 force-pushed the fix/symlink-preservation-in-installer branch 7 times, most recently from 5eaf599 to 056e580 Compare June 5, 2026 01:15
@0x1306a94
0x1306a94 force-pushed the fix/symlink-preservation-in-installer branch 2 times, most recently from 817c2a0 to 3e64a23 Compare June 12, 2026 01:28
@0x1306a94
0x1306a94 force-pushed the fix/symlink-preservation-in-installer branch 3 times, most recently from 6691433 to 07c8e25 Compare June 22, 2026 01:16
@0x1306a94
0x1306a94 force-pushed the fix/symlink-preservation-in-installer branch from 07c8e25 to 90d3a00 Compare July 8, 2026 00:17
@0x1306a94

Copy link
Copy Markdown
Contributor Author

@colbymchenry Can this PR be considered for merging?

@0x1306a94
0x1306a94 force-pushed the fix/symlink-preservation-in-installer branch from 90d3a00 to 599df05 Compare July 10, 2026 11:01
atomicWriteFileSync used write-tmp-then-rename, which replaces the
directory entry and breaks symlinks. Resolve symlinks to their real
target path before writing so shared AGENTS.md / CLAUDE.md setups
survive reinstall.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant