kaizen-agent 1.61.6 → 1.63.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.
Files changed (120) hide show
  1. package/README.md +2 -2
  2. package/agents/kaizen-builder.md +3 -0
  3. package/agents/kaizen-planner.md +3 -0
  4. package/agents/kaizen-reviewer.md +2 -0
  5. package/assets/kaizen-logo.png +0 -0
  6. package/assets/kaizen.ico +0 -0
  7. package/cli/__pycache__/computer-helper.cpython-314.pyc +0 -0
  8. package/cli/accounts.test.ts +126 -0
  9. package/cli/accounts.ts +116 -0
  10. package/cli/add-project.ts +4 -2
  11. package/cli/agent-prefs.test.ts +127 -0
  12. package/cli/agent-prefs.ts +106 -0
  13. package/cli/automations.test.ts +167 -0
  14. package/cli/automations.ts +298 -0
  15. package/cli/board.test.ts +4 -5
  16. package/cli/computer-helper.py +299 -0
  17. package/cli/computer.test.ts +155 -0
  18. package/cli/computer.ts +66 -0
  19. package/cli/dashboard.ts +15 -22
  20. package/cli/install.test.ts +16 -0
  21. package/cli/install.ts +134 -193
  22. package/cli/keep-awake.ts +30 -0
  23. package/cli/look.ts +33 -0
  24. package/cli/project-tree.test.ts +1 -0
  25. package/cli/pty.test.ts +2 -1
  26. package/cli/pty.ts +6 -5
  27. package/cli/report.test.ts +59 -0
  28. package/cli/report.ts +62 -0
  29. package/cli/restart.test.ts +1 -0
  30. package/cli/settings.test.ts +21 -1
  31. package/cli/settings.ts +22 -13
  32. package/cli/setup.test.ts +24 -4
  33. package/cli/setup.ts +101 -51
  34. package/cli/skills.test.ts +89 -0
  35. package/cli/skills.ts +112 -0
  36. package/cli/sources.ts +1 -1
  37. package/cli/state.test.ts +53 -4
  38. package/cli/state.ts +132 -42
  39. package/cli/term-image.test.ts +23 -0
  40. package/cli/term-image.ts +26 -0
  41. package/cli/usage.test.ts +8 -2
  42. package/cli/usage.ts +8 -6
  43. package/cli/video.test.ts +5 -5
  44. package/cli/web-accept.test.ts +1 -0
  45. package/cli/web-decide.test.ts +1 -0
  46. package/cli/web-pr.test.ts +1 -0
  47. package/cli/web-skills.test.ts +32 -0
  48. package/cli/web-symlink.test.ts +1 -0
  49. package/cli/web.ts +227 -21
  50. package/cli/workers.test.ts +319 -0
  51. package/cli/workers.ts +380 -0
  52. package/cli/worktree.test.ts +21 -2
  53. package/cli/worktree.ts +21 -2
  54. package/package.json +1 -1
  55. package/skills/kaizen/config.default.yml +40 -1
  56. package/skills/kaizen/settings.md +2 -1
  57. package/skills/kaizen/skill.json +1 -0
  58. package/skills/kaizen/spec-build.md +22 -2
  59. package/skills/kaizen/spec-main.md +9 -0
  60. package/skills/kaizen/spec-plan.md +18 -1
  61. package/skills/kaizen/spec-review.md +4 -0
  62. package/skills/kaizen/spec.md +15 -0
  63. package/skills/kaizen-help/SKILL.md +2 -0
  64. package/skills/kaizen-help/skill.json +1 -0
  65. package/skills/media/kaizen-book/skill.json +1 -0
  66. package/skills/media/kaizen-deck/SKILL.md +21 -2
  67. package/skills/media/kaizen-deck/scripts/motion.py +99 -0
  68. package/skills/media/kaizen-deck/skill.json +1 -0
  69. package/skills/media/kaizen-video/scripts/__pycache__/intake.cpython-314.pyc +0 -0
  70. package/skills/media/kaizen-video/scripts/__pycache__/make_film.cpython-314.pyc +0 -0
  71. package/skills/media/kaizen-video/scripts/__pycache__/make_tiktok.cpython-314.pyc +0 -0
  72. package/skills/media/kaizen-video/scripts/__pycache__/render_cut.cpython-314.pyc +0 -0
  73. package/skills/media/kaizen-video/scripts/__pycache__/sfx.cpython-314.pyc +0 -0
  74. package/skills/media/kaizen-video/scripts/__pycache__/srt.cpython-314.pyc +0 -0
  75. package/skills/media/kaizen-video/scripts/__pycache__/transcribe.cpython-314.pyc +0 -0
  76. package/skills/media/kaizen-video/scripts/__pycache__/vo.cpython-314.pyc +0 -0
  77. package/skills/media/kaizen-video/skill.json +1 -0
  78. package/skills/optional/kaizen-computer/SKILL.md +38 -0
  79. package/skills/optional/kaizen-computer/skill.json +1 -0
  80. package/web/board/add-project.ts +3 -3
  81. package/web/board/agent-favicons.ts +9 -0
  82. package/web/board/agent-term.ts +1 -1
  83. package/web/board/api.ts +1 -1
  84. package/web/board/approvals.ts +1 -1
  85. package/web/board/cards.ts +50 -7
  86. package/web/board/dictation.ts +46 -3
  87. package/web/board/fixes.ts +1 -1
  88. package/web/board/home.ts +1 -1
  89. package/web/board/icebox.ts +1 -1
  90. package/web/board/keys.ts +5 -15
  91. package/web/board/onboarding.ts +1 -1
  92. package/web/board/panel.ts +24 -20
  93. package/web/board/phone.ts +6 -1
  94. package/web/board/run-view.ts +118 -7
  95. package/web/board/search.ts +6 -0
  96. package/web/board/settings-accounts.ts +60 -0
  97. package/web/board/settings-agents.ts +102 -0
  98. package/web/board/settings-automations.ts +71 -0
  99. package/web/board/settings-orchestration.ts +32 -0
  100. package/web/board/settings-pages.test.ts +9 -0
  101. package/web/board/settings-pages.ts +11 -4
  102. package/web/board/settings-skills.ts +47 -0
  103. package/web/board/settings-voice.test.ts +18 -0
  104. package/web/board/settings-voice.ts +28 -0
  105. package/web/board/settings.ts +48 -5
  106. package/web/board/terms.ts +2 -2
  107. package/web/board/update.ts +1 -1
  108. package/web/board/workspace.ts +5 -1
  109. package/web/board/ws-board.test.ts +6 -0
  110. package/web/board/ws-board.ts +2 -0
  111. package/web/board/ws-tabs.test.ts +12 -1
  112. package/web/board/ws-tabs.ts +18 -0
  113. package/web/board.html +22 -5
  114. package/web/board.js +156 -85
  115. package/web/notebook.js +22 -22
  116. package/web/notes.html +3 -3
  117. package/web/term.js +27 -27
  118. package/web/term.ts +25 -3
  119. package/web/video.html +2 -2
  120. package/web/video.js +31 -31
@@ -0,0 +1,89 @@
1
+ import { afterEach, beforeEach, expect, test } from "bun:test";
2
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { dirname, join } from "node:path";
5
+ import { bundledSkills, setSkill, skillsOff, skillStatus, skillsToLink, SKILL_HOMES } from "./skills.ts";
6
+
7
+ let t: string, repo: string, home: string;
8
+ const skill = (rel: string, json?: object) => {
9
+ mkdirSync(join(repo, "skills", rel), { recursive: true });
10
+ writeFileSync(join(repo, "skills", rel, "SKILL.md"), `---\nname: x\ndescription: Does a thing. And more.\n---\n`);
11
+ if (json) writeFileSync(join(repo, "skills", rel, "skill.json"), JSON.stringify(json));
12
+ };
13
+ beforeEach(() => {
14
+ t = mkdtempSync(join(tmpdir(), "kz-skills-"));
15
+ repo = join(t, "repo"); home = join(t, "home");
16
+ mkdirSync(join(repo, "cli"), { recursive: true });
17
+ writeFileSync(join(repo, "cli", "install.ts"), "");
18
+ skill("kaizen", { group: "core" });
19
+ skill("media/kaizen-deck", { title: "Create deck", needs: ["x"] });
20
+ mkdirSync(join(home, ".claude", "skills"), { recursive: true });
21
+ symlinkSync(join(repo, "skills/media/kaizen-deck"), join(home, ".claude/skills/kaizen-deck"));
22
+ symlinkSync(join(repo, "skills/kaizen"), join(home, ".claude/skills/kaizen"));
23
+ });
24
+ afterEach(() => rmSync(t, { recursive: true, force: true }));
25
+ const link = () => join(home, ".claude/skills/kaizen-deck");
26
+
27
+ test("a new folder appears by itself, with its description; real skills all parse", () => {
28
+ skill("media/new-one");
29
+ const s = bundledSkills(repo).find((x) => x.id === "new-one")!;
30
+ expect([s.group, s.description]).toEqual(["media", "Does a thing."]);
31
+ const real = bundledSkills(join(import.meta.dir, ".."));
32
+ expect(real.map((x) => x.id).sort()).toEqual(["kaizen", "kaizen-book", "kaizen-computer", "kaizen-deck", "kaizen-help", "kaizen-video"]);
33
+ expect(real.filter((x) => x.group === "core").length).toBe(2);
34
+ for (const x of real) expect(x.description.length).toBeGreaterThan(10);
35
+ });
36
+ test("off removes our link and remembers; on restores it", () => {
37
+ expect(setSkill(repo, home, "kaizen-deck", false)).toBeNull();
38
+ expect(existsSync(link())).toBe(false);
39
+ expect(existsSync(join(repo, "skills/media/kaizen-deck/SKILL.md"))).toBe(true);
40
+ expect(skillsOff(home)).toEqual(["kaizen-deck"]);
41
+ expect(setSkill(repo, home, "kaizen-deck", true)).toBeNull();
42
+ expect(lstatSync(link()).isSymbolicLink()).toBe(true);
43
+ expect(skillsOff(home)).toEqual([]);
44
+ });
45
+ test("a real folder and a foreign link under the name stay", () => {
46
+ rmSync(link());
47
+ mkdirSync(link());
48
+ writeFileSync(join(link(), "mine"), "x");
49
+ setSkill(repo, home, "kaizen-deck", false);
50
+ expect(readFileSync(join(link(), "mine"), "utf8")).toBe("x");
51
+ expect(skillStatus(bundledSkills(repo)[1]!, home)[0]!.state).toBe("other");
52
+ rmSync(link(), { recursive: true });
53
+ mkdirSync(join(t, "skills/media/kaizen-deck"), { recursive: true }); // not a clone: no cli/install.ts
54
+ symlinkSync(join(t, "skills/media/kaizen-deck"), link());
55
+ setSkill(repo, home, "kaizen-deck", false);
56
+ expect(lstatSync(link()).isSymbolicLink()).toBe(true);
57
+ });
58
+ test("core and unknown names are refused", () => {
59
+ expect(setSkill(repo, home, "kaizen", false)).toMatch(/Core/);
60
+ expect(existsSync(join(home, ".claude/skills/kaizen"))).toBe(true);
61
+ expect(setSkill(repo, home, "../../x", false)).toBe("unknown skill");
62
+ });
63
+ test("the agent list stays the installer's, and install filters the off-list", () => {
64
+ const src = readFileSync(join(import.meta.dir, "install.ts"), "utf8");
65
+ for (const h of SKILL_HOMES) expect(src).toContain(`dir: "${h.dir}"`);
66
+ expect(dirname(link())).toContain(".claude");
67
+ });
68
+
69
+ test("install: off skills stay out globally, not in a project, and core always links", () => {
70
+ const rels = ["kaizen", "media/kaizen-deck"], off = ["kaizen", "kaizen-deck"];
71
+ expect(skillsToLink(rels, off, true)).toEqual(["kaizen"]);
72
+ expect(skillsToLink(rels, off, false)).toEqual(rels);
73
+ });
74
+ test("core holds with no manifest; a whole description is read; a restore follows the installed clone", () => {
75
+ rmSync(join(repo, "skills/kaizen/skill.json"));
76
+ expect(setSkill(repo, home, "kaizen", false)).toMatch(/Core/);
77
+ writeFileSync(join(repo, "skills/kaizen/SKILL.md"), "---\nname: x\ndescription: One line\n goes on here. Next.\nother: y\n---\n");
78
+ expect(bundledSkills(repo)[0]!.description).toBe("One line goes on here.");
79
+ const other = join(t, "clone");
80
+ mkdirSync(join(other, "cli"), { recursive: true });
81
+ writeFileSync(join(other, "cli", "install.ts"), "");
82
+ mkdirSync(join(other, "skills/media/kaizen-deck"), { recursive: true });
83
+ mkdirSync(join(other, "skills/kaizen"), { recursive: true });
84
+ rmSync(join(home, ".claude/skills/kaizen"));
85
+ symlinkSync(join(other, "skills/kaizen"), join(home, ".claude/skills/kaizen"));
86
+ rmSync(link());
87
+ setSkill(repo, home, "kaizen-deck", true);
88
+ expect(readlinkSync(link())).toBe(join(other, "skills/media/kaizen-deck"));
89
+ });
package/cli/skills.ts ADDED
@@ -0,0 +1,112 @@
1
+ // The skills kaizen ships: each folder under skills/ with a SKILL.md, plus an optional
2
+ // skill.json ({ title, group, needs, off_by_default }), so a new folder needs no change elsewhere.
3
+ // Turning one off removes kaizen's own links for this user; a real folder, or a link to
4
+ // anything else, under the same name stays. ~/.kaizen/skills-off.json keeps the choice.
5
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
6
+ import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
7
+
8
+ export type Skill = { id: string; rel: string; title: string; description: string; group: "core" | "media" | "optional"; needs: string[]; offByDefault: boolean };
9
+ export const SKILL_HOMES = [
10
+ { name: "Claude Code", dir: ".claude" }, { name: "Codex", dir: ".codex" }, { name: "Antigravity", dir: ".agents" },
11
+ { name: "OpenCode", dir: ".opencode" }, { name: "Cursor", dir: ".cursor" }, { name: "Gemini CLI", dir: ".gemini" },
12
+ ];
13
+
14
+ // Core by name, so a lost manifest or an edited off-list can never remove the workflow.
15
+ const CORE = ["kaizen", "kaizen-help"];
16
+
17
+ function frontMatter(text: string) {
18
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? "";
19
+ const d = /^description:[ \t]*(?:[>|][-+]?[ \t]*\r?\n)?([\s\S]*?)(?=\r?\n[A-Za-z_-]+:|(?![\s\S]))/m.exec(fm)?.[1] ?? "";
20
+ const line = d.replace(/\s+/g, " ").replace(/^["']|["']$/g, "").trim();
21
+ const first = /^.*?[.!?](?=\s|$)/.exec(line)?.[0] ?? line;
22
+ return first.length <= 200 ? first : first.slice(0, 200).replace(/\s+\S*$/, "") + "…";
23
+ }
24
+
25
+ export function bundledSkills(repo: string): Skill[] {
26
+ const root = join(repo, "skills");
27
+ const sub = (d: string) => (existsSync(join(root, d)) ? readdirSync(join(root, d)).map((n) => `${d}/${n}`) : []);
28
+ const rels = [...readdirSync(root), ...sub("media"), ...sub("optional")];
29
+ return rels.filter((rel) => existsSync(join(root, rel, "SKILL.md"))).map((rel) => {
30
+ let m: any = {};
31
+ try { m = JSON.parse(readFileSync(join(root, rel, "skill.json"), "utf8")); } catch { /* a folder alone is enough */ }
32
+ const group = CORE.includes(basename(rel)) ? "core" : m.group === "media" || rel.startsWith("media/") ? "media" : "optional";
33
+ return { id: basename(rel), rel, title: String(m.title ?? basename(rel)), description: frontMatter(readFileSync(join(root, rel, "SKILL.md"), "utf8")), group, needs: Array.isArray(m.needs) ? m.needs.map(String) : [], offByDefault: group !== "core" && m.off_by_default === true };
34
+ });
35
+ }
36
+
37
+ const offFile = (home: string) => join(home, ".kaizen", "skills-off.json");
38
+ export function skillsOff(home: string): string[] {
39
+ try { const v = JSON.parse(readFileSync(offFile(home), "utf8")); return Array.isArray(v) ? v.filter((x) => typeof x === "string") : []; } catch { return []; }
40
+ }
41
+
42
+ // A skill with off_by_default stays out until the user turns it on; ~/.kaizen/skills-on.json
43
+ // keeps that choice. `held` is the ones still waiting, whoever installs.
44
+ const onFile = (home: string) => join(home, ".kaizen", "skills-on.json");
45
+ export function skillsOn(home: string): string[] {
46
+ try { const v = JSON.parse(readFileSync(onFile(home), "utf8")); return Array.isArray(v) ? v.filter((x) => typeof x === "string") : []; } catch { return []; }
47
+ }
48
+ export const skillsHeld = (repo: string, home: string) => {
49
+ const on = skillsOn(home);
50
+ return bundledSkills(repo).filter((s) => s.offByDefault && !on.includes(s.id)).map((s) => s.id);
51
+ };
52
+
53
+ // What an install links. The off-list is the user's global choice: a project install is
54
+ // its own decision, and core is never off. `held` binds every install.
55
+ export const skillsToLink = (rels: string[], off: string[], global: boolean, held: string[] = []) =>
56
+ rels.filter((r) => CORE.includes(basename(r)) || (!held.includes(basename(r)) && (!global || !off.includes(basename(r)))));
57
+
58
+ const isLink = (p: string) => { try { return lstatSync(p).isSymbolicLink(); } catch { return false; } };
59
+ // Ours: a link into some kaizen clone's skills/<rel>, this one or the installed one.
60
+ function ours(p: string, rel: string) {
61
+ if (!isLink(p)) return false;
62
+ const raw = readlinkSync(p), target = resolve(isAbsolute(raw) ? raw : join(dirname(p), raw));
63
+ const tail = `${sep}skills${sep}${rel.split("/").join(sep)}`;
64
+ return target.endsWith(tail) && existsSync(join(target.slice(0, -tail.length), "cli", "install.ts"));
65
+ }
66
+
67
+ export function skillStatus(skill: Skill, home: string) {
68
+ return SKILL_HOMES.filter((h) => existsSync(join(home, h.dir))).map((h) => {
69
+ const p = join(home, h.dir, "skills", skill.id);
70
+ const present = existsSync(p) || isLink(p);
71
+ return { agent: h.name, state: !present ? "missing" : ours(p, skill.rel) ? "installed" : "other" };
72
+ });
73
+ }
74
+
75
+ // The clone the core link points at, so a restored link matches its neighbours.
76
+ function installedClone(home: string, repo: string) {
77
+ for (const h of SKILL_HOMES) {
78
+ const p = join(home, h.dir, "skills", "kaizen");
79
+ if (!ours(p, "kaizen")) continue;
80
+ const raw = readlinkSync(p);
81
+ return dirname(dirname(resolve(isAbsolute(raw) ? raw : dirname(p), raw)));
82
+ }
83
+ return repo;
84
+ }
85
+
86
+ // Returns an error, or null. Global links only: a project's own install is left alone.
87
+ // A skill off by default is turned on only with confirm, which the page sends after its warning.
88
+ export function setSkill(repo: string, home: string, id: string, on: boolean, confirm = false): string | null {
89
+ const skill = bundledSkills(repo).find((s) => s.id === id);
90
+ if (!skill) return "unknown skill";
91
+ if (skill.group === "core") return "Core skills can't be turned off";
92
+ if (on && skill.offByDefault && !confirm) return "confirm required";
93
+ const clone = installedClone(home, repo);
94
+ for (const h of SKILL_HOMES) {
95
+ if (!existsSync(join(home, h.dir))) continue;
96
+ const dir = join(home, h.dir, "skills"), p = join(dir, id);
97
+ if (!on) { if (ours(p, skill.rel)) unlinkSync(p); continue; }
98
+ if (existsSync(p) || isLink(p)) continue;
99
+ mkdirSync(dir, { recursive: true });
100
+ symlinkSync(join(clone, "skills", skill.rel), p, process.platform === "win32" ? "junction" : undefined);
101
+ }
102
+ const save = (file: string, list: Set<string>) => {
103
+ mkdirSync(join(home, ".kaizen"), { recursive: true });
104
+ writeFileSync(`${file}.tmp`, JSON.stringify([...list], null, 2));
105
+ renameSync(`${file}.tmp`, file);
106
+ };
107
+ const off = new Set(skillsOff(home));
108
+ on ? off.delete(id) : off.add(id);
109
+ save(offFile(home), off);
110
+ if (skill.offByDefault) { const list = new Set(skillsOn(home)); on ? list.add(id) : list.delete(id); save(onFile(home), list); }
111
+ return null;
112
+ }
package/cli/sources.ts CHANGED
@@ -135,7 +135,7 @@ const isCommand = (t: string) => COMMANDS.has((/[a-z][a-z-]*/i.exec(t.split(" ")
135
135
  // drops a `<where> - <severity> -` or `<severity>:` lead and every backtick. The
136
136
  // check is on that final text, whatever parseItem did to get there; the kind the
137
137
  // user chose, when it is still in front, is theirs and set aside.
138
- const obeyed = (t: string) => isCommand(t) || ["", "full ", "lite "].some((kind) => {
138
+ export const obeyed = (t: string) => isCommand(t) || ["", "full ", "lite "].some((kind) => {
139
139
  const sent = parseItem(kind + t).text;
140
140
  return isCommand(kind && sent.startsWith(kind) ? sent.slice(kind.length) : sent);
141
141
  });
package/cli/state.test.ts CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  readRuns, readInbox, writeInbox, replaceIdea, moveIdea, abandonRun, runToIdea, allBacklog, backlog,
11
11
  requestTitle, statusOf, columnOf, parseItem, startedRuns, boardCards, parentOf, addCard, readArchive, setArchived,
12
12
  requestOf, agentFlags, plainModel, readNotes, writeNotes, manualCommand, parseNotes, formatNote, appendNote, saveAttachment,
13
- reviewFindings, pickFindings, fixPrompt, approvalPrompt, sessionLaunch, closeSessions, sweepSessions, readSessions, ownerOf, gitStatus, runGit, cardsGit, commitPush, commitStaged, stageFiles, suggestMessage, readCommit, findTerminal, nativePath, pruneRuns, unrechecked, notice, notifier, notifyArgs, winToastArgs, LOGO, type Card,
13
+ gitStatus, reviewFindings, pickFindings, fixPrompt, approvalPrompt, sessionLaunch, closeSessions, sweepSessions, readSessions, ownerOf, gitStatus, runGit, cardsGit, commitPush, commitStaged, stageFiles, suggestMessage, readCommit, findTerminal, nativePath, pruneRuns, unrechecked, notice, notifier, notifyArgs, winToastArgs, LOGO, type Card,
14
14
  } from "./state.ts";
15
15
 
16
16
  let state: string;
@@ -588,6 +588,29 @@ test("commitPush: commits the run's files only, pushes, and records it; the mess
588
588
  expect(cardsGit(join(root, ".kaizen"), ["r1"])).toEqual({}); // not a repo
589
589
  }, 60_000); // dozens of git calls, ~250ms each on Windows
590
590
 
591
+ test("runGit: a recorded commit rebased away still closes the run", () => {
592
+ const proj = mkdtempSync(join(tmpdir(), "kz-git-")), st = join(proj, ".kaizen"), run = join(st, "runs", "gone");
593
+ const sh = (...a: string[]) => Bun.spawnSync(["git", "-C", proj, ...a], { env: { ...process.env, GIT_COMMITTER_DATE: "2001-01-01T00:00:00Z" } });
594
+ const bare = proj + "-remote.git";
595
+ Bun.spawnSync(["git", "init", "-q", "--bare", bare]);
596
+ sh("init", "-q");
597
+ sh("remote", "add", "origin", bare);
598
+ for (const kv of [["user.name", "t"], ["user.email", "t@t"], ["commit.gpgsign", "false"], ["core.hooksPath", "/dev/null"]]) sh("config", ...kv);
599
+ mkdirSync(run, { recursive: true });
600
+ writeFileSync(join(proj, ".gitignore"), ".kaizen/\n");
601
+ writeFileSync(join(proj, "z.txt"), "1");
602
+ sh("add", "-A");
603
+ sh("commit", "-qm", "chore: z");
604
+ sh("push", "-qu", "origin", "HEAD");
605
+ writeFileSync(join(run, "03-impl.md"), "- `z.txt`: z\n");
606
+ writeFileSync(join(proj, "z.txt"), "2");
607
+ utimesSync(join(run, "03-impl.md"), new Date(Date.now() - 60_000), new Date(Date.now() - 60_000));
608
+ expect(runGit(st, "gone").files).toEqual([" M z.txt"]);
609
+ writeFileSync(join(run, "07-commit.md"), "commit: abc1234\npushed: no\n");
610
+ utimesSync(join(run, "07-commit.md"), new Date(Date.now() - 30_000), new Date(Date.now() - 30_000));
611
+ expect(runGit(st, "gone").files).toEqual([]);
612
+ });
613
+
591
614
  test("runGit, cardsGit: a run committed elsewhere is not offered the edits made since, nor another run's unpushed commit", () => {
592
615
  const root = mkdtempSync(join(tmpdir(), "kz-git-"));
593
616
  const bare = join(root, "remote.git"), proj = join(root, "proj"), st = join(proj, ".kaizen");
@@ -1497,7 +1520,7 @@ test("stageFiles, commitStaged, suggestMessage: only the run's files are staged,
1497
1520
  expect(stageFiles(st, "r1", "discard", ["new.txt"])).toBeNull();
1498
1521
  expect(existsSync(join(proj, "new.txt"))).toBe(false);
1499
1522
  expect(stageFiles(st, "r1", "discard", ["a.txt"])).toBeNull();
1500
- expect(readFileSync(join(proj, "a.txt"), "utf8")).toBe("one\ntwo\n");
1523
+ expect(readFileSync(join(proj, "a.txt"), "utf8").replace(/\r/g, "")).toBe("one\ntwo\n"); // git may check out CRLF on Windows
1501
1524
  expect(readFileSync(join(proj, "other.txt"), "utf8")).toBe("changed\n"); // not the run's, untouched
1502
1525
  writeFileSync(join(proj, "a.txt"), "one\nTWO\nthree\n");
1503
1526
  // Plain Commit: nothing staged, a stale list, another file staged by hand, all refused.
@@ -1510,7 +1533,8 @@ test("stageFiles, commitStaged, suggestMessage: only the run's files are staged,
1510
1533
  expect((commitStaged(st, "r1", "no type", ["a.txt"]) as any).why).toContain("Start the message with a type");
1511
1534
  // The sparkle: with no claude on PATH the message is built from the file names, and it passes the type check.
1512
1535
  const path = process.env.PATH;
1513
- process.env.PATH = "";
1536
+ // On Windows git needs its full PATH, so only folders holding claude go.
1537
+ process.env.PATH = process.platform === "win32" ? path!.split(";").filter((d) => !Bun.which("claude", { PATH: d })).join(";") : "";
1514
1538
  try {
1515
1539
  const m = await suggestMessage(st, "r1");
1516
1540
  expect(m).toEqual({ ok: true, message: "chore: update a.txt", ai: false });
@@ -1525,7 +1549,7 @@ test("stageFiles, commitStaged, suggestMessage: only the run's files are staged,
1525
1549
  expect(stageFiles(st, "r1", "discard", ["a.txt"])).toBe("Not this run's: a.txt");
1526
1550
  expect(readFileSync(join(proj, "a.txt"), "utf8")).toBe("junk\n");
1527
1551
  rmSync(root, { recursive: true, force: true });
1528
- });
1552
+ }, 30_000); // real git, many calls: Windows CI takes 6-8 s, and a timed-out test has its children killed
1529
1553
 
1530
1554
  test("runGit: a run owns the files its report lists as changed, not ones it only mentions", () => {
1531
1555
  const proj = mkdtempSync(join(tmpdir(), "kaizen-own-")), st = join(proj, ".kaizen"), g = (...a: string[]) => Bun.spawnSync(["git", "-C", proj, ...a]);
@@ -1565,3 +1589,28 @@ test("a committed run does not claim a file edited after its commit", () => {
1565
1589
  expect(after.r1).not.toBe("commit");
1566
1590
  rmSync(root, { recursive: true, force: true });
1567
1591
  });
1592
+
1593
+ test("a recheck closes a finding with \"closed\" or \"PASS\", never with FAIL", () => {
1594
+ const st = mkdtempSync(join(tmpdir(), "kz-find-")), d = join(st, "runs", "r");
1595
+ mkdirSync(join(d, "05-iterations"), { recursive: true });
1596
+ writeFileSync(join(d, "04-review.md"), "1. a: low: one\n2. b: low: two\n3. c: low: three\n");
1597
+ writeFileSync(join(d, "05-iterations", "01-recheck.md"), "Finding 1 PASS: ok\nFinding 2 closed\nFinding 3 FAIL: no\n");
1598
+ expect(reviewFindings(st, "r").map((f) => f.done)).toEqual([true, true, false]);
1599
+ });
1600
+
1601
+ test("a git that can't answer is not reported as no repo", () => {
1602
+ const dir = mkdtempSync(join(tmpdir(), "kz-nogit-")), path = process.env.PATH;
1603
+ expect(gitStatus(dir)).toEqual({ repo: false });
1604
+ // A stand-in git that dies with no answer, as a killed one does.
1605
+ writeFileSync(join(dir, "git"), "#!/bin/sh\nexit 137\n", { mode: 0o755 });
1606
+ writeFileSync(join(dir, "git.cmd"), "@exit /b 137\n");
1607
+ process.env.PATH = `${dir}${process.platform === "win32" ? ";" : ":"}${path}`;
1608
+ try { expect(gitStatus(dir)).toEqual({ repo: false, failed: true }); } finally { process.env.PATH = path; }
1609
+ });
1610
+
1611
+ test("a tool's Settings model reaches its launch flag, ahead of a hand-written block", () => {
1612
+ expect(agentFlags("/x", "codex", 'agent:\n default: auto\n model:\n agy: ""\n codex: gpt-x\n')).toEqual(["-m", "gpt-x"]);
1613
+ expect(agentFlags("/x", "agy", 'agent:\n model:\n agy: ""\n codex: gpt-x\n')).toEqual([]);
1614
+ expect(agentFlags("/x", "codex", "agent:\n codex: { model: old, effort: low }\n model:\n codex: new\n")).toEqual(["-m", "new", "-c", "model_reasoning_effort=low"]);
1615
+ expect(agentFlags("/x", "codex", "agent:\n codex: { model: old }\n")).toEqual(["-m", "old"]);
1616
+ });