Skip to content

gaze init appends a second version marker instead of replacing the existing one #279

Closed

Description

@jflowers

Problem

insertMarkerAfterFrontmatter (internal/scaffold/scaffold.go:111) unconditionally inserts <!-- scaffolded by gaze <version> --> after the YAML frontmatter. It never checks for or removes an existing <!-- scaffolded by gaze ... --> marker, so running gaze init again with a different build leaves BOTH markers in the file.

Repro

  1. gaze init with a dev build → files get <!-- scaffolded by gaze dev -->.
  2. gaze init (or --force) with a v1.8.0 build → files get <!-- scaffolded by gaze v1.8.0 --> inserted next to the dev marker instead of replacing it.

Evidence

snake-eyes .opencode/ scaffolded files (gaze-test-generator.md, gaze-fix.md, speckit.testreview.md, references/doc-scoring-model.md, references/example-report.md) each contain both <!-- scaffolded by gaze dev --> and <!-- scaffolded by gaze v1.8.0 -->.

Suggested fix

In insertMarkerAfterFrontmatter (or a pre-pass in Run), detect an existing <!-- scaffolded by gaze ... --> line and replace it in place instead of inserting a new one. Add a regression test that re-scaffolds over an already-scaffolded file and asserts exactly one marker remains.

Activity

  1. added
    bug
    on Sep 23, 2026
  2. fullsend-ai-triage commented on Sep 23, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 8:19 PM UTC · Completed 8:23 PM UTC

    Commit: 6075877 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $0.91

  3. added
    good first issue
    ready-to-code
    on Sep 23, 2026
  4. fullsend-ai-triage commented on Sep 23, 2026

    @fullsend-ai-triage

    Proposed test case

    func TestInsertMarkerAfterFrontmatter_ReplacesExistingMarker(t *testing.T) {
    	content := []byte("---\ntitle: test\n---\n<!-- scaffolded by gaze dev -->\n# Agent\n")
    	newMarker := "<!-- scaffolded by gaze v1.8.0 -->\n"
    
    	result := insertMarkerAfterFrontmatter(content, newMarker)
    
    	count := strings.Count(string(result), "<!-- scaffolded by gaze")
    	if count != 1 {
    		t.Errorf("expected exactly 1 marker, got %d", count)
    	}
    	if !strings.Contains(string(result), "v1.8.0") {
    		t.Error("expected new version marker, not found")
    	}
    	if strings.Contains(string(result), "gaze dev") {
    		t.Error("old marker should have been replaced")
    	}
    }

    Related context

    The handleToolOwnedFile path already compares content via bytes.Equal and overwrites on diff — but by the time it compares, the new content already has the new marker appended (without removing the old one from the existing file content read from disk). The fix belongs in insertMarkerAfterFrontmatter itself so that both the tool-owned overwrite path and the --force path produce clean single-marker output.


    Labels: Bug label already applied; adding good-first-issue since the fix is well-scoped to a single function with a clear suggested approach.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  5. fullsend-ai-coder commented on Sep 23, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 8:24 PM UTC · Completed 8:31 PM UTC

    Commit: 6075877 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.62

  6. added 5 commits that reference this issue on Oct 23, 2026
  7. added a commit that references this issue on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueready-to-code

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions