Skip to content

fix: gaze init treats commands/gaze.md as tool-owned (gaze-local.md escape hatch) - #356

Merged
jflowers merged 2 commits into
unbound-force:mainfrom
jflowers:opsx/gaze-command-tool-owned
Nov 16, 2026
Merged

jflowers merged 2 commits into
unbound-force:mainfrom
jflowers:opsx/gaze-command-tool-owned

Conversation

@jflowers

Copy link
Copy Markdown
Collaborator

Summary

gaze init now treats commands/gaze.md as tool-owned (issue #353): overwrite-on-diff without --force, exactly like commands/gaze-fix.md, so the flagship /gaze command stops going stale in consumer projects on every gaze release. The first gaze init after upgrading delivers the accumulated upstream changes (the #221 <protect> block, the spec 040 rendered-report description, analyzer/language detection) and heals the duplicate dev/v1.8.0 version markers the 10-repo survey found. All nine embedded .opencode/ assets are now tool-owned; the CI workflow remains the only user-owned scaffold output.

Custom /gaze escape hatch: a separately named commands/gaze-local.md is structurally never written — even by --force — and OpenCode exposes it as /gaze-local. When init updates gaze.md, the summary prints a one-line tip naming the hatch (never on creation, identical-skip, or force-overwrite). Plain re-runs no longer print the --force hint (no user-owned .opencode/ file can be skipped), while the CI-workflow skip keeps it — now pinned by a test.

Embedded asset content and the 9-file manifest are byte-identical/unchanged (TestEmbeddedAssetsMatchSource green); scaffold.Run stays branch-free at the GazeCRAPload ceiling.

Closes #353

How to Test

Run the scaffold test suite:

go test -race -count=1 -short ./internal/scaffold/

The ownership behaviors are pinned by:

  • TestRun_OverwritesCustomizedGazeCommand — customized gaze.md restored without --force
  • TestRun_HealsDuplicateGazeCommandMarkers — dev + v1.8.0 duplicate markers healed to one current marker
  • TestRun_GazeLocalEscapeHatch — non-embedded commands/gaze-local.md never written, even under --force
  • TestRun_GazeCommandUpdateTip — tip prints only on update, not creation/skip/force
  • TestRun_SkipsExisting — plain re-run prints no --force hint
  • TestRun_CI_SkipIfPresent — the CI-workflow skip still prints the hint (its only surviving trigger)

Manual scenario: in a temp dir with a go.mod, run gaze init, edit .opencode/commands/gaze.md, re-run gaze init — the file is reported updated:, restored to the embedded copy with a single current marker, and the summary prints the gaze-local.md tip; a sibling commands/gaze-local.md is untouched.

Full CI parity (all green on the final tree): go build ./...; go test -race -count=1 -short -timeout 15m -coverprofile=coverage.out ./... (22/22 packages; cmd/gaze 79.0%, internal/scaffold 89.7% coverage); gaze dogfood thresholds (CRAPload 23/38, GazeCRAPload 6/6 at ceiling, AvgContractCoverage 39/8); golangci-lint run (0 issues); markdownlint on changed docs (0 issues); e2e TestRunSelfCheck (591.6s).

How to Demo

In a scratch project: gaze init → edit .opencode/commands/gaze.md → gaze init again. The summary reports updated: .opencode/commands/gaze.md (content changed) plus the one-line gaze-local.md tip, and the file is restored to the embedded asset with exactly one current version marker. A commands/gaze-local.md placed alongside is never touched — with or without --force.

Key Files Changed

 AGENTS.md                                                |   1 +
 docs/guides/opencode-integration.md                      |  38 +-
 docs/reference/cli/init.md                               |  26 +-
 internal/scaffold/ci_test.go                             |    7 +
 internal/scaffold/scaffold.go                            |   52 ++-
 internal/scaffold/scaffold_test.go                       |  517 +++++++++++--
 openspec/changes/gaze-command-tool-owned/.openspec.yaml  |    3 +
 openspec/changes/gaze-command-tool-owned/design.md       |  229 +
 openspec/changes/gaze-command-tool-owned/proposal.md     |  157 +
 .../specs/scaffold-file-ownership/spec.md                |   98 +
 openspec/changes/gaze-command-tool-owned/tasks.md        |  160 +
 11 files changed, 1230 insertions(+), 58 deletions(-)

Known Issues

Code review council returned APPROVE WITH ADVISORIES — 4 LOW advisories recorded for follow-up:

  • LOW — printSummary detects gaze.md updates via strings.TrimPrefix with filepath.Join separators but compares against the forward-slash literal commands/gaze.md; on Windows the relative path contains backslashes and never matches, so the escape-hatch tip (and the userSkipped count) misbehaves per-OS.
  • LOW — versionMarker embeds opts.Version verbatim into the <!-- scaffolded by gaze %s --> marker without sanitization; a custom-ldflags version containing --> or newlines could break the comment and inject Markdown into the scaffolded .md files.
  • LOW — TestRun_ReScaffoldNonForceSingleMarker exercises the multi-file version-bump path (the release-upgrade shape that motivated this change) but never asserts the escape-hatch tip printed; the tip requirement is pinned only by TestRun_GazeCommandUpdateTip's single-file-diff configuration.
  • LOW — The AGENTS.md Recent Changes entry overstates the re-scaffold test's assertion surface ("all nine files … carry the new single marker"): the test asserts 8 marker-bearing .md files carry the single new marker and that dcp.jsonc is skipped as byte-identical (it never carries an HTML marker).

Spec review council also returned APPROVE WITH ADVISORIES (all MEDIUM + LOW advisories remediated before code review).


This PR was generated by /uf.finale (AI-assisted).

…scape hatch)

commands/gaze.md was the only embedded .opencode/ asset on the
user-owned/skip-if-present side, which froze the flagship /gaze
command at whatever release first scaffolded it (issue unbound-force#353). A
10-repo consumer survey found zero customized copies; every observed
diff against the v2.4.0 asset was undelivered upstream change. All
nine embedded .opencode/ assets are now tool-owned, so the first
gaze init after upgrading delivers accumulated upstream changes and
heals the duplicate dev/v1.8.0 version markers; the CI workflow
remains the only user-owned scaffold output.

- Flip commands/gaze.md into the isToolOwned exact-match list
  (overwrite-on-diff without --force, like commands/gaze-fix.md)
- Escape hatch: a separately named commands/gaze-local.md is
  structurally never written, even under --force; OpenCode exposes
  it as /gaze-local
- printSummary prints a one-line tip naming the escape hatch only
  when gaze.md lands in Updated (never on creation, identical skip,
  or force-overwrite)
- Plain re-runs no longer print the --force hint (no user-owned
  .opencode/ file can be skipped); the CI-workflow skip keeps it,
  now pinned by a test
- Tests: isToolOwned table flip, customized-copy overwrite,
  duplicate-marker healing regression, escape-hatch byte-identity,
  tip-printing matrix, restructured re-scaffold coverage
- Docs: docs/guides/opencode-integration.md, docs/reference/cli/init.md,
  AGENTS.md Recent Changes; website docs issue unbound-force/website#425

File Sync Invariants untouched: no asset content changed; the
nine-file manifest and embedded-mirror byte-identity hold
(TestEmbeddedAssetsMatchSource green).

Closes unbound-force#353

Assisted-by: glm-5
Generated with AI assistance (glm-5)

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Council Review: #356 — gaze init treats commands/gaze.md as tool-owned

Council verdict: APPROVE WITH ADVISORIES — posted as APPROVE (no CRITICAL or HIGH findings).

Council Panel

Persona Verdict
divisor-adversary APPROVE
divisor-architect APPROVE
divisor-curator APPROVE
divisor-entropy APPROVE
divisor-gaze-testing APPROVE
divisor-guard APPROVE
divisor-testing APPROVE WITH ADVISORIES (2 LOW)

Assessment

gaze init now classifies commands/gaze.md as tool-owned (issue #353): overwrite-on-diff without --force, duplicate-marker healing via the wholesale rewrite, a structurally untouchable commands/gaze-local.md escape hatch, and an update-time tip gated on Updated only. The implementation adds one isToolOwned list entry and moves tip detection into printSummary, keeping Run branch-free at the dogfood GazeCRAPload ceiling. All spec scenarios are pinned by dedicated regression tests, File Sync Invariants are untouched, and all 6 CI checks pass including the dogfood thresholds (38/6/8).

Advisories (2 LOW — both already recorded in the PR body Known Issues for follow-up)

  1. LOW (test-coverage) — internal/scaffold/scaffold.go:841: the tip detection compares the forward-slash literal "commands/gaze.md" against a path trimmed using filepath.Separator; on Windows the comparison never matches (tip does not print, userSkipped over-counts). Gaze ships no Windows binaries and the CI matrix is Linux-only, which is why this is LOW. If Windows support is added, normalize separators before comparison or add a platform-matrix test.
  2. LOW (test-coverage) — internal/scaffold/scaffold_test.go:1527: TestRun_ReScaffoldNonForceSingleMarker drives the production-realistic multi-file version-bump path but never asserts the escape-hatch tip printed; the tip matrix (TestRun_GazeCommandUpdateTip) covers only the single-file-update case. The gating flag is set inside the same Result.Updated loop in both cases, so logical risk stays low.

Details are attached as inline comments. No CRITICAL or HIGH findings; no PR-caused CI failures.

This review was generated by /uf.review-pr (AI-assisted).

var gazeCmdUpdated bool
for _, f := range r.Updated {
_, _ = fmt.Fprintf(w, " updated: %s (content changed)\n", f)
rel := strings.TrimPrefix(f, filepath.Join(".opencode")+string(filepath.Separator))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tip detection compares the forward-slash literal "commands/gaze.md" against a path trimmed using filepath.Separator (scaffold.go:841-842), replicating the pre-existing userSkipped idiom (lines 861-862). On a Windows filesystem the trimmed rel path uses backslashes, so the comparison never matches: the tip does not print and userSkipped over-counts. TestRun_GazeCommandUpdateTip "prints on update" locks down the correct behavior and would fail on Windows, but the CI matrix runs Linux only and gaze ships no Windows binaries, so the divergence is never exercised by any test execution. LOW severity for exactly that reason — this confirms the advisory already recorded in the PR body Known Issues. If Windows support is ever added, normalize separators before comparison or add a platform-matrix test.

// non-force re-run: the eight Markdown files were updated on
// diff, commands/gaze.md included (the pre-flip user-owned
// exception), and the byte-identical dcp.jsonc was skipped.
if len(result.Updated) != 8 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestRun_ReScaffoldNonForceSingleMarker drives the production-realistic multi-file version-bump path — the exact scenario the #353 survey shows is how consumers actually receive updates (8 files updated on diff, commands/gaze.md among them, dcp.jsonc skipped) — but never asserts that the escape-hatch tip printed in buf2's output. The tip matrix (TestRun_GazeCommandUpdateTip, line 977) covers the tip only in the single-file-update case (Updated == 1). The gating flag is set inside the same Result.Updated loop in both cases, so the logical risk stays low. The one assertion that would tie the multi-file path to the tip contract is absent — this confirms the advisory already listed in the PR body Known Issues; no new work is required beyond the planned follow-up.

@jflowers
jflowers merged commit 0f980fd into unbound-force:main Nov 16, 2026
6 checks passed
@jflowers
jflowers deleted the opsx/gaze-command-tool-owned branch November 23, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gaze init never updates commands/gaze.md, so /gaze goes stale on every release

2 participants