@dexhq/canvas 0.15.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 (307) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/app/canvas/activity-parts.tsx +50 -6
  3. package/app/canvas/activity.tsx +2 -3
  4. package/app/canvas/agent-changes.ts +18 -8
  5. package/app/canvas/anchoring.ts +13 -3
  6. package/app/canvas/canvas-context.tsx +6 -2
  7. package/app/canvas/canvas-input.ts +35 -0
  8. package/app/canvas/canvas-model.ts +2 -2
  9. package/app/canvas/canvas-scene.ts +243 -24
  10. package/app/canvas/canvas-ui.ts +11 -2
  11. package/app/canvas/canvas.css +86 -3
  12. package/app/canvas/comments.tsx +66 -29
  13. package/app/canvas/element-link.ts +135 -0
  14. package/app/canvas/element-picker.ts +23 -0
  15. package/app/canvas/export-dialog.tsx +265 -0
  16. package/app/canvas/flow-canvas.tsx +65 -14
  17. package/app/canvas/frame-context-menu.tsx +61 -7
  18. package/app/canvas/frame-node.tsx +10 -11
  19. package/app/canvas/layout.ts +41 -22
  20. package/app/canvas/linked-element.tsx +196 -0
  21. package/app/canvas/live-page.ts +14 -0
  22. package/app/canvas/mentions.tsx +209 -0
  23. package/app/canvas/picked-box.tsx +21 -0
  24. package/app/canvas/removed-views-panel.tsx +4 -4
  25. package/app/canvas/request-node.tsx +151 -0
  26. package/app/canvas/review-panel.tsx +8 -3
  27. package/app/canvas/section-node.tsx +4 -133
  28. package/app/canvas/spec-margin.tsx +4 -1
  29. package/app/canvas/teammates-layer.tsx +205 -0
  30. package/app/canvas/text-layer.tsx +103 -17
  31. package/app/canvas/tool-cursors.ts +7 -6
  32. package/app/canvas/tool-icons.tsx +24 -56
  33. package/app/canvas/typing.ts +12 -0
  34. package/app/canvas/use-agent-changes.tsx +6 -2
  35. package/app/canvas/use-canvas-editor.ts +4 -2
  36. package/app/export/player-model.ts +159 -0
  37. package/app/export/player.tsx +198 -0
  38. package/app/export.html +31 -0
  39. package/app/export.tsx +9 -0
  40. package/app/frame/announce-refreshes.ts +21 -0
  41. package/app/frame/start-frame.tsx +50 -0
  42. package/app/frame/view-loads.ts +161 -0
  43. package/app/frame/views.ts +13 -49
  44. package/app/frame.tsx +2 -38
  45. package/app/i18n/locales/en/messages.po +145 -6
  46. package/app/i18n/locales/en/messages.ts +1 -1
  47. package/app/i18n/locales/pseudo/messages.po +144 -5
  48. package/app/i18n/locales/pseudo/messages.ts +1 -1
  49. package/app/icons/dex-glyphs.tsx +219 -0
  50. package/app/icons/glyphs.tsx +76 -80
  51. package/app/kit/use-flow.ts +2 -1
  52. package/app/live/canvas-teammates.ts +90 -0
  53. package/app/live/studio-api.ts +30 -20
  54. package/app/pages/canvas.tsx +18 -6
  55. package/app/pages/commands-settings.tsx +1 -1
  56. package/app/pages/render.tsx +39 -11
  57. package/app/shell/bell.tsx +15 -5
  58. package/app/shell/presence.tsx +123 -26
  59. package/app/shell/thread-list.tsx +25 -8
  60. package/app/shell/working-on.tsx +35 -3
  61. package/app/ui/prompt-editor.tsx +39 -11
  62. package/app/ui/reference.tsx +21 -8
  63. package/bin/sudio.mjs +1 -1
  64. package/dist/cli/commands/create.d.mts +5 -5
  65. package/dist/cli/commands/create.mjs +4 -4
  66. package/dist/cli/commands/export.d.mts +40 -0
  67. package/dist/cli/commands/export.mjs +66 -0
  68. package/dist/cli/commands/init.d.mts +2 -2
  69. package/dist/cli/commands/upgrade.mjs +1 -1
  70. package/dist/cli/help.d.mts +1 -1
  71. package/dist/cli/help.mjs +13 -7
  72. package/dist/cli/main.d.mts +42 -5
  73. package/dist/cli/main.mjs +1 -0
  74. package/dist/config/load.mjs +14 -2
  75. package/dist/config/project-files.d.mts +5 -0
  76. package/dist/config/project-files.mjs +10 -1
  77. package/dist/config/renamed.d.mts +7 -0
  78. package/dist/config/renamed.mjs +13 -1
  79. package/dist/content/commands.d.mts +11 -9
  80. package/dist/content/commands.mjs +22 -16
  81. package/dist/content/comments-log.mjs +2 -1
  82. package/dist/content/content.d.mts +11 -3
  83. package/dist/content/content.mjs +49 -15
  84. package/dist/content/element-words.d.mts +42 -0
  85. package/dist/content/element-words.mjs +112 -0
  86. package/dist/content/hosted-person.d.mts +31 -0
  87. package/dist/content/hosted-person.mjs +68 -0
  88. package/dist/content/merge-rules.d.mts +5 -0
  89. package/dist/content/merge-rules.mjs +17 -1
  90. package/dist/content/screenshot.mjs +9 -0
  91. package/dist/content/text-edit.d.mts +24 -14
  92. package/dist/content/text-edit.mjs +92 -81
  93. package/dist/content/text-replace.mjs +2 -26
  94. package/dist/content/thread-module.d.mts +2 -4
  95. package/dist/content/thread-module.mjs +4 -5
  96. package/dist/server/agents.d.mts +10 -0
  97. package/dist/server/agents.mjs +21 -6
  98. package/dist/server/canvas-presence.d.mts +22 -0
  99. package/dist/server/canvas-presence.mjs +160 -0
  100. package/dist/server/command-settings.mjs +1 -1
  101. package/dist/server/comments/actions.d.mts +0 -8
  102. package/dist/server/comments/actions.mjs +1 -9
  103. package/dist/server/comments/routes.mjs +10 -31
  104. package/dist/server/dev-server.mjs +35 -13
  105. package/dist/server/export/build.d.mts +15 -0
  106. package/dist/server/export/build.mjs +220 -0
  107. package/dist/server/export/page.d.mts +25 -0
  108. package/dist/server/export/page.mjs +40 -0
  109. package/dist/server/export/plugin.d.mts +31 -0
  110. package/dist/server/export/plugin.mjs +69 -0
  111. package/dist/server/export/run.d.mts +9 -0
  112. package/dist/server/export/run.mjs +61 -0
  113. package/dist/server/export/save.d.mts +7 -0
  114. package/dist/server/export/save.mjs +29 -0
  115. package/dist/server/hosted.d.mts +8 -0
  116. package/dist/server/hosted.mjs +78 -0
  117. package/dist/server/live-mirror.mjs +66 -10
  118. package/dist/server/live.mjs +28 -1
  119. package/dist/server/mcp.mjs +2 -0
  120. package/dist/server/me.d.mts +2 -0
  121. package/dist/server/me.mjs +8 -2
  122. package/dist/server/notices.d.mts +1 -1
  123. package/dist/server/notices.mjs +1 -1
  124. package/dist/server/own-copies.mjs +1 -1
  125. package/dist/server/people.d.mts +7 -2
  126. package/dist/server/people.mjs +6 -2
  127. package/dist/server/pictures.d.mts +1 -1
  128. package/dist/server/pictures.mjs +2 -2
  129. package/dist/server/prebundle.d.mts +32 -0
  130. package/dist/server/prebundle.mjs +115 -0
  131. package/dist/server/problems.d.mts +8 -0
  132. package/dist/server/problems.mjs +13 -0
  133. package/dist/server/requests.mjs +43 -30
  134. package/dist/server/source-stamp.d.mts +4 -3
  135. package/dist/server/source-stamp.mjs +60 -31
  136. package/dist/server/state.d.mts +19 -10
  137. package/dist/server/state.mjs +27 -18
  138. package/dist/server/thread-source.d.mts +8 -0
  139. package/dist/server/thread-source.mjs +24 -5
  140. package/dist/server/tools/export.d.mts +5 -0
  141. package/dist/server/tools/export.mjs +35 -0
  142. package/dist/server/tools/place-frame.mjs +16 -16
  143. package/dist/server/tools/thread-list.mjs +1 -1
  144. package/dist/server/vite.d.mts +9 -4
  145. package/dist/server/vite.mjs +63 -61
  146. package/dist/server/welcome.mjs +2 -1
  147. package/dist/setup/apply.d.mts +4 -0
  148. package/dist/setup/apply.mjs +5 -4
  149. package/dist/setup/create.mjs +5 -5
  150. package/dist/setup/design-system-checks.mjs +1 -6
  151. package/dist/setup/detect/workspace.d.mts +10 -10
  152. package/dist/setup/detect/workspace.mjs +10 -12
  153. package/dist/setup/doctor.d.mts +4 -1
  154. package/dist/setup/doctor.mjs +7 -5
  155. package/dist/setup/migrate/dex-folder.d.mts +61 -0
  156. package/dist/setup/migrate/dex-folder.mjs +544 -0
  157. package/dist/setup/migrate/files-folder.mjs +1 -1
  158. package/dist/setup/migrate/guides.mjs +1 -1
  159. package/dist/setup/migrate/migrations.mjs +4 -0
  160. package/dist/setup/migrate/setup-files.d.mts +5 -0
  161. package/dist/setup/migrate/setup-files.mjs +115 -0
  162. package/dist/setup/migrate/studio-state.d.mts +2 -2
  163. package/dist/setup/migrate/studio-state.mjs +4 -4
  164. package/dist/setup/placement.d.mts +1 -1
  165. package/dist/setup/placement.mjs +5 -4
  166. package/dist/setup/plan.d.mts +5 -5
  167. package/dist/setup/plan.mjs +8 -12
  168. package/dist/setup/project.mjs +1 -1
  169. package/dist/setup/prompts.d.mts +2 -1
  170. package/dist/setup/prompts.mjs +4 -3
  171. package/dist/setup/questions.mjs +3 -2
  172. package/dist/setup/starters.d.mts +1 -1
  173. package/dist/setup/starters.mjs +2 -2
  174. package/dist/setup/write.d.mts +15 -3
  175. package/dist/setup/write.mjs +23 -3
  176. package/dist/shared/canvas-core.d.mts +22 -7
  177. package/dist/shared/canvas-core.mjs +38 -10
  178. package/dist/shared/comments/routes.d.mts +3 -1
  179. package/dist/shared/comments/routes.mjs +4 -2
  180. package/dist/shared/export-core.d.mts +62 -0
  181. package/dist/shared/export-core.mjs +101 -0
  182. package/dist/shared/live-core.d.mts +2 -0
  183. package/dist/shared/live-core.mjs +6 -1
  184. package/dist/shared/live-presence.d.mts +57 -2
  185. package/dist/shared/live-presence.mjs +90 -4
  186. package/dist/shared/page-messages.d.mts +14 -1
  187. package/dist/shared/page-messages.mjs +30 -3
  188. package/dist/shared/people-core.d.mts +28 -0
  189. package/dist/shared/people-core.mjs +27 -1
  190. package/dist/shared/presence-core.d.mts +2 -0
  191. package/dist/shared/references-core.d.mts +4 -0
  192. package/dist/shared/references-core.mjs +12 -4
  193. package/dist/shared/studio-files.d.mts +9 -0
  194. package/dist/shared/studio-files.mjs +11 -2
  195. package/dist/shared/studio-routes.d.mts +13 -1
  196. package/dist/shared/threads-core.d.mts +27 -4
  197. package/dist/shared/threads-core.mjs +67 -12
  198. package/extension/dist/feedback.js +104 -294
  199. package/extension/dist/manifest.json +1 -1
  200. package/extension/dist/picker.js +104 -294
  201. package/package.json +2 -2
  202. package/src/cli/commands/create.ts +4 -4
  203. package/src/cli/commands/export.ts +78 -0
  204. package/src/cli/commands/upgrade.ts +1 -1
  205. package/src/cli/help.ts +13 -7
  206. package/src/cli/main.ts +1 -0
  207. package/src/config/load.ts +26 -2
  208. package/src/config/project-files.ts +15 -0
  209. package/src/config/renamed.ts +19 -1
  210. package/src/content/commands.ts +30 -18
  211. package/src/content/comments-log.ts +4 -1
  212. package/src/content/content.ts +64 -16
  213. package/src/content/element-words.ts +175 -0
  214. package/src/content/hosted-person.ts +107 -0
  215. package/src/content/merge-rules.ts +29 -0
  216. package/src/content/screenshot.ts +14 -0
  217. package/src/content/text-edit.ts +172 -105
  218. package/src/content/text-replace.ts +3 -32
  219. package/src/content/thread-module.ts +2 -4
  220. package/src/content/trash.ts +1 -1
  221. package/src/server/agents.ts +48 -17
  222. package/src/server/canvas-presence.ts +237 -0
  223. package/src/server/channel.ts +1 -1
  224. package/src/server/command-settings.ts +1 -1
  225. package/src/server/comments/actions.ts +0 -19
  226. package/src/server/comments/routes.ts +9 -54
  227. package/src/server/dev-server.ts +66 -26
  228. package/src/server/export/build.ts +310 -0
  229. package/src/server/export/page.ts +85 -0
  230. package/src/server/export/plugin.ts +138 -0
  231. package/src/server/export/run.ts +79 -0
  232. package/src/server/export/save.ts +38 -0
  233. package/src/server/hosted.ts +113 -0
  234. package/src/server/live-mirror.ts +93 -8
  235. package/src/server/live.ts +46 -1
  236. package/src/server/machine-update.ts +3 -3
  237. package/src/server/mcp.ts +2 -0
  238. package/src/server/me.ts +10 -1
  239. package/src/server/notices.ts +2 -2
  240. package/src/server/people.ts +11 -2
  241. package/src/server/pictures.ts +2 -2
  242. package/src/server/prebundle.ts +230 -0
  243. package/src/server/presence.ts +1 -1
  244. package/src/server/problems.ts +11 -0
  245. package/src/server/requests.ts +55 -40
  246. package/src/server/roster.ts +1 -1
  247. package/src/server/saved.ts +1 -1
  248. package/src/server/source-stamp.ts +118 -37
  249. package/src/server/state.ts +53 -31
  250. package/src/server/thread-source.ts +35 -3
  251. package/src/server/tools/export.ts +56 -0
  252. package/src/server/tools/place-frame.ts +23 -15
  253. package/src/server/tools/thread-list.ts +1 -1
  254. package/src/server/updates.ts +2 -2
  255. package/src/server/vite.ts +106 -110
  256. package/src/server/welcome.ts +3 -1
  257. package/src/setup/apply.ts +8 -5
  258. package/src/setup/create.ts +10 -10
  259. package/src/setup/design-system-checks.ts +1 -6
  260. package/src/setup/detect/workspace.ts +20 -21
  261. package/src/setup/doctor.ts +13 -6
  262. package/src/setup/migrate/dex-folder.ts +842 -0
  263. package/src/setup/migrate/files-folder.ts +1 -1
  264. package/src/setup/migrate/guides.ts +3 -1
  265. package/src/setup/migrate/migrations.ts +8 -2
  266. package/src/setup/migrate/setup-files.ts +198 -0
  267. package/src/setup/migrate/studio-state.ts +12 -10
  268. package/src/setup/own-app.ts +1 -1
  269. package/src/setup/placement.ts +7 -6
  270. package/src/setup/plan.ts +13 -18
  271. package/src/setup/project.ts +2 -2
  272. package/src/setup/prompts.ts +5 -4
  273. package/src/setup/questions.ts +6 -3
  274. package/src/setup/starters.ts +3 -3
  275. package/src/setup/write.ts +34 -3
  276. package/src/shared/canvas-core.ts +48 -9
  277. package/src/shared/comments/routes.ts +3 -1
  278. package/src/shared/export-core.ts +198 -0
  279. package/src/shared/live-core.ts +8 -0
  280. package/src/shared/live-presence.ts +171 -2
  281. package/src/shared/page-messages.ts +38 -2
  282. package/src/shared/people-core.ts +44 -0
  283. package/src/shared/presence-core.ts +2 -0
  284. package/src/shared/references-core.ts +22 -3
  285. package/src/shared/studio-files.ts +15 -1
  286. package/src/shared/studio-routes.ts +11 -1
  287. package/src/shared/threads-core.ts +132 -10
  288. package/templates/methods/explore.md +1 -1
  289. package/templates/methods/handoff.md +1 -1
  290. package/templates/methods/review.md +2 -1
  291. package/templates/rules/canvas-frames.md +6 -3
  292. package/templates/rules/commands.md +1 -0
  293. package/templates/rules/prototypes.md +1 -1
  294. package/templates/rules/studio.md +17 -11
  295. package/templates/skills/comprehend/SKILL.md +56 -0
  296. package/templates/skills/distill/SKILL.md +172 -0
  297. package/templates/skills/export-prototype/SKILL.md +35 -0
  298. package/templates/skills/riff/SKILL.md +21 -0
  299. package/templates/skills/riff-deep/SKILL.md +40 -0
  300. package/templates/skills/riff-max/SKILL.md +46 -0
  301. package/templates/skills/riff-state/SKILL.md +45 -0
  302. package/templates/skills/riff-up/SKILL.md +38 -0
  303. package/templates/skills/riff-wide/SKILL.md +40 -0
  304. package/templates/starters/standalone/README.md +1 -1
  305. package/templates/starters/turborepo/README.md +2 -2
  306. package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
  307. package/templates/starters/vite/README.md +1 -1
@@ -13,6 +13,8 @@ export interface PresenceTarget {
13
13
  /** An entry in a studio's presence file: which Agent is working on what. */
14
14
  export interface PresenceEntry extends PresenceTarget {
15
15
  agent: string;
16
+ /** A teammate's colour, for entries that came from the live room. */
17
+ color?: string;
16
18
  note?: string;
17
19
  session: string;
18
20
  /** When it was last marked, as an ISO date. */
@@ -29,14 +29,33 @@ const SPECIAL_RE = /[\\^$.*+?()[\]{}|/-]/g;
29
29
 
30
30
  const escaped = (char: string) => char.replace(SPECIAL_RE, "\\$&");
31
31
 
32
- /** Each trigger, then a name: at the start or after a space, then a space or the end. */
32
+ /**
33
+ * Each trigger, then a name: at the start, after a space or an opening
34
+ * bracket; then a space or the end, past any closing punctuation ("@ana,"
35
+ * and "(/break)" name them, "/a.b" does not).
36
+ */
33
37
  const tokens = (chars: readonly string[]) =>
34
- new RegExp(`(^|\\s)(${chars.map(escaped).join("|")})(${NAME})(?=\\s|$)`, "g");
38
+ new RegExp(
39
+ `(^|[\\s(])(${chars.map(escaped).join("|")})(${NAME})(?=[.,;:!?)]*(?:\\s|$))`,
40
+ "g"
41
+ );
35
42
 
36
43
  /** The text written for a reference: "/break". */
37
44
  export const referenceText = ({ char, id }: Reference): string =>
38
45
  `${char}${id}`;
39
46
 
47
+ /** The character that names a person: "@ana". */
48
+ export const MENTION = "@";
49
+
50
+ /** The people a message names, by their slugs, each once. */
51
+ export const mentionsIn = (text: string): string[] => [
52
+ ...new Set(
53
+ referenceParts(text, { [MENTION]: undefined }).flatMap((part) =>
54
+ "reference" in part ? [part.reference.id] : []
55
+ )
56
+ ),
57
+ ];
58
+
40
59
  /** A message split around the references it makes, of those known. */
41
60
  export function referenceParts(
42
61
  text: string,
@@ -80,7 +99,7 @@ export function triggerAt(
80
99
  return;
81
100
  }
82
101
  const match = new RegExp(
83
- `(?:^|\\s)(${chars.map(escaped).join("|")})([a-z0-9-]*)$`
102
+ `(?:^|[\\s(])(${chars.map(escaped).join("|")})([A-Za-z0-9-]*)$`
84
103
  ).exec(before);
85
104
  if (!(match?.[1] !== undefined)) {
86
105
  return;
@@ -11,7 +11,10 @@
11
11
  // people/<slug>/avatar.png a person's own picture, or avatar.jpg
12
12
  // (avatar-file.ts)
13
13
  // files/ every file (prototypes-core.ts)
14
- // .studio/ the studio's machine-local state (server/state.ts)
14
+ // skills/ the team's own skills, the / menu's commands
15
+ // (content/commands.ts)
16
+ // .local/ what only this machine has, never committed
17
+ // (server/state.ts)
15
18
  //
16
19
  // live-core.ts keeps its own list of the files a live workspace shares; see
17
20
  // there for why.
@@ -36,6 +39,15 @@ export interface Contributor {
36
39
  slug: string;
37
40
  }
38
41
 
42
+ /**
43
+ * The Dex folder's name: `dex/` in a project, `apps/web/dex/` in an app of
44
+ * a workspace. An app of its own (`apps/dex`) is its Dex folder.
45
+ */
46
+ export const DEX_FOLDER = "dex";
47
+
48
+ /** Its name before, `studio/`: `dex upgrade` moves it to DEX_FOLDER. */
49
+ export const OLD_DEX_FOLDER = "studio";
50
+
39
51
  /** Where each of the studio's own files is, relative to its content root. */
40
52
  export const STUDIO_FILES = {
41
53
  /** Who works in the studio, and the git users that are them. */
@@ -48,6 +60,8 @@ export const STUDIO_FILES = {
48
60
  context: "context",
49
61
  /** Each person's folder: people/<slug>/guidelines.md. */
50
62
  people: "people",
63
+ /** The team's own skills: skills/<name>/SKILL.md. */
64
+ skills: "skills",
51
65
  } as const;
52
66
 
53
67
  /** A person's own guidelines, for their agents, on top of the workspace's. */
@@ -465,6 +465,11 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes>
465
465
  * JSON: read with an EventSource.
466
466
  */
467
467
  events: { GET: unknown };
468
+ /**
469
+ * ?prototype=<name>: its frames as an exported prototype (export-core.ts),
470
+ * a zip (not JSON) named for the file. POST takes an ExportChoice.
471
+ */
472
+ export: { POST: Blob };
468
473
  /**
469
474
  * The browser extension, as a zip (not JSON) of the folder Chrome loads
470
475
  * unpacked, its files at the root, named EXTENSION_FILE.
@@ -512,6 +517,11 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes>
512
517
  * they make something.
513
518
  */
514
519
  newcomer: Own["contributor"] | null;
520
+ /**
521
+ * In Dex in the browser, hosted for the workspace: viewers look and
522
+ * comment, and never change the files.
523
+ */
524
+ viewer?: true;
515
525
  };
516
526
  };
517
527
  /**
@@ -527,7 +537,7 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes>
527
537
  saved: { frame: string; name: string }[];
528
538
  };
529
539
  };
530
- /** The workspace's contributors, the latest to commit first. */
540
+ /** The workspace's contributors, the latest to commit first; ?commits=0 skips git's log. */
531
541
  people: { GET: { people: Person[] } };
532
542
  /** A JPEG, or nothing (204) when the frame's stamp has not changed. */
533
543
  picture: { POST: Blob };
@@ -20,7 +20,13 @@
20
20
  // A thread can carry a wireframe (see sketch-core.ts): boxes drawn over a
21
21
  // frame, or in an empty cell for a new view, for an agent to build.
22
22
 
23
- import { isSpecPath, VIEWPORTS, type Viewport } from "./canvas-core.ts";
23
+ import {
24
+ isSpecPath,
25
+ type PageSize,
26
+ requestCell,
27
+ VIEWPORTS,
28
+ type Viewport,
29
+ } from "./canvas-core.ts";
24
30
  import { isOneOf, isRecord, isText } from "./checks.ts";
25
31
  import { prototypeFiles } from "./prototypes-core.ts";
26
32
  import type { Sketch } from "./sketch-core.ts";
@@ -154,10 +160,20 @@ export type ThreadTarget =
154
160
  viewport?: Viewport;
155
161
  }
156
162
  | {
163
+ /**
164
+ * With no row: the row its new row goes right above, as the + on the
165
+ * line between two rows asks. None puts the new row below the others.
166
+ */
167
+ above?: string;
157
168
  kind: "view";
158
169
  /** The row to add it to; leave out for a new row (a new iteration). */
159
170
  row?: string;
160
171
  section: string;
172
+ /**
173
+ * The size its frame takes, set by resizing the request on the canvas.
174
+ * Left out, it takes the size of the frame before it.
175
+ */
176
+ size?: PageSize;
161
177
  step: number;
162
178
  }
163
179
  | (SpecQuote & {
@@ -215,6 +231,9 @@ export interface ThreadReaction {
215
231
  */
216
232
  export type ChangePlace = Extract<ThreadTarget, { kind: "element" | "frame" }>;
217
233
 
234
+ /** A request for a new view's target: the cell it waits in, and its size. */
235
+ export type ViewTarget = Extract<ThreadTarget, { kind: "view" }>;
236
+
218
237
  /** What changed, or why not, when the thread was resolved or dismissed. */
219
238
  export interface ThreadResolution {
220
239
  agent?: boolean;
@@ -309,6 +328,11 @@ export interface ThreadChange {
309
328
  /** The agent session making the change, kept on its reaction. */
310
329
  session?: string;
311
330
  status?: ThreadStatus;
331
+ /**
332
+ * A request for a new view, moved or resized on the canvas by a person:
333
+ * the cell it now waits in, and the size its frame takes.
334
+ */
335
+ target?: ThreadTarget;
312
336
  via?: string;
313
337
  /** Resolving: where the change landed, kept with the note. */
314
338
  where?: ChangePlace;
@@ -316,7 +340,8 @@ export interface ThreadChange {
316
340
 
317
341
  /**
318
342
  * A person's change to a thread, before the studio adds who they are: a
319
- * reply, a reaction, who it is for, or its status.
343
+ * reply, a reaction, who it is for, its status, or where a request for a
344
+ * new view waits.
320
345
  */
321
346
  export type PersonChange = Pick<
322
347
  ThreadChange,
@@ -329,6 +354,7 @@ export type PersonChange = Pick<
329
354
  | "react"
330
355
  | "remove"
331
356
  | "status"
357
+ | "target"
332
358
  >;
333
359
 
334
360
  /**
@@ -420,7 +446,17 @@ const MAX_REACTION = 8;
420
446
  * for; a longer one is kept, and shortened where it is shown.
421
447
  */
422
448
  const MAX_NOTE = 2000;
423
- const MENTION_RE = /(?:^|\s)@(?:agent|claude|codex|cursor)\b/i;
449
+ /** The names "@" calls an agent by: no frame goes by one in a comment. */
450
+ export const AGENT_NAMES: readonly string[] = [
451
+ "agent",
452
+ "claude",
453
+ "codex",
454
+ "cursor",
455
+ ];
456
+ const MENTION_RE = new RegExp(
457
+ `(?:^|\\s)@(?:${AGENT_NAMES.join("|")})(?![\\w-])`,
458
+ "i"
459
+ );
424
460
  /** Why an agent cannot acknowledge a thread another session has claimed. */
425
461
  export const CLAIMED_PROBLEM = "Another agent is on this thread.";
426
462
  /** Why an agent cannot let go of a thread it does not hold. */
@@ -710,6 +746,12 @@ export function changeConflicts(
710
746
  if (change.hidden !== undefined && !thread.review) {
711
747
  return [HIDDEN_PROBLEM];
712
748
  }
749
+ if (
750
+ change.target !== undefined &&
751
+ (change.agent || thread.target.kind !== "view" || isClosed(thread))
752
+ ) {
753
+ return [MOVE_PROBLEM];
754
+ }
713
755
  if (!change.agent) {
714
756
  return ownMessageProblems(thread, change);
715
757
  }
@@ -770,6 +812,10 @@ export const isOwnMessage = (
770
812
  const HIDDEN_PROBLEM =
771
813
  "Only a review's comments can be hidden from the published site.";
772
814
 
815
+ /** Only a person moves a request for a new view, and only until it is built. */
816
+ const MOVE_PROBLEM =
817
+ "Only a person moves or resizes a request for a new view, and only while it is still to be built.";
818
+
773
819
  const ownMessageProblems = (thread: Thread, change: ThreadChange): string[] => {
774
820
  if (!(isText(change.edit) || change.remove)) {
775
821
  return [];
@@ -805,17 +851,52 @@ const changeMessage = (
805
851
  }
806
852
  };
807
853
 
854
+ /** Whether a value is a size in pixels: a positive width and height. */
855
+ const isSize = (value: unknown): value is PageSize =>
856
+ isRecord(value) &&
857
+ [value.width, value.height].every(
858
+ (side) => typeof side === "number" && Number.isFinite(side) && side > 0
859
+ );
860
+
861
+ /** What a request for a new view, moved or resized, must say. */
862
+ const movedRequestProblems = (target: unknown): string[] => {
863
+ if (!(isRecord(target) && target.kind === "view")) {
864
+ return ["Only a request for a new view moves: give its cell, as a view's."];
865
+ }
866
+ const { above, row, section, size, step } = target;
867
+ return [
868
+ ...(isText(section) ? [] : ["A request for a view names its section."]),
869
+ ...(row === undefined || isText(row)
870
+ ? []
871
+ : ["A request's row is a row's id; leave it out for a new row."]),
872
+ ...(above === undefined || isText(above)
873
+ ? []
874
+ : ["A new row's `above` is the id of the row it goes above."]),
875
+ ...(Number.isInteger(step) && Number(step) >= 1
876
+ ? []
877
+ : ["A request for a view needs the step it fills."]),
878
+ ...(size === undefined || isSize(size)
879
+ ? []
880
+ : ["A request's size is a width and a height in pixels."]),
881
+ ];
882
+ };
883
+
808
884
  /** Problems with a change to a thread, empty when it is fine. */
809
885
  export function changeProblems({
810
886
  status,
811
887
  for: audience,
812
888
  hidden,
889
+ target,
813
890
  }: {
814
891
  for?: unknown;
815
892
  hidden?: unknown;
816
893
  status?: unknown;
894
+ target?: unknown;
817
895
  }): string[] {
818
896
  const problems: string[] = [];
897
+ if (target !== undefined) {
898
+ problems.push(...movedRequestProblems(target));
899
+ }
819
900
  if (hidden !== undefined && typeof hidden !== "boolean") {
820
901
  problems.push("Hidden is true or false.");
821
902
  }
@@ -846,6 +927,7 @@ export function changeThread<T extends Thread>(
846
927
  at,
847
928
  };
848
929
  changeMessage(thread, change, at);
930
+ moveRequest(thread, change.target);
849
931
  addReaction(thread, change, who);
850
932
  keepResolution(thread, change, who);
851
933
  addMessage(thread, change, at);
@@ -856,6 +938,25 @@ export function changeThread<T extends Thread>(
856
938
  return thread;
857
939
  }
858
940
 
941
+ /**
942
+ * A request for a new view, moved or resized: the cell it waits in (for a
943
+ * new row, the row it goes above) and the size its frame takes, nothing else.
944
+ */
945
+ const moveRequest = (thread: Thread, target: ThreadTarget | undefined) => {
946
+ if (target?.kind !== "view" || thread.target.kind !== "view") {
947
+ return;
948
+ }
949
+ const { size } = target;
950
+ thread.target = given({
951
+ kind: "view",
952
+ ...requestCell(target),
953
+ size: size && {
954
+ width: Math.round(size.width),
955
+ height: Math.round(size.height),
956
+ },
957
+ });
958
+ };
959
+
859
960
  /** Leave an imported review's thread off the published site, or show it. */
860
961
  const setHidden = (thread: Thread, hidden: boolean | undefined) => {
861
962
  if (hidden === undefined || !thread.review) {
@@ -1240,6 +1341,28 @@ const frameFile = (
1240
1341
  const ownCanvas = (files: ReturnType<typeof prototypeFiles>) =>
1241
1342
  files && `${files.people}/<you>/canvas.json`;
1242
1343
 
1344
+ /** Where a request's new row goes, as an agent reads it. */
1345
+ const newRowWhere = (above?: string) =>
1346
+ above
1347
+ ? `a new row, right above row "${above}"`
1348
+ : "a new row at the end of the section";
1349
+
1350
+ /**
1351
+ * A request for a new view, as an agent reads it: the cell to put its frame
1352
+ * in, and the size to put it at when the person gave it one.
1353
+ */
1354
+ const requestWhere = (
1355
+ { above, row, section, size, step }: ViewTarget,
1356
+ files: ReturnType<typeof prototypeFiles>
1357
+ ): Record<string, unknown> => ({
1358
+ 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.`,
1359
+ canvas: ownCanvas(files),
1360
+ section,
1361
+ row: row ?? newRowWhere(above),
1362
+ step,
1363
+ ...(size ? { size } : {}),
1364
+ });
1365
+
1243
1366
  /** Where a thread is, as an agent reads it: what it is on, and its file. */
1244
1367
  const whereOf = (
1245
1368
  target: ThreadTarget,
@@ -1301,13 +1424,7 @@ const whereOf = (
1301
1424
  point: target.point,
1302
1425
  };
1303
1426
  case "view":
1304
- return {
1305
- 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.",
1306
- canvas: ownCanvas(files),
1307
- section: target.section,
1308
- row: target.row ?? "a new row at the end of the section",
1309
- step: target.step,
1310
- };
1427
+ return requestWhere(target, files);
1311
1428
  default:
1312
1429
  return {
1313
1430
  what: "A comment on the file as a whole.",
@@ -1391,6 +1508,11 @@ const publicTarget = (target: ThreadTarget): ThreadTarget => {
1391
1508
  section: target.section,
1392
1509
  step: target.step,
1393
1510
  row: target.row,
1511
+ above: target.above,
1512
+ size: target.size && {
1513
+ width: target.size.width,
1514
+ height: target.size.height,
1515
+ },
1394
1516
  });
1395
1517
  case "spec":
1396
1518
  return given({
@@ -1,5 +1,5 @@
1
1
  ---
2
- when: Exploring: variants, options, directions, riffs
2
+ when: Exploring: variants, options, directions
3
3
  ---
4
4
 
5
5
  # Method: explore directions
@@ -20,7 +20,7 @@ that agent: precise, short, pointing at files.
20
20
  ```md
21
21
  # Handoff: <file title>
22
22
 
23
- **Build from:** `<studio folder>/files/<slug>/people/<person>/views/<view>.tsx`
23
+ **Build from:** `<Dex folder>/files/<slug>/people/<person>/views/<view>.tsx`
24
24
  **Production target:** <screen, route or starter it changes>
25
25
 
26
26
  ## What changes
@@ -23,7 +23,8 @@ design changes; you never apply one they have not approved.
23
23
  near that spot.
24
24
  - **Requests for new views.** People click a dashed cell on the canvas and
25
25
  describe a screen. The thread's target has `kind: "view"` and the cell
26
- (section, row, step) where it belongs.
26
+ (section, row, step) where it belongs; with no row, a new row, right above
27
+ the row `above` names when it has one.
27
28
  - **Wireframes.** People draw boxes for a new view, or over a frame to change
28
29
  it. The thread has a `wireframe` describing each box; build it from the
29
30
  design system (see `rules/canvas-frames.md`).
@@ -74,9 +74,12 @@ make by drawing on the canvas. `rules/canvas.md` has the grid they sit in.
74
74
 
75
75
  People can click a dashed cell and ask for a new view there. That arrives as a
76
76
  thread whose target has `kind: "view"`, with its section id (`section`), row (or none,
77
- for a new row at the end) and step. While it is open, the cell shows the request.
78
- Build the view, add a frame for it to `canvas.json` in exactly that cell, then
79
- resolve the thread (see `methods/review.md`).
77
+ for a new row: right above the row `above` names, else at the end) and step, and a
78
+ `size` when the person resized it. While it is open, the cell shows the request, and
79
+ people can drag it to another cell or resize it: read the thread again before you
80
+ place the frame. Build the view, add a frame for it to `canvas.json` in exactly that
81
+ cell, at that size when it has one (`place_frame` with the thread's id does both),
82
+ then resolve the thread (see `methods/review.md`).
80
83
 
81
84
  ## Wireframes
82
85
 
@@ -26,5 +26,6 @@ stops the command and names the nearest one: fix it and run it again.
26
26
  | `npx dex scope --person <slug>` | Lists changed files outside that contributor's folder and files' shared parts. |
27
27
  | `npx dex presence --slug <file> --view <view> --agent "<name>" [--clear]` | Shows the team which view you are editing. Claude Code does this automatically. |
28
28
  | `npx dex snapshot --slug <file>` | Snapshots every canvas frame in light and dark, as the `snapshot` tool does; lists errors and overflow. Needs Dex running. `--view <view>` takes only that view's frames: what a sub-agent checks. |
29
+ | `npx dex export --slug <file> [--sections <ids> \| --frames <keys>] [--kind clickable\|pages\|content\|source] [--flows]` | When someone asks to send, share or zip frames as a prototype: a zip in their Downloads that opens by double-click, offline, as the `export` tool makes. Prepare the views first as the `export-prototype` skill says; never write the HTML or a bundler config yourself. |
29
30
  | `npx dex dev` | Serves Dex at http://localhost:3008, or the next free port when another checkout's Dex holds it. |
30
31
  | `npx dex stop` | Stops this checkout's Dex, and no other. Never stop Dex with `pkill`, `killall` or a `kill` of a pid you found by name: a pattern such as `pkill -f "dex dev"` stops every checkout's Dex on the machine. |
@@ -164,7 +164,7 @@ person is waiting on the canvas while you check.
164
164
  and overflow. Fix what you find in place, then look again, until a look
165
165
  finds nothing. Then run `npx dex check` and `npx tsc --noEmit` in the
166
166
  Dex folder. Without MCP, `npx dex snapshot --slug <slug> --view <view>`
167
- takes the same snapshots, writes them to `.studio/snapshots/<slug>/` and
167
+ takes the same snapshots, writes them to `.local/snapshots/<slug>/` and
168
168
  lists their problems.
169
169
  - **Before you say a file is ready for review or handoff.** The full
170
170
  pass over every frame, whatever changed: `npx dex snapshot --slug
@@ -4,7 +4,8 @@ when: A change to Dex itself: its pages, canvas, scripts, rules or methods
4
4
 
5
5
  # Working on Dex itself
6
6
 
7
- Dex's configuration and shared content. If it is not clear whether a
7
+ Dex's configuration and shared content, in the Dex folder (`dex/`, or the
8
+ app of its own in a workspace). If it is not clear whether a
8
9
  request is an idea for the product or a change to Dex itself, ask. These
9
10
  affect everyone, so they need the normal engineering workflow: a branch,
10
11
  a pull request and review.
@@ -13,13 +14,14 @@ a pull request and review.
13
14
 
14
15
  | Path | What it is |
15
16
  | -------------------- | -------------------------------------------------------------------------- |
16
- | `dex.config.ts` | All settings, in one file: content folder, port, build output, Vite plugins, `designSystem` (the components, imports, styles, guide and contributing doc views build with, and the provider that wraps every view) and `ui` (title, subtitle, your own interface components, and `primitives`: your components for Dex's buttons and menus). |
17
+ | `dex.config.ts` | All settings, in one file: where the Dex folder is (`content`), port, build output, Vite plugins, `designSystem` (the components, imports, styles, guide and contributing doc views build with, and the provider that wraps every view) and `ui` (title, subtitle, your own interface components, and `primitives`: your components for Dex's buttons and menus). |
17
18
  | `design-system/` | Studios set up before the design system moved into `dex.config.ts`: the adapter (`index.ts`) and styles (`styles.css`). `npx dex upgrade` moves them. |
18
19
  | `rules/`, `methods/` | Only when the team has its own: a file here replaces the installed one of the same name. The installed ones come with `@dexhq/canvas`, in its `templates/` folder, where agents read them (the MCP server's `brief` names each); Dex shows them in Settings, under Reference. |
19
20
  | `DESIGN.md` | The workspace guidelines for every file, edited under Guidelines, in Dex's sidebar. |
20
21
  | `context/` | Team context the critique method reads. |
21
22
  | `people/<you>/guidelines.md` | Each person's own guidelines, edited under Your guidelines, in Dex's sidebar. `brief` names them only to that person's agents. Never change someone else's. |
22
23
  | `contributors.json` | Who works here, matched to git users. Dex makes it when it first starts. |
24
+ | `skills/` | The team's own skills, the commands its `/` menu offers: `skills/<name>/SKILL.md`. Settings, under Commands, saves them here. |
23
25
  | `tsconfig.json` | Extends the project's, so views import as the app does. Never add `paths` here: they replace the project's. |
24
26
  | `studio.cloud.json` | The cloud workspace this Dex is linked to (Team plan). No secrets; commit it. |
25
27
 
@@ -35,7 +37,7 @@ package, or ask its maintainers.
35
37
  `DESIGN.md`, `context/*.md` and your `people/<you>/guidelines.md`
36
38
  (guidelines), `contributors.json`, new
37
39
  files made the same way as `npx dex new`, and a person's own views
38
- that no canvas shows, moved to `.studio/trash/` from the file's archive. All
40
+ that no canvas shows, moved to `.local/trash/` from the file's archive. All
39
41
  other content goes through you.
40
42
  - Comments are answered through `npx dex mcp`, which setup registers in
41
43
  `.mcp.json` (at the workspace root in a monorepo, where agents start, with
@@ -46,20 +48,24 @@ package, or ask its maintainers.
46
48
  hook in `.claude/settings.json` adds what changed in Dex (the
47
49
  workspace guidelines, your guidelines, the open file, new feedback) to the next prompt, as the
48
50
  Dex's tools do to their results.
49
- - Presence lives in `.studio/presence.json`. Claude Code writes it through
51
+ - Presence lives in `.local/presence.json`. Claude Code writes it through
50
52
  the `dex hook` entries in `.claude/settings.json`; other agents use
51
53
  `npx dex presence`. Entries expire after two minutes.
52
- - `.studio/` is Dex's own machine-local state (gitignored): presence,
53
- snapshots, the Watch switch, the open file, connected agents, the
54
- trash and Vite's cache. Its `README.md` says what each file is. Never edit or commit
55
- it; deleting it is safe.
54
+ - `.local/` is Dex's own machine-local state (gitignored, by the project's
55
+ `.gitignore` and its own): presence, snapshots, the Watch switch, the
56
+ open file, connected agents and the trash. Its `README.md` says what each
57
+ file is. Never edit or commit it; deleting it is safe.
56
58
  - To update Dex, update `@dexhq/canvas` with the package manager. Rules
57
59
  and methods update with it. A Dex set up by an older version
58
- (it has `design-system/index.ts`, `studio.lock.json`, `.presence.json` or
60
+ (its Dex folder is `studio/`, or it has `.studio/`, `.dex/skills/`,
61
+ `design-system/index.ts`, `studio.lock.json`, `.presence.json` or
59
62
  `.snapshots/`, or a generated `AGENTS.md`) runs
60
63
  `npx dex upgrade` once, after `npx dex upgrade --dry-run` shows the
61
- person what moves: the design system into `dex.config.ts` and its prose
62
- into `DESIGN.md`, presence and snapshots into `.studio/`, and copied rules,
64
+ person what moves: `studio/` to `dex/` (with what names it: the config,
65
+ `.gitignore`, agents' configs), `.studio/` to `.local/`, `.dex/skills/`
66
+ to `skills/` in the Dex folder, the design system into `dex.config.ts`
67
+ and its prose into `DESIGN.md`, presence and snapshots into `.local/`,
68
+ and copied rules,
63
69
  the generated `AGENTS.md`, its `CLAUDE.md` line and the old Claude skill
64
70
  nobody edited away. Exit code 2 means the
65
71
  config must be edited by hand: show the person the printed snippet.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: comprehend
3
+ description: "First-time readers at several model strengths say what they think it is"
4
+ ---
5
+
6
+ Find out what the element in focus, and the screen it sits on, say to
7
+ someone seeing the product for the first time, from a picture alone. This
8
+ surfaces insight: change nothing in the design.
9
+
10
+ ## Readers
11
+
12
+ Take a screenshot of the screen, in the state it is in. Send one
13
+ **reader** per model strength you can run, all at once: a sub-agent each,
14
+ from the smallest model to the strongest (in Claude Code: haiku, sonnet,
15
+ opus, and fable where you have it). Four by default; the request can name
16
+ fewer or others. A strength is a reader's depth of attention: what only
17
+ the strongest reader gets, a hurried person may miss.
18
+
19
+ A reader sees **pixels only**: the screenshot, and no files, code or
20
+ markup. Point it at the element by what is visible, its words, shape and
21
+ place on the screen ("the round button with a plus, bottom right"), never
22
+ by a selector, a component's name or a file's. Without sub-agents, give
23
+ each reader the picture in turn and write as each, from the smallest up,
24
+ before reading the next.
25
+
26
+ Give each reader this brief, with the element filled in:
27
+
28
+ > You are using this product for the first time, in a user interview,
29
+ > thinking aloud. Look at the screenshot and answer in the first person,
30
+ > as you would speak: "I think this is…", "I'd expect this to…", "I'm not
31
+ > sure whether…".
32
+ >
33
+ > 1. What you think this product and this screen are for, and who they are for.
34
+ > 2. What you think <the element> is, and what happens when you use it.
35
+ > 3. Three other things on the screen and what you think each one does.
36
+ > 4. Where you hesitate, and what you would do first.
37
+ > 5. The questions you would ask the interviewer.
38
+ >
39
+ > Say what you believe, even when unsure, and how sure you are.
40
+
41
+ ## Playback
42
+
43
+ Compare the readers, element by element. Done when every element any
44
+ reader named is placed in one of these, in plain words:
45
+
46
+ - **Clear**: every reader read it the same way, and as the design means it.
47
+ - **Misread**: a reader was sure of something it is not. Quote them.
48
+ - **Divided**: readers disagreed. Say which strength read what.
49
+ - **Missed**: only the stronger readers noticed it, or none did.
50
+
51
+ Then the questions people would ask, merged and in their words.
52
+
53
+ Write it up as one document, titled "Comprehend: <screen>", with each
54
+ reader's think-aloud in full under the playback, and save it beside the
55
+ work, where the project keeps documents. Reply with the headline: what
56
+ the screen read as, and the biggest misread.