fix(hooks/codex): write RTK reference to AGENTS.override.md, not AGENTS.md#1977
Open
YOMXXX wants to merge 1 commit into
Open
fix(hooks/codex): write RTK reference to AGENTS.override.md, not AGENTS.md#1977YOMXXX wants to merge 1 commit into
YOMXXX wants to merge 1 commit into
Conversation
…TS.md Codex CLI exposes two layered instruction files: AGENTS.md (base) and AGENTS.override.md (local overrides). The override layer is the intended target for tool-generated content because it keeps the base file pristine and makes generated changes easy to reason about and clean up. Prior behavior: rtk init --codex wrote '@RTK.md' into AGENTS.md, which mingled RTK output with user-authored base instructions and made provenance harder to track. New behavior: - run_codex_mode now routes through run_codex_mode_at(codex_dir, ...), which writes the @RTK.md reference into AGENTS.override.md. - On install, any RTK content found in a legacy AGENTS.md (inline rtk-instructions block and/or @RTK.md reference) is stripped from the base file; the reference is then added to AGENTS.override.md. User-authored AGENTS.md content is preserved verbatim. - uninstall_codex_at scrubs both AGENTS.md (legacy) and AGENTS.override.md (current), so users upgrading get fully cleaned up. - hook_check tests now treat AGENTS.override.md as a valid codex install marker alongside AGENTS.md. Five new tests cover: fresh install writes to override.md only, existing AGENTS.md content is preserved, legacy @RTK.md reference is migrated, legacy inline RTK block is stripped, uninstall cleans both files. Fixes rtk-ai#1943
Contributor
Author
|
recheck |
1 similar comment
Contributor
Author
|
recheck |
Contributor
Author
|
@CLAassistant recheck |
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
`rtk init --codex` previously injected its `@RTK.md` reference into Codex's base `AGENTS.md` file, mingling RTK output with user-authored base instructions. Codex's documented layering puts user/tool overrides in `AGENTS.override.md` — the least-destructive layer — so this PR routes RTK there. Existing installs that wrote into `AGENTS.md` are migrated cleanly: the legacy RTK reference (and any older inline `` block) is stripped from `AGENTS.md`, and the modern `@RTK.md` reference is added to `AGENTS.override.md`.
Reproduction
```bash
mkdir -p /tmp/codex-repro && cd /tmp/codex-repro
printf '# Base rules\nAnswer in Spanish.\n' > AGENTS.md
rtk init --codex
diff -u <(printf '# Base rules\nAnswer in Spanish.\n') AGENTS.md
Before this PR: diff (AGENTS.md was modified, @RTK.md appended)
After this PR: no diff (AGENTS.md untouched, @RTK.md lives in AGENTS.override.md)
cat AGENTS.override.md
After this PR: contains the @RTK.md reference
```
Root cause
`src/hooks/init.rs:2287-2353` (`run_codex_mode` / `run_codex_mode_with_paths`): both global and local codex install paths joined `codex_dir / AGENTS.md` and called `patch_agents_md()` on that path. `hook_check.rs:172` similarly used `AGENTS.md` as the install marker.
Fix approach
Behavior changes
Test plan
Fixes #1943