kaizen-agent 1.62.0 → 1.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/install.ts CHANGED
@@ -9,6 +9,7 @@ import { join, dirname, basename, resolve } from "node:path";
9
9
  import { homedir, tmpdir } from "node:os";
10
10
  import { ignoreKaizen } from "./add-project.ts";
11
11
  import { applyPreset, detectPreset, PRESETS, type PresetName } from "./settings.ts";
12
+ import { banner, c, nextSteps } from "./look.ts";
12
13
 
13
14
  // The real path: process.cwd() is always physical, so a raw $HOME that crosses a
14
15
  // symlink (/home -> var/home) would never compare equal to it, and the home
@@ -41,13 +42,6 @@ function parsePresetArg(): PresetName | null {
41
42
  }
42
43
  const presetArg = parsePresetArg();
43
44
 
44
- const c = {
45
- dim: (s: string) => `\x1b[2m${s}\x1b[0m`,
46
- bold: (s: string) => `\x1b[1m${s}\x1b[0m`,
47
- cyan: (s: string) => `\x1b[36m${s}\x1b[0m`,
48
- green: (s: string) => `\x1b[32m${s}\x1b[0m`,
49
- };
50
-
51
45
  // Skill folders shipped in skills/ and linked into every agent, by their last
52
46
  // path segment: media/kaizen-deck is linked as skills/kaizen-deck.
53
47
  const SKILLS = bundledSkills(dirname(import.meta.dir)).map((s) => s.rel);
@@ -124,6 +118,39 @@ if (Bun.argv[2] === "card") {
124
118
 
125
119
  // `kaizen computer <verb> ...`: desktop control through the accessibility tree, only while
126
120
  // the kaizen-computer skill is on. One JSON line out. See cli/computer.ts.
121
+ // `kaizen automation list | add | run | pause | resume | rm | runs`: schedules that start a run in this
122
+ // project. Fires happen while a board runs; `run` starts one now, in a terminal, without the precheck.
123
+ if (Bun.argv[2] === "automation") {
124
+ const A = await import("./automations.ts");
125
+ const { locate } = await import("./state.ts");
126
+ const state = locate() ?? join(home, ".kaizen");
127
+ const [verb, ...rest] = Bun.argv.slice(3);
128
+ const flag = (n: string) => { const i = rest.indexOf("--" + n); return i >= 0 ? rest.splice(i, 2)[1] : undefined; };
129
+ const fail = (m: string): never => { console.log(`\n ${m}\n`); process.exit(1); };
130
+ const rules = () => { try { return A.readRules(state); } catch (e: any) { return fail(e.message); } };
131
+ const find = (id?: string) => rules().find((r) => r.id === id) ?? fail("No such automation. See: kaizen automation list");
132
+ if (verb === "add") {
133
+ const input = { text: flag("text"), kind: flag("every"), time: flag("time"), day: flag("day"), cron: flag("cron"), precheck: flag("precheck"), grace_minutes: flag("grace"), agent: flag("agent"), name: rest.join(" ") };
134
+ if (input.cron && !input.kind) input.kind = "cron";
135
+ const r = A.addRule(state, input);
136
+ if (typeof r === "string") fail(`${r}\n kaizen automation add "<name>" --text "<request>" --every hourly|daily|weekdays|weekly [--time HH:MM] [--day mon] | --cron "<5 fields>" [--precheck "<cmd>"] [--grace N] [--agent <tool>]`);
137
+ else console.log(`\n ${c.green("added")} ${r.name} ${c.dim(`${r.id} · ${r.cron}`)}\n ${c.dim("Runs unattended in auto mode: it changes code and spends tokens with nobody watching.")}\n${r.precheck ? ` ${c.dim("precheck, runs on this computer every time it fires:")} ${r.precheck}\n` : ""}`);
138
+ } else if (verb === "list" || !verb) {
139
+ for (const r of rules()) { const n = A.nextRun(r.cron, Date.now()); console.log(` ${r.id} ${r.enabled ? "on " : "off"} ${r.cron.padEnd(14)} next ${n ? new Date(n).toLocaleString() : "never"} ${r.name}`); }
140
+ } else if (verb === "pause" || verb === "resume") {
141
+ const r = A.setEnabled(state, find(rest[0]).id, verb === "resume"); if (typeof r === "string") fail(r); console.log(`\n ${verb}d ${rest[0]}\n`);
142
+ } else if (verb === "rm") {
143
+ const r = A.removeRule(state, find(rest[0]).id); if (r) fail(r); console.log(`\n removed ${rest[0]}\n`);
144
+ } else if (verb === "run") {
145
+ const h = await A.fire(state, find(rest[0]), "manual", Date.now());
146
+ console.log(`\n ${h?.status}${h?.reason ? `: ${h.reason}` : ""}\n`); process.exit(h?.status === "launched" ? 0 : 1);
147
+ } else if (verb === "runs") {
148
+ const id = find(rest[0]).id;
149
+ for (const h of A.readHistory(state).filter((x) => x.rule === id).sort((a, b) => b.at - a.at)) { const v = A.shown(state, h); console.log(` ${new Date(h.at).toLocaleString()} ${h.kind.padEnd(9)} ${v.status}${v.run ? " " + v.run : ""}${h.reason ? " " + h.reason : ""}`); }
150
+ } else fail("kaizen automation list | add | run <id> | pause <id> | resume <id> | rm <id> | runs <id>");
151
+ process.exit(0);
152
+ }
153
+
127
154
  if (Bun.argv[2] === "computer") {
128
155
  const { computer } = await import("./computer.ts");
129
156
  const { out, code } = await computer(Bun.argv.slice(3), { home: homedir() });
@@ -288,7 +315,7 @@ if (Bun.argv[2] === "issue") {
288
315
  if (args.has("--env")) { console.log(systemInfo()); process.exit(0); }
289
316
  const what = Bun.argv.slice(3).join(" ");
290
317
  const url = issueUrl({ title: what.split("\n")[0], what });
291
- console.log(`\n ${c.cyan(url)}\n`);
318
+ console.log(`\n ${c.accent(url)}\n`);
292
319
  console.log(await openUrl(url)
293
320
  ? ` ${c.dim("Opened in your browser. Check it, then submit it on GitHub.")}\n`
294
321
  : ` ${c.dim("Open that link to file the issue.")}\n`);
@@ -336,6 +363,8 @@ async function removeEverything() {
336
363
  // projects live on other drives entirely. Every project kaizen knows about is
337
364
  // checked, plus whatever a drive-wide scan turns up.
338
365
  const { knownProjects, searchRoots, findProjects } = await import("./state.ts");
366
+ // Loaded now: the launcher runs this file from ~/kaizen, which is deleted below.
367
+ const { removeSessionHook } = await import("./knowledge.ts");
339
368
  step("looking for project installs");
340
369
  const roots = [home, process.cwd(), ...knownProjects(),
341
370
  ...searchRoots([process.cwd()]).flatMap((r) => findProjects(r))]
@@ -380,7 +409,6 @@ async function removeEverything() {
380
409
  drop(join(process.env.BUN_INSTALL ?? join(home, ".bun"), "bin", "kaizen.cmd"));
381
410
  drop(join(home, ".local", "bin", "kaizen"));
382
411
  {
383
- const { removeSessionHook } = await import("./knowledge.ts");
384
412
  if (removeSessionHook(join(home, ".claude", "settings.json"))) gone.push("the kaizen recall hook in ~/.claude/settings.json");
385
413
  }
386
414
  await clearBunxCache();
@@ -400,7 +428,7 @@ async function removeEverything() {
400
428
  }
401
429
  console.log(purge
402
430
  ? `\n ${c.dim("Runs and settings deleted too.")}\n`
403
- : `\n ${c.dim("Runs and settings kept in")} ${c.cyan(tilde(join(home, ".kaizen")))}${c.dim(" — add --purge to delete them.")}\n`);
431
+ : `\n ${c.dim("Runs and settings kept in")} ${c.accent(tilde(join(home, ".kaizen")))}${c.dim(" — add --purge to delete them.")}\n`);
404
432
  console.log(` ${c.dim("The CLAUDE.md / AGENTS.md line in each project is left for you to remove.")}\n`);
405
433
  }
406
434
 
@@ -450,11 +478,11 @@ async function noAgent(): Promise<boolean> {
450
478
  const docs = async (why = "") => {
451
479
  if (why) console.log(` ${why}`);
452
480
  console.log(` ${c.bold(pick.name)}`);
453
- console.log(` ${c.cyan(pick.docs)}\n`);
481
+ console.log(` ${c.accent(pick.docs)}\n`);
454
482
  const opened = await openUrl(pick.docs);
455
483
  console.log(opened
456
- ? ` ${c.dim("Opened in your browser. Install it, then run")} ${c.cyan("kaizen")} ${c.dim("again.")}`
457
- : ` ${c.dim("Open that page to install it, then run")} ${c.cyan("kaizen")} ${c.dim("again.")}`);
484
+ ? ` ${c.dim("Opened in your browser. Install it, then run")} ${c.accent("kaizen")} ${c.dim("again.")}`
485
+ : ` ${c.dim("Open that page to install it, then run")} ${c.accent("kaizen")} ${c.dim("again.")}`);
458
486
  return false;
459
487
  };
460
488
 
@@ -463,7 +491,7 @@ async function noAgent(): Promise<boolean> {
463
491
  if (!cmd) return docs();
464
492
  if (cmd.startsWith("npm ") && !Bun.which("npm")) return docs(c.dim(`${pick.name} installs with npm, which needs Node.js: https://nodejs.org`));
465
493
 
466
- console.log(`\n ${c.dim("Official installer:")} ${c.cyan(cmd)}`);
494
+ console.log(`\n ${c.dim("Official installer:")} ${c.accent(cmd)}`);
467
495
  if (!(await select(`Install ${pick.name} now?`, [
468
496
  { label: "Yes", hint: "run the command above", value: true },
469
497
  { label: "No", hint: "open the docs page instead", value: false },
@@ -478,7 +506,7 @@ async function noAgent(): Promise<boolean> {
478
506
  if (code !== 0 || !bin) {
479
507
  return docs(code !== 0
480
508
  ? `${c.bold("The install did not finish")} ${c.dim(`(exit ${code}).`)}`
481
- : `${c.bold(`${pick.name} installed, but`)} ${c.cyan(pick.cmd)} ${c.bold("is not on PATH yet.")} ${c.dim("Open a new terminal and run kaizen again.")}`);
509
+ : `${c.bold(`${pick.name} installed, but`)} ${c.accent(pick.cmd)} ${c.bold("is not on PATH yet.")} ${c.dim("Open a new terminal and run kaizen again.")}`);
482
510
  }
483
511
  step(`installed ${pick.name}`);
484
512
 
@@ -556,7 +584,7 @@ if (args.has("prune")) {
556
584
  const apply = args.has("--yes");
557
585
  const gone = pruneRuns(state, keep, apply);
558
586
  console.log(gone.length
559
- ? `\n ${apply ? "pruned" : "would prune"} ${gone.length} finished run(s), keeping the newest ${keep}:\n${gone.map((g) => ` ${g.id}${g.rescued ? c.dim(` ${g.rescued} open item(s) ${apply ? "moved" : "to move"} to backlog.md`) : ""}`).join("\n")}\n${apply ? "" : `\n ${c.dim("nothing deleted — run:")} ${c.cyan("kaizen prune --yes")}\n`}`
587
+ ? `\n ${apply ? "pruned" : "would prune"} ${gone.length} finished run(s), keeping the newest ${keep}:\n${gone.map((g) => ` ${g.id}${g.rescued ? c.dim(` ${g.rescued} open item(s) ${apply ? "moved" : "to move"} to backlog.md`) : ""}`).join("\n")}\n${apply ? "" : `\n ${c.dim("nothing deleted — run:")} ${c.accent("kaizen prune --yes")}\n`}`
560
588
  : `\n nothing to prune ${c.dim(`(${keep} finished runs are kept)`)}\n`);
561
589
  process.exit(0);
562
590
  }
@@ -767,7 +795,7 @@ if (upgrade) {
767
795
  if (after !== latest) {
768
796
  console.log(`\n ${c.bold(`could not install kaizen ${latest}`)}`);
769
797
  // npm names a new version before it serves it (its review takes minutes).
770
- console.log(` ${c.dim("npm may still be publishing it: try again in a few minutes, or run")} ${c.cyan(`bunx kaizen-agent@${latest}`)}\n`);
798
+ console.log(` ${c.dim("npm may still be publishing it: try again in a few minutes, or run")} ${c.accent(`bunx kaizen-agent@${latest}`)}\n`);
771
799
  finish(1);
772
800
  }
773
801
  console.log(`\n ${c.bold("Upgraded")} ${c.dim(now)} → ${c.green(after)}\n ${c.dim("Restart Claude Code to pick up any new slash commands.")}\n`);
@@ -776,107 +804,15 @@ if (upgrade) {
776
804
  if (!check && !upgrade) await welcome();
777
805
 
778
806
  async function welcome() {
779
- const rgb = (r: number, g: number, b: number, s: string) =>
780
- `\x1b[38;2;${r};${g};${b}m${s}\x1b[0m`;
781
-
782
- // Fuji: snow on the peak, deepening blue down the slope.
783
- const WORD = [
784
- "██╗ ██╗ █████╗ ██╗███████╗███████╗███╗ ██╗",
785
- "██║ ██╔╝██╔══██╗██║╚══███╔╝██╔════╝████╗ ██║",
786
- "█████╔╝ ███████║██║ ███╔╝ █████╗ ██╔██╗ ██║",
787
- "██╔═██╗ ██╔══██║██║ ███╔╝ ██╔══╝ ██║╚██╗██║",
788
- "██║ ██╗██║ ██║██║███████╗███████╗██║ ╚████║",
789
- "╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═══╝",
790
- ];
791
- const W = 69, C = 34, SNOW = 3;
792
- // One constant slope, three columns per row, all the way down. The rows behind
793
- // the wordmark keep the same rate, so the edge that goes in above the letters
794
- // comes out below them on the same line -- vary it and the cone reads broken.
795
- const H = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34];
796
-
797
- // Anything that would wrap is worse than the smaller thing that fits: the
798
- // mountain needs the full width, the wordmark needs 47, below that use words.
799
- const cols = process.stdout.columns || 80;
800
- const wide = cols >= W + 4;
801
- if (cols < 49) {
802
- console.log(`\n ${c.bold("kaizen")}`);
803
- } else {
804
-
805
- const cell: string[][] = H.map(() => Array(W).fill(" "));
806
- const isWord: boolean[][] = H.map(() => Array(W).fill(false));
807
-
808
- if (wide) {
809
- for (const [i, h] of H.entries()) {
810
- const l = C - h, r = C + h;
811
- if (i < SNOW) { // solid cap
812
- cell[i]![l] = "▄"; cell[i]![r] = "▄";
813
- for (let x = l + 1; x < r; x++) cell[i]![x] = "█";
814
- } else { // slope, drawn as two edges
815
- // Below the wordmark's top row the letters own the middle, so draw an
816
- // edge only where all three of its characters clear them.
817
- const band = i >= H.length - WORD.length;
818
- const gap = Math.floor((W - 45) / 2) - 2;
819
- if (!band || l + 2 < gap) {
820
- cell[i]![l] = "▄"; cell[i]![l + 1] = "█"; cell[i]![l + 2] = "▀";
821
- cell[i]![r - 2] = "▀"; cell[i]![r - 1] = "█"; cell[i]![r] = "▄";
822
- }
823
- }
824
- }
825
- }
826
-
827
- const top = H.length - WORD.length, left = Math.floor((W - 45) / 2);
828
- for (let r = top; r < H.length; r++) // air around the letters
829
- for (let x = left - 2; x < left + 47; x++) if (x >= 0 && x < W) cell[r]![x] = " ";
830
- for (const [r, line] of WORD.entries())
831
- for (const [x, ch] of [...line].entries())
832
- if (ch !== " ") { cell[top + r]![left + x] = ch; isWord[top + r]![left + x] = true; }
833
-
834
- console.log();
835
- for (const [i, row] of cell.entries()) {
836
- if (!wide && i < top) continue; // no mountain to draw, no blank rows
837
- const slope = Math.max(0, i - SNOW) / (H.length - SNOW);
838
- const mountain: [number, number, number] = i < SNOW
839
- ? [255 - i * 8, 255 - i * 5, 255]
840
- : [Math.round(150 - slope * 105), Math.round(190 - slope * 110), Math.round(245 - slope * 80)];
841
-
842
- // With no mountain there is nothing to sit under, so drop its left margin.
843
- const off = wide ? 0 : left;
844
- const chars = row.slice(off), flags = isWord[i]!.slice(off);
845
-
846
- let out = " ", run = "", runWord = flags[0]!;
847
- const flush = () => {
848
- if (!run) return;
849
- const t = (i - top) / (WORD.length - 1);
850
- const col: [number, number, number] = runWord
851
- ? [Math.round(214 - t * 150), Math.round(232 - t * 130), Math.round(255 - t * 45)]
852
- : mountain;
853
- out += rgb(col[0], col[1], col[2], run);
854
- run = "";
855
- };
856
- for (const [x, ch] of chars.entries()) {
857
- if (flags[x] !== runWord) { flush(); runWord = flags[x]!; }
858
- run += ch;
859
- }
860
- flush();
861
- console.log(out.replace(/\s+$/, ""));
862
- }
863
- if (wide) console.log(" " + rgb(38, 66, 130, "▀".repeat(W)));
864
- }
865
-
866
- console.log(`
867
- ${c.bold("改善")} ${c.dim("kaizen — continuous improvement")}
868
-
869
- ${c.dim("A staged workflow for AI agents — code, writing, research, operations:")}
870
- ${c.dim("plan -> you approve -> build -> independent review -> bounded fix loop")}
871
- `);
872
-
807
+ console.log(banner());
808
+ console.log(` ${c.dim("A staged workflow for AI agents: plan, you approve, build, independent review.")}\n`);
873
809
  if (interactive) await anyKey();
874
810
  }
875
811
 
876
812
  // A pause before anything touches the filesystem, and the place to back out.
877
813
  async function anyKey() {
878
814
  const { stdin, stdout } = process;
879
- stdout.write(` ${c.dim("press")} ${c.cyan("enter")} ${c.dim("to install, or")} ${c.cyan("ctrl-c")} ${c.dim("to leave")}`);
815
+ stdout.write(` ${c.dim("Press")} ${c.accent("Enter")} ${c.dim("to install, or")} ${c.accent("Ctrl-C")} ${c.dim("to leave")}`);
880
816
  stdin.setRawMode(true);
881
817
  stdin.resume();
882
818
  await new Promise<void>((resolve) => {
@@ -893,35 +829,12 @@ async function anyKey() {
893
829
  }
894
830
 
895
831
  const repo = await resolveRepo();
896
- const root = await chooseRoot();
897
- const presetChoice = await choosePreset();
832
+ // Global unless asked otherwise; the project and the preset are `kaizen setup`'s questions.
833
+ const root = args.has("--project") ? process.cwd() : home;
834
+ // null means "leave the config alone": answering for the user would overwrite their preset.
835
+ const presetChoice: PresetName | null = presetArg;
898
836
  const targets = found(root);
899
837
 
900
- // null means "leave the config alone": an upgrade or a --yes run never asked, and
901
- // answering "medium" for the user overwrote whatever preset they had chosen.
902
- async function choosePreset(): Promise<PresetName | null> {
903
- if (presetArg) return presetArg;
904
- if (!interactive) return null;
905
-
906
- return select("Choose workflow preset", [
907
- {
908
- label: "Medium (Recommended)",
909
- hint: "balanced — subagents, plan approval, auto-fix high/critical",
910
- value: "medium",
911
- },
912
- {
913
- label: "Low",
914
- hint: "inline & manual — lite runner, inline builder, manual approvals, no auto-fix",
915
- value: "low",
916
- },
917
- {
918
- label: "Ultra",
919
- hint: "autonomous — subagents, auto mode, auto-fix all findings (up to 4 rounds)",
920
- value: "ultra",
921
- },
922
- ]);
923
- }
924
-
925
838
  // ---------------------------------------------------------------- repo
926
839
 
927
840
  // Settings only needs the clone's default config, not a pull.
@@ -988,22 +901,6 @@ async function resolveRepo() {
988
901
  return dest;
989
902
  }
990
903
 
991
- async function chooseRoot() {
992
- if (args.has("--project")) return process.cwd();
993
- if (args.has("--global") || !interactive) return home;
994
- // A project install only means something in a project. Standing in the home
995
- // directory it is the global install under another name; any other folder is
996
- // a project worth installing into, git repository or not.
997
- const cwd = process.cwd();
998
- if (cwd === home) return home;
999
-
1000
- const names = (r: string) => found(r).map((a) => a.name).join(", ");
1001
- return select("Install kaizen for", [
1002
- { label: "Globally", hint: `every project \u2014 ${names(home)}`, value: home },
1003
- { label: "This project only", hint: `${basename(cwd)}/ \u2014 ${names(cwd)}`, value: cwd },
1004
- ]);
1005
- }
1006
-
1007
904
  // ---------------------------------------------------------------- linking
1008
905
 
1009
906
  function dirEntries(sub: string) {
@@ -1107,10 +1004,6 @@ step(
1107
1004
  : wrote ? `linked ${wrote} files into ${into}`
1108
1005
  : `already installed for ${into} ${c.dim("(nothing to change)")}`,
1109
1006
  );
1110
- if (targets.length === 1) {
1111
- console.log(` ${c.dim("Codex, Antigravity, OpenCode, Cursor and Gemini CLI get it too,")}`);
1112
- console.log(` ${c.dim("if their directory exists when you install.")}`);
1113
- }
1114
1007
 
1115
1008
  // Global knowledge reaches plain Claude Code sessions through a SessionStart hook
1116
1009
  // that prints only the lessons matching the project's stack (cli/knowledge.ts).
@@ -1152,7 +1045,7 @@ function installLauncher() {
1152
1045
  const onPath = (process.env.PATH ?? "").split(win ? ";" : ":")
1153
1046
  .some((p) => p.replace(/[\\/]+$/, "").toLowerCase() === binDir.replace(/[\\/]+$/, "").toLowerCase());
1154
1047
  step(onPath
1155
- ? `${c.cyan("kaizen upgrade")} is now on your PATH`
1048
+ ? `${c.accent("kaizen upgrade")} is now on your PATH`
1156
1049
  : `wrote ${tilde(bin)} ${c.dim(`— add ${tilde(binDir)} to PATH to use it`)}`);
1157
1050
  } catch {
1158
1051
  /* a read-only home is not worth failing the install over */
@@ -1202,17 +1095,7 @@ function kaizenAbove() {
1202
1095
  }
1203
1096
 
1204
1097
  if (inProject && !kaizenAbove()) {
1205
- const now = root === process.cwd() || args.has("--init-project")
1206
- ? true
1207
- : interactive
1208
- ? await select(`Set up ${basename(process.cwd())}/ for kaizen now`, [
1209
- // "Not now" leads: the offer now appears in any folder outside home, so the
1210
- // safe answer is the one under the cursor.
1211
- { label: "Not now", hint: "the first /kaizen run will do it", value: false },
1212
- { label: "Yes", hint: "writes .kaizen/ and a CLAUDE.md line so it runs by default", value: true },
1213
- ])
1214
- : false;
1215
- if (now) initProject();
1098
+ if (root === process.cwd() || args.has("--init-project")) initProject();
1216
1099
  } else if (existsSync(kaizenDir)) {
1217
1100
  const drift = specDrift();
1218
1101
  for (const f of drift) copyFileSync(join(repo, "skills/kaizen", f), join(kaizenDir, f));
@@ -1259,20 +1142,12 @@ function writePointer() {
1259
1142
 
1260
1143
  // ---------------------------------------------------------------- done
1261
1144
 
1262
- {
1263
- console.log(`
1264
- ${c.bold("Next")}
1265
- 1 restart Claude Code ${c.dim("— skills load live, slash commands only at session start")}
1266
- 2 ${c.cyan("/kaizen <what you want done>")} ${c.dim("in any project — it sets itself up on first run")}
1267
- 3 ${c.cyan("kaizen setup")} ${c.dim("— settings, the board, and the phone app, any time")}
1268
-
1269
- ${c.dim("/kaizen-help lists every command. kaizen upgrade updates all of this.")}
1270
- `);
1271
- if (interactive && !blocked && await select("Run setup now?", [
1272
- { label: "Not now", hint: "kaizen setup runs it later", value: false },
1273
- { label: "Yes", hint: "a project folder, settings, the board, the phone", value: true },
1274
- ])) await runSetup();
1275
- }
1145
+ // Setup ends by printing the next steps itself.
1146
+ if (interactive && !blocked && await select("Set up kaizen now? It takes about a minute.", [
1147
+ { label: "Yes", hint: "your project, how much kaizen asks you, the Kaizen App", value: true },
1148
+ { label: "Later", hint: "run kaizen setup any time", value: false },
1149
+ ])) await runSetup();
1150
+ else console.log(nextSteps());
1276
1151
  if (blocked) process.exit(1);
1277
1152
 
1278
1153
  // ---------------------------------------------------------------- helpers
@@ -1407,14 +1282,17 @@ async function select<T>(question: string, options: { label: string; hint: strin
1407
1282
  if (!first) stdout.write(`\x1b[${options.length}A`);
1408
1283
  for (const [i, o] of options.entries()) {
1409
1284
  const on = i === active;
1285
+ // A wrapped row would break the redraw, which moves up one line per option.
1286
+ const room = Math.max(0, (stdout.columns || 80) - o.label.length - 9);
1287
+ const hint = o.hint.length > room ? `${o.hint.slice(0, Math.max(0, room - 1))}…` : o.hint;
1410
1288
  stdout.write(
1411
- `\x1b[2K ${on ? c.cyan(">") : " "} ${on ? c.bold(o.label) : c.dim(o.label)}` +
1412
- ` ${c.dim(o.hint)}\n`,
1289
+ `\x1b[2K ${on ? c.bold(">") : " "} ${on ? c.bold(o.label) : c.dim(o.label)}` +
1290
+ ` ${c.dim(hint)}\n`,
1413
1291
  );
1414
1292
  }
1415
1293
  };
1416
1294
 
1417
- stdout.write(`\n ${c.bold(question)} ${c.dim("(arrows, enter)")}\n`);
1295
+ stdout.write(`\n ${c.bold(question)}\n ${c.dim("Up and down to move, Enter to choose")}\n`);
1418
1296
  stdout.write("\x1b[?25l");
1419
1297
  draw(true);
1420
1298
  stdin.setRawMode(true);
@@ -1430,7 +1308,7 @@ async function select<T>(question: string, options: { label: string; hint: strin
1430
1308
  const keys = chunk.toString();
1431
1309
  for (let i = 0; i < keys.length; i++) {
1432
1310
  const rest = keys.slice(i);
1433
- if (rest.startsWith("\x03")) { stdout.write("\ncancelled\n"); process.exit(130); }
1311
+ if (rest.startsWith("\x03")) { stdout.write("\x1b[?25h\ncancelled\n"); process.exit(130); }
1434
1312
  if (rest.startsWith("\r") || rest.startsWith("\n")) {
1435
1313
  stdin.off("data", onData);
1436
1314
  return resolve();
package/cli/look.ts ADDED
@@ -0,0 +1,33 @@
1
+ // How the installer and `kaizen setup` look: the current monochrome brand. Emphasis is
2
+ // bold, not a colour, so it follows the terminal's own theme, light or dark, as the
3
+ // board's default palette does (design.md, section 2). Green stays for success.
4
+ export const c = {
5
+ dim: (s: string) => `\x1b[2m${s}\x1b[0m`,
6
+ bold: (s: string) => `\x1b[1m${s}\x1b[0m`,
7
+ accent: (s: string) => `\x1b[1m${s}\x1b[0m`,
8
+ green: (s: string) => `\x1b[32m${s}\x1b[0m`,
9
+ };
10
+
11
+ // The pixel K of site/media/favicon.svg, drawn in half blocks so its squares stay square.
12
+ const K = ["█ ▄▀", "██ ", "█ ▀▄"];
13
+
14
+ // Compact block wordmark (27 columns x 3 rows).
15
+ export const WORDMARK = [
16
+ "█ █ ▄▀█ █ ▀▀█ █▀▀ █▄ █",
17
+ "█▀▄ █▀█ █ ▄▀ ██▄ █ ▀█",
18
+ "█ █ █ █ █ █▄▄ █▄▄ █ █",
19
+ ];
20
+
21
+ export function banner() {
22
+ return `\n${K.map((row) => ` ${c.bold(row)}`).join("\n")}\n\n ${c.bold("改善")} ${c.dim("continuous improvement")}\n`;
23
+ }
24
+
25
+ export function nextSteps() {
26
+ return `
27
+ ${c.bold("You're ready")}
28
+ 1 Restart Claude Code ${c.dim("so it picks up the new commands")}
29
+ 2 Ask for something: ${c.accent("/kaizen <what you want done>")}
30
+
31
+ ${c.dim("Change anything later:")} ${c.accent("kaizen setup")}${c.dim(". Every command:")} ${c.accent("/kaizen-help")}
32
+ `;
33
+ }
package/cli/settings.ts CHANGED
@@ -115,8 +115,8 @@ const SETTINGS: Setting[] = [
115
115
  { key: "agent.keep_alive", label: "Keep agents through a board restart", group: "Agents", values: ["off", "tmux"], help: "tmux: Linux and macOS with tmux installed", when: ["agent.launch", "card"] },
116
116
  { key: "agent.keep_awake", label: "Keep computer awake", group: "Board", values: ["off", "auto", "on"], help: "auto: while the board runs agents · on: while the board is open. Linux and macOS" },
117
117
  { key: "agent.heartbeat_minutes", label: "Agent heartbeat", group: "Board", values: ["2", "5", "10", "30"], help: "Minutes. A card says stale after two quiet intervals" },
118
- { key: "subagents.model", label: "Model for subagents", group: "Agents", values: ["inherit", "opus", "sonnet", "haiku"], help: "Planner, builder, reviewer", when: ["runner", "full"] },
119
- { key: "subagents.effort", label: "Effort for subagents", group: "Agents", values: ["inherit", "low", "medium", "high"], help: "Planner, builder, reviewer", when: ["runner", "full"] },
118
+ { key: "subagents.model", label: "Claude Code", group: "Agents", values: ["inherit", "opus", "sonnet", "haiku"], help: "Its stage subagents: planner, builder, reviewer", when: ["runner", "full"] },
119
+ { key: "subagents.effort", label: "Claude Code effort", group: "Agents", values: ["inherit", "low", "medium", "high"], help: "Planner, builder, reviewer", when: ["runner", "full"] },
120
120
  { key: "auto_fix.enabled", label: "Fix findings automatically", group: "Auto-fix", values: ["true", "false"], help: "" },
121
121
  { key: "auto_fix.min_severity", label: "Lowest severity to fix", group: "Auto-fix", values: ["critical", "high", "medium", "low"], help: "", when: ["auto_fix.enabled", "true"] },
122
122
  { key: "auto_fix.max_iterations", label: "Max fix rounds", group: "Auto-fix", values: ["1", "2", "3", "4", "5"], help: "", when: ["auto_fix.enabled", "true"] },
@@ -126,6 +126,7 @@ const SETTINGS: Setting[] = [
126
126
  { key: "orchestration.max_workers", label: "Max workers per run", group: "Orchestration", values: ["1", "2", "3", "4", "5", "6"], help: "Total per run", when: ["orchestration.enabled", "true"] },
127
127
  { key: "orchestration.permissions", label: "Worker permissions", group: "Orchestration", values: ["own", "bypass"], help: "own: each agent's own prompts. Bypass skips every prompt in every worker", when: ["orchestration.enabled", "true"] },
128
128
  // One per tool that takes a model flag; a run freezes its own agent's. Empty: the run's own model.
129
+ ...KNOWN_AGENTS.filter((a) => MODEL_FLAGS[a.cmd] && a.cmd !== "claude").map((a): Setting => ({ key: `agent.model.${a.cmd}`, label: `Model: ${a.name}`, group: "Agents", values: [], text: true, help: "The tool's own model name, for every stage: it runs them in one session. Empty: its own default" })),
129
130
  ...KNOWN_AGENTS.filter((a) => MODEL_FLAGS[a.cmd]).map((a): Setting => ({ key: `orchestration.worker_model.${a.cmd}`, label: `Worker model: ${a.name}`, group: "Orchestration", values: [], text: true, help: "The tool's own model name. Empty: the run's own model", when: ["orchestration.enabled", "true"] })),
130
131
  { key: "review.write_memory", label: "Remember lessons", group: "Project", values: ["true", "false"], help: "" },
131
132
  { key: "review.memory_max_lines", label: "Memory size cap", group: "Project", values: ["50", "100", "200", "400"], help: "" },
package/cli/setup.test.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { test, expect } from "bun:test";
2
- import { mkdtempSync, rmSync, existsSync, readdirSync } from "node:fs";
2
+ import { mkdtempSync, mkdirSync, rmSync, existsSync, readdirSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { qrMatrix, qr } from "./qr.ts";
6
- import { tailnetName } from "./setup.ts";
6
+ import { projectStep, tailnetName } from "./setup.ts";
7
+ import { banner } from "./look.ts";
7
8
 
8
9
  test("qr: right size per version, finder squares in three corners, deterministic", () => {
9
10
  const a = qrMatrix("https://pc.tail1234.ts.net"); // 26 bytes: version 2, 25 modules
@@ -56,3 +57,22 @@ test("web-hosts: names are normalized, deduped and merged with the env var", asy
56
57
  expect(JSON.parse(await new Response(p.stdout).text())).toEqual(["env.ts.net", "pc.tail1.ts.net"]);
57
58
  } finally { rmSync(homeDir, { recursive: true, force: true }); }
58
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
+ });