Skip to content

Commit 350526b

Browse files
committed
docs: add REST API migration shaping doc, remove outdated ACP specs
Replace opencode acp (JSON-RPC/stdio) with opencode serve (HTTP REST + SSE) as the planned backend transport. Add full shaping document with requirements, fit check, spike results, breadboard, and implementation slices. - Add docs/shaping/rest-api-migration.md with architecture decision - Remove opencode-monitor-spec.md (superseded by shaping doc) - Remove docs/plans/acp-parity-completion-spec-v2.md (ACP-specific) - Update AGENTS.md to describe project purpose concisely - Update docs/app-server-events.md to remove ACP mapping section - Update docs/codebase-map.md descriptions
1 parent 42bf937 commit 350526b

File tree

6 files changed

+488
-893
lines changed

6 files changed

+488
-893
lines changed

AGENTS.md

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,37 @@ Detailed navigation/runbooks live in:
99

1010
- `docs/codebase-map.md` (task-oriented file map: "if you need X, edit Y")
1111
- `README.md` (setup, build, release, and broader project docs)
12+
- `docs/shaping/rest-api-migration.md` (architecture decision: ACP to REST API migration)
1213

13-
## Project Snapshot
14+
## Project Purpose
1415

15-
OpenCodeMonitor is a fork of [CodexMonitor](https://github.com/Dimillian/CodexMonitor) — a Tauri desktop app that orchestrates coding agents across local workspaces. The backend has been replaced: instead of Codex CLI, it spawns **OpenCode ACP** (`opencode acp`) as the agent process and translates between ACP's protocol and the original CodexMonitor frontend event shapes.
16+
OpenCodeMonitor is a fork of [CodexMonitor](https://github.com/Dimillian/CodexMonitor) — a Tauri desktop app that orchestrates coding agents across local workspaces. The fork replaces the Codex CLI backend with [OpenCode](https://opencode.ai) and translates between OpenCode's protocol and the original CodexMonitor frontend event shapes.
17+
18+
We pull upstream CodexMonitor changes regularly (weekly/monthly). The fork's translation layer is isolated to three Rust files so frontend merges stay clean.
19+
20+
## Architecture
1621

1722
- Frontend: React + Vite (`src/`)
1823
- Backend app: Tauri Rust process (`src-tauri/src/lib.rs`)
1924
- Backend daemon: JSON-RPC process (`src-tauri/src/bin/codex_monitor_daemon.rs`)
2025
- Shared backend source of truth: `src-tauri/src/shared/*`
21-
- ACP event translation: `src-tauri/src/backend/event_translator.rs`
26+
- Protocol event translation: `src-tauri/src/backend/event_translator.rs`
2227

23-
## Fork Architecture — ACP Translation Layer
28+
### Core Design Invariant
2429

25-
The frontend thread reducer receives events in the **same shape** as original CodexMonitor. All ACP-to-CodexMonitor translation happens in Rust. This is the core design invariant.
30+
The frontend thread reducer receives events in the **same shape** as original CodexMonitor. All OpenCode-to-CodexMonitor translation happens in Rust, never in the frontend.
2631

27-
Key differences from upstream CodexMonitor:
32+
### Backend: Migrating from ACP to REST API
2833

29-
- **Process spawn**: `opencode acp --port <N> --cwd <path>` instead of Codex CLI. Ports allocated from `AtomicU16` starting at 14096.
30-
- **Protocol**: ACP uses `session/new`, `session/load`, `session/prompt`, `cancel`, `session/list`. Events arrive as `session/update` notifications.
31-
- **No turn concept in ACP**: Synthetic `turn/started` and `turn/completed` events are emitted around `session/prompt` calls.
32-
- **Permission requests**: ACP's `requestPermission` is translated to `codex/requestApproval`. Currently auto-approved by ACP — the approval UI is wired but dormant.
33-
- **Session creation latency**: 11-17 seconds — frontend shows loading state.
34-
35-
Internal Rust module paths (`codex_core.rs`, `codex/mod.rs`, etc.) are **not renamed** — only user-facing strings. This minimizes merge conflicts with upstream.
34+
The backend is migrating from `opencode acp` (JSON-RPC over stdio) to `opencode serve` (HTTP REST + SSE). See `docs/shaping/rest-api-migration.md` for the full rationale, requirements, and implementation slices.
3635

37-
### Key Translation Files
36+
The migration touches three files — the same three already diverged from upstream:
3837

39-
- `src-tauri/src/backend/event_translator.rs`ACP sessionUpdate → CodexMonitor event shapes
40-
- `src-tauri/src/shared/codex_core.rs`All protocol methods rewritten for ACP
41-
- `src-tauri/src/backend/app_server.rs`Stdout reader routes `session/update` through translator
38+
- `src-tauri/src/backend/event_translator.rs`protocol events to CodexMonitor event shapes
39+
- `src-tauri/src/shared/codex_core.rs`all protocol methods
40+
- `src-tauri/src/backend/app_server.rs`process spawn, event routing
4241

43-
### Stubbed Features
44-
45-
These Codex-specific features return empty/no-op responses:
46-
`fork_thread`, `turn_steer`, `start_review`, `model_list`, `account_rate_limits`, `codex_login`, `skills_list`, `apps_list`, `collaboration_mode_list`, `list_mcp_server_status`, `archive_thread`, `set_thread_name`
42+
Internal Rust module paths (`codex_core.rs`, `codex/mod.rs`, etc.) are **not renamed** — only user-facing strings. This minimizes merge conflicts with upstream.
4743

4844
## Non-Negotiable Architecture Rules
4945

@@ -52,7 +48,7 @@ These Codex-specific features return empty/no-op responses:
5248
3. Do not duplicate logic between app and daemon.
5349
4. Keep JSON-RPC method names and payload shapes stable unless intentionally changing contracts.
5450
5. Keep frontend IPC contracts in sync with backend command surfaces.
55-
6. All ACP protocol translation happens in Rust — never in the frontend.
51+
6. All OpenCode protocol translation happens in Rust — never in the frontend.
5652

5753
## Backend Routing Rules
5854

@@ -97,12 +93,11 @@ Use project aliases for frontend imports:
9793
- Daemon RPC router: `src-tauri/src/bin/codex_monitor_daemon/rpc.rs`
9894
- Shared workspaces core: `src-tauri/src/shared/workspaces_core.rs` + `src-tauri/src/shared/workspaces_core/*`
9995
- Shared git UI core: `src-tauri/src/shared/git_ui_core.rs` + `src-tauri/src/shared/git_ui_core/*`
100-
- ACP event translator: `src-tauri/src/backend/event_translator.rs`
101-
- ACP protocol methods: `src-tauri/src/shared/codex_core.rs`
102-
- ACP process spawn: `src-tauri/src/backend/app_server.rs`
96+
- Protocol event translator: `src-tauri/src/backend/event_translator.rs`
97+
- Protocol methods: `src-tauri/src/shared/codex_core.rs`
98+
- Process spawn + event routing: `src-tauri/src/backend/app_server.rs`
10399
- Threads reducer entrypoint: `src/features/threads/hooks/useThreadsReducer.ts`
104100
- Threads reducer slices: `src/features/threads/hooks/threadReducer/*`
105-
- Spec with wire captures: `opencode-monitor-spec.md`
106101

107102
For broader path maps, use `docs/codebase-map.md`.
108103

@@ -140,8 +135,6 @@ Run validations based on touched areas:
140135
- Rust backend changes: `cd src-tauri && cargo check`
141136
- Use targeted tests for touched modules before full-suite runs when iterating.
142137

143-
Known pre-existing failure: `tailscale::daemon_commands::tests::restart_required_for_old_version` — unrelated to the ACP port.
144-
145138
## Quick Runbook
146139

147140
Core local commands (keep these inline for daily use):
@@ -185,4 +178,5 @@ Use extra care in high-churn/high-complexity files:
185178

186179
- Task-oriented code map: `docs/codebase-map.md`
187180
- Setup/build/release/test commands: `README.md`
188-
- ACP protocol spec and wire captures: `opencode-monitor-spec.md`
181+
- Architecture decision (ACP to REST migration): `docs/shaping/rest-api-migration.md`
182+
- Frontend event contract: `docs/app-server-events.md`

docs/app-server-events.md

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# App-Server Events Reference (OpenCode ACP)
1+
# App-Server Events Reference
22

3-
This document describes the events OpenCode Monitor currently emits to the frontend after ACP-to-CodexMonitor translation.
3+
Events the Rust backend emits to the frontend after protocol-to-CodexMonitor translation.
44

55
## Source Of Truth
66

7-
- ACP process + stdout routing: `src-tauri/src/backend/app_server.rs`
8-
- ACP `session/update` translation: `src-tauri/src/backend/event_translator.rs`
7+
- Process management + event routing: `src-tauri/src/backend/app_server.rs`
8+
- Protocol event translation: `src-tauri/src/backend/event_translator.rs`
99
- Frontend method parser: `src/utils/appServerEvents.ts`
1010
- Frontend event router: `src/features/app/hooks/useAppServerEvents.ts`
1111

1212
## Supported Event Methods
1313

14-
These methods are currently recognized by `SUPPORTED_APP_SERVER_METHODS` and routed into thread/app state handlers:
14+
These methods are recognized by `SUPPORTED_APP_SERVER_METHODS` and routed into thread/app state handlers:
1515

1616
- `app/list/updated`
1717
- `codex/connected`
@@ -41,21 +41,6 @@ These methods are currently recognized by `SUPPORTED_APP_SERVER_METHODS` and rou
4141
- `account/login/completed`
4242
- `error`
4343

44-
## ACP Session Update Mapping
45-
46-
Current `session/update` mappings in `event_translator.rs`:
47-
48-
- `agent_message_chunk` -> `item/agentMessage/delta`
49-
- `agent_thought_chunk` -> `item/reasoning/textDelta`
50-
- `tool_call` -> `item/started`
51-
- `tool_call_update` -> tool deltas + `item/completed`
52-
- `usage_update` -> `thread/tokenUsage/updated`
53-
- `plan` -> `turn/plan/updated`
54-
- `user_message_chunk` -> `item/completed` (`userMessage`) during replay (live sends use synthetic user items)
55-
- dropped intentionally: `available_commands_update`
56-
57-
Unknown ACP `sessionUpdate` values are ignored (debug builds log them to stderr).
58-
5944
## Background Helper Routing
6045

6146
When translated events include a `params.threadId` that matches a registered background helper callback, the backend sends those translated events to the callback channel instead of the app event sink.
@@ -64,13 +49,14 @@ This prevents helper traffic from leaking into the visible thread stream while s
6449

6550
## Synthetic Turn Lifecycle
6651

67-
ACP has no native turn lifecycle notifications. OpenCode Monitor emits:
52+
OpenCode has no native turn lifecycle notifications. The backend emits:
6853

69-
- `turn/started` before `session/prompt`
70-
- `turn/completed` only after a successful `session/prompt` response
54+
- `turn/started` before sending a prompt
55+
- `turn/completed` after a successful prompt response
7156
- `error` for failed prompt paths (instead of emitting `turn/completed`)
7257

7358
## Notes
7459

75-
- All ACP translation stays in Rust by design.
76-
- Frontend should continue consuming CodexMonitor-shaped events and avoid protocol-specific logic.
60+
- All protocol translation stays in Rust by design.
61+
- Frontend consumes CodexMonitor-shaped events and avoids protocol-specific logic.
62+
- For the protocol-to-CodexMonitor event mapping, see `docs/shaping/rest-api-migration.md`.

docs/codebase-map.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ When adding a new method, keep method names and payload shape aligned with `src/
109109

110110
All cross-runtime domain behavior belongs in `src-tauri/src/shared/*`:
111111

112-
- Codex threads/approvals/account/skills/config: `src-tauri/src/shared/codex_core.rs`
113-
- Codex helper commands: `src-tauri/src/shared/codex_aux_core.rs`
114-
- Codex update/version helpers: `src-tauri/src/shared/codex_update_core.rs`
112+
- OpenCode protocol methods (sessions/approvals/account/models): `src-tauri/src/shared/codex_core.rs`
113+
- Helper commands: `src-tauri/src/shared/codex_aux_core.rs`
114+
- Update/version helpers: `src-tauri/src/shared/codex_update_core.rs`
115115
- Workspaces/worktrees: `src-tauri/src/shared/workspaces_core.rs`, `src-tauri/src/shared/workspaces_core/*`, `src-tauri/src/shared/worktree_core.rs`
116116
- Settings model/update: `src-tauri/src/shared/settings_core.rs`
117117
- Files read/write: `src-tauri/src/shared/files_core.rs`

0 commit comments

Comments
 (0)