Files
oh-my-opencode/src/cli/AGENTS.md
T
YeonGyu-Kim 838b5ae216 docs(agents): refresh hierarchical AGENTS.md with team-mode coverage
Update root + 43 directory-level AGENTS.md files to reflect current state:
- Root AGENTS.md rewritten with accurate counts (1967 TS files, 1304 source +
  663 test, 278k LOC, 120 barrel index.ts), 7-step init flow, 5-tier hook
  composition, and full Team Mode section (12 team_* tools, eligibility,
  storage layout, config gate)
- src/AGENTS.md adds team-mode init step, current per-subdir file/LOC table
- src/tools/AGENTS.md documents conditional gates (team-mode +12, task
  system +4, hashline +1, interactive_bash +1, look_at +1) with always-on
  baseline of 20
- src/hooks/AGENTS.md splits into 5 tiers + 4 conditional team-mode hooks
- src/features/team-mode/AGENTS.md surfaces 12 tools, eligible agents,
  spawn-race-safe invariants, and integration points
- src/features/builtin-skills/AGENTS.md tracks 10 skills incl. team-mode
- src/agents/AGENTS.md, src/plugin/AGENTS.md, src/config/AGENTS.md updated
  for team-mode awareness, accurate counts, and current schema field list
- All other AGENTS.md files refreshed to 2026-05-08 generation date
2026-05-08 12:08:42 +09:00

3.4 KiB

src/cli/ — CLI: install, run, doctor, mcp-oauth

Generated: 2026-05-08

OVERVIEW

Commander.js CLI with 6 commands. Entry: index.tsrunCli() in cli-program.ts.

COMMANDS

Command Purpose Key Logic
install Interactive/non-interactive setup Provider selection → config gen → plugin registration
run <message> Non-interactive session launcher Agent resolution (flag → env → config → Sisyphus)
doctor 4-category health checks System, Config, Tools, Models
get-local-version Version detection Installed vs npm latest
mcp-oauth OAuth token management login (PKCE), logout, status
refresh-model-capabilities Refresh models.dev cache Model capabilities refresh

STRUCTURE

cli/
├── index.ts                     # Entry point → runCli()
├── cli-program.ts               # Commander.js program (5 commands)
├── install.ts                   # Routes to TUI or CLI installer
├── cli-installer.ts             # Non-interactive (console output)
├── tui-installer.ts             # Interactive (@clack/prompts)
├── model-fallback.ts            # Model config gen by provider availability
├── provider-availability.ts     # Provider detection
├── fallback-chain-resolution.ts # Fallback chain logic
├── config-manager/              # 20 config utilities
│   ├── plugin registration, provider config
│   ├── JSONC operations, auth plugins
│   └── npm dist-tags, binary detection
├── doctor/
│   ├── runner.ts                # Parallel check execution
│   ├── formatter.ts             # Output formatting
│   └── checks/                  # 15 check files in 4 categories
│       ├── system.ts            # Binary, plugin, version
│       ├── config.ts            # JSONC validity, Zod schema
│       ├── tools.ts             # AST-Grep, LSP, GH CLI, MCP
│       └── model-resolution.ts  # Cache, resolution, overrides (6 sub-files)
├── run/                         # Session launcher
│   ├── runner.ts                # Main orchestration
│   ├── agent-resolver.ts        # Flag → env → config → Sisyphus
│   ├── session-resolver.ts      # Create/resume sessions
│   ├── event-handlers.ts        # Event processing
│   └── poll-for-completion.ts   # Wait for todos/background tasks
└── mcp-oauth/                   # OAuth token management

MODEL FALLBACK SYSTEM

No single global priority. CLI install-time resolution uses per-agent fallback chains from model-fallback-requirements.ts.

Common patterns: Claude/OpenAI/Gemini are preferred when an agent chain includes them, librarian prefers ZAI, sisyphus falls back through Kimi then GLM-5, and hephaestus requires OpenAI-compatible providers.

DOCTOR CHECKS

Category Validates
System Binary found, version >=1.0.150, plugin registered, version match
Config JSONC validity, Zod schema, model override syntax
Tools AST-Grep, comment-checker, LSP servers, GH CLI, MCP servers
Models Cache exists, model resolution, agent/category overrides, availability

HOW TO ADD A DOCTOR CHECK

  1. Create src/cli/doctor/checks/{name}.ts
  2. Export check function matching DoctorCheck interface
  3. Register in checks/index.ts