feat: add AGENTS.md context injection to agentdiff configure#17
Conversation
Extend `agentdiff configure` to write/update an `## AgentDiff` managed block in `AGENTS.md` at the current directory (repo root). This surfaces agentdiff context to agents like Codex, Cursor, and Copilot that read AGENTS.md for repo-level instructions — a gap the Claude-specific SKILL template couldn't fill. - New `src/configure/agents_md.rs`: idempotent managed-block writer using HTML comment markers, following the same pattern as antigravity GEMINI.md - `agentdiff configure` calls step_configure_agents_md(repo_root) as step 10 - `--no-agents-md` flag skips the AGENTS.md step - 4 unit tests: create-from-scratch, idempotency, in-place update, and append-to-existing-content - README updated to document AGENTS.md support and --no-agents-md flag Closes #15 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR adds an idempotent
Confidence Score: 5/5Safe to merge — all code paths are covered by tests, the malformed-block guard prevents file corruption, and the git-repo check prevents stray AGENTS.md files outside project roots. The change is well-scoped: it adds a new, optional configure step backed by thorough unit tests. The two findings are both cosmetic — a leading blank line in newly-created files and an unused import — neither of which affects correctness or data integrity. src/configure/agents_md.rs — separator logic for the empty-file case; src/configure/mod.rs — unused PathBuf import Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[agentdiff configure] --> B{--no-agents-md?}
B -- yes --> Z[skip AGENTS.md]
B -- no --> C{.git exists at repo_root?}
C -- no --> D[print skip message, return Ok]
C -- yes --> E[read AGENTS.md or default to empty string]
E --> F{AGENTS_MD_START found?}
F -- yes --> G{AGENTS_MD_END found?}
G -- no --> H[warn: malformed, skip]
G -- yes --> I{current block == managed_block?}
I -- yes --> J[print up-to-date, return Ok]
I -- no --> K[replace block in place, write file]
F -- no --> L{existing is empty?}
L -- yes --> M[separator = empty string]
L -- no --> N{ends with newline?}
N -- yes --> O[separator = single newline]
N -- no --> P[separator = double newline]
M & O & P --> Q[append managed block, write file]
Reviews (2): Last reviewed commit: "fix: skip AGENTS.md outside git repos; w..." | Re-trigger Greptile |
Two bugs flagged in review: - configure run outside a git repo (machine-global setup) wrote AGENTS.md to current_dir() instead of skipping. Now checks for .git before writing. - File with start sentinel but no end sentinel silently got a second block appended. Now warns and skips to avoid corrupting the file. Also: &PathBuf -> &Path in run_configure signature (idiomatic). Added two tests: skips_when_not_a_git_repo, warns_and_skips_on_unclosed_sentinel. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AgentDiff ReportSummary
Review Context
Files To Review First
Trace details
|
Summary
agentdiff configurenow writes/updates an## AgentDiffmanaged block inAGENTS.mdat the current directory (repo root), so agents like Codex, Cursor, and Copilot that readAGENTS.mdget the same context that Claude Code gets from the SKILL template--no-agents-mdflag skips the step entirelyChanges
src/configure/agents_md.rs— new module with managed-block write/update logic (same HTML-comment marker pattern as the existing antigravity GEMINI.md writer)src/cli.rs— add--no-agents-mdflag toConfigureArgssrc/configure/mod.rs— register module, call step 10, passrepo_root, update test helper structsrc/main.rs— passrepo_roottorun_configureREADME.md— document AGENTS.md support and--no-agents-mdflagTest plan
cargo test— all 39 unit tests pass, including 4 newagents_mdtests:cargo build— clean compileCloses #15
🤖 Generated with Claude Code