@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
@@ -1,3 +1,4 @@
1
+ import { isRecord, isText } from "./checks.mjs";
1
2
  import { isFrameUid, legacyFrameUid, newFrameUid, stepsOf, uniqueId } from "./canvas-core.mjs";
2
3
  //#region src/shared/people-core.ts
3
4
  const UNDATED = "~";
@@ -134,6 +135,31 @@ function withoutOthersRows(canvas, person) {
134
135
  }) };
135
136
  }
136
137
  /**
138
+ * The part of a save that is the person's to write. A save made on no
139
+ * revision has no read behind it, so a change it makes to someone else's
140
+ * section goes into a copy of the person's (copyOnEdit); a save on a
141
+ * revision was made so already. Either way the rows others keep in the
142
+ * person's sections stay out: had they gone into the person's file, each
143
+ * read would show them once more beside their own.
144
+ */
145
+ function savedPart(onDisk, sent, person, { onRevision }) {
146
+ return withoutOthersRows(onRevision ? sent : copyOnEdit(onDisk, sent, person), person);
147
+ }
148
+ /**
149
+ * Rows in a person's own file that name someone else as their author, by
150
+ * section and row id. No save writes one: each is a copy of a teammate's
151
+ * row, which a read shows beside the teammate's own. A file of the wrong
152
+ * shape has none: the canvas's checks report it.
153
+ */
154
+ function othersRowsIn(file, person) {
155
+ const listed = (value, key) => isRecord(value) && Array.isArray(value[key]) ? value[key].filter(isRecord) : [];
156
+ return listed(file, "sections").flatMap((section) => listed(section, "rows").flatMap(({ id, author }) => isText(author) && author !== person ? [{
157
+ section: String(section.id),
158
+ row: String(id),
159
+ author
160
+ }] : []));
161
+ }
162
+ /**
137
163
  * Each person's rows in someone else's section, as the canvas shows them:
138
164
  * kept in a section of their own file (`copyOf` the other), shown as rows of
139
165
  * the other, under their name. A copy whose section is gone shows on its own.
@@ -466,4 +492,4 @@ function copyOnEdit(before, after, person, touched) {
466
492
  return { sections };
467
493
  }
468
494
  //#endregion
469
- export { combineCanvases, copyOnEdit, inPeopleOrder, isOthers, isOthersRow, labelAuthors, liftRows, othersChanged, ownRow, ownSections, rowOwner, withFrameUids, withoutOthersRows };
495
+ export { combineCanvases, copyOnEdit, inPeopleOrder, isOthers, isOthersRow, labelAuthors, liftRows, othersChanged, othersRowsIn, ownRow, ownSections, rowOwner, savedPart, withFrameUids, withoutOthersRows };
@@ -8,6 +8,8 @@ export interface PresenceTarget {
8
8
  /** An entry in a studio's presence file: which Agent is working on what. */
9
9
  export interface PresenceEntry extends PresenceTarget {
10
10
  agent: string;
11
+ /** A teammate's colour, for entries that came from the live room. */
12
+ color?: string;
11
13
  note?: string;
12
14
  session: string;
13
15
  /** When it was last marked, as an ISO date. */
@@ -17,6 +17,10 @@ export type ReferencePart = {
17
17
  export type KnownReferences = Readonly<Record<string, readonly string[] | undefined>>;
18
18
  /** The text written for a reference: "/break". */
19
19
  export declare const referenceText: ({ char, id }: Reference) => string;
20
+ /** The character that names a person: "@ana". */
21
+ export declare const MENTION = "@";
22
+ /** The people a message names, by their slugs, each once. */
23
+ export declare const mentionsIn: (text: string) => string[];
20
24
  /** A message split around the references it makes, of those known. */
21
25
  export declare function referenceParts(text: string, known: KnownReferences): ReferencePart[];
22
26
  /**
@@ -3,10 +3,18 @@
3
3
  const NAME = "[a-z0-9]+(?:-[a-z0-9]+)*";
4
4
  const SPECIAL_RE = /[\\^$.*+?()[\]{}|/-]/g;
5
5
  const escaped = (char) => char.replace(SPECIAL_RE, "\\$&");
6
- /** Each trigger, then a name: at the start or after a space, then a space or the end. */
7
- const tokens = (chars) => new RegExp(`(^|\\s)(${chars.map(escaped).join("|")})(${NAME})(?=\\s|$)`, "g");
6
+ /**
7
+ * Each trigger, then a name: at the start, after a space or an opening
8
+ * bracket; then a space or the end, past any closing punctuation ("@ana,"
9
+ * and "(/break)" name them, "/a.b" does not).
10
+ */
11
+ const tokens = (chars) => new RegExp(`(^|[\\s(])(${chars.map(escaped).join("|")})(${NAME})(?=[.,;:!?)]*(?:\\s|$))`, "g");
8
12
  /** The text written for a reference: "/break". */
9
13
  const referenceText = ({ char, id }) => `${char}${id}`;
14
+ /** The character that names a person: "@ana". */
15
+ const MENTION = "@";
16
+ /** The people a message names, by their slugs, each once. */
17
+ const mentionsIn = (text) => [...new Set(referenceParts(text, { ["@"]: void 0 }).flatMap((part) => "reference" in part ? [part.reference.id] : []))];
10
18
  /** A message split around the references it makes, of those known. */
11
19
  function referenceParts(text, known) {
12
20
  const chars = Object.keys(known);
@@ -35,7 +43,7 @@ function referenceParts(text, known) {
35
43
  */
36
44
  function triggerAt(before, chars) {
37
45
  if (chars.length === 0) return;
38
- const match = new RegExp(`(?:^|\\s)(${chars.map(escaped).join("|")})([a-z0-9-]*)$`).exec(before);
46
+ const match = new RegExp(`(?:^|[\\s(])(${chars.map(escaped).join("|")})([A-Za-z0-9-]*)$`).exec(before);
39
47
  if (!(match?.[1] !== void 0)) return;
40
48
  return {
41
49
  char: match[1],
@@ -43,4 +51,4 @@ function triggerAt(before, chars) {
43
51
  };
44
52
  }
45
53
  //#endregion
46
- export { referenceParts, referenceText, triggerAt };
54
+ export { MENTION, mentionsIn, referenceParts, referenceText, triggerAt };
@@ -11,6 +11,13 @@ export interface Contributor {
11
11
  name: string;
12
12
  slug: string;
13
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";
14
21
  /** Where each of the studio's own files is, relative to its content root. */
15
22
  export declare const STUDIO_FILES: {
16
23
  /** Who works in the studio, and the git users that are them. */
@@ -23,6 +30,8 @@ export declare const STUDIO_FILES: {
23
30
  readonly context: "context";
24
31
  /** Each person's folder: people/<slug>/guidelines.md. */
25
32
  readonly people: "people";
33
+ /** The team's own skills: skills/<name>/SKILL.md. */
34
+ readonly skills: "skills";
26
35
  };
27
36
  /** A person's own guidelines, for their agents, on top of the workspace's. */
28
37
  export declare const personGuidelinesPath: (slug: string) => string;
@@ -5,6 +5,13 @@ const DISCIPLINES = [
5
5
  "brand",
6
6
  "engineering"
7
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";
8
15
  /** Where each of the studio's own files is, relative to its content root. */
9
16
  const STUDIO_FILES = {
10
17
  /** Who works in the studio, and the git users that are them. */
@@ -16,7 +23,9 @@ const STUDIO_FILES = {
16
23
  /** The folder of context files: context/<slug>.md. */
17
24
  context: "context",
18
25
  /** Each person's folder: people/<slug>/guidelines.md. */
19
- people: "people"
26
+ people: "people",
27
+ /** The team's own skills: skills/<name>/SKILL.md. */
28
+ skills: "skills"
20
29
  };
21
30
  /** A person's own guidelines, for their agents, on top of the workspace's. */
22
31
  const personGuidelinesPath = (slug) => {
@@ -60,4 +69,4 @@ function classify(file) {
60
69
  return "other";
61
70
  }
62
71
  //#endregion
63
- export { DISCIPLINES, STUDIO_FILES, classify, guidelinesPerson, isEditableMarkdown, isInstructionsFile, personGuidelinesPath };
72
+ export { DEX_FOLDER, DISCIPLINES, OLD_DEX_FOLDER, STUDIO_FILES, classify, guidelinesPerson, isEditableMarkdown, isInstructionsFile, personGuidelinesPath };
@@ -493,6 +493,13 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> extends CommentA
493
493
  events: {
494
494
  GET: unknown;
495
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
+ };
496
503
  /**
497
504
  * The browser extension, as a zip (not JSON) of the folder Chrome loads
498
505
  * unpacked, its files at the root, named EXTENSION_FILE.
@@ -594,6 +601,11 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> extends CommentA
594
601
  * they make something.
595
602
  */
596
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;
597
609
  };
598
610
  };
599
611
  /**
@@ -619,7 +631,7 @@ export interface StudioAnswers<Own extends OwnTypes = OwnTypes> extends CommentA
619
631
  }[];
620
632
  };
621
633
  };
622
- /** 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. */
623
635
  people: {
624
636
  GET: {
625
637
  people: Person[];
@@ -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
@@ -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
1
  import { isOneOf, isRecord, isText } from "./checks.mjs";
2
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 };