CLI Reference
Relevant source files
The following files were used as context for generating this wiki page:
The Oh-My-OpenCode Command Line Interface (CLI) serves as the primary entry point for managing the plugin, providing tools for interactive installation, health diagnostics, and session management. It is designed to extend the OpenCode ecosystem by offering a robust terminal-based utility suite implemented with Commander.js and the @clack/prompts TUI framework.
The CLI allows developers to maintain their environment through automated health checks, configure multi-model agent providers, and launch specialized AI sessions with enforced task discipline. It supports a variety of platforms through 11 platform-specific binaries.
Sources: src/cli/AGENTS.md:3-5, AGENTS.md:58-69
CLI Architecture and Commands
The CLI is structured into several specialized modules, each corresponding to a primary command. The entry point (src/cli/index.ts) utilizes Commander.js to route user input to the appropriate logic handlers.
Primary Commands
| Command | Purpose | Key Features |
|---|---|---|
install | Interactive Setup | Provider selection, TUI-based configuration |
doctor | Health Diagnostics | 14 health checks, dependency validation |
run | Session Launcher | Launches OpenCode sessions, enforces todo lists |
get-local-version | Version Management | Updates checks, local version detection |
Sources: src/cli/AGENTS.md:5-10, src/cli/AGENTS.md:31-36
TUI Framework
The interface leverages @clack/prompts for interactive elements such as spinners and select menus, while picocolors provides semantic coloring (e.g., green for passes, red for failures).
Sources: src/cli/AGENTS.md:54-57
Health Diagnostics (Doctor)
The doctor command performs 14 distinct health checks to ensure the plugin and its dependencies are correctly configured. These checks are orchestrated by a runner that produces formatted, colored terminal output.
Diagnostic Categories
| Category | Description |
|---|---|
| Installation | Verifies OpenCode and the plugin are installed correctly. |
| Configuration | Validates JSONC syntax, Zod schema compliance, and model resolution. |
| Authentication | Checks connectivity and credentials for Anthropic, OpenAI, and Google. |
| Dependencies | Validates presence of ast-grep, gh-cli, and comment-checker. |
| Tools | Ensures LSP connectivity and MCP (Model Context Protocol) validation. |
Sources: src/cli/AGENTS.md:38-45
Execution Flow
The doctor command follows a specific execution pattern to validate the environment:
The system is designed for extensibility, allowing developers to add new checks by exporting a CheckDefinition from a factory in src/cli/doctor/checks/.
Sources: src/cli/doctor/index.ts, src/cli/AGENTS.md:47-52
Session Management (Run)
The run command acts as the session launcher for Oh-My-OpenCode. Its primary responsibility is to initialize the environment and provide the necessary context for AI agent orchestration.
Workflow Integration
When a session is launched via the CLI, it interacts with the core plugin hooks to manage the lifecycle of a task. This includes:
- Todo Enforcement: Ensuring multi-step tasks are tracked via
TaskCreateortodowrite. - Agent Orchestration: Coordinating between models like Claude Opus 4.5, GPT-5.2, and Gemini 3 Flash.
Sources: src/cli/run/index.ts, src/cli/AGENTS.md:31-36, AGENTS.md:54-56
Configuration Management
The CLI utilizes a config-manager.ts that supports JSONC (JSON with Comments), allowing for more readable configuration files that include comments and trailing commas.
Multi-Level Configuration
The system resolves configuration across multiple levels:
- Project Level:
.opencode/directory within the current workspace. - User Level:
~/.config/opencode/directory.
Sources: src/cli/AGENTS.md:21-21, AGENTS.md:129-132
Summary
The Oh-My-OpenCode CLI provides a structured environment for AI-assisted engineering. By combining interactive installation through install, comprehensive environment validation via doctor, and strict session management via run, it ensures that the multi-model agent orchestration system operates within a stable and correctly configured host environment. This CLI is essential for maintaining the "disciplined" codebase state required for high-accuracy agent performance.
Sources: src/cli/AGENTS.md:3-10, AGENTS.md:104-106