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/knowledge.test.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// Global knowledge, driven through the real CLI entry with a scratch HOME. Every
|
|
2
|
-
// spawn gets an env built from nothing but PATH, so no test can reach the real
|
|
3
|
-
// ~/.kaizen/knowledge or ~/.claude/settings.json.
|
|
4
|
-
import { test, expect, afterAll } from "bun:test";
|
|
5
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, rmSync } from "node:fs";
|
|
6
|
-
import { join, dirname } from "node:path";
|
|
7
|
-
import { tmpdir, homedir } from "node:os";
|
|
8
|
-
import { secretReason, addSessionHook, removeSessionHook, SESSION_HEADER } from "./knowledge.ts";
|
|
9
|
-
|
|
10
|
-
const script = join(dirname(import.meta.path), "install.ts");
|
|
11
|
-
const realKnowledge = join(homedir(), ".kaizen", "knowledge");
|
|
12
|
-
const realMtime = existsSync(realKnowledge) ? statSync(realKnowledge).mtimeMs : -1;
|
|
13
|
-
const roots: string[] = [];
|
|
14
|
-
afterAll(() => roots.forEach((r) => rmSync(r, { recursive: true, force: true })));
|
|
15
|
-
|
|
16
|
-
const scratch = () => {
|
|
17
|
-
const root = mkdtempSync(join(tmpdir(), "kz-knowledge-"));
|
|
18
|
-
roots.push(root);
|
|
19
|
-
const home = join(root, "home");
|
|
20
|
-
mkdirSync(home);
|
|
21
|
-
const project = (name: string, files: Record<string, string> = {}) => {
|
|
22
|
-
const d = join(root, name);
|
|
23
|
-
mkdirSync(join(d, ".kaizen"), { recursive: true });
|
|
24
|
-
for (const [f, t] of Object.entries(files)) { mkdirSync(dirname(join(d, f)), { recursive: true }); writeFileSync(join(d, f), t); }
|
|
25
|
-
return d;
|
|
26
|
-
};
|
|
27
|
-
const kz = (cwd: string, ...a: string[]) => {
|
|
28
|
-
const p = Bun.spawnSync([process.execPath, script, ...a], { cwd, env: { PATH: process.env.PATH ?? "", HOME: home, USERPROFILE: home, TMPDIR: root } });
|
|
29
|
-
return { code: p.exitCode, out: p.stdout.toString() + p.stderr.toString() };
|
|
30
|
-
};
|
|
31
|
-
const file = (track: string) => { try { return readFileSync(join(home, ".kaizen", "knowledge", `${track}.md`), "utf8"); } catch { return ""; } };
|
|
32
|
-
return { root, home, project, kz, file };
|
|
33
|
-
};
|
|
34
|
-
const lesson = (...extra: string[]) => ["remember", "--track", "code", "--tags", "bun,testing", "--applies", "bun>=1.1; not node", "--run", "r1", ...extra];
|
|
35
|
-
|
|
36
|
-
test("secret check rejects keys, credentials, emails, IPs and private hosts", () => {
|
|
37
|
-
for (const t of ["use sk-abcdefghijklmnop", "ghp_abcdefghijklmnopqrst", "-----BEGIN RSA PRIVATE KEY", "set password=hunter22", "mail ops@example.com",
|
|
38
|
-
"server at 10.1.2.3", "db.acme.internal is slow", "token: abcdefABCDEF0123456789abcdefABCDEF01"]) expect(secretReason(t)).not.toBe("");
|
|
39
|
-
for (const t of ["bun test --bail stops at the first failing file", "127.0.0.1 binds loopback only", "see https://bun.sh/docs/cli/test"]) expect(secretReason(t)).toBe("");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test("a rejected lesson leaves the file unchanged and says why", () => {
|
|
43
|
-
const s = scratch(), a = s.project("a");
|
|
44
|
-
const r = s.kz(a, ...lesson("connect to 192.168.1.20 first"));
|
|
45
|
-
expect(r.code).toBe(1);
|
|
46
|
-
expect(r.out).toContain("rejected (secret check)");
|
|
47
|
-
expect(s.file("code")).toBe("");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("applies, tags, source and the track are required; preferences are not writable", () => {
|
|
51
|
-
const s = scratch(), a = s.project("a");
|
|
52
|
-
expect(s.kz(a, "remember", "--track", "code", "--tags", "bun", "--run", "r1", "x").out).toContain("--applies is required");
|
|
53
|
-
expect(s.kz(a, "remember", "--track", "code", "--applies", "y", "--run", "r1", "x").out).toContain("--tags is required");
|
|
54
|
-
expect(s.kz(a, "remember", "--track", "code", "--tags", "bun", "--applies", "y", "x").out).toContain("--source");
|
|
55
|
-
expect(s.kz(a, "remember", "--track", "preferences", "--tags", "tone", "--applies", "y", "--run", "r1", "x").out).toContain("written by hand");
|
|
56
|
-
expect(s.file("preferences")).toBe("");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("appends a same-tag lesson instead of merging, and lists the existing one", () => {
|
|
60
|
-
const s = scratch(), a = s.project("a");
|
|
61
|
-
expect(s.kz(a, ...lesson("spawnSync throws when the binary is not on PATH")).code).toBe(0);
|
|
62
|
-
const r = s.kz(a, ...lesson("Bun.spawnSync raises if the executable is missing"));
|
|
63
|
-
expect(r.code).toBe(0);
|
|
64
|
-
expect(r.out).toContain("Same-tag lessons");
|
|
65
|
-
expect(r.out).toContain("spawnSync throws when the binary");
|
|
66
|
-
const body = s.file("code");
|
|
67
|
-
expect(body).toContain("spawnSync throws when the binary");
|
|
68
|
-
expect(body).toContain("Bun.spawnSync raises");
|
|
69
|
-
expect(body).toMatch(/\(applies: bun>=1\.1; not node\) — \d{4}-\d{2}-\d{2} · a\/r1/);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test("run from a subfolder, remember uses the project's opt-out and name", () => {
|
|
73
|
-
const s = scratch();
|
|
74
|
-
const off = s.project("client", { ".kaizen/config.yml": "knowledge:\n global: false\n" });
|
|
75
|
-
mkdirSync(join(off, ".kaizen", "runs", "r1"), { recursive: true });
|
|
76
|
-
expect(s.kz(join(off, ".kaizen", "runs", "r1"), ...lesson("from the run dir")).code).toBe(1);
|
|
77
|
-
expect(s.file("code")).toBe("");
|
|
78
|
-
const a = s.project("project-a");
|
|
79
|
-
mkdirSync(join(a, "src", "deep"), { recursive: true });
|
|
80
|
-
expect(s.kz(join(a, "src", "deep"), ...lesson("from a subfolder")).code).toBe(0);
|
|
81
|
-
expect(s.file("code")).toContain("· project-a/r1");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("multi-line --applies stays one line, bad tags and limits are refused", () => {
|
|
85
|
-
const s = scratch(), a = s.project("a");
|
|
86
|
-
expect(s.kz(a, "remember", "--track", "code", "--tags", "bun", "--applies", "bun>=1.1\nlinux", "--run", "r1", "one line please").code).toBe(0);
|
|
87
|
-
expect(s.kz(a, "recall", "--tags", "bun").out).toContain("(applies: bun>=1.1 linux)");
|
|
88
|
-
expect(s.kz(a, "remember", "--track", "code", "--tags", "bun]x", "--applies", "y", "--run", "r1", "x").out).toContain('tag "bun]x"');
|
|
89
|
-
expect(s.kz(a, "recall", "--tags", "bun", "--limit", "abc").code).toBe(1);
|
|
90
|
-
const before = s.file("code");
|
|
91
|
-
expect(s.kz(a, "remember", "--track", "code", "--tags", "bun", "--applies", "y", "--source", "p/r1\nstray", "x").code).toBe(1);
|
|
92
|
-
expect(s.file("code")).toBe(before);
|
|
93
|
-
const spaced = s.project("my app");
|
|
94
|
-
expect(s.kz(spaced, "remember", "--track", "code", "--tags", "bun", "--applies", "y", "--run", "r1", "spaced folder").code).toBe(0);
|
|
95
|
-
expect(s.file("code")).toContain("· my-app/r1");
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test("--replace rewrites only the named line", () => {
|
|
99
|
-
const s = scratch(), a = s.project("a");
|
|
100
|
-
s.kz(a, ...lesson("first lesson about bun tests"));
|
|
101
|
-
s.kz(a, "remember", "--track", "code", "--tags", "go", "--applies", "go>=1.21", "--run", "r1", "second lesson about go");
|
|
102
|
-
const n = s.file("code").split("\n").findIndex((l) => l.includes("first lesson")) + 1;
|
|
103
|
-
expect(s.kz(a, ...lesson("--replace", String(n), "rewritten bun lesson")).code).toBe(0);
|
|
104
|
-
const body = s.file("code");
|
|
105
|
-
expect(body).not.toContain("first lesson");
|
|
106
|
-
expect(body).toContain("rewritten bun lesson");
|
|
107
|
-
expect(body).toContain("second lesson about go");
|
|
108
|
-
expect(s.kz(a, ...lesson("--replace", "1", "x")).out).toContain("not a lesson");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test("versions in tags keep lessons apart, recall matches text words and honours the limit", () => {
|
|
112
|
-
const s = scratch(), a = s.project("a");
|
|
113
|
-
s.kz(a, "remember", "--track", "code", "--tags", "bun@1.1", "--applies", "bun 1.1 only", "--run", "r1", "lockfile is binary bun.lockb");
|
|
114
|
-
s.kz(a, "remember", "--track", "code", "--tags", "bun@1.2", "--applies", "bun>=1.2", "--run", "r1", "lockfile is text bun.lock");
|
|
115
|
-
const body = s.file("code");
|
|
116
|
-
expect(body).toContain("binary bun.lockb");
|
|
117
|
-
expect(body).toContain("text bun.lock");
|
|
118
|
-
expect(s.kz(a, "recall", "--tags", "bun@1.2").out.split("\n")[0]).toContain("bun@1.2");
|
|
119
|
-
s.kz(a, "remember", "--track", "code", "--tags", "ci", "--applies", "any runner", "--run", "r1", "flaky snapshot diffs come from locale-dependent dates");
|
|
120
|
-
expect(s.kz(a, "recall", "--query", "why are snapshot tests flaky").out).toContain("locale-dependent");
|
|
121
|
-
expect(s.kz(a, "recall", "--tags", "bun", "--limit", "1").out.trim().split("\n")).toHaveLength(1);
|
|
122
|
-
expect(s.kz(a, "recall", "--tags", "elixir").out.trim()).toBe("Recalled: none");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("session hook merge keeps other hooks, is idempotent, leaves invalid JSON alone, removes only ours", () => {
|
|
126
|
-
const s = scratch(), f = join(s.home, ".claude", "settings.json");
|
|
127
|
-
mkdirSync(dirname(f), { recursive: true });
|
|
128
|
-
const theirs = { model: "x", hooks: { SessionStart: [{ hooks: [{ type: "command", command: "echo hi" }] }] } };
|
|
129
|
-
writeFileSync(f, JSON.stringify(theirs));
|
|
130
|
-
expect(addSessionHook(f)).toBe("added");
|
|
131
|
-
const once = readFileSync(f, "utf8");
|
|
132
|
-
expect(addSessionHook(f)).toBe("");
|
|
133
|
-
expect(readFileSync(f, "utf8")).toBe(once);
|
|
134
|
-
const j = JSON.parse(once);
|
|
135
|
-
expect(j.model).toBe("x");
|
|
136
|
-
expect(JSON.stringify(j)).toContain("echo hi");
|
|
137
|
-
expect(JSON.stringify(j)).toContain("recall --session");
|
|
138
|
-
expect(removeSessionHook(f)).toBe(true);
|
|
139
|
-
expect(JSON.parse(readFileSync(f, "utf8"))).toEqual(theirs);
|
|
140
|
-
writeFileSync(f, "{ not json");
|
|
141
|
-
expect(addSessionHook(f)).toContain("not valid JSON");
|
|
142
|
-
expect(readFileSync(f, "utf8")).toBe("{ not json");
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test("acceptance: saved in A, recalled and injected in B, opt-out A' writes nothing", () => {
|
|
146
|
-
const s = scratch();
|
|
147
|
-
const a = s.project("project-a");
|
|
148
|
-
const saved = s.kz(a, "remember", "--track", "code", "--tags", "bun,testing", "--applies", "bun>=1.1", "--run", "2026-10-27-x",
|
|
149
|
-
"bun test --bail stops at the first failing file, not the first failing test");
|
|
150
|
-
expect(saved.code).toBe(0);
|
|
151
|
-
expect(saved.out).toContain("Remembered (global):");
|
|
152
|
-
|
|
153
|
-
const b = s.project("project-b", { "package.json": JSON.stringify({ devDependencies: { typescript: "5" } }), "bun.lock": "" });
|
|
154
|
-
const found = s.kz(b, "recall", "--track", "code", "--tags", "bun", "--query", "make tests stop early");
|
|
155
|
-
expect(found.out).toContain("--bail stops at the first failing file");
|
|
156
|
-
expect(found.out).toContain("project-a/2026-10-27-x");
|
|
157
|
-
const hook = s.kz(b, "recall", "--session");
|
|
158
|
-
expect(hook.out.startsWith(SESSION_HEADER)).toBe(true);
|
|
159
|
-
expect(hook.out).toContain("--bail");
|
|
160
|
-
// A project with no matching stack gets nothing injected, not a fallback.
|
|
161
|
-
const py = s.project("project-py", { "requirements.txt": "flask\n" });
|
|
162
|
-
expect(s.kz(py, "recall", "--session").out).toBe("");
|
|
163
|
-
|
|
164
|
-
const before = s.file("code");
|
|
165
|
-
const secret = s.project("project-a2", { ".kaizen/config.yml": "knowledge:\n # client work\n global: false\n" });
|
|
166
|
-
const refused = s.kz(secret, "remember", "--track", "code", "--tags", "bun", "--applies", "bun", "--run", "r9", "a lesson from client work");
|
|
167
|
-
expect(refused.code).toBe(1);
|
|
168
|
-
expect(refused.out).toContain("knowledge.global is false");
|
|
169
|
-
expect(s.file("code")).toBe(before);
|
|
170
|
-
expect(s.kz(secret, "recall", "--tags", "bun").out).toContain("--bail");
|
|
171
|
-
|
|
172
|
-
// The global switch turns it off everywhere; a project can switch it back on.
|
|
173
|
-
writeFileSync(join(s.home, ".kaizen", "config.yml"), "knowledge:\n global: false\n");
|
|
174
|
-
expect(s.kz(a, "remember", "--track", "code", "--tags", "bun", "--applies", "bun", "--run", "r2", "global off").code).toBe(1);
|
|
175
|
-
const on = s.project("project-on", { ".kaizen/config.yml": "knowledge:\n global: true\n" });
|
|
176
|
-
expect(s.kz(on, "remember", "--track", "code", "--tags", "bun", "--applies", "bun", "--run", "r3", "project overrides global").code).toBe(0);
|
|
177
|
-
|
|
178
|
-
expect(existsSync(realKnowledge) ? statSync(realKnowledge).mtimeMs : -1).toBe(realMtime);
|
|
179
|
-
});
|
package/cli/localsend.test.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// LocalSend's sending half against a fake device that speaks protocol v2: what it
|
|
2
|
-
// receives, and what each of its refusals reads as on the page.
|
|
3
|
-
import { test, expect } from "bun:test";
|
|
4
|
-
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { tmpdir } from "node:os";
|
|
7
|
-
import { randomBytes, X509Certificate, createPrivateKey } from "node:crypto";
|
|
8
|
-
import { identity, sendFile, type Device } from "./localsend.ts";
|
|
9
|
-
|
|
10
|
-
// prepare: what prepare-upload answers (a status, or "hang" to never answer).
|
|
11
|
-
function fakeDevice(prepare: number | "hang") {
|
|
12
|
-
const got: { prepare?: any; upload?: { query: Record<string, string>; bytes: Buffer } } = {};
|
|
13
|
-
const srv = Bun.serve({ port: 0, hostname: "127.0.0.1", async fetch(req) {
|
|
14
|
-
const u = new URL(req.url);
|
|
15
|
-
if (u.pathname === "/api/localsend/v2/prepare-upload") {
|
|
16
|
-
got.prepare = await req.json();
|
|
17
|
-
if (prepare === "hang") { await Bun.sleep(5000); return new Response(null, { status: 500 }); }
|
|
18
|
-
if (prepare !== 200) return new Response(null, { status: prepare });
|
|
19
|
-
return Response.json({ sessionId: "s-1", files: { f1: "tok-1" } });
|
|
20
|
-
}
|
|
21
|
-
if (u.pathname === "/api/localsend/v2/upload") {
|
|
22
|
-
const q = Object.fromEntries(u.searchParams);
|
|
23
|
-
if (q.sessionId !== "s-1" || q.token !== "tok-1" || q.fileId !== "f1") return new Response(null, { status: 403 });
|
|
24
|
-
got.upload = { query: q, bytes: Buffer.from(await req.arrayBuffer()) };
|
|
25
|
-
return new Response(null, { status: 200 });
|
|
26
|
-
}
|
|
27
|
-
return new Response(null, { status: 404 });
|
|
28
|
-
} });
|
|
29
|
-
const dev: Device = { alias: "Pixel 8", deviceModel: "Pixel", deviceType: "mobile", ip: "127.0.0.1", port: srv.port, protocol: "http", fingerprint: "fp" };
|
|
30
|
-
return { dev, got, stop: () => srv.stop(true) };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function file() {
|
|
34
|
-
const f = join(mkdtempSync(join(tmpdir(), "kaizen-ls-")), "demo-9x16.mp4");
|
|
35
|
-
writeFileSync(f, randomBytes(300_000));
|
|
36
|
-
return f;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
test("a send carries the file's bytes with the session and token the device gave", async () => {
|
|
40
|
-
const d = fakeDevice(200), f = file(), steps: string[] = [];
|
|
41
|
-
try {
|
|
42
|
-
expect(await sendFile(d.dev, f, (p) => steps.push(p.phase))).toEqual({ ok: true });
|
|
43
|
-
expect(d.got.prepare.files.f1).toMatchObject({ id: "f1", fileName: "demo-9x16.mp4", size: 300_000, fileType: "video/mp4" });
|
|
44
|
-
expect(d.got.prepare.info.alias).toStartWith("kaizen");
|
|
45
|
-
expect(d.got.upload!.query).toEqual({ sessionId: "s-1", fileId: "f1", token: "tok-1" });
|
|
46
|
-
expect(d.got.upload!.bytes.equals(await Bun.file(f).bytes().then(Buffer.from))).toBe(true);
|
|
47
|
-
expect(steps[0]).toBe("waiting");
|
|
48
|
-
expect(steps.at(-1)).toBe("uploading");
|
|
49
|
-
} finally { d.stop(); }
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("a refusal, a busy device and no answer each say so, never sent", async () => {
|
|
53
|
-
const f = file();
|
|
54
|
-
for (const [status, words] of [[403, "Pixel 8 said no"], [409, "Pixel 8 is busy with another transfer"], [401, "PIN"], [500, "Pixel 8 answered 500"]] as const) {
|
|
55
|
-
const d = fakeDevice(status);
|
|
56
|
-
try {
|
|
57
|
-
const r = await sendFile(d.dev, f);
|
|
58
|
-
expect(r.ok).toBe(false);
|
|
59
|
-
expect((r as any).error).toContain(words);
|
|
60
|
-
expect(d.got.upload).toBeUndefined();
|
|
61
|
-
} finally { d.stop(); }
|
|
62
|
-
}
|
|
63
|
-
const d = fakeDevice("hang");
|
|
64
|
-
try {
|
|
65
|
-
const r = await sendFile(d.dev, f, () => {}, { acceptMs: 300 });
|
|
66
|
-
expect(r).toEqual({ ok: false, error: "No answer from Pixel 8 in 1 minute" });
|
|
67
|
-
} finally { d.stop(); }
|
|
68
|
-
// Nobody there at all.
|
|
69
|
-
const r = await sendFile({ ...d.dev, port: 1 }, f);
|
|
70
|
-
expect(r.ok).toBe(false);
|
|
71
|
-
expect((r as any).error).toStartWith("Could not reach Pixel 8");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// A real LocalSend in HTTPS mode refuses a sender without a client certificate
|
|
75
|
-
// ("tlsv13 alert certificate required"), and reads the sender's fingerprint as its SHA-256.
|
|
76
|
-
test("we carry a self-signed certificate whose SHA-256 is our fingerprint", () => {
|
|
77
|
-
const me = identity(), x = new X509Certificate(me.cert);
|
|
78
|
-
expect(x.subject).toBe("CN=kaizen");
|
|
79
|
-
expect(x.verify(x.publicKey)).toBe(true);
|
|
80
|
-
expect(x.checkPrivateKey(createPrivateKey(me.key))).toBe(true);
|
|
81
|
-
expect(x.fingerprint256.replace(/:/g, "")).toBe(me.fingerprint);
|
|
82
|
-
expect(new Date(x.validTo).getTime()).toBeGreaterThan(Date.now() + 365 * 86_400_000);
|
|
83
|
-
expect(identity()).toBe(me);
|
|
84
|
-
});
|
package/cli/logo.test.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test";
|
|
2
|
-
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { projectLogo } from "./logo.ts";
|
|
6
|
-
|
|
7
|
-
test("projectLogo finds a fixed-name logo and nothing else", () => {
|
|
8
|
-
const root = mkdtempSync(join(tmpdir(), "kz-logo-"));
|
|
9
|
-
mkdirSync(join(root, ".kaizen"));
|
|
10
|
-
expect(projectLogo(join(root, ".kaizen"))).toBeNull();
|
|
11
|
-
writeFileSync(join(root, "brand.png"), "x");
|
|
12
|
-
expect(projectLogo(join(root, ".kaizen"))).toBeNull();
|
|
13
|
-
mkdirSync(join(root, "public"));
|
|
14
|
-
writeFileSync(join(root, "public", "favicon.svg"), "<svg/>");
|
|
15
|
-
expect(projectLogo(join(root, ".kaizen"))).toBe(join(root, "public", "favicon.svg"));
|
|
16
|
-
writeFileSync(join(root, "logo.png"), "x");
|
|
17
|
-
expect(projectLogo(join(root, ".kaizen"))).toBe(join(root, "logo.png"));
|
|
18
|
-
});
|
package/cli/notes.test.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
// The notebook: file safety in cli/notes.ts, the text rules in web/notes-lib.ts, and
|
|
2
|
-
// the two things that drift silently — the copied design tokens and the committed bundle.
|
|
3
|
-
import { test, expect, beforeEach } from "bun:test";
|
|
4
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, readdirSync, utimesSync, symlinkSync } from "node:fs";
|
|
5
|
-
import { join, dirname } from "node:path";
|
|
6
|
-
import { tmpdir } from "node:os";
|
|
7
|
-
import { safeName, listNotes, saveNote, renameNote, deleteNote, boardIndex, linksTo } from "./notes.ts";
|
|
8
|
-
import { wikilinks, tags, resolve, safeUrl, tree, uncode, freshName, parseTable, boardLink, resolveRun, anchorWords } from "../web/notes-lib.ts";
|
|
9
|
-
import { sourceHash, OUT, TERM_OUT, BOARD_OUT, BOT_OUT, VIDEO_OUT } from "./build-web.ts";
|
|
10
|
-
|
|
11
|
-
let state = "";
|
|
12
|
-
beforeEach(() => { state = join(mkdtempSync(join(tmpdir(), "kaizen-notes-")), ".kaizen"); mkdirSync(state); });
|
|
13
|
-
const root = dirname(import.meta.dir);
|
|
14
|
-
|
|
15
|
-
test("safeName: folders allowed, nothing that leaves notes/", () => {
|
|
16
|
-
expect(safeName("Work/Standup")).toBe("Work/Standup");
|
|
17
|
-
expect(safeName(" Task.md ")).toBe("Task");
|
|
18
|
-
expect(safeName(" a / b ")).toBe("a/b");
|
|
19
|
-
for (const bad of ["", "../x", "a/../../b", ".hidden", "a/.b", "/etc/passwd", "a\\b", "C:x", "a//b", "a/", "x\ny", "1/2/3/4/5/6/7", "x".repeat(121), 7, null])
|
|
20
|
-
expect(safeName(bad as string)).toBeNull();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("every write route refuses a name outside notes/, and writes nothing", () => {
|
|
24
|
-
for (const bad of ["../escape", "a/../../escape", "/tmp/escape"]) {
|
|
25
|
-
expect(saveNote(state, bad, "x", 0)).toEqual({ ok: false, why: "bad name" });
|
|
26
|
-
expect(renameNote(state, bad, "ok")).toBe("bad name");
|
|
27
|
-
expect(deleteNote(state, bad)).toBe("bad name");
|
|
28
|
-
}
|
|
29
|
-
saveNote(state, "ok", "x", 0);
|
|
30
|
-
expect(renameNote(state, "ok", "../../escape")).toBe("bad name");
|
|
31
|
-
expect(readdirSync(dirname(state)).sort()).toEqual([".kaizen"]);
|
|
32
|
-
expect(readdirSync(state)).toEqual(["notes"]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("save: creates folders, then refuses a stale base and returns what is on disk", () => {
|
|
36
|
-
const a = saveNote(state, "Work/Standup", "one", 0);
|
|
37
|
-
expect(a.ok).toBe(true);
|
|
38
|
-
if (!a.ok) return;
|
|
39
|
-
expect(readFileSync(join(state, "notes", "Work", "Standup.md"), "utf8")).toBe("one");
|
|
40
|
-
// Created twice: the second is a conflict, not an overwrite.
|
|
41
|
-
expect(saveNote(state, "Work/Standup", "again", 0).ok).toBe(false);
|
|
42
|
-
// Someone else writes it.
|
|
43
|
-
const f = join(state, "notes", "Work", "Standup.md");
|
|
44
|
-
writeFileSync(f, "theirs"); utimesSync(f, new Date(), new Date(Date.now() + 5000));
|
|
45
|
-
const c = saveNote(state, "Work/Standup", "mine", a.mtime);
|
|
46
|
-
expect(c).toMatchObject({ ok: false, why: "conflict", text: "theirs" });
|
|
47
|
-
expect(readFileSync(f, "utf8")).toBe("theirs");
|
|
48
|
-
// Saving over what is there now works.
|
|
49
|
-
if (!c.ok && c.mtime) expect(saveNote(state, "Work/Standup", "mine", c.mtime).ok).toBe(true);
|
|
50
|
-
expect(readFileSync(f, "utf8")).toBe("mine");
|
|
51
|
-
// A note deleted elsewhere, saved with an old base: a conflict with nothing there.
|
|
52
|
-
expect(saveNote(state, "Gone", "x", 123)).toMatchObject({ ok: false, why: "conflict", text: "" });
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("save keeps the text byte for byte, CRLF included", () => {
|
|
56
|
-
const text = "# T\r\n\r\n- [ ] a\r\n\ttab \r\n";
|
|
57
|
-
saveNote(state, "crlf", text, 0);
|
|
58
|
-
expect(readFileSync(join(state, "notes", "crlf.md"), "utf8")).toBe(text);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("list: recursive, newest first, dot folders skipped", () => {
|
|
62
|
-
saveNote(state, "a", "A", 0);
|
|
63
|
-
saveNote(state, "Work/b", "B", 0);
|
|
64
|
-
const later = join(state, "notes", "Work", "b.md"); utimesSync(later, new Date(), new Date(Date.now() + 5000));
|
|
65
|
-
mkdirSync(join(state, "notes", ".obsidian")); writeFileSync(join(state, "notes", ".obsidian", "x.md"), "no");
|
|
66
|
-
writeFileSync(join(state, "notes", "skip.txt"), "no");
|
|
67
|
-
expect(listNotes(state).map((n) => n.name)).toEqual(["Work/b", "a"]);
|
|
68
|
-
expect(listNotes(join(state, "nothing"))).toEqual([]);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("list: only names the notebook can save back; a symlinked folder once, never a loop", () => {
|
|
72
|
-
const n = join(state, "notes");
|
|
73
|
-
saveNote(state, "ok", "x", 0);
|
|
74
|
-
// Windows refuses these names outright, so there is nothing to list.
|
|
75
|
-
if (process.platform !== "win32") { writeFileSync(join(n, "What?.md"), "x"); writeFileSync(join(n, "a: b.md"), "x"); }
|
|
76
|
-
mkdirSync(join(n, "1/2/3/4/5/6"), { recursive: true }); writeFileSync(join(n, "1/2/3/4/5/6/deep.md"), "x");
|
|
77
|
-
mkdirSync(join(n, "trail ")); writeFileSync(join(n, "trail ", "x.md"), "x");
|
|
78
|
-
symlinkSync(process.platform === "win32" ? dirname(n) : "..", join(n, "up"), "junction"); // a junction needs no admin
|
|
79
|
-
expect(listNotes(state).map((x) => x.name)).toEqual(["ok"]);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("rename moves between folders, refuses to clobber, prunes the emptied folder", () => {
|
|
83
|
-
saveNote(state, "Old/x", "X", 0);
|
|
84
|
-
saveNote(state, "y", "Y", 0);
|
|
85
|
-
expect(renameNote(state, "Old/x", "y")).toBe("a note with that name exists");
|
|
86
|
-
expect(renameNote(state, "nope", "z")).toBe("no such note");
|
|
87
|
-
expect(renameNote(state, "Old/x", "New/Deep/x")).toBeNull();
|
|
88
|
-
expect(existsSync(join(state, "notes", "Old"))).toBe(false);
|
|
89
|
-
expect(readFileSync(join(state, "notes", "New", "Deep", "x.md"), "utf8")).toBe("X");
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test("delete moves to .trash, never unlinks", () => {
|
|
93
|
-
saveNote(state, "F/gone", "keep me", 0);
|
|
94
|
-
expect(deleteNote(state, "F/gone")).toBeNull();
|
|
95
|
-
expect(deleteNote(state, "F/gone")).toBe("no such note");
|
|
96
|
-
const trash = readdirSync(join(state, "notes", ".trash"));
|
|
97
|
-
expect(trash.length).toBe(1);
|
|
98
|
-
expect(trash[0]).toEndWith("-F~gone.md");
|
|
99
|
-
expect(readFileSync(join(state, "notes", ".trash", trash[0]!), "utf8")).toBe("keep me");
|
|
100
|
-
expect(existsSync(join(state, "notes", "F"))).toBe(false);
|
|
101
|
-
expect(listNotes(state)).toEqual([]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test("wikilinks: plain, labelled, anchored; none inside code", () => {
|
|
105
|
-
const t = "See [[Alpha]] and [[Work/Beta|the beta]] and [[Gamma#Part]].\n`[[not]]`\n```\n[[nor]]\n```\n";
|
|
106
|
-
const w = wikilinks(t);
|
|
107
|
-
expect(w.map((x) => [x.name, x.label])).toEqual([["Alpha", "Alpha"], ["Work/Beta", "the beta"], ["Gamma", "Gamma#Part"]]);
|
|
108
|
-
expect(t.slice(w[1]!.from, w[1]!.to)).toBe("[[Work/Beta|the beta]]");
|
|
109
|
-
// uncode keeps offsets: blanked text is the same length.
|
|
110
|
-
expect(uncode(t).length).toBe(t.length);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test("tags: words after a space or at line start; not headings, numbers, urls or code", () => {
|
|
114
|
-
const t = "#plan and #Work/Q3 here\n# Heading\nissue #12 x#y http://a.b/#frag\n`#code`\n(#paren)";
|
|
115
|
-
expect(tags(t).map((x) => x.tag)).toEqual(["plan", "work/q3", "paren"]);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test("indented code is code: no tags or wikilinks in it; list continuations still count", () => {
|
|
119
|
-
const t = "Para #one\n\n #include <x>\n [[inCode]]\n\n\tmore #nottag\n\nback #two\n- item\n #three [[Cont]]\n";
|
|
120
|
-
expect(tags(t).map((x) => x.tag)).toEqual(["one", "two", "three"]);
|
|
121
|
-
expect(wikilinks(t).map((x) => x.name)).toEqual(["Cont"]);
|
|
122
|
-
expect(uncode(t).length).toBe(t.length);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("resolve: exact name first, then by last segment, ignoring case", () => {
|
|
126
|
-
const names = ["Work/Standup", "Home/Standup", "Alpha"];
|
|
127
|
-
expect(resolve("alpha", names)).toBe("Alpha");
|
|
128
|
-
expect(resolve("Work/Standup", names)).toBe("Work/Standup");
|
|
129
|
-
expect(resolve("standup", names)).toBe("Home/Standup");
|
|
130
|
-
expect(resolve("Nope", names)).toBeNull();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test("safeUrl: web, mail and relative only", () => {
|
|
134
|
-
for (const ok of ["https://x.dev", "http://x", "mailto:a@b.c", "Other note.md", "img/a.png", "#part"]) expect(safeUrl(ok)).toBe(ok);
|
|
135
|
-
for (const bad of ["javascript:alert(1)", " JavaScript:alert(1)", "data:text/html,x", "vbscript:x", "file:///etc/passwd", "//evil.com/x", "java\tscript:x", ""])
|
|
136
|
-
expect(safeUrl(bad)).toBeNull();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test("parseTable: header, alignment, rows padded, escaped pipes kept", () => {
|
|
140
|
-
expect(parseTable("| A | B | C |\n|:--|:-:|--:|\n| 1 | a \\| b |\n|2|3|4|5|\n")).toEqual({
|
|
141
|
-
head: ["A", "B", "C"], align: ["left", "center", "right"], rows: [["1", "a | b", ""], ["2", "3", "4"]],
|
|
142
|
-
});
|
|
143
|
-
expect(parseTable("A | B\r\n--- | ---\r\nx | y").rows).toEqual([["x", "y"]]);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
test("board links: kinds, tabs, items; a note link is not one", () => {
|
|
147
|
-
const w = (t: string) => wikilinks(t)[0]!;
|
|
148
|
-
expect(boardLink(w("[[run:2026-10-01-notebook]]"))).toEqual({ kind: "run", id: "2026-10-01-notebook" });
|
|
149
|
-
expect(boardLink(w("[[run:notebook#Review|see]]"))).toEqual({ kind: "run", id: "notebook", tab: "review" });
|
|
150
|
-
expect(boardLink(w("[[run:notebook#finding-2]]"))).toEqual({ kind: "run", id: "notebook", tab: "review", item: { type: "finding", n: 2 } });
|
|
151
|
-
expect(boardLink(w("[[run:notebook#backlog-13]]"))).toEqual({ kind: "run", id: "notebook", tab: "backlog", item: { type: "backlog", n: 13 } });
|
|
152
|
-
expect(boardLink(w("[[run:notebook#nonsense]]"))).toEqual({ kind: "run", id: "notebook" });
|
|
153
|
-
expect(boardLink(w("[[idea:fix #12 in the FAQ]]"))).toEqual({ kind: "idea", text: "fix #12 in the FAQ" });
|
|
154
|
-
expect(boardLink(w("[[Standup]]"))).toBeNull();
|
|
155
|
-
expect(boardLink(w("[[run:../../x]]"))).toBeNull();
|
|
156
|
-
expect(w("[[Note#Part|p]]")).toMatchObject({ name: "Note", anchor: "Part", target: "Note#Part", label: "p" });
|
|
157
|
-
expect(anchorWords({ kind: "run", id: "x", tab: "review", item: { type: "finding", n: 2 } })).toBe("finding 2");
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test("resolveRun: exact id, else the newest run of that name", () => {
|
|
161
|
-
const ids = ["2026-09-01-notebook", "2026-10-01-notebook", "2026-10-01-notebook-board-links"];
|
|
162
|
-
expect(resolveRun("2026-09-01-notebook", ids)).toBe("2026-09-01-notebook");
|
|
163
|
-
expect(resolveRun("notebook", ids)).toBe("2026-10-01-notebook");
|
|
164
|
-
expect(resolveRun("board-links", ids)).toBeNull();
|
|
165
|
-
expect(resolveRun("nope", ids)).toBeNull();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test("boardIndex and linksTo: runs with findings and every backlog line numbered; notes that link a run", () => {
|
|
169
|
-
const run = (id: string, files: Record<string, string>) => {
|
|
170
|
-
mkdirSync(join(state, "runs", id), { recursive: true });
|
|
171
|
-
writeFileSync(join(state, "runs", id, "state.json"), JSON.stringify({ id, stage: "done", awaiting: null }));
|
|
172
|
-
for (const [f, t] of Object.entries(files)) writeFileSync(join(state, "runs", id, f), t);
|
|
173
|
-
};
|
|
174
|
-
run("2026-10-01-notes", {
|
|
175
|
-
"00-request.md": "# Request\n\n> make notes\n",
|
|
176
|
-
"04-review.md": "# Review\n\n## Findings\n\n1. a.ts:1: high: first. fix.\n2. b.ts:2: low: second. fix.\n",
|
|
177
|
-
"06-backlog.md": "# Backlog\n\n- done: one | x\n- open: two | y\n- rejected: three | z\n",
|
|
178
|
-
});
|
|
179
|
-
run("2026-10-02-other", {});
|
|
180
|
-
writeFileSync(join(state, "inbox.md"), "- open: a task here\n");
|
|
181
|
-
const ix = boardIndex(state);
|
|
182
|
-
const r = ix.runs.find((x) => x.id === "2026-10-01-notes")!;
|
|
183
|
-
expect(r.short).toBe("notes");
|
|
184
|
-
expect(r.findings.map((f) => f.n)).toEqual([1, 2]);
|
|
185
|
-
expect(r.backlog).toEqual([{ n: 1, status: "done", text: "one | x" }, { n: 2, status: "open", text: "two | y" }, { n: 3, status: "rejected", text: "three | z" }]);
|
|
186
|
-
expect(ix.ideas.map((i) => i.text)).toEqual(["a task here"]);
|
|
187
|
-
saveNote(state, "A", "see [[run:notes#finding-1]]", 0);
|
|
188
|
-
saveNote(state, "B", "see [[run:2026-10-02-other]] and [[notes]]", 0);
|
|
189
|
-
saveNote(state, "C", "`[[run:notes]]` in code", 0);
|
|
190
|
-
expect(linksTo(state, "2026-10-01-notes")).toEqual(["A"]);
|
|
191
|
-
expect(linksTo(state, "2026-10-02-other")).toEqual(["B"]);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
test("tree and freshName", () => {
|
|
195
|
-
const tr = tree(["b", "Z/c", "A/x", "A/B/y", "a2"]);
|
|
196
|
-
expect([...tr.folders.keys()]).toEqual(["A", "Z"]);
|
|
197
|
-
expect(tr.notes).toEqual(["a2", "b"]);
|
|
198
|
-
expect([...tr.folders.get("A")!.folders.keys()]).toEqual(["B"]);
|
|
199
|
-
expect(freshName(["Untitled", "untitled 2"])).toBe("Untitled 3");
|
|
200
|
-
expect(freshName(["Untitled"], "Work")).toBe("Work/Untitled");
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
test("the notebook's design tokens are the board's, line for line", () => {
|
|
204
|
-
const block = (f: string) => {
|
|
205
|
-
const s = readFileSync(join(root, "web", f), "utf8").split("\n");
|
|
206
|
-
const at = s.findIndex((l) => l.startsWith(":root{--bg:"));
|
|
207
|
-
return s.slice(at, at + 11).join("\n");
|
|
208
|
-
};
|
|
209
|
-
expect(block("notes.html")).toBe(block("board.html"));
|
|
210
|
-
expect(block("board.html")).toContain("data-theme=dark]{--shade");
|
|
211
|
-
expect(block("board.html")).toContain(":root[data-color=blue][data-theme=dark]{");
|
|
212
|
-
const syms = (f: string) => readFileSync(join(root, "web", f), "utf8").split("\n").filter((l) => l.startsWith('<symbol id="s-')).join("\n");
|
|
213
|
-
expect(syms("notes.html")).toBe(syms("board.html"));
|
|
214
|
-
expect(syms("board.html").split("\n").length).toBe(7);
|
|
215
|
-
const mascot = (f: string) => readFileSync(join(root, "web", f), "utf8").split("\n").find((l) => l.startsWith(".mascot{"));
|
|
216
|
-
expect(mascot("notes.html")).toBe(mascot("board.html")!);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
test("the side menu is the board's on the notebook, line for line", () => {
|
|
220
|
-
const between = (f: string, from: string, to: string) => {
|
|
221
|
-
const s = readFileSync(join(root, "web", f), "utf8");
|
|
222
|
-
const at = s.indexOf(from);
|
|
223
|
-
expect(at).toBeGreaterThan(-1);
|
|
224
|
-
return s.slice(at, s.indexOf(to, at) + to.length);
|
|
225
|
-
};
|
|
226
|
-
for (const [from, to] of [["/* side menu:", "/* end side menu */"], ['<nav class="rail"', "</script>"]] as const)
|
|
227
|
-
for (const page of ["notes.html", "video.html"]) expect(between(page, from, to)).toBe(between("board.html", from, to));
|
|
228
|
-
const syms = (f: string) => ["board", "note", "video", "link", "gear", "side", "sun", "moon", "more"].map((n) => readFileSync(join(root, "web", f), "utf8").split("\n").find((l) => l.startsWith(`<symbol id="i-${n}"`)));
|
|
229
|
-
expect(syms("notes.html")).toEqual(syms("board.html"));
|
|
230
|
-
expect(syms("video.html")).toEqual(syms("board.html"));
|
|
231
|
-
expect(syms("board.html").every(Boolean)).toBe(true);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
test("web/notebook.js, web/term.js, web/board.js, web/video.js and bot/web/app.js were built from the sources as they are (bun run build:web)", () => {
|
|
235
|
-
expect(readFileSync(OUT, "utf8").split("\n", 1)[0]!).toContain(`kaizen notebook ${sourceHash()} `);
|
|
236
|
-
expect(readFileSync(TERM_OUT, "utf8").split("\n", 1)[0]!).toContain(`kaizen terminal ${sourceHash()} `);
|
|
237
|
-
expect(readFileSync(BOARD_OUT, "utf8").split("\n", 1)[0]!).toContain(`kaizen board ${sourceHash()} `);
|
|
238
|
-
expect(readFileSync(BOT_OUT, "utf8").split("\n", 1)[0]!).toContain(`kaizen bot page ${sourceHash()} `);
|
|
239
|
-
expect(readFileSync(VIDEO_OUT, "utf8").split("\n", 1)[0]!).toContain(`kaizen video page ${sourceHash()} `);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
test("an installed app fits the window, not the screen", () => {
|
|
243
|
-
for (const f of ["board.html", "notes.html", "video.html"]) {
|
|
244
|
-
const s = readFileSync(join(root, "web", f), "utf8");
|
|
245
|
-
expect(s).not.toMatch(/--sh\b(?!a)/);
|
|
246
|
-
expect(s).toContain("inset:0 0 auto;height:100dvh");
|
|
247
|
-
expect(s).toContain("body::after{content");
|
|
248
|
-
}
|
|
249
|
-
});
|
package/cli/onboarding.test.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test";
|
|
2
|
-
import { mkdtempSync, readFileSync, writeFileSync, mkdirSync, realpathSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { onboardingView, readOnboarding, writeOnboarding, installHelp, STEPS } from "./onboarding.ts";
|
|
6
|
-
|
|
7
|
-
const home = () => realpathSync(mkdtempSync(join(tmpdir(), "kz-onb-")));
|
|
8
|
-
|
|
9
|
-
test("a new user, with no project, is shown the flow", () => {
|
|
10
|
-
expect(onboardingView(home(), 0)).toEqual({ show: true, resume: false, step: 0, total: STEPS });
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test("a board with any project never shows it, saved state or not", () => {
|
|
14
|
-
const h = home();
|
|
15
|
-
expect(onboardingView(h, 1)).toMatchObject({ show: false, resume: false });
|
|
16
|
-
writeOnboarding(h, { step: 1 });
|
|
17
|
-
expect(onboardingView(h, 2)).toMatchObject({ show: false, resume: false });
|
|
18
|
-
writeOnboarding(h, { outcome: "skipped" });
|
|
19
|
-
expect(onboardingView(h, 1)).toMatchObject({ show: false, resume: false });
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("skipped or left half done comes back as resume at the step reached; done and dismissed never do", () => {
|
|
23
|
-
const h = home();
|
|
24
|
-
writeOnboarding(h, { step: 2 });
|
|
25
|
-
expect(onboardingView(h, 0)).toMatchObject({ show: false, resume: true, step: 2 });
|
|
26
|
-
writeOnboarding(h, { outcome: "skipped" });
|
|
27
|
-
expect(onboardingView(h, 0)).toMatchObject({ resume: true, step: 2 });
|
|
28
|
-
writeOnboarding(h, { outcome: "dismissed" });
|
|
29
|
-
expect(onboardingView(h, 0)).toMatchObject({ show: false, resume: false });
|
|
30
|
-
writeOnboarding(h, { outcome: "done" });
|
|
31
|
-
expect(onboardingView(h, 0)).toMatchObject({ show: false, resume: false });
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("a flow opened but not advanced shows again rather than resuming", () => {
|
|
35
|
-
const h = home();
|
|
36
|
-
writeOnboarding(h, { step: 0 });
|
|
37
|
-
expect(onboardingView(h, 0)).toMatchObject({ show: true, resume: false });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("writes merge, persist in the board's own file, and refuse anything else", () => {
|
|
41
|
-
const h = home();
|
|
42
|
-
expect(writeOnboarding(h, { step: 1 })).toEqual({ step: 1, outcome: null });
|
|
43
|
-
expect(writeOnboarding(h, { outcome: "skipped" })).toEqual({ step: 1, outcome: "skipped" });
|
|
44
|
-
expect(JSON.parse(readFileSync(join(h, ".kaizen", "onboarding.json"), "utf8"))).toEqual({ step: 1, outcome: "skipped" });
|
|
45
|
-
for (const bad of [{ step: -1 }, { step: STEPS }, { step: 1.5 }, { step: "1" }, { outcome: "finished" }, { outcome: 1 }])
|
|
46
|
-
expect(writeOnboarding(h, bad)).toEqual({ error: expect.any(String) });
|
|
47
|
-
expect(readOnboarding(h)).toEqual({ step: 1, outcome: "skipped" });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("a corrupt file reads as never started, and the next write replaces it", () => {
|
|
51
|
-
const h = home();
|
|
52
|
-
mkdirSync(join(h, ".kaizen"));
|
|
53
|
-
writeFileSync(join(h, ".kaizen", "onboarding.json"), "{nope");
|
|
54
|
-
expect(readOnboarding(h)).toBeNull();
|
|
55
|
-
expect(onboardingView(h, 0)).toMatchObject({ show: true });
|
|
56
|
-
expect(writeOnboarding(h, { step: 1 })).toEqual({ step: 1, outcome: null });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("installHelp covers every agent the step offers, with the same commands and pages as the installer", () => {
|
|
60
|
-
const src = readFileSync(join(import.meta.dir, "install.ts"), "utf8");
|
|
61
|
-
for (const win of [false, true]) {
|
|
62
|
-
const h = installHelp(win);
|
|
63
|
-
expect(Object.keys(h).sort()).toEqual(["agy", "claude", "codex", "gemini", "opencode"]);
|
|
64
|
-
for (const [cmd, x] of Object.entries(h)) {
|
|
65
|
-
expect(src).toContain(x.docs);
|
|
66
|
-
if (x.command) expect(src).toContain(x.command);
|
|
67
|
-
else expect(cmd).toBe("agy"); // only Antigravity has no command
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|