kaizen-agent 1.87.1 → 1.87.3
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/browser.ts +21 -0
- package/cli/chat.ts +53 -3
- package/cli/chatgpt.ts +1 -1
- package/cli/conpty.ts +7 -4
- package/cli/dashboard.ts +1 -1
- package/cli/models.ts +94 -0
- package/cli/pty.ts +5 -1
- package/cli/sources.ts +84 -20
- package/cli/state.ts +2 -2
- package/cli/task-service.ts +2 -0
- package/cli/web.ts +53 -9
- package/cli/whatsapp-bridge.ts +14 -2
- package/package.json +1 -1
- package/web/components/home/home-window.tsx +0 -36
- package/web/components/icebox/capture-box.tsx +11 -2
- package/web/components/icebox/request-card.tsx +33 -11
- package/web/components/rail/rail-list.tsx +43 -1
- package/web/components/settings/setting-row.tsx +8 -5
- package/web/components/settings/settings-section.tsx +5 -3
- package/web/components/shared/picker.tsx +21 -1
- package/web/dist/annotate.js +1 -1
- package/web/dist/board.css +5 -10
- package/web/dist/board.js +57 -55
- package/web/dist/boot.js +1 -1
- package/web/dist/notebook.css +2 -2
- package/web/dist/notebook.js +34 -34
- package/web/dist/popup.css +1 -1
- package/web/dist/popup.js +1 -1
- package/web/dist/term.js +1 -1
- package/web/dist/ui.css +2 -2
- package/web/dist/video.js +1 -1
- package/web/lib/icebox/icebox-actions.ts +24 -2
- package/web/lib/icebox/icebox-store.ts +7 -1
- package/web/lib/icebox/icebox-view.ts +3 -2
- package/web/lib/icebox/icebox.ts +24 -4
- package/web/lib/icebox/use-ice-keys.ts +5 -0
- package/web/lib/rail/rules.ts +4 -1
- package/web/lib/settings/index.ts +1 -0
- package/web/lib/settings/settings-actions.ts +8 -0
- package/web/lib/settings/settings.ts +0 -3
- package/web/lib/settings/use-model-choices.ts +31 -0
- package/web/pages/board/App.tsx +1 -9
- package/web/pages/icebox-page.tsx +173 -125
- package/web/ui/legacy/board.css +3 -8
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// toasts, and how the cursor, the selection and the open item move with them. Components call these; nothing here
|
|
3
3
|
// draws. Routes and payloads are the old page's, unchanged.
|
|
4
4
|
import { post, host, toast, toastUndo } from "@lib/core";
|
|
5
|
-
import { gatherLine, hostOf, iceKey, snoozedLine, stepPast, type IceItem, type Source, PLAT } from "./icebox.ts";
|
|
5
|
+
import { gatherLine, hostOf, iceKey, sameName, snoozedLine, stepPast, type IceItem, type Source, PLAT } from "./icebox.ts";
|
|
6
6
|
import { getIce, patchCap, setIce, type Ask, type Capture } from "./icebox-store.ts";
|
|
7
7
|
import { refreshIce } from "./use-icebox.ts";
|
|
8
8
|
|
|
@@ -369,14 +369,36 @@ export async function newCollection(to: string | null, where: string) {
|
|
|
369
369
|
// The capture picker's "New collection…": a client's one is made first, then it is the box's board.
|
|
370
370
|
export async function pickCaptureBoard(v: string, to: string | null) {
|
|
371
371
|
if (v === "\n") {
|
|
372
|
+
if (!to) return (toast("Pick a project first"), false);
|
|
372
373
|
const a = await askCollection();
|
|
373
374
|
if (!a) return false;
|
|
374
|
-
|
|
375
|
+
const j = await post("/icebox", { op: "boards", act: "add", dir: to, name: a.name, client: a.client });
|
|
376
|
+
if (!j.ok) return (toast(j.error || "Could not make the collection"), false);
|
|
377
|
+
toast(`Collection ${a.name} made`);
|
|
378
|
+
await refreshIce();
|
|
375
379
|
v = a.name;
|
|
376
380
|
}
|
|
377
381
|
patchCap({ board: v, boardDir: to });
|
|
378
382
|
return true;
|
|
379
383
|
}
|
|
384
|
+
// Remove a collection after asking; its items go back to the Inbox. A box or a filter on it falls back to the Inbox.
|
|
385
|
+
export async function removeCollection(dir: string, name: string, items: number) {
|
|
386
|
+
const ok = await askConfirm(
|
|
387
|
+
`Remove ${name}?`,
|
|
388
|
+
items ? `Its ${items} ${items === 1 ? "item goes" : "items go"} to the Inbox.` : "It has no items.",
|
|
389
|
+
"Remove",
|
|
390
|
+
true,
|
|
391
|
+
);
|
|
392
|
+
if (!ok) return;
|
|
393
|
+
const j = await post("/icebox", { op: "boards", act: "remove", dir, name });
|
|
394
|
+
if (!j.ok) return toast(j.error || "Could not remove the collection");
|
|
395
|
+
const s = getIce();
|
|
396
|
+
if (sameName(s.cap.board, name)) patchCap({ board: "", boardDir: null });
|
|
397
|
+
if (sameName(s.board, name)) setIce({ board: "" });
|
|
398
|
+
toast(`Collection ${name} removed`);
|
|
399
|
+
host.reload();
|
|
400
|
+
await refreshIce();
|
|
401
|
+
}
|
|
380
402
|
|
|
381
403
|
// ---- sources
|
|
382
404
|
// One change to a source, then what changed is shown.
|
|
@@ -46,6 +46,7 @@ export type IceState = {
|
|
|
46
46
|
view: "cards" | "sort";
|
|
47
47
|
board: string;
|
|
48
48
|
kinds: string[];
|
|
49
|
+
q: string; // the search box: every word must be in an item's words, link, tags or collection
|
|
49
50
|
cat: string;
|
|
50
51
|
src: string;
|
|
51
52
|
sel: string[]; // checked items, "<dir> <id>"
|
|
@@ -81,6 +82,7 @@ export const useIce = create<IceState>()(() => ({
|
|
|
81
82
|
view: saved("kz-ice-view") === "sort" ? "sort" : "cards",
|
|
82
83
|
board: "",
|
|
83
84
|
kinds: [],
|
|
85
|
+
q: "",
|
|
84
86
|
cat: "",
|
|
85
87
|
src: "",
|
|
86
88
|
sel: [],
|
|
@@ -106,7 +108,11 @@ export const useIce = create<IceState>()(() => ({
|
|
|
106
108
|
export const getIce = useIce.getState;
|
|
107
109
|
// Two elements the page reaches from outside their component, set as refs by the component that draws them: the swipe card the
|
|
108
110
|
// arrows and buttons fly away, and the Sources button the drawer gives focus back to.
|
|
109
|
-
export const iceEls: { swCard: HTMLElement | null; srcTog: HTMLElement | null
|
|
111
|
+
export const iceEls: { swCard: HTMLElement | null; srcTog: HTMLElement | null; search: HTMLInputElement | null } = {
|
|
112
|
+
swCard: null,
|
|
113
|
+
srcTog: null,
|
|
114
|
+
search: null, // the search box, which `/` focuses
|
|
115
|
+
};
|
|
110
116
|
export const setIce = useIce.setState;
|
|
111
117
|
export const patchCap = (p: Partial<Capture>) => setIce((s) => ({ cap: { ...s.cap, ...p } }));
|
|
112
118
|
export const patchDraft = (p: Partial<SourceDraft>) => setIce((s) => ({ draft: { ...s.draft, ...p } }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// How the Icebox page moves around: what a click on a row, a card, a chip or a bulk bar changes in the page's own
|
|
2
2
|
// state (open item, cursor, checked items, filters). No requests are made here (those are icebox-actions.ts).
|
|
3
3
|
import { clearShown } from "@lib/project";
|
|
4
|
-
import { iceKey, sameName, type Board, type IceItem } from "./icebox.ts";
|
|
4
|
+
import { iceKey, INBOX, sameName, type Board, type IceItem } from "./icebox.ts";
|
|
5
5
|
import { patchCap, setIce } from "./icebox-store.ts";
|
|
6
6
|
|
|
7
7
|
const focusTitle = (k: string) =>
|
|
@@ -36,6 +36,7 @@ export function openCard(it: IceItem) {
|
|
|
36
36
|
// A board chip filters, and the capture box follows it: its board and, in All projects, that board's project.
|
|
37
37
|
export function pickBoard(name: string, boards: Board[], single: boolean) {
|
|
38
38
|
setIce({ board: name });
|
|
39
|
+
if (name === INBOX) return patchCap({ board: "", boardDir: null });
|
|
39
40
|
const b = name && boards.find((x) => sameName(x.name, name));
|
|
40
41
|
if (b) patchCap({ board: b.name, boardDir: b.dir, ...(single ? {} : { dir: b.dir }) });
|
|
41
42
|
}
|
|
@@ -43,6 +44,6 @@ export const toggleKind = (kind: string) =>
|
|
|
43
44
|
setIce((s) => ({ kinds: s.kinds.includes(kind) ? s.kinds.filter((k) => k !== kind) : [...s.kinds, kind] }));
|
|
44
45
|
// "Clear filters": category, source, collection, kinds, and the board's "Showing" picker in All projects.
|
|
45
46
|
export function clearFilters(single: boolean) {
|
|
46
|
-
setIce({ cat: "", src: "", board: "", kinds: [] });
|
|
47
|
+
setIce({ cat: "", src: "", board: "", kinds: [], q: "" });
|
|
47
48
|
if (!single) clearShown();
|
|
48
49
|
}
|
package/web/lib/icebox/icebox.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type IceItem = {
|
|
|
17
17
|
board?: string;
|
|
18
18
|
tags?: string[];
|
|
19
19
|
images?: string[];
|
|
20
|
-
link?: { url: string; title?: string; summary?: string };
|
|
20
|
+
link?: { url: string; title?: string; summary?: string; image?: string };
|
|
21
21
|
post?: string | null;
|
|
22
22
|
replied?: string;
|
|
23
23
|
written?: string;
|
|
@@ -137,7 +137,22 @@ export function faviconUrl(u: string): string {
|
|
|
137
137
|
: origin + "/favicon.ico";
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
// A link's preview picture: the one read when it was saved, else Reddit's own for a post (links saved before pictures
|
|
141
|
+
// were read have none). Https only. Same address as redditPost() in cli/sources.ts.
|
|
142
|
+
export function linkImage(l: { url: string; image?: string }): string {
|
|
143
|
+
if (l.image && /^https:\/\//i.test(l.image)) return l.image;
|
|
144
|
+
const m = /^https:\/\/(?:(?:www|old|new|m)\.)?reddit\.com\/r\/[\w-]+\/comments\/([a-z0-9]+)/i.exec(l.url);
|
|
145
|
+
return m ? `https://share.redd.it/preview/post/${m[1]!.toLowerCase()}` : "";
|
|
146
|
+
}
|
|
147
|
+
// What the search box looks in: the words, notes, link, tags, collection and project, lowercased.
|
|
148
|
+
export const searchText = (it: IceItem) =>
|
|
149
|
+
[it.text, it.notes, it.link?.url, it.link?.title, it.link?.summary, ...(it.tags ?? []).map((t) => "#" + t), it.board, it.project]
|
|
150
|
+
.filter(Boolean)
|
|
151
|
+
.join("\n")
|
|
152
|
+
.toLowerCase();
|
|
153
|
+
// The Inbox chip's filter: items in no collection. A newline, so no collection name (one line) can equal it.
|
|
154
|
+
export const INBOX = "\ninbox";
|
|
155
|
+
export type Filters = { board: string; kinds: string[]; cat: string; src: string; q?: string };
|
|
141
156
|
export type Env = {
|
|
142
157
|
dir: string | null; // the one project the board shows, or null in All projects
|
|
143
158
|
shown: ReadonlySet<string>; // the "Showing" picker's projects; empty shows every one
|
|
@@ -157,6 +172,7 @@ export type Derived = {
|
|
|
157
172
|
src: string;
|
|
158
173
|
inProj: (it: IceItem) => boolean;
|
|
159
174
|
nOn: (b: Board) => number;
|
|
175
|
+
nInbox: number; // waiting items in no collection
|
|
160
176
|
};
|
|
161
177
|
const count = (xs: IceItem[], f: (it: IceItem) => string) => {
|
|
162
178
|
const m = new Map<string, { it: IceItem; n: number }>();
|
|
@@ -180,8 +196,8 @@ export function deriveIce(d: IceData, f: Filters, env: Env): Derived {
|
|
|
180
196
|
pv = ice.filter(inProj);
|
|
181
197
|
// A board is its name: two projects' boards of one name are one chip in All projects.
|
|
182
198
|
const boards = [...new Map((d.boards || []).filter(inProj).map((b) => [b.name.toLowerCase(), b])).values()];
|
|
183
|
-
const board = f.board && boards.some((b) => sameName(b.name, f.board)) ? f.board : "";
|
|
184
|
-
const onBoard = (it: IceItem) => !board || sameName(it.board, board),
|
|
199
|
+
const board = f.board === INBOX || (f.board && boards.some((b) => sameName(b.name, f.board))) ? f.board : "";
|
|
200
|
+
const onBoard = (it: IceItem) => !board || (board === INBOX ? !it.board : sameName(it.board, board)),
|
|
185
201
|
ofKind = (it: IceItem) => !f.kinds.length || f.kinds.includes(it.kind || ""),
|
|
186
202
|
base = pv.filter((it) => onBoard(it) && ofKind(it));
|
|
187
203
|
const byCat = count(base, (it) => catOf(list, it)),
|
|
@@ -189,10 +205,13 @@ export function deriveIce(d: IceData, f: Filters, env: Env): Derived {
|
|
|
189
205
|
const cv = base.filter((it) => !cat || catOf(list, it) === cat),
|
|
190
206
|
bySrc = count(cv, srcKey),
|
|
191
207
|
src = f.src && bySrc.has(f.src) ? f.src : "";
|
|
208
|
+
const words = (f.q ?? "").toLowerCase().split(/\s+/).filter(Boolean),
|
|
209
|
+
found = (it: IceItem) => !words.length || words.every((w) => searchText(it).includes(w));
|
|
192
210
|
const filtered = ice
|
|
193
211
|
.filter(
|
|
194
212
|
(it) =>
|
|
195
213
|
inProj(it) &&
|
|
214
|
+
found(it) &&
|
|
196
215
|
onBoard(it) &&
|
|
197
216
|
ofKind(it) &&
|
|
198
217
|
(cat ? catOf(list, it) === cat : it.status === "new") &&
|
|
@@ -213,6 +232,7 @@ export function deriveIce(d: IceData, f: Filters, env: Env): Derived {
|
|
|
213
232
|
src,
|
|
214
233
|
inProj,
|
|
215
234
|
nOn: (b) => pv.filter((it) => isWaiting(it) && sameName(it.board, b.name)).length,
|
|
235
|
+
nInbox: pv.filter((it) => isWaiting(it) && !it.board).length,
|
|
216
236
|
};
|
|
217
237
|
}
|
|
218
238
|
// Sources group by platform: two Threads searches sit under one Threads.
|
|
@@ -33,6 +33,11 @@ export function iceKeys(e: KeyboardEvent): boolean {
|
|
|
33
33
|
void f();
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
|
+
if (k === "/" && iceEls.search) {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
iceEls.search.focus();
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
36
41
|
if (k === "Escape") {
|
|
37
42
|
if (s.open) setIce(s.armed ? { armed: null } : { open: null });
|
|
38
43
|
else if (s.sel.length) setIce({ sel: [] });
|
package/web/lib/rail/rules.ts
CHANGED
|
@@ -95,6 +95,7 @@ export type RailGroup = {
|
|
|
95
95
|
mainWs: string;
|
|
96
96
|
shut: boolean;
|
|
97
97
|
empty: boolean;
|
|
98
|
+
home: boolean; // Home: your own space outside any project (the global queue and the Home terminals)
|
|
98
99
|
rows: RailRow[];
|
|
99
100
|
};
|
|
100
101
|
export const pinKey = (dir: string, ws: string) => dir + "\0" + ws;
|
|
@@ -109,7 +110,8 @@ export function railGroups(
|
|
|
109
110
|
folded = new Set(o.folded),
|
|
110
111
|
tasks = d.tasks,
|
|
111
112
|
wsOf = (c) => wsOfCard(c, d.projects);
|
|
112
|
-
|
|
113
|
+
// Home (the global queue, `home`) heads the list; the rest keep the registry's order (stable sort).
|
|
114
|
+
const projects = d.projects.filter((p) => p.workspaces?.length).sort((a, b) => +!!b.home - +!!a.home);
|
|
113
115
|
// Cards by project and workspace: each lands on a row, the main checkout when its own is not listed.
|
|
114
116
|
const by = new Map<string, any[]>();
|
|
115
117
|
const shownAgents = (rs: ARow[]) => rs.filter((r) => (r.st === "done" ? filt.done : filt.running));
|
|
@@ -152,6 +154,7 @@ export function railGroups(
|
|
|
152
154
|
// A project with nothing to list stays as a collapsed header.
|
|
153
155
|
shut: folded.has(dir) || !rows.length,
|
|
154
156
|
empty: !rows.length,
|
|
157
|
+
home: !!p.home,
|
|
155
158
|
rows: rows.map(({ w, cs, ags }): RailRow => {
|
|
156
159
|
const st0 = cs.length ? st([...cs].sort((a, b) => RANK[st(a)] - RANK[st(b)])[0]) : "";
|
|
157
160
|
return {
|
|
@@ -100,6 +100,14 @@ export async function accountRemove(id: string, name: string) {
|
|
|
100
100
|
return accountSend({ op: "remove", id, deleteFolder });
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
// Re-check and Refresh: read the page again and say so, because when nothing changed the page looks the same.
|
|
104
|
+
export async function recheck(id: string, done: string) {
|
|
105
|
+
if (getSettings().busy === id) return;
|
|
106
|
+
setSettings({ busy: id });
|
|
107
|
+
await loadSettings();
|
|
108
|
+
setSettings({ busy: "" });
|
|
109
|
+
toast(done);
|
|
110
|
+
}
|
|
103
111
|
// ---- Skills (/skills, /rea)
|
|
104
112
|
const WARN: Record<string, string> = {
|
|
105
113
|
"kaizen-computer":
|
|
@@ -169,9 +169,6 @@ export function controlOf(r: Pick<Row, "key" | "values" | "text" | "folder">): C
|
|
|
169
169
|
return "stepper";
|
|
170
170
|
}
|
|
171
171
|
export const settingId = (key: string) => "s-" + key.replace(/\./g, "-");
|
|
172
|
-
// Names worth suggesting, per tool, from the tool's own docs; typing any other name stays allowed.
|
|
173
|
-
// ponytail: claude only, add another tool's names when its own CLI help lists them.
|
|
174
|
-
export const MODEL_SUGGEST: Record<string, string[]> = { claude: ["haiku", "sonnet", "opus"] };
|
|
175
172
|
export const modelTool = (key: string) => key.split(".").pop()!;
|
|
176
173
|
export const modelName = (label: string) => label.replace(/^(Worker|Handoff) model: /, "");
|
|
177
174
|
// A row's help line: its own help, then why it is idle.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export type ModelChoice = { id: string; name: string };
|
|
4
|
+
|
|
5
|
+
// The models one agent tool offers, read by the board's server from the tool itself (`GET /models`). One request per
|
|
6
|
+
// tool per page: the rows of a tool share it. A failed read gives [] and the field stays a free text.
|
|
7
|
+
const asked = new Map<string, Promise<ModelChoice[]>>();
|
|
8
|
+
const ask = (tool: string) => {
|
|
9
|
+
let p = asked.get(tool);
|
|
10
|
+
if (!p) {
|
|
11
|
+
p = fetch("/models?agent=" + encodeURIComponent(tool))
|
|
12
|
+
.then((r) => (r.ok ? r.json() : { models: [] }))
|
|
13
|
+
.then((j) => (Array.isArray(j.models) ? (j.models as ModelChoice[]) : []))
|
|
14
|
+
.catch(() => []);
|
|
15
|
+
asked.set(tool, p);
|
|
16
|
+
}
|
|
17
|
+
return p;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function useModelChoices(tool: string, on: boolean): ModelChoice[] {
|
|
21
|
+
const [rows, setRows] = useState<ModelChoice[]>([]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!on) return;
|
|
24
|
+
let live = true;
|
|
25
|
+
void ask(tool).then((r) => live && setRows(r));
|
|
26
|
+
return () => {
|
|
27
|
+
live = false;
|
|
28
|
+
};
|
|
29
|
+
}, [tool, on]);
|
|
30
|
+
return rows;
|
|
31
|
+
}
|
package/web/pages/board/App.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import { useBoard } from "@lib/board";
|
|
|
5
5
|
import { useRunView } from "@lib/run";
|
|
6
6
|
import { checkUpdate } from "@lib/settings";
|
|
7
7
|
import { SourceMarks } from "@components/rail";
|
|
8
|
-
import { HomeWsRow } from "@components/home";
|
|
9
8
|
import { Rail, Sprite } from "@components/shell";
|
|
10
9
|
import { FootBar } from "@components/footer";
|
|
11
10
|
import { ContextPanel } from "@components/context";
|
|
@@ -50,14 +49,7 @@ export function App() {
|
|
|
50
49
|
return (
|
|
51
50
|
<TooltipProvider>
|
|
52
51
|
<Sprite />
|
|
53
|
-
<Rail
|
|
54
|
-
srcs={<SourceMarks />}
|
|
55
|
-
before={
|
|
56
|
-
<div style={{ display: "contents" }}>
|
|
57
|
-
<HomeWsRow />
|
|
58
|
-
</div>
|
|
59
|
-
}
|
|
60
|
-
/>
|
|
52
|
+
<Rail srcs={<SourceMarks />} />
|
|
61
53
|
<div className="app">
|
|
62
54
|
<Header />
|
|
63
55
|
<Pages />
|