@dexhq/canvas 0.13.0 → 0.14.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 (159) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +16 -15
  3. package/app/canvas/frame-node.tsx +34 -17
  4. package/app/canvas/tool-cursors.ts +16 -16
  5. package/app/i18n/locales/en/messages.po +26 -4
  6. package/app/i18n/locales/en/messages.ts +1 -1
  7. package/app/i18n/locales/pseudo/messages.po +26 -4
  8. package/app/i18n/locales/pseudo/messages.ts +1 -1
  9. package/app/icons/{sets/lucide.tsx → glyphs.tsx} +3 -5
  10. package/app/icons/index.tsx +3 -3
  11. package/app/icons/types.ts +3 -10
  12. package/app/index.html +3 -3
  13. package/app/pages/canvas-settings.tsx +35 -0
  14. package/app/shell/about.tsx +5 -4
  15. package/app/shell/feedback-details.ts +0 -3
  16. package/app/shell/instructions-editor.tsx +1 -1
  17. package/app/shell/presence-style.ts +59 -0
  18. package/app/shell/presence.tsx +6 -3
  19. package/app/shell/settings-sections.ts +12 -0
  20. package/app/shell/sidebar.tsx +1 -1
  21. package/app/studio-ui.d.ts +0 -9
  22. package/app/ui/prompt-editor.tsx +1 -1
  23. package/dist/cli/commands/create.d.mts +26 -14
  24. package/dist/cli/commands/create.mjs +13 -7
  25. package/dist/cli/commands/dev.mjs +2 -3
  26. package/dist/cli/commands/init.d.mts +11 -6
  27. package/dist/cli/help.d.mts +1 -1
  28. package/dist/cli/help.mjs +3 -3
  29. package/dist/cli/main.d.mts +22 -12
  30. package/dist/config/index.d.mts +6 -5
  31. package/dist/config/project-files.d.mts +0 -3
  32. package/dist/config/project-files.mjs +0 -3
  33. package/dist/config/schema.d.mts +0 -5
  34. package/dist/config/schema.mjs +0 -5
  35. package/dist/content/content.mjs +0 -3
  36. package/dist/content/snapshot-client.mjs +1 -1
  37. package/dist/paste/paste.mjs +1 -1
  38. package/dist/server/brief.mjs +3 -3
  39. package/dist/server/channel.d.mts +6 -0
  40. package/dist/server/channel.mjs +16 -1
  41. package/dist/server/claimed-presence.d.mts +17 -0
  42. package/dist/server/claimed-presence.mjs +50 -0
  43. package/dist/server/dev-server.mjs +9 -0
  44. package/dist/server/file-errors.d.mts +7 -2
  45. package/dist/server/file-errors.mjs +31 -8
  46. package/dist/server/requests.mjs +1 -1
  47. package/dist/server/studio-for.mjs +1 -1
  48. package/dist/server/vite.mjs +26 -29
  49. package/dist/server/web-app.mjs +3 -3
  50. package/dist/setup/apply.mjs +8 -14
  51. package/dist/setup/create.mjs +51 -19
  52. package/dist/setup/desktop-app.mjs +1 -1
  53. package/dist/setup/detect.d.mts +14 -5
  54. package/dist/setup/detect.mjs +56 -8
  55. package/dist/setup/doctor.mjs +1 -3
  56. package/dist/setup/existing-setup.d.mts +1 -3
  57. package/dist/setup/existing-setup.mjs +10 -11
  58. package/dist/setup/own-app.d.mts +1 -2
  59. package/dist/setup/own-app.mjs +4 -5
  60. package/dist/setup/plan.d.mts +8 -6
  61. package/dist/setup/plan.mjs +64 -48
  62. package/dist/setup/project.d.mts +0 -16
  63. package/dist/setup/project.mjs +8 -52
  64. package/dist/setup/prompts.d.mts +5 -5
  65. package/dist/setup/prompts.mjs +28 -61
  66. package/dist/setup/questions.d.mts +12 -4
  67. package/dist/setup/questions.mjs +10 -25
  68. package/dist/setup/starters.mjs +19 -8
  69. package/dist/setup/workspace-setup.d.mts +1 -2
  70. package/dist/setup/workspace-setup.mjs +4 -6
  71. package/dist/setup/write.d.mts +15 -5
  72. package/dist/setup/write.mjs +35 -9
  73. package/dist/shared/server-page.mjs +6 -0
  74. package/extension/dist/feedback.js +1 -1
  75. package/extension/dist/manifest.json +1 -1
  76. package/package.json +2 -19
  77. package/src/cli/commands/create.ts +17 -9
  78. package/src/cli/commands/dev.ts +0 -3
  79. package/src/cli/help.ts +3 -3
  80. package/src/config/index.ts +6 -5
  81. package/src/config/project-files.ts +0 -5
  82. package/src/config/schema.ts +0 -1
  83. package/src/content/content.ts +0 -3
  84. package/src/content/snapshot-client.ts +1 -1
  85. package/src/server/brief.ts +8 -3
  86. package/src/server/channel.ts +27 -0
  87. package/src/server/claimed-presence.ts +77 -0
  88. package/src/server/dev-server.ts +13 -0
  89. package/src/server/file-errors.ts +47 -13
  90. package/src/server/studio-for.ts +1 -1
  91. package/src/server/vite.ts +37 -40
  92. package/src/server/web-app.ts +3 -3
  93. package/src/setup/apply.ts +10 -16
  94. package/src/setup/create.ts +52 -20
  95. package/src/setup/desktop-app.ts +1 -1
  96. package/src/setup/detect.ts +56 -10
  97. package/src/setup/doctor.ts +4 -4
  98. package/src/setup/existing-setup.ts +10 -12
  99. package/src/setup/own-app.ts +2 -5
  100. package/src/setup/plan.ts +93 -84
  101. package/src/setup/project.ts +16 -110
  102. package/src/setup/prompts.ts +44 -127
  103. package/src/setup/questions.ts +27 -29
  104. package/src/setup/starters.ts +27 -9
  105. package/src/setup/workspace-setup.ts +8 -18
  106. package/src/setup/write.ts +52 -9
  107. package/src/shared/server-page.ts +9 -0
  108. package/templates/methods/review.md +2 -2
  109. package/templates/rules/canvas-frames.md +104 -0
  110. package/templates/rules/canvas.md +8 -142
  111. package/templates/rules/prototypes.md +1 -1
  112. package/templates/rules/snapshots.md +52 -0
  113. package/templates/starters/standalone/README.md +7 -7
  114. package/templates/starters/standalone/components.json +1 -1
  115. package/templates/starters/standalone/package.json +1 -2
  116. package/templates/starters/turborepo/README.md +6 -6
  117. package/templates/starters/turborepo/apps/web/components.json +1 -1
  118. package/templates/starters/turborepo/apps/web/package.json +1 -2
  119. package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
  120. package/templates/starters/turborepo/packages/ui/components.json +1 -1
  121. package/templates/starters/turborepo/packages/ui/package.json +1 -2
  122. package/templates/starters/vite/README.md +7 -6
  123. package/templates/starters/vite/components.json +1 -1
  124. package/templates/starters/vite/package.json +1 -2
  125. package/templates/starters/vite/src/app.tsx +3 -4
  126. package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
  127. package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
  128. package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
  129. package/templates/starters/vite/src/components/ui/button.tsx +17 -12
  130. package/templates/starters/vite/src/components/ui/card.tsx +1 -1
  131. package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
  132. package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
  133. package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
  134. package/templates/starters/vite/src/components/ui/field.tsx +3 -1
  135. package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
  136. package/templates/starters/vite/src/components/ui/input.tsx +1 -1
  137. package/templates/starters/vite/src/components/ui/label.tsx +2 -0
  138. package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
  139. package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
  140. package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
  141. package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
  142. package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
  143. package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
  144. package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
  145. package/templates/starters/vite/src/index.css +533 -111
  146. package/app/icons/sets/hugeicons.tsx +0 -259
  147. package/app/icons/sets/phosphor.tsx +0 -251
  148. package/dist/server/icon-set.d.mts +0 -15
  149. package/dist/server/icon-set.mjs +0 -31
  150. package/dist/shared/icon-sets.d.mts +0 -9
  151. package/dist/shared/icon-sets.mjs +0 -21
  152. package/src/server/icon-set.ts +0 -56
  153. package/src/shared/icon-sets.ts +0 -23
  154. /package/app/public/{sudio-192.png → dex-192.png} +0 -0
  155. /package/app/public/{sudio-512.png → dex-512.png} +0 -0
  156. /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
  157. /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
  158. /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
  159. /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
@@ -1,13 +1,12 @@
1
1
  import { PACKAGE_NAME } from "../paths.mjs";
2
2
  import { STUDIO_FILES } from "../shared/studio-files.mjs";
3
- import { ICON_SET_NAMES } from "../shared/icon-sets.mjs";
4
3
  import { parseJsonc } from "../config/project-files.mjs";
5
4
  import { listing } from "../shared/listing.mjs";
6
5
  import { designMdDetail, fromProject } from "./design-md-setup.mjs";
7
6
  import { pmCommand } from "../config/package-manager.mjs";
8
7
  import { agentName } from "./project.mjs";
9
- import { OLD_SCRIPTS, STUDIO_TYPES_FILE, hasPointer, ignoreFile, missingIgnoreLines, missingScripts } from "./write.mjs";
10
- import { PROVIDER_FILE } from "./questions.mjs";
8
+ import { OLD_SCRIPTS, STUDIO_TYPES_FILE, hasPointer, ignoreFile, missingIgnoreLines, missingScripts, pnpmDecidesEsbuild, withEsbuildBuilds } from "./write.mjs";
9
+ import { PROVIDER_FILE, shadcnInitFlags } from "./questions.mjs";
11
10
  //#region src/setup/plan.ts
12
11
  /** `path` in the package at `folder`: "apps/web/package.json". */
13
12
  const inPackage = (folder, path) => folder === "." ? path : `${folder}/${path}`;
@@ -29,37 +28,34 @@ const AGENT_DETAIL = {
29
28
  };
30
29
  /** A command as one line: "bun add -D @dexhq/canvas". */
31
30
  const commandLine = (command) => command.join(" ");
31
+ /**
32
+ * npm's audit and funding notes are about the project's whole tree, not the
33
+ * studio: setup leaves them out of its installs, as shadcn does.
34
+ */
35
+ const quietly = (agent, command) => agent === "npm" ? [
36
+ ...command,
37
+ "--no-audit",
38
+ "--no-fund"
39
+ ] : command;
32
40
  /** `<manager> add -D <specs>`, as the project's package manager writes it. */
33
- const addCommand = (agent, ...specs) => pmCommand(agent, "add", ["-D", ...specs]);
34
- /** As an install names them: "@phosphor-icons/react@^2.1.10". */
35
- const specsOf = (packages) => Object.entries(packages).map(([name, range]) => `${name}@${range}`);
36
- const withIcons = (input, detail) => Object.keys(input.iconPackages).length > 0 ? `${detail}, and ${ICON_SET_NAMES[input.decisions.icons.value]}, its icon set` : detail;
37
- /** The icon set's packages on their own, for a project that has the studio. */
38
- function iconSteps(input) {
39
- const icons = specsOf(input.iconPackages);
40
- if (icons.length === 0) return [];
41
- return [{
42
- action: "run",
43
- run: "install",
44
- command: addCommand(input.decisions.packageManager.value.agent, ...icons),
45
- detail: `${ICON_SET_NAMES[input.decisions.icons.value]}, the icon set`
46
- }];
47
- }
41
+ const addCommand = (agent, ...specs) => quietly(agent, pmCommand(agent, "add", ["-D", ...specs]));
42
+ /** `<manager> install`, as the project's package manager writes it. */
43
+ const installCommand = (agent) => quietly(agent, pmCommand(agent, "install", []));
48
44
  function againSteps(input, again) {
49
45
  const { agent } = input.decisions.packageManager.value;
50
46
  if (again.upgrade) return [{
51
47
  action: "run",
52
48
  run: "install",
53
- command: addCommand(agent, `${PACKAGE_NAME}@${again.upgrade.to}`, ...specsOf(input.iconPackages)),
54
- detail: withIcons(input, `the studio, ${again.upgrade.from} → ${again.upgrade.to}: what this setup writes needs it`)
49
+ command: addCommand(agent, `${PACKAGE_NAME}@${again.upgrade.to}`),
50
+ detail: `the studio, ${again.upgrade.from} → ${again.upgrade.to}: what this setup writes needs it`
55
51
  }];
56
52
  if (!again.installed) return [{
57
53
  action: "run",
58
54
  run: "install",
59
- command: pmCommand(agent, "install", []),
55
+ command: installCommand(agent),
60
56
  detail: "the studio is in package.json, not installed yet"
61
- }, ...iconSteps(input)];
62
- return iconSteps(input);
57
+ }];
58
+ return [];
63
59
  }
64
60
  /** The install, or the advice that replaces it, for how the studio is in. */
65
61
  function installSteps(input) {
@@ -67,43 +63,41 @@ function installSteps(input) {
67
63
  if (skipInstall) return [];
68
64
  const { again } = input;
69
65
  if (workspace) {
70
- const asks = workspace.studioSpec || Object.keys(input.iconPackages).length > 0;
71
- if (again?.installed && !asks) return [];
66
+ if (again?.installed && !workspace.studioSpec) return [];
72
67
  const links = workspace.app?.designSystem ? `, and links ${workspace.app.designSystem}` : "";
73
68
  return [{
74
69
  action: "run",
75
70
  run: "install",
76
71
  command: workspace.install,
77
- detail: withIcons(input, workspace.studioSpec ? `from the workspace root: ${PACKAGE_NAME} ${workspace.studioSpec}${links}` : "from the workspace root")
72
+ detail: workspace.studioSpec ? `from the workspace root: ${PACKAGE_NAME} ${workspace.studioSpec}${links}` : "from the workspace root"
78
73
  }];
79
74
  }
80
75
  const { agent, name } = decisions.packageManager.value;
81
- const icons = specsOf(input.iconPackages);
82
76
  if (studioSpec) return [{
83
77
  action: "run",
84
78
  run: "install",
85
- command: addCommand(agent, `${PACKAGE_NAME}@${studioSpec}`, ...icons),
86
- detail: withIcons(input, `the studio, from ${studioSpec}`)
79
+ command: addCommand(agent, `${PACKAGE_NAME}@${studioSpec}`),
80
+ detail: `the studio, from ${studioSpec}`
87
81
  }];
88
- if (studioPackage.kind === "listed") return again ? againSteps(input, again) : iconSteps(input);
82
+ if (studioPackage.kind === "listed") return again ? againSteps(input, again) : [];
89
83
  if (studioPackage.kind === "linked") {
90
84
  if (name === "bun") return [{
91
85
  action: "run",
92
86
  run: "link",
93
87
  command: addCommand(agent, `link:${PACKAGE_NAME}`),
94
88
  detail: "keeps the linked studio in package.json, not installed from npm"
95
- }, ...iconSteps(input)];
89
+ }];
96
90
  return [{
97
91
  action: "ask",
98
- command: commandLine(addCommand(agent, `${PACKAGE_NAME}@${name === "npm" ? "file" : "link"}:${studioPackage.dir}`, ...icons)),
92
+ command: commandLine(addCommand(agent, `${PACKAGE_NAME}@${name === "npm" ? "file" : "link"}:${studioPackage.dir}`)),
99
93
  detail: `${PACKAGE_NAME} is linked into this project, so it is not installed. It is not in package.json, so the next install may remove the link. To keep it, run`
100
94
  }];
101
95
  }
102
96
  return [{
103
97
  action: "run",
104
98
  run: "install",
105
- command: addCommand(agent, PACKAGE_NAME, ...icons),
106
- detail: withIcons(input, "the studio")
99
+ command: addCommand(agent, PACKAGE_NAME),
100
+ detail: "the studio"
107
101
  }];
108
102
  }
109
103
  /** A file the decisions name, as the person gave it: from the project. */
@@ -128,6 +122,15 @@ function configDetail(input) {
128
122
  if (designMd.value.kind === "link") parts.push(`guide ${shownFrom(input, designMd.value.file)}`);
129
123
  return parts.join(", ");
130
124
  }
125
+ /**
126
+ * What `shadcn init` is given: the preset and library chosen, or, asking
127
+ * nothing, its defaults (`--defaults`: the base-nova preset).
128
+ */
129
+ function shadcnArgs(init, quiet) {
130
+ const chosen = shadcnInitFlags(init);
131
+ if (!quiet) return chosen;
132
+ return [...init.preset ? chosen : ["--defaults", ...chosen], "--yes"];
133
+ }
131
134
  /** shadcn first, when the person has no components yet. */
132
135
  function shadcnSteps(input) {
133
136
  const { decisions, quiet } = input;
@@ -138,7 +141,8 @@ function shadcnSteps(input) {
138
141
  command: pmCommand(decisions.packageManager.value.agent, "execute", [
139
142
  "shadcn@latest",
140
143
  "init",
141
- ...quiet ? ["--defaults", "--yes"] : []
144
+ ...shadcnArgs(decisions.components.value, quiet),
145
+ "button"
142
146
  ]),
143
147
  interactive: !quiet,
144
148
  detail: "sets up shadcn's components and styles first"
@@ -152,11 +156,10 @@ function tsconfigDetail(input) {
152
156
  return app ? "views import packages as your apps do" : "views type-checked on their own: the project has no tsconfig";
153
157
  }
154
158
  /** Its own app's package.json: the line that says what it depends on. */
155
- function appDetail(app, iconPackages) {
159
+ function appDetail(app) {
156
160
  const parts = [PACKAGE_NAME];
157
161
  if (app.designSystem) parts.push(`${app.designSystem} ${app.dependencies[app.designSystem]}`);
158
162
  parts.push(`react ${app.dependencies.react}`);
159
- for (const [name, range] of Object.entries(iconPackages)) parts.push(`${name} ${range}`);
160
163
  return parts.join(", ");
161
164
  }
162
165
  /** Its own app's package.json and turbo.json, when it is its own app. */
@@ -167,7 +170,7 @@ function appSteps(input, target) {
167
170
  action: "create",
168
171
  write: "app-package",
169
172
  path: inPackage(target.package, "package.json"),
170
- detail: appDetail(app, input.iconPackages)
173
+ detail: appDetail(app)
171
174
  }];
172
175
  if (app.turbo) steps.push({
173
176
  action: "create",
@@ -267,7 +270,7 @@ function studioSteps(input, target) {
267
270
  ...tsconfigSteps(input, studio)
268
271
  ];
269
272
  }
270
- /** "+ script "studio"". */
273
+ /** "+ script "dex"". */
271
274
  const scriptsDetail = (names) => `+ ${names.length === 1 ? "script" : "scripts"} ${names.map((name) => `"${name}"`).join(", ")}`;
272
275
  const studioDetail = (input, spec) => input.again?.upgrade ? `devDependency ${PACKAGE_NAME} ${input.again.upgrade.from} → ${spec}` : `+ devDependency ${PACKAGE_NAME} ${spec}`;
273
276
  /** The package's own package.json, and the root's, with the studio's scripts. */
@@ -278,11 +281,7 @@ function scriptSteps(input, target) {
278
281
  if (!own || input.again) {
279
282
  const path = inPackage(target.package, "package.json");
280
283
  const scripts = own ? [] : Object.keys(missingScripts(input.scripts));
281
- const added = [
282
- ...scripts.length > 0 ? [scriptsDetail(scripts)] : [],
283
- ...workspace?.studioSpec ? [studioDetail(input, workspace.studioSpec)] : [],
284
- ...workspace ? Object.entries(input.iconPackages).map(([name, range]) => `+ devDependency ${name} ${range}`) : []
285
- ];
284
+ const added = [...scripts.length > 0 ? [scriptsDetail(scripts)] : [], ...workspace?.studioSpec ? [studioDetail(input, workspace.studioSpec)] : []];
286
285
  if (added.length > 0 && existing.has(path)) steps.push({
287
286
  action: "edit",
288
287
  write: "scripts",
@@ -290,11 +289,11 @@ function scriptSteps(input, target) {
290
289
  detail: added.join(", ")
291
290
  });
292
291
  }
293
- if (workspace && !("studio" in workspace.rootScripts)) steps.push({
292
+ if (workspace && !("dex" in workspace.rootScripts)) steps.push({
294
293
  action: "edit",
295
294
  write: "root-script",
296
295
  path: "package.json",
297
- detail: `+ script "studio": "${workspace.studioScript}"`
296
+ detail: `+ script "dex": "${workspace.studioScript}"`
298
297
  });
299
298
  return steps;
300
299
  }
@@ -348,6 +347,23 @@ function noteSteps(input, target) {
348
347
  });
349
348
  return notes;
350
349
  }
350
+ /**
351
+ * With pnpm 11 or later, what the project says about esbuild's install
352
+ * script, when it says nothing yet and the studio is about to be installed:
353
+ * pnpm stops the install otherwise (write.ts, withEsbuildBuilds). pnpm 10
354
+ * only warns, so its projects keep their files as they are.
355
+ */
356
+ function pnpmSteps(input) {
357
+ const yaml = input.pnpmWorkspace ?? "";
358
+ const installs = input.skipInstall || installSteps(input).some((step) => step.action === "run");
359
+ if (input.decisions.packageManager.value.name !== "pnpm" || !input.pnpmStopsOnBuilds || !installs || pnpmDecidesEsbuild(yaml) || withEsbuildBuilds(yaml) === void 0) return [];
360
+ return [{
361
+ action: input.pnpmWorkspace === void 0 ? "create" : "edit",
362
+ write: "pnpm-builds",
363
+ path: "pnpm-workspace.yaml",
364
+ detail: "+ allowBuilds: esbuild: false (the studio's Vite runs without its install script; pnpm 11 stops without a choice)"
365
+ }];
366
+ }
351
367
  /** Every step `dex create` takes, in order. */
352
368
  function planSetup(input) {
353
369
  const target = input.target ?? {
@@ -356,7 +372,6 @@ function planSetup(input) {
356
372
  studio: input.decisions.dir.value
357
373
  };
358
374
  return {
359
- iconPackages: input.iconPackages,
360
375
  studio: target.studio,
361
376
  target,
362
377
  ...input.workspace ? { workspace: input.workspace } : {},
@@ -367,6 +382,7 @@ function planSetup(input) {
367
382
  ...projectSteps(input, target),
368
383
  ...agentSteps(input),
369
384
  ...noteSteps(input, target),
385
+ ...pnpmSteps(input),
370
386
  ...installSteps(input)
371
387
  ]
372
388
  };
@@ -394,4 +410,4 @@ function planCounts(plan) {
394
410
  };
395
411
  }
396
412
  //#endregion
397
- export { AGENT_FILES, addCommand, changesAnything, commandLine, inPackage, planCounts, planLines, planSetup };
413
+ export { AGENT_FILES, addCommand, changesAnything, commandLine, inPackage, installCommand, planCounts, planLines, planSetup };
@@ -1,5 +1,4 @@
1
1
  import { StylingApproach } from "../shared/design-system.mjs";
2
- import { InterfaceIcons } from "../shared/icon-sets.mjs";
3
2
  import { FoundDesignMd } from "./design-md.mjs";
4
3
  import { Finding } from "./findings.mjs";
5
4
  import { AgentId, ComponentLibrary } from "./detect.mjs";
@@ -25,11 +24,6 @@ export interface ComponentsChoice {
25
24
  dir: string;
26
25
  /** Relative to the project, with forward slashes: "src/components/ui". */
27
26
  folder: string;
28
- /**
29
- * The icon set they draw with (components.json's iconLibrary), when the
30
- * studio's interface has it too.
31
- */
32
- icons?: InterfaceIcons;
33
27
  /** How prototypes import them: "@/components/ui"; undefined when unknown. */
34
28
  import: string | undefined;
35
29
  /** The first few components' names, to recognise the folder by. */
@@ -91,12 +85,9 @@ export interface ProjectFindings {
91
85
  imports: string[];
92
86
  styling: StylingApproach | undefined;
93
87
  };
94
- /** The icon set the project draws with already, else Lucide. */
95
- icons: Finding<InterfaceIcons>;
96
88
  /** The package's name, from package.json. */
97
89
  name: string | undefined;
98
90
  packageManager: Finding<PackageManagerChoice>;
99
- primitives: Finding<boolean>;
100
91
  /** A provider the design system needs around every view, when it needs one. */
101
92
  provider: Finding<ProviderNeed | undefined>;
102
93
  /** Absolute: the project's folder. */
@@ -116,13 +107,6 @@ export interface ProjectFindings {
116
107
  export declare function componentsChoice(library: ComponentLibrary, root: string): ComponentsChoice;
117
108
  /** The components in a folder someone named, as setup offers them. */
118
109
  export declare const componentsAt: (root: string, folder: string) => ComponentsChoice;
119
- /**
120
- * `source` names the components.json. Beside Lucide, which shadcn's
121
- * components bring, another set is the one chosen.
122
- */
123
- export declare function iconsFinding(root: string, components: ComponentsChoice | undefined, source: string): Finding<InterfaceIcons>;
124
- /** At the range @dexhq/canvas asks for; Lucide's comes with @dexhq/canvas. */
125
- export declare function iconPackagesToAdd(set: InterfaceIcons, dir: string): Record<string, string>;
126
110
  export declare const agentName: (id: AgentId) => string;
127
111
  /**
128
112
  * How to connect an agent from the studio's "Connect your agent" dialog:
@@ -1,11 +1,10 @@
1
- import { PACKAGE_NAME, posix as posix$1, studioPeer } from "../paths.mjs";
1
+ import { PACKAGE_NAME, posix as posix$1 } from "../paths.mjs";
2
2
  import { STUDIO_FILES } from "../shared/studio-files.mjs";
3
- import { ICON_SET_PACKAGES, iconSetsIn } from "../shared/icon-sets.mjs";
4
3
  import { dependenciesOf, exportedComponents, filesImport, packageAt, packageFolder } from "../config/project-files.mjs";
5
4
  import { found } from "./findings.mjs";
6
5
  import { findWorkspace, isInside } from "./detect/workspace.mjs";
7
6
  import { designMdFinding } from "./design-md-setup.mjs";
8
- import { builtGlobalCss, componentLibraries, detectAgentsWithEvidence, detectDesignSystem, globalCssFiles, isMixedFolder, libraryAt } from "./detect.mjs";
7
+ import { builtGlobalCss, componentLibraries, detectAgentsWithEvidence, detectDesignSystem, globalCssFiles, isMixedFolder, libraryAt, runningAgent } from "./detect.mjs";
9
8
  import { providerFinding } from "./provider.mjs";
10
9
  import { createRequire } from "node:module";
11
10
  import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
@@ -45,7 +44,6 @@ function componentsChoice(library, root) {
45
44
  count: library.components.length,
46
45
  names: library.components.slice(0, NAMES_SHOWN).map(({ path }) => path),
47
46
  baseUi: Boolean(library.baseUi),
48
- ...library.icons ? { icons: library.icons } : {},
49
47
  styles: library.globalCss ? posix$1(library.globalCss) : void 0
50
48
  };
51
49
  }
@@ -105,50 +103,6 @@ function stylesFinding(root, components, source) {
105
103
  }
106
104
  return found(first, `${first} imports Tailwind or defines tokens`, "likely", rest);
107
105
  }
108
- function primitivesFinding(components, source) {
109
- if (components?.baseUi && components.import) return found(true, `${source} → style is shadcn on Base UI`);
110
- return found(false, components ? "your components are not shadcn on Base UI" : "no components to build it from");
111
- }
112
- /** Icon packages people draw with that Dex's interface has no set for. */
113
- const OTHER_ICON_PACKAGES = [
114
- "@heroicons/react",
115
- "@primer/octicons-react",
116
- "@radix-ui/react-icons",
117
- "@tabler/icons-react",
118
- "@mui/icons-material",
119
- "@fortawesome/react-fontawesome",
120
- "@iconify/react",
121
- "@remixicon/react",
122
- "react-icons"
123
- ];
124
- /**
125
- * `source` names the components.json. Beside Lucide, which shadcn's
126
- * components bring, another set is the one chosen.
127
- */
128
- function iconsFinding(root, components, source) {
129
- if (components?.icons) return found(components.icons, `${source} → iconLibrary`, "certain");
130
- const home = components && packageFolder(components.dir);
131
- const manifests = [...home && home !== root ? [home] : [], root];
132
- const [first, ...rest] = manifests.flatMap((dir) => iconSetsIn(dependenciesOf(dir).all).sort((a, b) => Number(a === "lucide") - Number(b === "lucide")).map((set) => ({
133
- dir,
134
- set
135
- })));
136
- if (!first) {
137
- const other = manifests.flatMap((dir) => {
138
- const { all } = dependenciesOf(dir);
139
- return OTHER_ICON_PACKAGES.filter((name) => all[name]);
140
- }).at(0);
141
- return found("lucide", other ? `${other} isn't one Dex draws with, so Lucide` : "no iconLibrary in components.json, and no icon set in package.json, so Lucide", "likely");
142
- }
143
- const others = [...new Set(rest.map(({ set }) => set))].filter((set) => set !== first.set);
144
- return found(first.set, `${shown(root, join(first.dir, "package.json"))} → ${ICON_SET_PACKAGES[first.set][0]}`, others.length > 0 ? "guess" : "likely", others);
145
- }
146
- /** At the range @dexhq/canvas asks for; Lucide's comes with @dexhq/canvas. */
147
- function iconPackagesToAdd(set, dir) {
148
- if (set === "lucide") return {};
149
- const declared = dependenciesOf(dir).all;
150
- return Object.fromEntries(ICON_SET_PACKAGES[set].filter((name) => !declared[name]).map((name) => [name, studioPeer(name) ?? "*"]));
151
- }
152
106
  const AGENT_NAMES = {
153
107
  claude: "Claude Code",
154
108
  codex: "Codex",
@@ -166,7 +120,11 @@ const AGENT_IDS = Object.keys(AGENT_NAMES);
166
120
  function agentsFinding(root) {
167
121
  const agents = detectAgentsWithEvidence(root);
168
122
  if (agents.length === 0) return found([], "no agent's files in this folder", "likely");
169
- return found(agents.map(({ id }) => id), `found ${agents.map(({ evidence }) => evidence).join(", ")}`);
123
+ const running = runningAgent();
124
+ const files = agents.filter(({ id }) => id !== running?.id).map(({ evidence }) => evidence);
125
+ const said = [...running ? [`running this: ${running.evidence} is set`] : [], ...files.length > 0 ? [`found ${files.join(", ")}`] : []].join("; ");
126
+ const onlyGuide = agents.length === 1 && agents[0]?.evidence === "AGENTS.md";
127
+ return found(agents.map(({ id }) => id), said, onlyGuide ? "likely" : "certain");
170
128
  }
171
129
  const LOCKFILES = [
172
130
  ["bun.lock", "bun"],
@@ -286,8 +244,6 @@ async function findProject(root, options = {}) {
286
244
  ...workspace.isWorkspace ? { workspaceRoot: workspace.root } : {}
287
245
  }),
288
246
  styles: stylesFinding(root, components.value, source),
289
- primitives: primitivesFinding(components.value, source),
290
- icons: iconsFinding(root, components.value, source),
291
247
  provider: providerFinding(root),
292
248
  agents: agentsFinding(agentRoot),
293
249
  packageManager: await packageManagerFinding(agentRoot, options),
@@ -296,4 +252,4 @@ async function findProject(root, options = {}) {
296
252
  };
297
253
  }
298
254
  //#endregion
299
- export { AGENT_IDS, CREATE_COMMAND, USER_AGENT_RE, agentName, componentsAt, componentsChoice, connectInStudio, createCommandFor, findProject, iconPackagesToAdd, iconsFinding, packageManagerFinding, resolvedStudio, studioPackage };
255
+ export { AGENT_IDS, CREATE_COMMAND, USER_AGENT_RE, agentName, componentsAt, componentsChoice, connectInStudio, createCommandFor, findProject, packageManagerFinding, resolvedStudio, studioPackage };
@@ -1,5 +1,4 @@
1
1
  import { Reporter } from "../cli/ui.mjs";
2
- import { InterfaceIcons } from "../shared/icon-sets.mjs";
3
2
  import { DesignMdDecision } from "./design-md-setup.mjs";
4
3
  import { AgentId } from "./detect.mjs";
5
4
  import { ComponentsChoice, PackageManagerName, ProjectFindings } from "./project.mjs";
@@ -9,6 +8,8 @@ import { ComponentsDecision, Decided, SetupDecisions } from "./questions.mjs";
9
8
  export interface SetupFlags {
10
9
  /** The agents to connect: "claude,codex", or "none". */
11
10
  agent?: string;
11
+ /** shadcn's component library for `shadcn init`. Sets up shadcn. */
12
+ base?: string;
12
13
  /** The components' folder, or "none". */
13
14
  components?: string;
14
15
  /** How DESIGN.md starts: "draft", "none", a file to link or import, or a URL. */
@@ -17,14 +18,14 @@ export interface SetupFlags {
17
18
  dir?: string;
18
19
  /** Say what it would do, and do nothing. */
19
20
  dryRun?: boolean;
20
- /** The icon set the interface draws with: "lucide", "phosphor" or "hugeicons". */
21
- icons?: string;
22
21
  /** How prototypes import the components, when it cannot be derived. */
23
22
  import?: string;
24
23
  json?: boolean;
25
24
  /** The package manager, instead of the detected one. */
26
25
  pm?: string;
27
- /** Build the studio's interface from the components; false: never. */
26
+ /** shadcn's preset for `shadcn init`: a name or a code. Sets up shadcn. */
27
+ preset?: string;
28
+ /** Build the studio's interface from the components: off unless true. */
28
29
  primitives?: boolean;
29
30
  /** The module that wraps every prototype view, or "none". */
30
31
  provider?: string;
@@ -52,7 +53,6 @@ export declare const NO_STYLES = "--styles none";
52
53
  /** "4 components: Badge, Button, Card, Input". */
53
54
  export declare const describeComponents: (choice: ComponentsChoice) => string;
54
55
  export declare function showComponents(decision: ComponentsDecision): string;
55
- export declare function iconSet(flag: string): InterfaceIcons;
56
56
  /** The folder a draft names stylesheets from: the workspace, else the project. */
57
57
  export declare const repositoryRoot: (findings: ProjectFindings) => string;
58
58
  export declare function showDesignMd(decision: DesignMdDecision, root: string): string;
@@ -1,6 +1,5 @@
1
1
  import { isDirectory, isFile } from "../paths.mjs";
2
2
  import { STUDIO_FILES } from "../shared/studio-files.mjs";
3
- import { ICON_SET_NAMES, INTERFACE_ICONS } from "../shared/icon-sets.mjs";
4
3
  import { dependenciesOf, packageFolder } from "../config/project-files.mjs";
5
4
  import { isPath, providerModule } from "../config/design-system.mjs";
6
5
  import { found } from "./findings.mjs";
@@ -8,8 +7,8 @@ import { isInside } from "./detect/workspace.mjs";
8
7
  import { counted, designMdFinding, draftFor, folderComponents, fromProject, importDesignMd, isUrl, summaryLine } from "./design-md-setup.mjs";
9
8
  import { checkAgents } from "../server/agents.mjs";
10
9
  import { installedAgents } from "./detect.mjs";
11
- import { AGENT_IDS, agentName, componentsAt, iconsFinding } from "./project.mjs";
12
- import { IMPORT_FLAG, PROVIDER_FILE, QUESTION, QUESTIONS } from "./questions.mjs";
10
+ import { AGENT_IDS, agentName, componentsAt } from "./project.mjs";
11
+ import { IMPORT_FLAG, PROVIDER_FILE, QUESTION, QUESTIONS, shadcnInitFlags } from "./questions.mjs";
13
12
  import { createRequire } from "node:module";
14
13
  import { existsSync } from "node:fs";
15
14
  import { isAbsolute, resolve, sep } from "node:path";
@@ -164,9 +163,28 @@ const decidedComponents = (value, source, { warning, open } = {}) => ({
164
163
  ...warning ? { warning } : {},
165
164
  ...open ? { open } : {}
166
165
  });
166
+ /** The component libraries `shadcn init --base` takes. */
167
+ const SHADCN_BASES = [
168
+ "base",
169
+ "radix",
170
+ "aria"
171
+ ];
172
+ const PRESET_RE = /^[\w-]+$/;
173
+ /** `--preset` and `--base`, checked: what `shadcn init` is given. */
174
+ function shadcnInit({ preset, base }) {
175
+ if (base !== void 0 && !SHADCN_BASES.includes(base)) throw new Error(`Unknown --base "${base}". Choose ${SHADCN_BASES.join(", ")}.`);
176
+ if (preset !== void 0 && !PRESET_RE.test(preset)) throw new Error(`--preset takes a preset's name (nova) or its code from https://ui.shadcn.com/create (b2fA), not "${preset}".`);
177
+ return {
178
+ ...preset ? { preset } : {},
179
+ ...base ? { base } : {}
180
+ };
181
+ }
167
182
  /** The components, from a flag, a question or what was found. */
168
183
  async function decideComponents(findings, flags, ui, ask) {
169
- if (flags.shadcn) return decidedComponents({ kind: "shadcn" }, "--shadcn");
184
+ if (flags.shadcn || flags.preset || flags.base) return decidedComponents({
185
+ kind: "shadcn",
186
+ ...shadcnInit(flags)
187
+ }, flags.shadcn ? "--shadcn" : shadcnInitFlags(shadcnInit(flags)).join(" "));
170
188
  if (flags.components === "none") return decidedComponents({ kind: "none" }, "--components none");
171
189
  const { root } = findings;
172
190
  if (flags.components) {
@@ -360,9 +378,8 @@ async function decideStyles(findings, components, flags, ui, ask) {
360
378
  } : {}
361
379
  };
362
380
  }
363
- async function decidePrimitives(findings, components, flags, ui, ask) {
381
+ function decidePrimitives(components, flags) {
364
382
  const choice = components.kind === "folder" ? components.choice : void 0;
365
- const fits = Boolean(choice?.baseUi && choice.import);
366
383
  const decided = (value, source, warning) => ({
367
384
  key: "primitives",
368
385
  value,
@@ -371,56 +388,9 @@ async function decidePrimitives(findings, components, flags, ui, ask) {
371
388
  shown: value ? `yes, from ${choice?.import}` : "no, the studio's own",
372
389
  ...warning ? { warning } : {}
373
390
  });
374
- if (flags.primitives === false) return decided(false, "--no-primitives");
375
- if (flags.primitives === true) {
376
- if (!choice?.import) return decided(false, "--primitives", "--primitives needs components with an import path, so the studio keeps its own");
377
- return decided(true, "--primitives");
378
- }
379
- if (!fits) return decided(false, findings.primitives.evidence);
380
- if (!ask) return decided(true, `${findings.primitives.evidence}, so they fit`);
381
- return decided(answered(await ui.confirm([
382
- `Build the studio's own buttons, menus and dialogs from ${choice?.import}?`,
383
- " Your components use shadcn's Base UI API, so they fit.",
384
- ` (${QUESTION.primitives.flag})`
385
- ].join("\n"))), ANSWERED);
386
- }
387
- function iconSet(flag) {
388
- const set = INTERFACE_ICONS.find((each) => each === flag.trim());
389
- if (!set) throw new Error(`Unknown icon set "${flag}". Choose ${INTERFACE_ICONS.join(", ")}.`);
390
- return set;
391
- }
392
- /** Components chosen instead of those found bring their own. */
393
- async function decideIcons(findings, components, flags, ui, ask) {
394
- const decided = (value, source) => ({
395
- key: "icons",
396
- value,
397
- source,
398
- flag: QUESTION.icons.flag,
399
- shown: ICON_SET_NAMES[value]
400
- });
401
- if (flags.icons !== void 0) return decided(iconSet(flags.icons), "--icons");
402
- const choice = components.kind === "folder" ? components.choice : void 0;
403
- const finding = choice && choice.dir !== findings.components.value?.dir ? iconsFinding(findings.root, choice, "its components.json") : findings.icons;
404
- if (!ask) {
405
- const others = finding.alternatives.map((set) => ICON_SET_NAMES[set]);
406
- return finding.confidence === "guess" ? {
407
- ...decided(finding.value, finding.evidence),
408
- warning: `${ICON_SET_NAMES[finding.value]}, though ${others.join(" and ")} ${others.length === 1 ? "is" : "are"} installed too: check it, or choose with --icons`,
409
- open: {
410
- candidates: [finding.value, ...finding.alternatives].map((set) => ({ value: set })),
411
- safe: true
412
- }
413
- } : decided(finding.value, finding.evidence);
414
- }
415
- const answer = answered(await ui.choose([
416
- "Icon set: what Dex's interface draws its icons with",
417
- ` ${ICON_SET_NAMES[finding.value]} (${finding.evidence})`,
418
- ` (${QUESTION.icons.flag})`
419
- ].join("\n"), [finding.value, ...INTERFACE_ICONS.filter((set) => set !== finding.value)].map((set) => ({
420
- value: set,
421
- label: ICON_SET_NAMES[set]
422
- }))));
423
- return decided(answer, answer === finding.value ? finding.evidence : ANSWERED);
391
+ if (flags.primitives !== true) return decided(false, "Dex's own, unless --primitives");
392
+ if (!choice?.import) return decided(false, "--primitives", "--primitives needs components with an import path, so the studio keeps its own");
393
+ return decided(true, "--primitives");
424
394
  }
425
395
  const providerShown = (decision) => {
426
396
  if (decision.kind === "write") return `${PROVIDER_FILE}, ${decision.need.component} (written)`;
@@ -753,11 +723,9 @@ async function decide(findings, flags, ui, { ask }) {
753
723
  const dir = decideDir(flags);
754
724
  const packageManager = decidePackageManager(findings, flags);
755
725
  if (flags.agent !== void 0) parseAgents(flags.agent);
756
- if (flags.icons !== void 0) iconSet(flags.icons);
757
726
  const components = await decideComponents(findings, flags, ui, ask);
758
727
  const styles = await decideStyles(findings, components.value, flags, ui, ask);
759
- const primitives = await decidePrimitives(findings, components.value, flags, ui, ask);
760
- const icons = await decideIcons(findings, components.value, flags, ui, ask);
728
+ const primitives = decidePrimitives(components.value, flags);
761
729
  const designMd = await decideDesignMd(findings, {
762
730
  components: components.value,
763
731
  dir: dir.value,
@@ -771,7 +739,6 @@ async function decide(findings, flags, ui, { ask }) {
771
739
  components,
772
740
  styles,
773
741
  primitives,
774
- icons,
775
742
  ...provider ? { provider } : {},
776
743
  designMd,
777
744
  agents
@@ -783,4 +750,4 @@ const decisionList = (decisions) => QUESTIONS.flatMap((question) => {
783
750
  return decided ? [decided] : [];
784
751
  });
785
752
  //#endregion
786
- export { Cancelled, NO_STYLES, NeedsChoice, decide, decisionList, describeComponents, iconSet, packageManagerName, parseAgents, repositoryRoot, showComponents, showDesignMd, studioDir };
753
+ export { Cancelled, NO_STYLES, NeedsChoice, decide, decisionList, describeComponents, packageManagerName, parseAgents, repositoryRoot, showComponents, showDesignMd, studioDir };
@@ -1,19 +1,28 @@
1
- import { InterfaceIcons } from "../shared/icon-sets.mjs";
2
1
  import { DesignMdDecision } from "./design-md-setup.mjs";
3
2
  import { AgentId } from "./detect.mjs";
4
3
  import { Placement } from "./detect/workspace.mjs";
5
4
  import { ProviderNeed } from "./provider.mjs";
6
5
  import { ComponentsChoice, PackageManagerChoice } from "./project.mjs";
7
6
  //#region src/setup/questions.d.ts
7
+ /**
8
+ * How `shadcn init` sets the project up, as its own flags say it: a preset
9
+ * (a name, or a code from ui.shadcn.com/create) and the component library.
10
+ */
11
+ export interface ShadcnInit {
12
+ base?: string;
13
+ preset?: string;
14
+ }
8
15
  /** What to build prototypes with. */
9
16
  export type ComponentsDecision = {
10
17
  kind: "folder";
11
18
  choice: ComponentsChoice;
12
- } | {
19
+ } | ({
13
20
  kind: "shadcn";
14
- } | {
21
+ } & ShadcnInit) | {
15
22
  kind: "none";
16
23
  };
24
+ /** `--preset` and `--base` as setup passes them on to `shadcn init`. */
25
+ export declare const shadcnInitFlags: ({ preset, base }: ShadcnInit) => string[];
17
26
  /**
18
27
  * What wraps every prototype view (`designSystem.provider`): a module of the
19
28
  * project's (a path from where setup looked, or a package's module), the
@@ -63,7 +72,6 @@ export interface SetupDecisions {
63
72
  components: Decided<ComponentsDecision>;
64
73
  designMd: Decided<DesignMdDecision>;
65
74
  dir: Decided<string>;
66
- icons: Decided<InterfaceIcons>;
67
75
  packageManager: Decided<PackageManagerChoice>;
68
76
  primitives: Decided<boolean>;
69
77
  /**