@bigmistqke/whiteboard 0.0.0-stage → 0.1.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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +609 -2
  3. package/bin/whiteboard.ts +431 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  5. package/dist/bin/whiteboard.js +471 -0
  6. package/dist/client/runtime.js +391 -0
  7. package/dist/define.js +7 -0
  8. package/dist/plugins/callout/README.md +13 -0
  9. package/dist/plugins/callout/index.js +27 -0
  10. package/dist/plugins/callout/style.css +12 -0
  11. package/dist/plugins/chat/README.md +45 -0
  12. package/dist/plugins/chat/client.js +3 -0
  13. package/dist/plugins/chat/index.js +46 -0
  14. package/dist/plugins/chat/style.css +17 -0
  15. package/dist/plugins/claude-code/index.js +120 -0
  16. package/dist/plugins/code/README.md +42 -0
  17. package/dist/plugins/code/diff.js +64 -0
  18. package/dist/plugins/code/index.js +77 -0
  19. package/dist/plugins/code/style.css +29 -0
  20. package/dist/plugins/comments/client.js +10 -0
  21. package/dist/plugins/comments/index.js +51 -0
  22. package/dist/plugins/comments/style.css +32 -0
  23. package/dist/plugins/details/README.md +17 -0
  24. package/dist/plugins/details/index.js +17 -0
  25. package/dist/plugins/details/style.css +3 -0
  26. package/dist/plugins/form/README.md +111 -0
  27. package/dist/plugins/form/index.js +102 -0
  28. package/dist/plugins/form/style.css +41 -0
  29. package/dist/plugins/gallery/README.md +30 -0
  30. package/dist/plugins/gallery/client.js +1 -0
  31. package/dist/plugins/gallery/index.js +74 -0
  32. package/dist/plugins/gallery/style.css +27 -0
  33. package/dist/plugins/grid/README.md +33 -0
  34. package/dist/plugins/grid/index.js +33 -0
  35. package/dist/plugins/grid/style.css +25 -0
  36. package/dist/plugins/index.js +26 -0
  37. package/dist/plugins/mermaid/README.md +21 -0
  38. package/dist/plugins/mermaid/index.js +34 -0
  39. package/dist/plugins/mermaid/style.css +16 -0
  40. package/dist/plugins/quiet/README.md +26 -0
  41. package/dist/plugins/quiet/index.js +17 -0
  42. package/dist/plugins/terminal/client.js +41 -0
  43. package/dist/plugins/terminal/host.js +332 -0
  44. package/dist/plugins/terminal/index.js +171 -0
  45. package/dist/plugins/terminal/modes.js +32 -0
  46. package/dist/plugins/terminal/server.js +256 -0
  47. package/dist/plugins/terminal/sizes.js +57 -0
  48. package/dist/plugins/terminal/style.css +357 -0
  49. package/dist/solid/index.js +35 -0
  50. package/dist/src/auth.js +54 -0
  51. package/dist/src/client/page/base.css +274 -0
  52. package/dist/src/client/page/main.js +1004 -0
  53. package/dist/src/config.js +76 -0
  54. package/dist/src/events.js +162 -0
  55. package/dist/src/html.js +34 -0
  56. package/dist/src/load.js +77 -0
  57. package/dist/src/loader.js +120 -0
  58. package/dist/src/package.js +33 -0
  59. package/dist/src/pages/blocks.js +49 -0
  60. package/dist/src/pages/index.js +14 -0
  61. package/dist/src/pages/markdown.js +307 -0
  62. package/dist/src/pages/render.js +257 -0
  63. package/dist/src/plugins.js +238 -0
  64. package/dist/src/running.js +24 -0
  65. package/dist/src/serve.js +71 -0
  66. package/dist/src/server.js +700 -0
  67. package/dist/src/status.js +43 -0
  68. package/package.json +131 -4
  69. package/plugins/callout/README.md +13 -0
  70. package/plugins/callout/index.ts +25 -0
  71. package/plugins/callout/style.css +12 -0
  72. package/plugins/chat/README.md +45 -0
  73. package/plugins/chat/autosize.ts +101 -0
  74. package/plugins/chat/client.tsx +81 -0
  75. package/plugins/chat/index.ts +61 -0
  76. package/plugins/chat/style.css +17 -0
  77. package/plugins/claude-code/index.ts +136 -0
  78. package/plugins/code/README.md +42 -0
  79. package/plugins/code/diff.ts +58 -0
  80. package/plugins/code/index.ts +94 -0
  81. package/plugins/code/style.css +29 -0
  82. package/plugins/comments/client.ts +448 -0
  83. package/plugins/comments/index.ts +52 -0
  84. package/plugins/comments/style.css +32 -0
  85. package/plugins/details/README.md +17 -0
  86. package/plugins/details/index.ts +21 -0
  87. package/plugins/details/style.css +3 -0
  88. package/plugins/form/README.md +111 -0
  89. package/plugins/form/index.ts +104 -0
  90. package/plugins/form/style.css +41 -0
  91. package/plugins/gallery/README.md +30 -0
  92. package/plugins/gallery/client.tsx +64 -0
  93. package/plugins/gallery/index.ts +67 -0
  94. package/plugins/gallery/style.css +27 -0
  95. package/plugins/grid/README.md +33 -0
  96. package/plugins/grid/index.ts +36 -0
  97. package/plugins/grid/style.css +25 -0
  98. package/plugins/index.ts +19 -0
  99. package/plugins/mermaid/README.md +21 -0
  100. package/plugins/mermaid/index.ts +39 -0
  101. package/plugins/mermaid/style.css +16 -0
  102. package/plugins/quiet/README.md +26 -0
  103. package/plugins/quiet/index.ts +27 -0
  104. package/plugins/terminal/client.ts +317 -0
  105. package/plugins/terminal/host.ts +326 -0
  106. package/plugins/terminal/index.ts +138 -0
  107. package/plugins/terminal/modes.ts +30 -0
  108. package/plugins/terminal/server.ts +215 -0
  109. package/plugins/terminal/sizes.ts +60 -0
  110. package/plugins/terminal/style.css +71 -0
  111. package/skills/whiteboard/SKILL.md +292 -0
  112. package/solid/index.tsx +56 -0
  113. package/src/auth.ts +66 -0
  114. package/src/client/forms.ts +186 -0
  115. package/src/client/page/base.css +274 -0
  116. package/src/client/page/fresh.ts +205 -0
  117. package/src/client/page/main.ts +249 -0
  118. package/src/client/page/orphans.ts +46 -0
  119. package/src/client/page/theme.ts +32 -0
  120. package/src/client/page/view.ts +9 -0
  121. package/src/client/page/waiting.ts +109 -0
  122. package/src/client/runtime.ts +170 -0
  123. package/src/config.ts +96 -0
  124. package/src/define.ts +546 -0
  125. package/src/events.ts +194 -0
  126. package/src/html.ts +40 -0
  127. package/src/load.ts +89 -0
  128. package/src/loader.ts +109 -0
  129. package/src/package.ts +39 -0
  130. package/src/pages/blocks.ts +67 -0
  131. package/src/pages/index.ts +36 -0
  132. package/src/pages/markdown.ts +276 -0
  133. package/src/pages/render.ts +196 -0
  134. package/src/plugins.ts +197 -0
  135. package/src/running.ts +22 -0
  136. package/src/serve.ts +52 -0
  137. package/src/server.ts +644 -0
  138. package/src/status.ts +69 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bigmistqke
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,610 @@
1
- # Temporary Holding Version
1
+ # whiteboard
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A whiteboard for you and your agent.
4
+
5
+ Some things are too much for text in a terminal: a plan with open questions,
6
+ a comparison, the state of a long-running task. With whiteboard the agent
7
+ writes them as a markdown page, and you read the page live in your browser
8
+ next to the conversation. Every save updates the open page, and what changed
9
+ is marked until you've seen it. When the agent needs something from you, it
10
+ puts a form on the page. Your answer goes into a log the agent is waiting on.
11
+
12
+ It stays small: markdown files, one server per project, and one way to
13
+ interact (submitting a form). Everything else, from cards and diagrams to a
14
+ terminal at the bottom of the page, is a plugin.
15
+
16
+ ## Install
17
+
18
+ In the repository you work in:
19
+
20
+ ```sh
21
+ npm i -D @bigmistqke/whiteboard
22
+ npx whiteboard init # creates .whiteboard/ with a pages folder
23
+ ```
24
+
25
+ Then give your agent the skill that tells it how to use the whiteboard
26
+ ([below](#the-agent-skill)).
27
+
28
+ Requires Node 22.18 or later (it runs the TypeScript config itself).
29
+
30
+ <details>
31
+ <summary>Without npm in the repository, or for every project at once</summary>
32
+
33
+ Install the command globally instead and run it as `whiteboard`:
34
+
35
+ ```sh
36
+ npm i -g @bigmistqke/whiteboard
37
+ whiteboard init
38
+ ```
39
+
40
+ A project needs no `node_modules` of its own: the server resolves the
41
+ package's imports in `.whiteboard/config.ts` itself, so a Rust or Go
42
+ repository can have a whiteboard too.
43
+
44
+ </details>
45
+
46
+ ## Quick start
47
+
48
+ Write a page:
49
+
50
+ ````sh
51
+ cat > .whiteboard/pages/plan.md <<'EOF'
52
+ # Release plan
53
+
54
+ :::grid{cols=2}
55
+ ### Parser {done}
56
+ Rewritten, all tests pass.
57
+
58
+ ### Docs {todo}
59
+ Not started.
60
+ :::
61
+
62
+ :::form{name=ship}
63
+ Ship it this week? :radio[this week]{name=when} :radio[next week]{name=when}
64
+
65
+ :button[Decide]
66
+ :::
67
+ EOF
68
+ npx whiteboard show plan # starts the server, prints http://localhost:4777/plan
69
+ ````
70
+
71
+ Open the URL, then wait for the answer in another terminal:
72
+
73
+ ```sh
74
+ npx whiteboard wait --page plan --type ship
75
+ # {"id":"…","ts":"…","page":"plan","type":"ship","action":"Decide","data":{"when":"this week"}}
76
+ ```
77
+
78
+ That round trip is the whole idea. In practice the agent writes the page and
79
+ runs `wait`; you read and answer.
80
+
81
+ Agents claim their pages with `whiteboard new <name>`, which creates the file
82
+ under a name no other page has: `plan`, else `plan-2`, and so on. Several
83
+ agents can work in one project without writing into each other's pages or
84
+ waking on each other's answers.
85
+
86
+ ## How it works
87
+
88
+ A project is a folder with a `.whiteboard/` folder in it. Everything
89
+ whiteboard keeps is there; nothing is written outside the project.
90
+
91
+ ```
92
+ .whiteboard/
93
+ config.ts optional: what differs from the defaults (plugins, a stylesheet, options)
94
+ pages/ the pages: pages/plan.md is served at /plan
95
+ events.ndjson the events, one JSON object per line: form submits, comments, replies,
96
+ and which ones an agent picked up
97
+ token the secret for what runs code (the terminal)
98
+ server.json the port and process of the running server
99
+ server.log that server's output
100
+ ```
101
+
102
+ Pages, the event log and the server files are gitignored by default.
103
+
104
+ - **One server per project.** `whiteboard show` starts the project's server
105
+ when it isn't running. It takes the port it had last time, else 4777 (or
106
+ `$WHITEBOARD_PORT`), else the next free one.
107
+ - **Markdown, extended by plugins.** A page is markdown, and plugins add
108
+ blocks to it: `:::form`, `:::grid`, `:::chat`, ```` ```mermaid ```` and
109
+ the rest are built-in plugins, and a project can add its own.
110
+ - **Live pages.** Every save of a page updates the open tab in place, and
111
+ blocks that changed are marked until you've seen them.
112
+ - **Repository files render too.** `/-/README.md` shows that file as a page,
113
+ `/-/src/` lists a folder, and other text files show as highlighted code.
114
+ Relative links between documents work the way they do in the repository.
115
+ - **Markdown never breaks a page.** A block nobody brings renders its
116
+ content as plain markdown, and one that throws shows an error in place of
117
+ that block only. A config that fails to load leaves pages as their raw
118
+ text, with the error above it.
119
+
120
+ ## Forms and answers
121
+
122
+ A form with a `name` and no `action` attribute is recorded when submitted:
123
+
124
+ ```json
125
+ {"id":"…","ts":"2026-…","page":"plan","type":"ship","action":"Decide","data":{"when":"this week"}}
126
+ ```
127
+
128
+ `type` is the form's name, `action` is the button that was pressed and
129
+ `data` holds the fields. The log is an event stream: a plugin can append
130
+ events of other types too, through `api.append(type, data)`. Those types
131
+ are named after their plugin, `<plugin>:<what>` (`chat:message`,
132
+ `comments:reply`, whiteboard's own `whiteboard:picked`), so a form's name
133
+ can't contain a colon and its answers never mix with them. The built-in
134
+ `form` plugin writes forms as markdown with inputs inline
135
+ (`:::form{name=ship}` … `:radio[this week]{name=when}` … `:::`); a
136
+ hand-written `<form name="…">` works without it.
137
+
138
+ A plugin says which of its events are for an agent (`handOut: true`): chat
139
+ messages and comments are, so a `wait` on the page hands them out like
140
+ answers. Others, such as a vote, stay in the log, for `whiteboard events`
141
+ or a `wait --type` that asks for them.
142
+
143
+ Reading answers:
144
+
145
+ ```sh
146
+ whiteboard wait --page plan --type ship # the next answer to that form
147
+ whiteboard watch --page plan # streams submits, never exits
148
+ whiteboard events --page plan --last 1 # what was already submitted
149
+ ```
150
+
151
+ `wait` never misses an answer and never hands one out twice. Handing an
152
+ answer out is itself an event in the log (`whiteboard:picked`), and when a
153
+ wait starts it first returns the answers nobody picked up yet, including
154
+ ones given before it started, whatever filter handed out the others. So an
155
+ agent can ask, do other work, and wait later.
156
+
157
+ `wait` is built from smaller pieces that are commands too, for a script that
158
+ wants to use the log its own way (pick an answer up only once it has acted
159
+ on it, say):
160
+
161
+ ```sh
162
+ whiteboard events --follow --page plan # every new event as it comes, marking nothing
163
+ whiteboard pick <event id> # record one as picked up, as wait does
164
+ whiteboard append --page plan --type <t> # write one
165
+ ```
166
+
167
+ The same pieces are a module, `@bigmistqke/whiteboard/log`: `read`,
168
+ `follow`, `appendEvent`, `pick`, and `handOut`, which is `wait` itself.
169
+
170
+ ## A terminal on every page
171
+
172
+ The terminal is a plugin: add it to the config.
173
+
174
+ ```ts
175
+ import terminal from '@bigmistqke/whiteboard/terminal'
176
+
177
+ export default defineConfig({
178
+ plugins: [terminal()],
179
+ })
180
+ ```
181
+
182
+ `whiteboard terminal` prints a link that unlocks a terminal drawer at the
183
+ bottom of every page of the project, in that browser. Collapsed it's a bar;
184
+ open, it shows a terminal with tabs. Each tab is a session in a
185
+ pseudo-terminal, in a small host process of its own that the server starts.
186
+ So the sessions outlive the browser tab (switching pages, reloading or
187
+ opening a second browser tab shows the same ones) and the server: a
188
+ restarted server finds them where they were. The browser morphs the drawer
189
+ from one page into the next (a view transition across the page load), and
190
+ the server writes the current screens into each page, so it never shows
191
+ empty. Ctrl+\` opens and closes it.
192
+
193
+ Several browser windows can show the same tab. A tab has one size, the
194
+ size of the window you used last (opened the drawer, clicked or typed in
195
+ it); the others show it at that size, with a margin or cut off at the right,
196
+ until you use them.
197
+
198
+ Every tab is your shell. The tabs sit at the bar's right, "+" at its end
199
+ opens one, and "×" closes a tab and ends what runs in it. A tab started with
200
+ a program runs it inside your shell, and the shell takes over when it exits:
201
+ leaving `claude` leaves a prompt in the same tab, not a dead one. A tab whose
202
+ shell exited offers to start it again, as it was.
203
+
204
+ ```sh
205
+ whiteboard terminal [page] # the link that opens the drawer in this browser
206
+ whiteboard terminal --new # a new tab with the shell
207
+ whiteboard terminal -- <program> … # run a program in a new tab: -- claude --resume <id>
208
+ whiteboard terminal open <page> # show a page where the drawer you used last is
209
+ whiteboard terminal stop # end every tab and their host
210
+ ```
211
+
212
+ An agent can show you a page: `whiteboard terminal open <page>` takes the
213
+ browser tab whose drawer you used last to that page, and the drawer comes
214
+ along. A program in a tab knows which tab it runs in (`WHITEBOARD_TERMINAL`)
215
+ and opens it where that tab's drawer is; without it, where you were last.
216
+
217
+ The terminal runs code, so it needs the project's token: `.whiteboard/token`,
218
+ made on first use and gitignored. The link (`/_/auth`) sets it as a cookie
219
+ that is only sent from the project's own pages, and requests from another
220
+ origin are refused. Any plugin can ask the core whether a request has it.
221
+
222
+ It needs `node-pty`, an optional dependency; without it the drawer says what
223
+ to install. The host listens on `.whiteboard/terminal/host.sock`, readable
224
+ by its owner only, and leaves ten minutes after the last tab's program ended.
225
+
226
+ The token keeps other websites out, not agents: it is in the project, and so
227
+ is the config the server runs. **whiteboard runs with the rights of whoever
228
+ started its server, and adds none**, so start the server where your agents
229
+ run. If they run in a sandbox, start it from inside that sandbox (an agent
230
+ running `whiteboard show` does); the terminal and everything else it starts
231
+ are then boxed in the same way. A server started outside the sandbox lets an
232
+ agent reach past it, through the terminal or simply by editing `config.ts`.
233
+
234
+ ## Claude Code hooks
235
+
236
+ The Claude Code plugin tells an agent session what is open on its pages,
237
+ from outside the agent, so a forgotten wait gets noticed:
238
+
239
+ ```ts
240
+ import claudeCode from '@bigmistqke/whiteboard/claude-code'
241
+
242
+ export default defineConfig({
243
+ plugins: [claudeCode()],
244
+ })
245
+ ```
246
+
247
+ With it, `whiteboard new` claims the page it makes for the Claude Code
248
+ session that ran it, and `whiteboard status` marks that session's pages.
249
+ `whiteboard claude-code install` adds three hooks to the project's
250
+ `.claude/settings.json`. None of
251
+ them ever blocks:
252
+
253
+ - when a turn ends with something on the session's pages nobody listens for,
254
+ you see a one-line warning;
255
+ - when you send a message, answers on the session's pages that no wait
256
+ picked up come with it, and count as picked up from then on;
257
+ - a new session starts with the same, plus what is open on other sessions'
258
+ pages (not handed over: those answers stay for whoever waits on them).
259
+
260
+ ## Commands
261
+
262
+ Every command works on the project of the current folder: the nearest folder
263
+ upward with a `.whiteboard/` folder.
264
+
265
+ | command | does |
266
+ | --- | --- |
267
+ | `whiteboard init [name]` | make this folder a project |
268
+ | `whiteboard root` | print the folder pages go into |
269
+ | `whiteboard new <name>` | create a page under a name no other page has (`name`, else `name-2`, …), print its path |
270
+ | `whiteboard show <page\|file>` | start the server if needed, print the page's URL |
271
+ | `whiteboard url <page\|file>` | the same |
272
+ | `whiteboard docs [name]` | print how to write pages in this project: the blocks, then each plugin's docs; with a name, only that plugin's |
273
+ | `whiteboard events [filters] [--follow]` | print recorded events; with `--follow`, then each new one as it comes, marking nothing |
274
+ | `whiteboard wait [filters]` | print the next matching event not handed out before, waiting for it if needed |
275
+ | `whiteboard watch [filters]` | like `wait`, but never exits: print each matching event once |
276
+ | `whiteboard append --page <p> --type <t> [--data <json>]` | add an event to a page's log, such as a reply to a comment |
277
+ | `whiteboard pick <event id>` | record an event as picked up, as `wait` does when it hands one out |
278
+ | `whiteboard status [--page <p>]` | per page: questions without an answer, answers no agent picked up, who is listening |
279
+ | `whiteboard serve` | run the server in the foreground |
280
+ | `whiteboard skill [dir]` | print where the agent skill is, or link it into a skills folder |
281
+
282
+ Filters: `--page <page|file>` (includes pages below it), `--type <type>` (a form's type is its name).
283
+ `wait` also takes `--timeout <seconds>` (exits 2 on timeout) and `--count <n>`;
284
+ `events` takes `--since <time or event id>` and `--last <n>`.
285
+
286
+ ## Configuration
287
+
288
+ A project needs no config. Without one it has the defaults: the built-in
289
+ plugins and the folder's name. Add `.whiteboard/config.ts` to change any of
290
+ that; it takes effect at once, also while the server runs. Every field is
291
+ optional:
292
+
293
+ ```ts
294
+ // .whiteboard/config.ts
295
+ import { defineConfig } from '@bigmistqke/whiteboard'
296
+ import terminal from '@bigmistqke/whiteboard/terminal'
297
+ import code from '@bigmistqke/whiteboard/code'
298
+
299
+ export default defineConfig({
300
+ name: 'my-project', // shown in titles (default: the folder name)
301
+ plugins: [ // added to the built-in ones
302
+ terminal(),
303
+ code({ themes: { light: 'github-light', dark: 'github-dark' } }), // same name: replaces the built-in
304
+ ],
305
+ style: new URL('./site.css', import.meta.url), // a stylesheet on every page, after the others
306
+ files: true, // serve and watch the rest of the project at /-/ (default: true)
307
+ })
308
+ ```
309
+
310
+ The built-in plugins are callout, chat, code, comments, details, form,
311
+ gallery, grid, mermaid and quiet: every project has them, and
312
+ `whiteboard docs` shows how to write each. A config's `plugins` add to them,
313
+ and one with a built-in's name replaces it. The terminal and the Claude Code
314
+ plugin are opt-in, since they run code or are about one agent.
315
+
316
+ Named forms need nothing in the config: the core sends a submit of any
317
+ `<form name>` as an event, on any page.
318
+
319
+ Set `files: false` for a project whose folder is not a repository, such as
320
+ your home folder. Then only `.whiteboard/` is served and watched.
321
+ `whiteboard init` sets it when run in the home folder.
322
+
323
+ ## Writing a plugin
324
+
325
+ Everything that extends whiteboard is a plugin: syntax for pages,
326
+ behaviour on every page, commands, events. A plugin is an object with a
327
+ name, and everything it adds lives under that name, so two plugins can't
328
+ collide: its block `:::name`, its events `name:…`, its command
329
+ `whiteboard name`, its routes `/api/name/…` and its data folder
330
+ `.whiteboard/name/`. Local plugins go in `.whiteboard/plugins/`.
331
+
332
+ ### A block: a checklist the reader ticks
333
+
334
+ A block is syntax: `:::name` around content, `::name` on a line, `:name`
335
+ inside a line, or a code fence of that name. It renders on the server, and
336
+ with a `client` it is mounted in the browser too.
337
+
338
+ ```ts
339
+ // .whiteboard/plugins/checklist/index.ts
340
+ import { definePlugin, html, type DirectiveContext } from '@bigmistqke/whiteboard'
341
+
342
+ const toText = (node: any): string => node.value ?? (node.children ?? []).map(toText).join('')
343
+
344
+ export default function checklist() {
345
+ return definePlugin({
346
+ name: 'checklist',
347
+ blocks: {
348
+ checklist: {
349
+ // what the browser part gets: the block's list items as text
350
+ props: ctx => {
351
+ const c = ctx as DirectiveContext // a block (`:::checklist`), not a code fence
352
+ return {
353
+ name: c.attrs.name ?? 'checklist',
354
+ items: (c.children as any[]).filter(n => n.type === 'list')
355
+ .flatMap(list => list.children.map((item: any) => toText(item))),
356
+ }
357
+ },
358
+ // shown until the client mounts, then replaced
359
+ html: () => html`<ul class="checklist"></ul>`,
360
+ client: new URL('./client.js', import.meta.url),
361
+ },
362
+ },
363
+ // its events, and whether a `wait` on the page hands them out (a tick is information: no)
364
+ events: { 'checklist:tick': { description: '`{ checklist, item, checked }`' } },
365
+ // for `whiteboard docs`, under a `# Plugin: checklist` heading the core adds
366
+ docs: () => 'A list the reader ticks:\n\n :::checklist{name=launch}\n - Write the changelog\n :::\n',
367
+ })
368
+ }
369
+ ```
370
+
371
+ ```js
372
+ // .whiteboard/plugins/checklist/client.js: plain JavaScript, served as it is
373
+ export default function mount(el, { name, items }, api) {
374
+ const ticked = () => {
375
+ const state = new Map()
376
+ for (const e of api.events()) if (e.type === 'checklist:tick' && e.data.checklist === name) state.set(e.data.item, e.data.checked)
377
+ return state
378
+ }
379
+ const draw = () => {
380
+ const state = ticked()
381
+ el.replaceChildren(...items.map(item => {
382
+ const box = Object.assign(document.createElement('input'), { type: 'checkbox', checked: !!state.get(item) })
383
+ box.addEventListener('change', () => api.append('checklist:tick', { checklist: name, item, checked: box.checked }))
384
+ const label = document.createElement('label')
385
+ label.append(box, ' ', item)
386
+ return label
387
+ }))
388
+ }
389
+ draw()
390
+ // the page's events, also the ones it appends itself, come back here
391
+ return api.onEvents(draw)
392
+ }
393
+ ```
394
+
395
+ ```ts
396
+ // .whiteboard/config.ts
397
+ import { defineConfig } from '@bigmistqke/whiteboard'
398
+ import checklist from './plugins/checklist/index.ts'
399
+
400
+ export default defineConfig({ plugins: [checklist()] })
401
+ ```
402
+
403
+ An agent can wait for a tick by asking for it: `whiteboard wait --page
404
+ <file> --type checklist:tick`.
405
+
406
+ ### Behaviour on every page: votes
407
+
408
+ A plugin can also put something on every page, and add commands:
409
+
410
+ ```ts
411
+ // .whiteboard/plugins/votes.ts
412
+ import { definePlugin } from '@bigmistqke/whiteboard'
413
+ import { read } from '@bigmistqke/whiteboard/log'
414
+
415
+ export default function votes() {
416
+ return definePlugin({
417
+ name: 'votes',
418
+ events: { 'votes:up': { description: 'the reader voted the page up' } },
419
+ commands: {
420
+ '': {
421
+ description: 'print the votes per page',
422
+ run(ctx) {
423
+ const counts = new Map<string, number>()
424
+ for (const e of read(ctx.eventsFile).events) if (e.type === 'votes:up') counts.set(e.page, (counts.get(e.page) ?? 0) + 1)
425
+ for (const [page, n] of counts) console.log(`${page}: ${n}`)
426
+ },
427
+ },
428
+ },
429
+ docs: () => 'The reader can vote a page up: a `votes:up` event. `whiteboard votes` counts them.',
430
+ // from setup: what the running server adds (routes, markup, the browser module)
431
+ setup: () => ({ client: new URL('./votes.client.js', import.meta.url) }),
432
+ })
433
+ }
434
+ ```
435
+
436
+ ```js
437
+ // .whiteboard/plugins/votes.client.js: plain JavaScript, served as it is
438
+ export default function mount(root, page, api) {
439
+ const button = document.createElement('button')
440
+ const draw = () => { button.textContent = `👍 ${api.events().filter(e => e.type === 'votes:up').length}` }
441
+ button.addEventListener('click', () => api.append('votes:up'))
442
+ api.corner().append(button) // the page's corner, for floating buttons
443
+ api.onEvents(draw)
444
+ draw()
445
+ }
446
+ ```
447
+
448
+ ### What a plugin can have
449
+
450
+ - **`blocks`**, by name. A block has `html(ctx)` (the server's HTML; `ctx`
451
+ has the block's attributes, label, content as mdast nodes, `toHtml`,
452
+ `sections` and more), `props(ctx)` (JSON for its client), `client` (a
453
+ browser module, mounted per block), `style` (linked on pages that use it),
454
+ and `fence: 'any'` for the block that takes every code fence nobody else
455
+ claims. Block names are unique across a project's plugins.
456
+ - **`events`**, by type (`<plugin>:<what>`): a description each, and
457
+ `handOut: true` for those an agent should get unasked, like a chat
458
+ message. `whiteboard docs` lists them.
459
+ - **`style`**: a stylesheet on every page.
460
+ - **`docs`**: markdown for agents: how to write its blocks, what its events
461
+ mean, how to answer.
462
+ - **`commands`**: `whiteboard <name>` and `whiteboard <name> <sub>`, with
463
+ declared options that the core parses and checks. A command gets the
464
+ project, its event log (`ctx.eventsFile`, for
465
+ `@bigmistqke/whiteboard/log`), its token and server, what is open on each
466
+ page (`ctx.status`), and handing out (`ctx.handOut`, what `wait` does).
467
+ - **`session()`**: the agent session a command runs in, for a plugin that
468
+ knows how its agent says so.
469
+ - **`setup(ctx)`**, which runs once per loaded config on the server and
470
+ returns:
471
+ - `routes`, by method and path (`'POST /start'` is mounted at
472
+ `/api/<name>/start`), each with what it does, whether it needs the
473
+ project's token (`auth`), and the types of its body and query; the core
474
+ checks all of that before the route's code runs;
475
+ - `shell`, markup at the end of every page's `<head>` and `<body>`;
476
+ - `client`, a module on every page, run once per page load.
477
+
478
+ **Browser code is plain JavaScript**: the server sends it as it is, so one
479
+ written in TypeScript needs building first. A block's `client` gets
480
+ `mount(element, props, api)` and may return a cleanup, run when the block
481
+ is replaced on a live update; it replaces the server's HTML when it mounts.
482
+ A page module (`setup`'s `client`) gets `mount(root, page, api)`. Both get
483
+ the page's `api`: its events and `append` (which comes back through
484
+ `onEvents`), the listeners, `onRendered` (after a live update, to put back
485
+ what it adds), `corner()` for floating buttons, `badge()` for counts in the
486
+ tab title, and the theme. Files beside a browser module that are browser
487
+ assets (scripts, styles, images, fonts) are served too.
488
+
489
+ Something that covers the bottom of the window says how much in
490
+ `--wb-inset-bottom`, and the page keeps clear of it. A plugin can't be
491
+ named like a built-in command or a folder of the core.
492
+
493
+ ## Pages
494
+
495
+ Each page is a conversation between you and the agent that writes it:
496
+ forms you answer, a chat under each form, comments on any passage, and a
497
+ page that shows at a glance what waits on whom.
498
+
499
+ ````markdown
500
+ # Release plan
501
+
502
+ :::callout[Status: one question open]{.note}
503
+ The parser is done; the docs wait on the question below.
504
+ :::
505
+
506
+ :::grid{cols=2}
507
+ ### Parser {done}
508
+ Rewritten, all tests pass.
509
+
510
+ ### Docs {todo}
511
+ Not started.
512
+ :::
513
+
514
+ :::form{name=ship}
515
+ **When do we ship?**
516
+
517
+ - :radio[This week]{name=when recommended}
518
+ The docs are small; ship and follow up.
519
+ - :radio[Next week]{name=when}
520
+ Ship with the docs complete.
521
+ :::
522
+ ````
523
+
524
+ - **Forms.** The writer's recommended option is tagged, never preselected,
525
+ so a choice is only made by picking it. What you type is kept until you
526
+ send it, across live updates and reloads. Sending confirms itself.
527
+ - **A chat under every form,** to ask about a question without answering
528
+ it: a message is never a submit. `:::chat{name=…}` puts one anywhere.
529
+ - **What waits on whom.** A form is waiting for you (an agent listens for
530
+ it), nobody listening, waiting for the agent (answered, not yet picked
531
+ up), or decided: then it folds to one line quoting the answer, with its
532
+ chat still under it, and a click opens it again. A line above the page
533
+ counts them, a button jumps to the next form waiting for you, and the tab
534
+ title gets a `(!n)` prefix.
535
+ - **Comments.** Select any passage and comment on it; the agent replies in
536
+ the thread or edits the page. Passages are found again after edits.
537
+ - **What changed.** A block you haven't seen gets a bar until it has been
538
+ in view a moment, remembered per page, so coming back shows what changed
539
+ since. `:::quiet` content never counts as new.
540
+ - **Reading.** Updates keep your place: focus, typed values, open
541
+ `<details>` and scroll. A frame with breadcrumbs, the time of the last
542
+ update and a theme toggle. Numbered headings. An overview of the
543
+ project's pages and markdown documents, and repository files rendered at
544
+ `/-/`.
545
+
546
+ ## The agent skill
547
+
548
+ The package includes a skill: instructions that teach an agent where pages
549
+ go, how to write them, and how to wait for answers. It is a folder with a
550
+ `SKILL.md`, the format several coding agents read.
551
+
552
+ ```sh
553
+ npx whiteboard skill # prints where the skill folder is
554
+ npx whiteboard skill ~/.claude/skills # links it into Claude Code's skills folder
555
+ ```
556
+
557
+ Link it into whichever folder your agent reads skills from. The link points
558
+ into the installed package, so the skill updates when you update whiteboard.
559
+ Agents that don't read skills can be pointed at the `SKILL.md` file directly.
560
+
561
+ ## Working on whiteboard
562
+
563
+ Whiteboard is TypeScript. An installed package runs its build from
564
+ `dist/`, because Node won't run TypeScript inside `node_modules`. A clone
565
+ can run from source instead, so a change needs no build:
566
+
567
+ ```sh
568
+ git clone https://github.com/bigmistqke/whiteboard && cd whiteboard
569
+ npm install
570
+ ln -sf "$PWD/bin/whiteboard.ts" "$(npm prefix -g)/bin/whiteboard" # your global `whiteboard` runs the source
571
+ npm run dev # rebuilds the browser code as you change it
572
+ ```
573
+
574
+ `whiteboard` then runs from source in every project on your machine. That
575
+ includes the server it starts, and what a project's config imports from
576
+ the package (the plugins), so a project needs nothing of its
577
+ own for this. What a change takes:
578
+
579
+ | what you change | what it takes |
580
+ | --- | --- |
581
+ | a plugin's server side (its blocks, commands, routes) | nothing: the server reloads open pages |
582
+ | browser code (a plugin's `client.ts`/`client.tsx`, `src/client/`) | `npm run dev` running; open pages reload |
583
+ | the core (`src/`, `bin/`, the markdown engine in `src/pages/`) | restart the project's server; commands pick it up on their next run |
584
+
585
+ Don't use `npm link` for this: it links `whiteboard` to the build, which
586
+ changes only when you run `npm run build`. Without a global command,
587
+ `node bin/whiteboard.ts <command>` works from inside the clone.
588
+
589
+ - `npm test`: the unit tests (`node:test`)
590
+ - `npm run test:browser`: forms, comments and the terminal in a real browser
591
+ (Playwright; `npx playwright install chromium` once). Each test runs a
592
+ throwaway project with its own server, from source
593
+ - `npm run check`: type-check everything
594
+ - `npm run build`: build `dist/`, what the package ships; `node
595
+ dist/bin/whiteboard.js` runs it as an installed copy would
596
+ - `npm run release`: type-check and test, then ask for the new version
597
+ ([bumpp](https://github.com/antfu-collective/bumpp)), commit and tag it as
598
+ `Release vX.Y.Z`, push, and publish to npm. Publishing reads the token from
599
+ `NPM_TOKEN` (`.npmrc`); it needs a granular token that may publish without
600
+ a one-time password
601
+
602
+ ## Design
603
+
604
+ [DESIGN.md](https://github.com/bigmistqke/whiteboard/blob/main/DESIGN.md)
605
+ records how whiteboard works and why: the principles, the engine, the
606
+ plugin contract and the page in the browser.
607
+
608
+ ## License
609
+
610
+ MIT