@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexhq/canvas",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "description": "Dex Canvas: a prototyping environment for teams who design with agents and a design system. Start with `npm create dex@latest`.",
@@ -106,7 +106,7 @@
106
106
  "watch": "tsdown --watch",
107
107
  "prepack": "bun run typecheck && tsdown --logLevel warn && bun extension/build.ts",
108
108
  "test": "vitest run --root ../.. --project studio-node --project studio-app --project studio-extension",
109
- "test:e2e": "node e2e/narrow-window.e2e.mjs && node e2e/space-pan.e2e.mjs && node e2e/dialog-escape.e2e.mjs && node e2e/frame-keys.e2e.mjs && node e2e/file-drop.e2e.mjs && node e2e/pins-on-pictures.e2e.mjs",
109
+ "test:e2e": "node e2e/narrow-window.e2e.mjs && node e2e/space-pan.e2e.mjs && node e2e/dialog-escape.e2e.mjs && node e2e/frame-keys.e2e.mjs && node e2e/file-drop.e2e.mjs && node e2e/pins-on-pictures.e2e.mjs && node e2e/capture-states.e2e.mjs && node e2e/view-loads-again.e2e.mjs && node e2e/text-keys.e2e.mjs",
110
110
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.build.json",
111
111
  "clean": "rm -rf dist node_modules",
112
112
  "i18n": "lingui extract --clean && lingui compile",
@@ -13,12 +13,12 @@ export const SETUP_ARGS = {
13
13
  type: "string",
14
14
  valueHint: "package",
15
15
  description:
16
- "In a workspace: the studio inside this package, in its studio/ folder, e.g. --in apps/web",
16
+ "In a workspace: the studio inside this package, in its Dex folder (dex/), e.g. --in apps/web",
17
17
  },
18
18
  dir: {
19
19
  type: "string",
20
20
  valueHint: "folder",
21
- description: "The studio's folder in the project (default: studio)",
21
+ description: "The Dex folder in the project (default: dex)",
22
22
  },
23
23
  components: {
24
24
  type: "string",
@@ -155,7 +155,7 @@ export default defineCommand({
155
155
  meta: {
156
156
  name: "create",
157
157
  description:
158
- "Set up a studio, saying what it does at each step: in a project (where its package.json is) it adds one in studio/; in a workspace it gives the studio its own app (apps/studio) or puts it inside an app, by where your components are; in an empty folder it starts a new project (--template: a Vite + React app, a standalone studio or a Turborepo, all shadcn on Base UI) with one. It asks you to confirm what it finds and shows the plan first; without a terminal, or with --yes, it takes what it finds.",
158
+ "Set up a studio, saying what it does at each step: in a project (where its package.json is) it adds one in its Dex folder, dex/; in a workspace it gives the studio its own app (apps/dex) or puts it inside an app, by where your components are; in an empty folder it starts a new project (--template: a Vite + React app, a standalone studio or a Turborepo, all shadcn on Base UI) with one. It asks you to confirm what it finds and shows the plan first; without a terminal, or with --yes, it takes what it finds.",
159
159
  },
160
160
  args: {
161
161
  folder: {
@@ -173,7 +173,7 @@ export default defineCommand({
173
173
  type: "string",
174
174
  valueHint: "name",
175
175
  description:
176
- "In an empty folder, the new project: vite (a Vite + React app, also called shadcn), standalone (the studio on its own) or turborepo (apps/web, a shared packages/ui and the studio in apps/studio); all shadcn on Base UI (default: vite)",
176
+ "In an empty folder, the new project: vite (a Vite + React app, also called shadcn), standalone (the studio on its own) or turborepo (apps/web, a shared packages/ui and the studio in apps/dex); all shadcn on Base UI (default: vite)",
177
177
  },
178
178
  ...SETUP_ARGS,
179
179
  },
@@ -0,0 +1,78 @@
1
+ import { defineCommand } from "citty";
2
+ import { isText } from "../../shared/checks.ts";
3
+ import { loadProject, print } from "../command.ts";
4
+ import { slug } from "./work/args.ts";
5
+
6
+ const list = (value: unknown): string[] | undefined =>
7
+ isText(value)
8
+ ? value
9
+ .split(",")
10
+ .map((part) => part.trim())
11
+ .filter(Boolean)
12
+ : undefined;
13
+
14
+ export default defineCommand({
15
+ meta: {
16
+ name: "export",
17
+ description:
18
+ "Export a file's frames as a prototype that opens by double-click, offline: a zip of index.html, app.js and app.css, in Downloads.",
19
+ },
20
+ args: {
21
+ slug: { ...slug, required: true },
22
+ frames: {
23
+ type: "string",
24
+ valueHint: "keys",
25
+ description: "Frame keys (section/row/frame), comma-separated",
26
+ },
27
+ sections: {
28
+ type: "string",
29
+ valueHint: "ids",
30
+ description: "Whole sections, comma-separated (default: every section)",
31
+ },
32
+ kind: {
33
+ type: "string",
34
+ valueHint: "kind",
35
+ description: "clickable, pages, content or source",
36
+ default: "clickable",
37
+ },
38
+ flows: {
39
+ type: "boolean",
40
+ description: "Let people switch between the exported flows",
41
+ },
42
+ out: {
43
+ type: "string",
44
+ valueHint: "folder",
45
+ description: "Where to save the zip (default: Downloads)",
46
+ },
47
+ json: {
48
+ type: "boolean",
49
+ description: "Print { path } as JSON",
50
+ },
51
+ },
52
+ async run({ args }) {
53
+ const [{ exportChoiceProblems }, { exportPrototype }, { saveExport }] =
54
+ await Promise.all([
55
+ import("../../shared/export-core.ts"),
56
+ import("../../server/export/build.ts"),
57
+ import("../../server/export/save.ts"),
58
+ ]);
59
+ const choice = {
60
+ kind: args.kind,
61
+ frames: list(args.frames),
62
+ sections: list(args.sections),
63
+ flows: Boolean(args.flows),
64
+ };
65
+ const problems = exportChoiceProblems(choice);
66
+ if (problems.length > 0) {
67
+ throw new Error(problems.join(" "));
68
+ }
69
+ const project = await loadProject(process.cwd(), "build");
70
+ const exported = await exportPrototype(
71
+ project,
72
+ args.slug,
73
+ choice as Parameters<typeof exportPrototype>[2]
74
+ );
75
+ const path = await saveExport(exported, args.out);
76
+ print(args.json ? JSON.stringify({ path }) : `Exported to ${path}`);
77
+ },
78
+ });
@@ -62,7 +62,7 @@ export default defineCommand({
62
62
  meta: {
63
63
  name: "upgrade",
64
64
  description:
65
- "Bring a studio set up by an older version up to date: studio.config.ts renamed to dex.config.ts, the design system into it, its state into .studio/, each file's owner's work into people/, every file into files/, and the installed rules.",
65
+ "Bring a studio set up by an older version up to date: studio.config.ts renamed to dex.config.ts, the design system into it, studio/ moved to the Dex folder, dex/, with its state (.local/) and the team's skills (skills/) in it, each file's owner's work into people/, every file into files/, and the installed rules.",
66
66
  },
67
67
  args: {
68
68
  "dry-run": {
package/src/cli/help.ts CHANGED
@@ -21,12 +21,12 @@ Set up and maintain
21
21
  [--components <folder>|none] [--import <specifier>]
22
22
  [--shadcn] [--preset <code>] [--base base|radix|aria]
23
23
  [--styles <file>|none] [--primitives]
24
- [--agent <ids>|none] [--dir studio] [--pm <manager>]
24
+ [--agent <ids>|none] [--dir dex] [--pm <manager>]
25
25
  [--provider <module>|none] [--design-md draft|none|<path>|<url>]
26
26
  [--app <name> | --in <package>]
27
27
  [--studio <spec>] [--skip-install]
28
- Set up a studio: in a project it adds one in studio/,
29
- in a workspace its own app (--app) or inside an app
28
+ Set up a studio: in a project it adds its Dex folder,
29
+ dex/, in a workspace its own app (--app) or inside an app
30
30
  (--in), in an empty folder a new project from a
31
31
  starter (--template). It confirms what it finds,
32
32
  shows the plan, then says what it does. Without a
@@ -43,16 +43,22 @@ Set up and maintain
43
43
  upgrade [--dry-run] Bring a studio set up by an older version up to date:
44
44
  rename studio.config.ts to dex.config.ts, move
45
45
  design-system/index.ts into it (its prose into
46
- DESIGN.md), its state into .studio/, use the
47
- installed rules and delete old explorations/
48
- folders. --dry-run says what would change and
49
- writes nothing
46
+ DESIGN.md), move studio/ to the Dex folder, dex/,
47
+ with its state (.local/) and the team's skills
48
+ (skills/) in it, use the installed rules and delete
49
+ old explorations/ folders. --dry-run says what would
50
+ change and writes nothing
50
51
 
51
52
  Run
52
53
  dev [--live] Start the studio; --live also keeps it in step with
53
54
  the linked cloud workspace (see cloud live)
54
55
  stop Stop this checkout's studio, and no other
55
56
  build Check, then build a static site
57
+ export --slug <file> [--frames <keys>] [--sections <ids>] [--kind <kind>] [--flows] [--out <folder>]
58
+ Export frames as a prototype that opens by
59
+ double-click, offline: a zip in Downloads. --kind is
60
+ clickable, pages (a page per frame), content
61
+ (editable content.js) or source
56
62
  preview Serve the built site
57
63
  extension Install the Chrome extension that copies elements from
58
64
  any page to paste on a canvas
package/src/cli/main.ts CHANGED
@@ -23,6 +23,7 @@ export const COMMANDS = {
23
23
  dev: lazy(() => import("./commands/dev.ts")),
24
24
  stop: lazy(() => import("./commands/stop.ts")),
25
25
  build: lazy(() => import("./commands/build.ts")),
26
+ export: lazy(() => import("./commands/export.ts")),
26
27
  preview: lazy(() => import("./commands/preview.ts")),
27
28
  extension: lazy(() => import("./commands/extension.ts")),
28
29
  app: lazy(() => import("./commands/app.ts")),
@@ -1,10 +1,12 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { readFile, rm, writeFile } from "node:fs/promises";
3
- import { basename, dirname, join, resolve } from "node:path";
3
+ import { basename, dirname, join, relative, resolve } from "node:path";
4
4
  import { loadConfigFromFile, type PluginOption } from "vite";
5
+ import { posix } from "../paths.ts";
5
6
  import { studioOutput } from "../server/state.ts";
6
7
  import { CREATE_COMMAND } from "../setup/project.ts";
7
8
  import { BUILD_DEFAULTS } from "../shared/build-settings.ts";
9
+ import { DEX_FOLDER, OLD_DEX_FOLDER } from "../shared/studio-files.ts";
8
10
  import {
9
11
  type ResolvedDesignSystem,
10
12
  resolveDesignSystem,
@@ -16,7 +18,12 @@ import type {
16
18
  StudioGitSettings,
17
19
  StudioInterface,
18
20
  } from "./index.ts";
19
- import { importsOldPackage, renamedNotice, withNewPackage } from "./renamed.ts";
21
+ import {
22
+ importsOldPackage,
23
+ movedNotice,
24
+ renamedNotice,
25
+ withNewPackage,
26
+ } from "./renamed.ts";
20
27
  import { configProblems } from "./schema.ts";
21
28
 
22
29
  const EXTENSIONS = ["ts", "mts", "js", "mjs"];
@@ -141,6 +148,22 @@ async function loadConfig(
141
148
  }
142
149
  }
143
150
 
151
+ /**
152
+ * Say once that a Dex folder still called `studio/` is `dex/` now. An app of
153
+ * its own keeps its name: it is its Dex folder.
154
+ */
155
+ function oldFolderNotice(root: string, content: string): void {
156
+ if (basename(content) !== OLD_DEX_FOLDER || content === resolve(root)) {
157
+ return;
158
+ }
159
+ const old = posix(relative(root, content));
160
+ movedNotice(
161
+ `${old}/`,
162
+ `${posix(join(dirname(old), DEX_FOLDER))}/`,
163
+ `\`${UPGRADE_HINT}\` does it, with its state and the team's skills.`
164
+ );
165
+ }
166
+
144
167
  /**
145
168
  * Load a project: its config, checked, and the resolved paths and design
146
169
  * system every command needs. Environment overrides: STUDIO_PORT; STUDIO_HOST
@@ -175,6 +198,7 @@ export async function loadProject(
175
198
  }
176
199
  const config = raw as StudioConfig;
177
200
  const content = resolve(root, config.content ?? ".");
201
+ oldFolderNotice(root, content);
178
202
  return {
179
203
  file,
180
204
  root,
@@ -339,6 +339,21 @@ export function packageFolder(dir: string): string | undefined {
339
339
  }
340
340
  }
341
341
 
342
+ const TRAILING_WILDCARD_RE = /\/?\*$/;
343
+
344
+ /**
345
+ * The package a module is in, or an import pattern names:
346
+ * "@base-ui/react" for "@base-ui/react/accordion" and "@base-ui/react/*".
347
+ */
348
+ export const packageOf = (specifier: string): string => {
349
+ const [first = "", second] = specifier
350
+ .replace(TRAILING_WILDCARD_RE, "")
351
+ .split("/");
352
+ return first.startsWith("@") && second !== undefined
353
+ ? `${first}/${second}`
354
+ : first;
355
+ };
356
+
342
357
  /**
343
358
  * Where package `name` is installed: the first node_modules folder that holds
344
359
  * it, looking up from `from` as Node does. Not `require.resolve`, which under
@@ -2,7 +2,8 @@
2
2
  // old names (sudio.config.ts, sudio.components.tsx, SUDIO_* variables, the
3
3
  // MCP server "sudio", ~/.config/sudio): each is still read, and the first
4
4
  // time one is, a line on stderr says what to rename it to. `dex upgrade`
5
- // renames the project's own files.
5
+ // renames the project's own files. So with the Dex folder, `dex/`, which
6
+ // was `studio/`: what is still read from where it was says so once.
6
7
 
7
8
  const said = new Set<string>();
8
9
 
@@ -22,6 +23,23 @@ export function renamedNotice(old: string, now: string, how?: string): void {
22
23
  process.stderr.write(`Sudio is now Dex: rename ${old} to ${now}.${tail}\n`);
23
24
  }
24
25
 
26
+ /**
27
+ * Say once, on stderr, that Dex keeps `old` in its folder now, at `now`:
28
+ * the Dex folder was `studio/` before it was `dex/`, with its state in
29
+ * `.studio/` and the team's skills in `.dex/skills/`. `how` says how to move
30
+ * it, when there is a way.
31
+ */
32
+ export function movedNotice(old: string, now: string, how?: string): void {
33
+ if (said.has(old)) {
34
+ return;
35
+ }
36
+ said.add(old);
37
+ const tail = how ? ` ${how}` : "";
38
+ process.stderr.write(
39
+ `Dex's folder is dex/ now: move ${old} to ${now}.${tail}\n`
40
+ );
41
+ }
42
+
25
43
  /**
26
44
  * The variable `DEX_<name>`, else the old `SUDIO_<name>` (with a notice when
27
45
  * `quiet` is not set: for variables only the studio sets for itself).
@@ -3,7 +3,7 @@
3
3
  // description and the body what the agent does, any files it needs beside
4
4
  // it; a flat name.md, the older format, works too. So a skill from anywhere
5
5
  // works dropped in as it is. They come from three places, the first with a
6
- // name winning (SkillFolders): the Dex project's .dex/skills/ folder,
6
+ // name winning (SkillFolders): the Dex folder's skills/ (dex/skills/),
7
7
  // the team's own for Dex, committed with the rest; the codebase's, which its
8
8
  // developers keep for their agents (.agents/skills, .claude/skills), when
9
9
  // Settings turns them on; and Dex's, in the package (templates/skills/).
@@ -22,10 +22,10 @@ import {
22
22
  rm,
23
23
  writeFile,
24
24
  } from "node:fs/promises";
25
- import { join } from "node:path";
25
+ import { join, relative } from "node:path";
26
26
  import { parse, parseDocument } from "yaml";
27
- import { renamedNotice } from "../config/renamed.ts";
28
- import { TEMPLATES_DIR } from "../paths.ts";
27
+ import { movedNotice } from "../config/renamed.ts";
28
+ import { posix, TEMPLATES_DIR } from "../paths.ts";
29
29
  import {
30
30
  type Command,
31
31
  type CommandChange,
@@ -36,25 +36,37 @@ import {
36
36
  isCommandName,
37
37
  } from "../shared/commands-core.ts";
38
38
  import { splitFrontMatter } from "../shared/front-matter.ts";
39
+ import { STUDIO_FILES } from "../shared/studio-files.ts";
39
40
 
41
+ /** The team's own skills, in the Dex folder: `dex/skills/`. */
42
+ export const TEAM_SKILLS = STUDIO_FILES.skills;
40
43
  /**
41
- * The Dex project's own skills, from its root (beside dex.config.ts),
42
- * with the rest of what Dex keeps there.
44
+ * Where they were before, at the project's root (beside dex.config.ts),
45
+ * newest first: `.dex/skills`, and `.sudio/skills` before Sudio was Dex.
46
+ * Still read until `dex upgrade` moves them into the Dex folder.
43
47
  */
44
- export const TEAM_SKILLS = ".dex/skills";
45
- /** Where they were before Sudio was Dex, still read. */
46
- export const OLD_TEAM_SKILLS = ".sudio/skills";
48
+ export const OLD_TEAM_SKILLS = [".dex/skills", ".sudio/skills"];
47
49
 
48
50
  /**
49
- * The project's own skills folder at `root`: .dex/skills, or .sudio/skills
50
- * (with a notice) when only that one is there.
51
+ * The team's skills folder: `skills/` in the Dex folder (`content`), or,
52
+ * when only an older one is there, that one at the project's `root`, with
53
+ * a notice.
51
54
  */
52
- export function teamSkillsIn(root: string): string {
53
- const now = join(root, TEAM_SKILLS);
54
- const old = join(root, OLD_TEAM_SKILLS);
55
- if (!existsSync(now) && existsSync(old)) {
56
- renamedNotice(".sudio/", ".dex/", "Its skills are still read until then.");
57
- return old;
55
+ export function teamSkillsIn(content: string, root: string): string {
56
+ const now = join(content, TEAM_SKILLS);
57
+ if (existsSync(now)) {
58
+ return now;
59
+ }
60
+ for (const folder of OLD_TEAM_SKILLS) {
61
+ const old = join(root, folder);
62
+ if (existsSync(old)) {
63
+ movedNotice(
64
+ `${folder}/`,
65
+ `${posix(relative(root, now)) || "."}/`,
66
+ "`npx dex upgrade` does it; until then they are read where they are."
67
+ );
68
+ return old;
69
+ }
58
70
  }
59
71
  return now;
60
72
  }
@@ -108,7 +120,7 @@ export interface SkillFolders {
108
120
  codebase: readonly string[];
109
121
  /** Dex's own, in the package: none when Settings turned them off. */
110
122
  installed?: string;
111
- /** The Dex project's .dex/skills/ folder: where Settings saves. */
123
+ /** The Dex folder's skills/ (dex/skills/): where Settings saves. */
112
124
  team: string;
113
125
  }
114
126
 
@@ -9,7 +9,8 @@
9
9
  // Each line is one of:
10
10
  //
11
11
  // start a thread begins, with its first message
12
- // change a reply, a reaction, a status, who it is for (a ThreadChange)
12
+ // change a reply, a reaction, a status, who it is for, where a request
13
+ // for a new view waits (a ThreadChange)
13
14
  // snapshot a whole thread as it was, from the one-file-per-thread
14
15
  // comments/ folder of studios from before
15
16
  //
@@ -78,6 +79,8 @@ const CHANGE_KEYS = [
78
79
  // Resolving: the files the change touched and where it landed.
79
80
  "files",
80
81
  "where",
82
+ // A request for a new view, moved or resized: where it waits now.
83
+ "target",
81
84
  ] as const satisfies readonly (keyof ThreadChange)[];
82
85
 
83
86
  const randomHex = (bytes: number): string =>
@@ -36,6 +36,7 @@ import {
36
36
  type Cell,
37
37
  canvasFrames,
38
38
  canvasProblems,
39
+ type PageSize,
39
40
  placeViewInCell,
40
41
  rowTitleProblems,
41
42
  shapeProblems,
@@ -51,15 +52,15 @@ import { LARGE_CANVAS_BYTES } from "../shared/live-core.ts";
51
52
  import { targetForPath } from "../shared/live-presence.ts";
52
53
  import {
53
54
  combineCanvases,
54
- copyOnEdit,
55
55
  isOthers,
56
56
  isOthersRow,
57
57
  labelAuthors,
58
58
  liftRows,
59
+ othersRowsIn,
59
60
  ownRow,
60
61
  ownSections,
62
+ savedPart,
61
63
  withFrameUids,
62
- withoutOthersRows,
63
64
  } from "../shared/people-core.ts";
64
65
  import type { PresenceTarget } from "../shared/presence-core.ts";
65
66
  import {
@@ -82,11 +83,13 @@ import { NOT_RECOGNISED, youOf } from "../shared/studio-routes.ts";
82
83
  import {
83
84
  type AgentAction,
84
85
  agentChange,
86
+ describeThread,
85
87
  type ThreadChange,
86
88
  } from "../shared/threads-core.ts";
87
89
  import { findBiome, formatText } from "./biome.ts";
88
90
  import { loadDevices } from "./devices.ts";
89
91
  import { inTurn, replaceFile } from "./file-turns.ts";
92
+ import { hostedPerson, isHosted } from "./hosted-person.ts";
90
93
  import { checkPrototype, errorLines, findingLine } from "./prototype-checks.ts";
91
94
  import {
92
95
  clashingViews,
@@ -352,6 +355,7 @@ async function prototypeIssues(
352
355
  }
353
356
  // A new file has no view until its first frame is drawn: that is no
354
357
  // problem.
358
+ const copied: string[] = [];
355
359
  for (const part of await canvasParts(slug, root)) {
356
360
  problems.push(
357
361
  ...[
@@ -359,6 +363,15 @@ async function prototypeIssues(
359
363
  ...rowTitleProblems(part.canvas),
360
364
  ].map((problem) => `${shownIn(root, part.file)}: ${problem}`)
361
365
  );
366
+ // The canvas still reads, at worst showing the row twice: only a warning.
367
+ for (const { section, row, author } of othersRowsIn(
368
+ part.canvas,
369
+ part.person
370
+ )) {
371
+ copied.push(
372
+ `${shownIn(root, part.file)}: section "${section}" › row "${row}" is ${author}'s, copied into ${part.person}'s file, so the canvas can show it twice. ${part.person}'s next save in Dex takes the copy out.`
373
+ );
374
+ }
362
375
  }
363
376
  // Picks never change what a prototype shows, so a broken file only warns.
364
377
  const annotations = (await readPrototypeAnnotations(slug, root)).problems;
@@ -367,6 +380,7 @@ async function prototypeIssues(
367
380
  return {
368
381
  problems,
369
382
  warnings: [
383
+ ...copied,
370
384
  ...annotations,
371
385
  ...findings
372
386
  .filter((finding) => finding.level === "warning")
@@ -552,10 +566,24 @@ export function writeCanvas(
552
566
  return queued(root, save.slug, () => saveCanvasNow(save, root));
553
567
  }
554
568
 
569
+ /**
570
+ * The row a new row goes right under, as the + under it asks: the one
571
+ * before the row `above` names (above the first, the first: as near as it
572
+ * gets), else the last.
573
+ */
574
+ const rowBefore = <R extends { id: string }>(
575
+ rows: readonly R[],
576
+ above?: string
577
+ ): R | undefined => {
578
+ const at = rows.findIndex((row) => row.id === above);
579
+ return at < 0 ? rows.at(-1) : rows[Math.max(0, at - 1)];
580
+ };
581
+
555
582
  /**
556
583
  * A cell the person may add to: theirs, or, in someone else's row, the same
557
584
  * step of the person's own row right below it (ownRow; a new one with
558
- * `newRow`).
585
+ * `newRow`). A new row in someone else's section goes where the cell asks
586
+ * (rowBefore): in the person's own row there, or one right below theirs.
559
587
  */
560
588
  export function ownCell(
561
589
  canvas: Canvas,
@@ -571,12 +599,12 @@ export function ownCell(
571
599
  if (!(section && theirs)) {
572
600
  return { canvas, cell };
573
601
  }
574
- const own = ownRow(
575
- section,
576
- row?.id ?? section.rows[0]?.id ?? "main",
577
- person,
578
- { newRow }
579
- );
602
+ const anchor = row ?? rowBefore(section.rows, cell.above);
603
+ // A new row's place is the person's own row already: it goes in that.
604
+ if (!row && anchor && !isOthersRow(section, anchor, person)) {
605
+ return { canvas, cell: { ...cell, row: anchor.id } };
606
+ }
607
+ const own = ownRow(section, anchor?.id ?? "main", person, { newRow });
580
608
  return {
581
609
  canvas: {
582
610
  sections: canvas.sections.map((entry) =>
@@ -599,6 +627,7 @@ export function placeViewFrame(
599
627
  cell,
600
628
  view,
601
629
  viewport,
630
+ size,
602
631
  person,
603
632
  newRow,
604
633
  }: {
@@ -610,6 +639,8 @@ export function placeViewFrame(
610
639
  newRow?: boolean;
611
640
  /** Who is placing it: the cell must be in one of their sections. */
612
641
  person: string;
642
+ /** The size asked for it: a request's, set on the canvas. */
643
+ size?: PageSize;
613
644
  slug: string;
614
645
  view: string;
615
646
  viewport?: Viewport;
@@ -631,6 +662,7 @@ export function placeViewFrame(
631
662
  const placed = placeViewInCell(canvas, own, {
632
663
  view,
633
664
  viewport,
665
+ size,
634
666
  fallback: defaultDevice(devices),
635
667
  });
636
668
  if ("problem" in placed) {
@@ -777,13 +809,13 @@ async function saveCanvasNow(
777
809
  stylesheets,
778
810
  } = freeViewNames(labelled, save, existing, person);
779
811
  // A change to someone else's section goes into a copy of it that is the
780
- // saver's; then only the saver's sections are written, and everyone
781
- // else's stay as their files have them.
812
+ // saver's; then only the saver's sections are written, without others'
813
+ // rows, and everyone else's stay as their files have them.
782
814
  const now = new Date().toISOString();
783
815
  const lifted = liftRows(
784
- save.revision === undefined
785
- ? copyOnEdit(onDisk, named, person)
786
- : withoutOthersRows(named, person),
816
+ savedPart(onDisk, named, person, {
817
+ onRevision: save.revision !== undefined,
818
+ }),
787
819
  person
788
820
  );
789
821
  // Uids keep a frame the same frame when it moves, so picks follow it: with
@@ -1457,6 +1489,11 @@ const FILE_ORIGIN = "file:";
1457
1489
 
1458
1490
  /** Your git user as git has it: the name as you typed it, and the email. */
1459
1491
  export interface GitUser {
1492
+ /**
1493
+ * Hosted, the person's account says who they are: their email is checked,
1494
+ * their name is only what they chose, so it never makes them someone.
1495
+ */
1496
+ accountEmail?: true;
1460
1497
  email: string;
1461
1498
  name: string;
1462
1499
  }
@@ -1504,6 +1541,11 @@ const gitUsers = new Map<
1504
1541
  * it would read appears or changes.
1505
1542
  */
1506
1543
  async function yourGitUser(root: string): Promise<GitUser> {
1544
+ // Hosted, "you" is whoever this request is from, never the machine's git.
1545
+ const person = hostedPerson();
1546
+ if (person) {
1547
+ return { name: person.name, email: person.email, accountEmail: true };
1548
+ }
1507
1549
  const base = gitConfigFiles(root);
1508
1550
  const global = process.env.GIT_CONFIG_GLOBAL ?? "";
1509
1551
  const kept = gitUsers.get(root);
@@ -1574,6 +1616,10 @@ const askGithubCli = (host: string): Promise<string | undefined> =>
1574
1616
  * not answer is asked again next time.
1575
1617
  */
1576
1618
  export async function githubAccountLogin(): Promise<string | undefined> {
1619
+ // The machine's GitHub account is nobody's in particular when hosted.
1620
+ if (isHosted()) {
1621
+ return;
1622
+ }
1577
1623
  const host = githubHost();
1578
1624
  const file = githubHostsFile();
1579
1625
  const changed =
@@ -1660,7 +1706,9 @@ export function identityFrom(
1660
1706
  )
1661
1707
  : undefined;
1662
1708
  const byEmail = gitNamed(contributors, git.email);
1663
- const byName = gitNamed(contributors, git.name);
1709
+ const byName = git.accountEmail
1710
+ ? undefined
1711
+ : gitNamed(contributors, git.name);
1664
1712
  if (byGithub) {
1665
1713
  const byGit = byEmail ?? byName;
1666
1714
  // Your git user is theirs when it names them too: two can share a
@@ -2189,7 +2237,7 @@ export function createContentCommands({
2189
2237
  // Each with its file's title beside its name: a folder may be an id.
2190
2238
  const titleOf = await prototypeTitles(root, listed);
2191
2239
  const described = listed.map((thread) => {
2192
- const { id, prototype, ...rest } = threads.describe(thread);
2240
+ const { id, prototype, ...rest } = describeThread(thread);
2193
2241
  const fileTitle = titleOf(thread);
2194
2242
  return { id, prototype, ...(fileTitle ? { fileTitle } : {}), ...rest };
2195
2243
  });