kaizen-agent 1.64.3 → 1.66.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/install.ts +13 -2
- package/cli/roadmap.ts +74 -0
- package/cli/skills.ts +1 -1
- package/cli/web.ts +64 -2
- package/commands/kaizen-concept.md +6 -0
- package/commands/kaizen-roadmap.md +6 -0
- package/package.json +4 -2
- package/skills/kaizen/SKILL.md +12 -0
- package/skills/kaizen/roadmap.md +25 -0
- package/skills/kaizen/spec-main.md +27 -0
- package/skills/kaizen/spec-plan.md +37 -11
- package/skills/kaizen-concept/SKILL.md +416 -0
- package/skills/kaizen-concept/skill.json +1 -0
- package/skills/kaizen-concept/ux-rules.md +272 -0
- package/skills/kaizen-help/SKILL.md +2 -0
- package/web/board/chat.ts +4 -3
- package/web/board/run-view.ts +18 -3
- package/web/board/ws-tabs.ts +9 -0
- package/web/board.js +102 -102
- package/web/notebook.js +1 -1
- package/web/term.js +1 -1
- package/web/video.js +1 -1
- package/cli/__pycache__/computer-helper.cpython-314.pyc +0 -0
- package/cli/accounts.test.ts +0 -126
- package/cli/add-project.test.ts +0 -169
- package/cli/agent-prefs.test.ts +0 -127
- package/cli/automations.test.ts +0 -167
- package/cli/backlog.test.ts +0 -133
- package/cli/board.test.ts +0 -381
- package/cli/browser.test.ts +0 -132
- package/cli/chat.test.ts +0 -274
- package/cli/chatgpt.test.ts +0 -158
- package/cli/computer.test.ts +0 -155
- package/cli/docs.test.ts +0 -94
- package/cli/handoff.test.ts +0 -133
- package/cli/html.test.ts +0 -19
- package/cli/install.test.ts +0 -237
- package/cli/knowledge.test.ts +0 -179
- package/cli/localsend.test.ts +0 -84
- package/cli/logo.test.ts +0 -18
- package/cli/notes.test.ts +0 -249
- package/cli/onboarding.test.ts +0 -70
- package/cli/project-tree.test.ts +0 -40
- package/cli/pty.test.ts +0 -330
- package/cli/release.test.ts +0 -12
- package/cli/report.test.ts +0 -59
- package/cli/resources.test.ts +0 -50
- package/cli/restart.test.ts +0 -222
- package/cli/settings.test.ts +0 -168
- package/cli/setup.test.ts +0 -78
- package/cli/shell-agent.test.ts +0 -23
- package/cli/skills.test.ts +0 -95
- package/cli/sources.test.ts +0 -851
- package/cli/state.test.ts +0 -1639
- package/cli/term-image.test.ts +0 -23
- package/cli/usage.test.ts +0 -291
- package/cli/versions.test.ts +0 -154
- package/cli/video.test.ts +0 -545
- package/cli/web-accept.test.ts +0 -55
- package/cli/web-decide.test.ts +0 -54
- package/cli/web-pr.test.ts +0 -52
- package/cli/web-skills.test.ts +0 -32
- package/cli/web-symlink.test.ts +0 -29
- package/cli/workers.test.ts +0 -319
- package/cli/worktree.test.ts +0 -452
- package/cli/writeback.test.ts +0 -102
- package/skills/media/kaizen-video/scripts/__pycache__/intake.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/make_film.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/make_tiktok.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/render_cut.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/sfx.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/srt.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/transcribe.cpython-314.pyc +0 -0
- package/skills/media/kaizen-video/scripts/__pycache__/vo.cpython-314.pyc +0 -0
- package/web/board/search.test.ts +0 -20
- package/web/board/settings-pages.test.ts +0 -28
- package/web/board/settings-voice.test.ts +0 -18
- package/web/board/toast.test.ts +0 -77
- package/web/board/ws-board.test.ts +0 -77
- package/web/board/ws-name.test.ts +0 -10
- package/web/board/ws-tabs.test.ts +0 -213
- package/web/term-font.test.ts +0 -22
package/cli/docs.test.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test";
|
|
2
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, utimesSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { lintDocs } from "./docs.ts";
|
|
6
|
-
|
|
7
|
-
const fixture = (updated = "2026-10-28") => {
|
|
8
|
-
const root = mkdtempSync(join(tmpdir(), "kz-docs-lint-"));
|
|
9
|
-
const vault = join(root, ".kaizen", "notes", "Project");
|
|
10
|
-
mkdirSync(vault, { recursive: true });
|
|
11
|
-
writeFileSync(join(root, "app.ts"), "export const app = 1;\n");
|
|
12
|
-
writeFileSync(join(vault, "Index.md"), `---\ndescription: Index\ntags: [project, index]\nupdated: ${updated}\n---\n# Index\n[[App]]\n`);
|
|
13
|
-
writeFileSync(join(vault, "App.md"), `---\ndescription: App\ntags: [project, app]\nsources: [app.ts]\nupdated: ${updated}\n---\n# App\n`);
|
|
14
|
-
return { root, vault, cleanup: () => rmSync(root, { recursive: true, force: true }) };
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
test("clean vault, nested CLI invocation, and no writes", () => {
|
|
18
|
-
const f = fixture("2020-01-01");
|
|
19
|
-
try {
|
|
20
|
-
// A source written today would be stale against any fixed date: back-date it.
|
|
21
|
-
utimesSync(join(f.root, "app.ts"), new Date("2020-01-01T10:00:00"), new Date("2020-01-01T10:00:00"));
|
|
22
|
-
const nested = join(f.root, "inside"); mkdirSync(nested);
|
|
23
|
-
const before = readFileSync(join(f.vault, "App.md"));
|
|
24
|
-
const p = Bun.spawnSync([process.execPath, join(import.meta.dir, "install.ts"), "docs", "lint"], { cwd: nested });
|
|
25
|
-
expect(p.exitCode).toBe(0);
|
|
26
|
-
expect(p.stdout.toString()).toContain("docs lint: clean");
|
|
27
|
-
expect(readFileSync(join(f.vault, "App.md"))).toEqual(before);
|
|
28
|
-
expect(lintDocs(f.root)).toEqual([]);
|
|
29
|
-
} finally { f.cleanup(); }
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("reports links, metadata, missing and uncovered sources, and long Index", () => {
|
|
33
|
-
const f = fixture();
|
|
34
|
-
try {
|
|
35
|
-
writeFileSync(join(f.vault, "Index.md"), `---\ndescription: Index\ntags: [project, index]\nupdated: 2026-10-28\n---\n# Index\n[[App]]\n${"line\n".repeat(54)}`);
|
|
36
|
-
writeFileSync(join(f.vault, "App.md"), "---\ndescription: App\ntags: [project, app]\nsources: [gone.ts]\n---\n# App\n[[Missing]] `[[code]]` [[run:x]]\n");
|
|
37
|
-
writeFileSync(join(f.vault, "Unlisted.md"), "# unlisted\n");
|
|
38
|
-
const found = lintDocs(f.root).join("\n");
|
|
39
|
-
for (const s of ["under 60 lines", "broken link [[Missing]]", "missing updated", "missing source gone.ts", "uncovered: app.ts", "not listed in Index.md", "missing description", "missing sources"]) expect(found).toContain(s);
|
|
40
|
-
expect(found).not.toContain("[[code]]");
|
|
41
|
-
expect(found).not.toContain("[[run:x]]");
|
|
42
|
-
} finally { f.cleanup(); }
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("outside git, same-day source mtimes are covered and later ones are stale", () => {
|
|
46
|
-
const f = fixture("2020-01-01");
|
|
47
|
-
try {
|
|
48
|
-
const file = join(f.root, "app.ts");
|
|
49
|
-
utimesSync(file, new Date("2020-01-01T10:00:00"), new Date("2020-01-01T10:00:00"));
|
|
50
|
-
expect(lintDocs(f.root)).toEqual([]);
|
|
51
|
-
utimesSync(file, new Date("2020-01-02T10:00:00"), new Date("2020-01-02T10:00:00"));
|
|
52
|
-
expect(lintDocs(f.root)).toContain("Project/App.md: stale (sources changed after 2020-01-01)");
|
|
53
|
-
} finally { f.cleanup(); }
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test.skipIf(!Bun.which("git"))("git history detects stale notes; generated and binary files do not require coverage", () => {
|
|
57
|
-
const f = fixture("2020-01-01");
|
|
58
|
-
try {
|
|
59
|
-
const run = (args: string[], env = process.env) => Bun.spawnSync(["git", ...args], { cwd: f.root, env });
|
|
60
|
-
expect(run(["init", "-q"]).exitCode).toBe(0);
|
|
61
|
-
writeFileSync(join(f.root, "app.js"), "built\n");
|
|
62
|
-
writeFileSync(join(f.root, "picture.png"), "binary\n");
|
|
63
|
-
expect(run(["add", "."]).exitCode).toBe(0);
|
|
64
|
-
expect(run(["-c", "user.name=T", "-c", "user.email=t@example.com", "commit", "-qm", "initial"], { ...process.env, GIT_AUTHOR_DATE: "2020-01-01T10:00:00+0000", GIT_COMMITTER_DATE: "2020-01-01T10:00:00+0000" }).exitCode).toBe(0);
|
|
65
|
-
expect(lintDocs(f.root)).toEqual([]);
|
|
66
|
-
const nested = join(f.root, "inside"); mkdirSync(nested);
|
|
67
|
-
expect(Bun.spawnSync([process.execPath, join(import.meta.dir, "install.ts"), "docs", "lint"], { cwd: nested }).exitCode).toBe(0);
|
|
68
|
-
const worktree = join(f.root, ".kaizen", "wt", "lint");
|
|
69
|
-
expect(run(["worktree", "add", "-qb", "lint-branch", worktree]).exitCode).toBe(0);
|
|
70
|
-
const worktreeNote = join(worktree, ".kaizen", "notes", "Project", "App.md");
|
|
71
|
-
writeFileSync(worktreeNote, readFileSync(worktreeNote, "utf8") + "[[Broken]]\n");
|
|
72
|
-
const fromWorktree = Bun.spawnSync([process.execPath, join(import.meta.dir, "install.ts"), "docs", "lint"], { cwd: worktree });
|
|
73
|
-
expect(fromWorktree.exitCode).toBe(1);
|
|
74
|
-
expect(fromWorktree.stdout.toString()).toContain("broken link [[Broken]]");
|
|
75
|
-
writeFileSync(join(f.root, "app.ts"), "export const app = 2;\n");
|
|
76
|
-
expect(run(["add", "app.ts"]).exitCode).toBe(0);
|
|
77
|
-
expect(run(["-c", "user.name=T", "-c", "user.email=t@example.com", "commit", "-qm", "later"], { ...process.env, GIT_AUTHOR_DATE: "2020-01-02T10:00:00+0000", GIT_COMMITTER_DATE: "2020-01-02T10:00:00+0000" }).exitCode).toBe(0);
|
|
78
|
-
expect(lintDocs(f.root)).toContain("Project/App.md: stale (sources changed after 2020-01-01)");
|
|
79
|
-
} finally { f.cleanup(); }
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("missing vault and unsupported CLI arguments fail clearly", () => {
|
|
83
|
-
const root = mkdtempSync(join(tmpdir(), "kz-docs-none-"));
|
|
84
|
-
try {
|
|
85
|
-
expect(lintDocs(root)).toContain("missing Project/Index.md (run /kaizen docs first)");
|
|
86
|
-
mkdirSync(join(root, ".kaizen"));
|
|
87
|
-
const absent = Bun.spawnSync([process.execPath, join(import.meta.dir, "install.ts"), "docs", "lint"], { cwd: root });
|
|
88
|
-
expect(absent.exitCode).toBe(1);
|
|
89
|
-
expect(absent.stdout.toString()).toContain("missing Project/Index.md");
|
|
90
|
-
const p = Bun.spawnSync([process.execPath, join(import.meta.dir, "install.ts"), "docs", "other"], { cwd: root });
|
|
91
|
-
expect(p.exitCode).toBe(1);
|
|
92
|
-
expect(p.stdout.toString()).toContain("kaizen docs lint");
|
|
93
|
-
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
94
|
-
});
|
package/cli/handoff.test.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { test, expect, beforeEach } from "bun:test";
|
|
2
|
-
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { move, awaitBoard, childDied, childQuiet, QUIET_MS, finish, markWoken, requestOpen, readHandoff, request, REQUEST_MS, started, wakeAction, wakeLine, type Handoff } from "./handoff.ts";
|
|
6
|
-
import { agentLine } from "./workers.ts";
|
|
7
|
-
|
|
8
|
-
const ID = "2026-11-01-x";
|
|
9
|
-
let state: string;
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
state = mkdtempSync(join(tmpdir(), "hand-"));
|
|
12
|
-
mkdirSync(join(state, "runs", ID), { recursive: true });
|
|
13
|
-
writeFileSync(join(state, "runs", ID, "state.json"), "{}");
|
|
14
|
-
});
|
|
15
|
-
const idle = { alive: true, busy: false, asking: false, typedAt: 0 };
|
|
16
|
-
const ended = (o: Partial<Handoff> = {}): Handoff => ({ status: "done", parent_terminal: "sh-1", at: 0, ...o });
|
|
17
|
-
|
|
18
|
-
test("G-04 outside a board terminal nothing is requested", () => {
|
|
19
|
-
expect(request(state, ID, undefined)).toBeNull();
|
|
20
|
-
expect(readHandoff(state, ID)).toBeNull();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("G-04 no answer declines, so a late board opens nothing", async () => {
|
|
24
|
-
request(state, ID, "sh-1");
|
|
25
|
-
expect(await awaitBoard(state, ID, 30, 5)).toBe(false);
|
|
26
|
-
const h = readHandoff(state, ID)!;
|
|
27
|
-
expect(h.status).toBe("declined");
|
|
28
|
-
expect(requestOpen(h, h.at)).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("G-04 an old request is not acted on", () => {
|
|
32
|
-
expect(requestOpen(ended({ status: "requested", at: 0 }), REQUEST_MS + 1)).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("the board's answer ends the wait", async () => {
|
|
36
|
-
request(state, ID, "sh-1"); started(state, ID, "sh-2");
|
|
37
|
-
expect(await awaitBoard(state, ID, 30, 5)).toBe(true);
|
|
38
|
-
expect(readHandoff(state, ID)!.child_terminal).toBe("sh-2");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("only a running handoff takes a result", () => {
|
|
42
|
-
expect(finish(state, ID, "done")).toContain("no handoff");
|
|
43
|
-
request(state, ID, "sh-1");
|
|
44
|
-
expect(finish(state, ID, "done")).toContain("requested");
|
|
45
|
-
started(state, ID, "sh-2");
|
|
46
|
-
expect(finish(state, ID, "blocked", "why")).toBeNull();
|
|
47
|
-
expect(finish(state, ID, "done")).not.toBeNull();
|
|
48
|
-
expect(readHandoff(state, ID)).toMatchObject({ status: "blocked", reason: "why" });
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test("G-05 a wake is held while busy, asking or typing, then sent once", () => {
|
|
52
|
-
expect(wakeAction(ended(), { ...idle, busy: true }, 1e6)).toBe("wait");
|
|
53
|
-
expect(wakeAction(ended(), { ...idle, asking: true }, 1e6)).toBe("wait");
|
|
54
|
-
expect(wakeAction(ended(), { ...idle, typedAt: 1e6 - 1000 }, 1e6)).toBe("wait");
|
|
55
|
-
expect(wakeAction(ended(), idle, 1e6)).toBe("send");
|
|
56
|
-
expect(wakeAction(ended({ woken: true }), idle, 1e6)).toBe("none");
|
|
57
|
-
expect(wakeAction(ended({ status: "running" }), idle, 1e6)).toBe("none");
|
|
58
|
-
request(state, ID, "sh-1"); started(state, ID, "sh-2"); finish(state, ID, "done"); markWoken(state, ID);
|
|
59
|
-
expect(wakeAction(readHandoff(state, ID), idle, 1e6)).toBe("none");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("G-06 a dead child fails, and a dead parent is reported, not typed at", () => {
|
|
63
|
-
expect(childDied(ended({ status: "running" }), false)).toBe(true);
|
|
64
|
-
expect(childDied(ended({ status: "running" }), true)).toBe(false);
|
|
65
|
-
expect(childDied(ended(), false)).toBe(false);
|
|
66
|
-
expect(wakeAction(ended({ status: "failed" }), idle, 1e6)).toBe("send");
|
|
67
|
-
expect(wakeAction(ended(), null, 1e6)).toBe("gone");
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("G-04 a second agent that already finished is not mistaken for no board", async () => {
|
|
71
|
-
request(state, ID, "sh-1"); started(state, ID, "sh-2"); finish(state, ID, "done");
|
|
72
|
-
expect(await awaitBoard(state, ID, 30, 5)).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test("G-05 the wake line reaches a real terminal, submitted", async () => {
|
|
76
|
-
const { startPty, submitPty, ptyTail } = await import("./pty.ts");
|
|
77
|
-
if (process.platform === "win32") return;
|
|
78
|
-
startPty("hand-wake", ["sh", "-c", "timeout 1 cat"], state);
|
|
79
|
-
submitPty("hand-wake", wakeLine(ID, ended()), 20);
|
|
80
|
-
await Bun.sleep(200);
|
|
81
|
-
expect(ptyTail("hand-wake")).toContain(`kaizen run ${ID}: the worktree agent ended (done)`);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("G-07 the second agent never takes bypass", () => {
|
|
85
|
-
const project = join(state, "p");
|
|
86
|
-
mkdirSync(join(project, ".kaizen", "runs", ID), { recursive: true });
|
|
87
|
-
writeFileSync(join(project, ".kaizen", "runs", ID, "state.json"), JSON.stringify({ agent: "claude" }));
|
|
88
|
-
const l = agentLine(project, ID, "hi", "own");
|
|
89
|
-
if (typeof l !== "string") { expect(l.bypass).toBe(false); expect(l.argv.join(" ")).not.toContain("dangerously"); }
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test("a silent child goes quiet, wakes the parent, and can still report", () => {
|
|
93
|
-
const pty = { alive: true, busy: false, asking: false, lastOut: 0 };
|
|
94
|
-
expect(childQuiet(ended({ status: "running" }), pty, QUIET_MS + 1)).toBe(true);
|
|
95
|
-
expect(childQuiet(ended({ status: "running" }), { ...pty, asking: true }, QUIET_MS + 1)).toBe(false);
|
|
96
|
-
expect(childQuiet(ended({ status: "running" }), pty, QUIET_MS - 1)).toBe(false);
|
|
97
|
-
expect(wakeAction(ended({ status: "quiet" }), idle, 1e6)).toBe("send");
|
|
98
|
-
request(state, ID, "sh-1"); started(state, ID, "sh-2");
|
|
99
|
-
move(state, ID, ["running"], { status: "quiet", woken: true });
|
|
100
|
-
expect(finish(state, ID, "done")).toBeNull();
|
|
101
|
-
expect(wakeAction(readHandoff(state, ID), idle, 1e6)).toBe("send");
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test("cold 1: a second start never replaces a live agent", () => {
|
|
105
|
-
request(state, ID, "sh-1"); started(state, ID, "sh-2");
|
|
106
|
-
expect(request(state, ID, "sh-9")).toMatchObject({ status: "running", child_terminal: "sh-2" });
|
|
107
|
-
finish(state, ID, "blocked", "x");
|
|
108
|
-
expect(request(state, ID, "sh-9")).toMatchObject({ status: "requested", parent_terminal: "sh-9" });
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test("cold 2: claim and decline cannot both win", async () => {
|
|
112
|
-
request(state, ID, "sh-1");
|
|
113
|
-
const claim = setTimeout(() => started(state, ID, "sh-2"), 5);
|
|
114
|
-
await Bun.sleep(10); clearTimeout(claim);
|
|
115
|
-
expect(await awaitBoard(state, ID, 0)).toBe(true);
|
|
116
|
-
writeFileSync(join(state, "runs", ID, "handoff.json"), JSON.stringify({ status: "declined", parent_terminal: "sh-1", at: 0 }));
|
|
117
|
-
expect(started(state, ID, "sh-3")).toBe(false);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test("cold 3: a stale board read cannot overwrite done", () => {
|
|
121
|
-
request(state, ID, "sh-1"); started(state, ID, "sh-2"); finish(state, ID, "done");
|
|
122
|
-
expect(move(state, ID, ["running", "quiet"], { status: "failed" })).toBe(false);
|
|
123
|
-
expect(readHandoff(state, ID)!.status).toBe("done");
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("cold 5: a quiet child that dies counts as dead", () => {
|
|
127
|
-
expect(childDied(ended({ status: "quiet" }), false)).toBe(true);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test("cold 7: a draft holds the wake", () => {
|
|
131
|
-
expect(wakeAction(ended(), { ...idle, draft: true, typedAt: 1e6 - 6000 }, 1e6)).toBe("held");
|
|
132
|
-
expect(wakeAction(ended(), { ...idle, draft: true, typedAt: 1e9 - 11 * 60_000 }, 1e9)).toBe("send");
|
|
133
|
-
});
|
package/cli/html.test.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { html, ico, raw } from "../web/board/dom.ts";
|
|
3
|
-
|
|
4
|
-
test("html escapes interpolations once and keeps trusted markup", () => {
|
|
5
|
-
const bad = '<img src=x onerror=1> & "q"';
|
|
6
|
-
const out = String(html`<b title="${bad}">${bad}</b>`);
|
|
7
|
-
expect(out).not.toContain("<img");
|
|
8
|
-
expect(out).toContain("<img src=x onerror=1> & "q"");
|
|
9
|
-
expect(String(html`${"a&b"}`)).toBe("a&b");
|
|
10
|
-
expect(String(html`${raw("<i>")}${ico("x")}`)).toBe('<i><svg><use href="#i-x"/></svg>');
|
|
11
|
-
expect(String(html`<ul>${[1, 2].map((n) => html`<li>${n}</li>`)}</ul>`)).toBe("<ul><li>1</li><li>2</li></ul>");
|
|
12
|
-
expect(String(html`${["<a>"]}`)).toBe("<a>");
|
|
13
|
-
expect(String(html`[${null}${undefined}${false}]`)).toBe("[]");
|
|
14
|
-
expect(String(html`${html`<u>${"&"}</u>`}`)).toBe("<u>&</u>");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("aria states render false explicitly when stringified", () => {
|
|
18
|
-
expect(String(html`<b aria-pressed="${String(false)}" aria-checked="${String(true)}">`)).toBe('<b aria-pressed="false" aria-checked="true">');
|
|
19
|
-
});
|
package/cli/install.test.ts
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
// `kaizen uninstall` against throwaway folders only. Every path it may delete comes
|
|
2
|
-
// from the env built here (HOME, KAIZEN_HOME, TMPDIR all scratch), never from the
|
|
3
|
-
// real environment: on 2026-10-01 an uninstall pointed at a checkout deleted it.
|
|
4
|
-
// Skipped on Windows: there uninstall also walks every drive (searchRoots) and
|
|
5
|
-
// strips kaizen links from real projects, whatever HOME says.
|
|
6
|
-
import { test, expect } from "bun:test";
|
|
7
|
-
import { mkdtempSync, mkdirSync, writeFileSync, existsSync, rmSync, symlinkSync, cpSync, readFileSync } from "node:fs";
|
|
8
|
-
import { join, dirname } from "node:path";
|
|
9
|
-
import { tmpdir } from "node:os";
|
|
10
|
-
|
|
11
|
-
const script = join(dirname(import.meta.path), "install.ts");
|
|
12
|
-
const it = test.skipIf(process.platform === "win32");
|
|
13
|
-
const REPO = "https://github.com/hfadhlullah/kaizen.git";
|
|
14
|
-
|
|
15
|
-
// `custom` sets KAIZEN_HOME to a folder outside HOME; otherwise it is unset and the
|
|
16
|
-
// install is the scratch home's own ~/kaizen.
|
|
17
|
-
const uninstall = (make: (k: string) => void, custom = false) => {
|
|
18
|
-
const root = mkdtempSync(join(tmpdir(), "kz-uninstall-"));
|
|
19
|
-
const home = join(root, "home"), k = custom ? join(root, "kaizen") : join(home, "kaizen");
|
|
20
|
-
mkdirSync(home);
|
|
21
|
-
make(k);
|
|
22
|
-
const env: Record<string, string> = { PATH: process.env.PATH ?? "", HOME: home, USERPROFILE: home, TMPDIR: root };
|
|
23
|
-
if (custom) env.KAIZEN_HOME = k;
|
|
24
|
-
const p = Bun.spawnSync([process.execPath, script, "uninstall", "--yes"], { cwd: home, env });
|
|
25
|
-
const left = existsSync(k), out = p.stdout.toString();
|
|
26
|
-
rmSync(root, { recursive: true, force: true });
|
|
27
|
-
if (p.exitCode !== 0) throw new Error(p.stderr.toString());
|
|
28
|
-
return { left, out };
|
|
29
|
-
};
|
|
30
|
-
const kaizenFiles = (k: string) => { mkdirSync(join(k, "cli"), { recursive: true }); writeFileSync(join(k, "cli", "install.ts"), ""); };
|
|
31
|
-
// A clone without the network: an empty repository whose origin is `url`.
|
|
32
|
-
const clone = (url: string, dirty = false, more?: (k: string) => void) => (k: string) => {
|
|
33
|
-
mkdirSync(k, { recursive: true });
|
|
34
|
-
Bun.spawnSync(["git", "init", "-q", k]);
|
|
35
|
-
Bun.spawnSync(["git", "-C", k, "remote", "add", "origin", url]);
|
|
36
|
-
if (dirty) writeFileSync(join(k, "mine.txt"), "uncommitted");
|
|
37
|
-
more?.(k);
|
|
38
|
-
};
|
|
39
|
-
// The clone used as a project: its .kaizen/ is ignored, so `status --porcelain` alone reads clean.
|
|
40
|
-
const runs = (k: string) => {
|
|
41
|
-
writeFileSync(join(k, ".git", "info", "exclude"), ".kaizen/\n");
|
|
42
|
-
mkdirSync(join(k, ".kaizen", "runs", "r1"), { recursive: true });
|
|
43
|
-
writeFileSync(join(k, ".kaizen", "runs", "r1", "state.json"), "{}");
|
|
44
|
-
};
|
|
45
|
-
const commit = (k: string) => {
|
|
46
|
-
Bun.spawnSync(["git", "-C", k, "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-q", "--allow-empty", "-m", "mine"]);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
it("uninstall leaves a KAIZEN_HOME other than ~/kaizen, git checkout or not", () => {
|
|
50
|
-
const r = uninstall((k) => { kaizenFiles(k); mkdirSync(join(k, ".git")); }, true);
|
|
51
|
-
expect(r.left).toBe(true);
|
|
52
|
-
expect(r.out).toContain("KAIZEN_HOME is not ~/kaizen");
|
|
53
|
-
expect(uninstall(kaizenFiles, true).left).toBe(true);
|
|
54
|
-
// ~/kaizen is a link to the checkout KAIZEN_HOME names: same realpath, still refused.
|
|
55
|
-
const linked = uninstall((k) => { kaizenFiles(k); mkdirSync(join(k, ".git")); symlinkSync(k, join(dirname(k), "home", "kaizen")); }, true);
|
|
56
|
-
expect(linked.left).toBe(true);
|
|
57
|
-
expect(linked.out).toContain("KAIZEN_HOME is not ~/kaizen");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("uninstall leaves a ~/kaizen that is not a kaizen install", () => {
|
|
61
|
-
const r = uninstall((k) => { mkdirSync(k); writeFileSync(join(k, "notes.txt"), "mine"); });
|
|
62
|
-
expect(r.left).toBe(true);
|
|
63
|
-
expect(r.out).toContain("not a kaizen install");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("uninstall still removes the copy kaizen made without git", () => {
|
|
67
|
-
expect(uninstall(kaizenFiles).left).toBe(false);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it.skipIf(!Bun.which("git"))("uninstall removes a clean clone of kaizen and keeps any other", () => {
|
|
71
|
-
expect(uninstall(clone(REPO)).left).toBe(false);
|
|
72
|
-
expect(uninstall(clone(REPO.replace(/\.git$/, ""))).left).toBe(false);
|
|
73
|
-
const dirty = uninstall(clone(REPO, true));
|
|
74
|
-
expect(dirty.left).toBe(true);
|
|
75
|
-
expect(dirty.out).toContain("local changes");
|
|
76
|
-
const other = uninstall(clone("https://example.com/someone/else.git"));
|
|
77
|
-
expect(other.left).toBe(true);
|
|
78
|
-
expect(other.out).toContain("another repository");
|
|
79
|
-
const used = uninstall(clone(REPO, false, runs));
|
|
80
|
-
expect(used.left).toBe(true);
|
|
81
|
-
expect(used.out).toContain("ignored files");
|
|
82
|
-
const unpushed = uninstall(clone(REPO, false, commit));
|
|
83
|
-
expect(unpushed.left).toBe(true);
|
|
84
|
-
expect(unpushed.out).toContain("commits not pushed");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// An npm package of this checkout, at a version no real release has: no .git, so its
|
|
88
|
-
// installer runs as `bunx kaizen-agent` would. Scratch HOME only; ~/kaizen is a fake.
|
|
89
|
-
const fromPackage = (make: (k: string) => void, custom = false) => {
|
|
90
|
-
const root = mkdtempSync(join(tmpdir(), "kz-replace-"));
|
|
91
|
-
const home = join(root, "home"), pkg = join(root, "pkg");
|
|
92
|
-
const k = custom ? join(root, "kaizen") : join(home, "kaizen");
|
|
93
|
-
mkdirSync(join(home, ".claude"), { recursive: true }); // an agent: the installer stops on a box with none
|
|
94
|
-
const src = dirname(dirname(import.meta.path));
|
|
95
|
-
for (const d of ["cli", "skills", "agents", "commands", "web", "package.json"]) {
|
|
96
|
-
cpSync(join(src, d), join(pkg, d), { recursive: true, filter: (p) => !p.includes("node_modules") });
|
|
97
|
-
}
|
|
98
|
-
const pj = join(pkg, "package.json");
|
|
99
|
-
writeFileSync(pj, readFileSync(pj, "utf8").replace(/"version": "[^"]*"/, '"version": "9.9.9"'));
|
|
100
|
-
make(k);
|
|
101
|
-
const env: Record<string, string> = { PATH: process.env.PATH ?? "", HOME: home, USERPROFILE: home, TMPDIR: root };
|
|
102
|
-
if (custom) env.KAIZEN_HOME = k;
|
|
103
|
-
const p = Bun.spawnSync([process.execPath, join(pkg, "cli", "install.ts"), "--yes", "--global"], { cwd: home, env });
|
|
104
|
-
const r = {
|
|
105
|
-
out: p.stdout.toString(),
|
|
106
|
-
version: existsSync(join(k, "package.json")) ? JSON.parse(readFileSync(join(k, "package.json"), "utf8")).version : null,
|
|
107
|
-
oldKept: existsSync(join(`${k}.old`, "mine.txt")),
|
|
108
|
-
mineInPlace: existsSync(join(k, "mine.txt")),
|
|
109
|
-
};
|
|
110
|
-
rmSync(root, { recursive: true, force: true });
|
|
111
|
-
return r;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
it.skipIf(!Bun.which("git"))("an npm package replaces a ~/kaizen clone with local edits, keeping it as .old", () => {
|
|
115
|
-
const r = fromPackage(clone(REPO, true));
|
|
116
|
-
expect(r.version).toBe("9.9.9");
|
|
117
|
-
expect(r.mineInPlace).toBe(false);
|
|
118
|
-
expect(r.oldKept).toBe(true);
|
|
119
|
-
expect(r.out).toContain("replaced");
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it.skipIf(!Bun.which("git"))("an npm package never replaces a development checkout", () => {
|
|
123
|
-
expect(fromPackage(clone(REPO, true), true).mineInPlace).toBe(true);
|
|
124
|
-
const unpushed = fromPackage(clone(REPO, true, commit));
|
|
125
|
-
expect(unpushed.mineInPlace).toBe(true);
|
|
126
|
-
expect(unpushed.out).toContain("commits not pushed");
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("upgrade with npm unreachable says not upgraded, never up to date", () => {
|
|
130
|
-
const root = mkdtempSync(join(tmpdir(), "kz-offline-"));
|
|
131
|
-
const home = join(root, "home");
|
|
132
|
-
mkdirSync(join(home, ".claude"), { recursive: true }); // an agent: the installer stops on a box with none
|
|
133
|
-
kaizenFiles(join(home, "kaizen"));
|
|
134
|
-
const env = { PATH: process.env.PATH ?? "", HOME: home, TMPDIR: root, HTTPS_PROXY: "http://127.0.0.1:9", https_proxy: "http://127.0.0.1:9" };
|
|
135
|
-
const p = Bun.spawnSync([process.execPath, script, "upgrade"], { cwd: home, env });
|
|
136
|
-
rmSync(root, { recursive: true, force: true });
|
|
137
|
-
expect(p.exitCode).not.toBe(0);
|
|
138
|
-
expect(p.stdout.toString()).toContain("Not upgraded");
|
|
139
|
-
expect(p.stdout.toString()).not.toContain("Up to date");
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// initProject() runs only at the end of a full install, so its gitignore rules are read
|
|
143
|
-
// from the source and handed to git: what git ignores is the only answer that counts.
|
|
144
|
-
it("init's gitignore keeps run state and personal notes out, the docs vault in", () => {
|
|
145
|
-
const src = readFileSync(join(import.meta.dir, "add-project.ts"), "utf8");
|
|
146
|
-
const rules = JSON.parse(src.match(/const rules = (".kaizen\/\*[^"]*");/)![1]!);
|
|
147
|
-
const proj = mkdtempSync(join(tmpdir(), "kz-ignore-"));
|
|
148
|
-
Bun.spawnSync(["git", "init", "-q", proj]);
|
|
149
|
-
writeFileSync(join(proj, ".gitignore"), rules);
|
|
150
|
-
const ignored = (p: string) => Bun.spawnSync(["git", "-C", proj, "check-ignore", "-q", p]).exitCode === 0;
|
|
151
|
-
try {
|
|
152
|
-
expect(ignored(".kaizen/runs/x/state.json")).toBe(true);
|
|
153
|
-
expect(ignored(".kaizen/memory.md")).toBe(true);
|
|
154
|
-
expect(ignored(".kaizen/notes/Standup.md")).toBe(true);
|
|
155
|
-
expect(ignored(".kaizen/notes/Work/Standup.md")).toBe(true);
|
|
156
|
-
expect(ignored(".kaizen/spec.md")).toBe(false);
|
|
157
|
-
expect(ignored(".kaizen/config.yml")).toBe(false);
|
|
158
|
-
expect(ignored(".kaizen/notes/Project/Index.md")).toBe(false);
|
|
159
|
-
expect(ignored(".kaizen/notes/Project/Archive/Old.md")).toBe(false);
|
|
160
|
-
} finally { rmSync(proj, { recursive: true, force: true }); }
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// A box with no agent: the picker installs the chosen one with its official command and
|
|
164
|
-
// the kaizen install carries on in the same run. `curl` is a fake that hands back a
|
|
165
|
-
// script dropping a stub `claude` in ~/.local/bin, as the real installer does; nothing
|
|
166
|
-
// reaches the network.
|
|
167
|
-
const noAgentBox = () => {
|
|
168
|
-
const root = mkdtempSync(join(tmpdir(), "kz-noagent-"));
|
|
169
|
-
const home = join(root, "home"), pkg = join(root, "pkg"), bin = join(root, "bin");
|
|
170
|
-
mkdirSync(home); mkdirSync(bin);
|
|
171
|
-
const src = dirname(dirname(import.meta.path));
|
|
172
|
-
for (const d of ["cli", "skills", "agents", "commands", "web", "package.json"]) {
|
|
173
|
-
cpSync(join(src, d), join(pkg, d), { recursive: true, filter: (p) => !p.includes("node_modules") });
|
|
174
|
-
}
|
|
175
|
-
for (const t of ["sh", "bash", "mkdir", "chmod", "cat"]) { const w = Bun.which(t); if (w) symlinkSync(w, join(bin, t)); }
|
|
176
|
-
symlinkSync(process.execPath, join(bin, "bun"));
|
|
177
|
-
writeFileSync(join(bin, "curl"), `#!/bin/sh\necho "curl $*" >> "$HOME/curl.log"\nprintf 'mkdir -p "$HOME/.local/bin"\\nprintf "#!/bin/sh\\\\nexit 0\\\\n" > "$HOME/.local/bin/claude"\\nchmod +x "$HOME/.local/bin/claude"\\n'\n`, { mode: 0o755 });
|
|
178
|
-
const env = { PATH: bin, HOME: home, USERPROFILE: home, TMPDIR: root, TERM: "xterm" };
|
|
179
|
-
return { root, home, pkg, env };
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
it.skipIf(typeof (Bun as any).Terminal !== "function")("no agent: the picked agent is installed after a yes, and the kaizen install goes on", async () => {
|
|
183
|
-
const { root, home, pkg, env } = noAgentBox();
|
|
184
|
-
let out = "";
|
|
185
|
-
const answered = new Set<string>();
|
|
186
|
-
const proc = Bun.spawn([process.execPath, join(pkg, "cli", "install.ts"), "--global"], {
|
|
187
|
-
cwd: home, env,
|
|
188
|
-
terminal: { cols: 160, rows: 40, data: (_t: unknown, d: Uint8Array) => { out += new TextDecoder().decode(d); } },
|
|
189
|
-
} as any);
|
|
190
|
-
const answer = (prompt: string, keys: string) => {
|
|
191
|
-
if (!answered.has(prompt) && out.includes(prompt)) { answered.add(prompt); (proc as any).terminal.write(keys); }
|
|
192
|
-
};
|
|
193
|
-
const until = Date.now() + 30_000;
|
|
194
|
-
try {
|
|
195
|
-
while (Date.now() < until && !out.includes("to install, or")) {
|
|
196
|
-
answer("Which one would you like to install?", "\r");
|
|
197
|
-
answer("Install Claude Code now?", "\r");
|
|
198
|
-
answer("Start Claude Code now to sign in?", "\x1b[B\r");
|
|
199
|
-
await Bun.sleep(100);
|
|
200
|
-
}
|
|
201
|
-
expect(out).toContain("curl -fsSL https://claude.ai/install.sh | bash");
|
|
202
|
-
expect(readFileSync(join(home, "curl.log"), "utf8")).toContain("https://claude.ai/install.sh");
|
|
203
|
-
expect(out).toContain("installed Claude Code");
|
|
204
|
-
expect(existsSync(join(home, ".local", "bin", "claude"))).toBe(true);
|
|
205
|
-
expect(out).toContain("to install, or"); // the kaizen install went on, no rerun
|
|
206
|
-
} finally {
|
|
207
|
-
proc.kill();
|
|
208
|
-
await proc.exited;
|
|
209
|
-
rmSync(root, { recursive: true, force: true });
|
|
210
|
-
}
|
|
211
|
-
}, 40_000);
|
|
212
|
-
|
|
213
|
-
it("no agent, no terminal: the list is printed and nothing is installed", () => {
|
|
214
|
-
const { root, home, pkg, env } = noAgentBox();
|
|
215
|
-
const p = Bun.spawnSync([process.execPath, join(pkg, "cli", "install.ts")], { cwd: home, env });
|
|
216
|
-
const ran = existsSync(join(home, "curl.log"));
|
|
217
|
-
rmSync(root, { recursive: true, force: true });
|
|
218
|
-
expect(p.exitCode).toBe(0);
|
|
219
|
-
expect(p.stdout.toString()).toContain("Install one, then run this again.");
|
|
220
|
-
expect(ran).toBe(false);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it("uninstall finishes when it runs from the ~/kaizen it deletes, as the launcher does", () => {
|
|
224
|
-
const root = mkdtempSync(join(tmpdir(), "kz-uninstall-"));
|
|
225
|
-
const home = join(root, "home"), k = join(home, "kaizen");
|
|
226
|
-
mkdirSync(home);
|
|
227
|
-
for (const d of ["cli", "skills", "web"]) cpSync(join(dirname(script), "..", d), join(k, d), { recursive: true });
|
|
228
|
-
cpSync(join(dirname(script), "..", "package.json"), join(k, "package.json"));
|
|
229
|
-
const p = Bun.spawnSync([process.execPath, join(k, "cli", "install.ts"), "uninstall", "--yes"], {
|
|
230
|
-
cwd: home, env: { PATH: process.env.PATH ?? "", HOME: home, USERPROFILE: home, TMPDIR: root },
|
|
231
|
-
});
|
|
232
|
-
const left = existsSync(k), out = p.stdout.toString(), code = p.exitCode;
|
|
233
|
-
rmSync(root, { recursive: true, force: true });
|
|
234
|
-
expect(code).toBe(0);
|
|
235
|
-
expect(left).toBe(false);
|
|
236
|
-
expect(out).toContain("Uninstalled");
|
|
237
|
-
});
|