kaizen-agent 1.55.0 → 1.56.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/chat.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from "node:fs";
6
6
  import { randomUUID } from "node:crypto";
7
7
  import { basename, dirname, join } from "node:path";
8
- import { CHILD_ENV, readText } from "./state.ts";
8
+ import { CHILD_ENV, readRuns, readText } from "./state.ts";
9
9
 
10
10
  export type Step = { kind: "cmd" | "edit" | "tool" | "project"; text: string; ok?: boolean };
11
11
  export type Attachment = { name: string; path: string; image: boolean };
@@ -64,11 +64,18 @@ function saveUploads(base: string, id: string, uploads: Upload[]): Attachment[]
64
64
  export function brief(c: Chat, board: Board) {
65
65
  const here = board.projects.find((p) => p.dir === c.project);
66
66
  const list = board.projects.slice(0, 80).map((p) => `- ${p.label} — ${dirname(p.dir)}`).join("\n");
67
+ // So "what's waiting on me?" has an answer without a project.
68
+ const waiting = board.projects.slice(0, 80).flatMap((p) => readRuns(p.dir)
69
+ .filter((r) => r.awaiting && r.stage !== "done" && r.stage !== "abandoned")
70
+ .map((r) => `- ${p.label}: ${r.id} (${r.stage}, waiting on ${r.awaiting})`)).join("\n");
67
71
  return `[kaizen board context, not written by the user]
68
72
  You are kaizen's main agent, talking with the user from the kaizen board's Home page.
69
73
  Project of this chat: ${here ? `${here.label} (${dirname(here.dir)})` : "none — you are in a scratch folder"}.
70
74
  Projects on the board:
71
75
  ${list || "(none)"}
76
+ Runs waiting on the user:
77
+ ${waiting || "(none)"}
78
+ Each project's kaizen runs live in <project>/.kaizen/runs/<id>/ (state.json has stage and awaiting; 01-plan.md, 04-review.md, 06-backlog.md beside it); read them to answer questions about the board.
72
79
  You can read, analyse and edit files in any project folder listed above directly by its path; you do not need to switch to it. Do not write outside those folders and your working folder.
73
80
  Switching only changes this chat's home project (where you run and which project the board shows). On a line of its own write [[kaizen:project <folder>]] to switch to a listed project, or [[kaizen:new-project <name>]] to create one (a plain folder name). Switch only when the user asks; when what they want fits no listed project, ask whether to create a new one. After a successful move, the board starts one follow-up turn in the new project to finish the pending request; do not ask the user to repeat it.
74
81
  When the user asks you to develop, fix, change or enhance something (not a question, analysis or reading), first ask which way, as numbered options, and do nothing until they pick:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.55.0",
3
+ "version": "1.56.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": {
package/web/board/home.ts CHANGED
@@ -69,7 +69,7 @@ function msg(m, i) {
69
69
  const runs = runsIn(m.text + " " + (m.steps || []).map((s) => s.text).join(" "));
70
70
  // Nothing yet: the typing dots stand in for the reply.
71
71
  if (!steps.length && !m.text && !m.error && !active) return "";
72
- return html`<div class="hm a${anim}">${steps.length ? html`<details class="hsteps"${m.text ? "" : " open"}><summary>${steps.length} step${steps.length > 1 ? "s" : ""}</summary><ul>${steps}</ul></details>` : ""}${m.text ? html`<div class="hb md">${raw(md(m.text))}</div>` : ""}${m.error ? html`<div class="herr">${m.error}</div>` : ""}${moved.map((s) => html`<div class="hmove${s.ok === false ? " bad" : ""}">${ico("board")}${s.text}</div>`)}${runs.map((id) => html`<button class="btn ghost sm hrun" data-run="${id}">${ico("board")}Open ${id}</button>`)}${active ? html`<div class="hactivity" role="status"><span class="hmascot"><img src="/logo.png" alt="" aria-hidden="true"><i class="hlaptop"></i></span><span class="hactivity-copy"><span>${m.activity || "Thinking…"}</span><span class="hdots" aria-hidden="true"><i></i><i></i><i></i></span></span></div>` : ""}</div>`;
72
+ return html`<div class="hm a${anim}">${m.text ? html`<div class="hb md">${raw(md(m.text))}</div>` : ""}${steps.length ? html`<details class="hsteps"><summary>${steps.length} step${steps.length > 1 ? "s" : ""}</summary><ul>${steps}</ul></details>` : ""}${m.error ? html`<div class="herr">${m.error}</div>` : ""}${moved.map((s) => html`<div class="hmove${s.ok === false ? " bad" : ""}">${ico("board")}${s.text}</div>`)}${runs.map((id) => html`<button class="btn ghost sm hrun" data-run="${id}">${ico("board")}Open ${id}</button>`)}${active ? html`<div class="hactivity" role="status"><span class="hmascot" aria-hidden="true"><i class="mascot"></i><i class="hlaptop"></i></span><span class="hactivity-copy"><span>${m.activity || "Thinking…"}</span><span class="hdots" aria-hidden="true"><i></i><i></i><i></i></span></span></div>` : ""}</div>`;
73
73
  }
74
74
 
75
75
  function hero() {
@@ -180,7 +180,7 @@ function draw() {
180
180
  if (shown !== (cur && cur.id)) seen = 0;
181
181
  if (side === null) side = sideAtStart();
182
182
  h.classList.toggle("hopen", side);
183
- h.innerHTML = String(html`<div class="hside">${list()}</div><div class="hscrim" id="hscrim"></div><div class="hmain${empty ? " hfresh" : ""}"><div class="htop"><button class="ib" id="htog" aria-label="Chats" aria-expanded="${String(side)}" title="${side ? "Hide chats" : "Show chats"}">${ico("side")}</button>${empty ? "" : html`<span class="hwhere">${ico("board")}${cur.project ? name(cur.project) : "No project"}</span>`}</div><div class="hlog" id="hlog" aria-live="polite">${empty ? hero() : cur.messages.map(msg)}</div><form class="hbox" id="hbox"><input id="hfile" type="file" multiple hidden><button type="button" class="ib hattach" id="hattach" aria-label="Attach files" title="Attach files">${ico("clip")}</button><div class="hinput"><div class="hatt" id="hatt"></div><textarea id="hq" rows="1" placeholder="Message the agent" aria-label="Message the agent"></textarea></div>${sendButton()}</form>${empty ? chips() : ""}</div>`);
183
+ h.innerHTML = String(html`<div class="hside">${list()}</div><div class="hscrim" id="hscrim"></div><div class="hmain${empty ? " hfresh" : ""}"><div class="htop"><button class="ib" id="htog" aria-label="Chats" aria-expanded="${String(side)}" title="${side ? "Hide chats" : "Show chats"}">${ico("side")}</button></div><div class="hlog" id="hlog" aria-live="polite">${empty ? hero() : cur.messages.map(msg)}</div><form class="hbox" id="hbox"><input id="hfile" type="file" multiple hidden><button type="button" class="ib hattach" id="hattach" aria-label="Attach files" title="Attach files">${ico("clip")}</button><div class="hinput"><div class="hatt" id="hatt"></div><textarea id="hq" rows="1" placeholder="Ask anything, or describe what to build…" aria-label="Message the agent"></textarea></div>${empty ? "" : html`<span class="hwhere" title="Project">${ico("board")}${cur.project ? name(cur.project) : "No project"}</span>`}${sendButton()}</form>${empty ? chips() : ""}</div>`);
184
184
  seen = empty ? 0 : cur.messages.length;
185
185
  shown = cur && cur.id;
186
186
  $("htog").onclick = () => setSide(!side);
@@ -51,7 +51,7 @@ export function open(c, keepTab) {
51
51
  $("pterm").hidden = true;
52
52
  if (c.kind === "idea") {
53
53
  store.runDoc = null;
54
- $("psub").innerHTML = html`<span class="pst"><span class="st d-idea"><svg><use href="#s-idea"/></svg></span>Idea</span><span class="pst dim">${c.where.split(/[\\/]/).pop() || c.where}</span>`;
54
+ $("psub").innerHTML = c.status === "starting" && !c.archived ? steps(c) : html`<span class="pst"><span class="st d-idea"><svg><use href="#s-idea"/></svg></span>Idea</span><span class="pst dim">${c.where.split(/[\\/]/).pop() || c.where}</span>`;
55
55
  $("ptabs").innerHTML = "";
56
56
  ideaBody(c);
57
57
  const foot = $("pfoot");
@@ -105,6 +105,16 @@ function showProgress(c) {
105
105
  bar.style.width = lastProg.w + "%";
106
106
  }
107
107
  }
108
+ // The header's Plan → Build → Review → Done bar: steps before the card's column are done,
109
+ // its own is ringed in the run's status colour (waiting amber, stalled red), the rest wait.
110
+ const STEPS = ["Plan", "Build", "Review", "Done"];
111
+ function steps(c) {
112
+ const at = c.status === "done" ? 4 : Math.max(0, (c.column || 0) - 1),
113
+ tip = cap(WORD[c.status] || c.status) + (c.awaiting ? `: ${need(c.awaiting)}` : "");
114
+ return html`<span class="steps s-${c.status}" title="${tip}" aria-label="${tip}">${raw(
115
+ STEPS.map((n, i) => `<span class="${i < at ? "ok" : i === at ? "now" : ""}"><i></i>${n}</span>`).join(""),
116
+ )}</span>`;
117
+ }
108
118
  // An idea's panel: its terminal while the run it started is being born there, else its notes.
109
119
  export function ideaBody(c) {
110
120
  if (c.pty) showTerm(c);
@@ -128,10 +138,9 @@ export async function openRun(c, refresh, again) {
128
138
  const ta = $("pbody").querySelector(".notes textarea");
129
139
  if (refresh && ta && document.activeElement === ta) return;
130
140
  // The board's own status mark, then what it waits on: chips, not a dotted line.
131
- $("psub").innerHTML =
132
- html`<span class="pst"><span class="st d-${ICON[c.status] || "idea"}"><svg><use href="#s-${ICON[c.status] || "idea"}"/></svg></span>${cap(WORD[c.status] || c.status)}</span>` +
141
+ $("psub").innerHTML = c.status === "abandoned" ? html`<span class="pst"><span class="st d-${ICON[c.status] || "idea"}"><svg><use href="#s-${ICON[c.status] || "idea"}"/></svg></span>${cap(WORD[c.status] || c.status)}</span>` +
133
142
  (c.awaiting ? html`<span class="pst dim">${cap(need(c.awaiting))}</span>` : "") +
134
- (c.parent ? html`<span class="pst link" title="Filed by this run">${c.parent}</span>` : "");
143
+ (c.parent ? html`<span class="pst link" title="Filed by this run">${c.parent}</span>` : "") : steps(c);
135
144
  // Only tabs with something in them show. A card whose agent runs in the board gets its
136
145
  // terminal behind the header's terminal button, chosen once right after a launch from here.
137
146
  const tabs = TABS.filter(
package/web/board.html CHANGED
@@ -251,7 +251,7 @@ dialog.kz{border:0;padding:0;background:none;width:min(480px,calc(100vw - 32px))
251
251
  .notes{display:flex;flex-direction:column;gap:8px}
252
252
  #pbody img{max-width:100%;border-radius:var(--r-s)}
253
253
  /* the in-card agent: a wider panel, and the terminal filling its body */
254
- aside.wide{width:100%;border-left:0}#pbody:has(.term){display:flex;flex-direction:column}#pbody .term{flex:1;min-height:0;min-height:320px;background:var(--bg);border-radius:var(--r-s)}#pbody .term .xterm{height:100%;padding:4px}#pbody .term .xterm-viewport{background:transparent!important}.termkeys{padding:6px 0}.termkeys button{height:52px;padding:0;border:1px solid var(--line);border-bottom-width:4px;border-radius:10px;background:var(--bg-2);color:var(--ink-hi);font:600 17px var(--mono);touch-action:manipulation}.termkeys button:active{transform:translateY(2px);border-bottom-width:2px;background:var(--hover)}.termkeys button.on{color:var(--on-accent);background:var(--accent);border-color:var(--accent)}.keygrid{display:grid;grid-template-columns:repeat(6,1fr);gap:8px}.ctrlpad{margin-bottom:8px}.ctrlpad div{display:flex;gap:4px;margin-bottom:5px}.ctrlpad div:nth-child(2){padding:0 5%}.ctrlpad div:nth-child(3){padding:0 10%}.ctrlpad button{flex:1;min-width:0;height:44px;font-size:15px}.termkeys [hidden]{display:none}.keytop{display:flex;gap:8px;margin-bottom:6px}.keytop button{flex:1;height:30px;border-bottom-width:1px;font-size:14px}
254
+ aside.wide{width:100%;border-left:0}@media(min-width:901px){aside.wide{width:62%;border-left:1px solid var(--line)}}#pbody:has(.term){display:flex;flex-direction:column;padding:12px}#pbody .term{flex:1;min-height:0;min-height:240px;background:var(--bg);border-radius:var(--r-s)}#pbody .term .xterm{height:100%;padding:4px}#pbody .term .xterm-viewport{background:transparent!important}@media(max-width:640px){#pbody:has(.term){padding:0}#pbody .term{border-radius:0}aside:has(.term)>header{padding:12px 16px}aside:has(.term) .foot{padding:8px 16px max(8px,env(safe-area-inset-bottom));flex-wrap:nowrap}aside:has(.term) .foot .note{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px}}.termkeys{position:relative;border-top:1px solid var(--line);background:var(--bg-2)}.termkeys [hidden]{display:none}.termkeys .chips{display:flex;gap:6px;padding:8px 12px;overflow-x:auto;scrollbar-width:none}.termkeys .chips::-webkit-scrollbar{display:none}.termkeys button{flex:none;height:34px;min-width:40px;padding:0 12px;border:1px solid var(--line);border-radius:var(--r-pill);background:var(--bg-2);color:var(--ink-hi);font:13px var(--mono);touch-action:manipulation}.termkeys button:active{background:var(--hover)}.termkeys button.on{color:var(--on-accent);background:var(--accent);border-color:var(--accent)}.compose{display:flex;gap:8px;padding:2px 12px 10px}.compose input{flex:1;min-width:0;height:42px;padding:0 16px;border:1px solid var(--line);border-radius:21px;background:var(--bg);color:var(--ink-hi);font:16px var(--font)}.compose input:focus{outline:none;border-color:var(--accent)}.termkeys .compose button{width:42px;height:42px;min-width:0;padding:0;border:0;background:var(--accent);color:var(--on-accent);font-size:17px}.tmore{position:absolute;right:12px;bottom:100%;margin-bottom:6px;z-index:6;display:flex;flex-direction:column;min-width:170px;padding:4px;border:1px solid var(--line);border-radius:10px;background:var(--bg-2);box-shadow:var(--shadow-2)}.termkeys .tmore button{height:38px;border:0;border-radius:6px;text-align:left;font:14px var(--font)}.termkeys .tmore button.on{background:var(--hover);color:var(--accent)}.ctrlpad{padding:8px 8px 0}.ctrlpad div{display:flex;gap:4px;margin-bottom:5px}.ctrlpad div:nth-child(2){padding:0 5%}.ctrlpad div:nth-child(3){padding:0 10%}.termkeys .ctrlpad button{flex:1;min-width:0;height:40px;padding:0;border-radius:8px;font-size:15px}.steps{display:inline-grid;grid-template-columns:repeat(4,1fr);width:210px;max-width:100%;--c:var(--run)}.steps.s-waiting{--c:var(--warn)}.steps.s-stalled{--c:var(--danger)}.steps>span{position:relative;display:flex;flex-direction:column;align-items:center;gap:3px;font-size:10px;line-height:1.2;color:var(--dim)}.steps>span+span::before{content:"";position:absolute;top:4px;right:50%;width:100%;height:2px;background:var(--line)}.steps>span.ok+span::before{background:var(--ok)}.steps i{position:relative;z-index:1;width:10px;height:10px;border-radius:50%;border:2px solid var(--line);background:var(--bg-2)}.steps .ok i{background:var(--ok);border-color:var(--ok)}.steps .now i{border-color:var(--c);box-shadow:0 0 0 3px color-mix(in srgb,var(--c) 25%,transparent)}.steps .now{color:var(--c);font-weight:600}
255
255
  .desc{border-bottom:1px solid var(--line);padding-bottom:6px;margin-bottom:14px}.desc h3{margin-top:14px}
256
256
  .chat{display:flex;flex-direction:column;gap:10px;margin:0 0 14px}.msg{border:1px solid var(--line);border-radius:var(--r);padding:10px 12px;background:var(--bg)}.msg time{display:block;font-size:11px;color:var(--dim);margin-bottom:4px}.msg p:last-child{margin-bottom:0}.msg img{max-width:100%;max-height:260px;border-radius:var(--r-s);display:block;margin:4px 0}
257
257
  .notes .tools{display:flex;gap:6px;align-items:center}.notes .tools span{flex:1;font-size:11px;color:var(--dim)}.notes .att{font-size:11px;color:var(--dim)}.notes .rich{min-height:160px;max-height:50vh;overflow:auto;border:1px solid var(--line);border-radius:var(--r-s);padding:8px 12px;background:var(--bg-2);color:var(--ink);white-space:pre-wrap;overflow-wrap:anywhere}.notes .rich:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent)}.notes .rich:empty::before{content:attr(data-ph);color:var(--dim)}.notes .rich>:first-child{margin-top:0}
@@ -299,7 +299,7 @@ body.homev #home{flex:1;min-height:0;display:flex;position:relative;animation:fi
299
299
  .hmain{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:12px;min-height:0;padding:0 0 16px}
300
300
  .htop{align-self:stretch;display:flex;align-items:center;gap:4px;padding:8px 16px 0}
301
301
  .htop .ib svg{width:18px;height:18px}
302
- .hwhere{display:flex;align-items:center;gap:6px;margin-left:6px;font-size:12px;color:var(--dim)}.hwhere svg{width:13px;height:13px}
302
+ .hwhere{flex:none;display:flex;align-items:center;gap:6px;max-width:30%;height:34px;font-size:12px;color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hwhere svg{width:13px;height:13px}
303
303
  .hmain.hfresh{justify-content:flex-start}.hmain.hfresh .hlog{flex:none;overflow:visible;margin-top:auto}.hmain.hfresh .hchips{margin-bottom:auto}
304
304
  .hlog{flex:1;width:100%;box-sizing:border-box;overflow-y:auto;overflow-anchor:none;display:flex;flex-direction:column;gap:16px;padding:8px max(20px,calc((100% - 960px)/2))}
305
305
  .hhero{width:100%;text-align:center;animation:hin .4s cubic-bezier(.2,.7,.2,1)}.hhero .hint{margin:0;color:var(--dim)}.hhero h2{margin:0 0 6px;font-size:28px;font-weight:600;letter-spacing:-.01em;color:var(--ink-hi)}
@@ -313,7 +313,7 @@ body.homev #home{flex:1;min-height:0;display:flex;position:relative;animation:fi
313
313
  .herr{font-size:13px;color:var(--danger);white-space:pre-wrap}
314
314
  .hactivity{display:flex;align-items:center;gap:10px;min-height:54px;font-size:12px;color:var(--dim);overflow-wrap:anywhere}
315
315
  .hmascot{position:relative;display:block;width:52px;height:52px;flex:none;border-radius:12px}
316
- .hmascot img{display:block;width:100%;height:100%;border-radius:inherit;animation:hfloat 2.4s ease-in-out infinite}
316
+ .hmascot .mascot{display:block;width:100%;height:100%;background:var(--accent);animation:hfloat 2.4s ease-in-out infinite}
317
317
  .hlaptop{position:absolute;left:14px;bottom:5px;width:24px;height:13px;border:1.5px solid #dce9ff;border-radius:3px 3px 2px 2px;background:linear-gradient(145deg,#3269bd,#142e61);box-shadow:0 0 8px #4384ff66}
318
318
  .hlaptop:after{content:"";position:absolute;left:-4px;right:-4px;bottom:-4px;height:2px;border-radius:0 0 5px 5px;background:#b8d0ff}
319
319
  .hactivity-copy{display:flex;min-width:0;flex-direction:column;gap:6px}
@@ -324,7 +324,7 @@ body.homev #home{flex:1;min-height:0;display:flex;position:relative;animation:fi
324
324
  .hmove{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ok)}.hmove.bad{color:var(--danger)}.hmove svg{width:13px;height:13px}
325
325
  .hbox{position:relative;width:calc(100% - 40px);max-width:960px;display:flex;align-items:flex-end;gap:8px;padding:10px 10px 10px 16px;border:1px solid var(--line);border-radius:22px;background:var(--bg-2);box-shadow:var(--shadow-2);view-transition-name:hbox;transition:border-color .15s,box-shadow .15s}
326
326
  .hbox:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 15%,transparent),var(--shadow-2)}
327
- .hinput{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}.hbox textarea{width:100%;box-sizing:border-box;min-height:24px;max-height:220px;resize:none;border:0;outline:0;background:none;color:var(--ink);font:inherit;font-size:15px;line-height:1.5;padding:4px 0}.hattach{flex:none;margin-bottom:2px}
327
+ .hinput{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}.hbox textarea{width:100%;box-sizing:border-box;min-height:24px;max-height:220px;resize:none;border:0;outline:0;background:none;color:var(--ink);font:inherit;font-size:15px;line-height:1.5;padding:7px 0 5px}.hattach{flex:none}
328
328
  .hgo{flex:none;width:34px;height:34px;border-radius:50%;background:var(--accent);color:var(--on-accent);transition:transform .12s,filter .15s,background .15s}.hgo:hover{background:var(--accent);filter:brightness(1.1)}.hgo:active{transform:scale(.92)}.hgo.stop{background:var(--ink);color:var(--bg)}
329
329
  .hchips{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;width:calc(100% - 40px);max-width:960px;animation:hin .5s cubic-bezier(.2,.7,.2,1)}
330
330
  .hchips .chip{cursor:pointer;background:none;border:0;font:inherit;font-size:13px;padding:6px 12px;border-radius:var(--r-pill);transition:background .15s,color .15s,transform .15s}.hchips .chip:hover{color:var(--ink);background:var(--hover);transform:translateY(-1px)}