kaizen-agent 1.71.0 → 1.72.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.
@@ -28,6 +28,7 @@ anything.
28
28
  | `/kaizen review [target]` | Review-only: audit existing code, no plan, no implementation |
29
29
  | `/kaizen status` | List every run grouped waiting-on-you / in flight / done / abandoned, plus open backlog count |
30
30
  | `kaizen done <id> [--user-approved]` | Finish a run; refused while the review gate waits on the user, `--user-approved` after a clear yes in chat |
31
+ | `kaizen preflight <id>` | Before a push or merge: is the run behind its base, is CI failed or running, does another open PR, branch or run change the same files. Exit 0 clean, 2 stopped (ask the user; `kaizen worktree land <id> --checked` only after a go-ahead) |
31
32
  | `kaizen model [planner\|builder\|reviewer]` | The model to pass on that stage subagent's Agent call, from `subagents.<stage>` then `subagents.model`; `inherit` means pass none |
32
33
  | `kaizen state <id> key=value ...` | (1.69.0+) Set a run's `stage`, `awaiting` or `iteration` in `state.json`; refuses words no board knows (`done` goes through `kaizen done`) |
33
34
  | `kaizen stats [<id>] [--json]` | (1.69.0+) Fix-round and CANNOT VERIFY rates, stage times, tokens for one run |
package/web/board/git.ts CHANGED
@@ -278,6 +278,20 @@ function confirmDiscard(path, untracked, many = 0) {
278
278
  });
279
279
  }
280
280
 
281
+ // The preflight stopped a land: what it found, then Cancel or Go ahead anyway. True on go ahead.
282
+ function confirmPreflight(pf) {
283
+ return new Promise((res) => {
284
+ const dl = modal(html`<div class="gdis">
285
+ <b>${pf.branch === pf.base ? `Stopped before pushing to ${pf.base}` : `Stopped before landing ${pf.branch || "this run"} on ${pf.base}`}</b>
286
+ <p>Other work needs a look first. Rebase, wait for CI or land the other work first, or go ahead anyway.</p>
287
+ <div class="gpath">${pf.issues.map((i) => html`<div>${i.what}${i.files?.length ? html`: ${i.files.slice(0, 6).join(", ")}${i.files.length > 6 ? ` +${i.files.length - 6} more` : ""}` : ""}</div>`)}</div>
288
+ ${pf.notes.length ? html`<p>${pf.notes.map((n) => html`<span>${n}. </span>`)}</p>` : ""}
289
+ <div class="row"><button class="btn" value="no">Cancel</button><button class="btn danger" value="yes">Go ahead anyway</button></div>
290
+ </div>`);
291
+ dl.addEventListener("close", () => res(dl.returnValue === "yes"));
292
+ });
293
+ }
294
+
281
295
  function wire(c, el) {
282
296
  const u = st(c),
283
297
  inp = el.querySelector("#gmsg");
@@ -365,20 +379,23 @@ async function act(c, a, b) {
365
379
  b.dataset.busy = 1;
366
380
  b.textContent = BUSY[a] || "Working…";
367
381
  const base = { dir: c.state, id: c.id };
368
- const r =
382
+ const [path, payload] =
369
383
  a === "commit"
370
- ? await post("/commit", { ...base, message: u.msg, files: g.staged || [], push: false })
384
+ ? ["/commit", { ...base, message: u.msg, files: g.staged || [], push: false }]
371
385
  : a === "commitpush" || a === "push"
372
- ? await post("/commit", { ...base, message: a === "commitpush" ? u.msg : "", files: g.files })
386
+ ? ["/commit", { ...base, message: a === "commitpush" ? u.msg : "", files: g.files }]
373
387
  : a === "go-pr" || a === "go-draft"
374
- ? await post("/pr", {
388
+ ? ["/pr", {
375
389
  ...base,
376
390
  op: "create",
377
391
  title: u.title ?? $("gtitle").value,
378
392
  body: u.body ?? $("gbody").value,
379
393
  draft: a === "go-draft",
380
- })
381
- : await post("/pr", { ...base, op: a === "go-merge" ? "merge" : "remove" });
394
+ }]
395
+ : ["/pr", { ...base, op: a === "go-merge" ? "merge" : "remove" }];
396
+ let r = await post(path, payload);
397
+ // The preflight stopped it: show what it found; a go-ahead resends with its one-time token.
398
+ if (r.preflight && (await confirmPreflight(r.preflight))) r = await post(path, { ...payload, override: r.token });
382
399
  if (r.ok) {
383
400
  toast(
384
401
  a === "commit"
@@ -5,7 +5,7 @@ import { toast } from "./toast.ts";
5
5
 
6
6
  // Settings → Skills: one row per bundled skill, grouped. /skills scans the folders, so
7
7
  // a new skill shows here with no change to this file.
8
- type Row = { id: string; title: string; description: string; group: string; off: boolean; agents: { agent: string; state: string }[]; needs: { name: string; found: boolean }[]; offByDefault?: boolean; note?: string; status?: string };
8
+ type Row = { id: string; title: string; description: string; group: string; off: boolean; agents: { agent: string; state: string }[]; needs: { name: string; found: boolean }[]; offByDefault?: boolean; note?: string; status?: string; rea?: { installed: string | null; latest: string | null; update: boolean; outside: boolean } };
9
9
  const GROUPS: [string, string][] = [["core", "Core"], ["media", "Media"], ["optional", "Optional"]];
10
10
  const WORD: Record<string, string> = { installed: "installed", missing: "missing", other: "your own copy" };
11
11
 
@@ -19,6 +19,7 @@ const SKILL_ICONS: Record<string, string> = {
19
19
  "kaizen-computer": '<rect x="3" y="4" width="18" height="12" rx="1"/><path d="M8 20h8M12 16v4M9 8l5 3-2 .8-.8 2Z"/>',
20
20
  "kaizen-game": '<rect x="2" y="7" width="20" height="11" rx="5"/><path d="M7 10.5v4M5 12.5h4"/><circle cx="16" cy="11.5" r=".6"/><circle cx="18" cy="13.5" r=".6"/>',
21
21
  "kaizen-video": '<rect x="3" y="6" width="13" height="12" rx="2"/><path d="m16 10 5-3v10l-5-3"/>',
22
+ rea: '<circle cx="10.5" cy="10.5" r="6"/><path d="m15 15 6 6"/><path d="M8.5 9 7 10.5 8.5 12M12.5 9l1.5 1.5-1.5 1.5"/>',
22
23
  };
23
24
  const PUZZLE = '<path d="M10 4a2 2 0 1 1 4 0v2h5v5h-2a2 2 0 1 0 0 4h2v5H5v-5h2a2 2 0 1 0 0-4H5V6h5Z"/>';
24
25
  const skillIcon = (id: string) => raw(`<svg class="sk-i" viewBox="0 0 24 24" aria-hidden="true">${SKILL_ICONS[id] ?? PUZZLE}</svg>`);
@@ -26,18 +27,42 @@ const skillIcon = (id: string) => raw(`<svg class="sk-i" viewBox="0 0 24 24" ari
26
27
  const row = (s: Row) =>
27
28
  html`<div class="sk" data-q="${[s.title, s.id, s.description, s.group, "skill"].join(" ").toLowerCase()}">
28
29
  <div class="sk-h">${skillIcon(s.id)}<span class="sk-n"><b>${s.title}${s.status && s.status !== "stable" ? html` <em class="sk-st">${s.status === "beta" ? "Beta" : "Experimental"}</em>` : ""}</b><span>${s.description}</span></span>
29
- ${s.group === "core" ? html`<span class="hint">Always on</span>` : html`${!s.off && s.agents.some((a) => a.state === "missing") ? html`<button type="button" class="btn" data-skill="${s.id}" data-on="true">Install</button>` : ""}<button type="button" class="chk sm${s.off ? "" : " on"}" data-skill="${s.id}" data-on="${String(s.off)}" data-warn="${String(!!s.offByDefault)}" role="switch" aria-checked="${String(!s.off)}" aria-label="${s.title}" title="${s.off ? "Off" : "On"}"></button>`}</div>
30
+ ${s.group === "core" ? html`<span class="hint">Always on</span>` : html`${s.rea?.update ? html`<button type="button" class="btn" data-rea-update="1">Update to ${s.rea.latest}</button>` : ""}${!s.rea && !s.off && s.agents.some((a) => a.state === "missing") ? html`<button type="button" class="btn" data-skill="${s.id}" data-on="true">Install</button>` : ""}<button type="button" class="chk sm${s.off ? "" : " on"}" data-skill="${s.id}" data-on="${String(s.off)}" data-warn="${String(!!s.offByDefault)}" role="switch" aria-checked="${String(!s.off)}" aria-label="${s.title}" title="${s.off ? "Off" : "On"}"></button>`}</div>
30
31
  <div class="sk-a">${s.agents.map((a) => html`<img class="sk-ag${a.state === "installed" ? "" : " off"}" src="${AGENT_FAVICONS[AGENT_CMD[a.agent] ?? ""] ?? ""}" width="18" height="18" alt="${a.agent}: ${WORD[a.state] ?? a.state}" title="${a.agent}: ${WORD[a.state] ?? a.state}">`)}${s.needs.map((n) => html`<span class="${n.found ? "" : "miss"}">Needs ${n.name}${n.found ? "" : " (not found)"}</span>`)}${s.note ? html`<span>${s.note}</span>` : ""}</div>
31
32
  </div>`;
32
33
 
33
34
  export const skillRows = (skills: Row[]) =>
34
35
  html`${GROUPS.filter(([g]) => skills.some((s) => s.group === g)).map(([g, label], i) => html`<h3 class="sg">${label}${i ? "" : html` <button type="button" id="sk-recheck">Re-check</button>`}</h3><div class="sgrp">${skills.filter((s) => s.group === g).map(row)}</div>`)}`;
35
36
 
37
+ // REA: the board runs REA's dry run first and shows what would change; only a yes to that
38
+ // exact plan is applied. Off runs REA's own uninstall, whoever set REA up.
39
+ async function reaSwitch(on: boolean, update: boolean, redraw: () => Promise<unknown>) {
40
+ if (!on) {
41
+ if (!confirm("Turn REA off?\n\nThis runs REA's own uninstall: it removes REA's MCP registration and skill from every agent, also a REA you set up yourself outside kaizen. Ghidra, Java and REA's data stay.")) return;
42
+ toast("Removing REA…");
43
+ const j = await post("/rea", { step: "off" });
44
+ if (!j.error) toast(j.hint ? `REA removed. Claude still has one: run ${j.hint}` : "REA removed. Restart your agents");
45
+ return redraw();
46
+ }
47
+ toast(update ? "Checking the newest REA…" : "Asking REA what it would change… (first time downloads REA)");
48
+ const plan = await post("/rea", { step: "plan", update });
49
+ if (plan.error) return redraw();
50
+ const files = plan.files?.length ? plan.files.map((f: string) => " " + f).join("\n") : " (REA did not list files)";
51
+ if (!confirm(`${update ? "Update" : "Set up"} REA ${plan.version} for: ${plan.clients.join(", ")}\n\nREA's setup will change:\n${files}\n\nIt backs each file up first. Agents can then run REA's reverse-engineering tools on files you point them at. Go ahead?`)) return;
52
+ toast(update ? "Updating REA…" : "Setting up REA…");
53
+ const j = await post("/rea", { step: "apply", confirm: true, token: plan.token });
54
+ if (!j.error) toast(`REA ${j.version} is set up. Restart your agents to load its tools`);
55
+ return redraw();
56
+ }
57
+
36
58
  export function wireSkills(redraw: () => Promise<unknown>, token = "") {
37
59
  const again = $("sk-recheck");
38
60
  if (again) again.onclick = () => redraw();
61
+ const up = $("pbody").querySelector<HTMLElement>("[data-rea-update]");
62
+ if (up) up.onclick = () => reaSwitch(true, true, redraw);
39
63
  $("pbody").querySelectorAll<HTMLElement>("[data-skill]").forEach((b) => (b.onclick = async () => {
40
64
  const on = b.dataset.on === "true";
65
+ if (b.dataset.skill === "rea") return reaSwitch(on, false, redraw);
41
66
  // An off-by-default skill gives agents a power the user never had to grant: say so, then ask.
42
67
  const warn = on && b.dataset.warn === "true";
43
68
  if (warn && !confirm("Let agents read and operate the apps on your desktop?\n\nThey see the window text of the apps they open and can click, set values and type in them, as you. A password manager is blocked by its name only, so one inside a browser or under another name is not. Any other open app is in reach. Turn on?")) return;
package/web/board.html CHANGED
@@ -400,7 +400,7 @@ section li.hint{display:block;padding:14px;border:1px dashed var(--line);border-
400
400
  .gdis .gpath{padding:var(--gap) var(--padx);border:1px solid var(--line);border-radius:var(--r-xs);font:var(--fs-s) var(--mono);overflow-wrap:anywhere}
401
401
  .gitp .gmsgbox{position:relative}.gitp .gmsgbox textarea{padding-right:32px}.gitp .gspark{position:absolute;top:var(--gap);right:var(--gap);color:var(--dim)}.gitp .gspark:hover{color:var(--accent)}.gitp .gspark.spin svg{animation:gspin 1s linear infinite}@keyframes gspin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.gitp .gspark.spin svg{animation:none}}
402
402
  .gdis .gpath{white-space:pre-wrap;max-height:180px;overflow:auto}
403
- .gdis .row{display:flex;justify-content:flex-end;gap:var(--gap)}.gdis .btn.danger{background:var(--danger);border-color:var(--danger);color:#fff}.gdis .btn.danger:hover{filter:brightness(1.08)}.gdis .btn{display:inline-flex;align-items:center;gap:var(--gap)}
403
+ .gdis .row{display:flex;justify-content:flex-end;gap:var(--gap)}.gdis .btn.danger,body.runv .gdis .btn.danger:not(.pri){background:var(--danger);border-color:var(--danger);color:#fff}.gdis .btn.danger:hover{filter:brightness(1.08)}.gdis .btn{display:inline-flex;align-items:center;gap:var(--gap)}
404
404
  .inl .row .mic{margin-right:0}.inl .row #newpick{margin-right:auto}.inl .row .btn{white-space:nowrap}.inl .att{font-size:12px;color:var(--dim)}.inl .att{font-size:12px;color:var(--dim)}.inl .att:empty{display:none}
405
405
  /* first-run onboarding: one panel, three steps (see web/board/onboarding.ts) */
406
406
  dialog.onb{border:1px solid var(--line);padding:0;background:var(--bg);color:var(--ink);width:min(720px,calc(100vw - 32px));height:min(740px,calc(100dvh - 32px));border-radius:var(--r-l);box-shadow:var(--shadow-2);overflow:hidden}