Repository navigation
feat(rules): warn on diverging include selections for a shared root file - #4029
Merged
Merged
Conversation
When targets that write the same root rule file (e.g. codexcli and opencode, both AGENTS.md) resolve different rule selections and at least one of them sets the per-target `include` rules option, generate now warns once per file, naming the file, the targets and the last target that wins. Output is unchanged. Under preserveUnmanagedRuleContent, a leading frontmatter block above the fence is kept when the generated body has none, since it cannot be told apart from hand-written frontmatter. Document this and cover generate and --delete stability in tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
The shared-root selection warning now fires only when the targets sharing a root file would write different contents to it and at least one of them actually leaves rules out through `include`. Auto-discovery targets that file non-root rules in their own directories (kilo and antigravity-cli on AGENTS.md, for example) are no longer told to drop a valid config, and `include: ["*"]` is no longer blamed for differences that come from `targets` frontmatter. A file the selection warning names is skipped by the fold-root overwrite warning, so the run does not give conflicting advice. Tests use setupTestDirectory and cover a global-mode path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
When a fold target that keeps every rule is overwritten by a later narrowed target, the loss comes from the target order, so the fold-root overwrite warning (with its reorder advice) is printed and the selection warning skips that file. The selection warning only takes over when the overwritten fold target narrowed its own selection. Each shared root file gets one warning. The selection warning no longer claims `include` is the cause, and `include` narrowing is measured against the rules targeting the tool, so a rule for another tool does not make a selection look narrowed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…rap-followups # Conflicts: # src/generated/docs-content.ts
The fold-root overwrite warning was skipped whenever the overwritten fold target narrowed its selection, so a fold target that narrowed a little but still folded non-root rules lost them with no warning (e.g. codexcli and kilo both with include ["overview", "git-safety"]). The file is now handed to the selection warning only when the fold target folded nothing (its resolved selection holds no non-root rule); otherwise the fold warning with its reorder advice is printed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
This was referenced Nov 30, 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
Handles both low follow-ups from #4021.
rules.include(feat(rules): select rules per target with the include rules option #4017):rulesync generatenow warns, once per file, when targets that write the same root rule file (for examplecodexcliandopencode, bothAGENTS.md) resolve different rule selections and at least one of them setsinclude. The warning names the file, the targets, and the target that wins (the last one in config order). Nothing else changes.preserveUnmanagedRuleContent(feat(rules): add preserveUnmanagedRuleContent to keep hand edits in root rule files #4019): a frontmatter block above the fence that Rulesync wrote earlier, when the newly generated body has no frontmatter, is kept. Generate and--deletestay stable with it, and the behavior is now documented.What changed
src/lib/shared-root-selection-watch.ts(new): records the rulesync rules each target resolved for each rootToolRulepath, keyed by resolved output path.report()compares selections only for shared paths where some target setsinclude, and warns once per path. Wired intogenerateRulesCorenext to the existing fold-root overwrite watch.displayPathis now exported fromfold-root-overwrite-watch.tsso both watches name files the same way.src/features/rules/rule-managed-block.ts: the doc comment explains why a leading frontmatter block is kept when the generated content has none.include, not shared). An e2e case (codexcliwithincludeplusopencodewarns exactly once, and the same list on both stays quiet). A splice test (stale frontmatter: two generates give the same result, and removing the fence leaves the block). A processor test that runs generate twice (second run writes nothing) and then the--deletesweep twice (the block stays, nothing grows).docs/guide/configuration.md(theincludeshared-file bullet mentions the warning, and thepreserveUnmanagedRuleContentreference covers the kept frontmatter) anddocs/guide/global-mode.md. Regenerateddocs-content.ts.Design decisions (made autonomously)
keeps a hand-written leading frontmatter when the generated content has noneprotects. Being directly before the fence therefore does not show the block is Rulesync's. Matching "the shape this target emits" does not work either: the case only comes up when the target no longer emits frontmatter. Since there is no safe signal, the conservative choice wins: never delete possibly hand-written content. Docs tell users to remove a stale block by hand once. After a--deletesweep, the block keeps the file in place, as for any hand-written content.includeactually leaves a rule out. Many targets (kilo, antigravity-cli, copilot, ...) file non-root rules in their own directories, so a differentincludelist often leaves the shared root file byte-identical, and in that case nothing is reported.include: ["*"], or a list naming every rule, narrows nothing, so it is not blamed for differences that come from the rules' owntargetsfrontmatter.codexcli) folded any non-root rule into the file, with or withoutinclude, those rules are lost because of the target order. Only the fold-root overwrite warning, with its reorder advice, is printed then. The selection warning takes over only when the fold target folded nothing, because itsincludeleft it the root rule alone. Reordering would not help in that case.targetsfrontmatter excludes the tool does not make anincludelist look narrowed.Closes #4021
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4