diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts index 13540a73a36f..4090557c9942 100644 --- a/packages/opencode/src/index.ts +++ b/packages/opencode/src/index.ts @@ -39,7 +39,7 @@ function show(out: string) { process.stderr.write(text + EOL) return } - process.stderr.write(out) + process.stderr.write(out + EOL) } const cli = yargs(args) diff --git a/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap b/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap index e9d3ad233807..c626535583ad 100644 --- a/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap +++ b/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap @@ -18,7 +18,8 @@ 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: ""]" + --cwd working directory [string] [default: ""] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp --help 1`] = ` @@ -38,7 +39,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode attach --help 1`] = ` @@ -64,7 +66,8 @@ Options: [string] --mini start the minimal interactive interface [boolean] [default: false] --no-replay disable mini session history replay on resume and after resize [boolean] - --replay-limit cap visible mini replay to the newest N messages [number]" + --replay-limit cap visible mini replay to the newest N messages [number] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode run --help 1`] = ` @@ -104,7 +107,8 @@ Options: --thinking show thinking blocks [boolean] -i, --interactive run in direct interactive split-footer mode [boolean] [default: false] --auto auto-approve permissions that are not explicitly denied (dangerous!) - [boolean] [default: false]" + [boolean] [default: false] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode debug --help 1`] = ` @@ -132,7 +136,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode providers --help 1`] = ` @@ -150,7 +155,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode agent --help 1`] = ` @@ -167,7 +173,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode upgrade --help 1`] = ` @@ -185,7 +192,8 @@ Options: --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] -m, --method installation method to use - [string] [choices: "curl", "npm", "pnpm", "bun", "brew", "choco", "scoop"]" + [string] [choices: "curl", "npm", "pnpm", "bun", "brew", "choco", "scoop"] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode uninstall --help 1`] = ` @@ -202,7 +210,8 @@ Options: -c, --keep-config keep configuration files [boolean] [default: false] -d, --keep-data keep session data and snapshots [boolean] [default: false] --dry-run show what would be removed without removing [boolean] [default: false] - -f, --force skip confirmation prompts [boolean] [default: false]" + -f, --force skip confirmation prompts [boolean] [default: false] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode serve --help 1`] = ` @@ -222,7 +231,8 @@ Options: [boolean] [default: false] --mdns-domain custom domain name for mDNS service (default: opencode.local) [string] [default: "opencode.local"] - --cors additional domains to allow for CORS [array] [default: []]" + --cors additional domains to allow for CORS [array] [default: []] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode web --help 1`] = ` @@ -242,7 +252,8 @@ Options: [boolean] [default: false] --mdns-domain custom domain name for mDNS service (default: opencode.local) [string] [default: "opencode.local"] - --cors additional domains to allow for CORS [array] [default: []]" + --cors additional domains to allow for CORS [array] [default: []] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode models --help 1`] = ` @@ -260,7 +271,8 @@ Options: --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] --verbose use more verbose model output (includes metadata like costs) [boolean] - --refresh refresh the models cache from models.dev [boolean]" + --refresh refresh the models cache from models.dev [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode stats --help 1`] = ` @@ -278,7 +290,8 @@ Options: --tools number of tools to show (default: all) [number] --models show model statistics (default: hidden). Pass a number to show top N, otherwise shows all - --project filter by project (default: all projects, empty string: current project)[string]" + --project filter by project (default: all projects, empty string: current project)[string] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode export --help 1`] = ` @@ -295,7 +308,8 @@ Options: --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] - --sanitize redact sensitive transcript and file data [boolean]" + --sanitize redact sensitive transcript and file data [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode import --help 1`] = ` @@ -311,7 +325,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode github --help 1`] = ` @@ -328,7 +343,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode pr --help 1`] = ` @@ -344,7 +360,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode session --help 1`] = ` @@ -361,7 +378,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode plugin --help 1`] = ` @@ -379,7 +397,8 @@ Options: --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] -g, --global install in global config [boolean] [default: false] - -f, --force replace existing plugin version [boolean] [default: false]" + -f, --force replace existing plugin version [boolean] [default: false] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode db --help 1`] = ` @@ -400,7 +419,8 @@ Options: --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] - --format Output format [string] [choices: "json", "tsv"] [default: "tsv"]" + --format Output format [string] [choices: "json", "tsv"] [default: "tsv"] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp list --help 1`] = ` @@ -413,7 +433,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp add --help 1`] = ` @@ -432,7 +453,8 @@ Options: --pure run without external plugins [boolean] --url URL for a remote MCP server [string] --env environment variable for a local MCP server (KEY=VALUE) [array] - --header HTTP header for a remote MCP server (KEY=VALUE) [array]" + --header HTTP header for a remote MCP server (KEY=VALUE) [array] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp auth --help 1`] = ` @@ -451,7 +473,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp logout --help 1`] = ` @@ -467,7 +490,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode providers list --help 1`] = ` @@ -480,7 +504,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode providers login --help 1`] = ` @@ -498,7 +523,8 @@ Options: --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] -p, --provider provider id or name to log in to (skips provider selection) [string] - -m, --method login method label (skips method selection) [string]" + -m, --method login method label (skips method selection) [string] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode providers logout --help 1`] = ` @@ -514,7 +540,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode agent create --help 1`] = ` @@ -534,7 +561,8 @@ Options: --permissions, --tools comma-separated list of permissions to allow (default: all). Available: "bash, read, edit, glob, grep, webfetch, task, todowrite, websearch, lsp, skill" [string] - -m, --model model to use in the format of provider/model [string]" + -m, --model model to use in the format of provider/model [string] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode agent list --help 1`] = ` @@ -547,7 +575,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode session list --help 1`] = ` @@ -562,7 +591,8 @@ Options: --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] -n, --max-count limit to N most recent sessions [number] - --format output format [string] [choices: "table", "json"] [default: "table"]" + --format output format [string] [choices: "table", "json"] [default: "table"] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode session delete --help 1`] = ` @@ -578,7 +608,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode github install --help 1`] = ` @@ -591,7 +622,8 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode github run --help 1`] = ` @@ -606,7 +638,8 @@ Options: --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] --pure run without external plugins [boolean] --event GitHub mock event to run the agent for [string] - --token GitHub personal access token (github_pat_********) [string]" + --token GitHub personal access token (github_pat_********) [string] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode db path --help 1`] = ` @@ -619,5 +652,6 @@ Options: -v, --version show version number [boolean] --print-logs print logs to stderr [boolean] --log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"] - --pure run without external plugins [boolean]" + --pure run without external plugins [boolean] +" `; diff --git a/packages/opencode/test/cli/help/help-snapshots.test.ts b/packages/opencode/test/cli/help/help-snapshots.test.ts index 3a14d0d7ecc7..0033597d86a3 100644 --- a/packages/opencode/test/cli/help/help-snapshots.test.ts +++ b/packages/opencode/test/cli/help/help-snapshots.test.ts @@ -129,6 +129,7 @@ describe("opencode CLI help-text snapshots", () => { // yargs writes --help to stderr, not stdout. Snapshotting stderr // means our test catches the help body; stdout for these commands // is expected to be empty. + expect(result.stderr.endsWith("\n")).toBe(true) expect(normalize(result.stderr)).toMatchSnapshot(`opencode ${argv.join(" ")} --help`) } if (failures.length > 0) {