Skip non-scaffold files in tool config sync - #125
Conversation
checkToolConfigSync assumed any co-existing CLAUDE.md / AGENTS.md / .cursorrules were byte-identical copies installed from .tool-configs/, and flagged TOOL_CONFIG_DRIFT whenever two differed. Repos commonly have a hand-written CLAUDE.md or a generated AGENTS.md (e.g. a managed skill pack) that never came from the templates; comparing those is a false positive the user cannot fix without breaking one of the files. Every .tool-configs/ template carries a ROUTER.md scaffold pointer, so a file now participates in the mirror comparison only when its content includes that marker. Genuine drift between real scaffold copies is still flagged; non-copies are ignored.
…ositive fix: skip non-scaffold files in tool config sync
theDakshJaitly
left a comment
There was a problem hiding this comment.
The scaffold-copy detection remains too broad. ROUTER.md is not unique to mex-generated tool configs: independently owned CLAUDE.md and AGENTS.md files can legitimately tell agents to read ROUTER.md, causing this code to compare them and still report TOOL_CONFIG_DRIFT. I reproduced this with two unrelated files containing ordinary See ROUTER.md guidance. Please add a dedicated scaffold sentinel, such as an HTML mex-tool-config comment, to the generated templates and match that instead, with a regression test where non-scaffold files mention ROUTER.md. The focused tests, full suite (371 tests), and typecheck otherwise pass.
Matching on "ROUTER.md" was still too broad: independently owned CLAUDE.md/AGENTS.md files legitimately tell agents to read ROUTER.md, so unrelated files were compared and flagged as TOOL_CONFIG_DRIFT. Generated .tool-configs/ templates now carry an HTML sentinel comment (<!-- mex-tool-config ... -->) and the checker matches only that. Regression test covers non-scaffold files that mention ROUTER.md.
|
Addressed in 5f37ac4 (landing on this branch via the fork's main).
372 tests pass, typecheck clean. One trade-off to note: copies installed from pre-sentinel templates won't carry the marker, so the checker skips them until they're re-copied — a false negative rather than a false positive, which seems the right direction, but happy to add migration handling if you'd prefer. |
…ositive fix: use dedicated sentinel for tool config sync
Problem
checkToolConfigSynctreats any co-existingCLAUDE.md/AGENTS.md/.cursorrules/.windsurfrules/.github/copilot-instructions.mdas byte-identical copies installed from.tool-configs/, and raisesTOOL_CONFIG_DRIFTwhenever two differ.That assumption fails in repos where those files have independent owners. Real case: a repo with a hand-written
CLAUDE.md(project context) and anAGENTS.mdgenerated bytkt sync-pack(managed skill pack, "do not edit by hand"). Neither file ever came from.tool-configs/, and the warning is unfixable — making them match would either clobber the managed block or duplicate machine-regenerated content that re-drifts on the next sync.Fix
Every
.tool-configs/template carries aROUTER.mdscaffold pointer. A file now participates in the mirror comparison only when its content includes that marker:Trade-off: a copy edited so heavily that the
ROUTER.mdpointer is removed drops out of the check — at that point it is no longer a scaffold anchor, so silence is the correct behaviour.Testing
npx vitest run test/checkers.test.ts— 54/54 pass.TOOL_CONFIG_DRIFTfalse positive gone, drift score 88 → 91, real checks unaffected.