Repository navigation
feat(generate): warn when an output is written through a symlink - #3949
Merged
Merged
Conversation
Generate already refuses links that lead out of the output root and writes through ones that stay inside it. An in-root link such as AGENTS.md -> .claude/CLAUDE.md therefore let one target silently replace another target's file. Every writer now warns, once per run and path, naming the output path and the real path the content lands in whenever it writes (or, under --dry-run, would write) a file through such a link. What gets written is unchanged. Refs #3945 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
Key the in-root link warning on the first link below the output root, so a linked directory such as ~/.claude -> ~/dotfiles/.claude is reported once however many files below it a run writes. The warning names the link and its real path. Finding the link is a plain lstat walk over the segments below the root, so an output root that is itself a link does not count and no extra landing walks are needed for files without a link. Also warn from the Antigravity plugin manifest write. Refs #3945 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
The per-link warning stops at the first link below the output root, so with ~/.codex -> ~/dotfiles/.codex and AGENTS.md -> ../.claude/CLAUDE.md inside it, only ~/.codex was named. When a file's real landing differs from the first link's landing joined with the rest of its path, warn for that file too with its real path. Also pin that errors other than a missing entry propagate from firstLinkBelowRoot. Refs #3945 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…rn-symlink-writes # Conflicts: # src/generated/docs-content.ts
Owner
Author
|
@dyoshikawa Thank you! |
This was referenced Nov 24, 2026
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
Implements option 3 of #3945: a warning whenever generate writes a file through a symbolic link that stays inside the output root. What gets written is unchanged — no skip and no new option; options 1 and 2 stay open for a maintainer decision.
#3123 made generate refuse links that lead out of the output root and keep writing through in-root ones (dotfiles setups rely on that). As a result, an in-root
AGENTS.md -> .claude/CLAUDE.mdlink letgenerate --targets codexcli,opencodereplace Claude Code's instructions file without any message. Now the run prints:warnIfWriteFollowsLinkinsrc/types/feature-processor.ts, next torefusesWriteOutsideRoot. It finds the first symbolic link below the output root on the output path (newfirstLinkBelowRootinsrc/utils/file.ts, an lstat walk over the segments below the root) and names that link and its real path. An output root that is itself a link does not count.FeatureProcessor.writeAiFiles,DirFeatureProcessor.writeAiDirs(every file of a changed directory), and the Hermes / Goose config rewrites, Hermes plugin activation and the Antigravity plugin manifest. It runs before the dry-run branch, so--dry-run/--checkwarn too.--globaldotfiles setup (~/.claude -> ~/dotfiles/.claude) would get one warning per file on every run.warnOnceWithFallbackkeyed on the link, so a linked directory is reported once however many files below it change, and a path that several targets write in one run (codexcli and opencode both writeAGENTS.md) is reported once.~/.codex -> ~/dotfiles/.codexplus~/dotfiles/.codex/AGENTS.md -> ../.claude/CLAUDE.md), a second warning names that file and its own real path, once per file.docs/reference/file-formats.mddocuments the warning.Refs #3945
Tests
feature-processor.test.ts: the existing in-root-link case now expects the warning. New cases cover the issue'sAGENTS.md -> .claude/CLAUDE.mdfile link, a dry run, an up-to-date file (no warning), two processors writing the same linked file (one warning), and a path with no link (no warning), many files below one linked directory (one warning), an output root that is itself a link (no warning), and a nested link inside a linked directory (a second warning naming the file's real path).dir-feature-processor.test.ts: a skill directory linked inside the root warns for itsSKILL.md, and an up-to-date linked directory stays quiet.file.test.ts:firstLinkBelowRootcases, including a non-ENOENT error (EACCES) being rethrown.hermes-project-plugin-activation.test.ts: a config linked inside the home directory warns.pnpm cicheckpasses (17289 tests).🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4