kaizen-agent 1.68.0 → 1.69.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,6 +111,10 @@ G-02 FAIL: see finding 3
111
111
  R-01 CANNOT VERIFY: needs a live Stripe account; the test-mode fixture skips webhooks. Human: refund one real charge and confirm the ledger row.
112
112
  ```
113
113
 
114
+ A `G-nn` item's `— proof:` is the first check to run. `CANNOT VERIFY` on an item
115
+ whose proof the reviewer could run is not an answer: run it. Where the plan already
116
+ marked the proof a human check, `CANNOT VERIFY` is expected and names that check.
117
+
114
118
  `CANNOT VERIFY` is for a check that needs something the reviewer does not have —
115
119
  taste, a live account or device, a real reader, production data, a person's decision.
116
120
  It states what was tried, why that does not settle it, and exactly what a human must
@@ -132,7 +136,10 @@ human check never reads as a clean pass.
132
136
  Where `review.write_memory` is true (the default), the reviewer also appends any
133
137
  durable lesson about this material to `memory.md` —
134
138
  a recurring bug pattern, a non-obvious constraint, a convention worth keeping. Not
135
- run-specific detail; only what the next run would want to know.
139
+ run-specific detail; only what the next run would want to know. Where the state
140
+ directory has `notes/Project/Index.md`, a lesson about one area's files goes to that
141
+ area's note under `## Watch out` instead, since planners open only the notes for the
142
+ areas they touch; `memory.md` keeps the lessons that hold across the project.
136
143
 
137
144
  `memory.md` is read by every stage of every future run, so its size is a tax on all of
138
145
  them. Keep it under `review.memory_max_lines` (default 100): before appending, drop
@@ -73,7 +73,9 @@ connected in the session: cite what it returns, limitations included. When they
73
73
  not connected, say the claim is unverified rather than guess at internals.
74
74
 
75
75
  Record the track in `state.json` as `track`, with the three answers written into
76
- `00-request.md`. Every subsequent stage reads them before starting, and the words
76
+ `00-request.md`. The description stays free; the stored `track` word is the nearest of
77
+ `code`, `writing`, `communication`, `operations`, `research`, or a new word where none
78
+ fits (a mix joined with `+`), because `kaizen recall --track` looks lessons up by it. Every subsequent stage reads them before starting, and the words
77
79
  *build*, *verify*, and *finding* below are always to be read in the track's terms.
78
80
 
79
81
  ---
@@ -123,6 +125,12 @@ is building and a recheck is reviewing, whoever runs them and whether the loop o
123
125
  user picked the findings: `build` with `iteration` raised and `awaiting: null` before
124
126
  each iteration's first edit, `review` before its recheck reads. Any other word
125
127
  (`implement`, `fix`, `building`) is unknown to every reader and shows as still planning.
128
+ After intake, where `kaizen --version` prints 1.69.0 or later, write these keys with
129
+ `kaizen state <id> stage=build awaiting=null` (`iteration=<n>` likewise): one atomic
130
+ write that refuses unknown words and stamps `updated`. An older `kaizen` reads `state`
131
+ as a plain `kaizen` call and starts the installer, so there, and where no `kaizen` is
132
+ installed, edit `state.json` by hand in its two-space JSON layout. Finish with
133
+ `kaizen done <id>` either way.
126
134
 
127
135
  `awaiting` is `null` or the config key of the approval being waited on —
128
136
  `approvals.plan`, `approvals.review`, `approvals.each_file` — or `findings` when the
@@ -28,6 +28,9 @@ 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 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`) |
32
+ | `kaizen stats [<id>] [--json]` | (1.69.0+) Fix-round and CANNOT VERIFY rates, stage times, tokens for one run |
33
+ | `kaizen related <path> ...` | (1.69.0+) Earlier runs that changed these files |
31
34
  | `/kaizen backlog` | Print open backlog items across all runs, grouped by source run, rescued items last under `Orphaned` |
32
35
  | `/kaizen gather` | Read request sources kaizen cannot read by itself; their requests land in the icebox, nothing starts |
33
36
  | `/kaizen discover` | Group what is in the icebox and promote the tasks you pick; nothing starts |
@@ -42,6 +45,7 @@ anything.
42
45
  | `/kaizen config` | Show this project's settings and change them, one picker per setting |
43
46
  | `/kaizen init` | Set up this project folder: `.kaizen/` with the `spec*.md` files, config, and — in a git repo — the gitignore entry |
44
47
  | `/kaizen install` | Install the workflow itself globally or per-project |
48
+ | `kaizen preview <localhost url \| image>` | Show a change in the board (page → Browser tab, screenshot → Preview tab), not a new browser window |
45
49
  | `kaizen recall [--track t] [--tags a,b] [--query "<words>"]` | Lessons from other projects that match (global knowledge, `~/.kaizen/knowledge/`) |
46
50
  | `kaizen remember --track t --tags a,b --applies "<where>" --run <id> "<lesson>"` | Save a lesson that holds beyond this project; the reviewer calls it |
47
51
 
package/web/board/home.ts CHANGED
@@ -68,7 +68,7 @@ function msg(m, i) {
68
68
  const runs = runsIn(m.text + " " + (m.steps || []).map((s) => s.text).join(" "));
69
69
  // Nothing yet: the typing dots stand in for the reply.
70
70
  if (!steps.length && !m.text && !m.error && !active) return "";
71
- 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>`;
71
+ 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="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
72
  }
73
73
 
74
74
  function hero() {
@@ -200,7 +200,7 @@ function draw() {
200
200
  grow(q);
201
201
  q.oninput = () => grow(q);
202
202
  q.onkeydown = (e) => {
203
- if (e.key === "Enter" && !e.shiftKey && !e.isComposing) {
203
+ if (e.key === "Enter" && !e.shiftKey && !e.isComposing && !phone()) { // no Shift on a phone: Enter is a new line, the Send button sends
204
204
  e.preventDefault();
205
205
  $("hbox").requestSubmit();
206
206
  }
@@ -1,6 +1,6 @@
1
1
  // ---- Phones: their own Home (devices, recent runs, usage) and the Runs page (this
2
2
  // machine's runs grouped waiting / active / done). The board, Tasks and Icebox are set up
3
- // on a computer; a phone has Home, Chat, Runs and Settings.
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
5
  import { $, html, raw } from "./dom.ts";
6
6
  import { cardHref, logo, railData, stateOf, subline, titleOf, usageChips, wsHref } from "./workspace.ts";
@@ -537,6 +537,15 @@ async function openWindow(u: string) {
537
537
  // The run's Preview: its screenshots (each opens the image viewer on click), with an Open
538
538
  // app link when it names a localhost address. The address is framed only when the Preview
539
539
  // has no images: the dev server a run used is often gone, and a dead frame hides the proof.
540
+ // No run, no `## Preview`: what an agent last showed with `kaizen preview <image|url>` in this workspace.
541
+ async function directPreview(el: HTMLElement) {
542
+ if (!ctx) return false;
543
+ const p = await fetchPreview(ctx.dir, ctx.ws);
544
+ if (!p) return false;
545
+ const u = p.image ? fileUrl(ctx.dir, p.image) : p.url!;
546
+ el.insertAdjacentHTML("beforeend", String(p.image ? html`<div class="rprev"><figure><img src="${u}" alt="Latest change" style="max-width:100%"><figcaption>${p.image.split("/").pop()}</figcaption></figure></div>` : html`<iframe class="rframe" title="Preview" src="${u}"></iframe>`));
547
+ return true;
548
+ }
540
549
  async function previewPane(el: HTMLElement) {
541
550
  let doc = store.runDoc && store.runDoc.id === card?.id ? store.runDoc : null;
542
551
  if (!doc && card?.kind === "run")
@@ -544,6 +553,8 @@ async function previewPane(el: HTMLElement) {
544
553
  doc = await (await fetch(`/run/${encodeURIComponent(card.id)}?dir=${encodeURIComponent(card.state)}`)).json();
545
554
  } catch {}
546
555
  const pv = doc && preview(doc.impl);
556
+ (el as any).refresh = () => (el.replaceChildren(), void previewPane(el));
557
+ if (!pv && (await directPreview(el))) return;
547
558
  const url = loopbackUrl(pv);
548
559
  const shots = pv && /!\[[^\]]*\]\(/.test(pv);
549
560
  if (url && loopback && !shots) return void el.insertAdjacentHTML("beforeend", String(html`<iframe class="rframe" title="Preview" src="${url}"></iframe>`));
@@ -731,6 +742,25 @@ function onMoveMenu(e: Event) {
731
742
  m.style.left = Math.max(8, r.right - m.offsetWidth) + "px";
732
743
  }
733
744
 
745
+ // + makes a new tab; split right/down adds to the tab shown. `n` is a menu item's data-n.
746
+ function openNew(n: string, mode: string) {
747
+ const s = saved();
748
+ target = mode === "tab" || !s.on ? null : { screen: s.on, dir: mode as "cols" | "rows" };
749
+ if (n === "shell") void newPty();
750
+ else if (n.startsWith("agent:")) void newPty(n.slice(6));
751
+ else if (n === "local") addTab({ id: "local", kind: "local", title: "Browser" });
752
+ else if (n === "history") addTab({ id: "history", kind: "history", title: "History" });
753
+ else openPreview();
754
+ }
755
+ // Ctrl+Space r / d: a second terminal like the focused one (same agent, or a shell), split right or down.
756
+ // Anything else (Browser, Preview, notes) has no copy to make, so the menu opens to pick from.
757
+ function likeFocused(): string | null {
758
+ const sc = screens().find((x) => x.id === saved().on);
759
+ const t = sc && tabs().find((x) => x.id === sc.focus);
760
+ if (t?.kind === "shell") return "shell";
761
+ if (t?.kind === "agent") return "agent:" + (t.agent ?? (defAgent || agents[0]?.cmd || ""));
762
+ return null;
763
+ }
734
764
  function wire() {
735
765
  const bar = $("rtabs"),
736
766
  s = saved();
@@ -748,15 +778,8 @@ function wire() {
748
778
  const n = t.closest<HTMLElement>("[data-n]")?.dataset.n;
749
779
  if (n) {
750
780
  const d = t.closest<HTMLDetailsElement>(".radd")!;
751
- const mode = d.dataset.mode;
752
781
  d.open = false;
753
- // + makes a new tab; split right/down adds to the tab shown.
754
- target = mode === "tab" || !s.on ? null : { screen: s.on, dir: mode as "cols" | "rows" };
755
- if (n === "shell") void newPty();
756
- else if (n.startsWith("agent:")) void newPty(n.slice(6));
757
- else if (n === "local") addTab({ id: "local", kind: "local", title: "Browser" });
758
- else if (n === "history") addTab({ id: "history", kind: "history", title: "History" });
759
- else openPreview();
782
+ openNew(n, d.dataset.mode as string);
760
783
  return;
761
784
  }
762
785
  };
@@ -931,6 +954,42 @@ async function autoBrowse() {
931
954
  }
932
955
  }
933
956
 
957
+ // `kaizen preview <url|image>` (cli/preview.ts) wrote what an agent changed: the Browser tab opens
958
+ // on it, inside the board. Never an outside window. The newest one per workspace opens once; one
959
+ // older than two minutes at first sight is stale and is only recorded.
960
+ const previewAt = new Map<string, number>();
961
+ const fileUrl = (dir: string, image: string) => `${location.origin}/file?dir=${encodeURIComponent(dir)}&p=${encodeURIComponent(image)}`;
962
+ // The latest preview written for this workspace, or null.
963
+ async function fetchPreview(dir: string, ws: string) {
964
+ let p: { url?: string; image?: string; ws?: string; at?: number } = {};
965
+ try {
966
+ p = await (await fetch("/preview?dir=" + encodeURIComponent(dir))).json();
967
+ } catch {}
968
+ const same = p.ws && (p.ws === ws || p.ws.startsWith(ws + "/") || ws.startsWith(p.ws + "/"));
969
+ return p.at && same && (p.url || p.image) ? p : null;
970
+ }
971
+ async function pollPreview() {
972
+ if (!ctx) return;
973
+ const k = ctx.k, dir = ctx.dir;
974
+ const p = await fetchPreview(dir, ctx.ws);
975
+ if (!p || ctx?.k !== k || (previewAt.get(k) ?? 0) >= p.at!) return;
976
+ const first = !previewAt.has(k);
977
+ previewAt.set(k, p.at!);
978
+ if (first && Date.now() - p.at! > 120_000) return;
979
+ if (p.image) {
980
+ // A screenshot belongs in Preview; a live page in the Browser.
981
+ addTab({ id: "preview", kind: "preview", title: "Preview" });
982
+ (panes.get("preview")?.el as any)?.refresh?.();
983
+ return;
984
+ }
985
+ try {
986
+ localStorage.setItem("kz-browse:" + k, p.url!);
987
+ } catch {}
988
+ addTab({ id: "local", kind: "local", title: "Browser" });
989
+ (panes.get("local")?.el as any)?.browseTo?.(p.url!);
990
+ }
991
+ setInterval(() => void pollPreview(), 3000);
992
+
934
993
  // A phone's run sheet: drag it down from anywhere its content is at the top, or tap outside it.
935
994
  function initSheet() {
936
995
  const p = $("panel"),
@@ -1004,6 +1063,8 @@ function paneKey(k: string) {
1004
1063
  return;
1005
1064
  }
1006
1065
  const mode = { c: "tab", r: "cols", d: "rows" }[k];
1066
+ const same = mode && mode !== "tab" && !noPty ? likeFocused() : null;
1067
+ if (same) return void openNew(same, mode!);
1007
1068
  if (mode) {
1008
1069
  const add = $("rtabs").querySelector<HTMLDetailsElement>(`.radd[data-mode=${mode}]`);
1009
1070
  if (add) add.open = true;
@@ -1040,7 +1101,7 @@ function keyHint(on: boolean) {
1040
1101
  const h = document.createElement("div");
1041
1102
  h.id = "keyhint";
1042
1103
  h.setAttribute("role", "status");
1043
- const keys = [["←↓↑→", "pane"], ["1-9", "tab"], ["n p", "next, prev"], ["c", "new tab"], ["r", "split right"], ["d", "split down"], ["x", "close pane"], ["?", "all keys"]];
1104
+ const keys = [["←↓↑→", "pane"], ["1-9", "tab"], ["n p", "next, prev"], ["c", "new tab"], ["r", "split right, same as this pane"], ["d", "split down, same as this pane"], ["x", "close pane"], ["?", "all keys"]];
1044
1105
  h.innerHTML = String(html`${keys.map(([k, t]) => html`<span><kbd>${k}</kbd>${t}</span>`)}`);
1045
1106
  document.body.append(h);
1046
1107
  }
@@ -294,7 +294,7 @@ dialog.gs::backdrop{background:rgb(0 0 0/.35)}
294
294
  .gs-w{margin-left:auto;padding-left:8px;color:var(--dim);font-size:var(--fs-xs,11px);flex:none}
295
295
  .gs-none{padding:14px 8px;text-align:center;color:var(--dim);font-size:var(--fs-s,12px)}
296
296
  .gs-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
297
- @media(max-width:640px){.rail a.it.gs-it{display:none}}`;
297
+ @media(max-width:640px){.rail a.it.gs-it{order:4}}`;
298
298
 
299
299
  export function initSearch() {
300
300
  const st = document.createElement("style");
@@ -38,6 +38,7 @@ const PLACES: [RegExp, string, string][] = [
38
38
  [/^sources\./, "integrations", "Request sources"],
39
39
  [/^(mode|approvals\.|auto_accept)/, "approvals", "Approvals"],
40
40
  [/^auto_fix\./, "autofix", "Auto-fix"],
41
+ [/^auto_guard\./, "autofix", "Auto mode guard"],
41
42
  [/^git\./, "git", "Git"],
42
43
  [/^ui\./, "terminal", "Terminal"],
43
44
  [/^board\.chat_hotkey$/, "shortcuts", "Shortcuts"],
package/web/board.html CHANGED
@@ -139,13 +139,13 @@ body .rail a.upd::after{left:calc(50% + 6px);top:4px}body .toast{left:16px;botto
139
139
  [data-rail=min] .rail .psec{padding:0;margin:12px 0 2px;flex-direction:column}[data-rail=min] .rail .rbot{flex-direction:column}
140
140
  [data-rail=min] .plist .proj{justify-content:center;margin:10px 0 4px;padding:0}[data-rail=min] .plist .row{grid-template-columns:14px;justify-content:center;padding:0}
141
141
  @media(max-width:640px){.rail .psec,.rail .plist,.rail .rib{display:none}.rail .rbot,[data-rail=min] .rail .rbot{display:contents}.rail a.it[data-view=tasks]{order:3}.rail a.it[data-view=board]{order:4}.rail a.it .n,.rail a.it .srcs{display:none}}
142
- /* phones: Home, Chat, Runs, Settings. The board, Tasks and the Icebox are set up on a computer (web/board/phone.ts) */
142
+ /* phones: Home, Chat, Runs, Search (Settings is a Search result). The board, Tasks and the Icebox are set up on a computer (web/board/phone.ts) */
143
143
  @media(min-width:641px){.rail .rbot .lbl{display:none}.rail .rbot a.it{flex:none;width:var(--btn-xs);height:var(--btn-xs);padding:0;justify-content:center;margin-right:auto}[data-rail=min] .rail .rbot a.it{width:var(--btn-s);height:var(--btn-s);margin-right:0}}
144
144
  .rail a.it.ponly,#phome{display:none}
145
145
  @media(max-width:640px){
146
146
  .rail a.it:is([data-view=board],[data-view=tasks],[data-view=sources]),#foot,#ctx-open,body .rail .rbot .rib{display:none!important}
147
147
  .rail a.it.ponly{display:flex}
148
- .rail a.it[data-view=home]{order:1}.rail a.it[data-view=chat]{order:2}.rail a.it[data-view=device]{order:3}.rail a.it[data-view=settings]{order:4}
148
+ .rail a.it[data-view=home]{order:1}.rail a.it[data-view=chat]{order:2}.rail a.it[data-view=device]{order:3}.rail a.it[data-view=settings]{display:none}
149
149
  .rail,[data-rail=min] .rail{padding:8px 8px max(2px,calc(env(safe-area-inset-bottom) - 8px));border-top:1px solid color-mix(in srgb,var(--line) 70%,transparent)}
150
150
  .rail a.it,[data-rail=min] .rail a.it{min-height:46px;gap:3px;font-size:10.5px;letter-spacing:.01em}
151
151
  .rail a.it svg{width:44px;height:26px;padding:4px 12px;box-sizing:border-box;border-radius:13px;transition:background .15s}
@@ -666,7 +666,7 @@ body.homev #home{flex:1;min-height:0;display:flex;position:relative;animation:fi
666
666
  .hactivity{display:flex;align-items:center;gap:10px;min-height:54px;font-size:12px;color:var(--dim);overflow-wrap:anywhere}
667
667
  .hmascot{position:relative;display:block;width:52px;height:52px;flex:none;border-radius:12px}
668
668
  .hmascot .mascot{display:block;width:100%;height:100%;background:var(--accent);animation:hfloat 2.4s ease-in-out infinite}
669
- .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}
669
+ .hlaptop{position:absolute;left:14px;top:20px;animation:hfloat 2.4s ease-in-out infinite;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}
670
670
  .hlaptop:after{content:"";position:absolute;left:-4px;right:-4px;bottom:-4px;height:2px;border-radius:0 0 5px 5px;background:#b8d0ff}
671
671
  .hactivity-copy{display:flex;min-width:0;flex-direction:column;gap:6px}
672
672
  .hdots{display:flex;align-items:center;gap:6px;height:7px}
@@ -1028,6 +1028,7 @@ a.schip:hover{color:var(--ink);border-color:color-mix(in srgb,var(--line) 60%,va
1028
1028
  @view-transition{navigation:auto}
1029
1029
  ::view-transition-group(*){animation-duration:.2s}
1030
1030
  @media(prefers-reduced-motion:reduce){:root:not([data-motion=full]) *,:root:not([data-motion=full]) *::before,:root:not([data-motion=full]) *::after,:root:not([data-motion=full])::view-transition-group(*),:root:not([data-motion=full])::view-transition-old(*),:root:not([data-motion=full])::view-transition-new(*){transition:none!important;animation:none!important}}
1031
+ @media(prefers-reduced-motion:reduce){:root:not([data-motion=full]):not([data-motion=reduce]) .hdots i{animation:hdot 1.05s ease-in-out infinite!important}:root:not([data-motion=full]):not([data-motion=reduce]) .hdots i:nth-child(2){animation-delay:.16s!important}:root:not([data-motion=full]):not([data-motion=reduce]) .hdots i:nth-child(3){animation-delay:.32s!important}}
1031
1032
  :root[data-motion=reduce] *,:root[data-motion=reduce] *::before,:root[data-motion=reduce] *::after,:root[data-motion=reduce]::view-transition-group(*),:root[data-motion=reduce]::view-transition-old(*),:root[data-motion=reduce]::view-transition-new(*){transition:none!important;animation:none!important}
1032
1033
  /* Every page's top bar (Board, Tasks, Icebox, Terminal, Settings, a run's tabs): one height, one divider. */
1033
1034
  /* Tasks uses the Board's own header, as the Icebox does; its extra filters go in #hx. */