2026-02-21 04:07:06 +09:00
# CLI Reference
2026-01-09 02:24:43 +09:00
2026-03-27 12:20:40 +09:00
Complete reference for the published `oh-my-opencode` CLI. During the rename transition, OpenCode plugin registration now prefers `oh-my-openagent` inside `opencode.json` .
2026-01-09 02:24:43 +09:00
2026-02-21 04:07:06 +09:00
## Basic Usage
2026-01-09 02:24:43 +09:00
``` bash
2026-02-21 04:07:06 +09:00
# Display help
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode
2026-01-09 02:24:43 +09:00
2026-02-21 04:07:06 +09:00
# Or with npx
2026-03-27 12:20:40 +09:00
npx oh-my-opencode
2026-01-09 02:24:43 +09:00
```
2026-02-21 04:07:06 +09:00
## Commands
2026-01-09 02:24:43 +09:00
2026-03-06 20:50:11 +09:00
| Command | Description |
| ------------------- | ----------------------------------------- |
| `install` | Interactive setup wizard |
| `doctor` | Environment diagnostics and health checks |
| `run` | OpenCode session runner |
| `mcp oauth` | MCP OAuth authentication management |
| `auth` | Google Antigravity OAuth authentication |
| `get-local-version` | Display local version information |
2026-01-09 02:24:43 +09:00
---
2026-02-21 04:07:06 +09:00
## install
2026-01-09 02:24:43 +09:00
2026-03-27 12:20:40 +09:00
Interactive installation tool for initial Oh My OpenCode setup. Provides a TUI based on `@clack/prompts` .
2026-01-09 02:24:43 +09:00
### Usage
``` bash
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode install
2026-01-09 02:24:43 +09:00
```
### Installation Process
2026-02-21 04:07:06 +09:00
1. **Provider Selection ** : Choose your AI provider (Claude, ChatGPT, or Gemini)
2. **API Key Input ** : Enter the API key for your selected provider
2026-03-27 12:20:40 +09:00
3. **Configuration File Creation ** : Writes the plugin config file used by the current install path. Existing installs still commonly use `oh-my-opencode.json` , while renamed `oh-my-openagent.json[c]` files are also recognized.
4. **Plugin Registration ** : Registers `oh-my-openagent` in OpenCode settings, or upgrades a legacy `oh-my-opencode` entry during the compatibility window
2026-01-09 02:24:43 +09:00
### Options
2026-03-06 20:50:11 +09:00
| Option | Description |
| ----------- | ---------------------------------------------------------------- |
| `--no-tui` | Run in non-interactive mode without TUI (for CI/CD environments) |
| `--verbose` | Display detailed logs |
2026-01-09 02:24:43 +09:00
---
2026-02-21 04:07:06 +09:00
## doctor
2026-01-09 02:24:43 +09:00
2026-03-27 12:20:40 +09:00
Diagnoses your environment to ensure Oh My OpenCode is functioning correctly. Performs 17+ health checks covering installation, configuration, authentication, dependencies, and tools.
2026-01-09 02:24:43 +09:00
2026-03-27 12:20:40 +09:00
The doctor command detects common issues including:
- Legacy plugin entry references in `opencode.json` (warns when `oh-my-opencode` is still used instead of `oh-my-openagent` )
- Configuration file validity and JSONC parsing errors
- Model resolution and fallback chain verification
- API key validity for configured providers
- Missing or misconfigured MCP servers
2026-01-09 02:24:43 +09:00
### Usage
``` bash
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode doctor
2026-01-09 02:24:43 +09:00
```
### Diagnostic Categories
2026-03-06 20:50:11 +09:00
| Category | Check Items |
| ------------------ | --------------------------------------------------------- |
| **Installation ** | OpenCode version (>= 1.0.150), plugin registration status |
| **Configuration ** | Configuration file validity, JSONC parsing |
| **Authentication ** | Anthropic, OpenAI, Google API key validity |
| **Dependencies ** | Bun, Node.js, Git installation status |
| **Tools ** | LSP server status, MCP server status |
| **Updates ** | Latest version check |
2026-01-09 02:24:43 +09:00
### Options
2026-03-06 20:50:11 +09:00
| Option | Description |
| ------------------- | ---------------------------------------------------------------- |
2026-01-09 02:24:43 +09:00
| `--category <name>` | Check specific category only (e.g., `--category authentication` ) |
2026-03-06 20:50:11 +09:00
| `--json` | Output results in JSON format |
| `--verbose` | Include detailed information |
2026-01-09 02:24:43 +09:00
### Example Output
```
2026-03-27 12:20:40 +09:00
oh-my-opencode doctor
2026-01-09 02:24:43 +09:00
┌──────────────────────────────────────────────────┐
2026-03-24 15:31:54 +09:00
│ Oh-My-OpenAgent Doctor │
2026-01-09 02:24:43 +09:00
└──────────────────────────────────────────────────┘
Installation
✓ OpenCode version: 1.0.155 (>= 1.0.150)
✓ Plugin registered in opencode.json
Configuration
2026-03-27 12:20:40 +09:00
✓ oh-my-opencode.jsonc is valid
✓ Model resolution: all agents have valid fallback chains
2026-01-09 02:24:43 +09:00
⚠ categories.visual-engineering: using default model
Authentication
✓ Anthropic API key configured
✓ OpenAI API key configured
✗ Google API key not found
Dependencies
✓ Bun 1.2.5 installed
✓ Node.js 22.0.0 installed
✓ Git 2.45.0 installed
Summary: 10 passed, 1 warning, 1 failed
```
---
2026-02-21 04:07:06 +09:00
## run
2026-01-09 02:24:43 +09:00
Executes OpenCode sessions and monitors task completion.
### Usage
``` bash
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode run [ prompt]
2026-01-09 02:24:43 +09:00
```
### Options
2026-03-06 20:50:11 +09:00
| Option | Description |
| ------------------------ | ------------------------------------------------- |
| `--enforce-completion` | Keep session active until all TODOs are completed |
| `--timeout <seconds>` | Set maximum execution time |
| `--agent <name>` | Specify agent to use |
| `--directory <path>` | Set working directory |
| `--port <number>` | Set port for session |
| `--attach` | Attach to existing session |
| `--json` | Output in JSON format |
| `--no-timestamp` | Disable timestamped output |
| `--session-id <id>` | Resume existing session |
| `--on-complete <action>` | Action on completion |
| `--verbose` | Enable verbose logging |
2026-01-09 02:24:43 +09:00
---
2026-02-21 04:07:06 +09:00
## mcp oauth
2026-01-29 19:48:36 +09:00
Manages OAuth 2.1 authentication for remote MCP servers.
### Usage
``` bash
# Login to an OAuth-protected MCP server
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode mcp oauth login <server-name> --server-url https://api.example.com
2026-01-29 19:48:36 +09:00
# Login with explicit client ID and scopes
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode mcp oauth login my-api --server-url https://api.example.com --client-id my-client --scopes "read,write"
2026-01-29 19:48:36 +09:00
# Remove stored OAuth tokens
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode mcp oauth logout <server-name>
2026-01-29 19:48:36 +09:00
# Check OAuth token status
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode mcp oauth status [ server-name]
2026-01-29 19:48:36 +09:00
```
### Options
2026-03-06 20:50:11 +09:00
| Option | Description |
| -------------------- | ------------------------------------------------------------------------- |
| `--server-url <url>` | MCP server URL (required for login) |
| `--client-id <id>` | OAuth client ID (optional if server supports Dynamic Client Registration) |
| `--scopes <scopes>` | Comma-separated OAuth scopes |
2026-01-29 19:48:36 +09:00
### Token Storage
Tokens are stored in `~/.config/opencode/mcp-oauth.json` with `0600` permissions (owner read/write only). Key format: `{serverHost}/{resource}` .
---
2026-02-21 04:07:06 +09:00
## Configuration Files
2026-01-09 02:24:43 +09:00
The CLI searches for configuration files in the following locations (in priority order):
2026-03-27 12:20:40 +09:00
1. **Project Level ** : `.opencode/oh-my-openagent.jsonc` , `.opencode/oh-my-openagent.json` , `.opencode/oh-my-opencode.jsonc` , or `.opencode/oh-my-opencode.json`
2. **User Level ** : `~/.config/opencode/oh-my-openagent.jsonc` , `~/.config/opencode/oh-my-openagent.json` , `~/.config/opencode/oh-my-opencode.jsonc` , or `~/.config/opencode/oh-my-opencode.json`
**Naming Note ** : The published package and binary are still `oh-my-opencode` . Inside `opencode.json` , the compatibility layer now prefers the plugin entry `oh-my-openagent` . Plugin config loading recognizes both `oh-my-openagent.*` and legacy `oh-my-opencode.*` basenames. If both basenames exist in the same directory, the legacy `oh-my-opencode.*` file currently wins.
### Filename Compatibility
Both `.jsonc` and `.json` extensions are supported. JSONC (JSON with Comments) is preferred as it allows:
- Comments (both `//` and `/* */` styles)
- Trailing commas in arrays and objects
If both `.jsonc` and `.json` exist in the same directory, the `.jsonc` file takes precedence.
2026-01-09 02:24:43 +09:00
### JSONC Support
Configuration files support **JSONC (JSON with Comments) ** format. You can use comments and trailing commas.
``` jsonc
{
// Agent configuration
"sisyphus_agent" : {
"disabled" : false ,
"planner_enabled" : true ,
} ,
2026-02-21 04:07:06 +09:00
2026-01-09 02:24:43 +09:00
/ * C a t e g o r y c u s t o m i z a t i o n * /
"categories" : {
"visual-engineering" : {
2026-03-06 20:50:11 +09:00
"model" : "google/gemini-3.1-pro" ,
2026-01-09 02:24:43 +09:00
} ,
} ,
}
```
---
2026-02-21 04:07:06 +09:00
## Troubleshooting
2026-01-09 02:24:43 +09:00
### "OpenCode version too old" Error
``` bash
# Update OpenCode
npm install -g opencode@latest
# or
bun install -g opencode@latest
```
### "Plugin not registered" Error
``` bash
# Reinstall plugin
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode install
2026-01-09 02:24:43 +09:00
```
### Doctor Check Failures
``` bash
# Diagnose with detailed information
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode doctor --verbose
2026-01-09 02:24:43 +09:00
# Check specific category only
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode doctor --category authentication
2026-01-09 02:24:43 +09:00
```
2026-03-27 12:20:40 +09:00
### "Using legacy package name" Warning
The doctor warns if it finds the legacy plugin entry `oh-my-opencode` in `opencode.json` . Update the plugin array to the canonical `oh-my-openagent` entry:
``` bash
# Replace the legacy plugin entry in user config
jq '.plugin = (.plugin // [] | map(if . == "oh-my-opencode" then "oh-my-openagent" else . end))' \
~/.config/opencode/opencode.json > /tmp/opencode.json && mv /tmp/opencode.json ~/.config/opencode/opencode.json
```
2026-01-09 02:24:43 +09:00
---
2026-02-21 04:07:06 +09:00
## Non-Interactive Mode
2026-01-09 02:24:43 +09:00
2026-03-27 12:20:40 +09:00
Use JSON output for CI or scripted diagnostics.
2026-01-09 02:24:43 +09:00
``` bash
# Run doctor in CI environment
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode doctor --json
2026-01-09 02:24:43 +09:00
# Save results to file
2026-03-27 12:20:40 +09:00
bunx oh-my-opencode doctor --json > doctor-report.json
2026-01-09 02:24:43 +09:00
```
---
2026-02-21 04:07:06 +09:00
## Developer Information
2026-01-09 02:24:43 +09:00
### CLI Structure
```
src/cli/
2026-02-19 18:41:37 +09:00
├── cli-program.ts # Commander.js-based main entry
2026-01-09 02:24:43 +09:00
├── install.ts # @clack/prompts-based TUI installer
2026-02-19 18:41:37 +09:00
├── config-manager/ # JSONC parsing, multi-source config management
│ └── *.ts
2026-01-09 02:24:43 +09:00
├── doctor/ # Health check system
│ ├── index.ts # Doctor command entry
│ └── checks/ # 17+ individual check modules
├── run/ # Session runner
2026-02-19 18:41:37 +09:00
│ └── *.ts
└── mcp-oauth/ # OAuth management commands
└── *.ts
2026-01-09 02:24:43 +09:00
```
### Adding New Doctor Checks
2026-02-21 04:07:06 +09:00
Create `src/cli/doctor/checks/my-check.ts` :
2026-01-09 02:24:43 +09:00
``` typescript
2026-03-06 20:50:11 +09:00
import type { DoctorCheck } from "../types" ;
2026-01-09 02:24:43 +09:00
export const myCheck : DoctorCheck = {
name : "my-check" ,
category : "environment" ,
check : async ( ) = > {
// Check logic
2026-03-06 20:50:11 +09:00
const isOk = await someValidation ( ) ;
2026-02-21 04:07:06 +09:00
2026-01-09 02:24:43 +09:00
return {
status : isOk ? "pass" : "fail" ,
message : isOk ? "Everything looks good" : "Something is wrong" ,
2026-03-06 20:50:11 +09:00
} ;
2026-01-09 02:24:43 +09:00
} ,
2026-03-06 20:50:11 +09:00
} ;
2026-01-09 02:24:43 +09:00
```
2026-02-21 04:07:06 +09:00
Register in `src/cli/doctor/checks/index.ts` :
2026-01-09 02:24:43 +09:00
``` typescript
2026-03-06 20:50:11 +09:00
export { myCheck } from "./my-check" ;
2026-01-09 02:24:43 +09:00
```