@bigmistqke/workpad 0.18.1 → 0.20.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 +18 -9
- package/bin/workpad.ts +412 -58
- package/dist/bin/workpad.js +336 -46
- package/dist/client/runtime.js +141 -18
- package/dist/plugins/badge/README.md +59 -10
- package/dist/plugins/badge/index.js +130 -8
- package/dist/plugins/badge/public/style.css +132 -12
- package/dist/plugins/chat/README.md +7 -3
- package/dist/plugins/chat/index.js +8 -1
- package/dist/plugins/chat/public/client.js +2 -2
- package/dist/plugins/chat/public/style.css +10 -0
- package/dist/plugins/claude/README.md +13 -5
- package/dist/plugins/claude/channel.js +47 -6
- package/dist/plugins/claude/doctor.js +43 -47
- package/dist/plugins/claude/index.js +24 -8
- package/dist/plugins/claude/session.js +46 -1
- package/dist/plugins/comments/README.md +2 -1
- package/dist/plugins/comments/index.js +2 -0
- package/dist/plugins/comments/public/client.js +6 -5
- package/dist/plugins/comments/public/style.css +9 -0
- package/dist/plugins/form/README.md +1 -1
- package/dist/plugins/index.js +3 -1
- package/dist/plugins/opencode/channel.js +43 -7
- package/dist/plugins/opencode/index.js +2 -0
- package/dist/plugins/progress/README.md +41 -0
- package/dist/plugins/progress/index.js +117 -0
- package/dist/plugins/progress/public/client.js +1 -0
- package/dist/plugins/progress/public/style.css +85 -0
- package/dist/plugins/progress/state.js +210 -0
- package/dist/solid/index.js +3 -1
- package/dist/src/agents.js +13 -4
- package/dist/src/anchors.js +25 -1
- package/dist/src/build.js +1 -1
- package/dist/src/client/page/base.css +48 -2
- package/dist/src/client/page/main.js +58 -30
- package/dist/src/document.js +6 -4
- package/dist/src/events.js +22 -11
- package/dist/src/help.js +59 -12
- package/dist/src/hub.js +69 -3
- package/dist/src/listen.js +36 -4
- package/dist/src/listeners.js +14 -4
- package/dist/src/loader.js +7 -2
- package/dist/src/migrate.js +1 -1
- package/dist/src/pages/board.js +9 -4
- package/dist/src/pages/index.js +2 -4
- package/dist/src/pages/markdown.js +50 -19
- package/dist/src/pages/render.js +17 -1
- package/dist/src/server.js +94 -18
- package/dist/src/set.js +99 -0
- package/dist/src/state.js +2 -1
- package/dist/src/status.js +57 -9
- package/dist/src/turns.js +41 -0
- package/package.json +11 -1
- package/plugins/README.md +3 -1
- package/plugins/badge/README.md +59 -10
- package/plugins/badge/index.ts +141 -8
- package/plugins/badge/public/style.css +132 -12
- package/plugins/chat/README.md +7 -3
- package/plugins/chat/client.tsx +20 -3
- package/plugins/chat/index.ts +10 -1
- package/plugins/chat/public/style.css +10 -0
- package/plugins/claude/README.md +13 -5
- package/plugins/claude/channel.ts +45 -7
- package/plugins/claude/doctor.ts +58 -39
- package/plugins/claude/index.ts +30 -8
- package/plugins/claude/session.ts +32 -0
- package/plugins/comments/README.md +2 -1
- package/plugins/comments/client.ts +19 -0
- package/plugins/comments/index.ts +7 -1
- package/plugins/comments/public/style.css +9 -0
- package/plugins/form/README.md +1 -1
- package/plugins/index.ts +2 -0
- package/plugins/opencode/channel.ts +44 -8
- package/plugins/opencode/index.ts +4 -0
- package/plugins/progress/README.md +41 -0
- package/plugins/progress/client.ts +172 -0
- package/plugins/progress/index.ts +166 -0
- package/plugins/progress/public/style.css +85 -0
- package/plugins/progress/state.ts +278 -0
- package/skills/workpad/SKILL.md +149 -18
- package/solid/index.tsx +6 -2
- package/src/agents.ts +24 -2
- package/src/anchors.ts +32 -0
- package/src/build.ts +1 -1
- package/src/client/delivery.ts +49 -0
- package/src/client/forms.ts +18 -11
- package/src/client/page/base.css +48 -2
- package/src/client/page/waiting.ts +45 -25
- package/src/client/read.ts +9 -5
- package/src/client/runtime.ts +7 -3
- package/src/client/toast.ts +27 -3
- package/src/define.ts +120 -9
- package/src/document.ts +19 -5
- package/src/events.ts +47 -6
- package/src/help.ts +58 -11
- package/src/hub.ts +80 -2
- package/src/listen.ts +47 -4
- package/src/listeners.ts +22 -1
- package/src/loader.ts +14 -4
- package/src/migrate.ts +1 -1
- package/src/pages/board.ts +12 -3
- package/src/pages/index.ts +8 -10
- package/src/pages/markdown.ts +59 -12
- package/src/pages/render.ts +20 -2
- package/src/server.ts +127 -19
- package/src/set.ts +118 -0
- package/src/state.ts +3 -0
- package/src/status.ts +115 -14
- package/src/turns.ts +56 -0
package/dist/src/document.js
CHANGED
|
@@ -19,7 +19,7 @@ const BODY_SLOTS = [
|
|
|
19
19
|
* null for a page no browser asked for), and its browser module. One that failed to start or fails
|
|
20
20
|
* here is left out and told to `failed`; so are those in `leaveOut` (a build's skip), silently.
|
|
21
21
|
*/
|
|
22
|
-
async function pluginParts(hooks, req, { asset, messages, leaveOut = /* @__PURE__ */ new Set(), failed }) {
|
|
22
|
+
async function pluginParts(hooks, req, { asset, messages, handedOut = [], leaveOut = /* @__PURE__ */ new Set(), failed }) {
|
|
23
23
|
const included = hooks.filter((h) => !leaveOut.has(h.name));
|
|
24
24
|
for (const h of included) if (h.error) failed(`plugin "${h.name}" failed to start: ${h.error.message}`);
|
|
25
25
|
const working = included.filter((h) => !h.error);
|
|
@@ -50,14 +50,15 @@ async function pluginParts(hooks, req, { asset, messages, leaveOut = /* @__PURE_
|
|
|
50
50
|
name: h.name,
|
|
51
51
|
client: asset(h.client)
|
|
52
52
|
})),
|
|
53
|
-
messages
|
|
53
|
+
messages,
|
|
54
|
+
handedOut
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
/** A stored page's frontmatter, for the browser (PageHandle.frontmatter): a markdown page's, else none. */
|
|
57
58
|
const frontmatterOf = (page) => page.kind === "page" ? page.frontmatter : {};
|
|
58
59
|
/** JSON made safe inside a <script>. */
|
|
59
60
|
const json = (s) => JSON.stringify(s).replace(/</g, "\\u003c");
|
|
60
|
-
const DOCK_STYLE = "#wp-dock{position:fixed;right:16px;bottom:calc(16px + var(--wp-inset-bottom,0px));z-index:30;display:flex;flex-direction:column;align-items:flex-end;gap:6px}#wp-dock:not(:has(> :not(:empty))){display:none}[data-wp-slot]:not(#wp-dock),[data-wp-slot]>[data-plugin]{display:contents}.wp-toasts{display:flex;flex-direction:column;align-items:flex-end;gap:6px}.wp-toasts:empty{display:none}.wp-toast{display:inline-flex;align-items:center;gap:8px;cursor:pointer;padding:5px 12px;border-radius:99px;font:600 .8rem/1.4 var(--sans,system-ui,sans-serif);background:var(--accent,#1d5bbf);color:var(--accent-text,#fff);border:1px solid transparent;box-shadow:0 2px 10px rgb(0 0 0/.18)}.wp-toast[hidden]{display:none}.wp-toast[data-kind=warn]{background:var(--warn,#6b4fc0)}.wp-toast[data-kind=alert]{background:var(--bad,#c4352b);color:#fff}@keyframes wp-flash{from{outline-color:var(--accent,#1d5bbf)}to{outline-color:transparent}}.wp-flash{outline:3px solid transparent;outline-offset:6px;border-radius:4px;animation:wp-flash 2s ease-out}.wp-toast-dismiss{margin-right:-4px;padding:0 4px;border-left:1px solid rgb(255 255 255/.35);opacity:.75}.wp-toast-dismiss:hover{opacity:1}.wp-toast{max-width:min(24rem,calc(100vw - 32px));text-align:left}.wp-toast-more{margin:0 -4px 0 -2px;padding:0 4px;opacity:.75}.wp-toast-more:hover{opacity:1}.wp-toast[data-open]{flex-wrap:wrap;border-radius:12px}.wp-toast-details{flex-basis:100%;padding:2px 0 3px;font-weight:400;cursor:text}.wp-toast-details[hidden]{display:none}";
|
|
61
|
+
const DOCK_STYLE = "#wp-dock{position:fixed;right:16px;bottom:calc(16px + var(--wp-inset-bottom,0px));z-index:30;display:flex;flex-direction:column;align-items:flex-end;gap:6px}#wp-dock:not(:has(> :not(:empty))){display:none}[data-wp-slot]:not(#wp-dock),[data-wp-slot]>[data-plugin]{display:contents}.wp-toasts{display:flex;flex-direction:column;align-items:flex-end;gap:6px}.wp-toasts:empty{display:none}.wp-toast{display:inline-flex;align-items:center;gap:8px;cursor:pointer;padding:5px 12px;border-radius:99px;font:600 .8rem/1.4 var(--sans,system-ui,sans-serif);background:var(--accent,#1d5bbf);color:var(--accent-text,#fff);border:1px solid transparent;box-shadow:0 2px 10px rgb(0 0 0/.18)}.wp-toast[hidden]{display:none}.wp-toast[data-kind=warn]{background:var(--warn,#6b4fc0)}.wp-toast[data-kind=alert]{background:var(--bad,#c4352b);color:#fff}@keyframes wp-flash{from{outline-color:var(--accent,#1d5bbf)}to{outline-color:transparent}}.wp-flash{outline:3px solid transparent;outline-offset:6px;border-radius:4px;animation:wp-flash 2s ease-out}.wp-toast-dismiss{margin-right:-4px;padding:0 4px;border-left:1px solid rgb(255 255 255/.35);opacity:.75}.wp-toast-dismiss:hover{opacity:1}.wp-toast{max-width:min(24rem,calc(100vw - 32px));text-align:left}.wp-toast-more{margin:0 -4px 0 -2px;padding:0 4px;opacity:.75}.wp-toast-more:hover{opacity:1}.wp-toast[data-open]{flex-wrap:wrap;border-radius:12px}.wp-toast-details{flex-basis:100%;padding:2px 0 3px;font-weight:400;cursor:text}.wp-toast-details[hidden]{display:none}.wp-toast[data-kind=quiet]{display:grid;grid-template-columns:1fr auto;align-items:baseline;gap:4px 12px;width:230px;max-width:calc(100vw - 32px);padding:8px 12px 9px;border-radius:10px;background:var(--surface,#fff);color:var(--text,#1b1c1e);border:1px solid var(--border,#e3e5e9);box-shadow:0 4px 16px rgb(0 0 0/.14);font-weight:500}.wp-toast-meta{color:var(--muted,#696e76);font-weight:400;white-space:nowrap;text-align:right}.wp-toast[data-kind=quiet]:not(:has(.wp-toast-meta)) .wp-toast-text{grid-column:1/-1}.wp-toast-bar{grid-column:1/-1;position:relative;height:3px;margin-top:3px;border-radius:2px;overflow:hidden;background:color-mix(in srgb,var(--muted,#696e76) 28%,transparent)}.wp-toast-bar span{position:absolute;inset:0 auto 0 0;width:var(--wp-toast-bar,0%);border-radius:inherit;background:var(--accent,#1d5bbf)}.wp-toast-bar[data-tone=good] span{background:var(--ok,#1a7a49)}.wp-toast-bar[data-tone=bad] span{background:var(--bad,#c4352b)}@keyframes wp-toast-stripe{from{left:-30%}to{left:100%}}.wp-toast-bar[data-indeterminate] span{width:30%;animation:wp-toast-stripe 1.6s ease-in-out infinite}@media (prefers-reduced-motion:reduce){.wp-toast-bar[data-indeterminate] span{animation:none;left:0;width:100%;opacity:.5}}";
|
|
61
62
|
/** Each plugin's own element in a slot, with what it rendered there. */
|
|
62
63
|
const slotted = (list) => list.map((x) => html`<div data-plugin="${x.name}">${x.html}</div>`);
|
|
63
64
|
/** A page as a document: the render, the plugins' parts, and the handoff for the browser runtime. */
|
|
@@ -72,6 +73,7 @@ function pageDocument(page, { page: rendered, out, notices }, parts, o) {
|
|
|
72
73
|
frontmatter: frontmatterOf(page),
|
|
73
74
|
plugins: parts.clients,
|
|
74
75
|
messages: parts.messages,
|
|
76
|
+
handedOut: parts.handedOut,
|
|
75
77
|
...o.stamps && { stamps: o.stamps }
|
|
76
78
|
};
|
|
77
79
|
return String(html(_templateObject || (_templateObject = _taggedTemplateLiteral([
|
|
@@ -88,6 +90,6 @@ function pageDocument(page, { page: rendered, out, notices }, parts, o) {
|
|
|
88
90
|
"\n <\/script>\n <script type=\"module\" src=\"",
|
|
89
91
|
"\"><\/script>\n ",
|
|
90
92
|
"\n </body>\n </html>"
|
|
91
|
-
])), out.title || page.id || o.title, DOCK_STYLE, raw(String(out.head ?? "")), parts.head, page.id, page.kind, notices.map((n) => html`<pre class="wp-error" role="alert">${n}</pre>`), raw(String(out.html)), slotted(parts.slots.corner), raw(json(handoff)), o.runtime, BODY_SLOTS.map((name) => html`<div data-wp-slot="${name}">${slotted(parts.slots[name])}</div>`)));
|
|
93
|
+
])), out.title || page.id || o.title, raw(DOCK_STYLE), raw(String(out.head ?? "")), parts.head, page.id, page.kind, notices.map((n) => html`<pre class="wp-error" role="alert">${n}</pre>`), raw(String(out.html)), slotted(parts.slots.corner), raw(json(handoff)), o.runtime, BODY_SLOTS.map((name) => html`<div data-wp-slot="${name}">${slotted(parts.slots[name])}</div>`)));
|
|
92
94
|
}
|
|
93
95
|
export { PAGE_CLIENT, RUNTIME, frontmatterOf, pageDocument, pluginParts };
|
package/dist/src/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HANDLED, NAME, RECEIVED, SUBSCRIBE, UNSUBSCRIBE, channelSince, fromReader, handledIds, namesOf, receivedIds, subscriptions } from "./status.js";
|
|
1
|
+
import { HANDLED, NAME, RECEIVED, SUBSCRIBE, UNSUBSCRIBE, channelSince, fromReader, handledIds, namesOf, receivedIds, subscriptions, takesUnfollowed } from "./status.js";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import crypto from "node:crypto";
|
|
4
4
|
// src/events.ts
|
|
@@ -7,9 +7,11 @@ const isEventId = (id) => typeof id === "string" && /^[0-9a-z]{6,12}-[0-9a-f]{6,
|
|
|
7
7
|
/**
|
|
8
8
|
* Append one event; `action` is the button that submitted a form, null for anything else. `from`
|
|
9
9
|
* is set only for events the command line writes ('cli'), so that waits skip them and pages can
|
|
10
|
-
* tell them apart; what the browser appends has none.
|
|
10
|
+
* tell them apart; what the browser appends has none. `by` is who wrote it; `session`, the agent
|
|
11
|
+
* session it was written in, when that is another id than `by` (`WORKPAD_AGENT` named the writer):
|
|
12
|
+
* a channel that knows the agent by its session still knows the event for its own.
|
|
11
13
|
*/
|
|
12
|
-
function appendEvent(file, input, from = null, by = null) {
|
|
14
|
+
function appendEvent(file, input, from = null, by = null, session = null) {
|
|
13
15
|
const event = {
|
|
14
16
|
id: isEventId(input.id) ? input.id : `${Date.now().toString(36)}-${crypto.randomBytes(3).toString("hex")}`,
|
|
15
17
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18,7 +20,8 @@ function appendEvent(file, input, from = null, by = null) {
|
|
|
18
20
|
action: input.action ?? null,
|
|
19
21
|
data: input.data ?? {},
|
|
20
22
|
...from ? { from } : {},
|
|
21
|
-
...by ? { by } : {}
|
|
23
|
+
...by ? { by } : {},
|
|
24
|
+
...session && session !== by ? { session } : {}
|
|
22
25
|
};
|
|
23
26
|
fs.appendFileSync(file, JSON.stringify(event) + "\n");
|
|
24
27
|
return event;
|
|
@@ -265,9 +268,12 @@ function handle(file, event, by = null) {
|
|
|
265
268
|
const forAgent = (handedOut = /* @__PURE__ */ new Set()) => (type) => !type.includes(":") || handedOut.has(type);
|
|
266
269
|
/**
|
|
267
270
|
* Hand the events that match `filter` to `onEvent`, for agent `agent`: the reader's, and other
|
|
268
|
-
* agents' (an agent's event says who wrote it, `by`; one that doesn't is handed to no one)
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
+
* agents' (an agent's event says who wrote it, `by`; one that doesn't is handed to no one), never
|
|
272
|
+
* its own (written by `agent` or one of its `aliases`). Each is marked received by `agent` once
|
|
273
|
+
* handed out. First the backlog: what is not handled, also from before this started; of the
|
|
274
|
+
* reader's, those `agent` received before come again, saying so (`again`), until handled; another
|
|
275
|
+
* agent's message it received before doesn't: a message is news once, and an agent's message is
|
|
276
|
+
* never handled by a reply, so it would come back at every start. Then, with `follow`, every new one as
|
|
271
277
|
* it comes. The backlog and the following split the log at one line boundary, so no event falls
|
|
272
278
|
* between them. Any number hand out from one log at once: each gets every event. Of the plugins'
|
|
273
279
|
* events only those for an agent (`forAgent`), unless the filter asks for a type by name.
|
|
@@ -276,7 +282,7 @@ const forAgent = (handedOut = /* @__PURE__ */ new Set()) => (type) => !type.incl
|
|
|
276
282
|
* `follow`, or when `signal` aborts.
|
|
277
283
|
*/
|
|
278
284
|
function handOut(file, filter, onEvent, options = {}) {
|
|
279
|
-
const { count = Infinity, follow: following = true, interval, signal, forAgent: isForAgent = forAgent(), batch = false, mark = true, agent = null, skipReceivedBefore } = options;
|
|
285
|
+
const { count = Infinity, follow: following = true, interval, signal, forAgent: isForAgent = forAgent(), batch = false, mark = true, agent = null, aliases = /* @__PURE__ */ new Set(), skipReceivedBefore, readerOnly = false, notReceivedByOthers = false } = options;
|
|
280
286
|
return new Promise((resolve) => {
|
|
281
287
|
let got = 0;
|
|
282
288
|
let stop = () => {};
|
|
@@ -285,7 +291,9 @@ function handOut(file, filter, onEvent, options = {}) {
|
|
|
285
291
|
signal?.removeEventListener("abort", finish);
|
|
286
292
|
resolve(got);
|
|
287
293
|
};
|
|
288
|
-
const
|
|
294
|
+
const me = (id) => !!id && (id === agent || aliases.has(id));
|
|
295
|
+
const own = (e) => me(e.by) || me(e.session);
|
|
296
|
+
const fromOthers = (e) => fromReader(e) || !readerOnly && !!e.by && !own(e);
|
|
289
297
|
const wanted = (e) => fromOthers(e) && matches(e, filter) && (!!filter.type || isForAgent(e.type));
|
|
290
298
|
let before = /* @__PURE__ */ new Set();
|
|
291
299
|
const hand = (e) => {
|
|
@@ -297,12 +305,15 @@ function handOut(file, filter, onEvent, options = {}) {
|
|
|
297
305
|
const { events, end } = read(file);
|
|
298
306
|
const handled = handledIds(events);
|
|
299
307
|
before = receivedBy(events, agent);
|
|
308
|
+
for (const alias of aliases) for (const id of receivedBy(events, alias)) before.add(id);
|
|
309
|
+
const others = notReceivedByOthers ? new Set(events.filter((e) => e.type === "workpad:received" && !fromReader(e) && !me(e.by) && (e.by ?? null) !== agent).map((e) => String(e.data?.event))) : /* @__PURE__ */ new Set();
|
|
300
310
|
let skipping = !!skipReceivedBefore;
|
|
301
311
|
const receivedAny = skipping ? receivedIds(events) : /* @__PURE__ */ new Set();
|
|
302
312
|
for (const e of events) {
|
|
303
313
|
if (skipping && e.id === skipReceivedBefore) skipping = false;
|
|
304
314
|
if (skipping && !fromReader(e) && receivedAny.has(e.id)) continue;
|
|
305
|
-
if (
|
|
315
|
+
if (!fromReader(e) && before.has(e.id)) continue;
|
|
316
|
+
if (wanted(e) && !handled.has(e.id) && !others.has(e.id) && !hand(e)) return finish();
|
|
306
317
|
}
|
|
307
318
|
if (batch && got) return finish();
|
|
308
319
|
if (!following) return finish();
|
|
@@ -319,4 +330,4 @@ function receivedBy(events, agent) {
|
|
|
319
330
|
for (const e of events) if (e.type === "workpad:received" && e.from === "cli" && (e.by ?? null) === agent && typeof e.data?.event === "string") ids.add(e.data.event);
|
|
320
331
|
return ids;
|
|
321
332
|
}
|
|
322
|
-
export { HANDLED, NAME, RECEIVED, SUBSCRIBE, UNSUBSCRIBE, appendEvent, channelSince, editEvent, follow, forAgent, fromReader, handOut, handle, handledIds, isEventId, matches, namesOf, parseLines, prune, read, readEvents, receive, receivedBy, receivedIds, rewrite, subscriptions };
|
|
333
|
+
export { HANDLED, NAME, RECEIVED, SUBSCRIBE, UNSUBSCRIBE, appendEvent, channelSince, editEvent, follow, forAgent, fromReader, handOut, handle, handledIds, isEventId, matches, namesOf, parseLines, prune, read, readEvents, receive, receivedBy, receivedIds, rewrite, subscriptions, takesUnfollowed };
|
package/dist/src/help.js
CHANGED
|
@@ -35,8 +35,10 @@ opencode()). Alone, it says your id and your name.
|
|
|
35
35
|
confirmed, the channel listens on your pages, and the answers it brings count
|
|
36
36
|
as received. No channel (exit 1), or no pong: nothing brings answers here, so
|
|
37
37
|
listen for them. --wait: run it in the background; it pings and ends when
|
|
38
|
-
the pong is confirmed (exit 0), or
|
|
39
|
-
(exit 1): then listen
|
|
38
|
+
the pong is confirmed (exit 0), or --timeout seconds (120) after the
|
|
39
|
+
session's turn ended without one (exit 1): then listen. A pong comes only
|
|
40
|
+
once the turn ends, so it waits while the turn runs, 30 minutes at most;
|
|
41
|
+
where its plugin records no turn ends, it counts from the ping.`
|
|
40
42
|
},
|
|
41
43
|
show: {
|
|
42
44
|
usage: "<page|file> [<anchor>]",
|
|
@@ -49,9 +51,9 @@ opencode()). Alone, it says your id and your name.
|
|
|
49
51
|
details: "The link leaves out the server's address (`/rg/jobs/x/decisions#form:logger`), so it works however the board is opened; --full prints the whole URL, for outside a board. The page can be another project's: name its file. An anchor the page doesn't have exits 1, listing those it has."
|
|
50
52
|
},
|
|
51
53
|
settle: {
|
|
52
|
-
usage: "<page|file> <form>… | --all",
|
|
54
|
+
usage: "<page|file> <form>… | --all | <form> --replace-with <file|->",
|
|
53
55
|
summary: "settle questions answered elsewhere (a chat, the design moving on): no longer unanswered",
|
|
54
|
-
details: "A form a chat settled, or the design moved past, would otherwise stay \"unanswered\" for good: in `workpad status`, the page's counter, the turn-end check. Settled, it counts as answered elsewhere. With `--all`, every open (or held) question on the page; without forms or `--all` it settles nothing and says which are open. A form with an answer in is left as it is. If the reader answers a settled form after all, it is open again. Say what settled it in its chat first, so the reader sees why."
|
|
56
|
+
details: "A form a chat settled, or the design moved past, would otherwise stay \"unanswered\" for good: in `workpad status`, the page's counter, the turn-end check. Settled, it counts as answered elsewhere. With `--all`, every open (or held) question on the page; without forms or `--all` it settles nothing and says which are open. A form with an answer in is left as it is. If the reader answers a settled form after all, it is open again. Say what settled it in its chat first, so the reader sees why.\n\n --replace-with <file|-> also replace the form on the page with this markdown (a file, or - for\n standard input), such as a line saying what was decided: one form, named.\n The form is found as `workpad set` finds it; one the page lacks settles\n nothing. Its chat goes to the page's folded list of chats no longer on it\n (`workpad chat prune` removes it).\n\n workpad settle plan logger --replace-with - <<'EOF'\n **Decided:** pino, for its speed.\n EOF"
|
|
55
57
|
},
|
|
56
58
|
hold: {
|
|
57
59
|
usage: "<page|file> <form>… \"<reason>\"",
|
|
@@ -64,14 +66,39 @@ opencode()). Alone, it says your id and your name.
|
|
|
64
66
|
},
|
|
65
67
|
check: {
|
|
66
68
|
usage: "[<page|file>…]",
|
|
67
|
-
summary: "what is wrong on pages, as they render: a block nobody brings, an input outside its form, a block's error",
|
|
68
|
-
details: "Every page of the project, or those named. Per page, one line for each problem: a config or frontmatter that doesn't parse, a block that reports an error (a diagram that doesn't parse, a form's name used twice), a block nobody brings (`:::tabz`), a form's input or button outside any form (a block inside the form one colon short), an attribute a block doesn't read, a link to an anchor the page
|
|
69
|
+
summary: "what is wrong on pages, as they render: a block nobody brings, an input outside its form, a block's error, a broken link",
|
|
70
|
+
details: "Every page of the project, or those named. Per page, one line for each problem: a config or frontmatter that doesn't parse, a block that reports an error (a diagram that doesn't parse, a form's name used twice), a block nobody brings (`:::tabz`), a form's input or button outside any form (a block inside the form one colon short), an attribute a block doesn't read, a link to an anchor that isn't there: on the same page (`#form:logger`, which the page shows above it too) or on another page of the project (`decisions.md#form:logger`), with the nearest anchors it does have; a link to a page that doesn't exist. Links to other projects and sites aren't checked. Exits 1 when there is any. Run it after writing a page."
|
|
69
71
|
},
|
|
70
72
|
anchors: {
|
|
71
73
|
usage: "<page|file>",
|
|
72
74
|
summary: "what a page can be linked to: each #anchor, what it is and what it says",
|
|
73
75
|
details: "Headings by their slug (`#open-questions`), and `#<type>:<name>` for the rest: `#form:logger`, `#chat:notes`, `#tab:intro`, `#details:why`. A chat message is `#message:<event id>`, not listed. The page can be another project's: name its file."
|
|
74
76
|
},
|
|
77
|
+
set: {
|
|
78
|
+
usage: "<page|file> <anchor|form> --file <file|->",
|
|
79
|
+
summary: "replace one block of a page by its name: a form, a heading's section, a chat or other named block",
|
|
80
|
+
details: `The markdown comes from a file, or with - from standard input (a heredoc with a quoted
|
|
81
|
+
delimiter: nothing in it passes through the shell's quoting). The block is found by parsing the
|
|
82
|
+
page, as a link names it (\`workpad anchors\`):
|
|
83
|
+
|
|
84
|
+
#form:logger the :::form{name=logger} container
|
|
85
|
+
#open-questions a heading's section: the heading and what follows, up to the next heading
|
|
86
|
+
of the same or a higher level (a deeper one is inside it)
|
|
87
|
+
#chat:notes a :::chat{name=notes}; any block with a name: #<type>:<name>, or with a
|
|
88
|
+
label: #details:why-not-mdx, #item:parser
|
|
89
|
+
logger a bare name: the block whose anchor it is, or whose name it is (form:logger);
|
|
90
|
+
when it fits two (a heading and a form), name it by its anchor, with its #
|
|
91
|
+
|
|
92
|
+
Everything else on the page stays as it was, byte for byte; a form in a code fence is never touched.
|
|
93
|
+
A name the page doesn't have exits 1, listing the blocks it has. To settle a form and put what was
|
|
94
|
+
decided in its place in one step: workpad settle <page> <form> --replace-with <file|->.
|
|
95
|
+
|
|
96
|
+
workpad set plan '#open-questions' --file - <<'EOF'
|
|
97
|
+
## Open questions
|
|
98
|
+
|
|
99
|
+
None left.
|
|
100
|
+
EOF`
|
|
101
|
+
},
|
|
75
102
|
migrate: {
|
|
76
103
|
usage: "[<folder|file>…] [--write]",
|
|
77
104
|
summary: "after updating workpad: rewrite pages written in an older syntax in the current one",
|
|
@@ -108,9 +135,11 @@ One chat's messages: workpad chat prune <page|file> <chat>.`
|
|
|
108
135
|
--skip <a,b> plugins or blocks to leave out (default: form, chat, comments, draft)`
|
|
109
136
|
},
|
|
110
137
|
edit: {
|
|
111
|
-
usage: "<event id> --data <json>",
|
|
138
|
+
usage: "<event id> --data <json> | --file <file|-> | --text-file <file|->",
|
|
112
139
|
summary: "change an agent's own event in place (merged into its data)",
|
|
113
|
-
details:
|
|
140
|
+
details: `Keeps its id, so what refers to it still does. What the reader sent can't be edited.
|
|
141
|
+
The data is taken as append takes it: --data, --file (JSON from a file, or - for standard input),
|
|
142
|
+
--text-file (markdown as its text).`
|
|
114
143
|
},
|
|
115
144
|
scroll: {
|
|
116
145
|
usage: "<page|file> <where>",
|
|
@@ -131,13 +160,14 @@ One chat's messages: workpad chat prune <page|file> <chat>.`
|
|
|
131
160
|
--follow then print each new one as it comes`
|
|
132
161
|
},
|
|
133
162
|
listen: {
|
|
134
|
-
usage: "[--page <p>…] [--type <t>] [--wait [--timeout <s>] | --channel] [--agent <who>]",
|
|
163
|
+
usage: "[--page <p>… | --unfollowed] [--type <t>] [--wait [--timeout <s>] | --channel] [--agent <who>]",
|
|
135
164
|
summary: "print what you haven't handled on the pages (the reader's answers, other agents' messages) and each as it comes; --wait stops at the first, --channel hands over to your channel",
|
|
136
165
|
details: `${FILTERS}
|
|
137
166
|
--page again several pages in one listen: it listens on each, and takes what comes on any
|
|
138
167
|
--wait stop once it printed: all there are, or with none, the first to come
|
|
139
168
|
--timeout <seconds> with --wait: exit 2 when nothing came
|
|
140
169
|
--channel make the pages yours and exit: your session's channel brings their answers
|
|
170
|
+
--unfollowed the pages no live session follows, for a coordinator: see below
|
|
141
171
|
--agent <who> who listens (else WORKPAD_AGENT, else the session an agent plugin names)
|
|
142
172
|
|
|
143
173
|
It prints, one line each, everything on the page you haven't handled, also from before it started,
|
|
@@ -153,11 +183,28 @@ answers to handle, chats waiting for your reply, questions still unanswered.
|
|
|
153
183
|
|
|
154
184
|
Any number listen on a page, and each hears everything there but its own events: agents can talk
|
|
155
185
|
to each other in the same chats. Without --page it listens on every page (in a project of the
|
|
156
|
-
machine's entries, every page of the entry)
|
|
186
|
+
machine's entries, every page of the entry).
|
|
187
|
+
|
|
188
|
+
--unfollowed is for a coordinator, so no page swallows an answer: it listens on every page no live
|
|
189
|
+
session follows (in a project of the machine's entries, in every project of the entry, each line
|
|
190
|
+
with its \`project\` and \`url\`), and hands out the reader's answers there that no other agent
|
|
191
|
+
received. Following is listening now: a running listen on the page, or a confirmed channel of a
|
|
192
|
+
session it belongs to; a subscriber that is gone, between turns, or whose channel was never
|
|
193
|
+
confirmed follows nothing. A page drops out while someone follows it, and joins when its last
|
|
194
|
+
follower goes, as do new pages. What it hands out counts as received by you. With --channel your
|
|
195
|
+
confirmed channel takes these pages on (none becomes yours) and it exits.`
|
|
157
196
|
},
|
|
158
197
|
append: {
|
|
159
|
-
usage: "--page <p> --type <t> [--data <json>]",
|
|
160
|
-
summary: "add an event to a page's log, as the agent (a reply, a chat message)"
|
|
198
|
+
usage: "--page <p> --type <t> [--data <json> | --file <file|->] [--text-file <file|->]",
|
|
199
|
+
summary: "add an event to a page's log, as the agent (a reply, a chat message)",
|
|
200
|
+
details: ` --data <json> its data, as JSON on the command line: for short data without markdown
|
|
201
|
+
--file <file|-> its data, as JSON from a file, or - for standard input
|
|
202
|
+
--text-file <file|-> markdown from a file, or - for standard input, as the data's "text" (with
|
|
203
|
+
--data or --file for the rest): a chat reply, without shell quoting
|
|
204
|
+
|
|
205
|
+
workpad append --page plan --type chat:message --data '{"chat":"page"}' --text-file - <<'EOF'
|
|
206
|
+
It's **done**: see [the logger question](#form:logger).
|
|
207
|
+
EOF`
|
|
161
208
|
},
|
|
162
209
|
handled: {
|
|
163
210
|
usage: "<event id> [<event id>…]",
|
package/dist/src/hub.js
CHANGED
|
@@ -4,6 +4,8 @@ import { followEntries, machineDir, readMachineConfig, stateDir } from "./entrie
|
|
|
4
4
|
import { VERSION, compareVersions } from "./package.js";
|
|
5
5
|
import { API_LISTS, createServer } from "./server.js";
|
|
6
6
|
import { holdStream, listenerOf } from "./listeners.js";
|
|
7
|
+
import { readEvents } from "./events.js";
|
|
8
|
+
import { isStale, running } from "../plugins/progress/state.js";
|
|
7
9
|
import fs from "node:fs";
|
|
8
10
|
import path from "node:path";
|
|
9
11
|
// src/hub.ts
|
|
@@ -12,6 +14,19 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
12
14
|
let origins = [];
|
|
13
15
|
const allowed = () => origins;
|
|
14
16
|
const entryListens = /* @__PURE__ */ new Set();
|
|
17
|
+
const unfollowedListens = /* @__PURE__ */ new Set();
|
|
18
|
+
function takeOn(s, ul) {
|
|
19
|
+
if (ul.held.has(s) || ul.entry && s.entry !== ul.entry) return;
|
|
20
|
+
ul.held.set(s, s.server.unfollowed(ul.listener, (pages) => {
|
|
21
|
+
ul.pages.set(s, pages);
|
|
22
|
+
ul.tell();
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
function letGo(s, ul) {
|
|
26
|
+
ul.held.get(s)?.();
|
|
27
|
+
ul.held.delete(s);
|
|
28
|
+
if (ul.pages.delete(s)) ul.tell();
|
|
29
|
+
}
|
|
15
30
|
/** An entry listen held on one of its projects, so the project's pages say it listens. */
|
|
16
31
|
function hold(s, el) {
|
|
17
32
|
if (!el.held.has(s)) el.held.set(s, s.server.addListener(el.listener));
|
|
@@ -34,6 +49,7 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
34
49
|
const wanted = new Map(projects.map((p) => [`${p.base}\n${p.dir}\n${p.files ?? ""}`, p]));
|
|
35
50
|
for (const [key, s] of served) if (!wanted.has(key)) {
|
|
36
51
|
for (const el of entryListens) release(s, el);
|
|
52
|
+
for (const ul of unfollowedListens) letGo(s, ul);
|
|
37
53
|
s.server.close();
|
|
38
54
|
served.delete(key);
|
|
39
55
|
console.log(`workpad: ${s.base} is gone (${s.dir})`);
|
|
@@ -57,6 +73,7 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
57
73
|
};
|
|
58
74
|
served.set(key, s);
|
|
59
75
|
for (const el of entryListens) if (el.entry === p.entry) hold(s, el);
|
|
76
|
+
for (const ul of unfollowedListens) takeOn(s, ul);
|
|
60
77
|
console.log(`workpad: ${p.base} → ${p.dir}`);
|
|
61
78
|
}
|
|
62
79
|
for (const el of entryListens) el.tell();
|
|
@@ -130,19 +147,31 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
130
147
|
error: err.message
|
|
131
148
|
};
|
|
132
149
|
}
|
|
150
|
+
const now = Date.now();
|
|
151
|
+
const runs = /* @__PURE__ */ new Map();
|
|
152
|
+
for (const r of running(readEvents(s.project.eventsFile))) if (!runs.has(r.page)) runs.set(r.page, {
|
|
153
|
+
id: r.id,
|
|
154
|
+
note: r.note,
|
|
155
|
+
n: r.n,
|
|
156
|
+
total: r.total,
|
|
157
|
+
ts: r.ts,
|
|
158
|
+
stale: isStale(r, now)
|
|
159
|
+
});
|
|
133
160
|
const pages = statuses.map((p) => ({
|
|
134
161
|
page: p.page,
|
|
135
162
|
title: p.title,
|
|
136
163
|
url: `${s.base}/${p.page.split("/").map(encodeURIComponent).join("/")}`,
|
|
137
164
|
mtime: mtimeOf(p.file),
|
|
165
|
+
updated: Math.max(mtimeOf(p.file), p.updated ? Date.parse(p.updated) : 0),
|
|
138
166
|
open: p.open,
|
|
139
167
|
unread: p.unread.length,
|
|
140
|
-
unreceived: p.unreceived.length
|
|
141
|
-
|
|
168
|
+
unreceived: p.unreceived.length,
|
|
169
|
+
progress: runs.get(p.page) ?? null
|
|
170
|
+
})).toSorted((a, b) => b.updated - a.updated);
|
|
142
171
|
return {
|
|
143
172
|
...at,
|
|
144
173
|
pages,
|
|
145
|
-
active: pages[0]?.
|
|
174
|
+
active: pages[0]?.updated ?? 0
|
|
146
175
|
};
|
|
147
176
|
}
|
|
148
177
|
const index = () => Promise.all([...served.values()].map(indexOf));
|
|
@@ -206,6 +235,7 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
206
235
|
setImmediate(() => onShutdown?.());
|
|
207
236
|
return;
|
|
208
237
|
}
|
|
238
|
+
if (p === "/api/listen" && url.searchParams.has("unfollowed")) return listenUnfollowed(req, res, url.searchParams);
|
|
209
239
|
if (p === "/api/listen" && url.searchParams.has("entry")) return listenEntry(req, res, url.searchParams);
|
|
210
240
|
const what = /^\/api\/(\w+)$/.exec(p)?.[1];
|
|
211
241
|
if (req.method === "GET" && what && API_LISTS.includes(what)) {
|
|
@@ -290,6 +320,42 @@ function createHub({ dir = machineDir(), state = stateDir(), home, interval, onS
|
|
|
290
320
|
el.tell();
|
|
291
321
|
}
|
|
292
322
|
const closers = /* @__PURE__ */ new Set();
|
|
323
|
+
/**
|
|
324
|
+
* A listen on the pages no one follows (`workpad listen --unfollowed`), across every project or
|
|
325
|
+
* one entry's: each project holds it on those of its pages (WorkpadServer.unfollowed), and its
|
|
326
|
+
* stream is told them all, once for several changes.
|
|
327
|
+
*/
|
|
328
|
+
function listenUnfollowed(req, res, q) {
|
|
329
|
+
let telling = false;
|
|
330
|
+
const ul = {
|
|
331
|
+
entry: q.get("entry"),
|
|
332
|
+
listener: listenerOf(q),
|
|
333
|
+
held: /* @__PURE__ */ new Map(),
|
|
334
|
+
pages: /* @__PURE__ */ new Map(),
|
|
335
|
+
tell: () => {
|
|
336
|
+
if (telling) return;
|
|
337
|
+
telling = true;
|
|
338
|
+
setImmediate(() => {
|
|
339
|
+
telling = false;
|
|
340
|
+
const projects = [...ul.pages].filter(([, pages]) => pages.length).map(([s, pages]) => ({
|
|
341
|
+
dir: s.dir,
|
|
342
|
+
base: s.base,
|
|
343
|
+
pages
|
|
344
|
+
}));
|
|
345
|
+
stream.send("pages", { projects });
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
const stream = holdStream(req, res, () => {
|
|
350
|
+
closers.delete(stream.end);
|
|
351
|
+
unfollowedListens.delete(ul);
|
|
352
|
+
for (const s of [...ul.held.keys()]) letGo(s, ul);
|
|
353
|
+
});
|
|
354
|
+
closers.add(stream.end);
|
|
355
|
+
unfollowedListens.add(ul);
|
|
356
|
+
for (const s of served.values()) takeOn(s, ul);
|
|
357
|
+
ul.tell();
|
|
358
|
+
}
|
|
293
359
|
/** /api/stream across every project: as a project's, each event with its project. */
|
|
294
360
|
function streamAll(req, res, query) {
|
|
295
361
|
res.writeHead(200, {
|
package/dist/src/listen.js
CHANGED
|
@@ -12,13 +12,17 @@ const get = (url, onResponse) => (url.startsWith("https:") ? https : http).get(u
|
|
|
12
12
|
* Resolves once the server holds it; with `orNone`, also after a first try that found no server
|
|
13
13
|
* running (a listen reads the log all the same, and registers once one appears).
|
|
14
14
|
*/
|
|
15
|
-
function listen({ at, query, onSnapshot }, { orNone = false } = {}) {
|
|
15
|
+
function listen({ at, query, onSnapshot, onPages, signal }, { orNone = false } = {}) {
|
|
16
16
|
return new Promise((settled) => {
|
|
17
|
+
let current = null;
|
|
18
|
+
signal?.addEventListener("abort", () => current?.destroy());
|
|
17
19
|
const connect = async () => {
|
|
20
|
+
if (signal?.aborted) return settled();
|
|
18
21
|
let base = null;
|
|
19
22
|
try {
|
|
20
23
|
base = await at();
|
|
21
24
|
} catch {}
|
|
25
|
+
if (signal?.aborted) return settled();
|
|
22
26
|
if (!base) {
|
|
23
27
|
if (orNone) settled();
|
|
24
28
|
return setTimeout(connect, 2e3).unref();
|
|
@@ -30,7 +34,7 @@ function listen({ at, query, onSnapshot }, { orNone = false } = {}) {
|
|
|
30
34
|
setTimeout(connect, ms).unref();
|
|
31
35
|
}
|
|
32
36
|
};
|
|
33
|
-
get(`${base}/api/listen?${new URLSearchParams(query)}`, (res) => {
|
|
37
|
+
(current = get(`${base}/api/listen?${new URLSearchParams(query)}`, (res) => {
|
|
34
38
|
res.setEncoding("utf8");
|
|
35
39
|
settled();
|
|
36
40
|
res.socket.unref();
|
|
@@ -44,10 +48,11 @@ function listen({ at, query, onSnapshot }, { orNone = false } = {}) {
|
|
|
44
48
|
const event = /^event: (.*)$/m.exec(block)?.[1];
|
|
45
49
|
const data = /^data: (.*)$/m.exec(block)?.[1];
|
|
46
50
|
if (event === "projects" && data && onSnapshot) onSnapshot(JSON.parse(data));
|
|
51
|
+
if (event === "pages" && data && onPages) onPages(JSON.parse(data));
|
|
47
52
|
}
|
|
48
53
|
});
|
|
49
54
|
res.on("close", () => retry(1e3));
|
|
50
|
-
}).on("error", () => retry(2e3));
|
|
55
|
+
})).on("error", () => retry(2e3));
|
|
51
56
|
};
|
|
52
57
|
connect();
|
|
53
58
|
});
|
|
@@ -73,6 +78,33 @@ function everyProject(start) {
|
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
81
|
+
* A listen on the unfollowed pages: `start` is called once for each page as it joins, to hand out
|
|
82
|
+
* from its project's log; a page that drops out (someone follows it now) is stopped (`signal`).
|
|
83
|
+
* @returns what takes each list of pages the server sends
|
|
84
|
+
*/
|
|
85
|
+
function everyPage(start) {
|
|
86
|
+
const taken = /* @__PURE__ */ new Map();
|
|
87
|
+
return ({ projects }) => {
|
|
88
|
+
const now = /* @__PURE__ */ new Set();
|
|
89
|
+
for (const p of projects) for (const page of p.pages) {
|
|
90
|
+
const key = `${p.dir}\n${page}`;
|
|
91
|
+
now.add(key);
|
|
92
|
+
if (taken.has(key)) continue;
|
|
93
|
+
const stop = new AbortController();
|
|
94
|
+
taken.set(key, stop);
|
|
95
|
+
start({
|
|
96
|
+
dir: p.dir,
|
|
97
|
+
base: p.base,
|
|
98
|
+
page
|
|
99
|
+
}, stop.signal);
|
|
100
|
+
}
|
|
101
|
+
for (const [key, stop] of taken) if (!now.has(key)) {
|
|
102
|
+
stop.abort();
|
|
103
|
+
taken.delete(key);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
76
108
|
* Hold an agent channel's line at the server (/api/channel) for as long as the process runs, and
|
|
77
109
|
* again after the server restarts, then saying it was confirmed: the server forgets that. `move`:
|
|
78
110
|
* the session it serves changed (a resume); it was confirmed for the process, not the session, so
|
|
@@ -129,4 +161,4 @@ function holdChannel(at, first, { onPing, onConfirmed }) {
|
|
|
129
161
|
current?.destroy();
|
|
130
162
|
} };
|
|
131
163
|
}
|
|
132
|
-
export { everyProject, holdChannel, listen };
|
|
164
|
+
export { everyPage, everyProject, holdChannel, listen };
|
package/dist/src/listeners.js
CHANGED
|
@@ -7,10 +7,11 @@ function createRegistry() {
|
|
|
7
7
|
for (const fn of watchers) fn();
|
|
8
8
|
};
|
|
9
9
|
return {
|
|
10
|
-
list: (page = null) => [...listeners].filter((l) => page == null || covers(l, page)).map(({ page, type, agent }) => ({
|
|
10
|
+
list: (page = null) => [...listeners].filter((l) => page == null || covers(l, page)).map(({ page, type, agent, unfollowed }) => ({
|
|
11
11
|
page,
|
|
12
12
|
type,
|
|
13
|
-
agent
|
|
13
|
+
agent,
|
|
14
|
+
...unfollowed && { unfollowed }
|
|
14
15
|
})),
|
|
15
16
|
add(l) {
|
|
16
17
|
listeners.add(l);
|
|
@@ -29,9 +30,18 @@ function createRegistry() {
|
|
|
29
30
|
const listenerOf = (q) => ({
|
|
30
31
|
page: q.get("page") || "",
|
|
31
32
|
type: q.get("type") || null,
|
|
32
|
-
agent: q.get("agent") || null
|
|
33
|
+
agent: q.get("agent") || null,
|
|
34
|
+
...q.has("unfollowed") && { unfollowed: true }
|
|
33
35
|
});
|
|
34
36
|
/**
|
|
37
|
+
* Does `l` follow `page`: is someone there to take whatever comes on it? A listener covering the
|
|
38
|
+
* page, for every type: a running listen on it (or above it, or on every page), and a confirmed
|
|
39
|
+
* channel, which holds one on each page of its session's. A listen for one form only (`--type`)
|
|
40
|
+
* leaves the rest to no one, and a listen on the unfollowed pages follows nothing itself. A
|
|
41
|
+
* subscriber listening nowhere (gone, between turns, or a channel never confirmed) is no listener.
|
|
42
|
+
*/
|
|
43
|
+
const follows = (l, page) => !l.unfollowed && !l.type && covers(l, page);
|
|
44
|
+
/**
|
|
35
45
|
* Hold a /api/listen connection open as an event stream (with a ping, so nothing between closes it
|
|
36
46
|
* as idle). `send` writes an event on it; `onEnd` runs once, when the agent goes or `end` is called.
|
|
37
47
|
*/
|
|
@@ -61,4 +71,4 @@ function holdStream(req, res, onEnd) {
|
|
|
61
71
|
}
|
|
62
72
|
};
|
|
63
73
|
}
|
|
64
|
-
export { createRegistry, holdStream, listenerOf };
|
|
74
|
+
export { createRegistry, follows, holdStream, listenerOf };
|
package/dist/src/loader.js
CHANGED
|
@@ -23,6 +23,7 @@ const BUILTIN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
23
23
|
"release",
|
|
24
24
|
"url",
|
|
25
25
|
"anchors",
|
|
26
|
+
"set",
|
|
26
27
|
"docs",
|
|
27
28
|
"events",
|
|
28
29
|
"listen",
|
|
@@ -130,11 +131,14 @@ function createConfigLoader(proj, { pages: withPages = true, files: filesDefault
|
|
|
130
131
|
ends
|
|
131
132
|
}) : null;
|
|
132
133
|
const declared = (flag) => new Set(plugins.flatMap((p) => Object.entries(p.events ?? {}).filter(([, spec]) => spec?.[flag]).map(([type]) => type)));
|
|
134
|
+
const specs = plugins.flatMap((p) => Object.entries(p.events ?? {}));
|
|
135
|
+
const requires = new Map(specs.flatMap(([type, spec]) => spec?.requires?.length ? [[type, spec.requires]] : []));
|
|
133
136
|
return {
|
|
134
137
|
pages,
|
|
135
138
|
plugins,
|
|
136
139
|
handedOut: declared("handOut"),
|
|
137
|
-
forReader: declared("forReader"),
|
|
140
|
+
forReader: new Map([...declared("forReader")].map((type) => [type, requires.get(type) ?? []])),
|
|
141
|
+
requires,
|
|
138
142
|
publicDirs,
|
|
139
143
|
files: config?.files == null ? filesDefault : config.files !== false,
|
|
140
144
|
fileFilter: fileFilter(config?.files),
|
|
@@ -158,7 +162,8 @@ function createConfigLoader(proj, { pages: withPages = true, files: filesDefault
|
|
|
158
162
|
pages: null,
|
|
159
163
|
plugins: [],
|
|
160
164
|
handedOut: /* @__PURE__ */ new Set(),
|
|
161
|
-
forReader: /* @__PURE__ */ new
|
|
165
|
+
forReader: /* @__PURE__ */ new Map(),
|
|
166
|
+
requires: /* @__PURE__ */ new Map(),
|
|
162
167
|
publicDirs: /* @__PURE__ */ new Map(),
|
|
163
168
|
files: false,
|
|
164
169
|
fileFilter: fileFilter(),
|
package/dist/src/migrate.js
CHANGED
|
@@ -311,4 +311,4 @@ function markdownFiles(target) {
|
|
|
311
311
|
if (fs.statSync(target).isFile()) return [target];
|
|
312
312
|
return fs.readdirSync(target, { withFileTypes: true }).filter((e) => !e.name.startsWith(".") && e.name !== "node_modules").sort((a, b) => a.name.localeCompare(b.name)).flatMap((e) => e.isDirectory() ? markdownFiles(path.join(target, e.name)) : e.name.endsWith(".md") ? [path.join(target, e.name)] : []);
|
|
313
313
|
}
|
|
314
|
-
export { MIGRATIONS, markdownFiles, migrate };
|
|
314
|
+
export { MIGRATIONS, edit, markdownFiles, migrate };
|
package/dist/src/pages/board.js
CHANGED
|
@@ -7,6 +7,11 @@ const waitingOn = (p) => ({
|
|
|
7
7
|
unreceived: p.unreceived
|
|
8
8
|
});
|
|
9
9
|
const total = (w) => w.open + w.unread + w.unreceived;
|
|
10
|
+
/**
|
|
11
|
+
* How much a card needs the reader: something waiting on it first, then the newest update (its file,
|
|
12
|
+
* or an agent's message or question on it) first.
|
|
13
|
+
*/
|
|
14
|
+
const byAttention = (a, b) => Number(total(b.waiting) > 0) - Number(total(a.waiting) > 0) || b.page.updated - a.page.updated;
|
|
10
15
|
/** Every project's pages by state, each column newest first. */
|
|
11
16
|
function byState(projects, now, activeFor = ACTIVE_FOR) {
|
|
12
17
|
const columns = {
|
|
@@ -20,13 +25,13 @@ function byState(projects, now, activeFor = ACTIVE_FOR) {
|
|
|
20
25
|
project,
|
|
21
26
|
waiting: waitingOn(page)
|
|
22
27
|
};
|
|
23
|
-
columns[total(card.waiting) > 0 ? "waiting" : now - page.
|
|
28
|
+
columns[total(card.waiting) > 0 ? "waiting" : page.progress || now - page.updated <= activeFor ? "active" : "quiet"].push(card);
|
|
24
29
|
}
|
|
25
30
|
for (const cards of [
|
|
26
31
|
columns.waiting,
|
|
27
32
|
columns.active,
|
|
28
33
|
columns.quiet
|
|
29
|
-
]) cards.sort(
|
|
34
|
+
]) cards.sort(byAttention);
|
|
30
35
|
return columns;
|
|
31
36
|
}
|
|
32
37
|
/** The projects with pages, a column each, the one changed last first. */
|
|
@@ -36,7 +41,7 @@ function byProject(projects) {
|
|
|
36
41
|
page,
|
|
37
42
|
project,
|
|
38
43
|
waiting: waitingOn(page)
|
|
39
|
-
})).sort(
|
|
44
|
+
})).sort(byAttention);
|
|
40
45
|
return {
|
|
41
46
|
project,
|
|
42
47
|
cards,
|
|
@@ -56,4 +61,4 @@ function byProject(projects) {
|
|
|
56
61
|
function withoutPages(projects) {
|
|
57
62
|
return projects.filter((p) => !p.pages.length).toSorted((a, b) => a.label.localeCompare(b.label));
|
|
58
63
|
}
|
|
59
|
-
export { ACTIVE_FOR, byProject, byState, total, waitingOn, withoutPages };
|
|
64
|
+
export { ACTIVE_FOR, byAttention, byProject, byState, total, waitingOn, withoutPages };
|
package/dist/src/pages/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveBlocks } from "./blocks.js";
|
|
2
2
|
import { createAgentMessageRender, createBlocksRender, createDocs, createMessageRender, createRender } from "./render.js";
|
|
3
|
-
import {
|
|
3
|
+
import { pageAsks } from "./markdown.js";
|
|
4
4
|
// src/pages/index.ts
|
|
5
5
|
function createPages(options) {
|
|
6
6
|
const resolved = resolveBlocks(options.blocks);
|
|
@@ -19,9 +19,7 @@ function createPages(options) {
|
|
|
19
19
|
agentMessage: createAgentMessageRender(blocks, options.links ?? [], options.composers),
|
|
20
20
|
blocks: createBlocksRender(blocks, options.links ?? [], options.composers),
|
|
21
21
|
docs: createDocs(blocks),
|
|
22
|
-
|
|
23
|
-
chats: (page) => chatNames(ended(page).body),
|
|
24
|
-
forms: (page) => formDetails(ended(page).body)
|
|
22
|
+
asks: (page) => pageAsks(ended(page).body)
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
export { createPages };
|