@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/src/status.ts ADDED
@@ -0,0 +1,69 @@
1
+ // Where a page's questions stand, and how to say what is open on it: one definition for the server
2
+ // (`whiteboard status`, the hooks) and the page in the browser alike. No Node in it, so the browser
3
+ // runtime uses the same module.
4
+ //
5
+ // A question is a named form; its answers are the reader's events of its name. It stands:
6
+ // waiting an agent is listening and wants its answer: a wait or watch asks for it by name (also
7
+ // when it was answered before: the agent wants a new answer), or takes any answer and
8
+ // it has none
9
+ // unheard no answer, and no agent is listening
10
+ // pending answered, but no agent has picked the answer up yet
11
+ // decided an agent picked up its latest answer
12
+ import type { FormState, Listener, PageStatus, WbEvent } from './define.ts'
13
+
14
+ /**
15
+ * Can this be a question's name, the type of its answers? Not with a colon: types with one belong
16
+ * to whiteboard (`whiteboard:picked`) or a plugin (`comments:reply`, `chat:message`),
17
+ * named after its owner, so a form's answers never mix with their events.
18
+ */
19
+ export const isQuestionName = (name: string): boolean => !!name && !name.includes(':')
20
+
21
+ /** The states, in the order a reader should see them: what waits on them first. */
22
+ export const STATES: FormState[] = ['waiting', 'unheard', 'pending', 'decided']
23
+
24
+ /**
25
+ * Was this event written by the reader (a form submit, a comment), not by an agent? Agents write
26
+ * through the command line, which marks its events `from: 'cli'`: an agent's reply, a claim, a pick.
27
+ */
28
+ export const fromReader = (event: WbEvent): boolean => event.from !== 'cli'
29
+
30
+ /**
31
+ * Where the question `name` stands. `events` are the page's, `listeners` the running waits and
32
+ * watches that cover the page, `pickedUp` whether an event was handed to an agent. `last` is its
33
+ * latest answer: the reader's latest event of its name.
34
+ */
35
+ export function questionState(
36
+ name: string,
37
+ events: WbEvent[],
38
+ listeners: Listener[],
39
+ pickedUp: (id: string) => boolean,
40
+ ): { state: FormState; last: WbEvent | undefined } {
41
+ const last = events.findLast(e => e.type === name && fromReader(e))
42
+ const asked = listeners.some(l => l.type === name)
43
+ const any = listeners.some(l => l.type === null)
44
+ const state: FormState =
45
+ asked || (any && !last) ? 'waiting'
46
+ : !last ? 'unheard'
47
+ : pickedUp(last.id) ? 'decided'
48
+ : 'pending'
49
+ return { state, last }
50
+ }
51
+
52
+ /**
53
+ * What is open on a page, one short line each; the command that picks it up comes last, once.
54
+ * `file` is how to name the page's file to the reader (relative to where they are). Without
55
+ * `waiting`, the questions an agent is already waiting on are left out.
56
+ */
57
+ export function statusLines(p: PageStatus, file: string, { waiting = true } = {}): string[] {
58
+ const lines: string[] = []
59
+ if (p.unpicked.length) lines.push(`${p.unpicked.length} answer${p.unpicked.length > 1 ? 's' : ''} no agent picked up (${[...new Set(p.unpicked.map(e => e.type))].join(', ')})`)
60
+ if (p.unheard.length) lines.push(`nobody listens for ${p.unheard.join(', ')}`)
61
+ if (lines.length) lines.push(`→ whiteboard wait --page ${file}`)
62
+ const heard = p.open.filter(t => !p.unheard.includes(t))
63
+ if (waiting && heard.length) lines.push(`waiting for the reader: ${heard.join(', ')}`)
64
+ return lines
65
+ }
66
+
67
+ /** Whose a page is, said to `session`: yours, another session's, or nobody's. */
68
+ export const whose = (p: PageStatus, session: string | null): string =>
69
+ p.owner && p.owner === session ? 'yours' : p.owner ? `session ${p.owner.slice(0, 8)}` : 'no session'