@dexhq/canvas 0.13.0 → 0.15.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 (341) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +21 -18
  3. package/app/canvas/activity.tsx +8 -15
  4. package/app/canvas/anchoring.ts +3 -5
  5. package/app/canvas/canvas-input.ts +151 -14
  6. package/app/canvas/canvas-keys.ts +9 -0
  7. package/app/canvas/canvas-model.ts +5 -42
  8. package/app/canvas/canvas-panels.ts +1 -17
  9. package/app/canvas/canvas-scene.ts +7 -3
  10. package/app/canvas/canvas-ui.ts +2 -1
  11. package/app/canvas/canvas.css +61 -26
  12. package/app/canvas/change-notice.tsx +10 -1
  13. package/app/canvas/comment-layer.tsx +2 -1
  14. package/app/canvas/comments.tsx +204 -82
  15. package/app/canvas/element-picker.ts +200 -27
  16. package/app/canvas/engine/canvas-gestures.ts +72 -17
  17. package/app/canvas/engine/canvas-store.ts +17 -1
  18. package/app/canvas/engine/engine.css +6 -3
  19. package/app/canvas/find-bar.tsx +817 -0
  20. package/app/canvas/find-model.ts +135 -0
  21. package/app/canvas/flow-canvas.tsx +18 -2
  22. package/app/canvas/follow-pin.ts +26 -6
  23. package/app/canvas/frame-node.tsx +43 -26
  24. package/app/canvas/imported-reviews.tsx +12 -22
  25. package/app/canvas/layout.ts +27 -0
  26. package/app/canvas/live-page.ts +142 -19
  27. package/app/canvas/page-find.ts +220 -0
  28. package/app/canvas/page-style.ts +23 -0
  29. package/app/canvas/section-node.tsx +2 -0
  30. package/app/canvas/spec-threads.ts +24 -23
  31. package/app/canvas/thread-focus.tsx +14 -12
  32. package/app/canvas/tool-cursors.ts +16 -16
  33. package/app/canvas/use-activity.ts +0 -8
  34. package/app/canvas/use-agent-changes.tsx +34 -40
  35. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  36. package/app/canvas/xray.ts +3 -12
  37. package/app/frame.tsx +5 -0
  38. package/app/i18n/locales/en/messages.po +114 -12
  39. package/app/i18n/locales/en/messages.ts +1 -1
  40. package/app/i18n/locales/pseudo/messages.po +114 -12
  41. package/app/i18n/locales/pseudo/messages.ts +1 -1
  42. package/app/icons/{sets/lucide.tsx → glyphs.tsx} +7 -5
  43. package/app/icons/index.tsx +3 -3
  44. package/app/icons/types.ts +3 -10
  45. package/app/index.html +3 -3
  46. package/app/main.tsx +3 -0
  47. package/app/pages/canvas-settings.tsx +35 -0
  48. package/app/pages/canvas.tsx +27 -8
  49. package/app/pages/commands-settings.tsx +16 -2
  50. package/app/shell/about.tsx +5 -4
  51. package/app/shell/feedback-details.ts +0 -3
  52. package/app/shell/feedback-form.tsx +10 -21
  53. package/app/shell/feedback-link.tsx +2 -1
  54. package/app/shell/instructions-editor.tsx +1 -1
  55. package/app/shell/presence-style.ts +59 -0
  56. package/app/shell/presence.tsx +6 -3
  57. package/app/shell/scaled-frame.tsx +21 -9
  58. package/app/shell/settings-sections.ts +12 -0
  59. package/app/shell/sidebar.tsx +1 -1
  60. package/app/studio-ui.d.ts +0 -9
  61. package/app/types.ts +21 -205
  62. package/app/ui/file-drop.ts +128 -0
  63. package/app/ui/prompt-editor.tsx +1 -1
  64. package/app/ui/shadcn/input-group.tsx +2 -2
  65. package/dist/cli/banner.d.mts +4 -2
  66. package/dist/cli/banner.mjs +34 -11
  67. package/dist/cli/commands/app.mjs +19 -11
  68. package/dist/cli/commands/create.d.mts +26 -14
  69. package/dist/cli/commands/create.mjs +13 -7
  70. package/dist/cli/commands/dev.mjs +2 -3
  71. package/dist/cli/commands/hook.mjs +2 -1
  72. package/dist/cli/commands/init.d.mts +11 -6
  73. package/dist/cli/help.d.mts +1 -1
  74. package/dist/cli/help.mjs +3 -3
  75. package/dist/cli/main.d.mts +22 -12
  76. package/dist/config/index.d.mts +6 -5
  77. package/dist/config/project-files.d.mts +6 -3
  78. package/dist/config/project-files.mjs +14 -5
  79. package/dist/config/renamed.d.mts +0 -2
  80. package/dist/config/renamed.mjs +1 -3
  81. package/dist/config/schema.d.mts +0 -5
  82. package/dist/config/schema.mjs +0 -5
  83. package/dist/content/capture.d.mts +2 -2
  84. package/dist/content/capture.mjs +2 -2
  85. package/dist/content/content.d.mts +3 -141
  86. package/dist/content/content.mjs +7 -65
  87. package/dist/content/flow-specs.mjs +1 -1
  88. package/dist/content/prototype-summary.d.mts +3 -39
  89. package/dist/content/prototype-summary.mjs +2 -3
  90. package/dist/content/prototypes.mjs +1 -1
  91. package/dist/content/snapshot-client.mjs +1 -1
  92. package/dist/content/text-replace.d.mts +30 -0
  93. package/dist/content/text-replace.mjs +309 -0
  94. package/dist/content/thread-module.mjs +1 -1
  95. package/dist/content/threads.mjs +1 -1
  96. package/dist/paths.d.mts +0 -2
  97. package/dist/paths.mjs +1 -3
  98. package/dist/server/agent-env.d.mts +5 -1
  99. package/dist/server/agent-env.mjs +7 -2
  100. package/dist/server/agent-session.d.mts +14 -1
  101. package/dist/server/agent-session.mjs +84 -19
  102. package/dist/server/brief.mjs +3 -3
  103. package/dist/server/build-pictures.mjs +1 -1
  104. package/dist/server/channel.d.mts +19 -24
  105. package/dist/server/channel.mjs +70 -37
  106. package/dist/server/claimed-presence.d.mts +18 -0
  107. package/dist/server/claimed-presence.mjs +58 -0
  108. package/dist/server/close-check.mjs +2 -2
  109. package/dist/server/comments/actions.d.mts +153 -0
  110. package/dist/server/comments/actions.mjs +154 -0
  111. package/dist/server/comments/routes.d.mts +25 -0
  112. package/dist/server/comments/routes.mjs +88 -0
  113. package/dist/server/comments/tools.d.mts +6 -0
  114. package/dist/server/comments/tools.mjs +154 -0
  115. package/dist/server/dev-server.mjs +36 -13
  116. package/dist/server/file-errors.d.mts +7 -2
  117. package/dist/server/file-errors.mjs +31 -8
  118. package/dist/server/file-lock.d.mts +2 -2
  119. package/dist/server/file-lock.mjs +130 -36
  120. package/dist/server/mcp.d.mts +0 -2
  121. package/dist/server/mcp.mjs +7 -8
  122. package/dist/server/me.d.mts +1 -1
  123. package/dist/server/open-page.d.mts +22 -0
  124. package/dist/server/open-page.mjs +20 -2
  125. package/dist/server/outcome.d.mts +22 -0
  126. package/dist/server/outcome.mjs +8 -0
  127. package/dist/server/own-copies.mjs +2 -2
  128. package/dist/server/people.d.mts +1 -1
  129. package/dist/server/port.d.mts +12 -0
  130. package/dist/server/port.mjs +66 -14
  131. package/dist/server/presence.d.mts +4 -1
  132. package/dist/server/presence.mjs +2 -2
  133. package/dist/server/requests.d.mts +5 -1
  134. package/dist/server/requests.mjs +32 -47
  135. package/dist/server/studio-for.d.mts +5 -0
  136. package/dist/server/studio-for.mjs +18 -4
  137. package/dist/server/sync-install.d.mts +8 -12
  138. package/dist/server/sync-install.mjs +12 -30
  139. package/dist/server/thread-source.mjs +2 -2
  140. package/dist/server/tools/describe.d.mts +1 -1
  141. package/dist/server/tools/describe.mjs +1 -1
  142. package/dist/server/tools/feedback.d.mts +1 -1
  143. package/dist/server/tools/reading.mjs +13 -4
  144. package/dist/server/tools/show.d.mts +1 -1
  145. package/dist/server/tools/snapshot.d.mts +1 -1
  146. package/dist/server/tools/thread-list.mjs +1 -1
  147. package/dist/server/tools/watch.mjs +5 -3
  148. package/dist/server/vite.mjs +28 -31
  149. package/dist/server/web-app.mjs +7 -10
  150. package/dist/server/work-groups.mjs +1 -1
  151. package/dist/setup/apply.mjs +8 -14
  152. package/dist/setup/create.d.mts +4 -2
  153. package/dist/setup/create.mjs +118 -36
  154. package/dist/setup/design-system-checks.mjs +3 -12
  155. package/dist/setup/desktop-app-script.mjs +4 -3
  156. package/dist/setup/desktop-app-start.d.mts +8 -2
  157. package/dist/setup/desktop-app-start.mjs +64 -29
  158. package/dist/setup/desktop-app.d.mts +8 -0
  159. package/dist/setup/desktop-app.mjs +20 -4
  160. package/dist/setup/detect.d.mts +14 -7
  161. package/dist/setup/detect.mjs +56 -10
  162. package/dist/setup/doctor.mjs +2 -4
  163. package/dist/setup/existing-setup.d.mts +1 -3
  164. package/dist/setup/existing-setup.mjs +10 -11
  165. package/dist/setup/migrate/row-titles.mjs +1 -1
  166. package/dist/setup/own-app.d.mts +1 -2
  167. package/dist/setup/own-app.mjs +4 -5
  168. package/dist/setup/plan.d.mts +8 -6
  169. package/dist/setup/plan.mjs +64 -48
  170. package/dist/setup/project.d.mts +6 -17
  171. package/dist/setup/project.mjs +17 -61
  172. package/dist/setup/prompts.d.mts +5 -5
  173. package/dist/setup/prompts.mjs +28 -61
  174. package/dist/setup/questions.d.mts +12 -4
  175. package/dist/setup/questions.mjs +10 -25
  176. package/dist/setup/starters.d.mts +2 -0
  177. package/dist/setup/starters.mjs +26 -9
  178. package/dist/setup/workspace-setup.d.mts +1 -2
  179. package/dist/setup/workspace-setup.mjs +4 -6
  180. package/dist/setup/write.d.mts +15 -5
  181. package/dist/setup/write.mjs +35 -9
  182. package/dist/shared/annotations-core.mjs +1 -1
  183. package/dist/shared/canvas-core.mjs +1 -1
  184. package/dist/shared/canvas-file.d.mts +201 -0
  185. package/dist/shared/canvas-file.mjs +1 -0
  186. package/dist/shared/comments/routes.d.mts +53 -0
  187. package/dist/shared/comments/routes.mjs +37 -0
  188. package/dist/shared/feedback.d.mts +8 -0
  189. package/dist/shared/feedback.mjs +10 -2
  190. package/dist/shared/page-review.d.mts +2 -11
  191. package/dist/shared/page-review.mjs +4 -13
  192. package/dist/shared/presence-core.d.mts +11 -0
  193. package/dist/shared/presence-core.mjs +11 -2
  194. package/dist/shared/review-file.d.mts +5 -0
  195. package/dist/shared/review-file.mjs +23 -13
  196. package/dist/shared/server-page.mjs +7 -1
  197. package/dist/shared/signup.d.mts +2 -5
  198. package/dist/shared/signup.mjs +2 -35
  199. package/dist/shared/studio-events.d.mts +0 -6
  200. package/dist/shared/studio-events.mjs +1 -5
  201. package/dist/shared/studio-files.d.mts +12 -0
  202. package/dist/shared/studio-files.mjs +6 -1
  203. package/dist/shared/studio-routes.d.mts +16 -62
  204. package/dist/shared/studio-routes.mjs +1 -69
  205. package/dist/shared/threads-core.d.mts +2 -2
  206. package/dist/shared/threads-core.mjs +1 -1
  207. package/extension/dist/feedback.js +148 -138
  208. package/extension/dist/manifest.json +1 -1
  209. package/extension/dist/picker.js +146 -136
  210. package/package.json +3 -20
  211. package/src/cli/banner.ts +45 -11
  212. package/src/cli/commands/app.ts +23 -8
  213. package/src/cli/commands/create.ts +17 -9
  214. package/src/cli/commands/dev.ts +0 -3
  215. package/src/cli/commands/hook.ts +4 -1
  216. package/src/cli/help.ts +3 -3
  217. package/src/config/index.ts +6 -5
  218. package/src/config/project-files.ts +21 -11
  219. package/src/config/renamed.ts +0 -3
  220. package/src/config/schema.ts +0 -1
  221. package/src/content/capture.ts +6 -12
  222. package/src/content/content.ts +7 -244
  223. package/src/content/flow-specs.ts +2 -1
  224. package/src/content/prototype-summary.ts +4 -44
  225. package/src/content/review-pages.ts +2 -1
  226. package/src/content/snapshot-client.ts +1 -1
  227. package/src/content/text-replace.ts +449 -0
  228. package/src/paths.ts +0 -8
  229. package/src/server/agent-env.ts +12 -2
  230. package/src/server/agent-session.ts +124 -34
  231. package/src/server/brief.ts +8 -3
  232. package/src/server/channel.ts +121 -52
  233. package/src/server/claimed-presence.ts +93 -0
  234. package/src/server/comments/actions.ts +352 -0
  235. package/src/server/comments/routes.ts +176 -0
  236. package/src/server/comments/tools.ts +317 -0
  237. package/src/server/dev-server.ts +49 -15
  238. package/src/server/file-errors.ts +47 -13
  239. package/src/server/file-lock.ts +205 -54
  240. package/src/server/mcp.ts +13 -14
  241. package/src/server/me.ts +2 -5
  242. package/src/server/open-page.ts +54 -4
  243. package/src/server/outcome.ts +26 -0
  244. package/src/server/people.ts +2 -1
  245. package/src/server/port.ts +94 -20
  246. package/src/server/presence.ts +11 -3
  247. package/src/server/requests.ts +60 -70
  248. package/src/server/studio-for.ts +27 -3
  249. package/src/server/sync-install.ts +35 -26
  250. package/src/server/thread-place.ts +2 -4
  251. package/src/server/tools/reading.ts +16 -3
  252. package/src/server/tools/watch.ts +7 -7
  253. package/src/server/vite.ts +37 -40
  254. package/src/server/web-app.ts +14 -12
  255. package/src/setup/apply.ts +10 -16
  256. package/src/setup/create.ts +143 -37
  257. package/src/setup/design-system-checks.ts +7 -15
  258. package/src/setup/desktop-app-script.ts +4 -3
  259. package/src/setup/desktop-app-start.ts +94 -26
  260. package/src/setup/desktop-app.ts +24 -3
  261. package/src/setup/detect.ts +56 -14
  262. package/src/setup/doctor.ts +4 -4
  263. package/src/setup/existing-setup.ts +10 -12
  264. package/src/setup/own-app.ts +2 -5
  265. package/src/setup/plan.ts +93 -84
  266. package/src/setup/project.ts +25 -118
  267. package/src/setup/prompts.ts +44 -127
  268. package/src/setup/questions.ts +27 -29
  269. package/src/setup/starters.ts +35 -10
  270. package/src/setup/workspace-setup.ts +8 -18
  271. package/src/setup/write.ts +52 -9
  272. package/src/shared/canvas-file.ts +205 -0
  273. package/src/shared/comments/routes.ts +79 -0
  274. package/src/shared/feedback.ts +14 -4
  275. package/src/shared/page-review.ts +11 -16
  276. package/src/shared/presence-core.ts +16 -2
  277. package/src/shared/review-file.ts +28 -12
  278. package/src/shared/server-page.ts +11 -1
  279. package/src/shared/signup.ts +4 -28
  280. package/src/shared/studio-events.ts +0 -13
  281. package/src/shared/studio-files.ts +14 -0
  282. package/src/shared/studio-routes.ts +21 -64
  283. package/src/shared/threads-core.ts +2 -2
  284. package/templates/methods/review.md +2 -2
  285. package/templates/rules/canvas-frames.md +104 -0
  286. package/templates/rules/canvas.md +8 -142
  287. package/templates/rules/prototypes.md +1 -1
  288. package/templates/rules/snapshots.md +52 -0
  289. package/templates/starters/standalone/README.md +7 -7
  290. package/templates/starters/standalone/components.json +1 -1
  291. package/templates/starters/standalone/package.json +1 -2
  292. package/templates/starters/turborepo/README.md +6 -6
  293. package/templates/starters/turborepo/apps/web/components.json +1 -1
  294. package/templates/starters/turborepo/apps/web/package.json +1 -2
  295. package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
  296. package/templates/starters/turborepo/packages/ui/components.json +1 -1
  297. package/templates/starters/turborepo/packages/ui/package.json +1 -2
  298. package/templates/starters/vite/README.md +7 -6
  299. package/templates/starters/vite/components.json +1 -1
  300. package/templates/starters/vite/package.json +1 -2
  301. package/templates/starters/vite/src/app.tsx +3 -4
  302. package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
  303. package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
  304. package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
  305. package/templates/starters/vite/src/components/ui/button.tsx +17 -12
  306. package/templates/starters/vite/src/components/ui/card.tsx +1 -1
  307. package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
  308. package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
  309. package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
  310. package/templates/starters/vite/src/components/ui/field.tsx +3 -1
  311. package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
  312. package/templates/starters/vite/src/components/ui/input.tsx +1 -1
  313. package/templates/starters/vite/src/components/ui/label.tsx +2 -0
  314. package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
  315. package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
  316. package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
  317. package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
  318. package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
  319. package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
  320. package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
  321. package/templates/starters/vite/src/index.css +533 -111
  322. package/app/icons/sets/hugeicons.tsx +0 -259
  323. package/app/icons/sets/phosphor.tsx +0 -251
  324. package/dist/server/icon-set.d.mts +0 -15
  325. package/dist/server/icon-set.mjs +0 -31
  326. package/dist/server/tools/close-reply.d.mts +0 -6
  327. package/dist/server/tools/close-reply.mjs +0 -138
  328. package/dist/server/tools/comment.d.mts +0 -6
  329. package/dist/server/tools/comment.mjs +0 -49
  330. package/dist/shared/icon-sets.d.mts +0 -9
  331. package/dist/shared/icon-sets.mjs +0 -21
  332. package/src/server/icon-set.ts +0 -56
  333. package/src/server/tools/close-reply.ts +0 -271
  334. package/src/server/tools/comment.ts +0 -96
  335. package/src/shared/icon-sets.ts +0 -23
  336. /package/app/public/{sudio-192.png → dex-192.png} +0 -0
  337. /package/app/public/{sudio-512.png → dex-512.png} +0 -0
  338. /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
  339. /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
  340. /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
  341. /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
@@ -1,22 +1,21 @@
1
1
  import { APP_DIR, PACKAGE_ROOT } 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
- import { interfaceIconSet } from "./icon-set.mjs";
18
18
  import { readBuildSettings } from "./build-settings.mjs";
19
- import { readMe } from "./me.mjs";
20
19
  import { findWorkspaceIcon, readWorkspace, workspaceIconBytes } from "./workspace-settings.mjs";
21
20
  import { studioDev } from "./dev-server.mjs";
22
21
  import { fileErrors } from "./file-errors.mjs";
@@ -129,6 +128,25 @@ const GENERATED = "/* Generated by Dex on every start. Do not edit. */";
129
128
  */
130
129
  const interfaceTakesDesignSystem = (project) => project.ui?.theme === "design-system" || Boolean(project.ui?.components || project.ui?.primitives);
131
130
  /**
131
+ * Where views import the project's components from: the top folder of the
132
+ * package they are in ("src" for src/components/ui), which holds what views
133
+ * import beside them too, such as a block shadcn adds to src/components.
134
+ * Vite's root is Dex's own, so neither Tailwind nor Vite's watcher finds any
135
+ * of it on their own, as they do in the project: views' Tailwind scans it,
136
+ * and the watcher sees a file appear in it (file-errors.ts). Never the
137
+ * package itself, which for an app is the whole repository, its node_modules
138
+ * and Dex's output with it; a package in node_modules gives its components'
139
+ * folder alone.
140
+ */
141
+ function componentsRoot(project) {
142
+ const folder = project.designSystem?.componentSource?.folder;
143
+ if (!folder) return;
144
+ const home = project.designSystem?.componentPackage ?? project.root;
145
+ const path = relative(home, folder);
146
+ if (!path || path.startsWith("..") || isAbsolute(path) || folder.split(sep).includes("node_modules")) return folder;
147
+ return join(home, path.split(sep)[0] ?? "");
148
+ }
149
+ /**
132
150
  * Two stylesheets per project, one for each page. The frame page's is what
133
151
  * the real product would have: the design system's CSS (it brings Tailwind
134
152
  * and the tokens) and Tailwind told where the prototypes and the design
@@ -143,7 +161,6 @@ async function writeEntries(project) {
143
161
  return `@import "${isAbsolute(entry) ? from(entry) : entry}"${layer ? ` layer(${layer})` : ""};`;
144
162
  });
145
163
  const sources = (values) => [...new Set(values.map((value) => value && folderOf(value, project.root)).filter((folder) => Boolean(folder)).map((folder) => `@source "${from(folder)}";`))];
146
- const componentFolder = project.designSystem?.componentSource?.folder;
147
164
  const tailwind = tailwindSetup(project.root);
148
165
  const tailwind3 = tailwind3Config([project.designSystem?.componentPackage, project.root])?.config;
149
166
  const config = tailwind3 ? [`@config "${from(tailwind3)}";`] : [];
@@ -155,7 +172,7 @@ async function writeEntries(project) {
155
172
  `@import "${from(join(APP_DIR, "frame.css"))}";`,
156
173
  ...config,
157
174
  `@source "${from(prototypesDir(project.content))}";`,
158
- ...sources([componentFolder]),
175
+ ...sources([componentsRoot(project)]),
159
176
  ""
160
177
  ].join("\n");
161
178
  const own = [
@@ -189,18 +206,14 @@ async function sourceFiles(dir) {
189
206
  }
190
207
  return files;
191
208
  }
192
- const ICON_SETS_DIR = join(APP_DIR, "icons", "sets");
193
- const iconSetFile = (set) => join(ICON_SETS_DIR, `${set}.tsx`);
194
209
  /**
195
- * Every library the studio's own interface imports, with only the icon set
196
- * it draws with: the others may not be installed. Installed from npm, the
210
+ * Every library the studio's own interface imports. Installed from npm, the
197
211
  * interface lives in node_modules, where Vite neither crawls imports nor
198
212
  * converts CommonJS for the browser, so they are listed for it to prepare.
199
213
  */
200
- async function interfaceDependencies(icons) {
214
+ async function interfaceDependencies() {
201
215
  const found = /* @__PURE__ */ new Set();
202
- const files = (await sourceFiles(APP_DIR)).filter((file) => dirname(file) !== ICON_SETS_DIR || file === iconSetFile(icons));
203
- for (const file of files) for (const specifier of importsIn(await readFile(file, "utf8"))) if (!MACRO_IMPORT_RE.test(specifier)) found.add(specifier);
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);
204
217
  return [...found].sort();
205
218
  }
206
219
  const LINGUI_MACRO = "@lingui/babel-plugin-lingui-macro";
@@ -248,20 +261,6 @@ const studioMacros = () => {
248
261
  }
249
262
  };
250
263
  };
251
- const ICONS_MODULE = "virtual:studio-icons";
252
- const RESOLVED_ICONS_MODULE = `\0${ICONS_MODULE}`;
253
- /**
254
- * `virtual:studio-icons`: the glyphs of the icon set the interface draws
255
- * with (interfaceIconSet). Only that set is bundled.
256
- */
257
- const studioIcons = (project) => {
258
- const set = interfaceIconSet(project);
259
- return {
260
- name: "studio-icons",
261
- resolveId: (id) => id === ICONS_MODULE ? RESOLVED_ICONS_MODULE : void 0,
262
- load: (id) => id === RESOLVED_ICONS_MODULE ? `export { glyphs } from ${JSON.stringify(iconSetFile(set))};\n` : void 0
263
- };
264
- };
265
264
  /**
266
265
  * While serving, what a module made from `build` in dex.config.ts has is
267
266
  * made again once the file changes (Settings → Deployment writes it), so a
@@ -352,14 +351,13 @@ const studioInterface = (project) => {
352
351
  load: async (id) => {
353
352
  if (id !== RESOLVED_UI_MODULE) return;
354
353
  const build = serving ? await readBuildSettings(project.root) : project.build;
355
- const { title, subtitle, theme, locale, chromeTheme, components, icons } = project.ui ?? {};
354
+ const { title, subtitle, theme, locale, chromeTheme, components } = project.ui ?? {};
356
355
  return `${`export const ui = ${JSON.stringify({
357
356
  title: workspaceName(title),
358
357
  subtitle,
359
358
  theme,
360
359
  locale,
361
360
  chromeTheme,
362
- icons,
363
361
  workspaceIcon
364
362
  })};`}\n${components ? `export * as slots from ${JSON.stringify(resolve(project.root, components))};` : "export const slots = {};"}\nexport const features = ${JSON.stringify(features())};\nexport const build = ${JSON.stringify(build)};\n`;
365
363
  }
@@ -686,7 +684,6 @@ async function viteConfig(project, mode) {
686
684
  reactFromStudio(),
687
685
  tailwindcss(),
688
686
  studioInterface(project),
689
- studioIcons(project),
690
687
  studioThreads(project),
691
688
  studioDesignSystem(project),
692
689
  studioComponents(project),
@@ -695,7 +692,7 @@ async function viteConfig(project, mode) {
695
692
  ...project.plugins,
696
693
  ...await lacksNext(project) ? [next()] : [],
697
694
  studioDev(project),
698
- fileErrors(project.content),
695
+ fileErrors(project.content, componentsRoot(project)),
699
696
  studioWebApp(project),
700
697
  projectPublic(project.root)
701
698
  ],
@@ -736,7 +733,7 @@ async function viteConfig(project, mode) {
736
733
  searchForWorkspaceRoot(PACKAGE_ROOT)
737
734
  ] }
738
735
  },
739
- optimizeDeps: { include: await interfaceDependencies(interfaceIconSet(project)) },
736
+ optimizeDeps: { include: await interfaceDependencies() },
740
737
  preview: { port: project.port },
741
738
  build: {
742
739
  outDir: project.outDir,
@@ -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
@@ -30,17 +30,17 @@ const webAppManifest = (name) => ({
30
30
  theme_color: LIGHT,
31
31
  icons: [
32
32
  {
33
- src: "sudio-192.png",
33
+ src: "dex-192.png",
34
34
  sizes: "192x192",
35
35
  type: "image/png"
36
36
  },
37
37
  {
38
- src: "sudio-512.png",
38
+ src: "dex-512.png",
39
39
  sizes: "512x512",
40
40
  type: "image/png"
41
41
  },
42
42
  {
43
- src: "sudio-maskable-512.png",
43
+ src: "dex-maskable-512.png",
44
44
  sizes: "512x512",
45
45
  type: "image/png",
46
46
  purpose: "maskable"
@@ -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,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";
@@ -1,7 +1,6 @@
1
1
  import { PACKAGE_NAME, posix as posix$1 } from "../paths.mjs";
2
2
  import { STATE_FOLDER } from "../server/state.mjs";
3
3
  import { STUDIO_FILES } from "../shared/studio-files.mjs";
4
- import { ICON_SET_NAMES } from "../shared/icon-sets.mjs";
5
4
  import { compilerOption, tsconfigFile } from "../config/project-files.mjs";
6
5
  import { componentFiles, isPath, providerModule } from "../config/design-system.mjs";
7
6
  import { draftFor } from "./design-md-setup.mjs";
@@ -13,7 +12,7 @@ import { agentName, componentsChoice, connectInStudio } from "./project.mjs";
13
12
  import { nextPackage } from "../server/next.mjs";
14
13
  import { choicesOnly } from "./config-choices.mjs";
15
14
  import { formatAsProject, keepLockfilesFormatted, readLockfiles } from "./host-format.mjs";
16
- import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, tsconfigJson, withIgnoreLines, withPointer } from "./write.mjs";
15
+ import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, pnpmDecidesEsbuild, tsconfigJson, withEsbuildBuilds, withIgnoreLines, withPointer } from "./write.mjs";
17
16
  import { appPackageJson, appTsconfigJson, turboJson } from "./own-app.mjs";
18
17
  import { PROVIDER_FILE } from "./questions.mjs";
19
18
  import { commandLine, planCounts } from "./plan.mjs";
@@ -125,18 +124,12 @@ function afterShadcn(root, decisions) {
125
124
  kind: "folder",
126
125
  choice
127
126
  };
128
- const icons = choice.icons ?? decisions.icons.value;
129
127
  return {
130
128
  ...decisions,
131
129
  components: {
132
130
  ...decisions.components,
133
131
  value
134
132
  },
135
- icons: decisions.icons.source === "--icons" ? decisions.icons : {
136
- ...decisions.icons,
137
- value: icons,
138
- shown: ICON_SET_NAMES[icons]
139
- },
140
133
  styles: decisions.styles.value || decisions.styles.source === "--styles none" ? decisions.styles : {
141
134
  ...decisions.styles,
142
135
  value: choice.styles,
@@ -195,7 +188,6 @@ async function writeStep(step, context) {
195
188
  await write(file, configSource(written, {
196
189
  studio: posix$1(relative(packageDir, content)) || ".",
197
190
  primitives: decisions.primitives.value,
198
- icons: decisions.icons.value,
199
191
  next: nextPackage(nextFolders(packageDir, decisions, resolved?.componentPackage)) !== void 0
200
192
  }));
201
193
  } else if (step.write === "provider" && decisions.provider?.value.kind === "write") await write(file, decisions.provider.value.need.source);
@@ -203,7 +195,6 @@ async function writeStep(step, context) {
203
195
  else if (step.write === "types") await write(file, STUDIO_TYPES);
204
196
  else if (step.write === "scripts") {
205
197
  const spec = plan.workspace?.studioSpec;
206
- const icons = plan.workspace ? plan.iconPackages : {};
207
198
  const own = plan.target.kind === "own-app";
208
199
  await editManifest(file, (manifest) => {
209
200
  const scripts = recordAt(manifest, "scripts");
@@ -211,10 +202,9 @@ async function writeStep(step, context) {
211
202
  ...scripts,
212
203
  ...missingScripts(scripts)
213
204
  };
214
- if (spec || Object.keys(icons).length > 0) manifest.devDependencies = {
205
+ if (spec) manifest.devDependencies = {
215
206
  ...recordAt(manifest, "devDependencies"),
216
- ...spec ? { [PACKAGE_NAME]: spec } : {},
217
- ...icons
207
+ [PACKAGE_NAME]: spec
218
208
  };
219
209
  });
220
210
  } else if (step.write === "root-script" && plan.workspace) {
@@ -223,7 +213,7 @@ async function writeStep(step, context) {
223
213
  const scripts = recordAt(manifest, "scripts");
224
214
  manifest.scripts = {
225
215
  ...scripts,
226
- studio: scripts.studio ?? script
216
+ dex: scripts.dex ?? script
227
217
  };
228
218
  });
229
219
  } else await editProjectFile(step, file, plan);
@@ -240,6 +230,10 @@ async function editProjectFile(step, file, plan) {
240
230
  const missing = missingIgnoreLines(text, lines);
241
231
  await writeFile(file, withIgnoreLines(text, missing));
242
232
  } else if (step.write === "pointer") await writeFile(file, withPointer(text, studio));
233
+ else if (step.write === "pnpm-builds") {
234
+ const edited = withEsbuildBuilds(text);
235
+ if (edited !== void 0 && !pnpmDecidesEsbuild(text)) await writeFile(file, edited);
236
+ }
243
237
  }
244
238
  /**
245
239
  * The studio's DESIGN.md, when it starts from a draft or an import: the
@@ -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
@@ -2,29 +2,30 @@ import { PACKAGE_NAME, TEMPLATES_DIR, isDirectory, posix as posix$1, studioVersi
2
2
  import { createReporter } from "../cli/ui.mjs";
3
3
  import { isOneOf } from "../shared/checks.mjs";
4
4
  import { STUDIO_FILES } from "../shared/studio-files.mjs";
5
- import { ICON_SET_NAMES } from "../shared/icon-sets.mjs";
6
5
  import { dependenciesOf } from "../config/project-files.mjs";
7
6
  import { componentFolders, recommendPlacement } from "./detect/workspace.mjs";
8
7
  import { summaryLines } from "./design-md-setup.mjs";
9
8
  import { dexRunner, pmCommand } from "../config/package-manager.mjs";
10
9
  import { createPrototype, loadStudio, scratchView } from "../content/content.mjs";
11
10
  import { agentSetups } from "../server/agents.mjs";
12
- import { AGENT_IDS, CREATE_COMMAND, agentName, connectInStudio, createCommandFor, findProject, iconPackagesToAdd, resolvedStudio } from "./project.mjs";
11
+ import { runningAgent } from "./detect.mjs";
12
+ import { AGENT_IDS, CREATE_COMMAND, agentName, connectInStudio, createCommandFor, findProject, resolvedStudio } from "./project.mjs";
13
13
  import { prepareContent } from "../content/first-run.mjs";
14
14
  import { nextPackage } from "../server/next.mjs";
15
15
  import { STUDIO_TYPES_FILE } from "./write.mjs";
16
16
  import { PROVIDER_FILE, QUESTIONS, questionEvent, questionFor } from "./questions.mjs";
17
- import { changesAnything, inPackage, planLines, planSetup } from "./plan.mjs";
17
+ import { changesAnything, inPackage, installCommand, planLines, planSetup } from "./plan.mjs";
18
18
  import { Cancelled, NeedsChoice, decide, decisionList, describeComponents, packageManagerName, parseAgents, studioDir } from "./prompts.mjs";
19
19
  import { applyPlan, foldersOf, nextFolders, projectTsconfig, runCommand, studioDesignSystem } from "./apply.mjs";
20
20
  import { doctor, realProbes, startProblems } from "./doctor.mjs";
21
21
  import { configChange, decideAgain, existingStudio, newStudioSpec, placementOf, refuseOwnFolder, studioUpgrade } from "./existing-setup.mjs";
22
22
  import { setupHints } from "./hints.mjs";
23
23
  import { PLACEMENT, decidePlacement, describePlacement, workspaceLines } from "./placement.mjs";
24
- import { DEFAULT_STARTER, STARTERS, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager } from "./starters.mjs";
25
- import { findingsFor, packageDirOf, targetFor, workspaceFor, workspaceSetup, workspaceWarnings } from "./workspace-setup.mjs";
26
- import { existsSync } from "node:fs";
24
+ import { DEFAULT_STARTER, STARTERS, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager, starterRootNames } from "./starters.mjs";
25
+ import { findingsFor, targetFor, workspaceFor, workspaceSetup, workspaceWarnings } from "./workspace-setup.mjs";
26
+ import { existsSync, readFileSync } from "node:fs";
27
27
  import { basename, join, relative, resolve } from "node:path";
28
+ import { execFileSync } from "node:child_process";
28
29
  import { readFile, readdir } from "node:fs/promises";
29
30
  //#region src/setup/create.ts
30
31
  /** Exit code when no default is safe and the person must choose. */
@@ -56,7 +57,6 @@ function detectionLines(findings, { situation = true } = {}) {
56
57
  components.value ? `Components: ${describeComponents(components.value)} ${evidence(components)}` : `Components: none found (${components.evidence})`,
57
58
  ...components.alternatives.map((alt) => ` also ${describeComponents(alt)}`),
58
59
  styles.value ? `Styles: ${styles.value} ${evidence(styles)}` : `Styles: none found (${styles.evidence})`,
59
- `Icon set: ${ICON_SET_NAMES[findings.icons.value]} ${evidence(findings.icons)}`,
60
60
  ...findings.provider.value ? [`Provider: ${findings.provider.value.library} needs ${findings.provider.value.component} around every view ${evidence(findings.provider)}`] : [],
61
61
  findings.designMd.value ? `DESIGN.md: ${findings.designMd.evidence}` : `DESIGN.md: none found (${findings.designMd.evidence})`,
62
62
  agents.value.length > 0 ? `Agents: ${agents.value.map(agentName).join(", ")} ${evidence(agents)}` : `Agents: none found (${agents.evidence})`
@@ -78,8 +78,6 @@ function reportFindings(ui, findings, title = "Looked at this folder") {
78
78
  count: components.value.count
79
79
  });
80
80
  finding("styles", findings.styles, findings.styles.value);
81
- finding("primitives", findings.primitives, findings.primitives.value);
82
- finding("icons", findings.icons, findings.icons.value);
83
81
  const need = findings.provider.value;
84
82
  if (need) finding("provider", findings.provider, {
85
83
  library: need.library,
@@ -215,19 +213,22 @@ function sameSetup(decisions, { cwd, placement, root }) {
215
213
  }
216
214
  function nextLines(decisions, result, { blockers = [], cwd, root, placement }) {
217
215
  const { agent } = decisions.packageManager.value;
218
- const start = pmCommand(agent, "run", ["studio"]).join(" ");
216
+ const start = pmCommand(agent, "run", ["dex"]).join(" ");
219
217
  const inPackage = cdInto(placement);
220
218
  const dex = dexRunner(agent).join(" ");
221
219
  const where = placement ? " (from the workspace root)" : "";
220
+ const drafted = result.designMd.kind === "draft" && result.designMd.written;
221
+ const connected = decisions.agents.value.length > 0;
222
222
  const asks = [
223
- ...result.designMd.kind === "draft" && result.designMd.written ? ["\"Finish DESIGN.md with me.\" (it follows methods/design-md.md)"] : [],
223
+ ...drafted ? ["\"Finish DESIGN.md with me.\" (it follows methods/design-md.md)"] : [],
224
224
  "\"Create a new file for <your idea>.\"",
225
225
  "\"Watch the studio for feedback and work through it.\""
226
226
  ];
227
227
  const lines = [
228
228
  ...result.failedInstall ? [`Install it first: ${result.failedInstall} (it failed: fix what it said, then run it again)`] : [],
229
229
  ...blockers.map(({ fix, message }) => `Fix this first: ${fix} (${message})`),
230
- blockers.length > 0 ? `Then start it: ${start}${where}` : `Start the studio: ${start}${where}`,
230
+ blockers.length > 0 ? `Then start it: ${start}${where}` : `Start Dex: ${start}${where}`,
231
+ ...connected ? [] : [`Connect your agent: ${connectInStudio()}`],
231
232
  ...asks.map((ask, index) => `${index === 0 ? "Then ask your agent: " : " "}${ask}`)
232
233
  ];
233
234
  if (result.decisions.components.value.kind === "none") {
@@ -247,6 +248,40 @@ function cdInto(placement) {
247
248
  const folder = placement.kind === "own-app" ? placement.folder : placement.packageFolder;
248
249
  return folder === "." ? "" : `cd ${folder} && `;
249
250
  }
251
+ const PNPM_FIELD_RE = /^pnpm@(\d+)/;
252
+ /** The first version of pnpm to stop an install on an undecided build script. */
253
+ const PNPM_STRICT_BUILDS = 11;
254
+ /**
255
+ * Whether the project's pnpm stops an install on a build script nobody
256
+ * decided on: the version its packageManager field names, else the pnpm on
257
+ * PATH. Unknown, it is taken not to.
258
+ */
259
+ function pnpmStopsOnBuilds(root) {
260
+ let major;
261
+ try {
262
+ const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
263
+ major = PNPM_FIELD_RE.exec(String(manifest.packageManager ?? ""))?.[1];
264
+ } catch {}
265
+ if (major === void 0) try {
266
+ major = execFileSync("pnpm", ["--version"], {
267
+ cwd: root,
268
+ encoding: "utf8",
269
+ env: {
270
+ ...process.env,
271
+ COREPACK_ENABLE_DOWNLOAD_PROMPT: "0"
272
+ },
273
+ stdio: [
274
+ "ignore",
275
+ "pipe",
276
+ "ignore"
277
+ ],
278
+ timeout: 1e4
279
+ }).split(".")[0];
280
+ } catch {
281
+ return false;
282
+ }
283
+ return Number(major) >= PNPM_STRICT_BUILDS;
284
+ }
250
285
  /** Read what the plan needs to know is there, from `root`. */
251
286
  async function onDisk(root, target) {
252
287
  const { studio } = target;
@@ -282,6 +317,7 @@ async function onDisk(root, target) {
282
317
  scripts,
283
318
  gitignore: await read(ignore),
284
319
  hostGitignore: existsSync(join(root, ".gitignore")) ? await read(".gitignore") : void 0,
320
+ pnpmWorkspace: existsSync(join(root, "pnpm-workspace.yaml")) ? await read("pnpm-workspace.yaml") : void 0,
285
321
  tsconfig: existing.has(tsconfig) ? await read(tsconfig) : void 0,
286
322
  read
287
323
  };
@@ -339,19 +375,16 @@ function settled(ui, { cwd, decisions, findings, flags, placed, root, workspace
339
375
  ...title ? { title } : {},
340
376
  ...where ? { placement: where } : {}
341
377
  });
342
- const iconPackages = iconPackagesToAdd(decisions.icons.value, placement ? packageDirOf(placement) : root);
343
378
  return {
344
379
  cwd,
345
380
  root,
346
381
  findings,
347
382
  decisions,
348
- iconPackages,
349
383
  target,
350
384
  ...where ? { placement: where } : {},
351
385
  ...workspace && placement ? { workspace: workspaceSetup(workspace, placement, findings, decisions, {
352
386
  flags,
353
- cwd,
354
- iconPackages
387
+ cwd
355
388
  }) } : {}
356
389
  };
357
390
  }
@@ -531,7 +564,6 @@ async function planFor(prepared, flags, ui, ask) {
531
564
  }));
532
565
  const again = existing && {
533
566
  config: configChange(existing, prepared.designSystem, {
534
- icons: decisions.icons.value,
535
567
  next: nextPackage(viewFolders) !== void 0,
536
568
  root
537
569
  }),
@@ -544,7 +576,8 @@ async function planFor(prepared, flags, ui, ask) {
544
576
  existing: disk.existing,
545
577
  gitignore: disk.gitignore,
546
578
  hostGitignore: disk.hostGitignore,
547
- iconPackages: prepared.iconPackages,
579
+ pnpmWorkspace: disk.pnpmWorkspace,
580
+ pnpmStopsOnBuilds: decisions.packageManager.value.name === "pnpm" && pnpmStopsOnBuilds(root),
548
581
  quiet: !ask,
549
582
  rootGuide: findings.rootGuide ? {
550
583
  file: findings.rootGuide,
@@ -688,6 +721,33 @@ function shownPath(root) {
688
721
  }
689
722
  /** Whether a folder can take a new project: missing, empty or near enough. */
690
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
+ }
691
751
  const WELCOME_IMPORT = "\"@/components/ui/";
692
752
  /**
693
753
  * A first prototype, by whoever is creating the project, importing the
@@ -722,8 +782,8 @@ async function chooseStarter(ui, ask) {
722
782
  }
723
783
  /**
724
784
  * `--agent`, parsed: the agents it names ("none" for none). Without it, a
725
- * new folder has no agent files to go by: asked in a terminal, else Claude
726
- * Code.
785
+ * new folder has no agent files to go by: asked in a terminal, else the
786
+ * agent running setup, else Claude Code.
727
787
  */
728
788
  function newProjectAgents(flag, ask) {
729
789
  if (flag !== void 0) return {
@@ -732,7 +792,7 @@ function newProjectAgents(flag, ask) {
732
792
  };
733
793
  return ask ? { kind: "ask" } : {
734
794
  kind: "given",
735
- ids: ["claude"]
795
+ ids: [runningAgent()?.id ?? "claude"]
736
796
  };
737
797
  }
738
798
  /** The agents as the plan names them. */
@@ -838,7 +898,7 @@ function readyLines(root, project, result) {
838
898
  what
839
899
  }));
840
900
  const width = Math.max(...commands.map(({ line }) => line.length)) + 4;
841
- const lines = [`cd ${where}`, ...commands.map(({ line, what }) => `${line.padEnd(width)}# ${what}`)];
901
+ const lines = [...where === "." ? [] : [`cd ${where}`], ...commands.map(({ line, what }) => `${line.padEnd(width)}# ${what}`)];
842
902
  if (!connected) lines.push(`Then connect your agent: ${connectInStudio()}.`);
843
903
  if (drafted) {
844
904
  const ask = connected ? "Then ask your agent" : "Once it's connected, ask it";
@@ -854,7 +914,8 @@ function readyLines(root, project, result) {
854
914
  * Turborepo's studio gets its own app. The agents are asked in a terminal,
855
915
  * as in any project; without one, Claude Code, unless --agent says otherwise.
856
916
  */
857
- async function newProject(root, flags, deps) {
917
+ async function newProject(root, flags, deps, names) {
918
+ const kept = names.filter((name) => !ALLOWED_EXISTING.has(name));
858
919
  const name = basename(root).toLowerCase().replace(NAME_RE, "-").replace(EDGE_RE, "") || "my-studio";
859
920
  const named = checkNewProjectFlags(flags);
860
921
  const ui = deps.ui ?? await createReporter({ json: flags.json });
@@ -875,11 +936,19 @@ async function newProject(root, flags, deps) {
875
936
  const project = {
876
937
  agents,
877
938
  dir: studioDir(flags.dir),
878
- install: pmCommand(pm, "install", []),
939
+ install: installCommand(pm),
879
940
  name,
880
941
  pm,
881
942
  starter
882
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
+ }
883
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`]);
884
953
  ui.event({
885
954
  step: "decide",
@@ -911,7 +980,8 @@ async function newProject(root, flags, deps) {
911
980
  await trackWithGit(root, flags, {
912
981
  ui,
913
982
  exec,
914
- ask
983
+ ask,
984
+ kept
915
985
  });
916
986
  if (!flags.skipInstall) await check(ui, join(root, plan.target.package));
917
987
  ui.end("Ready.", readyLines(root, project, result));
@@ -925,12 +995,12 @@ const inRepository = async (dir, exec) => (await exec("git", ["rev-parse", "--is
925
995
  * in a terminal, done without one; skipped inside a repository, with
926
996
  * --no-git, or without git. It adds no remote: that is the person's.
927
997
  */
928
- async function trackWithGit(root, flags, { ask, exec, ui }) {
998
+ async function trackWithGit(root, flags, { ask, exec, ui, kept }) {
929
999
  if (flags.git === false || await inRepository(root, exec)) return;
930
1000
  if (ask) {
931
1001
  if (!await ui.confirm("Track this project with git?", { initial: true })) return;
932
1002
  }
933
- for (const { args, failed } of [
1003
+ const steps = [
934
1004
  {
935
1005
  args: ["init", "--quiet"],
936
1006
  failed: "Git didn’t start: run git init in the project to track it."
@@ -939,6 +1009,18 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
939
1009
  args: ["add", "--all"],
940
1010
  failed: "Git started, but the files weren’t added: run git add --all."
941
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
+ }] : [],
942
1024
  {
943
1025
  args: [
944
1026
  "commit",
@@ -948,7 +1030,8 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
948
1030
  ],
949
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."
950
1032
  }
951
- ]) {
1033
+ ];
1034
+ for (const { args, failed } of steps) {
952
1035
  const { ok } = await exec("git", args, { cwd: root });
953
1036
  if (!ok) {
954
1037
  ui.step(failed);
@@ -963,17 +1046,16 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
963
1046
  ui.step("Tracked with git, with a first commit.");
964
1047
  }
965
1048
  /**
966
- * `dex create [dir]`: a new project in an empty or missing folder, or the
967
- * 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.
968
1053
  */
969
1054
  async function create(dir, flags = {}, deps = {}) {
970
1055
  const root = resolve(dir ?? ".");
971
- if (await isEmpty(root)) return newProject(root, flags, deps);
972
- 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}.`);
973
- if (!existsSync(join(root, "package.json"))) {
974
- const shown = relative(process.cwd(), root) || ".";
975
- 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.`);
976
- }
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}.`);
977
1059
  return setUp(root, flags, {
978
1060
  ...deps,
979
1061
  workspaces: true