@dexhq/canvas 0.13.0 → 0.15.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 (341) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +21 -18
  3. package/app/canvas/activity.tsx +8 -15
  4. package/app/canvas/anchoring.ts +3 -5
  5. package/app/canvas/canvas-input.ts +151 -14
  6. package/app/canvas/canvas-keys.ts +9 -0
  7. package/app/canvas/canvas-model.ts +5 -42
  8. package/app/canvas/canvas-panels.ts +1 -17
  9. package/app/canvas/canvas-scene.ts +7 -3
  10. package/app/canvas/canvas-ui.ts +2 -1
  11. package/app/canvas/canvas.css +61 -26
  12. package/app/canvas/change-notice.tsx +10 -1
  13. package/app/canvas/comment-layer.tsx +2 -1
  14. package/app/canvas/comments.tsx +204 -82
  15. package/app/canvas/element-picker.ts +200 -27
  16. package/app/canvas/engine/canvas-gestures.ts +72 -17
  17. package/app/canvas/engine/canvas-store.ts +17 -1
  18. package/app/canvas/engine/engine.css +6 -3
  19. package/app/canvas/find-bar.tsx +817 -0
  20. package/app/canvas/find-model.ts +135 -0
  21. package/app/canvas/flow-canvas.tsx +18 -2
  22. package/app/canvas/follow-pin.ts +26 -6
  23. package/app/canvas/frame-node.tsx +43 -26
  24. package/app/canvas/imported-reviews.tsx +12 -22
  25. package/app/canvas/layout.ts +27 -0
  26. package/app/canvas/live-page.ts +142 -19
  27. package/app/canvas/page-find.ts +220 -0
  28. package/app/canvas/page-style.ts +23 -0
  29. package/app/canvas/section-node.tsx +2 -0
  30. package/app/canvas/spec-threads.ts +24 -23
  31. package/app/canvas/thread-focus.tsx +14 -12
  32. package/app/canvas/tool-cursors.ts +16 -16
  33. package/app/canvas/use-activity.ts +0 -8
  34. package/app/canvas/use-agent-changes.tsx +34 -40
  35. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  36. package/app/canvas/xray.ts +3 -12
  37. package/app/frame.tsx +5 -0
  38. package/app/i18n/locales/en/messages.po +114 -12
  39. package/app/i18n/locales/en/messages.ts +1 -1
  40. package/app/i18n/locales/pseudo/messages.po +114 -12
  41. package/app/i18n/locales/pseudo/messages.ts +1 -1
  42. package/app/icons/{sets/lucide.tsx → glyphs.tsx} +7 -5
  43. package/app/icons/index.tsx +3 -3
  44. package/app/icons/types.ts +3 -10
  45. package/app/index.html +3 -3
  46. package/app/main.tsx +3 -0
  47. package/app/pages/canvas-settings.tsx +35 -0
  48. package/app/pages/canvas.tsx +27 -8
  49. package/app/pages/commands-settings.tsx +16 -2
  50. package/app/shell/about.tsx +5 -4
  51. package/app/shell/feedback-details.ts +0 -3
  52. package/app/shell/feedback-form.tsx +10 -21
  53. package/app/shell/feedback-link.tsx +2 -1
  54. package/app/shell/instructions-editor.tsx +1 -1
  55. package/app/shell/presence-style.ts +59 -0
  56. package/app/shell/presence.tsx +6 -3
  57. package/app/shell/scaled-frame.tsx +21 -9
  58. package/app/shell/settings-sections.ts +12 -0
  59. package/app/shell/sidebar.tsx +1 -1
  60. package/app/studio-ui.d.ts +0 -9
  61. package/app/types.ts +21 -205
  62. package/app/ui/file-drop.ts +128 -0
  63. package/app/ui/prompt-editor.tsx +1 -1
  64. package/app/ui/shadcn/input-group.tsx +2 -2
  65. package/dist/cli/banner.d.mts +4 -2
  66. package/dist/cli/banner.mjs +34 -11
  67. package/dist/cli/commands/app.mjs +19 -11
  68. package/dist/cli/commands/create.d.mts +26 -14
  69. package/dist/cli/commands/create.mjs +13 -7
  70. package/dist/cli/commands/dev.mjs +2 -3
  71. package/dist/cli/commands/hook.mjs +2 -1
  72. package/dist/cli/commands/init.d.mts +11 -6
  73. package/dist/cli/help.d.mts +1 -1
  74. package/dist/cli/help.mjs +3 -3
  75. package/dist/cli/main.d.mts +22 -12
  76. package/dist/config/index.d.mts +6 -5
  77. package/dist/config/project-files.d.mts +6 -3
  78. package/dist/config/project-files.mjs +14 -5
  79. package/dist/config/renamed.d.mts +0 -2
  80. package/dist/config/renamed.mjs +1 -3
  81. package/dist/config/schema.d.mts +0 -5
  82. package/dist/config/schema.mjs +0 -5
  83. package/dist/content/capture.d.mts +2 -2
  84. package/dist/content/capture.mjs +2 -2
  85. package/dist/content/content.d.mts +3 -141
  86. package/dist/content/content.mjs +7 -65
  87. package/dist/content/flow-specs.mjs +1 -1
  88. package/dist/content/prototype-summary.d.mts +3 -39
  89. package/dist/content/prototype-summary.mjs +2 -3
  90. package/dist/content/prototypes.mjs +1 -1
  91. package/dist/content/snapshot-client.mjs +1 -1
  92. package/dist/content/text-replace.d.mts +30 -0
  93. package/dist/content/text-replace.mjs +309 -0
  94. package/dist/content/thread-module.mjs +1 -1
  95. package/dist/content/threads.mjs +1 -1
  96. package/dist/paths.d.mts +0 -2
  97. package/dist/paths.mjs +1 -3
  98. package/dist/server/agent-env.d.mts +5 -1
  99. package/dist/server/agent-env.mjs +7 -2
  100. package/dist/server/agent-session.d.mts +14 -1
  101. package/dist/server/agent-session.mjs +84 -19
  102. package/dist/server/brief.mjs +3 -3
  103. package/dist/server/build-pictures.mjs +1 -1
  104. package/dist/server/channel.d.mts +19 -24
  105. package/dist/server/channel.mjs +70 -37
  106. package/dist/server/claimed-presence.d.mts +18 -0
  107. package/dist/server/claimed-presence.mjs +58 -0
  108. package/dist/server/close-check.mjs +2 -2
  109. package/dist/server/comments/actions.d.mts +153 -0
  110. package/dist/server/comments/actions.mjs +154 -0
  111. package/dist/server/comments/routes.d.mts +25 -0
  112. package/dist/server/comments/routes.mjs +88 -0
  113. package/dist/server/comments/tools.d.mts +6 -0
  114. package/dist/server/comments/tools.mjs +154 -0
  115. package/dist/server/dev-server.mjs +36 -13
  116. package/dist/server/file-errors.d.mts +7 -2
  117. package/dist/server/file-errors.mjs +31 -8
  118. package/dist/server/file-lock.d.mts +2 -2
  119. package/dist/server/file-lock.mjs +130 -36
  120. package/dist/server/mcp.d.mts +0 -2
  121. package/dist/server/mcp.mjs +7 -8
  122. package/dist/server/me.d.mts +1 -1
  123. package/dist/server/open-page.d.mts +22 -0
  124. package/dist/server/open-page.mjs +20 -2
  125. package/dist/server/outcome.d.mts +22 -0
  126. package/dist/server/outcome.mjs +8 -0
  127. package/dist/server/own-copies.mjs +2 -2
  128. package/dist/server/people.d.mts +1 -1
  129. package/dist/server/port.d.mts +12 -0
  130. package/dist/server/port.mjs +66 -14
  131. package/dist/server/presence.d.mts +4 -1
  132. package/dist/server/presence.mjs +2 -2
  133. package/dist/server/requests.d.mts +5 -1
  134. package/dist/server/requests.mjs +32 -47
  135. package/dist/server/studio-for.d.mts +5 -0
  136. package/dist/server/studio-for.mjs +18 -4
  137. package/dist/server/sync-install.d.mts +8 -12
  138. package/dist/server/sync-install.mjs +12 -30
  139. package/dist/server/thread-source.mjs +2 -2
  140. package/dist/server/tools/describe.d.mts +1 -1
  141. package/dist/server/tools/describe.mjs +1 -1
  142. package/dist/server/tools/feedback.d.mts +1 -1
  143. package/dist/server/tools/reading.mjs +13 -4
  144. package/dist/server/tools/show.d.mts +1 -1
  145. package/dist/server/tools/snapshot.d.mts +1 -1
  146. package/dist/server/tools/thread-list.mjs +1 -1
  147. package/dist/server/tools/watch.mjs +5 -3
  148. package/dist/server/vite.mjs +28 -31
  149. package/dist/server/web-app.mjs +7 -10
  150. package/dist/server/work-groups.mjs +1 -1
  151. package/dist/setup/apply.mjs +8 -14
  152. package/dist/setup/create.d.mts +4 -2
  153. package/dist/setup/create.mjs +118 -36
  154. package/dist/setup/design-system-checks.mjs +3 -12
  155. package/dist/setup/desktop-app-script.mjs +4 -3
  156. package/dist/setup/desktop-app-start.d.mts +8 -2
  157. package/dist/setup/desktop-app-start.mjs +64 -29
  158. package/dist/setup/desktop-app.d.mts +8 -0
  159. package/dist/setup/desktop-app.mjs +20 -4
  160. package/dist/setup/detect.d.mts +14 -7
  161. package/dist/setup/detect.mjs +56 -10
  162. package/dist/setup/doctor.mjs +2 -4
  163. package/dist/setup/existing-setup.d.mts +1 -3
  164. package/dist/setup/existing-setup.mjs +10 -11
  165. package/dist/setup/migrate/row-titles.mjs +1 -1
  166. package/dist/setup/own-app.d.mts +1 -2
  167. package/dist/setup/own-app.mjs +4 -5
  168. package/dist/setup/plan.d.mts +8 -6
  169. package/dist/setup/plan.mjs +64 -48
  170. package/dist/setup/project.d.mts +6 -17
  171. package/dist/setup/project.mjs +17 -61
  172. package/dist/setup/prompts.d.mts +5 -5
  173. package/dist/setup/prompts.mjs +28 -61
  174. package/dist/setup/questions.d.mts +12 -4
  175. package/dist/setup/questions.mjs +10 -25
  176. package/dist/setup/starters.d.mts +2 -0
  177. package/dist/setup/starters.mjs +26 -9
  178. package/dist/setup/workspace-setup.d.mts +1 -2
  179. package/dist/setup/workspace-setup.mjs +4 -6
  180. package/dist/setup/write.d.mts +15 -5
  181. package/dist/setup/write.mjs +35 -9
  182. package/dist/shared/annotations-core.mjs +1 -1
  183. package/dist/shared/canvas-core.mjs +1 -1
  184. package/dist/shared/canvas-file.d.mts +201 -0
  185. package/dist/shared/canvas-file.mjs +1 -0
  186. package/dist/shared/comments/routes.d.mts +53 -0
  187. package/dist/shared/comments/routes.mjs +37 -0
  188. package/dist/shared/feedback.d.mts +8 -0
  189. package/dist/shared/feedback.mjs +10 -2
  190. package/dist/shared/page-review.d.mts +2 -11
  191. package/dist/shared/page-review.mjs +4 -13
  192. package/dist/shared/presence-core.d.mts +11 -0
  193. package/dist/shared/presence-core.mjs +11 -2
  194. package/dist/shared/review-file.d.mts +5 -0
  195. package/dist/shared/review-file.mjs +23 -13
  196. package/dist/shared/server-page.mjs +7 -1
  197. package/dist/shared/signup.d.mts +2 -5
  198. package/dist/shared/signup.mjs +2 -35
  199. package/dist/shared/studio-events.d.mts +0 -6
  200. package/dist/shared/studio-events.mjs +1 -5
  201. package/dist/shared/studio-files.d.mts +12 -0
  202. package/dist/shared/studio-files.mjs +6 -1
  203. package/dist/shared/studio-routes.d.mts +16 -62
  204. package/dist/shared/studio-routes.mjs +1 -69
  205. package/dist/shared/threads-core.d.mts +2 -2
  206. package/dist/shared/threads-core.mjs +1 -1
  207. package/extension/dist/feedback.js +148 -138
  208. package/extension/dist/manifest.json +1 -1
  209. package/extension/dist/picker.js +146 -136
  210. package/package.json +3 -20
  211. package/src/cli/banner.ts +45 -11
  212. package/src/cli/commands/app.ts +23 -8
  213. package/src/cli/commands/create.ts +17 -9
  214. package/src/cli/commands/dev.ts +0 -3
  215. package/src/cli/commands/hook.ts +4 -1
  216. package/src/cli/help.ts +3 -3
  217. package/src/config/index.ts +6 -5
  218. package/src/config/project-files.ts +21 -11
  219. package/src/config/renamed.ts +0 -3
  220. package/src/config/schema.ts +0 -1
  221. package/src/content/capture.ts +6 -12
  222. package/src/content/content.ts +7 -244
  223. package/src/content/flow-specs.ts +2 -1
  224. package/src/content/prototype-summary.ts +4 -44
  225. package/src/content/review-pages.ts +2 -1
  226. package/src/content/snapshot-client.ts +1 -1
  227. package/src/content/text-replace.ts +449 -0
  228. package/src/paths.ts +0 -8
  229. package/src/server/agent-env.ts +12 -2
  230. package/src/server/agent-session.ts +124 -34
  231. package/src/server/brief.ts +8 -3
  232. package/src/server/channel.ts +121 -52
  233. package/src/server/claimed-presence.ts +93 -0
  234. package/src/server/comments/actions.ts +352 -0
  235. package/src/server/comments/routes.ts +176 -0
  236. package/src/server/comments/tools.ts +317 -0
  237. package/src/server/dev-server.ts +49 -15
  238. package/src/server/file-errors.ts +47 -13
  239. package/src/server/file-lock.ts +205 -54
  240. package/src/server/mcp.ts +13 -14
  241. package/src/server/me.ts +2 -5
  242. package/src/server/open-page.ts +54 -4
  243. package/src/server/outcome.ts +26 -0
  244. package/src/server/people.ts +2 -1
  245. package/src/server/port.ts +94 -20
  246. package/src/server/presence.ts +11 -3
  247. package/src/server/requests.ts +60 -70
  248. package/src/server/studio-for.ts +27 -3
  249. package/src/server/sync-install.ts +35 -26
  250. package/src/server/thread-place.ts +2 -4
  251. package/src/server/tools/reading.ts +16 -3
  252. package/src/server/tools/watch.ts +7 -7
  253. package/src/server/vite.ts +37 -40
  254. package/src/server/web-app.ts +14 -12
  255. package/src/setup/apply.ts +10 -16
  256. package/src/setup/create.ts +143 -37
  257. package/src/setup/design-system-checks.ts +7 -15
  258. package/src/setup/desktop-app-script.ts +4 -3
  259. package/src/setup/desktop-app-start.ts +94 -26
  260. package/src/setup/desktop-app.ts +24 -3
  261. package/src/setup/detect.ts +56 -14
  262. package/src/setup/doctor.ts +4 -4
  263. package/src/setup/existing-setup.ts +10 -12
  264. package/src/setup/own-app.ts +2 -5
  265. package/src/setup/plan.ts +93 -84
  266. package/src/setup/project.ts +25 -118
  267. package/src/setup/prompts.ts +44 -127
  268. package/src/setup/questions.ts +27 -29
  269. package/src/setup/starters.ts +35 -10
  270. package/src/setup/workspace-setup.ts +8 -18
  271. package/src/setup/write.ts +52 -9
  272. package/src/shared/canvas-file.ts +205 -0
  273. package/src/shared/comments/routes.ts +79 -0
  274. package/src/shared/feedback.ts +14 -4
  275. package/src/shared/page-review.ts +11 -16
  276. package/src/shared/presence-core.ts +16 -2
  277. package/src/shared/review-file.ts +28 -12
  278. package/src/shared/server-page.ts +11 -1
  279. package/src/shared/signup.ts +4 -28
  280. package/src/shared/studio-events.ts +0 -13
  281. package/src/shared/studio-files.ts +14 -0
  282. package/src/shared/studio-routes.ts +21 -64
  283. package/src/shared/threads-core.ts +2 -2
  284. package/templates/methods/review.md +2 -2
  285. package/templates/rules/canvas-frames.md +104 -0
  286. package/templates/rules/canvas.md +8 -142
  287. package/templates/rules/prototypes.md +1 -1
  288. package/templates/rules/snapshots.md +52 -0
  289. package/templates/starters/standalone/README.md +7 -7
  290. package/templates/starters/standalone/components.json +1 -1
  291. package/templates/starters/standalone/package.json +1 -2
  292. package/templates/starters/turborepo/README.md +6 -6
  293. package/templates/starters/turborepo/apps/web/components.json +1 -1
  294. package/templates/starters/turborepo/apps/web/package.json +1 -2
  295. package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
  296. package/templates/starters/turborepo/packages/ui/components.json +1 -1
  297. package/templates/starters/turborepo/packages/ui/package.json +1 -2
  298. package/templates/starters/vite/README.md +7 -6
  299. package/templates/starters/vite/components.json +1 -1
  300. package/templates/starters/vite/package.json +1 -2
  301. package/templates/starters/vite/src/app.tsx +3 -4
  302. package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
  303. package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
  304. package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
  305. package/templates/starters/vite/src/components/ui/button.tsx +17 -12
  306. package/templates/starters/vite/src/components/ui/card.tsx +1 -1
  307. package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
  308. package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
  309. package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
  310. package/templates/starters/vite/src/components/ui/field.tsx +3 -1
  311. package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
  312. package/templates/starters/vite/src/components/ui/input.tsx +1 -1
  313. package/templates/starters/vite/src/components/ui/label.tsx +2 -0
  314. package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
  315. package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
  316. package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
  317. package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
  318. package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
  319. package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
  320. package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
  321. package/templates/starters/vite/src/index.css +533 -111
  322. package/app/icons/sets/hugeicons.tsx +0 -259
  323. package/app/icons/sets/phosphor.tsx +0 -251
  324. package/dist/server/icon-set.d.mts +0 -15
  325. package/dist/server/icon-set.mjs +0 -31
  326. package/dist/server/tools/close-reply.d.mts +0 -6
  327. package/dist/server/tools/close-reply.mjs +0 -138
  328. package/dist/server/tools/comment.d.mts +0 -6
  329. package/dist/server/tools/comment.mjs +0 -49
  330. package/dist/shared/icon-sets.d.mts +0 -9
  331. package/dist/shared/icon-sets.mjs +0 -21
  332. package/src/server/icon-set.ts +0 -56
  333. package/src/server/tools/close-reply.ts +0 -271
  334. package/src/server/tools/comment.ts +0 -96
  335. package/src/shared/icon-sets.ts +0 -23
  336. /package/app/public/{sudio-192.png → dex-192.png} +0 -0
  337. /package/app/public/{sudio-512.png → dex-512.png} +0 -0
  338. /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
  339. /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
  340. /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
  341. /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
@@ -0,0 +1,205 @@
1
+ // canvas.json: the frames, rows and sections of a prototype's canvas, as
2
+ // people/<person>/canvas.json has them and the studio reads them. The one
3
+ // declaration the commands, the server and the interface all use;
4
+ // canvas-core.ts has the rules that check one. Types only, so the browser can
5
+ // use it too.
6
+
7
+ import type { CanvasPoint, SlideLayout, Viewport } from "./canvas-core.ts";
8
+ import type { FrameGrid, FrameGuide } from "./frame-grids.ts";
9
+ import type { Sketch } from "./sketch-core.ts";
10
+
11
+ interface FrameBase {
12
+ /**
13
+ * On a column's first frame: the id of a frame stacked further down a
14
+ * column to its left, in its row, for this column to start level with
15
+ * rather than at the row's top.
16
+ */
17
+ beside?: string;
18
+ id: string;
19
+ /**
20
+ * The step this frame shows, counted from 1: its column on the canvas. Leave
21
+ * out to follow the previous frame in the row.
22
+ */
23
+ step?: number;
24
+ title?: string;
25
+ /**
26
+ * Which frame this is, for good: kept when it moves or is renamed, new on
27
+ * a copy. Picks follow it. Given to the saver's frames that have none when
28
+ * they save.
29
+ */
30
+ uid?: string;
31
+ /**
32
+ * Stacked directly below the frame before it in its row, in that frame's
33
+ * column, rather than in a column of its own.
34
+ */
35
+ under?: true;
36
+ }
37
+
38
+ /** A live, interactive render of one of the prototype's views. */
39
+ export interface ViewFrame extends FrameBase {
40
+ doc?: undefined;
41
+ /** The frame's own grids, shown in place of the canvas's (Figma's, pasted). */
42
+ grids?: FrameGrid[];
43
+ /** Guide lines on the frame. */
44
+ guides?: FrameGuide[];
45
+ params?: Record<string, string>;
46
+ /** A fixed size in pixels, for a snapshot of one element; else the viewport's. */
47
+ size?: { height: number; width: number };
48
+ sketch?: undefined;
49
+ /**
50
+ * Where a snapshot was captured from, and when; and the image it is, when
51
+ * it is one, in the prototype's folder: "images/….png".
52
+ */
53
+ snapshot?: { captured: string; image?: string; url: string };
54
+ spec?: undefined;
55
+ view: string;
56
+ viewport?: Viewport;
57
+ }
58
+
59
+ /** A markdown document from the prototype's docs folder. */
60
+ export interface DocFrame extends FrameBase {
61
+ doc: string;
62
+ /** A size of its own in pixels, set by resizing it; else 640 by 900. */
63
+ size?: { height: number; width: number };
64
+ sketch?: undefined;
65
+ spec?: undefined;
66
+ view?: undefined;
67
+ }
68
+
69
+ /**
70
+ * A spec, edited in place on the canvas: a markdown file in its placer's
71
+ * folder. In a section, it is that section's spec; outside any section, it is part
72
+ * of the file spec.
73
+ */
74
+ export interface SpecFrame extends FrameBase {
75
+ doc?: undefined;
76
+ /**
77
+ * A slide's layout: its first frame beside its words (the default), or
78
+ * centred above them. Only a slide (people/<person>/slides/) has one.
79
+ */
80
+ layout?: SlideLayout;
81
+ /**
82
+ * A width of its own in pixels, set by resizing it; else 520. With a
83
+ * height, it is never taller than that, and scrolls; without one, it is
84
+ * as tall as its words (never less than 240). A slide's is fixed, both
85
+ * ways: 1920 by 1080 until resized.
86
+ */
87
+ size?: { height?: number; width: number };
88
+ sketch?: undefined;
89
+ /** Its file, from the file's folder: "people/ana/specs/checkout.md". */
90
+ spec: string;
91
+ view?: undefined;
92
+ }
93
+
94
+ export interface SketchFrame extends FrameBase {
95
+ doc?: undefined;
96
+ sketch: Sketch;
97
+ spec?: undefined;
98
+ /** Required, as an older Dex names a frame by its title or view. */
99
+ title: string;
100
+ view?: undefined;
101
+ }
102
+
103
+ declare const readFromDisk: unique symbol;
104
+
105
+ /**
106
+ * A frame this Dex cannot show: a kind from a newer Dex, or a mistake.
107
+ * Only reading a canvas makes one, so Dex never writes a frame that shows
108
+ * nothing.
109
+ */
110
+ export interface UnknownFrame extends FrameBase {
111
+ doc?: undefined;
112
+ sketch?: undefined;
113
+ spec?: undefined;
114
+ view?: undefined;
115
+ readonly [readFromDisk]: true;
116
+ }
117
+
118
+ export type Frame =
119
+ | ViewFrame
120
+ | DocFrame
121
+ | SpecFrame
122
+ | SketchFrame
123
+ | UnknownFrame;
124
+
125
+ /**
126
+ * One pass through the section's steps: the main path, an error state, an
127
+ * alternative. Its frames are the steps, left to right.
128
+ */
129
+ export interface Row {
130
+ /**
131
+ * In a person's copy of someone else's section: the id of their row this one
132
+ * is shown under (people-core.ts).
133
+ */
134
+ after?: string;
135
+ /**
136
+ * Whose it is, when not its section's: someone's version of a row in
137
+ * another person's section. Set when the canvas is read, never written.
138
+ */
139
+ author?: string;
140
+ /** The id of the section in its author's file that keeps it. */
141
+ copy?: string;
142
+ frames: Frame[];
143
+ id: string;
144
+ title?: string;
145
+ }
146
+
147
+ /**
148
+ * A section. Rows below the first are iterations of it. With `at`, a frame of
149
+ * its own instead: one frame, drawn at that point, with no section around it.
150
+ */
151
+ export interface Section {
152
+ /** Where a frame of its own's top left corner is, in canvas pixels. */
153
+ at?: CanvasPoint;
154
+ /**
155
+ * Whose it is: the person whose people/<person>/canvas.json it is in. Set
156
+ * when the canvas is read, never written; only they change it.
157
+ */
158
+ author?: string;
159
+ /** The id of the section it is a copy of, shown right below it. */
160
+ copyOf?: string;
161
+ /** When it was added, as an ISO date. */
162
+ created?: string;
163
+ description?: string;
164
+ /** Whose section it was copied from, when it is a copy. */
165
+ from?: string;
166
+ id: string;
167
+ /**
168
+ * Where the section's area starts, its top left corner in canvas pixels,
169
+ * once someone has drawn it or dragged it there. None stacks it with the
170
+ * others, top to bottom.
171
+ */
172
+ position?: CanvasPoint;
173
+ rows: Row[];
174
+ /**
175
+ * The least size of a section's area, in canvas pixels, once someone has
176
+ * sized it or frames have left it: its frames still grow it, but it never
177
+ * shrinks below this.
178
+ */
179
+ size?: { height: number; width: number };
180
+ title: string;
181
+ }
182
+
183
+ /**
184
+ * canvas.json: sections stacked top to bottom, and frames of their own where
185
+ * they were drawn. In each section, steps run left to right and iterations
186
+ * (states, errors, alternatives) top to bottom.
187
+ */
188
+ export interface Canvas {
189
+ /**
190
+ * Set in a person's file once their frames have uids: from then on, a
191
+ * frame of theirs with none is new.
192
+ */
193
+ frameUids?: true;
194
+ /**
195
+ * Whose sections come first, as the canvas was read: each
196
+ * person by when they joined. Never saved.
197
+ */
198
+ people?: readonly string[];
199
+ sections: Section[];
200
+ /**
201
+ * Whose canvas.json has given its frames uids, as the canvas was read: a
202
+ * frame of theirs with none is new. Never saved.
203
+ */
204
+ uidsGiven?: readonly string[];
205
+ }
@@ -0,0 +1,79 @@
1
+ // The comment requests, as the interface and the server both know them:
2
+ // each one's name, the methods it takes, the body it takes, as the zod
3
+ // schema the server checks every request against, and what it answers to
4
+ // each. The list of every request and its types take them from here, so a
5
+ // comment request is declared once, in this file. The interface imports
6
+ // this module for its types alone, so zod never runs in the browser.
7
+ //
8
+ // Only a field's type is checked here. What a value may be (a target's
9
+ // kinds, the statuses, who a comment is for) is the thread rules'
10
+ // (threads-core.ts), which refuse it where it is kept.
11
+
12
+ import { z } from "zod";
13
+ import { isRecord } from "../checks.ts";
14
+ import type {
15
+ Sketch,
16
+ ThreadAudience,
17
+ ThreadStatus,
18
+ ThreadTarget,
19
+ ThreadWithPrototype,
20
+ } from "../threads-core.ts";
21
+
22
+ /** An object, of a type whose fields the thread rules check. */
23
+ const record = <T>(what: string) => z.custom<T>(isRecord, `Expected ${what}`);
24
+
25
+ /** Text, of a type whose words the thread rules check. */
26
+ const word = <T extends string>() =>
27
+ z.custom<T>((value) => typeof value === "string", "Expected text");
28
+
29
+ /**
30
+ * A comment to start: what it is on, its first message (left out with a
31
+ * wireframe), who it is for, and a wireframe for an agent to build.
32
+ */
33
+ export const NEW_COMMENT = z.object({
34
+ target: record<ThreadTarget>("what the comment is on, with its kind"),
35
+ body: z.string().optional(),
36
+ for: word<ThreadAudience>().optional(),
37
+ sketch: record<Sketch>("a wireframe").optional(),
38
+ });
39
+
40
+ /**
41
+ * A person's change to a comment, by its id: a reply, a status, who it is
42
+ * for, a reaction, an edit or removal of their own message (`on`, by its
43
+ * `at`), or a review's comment hidden from the published site.
44
+ */
45
+ export const COMMENT_CHANGE = z.object({
46
+ id: z.string(),
47
+ body: z.string().optional(),
48
+ edit: z.string().optional(),
49
+ for: word<ThreadAudience>().optional(),
50
+ hidden: z.boolean().optional(),
51
+ on: z.string().optional(),
52
+ react: z.string().optional(),
53
+ remove: z.boolean().optional(),
54
+ status: word<ThreadStatus>().optional(),
55
+ });
56
+
57
+ /**
58
+ * Each comment request, by name, and its answer to each method it takes.
59
+ * The query a request needs is in its comment.
60
+ */
61
+ export interface CommentAnswers {
62
+ /** ?slug= for one prototype's, or none for every one's. */
63
+ threads: { GET: ThreadWithPrototype[]; POST: ThreadWithPrototype };
64
+ }
65
+
66
+ /** The bodies they take, by request and method, as the schemas above check them. */
67
+ export interface CommentBodies {
68
+ /** A comment to start, or a change to one, by its id. */
69
+ threads: {
70
+ POST: z.input<typeof NEW_COMMENT> | z.input<typeof COMMENT_CHANGE>;
71
+ };
72
+ }
73
+
74
+ /** The comment requests and the methods each takes. */
75
+ export const COMMENT_ROUTES = {
76
+ threads: ["GET", "POST"],
77
+ } as const satisfies {
78
+ [Name in keyof CommentAnswers]: readonly (keyof CommentAnswers[Name])[];
79
+ };
@@ -259,11 +259,21 @@ export const sendFeedback = async (
259
259
  if (problems.length > 0) {
260
260
  return { ok: false, reason: "invalid", problems };
261
261
  }
262
+ return await postToRelay(url, toForm(feedback), fetch);
263
+ };
264
+
265
+ /**
266
+ * Post a form to a relay and read its answer: the tracker's id, or why not.
267
+ * A form, so a simple request with no preflight; sign-ups travel this way
268
+ * too (signup.ts). Never throws.
269
+ */
270
+ export const postToRelay = async (
271
+ url: string,
272
+ form: FormData,
273
+ fetch: NonNullable<SendOptions["fetch"]>
274
+ ): Promise<Exclude<Sent, { reason: "invalid" }>> => {
262
275
  try {
263
- const response = await fetch(url, {
264
- method: "POST",
265
- body: toForm(feedback),
266
- });
276
+ const response = await fetch(url, { method: "POST", body: form });
267
277
  if (response.ok) {
268
278
  // Sent only once the relay says what it filed it as.
269
279
  const { id } = (await response.json()) as { id?: unknown };
@@ -8,7 +8,12 @@
8
8
  // Browser-safe, so the import dialog can say what a file is first.
9
9
 
10
10
  import { isRecord, isText } from "./checks.ts";
11
- import { GUEST_NAME, isReviewFormat, REVIEW_VERSION } from "./review-file.ts";
11
+ import {
12
+ isReviewFormat,
13
+ REVIEW_VERSION,
14
+ type ReviewFile,
15
+ reviewHeader,
16
+ } from "./review-file.ts";
12
17
  import { THREAD_ID_RE } from "./threads-core.ts";
13
18
  import { unzip } from "./unzip.ts";
14
19
 
@@ -70,14 +75,13 @@ export interface ReviewPage {
70
75
  }
71
76
 
72
77
  /** A Markup review, checked. */
73
- export interface PageReviewFile {
78
+ export interface PageReviewFile
79
+ extends Pick<ReviewFile, "review" | "reviewer"> {
74
80
  /** The app it is of: its origin, unless its config names it. */
75
81
  app: string;
76
82
  /** The outline's tasks, in its order. */
77
83
  outline?: { tasks: { id: string; title: string }[] };
78
84
  pages: ReviewPage[];
79
- review: { completed?: string; created?: string; id: string; title: string };
80
- reviewer: { key: string; name: string };
81
85
  threads: PageComment[];
82
86
  }
83
87
 
@@ -204,8 +208,8 @@ export function parsePageReview(value: unknown): PageReviewAnswer {
204
208
  if (value.version !== REVIEW_VERSION) {
205
209
  return { problem: "newer" };
206
210
  }
207
- const { review, reviewer } = value;
208
- if (!(isText(review.id) && isText(reviewer.key) && isText(value.app))) {
211
+ const header = reviewHeader(value.review, value.reviewer);
212
+ if (!(header && isText(value.app))) {
209
213
  return { problem: "unreadable" };
210
214
  }
211
215
  const listed: unknown[] = Array.isArray(value.threads) ? value.threads : [];
@@ -220,16 +224,7 @@ export function parsePageReview(value: unknown): PageReviewAnswer {
220
224
  return {
221
225
  review: {
222
226
  app: value.app,
223
- review: {
224
- id: review.id,
225
- title: isText(review.title) ? review.title.trim() : "",
226
- ...(isText(review.created) ? { created: review.created } : {}),
227
- ...(isText(review.completed) ? { completed: review.completed } : {}),
228
- },
229
- reviewer: {
230
- key: reviewer.key,
231
- name: isText(reviewer.name) ? reviewer.name.trim() : GUEST_NAME,
232
- },
227
+ ...header,
233
228
  ...(outline ? { outline } : {}),
234
229
  threads,
235
230
  pages,
@@ -19,12 +19,26 @@ export interface PresenceEntry extends PresenceTarget {
19
19
  updated: string;
20
20
  }
21
21
 
22
+ /**
23
+ * The session a Claude Code sub-agent's marks are under: its agent's
24
+ * session, then its own id, so each sub-agent shows on its own.
25
+ */
26
+ export const workerSession = (session: string, agentId: string): string =>
27
+ `${session}/${agentId}`;
28
+
29
+ /** Whether marks under session `marked` are `session`'s own or its sub-agents'. */
30
+ export const underSession = (marked: string, session: string): boolean =>
31
+ marked === session || marked.startsWith(`${session}/`);
32
+
22
33
  /** How long an entry lasts after it was last marked. */
23
34
  export const PRESENCE_TTL_MS = 120_000;
24
35
 
36
+ /** When an entry ends, unless it is marked again first: as an epoch time. */
37
+ export const endsAt = (entry: { updated: string }): number =>
38
+ Date.parse(entry.updated) + PRESENCE_TTL_MS;
39
+
25
40
  /** The entries that have not expired at `now`. */
26
41
  export const freshPresence = <Entry extends { updated: string }>(
27
42
  entries: Entry[],
28
43
  now: number
29
- ): Entry[] =>
30
- entries.filter((entry) => now - Date.parse(entry.updated) < PRESENCE_TTL_MS);
44
+ ): Entry[] => entries.filter((entry) => now < endsAt(entry));
@@ -95,6 +95,31 @@ const commentOf = (value: unknown): ReviewComment | undefined => {
95
95
  };
96
96
  };
97
97
 
98
+ /**
99
+ * Who reviewed and which review, as a review file and a Markup review both
100
+ * keep them; undefined without the review's id and the reviewer's key.
101
+ */
102
+ export const reviewHeader = (
103
+ review: Record<string, unknown>,
104
+ reviewer: Record<string, unknown>
105
+ ): Pick<ReviewFile, "review" | "reviewer"> | undefined => {
106
+ if (!(isText(review.id) && isText(reviewer.key))) {
107
+ return;
108
+ }
109
+ return {
110
+ review: {
111
+ id: review.id,
112
+ title: isText(review.title) ? review.title.trim() : "",
113
+ ...(isText(review.created) ? { created: review.created } : {}),
114
+ ...(isText(review.completed) ? { completed: review.completed } : {}),
115
+ },
116
+ reviewer: {
117
+ key: reviewer.key,
118
+ name: isText(reviewer.name) ? reviewer.name.trim() : GUEST_NAME,
119
+ },
120
+ };
121
+ };
122
+
98
123
  /** A file's review, checked, or why it cannot be imported. */
99
124
  export function parseReviewFile(value: unknown): ReviewFileAnswer {
100
125
  if (
@@ -110,8 +135,8 @@ export function parseReviewFile(value: unknown): ReviewFileAnswer {
110
135
  if (value.version !== REVIEW_VERSION) {
111
136
  return { problem: "newer" };
112
137
  }
113
- const { review, reviewer } = value;
114
- if (!(isText(review.id) && isText(reviewer.key))) {
138
+ const header = reviewHeader(value.review, value.reviewer);
139
+ if (!header) {
115
140
  return { problem: "not-a-review" };
116
141
  }
117
142
  const listed: unknown[] = Array.isArray(value.threads) ? value.threads : [];
@@ -125,16 +150,7 @@ export function parseReviewFile(value: unknown): ReviewFileAnswer {
125
150
  return {
126
151
  review: {
127
152
  ...(isText(value.prototype) ? { prototype: value.prototype } : {}),
128
- review: {
129
- id: review.id,
130
- title: isText(review.title) ? review.title.trim() : "",
131
- ...(isText(review.created) ? { created: review.created } : {}),
132
- ...(isText(review.completed) ? { completed: review.completed } : {}),
133
- },
134
- reviewer: {
135
- key: reviewer.key,
136
- name: isText(reviewer.name) ? reviewer.name.trim() : GUEST_NAME,
137
- },
153
+ ...header,
138
154
  threads: read,
139
155
  },
140
156
  };
@@ -60,7 +60,8 @@ export const FAILURE_CAUSES: readonly { pattern: string; cause: string }[] = [
60
60
  "Its packages aren't installed in {project}. Install them, then try again.",
61
61
  },
62
62
  {
63
- pattern: "EADDRINUSE",
63
+ // Node's error, or Dex's own refusal (cli/banner.ts), which names it.
64
+ pattern: "EADDRINUSE|Port [0-9]+ is in use",
64
65
  cause: "Another program is using its port. Close it, then try again.",
65
66
  },
66
67
  {
@@ -340,6 +341,14 @@ setInterval(() => {
340
341
  }, CONFIG.inApp ? 500 : 2000);
341
342
  `;
342
343
 
344
+ /**
345
+ * The tab's icon, inlined, as this page shows while the server that serves
346
+ * app/public/dex-icon.svg is down. Drawn by scripts/studio-icons.mjs.
347
+ */
348
+ const ICON = `data:image/svg+xml,${encodeURIComponent(
349
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="24" height="24" rx="5.5" fill="#155dfc"/><path transform="translate(6.206 4.750) scale(0.3625)" fill="#ffffff" d="M0,10.13333l0,-10.13333h14.5c7.45773,0 13.96208,4.08187 17.4008,10.13333zM34.5,20c0,1.75052 -0.2249,3.44852 -0.64737,5.06667l-33.85263,0l0,-10.13333l33.85263,0c0.42247,1.61815 0.64737,3.31614 0.64737,5.06667zM31.9008,29.86667c-3.43872,6.05147 -9.94307,10.13333 -17.4008,10.13333h-14.5l0,-10.13333z"/></svg>'
350
+ )}`;
351
+
343
352
  /** The whole page, saying `options.state` first. */
344
353
  export const serverPage = (options: ServerPageOptions): string => {
345
354
  const name = escapeHtml(options.name);
@@ -354,6 +363,7 @@ export const serverPage = (options: ServerPageOptions): string => {
354
363
  <meta name="viewport" content="width=device-width, initial-scale=1">
355
364
  <meta name="color-scheme" content="light dark">
356
365
  <title>${name}</title>
366
+ <link rel="icon" href="${ICON}" type="image/svg+xml">
357
367
  <style>${STYLE}</style>
358
368
  </head>
359
369
  <body>
@@ -5,6 +5,8 @@
5
5
  //
6
6
  // Only what the person typed is sent, and only when they choose Send.
7
7
 
8
+ import { postToRelay, type SendOptions } from "./feedback.ts";
9
+
8
10
  /** Where sign-ups go: the relay on Dex's site. */
9
11
  export const SIGNUP_URL = "https://sudio-site.vercel.app/api/signup";
10
12
 
@@ -62,42 +64,16 @@ export type SignupSent =
62
64
  | { ok: true; id: string }
63
65
  | { ok: false; reason: "invalid" | "limited" | "unavailable" | "failed" };
64
66
 
65
- const TOO_MANY_REQUESTS = 429;
66
- const SERVICE_UNAVAILABLE = 503;
67
-
68
- export interface SignupSendOptions {
69
- fetch?: (url: string, init: RequestInit) => Promise<Response>;
70
- url?: string;
71
- }
72
-
73
67
  /** Send a sign-up to the relay, if it is ready; never throws. */
74
68
  export const sendSignup = async (
75
69
  signup: Signup,
76
- { fetch = globalThis.fetch, url = SIGNUP_URL }: SignupSendOptions = {}
70
+ { fetch = globalThis.fetch, url = SIGNUP_URL }: SendOptions = {}
77
71
  ): Promise<SignupSent> => {
78
72
  if (checkSignup(signup).length > 0) {
79
73
  return { ok: false, reason: "invalid" };
80
74
  }
81
- // A form, as feedback travels: a simple request, with no preflight.
82
75
  const form = new FormData();
83
76
  form.set("name", signup.name.trim());
84
77
  form.set("email", signup.email.trim());
85
- try {
86
- const response = await fetch(url, { method: "POST", body: form });
87
- if (response.ok) {
88
- const { id } = (await response.json()) as { id?: unknown };
89
- return typeof id === "string" && id
90
- ? { ok: true, id }
91
- : { ok: false, reason: "failed" };
92
- }
93
- if (response.status === TOO_MANY_REQUESTS) {
94
- return { ok: false, reason: "limited" };
95
- }
96
- if (response.status === SERVICE_UNAVAILABLE) {
97
- return { ok: false, reason: "unavailable" };
98
- }
99
- return { ok: false, reason: "failed" };
100
- } catch {
101
- return { ok: false, reason: "failed" };
102
- }
78
+ return await postToRelay(url, form, fetch);
103
79
  };
@@ -51,19 +51,6 @@ export interface ConnectedAgent {
51
51
  watching?: boolean;
52
52
  }
53
53
 
54
- /**
55
- * How an agent comes by new feedback: pushed to it as it is left, pushed
56
- * with nothing yet to say it arrives, or only when it is asked or watches.
57
- */
58
- export type Hearing = "pushed" | "unproven" | "asked";
59
-
60
- export const hearingOf = (agent: ConnectedAgent): Hearing => {
61
- if (agent.channel) {
62
- return "pushed";
63
- }
64
- return agent.unproven ? "unproven" : "asked";
65
- };
66
-
67
54
  export type StudioEvent =
68
55
  | { type: "presence"; presence: PresenceEntry[] }
69
56
  | { type: "canvas"; slug: string }
@@ -22,6 +22,20 @@ import {
22
22
  splitPrototypePath,
23
23
  } from "./prototypes-core.ts";
24
24
 
25
+ export const DISCIPLINES = ["product", "brand", "engineering"] as const;
26
+ export type Discipline = (typeof DISCIPLINES)[number];
27
+
28
+ /** A person who makes prototypes, from contributors.json. */
29
+ export interface Contributor {
30
+ discipline: Discipline;
31
+ /** Git user names that identify this person, so the agent knows who it is working for. */
32
+ git: string[];
33
+ /** Their GitHub username, for their avatar. */
34
+ github?: string;
35
+ name: string;
36
+ slug: string;
37
+ }
38
+
25
39
  /** Where each of the studio's own files is, relative to its content root. */
26
40
  export const STUDIO_FILES = {
27
41
  /** Who works in the studio, and the git users that are them. */