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,534 +0,0 @@
1
- # V1 Message Bus Orchestration Design
2
-
3
- ## 1. Goal
4
-
5
- Replace the current user-clicked `Send Command` handoff with a PM-mediated role message bus.
6
-
7
- The desired user experience:
8
-
9
- - The user talks primarily with `project-manager`.
10
- - `project-manager` can assign work to `architect`, `coder`, and `reviewer`.
11
- - Other roles can report results, questions, and blockers back to `project-manager`.
12
- - `project-manager` decides whether to continue orchestration or stop and ask the user.
13
- - The user can still inspect every role session, pause orchestration, and intervene manually.
14
-
15
- The key product rule:
16
-
17
- ```text
18
- User <-> Project Manager <-> Other Roles
19
- ```
20
-
21
- Do not create a fully connected agent chat room.
22
-
23
- ## 1.1 Orchestration Mode Switch
24
-
25
- The message bus and automatic execution must be separate features.
26
-
27
- V1 should expose a task-level switch:
28
-
29
- ```ts
30
- export type VcmOrchestrationMode =
31
- | "manual"
32
- | "auto";
33
- ```
34
-
35
- Default:
36
-
37
- ```text
38
- manual
39
- ```
40
-
41
- Meaning:
42
-
43
- - `manual`: roles may send messages through VCM, but VCM does not automatically execute them in the target Claude Code terminal.
44
- - `auto`: VCM may deliver approved role messages directly into the target Claude Code terminal according to backend policy.
45
-
46
- Manual mode is the safety-first default. It allows PM-led collaboration without hidden agent-to-agent execution.
47
-
48
- ## 2. Feasibility
49
-
50
- This is feasible with the current VCM architecture.
51
-
52
- Existing capability:
53
-
54
- - `TerminalRuntime.write(sessionId, data)` can programmatically write to a role terminal.
55
- - `SessionService` can locate role sessions by `taskSlug` and `role`.
56
- - `NodePtyTerminalRuntime` already persists terminal output to role logs.
57
- - The backend already owns task metadata, canonical handoff paths, and role session state.
58
- - The frontend already has role tabs and event log surfaces.
59
-
60
- Missing pieces:
61
-
62
- - A persistent message model.
63
- - A message service that validates sender, target, task, and delivery policy.
64
- - Role-facing commands or skills so Claude Code roles can ask VCM to send/reply.
65
- - UI state for message history, pause/resume, queued messages, and failures.
66
- - Guardrails against loops, hidden automation, and terminal injection during unsafe moments.
67
-
68
- ## 3. Recommended Model
69
-
70
- Use a backend-mediated message bus.
71
-
72
- Roles should not write directly to other PTYs. Roles call VCM, and VCM decides whether to deliver.
73
-
74
- ```text
75
- project-manager Claude Code session
76
- -> vcmctl send --to coder --type task --body-file ...
77
- -> VCM backend MessageService
78
- -> persist message
79
- -> policy check
80
- -> manual mode: wait for user approval
81
- -> auto mode: write message envelope to coder terminal
82
-
83
- coder Claude Code session
84
- -> vcmctl reply --type blocked --body-file ...
85
- -> VCM backend MessageService
86
- -> persist message
87
- -> policy check
88
- -> manual mode: wait for user approval
89
- -> auto mode: write message envelope to project-manager terminal
90
- ```
91
-
92
- ## 4. Role Permissions
93
-
94
- V1 should enforce these rules in backend code, not only in prompts.
95
-
96
- | Sender | Allowed target | Allowed message types |
97
- | --- | --- | --- |
98
- | user | project-manager | user-request |
99
- | project-manager | architect / coder / reviewer | task, question, review-request, revise, cancel |
100
- | architect | project-manager | result, question, blocked |
101
- | coder | project-manager | result, question, blocked |
102
- | reviewer | project-manager | result, finding, blocked |
103
-
104
- Disallowed:
105
-
106
- - `coder -> architect`
107
- - `architect -> coder`
108
- - `reviewer -> coder`
109
- - any role creating a new task identity
110
- - any role sending messages for a different `taskSlug`
111
-
112
- If a role needs another role, it must ask PM.
113
-
114
- ## 5. Message Data Model
115
-
116
- Add shared type `VcmRoleMessage`.
117
-
118
- ```ts
119
- export type VcmMessageType =
120
- | "user-request"
121
- | "task"
122
- | "question"
123
- | "blocked"
124
- | "result"
125
- | "finding"
126
- | "review-request"
127
- | "revise"
128
- | "cancel";
129
-
130
- export type VcmMessageStatus =
131
- | "pending_approval"
132
- | "queued"
133
- | "staged"
134
- | "delivered"
135
- | "acknowledged"
136
- | "failed"
137
- | "rejected"
138
- | "cancelled";
139
-
140
- export interface VcmRoleMessage {
141
- id: string;
142
- taskSlug: string;
143
- fromRole: RoleName | "user";
144
- toRole: RoleName;
145
- type: VcmMessageType;
146
- body: string;
147
- artifactRefs: string[];
148
- parentMessageId?: string;
149
- status: VcmMessageStatus;
150
- createdAt: string;
151
- deliveredAt?: string;
152
- acknowledgedAt?: string;
153
- stagedAt?: string;
154
- failureReason?: string;
155
- }
156
- ```
157
-
158
- Persistence:
159
-
160
- ```text
161
- .vcm/messages/<task-slug>.jsonl
162
- ```
163
-
164
- For long bodies:
165
-
166
- ```text
167
- .ai/handoffs/<task-slug>/messages/<message-id>.md
168
- ```
169
-
170
- The JSONL record should keep a short preview and a body path when needed.
171
-
172
- Orchestration state persistence:
173
-
174
- ```text
175
- .vcm/orchestration/<task-slug>.json
176
- ```
177
-
178
- If the file is missing, VCM must treat the task as `manual` mode and `paused: false`.
179
-
180
- ## 6. Delivery Envelope
181
-
182
- VCM should write a clear envelope into the target terminal.
183
-
184
- In `auto` mode, VCM may write the full envelope and submit it to the target role.
185
-
186
- ```text
187
-
188
- [VCM MESSAGE]
189
- id: msg_...
190
- task: demo-task
191
- from: project-manager
192
- to: coder
193
- type: task
194
-
195
- <message body>
196
-
197
- Artifact refs:
198
- - .ai/handoffs/demo-task/architecture-plan.md
199
-
200
- Instructions:
201
- - Read the message and execute only within this VCM task.
202
- - Reply to project-manager with vcmctl reply when complete, blocked, or unclear.
203
- [/VCM MESSAGE]
204
-
205
- ```
206
-
207
- The envelope is intentionally visible. Hidden agent-to-agent work should not happen.
208
-
209
- In `manual` mode, VCM should not write the full message into the target PTY automatically. Instead:
210
-
211
- 1. Persist the message.
212
- 2. Show the message in the GUI as `pending_approval`.
213
- 3. Let the user inspect, approve, reject, or edit.
214
- 4. On approval, stage a short one-line terminal input without a trailing carriage return:
215
-
216
- ```text
217
- Read and handle VCM message msg_123 at .ai/handoffs/demo-task/messages/msg_123.md
218
- ```
219
-
220
- The user must press Enter in the target embedded terminal for the role to execute it.
221
-
222
- This avoids accidental execution while still removing copy/paste burden.
223
-
224
- ## 7. Role Skill / Command Design
225
-
226
- Provide a VCM role skill backed by a local CLI.
227
-
228
- The skill text should teach roles when to use VCM messaging. The actual action should be a command, because Claude Code can execute shell commands but VCM should enforce policy in backend.
229
-
230
- CLI shape:
231
-
232
- ```bash
233
- vcmctl send --to coder --type task --body-file /tmp/vcm-message.md
234
- vcmctl reply --type blocked --body "Need clarification on test scope."
235
- vcmctl result --body-file /tmp/vcm-result.md --artifact .ai/handoffs/demo-task/implementation-log.md
236
- vcmctl inbox
237
- vcmctl ready
238
- ```
239
-
240
- CLI behavior:
241
-
242
- - In `manual` mode, `vcmctl send/reply/result` returns `pending_approval` and tells the sender that the user must approve delivery.
243
- - In `auto` mode, `vcmctl send/reply/result` may deliver immediately if policy checks pass.
244
- - Roles must not assume that a sent message has been executed by the target role.
245
- - Roles should wait for a reply message, not for terminal side effects.
246
-
247
- Injected environment per role session:
248
-
249
- ```bash
250
- VCM_API_URL=http://127.0.0.1:<backend-port>
251
- VCM_TASK_SLUG=demo-task
252
- VCM_ROLE=project-manager
253
- VCM_SESSION_ID=session_...
254
- VCM_MESSAGE_TOKEN=<local-session-token>
255
- ```
256
-
257
- Backend must verify token, task, role, and session before accepting a message.
258
-
259
- Skill files:
260
-
261
- ```text
262
- .vcm/skills/project-manager-messaging.md
263
- .vcm/skills/role-reply.md
264
- ```
265
-
266
- Or generated role context injected at session start:
267
-
268
- - PM gets `send_to_role` rules.
269
- - Other roles get `reply_to_pm` rules.
270
- - All roles get the canonical `taskSlug` and `handoffDir`.
271
-
272
- ## 8. Backend Components
273
-
274
- New files:
275
-
276
- ```text
277
- src/shared/types/message.ts
278
- src/backend/services/message-service.ts
279
- src/backend/api/message-routes.ts
280
- src/backend/templates/message-envelope.ts
281
- src/backend/templates/role-messaging-context.ts
282
- src/cli/vcmctl.ts
283
- tests/unit/backend/message-service.test.ts
284
- tests/unit/backend/message-envelope.test.ts
285
- ```
286
-
287
- Existing files to change:
288
-
289
- ```text
290
- src/backend/server.ts
291
- src/backend/services/session-service.ts
292
- src/backend/runtime/terminal-runtime.ts
293
- src/frontend/routes/task-workspace.tsx
294
- src/frontend/components/event-log.tsx
295
- src/frontend/state/api-client.ts
296
- src/shared/types/api.ts
297
- package.json
298
- ```
299
-
300
- ## 9. Backend API
301
-
302
- ```http
303
- GET /api/tasks/:taskSlug/messages
304
- POST /api/tasks/:taskSlug/messages
305
- POST /api/tasks/:taskSlug/messages/:messageId/ack
306
- GET /api/tasks/:taskSlug/orchestration
307
- PUT /api/tasks/:taskSlug/orchestration
308
- POST /api/tasks/:taskSlug/messages/:messageId/stage
309
- POST /api/tasks/:taskSlug/messages/:messageId/approve
310
- POST /api/tasks/:taskSlug/messages/:messageId/reject
311
- POST /api/tasks/:taskSlug/orchestration/pause
312
- POST /api/tasks/:taskSlug/orchestration/resume
313
- ```
314
-
315
- Request:
316
-
317
- ```ts
318
- export interface SendRoleMessageRequest {
319
- fromRole: RoleName | "user";
320
- toRole: RoleName;
321
- type: VcmMessageType;
322
- body: string;
323
- artifactRefs?: string[];
324
- parentMessageId?: string;
325
- }
326
- ```
327
-
328
- Response:
329
-
330
- ```ts
331
- export interface SendRoleMessageResult {
332
- message: VcmRoleMessage;
333
- delivered: boolean;
334
- requiresUserApproval: boolean;
335
- }
336
- ```
337
-
338
- Task-level orchestration state:
339
-
340
- ```ts
341
- export interface VcmOrchestrationState {
342
- taskSlug: string;
343
- mode: VcmOrchestrationMode;
344
- paused: boolean;
345
- updatedAt: string;
346
- }
347
- ```
348
-
349
- ## 10. Delivery Policy
350
-
351
- V1 should be conservative.
352
-
353
- Recommended V1 behavior:
354
-
355
- - Message bus is always available.
356
- - `manual` mode is the default.
357
- - In `manual` mode, role messages become `pending_approval`; VCM does not write to target PTY automatically.
358
- - In `manual` mode, user approval can stage a one-line input into the target terminal, but VCM must not append `\r`.
359
- - In `manual` mode, the user presses Enter to execute the staged message.
360
- - In `auto` mode, VCM may write the visible message envelope and append `\r` after policy checks.
361
- - If target session is not running, queue message and show it in UI.
362
- - If target session is running and mode is `auto`, deliver immediately unless orchestration is paused.
363
- - Prefix delivery with a newline so it does not merge with existing terminal input.
364
- - Persist every attempted delivery.
365
- - Do not auto-confirm Claude Code prompts.
366
- - Do not send more than one queued message to a role at a time.
367
-
368
- Known limitation:
369
-
370
- VCM currently cannot reliably know whether Claude Code is idle, thinking, or waiting for a permission prompt. This means terminal injection can still arrive at an awkward time.
371
-
372
- Mitigation:
373
-
374
- - Keep `manual` mode as the default.
375
- - Add `vcmctl ready` as an explicit role readiness signal.
376
- - Phase 1 can use manual approval and staging.
377
- - Phase 2 can add auto delivery only to roles marked ready.
378
-
379
- ## 11. Loop Prevention
380
-
381
- Required guardrails:
382
-
383
- - Only PM can send tasks to non-PM roles.
384
- - Non-PM roles can only reply to PM.
385
- - Add `maxMessagesPerTaskRun`, default 20.
386
- - Add `maxConsecutiveAutoTurns`, default 6.
387
- - Add `orchestrationPaused` state.
388
- - Add explicit `orchestrationMode`, default `manual`.
389
- - Add `blocked` message type that stops automation until PM handles it.
390
- - PM must ask user for high-risk decisions.
391
-
392
- High-risk blockers:
393
-
394
- - destructive file deletion
395
- - database/schema migration
396
- - auth, permission, billing, payment, security
397
- - public API contract changes
398
- - uncertainty about user intent
399
- - repeated role failure
400
-
401
- ## 12. GUI Changes
402
-
403
- Keep role terminals visible, but make PM the user-facing default.
404
-
405
- Task workspace:
406
-
407
- - PM terminal remains primary.
408
- - Role tabs remain available for inspection.
409
- - Add an `Auto orchestration` toggle, default off.
410
- - Add message timeline below or beside terminal.
411
- - In manual mode, show incoming role messages as approval cards.
412
- - Approval card actions: `Stage`, `Reject`, `Edit`, `Open target role`.
413
- - `Stage` writes a one-line prompt to the target terminal without pressing Enter.
414
- - Add pause/resume orchestration button.
415
- - Show queued/delivered/failed message badges.
416
- - Replace `Send Command` with message-aware actions later.
417
-
418
- Possible controls:
419
-
420
- ```text
421
- [Auto orchestration: Off] [Pause] [Messages: 2 pending / 3 queued / 12 delivered]
422
- ```
423
-
424
- The user should never need to copy role commands manually.
425
-
426
- ## 13. Migration From Current Send Command
427
-
428
- Current mode:
429
-
430
- ```text
431
- User clicks Send Command
432
- -> backend sends "read file at role-commands/<role>.md"
433
- ```
434
-
435
- New mode:
436
-
437
- ```text
438
- PM calls vcmctl send --to coder
439
- -> backend persists the message
440
- -> if manual mode: GUI asks user to approve/stage
441
- -> if auto mode: backend sends the message envelope directly to coder
442
- ```
443
-
444
- Role command files can remain useful for long-form handoffs, but they should not be the only dispatch mechanism.
445
-
446
- Recommended transition:
447
-
448
- 1. Keep current `Send Command` temporarily.
449
- 2. Add MessageService and message APIs.
450
- 3. Add task-level orchestration mode, default `manual`.
451
- 4. Add `vcmctl send/reply`.
452
- 5. Inject role messaging context into sessions.
453
- 6. Update PM instructions to use `vcmctl send`.
454
- 7. Replace `Send Command` button with message timeline approval actions.
455
- 8. Remove old role-command dispatch once message bus is stable.
456
-
457
- ## 14. Implementation Phases
458
-
459
- ### Phase 1: Message Bus MVP
460
-
461
- - Add message types.
462
- - Add `MessageService`.
463
- - Persist `.vcm/messages/<task>.jsonl`.
464
- - Add API routes.
465
- - Add `manual` orchestration mode as the default.
466
- - Add user approval and stage APIs.
467
- - Add terminal staging through `TerminalRuntime.write` without trailing `\r`.
468
- - Add backend policy checks.
469
- - Add unit tests.
470
-
471
- Acceptance:
472
-
473
- - PM can send a message to coder through API.
474
- - Message appears as pending approval in GUI.
475
- - User can stage the message into coder terminal.
476
- - Coder does not execute until user presses Enter.
477
- - Coder can reply to PM through API.
478
- - All messages persist and appear in API.
479
-
480
- ### Phase 2: Role CLI / Skill
481
-
482
- - Add `vcmctl`.
483
- - Inject `VCM_*` env vars into role sessions.
484
- - Add role messaging context templates.
485
- - Add PM skill text and non-PM reply skill text.
486
-
487
- Acceptance:
488
-
489
- - PM can run `vcmctl send --to coder`.
490
- - Coder can run `vcmctl reply --type blocked`.
491
- - Backend rejects disallowed role-to-role messages.
492
-
493
- ### Phase 3: GUI Orchestration View
494
-
495
- - Add message timeline.
496
- - Add queue/failed badges.
497
- - Add `Auto orchestration` toggle.
498
- - Add pause/resume button for auto mode.
499
- - Add approval cards for manual mode.
500
- - Replace old `Send Command` button.
501
-
502
- Acceptance:
503
-
504
- - User can understand what PM sent and what roles replied.
505
- - User can keep auto orchestration off and approve each staged delivery.
506
- - User can pause automation when auto orchestration is on.
507
- - Failed deliveries are visible.
508
-
509
- ### Phase 4: Auto Mode, Readiness, and Queues
510
-
511
- - Add `vcmctl ready`.
512
- - Queue messages when target is not ready.
513
- - Deliver one queued message at a time.
514
- - Add max turn limits.
515
- - Enable auto delivery only when task mode is `auto`, orchestration is not paused, target role is ready, and policy checks pass.
516
-
517
- Acceptance:
518
-
519
- - VCM no longer injects messages into busy role terminals by default.
520
- - Loops stop automatically and surface to PM/user.
521
-
522
- ## 15. Key Design Decision
523
-
524
- Do PM-mediated orchestration, not free multi-agent chat.
525
-
526
- This preserves the product promise:
527
-
528
- - user talks to PM
529
- - PM coordinates
530
- - roles execute
531
- - blockers return to PM
532
- - PM asks user only when needed
533
-
534
- It also keeps auditability and control. The message bus becomes the product spine; embedded terminals remain the execution surface.