multi-agents-cli 1.0.90 → 1.0.92

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.
@@ -1143,6 +1143,122 @@ const main = async () => {
1143
1143
  }
1144
1144
  }
1145
1145
 
1146
+
1147
+ // ── Backend simultaneous flow (client/LOGIC only, separate backend, first run) ──
1148
+ let backendLaunchTiming = null;
1149
+ const isSimultaneousCandidate =
1150
+ project === 'client' &&
1151
+ agent === 'LOGIC' &&
1152
+ config.backend?.type === 'separate' &&
1153
+ !argAgent &&
1154
+ !buildEntries.some(e => e.scope === 'backend') &&
1155
+ !tracking?.backend?.INIT?.backendPromptShown;
1156
+
1157
+ if (isSimultaneousCandidate) {
1158
+ separator();
1159
+ console.log(`\n ${yellow('⚡ Backend not started yet')}\n`);
1160
+ console.log(` Your backend has not been scaffolded yet.`);
1161
+ console.log(` Since client/LOGIC establishes integration contracts, this is the ideal moment to plan backend scaffolding.\n`);
1162
+
1163
+ const intentIdx = await arrowSelect('Would you like to include backend/INIT?', [
1164
+ { label: `${green('→')} Yes — I want to scaffold the backend` },
1165
+ { label: `${dim('→')} No — continue with client/LOGIC only` },
1166
+ ], rl);
1167
+
1168
+ if (intentIdx === 0) {
1169
+ console.log('');
1170
+ const timingIdx = await arrowSelect('When would you like to scaffold backend/INIT?', [
1171
+ { label: `${green('→')} Now — open backend/INIT workspace alongside this LOGIC session\n ${dim('A second IDE window will open. Both agents run in parallel.')}` },
1172
+ { label: `${dim('→')} After — launch backend/INIT when LOGIC completes\n ${dim('complete.js will prompt you immediately after merge.')}` },
1173
+ { label: `${dim('→')} Skip — changed my mind, continue with client/LOGIC only` },
1174
+ ], rl);
1175
+
1176
+ if (timingIdx === 0) backendLaunchTiming = 'now';
1177
+ else if (timingIdx === 1) backendLaunchTiming = 'after';
1178
+ else backendLaunchTiming = 'skip';
1179
+ } else {
1180
+ backendLaunchTiming = 'skip';
1181
+ }
1182
+
1183
+ // Write flag to backend/INIT tracking slot — prevents prompt from showing again
1184
+ guards.updateTrackingSlot(tracking, 'backend', 'INIT', {
1185
+ backendPromptShown: true,
1186
+ backendLaunchTiming,
1187
+ }, ROOT);
1188
+
1189
+ // Inject backend coordination block into TASK.md contextSection
1190
+ if (backendLaunchTiming === 'now') {
1191
+ contextSection += `\n---\n\n## Backend Coordination\n\nBackend/INIT is running in parallel in a separate workspace.\nEstablish CONTRACTS.md entries early — the backend agent will consume them.\nDo not wait for backend confirmation. Work autonomously on client scope.\n`;
1192
+ } else if (backendLaunchTiming === 'after') {
1193
+ contextSection += `\n---\n\n## Backend Coordination\n\nBackend/INIT will launch after this LOGIC session completes.\nBe deliberate about API contracts — document all integration points in CONTRACTS.md.\nThe backend agent will use these as its starting reference.\n`;
1194
+ }
1195
+
1196
+ // If Now — create backend/INIT worktree immediately
1197
+ if (backendLaunchTiming === 'now') {
1198
+ const beTimestamp = Date.now();
1199
+ const beBranchName = `agent/backend/init/${beTimestamp}`;
1200
+ const beWorktreeName = `${config.projectName.toLowerCase().replace(/\s+/g, '-')}-backend-init-${beTimestamp}`;
1201
+ const beWorktreePath = path.join(ROOT, 'worktrees', beWorktreeName);
1202
+
1203
+ console.log(`\n ${dim('Setting up backend/INIT workspace...')}\n`);
1204
+
1205
+ try {
1206
+ execSync(`git worktree add "${beWorktreePath}" -b ${beBranchName}`, { cwd: ROOT, stdio: 'pipe' });
1207
+
1208
+ // Framework files
1209
+ const beScope = generateClaudeScope({ project: 'backend', agent: 'INIT', branchName: beBranchName, worktreePath: beWorktreePath });
1210
+ fs.writeFileSync(path.join(beWorktreePath, '.claude-scope'), beScope, 'utf8');
1211
+
1212
+ const beTask = AGENT_DESCRIPTIONS.backend?.INIT || 'scaffolds backend architecture, folder structure, DB setup, wiring config and contracts';
1213
+ const beTaskMd = generateTaskMd({ project: 'backend', agent: 'INIT', task: beTask, branchName: beBranchName, contextSection: '', remoteSetupSection: '' });
1214
+ fs.writeFileSync(path.join(beWorktreePath, 'TASK.md'), beTaskMd, 'utf8');
1215
+
1216
+ const bePkg = {
1217
+ name: `${config.projectName.toLowerCase().replace(/\s+/g, '-')}-worktree`,
1218
+ version: '1.0.0', private: true,
1219
+ scripts: {
1220
+ init: 'multi-agents init',
1221
+ agent: `node "${ROOT}/.workflow/run.js"`,
1222
+ restart: `node "${ROOT}/.workflow/restart.js"`,
1223
+ reset: `node "${ROOT}/.workflow/reset.js"`,
1224
+ complete: `node "${ROOT}/.workflow/complete.js"`,
1225
+ },
1226
+ };
1227
+ fs.writeFileSync(path.join(beWorktreePath, 'package.json'), JSON.stringify(bePkg, null, 2), 'utf8');
1228
+
1229
+ const beGitignore = ['# Framework files — never commit these to the agent branch', 'package.json', '.claude-scope', 'scope.json', 'TASK.md', '.vscode/', '.idea/', '.zed/', 'node_modules/'].join('\n') + '\n';
1230
+ fs.writeFileSync(path.join(beWorktreePath, '.gitignore'), beGitignore, 'utf8');
1231
+
1232
+ // Tracking
1233
+ guards.updateTrackingSlot(tracking, 'backend', 'INIT', {
1234
+ branch: beBranchName,
1235
+ timestamp: beTimestamp,
1236
+ launchedAt: new Date().toISOString(),
1237
+ status: 'ACTIVE',
1238
+ worktreePath: beWorktreePath,
1239
+ backendPromptShown: true,
1240
+ backendLaunchTiming: 'now',
1241
+ }, ROOT);
1242
+
1243
+ // TASKS_HISTORY
1244
+ tasksHistory.ensureHistoryFile(ROOT);
1245
+ tasksHistory.writeSessionEntry(ROOT, { scope: 'backend', agent: 'INIT', branch: beBranchName, task: beTask, launchedAt: new Date().toISOString() });
1246
+
1247
+ console.log(` ${green('✓')} Backend/INIT worktree created: worktrees/${beWorktreeName}`);
1248
+
1249
+ // Open backend IDE window
1250
+ const beIdeOpened = openIDE(beWorktreePath);
1251
+ if (!beIdeOpened) console.log(` ${yellow('!')} Could not open IDE for backend — open manually at: ${dim(beWorktreePath)}`);
1252
+ console.log(` ${green('✓')} Backend/INIT workspace open — start a Claude Code session there when ready\n`);
1253
+
1254
+ } catch (e) {
1255
+ console.log(` ${yellow('⚠')} Could not create backend/INIT worktree: ${e.message}`);
1256
+ }
1257
+ }
1258
+
1259
+ separator();
1260
+ }
1261
+
1146
1262
  separator();
1147
1263
 
1148
1264
  // ── Confirm ───────────────────────────────────────────────────────────────────
@@ -448,6 +448,47 @@ const main = async () => {
448
448
  separator();
449
449
  console.log('');
450
450
 
451
+
452
+ // ── Backend/INIT launch prompt (if user chose 'after' during LOGIC session) ──
453
+ try {
454
+ const _tracking = guards.loadTracking(ROOT, config);
455
+ const beSlot = _tracking?.backend?.INIT;
456
+ if (
457
+ _scope === 'logic' &&
458
+ _parts[0] === 'agent' && _parts[1] === 'client' &&
459
+ beSlot?.backendLaunchTiming === 'after' &&
460
+ beSlot?.status !== 'ACTIVE' &&
461
+ beSlot?.status !== 'COMPLETED'
462
+ ) {
463
+ separator();
464
+ console.log(`\n ${yellow('⚡ Ready to scaffold your backend?')}\n`);
465
+ console.log(` client/LOGIC is merged. This is the ideal moment to launch backend/INIT.\n`);
466
+
467
+ const { spawn: _spawn } = require('child_process');
468
+ const launchIdx = await new Promise(resolve => {
469
+ rl2 = readline.createInterface({ input: process.stdin, output: process.stdout });
470
+ const choices = [
471
+ '1. Launch backend/INIT now ← recommended',
472
+ '2. Skip — I will handle it manually',
473
+ ];
474
+ choices.forEach(c => console.log(` ${c}`));
475
+ rl2.question('\n Select (1-2): ', ans => {
476
+ rl2.close();
477
+ resolve(parseInt(ans));
478
+ });
479
+ });
480
+
481
+ if (launchIdx === 1) {
482
+ console.log(`\n ${green('✓')} Launching backend/INIT...\n`);
483
+ rl.close();
484
+ _spawn('node', [path.join(ROOT, '.workflow', 'agent.js'), '--scope=backend', '--agent=INIT'], {
485
+ cwd: ROOT, stdio: 'inherit',
486
+ });
487
+ return;
488
+ }
489
+ }
490
+ } catch { /* best-effort */ }
491
+
451
492
  rl.close();
452
493
  };
453
494
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multi-agents-cli",
3
- "version": "1.0.90",
3
+ "version": "1.0.92",
4
4
  "description": "Multi-agent workflow orchestration for Claude Code — isolated git worktrees, structured state tracking, autonomous task chaining",
5
5
  "keywords": [
6
6
  "claude-code",