kaizen-agent 1.6.8 → 1.6.9

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/web.ts +15 -2
  2. package/package.json +1 -1
package/cli/web.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // `kaizen web`: the board in a browser. A loopback HTTP server over state.ts and
2
2
  // one HTML page; the page never sees the filesystem, only JSON.
3
- import { existsSync, readFileSync, readdirSync, statSync, watch, type FSWatcher } from "node:fs";
3
+ import { existsSync, readFileSync, readdirSync, statSync, watch, appendFileSync, type FSWatcher } from "node:fs";
4
4
  import { join, dirname } from "node:path";
5
5
  import {
6
6
  home, type Item, boardCards, knownProjects, remember, locate, label, tilde,
@@ -14,6 +14,17 @@ const DEFAULT_PORT = 7420;
14
14
  type Opts = { port?: number; open?: boolean };
15
15
 
16
16
  export async function web(repoDir: string, opts: Opts = {}) {
17
+ // A board started from the shortcut has no terminal to show a crash in, so any
18
+ // crash is written where it can be read afterwards.
19
+ const log = join(home, ".kaizen", "web.log");
20
+ for (const ev of ["uncaughtException", "unhandledRejection"] as const) {
21
+ process.on(ev, (err: unknown) => {
22
+ const line = `${new Date().toISOString()} ${ev}: ${err instanceof Error ? err.stack ?? err.message : String(err)}\n`;
23
+ try { appendFileSync(log, line); } catch { /* nowhere to write */ }
24
+ console.error(line);
25
+ if (ev === "uncaughtException") process.exit(1);
26
+ });
27
+ }
17
28
  const state = locate();
18
29
  if (state && dirname(state) !== home) remember(dirname(state));
19
30
  const project = state ? label(state) : null;
@@ -56,7 +67,9 @@ export async function web(repoDir: string, opts: Opts = {}) {
56
67
  for (const w of watchers) { try { w.close(); } catch { /* gone */ } }
57
68
  watchers.length = 0;
58
69
  for (const dir of states(true)) {
59
- try { watchers.push(watch(dir, { recursive: true }, changed)); } catch { /* poll covers it */ }
70
+ // An unhandled 'error' on a watcher (Windows: a watched dir renamed, EPERM on
71
+ // a locked file) would end the process; the poll covers what the watch misses.
72
+ try { watchers.push(watch(dir, { recursive: true }, changed).on("error", () => {})); } catch { /* poll covers it */ }
60
73
  }
61
74
  };
62
75
  watchAll();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
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": {