@yemi33/minions 0.1.1759 → 0.1.1761

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.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.1759 (2026-05-07)
3
+ ## 0.1.1761 (2026-05-07)
4
4
 
5
5
  ### Fixes
6
- - isolate meeting tests, kill rename-live-dir antipattern (#2142)
7
- - honor no-op completions in PR attachment contract (#2141)
6
+ - kill engine PID only, not its tree, to preserve in-flight agents
7
+
8
+ ## 0.1.1760 (2026-05-07)
9
+
10
+ ### Fixes
11
+ - reliable engine kill + visible restart output
8
12
 
9
13
  ## 0.1.1757 (2026-05-06)
10
14
 
package/bin/minions.js CHANGED
@@ -46,6 +46,36 @@ function killByPort(port) {
46
46
  } catch {}
47
47
  }
48
48
 
49
+ /**
50
+ * Read the engine's recorded PID from engine/control.json. Returns null if
51
+ * the file is missing/corrupt or the PID isn't a positive integer.
52
+ */
53
+ function readEnginePid(minionsHome) {
54
+ try {
55
+ const data = JSON.parse(fs.readFileSync(path.join(minionsHome, 'engine', 'control.json'), 'utf8'));
56
+ const pid = Number(data && data.pid);
57
+ return Number.isInteger(pid) && pid > 0 ? pid : null;
58
+ } catch { return null; }
59
+ }
60
+
61
+ /**
62
+ * Force-kill a single process by PID — does NOT recurse into children.
63
+ * This preserves the engine→agent invariant: agents are independent processes
64
+ * spawned as children of the engine, but they must survive engine restarts so
65
+ * they can be re-attached on next start (CLAUDE.md timeouts/liveness section).
66
+ * Tree-kill (`taskkill /T`, `pgrep -P` walk) would orphan in-flight work.
67
+ */
68
+ function killPidOnly(pid) {
69
+ if (!pid || pid === process.pid) return;
70
+ try {
71
+ if (process.platform === 'win32') {
72
+ execSync(`taskkill /F /PID ${pid}`, { stdio: 'ignore', timeout: 5000, windowsHide: true });
73
+ } else {
74
+ try { process.kill(pid, 'SIGKILL'); } catch {}
75
+ }
76
+ } catch {}
77
+ }
78
+
49
79
  /** Kill minions processes by command-line pattern matching (wmic on Windows, pkill on Unix). */
50
80
  function killMinionsProcesses(patterns) {
51
81
  try {
@@ -330,14 +360,12 @@ function init() {
330
360
  printPreflight(results, { label: 'Preflight checks' });
331
361
  } catch {}
332
362
 
333
- if (isUpgrade && skipStart) {
334
- console.log(`\n Upgrade complete (${pkgVersion}). Restart skipped by caller.\n`);
335
- return;
336
- }
363
+ // Update flow passes --skip-start so it can perform a single visible restart afterwards.
364
+ if (isUpgrade && skipStart) return;
337
365
 
338
366
  // Auto-start on fresh install; direct force-upgrade restarts automatically.
339
367
  if (isUpgrade) {
340
- try { execSync(`node "${path.join(MINIONS_HOME, 'engine.js')}" stop`, { stdio: 'ignore', cwd: MINIONS_HOME }); } catch {}
368
+ try { execSync(`node "${path.join(MINIONS_HOME, 'engine.js')}" stop`, { stdio: 'ignore', cwd: MINIONS_HOME, timeout: 10000, windowsHide: true }); } catch {}
341
369
  }
342
370
  console.log(isUpgrade
343
371
  ? `\n Upgrade complete (${pkgVersion}). Restarting engine and dashboard...\n`
@@ -422,11 +450,6 @@ function showChangelog(fromVersion) {
422
450
  console.log(` cat ${changelogPath}\n`);
423
451
  }
424
452
 
425
- function writeCommandOutput(stream, output) {
426
- if (!output) return;
427
- stream.write(Buffer.isBuffer(output) ? output.toString('utf8') : String(output));
428
- }
429
-
430
453
  function formatPackageCliCommand(args) {
431
454
  const initScript = path.join(PKG_ROOT, 'bin', 'minions.js');
432
455
  return `node "${initScript}" ${args.join(' ')}`;
@@ -434,17 +457,13 @@ function formatPackageCliCommand(args) {
434
457
 
435
458
  function runPackageCli(args, timeout) {
436
459
  const initScript = path.join(PKG_ROOT, 'bin', 'minions.js');
437
- const result = spawnSync(process.execPath, [initScript, ...args], {
460
+ return spawnSync(process.execPath, [initScript, ...args], {
438
461
  cwd: process.cwd(),
439
462
  env: { ...process.env, MINIONS_HOME },
440
- encoding: 'utf8',
463
+ stdio: 'inherit',
441
464
  timeout,
442
465
  windowsHide: true,
443
466
  });
444
-
445
- writeCommandOutput(process.stdout, result.stdout);
446
- writeCommandOutput(process.stderr, result.stderr);
447
- return result;
448
467
  }
449
468
 
450
469
  function runPostUpdateInit() {
@@ -615,10 +634,18 @@ if (!cmd || cmd === 'help' || cmd === '--help' || cmd === '-h') {
615
634
  // `--cli` / `--model` flags forward to `engine.js start` so the runtime
616
635
  // fleet flips before the daemon spawns (P-6b3f9c2e AC: works on restart).
617
636
  ensureInstalled();
618
- // Stop engine if running (graceful attempt)
619
- try { execSync(`node "${path.join(MINIONS_HOME, 'engine.js')}" stop`, { stdio: 'ignore', cwd: MINIONS_HOME }); } catch {}
620
- // Kill all existing engine/dashboard processes handles crashed engines and orphan dashboards
637
+ // Layered kill each step is best-effort, layered so the next still runs if
638
+ // one fails. Goal: the old engine is gone before we spawn a new one, even if
639
+ // PowerShell is unavailable, the engine is hung, or its cmdline doesn't match.
640
+ const oldEnginePid = readEnginePid(MINIONS_HOME);
641
+ // 1. Graceful stop — short timeout so a hung engine can't block what follows.
642
+ try { execSync(`node "${path.join(MINIONS_HOME, 'engine.js')}" stop`, { stdio: 'ignore', cwd: MINIONS_HOME, timeout: 10000, windowsHide: true }); } catch {}
643
+ // 2. Force-kill the recorded engine PID (NOT the tree — agent children must
644
+ // survive so the new engine can re-attach them via PID files).
645
+ killPidOnly(oldEnginePid);
646
+ // 3. Free dashboard port (catches orphan dashboards with no recorded PID).
621
647
  killByPort(7331);
648
+ // 4. Belt-and-suspenders cmdline match for anything still alive.
622
649
  killMinionsProcesses(['engine.js', 'dashboard.js']);
623
650
  const engineProc = spawn(process.execPath, [path.join(MINIONS_HOME, 'engine.js'), 'start', ...rest], {
624
651
  cwd: MINIONS_HOME, stdio: 'ignore', detached: true, windowsHide: true
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "runtime": "copilot",
3
3
  "models": null,
4
- "cachedAt": "2026-05-07T00:36:52.041Z"
4
+ "cachedAt": "2026-05-07T00:43:24.079Z"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yemi33/minions",
3
- "version": "0.1.1759",
3
+ "version": "0.1.1761",
4
4
  "description": "Multi-agent AI dev team that runs from ~/.minions/ — five autonomous agents share a single engine, dashboard, and knowledge base",
5
5
  "bin": {
6
6
  "minions": "bin/minions.js"