kaizen-agent 1.6.6 → 1.6.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 (2) hide show
  1. package/cli/install.ts +23 -4
  2. package/package.json +1 -1
package/cli/install.ts CHANGED
@@ -218,10 +218,16 @@ if (wantWeb) {
218
218
  const alive = async () => { try { await fetch(url); return true; } catch { return false; } };
219
219
 
220
220
  if (args.has("--stop")) {
221
- const pid = existsSync(pidFile) ? Number(readFileSync(pidFile, "utf8")) : NaN;
222
- if (!pid) { console.log(" no kaizen web daemon recorded"); process.exit(0); }
223
- try { process.kill(pid, "SIGTERM"); console.log(` stopped kaizen web (pid ${pid})`); }
224
- catch { console.log(` pid ${pid} already gone; cleared the stale record`); }
221
+ // The pid file only knows a --daemon; a board started from the shortcut or a
222
+ // terminal has none, so also ask the OS what listens on the port.
223
+ const recorded = existsSync(pidFile) ? Number(readFileSync(pidFile, "utf8")) : NaN;
224
+ const listening = await pidOnPort(port ?? 7420);
225
+ const pids = [...new Set([recorded, listening].filter((p): p is number => Number.isFinite(p) && p > 0))];
226
+ if (!pids.length) { console.log(" nothing running on the kaizen web port"); process.exit(0); }
227
+ for (const pid of pids) {
228
+ try { process.kill(pid, "SIGTERM"); console.log(` stopped kaizen web (pid ${pid})`); }
229
+ catch { console.log(` pid ${pid} already gone`); }
230
+ }
225
231
  rmSync(pidFile, { force: true });
226
232
  process.exit(0);
227
233
  }
@@ -791,6 +797,19 @@ if (blocked) process.exit(1);
791
797
 
792
798
  // ---------------------------------------------------------------- helpers
793
799
 
800
+ // Whoever holds the board's port, by the OS's own accounting.
801
+ async function pidOnPort(port: number): Promise<number | null> {
802
+ try {
803
+ if (process.platform === "win32") {
804
+ const out = await Bun.$`netstat -ano -p tcp`.text();
805
+ const m = new RegExp(`127\\.0\\.0\\.1:${port}\\s+\\S+\\s+LISTENING\\s+(\\d+)`).exec(out);
806
+ return m ? Number(m[1]) : null;
807
+ }
808
+ const out = await Bun.$`lsof -t -iTCP:${port} -sTCP:LISTEN`.quiet().nothrow().text();
809
+ return Number(out.trim().split("\n")[0]) || null;
810
+ } catch { return null; }
811
+ }
812
+
794
813
  function step(msg: string) { console.log(` ${c.green("+")} ${msg}`); }
795
814
 
796
815
  // Runs the upgrade and reports what it actually did, version to version, so the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "Staged workflow for AI agents — code, writing, research, operations: plan, human approval, build, independent review, bounded fix loop.",
5
5
  "type": "module",
6
6
  "bin": {