Dashboard › opencode › Distillation
e5bb6895-162a-4d8f-850b-18f59d867512["lore_tm_v1_qvKmMivL8-MS13jvFhWsKL4Zoz0ploiwNGz7sFP7DDE"]
/home/byk/Code/opencode/packages/opencode/src/index.ts is the CLI entry point. It derives args with hideBin(process.argv) and configures yargs with .parserConfiguration({ "populate--": true }), .scriptName("opencode"), .wrap(100), help aliases help/h, version aliases version/v, and InstallationVersion.show(out: string) helper in /home/byk/Code/opencode/packages/opencode/src/index.ts:35-43 trims only for prefix detection: output not starting with "opencode " is written to stderr after UI.logo() and two EOLs, while matching output is written unchanged.--print-logs (boolean, “print logs to stderr”), --log-level (string restricted to "DEBUG", "INFO", "WARN", or "ERROR"), and --pure (boolean, “run without external plugins”).--print-logs to OPENCODE_PRINT_LOGS="1", --log-level to OPENCODE_LOG_LEVEL, and --pure to OPENCODE_PURE="1"; it then calls Heap.start() and always sets AGENT="1", OPENCODE="1", and OPENCODE_PID=String(process.pid)./home/byk/Code/opencode/packages/opencode/src/index.ts registers shell completion and commands in this exact order: 1. AcpCommand, 2. McpCommand, 3. TuiThreadCommand, 4. AttachCommand, 5. RunCommand, 6. GenerateCommand, 7. DebugCommand, 8. ConsoleCommand, 9. ProvidersCommand, 10. AgentCommand, 11. UpgradeCommand, 12. UninstallCommand, 13. ServeCommand, 14. WebCommand, 15. ModelsCommand, 16. StatsCommand, 17. ExportCommand, 18. ImportCommand, 19. GithubCommand, 20. PrCommand, 21. SessionCommand, 22. PluginCommand, 23. DbCommand; strict parsing is enabled with .strict()..fail() handler specially recognizes messages beginning with "Unknown argument", "Not enough non-option arguments", or "Invalid values:"; it rethrows an accompanying error, otherwise calls cli.showHelp(show), then rethrows any remaining error or calls process.exit(1).-h or --help arguments use cli.parse(args, callback) and route nonempty generated output through show(out); all other invocations use await cli.parse().FormatError(e). A defined formatted result is displayed with UI.error(formatted); otherwise the CLI displays "Unexpected error" + EOL and writes errorMessage(e) + EOL to stderr. The catch sets process.exitCode = 1./home/byk/Code/opencode/packages/opencode/src/index.ts:136-141 unconditionally invokes process.exit() in finally to prevent hanging subprocesses, particularly Docker-container-based MCP servers that do not handle SIGTERM unless run with docker run --init.