Repository navigation
fix(sync): exclude templates/opencode from the generic diff/copy engine (#1030) - #1042
Merged
admarble merged 5 commits intoSep 11, 2026
Conversation
Entire-Checkpoint: 3b4d69cae5da
…ne; sync/update refresh the shim in place (#1030) - templateDestination() routes templates/opencode/** to null, matching the mcp.json/relay/ precedent — the generic engine never diffs or copies it. - init.ts exports decideOpencodeShimSync/refreshOpencodeShim so sync/update can preview and apply the same opencode shim refresh init performs, gated on an existing .opencode/ directory. - sync --dry-run previews 'opencode shim: refresh' alongside the AGENTS.md/ scripts/dev decisions; the apply path refreshes the shim after copyTemplates. - update mirrors the same preview/refresh and states explicitly that it still does not manage AGENTS.md or scripts/dev (sync-only). - Fixes the phantom serve/preflight 'differ from bundled content' warning on every project that predates the opencode shim, and update no longer plants unrendered {{PHASE}} placeholder files. Entire-Checkpoint: 364e5007d2d5
…ng to do Second-pass QA found the presence-based decision made every opencode project permanently "pending": sync --dry-run exited non-zero forever (breaking the #709 CI-gating contract) and a non-interactive update refused to run with nothing to do. decideOpencodeShimSync now renders the shim with the same writers into a scratch dir and compares file-by-file (MCP config: sequant's entry present and equal, user entries ignored); 'current' reads like 'none' for the exit code and the apply path while staying visible in the dry-run preview. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
…im instead of skipping it Second-pass QA: sync's report-only fast path returned before the shim decision, so on a version-current project a drifted shim was invisible to sync and sync --dry-run (only update / sync --force repaired it). The fast path now consults decideOpencodeShimSync and treats a stale shim like any other drift on that path: reported, exit 1, same repair hint, no mutation (#708 contract). Tests cover both the stale and the current case. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
This was referenced Sep 11, 2026
…-dry-run-lists-files-apply-never-writes-th
admarble
deleted the
feature/1030-fix-sync-dry-run-lists-files-apply-never-writes-th
branch
September 11, 2026 01:43
This was referenced Sep 19, 2026
admarble
added a commit
that referenced
this pull request
Sep 20, 2026
…s outside the diff need an issue number (#1101) * chore(hooks): allow anchored env|grep in the env-dump guard; red tests outside the diff need an issue number pre-tool.sh (all three copies): a bare env/printenv piped into a grep whose pattern starts with ^ is a prefix-scoped listing, not a dump. It is how a phase checks for the orchestrator's own SEQUANT_* vars leaking into the suite (#1086). Bare env, printenv, export and an unanchored env | grep TOKEN still block. 8 new cases per hook copy in the integration test. exec and qa skills (all three copies): a failing test in a file the diff never touched must be re-run with the SEQUANT_* vars unset, settled against base in the same worktree, and named in the PR body with an issue number. PRs #1036, #1042 and #1048 wrote 'pre-existing, unrelated' for the same three failures; none filed, and the same failures stopped the #1060 gate a week later. Entire-Checkpoint: 2ebe233c071c * chore(skills): unset every SEQUANT_* var generically so the exec skill passes the relay isolation guard (AC-16) Entire-Checkpoint: 02360586d1fc
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
templateDestination()now excludestemplates/opencode/**from the generic diff/copy engine (same pattern asmcp.json/relay/) — the engine never reported phantom drift on a tree it never writes.init.tsexportsdecideOpencodeShimSync/refreshOpencodeShim;sync/updatereuse them to preview (--dry-run:opencode shim: refresh) and apply the same shim refreshinit --agent opencodeperforms, gated on an existing.opencode/directory so neither command creates one on a project that never opted in.update --dry-runnow states explicitly it doesn't manageAGENTS.md/scripts/dev(stayssync-only), resolving the fix(sync): never rewrite a user-owned AGENTS.md or write a machine-specific scripts/dev symlink (absorbs #991) #990 scope-addition comment's open question with the "state explicitly" option rather than reconciling full AGENTS.md/scripts-dev behavior intoupdate.init's renderer (not exclude-only design (b)) — this actually resolves symptom 4 ("shim drifts silently") rather than leaving it open.AC Verification
sync.test.ts"opencode shim (AC-1, AC-3)" —dry-run matches apply: previews 'refresh' and apply actually refreshes it.claude/opencode/path produced by the generic enginesrc/lib/templates.ts:templateDestination—templates.test.ts"returns null for templates/opencode/** (#1030)" + "excludes templates/opencode/** from the opencode-shim diff entirely (#1030)".opencode/existssync.test.ts+update.test.ts"opencode shim (AC-3)" describe blockssync-source-invocation.integration.test.ts"no phantom opencode drift after a plain init (#1030)"{{...}}placeholdertemplates.test.ts"writeOpencodeCommands leaves no unrendered placeholders (#1030)"npm run build && npm test— see Test planMutation verification
Mutation-verified: AC-2 — removed the
templates/opencode/case fromtemplateDestination;src/lib/templates.test.ts > templates > templateDestination > returns null for templates/opencode/** (#1030)failed; restored.Mutation-verified: AC-3 — removed the
refreshOpencodeShim()call fromsync.ts's apply path;src/commands/sync.test.ts > sync command > syncCommand > opencode shim (AC-1, AC-3) > dry-run matches apply: previews 'refresh' and apply actually refreshes it, on a project with .opencode/failed; restored.Second-pass fix (first QA: AC_MET_BUT_NOT_A_PLUS, 3fce881)
QA's two real gaps were a regression for opencode projects: the shim decision was presence-based, so
.opencode/could never resolve to "nothing to do" —sync --dry-runexited non-zero forever (breaking the #709 CI-gating contract) and a non-interactiveupdaterefused to run with nothing to apply.decideOpencodeShimSyncis now content-aware: it renders the shim with the same writers into a scratch directory and compares file-by-file (MCP config: sequant's entry present and equal; user-added entries ignored). Resultcurrentreads likenonefor the exit code and the apply path while staying visible in the preview. Real-filesystem tests insrc/commands/init.opencode-shim.test.ts(5 cases: none / current / drifted command / missing plugin file / MCP entry lost vs user entry added) pluscurrent/refreshcases insync.test.tsandupdate.test.ts.Not changed: the second templates→
.claudemapping QA flagged as harmless duplication (noted for a follow-up), theUpdated 0 filestally wording, and the doubledecideOpencodeShimSync()call insync.ts(mutually exclusive paths).Mutation-verified: AC-1 — removed the
templates/opencode/exclusion line fromtemplateDestination;src/commands/sync-source-invocation.integration.test.ts > reports no phantom drift on a plain (no --agent opencode) projectfailed (the motivating "3 file(s) differ from bundled content" reappeared); restored.Mutation-verified: AC-4 — same mutation: removed the
templates/opencode/exclusion line fromtemplateDestination;src/commands/sync-source-invocation.integration.test.ts > reports no phantom drift on a plain (no --agent opencode) projectfailed; restored.Mutation-verified: AC-3 — made decideOpencodeShimSync return 'refresh' whenever .opencode/ exists (the presence-only decision);
src/commands/init.opencode-shim.test.ts > is 'current' right after the writers ran, and stays so on a second lookfailed (with two sibling cases); restored.Third pass (second QA: AC_NOT_MET on AC-3, 48047fb)
QA reproduced that
sync's version-current fast path (sync.ts~:330) returned before the shim decision, so a drifted shim on an up-to-date project was invisible tosyncandsync --dry-run; onlyupdate/sync --forcerepaired it. The fast path is report-only by design (#708 — it never overwrites in-place customizations), so a stale shim is now treated like every other drift there: printed asopencode shim: refresh, named in theVersion current, but … the opencode shim is stale — run update or sync --forceline, exit 1, no mutation. A matching shim still reads "already up to date" with exit 0. Twosync.test.tscases cover the version-current path, which no shim test exercised before.Not changed: the duplicated templates→
.claudemapping incomputeDriftFingerprint(sync.ts~:130, stat-only cache key) — QA classed itdocument; worth folding intotemplateDestinationin a follow-up.Mutation-verified: AC-3 — removed the && fastPathShim !== "refresh" clause from sync's version-current fast path;
src/commands/sync.test.ts > version-current fast path: a stale shim is reported with exit 1 and the repair hint, never silently skipped (second-pass QA)failed; restored.Pre-PR Confidence Check
decideOpencodeShimSyncdetects intent to refresh purely via.opencode/directory presence, not by re-reading whether the project was ever initialized with--agent opencode. A project that manually created.opencode/for unrelated reasons would get an (idempotent, harmless) refresh — an edge case the spec's own design note calls out as the accepted tradeoff of design (a).init.ts,sync.ts,update.ts,templates.ts) have direct test coverage exercising the new code paths, including two mutation-verified gate tests above.Test plan
npm run build— passesnpm run lint— passes (0 errors, 0 warnings)npm test— 6285 passed / 3 failed / 4 skipped / 1 expected fail. The 3 failures (relay-hook.integration.test.ts,prompt-wait.test.ts,batch-executor.test.ts) are in files this PR never touches (relay hook, prompt --wait, activity-hook wiring) and are pre-existing/unrelated to the opencode-shim change.Closes #1030