Skip to content

fix(cli): keep audit progress off stdout for machine-readable formats - #622

Closed
nc9 wants to merge 1 commit into
mainfrom
cc/exciting-tesla-ldjumz
Closed

nc9 wants to merge 1 commit into
mainfrom
cc/exciting-tesla-ldjumz

Conversation

@nc9

@nc9 nc9 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

squirrel audit <url> -f json (and xml, llm, markdown, text) printed progress and log lines on stdout before the report. The first line was New crawl: http://..., followed by Found N URLs in sitemap and any intercepted logger lines. That broke squirrel audit <url> -f json | jq .meta, which is how coding agents read the CLI.

  • apps/cli/src/cli/progress.ts: Progress / createProgress take an output stream ("stdout" by default). The spinner, log() and the final messages all write to that stream, and its TTY state controls the spinner.
  • apps/cli/src/cli/commands/audit.ts: progress goes to stdout only for the console format and to stderr for every other format. The logger interceptor goes through progress.log, so it moves to stderr too.
  • squirrel audit -f <unknown> now runs validateFormat before crawling and exits 1 with Unknown format: ..., the same as squirrel report -f. Before, it ran the whole audit, printed nothing and exited 0.
  • crawl is unchanged: it has no --format and its output is all console.
  • CHANGELOG: two [Unreleased] > Fixed entries.

Known gap, not fixed here: the logger still picks colour for intercepted warn/error lines from stdout's TTY state. With NO_COLOR unset, stdout on a terminal and stderr redirected to a file, those lines can carry ANSI codes into the file.

Agent skill (squirrelscan/skills): no change needed. Piping -f json/-f llm now works the way the skill already expects.

Verification

  • Repro on main against a local Bun.serve site: stdout began New crawl: http://localhost:4100, then Found 2 URLs in sitemap, then {. With the fix, stdout's first bytes are { / <?xml / <?xml / # squirrelscan / squirrelscan v for json / xml / llm / markdown / text, and squirrel audit http://localhost:4100 -f json 2>/dev/null | jq -c .meta prints the meta object.
  • squirrel audit <url> -f bogus prints Error: Unknown format: bogus. Supported: ... and exits 1.
  • New apps/cli/tests/cli/audit-stdout.test.ts: runs the real entry point against a Bun.serve site with a scratch HOME and --offline. The 7 tests fail on main and pass with this change.
  • bun test in apps/cli: 2833 pass, 1 fail. The failure is checkReachability > returns unreachable for non-existent domains, which also fails on main in this sandbox because the network proxy resolves every hostname.
  • bun run typecheck, bun run lint, bun run format:check in apps/cli: clean.

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

Generated by Claude Code

`squirrel audit <url> -f json` printed "New crawl: ...", "Found N URLs in
sitemap" and intercepted logger lines on stdout ahead of the report, so
`squirrel audit <url> -f json | jq` failed. Progress now takes an output
stream, and audit sends it to stderr for every format except console.

`squirrel audit -f <unknown>` now validates the format up front and exits 1,
like `squirrel report -f`, instead of running the audit, printing nothing
and exiting 0.

Adds an end-to-end test against a local Bun.serve site that checks stdout
starts with the report for json, xml, llm, markdown and text, and that an
unknown format exits 1.

Signed-off-by: Claude <[email protected]>
@nc9 nc9 mentioned this pull request Oct 26, 2026
@nc9

nc9 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Landed in the v0.0.135 batch (#1151), main commit 8b588fc.

@nc9 nc9 closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants