kaizen-agent 1.59.2 → 1.60.1
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/add-project.test.ts +169 -0
- package/cli/add-project.ts +132 -0
- package/cli/board.test.ts +15 -0
- package/cli/chat.ts +1 -1
- package/cli/dashboard.ts +6 -2
- package/cli/install.test.ts +1 -1
- package/cli/install.ts +18 -9
- package/cli/pty.test.ts +89 -5
- package/cli/pty.ts +126 -9
- package/cli/restart.test.ts +169 -0
- package/cli/settings.test.ts +35 -0
- package/cli/settings.ts +69 -18
- package/cli/state.test.ts +119 -3
- package/cli/state.ts +171 -13
- package/cli/usage.test.ts +130 -1
- package/cli/web-accept.test.ts +54 -0
- package/cli/web-pr.test.ts +51 -0
- package/cli/web-symlink.test.ts +28 -0
- package/cli/web.ts +349 -100
- package/cli/worktree.test.ts +146 -1
- package/cli/worktree.ts +214 -4
- package/cli/writeback.ts +1 -1
- package/package.json +1 -1
- package/skills/kaizen/SKILL.md +5 -1
- package/skills/kaizen/config.default.yml +15 -2
- package/skills/kaizen/settings.md +1 -0
- package/skills/kaizen/spec-main.md +28 -2
- package/skills/kaizen-help/SKILL.md +1 -0
- package/web/board/add-project.ts +136 -0
- package/web/board/api.ts +1 -1
- package/web/board/badge.ts +5 -5
- package/web/board/cards.ts +11 -3
- package/web/board/context.ts +1 -0
- package/web/board/fixes.ts +3 -2
- package/web/board/git.ts +309 -60
- package/web/board/home.ts +7 -1
- package/web/board/ideas.ts +20 -3
- package/web/board/live.ts +1 -1
- package/web/board/main.ts +26 -9
- package/web/board/panel.ts +31 -16
- package/web/board/projects.ts +6 -85
- package/web/board/run-pick.ts +41 -0
- package/web/board/run-view.ts +286 -110
- package/web/board/search-match.ts +20 -0
- package/web/board/search.test.ts +20 -0
- package/web/board/search.ts +324 -0
- package/web/board/settings.ts +42 -5
- package/web/board/store.ts +3 -1
- package/web/board/toast.ts +4 -1
- package/web/board/views.ts +3 -1
- package/web/board/workspace.ts +127 -38
- package/web/board/ws-board-ui.ts +95 -0
- package/web/board/ws-board.test.ts +71 -0
- package/web/board/ws-board.ts +45 -0
- package/web/board/ws-tabs.test.ts +181 -0
- package/web/board/ws-tabs.ts +173 -0
- package/web/board.html +86 -36
- package/web/board.js +129 -44
- package/web/notebook.js +41 -24
- package/web/notes.html +26 -20
- package/web/term.js +1 -1
- package/web/video.html +26 -20
- package/web/video.js +76 -59
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// The Projects "+" sheet, modelled on Orca's "Add a project": a chooser (existing folder,
|
|
2
|
+
// clone from URL, create new project, new workspace), then one form with a way back.
|
|
3
|
+
// Every call is a JSON POST to the board; the server validates paths, URLs and refs again.
|
|
4
|
+
import { html, modal } from "./dom.ts";
|
|
5
|
+
import { gitProjects, wsHref } from "./workspace.ts";
|
|
6
|
+
|
|
7
|
+
type Start = "folder" | "clone" | "create" | "ws";
|
|
8
|
+
const SEP = (p: string) => (p.includes("\\") ? "\\" : "/");
|
|
9
|
+
|
|
10
|
+
async function call(path: string, body?: object): Promise<{ ok: boolean; d: any }> {
|
|
11
|
+
try {
|
|
12
|
+
const r = await fetch(path, body ? { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) } : undefined);
|
|
13
|
+
const d = await r.json().catch(() => ({}));
|
|
14
|
+
return { ok: r.ok, d: r.ok ? d : { error: d.error || d.why || "that did not work" } };
|
|
15
|
+
} catch {
|
|
16
|
+
return { ok: false, d: { error: "the board is offline" } };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// opts.dir: the project the + was opened for (preselected in New workspace); opts.start skips the chooser.
|
|
21
|
+
export function openAdd(opts: { dir?: string | null; start?: Start } = {}) {
|
|
22
|
+
const dl = modal("");
|
|
23
|
+
const form = dl.querySelector("form")!;
|
|
24
|
+
dl.setAttribute("aria-label", "Add a project");
|
|
25
|
+
const fixed = opts.start === "ws"; // opened from a project row: no chooser to go back to
|
|
26
|
+
const field = (n: string) => form.elements.namedItem(n) as HTMLInputElement;
|
|
27
|
+
const busy = (b: HTMLButtonElement, on: boolean, say: string, idle: string) => ((b.disabled = on), (b.textContent = on ? say : idle));
|
|
28
|
+
const back = fixed ? "" : html`<button type="button" class="btn ghost" data-a="back">Back to add options</button>`;
|
|
29
|
+
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>`;
|
|
30
|
+
const say = (t: string) => ((form.querySelector(".err") as HTMLElement).textContent = t);
|
|
31
|
+
// A project was added: the sheet says so, then the board shows it (the saved project is what the pages read).
|
|
32
|
+
const landed = (stateDir: string, msg: string) => {
|
|
33
|
+
say(msg);
|
|
34
|
+
try {
|
|
35
|
+
localStorage.setItem("kz-proj", stateDir);
|
|
36
|
+
} catch {}
|
|
37
|
+
setTimeout(() => (location.href = "/?view=board"), 900);
|
|
38
|
+
};
|
|
39
|
+
// The folder dialog; with `name`, the picked folder is a parent and the project's name is appended.
|
|
40
|
+
const pick = async (into: HTMLInputElement, name?: () => string) => {
|
|
41
|
+
const p = await call("/pick-folder", {});
|
|
42
|
+
if (p.d.path) into.value = name ? p.d.path.replace(/[\\/]+$/, "") + SEP(p.d.path) + name() : p.d.path;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const draw = (v: Start | "menu") => {
|
|
46
|
+
const ws = gitProjects();
|
|
47
|
+
if (v === "menu") {
|
|
48
|
+
form.innerHTML = html`<b>Add a project</b><small class="att">Add a project to get started with kaizen.</small><button type="button" class="btn opt" data-go="folder"><b>Existing folder</b><small>A project, a Git repo, or any folder</small></button><small class="att">Other ways to add</small><button type="button" class="btn opt" data-go="clone"><b>Clone from URL</b><small>Clone a remote Git repository</small></button><button type="button" class="btn opt" data-go="create"><b>Create new project</b><small>Start from an empty folder</small></button>${ws.length ? html`<button type="button" class="btn opt" data-go="ws"><b>New workspace</b><small>A branch in its own folder, in a project you have</small></button>` : ""}<div class="row"><button type="button" class="btn ghost" data-a="x">Cancel</button></div>`.toString();
|
|
49
|
+
form.querySelectorAll<HTMLElement>("[data-go]").forEach((b) => (b.onclick = () => draw(b.dataset.go as Start)));
|
|
50
|
+
form.onsubmit = (e) => e.preventDefault();
|
|
51
|
+
} else if (v === "folder") {
|
|
52
|
+
form.innerHTML = html`<b>Existing folder</b><small class="att">Pick a folder, or type its path. A .kaizen folder is added to it.</small><div class="row"><input name="path" placeholder="/path/to/folder" aria-label="Folder" autocomplete="off" spellcheck="false" required><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${foot("Add project")}`.toString();
|
|
53
|
+
field("path").focus();
|
|
54
|
+
form.onsubmit = async (e) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
const b = form.querySelector<HTMLButtonElement>("[data-a=go]")!;
|
|
57
|
+
busy(b, true, "Adding...", "Add project");
|
|
58
|
+
const r = await call("/add-project", { path: field("path").value.trim() });
|
|
59
|
+
busy(b, false, "", "Add project");
|
|
60
|
+
r.ok ? landed(r.d.dir, r.d.already ? "Project already added" : "Project added") : say(r.d.error);
|
|
61
|
+
};
|
|
62
|
+
form.querySelector<HTMLElement>("[data-a=pick]")!.onclick = () => pick(field("path"));
|
|
63
|
+
} else if (v === "clone") {
|
|
64
|
+
form.innerHTML = html`<b>Clone from URL</b><small class="att">Enter the Git URL (https or ssh) and choose where to clone it.</small><input name="url" placeholder="https://github.com/user/repo.git" aria-label="Git URL" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to clone into" aria-label="Clone into" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${foot("Clone")}`.toString();
|
|
65
|
+
field("url").focus();
|
|
66
|
+
let name = "", auto = ""; // the folder this form filled in; one the user typed is left alone
|
|
67
|
+
const check = async () => {
|
|
68
|
+
const u = field("url").value.trim();
|
|
69
|
+
if (!u) return false;
|
|
70
|
+
const r = await call("/clone", { url: u, check: true });
|
|
71
|
+
if (!r.ok) return say(r.d.error), false;
|
|
72
|
+
say("");
|
|
73
|
+
name = r.d.name;
|
|
74
|
+
if (!field("to").value.trim() || field("to").value === auto) field("to").value = auto = r.d.to;
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
field("url").onchange = check;
|
|
78
|
+
form.querySelector<HTMLElement>("[data-a=pick]")!.onclick = async () => ((await check()) ? pick(field("to"), () => name) : field("url").focus());
|
|
79
|
+
form.onsubmit = async (e) => {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
if (!(await check())) return;
|
|
82
|
+
const b = form.querySelector<HTMLButtonElement>("[data-a=go]")!;
|
|
83
|
+
busy(b, true, "Cloning...", "Clone");
|
|
84
|
+
const r = await call("/clone", { url: field("url").value.trim(), to: field("to").value.trim() || undefined });
|
|
85
|
+
busy(b, false, "", "Clone");
|
|
86
|
+
r.ok ? landed(r.d.dir, "Cloned") : say(r.d.error);
|
|
87
|
+
};
|
|
88
|
+
} else if (v === "create") {
|
|
89
|
+
form.innerHTML = html`<b>Create a new project</b><small class="att">Name it and kaizen will create the folder with a .kaizen inside.</small><input name="name" placeholder="my-project" aria-label="Name" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to create" aria-label="Create in" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div><label class="att"><input type="checkbox" name="git" checked> Git repository</label>${foot("Create project")}`.toString();
|
|
90
|
+
field("name").focus();
|
|
91
|
+
let auto = "";
|
|
92
|
+
field("name").oninput = async () => {
|
|
93
|
+
const n = field("name").value.trim();
|
|
94
|
+
if (!n || /[\\/:*?"<>|]/.test(n) || (field("to").value.trim() && field("to").value !== auto)) return;
|
|
95
|
+
const r = await call("/new-project", { name: n, check: true });
|
|
96
|
+
if (r.ok && field("name").value.trim() === n) field("to").value = auto = r.d.to;
|
|
97
|
+
};
|
|
98
|
+
form.querySelector<HTMLElement>("[data-a=pick]")!.onclick = () => pick(field("to"), () => field("name").value.trim());
|
|
99
|
+
form.onsubmit = async (e) => {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
const b = form.querySelector<HTMLButtonElement>("[data-a=go]")!;
|
|
102
|
+
busy(b, true, "Creating...", "Create project");
|
|
103
|
+
const r = await call("/new-project", { name: field("name").value.trim(), to: field("to").value.trim() || undefined, git: field("git").checked });
|
|
104
|
+
busy(b, false, "", "Create project");
|
|
105
|
+
if (!r.ok) return say(r.d.error);
|
|
106
|
+
landed(r.d.dir, r.d.git === false ? "Project created, but git init failed" : "Project created");
|
|
107
|
+
};
|
|
108
|
+
} else {
|
|
109
|
+
// New workspace: a project (git ones), a branch name and the branch it starts from.
|
|
110
|
+
const cur = ws.some((p) => p.dir === opts.dir) ? opts.dir : ws[0]?.dir;
|
|
111
|
+
form.innerHTML = html`<b>New workspace</b><small class="att">A new branch in its own folder under .kaizen/wt/.</small><label class="att">Project<select name="project" aria-label="Project">${ws.map((p) => html`<option value="${p.dir}"${p.dir === cur ? " selected" : ""}>${p.name}</option>`)}</select></label><label class="att">Branch name<input name="branch" placeholder="feature/my-branch" aria-label="Branch name" autocomplete="off" spellcheck="false" required></label><label class="att">Base branch<select name="base" aria-label="Base branch"></select></label>${foot("Create workspace")}`.toString();
|
|
112
|
+
field("branch").focus();
|
|
113
|
+
const sel = form.elements.namedItem("base") as HTMLSelectElement;
|
|
114
|
+
const bases = async () => {
|
|
115
|
+
const r = await call("/branches?dir=" + encodeURIComponent(field("project").value));
|
|
116
|
+
const { def = "", branches = [] } = r.ok ? r.d : {};
|
|
117
|
+
sel.innerHTML = (branches as string[]).map((b) => html`<option${b === def ? " selected" : ""}>${b}</option>`.toString()).join("") || `<option value="">current branch</option>`;
|
|
118
|
+
};
|
|
119
|
+
(form.elements.namedItem("project") as HTMLSelectElement).onchange = bases;
|
|
120
|
+
bases();
|
|
121
|
+
form.onsubmit = async (e) => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
const dir = field("project").value;
|
|
124
|
+
const b = form.querySelector<HTMLButtonElement>("[data-a=go]")!;
|
|
125
|
+
busy(b, true, "Creating...", "Create workspace");
|
|
126
|
+
const r = await call("/worktree", { dir, branch: field("branch").value.trim(), base: sel.value || undefined });
|
|
127
|
+
busy(b, false, "", "Create workspace");
|
|
128
|
+
r.ok ? (dl.close(), (location.href = wsHref(dir, r.d.path))) : say(r.d.error);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
form.querySelector<HTMLElement>("[data-a=x]")!.onclick = () => dl.close();
|
|
132
|
+
const bk = form.querySelector<HTMLElement>("[data-a=back]");
|
|
133
|
+
if (bk) bk.onclick = () => draw("menu");
|
|
134
|
+
};
|
|
135
|
+
draw(opts.start ?? "menu");
|
|
136
|
+
}
|
package/web/board/api.ts
CHANGED
|
@@ -95,7 +95,7 @@ export async function load(quiet) {
|
|
|
95
95
|
if (was && was.kind === "idea") follow(was);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
if (store.runDoc) openRun(c, true, true);
|
|
98
|
+
if (store.runDoc && c.kind === "run") openRun(c, true, true);
|
|
99
99
|
else if (c.kind === "idea") ideaBody(c);
|
|
100
100
|
}
|
|
101
101
|
}
|
package/web/board/badge.ts
CHANGED
|
@@ -5,12 +5,12 @@ export function waitingCount(cards: BadgeCard[]) {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
// The rail's Projects list draws from the same cards: one fetch feeds both.
|
|
8
|
-
let onCards: ((cards: any[], projects?: any[]) => void) | null = null;
|
|
8
|
+
let onCards: ((cards: any[], projects?: any[], agents?: any[]) => void) | null = null;
|
|
9
9
|
export const onBoardCards = (f: typeof onCards) => { onCards = f; };
|
|
10
10
|
|
|
11
|
-
export function boardBadge(cards: BadgeCard[], projects?: unknown[]) {
|
|
11
|
+
export function boardBadge(cards: BadgeCard[], projects?: unknown[], agents?: unknown[]) {
|
|
12
12
|
generation++;
|
|
13
|
-
onCards?.(cards, projects);
|
|
13
|
+
onCards?.(cards, projects, agents);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
let generation = 0;
|
|
@@ -25,8 +25,8 @@ export async function refreshBoardBadge() {
|
|
|
25
25
|
try {
|
|
26
26
|
const r = await fetch("/state?all=1");
|
|
27
27
|
if (!r.ok) continue;
|
|
28
|
-
const { cards, projects } = await r.json();
|
|
29
|
-
if (!again && current === generation) boardBadge(cards, projects);
|
|
28
|
+
const { cards, projects, rail, agents } = await r.json();
|
|
29
|
+
if (!again && current === generation) boardBadge(cards, [...projects, ...(rail ?? [])], agents);
|
|
30
30
|
} catch { /* keep the last count while the board is offline */ }
|
|
31
31
|
} while (again);
|
|
32
32
|
loading = false;
|
package/web/board/cards.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { answer, decided, resumable, resume } from "./approvals.ts";
|
|
|
13
13
|
import { termsBadge } from "./terms.ts";
|
|
14
14
|
import { boardBadge, waitingCount } from "./badge.ts";
|
|
15
15
|
import { openWorkspace } from "./run-view.ts";
|
|
16
|
+
import { boardMode, drawWsBoard, initWsBoard, syncMode } from "./ws-board-ui.ts";
|
|
16
17
|
|
|
17
18
|
let filter = null;
|
|
18
19
|
let query = ""; // the header filter box, matched against a card's title and request
|
|
@@ -86,6 +87,8 @@ const actionOf = (c) =>
|
|
|
86
87
|
? "Sent to agent"
|
|
87
88
|
: c.status !== "waiting"
|
|
88
89
|
? "Open"
|
|
90
|
+
: c.healed
|
|
91
|
+
? "Approve"
|
|
89
92
|
: { "approvals.plan": "Review plan", findings: "See findings", "approvals.review": "Review work" }[c.awaiting] || "Open";
|
|
90
93
|
|
|
91
94
|
function card(c) {
|
|
@@ -675,6 +678,7 @@ export function render() {
|
|
|
675
678
|
const fk = focusedKey();
|
|
676
679
|
// All projects: only the ones ticked in the filter, or every one when none is.
|
|
677
680
|
const only = store.all && store.shown.size && showable().some((p) => store.shown.has(p.dir));
|
|
681
|
+
syncMode();
|
|
678
682
|
const cs = store.S.cards.filter((c) => c.archived === archive && (!only || store.shown.has(c.state))),
|
|
679
683
|
b = $("board");
|
|
680
684
|
b.innerHTML = "";
|
|
@@ -738,14 +742,17 @@ export function render() {
|
|
|
738
742
|
ns = sp.filter((p) => store.shown.has(p.dir)).length;
|
|
739
743
|
$("show").textContent = ns ? `Showing ${ns} of ${sp.length}` : "Showing all";
|
|
740
744
|
if (!$("showpop").hidden) showList();
|
|
741
|
-
|
|
745
|
+
// Workspaces mode: the same page, a different body.
|
|
746
|
+
const wsm = boardMode() === "ws";
|
|
747
|
+
if (wsm) drawWsBoard((dir) => (!only || store.shown.has(dir)) && (store.all || !store.S.dir || dir === store.S.dir));
|
|
748
|
+
if (!wsm && !cs.length && store.mode !== "new") {
|
|
742
749
|
b.innerHTML = archive
|
|
743
750
|
? '<div class="empty"><div class="mascot"></div><b>Nothing archived</b></div>'
|
|
744
751
|
: '<div class="empty"><div class="mascot"></div><b>Nothing here yet</b><p>Add an idea and kaizen will plan it, build it, and check the result.</p><button class="btn pri" id="newempty">New idea</button></div>';
|
|
745
752
|
if (!archive)
|
|
746
753
|
$("newempty").onclick = newIdea;
|
|
747
754
|
}
|
|
748
|
-
COLS.forEach((name, ci) => {
|
|
755
|
+
(wsm ? [] : COLS).forEach((name, ci) => {
|
|
749
756
|
const s = document.createElement("section");
|
|
750
757
|
const q = query.trim().toLowerCase();
|
|
751
758
|
const bl = ci === 0 && !archive && ideasTab === "backlog";
|
|
@@ -946,7 +953,7 @@ export function render() {
|
|
|
946
953
|
// The tab says how many runs wait on you, or agents wait on input, so a background tab still tells you.
|
|
947
954
|
const nw = waitingCount(store.S.cards);
|
|
948
955
|
document.title = nw ? `(${nw}) kaizen` : "kaizen";
|
|
949
|
-
if (store.all) boardBadge(store.S.cards, store.S.projects);
|
|
956
|
+
if (store.all) boardBadge(store.S.cards, [...store.S.projects, ...(store.S.rail ?? [])], store.S.agents);
|
|
950
957
|
termsBadge();
|
|
951
958
|
stopDictation(false); // forms were just rebuilt; a listener whose field is gone would write into nothing
|
|
952
959
|
if (fk && document.activeElement === document.body) cardEl(fk)?.focus({ preventScroll: true });
|
|
@@ -960,6 +967,7 @@ export function filterBox() {
|
|
|
960
967
|
query = el.value;
|
|
961
968
|
render();
|
|
962
969
|
});
|
|
970
|
+
initWsBoard(render);
|
|
963
971
|
el.addEventListener("keydown", (e) => {
|
|
964
972
|
if (e.key === "Escape") {
|
|
965
973
|
e.stopPropagation();
|
package/web/board/context.ts
CHANGED
package/web/board/fixes.ts
CHANGED
|
@@ -35,7 +35,7 @@ export function fixForm(c) {
|
|
|
35
35
|
return;
|
|
36
36
|
const el = document.createElement("div");
|
|
37
37
|
el.className = "inl fix";
|
|
38
|
-
el.innerHTML = html`<div class="q">Fix findings</div><div class="q dim">Opens your agent in this project, told to fix the ticked findings and recheck them.</div>${c.status === "waiting" ? html`<div class="q dim">
|
|
38
|
+
el.innerHTML = html`<div class="q">Fix findings</div><div class="q dim">Opens your agent in this project, told to fix the ticked findings and recheck them.</div>${c.status === "waiting" ? html`<div class="q dim">An agent is already open on this run; the fix is sent to it when it runs in its card, else another one opens.</div>` : ""}${
|
|
39
39
|
fs
|
|
40
40
|
.map((f) => {
|
|
41
41
|
const x = f.done ? " (closed)" : sent(f) ? " (sent)" : "";
|
|
@@ -73,7 +73,8 @@ export function fixForm(c) {
|
|
|
73
73
|
// Sent findings lock as sent, so a second press cannot open a second agent on them.
|
|
74
74
|
if (r.ok) {
|
|
75
75
|
toast(
|
|
76
|
-
"Fixing " + nums.length + " finding" + (nums.length === 1 ? "" : "s") + ", " +
|
|
76
|
+
"Fixing " + nums.length + " finding" + (nums.length === 1 ? "" : "s") + ", " +
|
|
77
|
+
(r.reused ? "sent to the agent already open in its card" : where(r) + ": " + via(r.agent)),
|
|
77
78
|
);
|
|
78
79
|
if (r.pty) store.wantTerm = key(c);
|
|
79
80
|
nums.forEach((n) => fixSent.add(k(n)));
|