vibe-coding-master 0.3.27 → 0.3.29

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,6 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import path from "node:path";
3
- import { VCM_ROLE_NAMES, isCodexRoleName, isDispatchableRole } from "../../shared/constants.js";
3
+ import { CORE_VCM_ROLE_NAMES, isCodexRoleName, isDispatchableRole } from "../../shared/constants.js";
4
4
  import { VcmError } from "../errors.js";
5
5
  import { resolveRepoPath } from "../adapters/filesystem.js";
6
6
  import { claudeTranscriptPath } from "./claude-transcript-service.js";
@@ -101,10 +101,10 @@ export function createSessionService(deps) {
101
101
  await persistRoleSessionRecord(deps.fs, repoRoot, taskRepoRoot, config.stateRoot, record);
102
102
  return record;
103
103
  }
104
- async function launchProjectGateReviewerSession(repoRoot, input, launchMode) {
104
+ async function launchProjectGateReviewerSession(repoRoot, input, launchMode, activeTaskSlug) {
105
105
  const live = toRoleSessionRecordView(getRegisteredProjectGateReviewerSession(deps.registry, deps.runtime), deps.runtime);
106
106
  if (live && live.status === "running") {
107
- return live;
107
+ return bindProjectGateReviewerSession(repoRoot, live, activeTaskSlug);
108
108
  }
109
109
  const config = await deps.projectService.loadConfig(repoRoot);
110
110
  const persisted = await loadPersistedProjectGateReviewerSession(deps.fs, repoRoot);
@@ -125,6 +125,10 @@ export function createSessionService(deps) {
125
125
  const transcriptPath = launchMode === "resume" && persisted?.transcriptPath
126
126
  ? persisted.transcriptPath
127
127
  : claudeTranscriptPath(repoRoot, claudeSessionId);
128
+ const activeTask = activeTaskSlug
129
+ ? await deps.taskService.loadTask(repoRoot, activeTaskSlug)
130
+ : undefined;
131
+ const activeTaskRepoRoot = activeTask ? getTaskRuntimeRepoRoot(activeTask) : undefined;
128
132
  const startCommand = {
129
133
  ...deps.claude.buildRoleStartCommand(GATE_REVIEWER_ROLE, config.claudeCommand, permissionMode, claudeSessionId, launchMode === "resume", model, effort),
130
134
  cwd: repoRoot
@@ -137,8 +141,8 @@ export function createSessionService(deps) {
137
141
  cwd: startCommand.cwd,
138
142
  env: {
139
143
  VCM_API_URL: deps.apiUrl,
140
- VCM_TASK_REPO_ROOT: repoRoot,
141
- VCM_TASK_SLUG: PROJECT_GATE_REVIEWER_SCOPE,
144
+ VCM_TASK_REPO_ROOT: activeTaskRepoRoot ?? repoRoot,
145
+ VCM_TASK_SLUG: activeTaskSlug ?? PROJECT_GATE_REVIEWER_SCOPE,
142
146
  VCM_ROLE: GATE_REVIEWER_ROLE,
143
147
  VCM_SESSION_ID: claudeSessionId
144
148
  },
@@ -164,12 +168,31 @@ export function createSessionService(deps) {
164
168
  startedAt: runtimeSession.startedAt,
165
169
  updatedAt: timestamp,
166
170
  lastOutputAt: runtimeSession.lastOutputAt,
171
+ activeTaskSlug,
172
+ activeTaskRepoRoot,
167
173
  exitCode: runtimeSession.exitCode
168
174
  };
169
175
  deps.registry.upsert(record);
170
176
  await persistProjectGateReviewerSession(deps.fs, repoRoot, record);
171
177
  return record;
172
178
  }
179
+ async function bindProjectGateReviewerSession(repoRoot, record, activeTaskSlug) {
180
+ if (!activeTaskSlug) {
181
+ return record;
182
+ }
183
+ const task = await deps.taskService.loadTask(repoRoot, activeTaskSlug);
184
+ const activeTaskRepoRoot = getTaskRuntimeRepoRoot(task);
185
+ const updated = {
186
+ ...record,
187
+ taskSlug: PROJECT_GATE_REVIEWER_SCOPE,
188
+ activeTaskSlug,
189
+ activeTaskRepoRoot,
190
+ updatedAt: now()
191
+ };
192
+ deps.registry.upsert(updated);
193
+ await persistProjectGateReviewerSession(deps.fs, repoRoot, updated);
194
+ return updated;
195
+ }
173
196
  async function launchProjectTranslatorSession(repoRoot, input, launchMode) {
174
197
  const live = toRoleSessionRecordView(getRegisteredProjectTranslatorSession(deps.registry, deps.runtime), deps.runtime);
175
198
  if (live && live.status === "running") {
@@ -377,7 +400,7 @@ export function createSessionService(deps) {
377
400
  },
378
401
  startRoleSession(repoRoot, taskSlug, role, input = {}) {
379
402
  if (role === GATE_REVIEWER_ROLE) {
380
- return this.startProjectGateReviewerSession(repoRoot, input)
403
+ return launchProjectGateReviewerSession(repoRoot, input, "fresh", taskSlug)
381
404
  .then((session) => scopeProjectRoleSession(session, taskSlug));
382
405
  }
383
406
  if (role === CODEX_TRANSLATOR_ROLE) {
@@ -388,7 +411,7 @@ export function createSessionService(deps) {
388
411
  },
389
412
  resumeRoleSession(repoRoot, taskSlug, role, input = {}) {
390
413
  if (role === GATE_REVIEWER_ROLE) {
391
- return this.resumeProjectGateReviewerSession(repoRoot, input)
414
+ return launchProjectGateReviewerSession(repoRoot, input, "resume", taskSlug)
392
415
  .then((session) => scopeProjectRoleSession(session, taskSlug));
393
416
  }
394
417
  if (role === CODEX_TRANSLATOR_ROLE) {
@@ -430,7 +453,14 @@ export function createSessionService(deps) {
430
453
  },
431
454
  async restartRoleSession(repoRoot, taskSlug, role, input = {}) {
432
455
  if (role === GATE_REVIEWER_ROLE) {
433
- return scopeProjectRoleSession(await this.restartProjectGateReviewerSession(repoRoot, input), taskSlug);
456
+ const existing = await this.getProjectGateReviewerSession(repoRoot);
457
+ if (existing && deps.runtime.getSession(existing.id)) {
458
+ await deps.runtime.stop(existing.id);
459
+ }
460
+ if (existing) {
461
+ deps.registry.remove(existing.id);
462
+ }
463
+ return scopeProjectRoleSession(await launchProjectGateReviewerSession(repoRoot, input, "fresh", taskSlug), taskSlug);
434
464
  }
435
465
  if (role === CODEX_TRANSLATOR_ROLE) {
436
466
  void taskSlug;
@@ -448,7 +478,11 @@ export function createSessionService(deps) {
448
478
  },
449
479
  async getRoleSession(repoRoot, taskSlug, role) {
450
480
  if (role === GATE_REVIEWER_ROLE) {
451
- return scopeProjectRoleSession(await this.getProjectGateReviewerSession(repoRoot), taskSlug);
481
+ const session = await this.getProjectGateReviewerSession(repoRoot);
482
+ if (!session) {
483
+ return undefined;
484
+ }
485
+ return scopeProjectRoleSession(await bindProjectGateReviewerSession(repoRoot, session, taskSlug), taskSlug);
452
486
  }
453
487
  if (role === CODEX_TRANSLATOR_ROLE) {
454
488
  void taskSlug;
@@ -470,7 +504,7 @@ export function createSessionService(deps) {
470
504
  const task = await deps.taskService.loadTask(repoRoot, taskSlug);
471
505
  const taskRepoRoot = getTaskRuntimeRepoRoot(task);
472
506
  const persistedTaskSession = await loadPersistedTaskSessionRecord(deps.fs, taskRepoRoot, config.stateRoot, taskSlug);
473
- for (const role of VCM_ROLE_NAMES) {
507
+ for (const role of CORE_VCM_ROLE_NAMES) {
474
508
  const record = deps.registry.getByRole(taskSlug, role)
475
509
  ?? normalizePersistedRoleRecord(persistedTaskSession?.roles[role]?.record);
476
510
  const session = toRoleSessionRecordView(record, deps.runtime);
@@ -1,6 +1,6 @@
1
1
  export const DEFAULT_BACKEND_PORT = 4173;
2
2
  export const DEFAULT_FRONTEND_PORT = 5173;
3
- export const VCM_ROLE_DEFINITIONS = [
3
+ export const CORE_VCM_ROLE_DEFINITIONS = [
4
4
  {
5
5
  name: "project-manager",
6
6
  label: "Project Manager",
@@ -32,6 +32,10 @@ export const GATE_REVIEWER_ROLE_DEFINITION = {
32
32
  commandAgent: "gate-reviewer",
33
33
  dispatchable: false
34
34
  };
35
+ export const VCM_ROLE_DEFINITIONS = [
36
+ ...CORE_VCM_ROLE_DEFINITIONS,
37
+ GATE_REVIEWER_ROLE_DEFINITION
38
+ ];
35
39
  export const CODEX_TRANSLATOR_ROLE_DEFINITION = {
36
40
  name: "codex-translator",
37
41
  label: "Codex Translator",
@@ -43,9 +47,9 @@ export const CODEX_ROLE_DEFINITIONS = [
43
47
  ];
44
48
  export const ROLE_DEFINITIONS = [
45
49
  ...VCM_ROLE_DEFINITIONS,
46
- GATE_REVIEWER_ROLE_DEFINITION,
47
50
  ...CODEX_ROLE_DEFINITIONS
48
51
  ];
52
+ export const CORE_VCM_ROLE_NAMES = CORE_VCM_ROLE_DEFINITIONS.map((role) => role.name);
49
53
  export const VCM_ROLE_NAMES = VCM_ROLE_DEFINITIONS.map((role) => role.name);
50
54
  export const CODEX_ROLE_NAMES = CODEX_ROLE_DEFINITIONS.map((role) => role.name);
51
55
  export const ROLE_NAMES = ROLE_DEFINITIONS.map((role) => role.name);