kaizen-agent 1.52.0 → 1.53.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/README.md +4 -4
- package/cli/chat-window.py +37 -0
- package/cli/chat.test.ts +38 -5
- package/cli/chat.ts +56 -13
- package/cli/install.ts +76 -1
- package/cli/settings.ts +25 -0
- package/cli/state.ts +1 -1
- package/cli/web.ts +71 -2
- package/package.json +1 -1
- package/skills/kaizen/config.default.yml +4 -0
- package/web/board/home.ts +18 -2
- package/web/board.html +3 -1
- package/web/board.js +18 -18
- package/web/notebook.js +1 -1
- package/web/popup.html +141 -0
- package/web/term.js +1 -1
- package/web/video.js +1 -1
package/README.md
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
<a href="https://www.npmjs.com/package/kaizen-agent"><img alt="npm" src="https://img.shields.io/npm/v/kaizen-agent?style=for-the-badge&color=000&labelColor=1c1c1e&logo=npm"></a>
|
|
12
12
|
<a href="https://github.com/hfadhlullah/kaizen/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/hfadhlullah/kaizen?style=for-the-badge&logo=github&color=000&labelColor=1c1c1e"></a>
|
|
13
13
|
<img alt="Bun 1.1+" src="https://img.shields.io/badge/Bun-1.1%2B-000?style=for-the-badge&logo=bun&logoColor=white">
|
|
14
|
-
<img alt="macOS · Linux · Windows
|
|
14
|
+
<img alt="macOS · Linux · Windows" src="https://img.shields.io/badge/macOS_·_Linux_·_Windows-000?style=for-the-badge">
|
|
15
15
|
<a href="LICENSE"><img alt="License MIT" src="https://img.shields.io/badge/license-MIT-000?style=for-the-badge"></a>
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
|
-
> **kaizen runs inside an AI agent; it is not one.** The agent does the work; kaizen gives it a plan, an approval stop and an independent review. It works with Claude Code, Codex, Antigravity and Gemini CLI, and the installer offers to set one up if you have none. A run costs several times a single prompt, so it is meant for work where being wrong is expensive.
|
|
18
|
+
> **kaizen runs inside an AI agent; it is not one.** The agent does the work; kaizen gives it a plan, an approval stop and an independent review. It works with Claude Code, Codex, Antigravity and Gemini CLI, and the installer offers to set one up if you have none. A run costs several times a single prompt, so it is meant for work where being wrong is expensive.
|
|
19
19
|
|
|
20
20
|
<br>
|
|
21
21
|
|
|
@@ -56,7 +56,7 @@ None of this is a lack of intelligence. It is a missing workflow. Many assistant
|
|
|
56
56
|
```bash
|
|
57
57
|
curl -fsSL https://bun.sh/install | bash && ~/.bun/bin/bunx kaizen-agent
|
|
58
58
|
```
|
|
59
|
-
On Windows
|
|
59
|
+
On Windows, in PowerShell:
|
|
60
60
|
```powershell
|
|
61
61
|
irm bun.sh/install.ps1 | iex; & "$env:USERPROFILE\.bun\bin\bunx.exe" kaizen-agent
|
|
62
62
|
```
|
|
@@ -75,7 +75,7 @@ None of this is a lack of intelligence. It is a missing workflow. Many assistant
|
|
|
75
75
|
| Runtime | [Bun](https://bun.sh) 1.1 or newer. The installer above gets it. |
|
|
76
76
|
| Agent | Claude Code, Codex, Antigravity or Gemini CLI. Claude Code gets the full flow with separate subagents; the others run every stage in one session. |
|
|
77
77
|
| Git | Needed for the board's commit and push. Optional otherwise. |
|
|
78
|
-
| OS | macOS, Linux
|
|
78
|
+
| OS | macOS, Linux, Windows. |
|
|
79
79
|
| Phone app | [Tailscale](https://tailscale.com/download) on the PC and the phone, same account. |
|
|
80
80
|
|
|
81
81
|
## How it works
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# `kaizen chat`'s window: a see-through WebKitGTK window, so the popup shows
|
|
2
|
+
# only its bubbles over the desktop. Chromium app windows always paint a
|
|
3
|
+
# background; this is used when python3 has GTK 3 and WebKit2GTK 4.1.
|
|
4
|
+
import sys
|
|
5
|
+
import gi
|
|
6
|
+
gi.require_version("Gtk", "3.0")
|
|
7
|
+
gi.require_version("Gdk", "3.0")
|
|
8
|
+
gi.require_version("WebKit2", "4.1")
|
|
9
|
+
from gi.repository import GLib, Gdk, Gtk, WebKit2
|
|
10
|
+
|
|
11
|
+
if len(sys.argv) > 1 and sys.argv[1] == "--check":
|
|
12
|
+
sys.exit(0)
|
|
13
|
+
GLib.set_prgname("kaizen-chat")
|
|
14
|
+
win = Gtk.Window(title="kaizen chat")
|
|
15
|
+
win.set_default_size(420, 600)
|
|
16
|
+
win.set_decorated(False)
|
|
17
|
+
win.set_app_paintable(True)
|
|
18
|
+
visual = win.get_screen().get_rgba_visual()
|
|
19
|
+
if visual:
|
|
20
|
+
win.set_visual(visual)
|
|
21
|
+
view = WebKit2.WebView()
|
|
22
|
+
clear = Gdk.RGBA()
|
|
23
|
+
clear.parse("rgba(0,0,0,0)")
|
|
24
|
+
view.set_background_color(clear)
|
|
25
|
+
# The page's drag handle: the compositor moves the window while the button is held.
|
|
26
|
+
def on_message(_manager, _result):
|
|
27
|
+
win.begin_move_drag(1, 0, 0, Gtk.get_current_event_time())
|
|
28
|
+
manager = view.get_user_content_manager()
|
|
29
|
+
manager.connect("script-message-received::kaizen", on_message)
|
|
30
|
+
manager.register_script_message_handler("kaizen")
|
|
31
|
+
# window.close() from the page (Esc) closes the window.
|
|
32
|
+
view.connect("close", lambda *_: win.destroy())
|
|
33
|
+
view.load_uri(sys.argv[1])
|
|
34
|
+
win.add(view)
|
|
35
|
+
win.connect("destroy", Gtk.main_quit)
|
|
36
|
+
win.show_all()
|
|
37
|
+
Gtk.main()
|
package/cli/chat.test.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { join, delimiter } from "node:path";
|
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import { sendChat, readChat, listChats, deleteChat, stopChat, parseLine, takeMoves, type Event, type Board, type Upload } from "./chat.ts";
|
|
8
8
|
|
|
9
|
-
let root = "", base = "", bin = "", projA = "", projD = "", board: Board, created: string[] = [];
|
|
9
|
+
let root = "", base = "", bin = "", projA = "", projD = "", board: Board, created: string[] = [], runs: string[][] = [];
|
|
10
10
|
const PATH = process.env.PATH;
|
|
11
11
|
const posix = process.platform !== "win32";
|
|
12
12
|
|
|
@@ -46,7 +46,10 @@ beforeEach(() => {
|
|
|
46
46
|
mkdirSync(bin);
|
|
47
47
|
process.env.PATH = bin + delimiter + PATH;
|
|
48
48
|
created = [];
|
|
49
|
+
runs = [];
|
|
49
50
|
board = {
|
|
51
|
+
agents: ["claude", "codex"],
|
|
52
|
+
run: async (dir, runner, agent, text) => { runs.push([dir, runner, agent, text]); return { agent }; },
|
|
50
53
|
projects: [{ dir: projA, label: "A" }, { dir: projD, label: "D" }],
|
|
51
54
|
create: async (name) => {
|
|
52
55
|
if (name.includes("/")) return { error: "bad name" };
|
|
@@ -76,13 +79,13 @@ test.if(posix)("a message streams the reply, saves both sides, runs in the chat'
|
|
|
76
79
|
expect(stdin).toContain(`- D — ${join(root, "D")}`);
|
|
77
80
|
expect(stdin.endsWith("say hi")).toBe(true);
|
|
78
81
|
expect(argv()).toContain("workspace-write");
|
|
79
|
-
expect(argv().slice(
|
|
82
|
+
expect(argv().slice(argv().indexOf("-m"), argv().indexOf("-m") + 4)).toEqual(["-m", "gpt-6-luna", "-c", "model_reasoning_effort=medium"]);
|
|
80
83
|
expect(argv()).not.toContain("resume");
|
|
81
84
|
expect(listChats(base).map((x) => [x.id, x.project])).toEqual([[id, projA]]);
|
|
82
85
|
|
|
83
86
|
fake(say("Again."));
|
|
84
87
|
await turn(id, "again");
|
|
85
|
-
expect(argv().slice(
|
|
88
|
+
expect(argv().slice(argv().indexOf("-m"), argv().indexOf("-m") + 4)).toEqual(["-m", "gpt-6-luna", "-c", "model_reasoning_effort=medium"]);
|
|
86
89
|
expect(argv().slice(-3)).toEqual(["resume", "T1", "-"]);
|
|
87
90
|
expect(readChat(base, id)!.messages).toHaveLength(4);
|
|
88
91
|
});
|
|
@@ -92,7 +95,8 @@ test.if(posix)("no project: a read-only scratch folder outside every project", a
|
|
|
92
95
|
const { id } = await turn(null, "hello");
|
|
93
96
|
expect(readChat(base, id)!.project).toBeUndefined();
|
|
94
97
|
expect(readFileSync(join(bin, "cwd"), "utf8").trim()).toBe(join(base, "chats", "scratch"));
|
|
95
|
-
expect(argv()).toContain("
|
|
98
|
+
expect(argv()).toContain("workspace-write");
|
|
99
|
+
expect(argv().join(" ")).toContain(`--add-dir ${join(root, "A")} --add-dir ${join(root, "D")}`);
|
|
96
100
|
expect(readFileSync(join(bin, "stdin"), "utf8")).toContain("Project of this chat: none");
|
|
97
101
|
// A project the page names that the board does not list is not taken.
|
|
98
102
|
const r = await turn(null, "hi", join(root, "elsewhere", ".kaizen"));
|
|
@@ -235,7 +239,36 @@ test("parseLine and takeMoves", () => {
|
|
|
235
239
|
.toEqual({ t: "step", step: { kind: "cmd", text: "cat a.md", ok: false } });
|
|
236
240
|
expect(parseLine(`{"type":"item.completed","item":{"type":"file_change","changes":[{"path":"a.ts"}],"status":"completed"}}`))
|
|
237
241
|
.toEqual({ t: "step", step: { kind: "edit", text: "a.ts", ok: true } });
|
|
238
|
-
expect(takeMoves("ok\n\n[[kaizen:project A]]\n")).toEqual({ text: "ok", move: { op: "project", arg: "A" } });
|
|
242
|
+
expect(takeMoves("ok\n\n[[kaizen:project A]]\n")).toEqual({ text: "ok", move: { op: "project", arg: "A" }, run: null });
|
|
239
243
|
// Only a line of its own counts: a move quoted inside a sentence is text.
|
|
240
244
|
expect(takeMoves("write `[[kaizen:project A]]` to move").move).toBeNull();
|
|
241
245
|
});
|
|
246
|
+
|
|
247
|
+
test.if(posix)("every listed project is writable without a switch; the chat's own folder is not repeated", async () => {
|
|
248
|
+
fake(say("Read D."));
|
|
249
|
+
await turn(null, "what is in D", projA);
|
|
250
|
+
expect(argv().filter((a, i) => argv()[i - 1] === "--add-dir")).toEqual([join(root, "D")]);
|
|
251
|
+
const stdin = readFileSync(join(bin, "stdin"), "utf8");
|
|
252
|
+
expect(stdin).toContain("you do not need to switch");
|
|
253
|
+
expect(stdin).toContain("installed: claude, codex");
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test.if(posix)("a run line starts a kaizen run in the named project; the chat stays where it is", async () => {
|
|
257
|
+
fake(say(`Starting it.\n[[kaizen:run ${join(root, "D")} | full | claude | add a dark mode]]`));
|
|
258
|
+
const { events, id } = await turn(null, "1, full, claude", projA);
|
|
259
|
+
expect(events.filter((e) => e.t === "text")).toEqual([{ t: "text", text: "Starting it." }]);
|
|
260
|
+
expect(runs).toEqual([[projD, "full", "claude", "add a dark mode"]]);
|
|
261
|
+
expect(events.find((e) => e.t === "run")).toEqual({ t: "run", dir: projD });
|
|
262
|
+
const c = readChat(base, id)!;
|
|
263
|
+
expect(c.project).toBe(projA);
|
|
264
|
+
expect(c.messages[1].steps!.at(-1)).toEqual({ kind: "project", text: "Started a full run in D with claude", ok: true });
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test.if(posix)("a run line with an unlisted project, unknown runner or missing agent is refused", async () => {
|
|
268
|
+
for (const line of ["/etc | lite | claude | x", "D | auto | claude | x", "D | lite | gemini | x", "D | lite | claude | "]) {
|
|
269
|
+
fake(say(`[[kaizen:run ${line}]]`));
|
|
270
|
+
const { id } = await turn(null, "go", projA);
|
|
271
|
+
expect(readChat(base, id)!.messages[1].steps!.at(-1)).toMatchObject({ kind: "project", ok: false });
|
|
272
|
+
}
|
|
273
|
+
expect(runs).toEqual([]);
|
|
274
|
+
});
|
package/cli/chat.ts
CHANGED
|
@@ -19,13 +19,19 @@ export type Event =
|
|
|
19
19
|
| { t: "status"; text: string }
|
|
20
20
|
| { t: "step"; step: Step }
|
|
21
21
|
| { t: "project"; dir: string | null }
|
|
22
|
+
| { t: "run"; dir: string }
|
|
22
23
|
| { t: "error"; error: string }
|
|
23
24
|
| { t: "done" };
|
|
24
|
-
// What the board knows, handed in by the server: its projects (state dirs)
|
|
25
|
+
// What the board knows, handed in by the server: its projects (state dirs), how it makes one,
|
|
26
|
+
// the agents installed, and how it starts a kaizen run in a project.
|
|
25
27
|
export type Board = {
|
|
26
28
|
projects: { dir: string; label: string }[];
|
|
27
29
|
create: (name: string) => Promise<{ dir: string } | { error: string }>;
|
|
30
|
+
agents: string[];
|
|
31
|
+
run: (dir: string, runner: "lite" | "full", agent: string, text: string) => Promise<{ agent: string } | { error: string }>;
|
|
28
32
|
};
|
|
33
|
+
// The project folders the agent may write in: every listed one, capped like the brief's list.
|
|
34
|
+
const roots = (board: Board) => board.projects.slice(0, 80).map((p) => dirname(p.dir));
|
|
29
35
|
|
|
30
36
|
export const okId = (id: unknown): id is string => typeof id === "string" && /^[\w-]{1,80}$/.test(id);
|
|
31
37
|
const file = (base: string, id: string) => join(base, "chats", `${id}.json`);
|
|
@@ -60,11 +66,16 @@ export function brief(c: Chat, board: Board) {
|
|
|
60
66
|
const list = board.projects.slice(0, 80).map((p) => `- ${p.label} — ${dirname(p.dir)}`).join("\n");
|
|
61
67
|
return `[kaizen board context, not written by the user]
|
|
62
68
|
You are kaizen's main agent, talking with the user from the kaizen board's Home page.
|
|
63
|
-
Project of this chat: ${here ? `${here.label} (${dirname(here.dir)})` : "none — you are in a scratch folder
|
|
69
|
+
Project of this chat: ${here ? `${here.label} (${dirname(here.dir)})` : "none — you are in a scratch folder"}.
|
|
64
70
|
Projects on the board:
|
|
65
71
|
${list || "(none)"}
|
|
66
|
-
You can
|
|
67
|
-
|
|
72
|
+
You can read, analyse and edit files in any project folder listed above directly by its path; you do not need to switch to it. Do not write outside those folders and your working folder.
|
|
73
|
+
Switching only changes this chat's home project (where you run and which project the board shows). On a line of its own write [[kaizen:project <folder>]] to switch to a listed project, or [[kaizen:new-project <name>]] to create one (a plain folder name). Switch only when the user asks; when what they want fits no listed project, ask whether to create a new one. After a successful move, the board starts one follow-up turn in the new project to finish the pending request; do not ask the user to repeat it.
|
|
74
|
+
When the user asks you to develop, fix, change or enhance something (not a question, analysis or reading), first ask which way, as numbered options, and do nothing until they pick:
|
|
75
|
+
1. Start a kaizen run for it: lite (cheap, one session) or full (independent review), with which agent (installed: ${board.agents.join(", ") || "none"}), in which project.
|
|
76
|
+
2. Let you handle it here in the chat.
|
|
77
|
+
For 1, once they pick, write on a line of its own [[kaizen:run <project folder> | <lite or full> | <agent> | <the request, one line>]]; the board starts the run in that project and it shows there. Do not start it yourself with /kaizen. For 2, do the work directly.
|
|
78
|
+
Keep replies short.
|
|
68
79
|
[end of context]
|
|
69
80
|
|
|
70
81
|
`;
|
|
@@ -141,12 +152,21 @@ export function parseLine(line: string): Event | { t: "thread"; id: string } | n
|
|
|
141
152
|
return null;
|
|
142
153
|
}
|
|
143
154
|
|
|
144
|
-
// The agent's move lines: taken out of what the user reads; the last
|
|
145
|
-
const MOVE = /^[ \t]*\[\[kaizen:(project|new-project)[ \t]+([^\]\n]+?)\]\][ \t]*$/gm;
|
|
155
|
+
// The agent's move and run lines: taken out of what the user reads; the last of each counts.
|
|
156
|
+
const MOVE = /^[ \t]*\[\[kaizen:(project|new-project|run)[ \t]+([^\]\n]+?)\]\][ \t]*$/gm;
|
|
157
|
+
export type RunAsk = { project: string; runner: string; agent: string; text: string };
|
|
146
158
|
export function takeMoves(text: string) {
|
|
147
159
|
let move: { op: "project" | "new-project"; arg: string } | null = null;
|
|
148
|
-
|
|
149
|
-
|
|
160
|
+
let run: RunAsk | null = null;
|
|
161
|
+
const rest = text.replace(MOVE, (_, op, arg) => {
|
|
162
|
+
if (op !== "run") move = { op, arg: arg.trim() };
|
|
163
|
+
else {
|
|
164
|
+
const [project = "", runner = "", agent = "", ...t] = arg.split("|").map((x: string) => x.trim());
|
|
165
|
+
run = { project, runner, agent, text: t.join(" | ").trim() };
|
|
166
|
+
}
|
|
167
|
+
return "";
|
|
168
|
+
}).replace(/\n{3,}/g, "\n\n").trim();
|
|
169
|
+
return { text: rest, move: move as { op: "project" | "new-project"; arg: string } | null, run: run as RunAsk | null };
|
|
150
170
|
}
|
|
151
171
|
|
|
152
172
|
// Not winShim: the message goes in on stdin, so the .cmd shim's newline limit never applies.
|
|
@@ -180,7 +200,7 @@ export function sendChat(base: string, id: string | null, text: string, project:
|
|
|
180
200
|
chat.updated = now;
|
|
181
201
|
save(base, chat);
|
|
182
202
|
|
|
183
|
-
// No project: a scratch folder outside every project
|
|
203
|
+
// No project: a scratch folder outside every project.
|
|
184
204
|
const scratch = join(base, "chats", "scratch");
|
|
185
205
|
if (!chat.project) mkdirSync(scratch, { recursive: true });
|
|
186
206
|
const cwd = chat.project ? dirname(chat.project) : scratch;
|
|
@@ -188,7 +208,9 @@ export function sendChat(base: string, id: string | null, text: string, project:
|
|
|
188
208
|
const env: Record<string, string> = {};
|
|
189
209
|
for (const [k, v] of Object.entries(process.env)) if (v !== undefined && !CHILD_ENV.test(k)) env[k] = v;
|
|
190
210
|
const images = files.filter((f) => f.image).flatMap((f) => ["-i", f.path]);
|
|
191
|
-
|
|
211
|
+
// Every listed project is writable, so the agent works on any of them without a switch.
|
|
212
|
+
const dirs = roots(board).filter((d) => d !== cwd).flatMap((d) => ["--add-dir", d]);
|
|
213
|
+
const argv = [bin, "exec", "--json", "--skip-git-repo-check", "-s", "workspace-write", ...dirs,
|
|
192
214
|
"-m", "gpt-6-luna", "-c", "model_reasoning_effort=medium", ...(chat.thread ? ["resume", chat.thread] : []), ...images, "-"];
|
|
193
215
|
let p;
|
|
194
216
|
try { p = Bun.spawn(argv, { cwd, env, stdin: "pipe", stdout: "pipe", stderr: "pipe" }); }
|
|
@@ -212,6 +234,7 @@ export function sendChat(base: string, id: string | null, text: string, project:
|
|
|
212
234
|
const dec = new TextDecoder();
|
|
213
235
|
let buf = "";
|
|
214
236
|
let move: ReturnType<typeof takeMoves>["move"] = null;
|
|
237
|
+
let run: RunAsk | null = null;
|
|
215
238
|
const take = (line: string) => {
|
|
216
239
|
const e = parseLine(line);
|
|
217
240
|
if (!e) return;
|
|
@@ -219,6 +242,7 @@ export function sendChat(base: string, id: string | null, text: string, project:
|
|
|
219
242
|
if (e.t === "text") {
|
|
220
243
|
const m = takeMoves(e.text);
|
|
221
244
|
if (m.move) move = m.move;
|
|
245
|
+
if (m.run) run = m.run;
|
|
222
246
|
if (!m.text) return;
|
|
223
247
|
e.text = m.text;
|
|
224
248
|
reply.text += (reply.text ? "\n\n" : "") + e.text;
|
|
@@ -244,6 +268,7 @@ export function sendChat(base: string, id: string | null, text: string, project:
|
|
|
244
268
|
reply.error = err || `codex exited with code ${code}`;
|
|
245
269
|
emit({ t: "error", error: reply.error });
|
|
246
270
|
}
|
|
271
|
+
if (run && !stopped) await startRun(reply, run, board, emit);
|
|
247
272
|
if (move && !stopped) await moveChat(chat, reply, move, board, emit);
|
|
248
273
|
} finally {
|
|
249
274
|
delete reply.activity;
|
|
@@ -256,14 +281,32 @@ export function sendChat(base: string, id: string | null, text: string, project:
|
|
|
256
281
|
return null;
|
|
257
282
|
}
|
|
258
283
|
|
|
284
|
+
const findProject = (board: Board, arg: string) => {
|
|
285
|
+
const a = arg.replace(/[\\/]+$/, "");
|
|
286
|
+
return board.projects.find((x) => x.dir === a || dirname(x.dir) === a || x.dir === join(a, ".kaizen"))
|
|
287
|
+
?? board.projects.find((x) => x.label === a || basename(dirname(x.dir)) === a);
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// Start the run the user picked: only in a listed project, with an installed agent.
|
|
291
|
+
async function startRun(reply: Msg, ask: RunAsk, board: Board, emit: (e: Event) => void) {
|
|
292
|
+
const step = (text: string, ok: boolean) => { const s: Step = { kind: "project", text, ok }; reply.steps!.push(s); emit({ t: "step", step: s }); };
|
|
293
|
+
const p = findProject(board, ask.project);
|
|
294
|
+
if (!p) return step(`No project ${ask.project} on the board`, false);
|
|
295
|
+
if (ask.runner !== "lite" && ask.runner !== "full") return step(`Unknown runner ${ask.runner}`, false);
|
|
296
|
+
if (!board.agents.includes(ask.agent)) return step(`Agent ${ask.agent} is not installed`, false);
|
|
297
|
+
if (!ask.text) return step("No request for the run", false);
|
|
298
|
+
const r = await board.run(p.dir, ask.runner, ask.agent, ask.text);
|
|
299
|
+
if ("error" in r) return step(`Could not start the run: ${r.error}`, false);
|
|
300
|
+
step(`Started a ${ask.runner} run in ${p.label} with ${r.agent}`, true);
|
|
301
|
+
emit({ t: "run", dir: p.dir });
|
|
302
|
+
}
|
|
303
|
+
|
|
259
304
|
// Apply the agent's move: only to a project the board lists, or one the board's own rules create.
|
|
260
305
|
async function moveChat(chat: Chat, reply: Msg, move: { op: string; arg: string }, board: Board, emit: (e: Event) => void) {
|
|
261
306
|
const step = (text: string, ok: boolean) => { const s: Step = { kind: "project", text, ok }; reply.steps!.push(s); emit({ t: "step", step: s }); };
|
|
262
307
|
let dir: string | null = null;
|
|
263
308
|
if (move.op === "project") {
|
|
264
|
-
const
|
|
265
|
-
const p = board.projects.find((x) => x.dir === a || dirname(x.dir) === a || x.dir === join(a, ".kaizen"))
|
|
266
|
-
?? board.projects.find((x) => x.label === a || basename(dirname(x.dir)) === a);
|
|
309
|
+
const p = findProject(board, move.arg);
|
|
267
310
|
if (!p) return step(`No project ${move.arg} on the board`, false);
|
|
268
311
|
dir = p.dir;
|
|
269
312
|
} else {
|
package/cli/install.ts
CHANGED
|
@@ -460,6 +460,77 @@ if (args.has("prune")) {
|
|
|
460
460
|
process.exit(0);
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
+
// `kaizen chat`: Home's chat in a small window over the desktop, like Hermes's HUD.
|
|
464
|
+
// Bind it to a hotkey: run again while the window is open and it closes.
|
|
465
|
+
if (Bun.argv[2] === "chat") {
|
|
466
|
+
const at = Bun.argv.indexOf("--port");
|
|
467
|
+
const port = at !== -1 ? Number(Bun.argv[at + 1]) || 7420 : 7420;
|
|
468
|
+
const url = `http://127.0.0.1:${port}/`;
|
|
469
|
+
const { current } = await import("./web.ts");
|
|
470
|
+
if (!(await current(url))) await Bun.spawn([process.execPath, Bun.main, "web", "--daemon", "--no-open", "--port", String(port)], { stdout: "ignore", stderr: "inherit" }).exited;
|
|
471
|
+
// Chromium on Wayland ignores --class: the app window's class comes from the URL.
|
|
472
|
+
const isChat = (c: any) => c.class === "kaizen-chat" || String(c.class).startsWith("chrome-127.0.0.1__popup");
|
|
473
|
+
const hypr = !!process.env.HYPRLAND_INSTANCE_SIGNATURE && !!Bun.which("hyprctl");
|
|
474
|
+
const clients = async (): Promise<any[]> => hypr ? await Bun.$`hyprctl clients -j`.quiet().nothrow().json().catch(() => []) : [];
|
|
475
|
+
if (hypr) {
|
|
476
|
+
const { listSettings, bindChatHotkey } = await import("./settings.ts");
|
|
477
|
+
const keys = listSettings(dirname(import.meta.dir)).rows.find((r) => r.key === "board.chat_hotkey")?.value;
|
|
478
|
+
if (keys) bindChatHotkey(String(keys), undefined, true);
|
|
479
|
+
}
|
|
480
|
+
const open = (await clients()).find(isChat);
|
|
481
|
+
// Where the window was left, so the next one opens there.
|
|
482
|
+
const spot = join(home, ".kaizen", "chat-window.json");
|
|
483
|
+
// --show only opens (the board's Pop out), --close only closes (the popup's Back);
|
|
484
|
+
// plain `kaizen chat` toggles, for a hotkey.
|
|
485
|
+
if (open && Bun.argv.includes("--show")) {
|
|
486
|
+
await Bun.$`hyprctl dispatch ${`hl.dsp.focus({ window = "address:${open.address}" })`}`.quiet().nothrow();
|
|
487
|
+
process.exit(0);
|
|
488
|
+
}
|
|
489
|
+
if (!open && Bun.argv.includes("--close")) process.exit(0);
|
|
490
|
+
if (open) {
|
|
491
|
+
try { writeFileSync(spot, JSON.stringify({ x: open.at[0], y: open.at[1] })); } catch {}
|
|
492
|
+
try { process.kill(open.pid, "SIGTERM"); } catch {}
|
|
493
|
+
process.exit(0);
|
|
494
|
+
}
|
|
495
|
+
// A see-through WebKitGTK window when python3 has it; Chromium paints a background.
|
|
496
|
+
const ci = Bun.argv.indexOf("--chat"), chatId = ci !== -1 ? Bun.argv[ci + 1] ?? "" : "";
|
|
497
|
+
const page = `${url}popup${/^[\w.-]+$/.test(chatId) ? `?chat=${chatId}` : ""}`;
|
|
498
|
+
const shell = join(import.meta.dir, "chat-window.py");
|
|
499
|
+
const py = Bun.which("python3");
|
|
500
|
+
const bin = ["chromium", "chromium-browser", "google-chrome", "google-chrome-stable", "microsoft-edge", "brave", "brave-browser"].map((b) => Bun.which(b)).find(Boolean);
|
|
501
|
+
const cmd = py && Bun.spawnSync([py, shell, "--check"], { stdout: "ignore", stderr: "ignore" }).exitCode === 0 ? [py, shell, page]
|
|
502
|
+
// Its own profile, so it is its own process: closing it never takes the browser along.
|
|
503
|
+
: bin ? [bin, `--app=${page}`, `--user-data-dir=${join(home, ".kaizen", "chat-window")}`, "--window-size=420,600"] : null;
|
|
504
|
+
if (!cmd) { console.log(` no Chromium-based browser found; open ${url}popup instead`); process.exit(1); }
|
|
505
|
+
Bun.spawn(cmd, { stdin: "ignore", stdout: "ignore", stderr: "ignore", detached: true }).unref();
|
|
506
|
+
if (hypr) {
|
|
507
|
+
let win: any;
|
|
508
|
+
for (let i = 0; i < 50 && !(win = (await clients()).find(isChat)); i++) await Bun.sleep(100);
|
|
509
|
+
if (win) {
|
|
510
|
+
// Hyprland 0.55+ on a Lua config reads dispatch as Lua; older ones want the classic words.
|
|
511
|
+
const w = `address:${win.address}`;
|
|
512
|
+
const mon = (await Bun.$`hyprctl monitors -j`.quiet().nothrow().json().catch(() => [])).find((m: any) => m.id === win.monitor);
|
|
513
|
+
let x = mon ? mon.x + Math.round(mon.width / mon.scale) - 440 : 100, y = mon ? mon.y + Math.round(mon.height / mon.scale) - 640 : 100;
|
|
514
|
+
// The saved spot, while it is still on a connected monitor.
|
|
515
|
+
const was = (() => { try { return JSON.parse(readFileSync(spot, "utf8")); } catch { return null; } })();
|
|
516
|
+
const mons: any[] = await Bun.$`hyprctl monitors -j`.quiet().nothrow().json().catch(() => []);
|
|
517
|
+
if (Number.isFinite(was?.x) && Number.isFinite(was?.y) && mons.some((m) => was.x >= m.x && was.y >= m.y && was.x < m.x + m.width / m.scale && was.y < m.y + m.height / m.scale)) ({ x, y } = was);
|
|
518
|
+
const steps = [
|
|
519
|
+
[`hl.dsp.window.float({ action = "enable", window = "${w}" })`, `setfloating ${w}`],
|
|
520
|
+
[`hl.dsp.window.pin({ action = "enable", window = "${w}" })`, `pin ${w}`],
|
|
521
|
+
// No border, rounding or shadow: only the bubbles show.
|
|
522
|
+
[`hl.dsp.window.set_prop({ prop = "no_shadow", value = "1", window = "${w}" })`, `setprop ${w} no_shadow 1`],
|
|
523
|
+
[`hl.dsp.window.set_prop({ prop = "border_size", value = "0", window = "${w}" })`, `setprop ${w} border_size 0`],
|
|
524
|
+
[`hl.dsp.window.resize({ x = 420, y = 600, window = "${w}" })`, `resizewindowpixel exact 420 600,${w}`],
|
|
525
|
+
[`hl.dsp.window.move({ x = ${x}, y = ${y}, window = "${w}" })`, `movewindowpixel exact ${x} ${y},${w}`],
|
|
526
|
+
];
|
|
527
|
+
for (const [lua, legacy] of steps)
|
|
528
|
+
if ((await Bun.$`hyprctl dispatch ${lua}`.quiet().nothrow().text()).trim() !== "ok") await Bun.$`hyprctl dispatch ${legacy.split(" ")}`.quiet().nothrow();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
process.exit(0);
|
|
532
|
+
}
|
|
533
|
+
|
|
463
534
|
if (wantWeb) {
|
|
464
535
|
if (args.has("--shortcut")) { const { shortcut } = await import("./web.ts"); console.log(`\n kaizen web shortcut ${await shortcut()}\n`); process.exit(0); }
|
|
465
536
|
const at = Bun.argv.indexOf("--port");
|
|
@@ -957,8 +1028,12 @@ function installLauncher() {
|
|
|
957
1028
|
? join(process.env.BUN_INSTALL ?? join(home, ".bun"), "bin")
|
|
958
1029
|
: join(home, ".local", "bin");
|
|
959
1030
|
const bin = join(binDir, win ? "kaizen.cmd" : "kaizen");
|
|
1031
|
+
// Windows calls bun by full path: cmd.exe on some machines cannot find bun on PATH
|
|
1032
|
+
// even when PowerShell can, and `kaizen` then fails with "'bun' is not recognized".
|
|
1033
|
+
// POSIX keeps `bun`, since version managers (mise, asdf) put bun under a versioned
|
|
1034
|
+
// path that an upgrade removes.
|
|
960
1035
|
const script = win
|
|
961
|
-
? `@echo off\r\nrem kaizen launcher -- installed by kaizen-agent\r\
|
|
1036
|
+
? `@echo off\r\nrem kaizen launcher -- installed by kaizen-agent\r\n"${process.execPath}" run "${entry}" %*\r\n`
|
|
962
1037
|
: `#!/bin/sh\n# kaizen launcher -- installed by kaizen-agent\nexec bun run ${entry} "$@"\n`;
|
|
963
1038
|
try {
|
|
964
1039
|
if (existsSync(bin) && readFileSync(bin, "utf8") === script) return;
|
package/cli/settings.ts
CHANGED
|
@@ -127,6 +127,7 @@ const SETTINGS: Setting[] = [
|
|
|
127
127
|
{ key: "board.projects_dir", label: "Projects folder", group: "Board", values: [], text: true, folder: true, help: "Empty: known projects only" },
|
|
128
128
|
{ key: "board.video_dir", label: "Video library folder", group: "Board", values: [], text: true, folder: true, help: "Empty: ~/.kaizen" },
|
|
129
129
|
{ key: "board.open", label: "Open the board in", group: "Board", values: ["browser", "app"], help: "" },
|
|
130
|
+
{ key: "board.chat_hotkey", label: "Popup chat hotkey", group: "Board", values: [], text: true, help: "Hyprland, e.g. SUPER + ALT + SPACE. Empty: none" },
|
|
130
131
|
{ key: "ui.mouse", label: "Enable mouse", group: "Terminal", values: ["false", "true"], help: "" },
|
|
131
132
|
];
|
|
132
133
|
|
|
@@ -169,7 +170,9 @@ export function setSetting(repoRoot: string, key: string, value: string) {
|
|
|
169
170
|
updated = write(updated, "preset", detectPreset(updated, defaults), defaults);
|
|
170
171
|
if (read(updated, key) !== value) return { error: `${key} did not save; edit ${tilde(file)} by hand` };
|
|
171
172
|
}
|
|
173
|
+
if (key === "board.chat_hotkey" && !HOTKEY.test(value)) return { error: "keys are words joined by +, e.g. SUPER + ALT + SPACE" };
|
|
172
174
|
writeFileSync(file, updated);
|
|
175
|
+
if (key === "board.chat_hotkey") bindChatHotkey(value);
|
|
173
176
|
return { ok: true };
|
|
174
177
|
}
|
|
175
178
|
|
|
@@ -493,3 +496,25 @@ function tilde(p: string) {
|
|
|
493
496
|
const h = homedir();
|
|
494
497
|
return p.startsWith(h) ? "~" + p.slice(h.length) : p;
|
|
495
498
|
}
|
|
499
|
+
|
|
500
|
+
// `board.chat_hotkey`: the key that toggles `kaizen chat`, written into the Hyprland
|
|
501
|
+
// config as a marked block, unbinding whatever held the key first. Hyprland reloads
|
|
502
|
+
// the file by itself. Elsewhere there is nowhere to bind it; returns where it went.
|
|
503
|
+
const HOTKEY = /^$|^[A-Za-z0-9_]+( *\+ *[A-Za-z0-9_]+)*$/;
|
|
504
|
+
const BEGIN = "kaizen chat hotkey (written by kaizen; change it in kaizen settings)", END = "end kaizen chat hotkey";
|
|
505
|
+
// `missingOnly`: leave a block already there alone (`kaizen chat` applying the default).
|
|
506
|
+
export function bindChatHotkey(keys: string, dir = join(homedir(), ".config", "hypr"), missingOnly = false) {
|
|
507
|
+
if (!HOTKEY.test(keys)) return null;
|
|
508
|
+
const lua = join(dir, "bindings.lua"), conf = join(dir, "hyprland.conf");
|
|
509
|
+
const file = existsSync(lua) ? lua : existsSync(conf) ? conf : null;
|
|
510
|
+
if (!file || (missingOnly && readText(file).includes(BEGIN))) return null;
|
|
511
|
+
const k = keys.split("+").map((x) => x.trim().toUpperCase());
|
|
512
|
+
const cmd = Bun.which("kaizen") ?? "kaizen";
|
|
513
|
+
const c = file === lua ? "--" : "#";
|
|
514
|
+
const body = !keys ? "" : file === lua
|
|
515
|
+
? `pcall(hl.unbind, "${k.join(" + ")}")\no.bind("${k.join(" + ")}", "kaizen chat", "${cmd} chat")`
|
|
516
|
+
: `unbind = ${k.slice(0, -1).join(" ")}, ${k.at(-1)}\nbind = ${k.slice(0, -1).join(" ")}, ${k.at(-1)}, exec, ${cmd} chat`;
|
|
517
|
+
const text = readText(file).replace(new RegExp(`\\n?${c} ${BEGIN.replace(/[()]/g, "\\$&")}[\\s\\S]*?${c} ${END}\\n?`), "\n");
|
|
518
|
+
writeFileSync(file, text.replace(/\n*$/, "\n") + (body ? `\n${c} ${BEGIN}\n${body}\n${c} ${END}\n` : ""));
|
|
519
|
+
return file;
|
|
520
|
+
}
|
package/cli/state.ts
CHANGED
|
@@ -128,7 +128,7 @@ const shq = (a: string) => `'${a.replace(/'/g, `'\\''`)}'`;
|
|
|
128
128
|
// every `key:\n` regex the same silent way, so line endings are made LF here too.
|
|
129
129
|
export const readText = (file: string) => readFileSync(file, "utf8").replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
|
|
130
130
|
|
|
131
|
-
const onPath = (bin: string) => Bun.which(bin, { PATH: process.env.PATH });
|
|
131
|
+
export const onPath = (bin: string) => Bun.which(bin, { PATH: process.env.PATH });
|
|
132
132
|
|
|
133
133
|
// npm installs a Windows tool as x.cmd with x.ps1 beside it. PowerShell hands a .cmd to
|
|
134
134
|
// cmd.exe, which ends the command line at the first newline -- a prompt with notes lost
|
package/cli/web.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync, readdirSync, statSync, watch, appendFileSync, mkdirSync, cp
|
|
|
4
4
|
import { join, dirname, resolve, sep, basename } from "node:path";
|
|
5
5
|
import {
|
|
6
6
|
home, type Item, type Card, boardCards, knownProjects, remember, locate, label, tilde, searchRoots, findProjects,
|
|
7
|
-
readInbox, writeInbox, replaceIdea, moveIdea, abandonRun, runToIdea, launchRun, parseItem, agentChoices, projectOf, KNOWN_AGENTS, plainModel, short, setArchived, writeNotes,
|
|
7
|
+
readInbox, writeInbox, replaceIdea, moveIdea, abandonRun, runToIdea, launchRun, parseItem, agentChoices, onPath, projectOf, KNOWN_AGENTS, plainModel, short, setArchived, writeNotes,
|
|
8
8
|
appendNote, saveAttachment, pidOnPort, readText, cmdExe, sysExe, powershellExe, runGit, cardsGit, readCommit, commitPush, notice, notifier, LOGO,
|
|
9
9
|
reviewFindings, pickFindings, backlogCards, backlogItem, startedBacklog, closeBacklog, markBacklogDone, fixPrompt, approvalPrompt, canApproveAwaiting, nativePath, closeSessions, sweepSessions, issueUrl,
|
|
10
10
|
launchMode, readSessions, ownerOf, runIndex, resumePrompt, runAgent, firstSession, webHosts,
|
|
@@ -34,6 +34,9 @@ const TERM_JS = join(dirname(import.meta.dir), "web", "term.js");
|
|
|
34
34
|
const TERM_CSS = join(dirname(import.meta.dir), "web", "term.css");
|
|
35
35
|
// The Video page (kaizen-video's library, editor and renders) and its bundle.
|
|
36
36
|
const VIDEO_PAGE = join(dirname(import.meta.dir), "web", "video.html");
|
|
37
|
+
const POPUP_PAGE = join(dirname(import.meta.dir), "web", "popup.html");
|
|
38
|
+
// The chat the popup was on when its Back button was pressed, until Home takes it.
|
|
39
|
+
let popupChat: string | null = null;
|
|
37
40
|
const VIDEO_JS = join(dirname(import.meta.dir), "web", "video.js");
|
|
38
41
|
const DEFAULT_PORT = 7420;
|
|
39
42
|
// Gathered posts a reply is going out to right now: one send per item at a time.
|
|
@@ -408,6 +411,63 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
408
411
|
return new Response(body, { headers: { "content-type": type, "cache-control": "no-store" } });
|
|
409
412
|
}
|
|
410
413
|
|
|
414
|
+
// `kaizen chat`: the small chat window over the desktop.
|
|
415
|
+
if (req.method === "GET" && path === "/popup") {
|
|
416
|
+
const body = served(POPUP_PAGE);
|
|
417
|
+
if (body === null) return new Response("web/popup.html missing", { status: 500 });
|
|
418
|
+
return new Response(body, { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" } });
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Handing the chat between Home and the popup (`kaizen chat`). /popup/open:
|
|
422
|
+
// open the popup on Home's chat and hide the board's browser window in a
|
|
423
|
+
// special workspace. /popup/board: bring that window back, focus it (open the
|
|
424
|
+
// board when no window shows it) and close the popup. Hyprland moves windows;
|
|
425
|
+
// elsewhere only the popup opens and closes.
|
|
426
|
+
if (req.method === "POST" && (path === "/popup/open" || path === "/popup/board")) {
|
|
427
|
+
const body = await req.json().catch(() => ({}));
|
|
428
|
+
const chat = (...a: string[]) => Bun.spawn([process.execPath, join(import.meta.dir, "install.ts"), "chat", "--port", String(new URL(req.url).port || DEFAULT_PORT), ...a], { stdout: "ignore", stderr: "ignore" }).exited;
|
|
429
|
+
const hypr = !!process.env.HYPRLAND_INSTANCE_SIGNATURE && !!Bun.which("hyprctl");
|
|
430
|
+
const json = async (cmd: string) => await Bun.$`hyprctl ${cmd} -j`.quiet().nothrow().json().catch(() => null);
|
|
431
|
+
// Several windows can show a board: Pop out takes the one clicked in (the active
|
|
432
|
+
// one), Back the one Pop out hid.
|
|
433
|
+
const isBoard = (c: any) => c && /(^|\) )kaizen( [—-] |$)/.test(String(c.title));
|
|
434
|
+
const all: any[] = hypr ? (await json("clients")) || [] : [];
|
|
435
|
+
const active = hypr ? await json("activewindow") : null;
|
|
436
|
+
const board = path === "/popup/open" ? (isBoard(active) ? active : all.find(isBoard))
|
|
437
|
+
: all.find((c) => isBoard(c) && c.workspace?.name === "special:kaizen") ?? all.find(isBoard);
|
|
438
|
+
const w = board && `address:${board.address}`;
|
|
439
|
+
// Lua grammar first (Hyprland 0.55+ with a Lua config), the classic words after.
|
|
440
|
+
const dispatch = async (lua: string, legacy: string[]) => {
|
|
441
|
+
if ((await Bun.$`hyprctl dispatch ${lua}`.quiet().nothrow().text()).trim() !== "ok") await Bun.$`hyprctl dispatch ${legacy}`.quiet().nothrow();
|
|
442
|
+
};
|
|
443
|
+
if (path === "/popup/open") {
|
|
444
|
+
const id = typeof body.id === "string" && /^[\w.-]+$/.test(body.id) ? body.id : "";
|
|
445
|
+
await chat("--show", ...(id ? ["--chat", id] : []));
|
|
446
|
+
if (w) await dispatch(`hl.dsp.window.move({ workspace = "special:kaizen", follow = false, window = "${w}" })`, ["movetoworkspacesilent", `special:kaizen,${w}`]);
|
|
447
|
+
// Typing goes to the popup, not to whatever was under the hidden board.
|
|
448
|
+
const pop = hypr && ((await json("clients")) || []).find((c: any) => c.class === "kaizen-chat" || String(c.class).startsWith("chrome-127.0.0.1__popup"));
|
|
449
|
+
if (pop) await dispatch(`hl.dsp.focus({ window = "address:${pop.address}" })`, ["focuswindow", `address:${pop.address}`]);
|
|
450
|
+
return Response.json({ ok: true, hidden: !!w });
|
|
451
|
+
}
|
|
452
|
+
if (!w) Bun.spawn([process.platform === "darwin" ? "open" : "xdg-open", new URL("/", req.url).href], { stdout: "ignore", stderr: "ignore" });
|
|
453
|
+
else {
|
|
454
|
+
if (String(board.workspace?.name).startsWith("special:")) {
|
|
455
|
+
const ws = (await json("activeworkspace"))?.id ?? 1;
|
|
456
|
+
await dispatch(`hl.dsp.window.move({ workspace = "${ws}", window = "${w}" })`, ["movetoworkspace", `${ws},${w}`]);
|
|
457
|
+
}
|
|
458
|
+
await dispatch(`hl.dsp.focus({ window = "${w}" })`, ["focuswindow", w]);
|
|
459
|
+
}
|
|
460
|
+
if (typeof body.id === "string") popupChat = body.id;
|
|
461
|
+
await chat("--close");
|
|
462
|
+
return Response.json({ ok: true });
|
|
463
|
+
}
|
|
464
|
+
// Home, refocused after Back, takes the popup's chat once.
|
|
465
|
+
if (req.method === "GET" && path === "/popup/handoff") {
|
|
466
|
+
const id = popupChat;
|
|
467
|
+
popupChat = null;
|
|
468
|
+
return Response.json({ id });
|
|
469
|
+
}
|
|
470
|
+
|
|
411
471
|
if (req.method === "GET" && (path === "/video" || path === "/video.js")) {
|
|
412
472
|
const [f, type] = path === "/video" ? [VIDEO_PAGE, "text/html; charset=utf-8"] : [VIDEO_JS, "application/javascript; charset=utf-8"];
|
|
413
473
|
const body = served(f);
|
|
@@ -841,6 +901,13 @@ export async function web(repoDir: string, opts: Opts = {}) {
|
|
|
841
901
|
const r = await makeProject(name);
|
|
842
902
|
return "error" in r ? { error: r.error } : { dir: (r as { dir: string }).dir };
|
|
843
903
|
},
|
|
904
|
+
agents: KNOWN_AGENTS.filter((a) => onPath(a.cmd)).map((a) => a.cmd),
|
|
905
|
+
// As POST /run starts an idea, without one on the inbox.
|
|
906
|
+
run: async (d: string, runner: "lite" | "full", agent: string, text: string) => {
|
|
907
|
+
const r = launchRun(parseItem(`${runner} ${text}`), d, undefined, { agent, ...inCard(d) });
|
|
908
|
+
changed();
|
|
909
|
+
return r.ok ? { agent: r.agent.cmd } : { error: r.why };
|
|
910
|
+
},
|
|
844
911
|
};
|
|
845
912
|
let ctl!: ReadableStreamDefaultController;
|
|
846
913
|
const stream = new ReadableStream({ start: (c) => { ctl = c; } });
|
|
@@ -1518,7 +1585,9 @@ export async function shortcut() {
|
|
|
1518
1585
|
// style 0 starts `kaizen web --daemon` with no window at all; the daemon outlives
|
|
1519
1586
|
// that launcher and `kaizen web --stop` ends it. A crash has no console to land
|
|
1520
1587
|
// in, so web() writes it to ~/.kaizen/web.log instead. A .lnk icon must be an .ico.
|
|
1521
|
-
|
|
1588
|
+
// OneDrive moves the Desktop (C:\Users\x\OneDrive\Desktop), so ask Windows for it.
|
|
1589
|
+
const desk = (await Bun.$`${powershellExe()} -NoProfile -Command [Environment]::GetFolderPath('Desktop')`.quiet().nothrow().text()).trim();
|
|
1590
|
+
const lnk = join(desk || join(home, "Desktop"), "Kaizen.lnk");
|
|
1522
1591
|
const ico = join(dirname(import.meta.dir), "assets", "kaizen.ico");
|
|
1523
1592
|
const vbs = join(home, ".kaizen", "kaizen-web.vbs");
|
|
1524
1593
|
mkdirSync(dirname(vbs), { recursive: true });
|
package/package.json
CHANGED
|
@@ -159,6 +159,10 @@ board:
|
|
|
159
159
|
# Where `kaizen web` opens the board: browser (a tab in your default browser) or
|
|
160
160
|
# app (a Chrome, Edge or Brave window with no tabs or address bar).
|
|
161
161
|
open: browser
|
|
162
|
+
# The key that opens and closes `kaizen chat`, the popup chat window. kaizen
|
|
163
|
+
# writes it into your Hyprland config (bindings.lua or hyprland.conf), taking the
|
|
164
|
+
# key over from whatever held it. Empty: no hotkey. Hyprland only for now.
|
|
165
|
+
chat_hotkey: "SUPER + ALT + SPACE"
|
|
162
166
|
|
|
163
167
|
sources:
|
|
164
168
|
# How often the web board checks your request sources (links added in the board's
|
package/web/board/home.ts
CHANGED
|
@@ -82,7 +82,7 @@ function chips() {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function list() {
|
|
85
|
-
return html`<div class="hsin"><div class="hshd"><span>Chats</span
|
|
85
|
+
return html`<div class="hsin"><div class="hshd"><span>Chats</span></div><nav class="hlist" aria-label="Chats">${chats.map((c) => html`<div class="hli${cur && cur.id === c.id ? " on" : ""}"><button data-c="${c.id}" title="${c.title}">${c.busy ? html`<span class="dot"></span>` : ""}<span class="ht">${c.title}</span><span class="hp">${c.project ? name(c.project) : "No project"}</span></button><button class="ib sm" data-del="${c.id}" aria-label="Delete chat: ${c.title}" title="Delete chat">${ico("trash")}</button></div>`)}</nav></div>`;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function bindReply(root) {
|
|
@@ -184,7 +184,6 @@ function draw() {
|
|
|
184
184
|
seen = empty ? 0 : cur.messages.length;
|
|
185
185
|
shown = cur && cur.id;
|
|
186
186
|
$("htog").onclick = () => setSide(!side);
|
|
187
|
-
$("hclose").onclick = () => setSide(false);
|
|
188
187
|
$("hscrim").onclick = () => setSide(false);
|
|
189
188
|
const q = $("hq");
|
|
190
189
|
renderAttachments();
|
|
@@ -212,6 +211,11 @@ function draw() {
|
|
|
212
211
|
};
|
|
213
212
|
syncSendButton();
|
|
214
213
|
$("hnewtop").onclick = newChat;
|
|
214
|
+
// Pop out: `kaizen chat` opens the popup on this chat and hides this window.
|
|
215
|
+
$("hpop").onclick = () =>
|
|
216
|
+
fetch("/popup/open", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ id: cur?.id }) })
|
|
217
|
+
.then((r) => r.ok || toast("Could not open the popup"))
|
|
218
|
+
.catch(() => toast("Could not open the popup"));
|
|
215
219
|
$("hnewtop").disabled = sending;
|
|
216
220
|
bindChatItems(h);
|
|
217
221
|
h.querySelectorAll("[data-s]").forEach(
|
|
@@ -389,6 +393,18 @@ export async function openHome() {
|
|
|
389
393
|
else { remember(null); draw(); }
|
|
390
394
|
}
|
|
391
395
|
|
|
396
|
+
// Back from the popup (`kaizen chat`): the server brings this window back and hands
|
|
397
|
+
// over the chat the popup was on; Home opens it. A browser window coming back from a
|
|
398
|
+
// hidden Hyprland workspace fires no focus event, so Home asks every 1.5 s.
|
|
399
|
+
async function takeHandoff() {
|
|
400
|
+
const r = await fetch("/popup/handoff").then((r) => r.json()).catch(() => null);
|
|
401
|
+
if (!r?.id) return;
|
|
402
|
+
await refreshChats();
|
|
403
|
+
if (chats.some((c) => c.id === r.id)) await show(r.id);
|
|
404
|
+
}
|
|
405
|
+
// ponytail: polling; push it through the board's state stream if this ever costs anything.
|
|
406
|
+
if (typeof document !== "undefined") setInterval(() => globalThis.document?.body?.classList.contains("homev") && takeHandoff(), 1500);
|
|
407
|
+
|
|
392
408
|
// A project picked above: a new chat's greeting names it. Only then: a redraw replays the greeting's entrance.
|
|
393
409
|
let greeted;
|
|
394
410
|
addEventListener("kz-state", () => {
|