@bigmistqke/whiteboard 0.5.0 → 0.6.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 (106) hide show
  1. package/README.md +125 -25
  2. package/bin/whiteboard.ts +299 -16
  3. package/dist/bin/whiteboard.js +247 -17
  4. package/dist/client/runtime.js +22 -10
  5. package/dist/plugins/ansi/README.md +36 -0
  6. package/dist/plugins/ansi/index.js +64 -0
  7. package/dist/plugins/ansi/public/style.css +28 -0
  8. package/dist/plugins/badge/README.md +28 -0
  9. package/dist/plugins/badge/index.js +24 -0
  10. package/dist/plugins/badge/public/style.css +30 -0
  11. package/dist/plugins/chat/public/style.css +7 -2
  12. package/dist/plugins/code/README.md +4 -2
  13. package/dist/plugins/code/diff.js +12 -2
  14. package/dist/plugins/grid/README.md +12 -12
  15. package/dist/plugins/grid/index.js +7 -19
  16. package/dist/plugins/grid/public/style.css +4 -33
  17. package/dist/plugins/iframe/README.md +7 -7
  18. package/dist/plugins/iframe/index.js +11 -11
  19. package/dist/plugins/iframe/public/style.css +15 -0
  20. package/dist/plugins/index.js +7 -3
  21. package/dist/plugins/lightbox/README.md +22 -0
  22. package/dist/plugins/lightbox/index.js +20 -0
  23. package/dist/plugins/lightbox/public/client.js +4 -0
  24. package/dist/plugins/lightbox/public/style.css +66 -0
  25. package/dist/plugins/steps/README.md +3 -3
  26. package/dist/plugins/steps/index.js +3 -42
  27. package/dist/plugins/steps/public/client.js +1 -1
  28. package/dist/plugins/terminal/host.js +1 -1
  29. package/dist/plugins/terminal/public/client.js +1 -1
  30. package/dist/plugins/window/README.md +34 -14
  31. package/dist/plugins/window/index.js +21 -13
  32. package/dist/src/auth.js +4 -3
  33. package/dist/src/client/page/base.css +61 -1
  34. package/dist/src/client/page/main.js +60 -14
  35. package/dist/src/entries.js +211 -0
  36. package/dist/src/events.js +1 -1
  37. package/dist/src/hub.js +272 -0
  38. package/dist/src/loader.js +4 -1
  39. package/dist/src/package.js +23 -1
  40. package/dist/src/pages/blocks.js +1 -0
  41. package/dist/src/pages/index.js +1 -1
  42. package/dist/src/pages/markdown.js +87 -33
  43. package/dist/src/pages/render.js +116 -14
  44. package/dist/src/pages/window.js +16 -18
  45. package/dist/src/running.js +37 -2
  46. package/dist/src/serve.js +111 -2
  47. package/dist/src/server.js +49 -14
  48. package/package.json +1 -1
  49. package/plugins/ansi/README.md +36 -0
  50. package/plugins/ansi/index.ts +95 -0
  51. package/plugins/ansi/public/style.css +28 -0
  52. package/plugins/badge/README.md +28 -0
  53. package/plugins/badge/index.ts +35 -0
  54. package/plugins/badge/public/style.css +30 -0
  55. package/plugins/chat/public/style.css +7 -2
  56. package/plugins/code/README.md +4 -2
  57. package/plugins/code/diff.ts +14 -2
  58. package/plugins/grid/README.md +12 -12
  59. package/plugins/grid/index.ts +11 -26
  60. package/plugins/grid/public/style.css +4 -33
  61. package/plugins/iframe/README.md +7 -7
  62. package/plugins/iframe/index.ts +15 -15
  63. package/plugins/iframe/public/style.css +15 -0
  64. package/plugins/index.ts +6 -2
  65. package/plugins/lightbox/README.md +22 -0
  66. package/plugins/lightbox/client.ts +99 -0
  67. package/plugins/lightbox/index.ts +25 -0
  68. package/plugins/lightbox/public/style.css +66 -0
  69. package/plugins/steps/README.md +3 -3
  70. package/plugins/steps/client.ts +15 -6
  71. package/plugins/steps/index.ts +3 -46
  72. package/plugins/terminal/client.ts +16 -7
  73. package/plugins/window/README.md +34 -14
  74. package/plugins/window/index.ts +20 -13
  75. package/skills/whiteboard/SKILL.md +18 -10
  76. package/src/auth.ts +5 -3
  77. package/src/client/base.ts +19 -0
  78. package/src/client/forms.ts +2 -1
  79. package/src/client/markdown.ts +2 -1
  80. package/src/client/page/base.css +61 -1
  81. package/src/client/page/elsewhere.ts +72 -16
  82. package/src/client/page/fresh.ts +2 -1
  83. package/src/client/page/sort.ts +2 -1
  84. package/src/client/runtime.ts +11 -9
  85. package/src/define.ts +66 -7
  86. package/src/entries.ts +258 -0
  87. package/src/events.ts +2 -1
  88. package/src/hub.ts +355 -0
  89. package/src/loader.ts +7 -1
  90. package/src/package.ts +22 -0
  91. package/src/pages/blocks.ts +3 -0
  92. package/src/pages/index.ts +4 -2
  93. package/src/pages/markdown.ts +89 -32
  94. package/src/pages/render.ts +134 -13
  95. package/src/pages/window.ts +16 -25
  96. package/src/running.ts +47 -1
  97. package/src/serve.ts +114 -1
  98. package/src/server.ts +80 -14
  99. package/dist/plugins/gallery/README.md +0 -30
  100. package/dist/plugins/gallery/index.js +0 -75
  101. package/dist/plugins/gallery/public/client.js +0 -1
  102. package/dist/plugins/gallery/public/style.css +0 -90
  103. package/plugins/gallery/README.md +0 -30
  104. package/plugins/gallery/client.tsx +0 -70
  105. package/plugins/gallery/index.ts +0 -89
  106. package/plugins/gallery/public/style.css +0 -90
package/README.md CHANGED
@@ -52,10 +52,10 @@ cat > .whiteboard/pages/plan.md <<'EOF'
52
52
  # Release plan
53
53
 
54
54
  :::grid{cols=2}
55
- ### Parser {done}
55
+ ### Parser :badge[done]
56
56
  Rewritten, all tests pass.
57
57
 
58
- ### Docs {todo}
58
+ ### Docs :badge[todo]
59
59
  Not started.
60
60
  :::
61
61
 
@@ -85,8 +85,9 @@ waking on each other's answers.
85
85
 
86
86
  ## How it works
87
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.
88
+ A project is a folder with a `.whiteboard/` folder in it. Everything whiteboard keeps of a project is there; outside a project it
89
+ writes only the shared server's state, when you run one
90
+ ([below](#many-projects-one-server)).
90
91
 
91
92
  ```
92
93
  .whiteboard/
@@ -101,9 +102,10 @@ whiteboard keeps is there; nothing is written outside the project.
101
102
 
102
103
  Pages, the event log and the server files are gitignored by default.
103
104
 
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.
105
+ - **One server per project,** or one for many ([below](#many-projects-one-server)).
106
+ `whiteboard show` starts the project's server when it isn't running. It
107
+ takes the port it had last time, else 4777 (or `$WHITEBOARD_PORT`), else
108
+ the next free one.
107
109
  - **Markdown, extended by plugins.** A page is markdown, and plugins add
108
110
  blocks to it: `:::form`, `:::grid`, `:::chat`, ```` ```mermaid ```` and
109
111
  the rest are built-in plugins, and a project can add its own.
@@ -117,6 +119,85 @@ Pages, the event log and the server files are gitignored by default.
117
119
  that block only. A config that fails to load leaves pages as their raw
118
120
  text, with the error above it.
119
121
 
122
+ ## Many projects, one server
123
+
124
+ With many checkouts at once (git worktrees, job folders), one server per
125
+ project means one port per project, and no place that shows them all. A
126
+ machine config gathers them under one server instead:
127
+
128
+ ```json
129
+ // ~/.config/whiteboard/config.json ($XDG_CONFIG_HOME/whiteboard, or $WHITEBOARD_HOME)
130
+ {
131
+ "port": 4777,
132
+ "entries": {
133
+ "rg": {
134
+ "include": ["~/rg/develop", "~/rg/develop/.claude/worktrees/*", "~/rg/worksite/jobs/*"],
135
+ "exclude": ["~/rg/worksite/archive/**"]
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ Every folder an include matches, that no exclude matches and that has a
142
+ `.whiteboard/` folder, is a project of that entry. It is served at
143
+ `/<entry>/<path>/`, where `<path>` is the include's last plain folder and what
144
+ its wildcards matched: `/rg/develop/`, `/rg/worktrees/cmux/`,
145
+ `/rg/jobs/2026-11-19-solid-port/`. A second folder that would get the same path
146
+ gets `-2`. The server looks for projects again every few seconds, so a new
147
+ worktree with a `.whiteboard/` shows up, and a removed one goes, without a
148
+ restart.
149
+
150
+ - **`/` is the overview of every project,** as a project's own overview is of
151
+ its pages, and it looks and updates the same: each project under its name
152
+ (`develop`, `worktrees › cmux`), its pages as its overview lists them, with
153
+ the inbox badge on those waiting for you, and its documents folded under them by folder, under its folder. Projects with something waiting
154
+ come first, and in each the pages waiting; projects without pages are folded
155
+ at the end, under the server's version and the folders it is boxed to.
156
+ - **Every page's menu of what waits elsewhere** (the inbox in its header)
157
+ lists the other projects of its entry too, under each project's name.
158
+ - **Commands work as before,** in the project's folder: `show`, `url`,
159
+ `wait`, `append`, `events`, `status` act on their own project and find the
160
+ shared server. Events stay in each project's own `.whiteboard/events.ndjson`.
161
+ A project outside every include runs its own server, as without the config.
162
+ - **The fallback covers the whole entry.** A `wait` or `watch` without
163
+ `--page` in a project of an entry takes what no other wait or watch in any
164
+ of the entry's projects would take, from each project's own log, and says
165
+ where each answer is from (`project`, its folder, and the page's `url`). So
166
+ an agent overseeing the others runs `whiteboard watch` once, and an answer
167
+ on a page whose agent stopped listening still reaches it. One runs per
168
+ entry; a second exits 1.
169
+ - **Commands never start the shared server.** `show` without it says so; a
170
+ `wait` waits for it to appear, and the answers in the log reach it either
171
+ way; `status` and `docs` answer without it. A project outside every include
172
+ still starts its own, with `show`.
173
+ - **You start it, outside the agents' sandboxes:** `whiteboard serve` outside
174
+ any project, in a terminal or as a login service. It runs every project's
175
+ config and plugins (the terminal runs programs), so it can do whatever any
176
+ of them can; started from inside one agent's sandbox, it would be boxed in
177
+ there and miss the other folders. Box it on its own instead, with a
178
+ wrapper of your own, as you may do for your agent: `whiteboard paths
179
+ --write` and `--read` print what it needs (`:` between folders), so the
180
+ box follows the config:
181
+ ```sh
182
+ safehouse --workdir= --add-dirs="$(whiteboard paths --write)" \
183
+ --add-dirs-ro="$(whiteboard paths --read)" \
184
+ -- WHITEBOARD_SANDBOX="$(whiteboard paths --write)" whiteboard serve
185
+ ```
186
+ `$WHITEBOARD_SANDBOX`, when set, is what the overview says it is boxed to.
187
+ The server writes only its state folder (`~/.local/state/whiteboard`:
188
+ `server.json`, its log, the overview's project) and reads the config, so
189
+ nothing running inside it can change how it is served or boxed next time.
190
+ See [DESIGN.md](DESIGN.md#entries-one-server-for-many-projects).
191
+ - **Versions.** The server records its version (in `server.json` in its state
192
+ folder, and in the overview). `serve` from a newer whiteboard takes an older
193
+ server over: it asks it to exit and starts in its place. A command from a
194
+ newer whiteboard uses an older server and says to restart it; an older one
195
+ never replaces a newer one.
196
+ - **A project per checkout.** A folder is a project once it has a
197
+ `.whiteboard/`: have whatever makes worktrees and job folders run
198
+ `whiteboard init` in each, and every one appears on the index by itself, its
199
+ pages and answers its own.
200
+
120
201
  ## Forms and answers
121
202
 
122
203
  A form with a `name` and no `action` attribute is recorded when submitted:
@@ -267,22 +348,23 @@ upward with a `.whiteboard/` folder.
267
348
  | `whiteboard init [name]` | make this folder a project |
268
349
  | `whiteboard root` | print the folder pages go into |
269
350
  | `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 |
351
+ | `whiteboard show <page\|file>` | start the project's server if needed (never the shared one), print the page's URL |
352
+ | `whiteboard url <page\|file>` | print the page's URL, when the server runs |
272
353
  | `whiteboard close <page>` | a page that did its job: remove its file, and all its events from the log |
273
354
  | `whiteboard prune <page> [--type <t>] [--id <id>]` | remove a page's events from the log (all, one type, or one), keep the page |
274
355
  | `whiteboard edit <event id> --data <json>` | change an agent's own event in place: merged into its data, its id kept |
275
356
  | `whiteboard scroll <page\|file> <where>` | scroll the tabs that have the page open to a heading's text, a form's name or any text on it; exits 1 when nothing matches or no tab has it open |
276
357
  | `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 |
277
358
  | `whiteboard events [filters] [--follow]` | print recorded events; with `--follow`, then each new one as it comes, marking nothing |
278
- | `whiteboard wait [filters]` | print the next matching event not handed out before, waiting for it if needed; without `--page`, only what no other wait or watch would take (the fallback, one per project) |
359
+ | `whiteboard wait [filters]` | print the next matching event not handed out before, waiting for it if needed; without `--page`, only what no other wait or watch would take (the fallback: one per project, or, in a project of the machine config's entries, one for the whole entry, each event with its `project` and `url`) |
279
360
  | `whiteboard watch [filters]` | like `wait`, but never exits: print each matching event once |
280
361
  | `whiteboard append --page <p> --type <t> [--data <json>]` | add an event to a page's log, such as a reply to a comment |
281
362
  | `whiteboard pick <event id>` | record an event as picked up, as `wait` does when it hands one out |
282
363
  | `whiteboard status [--page <p>]` | per page: questions without an answer, answers no agent picked up, who is listening |
283
364
  | `whiteboard build [globs…] [--out <dir>] [--skip <a,b>]` | pages as a static site (see [Building a site](#building-a-site)) |
284
- | `whiteboard serve` | run the server in the foreground |
365
+ | `whiteboard serve` | run the server in the foreground; for a project of the machine config's entries, or outside any project, the shared server |
285
366
  | `whiteboard skill [dir]` | print where the agent skill is, or link it into a skills folder |
367
+ | `whiteboard paths [--write\|--read]` | the folders the shared server needs, `:` between them, for a sandbox wrapper to grant (see [Many projects, one server](#many-projects-one-server)) |
286
368
 
287
369
  Filters: `--page <page|file>` (includes pages below it), `--type <type>` (a form's type is its name).
288
370
  `wait` also takes `--timeout <seconds>` (exits 2 on timeout) and `--count <n>`;
@@ -341,8 +423,8 @@ Every colour is a `light-dark()` pair, so one line sets it for both themes:
341
423
  :root { --text-size: 17px; --rhythm: 1em; }
342
424
  ```
343
425
 
344
- The built-in plugins are callout, chat, code, comments, details, draft,
345
- forge, form, gallery, grid, iframe, mermaid, quiet, steps and window: every project has them, and
426
+ The built-in plugins are ansi, badge, callout, chat, code, comments, details, draft,
427
+ forge, form, grid, iframe, lightbox, mermaid, quiet, steps and window: every project has them, and
346
428
  `whiteboard docs` shows how to write each. A config's `plugins` add to them,
347
429
  and one with a built-in's name replaces it. The terminal and the Claude Code
348
430
  plugin are opt-in, since they run code or are about one agent, and so is the
@@ -387,7 +469,7 @@ whiteboard build 'docs/guide/*.md' --out preview # or what is given, over the
387
469
  A plugin's `shell` is asked with no request, since no browser asked for the
388
470
  page: the terminal's drawer, which is only for the project's own browser,
389
471
  isn't there.
390
- - **What is for reading stays:** steps, the gallery's lightbox, ⤢ on
472
+ - **What is for reading stays:** steps, the lightbox, ⤢ on
391
473
  windows, the theme toggle, the contents, details. Code and diagrams were
392
474
  rendered on the server, so the site loads no highlighter.
393
475
  - **`:::draft`** is for what is there while you write and not after: a note
@@ -533,11 +615,14 @@ export default function mount(root, page, api) {
533
615
 
534
616
  - **`blocks`**, by name. A block has `html(ctx)` (the server's HTML; `ctx`
535
617
  has the block's attributes, label, content as mdast nodes, `toHtml`,
536
- `sections` and more), `props(ctx)` (JSON for its client), `client` (a
618
+ `items()` and more), `props(ctx)` (JSON for its client), `client` (a
537
619
  browser module, mounted per block), `style` (linked on pages that use it),
538
620
  `fence: true` to also take the code fences of its name (```` ```mermaid ````),
539
- and `fence: 'any'` for the block that takes every code fence nobody else
540
- claims. Block names are unique across a project's plugins.
621
+ `fence: 'any'` for the block that takes every code fence nobody else
622
+ claims, and `open(ctx)`: what it shows on its own, for a window around it.
623
+ Block names are unique across a project's plugins.
624
+ - **`compose(ctx)`**: itself around any block that names the plugin in its
625
+ `compose` attribute, that block's HTML as `ctx.children` (see below).
541
626
  - **`events`**, by type (`<plugin>:<what>`): a description each, and
542
627
  `handOut: true` for those an agent should get unasked, like a chat
543
628
  message. `whiteboard docs` lists them.
@@ -560,11 +645,22 @@ export default function mount(root, page, api) {
560
645
  - `shell`, markup at the end of every page's `<head>` and `<body>`;
561
646
  - `client`, a module on every page, run once per page load.
562
647
 
563
- **A block can draw a window** around what it shows, the same one as
564
- `::iframe`, `::image`, `::video` and `:::window`: `windowFrame({ label, open,
565
- body })` from `@bigmistqke/whiteboard` gives it a header with its label, a
566
- button that opens `open` on its own, and one that fills the browser window
567
- (the page does that part).
648
+ **A plugin can compose itself around other blocks.** With `compose`, a
649
+ block whose `compose` attribute names the plugin is put in what it returns,
650
+ the block's HTML as `children`, as a component gets what it wraps. The
651
+ window plugin is one: `::image{src compose=window}`, ```` ```mermaid {compose=window} ````
652
+ and `:::grid{compose=window}` all go in a window, and none of those blocks
653
+ knows of windows. A block says what it shows on its own with `open` (an
654
+ image's file), which a window's ↗ opens. Several named compose in the order
655
+ written, the first innermost: `compose=lightbox,window`. A name no plugin
656
+ composes is said in place.
657
+
658
+ ```ts
659
+ definePlugin({
660
+ name: 'window',
661
+ compose: ({ children, label, open }) => windowFrame({ label, open, body: children }),
662
+ })
663
+ ```
568
664
 
569
665
  **A plugin's browser files live in its `public/` folder**, and only that
570
666
  folder is served: its client modules, styles, images and fonts, never its
@@ -588,7 +684,11 @@ on the page handle (YAML, as parsed) and the plugin's own `settings` in it
588
684
  (under `plugins:` by its name: `plugins: { toc: true }` is `true` for toc), `corner()` for floating buttons, `toast()` for a label in
589
685
  the corner that says what is going on and goes there (one that hides after a
590
686
  few seconds, or one that stays with a count), `badge()` for counts in the
591
- tab title, and the `theme`. Every value that changes is called for what it
687
+ tab title, the `theme`, and `url(path)`: the address of one of the
688
+ project's server routes as this page requests it (`api.url('/api/votes/count')`).
689
+ Ask for the plugin's routes through it rather than writing `/api/…`: under a
690
+ shared server a project is served below a path (`/rg/develop`). Every value
691
+ that changes is called for what it
592
692
  is now and has `.on(fn)` for each change: `api.events()`,
593
693
  `api.events.on(draw)`, `page.frontmatter.on(…)`. Files beside a browser module that are browser
594
694
  assets (scripts, styles, images, fonts) are served too.
@@ -611,10 +711,10 @@ The parser is done; the docs wait on the question below.
611
711
  :::
612
712
 
613
713
  :::grid{cols=2}
614
- ### Parser {done}
714
+ ### Parser :badge[done]
615
715
  Rewritten, all tests pass.
616
716
 
617
- ### Docs {todo}
717
+ ### Docs :badge[todo]
618
718
  Not started.
619
719
  :::
620
720