@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
@@ -14,11 +14,6 @@ import { isPath, providerModule } from "../config/design-system.ts";
14
14
  import { dependenciesOf, packageFolder } from "../config/project-files.ts";
15
15
  import { isDirectory, isFile } from "../paths.ts";
16
16
  import { checkAgents } from "../server/agents.ts";
17
- import {
18
- ICON_SET_NAMES,
19
- INTERFACE_ICONS,
20
- type InterfaceIcons,
21
- } from "../shared/icon-sets.ts";
22
17
  import { STUDIO_FILES } from "../shared/studio-files.ts";
23
18
  import type { FoundDesignMd } from "./design-md.ts";
24
19
  import {
@@ -42,7 +37,6 @@ import {
42
37
  type ComponentsChoice,
43
38
  type ComponentsFinding,
44
39
  componentsAt,
45
- iconsFinding,
46
40
  type PackageManagerChoice,
47
41
  type PackageManagerName,
48
42
  type ProjectFindings,
@@ -59,12 +53,16 @@ import {
59
53
  QUESTION,
60
54
  QUESTIONS,
61
55
  type SetupDecisions,
56
+ type ShadcnInit,
57
+ shadcnInitFlags,
62
58
  } from "./questions.ts";
63
59
 
64
60
  /** Every flag of `dex create` that answers a question or sets a fact. */
65
61
  export interface SetupFlags {
66
62
  /** The agents to connect: "claude,codex", or "none". */
67
63
  agent?: string;
64
+ /** shadcn's component library for `shadcn init`. Sets up shadcn. */
65
+ base?: string;
68
66
  /** The components' folder, or "none". */
69
67
  components?: string;
70
68
  /** How DESIGN.md starts: "draft", "none", a file to link or import, or a URL. */
@@ -73,14 +71,14 @@ export interface SetupFlags {
73
71
  dir?: string;
74
72
  /** Say what it would do, and do nothing. */
75
73
  dryRun?: boolean;
76
- /** The icon set the interface draws with: "lucide", "phosphor" or "hugeicons". */
77
- icons?: string;
78
74
  /** How prototypes import the components, when it cannot be derived. */
79
75
  import?: string;
80
76
  json?: boolean;
81
77
  /** The package manager, instead of the detected one. */
82
78
  pm?: string;
83
- /** Build the studio's interface from the components; false: never. */
79
+ /** shadcn's preset for `shadcn init`: a name or a code. Sets up shadcn. */
80
+ preset?: string;
81
+ /** Build the studio's interface from the components: off unless true. */
84
82
  primitives?: boolean;
85
83
  /** The module that wraps every prototype view, or "none". */
86
84
  provider?: string;
@@ -315,6 +313,25 @@ const decidedComponents = (
315
313
  ...(open ? { open } : {}),
316
314
  });
317
315
 
316
+ /** The component libraries `shadcn init --base` takes. */
317
+ const SHADCN_BASES = ["base", "radix", "aria"];
318
+ const PRESET_RE = /^[\w-]+$/;
319
+
320
+ /** `--preset` and `--base`, checked: what `shadcn init` is given. */
321
+ function shadcnInit({ preset, base }: SetupFlags): ShadcnInit {
322
+ if (base !== undefined && !SHADCN_BASES.includes(base)) {
323
+ throw new Error(
324
+ `Unknown --base "${base}". Choose ${SHADCN_BASES.join(", ")}.`
325
+ );
326
+ }
327
+ if (preset !== undefined && !PRESET_RE.test(preset)) {
328
+ throw new Error(
329
+ `--preset takes a preset's name (nova) or its code from https://ui.shadcn.com/create (b2fA), not "${preset}".`
330
+ );
331
+ }
332
+ return { ...(preset ? { preset } : {}), ...(base ? { base } : {}) };
333
+ }
334
+
318
335
  /** The components, from a flag, a question or what was found. */
319
336
  async function decideComponents(
320
337
  findings: ProjectFindings,
@@ -322,8 +339,11 @@ async function decideComponents(
322
339
  ui: Reporter,
323
340
  ask: boolean
324
341
  ): Promise<Decided<ComponentsDecision>> {
325
- if (flags.shadcn) {
326
- return decidedComponents({ kind: "shadcn" }, "--shadcn");
342
+ if (flags.shadcn || flags.preset || flags.base) {
343
+ return decidedComponents(
344
+ { kind: "shadcn", ...shadcnInit(flags) },
345
+ flags.shadcn ? "--shadcn" : shadcnInitFlags(shadcnInit(flags)).join(" ")
346
+ );
327
347
  }
328
348
  if (flags.components === "none") {
329
349
  return decidedComponents({ kind: "none" }, "--components none");
@@ -575,15 +595,11 @@ async function decideStyles(
575
595
 
576
596
  // --- Primitives ---------------------------------------------------------------
577
597
 
578
- async function decidePrimitives(
579
- findings: ProjectFindings,
598
+ function decidePrimitives(
580
599
  components: ComponentsDecision,
581
- flags: SetupFlags,
582
- ui: Reporter,
583
- ask: boolean
584
- ): Promise<Decided<boolean>> {
600
+ flags: SetupFlags
601
+ ): Decided<boolean> {
585
602
  const choice = components.kind === "folder" ? components.choice : undefined;
586
- const fits = Boolean(choice?.baseUi && choice.import);
587
603
  const decided = (value: boolean, source: string, warning?: string) => ({
588
604
  key: "primitives",
589
605
  value,
@@ -592,105 +608,17 @@ async function decidePrimitives(
592
608
  shown: value ? `yes, from ${choice?.import}` : "no, the studio's own",
593
609
  ...(warning ? { warning } : {}),
594
610
  });
595
- if (flags.primitives === false) {
596
- return decided(false, "--no-primitives");
611
+ if (flags.primitives !== true) {
612
+ return decided(false, "Dex's own, unless --primitives");
597
613
  }
598
- if (flags.primitives === true) {
599
- if (!choice?.import) {
600
- return decided(
601
- false,
602
- "--primitives",
603
- "--primitives needs components with an import path, so the studio keeps its own"
604
- );
605
- }
606
- return decided(true, "--primitives");
607
- }
608
- if (!fits) {
609
- return decided(false, findings.primitives.evidence);
610
- }
611
- if (!ask) {
612
- return decided(true, `${findings.primitives.evidence}, so they fit`);
613
- }
614
- const yes = answered(
615
- await ui.confirm(
616
- [
617
- `Build the studio's own buttons, menus and dialogs from ${choice?.import}?`,
618
- " Your components use shadcn's Base UI API, so they fit.",
619
- ` (${QUESTION.primitives.flag})`,
620
- ].join("\n")
621
- )
622
- );
623
- return decided(yes, ANSWERED);
624
- }
625
-
626
- // --- Icon set -------------------------------------------------------------------
627
-
628
- export function iconSet(flag: string): InterfaceIcons {
629
- const set = INTERFACE_ICONS.find((each) => each === flag.trim());
630
- if (!set) {
631
- throw new Error(
632
- `Unknown icon set "${flag}". Choose ${INTERFACE_ICONS.join(", ")}.`
614
+ if (!choice?.import) {
615
+ return decided(
616
+ false,
617
+ "--primitives",
618
+ "--primitives needs components with an import path, so the studio keeps its own"
633
619
  );
634
620
  }
635
- return set;
636
- }
637
-
638
- /** Components chosen instead of those found bring their own. */
639
- async function decideIcons(
640
- findings: ProjectFindings,
641
- components: ComponentsDecision,
642
- flags: SetupFlags,
643
- ui: Reporter,
644
- ask: boolean
645
- ): Promise<Decided<InterfaceIcons>> {
646
- const decided = (value: InterfaceIcons, source: string) => ({
647
- key: "icons",
648
- value,
649
- source,
650
- flag: QUESTION.icons.flag,
651
- shown: ICON_SET_NAMES[value],
652
- });
653
- if (flags.icons !== undefined) {
654
- return decided(iconSet(flags.icons), "--icons");
655
- }
656
- const choice = components.kind === "folder" ? components.choice : undefined;
657
- const finding =
658
- choice && choice.dir !== findings.components.value?.dir
659
- ? iconsFinding(findings.root, choice, "its components.json")
660
- : findings.icons;
661
- if (!ask) {
662
- // More than one set installed: the one taken is a guess.
663
- const others = finding.alternatives.map((set) => ICON_SET_NAMES[set]);
664
- return finding.confidence === "guess"
665
- ? {
666
- ...decided(finding.value, finding.evidence),
667
- warning: `${ICON_SET_NAMES[finding.value]}, though ${others.join(" and ")} ${others.length === 1 ? "is" : "are"} installed too: check it, or choose with --icons`,
668
- open: {
669
- candidates: [finding.value, ...finding.alternatives].map((set) => ({
670
- value: set,
671
- })),
672
- safe: true,
673
- },
674
- }
675
- : decided(finding.value, finding.evidence);
676
- }
677
- const answer = answered(
678
- await ui.choose<InterfaceIcons>(
679
- [
680
- "Icon set: what Dex's interface draws its icons with",
681
- ` ${ICON_SET_NAMES[finding.value]} (${finding.evidence})`,
682
- ` (${QUESTION.icons.flag})`,
683
- ].join("\n"),
684
- [
685
- finding.value,
686
- ...INTERFACE_ICONS.filter((set) => set !== finding.value),
687
- ].map((set) => ({ value: set, label: ICON_SET_NAMES[set] }))
688
- )
689
- );
690
- return decided(
691
- answer,
692
- answer === finding.value ? finding.evidence : ANSWERED
693
- );
621
+ return decided(true, "--primitives");
694
622
  }
695
623
 
696
624
  // --- Provider -------------------------------------------------------------------
@@ -1225,23 +1153,13 @@ export async function decide(
1225
1153
  ): Promise<SetupDecisions> {
1226
1154
  const dir = decideDir(flags);
1227
1155
  const packageManager = decidePackageManager(findings, flags);
1228
- // Unknown agents and icon sets stop setup before any question.
1156
+ // Unknown agents stop setup before any question.
1229
1157
  if (flags.agent !== undefined) {
1230
1158
  parseAgents(flags.agent);
1231
1159
  }
1232
- if (flags.icons !== undefined) {
1233
- iconSet(flags.icons);
1234
- }
1235
1160
  const components = await decideComponents(findings, flags, ui, ask);
1236
1161
  const styles = await decideStyles(findings, components.value, flags, ui, ask);
1237
- const primitives = await decidePrimitives(
1238
- findings,
1239
- components.value,
1240
- flags,
1241
- ui,
1242
- ask
1243
- );
1244
- const icons = await decideIcons(findings, components.value, flags, ui, ask);
1162
+ const primitives = decidePrimitives(components.value, flags);
1245
1163
  const designMd = await decideDesignMd(
1246
1164
  findings,
1247
1165
  { components: components.value, dir: dir.value, styles: styles.value },
@@ -1257,7 +1175,6 @@ export async function decide(
1257
1175
  components,
1258
1176
  styles,
1259
1177
  primitives,
1260
- icons,
1261
1178
  ...(provider ? { provider } : {}),
1262
1179
  designMd,
1263
1180
  agents,
@@ -5,19 +5,33 @@
5
5
 
6
6
  import { relative } from "node:path";
7
7
  import { posix } from "../paths.ts";
8
- import { ICON_SET_NAMES, type InterfaceIcons } from "../shared/icon-sets.ts";
9
8
  import { type DesignMdDecision, fromProject } from "./design-md-setup.ts";
10
9
  import type { Placement } from "./detect/workspace.ts";
11
10
  import type { AgentId } from "./detect.ts";
12
11
  import type { ComponentsChoice, PackageManagerChoice } from "./project.ts";
13
12
  import type { ProviderNeed } from "./provider.ts";
14
13
 
14
+ /**
15
+ * How `shadcn init` sets the project up, as its own flags say it: a preset
16
+ * (a name, or a code from ui.shadcn.com/create) and the component library.
17
+ */
18
+ export interface ShadcnInit {
19
+ base?: string;
20
+ preset?: string;
21
+ }
22
+
15
23
  /** What to build prototypes with. */
16
24
  export type ComponentsDecision =
17
25
  | { kind: "folder"; choice: ComponentsChoice }
18
- | { kind: "shadcn" }
26
+ | ({ kind: "shadcn" } & ShadcnInit)
19
27
  | { kind: "none" };
20
28
 
29
+ /** `--preset` and `--base` as setup passes them on to `shadcn init`. */
30
+ export const shadcnInitFlags = ({ preset, base }: ShadcnInit): string[] => [
31
+ ...(preset ? ["--preset", preset] : []),
32
+ ...(base ? ["--base", base] : []),
33
+ ];
34
+
21
35
  /**
22
36
  * What wraps every prototype view (`designSystem.provider`): a module of the
23
37
  * project's (a path from where setup looked, or a package's module), the
@@ -66,7 +80,6 @@ export interface SetupDecisions {
66
80
  components: Decided<ComponentsDecision>;
67
81
  designMd: Decided<DesignMdDecision>;
68
82
  dir: Decided<string>;
69
- icons: Decided<InterfaceIcons>;
70
83
  packageManager: Decided<PackageManagerChoice>;
71
84
  primitives: Decided<boolean>;
72
85
  /**
@@ -227,7 +240,11 @@ export const QUESTION: {
227
240
  : decision.kind,
228
241
  asFlags: (decision, { cwd }) => {
229
242
  if (decision.kind === "shadcn") {
230
- return ["--shadcn"];
243
+ return [
244
+ "--shadcn",
245
+ ...(decision.preset ? [`--preset ${decision.preset}`] : []),
246
+ ...(decision.base ? [`--base ${decision.base}`] : []),
247
+ ];
231
248
  }
232
249
  if (decision.kind === "none") {
233
250
  return ["--components none"];
@@ -259,31 +276,13 @@ export const QUESTION: {
259
276
  primitives: {
260
277
  key: "primitives",
261
278
  label: "Primitives",
262
- flag: "--primitives | --no-primitives",
279
+ flag: "--primitives",
263
280
  asJson: (primitives) => primitives,
264
- // --primitives is honoured for any components with an import path, Base UI
265
- // or not; --no-primitives only differs from the default on Base UI.
266
- asFlags: (primitives, { components }) => {
267
- if (components.kind !== "folder") {
268
- return [];
269
- }
270
- const { baseUi, import: specifier } = components.choice;
271
- if (primitives) {
272
- return specifier ? ["--primitives"] : [];
273
- }
274
- return baseUi ? ["--no-primitives"] : [];
275
- },
276
- },
277
- icons: {
278
- key: "icons",
279
- label: "Icon set",
280
- flag: "--icons lucide|phosphor|hugeicons",
281
- asked: {
282
- question: "Which icon set should Dex's interface draw with?",
283
- choice: (icons) => ({ value: icons, label: ICON_SET_NAMES[icons] }),
284
- },
285
- asJson: (icons) => icons,
286
- asFlags: (icons) => [`--icons ${icons}`],
281
+ // Off unless asked for: --primitives, for components with an import path.
282
+ asFlags: (primitives, { components }) =>
283
+ primitives && components.kind === "folder" && components.choice.import
284
+ ? ["--primitives"]
285
+ : [],
287
286
  },
288
287
  provider: {
289
288
  key: "provider",
@@ -353,7 +352,6 @@ export const QUESTIONS: readonly AnyQuestion[] = [
353
352
  QUESTION.components,
354
353
  QUESTION.styles,
355
354
  QUESTION.primitives,
356
- QUESTION.icons,
357
355
  QUESTION.provider,
358
356
  QUESTION.designMd,
359
357
  QUESTION.agents,
@@ -10,6 +10,7 @@ import { TEMPLATES_DIR } from "../paths.ts";
10
10
  import type { Exec } from "./apply.ts";
11
11
  import { type PackageManagerName, USER_AGENT_RE } from "./project.ts";
12
12
  import { packageManagerName } from "./prompts.ts";
13
+ import { withEsbuildBuilds } from "./write.ts";
13
14
 
14
15
  export const STARTERS_DIR = join(TEMPLATES_DIR, "starters");
15
16
 
@@ -68,7 +69,7 @@ export const STARTERS: Record<StarterName, Starter> = {
68
69
  workspace: false,
69
70
  shared: [],
70
71
  next: [
71
- { script: "studio", what: "the studio, with a first file" },
72
+ { script: "dex", what: "Dex, with a first file" },
72
73
  { script: "dev", what: "your app" },
73
74
  ],
74
75
  },
@@ -80,7 +81,7 @@ export const STARTERS: Record<StarterName, Starter> = {
80
81
  packageManager: "npm",
81
82
  workspace: false,
82
83
  shared: [COMPONENTS, LIB, STYLES],
83
- next: [{ script: "studio", what: "the studio, with a first file" }],
84
+ next: [{ script: "dex", what: "Dex, with a first file" }],
84
85
  },
85
86
  turborepo: {
86
87
  name: "turborepo",
@@ -102,8 +103,8 @@ export const STARTERS: Record<StarterName, Starter> = {
102
103
  { from: "vite/src/index.css", to: "packages/ui/src/styles/globals.css" },
103
104
  ],
104
105
  next: [
105
- { script: "studio", what: "the studio, with a first file" },
106
- { script: "dev", what: "every app: apps/web and the studio" },
106
+ { script: "dex", what: "Dex, with a first file" },
107
+ { script: "dev", what: "every app: apps/web and Dex" },
107
108
  ],
108
109
  },
109
110
  };
@@ -229,14 +230,29 @@ async function fitPackageManager(
229
230
  manifest.workspaces = undefined;
230
231
  }
231
232
  await writeFile(file, `${JSON.stringify(manifest, null, 2)}\n`);
232
- if (values.pm === "pnpm" && Array.isArray(workspaces)) {
233
- await writeFile(
234
- join(root, "pnpm-workspace.yaml"),
235
- `packages:\n${workspaces.map((glob) => ` - "${glob}"`).join("\n")}\n`
236
- );
233
+ if (values.pm === "pnpm") {
234
+ await writePnpmWorkspace(root, workspaces);
237
235
  }
238
236
  }
239
237
 
238
+ /**
239
+ * pnpm's settings file: the workspaces, in a workspace, and what to do with
240
+ * esbuild's install script. Vite brings esbuild, and pnpm 11 stops the
241
+ * install on a script nobody decided on (write.ts, withEsbuildBuilds).
242
+ */
243
+ async function writePnpmWorkspace(
244
+ root: string,
245
+ workspaces: unknown
246
+ ): Promise<void> {
247
+ const packages = Array.isArray(workspaces)
248
+ ? `packages:\n${workspaces.map((glob) => ` - "${glob}"`).join("\n")}\n`
249
+ : "";
250
+ await writeFile(
251
+ join(root, "pnpm-workspace.yaml"),
252
+ withEsbuildBuilds(packages) ?? packages
253
+ );
254
+ }
255
+
240
256
  /**
241
257
  * Copy `starter` into `root`, which is empty: its own files, then the files
242
258
  * it shares with another, with the name, title and package manager filled in.
@@ -268,5 +284,7 @@ export async function copyStarter(
268
284
  }
269
285
  if (starter.workspace) {
270
286
  await fitPackageManager(root, values);
287
+ } else if (values.pm === "pnpm") {
288
+ await writePnpmWorkspace(root, undefined);
271
289
  }
272
290
  }
@@ -7,7 +7,6 @@
7
7
 
8
8
  import { existsSync, readFileSync } from "node:fs";
9
9
  import { dirname, isAbsolute, join, relative, resolve } from "node:path";
10
- import { pmCommand } from "../config/package-manager.ts";
11
10
  import { PACKAGE_NAME, posix, studioVersion } from "../paths.ts";
12
11
  import { designMdFinding } from "./design-md-setup.ts";
13
12
  import {
@@ -22,8 +21,12 @@ import {
22
21
  ownAppFacts,
23
22
  rootStudioScript,
24
23
  } from "./own-app.ts";
25
- import type { StudioTarget, WorkspaceSetup } from "./plan.ts";
26
- import { findProject, iconsFinding, type ProjectFindings } from "./project.ts";
24
+ import {
25
+ installCommand,
26
+ type StudioTarget,
27
+ type WorkspaceSetup,
28
+ } from "./plan.ts";
29
+ import { findProject, type ProjectFindings } from "./project.ts";
27
30
  import type { SetupFlags } from "./prompts.ts";
28
31
  import type { SetupDecisions } from "./questions.ts";
29
32
 
@@ -124,14 +127,6 @@ export async function findingsFor(
124
127
  evidence: `${library.folder} is a shared package`,
125
128
  alternatives: candidates.filter((choice) => choice !== shared),
126
129
  },
127
- icons:
128
- shared === value
129
- ? findings.icons
130
- : iconsFinding(
131
- findings.root,
132
- shared,
133
- `${library.folder}'s components.json`
134
- ),
135
130
  designSystem: { ...findings.designSystem, name: library.name },
136
131
  };
137
132
  }
@@ -207,11 +202,7 @@ export function workspaceSetup(
207
202
  placement: Placement,
208
203
  findings: ProjectFindings,
209
204
  decisions: SetupDecisions,
210
- {
211
- flags,
212
- cwd,
213
- iconPackages,
214
- }: { flags: SetupFlags; cwd: string; iconPackages: Record<string, string> }
205
+ { flags, cwd }: { flags: SetupFlags; cwd: string }
215
206
  ): WorkspaceSetup {
216
207
  const manager = decisions.packageManager.value;
217
208
  const studioSpec = studioSpecFor(findings, placement, flags, {
@@ -224,13 +215,12 @@ export function workspaceSetup(
224
215
  ? ownAppFacts(workspace, placement, {
225
216
  componentsDir:
226
217
  components.kind === "folder" ? components.choice.dir : undefined,
227
- iconPackages,
228
218
  studioSpec: studioSpec ?? versionSpec(),
229
219
  })
230
220
  : undefined;
231
221
  return {
232
222
  app,
233
- install: pmCommand(manager.agent, "install", []),
223
+ install: installCommand(manager.agent),
234
224
  rootScripts: recordAt(readManifest(workspace.root), "scripts"),
235
225
  studioScript: rootStudioScript(workspace, manager, placement),
236
226
  studioSpec,
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { isAbsolute, relative, resolve } from "node:path";
5
5
  import { componentName } from "../config/design-system.ts";
6
- import type { DesignSystemConfig, StudioInterface } from "../config/index.ts";
6
+ import type { DesignSystemConfig } from "../config/index.ts";
7
7
  import { PACKAGE_NAME, posix } from "../paths.ts";
8
8
  import { stateIgnoreLine } from "../server/state.ts";
9
9
  import type { StylingApproach } from "../shared/design-system.ts";
@@ -101,20 +101,17 @@ export function designSystemConfig(
101
101
  /**
102
102
  * dex.config.ts for a new studio: the choices made, and nothing the
103
103
  * project's files or the defaults say. `studio` is "studio", or "." for an
104
- * app of its own. The icon set is always written, Lucide too: it is a
105
- * choice the team made, and what the install brought in.
104
+ * app of its own.
106
105
  */
107
106
  export function configSource(
108
107
  designSystem: DesignSystemConfig | undefined,
109
108
  {
110
109
  studio,
111
110
  primitives,
112
- icons,
113
111
  next,
114
112
  }: {
115
113
  studio: string;
116
114
  primitives: boolean;
117
- icons: NonNullable<StudioInterface["icons"]>;
118
115
  next?: boolean;
119
116
  }
120
117
  ): string {
@@ -137,9 +134,9 @@ export default defineConfig({${content}});
137
134
  designSystem: designSystem as unknown as ConfigValue | undefined,
138
135
  plugins: next ? [{ code: "next()" }] : undefined,
139
136
  },
140
- // With primitives, the studio's interface uses the project's own
141
- // buttons, menus and dialogs rather than carrying second copies.
142
- ui: { icons, ...(primitives ? { primitives: true } : {}) },
137
+ // With primitives (--primitives), the studio's interface uses the
138
+ // project's own buttons, menus and dialogs rather than its own.
139
+ ...(primitives ? { ui: { primitives: true } } : {}),
143
140
  });
144
141
  }
145
142
 
@@ -252,11 +249,12 @@ export const fromStudio = (content: string, file: string): string => {
252
249
  * the project's own file changes by a dependency and a line.
253
250
  */
254
251
  export const STUDIO_SCRIPTS: Record<string, string> = {
255
- studio: "dex dev",
252
+ dex: "dex dev",
256
253
  };
257
254
 
258
255
  /** A later setup leaves these, as anything of the project's own: as Dex wrote them, or Sudio. */
259
256
  export const OLD_SCRIPTS: Record<string, string[]> = {
257
+ studio: ["dex dev", "sudio dev"],
260
258
  "studio:build": ["dex build", "sudio build"],
261
259
  "studio:claude": ["dex claude", "sudio claude"],
262
260
  };
@@ -309,6 +307,51 @@ export const withIgnoreLines = (
309
307
  ? gitignore
310
308
  : `${gitignore.trimEnd() ? `${gitignore.trimEnd()}\n\n` : ""}# Dex\n${missing.join("\n")}\n`;
311
309
 
310
+ // --- pnpm's build scripts -----------------------------------------------------
311
+ //
312
+ // The studio's Vite brings esbuild, whose install script pnpm runs only when
313
+ // the project allows it. pnpm 11 stops the install on a script nobody
314
+ // decided on (ERR_PNPM_IGNORED_BUILDS), and then every later install too;
315
+ // pnpm 10 warned. esbuild runs without its script (it only checks the
316
+ // binary its platform package brings), so setup says so for the project:
317
+ // `allowBuilds: { esbuild: false }`, which pnpm 10 reads as well.
318
+
319
+ const ESBUILD_DECIDED_RE = /^\s*-?\s*["']?esbuild["']?\s*(:|$)/m;
320
+ const ALL_BUILDS_RE =
321
+ /^(dangerouslyAllowAllBuilds:\s*true|strictDepBuilds:\s*false)\s*$/m;
322
+ const ALLOW_BUILDS_RE = /^allowBuilds:[ \t]*\n((?:[ \t]+.*\n?)*)/m;
323
+ const ALLOW_BUILDS_KEY_RE = /^allowBuilds:/m;
324
+ const INDENT_RE = /^([ \t]+)\S/;
325
+
326
+ /**
327
+ * Whether pnpm-workspace.yaml settles esbuild's install script already:
328
+ * names it in any list or map (allowBuilds, onlyBuiltDependencies...), or
329
+ * allows every script.
330
+ */
331
+ export const pnpmDecidesEsbuild = (yaml: string): boolean =>
332
+ ESBUILD_DECIDED_RE.test(yaml) || ALL_BUILDS_RE.test(yaml);
333
+
334
+ /**
335
+ * pnpm-workspace.yaml with `esbuild: false` under `allowBuilds`, keeping
336
+ * everything else; undefined when its `allowBuilds` is written some way
337
+ * this can't add to (`allowBuilds: {}`).
338
+ */
339
+ export function withEsbuildBuilds(yaml: string): string | undefined {
340
+ const block = ALLOW_BUILDS_RE.exec(yaml);
341
+ if (block) {
342
+ const indent = INDENT_RE.exec(block[1] ?? "")?.[1] ?? " ";
343
+ const end = block.index + block[0].length;
344
+ const before = yaml.slice(0, end);
345
+ const line = `${indent}esbuild: false\n`;
346
+ return `${before}${before.endsWith("\n") ? "" : "\n"}${line}${yaml.slice(end)}`;
347
+ }
348
+ if (ALLOW_BUILDS_KEY_RE.test(yaml)) {
349
+ return;
350
+ }
351
+ const kept = yaml.trimEnd();
352
+ return `${kept ? `${kept}\n` : ""}allowBuilds:\n esbuild: false\n`;
353
+ }
354
+
312
355
  /**
313
356
  * The pointer setup adds to the root's AGENTS.md or CLAUDE.md, so an agent
314
357
  * started at the root reads the studio's brief before studio work.
@@ -340,6 +340,14 @@ setInterval(() => {
340
340
  }, CONFIG.inApp ? 500 : 2000);
341
341
  `;
342
342
 
343
+ /**
344
+ * The tab's icon, inlined, as this page shows while the server that serves
345
+ * app/public/dex-icon.svg is down. Drawn by scripts/studio-icons.mjs.
346
+ */
347
+ const ICON = `data:image/svg+xml,${encodeURIComponent(
348
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="24" height="24" rx="5.5" fill="#155dfc"/><path transform="translate(6.206 4.750) scale(0.3625)" fill="#ffffff" d="M0,10.13333l0,-10.13333h14.5c7.45773,0 13.96208,4.08187 17.4008,10.13333zM34.5,20c0,1.75052 -0.2249,3.44852 -0.64737,5.06667l-33.85263,0l0,-10.13333l33.85263,0c0.42247,1.61815 0.64737,3.31614 0.64737,5.06667zM31.9008,29.86667c-3.43872,6.05147 -9.94307,10.13333 -17.4008,10.13333h-14.5l0,-10.13333z"/></svg>'
349
+ )}`;
350
+
343
351
  /** The whole page, saying `options.state` first. */
344
352
  export const serverPage = (options: ServerPageOptions): string => {
345
353
  const name = escapeHtml(options.name);
@@ -354,6 +362,7 @@ export const serverPage = (options: ServerPageOptions): string => {
354
362
  <meta name="viewport" content="width=device-width, initial-scale=1">
355
363
  <meta name="color-scheme" content="light dark">
356
364
  <title>${name}</title>
365
+ <link rel="icon" href="${ICON}" type="image/svg+xml">
357
366
  <style>${STYLE}</style>
358
367
  </head>
359
368
  <body>
@@ -26,7 +26,7 @@ design changes; you never apply one they have not approved.
26
26
  (section, row, step) where it belongs.
27
27
  - **Wireframes.** People draw boxes for a new view, or over a frame to change
28
28
  it. The thread has a `wireframe` describing each box; build it from the
29
- design system (see `rules/canvas.md`).
29
+ design system (see `rules/canvas-frames.md`).
30
30
  - **A section's spec.** A thread on a section, or on a frame in a section, that has a
31
31
  spec names it, as `flowSpec` (the spec's path; `moreFlowSpecs` names any
32
32
  other specs the section has). Read it before you answer, and follow it: it
@@ -130,7 +130,7 @@ review:
130
130
  the thread (`ask: true`).
131
131
  4. For a request for a new view: build the view in the file's `views/`,
132
132
  then put its frame in the requested cell with `place_frame` and the
133
- thread's id (by hand, see `rules/canvas.md`). A wireframe works the same
133
+ thread's id (by hand, see `rules/canvas-frames.md`). A wireframe works the same
134
134
  way: build what its boxes describe, in that cell or in the frame's view.
135
135
  Close each thread with `close`, a short summary of what changed and
136
136
  `where` it landed: the frame and the selector of the element you changed.