feat(rules): let Pi rules emit AGENTS.override.md - #2627
Merged
Conversation
Pi tries AGENTS.override.md before AGENTS.md and CLAUDE.md in every directory it scans, so it is the only way to make Rulesync's output deterministically win next to a sibling context file. The root rule opts in with pi.contextFile: override and decides for the whole Pi output; the flag on a non-root rule alone is ignored with a warning, because a split across both files would leave everything in AGENTS.md unread.
With pi.contextFile: override the target no longer writes ./AGENTS.md, so the orphan sweep removed the copy agentsmd, codexcli or warp had just written (the root-file ownership map only arbitrates --check). That path is never Pi-exclusive, so PiRule now refuses to delete it; the global ~/.pi/agent/AGENTS.md still is. Also align the flag across every targeted rule rather than only the non-root ones, so a second root rule cannot be left in the file Pi stops reading, and skip rules targeting other tools.
This was referenced Aug 7, 2026
Merged
Merged
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.
Gap 2:
AGENTS.override.mdis now emittableVerified upstream first:
loadContextFileFromDirinpackages/coding-agent/src/core/resource-loader.tstries["AGENTS.override.md", "AGENTS.md", "AGENTS.MD", "CLAUDE.md", "CLAUDE.MD"]and returns the first hit, andloadProjectContextFilesruns it over the global agent dir as well as the project ancestors — so the override wins deterministically at both scopes. (The doc line ispackages/coding-agent/docs/usage.md~106; the issue'sdocs/usage.mdpath is stale.)A
root: truerule opts in withpi.contextFile: override. Because Pi folds every rule body into the single root context file, the root rule decides for the whole Pi output: the flag is copied onto non-root rules, and setting it only on a non-root rule is ignored with a warning — emitting both files would leave everything inAGENTS.mdunread by Pi.AGENTS.override.mdis Pi-exclusive, so it round-trips through import and is cleaned up when the flag is toggled off, while the sharedAGENTS.mdis never deleted on Pi's behalf.Gap 1: closing as not-a-bug
The premise does not hold. The
stop→agent_endmapping was made on 2026-07-19, ten days afteragent_settledand its recommendation text already existed upstream (commit e9fa5a68, 2026-07-09), so it was not made in ignorance of the alternative.src/types/hooks.ts:1146-1152records it as a deliberate trade-off:agent_settledwould skip queued follow-ups instead, which is a pure trade-off rather than a strict improvement, so it is intentionally unmapped. Changing it would be a canonical-semantics design decision, not a bug fix.With gap 2 implemented and gap 1 resolved as intended behavior, this issue is complete.
Closes #2601
🤖 Generated with Claude Code