@dexhq/canvas 0.14.0 → 0.16.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 (451) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +5 -3
  3. package/app/canvas/activity-parts.tsx +50 -6
  4. package/app/canvas/activity.tsx +10 -18
  5. package/app/canvas/agent-changes.ts +18 -8
  6. package/app/canvas/anchoring.ts +15 -7
  7. package/app/canvas/canvas-context.tsx +6 -2
  8. package/app/canvas/canvas-input.ts +186 -14
  9. package/app/canvas/canvas-keys.ts +9 -0
  10. package/app/canvas/canvas-model.ts +7 -44
  11. package/app/canvas/canvas-panels.ts +1 -17
  12. package/app/canvas/canvas-scene.ts +250 -27
  13. package/app/canvas/canvas-ui.ts +13 -3
  14. package/app/canvas/canvas.css +147 -29
  15. package/app/canvas/change-notice.tsx +10 -1
  16. package/app/canvas/comment-layer.tsx +2 -1
  17. package/app/canvas/comments.tsx +270 -111
  18. package/app/canvas/element-link.ts +135 -0
  19. package/app/canvas/element-picker.ts +223 -27
  20. package/app/canvas/engine/canvas-gestures.ts +72 -17
  21. package/app/canvas/engine/canvas-store.ts +17 -1
  22. package/app/canvas/engine/engine.css +6 -3
  23. package/app/canvas/export-dialog.tsx +265 -0
  24. package/app/canvas/find-bar.tsx +817 -0
  25. package/app/canvas/find-model.ts +135 -0
  26. package/app/canvas/flow-canvas.tsx +83 -16
  27. package/app/canvas/follow-pin.ts +26 -6
  28. package/app/canvas/frame-context-menu.tsx +61 -7
  29. package/app/canvas/frame-node.tsx +19 -20
  30. package/app/canvas/imported-reviews.tsx +12 -22
  31. package/app/canvas/layout.ts +68 -22
  32. package/app/canvas/linked-element.tsx +196 -0
  33. package/app/canvas/live-page.ts +156 -19
  34. package/app/canvas/mentions.tsx +209 -0
  35. package/app/canvas/page-find.ts +220 -0
  36. package/app/canvas/page-style.ts +23 -0
  37. package/app/canvas/picked-box.tsx +21 -0
  38. package/app/canvas/removed-views-panel.tsx +4 -4
  39. package/app/canvas/request-node.tsx +151 -0
  40. package/app/canvas/review-panel.tsx +8 -3
  41. package/app/canvas/section-node.tsx +6 -133
  42. package/app/canvas/spec-margin.tsx +4 -1
  43. package/app/canvas/spec-threads.ts +24 -23
  44. package/app/canvas/teammates-layer.tsx +205 -0
  45. package/app/canvas/text-layer.tsx +103 -17
  46. package/app/canvas/thread-focus.tsx +14 -12
  47. package/app/canvas/tool-cursors.ts +7 -6
  48. package/app/canvas/tool-icons.tsx +24 -56
  49. package/app/canvas/typing.ts +12 -0
  50. package/app/canvas/use-activity.ts +0 -8
  51. package/app/canvas/use-agent-changes.tsx +40 -42
  52. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  53. package/app/canvas/use-canvas-editor.ts +4 -2
  54. package/app/canvas/xray.ts +3 -12
  55. package/app/export/player-model.ts +159 -0
  56. package/app/export/player.tsx +198 -0
  57. package/app/export.html +31 -0
  58. package/app/export.tsx +9 -0
  59. package/app/frame/announce-refreshes.ts +21 -0
  60. package/app/frame/start-frame.tsx +50 -0
  61. package/app/frame/view-loads.ts +161 -0
  62. package/app/frame/views.ts +13 -49
  63. package/app/frame.tsx +2 -33
  64. package/app/i18n/locales/en/messages.po +233 -14
  65. package/app/i18n/locales/en/messages.ts +1 -1
  66. package/app/i18n/locales/pseudo/messages.po +232 -13
  67. package/app/i18n/locales/pseudo/messages.ts +1 -1
  68. package/app/icons/dex-glyphs.tsx +219 -0
  69. package/app/icons/glyphs.tsx +80 -80
  70. package/app/kit/use-flow.ts +2 -1
  71. package/app/live/canvas-teammates.ts +90 -0
  72. package/app/live/studio-api.ts +30 -20
  73. package/app/main.tsx +3 -0
  74. package/app/pages/canvas.tsx +45 -14
  75. package/app/pages/commands-settings.tsx +17 -3
  76. package/app/pages/render.tsx +39 -11
  77. package/app/shell/bell.tsx +15 -5
  78. package/app/shell/feedback-form.tsx +10 -21
  79. package/app/shell/feedback-link.tsx +2 -1
  80. package/app/shell/presence.tsx +123 -26
  81. package/app/shell/scaled-frame.tsx +21 -9
  82. package/app/shell/thread-list.tsx +25 -8
  83. package/app/shell/working-on.tsx +35 -3
  84. package/app/types.ts +21 -205
  85. package/app/ui/file-drop.ts +128 -0
  86. package/app/ui/prompt-editor.tsx +39 -11
  87. package/app/ui/reference.tsx +21 -8
  88. package/app/ui/shadcn/input-group.tsx +2 -2
  89. package/bin/sudio.mjs +1 -1
  90. package/dist/cli/banner.d.mts +4 -2
  91. package/dist/cli/banner.mjs +34 -11
  92. package/dist/cli/commands/app.mjs +19 -11
  93. package/dist/cli/commands/create.d.mts +5 -5
  94. package/dist/cli/commands/create.mjs +4 -4
  95. package/dist/cli/commands/export.d.mts +40 -0
  96. package/dist/cli/commands/export.mjs +66 -0
  97. package/dist/cli/commands/hook.mjs +2 -1
  98. package/dist/cli/commands/init.d.mts +2 -2
  99. package/dist/cli/commands/upgrade.mjs +1 -1
  100. package/dist/cli/help.d.mts +1 -1
  101. package/dist/cli/help.mjs +13 -7
  102. package/dist/cli/main.d.mts +42 -5
  103. package/dist/cli/main.mjs +1 -0
  104. package/dist/config/load.mjs +14 -2
  105. package/dist/config/project-files.d.mts +11 -0
  106. package/dist/config/project-files.mjs +23 -2
  107. package/dist/config/renamed.d.mts +7 -2
  108. package/dist/config/renamed.mjs +13 -3
  109. package/dist/content/capture.d.mts +2 -2
  110. package/dist/content/capture.mjs +2 -2
  111. package/dist/content/commands.d.mts +11 -9
  112. package/dist/content/commands.mjs +22 -16
  113. package/dist/content/comments-log.mjs +2 -1
  114. package/dist/content/content.d.mts +13 -143
  115. package/dist/content/content.mjs +55 -76
  116. package/dist/content/element-words.d.mts +42 -0
  117. package/dist/content/element-words.mjs +112 -0
  118. package/dist/content/flow-specs.mjs +1 -1
  119. package/dist/content/hosted-person.d.mts +31 -0
  120. package/dist/content/hosted-person.mjs +68 -0
  121. package/dist/content/merge-rules.d.mts +5 -0
  122. package/dist/content/merge-rules.mjs +17 -1
  123. package/dist/content/prototype-summary.d.mts +3 -39
  124. package/dist/content/prototype-summary.mjs +2 -3
  125. package/dist/content/prototypes.mjs +1 -1
  126. package/dist/content/screenshot.mjs +9 -0
  127. package/dist/content/text-edit.d.mts +24 -14
  128. package/dist/content/text-edit.mjs +92 -81
  129. package/dist/content/text-replace.d.mts +30 -0
  130. package/dist/content/text-replace.mjs +285 -0
  131. package/dist/content/thread-module.d.mts +2 -4
  132. package/dist/content/thread-module.mjs +4 -5
  133. package/dist/content/threads.mjs +1 -1
  134. package/dist/paste/paste.mjs +1 -1
  135. package/dist/paths.d.mts +0 -2
  136. package/dist/paths.mjs +1 -3
  137. package/dist/server/agent-env.d.mts +5 -1
  138. package/dist/server/agent-env.mjs +7 -2
  139. package/dist/server/agent-session.d.mts +14 -1
  140. package/dist/server/agent-session.mjs +84 -19
  141. package/dist/server/agents.d.mts +10 -0
  142. package/dist/server/agents.mjs +21 -6
  143. package/dist/server/build-pictures.mjs +1 -1
  144. package/dist/server/canvas-presence.d.mts +22 -0
  145. package/dist/server/canvas-presence.mjs +160 -0
  146. package/dist/server/channel.d.mts +13 -24
  147. package/dist/server/channel.mjs +55 -37
  148. package/dist/server/claimed-presence.d.mts +3 -2
  149. package/dist/server/claimed-presence.mjs +15 -7
  150. package/dist/server/close-check.mjs +2 -2
  151. package/dist/server/command-settings.mjs +1 -1
  152. package/dist/server/comments/actions.d.mts +145 -0
  153. package/dist/server/comments/actions.mjs +146 -0
  154. package/dist/server/comments/routes.d.mts +25 -0
  155. package/dist/server/comments/routes.mjs +67 -0
  156. package/dist/server/comments/tools.d.mts +6 -0
  157. package/dist/server/comments/tools.mjs +154 -0
  158. package/dist/server/dev-server.mjs +59 -23
  159. package/dist/server/export/build.d.mts +15 -0
  160. package/dist/server/export/build.mjs +220 -0
  161. package/dist/server/export/page.d.mts +25 -0
  162. package/dist/server/export/page.mjs +40 -0
  163. package/dist/server/export/plugin.d.mts +31 -0
  164. package/dist/server/export/plugin.mjs +69 -0
  165. package/dist/server/export/run.d.mts +9 -0
  166. package/dist/server/export/run.mjs +61 -0
  167. package/dist/server/export/save.d.mts +7 -0
  168. package/dist/server/export/save.mjs +29 -0
  169. package/dist/server/file-lock.d.mts +2 -2
  170. package/dist/server/file-lock.mjs +130 -36
  171. package/dist/server/hosted.d.mts +8 -0
  172. package/dist/server/hosted.mjs +78 -0
  173. package/dist/server/live-mirror.mjs +66 -10
  174. package/dist/server/live.mjs +28 -1
  175. package/dist/server/mcp.d.mts +0 -2
  176. package/dist/server/mcp.mjs +9 -8
  177. package/dist/server/me.d.mts +3 -1
  178. package/dist/server/me.mjs +8 -2
  179. package/dist/server/notices.d.mts +1 -1
  180. package/dist/server/notices.mjs +1 -1
  181. package/dist/server/open-page.d.mts +22 -0
  182. package/dist/server/open-page.mjs +20 -2
  183. package/dist/server/outcome.d.mts +22 -0
  184. package/dist/server/outcome.mjs +8 -0
  185. package/dist/server/own-copies.mjs +1 -1
  186. package/dist/server/people.d.mts +8 -3
  187. package/dist/server/people.mjs +6 -2
  188. package/dist/server/pictures.d.mts +1 -1
  189. package/dist/server/pictures.mjs +2 -2
  190. package/dist/server/port.d.mts +12 -0
  191. package/dist/server/port.mjs +66 -14
  192. package/dist/server/prebundle.d.mts +32 -0
  193. package/dist/server/prebundle.mjs +115 -0
  194. package/dist/server/presence.d.mts +4 -1
  195. package/dist/server/presence.mjs +2 -2
  196. package/dist/server/problems.d.mts +8 -0
  197. package/dist/server/problems.mjs +13 -0
  198. package/dist/server/requests.d.mts +5 -1
  199. package/dist/server/requests.mjs +76 -78
  200. package/dist/server/source-stamp.d.mts +4 -3
  201. package/dist/server/source-stamp.mjs +60 -31
  202. package/dist/server/state.d.mts +19 -10
  203. package/dist/server/state.mjs +27 -18
  204. package/dist/server/studio-for.d.mts +5 -0
  205. package/dist/server/studio-for.mjs +17 -3
  206. package/dist/server/sync-install.d.mts +8 -12
  207. package/dist/server/sync-install.mjs +12 -30
  208. package/dist/server/thread-source.d.mts +8 -0
  209. package/dist/server/thread-source.mjs +25 -6
  210. package/dist/server/tools/describe.d.mts +1 -1
  211. package/dist/server/tools/describe.mjs +1 -1
  212. package/dist/server/tools/export.d.mts +5 -0
  213. package/dist/server/tools/export.mjs +35 -0
  214. package/dist/server/tools/feedback.d.mts +1 -1
  215. package/dist/server/tools/place-frame.mjs +16 -16
  216. package/dist/server/tools/reading.mjs +13 -4
  217. package/dist/server/tools/show.d.mts +1 -1
  218. package/dist/server/tools/snapshot.d.mts +1 -1
  219. package/dist/server/tools/thread-list.mjs +2 -2
  220. package/dist/server/tools/watch.mjs +5 -3
  221. package/dist/server/vite.d.mts +9 -4
  222. package/dist/server/vite.mjs +65 -63
  223. package/dist/server/web-app.mjs +4 -7
  224. package/dist/server/welcome.mjs +2 -1
  225. package/dist/server/work-groups.mjs +1 -1
  226. package/dist/setup/apply.d.mts +4 -0
  227. package/dist/setup/apply.mjs +5 -4
  228. package/dist/setup/create.d.mts +4 -2
  229. package/dist/setup/create.mjs +72 -22
  230. package/dist/setup/design-system-checks.mjs +3 -17
  231. package/dist/setup/desktop-app-script.mjs +4 -3
  232. package/dist/setup/desktop-app-start.d.mts +8 -2
  233. package/dist/setup/desktop-app-start.mjs +64 -29
  234. package/dist/setup/desktop-app.d.mts +8 -0
  235. package/dist/setup/desktop-app.mjs +19 -3
  236. package/dist/setup/detect/workspace.d.mts +10 -10
  237. package/dist/setup/detect/workspace.mjs +10 -12
  238. package/dist/setup/detect.d.mts +0 -2
  239. package/dist/setup/detect.mjs +1 -3
  240. package/dist/setup/doctor.d.mts +4 -1
  241. package/dist/setup/doctor.mjs +8 -6
  242. package/dist/setup/migrate/dex-folder.d.mts +61 -0
  243. package/dist/setup/migrate/dex-folder.mjs +544 -0
  244. package/dist/setup/migrate/files-folder.mjs +1 -1
  245. package/dist/setup/migrate/guides.mjs +1 -1
  246. package/dist/setup/migrate/migrations.mjs +4 -0
  247. package/dist/setup/migrate/row-titles.mjs +1 -1
  248. package/dist/setup/migrate/setup-files.d.mts +5 -0
  249. package/dist/setup/migrate/setup-files.mjs +115 -0
  250. package/dist/setup/migrate/studio-state.d.mts +2 -2
  251. package/dist/setup/migrate/studio-state.mjs +4 -4
  252. package/dist/setup/placement.d.mts +1 -1
  253. package/dist/setup/placement.mjs +5 -4
  254. package/dist/setup/plan.d.mts +5 -5
  255. package/dist/setup/plan.mjs +8 -12
  256. package/dist/setup/project.d.mts +6 -1
  257. package/dist/setup/project.mjs +10 -10
  258. package/dist/setup/prompts.d.mts +2 -1
  259. package/dist/setup/prompts.mjs +4 -3
  260. package/dist/setup/questions.mjs +3 -2
  261. package/dist/setup/starters.d.mts +3 -1
  262. package/dist/setup/starters.mjs +9 -3
  263. package/dist/setup/write.d.mts +15 -3
  264. package/dist/setup/write.mjs +23 -3
  265. package/dist/shared/annotations-core.mjs +1 -1
  266. package/dist/shared/canvas-core.d.mts +22 -7
  267. package/dist/shared/canvas-core.mjs +39 -11
  268. package/dist/shared/canvas-file.d.mts +201 -0
  269. package/dist/shared/canvas-file.mjs +1 -0
  270. package/dist/shared/comments/routes.d.mts +55 -0
  271. package/dist/shared/comments/routes.mjs +39 -0
  272. package/dist/shared/export-core.d.mts +62 -0
  273. package/dist/shared/export-core.mjs +101 -0
  274. package/dist/shared/feedback.d.mts +8 -0
  275. package/dist/shared/feedback.mjs +10 -2
  276. package/dist/shared/live-core.d.mts +2 -0
  277. package/dist/shared/live-core.mjs +6 -1
  278. package/dist/shared/live-presence.d.mts +57 -2
  279. package/dist/shared/live-presence.mjs +90 -4
  280. package/dist/shared/page-messages.d.mts +14 -1
  281. package/dist/shared/page-messages.mjs +30 -3
  282. package/dist/shared/page-review.d.mts +2 -11
  283. package/dist/shared/page-review.mjs +4 -13
  284. package/dist/shared/people-core.d.mts +28 -0
  285. package/dist/shared/people-core.mjs +27 -1
  286. package/dist/shared/presence-core.d.mts +13 -0
  287. package/dist/shared/presence-core.mjs +11 -2
  288. package/dist/shared/references-core.d.mts +4 -0
  289. package/dist/shared/references-core.mjs +12 -4
  290. package/dist/shared/review-file.d.mts +5 -0
  291. package/dist/shared/review-file.mjs +23 -13
  292. package/dist/shared/server-page.mjs +1 -1
  293. package/dist/shared/signup.d.mts +2 -5
  294. package/dist/shared/signup.mjs +2 -35
  295. package/dist/shared/studio-events.d.mts +0 -6
  296. package/dist/shared/studio-events.mjs +1 -5
  297. package/dist/shared/studio-files.d.mts +21 -0
  298. package/dist/shared/studio-files.mjs +16 -2
  299. package/dist/shared/studio-routes.d.mts +29 -63
  300. package/dist/shared/studio-routes.mjs +1 -69
  301. package/dist/shared/threads-core.d.mts +29 -6
  302. package/dist/shared/threads-core.mjs +68 -13
  303. package/extension/dist/feedback.js +104 -284
  304. package/extension/dist/manifest.json +1 -1
  305. package/extension/dist/picker.js +104 -284
  306. package/package.json +2 -2
  307. package/src/cli/banner.ts +45 -11
  308. package/src/cli/commands/app.ts +23 -8
  309. package/src/cli/commands/create.ts +4 -4
  310. package/src/cli/commands/export.ts +78 -0
  311. package/src/cli/commands/hook.ts +4 -1
  312. package/src/cli/commands/upgrade.ts +1 -1
  313. package/src/cli/help.ts +13 -7
  314. package/src/cli/main.ts +1 -0
  315. package/src/config/load.ts +26 -2
  316. package/src/config/project-files.ts +36 -6
  317. package/src/config/renamed.ts +19 -4
  318. package/src/content/capture.ts +6 -12
  319. package/src/content/commands.ts +30 -18
  320. package/src/content/comments-log.ts +4 -1
  321. package/src/content/content.ts +71 -257
  322. package/src/content/element-words.ts +175 -0
  323. package/src/content/flow-specs.ts +2 -1
  324. package/src/content/hosted-person.ts +107 -0
  325. package/src/content/merge-rules.ts +29 -0
  326. package/src/content/prototype-summary.ts +4 -44
  327. package/src/content/review-pages.ts +2 -1
  328. package/src/content/screenshot.ts +14 -0
  329. package/src/content/text-edit.ts +172 -105
  330. package/src/content/text-replace.ts +420 -0
  331. package/src/content/thread-module.ts +2 -4
  332. package/src/content/trash.ts +1 -1
  333. package/src/paths.ts +0 -8
  334. package/src/server/agent-env.ts +12 -2
  335. package/src/server/agent-session.ts +124 -34
  336. package/src/server/agents.ts +48 -17
  337. package/src/server/canvas-presence.ts +237 -0
  338. package/src/server/channel.ts +95 -53
  339. package/src/server/claimed-presence.ts +26 -10
  340. package/src/server/command-settings.ts +1 -1
  341. package/src/server/comments/actions.ts +333 -0
  342. package/src/server/comments/routes.ts +131 -0
  343. package/src/server/comments/tools.ts +317 -0
  344. package/src/server/dev-server.ts +94 -33
  345. package/src/server/export/build.ts +310 -0
  346. package/src/server/export/page.ts +85 -0
  347. package/src/server/export/plugin.ts +138 -0
  348. package/src/server/export/run.ts +79 -0
  349. package/src/server/export/save.ts +38 -0
  350. package/src/server/file-lock.ts +205 -54
  351. package/src/server/hosted.ts +113 -0
  352. package/src/server/live-mirror.ts +93 -8
  353. package/src/server/live.ts +46 -1
  354. package/src/server/machine-update.ts +3 -3
  355. package/src/server/mcp.ts +15 -14
  356. package/src/server/me.ts +12 -6
  357. package/src/server/notices.ts +2 -2
  358. package/src/server/open-page.ts +54 -4
  359. package/src/server/outcome.ts +26 -0
  360. package/src/server/people.ts +13 -3
  361. package/src/server/pictures.ts +2 -2
  362. package/src/server/port.ts +94 -20
  363. package/src/server/prebundle.ts +230 -0
  364. package/src/server/presence.ts +12 -4
  365. package/src/server/problems.ts +11 -0
  366. package/src/server/requests.ts +115 -110
  367. package/src/server/roster.ts +1 -1
  368. package/src/server/saved.ts +1 -1
  369. package/src/server/source-stamp.ts +118 -37
  370. package/src/server/state.ts +53 -31
  371. package/src/server/studio-for.ts +26 -2
  372. package/src/server/sync-install.ts +35 -26
  373. package/src/server/thread-place.ts +2 -4
  374. package/src/server/thread-source.ts +35 -3
  375. package/src/server/tools/export.ts +56 -0
  376. package/src/server/tools/place-frame.ts +23 -15
  377. package/src/server/tools/reading.ts +16 -3
  378. package/src/server/tools/thread-list.ts +1 -1
  379. package/src/server/tools/watch.ts +7 -7
  380. package/src/server/updates.ts +2 -2
  381. package/src/server/vite.ts +106 -110
  382. package/src/server/web-app.ts +11 -9
  383. package/src/server/welcome.ts +3 -1
  384. package/src/setup/apply.ts +8 -5
  385. package/src/setup/create.ts +101 -27
  386. package/src/setup/design-system-checks.ts +8 -21
  387. package/src/setup/desktop-app-script.ts +4 -3
  388. package/src/setup/desktop-app-start.ts +94 -26
  389. package/src/setup/desktop-app.ts +23 -2
  390. package/src/setup/detect/workspace.ts +20 -21
  391. package/src/setup/detect.ts +0 -4
  392. package/src/setup/doctor.ts +13 -6
  393. package/src/setup/migrate/dex-folder.ts +842 -0
  394. package/src/setup/migrate/files-folder.ts +1 -1
  395. package/src/setup/migrate/guides.ts +3 -1
  396. package/src/setup/migrate/migrations.ts +8 -2
  397. package/src/setup/migrate/setup-files.ts +198 -0
  398. package/src/setup/migrate/studio-state.ts +12 -10
  399. package/src/setup/own-app.ts +1 -1
  400. package/src/setup/placement.ts +7 -6
  401. package/src/setup/plan.ts +13 -18
  402. package/src/setup/project.ts +11 -10
  403. package/src/setup/prompts.ts +5 -4
  404. package/src/setup/questions.ts +6 -3
  405. package/src/setup/starters.ts +11 -4
  406. package/src/setup/write.ts +34 -3
  407. package/src/shared/canvas-core.ts +48 -9
  408. package/src/shared/canvas-file.ts +205 -0
  409. package/src/shared/comments/routes.ts +81 -0
  410. package/src/shared/export-core.ts +198 -0
  411. package/src/shared/feedback.ts +14 -4
  412. package/src/shared/live-core.ts +8 -0
  413. package/src/shared/live-presence.ts +171 -2
  414. package/src/shared/page-messages.ts +38 -2
  415. package/src/shared/page-review.ts +11 -16
  416. package/src/shared/people-core.ts +44 -0
  417. package/src/shared/presence-core.ts +18 -2
  418. package/src/shared/references-core.ts +22 -3
  419. package/src/shared/review-file.ts +28 -12
  420. package/src/shared/server-page.ts +2 -1
  421. package/src/shared/signup.ts +4 -28
  422. package/src/shared/studio-events.ts +0 -13
  423. package/src/shared/studio-files.ts +29 -1
  424. package/src/shared/studio-routes.ts +32 -65
  425. package/src/shared/threads-core.ts +134 -12
  426. package/templates/methods/explore.md +1 -1
  427. package/templates/methods/handoff.md +1 -1
  428. package/templates/methods/review.md +2 -1
  429. package/templates/rules/canvas-frames.md +6 -3
  430. package/templates/rules/commands.md +1 -0
  431. package/templates/rules/prototypes.md +1 -1
  432. package/templates/rules/studio.md +17 -11
  433. package/templates/skills/comprehend/SKILL.md +56 -0
  434. package/templates/skills/distill/SKILL.md +172 -0
  435. package/templates/skills/export-prototype/SKILL.md +35 -0
  436. package/templates/skills/riff/SKILL.md +21 -0
  437. package/templates/skills/riff-deep/SKILL.md +40 -0
  438. package/templates/skills/riff-max/SKILL.md +46 -0
  439. package/templates/skills/riff-state/SKILL.md +45 -0
  440. package/templates/skills/riff-up/SKILL.md +38 -0
  441. package/templates/skills/riff-wide/SKILL.md +40 -0
  442. package/templates/starters/standalone/README.md +1 -1
  443. package/templates/starters/turborepo/README.md +2 -2
  444. package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
  445. package/templates/starters/vite/README.md +1 -1
  446. package/dist/server/tools/close-reply.d.mts +0 -6
  447. package/dist/server/tools/close-reply.mjs +0 -138
  448. package/dist/server/tools/comment.d.mts +0 -6
  449. package/dist/server/tools/comment.mjs +0 -49
  450. package/src/server/tools/close-reply.ts +0 -271
  451. package/src/server/tools/comment.ts +0 -96
@@ -1,3 +1,4 @@
1
+ import { postToRelay } from "./feedback.mjs";
1
2
  //#region src/shared/signup.ts
2
3
  /** Where sign-ups go: the relay on Dex's site. */
3
4
  const SIGNUP_URL = "https://sudio-site.vercel.app/api/signup";
@@ -48,8 +49,6 @@ const receiveSignup = (form) => {
48
49
  signup
49
50
  };
50
51
  };
51
- const TOO_MANY_REQUESTS = 429;
52
- const SERVICE_UNAVAILABLE = 503;
53
52
  /** Send a sign-up to the relay, if it is ready; never throws. */
54
53
  const sendSignup = async (signup, { fetch = globalThis.fetch, url = SIGNUP_URL } = {}) => {
55
54
  if (checkSignup(signup).length > 0) return {
@@ -59,39 +58,7 @@ const sendSignup = async (signup, { fetch = globalThis.fetch, url = SIGNUP_URL }
59
58
  const form = new FormData();
60
59
  form.set("name", signup.name.trim());
61
60
  form.set("email", signup.email.trim());
62
- try {
63
- const response = await fetch(url, {
64
- method: "POST",
65
- body: form
66
- });
67
- if (response.ok) {
68
- const { id } = await response.json();
69
- return typeof id === "string" && id ? {
70
- ok: true,
71
- id
72
- } : {
73
- ok: false,
74
- reason: "failed"
75
- };
76
- }
77
- if (response.status === TOO_MANY_REQUESTS) return {
78
- ok: false,
79
- reason: "limited"
80
- };
81
- if (response.status === SERVICE_UNAVAILABLE) return {
82
- ok: false,
83
- reason: "unavailable"
84
- };
85
- return {
86
- ok: false,
87
- reason: "failed"
88
- };
89
- } catch {
90
- return {
91
- ok: false,
92
- reason: "failed"
93
- };
94
- }
61
+ return await postToRelay(url, form, fetch);
95
62
  };
96
63
  //#endregion
97
64
  export { SIGNUP_LIMITS, SIGNUP_URL, checkSignup, receiveSignup, sendSignup };
@@ -33,12 +33,6 @@ export interface ConnectedAgent {
33
33
  */
34
34
  watching?: boolean;
35
35
  }
36
- /**
37
- * How an agent comes by new feedback: pushed to it as it is left, pushed
38
- * with nothing yet to say it arrives, or only when it is asked or watches.
39
- */
40
- export type Hearing = "pushed" | "unproven" | "asked";
41
- export declare const hearingOf: (agent: ConnectedAgent) => Hearing;
42
36
  export type StudioEvent = {
43
37
  type: "presence";
44
38
  presence: PresenceEntry[];
@@ -1,10 +1,6 @@
1
1
  import { UNSEEN_PARTS, splitPrototypePath } from "./prototypes-core.mjs";
2
2
  import { classify } from "./studio-files.mjs";
3
3
  //#region src/shared/studio-events.ts
4
- const hearingOf = (agent) => {
5
- if (agent.channel) return "pushed";
6
- return agent.unproven ? "unproven" : "asked";
7
- };
8
4
  /** Each event, made from what it carries. */
9
5
  const studioEvent = {
10
6
  presence: (presence) => ({
@@ -92,4 +88,4 @@ function eventsForFile(file) {
92
88
  return [];
93
89
  }
94
90
  //#endregion
95
- export { STUDIO_EVENT_TYPES, eventMessage, eventsForFile, handleStudioEvent, hearingOf, studioEvent };
91
+ export { STUDIO_EVENT_TYPES, eventMessage, eventsForFile, handleStudioEvent, studioEvent };
@@ -1,4 +1,23 @@
1
1
  //#region src/shared/studio-files.d.ts
2
+ export declare const DISCIPLINES: readonly ["product", "brand", "engineering"];
3
+ export type Discipline = (typeof DISCIPLINES)[number];
4
+ /** A person who makes prototypes, from contributors.json. */
5
+ export interface Contributor {
6
+ discipline: Discipline;
7
+ /** Git user names that identify this person, so the agent knows who it is working for. */
8
+ git: string[];
9
+ /** Their GitHub username, for their avatar. */
10
+ github?: string;
11
+ name: string;
12
+ slug: string;
13
+ }
14
+ /**
15
+ * The Dex folder's name: `dex/` in a project, `apps/web/dex/` in an app of
16
+ * a workspace. An app of its own (`apps/dex`) is its Dex folder.
17
+ */
18
+ export declare const DEX_FOLDER = "dex";
19
+ /** Its name before, `studio/`: `dex upgrade` moves it to DEX_FOLDER. */
20
+ export declare const OLD_DEX_FOLDER = "studio";
2
21
  /** Where each of the studio's own files is, relative to its content root. */
3
22
  export declare const STUDIO_FILES: {
4
23
  /** Who works in the studio, and the git users that are them. */
@@ -11,6 +30,8 @@ export declare const STUDIO_FILES: {
11
30
  readonly context: "context";
12
31
  /** Each person's folder: people/<slug>/guidelines.md. */
13
32
  readonly people: "people";
33
+ /** The team's own skills: skills/<name>/SKILL.md. */
34
+ readonly skills: "skills";
14
35
  };
15
36
  /** A person's own guidelines, for their agents, on top of the workspace's. */
16
37
  export declare const personGuidelinesPath: (slug: string) => string;
@@ -1,5 +1,17 @@
1
1
  import { PROTOTYPES_FOLDER, isSlug, splitPrototypePath } from "./prototypes-core.mjs";
2
2
  //#region src/shared/studio-files.ts
3
+ const DISCIPLINES = [
4
+ "product",
5
+ "brand",
6
+ "engineering"
7
+ ];
8
+ /**
9
+ * The Dex folder's name: `dex/` in a project, `apps/web/dex/` in an app of
10
+ * a workspace. An app of its own (`apps/dex`) is its Dex folder.
11
+ */
12
+ const DEX_FOLDER = "dex";
13
+ /** Its name before, `studio/`: `dex upgrade` moves it to DEX_FOLDER. */
14
+ const OLD_DEX_FOLDER = "studio";
3
15
  /** Where each of the studio's own files is, relative to its content root. */
4
16
  const STUDIO_FILES = {
5
17
  /** Who works in the studio, and the git users that are them. */
@@ -11,7 +23,9 @@ const STUDIO_FILES = {
11
23
  /** The folder of context files: context/<slug>.md. */
12
24
  context: "context",
13
25
  /** Each person's folder: people/<slug>/guidelines.md. */
14
- people: "people"
26
+ people: "people",
27
+ /** The team's own skills: skills/<name>/SKILL.md. */
28
+ skills: "skills"
15
29
  };
16
30
  /** A person's own guidelines, for their agents, on top of the workspace's. */
17
31
  const personGuidelinesPath = (slug) => {
@@ -55,4 +69,4 @@ function classify(file) {
55
69
  return "other";
56
70
  }
57
71
  //#endregion
58
- export { STUDIO_FILES, classify, guidelinesPerson, isEditableMarkdown, isInstructionsFile, personGuidelinesPath };
72
+ export { DEX_FOLDER, DISCIPLINES, OLD_DEX_FOLDER, STUDIO_FILES, classify, guidelinesPerson, isEditableMarkdown, isInstructionsFile, personGuidelinesPath };
@@ -7,6 +7,7 @@ import { PasteSource } from "./snapshot-clipboard.mjs";
7
7
  import { Devices } from "./devices.mjs";
8
8
  import { AvatarFile } from "./avatar-file.mjs";
9
9
  import { BuildSettings } from "./build-settings.mjs";
10
+ import { CommentAnswers, CommentBodies } from "./comments/routes.mjs";
10
11
  import { RemovedView } from "./removed-views-core.mjs";
11
12
  import { ReviewImport } from "./review-file.mjs";
12
13
  import { ConnectedAgent } from "./studio-events.mjs";
@@ -304,7 +305,7 @@ export type GitStepName = GitStepBody["step"];
304
305
  * The bodies the contract declares, by request and method; the rest are
305
306
  * unknown, checked by their handlers.
306
307
  */
307
- export interface StudioBodies {
308
+ export interface StudioBodies extends CommentBodies {
308
309
  "agent-launch": {
309
310
  POST: {
310
311
  agent: LaunchAgentId;
@@ -382,7 +383,7 @@ export type StudioBodyOf<Name extends StudioRouteName, Method extends StudioMeth
382
383
  * Each request, by name, and its answer to each method it takes. The query
383
384
  * a request needs is in its comment.
384
385
  */
385
- export interface StudioAnswers<Own extends OwnTypes = OwnTypes> {
386
+ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> extends CommentAnswers {
386
387
  /**
387
388
  * Open an agent, or a plain terminal, where agents start: in a terminal
388
389
  * window on this Mac (`opened`), else the command to run. Only from this
@@ -492,6 +493,13 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> {
492
493
  events: {
493
494
  GET: unknown;
494
495
  };
496
+ /**
497
+ * ?prototype=<name>: its frames as an exported prototype (export-core.ts),
498
+ * a zip (not JSON) named for the file. POST takes an ExportChoice.
499
+ */
500
+ export: {
501
+ POST: Blob;
502
+ };
495
503
  /**
496
504
  * The browser extension, as a zip (not JSON) of the folder Chrome loads
497
505
  * unpacked, its files at the root, named EXTENSION_FILE.
@@ -593,6 +601,11 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> {
593
601
  * they make something.
594
602
  */
595
603
  newcomer: Own["contributor"] | null;
604
+ /**
605
+ * In Dex in the browser, hosted for the workspace: viewers look and
606
+ * comment, and never change the files.
607
+ */
608
+ viewer?: true;
596
609
  };
597
610
  };
598
611
  /**
@@ -618,7 +631,7 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> {
618
631
  }[];
619
632
  };
620
633
  };
621
- /** The workspace's contributors, the latest to commit first. */
634
+ /** The workspace's contributors, the latest to commit first; ?commits=0 skips git's log. */
622
635
  people: {
623
636
  GET: {
624
637
  people: Person[];
@@ -652,6 +665,19 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> {
652
665
  views: string[];
653
666
  };
654
667
  };
668
+ /** A find and replace's changes, or what its undo put back. */
669
+ replace: {
670
+ POST: {
671
+ files: string[];
672
+ left?: number;
673
+ replaced: number;
674
+ skipped: number;
675
+ undo?: string;
676
+ } | {
677
+ kept: string[];
678
+ restored: string[];
679
+ };
680
+ };
655
681
  /**
656
682
  * GET: how a restart goes, from this Dex or, while none answers, its
657
683
  * supervisor; POST: the run Dex restarts from.
@@ -697,11 +723,6 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> {
697
723
  file: string;
698
724
  };
699
725
  };
700
- /** ?slug= for one prototype's, or none for every one's. */
701
- threads: {
702
- GET: ThreadWithPrototype[];
703
- POST: ThreadWithPrototype;
704
- };
705
726
  trash: {
706
727
  DELETE: Done;
707
728
  };
@@ -773,61 +794,6 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> {
773
794
  export type StudioRouteName = keyof StudioAnswers;
774
795
  /** The methods a request takes. */
775
796
  export type StudioMethodOf<Name extends StudioRouteName> = keyof StudioAnswers[Name] & StudioMethod;
776
- /**
777
- * The requests and the methods each takes, for what has to know them as it
778
- * runs: the server's test that it serves each one as declared.
779
- */
780
- export declare const STUDIO_ROUTES: {
781
- readonly canvas: readonly ["GET", "PUT"];
782
- readonly annotations: readonly ["GET", "PUT", "DELETE"];
783
- readonly events: readonly ["GET"];
784
- readonly "removed-views": readonly ["GET", "POST"];
785
- readonly reviews: readonly ["POST"];
786
- readonly trash: readonly ["DELETE"];
787
- readonly threads: readonly ["GET", "POST"];
788
- readonly "spec-suggestion": readonly ["POST"];
789
- readonly instructions: readonly ["GET", "PUT"];
790
- readonly focus: readonly ["PUT"];
791
- readonly me: readonly ["GET"];
792
- readonly people: readonly ["GET"];
793
- readonly prototypes: readonly ["POST"];
794
- readonly paste: readonly ["POST"];
795
- readonly frame: readonly ["POST"];
796
- readonly show: readonly ["POST"];
797
- readonly text: readonly ["POST"];
798
- readonly props: readonly ["POST"];
799
- readonly insert: readonly ["POST"];
800
- readonly screenshot: readonly ["POST"];
801
- readonly snapshot: readonly ["POST"];
802
- readonly picture: readonly ["POST"];
803
- readonly agents: readonly ["GET"];
804
- readonly edited: readonly ["GET"];
805
- readonly extension: readonly ["GET"];
806
- readonly "agent-setup": readonly ["GET", "POST"];
807
- readonly "agent-launch": readonly ["POST"];
808
- readonly "agent-stop": readonly ["POST"];
809
- readonly preferences: readonly ["GET", "PUT"];
810
- readonly watch: readonly ["GET", "POST"];
811
- readonly welcome: readonly ["GET", "POST"];
812
- readonly update: readonly ["GET", "POST"];
813
- readonly "machine-update": readonly ["GET", "POST"];
814
- readonly "other-dexes": readonly ["GET", "POST"];
815
- readonly restart: readonly ["GET", "POST"];
816
- readonly "desktop-app": readonly ["GET", "POST"];
817
- readonly devices: readonly ["GET", "PUT"];
818
- readonly git: readonly ["GET", "POST"];
819
- readonly "git-branches": readonly ["GET"];
820
- readonly "git-sync": readonly ["POST"];
821
- readonly "git-pull-base": readonly ["POST"];
822
- readonly "git-saved": readonly ["GET", "POST"];
823
- readonly "git-checks": readonly ["POST"];
824
- readonly "git-settings": readonly ["GET", "PUT"];
825
- readonly "build-settings": readonly ["GET", "PUT"];
826
- readonly commands: readonly ["GET", "POST", "PUT", "DELETE"];
827
- readonly "workspace-settings": readonly ["GET", "PUT"];
828
- readonly "workspace-icon": readonly ["GET", "PUT", "DELETE"];
829
- readonly avatar: readonly ["PUT", "DELETE"];
830
- };
831
797
  /** The web app manifest `dex dev` serves. */
832
798
  export declare const MANIFEST_FILE = "manifest.webmanifest";
833
799
  /**
@@ -52,74 +52,6 @@ const START_LINK_META = "dex-start-link";
52
52
  * standalone display says in a browser.
53
53
  */
54
54
  const DESKTOP_APP_AGENT = "DexApp";
55
- /**
56
- * The requests and the methods each takes, for what has to know them as it
57
- * runs: the server's test that it serves each one as declared.
58
- */
59
- const STUDIO_ROUTES = {
60
- canvas: ["GET", "PUT"],
61
- annotations: [
62
- "GET",
63
- "PUT",
64
- "DELETE"
65
- ],
66
- events: ["GET"],
67
- "removed-views": ["GET", "POST"],
68
- reviews: ["POST"],
69
- trash: ["DELETE"],
70
- threads: ["GET", "POST"],
71
- "spec-suggestion": ["POST"],
72
- instructions: ["GET", "PUT"],
73
- focus: ["PUT"],
74
- me: ["GET"],
75
- people: ["GET"],
76
- prototypes: ["POST"],
77
- paste: ["POST"],
78
- frame: ["POST"],
79
- show: ["POST"],
80
- text: ["POST"],
81
- props: ["POST"],
82
- insert: ["POST"],
83
- screenshot: ["POST"],
84
- snapshot: ["POST"],
85
- picture: ["POST"],
86
- agents: ["GET"],
87
- edited: ["GET"],
88
- extension: ["GET"],
89
- "agent-setup": ["GET", "POST"],
90
- "agent-launch": ["POST"],
91
- "agent-stop": ["POST"],
92
- preferences: ["GET", "PUT"],
93
- watch: ["GET", "POST"],
94
- welcome: ["GET", "POST"],
95
- update: ["GET", "POST"],
96
- "machine-update": ["GET", "POST"],
97
- "other-dexes": ["GET", "POST"],
98
- restart: ["GET", "POST"],
99
- "desktop-app": ["GET", "POST"],
100
- devices: ["GET", "PUT"],
101
- git: ["GET", "POST"],
102
- "git-branches": ["GET"],
103
- "git-sync": ["POST"],
104
- "git-pull-base": ["POST"],
105
- "git-saved": ["GET", "POST"],
106
- "git-checks": ["POST"],
107
- "git-settings": ["GET", "PUT"],
108
- "build-settings": ["GET", "PUT"],
109
- commands: [
110
- "GET",
111
- "POST",
112
- "PUT",
113
- "DELETE"
114
- ],
115
- "workspace-settings": ["GET", "PUT"],
116
- "workspace-icon": [
117
- "GET",
118
- "PUT",
119
- "DELETE"
120
- ],
121
- avatar: ["PUT", "DELETE"]
122
- };
123
55
  /** The web app manifest `dex dev` serves. */
124
56
  const MANIFEST_FILE = "manifest.webmanifest";
125
57
  /**
@@ -134,4 +66,4 @@ const PROJECT_ID_HEADER = "x-dex-project";
134
66
  */
135
67
  const OLD_PROJECT_ID_HEADER = "x-sudio-project";
136
68
  //#endregion
137
- export { DESKTOP_APP_AGENT, DESKTOP_APP_INSTALLED, DESKTOP_APP_KEY, EXTENSION_FILE, GITHUB_SIGN_IN_COMMAND, GIT_NAME_COMMAND, MANIFEST_FILE, ME_META, NOT_RECOGNISED, OLD_PROJECT_ID_HEADER, PROJECT_ID_HEADER, STALE_PICTURE_HEADER, START_LINK_META, STUDIO_ROUTES, canLaunch, nameOfMe, youOf };
69
+ export { DESKTOP_APP_AGENT, DESKTOP_APP_INSTALLED, DESKTOP_APP_KEY, EXTENSION_FILE, GITHUB_SIGN_IN_COMMAND, GIT_NAME_COMMAND, MANIFEST_FILE, ME_META, NOT_RECOGNISED, OLD_PROJECT_ID_HEADER, PROJECT_ID_HEADER, STALE_PICTURE_HEADER, START_LINK_META, canLaunch, nameOfMe, youOf };
@@ -1,4 +1,4 @@
1
- import { Viewport } from "./canvas-core.mjs";
1
+ import { PageSize, Viewport } from "./canvas-core.mjs";
2
2
  import { Sketch, SketchBox } from "./sketch-core.mjs";
3
3
  import { SpecQuote } from "./spec-quote.mjs";
4
4
  //#region src/shared/threads-core.d.ts
@@ -73,8 +73,8 @@ export type ThreadTarget = {
73
73
  selector?: string;
74
74
  /**
75
75
  * The start of the element's text, or its label or placeholder when it
76
- * has none, to help find it in code. Its pin shows while it still
77
- * says so.
76
+ * has none, to help find it in code, and on the page when it moves.
77
+ * Its pin stays in its place when the words change.
78
78
  */
79
79
  text?: string;
80
80
  /**
@@ -111,10 +111,20 @@ export type ThreadTarget = {
111
111
  params?: Record<string, string>;
112
112
  viewport?: Viewport;
113
113
  } | {
114
+ /**
115
+ * With no row: the row its new row goes right above, as the + on the
116
+ * line between two rows asks. None puts the new row below the others.
117
+ */
118
+ above?: string;
114
119
  kind: "view";
115
120
  /** The row to add it to; leave out for a new row (a new iteration). */
116
121
  row?: string;
117
122
  section: string;
123
+ /**
124
+ * The size its frame takes, set by resizing the request on the canvas.
125
+ * Left out, it takes the size of the frame before it.
126
+ */
127
+ size?: PageSize;
118
128
  step: number;
119
129
  } | (SpecQuote & {
120
130
  kind: "spec";
@@ -169,6 +179,10 @@ export interface ThreadReaction {
169
179
  export type ChangePlace = Extract<ThreadTarget, {
170
180
  kind: "element" | "frame";
171
181
  }>;
182
+ /** A request for a new view's target: the cell it waits in, and its size. */
183
+ export type ViewTarget = Extract<ThreadTarget, {
184
+ kind: "view";
185
+ }>;
172
186
  /** What changed, or why not, when the thread was resolved or dismissed. */
173
187
  export interface ThreadResolution {
174
188
  agent?: boolean;
@@ -262,15 +276,21 @@ export interface ThreadChange {
262
276
  /** The agent session making the change, kept on its reaction. */
263
277
  session?: string;
264
278
  status?: ThreadStatus;
279
+ /**
280
+ * A request for a new view, moved or resized on the canvas by a person:
281
+ * the cell it now waits in, and the size its frame takes.
282
+ */
283
+ target?: ThreadTarget;
265
284
  via?: string;
266
285
  /** Resolving: where the change landed, kept with the note. */
267
286
  where?: ChangePlace;
268
287
  }
269
288
  /**
270
289
  * A person's change to a thread, before the studio adds who they are: a
271
- * reply, a reaction, who it is for, or its status.
290
+ * reply, a reaction, who it is for, its status, or where a request for a
291
+ * new view waits.
272
292
  */
273
- export type PersonChange = Pick<ThreadChange, "authorId" | "body" | "edit" | "for" | "on" | "hidden" | "react" | "remove" | "status">;
293
+ export type PersonChange = Pick<ThreadChange, "authorId" | "body" | "edit" | "for" | "on" | "hidden" | "react" | "remove" | "status" | "target">;
274
294
  /**
275
295
  * A thread with the prototype it belongs to, as the thread module and the
276
296
  * studio's requests return it.
@@ -332,6 +352,8 @@ export declare const THREAD_STATUSES: ThreadStatus[];
332
352
  export declare const AUDIENCES: ThreadAudience[];
333
353
  /** The reaction an agent leaves for each status it sets. */
334
354
  export declare const STATUS_REACTIONS: Record<"acknowledged" | "resolved" | "dismissed", string>;
355
+ /** The names "@" calls an agent by: no frame goes by one in a comment. */
356
+ export declare const AGENT_NAMES: readonly string[];
335
357
  /** Why an agent cannot acknowledge a thread another session has claimed. */
336
358
  export declare const CLAIMED_PROBLEM = "Another agent is on this thread.";
337
359
  /** Why an agent cannot let go of a thread it does not hold. */
@@ -394,10 +416,11 @@ export declare function changeConflicts(thread: Thread, change: ThreadChange): s
394
416
  */
395
417
  export declare const isOwnMessage: (message: ThreadMessage, { author, authorId }: Pick<ThreadChange, "author" | "authorId">) => boolean;
396
418
  /** Problems with a change to a thread, empty when it is fine. */
397
- export declare function changeProblems({ status, for: audience, hidden }: {
419
+ export declare function changeProblems({ status, for: audience, hidden, target }: {
398
420
  for?: unknown;
399
421
  hidden?: unknown;
400
422
  status?: unknown;
423
+ target?: unknown;
401
424
  }): string[];
402
425
  /**
403
426
  * Apply a change to a thread in place: a message, a status, who it is for, a
@@ -1,7 +1,7 @@
1
- import { prototypeFiles } from "./prototypes-core.mjs";
2
1
  import { isOneOf, isRecord, isText } from "./checks.mjs";
2
+ import { prototypeFiles } from "./prototypes-core.mjs";
3
3
  import { cleanSketch, describeSketch, threadSketchProblems } from "./sketch-core.mjs";
4
- import { VIEWPORTS, isSpecPath } from "./canvas-core.mjs";
4
+ import { VIEWPORTS, isSpecPath, requestCell } from "./canvas-core.mjs";
5
5
  import "./spec-quote.mjs";
6
6
  //#region src/shared/threads-core.ts
7
7
  const THREAD_STATUSES = [
@@ -34,7 +34,14 @@ const MAX_REACTION = 8;
34
34
  * for; a longer one is kept, and shortened where it is shown.
35
35
  */
36
36
  const MAX_NOTE = 2e3;
37
- const MENTION_RE = /(?:^|\s)@(?:agent|claude|codex|cursor)\b/i;
37
+ /** The names "@" calls an agent by: no frame goes by one in a comment. */
38
+ const AGENT_NAMES = [
39
+ "agent",
40
+ "claude",
41
+ "codex",
42
+ "cursor"
43
+ ];
44
+ const MENTION_RE = new RegExp(`(?:^|\\s)@(?:${AGENT_NAMES.join("|")})(?![\\w-])`, "i");
38
45
  /** Why an agent cannot acknowledge a thread another session has claimed. */
39
46
  const CLAIMED_PROBLEM = "Another agent is on this thread.";
40
47
  /** Why an agent cannot let go of a thread it does not hold. */
@@ -160,6 +167,7 @@ const claimOf = (thread) => thread.status === "acknowledged" ? (thread.reactions
160
167
  */
161
168
  function changeConflicts(thread, change) {
162
169
  if (change.hidden !== void 0 && !thread.review) return [HIDDEN_PROBLEM];
170
+ if (change.target !== void 0 && (change.agent || thread.target.kind !== "view" || isClosed(thread))) return [MOVE_PROBLEM];
163
171
  if (!change.agent) return ownMessageProblems(thread, change);
164
172
  const problems = [];
165
173
  if (isText(change.edit) || change.remove) problems.push("Only a person edits or removes a comment, and only their own.");
@@ -186,6 +194,8 @@ const isOwnMessage = (message, { author, authorId }) => {
186
194
  */
187
195
  /** Only a reviewer's imported comment is ever left off the published site. */
188
196
  const HIDDEN_PROBLEM = "Only a review's comments can be hidden from the published site.";
197
+ /** Only a person moves a request for a new view, and only until it is built. */
198
+ const MOVE_PROBLEM = "Only a person moves or resizes a request for a new view, and only while it is still to be built.";
189
199
  const ownMessageProblems = (thread, change) => {
190
200
  if (!(isText(change.edit) || change.remove)) return [];
191
201
  const message = messageOn(thread, change.on);
@@ -208,9 +218,24 @@ const changeMessage = (thread, { agent, author, authorId, edit, on, remove }, at
208
218
  message.edited = at;
209
219
  }
210
220
  };
221
+ /** Whether a value is a size in pixels: a positive width and height. */
222
+ const isSize = (value) => isRecord(value) && [value.width, value.height].every((side) => typeof side === "number" && Number.isFinite(side) && side > 0);
223
+ /** What a request for a new view, moved or resized, must say. */
224
+ const movedRequestProblems = (target) => {
225
+ if (!(isRecord(target) && target.kind === "view")) return ["Only a request for a new view moves: give its cell, as a view's."];
226
+ const { above, row, section, size, step } = target;
227
+ return [
228
+ ...isText(section) ? [] : ["A request for a view names its section."],
229
+ ...row === void 0 || isText(row) ? [] : ["A request's row is a row's id; leave it out for a new row."],
230
+ ...above === void 0 || isText(above) ? [] : ["A new row's `above` is the id of the row it goes above."],
231
+ ...Number.isInteger(step) && Number(step) >= 1 ? [] : ["A request for a view needs the step it fills."],
232
+ ...size === void 0 || isSize(size) ? [] : ["A request's size is a width and a height in pixels."]
233
+ ];
234
+ };
211
235
  /** Problems with a change to a thread, empty when it is fine. */
212
- function changeProblems({ status, for: audience, hidden }) {
236
+ function changeProblems({ status, for: audience, hidden, target }) {
213
237
  const problems = [];
238
+ if (target !== void 0) problems.push(...movedRequestProblems(target));
214
239
  if (hidden !== void 0 && typeof hidden !== "boolean") problems.push("Hidden is true or false.");
215
240
  if (status && !isOneOf(THREAD_STATUSES, status)) problems.push(`A status is one of: ${THREAD_STATUSES.join(", ")}.`);
216
241
  if (audience !== void 0 && !isOneOf(AUDIENCES, audience)) problems.push(`A thread is for ${AUDIENCES.join(" or ")}.`);
@@ -230,6 +255,7 @@ function changeThread(thread, change, at = now()) {
230
255
  at
231
256
  };
232
257
  changeMessage(thread, change, at);
258
+ moveRequest(thread, change.target);
233
259
  addReaction(thread, change, who);
234
260
  keepResolution(thread, change, who);
235
261
  addMessage(thread, change, at);
@@ -239,6 +265,22 @@ function changeThread(thread, change, at = now()) {
239
265
  thread.updated = at;
240
266
  return thread;
241
267
  }
268
+ /**
269
+ * A request for a new view, moved or resized: the cell it waits in (for a
270
+ * new row, the row it goes above) and the size its frame takes, nothing else.
271
+ */
272
+ const moveRequest = (thread, target) => {
273
+ if (target?.kind !== "view" || thread.target.kind !== "view") return;
274
+ const { size } = target;
275
+ thread.target = given({
276
+ kind: "view",
277
+ ...requestCell(target),
278
+ size: size && {
279
+ width: Math.round(size.width),
280
+ height: Math.round(size.height)
281
+ }
282
+ });
283
+ };
242
284
  /** Leave an imported review's thread off the published site, or show it. */
243
285
  const setHidden = (thread, hidden) => {
244
286
  if (hidden === void 0 || !thread.review) return;
@@ -477,6 +519,20 @@ const frameFile = (files, { doc, view }) => {
477
519
  * for, which it knows from `npx dex whoami`.
478
520
  */
479
521
  const ownCanvas = (files) => files && `${files.people}/<you>/canvas.json`;
522
+ /** Where a request's new row goes, as an agent reads it. */
523
+ const newRowWhere = (above) => above ? `a new row, right above row "${above}"` : "a new row at the end of the section";
524
+ /**
525
+ * A request for a new view, as an agent reads it: the cell to put its frame
526
+ * in, and the size to put it at when the person gave it one.
527
+ */
528
+ const requestWhere = ({ above, row, section, size, step }, files) => ({
529
+ what: `A request for a new view. Build it, then add a frame for it in this cell${size ? ", at this size" : ""}: with \`place_frame\` (pass this thread's id) where you have it, otherwise in canvas.json.`,
530
+ canvas: ownCanvas(files),
531
+ section,
532
+ row: row ?? newRowWhere(above),
533
+ step,
534
+ ...size ? { size } : {}
535
+ });
480
536
  /** Where a thread is, as an agent reads it: what it is on, and its file. */
481
537
  const whereOf = (target, files) => {
482
538
  switch (target.kind) {
@@ -522,13 +578,7 @@ const whereOf = (target, files) => {
522
578
  canvas: ownCanvas(files),
523
579
  point: target.point
524
580
  };
525
- case "view": return {
526
- what: "A request for a new view. Build it, then add a frame for it in this cell: with `place_frame` (pass this thread's id) where you have it, otherwise in canvas.json.",
527
- canvas: ownCanvas(files),
528
- section: target.section,
529
- row: target.row ?? "a new row at the end of the section",
530
- step: target.step
531
- };
581
+ case "view": return requestWhere(target, files);
532
582
  default: return {
533
583
  what: "A comment on the file as a whole.",
534
584
  folder: files?.folder
@@ -598,7 +648,12 @@ const publicTarget = (target) => {
598
648
  kind: target.kind,
599
649
  section: target.section,
600
650
  step: target.step,
601
- row: target.row
651
+ row: target.row,
652
+ above: target.above,
653
+ size: target.size && {
654
+ width: target.size.width,
655
+ height: target.size.height
656
+ }
602
657
  });
603
658
  case "spec": return given({
604
659
  kind: target.kind,
@@ -675,4 +730,4 @@ const publicThread = ({ created, for: audience, id, messages, reactions, resolut
675
730
  */
676
731
  const publicThreads = (threads) => threads.flatMap(({ status, ...thread }) => status === "dismissed" || thread.review?.hidden ? [] : [publicThread(thread, status)]);
677
732
  //#endregion
678
- export { AGENT_ACTIONS, AUDIENCES, CLAIMED_PROBLEM, LIST_STATUSES, RELEASE_PROBLEM, REPLY_PROBLEM, SKETCH_BODY, STATUS_REACTIONS, SUGGESTED_BODY, THREAD_ID_RE, THREAD_STATUSES, agentChange, audienceOf, changeConflicts, changePlace, changeProblems, changeThread, claimOf, describeThread, isClosed, isOwnMessage, isRenameSuggestion, keptFiles, mentionsAgent, needsAgent, needsPerson, newThread, newThreadId, publicThreads, statusFilter, threadProblems, threadState };
733
+ export { AGENT_ACTIONS, AGENT_NAMES, AUDIENCES, CLAIMED_PROBLEM, LIST_STATUSES, RELEASE_PROBLEM, REPLY_PROBLEM, SKETCH_BODY, STATUS_REACTIONS, SUGGESTED_BODY, THREAD_ID_RE, THREAD_STATUSES, agentChange, audienceOf, changeConflicts, changePlace, changeProblems, changeThread, claimOf, describeThread, isClosed, isOwnMessage, isRenameSuggestion, keptFiles, mentionsAgent, needsAgent, needsPerson, newThread, newThreadId, publicThreads, statusFilter, threadProblems, threadState };