@netnodeag/kraftwerk 0.97.0 → 0.99.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 +29 -0
- package/dist/cli/boards.js +69 -20
- package/dist/client/routes.d.ts +11 -0
- package/dist/client/routes.js +11 -0
- package/dist/core/boards.d.ts +6 -0
- package/dist/core/boards.js +22 -3
- package/dist/server/api/boards.d.ts +15 -3
- package/dist/server/api/boards.js +61 -18
- package/dist/server/api/index.d.ts +79 -3
- package/dist/server/api/index.js +2 -0
- package/dist/server/api/remote-boards.d.ts +118 -0
- package/dist/server/api/remote-boards.js +51 -0
- package/dist/server/cloud-boards.d.ts +79 -0
- package/dist/server/cloud-boards.js +200 -0
- package/dist/server/remote-boards.d.ts +37 -0
- package/dist/server/remote-boards.js +87 -0
- package/package.json +1 -1
- package/web/dist/assets/{dist-lcPkaK4d.js → dist-BRxqHunp.js} +1 -1
- package/web/dist/assets/{dist-D_uWSMLk.js → dist-BXFsZFyR.js} +1 -1
- package/web/dist/assets/{dist-BD4ooe-Y.js → dist-CLgsXxq9.js} +1 -1
- package/web/dist/assets/{dist-BduOHHOY.js → dist-CRwoZ0QP.js} +1 -1
- package/web/dist/assets/{dist-P7JCq9c3.js → dist-CZyarE8b.js} +1 -1
- package/web/dist/assets/{dist-oRcLByHn.js → dist-DAw93zvk.js} +1 -1
- package/web/dist/assets/{dist-BoajTxbz.js → dist-DIla3sxz.js} +1 -1
- package/web/dist/assets/{dist-DJACzcZZ.js → dist-MYpSAhEK.js} +1 -1
- package/web/dist/assets/{dist-DGLb7wE6.js → dist-Ntegnq0p.js} +1 -1
- package/web/dist/assets/dist-Whol13-K.js +1 -0
- package/web/dist/assets/{dist-DY6QplYX.js → dist-trHwQ1EL.js} +1 -1
- package/web/dist/assets/{editor-hTceN7Iz.js → editor-BIPcwrnh.js} +3 -3
- package/web/dist/assets/{index-BOkjCxut.js → index-DbBIKEeD.js} +121 -121
- package/web/dist/index.html +1 -1
- package/web/dist/assets/dist-ajNgHt2Q.js +0 -1
package/README.md
CHANGED
|
@@ -565,6 +565,35 @@ An API caller cannot name another person: a `human:…` actor in a request
|
|
|
565
565
|
body is replaced by whoever asks. Agents and processes still name
|
|
566
566
|
themselves (`lisa/claude`, `process:sync`).
|
|
567
567
|
|
|
568
|
+
### Single player and multiplayer: local and cloud boards
|
|
569
|
+
|
|
570
|
+
Local boards (files under `kraftwerk-data/boards`) are single player: a
|
|
571
|
+
task goes to an agent or to yourself (`human:<handle>`, the person
|
|
572
|
+
`GET /api/me` names), and a person is never woken.
|
|
573
|
+
|
|
574
|
+
Cloud boards are multiplayer. They live in kraftwerk cloud, belong to the
|
|
575
|
+
workspace's `id:`, and everyone on the workspace sees and edits them, from
|
|
576
|
+
their own machine or the cloud's web app (`/w/<ws id>`). A task goes to
|
|
577
|
+
anyone on the workspace or to an agent. They never sync with local boards.
|
|
578
|
+
|
|
579
|
+
Here they are boards like any other, with a cloud mark: on Home, in the
|
|
580
|
+
boards page, on a task's page beside its chat. Pick "kraftwerk cloud" when
|
|
581
|
+
you make a board. A cloud board's slug starts with `@`, so the same API
|
|
582
|
+
(`/api/boards/@launch/tasks/3`) and the same commands
|
|
583
|
+
(`kraftwerk tasks show 3 --board @launch`) work on it. A cloud task has no
|
|
584
|
+
folder and no files; a cloud board has no default agent, rules or project
|
|
585
|
+
links. `/api/remote-boards/…` speaks the cloud's own shapes. Calls go to
|
|
586
|
+
the cloud as the caller:
|
|
587
|
+
|
|
588
|
+
- A signed-in browser (`users: cloud`) acts as its person.
|
|
589
|
+
- Everything else on the machine acts as the account that claimed it.
|
|
590
|
+
- An agent names itself with `actor`.
|
|
591
|
+
|
|
592
|
+
The cloud lets a machine act only for that account and for people who
|
|
593
|
+
signed in to its UI. Offline is offline: while the cloud does not answer,
|
|
594
|
+
cloud boards are marked offline and nothing is cached. Agents are not
|
|
595
|
+
woken from a cloud board yet.
|
|
596
|
+
|
|
568
597
|
## Projects
|
|
569
598
|
|
|
570
599
|
Turn on `projects:` in `kraftwerk.yml` (or the checkbox in settings) and
|
package/dist/cli/boards.js
CHANGED
|
@@ -6,6 +6,8 @@ import { taskSessions } from "../core/board-wake.js";
|
|
|
6
6
|
import { initContext as prepare } from "./routines.js";
|
|
7
7
|
import { fmtAgo } from "./workspaces.js";
|
|
8
8
|
import { actorFor } from "../core/person.js";
|
|
9
|
+
import { resolveWorkspace, workspaceSlug } from "../config.js";
|
|
10
|
+
import { findDaemon } from "../core/daemon.js";
|
|
9
11
|
/**
|
|
10
12
|
* `kraftwerk boards` and `kraftwerk tasks` — the boards (columns of tasks)
|
|
11
13
|
* of a project or of the workspace, and the tasks on them. The same module
|
|
@@ -31,7 +33,9 @@ import { actorFor } from "../core/person.js";
|
|
|
31
33
|
* kraftwerk tasks remove <n>
|
|
32
34
|
*
|
|
33
35
|
* --board defaults to the project's `tasks` board (or the only board); the
|
|
34
|
-
* number alone names a task.
|
|
36
|
+
* number alone names a task. A cloud board (`--board @launch`, kept in
|
|
37
|
+
* kraftwerk cloud, server/cloud-boards.ts) is reached through the running
|
|
38
|
+
* daemon, which asks the cloud for this machine; the same commands work.
|
|
35
39
|
*/
|
|
36
40
|
const die = (msg) => {
|
|
37
41
|
console.error(chalk.red(msg));
|
|
@@ -65,6 +69,26 @@ async function whereOf(w, create = false) {
|
|
|
65
69
|
die(`no board ${project ? `in project ${project}` : "in the workspace"} yet — \`kraftwerk boards create "<title>"${project ? ` --project ${project}` : ""}\` makes one`);
|
|
66
70
|
return die(`several boards here (${view.boards.map((b) => b.board).join(", ")}) — say which with --board`);
|
|
67
71
|
}
|
|
72
|
+
/** A cloud board: `@<slug>`. */
|
|
73
|
+
const isCloud = (w) => !!w.board?.trim().startsWith("@");
|
|
74
|
+
/** The boards API of this workspace on the running daemon — the way to a cloud board. */
|
|
75
|
+
async function cloudApi(method, route, body) {
|
|
76
|
+
const ws = await resolveWorkspace(process.cwd());
|
|
77
|
+
const daemon = await findDaemon();
|
|
78
|
+
if (!daemon)
|
|
79
|
+
die("cloud boards go through the daemon, and it is not running — `kraftwerk daemon start`");
|
|
80
|
+
const r = await fetch(`http://127.0.0.1:${daemon.port}/w/${encodeURIComponent(workspaceSlug(ws))}${route}`, {
|
|
81
|
+
method,
|
|
82
|
+
headers: body !== undefined ? { "content-type": "application/json" } : {},
|
|
83
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
84
|
+
signal: AbortSignal.timeout(20_000),
|
|
85
|
+
}).catch((err) => die(`the daemon did not answer: ${err.message}`));
|
|
86
|
+
const data = (await r.json().catch(() => ({})));
|
|
87
|
+
if (!r.ok)
|
|
88
|
+
die(data.error ?? `${r.status} from the daemon`);
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
91
|
+
const cloudTask = (w, task, rest = "") => `/api/boards/${encodeURIComponent(w.board.trim())}/tasks/${encodeURIComponent(task)}${rest}`;
|
|
68
92
|
const flags = (ref) => (ref.project ? `--project ${ref.project} --board ${ref.board}` : `--board ${ref.board}`);
|
|
69
93
|
function taskRow(t) {
|
|
70
94
|
return [
|
|
@@ -83,7 +107,7 @@ function printBoard(b) {
|
|
|
83
107
|
console.log(chalk.red(`board.md: ${b.configError}`));
|
|
84
108
|
if (b.notes.trim())
|
|
85
109
|
console.log(b.notes.trim());
|
|
86
|
-
console.log(chalk.dim(b.path));
|
|
110
|
+
console.log(chalk.dim(b.cloud ? "a cloud board (kraftwerk cloud), shared with everyone on the workspace" : b.path));
|
|
87
111
|
for (const c of b.columns) {
|
|
88
112
|
const items = b.items.filter((t) => t.status === c.slug);
|
|
89
113
|
console.log(`\n${chalk.bold(c.label)} ${chalk.dim(`(${items.length}${c.limit ? `/${c.limit}` : ""}${c.review ? ", review" : c.done ? ", done" : ""})`)}`);
|
|
@@ -102,7 +126,7 @@ function printTask(t) {
|
|
|
102
126
|
console.log(`${t.status}${t.assignee ? ` · ${t.assignee}` : " · unassigned"}${t.due ? ` · due ${t.due}` : ""}${t.tags.length ? ` · ${t.tags.join(", ")}` : ""}${t.stale ? chalk.yellow(" · stale") : ""}`);
|
|
103
127
|
if (t.refs.length)
|
|
104
128
|
console.log(chalk.dim(`refs: ${t.refs.join(", ")}`));
|
|
105
|
-
console.log(chalk.dim(`folder: ${t.path}`));
|
|
129
|
+
console.log(chalk.dim(t.cloud ? "on a cloud board (kraftwerk cloud) — no folder" : `folder: ${t.path}`));
|
|
106
130
|
const sessions = t.sessions ?? [];
|
|
107
131
|
if (sessions.length)
|
|
108
132
|
console.log(chalk.dim(`sessions: ${sessions.map((s) => `${s.emoji ? `${s.emoji} ` : ""}${s.name ?? s.agent} ${s.id}${s.busy ? " (working)" : ""}`).join(", ")}`));
|
|
@@ -110,9 +134,11 @@ function printTask(t) {
|
|
|
110
134
|
console.log(chalk.red(`task.md: ${t.configError}`));
|
|
111
135
|
if (t.notes.trim())
|
|
112
136
|
console.log(`\n${t.notes.trim()}`);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
137
|
+
if (!t.cloud) {
|
|
138
|
+
console.log(`\n${chalk.bold("files")}${t.fileList.length ? "" : chalk.dim(" (none)")}`);
|
|
139
|
+
for (const f of t.fileList)
|
|
140
|
+
console.log(` ${f}`);
|
|
141
|
+
}
|
|
116
142
|
if (t.log.trim())
|
|
117
143
|
console.log(`\n${chalk.bold("log")}\n${t.log.trim()}`);
|
|
118
144
|
}
|
|
@@ -161,7 +187,7 @@ export function registerBoardCommands(program) {
|
|
|
161
187
|
.action(async (board, opts) => {
|
|
162
188
|
await prepare();
|
|
163
189
|
try {
|
|
164
|
-
const b = await getBoard({ ...(opts.project ? { project: opts.project } : {}), board });
|
|
190
|
+
const b = board.startsWith("@") ? await cloudApi("GET", `/api/boards/${encodeURIComponent(board)}`) : await getBoard({ ...(opts.project ? { project: opts.project } : {}), board });
|
|
165
191
|
if (!b)
|
|
166
192
|
die(`no board "${board}"`);
|
|
167
193
|
if (opts.json)
|
|
@@ -258,8 +284,8 @@ export function registerBoardCommands(program) {
|
|
|
258
284
|
.action(async (opts) => {
|
|
259
285
|
await prepare();
|
|
260
286
|
try {
|
|
261
|
-
const ref = await whereOf(opts);
|
|
262
|
-
const b = await getBoard(ref);
|
|
287
|
+
const ref = isCloud(opts) ? { board: opts.board.trim() } : await whereOf(opts);
|
|
288
|
+
const b = isCloud(opts) ? await cloudApi("GET", `/api/boards/${encodeURIComponent(ref.board)}`) : await getBoard(ref);
|
|
263
289
|
if (!b)
|
|
264
290
|
die(`no board "${ref.board}"`);
|
|
265
291
|
const me = opts.mine ? agentOf(opts.as) || die("--mine needs --as <agent> outside an agent session") : undefined;
|
|
@@ -289,6 +315,14 @@ export function registerBoardCommands(program) {
|
|
|
289
315
|
.action(async (task, opts) => {
|
|
290
316
|
await prepare();
|
|
291
317
|
try {
|
|
318
|
+
if (isCloud(opts)) {
|
|
319
|
+
const t = await cloudApi("GET", cloudTask(opts, task));
|
|
320
|
+
if (opts.json)
|
|
321
|
+
console.log(JSON.stringify(t, null, 2));
|
|
322
|
+
else
|
|
323
|
+
printTask(t);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
292
326
|
const found = await getTask(await whereOf(opts), task);
|
|
293
327
|
if (!found)
|
|
294
328
|
die(`no task "${task}"`);
|
|
@@ -318,8 +352,7 @@ export function registerBoardCommands(program) {
|
|
|
318
352
|
.action(async (title, opts) => {
|
|
319
353
|
await prepare();
|
|
320
354
|
try {
|
|
321
|
-
const
|
|
322
|
-
const t = await createTask(ref, {
|
|
355
|
+
const input = {
|
|
323
356
|
title,
|
|
324
357
|
status: opts.status,
|
|
325
358
|
assignee: opts.assign,
|
|
@@ -329,11 +362,14 @@ export function registerBoardCommands(program) {
|
|
|
329
362
|
notes: opts.file ? await readFile(opts.file, "utf8") : opts.notes,
|
|
330
363
|
actor: actorOf(opts.actor),
|
|
331
364
|
message: opts.message,
|
|
332
|
-
}
|
|
365
|
+
};
|
|
366
|
+
const t = isCloud(opts)
|
|
367
|
+
? await cloudApi("POST", `/api/boards/${encodeURIComponent(opts.board.trim())}/tasks`, { ...input, tags: input.tags?.split(",").map((x) => x.trim()).filter(Boolean), refs: undefined })
|
|
368
|
+
: await createTask(await whereOf(opts, true), input);
|
|
333
369
|
if (opts.json)
|
|
334
370
|
console.log(JSON.stringify(t, null, 2));
|
|
335
371
|
else
|
|
336
|
-
console.log(`${chalk.green("✔")} ${chalk.cyan(String(t.number))} ${t.title} ${chalk.dim(`(${t.status}${t.assignee ? `, ${t.assignee}` : ""}) → ${t.path}`)}`);
|
|
372
|
+
console.log(`${chalk.green("✔")} ${chalk.cyan(String(t.number))} ${t.title} ${chalk.dim(`(${t.status}${t.assignee ? `, ${t.assignee}` : ""}) → ${t.path || t.ref}`)}`);
|
|
337
373
|
}
|
|
338
374
|
catch (err) {
|
|
339
375
|
die(err.message);
|
|
@@ -361,7 +397,9 @@ export function registerBoardCommands(program) {
|
|
|
361
397
|
};
|
|
362
398
|
if (Object.keys(input).length === 0)
|
|
363
399
|
die("nothing to set — pass --title, --due, --tags, --refs or --notes-file");
|
|
364
|
-
const t =
|
|
400
|
+
const t = isCloud(opts)
|
|
401
|
+
? await cloudApi("PUT", cloudTask(opts, task), { ...input, ...(typeof input.tags === "string" ? { tags: input.tags.split(",").map((x) => x.trim()).filter(Boolean) } : {}), refs: undefined, actor: actorOf(opts.actor) })
|
|
402
|
+
: await saveTask(await whereOf(opts), task, input, { actor: actorOf(opts.actor) });
|
|
365
403
|
if (opts.json)
|
|
366
404
|
console.log(JSON.stringify(t, null, 2));
|
|
367
405
|
else
|
|
@@ -381,7 +419,9 @@ export function registerBoardCommands(program) {
|
|
|
381
419
|
.action(async (task, column, opts) => {
|
|
382
420
|
await prepare();
|
|
383
421
|
try {
|
|
384
|
-
const t =
|
|
422
|
+
const t = isCloud(opts)
|
|
423
|
+
? await cloudApi("POST", cloudTask(opts, task, "/move"), { status: column, message: opts.message, actor: actorOf(opts.actor) })
|
|
424
|
+
: await moveTask(await whereOf(opts), task, column, { message: opts.message, actor: actorOf(opts.actor) });
|
|
385
425
|
if (opts.json)
|
|
386
426
|
console.log(JSON.stringify(t, null, 2));
|
|
387
427
|
else
|
|
@@ -405,7 +445,9 @@ export function registerBoardCommands(program) {
|
|
|
405
445
|
if (!to)
|
|
406
446
|
die('say who: `tasks assign <n> <agent>` or `--to human`');
|
|
407
447
|
try {
|
|
408
|
-
const t =
|
|
448
|
+
const t = isCloud(opts)
|
|
449
|
+
? await cloudApi("POST", cloudTask(opts, task, "/assign"), { to: to === "human" ? null : to, message: opts.message, actor: actorOf(opts.actor) })
|
|
450
|
+
: await assignTask(await whereOf(opts), task, to === "human" ? null : to, { message: opts.message, actor: actorOf(opts.actor) });
|
|
409
451
|
if (opts.json)
|
|
410
452
|
console.log(JSON.stringify(t, null, 2));
|
|
411
453
|
else
|
|
@@ -425,9 +467,10 @@ export function registerBoardCommands(program) {
|
|
|
425
467
|
.action(async (task, entry, opts) => {
|
|
426
468
|
await prepare();
|
|
427
469
|
try {
|
|
428
|
-
const
|
|
470
|
+
const cloudBoard = isCloud(opts);
|
|
471
|
+
const ref = cloudBoard ? { board: opts.board.trim() } : await whereOf(opts);
|
|
429
472
|
if (opts.tail !== undefined) {
|
|
430
|
-
const t = await getTask(ref, task);
|
|
473
|
+
const t = cloudBoard ? await cloudApi("GET", cloudTask(opts, task)) : await getTask(ref, task);
|
|
431
474
|
if (!t)
|
|
432
475
|
die(`no task "${task}"`);
|
|
433
476
|
const n = Number(opts.tail) || 5;
|
|
@@ -439,7 +482,7 @@ export function registerBoardCommands(program) {
|
|
|
439
482
|
return;
|
|
440
483
|
}
|
|
441
484
|
const text = opts.file ? await readFile(opts.file, "utf8") : entry ?? "";
|
|
442
|
-
const t = await appendTaskLog(ref, task, text, actorOf(opts.actor));
|
|
485
|
+
const t = cloudBoard ? await cloudApi("POST", cloudTask(opts, task, "/log"), { entry: text, actor: actorOf(opts.actor) }) : await appendTaskLog(ref, task, text, actorOf(opts.actor));
|
|
443
486
|
console.log(`${chalk.green("✔")} logged on ${chalk.cyan(String(t.number))} ${chalk.dim(`(${await actorFor(actorOf(opts.actor))})`)}`);
|
|
444
487
|
}
|
|
445
488
|
catch (err) {
|
|
@@ -457,7 +500,9 @@ export function registerBoardCommands(program) {
|
|
|
457
500
|
if (!agent)
|
|
458
501
|
die("who picks? pass --as <agent> (inside an agent session KRAFTWERK_AGENT is set)");
|
|
459
502
|
try {
|
|
460
|
-
const t =
|
|
503
|
+
const t = isCloud(opts)
|
|
504
|
+
? (await cloudApi("POST", `/api/boards/${encodeURIComponent(opts.board.trim())}/pick`, { agent, ...(opts.column ? { column: opts.column } : {}) })).task
|
|
505
|
+
: await pickTask(await whereOf(opts), agent, { column: opts.column, actor: process.env.KRAFTWERK_ACTOR || agent });
|
|
461
506
|
if (!t) {
|
|
462
507
|
if (opts.json)
|
|
463
508
|
console.log("null");
|
|
@@ -482,6 +527,10 @@ export function registerBoardCommands(program) {
|
|
|
482
527
|
.action(async (task, opts) => {
|
|
483
528
|
await prepare();
|
|
484
529
|
try {
|
|
530
|
+
if (isCloud(opts)) {
|
|
531
|
+
await cloudApi("DELETE", cloudTask(opts, task));
|
|
532
|
+
return void console.log(`${chalk.green("✔")} deleted task ${chalk.cyan(task)} from the cloud board`);
|
|
533
|
+
}
|
|
485
534
|
await deleteTask(await whereOf(opts), task);
|
|
486
535
|
console.log(`${chalk.green("✔")} moved task ${chalk.cyan(task)} to the trash`);
|
|
487
536
|
}
|
package/dist/client/routes.d.ts
CHANGED
|
@@ -140,6 +140,17 @@ export declare const ROUTES: {
|
|
|
140
140
|
readonly "projects.saveLayout": readonly ["PUT", "/api/projects"];
|
|
141
141
|
readonly "protocol.get": readonly ["GET", "/api/protocol"];
|
|
142
142
|
readonly "refs.resolve": readonly ["POST", "/api/refs/resolve"];
|
|
143
|
+
readonly "remoteBoards.create": readonly ["POST", "/api/remote-boards"];
|
|
144
|
+
readonly "remoteBoards.delete": readonly ["DELETE", "/api/remote-boards/:board"];
|
|
145
|
+
readonly "remoteBoards.get": readonly ["GET", "/api/remote-boards/:board"];
|
|
146
|
+
readonly "remoteBoards.list": readonly ["GET", "/api/remote-boards"];
|
|
147
|
+
readonly "remoteBoards.people": readonly ["GET", "/api/remote-boards/people"];
|
|
148
|
+
readonly "remoteBoards.save": readonly ["PUT", "/api/remote-boards/:board"];
|
|
149
|
+
readonly "remoteTasks.create": readonly ["POST", "/api/remote-boards/:board/tasks"];
|
|
150
|
+
readonly "remoteTasks.delete": readonly ["DELETE", "/api/remote-boards/:board/tasks/:task"];
|
|
151
|
+
readonly "remoteTasks.get": readonly ["GET", "/api/remote-boards/:board/tasks/:task"];
|
|
152
|
+
readonly "remoteTasks.log": readonly ["POST", "/api/remote-boards/:board/tasks/:task/log"];
|
|
153
|
+
readonly "remoteTasks.save": readonly ["PUT", "/api/remote-boards/:board/tasks/:task"];
|
|
143
154
|
readonly "repos.add": readonly ["POST", "/api/repos"];
|
|
144
155
|
readonly "repos.commit": readonly ["GET", "/api/repos/:slug/commits/:hash"];
|
|
145
156
|
readonly "repos.diff": readonly ["GET", "/api/repos/:slug/diff"];
|
package/dist/client/routes.js
CHANGED
|
@@ -141,6 +141,17 @@ export const ROUTES = {
|
|
|
141
141
|
"projects.saveLayout": ["PUT", "/api/projects"],
|
|
142
142
|
"protocol.get": ["GET", "/api/protocol"],
|
|
143
143
|
"refs.resolve": ["POST", "/api/refs/resolve"],
|
|
144
|
+
"remoteBoards.create": ["POST", "/api/remote-boards"],
|
|
145
|
+
"remoteBoards.delete": ["DELETE", "/api/remote-boards/:board"],
|
|
146
|
+
"remoteBoards.get": ["GET", "/api/remote-boards/:board"],
|
|
147
|
+
"remoteBoards.list": ["GET", "/api/remote-boards"],
|
|
148
|
+
"remoteBoards.people": ["GET", "/api/remote-boards/people"],
|
|
149
|
+
"remoteBoards.save": ["PUT", "/api/remote-boards/:board"],
|
|
150
|
+
"remoteTasks.create": ["POST", "/api/remote-boards/:board/tasks"],
|
|
151
|
+
"remoteTasks.delete": ["DELETE", "/api/remote-boards/:board/tasks/:task"],
|
|
152
|
+
"remoteTasks.get": ["GET", "/api/remote-boards/:board/tasks/:task"],
|
|
153
|
+
"remoteTasks.log": ["POST", "/api/remote-boards/:board/tasks/:task/log"],
|
|
154
|
+
"remoteTasks.save": ["PUT", "/api/remote-boards/:board/tasks/:task"],
|
|
144
155
|
"repos.add": ["POST", "/api/repos"],
|
|
145
156
|
"repos.commit": ["GET", "/api/repos/:slug/commits/:hash"],
|
|
146
157
|
"repos.diff": ["GET", "/api/repos/:slug/diff"],
|
package/dist/core/boards.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export interface BoardSummary extends BoardDef {
|
|
|
71
71
|
tasks: number;
|
|
72
72
|
/** Tasks in a review column. */
|
|
73
73
|
review: number;
|
|
74
|
+
/** A cloud board (server/cloud-boards.ts): kept in kraftwerk cloud, `board` is "@<slug>", no folder. */
|
|
75
|
+
cloud?: true;
|
|
74
76
|
}
|
|
75
77
|
export interface BoardDetail extends BoardSummary {
|
|
76
78
|
/** The body of board.md: what the board is for, the rules agents follow. */
|
|
@@ -108,6 +110,8 @@ export interface TaskSummary extends TaskDef {
|
|
|
108
110
|
lastLog?: string;
|
|
109
111
|
/** In a work column with an assignee and nothing logged for staleAfter. */
|
|
110
112
|
stale?: boolean;
|
|
113
|
+
/** On a cloud board: no folder, no files. */
|
|
114
|
+
cloud?: true;
|
|
111
115
|
}
|
|
112
116
|
export interface TaskDetail extends TaskSummary {
|
|
113
117
|
/** The body of task.md. */
|
|
@@ -178,6 +182,8 @@ export declare function parseTaskRef(text: string): {
|
|
|
178
182
|
export declare function parseBoardRef(text: string): BoardRef;
|
|
179
183
|
/** "1d", "12h", "90m" -> milliseconds. */
|
|
180
184
|
export declare function parseDuration(text: string): number;
|
|
185
|
+
/** A person as assignee: `human:<handle>`, the same form logs sign human changes with. */
|
|
186
|
+
export declare const isHumanAssignee: (a: string | undefined | null) => a is string;
|
|
181
187
|
/** The column `tasks pick` takes from: "todo" when the board has it, else the second column (the first is the inbox), else the only one. */
|
|
182
188
|
export declare const pickColumn: (columns: Column[]) => Column | undefined;
|
|
183
189
|
/** A column's role: work columns — from the pick column on, review and done excepted — are where an assigned agent is expected to act. */
|
package/dist/core/boards.js
CHANGED
|
@@ -10,6 +10,7 @@ import { openProjects, safeProjectSlug } from "./projects.js";
|
|
|
10
10
|
import { findRefs, resolveTokens } from "./refs.js";
|
|
11
11
|
import { SLUG_RE, slugify } from "./slug.js";
|
|
12
12
|
import { moveToTrash } from "./trash.js";
|
|
13
|
+
import { IDENTITY_PART_RE } from "./identity.js";
|
|
13
14
|
import { actorFor } from "./person.js";
|
|
14
15
|
/**
|
|
15
16
|
* Boards and tasks: the work of a project (or of the whole workspace) as
|
|
@@ -178,6 +179,23 @@ const cleanAgentSlug = (v) => {
|
|
|
178
179
|
throw new Error("agent must be an agent slug");
|
|
179
180
|
return v.trim();
|
|
180
181
|
};
|
|
182
|
+
/** A person as assignee: `human:<handle>`, the same form logs sign human changes with. */
|
|
183
|
+
export const isHumanAssignee = (a) => !!a && a.startsWith("human:");
|
|
184
|
+
/** An assignee is an agent slug or a person (`human:<handle>`); a person is never woken. */
|
|
185
|
+
const cleanAssignee = (v) => {
|
|
186
|
+
if (typeof v === "string" && v.trim().startsWith("human:")) {
|
|
187
|
+
const handle = v.trim().slice("human:".length);
|
|
188
|
+
if (!IDENTITY_PART_RE.test(handle))
|
|
189
|
+
throw new Error(`assignee "${v.trim()}" must be an agent slug or human:<handle>`);
|
|
190
|
+
return `human:${handle}`;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
return cleanAgentSlug(v);
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
throw new Error(`assignee must be an agent slug or human:<handle>, not "${String(v)}"`);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
181
199
|
/** Split a Markdown file into its frontmatter text and body (same rule as entities.ts). */
|
|
182
200
|
function splitFrontmatter(raw) {
|
|
183
201
|
if (!raw.startsWith("---"))
|
|
@@ -307,7 +325,7 @@ function parseTask(slug, data, columns) {
|
|
|
307
325
|
if (!Number.isFinite(order))
|
|
308
326
|
throw new Error("order must be a number");
|
|
309
327
|
const def = { slug, number, title, status, order, created: cleanDate(data.created, "created") ?? "", tags: strList(data.tags, "tags"), refs: strList(data.refs, "refs") };
|
|
310
|
-
const assignee =
|
|
328
|
+
const assignee = cleanAssignee(data.assignee);
|
|
311
329
|
if (assignee)
|
|
312
330
|
def.assignee = assignee;
|
|
313
331
|
const due = cleanDate(data.due, "due");
|
|
@@ -694,7 +712,8 @@ async function emitTaskEvent(ev) {
|
|
|
694
712
|
/** After a write: wake the assignee when the (assignee, status) pair changed into "an agent in a work column". */
|
|
695
713
|
async function maybeEmit(ref, board, before, after, reason, actor, message) {
|
|
696
714
|
const col = board.columns.find((c) => c.slug === after.status);
|
|
697
|
-
|
|
715
|
+
// A person works on their own: only agents are woken.
|
|
716
|
+
if (!after.assignee || isHumanAssignee(after.assignee) || !isWorkColumn(col, board.columns))
|
|
698
717
|
return;
|
|
699
718
|
if (before && before.assignee === after.assignee && before.status === after.status)
|
|
700
719
|
return;
|
|
@@ -743,7 +762,7 @@ function applyInput(def, input, board) {
|
|
|
743
762
|
next.order = Number(input.order);
|
|
744
763
|
}
|
|
745
764
|
if (input.assignee !== undefined) {
|
|
746
|
-
const a =
|
|
765
|
+
const a = cleanAssignee(input.assignee ?? undefined);
|
|
747
766
|
if (a)
|
|
748
767
|
next.assignee = a;
|
|
749
768
|
else
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
+
import * as cloud from "../cloud-boards.js";
|
|
2
3
|
/**
|
|
3
4
|
* Boards and tasks over the API. A board is addressed by its slug and, for
|
|
4
5
|
* a project's board, `?project=<slug>`; a task by its folder name or its
|
|
@@ -6,7 +7,7 @@ import * as z from "zod";
|
|
|
6
7
|
* on the task and may wake the assignee (core/board-wake.ts).
|
|
7
8
|
*/
|
|
8
9
|
export declare const boardErrors: (message: string) => number;
|
|
9
|
-
export declare const boardRoutes: (import("./router.js").Route<"boards.create", import("./router.js").Reply<import("../../core/boards.js").
|
|
10
|
+
export declare const boardRoutes: (import("./router.js").Route<"boards.create", import("./router.js").Reply<import("../../core/boards.js").BoardSummary & cloud.CloudMark>, "/api/boards", z.ZodObject<{
|
|
10
11
|
title: z.ZodString;
|
|
11
12
|
slug: z.ZodOptional<z.ZodString>;
|
|
12
13
|
project: z.ZodOptional<z.ZodString>;
|
|
@@ -19,11 +20,21 @@ export declare const boardRoutes: (import("./router.js").Route<"boards.create",
|
|
|
19
20
|
}, z.core.$strip>]>>>;
|
|
20
21
|
agent: z.ZodOptional<z.ZodString>;
|
|
21
22
|
notes: z.ZodOptional<z.ZodString>;
|
|
23
|
+
cloud: z.ZodOptional<z.ZodBoolean>;
|
|
22
24
|
}, z.core.$strip>> | import("./router.js").Route<"boards.delete", {
|
|
23
25
|
ok: boolean;
|
|
24
26
|
}, "/api/boards/:board", undefined> | import("./router.js").Route<"boards.ensure", import("../../core/boards.js").BoardDetail, "/api/boards/default", z.ZodObject<{
|
|
25
27
|
project: z.ZodOptional<z.ZodString>;
|
|
26
|
-
}, z.core.$strip>> | import("./router.js").Route<"boards.get", import("../../core/boards.js").BoardDetail, "/api/boards/:board", undefined> | import("./router.js").Route<"boards.list", import("../../core/boards.js").BoardsView
|
|
28
|
+
}, z.core.$strip>> | import("./router.js").Route<"boards.get", import("../../core/boards.js").BoardDetail, "/api/boards/:board", undefined> | import("./router.js").Route<"boards.list", import("../../core/boards.js").BoardsView | {
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
root?: string;
|
|
31
|
+
error?: string;
|
|
32
|
+
boards: import("../../core/boards.js").BoardSummary[];
|
|
33
|
+
cloud: {
|
|
34
|
+
offline?: boolean | undefined;
|
|
35
|
+
error?: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
}, "/api/boards", undefined> | import("./router.js").Route<"boards.save", import("../../core/boards.js").BoardSummary & cloud.CloudMark, "/api/boards/:board", z.ZodObject<{
|
|
27
38
|
title: z.ZodOptional<z.ZodString>;
|
|
28
39
|
columns: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
29
40
|
slug: z.ZodString;
|
|
@@ -72,6 +83,7 @@ export declare const boardRoutes: (import("./router.js").Route<"boards.create",
|
|
|
72
83
|
files: number;
|
|
73
84
|
lastLog?: string;
|
|
74
85
|
stale?: boolean;
|
|
86
|
+
cloud?: true;
|
|
75
87
|
notes: string;
|
|
76
88
|
log: string;
|
|
77
89
|
fileList: string[];
|
|
@@ -90,7 +102,7 @@ export declare const boardRoutes: (import("./router.js").Route<"boards.create",
|
|
|
90
102
|
message: z.ZodOptional<z.ZodString>;
|
|
91
103
|
actor: z.ZodOptional<z.ZodString>;
|
|
92
104
|
}, z.core.$strip>> | import("./router.js").Route<"tasks.pick", {
|
|
93
|
-
task: import("../../core/boards.js").TaskDetail | null;
|
|
105
|
+
task: (import("../../core/boards.js").TaskDetail & cloud.CloudMark) | null;
|
|
94
106
|
}, "/api/boards/:board/pick", z.ZodObject<{
|
|
95
107
|
agent: z.ZodString;
|
|
96
108
|
column: z.ZodOptional<z.ZodString>;
|
|
@@ -2,6 +2,7 @@ import * as z from "zod";
|
|
|
2
2
|
import { appendTaskLog, assignTask, createBoard, createTask, deleteBoard, deleteTask, ensureDefaultBoard, getBoard, getTask, listAllBoards, listAllTasks, listBoards, moveTask, openBoards, pickTask, saveBoard, saveTask, } from "../../core/boards.js";
|
|
3
3
|
import { taskSessions } from "../../core/board-wake.js";
|
|
4
4
|
import { fail, reply, route, statusByMessage } from "./router.js";
|
|
5
|
+
import * as cloud from "../cloud-boards.js";
|
|
5
6
|
/**
|
|
6
7
|
* Boards and tasks over the API. A board is addressed by its slug and, for
|
|
7
8
|
* a project's board, `?project=<slug>`; a task by its folder name or its
|
|
@@ -35,17 +36,26 @@ const refOf = (c) => {
|
|
|
35
36
|
const project = c.query.get("project");
|
|
36
37
|
return { ...(project ? { project } : {}), board: c.params.board };
|
|
37
38
|
};
|
|
39
|
+
/** A cloud board (`@<slug>`, server/cloud-boards.ts) — only ever at the workspace level. */
|
|
40
|
+
const onCloud = (c) => cloud.isCloudBoard(c.params.board) && !c.query.get("project");
|
|
38
41
|
const requireOn = async () => {
|
|
39
42
|
if ((await openBoards()).off)
|
|
40
43
|
fail(409, "boards are off");
|
|
41
44
|
};
|
|
42
45
|
export const boardRoutes = [
|
|
43
46
|
route({ name: "boards.list", method: "GET", path: "/api/boards", summary: "the boards: a project's with ?project=, every board with ?all=1, else the workspace's" }, async (c) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
// The workspace's cloud boards follow its local ones (none in a project's list); how the cloud is doing rides along.
|
|
48
|
+
const project = c.query.get("project") ?? undefined;
|
|
49
|
+
const all = c.query.get("all") === "1";
|
|
50
|
+
const [local, remote] = await Promise.all([
|
|
51
|
+
all
|
|
52
|
+
? openBoards().then(async (opened) => ({ enabled: !opened.off && !!opened.root, ...(opened.root ? { root: opened.root } : {}), boards: await listAllBoards(), ...(opened.error ? { error: opened.error } : {}) }))
|
|
53
|
+
: listBoards(project),
|
|
54
|
+
project && !all ? null : cloud.listCloudBoards(c.trust),
|
|
55
|
+
]);
|
|
56
|
+
if (!remote)
|
|
57
|
+
return local;
|
|
58
|
+
return { ...local, boards: [...local.boards, ...remote.boards], cloud: { ...(remote.offline ? { offline: true } : {}), ...(remote.error ? { error: remote.error } : {}) } };
|
|
49
59
|
}),
|
|
50
60
|
route({
|
|
51
61
|
name: "boards.create",
|
|
@@ -53,23 +63,35 @@ export const boardRoutes = [
|
|
|
53
63
|
path: "/api/boards",
|
|
54
64
|
summary: "create a board {title, slug?, project?, columns?, agent?, notes?}",
|
|
55
65
|
errors: boardErrors,
|
|
56
|
-
body: z.object({ title: z.string(), slug: z.string().optional(), project: z.string().optional(), columns: Columns.optional(), agent: z.string().optional(), notes: z.string().optional() }),
|
|
66
|
+
body: z.object({ title: z.string(), slug: z.string().optional(), project: z.string().optional(), columns: Columns.optional(), agent: z.string().optional(), notes: z.string().optional(), cloud: z.boolean().optional() }),
|
|
57
67
|
}, async (c) => {
|
|
68
|
+
const { cloud: inCloud, ...input } = await c.body();
|
|
69
|
+
// In kraftwerk cloud: shared with everyone on the workspace, at the workspace level.
|
|
70
|
+
if (inCloud)
|
|
71
|
+
return reply(201, await cloud.createCloudBoard(c.trust, input));
|
|
58
72
|
await requireOn();
|
|
59
|
-
return reply(201, await createBoard(
|
|
73
|
+
return reply(201, await createBoard(input));
|
|
60
74
|
}),
|
|
61
75
|
route({ name: "boards.get", method: "GET", path: "/api/boards/:board", summary: "columns, rules, counts and every task (?project=)", errors: boardErrors }, async (c) => {
|
|
76
|
+
if (onCloud(c))
|
|
77
|
+
return cloud.getCloudBoard(c.trust, c.params.board);
|
|
62
78
|
await requireOn();
|
|
63
79
|
const ref = refOf(c);
|
|
64
80
|
return (await getBoard(ref)) ?? fail(404, `no board "${ref.board}"`);
|
|
65
81
|
}),
|
|
66
82
|
route({ name: "boards.save", method: "PUT", path: "/api/boards/:board", summary: "save title, columns, default agent, stale_after, rules", errors: boardErrors, body: BoardFields }, async (c) => {
|
|
83
|
+
if (onCloud(c))
|
|
84
|
+
return cloud.saveCloudBoard(c.trust, c.params.board, await c.body());
|
|
67
85
|
await requireOn();
|
|
68
86
|
return saveBoard(refOf(c), (await c.body()));
|
|
69
87
|
}),
|
|
70
88
|
route({ name: "boards.delete", method: "DELETE", path: "/api/boards/:board", summary: "move the board, tasks and all, to the trash", errors: boardErrors }, async (c) => {
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
if (onCloud(c))
|
|
90
|
+
await cloud.deleteCloudBoard(c.trust, c.params.board);
|
|
91
|
+
else {
|
|
92
|
+
await requireOn();
|
|
93
|
+
await deleteBoard(refOf(c));
|
|
94
|
+
}
|
|
73
95
|
return { ok: true };
|
|
74
96
|
}),
|
|
75
97
|
route({
|
|
@@ -92,20 +114,29 @@ export const boardRoutes = [
|
|
|
92
114
|
errors: boardErrors,
|
|
93
115
|
body: TaskFields.extend({ title: z.string() }),
|
|
94
116
|
}, async (c) => {
|
|
117
|
+
if (onCloud(c))
|
|
118
|
+
return reply(201, await cloud.createCloudTask(c.trust, c.params.board, await c.body()));
|
|
95
119
|
await requireOn();
|
|
96
120
|
return reply(201, await createTask(refOf(c), (await c.body())));
|
|
97
121
|
}),
|
|
98
|
-
route({ name: "tasks.list", method: "GET", path: "/api/tasks", summary: "every task of every board, the workspace's and the
|
|
99
|
-
|
|
122
|
+
route({ name: "tasks.list", method: "GET", path: "/api/tasks", summary: "every task of every board, the workspace's, the projects' and the cloud's, each with its board and column" }, async (c) => {
|
|
123
|
+
const [local, remote] = await Promise.all([openBoards().then(async (o) => (o.off ? [] : await listAllTasks())), cloud.listCloudTasks(c.trust)]);
|
|
124
|
+
return { tasks: [...local, ...remote] };
|
|
100
125
|
}),
|
|
101
126
|
route({ name: "tasks.get", method: "GET", path: "/api/boards/:board/tasks/:task", summary: "the task: fields, markdown, files, log and the sessions that worked on it (:task = folder name or number)", errors: boardErrors }, async (c) => {
|
|
127
|
+
if (onCloud(c)) {
|
|
128
|
+
const t = await cloud.getCloudTask(c.trust, c.params.board, c.params.task);
|
|
129
|
+
return { ...t, sessions: await taskSessions(t.ref) };
|
|
130
|
+
}
|
|
102
131
|
await requireOn();
|
|
103
132
|
const task = (await getTask(refOf(c), c.params.task)) ?? fail(404, `no task "${c.params.task}"`);
|
|
104
133
|
return { ...task, sessions: await taskSessions(task.ref) };
|
|
105
134
|
}),
|
|
106
135
|
route({ name: "tasks.save", method: "PUT", path: "/api/boards/:board/tasks/:task", summary: "save fields and markdown; a status or assignee change is logged (message?) and wakes an agent assigned in a work column (unless wake: false)", errors: boardErrors, body: TaskFields.extend({ wake: z.boolean().optional() }) }, async (c) => {
|
|
107
|
-
await requireOn();
|
|
108
136
|
const { actor, message, wake, ...fields } = await c.body();
|
|
137
|
+
if (onCloud(c))
|
|
138
|
+
return cloud.saveCloudTask(c.trust, c.params.board, c.params.task, { ...fields, actor, message });
|
|
139
|
+
await requireOn();
|
|
109
140
|
return saveTask(refOf(c), c.params.task, fields, { actor, message, quiet: wake === false });
|
|
110
141
|
}),
|
|
111
142
|
route({
|
|
@@ -116,8 +147,10 @@ export const boardRoutes = [
|
|
|
116
147
|
errors: boardErrors,
|
|
117
148
|
body: z.object({ status: z.string(), before: z.string().optional(), order: z.number().optional(), message: z.string().optional(), actor: z.string().optional() }),
|
|
118
149
|
}, async (c) => {
|
|
119
|
-
await requireOn();
|
|
120
150
|
const { status, ...opts } = await c.body();
|
|
151
|
+
if (onCloud(c))
|
|
152
|
+
return cloud.moveCloudTask(c.trust, c.params.board, c.params.task, status, opts);
|
|
153
|
+
await requireOn();
|
|
121
154
|
return moveTask(refOf(c), c.params.task, status, opts);
|
|
122
155
|
}),
|
|
123
156
|
route({
|
|
@@ -128,8 +161,10 @@ export const boardRoutes = [
|
|
|
128
161
|
errors: boardErrors,
|
|
129
162
|
body: z.object({ to: z.string().nullable(), message: z.string().optional(), actor: z.string().optional() }),
|
|
130
163
|
}, async (c) => {
|
|
131
|
-
await requireOn();
|
|
132
164
|
const { to, ...opts } = await c.body();
|
|
165
|
+
if (onCloud(c))
|
|
166
|
+
return cloud.assignCloudTask(c.trust, c.params.board, c.params.task, to, opts);
|
|
167
|
+
await requireOn();
|
|
133
168
|
return assignTask(refOf(c), c.params.task, to, opts);
|
|
134
169
|
}),
|
|
135
170
|
route({
|
|
@@ -140,8 +175,10 @@ export const boardRoutes = [
|
|
|
140
175
|
errors: boardErrors,
|
|
141
176
|
body: z.object({ entry: z.string(), actor: z.string().optional() }),
|
|
142
177
|
}, async (c) => {
|
|
143
|
-
await requireOn();
|
|
144
178
|
const { entry, actor } = await c.body();
|
|
179
|
+
if (onCloud(c))
|
|
180
|
+
return cloud.logCloudTask(c.trust, c.params.board, c.params.task, entry, actor);
|
|
181
|
+
await requireOn();
|
|
145
182
|
return appendTaskLog(refOf(c), c.params.task, entry, actor);
|
|
146
183
|
}),
|
|
147
184
|
route({
|
|
@@ -152,13 +189,19 @@ export const boardRoutes = [
|
|
|
152
189
|
errors: boardErrors,
|
|
153
190
|
body: z.object({ agent: z.string(), column: z.string().optional() }),
|
|
154
191
|
}, async (c) => {
|
|
155
|
-
await requireOn();
|
|
156
192
|
const { agent, column } = await c.body();
|
|
193
|
+
if (onCloud(c))
|
|
194
|
+
return { task: await cloud.pickCloudTask(c.trust, c.params.board, agent, column) };
|
|
195
|
+
await requireOn();
|
|
157
196
|
return { task: await pickTask(refOf(c), agent, { column }) };
|
|
158
197
|
}),
|
|
159
198
|
route({ name: "tasks.delete", method: "DELETE", path: "/api/boards/:board/tasks/:task", summary: "move the task folder to the trash", errors: boardErrors }, async (c) => {
|
|
160
|
-
|
|
161
|
-
|
|
199
|
+
if (onCloud(c))
|
|
200
|
+
await cloud.deleteCloudTask(c.trust, c.params.board, c.params.task);
|
|
201
|
+
else {
|
|
202
|
+
await requireOn();
|
|
203
|
+
await deleteTask(refOf(c), c.params.task);
|
|
204
|
+
}
|
|
162
205
|
return { ok: true };
|
|
163
206
|
}),
|
|
164
207
|
];
|