@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
@@ -17,7 +17,8 @@
17
17
  // after the plan. With `--json`, what setup isn't sure of is a `question`
18
18
  // event, for an agent to ask the person, then run it with the answers' flags.
19
19
 
20
- import { existsSync } from "node:fs";
20
+ import { execFileSync } from "node:child_process";
21
+ import { existsSync, readFileSync } from "node:fs";
21
22
  import { readdir, readFile } from "node:fs/promises";
22
23
  import { basename, join, relative, resolve } from "node:path";
23
24
  import { type Check, createReporter, type Reporter } from "../cli/ui.ts";
@@ -39,7 +40,6 @@ import {
39
40
  import { agentSetups } from "../server/agents.ts";
40
41
  import { nextPackage } from "../server/next.ts";
41
42
  import { isOneOf } from "../shared/checks.ts";
42
- import { ICON_SET_NAMES } from "../shared/icon-sets.ts";
43
43
  import { STUDIO_FILES } from "../shared/studio-files.ts";
44
44
  import {
45
45
  type ApplyResult,
@@ -60,7 +60,7 @@ import {
60
60
  recommendPlacement,
61
61
  type Workspace,
62
62
  } from "./detect/workspace.ts";
63
- import type { AgentId } from "./detect.ts";
63
+ import { type AgentId, runningAgent } from "./detect.ts";
64
64
  import {
65
65
  doctor,
66
66
  realProbes,
@@ -89,6 +89,7 @@ import {
89
89
  import {
90
90
  changesAnything,
91
91
  inPackage,
92
+ installCommand,
92
93
  planLines,
93
94
  planSetup,
94
95
  type SetUpAgain,
@@ -104,7 +105,6 @@ import {
104
105
  connectInStudio,
105
106
  createCommandFor,
106
107
  findProject,
107
- iconPackagesToAdd,
108
108
  type PackageManagerName,
109
109
  type ProjectFindings,
110
110
  resolvedStudio,
@@ -141,11 +141,11 @@ import {
141
141
  type Starter,
142
142
  starterNamed,
143
143
  starterPackageManager,
144
+ starterRootNames,
144
145
  TEMPLATE_FLAG,
145
146
  } from "./starters.ts";
146
147
  import {
147
148
  findingsFor,
148
- packageDirOf,
149
149
  targetFor,
150
150
  workspaceFor,
151
151
  workspaceSetup,
@@ -233,7 +233,6 @@ function detectionLines(
233
233
  styles.value
234
234
  ? `Styles: ${styles.value} ${evidence(styles)}`
235
235
  : `Styles: none found (${styles.evidence})`,
236
- `Icon set: ${ICON_SET_NAMES[findings.icons.value]} ${evidence(findings.icons)}`,
237
236
  ...(findings.provider.value
238
237
  ? [
239
238
  `Provider: ${findings.provider.value.library} needs ${findings.provider.value.component} around every view ${evidence(findings.provider)}`,
@@ -276,8 +275,6 @@ function reportFindings(
276
275
  }
277
276
  );
278
277
  finding("styles", findings.styles, findings.styles.value);
279
- finding("primitives", findings.primitives, findings.primitives.value);
280
- finding("icons", findings.icons, findings.icons.value);
281
278
  const need = findings.provider.value;
282
279
  if (need) {
283
280
  finding("provider", findings.provider, {
@@ -537,13 +534,14 @@ function nextLines(
537
534
  }
538
535
  ): string[] {
539
536
  const { agent } = decisions.packageManager.value;
540
- const start = pmCommand(agent, "run", ["studio"]).join(" ");
537
+ const start = pmCommand(agent, "run", ["dex"]).join(" ");
541
538
  // The studio's own commands run in its package, with the project's runner.
542
539
  const inPackage = cdInto(placement);
543
540
  const dex = dexRunner(agent).join(" ");
544
541
  const where = placement ? " (from the workspace root)" : "";
545
542
  // A draft has the facts; the person and their agent write the rest.
546
543
  const drafted = result.designMd.kind === "draft" && result.designMd.written;
544
+ const connected = decisions.agents.value.length > 0;
547
545
  const asks = [
548
546
  ...(drafted
549
547
  ? ['"Finish DESIGN.md with me." (it follows methods/design-md.md)']
@@ -564,7 +562,9 @@ function nextLines(
564
562
  ),
565
563
  blockers.length > 0
566
564
  ? `Then start it: ${start}${where}`
567
- : `Start the studio: ${start}${where}`,
565
+ : `Start Dex: ${start}${where}`,
566
+ // No agent chosen: there is none to ask until one is connected.
567
+ ...(connected ? [] : [`Connect your agent: ${connectInStudio()}`]),
568
568
  ...asks.map(
569
569
  (ask, index) =>
570
570
  `${index === 0 ? "Then ask your agent: " : " "}${ask}`
@@ -600,6 +600,41 @@ function cdInto(placement: Placement | undefined): string {
600
600
 
601
601
  // --- Setting up -------------------------------------------------------------------
602
602
 
603
+ const PNPM_FIELD_RE = /^pnpm@(\d+)/;
604
+ /** The first version of pnpm to stop an install on an undecided build script. */
605
+ const PNPM_STRICT_BUILDS = 11;
606
+
607
+ /**
608
+ * Whether the project's pnpm stops an install on a build script nobody
609
+ * decided on: the version its packageManager field names, else the pnpm on
610
+ * PATH. Unknown, it is taken not to.
611
+ */
612
+ function pnpmStopsOnBuilds(root: string): boolean {
613
+ let major: string | undefined;
614
+ try {
615
+ const manifest = JSON.parse(
616
+ readFileSync(join(root, "package.json"), "utf8")
617
+ ) as { packageManager?: unknown };
618
+ major = PNPM_FIELD_RE.exec(String(manifest.packageManager ?? ""))?.[1];
619
+ } catch {
620
+ // No package.json to read: the pnpm on PATH says.
621
+ }
622
+ if (major === undefined) {
623
+ try {
624
+ major = execFileSync("pnpm", ["--version"], {
625
+ cwd: root,
626
+ encoding: "utf8",
627
+ env: { ...process.env, COREPACK_ENABLE_DOWNLOAD_PROMPT: "0" },
628
+ stdio: ["ignore", "pipe", "ignore"],
629
+ timeout: 10_000,
630
+ }).split(".")[0];
631
+ } catch {
632
+ return false;
633
+ }
634
+ }
635
+ return Number(major) >= PNPM_STRICT_BUILDS;
636
+ }
637
+
603
638
  /** Read what the plan needs to know is there, from `root`. */
604
639
  async function onDisk(root: string, target: StudioTarget) {
605
640
  const { studio } = target;
@@ -646,6 +681,9 @@ async function onDisk(root: string, target: StudioTarget) {
646
681
  hostGitignore: existsSync(join(root, ".gitignore"))
647
682
  ? await read(".gitignore")
648
683
  : undefined,
684
+ pnpmWorkspace: existsSync(join(root, "pnpm-workspace.yaml"))
685
+ ? await read("pnpm-workspace.yaml")
686
+ : undefined,
649
687
  tsconfig: existing.has(tsconfig) ? await read(tsconfig) : undefined,
650
688
  read,
651
689
  };
@@ -660,7 +698,6 @@ interface Prepared {
660
698
  designSystem?: DesignSystemChoices;
661
699
  existing?: ExistingStudio;
662
700
  findings: ProjectFindings;
663
- iconPackages: Record<string, string>;
664
701
  /** In a workspace: where the studio goes, and what that adds. */
665
702
  placement?: { decided: Decided<Placement>; target: StudioTarget };
666
703
  /** Where the plan's paths start: the project, or the workspace root. */
@@ -756,16 +793,11 @@ function settled(
756
793
  ...(title ? { title } : {}),
757
794
  ...(where ? { placement: where } : {}),
758
795
  });
759
- const iconPackages = iconPackagesToAdd(
760
- decisions.icons.value,
761
- placement ? packageDirOf(placement) : root
762
- );
763
796
  return {
764
797
  cwd,
765
798
  root,
766
799
  findings,
767
800
  decisions,
768
- iconPackages,
769
801
  target,
770
802
  ...(where ? { placement: where } : {}),
771
803
  ...(workspace && placement
@@ -773,7 +805,6 @@ function settled(
773
805
  workspace: workspaceSetup(workspace, placement, findings, decisions, {
774
806
  flags,
775
807
  cwd,
776
- iconPackages,
777
808
  }),
778
809
  }
779
810
  : {}),
@@ -1066,7 +1097,6 @@ async function planFor(
1066
1097
  );
1067
1098
  const again: SetUpAgain | undefined = existing && {
1068
1099
  config: configChange(existing, prepared.designSystem, {
1069
- icons: decisions.icons.value,
1070
1100
  next: nextPackage(viewFolders) !== undefined,
1071
1101
  root,
1072
1102
  }),
@@ -1079,7 +1109,9 @@ async function planFor(
1079
1109
  existing: disk.existing,
1080
1110
  gitignore: disk.gitignore,
1081
1111
  hostGitignore: disk.hostGitignore,
1082
- iconPackages: prepared.iconPackages,
1112
+ pnpmWorkspace: disk.pnpmWorkspace,
1113
+ pnpmStopsOnBuilds:
1114
+ decisions.packageManager.value.name === "pnpm" && pnpmStopsOnBuilds(root),
1083
1115
  quiet: !ask,
1084
1116
  rootGuide: findings.rootGuide
1085
1117
  ? { file: findings.rootGuide, text: await disk.read(findings.rootGuide) }
@@ -1275,6 +1307,46 @@ const isEmpty = async (root: string): Promise<boolean> =>
1275
1307
  !existsSync(root) ||
1276
1308
  (await readdir(root)).every((name) => ALLOWED_EXISTING.has(name));
1277
1309
 
1310
+ /**
1311
+ * A new project beside what a folder holds already (an agent's `work/`, a
1312
+ * few notes): asked in a terminal, said without one. It stops, writing
1313
+ * nothing, when the project would write over any of it.
1314
+ */
1315
+ async function besideKept(
1316
+ root: string,
1317
+ project: NewProject,
1318
+ kept: string[],
1319
+ { ui, ask }: { ui: Reporter; ask: boolean }
1320
+ ): Promise<void> {
1321
+ const written = [
1322
+ ...(await starterRootNames(project.starter)),
1323
+ project.starter.workspace ? "apps" : project.dir,
1324
+ "dex.config.ts",
1325
+ ];
1326
+ const clashes = kept.filter((name) => written.includes(name));
1327
+ const shown = shownPath(root);
1328
+ if (clashes.length > 0) {
1329
+ throw new Error(
1330
+ `${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>.`
1331
+ );
1332
+ }
1333
+ const list = kept.join(", ");
1334
+ ui.event({ step: "decide", key: "kept", value: kept, source: "the folder" });
1335
+ if (!ask) {
1336
+ ui.step(
1337
+ `${shown} has no package.json: a new project goes here, beside ${list}, which stay as they are.`
1338
+ );
1339
+ return;
1340
+ }
1341
+ const yes = await ui.confirm(
1342
+ `${shown} has ${list} but no package.json. Start a new project here, beside ${kept.length === 1 ? "it" : "them"}?`,
1343
+ { initial: true }
1344
+ );
1345
+ if (!yes) {
1346
+ throw new Cancelled();
1347
+ }
1348
+ }
1349
+
1278
1350
  // How the welcome prototype imports the starters' components.
1279
1351
  const WELCOME_IMPORT = '"@/components/ui/';
1280
1352
 
@@ -1340,8 +1412,8 @@ type NewProjectAgents = { kind: "ask" } | { kind: "given"; ids: AgentId[] };
1340
1412
 
1341
1413
  /**
1342
1414
  * `--agent`, parsed: the agents it names ("none" for none). Without it, a
1343
- * new folder has no agent files to go by: asked in a terminal, else Claude
1344
- * Code.
1415
+ * new folder has no agent files to go by: asked in a terminal, else the
1416
+ * agent running setup, else Claude Code.
1345
1417
  */
1346
1418
  function newProjectAgents(
1347
1419
  flag: string | undefined,
@@ -1350,7 +1422,9 @@ function newProjectAgents(
1350
1422
  if (flag !== undefined) {
1351
1423
  return { kind: "given", ids: parseAgents(flag) };
1352
1424
  }
1353
- return ask ? { kind: "ask" } : { kind: "given", ids: ["claude"] };
1425
+ return ask
1426
+ ? { kind: "ask" }
1427
+ : { kind: "given", ids: [runningAgent()?.id ?? "claude"] };
1354
1428
  }
1355
1429
 
1356
1430
  /** The agents as the plan names them. */
@@ -1518,7 +1592,8 @@ function readyLines(
1518
1592
  }));
1519
1593
  const width = Math.max(...commands.map(({ line }) => line.length)) + 4;
1520
1594
  const lines = [
1521
- `cd ${where}`,
1595
+ // Made in this folder: there is nowhere to go.
1596
+ ...(where === "." ? [] : [`cd ${where}`]),
1522
1597
  ...commands.map(({ line, what }) => `${line.padEnd(width)}# ${what}`),
1523
1598
  ];
1524
1599
  // No agent was chosen: there is none to ask until one is connected.
@@ -1547,8 +1622,10 @@ function readyLines(
1547
1622
  async function newProject(
1548
1623
  root: string,
1549
1624
  flags: CreateFlags,
1550
- deps: CreateDeps
1625
+ deps: CreateDeps,
1626
+ names: string[]
1551
1627
  ): Promise<SetupOutcome> {
1628
+ const kept = names.filter((name) => !ALLOWED_EXISTING.has(name));
1552
1629
  const name =
1553
1630
  basename(root).toLowerCase().replace(NAME_RE, "-").replace(EDGE_RE, "") ||
1554
1631
  "my-studio";
@@ -1572,11 +1649,18 @@ async function newProject(
1572
1649
  const project: NewProject = {
1573
1650
  agents,
1574
1651
  dir: studioDir(flags.dir),
1575
- install: pmCommand(pm, "install", []),
1652
+ install: installCommand(pm),
1576
1653
  name,
1577
1654
  pm,
1578
1655
  starter,
1579
1656
  };
1657
+ if (kept.length > 0) {
1658
+ try {
1659
+ await besideKept(root, project, kept, { ui, ask });
1660
+ } catch (error) {
1661
+ return stopped(ui, error);
1662
+ }
1663
+ }
1580
1664
  if (!(ask || named)) {
1581
1665
  ui.step("A new project. Change it with its flag:", [
1582
1666
  `Template ${starter.name.padEnd(12)}${TEMPLATE_FLAG}`,
@@ -1616,7 +1700,7 @@ async function newProject(
1616
1700
  }
1617
1701
  const { plan, result } = outcome;
1618
1702
  await addWelcome(join(root, plan.studio), result.decisions.components.value);
1619
- await trackWithGit(root, flags, { ui, exec, ask });
1703
+ await trackWithGit(root, flags, { ui, exec, ask, kept });
1620
1704
  if (!flags.skipInstall) {
1621
1705
  await check(ui, join(root, plan.target.package));
1622
1706
  }
@@ -1637,7 +1721,12 @@ const inRepository = async (dir: string, exec: Exec): Promise<boolean> =>
1637
1721
  async function trackWithGit(
1638
1722
  root: string,
1639
1723
  flags: CreateFlags,
1640
- { ask, exec, ui }: { ask: boolean; exec: Exec; ui: Reporter }
1724
+ {
1725
+ ask,
1726
+ exec,
1727
+ ui,
1728
+ kept,
1729
+ }: { ask: boolean; exec: Exec; ui: Reporter; kept: string[] }
1641
1730
  ): Promise<void> {
1642
1731
  if (flags.git === false || (await inRepository(root, exec))) {
1643
1732
  return;
@@ -1660,6 +1749,24 @@ async function trackWithGit(
1660
1749
  args: ["add", "--all"],
1661
1750
  failed: "Git started, but the files weren’t added: run git add --all.",
1662
1751
  },
1752
+ // Only what setup wrote goes in the first commit: what was here is the
1753
+ // person's, left untracked.
1754
+ ...(kept.length > 0
1755
+ ? [
1756
+ {
1757
+ args: [
1758
+ "rm",
1759
+ "-r",
1760
+ "--cached",
1761
+ "--quiet",
1762
+ "--ignore-unmatch",
1763
+ "--",
1764
+ ...kept,
1765
+ ],
1766
+ failed: `Git started, but it holds what was here too: run git rm -r --cached ${kept.join(" ")} to leave it out.`,
1767
+ },
1768
+ ]
1769
+ : []),
1663
1770
  {
1664
1771
  args: ["commit", "--quiet", "--message", "Start with Dex"],
1665
1772
  failed:
@@ -1678,8 +1785,10 @@ async function trackWithGit(
1678
1785
  }
1679
1786
 
1680
1787
  /**
1681
- * `dex create [dir]`: a new project in an empty or missing folder, or the
1682
- * studio added to the project in one with a package.json.
1788
+ * `dex create [dir]`: the studio added to the project in a folder with a
1789
+ * package.json, or else a new project. A folder with files but no project
1790
+ * (an agent's `work/` and `outputs/`, notes) gets the new project beside
1791
+ * them.
1683
1792
  */
1684
1793
  export async function create(
1685
1794
  dir: string | undefined,
@@ -1688,17 +1797,14 @@ export async function create(
1688
1797
  ): Promise<SetupOutcome> {
1689
1798
  const root = resolve(dir ?? ".");
1690
1799
  if (await isEmpty(root)) {
1691
- return newProject(root, flags, deps);
1692
- }
1693
- if (flags.template !== undefined) {
1694
- throw new Error(
1695
- `--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}.`
1696
- );
1800
+ return newProject(root, flags, deps, []);
1697
1801
  }
1698
1802
  if (!existsSync(join(root, "package.json"))) {
1699
- const shown = relative(process.cwd(), root) || ".";
1803
+ return newProject(root, flags, deps, await readdir(root));
1804
+ }
1805
+ if (flags.template !== undefined) {
1700
1806
  throw new Error(
1701
- `${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.`
1807
+ `--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}.`
1702
1808
  );
1703
1809
  }
1704
1810
  return setUp(root, flags, { ...deps, workspaces: true });
@@ -12,7 +12,11 @@ import { dirname, isAbsolute, join, relative } from "node:path";
12
12
  import type { types } from "@babel/core";
13
13
  import type { ResolvedDesignSystem } from "../config/design-system.ts";
14
14
  import type { StudioInterface } from "../config/index.ts";
15
- import { componentsJsonError, projectPaths } from "../config/project-files.ts";
15
+ import {
16
+ componentsJsonError,
17
+ installedPackageDir,
18
+ projectPaths,
19
+ } from "../config/project-files.ts";
16
20
  import { posix } from "../paths.ts";
17
21
 
18
22
  /** How doctor reports: a line each, with how to fix what is wrong. */
@@ -95,18 +99,6 @@ const localTo = (root: string): ((name: string) => boolean) => {
95
99
  aliases.some((alias) => name === alias || name.startsWith(`${alias}/`));
96
100
  };
97
101
 
98
- /** Where an installed package lives, looking up from `from`. */
99
- const packageDir = (from: string, name: string): string | undefined => {
100
- let dir = from;
101
- while (dir !== dirname(dir)) {
102
- const candidate = join(dir, "node_modules", name);
103
- if (existsSync(join(candidate, "package.json"))) {
104
- return candidate;
105
- }
106
- dir = dirname(dir);
107
- }
108
- };
109
-
110
102
  // The conditions the studio's Vite resolves an export by: it builds for the
111
103
  // browser. `require` (a CommonJS build an ESM-only package never makes) and
112
104
  // `types` are another tool's.
@@ -213,7 +205,7 @@ export function unbuiltPackages(
213
205
  return importedPackages(project.designSystem)
214
206
  .filter((name) => !isLocal(name))
215
207
  .flatMap((name) => {
216
- const dir = packageDir(project.content, name);
208
+ const dir = installedPackageDir(project.content, name);
217
209
  const missing = dir ? missingExports(dir) : [];
218
210
  return missing.length > 0 ? [{ name, missing }] : [];
219
211
  });
@@ -231,7 +223,7 @@ function checkImports(
231
223
  );
232
224
  }
233
225
  for (const name of importedPackages(designSystem)) {
234
- const dir = isLocal(name) ? undefined : packageDir(content, name);
226
+ const dir = isLocal(name) ? undefined : installedPackageDir(content, name);
235
227
  // A package whose `exports` list only subpaths ("./components/*", as
236
228
  // shadcn's monorepo template has) resolves neither itself nor its
237
229
  // package.json, but is installed all the same.
@@ -204,9 +204,10 @@ function startOutput() {
204
204
  ObjC.bindFunction("kill", ["int", ["int", "int"]]);
205
205
 
206
206
  /**
207
- * Whether the server the launcher started last still runs. The launcher
208
- * clears its process id before each start and writes it once started, so
209
- * without one, it gave up before starting anything.
207
+ * Whether the server the launcher started last still runs. The pid file
208
+ * names the start the window waits on; the launcher clears it when it
209
+ * gives up, and dex app start when the port is taken, so without one,
210
+ * nothing is starting.
210
211
  */
211
212
  function startAlive() {
212
213
  const pid = Number(readText(DEX.pidFile).trim());
@@ -1,18 +1,25 @@
1
1
  // `dex app start`: what the app's launcher runs when the app opens
2
2
  // (desktop-app.ts). It shows the studio only when the server on the port is
3
3
  // this project's own Dex, and otherwise starts `dex dev` for the
4
- // project, in the background, with what it writes going to the app's log.
4
+ // project, in the background, with what it writes going to the app's log,
5
+ // unless the one it started last is still coming up.
5
6
  // The launcher has already marked the log with the time, so whatever this
6
7
  // says lands after the mark, where the app's window reads it.
7
8
 
8
9
  import { execFile, spawn } from "node:child_process";
9
10
  import { existsSync } from "node:fs";
10
- import { mkdir, open, rm, writeFile } from "node:fs/promises";
11
- import { connect } from "node:net";
11
+ import { mkdir, open, readFile, rm, stat, writeFile } from "node:fs/promises";
12
12
  import { dirname } from "node:path";
13
13
  import { promisify } from "node:util";
14
- import { lsofHolder, type PortTaken, whatHolds } from "../server/port.ts";
14
+ import {
15
+ heldOnLocalhost,
16
+ lsofHolder,
17
+ type PortTaken,
18
+ whatHolds,
19
+ } from "../server/port.ts";
15
20
  import { FROM_APP_ENV } from "../server/roster.ts";
21
+ import { ownPort, studioFor } from "../server/studio-for.ts";
22
+ import { GIVE_UP_AFTER_MS } from "../shared/server-page.ts";
16
23
  import { logFile, pidFile, projectGone } from "./desktop-app.ts";
17
24
 
18
25
  const run = promisify(execFile);
@@ -22,8 +29,6 @@ export const DEFAULT_PATH =
22
29
  "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
23
30
  /** How long the login shell may take to say its PATH. */
24
31
  const SHELL_TIMEOUT_MS = 5000;
25
- /** How long the port may take to answer a connection. */
26
- const CONNECT_TIMEOUT_MS = 1000;
27
32
  /** Comes before the PATH in the shell's output, past whatever its startup prints. */
28
33
  const PATH_MARK = "__DEX_PATH__";
29
34
 
@@ -35,8 +40,11 @@ export type AppStart =
35
40
  | { state: "started"; pid: number }
36
41
  /** The project is not where the app was made for it. */
37
42
  | { state: "gone"; message: string }
38
- /** Something other than this project's Dex holds the port. */
39
- | { state: "taken"; taken: PortTaken };
43
+ /**
44
+ * Something other than this project's Dex holds the port. `ownUrl` is
45
+ * where this project's Dex answers instead, when it runs on another port.
46
+ */
47
+ | { state: "taken"; taken: PortTaken; ownUrl?: string };
40
48
 
41
49
  export interface AppStartOptions {
42
50
  /** The `dex` to run `dev` with. */
@@ -55,19 +63,6 @@ export interface AppStartOptions {
55
63
  runtime: string;
56
64
  }
57
65
 
58
- /** Whether anything accepts a connection on the port, on localhost. */
59
- const listening = (port: number): Promise<boolean> =>
60
- new Promise((answer) => {
61
- const socket = connect({ port, host: "localhost" });
62
- const done = (open: boolean) => {
63
- socket.destroy();
64
- answer(open);
65
- };
66
- socket.setTimeout(CONNECT_TIMEOUT_MS, () => done(false));
67
- socket.once("connect", () => done(true));
68
- socket.once("error", () => done(false));
69
- });
70
-
71
66
  /**
72
67
  * The PATH the person's own shell sets up at login, as a terminal has it:
73
68
  * the app is opened with only the system's, and `dex dev` runs git,
@@ -132,21 +127,94 @@ async function startDev(options: AppStartOptions): Promise<number> {
132
127
  }
133
128
  }
134
129
 
130
+ /**
131
+ * The `dex dev` the last start began, while it may still come up: alive,
132
+ * and started less than the minute the app's window waits for it. Past
133
+ * that, its pid may be another process's.
134
+ */
135
+ async function startUnderWay(file: string): Promise<number | undefined> {
136
+ try {
137
+ const [text, { mtimeMs }] = await Promise.all([
138
+ readFile(file, "utf8"),
139
+ stat(file),
140
+ ]);
141
+ const pid = Number(text.trim());
142
+ const young = Date.now() - mtimeMs <= GIVE_UP_AFTER_MS;
143
+ // 0 would ask about this process's own group.
144
+ if (!(Number.isInteger(pid) && pid > 0 && young)) {
145
+ return;
146
+ }
147
+ // Signal 0 asks only whether the process is there.
148
+ process.kill(pid, 0);
149
+ return pid;
150
+ } catch {
151
+ return;
152
+ }
153
+ }
154
+
155
+ /**
156
+ * The port this project's Dex is on, as its roster says, or undefined.
157
+ * On the app's port, it was only slow to answer, and the app opens it. On
158
+ * another port, the app can't open it, so it says where it is.
159
+ */
160
+ async function ownDexPort(
161
+ root: string,
162
+ port: number,
163
+ holderOf: typeof lsofHolder
164
+ ): Promise<number | undefined> {
165
+ try {
166
+ // Loads Vite, so only once the port is taken.
167
+ const { loadProject } = await import("../config/load.ts");
168
+ const { content } = await loadProject(root);
169
+ return ownPort(await studioFor({ content, root, port }, { holderOf }));
170
+ } catch {
171
+ // No config to find its roster by: there is nothing more to say.
172
+ return;
173
+ }
174
+ }
175
+
135
176
  /**
136
177
  * Show this project's Dex, or start it: never a server another project,
137
- * or anything else, put on the port.
178
+ * or anything else, put on the port. The app's start link asks again as
179
+ * the app opens: then the `dex dev` it started is still coming up, and
180
+ * it waits on that one rather than start another.
138
181
  */
139
182
  export async function startForApp(options: AppStartOptions): Promise<AppStart> {
140
183
  const { home, project, root, port, holderOf = lsofHolder } = options;
141
- await rm(pidFile(home, project), { force: true });
184
+ // The window watches it: cleared, the start has failed.
185
+ const pidPath = pidFile(home, project);
142
186
  if (!existsSync(root)) {
187
+ await rm(pidPath, { force: true });
143
188
  return { state: "gone", message: projectGone(root, home) };
144
189
  }
145
190
  // Where the machine update's check is to run, once there is one, so the
146
191
  // window opens with the right notice.
147
- if (await listening(port)) {
192
+ if (await heldOnLocalhost(port)) {
148
193
  const taken = await whatHolds(port, project, holderOf);
149
- return taken.sameProject ? { state: "running" } : { state: "taken", taken };
194
+ if (taken.sameProject) {
195
+ // A window still waiting on the start that brought it up keeps it.
196
+ return { state: "running" };
197
+ }
198
+ // This project's start may hold the port before its manifest answers.
199
+ // While that start is young, anything but another project's Dex is
200
+ // waited on. If it is something else, that start fails and says so.
201
+ const underWay =
202
+ taken.by === "Dex" ? undefined : await startUnderWay(pidPath);
203
+ if (underWay) {
204
+ return { state: "started", pid: underWay };
205
+ }
206
+ const own = await ownDexPort(root, port, holderOf);
207
+ if (own === port) {
208
+ // This project's Dex, slower to answer than the first ask waited.
209
+ return { state: "running" };
210
+ }
211
+ await rm(pidPath, { force: true });
212
+ return {
213
+ state: "taken",
214
+ taken,
215
+ ...(own === undefined ? {} : { ownUrl: `http://localhost:${own}` }),
216
+ };
150
217
  }
151
- return { state: "started", pid: await startDev(options) };
218
+ const pid = (await startUnderWay(pidPath)) ?? (await startDev(options));
219
+ return { state: "started", pid };
152
220
  }