2025-12-31 14:07:14 +09:00
|
|
|
|
# CLI KNOWLEDGE BASE
|
|
|
|
|
|
|
|
|
|
|
|
## OVERVIEW
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
2026-02-08 17:51:30 +09:00
|
|
|
|
CLI entry: `bunx oh-my-opencode`. 70 CLI utilities and commands with Commander.js + @clack/prompts TUI.
|
2026-02-01 19:26:57 +09:00
|
|
|
|
|
2026-02-06 18:59:58 +09:00
|
|
|
|
**Commands**: install (interactive setup), doctor (14 health checks), run (session launcher), get-local-version, mcp-oauth
|
2025-12-31 14:07:14 +09:00
|
|
|
|
|
|
|
|
|
|
## STRUCTURE
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
2025-12-31 14:07:14 +09:00
|
|
|
|
```
|
|
|
|
|
|
cli/
|
2026-02-06 18:59:58 +09:00
|
|
|
|
├── index.ts # Commander.js entry (5 commands)
|
2026-02-01 19:26:57 +09:00
|
|
|
|
├── install.ts # Interactive TUI (542 lines)
|
|
|
|
|
|
├── config-manager.ts # JSONC parsing (667 lines)
|
2026-01-25 13:12:40 +09:00
|
|
|
|
├── model-fallback.ts # Model fallback configuration
|
2026-02-06 18:59:58 +09:00
|
|
|
|
├── types.ts # InstallArgs, InstallConfig
|
2026-01-17 22:01:56 +09:00
|
|
|
|
├── doctor/
|
2026-01-23 02:14:08 +09:00
|
|
|
|
│ ├── index.ts # Doctor entry
|
2026-01-17 22:01:56 +09:00
|
|
|
|
│ ├── runner.ts # Check orchestration
|
2026-01-23 02:14:08 +09:00
|
|
|
|
│ ├── formatter.ts # Colored output
|
|
|
|
|
|
│ ├── constants.ts # Check IDs, symbols
|
2026-02-06 18:59:58 +09:00
|
|
|
|
│ ├── types.ts # CheckResult, CheckDefinition
|
2026-02-01 19:26:57 +09:00
|
|
|
|
│ └── checks/ # 14 checks, 23 files
|
2026-01-17 22:01:56 +09:00
|
|
|
|
│ ├── version.ts # OpenCode + plugin version
|
2026-01-23 02:14:08 +09:00
|
|
|
|
│ ├── config.ts # JSONC validity, Zod
|
2026-01-17 22:01:56 +09:00
|
|
|
|
│ ├── auth.ts # Anthropic, OpenAI, Google
|
|
|
|
|
|
│ ├── dependencies.ts # AST-Grep, Comment Checker
|
2026-01-23 02:14:08 +09:00
|
|
|
|
│ ├── lsp.ts # LSP connectivity
|
|
|
|
|
|
│ ├── mcp.ts # MCP validation
|
2026-02-06 18:59:58 +09:00
|
|
|
|
│ ├── model-resolution.ts # Model resolution check (323 lines)
|
2026-01-23 02:14:08 +09:00
|
|
|
|
│ └── gh.ts # GitHub CLI
|
2026-01-17 22:01:56 +09:00
|
|
|
|
├── run/
|
2026-02-06 18:59:58 +09:00
|
|
|
|
│ ├── index.ts # Session launcher
|
|
|
|
|
|
│ └── events.ts # CLI run events (325 lines)
|
2026-02-01 19:26:57 +09:00
|
|
|
|
├── mcp-oauth/
|
|
|
|
|
|
│ └── index.ts # MCP OAuth flow
|
2026-01-17 22:01:56 +09:00
|
|
|
|
└── get-local-version/
|
2026-01-23 02:14:08 +09:00
|
|
|
|
└── index.ts # Version detection
|
2025-12-31 14:07:14 +09:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-01-23 02:14:08 +09:00
|
|
|
|
## COMMANDS
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
|
| Command | Purpose |
|
|
|
|
|
|
|---------|---------|
|
2026-01-26 11:48:30 +09:00
|
|
|
|
| `install` | Interactive setup with provider selection |
|
|
|
|
|
|
| `doctor` | 14 health checks for diagnostics |
|
|
|
|
|
|
| `run` | Launch session with todo enforcement |
|
|
|
|
|
|
| `get-local-version` | Version detection and update check |
|
2026-02-06 18:59:58 +09:00
|
|
|
|
| `mcp-oauth` | MCP OAuth authentication flow |
|
2026-01-13 21:00:00 +09:00
|
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
|
## DOCTOR CATEGORIES (14 Checks)
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
|
|
|
|
|
| Category | Checks |
|
|
|
|
|
|
|----------|--------|
|
2026-01-23 02:14:08 +09:00
|
|
|
|
| installation | opencode, plugin |
|
2026-01-26 11:48:30 +09:00
|
|
|
|
| configuration | config validity, Zod, model-resolution |
|
2026-01-17 22:01:56 +09:00
|
|
|
|
| authentication | anthropic, openai, google |
|
2026-01-26 11:48:30 +09:00
|
|
|
|
| dependencies | ast-grep, comment-checker, gh-cli |
|
2026-01-23 02:14:08 +09:00
|
|
|
|
| tools | LSP, MCP |
|
2026-01-17 22:01:56 +09:00
|
|
|
|
| updates | version comparison |
|
2025-12-31 14:07:14 +09:00
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
|
## HOW TO ADD CHECK
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
2026-01-23 02:14:08 +09:00
|
|
|
|
1. Create `src/cli/doctor/checks/my-check.ts`
|
2026-01-26 11:48:30 +09:00
|
|
|
|
2. Export `getXXXCheckDefinition()` factory returning `CheckDefinition`
|
|
|
|
|
|
3. Add to `getAllCheckDefinitions()` in `checks/index.ts`
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
|
|
|
|
|
## TUI FRAMEWORK
|
|
|
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
|
- **@clack/prompts**: `select()`, `spinner()`, `intro()`, `outro()`
|
|
|
|
|
|
- **picocolors**: Terminal colors for status and headers
|
|
|
|
|
|
- **Symbols**: ✓ (pass), ✗ (fail), ⚠ (warn), ℹ (info)
|
2025-12-31 14:07:14 +09:00
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
|
## ANTI-PATTERNS
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
|
- **Blocking in non-TTY**: Always check `process.stdout.isTTY`
|
|
|
|
|
|
- **Direct JSON.parse**: Use `parseJsonc()` from shared utils
|
|
|
|
|
|
- **Silent failures**: Return `warn` or `fail` in doctor instead of throwing
|
|
|
|
|
|
- **Hardcoded paths**: Use `getOpenCodeConfigPaths()` from `config-manager.ts`
|