oh-my-opencode/src/cli/AGENTS.md
YeonGyu-Kim d9ab6ab99b docs: update AGENTS.md hierarchy with latest structure and line counts
- Root: Add Prometheus/Metis/Momus agents, MCP architecture, 82 test files
- agents/: Document 7-section delegation and wisdom notepad
- auth/: Multi-account load balancing (10 accounts), endpoint fallback
- features/: Update background-agent 825 lines, builtin-skills 1230 lines
- hooks/: 22+ hooks with event timing details
- tools/: sisyphus-task 583 lines, LSP client 632 lines
- cli/: config-manager 725 lines, 17+ doctor checks
- shared/: Cross-cutting utilities with usage patterns
2026-01-13 21:00:00 +09:00

2.4 KiB

CLI KNOWLEDGE BASE

OVERVIEW

CLI for oh-my-opencode: interactive installer, health diagnostics (doctor), runtime launcher. Entry: bunx oh-my-opencode.

STRUCTURE

cli/
├── index.ts              # Commander.js entry, subcommand routing (184 lines)
├── install.ts            # Interactive TUI installer (436 lines)
├── config-manager.ts     # JSONC parsing, env detection (725 lines)
├── types.ts              # CLI-specific types
├── commands/             # CLI subcommands (auth.ts)
├── doctor/               # Health check system
│   ├── index.ts          # Doctor command entry
│   ├── runner.ts         # Health check orchestration
│   ├── constants.ts      # Check categories
│   ├── types.ts          # Check result interfaces
│   └── checks/           # 10+ check modules (17+ individual checks)
├── get-local-version/    # Version detection
└── run/                  # OpenCode session launcher
    ├── completion.ts     # Completion logic
    └── events.ts         # Event handling

CLI COMMANDS

Command Purpose
install Interactive setup wizard with subscription detection
doctor Environment health checks (LSP, Auth, Config, Deps)
run Launch OpenCode session with event handling
auth Manage authentication providers

DOCTOR CHECKS

17+ checks in doctor/checks/:

  • version.ts: OpenCode >= 1.0.150
  • config.ts: Plugin registration & JSONC validity
  • dependencies.ts: bun, node, git, gh-cli
  • auth.ts: Anthropic, OpenAI, Google (Antigravity)
  • lsp.ts, mcp.ts: Tool connectivity checks

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

HOW TO ADD CHECK

  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)

ANTI-PATTERNS

  • Blocking prompts in non-TTY (check process.stdout.isTTY)
  • Direct JSON.parse (breaks JSONC compatibility)
  • Silent failures (always return warn or fail in doctor)
  • Environment-specific hardcoding (use ConfigManager)