vibe-coding-master 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +168 -63
  2. package/dist/backend/adapters/translation-provider.js +145 -0
  3. package/dist/backend/api/artifact-routes.js +3 -0
  4. package/dist/backend/api/harness-routes.js +22 -0
  5. package/dist/backend/api/project-routes.js +3 -8
  6. package/dist/backend/api/translation-routes.js +70 -0
  7. package/dist/backend/runtime/node-pty-runtime.js +20 -18
  8. package/dist/backend/server.js +31 -1
  9. package/dist/backend/services/app-settings-service.js +128 -0
  10. package/dist/backend/services/artifact-service.js +7 -4
  11. package/dist/backend/services/claude-transcript-service.js +509 -0
  12. package/dist/backend/services/harness-service.js +178 -0
  13. package/dist/backend/services/project-service.js +4 -0
  14. package/dist/backend/services/session-service.js +7 -5
  15. package/dist/backend/services/status-service.js +76 -0
  16. package/dist/backend/services/translation-prompts.js +173 -0
  17. package/dist/backend/services/translation-queue.js +39 -0
  18. package/dist/backend/services/translation-service.js +546 -0
  19. package/dist/backend/templates/handoff.js +32 -0
  20. package/dist/backend/templates/harness/architect-agent.js +12 -0
  21. package/dist/backend/templates/harness/claude-root.js +14 -0
  22. package/dist/backend/templates/harness/coder-agent.js +11 -0
  23. package/dist/backend/templates/harness/project-manager-agent.js +14 -0
  24. package/dist/backend/templates/harness/reviewer-agent.js +13 -0
  25. package/dist/backend/ws/translation-ws.js +35 -0
  26. package/dist/shared/types/harness.js +1 -0
  27. package/dist/shared/types/translation.js +5 -0
  28. package/dist/shared/validation/artifact-check.js +15 -1
  29. package/dist/shared/validation/language-detect.js +46 -0
  30. package/dist-frontend/assets/index-BNASqKEK.css +32 -0
  31. package/dist-frontend/assets/index-Bp49_End.js +58 -0
  32. package/dist-frontend/index.html +2 -2
  33. package/docs/cc-best-practices.md +93 -36
  34. package/docs/product-design.md +313 -1408
  35. package/docs/v1-architecture-design.md +500 -1153
  36. package/docs/v1-implementation-plan.md +783 -1604
  37. package/package.json +1 -1
  38. package/scripts/verify-package.mjs +8 -0
  39. package/dist/backend/templates/role-messaging-context.js +0 -44
  40. package/dist-frontend/assets/index-Bah6k-Ix.css +0 -32
  41. package/dist-frontend/assets/index-EMaQuIB6.js +0 -58
  42. package/docs/v1-message-bus-orchestration-design.md +0 -534
@@ -1,1431 +1,778 @@
1
- # VibeCodingMaster V1 架构设计方案
1
+ # V1 Architecture Design
2
2
 
3
- 版本:v0.2
4
- 日期:2026-05-29
5
- 状态:架构设计草案
6
- 依据:
3
+ Last updated: 2026-05-30
7
4
 
8
- - `docs/product-design.md`
9
- - `docs/cc-best-practices.md`
5
+ This document describes the architecture implemented by the current VCM codebase.
10
6
 
11
- ## 1. V1 架构目标
7
+ ## 1. System Overview
12
8
 
13
- VibeCodingMaster V1 只解决一个核心问题:
9
+ VCM is a local Node.js application with:
14
10
 
15
- > 做一个本地 GUI Session Cockpit,让用户可以在一个任务工作台中启动、切换、查看、输入和管理多个 Claude Code role sessions。
11
+ - Fastify backend.
12
+ - React frontend.
13
+ - `node-pty` terminal runtime.
14
+ - `xterm.js` terminal view.
15
+ - Claude Code role processes.
16
+ - API-driven message bus.
17
+ - Claude transcript JSONL tailer for translation.
16
18
 
17
- V1 不再把 CLI 或手动终端管理作为主交互模式。CLI 可以保留为开发、调试和 smoke test 入口,但用户主流程必须在 GUI 中完成。
19
+ Runtime shape:
18
20
 
19
- 核心能力:
20
-
21
- - 启动本地 GUI 应用。
22
- - 连接或选择本地 Git repo。
23
- - 检查 Claude Code 是否可用。
24
- - 创建任务 workspace。
25
- - 为任务创建 `.ai/handoffs/<task-slug>/`、`role-commands/`、`logs/`。
26
- - GUI 中展示 `project-manager / architect / coder / reviewer` role session tabs。
27
- - 用 embedded terminal 承载每个 Claude Code role session。
28
- - 支持用户在 GUI 内直接输入、确认权限、继续对话。
29
- - 将 terminal output 持续保存为 raw logs。
30
- - 在 GUI 中查看 role command 和 handoff artifacts。
31
- - 从 GUI 将 role command 发送到目标 role session。
32
- - 展示 session 状态、artifact 状态、任务状态和下一步建议。
33
- - 支持停止、重启、恢复单个 role session。
34
-
35
- V1 的成功标准不是“能不能用命令控制多个终端”,而是:
36
-
37
- > 用户是否可以不离开 GUI,就完成多 Claude Code sessions 的创建、切换、沟通、观察、日志保存和 handoff artifact 查看。
38
-
39
- ## 2. V1 非目标
40
-
41
- V1 明确不做:
42
-
43
- - SaaS 多用户协作。
44
- - 企业权限和审计。
45
- - 完整 Desktop 打包和自动更新。
46
- - 产品层翻译管线。
47
- - 独立翻译模型调用。
48
- - 自动生成完整 Task Spec。
49
- - 自动 Preflight Review。
50
- - 自动 Cross-Model Code Review。
51
- - 自动识别 public contract / test contract。
52
- - 自动执行 validation commands。
53
- - 自动创建 PR。
54
- - Jira / Linear / GitHub 双向同步。
55
- - 云端 session 托管。
56
- - 多 repo / 多任务并行调度。
57
- - 多 worktree 自动管理。
58
- - 让用户手动管理底层 terminal process。
59
-
60
- 这些能力应在 V1 的 GUI session cockpit 稳定后作为 V2/V3 能力演进。
61
-
62
- ## 3. 关键设计原则
63
-
64
- ### 3.1 GUI First
65
-
66
- V1 的主入口是本地 GUI。用户应该通过页面完成:
67
-
68
- - 选择 repo。
69
- - 创建任务。
70
- - 启动 role sessions。
71
- - 切换 `project-manager / architect / coder / reviewer`。
72
- - 直接在 session 面板中输入和查看输出。
73
- - 查看 role command、logs、handoff artifacts 和状态。
74
-
75
- CLI 只用于:
76
-
77
- - 启动 dev server。
78
- - 调试 backend。
79
- - 导出状态。
80
- - 执行自动化 smoke test。
81
-
82
- ### 3.2 Terminal Runtime Is Internal
83
-
84
- Claude Code 本质上是交互式终端程序,V1 通过 embedded terminal 承载它。
85
-
86
- 用户不需要理解:
21
+ ```text
22
+ browser
23
+ -> React GUI
24
+ -> HTTP API + WebSocket
25
+ -> Fastify backend
26
+ -> services
27
+ -> node-pty
28
+ -> claude --agent <role>
29
+ ```
87
30
 
88
- - pseudo-terminal。
89
- - process id。
90
- - terminal stream。
91
- - WebSocket message。
92
- - input/output bridge。
31
+ The app is local-first. It writes repository task state under `.vcm/`, handoff artifacts under `.ai/handoffs/`, app settings under `~/.vcm/settings.json`, and reads Claude transcript files under `~/.claude/projects/`.
93
32
 
94
- 产品界面表达的是任务、角色、会话、artifact、状态和验收。
33
+ ## 2. Processes And Ports
95
34
 
96
- ### 3.3 Controller-Mediated
35
+ Default ports:
97
36
 
98
- Project Manager session 不直接无限制控制其他 Claude Code sessions。
37
+ - backend / production GUI: `4173`
38
+ - Vite dev GUI: `5173`
99
39
 
100
- 正确模型:
40
+ Development:
101
41
 
102
42
  ```text
103
- Project Manager session
104
- -> writes role command artifact
105
- -> GUI shows command artifact to user
106
- -> user approves or sends from GUI
107
- -> VibeCodingMaster backend writes short instruction to target role session
108
- -> target role session executes
109
- -> backend records raw log
110
- -> handoff artifact becomes stable result
43
+ npm run dev
44
+ -> backend at http://127.0.0.1:4173
45
+ -> Vite dev server at http://127.0.0.1:5173
111
46
  ```
112
47
 
113
- 职责分离:
114
-
115
- - PM 决定发什么 role command。
116
- - GUI 让用户看见、确认和发送。
117
- - Backend 把短指令写入正确 role session。
118
- - Role agent 执行命令并产出 artifact。
119
- - Handoff artifacts 是跨 session 的事实源。
120
-
121
- ### 3.4 File Handoff First
122
-
123
- 角色交接不依赖聊天记忆。所有关键结果必须进入:
48
+ Production / npm package:
124
49
 
125
50
  ```text
126
- .ai/handoffs/<task-slug>/
51
+ vcm
52
+ -> backend serves dist-frontend at http://127.0.0.1:4173
127
53
  ```
128
54
 
129
- Terminal output 是调试信息;长期事实源是 handoff artifacts。
55
+ `src/main.ts` starts the backend and optionally starts Vite when `--dev` is passed.
130
56
 
131
- ### 3.5 One Task, One Workspace
57
+ ## 3. Frontend Architecture
132
58
 
133
- V1 默认:
59
+ Entry:
134
60
 
135
- ```text
136
- one task
137
- -> one GUI task workspace
138
- -> multiple role sessions
139
- -> one handoff directory
140
- -> one repo working directory
141
- ```
61
+ - `src/frontend/main.tsx`
62
+ - `src/frontend/app.tsx`
142
63
 
143
- V1 不为每个 role 创建独立 worktree。角色隔离由 role session、role prompt、permissions、handoff files 和流程顺序实现。
64
+ Main state lives in `App`:
144
65
 
145
- ### 3.6 Single-Writer Rule
66
+ - connected project
67
+ - recent repository paths
68
+ - harness status
69
+ - task list
70
+ - active task
71
+ - active role
72
+ - active workflow report
73
+ - active messages
74
+ - active orchestration state
75
+ - task-local event list
146
76
 
147
- 同一个任务中,默认只有一个 write-capable role 在编辑代码。
148
-
149
- 推荐顺序:
77
+ Layout:
150
78
 
151
79
  ```text
152
- project-manager -> architect -> coder -> reviewer
80
+ AppShell
81
+ sidebar: ProjectDashboard
82
+ main: TaskWorkspace or EmptyWorkspace
153
83
  ```
154
84
 
155
- 允许并行:
85
+ ### ProjectDashboard
156
86
 
157
- - read-only review。
158
- - log analysis。
159
- - artifact inspection。
160
- - 用户查看多个 session。
87
+ File:
161
88
 
162
- 不允许:
89
+ - `src/frontend/routes/project-dashboard.tsx`
163
90
 
164
- - `coder` 和 `reviewer` 同时大范围改代码。
165
- - PM 直接替代 coder 实现复杂功能。
166
- - reviewer 接管大范围实现。
91
+ Responsibilities:
167
92
 
168
- ### 3.7 State Can Be Rebuilt
93
+ - Render collapsible sidebar sections.
94
+ - Render repository connect form.
95
+ - Render repository summary.
96
+ - Render workflow panel.
97
+ - Render settings section with Messages, Events, Auto orchestration.
98
+ - Render harness status/actions.
99
+ - Render one-field task creation form.
100
+ - Render task list.
101
+ - Render Messages and Events modals.
169
102
 
170
- V1 的状态必须能从四类来源恢复:
103
+ All sections default collapsed. `Repository Path` opens when there is no selected task.
171
104
 
172
- ```text
173
- backend session registry
174
- terminal process state
175
- repo artifacts
176
- local VCM metadata
177
- ```
105
+ ### TaskWorkspace
178
106
 
179
- 不要把前端页面内存作为唯一状态源。
107
+ File:
180
108
 
181
- ## 4. 技术栈选择
109
+ - `src/frontend/routes/task-workspace.tsx`
182
110
 
183
- ### 4.1 主语言
111
+ Responsibilities:
184
112
 
185
- 推荐:
113
+ - Fetch task status, messages, and orchestration state.
114
+ - Poll those every three seconds.
115
+ - Render compact header with task title, branch, role tabs, and Refresh.
116
+ - Hold per-role permission mode selection.
117
+ - Render one `SessionConsole` per role but only show the active role.
118
+ - Emit workflow/messages/orchestration/events back to `App` so sidebar stays synchronized.
186
119
 
187
- ```text
188
- TypeScript + Node.js LTS
189
- ```
120
+ ### SessionConsole
190
121
 
191
- 原因:
122
+ File:
192
123
 
193
- - 前后端共享类型。
194
- - 适合本地 GUI、WebSocket 和进程编排。
195
- - 易于调用 `git`、`claude`、文件系统和终端 runtime。
196
- - 与后续 Desktop shell、Web UI 和自动化能力兼容。
124
+ - `src/frontend/components/session-console.tsx`
197
125
 
198
- ### 4.2 前端
126
+ Responsibilities:
199
127
 
200
- 推荐:
128
+ - Render role toolbar.
129
+ - Render embedded terminal for running sessions.
130
+ - Render empty/resume state for stopped sessions.
131
+ - Toggle translation panel.
132
+ - Split terminal and translation into two equal columns when translation is on.
201
133
 
202
- ```text
203
- React + Vite
204
- ```
134
+ ### TranslationPanel
205
135
 
206
- 原因:
136
+ File:
207
137
 
208
- - 适合构建本地单页工作台。
209
- - 与 xterm.js 集成成熟。
210
- - 本地开发体验快。
211
- - 后续可以被 Electron / Tauri / Desktop shell 包装。
138
+ - `src/frontend/components/translation-panel.tsx`
212
139
 
213
- 前端核心依赖:
140
+ Responsibilities:
214
141
 
215
- ```text
216
- @xterm/xterm
217
- @xterm/addon-fit
218
- @xterm/addon-web-links
219
- ```
142
+ - Load translation settings and prompt previews.
143
+ - Open translation WebSocket for the current terminal runtime session id.
144
+ - Render dark translation output panel.
145
+ - Render translation status: `ready`, `translating <elapsed>`, or `error`.
146
+ - Render preserved tool output as dim one-line rows.
147
+ - Render prose source while translating, then translated text after completion.
148
+ - Render user composer.
149
+ - Translate on `Enter`; newline on `Shift+Enter`.
150
+ - Replace Chinese input with English draft after translation.
151
+ - Send English draft to the active terminal.
152
+ - Provide panel-level `Auto-send`, `Settings`, and `Clear`.
220
153
 
221
- ### 4.3 后端
154
+ ## 4. Backend Architecture
222
155
 
223
- 推荐:
156
+ Entry:
224
157
 
225
- ```text
226
- Node.js HTTP server + WebSocket
227
- ```
158
+ - `src/backend/server.ts`
228
159
 
229
- 可选框架:
160
+ `createDefaultServerDeps()` wires:
230
161
 
231
- ```text
232
- Fastify Express
233
- ws
234
- ```
162
+ - filesystem adapter
163
+ - command runner
164
+ - git adapter
165
+ - Claude adapter
166
+ - app settings service
167
+ - node-pty runtime
168
+ - session registry
169
+ - artifact service
170
+ - harness service
171
+ - project service
172
+ - task service
173
+ - session service
174
+ - command dispatcher
175
+ - status service
176
+ - message service
177
+ - translation service
235
178
 
236
- 后端职责:
179
+ Fastify registers:
237
180
 
238
- - 提供 REST API。
239
- - 提供 terminal WebSocket。
240
- - 管理 pseudo-terminal lifecycle。
241
- - 读写 `.vcm` 和 `.ai/handoffs`。
242
- - 执行 git / claude 环境检查。
181
+ - project routes
182
+ - harness routes
183
+ - task routes
184
+ - session routes
185
+ - artifact routes
186
+ - message routes
187
+ - translation routes
188
+ - terminal WebSocket
189
+ - translation WebSocket
243
190
 
244
- ### 4.4 Terminal Runtime
191
+ ## 5. Repository Connection
245
192
 
246
- V1 推荐:
193
+ File:
247
194
 
248
- ```text
249
- node-pty
250
- ```
195
+ - `src/backend/services/project-service.ts`
196
+ - `src/backend/adapters/git-adapter.ts`
251
197
 
252
- 用途:
253
-
254
- - 启动 `claude --agent <role>`,并按用户选择追加权限参数。
255
- - 承载交互式输入输出。
256
- - 支持 backend 程序化写入 input。
257
- - 支持 backend 程序化监听 output。
258
- - 支持 terminal resize。
259
- - 支持退出码和进程状态。
260
- - 配合 xterm.js 提供接近真实终端的 GUI 体验。
261
-
262
- V1 的 terminal runtime 固定为:
198
+ Connect flow:
263
199
 
264
200
  ```text
265
- TerminalRuntime implementation = node-pty
201
+ POST /api/projects/connect
202
+ -> resolve path
203
+ -> check path exists
204
+ -> check .git marker directly
205
+ -> create .vcm/config.json
206
+ -> ensure .ai/handoffs and .vcm state dirs
207
+ -> read branch and dirty state
208
+ -> record recent repo path in ~/.vcm/settings.json
266
209
  ```
267
210
 
268
- 后续持久性增强应优先改进 backend lifecycle、session registry、raw logs 和恢复体验。
211
+ Git repository detection:
269
212
 
270
- ### 4.5 进程执行
213
+ - `.git` directory with `HEAD` is accepted.
214
+ - `.git` file with `gitdir:` pointer and target `HEAD` is accepted.
215
+ - This supports normal repositories and worktrees.
271
216
 
272
- 推荐:
217
+ Git metadata commands use:
273
218
 
274
219
  ```text
275
- execa
220
+ git -c safe.directory=<repoRoot> -c safe.directory=<realpath(repoRoot)> ...
276
221
  ```
277
222
 
278
- 用途:
223
+ VCM does not require global `safe.directory` configuration.
279
224
 
280
- - 调用 `git`。
281
- - 调用 `claude --version`。
282
- - 执行 shell-safe command。
283
- - 不用于承载 Claude Code 交互式 session;交互式 session 由 `node-pty` 负责。
225
+ ## 6. Task And Artifact Model
284
226
 
285
- ### 4.6 本地状态存储
227
+ File:
286
228
 
287
- V1 推荐 JSON 文件,而不是 SQLite。
229
+ - `src/backend/services/task-service.ts`
230
+ - `src/backend/services/artifact-service.ts`
231
+ - `src/shared/types/task.ts`
232
+ - `src/shared/types/artifact.ts`
288
233
 
289
- 推荐路径:
234
+ Task state:
290
235
 
291
236
  ```text
292
- .vcm/
293
- config.json
294
- tasks/
295
- <task-slug>.json
296
- sessions/
297
- <task-slug>.json
298
- app-state.json
237
+ .vcm/tasks/<task>.json
299
238
  ```
300
239
 
301
- 原因:
240
+ Each task stores:
302
241
 
303
- - V1 是本地单用户。
304
- - 状态量小。
305
- - 易于检查和恢复。
306
- - repo-local harness 理念一致。
242
+ - `taskSlug`
243
+ - optional `title`
244
+ - timestamps
245
+ - repo root
246
+ - branch at task creation
247
+ - handoff directory
248
+ - status
249
+ - optional spec path
307
250
 
308
- 后续加入多任务并发、后台 daemon 或复杂查询后,再迁移到 SQLite。
309
-
310
- ### 4.7 Markdown 处理
311
-
312
- V1 不需要复杂 Markdown AST。
313
-
314
- 建议:
315
-
316
- - 写入模板用字符串模板。
317
- - artifact completeness 用标题存在性检查。
318
- - 前端预览用简单 Markdown renderer。
319
- - 后续再引入 Markdown parser。
320
-
321
- ### 4.8 测试框架
322
-
323
- 推荐:
251
+ Task creation:
324
252
 
325
253
  ```text
326
- Vitest
327
- Playwright
254
+ POST /api/tasks
255
+ -> validate slug
256
+ -> create handoff directories
257
+ -> create artifact templates
258
+ -> write .vcm/tasks/<task>.json
328
259
  ```
329
260
 
330
- 测试重点:
331
-
332
- - slug/path 生成。
333
- - artifact schema 检查。
334
- - session status 推断。
335
- - REST API。
336
- - WebSocket terminal bridge。
337
- - role command dispatch。
338
- - GUI task workspace smoke test。
339
-
340
- ## 5. 进程架构
341
-
342
- V1 采用本地 Web GUI + 本地 Node backend。
261
+ Handoff directory:
343
262
 
344
263
  ```text
345
- User
346
- -> Browser / Desktop shell
347
- -> React Task Workspace
348
- -> xterm.js Role Session Console
349
- -> WebSocket terminal bridge
350
- -> REST API
351
- -> Local Node backend
352
- -> GitAdapter
353
- -> ClaudeAdapter
354
- -> FileSystemAdapter
355
- -> ArtifactService
356
- -> TaskService
357
- -> SessionRegistry
358
- -> TerminalRuntimeManager
359
- -> node-pty
360
- -> claude --agent project-manager
361
- -> claude --agent architect
362
- -> claude --agent coder
363
- -> claude --agent reviewer
264
+ .ai/handoffs/<task>/
265
+ role-commands/
266
+ architect.md
267
+ coder.md
268
+ reviewer.md
269
+ logs/
270
+ project-manager.log
271
+ architect.log
272
+ coder.log
273
+ reviewer.log
274
+ architecture-plan.md
275
+ implementation-log.md
276
+ validation-log.md
277
+ review-report.md
278
+ docs-sync-report.md
279
+ messages/
364
280
  ```
365
281
 
366
- Backend 是长生命周期本地进程。前端刷新后,应该能重新连接 backend 并恢复可见状态。
367
-
368
- ## 6. GUI 结构
282
+ Artifact checks are simple V1 checks:
369
283
 
370
- ### 6.1 Project Dashboard
284
+ - missing
285
+ - placeholder / incomplete
286
+ - ok
371
287
 
372
- 职责:
288
+ They are used for workflow readiness, not content quality judgment.
373
289
 
374
- - 显示已连接 repo。
375
- - 显示 active tasks。
376
- - 显示每个任务的 severity、required role route、session health。
377
- - 显示 blocked tasks、recent validation failures、known issues、harness health。
378
- - 提供进入 Task Workspace 的入口。
290
+ ## 7. Workflow Computation
379
291
 
380
- ### 6.2 Task Workspace
292
+ File:
381
293
 
382
- V1 的主界面。
294
+ - `src/backend/services/status-service.ts`
383
295
 
384
- 推荐布局:
296
+ Endpoint:
385
297
 
386
298
  ```text
387
- ┌──────────────────────────────────────────────────────────────────────────────┐
388
- │ Header: repo / branch / task / severity / route / overall status │
389
- ├───────────────┬──────────────────────────────────────────────────────────────┤
390
- │ Task Nav │ Role Sessions │
391
- │ │ tabs: PM | Architect | Coder | Reviewer │
392
- │ Session State │ embedded terminal │
393
- │ Known Issues │ session ops │
394
- │ │ input handled by terminal │
395
- ├───────────────┴──────────────────────────────────────────────────────────────┤
396
- │ Event Log: PM wrote architect.md | Coder waiting for approval │
397
- └──────────────────────────────────────────────────────────────────────────────┘
299
+ GET /api/tasks/:taskSlug/status
398
300
  ```
399
301
 
400
- ### 6.3 Session Console
401
-
402
- 每个 role session 对应一个 console。
403
-
404
- 能力:
405
-
406
- - 展示 role name。
407
- - 展示 command,例如 `claude --agent architect`。
408
- - 展示 xterm.js terminal viewport。
409
- - 支持输入、复制、选择文本、resize。
410
- - 展示状态:not started / starting / running / waiting / blocked / done / crashed。
411
- - 支持 start / stop / restart。
412
- - 显示 raw log path。
413
-
414
- ### 6.4 Handoff Files
415
-
416
- V1 不在主界面展示独立 artifact inspector。handoff artifacts 和 role commands 仍保存在任务目录中,作为 session 之间的文件级事实源;GUI 的主工作区优先展示 embedded terminal。
417
-
418
- ### 6.5 Event Log
419
-
420
- 展示产品级事件,不展示完整 terminal stream。
421
-
422
- 示例:
302
+ The workflow has five steps:
423
303
 
424
304
  ```text
425
- PM session started
426
- PM wrote architect.md
427
- User sent architect command
428
- Architect wrote architecture-plan.md
429
- Coder waiting for permission
430
- Reviewer missing validation evidence
431
- ```
432
-
433
- ## 7. Terminal Runtime
434
-
435
- ### 7.1 Role Session 启动命令
436
-
437
- 每个 role session 启动对应 Claude Code:
438
-
439
- ```bash
440
- claude --agent project-manager
441
- claude --agent architect
442
- claude --agent coder
443
- claude --agent reviewer
305
+ architecture-plan -> implementation -> review -> docs-sync -> final-acceptance
444
306
  ```
445
307
 
446
- ### 7.2 TerminalRuntime 接口
308
+ Step readiness:
447
309
 
448
- V1 后端应抽象 terminal runtime,避免把 node-pty 写死到上层业务。
310
+ - Architecture is ready until `architecture-plan.md` is ok.
311
+ - Implementation is blocked until architecture is ok.
312
+ - Review is blocked until `implementation-log.md` and `validation-log.md` are ok.
313
+ - Docs Sync is blocked until `review-report.md` is ok.
314
+ - PM Final is blocked until `docs-sync-report.md` is ok.
449
315
 
450
- ```ts
451
- interface TerminalRuntime {
452
- createSession(input: CreateTerminalSessionInput): Promise<TerminalSession>;
453
- getSession(sessionId: string): TerminalSession | undefined;
454
- listSessions(taskSlug?: string): TerminalSessionSummary[];
455
- write(sessionId: string, data: string): void;
456
- resize(sessionId: string, cols: number, rows: number): void;
457
- stop(sessionId: string): Promise<void>;
458
- restart(sessionId: string): Promise<TerminalSession>;
459
- subscribe(sessionId: string, listener: TerminalEventListener): Unsubscribe;
460
- }
461
- ```
316
+ The report is displayed in the sidebar `Workflow` section.
462
317
 
463
- ### 7.3 node-pty 实现
318
+ ## 8. Session Runtime
464
319
 
465
- `NodePtyTerminalRuntime` 负责:
320
+ Files:
466
321
 
467
- - spawn `claude`。
468
- - 设置 cwd 为 repo root。
469
- - 设置 env。
470
- - 捕获 stdout/stderr stream。
471
- - 将 stream 推送给 WebSocket subscribers。
472
- - 将 stream append 到 role log。
473
- - 监听 exit code。
474
- - 更新 session status。
475
- - 支持 resize。
322
+ - `src/backend/services/session-service.ts`
323
+ - `src/backend/adapters/claude-adapter.ts`
324
+ - `src/backend/runtime/node-pty-runtime.ts`
325
+ - `src/backend/runtime/session-registry.ts`
476
326
 
477
- ### 7.4 WebSocket Terminal Bridge
327
+ Session service owns role session lifecycle:
478
328
 
479
- WebSocket 负责前后端双向通信。
329
+ - start
330
+ - resume
331
+ - restart
332
+ - stop
333
+ - list
334
+ - get
480
335
 
481
- 推荐消息:
336
+ Runtime session id and Claude session id are different:
482
337
 
483
- ```json
484
- { "type": "input", "sessionId": "session_123", "data": "hello\n" }
485
- { "type": "resize", "sessionId": "session_123", "cols": 120, "rows": 32 }
486
- { "type": "output", "sessionId": "session_123", "data": "..." }
487
- { "type": "status", "sessionId": "session_123", "status": "running" }
488
- { "type": "exit", "sessionId": "session_123", "exitCode": 0 }
489
- ```
338
+ - runtime session id identifies the local `node-pty` process in VCM.
339
+ - Claude session id identifies the Claude Code conversation for resume/transcript lookup.
490
340
 
491
- ### 7.5 Role Command Dispatch
492
-
493
- 长 role command 不直接粘贴进 terminal。V1 应先写入文件,再向目标 session 发送短指令。
494
-
495
- 任务身份以 VCM `taskSlug` 为准。Project Manager 必须只写入当前 task 的 canonical handoff directory:
341
+ Start:
496
342
 
497
343
  ```text
498
- .ai/handoffs/<task-slug>/role-commands/<role>.md
344
+ claude --agent <role> --session-id <uuid>
499
345
  ```
500
346
 
501
- 如果 task slug 不符合用户意图,Project Manager 必须要求用户创建或选择正确的 VCM task,不能自行创建 `.ai/handoffs/<other-task>/` 来绕过当前 task。
502
-
503
- 示例:
347
+ Resume:
504
348
 
505
349
  ```text
506
- Please read and execute the role command at: .ai/handoffs/<task-slug>/role-commands/architect.md
350
+ claude --agent <role> --resume <uuid>
507
351
  ```
508
352
 
509
- 发送流程:
353
+ Permission flags:
510
354
 
511
355
  ```text
512
- GUI Send Command button
513
- -> POST /api/tasks/:taskSlug/sessions/:role/dispatch
514
- -> backend checks role command file exists, non-empty, and not placeholder/draft
515
- -> backend writes short instruction to terminal runtime
516
- -> backend records dispatch event
356
+ --permission-mode bypassPermissions
357
+ --dangerously-skip-permissions
517
358
  ```
518
359
 
519
- ### 7.6 Programmatic I/O Boundary
520
-
521
- 通过 `node-pty`,backend 技术上可以对 Claude Code session 做两类程序化操作:
360
+ Session persistence:
522
361
 
523
362
  ```text
524
- write input:
525
- runtime.write(sessionId, "Please read ...\r")
526
-
527
- read output:
528
- runtime.subscribe(sessionId, listener)
363
+ .vcm/sessions/<task>.json
529
364
  ```
530
365
 
531
- V1 允许:
366
+ The persisted record includes:
532
367
 
533
- - 用户点击 Send Command 后,backend 写入短指令。
534
- - 用户在 GUI terminal 中输入后,backend 转发输入。
535
- - 用户在 Start / Restart 前选择 Claude Code 权限模式。
536
- - backend 监听 output,写入 raw log。
537
- - backend 根据进程退出、输出活动和用户操作更新轻量状态。
538
- - backend 在 GUI 中提示 waiting / crashed / exited 等状态。
368
+ - runtime session id
369
+ - Claude session id
370
+ - transcript path
371
+ - role
372
+ - status
373
+ - command display
374
+ - permission mode
375
+ - cwd
376
+ - pid
377
+ - raw log path
378
+ - role command path
379
+ - handoff artifact path
539
380
 
540
- V1 不允许:
381
+ If a runtime process is gone but the role has a Claude session id, `getRoleSession` returns a recoverable `resumable` status.
541
382
 
542
- - 自动确认 Claude Code 权限提示。
543
- - PM 写完 command 后自动发送给下一个 role。
544
- - Architect 完成后自动触发 Coder。
545
- - Coder 完成后自动触发 Reviewer。
546
- - 根据 terminal output 自动执行高风险下一步。
383
+ ## 9. Terminal Runtime
547
384
 
548
- 更高级的自动编排必须进入后续版本,并带有人类 approval gate、审计日志和明确 stop conditions。
385
+ File:
549
386
 
550
- ### 7.7 Claude Code Permission Modes
387
+ - `src/backend/runtime/node-pty-runtime.ts`
551
388
 
552
- V1 在 Task Workspace 的每个 role session 控制区提供三档权限模式:
389
+ The runtime:
553
390
 
554
- ```text
555
- 默认
556
- -> claude --agent <role>
391
+ - spawns `node-pty`
392
+ - sets `TERM=xterm-256color`
393
+ - sets color-friendly env vars
394
+ - appends raw PTY output to `.ai/handoffs/<task>/logs/<role>.log`
395
+ - emits terminal output/input/exit events to WebSocket subscribers
396
+ - replays the log on terminal WebSocket subscribe
557
397
 
558
- bypassPermissions
559
- -> claude --agent <role> --permission-mode bypassPermissions
398
+ Terminal WebSocket:
560
399
 
561
- --dangerously-skip-permissions
562
- -> claude --agent <role> --dangerously-skip-permissions
400
+ ```text
401
+ GET /ws/terminal/:sessionId
563
402
  ```
564
403
 
565
- 规则:
404
+ Client messages:
566
405
 
567
- - 权限模式是用户显式选择,不由 Project Manager 或 backend 自动切换。
568
- - 权限模式只影响 Start / Restart 创建的新 Claude Code 进程。
569
- - `RoleSessionRecord.permissionMode` 必须记录实际启动模式。
570
- - GUI 显示实际 command,方便用户确认当前 session 的权限状态。
406
+ - input
407
+ - resize
571
408
 
572
- ## 8. Repo Artifacts
409
+ Server messages:
573
410
 
574
- V1 需要创建和维护:
411
+ - output
412
+ - exit
413
+ - error
575
414
 
576
- ```text
577
- .ai/
578
- handoffs/
579
- <task-slug>/
580
- role-commands/
581
- architect.md
582
- coder.md
583
- reviewer.md
584
- logs/
585
- project-manager.log
586
- architect.log
587
- coder.log
588
- reviewer.log
589
- architecture-plan.md
590
- implementation-log.md
591
- validation-log.md
592
- review-report.md
593
-
594
- .vcm/
595
- config.json
596
- tasks/
597
- <task-slug>.json
598
- sessions/
599
- <task-slug>.json
600
- app-state.json
601
- ```
415
+ ## 10. Message Bus
602
416
 
603
- V1 可以不自动创建 `.ai/task-specs/`,但如果 Project Manager 已经生成 task spec,应在 task metadata 中记录路径。
417
+ Files:
604
418
 
605
- ## 9. 模块划分
419
+ - `src/backend/services/message-service.ts`
420
+ - `src/backend/templates/message-envelope.ts`
421
+ - `src/cli/vcmctl.ts`
606
422
 
607
- 推荐代码结构:
423
+ State:
608
424
 
609
425
  ```text
610
- src/
611
- main.ts
612
-
613
- frontend/
614
- app.tsx
615
- routes/
616
- project-dashboard.tsx
617
- task-workspace.tsx
618
- components/
619
- app-shell.tsx
620
- task-nav.tsx
621
- role-session-tabs.tsx
622
- session-console.tsx
623
- event-log.tsx
624
- status-badge.tsx
625
- terminal/
626
- xterm-view.tsx
627
- terminal-client.ts
628
- state/
629
- api-client.ts
630
- task-store.ts
631
- session-store.ts
632
-
633
- backend/
634
- server.ts
635
- api/
636
- project-routes.ts
637
- task-routes.ts
638
- session-routes.ts
639
- artifact-routes.ts
640
- ws/
641
- terminal-ws.ts
642
- runtime/
643
- terminal-runtime.ts
644
- node-pty-runtime.ts
645
- session-registry.ts
646
- services/
647
- project-service.ts
648
- task-service.ts
649
- session-service.ts
650
- artifact-service.ts
651
- command-dispatcher.ts
652
- status-service.ts
653
- adapters/
654
- git-adapter.ts
655
- claude-adapter.ts
656
- filesystem.ts
657
- command-runner.ts
658
- validation/
659
- environment-check.ts
660
- artifact-check.ts
661
- slug-check.ts
662
- templates/
663
- handoff.ts
664
- role-command.ts
665
- types/
666
- project.ts
667
- task.ts
668
- session.ts
669
- role.ts
670
- artifact.ts
671
- terminal.ts
672
- api.ts
673
-
674
- tests/
675
- unit/
676
- integration/
677
- e2e/
426
+ .vcm/messages/<task>.jsonl
427
+ .vcm/orchestration/<task>.json
428
+ .ai/handoffs/<task>/messages/<message-id>.md
678
429
  ```
679
430
 
680
- ### 9.1 Frontend App
681
-
682
- 职责:
683
-
684
- - 渲染 GUI。
685
- - 调用 REST API。
686
- - 连接 terminal WebSocket。
687
- - 管理 active task 和 active role tab state。
688
-
689
- ### 9.2 SessionConsole
690
-
691
- 职责:
692
-
693
- - 渲染 xterm.js。
694
- - 连接指定 role session 的 WebSocket stream。
695
- - 将用户输入写回 backend。
696
- - 处理 resize。
697
- - 显示 start / stop / restart 操作。
698
-
699
- ### 9.3 EventLog
700
-
701
- 职责:
702
-
703
- - 展示任务级运行事件。
704
- - 保持短日志形态,不占用 terminal 主视野。
705
-
706
- ### 9.4 Backend Server
707
-
708
- 职责:
709
-
710
- - 提供 REST API。
711
- - 提供 WebSocket endpoint。
712
- - 管理 backend service lifecycle。
713
- - Serve frontend static assets。
714
-
715
- ### 9.5 TerminalRuntimeManager
716
-
717
- 职责:
718
-
719
- - 管理 role session 生命周期。
720
- - 启动 Claude Code pty。
721
- - 转发 terminal input/output。
722
- - 保存 raw logs。
723
- - 维护 runtime status。
724
-
725
- ### 9.6 SessionRegistry
726
-
727
- 职责:
728
-
729
- - 保存当前 backend 进程中的 live sessions。
730
- - 对比 `.vcm/sessions/<task-slug>.json`。
731
- - 支持页面刷新后的 session 查询。
732
- - 标记 crashed / exited / missing。
431
+ Policy:
733
432
 
734
- ### 9.7 ArtifactService
433
+ - User can only send `user-request` to `project-manager`.
434
+ - PM can send `task`, `question`, `review-request`, `revise`, `cancel` to non-PM roles.
435
+ - Non-PM roles can send `result`, `question`, `blocked`, `finding` to PM.
735
436
 
736
- 职责:
737
-
738
- - 创建 handoff directory。
739
- - 创建 `role-commands/` 和 `logs/`。
740
- - 创建 artifact 模板。
741
- - 检查 artifact 是否存在。
742
- - 检查 artifact 是否包含关键标题。
743
- - 保存 role command。
744
- - 追加 raw terminal logs。
745
-
746
- ### 9.8 CommandDispatcher
747
-
748
- 职责:
749
-
750
- - 读取 `role-commands/<role>.md`。
751
- - 校验目标 role session 是否 running。
752
- - 将短指令写入目标 terminal session。
753
- - 记录 dispatch event。
754
-
755
- 原则:
756
-
757
- - 不发送未落盘的长 prompt。
758
- - 每次 dispatch 都必须有 role command artifact。
759
- - 高风险 command 后续可增加用户确认 gate。
760
-
761
- ## 10. API 设计
762
-
763
- ### 10.1 Project API
437
+ Manual mode:
764
438
 
765
439
  ```text
766
- GET /api/health
767
- POST /api/projects/connect
768
- GET /api/projects/current
769
- GET /api/projects/harness
440
+ send -> pending_approval -> Stage -> staged
770
441
  ```
771
442
 
772
- `POST /api/projects/connect`:
443
+ `Stage` writes:
773
444
 
774
- ```json
775
- {
776
- "repoPath": "/path/to/repo"
777
- }
445
+ ```text
446
+ Read and handle VCM message <id> at <bodyPath>
778
447
  ```
779
448
 
780
- ### 10.2 Task API
449
+ It does not append Enter.
450
+
451
+ Auto mode:
781
452
 
782
453
  ```text
783
- GET /api/tasks
784
- POST /api/tasks
785
- GET /api/tasks/:taskSlug
786
- GET /api/tasks/:taskSlug/status
454
+ send -> delivered
787
455
  ```
788
456
 
789
- `POST /api/tasks`:
790
-
791
- ```json
792
- {
793
- "taskSlug": "fix-refund-coupon",
794
- "title": "Fix refund coupon behavior",
795
- "specPath": ".ai/task-specs/fix-refund-coupon.md"
796
- }
797
- ```
457
+ The backend writes a `[VCM MESSAGE]` envelope to the target terminal and appends Enter.
798
458
 
799
- ### 10.3 Session API
459
+ The backend still exposes pause/resume orchestration API routes and stores `paused` for compatibility. The current GUI only toggles `mode` between `manual` and `auto`.
800
460
 
801
- ```text
802
- GET /api/tasks/:taskSlug/sessions
803
- POST /api/tasks/:taskSlug/sessions/:role/start
804
- POST /api/tasks/:taskSlug/sessions/:role/stop
805
- POST /api/tasks/:taskSlug/sessions/:role/resume
806
- POST /api/tasks/:taskSlug/sessions/:role/restart
807
- POST /api/tasks/:taskSlug/sessions/:role/resize
808
- POST /api/tasks/:taskSlug/sessions/:role/dispatch
809
- ```
461
+ ## 11. Role Command Compatibility
810
462
 
811
- ### 10.4 Artifact API
463
+ Files:
812
464
 
813
- ```text
814
- GET /api/tasks/:taskSlug/artifacts
815
- GET /api/tasks/:taskSlug/artifacts/:artifactName
816
- GET /api/tasks/:taskSlug/role-commands/:role
817
- PUT /api/tasks/:taskSlug/role-commands/:role
818
- GET /api/tasks/:taskSlug/logs/:role
819
- ```
465
+ - `src/backend/services/command-dispatcher.ts`
466
+ - `src/backend/api/session-routes.ts`
467
+ - `src/backend/api/artifact-routes.ts`
820
468
 
821
- ### 10.5 Terminal WebSocket
469
+ Compatibility endpoint:
822
470
 
823
471
  ```text
824
- WS /ws/tasks/:taskSlug/sessions/:role
472
+ POST /api/tasks/:taskSlug/sessions/:role/dispatch
825
473
  ```
826
474
 
827
- Client -> server:
475
+ Dispatchable roles:
828
476
 
829
- ```json
830
- { "type": "input", "data": "..." }
831
- { "type": "resize", "cols": 120, "rows": 32 }
832
- ```
477
+ - `architect`
478
+ - `coder`
479
+ - `reviewer`
833
480
 
834
- Server -> client:
481
+ The dispatcher:
835
482
 
836
- ```json
837
- { "type": "output", "data": "..." }
838
- { "type": "status", "status": "running" }
839
- { "type": "exit", "exitCode": 0 }
840
- { "type": "error", "message": "Claude Code is not available" }
841
- ```
483
+ 1. Loads the task.
484
+ 2. Reads the role command artifact.
485
+ 3. Rejects missing, empty, or placeholder role commands.
486
+ 4. Resolves primary command path `role-commands/<role>.md`, with legacy fallback `<role>-command.md`.
487
+ 5. Writes `Please read and execute the role command at: <path>` to the target terminal and submits Enter.
842
488
 
843
- ## 11. 数据模型
489
+ This is a compatibility path. The preferred V1 coordination path is `vcmctl` message bus.
844
490
 
845
- ### 11.1 ProjectConfig
491
+ ## 12. Harness Service
846
492
 
847
- ```json
848
- {
849
- "version": 1,
850
- "repoRoot": "/path/to/repo",
851
- "defaultRoles": ["project-manager", "architect", "coder", "reviewer"],
852
- "handoffRoot": ".ai/handoffs",
853
- "stateRoot": ".vcm",
854
- "terminalBackend": "node-pty",
855
- "claudeCommand": "claude"
856
- }
857
- ```
858
-
859
- ### 11.2 TaskRecord
493
+ File:
860
494
 
861
- ```json
862
- {
863
- "version": 1,
864
- "taskSlug": "fix-refund-coupon",
865
- "title": "Fix refund coupon behavior",
866
- "createdAt": "2026-05-29T00:00:00+08:00",
867
- "updatedAt": "2026-05-29T00:00:00+08:00",
868
- "repoRoot": "/path/to/repo",
869
- "branch": "feature/refund-coupon",
870
- "handoffDir": ".ai/handoffs/fix-refund-coupon",
871
- "status": "created",
872
- "specPath": ".ai/task-specs/fix-refund-coupon.md"
873
- }
874
- ```
495
+ - `src/backend/services/harness-service.ts`
875
496
 
876
- ### 11.3 RoleSessionRecord
497
+ Harness files:
877
498
 
878
- ```json
879
- {
880
- "id": "session_architect_123",
881
- "claudeSessionId": "00000000-0000-4000-8000-000000000001",
882
- "taskSlug": "fix-refund-coupon",
883
- "role": "architect",
884
- "status": "running",
885
- "command": "claude --agent architect --permission-mode bypassPermissions",
886
- "permissionMode": "bypassPermissions",
887
- "cwd": "/path/to/repo",
888
- "terminalBackend": "node-pty",
889
- "pid": 12345,
890
- "logPath": ".ai/handoffs/fix-refund-coupon/logs/architect.log",
891
- "roleCommandPath": ".ai/handoffs/fix-refund-coupon/role-commands/architect.md",
892
- "handoffArtifactPath": ".ai/handoffs/fix-refund-coupon/architecture-plan.md",
893
- "startedAt": "2026-05-29T00:00:00+08:00",
894
- "lastOutputAt": "2026-05-29T00:03:14+08:00",
895
- "exitCode": null
896
- }
499
+ ```text
500
+ CLAUDE.md
501
+ .claude/agents/project-manager.md
502
+ .claude/agents/architect.md
503
+ .claude/agents/coder.md
504
+ .claude/agents/reviewer.md
897
505
  ```
898
506
 
899
- ### 11.4 TaskSessionRecord
507
+ Managed block:
900
508
 
901
- ```json
902
- {
903
- "version": 1,
904
- "taskSlug": "fix-refund-coupon",
905
- "updatedAt": "2026-05-29T00:03:14+08:00",
906
- "roles": {
907
- "project-manager": {
908
- "id": "session_pm_123",
909
- "status": "running"
910
- },
911
- "architect": {
912
- "id": "session_architect_123",
913
- "claudeSessionId": "00000000-0000-4000-8000-000000000001",
914
- "status": "running",
915
- "record": "{...RoleSessionRecord}"
916
- },
917
- "coder": {
918
- "id": null,
919
- "status": "not_started"
920
- },
921
- "reviewer": {
922
- "id": null,
923
- "status": "not_started"
924
- }
925
- }
926
- }
509
+ ```md
510
+ <!-- VCM:BEGIN version=1 -->
511
+ ...
512
+ <!-- VCM:END -->
927
513
  ```
928
514
 
929
- ### 11.5 RoleStatus
515
+ The service:
930
516
 
931
- V1 状态枚举:
517
+ - checks whether files exist
518
+ - checks whether a managed block exists
519
+ - compares the managed block with the current template
520
+ - plans `create`, `insert`, `update`, or `ok`
521
+ - applies only the planned managed-block change
932
522
 
933
- ```text
934
- not_started
935
- starting
936
- running
937
- waiting
938
- blocked
939
- done
940
- resumable
941
- crashed
942
- exited
943
- missing
944
- unknown
945
- ```
523
+ It must not overwrite user content outside the VCM block.
946
524
 
947
- V1 很难可靠判断 Claude Code 内部语义状态,因此:
525
+ ## 13. Translation Architecture
948
526
 
949
- - `not_started` 来自 metadata。
950
- - `running` 来自 live pty。
951
- - `exited/crashed` 来自 process exit。
952
- - `missing` 来自 metadata 存在但 live process 不存在。
953
- - `resumable` 来自 metadata 中存在 `claudeSessionId`,但当前没有 live pty。
954
- - `waiting/blocked/done` 可以先由用户或 role output marker 显式标记。
955
- - 自动推断只能作为 best-effort。
527
+ Files:
956
528
 
957
- ### 11.6 TerminalEvent
529
+ - `src/backend/services/translation-service.ts`
530
+ - `src/backend/services/translation-queue.ts`
531
+ - `src/backend/services/translation-prompts.ts`
532
+ - `src/backend/services/claude-transcript-service.ts`
533
+ - `src/backend/adapters/translation-provider.ts`
534
+ - `src/backend/ws/translation-ws.ts`
535
+ - `src/backend/api/translation-routes.ts`
536
+ - `src/frontend/components/translation-panel.tsx`
537
+ - `src/frontend/components/translation-settings-modal.tsx`
958
538
 
959
- ```json
960
- {
961
- "id": "evt_123",
962
- "sessionId": "session_architect_123",
963
- "taskSlug": "fix-refund-coupon",
964
- "role": "architect",
965
- "type": "output",
966
- "timestamp": "2026-05-29T00:03:14+08:00",
967
- "data": "..."
968
- }
969
- ```
970
-
971
- ## 12. 核心工作流
539
+ ### Settings
972
540
 
973
- ### 12.1 启动应用
541
+ Settings service:
974
542
 
975
- ```text
976
- vcm dev 或桌面入口
977
- -> start local Node backend
978
- -> serve React frontend
979
- -> open browser / desktop shell
980
- -> show Project Dashboard
981
- ```
543
+ - `src/backend/services/app-settings-service.ts`
982
544
 
983
- ### 12.2 连接 repo
545
+ Storage:
984
546
 
985
547
  ```text
986
- User selects repo path
987
- -> POST /api/projects/connect
988
- -> check git repo
989
- -> check claude --version
990
- -> create .vcm/config.json
991
- -> create .ai/handoffs/
992
- -> show branch and dirty warning
548
+ ~/.vcm/settings.json
993
549
  ```
994
550
 
995
- ### 12.3 创建任务 workspace
551
+ Stored data:
996
552
 
997
- ```text
998
- User clicks New Task
999
- -> enter task slug / title
1000
- -> POST /api/tasks
1001
- -> create .ai/handoffs/<task-slug>/
1002
- -> create role-commands/
1003
- -> create logs/
1004
- -> create artifact templates
1005
- -> create .vcm/tasks/<task-slug>.json
1006
- -> open Task Workspace
1007
- ```
553
+ - translation settings
554
+ - translation secrets
555
+ - recent repository paths, max 5
1008
556
 
1009
- ### 12.4 启动 role session
557
+ Legacy migration:
1010
558
 
1011
- ```text
1012
- User clicks Start project-manager
1013
- -> POST /api/tasks/<task-slug>/sessions/project-manager/start
1014
- -> NodePtyTerminalRuntime spawns claude --agent project-manager
1015
- -> backend writes RoleSessionRecord
1016
- -> frontend opens WebSocket
1017
- -> xterm.js renders output
1018
- ```
559
+ - `~/.vibe-coding-master/settings.json`
560
+ - `~/.vibe-coding-master/translation.json`
1019
561
 
1020
- ### 12.5 用户切换和沟通
562
+ ### Provider
1021
563
 
1022
- ```text
1023
- User clicks Architect tab
1024
- -> frontend switches active role
1025
- -> if session exists, subscribe to WebSocket
1026
- -> if session not started, show Start button
1027
- -> user types directly into terminal
1028
- ```
1029
-
1030
- ### 12.6 下发 role command
564
+ Provider type:
1031
565
 
1032
566
  ```text
1033
- PM writes architect.md
1034
- -> User can inspect the command file in the task directory when needed
1035
- -> User clicks Send Command in the target role toolbar
1036
- -> backend validates command file
1037
- -> backend writes short instruction to architect pty
1038
- -> backend records dispatch event
567
+ openai-compatible
1039
568
  ```
1040
569
 
1041
- ### 12.7 查看 artifacts
570
+ It uses chat completions and builds the URL from `baseUrl`.
1042
571
 
1043
- ```text
1044
- V1 main GUI does not render artifact status.
1045
- Handoff files remain available in the task directory and backend services.
1046
- ```
572
+ Prompt keys:
1047
573
 
1048
- ### 12.8 重启 role session
574
+ - `zh-to-en`
575
+ - `zh-to-en-with-context`
576
+ - `en-to-zh`
1049
577
 
1050
- ```text
1051
- User clicks Restart coder
1052
- -> backend stops existing coder pty if any
1053
- -> preserves logs and artifacts
1054
- -> starts new claude --agent coder
1055
- -> updates session record
1056
- -> frontend reconnects WebSocket
1057
- ```
578
+ ### Claude Output Path
1058
579
 
1059
- ## 13. Artifact Schema Checks
580
+ Output translation reads Claude transcript JSONL, not terminal raw output.
1060
581
 
1061
- V1 不判断内容质量,但必须检查关键 artifact 是否存在且包含必要标题。
582
+ Resolution order:
1062
583
 
1063
- ### 13.1 architecture-plan.md
584
+ 1. persisted `RoleSessionRecord.transcriptPath`
585
+ 2. `claudeTranscriptPath(session.cwd, session.claudeSessionId)`
586
+ 3. scan `~/.claude/projects/*/<sessionId>.jsonl` and choose newest mtime
1064
587
 
1065
- 最低标题:
588
+ Tailer:
1066
589
 
1067
- ```text
1068
- Architecture Summary
1069
- Task Classification
1070
- Required Role Route
1071
- Modules / Files
1072
- File Responsibilities
1073
- Public Surface Contract
1074
- Phases
1075
- Validation Per Phase
1076
- Risks
1077
- Stop Conditions
1078
- ```
590
+ - validates file exists
591
+ - can replay history since session start minus a grace window
592
+ - uses `fs.watch`
593
+ - also polls every 500ms
594
+ - parses only complete newline-delimited JSON records
1079
595
 
1080
- ### 13.2 implementation-log.md
596
+ Parsed transcript events:
1081
597
 
1082
- 最低标题:
598
+ - `text`
599
+ - `thinking`
600
+ - `question`
601
+ - `todo`
602
+ - `agent`
603
+ - `tool_use`
604
+ - `tool_result`
1083
605
 
1084
- ```text
1085
- Summary
1086
- Files Changed
1087
- Public Surface Changed
1088
- Tests Added / Updated
1089
- Validation Run
1090
- Deviations From Architecture Plan
1091
- Follow-ups
1092
- ```
606
+ Translation service behavior:
1093
607
 
1094
- ### 13.3 validation-log.md
608
+ - ignores thinking
609
+ - translates text/question/todo/agent as prose
610
+ - preserves tool_use/tool_result as tool-output
611
+ - queues translation per runtime session id
612
+ - emits WebSocket `translation-entry`
613
+ - emits WebSocket `translation-status`
1095
614
 
1096
- 最低要求:
615
+ ### User Input Path
1097
616
 
1098
617
  ```text
1099
- 至少存在一个 validation entry,或明确说明 not run + reason。
618
+ textarea -> POST translation/input -> provider -> English draft in the same textarea -> optional send
1100
619
  ```
1101
620
 
1102
- ### 13.4 review-report.md
1103
-
1104
- 最低标题:
621
+ Send path:
1105
622
 
1106
623
  ```text
1107
- Summary
1108
- Role / Handoff Compliance
1109
- Scope Review
1110
- Architecture Review
1111
- Public Contract Review
1112
- Test Review
1113
- Validation Evidence
1114
- Findings
1115
- Decision
624
+ POST translation/send -> runtime.write(session.id, englishText + "\r")
1116
625
  ```
1117
626
 
1118
- ## 14. 错误处理
627
+ The backend strips trailing newlines before appending `\r`.
1119
628
 
1120
- ### 14.1 Claude Code 不存在
629
+ ## 14. API Surface
1121
630
 
1122
- 连接 repo 或启动 role session 前失败,并在 GUI 中提示:
631
+ Project:
1123
632
 
1124
633
  ```text
1125
- Claude Code command is not available.
1126
- Install Claude Code or configure the claude command path.
634
+ GET /api/health
635
+ GET /api/projects/recent
636
+ GET /api/projects/current
637
+ POST /api/projects/connect
1127
638
  ```
1128
639
 
1129
- ### 14.2 Repo 无效
1130
-
1131
- `POST /api/projects/connect` 必须检查 Git repo。
1132
-
1133
- 失败时提示:
640
+ Harness:
1134
641
 
1135
642
  ```text
1136
- Selected path is not a Git repository.
643
+ GET /api/projects/harness
644
+ POST /api/projects/harness/apply
1137
645
  ```
1138
646
 
1139
- ### 14.3 Role session 已存在
1140
-
1141
- 默认不重复启动。
1142
-
1143
- GUI 显示:
1144
-
1145
- - Focus existing session。
1146
- - Restart session。
1147
- - Stop session。
1148
-
1149
- ### 14.4 role command 缺失
1150
-
1151
- 发送 command 必须失败:
647
+ Tasks:
1152
648
 
1153
649
  ```text
1154
- Missing .ai/handoffs/<task-slug>/role-commands/<role>.md
1155
- Ask project-manager to produce the role command first.
650
+ GET /api/tasks
651
+ POST /api/tasks
652
+ GET /api/tasks/:taskSlug
653
+ GET /api/tasks/:taskSlug/status
1156
654
  ```
1157
655
 
1158
- ### 14.5 role command 为空
1159
-
1160
- 发送 command 必须失败:
656
+ Sessions:
1161
657
 
1162
658
  ```text
1163
- Role command exists but is empty.
659
+ GET /api/tasks/:taskSlug/sessions
660
+ POST /api/tasks/:taskSlug/sessions/:role/start
661
+ POST /api/tasks/:taskSlug/sessions/:role/resume
662
+ POST /api/tasks/:taskSlug/sessions/:role/restart
663
+ POST /api/tasks/:taskSlug/sessions/:role/stop
664
+ POST /api/tasks/:taskSlug/sessions/:role/dispatch
1164
665
  ```
1165
666
 
1166
- ### 14.6 artifact 缺失
1167
-
1168
- Backend artifact schema check 标记 missing,不自动补写真实内容。
1169
-
1170
- ### 14.7 进程崩溃
1171
-
1172
- role session 进程异常退出时:
1173
-
1174
- - 状态标记为 `crashed`。
1175
- - 保留 raw log。
1176
- - 显示 exit code。
1177
- - 提供 Restart。
1178
-
1179
- ### 14.8 页面刷新
1180
-
1181
- 页面刷新后:
1182
-
1183
- - 前端重新请求 task/session 状态。
1184
- - 对 live session 重新建立 WebSocket。
1185
- - 对 missing live process 显示 `missing` 或 `exited`。
1186
-
1187
- ## 15. 安全和权限边界
1188
-
1189
- V1 不是 sandbox。它是本地 GUI session orchestrator。
1190
-
1191
- V1 必须明确提示:
1192
-
1193
- - Claude Code 在用户当前 repo 环境运行。
1194
- - VCM 不拦截 Claude Code 的所有文件写入。
1195
- - GUI 中的 terminal 是真实 Claude Code session。
1196
- - 高风险任务仍需要 human approval。
1197
- - 角色隔离依赖 `.claude/agents/*`、Claude Code permissions、用户 review 和 handoff artifacts。
1198
-
1199
- V1 推荐但不强制:
1200
-
1201
- - 项目提供 `.claude/agents/project-manager.md`。
1202
- - 项目提供 `.claude/agents/architect.md`。
1203
- - 项目提供 `.claude/agents/coder.md`。
1204
- - 项目提供 `.claude/agents/reviewer.md`。
1205
- - 项目配置 Claude Code permission hooks。
1206
-
1207
- V1 可以提供 Harness Health 检查这些文件是否存在,但不自动生成复杂 role agents。
1208
-
1209
- ## 16. 后续演进接口
1210
-
1211
- V1 代码应预留这些抽象,但不完整实现:
1212
-
1213
- ### 16.1 Review Adapter
1214
-
1215
- 后续接入 Cross-Model Reviewer。
1216
-
1217
- ### 16.2 Validation Runner
1218
-
1219
- 后续自动运行 validation commands。
1220
-
1221
- ### 16.3 Worktree Manager
1222
-
1223
- 后续实现:
667
+ Artifacts:
1224
668
 
1225
669
  ```text
1226
- one task -> one branch -> one worktree
670
+ GET /api/tasks/:taskSlug/artifacts
671
+ GET /api/tasks/:taskSlug/artifacts/:artifactName
672
+ GET /api/tasks/:taskSlug/role-commands/:role
673
+ PUT /api/tasks/:taskSlug/role-commands/:role
674
+ GET /api/tasks/:taskSlug/logs/:role
1227
675
  ```
1228
676
 
1229
- V1 只做当前 repo working directory orchestration。
1230
-
1231
- ### 16.4 Session Persistence Hardening
1232
-
1233
- 后续增强:
1234
-
1235
- - backend lifecycle 管理。
1236
- - session registry 持久化。
1237
- - raw log replay。
1238
- - 页面刷新和 backend 重启后的状态恢复。
1239
- - crashed / exited session 的恢复建议。
1240
-
1241
- ### 16.5 Desktop Shell
1242
-
1243
- 后续用 Electron 或 Tauri 包装本地 Web GUI。
1244
-
1245
- ### 16.6 Permission / Hook Manager
1246
-
1247
- 后续生成 role-specific Claude Code permission hooks。
1248
-
1249
- ## 17. 实施顺序
1250
-
1251
- ### Milestone 1: Local GUI Shell
1252
-
1253
- - TypeScript monorepo / app 初始化。
1254
- - React + Vite frontend。
1255
- - Node backend。
1256
- - `vcm dev` 启动前后端。
1257
- - Project Dashboard。
1258
- - repo connect API。
1259
- - environment check。
1260
-
1261
- ### Milestone 2: Task Workspace and Artifacts
1262
-
1263
- - Task Workspace 页面。
1264
- - `POST /api/tasks`。
1265
- - handoff directory。
1266
- - role command templates。
1267
- - artifact templates。
1268
- - artifact schema checks。
1269
-
1270
- ### Milestone 3: Embedded Terminal Runtime
1271
-
1272
- - TerminalRuntime interface。
1273
- - NodePtyTerminalRuntime。
1274
- - WebSocket terminal bridge。
1275
- - xterm.js SessionConsole。
1276
- - start / stop / restart role session。
1277
- - raw logs。
1278
-
1279
- ### Milestone 4: Role Session Cockpit
1280
-
1281
- - role session tabs。
1282
- - session status badges。
1283
- - reconnect after page refresh。
1284
- - event log。
1285
- - session registry。
1286
- - crash / exited handling。
1287
-
1288
- ### Milestone 5: GUI Role Command Dispatch
1289
-
1290
- - role command viewer。
1291
- - Send Command button。
1292
- - backend dispatch API。
1293
- - short instruction write to pty。
1294
- - dispatch event recording。
1295
-
1296
- ### Milestone 6: Acceptance Smoke
1297
-
1298
- - one repo。
1299
- - one task。
1300
- - start project-manager。
1301
- - start architect。
1302
- - send architect command。
1303
- - verify output streams in GUI。
1304
- - verify raw logs saved。
1305
- - verify artifact status shown。
1306
- - restart coder session。
1307
- - stop all sessions。
1308
-
1309
- ## 18. V1 验收标准
1310
-
1311
- V1 完成时,应能在一个真实 repo 中演示:
677
+ Messages:
1312
678
 
1313
679
  ```text
1314
- 1. 打开 VibeCodingMaster GUI
1315
- 2. 选择本地 Git repo
1316
- 3. 创建 demo-task
1317
- 4. Task Workspace 打开成功
1318
- 5. project-manager session 在 embedded terminal 中启动
1319
- 6. architect session 在另一个 tab 中启动
1320
- 7. 用户可以在 GUI 中切换 PM / architect
1321
- 8. 用户可以直接在 terminal 中输入和确认 Claude Code 提示
1322
- 9. PM 产出 architect.md
1323
- 10. 用户需要时可在任务目录查看 architect.md
1324
- 11. 用户点击目标 role 的 Send Command
1325
- 12. architect session 收到短指令并执行
1326
- 13. architect raw output 写入 logs/architect.log
1327
- 14. backend artifact check 可识别 architecture-plan.md missing / incomplete / ok
1328
- 15. 用户可以 restart coder session
1329
- 16. 页面刷新后能恢复 task/session 状态
680
+ GET /api/tasks/:taskSlug/messages
681
+ POST /api/tasks/:taskSlug/messages
682
+ POST /api/tasks/:taskSlug/messages/:messageId/stage
683
+ POST /api/tasks/:taskSlug/messages/:messageId/approve
684
+ POST /api/tasks/:taskSlug/messages/:messageId/reject
685
+ GET /api/tasks/:taskSlug/orchestration
686
+ PUT /api/tasks/:taskSlug/orchestration
687
+ POST /api/tasks/:taskSlug/orchestration/pause
688
+ POST /api/tasks/:taskSlug/orchestration/resume
1330
689
  ```
1331
690
 
1332
- 成功指标:
1333
-
1334
- - GUI 启动成功。
1335
- - repo 连接成功。
1336
- - role session 创建成功。
1337
- - terminal input/output 稳定。
1338
- - raw logs 不丢。
1339
- - artifact 状态可见。
1340
- - role command dispatch 可控。
1341
- - 页面刷新后可恢复状态。
1342
-
1343
- ## 19. 主要风险和应对
1344
-
1345
- ### 19.1 Claude Code 交互终端嵌入复杂
691
+ Translation:
1346
692
 
1347
- 应对:
1348
-
1349
- - 使用 xterm.js。
1350
- - 使用 node-pty。
1351
- - 保留 raw stream。
1352
- - 支持 resize。
1353
- - 支持权限确认和用户输入。
1354
-
1355
- ### 19.2 Session 持久性不足
1356
-
1357
- 应对:
1358
-
1359
- - backend 持有 session registry。
1360
- - `.vcm/sessions` 保存每个 role 的完整 `RoleSessionRecord` 和 `claudeSessionId`。
1361
- - 首次启动使用 `claude --agent <role> --session-id <uuid>`。
1362
- - backend 重启或异常退出后,GUI 将旧 pty 标记为 `resumable`。
1363
- - Resume 使用 `claude --agent <role> --resume <uuid>` 创建新的 embedded terminal。
1364
- - raw logs 持续写入。
1365
- - 页面刷新重新订阅。
1366
- - 后续继续增强 backend lifecycle 和 raw log replay。
1367
-
1368
- ### 19.3 Claude Code 状态不可结构化
693
+ ```text
694
+ GET /api/translation/settings
695
+ PUT /api/translation/settings
696
+ GET /api/translation/prompts
697
+ POST /api/translation/test
698
+ POST /api/tasks/:taskSlug/sessions/:role/translation/input
699
+ POST /api/tasks/:taskSlug/sessions/:role/translation/send
700
+ POST /api/translation/sessions/:sessionId/clear
701
+ POST /api/translation/sessions/:sessionId/retry/:translationId
702
+ ```
1369
703
 
1370
- 应对:
704
+ WebSockets:
1371
705
 
1372
- - V1 不深度解析 Claude Code 输出。
1373
- - 状态以 process state、用户显式标记、artifact state 为主。
1374
- - 后续通过 structured reports 改进。
706
+ ```text
707
+ /ws/terminal/:sessionId
708
+ /ws/translation/:sessionId
709
+ ```
1375
710
 
1376
- ### 19.4 PM 误控其他 session
711
+ ## 15. Error Handling
1377
712
 
1378
- 应对:
713
+ File:
1379
714
 
1380
- - PM 不直接操作 runtime。
1381
- - dispatch 必须读取 role command artifact。
1382
- - GUI 展示 command 并由用户发送。
1383
- - backend 记录 dispatch event。
715
+ - `src/backend/errors.ts`
1384
716
 
1385
- ### 19.5 Handoff 空洞
717
+ Backend services throw `VcmError` with:
1386
718
 
1387
- 应对:
719
+ - code
720
+ - message
721
+ - status code
722
+ - optional hint
1388
723
 
1389
- - artifact schema check。
1390
- - backend status 可报告 missing/incomplete/ok。
1391
- - reviewer 后续检查 handoff compliance。
724
+ Fastify error handler returns:
1392
725
 
1393
- ### 19.6 用户在 main 分支上开发
726
+ ```json
727
+ {
728
+ "error": {
729
+ "code": "CODE",
730
+ "message": "Human-readable message",
731
+ "hint": "Optional hint"
732
+ }
733
+ }
734
+ ```
1394
735
 
1395
- 应对:
736
+ ## 16. Packaging Architecture
1396
737
 
1397
- - repo connect 和 task create 时显示当前 branch。
1398
- - 如果当前 branch 是 `main` 或 `master`,显示 warning。
1399
- - V1 不强制创建 branch,但强烈建议用户切到 task branch。
738
+ `package.json` publishes built artifacts:
1400
739
 
1401
- ### 19.7 GUI 复杂度过高
740
+ - `dist`
741
+ - `dist-frontend`
742
+ - `docs`
743
+ - `scripts`
744
+ - `README.md`
1402
745
 
1403
- 应对:
746
+ Bins:
1404
747
 
1405
- - V1 只做本地单用户。
1406
- - V1 只做一个 repo 的核心路径。
1407
- - V1 不做自动 review、validation runner、PR。
1408
- - 优先完成 SessionConsole、role dispatch 和 session recovery。
748
+ - `vcm` -> `dist/main.js`
749
+ - `vcmctl` -> `dist/cli/vcmctl.js`
1409
750
 
1410
- ## 20. 架构判断
751
+ Important scripts:
1411
752
 
1412
- V1 的本质不是“自动写代码”,也不是“给终端包一层命令”。
753
+ - `build`: clean, TypeScript build, Vite build
754
+ - `verify:package`: verifies required dist files and frontend assets
755
+ - `prepack`: build and package verification
756
+ - `postinstall`: fixes `node-pty` spawn helper when needed
1413
757
 
1414
- V1 的本质是:
758
+ ## 17. Security And Safety Boundaries
1415
759
 
1416
- > 搭建一个可靠的本地 Claude Code 多角色 GUI 工作台,让多个 role sessions、handoff artifacts、logs 和状态在一个任务页面中变得可见、可切换、可沟通、可恢复。
760
+ Current boundaries:
1417
761
 
1418
- 第一版应该保持克制:
762
+ - VCM runs local processes with the user's permissions.
763
+ - VCM does not auto-confirm Claude Code permission prompts.
764
+ - Relaxed Claude permission modes are user-selected per role launch.
765
+ - Translation API key is local in `~/.vcm/settings.json`.
766
+ - Translation output is UI/runtime state only unless a user or role copies it into a file.
767
+ - Handoff artifacts and `.vcm` state live in the connected repository; users should decide what to commit or ignore.
768
+ - Sandbox isolation should come from a devContainer, Docker container, VM, or other user-controlled environment.
1419
769
 
1420
- ```text
1421
- 少做智能判断
1422
- 多做状态可见
1423
- 少自动修改代码
1424
- 多沉淀 artifacts
1425
- 少解析终端语义
1426
- 多保留 raw logs
1427
- 少暴露终端编排细节
1428
- 多提供 GUI 操作入口
1429
- ```
770
+ ## 18. Known Implementation Boundaries
1430
771
 
1431
- 只要 V1 能稳定做到 GUI task workspace、embedded Claude Code role sessions、terminal I/O、raw logs、role command dispatch 和 handoff artifact checks,后续 Task Spec Builder、Validation Runner、Cross-Model Review、Worktree Manager、Desktop Packaging 和 session persistence hardening 才有可靠地基。
772
+ - No tmux backend.
773
+ - No per-role worktree manager.
774
+ - No main-page artifact inspector.
775
+ - No raw PTY output translation.
776
+ - No hard workflow gate enforcement.
777
+ - No durable backend event log for the sidebar Events modal; current events are frontend runtime events for the active task.
778
+ - No hosted multi-user collaboration.