Skip to content

Phase 6: --check should print a unified diff in gen_docs.py and sync_agents_md.py #11

@thomaschristory

Description

@thomaschristory

Both drift-detection scripts only print the names of drifted files when their --check flag fires. CI logs say "out of date; re-run …" without showing what's actually different — a maintainer has to clone the PR locally and re-run the generator to see the diff.

Current state

  • scripts/gen_docs.py (5b): on drift, prints reference pages drifted (re-run \python scripts/gen_docs.py`): ['cli.md', ...]`. No content diff.
  • scripts/sync_agents_md.py (5d): on drift, prints AGENTS.md is out of date; run \uv run python scripts/sync_agents_md.py` and commit the result.` No content diff.

Proposed change

Add a difflib.unified_diff step before the error message in both scripts. Format:

$ uv run python scripts/sync_agents_md.py --check
AGENTS.md is out of date. Diff (expected vs current):
--- expected
+++ AGENTS.md
@@ -42,3 +42,4 @@
 line that's still there
-removed line
+added line
+other added line

run `uv run python scripts/sync_agents_md.py` and commit the result.

For gen_docs.py: print the diff per drifted file, capped at ~40 lines per file to avoid log spam if a generator change rewrote everything.

Why deferred from v1

Both --check flags work correctly; they just produce sparse output. CI gates fire as expected. This is a maintainer-ergonomics improvement that costs ~10 lines per script.

Acceptance

  • Both --check flags print a difflib.unified_diff-formatted diff to stderr before exiting non-zero.
  • New --no-diff flag preserves the current behavior for callers that want only the summary line.
  • Test coverage: each script's existing test suite gains a "drift produces a diff" case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions