kaizen-agent 1.64.2 → 1.65.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 +18 -1
- package/cli/roadmap.ts +74 -0
- package/cli/skills.ts +3 -3
- package/cli/web.ts +55 -1
- package/commands/kaizen-concept.md +6 -0
- package/commands/kaizen-plan.md +1 -1
- package/commands/kaizen-roadmap.md +6 -0
- package/package.json +4 -2
- package/skills/kaizen/SKILL.md +19 -5
- package/skills/kaizen/config.default.yml +2 -2
- package/skills/kaizen/roadmap.md +25 -0
- package/skills/kaizen/settings.md +4 -0
- package/skills/kaizen/spec-main.md +27 -0
- package/skills/kaizen/spec-plan.md +37 -11
- package/skills/kaizen-concept/SKILL.md +262 -0
- package/skills/kaizen-concept/skill.json +1 -0
- package/skills/kaizen-help/SKILL.md +14 -89
- package/skills/media/kaizen-book/skill.json +1 -1
- package/skills/media/kaizen-deck/SKILL.md +2 -3
- package/skills/media/kaizen-deck/skill.json +1 -1
- package/skills/media/kaizen-video/SKILL.md +2 -2
- package/skills/media/kaizen-video/examples/{notula-promo → meeting-promo}/promo.json +3 -3
- package/skills/media/kaizen-video/examples/{notula-promo → meeting-promo}/record.json +1 -1
- package/skills/media/kaizen-video/examples/{notula-promo → meeting-promo}/seed.php +1 -1
- package/skills/media/kaizen-video/examples/{notula-promo → meeting-promo}/seed.py +1 -1
- package/skills/media/kaizen-video/references/licensing.md +1 -1
- package/skills/media/kaizen-video/references/promo.md +2 -2
- package/skills/media/kaizen-video/skill.json +1 -1
- package/skills/optional/kaizen-computer/skill.json +1 -1
- package/web/board/chat.ts +4 -3
- package/web/board/run-view.ts +18 -3
- package/web/board/settings-skills.ts +2 -2
- package/web/board/ws-tabs.ts +9 -0
- package/web/board.html +1 -1
- 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 -153
- package/cli/setup.test.ts +0 -78
- package/cli/shell-agent.test.ts +0 -23
- package/cli/skills.test.ts +0 -89
- 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/restart.test.ts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
// A board that stops or dies with agents running in their cards: the next board starts
|
|
2
|
-
// them again (once, after a crash) with their last screen, ends what they left behind,
|
|
3
|
-
// and with agent.keep_alive: tmux attaches to the same agent instead.
|
|
4
|
-
import { test, expect } from "bun:test";
|
|
5
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, realpathSync } from "node:fs";
|
|
6
|
-
import { tmpdir } from "node:os";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import { startPty, exitPty, killPty, ptyState, tmuxOk, tmuxName, tmuxAlive, killTmux, detachPty, attachPty, panePid } from "./pty.ts";
|
|
9
|
-
import { keepAlive } from "./state.ts";
|
|
10
|
-
import { processTable, treeRss } from "./resources.ts";
|
|
11
|
-
|
|
12
|
-
const root = realpathSync(mkdtempSync(join(tmpdir(), "kaizen-restart-")));
|
|
13
|
-
const posix = process.platform !== "win32";
|
|
14
|
-
const gone = async (pid: number) => { for (let i = 0; i < 100; i++) { try { process.kill(pid, 0); await Bun.sleep(30); } catch { return true; } } return false; };
|
|
15
|
-
|
|
16
|
-
test("agent.keep_alive: off unless the config chain says tmux", () => {
|
|
17
|
-
const p = join(root, "keep");
|
|
18
|
-
mkdirSync(join(p, ".kaizen"), { recursive: true });
|
|
19
|
-
writeFileSync(join(p, ".kaizen", "config.yml"), "agent:\n launch: card\n # kept\n keep_alive: tmux\n");
|
|
20
|
-
expect(keepAlive(p)).toBe("tmux");
|
|
21
|
-
writeFileSync(join(p, ".kaizen", "config.yml"), "agent.keep_alive: off\n");
|
|
22
|
-
expect(keepAlive(p)).toBe("off");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// G-04: what the agent started goes with it, whether it is ended or ends by itself.
|
|
26
|
-
test.skipIf(!posix)("an ended card agent takes the processes it started with it", async () => {
|
|
27
|
-
for (const [key, how] of [["kids-ended", "ended"], ["kids-exit", "exit"]] as const) {
|
|
28
|
-
const pidFile = join(root, `${key}.child`);
|
|
29
|
-
// nohup: the pty's hangup alone would not end it, as with a dev server.
|
|
30
|
-
startPty(key, ["sh", "-c", `nohup sleep 300 >/dev/null 2>&1 & echo $! > ${pidFile}; read l; read l`], root);
|
|
31
|
-
for (let i = 0; i < 100 && !existsSync(pidFile); i++) await Bun.sleep(20);
|
|
32
|
-
const child = Number(readFileSync(pidFile, "utf8"));
|
|
33
|
-
if (how === "ended") exitPty(key, 200);
|
|
34
|
-
else { const { writePty } = await import("./pty.ts"); writePty(key, "a\r"); writePty(key, "b\r"); }
|
|
35
|
-
for (let i = 0; i < 100 && ptyState(key)!.alive; i++) await Bun.sleep(30);
|
|
36
|
-
expect(await gone(child)).toBe(true);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// G-06: a kept agent outlives its client, a new client sees it, closing ends it; the
|
|
41
|
-
// user's own tmux server is never asked anything.
|
|
42
|
-
test.skipIf(!posix || !tmuxOk())("tmux keep-alive: detach keeps the agent, attach shows it, exit ends it", async () => {
|
|
43
|
-
const name = tmuxName(`t${Date.now()}`), mark = join(root, "tmux.count");
|
|
44
|
-
const pidFile = join(root, "kept.pid"), argsOf = (pid: number) => Bun.spawnSync(["ps", "-o", "args=", "-p", String(pid)]).stdout.toString();
|
|
45
|
-
// The board's PATH reaches the agent even though the tmux server may be older than it.
|
|
46
|
-
process.env.PATH = `/kz-path-mark:${process.env.PATH}`;
|
|
47
|
-
startPty("kept", ["sh", "-c", `echo $PATH > ${mark}.path; i=0; while true; do i=$((i+1)); echo $i > ${mark}; echo tick$i; sleep 0.1; done`], root, pidFile, undefined, { tmux: name });
|
|
48
|
-
process.env.PATH = process.env.PATH.replace("/kz-path-mark:", "");
|
|
49
|
-
try {
|
|
50
|
-
for (let i = 0; i < 100 && !existsSync(mark); i++) await Bun.sleep(30);
|
|
51
|
-
expect(readFileSync(`${mark}.path`, "utf8")).toContain("/kz-path-mark");
|
|
52
|
-
// The pid file holds the agent in the pane, so closeSessions knows it (isSession reads its args).
|
|
53
|
-
for (let i = 0; i < 50 && Number(readFileSync(pidFile, "utf8")) !== panePid(name); i++) await Bun.sleep(30);
|
|
54
|
-
expect(Number(readFileSync(pidFile, "utf8"))).toBe(panePid(name)!);
|
|
55
|
-
expect(argsOf(panePid(name)!)).toContain("tick$i");
|
|
56
|
-
expect(detachPty("kept")).toBe(true);
|
|
57
|
-
for (let i = 0; i < 100 && ptyState("kept")!.alive; i++) await Bun.sleep(30);
|
|
58
|
-
expect(ptyState("kept")!.alive).toBe(false);
|
|
59
|
-
expect(tmuxAlive(name)).toBe(true);
|
|
60
|
-
const before = Number(readFileSync(mark, "utf8"));
|
|
61
|
-
await Bun.sleep(400);
|
|
62
|
-
expect(Number(readFileSync(mark, "utf8"))).toBeGreaterThan(before); // kept working with no client
|
|
63
|
-
startPty("kept2", [], root, pidFile, undefined, { tmux: name, attach: true });
|
|
64
|
-
let seen = "";
|
|
65
|
-
attachPty("kept2", (d) => { if (d) seen += d; });
|
|
66
|
-
for (let i = 0; i < 100 && !/tick\d+/.test(seen); i++) await Bun.sleep(30);
|
|
67
|
-
expect(seen).toMatch(/tick\d+/);
|
|
68
|
-
// Reattached: still the agent's PID, never the new client's.
|
|
69
|
-
for (let i = 0; i < 50 && !argsOf(Number(readFileSync(pidFile, "utf8"))).includes("tick$i"); i++) await Bun.sleep(30);
|
|
70
|
-
expect(argsOf(Number(readFileSync(pidFile, "utf8")))).toContain("tick$i");
|
|
71
|
-
exitPty("kept2", 200);
|
|
72
|
-
for (let i = 0; i < 100 && tmuxAlive(name); i++) await Bun.sleep(30);
|
|
73
|
-
expect(tmuxAlive(name)).toBe(false);
|
|
74
|
-
// Only kaizen's own server: the default socket never got this session.
|
|
75
|
-
expect(Bun.spawnSync(["tmux", "has-session", "-t", `=${name}`], { stderr: "ignore" }).exitCode).not.toBe(0);
|
|
76
|
-
} finally { killTmux(name); }
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// G-01, G-02, G-09: the real board, stopped and killed, with a fake agent in a card.
|
|
80
|
-
test.skipIf(!posix)("a stopped or crashed board resumes its card agents, once after a crash, showing the last screen", async () => {
|
|
81
|
-
const homeDir = join(root, "home"), proj = join(homeDir, "a"), st = join(proj, ".kaizen"), bin = join(root, "bin");
|
|
82
|
-
for (const d of [st, join(homeDir, ".kaizen"), join(homeDir, ".claude"), bin]) mkdirSync(d, { recursive: true });
|
|
83
|
-
writeFileSync(join(homeDir, ".kaizen", "projects"), proj + "\n");
|
|
84
|
-
writeFileSync(join(st, "config.yml"), "agent:\n default: claude\n launch: card\n");
|
|
85
|
-
writeFileSync(join(bin, "claude"), '#!/bin/sh\necho "args:$*"\nwhile read x; do echo "got:$x"; done\n', { mode: 0o755 });
|
|
86
|
-
const repo = join(import.meta.dir, "..");
|
|
87
|
-
const port = 20000 + Math.floor(Math.random() * 20000), at = `http://127.0.0.1:${port}`;
|
|
88
|
-
let out = "";
|
|
89
|
-
const board = () => {
|
|
90
|
-
const p = Bun.spawn([process.execPath, join(repo, "cli", "install.ts"), "web", "--port", String(port), "--no-open", "--foreground"], {
|
|
91
|
-
cwd: proj, stdout: "pipe", stderr: "ignore",
|
|
92
|
-
env: { ...process.env, HOME: homeDir, USERPROFILE: homeDir, KAIZEN_HOME: repo, CLAUDE_CONFIG_DIR: join(homeDir, ".claude"),
|
|
93
|
-
PATH: `${bin}:/usr/bin:/bin`, SHELL: "/bin/false", DISPLAY: "", WAYLAND_DISPLAY: "", TERMINAL: "", TMUX: "" },
|
|
94
|
-
});
|
|
95
|
-
(async () => { for await (const c of p.stdout) out += new TextDecoder().decode(c); })();
|
|
96
|
-
return p;
|
|
97
|
-
};
|
|
98
|
-
const up = async () => { for (let i = 0; ; i++) { try { await fetch(at + "/state"); return; } catch { if (i > 150) throw new Error("board did not start"); await Bun.sleep(50); } } };
|
|
99
|
-
const screen = async (key: string, re: RegExp) => {
|
|
100
|
-
let seen = "";
|
|
101
|
-
const ws = new WebSocket(`${at}/pty?key=${key}`.replace("http", "ws"), { headers: { origin: at } } as any);
|
|
102
|
-
ws.onmessage = (e) => { seen += String(e.data); };
|
|
103
|
-
await new Promise((ok, no) => { ws.onopen = ok; ws.onerror = no; });
|
|
104
|
-
for (let i = 0; i < 100 && !re.test(seen); i++) await Bun.sleep(30);
|
|
105
|
-
ws.close();
|
|
106
|
-
return seen;
|
|
107
|
-
};
|
|
108
|
-
const liveKey = async () => ((await (await fetch(at + "/state")).json()) as any).cards.find((c: any) => c.id === "r1")?.pty?.key as string | undefined;
|
|
109
|
-
|
|
110
|
-
let b = board();
|
|
111
|
-
try {
|
|
112
|
-
await up();
|
|
113
|
-
const r = await (await fetch(at + "/run", { method: "POST", body: JSON.stringify({ dir: st, text: "say hello" }) })).json() as any;
|
|
114
|
-
expect(r.ok).toBe(true);
|
|
115
|
-
// The run that launch became, in its build stage, with its conversation on disk.
|
|
116
|
-
mkdirSync(join(st, "runs", "r1"), { recursive: true });
|
|
117
|
-
writeFileSync(join(st, "runs", "r1", "00-request.md"), "say hello\n");
|
|
118
|
-
writeFileSync(join(st, "runs", "r1", "state.json"), JSON.stringify({ id: "r1", stage: "build", awaiting: null }));
|
|
119
|
-
const sid = JSON.parse(readFileSync(join(st, "sessions", r.pty + ".json"), "utf8")).sessionId;
|
|
120
|
-
const tr = join(homeDir, ".claude", "projects", proj.replace(/[^A-Za-z0-9]/g, "-"));
|
|
121
|
-
mkdirSync(tr, { recursive: true });
|
|
122
|
-
writeFileSync(join(tr, sid + ".jsonl"), "{}\n");
|
|
123
|
-
const ws = new WebSocket(`${at}/pty?key=${r.pty}`.replace("http", "ws"), { headers: { origin: at } } as any);
|
|
124
|
-
await new Promise((ok, no) => { ws.onopen = ok; ws.onerror = no; });
|
|
125
|
-
ws.send(JSON.stringify({ t: "i", d: "first-screen\r" }));
|
|
126
|
-
await screen(r.pty, /got:first-screen/);
|
|
127
|
-
const agent = Number(readFileSync(join(st, "sessions", r.pty + ".pid"), "utf8"));
|
|
128
|
-
|
|
129
|
-
// An orderly stop (systemd, Ctrl-C): the agent is ended, the list and screen kept.
|
|
130
|
-
b.kill("SIGTERM");
|
|
131
|
-
await b.exited;
|
|
132
|
-
expect(await gone(agent)).toBe(true);
|
|
133
|
-
const list = JSON.parse(readFileSync(join(homeDir, ".kaizen", "resume-after-upgrade.json"), "utf8"));
|
|
134
|
-
expect(list).toMatchObject({ crash: false, list: [{ key: r.pty, run: "r1" }] });
|
|
135
|
-
|
|
136
|
-
b = board();
|
|
137
|
-
await up();
|
|
138
|
-
const k2 = await liveKey();
|
|
139
|
-
expect(k2).toBeTruthy();
|
|
140
|
-
const seen = await screen(k2!, new RegExp(`--resume ${sid}`));
|
|
141
|
-
expect(seen).toMatch(/got:first-screen[\s\S]*board restarted · agent resumed[\s\S]*--resume/);
|
|
142
|
-
expect(out).toMatch(/resumed r1/);
|
|
143
|
-
|
|
144
|
-
// A crash: no stop runs, yet the list kept current while it ran resumes it once.
|
|
145
|
-
await Bun.sleep(3500);
|
|
146
|
-
b.kill("SIGKILL");
|
|
147
|
-
await b.exited;
|
|
148
|
-
expect(JSON.parse(readFileSync(join(homeDir, ".kaizen", "resume-after-upgrade.json"), "utf8")).crash).toBe(true);
|
|
149
|
-
out = "";
|
|
150
|
-
b = board();
|
|
151
|
-
await up();
|
|
152
|
-
expect(await liveKey()).toBeTruthy();
|
|
153
|
-
expect(out).toMatch(/resumed r1/);
|
|
154
|
-
// Dying again right after that resume: the next board leaves it on its Resume button.
|
|
155
|
-
await Bun.sleep(3500);
|
|
156
|
-
expect(JSON.parse(readFileSync(join(homeDir, ".kaizen", "resume-after-upgrade.json"), "utf8")).list[0].resumed).toBeGreaterThan(0);
|
|
157
|
-
b.kill("SIGKILL");
|
|
158
|
-
await b.exited;
|
|
159
|
-
out = "";
|
|
160
|
-
b = board();
|
|
161
|
-
await up();
|
|
162
|
-
await Bun.sleep(300);
|
|
163
|
-
expect(out).toMatch(/not resuming r1/);
|
|
164
|
-
expect(await liveKey()).toBeFalsy();
|
|
165
|
-
} finally {
|
|
166
|
-
b.kill("SIGKILL");
|
|
167
|
-
// The fake agents of the killed boards: ended so nothing outlives the test.
|
|
168
|
-
Bun.spawnSync(["pkill", "-f", `${bin}/claude`]);
|
|
169
|
-
}
|
|
170
|
-
}, 40_000);
|
|
171
|
-
|
|
172
|
-
// A phone reaches the board through a proxy pinned to its port, so the board an update
|
|
173
|
-
// starts has to outwait the old one instead of walking to the next port.
|
|
174
|
-
test.skipIf(!posix || !Bun.which("lsof"))("a new board takes over the port of a board slow to stop", async () => {
|
|
175
|
-
const port = 20000 + Math.floor(Math.random() * 20000);
|
|
176
|
-
const home = join(root, "takeover");
|
|
177
|
-
mkdirSync(home, { recursive: true });
|
|
178
|
-
const script = join(home, "old.ts");
|
|
179
|
-
writeFileSync(script, `Bun.serve({ hostname: "127.0.0.1", port: ${port}, fetch: () => new Response("old", { headers: { "x-kaizen-version": "0.0.0" } }) });
|
|
180
|
-
process.on("SIGTERM", () => setTimeout(() => process.exit(0), 1500));
|
|
181
|
-
console.log("up");`);
|
|
182
|
-
const old = Bun.spawn([process.execPath, script], { stdout: "pipe" });
|
|
183
|
-
await new Response(old.stdout).body!.getReader().read();
|
|
184
|
-
mkdirSync(join(home, ".claude"), { recursive: true }); // an agent, or `kaizen web` stops at its no-agent notice
|
|
185
|
-
const fresh = Bun.spawn([process.execPath, join(import.meta.dir, "install.ts"), "web", "--port", String(port), "--no-open", "--foreground"], {
|
|
186
|
-
cwd: home, env: { ...process.env, HOME: home, USERPROFILE: home }, stdin: "ignore", stdout: "ignore", stderr: "ignore",
|
|
187
|
-
});
|
|
188
|
-
try {
|
|
189
|
-
let version: string | null = null;
|
|
190
|
-
for (let i = 0; i < 60 && (!version || version === "0.0.0"); i++) {
|
|
191
|
-
await Bun.sleep(200);
|
|
192
|
-
version = await fetch(`http://127.0.0.1:${port}/`).then((r) => r.headers.get("x-kaizen-version"), () => null);
|
|
193
|
-
}
|
|
194
|
-
expect(version).toBe(JSON.parse(readFileSync(join(import.meta.dir, "..", "package.json"), "utf8")).version);
|
|
195
|
-
} finally { fresh.kill("SIGKILL"); old.kill("SIGKILL"); }
|
|
196
|
-
}, 20000);
|
|
197
|
-
|
|
198
|
-
test("killPty ends the terminal's whole group at once, and only that terminal", async () => {
|
|
199
|
-
if (!posix) return;
|
|
200
|
-
const file = (n: string) => join(root, n + ".pid");
|
|
201
|
-
for (const k of ["kill-a", "kill-b"]) startPty(k, ["sh", "-c", `sleep 300 & echo $! > ${file(k)}; wait`], root);
|
|
202
|
-
for (let i = 0; i < 100 && !(existsSync(file("kill-a")) && existsSync(file("kill-b"))); i++) await Bun.sleep(20);
|
|
203
|
-
const a = Number(readFileSync(file("kill-a"), "utf8")), b = Number(readFileSync(file("kill-b"), "utf8"));
|
|
204
|
-
expect(killPty("kill-a")).toBe(true);
|
|
205
|
-
expect(await gone(a)).toBe(true);
|
|
206
|
-
expect(() => process.kill(b, 0)).not.toThrow();
|
|
207
|
-
expect(killPty("no-such")).toBe(false);
|
|
208
|
-
killPty("kill-b");
|
|
209
|
-
expect(await gone(b)).toBe(true);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
test.skipIf(!posix || !tmuxOk())("a tmux-kept terminal is measured from its pane and killed with its session", async () => {
|
|
213
|
-
const name = tmuxName("res-" + process.pid);
|
|
214
|
-
startPty("res-tmux", ["sleep", "60"], root, undefined, undefined, { tmux: name });
|
|
215
|
-
let pane: number | null = null;
|
|
216
|
-
for (let i = 0; i < 100 && !(pane = panePid(name)); i++) await Bun.sleep(30);
|
|
217
|
-
expect(pane).toBeGreaterThan(0);
|
|
218
|
-
expect(treeRss((await processTable())!, [pane!])).toBeGreaterThan(0);
|
|
219
|
-
expect(killPty("res-tmux")).toBe(true);
|
|
220
|
-
for (let i = 0; i < 100 && tmuxAlive(name); i++) await Bun.sleep(30);
|
|
221
|
-
expect(tmuxAlive(name)).toBe(false);
|
|
222
|
-
});
|
package/cli/settings.test.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
// Settings against a throwaway home and project: a project with its own config.yml
|
|
2
|
-
// must not hide the board's machine-wide settings. Bun reads HOME once at startup,
|
|
3
|
-
// so the settings code runs in a child process with a fake HOME; setting HOME here
|
|
4
|
-
// would write to the real ~/.kaizen/config.yml.
|
|
5
|
-
import { test, expect, beforeAll, afterAll } from "bun:test";
|
|
6
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, copyFileSync, rmSync } from "node:fs";
|
|
7
|
-
import { join, dirname } from "node:path";
|
|
8
|
-
import { tmpdir } from "node:os";
|
|
9
|
-
import { applyPreset, detectPreset, read } from "./settings.ts";
|
|
10
|
-
|
|
11
|
-
const repo = join(dirname(import.meta.path), "..");
|
|
12
|
-
const defaults = join(repo, "skills/kaizen/config.default.yml");
|
|
13
|
-
let root: string, home: string, project: string;
|
|
14
|
-
|
|
15
|
-
beforeAll(() => {
|
|
16
|
-
root = mkdtempSync(join(tmpdir(), "kaizen-settings-"));
|
|
17
|
-
home = join(root, "home");
|
|
18
|
-
mkdirSync(join(home, ".kaizen"), { recursive: true });
|
|
19
|
-
writeFileSync(join(home, ".kaizen", "config.yml"), readFileSync(defaults, "utf8").replace('projects_dir: ""', "projects_dir: ~/Projects"));
|
|
20
|
-
// A project that carries its own config, as a cloned repo with .kaizen/config.yml does.
|
|
21
|
-
project = join(home, "Projects", "app");
|
|
22
|
-
mkdirSync(join(project, ".git"), { recursive: true });
|
|
23
|
-
mkdirSync(join(project, ".kaizen"), { recursive: true });
|
|
24
|
-
copyFileSync(defaults, join(project, ".kaizen", "config.yml"));
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
afterAll(() => rmSync(root, { recursive: true, force: true }));
|
|
28
|
-
|
|
29
|
-
// Runs `code` with listSettings/setSetting in scope, from inside the project, and returns what it prints.
|
|
30
|
-
const inProject = (code: string) => {
|
|
31
|
-
const script = `import { listSettings, setSetting } from ${JSON.stringify(join(repo, "cli/settings.ts"))};
|
|
32
|
-
const repo = ${JSON.stringify(repo)};
|
|
33
|
-
const value = (k) => listSettings(repo).rows.find((r) => r.key === k)?.value;
|
|
34
|
-
console.log(JSON.stringify(await (async () => { ${code} })()));`;
|
|
35
|
-
const p = Bun.spawnSync(["bun", "-e", script], { cwd: project, env: { ...process.env, HOME: home, USERPROFILE: home } });
|
|
36
|
-
if (p.exitCode !== 0) throw new Error(p.stderr.toString());
|
|
37
|
-
return JSON.parse(p.stdout.toString());
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
test("the projects folder survives moving into a project with its own config", () => {
|
|
41
|
-
expect(inProject(`return value("board.projects_dir")`)).toBe("~/Projects");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("board settings save to the global config, project settings to the project", () => {
|
|
45
|
-
expect(inProject(`return [setSetting(repo, "board.projects_dir", "~/Work"), value("board.projects_dir")]`)).toEqual([{ ok: true }, "~/Work"]);
|
|
46
|
-
expect(readFileSync(join(home, ".kaizen", "config.yml"), "utf8")).toContain("projects_dir: ~/Work");
|
|
47
|
-
expect(readFileSync(join(project, ".kaizen", "config.yml"), "utf8")).toContain('projects_dir: ""');
|
|
48
|
-
|
|
49
|
-
expect(inProject(`return setSetting(repo, "git.auto_commit", "true")`)).toEqual({ ok: true });
|
|
50
|
-
expect(readFileSync(join(project, ".kaizen", "config.yml"), "utf8")).toMatch(/auto_commit: true/);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test("every row is a key in config.default.yml, and every `when` names a row and one of its values", () => {
|
|
54
|
-
const rows = inProject(`return listSettings(repo).rows`);
|
|
55
|
-
const text = readFileSync(defaults, "utf8");
|
|
56
|
-
for (const r of rows) {
|
|
57
|
-
const [top, leaf] = r.key.split(".");
|
|
58
|
-
const block = leaf ? new RegExp(`^${top}:\\n(?:(?: .*|\\s*)\\n)*? ${leaf}:`, "m") : new RegExp(`^${top}:`, "m");
|
|
59
|
-
expect(block.test(text) ? r.key : `${r.key} missing`).toBe(r.key);
|
|
60
|
-
if (!r.when) continue;
|
|
61
|
-
const dep = rows.find((x) => x.key === r.when[0]);
|
|
62
|
-
expect(dep?.values).toContain(r.when[1]);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("a row dims while the setting it depends on has it switched off, and a leftover dead key changes nothing", () => {
|
|
67
|
-
const conf = join(project, ".kaizen", "config.yml");
|
|
68
|
-
// The low preset as an older config holds it, with keys kaizen no longer reads.
|
|
69
|
-
writeFileSync(conf, readFileSync(defaults, "utf8")
|
|
70
|
-
.replace("enabled: true\n # critical", "enabled: false\n # critical")
|
|
71
|
-
.replace("git:\n", "git:\n branch_before_implement: false\n")
|
|
72
|
-
+ "\ntrack:\n default: software\n");
|
|
73
|
-
const idle = (k: string) => inProject(`return listSettings(repo).rows.find((r) => r.key === ${JSON.stringify(k)}).idle`);
|
|
74
|
-
expect(idle("auto_fix.min_severity")).toBe("No effect unless Fix findings automatically is on");
|
|
75
|
-
expect(idle("auto_fix.enabled")).toBe("");
|
|
76
|
-
expect(inProject(`return setSetting(repo, "auto_fix.max_iterations", "3")`)).toEqual({ ok: true });
|
|
77
|
-
expect(inProject(`return setSetting(repo, "auto_fix.enabled", "true")`)).toEqual({ ok: true });
|
|
78
|
-
expect(idle("auto_fix.min_severity")).toBe("");
|
|
79
|
-
expect(inProject(`return value("auto_fix.max_iterations")`)).toBe("3");
|
|
80
|
-
copyFileSync(defaults, conf);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("a config still holding git.branch_before_implement keeps its preset", () => {
|
|
84
|
-
const text = readFileSync(defaults, "utf8");
|
|
85
|
-
expect(inProject(`return value("auto_fix.min_severity")`)).toBe("low");
|
|
86
|
-
const low = applyPreset(text, "low", text).replace("git:\n", "git:\n branch_before_implement: true\n");
|
|
87
|
-
expect(detectPreset(low, text)).toBe("low");
|
|
88
|
-
expect(detectPreset(text, text)).toBe("medium");
|
|
89
|
-
expect(applyPreset(text, "medium", text)).toContain("min_severity: low");
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test("a low-preset config saved before review.executor existed still reads as low", () => {
|
|
93
|
-
const text = readFileSync(defaults, "utf8");
|
|
94
|
-
const low = applyPreset("", "low", text);
|
|
95
|
-
const old = low.replace(/(review:\n(?:\s*#.*\n)*)\s*executor: inline\n/, "$1");
|
|
96
|
-
expect(old).not.toContain("executor: inline\n # Let");
|
|
97
|
-
expect(detectPreset(old, text)).toBe("low");
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("a project scope reads over All projects, starts its own file empty, and resets a key back", () => {
|
|
101
|
-
const other = join(home, "Projects", "other");
|
|
102
|
-
mkdirSync(join(other, ".kaizen"), { recursive: true });
|
|
103
|
-
writeFileSync(join(home, ".kaizen", "projects"), `${project}\n${other}\n`);
|
|
104
|
-
const r = inProject(`
|
|
105
|
-
const at = (p, k) => listSettings(repo, p).rows.find((r) => r.key === k);
|
|
106
|
-
const other = ${JSON.stringify(other)};
|
|
107
|
-
setSetting(repo, "git.auto_commit", "true", null);
|
|
108
|
-
const before = at(other, "git.auto_commit");
|
|
109
|
-
setSetting(repo, "git.auto_commit", "false", other);
|
|
110
|
-
const file = (await Bun.file(other + "/.kaizen/config.yml").text());
|
|
111
|
-
const own = at(other, "git.auto_commit");
|
|
112
|
-
const global = at(null, "git.auto_commit");
|
|
113
|
-
const board = setSetting(repo, "board.open", "app", other) && at(null, "board.open").value;
|
|
114
|
-
const { resetSetting } = await import(${JSON.stringify(join(repo, "cli/settings.ts"))});
|
|
115
|
-
resetSetting(repo, "git.auto_commit", other);
|
|
116
|
-
const after = at(other, "git.auto_commit"), left = await Bun.file(other + "/.kaizen/config.yml").text();
|
|
117
|
-
await Bun.write(other + "/.kaizen/config.yml", "# my team's git rules\\ngit:\\n # mine\\n auto_commit: true\\n");
|
|
118
|
-
resetSetting(repo, "git.auto_commit", other);
|
|
119
|
-
const kept = await Bun.file(other + "/.kaizen/config.yml").text();
|
|
120
|
-
return { kept, before, file, own, global, board, after, left };
|
|
121
|
-
`);
|
|
122
|
-
expect(r.before).toMatchObject({ value: "true" });
|
|
123
|
-
expect(r.before.own).toBeUndefined();
|
|
124
|
-
expect(r.file).not.toContain("runner:");
|
|
125
|
-
expect(r.file).not.toContain("preset:");
|
|
126
|
-
expect(r.own).toMatchObject({ value: "false", own: true });
|
|
127
|
-
expect(r.global.value).toBe("true");
|
|
128
|
-
expect(r.global.overrides).toContainEqual({ label: "other", value: "false" });
|
|
129
|
-
expect(r.board).toBe("app");
|
|
130
|
-
expect(r.after).toMatchObject({ value: "true" });
|
|
131
|
-
expect(r.left).not.toContain("auto_commit");
|
|
132
|
-
expect(r.kept).toBe("# my team's git rules\ngit:\n # mine\n");
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test("the orchestration keys read at their exact nesting, off by default, comments between lines allowed", () => {
|
|
136
|
-
const d = readFileSync(defaults, "utf8");
|
|
137
|
-
expect(["enabled", "max_workers", "permissions", "worker_model.claude", "worker_model.codex"].map((k) => read(d, `orchestration.${k}`))).toEqual(["false", "3", "own", "", ""]);
|
|
138
|
-
const mine = "orchestration:\n # why\n enabled: true # on\n\n # a comment\n max_workers: 2\n";
|
|
139
|
-
expect([read(mine, "orchestration.enabled"), read(mine, "orchestration.max_workers"), read(mine, "orchestration.permissions")]).toEqual(["true", "2", null]);
|
|
140
|
-
expect(read("git:\n enabled: true\n", "orchestration.enabled")).toBeNull();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test("a worker model written into a config that has no such block lands under orchestration, not a second header", () => {
|
|
144
|
-
const file = join(project, ".kaizen", "config.yml"), keep = readFileSync(file, "utf8");
|
|
145
|
-
try {
|
|
146
|
-
writeFileSync(file, "orchestration:\n enabled: true\n");
|
|
147
|
-
expect(inProject(`return setSetting(repo, "orchestration.worker_model.claude", "haiku")`)).toEqual({ ok: true });
|
|
148
|
-
const text = readFileSync(file, "utf8");
|
|
149
|
-
expect((text.match(/^orchestration:/gm) ?? []).length).toBe(1);
|
|
150
|
-
expect(read(text, "orchestration.worker_model.claude")).toBe("haiku");
|
|
151
|
-
expect(read(text, "orchestration.enabled")).toBe("true");
|
|
152
|
-
} finally { writeFileSync(file, keep); }
|
|
153
|
-
});
|
package/cli/setup.test.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test";
|
|
2
|
-
import { mkdtempSync, mkdirSync, rmSync, existsSync, readdirSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { qrMatrix, qr } from "./qr.ts";
|
|
6
|
-
import { projectStep, tailnetName } from "./setup.ts";
|
|
7
|
-
import { banner } from "./look.ts";
|
|
8
|
-
|
|
9
|
-
test("qr: right size per version, finder squares in three corners, deterministic", () => {
|
|
10
|
-
const a = qrMatrix("https://pc.tail1234.ts.net"); // 26 bytes: version 2, 25 modules
|
|
11
|
-
expect(a.length).toBe(25);
|
|
12
|
-
for (const [x, y] of [[0, 0], [18, 0], [0, 18]] as const) {
|
|
13
|
-
expect(a[y]![x]).toBe(true); expect(a[y + 3]![x + 3]).toBe(true); expect(a[y + 1]![x + 1]).toBe(false);
|
|
14
|
-
}
|
|
15
|
-
expect(qr("https://pc.tail1234.ts.net")).toBe(qr("https://pc.tail1234.ts.net"));
|
|
16
|
-
expect(qrMatrix("https://a.b").length).toBe(21); // version 1
|
|
17
|
-
expect(qrMatrix("x".repeat(130)).length).toBe(41); // version 6
|
|
18
|
-
expect(() => qrMatrix("x".repeat(200))).toThrow();
|
|
19
|
-
const lines = qr("https://a.b").split("\n");
|
|
20
|
-
expect(lines.length).toBe(13); // (21 + 4 quiet) / 2 rows, rounded up
|
|
21
|
-
expect(new Set(lines.map((l) => l.length))).toEqual(new Set([25]));
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("tailnetName: the machine's DNS name only when Tailscale is running", () => {
|
|
25
|
-
const up = JSON.stringify({ BackendState: "Running", Self: { DNSName: "PC.tail1234.ts.net." } });
|
|
26
|
-
expect(tailnetName(up)).toBe("pc.tail1234.ts.net");
|
|
27
|
-
expect(tailnetName(JSON.stringify({ BackendState: "NeedsLogin", Self: { DNSName: "pc.x.ts.net." } }))).toBeNull();
|
|
28
|
-
expect(tailnetName(JSON.stringify({ BackendState: "Running" }))).toBeNull();
|
|
29
|
-
expect(tailnetName("not json")).toBeNull();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Scratch HOME only: setup must never touch the real ~/.kaizen.
|
|
33
|
-
test("kaizen setup without a terminal prints the manual steps and writes nothing", async () => {
|
|
34
|
-
const homeDir = mkdtempSync(join(tmpdir(), "kaizen-setup-"));
|
|
35
|
-
try {
|
|
36
|
-
const p = Bun.spawn([process.execPath, join(import.meta.dir, "install.ts"), "setup"], {
|
|
37
|
-
cwd: homeDir, env: { ...process.env, HOME: homeDir, USERPROFILE: homeDir }, stdin: "ignore", stdout: "pipe", stderr: "pipe",
|
|
38
|
-
});
|
|
39
|
-
const out = await new Response(p.stdout).text();
|
|
40
|
-
expect(await p.exited).toBe(0);
|
|
41
|
-
expect(out).toContain("tailscale serve --bg 127.0.0.1:7420");
|
|
42
|
-
// Bun's cache (~/.bun) and macOS's ~/Library land in HOME; only what kaizen writes counts.
|
|
43
|
-
expect(readdirSync(homeDir).filter((n) => n !== ".bun" && !(process.platform === "darwin" && n === "Library"))).toEqual([]);
|
|
44
|
-
expect(existsSync(join(homeDir, ".kaizen"))).toBe(false);
|
|
45
|
-
} finally { rmSync(homeDir, { recursive: true, force: true }); }
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("web-hosts: names are normalized, deduped and merged with the env var", async () => {
|
|
49
|
-
const homeDir = mkdtempSync(join(tmpdir(), "kaizen-hosts2-"));
|
|
50
|
-
try {
|
|
51
|
-
const p = Bun.spawn([process.execPath, "-e", `
|
|
52
|
-
const s = await import(${JSON.stringify(join(import.meta.dir, "state.ts"))});
|
|
53
|
-
s.addWebHost("PC.Tail1.ts.net"); s.addWebHost("pc.tail1.ts.net");
|
|
54
|
-
console.log(JSON.stringify([...s.webHosts()].sort()));`], {
|
|
55
|
-
env: { ...process.env, HOME: homeDir, USERPROFILE: homeDir, KAIZEN_WEB_HOSTS: "Env.ts.net:443" }, stdout: "pipe",
|
|
56
|
-
});
|
|
57
|
-
expect(JSON.parse(await new Response(p.stdout).text())).toEqual(["env.ts.net", "pc.tail1.ts.net"]);
|
|
58
|
-
} finally { rmSync(homeDir, { recursive: true, force: true }); }
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("projectStep: home asks, a repository offers its root, an owned folder is left alone", () => {
|
|
62
|
-
const h = mkdtempSync(join(tmpdir(), "kaizen-step-"));
|
|
63
|
-
try {
|
|
64
|
-
const sub = join(h, "app", "src"), plain = join(h, "plain");
|
|
65
|
-
mkdirSync(join(h, "app", ".git"), { recursive: true }); mkdirSync(sub); mkdirSync(plain);
|
|
66
|
-
expect(projectStep(h, h)).toBeNull();
|
|
67
|
-
expect(projectStep(sub, h)).toEqual({ offer: join(h, "app"), git: true });
|
|
68
|
-
expect(projectStep(plain, h)).toEqual({ offer: plain, git: false });
|
|
69
|
-
mkdirSync(join(h, "app", ".kaizen"));
|
|
70
|
-
expect(projectStep(sub, h)).toEqual({ ready: true });
|
|
71
|
-
} finally { rmSync(h, { recursive: true, force: true }); }
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test("banner: the K alone, and no hard-coded colour", () => {
|
|
75
|
-
const plain = (s: string) => s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
76
|
-
expect(plain(banner())).not.toContain("█▀▄ █▀█");
|
|
77
|
-
expect(banner()).not.toContain("38;2");
|
|
78
|
-
});
|
package/cli/shell-agent.test.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { shellAgent } from "./web.ts";
|
|
3
|
-
import { colorEnv } from "./pty.ts";
|
|
4
|
-
|
|
5
|
-
const procs = (m: Record<string, string>) => (path: string) => {
|
|
6
|
-
if (path in m) return m[path];
|
|
7
|
-
throw new Error("gone");
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
test("finds an agent below the shell, through a wrapper script", () => {
|
|
11
|
-
const read = procs({ "/proc/1/task/1/children": "2 ", "/proc/2/cmdline": "/bin/bash\0/home/u/.local/bin/claude\0--x\0", "/proc/2/task/2/children": "" });
|
|
12
|
-
expect(shellAgent(1, ["claude", "codex"], read)).toBe("claude");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test("a shell running something else, or already gone, has no agent", () => {
|
|
16
|
-
const read = procs({ "/proc/1/task/1/children": "2", "/proc/2/cmdline": "vim\0claude.md\0", "/proc/2/task/2/children": "" });
|
|
17
|
-
expect(shellAgent(1, ["claude"], read)).toBeUndefined();
|
|
18
|
-
expect(shellAgent(9, ["claude"], read)).toBeUndefined();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test("board terminals drop an inherited NO_COLOR", () => {
|
|
22
|
-
expect(colorEnv({ NO_COLOR: "1", PATH: "/bin" })).toEqual({ PATH: "/bin" });
|
|
23
|
-
});
|
package/cli/skills.test.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
});
|