test(cli): stabilize acp --help snapshot against random home path length

yargs wraps the \`[string] [default: "..."]\` clause based on the
pre-normalized default value's character length, so a different random
tmpdir width produces a different leading-whitespace count on the
wrapped continuation line. After normalizing the path to \`<HOME>\` we
were left with a one-space drift between runs.

Collapse the wrap-dependent whitespace immediately before the clause
so the snapshot is byte-stable regardless of home path length.

Verified by deleting the .snap and regenerating across 3 runs.
This commit is contained in:
Kit Langton
2026-05-18 21:22:59 -04:00
parent 13e68a5892
commit af1e67d850
2 changed files with 12 additions and 6 deletions
@@ -18,8 +18,7 @@ Options:
--mdns-domain custom domain name for mDNS service (default: opencode.local)
[string] [default: "opencode.local"]
--cors additional domains to allow for CORS [array] [default: []]
--cwd working directory
[string] [default: "<HOME>"]"
--cwd working directory [string] [default: "<HOME>"]"
`;
exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp --help 1`] = `
@@ -27,10 +27,17 @@ import { cliIt } from "../../lib/cli-process"
const TMP = os.tmpdir()
const REAL_TMP = fs.realpathSync(TMP)
function normalize(text: string): string {
return text
.replaceAll(REAL_TMP, "<TMPDIR>")
.replaceAll(TMP, "<TMPDIR>")
.replace(/<TMPDIR>\/oc-cli-[a-z0-9]+/g, "<HOME>")
return (
text
.replaceAll(REAL_TMP, "<TMPDIR>")
.replaceAll(TMP, "<TMPDIR>")
.replace(/<TMPDIR>\/oc-cli-[a-z0-9]+/g, "<HOME>")
// yargs wraps the `[string] [default: "..."]` clause based on the
// pre-normalized default's character length, so different random home
// path widths produce different leading-whitespace counts on the
// wrapped continuation. Collapse the wrap-dependent whitespace.
.replace(/\s+\[string\] \[default: "<HOME>"\]/g, ' [string] [default: "<HOME>"]')
)
}
// Top-level commands. Order matches what `opencode --help` prints today;