- Update root AGENTS.md: hook count 44→46, commit fcb90d92, generated 2026-02-24 - Update src/AGENTS.md: core hooks 35→37, session hooks 21→23 - Update src/hooks/AGENTS.md: 46 hooks total, add modelFallback/noSisyphusGpt/noHephaestusNonGpt/runtimeFallback, jsonErrorRecovery moved to tool-guard (tier 2) - Create src/tools/hashline-edit/AGENTS.md (93 lines): documents three-op model, LINE#ID format, execution pipeline - Refresh timestamps: 2026-02-21→2026-02-24 on 28 files - Update plugin/AGENTS.md hook composition counts 🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2.2 KiB
2.2 KiB
src/cli/run/ — Non-Interactive Session Launcher
Generated: 2026-02-24
OVERVIEW
37 files. Powers the oh-my-opencode run <message> command. Connects to OpenCode server, creates/resumes sessions, streams events, and polls for completion.
EXECUTION FLOW
runner.ts
1. opencode-binary-resolver.ts → Find OpenCode binary
2. server-connection.ts → Connect to OpenCode server (start if needed)
3. agent-resolver.ts → Flag → env → config → Sisyphus
4. session-resolver.ts → Create new or resume existing session
5. events.ts → Stream SSE events from session
6. event-handlers.ts → Process each event type
7. poll-for-completion.ts → Wait for todos + background tasks done
8. on-complete-hook.ts → Execute user-defined completion hook
KEY FILES
| File | Purpose |
|---|---|
runner.ts |
Main orchestration — connects, resolves, runs, completes |
server-connection.ts |
Start OpenCode server process, create SDK client |
agent-resolver.ts |
Resolve agent: --agent flag → OPENCODE_AGENT env → config → Sisyphus |
session-resolver.ts |
Create new session or resume via --attach / --session-id |
events.ts |
SSE event stream subscription |
event-handlers.ts |
Route events to handlers (message, tool, error, idle) |
event-stream-processor.ts |
Process event stream with filtering and buffering |
poll-for-completion.ts |
Poll session until todos complete + no background tasks |
completion.ts |
Determine if session is truly done |
continuation-state.ts |
Persist state for run continuation across invocations |
output-renderer.ts |
Format session output for terminal |
json-output.ts |
JSON output mode (--json flag) |
types.ts |
RunOptions, RunResult, RunContext, event payload types |
AGENT RESOLUTION PRIORITY
1. --agent CLI flag
2. OPENCODE_AGENT environment variable
3. default_run_agent config
4. "sisyphus" (default)
COMPLETION DETECTION
Poll-based with two conditions:
- All todos marked completed (no pending/in_progress)
- No running background tasks
on-complete-hook.ts executes optional user command on completion (e.g., --on-complete "notify-send done").