diff --git a/.gitignore b/.gitignore
index 95272ef..1480bb3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,6 @@ todos/
# test artefacts
/tmp/
+
+# fixture files that intentionally resemble secrets/env files
+!test/fixtures/golden-repo/.env.example
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 827ac61..a82685f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -41,6 +41,27 @@ bats test/*.bats # all tests
bats test/smoosh_args.bats # specific file
```
+## Golden File Tests
+
+The golden file suite (`test/smoosh_golden.bats`) verifies that smoosh output
+is byte-for-byte correct across all modes, formats, and feature combinations.
+
+If you intentionally change smoosh's output format (for example, adding a new
+header field or changing the section separator), regenerate the expected files:
+
+```bash
+UPDATE_GOLDEN=1 bats test/smoosh_golden.bats
+```
+
+Then review the diff to confirm the changes are intentional before committing:
+
+```bash
+git diff test/golden/
+```
+
+The golden files live in `test/golden/expected/`. Never edit them by hand —
+always use `UPDATE_GOLDEN=1` to regenerate them from a passing smoosh run.
+
## Updating the Demos
The demos are recorded with [VHS](https://github.com/charmbracelet/vhs)
diff --git a/README.md b/README.md
index 9ad2c4a..bc28528 100644
--- a/README.md
+++ b/README.md
@@ -323,7 +323,7 @@ smoosh counts words using `wc -w`, which splits on whitespace. Code files
with dense syntax (JSON, minified JS) count differently than prose.
**Is it overengineered for a shell script?**
-Absolutely. 198 tests, 100% file inclusion verification, CDATA escaping for
+Absolutely. 228 tests, 100% file inclusion verification, CDATA escaping for
XML output, and a box-drawing letter logo. But your codebase deserves to be
smooshed properly.
diff --git a/smoosh b/smoosh
index 9bfc078..eea56f9 100755
--- a/smoosh
+++ b/smoosh
@@ -898,8 +898,13 @@ write_chunk_footer() {
# add_line_numbers FILE
# Print file content to stdout with right-aligned line numbers.
+# Captures via $() to strip trailing newlines — GNU nl adds one for files
+# that lack it; BSD nl preserves the original. printf '%s' ensures consistent
+# output on both, and the caller's printf '\n' adds exactly one.
add_line_numbers() {
- nl -ba -nrz -w4 -s' | ' -- "${1}" 2>/dev/null || cat -- "${1}"
+ local numbered
+ numbered="$(nl -ba -nrz -w4 -s' | ' -- "${1}" 2>/dev/null || cat -- "${1}")"
+ printf '%s' "${numbered}"
}
# write_file_entry FD REL_PATH
@@ -929,9 +934,10 @@ write_file_entry() {
add_line_numbers "${abs_path}" |
sed 's/]]>/]]]]>/g' >&"${fd}"
else
- # Group sed+fallback so only one redirect is applied to the combined stdout.
- { sed 's/]]>/]]]]>/g' -- "${abs_path}" 2>/dev/null ||
- cat -- "${abs_path}"; } >&"${fd}"
+ # Pipe through sed rather than sed -- file: BSD sed does not support --
+ # as end-of-options (it treats it as a literal filename, causing doubled
+ # output via the || fallback).
+ cat -- "${abs_path}" | sed 's/]]>/]]]]>/g' >&"${fd}"
fi
elif [[ "${LINE_NUMBERS}" == "true" ]]; then
add_line_numbers "${abs_path}" >&"${fd}"
diff --git a/test/ACCEPTANCE.md b/test/ACCEPTANCE.md
new file mode 100644
index 0000000..0cd070f
--- /dev/null
+++ b/test/ACCEPTANCE.md
@@ -0,0 +1,265 @@
+# smoosh Acceptance Test Runbook
+
+This document describes the manual acceptance tests for smoosh. Run these
+before any major release or when the automated tests are insufficient to
+verify a change — for example, when interactive mode, network behaviour, or
+AI tool integration is involved.
+
+All automated tests can be run with `bats test/*.bats`. The scenarios below
+cover what cannot be automated: interactive TTY behaviour and end-to-end
+upload flows with real AI tools.
+
+---
+
+## Setup
+
+Install smoosh or build from source:
+
+ brew install K1-R1/tap/smoosh # installed release
+ # or
+ ./smoosh --version # local dev build (run from repo root)
+
+Pick a real git repository to test against — the smoosh repo itself works
+well. All examples below use `.` for the current directory.
+
+---
+
+## 1. Interactive Mode
+
+smoosh opens an interactive guided experience when called with no arguments
+in a real terminal (TTY).
+
+**Steps:**
+
+1. Open a terminal (not inside a script or pipe).
+2. Change into any git repository: `cd /path/to/some/repo`
+3. Run `smoosh` with no arguments.
+
+**Expected behaviour:**
+
+- The logo and tagline appear.
+- smoosh scans the repo and shows a summary table: docs, code, config, and
+ other file counts with example extensions.
+- A prompt asks which mode to use (`docs`, `code`, `all`, or `q` to quit).
+- After selecting a mode, smoosh processes and writes output to `_smooshes/`.
+- A summary table shows file count, word count, token estimate, and chunk count.
+
+**Pass criteria:**
+
+- [ ] Interactive prompt appears (not skipped)
+- [ ] Repo scan table shows plausible file counts
+- [ ] Selecting `docs` produces `.md` output files
+- [ ] Output lands in `_smooshes/`
+- [ ] No error messages or stack traces
+
+---
+
+## 2. Remote Repository
+
+smoosh can clone and process a remote repo in a single command.
+
+**Steps:**
+
+ smoosh https://github.com/K1-R1/smoosh
+
+**Expected behaviour:**
+
+- smoosh clones the repo to a temp directory.
+- Processes it in docs mode (default).
+- Writes output to `_smooshes/` in the current directory (not inside the
+ clone).
+- Cleans up the temp clone on exit.
+
+**Pass criteria:**
+
+- [ ] Clone succeeds (no "Remote clone failed" error)
+- [ ] Output files appear in `_smooshes/` of the working directory
+- [ ] Output contains smoosh's own `README.md` content
+- [ ] Temp clone is removed after the run
+
+---
+
+## 3. NotebookLM Upload
+
+Verify that smoosh output can be uploaded to NotebookLM and queried.
+
+**Steps:**
+
+1. Run smoosh on a real codebase:
+
+ cd /path/to/some/repo
+ smoosh --code
+
+2. Go to [notebooklm.google.com](https://notebooklm.google.com) and create
+ a new notebook.
+3. Click **Add source → Upload file**.
+4. Upload each `.md` file from `_smooshes/`.
+5. Wait for processing (usually 30–60 seconds).
+6. Ask a question that can only be answered with the uploaded content, for
+ example:
+ - "What functions are defined in this codebase?"
+ - "What does the main entry point do?"
+ - "List all the files included in this upload."
+
+**Pass criteria:**
+
+- [ ] Upload succeeds (no error from NotebookLM)
+- [ ] NotebookLM answers questions using specific file content (cites sources)
+- [ ] Answer is not a hallucination (verifiable against the actual code)
+- [ ] Word count per file is within NotebookLM's 500,000-word limit per source
+
+**NotebookLM plan limits (early 2026):**
+
+| Plan | Max sources | Max words/source |
+|-------|-------------|------------------|
+| Free | 50 | 500,000 |
+| Plus | 300 | 500,000 |
+| Ultra | 600 | 500,000 |
+
+---
+
+## 4. Claude Projects Upload
+
+Verify that smoosh output can be added to a Claude Project and queried.
+
+**Steps:**
+
+1. Run smoosh:
+
+ smoosh --code
+
+2. Go to [claude.ai](https://claude.ai) and open or create a Project.
+3. Open the project knowledge panel.
+4. Upload the files from `_smooshes/`.
+5. Start a conversation and ask a code-specific question, for example:
+ - "What language is the main entry point written in?"
+ - "Are there any tests in this codebase?"
+
+**Pass criteria:**
+
+- [ ] Upload succeeds
+- [ ] Claude answers using specific content from the uploaded files
+- [ ] Claude does not claim it cannot access the files
+
+---
+
+## 5. ChatGPT Upload
+
+Verify that smoosh output can be attached to a ChatGPT conversation.
+
+**Steps:**
+
+1. Run smoosh:
+
+ smoosh --code
+
+2. Open [chatgpt.com](https://chatgpt.com) and start a new conversation.
+3. Attach the files from `_smooshes/` using the paperclip icon.
+4. Ask a specific question about the uploaded codebase.
+
+**Pass criteria:**
+
+- [ ] Files attach without errors
+- [ ] ChatGPT answers using content from the uploaded files
+- [ ] For repos with multiple chunks: all chunks can be attached
+
+---
+
+## 6. Secrets Detection
+
+Verify that secrets are flagged and excluded from output.
+
+**Steps:**
+
+1. Create a temporary test repo:
+
+ mkdir /tmp/secrets-test && cd /tmp/secrets-test
+ git init && git config user.email "t@t.com" && git config user.name "T"
+ echo '# Docs' > README.md
+ echo 'AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"' > creds.py
+ git add -A && git commit -m "init"
+
+2. Run smoosh:
+
+ smoosh --code .
+
+**Expected behaviour:**
+
+- smoosh prints a secrets warning mentioning `creds.py`.
+- The warning includes a disclaimer ("basic pattern matching only").
+- `creds.py` does not appear in the output files.
+- `README.md` appears in the output files.
+- Exit code is 0 (secrets detected is a warning, not a failure).
+
+**Pass criteria:**
+
+- [ ] Warning appears on stderr
+- [ ] `creds.py` content is absent from `_smooshes/` output
+- [ ] `README.md` content is present in `_smooshes/` output
+- [ ] Exit code is 0
+
+---
+
+## 7. Agent / CI Usage
+
+Verify that smoosh works in a headless, non-interactive environment.
+
+**Steps:**
+
+ smoosh --code --no-interactive --json --quiet . 2>/dev/null
+
+**Expected behaviour:** an error — `--json` and `--quiet` cannot be combined.
+
+Then:
+
+ smoosh --code --no-interactive --json . 2>/dev/null | jq .
+
+**Expected behaviour:**
+
+- Valid JSON is printed to stdout.
+- JSON includes `repo`, `files_processed`, `total_words`, `chunks`, and
+ `exit_code` fields.
+- Exit code is 0.
+
+**Pass criteria:**
+
+- [ ] `--json` and `--quiet` together print an error and exit 1
+- [ ] `--json` alone produces valid, parseable JSON
+- [ ] `exit_code` in JSON matches the actual process exit code
+
+---
+
+## 8. Regression: Golden File Tests
+
+The automated golden file tests (run as part of `bats test/*.bats`) verify
+that smoosh output is byte-for-byte identical to the checked-in expected
+files. Run them to confirm no regressions:
+
+ bats test/smoosh_golden.bats
+
+All 30 tests should pass.
+
+If you intentionally change smoosh's output format (for example, adding a
+new header field), regenerate the golden files:
+
+ UPDATE_GOLDEN=1 bats test/smoosh_golden.bats
+
+Then review `git diff test/golden/` to confirm the changes are intentional
+before committing.
+
+---
+
+## Completing a Release Acceptance Run
+
+Tick every checkbox above, then record the result:
+
+| Scenario | Result | Notes |
+|----------|--------|-------|
+| 1. Interactive mode | Pass / Fail | |
+| 2. Remote repository | Pass / Fail | |
+| 3. NotebookLM upload | Pass / Fail | |
+| 4. Claude Projects upload | Pass / Fail | |
+| 5. ChatGPT upload | Pass / Fail | |
+| 6. Secrets detection | Pass / Fail | |
+| 7. Agent / CI usage | Pass / Fail | |
+| 8. Golden file tests | Pass / Fail | |
diff --git a/test/fixtures/golden-repo/.env.example b/test/fixtures/golden-repo/.env.example
new file mode 100644
index 0000000..17535e8
--- /dev/null
+++ b/test/fixtures/golden-repo/.env.example
@@ -0,0 +1,3 @@
+DATABASE_URL=postgres://localhost:5432/mydb
+SECRET_KEY=your-secret-key-here
+DEBUG=false
diff --git a/test/fixtures/golden-repo/.github/ci.yml b/test/fixtures/golden-repo/.github/ci.yml
new file mode 100644
index 0000000..5b8caa4
--- /dev/null
+++ b/test/fixtures/golden-repo/.github/ci.yml
@@ -0,0 +1,8 @@
+name: CI
+on: [push, pull_request]
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - run: echo "Golden fixture CI workflow"
diff --git a/test/fixtures/golden-repo/Makefile b/test/fixtures/golden-repo/Makefile
new file mode 100644
index 0000000..b0eb533
--- /dev/null
+++ b/test/fixtures/golden-repo/Makefile
@@ -0,0 +1,7 @@
+.PHONY: all clean
+
+all:
+ @echo "Golden fixture Makefile"
+
+clean:
+ @echo "Nothing to clean"
diff --git a/test/fixtures/golden-repo/README.md b/test/fixtures/golden-repo/README.md
new file mode 100644
index 0000000..a2c2777
--- /dev/null
+++ b/test/fixtures/golden-repo/README.md
@@ -0,0 +1,4 @@
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
diff --git a/test/fixtures/golden-repo/app.py b/test/fixtures/golden-repo/app.py
new file mode 100644
index 0000000..c3e98b9
--- /dev/null
+++ b/test/fixtures/golden-repo/app.py
@@ -0,0 +1,11 @@
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
diff --git a/test/fixtures/golden-repo/aws-creds.py b/test/fixtures/golden-repo/aws-creds.py
new file mode 100644
index 0000000..f0718ce
--- /dev/null
+++ b/test/fixtures/golden-repo/aws-creds.py
@@ -0,0 +1,4 @@
+# Golden fixture secrets file.
+# This file contains a fake AWS key for secrets detection testing.
+AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"
+AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
diff --git a/test/fixtures/golden-repo/cdata-break.md b/test/fixtures/golden-repo/cdata-break.md
new file mode 100644
index 0000000..a71dbef
--- /dev/null
+++ b/test/fixtures/golden-repo/cdata-break.md
@@ -0,0 +1,4 @@
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
diff --git a/test/fixtures/golden-repo/deep/nested/path/doc.md b/test/fixtures/golden-repo/deep/nested/path/doc.md
new file mode 100644
index 0000000..c345958
--- /dev/null
+++ b/test/fixtures/golden-repo/deep/nested/path/doc.md
@@ -0,0 +1,4 @@
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
diff --git a/test/fixtures/golden-repo/empty.md b/test/fixtures/golden-repo/empty.md
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/golden-repo/guide.rst b/test/fixtures/golden-repo/guide.rst
new file mode 100644
index 0000000..03a5d29
--- /dev/null
+++ b/test/fixtures/golden-repo/guide.rst
@@ -0,0 +1,5 @@
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
diff --git a/test/fixtures/golden-repo/index.js b/test/fixtures/golden-repo/index.js
new file mode 100644
index 0000000..90e3dbc
--- /dev/null
+++ b/test/fixtures/golden-repo/index.js
@@ -0,0 +1,9 @@
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
diff --git a/test/fixtures/golden-repo/it's-fine.md b/test/fixtures/golden-repo/it's-fine.md
new file mode 100644
index 0000000..265c4d3
--- /dev/null
+++ b/test/fixtures/golden-repo/it's-fine.md
@@ -0,0 +1,4 @@
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
diff --git a/test/fixtures/golden-repo/journal.org b/test/fixtures/golden-repo/journal.org
new file mode 100644
index 0000000..f91e9ff
--- /dev/null
+++ b/test/fixtures/golden-repo/journal.org
@@ -0,0 +1,7 @@
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
diff --git a/test/fixtures/golden-repo/logo.png b/test/fixtures/golden-repo/logo.png
new file mode 100644
index 0000000..0dd1608
--- /dev/null
+++ b/test/fixtures/golden-repo/logo.png
@@ -0,0 +1,2 @@
+‰PNG
+
diff --git a/test/fixtures/golden-repo/main.go b/test/fixtures/golden-repo/main.go
new file mode 100644
index 0000000..c692b02
--- /dev/null
+++ b/test/fixtures/golden-repo/main.go
@@ -0,0 +1,12 @@
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
diff --git a/test/fixtures/golden-repo/manual.adoc b/test/fixtures/golden-repo/manual.adoc
new file mode 100644
index 0000000..18e720c
--- /dev/null
+++ b/test/fixtures/golden-repo/manual.adoc
@@ -0,0 +1,5 @@
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
diff --git a/test/fixtures/golden-repo/my notes.md b/test/fixtures/golden-repo/my notes.md
new file mode 100644
index 0000000..8486737
--- /dev/null
+++ b/test/fixtures/golden-repo/my notes.md
@@ -0,0 +1,3 @@
+# My Notes
+
+This file name contains a space to test path handling.
diff --git a/test/fixtures/golden-repo/no-newline.md b/test/fixtures/golden-repo/no-newline.md
new file mode 100644
index 0000000..56d2633
--- /dev/null
+++ b/test/fixtures/golden-repo/no-newline.md
@@ -0,0 +1 @@
+This file has no trailing newline at the end.
\ No newline at end of file
diff --git a/test/fixtures/golden-repo/notes.txt b/test/fixtures/golden-repo/notes.txt
new file mode 100644
index 0000000..7326c96
--- /dev/null
+++ b/test/fixtures/golden-repo/notes.txt
@@ -0,0 +1,4 @@
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
diff --git a/test/fixtures/golden-repo/package.json b/test/fixtures/golden-repo/package.json
new file mode 100644
index 0000000..0180bc4
--- /dev/null
+++ b/test/fixtures/golden-repo/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
diff --git a/test/fixtures/golden-repo/paper.tex b/test/fixtures/golden-repo/paper.tex
new file mode 100644
index 0000000..99fae23
--- /dev/null
+++ b/test/fixtures/golden-repo/paper.tex
@@ -0,0 +1,6 @@
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/fixtures/golden-repo/src/lib.rs b/test/fixtures/golden-repo/src/lib.rs
new file mode 100644
index 0000000..d793aa7
--- /dev/null
+++ b/test/fixtures/golden-repo/src/lib.rs
@@ -0,0 +1,9 @@
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/all-md.golden b/test/golden/expected/all-md.golden
new file mode 100644
index 0000000..9a50298
--- /dev/null
+++ b/test/golden/expected/all-md.golden
@@ -0,0 +1,227 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: Makefile
+---
+
+.PHONY: all clean
+
+all:
+ @echo "Golden fixture Makefile"
+
+clean:
+ @echo "Nothing to clean"
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/chunked-json.golden b/test/golden/expected/chunked-json.golden
new file mode 100644
index 0000000..216a1ef
--- /dev/null
+++ b/test/golden/expected/chunked-json.golden
@@ -0,0 +1,15 @@
+{
+ "repo": "golden-repo",
+ "output_dir": "OUTPUT_DIR",
+ "files_processed": 12,
+ "total_words": 313,
+ "estimated_tokens": 406,
+ "verified": true,
+ "secrets_excluded": [],
+ "chunks": [
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 131},
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part2.md", "words": 126},
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part3.md", "words": 56}
+ ],
+ "exit_code": 0
+}
diff --git a/test/golden/expected/chunked-md.golden b/test/golden/expected/chunked-md.golden
new file mode 100644
index 0000000..4c185e2
--- /dev/null
+++ b/test/golden/expected/chunked-md.golden
@@ -0,0 +1,139 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+--- CHUNK BOUNDARY ---
+# Repository Compilation: golden-repo (Part 2)
+Generated: TIMESTAMP
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+--- CHUNK BOUNDARY ---
+# Repository Compilation: golden-repo (Part 3)
+Generated: TIMESTAMP
+
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/chunked-quiet.golden b/test/golden/expected/chunked-quiet.golden
new file mode 100644
index 0000000..338c01f
--- /dev/null
+++ b/test/golden/expected/chunked-quiet.golden
@@ -0,0 +1,3 @@
+OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md
+OUTPUT_DIR/TIMESTAMP_golden-repo_part2.md
+OUTPUT_DIR/TIMESTAMP_golden-repo_part3.md
diff --git a/test/golden/expected/chunked-text.golden b/test/golden/expected/chunked-text.golden
new file mode 100644
index 0000000..c1eb733
--- /dev/null
+++ b/test/golden/expected/chunked-text.golden
@@ -0,0 +1,142 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: README.md
+============================================================
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+--- CHUNK BOUNDARY ---
+Repository Compilation: golden-repo (Part 2)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: my notes.md
+============================================================
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+This file has no trailing newline at the end.
+--- CHUNK BOUNDARY ---
+Repository Compilation: golden-repo (Part 3)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: notes.txt
+============================================================
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/chunked-xml.golden b/test/golden/expected/chunked-xml.golden
new file mode 100644
index 0000000..f001e23
--- /dev/null
+++ b/test/golden/expected/chunked-xml.golden
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+ which breaks CDATA sections.
+The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+--- CHUNK BOUNDARY ---
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+--- CHUNK BOUNDARY ---
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/code-json.golden b/test/golden/expected/code-json.golden
new file mode 100644
index 0000000..6d444c4
--- /dev/null
+++ b/test/golden/expected/code-json.golden
@@ -0,0 +1,13 @@
+{
+ "repo": "golden-repo",
+ "output_dir": "OUTPUT_DIR",
+ "files_processed": 17,
+ "total_words": 437,
+ "estimated_tokens": 568,
+ "verified": true,
+ "secrets_excluded": ["aws-creds.py"],
+ "chunks": [
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 437}
+ ],
+ "exit_code": 0
+}
diff --git a/test/golden/expected/code-md.golden b/test/golden/expected/code-md.golden
new file mode 100644
index 0000000..3847d86
--- /dev/null
+++ b/test/golden/expected/code-md.golden
@@ -0,0 +1,213 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/code-xml-toc.golden b/test/golden/expected/code-xml-toc.golden
new file mode 100644
index 0000000..a10f548
--- /dev/null
+++ b/test/golden/expected/code-xml-toc.golden
@@ -0,0 +1,183 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ which breaks CDATA sections.
+The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
+
+]]>
+
+
diff --git a/test/golden/expected/docs-md-line-numbers.golden b/test/golden/expected/docs-md-line-numbers.golden
new file mode 100644
index 0000000..54cb4e1
--- /dev/null
+++ b/test/golden/expected/docs-md-line-numbers.golden
@@ -0,0 +1,123 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+---
+### File: cdata-break.md
+---
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+---
+### File: it's-fine.md
+---
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+---
+### File: journal.org
+---
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+---
+### File: manual.adoc
+---
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+---
+### File: my notes.md
+---
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+---
+### File: no-newline.md
+---
+
+0001 | This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+---
+### File: paper.tex
+---
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-md-toc-line-numbers.golden b/test/golden/expected/docs-md-toc-line-numbers.golden
new file mode 100644
index 0000000..e9972e0
--- /dev/null
+++ b/test/golden/expected/docs-md-toc-line-numbers.golden
@@ -0,0 +1,142 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+## Table of Contents
+
+| # | File | Words |
+|---|------|-------|
+| 1 | README.md | 21 |
+| 2 | cdata-break.md | 25 |
+| 3 | deep/nested/path/doc.md | 27 |
+| 4 | empty.md | 0 |
+| 5 | guide.rst | 24 |
+| 6 | it's-fine.md | 16 |
+| 7 | journal.org | 24 |
+| 8 | manual.adoc | 29 |
+| 9 | my notes.md | 13 |
+| 10 | no-newline.md | 9 |
+| 11 | notes.txt | 22 |
+| 12 | paper.tex | 15 |
+| **Total** | **12 files** | **225** |
+
+
+
+---
+### File: README.md
+---
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+---
+### File: cdata-break.md
+---
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+---
+### File: it's-fine.md
+---
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+---
+### File: journal.org
+---
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+---
+### File: manual.adoc
+---
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+---
+### File: my notes.md
+---
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+---
+### File: no-newline.md
+---
+
+0001 | This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+---
+### File: paper.tex
+---
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-md-toc.golden b/test/golden/expected/docs-md-toc.golden
new file mode 100644
index 0000000..a923251
--- /dev/null
+++ b/test/golden/expected/docs-md-toc.golden
@@ -0,0 +1,151 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+## Table of Contents
+
+| # | File | Words |
+|---|------|-------|
+| 1 | README.md | 21 |
+| 2 | cdata-break.md | 25 |
+| 3 | deep/nested/path/doc.md | 27 |
+| 4 | empty.md | 0 |
+| 5 | guide.rst | 24 |
+| 6 | it's-fine.md | 16 |
+| 7 | journal.org | 24 |
+| 8 | manual.adoc | 29 |
+| 9 | my notes.md | 13 |
+| 10 | no-newline.md | 9 |
+| 11 | notes.txt | 22 |
+| 12 | paper.tex | 15 |
+| **Total** | **12 files** | **225** |
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-md.golden b/test/golden/expected/docs-md.golden
new file mode 100644
index 0000000..406476f
--- /dev/null
+++ b/test/golden/expected/docs-md.golden
@@ -0,0 +1,132 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-text-line-numbers.golden b/test/golden/expected/docs-text-line-numbers.golden
new file mode 100644
index 0000000..640cfb7
--- /dev/null
+++ b/test/golden/expected/docs-text-line-numbers.golden
@@ -0,0 +1,124 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: README.md
+============================================================
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+============================================================
+File: journal.org
+============================================================
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+============================================================
+File: my notes.md
+============================================================
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+0001 | This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+============================================================
+File: paper.tex
+============================================================
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-text-toc-line-numbers.golden b/test/golden/expected/docs-text-toc-line-numbers.golden
new file mode 100644
index 0000000..d34d84a
--- /dev/null
+++ b/test/golden/expected/docs-text-toc-line-numbers.golden
@@ -0,0 +1,143 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+Table of Contents
+------------------------------------------------------------
+
+ 1 README.md 21 words
+ 2 cdata-break.md 25 words
+ 3 deep/nested/path/doc.md 27 words
+ 4 empty.md 0 words
+ 5 guide.rst 24 words
+ 6 it's-fine.md 16 words
+ 7 journal.org 24 words
+ 8 manual.adoc 29 words
+ 9 my notes.md 13 words
+ 10 no-newline.md 9 words
+ 11 notes.txt 22 words
+ 12 paper.tex 15 words
+
+ Total: 12 files, 225 words
+
+
+
+============================================================
+File: README.md
+============================================================
+
+0001 | # Golden Repo
+0002 |
+0003 | This is the readme for the golden test fixture repository.
+0004 | It contains files that exercise every smoosh capability.
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+0001 | # CDATA Edge Case
+0002 |
+0003 | This file contains the sequence ]]> which breaks CDATA sections.
+0004 | The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+0001 | # Deeply Nested Document
+0002 |
+0003 | This document lives at a deeply nested path to test path handling.
+0004 | smoosh should include this file with its full relative path preserved.
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+0001 | User Guide
+0002 | ==========
+0003 |
+0004 | This guide covers the basic usage of the golden fixture project.
+0005 | See the readme for an overview of the project structure.
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+0001 | # It's Fine
+0002 |
+0003 | This file's name contains an apostrophe.
+0004 | It tests filename quoting in shell pipelines.
+
+
+============================================================
+File: journal.org
+============================================================
+
+0001 | #+TITLE: Project Journal
+0002 | #+DATE: 2026-01-01
+0003 |
+0004 | * Overview
+0005 |
+0006 | This org file documents the golden fixture project history.
+0007 | Each entry records a notable event during development.
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+0001 | = Technical Manual
+0002 | :doctype: article
+0003 |
+0004 | This manual describes the technical details of the golden fixture project.
+0005 | Refer to the guide for usage instructions and the readme for an overview.
+
+
+============================================================
+File: my notes.md
+============================================================
+
+0001 | # My Notes
+0002 |
+0003 | This file name contains a space to test path handling.
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+0001 | This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+0001 | Release notes for golden fixture project.
+0002 |
+0003 | Version one introduces the initial set of fixture files.
+0004 | These files exercise smoosh output format correctness.
+
+
+============================================================
+File: paper.tex
+============================================================
+
+0001 | \documentclass{article}
+0002 | \title{Golden Fixture Paper}
+0003 | \begin{document}
+0004 | \maketitle
+0005 | This paper describes the golden fixture test repository.
+0006 | \end{document}
diff --git a/test/golden/expected/docs-text-toc.golden b/test/golden/expected/docs-text-toc.golden
new file mode 100644
index 0000000..ef9a904
--- /dev/null
+++ b/test/golden/expected/docs-text-toc.golden
@@ -0,0 +1,152 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+Table of Contents
+------------------------------------------------------------
+
+ 1 README.md 21 words
+ 2 cdata-break.md 25 words
+ 3 deep/nested/path/doc.md 27 words
+ 4 empty.md 0 words
+ 5 guide.rst 24 words
+ 6 it's-fine.md 16 words
+ 7 journal.org 24 words
+ 8 manual.adoc 29 words
+ 9 my notes.md 13 words
+ 10 no-newline.md 9 words
+ 11 notes.txt 22 words
+ 12 paper.tex 15 words
+
+ Total: 12 files, 225 words
+
+
+
+============================================================
+File: README.md
+============================================================
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: my notes.md
+============================================================
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-text.golden b/test/golden/expected/docs-text.golden
new file mode 100644
index 0000000..3a98a02
--- /dev/null
+++ b/test/golden/expected/docs-text.golden
@@ -0,0 +1,133 @@
+Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+============================================================
+
+
+
+============================================================
+File: README.md
+============================================================
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+============================================================
+File: cdata-break.md
+============================================================
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+============================================================
+File: deep/nested/path/doc.md
+============================================================
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+============================================================
+File: empty.md
+============================================================
+
+
+
+
+============================================================
+File: guide.rst
+============================================================
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+============================================================
+File: it's-fine.md
+============================================================
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+============================================================
+File: journal.org
+============================================================
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+============================================================
+File: manual.adoc
+============================================================
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+============================================================
+File: my notes.md
+============================================================
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+============================================================
+File: no-newline.md
+============================================================
+
+This file has no trailing newline at the end.
+
+
+============================================================
+File: notes.txt
+============================================================
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+============================================================
+File: paper.tex
+============================================================
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/docs-xml-line-numbers.golden b/test/golden/expected/docs-xml-line-numbers.golden
new file mode 100644
index 0000000..b1539cd
--- /dev/null
+++ b/test/golden/expected/docs-xml-line-numbers.golden
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+ which breaks CDATA sections.
+0004 | The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/docs-xml-toc-line-numbers.golden b/test/golden/expected/docs-xml-toc-line-numbers.golden
new file mode 100644
index 0000000..e759c68
--- /dev/null
+++ b/test/golden/expected/docs-xml-toc-line-numbers.golden
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ which breaks CDATA sections.
+0004 | The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/docs-xml.golden b/test/golden/expected/docs-xml.golden
new file mode 100644
index 0000000..08b1e1b
--- /dev/null
+++ b/test/golden/expected/docs-xml.golden
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+ which breaks CDATA sections.
+The sequence ]]]]> must be escaped to ]]]]]]><\![CDATA[> in XML output.
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/golden/expected/dry-run.golden b/test/golden/expected/dry-run.golden
new file mode 100644
index 0000000..be84ee6
--- /dev/null
+++ b/test/golden/expected/dry-run.golden
@@ -0,0 +1,22 @@
+
+Dry run — 12 file(s) matched in golden-repo
+
+ • README.md 21 words
+ • cdata-break.md 25 words
+ • deep/nested/path/doc.md 27 words
+ • empty.md 0 words
+ • guide.rst 24 words
+ • it's-fine.md 16 words
+ • journal.org 24 words
+ • manual.adoc 29 words
+ • my notes.md 13 words
+ • no-newline.md 9 words
+ • notes.txt 22 words
+ • paper.tex 15 words
+
+ Files : 12
+ Words : 225
+ Tokens: ~292
+ Chunks: ~1
+
+Run without --dry-run to generate output.
diff --git a/test/golden/expected/exclude-deep-md.golden b/test/golden/expected/exclude-deep-md.golden
new file mode 100644
index 0000000..b2ed332
--- /dev/null
+++ b/test/golden/expected/exclude-deep-md.golden
@@ -0,0 +1,121 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/exclude-multi-md.golden b/test/golden/expected/exclude-multi-md.golden
new file mode 100644
index 0000000..adb3d39
--- /dev/null
+++ b/test/golden/expected/exclude-multi-md.golden
@@ -0,0 +1,110 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/include-hidden-md.golden b/test/golden/expected/include-hidden-md.golden
new file mode 100644
index 0000000..9ce57ac
--- /dev/null
+++ b/test/golden/expected/include-hidden-md.golden
@@ -0,0 +1,260 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: .env.example
+---
+
+DATABASE_URL=postgres://localhost:5432/mydb
+SECRET_KEY=your-secret-key-here
+DEBUG=false
+
+
+
+---
+### File: .github/ci.yml
+---
+
+name: CI
+on: [push, pull_request]
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - run: echo "Golden fixture CI workflow"
+
+
+
+---
+### File: .gitignore
+---
+
+OUTPUT_DIR/
+
+
+
+---
+### File: Makefile
+---
+
+.PHONY: all clean
+
+all:
+ @echo "Golden fixture Makefile"
+
+clean:
+ @echo "Nothing to clean"
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/include-json-md.golden b/test/golden/expected/include-json-md.golden
new file mode 100644
index 0000000..a802410
--- /dev/null
+++ b/test/golden/expected/include-json-md.golden
@@ -0,0 +1,144 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
diff --git a/test/golden/expected/json-dry-run.golden b/test/golden/expected/json-dry-run.golden
new file mode 100644
index 0000000..4e4ca9a
--- /dev/null
+++ b/test/golden/expected/json-dry-run.golden
@@ -0,0 +1,21 @@
+{
+ "dry_run": true,
+ "repo": "golden-repo",
+ "files": [
+ {"path": "README.md", "words": 21, "chunk": 1},
+ {"path": "cdata-break.md", "words": 25, "chunk": 1},
+ {"path": "deep/nested/path/doc.md", "words": 27, "chunk": 1},
+ {"path": "empty.md", "words": 0, "chunk": 1},
+ {"path": "guide.rst", "words": 24, "chunk": 1},
+ {"path": "it's-fine.md", "words": 16, "chunk": 1},
+ {"path": "journal.org", "words": 24, "chunk": 1},
+ {"path": "manual.adoc", "words": 29, "chunk": 1},
+ {"path": "my notes.md", "words": 13, "chunk": 1},
+ {"path": "no-newline.md", "words": 9, "chunk": 1},
+ {"path": "notes.txt", "words": 22, "chunk": 1},
+ {"path": "paper.tex", "words": 15, "chunk": 1}
+ ],
+ "total_words": 225,
+ "estimated_tokens": 292,
+ "estimated_chunks": 1
+}
diff --git a/test/golden/expected/json.golden b/test/golden/expected/json.golden
new file mode 100644
index 0000000..bcffe15
--- /dev/null
+++ b/test/golden/expected/json.golden
@@ -0,0 +1,13 @@
+{
+ "repo": "golden-repo",
+ "output_dir": "OUTPUT_DIR",
+ "files_processed": 12,
+ "total_words": 295,
+ "estimated_tokens": 383,
+ "verified": true,
+ "secrets_excluded": [],
+ "chunks": [
+ {"path": "OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md", "words": 295}
+ ],
+ "exit_code": 0
+}
diff --git a/test/golden/expected/no-check-secrets-code-md.golden b/test/golden/expected/no-check-secrets-code-md.golden
new file mode 100644
index 0000000..e9612d3
--- /dev/null
+++ b/test/golden/expected/no-check-secrets-code-md.golden
@@ -0,0 +1,224 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: README.md
+---
+
+# Golden Repo
+
+This is the readme for the golden test fixture repository.
+It contains files that exercise every smoosh capability.
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
+
+
+
+---
+### File: aws-creds.py
+---
+
+# Golden fixture secrets file.
+# This file contains a fake AWS key for secrets detection testing.
+AWS_ACCESS_KEY_ID = "AKIAIOSFODNN7EXAMPLE"
+AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
+
+
+
+---
+### File: cdata-break.md
+---
+
+# CDATA Edge Case
+
+This file contains the sequence ]]> which breaks CDATA sections.
+The sequence ]]> must be escaped to ]]]]><\![CDATA[> in XML output.
+
+
+
+---
+### File: deep/nested/path/doc.md
+---
+
+# Deeply Nested Document
+
+This document lives at a deeply nested path to test path handling.
+smoosh should include this file with its full relative path preserved.
+
+
+
+---
+### File: empty.md
+---
+
+
+
+
+---
+### File: guide.rst
+---
+
+User Guide
+==========
+
+This guide covers the basic usage of the golden fixture project.
+See the readme for an overview of the project structure.
+
+
+
+---
+### File: index.js
+---
+
+// Golden fixture JavaScript module.
+
+const VERSION = '1.0.0';
+
+function greet(name) {
+ return 'Hello, ' + name;
+}
+
+module.exports = { VERSION, greet };
+
+
+
+---
+### File: it's-fine.md
+---
+
+# It's Fine
+
+This file's name contains an apostrophe.
+It tests filename quoting in shell pipelines.
+
+
+
+---
+### File: journal.org
+---
+
+#+TITLE: Project Journal
+#+DATE: 2026-01-01
+
+* Overview
+
+This org file documents the golden fixture project history.
+Each entry records a notable event during development.
+
+
+
+---
+### File: main.go
+---
+
+// Golden fixture Go program.
+package main
+
+import "fmt"
+
+func greet(name string) string {
+ return "Hello, " + name
+}
+
+func main() {
+ fmt.Println(greet("world"))
+}
+
+
+
+---
+### File: manual.adoc
+---
+
+= Technical Manual
+:doctype: article
+
+This manual describes the technical details of the golden fixture project.
+Refer to the guide for usage instructions and the readme for an overview.
+
+
+
+---
+### File: my notes.md
+---
+
+# My Notes
+
+This file name contains a space to test path handling.
+
+
+
+---
+### File: no-newline.md
+---
+
+This file has no trailing newline at the end.
+
+
+---
+### File: notes.txt
+---
+
+Release notes for golden fixture project.
+
+Version one introduces the initial set of fixture files.
+These files exercise smoosh output format correctness.
+
+
+
+---
+### File: package.json
+---
+
+{
+ "name": "golden-fixture",
+ "version": "1.0.0",
+ "description": "Golden test fixture package"
+}
+
+
+
+---
+### File: paper.tex
+---
+
+\documentclass{article}
+\title{Golden Fixture Paper}
+\begin{document}
+\maketitle
+This paper describes the golden fixture test repository.
+\end{document}
+
+
+
+---
+### File: src/lib.rs
+---
+
+// Golden fixture Rust library.
+
+pub fn greet(name: &str) -> String {
+ format!("Hello, {}!", name)
+}
+
+pub fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/test/golden/expected/only-py-md.golden b/test/golden/expected/only-py-md.golden
new file mode 100644
index 0000000..bc3d1ae
--- /dev/null
+++ b/test/golden/expected/only-py-md.golden
@@ -0,0 +1,20 @@
+# Repository Compilation: golden-repo (Part 1)
+Generated: TIMESTAMP
+
+
+
+---
+### File: app.py
+---
+
+"""Golden fixture Python module."""
+
+
+def greet(name):
+ """Return a greeting string."""
+ return "Hello, " + name
+
+
+def add(a, b):
+ """Return the sum of two numbers."""
+ return a + b
diff --git a/test/golden/expected/quiet.golden b/test/golden/expected/quiet.golden
new file mode 100644
index 0000000..3b55acd
--- /dev/null
+++ b/test/golden/expected/quiet.golden
@@ -0,0 +1 @@
+OUTPUT_DIR/TIMESTAMP_golden-repo_part1.md
diff --git a/test/smoosh_golden.bats b/test/smoosh_golden.bats
new file mode 100644
index 0000000..6a8255e
--- /dev/null
+++ b/test/smoosh_golden.bats
@@ -0,0 +1,387 @@
+#!/usr/bin/env bats
+# Golden file acceptance tests — verify smoosh output is byte-for-byte correct
+# across all modes, formats, and feature flag combinations.
+#
+# Usage:
+# bats test/smoosh_golden.bats # run all golden tests
+# UPDATE_GOLDEN=1 bats test/smoosh_golden.bats # regenerate all golden files
+#
+# shellcheck disable=SC2154,SC2034 # SC2154: bats vars; SC2034: globals used by sourced smoosh.
+
+load 'test_helper/common-setup'
+
+# Paths (set at load time, before setup_file).
+GOLDEN_SRC="${BATS_TEST_DIRNAME}/fixtures/golden-repo"
+GOLDEN_DIR="${BATS_TEST_DIRNAME}/golden/expected"
+
+setup_file() {
+ export GOLDEN_REPO GOLDEN_OUT
+ GOLDEN_REPO="$(mktemp -d)"
+ GOLDEN_OUT="$(mktemp -d)"
+
+ # Create a real git repo from the static fixture files.
+ # The fixture files in GOLDEN_SRC are plain source files (no .git/);
+ # we create the git repo here at test time.
+ cp -r "${GOLDEN_SRC}/." "${GOLDEN_REPO}/"
+
+ # Create a symlink to exercise the symlink exclusion code path (line 642
+ # in smoosh). Created at test time rather than in the fixture directory
+ # because git's core.symlinks setting varies across platforms.
+ ln -s README.md "${GOLDEN_REPO}/link-to-readme"
+
+ git -C "${GOLDEN_REPO}" init -q
+ git -C "${GOLDEN_REPO}" config user.email "test@example.com"
+ git -C "${GOLDEN_REPO}" config user.name "Test"
+ git -C "${GOLDEN_REPO}" add -A
+ git -C "${GOLDEN_REPO}" commit -q -m "init"
+}
+
+teardown_file() {
+ [[ -d "${GOLDEN_REPO-}" ]] && rm -rf "${GOLDEN_REPO}"
+ [[ -d "${GOLDEN_OUT-}" ]] && rm -rf "${GOLDEN_OUT}"
+}
+
+setup() {
+ # Clear output dir between tests so each test starts with a clean slate.
+ rm -rf "${GOLDEN_OUT:?}/"*
+}
+
+# ---------------------------------------------------------------------------
+# Normalisation — strips non-deterministic content before comparison.
+# ---------------------------------------------------------------------------
+
+# normalise CONTENT — print normalised version to stdout.
+#
+# Replaces:
+# - temp dir paths (GOLDEN_REPO, GOLDEN_OUT) with fixed placeholders
+# - random mktemp dir name in chunk headers and filenames → "golden-repo"
+# - timestamps in all three format headers (md text, XML attribute)
+# - timestamp prefixes in output filenames
+# - JSON fields that contain absolute paths or timestamps
+normalise() {
+ local content="${1}"
+ local repo_basename
+ repo_basename="$(basename "${GOLDEN_REPO}")"
+ printf '%s' "${content}" | sed \
+ -e "s|${GOLDEN_REPO}|REPO_ROOT|g" \
+ -e "s|${GOLDEN_OUT}|OUTPUT_DIR|g" \
+ -e "s|${repo_basename}|golden-repo|g" \
+ -e 's/Generated: [0-9-]* [0-9:]*/Generated: TIMESTAMP/g' \
+ -e 's/generated="[^"]*"/generated="TIMESTAMP"/g' \
+ -e 's/[0-9_]*_golden-repo_part/TIMESTAMP_golden-repo_part/g' \
+ -e 's|"generated":"[^"]*"|"generated":"TIMESTAMP"|g' \
+ -e 's|"output_dir":"[^"]*"|"output_dir":"OUTPUT_DIR"|g' \
+ -e 's|"path":"[^"]*TIMESTAMP_golden-repo_part|"path":"OUTPUT_DIR/TIMESTAMP_golden-repo_part|g'
+}
+
+# golden_compare GOLDEN_NAME ACTUAL
+#
+# If UPDATE_GOLDEN=1: write ACTUAL to the golden file and skip the test.
+# Otherwise: diff ACTUAL against the golden file and fail on any difference.
+golden_compare() {
+ local golden_name="${1}" actual="${2}"
+ if [[ "${UPDATE_GOLDEN:-}" == "1" ]]; then
+ printf '%s\n' "${actual}" >"${GOLDEN_DIR}/${golden_name}"
+ skip "Golden file updated: ${golden_name}"
+ fi
+ if [[ ! -f "${GOLDEN_DIR}/${golden_name}" ]]; then
+ fail "Golden file missing: ${golden_name}. Run UPDATE_GOLDEN=1 bats test/smoosh_golden.bats to generate."
+ fi
+ local expected
+ expected="$(cat "${GOLDEN_DIR}/${golden_name}")"
+ if [[ "${actual}" != "${expected}" ]]; then
+ diff <(printf '%s\n' "${expected}") <(printf '%s\n' "${actual}") >&2
+ fail "Output differs from ${golden_name}. Run UPDATE_GOLDEN=1 bats test/smoosh_golden.bats to regenerate."
+ fi
+}
+
+# _concat_chunks EXT — concatenate chunk files with boundary markers.
+# Bash 3.2-compatible: uses find + while loop instead of mapfile.
+_concat_chunks() {
+ local ext="${1}"
+ local result="" first=true chunk_file
+ while IFS= read -r chunk_file; do
+ if [[ "${first}" == "true" ]]; then
+ first=false
+ else
+ result="${result}
+--- CHUNK BOUNDARY ---
+"
+ fi
+ result="${result}$(cat "${chunk_file}")"
+ done < <(find "${GOLDEN_OUT}" -maxdepth 1 -name "*.${ext}" | LC_ALL=C sort)
+ printf '%s' "${result}"
+}
+
+# ---------------------------------------------------------------------------
+# Docs mode — all three output formats
+# ---------------------------------------------------------------------------
+
+@test "golden: docs-md" {
+ smoosh --docs --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md.golden" "${actual}"
+}
+
+@test "golden: docs-text" {
+ smoosh --docs --no-interactive --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text.golden" "${actual}"
+}
+
+@test "golden: docs-xml" {
+ smoosh --docs --no-interactive --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "docs-xml.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Docs mode — feature flags: TOC, line numbers, combined (all 3 formats)
+# ---------------------------------------------------------------------------
+
+@test "golden: docs-md-toc" {
+ smoosh --docs --no-interactive --toc --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md-toc.golden" "${actual}"
+}
+
+@test "golden: docs-md-line-numbers" {
+ smoosh --docs --no-interactive --line-numbers --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-md-toc-line-numbers" {
+ smoosh --docs --no-interactive --toc --line-numbers --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "docs-md-toc-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-text-toc" {
+ smoosh --docs --no-interactive --toc --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text-toc.golden" "${actual}"
+}
+
+@test "golden: docs-text-line-numbers" {
+ smoosh --docs --no-interactive --line-numbers --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-text-toc-line-numbers" {
+ smoosh --docs --no-interactive --toc --line-numbers --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.txt)")"
+ golden_compare "docs-text-toc-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-xml-line-numbers" {
+ smoosh --docs --no-interactive --line-numbers --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "docs-xml-line-numbers.golden" "${actual}"
+}
+
+@test "golden: docs-xml-toc-line-numbers" {
+ smoosh --docs --no-interactive --toc --line-numbers --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "docs-xml-toc-line-numbers.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Code mode — markdown and XML+TOC
+# ---------------------------------------------------------------------------
+
+@test "golden: code-md" {
+ # aws-creds.py is a .py file in code mode — secrets detection excludes it.
+ smoosh --code --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "code-md.golden" "${actual}"
+}
+
+@test "golden: code-xml-toc" {
+ smoosh --code --no-interactive --toc --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.xml)")"
+ golden_compare "code-xml-toc.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Code mode — secrets variant: --no-check-secrets includes aws-creds.py
+# ---------------------------------------------------------------------------
+
+@test "golden: no-check-secrets-code-md" {
+ smoosh --code --no-interactive --no-check-secrets --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "no-check-secrets-code-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# All mode
+# ---------------------------------------------------------------------------
+
+@test "golden: all-md" {
+ smoosh --all --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "all-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Filter flags: --only, --exclude, --include
+# ---------------------------------------------------------------------------
+
+@test "golden: only-py-md" {
+ # app.py included; aws-creds.py excluded by secrets detection.
+ smoosh --only "*.py" --no-interactive --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "only-py-md.golden" "${actual}"
+}
+
+@test "golden: exclude-deep-md" {
+ # deep/nested/path/doc.md excluded; all other docs present.
+ smoosh --docs --no-interactive --exclude "deep/*" --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "exclude-deep-md.golden" "${actual}"
+}
+
+@test "golden: exclude-multi-md" {
+ # Comma-separated excludes: deep paths and .txt files both excluded.
+ smoosh --docs --no-interactive --exclude "deep/*,*.txt" --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "exclude-multi-md.golden" "${actual}"
+}
+
+@test "golden: include-json-md" {
+ # package.json added to docs mode via --include.
+ smoosh --docs --no-interactive --include "*.json" --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "include-json-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Chunking: --max-words 100 across all three formats
+# ---------------------------------------------------------------------------
+
+@test "golden: chunked-md" {
+ smoosh --docs --no-interactive --max-words 100 --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(_concat_chunks md)")"
+ golden_compare "chunked-md.golden" "${actual}"
+}
+
+@test "golden: chunked-text" {
+ smoosh --docs --no-interactive --max-words 100 --format text --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(_concat_chunks txt)")"
+ golden_compare "chunked-text.golden" "${actual}"
+}
+
+@test "golden: chunked-xml" {
+ smoosh --docs --no-interactive --max-words 100 --format xml --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(_concat_chunks xml)")"
+ golden_compare "chunked-xml.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Hidden files: --include-hidden
+# ---------------------------------------------------------------------------
+
+@test "golden: include-hidden-md" {
+ # .github/ci.yml and .env.example included alongside all tracked files.
+ smoosh --all --no-interactive --include-hidden --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" >/dev/null 2>&1
+ local actual
+ actual="$(normalise "$(cat "${GOLDEN_OUT}/"*.md)")"
+ golden_compare "include-hidden-md.golden" "${actual}"
+}
+
+# ---------------------------------------------------------------------------
+# Stdout / stderr output tests
+# ---------------------------------------------------------------------------
+
+@test "golden: dry-run" {
+ # --dry-run writes its file listing to stderr; nothing is written to disk.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --dry-run "${GOLDEN_REPO}" 2>&1 >/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "dry-run.golden" "${actual}"
+}
+
+@test "golden: json" {
+ # --json writes structured JSON to stdout; all progress goes to stderr.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --json --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "json.golden" "${actual}"
+}
+
+@test "golden: json-dry-run" {
+ # --json --dry-run: different JSON structure (file list, no chunks).
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --json --dry-run "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "json-dry-run.golden" "${actual}"
+}
+
+@test "golden: code-json" {
+ # --code --json: secrets_excluded array is populated (aws-creds.py flagged).
+ local actual exit_code
+ actual="$(smoosh --code --no-interactive --json --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "code-json.golden" "${actual}"
+}
+
+@test "golden: quiet" {
+ # --quiet writes output file paths to stdout, one per line.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --quiet --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "quiet.golden" "${actual}"
+}
+
+@test "golden: chunked-quiet" {
+ # --quiet with chunking: outputs one path per chunk.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --quiet --max-words 100 --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "chunked-quiet.golden" "${actual}"
+}
+
+@test "golden: chunked-json" {
+ # --json with chunking: chunks[] array has multiple entries.
+ local actual exit_code
+ actual="$(smoosh --docs --no-interactive --json --max-words 100 --output-dir "${GOLDEN_OUT}" "${GOLDEN_REPO}" 2>/dev/null)"
+ exit_code=$?
+ [[ "${exit_code}" -eq 0 ]] || fail "smoosh exited with code ${exit_code}"
+ actual="$(normalise "${actual}")"
+ golden_compare "chunked-json.golden" "${actual}"
+}