@dexhq/canvas 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +5 -3
  3. package/app/canvas/activity-parts.tsx +50 -6
  4. package/app/canvas/activity.tsx +10 -18
  5. package/app/canvas/agent-changes.ts +18 -8
  6. package/app/canvas/anchoring.ts +15 -7
  7. package/app/canvas/canvas-context.tsx +6 -2
  8. package/app/canvas/canvas-input.ts +186 -14
  9. package/app/canvas/canvas-keys.ts +9 -0
  10. package/app/canvas/canvas-model.ts +7 -44
  11. package/app/canvas/canvas-panels.ts +1 -17
  12. package/app/canvas/canvas-scene.ts +250 -27
  13. package/app/canvas/canvas-ui.ts +13 -3
  14. package/app/canvas/canvas.css +147 -29
  15. package/app/canvas/change-notice.tsx +10 -1
  16. package/app/canvas/comment-layer.tsx +2 -1
  17. package/app/canvas/comments.tsx +270 -111
  18. package/app/canvas/element-link.ts +135 -0
  19. package/app/canvas/element-picker.ts +223 -27
  20. package/app/canvas/engine/canvas-gestures.ts +72 -17
  21. package/app/canvas/engine/canvas-store.ts +17 -1
  22. package/app/canvas/engine/engine.css +6 -3
  23. package/app/canvas/export-dialog.tsx +265 -0
  24. package/app/canvas/find-bar.tsx +817 -0
  25. package/app/canvas/find-model.ts +135 -0
  26. package/app/canvas/flow-canvas.tsx +83 -16
  27. package/app/canvas/follow-pin.ts +26 -6
  28. package/app/canvas/frame-context-menu.tsx +61 -7
  29. package/app/canvas/frame-node.tsx +19 -20
  30. package/app/canvas/imported-reviews.tsx +12 -22
  31. package/app/canvas/layout.ts +68 -22
  32. package/app/canvas/linked-element.tsx +196 -0
  33. package/app/canvas/live-page.ts +156 -19
  34. package/app/canvas/mentions.tsx +209 -0
  35. package/app/canvas/page-find.ts +220 -0
  36. package/app/canvas/page-style.ts +23 -0
  37. package/app/canvas/picked-box.tsx +21 -0
  38. package/app/canvas/removed-views-panel.tsx +4 -4
  39. package/app/canvas/request-node.tsx +151 -0
  40. package/app/canvas/review-panel.tsx +8 -3
  41. package/app/canvas/section-node.tsx +6 -133
  42. package/app/canvas/spec-margin.tsx +4 -1
  43. package/app/canvas/spec-threads.ts +24 -23
  44. package/app/canvas/teammates-layer.tsx +205 -0
  45. package/app/canvas/text-layer.tsx +103 -17
  46. package/app/canvas/thread-focus.tsx +14 -12
  47. package/app/canvas/tool-cursors.ts +7 -6
  48. package/app/canvas/tool-icons.tsx +24 -56
  49. package/app/canvas/typing.ts +12 -0
  50. package/app/canvas/use-activity.ts +0 -8
  51. package/app/canvas/use-agent-changes.tsx +40 -42
  52. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  53. package/app/canvas/use-canvas-editor.ts +4 -2
  54. package/app/canvas/xray.ts +3 -12
  55. package/app/export/player-model.ts +159 -0
  56. package/app/export/player.tsx +198 -0
  57. package/app/export.html +31 -0
  58. package/app/export.tsx +9 -0
  59. package/app/frame/announce-refreshes.ts +21 -0
  60. package/app/frame/start-frame.tsx +50 -0
  61. package/app/frame/view-loads.ts +161 -0
  62. package/app/frame/views.ts +13 -49
  63. package/app/frame.tsx +2 -33
  64. package/app/i18n/locales/en/messages.po +233 -14
  65. package/app/i18n/locales/en/messages.ts +1 -1
  66. package/app/i18n/locales/pseudo/messages.po +232 -13
  67. package/app/i18n/locales/pseudo/messages.ts +1 -1
  68. package/app/icons/dex-glyphs.tsx +219 -0
  69. package/app/icons/glyphs.tsx +80 -80
  70. package/app/kit/use-flow.ts +2 -1
  71. package/app/live/canvas-teammates.ts +90 -0
  72. package/app/live/studio-api.ts +30 -20
  73. package/app/main.tsx +3 -0
  74. package/app/pages/canvas.tsx +45 -14
  75. package/app/pages/commands-settings.tsx +17 -3
  76. package/app/pages/render.tsx +39 -11
  77. package/app/shell/bell.tsx +15 -5
  78. package/app/shell/feedback-form.tsx +10 -21
  79. package/app/shell/feedback-link.tsx +2 -1
  80. package/app/shell/presence.tsx +123 -26
  81. package/app/shell/scaled-frame.tsx +21 -9
  82. package/app/shell/thread-list.tsx +25 -8
  83. package/app/shell/working-on.tsx +35 -3
  84. package/app/types.ts +21 -205
  85. package/app/ui/file-drop.ts +128 -0
  86. package/app/ui/prompt-editor.tsx +39 -11
  87. package/app/ui/reference.tsx +21 -8
  88. package/app/ui/shadcn/input-group.tsx +2 -2
  89. package/bin/sudio.mjs +1 -1
  90. package/dist/cli/banner.d.mts +4 -2
  91. package/dist/cli/banner.mjs +34 -11
  92. package/dist/cli/commands/app.mjs +19 -11
  93. package/dist/cli/commands/create.d.mts +5 -5
  94. package/dist/cli/commands/create.mjs +4 -4
  95. package/dist/cli/commands/export.d.mts +40 -0
  96. package/dist/cli/commands/export.mjs +66 -0
  97. package/dist/cli/commands/hook.mjs +2 -1
  98. package/dist/cli/commands/init.d.mts +2 -2
  99. package/dist/cli/commands/upgrade.mjs +1 -1
  100. package/dist/cli/help.d.mts +1 -1
  101. package/dist/cli/help.mjs +13 -7
  102. package/dist/cli/main.d.mts +42 -5
  103. package/dist/cli/main.mjs +1 -0
  104. package/dist/config/load.mjs +14 -2
  105. package/dist/config/project-files.d.mts +11 -0
  106. package/dist/config/project-files.mjs +23 -2
  107. package/dist/config/renamed.d.mts +7 -2
  108. package/dist/config/renamed.mjs +13 -3
  109. package/dist/content/capture.d.mts +2 -2
  110. package/dist/content/capture.mjs +2 -2
  111. package/dist/content/commands.d.mts +11 -9
  112. package/dist/content/commands.mjs +22 -16
  113. package/dist/content/comments-log.mjs +2 -1
  114. package/dist/content/content.d.mts +13 -143
  115. package/dist/content/content.mjs +55 -76
  116. package/dist/content/element-words.d.mts +42 -0
  117. package/dist/content/element-words.mjs +112 -0
  118. package/dist/content/flow-specs.mjs +1 -1
  119. package/dist/content/hosted-person.d.mts +31 -0
  120. package/dist/content/hosted-person.mjs +68 -0
  121. package/dist/content/merge-rules.d.mts +5 -0
  122. package/dist/content/merge-rules.mjs +17 -1
  123. package/dist/content/prototype-summary.d.mts +3 -39
  124. package/dist/content/prototype-summary.mjs +2 -3
  125. package/dist/content/prototypes.mjs +1 -1
  126. package/dist/content/screenshot.mjs +9 -0
  127. package/dist/content/text-edit.d.mts +24 -14
  128. package/dist/content/text-edit.mjs +92 -81
  129. package/dist/content/text-replace.d.mts +30 -0
  130. package/dist/content/text-replace.mjs +285 -0
  131. package/dist/content/thread-module.d.mts +2 -4
  132. package/dist/content/thread-module.mjs +4 -5
  133. package/dist/content/threads.mjs +1 -1
  134. package/dist/paste/paste.mjs +1 -1
  135. package/dist/paths.d.mts +0 -2
  136. package/dist/paths.mjs +1 -3
  137. package/dist/server/agent-env.d.mts +5 -1
  138. package/dist/server/agent-env.mjs +7 -2
  139. package/dist/server/agent-session.d.mts +14 -1
  140. package/dist/server/agent-session.mjs +84 -19
  141. package/dist/server/agents.d.mts +10 -0
  142. package/dist/server/agents.mjs +21 -6
  143. package/dist/server/build-pictures.mjs +1 -1
  144. package/dist/server/canvas-presence.d.mts +22 -0
  145. package/dist/server/canvas-presence.mjs +160 -0
  146. package/dist/server/channel.d.mts +13 -24
  147. package/dist/server/channel.mjs +55 -37
  148. package/dist/server/claimed-presence.d.mts +3 -2
  149. package/dist/server/claimed-presence.mjs +15 -7
  150. package/dist/server/close-check.mjs +2 -2
  151. package/dist/server/command-settings.mjs +1 -1
  152. package/dist/server/comments/actions.d.mts +145 -0
  153. package/dist/server/comments/actions.mjs +146 -0
  154. package/dist/server/comments/routes.d.mts +25 -0
  155. package/dist/server/comments/routes.mjs +67 -0
  156. package/dist/server/comments/tools.d.mts +6 -0
  157. package/dist/server/comments/tools.mjs +154 -0
  158. package/dist/server/dev-server.mjs +59 -23
  159. package/dist/server/export/build.d.mts +15 -0
  160. package/dist/server/export/build.mjs +220 -0
  161. package/dist/server/export/page.d.mts +25 -0
  162. package/dist/server/export/page.mjs +40 -0
  163. package/dist/server/export/plugin.d.mts +31 -0
  164. package/dist/server/export/plugin.mjs +69 -0
  165. package/dist/server/export/run.d.mts +9 -0
  166. package/dist/server/export/run.mjs +61 -0
  167. package/dist/server/export/save.d.mts +7 -0
  168. package/dist/server/export/save.mjs +29 -0
  169. package/dist/server/file-lock.d.mts +2 -2
  170. package/dist/server/file-lock.mjs +130 -36
  171. package/dist/server/hosted.d.mts +8 -0
  172. package/dist/server/hosted.mjs +78 -0
  173. package/dist/server/live-mirror.mjs +66 -10
  174. package/dist/server/live.mjs +28 -1
  175. package/dist/server/mcp.d.mts +0 -2
  176. package/dist/server/mcp.mjs +9 -8
  177. package/dist/server/me.d.mts +3 -1
  178. package/dist/server/me.mjs +8 -2
  179. package/dist/server/notices.d.mts +1 -1
  180. package/dist/server/notices.mjs +1 -1
  181. package/dist/server/open-page.d.mts +22 -0
  182. package/dist/server/open-page.mjs +20 -2
  183. package/dist/server/outcome.d.mts +22 -0
  184. package/dist/server/outcome.mjs +8 -0
  185. package/dist/server/own-copies.mjs +1 -1
  186. package/dist/server/people.d.mts +8 -3
  187. package/dist/server/people.mjs +6 -2
  188. package/dist/server/pictures.d.mts +1 -1
  189. package/dist/server/pictures.mjs +2 -2
  190. package/dist/server/port.d.mts +12 -0
  191. package/dist/server/port.mjs +66 -14
  192. package/dist/server/prebundle.d.mts +32 -0
  193. package/dist/server/prebundle.mjs +115 -0
  194. package/dist/server/presence.d.mts +4 -1
  195. package/dist/server/presence.mjs +2 -2
  196. package/dist/server/problems.d.mts +8 -0
  197. package/dist/server/problems.mjs +13 -0
  198. package/dist/server/requests.d.mts +5 -1
  199. package/dist/server/requests.mjs +76 -78
  200. package/dist/server/source-stamp.d.mts +4 -3
  201. package/dist/server/source-stamp.mjs +60 -31
  202. package/dist/server/state.d.mts +19 -10
  203. package/dist/server/state.mjs +27 -18
  204. package/dist/server/studio-for.d.mts +5 -0
  205. package/dist/server/studio-for.mjs +17 -3
  206. package/dist/server/sync-install.d.mts +8 -12
  207. package/dist/server/sync-install.mjs +12 -30
  208. package/dist/server/thread-source.d.mts +8 -0
  209. package/dist/server/thread-source.mjs +25 -6
  210. package/dist/server/tools/describe.d.mts +1 -1
  211. package/dist/server/tools/describe.mjs +1 -1
  212. package/dist/server/tools/export.d.mts +5 -0
  213. package/dist/server/tools/export.mjs +35 -0
  214. package/dist/server/tools/feedback.d.mts +1 -1
  215. package/dist/server/tools/place-frame.mjs +16 -16
  216. package/dist/server/tools/reading.mjs +13 -4
  217. package/dist/server/tools/show.d.mts +1 -1
  218. package/dist/server/tools/snapshot.d.mts +1 -1
  219. package/dist/server/tools/thread-list.mjs +2 -2
  220. package/dist/server/tools/watch.mjs +5 -3
  221. package/dist/server/vite.d.mts +9 -4
  222. package/dist/server/vite.mjs +65 -63
  223. package/dist/server/web-app.mjs +4 -7
  224. package/dist/server/welcome.mjs +2 -1
  225. package/dist/server/work-groups.mjs +1 -1
  226. package/dist/setup/apply.d.mts +4 -0
  227. package/dist/setup/apply.mjs +5 -4
  228. package/dist/setup/create.d.mts +4 -2
  229. package/dist/setup/create.mjs +72 -22
  230. package/dist/setup/design-system-checks.mjs +3 -17
  231. package/dist/setup/desktop-app-script.mjs +4 -3
  232. package/dist/setup/desktop-app-start.d.mts +8 -2
  233. package/dist/setup/desktop-app-start.mjs +64 -29
  234. package/dist/setup/desktop-app.d.mts +8 -0
  235. package/dist/setup/desktop-app.mjs +19 -3
  236. package/dist/setup/detect/workspace.d.mts +10 -10
  237. package/dist/setup/detect/workspace.mjs +10 -12
  238. package/dist/setup/detect.d.mts +0 -2
  239. package/dist/setup/detect.mjs +1 -3
  240. package/dist/setup/doctor.d.mts +4 -1
  241. package/dist/setup/doctor.mjs +8 -6
  242. package/dist/setup/migrate/dex-folder.d.mts +61 -0
  243. package/dist/setup/migrate/dex-folder.mjs +544 -0
  244. package/dist/setup/migrate/files-folder.mjs +1 -1
  245. package/dist/setup/migrate/guides.mjs +1 -1
  246. package/dist/setup/migrate/migrations.mjs +4 -0
  247. package/dist/setup/migrate/row-titles.mjs +1 -1
  248. package/dist/setup/migrate/setup-files.d.mts +5 -0
  249. package/dist/setup/migrate/setup-files.mjs +115 -0
  250. package/dist/setup/migrate/studio-state.d.mts +2 -2
  251. package/dist/setup/migrate/studio-state.mjs +4 -4
  252. package/dist/setup/placement.d.mts +1 -1
  253. package/dist/setup/placement.mjs +5 -4
  254. package/dist/setup/plan.d.mts +5 -5
  255. package/dist/setup/plan.mjs +8 -12
  256. package/dist/setup/project.d.mts +6 -1
  257. package/dist/setup/project.mjs +10 -10
  258. package/dist/setup/prompts.d.mts +2 -1
  259. package/dist/setup/prompts.mjs +4 -3
  260. package/dist/setup/questions.mjs +3 -2
  261. package/dist/setup/starters.d.mts +3 -1
  262. package/dist/setup/starters.mjs +9 -3
  263. package/dist/setup/write.d.mts +15 -3
  264. package/dist/setup/write.mjs +23 -3
  265. package/dist/shared/annotations-core.mjs +1 -1
  266. package/dist/shared/canvas-core.d.mts +22 -7
  267. package/dist/shared/canvas-core.mjs +39 -11
  268. package/dist/shared/canvas-file.d.mts +201 -0
  269. package/dist/shared/canvas-file.mjs +1 -0
  270. package/dist/shared/comments/routes.d.mts +55 -0
  271. package/dist/shared/comments/routes.mjs +39 -0
  272. package/dist/shared/export-core.d.mts +62 -0
  273. package/dist/shared/export-core.mjs +101 -0
  274. package/dist/shared/feedback.d.mts +8 -0
  275. package/dist/shared/feedback.mjs +10 -2
  276. package/dist/shared/live-core.d.mts +2 -0
  277. package/dist/shared/live-core.mjs +6 -1
  278. package/dist/shared/live-presence.d.mts +57 -2
  279. package/dist/shared/live-presence.mjs +90 -4
  280. package/dist/shared/page-messages.d.mts +14 -1
  281. package/dist/shared/page-messages.mjs +30 -3
  282. package/dist/shared/page-review.d.mts +2 -11
  283. package/dist/shared/page-review.mjs +4 -13
  284. package/dist/shared/people-core.d.mts +28 -0
  285. package/dist/shared/people-core.mjs +27 -1
  286. package/dist/shared/presence-core.d.mts +13 -0
  287. package/dist/shared/presence-core.mjs +11 -2
  288. package/dist/shared/references-core.d.mts +4 -0
  289. package/dist/shared/references-core.mjs +12 -4
  290. package/dist/shared/review-file.d.mts +5 -0
  291. package/dist/shared/review-file.mjs +23 -13
  292. package/dist/shared/server-page.mjs +1 -1
  293. package/dist/shared/signup.d.mts +2 -5
  294. package/dist/shared/signup.mjs +2 -35
  295. package/dist/shared/studio-events.d.mts +0 -6
  296. package/dist/shared/studio-events.mjs +1 -5
  297. package/dist/shared/studio-files.d.mts +21 -0
  298. package/dist/shared/studio-files.mjs +16 -2
  299. package/dist/shared/studio-routes.d.mts +29 -63
  300. package/dist/shared/studio-routes.mjs +1 -69
  301. package/dist/shared/threads-core.d.mts +29 -6
  302. package/dist/shared/threads-core.mjs +68 -13
  303. package/extension/dist/feedback.js +104 -284
  304. package/extension/dist/manifest.json +1 -1
  305. package/extension/dist/picker.js +104 -284
  306. package/package.json +2 -2
  307. package/src/cli/banner.ts +45 -11
  308. package/src/cli/commands/app.ts +23 -8
  309. package/src/cli/commands/create.ts +4 -4
  310. package/src/cli/commands/export.ts +78 -0
  311. package/src/cli/commands/hook.ts +4 -1
  312. package/src/cli/commands/upgrade.ts +1 -1
  313. package/src/cli/help.ts +13 -7
  314. package/src/cli/main.ts +1 -0
  315. package/src/config/load.ts +26 -2
  316. package/src/config/project-files.ts +36 -6
  317. package/src/config/renamed.ts +19 -4
  318. package/src/content/capture.ts +6 -12
  319. package/src/content/commands.ts +30 -18
  320. package/src/content/comments-log.ts +4 -1
  321. package/src/content/content.ts +71 -257
  322. package/src/content/element-words.ts +175 -0
  323. package/src/content/flow-specs.ts +2 -1
  324. package/src/content/hosted-person.ts +107 -0
  325. package/src/content/merge-rules.ts +29 -0
  326. package/src/content/prototype-summary.ts +4 -44
  327. package/src/content/review-pages.ts +2 -1
  328. package/src/content/screenshot.ts +14 -0
  329. package/src/content/text-edit.ts +172 -105
  330. package/src/content/text-replace.ts +420 -0
  331. package/src/content/thread-module.ts +2 -4
  332. package/src/content/trash.ts +1 -1
  333. package/src/paths.ts +0 -8
  334. package/src/server/agent-env.ts +12 -2
  335. package/src/server/agent-session.ts +124 -34
  336. package/src/server/agents.ts +48 -17
  337. package/src/server/canvas-presence.ts +237 -0
  338. package/src/server/channel.ts +95 -53
  339. package/src/server/claimed-presence.ts +26 -10
  340. package/src/server/command-settings.ts +1 -1
  341. package/src/server/comments/actions.ts +333 -0
  342. package/src/server/comments/routes.ts +131 -0
  343. package/src/server/comments/tools.ts +317 -0
  344. package/src/server/dev-server.ts +94 -33
  345. package/src/server/export/build.ts +310 -0
  346. package/src/server/export/page.ts +85 -0
  347. package/src/server/export/plugin.ts +138 -0
  348. package/src/server/export/run.ts +79 -0
  349. package/src/server/export/save.ts +38 -0
  350. package/src/server/file-lock.ts +205 -54
  351. package/src/server/hosted.ts +113 -0
  352. package/src/server/live-mirror.ts +93 -8
  353. package/src/server/live.ts +46 -1
  354. package/src/server/machine-update.ts +3 -3
  355. package/src/server/mcp.ts +15 -14
  356. package/src/server/me.ts +12 -6
  357. package/src/server/notices.ts +2 -2
  358. package/src/server/open-page.ts +54 -4
  359. package/src/server/outcome.ts +26 -0
  360. package/src/server/people.ts +13 -3
  361. package/src/server/pictures.ts +2 -2
  362. package/src/server/port.ts +94 -20
  363. package/src/server/prebundle.ts +230 -0
  364. package/src/server/presence.ts +12 -4
  365. package/src/server/problems.ts +11 -0
  366. package/src/server/requests.ts +115 -110
  367. package/src/server/roster.ts +1 -1
  368. package/src/server/saved.ts +1 -1
  369. package/src/server/source-stamp.ts +118 -37
  370. package/src/server/state.ts +53 -31
  371. package/src/server/studio-for.ts +26 -2
  372. package/src/server/sync-install.ts +35 -26
  373. package/src/server/thread-place.ts +2 -4
  374. package/src/server/thread-source.ts +35 -3
  375. package/src/server/tools/export.ts +56 -0
  376. package/src/server/tools/place-frame.ts +23 -15
  377. package/src/server/tools/reading.ts +16 -3
  378. package/src/server/tools/thread-list.ts +1 -1
  379. package/src/server/tools/watch.ts +7 -7
  380. package/src/server/updates.ts +2 -2
  381. package/src/server/vite.ts +106 -110
  382. package/src/server/web-app.ts +11 -9
  383. package/src/server/welcome.ts +3 -1
  384. package/src/setup/apply.ts +8 -5
  385. package/src/setup/create.ts +101 -27
  386. package/src/setup/design-system-checks.ts +8 -21
  387. package/src/setup/desktop-app-script.ts +4 -3
  388. package/src/setup/desktop-app-start.ts +94 -26
  389. package/src/setup/desktop-app.ts +23 -2
  390. package/src/setup/detect/workspace.ts +20 -21
  391. package/src/setup/detect.ts +0 -4
  392. package/src/setup/doctor.ts +13 -6
  393. package/src/setup/migrate/dex-folder.ts +842 -0
  394. package/src/setup/migrate/files-folder.ts +1 -1
  395. package/src/setup/migrate/guides.ts +3 -1
  396. package/src/setup/migrate/migrations.ts +8 -2
  397. package/src/setup/migrate/setup-files.ts +198 -0
  398. package/src/setup/migrate/studio-state.ts +12 -10
  399. package/src/setup/own-app.ts +1 -1
  400. package/src/setup/placement.ts +7 -6
  401. package/src/setup/plan.ts +13 -18
  402. package/src/setup/project.ts +11 -10
  403. package/src/setup/prompts.ts +5 -4
  404. package/src/setup/questions.ts +6 -3
  405. package/src/setup/starters.ts +11 -4
  406. package/src/setup/write.ts +34 -3
  407. package/src/shared/canvas-core.ts +48 -9
  408. package/src/shared/canvas-file.ts +205 -0
  409. package/src/shared/comments/routes.ts +81 -0
  410. package/src/shared/export-core.ts +198 -0
  411. package/src/shared/feedback.ts +14 -4
  412. package/src/shared/live-core.ts +8 -0
  413. package/src/shared/live-presence.ts +171 -2
  414. package/src/shared/page-messages.ts +38 -2
  415. package/src/shared/page-review.ts +11 -16
  416. package/src/shared/people-core.ts +44 -0
  417. package/src/shared/presence-core.ts +18 -2
  418. package/src/shared/references-core.ts +22 -3
  419. package/src/shared/review-file.ts +28 -12
  420. package/src/shared/server-page.ts +2 -1
  421. package/src/shared/signup.ts +4 -28
  422. package/src/shared/studio-events.ts +0 -13
  423. package/src/shared/studio-files.ts +29 -1
  424. package/src/shared/studio-routes.ts +32 -65
  425. package/src/shared/threads-core.ts +134 -12
  426. package/templates/methods/explore.md +1 -1
  427. package/templates/methods/handoff.md +1 -1
  428. package/templates/methods/review.md +2 -1
  429. package/templates/rules/canvas-frames.md +6 -3
  430. package/templates/rules/commands.md +1 -0
  431. package/templates/rules/prototypes.md +1 -1
  432. package/templates/rules/studio.md +17 -11
  433. package/templates/skills/comprehend/SKILL.md +56 -0
  434. package/templates/skills/distill/SKILL.md +172 -0
  435. package/templates/skills/export-prototype/SKILL.md +35 -0
  436. package/templates/skills/riff/SKILL.md +21 -0
  437. package/templates/skills/riff-deep/SKILL.md +40 -0
  438. package/templates/skills/riff-max/SKILL.md +46 -0
  439. package/templates/skills/riff-state/SKILL.md +45 -0
  440. package/templates/skills/riff-up/SKILL.md +38 -0
  441. package/templates/skills/riff-wide/SKILL.md +40 -0
  442. package/templates/starters/standalone/README.md +1 -1
  443. package/templates/starters/turborepo/README.md +2 -2
  444. package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
  445. package/templates/starters/vite/README.md +1 -1
  446. package/dist/server/tools/close-reply.d.mts +0 -6
  447. package/dist/server/tools/close-reply.mjs +0 -138
  448. package/dist/server/tools/comment.d.mts +0 -6
  449. package/dist/server/tools/comment.mjs +0 -49
  450. package/src/server/tools/close-reply.ts +0 -271
  451. package/src/server/tools/comment.ts +0 -96
@@ -1,31 +1,34 @@
1
- import { APP_DIR, PACKAGE_ROOT } from "../paths.mjs";
1
+ import { APP_DIR, PACKAGE_ROOT, posix as posix$1 } from "../paths.mjs";
2
2
  import { ME_META } from "../shared/studio-routes.mjs";
3
+ import { publicThreads } from "../shared/threads-core.mjs";
3
4
  import { legacyState, prepareOutput, prepareState, studioOutput, studioState } from "./state.mjs";
4
5
  import { prototypesDir } from "../content/prototypes.mjs";
5
6
  import { renamedNotice } from "../config/renamed.mjs";
6
7
  import { canImport, dependenciesOf, projectAliases, projectBaseUrl, resolveAlias, tailwind3Config, tailwindSetup } from "../config/project-files.mjs";
7
8
  import { forInterface } from "../config/design-system.mjs";
8
- import { publicThreads } from "../shared/threads-core.mjs";
9
9
  import { CloudError } from "./cloud.mjs";
10
10
  import { features } from "./features.mjs";
11
11
  import { openThreads } from "../content/thread-module.mjs";
12
+ import { readMe } from "./me.mjs";
12
13
  import { WORKSPACE_META, workspaceName } from "../shared/workspace.mjs";
13
14
  import { EXAMPLE_FILES, OLD_EXAMPLE_FILES, findConfigFile } from "../config/load.mjs";
14
15
  import { componentFileProps, withConfiguredProps } from "../content/component-props.mjs";
15
16
  import { prepareContent } from "../content/first-run.mjs";
16
17
  import { lacksNext, next } from "./next.mjs";
17
18
  import { readBuildSettings } from "./build-settings.mjs";
18
- import { readMe } from "./me.mjs";
19
+ import { canvasPresence } from "./canvas-presence.mjs";
19
20
  import { findWorkspaceIcon, readWorkspace, workspaceIconBytes } from "./workspace-settings.mjs";
20
21
  import { studioDev } from "./dev-server.mjs";
21
22
  import { fileErrors } from "./file-errors.mjs";
23
+ import { hostedPeople } from "./hosted.mjs";
24
+ import { interfaceDependencies, prebundleViews } from "./prebundle.mjs";
22
25
  import { projectPublic } from "./project-public.mjs";
23
26
  import { sourceStamp } from "./source-stamp.mjs";
24
27
  import { studioWebApp } from "./web-app.mjs";
25
28
  import { createRequire } from "node:module";
26
29
  import { existsSync, readFileSync } from "node:fs";
27
30
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
28
- import { readFile, readdir, rm, writeFile } from "node:fs/promises";
31
+ import { readFile, rm, writeFile } from "node:fs/promises";
29
32
  import { normalizePath, searchForWorkspaceRoot } from "vite";
30
33
  import { makeConfig } from "@lingui/conf";
31
34
  import tailwindcss from "@tailwindcss/vite";
@@ -33,12 +36,6 @@ import react from "@vitejs/plugin-react";
33
36
  //#region src/server/vite.ts
34
37
  const ENTRY_CSS_RE = /^@studio-entry\.css$/;
35
38
  const FRAME_CSS_RE = /^@studio-frame\.css$/;
36
- const SOURCE_FILE_RE = /\.(?:ts|tsx)$/;
37
- const TEST_FILE_RE = /\.(?:test|bench)\./;
38
- const TEST_SUPPORT_DIR = "testing";
39
- const BARE_IMPORT_RE = /^\s*import\s+(?!type\s)[^"';]*?from\s+["']([^"'./][^"']*)["']|import\(\s*["']([^"'./][^"']*)["']\s*\)/gm;
40
- const SIDE_EFFECT_IMPORT_RE = /^\s*import\s+["']([^"'./][^"']*)["']/gm;
41
- const OWN_ALIASES = ["@studio"];
42
39
  const INTERFACE_COMPONENT_RE = /^@studio\/ui\/shadcn\/([a-z-]+)$/;
43
40
  const INTERFACE_COMPONENT = "studio-interface-component:";
44
41
  const PACKAGED_COMPONENTS = join(APP_DIR, "ui", "shadcn");
@@ -146,76 +143,79 @@ function componentsRoot(project) {
146
143
  if (!path || path.startsWith("..") || isAbsolute(path) || folder.split(sep).includes("node_modules")) return folder;
147
144
  return join(home, path.split(sep)[0] ?? "");
148
145
  }
146
+ /** A stylesheet's imports, as `@import` lines relative to `dir`. */
147
+ const importLines = (dir, entries) => entries.map(({ entry, layer }) => {
148
+ return `@import "${isAbsolute(entry) ? posixFrom(dir, entry) : entry}"${layer ? ` layer(${layer})` : ""};`;
149
+ });
150
+ const posixFrom = (dir, path) => posix$1(relative(dir, path));
151
+ /**
152
+ * `@source` lines for folders given as paths, or aliases like
153
+ * "@/components/ui" the project's tsconfig maps, relative to `dir`.
154
+ */
155
+ const sourceLines = (project, dir, values) => [...new Set(values.map((value) => value && folderOf(value, project.root)).filter((folder) => Boolean(folder)).map((folder) => `@source "${posixFrom(dir, folder)}";`))];
156
+ /**
157
+ * Tailwind 3's config, for Tailwind 4 wherever the design system's theme is
158
+ * used: the one beside the components views render (Dub's packages/ui, for
159
+ * its semantic classes), else the project's own.
160
+ */
161
+ const tailwind3Lines = (project, dir) => {
162
+ const config = tailwind3Config([project.designSystem?.componentPackage, project.root])?.config;
163
+ return config ? [`@config "${posixFrom(dir, config)}";`] : [];
164
+ };
149
165
  /**
150
- * Two stylesheets per project, one for each page. The frame page's is what
151
- * the real product would have: the design system's CSS (it brings Tailwind
152
- * and the tokens) and Tailwind told where the prototypes and the design
153
- * system's components are, and none of Dex's. The interface's is Dex's
166
+ * The frame page's stylesheet, written in `dir`: what the real product would
167
+ * have, the design system's CSS (it brings Tailwind and the tokens) and
168
+ * Tailwind told where the views are (`views`, folders) and where the design
169
+ * system's components are, and none of Dex's.
170
+ */
171
+ function frameStylesheet(project, dir, views) {
172
+ const tailwind = tailwindSetup(project.root);
173
+ return [
174
+ GENERATED,
175
+ LAYER_ORDER,
176
+ ...importLines(dir, designSystemStyles(project, tailwind, resetsViews(project))),
177
+ `@import "${posixFrom(dir, join(APP_DIR, "frame.css"))}";`,
178
+ ...tailwind3Lines(project, dir),
179
+ ...views.map((folder) => `@source "${posixFrom(dir, folder)}";`),
180
+ ...sourceLines(project, dir, [componentsRoot(project)]),
181
+ ""
182
+ ].join("\n");
183
+ }
184
+ /**
185
+ * Write a generated file only when it changes: the development server
186
+ * watches these, and a rewrite of the same text reloads every open page's
187
+ * styles.
188
+ */
189
+ async function writeChanged(file, text) {
190
+ if (await readFile(file, "utf8").catch(() => void 0) !== text) await writeFile(file, text);
191
+ }
192
+ /**
193
+ * Two stylesheets per project, one for each page. The frame page's
194
+ * (frameStylesheet) reads every prototype's views. The interface's is Dex's
154
195
  * own, with the design system's first only when the interface takes it.
155
196
  */
156
197
  async function writeEntries(project) {
157
198
  const { dir, entryCss, frameCss } = studioState(project.content);
158
199
  await prepareState(project.content);
159
- const from = (path) => relative(dir, path).split(sep).join("/");
160
- const imports = (entries) => entries.map(({ entry, layer }) => {
161
- return `@import "${isAbsolute(entry) ? from(entry) : entry}"${layer ? ` layer(${layer})` : ""};`;
162
- });
163
- const sources = (values) => [...new Set(values.map((value) => value && folderOf(value, project.root)).filter((folder) => Boolean(folder)).map((folder) => `@source "${from(folder)}";`))];
164
200
  const tailwind = tailwindSetup(project.root);
165
- const tailwind3 = tailwind3Config([project.designSystem?.componentPackage, project.root])?.config;
166
- const config = tailwind3 ? [`@config "${from(tailwind3)}";`] : [];
167
201
  const takesDesignSystem = interfaceTakesDesignSystem(project);
168
- const frame = [
169
- GENERATED,
170
- LAYER_ORDER,
171
- ...imports(designSystemStyles(project, tailwind, resetsViews(project))),
172
- `@import "${from(join(APP_DIR, "frame.css"))}";`,
173
- ...config,
174
- `@source "${from(prototypesDir(project.content))}";`,
175
- ...sources([componentsRoot(project)]),
176
- ""
177
- ].join("\n");
178
202
  const own = [
179
203
  GENERATED,
180
204
  LAYER_ORDER,
181
- ...imports(takesDesignSystem ? designSystemStyles(project, tailwind, true) : [{ entry: tailwindModule(tailwind) }]),
182
- `@import "${from(join(APP_DIR, "styles.css"))}";`,
183
- ...takesDesignSystem ? config : [],
184
- ...sources([project.ui?.components, primitivesFrom(project)]),
205
+ ...importLines(dir, takesDesignSystem ? designSystemStyles(project, tailwind, true) : [{ entry: tailwindModule(tailwind) }]),
206
+ `@import "${posixFrom(dir, join(APP_DIR, "styles.css"))}";`,
207
+ ...takesDesignSystem ? tailwind3Lines(project, dir) : [],
208
+ ...sourceLines(project, dir, [project.ui?.components, primitivesFrom(project)]),
185
209
  ...project.ui?.accent ? [`:root, .dark { --studio-accent: ${project.ui.accent}; }`] : [],
186
210
  ""
187
211
  ].join("\n");
188
- await writeFile(frameCss, frame);
189
- await writeFile(entryCss, own);
212
+ await writeChanged(frameCss, frameStylesheet(project, dir, [prototypesDir(project.content)]));
213
+ await writeChanged(entryCss, own);
190
214
  return {
191
215
  frame: frameCss,
192
216
  interface: entryCss
193
217
  };
194
218
  }
195
- const isOwn = (specifier) => OWN_ALIASES.some((alias) => specifier === alias || specifier.startsWith(`${alias}/`)) || specifier.startsWith("@studio-") || specifier.startsWith("virtual:");
196
- /** The libraries one source file imports, not counting the studio's own. */
197
- const importsIn = (source) => [BARE_IMPORT_RE, SIDE_EFFECT_IMPORT_RE].flatMap((re) => [...source.matchAll(re)]).map((match) => match[1] ?? match[2]).filter((specifier) => Boolean(specifier) && !specifier.endsWith(".css") && !isOwn(specifier));
198
- /** Every source file under a folder, tests and what they share aside. */
199
- async function sourceFiles(dir) {
200
- const files = [];
201
- for (const entry of await readdir(dir, { withFileTypes: true })) {
202
- const path = join(dir, entry.name);
203
- if (entry.isDirectory()) {
204
- if (entry.name !== TEST_SUPPORT_DIR) files.push(...await sourceFiles(path));
205
- } else if (SOURCE_FILE_RE.test(entry.name) && !TEST_FILE_RE.test(entry.name)) files.push(path);
206
- }
207
- return files;
208
- }
209
- /**
210
- * Every library the studio's own interface imports. Installed from npm, the
211
- * interface lives in node_modules, where Vite neither crawls imports nor
212
- * converts CommonJS for the browser, so they are listed for it to prepare.
213
- */
214
- async function interfaceDependencies() {
215
- const found = /* @__PURE__ */ new Set();
216
- for (const file of await sourceFiles(APP_DIR)) for (const specifier of importsIn(await readFile(file, "utf8"))) if (!MACRO_IMPORT_RE.test(specifier)) found.add(specifier);
217
- return [...found].sort();
218
- }
219
219
  const LINGUI_MACRO = "@lingui/babel-plugin-lingui-macro";
220
220
  /**
221
221
  * What Lingui's macro needs to compile the interface's messages, made here
@@ -228,7 +228,6 @@ const lingui = () => makeConfig({
228
228
  locales: ["en"],
229
229
  sourceLocale: "en"
230
230
  }, { skipValidation: true });
231
- const MACRO_IMPORT_RE = /\/macro$/;
232
231
  const SCRIPT_RE = /\.[cm]?[jt]sx?$/;
233
232
  /**
234
233
  * Compile Lingui's macros in the studio's own interface. React's plugin
@@ -676,6 +675,7 @@ async function viteConfig(project, mode) {
676
675
  envDir: project.root,
677
676
  define: { "process.env.NODE_ENV": JSON.stringify(mode) },
678
677
  plugins: [
678
+ hostedPeople(),
679
679
  studioMacros(),
680
680
  oneInterfaceCopy(),
681
681
  sourceStamp(project.content, project.designSystem?.imports ?? [], { places: stampsSources(features()) }),
@@ -692,6 +692,8 @@ async function viteConfig(project, mode) {
692
692
  ...project.plugins,
693
693
  ...await lacksNext(project) ? [next()] : [],
694
694
  studioDev(project),
695
+ canvasPresence(),
696
+ prebundleViews(project),
695
697
  fileErrors(project.content, componentsRoot(project)),
696
698
  studioWebApp(project),
697
699
  projectPublic(project.root)
@@ -748,4 +750,4 @@ async function viteConfig(project, mode) {
748
750
  return project.vite ? await project.vite(config, { mode }) : config;
749
751
  }
750
752
  //#endregion
751
- export { SAVE_TEMPORARY, hostTag, importsTailwind, meTag, oneInterfaceCopy, primitivesFrom, projectBaseUrlResolver, studioComponents, studioProvider, studioThreads, viteConfig, workspaceTag, writeEntries };
753
+ export { SAVE_TEMPORARY, frameStylesheet, hostTag, importsTailwind, meTag, oneInterfaceCopy, primitivesFrom, projectBaseUrlResolver, studioComponents, studioProvider, studioThreads, viteConfig, workspaceTag, writeEntries };
@@ -2,7 +2,7 @@ import { runningVersion } from "../paths.mjs";
2
2
  import { DESKTOP_APP_INSTALLED, DESKTOP_APP_KEY, MANIFEST_FILE, OLD_PROJECT_ID_HEADER, PROJECT_ID_HEADER, START_LINK_META } from "../shared/studio-routes.mjs";
3
3
  import { projectId } from "./project-id.mjs";
4
4
  import { serverPage, shownPath } from "../shared/server-page.mjs";
5
- import { APP_NAME, desktopApp, desktopAppState, desktopAppUnavailable, urlScheme } from "../setup/desktop-app.mjs";
5
+ import { APP_NAME, desktopAppState, desktopAppUnavailable, servedApp, urlScheme } from "../setup/desktop-app.mjs";
6
6
  import { basename, sep } from "node:path";
7
7
  import { homedir } from "node:os";
8
8
  //#region src/server/web-app.ts
@@ -109,7 +109,7 @@ const rememberAppScript = (startsHere) => {
109
109
  function studioWebApp(project) {
110
110
  let base = "/";
111
111
  let serving = false;
112
- let app;
112
+ let devServer;
113
113
  const name = APP_NAME;
114
114
  const manifest = JSON.stringify(webAppManifest(name), null, 2);
115
115
  return {
@@ -117,13 +117,9 @@ function studioWebApp(project) {
117
117
  configResolved(config) {
118
118
  base = config.base;
119
119
  serving = config.command === "serve";
120
- app = serving && desktopAppUnavailable() === void 0 ? desktopApp({
121
- root: project.root,
122
- port: config.server.port,
123
- base
124
- }) : void 0;
125
120
  },
126
121
  configureServer(server) {
122
+ devServer = server;
127
123
  const worker = serviceWorker(project.root);
128
124
  const id = projectId(project.root);
129
125
  server.middlewares.use((request, response, next) => {
@@ -166,6 +162,7 @@ function studioWebApp(project) {
166
162
  })];
167
163
  if (!serving) return tags;
168
164
  tags.push(head("script", { type: "module" }, registration(base)));
165
+ const app = devServer && desktopAppUnavailable() === void 0 ? servedApp(project.root, devServer) : void 0;
169
166
  if (app) {
170
167
  const { startsHere } = await desktopAppState(app);
171
168
  tags.push(head("meta", {
@@ -1,5 +1,6 @@
1
1
  import { nameOfMe } from "../shared/studio-routes.mjs";
2
2
  import { personalFolder } from "./personal-folder.mjs";
3
+ import { isHosted } from "../content/hosted-person.mjs";
3
4
  import { readMe } from "./me.mjs";
4
5
  import { join } from "node:path";
5
6
  import { execFile } from "node:child_process";
@@ -19,7 +20,7 @@ const welcomed = async () => {
19
20
  const gitEmail = (content) => new Promise((done) => execFile("git", ["config", "user.email"], { cwd: content }, (_, out) => done(String(out ?? "").trim())));
20
21
  /** Whether to welcome the person, and who Dex takes them to be. */
21
22
  const readWelcome = async (content) => {
22
- if (await welcomed()) return {
23
+ if (isHosted() || await welcomed()) return {
23
24
  due: false,
24
25
  name: "",
25
26
  email: ""
@@ -1,6 +1,6 @@
1
1
  import { prototypeFiles } from "../shared/prototypes-core.mjs";
2
- import { ownTitle, prototypeTitle, viewFiles } from "../content/prototypes.mjs";
3
2
  import { specName } from "../shared/canvas-core.mjs";
3
+ import { ownTitle, prototypeTitle, viewFiles } from "../content/prototypes.mjs";
4
4
  import { existsSync } from "node:fs";
5
5
  import { dirname, extname, join, relative, resolve } from "node:path";
6
6
  import { readFile } from "node:fs/promises";
@@ -59,6 +59,10 @@ export declare function studioDesignSystem(findings: ProjectFindings, decisions:
59
59
  * yet, but its folder was chosen.
60
60
  */
61
61
  export declare function nextFolders(packageDir: string, decisions: SetupDecisions, componentPackage: string | undefined): (string | undefined)[];
62
+ /** A package.json, changed by `change`, written back. */
63
+ export declare function editManifest(file: string, change: (manifest: Record<string, unknown>) => void): Promise<void>;
64
+ /** It extends the tsconfig the dev server resolves views' imports through. */
65
+ export declare function studioTsconfig(folders: Folders): string;
62
66
  /** The project's tsconfig as the studio's extends it: "../tsconfig.json". */
63
67
  export declare function projectTsconfig({ content, packageDir }: Folders): string | undefined;
64
68
  /** How the studio's DESIGN.md started: drafted, imported, or left as it was. */
@@ -12,7 +12,7 @@ import { agentName, componentsChoice, connectInStudio } from "./project.mjs";
12
12
  import { nextPackage } from "../server/next.mjs";
13
13
  import { choicesOnly } from "./config-choices.mjs";
14
14
  import { formatAsProject, keepLockfilesFormatted, readLockfiles } from "./host-format.mjs";
15
- import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, pnpmDecidesEsbuild, tsconfigJson, withEsbuildBuilds, withIgnoreLines, withPointer } from "./write.mjs";
15
+ import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, pnpmDecidesEsbuild, renamedScripts, tsconfigJson, withEsbuildBuilds, withIgnoreLines, withPointer } from "./write.mjs";
16
16
  import { appPackageJson, appTsconfigJson, turboJson } from "./own-app.mjs";
17
17
  import { PROVIDER_FILE } from "./questions.mjs";
18
18
  import { commandLine, planCounts } from "./plan.mjs";
@@ -198,9 +198,10 @@ async function writeStep(step, context) {
198
198
  const own = plan.target.kind === "own-app";
199
199
  await editManifest(file, (manifest) => {
200
200
  const scripts = recordAt(manifest, "scripts");
201
- if (!own) manifest.scripts = {
201
+ manifest.scripts = {
202
202
  ...scripts,
203
- ...missingScripts(scripts)
203
+ ...renamedScripts(scripts),
204
+ ...own ? {} : missingScripts(scripts)
204
205
  };
205
206
  if (spec) manifest.devDependencies = {
206
207
  ...recordAt(manifest, "devDependencies"),
@@ -455,4 +456,4 @@ async function applyPlan(plan, context) {
455
456
  };
456
457
  }
457
458
  //#endregion
458
- export { applyPlan, foldersOf, nextFolders, projectTsconfig, runCommand, studioDesignSystem };
459
+ export { applyPlan, editManifest, foldersOf, nextFolders, projectTsconfig, runCommand, studioDesignSystem, studioTsconfig };
@@ -43,8 +43,10 @@ export declare function setUp(root: string, flags: CreateFlags, deps?: CreateDep
43
43
  workspaces?: boolean;
44
44
  }): Promise<SetupOutcome>;
45
45
  /**
46
- * `dex create [dir]`: a new project in an empty or missing folder, or the
47
- * studio added to the project in one with a package.json.
46
+ * `dex create [dir]`: the studio added to the project in a folder with a
47
+ * package.json, or else a new project. A folder with files but no project
48
+ * (an agent's `work/` and `outputs/`, notes) gets the new project beside
49
+ * them.
48
50
  */
49
51
  export declare function create(dir: string | undefined, flags?: CreateFlags, deps?: CreateDeps): Promise<SetupOutcome>;
50
52
  //#endregion
@@ -8,6 +8,7 @@ import { summaryLines } from "./design-md-setup.mjs";
8
8
  import { dexRunner, pmCommand } from "../config/package-manager.mjs";
9
9
  import { createPrototype, loadStudio, scratchView } from "../content/content.mjs";
10
10
  import { agentSetups } from "../server/agents.mjs";
11
+ import { runningAgent } from "./detect.mjs";
11
12
  import { AGENT_IDS, CREATE_COMMAND, agentName, connectInStudio, createCommandFor, findProject, resolvedStudio } from "./project.mjs";
12
13
  import { prepareContent } from "../content/first-run.mjs";
13
14
  import { nextPackage } from "../server/next.mjs";
@@ -20,7 +21,7 @@ import { doctor, realProbes, startProblems } from "./doctor.mjs";
20
21
  import { configChange, decideAgain, existingStudio, newStudioSpec, placementOf, refuseOwnFolder, studioUpgrade } from "./existing-setup.mjs";
21
22
  import { setupHints } from "./hints.mjs";
22
23
  import { PLACEMENT, decidePlacement, describePlacement, workspaceLines } from "./placement.mjs";
23
- import { DEFAULT_STARTER, STARTERS, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager } from "./starters.mjs";
24
+ import { DEFAULT_STARTER, STARTERS, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager, starterRootNames } from "./starters.mjs";
24
25
  import { findingsFor, targetFor, workspaceFor, workspaceSetup, workspaceWarnings } from "./workspace-setup.mjs";
25
26
  import { existsSync, readFileSync } from "node:fs";
26
27
  import { basename, join, relative, resolve } from "node:path";
@@ -241,7 +242,7 @@ function nextLines(decisions, result, { blockers = [], cwd, root, placement }) {
241
242
  })}`, `Check the setup any time: ${inPackage}${dex} doctor`);
242
243
  return lines;
243
244
  }
244
- /** Where the studio's commands find its config: "cd apps/studio && ", or "". */
245
+ /** Where the studio's commands find its config: "cd apps/dex && ", or "". */
245
246
  function cdInto(placement) {
246
247
  if (!placement) return "";
247
248
  const folder = placement.kind === "own-app" ? placement.folder : placement.packageFolder;
@@ -329,9 +330,9 @@ function ending(installed, flags, blocked) {
329
330
  }
330
331
  /** --app and --in choose a place in a workspace: a single project has none. */
331
332
  function refuseWorkspaceFlags(flags) {
332
- if (flags.app !== void 0 || flags.in !== void 0) throw new Error(`${flags.app === void 0 ? "--in" : "--app"} is for a workspace, and this is a single project: the studio goes in its studio/ folder (--dir).`);
333
+ if (flags.app !== void 0 || flags.in !== void 0) throw new Error(`${flags.app === void 0 ? "--in" : "--app"} is for a workspace, and this is a single project: the studio goes in its Dex folder, dex/ (--dir).`);
333
334
  }
334
- /** A single project (or a package set up by itself): the studio in studio/. */
335
+ /** A single project (or a package set up by itself): the studio in dex/. */
335
336
  async function prepareProject(root, flags, ui, { ask, deps }) {
336
337
  const findings = await findProject(root, { userAgent: deps.userAgent });
337
338
  reportFindings(ui, findings);
@@ -720,6 +721,33 @@ function shownPath(root) {
720
721
  }
721
722
  /** Whether a folder can take a new project: missing, empty or near enough. */
722
723
  const isEmpty = async (root) => !existsSync(root) || (await readdir(root)).every((name) => ALLOWED_EXISTING.has(name));
724
+ /**
725
+ * A new project beside what a folder holds already (an agent's `work/`, a
726
+ * few notes): asked in a terminal, said without one. It stops, writing
727
+ * nothing, when the project would write over any of it.
728
+ */
729
+ async function besideKept(root, project, kept, { ui, ask }) {
730
+ const written = [
731
+ ...await starterRootNames(project.starter),
732
+ project.starter.workspace ? "apps" : project.dir,
733
+ "dex.config.ts"
734
+ ];
735
+ const clashes = kept.filter((name) => written.includes(name));
736
+ const shown = shownPath(root);
737
+ if (clashes.length > 0) throw new Error(`${shown} has no package.json, but it has ${clashes.join(", ")}, which a new project would write over. Move ${clashes.length === 1 ? "it" : "them"}, or start in another folder: dex create <folder>.`);
738
+ const list = kept.join(", ");
739
+ ui.event({
740
+ step: "decide",
741
+ key: "kept",
742
+ value: kept,
743
+ source: "the folder"
744
+ });
745
+ if (!ask) {
746
+ ui.step(`${shown} has no package.json: a new project goes here, beside ${list}, which stay as they are.`);
747
+ return;
748
+ }
749
+ if (!await ui.confirm(`${shown} has ${list} but no package.json. Start a new project here, beside ${kept.length === 1 ? "it" : "them"}?`, { initial: true })) throw new Cancelled();
750
+ }
723
751
  const WELCOME_IMPORT = "\"@/components/ui/";
724
752
  /**
725
753
  * A first prototype, by whoever is creating the project, importing the
@@ -754,8 +782,8 @@ async function chooseStarter(ui, ask) {
754
782
  }
755
783
  /**
756
784
  * `--agent`, parsed: the agents it names ("none" for none). Without it, a
757
- * new folder has no agent files to go by: asked in a terminal, else Claude
758
- * Code.
785
+ * new folder has no agent files to go by: asked in a terminal, else the
786
+ * agent running setup, else Claude Code.
759
787
  */
760
788
  function newProjectAgents(flag, ask) {
761
789
  if (flag !== void 0) return {
@@ -764,7 +792,7 @@ function newProjectAgents(flag, ask) {
764
792
  };
765
793
  return ask ? { kind: "ask" } : {
766
794
  kind: "given",
767
- ids: ["claude"]
795
+ ids: [runningAgent()?.id ?? "claude"]
768
796
  };
769
797
  }
770
798
  /** The agents as the plan names them. */
@@ -773,7 +801,7 @@ function agentsInPlan(agents) {
773
801
  return agents.ids.length > 0 ? agents.ids.join(",") : "no agents";
774
802
  }
775
803
  /** Where the studio goes in a new project, as the plan says it. */
776
- const studioPlace = ({ starter, dir }) => starter.workspace ? "its own app, apps/studio" : `${dir}/`;
804
+ const studioPlace = ({ starter, dir }) => starter.workspace ? "its own app, apps/dex" : `${dir}/`;
777
805
  /** `create --dry-run` in an empty folder: what it would do, writing nothing. */
778
806
  function newProjectPlan(ui, project, flags) {
779
807
  const agents = agentsInPlan(project.agents);
@@ -857,7 +885,7 @@ function checkNewProjectFlags(flags) {
857
885
  studioDir(flags.dir);
858
886
  if (flags.pm !== void 0) packageManagerName(flags.pm);
859
887
  const named = flags.template === void 0 ? void 0 : starterNamed(flags.template);
860
- if (named?.workspace && flags.dir !== void 0) throw new Error(`--dir is for a studio inside an app; in a ${named.label} the studio is an app of its own, apps/studio.`);
888
+ if (named?.workspace && flags.dir !== void 0) throw new Error(`--dir is for a studio inside an app; in a ${named.label} the studio is an app of its own, apps/dex.`);
861
889
  return named;
862
890
  }
863
891
  /** How a new project's output ends: where it is, and how to start. */
@@ -886,7 +914,8 @@ function readyLines(root, project, result) {
886
914
  * Turborepo's studio gets its own app. The agents are asked in a terminal,
887
915
  * as in any project; without one, Claude Code, unless --agent says otherwise.
888
916
  */
889
- async function newProject(root, flags, deps) {
917
+ async function newProject(root, flags, deps, names) {
918
+ const kept = names.filter((name) => !ALLOWED_EXISTING.has(name));
890
919
  const name = basename(root).toLowerCase().replace(NAME_RE, "-").replace(EDGE_RE, "") || "my-studio";
891
920
  const named = checkNewProjectFlags(flags);
892
921
  const ui = deps.ui ?? await createReporter({ json: flags.json });
@@ -912,6 +941,14 @@ async function newProject(root, flags, deps) {
912
941
  pm,
913
942
  starter
914
943
  };
944
+ if (kept.length > 0) try {
945
+ await besideKept(root, project, kept, {
946
+ ui,
947
+ ask
948
+ });
949
+ } catch (error) {
950
+ return stopped(ui, error);
951
+ }
915
952
  if (!(ask || named)) ui.step("A new project. Change it with its flag:", [`Template ${starter.name.padEnd(12)}${TEMPLATE_FLAG}`, `Package manager ${pm.padEnd(12)}--pm bun | pnpm | yarn | npm`]);
916
953
  ui.event({
917
954
  step: "decide",
@@ -943,7 +980,8 @@ async function newProject(root, flags, deps) {
943
980
  await trackWithGit(root, flags, {
944
981
  ui,
945
982
  exec,
946
- ask
983
+ ask,
984
+ kept
947
985
  });
948
986
  if (!flags.skipInstall) await check(ui, join(root, plan.target.package));
949
987
  ui.end("Ready.", readyLines(root, project, result));
@@ -957,12 +995,12 @@ const inRepository = async (dir, exec) => (await exec("git", ["rev-parse", "--is
957
995
  * in a terminal, done without one; skipped inside a repository, with
958
996
  * --no-git, or without git. It adds no remote: that is the person's.
959
997
  */
960
- async function trackWithGit(root, flags, { ask, exec, ui }) {
998
+ async function trackWithGit(root, flags, { ask, exec, ui, kept }) {
961
999
  if (flags.git === false || await inRepository(root, exec)) return;
962
1000
  if (ask) {
963
1001
  if (!await ui.confirm("Track this project with git?", { initial: true })) return;
964
1002
  }
965
- for (const { args, failed } of [
1003
+ const steps = [
966
1004
  {
967
1005
  args: ["init", "--quiet"],
968
1006
  failed: "Git didn’t start: run git init in the project to track it."
@@ -971,6 +1009,18 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
971
1009
  args: ["add", "--all"],
972
1010
  failed: "Git started, but the files weren’t added: run git add --all."
973
1011
  },
1012
+ ...kept.length > 0 ? [{
1013
+ args: [
1014
+ "rm",
1015
+ "-r",
1016
+ "--cached",
1017
+ "--quiet",
1018
+ "--ignore-unmatch",
1019
+ "--",
1020
+ ...kept
1021
+ ],
1022
+ failed: `Git started, but it holds what was here too: run git rm -r --cached ${kept.join(" ")} to leave it out.`
1023
+ }] : [],
974
1024
  {
975
1025
  args: [
976
1026
  "commit",
@@ -980,7 +1030,8 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
980
1030
  ],
981
1031
  failed: "Git started, but the first commit failed. If git doesn’t know who you are yet, set git config user.name and user.email, then commit."
982
1032
  }
983
- ]) {
1033
+ ];
1034
+ for (const { args, failed } of steps) {
984
1035
  const { ok } = await exec("git", args, { cwd: root });
985
1036
  if (!ok) {
986
1037
  ui.step(failed);
@@ -995,17 +1046,16 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
995
1046
  ui.step("Tracked with git, with a first commit.");
996
1047
  }
997
1048
  /**
998
- * `dex create [dir]`: a new project in an empty or missing folder, or the
999
- * studio added to the project in one with a package.json.
1049
+ * `dex create [dir]`: the studio added to the project in a folder with a
1050
+ * package.json, or else a new project. A folder with files but no project
1051
+ * (an agent's `work/` and `outputs/`, notes) gets the new project beside
1052
+ * them.
1000
1053
  */
1001
1054
  async function create(dir, flags = {}, deps = {}) {
1002
1055
  const root = resolve(dir ?? ".");
1003
- if (await isEmpty(root)) return newProject(root, flags, deps);
1004
- if (flags.template !== void 0) throw new Error(`--template starts a new project, in an empty folder, and ${shownPath(root)} has files. Leave it out to add a studio to the project here, or give an empty folder: dex create <folder> --template ${flags.template}.`);
1005
- if (!existsSync(join(root, "package.json"))) {
1006
- const shown = relative(process.cwd(), root) || ".";
1007
- throw new Error(`${shown} has files but no package.json. Run \`dex create\` in a project's folder (where its package.json is), or in an empty folder for a new project.`);
1008
- }
1056
+ if (await isEmpty(root)) return newProject(root, flags, deps, []);
1057
+ if (!existsSync(join(root, "package.json"))) return newProject(root, flags, deps, await readdir(root));
1058
+ if (flags.template !== void 0) throw new Error(`--template starts a new project, and ${shownPath(root)} has one already. Leave it out to add a studio to the project here, or give another folder: dex create <folder> --template ${flags.template}.`);
1009
1059
  return setUp(root, flags, {
1010
1060
  ...deps,
1011
1061
  workspaces: true
@@ -1,5 +1,5 @@
1
1
  import { posix as posix$1 } from "../paths.mjs";
2
- import { componentsJsonError, projectPaths } from "../config/project-files.mjs";
2
+ import { componentsJsonError, installedPackageDir, packageOf, projectPaths } from "../config/project-files.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { existsSync, readFileSync, readdirSync } from "node:fs";
5
5
  import { dirname, isAbsolute, join, relative } from "node:path";
@@ -15,11 +15,6 @@ const canResolve = (from, specifier) => {
15
15
  };
16
16
  /** A path as doctor prints it: from the config's folder. */
17
17
  const shown = (file, root) => posix$1(relative(root, file)) || ".";
18
- /** A package name from an import pattern: "@acme/ui/*" → "@acme/ui". */
19
- const packageOf = (pattern) => {
20
- const parts = pattern.replace(WILDCARD_RE, "").split("/");
21
- return pattern.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
22
- };
23
18
  const SCOPE_WILDCARD_RE = /^(@[^/]+)\/\*$/;
24
19
  /** The scope a whole-scope pattern allows: "@mantine/*" → "@mantine". */
25
20
  const scopeOf = (pattern) => SCOPE_WILDCARD_RE.exec(pattern)?.[1];
@@ -43,15 +38,6 @@ const localTo = (root) => {
43
38
  const aliases = projectPaths(root).map(([pattern]) => pattern.replace(WILDCARD_RE, ""));
44
39
  return (name) => name.startsWith(".") || name.startsWith("@/") || aliases.some((alias) => name === alias || name.startsWith(`${alias}/`));
45
40
  };
46
- /** Where an installed package lives, looking up from `from`. */
47
- const packageDir = (from, name) => {
48
- let dir = from;
49
- while (dir !== dirname(dir)) {
50
- const candidate = join(dir, "node_modules", name);
51
- if (existsSync(join(candidate, "package.json"))) return candidate;
52
- dir = dirname(dir);
53
- }
54
- };
55
41
  const VITE_CONDITIONS = /* @__PURE__ */ new Set([
56
42
  "browser",
57
43
  "import",
@@ -109,7 +95,7 @@ function unbuiltPackages(project) {
109
95
  if (!project.designSystem) return [];
110
96
  const isLocal = localTo(project.root);
111
97
  return importedPackages(project.designSystem).filter((name) => !isLocal(name)).flatMap((name) => {
112
- const dir = packageDir(project.content, name);
98
+ const dir = installedPackageDir(project.content, name);
113
99
  const missing = dir ? missingExports(dir) : [];
114
100
  return missing.length > 0 ? [{
115
101
  name,
@@ -121,7 +107,7 @@ function checkImports({ content, root, designSystem }, { ok, warn }) {
121
107
  const isLocal = localTo(root);
122
108
  if (designSystem.imports.length === 0) warn("The design system lists no imports", "Fill in `designSystem.imports` in dex.config.ts so the audit can tell your components apart.");
123
109
  for (const name of importedPackages(designSystem)) {
124
- const dir = isLocal(name) ? void 0 : packageDir(content, name);
110
+ const dir = isLocal(name) ? void 0 : installedPackageDir(content, name);
125
111
  const resolves = isLocal(name) || canResolve(content, `${name}/package.json`) || canResolve(content, name) || dir !== void 0;
126
112
  const missing = dir ? missingExports(dir) : [];
127
113
  if (resolves && missing.length > 0) warn(`${name} is not built: ${missing.slice(0, 3).join(", ")} ${missing.length === 1 ? "is" : "are"} missing`, `Build it before starting the studio (in a monorepo, \`npx turbo run build --filter=${name}\`), or views cannot import it.`);
@@ -162,9 +162,10 @@ function startOutput() {
162
162
  ObjC.bindFunction("kill", ["int", ["int", "int"]]);
163
163
 
164
164
  /**
165
- * Whether the server the launcher started last still runs. The launcher
166
- * clears its process id before each start and writes it once started, so
167
- * without one, it gave up before starting anything.
165
+ * Whether the server the launcher started last still runs. The pid file
166
+ * names the start the window waits on; the launcher clears it when it
167
+ * gives up, and dex app start when the port is taken, so without one,
168
+ * nothing is starting.
168
169
  */
169
170
  function startAlive() {
170
171
  const pid = Number(readText(DEX.pidFile).trim());
@@ -18,10 +18,14 @@ export type AppStart =
18
18
  state: "gone";
19
19
  message: string;
20
20
  } |
21
- /** Something other than this project's Dex holds the port. */
21
+ /**
22
+ * Something other than this project's Dex holds the port. `ownUrl` is
23
+ * where this project's Dex answers instead, when it runs on another port.
24
+ */
22
25
  {
23
26
  state: "taken";
24
27
  taken: PortTaken;
28
+ ownUrl?: string;
25
29
  };
26
30
  export interface AppStartOptions {
27
31
  /** The `dex` to run `dev` with. */
@@ -53,7 +57,9 @@ export declare function loginShellPath(env: NodeJS.ProcessEnv): Promise<string |
53
57
  export declare const launchPath: (runtime: string, login: string | undefined) => string;
54
58
  /**
55
59
  * Show this project's Dex, or start it: never a server another project,
56
- * or anything else, put on the port.
60
+ * or anything else, put on the port. The app's start link asks again as
61
+ * the app opens: then the `dex dev` it started is still coming up, and
62
+ * it waits on that one rather than start another.
57
63
  */
58
64
  export declare function startForApp(options: AppStartOptions): Promise<AppStart>;
59
65
  //#endregion