vibe-coding-master 0.0.5 → 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 +3 -1
  38. package/scripts/verify-package.mjs +121 -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,1949 +1,1128 @@
1
- # VibeCodingMaster V1 实施计划
1
+ # V1 Implementation Plan And File Map
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/v1-architecture-design.md`
10
- - `docs/cc-best-practices.md`
5
+ This document is the current implementation map for VCM V1. It replaces older plan text that referenced removed files or obsolete UI behavior.
11
6
 
12
- ## 1. 实施目标
7
+ ## 1. Current Status
13
8
 
14
- V1 实现一个本地 GUI Session Cockpit,让用户可以在一个任务工作台中启动、切换、查看、输入和管理多个 Claude Code role sessions。
9
+ V1 is implemented as a local GUI app with:
15
10
 
16
- V1 完成后,用户应能:
11
+ - Fastify backend.
12
+ - React frontend.
13
+ - `node-pty` embedded terminals.
14
+ - `xterm.js` terminal rendering.
15
+ - Four Claude Code role sessions.
16
+ - VCM harness installer.
17
+ - API-driven message bus.
18
+ - Translation panel based on Claude transcript JSONL tailing.
19
+ - npm packaging with built `dist` and `dist-frontend` output.
17
20
 
18
- ```text
19
- Open VibeCodingMaster
20
- -> Select repo
21
- -> New task
22
- -> Start project-manager session
23
- -> Start architect session
24
- -> Switch between role sessions
25
- -> Type directly into embedded Claude Code terminals
26
- -> View role commands, logs, and handoff artifacts
27
- -> Send role command to target session from GUI
28
- -> Restart / stop role sessions
29
- ```
21
+ The implementation still has planned improvement space, but this file only describes code that exists now.
30
22
 
31
- V1 不再以手动 CLI 或手动终端控制为主路径。
23
+ ## 2. Package And Build
32
24
 
33
- V1 不实现:
25
+ File:
34
26
 
35
- - 自动生成完整 Task Spec。
36
- - 自动识别 public contract / test contract。
37
- - 自动执行 validation commands。
38
- - 自动 Cross-Model Review。
39
- - 自动创建 PR。
40
- - SaaS 多用户协作。
41
- - 完整 Desktop 打包和自动更新。
42
- - 多 worktree 自动管理。
27
+ - `package.json`
43
28
 
44
- ## 2. 关键约束
29
+ Current package facts:
45
30
 
46
- 1. GUI 是用户主入口,CLI 只用于启动 dev server、调试和 smoke test。
47
- 2. Claude Code role session 必须在 embedded terminal 中可见、可输入、可重启。
48
- 3. Project Manager 不直接无限制控制其他 role sessions。
49
- 4. Role command 必须先落盘到 `.ai/handoffs/<task-slug>/role-commands/<role>.md`。
50
- 5. GUI 读取 role command,用户点击发送后,backend 只向目标 terminal 写入短指令。
51
- 6. Backend 可以程序化写入和监听 embedded terminal,但 V1 只允许用户触发的 command dispatch,不自动确认权限,不自动串联驱动角色。
52
- 7. Terminal output 只作为调试信息;长期事实源是 handoff artifacts。
53
- 8. Raw terminal stream 必须持续写入 `.ai/handoffs/<task-slug>/logs/<role>.log`。
54
- 9. V1 只做 artifact 存在性和标题完整性检查,不判断内容质量。
55
- 10. 状态必须能从 backend session registry、terminal process state、repo artifacts、`.vcm` metadata 恢复。
56
- 11. V1 不把每个 role 放到独立 worktree。同一任务默认共享当前 repo working directory。
57
- 12. V1 默认遵守 single-writer rule,但主要通过流程提示、role status 和 review gate 实现,不做强制 sandbox。
31
+ - package name: `vibe-coding-master`
32
+ - current version: `0.0.6`
33
+ - type: ESM
34
+ - `bin.vcm`: `dist/main.js`
35
+ - `bin.vcmctl`: `dist/cli/vcmctl.js`
36
+ - published files: `dist`, `dist-frontend`, `docs`, `scripts`, `README.md`
58
37
 
59
- ## 3. 技术选型
38
+ Scripts:
60
39
 
61
- ```text
62
- Language: TypeScript
63
- Runtime: Node.js LTS
64
- Frontend: React + Vite
65
- Terminal UI: xterm.js
66
- Backend: Fastify + ws
67
- Terminal runtime: node-pty
68
- Process execution: execa
69
- State storage: JSON files
70
- Test runner: Vitest + Playwright
71
- Module format: ESM / NodeNext
72
- ```
40
+ - `clean`: remove build output.
41
+ - `fix:node-pty`: fix packaged `node-pty` spawn helper.
42
+ - `postinstall`: run `fix:node-pty`.
43
+ - `verify:package`: verify required package files.
44
+ - `prepack`: run build and package verification.
45
+ - `dev`: start backend plus Vite dev server.
46
+ - `build`: clean, compile Node TypeScript, build frontend.
47
+ - `start`: run built backend.
48
+ - `typecheck`: TypeScript no-emit checks for browser and Node configs.
49
+ - `test`: Vitest.
50
+ - `e2e`: Playwright.
51
+
52
+ Packaging guard:
53
+
54
+ - `scripts/verify-package.mjs`
55
+
56
+ It verifies required files, shebangs, packaged static path behavior, and frontend built assets.
73
57
 
74
- ## 4. 目标目录结构
58
+ ## 3. Source Tree
75
59
 
76
60
  ```text
77
- VibeCodingMaster/
78
- package.json
79
- tsconfig.json
80
- tsconfig.node.json
81
- vite.config.ts
82
- vitest.config.ts
83
- playwright.config.ts
84
- index.html
85
- README.md
86
- docs/
87
- product-design.md
88
- v1-architecture-design.md
89
- v1-implementation-plan.md
90
- cc-best-practices.md
91
-
92
- src/
93
- main.ts
94
-
95
- shared/
96
- constants.ts
97
- types/
98
- api.ts
99
- artifact.ts
100
- project.ts
101
- role.ts
102
- session.ts
103
- task.ts
104
- terminal.ts
105
- validation/
106
- artifact-check.ts
107
- slug-check.ts
108
-
109
- frontend/
110
- app.tsx
111
- main.tsx
112
- styles.css
113
- routes/
114
- project-dashboard.tsx
115
- task-workspace.tsx
116
- components/
117
- app-shell.tsx
118
- event-log.tsx
119
- repo-connect-form.tsx
120
- role-session-tabs.tsx
121
- session-console.tsx
122
- session-toolbar.tsx
123
- status-badge.tsx
124
- task-nav.tsx
125
- terminal/
126
- terminal-client.ts
127
- xterm-view.tsx
128
- state/
129
- api-client.ts
130
- app-store.ts
131
- session-store.ts
132
-
133
- backend/
134
- server.ts
135
- api/
136
- artifact-routes.ts
137
- project-routes.ts
138
- session-routes.ts
139
- task-routes.ts
140
- ws/
141
- terminal-ws.ts
142
- runtime/
143
- node-pty-runtime.ts
144
- session-registry.ts
145
- terminal-runtime.ts
146
- services/
147
- artifact-service.ts
148
- command-dispatcher.ts
149
- project-service.ts
150
- session-service.ts
151
- status-service.ts
152
- task-service.ts
153
- adapters/
154
- claude-adapter.ts
155
- command-runner.ts
156
- filesystem.ts
157
- git-adapter.ts
158
- templates/
159
- handoff.ts
160
- role-command.ts
161
- validation/
162
- environment-check.ts
163
-
164
- tests/
165
- unit/
166
- shared/
167
- backend/
168
- frontend/
169
- integration/
170
- api/
171
- runtime/
172
- e2e/
173
- task-workspace.spec.ts
61
+ src/
62
+ main.ts
63
+ cli/
64
+ vcmctl.ts
65
+ shared/
66
+ constants.ts
67
+ types/
68
+ validation/
69
+ backend/
70
+ server.ts
71
+ adapters/
72
+ api/
73
+ runtime/
74
+ services/
75
+ templates/
76
+ ws/
77
+ frontend/
78
+ app.tsx
79
+ main.tsx
80
+ routes/
81
+ components/
82
+ state/
83
+ terminal/
84
+ styles.css
174
85
  ```
175
86
 
176
- ## 5. Package 和配置文件
177
-
178
- ### 5.1 `package.json`
179
-
180
- 职责:
181
-
182
- - 声明本地开发命令。
183
- - 声明 build、test、typecheck、e2e 命令。
184
- - 保留 `vcm` binary 用于启动本地 GUI dev/prod server。
185
-
186
- 计划字段:
187
-
188
- ```json
189
- {
190
- "type": "module",
191
- "bin": {
192
- "vcm": "./dist/main.js"
193
- },
194
- "scripts": {
195
- "dev": "tsx src/main.ts --dev",
196
- "build": "tsc -p tsconfig.node.json && vite build",
197
- "start": "node dist/main.js",
198
- "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.node.json --noEmit",
199
- "test": "vitest run",
200
- "test:watch": "vitest",
201
- "e2e": "playwright test"
202
- },
203
- "dependencies": {
204
- "@fastify/static": "^7.0.0",
205
- "@xterm/addon-fit": "^0.10.0",
206
- "@xterm/addon-web-links": "^0.11.0",
207
- "@xterm/xterm": "^5.5.0",
208
- "execa": "^9.0.0",
209
- "fastify": "^5.0.0",
210
- "node-pty": "^1.0.0",
211
- "react": "^19.0.0",
212
- "react-dom": "^19.0.0",
213
- "ws": "^8.0.0",
214
- "zod": "^3.0.0"
215
- },
216
- "devDependencies": {
217
- "@playwright/test": "^1.0.0",
218
- "@types/node": "^22.0.0",
219
- "@types/react": "^19.0.0",
220
- "@types/react-dom": "^19.0.0",
221
- "@types/ws": "^8.0.0",
222
- "@vitejs/plugin-react": "^4.0.0",
223
- "tsx": "^4.0.0",
224
- "typescript": "^5.0.0",
225
- "vite": "^6.0.0",
226
- "vitest": "^2.0.0"
227
- }
228
- }
229
- ```
87
+ Removed/obsolete files that must not be documented as active:
230
88
 
231
- ### 5.2 `tsconfig.json`
232
-
233
- 职责:
234
-
235
- - 类型检查前端和 shared 代码。
236
- - 使用 JSX。
237
- - 不输出文件。
238
-
239
- 关键配置:
240
-
241
- ```json
242
- {
243
- "compilerOptions": {
244
- "target": "ES2022",
245
- "module": "ESNext",
246
- "moduleResolution": "Bundler",
247
- "jsx": "react-jsx",
248
- "strict": true,
249
- "esModuleInterop": true,
250
- "skipLibCheck": true,
251
- "types": ["vite/client"]
252
- },
253
- "include": ["src/frontend/**/*.ts", "src/frontend/**/*.tsx", "src/shared/**/*.ts"]
254
- }
255
- ```
89
+ - `src/shared/validation/translation-classifier.ts`
90
+ - `src/frontend/state/translation-store.ts`
91
+ - `src/frontend/components/translation-entry-row.tsx`
92
+ - `src/frontend/state/task-store.ts`
256
93
 
257
- ### 5.3 `tsconfig.node.json`
258
-
259
- 职责:
260
-
261
- - 编译 backend、main 和 shared 代码到 `dist/`。
262
- - 使用 NodeNext ESM。
263
-
264
- 关键配置:
265
-
266
- ```json
267
- {
268
- "compilerOptions": {
269
- "target": "ES2022",
270
- "module": "NodeNext",
271
- "moduleResolution": "NodeNext",
272
- "rootDir": "src",
273
- "outDir": "dist",
274
- "strict": true,
275
- "esModuleInterop": true,
276
- "skipLibCheck": true
277
- },
278
- "include": ["src/main.ts", "src/backend/**/*.ts", "src/shared/**/*.ts"]
279
- }
280
- ```
94
+ ## 4. Entry Points
281
95
 
282
- ### 5.4 `vite.config.ts`
283
-
284
- 职责:
285
-
286
- - 构建 React frontend。
287
- - 开发时代理 API 和 WebSocket 到 local backend。
288
-
289
- 导出定义:
290
-
291
- ```ts
292
- export default defineConfig({
293
- plugins: [react()],
294
- root: ".",
295
- build: {
296
- outDir: "dist-frontend"
297
- },
298
- server: {
299
- port: 5173,
300
- proxy: {
301
- "/api": "http://localhost:4173",
302
- "/ws": {
303
- target: "ws://localhost:4173",
304
- ws: true
305
- }
306
- }
307
- }
308
- });
309
- ```
96
+ ### `src/main.ts`
310
97
 
311
- ### 5.5 `vitest.config.ts`
98
+ Exports:
312
99
 
313
- 职责:
100
+ - `MainOptions`
101
+ - `parseMainArgs(argv): MainOptions`
102
+ - `main(argv): Promise<void>`
314
103
 
315
- - 运行 unit 和 integration tests。
316
- - 使用 node environment。
104
+ Responsibilities:
317
105
 
318
- 导出定义:
106
+ - parse `--dev`, `--open`, `--host=`, `--port=`
107
+ - start backend on port `4173` by default
108
+ - start Vite on port `5173` in dev mode
109
+ - serve `dist-frontend` through backend in production mode
110
+ - close backend/Vite on `SIGINT`
319
111
 
320
- ```ts
321
- export default defineConfig({
322
- test: {
323
- environment: "node",
324
- include: ["tests/unit/**/*.test.ts", "tests/integration/**/*.test.ts"]
325
- }
326
- });
327
- ```
112
+ ### `src/cli/vcmctl.ts`
328
113
 
329
- ### 5.6 `playwright.config.ts`
114
+ CLI commands:
330
115
 
331
- 职责:
116
+ - `vcmctl send`
117
+ - `vcmctl reply`
118
+ - `vcmctl result`
119
+ - `vcmctl inbox`
120
+ - `vcmctl ready`
332
121
 
333
- - 运行 GUI smoke tests。
334
- - 启动 `npm run dev` 作为 webServer。
122
+ Environment required in role sessions:
335
123
 
336
- 导出定义:
124
+ - `VCM_API_URL`
125
+ - `VCM_TASK_SLUG`
126
+ - `VCM_ROLE`
337
127
 
338
- ```ts
339
- export default defineConfig({
340
- testDir: "tests/e2e",
341
- webServer: {
342
- command: "npm run dev",
343
- url: "http://localhost:5173",
344
- reuseExistingServer: true
345
- }
346
- });
347
- ```
128
+ Role sessions receive these env vars from `SessionService`.
348
129
 
349
- ### 5.7 `src/main.ts`
130
+ ## 5. Shared Layer
350
131
 
351
- 职责:
132
+ ### `src/shared/constants.ts`
352
133
 
353
- - 启动 local backend。
354
- - 在 dev 模式提示 Vite URL。
355
- - 在 prod 模式 serve frontend static assets。
134
+ Exports:
356
135
 
357
- 导出定义:
136
+ - `DEFAULT_BACKEND_PORT`
137
+ - `DEFAULT_FRONTEND_PORT`
138
+ - `ROLE_DEFINITIONS`
139
+ - `ROLE_NAMES`
140
+ - `DISPATCHABLE_ROLES`
141
+ - `isRoleName(value)`
142
+ - `isDispatchableRole(value)`
143
+ - `getRoleDefinition(role)`
358
144
 
359
- ```ts
360
- export interface MainOptions {
361
- dev?: boolean;
362
- host?: string;
363
- port?: number;
364
- open?: boolean;
365
- }
145
+ Roles:
366
146
 
367
- export function parseMainArgs(argv: string[]): MainOptions;
147
+ - `project-manager`
148
+ - `architect`
149
+ - `coder`
150
+ - `reviewer`
368
151
 
369
- export async function main(argv?: string[]): Promise<void>;
370
- ```
152
+ Dispatchable roles:
371
153
 
372
- ## 6. Shared 类型层
373
-
374
- ### 6.1 `src/shared/types/role.ts`
375
-
376
- 职责:
377
-
378
- - 定义 V1 role 集合和状态。
379
-
380
- 导出定义:
381
-
382
- ```ts
383
- export type RoleName =
384
- | "project-manager"
385
- | "architect"
386
- | "coder"
387
- | "reviewer";
388
-
389
- export type DispatchableRole =
390
- | "architect"
391
- | "coder"
392
- | "reviewer";
393
-
394
- export type RoleStatus =
395
- | "not_started"
396
- | "starting"
397
- | "running"
398
- | "waiting"
399
- | "blocked"
400
- | "done"
401
- | "resumable"
402
- | "crashed"
403
- | "exited"
404
- | "missing"
405
- | "unknown";
406
-
407
- export interface RoleDefinition {
408
- name: RoleName;
409
- label: string;
410
- commandAgent: string;
411
- dispatchable: boolean;
412
- }
413
- ```
154
+ - `architect`
155
+ - `coder`
156
+ - `reviewer`
414
157
 
415
- ### 6.2 `src/shared/constants.ts`
158
+ ### `src/shared/types/role.ts`
416
159
 
417
- 职责:
160
+ Defines:
418
161
 
419
- - 定义固定 role、artifact 文件名、默认端口。
162
+ - `RoleName`
163
+ - `DispatchableRole`
164
+ - `RoleStatus`
165
+ - `RoleDefinition`
420
166
 
421
- 导出定义:
167
+ ### `src/shared/types/project.ts`
422
168
 
423
- ```ts
424
- export const DEFAULT_BACKEND_PORT = 4173;
425
- export const DEFAULT_FRONTEND_PORT = 5173;
169
+ Defines:
426
170
 
427
- export const ROLE_DEFINITIONS: readonly RoleDefinition[];
428
- export const ROLE_NAMES: readonly RoleName[];
429
- export const DISPATCHABLE_ROLES: readonly DispatchableRole[];
171
+ - `ProjectConfig`
172
+ - `ProjectSummary`
173
+ - `ConnectProjectRequest`
430
174
 
431
- export function isRoleName(value: string): value is RoleName;
432
- export function isDispatchableRole(value: string): value is DispatchableRole;
433
- export function getRoleDefinition(role: RoleName): RoleDefinition;
434
- ```
175
+ Important fields:
435
176
 
436
- ### 6.3 `src/shared/types/project.ts`
177
+ - `handoffRoot`
178
+ - `stateRoot`
179
+ - `terminalBackend`
180
+ - `claudeCommand`
181
+ - `isDirty`
437
182
 
438
- 职责:
183
+ ### `src/shared/types/task.ts`
439
184
 
440
- - 定义 repo 连接和项目配置。
185
+ Defines:
441
186
 
442
- 导出定义:
187
+ - `TaskStatus`
188
+ - `TaskRecord`
189
+ - `CreateTaskRequest`
443
190
 
444
- ```ts
445
- export interface ProjectConfig {
446
- version: 1;
447
- repoRoot: string;
448
- defaultRoles: RoleName[];
449
- handoffRoot: string;
450
- stateRoot: string;
451
- terminalBackend: "node-pty";
452
- claudeCommand: string;
453
- }
191
+ Current UI sends only `taskSlug`, although the API type still permits optional `title` and `specPath`.
454
192
 
455
- export interface ProjectSummary {
456
- repoRoot: string;
457
- branch: string;
458
- isDirty: boolean;
459
- config: ProjectConfig;
460
- warnings: string[];
461
- }
193
+ ### `src/shared/types/session.ts`
462
194
 
463
- export interface ConnectProjectRequest {
464
- repoPath: string;
465
- }
466
- ```
195
+ Defines:
467
196
 
468
- ### 6.4 `src/shared/types/task.ts`
469
-
470
- 职责:
471
-
472
- - 定义 task metadata。
473
-
474
- 导出定义:
475
-
476
- ```ts
477
- export type TaskStatus =
478
- | "created"
479
- | "planning"
480
- | "running"
481
- | "blocked"
482
- | "stopped"
483
- | "done";
484
-
485
- export interface TaskRecord {
486
- version: 1;
487
- taskSlug: string;
488
- title?: string;
489
- createdAt: string;
490
- updatedAt: string;
491
- repoRoot: string;
492
- branch: string;
493
- handoffDir: string;
494
- status: TaskStatus;
495
- specPath?: string;
496
- }
497
-
498
- export interface CreateTaskRequest {
499
- taskSlug: string;
500
- title?: string;
501
- specPath?: string;
502
- }
503
- ```
197
+ - `ClaudePermissionMode`
198
+ - `RoleSessionRecord`
199
+ - `TaskSessionRecord`
200
+ - `RoleSessionPointer`
201
+ - `StartRoleSessionRequest`
504
202
 
505
- ### 6.5 `src/shared/types/session.ts`
506
-
507
- 职责:
508
-
509
- - 定义 role session metadata 和 task session summary。
510
-
511
- 导出定义:
512
-
513
- ```ts
514
- export type ClaudePermissionMode =
515
- | "default"
516
- | "bypassPermissions"
517
- | "dangerously-skip-permissions";
518
-
519
- export interface RoleSessionRecord {
520
- id: string;
521
- claudeSessionId: string;
522
- taskSlug: string;
523
- role: RoleName;
524
- status: RoleStatus;
525
- command: string;
526
- permissionMode: ClaudePermissionMode;
527
- cwd: string;
528
- terminalBackend: "node-pty";
529
- pid?: number;
530
- logPath: string;
531
- roleCommandPath?: string;
532
- handoffArtifactPath?: string;
533
- startedAt?: string;
534
- updatedAt: string;
535
- lastOutputAt?: string;
536
- exitCode?: number | null;
537
- }
538
-
539
- export interface TaskSessionRecord {
540
- version: 1;
541
- taskSlug: string;
542
- updatedAt: string;
543
- roles: Record<RoleName, RoleSessionPointer>;
544
- }
545
-
546
- export interface RoleSessionPointer {
547
- id: string | null;
548
- claudeSessionId?: string;
549
- status: RoleStatus;
550
- record?: RoleSessionRecord;
551
- }
552
-
553
- export interface StartRoleSessionRequest {
554
- cols?: number;
555
- rows?: number;
556
- permissionMode?: ClaudePermissionMode;
557
- }
558
- ```
203
+ `RoleSessionRecord` includes `claudeSessionId` and `transcriptPath`, which are required for resume and translation transcript lookup.
559
204
 
560
- ### 6.6 `src/shared/types/terminal.ts`
205
+ ### `src/shared/types/message.ts`
561
206
 
562
- 职责:
207
+ Defines:
563
208
 
564
- - 定义 WebSocket terminal 消息和事件。
209
+ - `VcmMessageActor`
210
+ - `VcmMessageType`
211
+ - `VcmMessageStatus`
212
+ - `VcmOrchestrationMode`
213
+ - `VcmRoleMessage`
214
+ - `VcmOrchestrationState`
215
+ - `SendRoleMessageRequest`
216
+ - `SendRoleMessageResult`
565
217
 
566
- 导出定义:
218
+ The state type includes `paused` for backend/API compatibility. The current GUI only exposes manual/auto.
567
219
 
568
- ```ts
569
- export type ClientTerminalMessage =
570
- | { type: "input"; data: string }
571
- | { type: "resize"; cols: number; rows: number };
220
+ ### `src/shared/types/translation.ts`
572
221
 
573
- export type ServerTerminalMessage =
574
- | { type: "output"; data: string }
575
- | { type: "status"; status: RoleStatus }
576
- | { type: "exit"; exitCode: number | null }
577
- | { type: "error"; message: string };
222
+ Defines:
578
223
 
579
- export interface TerminalEvent {
580
- id: string;
581
- sessionId: string;
582
- taskSlug: string;
583
- role: RoleName;
584
- type: "input" | "output" | "status" | "exit" | "error" | "dispatch";
585
- timestamp: string;
586
- data?: string;
587
- status?: RoleStatus;
588
- exitCode?: number | null;
589
- }
590
- ```
224
+ - `TranslationProviderType`
225
+ - `TranslationDirection`
226
+ - `TranslationInputMode`
227
+ - `TranslationPromptKey`
228
+ - `TRANSLATION_PROMPT_KEYS`
229
+ - `TranslationSourceKind`
230
+ - `TranslationStatus`
231
+ - `TranslationSettings`
232
+ - `TranslationSecretSettings`
233
+ - `TranslationEntry`
234
+ - `TranslateUserInputRequest`
235
+ - `TranslateUserInputResult`
236
+ - `SendTranslatedInputRequest`
237
+ - `TranslationProviderTestResult`
238
+ - `TranslationPromptPreview`
239
+ - `TranslationWsMessage`
591
240
 
592
- ### 6.7 `src/shared/types/artifact.ts`
593
-
594
- 职责:
595
-
596
- - 定义 handoff artifact paths 和 schema check。
597
-
598
- 导出定义:
599
-
600
- ```ts
601
- export type ArtifactKind =
602
- | "architecture-plan"
603
- | "implementation-log"
604
- | "validation-log"
605
- | "review-report";
606
-
607
- export interface HandoffPaths {
608
- handoffDir: string;
609
- roleCommandsDir: string;
610
- logsDir: string;
611
- roleCommandPaths: Record<DispatchableRole, string>;
612
- roleLogPaths: Record<RoleName, string>;
613
- architecturePlanPath: string;
614
- implementationLogPath: string;
615
- validationLogPath: string;
616
- reviewReportPath: string;
617
- }
618
-
619
- export interface ArtifactCheckResult {
620
- kind: ArtifactKind;
621
- path: string;
622
- exists: boolean;
623
- isEmpty: boolean;
624
- missingHeadings: string[];
625
- status: "missing" | "empty" | "incomplete" | "ok";
626
- }
627
-
628
- export interface ArtifactSummary {
629
- paths: HandoffPaths;
630
- checks: ArtifactCheckResult[];
631
- }
632
- ```
241
+ Prompt keys:
633
242
 
634
- ### 6.8 `src/shared/types/api.ts`
243
+ - `zh-to-en`
244
+ - `zh-to-en-with-context`
245
+ - `en-to-zh`
635
246
 
636
- 职责:
247
+ Source kinds:
637
248
 
638
- - 定义统一 API response。
249
+ - `prose`
250
+ - `tool-output`
639
251
 
640
- 导出定义:
252
+ Statuses:
641
253
 
642
- ```ts
643
- export interface ApiSuccess<T> {
644
- ok: true;
645
- data: T;
646
- }
254
+ - `queued`
255
+ - `translating`
256
+ - `translated`
257
+ - `failed`
258
+ - `preserved`
647
259
 
648
- export interface ApiFailure {
649
- ok: false;
650
- error: {
651
- code: string;
652
- message: string;
653
- hint?: string;
654
- };
655
- }
260
+ ### `src/shared/types/api.ts`
656
261
 
657
- export type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
658
- ```
262
+ Defines:
659
263
 
660
- ## 7. Shared Validation
264
+ - `ApiErrorResponse`
265
+ - `TaskStatusReport`
266
+ - `TaskWorkflowStepId`
267
+ - `TaskWorkflowStepStatus`
268
+ - `TaskWorkflowStep`
269
+ - `TaskWorkflowReport`
270
+ - `DispatchRoleCommandResult`
271
+ - `BootstrapState`
661
272
 
662
- ### 7.1 `src/shared/validation/slug-check.ts`
273
+ ### `src/shared/types/artifact.ts`
663
274
 
664
- 导出定义:
275
+ Defines:
665
276
 
666
- ```ts
667
- export interface SlugValidationResult {
668
- valid: boolean;
669
- reason?: string;
670
- suggestion?: string;
671
- }
277
+ - `ArtifactKind`
278
+ - `HandoffPaths`
279
+ - `ArtifactCheckResult`
280
+ - `ArtifactSummary`
672
281
 
673
- export function isValidTaskSlug(value: string): boolean;
674
- export function validateTaskSlug(value: string): SlugValidationResult;
675
- export function assertValidTaskSlug(value: string): string;
676
- export function suggestTaskSlug(value: string): string;
677
- ```
282
+ Artifact kinds:
678
283
 
679
- ### 7.2 `src/shared/validation/artifact-check.ts`
284
+ - `architecture-plan`
285
+ - `implementation-log`
286
+ - `validation-log`
287
+ - `review-report`
288
+ - `docs-sync-report`
680
289
 
681
- 导出定义:
290
+ ### `src/shared/types/harness.ts`
682
291
 
683
- ```ts
684
- export const REQUIRED_ARCHITECTURE_PLAN_HEADINGS: readonly string[];
685
- export const REQUIRED_IMPLEMENTATION_LOG_HEADINGS: readonly string[];
686
- export const REQUIRED_REVIEW_REPORT_HEADINGS: readonly string[];
292
+ Defines:
687
293
 
688
- export function getRequiredHeadings(kind: ArtifactKind): readonly string[];
689
- export function parseMarkdownHeadings(content: string): string[];
690
- export function findMissingHeadings(content: string, required: readonly string[]): string[];
691
- export function checkMarkdownArtifact(kind: ArtifactKind, path: string, content: string | null): ArtifactCheckResult;
692
- export function checkValidationLogArtifact(path: string, content: string | null): ArtifactCheckResult;
693
- ```
294
+ - `HarnessFileKind`
295
+ - `HarnessFileAction`
296
+ - `HarnessFileStatus`
297
+ - `HarnessPlannedChange`
298
+ - `HarnessStatusReport`
299
+ - `HarnessApplyResult`
694
300
 
695
- ## 8. Backend Adapter 层
301
+ ### `src/shared/types/terminal.ts`
696
302
 
697
- ### 8.1 `src/backend/adapters/command-runner.ts`
303
+ Defines:
698
304
 
699
- 职责:
305
+ - `ClientTerminalMessage`
306
+ - `ServerTerminalMessage`
307
+ - `TerminalEvent`
700
308
 
701
- - 封装 `execa`。
702
- - 供 git / claude check 使用。
309
+ ### `src/shared/validation/slug-check.ts`
703
310
 
704
- 导出定义:
311
+ Exports:
705
312
 
706
- ```ts
707
- export interface RunCommandOptions {
708
- cwd?: string;
709
- reject?: boolean;
710
- env?: NodeJS.ProcessEnv;
711
- }
313
+ - `validateTaskSlug(taskSlug)`
314
+ - `assertValidTaskSlug(taskSlug)`
712
315
 
713
- export interface RunCommandResult {
714
- stdout: string;
715
- stderr: string;
716
- exitCode: number;
717
- }
316
+ Current rule:
718
317
 
719
- export interface CommandRunner {
720
- run(command: string, args: string[], options?: RunCommandOptions): Promise<RunCommandResult>;
721
- }
318
+ - lowercase slug-style task names
319
+ - safe for local paths and URLs
722
320
 
723
- export function createDefaultCommandRunner(): CommandRunner;
724
- export function normalizeCommandError(error: unknown): RunCommandResult;
725
- ```
321
+ ### `src/shared/validation/artifact-check.ts`
726
322
 
727
- ### 8.2 `src/backend/adapters/filesystem.ts`
323
+ Exports:
728
324
 
729
- 职责:
325
+ - `checkMarkdownArtifact(kind, path, content)`
730
326
 
731
- - 封装文件读写、JSON 读写、目录创建。
327
+ Current checks are title/placeholder oriented and do not judge semantic quality.
732
328
 
733
- 导出定义:
329
+ ### `src/shared/validation/language-detect.ts`
734
330
 
735
- ```ts
736
- export interface FileSystemAdapter {
737
- pathExists(path: string): Promise<boolean>;
738
- ensureDir(path: string): Promise<void>;
739
- readText(path: string): Promise<string>;
740
- writeText(path: string, content: string): Promise<void>;
741
- appendText(path: string, content: string): Promise<void>;
742
- readJson<T>(path: string): Promise<T>;
743
- writeJsonAtomic<T>(path: string, value: T): Promise<void>;
744
- ensureFile(path: string, content: string, options?: EnsureFileOptions): Promise<boolean>;
745
- }
331
+ Exports:
746
332
 
747
- export interface EnsureFileOptions {
748
- overwrite?: boolean;
749
- }
333
+ - `cjkRatio(value)`
334
+ - `isProbablyCjk(value, threshold)`
335
+ - `shouldSkipForTargetLanguage(value, targetLanguage)`
750
336
 
751
- export function createNodeFileSystemAdapter(): FileSystemAdapter;
752
- export function resolveRepoPath(repoRoot: string, repoRelativePath: string): string;
753
- export function toRepoRelativePath(repoRoot: string, absolutePath: string): string;
754
- ```
337
+ These helpers remain available, but current Claude-output translation no longer uses a classifier to skip assistant prose.
755
338
 
756
- ### 8.3 `src/backend/adapters/git-adapter.ts`
339
+ ## 6. Backend Adapters
757
340
 
758
- 职责:
341
+ ### `src/backend/adapters/filesystem.ts`
759
342
 
760
- - 检查 Git repo 和 branch 状态。
343
+ Exports:
761
344
 
762
- 导出定义:
345
+ - `FileSystemAdapter`
346
+ - `EnsureFileOptions`
347
+ - `createNodeFileSystemAdapter()`
348
+ - `resolveRepoPath(repoRoot, repoRelativePath)`
349
+ - `toRepoRelativePath(repoRoot, absolutePath)`
763
350
 
764
- ```ts
765
- export interface GitAdapter {
766
- isGitRepo(cwd: string): Promise<boolean>;
767
- getRepoRoot(cwd: string): Promise<string>;
768
- getCurrentBranch(repoRoot: string): Promise<string>;
769
- isDirty(repoRoot: string): Promise<boolean>;
770
- getDiffSummary(repoRoot: string): Promise<string>;
771
- }
351
+ Used by all services that touch repo/app files.
772
352
 
773
- export function createGitAdapter(runner: CommandRunner): GitAdapter;
774
- ```
353
+ ### `src/backend/adapters/command-runner.ts`
775
354
 
776
- ### 8.4 `src/backend/adapters/claude-adapter.ts`
355
+ Exports:
777
356
 
778
- 职责:
357
+ - `CommandResult`
358
+ - `CommandRunner`
359
+ - `CommandRunnerOptions`
360
+ - `createCommandRunner()`
779
361
 
780
- - 检查 Claude Code 是否安装。
781
- - 生成 role session 启动命令。
362
+ Used by Git and Claude adapters.
782
363
 
783
- 导出定义:
364
+ ### `src/backend/adapters/git-adapter.ts`
784
365
 
785
- ```ts
786
- export interface ClaudeAdapter {
787
- isAvailable(command?: string): Promise<boolean>;
788
- getVersion(command?: string): Promise<string>;
789
- buildRoleStartCommand(
790
- role: RoleName,
791
- command?: string,
792
- permissionMode?: ClaudePermissionMode
793
- ): { command: string; args: string[]; display: string };
794
- }
366
+ Exports:
795
367
 
796
- export function createClaudeAdapter(runner: CommandRunner): ClaudeAdapter;
797
- ```
368
+ - `GitRepoCheck`
369
+ - `GitAdapter`
370
+ - `createGitAdapter(runner)`
798
371
 
799
- ## 9. Backend Runtime 层
800
-
801
- ### 9.1 `src/backend/runtime/terminal-runtime.ts`
802
-
803
- 职责:
804
-
805
- - 定义 terminal runtime 抽象。
806
- - 让上层业务不依赖 node-pty 细节。
807
-
808
- 导出定义:
809
-
810
- ```ts
811
- export interface CreateTerminalSessionInput {
812
- taskSlug: string;
813
- role: RoleName;
814
- command: string;
815
- args: string[];
816
- cwd: string;
817
- env?: NodeJS.ProcessEnv;
818
- cols?: number;
819
- rows?: number;
820
- logPath: string;
821
- }
822
-
823
- export interface TerminalSession {
824
- id: string;
825
- taskSlug: string;
826
- role: RoleName;
827
- status: RoleStatus;
828
- pid?: number;
829
- startedAt: string;
830
- lastOutputAt?: string;
831
- exitCode?: number | null;
832
- }
833
-
834
- export type TerminalEventListener = (event: TerminalEvent) => void;
835
- export type Unsubscribe = () => void;
836
-
837
- export interface TerminalRuntime {
838
- createSession(input: CreateTerminalSessionInput): Promise<TerminalSession>;
839
- getSession(sessionId: string): TerminalSession | undefined;
840
- getSessionByRole(taskSlug: string, role: RoleName): TerminalSession | undefined;
841
- listSessions(taskSlug?: string): TerminalSession[];
842
- write(sessionId: string, data: string): void;
843
- resize(sessionId: string, cols: number, rows: number): void;
844
- stop(sessionId: string): Promise<void>;
845
- restart(sessionId: string): Promise<TerminalSession>;
846
- subscribe(sessionId: string, listener: TerminalEventListener): Unsubscribe;
847
- }
848
- ```
372
+ Important behavior:
849
373
 
850
- ### 9.2 `src/backend/runtime/node-pty-runtime.ts`
374
+ - checks `.git` directly
375
+ - accepts normal `.git` directories
376
+ - accepts `.git` pointer files
377
+ - passes per-command `safe.directory`
851
378
 
852
- 职责:
379
+ ### `src/backend/adapters/claude-adapter.ts`
853
380
 
854
- - 实现 `TerminalRuntime`。
855
- - 使用 node-pty 承载 Claude Code 交互式 session。
856
- - 将 output 写入 logs 并推送给 subscribers。
381
+ Exports:
857
382
 
858
- 导出定义:
383
+ - `ClaudeAdapter`
384
+ - `createClaudeAdapter(runner)`
859
385
 
860
- ```ts
861
- export interface NodePtyRuntimeDeps {
862
- fs: FileSystemAdapter;
863
- now?: () => string;
864
- id?: () => string;
865
- }
386
+ Builds role commands:
866
387
 
867
- export function createNodePtyTerminalRuntime(deps: NodePtyRuntimeDeps): TerminalRuntime;
388
+ ```text
389
+ claude --agent <role> --session-id <uuid>
390
+ claude --agent <role> --resume <uuid>
868
391
  ```
869
392
 
870
- 实现规则:
393
+ Adds permission flags for `bypassPermissions` and `dangerously-skip-permissions`.
871
394
 
872
- - `createSession` 使用 `pty.spawn(command, args, { cwd, env, cols, rows })`。
873
- - 监听 `onData`:
874
- - append 到 log。
875
- - emit `TerminalEvent`。
876
- - 更新 `lastOutputAt`。
877
- - 监听 `onExit`:
878
- - 更新 `status` 为 `exited` 或 `crashed`。
879
- - emit `exit` event。
880
- - `write` 写入 pty。
881
- - `resize` 调用 pty resize。
882
- - `stop` kill pty 并更新状态。
395
+ ### `src/backend/adapters/translation-provider.ts`
883
396
 
884
- ### 9.3 Programmatic I/O Boundary
397
+ Exports:
885
398
 
886
- V1 的 backend 允许程序化读写 embedded terminal:
399
+ - `TranslationProviderRequest`
400
+ - `TranslationProviderResult`
401
+ - `TranslationProvider`
402
+ - `TranslationProviderError`
403
+ - `createOpenAiCompatibleTranslationProvider(fetchImpl)`
404
+ - `buildChatCompletionsUrl(baseUrl)`
405
+ - `parseOpenAiUsage(raw)`
887
406
 
888
- - `runtime.write(sessionId, data)`:向指定 role session 写入 terminal input。
889
- - `runtime.subscribe(sessionId, listener)`:监听 terminal output、status、exit 和 error event。
890
- - `terminal-ws`:把用户在 GUI terminal 中输入的内容转发给 runtime。
891
- - `command-dispatcher`:在用户点击 Send Command 后,向目标 session 写入短指令。
407
+ Implements OpenAI-compatible chat completions.
892
408
 
893
- V1 允许的自动化边界:
409
+ ## 7. Backend Runtime
894
410
 
895
- - 用户在 GUI terminal 里的输入可以原样转发。
896
- - 用户点击 Send Command 后,backend 可以写入 `Please read and execute the role command at: <path>`。
897
- - Backend 可以监听 output 并写入 raw log。
898
- - Backend 可以根据 output/exit event 更新轻量状态和 GUI 提示。
411
+ ### `src/backend/runtime/terminal-runtime.ts`
899
412
 
900
- V1 明确不做:
413
+ Defines the runtime interface:
901
414
 
902
- - 不自动确认 Claude Code permission prompt。
903
- - 不由 Project Manager 自动向 Architect/Coder/Reviewer 连续下发命令。
904
- - 不由 Architect 输出自动触发 Coder。
905
- - 不由 Coder 输出自动触发 Reviewer。
906
- - 不根据 terminal output 自动执行高风险下一步。
415
+ - `CreateTerminalSessionInput`
416
+ - `TerminalSession`
417
+ - `TerminalEventListener`
418
+ - `Unsubscribe`
419
+ - `SubscribeTerminalOptions`
420
+ - `TerminalRuntime`
907
421
 
908
- ### 9.4 `src/backend/runtime/session-registry.ts`
422
+ ### `src/backend/runtime/node-pty-runtime.ts`
909
423
 
910
- 职责:
424
+ Exports:
911
425
 
912
- - 保存 backend 内存中的 live sessions。
913
- - 将 runtime state 转为 GUI 可展示状态。
426
+ - `NodePtyRuntimeDeps`
427
+ - `createNodePtyTerminalRuntime(deps)`
428
+ - `buildPtyEnvironment(baseEnv, inputEnv)`
914
429
 
915
- 导出定义:
430
+ Responsibilities:
916
431
 
917
- ```ts
918
- export interface SessionRegistry {
919
- upsert(session: RoleSessionRecord): void;
920
- get(sessionId: string): RoleSessionRecord | undefined;
921
- getByRole(taskSlug: string, role: RoleName): RoleSessionRecord | undefined;
922
- list(taskSlug?: string): RoleSessionRecord[];
923
- updateStatus(sessionId: string, status: RoleStatus, patch?: Partial<RoleSessionRecord>): void;
924
- remove(sessionId: string): void;
925
- }
432
+ - spawn Claude Code with `node-pty`
433
+ - append raw output to role log file
434
+ - emit terminal output/input/exit events
435
+ - replay logs on subscribe
436
+ - handle writes, resize, stop
437
+ - set color-friendly terminal env vars
926
438
 
927
- export function createSessionRegistry(): SessionRegistry;
928
- ```
439
+ ### `src/backend/runtime/session-registry.ts`
929
440
 
930
- ## 10. Backend Service 层
441
+ Exports:
931
442
 
932
- ### 10.1 `src/backend/services/project-service.ts`
443
+ - `SessionRegistry`
444
+ - `createSessionRegistry()`
933
445
 
934
- 职责:
446
+ In-memory index for live/persisted role records by runtime session id and role.
935
447
 
936
- - 连接 repo。
937
- - 创建 `.vcm/config.json`。
938
- - 检查 Claude Code、branch、dirty state。
448
+ ## 8. Backend Services
939
449
 
940
- 导出定义:
450
+ ### `src/backend/services/project-service.ts`
941
451
 
942
- ```ts
943
- export interface ProjectService {
944
- connectProject(input: ConnectProjectInput): Promise<ProjectSummary>;
945
- getCurrentProject(): Promise<ProjectSummary | null>;
946
- loadConfig(repoRoot: string): Promise<ProjectConfig>;
947
- saveConfig(config: ProjectConfig, force?: boolean): Promise<void>;
948
- getConfigPath(repoRoot: string): string;
949
- }
452
+ Exports:
950
453
 
951
- export interface ProjectServiceDeps {
952
- fs: FileSystemAdapter;
953
- git: GitAdapter;
954
- claude: ClaudeAdapter;
955
- }
454
+ - `ProjectService`
455
+ - `ProjectServiceDeps`
456
+ - `createProjectService(deps)`
457
+ - `buildDefaultProjectConfig(repoRoot)`
956
458
 
957
- export function createProjectService(deps: ProjectServiceDeps): ProjectService;
958
- export function buildDefaultProjectConfig(repoRoot: string): ProjectConfig;
959
- ```
459
+ Responsibilities:
960
460
 
961
- ### 10.2 `src/backend/services/task-service.ts`
461
+ - connect repo
462
+ - store current project in process memory
463
+ - record recent repo paths in app settings
464
+ - create `.vcm/config.json`
465
+ - ensure base state directories
962
466
 
963
- 职责:
467
+ ### `src/backend/services/task-service.ts`
964
468
 
965
- - 创建任务 metadata。
966
- - 创建 handoff structure。
967
- - 读取任务列表和单个任务。
469
+ Exports:
968
470
 
969
- 导出定义:
471
+ - `TaskService`
472
+ - `TaskServiceDeps`
473
+ - `createTaskService(deps)`
970
474
 
971
- ```ts
972
- export interface TaskService {
973
- createTask(repoRoot: string, input: CreateTaskRequest): Promise<TaskRecord>;
974
- listTasks(repoRoot: string): Promise<TaskRecord[]>;
975
- loadTask(repoRoot: string, taskSlug: string): Promise<TaskRecord>;
976
- saveTask(repoRoot: string, task: TaskRecord): Promise<void>;
977
- updateTaskStatus(repoRoot: string, taskSlug: string, status: TaskStatus): Promise<TaskRecord>;
978
- }
475
+ Responsibilities:
979
476
 
980
- export interface TaskServiceDeps {
981
- fs: FileSystemAdapter;
982
- git: GitAdapter;
983
- artifactService: ArtifactService;
984
- projectService: Pick<ProjectService, "loadConfig">;
985
- }
477
+ - create task
478
+ - list tasks
479
+ - load task
480
+ - save task
481
+ - update task status
986
482
 
987
- export function createTaskService(deps: TaskServiceDeps): TaskService;
483
+ Task files:
484
+
485
+ ```text
486
+ .vcm/tasks/<task>.json
988
487
  ```
989
488
 
990
- ### 10.3 `src/backend/services/artifact-service.ts`
991
-
992
- 职责:
993
-
994
- - 创建 handoff 目录结构。
995
- - 创建 artifact 模板。
996
- - 读写 role command。
997
- - 检查 artifact 状态。
998
- - 追加 raw logs。
999
-
1000
- 导出定义:
1001
-
1002
- ```ts
1003
- export interface ArtifactService {
1004
- getHandoffPaths(repoRoot: string, handoffDir: string): HandoffPaths;
1005
- ensureHandoffStructure(input: EnsureHandoffStructureInput): Promise<HandoffPaths>;
1006
- createArtifactTemplates(input: CreateArtifactTemplatesInput): Promise<string[]>;
1007
- listArtifacts(input: ListArtifactsInput): Promise<ArtifactSummary>;
1008
- readArtifact(input: ReadArtifactInput): Promise<string>;
1009
- readRoleCommand(input: ReadRoleCommandInput): Promise<string>;
1010
- saveRoleCommand(input: SaveRoleCommandInput): Promise<void>;
1011
- appendRoleLog(input: AppendRoleLogInput): Promise<void>;
1012
- }
1013
-
1014
- export interface EnsureHandoffStructureInput {
1015
- repoRoot: string;
1016
- taskSlug: string;
1017
- handoffDir: string;
1018
- }
1019
-
1020
- export interface CreateArtifactTemplatesInput {
1021
- repoRoot: string;
1022
- taskSlug: string;
1023
- handoffDir: string;
1024
- overwrite?: boolean;
1025
- }
1026
-
1027
- export interface ListArtifactsInput {
1028
- repoRoot: string;
1029
- taskSlug: string;
1030
- handoffDir: string;
1031
- }
1032
-
1033
- export interface ReadArtifactInput {
1034
- repoRoot: string;
1035
- path: string;
1036
- }
1037
-
1038
- export interface ReadRoleCommandInput {
1039
- repoRoot: string;
1040
- handoffDir: string;
1041
- role: DispatchableRole;
1042
- }
1043
-
1044
- export interface SaveRoleCommandInput {
1045
- repoRoot: string;
1046
- handoffDir: string;
1047
- role: DispatchableRole;
1048
- content: string;
1049
- }
1050
-
1051
- export interface AppendRoleLogInput {
1052
- repoRoot: string;
1053
- handoffDir: string;
1054
- role: RoleName;
1055
- content: string;
1056
- }
1057
-
1058
- export function createArtifactService(fs: FileSystemAdapter): ArtifactService;
489
+ ### `src/backend/services/artifact-service.ts`
490
+
491
+ Exports:
492
+
493
+ - `ArtifactService`
494
+ - input interfaces for handoff, artifacts, role commands, logs
495
+ - `createArtifactService(fs)`
496
+
497
+ Responsibilities:
498
+
499
+ - compute handoff paths
500
+ - create handoff directory structure
501
+ - create artifact templates
502
+ - list artifact checks
503
+ - read artifacts
504
+ - read/save role commands
505
+ - append role logs
506
+
507
+ Primary role command path:
508
+
509
+ ```text
510
+ .ai/handoffs/<task>/role-commands/<role>.md
1059
511
  ```
1060
512
 
1061
- ### 10.4 `src/backend/services/session-service.ts`
1062
-
1063
- 职责:
1064
-
1065
- - 启动、停止、重启 role session。
1066
- - 同步 runtime、registry 和 `.vcm/sessions` metadata。
1067
- - 首次启动生成 `claudeSessionId`,并使用 `claude --agent <role> --session-id <uuid>`。
1068
- - 异常中断或 backend 重启后,从 `.vcm/sessions/<task-slug>.json` 恢复 role metadata。
1069
- - Resume 使用 `claude --agent <role> --resume <claudeSessionId>` 创建新的 embedded terminal。
1070
- - Restart 优先复用已有 `claudeSessionId`,避免丢失长任务上下文。
1071
-
1072
- 导出定义:
1073
-
1074
- ```ts
1075
- export interface SessionService {
1076
- listSessions(repoRoot: string, taskSlug: string): Promise<RoleSessionRecord[]>;
1077
- startRoleSession(input: StartRoleSessionInput): Promise<RoleSessionRecord>;
1078
- resumeRoleSession(input: StartRoleSessionInput): Promise<RoleSessionRecord>;
1079
- stopRoleSession(input: StopRoleSessionInput): Promise<RoleSessionRecord>;
1080
- restartRoleSession(input: RestartRoleSessionInput): Promise<RoleSessionRecord>;
1081
- getRoleSession(repoRoot: string, taskSlug: string, role: RoleName): Promise<RoleSessionRecord | null>;
1082
- }
1083
-
1084
- export interface StartRoleSessionInput {
1085
- repoRoot: string;
1086
- taskSlug: string;
1087
- role: RoleName;
1088
- cols?: number;
1089
- rows?: number;
1090
- permissionMode?: ClaudePermissionMode;
1091
- }
1092
-
1093
- export interface StopRoleSessionInput {
1094
- repoRoot: string;
1095
- taskSlug: string;
1096
- role: RoleName;
1097
- }
1098
-
1099
- export interface RestartRoleSessionInput extends StopRoleSessionInput {
1100
- cols?: number;
1101
- rows?: number;
1102
- }
1103
-
1104
- export interface SessionServiceDeps {
1105
- claude: ClaudeAdapter;
1106
- runtime: TerminalRuntime;
1107
- registry: SessionRegistry;
1108
- taskService: TaskService;
1109
- artifactService: ArtifactService;
1110
- projectService: Pick<ProjectService, "loadConfig">;
1111
- }
1112
-
1113
- export function createSessionService(deps: SessionServiceDeps): SessionService;
513
+ Legacy fallback:
514
+
515
+ ```text
516
+ .ai/handoffs/<task>/role-commands/<role>-command.md
1114
517
  ```
1115
518
 
1116
- ### 10.5 `src/backend/services/command-dispatcher.ts`
519
+ ### `src/backend/services/status-service.ts`
1117
520
 
1118
- 职责:
521
+ Exports:
1119
522
 
1120
- - 从 role command artifact 读取命令。
1121
- - 将短指令写入目标 role terminal。
1122
- - 记录 dispatch event。
523
+ - `StatusService`
524
+ - `StatusServiceDeps`
525
+ - `createStatusService(deps)`
1123
526
 
1124
- 导出定义:
527
+ Responsibilities:
1125
528
 
1126
- ```ts
1127
- export interface CommandDispatcher {
1128
- dispatchRoleCommand(input: DispatchRoleCommandInput): Promise<DispatchRoleCommandResult>;
1129
- }
529
+ - assemble `TaskStatusReport`
530
+ - list sessions
531
+ - list artifact checks
532
+ - compute workflow report
1130
533
 
1131
- export interface DispatchRoleCommandInput {
1132
- repoRoot: string;
1133
- taskSlug: string;
1134
- role: DispatchableRole;
1135
- }
534
+ ### `src/backend/services/session-service.ts`
1136
535
 
1137
- export interface DispatchRoleCommandResult {
1138
- taskSlug: string;
1139
- role: DispatchableRole;
1140
- commandPath: string;
1141
- instruction: string;
1142
- dispatchedAt: string;
1143
- }
536
+ Exports:
1144
537
 
1145
- export interface CommandDispatcherDeps {
1146
- runtime: TerminalRuntime;
1147
- sessionService: SessionService;
1148
- taskService: TaskService;
1149
- artifactService: ArtifactService;
1150
- }
538
+ - `SessionService`
539
+ - `SessionServiceDeps`
540
+ - `createSessionService(deps)`
1151
541
 
1152
- export function createCommandDispatcher(deps: CommandDispatcherDeps): CommandDispatcher;
1153
- ```
542
+ Responsibilities:
1154
543
 
1155
- 实现规则:
544
+ - start role session
545
+ - resume role session
546
+ - restart role session
547
+ - stop role session
548
+ - get role session
549
+ - list role sessions
1156
550
 
1157
- - role command 文件缺失时失败。
1158
- - role command 文件为空时失败。
1159
- - role command 文件仍是模板或包含 `TBD` / `status: draft` 时失败。
1160
- - role command 必须使用当前 VCM task 的 canonical path:`.ai/handoffs/<task-slug>/role-commands/<role>.md`。
1161
- - Project Manager 启动时,backend 必须向 session 注入 task context,明确 `taskSlug`、`handoffDir` 和三个 role command 路径。
1162
- - 目标 role session 未运行时失败并提示启动 session。
1163
- - `instruction` 必须是短文本:
1164
- - 只有用户通过 GUI 点击 Send Command 时才调用 dispatch。
1165
- - dispatch 不解析 Claude Code 输出,不自动重试,不自动确认权限。
1166
- - dispatch 成功后只记录 event,不继续触发下一个 role。
551
+ Persistence:
1167
552
 
1168
553
  ```text
1169
- Please read and execute the role command at: <path>
554
+ .vcm/sessions/<task>.json
1170
555
  ```
1171
556
 
1172
- ### 10.6 `src/backend/services/status-service.ts`
557
+ Environment passed to Claude Code:
1173
558
 
1174
- 职责:
559
+ - `VCM_API_URL`
560
+ - `VCM_CTL_COMMAND`
561
+ - `VCM_TASK_SLUG`
562
+ - `VCM_ROLE`
1175
563
 
1176
- - 汇总 task、sessions、artifacts、events。
564
+ ### `src/backend/services/message-service.ts`
1177
565
 
1178
- 导出定义:
566
+ Exports:
1179
567
 
1180
- ```ts
1181
- export interface TaskStatusReport {
1182
- task: TaskRecord;
1183
- sessions: RoleSessionRecord[];
1184
- artifacts: ArtifactSummary;
1185
- warnings: string[];
1186
- }
568
+ - `MessageService`
569
+ - input interfaces
570
+ - `createMessageService(deps)`
1187
571
 
1188
- export interface StatusService {
1189
- getTaskStatus(repoRoot: string, taskSlug: string): Promise<TaskStatusReport>;
1190
- }
572
+ Responsibilities:
1191
573
 
1192
- export interface StatusServiceDeps {
1193
- taskService: TaskService;
1194
- sessionService: SessionService;
1195
- artifactService: ArtifactService;
1196
- }
574
+ - list messages
575
+ - send messages
576
+ - stage/approve/reject messages
577
+ - get/update orchestration state
578
+ - enforce message policy
579
+ - persist message snapshots
580
+ - write message body markdown
581
+ - write staged or delivered messages to target terminal
1197
582
 
1198
- export function createStatusService(deps: StatusServiceDeps): StatusService;
1199
- ```
583
+ ### `src/backend/services/command-dispatcher.ts`
1200
584
 
1201
- ## 11. Backend API 层
585
+ Exports:
1202
586
 
1203
- ### 11.1 `src/backend/server.ts`
587
+ - `CommandDispatcher`
588
+ - `DispatchRoleCommandInput`
589
+ - `CommandDispatcherDeps`
590
+ - `createCommandDispatcher(deps)`
1204
591
 
1205
- 职责:
592
+ Compatibility role-command dispatch only. Preferred orchestration is `MessageService` plus `vcmctl`.
1206
593
 
1207
- - 创建 Fastify server。
1208
- - 注册 API routes。
1209
- - 注册 WebSocket terminal bridge。
1210
- - Serve frontend assets。
594
+ ### `src/backend/services/harness-service.ts`
1211
595
 
1212
- 导出定义:
596
+ Exports:
1213
597
 
1214
- ```ts
1215
- export interface CreateServerOptions {
1216
- host?: string;
1217
- port?: number;
1218
- staticDir?: string;
1219
- dev?: boolean;
1220
- }
598
+ - `HarnessService`
599
+ - `HarnessServiceDeps`
600
+ - `VCM_HARNESS_VERSION`
601
+ - `createHarnessService(deps)`
1221
602
 
1222
- export interface ServerDeps {
1223
- projectService: ProjectService;
1224
- taskService: TaskService;
1225
- sessionService: SessionService;
1226
- artifactService: ArtifactService;
1227
- commandDispatcher: CommandDispatcher;
1228
- statusService: StatusService;
1229
- runtime: TerminalRuntime;
1230
- }
603
+ Responsibilities:
1231
604
 
1232
- export function createServer(deps: ServerDeps, options?: CreateServerOptions): Promise<FastifyInstance>;
1233
- export async function startServer(options?: CreateServerOptions): Promise<{ url: string; close(): Promise<void> }>;
1234
- ```
605
+ - inspect harness files
606
+ - plan create/insert/update/ok
607
+ - apply VCM managed blocks
608
+ - preserve user content outside managed blocks
609
+
610
+ ### `src/backend/services/app-settings-service.ts`
1235
611
 
1236
- ### 11.2 `src/backend/api/project-routes.ts`
612
+ Exports:
1237
613
 
1238
- Routes:
614
+ - `StoredTranslationConfig`
615
+ - `AppSettingsFile`
616
+ - `AppSettingsService`
617
+ - `AppSettingsServiceDeps`
618
+ - `createAppSettingsService(deps)`
619
+
620
+ Storage:
1239
621
 
1240
622
  ```text
1241
- GET /api/health
1242
- POST /api/projects/connect
1243
- GET /api/projects/current
1244
- GET /api/projects/harness
623
+ ~/.vcm/settings.json
1245
624
  ```
1246
625
 
1247
- 导出定义:
1248
-
1249
- ```ts
1250
- export function registerProjectRoutes(app: FastifyInstance, deps: ProjectRouteDeps): void;
626
+ Also migrates legacy:
1251
627
 
1252
- export interface ProjectRouteDeps {
1253
- projectService: ProjectService;
1254
- }
628
+ ```text
629
+ ~/.vibe-coding-master/settings.json
630
+ ~/.vibe-coding-master/translation.json
1255
631
  ```
1256
632
 
1257
- ### 11.3 `src/backend/api/task-routes.ts`
633
+ ### `src/backend/services/translation-prompts.ts`
1258
634
 
1259
- Routes:
635
+ Exports:
1260
636
 
1261
- ```text
1262
- GET /api/tasks
1263
- POST /api/tasks
1264
- GET /api/tasks/:taskSlug
1265
- GET /api/tasks/:taskSlug/status
1266
- ```
637
+ - `TranslationPromptInput`
638
+ - `BuiltTranslationPrompt`
639
+ - `buildTranslationPrompt(input)`
640
+ - `getTranslationPromptKey(input)`
641
+ - `getBaseTranslationPrompt(key, settings)`
642
+ - `resolveTranslationSystemPrompt(key, settings)`
643
+ - `getTranslationPromptPreviews(settings)`
1267
644
 
1268
- 导出定义:
645
+ Owns default prompts and user overrides.
1269
646
 
1270
- ```ts
1271
- export function registerTaskRoutes(app: FastifyInstance, deps: TaskRouteDeps): void;
647
+ ### `src/backend/services/translation-queue.ts`
1272
648
 
1273
- export interface TaskRouteDeps {
1274
- projectService: ProjectService;
1275
- taskService: TaskService;
1276
- statusService: StatusService;
1277
- }
1278
- ```
649
+ Exports:
1279
650
 
1280
- ### 11.4 `src/backend/api/session-routes.ts`
651
+ - `SerialTranslationQueue`
652
+ - `TranslationQueueRegistry`
653
+ - `createSerialTranslationQueue()`
654
+ - `createTranslationQueueRegistry()`
1281
655
 
1282
- Routes:
656
+ Ensures translations for one session run serially.
1283
657
 
1284
- ```text
1285
- GET /api/tasks/:taskSlug/sessions
1286
- POST /api/tasks/:taskSlug/sessions/:role/start
1287
- POST /api/tasks/:taskSlug/sessions/:role/stop
1288
- POST /api/tasks/:taskSlug/sessions/:role/resume
1289
- POST /api/tasks/:taskSlug/sessions/:role/restart
1290
- POST /api/tasks/:taskSlug/sessions/:role/dispatch
1291
- ```
658
+ ### `src/backend/services/claude-transcript-service.ts`
1292
659
 
1293
- 导出定义:
660
+ Exports:
1294
661
 
1295
- ```ts
1296
- export function registerSessionRoutes(app: FastifyInstance, deps: SessionRouteDeps): void;
662
+ - transcript event types
663
+ - `ClaudeTranscriptService`
664
+ - `TranscriptTail`
665
+ - `createClaudeTranscriptService()`
666
+ - `resolveExistingClaudeTranscriptPath(session)`
667
+ - `findClaudeTranscriptPathBySessionId(claudeSessionId)`
668
+ - `claudeProjectsRoot()`
669
+ - `projectHash(projectDir)`
670
+ - `projectsTranscriptDir(projectDir)`
671
+ - `claudeTranscriptPath(projectDir, claudeSessionId)`
672
+ - `parseAssistantContent(line)`
1297
673
 
1298
- export interface SessionRouteDeps {
1299
- projectService: ProjectService;
1300
- sessionService: SessionService;
1301
- commandDispatcher: CommandDispatcher;
1302
- }
1303
- ```
674
+ Responsibilities:
1304
675
 
1305
- ### 11.5 `src/backend/api/artifact-routes.ts`
676
+ - tail Claude JSONL transcript files
677
+ - resolve transcript path after start/resume/restart
678
+ - parse assistant messages, tool uses, tool results, questions, todos, and agent calls
1306
679
 
1307
- Routes:
680
+ ### `src/backend/services/translation-service.ts`
1308
681
 
1309
- ```text
1310
- GET /api/tasks/:taskSlug/artifacts
1311
- GET /api/tasks/:taskSlug/artifacts/:artifactName
1312
- GET /api/tasks/:taskSlug/role-commands/:role
1313
- PUT /api/tasks/:taskSlug/role-commands/:role
1314
- GET /api/tasks/:taskSlug/logs/:role
1315
- ```
682
+ Exports:
1316
683
 
1317
- 导出定义:
684
+ - `TranslationService`
685
+ - `TranslateUserInputServiceInput`
686
+ - `SendTranslatedInputServiceInput`
687
+ - `TranslationEventListener`
688
+ - `TranslationServiceDeps`
689
+ - `createTranslationService(deps)`
690
+ - `formatTerminalSubmit(text)`
1318
691
 
1319
- ```ts
1320
- export function registerArtifactRoutes(app: FastifyInstance, deps: ArtifactRouteDeps): void;
692
+ Responsibilities:
1321
693
 
1322
- export interface ArtifactRouteDeps {
1323
- projectService: ProjectService;
1324
- taskService: TaskService;
1325
- artifactService: ArtifactService;
1326
- }
1327
- ```
694
+ - load/update translation settings
695
+ - expose prompt previews
696
+ - test provider
697
+ - translate user input
698
+ - send English text to active terminal
699
+ - subscribe to session translation events
700
+ - clear session entries
701
+ - retry failed output translation
702
+ - subscribe to Claude transcript service
703
+ - translate prose output and preserve tool output
1328
704
 
1329
- ### 11.6 `src/backend/ws/terminal-ws.ts`
705
+ ## 9. Backend API
1330
706
 
1331
- 职责:
707
+ ### `src/backend/server.ts`
1332
708
 
1333
- - 处理 `/ws/tasks/:taskSlug/sessions/:role`。
1334
- - 将 runtime events 推送给前端。
1335
- - 将前端 input/resize 写回 runtime。
709
+ Exports:
1336
710
 
1337
- 导出定义:
711
+ - `CreateServerOptions`
712
+ - `ServerDeps`
713
+ - `createServer(deps, options)`
714
+ - `startServer(options)`
715
+ - `CreateDefaultServerDepsOptions`
716
+ - `createDefaultServerDeps(options)`
717
+ - `getDefaultStaticDir()`
1338
718
 
1339
- ```ts
1340
- export interface TerminalWsDeps {
1341
- projectService: ProjectService;
1342
- sessionService: SessionService;
1343
- runtime: TerminalRuntime;
1344
- }
719
+ Registers all routes and WebSockets.
1345
720
 
1346
- export function registerTerminalWebSocket(server: FastifyInstance, deps: TerminalWsDeps): void;
721
+ ### Route files
1347
722
 
1348
- export function parseClientTerminalMessage(raw: string): ClientTerminalMessage;
1349
- export function serializeServerTerminalMessage(message: ServerTerminalMessage): string;
1350
- ```
723
+ - `src/backend/api/project-routes.ts`: health, recent paths, connect/current project
724
+ - `src/backend/api/harness-routes.ts`: harness status/apply
725
+ - `src/backend/api/task-routes.ts`: tasks and task status
726
+ - `src/backend/api/session-routes.ts`: session lifecycle and dispatch compatibility endpoint
727
+ - `src/backend/api/artifact-routes.ts`: artifact, role command, and log reads/writes
728
+ - `src/backend/api/message-routes.ts`: messages and orchestration
729
+ - `src/backend/api/translation-routes.ts`: settings, prompt previews, provider test, input/send, clear/retry
1351
730
 
1352
- ## 12. Frontend 层
731
+ ### WebSocket files
1353
732
 
1354
- ### 12.1 `src/frontend/main.tsx`
733
+ - `src/backend/ws/terminal-ws.ts`
734
+ - `src/backend/ws/translation-ws.ts`
1355
735
 
1356
- 职责:
736
+ Terminal WebSocket forwards PTY output/input/resize.
1357
737
 
1358
- - 挂载 React app。
738
+ Translation WebSocket subscribes to translation entries/status for a runtime session id.
1359
739
 
1360
- 导出定义:
740
+ ## 10. Backend Templates
1361
741
 
1362
- ```ts
1363
- export function bootstrap(): void;
1364
- ```
742
+ ### `src/backend/templates/handoff.ts`
1365
743
 
1366
- ### 12.2 `src/frontend/app.tsx`
744
+ Exports:
1367
745
 
1368
- 职责:
746
+ - `renderArchitecturePlanTemplate(taskSlug)`
747
+ - `renderImplementationLogTemplate(taskSlug)`
748
+ - `renderValidationLogTemplate(taskSlug)`
749
+ - `renderReviewReportTemplate(taskSlug)`
750
+ - `renderDocsSyncReportTemplate(taskSlug)`
1369
751
 
1370
- - 应用顶层路由和布局。
752
+ ### `src/backend/templates/role-command.ts`
1371
753
 
1372
- 导出定义:
754
+ Exports:
1373
755
 
1374
- ```tsx
1375
- export function App(): JSX.Element;
1376
- ```
756
+ - `renderRoleCommandTemplate(taskSlug, role)`
1377
757
 
1378
- ### 12.3 `src/frontend/state/api-client.ts`
1379
-
1380
- 职责:
1381
-
1382
- - 封装 REST API。
1383
-
1384
- 导出定义:
1385
-
1386
- ```ts
1387
- export interface ApiClient {
1388
- connectProject(input: ConnectProjectRequest): Promise<ProjectSummary>;
1389
- getCurrentProject(): Promise<ProjectSummary | null>;
1390
- listTasks(): Promise<TaskRecord[]>;
1391
- createTask(input: CreateTaskRequest): Promise<TaskRecord>;
1392
- getTask(taskSlug: string): Promise<TaskRecord>;
1393
- getTaskStatus(taskSlug: string): Promise<TaskStatusReport>;
1394
- listSessions(taskSlug: string): Promise<RoleSessionRecord[]>;
1395
- startRoleSession(taskSlug: string, role: RoleName, input?: StartRoleSessionRequest): Promise<RoleSessionRecord>;
1396
- stopRoleSession(taskSlug: string, role: RoleName): Promise<RoleSessionRecord>;
1397
- restartRoleSession(taskSlug: string, role: RoleName, input?: StartRoleSessionRequest): Promise<RoleSessionRecord>;
1398
- dispatchRoleCommand(taskSlug: string, role: DispatchableRole): Promise<DispatchRoleCommandResult>;
1399
- listArtifacts(taskSlug: string): Promise<ArtifactSummary>;
1400
- readRoleCommand(taskSlug: string, role: DispatchableRole): Promise<string>;
1401
- saveRoleCommand(taskSlug: string, role: DispatchableRole, content: string): Promise<void>;
1402
- readLog(taskSlug: string, role: RoleName): Promise<string>;
1403
- }
1404
-
1405
- export function createApiClient(baseUrl?: string): ApiClient;
1406
- ```
758
+ ### `src/backend/templates/message-envelope.ts`
1407
759
 
1408
- ### 12.4 `src/frontend/terminal/terminal-client.ts`
760
+ Exports:
1409
761
 
1410
- 职责:
762
+ - `renderMessageEnvelope(message)`
763
+ - `renderManualStagePrompt(message)`
1411
764
 
1412
- - 封装 terminal WebSocket。
765
+ Manual stage prompt does not submit Enter.
1413
766
 
1414
- 导出定义:
767
+ Auto delivery envelope is submitted with Enter.
1415
768
 
1416
- ```ts
1417
- export interface TerminalClient {
1418
- connect(): void;
1419
- disconnect(): void;
1420
- sendInput(data: string): void;
1421
- resize(cols: number, rows: number): void;
1422
- onMessage(listener: (message: ServerTerminalMessage) => void): Unsubscribe;
1423
- }
769
+ ### Harness templates
1424
770
 
1425
- export function createTerminalClient(input: CreateTerminalClientInput): TerminalClient;
771
+ - `src/backend/templates/harness/claude-root.ts`
772
+ - `src/backend/templates/harness/project-manager-agent.ts`
773
+ - `src/backend/templates/harness/architect-agent.ts`
774
+ - `src/backend/templates/harness/coder-agent.ts`
775
+ - `src/backend/templates/harness/reviewer-agent.ts`
1426
776
 
1427
- export interface CreateTerminalClientInput {
1428
- taskSlug: string;
1429
- role: RoleName;
1430
- baseUrl?: string;
1431
- }
1432
- ```
777
+ Each exports one render function for VCM managed rules.
1433
778
 
1434
- ### 12.5 `src/frontend/terminal/xterm-view.tsx`
779
+ ## 11. Frontend State And API Client
1435
780
 
1436
- 职责:
781
+ ### `src/frontend/state/api-client.ts`
1437
782
 
1438
- - 渲染 xterm.js。
1439
- - 连接 TerminalClient。
1440
- - 处理 fit、resize、input、output。
783
+ Central browser API wrapper.
1441
784
 
1442
- 导出定义:
785
+ It calls:
1443
786
 
1444
- ```tsx
1445
- export interface XtermViewProps {
1446
- taskSlug: string;
1447
- role: RoleName;
1448
- active: boolean;
1449
- }
787
+ - project endpoints
788
+ - harness endpoints
789
+ - task endpoints
790
+ - session endpoints
791
+ - artifact endpoints
792
+ - message endpoints
793
+ - orchestration endpoints
794
+ - translation endpoints
1450
795
 
1451
- export function XtermView(props: XtermViewProps): JSX.Element;
1452
- ```
796
+ ### `src/frontend/state/app-store.ts`
1453
797
 
1454
- ### 12.6 `src/frontend/components/session-console.tsx`
798
+ Exports:
1455
799
 
1456
- 职责:
800
+ - `AppStateSnapshot`
801
+ - `selectActiveTask(tasks, activeTaskSlug)`
1457
802
 
1458
- - 展示单个 role session
1459
- - 在 Start / Restart 上方提供三档权限模式选择。
1460
- - 未启动时显示 Start。
1461
- - 已启动时显示 terminal。
803
+ ### `src/frontend/state/session-store.ts`
1462
804
 
1463
- 导出定义:
805
+ Exports:
1464
806
 
1465
- ```tsx
1466
- export interface SessionConsoleProps {
1467
- taskSlug: string;
1468
- role: RoleName;
1469
- session?: RoleSessionRecord;
1470
- active: boolean;
1471
- permissionMode: ClaudePermissionMode;
1472
- onPermissionModeChange(mode: ClaudePermissionMode): void;
1473
- onStart(role: RoleName): Promise<void>;
1474
- onResume(role: RoleName): Promise<void>;
1475
- onStop(role: RoleName): Promise<void>;
1476
- onRestart(role: RoleName): Promise<void>;
1477
- }
807
+ - `getSessionForRole(sessions, role)`
1478
808
 
1479
- export function SessionConsole(props: SessionConsoleProps): JSX.Element;
1480
- ```
809
+ ## 12. Frontend Routes
1481
810
 
1482
- ### 12.7 `src/frontend/components/role-session-tabs.tsx`
811
+ ### `src/frontend/app.tsx`
1483
812
 
1484
- 职责:
813
+ Exports:
1485
814
 
1486
- - 渲染 PM / Architect / Coder / Reviewer tabs。
1487
- - 展示 status badge。
815
+ - `App()`
1488
816
 
1489
- 导出定义:
817
+ Responsibilities:
1490
818
 
1491
- ```tsx
1492
- export interface RoleSessionTabsProps {
1493
- activeRole: RoleName;
1494
- sessions: RoleSessionRecord[];
1495
- onRoleChange(role: RoleName): void;
1496
- }
819
+ - own top-level app state
820
+ - load current project and recent paths on startup
821
+ - load tasks and harness status after connect
822
+ - pass sidebar props to `ProjectDashboard`
823
+ - pass task props to `TaskWorkspace`
824
+ - keep active workflow/messages/orchestration/events synchronized by task
1497
825
 
1498
- export function RoleSessionTabs(props: RoleSessionTabsProps): JSX.Element;
1499
- ```
826
+ ### `src/frontend/routes/project-dashboard.tsx`
1500
827
 
1501
- ### 12.8 `src/frontend/components/event-log.tsx`
828
+ Exports:
1502
829
 
1503
- 职责:
830
+ - `ProjectDashboardProps`
831
+ - `ProjectDashboard(props)`
1504
832
 
1505
- - 展示产品级事件摘要。
833
+ Responsibilities:
1506
834
 
1507
- 导出定义:
835
+ - collapsible sidebar
836
+ - repository connect form
837
+ - repository summary
838
+ - workflow panel
839
+ - settings section
840
+ - messages modal
841
+ - events modal
842
+ - harness panel
843
+ - one-field task creation
844
+ - task navigation
1508
845
 
1509
- ```tsx
1510
- export interface EventLogProps {
1511
- events: TerminalEvent[];
1512
- }
846
+ ### `src/frontend/routes/task-workspace.tsx`
1513
847
 
1514
- export function EventLog(props: EventLogProps): JSX.Element;
1515
- ```
848
+ Exports:
1516
849
 
1517
- ### 12.9 `src/frontend/routes/project-dashboard.tsx`
850
+ - `TaskWorkspaceProps`
851
+ - `TaskWorkspace(props)`
1518
852
 
1519
- 职责:
853
+ Responsibilities:
1520
854
 
1521
- - 展示 repo 连接表单、任务列表和 harness health。
855
+ - task header with role tabs and refresh
856
+ - status/message/orchestration refresh
857
+ - periodic polling
858
+ - session lifecycle actions
859
+ - per-role permission state
860
+ - runtime event collection for sidebar Events modal
1522
861
 
1523
- 导出定义:
862
+ ## 13. Frontend Components
1524
863
 
1525
- ```tsx
1526
- export function ProjectDashboard(): JSX.Element;
1527
- ```
864
+ ### `src/frontend/components/app-shell.tsx`
1528
865
 
1529
- ### 12.10 `src/frontend/routes/task-workspace.tsx`
866
+ Exports:
1530
867
 
1531
- 职责:
868
+ - `AppShellProps`
869
+ - `AppShell({ sidebar, children })`
1532
870
 
1533
- - 任务运行时主界面。
1534
- - 组合 TaskNav、RoleSessionTabs、SessionConsole、EventLog。
1535
- - 不渲染独立 ArtifactPanel;handoff files 保留在任务目录中。
871
+ Two-column page shell.
1536
872
 
1537
- 导出定义:
873
+ ### `src/frontend/components/repo-connect-form.tsx`
1538
874
 
1539
- ```tsx
1540
- export interface TaskWorkspaceProps {
1541
- taskSlug: string;
1542
- }
875
+ Exports:
1543
876
 
1544
- export function TaskWorkspace(props: TaskWorkspaceProps): JSX.Element;
1545
- ```
877
+ - `RepoConnectFormProps`
878
+ - `RepoConnectForm(props)`
1546
879
 
1547
- ## 13. Templates
880
+ Layout:
1548
881
 
1549
- ### 13.1 `src/backend/templates/handoff.ts`
882
+ - path input row
883
+ - recent select plus connect button row
1550
884
 
1551
- 导出定义:
885
+ ### `src/frontend/components/harness-panel.tsx`
1552
886
 
1553
- ```ts
1554
- export function renderArchitecturePlanTemplate(taskSlug: string): string;
1555
- export function renderImplementationLogTemplate(taskSlug: string): string;
1556
- export function renderValidationLogTemplate(taskSlug: string): string;
1557
- export function renderReviewReportTemplate(taskSlug: string): string;
1558
- ```
887
+ Exports:
1559
888
 
1560
- ### 13.2 `src/backend/templates/role-command.ts`
889
+ - `HarnessPanelProps`
890
+ - `HarnessPanel(props)`
1561
891
 
1562
- 导出定义:
892
+ Shows harness status and install/update action.
1563
893
 
1564
- ```ts
1565
- export function renderRoleCommandTemplate(taskSlug: string, role: DispatchableRole): string;
1566
- export function renderDispatchInstruction(commandPath: string): string;
1567
- ```
894
+ ### `src/frontend/components/workflow-panel.tsx`
1568
895
 
1569
- `renderDispatchInstruction` 必须返回单行短指令:
896
+ Exports:
1570
897
 
1571
- ```text
1572
- Please read and execute the role command at: <commandPath>
1573
- ```
898
+ - `WorkflowPanelProps`
899
+ - `WorkflowPanel({ workflow })`
1574
900
 
1575
- ## 14. 核心调用链
901
+ Renders the sidebar workflow steps.
1576
902
 
1577
- ### 14.1 启动应用
903
+ ### `src/frontend/components/message-timeline.tsx`
1578
904
 
1579
- ```text
1580
- main
1581
- -> startServer
1582
- -> create services/adapters/runtime
1583
- -> register REST routes
1584
- -> register terminal WebSocket
1585
- -> serve frontend
1586
- ```
905
+ Exports:
1587
906
 
1588
- ### 14.2 连接 repo
907
+ - `MessageTimelineProps`
908
+ - `getMessageCounts(messages)`
909
+ - `MessageTimeline(props)`
1589
910
 
1590
- ```text
1591
- ProjectDashboard
1592
- -> api.connectProject
1593
- -> POST /api/projects/connect
1594
- -> projectService.connectProject
1595
- -> git.getRepoRoot
1596
- -> git.getCurrentBranch
1597
- -> git.isDirty
1598
- -> claude.isAvailable
1599
- -> fs.writeJsonAtomic(.vcm/config.json)
1600
- ```
911
+ Used inside the Messages modal. Can show stage/reject/open-role actions.
1601
912
 
1602
- ### 14.3 创建任务
913
+ ### `src/frontend/components/event-log.tsx`
1603
914
 
1604
- ```text
1605
- ProjectDashboard / TaskWorkspace
1606
- -> api.createTask
1607
- -> POST /api/tasks
1608
- -> taskService.createTask
1609
- -> assertValidTaskSlug
1610
- -> artifactService.ensureHandoffStructure
1611
- -> artifactService.createArtifactTemplates
1612
- -> fs.writeJsonAtomic(.vcm/tasks/<task-slug>.json)
1613
- ```
915
+ Exports:
1614
916
 
1615
- ### 14.4 启动 role session
917
+ - `EventLogProps`
918
+ - `EventLog(props)`
1616
919
 
1617
- ```text
1618
- SessionConsole Start
1619
- -> api.startRoleSession
1620
- -> POST /api/tasks/:taskSlug/sessions/:role/start
1621
- -> sessionService.startRoleSession
1622
- -> claude.buildRoleStartCommand
1623
- -> runtime.createSession
1624
- -> node-pty spawn
1625
- -> registry.upsert
1626
- -> write session metadata
1627
- ```
920
+ Used inside the Events modal.
1628
921
 
1629
- ### 14.5 Terminal 输入输出
922
+ ### `src/frontend/components/task-nav.tsx`
1630
923
 
1631
- ```text
1632
- XtermView
1633
- -> TerminalClient WebSocket
1634
- -> input message
1635
- -> terminal-ws
1636
- -> runtime.write
1637
- -> node-pty
1638
- -> output event
1639
- -> append role log
1640
- -> WebSocket output message
1641
- -> xterm.write
1642
- ```
924
+ Exports:
1643
925
 
1644
- ### 14.6 下发 role command
926
+ - `TaskNavProps`
927
+ - `TaskNav(props)`
1645
928
 
1646
- ```text
1647
- Role toolbar Send Command
1648
- -> api.dispatchRoleCommand
1649
- -> POST /api/tasks/:taskSlug/sessions/:role/dispatch
1650
- -> commandDispatcher.dispatchRoleCommand
1651
- -> artifactService.readRoleCommand
1652
- -> sessionService.getRoleSession
1653
- -> runtime.write(short instruction)
1654
- -> registry event
1655
- ```
929
+ Task list in sidebar.
1656
930
 
1657
- ### 14.7 Handoff files
931
+ ### `src/frontend/components/role-session-tabs.tsx`
1658
932
 
1659
- V1 主界面不展示 artifact 状态。handoff files 和 role commands 仍由 backend templates / services 管理,供 Claude Code sessions 和 dispatch 流程使用。
933
+ Exports:
1660
934
 
1661
- ## 15. 测试计划
935
+ - `RoleSessionTabsProps`
936
+ - `RoleSessionTabs(props)`
1662
937
 
1663
- ### 15.1 Unit Tests
938
+ Header role tabs with status badges.
1664
939
 
1665
- `tests/unit/shared/slug-check.test.ts`
940
+ ### `src/frontend/components/session-console.tsx`
1666
941
 
1667
- - accepts valid task slugs。
1668
- - rejects uppercase、underscore、space、path traversal。
1669
- - suggests normalized slugs。
942
+ Exports:
1670
943
 
1671
- `tests/unit/shared/artifact-check.test.ts`
944
+ - `SessionConsoleProps`
945
+ - `SessionConsole(props)`
1672
946
 
1673
- - parses headings。
1674
- - detects missing headings。
1675
- - validates handoff templates。
1676
- - validates `validation-log` not-run reason。
947
+ Role console and translation split.
1677
948
 
1678
- `tests/unit/backend/artifact-service.test.ts`
949
+ ### `src/frontend/components/session-toolbar.tsx`
1679
950
 
1680
- - creates handoff directory。
1681
- - creates role command files。
1682
- - does not overwrite existing files by default。
1683
- - returns artifact summary statuses。
951
+ Exports:
1684
952
 
1685
- `tests/unit/backend/command-dispatcher.test.ts`
953
+ - `SessionToolbarProps`
954
+ - `SessionToolbar(props)`
1686
955
 
1687
- - rejects missing command。
1688
- - rejects empty command。
1689
- - rejects not-started target session。
1690
- - writes only short instruction to runtime。
956
+ Renders permission select and session lifecycle buttons.
1691
957
 
1692
- `tests/unit/backend/session-registry.test.ts`
958
+ There is no visible primary `Send Command` button in the current toolbar. Role-command dispatch remains backend compatibility.
1693
959
 
1694
- - upserts sessions。
1695
- - finds by task + role。
1696
- - updates status。
1697
- - removes sessions。
960
+ ### `src/frontend/components/translation-panel.tsx`
1698
961
 
1699
- `tests/unit/frontend/api-client.test.ts`
962
+ Exports:
1700
963
 
1701
- - unwraps successful API responses。
1702
- - throws useful errors for API failures。
964
+ - `TranslationPanelProps`
965
+ - `TranslationPanel(props)`
1703
966
 
1704
- `tests/unit/frontend/terminal-client.test.ts`
967
+ Renders output translations, settings actions, auto-send toggle, and composer.
1705
968
 
1706
- - serializes input and resize messages。
1707
- - dispatches output/status/exit messages to listeners。
969
+ Important current behavior:
1708
970
 
1709
- ### 15.2 Integration Tests
971
+ - panel-level status only
972
+ - no per-entry status label
973
+ - no `Original` buttons
974
+ - tool output is preserved, dim, one-line
975
+ - prose source is replaced by translated text after completion
976
+ - no separate translated-English textarea
1710
977
 
1711
- `tests/integration/api/project-routes.test.ts`
978
+ ### `src/frontend/components/translation-settings-modal.tsx`
1712
979
 
1713
- - connects repo fixture。
1714
- - writes `.vcm/config.json`。
1715
- - returns branch and dirty warning。
980
+ Exports:
1716
981
 
1717
- `tests/integration/api/task-routes.test.ts`
982
+ - `TranslationSettingsModalProps`
983
+ - `TranslationSettingsModal(props)`
1718
984
 
1719
- - creates task。
1720
- - writes `.vcm/tasks/<task-slug>.json`。
1721
- - creates handoff artifacts。
985
+ Settings:
1722
986
 
1723
- `tests/integration/runtime/node-pty-runtime.test.ts`
987
+ - enable translation
988
+ - base URL
989
+ - API key as text input
990
+ - model
991
+ - target language
992
+ - input mode
993
+ - context
994
+ - translate output
995
+ - translate user input
996
+ - timeout
997
+ - temperature
998
+ - prompt slot overrides
999
+ - provider test
1724
1000
 
1725
- - starts a simple shell command fixture。
1726
- - streams output。
1727
- - writes log file。
1728
- - handles exit。
1001
+ ### `src/frontend/components/status-badge.tsx`
1729
1002
 
1730
- `tests/integration/api/session-routes.test.ts`
1003
+ Exports:
1731
1004
 
1732
- - starts role session with fake runtime。
1733
- - stops role session。
1734
- - restarts role session。
1735
- - dispatches role command.
1005
+ - `StatusBadgeProps`
1006
+ - `StatusBadge(props)`
1736
1007
 
1737
- ### 15.3 E2E Tests
1008
+ ### `src/frontend/terminal/xterm-view.tsx`
1738
1009
 
1739
- `tests/e2e/task-workspace.spec.ts`
1010
+ Renders `xterm.js`, connects to terminal WebSocket, sends input and resize, and preserves terminal colors.
1740
1011
 
1741
- - open GUI。
1742
- - connect temp repo。
1743
- - create task。
1744
- - see Task Workspace。
1745
- - start fake project-manager session。
1746
- - see terminal output。
1747
- - switch to architect tab。
1748
- - see Start button。
1749
- - verify the main workspace has no right-side artifact panel。
1012
+ ### `src/frontend/terminal/terminal-client.ts`
1750
1013
 
1751
- V1 e2e 可以使用 fake Claude command,避免真实消耗 Claude Code tokens。
1014
+ Terminal WebSocket client wrapper.
1752
1015
 
1753
- ### 15.4 Manual Smoke Test
1016
+ ## 14. UI State Details
1754
1017
 
1755
- 在真实 repo 中执行:
1018
+ Sidebar:
1756
1019
 
1757
- ```text
1758
- npm install
1759
- npm run dev
1760
- open http://localhost:5173
1761
- Select repo
1762
- Create demo-task
1763
- Start project-manager
1764
- Start architect
1765
- Type in PM terminal
1766
- Send architect command
1767
- Verify logs/architect.log
1768
- Verify artifact status
1769
- Restart coder
1770
- Refresh browser
1771
- Verify session state recovers
1772
- ```
1020
+ - all groups default collapsed
1021
+ - `Repository Path` default open only when no task is selected
1022
+ - `Settings` includes `Messages`, `Events`, and `Auto orchestration`
1773
1023
 
1774
- ## 16. 实施里程碑
1024
+ Task workspace:
1775
1025
 
1776
- ### Milestone 1: Project Reshape and Local GUI Shell
1026
+ - role tabs in the first header row
1027
+ - workflow is not in main workspace
1028
+ - messages/events are not in main workspace
1029
+ - active role console fills available space
1777
1030
 
1778
- 文件:
1031
+ Translation:
1779
1032
 
1780
- - `package.json`
1781
- - `tsconfig.json`
1782
- - `tsconfig.node.json`
1783
- - `vite.config.ts`
1784
- - `src/main.ts`
1785
- - `src/backend/server.ts`
1786
- - `src/frontend/main.tsx`
1787
- - `src/frontend/app.tsx`
1788
- - `src/frontend/routes/project-dashboard.tsx`
1033
+ - top role toolbar button label is `✅ Translate` when on and `× Translate` when off
1034
+ - translation panel `Auto-send` label is `✅ Auto-send` when on and `× Auto-send` when off
1035
+ - panel uses terminal-like dark styling
1036
+ - composer height is compact
1037
+ - `Enter` translates/sends, `Shift+Enter` inserts newline
1789
1038
 
1790
- 验收:
1039
+ ## 15. Data Persistence Summary
1791
1040
 
1792
- - `npm run dev` 启动 backend + frontend。
1793
- - 浏览器打开 Project Dashboard。
1794
- - `/api/health` 返回 ok。
1041
+ App settings:
1795
1042
 
1796
- ### Milestone 2: Shared Types, Validation, and Artifacts
1043
+ ```text
1044
+ ~/.vcm/settings.json
1045
+ ```
1797
1046
 
1798
- 文件:
1047
+ Project config:
1799
1048
 
1800
- - `src/shared/types/*.ts`
1801
- - `src/shared/validation/*.ts`
1802
- - `src/backend/templates/*.ts`
1803
- - `src/backend/services/artifact-service.ts`
1804
- - `src/backend/services/task-service.ts`
1805
- - `src/backend/api/task-routes.ts`
1049
+ ```text
1050
+ .vcm/config.json
1051
+ ```
1806
1052
 
1807
- 验收:
1053
+ Task state:
1808
1054
 
1809
- - GUI 可以创建 task。
1810
- - `.ai/handoffs/<task-slug>/` 被创建。
1811
- - Handoff artifacts 在任务目录中被创建。
1055
+ ```text
1056
+ .vcm/tasks/<task>.json
1057
+ ```
1812
1058
 
1813
- ### Milestone 3: Repo Connect and Project Service
1059
+ Session state:
1814
1060
 
1815
- 文件:
1061
+ ```text
1062
+ .vcm/sessions/<task>.json
1063
+ ```
1816
1064
 
1817
- - `src/backend/adapters/*.ts`
1818
- - `src/backend/services/project-service.ts`
1819
- - `src/backend/validation/environment-check.ts`
1820
- - `src/backend/api/project-routes.ts`
1821
- - `src/frontend/components/repo-connect-form.tsx`
1065
+ Messages:
1822
1066
 
1823
- 验收:
1067
+ ```text
1068
+ .vcm/messages/<task>.jsonl
1069
+ .ai/handoffs/<task>/messages/<message-id>.md
1070
+ ```
1824
1071
 
1825
- - GUI 可以选择/输入 repo path。
1826
- - backend 检查 Git repo 和 Claude Code。
1827
- - `.vcm/config.json` 被创建。
1828
- - main/master 和 dirty state 显示 warning。
1072
+ Orchestration:
1829
1073
 
1830
- ### Milestone 4: Embedded Terminal Runtime
1074
+ ```text
1075
+ .vcm/orchestration/<task>.json
1076
+ ```
1831
1077
 
1832
- 文件:
1078
+ Handoff artifacts:
1833
1079
 
1834
- - `src/backend/runtime/terminal-runtime.ts`
1835
- - `src/backend/runtime/node-pty-runtime.ts`
1836
- - `src/backend/runtime/session-registry.ts`
1837
- - `src/backend/ws/terminal-ws.ts`
1838
- - `src/frontend/terminal/terminal-client.ts`
1839
- - `src/frontend/terminal/xterm-view.tsx`
1840
- - `src/frontend/components/session-console.tsx`
1841
-
1842
- 验收:
1843
-
1844
- - GUI 可以启动 fake role session。
1845
- - xterm.js 显示 output。
1846
- - 用户输入能写入 backend runtime。
1847
- - output 写入 raw log。
1848
- - resize 工作。
1849
-
1850
- ### Milestone 5: Role Session Cockpit
1851
-
1852
- 文件:
1853
-
1854
- - `src/backend/services/session-service.ts`
1855
- - `src/backend/api/session-routes.ts`
1856
- - `src/frontend/components/role-session-tabs.tsx`
1857
- - `src/frontend/components/session-toolbar.tsx`
1858
- - `src/frontend/components/status-badge.tsx`
1859
- - `src/frontend/routes/task-workspace.tsx`
1860
- - `src/frontend/state/session-store.ts`
1861
-
1862
- 验收:
1863
-
1864
- - PM / Architect / Coder / Reviewer tabs 可切换。
1865
- - 每个 role 可 start / stop / restart。
1866
- - 状态 badge 正确显示。
1867
- - 页面刷新后可重新加载 task/session 状态。
1868
-
1869
- ### Milestone 6: GUI Role Command Dispatch
1870
-
1871
- 文件:
1872
-
1873
- - `src/backend/services/command-dispatcher.ts`
1874
- - `src/frontend/components/event-log.tsx`
1875
-
1876
- 验收:
1877
-
1878
- - 用户点击目标 role toolbar 的 Send Command。
1879
- - backend 写入短指令到 architect runtime。
1880
- - dispatch event 出现在 Event Log。
1881
- - 不发送未落盘长 prompt。
1882
-
1883
- ### Milestone 7: Acceptance and Hardening
1884
-
1885
- 内容:
1886
-
1887
- - unit tests。
1888
- - integration tests。
1889
- - e2e smoke。
1890
- - README 更新。
1891
- - GUI 错误态。
1892
- - empty/missing/incomplete artifact 状态。
1893
- - Claude Code 缺失提示。
1894
- - process crashed 提示。
1895
-
1896
- 验收:
1897
-
1898
- - `npm run typecheck` 通过。
1899
- - `npm test` 通过。
1900
- - `npm run build` 通过。
1901
- - `npm run e2e` 通过或有明确 fake Claude 限制说明。
1902
-
1903
- ## 17. 最终 V1 验收清单
1904
-
1905
- - [ ] GUI 可以启动。
1906
- - [ ] 用户可以连接本地 Git repo。
1907
- - [ ] GUI 显示 repo path、branch、dirty warning。
1908
- - [ ] 用户可以创建 task workspace。
1909
- - [ ] 系统创建 `.vcm/config.json`。
1910
- - [ ] 系统创建 `.vcm/tasks/<task-slug>.json`。
1911
- - [ ] 系统创建 `.ai/handoffs/<task-slug>/role-commands/`。
1912
- - [ ] 系统创建 `.ai/handoffs/<task-slug>/logs/`。
1913
- - [ ] 系统创建 architecture / implementation / validation / review artifact templates。
1914
- - [ ] GUI 显示 PM / Architect / Coder / Reviewer tabs。
1915
- - [ ] 用户可以启动 project-manager session。
1916
- - [ ] 用户可以启动 architect session。
1917
- - [ ] embedded terminal 可以显示 Claude Code output。
1918
- - [ ] 用户可以直接在 embedded terminal 中输入。
1919
- - [ ] terminal output 被保存到 role log。
1920
- - [ ] 用户可以从 GUI 发送 role command 到目标 role session。
1921
- - [ ] backend 只发送短指令,不粘贴完整长 prompt。
1922
- - [ ] 用户可以 stop / restart role session。
1923
- - [ ] 页面刷新后可以恢复 task/session 可见状态。
1924
- - [ ] Claude Code 缺失时 GUI 有清晰提示。
1925
- - [ ] 进程 crashed/exited 时 GUI 有清晰提示。
1926
-
1927
- ## 18. 需要延后到 V2 的接口
1928
-
1929
- V1 文件中可以预留类型或接口,但不实现完整功能:
1930
-
1931
- - `ReviewAdapter`:后续接 Cross-Model Reviewer。
1932
- - `ValidationRunner`:后续自动运行 validation commands。
1933
- - `WorktreeManager`:后续实现 one task -> one branch -> one worktree。
1934
- - `SessionPersistenceService`:后续增强 backend lifecycle、session registry 持久化、raw log replay 和恢复体验。
1935
- - `DesktopShell`:后续用 Electron 或 Tauri 打包。
1936
- - `PermissionHookManager`:后续生成 role-specific Claude Code permission hooks。
1937
-
1938
- V1 的判断标准是:
1080
+ ```text
1081
+ .ai/handoffs/<task>/
1082
+ ```
1083
+
1084
+ Claude transcripts:
1939
1085
 
1940
1086
  ```text
1941
- 少做智能判断
1942
- 多做状态可见
1943
- 少自动修改代码
1944
- 多沉淀 artifacts
1945
- 少解析终端语义
1946
- 多保留 raw logs
1947
- 少暴露终端编排细节
1948
- 多提供 GUI 操作入口
1087
+ ~/.claude/projects/<project-hash>/<claude-session-id>.jsonl
1088
+ ```
1089
+
1090
+ ## 16. Validation Checklist
1091
+
1092
+ Before release or publish:
1093
+
1094
+ ```bash
1095
+ npm run typecheck
1096
+ npm test
1097
+ npm run build
1098
+ npm run verify:package
1949
1099
  ```
1100
+
1101
+ For frontend layout changes, also verify manually:
1102
+
1103
+ - connect repository
1104
+ - open task
1105
+ - role tabs stay in header
1106
+ - sidebar sections collapse/open correctly
1107
+ - embedded terminal remains visible after role switch
1108
+ - translation split is 50/50
1109
+ - Messages modal opens from sidebar Settings
1110
+ - Events modal opens from sidebar Settings
1111
+ - Auto orchestration toggles on/off
1112
+ - `Enter` in translation composer translates/sends
1113
+ - `Shift+Enter` inserts newline
1114
+
1115
+ ## 17. V1 Boundaries To Preserve
1116
+
1117
+ Do not reintroduce these into V1 docs or UI unless the product direction changes:
1118
+
1119
+ - tmux persistence backend
1120
+ - CLI-first task management as the main product mode
1121
+ - main workspace artifact panel
1122
+ - Pause/Resume orchestration buttons in GUI
1123
+ - raw PTY output translation
1124
+ - translation classifier that drops assistant prose
1125
+ - separate translated-English textarea
1126
+ - optional title input in New Task
1127
+ - `Dirty: yes/no` sidebar label
1128
+ - role command dispatch as the primary orchestration path