kaizen-agent 1.79.0 → 1.80.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/hermes.ts +20 -0
- package/cli/install.ts +20 -1
- package/cli/localsend.ts +61 -4
- package/cli/report.ts +7 -4
- package/cli/settings.ts +2 -8
- package/cli/state.ts +19 -3
- package/cli/task-results.ts +133 -0
- package/cli/task-service.ts +180 -0
- package/cli/tasks.ts +201 -0
- package/cli/ui-audit.allow.json +6 -0
- package/cli/ui-audit.ts +427 -0
- package/cli/web.ts +72 -1
- package/cli/whatsapp.ts +112 -0
- package/package.json +2 -1
- package/skills/kaizen/SKILL.md +4 -0
- package/skills/kaizen/adapters.md +4 -0
- package/skills/kaizen/spec-build.md +5 -1
- package/skills/kaizen/spec-main.md +4 -0
- package/skills/kaizen/spec-plan.md +4 -0
- package/skills/kaizen/spec-review.md +4 -0
- package/skills/kaizen/spec.md +52 -0
- package/web/board/add-project.ts +1 -1
- package/web/board/badge.ts +70 -8
- package/web/board/cards.ts +4 -2
- package/web/board/dom.ts +10 -0
- package/web/board/icebox.ts +2 -2
- package/web/board/keys.ts +1 -1
- package/web/board/live.ts +9 -5
- package/web/board/phone.ts +4 -3
- package/web/board/rich.ts +4 -2
- package/web/board/run-view.ts +16 -14
- package/web/board/settings-automations.ts +2 -2
- package/web/board/settings-skills.ts +2 -2
- package/web/board/settings.ts +12 -14
- package/web/board/task-page.ts +672 -0
- package/web/board/task-results.ts +235 -0
- package/web/board/tasks.ts +214 -200
- package/web/board/terms.ts +17 -2
- package/web/board/views.ts +35 -9
- package/web/board/whatsapp-setup.ts +137 -0
- package/web/board/workspace.ts +24 -2
- package/web/board.html +62 -35
- package/web/board.js +403 -142
- package/web/notebook.js +388 -153
- package/web/notes.html +21 -11
- package/web/term.js +1 -1
- package/web/video.html +27 -11
- package/web/video.js +415 -180
- package/web/video.ts +5 -5
- package/web/board/new-agent.ts +0 -20
package/cli/whatsapp.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Kaizen WhatsApp: manages the background Baileys bridge (~/.kaizen/whatsapp/bridge.ts)
|
|
2
|
+
// and proxies requests to it over the local Unix domain socket.
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
|
|
7
|
+
export const WA_DIR = join(homedir(), ".kaizen", "whatsapp");
|
|
8
|
+
export const BRIDGE_SCRIPT = join(WA_DIR, "bridge.ts");
|
|
9
|
+
export const SOCK_PATH = join(WA_DIR, "bridge.sock");
|
|
10
|
+
|
|
11
|
+
export type WAStatus = {
|
|
12
|
+
installed: boolean;
|
|
13
|
+
running: boolean;
|
|
14
|
+
connected: boolean;
|
|
15
|
+
user: string | null;
|
|
16
|
+
qrSvg: string | null;
|
|
17
|
+
error: string | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type WAChat = { id: string; name: string; type: string };
|
|
21
|
+
|
|
22
|
+
async function callBridge(path: string, options: RequestInit = {}, timeoutMs = 4000): Promise<any> {
|
|
23
|
+
if (!existsSync(SOCK_PATH)) return null;
|
|
24
|
+
try {
|
|
25
|
+
const res = await fetch(`http://localhost${path}`, {
|
|
26
|
+
// Bun unix socket option
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
unix: SOCK_PATH,
|
|
29
|
+
...options,
|
|
30
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
31
|
+
});
|
|
32
|
+
if (!res.ok) return null;
|
|
33
|
+
return await res.json().catch(() => null);
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function ensureDaemon(ms = 3000): Promise<boolean> {
|
|
40
|
+
if (!existsSync(BRIDGE_SCRIPT)) return false;
|
|
41
|
+
// If already answering, we are good
|
|
42
|
+
const st = await callBridge("/status", {}, 1000);
|
|
43
|
+
if (st) return true;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const p = Bun.spawn(["bun", BRIDGE_SCRIPT], {
|
|
47
|
+
cwd: WA_DIR,
|
|
48
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
49
|
+
env: process.env,
|
|
50
|
+
windowsHide: true,
|
|
51
|
+
});
|
|
52
|
+
p.unref();
|
|
53
|
+
|
|
54
|
+
const start = Date.now();
|
|
55
|
+
while (Date.now() - start < ms) {
|
|
56
|
+
await Bun.sleep(200);
|
|
57
|
+
const ready = await callBridge("/status", {}, 500);
|
|
58
|
+
if (ready) return true;
|
|
59
|
+
}
|
|
60
|
+
} catch {}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function whatsappStatus(): Promise<WAStatus> {
|
|
65
|
+
const installed = existsSync(BRIDGE_SCRIPT);
|
|
66
|
+
if (!installed) {
|
|
67
|
+
return { installed: false, running: false, connected: false, user: null, qrSvg: null, error: null };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const res = await callBridge("/status", {}, 1500);
|
|
71
|
+
if (!res) {
|
|
72
|
+
return { installed: true, running: false, connected: false, user: null, qrSvg: null, error: null };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
installed: true,
|
|
77
|
+
running: true,
|
|
78
|
+
connected: !!res.connected,
|
|
79
|
+
user: res.user ?? null,
|
|
80
|
+
qrSvg: res.qrSvg ?? null,
|
|
81
|
+
error: res.error ?? null,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function whatsappConnect(): Promise<WAStatus> {
|
|
86
|
+
await ensureDaemon();
|
|
87
|
+
await callBridge("/connect", { method: "POST" });
|
|
88
|
+
return whatsappStatus();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function whatsappDisconnect(): Promise<{ ok: boolean }> {
|
|
92
|
+
const res = await callBridge("/disconnect", { method: "POST" });
|
|
93
|
+
return { ok: !!res?.ok };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function whatsappChats(): Promise<WAChat[] | null> {
|
|
97
|
+
const res = await callBridge("/chats", {}, 2000);
|
|
98
|
+
if (Array.isArray(res?.chats)) return res.chats;
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function whatsappSend(target: string, text: string, file: string): Promise<{ ok: true } | { ok: false; error: string } | null> {
|
|
103
|
+
const running = await ensureDaemon();
|
|
104
|
+
if (!running) return null;
|
|
105
|
+
const res = await callBridge("/send", {
|
|
106
|
+
method: "POST",
|
|
107
|
+
headers: { "content-type": "application/json" },
|
|
108
|
+
body: JSON.stringify({ target, text, file }),
|
|
109
|
+
}, 120_000);
|
|
110
|
+
if (!res) return null;
|
|
111
|
+
return res.ok ? { ok: true } : { ok: false, error: res.error || "Send failed" };
|
|
112
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kaizen-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.80.0",
|
|
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": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"install-links": "bun run cli/install.ts",
|
|
25
25
|
"check": "bun run cli/install.ts --check",
|
|
26
26
|
"build:web": "bun run cli/build-web.ts",
|
|
27
|
+
"audit:ui": "bun run cli/ui-audit.ts",
|
|
27
28
|
"format": "prettier --write web/*.ts web/board bot/web/app",
|
|
28
29
|
"format:check": "prettier --check web/*.ts web/board bot/web/app",
|
|
29
30
|
"test": "bun test",
|
package/skills/kaizen/SKILL.md
CHANGED
|
@@ -397,3 +397,7 @@ gitignore.
|
|
|
397
397
|
## Install
|
|
398
398
|
|
|
399
399
|
`/kaizen install`: read [`install.md`](install.md) first and follow it.
|
|
400
|
+
|
|
401
|
+
## Task-linked runs
|
|
402
|
+
|
|
403
|
+
Task launch context identifies a persistent task. Read the Persistent Task protocol in spec.md before intake. Preserve its UUID and input receipts; use its frozen proposal policy and the supplied current CLI command. Task feedback explicitly authorizes linked follow-ups without reopening completed runs.
|
|
@@ -85,3 +85,7 @@ is ignored — the workflow is shared, the run data is not:
|
|
|
85
85
|
!.kaizen/spec*.md
|
|
86
86
|
!.kaizen/config.yml
|
|
87
87
|
```
|
|
88
|
+
|
|
89
|
+
## Task-linked runs
|
|
90
|
+
|
|
91
|
+
All supported adapters/runners receive task identity and frozen task policy in run state plus the launch prompt. They must use the supplied current CLI Task protocol (spec.md), acknowledge delivery, report structured questions/proposals/results/receipts and wait for explicit proposal confirmation. Do not infer acknowledgements from terminal output or swap to Home chat/Codex when the configured agent fails.
|
|
@@ -153,7 +153,7 @@ commands to start it locally and the URL to open, copied from the material's own
|
|
|
153
153
|
where one exists. An app with a dev server: leave it running when the build ends
|
|
154
154
|
(started in the background, its log in a file), and write its full `http://localhost:<port>`
|
|
155
155
|
address here; the board's Browser opens that address on its own, a phone included, and
|
|
156
|
-
its
|
|
156
|
+
its Run app button starts the folder's `dev` script when the server has stopped. For anything else — a document, copy, a runbook, a memo — the path
|
|
157
157
|
to open, or the result itself when it fits in a screen. The board shows this section on
|
|
158
158
|
the run's card, so a person can try the work without reading the rest of the report.
|
|
159
159
|
Every run whose result shows on a screen must put at least one screenshot of it here,
|
|
@@ -253,3 +253,7 @@ Fix what the finding names and stop. A second defect noticed while fixing the fi
|
|
|
253
253
|
a note in the iteration file, not a second fix: it has not been reviewed, and the
|
|
254
254
|
recheck is scoped to what the iteration claims to have changed.
|
|
255
255
|
|
|
256
|
+
|
|
257
|
+
## Task-linked runs
|
|
258
|
+
|
|
259
|
+
For a task-linked run, acknowledge the supplied launch/input ids, obey frozen proposal confirmation, and publish real work/receipt/boundary/result events using spec.md. A safe boundary promises no active writes and all dispatched receipts acknowledged. Preserve settled deliverable files; report snapshot failures and validation limitations. A boundary lets the board deliver one queued batch to the same agent.
|
|
@@ -339,3 +339,7 @@ preserves partial evidence. A resumed run never restarts Explore from a changed
|
|
|
339
339
|
setting. On a board confirmation record the decision, unblock and prepare the plan;
|
|
340
340
|
normal plan approval remains required. An Explore revise returns to questioning,
|
|
341
341
|
not implementation. Stop abandons the run.
|
|
342
|
+
|
|
343
|
+
## Task-linked runs
|
|
344
|
+
|
|
345
|
+
For a task-linked run, persisted task_policy takes precedence over global auto/approval defaults under both runners. The task page confirms the exact proposal/run/iteration/result. Preserve task id across linked follow-ups explicitly authorized by task feedback. Finish workflow checks without interpreting technical completion as task acceptance or publication. Follow the Persistent Task protocol in spec.md.
|
|
@@ -386,3 +386,7 @@ Either way, do not proceed to implementation on a rejected plan under any mode.
|
|
|
386
386
|
revised plan returns through this same approval; a killed run's `stage` never advances
|
|
387
387
|
past `"abandoned"`.
|
|
388
388
|
|
|
389
|
+
|
|
390
|
+
## Task-linked runs
|
|
391
|
+
|
|
392
|
+
For a task-linked run, publish a concise structured proposal with outcome, constraints and checks plus expandable full-plan details using the Persistent Task protocol in spec.md. Questions and planning do not authorize production; wait for confirmation of this proposal even under saved auto mode.
|
|
@@ -228,3 +228,7 @@ The exception is the regression check, which runs every iteration whatever the f
|
|
|
228
228
|
touched. It is cheap, and it is the one that catches a fix breaking something nobody
|
|
229
229
|
thought to connect it to.
|
|
230
230
|
|
|
231
|
+
|
|
232
|
+
## Task-linked runs
|
|
233
|
+
|
|
234
|
+
For a task-linked run, distinguish observed checks from functional limits and user acceptance. Publish completed typed outputs with checks and limitations through the Persistent Task protocol in spec.md; preserve immutable files and specialized Video ids. Never claim a rendered form proves its backend works.
|
package/skills/kaizen/spec.md
CHANGED
|
@@ -202,3 +202,55 @@ Any tool picking up a run reads `state.json` and continues from `stage`, honorin
|
|
|
202
202
|
`awaiting`. A run whose `awaiting` is non-null must not be advanced without a
|
|
203
203
|
recorded decision in `02-approval.md`. This is what makes a run safe to hand between
|
|
204
204
|
Claude Code, Codex, and Antigravity mid-flight.
|
|
205
|
+
|
|
206
|
+
## Persistent Task protocol
|
|
207
|
+
|
|
208
|
+
A board Task has a durable UUID independent of its title and linked workflow runs.
|
|
209
|
+
The launch prompt supplies the task id, frozen policy, current result, input ids,
|
|
210
|
+
current CLI command and this source contract. Use that command when a global
|
|
211
|
+
installation is older. Never replace task identity, broaden permissions, or silently
|
|
212
|
+
switch agents. Both full and lite runners honor the persisted task policy before
|
|
213
|
+
reading global auto/approval defaults.
|
|
214
|
+
|
|
215
|
+
Task intake/planning may ask questions and propose an outcome, but must not produce
|
|
216
|
+
until the current proposal is explicitly confirmed. Use the sanctioned state command;
|
|
217
|
+
it rejects build/review/done before that confirmation. Do not overwrite task_policy,
|
|
218
|
+
task_id or task_confirmed by hand. The task page owns the versioned decision.
|
|
219
|
+
|
|
220
|
+
Read context with `kaizen task show --task <uuid>`. Publish structured events with
|
|
221
|
+
`kaizen task event --task <uuid> --run <run-id> --operation <stable-event-id> --json '<event>'`.
|
|
222
|
+
Use a stable operation id on retries. The launcher gives the launch id and dispatched
|
|
223
|
+
input ids; acknowledge the launch before doing anything else:
|
|
224
|
+
|
|
225
|
+
- `{"type":"ack","launchId":"<launch-id>"}` acknowledges delivery, not completion.
|
|
226
|
+
- `{"type":"reply","text":"..."}` is a user-facing explanation.
|
|
227
|
+
- `{"type":"question","text":"...","options":["..."]}` requests material input.
|
|
228
|
+
- `{"type":"proposal","text":"outcome, constraints and checks","details":"full plan"}`
|
|
229
|
+
requests explicit confirmation of this run/iteration/result. Stop production here.
|
|
230
|
+
- `{"type":"work","text":"..."}` reports genuine production after confirmation.
|
|
231
|
+
- `{"type":"receipt","inputIds":["..."],"outcome":"applied"}` acknowledges only
|
|
232
|
+
dispatched input ids. Use `failed` and `error` for requests not applied.
|
|
233
|
+
- `{"type":"boundary","text":"..."}` promises no active writes and no dispatched
|
|
234
|
+
input awaiting acknowledgement. Only this acknowledged safe boundary or a completed
|
|
235
|
+
result enables the next queued batch. Do not infer safety from terminal quiet.
|
|
236
|
+
- `{"type":"result","title":"...","summary":"...","artifacts":[{"path":"output.md"},
|
|
237
|
+
{"url":"http://localhost:3000","name":"Live preview"}],"checks":["what actually passed"],
|
|
238
|
+
"limitations":["what remains unverified"]}` preserves settled deliverable files and
|
|
239
|
+
publishes a typed version. Paths must be regular files inside the project/worktree.
|
|
240
|
+
Do not snapshot source trees or databases. HTML/SVG files download only. Include
|
|
241
|
+
specialized Video identity as `video:{name,letter,revision}` when relevant, without
|
|
242
|
+
changing its recipes. A copy/disk failure retains earlier versions and needs recovery.
|
|
243
|
+
|
|
244
|
+
A question/status reply never authorizes production. Queued change requests are not
|
|
245
|
+
already applied: keep their ids and report receipts. Stop requests cancellation and
|
|
246
|
+
never rollback. Reconcile ambiguous launches/edits on explicit resume; do not replay
|
|
247
|
+
unacknowledged work blindly. Material scope changes publish a new proposal; routine
|
|
248
|
+
revisions reuse the accepted direction. Feedback sent from the task page explicitly
|
|
249
|
+
authorizes a linked follow-up after done/abandoned, so do not ask the user to manage
|
|
250
|
+
run types or reopen a finished run. Preserve `Follow-up of:` and task id. This is the
|
|
251
|
+
Task-specific exception to the general follow-up confirmation rule.
|
|
252
|
+
|
|
253
|
+
Task acceptance (Looks good) is distinct from workflow completion, technical git
|
|
254
|
+
housekeeping and publication. Finish genuine checks and workflow decisions, publish
|
|
255
|
+
checks/limitations honestly, then leave the completed result for user acceptance.
|
|
256
|
+
A rendered event form is not evidence of registration storage or delivery.
|
package/web/board/add-project.ts
CHANGED
|
@@ -112,7 +112,7 @@ export function openAdd(opts: { dir?: string | null; start?: Start } = {}) {
|
|
|
112
112
|
// New workspace, after Orca's composer: one name box, the start branch on its label row, Advanced for an exact branch.
|
|
113
113
|
const cur = ws.some((p) => p.dir === opts.dir) ? opts.dir : ws[0]?.dir;
|
|
114
114
|
const mod = /Mac/.test(navigator.platform) ? "⌘" : "Ctrl";
|
|
115
|
-
form.innerHTML = html`<b>New workspace</b><label class="att">Project<select name="project" aria-label="Project">${ws.map((p) => html`<option value="${p.dir}"${p.dir === cur ? " selected" : ""}>${p.name}</option>`)}</select></label><div class="wsfrom"><span class="att" id="wsfl">Create from <i>[Optional]</i></span><label class="wsbase">from <select name="base" aria-label="Start from branch"></select></label></div><input name="name" placeholder="What is this workspace for?" aria-labelledby="wsfl" autocomplete="off" spellcheck="false"><details class="wsadv"><summary>Advanced</summary><label class="att">Branch name<input name="branch" placeholder="feature/my-branch" aria-label="Branch name" autocomplete="off" spellcheck="false"></label></details><small class="att err" role="alert"></small><div class="row">${back}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">Create workspace</button><kbd class="wskey" aria-hidden="true">${mod} ↵</kbd></div>`.toString();
|
|
115
|
+
form.innerHTML = html`<b>New workspace</b><label class="att">Project<select class="sel" name="project" aria-label="Project">${ws.map((p) => html`<option value="${p.dir}"${p.dir === cur ? " selected" : ""}>${p.name}</option>`)}</select></label><div class="wsfrom"><span class="att" id="wsfl">Create from <i>[Optional]</i></span><label class="wsbase">from <select class="sel" name="base" aria-label="Start from branch"></select></label></div><input name="name" placeholder="What is this workspace for?" aria-labelledby="wsfl" autocomplete="off" spellcheck="false"><details class="wsadv"><summary>Advanced</summary><label class="att">Branch name<input name="branch" placeholder="feature/my-branch" aria-label="Branch name" autocomplete="off" spellcheck="false"></label></details><small class="att err" role="alert"></small><div class="row">${back}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">Create workspace</button><kbd class="wskey" aria-hidden="true">${mod} ↵</kbd></div>`.toString();
|
|
116
116
|
field("name").focus();
|
|
117
117
|
const sel = form.elements.namedItem("base") as HTMLSelectElement;
|
|
118
118
|
field("name").oninput = () => (field("branch").placeholder = branchSlug(field("name").value) || "feature/my-branch");
|
package/web/board/badge.ts
CHANGED
|
@@ -1,14 +1,65 @@
|
|
|
1
|
-
type
|
|
1
|
+
export type AttentionTask = {
|
|
2
|
+
id: string;
|
|
3
|
+
dir: string;
|
|
4
|
+
title: string;
|
|
5
|
+
status?: string;
|
|
6
|
+
activeRun?: string | null;
|
|
7
|
+
runs?: (string | { id: string })[];
|
|
8
|
+
runIds?: string[];
|
|
9
|
+
legacy?: { kind: string; id?: string; index?: number };
|
|
10
|
+
attention: { category: string; reason: string; action: string };
|
|
11
|
+
};
|
|
12
|
+
export let attentionTasks: AttentionTask[] | null = null;
|
|
13
|
+
export const taskForCard = (c: any, tasks = attentionTasks) =>
|
|
14
|
+
tasks?.find(
|
|
15
|
+
(t) =>
|
|
16
|
+
t.dir === c.state &&
|
|
17
|
+
(t.id === c.taskId ||
|
|
18
|
+
(c.kind === "run" &&
|
|
19
|
+
[
|
|
20
|
+
t.activeRun,
|
|
21
|
+
...(t.runs ?? t.runIds ?? []).map((r) => (typeof r === "string" ? r : r.id)),
|
|
22
|
+
...(t.legacy?.kind === "run" ? [t.legacy.id] : []),
|
|
23
|
+
].includes(c.id))),
|
|
24
|
+
);
|
|
25
|
+
export function setTaskAttention(tasks: AttentionTask[]) {
|
|
26
|
+
attentionTasks = tasks;
|
|
27
|
+
if (typeof document !== "undefined") {
|
|
28
|
+
const count = tasks.filter((t) => t.attention.category === "needs-you").length;
|
|
29
|
+
document.querySelectorAll<HTMLElement>('.rail a[data-view="tasks"]').forEach((a) => {
|
|
30
|
+
if (count) a.dataset.n = String(count);
|
|
31
|
+
else delete a.dataset.n;
|
|
32
|
+
a.title = count ? `Tasks · ${count} need you` : "Tasks";
|
|
33
|
+
a.setAttribute("aria-label", a.title);
|
|
34
|
+
});
|
|
35
|
+
dispatchEvent(new Event("kz-task-attention"));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
type BadgeCard = {
|
|
39
|
+
state?: string;
|
|
40
|
+
archived?: boolean;
|
|
41
|
+
kind: string;
|
|
42
|
+
status: string;
|
|
43
|
+
pty?: { alive: boolean; asking: boolean };
|
|
44
|
+
};
|
|
2
45
|
|
|
3
|
-
export function waitingCount(cards: BadgeCard[]) {
|
|
4
|
-
|
|
46
|
+
export function waitingCount(cards: BadgeCard[], tasks = attentionTasks) {
|
|
47
|
+
if (tasks) {
|
|
48
|
+
const dirs = new Set(cards.map((c) => c.state).filter(Boolean));
|
|
49
|
+
return tasks.filter((t) => (!dirs.size || dirs.has(t.dir)) && t.attention.category === "needs-you").length;
|
|
50
|
+
}
|
|
51
|
+
return cards.filter(
|
|
52
|
+
(c) => !c.archived && ((c.kind === "run" && c.status === "waiting") || (c.pty?.alive && c.pty.asking)),
|
|
53
|
+
).length;
|
|
5
54
|
}
|
|
6
55
|
|
|
7
56
|
// The rail's Projects list draws from the same cards: one fetch feeds both.
|
|
8
57
|
export let allBoardCards: any[] | null = null;
|
|
9
58
|
|
|
10
59
|
let onCards: ((cards: any[], projects?: any[], agents?: any[]) => void) | null = null;
|
|
11
|
-
export const onBoardCards = (f: typeof onCards) => {
|
|
60
|
+
export const onBoardCards = (f: typeof onCards) => {
|
|
61
|
+
onCards = f;
|
|
62
|
+
};
|
|
12
63
|
|
|
13
64
|
export function boardBadge(cards: BadgeCard[], projects?: unknown[], agents?: unknown[]) {
|
|
14
65
|
generation++;
|
|
@@ -28,10 +79,16 @@ const BADGE_GAP = 2000;
|
|
|
28
79
|
let lastRun = 0;
|
|
29
80
|
let waiting: ReturnType<typeof setTimeout> | undefined;
|
|
30
81
|
export async function refreshBoardBadge() {
|
|
31
|
-
if (loading) {
|
|
82
|
+
if (loading) {
|
|
83
|
+
again = true;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
32
86
|
const gap = lastRun + BADGE_GAP - Date.now();
|
|
33
87
|
if (gap > 0) {
|
|
34
|
-
waiting ??= setTimeout(() => {
|
|
88
|
+
waiting ??= setTimeout(() => {
|
|
89
|
+
waiting = undefined;
|
|
90
|
+
void refreshBoardBadge();
|
|
91
|
+
}, gap);
|
|
35
92
|
return;
|
|
36
93
|
}
|
|
37
94
|
lastRun = Date.now();
|
|
@@ -46,8 +103,13 @@ export async function refreshBoardBadge() {
|
|
|
46
103
|
const body = text.replace(/"now":\d+\}$/, "");
|
|
47
104
|
if (body === lastAll) continue;
|
|
48
105
|
const { cards, projects, rail, agents } = JSON.parse(text);
|
|
49
|
-
if (!again && current === generation) {
|
|
50
|
-
|
|
106
|
+
if (!again && current === generation) {
|
|
107
|
+
lastAll = body;
|
|
108
|
+
boardBadge(cards, [...projects, ...(rail ?? [])], agents);
|
|
109
|
+
}
|
|
110
|
+
} catch {
|
|
111
|
+
/* keep the last count while the board is offline */
|
|
112
|
+
}
|
|
51
113
|
} while (again);
|
|
52
114
|
loading = false;
|
|
53
115
|
}
|
package/web/board/cards.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { store } from "./store.ts";
|
|
|
2
2
|
import { where } from "./agent-term.ts";
|
|
3
3
|
import { load, post } from "./api.ts";
|
|
4
4
|
import { mic, stopDictation } from "./dictation.ts";
|
|
5
|
-
import { $, dataUrls, html, ico, modal, raw } from "./dom.ts";
|
|
5
|
+
import { $, dataUrls, html, ico, modal, raw, toggleSwitch } from "./dom.ts";
|
|
6
6
|
import { draft, undraft } from "./drafts.ts";
|
|
7
7
|
import { COLS, ICON, MARKS, NAMES, WORD, age, d, need } from "./labels.ts";
|
|
8
8
|
import { brief } from "./markdown.ts";
|
|
@@ -455,7 +455,7 @@ function inlineForm(c) {
|
|
|
455
455
|
}
|
|
456
456
|
|
|
457
457
|
const runHtml = (c) =>
|
|
458
|
-
html`<div class="q">Run "${c.text}"</div><div class="q dim">Opens your agent with this request in a terminal.</div><div class="q dim">Full plans, builds, and checks with a separate reviewer. Lite does it in one session.</div><div id="run-pick" style="display:grid;gap:6px"><div id="run-agent" class="agents" role="radiogroup" aria-label="Agent"></div></div><label class="yolo"><input type="checkbox" id="run-explore"> Explore first</label><div class="run-actions"><label class="yolo" id="run-yolo" title="Yolo: the agent runs every command and edit without asking" hidden
|
|
458
|
+
html`<div class="q">Run "${c.text}"</div><div class="q dim">Opens your agent with this request in a terminal.</div><div class="q dim">Full plans, builds, and checks with a separate reviewer. Lite does it in one session.</div><div id="run-pick" style="display:grid;gap:6px"><div id="run-agent" class="agents" role="radiogroup" aria-label="Agent"></div></div><label class="yolo"><input type="checkbox" id="run-explore"> Explore first</label><div class="run-actions"><label class="yolo" id="run-yolo" title="Yolo: the agent runs every command and edit without asking" hidden>${toggleSwitch(false)}Yolo</label><div class="row"><button type="button" class="btn ghost" data-a="c">Cancel</button><button type="button" class="btn" data-a="l">Lite</button><button type="button" class="btn pri" data-a="s">Full run</button></div></div>`;
|
|
459
459
|
// The run form as a popup over any page: Start in the new-task form and on Tasks.
|
|
460
460
|
export function runPopup(c) {
|
|
461
461
|
const dl = modal(runHtml(c)),
|
|
@@ -697,6 +697,8 @@ function taskForm(f, shut) {
|
|
|
697
697
|
|
|
698
698
|
// New task from the top bar, the empty board or n: the same form, in a modal.
|
|
699
699
|
export function newTask(from?: { dir: string | null }) {
|
|
700
|
+
const taskDir = from && "dir" in from ? from.dir : !store.all ? store.S.dir : null;
|
|
701
|
+
if (!dispatchEvent(new CustomEvent("kz-new-task", { cancelable: true, detail: { dir: taskDir } }))) return;
|
|
700
702
|
// The header button passes its click event: only an explicit { dir } is another page's call.
|
|
701
703
|
formPick = from && "dir" in from ? from : null;
|
|
702
704
|
if (store.mode === "new") {
|
package/web/board/dom.ts
CHANGED
|
@@ -14,6 +14,16 @@ const part = (v): string => (v instanceof Safe ? v.s : Array.isArray(v) ? v.map(
|
|
|
14
14
|
// Escape-by-default template: html`<b>${title}</b>` cannot inject markup. Keep attributes double-quoted.
|
|
15
15
|
export const html = (strs: TemplateStringsArray, ...vals) => raw(strs.reduce((a, s, i) => a + part(vals[i - 1]) + s));
|
|
16
16
|
export const ico = (n) => raw(`<svg><use href="#i-${n}"/></svg>`);
|
|
17
|
+
// The board's one switch (.chk in board.html). A <button role="switch"> whose owner flips `.on`
|
|
18
|
+
// and aria-checked; with `box`, a checkbox whose `checked` is the state, for code that reads it.
|
|
19
|
+
// `sm` is the compact size; `attrs` are further attributes, escaped.
|
|
20
|
+
export const toggleSwitch = (on: boolean, o: { sm?: boolean; box?: boolean; attrs?: Record<string, string> } = {}) => {
|
|
21
|
+
const cls = "chk" + (o.sm ? " sm" : ""),
|
|
22
|
+
at = raw(Object.entries(o.attrs ?? {}).map(([k, v]) => ` ${k}="${esc(v)}"`).join(""));
|
|
23
|
+
return o.box
|
|
24
|
+
? html`<input type="checkbox" class="${cls}" role="switch"${at}${raw(on ? " checked" : "")}>`
|
|
25
|
+
: html`<button type="button" class="${cls}${on ? " on" : ""}" role="switch" aria-checked="${String(on)}"${at}></button>`;
|
|
26
|
+
};
|
|
17
27
|
// Placeholder rows for a panel whose body is still being fetched.
|
|
18
28
|
export const SKEL = raw(
|
|
19
29
|
'<div aria-busy="true" aria-label="Loading">' +
|
package/web/board/icebox.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { termStop } from "./agent-term.ts";
|
|
|
3
3
|
import { load, post } from "./api.ts";
|
|
4
4
|
import { via } from "./cards.ts";
|
|
5
5
|
import { mic, stopDictation } from "./dictation.ts";
|
|
6
|
-
import { $, dataUrls, html, ico, modal, motion, pageOf, pager, pagerHtml, raw, SKEL, wirePager } from "./dom.ts";
|
|
6
|
+
import { $, dataUrls, html, ico, modal, motion, pageOf, pager, pagerHtml, raw, SKEL, toggleSwitch, wirePager } from "./dom.ts";
|
|
7
7
|
import { plogo, setShown, short, showable } from "./projects.ts";
|
|
8
8
|
import { playSound, soundPick, toast } from "./toast.ts";
|
|
9
9
|
import { go, view } from "./views.ts";
|
|
@@ -306,7 +306,7 @@ export async function openSources() {
|
|
|
306
306
|
: html`<span class="src-badge warn"><svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" stroke="currentColor" fill="none" stroke-width="1.8"/><path d="M8 5v3.5M8 11v.1" stroke="currentColor" fill="none" stroke-width="2" stroke-linecap="round"/></svg>Failed: ${s.last.note}</span><span class="hint" style="margin:0">${ago(s.last.at)}</span>`;
|
|
307
307
|
const kind = st === "sheet" ? "sheet" : st === "doc" ? "doc" : st === "social" ? "at" : "link",
|
|
308
308
|
bare = s.url.replace(/^https?:\/\/(www\.)?/, "");
|
|
309
|
-
return html`<div class="src-card" id="src-card-${i}"><div class="src-hd"><span class="src-ico" title="${st === "social" ? (PLAT[s.social] || "social") : st}">${fav(s.url, kind, s.social)}</span><div class="src-info"><span class="src-title" title="${title}">${title}</span><a class="src-url" href="${web(s.url)}" target="_blank" rel="noopener noreferrer" title="${s.url}"><span>${bare}</span>${ico("ext")}</a></div><div class="src-acts">${s.social ? html`<button class="ib sm" id="src-ag-${i}" data-ag="${i}" aria-label="Gather ${title} with your agent" title="${chatOn ? "Gather with your ChatGPT plan" : "Gather: opens your agent on /kaizen gather"}">${ico("refresh")}</button>` : html`<button class="ib sm" id="src-chk-${i}" data-chk="${i}" aria-label="Check ${title} now" title="Check now">${ico("refresh")}</button>`}<button class="ib sm danger" id="src-rm-${i}" data-rm="${i}" aria-label="Remove ${title}" title="Remove source">${ico("trash")}</button></div></div><div class="src-status">${statusHtml}</div><div class="src-fields"><label class="src-f" title="Category"><span>Category</span><input class="sel" id="src-ct-${i}" data-ct="${i}" data-k="${s.dir + " " + s.url}" value="${s.category || ""}" placeholder="${platOf(s)}" maxlength="40" aria-label="Category of ${title}"><button class="btn sm pri" id="src-cs-${i}" aria-label="Save the category of ${title}" disabled>Save</button></label><label class="src-f" title="Project"><span>Project</span>${plogo(s.dir, s.project || "")}<select class="sel" id="src-mv-${i}" data-mv="${i}" data-k="${s.dir + " " + s.url}" aria-label="Project of ${title}">${opts(s.dir, s.project)}</select><button class="btn sm pri" id="src-mb-${i}" aria-label="Move ${title} to the chosen project" disabled>Move</button></label></div><div class="src-sws">${st === "sheet" || /github\.com/.test(s.url) ? html`<label class="src-sw">Write back
|
|
309
|
+
return html`<div class="src-card" id="src-card-${i}"><div class="src-hd"><span class="src-ico" title="${st === "social" ? (PLAT[s.social] || "social") : st}">${fav(s.url, kind, s.social)}</span><div class="src-info"><span class="src-title" title="${title}">${title}</span><a class="src-url" href="${web(s.url)}" target="_blank" rel="noopener noreferrer" title="${s.url}"><span>${bare}</span>${ico("ext")}</a></div><div class="src-acts">${s.social ? html`<button class="ib sm" id="src-ag-${i}" data-ag="${i}" aria-label="Gather ${title} with your agent" title="${chatOn ? "Gather with your ChatGPT plan" : "Gather: opens your agent on /kaizen gather"}">${ico("refresh")}</button>` : html`<button class="ib sm" id="src-chk-${i}" data-chk="${i}" aria-label="Check ${title} now" title="Check now">${ico("refresh")}</button>`}<button class="ib sm danger" id="src-rm-${i}" data-rm="${i}" aria-label="Remove ${title}" title="Remove source">${ico("trash")}</button></div></div><div class="src-status">${statusHtml}</div><div class="src-fields"><label class="src-f" title="Category"><span>Category</span><input class="sel" id="src-ct-${i}" data-ct="${i}" data-k="${s.dir + " " + s.url}" value="${s.category || ""}" placeholder="${platOf(s)}" maxlength="40" aria-label="Category of ${title}"><button class="btn sm pri" id="src-cs-${i}" aria-label="Save the category of ${title}" disabled>Save</button></label><label class="src-f" title="Project"><span>Project</span>${plogo(s.dir, s.project || "")}<select class="sel" id="src-mv-${i}" data-mv="${i}" data-k="${s.dir + " " + s.url}" aria-label="Project of ${title}">${opts(s.dir, s.project)}</select><button class="btn sm pri" id="src-mb-${i}" aria-label="Move ${title} to the chosen project" disabled>Move</button></label></div><div class="src-sws">${st === "sheet" || /github\.com/.test(s.url) ? html`<label class="src-sw">Write back${toggleSwitch(!!s.writeback, { sm: true, attrs: { id: `src-wb-${i}`, "data-wb": String(i), "aria-label": `Write back to ${title}` } })}</label>` : ""}<label class="src-sw" title="Off: the scheduled gather skips this source; Check now still reads it">Auto gather${toggleSwitch(!s.paused, { sm: true, attrs: { id: `src-ag-on-${i}`, "data-ag-on": String(i), "aria-label": `Auto gather ${title}` } })}</label></div></div>`;
|
|
310
310
|
});
|
|
311
311
|
const fails = ((d && d.failed) || []).map((f) => html`<p style="color:var(--dim)">The sources of ${f} could not be read.</p>`);
|
|
312
312
|
const emptyState = html`<div class="src-empty"><div class="src-empty-ico">${ico("link")}</div><h4>No sources yet</h4></div>`;
|
package/web/board/keys.ts
CHANGED
|
@@ -52,7 +52,7 @@ export function initKeys() {
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
// The Terminal page has no cards to move between; its keys are the terminals'.
|
|
55
|
-
if (view === "terminal") return;
|
|
55
|
+
if (view === "terminal" || view === "task") return;
|
|
56
56
|
if (e.key === "n" && !document.querySelector("dialog[open]")) {
|
|
57
57
|
newTask();
|
|
58
58
|
}
|
package/web/board/live.ts
CHANGED
|
@@ -33,21 +33,26 @@ function listen() {
|
|
|
33
33
|
// Back to the project picked last time, unless the URL says which view it wants. A
|
|
34
34
|
// plain fetch: a project that is gone should fall back to all, not raise a toast.
|
|
35
35
|
// A page named in the address shows from the first paint; it is filled once the board has loaded.
|
|
36
|
-
const v0 = ((v) => (v === "icebox" ? "sources" : v === "ws" ? "run" : v === "ideas" ? "tasks" : v))(
|
|
36
|
+
const v0 = ((v) => (v === "icebox" ? "sources" : v === "ws" ? "run" : v === "ideas" ? "tasks" : v))(
|
|
37
|
+
new URLSearchParams(location.search).get("view"),
|
|
38
|
+
);
|
|
37
39
|
|
|
38
40
|
export function initLive() {
|
|
39
|
-
addEventListener("kz-view", () => {
|
|
41
|
+
addEventListener("kz-view", () => {
|
|
42
|
+
if (pendingReload && !document.body.classList.contains("homev")) location.reload();
|
|
43
|
+
});
|
|
40
44
|
// Back from a terminal: what was committed or pushed there touched nothing the server watches.
|
|
41
45
|
addEventListener("focus", () => load(true));
|
|
42
46
|
addEventListener("visibilitychange", flushLoad);
|
|
43
47
|
// No view in the address is Home.
|
|
44
|
-
const first = ["settings", "sources", "terminal", "board", "tasks", "run"].includes(v0) ? v0 : "home";
|
|
48
|
+
const first = ["settings", "sources", "terminal", "board", "tasks", "task", "run"].includes(v0) ? v0 : "home";
|
|
45
49
|
markView(first);
|
|
46
50
|
document.body.classList.toggle("paged", first !== "board");
|
|
47
51
|
document.body.classList.toggle("ice", v0 === "sources");
|
|
48
52
|
document.body.classList.toggle("termv", v0 === "terminal");
|
|
49
53
|
document.body.classList.toggle("homev", first === "home");
|
|
50
54
|
document.body.classList.toggle("taskv", first === "tasks");
|
|
55
|
+
document.body.classList.toggle("taskpagev", first === "task");
|
|
51
56
|
document.body.classList.toggle("runv", first === "run");
|
|
52
57
|
(async () => {
|
|
53
58
|
let d;
|
|
@@ -67,8 +72,7 @@ export function initLive() {
|
|
|
67
72
|
) {
|
|
68
73
|
store.all = false;
|
|
69
74
|
store.dir = d;
|
|
70
|
-
}
|
|
71
|
-
else keep();
|
|
75
|
+
} else keep();
|
|
72
76
|
} catch (e) {}
|
|
73
77
|
try {
|
|
74
78
|
const f = JSON.parse(sessionStorage.getItem("kz-form"));
|
package/web/board/phone.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// machine's runs grouped waiting / active / done). The board, Tasks and Icebox are set up
|
|
3
3
|
// on a computer; a phone has Home, Chat, Runs and Search (Settings is found through it).
|
|
4
4
|
import { runPopup } from "./cards.ts";
|
|
5
|
-
import { $, html, raw } from "./dom.ts";
|
|
5
|
+
import { $, html, raw, toggleSwitch } 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
8
|
import { agentStatus, wsKey, WORD, DOT, type Agent, type Status } from "./ws-tabs.ts";
|
|
@@ -86,7 +86,7 @@ async function newSheet(dir?: string, ws?: string) {
|
|
|
86
86
|
const kinds: { cmd: string; name: string; yolo?: boolean; bypassDefault?: boolean }[] = [...(list?.agents ?? []), { cmd: "", name: "Shell" }];
|
|
87
87
|
const d = document.createElement("dialog");
|
|
88
88
|
d.className = "pagsheet";
|
|
89
|
-
d.innerHTML = String(html`<h4>New in</h4><select aria-label="Workspace">${spots.map((x, i) => html`<option value="${String(i)}"${raw(x === on ? " selected" : "")}>${projName(x.dir)} ${x.name}</option>`)}</select><label class="agent-yolo"><span>Yolo / bypass permissions<small>Run commands without permission prompts</small></span
|
|
89
|
+
d.innerHTML = String(html`<h4>New in</h4><select class="sel" aria-label="Workspace">${spots.map((x, i) => html`<option value="${String(i)}"${raw(x === on ? " selected" : "")}>${projName(x.dir)} ${x.name}</option>`)}</select><label class="agent-yolo"><span>Yolo / bypass permissions<small>Run commands without permission prompts</small></span>${toggleSwitch(!!list?.agents?.find((a) => a.cmd === list.default)?.bypassDefault, { box: true, attrs: { "aria-label": "Yolo / bypass permissions" } })}</label>${kinds.map((k, i) => html`<button type="button" data-i="${String(i)}">${k.cmd ? agentIco({ agent: k.cmd } as Agent) : raw(`<svg class="pag-ico" aria-hidden="true"><use href="#i-term"/></svg>`)}${k.name}</button>`)}`);
|
|
90
90
|
d.addEventListener("click", async (e) => {
|
|
91
91
|
const b = (e.target as HTMLElement).closest<HTMLButtonElement>("button");
|
|
92
92
|
if (e.target === d) return d.close();
|
|
@@ -131,7 +131,7 @@ function device() {
|
|
|
131
131
|
const group = (title: string, cs: any[], shut = false) =>
|
|
132
132
|
cs.length ? html`<details class="pgrp"${raw(shut ? "" : " open")}><summary>${title}<span>${cs.length}</span></summary><div class="plist2">${cs.map((c) => row(c, now))}</div></details>` : "";
|
|
133
133
|
const idle = tasks().sort((a, b) => (b.moved ?? b.added ?? 0) - (a.moved ?? a.added ?? 0));
|
|
134
|
-
return html
|
|
134
|
+
return html`<a class="btn" href="?view=tasks" data-tasks="1">All tasks and results</a>${group("Waiting on you", wait)}${group("Active", active)}${group("Tasks", idle)}${group("Done", done, true)}${all.length || idle.length ? "" : html`<p class="pnote">No runs yet.</p>`}`;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
function draw() {
|
|
@@ -201,6 +201,7 @@ export function initPhone(go: (v: string, push?: boolean) => void, openRun: (c)
|
|
|
201
201
|
}
|
|
202
202
|
const a = t.closest<HTMLAnchorElement>("a");
|
|
203
203
|
if (!a) return;
|
|
204
|
+
if (a.dataset.tasks) return (e.preventDefault(), go("tasks", true));
|
|
204
205
|
if (a.dataset.dev) return (e.preventDefault(), go("device", true));
|
|
205
206
|
if (a.getAttribute("aria-disabled")) return e.preventDefault();
|
|
206
207
|
if (a.classList.contains("prow")) {
|
package/web/board/rich.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { md } from "./markdown.ts";
|
|
|
6
6
|
// The editor is turned back into markdown on every edit; typing a markdown pattern
|
|
7
7
|
// (`**b**`, `` `c` ``, `- `, `1. `, `# `) re-renders the editor with md().
|
|
8
8
|
|
|
9
|
+
// Keep Markdown hard breaks exact without generated multiline trailing spaces.
|
|
10
|
+
const HARD_BREAK = " " + String.fromCharCode(10);
|
|
9
11
|
const ZW = /\u200b/g;
|
|
10
12
|
// Editor DOM to markdown. Paragraph blocks are separated by a blank line, list items
|
|
11
13
|
// by a newline, so md() renders them back as the same blocks.
|
|
@@ -16,11 +18,11 @@ export function toMd(root) {
|
|
|
16
18
|
return n.textContent
|
|
17
19
|
.replace(ZW, "")
|
|
18
20
|
.replace(/\u00a0/g, " ")
|
|
19
|
-
.replace(/\n/g,
|
|
21
|
+
.replace(/\n/g, HARD_BREAK);
|
|
20
22
|
if (n.nodeType !== 1) return "";
|
|
21
23
|
const t = n.nodeName.toLowerCase(),
|
|
22
24
|
kids = () => [...n.childNodes].map(inl).join("");
|
|
23
|
-
if (t === "br") return
|
|
25
|
+
if (t === "br") return HARD_BREAK;
|
|
24
26
|
if (t === "b" || t === "strong") return ((s) => (s.trim() ? `**${s}**` : s))(kids());
|
|
25
27
|
if (t === "i" || t === "em") return ((s) => (s.trim() ? `*${s}*` : s))(kids());
|
|
26
28
|
if (t === "code") return ((s) => (s ? "`" + s + "`" : s))(n.textContent.replace(ZW, ""));
|