vibe-coding-master 0.4.42 → 0.5.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.
@@ -1,891 +0,0 @@
1
- # VibeCodingMaster Product Design
2
-
3
- Last updated: 2026-06-21
4
-
5
- This document describes the current product direction and implemented V1 behavior for VCM.
6
-
7
- ## 1. Product Positioning
8
-
9
- VibeCodingMaster is a local GUI task workspace for Claude Code.
10
-
11
- It helps a user run one engineering task through several explicit Claude Code role sessions:
12
-
13
- - `project-manager`
14
- - `architect`
15
- - `coder`
16
- - `reviewer`
17
-
18
- The user should mostly talk to `project-manager`. The project manager coordinates the other roles through VCM messaging and durable handoff files. The user can still switch into any role session to inspect, guide, or interrupt.
19
-
20
- VCM is not a hosted SaaS product. It runs locally, connects to a local repository path, starts local Claude Code processes, and writes local task metadata into that repository.
21
-
22
- ### 1.1 VCM Statistics Terminology
23
-
24
- VCM statistics use a task-level hierarchy:
25
-
26
- ```text
27
- Session = n x Round = m x Turn
28
- ```
29
-
30
- - `Session`: one VCM task. It is the statistics container for the whole task, from task creation until Close Task.
31
- - `Round`: one VCM conversation cycle. It starts with an accepted user prompt or VCM-delivered prompt, continues through sequential role orchestration, and ends when the final role turn stops and no next turn starts inside the 10 second stop window. In the normal orchestrated workflow, the final visible result comes back from `project-manager`.
32
- - `Turn`: one role-level Claude Code conversation. It starts when a prompt is submitted to one role session and ends when that role's Claude Code process emits `Stop` or `StopFailure`.
33
-
34
- Turns inside one Round are strictly sequential. VCM should finish one role Turn before starting the next role Turn in that Round.
35
-
36
- Session state is intentionally small: `created` means no Round has started yet, `running` means there is a current running Round, and `stopped` means there is no current running Round after at least one Round has stopped. Starting Claude Code role sessions does not make the VCM Session `running`.
37
-
38
- Round state is only `running` or `stopped`. After a turn-end hook, the 10 second stop window still counts as `running`; the Round becomes `stopped` only when the timer expires without another `UserPromptSubmit`.
39
-
40
- This `Session` term is only for VCM statistics. It must not be confused with a Claude Code role session, terminal runtime session, or Claude transcript session id. VCM still runs one Claude Code role session per role inside one task-level VCM Session.
41
-
42
- ## 2. Product Goals
43
-
44
- VCM V1 must make multi-session Claude Code work visible and recoverable:
45
-
46
- - Connect a local Git repository.
47
- - Create a named task with its own branch and task-level worktree.
48
- - Start, stop, restart, and resume one Claude Code session per role.
49
- - Keep role terminals embedded in one GUI.
50
- - Preserve task state, session state, handoff files, and message history.
51
- - Let roles communicate through a PM-mediated message bus.
52
- - Let users choose between manual message approval and auto orchestration.
53
- - Install or update VCM role rules into `CLAUDE.md` and `.claude/agents/*.md`.
54
- - Provide a low-cost translation layer so the user can write Chinese while Claude Code receives English engineering instructions.
55
- - Clean up completed task worktrees and VCM task metadata when the task is done.
56
-
57
- ## 3. Non-Goals
58
-
59
- V1 does not include:
60
-
61
- - tmux.
62
- - Worktree isolation per role.
63
- - Switching a task to a different branch or worktree after task creation.
64
- - A separate `Create task worktree` action after the task already exists.
65
- - Concurrent edits across roles as a product workflow.
66
- - Automatic confirmation of Claude Code permission prompts.
67
- - A main-page artifact inspector.
68
- - Raw PTY parsing to infer Claude answer boundaries.
69
- - Automatic writing of translations into repo artifacts.
70
- - Hosted auth, cloud sync, multi-user collaboration, or project indexing.
71
-
72
- ## 4. Core Workflow
73
-
74
- Recommended flow:
75
-
76
- ```text
77
- project-manager
78
- -> architect architecture plan, Scaffold Manifest, and code scaffolding
79
- -> coder implementation and baseline unit checks
80
- -> reviewer independent validation
81
- -> architect docs sync / architecture drift check
82
- -> project-manager final acceptance, commit, and PR
83
- ```
84
-
85
- ### 4.1 Gate Review Gates
86
-
87
- For complex tasks, VCM supports optional Gate Review Gates through a
88
- `gate-reviewer` Claude Code role. Gate Reviewer is a VCM flow role with the same
89
- hook, Round, terminal, and translation behavior as the core roles. Its session
90
- is task-scoped: each task gets its own Gate Reviewer session in the active task
91
- worktree.
92
-
93
- ```text
94
- architect architecture plan
95
- -> Gate Reviewer checks plan quality before coder starts
96
-
97
- reviewer review-report
98
- -> Gate Reviewer checks validation adequacy before final acceptance
99
-
100
- final task diff
101
- -> Gate Reviewer checks code and PR readiness before PR preparation
102
- ```
103
-
104
- Each gate returns `approve` or `request_changes`. PM triggers gates through the
105
- `vcm-gate-review` skill at the three workflow points; VCM owns the sidebar
106
- toggles, gate state, Gate Reviewer session, report polling, and PM callback.
107
- Reports are task-scoped under `.ai/vcm/gate-reviews/`. All three gate toggles
108
- default to off.
109
-
110
- When any gate is on, or when a Gate Reviewer session already exists, the task
111
- workspace shows `Gate Reviewer` as a fifth terminal role. VCM sends a short gate
112
- prompt into that task session and uses the normal role hook path for Round
113
- state, translation, and report polling. The role remains outside PM route-file
114
- dispatch.
115
- Architecture-plan findings return to architect, validation-adequacy findings
116
- return to reviewer, and final-diff findings go to architect first for
117
- assessment. Gate Reviewer role rules live in `.claude/agents/gate-reviewer.md`.
118
-
119
- The detailed design lives in `docs/gate-review-gates.md`.
120
-
121
- ### 4.2 Task Worktree Model
122
-
123
- Task-level worktree management is the required model for all tasks:
124
-
125
- ```text
126
- one task
127
- -> one branch
128
- -> one git worktree
129
- -> one handoff directory
130
- -> one set of role sessions
131
- ```
132
-
133
- VCM must not create worktrees per role. `project-manager`, `architect`, `coder`, and `reviewer` for the same task all run in the same task worktree and hand off sequentially.
134
-
135
- When the user creates a task, VCM always creates the branch and worktree immediately. Tasks never run directly in the connected base repository, and there is no separate later button named `Create task worktree`.
136
-
137
- Branch naming:
138
-
139
- ```text
140
- feature/<task-name>
141
- ```
142
-
143
- Worktree path:
144
-
145
- ```text
146
- <base-repo>/.claude/worktrees/<task-name>
147
- ```
148
-
149
- Example:
150
-
151
- ```text
152
- base repo: /workspace
153
- task: docs-cleanup
154
- branch: feature/docs-cleanup
155
- worktree: /workspace/.claude/worktrees/docs-cleanup
156
- ```
157
-
158
- The repo's `.gitignore` must ignore `.ai/vcm/` and `.claude/worktrees/`. This is mandatory because the task worktrees live under `.claude/worktrees/`, and the base repository must not see nested worktree files as untracked source files.
159
-
160
- Task creation flow:
161
-
162
- ```text
163
- New Task submit
164
- -> validate task name
165
- -> verify .ai/vcm/ is ignored
166
- -> verify .claude/worktrees/ is ignored
167
- -> derive branch feature/<task-name>
168
- -> derive worktree path .claude/worktrees/<task-name>
169
- -> verify the base repo is clean
170
- -> git worktree add -b feature/<task-name> .claude/worktrees/<task-name> <base-ref>
171
- -> create task metadata
172
- -> create handoff structure inside the task worktree
173
- -> open the task workspace with role session cwd = task worktree
174
- ```
175
-
176
- Task close flow:
177
-
178
- ```text
179
- user clicks red Close Task
180
- -> show destructive confirmation
181
- -> stop VCM-managed running role sessions for the task
182
- -> explain that VCM deletes the task worktree and task branch
183
- -> explain that VCM does not check running sessions or uncommitted changes
184
- -> remove git worktree
185
- -> delete the task branch
186
- -> remove VCM task metadata from the base repo
187
- -> remove task runtime metadata from the task worktree
188
- ```
189
-
190
- ## 5. Roles
191
-
192
- ### Project Manager
193
-
194
- The project manager owns:
195
-
196
- - user communication
197
- - task clarification
198
- - role routing
199
- - Debug Mode routing for bugs, failing checks, build/runtime errors, unclear defects, and reviewer failure evidence
200
- - message dispatch
201
- - handoff verification
202
- - final acceptance
203
- - commit and PR preparation after gates pass
204
-
205
- The project manager must not become the architect, coder, reviewer, or debugger for non-trivial work. PM routes debug evidence to architect and resumes normal gates after architect reports the debug disposition.
206
-
207
- ### Architect
208
-
209
- The architect owns:
210
-
211
- - architecture plan
212
- - Scaffold Manifest with stable row IDs for task-specific file context and coder guidance
213
- - module boundaries
214
- - file responsibilities
215
- - cross-file callable surfaces and contract comments
216
- - code scaffolding with `VCM:CODE <ID>` placeholders
217
- - public contracts
218
- - verifiable behavior and behavior/contract proof points
219
- - Replan triggers
220
- - Debug Mode for routed bug/build/test/runtime investigations
221
- - post-review docs sync and architecture drift checks
222
-
223
- Outputs:
224
-
225
- - `.ai/vcm/handoffs/architecture-plan.md`
226
- - `.ai/vcm/handoffs/docs-sync-report.md`
227
-
228
- ### Coder
229
-
230
- The coder owns:
231
-
232
- - implementation within the approved plan
233
- - completion of architect-defined `VCM:CODE` placeholders and Scaffold Completion handoff by ID
234
- - baseline unit/contract/regression tests
235
- - general coding standards and code documentation consistency
236
-
237
- Outputs:
238
-
239
- - `.ai/vcm/handoffs/known-issues.md`
240
-
241
- ### Reviewer
242
-
243
- The reviewer owns:
244
-
245
- - independent review
246
- - test adequacy
247
- - final validation confidence
248
- - integration and E2E case definitions in `docs/TESTING.md`
249
- - validation strategy, selection rules, and final-validation cleanup
250
- - docs gap detection
251
- - risk findings
252
-
253
- Output:
254
-
255
- - `.ai/vcm/handoffs/review-report.md`
256
- - `.ai/vcm/handoffs/known-issues.md`
257
-
258
- ## 6. Information Architecture
259
-
260
- The app has two primary areas:
261
-
262
- ```text
263
- ┌───────────────────────────────┬─────────────────────────────────────────────┐
264
- │ Sidebar │ Task Workspace │
265
- │ collapsible sections │ header + active role console │
266
- └───────────────────────────────┴─────────────────────────────────────────────┘
267
- ```
268
-
269
- ### Sidebar
270
-
271
- All sidebar groups are collapsible and default to collapsed. When no task is selected, `Repository Path` opens by default. The sidebar is a single-open accordion: opening one group closes the previous group, and clicking the open group collapses it.
272
-
273
- Sections:
274
-
275
- - `Repository Path`
276
- - `Connected Repository`
277
- - `Settings`
278
- - `Translation`
279
- - `Gate Review Gates`
280
- - `Gateway`
281
- - `VCM Harness`
282
- - `New Task`
283
- - `Tasks`
284
-
285
- The connected active task also has a bottom status dock. It is not a collapsible sidebar section. It stays at the bottom of the sidebar and shows the active VCM Session title, task status, Session start time, total elapsed time, total Round count, and role active runtime. It also shows the Current Round while a Round is running, or the Last Round after a flow pause, including start time, total elapsed time, role active runtime, Turn count, and Round status.
286
-
287
- `Repository Path` layout:
288
-
289
- ```text
290
- Repository Path
291
- [ /path/to/repo ]
292
- [ Recent v ] [ Connect ]
293
- ```
294
-
295
- `Connected Repository` shows the connected base repository, not the active task
296
- worktree:
297
-
298
- - base repo path
299
- - current branch
300
- - upstream branch when configured
301
- - ahead/behind status relative to upstream
302
- - current commit hash
303
- - base repo working tree state
304
- - last checked time
305
- - a `Pull` button
306
-
307
- Opening this section refreshes the connected repository status through
308
- `GET /api/projects/current`. VCM does not poll this state at high frequency.
309
-
310
- The `Pull` button runs `git pull --ff-only` only against the connected base
311
- repository. It is disabled when the base repository has uncommitted changes,
312
- or when the branch has no upstream. VCM does not stash, merge, or mutate task
313
- worktrees from this button.
314
-
315
- The old `Dirty: yes/no` label is not used. The UI uses `Working tree: clean` or
316
- `Working tree: uncommitted changes`.
317
-
318
- `Settings` contains:
319
-
320
- - `Theme` button, cycling through `System`, `Light`, and `Dark`.
321
- - `Pause alert sound` button, on by default, controlling only the audible pause reminder.
322
- - `Messages` button, opening a modal list of role messages.
323
- - `Events` button, opening a modal list of runtime UI events for the current task.
324
-
325
- The default theme mode is `System`, which follows the OS/browser color-scheme preference. The entire application chrome, sidebar, forms, modals, status badges, and workspace panels must support both light and dark rendering. Embedded terminals keep their terminal-native dark styling.
326
-
327
- When a role flow stops advancing, VCM always shows the fixed in-app pause alert dialog. When `Pause alert sound` is on, VCM also plays a short, soft, two-note local chime. If the flow lasted less than 2 minutes, the chime plays 3 times, 1.4 seconds apart, and stops. If the flow lasted 2 minutes or longer, the chime repeats until the user confirms the dialog. The alert sound must reuse one browser audio context after user activation instead of creating a fresh context for each repeat, because Safari can block repeated timer-driven playback when every repeat looks like a new autoplay attempt.
328
- Safari may still require the user to manually set `Safari > Website Settings > Auto-Play > Allow All Auto-Play`; Chrome is the recommended browser for reliable repeated alert sound.
329
-
330
- There is no separate `Pause orchestration` or `Resume orchestration` control in the GUI. The current product model is one on/off toggle in the role console toolbar.
331
-
332
- `Translation` contains:
333
-
334
- - `Conversation translation`
335
- - `Auto-send`
336
- - `Language`
337
- - `Reply scope`
338
- - `File translation`
339
- - `Bootstrap`
340
- - `Update memory`
341
- - `Session status`
342
- - `Open Session`
343
-
344
- `Gate Review Gates` contains three independent switches:
345
-
346
- - `Architecture plan`
347
- - `Validation adequacy`
348
- - `Final diff`
349
-
350
- `VCM Harness` shows whether VCM managed blocks are installed/up to date in the project rules files and `.gitignore`.
351
-
352
- `New Task` contains:
353
-
354
- - `task name`
355
- - generated branch preview: `feature/<task-name>`
356
- - generated worktree preview: `.claude/worktrees/<task-name>`
357
-
358
- There is no optional title input in the current UI.
359
-
360
- ### Task Workspace
361
-
362
- The task workspace header is one compact row:
363
-
364
- ```text
365
- <task> [Project Manager] [Architect] [Coder] [Reviewer] [Gate Reviewer?] [Auto orchestration] [Close Task]
366
- ```
367
-
368
- The header does not show `TASK WORKSPACE`, branch, or worktree path. Task branch/worktree details remain task metadata, but they are not first-row chrome.
369
-
370
- The task workspace does not show a manual `Refresh` button. Task status, role status, messages, orchestration state, and flow pause state refresh automatically. The only remaining `Refresh` control is inside the sidebar `VCM Harness` section, where it rechecks managed project files.
371
-
372
- Role tabs show the session status for each visible role. `Gate Reviewer` appears
373
- only when a Gate Review switch is enabled or a Gate Reviewer session already
374
- exists.
375
-
376
- The main task workspace only renders the active role console. Messages and Events are opened from the sidebar.
377
-
378
- ## 7. Role Console
379
-
380
- The role console owns a single role session.
381
-
382
- Controls:
383
-
384
- - Permission mode select.
385
- - `Start`.
386
- - `Resume`.
387
- - `Restart`.
388
- - `Stop`.
389
-
390
- Permission modes:
391
-
392
- - `bypassPermissions`
393
- - `plan`
394
- - `default`
395
-
396
- The permission mode applies on the next start/resume/restart. If a session is already running, changing the select does not mutate that live process.
397
-
398
- When translation is off, the console shows one embedded terminal.
399
-
400
- When translation is on, the console splits horizontally:
401
-
402
- ```text
403
- ┌────────────────────────────┬────────────────────────────┐
404
- │ embedded Claude terminal │ Translation panel │
405
- └────────────────────────────┴────────────────────────────┘
406
- ```
407
-
408
- The split should stay close to 50/50 width. Both panes expand vertically to fill the remaining workspace height.
409
-
410
- ## 8. Flow Pause Detection
411
-
412
- VCM detects flow pauses from role hook events, not from terminal silence, message history, or pending route files. Claude Code VCM flow roles report through `.claude/settings.json`; Gate Reviewer follows the same hook path while VCM separately validates the assigned gate report.
413
-
414
- Backend role state:
415
-
416
- - VCM terminal submit: role becomes `running`.
417
- - `Stop`: role becomes `idle` and records `lastTurnEndedAt`.
418
- - `PostCompact`: refreshes role session metadata and records `lastCompactAt` without changing `running`/`idle`.
419
- - `StopFailure`: first checks completion evidence. If the role already wrote an outgoing route file, VCM marks the role idle and dispatches normally. If not, VCM sends a recovery prompt to the same role without marking it idle.
420
- - The role tab and flow pause state react to Claude Code hook events for all VCM flow roles, including Gate Reviewer.
421
-
422
- Task-level Round state:
423
-
424
- - The first `UserPromptSubmit` starts a Round for the current VCM Session.
425
- - Each accepted `UserPromptSubmit` is the start of one Turn.
426
- - `Stop` ends the current Turn and starts a 10 second stop timer; during that timer, the Round is still `running`.
427
- - `StopFailure` ends the Turn only after VCM decides the role completed or recovery is unavailable. When recovery is sent, the existing Turn stays running.
428
- - A new `UserPromptSubmit` inside the window continues the same Round and starts the next Turn.
429
- - If no new prompt is accepted before the deadline, the Round becomes `stopped`.
430
- - The stop transition is timer-driven from the turn-end event. Round-state reads do not end a Round.
431
- - Before stopping, VCM checks `.ai/vcm/handoffs/messages`; if a pending route message exists and can be delivered, VCM retries delivery and extends the stop window instead of alerting.
432
- - The same Round state stores total Round count, Turn count, completed Turn count, and role active runtime. Active runtime is measured only between `UserPromptSubmit` and the turn-end event, not during the stop window.
433
- - The Round dock shows both wall-clock Round duration and role active runtime. For a running Round, `Total` is `now - Round.startedAt`; for a stopped Round, it is `stoppedAt - Round.startedAt`. `Role runtime` is the accumulated active runtime across Turns in that Round; `Turn count` is the number of accepted prompts in the Round.
434
-
435
- The frontend polls this task-level Round state and deduplicates each stopped Round so the same stopped state does not alert on every poll. Flow duration is measured from the first `UserPromptSubmit` to `stoppedAt`, falling back to the last turn-end timestamp when needed. Runs under 2 minutes trigger the weak 3-chime reminder at 1.4 second intervals. Runs at or above 2 minutes trigger the strong alert dialog and repeating sound until confirmation.
436
-
437
- ## 9. Session Lifecycle
438
-
439
- Buttons:
440
-
441
- - `Start`: creates a new Claude session id and starts a fresh role process.
442
- - `Resume`: reuses the persisted Claude session id and starts Claude Code with resume.
443
- - `Restart`: stops the current process and starts a fresh Claude session id.
444
- - `Stop`: stops the current embedded terminal process.
445
-
446
- Current command shapes:
447
-
448
- ```text
449
- claude --agent <role> --session-id <uuid>
450
- claude --agent <role> --resume <uuid>
451
- claude --agent <role> --session-id <uuid> --permission-mode bypassPermissions
452
- ```
453
-
454
- VCM persists:
455
-
456
- - terminal runtime session id
457
- - Claude session id
458
- - transcript path
459
- - role status
460
- - permission mode
461
- - display command
462
- - cwd
463
- - pid when running
464
- - log path
465
-
466
- Raw terminal output is appended to the role log path for recovery and debugging. The embedded terminal UI is bounded: xterm keeps a finite scrollback buffer, and reconnect/replay sends only the tail of the raw log, capped at 2 MB. The product must not replay an unbounded terminal log into the browser after a long-running session reconnects.
467
-
468
- ## 10. Harness Installation
469
-
470
- On repository connect, VCM checks:
471
-
472
- ```text
473
- CLAUDE.md
474
- .gitignore
475
- .claude/agents/project-manager.md
476
- .claude/agents/architect.md
477
- .claude/agents/coder.md
478
- .claude/agents/reviewer.md
479
- ```
480
-
481
- If a file is missing, VCM can create a recommended default.
482
-
483
- If a file already exists, VCM only inserts or replaces the managed block:
484
-
485
- ```md
486
- <!-- VCM:BEGIN version=1 -->
487
- ...
488
- <!-- VCM:END -->
489
- ```
490
-
491
- For `.gitignore`, VCM uses hash comments:
492
-
493
- ```gitignore
494
- # VCM:BEGIN version=1
495
- .ai/vcm/
496
- .claude/worktrees/
497
- # VCM:END
498
- ```
499
-
500
- `.ai/vcm/` is the active VCM local control area, and `.claude/worktrees/` is the Claude-compatible task worktree area. The base repo keeps project-scoped runtime state outside Git; each task runtime repo keeps its own session, message, orchestration, and translation state.
501
-
502
- VCM must preserve all user-authored content outside the managed block.
503
-
504
- Harness changes are applied only in the active task worktree. For deterministic fixed-harness updates, VCM refuses to run when that worktree has Git-visible changes, writes the harness update, stages the changed harness files, and immediately creates a harness commit. For AI bootstrap work, Harness Engineer runs in the active task worktree and creates its own commit; VCM tracks status and shows the latest active task commit diff for review.
505
-
506
- Role sessions get VCM behavior from `CLAUDE.md` and `.claude/agents/*.md`, not from a pasted startup context.
507
-
508
- ## 11. Handoff Files
509
-
510
- Each task creates:
511
-
512
- ```text
513
- .ai/vcm/handoffs/
514
- role-commands/
515
- architect.md
516
- coder.md
517
- reviewer.md
518
- architecture-plan.md
519
- known-issues.md
520
- review-report.md
521
- docs-sync-report.md
522
- messages/
523
- project-manager-architect.md
524
- project-manager-coder.md
525
- project-manager-reviewer.md
526
- architect-project-manager.md
527
- coder-project-manager.md
528
- reviewer-project-manager.md
529
- <optional-peer-route>.md
530
- ```
531
-
532
- The product treats handoff files as task-local coordination facts. The terminal is useful for live interaction, but handoff files and message history are the source of truth during a task. They live under `.ai/vcm/`, are ignored by Git, and are removed by `Close Task`; final decisions that should survive must be copied into normal project docs, source, commit messages, or PR text.
533
-
534
- The main UI no longer has a dedicated artifact panel. Artifact APIs still exist for status checks and future UI work.
535
-
536
- ## 12. Message Bus
537
-
538
- VCM messaging is file-driven and dispatched by VCM after Claude Code turn completion. Roles do not call a VCM CLI to send messages.
539
-
540
- ```text
541
- role terminal
542
- -> writes/updates one route file under .ai/vcm/handoffs/messages/
543
- -> ends the Claude Code turn
544
- -> Claude Code Stop hook calls VCM backend directly
545
- -> VCM scans pending route files
546
- -> VCM validates, snapshots, and dispatches one allowed message per idle target role
547
- ```
548
-
549
- Route files:
550
-
551
- - File name format is `<from-role>-<to-role>.md`.
552
- - Role names use VCM role slugs, for example `project-manager-coder.md`.
553
- - The file path determines `from` and `to`; frontmatter cannot override the route.
554
- - The file body is Markdown.
555
- - Optional YAML frontmatter may provide `type`, `severity`, `title`, or `related_artifact`.
556
- - Blank or whitespace-only files mean "no pending message".
557
- - Non-empty files mean "pending message waiting for VCM dispatch".
558
-
559
- The important product rule is one file per directed route. If role A decides several times during one turn that it needs to call role B, it must edit the same `A-B.md` file instead of creating multiple messages. This turns duplicate sends into a single latest pending instruction.
560
-
561
- Default route policy:
562
-
563
- - `project-manager` may send to `architect`, `coder`, and `reviewer`.
564
- - `architect`, `coder`, and `reviewer` may send to `project-manager`.
565
- - Peer routes such as `coder-reviewer.md` may exist for explicit task designs, but VCM still serializes delivery per target role.
566
- - `user` talks to `project-manager` through the normal active terminal or translation composer, not through a route file.
567
-
568
- Claude turn-end scan:
569
-
570
- - VCM injects Claude Code `UserPromptSubmit`, `Stop`, `StopFailure`, `PostCompact`, and `PermissionRequest` hooks into `.claude/settings.json`.
571
- - The hooks do not call `vcmctl`; they POST directly to the local VCM backend.
572
- - When a Claude Code role stops, VCM marks that role idle, then scans pending route files.
573
- - VCM scans the stopped role's outgoing files and also any pending files targeting newly idle roles, so messages that were blocked by a busy target can be delivered after that target stops.
574
- - VCM reads only stable, non-empty files and ignores blank files.
575
- - VCM delivers at most one message to a target role per scan.
576
- - If multiple pending files target the same idle role, VCM chooses deterministically by oldest modified time, then route name.
577
-
578
- Manual mode:
579
-
580
- - role route files stay non-empty as pending handoffs
581
- - user opens `Messages`
582
- - message rows show newest delivered history first with stable increasing sequence, timestamp, body preview, path, and `Copy`
583
- - `Mark All Done` clears pending route files after the user manually handled stuck handoff content
584
- - `Delete All` removes message history without touching pending route files
585
- - user decides whether to copy or manually act on the message
586
- - VCM does not write to the target terminal or submit Enter
587
- - VCM does not clear the source route file until the user marks it done or VCM later dispatches it in auto mode
588
-
589
- Auto mode:
590
-
591
- - if the target role is running and hook-idle, VCM writes a `[VCM MESSAGE]` envelope to that role's embedded terminal and submits Enter
592
- - before writing to the terminal, VCM stores `dispatchingAt` and waits briefly so the GUI can switch to the target role tab first
593
- - terminal write success stores a durable delivered message snapshot
594
- - Claude Code `UserPromptSubmit` confirms the accepted prompt, stores `acceptedAt`, and clears the source route file if it still contains that same message
595
- - if the target role is not running, is busy, or terminal submission fails, VCM leaves the route file non-empty so it remains pending
596
- - when VCM records `dispatchingAt`, the GUI switches to the target role tab so the user can watch the terminal receive and execute the message
597
- - the target role answers by writing its own route file back to the next role and then ending its turn
598
- - `Mark All Done` is a manual recovery action for stuck orchestration. It clears route files only after the user confirms the pending file contents were manually handled.
599
-
600
- VCM Harness injects Claude Code hooks into `.claude/settings.json`:
601
-
602
- - `UserPromptSubmit`: posts directly to the VCM backend, marks the role running, and confirms any matching VCM message by recording `acceptedAt`
603
- - `Stop`: posts directly to the VCM backend, marks the role idle, and triggers pending route-file dispatch
604
- - `StopFailure`: posts directly to the VCM backend; VCM checks for outgoing route-file completion evidence before marking idle. If no evidence exists, VCM sends a same-role recovery prompt and keeps the Turn running.
605
- - `PostCompact`: posts directly to the VCM backend, refreshes `session_id`/`transcript_path`/`cwd`, and records `lastCompactAt`
606
- - `PermissionRequest`: posts directly to the VCM backend and prints the backend response to stdout so Claude Code can consume an allow decision when the local VCM setting is enabled
607
-
608
- VCM uses `UserPromptSubmit` as the Claude Code acceptance signal. A successful PTY write only proves VCM delivered text to the embedded terminal; `UserPromptSubmit` proves Claude Code accepted the prompt.
609
-
610
- Gate Reviewer does not dispatch route files. PM receives Gate Review completion through the Gate Review callback managed by VCM.
611
-
612
- The injected role rules require asynchronous file messaging: after writing or updating a route file, the role must end the current Claude Code turn and wait for VCM to deliver a later reply. Roles should use `.claude/skills/vcm-route-message/SKILL.md` to author route files. Roles must not poll files, start shell loops, keep the turn open waiting for another role to answer, paste directly into another role terminal, or use Claude Code Task/Subagent for VCM role delegation.
613
-
614
- Roles must not run background Bash; a `PreToolUse` hook (`.ai/tools/vcm-bash-guard`) denies `run_in_background`, `nohup`, `setsid`, `disown`, and trailing `&`. The only sanctioned long-running mechanism is `.ai/tools/run-long-check` plus `.ai/tools/watch-job` through `vcm-long-running-validation`: the detached job worker enforces the 60 minute ceiling and a supervision lease that kills unwatched jobs, `watch-job` renews the lease in foreground windows of up to 8 minutes (exit `125` means call it again in the same turn), and the VCM backend blocks a role's turn-end while one of its validation jobs is still running.
615
-
616
- There is no `vcmctl` in the target design. Hook entrypoints are direct HTTP from Claude Code hooks to the local VCM backend.
617
-
618
- ## 13. Translation
619
-
620
- Translation is a local assistant layer beside the role terminal.
621
-
622
- ### Translation Controls
623
-
624
- Settings are saved in:
625
-
626
- ```text
627
- <vcmDataDir>/settings.json
628
- ```
629
-
630
- The settings file stores:
631
-
632
- - global translation enablement
633
- - global translation auto-send preference
634
- - global translation target language
635
- - recent repository paths
636
-
637
- Translation work is routed through the long-lived Translator session. VCM no longer exposes API-key, provider, or prompt-slot settings for the old API-backed translation path.
638
-
639
- Sidebar controls:
640
-
641
- - Conversation translation on/off
642
- - Auto-send on/off
643
- - Target language
644
- - Output mode: final summary or all output
645
- - File translation
646
- - Bootstrap
647
- - Update memory
648
-
649
- ### Claude Output Translation
650
-
651
- Output translation does not read raw PTY text.
652
-
653
- VCM tails Claude Code transcript JSONL files under:
654
-
655
- ```text
656
- ~/.claude/projects/<project-hash>/<claude-session-id>.jsonl
657
- ```
658
-
659
- The transcript path is persisted in the role session record. If that path is missing, VCM falls back to resolving by current working directory and then scanning `~/.claude/projects` for the newest file with the session id.
660
-
661
- VCM owns transcript listening in the backend. Opening the translation panel starts or confirms the backend tailer for the active role session. Closing the panel does not stop that tailer; it keeps collecting Claude output until the role session is stopped/restarted or the task is closed. This keeps translation capture independent from frontend rendering.
662
-
663
- Backend translation cache lives under:
664
-
665
- ```text
666
- <taskRepoRoot>/.ai/vcm/translation/<task>/<role>/<session-id>.jsonl
667
- ```
668
-
669
- The frontend does not subscribe through WebSocket. It polls the backend with a cursor and receives new cached events. The cursor means "next expected seq": `after=18` confirms that seq `1..17` have already been displayed, so the backend can remove those cached events and return seq `18` and later. If the cursor is older than the retained cache, VCM still returns whatever newer events remain; it does not use a snapshot error mode.
670
-
671
- Transcript event handling:
672
-
673
- - assistant text with `stopReason=end_turn` -> `prose` -> translated
674
- - assistant text with other stop reasons -> `prose` -> preserved by default, translated only in `all output` mode
675
- - AskUserQuestion tool -> formatted `prose` -> preserved by default, translated only in `all output` mode
676
- - TodoWrite tool -> formatted `prose` -> preserved by default, translated only in `all output` mode
677
- - Agent/Task tool -> formatted `prose` -> preserved by default, translated only in `all output` mode
678
- - normal tool_use -> `tool-output` -> preserved
679
- - tool_result -> `tool-output` -> preserved
680
-
681
- Display behavior:
682
-
683
- - `prose` starts by showing the English source as queued.
684
- - while translating, panel status shows `translating <elapsed>`.
685
- - when translation succeeds, the English source is replaced by Chinese translated text.
686
- - when new translation events arrive, the active panel scrolls to the bottom after render so the latest entry, retry result, or conversation boundary is visible.
687
- - `prose` content is rendered as Markdown, including headings, lists, code fences, tables, and links.
688
- - when translation fails, panel status shows `error` and the entry keeps the visible source plus an error.
689
- - `tool-output` is dim, one-line, truncated by CSS, and not translated.
690
-
691
- Long translations do not block capture. Translatable prose entries are pushed to the panel before translation starts. Claude Code prose output waits up to 10 seconds so adjacent entries can be batched into one Claude Code Translator prompt and one temporary result file. When an `end_turn` assistant text arrives, VCM adds it to the current batch and flushes the batch immediately. The default output mode is `PM final reply`, which translates only Project Manager `end_turn` assistant text to reduce translation work. In `all output` mode, intermediate assistant text and structured question/todo/agent events are also translated. `tool_use` and `tool_result` entries are never added to the translation queue; they are displayed immediately.
692
-
693
- There is no keyword classifier that drops assistant text. A previous design skipped permission-looking or log-looking text; that is removed.
694
-
695
- ### Translation Retention And Retry
696
-
697
- Translation display state is bounded for long sessions. VCM retains the most recent 500 translation entries per role session in frontend/backend memory. Older entries are pruned from the live panel state and from the backend event cache so reconnects do not replay unbounded translation history. Entries that are currently `queued` or `translating` are protected from pruning.
698
-
699
- Translation failures are tracked as a backend failure list, separate from the rendered entry list. The panel shows `Ignore N` and `Retry N` only when that list is non-empty.
700
-
701
- Failure behavior:
702
-
703
- - provider failure for Claude output `prose` adds a `TranslationFailureItem`.
704
- - `Retry N` retries the failure list and reuses the original translation entry id, so the existing failed row becomes `translating` and then `translated` on success.
705
- - `Ignore N` clears the failure list without deleting visible entries.
706
- - if retention pruning removes an old failed entry, VCM also removes the matching failure-list item so retry never targets a deleted entry.
707
- - `tool-output`, conversation boundary rows, and user-input translation failures are not part of the output retry list.
708
-
709
- ### User Input Translation
710
-
711
- The composer has one textarea and one `Send English` button.
712
-
713
- Keyboard behavior:
714
-
715
- - `Enter`: translate current Chinese text, or send the current English draft.
716
- - `Shift+Enter`: insert newline.
717
-
718
- After translation succeeds, the English draft is appended after the original Chinese text in the same textarea.
719
-
720
- The translated user input is also shown in the translation panel as a conversation boundary. User-input entries have a thick divider and larger top spacing so the next Claude output reads as the answer to that prompt.
721
-
722
- `Send English` pastes the current English text into the active role terminal, then sends Enter as a separate terminal input event.
723
-
724
- Translation panel `Auto-send` is separate from task `Auto orchestration`:
725
-
726
- - `Auto-send` on: translate and send if there is no translation warning.
727
- - `Auto-send` off: translate to English draft and wait for user send.
728
-
729
- Task `Auto orchestration` is a compact selected/unselected button in the task
730
- workspace header next to `Close Task`. New tasks default to auto orchestration.
731
- Conversation translation is controlled by the sidebar `Translation` group; when
732
- enabled, each running core VCM role console shows the translation split, so
733
- switching roles keeps the same global translation setting.
734
-
735
- ## 14. Mobile Gateway
736
-
737
- VCM Gateway is a mobile chat bridge to the local desktop VCM instance. Supported
738
- channels are Weixin iLink and Lark.
739
-
740
- Gateway product rules:
741
-
742
- - Weixin is DM only; Lark can receive group messages only when the bot is
743
- mentioned.
744
- - Weixin binds one mobile chat identity to one desktop VCM instance.
745
- - Lark accepts any DM or group @mention that can reach the bot, and the most
746
- recent active Lark chat becomes the PM reply target.
747
- - The active mobile chat is not tied to one project or one task.
748
- - The active mobile chat can select among the projects and tasks available to
749
- the desktop VCM instance.
750
- - After setup succeeds, VCM keeps a Gateway channel connection even when
751
- Gateway is off; only `/help`, `/start`, `/status`, `/projects`, and `/tasks`
752
- are accepted in that state. `/start` turns Gateway on from the active mobile
753
- chat.
754
- - VCM caches the latest PM reply per task locally. When `/start` turns Gateway
755
- on and the current task has a cached PM reply, the response includes that
756
- latest PM reply so the mobile user can resume with context.
757
- - Plain mobile text is sent only to the current task's `project-manager`.
758
- - Gateway never sends directly to `architect`, `coder`, or `reviewer`.
759
- - Gateway can push PM assistant replies to the active mobile chat whenever
760
- gateway is enabled, even if that PM turn was started from desktop VCM.
761
- - When gateway translation is enabled, mobile input is translated to English
762
- before PM receives it, and PM English replies are translated before the mobile
763
- chat receives them.
764
- - If PM reply translation fails or times out, Gateway sends a translation
765
- failure notice instead of the English source. The active mobile chat can send
766
- `/retry` to retry the latest failed output translation kept in memory.
767
- - The PM prompt does not include the original Chinese text.
768
- - There is no multi-user allowlist. Weixin is a bound identity model; Lark is a
769
- trusted-chat bot model.
770
-
771
- The Weixin channel uses Tencent iLink QR login, `getupdates` long polling, and
772
- `sendmessage` text replies. The Lark channel uses QR setup to create/configure a
773
- bot app, stores the resulting App ID/App Secret locally, then uses WebSocket
774
- event delivery. Gateway details and implementation plan live in
775
- `docs/gateway-design.md`.
776
-
777
- ## 15. Local State
778
-
779
- App-level settings:
780
-
781
- ```text
782
- <vcmDataDir>/settings.json
783
- ```
784
-
785
- Stored app-level settings include:
786
-
787
- - UI theme mode: `system`, `light`, or `dark`
788
- - pause alert sound preference
789
- - Claude Code permission request handling preference
790
- - global translation preferences
791
- - recent repository paths
792
-
793
- Gateway state and audit logs:
794
-
795
- ```text
796
- <vcmDataDir>/gateway/settings.json
797
- <vcmDataDir>/gateway/audit.jsonl
798
- ```
799
-
800
- Gateway credentials, iLink tokens, active chat metadata, cursors, context
801
- tokens, and audit logs live under `vcmDataDir`. VCM resolves `vcmDataDir` from
802
- `VCM_DATA_DIR`; if it is unset or empty, VCM uses `~/.vcm`.
803
-
804
- Repository-level VCM state:
805
-
806
- ```text
807
- .claude/worktrees/<task>/
808
- ```
809
-
810
- Project config:
811
-
812
- ```text
813
- <vcmDataDir>/projects/<project-id>/config.json
814
- <vcmDataDir>/projects/index.json
815
- ```
816
-
817
- The base repository's `.ai/vcm/` directory stores task-local runtime state, while `.claude/worktrees/` stores nested task worktrees. Long-lived project config is stored under `vcmDataDir`. In Dev Containers, set `VCM_DATA_DIR=/workspace/.ai/vcm` through `containerEnv` so VCM app state survives container rebuilds.
818
-
819
- Task worktree local files:
820
-
821
- ```text
822
- .claude/worktrees/<task>/.ai/vcm/sessions/<task>.json
823
- .claude/worktrees/<task>/.ai/vcm/messages/<task>.jsonl
824
- .claude/worktrees/<task>/.ai/vcm/orchestration/<task>.json
825
- .claude/worktrees/<task>/.ai/vcm/translation/<task>/
826
- .claude/worktrees/<task>/.ai/vcm/gate-reviews/
827
- .claude/worktrees/<task>/.ai/vcm/handoffs/
828
- .claude/worktrees/<task>/.ai/vcm/handoffs/messages/<from-role>-<to-role>.md
829
- ```
830
-
831
- Project-scoped local files:
832
-
833
- ```text
834
- .ai/vcm/harness-engineer/session.json
835
- .ai/vcm/translations/
836
- .ai/vcm/bootstrap/session.json
837
- ```
838
-
839
- Project-scoped tool sessions keep their durable state in the base repository,
840
- but their execution cwd is the active task worktree.
841
-
842
- External Claude transcripts:
843
-
844
- ```text
845
- ~/.claude/projects/<project-hash>/<claude-session-id>.jsonl
846
- ```
847
-
848
- ## 16. Packaging Expectations
849
-
850
- Published npm packages must include built output:
851
-
852
- - `dist/main.js`
853
- - backend route/service/template output in `dist/`
854
- - frontend static assets in `dist-frontend/`
855
- - `README.md`
856
- - `docs/`
857
- - `scripts/`
858
-
859
- `prepack` runs:
860
-
861
- ```text
862
- npm run build && npm run verify:package
863
- ```
864
-
865
- This protects against publishing raw TypeScript bin files or missing frontend assets.
866
-
867
- ## 17. Success Criteria
868
-
869
- VCM V1 is successful when:
870
-
871
- - A user can connect a repo without global Git safe-directory setup.
872
- - A user can create a task, which creates `feature/<task>` and `.claude/worktrees/<task>`.
873
- - A user can start all four role sessions in the task worktree.
874
- - Switching roles never loses the embedded terminal.
875
- - Restart creates a fresh Claude session; Resume reconnects to the persisted one.
876
- - Permission modes are reflected in the Claude command.
877
- - Sidebar settings include Claude Code permission request handling with `off` and `allow all`; `off` is the default.
878
- - Roles can route messages by writing fixed route files under `.ai/vcm/handoffs/messages/`.
879
- - Manual orchestration lets the user inspect pending route-file messages without auto-submitting Enter.
880
- - Auto orchestration can deliver pending route-file messages to idle running target roles.
881
- - Auto orchestration switches to the target role tab when VCM records `dispatchingAt`, before VCM submits the route-file message.
882
- - Auto orchestration treats `UserPromptSubmit` as the reliable acceptance confirmation; if confirmation does not arrive, backend PTY retries Enter and records a message `failureReason` after retry exhaustion.
883
- - Round completion detection waits for the final role in a chained conversation and can alert with prompt plus sound.
884
- - Translation settings save to `<vcmDataDir>/settings.json`.
885
- - Translation reads Claude transcript JSONL reliably after start, resume, and restart.
886
- - Gateway can bind one Weixin DM identity or use the most recent active Lark
887
- chat, send translated plain text to PM, and push translated PM replies back to
888
- the active mobile chat.
889
- - Terminal and translation panel have equal, stable reading space.
890
- - Harness install/update preserves user content outside VCM managed blocks.
891
- - Completed tasks can cleanly remove their worktree and VCM task metadata without affecting other tasks.