2025-12-31 14:07:14 +09:00
|
|
|
# CLI KNOWLEDGE BASE
|
|
|
|
|
|
|
|
|
|
## OVERVIEW
|
2026-01-17 22:01:56 +09:00
|
|
|
|
2026-01-23 02:14:08 +09:00
|
|
|
CLI entry: `bunx oh-my-opencode`. Interactive installer, doctor diagnostics. Commander.js + @clack/prompts.
|
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-01-23 02:14:08 +09:00
|
|
|
├── index.ts # Commander.js entry
|
|
|
|
|
├── install.ts # Interactive TUI (520 lines)
|
2026-01-25 13:12:40 +09:00
|
|
|
├── config-manager.ts # JSONC parsing (664 lines)
|
2026-01-23 02:14:08 +09:00
|
|
|
├── types.ts # InstallArgs, InstallConfig
|
2026-01-25 13:12:40 +09:00
|
|
|
├── model-fallback.ts # Model fallback configuration
|
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-01-17 22:01:56 +09:00
|
|
|
│ ├── types.ts # CheckResult, CheckDefinition
|
2026-01-23 02:14:08 +09:00
|
|
|
│ └── checks/ # 14 checks, 21 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-01-25 13:12:40 +09:00
|
|
|
│ ├── model-resolution.ts # Model resolution check
|
2026-01-23 02:14:08 +09:00
|
|
|
│ └── gh.ts # GitHub CLI
|
2026-01-17 22:01:56 +09:00
|
|
|
├── run/
|
2026-01-23 02:14:08 +09:00
|
|
|
│ └── index.ts # Session launcher
|
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-23 02:14:08 +09:00
|
|
|
| `install` | Interactive setup |
|
|
|
|
|
| `doctor` | 14 health checks |
|
|
|
|
|
| `run` | Launch session |
|
|
|
|
|
| `get-local-version` | Version check |
|
2026-01-13 21:00:00 +09:00
|
|
|
|
2026-01-23 02:14:08 +09:00
|
|
|
## DOCTOR CATEGORIES
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
|
|
|
| Category | Checks |
|
|
|
|
|
|----------|--------|
|
2026-01-23 02:14:08 +09:00
|
|
|
| installation | opencode, plugin |
|
|
|
|
|
| configuration | config validity, Zod |
|
2026-01-17 22:01:56 +09:00
|
|
|
| authentication | anthropic, openai, google |
|
2026-01-23 02:14:08 +09:00
|
|
|
| dependencies | ast-grep, comment-checker |
|
|
|
|
|
| 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-17 22:01:56 +09:00
|
|
|
2. Export from `checks/index.ts`
|
|
|
|
|
3. Add to `getAllCheckDefinitions()`
|
|
|
|
|
|
|
|
|
|
## TUI FRAMEWORK
|
|
|
|
|
|
2026-01-23 02:14:08 +09:00
|
|
|
- **@clack/prompts**: `select()`, `spinner()`, `intro()`
|
|
|
|
|
- **picocolors**: Terminal colors
|
|
|
|
|
- **Symbols**: ✓ (pass), ✗ (fail), ⚠ (warn)
|
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
|
|
|
|
|
|
|
|
- **Blocking in non-TTY**: Check `process.stdout.isTTY`
|
2026-01-23 02:14:08 +09:00
|
|
|
- **Direct JSON.parse**: Use `parseJsonc()`
|
|
|
|
|
- **Silent failures**: Return warn/fail in doctor
|