@bigmistqke/workpad 0.0.0-stage → 0.18.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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +781 -2
  3. package/bin/workpad.ts +1509 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  5. package/dist/bin/workpad.js +1190 -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 +2098 -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 +211 -0
  103. package/dist/src/html.js +34 -0
  104. package/dist/src/hub.js +341 -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 +665 -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 +588 -0
  213. package/solid/index.tsx +80 -0
  214. package/src/agents.ts +133 -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 +137 -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 +238 -0
  251. package/src/html.ts +44 -0
  252. package/src/hub.ts +426 -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 +748 -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
@@ -0,0 +1,48 @@
1
+ // Comments, as a workpad plugin: on every page the reader selects a passage and comments on it,
2
+ // and the agent replies in the thread or edits the page. Built in: every project has it.
3
+ //
4
+ // A thread is events on the page (see client.ts), so the server has nothing to do but serve the
5
+ // browser module and the styles, and tell agents how to answer (`workpad docs`).
6
+ import fs from 'node:fs'
7
+ import { builtinPublic } from '../../src/package.ts'
8
+ import type { Plugin, WpEvent } from '../../src/define.ts'
9
+ import { item, when } from '../../src/archive.ts'
10
+
11
+ export default function comments(): Plugin {
12
+ return {
13
+ name: 'comments',
14
+ docs: () => fs.readFileSync(new URL('./README.md', import.meta.url), 'utf8'),
15
+ archive: archiveComments,
16
+ events: {
17
+ 'comments:new': {
18
+ handOut: true,
19
+ description:
20
+ "a comment on a passage or lines of code: `{ quote, before, after, block, at?, text }`; its id is the thread's",
21
+ },
22
+ 'comments:reply': { handOut: true, forReader: true, description: 'a reply in a thread: `{ replyTo, text }`' },
23
+ 'comments:resolve': { description: 'the reader closed a thread: `{ replyTo }`' },
24
+ },
25
+ public: builtinPublic('comments'),
26
+ style: 'style.css',
27
+ setup: () => ({ client: 'client.js' }),
28
+ }
29
+ }
30
+
31
+ /** An archived page's comments: each thread, the passage it is on, its replies, and whether it was closed. */
32
+ function archiveComments(events: WpEvent[]) {
33
+ const threads = events.filter(e => e.type === 'comments:new')
34
+ if (!threads.length) return
35
+ const who = (e: WpEvent) => (e.from === 'cli' ? 'agent' : 'you')
36
+ return [
37
+ '## Comments',
38
+ ...threads.map(c => {
39
+ const replies = events.filter(e => e.type === 'comments:reply' && e.data.replyTo === c.id)
40
+ const closed = events.some(e => e.type === 'comments:resolve' && e.data.replyTo === c.id)
41
+ const on = String(c.data.quote ?? c.data.at ?? '').trim()
42
+ return [
43
+ `### On ${on ? `“${on.length > 80 ? on.slice(0, 80) + '…' : on}”` : 'the page'}${closed ? ' (closed)' : ''}`,
44
+ [c, ...replies].map(e => item(`${who(e)}, ${when(e)}`, String(e.data.text ?? ''))).join('\n'),
45
+ ].join('\n\n')
46
+ }),
47
+ ].join('\n\n')
48
+ }
@@ -0,0 +1,224 @@
1
+ /*
2
+ * Comments: highlights through the CSS Highlight API, badges and threads above the page. Colors
3
+ * and fonts come from the page's theme variables, else from
4
+ * the fallbacks here.
5
+ */
6
+ ::highlight(wp-comment) {
7
+ background-color: color-mix(in srgb, var(--accent, #1d5bbf) var(--tint-soft), transparent);
8
+ }
9
+ ::highlight(wp-comment-active) {
10
+ background-color: color-mix(in srgb, var(--accent, #1d5bbf) var(--tint-strong), transparent);
11
+ }
12
+ .wp-comment-start,
13
+ .wp-comment-badge,
14
+ .wp-thread {
15
+ position: absolute;
16
+ z-index: var(--layer-popover);
17
+ font-family: var(--sans, sans-serif);
18
+ }
19
+ .wp-comment-start[hidden],
20
+ .wp-thread[hidden],
21
+ .wp-line-comment[hidden] {
22
+ display: none;
23
+ }
24
+ .wp-comment-start {
25
+ background: var(--accent, #1d5bbf);
26
+ color: var(--accent-text, #fff);
27
+ border-color: var(--accent, #1d5bbf);
28
+ border-radius: var(--radius-pill);
29
+ font-size: var(--ui-small);
30
+ padding: var(--space-2xs) var(--space-lg);
31
+ box-shadow: 0 2px 8px rgb(0 0 0 / 0.15);
32
+ }
33
+ .wp-comment-badge {
34
+ min-width: 24px;
35
+ height: 24px;
36
+ padding: 0 var(--space-sm);
37
+ border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
38
+ font-size: var(--ui-tiny);
39
+ font-weight: var(--weight-strong);
40
+ background: var(--bg, Canvas);
41
+ color: var(--accent, #1d5bbf);
42
+ border: var(--hairline) solid color-mix(in srgb, var(--accent, #1d5bbf) var(--tint-strong), transparent);
43
+ }
44
+ .wp-comment-badge[data-agent] {
45
+ background: var(--accent, #1d5bbf);
46
+ color: var(--accent-text, #fff);
47
+ }
48
+ .wp-comment-badge[data-detached] {
49
+ border-style: dashed;
50
+ }
51
+ /* a reply the reader hasn't read: a dot on the badge until its thread is open and it is in view */
52
+ .wp-comment-badge[data-unread]::after {
53
+ content: '';
54
+ position: absolute;
55
+ top: -3px;
56
+ right: -3px;
57
+ width: 9px;
58
+ height: 9px;
59
+ border-radius: 50%;
60
+ background: var(--bad, #c4352b);
61
+ border: 2px solid var(--bg, Canvas);
62
+ }
63
+ .wp-thread {
64
+ background: var(--bg, Canvas);
65
+ border: var(--hairline) solid var(--border, #e3e5e9);
66
+ border-radius: var(--radius);
67
+ padding: var(--space-xl) var(--space-xl);
68
+ box-shadow: var(--shadow-pop);
69
+ display: grid;
70
+ /* one column as wide as the thread: a line that can't wrap scrolls in its own block, not the thread */
71
+ grid-template-columns: minmax(0, 1fr);
72
+ gap: var(--space-lg);
73
+ font-size: var(--ui-text);
74
+ }
75
+ .wp-thread-quote {
76
+ margin: 0;
77
+ padding-left: var(--space-lg);
78
+ border-left: 3px solid color-mix(in srgb, var(--accent, #1d5bbf) var(--tint-strong), transparent);
79
+ color: var(--muted, #696e76);
80
+ font-size: var(--ui-small);
81
+ max-height: 6.5em;
82
+ overflow: auto;
83
+ white-space: pre-wrap;
84
+ overflow-wrap: anywhere;
85
+ }
86
+ .wp-thread-detached {
87
+ margin: 0;
88
+ color: var(--muted, #696e76);
89
+ font-size: var(--ui-small);
90
+ }
91
+ .wp-thread-message {
92
+ display: grid;
93
+ grid-template-columns: minmax(0, 1fr);
94
+ gap: var(--space-2xs);
95
+ }
96
+ .wp-thread-who {
97
+ font-size: var(--ui-tiny);
98
+ font-weight: var(--weight-strong);
99
+ letter-spacing: var(--caps-spacing);
100
+ text-transform: uppercase;
101
+ color: var(--muted, #696e76);
102
+ }
103
+ .wp-thread-message[data-from='agent'] .wp-thread-who {
104
+ color: var(--accent, #1d5bbf);
105
+ }
106
+ .wp-thread-text {
107
+ white-space: pre-wrap;
108
+ overflow-wrap: anywhere;
109
+ line-height: var(--ui-line-height);
110
+ }
111
+ /* rendered from markdown: its paragraphs and code carry the spacing */
112
+ .wp-thread-text[data-md] {
113
+ white-space: normal;
114
+ overflow-wrap: anywhere;
115
+ }
116
+ .wp-thread-text[data-md] > :first-child {
117
+ margin-top: 0;
118
+ }
119
+ .wp-thread-text[data-md] > :last-child {
120
+ margin-bottom: 0;
121
+ }
122
+ .wp-thread-text[data-md] :is(p, ul, ol, pre, blockquote) {
123
+ margin: 0 0 0.5em;
124
+ }
125
+ .wp-thread-text[data-md] pre {
126
+ font-size: var(--ui-small);
127
+ padding: var(--space-md) var(--space-lg);
128
+ border-radius: var(--radius-sm);
129
+ overflow-x: auto;
130
+ max-width: 100%;
131
+ }
132
+ .wp-thread textarea {
133
+ width: 100%;
134
+ resize: vertical;
135
+ font: inherit;
136
+ }
137
+ .wp-thread-reply {
138
+ display: grid;
139
+ gap: var(--space-md);
140
+ margin: 0;
141
+ }
142
+ .wp-thread-actions {
143
+ display: flex;
144
+ gap: var(--space-md);
145
+ }
146
+ /* its own buttons, styled here rather than borrowed from the page */
147
+ .wp-comment-button {
148
+ font: 500 var(--ui-small)/1.3 var(--sans, sans-serif);
149
+ padding: var(--space-sm) var(--space-xl);
150
+ border-radius: var(--radius-sm);
151
+ cursor: pointer;
152
+ border: var(--hairline) solid var(--border, #e3e5e9);
153
+ background: var(--surface, Canvas);
154
+ color: var(--text, CanvasText);
155
+ }
156
+ .wp-comment-button:hover {
157
+ border-color: var(--muted, #696e76);
158
+ }
159
+ .wp-comment-primary {
160
+ background: var(--accent, #1d5bbf);
161
+ color: var(--accent-text, #fff);
162
+ border-color: var(--accent, #1d5bbf);
163
+ }
164
+ .wp-comment-start,
165
+ .wp-comment-badge {
166
+ cursor: pointer;
167
+ border-style: solid;
168
+ border-width: var(--hairline);
169
+ }
170
+
171
+ /* "+" beside a line of code: comment on it, or drag over several */
172
+ .wp-line-comment {
173
+ position: absolute;
174
+ z-index: var(--layer-popover);
175
+ width: 20px;
176
+ height: 20px;
177
+ padding: 0;
178
+ border-radius: var(--radius-sm);
179
+ cursor: pointer;
180
+ font: var(--weight-strong) 14px/1 var(--sans, sans-serif);
181
+ background: var(--accent, #1d5bbf);
182
+ color: var(--accent-text, #fff);
183
+ border: none;
184
+ box-shadow: 0 1px 4px rgb(0 0 0 / 0.2);
185
+ }
186
+ .wp-thread-at {
187
+ margin: -4px 0 0;
188
+ font: var(--ui-small) var(--mono, monospace);
189
+ color: var(--muted, #696e76);
190
+ }
191
+ /* shown at once, grey until the server has it */
192
+ .wp-thread-message[data-sending] .wp-thread-text {
193
+ color: var(--wp-sending, #9a9fa7);
194
+ }
195
+
196
+ /* comments on text no longer on the page, with nothing of where it was left: listed after the
197
+ page's content, each quote with its badge beside it; a click opens the thread */
198
+ .wp-orphan-comments-title {
199
+ margin: var(--gap-section) 0 var(--space-md);
200
+ color: var(--muted, #696e76);
201
+ font-size: var(--ui-small);
202
+ }
203
+ /* laid out as the list of chats no longer on the page (the page's .wp-orphans), which may follow */
204
+ .wp-orphan-comments {
205
+ max-width: calc(var(--measure) + 66px);
206
+ margin: 0 auto;
207
+ position: relative;
208
+ left: calc(var(--wp-aside, 0px) / 2);
209
+ padding: 0 var(--space-2xl) 220px;
210
+ box-sizing: border-box;
211
+ font: var(--ui-text)/var(--ui-line-height) var(--sans);
212
+ }
213
+ .wp-orphan-comments[hidden] {
214
+ display: none;
215
+ }
216
+ /* the page's bottom space goes below the last list after the page */
217
+ main:has(+ .wp-orphan-comments:not([hidden])),
218
+ .wp-orphan-comments:has(+ .wp-orphans:not([hidden])) {
219
+ padding-bottom: 0;
220
+ }
221
+ .wp-orphan-comments .wp-thread-quote {
222
+ cursor: pointer;
223
+ margin: 0 0 var(--space-md);
224
+ }
@@ -0,0 +1,24 @@
1
+ A collapsible section. The label is the summary line; the body is any
2
+ markdown. Use it to keep in-depth explanation out of the way of the main read.
3
+ Unlike a raw `<details>` tag, the body needs no blank-line care. While it
4
+ is open, its title stays at the top as you scroll through it, and the title
5
+ of a details inside it stacks below.
6
+
7
+ A link to it, `#details:<its label as a slug>`, opens it.
8
+
9
+ Directly in a grid, tabs or a timeline, a details is an item as it is, its
10
+ label the title: in a grid it is the card, collapsed until opened.
11
+
12
+ Attributes: `open` (start expanded).
13
+
14
+ ```markdown
15
+ :::details[Why remark-directive instead of MDX?]
16
+ MDX fails the **whole page** on one stray `<` or `{`. Directives that no
17
+ block handles still render as plain markdown.
18
+ :::
19
+ ```
20
+
21
+ :::details[Why remark-directive instead of MDX?]
22
+ MDX fails the **whole page** on one stray `<` or `{`. Directives that no
23
+ block handles still render as plain markdown.
24
+ :::
@@ -0,0 +1,30 @@
1
+ import fs from 'node:fs'
2
+ import { definePlugin, type Plugin } from '@bigmistqke/workpad'
3
+ import { html, raw, slugText, type DirectiveContext } from '@bigmistqke/workpad'
4
+ import { builtinPublic } from '../../src/package.ts'
5
+
6
+ export async function render(ctx: DirectiveContext) {
7
+ // the label and content are HTML already
8
+ // #details:<its label as a slug> opens it, a repeat numbered (src/anchors.ts)
9
+ const id = ctx.anchor('details', slugText(ctx.labelText ?? 'details'), { numbered: true })
10
+ return html`<details class="wp-details" ${id ? html` id="${id}"` : ''} ${'open' in ctx.attrs && raw(' open')}>
11
+ <summary>${ctx.label ? raw(ctx.label) : 'Details'}</summary>
12
+ <div class="wp-details-body">${raw(await ctx.toHtml(ctx.children))}</div>
13
+ </details>`
14
+ }
15
+
16
+ export default function details(): Plugin {
17
+ return definePlugin({
18
+ name: 'details',
19
+ public: builtinPublic('details'),
20
+ blocks: {
21
+ details: {
22
+ menu: { group: 'arrange', summary: 'folded shut: depth the first view doesn\'t need' },
23
+ attrs: ['open'],
24
+ html: render,
25
+ style: 'style.css',
26
+ },
27
+ },
28
+ docs: () => fs.readFileSync(new URL('./README.md', import.meta.url), 'utf8'),
29
+ })
30
+ }
@@ -0,0 +1,7 @@
1
+ /* the base <details> style does the work; the body wrapper only needs spacing */
2
+ .wp-details > .wp-details-body > :first-child {
3
+ margin-top: 0.2em;
4
+ }
5
+ .wp-details > .wp-details-body > :last-child {
6
+ margin-bottom: 0;
7
+ }
@@ -0,0 +1,14 @@
1
+ What is there while a page is written, and not once it is built: a note to
2
+ check something, two versions of a paragraph, a question for later. It shows
3
+ set apart, marked as a draft; `workpad build` leaves it out (it is in the
4
+ build's `skip` by default). The label is optional.
5
+
6
+ ```markdown
7
+ :::draft[Check with the API]
8
+ Is `listen` really the only way to get answers?
9
+ :::
10
+ ```
11
+
12
+ :::draft[Check with the API]
13
+ Is `listen` really the only way to get answers?
14
+ :::
@@ -0,0 +1,23 @@
1
+ // Draft: what is there while a page is written, and not once it is built (`workpad build` leaves
2
+ // it out by default): a note to check something, two versions of a paragraph, a question for later.
3
+ import fs from 'node:fs'
4
+ import { definePlugin, html, raw, type DirectiveContext, type Plugin } from '@bigmistqke/workpad'
5
+ import { builtinPublic } from '../../src/package.ts'
6
+
7
+ export async function render(ctx: DirectiveContext) {
8
+ const label = ctx.label != null && String(ctx.label) !== '' ? ctx.label : 'draft'
9
+ return html`<aside class="wp-draft">
10
+ <div class="wp-draft-label">${raw(String(label))}</div>
11
+ ${raw(await ctx.toHtml(ctx.children))}
12
+ </aside>`
13
+ }
14
+
15
+ export default function draft(): Plugin {
16
+ return definePlugin({
17
+ name: 'draft',
18
+ public: builtinPublic('draft'),
19
+ style: 'style.css',
20
+ blocks: { draft: { html: render, menu: { group: 'mark', summary: 'not built yet: a proposal' } } },
21
+ docs: () => fs.readFileSync(new URL('./README.md', import.meta.url), 'utf8'),
22
+ })
23
+ }
@@ -0,0 +1,21 @@
1
+ /* A draft (index.ts): set apart, plainly not final */
2
+ .wp-draft {
3
+ margin: var(--gap-block) 0;
4
+ padding: var(--space-md) var(--space-xl) var(--space-xl);
5
+ border: var(--hairline) dashed color-mix(in srgb, var(--warn) var(--tint-strong), transparent);
6
+ border-radius: var(--radius);
7
+ background: color-mix(in srgb, var(--warn) var(--tint-faint), transparent);
8
+ }
9
+ .wp-draft-label {
10
+ font: var(--weight-strong) var(--ui-tiny) / var(--ui-line-height) var(--sans);
11
+ letter-spacing: var(--caps-spacing);
12
+ text-transform: uppercase;
13
+ color: var(--warn);
14
+ margin-bottom: var(--space-xs);
15
+ }
16
+ .wp-draft-label > * {
17
+ margin: 0;
18
+ }
19
+ .wp-draft > :last-child {
20
+ margin-bottom: 0;
21
+ }
@@ -0,0 +1,22 @@
1
+ Issues and pull/merge requests of the project's GitHub or GitLab repository
2
+ link themselves: write `#12` for issue 12 and `!34` for pull or merge request
3
+ 34, as plain text. `owner/repo#12` and `group/project!34` point into another
4
+ repository on the same host. Inside code (`` `#12` ``) they stay text.
5
+
6
+ The repository is read from the project's `origin` remote, so a self-hosted
7
+ GitLab works too. Without such a remote (a folder that is no git checkout)
8
+ they stay text; the project's config can say which:
9
+
10
+ ```ts
11
+ import forge from '@bigmistqke/workpad/forge'
12
+
13
+ export default defineConfig({
14
+ plugins: [forge({ host: 'gitlab.com', repo: 'group/project' })],
15
+ })
16
+ ```
17
+
18
+ `kind: 'github' | 'gitlab'` is needed only for a host whose name says neither.
19
+
20
+ ```markdown
21
+ Fixed in !34, which closes #12 (see also bigmistqke/other#3).
22
+ ```
@@ -0,0 +1,84 @@
1
+ // Links to a GitHub or GitLab repository's issues and pull/merge requests, as written in a page's
2
+ // text: `#12` is issue 12, `!34` pull or merge request 34, and `owner/repo#12` or
3
+ // `group/project!34` the same in another repository on the same host. Which repository is read
4
+ // from the project's `origin` remote (https or ssh), so self-hosted GitLab works too; without one,
5
+ // or one that is neither GitHub nor GitLab, it links nothing. `forge({ repo, host, kind })` in the
6
+ // config says it instead. Links only: nothing is fetched.
7
+ import fs from 'node:fs'
8
+ import { execFileSync } from 'node:child_process'
9
+ import { definePlugin, type Plugin, type TextLink } from '@bigmistqke/workpad'
10
+
11
+ export type ForgeKind = 'github' | 'gitlab'
12
+ export interface Forge {
13
+ kind: ForgeKind
14
+ host: string
15
+ repo: string
16
+ }
17
+
18
+ /** A git remote's URL → its host and repository path: https, ssh (`git@host:path`), ssh://. */
19
+ export function parseRemote(url: string): { host: string; repo: string } | null {
20
+ const u = url.trim()
21
+ const scp = /^[\w.-]+@([^:/]+):(.+?)(?:\.git)?\/?$/.exec(u)
22
+ if (scp) return { host: scp[1], repo: scp[2] }
23
+ const full = /^(?:https?|ssh|git):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(u)
24
+ if (full) return { host: full[1], repo: full[2] }
25
+ return null
26
+ }
27
+
28
+ /** GitHub or GitLab, by the host's name; null for any other. */
29
+ export const kindOf = (host: string): ForgeKind | null =>
30
+ /(^|\.)github\./.test(host) ? 'github' : /(^|\.)gitlab\./.test(host) || /^gitlab/.test(host) ? 'gitlab' : null
31
+
32
+ /** The links for one forge: issues (`#n`) and pull or merge requests (`!n`), here or in `owner/repo`. */
33
+ export function forgeLinks({ kind, host, repo }: Forge): TextLink[] {
34
+ const base = (path: string | undefined) => `https://${host}/${path ?? repo}`
35
+ // after the start, a space or punctuation, so `C#1`, `a/b.md#12` and `x!3` stay text; an optional
36
+ // repository in front (`owner/repo#12`); then the number, ending at a word's end
37
+ const ref = (sign: string) => new RegExp(`(?<![\\w/.#!-])(?:([\\w.-]+(?:/[\\w.-]+)+))?${sign}(\\d+)(?![\\w-])`, 'g')
38
+ const issue = kind === 'github' ? 'issues' : '-/issues'
39
+ const change = kind === 'github' ? 'pull' : '-/merge_requests'
40
+ const what = kind === 'github' ? 'pull request' : 'merge request'
41
+ return [
42
+ { pattern: ref('#'), href: m => `${base(m[1])}/${issue}/${m[2]}`, title: m => `issue ${m[1] ?? repo}#${m[2]}` },
43
+ { pattern: ref('!'), href: m => `${base(m[1])}/${change}/${m[2]}`, title: m => `${what} ${m[1] ?? repo}!${m[2]}` },
44
+ ]
45
+ }
46
+
47
+ /** The project's forge, from its `origin` remote; null without one it knows. */
48
+ export function detect(dir: string): Forge | null {
49
+ let url: string
50
+ try {
51
+ url = execFileSync('git', ['remote', 'get-url', 'origin'], {
52
+ cwd: dir,
53
+ encoding: 'utf8',
54
+ stdio: ['ignore', 'pipe', 'ignore'],
55
+ })
56
+ } catch {
57
+ return null
58
+ }
59
+ const remote = parseRemote(url)
60
+ const kind = remote && kindOf(remote.host)
61
+ return remote && kind ? { kind, ...remote } : null
62
+ }
63
+
64
+ export interface ForgeOptions {
65
+ /** the repository's path on its host: `owner/repo`, `group/subgroup/project` */
66
+ repo?: string
67
+ /** github.com, gitlab.com, or a self-hosted GitLab's host */
68
+ host?: string
69
+ kind?: ForgeKind
70
+ }
71
+
72
+ export default function forge(options: ForgeOptions = {}): Plugin {
73
+ return definePlugin({
74
+ name: 'forge',
75
+ links({ dir }) {
76
+ const found = detect(dir)
77
+ const host = options.host ?? found?.host
78
+ const repo = options.repo ?? found?.repo
79
+ const kind = options.kind ?? (options.host ? kindOf(options.host) : null) ?? found?.kind
80
+ return host && repo && kind ? forgeLinks({ kind, host, repo }) : []
81
+ },
82
+ docs: () => fs.readFileSync(new URL('./README.md', import.meta.url), 'utf8'),
83
+ })
84
+ }
@@ -0,0 +1,126 @@
1
+ A named form, written as markdown. Submitting it appends
2
+ `{ id, ts, page, type, action, data }` to the events log, where `type` is the
3
+ form's `name`, `action` is the button that was pressed and `data` holds the
4
+ inputs. The form starts from its last answer. A link to it is `#form:<name>`; a
5
+ second form with the same name on a page gets no link and says so. A name has
6
+ no `:` (those are event types') and no `/` (those are forms in a chat message,
7
+ `<chat>/<name>`: see the chat plugin).
8
+
9
+ The body of `:::form{name=…}` is ordinary markdown, and inputs are inline
10
+ directives that can sit anywhere in it: in a paragraph, a list, a table
11
+ cell, a heading, a grid card. So a question sits with everything that
12
+ explains it.
13
+
14
+ | input | written as | sends |
15
+ | --- | --- | --- |
16
+ | one choice | `:radio[This week]{name=when}` per option | the picked label's text, or `null` |
17
+ | an answer not on the list | `:radio[Other]{name=when other}` (or `:checkbox[…]{… other}`) | what the reader typed in its box |
18
+ | several choices | `:checkbox[Android]{name=phones}` per option | an array of the checked labels |
19
+ | one checkbox | `:checkbox[I read it]{name=read}` | `true` or `false` |
20
+ | text | `:text[Title]{name=title placeholder="a short name"}` | the text |
21
+ | more text | `:textarea[Notes]{name=notes}` | the text |
22
+ | number, date, range | `:number[Count]{name=count min=0 max=10}`, `:date[Due]{name=due}`, `:range[…]{name=… min=0 max=100}` | the value |
23
+ | dropdown | `:select[Target]{name=env options="staging, production"}` | the picked option |
24
+ | fixed value | `:hidden{name=version value=2.3}` | the value |
25
+ | buttons | `:button[Approve]` `:button[Hold]` | which one is `action` |
26
+
27
+ - The label in `[…]` is markdown. An option sends its label as plain text
28
+ (`:radio[This **week**]` sends `This week`), unless `value=…` says what
29
+ to send instead.
30
+ - `other` makes an option for an answer not on the list: it has a text box,
31
+ typing in it picks the option, and it sends what was typed (`placeholder`
32
+ says what goes in the box). Prefer it to a separate free-text field.
33
+ - `recommended` tags an option as the writer's recommendation; it is never
34
+ preselected, so a choice is only made by picking it. `checked` does
35
+ preselect one; use it for defaults, not for decisions.
36
+ - Without a `:button`, the form gets one `Send` button. The first button is
37
+ the primary one.
38
+ - `value=…` on `:text`, `:textarea`, `:select` and the others sets what
39
+ they start with.
40
+
41
+ **Options with what they mean.** When the options of a decision need
42
+ explaining, put each one at the start of a list item, with its explanation
43
+ under it. Such an item reads as a row to pick:
44
+
45
+ ````markdown
46
+ :::form{name=storage}
47
+ **Where are answers kept?**
48
+
49
+ - :radio[One log per project]{name=where recommended}
50
+ Simple, and the agent waits on one file.
51
+ - :radio[One log per page]{name=where}
52
+ Pages can be moved with their answers.
53
+ - :radio[Somewhere else]{name=where other placeholder="where?"}
54
+ :::
55
+ ````
56
+
57
+ :::form{name=storage}
58
+ **Where are answers kept?**
59
+
60
+ - :radio[One log per project]{name=where recommended}
61
+ Simple, and the agent waits on one file.
62
+ - :radio[One log per page]{name=where}
63
+ Pages can be moved with their answers.
64
+ - :radio[Somewhere else]{name=where other placeholder="where?"}
65
+ :::
66
+
67
+ An option's explanation can be any markdown: a code block, a table, a
68
+ picture, a `:::details` block. Indent it under the item, and mind the
69
+ colons: a container inside the form needs fewer colons than the form, so
70
+ write the form as `::::form` around a `:::details`.
71
+
72
+ **Inputs anywhere.** Since an input is a word-sized element, any layout
73
+ can hold one: a card per option in a grid, a checkbox per row of a table.
74
+
75
+ `````markdown
76
+ :::::form{name=deploy-review}
77
+ Ship **v2.3** to production?
78
+
79
+ ::::grid{cols=2}
80
+ :::item[:radio[Staging]{name=env}]
81
+ Runs the migration on a copy first.
82
+ :::
83
+
84
+ :::item[:radio[Production]{name=env recommended}]
85
+ The migration is reversible.
86
+ :::
87
+ ::::
88
+
89
+ :button[Approve] :button[Hold]
90
+ :::::
91
+ `````
92
+
93
+ :::::form{name=deploy-review}
94
+ Ship **v2.3** to production?
95
+
96
+ ::::grid{cols=2}
97
+ :::item[:radio[Staging]{name=env}]
98
+ Runs the migration on a copy first.
99
+ :::
100
+
101
+ :::item[:radio[Production]{name=env recommended}]
102
+ The migration is reversible.
103
+ :::
104
+ ::::
105
+
106
+ :button[Approve] :button[Hold]
107
+ :::::
108
+
109
+ **A form as a card.** A form's label is its title, `:::form[Title]{name=…}`.
110
+ Directly in a grid, tabs or a timeline, a form is an item as it is, the
111
+ label its title: in a grid the form is the card, not a card around a form.
112
+
113
+ Forms don't nest, and inputs belong inside a form: outside one they show
114
+ but send nothing.
115
+
116
+ **A chat under every form.** The reader can ask about a question without
117
+ answering it: under every form is a chat (see the chat plugin), named
118
+ after the form, whose messages are never a submit, so talking about a choice
119
+ never makes it. Answer there with `workpad append --type chat:message
120
+ --data '{"chat":"<form name>","text":"…"}'`, and don't add a free-text field
121
+ for questions to a decision form. A form that asks nothing to talk about (a
122
+ lone button that starts something) can leave its chat out:
123
+ `:::form{name=start chat=false}`.
124
+
125
+ A hand-written `<form name="…">` (no `action` attribute) is recorded the same
126
+ way; this block only saves typing.