kaizen-agent 1.62.0 → 1.64.0
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/automations.test.ts +167 -0
- package/cli/automations.ts +298 -0
- package/cli/dashboard.ts +1 -7
- package/cli/handoff.test.ts +133 -0
- package/cli/handoff.ts +122 -0
- package/cli/install.test.ts +16 -0
- package/cli/install.ts +92 -191
- package/cli/look.ts +33 -0
- package/cli/pty.ts +16 -2
- package/cli/resources.test.ts +50 -0
- package/cli/resources.ts +113 -0
- package/cli/restart.test.ts +28 -1
- package/cli/settings.ts +6 -2
- package/cli/setup.test.ts +22 -2
- package/cli/setup.ts +101 -51
- package/cli/sources.ts +1 -1
- package/cli/state.test.ts +7 -0
- package/cli/state.ts +13 -2
- package/cli/usage.test.ts +11 -0
- package/cli/web.ts +134 -6
- package/cli/workers.ts +11 -4
- package/cli/worktree.test.ts +174 -1
- package/cli/worktree.ts +190 -35
- package/package.json +1 -1
- package/skills/kaizen/config.default.yml +17 -0
- package/skills/kaizen/settings.md +4 -0
- package/skills/kaizen/spec-build.md +13 -0
- package/skills/kaizen/spec-main.md +13 -0
- package/skills/kaizen-help/SKILL.md +1 -0
- package/skills/media/kaizen-deck/SKILL.md +21 -2
- package/skills/media/kaizen-deck/scripts/motion.py +99 -0
- package/web/board/cards.ts +1 -0
- package/web/board/git.ts +4 -4
- package/web/board/phone.ts +5 -5
- package/web/board/resources.ts +152 -0
- package/web/board/run-view.ts +107 -1
- package/web/board/search.ts +6 -0
- package/web/board/settings-automations.ts +71 -0
- package/web/board/settings-pages.test.ts +4 -0
- package/web/board/settings-pages.ts +2 -1
- package/web/board/settings.ts +10 -3
- package/web/board/workspace.ts +7 -1
- package/web/board/ws-tabs.test.ts +20 -1
- package/web/board/ws-tabs.ts +26 -7
- package/web/board.html +20 -3
- package/web/board.js +119 -88
- package/web/notebook.js +23 -23
- package/web/notes.html +1 -0
- package/web/term.js +1 -1
- package/web/video.html +1 -0
- package/web/video.js +49 -49
package/web/board/git.ts
CHANGED
|
@@ -61,14 +61,14 @@ function steps(c) {
|
|
|
61
61
|
why: files
|
|
62
62
|
? "Commit changes first"
|
|
63
63
|
: b && !b.upstream
|
|
64
|
-
? "Not published yet: Create PR pushes it"
|
|
64
|
+
? b.local ? "Lands by local merge: kaizen worktree land" : "Not published yet: Create PR pushes it"
|
|
65
65
|
: g.ahead > 0
|
|
66
66
|
? ""
|
|
67
67
|
: "Nothing to push",
|
|
68
68
|
},
|
|
69
69
|
];
|
|
70
70
|
if (!b) return s;
|
|
71
|
-
const noGh = b.gh ? "" : "Needs the GitHub CLI (gh) and a GitHub remote";
|
|
71
|
+
const noGh = b.local ? "Lands by local merge: kaizen worktree land" : b.gh ? "" : "Needs the GitHub CLI (gh) and a GitHub remote";
|
|
72
72
|
const prWhy =
|
|
73
73
|
noGh ||
|
|
74
74
|
(files
|
|
@@ -134,7 +134,7 @@ export function gitTab(c, refresh) {
|
|
|
134
134
|
rows = g.rows || [],
|
|
135
135
|
staged = rows.filter((r) => r.staged),
|
|
136
136
|
unstaged = rows.filter((r) => !r.staged),
|
|
137
|
-
target = b ? `origin/${b.base}` : `${g.remote}/${g.branch || "HEAD"}`;
|
|
137
|
+
target = b ? (b.local ? b.base : `origin/${b.base}`) : `${g.remote}/${g.branch || "HEAD"}`;
|
|
138
138
|
if (u.msg === undefined) u.msg = commitMsg(store.runDoc.impl) || c.title || c.text || "";
|
|
139
139
|
u.shut = u.shut || {};
|
|
140
140
|
// The main button: Stage all while nothing is staged, Commit once something is, else the
|
|
@@ -223,7 +223,7 @@ export function gitTab(c, refresh) {
|
|
|
223
223
|
: u.ask === "remove"
|
|
224
224
|
? html`<div class="gsec gform">
|
|
225
225
|
<div class="ghd">Remove the worktree and delete ${b.branch}?</div>
|
|
226
|
-
<div class="dim">Its work is on ${b.base}. The branch is deleted here and on GitHub.</div>
|
|
226
|
+
<div class="dim">Its work is on ${b.base}. The branch is deleted here${b.local ? "" : " and on GitHub"}.</div>
|
|
227
227
|
<div class="row"><button class="btn ghost" data-a="cancel">Cancel</button><button class="btn danger" data-a="go-remove">Remove workspace</button></div>
|
|
228
228
|
</div>`
|
|
229
229
|
: "";
|
package/web/board/phone.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { runPopup } from "./cards.ts";
|
|
|
5
5
|
import { $, html, raw } from "./dom.ts";
|
|
6
6
|
import { cardHref, logo, railData, stateOf, subline, titleOf, usageChips, wsHref } from "./workspace.ts";
|
|
7
7
|
import { toast } from "./toast.ts";
|
|
8
|
-
import { agentStatus, wsKey, type Agent, type Status } from "./ws-tabs.ts";
|
|
8
|
+
import { agentStatus, wsKey, WORD, DOT, type Agent, type Status } from "./ws-tabs.ts";
|
|
9
9
|
|
|
10
10
|
export const isPhone = () => matchMedia("(max-width:640px)").matches;
|
|
11
11
|
|
|
@@ -31,9 +31,7 @@ function row(c, now: number) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// Home's slider: one card per workspace with an agent open, those asking first.
|
|
34
|
-
const
|
|
35
|
-
const DOT: Record<Status, string> = { asking: "wait", working: "build", done: "done" };
|
|
36
|
-
const RANK: Record<Status, number> = { asking: 0, working: 1, done: 2 };
|
|
34
|
+
const RANK: Record<Status, number> = { conflict: 0, failed: 0, asking: 1, working: 2, done: 3 };
|
|
37
35
|
const agentIco = (a: Agent) => {
|
|
38
36
|
const id = "i-" + (a.agent || "").toLowerCase();
|
|
39
37
|
return raw(`<svg class="pag-ico" aria-hidden="true"><use href="#${document.getElementById(id) ? id : "i-ai"}"/></svg>`);
|
|
@@ -54,7 +52,7 @@ function agentCards(now: number) {
|
|
|
54
52
|
const asking = groups.filter((g) => g.rows[0].st === "asking").length;
|
|
55
53
|
const cards = groups.map(({ k, rows }) => {
|
|
56
54
|
const { a, st } = rows[0];
|
|
57
|
-
return html`<button type="button" class="pag${st === "asking" ? " ask" : ""}" data-group="${k}"><span class="pag-st"><i class="si ${DOT[st]}"></i>${rows.length > 1 ? rows.length + " agents" : WORD[st]}<span class="pag-icos">${rows.map((r) => agentIco(r.a))}</span></span><span class="pag-ws">${wsName(a)}</span><small>${projName(a.dir)}</small></button>`;
|
|
55
|
+
return html`<button type="button" class="pag${st === "asking" || DOT[st] === "fail" ? " ask" : ""}" data-group="${k}"><span class="pag-st"><i class="si ${DOT[st]}"></i>${rows.length > 1 ? rows.length + " agents" : WORD[st]}<span class="pag-icos">${rows.map((r) => agentIco(r.a))}</span></span><span class="pag-ws">${wsName(a)}</span><small>${projName(a.dir)}</small></button>`;
|
|
58
56
|
});
|
|
59
57
|
return html`<section class="psec2"><div class="pag-h"><h3>Agents${asking ? html`<span class="pag-n">${asking} asking</span>` : ""}</h3><button type="button" class="pag-new">New</button></div>${groups.length ? html`<div class="pslide">${cards}</div>` : html`<p class="pnote">No agents running.</p>`}</section>`;
|
|
60
58
|
}
|
|
@@ -176,6 +174,8 @@ function haptic() {
|
|
|
176
174
|
tick = document.createElement("label");
|
|
177
175
|
tick.hidden = true;
|
|
178
176
|
tick.innerHTML = `<input type="checkbox" switch>`;
|
|
177
|
+
// This click is not the user's: a window listener would read it as a tap outside a sheet.
|
|
178
|
+
tick.onclick = (e) => e.stopPropagation();
|
|
179
179
|
document.body.append(tick);
|
|
180
180
|
}
|
|
181
181
|
tick.click();
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// The footer's resource monitor, left of the terminal button: memory, storage and every
|
|
2
|
+
// live terminal by workspace. Modelled on Orca's Resource Manager status segment.
|
|
3
|
+
import { $, html } from "./dom.ts";
|
|
4
|
+
|
|
5
|
+
const size = (n: number) => {
|
|
6
|
+
if (n < 1024 ** 2) return `${Math.round(n / 1024)} KB`;
|
|
7
|
+
if (n < 1024 ** 3) return `${Math.round(n / 1024 ** 2)} MB`;
|
|
8
|
+
return `${(n / 1024 ** 3).toFixed(1)} GB`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let res: any = null, disk: any = null, confirm = "", failed = "", timer: any = null;
|
|
12
|
+
|
|
13
|
+
// Recent memory use, kept in this page only: it starts empty on each load.
|
|
14
|
+
const history: number[] = [];
|
|
15
|
+
let diskOpen = false;
|
|
16
|
+
try { diskOpen = localStorage.getItem("kz-res-disk") === "1"; } catch {}
|
|
17
|
+
|
|
18
|
+
// The largest rows, the rest folded into one, so the bar stays readable.
|
|
19
|
+
const top = (rows: any[]) => {
|
|
20
|
+
const head = rows.slice(0, 4).map((r) => [r.name, r.bytes] as [string, number]), left = rows.slice(4).reduce((n, r) => n + r.bytes, 0);
|
|
21
|
+
return left ? [...head, ["Other", left] as [string, number]] : head;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// A segmented bar with its legend beside the values, so identity is never colour alone.
|
|
25
|
+
const split = (parts: [string, number][], rows = true) => {
|
|
26
|
+
const sum = parts.reduce((n, p) => n + p[1], 0) || 1;
|
|
27
|
+
return html`<div class="rseg">${parts.map(([n, v], i) => html`<i class="s${i}" style="flex:${v} 0 2px" title="${n}: ${size(v)}"></i>`)}</div>
|
|
28
|
+
${rows && parts.map(([n, v], i) => html`<div class="rsrow"><span><u class="s${i}"></u>${n}</span><em>${Math.round((v / sum) * 100)}%</em><b>${size(v)}</b></div>`)}`;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function spark() {
|
|
32
|
+
if (history.length < 2) return "";
|
|
33
|
+
const x = (i: number) => (i / (history.length - 1)) * 100, y = (v: number) => 36 - v * 0.34;
|
|
34
|
+
const line = history.map((v, i) => `${x(i).toFixed(1)},${y(v).toFixed(1)}`).join(" ");
|
|
35
|
+
return html`<svg class="rspark" viewBox="0 0 100 36" preserveAspectRatio="none" role="img" aria-label="Memory use over recent minutes"><polygon points="0,36 ${line} 100,36"></polygon><polyline points="${line}" vector-effect="non-scaling-stroke"></polyline></svg>`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const pop = () => document.getElementById("respop");
|
|
39
|
+
|
|
40
|
+
function draw() {
|
|
41
|
+
const box = pop();
|
|
42
|
+
if (!box || !res) return;
|
|
43
|
+
const pct = Math.round((res.system.used / res.system.total) * 100);
|
|
44
|
+
const groups = new Map<string, any[]>();
|
|
45
|
+
for (const t of res.terminals) {
|
|
46
|
+
const g = `${t.project || "Other"} / ${t.ws.split(/[\\/]/).pop() || "main"}`;
|
|
47
|
+
(groups.get(g) ?? groups.set(g, []).get(g)!).push(t);
|
|
48
|
+
}
|
|
49
|
+
const row = (t: any) => html`<div class="rsrow"><span title="${t.title}">${t.title}</span><b>${t.rss == null ? "–" : size(t.rss)}</b>${
|
|
50
|
+
confirm === t.key
|
|
51
|
+
? html`<button type="button" data-keep>Keep</button><button type="button" class="yes" data-kill="${t.key}">Kill</button>`
|
|
52
|
+
: html`${t.dir ? html`<button type="button" data-open="${t.key}">Open</button>` : ""}<button type="button" class="kill" data-ask="${t.key}" aria-label="Kill ${t.title}">Kill</button>`
|
|
53
|
+
}</div>`;
|
|
54
|
+
const other = Math.max(0, res.system.used - res.kaizen), free = Math.max(0, res.system.total - res.system.used);
|
|
55
|
+
const mem = html`
|
|
56
|
+
<h3>Memory</h3>
|
|
57
|
+
<div class="rhero"><b>${pct}%</b><span>${size(res.system.used)} of ${size(res.system.total)} used</span></div>
|
|
58
|
+
${spark()}
|
|
59
|
+
${split([["Kaizen and its terminals", res.kaizen], ["Other apps", other], ["Free", free]])}`;
|
|
60
|
+
const rest = html`
|
|
61
|
+
<h3><button type="button" class="rfold" data-fold aria-expanded="${diskOpen}"><span>${diskOpen ? "▾" : "▸"}</span> Storage</button><button type="button" data-rescan>${disk?.scanning ? "Scanning…" : "Rescan"}</button></h3>
|
|
62
|
+
${disk?.at ? html`<div class="rhero"><b>${size(disk.total)}</b><span>used by kaizen</span></div>${split(top(disk.rows), diskOpen)}` : html`<div class="rnote">Scanning…</div>`}
|
|
63
|
+
<h3>Terminals (${res.terminals.length})</h3>
|
|
64
|
+
${failed ? html`<div class="rnote" role="alert">${failed}</div>` : ""}
|
|
65
|
+
${res.terminals.length ? [...groups].map(([g, ts]) => html`<div class="rgrp">${g}</div>${ts.map(row)}`) : html`<div class="rnote">No live terminals.</div>`}`;
|
|
66
|
+
// Memory changes on every poll; the rest stays put, or a row's button would lose focus.
|
|
67
|
+
for (const [id, m] of [["resm", mem], ["resr", rest]] as const) {
|
|
68
|
+
let el = document.getElementById(id);
|
|
69
|
+
if (!el) { el = document.createElement("div"); el.id = id; box.append(el); }
|
|
70
|
+
const text = String(m);
|
|
71
|
+
if (el.dataset.was !== text) { el.dataset.was = text; el.innerHTML = text; }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function load() {
|
|
76
|
+
try {
|
|
77
|
+
res = await (await fetch("/resources")).json();
|
|
78
|
+
history.push((res.system.used / res.system.total) * 100);
|
|
79
|
+
if (history.length > 60) history.shift();
|
|
80
|
+
const b = $("res");
|
|
81
|
+
b.querySelector("span").textContent = size(res.kaizen);
|
|
82
|
+
b.title = `Kaizen uses ${size(res.kaizen)} of memory`;
|
|
83
|
+
draw();
|
|
84
|
+
} catch { /* board restarting */ }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function loadDisk(refresh = false) {
|
|
88
|
+
try {
|
|
89
|
+
disk = await (await fetch("/resources/storage" + (refresh ? "?refresh=1" : ""))).json();
|
|
90
|
+
draw();
|
|
91
|
+
} catch { /* board restarting */ }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function close() {
|
|
95
|
+
pop()?.remove();
|
|
96
|
+
confirm = failed = "";
|
|
97
|
+
$("res").setAttribute("aria-expanded", "false");
|
|
98
|
+
clearInterval(timer);
|
|
99
|
+
timer = setInterval(load, 15_000);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function open() {
|
|
103
|
+
const box = document.createElement("div");
|
|
104
|
+
box.id = "respop";
|
|
105
|
+
box.setAttribute("role", "dialog");
|
|
106
|
+
box.setAttribute("aria-label", "Resources");
|
|
107
|
+
document.body.append(box);
|
|
108
|
+
$("res").setAttribute("aria-expanded", "true");
|
|
109
|
+
box.onclick = (e) => void click(e);
|
|
110
|
+
draw();
|
|
111
|
+
void load();
|
|
112
|
+
void loadDisk();
|
|
113
|
+
clearInterval(timer);
|
|
114
|
+
timer = setInterval(() => { void load(); if (disk?.scanning || !disk?.at) void loadDisk(); }, 3000);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function click(e: MouseEvent) {
|
|
118
|
+
const b = (e.target as HTMLElement).closest("button");
|
|
119
|
+
if (!b) return;
|
|
120
|
+
const d = b.dataset;
|
|
121
|
+
if ("fold" in d) {
|
|
122
|
+
diskOpen = !diskOpen;
|
|
123
|
+
try { localStorage.setItem("kz-res-disk", diskOpen ? "1" : "0"); } catch {}
|
|
124
|
+
return draw();
|
|
125
|
+
}
|
|
126
|
+
if ("rescan" in d) return void loadDisk(true);
|
|
127
|
+
if ("keep" in d) { confirm = ""; return draw(); }
|
|
128
|
+
if (d.ask) { confirm = d.ask; failed = ""; return draw(); }
|
|
129
|
+
if (d.open) {
|
|
130
|
+
const t = res.terminals.find((x: any) => x.key === d.open);
|
|
131
|
+
if (!t) return;
|
|
132
|
+
close();
|
|
133
|
+
if (dispatchEvent(new CustomEvent("kz-open-term", { cancelable: true, detail: { dir: t.dir, ws: t.ws, key: t.key } }))) location.href = `/?view=ws&dir=${encodeURIComponent(t.dir)}&ws=${encodeURIComponent(t.ws)}`;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (d.kill) {
|
|
137
|
+
confirm = "";
|
|
138
|
+
const r = await fetch("/pty/kill", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ key: d.kill }) }).catch(() => null);
|
|
139
|
+
failed = r?.ok ? "" : "Could not kill that terminal.";
|
|
140
|
+
await load();
|
|
141
|
+
draw();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function initResources() {
|
|
146
|
+
const b = $("res");
|
|
147
|
+
b.onclick = () => (pop() ? close() : open());
|
|
148
|
+
addEventListener("pointerdown", (e) => { if (pop() && !(e.target as Element).closest("#respop,#res")) close(); });
|
|
149
|
+
addEventListener("keydown", (e) => { if (e.key === "Escape" && pop()) close(); });
|
|
150
|
+
void load();
|
|
151
|
+
timer = setInterval(load, 15_000);
|
|
152
|
+
}
|
package/web/board/run-view.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { load, post } from "./api.ts";
|
|
|
19
19
|
import { attach, md, preview } from "./markdown.ts";
|
|
20
20
|
import { layout } from "./terms.ts";
|
|
21
21
|
import { cardHref, markCurrent, railData, stateOf, titleOf, wsHref, wsOfCard } from "./workspace.ts";
|
|
22
|
-
import { type Node, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, newRun, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
22
|
+
import { type Node, type Box, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, nearestPane, newRun, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
23
23
|
import { drawPick, hidePick, initPick, setOpen } from "./run-pick.ts";
|
|
24
24
|
import { age } from "./labels.ts";
|
|
25
25
|
import { go } from "./views.ts";
|
|
@@ -903,7 +903,113 @@ function initSheet() {
|
|
|
903
903
|
addEventListener("click", (e) => on() && !e.composedPath().some((n) => (n as Element).matches?.("#panel,#rside,dialog,.toast")) && shut());
|
|
904
904
|
}
|
|
905
905
|
|
|
906
|
+
// The keyboard, tmux style: Ctrl+Space puts focus in the current pane, then one more key
|
|
907
|
+
// moves it: arrows or hjkl between panes, 1-9, n, p between tabs.
|
|
908
|
+
const focusPane = (id?: string) => {
|
|
909
|
+
const el = id ? panes.get(id)?.el : null;
|
|
910
|
+
requestAnimationFrame(() => el?.querySelector<HTMLElement>("textarea,input,iframe")?.focus());
|
|
911
|
+
};
|
|
912
|
+
const setPane = (sc: Screen, id: string) => {
|
|
913
|
+
sc.focus = id;
|
|
914
|
+
save();
|
|
915
|
+
draw();
|
|
916
|
+
focusPane(id);
|
|
917
|
+
};
|
|
918
|
+
const DIRS = { ArrowLeft: "l", h: "l", ArrowRight: "r", l: "r", ArrowUp: "u", k: "u", ArrowDown: "d", j: "d" } as const;
|
|
919
|
+
function paneKey(k: string) {
|
|
920
|
+
if (k === "?") {
|
|
921
|
+
(document.activeElement as HTMLElement)?.blur(); // Escape closes it only from outside the terminal
|
|
922
|
+
return void $("help").classList.add("on");
|
|
923
|
+
}
|
|
924
|
+
if (k === "x") {
|
|
925
|
+
const sc = screens().find((x) => x.id === saved().on);
|
|
926
|
+
if (sc) void closeTab(sc.focus).then(() => focusPane(screens().find((x) => x.id === saved().on)?.focus));
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
const mode = { c: "tab", r: "cols", d: "rows" }[k];
|
|
930
|
+
if (mode) {
|
|
931
|
+
const add = $("rtabs").querySelector<HTMLDetailsElement>(`.radd[data-mode=${mode}]`);
|
|
932
|
+
if (add) add.open = true;
|
|
933
|
+
requestAnimationFrame(() => add?.querySelector<HTMLElement>(".menu-pop button")?.focus());
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
const s = saved(),
|
|
937
|
+
scs = screens(),
|
|
938
|
+
at = scs.findIndex((x) => x.id === s.on),
|
|
939
|
+
sc = scs[at];
|
|
940
|
+
if (!sc) return;
|
|
941
|
+
if (DIRS[k]) {
|
|
942
|
+
const boxes: Record<string, Box> = {};
|
|
943
|
+
for (const id of leaves(sc.tree)) {
|
|
944
|
+
const el = panes.get(id)?.el;
|
|
945
|
+
if (el) boxes[id] = el.getBoundingClientRect();
|
|
946
|
+
}
|
|
947
|
+
const to = nearestPane(boxes, sc.focus, DIRS[k]);
|
|
948
|
+
if (to) setPane(sc, to);
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const i = k === "n" ? (at + 1) % scs.length : k === "p" ? (at - 1 + scs.length) % scs.length : /^[1-9]$/.test(k) ? +k - 1 : -1;
|
|
952
|
+
const to = scs[i];
|
|
953
|
+
if (!to) return;
|
|
954
|
+
s.on = to.id;
|
|
955
|
+
save();
|
|
956
|
+
draw();
|
|
957
|
+
focusPane(to.focus);
|
|
958
|
+
}
|
|
959
|
+
// While the prefix waits for its key, a chip says so and lists the keys.
|
|
960
|
+
function keyHint(on: boolean) {
|
|
961
|
+
document.getElementById("keyhint")?.remove();
|
|
962
|
+
if (!on) return;
|
|
963
|
+
const h = document.createElement("div");
|
|
964
|
+
h.id = "keyhint";
|
|
965
|
+
h.setAttribute("role", "status");
|
|
966
|
+
const keys = [["←↓↑→", "pane"], ["1-9", "tab"], ["n p", "next, prev"], ["c", "new tab"], ["r", "split right"], ["d", "split down"], ["x", "close pane"], ["?", "all keys"]];
|
|
967
|
+
h.innerHTML = String(html`${keys.map(([k, t]) => html`<span><kbd>${k}</kbd>${t}</span>`)}`);
|
|
968
|
+
document.body.append(h);
|
|
969
|
+
}
|
|
970
|
+
function initPaneKeys() {
|
|
971
|
+
let armed: Timer | undefined;
|
|
972
|
+
// Capture: xterm must not see these. Ctrl+B would reach an agent or a tmux inside the pane.
|
|
973
|
+
addEventListener(
|
|
974
|
+
"keydown",
|
|
975
|
+
(e) => {
|
|
976
|
+
if (!ctx || !document.body.classList.contains("runv") || document.querySelector("dialog[open]")) return;
|
|
977
|
+
if (e.ctrlKey && !e.shiftKey && e.code === "Space") {
|
|
978
|
+
e.preventDefault();
|
|
979
|
+
e.stopPropagation();
|
|
980
|
+
focusPane(screens().find((x) => x.id === saved().on)?.focus);
|
|
981
|
+
clearTimeout(armed);
|
|
982
|
+
keyHint(true);
|
|
983
|
+
armed = setTimeout(() => ((armed = undefined), keyHint(false)), 2000);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
// The open +, split right or split down menu: arrows or j k walk it, Enter picks, Escape closes.
|
|
987
|
+
const add = $("rtabs").querySelector<HTMLDetailsElement>(".radd[open]");
|
|
988
|
+
if (add) {
|
|
989
|
+
const step = { ArrowDown: 1, j: 1, ArrowUp: -1, k: -1 }[e.key];
|
|
990
|
+
if (step || e.key === "Escape") {
|
|
991
|
+
e.preventDefault();
|
|
992
|
+
e.stopPropagation();
|
|
993
|
+
if (!step) return void ((add.open = false), focusPane(screens().find((x) => x.id === saved().on)?.focus));
|
|
994
|
+
const items = [...add.querySelectorAll<HTMLElement>(".menu-pop button")];
|
|
995
|
+
items[(items.indexOf(document.activeElement as HTMLElement) + step + items.length) % items.length]?.focus();
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
if (!armed || ["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
|
|
1000
|
+
e.preventDefault();
|
|
1001
|
+
e.stopPropagation();
|
|
1002
|
+
clearTimeout(armed);
|
|
1003
|
+
armed = undefined;
|
|
1004
|
+
keyHint(false);
|
|
1005
|
+
paneKey(e.key);
|
|
1006
|
+
},
|
|
1007
|
+
true,
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
906
1011
|
export function initRunView() {
|
|
1012
|
+
initPaneKeys();
|
|
907
1013
|
// A phone's sheet closes with the panel's ×, which here hides the sheet rather than closing the card.
|
|
908
1014
|
document.addEventListener(
|
|
909
1015
|
"click",
|
package/web/board/search.ts
CHANGED
|
@@ -309,6 +309,12 @@ export function initSearch() {
|
|
|
309
309
|
addEventListener(
|
|
310
310
|
"keydown",
|
|
311
311
|
(e) => {
|
|
312
|
+
// Ctrl+Shift+Space works in a terminal too: no shell or agent needs it.
|
|
313
|
+
if (e.ctrlKey && e.shiftKey && e.code === "Space") {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
e.stopPropagation();
|
|
316
|
+
return void (dl ? dl.close() : openSearch());
|
|
317
|
+
}
|
|
312
318
|
// A terminal keeps its keys: Ctrl+K there is the shell's kill-line.
|
|
313
319
|
if ((e.target as Element)?.closest?.(".xterm")) return;
|
|
314
320
|
const mod = mac ? e.metaKey : e.ctrlKey;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { post } from "./api.ts";
|
|
2
|
+
import { $, html, raw } from "./dom.ts";
|
|
3
|
+
import { toast } from "./toast.ts";
|
|
4
|
+
|
|
5
|
+
// Settings → Workflows → Automations: schedules that start a run in this project. /automations
|
|
6
|
+
// answers for the page's project; the server makes every decision, this only draws and posts.
|
|
7
|
+
type Hist = { fire: string; at: number; kind: string; status: string; reason?: string; run?: string };
|
|
8
|
+
type Rule = { id: string; name: string; text: string; cron: string; kind: string; enabled: boolean; agent?: string; precheck?: string; precheck_timeout: number; grace_minutes: number; next: number | null; history: Hist[] };
|
|
9
|
+
export type Auto = { zone: string; cap: number; project: string; agents: { cmd: string; name: string }[]; rules: Rule[] };
|
|
10
|
+
|
|
11
|
+
// The form survives the redraw every change event causes.
|
|
12
|
+
const draft: Record<string, string> = { kind: "daily", time: "09:00", day: "mon", grace_minutes: "720", precheck_timeout: "60" };
|
|
13
|
+
let editing = "";
|
|
14
|
+
const when = (t: number) => new Date(t).toLocaleString([], { weekday: "short", hour: "2-digit", minute: "2-digit", day: "numeric", month: "short" });
|
|
15
|
+
const SCHEDULE: Record<string, string> = { hourly: "Every hour", daily: "Every day", weekdays: "Weekdays", weekly: "Every week", cron: "Cron" };
|
|
16
|
+
const f = (k: string) => draft[k] ?? "";
|
|
17
|
+
|
|
18
|
+
const hist = (h: Hist) => html`<li><time>${when(h.at)}</time> · ${h.kind} · <b>${h.status.replace(/_/g, " ")}</b>${h.reason ? html` · ${h.reason}` : ""}${h.run ? html` · <code>${h.run}</code>` : ""}</li>`;
|
|
19
|
+
|
|
20
|
+
const row = (r: Rule) => html`<div class="sk" data-q="${["automation", r.name, r.text, r.cron].join(" ").toLowerCase()}">
|
|
21
|
+
<div class="sk-h"><span class="sk-n"><b>${r.name}</b><span>${SCHEDULE[r.kind]} · <code>${r.cron}</code> · ${r.enabled ? (r.next ? "next " + when(r.next) : "never") : "paused"}</span></span>
|
|
22
|
+
<button type="button" class="btn" data-auto="run" data-id="${r.id}">Run now</button>
|
|
23
|
+
<button type="button" class="btn" data-auto="edit" data-id="${r.id}">Edit</button>
|
|
24
|
+
<button type="button" class="btn" data-auto="delete" data-id="${r.id}">Delete</button>
|
|
25
|
+
<button type="button" class="chk sm${r.enabled ? " on" : ""}" data-auto="${r.enabled ? "pause" : "resume"}" data-id="${r.id}" role="switch" aria-checked="${String(r.enabled)}" aria-label="${r.name}" title="${r.enabled ? "On" : "Paused"}"></button></div>
|
|
26
|
+
<div class="sk-a"><span>${r.text.length > 140 ? r.text.slice(0, 140) + "…" : r.text}</span></div>
|
|
27
|
+
${r.history.length ? html`<details class="sk-a"><summary>History (${r.history.length})</summary><ul>${r.history.map(hist)}</ul></details>` : ""}
|
|
28
|
+
</div>`;
|
|
29
|
+
|
|
30
|
+
const field = (label: string, id: string, ctl: unknown) => html`<label class="sk-n" style="display:block;margin-top:8px"><span style="display:block">${label}</span>${ctl}</label>`;
|
|
31
|
+
const input = (k: string, attrs = "") => html`<input class="sel" data-f="${k}" value="${f(k)}" ${raw(attrs)} spellcheck="false" autocomplete="off" style="width:100%">`;
|
|
32
|
+
|
|
33
|
+
const form = (d: Auto) => html`<div class="sk" data-q="automation new create add schedule">
|
|
34
|
+
<div class="sk-n"><b>${editing ? "Edit automation" : "New automation"}</b><span>Project: ${d.project}. Times are ${d.zone}, this computer's. One board per project: runs start only while a board is open.</span></div>
|
|
35
|
+
<p class="hint" role="alert" style="color:var(--warn)">Warning: an automation runs unattended in auto mode. It plans, builds and reviews with nobody watching, so it changes code in this project and spends tokens. It stops at the final approval only if your approval settings say so. At most ${d.cap} runs a day, and one open run at a time.</p>
|
|
36
|
+
${field("Name", "name", input("name", 'maxlength="60"'))}
|
|
37
|
+
${field("Request (what each run should do)", "text", html`<textarea class="sel" data-f="text" rows="3" style="width:100%">${f("text")}</textarea>`)}
|
|
38
|
+
${field("Schedule", "kind", html`<select class="sel" data-f="kind" style="width:100%">${Object.entries(SCHEDULE).map(([k, v]) => html`<option value="${k}"${f("kind") === k ? " selected" : ""}>${v}</option>`)}</select>`)}
|
|
39
|
+
${f("kind") === "cron" ? field("Cron (minute hour day month weekday)", "cron", input("cron", 'placeholder="0 9 * * 1-5"')) : html`${field(f("kind") === "hourly" ? "At minute (uses the minutes of HH:MM)" : "Time (HH:MM)", "time", input("time", 'placeholder="09:00"'))}${f("kind") === "weekly" ? field("Day", "day", html`<select class="sel" data-f="day" style="width:100%">${["mon", "tue", "wed", "thu", "fri", "sat", "sun"].map((x) => html`<option${f("day") === x ? " selected" : ""}>${x}</option>`)}</select>`) : ""}`}
|
|
40
|
+
${field("Agent", "agent", html`<select class="sel" data-f="agent" style="width:100%"><option value="">Project default</option>${d.agents.map((a) => html`<option value="${a.cmd}"${f("agent") === a.cmd ? " selected" : ""}>${a.name}</option>`)}</select>`)}
|
|
41
|
+
${field("Check before each scheduled run (optional shell command; exit 0 continues)", "precheck", input("precheck", 'placeholder="git fetch -q && test -n "$(git log --since=7.days -1)""'))}
|
|
42
|
+
<p class="hint">Runs on this computer, in the project folder, every time this fires. Not run by Run now.</p>
|
|
43
|
+
${field("Check time limit (seconds)", "precheck_timeout", input("precheck_timeout", 'inputmode="numeric"'))}
|
|
44
|
+
${field("Late start allowed (minutes after the due time)", "grace_minutes", input("grace_minutes", 'inputmode="numeric"'))}
|
|
45
|
+
<div class="sk-a"><button type="button" class="btn pri" data-auto="save">${editing ? "Save" : "Create"}</button>${editing ? html`<button type="button" class="btn" data-auto="cancel">Cancel</button>` : ""}</div>
|
|
46
|
+
</div>`;
|
|
47
|
+
|
|
48
|
+
export const automationRows = (d: Auto) => html`<h3 class="sg">Automations</h3><div class="sgrp">${d.rules.map(row)}${form(d)}</div>`;
|
|
49
|
+
|
|
50
|
+
export function wireAutomations(d: Auto, redraw: () => Promise<unknown>) {
|
|
51
|
+
$("pbody").querySelectorAll<HTMLInputElement>("[data-f]").forEach((el) => {
|
|
52
|
+
el.oninput = () => { draft[el.dataset.f!] = el.value; };
|
|
53
|
+
el.onchange = () => { draft[el.dataset.f!] = el.value; if (el.dataset.f === "kind") redraw(); };
|
|
54
|
+
});
|
|
55
|
+
$("pbody").querySelectorAll<HTMLElement>("[data-auto]").forEach((b) => (b.onclick = async () => {
|
|
56
|
+
const op = b.dataset.auto!, id = b.dataset.id ?? "";
|
|
57
|
+
if (op === "edit") {
|
|
58
|
+
const r = d.rules.find((x) => x.id === id)!;
|
|
59
|
+
editing = id;
|
|
60
|
+
Object.assign(draft, { name: r.name, text: r.text, kind: r.kind, cron: r.cron, agent: r.agent ?? "", precheck: r.precheck ?? "", precheck_timeout: String(r.precheck_timeout), grace_minutes: String(r.grace_minutes), time: "09:00", day: "mon" });
|
|
61
|
+
return void redraw();
|
|
62
|
+
}
|
|
63
|
+
if (op === "cancel") { editing = ""; return void redraw(); }
|
|
64
|
+
if (op === "delete" && !confirm("Delete this automation and its history?")) return;
|
|
65
|
+
const j = await post("/automations", op === "save" ? { op: editing ? "update" : "create", id: editing, ...draft } : { op, id });
|
|
66
|
+
if (j.error) return toast(j.error);
|
|
67
|
+
if (op === "save") { editing = ""; for (const k of ["name", "text", "cron", "agent", "precheck"]) delete draft[k]; toast("Saved"); }
|
|
68
|
+
else if (op === "run") toast(j.ok ? "Started" : (j.status ?? "not started").replace(/_/g, " ") + (j.why ? ": " + j.why : ""));
|
|
69
|
+
await redraw();
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
@@ -22,3 +22,7 @@ test("the Orchestration page exists and holds its three settings", () => {
|
|
|
22
22
|
expect(pages.has("orchestration")).toBe(true);
|
|
23
23
|
for (const k of ["enabled", "max_workers", "permissions", "worker_model.claude"]) expect(placeOf(`orchestration.${k}`)).toEqual(["orchestration", "Workers"]);
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
test("the Automations page sits under Workflows", () => {
|
|
27
|
+
expect(SETTINGS_NAV.find(([g]) => g === "Workflows")![1].some((p) => p.id === "automations")).toBe(true);
|
|
28
|
+
});
|
|
@@ -17,6 +17,7 @@ export const SETTINGS_NAV: [string, SettingsPage[]][] = [
|
|
|
17
17
|
["Workflows", [
|
|
18
18
|
{ id: "approvals", title: "Approvals", desc: "Where a run stops and waits for you.", ico: "check" },
|
|
19
19
|
{ id: "autofix", title: "Auto-fix", desc: "What happens to review findings.", ico: "bug" },
|
|
20
|
+
{ id: "automations", title: "Automations", desc: "Schedules that start a run in this project.", ico: "clock" },
|
|
20
21
|
{ id: "git", title: "Git & Source Control", desc: "Branches and commits for each run.", ico: "pen" },
|
|
21
22
|
{ id: "terminal", title: "Terminal", desc: "The terminal dashboard.", ico: "term" },
|
|
22
23
|
]],
|
|
@@ -29,7 +30,7 @@ export const SETTINGS_NAV: [string, SettingsPage[]][] = [
|
|
|
29
30
|
// First match wins: [key pattern, page, subsection].
|
|
30
31
|
const PLACES: [RegExp, string, string][] = [
|
|
31
32
|
[/^(preset|runner|build\.|review\.executor)/, "agents", "Workflow"],
|
|
32
|
-
[/^subagents
|
|
33
|
+
[/^(subagents\.|agent\.model\.)/, "agents", "Models"],
|
|
33
34
|
[/^agent\.default$/, "agents", "Default agent"],
|
|
34
35
|
[/^agent\./, "agents", "Running agents"],
|
|
35
36
|
[/^orchestration\./, "orchestration", "Workers"],
|
package/web/board/settings.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { store } from "./store.ts";
|
|
2
2
|
import { termStop } from "./agent-term.ts";
|
|
3
|
-
import { load, post } from "./api.ts";
|
|
3
|
+
import { dirHeader, load, post } from "./api.ts";
|
|
4
4
|
import { stopDictation } from "./dictation.ts";
|
|
5
5
|
import { $, html, ico, raw } from "./dom.ts";
|
|
6
6
|
import { close } from "./panel.ts";
|
|
7
7
|
import { accountRows, wireAccounts } from "./settings-accounts.ts";
|
|
8
8
|
import { agentRows, wireAgents } from "./settings-agents.ts";
|
|
9
9
|
import { modelInput, modelLabel, orchestrationRows } from "./settings-orchestration.ts";
|
|
10
|
+
import { automationRows, wireAutomations } from "./settings-automations.ts";
|
|
10
11
|
import { skillRows, wireSkills } from "./settings-skills.ts";
|
|
11
12
|
import { fillMics, micRow } from "./settings-voice.ts";
|
|
12
13
|
import { placeOf, SETTINGS_NAV } from "./settings-pages.ts";
|
|
@@ -70,6 +71,9 @@ export async function openSettings() {
|
|
|
70
71
|
const sk = await fetch("/skills")
|
|
71
72
|
.then((r) => (r.ok ? r.json() : null))
|
|
72
73
|
.catch(() => null);
|
|
74
|
+
const au = await fetch("/automations", { headers: dirHeader() })
|
|
75
|
+
.then((r) => (r.ok ? r.json() : null))
|
|
76
|
+
.catch(() => null);
|
|
73
77
|
if (gen !== store.pageGen) return;
|
|
74
78
|
$("psub").textContent = "";
|
|
75
79
|
$("psub").title = "";
|
|
@@ -127,10 +131,12 @@ export async function openSettings() {
|
|
|
127
131
|
));
|
|
128
132
|
// Drawn as chips with the agent list, above the rest of the page.
|
|
129
133
|
cfg.rows = cfg.rows.filter((r) => !(r.key === "agent.default" && ap));
|
|
134
|
+
// A model row only for a tool on this machine.
|
|
135
|
+
if (ap) cfg.rows = cfg.rows.filter((r) => !r.key.startsWith("agent.model.") || ap.agents.some((a) => a.installed && r.key.endsWith("." + a.cmd)));
|
|
130
136
|
for (const r of cfg.rows) {
|
|
131
137
|
const id = "s-" + r.key.replace(/\./g, "-");
|
|
132
138
|
const [page, sub] = placeOf(r.key);
|
|
133
|
-
const wm =
|
|
139
|
+
const wm = /^(orchestration\.worker_model|agent\.model)\./.test(r.key);
|
|
134
140
|
put(page, sub + (scoped && r.group === "Board" ? " · all projects" : ""), row(
|
|
135
141
|
wm ? modelLabel(r) : r.label,
|
|
136
142
|
r.text
|
|
@@ -178,7 +184,7 @@ export async function openSettings() {
|
|
|
178
184
|
<button class="sup" type="button">${ico("chev")}Settings</button>
|
|
179
185
|
<header><h2>${p.title}</h2><p>${p.desc}${scopeName ? ` Editing ${scopeName}.` : ""}</p></header>
|
|
180
186
|
${p.id === "general" ? html`<div id="supd"></div>` : ""}
|
|
181
|
-
<div class="scard">${p.id === "agents" && ap ? agentRows(ap, defaultAgent, scopeName) : ""}${p.id === "accounts" && ac ? accountRows(ac) : ""}${p.id === "orchestration" && cfg ? orchestrationRows({ windows: !!cfg.windows, bypass: cfg.rows.some((r) => r.key === "orchestration.permissions" && r.value === "bypass") }) : ""}${p.id === "skills" && sk ? skillRows(sk.skills) : ""}${[...pageRows.get(p.id)].map(([sub, rows]) => html`<h3 class="sg">${sub}</h3><div class="sgrp">${rows}</div>`)}</div>
|
|
187
|
+
<div class="scard">${p.id === "agents" && ap ? agentRows(ap, defaultAgent, scopeName) : ""}${p.id === "accounts" && ac ? accountRows(ac) : ""}${p.id === "orchestration" && cfg ? orchestrationRows({ windows: !!cfg.windows, bypass: cfg.rows.some((r) => r.key === "orchestration.permissions" && r.value === "bypass") }) : ""}${p.id === "skills" && sk ? skillRows(sk.skills) : ""}${p.id === "automations" ? (au ? automationRows(au) : html`<h3 class="sg">Automations</h3><div class="sgrp"><div class="sk" data-q="automation">Open a project to add automations. They belong to one project each.</div></div>`) : ""}${[...pageRows.get(p.id)].map(([sub, rows]) => html`<h3 class="sg">${sub}</h3><div class="sgrp">${rows}</div>`)}</div>
|
|
182
188
|
</div>`)}
|
|
183
189
|
${cfg ? "" : html`<p class="snone">Settings could not be read. Run <code>kaizen settings</code>.</p>`}
|
|
184
190
|
<p class="snone" id="snone" hidden></p>
|
|
@@ -243,6 +249,7 @@ export async function openSettings() {
|
|
|
243
249
|
};
|
|
244
250
|
if (ap) wireAgents(openSettings, cfg?.scope ?? null);
|
|
245
251
|
if (sk) wireSkills(openSettings, sk.token);
|
|
252
|
+
if (au) wireAutomations(au, openSettings);
|
|
246
253
|
fillMics();
|
|
247
254
|
if (ac) wireAccounts(openSettings);
|
|
248
255
|
filter();
|
package/web/board/workspace.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { onBoardCards } from "./badge.ts";
|
|
6
6
|
import { store } from "./store.ts";
|
|
7
7
|
import { $, html, modal, raw } from "./dom.ts";
|
|
8
|
+
import { initResources } from "./resources.ts";
|
|
8
9
|
import { age, need } from "./labels.ts";
|
|
9
10
|
import { openAdd } from "./add-project.ts";
|
|
10
11
|
import { initSearch } from "./search.ts";
|
|
@@ -454,7 +455,11 @@ export function usageChips(list) {
|
|
|
454
455
|
async function usage(refresh = false) {
|
|
455
456
|
try {
|
|
456
457
|
const r = await fetch("/usage" + (refresh ? "?refresh=1" : ""));
|
|
457
|
-
if (r.ok)
|
|
458
|
+
if (!r.ok) return;
|
|
459
|
+
const list = await r.json();
|
|
460
|
+
$("usage").innerHTML = usageChips(list);
|
|
461
|
+
// Nothing to refresh: only Claude and Codex report usage.
|
|
462
|
+
$("usage-r").style.display = list.length ? "" : "none";
|
|
458
463
|
} catch {}
|
|
459
464
|
}
|
|
460
465
|
async function phone() {
|
|
@@ -493,6 +498,7 @@ export function initFooter(goTerminal: () => void) {
|
|
|
493
498
|
const fh = () => document.documentElement.style.setProperty("--foot-h", $("foot").offsetHeight + "px");
|
|
494
499
|
new ResizeObserver(fh).observe($("foot"));
|
|
495
500
|
fh();
|
|
501
|
+
initResources();
|
|
496
502
|
void usage();
|
|
497
503
|
void phone();
|
|
498
504
|
setInterval(() => void usage(), 5 * 60_000);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect, test } from "bun:test";
|
|
2
|
-
import { agentStatus, agentsHtml, forgetAgents, lineOf, settleIn, toggleOpen, wsAgents, SETTLE_MS, awaiting, dueWord, chosen, newRun, loopbackUrl, toOpen, stageKeys, stageTabs, finished, historyOf, liveIn, migrate, pickable, prune, wsKey } from "./ws-tabs.ts";
|
|
2
|
+
import { nearestPane, agentStatus, agentsHtml, forgetAgents, lineOf, settleIn, toggleOpen, wsAgents, SETTLE_MS, awaiting, dueWord, chosen, newRun, loopbackUrl, toOpen, stageKeys, stageTabs, finished, historyOf, liveIn, migrate, pickable, prune, wsKey } from "./ws-tabs.ts";
|
|
3
3
|
|
|
4
4
|
const run = (id: string, status: string, o: any = {}) => ({ kind: "run", state: "/p/.kaizen", id, status, moved: 1, ws: "/p", ...o });
|
|
5
5
|
const wsOf = (c) => c.ws;
|
|
@@ -192,3 +192,22 @@ test("a terminal that carried plan and build is named for the run's stage", () =
|
|
|
192
192
|
expect(stageTabs(c, "Claude")).toEqual([{ key: "a", title: "Build · Claude" }]);
|
|
193
193
|
expect(stageTabs({ ...c, column: 3 }, "Claude")[0].title).toBe("Review · Claude");
|
|
194
194
|
});
|
|
195
|
+
|
|
196
|
+
test("nearestPane walks a split like tmux", () => {
|
|
197
|
+
const box = (left: number, top: number, right: number, bottom: number) => ({ left, top, right, bottom });
|
|
198
|
+
const b = { a: box(0, 0, 50, 100), b: box(50, 0, 100, 50), c: box(50, 50, 100, 100) };
|
|
199
|
+
expect(nearestPane(b, "b", "d")).toBe("c");
|
|
200
|
+
expect(nearestPane(b, "c", "l")).toBe("a");
|
|
201
|
+
expect(nearestPane(b, "a", "l")).toBeNull();
|
|
202
|
+
expect(nearestPane(b, "a", "u")).toBeNull();
|
|
203
|
+
expect(nearestPane(b, "a", "r")).toBe("b");
|
|
204
|
+
expect(nearestPane(b, "gone", "r")).toBeNull();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("a failed land outranks every other agent status", () => {
|
|
208
|
+
const a = { key: "k", dir: "d", name: "Claude", asking: true, busy: true };
|
|
209
|
+
expect(agentStatus({ ...a, land: "conflict" }, 0, new Map())).toBe("conflict");
|
|
210
|
+
expect(agentStatus({ ...a, land: "check" }, 0, new Map())).toBe("failed");
|
|
211
|
+
expect(lineOf({ a: { ...a, land: "conflict", last: "x" }, st: "conflict" })).toBe("Conflict - Claude");
|
|
212
|
+
expect(agentStatus(a, 0, new Map())).toBe("asking");
|
|
213
|
+
});
|