2025-12-31 14:07:14 +09:00
|
|
|
# CLI KNOWLEDGE BASE
|
|
|
|
|
|
|
|
|
|
## OVERVIEW
|
2026-01-02 10:42:38 +09:00
|
|
|
CLI for oh-my-opencode: interactive installer, health diagnostics (doctor), runtime launcher. Entry: `bunx oh-my-opencode`.
|
2025-12-31 14:07:14 +09:00
|
|
|
|
|
|
|
|
## STRUCTURE
|
|
|
|
|
```
|
|
|
|
|
cli/
|
2026-01-17 19:16:49 +09:00
|
|
|
├── index.ts # Commander.js entry, subcommand routing
|
2026-01-15 15:53:51 +09:00
|
|
|
├── install.ts # Interactive TUI installer (462 lines)
|
|
|
|
|
├── config-manager.ts # JSONC parsing, env detection (730 lines)
|
2025-12-31 14:07:14 +09:00
|
|
|
├── types.ts # CLI-specific types
|
|
|
|
|
├── doctor/ # Health check system
|
|
|
|
|
│ ├── index.ts # Doctor command entry
|
2026-01-09 15:44:06 +09:00
|
|
|
│ ├── runner.ts # Health check orchestration
|
2026-01-02 10:42:38 +09:00
|
|
|
│ ├── constants.ts # Check categories
|
2025-12-31 14:07:14 +09:00
|
|
|
│ ├── types.ts # Check result interfaces
|
2026-01-15 15:53:51 +09:00
|
|
|
│ └── checks/ # 10 check modules (14 individual checks)
|
2026-01-02 10:42:38 +09:00
|
|
|
├── get-local-version/ # Version detection
|
2025-12-31 14:07:14 +09:00
|
|
|
└── run/ # OpenCode session launcher
|
2026-01-09 15:44:06 +09:00
|
|
|
├── completion.ts # Completion logic
|
|
|
|
|
└── events.ts # Event handling
|
2025-12-31 14:07:14 +09:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## CLI COMMANDS
|
2026-01-02 10:42:38 +09:00
|
|
|
| Command | Purpose |
|
|
|
|
|
|---------|---------|
|
2026-01-13 21:00:00 +09:00
|
|
|
| `install` | Interactive setup wizard with subscription detection |
|
|
|
|
|
| `doctor` | Environment health checks (LSP, Auth, Config, Deps) |
|
2026-01-15 15:53:51 +09:00
|
|
|
| `run` | Launch OpenCode session with todo/background completion enforcement |
|
|
|
|
|
| `get-local-version` | Detect and return local plugin version & update status |
|
2025-12-31 14:07:14 +09:00
|
|
|
|
|
|
|
|
## DOCTOR CHECKS
|
2026-01-15 15:53:51 +09:00
|
|
|
14 checks in `doctor/checks/`:
|
|
|
|
|
- `version.ts`: OpenCode >= 1.0.150 & plugin update status
|
2026-01-13 21:00:00 +09:00
|
|
|
- `config.ts`: Plugin registration & JSONC validity
|
2026-01-15 15:53:51 +09:00
|
|
|
- `dependencies.ts`: AST-Grep (CLI/NAPI), Comment Checker
|
2026-01-13 21:00:00 +09:00
|
|
|
- `auth.ts`: Anthropic, OpenAI, Google (Antigravity)
|
|
|
|
|
- `lsp.ts`, `mcp.ts`: Tool connectivity checks
|
2026-01-15 15:53:51 +09:00
|
|
|
- `gh.ts`: GitHub CLI availability
|
2026-01-13 21:00:00 +09:00
|
|
|
|
|
|
|
|
## CONFIG-MANAGER
|
|
|
|
|
- **JSONC**: Supports comments and trailing commas via `parseJsonc`
|
|
|
|
|
- **Multi-source**: Merges User (`~/.config/opencode/`) + Project (`.opencode/`)
|
|
|
|
|
- **Validation**: Strict Zod schema with error aggregation for `doctor`
|
|
|
|
|
- **Env**: Detects `OPENCODE_CONFIG_DIR` for profile isolation
|
2025-12-31 14:07:14 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
## HOW TO ADD CHECK
|
2026-01-13 21:00:00 +09:00
|
|
|
1. Create `src/cli/doctor/checks/my-check.ts` returning `DoctorCheck`
|
|
|
|
|
2. Export from `checks/index.ts` and add to `getAllCheckDefinitions()`
|
|
|
|
|
3. Use `CheckContext` for shared utilities (LSP, Auth)
|
2025-12-31 14:07:14 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
## ANTI-PATTERNS
|
|
|
|
|
- Blocking prompts in non-TTY (check `process.stdout.isTTY`)
|
2026-01-13 21:00:00 +09:00
|
|
|
- Direct `JSON.parse` (breaks JSONC compatibility)
|
|
|
|
|
- Silent failures (always return `warn` or `fail` in `doctor`)
|
|
|
|
|
- Environment-specific hardcoding (use `ConfigManager`)
|