kaizen-agent 1.59.0 → 1.59.1
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/cli/docs.test.ts +3 -1
- package/cli/web.ts +29 -3
- package/package.json +1 -1
- package/web/board/panel.ts +4 -10
- package/web/board.js +8 -8
- package/web/notebook.js +1 -1
- package/web/term.js +1 -1
- package/web/video.js +1 -1
package/cli/docs.test.ts
CHANGED
|
@@ -15,8 +15,10 @@ const fixture = (updated = "2026-10-28") => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
test("clean vault, nested CLI invocation, and no writes", () => {
|
|
18
|
-
const f = fixture();
|
|
18
|
+
const f = fixture("2020-01-01");
|
|
19
19
|
try {
|
|
20
|
+
// A source written today would be stale against any fixed date: back-date it.
|
|
21
|
+
utimesSync(join(f.root, "app.ts"), new Date("2020-01-01T10:00:00"), new Date("2020-01-01T10:00:00"));
|
|
20
22
|
const nested = join(f.root, "inside"); mkdirSync(nested);
|
|
21
23
|
const before = readFileSync(join(f.vault, "App.md"));
|
|
22
24
|
const p = Bun.spawnSync([process.execPath, join(import.meta.dir, "install.ts"), "docs", "lint"], { cwd: nested });
|
package/cli/web.ts
CHANGED
|
@@ -226,7 +226,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
226
226
|
// works and a slow poll where it does not.
|
|
227
227
|
const clients = new Set<ReadableStreamDefaultController>();
|
|
228
228
|
// Shells the board started (POST /shell), by /pty key; dead ones drop on the next /shells.
|
|
229
|
-
const shells = new Map<string, { key: string; dir: string; title: string; agent: string; run: string }>();
|
|
229
|
+
const shells = new Map<string, { key: string; dir: string; title: string; agent: string; run: string; pid?: number }>();
|
|
230
230
|
const SHELL_CAP = 8;
|
|
231
231
|
let usageCache: Usage[] = [];
|
|
232
232
|
let usageAt = 0;
|
|
@@ -651,6 +651,14 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
651
651
|
// transcript-age check alone would miss it where there is no /proc.
|
|
652
652
|
const idx = runIndex(dir);
|
|
653
653
|
if (readSessions(dir).some((x) => ptyState(x.key)?.alive && ownerOf(dir, x, idx) === id)) return json({ live: true }, 409);
|
|
654
|
+
// Running in a board terminal (the Terminal page's shell, opened by another run or
|
|
655
|
+
// none): that terminal becomes this run's, so the run view shows it.
|
|
656
|
+
const host = [...shells.values()].find((x) => x.dir === dir && x.pid && ptyState(x.key)?.alive && shellHosts(x.pid, sid));
|
|
657
|
+
if (host) {
|
|
658
|
+
host.run = runKey;
|
|
659
|
+
changed();
|
|
660
|
+
return json(host);
|
|
661
|
+
}
|
|
654
662
|
if (sessionLive(sid)) return json({ live: true }, 409);
|
|
655
663
|
agent = "claude";
|
|
656
664
|
cmd = ["claude", "--resume", sid];
|
|
@@ -664,9 +672,9 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
664
672
|
if ([...shells.values()].filter((x) => x.dir === dir).length >= SHELL_CAP) return bad(`at most ${SHELL_CAP} terminals per project: close one first`, 429);
|
|
665
673
|
const key = "sh-" + crypto.randomUUID().slice(0, 8);
|
|
666
674
|
const title = agent ? KNOWN_AGENTS.find((k) => k.cmd === agent)!.name : "shell";
|
|
667
|
-
startPty(key, cmd, projectOf(dir), undefined, changed);
|
|
675
|
+
const pid = startPty(key, cmd, projectOf(dir), undefined, changed);
|
|
668
676
|
// The run workspace that opened it (its card key), so each run keeps its own centre.
|
|
669
|
-
shells.set(key, { key, dir, title, agent, run: runKey });
|
|
677
|
+
shells.set(key, { key, dir, title, agent, run: runKey, pid });
|
|
670
678
|
changed();
|
|
671
679
|
return json(shells.get(key));
|
|
672
680
|
}
|
|
@@ -1705,6 +1713,24 @@ export function sessionLive(id: string): boolean {
|
|
|
1705
1713
|
return false;
|
|
1706
1714
|
}
|
|
1707
1715
|
|
|
1716
|
+
// Whether Claude Code session `id` runs as process `root` or under it: Claude Code records
|
|
1717
|
+
// each running session as ~/.claude/sessions/<pid>.json; /proc gives the parent chain.
|
|
1718
|
+
// Linux only; elsewhere false, and the run view says the session runs elsewhere.
|
|
1719
|
+
export function shellHosts(root: number, id: string): boolean {
|
|
1720
|
+
try {
|
|
1721
|
+
for (const f of readdirSync(join(home, ".claude", "sessions"))) {
|
|
1722
|
+
if (!/^\d+\.json$/.test(f)) continue;
|
|
1723
|
+
let pid = Number(f.slice(0, -5));
|
|
1724
|
+
try { if (JSON.parse(readFileSync(join(home, ".claude", "sessions", f), "utf8")).sessionId !== id) continue; } catch { continue; }
|
|
1725
|
+
for (let i = 0; i < 20 && pid > 1; i++) {
|
|
1726
|
+
if (pid === root) return true;
|
|
1727
|
+
try { pid = Number(readFileSync(`/proc/${pid}/stat`, "utf8").replace(/^.*\) /, "").split(" ")[1]); } catch { break; }
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
} catch { /* no sessions folder or no /proc */ }
|
|
1731
|
+
return false;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1708
1734
|
export async function openApp(url: string, profile?: string) {
|
|
1709
1735
|
// Kaizen Bot's window (a profile) is always an app; the board asks the setting.
|
|
1710
1736
|
if (!profile) {
|
package/package.json
CHANGED
package/web/board/panel.ts
CHANGED
|
@@ -87,9 +87,6 @@ export function open(c, keepTab) {
|
|
|
87
87
|
if (!keepTab)
|
|
88
88
|
store.lastTab = store.tab =
|
|
89
89
|
c.status === "abandoned" ? "plan" : { 1: "plan", 2: "backlog", 3: "review", 4: "preview" }[c.column] || "request";
|
|
90
|
-
// A run its agent is working on in this board, while planning, building or reviewing, opens on that agent.
|
|
91
|
-
// Not in the run workspace: there the agent is a centre tab.
|
|
92
|
-
if (!keepTab && c.pty && c.pty.alive && c.column >= 1 && c.column <= 3 && view !== "run") store.tab = "term";
|
|
93
90
|
openRun(c, false);
|
|
94
91
|
}
|
|
95
92
|
// A building run's Backlog tab opens with its progress, above the deferred items. The
|
|
@@ -173,12 +170,9 @@ export async function openRun(c, refresh, again) {
|
|
|
173
170
|
? preview(store.runDoc.impl)
|
|
174
171
|
: store.runDoc[t[1]] || (t[1] === "backlog" && c.column === 2 && store.runDoc.progress)),
|
|
175
172
|
);
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
// In the run workspace the agent is a centre tab, so the panel never shows a terminal.
|
|
181
|
-
if (store.tab === "term" && (!c.pty || view === "run")) store.tab = store.lastTab;
|
|
173
|
+
if (store.wantTerm === key(c)) store.wantTerm = null;
|
|
174
|
+
// The agent is a centre tab of the run workspace only: the panel never shows a terminal.
|
|
175
|
+
if (store.tab === "term") store.tab = store.lastTab;
|
|
182
176
|
// In the run workspace Preview is a centre tab, so the panel never shows it.
|
|
183
177
|
if (view === "run" && store.tab === "preview") store.tab = "review";
|
|
184
178
|
// A tab not written yet falls back to the latest one that is.
|
|
@@ -187,7 +181,7 @@ export async function openRun(c, refresh, again) {
|
|
|
187
181
|
if (store.tab !== "term") store.lastTab = store.tab;
|
|
188
182
|
$("panel").classList.toggle("wide", store.tab === "term");
|
|
189
183
|
const pt = $("pterm");
|
|
190
|
-
pt.hidden =
|
|
184
|
+
pt.hidden = true;
|
|
191
185
|
pt.classList.toggle("on", store.tab === "term");
|
|
192
186
|
pt.setAttribute("aria-pressed", store.tab === "term");
|
|
193
187
|
pt.title = pt.ariaLabel = store.tab === "term" ? "Close terminal" : "Terminal";
|