@bigmistqke/workpad 0.0.0-stage → 0.18.1

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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +781 -2
  3. package/bin/workpad.ts +1526 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  5. package/dist/bin/workpad.js +1202 -0
  6. package/dist/client/runtime.js +1194 -0
  7. package/dist/define.js +27 -0
  8. package/dist/plugins/alert/README.md +18 -0
  9. package/dist/plugins/alert/index.js +40 -0
  10. package/dist/plugins/alert/public/style.css +40 -0
  11. package/dist/plugins/ansi/README.md +36 -0
  12. package/dist/plugins/ansi/index.js +63 -0
  13. package/dist/plugins/ansi/public/style.css +28 -0
  14. package/dist/plugins/badge/README.md +32 -0
  15. package/dist/plugins/badge/index.js +28 -0
  16. package/dist/plugins/badge/public/style.css +30 -0
  17. package/dist/plugins/chat/README.md +81 -0
  18. package/dist/plugins/chat/index.js +96 -0
  19. package/dist/plugins/chat/public/client.js +3 -0
  20. package/dist/plugins/chat/public/style.css +143 -0
  21. package/dist/plugins/claude/README.md +116 -0
  22. package/dist/plugins/claude/channel.js +130 -0
  23. package/dist/plugins/claude/doctor.js +316 -0
  24. package/dist/plugins/claude/index.js +199 -0
  25. package/dist/plugins/claude/session.js +68 -0
  26. package/dist/plugins/code/README.md +54 -0
  27. package/dist/plugins/code/diff.js +75 -0
  28. package/dist/plugins/code/index.js +105 -0
  29. package/dist/plugins/code/public/client.js +1 -0
  30. package/dist/plugins/code/public/style.css +99 -0
  31. package/dist/plugins/comments/README.md +30 -0
  32. package/dist/plugins/comments/index.js +39 -0
  33. package/dist/plugins/comments/public/client.js +24 -0
  34. package/dist/plugins/comments/public/style.css +224 -0
  35. package/dist/plugins/details/README.md +24 -0
  36. package/dist/plugins/details/index.js +28 -0
  37. package/dist/plugins/details/public/style.css +7 -0
  38. package/dist/plugins/draft/README.md +14 -0
  39. package/dist/plugins/draft/index.js +27 -0
  40. package/dist/plugins/draft/public/style.css +21 -0
  41. package/dist/plugins/forge/README.md +22 -0
  42. package/dist/plugins/forge/index.js +83 -0
  43. package/dist/plugins/form/README.md +126 -0
  44. package/dist/plugins/form/index.js +179 -0
  45. package/dist/plugins/form/public/style.css +172 -0
  46. package/dist/plugins/grid/README.md +45 -0
  47. package/dist/plugins/grid/index.js +35 -0
  48. package/dist/plugins/grid/public/style.css +98 -0
  49. package/dist/plugins/iframe/README.md +18 -0
  50. package/dist/plugins/iframe/index.js +49 -0
  51. package/dist/plugins/iframe/public/style.css +28 -0
  52. package/dist/plugins/index.js +44 -0
  53. package/dist/plugins/lightbox/README.md +24 -0
  54. package/dist/plugins/lightbox/index.js +20 -0
  55. package/dist/plugins/lightbox/public/client.js +4 -0
  56. package/dist/plugins/lightbox/public/style.css +66 -0
  57. package/dist/plugins/mermaid/README.md +21 -0
  58. package/dist/plugins/mermaid/index.js +42 -0
  59. package/dist/plugins/mermaid/public/style.css +21 -0
  60. package/dist/plugins/opencode/README.md +48 -0
  61. package/dist/plugins/opencode/channel.js +92 -0
  62. package/dist/plugins/opencode/index.js +64 -0
  63. package/dist/plugins/opencode/shim.js +150 -0
  64. package/dist/plugins/quiet/README.md +26 -0
  65. package/dist/plugins/quiet/index.js +23 -0
  66. package/dist/plugins/tabs/README.md +44 -0
  67. package/dist/plugins/tabs/index.js +75 -0
  68. package/dist/plugins/tabs/public/client.js +1 -0
  69. package/dist/plugins/tabs/public/style.css +98 -0
  70. package/dist/plugins/terminal/README.md +63 -0
  71. package/dist/plugins/terminal/host.js +338 -0
  72. package/dist/plugins/terminal/index.js +170 -0
  73. package/dist/plugins/terminal/modes.js +32 -0
  74. package/dist/plugins/terminal/public/client.js +41 -0
  75. package/dist/plugins/terminal/public/style.css +511 -0
  76. package/dist/plugins/terminal/server.js +256 -0
  77. package/dist/plugins/terminal/sizes.js +58 -0
  78. package/dist/plugins/timeline/README.md +48 -0
  79. package/dist/plugins/timeline/index.js +83 -0
  80. package/dist/plugins/timeline/public/style.css +138 -0
  81. package/dist/plugins/toc/README.md +40 -0
  82. package/dist/plugins/toc/index.js +29 -0
  83. package/dist/plugins/toc/public/client.js +1 -0
  84. package/dist/plugins/toc/public/style.css +117 -0
  85. package/dist/plugins/window/README.md +51 -0
  86. package/dist/plugins/window/index.js +91 -0
  87. package/dist/solid/index.js +41 -0
  88. package/dist/src/agents.js +81 -0
  89. package/dist/src/anchors.js +52 -0
  90. package/dist/src/api.js +282 -0
  91. package/dist/src/archive.js +49 -0
  92. package/dist/src/auth.js +67 -0
  93. package/dist/src/build.js +159 -0
  94. package/dist/src/client/page/base.css +1762 -0
  95. package/dist/src/client/page/main.js +2121 -0
  96. package/dist/src/config.js +76 -0
  97. package/dist/src/document.js +93 -0
  98. package/dist/src/entries.js +264 -0
  99. package/dist/src/events.js +322 -0
  100. package/dist/src/files.js +47 -0
  101. package/dist/src/formstate.js +65 -0
  102. package/dist/src/help.js +213 -0
  103. package/dist/src/html.js +34 -0
  104. package/dist/src/hub.js +348 -0
  105. package/dist/src/icons.js +6 -0
  106. package/dist/src/listen.js +132 -0
  107. package/dist/src/listeners.js +64 -0
  108. package/dist/src/load.js +81 -0
  109. package/dist/src/loader.js +179 -0
  110. package/dist/src/migrate.js +314 -0
  111. package/dist/src/package.js +52 -0
  112. package/dist/src/pages/blocks.js +67 -0
  113. package/dist/src/pages/board.js +59 -0
  114. package/dist/src/pages/index.js +27 -0
  115. package/dist/src/pages/markdown.js +863 -0
  116. package/dist/src/pages/render.js +761 -0
  117. package/dist/src/pages/window.js +29 -0
  118. package/dist/src/plugins.js +283 -0
  119. package/dist/src/public.js +24 -0
  120. package/dist/src/rename.js +130 -0
  121. package/dist/src/running.js +146 -0
  122. package/dist/src/serve.js +188 -0
  123. package/dist/src/server.js +1105 -0
  124. package/dist/src/site.js +179 -0
  125. package/dist/src/state.js +155 -0
  126. package/dist/src/status.js +323 -0
  127. package/dist/src/thread.js +68 -0
  128. package/dist/src/watchdog.js +38 -0
  129. package/dist/src/ws.js +128 -0
  130. package/package.json +154 -4
  131. package/plugins/README.md +304 -0
  132. package/plugins/alert/README.md +18 -0
  133. package/plugins/alert/index.ts +50 -0
  134. package/plugins/alert/public/style.css +40 -0
  135. package/plugins/ansi/README.md +36 -0
  136. package/plugins/ansi/index.ts +95 -0
  137. package/plugins/ansi/public/style.css +28 -0
  138. package/plugins/badge/README.md +32 -0
  139. package/plugins/badge/index.ts +36 -0
  140. package/plugins/badge/public/style.css +30 -0
  141. package/plugins/chat/README.md +81 -0
  142. package/plugins/chat/autosize.ts +139 -0
  143. package/plugins/chat/client.tsx +187 -0
  144. package/plugins/chat/index.ts +146 -0
  145. package/plugins/chat/public/style.css +143 -0
  146. package/plugins/claude/README.md +116 -0
  147. package/plugins/claude/channel.ts +136 -0
  148. package/plugins/claude/doctor.ts +274 -0
  149. package/plugins/claude/index.ts +248 -0
  150. package/plugins/claude/session.ts +70 -0
  151. package/plugins/code/README.md +54 -0
  152. package/plugins/code/client.ts +73 -0
  153. package/plugins/code/diff.ts +96 -0
  154. package/plugins/code/index.ts +136 -0
  155. package/plugins/code/public/style.css +99 -0
  156. package/plugins/comments/README.md +30 -0
  157. package/plugins/comments/client.ts +723 -0
  158. package/plugins/comments/index.ts +48 -0
  159. package/plugins/comments/public/style.css +224 -0
  160. package/plugins/details/README.md +24 -0
  161. package/plugins/details/index.ts +30 -0
  162. package/plugins/details/public/style.css +7 -0
  163. package/plugins/draft/README.md +14 -0
  164. package/plugins/draft/index.ts +23 -0
  165. package/plugins/draft/public/style.css +21 -0
  166. package/plugins/forge/README.md +22 -0
  167. package/plugins/forge/index.ts +84 -0
  168. package/plugins/form/README.md +126 -0
  169. package/plugins/form/index.ts +199 -0
  170. package/plugins/form/public/style.css +172 -0
  171. package/plugins/grid/README.md +45 -0
  172. package/plugins/grid/index.ts +41 -0
  173. package/plugins/grid/public/style.css +98 -0
  174. package/plugins/iframe/README.md +18 -0
  175. package/plugins/iframe/index.ts +53 -0
  176. package/plugins/iframe/public/style.css +28 -0
  177. package/plugins/index.ts +49 -0
  178. package/plugins/lightbox/README.md +24 -0
  179. package/plugins/lightbox/client.ts +109 -0
  180. package/plugins/lightbox/index.ts +25 -0
  181. package/plugins/lightbox/public/style.css +66 -0
  182. package/plugins/mermaid/README.md +21 -0
  183. package/plugins/mermaid/index.ts +46 -0
  184. package/plugins/mermaid/public/style.css +21 -0
  185. package/plugins/opencode/README.md +48 -0
  186. package/plugins/opencode/channel.ts +112 -0
  187. package/plugins/opencode/index.ts +91 -0
  188. package/plugins/opencode/shim.ts +166 -0
  189. package/plugins/quiet/README.md +26 -0
  190. package/plugins/quiet/index.ts +28 -0
  191. package/plugins/tabs/README.md +44 -0
  192. package/plugins/tabs/client.ts +96 -0
  193. package/plugins/tabs/index.ts +103 -0
  194. package/plugins/tabs/public/style.css +98 -0
  195. package/plugins/terminal/README.md +63 -0
  196. package/plugins/terminal/client.ts +391 -0
  197. package/plugins/terminal/host.ts +434 -0
  198. package/plugins/terminal/index.ts +199 -0
  199. package/plugins/terminal/modes.ts +30 -0
  200. package/plugins/terminal/public/style.css +225 -0
  201. package/plugins/terminal/server.ts +266 -0
  202. package/plugins/terminal/sizes.ts +72 -0
  203. package/plugins/timeline/README.md +48 -0
  204. package/plugins/timeline/index.ts +82 -0
  205. package/plugins/timeline/public/style.css +138 -0
  206. package/plugins/toc/README.md +40 -0
  207. package/plugins/toc/client.ts +236 -0
  208. package/plugins/toc/index.ts +55 -0
  209. package/plugins/toc/public/style.css +117 -0
  210. package/plugins/window/README.md +51 -0
  211. package/plugins/window/index.ts +92 -0
  212. package/skills/workpad/SKILL.md +592 -0
  213. package/solid/index.tsx +80 -0
  214. package/src/agents.ts +134 -0
  215. package/src/anchors.ts +85 -0
  216. package/src/api.ts +444 -0
  217. package/src/archive.ts +75 -0
  218. package/src/auth.ts +99 -0
  219. package/src/build.ts +213 -0
  220. package/src/client/base.ts +19 -0
  221. package/src/client/forms.ts +420 -0
  222. package/src/client/markdown.ts +147 -0
  223. package/src/client/page/base.css +1762 -0
  224. package/src/client/page/board.ts +166 -0
  225. package/src/client/page/elsewhere.ts +153 -0
  226. package/src/client/page/fresh.ts +343 -0
  227. package/src/client/page/heading-link.ts +32 -0
  228. package/src/client/page/live.ts +134 -0
  229. package/src/client/page/main.ts +398 -0
  230. package/src/client/page/orphans.ts +64 -0
  231. package/src/client/page/place.ts +260 -0
  232. package/src/client/page/sort.ts +49 -0
  233. package/src/client/page/sticky.ts +58 -0
  234. package/src/client/page/theme.ts +36 -0
  235. package/src/client/page/view.ts +9 -0
  236. package/src/client/page/waiting.ts +278 -0
  237. package/src/client/page/window.ts +40 -0
  238. package/src/client/reactive.ts +19 -0
  239. package/src/client/read.ts +111 -0
  240. package/src/client/runtime.ts +499 -0
  241. package/src/client/scroll.ts +90 -0
  242. package/src/client/toast.ts +99 -0
  243. package/src/config.ts +111 -0
  244. package/src/define.ts +997 -0
  245. package/src/document.ts +191 -0
  246. package/src/entries.ts +352 -0
  247. package/src/events.ts +463 -0
  248. package/src/files.ts +74 -0
  249. package/src/formstate.ts +72 -0
  250. package/src/help.ts +240 -0
  251. package/src/html.ts +44 -0
  252. package/src/hub.ts +435 -0
  253. package/src/icons.ts +18 -0
  254. package/src/listen.ts +171 -0
  255. package/src/listeners.ts +89 -0
  256. package/src/load.ts +113 -0
  257. package/src/loader.ts +227 -0
  258. package/src/migrate.ts +352 -0
  259. package/src/package.ts +62 -0
  260. package/src/pages/blocks.ts +106 -0
  261. package/src/pages/board.ts +89 -0
  262. package/src/pages/index.ts +79 -0
  263. package/src/pages/markdown.ts +976 -0
  264. package/src/pages/render.ts +845 -0
  265. package/src/pages/window.ts +69 -0
  266. package/src/plugins.ts +319 -0
  267. package/src/public.ts +39 -0
  268. package/src/rename.ts +147 -0
  269. package/src/running.ts +171 -0
  270. package/src/serve.ts +221 -0
  271. package/src/server.ts +1385 -0
  272. package/src/site.ts +170 -0
  273. package/src/state.ts +327 -0
  274. package/src/status.ts +466 -0
  275. package/src/thread.ts +98 -0
  276. package/src/watchdog.ts +53 -0
  277. package/src/ws.ts +155 -0
package/src/help.ts ADDED
@@ -0,0 +1,240 @@
1
+ // The help of the built-in commands: what each takes and does, for `workpad <command> --help`
2
+ // (which prints it and exits before the command does anything), and the overview `workpad help`
3
+ // lists from the same entries, so the two never drift. A plugin's commands have theirs from what
4
+ // they declare (src/plugins.ts, commandHelp).
5
+ import { MIGRATIONS } from './migrate.ts'
6
+
7
+ export interface CommandHelp {
8
+ /** what follows the command's name: `<page|file> [--type <type>]` */
9
+ usage: string
10
+ /** one line, for the overview */
11
+ summary: string
12
+ /** its options and what to know beyond the summary, for its own help */
13
+ details?: string
14
+ }
15
+
16
+ const FILTERS = ` --page <page|file> only that page and the pages below it
17
+ --type <type> only events of that type (a form's name, chat:message, comments:new…)`
18
+
19
+ export const COMMAND_HELP: Record<string, CommandHelp> = {
20
+ init: {
21
+ usage: '[name]',
22
+ summary: 'make this folder a project: .workpad/pages/',
23
+ details: 'Writes a config only for what differs from the defaults (a name; files: false in the home folder).',
24
+ },
25
+ root: { usage: '', summary: "print where pages go (this project's .workpad/pages)" },
26
+ new: {
27
+ usage: '<name>',
28
+ summary: 'create a page under a name no other page has (name, name-2, …), print its path',
29
+ details: 'Subfolders are fine (task/plan). Whoever runs it (--agent, WORKPAD_AGENT, a plugin\'s session) is subscribed to the page.',
30
+ },
31
+
32
+ agent: {
33
+ usage: '[name <name> | name --clear | list | unsubscribe <agent> [--page <p>…] | ping [<code> | --wait [--timeout <s>]]]',
34
+ summary: 'who you are on the boards: your id and name; name yourself, see who else is around, check a channel reaches you',
35
+ details: `Your id is --agent, else WORKPAD_AGENT, else the session an agent plugin names (claude(),
36
+ opencode()). Alone, it says your id and your name.
37
+
38
+ name <name> the name you show as (the list on a page's dot, status), one per agent: a new
39
+ one takes the old one's place; --clear drops it. Kept on no page, so deleting a
40
+ page keeps it
41
+ list everyone on this board: their name and id, what each is subscribed to, what
42
+ each listens on now; subscribed and not listening is said
43
+ unsubscribe <agent> take an agent (its id or name) off the pages named with --page, else off all
44
+ of them: one that is gone (a relay that stopped) stays a subscriber otherwise
45
+ ping [<code>] does what a plugin pushes reach you? It pings your channel, which pushes a pong
46
+ into the session, the way answers will, with the code to confirm with. Once
47
+ confirmed, the channel listens on your pages, and the answers it brings count
48
+ as received. No channel (exit 1), or no pong: nothing brings answers here, so
49
+ listen for them. --wait: run it in the background; it pings and ends when
50
+ the pong is confirmed (exit 0), or after --timeout seconds (120) without one
51
+ (exit 1): then listen.`,
52
+ },
53
+
54
+ show: {
55
+ usage: '<page|file> [<anchor>]',
56
+ summary: "start this project's server if needed, print the page's URL",
57
+ details:
58
+ "Any file of the project renders too (README.md). Under a shared server that isn't running, says so and starts nothing. With an anchor (`form:logger`, a heading's slug: see `workpad anchors`), the URL opens the page there; one the page doesn't have exits 1.",
59
+ },
60
+ url: {
61
+ usage: '<page|file> [<anchor>] [--full]',
62
+ summary: 'a link to a page, or to a place on it, for a message or a page: from the server root',
63
+ details:
64
+ "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
+ },
66
+ settle: {
67
+ usage: '<page|file> <form>… | --all',
68
+ summary: 'settle questions answered elsewhere (a chat, the design moving on): no longer unanswered',
69
+ 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.",
71
+ },
72
+ hold: {
73
+ usage: '<page|file> <form>… "<reason>"',
74
+ summary: 'hold questions that wait on something else ("waits for !2145"): not waiting for the reader, not settled',
75
+ details:
76
+ "A held form shows on the page with its reason, and counts nowhere as waiting for the reader: not in `workpad status`, the page's counter, the turn-end check or the overview's waiting column. It isn't settled either: `workpad release` opens it again. Only a question that waits for the reader is held (one held already takes the new reason). If the reader answers it after all, the answer counts and the hold ends.",
77
+ },
78
+ release: {
79
+ usage: '<page|file> <form>…',
80
+ summary: 'release held questions: they wait for the reader again',
81
+ },
82
+ check: {
83
+ 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",
85
+ 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 doesn't have. The page shows the same above it. Exits 1 when there is any. Run it after writing a page.",
87
+ },
88
+ anchors: {
89
+ usage: '<page|file>',
90
+ summary: 'what a page can be linked to: each #anchor, what it is and what it says',
91
+ details:
92
+ "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
+ },
94
+ migrate: {
95
+ usage: '[<folder|file>…] [--write]',
96
+ summary: "after updating workpad: rewrite pages written in an older syntax in the current one",
97
+ details: `Without --write, a dry run: each page that would change, and what would. --write rewrites them
98
+ in place. Without paths, this project's pages (.workpad/pages); a folder is searched for .md files.
99
+ Code fences and inline code are left as they are, and a page already in the current syntax doesn't
100
+ change: running it again changes nothing. A dry run that finds pages to change exits 1 (for CI);
101
+ otherwise it exits 0.
102
+
103
+ ${MIGRATIONS.map(m => ` ${m.name.padEnd(20)} ${m.description}`).join('\n')}`,
104
+ },
105
+ archive: {
106
+ usage: '<page|file>',
107
+ summary:
108
+ 'a page that did its job: it leaves the pages and its events the log, kept as markdown with what was answered on it',
109
+ details:
110
+ "The file goes to .workpad/archive/<page>-<date>.md: the page, then each form's answers with when they came, its chats, its comments. It reads without a server, and moves with the project's folder.",
111
+ },
112
+ destroy: {
113
+ usage: '<page|file>',
114
+ summary: 'a throwaway page: remove its file, and its events from the log; nothing is kept',
115
+ },
116
+ prune: {
117
+ usage: '<page|file> [--type <type>] [--id <event id>]',
118
+ summary: "remove a page's events from the log, keep the page",
119
+ details: ` --type <type> only the events of that type
120
+ --id <event id> only that event
121
+
122
+ Without either, all of the page's events: its questions are open again.
123
+ One chat's messages: workpad chat prune <page|file> <chat>.`,
124
+ },
125
+ build: {
126
+ usage: '[globs…] [--out <dir>] [--skip <a,b>]',
127
+ summary: 'pages as a static site: plain HTML, links relative',
128
+ details: ` --out <dir> where to write it (default: the config's build.out)
129
+ --skip <a,b> plugins or blocks to leave out (default: form, chat, comments, draft)`,
130
+ },
131
+ edit: {
132
+ usage: '<event id> --data <json>',
133
+ summary: "change an agent's own event in place (merged into its data)",
134
+ details: "Keeps its id, so what refers to it still does. What the reader sent can't be edited.",
135
+ },
136
+ scroll: {
137
+ usage: '<page|file> <where>',
138
+ summary: "scroll the tabs that have the page open to a heading's text, a form's name or any text",
139
+ details:
140
+ 'Opens details around it and lights it up. Exits 1 when nothing matches or no tab of the page is connected.',
141
+ },
142
+ docs: {
143
+ usage: '[<block|plugin> | --all]',
144
+ summary: 'how to write pages here: markdown, and a line per block by what it is for; read it before writing one',
145
+ details:
146
+ "Without arguments, the menu: how pages are written, and each block's line under what an agent wants to do (ask, show, arrange, mark). With a block's name, the docs of the plugin that brings it (`workpad docs tabs`); a plugin's name works too. With `--all`, every plugin's docs.",
147
+ },
148
+ events: {
149
+ usage: '[--page <p>] [--type <t>] [--since <time|id>] [--last <n>] [--follow]',
150
+ summary: 'print recorded events as ndjson; marks nothing received',
151
+ details: `${FILTERS}
152
+ --since <time|id> only those after an ISO time or an event id
153
+ --last <n> only the last n
154
+ --follow then print each new one as it comes`,
155
+ },
156
+ listen: {
157
+ usage: '[--page <p>…] [--type <t>] [--wait [--timeout <s>] | --channel] [--agent <who>]',
158
+ summary:
159
+ "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
+ details: `${FILTERS}
161
+ --page again several pages in one listen: it listens on each, and takes what comes on any
162
+ --wait stop once it printed: all there are, or with none, the first to come
163
+ --timeout <seconds> with --wait: exit 2 when nothing came
164
+ --channel make the pages yours and exit: your session's channel brings their answers
165
+ --agent <who> who listens (else WORKPAD_AGENT, else the session an agent plugin names)
166
+
167
+ It prints, one line each, everything on the page you haven't handled, also from before it started,
168
+ then each new one as it comes, and runs on: run it in the background. To get the next answer and
169
+ your turn back, --wait. In a session whose channel is confirmed (workpad agent ping), --channel
170
+ makes the pages yours (without --page, every page, also those made later) and exits: the channel
171
+ brings the reader's answers waiting there and what comes; other agents' messages from before that
172
+ someone already received are skipped, and it says how many (listen --wait hands them out). Each
173
+ counts as received by you. One you
174
+ received before and still haven't handled comes again, with "again": true. You handle one by
175
+ replying in its chat (or to it), or with workpad handled <id>. Then it lists what is left:
176
+ answers to handle, chats waiting for your reply, questions still unanswered.
177
+
178
+ Any number listen on a page, and each hears everything there but its own events: agents can talk
179
+ 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).`,
181
+ },
182
+ append: {
183
+ usage: '--page <p> --type <t> [--data <json>]',
184
+ summary: "add an event to a page's log, as the agent (a reply, a chat message)",
185
+ },
186
+ handled: {
187
+ usage: '<event id> [<event id>…]',
188
+ summary:
189
+ 'you are done with these answers: handled, so no listen hands them out again and nothing reminds you of them',
190
+ details: "Replying in an answer's chat (or to it) handles it too.",
191
+ },
192
+ thread: {
193
+ usage: '<event id>',
194
+ summary:
195
+ 'an answer or chat message with its question: the form as written, the chosen options marked, its answers and its chat',
196
+ details:
197
+ 'For acting on an answer you were handed (a listen, the channel) without piecing the question together from the page and the log. Reads the page and the log: no server needed.',
198
+ },
199
+ status: {
200
+ usage: '[--page <p>]',
201
+ summary:
202
+ 'per page: questions without an answer, answers not received or not handled, chats waiting for a reply, who listens',
203
+ },
204
+ serve: {
205
+ usage: '',
206
+ summary:
207
+ "run this project's server in the foreground; outside a project or for one of the machine's entries, the shared server",
208
+ },
209
+ skill: { usage: '[dir]', summary: 'print where the agent skill is, or link it into a skills folder' },
210
+ paths: {
211
+ usage: '[--write|--read]',
212
+ summary: 'the folders the shared server needs, for a sandbox wrapper to grant',
213
+ details: ` --write the entries' folders and the server's state
214
+ --read the machine config and workpad itself`,
215
+ },
216
+ help: { usage: '[command]', summary: 'this overview; with a command, its help (as <command> --help)' },
217
+ }
218
+
219
+ /** `workpad <name> --help`: its usage, what it does, and its options. */
220
+ export function commandHelp(name: string): string {
221
+ const h = COMMAND_HELP[name]
222
+ if (!h) throw new Error(`no command ${name}`)
223
+ return [
224
+ `usage: workpad ${[name, h.usage].filter(Boolean).join(' ')}`,
225
+ '',
226
+ h.summary,
227
+ h.details ? `\n${h.details}` : '',
228
+ ]
229
+ .join('\n')
230
+ .trimEnd()
231
+ }
232
+
233
+ /** The overview's list of commands, one line each. */
234
+ export function commandList(): string {
235
+ const lines = Object.entries(COMMAND_HELP).map(([name, h]) => {
236
+ const head = ` workpad ${[name, h.usage].filter(Boolean).join(' ')}`
237
+ return head.length < 36 ? `${head.padEnd(36)} ${h.summary}` : `${head}\n${' '.repeat(37)}${h.summary}`
238
+ })
239
+ return lines.join('\n')
240
+ }
package/src/html.ts ADDED
@@ -0,0 +1,44 @@
1
+ // HTML from a template literal, escaped by default:
2
+ //
3
+ // html`<li><a href="/${id}">${title}</a></li>`
4
+ //
5
+ // Every interpolated value is escaped, in text and in attributes alike, unless it is HTML already:
6
+ // what `html` itself returns, or a string passed through `raw()` on purpose (markdown's output, say).
7
+ // An array is joined, so `${items.map(i => html`<li>${i}</li>`)}` needs no `.join('')`; null,
8
+ // undefined and false render as nothing, so `${cond && html`…`}` works when `cond` is a boolean (a
9
+ // count of 0 would render as 0: write `count > 0 && …`).
10
+ //
11
+ // Everything that builds HTML uses it: the core's page shell, the page on the server and in the
12
+ // browser, and plugins (`import { html, raw } from '@bigmistqke/workpad'`).
13
+
14
+ /** A piece of HTML that is not escaped again. `String(piece)` is its markup. */
15
+ export class Html {
16
+ value: string
17
+ constructor(value: string) {
18
+ this.value = value
19
+ }
20
+ toString() {
21
+ return this.value
22
+ }
23
+ }
24
+
25
+ const ESCAPE: Record<string, string> = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }
26
+
27
+ /** Text → HTML that shows it as text. */
28
+ export const escape = (value: unknown): string => String(value).replace(/[&<>"']/g, c => ESCAPE[c]!)
29
+
30
+ /** Markup to use as it is: only for HTML that is safe already, never for text from outside. */
31
+ export const raw = (value: unknown): Html => new Html(String(value ?? ''))
32
+
33
+ function part(value: unknown): string {
34
+ if (value == null || value === false) return ''
35
+ if (value instanceof Html) return value.value
36
+ if (Array.isArray(value)) return value.map(part).join('')
37
+ return escape(value)
38
+ }
39
+
40
+ export function html(strings: TemplateStringsArray, ...values: unknown[]): Html {
41
+ let out = strings[0]!
42
+ for (let i = 0; i < values.length; i++) out += part(values[i]) + strings[i + 1]
43
+ return new Html(out)
44
+ }