vibe-coding-master 0.0.1
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.
- package/LICENSE +201 -0
- package/README.md +226 -0
- package/dist/backend/adapters/claude-adapter.js +38 -0
- package/dist/backend/adapters/command-runner.js +33 -0
- package/dist/backend/adapters/filesystem.js +60 -0
- package/dist/backend/adapters/git-adapter.js +33 -0
- package/dist/backend/api/artifact-routes.js +109 -0
- package/dist/backend/api/message-routes.js +90 -0
- package/dist/backend/api/project-routes.js +17 -0
- package/dist/backend/api/session-routes.js +64 -0
- package/dist/backend/api/task-routes.js +30 -0
- package/dist/backend/errors.js +29 -0
- package/dist/backend/runtime/node-pty-runtime.js +162 -0
- package/dist/backend/runtime/session-registry.js +36 -0
- package/dist/backend/runtime/terminal-runtime.js +1 -0
- package/dist/backend/server.js +159 -0
- package/dist/backend/services/artifact-service.js +170 -0
- package/dist/backend/services/command-dispatcher.js +37 -0
- package/dist/backend/services/message-service.js +217 -0
- package/dist/backend/services/project-service.js +71 -0
- package/dist/backend/services/session-service.js +221 -0
- package/dist/backend/services/status-service.js +21 -0
- package/dist/backend/services/task-service.js +88 -0
- package/dist/backend/templates/handoff.js +76 -0
- package/dist/backend/templates/message-envelope.js +27 -0
- package/dist/backend/templates/role-command.js +21 -0
- package/dist/backend/templates/role-messaging-context.js +44 -0
- package/dist/backend/ws/terminal-ws.js +60 -0
- package/dist/cli/vcmctl.js +141 -0
- package/dist/main.js +63 -0
- package/dist/shared/constants.js +45 -0
- package/dist/shared/types/api.js +1 -0
- package/dist/shared/types/artifact.js +1 -0
- package/dist/shared/types/message.js +1 -0
- package/dist/shared/types/project.js +1 -0
- package/dist/shared/types/role.js +1 -0
- package/dist/shared/types/session.js +1 -0
- package/dist/shared/types/task.js +1 -0
- package/dist/shared/types/terminal.js +1 -0
- package/dist/shared/validation/artifact-check.js +64 -0
- package/dist/shared/validation/slug-check.js +22 -0
- package/dist-frontend/assets/index-Bah6k-Ix.css +32 -0
- package/dist-frontend/assets/index-EMaQuIB6.js +58 -0
- package/dist-frontend/index.html +13 -0
- package/docs/cc-best-practices.md +2142 -0
- package/docs/product-design.md +1597 -0
- package/docs/v1-architecture-design.md +1431 -0
- package/docs/v1-implementation-plan.md +1949 -0
- package/docs/v1-message-bus-orchestration-design.md +534 -0
- package/package.json +60 -0
- package/scripts/clean-build.mjs +12 -0
- package/scripts/fix-node-pty-spawn-helper.mjs +31 -0
|
@@ -0,0 +1,1431 @@
|
|
|
1
|
+
# VibeCodingMaster V1 架构设计方案
|
|
2
|
+
|
|
3
|
+
版本:v0.2
|
|
4
|
+
日期:2026-05-29
|
|
5
|
+
状态:架构设计草案
|
|
6
|
+
依据:
|
|
7
|
+
|
|
8
|
+
- `docs/product-design.md`
|
|
9
|
+
- `docs/cc-best-practices.md`
|
|
10
|
+
|
|
11
|
+
## 1. V1 架构目标
|
|
12
|
+
|
|
13
|
+
VibeCodingMaster V1 只解决一个核心问题:
|
|
14
|
+
|
|
15
|
+
> 做一个本地 GUI Session Cockpit,让用户可以在一个任务工作台中启动、切换、查看、输入和管理多个 Claude Code role sessions。
|
|
16
|
+
|
|
17
|
+
V1 不再把 CLI 或手动终端管理作为主交互模式。CLI 可以保留为开发、调试和 smoke test 入口,但用户主流程必须在 GUI 中完成。
|
|
18
|
+
|
|
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
|
+
用户不需要理解:
|
|
87
|
+
|
|
88
|
+
- pseudo-terminal。
|
|
89
|
+
- process id。
|
|
90
|
+
- terminal stream。
|
|
91
|
+
- WebSocket message。
|
|
92
|
+
- input/output bridge。
|
|
93
|
+
|
|
94
|
+
产品界面表达的是任务、角色、会话、artifact、状态和验收。
|
|
95
|
+
|
|
96
|
+
### 3.3 Controller-Mediated
|
|
97
|
+
|
|
98
|
+
Project Manager session 不直接无限制控制其他 Claude Code sessions。
|
|
99
|
+
|
|
100
|
+
正确模型:
|
|
101
|
+
|
|
102
|
+
```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
|
|
111
|
+
```
|
|
112
|
+
|
|
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
|
+
角色交接不依赖聊天记忆。所有关键结果必须进入:
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
.ai/handoffs/<task-slug>/
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Terminal output 是调试信息;长期事实源是 handoff artifacts。
|
|
130
|
+
|
|
131
|
+
### 3.5 One Task, One Workspace
|
|
132
|
+
|
|
133
|
+
V1 默认:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
one task
|
|
137
|
+
-> one GUI task workspace
|
|
138
|
+
-> multiple role sessions
|
|
139
|
+
-> one handoff directory
|
|
140
|
+
-> one repo working directory
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
V1 不为每个 role 创建独立 worktree。角色隔离由 role session、role prompt、permissions、handoff files 和流程顺序实现。
|
|
144
|
+
|
|
145
|
+
### 3.6 Single-Writer Rule
|
|
146
|
+
|
|
147
|
+
同一个任务中,默认只有一个 write-capable role 在编辑代码。
|
|
148
|
+
|
|
149
|
+
推荐顺序:
|
|
150
|
+
|
|
151
|
+
```text
|
|
152
|
+
project-manager -> architect -> coder -> reviewer
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
允许并行:
|
|
156
|
+
|
|
157
|
+
- read-only review。
|
|
158
|
+
- log analysis。
|
|
159
|
+
- artifact inspection。
|
|
160
|
+
- 用户查看多个 session。
|
|
161
|
+
|
|
162
|
+
不允许:
|
|
163
|
+
|
|
164
|
+
- `coder` 和 `reviewer` 同时大范围改代码。
|
|
165
|
+
- PM 直接替代 coder 实现复杂功能。
|
|
166
|
+
- reviewer 接管大范围实现。
|
|
167
|
+
|
|
168
|
+
### 3.7 State Can Be Rebuilt
|
|
169
|
+
|
|
170
|
+
V1 的状态必须能从四类来源恢复:
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
backend session registry
|
|
174
|
+
terminal process state
|
|
175
|
+
repo artifacts
|
|
176
|
+
local VCM metadata
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
不要把前端页面内存作为唯一状态源。
|
|
180
|
+
|
|
181
|
+
## 4. 技术栈选择
|
|
182
|
+
|
|
183
|
+
### 4.1 主语言
|
|
184
|
+
|
|
185
|
+
推荐:
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
TypeScript + Node.js LTS
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
原因:
|
|
192
|
+
|
|
193
|
+
- 前后端共享类型。
|
|
194
|
+
- 适合本地 GUI、WebSocket 和进程编排。
|
|
195
|
+
- 易于调用 `git`、`claude`、文件系统和终端 runtime。
|
|
196
|
+
- 与后续 Desktop shell、Web UI 和自动化能力兼容。
|
|
197
|
+
|
|
198
|
+
### 4.2 前端
|
|
199
|
+
|
|
200
|
+
推荐:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
React + Vite
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
原因:
|
|
207
|
+
|
|
208
|
+
- 适合构建本地单页工作台。
|
|
209
|
+
- 与 xterm.js 集成成熟。
|
|
210
|
+
- 本地开发体验快。
|
|
211
|
+
- 后续可以被 Electron / Tauri / Desktop shell 包装。
|
|
212
|
+
|
|
213
|
+
前端核心依赖:
|
|
214
|
+
|
|
215
|
+
```text
|
|
216
|
+
@xterm/xterm
|
|
217
|
+
@xterm/addon-fit
|
|
218
|
+
@xterm/addon-web-links
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 4.3 后端
|
|
222
|
+
|
|
223
|
+
推荐:
|
|
224
|
+
|
|
225
|
+
```text
|
|
226
|
+
Node.js HTTP server + WebSocket
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
可选框架:
|
|
230
|
+
|
|
231
|
+
```text
|
|
232
|
+
Fastify 或 Express
|
|
233
|
+
ws
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
后端职责:
|
|
237
|
+
|
|
238
|
+
- 提供 REST API。
|
|
239
|
+
- 提供 terminal WebSocket。
|
|
240
|
+
- 管理 pseudo-terminal lifecycle。
|
|
241
|
+
- 读写 `.vcm` 和 `.ai/handoffs`。
|
|
242
|
+
- 执行 git / claude 环境检查。
|
|
243
|
+
|
|
244
|
+
### 4.4 Terminal Runtime
|
|
245
|
+
|
|
246
|
+
V1 推荐:
|
|
247
|
+
|
|
248
|
+
```text
|
|
249
|
+
node-pty
|
|
250
|
+
```
|
|
251
|
+
|
|
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 固定为:
|
|
263
|
+
|
|
264
|
+
```text
|
|
265
|
+
TerminalRuntime implementation = node-pty
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
后续持久性增强应优先改进 backend lifecycle、session registry、raw logs 和恢复体验。
|
|
269
|
+
|
|
270
|
+
### 4.5 进程执行
|
|
271
|
+
|
|
272
|
+
推荐:
|
|
273
|
+
|
|
274
|
+
```text
|
|
275
|
+
execa
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
用途:
|
|
279
|
+
|
|
280
|
+
- 调用 `git`。
|
|
281
|
+
- 调用 `claude --version`。
|
|
282
|
+
- 执行 shell-safe command。
|
|
283
|
+
- 不用于承载 Claude Code 交互式 session;交互式 session 由 `node-pty` 负责。
|
|
284
|
+
|
|
285
|
+
### 4.6 本地状态存储
|
|
286
|
+
|
|
287
|
+
V1 推荐 JSON 文件,而不是 SQLite。
|
|
288
|
+
|
|
289
|
+
推荐路径:
|
|
290
|
+
|
|
291
|
+
```text
|
|
292
|
+
.vcm/
|
|
293
|
+
config.json
|
|
294
|
+
tasks/
|
|
295
|
+
<task-slug>.json
|
|
296
|
+
sessions/
|
|
297
|
+
<task-slug>.json
|
|
298
|
+
app-state.json
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
原因:
|
|
302
|
+
|
|
303
|
+
- V1 是本地单用户。
|
|
304
|
+
- 状态量小。
|
|
305
|
+
- 易于检查和恢复。
|
|
306
|
+
- 与 repo-local harness 理念一致。
|
|
307
|
+
|
|
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
|
+
推荐:
|
|
324
|
+
|
|
325
|
+
```text
|
|
326
|
+
Vitest
|
|
327
|
+
Playwright
|
|
328
|
+
```
|
|
329
|
+
|
|
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。
|
|
343
|
+
|
|
344
|
+
```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
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Backend 是长生命周期本地进程。前端刷新后,应该能重新连接 backend 并恢复可见状态。
|
|
367
|
+
|
|
368
|
+
## 6. GUI 结构
|
|
369
|
+
|
|
370
|
+
### 6.1 Project Dashboard
|
|
371
|
+
|
|
372
|
+
职责:
|
|
373
|
+
|
|
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 的入口。
|
|
379
|
+
|
|
380
|
+
### 6.2 Task Workspace
|
|
381
|
+
|
|
382
|
+
V1 的主界面。
|
|
383
|
+
|
|
384
|
+
推荐布局:
|
|
385
|
+
|
|
386
|
+
```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
|
+
└──────────────────────────────────────────────────────────────────────────────┘
|
|
398
|
+
```
|
|
399
|
+
|
|
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
|
+
示例:
|
|
423
|
+
|
|
424
|
+
```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
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### 7.2 TerminalRuntime 接口
|
|
447
|
+
|
|
448
|
+
V1 后端应抽象 terminal runtime,避免把 node-pty 写死到上层业务。
|
|
449
|
+
|
|
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
|
+
```
|
|
462
|
+
|
|
463
|
+
### 7.3 node-pty 实现
|
|
464
|
+
|
|
465
|
+
`NodePtyTerminalRuntime` 负责:
|
|
466
|
+
|
|
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。
|
|
476
|
+
|
|
477
|
+
### 7.4 WebSocket Terminal Bridge
|
|
478
|
+
|
|
479
|
+
WebSocket 负责前后端双向通信。
|
|
480
|
+
|
|
481
|
+
推荐消息:
|
|
482
|
+
|
|
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
|
+
```
|
|
490
|
+
|
|
491
|
+
### 7.5 Role Command Dispatch
|
|
492
|
+
|
|
493
|
+
长 role command 不直接粘贴进 terminal。V1 应先写入文件,再向目标 session 发送短指令。
|
|
494
|
+
|
|
495
|
+
任务身份以 VCM `taskSlug` 为准。Project Manager 必须只写入当前 task 的 canonical handoff directory:
|
|
496
|
+
|
|
497
|
+
```text
|
|
498
|
+
.ai/handoffs/<task-slug>/role-commands/<role>.md
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
如果 task slug 不符合用户意图,Project Manager 必须要求用户创建或选择正确的 VCM task,不能自行创建 `.ai/handoffs/<other-task>/` 来绕过当前 task。
|
|
502
|
+
|
|
503
|
+
示例:
|
|
504
|
+
|
|
505
|
+
```text
|
|
506
|
+
Please read and execute the role command at: .ai/handoffs/<task-slug>/role-commands/architect.md
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
发送流程:
|
|
510
|
+
|
|
511
|
+
```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
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
### 7.6 Programmatic I/O Boundary
|
|
520
|
+
|
|
521
|
+
通过 `node-pty`,backend 技术上可以对 Claude Code session 做两类程序化操作:
|
|
522
|
+
|
|
523
|
+
```text
|
|
524
|
+
write input:
|
|
525
|
+
runtime.write(sessionId, "Please read ...\r")
|
|
526
|
+
|
|
527
|
+
read output:
|
|
528
|
+
runtime.subscribe(sessionId, listener)
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
V1 允许:
|
|
532
|
+
|
|
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 等状态。
|
|
539
|
+
|
|
540
|
+
V1 不允许:
|
|
541
|
+
|
|
542
|
+
- 自动确认 Claude Code 权限提示。
|
|
543
|
+
- PM 写完 command 后自动发送给下一个 role。
|
|
544
|
+
- Architect 完成后自动触发 Coder。
|
|
545
|
+
- Coder 完成后自动触发 Reviewer。
|
|
546
|
+
- 根据 terminal output 自动执行高风险下一步。
|
|
547
|
+
|
|
548
|
+
更高级的自动编排必须进入后续版本,并带有人类 approval gate、审计日志和明确 stop conditions。
|
|
549
|
+
|
|
550
|
+
### 7.7 Claude Code Permission Modes
|
|
551
|
+
|
|
552
|
+
V1 在 Task Workspace 的每个 role session 控制区提供三档权限模式:
|
|
553
|
+
|
|
554
|
+
```text
|
|
555
|
+
默认
|
|
556
|
+
-> claude --agent <role>
|
|
557
|
+
|
|
558
|
+
bypassPermissions
|
|
559
|
+
-> claude --agent <role> --permission-mode bypassPermissions
|
|
560
|
+
|
|
561
|
+
--dangerously-skip-permissions
|
|
562
|
+
-> claude --agent <role> --dangerously-skip-permissions
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
规则:
|
|
566
|
+
|
|
567
|
+
- 权限模式是用户显式选择,不由 Project Manager 或 backend 自动切换。
|
|
568
|
+
- 权限模式只影响 Start / Restart 创建的新 Claude Code 进程。
|
|
569
|
+
- `RoleSessionRecord.permissionMode` 必须记录实际启动模式。
|
|
570
|
+
- GUI 显示实际 command,方便用户确认当前 session 的权限状态。
|
|
571
|
+
|
|
572
|
+
## 8. Repo Artifacts
|
|
573
|
+
|
|
574
|
+
V1 需要创建和维护:
|
|
575
|
+
|
|
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
|
+
```
|
|
602
|
+
|
|
603
|
+
V1 可以不自动创建 `.ai/task-specs/`,但如果 Project Manager 已经生成 task spec,应在 task metadata 中记录路径。
|
|
604
|
+
|
|
605
|
+
## 9. 模块划分
|
|
606
|
+
|
|
607
|
+
推荐代码结构:
|
|
608
|
+
|
|
609
|
+
```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/
|
|
678
|
+
```
|
|
679
|
+
|
|
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。
|
|
733
|
+
|
|
734
|
+
### 9.7 ArtifactService
|
|
735
|
+
|
|
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
|
|
764
|
+
|
|
765
|
+
```text
|
|
766
|
+
GET /api/health
|
|
767
|
+
POST /api/projects/connect
|
|
768
|
+
GET /api/projects/current
|
|
769
|
+
GET /api/projects/harness
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
`POST /api/projects/connect`:
|
|
773
|
+
|
|
774
|
+
```json
|
|
775
|
+
{
|
|
776
|
+
"repoPath": "/path/to/repo"
|
|
777
|
+
}
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
### 10.2 Task API
|
|
781
|
+
|
|
782
|
+
```text
|
|
783
|
+
GET /api/tasks
|
|
784
|
+
POST /api/tasks
|
|
785
|
+
GET /api/tasks/:taskSlug
|
|
786
|
+
GET /api/tasks/:taskSlug/status
|
|
787
|
+
```
|
|
788
|
+
|
|
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
|
+
```
|
|
798
|
+
|
|
799
|
+
### 10.3 Session API
|
|
800
|
+
|
|
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
|
+
```
|
|
810
|
+
|
|
811
|
+
### 10.4 Artifact API
|
|
812
|
+
|
|
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
|
+
```
|
|
820
|
+
|
|
821
|
+
### 10.5 Terminal WebSocket
|
|
822
|
+
|
|
823
|
+
```text
|
|
824
|
+
WS /ws/tasks/:taskSlug/sessions/:role
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
Client -> server:
|
|
828
|
+
|
|
829
|
+
```json
|
|
830
|
+
{ "type": "input", "data": "..." }
|
|
831
|
+
{ "type": "resize", "cols": 120, "rows": 32 }
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
Server -> client:
|
|
835
|
+
|
|
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
|
+
```
|
|
842
|
+
|
|
843
|
+
## 11. 数据模型
|
|
844
|
+
|
|
845
|
+
### 11.1 ProjectConfig
|
|
846
|
+
|
|
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
|
|
860
|
+
|
|
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
|
+
```
|
|
875
|
+
|
|
876
|
+
### 11.3 RoleSessionRecord
|
|
877
|
+
|
|
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
|
+
}
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
### 11.4 TaskSessionRecord
|
|
900
|
+
|
|
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
|
+
}
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
### 11.5 RoleStatus
|
|
930
|
+
|
|
931
|
+
V1 状态枚举:
|
|
932
|
+
|
|
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
|
+
```
|
|
946
|
+
|
|
947
|
+
V1 很难可靠判断 Claude Code 内部语义状态,因此:
|
|
948
|
+
|
|
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。
|
|
956
|
+
|
|
957
|
+
### 11.6 TerminalEvent
|
|
958
|
+
|
|
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. 核心工作流
|
|
972
|
+
|
|
973
|
+
### 12.1 启动应用
|
|
974
|
+
|
|
975
|
+
```text
|
|
976
|
+
vcm dev 或桌面入口
|
|
977
|
+
-> start local Node backend
|
|
978
|
+
-> serve React frontend
|
|
979
|
+
-> open browser / desktop shell
|
|
980
|
+
-> show Project Dashboard
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
### 12.2 连接 repo
|
|
984
|
+
|
|
985
|
+
```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
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
### 12.3 创建任务 workspace
|
|
996
|
+
|
|
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
|
+
```
|
|
1008
|
+
|
|
1009
|
+
### 12.4 启动 role session
|
|
1010
|
+
|
|
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
|
+
```
|
|
1019
|
+
|
|
1020
|
+
### 12.5 用户切换和沟通
|
|
1021
|
+
|
|
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
|
|
1031
|
+
|
|
1032
|
+
```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
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
### 12.7 查看 artifacts
|
|
1042
|
+
|
|
1043
|
+
```text
|
|
1044
|
+
V1 main GUI does not render artifact status.
|
|
1045
|
+
Handoff files remain available in the task directory and backend services.
|
|
1046
|
+
```
|
|
1047
|
+
|
|
1048
|
+
### 12.8 重启 role session
|
|
1049
|
+
|
|
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
|
+
```
|
|
1058
|
+
|
|
1059
|
+
## 13. Artifact Schema Checks
|
|
1060
|
+
|
|
1061
|
+
V1 不判断内容质量,但必须检查关键 artifact 是否存在且包含必要标题。
|
|
1062
|
+
|
|
1063
|
+
### 13.1 architecture-plan.md
|
|
1064
|
+
|
|
1065
|
+
最低标题:
|
|
1066
|
+
|
|
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
|
+
```
|
|
1079
|
+
|
|
1080
|
+
### 13.2 implementation-log.md
|
|
1081
|
+
|
|
1082
|
+
最低标题:
|
|
1083
|
+
|
|
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
|
+
```
|
|
1093
|
+
|
|
1094
|
+
### 13.3 validation-log.md
|
|
1095
|
+
|
|
1096
|
+
最低要求:
|
|
1097
|
+
|
|
1098
|
+
```text
|
|
1099
|
+
至少存在一个 validation entry,或明确说明 not run + reason。
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
### 13.4 review-report.md
|
|
1103
|
+
|
|
1104
|
+
最低标题:
|
|
1105
|
+
|
|
1106
|
+
```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
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
## 14. 错误处理
|
|
1119
|
+
|
|
1120
|
+
### 14.1 Claude Code 不存在
|
|
1121
|
+
|
|
1122
|
+
连接 repo 或启动 role session 前失败,并在 GUI 中提示:
|
|
1123
|
+
|
|
1124
|
+
```text
|
|
1125
|
+
Claude Code command is not available.
|
|
1126
|
+
Install Claude Code or configure the claude command path.
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
### 14.2 Repo 无效
|
|
1130
|
+
|
|
1131
|
+
`POST /api/projects/connect` 必须检查 Git repo。
|
|
1132
|
+
|
|
1133
|
+
失败时提示:
|
|
1134
|
+
|
|
1135
|
+
```text
|
|
1136
|
+
Selected path is not a Git repository.
|
|
1137
|
+
```
|
|
1138
|
+
|
|
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 必须失败:
|
|
1152
|
+
|
|
1153
|
+
```text
|
|
1154
|
+
Missing .ai/handoffs/<task-slug>/role-commands/<role>.md
|
|
1155
|
+
Ask project-manager to produce the role command first.
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
### 14.5 role command 为空
|
|
1159
|
+
|
|
1160
|
+
发送 command 必须失败:
|
|
1161
|
+
|
|
1162
|
+
```text
|
|
1163
|
+
Role command exists but is empty.
|
|
1164
|
+
```
|
|
1165
|
+
|
|
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
|
+
后续实现:
|
|
1224
|
+
|
|
1225
|
+
```text
|
|
1226
|
+
one task -> one branch -> one worktree
|
|
1227
|
+
```
|
|
1228
|
+
|
|
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 中演示:
|
|
1312
|
+
|
|
1313
|
+
```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 状态
|
|
1330
|
+
```
|
|
1331
|
+
|
|
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 交互终端嵌入复杂
|
|
1346
|
+
|
|
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 状态不可结构化
|
|
1369
|
+
|
|
1370
|
+
应对:
|
|
1371
|
+
|
|
1372
|
+
- V1 不深度解析 Claude Code 输出。
|
|
1373
|
+
- 状态以 process state、用户显式标记、artifact state 为主。
|
|
1374
|
+
- 后续通过 structured reports 改进。
|
|
1375
|
+
|
|
1376
|
+
### 19.4 PM 误控其他 session
|
|
1377
|
+
|
|
1378
|
+
应对:
|
|
1379
|
+
|
|
1380
|
+
- PM 不直接操作 runtime。
|
|
1381
|
+
- dispatch 必须读取 role command artifact。
|
|
1382
|
+
- GUI 展示 command 并由用户发送。
|
|
1383
|
+
- backend 记录 dispatch event。
|
|
1384
|
+
|
|
1385
|
+
### 19.5 Handoff 空洞
|
|
1386
|
+
|
|
1387
|
+
应对:
|
|
1388
|
+
|
|
1389
|
+
- artifact schema check。
|
|
1390
|
+
- backend status 可报告 missing/incomplete/ok。
|
|
1391
|
+
- reviewer 后续检查 handoff compliance。
|
|
1392
|
+
|
|
1393
|
+
### 19.6 用户在 main 分支上开发
|
|
1394
|
+
|
|
1395
|
+
应对:
|
|
1396
|
+
|
|
1397
|
+
- repo connect 和 task create 时显示当前 branch。
|
|
1398
|
+
- 如果当前 branch 是 `main` 或 `master`,显示 warning。
|
|
1399
|
+
- V1 不强制创建 branch,但强烈建议用户切到 task branch。
|
|
1400
|
+
|
|
1401
|
+
### 19.7 GUI 复杂度过高
|
|
1402
|
+
|
|
1403
|
+
应对:
|
|
1404
|
+
|
|
1405
|
+
- V1 只做本地单用户。
|
|
1406
|
+
- V1 只做一个 repo 的核心路径。
|
|
1407
|
+
- V1 不做自动 review、validation runner、PR。
|
|
1408
|
+
- 优先完成 SessionConsole、role dispatch 和 session recovery。
|
|
1409
|
+
|
|
1410
|
+
## 20. 架构判断
|
|
1411
|
+
|
|
1412
|
+
V1 的本质不是“自动写代码”,也不是“给终端包一层命令”。
|
|
1413
|
+
|
|
1414
|
+
V1 的本质是:
|
|
1415
|
+
|
|
1416
|
+
> 搭建一个可靠的本地 Claude Code 多角色 GUI 工作台,让多个 role sessions、handoff artifacts、logs 和状态在一个任务页面中变得可见、可切换、可沟通、可恢复。
|
|
1417
|
+
|
|
1418
|
+
第一版应该保持克制:
|
|
1419
|
+
|
|
1420
|
+
```text
|
|
1421
|
+
少做智能判断
|
|
1422
|
+
多做状态可见
|
|
1423
|
+
少自动修改代码
|
|
1424
|
+
多沉淀 artifacts
|
|
1425
|
+
少解析终端语义
|
|
1426
|
+
多保留 raw logs
|
|
1427
|
+
少暴露终端编排细节
|
|
1428
|
+
多提供 GUI 操作入口
|
|
1429
|
+
```
|
|
1430
|
+
|
|
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 才有可靠地基。
|