diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts index d20f29dd4d2f..3cf8bf9c9330 100644 --- a/packages/opencode/src/index.ts +++ b/packages/opencode/src/index.ts @@ -61,10 +61,10 @@ function show(out: string) { const text = out.trimStart() if (!text.startsWith("opencode ")) { process.stderr.write(UI.logo() + EOL + EOL) - process.stderr.write(text) + process.stderr.write(text.trimEnd() + EOL) return } - process.stderr.write(out) + process.stderr.write(out.trimEnd() + 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 22ad59aaa29d..7d4d10ac4092 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`] = ` @@ -60,7 +62,8 @@ Options: -s, --session session id to continue [string] --fork fork the session when continuing (use with --continue or --session) [boolean] -p, --password basic auth password (defaults to OPENCODE_SERVER_PASSWORD) [string] - -u, --username basic auth username (defaults to OPENCODE_SERVER_USERNAME or 'opencode')[string]" + -u, --username basic auth username (defaults to OPENCODE_SERVER_USERNAME or 'opencode')[string] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode run --help 1`] = ` @@ -112,7 +115,8 @@ Options: --dangerously-skip-permissions auto-approve permissions that are not explicitly denied (dangerous!) [boolean] [default: false] --demo enable direct interactive demo slash commands; pass one as the - message to run it immediately [boolean] [default: false]" + message to run it immediately [boolean] [default: false] +" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode debug --help 1`] = ` @@ -140,7 +144,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`] = ` @@ -158,7 +163,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`] = ` @@ -175,7 +181,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`] = ` @@ -193,7 +200,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`] = ` @@ -210,7 +218,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`] = ` @@ -230,7 +239,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`] = ` @@ -250,7 +260,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`] = ` @@ -268,7 +279,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`] = ` @@ -286,7 +298,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`] = ` @@ -303,7 +316,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`] = ` @@ -319,7 +333,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`] = ` @@ -336,7 +351,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`] = ` @@ -352,7 +368,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`] = ` @@ -369,7 +386,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`] = ` @@ -387,7 +405,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`] = ` @@ -409,7 +428,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`] = ` @@ -422,7 +442,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`] = ` @@ -435,7 +456,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 auth --help 1`] = ` @@ -454,7 +476,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`] = ` @@ -470,7 +493,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`] = ` @@ -483,7 +507,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`] = ` @@ -501,7 +526,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] +" `;