kaizen-agent 1.72.0 → 1.73.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/skills.ts +21 -1
- package/cli/web.ts +15 -3
- package/package.json +1 -1
- package/web/board/add-project.ts +7 -6
- package/web/board/settings-skills.ts +9 -1
- package/web/board.html +1 -1
- package/web/board.js +95 -93
- package/web/notebook.js +252 -29
- package/web/term.js +1 -1
- package/web/video.js +287 -64
package/cli/skills.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// skill.json ({ title, group, needs, off_by_default }), so a new folder needs no change elsewhere.
|
|
3
3
|
// Turning one off removes kaizen's own links for this user; a real folder, or a link to
|
|
4
4
|
// anything else, under the same name stays. ~/.kaizen/skills-off.json keeps the choice.
|
|
5
|
-
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, rmdirSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
7
7
|
|
|
8
8
|
export type Skill = { id: string; rel: string; title: string; description: string; group: "core" | "media" | "optional"; needs: string[]; offByDefault: boolean; status: string };
|
|
@@ -83,6 +83,26 @@ function installedClone(home: string, repo: string) {
|
|
|
83
83
|
return repo;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
// A core skill that is not kaizen's link for some agent: link it again from the installed clone.
|
|
87
|
+
// A stale or foreign link just goes; a real folder in the way goes only with `replace`, which the
|
|
88
|
+
// page sends after asking. Returns an error, "replace required", or null.
|
|
89
|
+
export function repairSkill(repo: string, home: string, id: string, replace = false): string | null {
|
|
90
|
+
const skill = bundledSkills(repo).find((s) => s.id === id);
|
|
91
|
+
if (!skill) return "unknown skill";
|
|
92
|
+
const clone = installedClone(home, repo), src = join(clone, "skills", skill.rel);
|
|
93
|
+
if (!existsSync(join(src, "SKILL.md"))) return `The kaizen install in ${clone} is older than this skill. Run kaizen upgrade, then Re-check`;
|
|
94
|
+
const todo = SKILL_HOMES.filter((h) => existsSync(join(home, h.dir))).map((h) => join(home, h.dir, "skills", id)).filter((p) => !ours(p, skill.rel));
|
|
95
|
+
if (!replace && todo.some((p) => existsSync(p) && !isLink(p))) return "replace required";
|
|
96
|
+
for (const p of todo) {
|
|
97
|
+
// A link goes as a link (a junction is a directory to rmdir), never what it points at.
|
|
98
|
+
if (isLink(p)) { try { unlinkSync(p); } catch { rmdirSync(p); } }
|
|
99
|
+
else if (existsSync(p)) rmSync(p, { recursive: true, force: true });
|
|
100
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
101
|
+
symlinkSync(src, p, process.platform === "win32" ? "junction" : undefined);
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
86
106
|
// Returns an error, or null. Global links only: a project's own install is left alone.
|
|
87
107
|
// A skill off by default is turned on only with confirm, which the page sends after its warning.
|
|
88
108
|
export function setSkill(repo: string, home: string, id: string, on: boolean, confirm = false): string | null {
|
package/cli/web.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { ACCOUNT_VAR, accountDir, addAccount, readAccounts, renameAccount, signedIn, removeAccount, resolveAccount, setDefaultAccount } from "./accounts.ts";
|
|
15
15
|
import { readReport, signalOf } from "./report.ts";
|
|
16
16
|
import { MAX_IMAGE, saveImage } from "./term-image.ts";
|
|
17
|
-
import { bundledSkills, setSkill, skillsHeld, skillsOff, skillStatus } from "./skills.ts";
|
|
17
|
+
import { bundledSkills, repairSkill, setSkill, skillsHeld, skillsOff, skillStatus } from "./skills.ts";
|
|
18
18
|
import * as rea from "./rea.ts";
|
|
19
19
|
import { accountEnv, accountForRun, agentUsable, CHILD_ENV, heartbeatMinutes, keepAwake, launchPreview, trustFolder, YOLO_FLAGS } from "./state.ts";
|
|
20
20
|
import { agentLine, failStart, handoffModel, markRunning, readWorkers, requested, startWorker, sweep, workerStale } from "./workers.ts";
|
|
@@ -72,7 +72,10 @@ const installed = () => {
|
|
|
72
72
|
const VERSION = installed();
|
|
73
73
|
// Set by the desktop app when this board is its own read-only copy, which updates
|
|
74
74
|
// with the app. Read once and removed, so terminals and agents this board starts
|
|
75
|
-
// (and any board started from them) do not inherit it.
|
|
75
|
+
// (and any board started from them) do not inherit it. The app's KAIZEN_HOME (that
|
|
76
|
+
// copy's folder) is removed too, both again in web() after adoptLoginEnv, which would
|
|
77
|
+
// put them back: inherited, it sent `kaizen upgrade` in a board terminal at the
|
|
78
|
+
// read-only AppImage (EROFS).
|
|
76
79
|
const DESKTOP_BUNDLED = process.env.KAIZEN_DESKTOP_BUNDLED === "1";
|
|
77
80
|
delete process.env.KAIZEN_DESKTOP_BUNDLED;
|
|
78
81
|
// An upgrade replaces the page files under a running board but not its code, and a
|
|
@@ -186,6 +189,13 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
186
189
|
// Before anything looks for an agent on PATH: the board starts agents itself, and
|
|
187
190
|
// from a launcher it would otherwise have none of the user's shell setup.
|
|
188
191
|
adoptLoginEnv();
|
|
192
|
+
// After the login shell's variables: Bun runs that probe with the board's original
|
|
193
|
+
// environment, so it hands back what was removed at load and adoptLoginEnv put it back.
|
|
194
|
+
// The desktop app's flag never leaves this board, and nor does its KAIZEN_HOME (the
|
|
195
|
+
// bundled copy's folder, which the board has as repoDir and reads no more): its
|
|
196
|
+
// terminals and agents get the user's own install. A KAIZEN_HOME the user set is kept.
|
|
197
|
+
delete process.env.KAIZEN_DESKTOP_BUNDLED;
|
|
198
|
+
if (DESKTOP_BUNDLED && process.env.KAIZEN_HOME && resolve(process.env.KAIZEN_HOME) === resolve(repoDir)) delete process.env.KAIZEN_HOME;
|
|
189
199
|
// Where the board started. Each page picks its own project and names it in the
|
|
190
200
|
// x-kz-dir header, so a phone choosing another project never moves this tab.
|
|
191
201
|
const boardState = locate();
|
|
@@ -1628,7 +1638,9 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
1628
1638
|
// GET: the warning is a step a person takes, not a flag a caller can send.
|
|
1629
1639
|
const tokenOk = !!skillToken && body?.token === skillToken;
|
|
1630
1640
|
skillToken = "";
|
|
1631
|
-
const why =
|
|
1641
|
+
const why = body?.repair === true
|
|
1642
|
+
? repairSkill(repoDir, home, String(body?.id ?? ""), body?.replace === true && tokenOk)
|
|
1643
|
+
: setSkill(repoDir, home, String(body?.id ?? ""), body?.on === true, body?.confirm === true && tokenOk);
|
|
1632
1644
|
if (why) return bad(why);
|
|
1633
1645
|
}
|
|
1634
1646
|
const off = [...skillsOff(home), ...skillsHeld(repoDir, home)];
|
package/package.json
CHANGED
package/web/board/add-project.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { html, modal } from "./dom.ts";
|
|
5
5
|
import { gitProjects, wsHref } from "./workspace.ts";
|
|
6
6
|
import { branchSlug } from "./ws-tabs.ts";
|
|
7
|
+
import { toast } from "./toast.ts";
|
|
8
|
+
import { pick as pickProject } from "./projects.ts";
|
|
7
9
|
|
|
8
10
|
type Start = "folder" | "clone" | "create" | "ws";
|
|
9
11
|
const SEP = (p: string) => (p.includes("\\") ? "\\" : "/");
|
|
@@ -29,13 +31,12 @@ export function openAdd(opts: { dir?: string | null; start?: Start } = {}) {
|
|
|
29
31
|
const back = fixed ? "" : html`<button type="button" class="btn ghost" data-a="back">Back to add options</button>`;
|
|
30
32
|
const foot = (go: string) => html`<small class="att err" role="alert"></small><div class="row">${back}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">${go}</button></div>`;
|
|
31
33
|
const say = (t: string) => ((form.querySelector(".err") as HTMLElement).textContent = t);
|
|
32
|
-
// A project was added: the sheet says so,
|
|
34
|
+
// A project was added: the sheet closes, a toast says so, and the project list picks it up.
|
|
35
|
+
// No reload: the board switches to it in place.
|
|
33
36
|
const landed = (stateDir: string, msg: string) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} catch {}
|
|
38
|
-
setTimeout(() => (location.href = "/"), 900);
|
|
37
|
+
dl.close();
|
|
38
|
+
toast(msg);
|
|
39
|
+
void pickProject(stateDir);
|
|
39
40
|
};
|
|
40
41
|
// The folder dialog; with `name`, the picked folder is a parent and the project's name is appended.
|
|
41
42
|
const pick = async (into: HTMLInputElement, name?: () => string) => {
|
|
@@ -27,7 +27,7 @@ const skillIcon = (id: string) => raw(`<svg class="sk-i" viewBox="0 0 24 24" ari
|
|
|
27
27
|
const row = (s: Row) =>
|
|
28
28
|
html`<div class="sk" data-q="${[s.title, s.id, s.description, s.group, "skill"].join(" ").toLowerCase()}">
|
|
29
29
|
<div class="sk-h">${skillIcon(s.id)}<span class="sk-n"><b>${s.title}${s.status && s.status !== "stable" ? html` <em class="sk-st">${s.status === "beta" ? "Beta" : "Experimental"}</em>` : ""}</b><span>${s.description}</span></span>
|
|
30
|
-
${s.group === "core" ? html`<span class="hint">Always on</span>` : html`${s.rea?.update ? html`<button type="button" class="btn" data-rea-update="1">Update to ${s.rea.latest}</button>` : ""}${!s.rea && !s.off && s.agents.some((a) => a.state === "missing") ? html`<button type="button" class="btn" data-skill="${s.id}" data-on="true">Install</button>` : ""}<button type="button" class="chk sm${s.off ? "" : " on"}" data-skill="${s.id}" data-on="${String(s.off)}" data-warn="${String(!!s.offByDefault)}" role="switch" aria-checked="${String(!s.off)}" aria-label="${s.title}" title="${s.off ? "Off" : "On"}"></button>`}</div>
|
|
30
|
+
${s.group === "core" ? (s.agents.some((a) => a.state !== "installed") ? html`<button type="button" class="btn" data-repair="${s.id}" data-own="${String(s.agents.some((a) => a.state === "other"))}">Repair</button>` : html`<span class="hint">Always on</span>`) : html`${s.rea?.update ? html`<button type="button" class="btn" data-rea-update="1">Update to ${s.rea.latest}</button>` : ""}${!s.rea && !s.off && s.agents.some((a) => a.state === "missing") ? html`<button type="button" class="btn" data-skill="${s.id}" data-on="true">Install</button>` : ""}<button type="button" class="chk sm${s.off ? "" : " on"}" data-skill="${s.id}" data-on="${String(s.off)}" data-warn="${String(!!s.offByDefault)}" role="switch" aria-checked="${String(!s.off)}" aria-label="${s.title}" title="${s.off ? "Off" : "On"}"></button>`}</div>
|
|
31
31
|
<div class="sk-a">${s.agents.map((a) => html`<img class="sk-ag${a.state === "installed" ? "" : " off"}" src="${AGENT_FAVICONS[AGENT_CMD[a.agent] ?? ""] ?? ""}" width="18" height="18" alt="${a.agent}: ${WORD[a.state] ?? a.state}" title="${a.agent}: ${WORD[a.state] ?? a.state}">`)}${s.needs.map((n) => html`<span class="${n.found ? "" : "miss"}">Needs ${n.name}${n.found ? "" : " (not found)"}</span>`)}${s.note ? html`<span>${s.note}</span>` : ""}</div>
|
|
32
32
|
</div>`;
|
|
33
33
|
|
|
@@ -60,6 +60,14 @@ export function wireSkills(redraw: () => Promise<unknown>, token = "") {
|
|
|
60
60
|
if (again) again.onclick = () => redraw();
|
|
61
61
|
const up = $("pbody").querySelector<HTMLElement>("[data-rea-update]");
|
|
62
62
|
if (up) up.onclick = () => reaSwitch(true, true, redraw);
|
|
63
|
+
// A core skill one agent is missing: relink it; a real folder in the way is replaced only after asking.
|
|
64
|
+
$("pbody").querySelectorAll<HTMLElement>("[data-repair]").forEach((b) => (b.onclick = async () => {
|
|
65
|
+
const own = b.dataset.own === "true";
|
|
66
|
+
if (own && !confirm("Replace your own copy?\n\nFor at least one agent, a folder or link of the same name is in the way. It is deleted and kaizen's skill is linked in its place. Go ahead?")) return;
|
|
67
|
+
const j = await post("/skills", { id: b.dataset.repair, repair: true, ...(own ? { replace: true, token } : {}) });
|
|
68
|
+
toast(j.error ? j.error : "Repaired. Applies to new sessions");
|
|
69
|
+
await redraw();
|
|
70
|
+
}));
|
|
63
71
|
$("pbody").querySelectorAll<HTMLElement>("[data-skill]").forEach((b) => (b.onclick = async () => {
|
|
64
72
|
const on = b.dataset.on === "true";
|
|
65
73
|
if (b.dataset.skill === "rea") return reaSwitch(on, false, redraw);
|
package/web/board.html
CHANGED
|
@@ -455,7 +455,7 @@ dialog.onb-ask h3{margin:0 0 4px;font-size:16px;color:var(--ink-hi)}dialog.onb-a
|
|
|
455
455
|
@media(max-width:640px){dialog.onb{width:100vw;height:100dvh;max-width:none;max-height:none;border-radius:0}dialog.onb[open]{padding:18px 18px 12px}.onb-grid,.onb-themes{grid-template-columns:1fr 1fr}.onb-main h2{font-size:24px}.onb-ft kbd{display:none}}
|
|
456
456
|
@media(prefers-reduced-motion:reduce){.onb-prog button{transition:none}}
|
|
457
457
|
dialog.kz.wsnew{width:min(576px,calc(100vw - 32px))}dialog.wsnew .inl{gap:12px;max-height:85dvh;overflow-y:auto}dialog.wsnew .wsfrom{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:-6px}dialog.wsnew .wsfrom i{font-style:normal;opacity:.7}dialog.wsnew .wsbase{display:flex;align-items:center;gap:4px;font-size:12px;color:var(--dim);min-width:0}dialog.wsnew .wsbase select{width:auto;max-width:200px;border:0;background:none;color:var(--ink);font-size:12px;padding:2px}dialog.wsnew .wsadv summary{cursor:pointer;font-size:12px;color:var(--dim);padding:2px 0}dialog.wsnew .wsadv[open] summary{margin-bottom:8px}dialog.wsnew .err:empty{display:none}dialog.wsnew .err:not(:empty){color:var(--danger);border:1px solid color-mix(in srgb,var(--danger) 30%,transparent);background:color-mix(in srgb,var(--danger) 10%,transparent);border-radius:var(--r-xs);padding:8px 12px}dialog.wsnew .row{justify-content:flex-end;align-items:center}dialog.wsnew .wskey{order:-1;margin-right:auto;font:11px var(--mono);color:var(--dim)}
|
|
458
|
-
dialog.kz{border:0;padding:0;background:none;width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:visible;color:var(--ink)}dialog.kz::backdrop{background:rgb(0 0 0/.45)}dialog.kz>.inl{background:var(--bg);border:1px solid var(--line);border-radius:var(--r-l);padding:16px;gap:10px}dialog.kz .inl input,dialog.kz .inl textarea{background:var(--canvas);border-color:var(--line)}dialog.kz .row input{flex:1;min-width:0}dialog.kz #ndc{align-self:flex-start}dialog.kz .btn.opt{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:8px 12px;text-align:left}dialog.kz .btn.opt small{color:var(--dim)}dialog.kz label.att{display:flex;flex-direction:column;gap:4px}dialog.kz label.att:has(input[type=checkbox]){flex-direction:row;align-items:center}dialog.kz select{background:var(--canvas);border:1px solid var(--line);border-radius:var(--r-s);color:var(--ink);padding:6px 8px;font:inherit}dialog.viewer{width:min(1100px,calc(100vw - 32px));height:calc(100dvh - 32px);background:var(--bg);border-radius:var(--r);display:none;flex-direction:column;overflow:hidden}dialog.viewer[open]{display:flex}.viewer-hd{display:flex;gap:12px;align-items:center;padding:8px 12px;border-bottom:1px solid var(--line)}.viewer-hd span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600}dialog.viewer img{flex:1;min-height:0;width:100%;object-fit:contain}dialog.viewer iframe{flex:1;border:0;width:100%;background:#fff}
|
|
458
|
+
dialog.kz{border:0;padding:0;background:none;width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:visible;color:var(--ink)}dialog.kz::backdrop{background:rgb(0 0 0/.45)}dialog.kz>.inl{background:var(--bg);border:1px solid var(--line);border-radius:var(--r-l);padding:16px;gap:10px}dialog.kz .inl input,dialog.kz .inl textarea{background:var(--canvas);border-color:var(--line)}dialog.kz .row input{flex:1;min-width:0}dialog.kz #ndc{align-self:flex-start}dialog.kz .btn.opt{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:8px 12px;text-align:left}dialog.kz .btn.opt small{color:var(--dim)}dialog.kz label.att{display:flex;flex-direction:column;gap:4px}dialog.kz label.att:has(input[type=checkbox]){flex-direction:row;align-items:center;gap:8px}dialog.kz label.att input[type=checkbox]{flex:none;width:auto;margin:0}dialog.kz select{background:var(--canvas);border:1px solid var(--line);border-radius:var(--r-s);color:var(--ink);padding:6px 8px;font:inherit}dialog.viewer{width:min(1100px,calc(100vw - 32px));height:calc(100dvh - 32px);background:var(--bg);border-radius:var(--r);display:none;flex-direction:column;overflow:hidden}dialog.viewer[open]{display:flex}.viewer-hd{display:flex;gap:12px;align-items:center;padding:8px 12px;border-bottom:1px solid var(--line)}.viewer-hd span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600}dialog.viewer img{flex:1;min-height:0;width:100%;object-fit:contain}dialog.viewer iframe{flex:1;border:0;width:100%;background:#fff}
|
|
459
459
|
@keyframes sheet-up{from{transform:translateY(100%)}}dialog.kz.sheet{width:100vw;max-width:none;margin:auto 0 0;max-height:85dvh;animation:sheet-up .2s ease-out}dialog.kz.sheet>.inl{border-width:1px 0 0;border-radius:16px 16px 0 0;padding-bottom:calc(16px + env(safe-area-inset-bottom));max-height:85dvh;overflow-y:auto}@media(prefers-reduced-motion:reduce){dialog.kz.sheet{animation:none}}
|
|
460
460
|
.inl .run-actions{display:grid;gap:8px}.inl .run-actions .row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.inl .run-actions .pri{grid-column:1/-1}
|
|
461
461
|
.notes{display:flex;flex-direction:column;gap:8px}
|