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/automations.test.ts +167 -0
- package/cli/automations.ts +298 -0
- package/cli/dashboard.ts +1 -7
- package/cli/install.test.ts +16 -0
- package/cli/install.ts +67 -189
- package/cli/look.ts +33 -0
- package/cli/settings.ts +3 -2
- package/cli/setup.test.ts +22 -2
- package/cli/setup.ts +101 -51
- package/cli/sources.ts +1 -1
- package/cli/state.test.ts +7 -0
- package/cli/state.ts +5 -1
- package/cli/web.ts +48 -1
- package/package.json +1 -1
- package/skills/kaizen/config.default.yml +7 -0
- package/skills/kaizen/settings.md +1 -0
- package/skills/kaizen-help/SKILL.md +1 -0
- package/skills/media/kaizen-deck/SKILL.md +21 -2
- package/skills/media/kaizen-deck/scripts/motion.py +99 -0
- package/web/board/phone.ts +2 -0
- package/web/board/run-view.ts +107 -1
- package/web/board/search.ts +6 -0
- package/web/board/settings-automations.ts +71 -0
- package/web/board/settings-pages.test.ts +4 -0
- package/web/board/settings-pages.ts +2 -1
- package/web/board/settings.ts +10 -3
- package/web/board/workspace.ts +5 -1
- package/web/board/ws-tabs.test.ts +12 -1
- package/web/board/ws-tabs.ts +18 -0
- package/web/board.html +7 -2
- package/web/board.js +110 -89
- package/web/notebook.js +22 -22
- package/web/term.js +1 -1
- package/web/video.js +31 -31
package/cli/setup.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
// `kaizen setup`: the walk after install — a project, the settings, the board, the
|
|
2
|
-
// phone.
|
|
3
|
-
import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { join, resolve } from "node:path";
|
|
2
|
+
// phone. Enter takes the first choice at every step; nothing changes without an answer.
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { basename, join, resolve } from "node:path";
|
|
5
5
|
import { addWebHost, home, remember } from "./state.ts";
|
|
6
6
|
import { applyPreset, detectPreset } from "./settings.ts";
|
|
7
7
|
import { qr } from "./qr.ts";
|
|
8
|
+
import { nextSteps } from "./look.ts";
|
|
8
9
|
|
|
9
10
|
const PORT = 7420;
|
|
11
|
+
const TAILSCALE = "https://tailscale.com/download";
|
|
10
12
|
const INSTALL = join(import.meta.dir, "install.ts");
|
|
11
13
|
|
|
12
14
|
export type Ui = {
|
|
13
15
|
select: <T>(q: string, o: { label: string; hint: string; value: T }[]) => Promise<T>;
|
|
14
16
|
ask: (q: string) => string | null;
|
|
15
|
-
c: Record<"dim" | "bold" | "
|
|
17
|
+
c: Record<"dim" | "bold" | "accent" | "green", (s: string) => string>;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
// The DNS name `tailscale status --json` reports for this machine, or null when
|
|
@@ -25,22 +27,26 @@ export function tailnetName(json: string): string | null {
|
|
|
25
27
|
} catch { return null; }
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// What the project step should do from `dir`: nothing when kaizen already owns it,
|
|
31
|
+
// offer the git root or the folder itself, or null at home, where it has to ask.
|
|
32
|
+
export function projectStep(dir: string, homeDir: string): { ready: true } | { offer: string; git: boolean } | null {
|
|
33
|
+
if (dir === homeDir) return null;
|
|
34
|
+
let git = "";
|
|
35
|
+
for (let d = dir; d !== homeDir; ) {
|
|
36
|
+
if (existsSync(join(d, ".kaizen"))) return { ready: true };
|
|
37
|
+
if (!git && existsSync(join(d, ".git"))) git = d;
|
|
32
38
|
const up = resolve(d, "..");
|
|
33
|
-
if (up === d)
|
|
39
|
+
if (up === d) break;
|
|
34
40
|
d = up;
|
|
35
41
|
}
|
|
36
|
-
return
|
|
42
|
+
return { offer: git || dir, git: !!git };
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
export function manual() {
|
|
40
46
|
return `
|
|
41
47
|
kaizen setup needs a terminal. By hand:
|
|
42
48
|
kaizen settings pick a preset
|
|
43
|
-
kaizen web the
|
|
49
|
+
kaizen web the Kaizen App
|
|
44
50
|
tailscale serve --bg 127.0.0.1:${PORT} phone, then add the name it prints to ~/.kaizen/web-hosts
|
|
45
51
|
`;
|
|
46
52
|
}
|
|
@@ -50,59 +56,103 @@ export async function setup(ui: Ui) {
|
|
|
50
56
|
const out = (s = "") => console.log(s);
|
|
51
57
|
const run = (cmd: string[], cwd?: string) => Bun.spawnSync(cmd, { cwd, stdin: "inherit", stdout: "inherit", stderr: "inherit" }).exitCode === 0;
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
const project = projectStep(process.cwd(), home);
|
|
60
|
+
const needsProject = !(project && "ready" in project);
|
|
61
|
+
const tailnetNow = () => {
|
|
62
|
+
try { return tailnetName(Bun.spawnSync(["tailscale", "status", "--json"]).stdout.toString()); } catch { return null; /* not installed */ }
|
|
63
|
+
};
|
|
64
|
+
let tailnet = tailnetNow();
|
|
65
|
+
const total = 3 + (needsProject ? 1 : 0);
|
|
66
|
+
let n = 0;
|
|
67
|
+
const title = (name: string) => `Step ${++n} of ${total}: ${name}`;
|
|
54
68
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
out(`\n ${c.bold("kaizen setup")} ${c.dim("Press Enter to take the first choice. Nothing changes without an answer.")}`);
|
|
70
|
+
|
|
71
|
+
const initProject = (dir: string) => {
|
|
72
|
+
const r = Bun.spawnSync([process.execPath, INSTALL, "--yes", "--init-project"], { cwd: dir });
|
|
73
|
+
if (r.exitCode === 0 && existsSync(join(dir, ".kaizen"))) { remember(dir); out(` ${c.green("+")} ${dir} is ready`); }
|
|
74
|
+
else out(` ${c.dim(`Could not set up ${dir}. Run kaizen setup from inside it to try again.`)}`);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Project
|
|
78
|
+
if (project && "offer" in project) {
|
|
79
|
+
const { offer, git } = project;
|
|
80
|
+
const yes = { label: "Yes", hint: "kaizen keeps its work here: a .kaizen folder, a CLAUDE.md line", value: true };
|
|
81
|
+
const no = { label: "Skip", hint: "the first /kaizen run does it", value: false };
|
|
82
|
+
// Yes leads only in a repository: setup may be running in any folder at all.
|
|
83
|
+
if (await select(title(`Set up kaizen in the ${basename(offer)} folder?`), git ? [yes, no] : [no, yes])) initProject(offer);
|
|
84
|
+
} else if (!project) {
|
|
85
|
+
out(`\n ${c.bold(title("Your project"))}`);
|
|
58
86
|
for (let tries = 0; tries < 2; tries++) {
|
|
59
|
-
const typed = ui.ask("
|
|
87
|
+
const typed = ui.ask(" Folder of a project, or Enter to skip: ")?.trim();
|
|
60
88
|
if (!typed) break;
|
|
61
89
|
const dir = resolve(typed.replace(/^~(?=$|[\\/])/, home));
|
|
62
|
-
if (dir === home || !existsSync(dir) || !statSync(dir).isDirectory()) { out(` ${c.dim(`${typed}
|
|
63
|
-
|
|
64
|
-
if (r.exitCode === 0 && existsSync(join(dir, ".kaizen"))) { remember(dir); out(` ${c.green("+")} set up ${dir}`); }
|
|
65
|
-
else out(` ${c.dim(`could not set up ${dir}`)}`);
|
|
90
|
+
if (dir === home || !existsSync(dir) || !statSync(dir).isDirectory()) { out(` ${c.dim(`${typed} is not a project folder`)}`); continue; }
|
|
91
|
+
initProject(dir);
|
|
66
92
|
break;
|
|
67
93
|
}
|
|
68
94
|
}
|
|
69
95
|
|
|
70
|
-
//
|
|
96
|
+
// Settings
|
|
71
97
|
const defaults = readFileSync(join(import.meta.dir, "..", "skills/kaizen/config.default.yml"), "utf8");
|
|
72
98
|
const file = join(home, ".kaizen", "config.yml");
|
|
73
99
|
const current = existsSync(file) ? readFileSync(file, "utf8") : defaults;
|
|
74
100
|
const now = detectPreset(current, defaults);
|
|
75
|
-
const
|
|
76
|
-
{ label: "
|
|
77
|
-
{ label: "
|
|
78
|
-
{ label: "
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
101
|
+
const presets = [
|
|
102
|
+
{ label: "Medium (recommended)", hint: "you approve the plan; serious findings get fixed for you", value: "medium" as const },
|
|
103
|
+
{ label: "Low", hint: "cheapest; you approve every step", value: "low" as const },
|
|
104
|
+
{ label: "Ultra", hint: "runs on its own and fixes every finding", value: "ultra" as const },
|
|
105
|
+
];
|
|
106
|
+
// What is set now leads, so Enter keeps it.
|
|
107
|
+
const options = [
|
|
108
|
+
{ label: `Keep ${now}`, hint: "your current settings", value: null },
|
|
109
|
+
...presets.filter((p) => p.value !== now),
|
|
110
|
+
];
|
|
111
|
+
const preset = await select(title("How much should kaizen ask you?"), options);
|
|
112
|
+
if (preset) {
|
|
113
|
+
mkdirSync(join(home, ".kaizen"), { recursive: true });
|
|
114
|
+
writeFileSync(file, applyPreset(current, preset, defaults));
|
|
115
|
+
out(` ${c.green("+")} ${preset} is set`);
|
|
116
|
+
}
|
|
83
117
|
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
118
|
+
// Kaizen App
|
|
119
|
+
if (await select(title("Open the Kaizen App?"), [
|
|
120
|
+
{ label: "Yes", hint: "see your work in the browser, on this computer only", value: true },
|
|
121
|
+
{ label: "Later", hint: "run kaizen web", value: false },
|
|
122
|
+
])) run([process.execPath, INSTALL, "web", "--daemon"]);
|
|
87
123
|
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
let name: string | null = null;
|
|
91
|
-
try { name = tailnetName(Bun.spawnSync(["tailscale", "status", "--json"]).stdout.toString()); } catch { /* not installed */ }
|
|
92
|
-
if (!name) {
|
|
93
|
-
out(` Tailscale is not running here. Install it on this PC and your phone (${c.cyan("https://tailscale.com/download")}),`);
|
|
94
|
-
out(` sign in on both, then run ${c.cyan("kaizen setup")} again.\n`);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const yes = await select(`Run tailscale serve so your phone can reach the board?`, [
|
|
124
|
+
// Phone
|
|
125
|
+
if (await select(title("Use the Kaizen App on your phone?"), [
|
|
98
126
|
{ label: "Not now", hint: "nothing changes", value: false },
|
|
99
|
-
{ label: "Yes", hint:
|
|
100
|
-
])
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
{ label: "Yes", hint: "private to your own devices, through Tailscale", value: true },
|
|
128
|
+
])) {
|
|
129
|
+
if (!tailnet) {
|
|
130
|
+
out(`\n The phone connects through Tailscale, a free private network.`);
|
|
131
|
+
out(` 1 Install it on this computer: ${c.accent(TAILSCALE)}`);
|
|
132
|
+
out(` 2 Install it on your phone too, from the same link`);
|
|
133
|
+
out(` 3 Sign in on both with the same account`);
|
|
134
|
+
}
|
|
135
|
+
while (!tailnet) {
|
|
136
|
+
if (!await select("Tailscale ready on both?", [
|
|
137
|
+
{ label: "Check again", hint: "see if Tailscale is running here", value: true },
|
|
138
|
+
{ label: "Skip for now", hint: "run kaizen setup when it is ready", value: false },
|
|
139
|
+
])) break;
|
|
140
|
+
tailnet = tailnetNow();
|
|
141
|
+
if (!tailnet) out(` ${c.dim("Tailscale is not running on this computer yet.")}`);
|
|
142
|
+
else out(` ${c.green("+")} Tailscale is running`);
|
|
143
|
+
}
|
|
144
|
+
if (tailnet && run(["tailscale", "serve", "--bg", `127.0.0.1:${PORT}`])) {
|
|
145
|
+
addWebHost(tailnet);
|
|
146
|
+
const url = `https://${tailnet}`;
|
|
147
|
+
out(`\n${qr(url)}\n\n Scan with your phone camera, or open ${c.accent(url)}`);
|
|
148
|
+
out(` Then choose Add to Home screen: it opens full screen with the kaizen icon.`);
|
|
149
|
+
out(` ${c.dim("Anyone on your tailnet who can reach this PC can drive your agents; restrict it with Tailscale ACLs.")}`);
|
|
150
|
+
} else if (tailnet) out(` ${c.dim("tailscale serve failed; see its message above")}`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Failing to make a shortcut must not spoil a finished setup; web prints what happened.
|
|
154
|
+
// From the install, not this file: under bunx this file is a temp copy that goes away.
|
|
155
|
+
const installed = join(process.env.KAIZEN_HOME ?? join(home, "kaizen"), "cli", "install.ts");
|
|
156
|
+
run([process.execPath, existsSync(installed) ? installed : INSTALL, "web", "--shortcut"]);
|
|
157
|
+
out(nextSteps());
|
|
108
158
|
}
|
package/cli/sources.ts
CHANGED
|
@@ -135,7 +135,7 @@ const isCommand = (t: string) => COMMANDS.has((/[a-z][a-z-]*/i.exec(t.split(" ")
|
|
|
135
135
|
// drops a `<where> - <severity> -` or `<severity>:` lead and every backtick. The
|
|
136
136
|
// check is on that final text, whatever parseItem did to get there; the kind the
|
|
137
137
|
// user chose, when it is still in front, is theirs and set aside.
|
|
138
|
-
const obeyed = (t: string) => isCommand(t) || ["", "full ", "lite "].some((kind) => {
|
|
138
|
+
export const obeyed = (t: string) => isCommand(t) || ["", "full ", "lite "].some((kind) => {
|
|
139
139
|
const sent = parseItem(kind + t).text;
|
|
140
140
|
return isCommand(kind && sent.startsWith(kind) ? sent.slice(kind.length) : sent);
|
|
141
141
|
});
|
package/cli/state.test.ts
CHANGED
|
@@ -1607,3 +1607,10 @@ test("a git that can't answer is not reported as no repo", () => {
|
|
|
1607
1607
|
process.env.PATH = `${dir}${process.platform === "win32" ? ";" : ":"}${path}`;
|
|
1608
1608
|
try { expect(gitStatus(dir)).toEqual({ repo: false, failed: true }); } finally { process.env.PATH = path; }
|
|
1609
1609
|
});
|
|
1610
|
+
|
|
1611
|
+
test("a tool's Settings model reaches its launch flag, ahead of a hand-written block", () => {
|
|
1612
|
+
expect(agentFlags("/x", "codex", 'agent:\n default: auto\n model:\n agy: ""\n codex: gpt-x\n')).toEqual(["-m", "gpt-x"]);
|
|
1613
|
+
expect(agentFlags("/x", "agy", 'agent:\n model:\n agy: ""\n codex: gpt-x\n')).toEqual([]);
|
|
1614
|
+
expect(agentFlags("/x", "codex", "agent:\n codex: { model: old, effort: low }\n model:\n codex: new\n")).toEqual(["-m", "new", "-c", "model_reasoning_effort=low"]);
|
|
1615
|
+
expect(agentFlags("/x", "codex", "agent:\n codex: { model: old }\n")).toEqual(["-m", "old"]);
|
|
1616
|
+
});
|
package/cli/state.ts
CHANGED
|
@@ -112,7 +112,11 @@ function agentConfig(projectDir: string, cmd: string, configText?: string) {
|
|
|
112
112
|
let block: RegExpExecArray | null = null;
|
|
113
113
|
for (const t of configText === undefined ? configTexts(projectDir) : [configText]) if ((block = re.exec(t))) break;
|
|
114
114
|
const get = (k: string) => block && new RegExp(`\\b${k}:[ \\t]*["']?([^"',}\\s]+)`).exec(block[1])?.[1];
|
|
115
|
-
|
|
115
|
+
// Settings' row (agent.model.<tool>) wins over a hand-written block.
|
|
116
|
+
const row = new RegExp(`^agent:\\n(?:[ \\t#][^\\n]*\\n|\\n)*?[ \\t]+model:[ \\t]*\\n(?:[ \\t]{3,}[^\\n]*\\n)*?[ \\t]{3,}${cmd}:[ \\t]*["']?([^"'\\s#]+)`, "m");
|
|
117
|
+
let set: string | undefined;
|
|
118
|
+
for (const t of configText === undefined ? configTexts(projectDir) : [configText]) if ((set = row.exec(t)?.[1])) break;
|
|
119
|
+
return { model: set || get("model") || undefined, effort: get("effort") || undefined };
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
// `model`: a per-run pick, in place of the configured one. Effort stays configured.
|
package/cli/web.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { writeBacks } from "./writeback.ts";
|
|
|
28
28
|
import { postLink, sendReply } from "./browser.ts";
|
|
29
29
|
import { listNotes, saveNote, renameNote, deleteNote, boardIndex, linksTo } from "./notes.ts";
|
|
30
30
|
import * as video from "./video.ts";
|
|
31
|
+
import * as auto from "./automations.ts";
|
|
31
32
|
import * as localsend from "./localsend.ts";
|
|
32
33
|
import * as hermes from "./hermes.ts";
|
|
33
34
|
import { listChats, readChat, sendChat, stopChat, deleteChat, okId as okChatId, busy as chatBusy, type Event as ChatEvent, type Upload as ChatUpload } from "./chat.ts";
|
|
@@ -75,6 +76,8 @@ const served = (f: string) => installed() === VERSION && existsSync(f) ? readTex
|
|
|
75
76
|
// Loopback hosts only; shared by /open-url and /frameable so the board is never a way to reach other sites.
|
|
76
77
|
const isLoopback = (u: URL) => ["localhost", "127.0.0.1", "[::1]"].includes(u.hostname);
|
|
77
78
|
|
|
79
|
+
// A run whose launched terminal is still alive (automations treat it as open).
|
|
80
|
+
const runLive = (dir: string, id: string) => Object.values(stagesOf(dir, id)).some((k) => !!ptyState(k)?.alive);
|
|
78
81
|
export const stagesOf = (dir: string, id: string): Record<string, string> => { try { return JSON.parse(readText(join(dir, "runs", id, "terminals.json"))) ?? {}; } catch { return {}; } };
|
|
79
82
|
export const markStage = (dir: string, id: string, stage: string, key?: string) => {
|
|
80
83
|
if (!stage || !key || !id || /^\.+$/.test(id)) return;
|
|
@@ -542,6 +545,15 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
542
545
|
busy = false;
|
|
543
546
|
}, 60_000);
|
|
544
547
|
|
|
548
|
+
// Automations: a due rule starts a run in its own project. Own busy flag; a fire may wait on a precheck.
|
|
549
|
+
let autoBusy = false;
|
|
550
|
+
const automate = setInterval(async () => {
|
|
551
|
+
if (autoBusy) return;
|
|
552
|
+
autoBusy = true;
|
|
553
|
+
try { if (await auto.tickAutomations(states(true).filter((d) => d !== join(home, ".kaizen")), { pick: inCard, live: runLive })) changed(); } catch { /* the next tick tries again */ }
|
|
554
|
+
autoBusy = false;
|
|
555
|
+
}, 60_000);
|
|
556
|
+
|
|
545
557
|
// Done requests are reported back to their sources here, on the board's own clock: a
|
|
546
558
|
// page load only reads, so opening the Icebox never closes an issue.
|
|
547
559
|
const loop = setInterval(async () => {
|
|
@@ -1271,6 +1283,41 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1271
1283
|
return json({ accounts: rows, windows: process.platform === "win32", ...(added ? { added } : {}) });
|
|
1272
1284
|
}
|
|
1273
1285
|
|
|
1286
|
+
if (path === "/automations" && (req.method === "GET" || req.method === "POST")) {
|
|
1287
|
+
if (!state || state === join(home, ".kaizen")) return json({ error: "Open a project first." }, 404);
|
|
1288
|
+
let rules: auto.Rule[];
|
|
1289
|
+
try { rules = auto.readRules(state); } catch (e: any) { return bad(e.message, 500); }
|
|
1290
|
+
if (req.method === "POST") {
|
|
1291
|
+
const refused = strict(req);
|
|
1292
|
+
if (refused) return refused;
|
|
1293
|
+
let body: any;
|
|
1294
|
+
try { body = await req.json(); } catch { return bad("json body expected"); }
|
|
1295
|
+
const id = String(body.id ?? "");
|
|
1296
|
+
let r: unknown = null;
|
|
1297
|
+
if (body.op === "create") r = auto.addRule(state, body);
|
|
1298
|
+
else if (body.op === "update") r = auto.updateRule(state, id, body);
|
|
1299
|
+
else if (body.op === "pause" || body.op === "resume") r = auto.setEnabled(state, id, body.op === "resume");
|
|
1300
|
+
else if (body.op === "delete") r = auto.removeRule(state, id);
|
|
1301
|
+
else if (body.op === "run") {
|
|
1302
|
+
const rule = rules.find((x) => x.id === id);
|
|
1303
|
+
if (!rule) return bad("No such automation.", 404);
|
|
1304
|
+
const h = await auto.fire(state, rule, "manual", Date.now(), { pick: inCard, live: runLive });
|
|
1305
|
+
changed();
|
|
1306
|
+
return json({ ok: h?.status === "launched", status: h?.status, why: h?.reason }, 200);
|
|
1307
|
+
} else return bad("unknown op");
|
|
1308
|
+
if (typeof r === "string") return bad(r);
|
|
1309
|
+
changed();
|
|
1310
|
+
rules = auto.readRules(state);
|
|
1311
|
+
}
|
|
1312
|
+
const hist = auto.readHistory(state);
|
|
1313
|
+
const now = Date.now();
|
|
1314
|
+
return json({
|
|
1315
|
+
zone: Intl.DateTimeFormat().resolvedOptions().timeZone, cap: auto.DAILY_CAP, project: label(state),
|
|
1316
|
+
agents: KNOWN_AGENTS.filter((a) => agentEnabled(a.cmd)).map((a) => ({ cmd: a.cmd, name: a.name })),
|
|
1317
|
+
rules: rules.map((r) => ({ ...r, next: auto.nextRun(r.cron, now), history: hist.filter((h) => h.rule === r.id).sort((a, b) => b.at - a.at).slice(0, 20).map((h) => ({ ...h, ...auto.shown(state, h, now) })) })),
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1274
1321
|
if (path === "/skills" && (req.method === "GET" || req.method === "POST")) {
|
|
1275
1322
|
if (req.method === "POST") {
|
|
1276
1323
|
const refused = strict(req);
|
|
@@ -2197,7 +2244,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
2197
2244
|
const live = ptyKeys().some((k) => ptyState(k)?.alive);
|
|
2198
2245
|
saveLive();
|
|
2199
2246
|
awake.stop();
|
|
2200
|
-
clearInterval(poll); clearInterval(ping); clearInterval(gather); clearInterval(loop); clearInterval(keepList);
|
|
2247
|
+
clearInterval(poll); clearInterval(ping); clearInterval(gather); clearInterval(automate); clearInterval(loop); clearInterval(keepList);
|
|
2201
2248
|
for (const w of watchers) { try { w.close(); } catch { /* gone */ } }
|
|
2202
2249
|
setTimeout(() => { server.stop(true); resolve(); }, live ? 400 : 0);
|
|
2203
2250
|
};
|
package/package.json
CHANGED
|
@@ -182,6 +182,13 @@ agent:
|
|
|
182
182
|
# Stops idle sleep from the board. off | auto (while the board runs agents) | on
|
|
183
183
|
# (while the board is open). Linux and macOS; agents in an outside terminal don't count.
|
|
184
184
|
keep_awake: off
|
|
185
|
+
# The model each tool launches with, the tool's own name. Empty: its default.
|
|
186
|
+
# Claude Code's stage subagents use subagents.model instead.
|
|
187
|
+
model:
|
|
188
|
+
agy: ""
|
|
189
|
+
codex: ""
|
|
190
|
+
gemini: ""
|
|
191
|
+
opencode: ""
|
|
185
192
|
# Minutes between an agent's reports. Quiet for two of these with no terminal
|
|
186
193
|
# activity, its card says stale.
|
|
187
194
|
heartbeat_minutes: 5
|
|
@@ -27,6 +27,7 @@ nearest first, so a change lands globally unless this project keeps its own conf
|
|
|
27
27
|
| `git.auto_commit` | `true`, `false` | Commit the work when a run finishes |
|
|
28
28
|
| `git.worktree_per_run` | `ask`, `true`, `false` | Build each run on its own branch in its own worktree and land it by pull request; `ask` offers the choice at the plan approval |
|
|
29
29
|
| `ui.mouse` | `false`, `true` | Click to select, click again to act; while on, the terminal cannot select text |
|
|
30
|
+
| `agent.model.<tool>` | the tool's own model name, or empty | Launch model for agy, codex, gemini, opencode, for every stage |
|
|
30
31
|
| `subagents.model` | `inherit`, `opus`, `sonnet`, `haiku` | Model the stage subagents run on (Claude Code only) |
|
|
31
32
|
| `subagents.effort` | `inherit`, `low`, `medium`, `high` | Reasoning effort for the stage subagents (Claude Code only) |
|
|
32
33
|
| `sources.every` | `off`, `1h`, `6h`, `24h` | How often the web board checks request sources for new requests, into the icebox, while it runs |
|
|
@@ -33,6 +33,7 @@ anything.
|
|
|
33
33
|
| `/kaizen gather` | Read request sources kaizen cannot read by itself; their requests land in the icebox, nothing starts |
|
|
34
34
|
| `/kaizen discover` | Group what is in the icebox and promote the ideas you pick; nothing starts |
|
|
35
35
|
| `/kaizen docs [lint]` | Write or refresh the project's docs vault in the notebook, which agents read first; `lint` only reports what is stale, broken or uncovered |
|
|
36
|
+
| `kaizen automation list\|add\|run <id>\|pause <id>\|resume <id>\|rm <id>\|runs <id>` | Schedules that start an unattended auto-mode run in this project (hourly, daily, weekdays, weekly or cron; optional precheck). Fires only while a board runs |
|
|
36
37
|
| `kaizen worker init\|start <wid>\|status\|config\|merge\|set <run> on\|off` | Orchestration (off by default): split a run into workers, each in its own board terminal and folder. `kaizen worker report` is for the workers themselves |
|
|
37
38
|
| `/kaizen approve` | Approve whatever the current run is waiting on |
|
|
38
39
|
| `/kaizen reject <reason>` | Reject it; the reason decides revise (back to planner) vs kill (abandon) |
|
|
@@ -51,10 +51,29 @@ Run `scripts/check.sh` first on a new machine.
|
|
|
51
51
|
For anything the helpers do not cover (triptych, recap timeline, stat rows) use
|
|
52
52
|
`d.slide()`, `d.kicker()`, `d.headline()`, `d.body()` and see build.js / build-features.js
|
|
53
53
|
in the reference project.
|
|
54
|
-
7. **
|
|
55
|
-
|
|
54
|
+
7. **Motion (when asked for animation or transitions):** copy in `scripts/motion.py` and run
|
|
55
|
+
`python3 motion.py Deck.pptx Deck-motion.pptx`, then QA the result. See "Brand theme and motion" below.
|
|
56
|
+
8. **QA:** `./qa.sh build-<name>.js`, look at every printed sheet (or send them to the user), fix, repeat. Clean `qa/` after.
|
|
57
|
+
9. **Report:** file path, the story in one line per slide, every placeholder left, every
|
|
56
58
|
claim the user must verify, and what was deliberately left out.
|
|
57
59
|
|
|
60
|
+
## Brand theme and motion
|
|
61
|
+
|
|
62
|
+
**Follow the user's brand when they name one.** Asked to match a landing page or site, read its CSS and
|
|
63
|
+
markup first, and use its colors, type, shapes and exact words instead of ink and gold. Pass them through the
|
|
64
|
+
`makeDeck` branding options, or build with `d.slide()`. Write new copy only for what the source lacks
|
|
65
|
+
(a researched problem, a contact slide), and say which lines are yours. Sales decks end on contact: name,
|
|
66
|
+
company, site, and a QR code. Do not put decks in the project repo.
|
|
67
|
+
|
|
68
|
+
**Transitions and animation:** `motion.py` adds fade and push transitions and automatic entrance fades. Name
|
|
69
|
+
shapes `a<N>-...` with `objectName` so the same N appears together; unnamed shapes appear one by one.
|
|
70
|
+
|
|
71
|
+
**Product footage is MP4, never GIF.** GIFs may not play in presentation apps. Render clips from real footage
|
|
72
|
+
with the `hyperframes` skill, then embed with
|
|
73
|
+
`slide.addMedia({ type: "video", path, cover: "data:image/png;base64,...", x, y, w, h })`.
|
|
74
|
+
`cover` must be base64. `motion.py` makes the first video on each slide autoplay, muted and looping. Renders
|
|
75
|
+
and QA sheets cannot show motion, so report it as unplayed until someone runs the slideshow.
|
|
76
|
+
|
|
58
77
|
## Agent notes (Claude Code, Codex, Gemini CLI, OpenCode, Cursor…)
|
|
59
78
|
Steps name capabilities, not tools. Where your agent lacks one:
|
|
60
79
|
- **web fetch** (finding stock photos, sources): ask the user for photos/links instead.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Add slide transitions, entrance fades and video autoplay to a built .pptx.
|
|
3
|
+
|
|
4
|
+
Usage: python3 motion.py in.pptx out.pptx
|
|
5
|
+
|
|
6
|
+
Shapes appear on their own, with no clicks. Name shapes `a<N>-anything`
|
|
7
|
+
(objectName in pptxgenjs) to control the order: the same N fades in together.
|
|
8
|
+
A slide with no such names fades its shapes in one after another.
|
|
9
|
+
Embedded videos play on slide entry, muted and looping.
|
|
10
|
+
"""
|
|
11
|
+
import re
|
|
12
|
+
import struct
|
|
13
|
+
import sys
|
|
14
|
+
import zipfile
|
|
15
|
+
|
|
16
|
+
TRANSITIONS = ['<p:transition spd="med"><p:fade/></p:transition>',
|
|
17
|
+
'<p:transition spd="med"><p:push dir="l"/></p:transition>']
|
|
18
|
+
STAGGER_MS = 350
|
|
19
|
+
FADE_MS = 600
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def mp4_ms(data):
|
|
23
|
+
"""Duration from the mp4 mvhd box."""
|
|
24
|
+
i = data.find(b"mvhd")
|
|
25
|
+
if i < 0:
|
|
26
|
+
return 60000
|
|
27
|
+
if data[i + 4] == 1:
|
|
28
|
+
scale, length = struct.unpack(">IQ", data[i + 24:i + 36])
|
|
29
|
+
else:
|
|
30
|
+
scale, length = struct.unpack(">II", data[i + 16:i + 24])
|
|
31
|
+
return max(1, length * 1000 // scale)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def fade(ids, sid, group):
|
|
35
|
+
target = f'<p:tgtEl><p:spTgt spid="{sid}"/></p:tgtEl>'
|
|
36
|
+
return (f'<p:par><p:cTn id="{next(ids)}" presetID="10" presetClass="entr" presetSubtype="0" fill="hold" nodeType="withEffect">'
|
|
37
|
+
f'<p:stCondLst><p:cond delay="{200 + group * STAGGER_MS}"/></p:stCondLst><p:childTnLst>'
|
|
38
|
+
f'<p:set><p:cBhvr><p:cTn id="{next(ids)}" dur="1" fill="hold"><p:stCondLst><p:cond delay="0"/></p:stCondLst></p:cTn>{target}'
|
|
39
|
+
'<p:attrNameLst><p:attrName>style.visibility</p:attrName></p:attrNameLst></p:cBhvr><p:to><p:strVal val="visible"/></p:to></p:set>'
|
|
40
|
+
f'<p:animEffect transition="in" filter="fade"><p:cBhvr><p:cTn id="{next(ids)}" dur="{FADE_MS}"/>{target}</p:cBhvr></p:animEffect>'
|
|
41
|
+
'</p:childTnLst></p:cTn></p:par>')
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def play(ids, sid, ms):
|
|
45
|
+
return (f'<p:par><p:cTn id="{next(ids)}" presetID="1" presetClass="mediacall" presetSubtype="0" fill="hold" nodeType="withEffect">'
|
|
46
|
+
'<p:stCondLst><p:cond delay="0"/></p:stCondLst><p:childTnLst><p:cmd type="call" cmd="playFrom(0.0)"><p:cBhvr>'
|
|
47
|
+
f'<p:cTn id="{next(ids)}" dur="{ms}" fill="hold"/><p:tgtEl><p:spTgt spid="{sid}"/></p:tgtEl></p:cBhvr></p:cmd>'
|
|
48
|
+
'</p:childTnLst></p:cTn></p:par>')
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def timing(xml, video_ms):
|
|
52
|
+
ids = iter(range(4, 100000))
|
|
53
|
+
named = [(sid, int(g)) for sid, g in re.findall(r'<p:cNvPr id="(\d+)" name="a(\d+)-', xml)]
|
|
54
|
+
if not named:
|
|
55
|
+
found = re.findall(r'<p:(?:sp|pic)>.*?<p:cNvPr id="(\d+)"', xml, re.S)
|
|
56
|
+
named = [(sid, n) for n, sid in enumerate(found)]
|
|
57
|
+
video = next((re.search(r'<p:cNvPr id="(\d+)"', pic)[1]
|
|
58
|
+
for pic in re.findall(r"<p:pic>.*?</p:pic>", xml, re.S) if "videoFile" in pic), None)
|
|
59
|
+
if not named and not video:
|
|
60
|
+
return ""
|
|
61
|
+
inner = next(ids)
|
|
62
|
+
effects = "".join(fade(ids, sid, group) for sid, group in named)
|
|
63
|
+
media = ""
|
|
64
|
+
if video and video_ms:
|
|
65
|
+
effects += play(ids, video, video_ms)
|
|
66
|
+
media = (f'<p:video><p:cMediaNode vol="0"><p:cTn id="{next(ids)}" repeatCount="indefinite" fill="hold" display="0">'
|
|
67
|
+
f'<p:stCondLst><p:cond delay="indefinite"/></p:stCondLst></p:cTn><p:tgtEl><p:spTgt spid="{video}"/></p:tgtEl>'
|
|
68
|
+
'</p:cMediaNode></p:video>')
|
|
69
|
+
slide = '<p:tgtEl><p:sldTgt/></p:tgtEl>'
|
|
70
|
+
return ('<p:timing><p:tnLst><p:par><p:cTn id="1" dur="indefinite" restart="never" nodeType="tmRoot"><p:childTnLst>'
|
|
71
|
+
'<p:seq concurrent="1" nextAc="seek"><p:cTn id="2" dur="indefinite" nodeType="mainSeq"><p:childTnLst>'
|
|
72
|
+
'<p:par><p:cTn id="3" fill="hold"><p:stCondLst><p:cond delay="indefinite"/><p:cond evt="onBegin" delay="0"><p:tn val="2"/></p:cond></p:stCondLst><p:childTnLst>'
|
|
73
|
+
f'<p:par><p:cTn id="{inner}" fill="hold"><p:stCondLst><p:cond delay="0"/></p:stCondLst><p:childTnLst>{effects}</p:childTnLst></p:cTn></p:par>'
|
|
74
|
+
'</p:childTnLst></p:cTn></p:par></p:childTnLst></p:cTn>'
|
|
75
|
+
f'<p:prevCondLst><p:cond evt="onPrev" delay="0">{slide}</p:cond></p:prevCondLst>'
|
|
76
|
+
f'<p:nextCondLst><p:cond evt="onNext" delay="0">{slide}</p:cond></p:nextCondLst></p:seq>'
|
|
77
|
+
f'{media}</p:childTnLst></p:cTn></p:par></p:tnLst></p:timing>')
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def main(src, dst):
|
|
81
|
+
with zipfile.ZipFile(src) as zin, zipfile.ZipFile(dst, "w", zipfile.ZIP_DEFLATED) as zout:
|
|
82
|
+
for item in zin.infolist():
|
|
83
|
+
data = zin.read(item)
|
|
84
|
+
m = re.fullmatch(r"ppt/slides/slide(\d+)\.xml", item.filename)
|
|
85
|
+
if m:
|
|
86
|
+
rels = zin.read(f"ppt/slides/_rels/slide{m[1]}.xml.rels").decode()
|
|
87
|
+
# ponytail: one video per slide; a second one stays click-to-play
|
|
88
|
+
mp4 = re.search(r"media/([^\"]+\.mp4)", rels)
|
|
89
|
+
ms = mp4_ms(zin.read("ppt/media/" + mp4[1])) if mp4 else 0
|
|
90
|
+
xml = data.decode()
|
|
91
|
+
add = TRANSITIONS[int(m[1]) % 2] + timing(xml, ms)
|
|
92
|
+
data = xml.replace("</p:clrMapOvr>", "</p:clrMapOvr>" + add, 1).encode()
|
|
93
|
+
zout.writestr(item, data)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
if __name__ == "__main__":
|
|
97
|
+
if len(sys.argv) != 3:
|
|
98
|
+
sys.exit(__doc__)
|
|
99
|
+
main(sys.argv[1], sys.argv[2])
|
package/web/board/phone.ts
CHANGED
|
@@ -176,6 +176,8 @@ function haptic() {
|
|
|
176
176
|
tick = document.createElement("label");
|
|
177
177
|
tick.hidden = true;
|
|
178
178
|
tick.innerHTML = `<input type="checkbox" switch>`;
|
|
179
|
+
// This click is not the user's: a window listener would read it as a tap outside a sheet.
|
|
180
|
+
tick.onclick = (e) => e.stopPropagation();
|
|
179
181
|
document.body.append(tick);
|
|
180
182
|
}
|
|
181
183
|
tick.click();
|
package/web/board/run-view.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { load, post } from "./api.ts";
|
|
|
19
19
|
import { attach, md, preview } from "./markdown.ts";
|
|
20
20
|
import { layout } from "./terms.ts";
|
|
21
21
|
import { cardHref, markCurrent, railData, stateOf, titleOf, wsHref, wsOfCard } from "./workspace.ts";
|
|
22
|
-
import { type Node, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, newRun, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
22
|
+
import { type Node, type Box, awaiting, chosen, finished, historyOf, leaves, liveIn, loopbackUrl, migrate, nearestPane, newRun, pickable, prune, reviewing, stageTabs, toOpen, wsKey } from "./ws-tabs.ts";
|
|
23
23
|
import { drawPick, hidePick, initPick, setOpen } from "./run-pick.ts";
|
|
24
24
|
import { age } from "./labels.ts";
|
|
25
25
|
import { go } from "./views.ts";
|
|
@@ -903,7 +903,113 @@ function initSheet() {
|
|
|
903
903
|
addEventListener("click", (e) => on() && !e.composedPath().some((n) => (n as Element).matches?.("#panel,#rside,dialog,.toast")) && shut());
|
|
904
904
|
}
|
|
905
905
|
|
|
906
|
+
// The keyboard, tmux style: Ctrl+Space puts focus in the current pane, then one more key
|
|
907
|
+
// moves it: arrows or hjkl between panes, 1-9, n, p between tabs.
|
|
908
|
+
const focusPane = (id?: string) => {
|
|
909
|
+
const el = id ? panes.get(id)?.el : null;
|
|
910
|
+
requestAnimationFrame(() => el?.querySelector<HTMLElement>("textarea,input,iframe")?.focus());
|
|
911
|
+
};
|
|
912
|
+
const setPane = (sc: Screen, id: string) => {
|
|
913
|
+
sc.focus = id;
|
|
914
|
+
save();
|
|
915
|
+
draw();
|
|
916
|
+
focusPane(id);
|
|
917
|
+
};
|
|
918
|
+
const DIRS = { ArrowLeft: "l", h: "l", ArrowRight: "r", l: "r", ArrowUp: "u", k: "u", ArrowDown: "d", j: "d" } as const;
|
|
919
|
+
function paneKey(k: string) {
|
|
920
|
+
if (k === "?") {
|
|
921
|
+
(document.activeElement as HTMLElement)?.blur(); // Escape closes it only from outside the terminal
|
|
922
|
+
return void $("help").classList.add("on");
|
|
923
|
+
}
|
|
924
|
+
if (k === "x") {
|
|
925
|
+
const sc = screens().find((x) => x.id === saved().on);
|
|
926
|
+
if (sc) void closeTab(sc.focus).then(() => focusPane(screens().find((x) => x.id === saved().on)?.focus));
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
const mode = { c: "tab", r: "cols", d: "rows" }[k];
|
|
930
|
+
if (mode) {
|
|
931
|
+
const add = $("rtabs").querySelector<HTMLDetailsElement>(`.radd[data-mode=${mode}]`);
|
|
932
|
+
if (add) add.open = true;
|
|
933
|
+
requestAnimationFrame(() => add?.querySelector<HTMLElement>(".menu-pop button")?.focus());
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
const s = saved(),
|
|
937
|
+
scs = screens(),
|
|
938
|
+
at = scs.findIndex((x) => x.id === s.on),
|
|
939
|
+
sc = scs[at];
|
|
940
|
+
if (!sc) return;
|
|
941
|
+
if (DIRS[k]) {
|
|
942
|
+
const boxes: Record<string, Box> = {};
|
|
943
|
+
for (const id of leaves(sc.tree)) {
|
|
944
|
+
const el = panes.get(id)?.el;
|
|
945
|
+
if (el) boxes[id] = el.getBoundingClientRect();
|
|
946
|
+
}
|
|
947
|
+
const to = nearestPane(boxes, sc.focus, DIRS[k]);
|
|
948
|
+
if (to) setPane(sc, to);
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const i = k === "n" ? (at + 1) % scs.length : k === "p" ? (at - 1 + scs.length) % scs.length : /^[1-9]$/.test(k) ? +k - 1 : -1;
|
|
952
|
+
const to = scs[i];
|
|
953
|
+
if (!to) return;
|
|
954
|
+
s.on = to.id;
|
|
955
|
+
save();
|
|
956
|
+
draw();
|
|
957
|
+
focusPane(to.focus);
|
|
958
|
+
}
|
|
959
|
+
// While the prefix waits for its key, a chip says so and lists the keys.
|
|
960
|
+
function keyHint(on: boolean) {
|
|
961
|
+
document.getElementById("keyhint")?.remove();
|
|
962
|
+
if (!on) return;
|
|
963
|
+
const h = document.createElement("div");
|
|
964
|
+
h.id = "keyhint";
|
|
965
|
+
h.setAttribute("role", "status");
|
|
966
|
+
const keys = [["←↓↑→", "pane"], ["1-9", "tab"], ["n p", "next, prev"], ["c", "new tab"], ["r", "split right"], ["d", "split down"], ["x", "close pane"], ["?", "all keys"]];
|
|
967
|
+
h.innerHTML = String(html`${keys.map(([k, t]) => html`<span><kbd>${k}</kbd>${t}</span>`)}`);
|
|
968
|
+
document.body.append(h);
|
|
969
|
+
}
|
|
970
|
+
function initPaneKeys() {
|
|
971
|
+
let armed: Timer | undefined;
|
|
972
|
+
// Capture: xterm must not see these. Ctrl+B would reach an agent or a tmux inside the pane.
|
|
973
|
+
addEventListener(
|
|
974
|
+
"keydown",
|
|
975
|
+
(e) => {
|
|
976
|
+
if (!ctx || !document.body.classList.contains("runv") || document.querySelector("dialog[open]")) return;
|
|
977
|
+
if (e.ctrlKey && !e.shiftKey && e.code === "Space") {
|
|
978
|
+
e.preventDefault();
|
|
979
|
+
e.stopPropagation();
|
|
980
|
+
focusPane(screens().find((x) => x.id === saved().on)?.focus);
|
|
981
|
+
clearTimeout(armed);
|
|
982
|
+
keyHint(true);
|
|
983
|
+
armed = setTimeout(() => ((armed = undefined), keyHint(false)), 2000);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
// The open +, split right or split down menu: arrows or j k walk it, Enter picks, Escape closes.
|
|
987
|
+
const add = $("rtabs").querySelector<HTMLDetailsElement>(".radd[open]");
|
|
988
|
+
if (add) {
|
|
989
|
+
const step = { ArrowDown: 1, j: 1, ArrowUp: -1, k: -1 }[e.key];
|
|
990
|
+
if (step || e.key === "Escape") {
|
|
991
|
+
e.preventDefault();
|
|
992
|
+
e.stopPropagation();
|
|
993
|
+
if (!step) return void ((add.open = false), focusPane(screens().find((x) => x.id === saved().on)?.focus));
|
|
994
|
+
const items = [...add.querySelectorAll<HTMLElement>(".menu-pop button")];
|
|
995
|
+
items[(items.indexOf(document.activeElement as HTMLElement) + step + items.length) % items.length]?.focus();
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
if (!armed || ["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
|
|
1000
|
+
e.preventDefault();
|
|
1001
|
+
e.stopPropagation();
|
|
1002
|
+
clearTimeout(armed);
|
|
1003
|
+
armed = undefined;
|
|
1004
|
+
keyHint(false);
|
|
1005
|
+
paneKey(e.key);
|
|
1006
|
+
},
|
|
1007
|
+
true,
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
906
1011
|
export function initRunView() {
|
|
1012
|
+
initPaneKeys();
|
|
907
1013
|
// A phone's sheet closes with the panel's ×, which here hides the sheet rather than closing the card.
|
|
908
1014
|
document.addEventListener(
|
|
909
1015
|
"click",
|