@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/src/define.ts
CHANGED
|
@@ -195,6 +195,12 @@ export interface EventSpec {
|
|
|
195
195
|
* event's id) has been in view; default false
|
|
196
196
|
*/
|
|
197
197
|
forReader?: boolean
|
|
198
|
+
/**
|
|
199
|
+
* the fields of its `data` it can't be without, each a non-empty string (`['chat', 'text']`):
|
|
200
|
+
* `workpad append` and the API refuse one that lacks any, and one in the log that lacks any is
|
|
201
|
+
* no message for the reader, since nothing on the page can show it
|
|
202
|
+
*/
|
|
203
|
+
requires?: string[]
|
|
198
204
|
}
|
|
199
205
|
|
|
200
206
|
export interface Project {
|
|
@@ -329,6 +335,11 @@ export interface CommandContext {
|
|
|
329
335
|
running(): Promise<{ base: string; version: string } | null>
|
|
330
336
|
/** the version of workpad this command runs */
|
|
331
337
|
version: string
|
|
338
|
+
/**
|
|
339
|
+
* who runs it: `--agent`, else `WORKPAD_AGENT`, else the agent session a plugin names; null when
|
|
340
|
+
* none says. The `by` of what the command appends to the log itself.
|
|
341
|
+
*/
|
|
342
|
+
agent: string | null
|
|
332
343
|
/**
|
|
333
344
|
* The project's state as data, and what an agent changes of it: the client of
|
|
334
345
|
* `@bigmistqke/workpad/api`, connected to the project's server (started at its first call when
|
|
@@ -346,9 +357,10 @@ export interface CommandContext {
|
|
|
346
357
|
status(page?: string): Promise<PageStatus[]>
|
|
347
358
|
/**
|
|
348
359
|
* Hand the events on `page` (and below it, unless `exact`) or of `type` to `onEvent`, as `workpad
|
|
349
|
-
* listen` does, for agent `agent`: the reader's and other agents', never its own
|
|
350
|
-
* before, each counted as received (by `agent`) from then on;
|
|
351
|
-
*
|
|
360
|
+
* listen` does, for agent `agent`: the reader's and other agents', never its own (nor those of its
|
|
361
|
+
* `aliases`); also those from before, each counted as received (by `agent`) from then on; a reader's
|
|
362
|
+
* answer it received before and not handled again (`again`), another agent's message never twice.
|
|
363
|
+
* With `follow: false` only those there are now. Resolves with how many.
|
|
352
364
|
* For the log's other primitives, import `@bigmistqke/workpad/log`.
|
|
353
365
|
*/
|
|
354
366
|
handOut(
|
|
@@ -360,6 +372,8 @@ export interface CommandContext {
|
|
|
360
372
|
signal?: AbortSignal
|
|
361
373
|
mark?: boolean
|
|
362
374
|
agent?: string | null
|
|
375
|
+
/** the other ids the agent goes by (its sessions before, the session beside WORKPAD_AGENT), read as events come */
|
|
376
|
+
aliases?: ReadonlySet<string>
|
|
363
377
|
/** an event id: of the backlog before it, what someone received is skipped, the reader's aside (channelSince) */
|
|
364
378
|
skipReceivedBefore?: string
|
|
365
379
|
},
|
|
@@ -367,9 +381,21 @@ export interface CommandContext {
|
|
|
367
381
|
/**
|
|
368
382
|
* Listen on `page` at the project's server as `agent`, as `workpad listen` does, for as
|
|
369
383
|
* long as the command runs: the page and `workpad status` show who listens. Any number listen on
|
|
370
|
-
* a page; resolves once the server holds it.
|
|
384
|
+
* a page; resolves once the server holds it. `signal` lets go of it (the session moved on).
|
|
371
385
|
*/
|
|
372
|
-
listen(page: string, options?: { agent?: string | null }): Promise<void>
|
|
386
|
+
listen(page: string, options?: { agent?: string | null; signal?: AbortSignal }): Promise<void>
|
|
387
|
+
/**
|
|
388
|
+
* Take the pages no one follows (`workpad listen --unfollowed`), as `agent`, until `signal`
|
|
389
|
+
* aborts: listen on each, and hand the reader's answers there that no other agent received to
|
|
390
|
+
* `onEvent`, as handOut does (received by `agent` unless `mark` is false). A page drops out once someone follows it and
|
|
391
|
+
* joins when its last follower goes; new pages join. Under the shared server they are the pages
|
|
392
|
+
* of every project of this one's entry, and `from` says where each answer is (its project's
|
|
393
|
+
* folder, its page's address); else null. Resolves once the server holds it.
|
|
394
|
+
*/
|
|
395
|
+
unfollowed(
|
|
396
|
+
onEvent: (event: WpEvent, again: boolean, from: { project: string; url: string } | null) => void,
|
|
397
|
+
options?: { agent?: string | null; mark?: boolean; signal?: AbortSignal },
|
|
398
|
+
): Promise<void>
|
|
373
399
|
/**
|
|
374
400
|
* Be the channel of agent `session`, a plugin's command that pushes answers into it, for as long
|
|
375
401
|
* as the command runs. Whether its messages reach the agent only the agent can say: `workpad
|
|
@@ -412,6 +438,8 @@ export interface PageStatus {
|
|
|
412
438
|
unhandled: WpEvent[]
|
|
413
439
|
/** the chats on the page whose latest message is the reader's: waiting for the agent's reply */
|
|
414
440
|
awaitingReply: string[]
|
|
441
|
+
/** when an agent last added to the page's log (a message, a question in a chat), or null */
|
|
442
|
+
updated: string | null
|
|
415
443
|
/** the running waits and watches that cover the page */
|
|
416
444
|
listeners: Listener[]
|
|
417
445
|
}
|
|
@@ -484,12 +512,29 @@ export interface IndexPage {
|
|
|
484
512
|
url: string
|
|
485
513
|
/** when its file last changed, in ms */
|
|
486
514
|
mtime: number
|
|
515
|
+
/** when it last changed for the reader, in ms: its file, or an agent's message or question on it */
|
|
516
|
+
updated: number
|
|
487
517
|
/** its questions waiting for the reader */
|
|
488
518
|
open: string[]
|
|
489
519
|
/** the agent's messages on it the reader hasn't read */
|
|
490
520
|
unread: number
|
|
491
521
|
/** the reader's answers no agent received */
|
|
492
522
|
unreceived: number
|
|
523
|
+
/** the progress running on it that moved last (plugins/progress), or null: its line on the card */
|
|
524
|
+
progress?: IndexProgress | null
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/** A running progress, as a card on the overview shows it. */
|
|
528
|
+
export interface IndexProgress {
|
|
529
|
+
id: string
|
|
530
|
+
note: string
|
|
531
|
+
/** how far, out of `total`; null without a count */
|
|
532
|
+
n: number | null
|
|
533
|
+
total: number | null
|
|
534
|
+
/** when it last moved */
|
|
535
|
+
ts: string
|
|
536
|
+
/** no update for long, or past its ETA */
|
|
537
|
+
stale: boolean
|
|
493
538
|
}
|
|
494
539
|
|
|
495
540
|
/** A project, as the shared server's index gives it (/api/index, the overview). */
|
|
@@ -503,7 +548,7 @@ export interface IndexProject {
|
|
|
503
548
|
base: string
|
|
504
549
|
/** its pages, the latest changed first */
|
|
505
550
|
pages: IndexPage[]
|
|
506
|
-
/** when one of its pages last
|
|
551
|
+
/** when one of its pages was last updated (IndexPage.updated); 0 without pages */
|
|
507
552
|
active: number
|
|
508
553
|
error?: string
|
|
509
554
|
}
|
|
@@ -611,8 +656,19 @@ export interface WpEvent {
|
|
|
611
656
|
* session a plugin names. An agent's events reach every listener but this identity.
|
|
612
657
|
*/
|
|
613
658
|
by?: string
|
|
659
|
+
/**
|
|
660
|
+
* the agent session it was written in, when the command line knew one and it isn't `by` (the
|
|
661
|
+
* writer was named by `--agent` or `WORKPAD_AGENT`): a listener known by that session doesn't
|
|
662
|
+
* get it either, it is its own
|
|
663
|
+
*/
|
|
664
|
+
session?: string
|
|
614
665
|
/** in the browser: a wait or watch handed this event to an agent */
|
|
615
666
|
received?: true
|
|
667
|
+
/**
|
|
668
|
+
* in the browser: who received it first, as the page names them: the name the agent gave itself
|
|
669
|
+
* (`workpad agent name`), else its id (a long one cut short); absent when it gave neither
|
|
670
|
+
*/
|
|
671
|
+
receivedBy?: string
|
|
616
672
|
/** in the browser: the agent handled this event (acknowledged it, or replied to it) */
|
|
617
673
|
handled?: true
|
|
618
674
|
/**
|
|
@@ -635,12 +691,21 @@ export interface Listener {
|
|
|
635
691
|
agent: string | null
|
|
636
692
|
/** the name the agent gave itself (`workpad agent name`), when it did: as the server lists it */
|
|
637
693
|
name?: string
|
|
694
|
+
/**
|
|
695
|
+
* held by `workpad listen --unfollowed` on a page no one else follows: it listens there, but
|
|
696
|
+
* follows nothing, so it never keeps another such listen off the page (listeners.ts, follows)
|
|
697
|
+
*/
|
|
698
|
+
unfollowed?: true
|
|
638
699
|
}
|
|
639
700
|
|
|
640
701
|
/** How a toast looks and acts (Api.toast). */
|
|
641
702
|
export interface ToastOptions {
|
|
642
|
-
/**
|
|
643
|
-
|
|
703
|
+
/**
|
|
704
|
+
* its colour: `info` (the accent, the default), `warn`, or `alert` (as for what is new); or
|
|
705
|
+
* `quiet`, a card in the page's own surface and text colours, for what stays a while without
|
|
706
|
+
* asking anything (a progress), with `meta` and `bar`
|
|
707
|
+
*/
|
|
708
|
+
kind?: 'info' | 'warn' | 'alert' | 'quiet'
|
|
644
709
|
/** milliseconds before it goes, 7000 by default; 0: it stays until closed through its `Toast` */
|
|
645
710
|
ms?: number
|
|
646
711
|
/** what a click on it does (go to what it is about); a toast that goes by itself also closes */
|
|
@@ -656,12 +721,26 @@ export interface ToastOptions {
|
|
|
656
721
|
* this under it (and keeps it open while it is read). Keep `text` a few words, and put the why here.
|
|
657
722
|
*/
|
|
658
723
|
details?: string
|
|
724
|
+
/** a few muted words at the right of its line: a time (`~20 min left`, `just now`) */
|
|
725
|
+
meta?: string
|
|
726
|
+
/**
|
|
727
|
+
* a thin bar under its line: how far (0 to 1; null: no count, a stripe that moves), in the
|
|
728
|
+
* accent, or `good` (green) or `bad` (red)
|
|
729
|
+
*/
|
|
730
|
+
bar?: ToastBar
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/** A toast's bar (ToastOptions.bar). */
|
|
734
|
+
export interface ToastBar {
|
|
735
|
+
value: number | null
|
|
736
|
+
tone?: 'accent' | 'good' | 'bad'
|
|
659
737
|
}
|
|
660
738
|
|
|
661
739
|
/** A toast on the screen: change what it says (a count), hide it and show it again, or close it. */
|
|
662
740
|
export interface Toast {
|
|
663
741
|
close(): void
|
|
664
|
-
|
|
742
|
+
/** its text, and its `meta` and `bar` when given (null takes one away) */
|
|
743
|
+
update(text: string, more?: { meta?: string | null; bar?: ToastBar | null }): void
|
|
665
744
|
hide(): void
|
|
666
745
|
show(): void
|
|
667
746
|
}
|
|
@@ -759,6 +838,32 @@ export interface Api {
|
|
|
759
838
|
* count). It changes when the forms are marked again: the log, the listeners or the page changed.
|
|
760
839
|
*/
|
|
761
840
|
forms: Reactive<FormStatus[]>
|
|
841
|
+
/**
|
|
842
|
+
* Where each of the reader's events for an agent went (a form's answer, a chat message, a
|
|
843
|
+
* comment), by its id: on its way, waiting for an agent (or for anyone to follow the page at
|
|
844
|
+
* all), late, received by whom, handled. For a line beside what was sent. It changes with the
|
|
845
|
+
* log, with who listens, and as an answer waits long enough to be late (NOT_RECEIVED_AFTER).
|
|
846
|
+
*/
|
|
847
|
+
delivery: Reactive<ReadonlyMap<string, Delivery>>
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Where one of the reader's events for an agent went (Api.delivery):
|
|
852
|
+
* - sending: on its way to the server (retried while it doesn't answer)
|
|
853
|
+
* - waiting: in the log, and someone listens on the page: an agent will receive it
|
|
854
|
+
* - unfollowed: in the log, and no one listens on the page: it waits until an agent does
|
|
855
|
+
* - late: no agent received it for NOT_RECEIVED_AFTER (`nobody`: and no one listens now)
|
|
856
|
+
* - received: an agent has it (`by` says who, when it said)
|
|
857
|
+
* - handled: an agent is done with it: it said so, or replied
|
|
858
|
+
*/
|
|
859
|
+
export interface Delivery {
|
|
860
|
+
state: 'sending' | 'waiting' | 'unfollowed' | 'late' | 'received' | 'handled'
|
|
861
|
+
/** a few words saying so, for beside what was sent */
|
|
862
|
+
text: string
|
|
863
|
+
/** received: who received it (WpEvent.receivedBy) */
|
|
864
|
+
by?: string
|
|
865
|
+
/** late: and no one listens on the page now */
|
|
866
|
+
nobody?: boolean
|
|
762
867
|
}
|
|
763
868
|
|
|
764
869
|
/**
|
|
@@ -931,6 +1036,12 @@ interface BaseContext {
|
|
|
931
1036
|
inline(src: string): Promise<string>
|
|
932
1037
|
/** what a client gets when the block has no props() */
|
|
933
1038
|
defaults(): Promise<Record<string, unknown>>
|
|
1039
|
+
/**
|
|
1040
|
+
* Report what is wrong with the block as written, for whoever wrote the page, in one sentence (a
|
|
1041
|
+
* value it doesn't know): shown above the page and listed by `workpad check` (Rendered.problems).
|
|
1042
|
+
* The block still renders as best it can. Nothing in an agent's chat message: nobody there can fix it.
|
|
1043
|
+
*/
|
|
1044
|
+
problem(text: string): void
|
|
934
1045
|
}
|
|
935
1046
|
|
|
936
1047
|
/** `:::name[label]{attrs}` … `:::`, `::name[label]{attrs}`, `:name[label]{attrs}` */
|
package/src/document.ts
CHANGED
|
@@ -43,8 +43,10 @@ export interface PageParts {
|
|
|
43
43
|
slots: { [K in Exclude<SlotName, 'header'>]: Slotted[] }
|
|
44
44
|
/** their browser modules, which the runtime imports after the page's */
|
|
45
45
|
clients: { name: string; client: string }[]
|
|
46
|
-
/** the event types that, from the agent, are messages for the reader (EventSpec.forReader) */
|
|
47
|
-
messages: string[]
|
|
46
|
+
/** the event types that, from the agent, are messages for the reader (EventSpec.forReader), each with the `data` fields it requires */
|
|
47
|
+
messages: Record<string, string[]>
|
|
48
|
+
/** the plugins' event types that, from the reader, go to an agent (EventSpec.handOut) */
|
|
49
|
+
handedOut: string[]
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
@@ -58,11 +60,14 @@ export async function pluginParts(
|
|
|
58
60
|
{
|
|
59
61
|
asset,
|
|
60
62
|
messages,
|
|
63
|
+
handedOut = [],
|
|
61
64
|
leaveOut = new Set(),
|
|
62
65
|
failed,
|
|
63
66
|
}: {
|
|
64
67
|
asset(ref: string | URL): string
|
|
65
|
-
messages: string[]
|
|
68
|
+
messages: Record<string, string[]>
|
|
69
|
+
/** none on a built page: nothing it sends goes anywhere */
|
|
70
|
+
handedOut?: string[]
|
|
66
71
|
leaveOut?: ReadonlySet<string>
|
|
67
72
|
failed(message: string): void
|
|
68
73
|
},
|
|
@@ -95,6 +100,7 @@ export async function pluginParts(
|
|
|
95
100
|
},
|
|
96
101
|
clients: working.filter(h => h.client).map(h => ({ name: h.name, client: asset(h.client!) })),
|
|
97
102
|
messages,
|
|
103
|
+
handedOut,
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
|
|
@@ -123,7 +129,14 @@ const DOCK_STYLE =
|
|
|
123
129
|
'.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}' +
|
|
124
130
|
// a toast's details (ToastOptions.details): a ▸ on its line, unfolding them under it
|
|
125
131
|
'.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}' +
|
|
126
|
-
'.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}'
|
|
132
|
+
'.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}' +
|
|
133
|
+
// a quiet toast (kind quiet): a card in the page's colours, its time at the right, a thin bar under
|
|
134
|
+
'.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}' +
|
|
135
|
+
'.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}' +
|
|
136
|
+
'.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)}' +
|
|
137
|
+
'.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)}' +
|
|
138
|
+
'@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}' +
|
|
139
|
+
'@media (prefers-reduced-motion:reduce){.wp-toast-bar[data-indeterminate] span{animation:none;left:0;width:100%;opacity:.5}}'
|
|
127
140
|
|
|
128
141
|
/** How a page is put out: by the server (live) or by a build (a file with no server behind it). */
|
|
129
142
|
export interface Output {
|
|
@@ -161,6 +174,7 @@ export function pageDocument(
|
|
|
161
174
|
frontmatter: frontmatterOf(page),
|
|
162
175
|
plugins: parts.clients,
|
|
163
176
|
messages: parts.messages,
|
|
177
|
+
handedOut: parts.handedOut,
|
|
164
178
|
...(o.stamps && { stamps: o.stamps }),
|
|
165
179
|
}
|
|
166
180
|
// the page's head and html are HTML already; the handoff is JSON made safe for a script tag
|
|
@@ -172,7 +186,7 @@ export function pageDocument(
|
|
|
172
186
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
173
187
|
<title>${out.title || page.id || o.title}</title>
|
|
174
188
|
<style>
|
|
175
|
-
${DOCK_STYLE}
|
|
189
|
+
${raw(DOCK_STYLE)}
|
|
176
190
|
</style>
|
|
177
191
|
${raw(String(out.head ?? ''))}${parts.head}
|
|
178
192
|
</head>
|
package/src/events.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
namesOf,
|
|
23
23
|
receivedIds,
|
|
24
24
|
subscriptions,
|
|
25
|
+
takesUnfollowed,
|
|
25
26
|
} from './status.ts'
|
|
26
27
|
|
|
27
28
|
export {
|
|
@@ -37,6 +38,7 @@ export {
|
|
|
37
38
|
namesOf,
|
|
38
39
|
receivedIds,
|
|
39
40
|
subscriptions,
|
|
41
|
+
takesUnfollowed,
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/** What is appended: the id and time are added. */
|
|
@@ -68,13 +70,16 @@ export const isEventId = (id: unknown): id is string =>
|
|
|
68
70
|
/**
|
|
69
71
|
* Append one event; `action` is the button that submitted a form, null for anything else. `from`
|
|
70
72
|
* is set only for events the command line writes ('cli'), so that waits skip them and pages can
|
|
71
|
-
* tell them apart; what the browser appends has none.
|
|
73
|
+
* tell them apart; what the browser appends has none. `by` is who wrote it; `session`, the agent
|
|
74
|
+
* session it was written in, when that is another id than `by` (`WORKPAD_AGENT` named the writer):
|
|
75
|
+
* a channel that knows the agent by its session still knows the event for its own.
|
|
72
76
|
*/
|
|
73
77
|
export function appendEvent(
|
|
74
78
|
file: string,
|
|
75
79
|
input: EventInput,
|
|
76
80
|
from: 'cli' | null = null,
|
|
77
81
|
by: string | null = null,
|
|
82
|
+
session: string | null = null,
|
|
78
83
|
): WpEvent {
|
|
79
84
|
const event: WpEvent = {
|
|
80
85
|
id: isEventId(input.id) ? input.id : `${Date.now().toString(36)}-${crypto.randomBytes(3).toString('hex')}`,
|
|
@@ -85,6 +90,7 @@ export function appendEvent(
|
|
|
85
90
|
data: input.data ?? {},
|
|
86
91
|
...(from ? { from } : {}),
|
|
87
92
|
...(by ? { by } : {}),
|
|
93
|
+
...(session && session !== by ? { session } : {}),
|
|
88
94
|
}
|
|
89
95
|
fs.appendFileSync(file, JSON.stringify(event) + '\n')
|
|
90
96
|
return event
|
|
@@ -361,6 +367,13 @@ export interface HandOutOptions {
|
|
|
361
367
|
* handed to it, other agents' are; its received marks say it; `again` is what it received before.
|
|
362
368
|
*/
|
|
363
369
|
agent?: string | null
|
|
370
|
+
/**
|
|
371
|
+
* The other ids `agent` goes by, read as each event comes (a channel adds to it): the sessions
|
|
372
|
+
* its conversation had before (a resume, a clear), the session beside its `WORKPAD_AGENT`. An
|
|
373
|
+
* event any of them wrote (`by`, or the `session` it was written in) is its own too, and what
|
|
374
|
+
* they received it received before.
|
|
375
|
+
*/
|
|
376
|
+
aliases?: ReadonlySet<string>
|
|
364
377
|
/**
|
|
365
378
|
* Mark each as received once handed out (default true). Without, the receiver marks it itself
|
|
366
379
|
* once it has it (a channel: once its message is in the session).
|
|
@@ -372,13 +385,26 @@ export interface HandOutOptions {
|
|
|
372
385
|
* gets what is new, not other agents' talk from before; `listen --wait` still hands it all out.
|
|
373
386
|
*/
|
|
374
387
|
skipReceivedBefore?: string
|
|
388
|
+
/**
|
|
389
|
+
* Only the reader's events, no agent's: a listen on the pages no one follows takes the answers
|
|
390
|
+
* waiting there, not what the page's own agents said on them.
|
|
391
|
+
*/
|
|
392
|
+
readerOnly?: boolean
|
|
393
|
+
/**
|
|
394
|
+
* Leave out what another agent received: it has it, and is on it (or handed it on). A listen on
|
|
395
|
+
* the pages no one follows takes what reached nobody, not what a session left for between turns.
|
|
396
|
+
*/
|
|
397
|
+
notReceivedByOthers?: boolean
|
|
375
398
|
}
|
|
376
399
|
|
|
377
400
|
/**
|
|
378
401
|
* Hand the events that match `filter` to `onEvent`, for agent `agent`: the reader's, and other
|
|
379
|
-
* agents' (an agent's event says who wrote it, `by`; one that doesn't is handed to no one)
|
|
380
|
-
*
|
|
381
|
-
*
|
|
402
|
+
* agents' (an agent's event says who wrote it, `by`; one that doesn't is handed to no one), never
|
|
403
|
+
* its own (written by `agent` or one of its `aliases`). Each is marked received by `agent` once
|
|
404
|
+
* handed out. First the backlog: what is not handled, also from before this started; of the
|
|
405
|
+
* reader's, those `agent` received before come again, saying so (`again`), until handled; another
|
|
406
|
+
* agent's message it received before doesn't: a message is news once, and an agent's message is
|
|
407
|
+
* never handled by a reply, so it would come back at every start. Then, with `follow`, every new one as
|
|
382
408
|
* it comes. The backlog and the following split the log at one line boundary, so no event falls
|
|
383
409
|
* between them. Any number hand out from one log at once: each gets every event. Of the plugins'
|
|
384
410
|
* events only those for an agent (`forAgent`), unless the filter asks for a type by name.
|
|
@@ -401,7 +427,10 @@ export function handOut(
|
|
|
401
427
|
batch = false,
|
|
402
428
|
mark = true,
|
|
403
429
|
agent = null,
|
|
430
|
+
aliases = new Set<string>(),
|
|
404
431
|
skipReceivedBefore,
|
|
432
|
+
readerOnly = false,
|
|
433
|
+
notReceivedByOthers = false,
|
|
405
434
|
} = options
|
|
406
435
|
return new Promise(resolve => {
|
|
407
436
|
let got = 0
|
|
@@ -412,7 +441,9 @@ export function handOut(
|
|
|
412
441
|
resolve(got)
|
|
413
442
|
}
|
|
414
443
|
// whose events: the reader's, and another agent's that says who it is
|
|
415
|
-
const
|
|
444
|
+
const me = (id: string | undefined) => !!id && (id === agent || aliases.has(id))
|
|
445
|
+
const own = (e: WpEvent) => me(e.by) || me(e.session)
|
|
446
|
+
const fromOthers = (e: WpEvent) => fromReader(e) || (!readerOnly && !!e.by && !own(e))
|
|
416
447
|
// of those, the ones for an agent, unless the filter names a type
|
|
417
448
|
const wanted = (e: WpEvent) => fromOthers(e) && matches(e, filter) && (!!filter.type || isForAgent(e.type))
|
|
418
449
|
// what this identity received before, by id: handed out again, it says so
|
|
@@ -428,13 +459,23 @@ export function handOut(
|
|
|
428
459
|
const { events, end } = read(file)
|
|
429
460
|
const handled = handledIds(events)
|
|
430
461
|
before = receivedBy(events, agent)
|
|
462
|
+
for (const alias of aliases) for (const id of receivedBy(events, alias)) before.add(id)
|
|
463
|
+
const others = notReceivedByOthers
|
|
464
|
+
? new Set(
|
|
465
|
+
events
|
|
466
|
+
.filter(e => e.type === RECEIVED && !fromReader(e) && !me(e.by) && (e.by ?? null) !== agent)
|
|
467
|
+
.map(e => String(e.data?.event)),
|
|
468
|
+
)
|
|
469
|
+
: new Set<string>()
|
|
431
470
|
// the past before a channel's subscription: what someone received, unless it is the reader's
|
|
432
471
|
let skipping = !!skipReceivedBefore
|
|
433
472
|
const receivedAny = skipping ? receivedIds(events) : new Set<string>()
|
|
434
473
|
for (const e of events) {
|
|
435
474
|
if (skipping && e.id === skipReceivedBefore) skipping = false
|
|
436
475
|
if (skipping && !fromReader(e) && receivedAny.has(e.id)) continue
|
|
437
|
-
|
|
476
|
+
// another agent's message this agent had already: not again
|
|
477
|
+
if (!fromReader(e) && before.has(e.id)) continue
|
|
478
|
+
if (wanted(e) && !handled.has(e.id) && !others.has(e.id) && !hand(e)) return finish()
|
|
438
479
|
}
|
|
439
480
|
// a batch: what there was, if anything; else it goes on for the first to come
|
|
440
481
|
if (batch && got) return finish()
|
package/src/help.ts
CHANGED
|
@@ -47,8 +47,10 @@ opencode()). Alone, it says your id and your name.
|
|
|
47
47
|
confirmed, the channel listens on your pages, and the answers it brings count
|
|
48
48
|
as received. No channel (exit 1), or no pong: nothing brings answers here, so
|
|
49
49
|
listen for them. --wait: run it in the background; it pings and ends when
|
|
50
|
-
the pong is confirmed (exit 0), or
|
|
51
|
-
(exit 1): then listen
|
|
50
|
+
the pong is confirmed (exit 0), or --timeout seconds (120) after the
|
|
51
|
+
session's turn ended without one (exit 1): then listen. A pong comes only
|
|
52
|
+
once the turn ends, so it waits while the turn runs, 30 minutes at most;
|
|
53
|
+
where its plugin records no turn ends, it counts from the ping.`,
|
|
52
54
|
},
|
|
53
55
|
|
|
54
56
|
show: {
|
|
@@ -64,10 +66,10 @@ opencode()). Alone, it says your id and your name.
|
|
|
64
66
|
"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.",
|
|
65
67
|
},
|
|
66
68
|
settle: {
|
|
67
|
-
usage: '<page|file> <form>… | --all',
|
|
69
|
+
usage: '<page|file> <form>… | --all | <form> --replace-with <file|->',
|
|
68
70
|
summary: 'settle questions answered elsewhere (a chat, the design moving on): no longer unanswered',
|
|
69
71
|
details:
|
|
70
|
-
"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.",
|
|
72
|
+
"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",
|
|
71
73
|
},
|
|
72
74
|
hold: {
|
|
73
75
|
usage: '<page|file> <form>… "<reason>"',
|
|
@@ -81,9 +83,9 @@ opencode()). Alone, it says your id and your name.
|
|
|
81
83
|
},
|
|
82
84
|
check: {
|
|
83
85
|
usage: '[<page|file>…]',
|
|
84
|
-
summary: "what is wrong on pages, as they render: a block nobody brings, an input outside its form, a block's error",
|
|
86
|
+
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",
|
|
85
87
|
details:
|
|
86
|
-
"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
|
|
88
|
+
"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.",
|
|
87
89
|
},
|
|
88
90
|
anchors: {
|
|
89
91
|
usage: '<page|file>',
|
|
@@ -91,6 +93,31 @@ opencode()). Alone, it says your id and your name.
|
|
|
91
93
|
details:
|
|
92
94
|
"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.",
|
|
93
95
|
},
|
|
96
|
+
set: {
|
|
97
|
+
usage: '<page|file> <anchor|form> --file <file|->',
|
|
98
|
+
summary: "replace one block of a page by its name: a form, a heading's section, a chat or other named block",
|
|
99
|
+
details: `The markdown comes from a file, or with - from standard input (a heredoc with a quoted
|
|
100
|
+
delimiter: nothing in it passes through the shell's quoting). The block is found by parsing the
|
|
101
|
+
page, as a link names it (\`workpad anchors\`):
|
|
102
|
+
|
|
103
|
+
#form:logger the :::form{name=logger} container
|
|
104
|
+
#open-questions a heading's section: the heading and what follows, up to the next heading
|
|
105
|
+
of the same or a higher level (a deeper one is inside it)
|
|
106
|
+
#chat:notes a :::chat{name=notes}; any block with a name: #<type>:<name>, or with a
|
|
107
|
+
label: #details:why-not-mdx, #item:parser
|
|
108
|
+
logger a bare name: the block whose anchor it is, or whose name it is (form:logger);
|
|
109
|
+
when it fits two (a heading and a form), name it by its anchor, with its #
|
|
110
|
+
|
|
111
|
+
Everything else on the page stays as it was, byte for byte; a form in a code fence is never touched.
|
|
112
|
+
A name the page doesn't have exits 1, listing the blocks it has. To settle a form and put what was
|
|
113
|
+
decided in its place in one step: workpad settle <page> <form> --replace-with <file|->.
|
|
114
|
+
|
|
115
|
+
workpad set plan '#open-questions' --file - <<'EOF'
|
|
116
|
+
## Open questions
|
|
117
|
+
|
|
118
|
+
None left.
|
|
119
|
+
EOF`,
|
|
120
|
+
},
|
|
94
121
|
migrate: {
|
|
95
122
|
usage: '[<folder|file>…] [--write]',
|
|
96
123
|
summary: "after updating workpad: rewrite pages written in an older syntax in the current one",
|
|
@@ -129,9 +156,11 @@ One chat's messages: workpad chat prune <page|file> <chat>.`,
|
|
|
129
156
|
--skip <a,b> plugins or blocks to leave out (default: form, chat, comments, draft)`,
|
|
130
157
|
},
|
|
131
158
|
edit: {
|
|
132
|
-
usage: '<event id> --data <json>',
|
|
159
|
+
usage: '<event id> --data <json> | --file <file|-> | --text-file <file|->',
|
|
133
160
|
summary: "change an agent's own event in place (merged into its data)",
|
|
134
|
-
details:
|
|
161
|
+
details: `Keeps its id, so what refers to it still does. What the reader sent can't be edited.
|
|
162
|
+
The data is taken as append takes it: --data, --file (JSON from a file, or - for standard input),
|
|
163
|
+
--text-file (markdown as its text).`,
|
|
135
164
|
},
|
|
136
165
|
scroll: {
|
|
137
166
|
usage: '<page|file> <where>',
|
|
@@ -154,7 +183,7 @@ One chat's messages: workpad chat prune <page|file> <chat>.`,
|
|
|
154
183
|
--follow then print each new one as it comes`,
|
|
155
184
|
},
|
|
156
185
|
listen: {
|
|
157
|
-
usage: '[--page <p>…] [--type <t>] [--wait [--timeout <s>] | --channel] [--agent <who>]',
|
|
186
|
+
usage: '[--page <p>… | --unfollowed] [--type <t>] [--wait [--timeout <s>] | --channel] [--agent <who>]',
|
|
158
187
|
summary:
|
|
159
188
|
"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",
|
|
160
189
|
details: `${FILTERS}
|
|
@@ -162,6 +191,7 @@ One chat's messages: workpad chat prune <page|file> <chat>.`,
|
|
|
162
191
|
--wait stop once it printed: all there are, or with none, the first to come
|
|
163
192
|
--timeout <seconds> with --wait: exit 2 when nothing came
|
|
164
193
|
--channel make the pages yours and exit: your session's channel brings their answers
|
|
194
|
+
--unfollowed the pages no live session follows, for a coordinator: see below
|
|
165
195
|
--agent <who> who listens (else WORKPAD_AGENT, else the session an agent plugin names)
|
|
166
196
|
|
|
167
197
|
It prints, one line each, everything on the page you haven't handled, also from before it started,
|
|
@@ -177,11 +207,28 @@ answers to handle, chats waiting for your reply, questions still unanswered.
|
|
|
177
207
|
|
|
178
208
|
Any number listen on a page, and each hears everything there but its own events: agents can talk
|
|
179
209
|
to each other in the same chats. Without --page it listens on every page (in a project of the
|
|
180
|
-
machine's entries, every page of the entry)
|
|
210
|
+
machine's entries, every page of the entry).
|
|
211
|
+
|
|
212
|
+
--unfollowed is for a coordinator, so no page swallows an answer: it listens on every page no live
|
|
213
|
+
session follows (in a project of the machine's entries, in every project of the entry, each line
|
|
214
|
+
with its \`project\` and \`url\`), and hands out the reader's answers there that no other agent
|
|
215
|
+
received. Following is listening now: a running listen on the page, or a confirmed channel of a
|
|
216
|
+
session it belongs to; a subscriber that is gone, between turns, or whose channel was never
|
|
217
|
+
confirmed follows nothing. A page drops out while someone follows it, and joins when its last
|
|
218
|
+
follower goes, as do new pages. What it hands out counts as received by you. With --channel your
|
|
219
|
+
confirmed channel takes these pages on (none becomes yours) and it exits.`,
|
|
181
220
|
},
|
|
182
221
|
append: {
|
|
183
|
-
usage: '--page <p> --type <t> [--data <json>]',
|
|
222
|
+
usage: '--page <p> --type <t> [--data <json> | --file <file|->] [--text-file <file|->]',
|
|
184
223
|
summary: "add an event to a page's log, as the agent (a reply, a chat message)",
|
|
224
|
+
details: ` --data <json> its data, as JSON on the command line: for short data without markdown
|
|
225
|
+
--file <file|-> its data, as JSON from a file, or - for standard input
|
|
226
|
+
--text-file <file|-> markdown from a file, or - for standard input, as the data's "text" (with
|
|
227
|
+
--data or --file for the rest): a chat reply, without shell quoting
|
|
228
|
+
|
|
229
|
+
workpad append --page plan --type chat:message --data '{"chat":"page"}' --text-file - <<'EOF'
|
|
230
|
+
It's **done**: see [the logger question](#form:logger).
|
|
231
|
+
EOF`,
|
|
185
232
|
},
|
|
186
233
|
handled: {
|
|
187
234
|
usage: '<event id> [<event id>…]',
|