@dinachi/cli 0.12.0 → 1.1.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 (74) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/dist/index.js +73 -7
  3. package/package.json +1 -1
  4. package/templates/accordion/accordion.tsx +70 -12
  5. package/templates/agent/agent.tsx +1865 -0
  6. package/templates/agent/index.ts +52 -0
  7. package/templates/alert-dialog/alert-dialog.tsx +59 -19
  8. package/templates/alert-dialog/index.ts +2 -0
  9. package/templates/animated-icon/animated-icon.tsx +1 -0
  10. package/templates/animated-list/animated-list.tsx +2 -1
  11. package/templates/animated-tabs/animated-tabs.tsx +69 -5
  12. package/templates/autocomplete/autocomplete.tsx +188 -21
  13. package/templates/avatar/avatar.tsx +3 -0
  14. package/templates/badge/badge.tsx +1 -0
  15. package/templates/button/button.tsx +1 -0
  16. package/templates/card/card.tsx +6 -1
  17. package/templates/carousel/carousel.tsx +109 -24
  18. package/templates/checkbox/checkbox.tsx +61 -4
  19. package/templates/checkbox-group/checkbox-group.tsx +83 -8
  20. package/templates/collapsible/collapsible.tsx +15 -4
  21. package/templates/combobox/combobox.tsx +312 -26
  22. package/templates/compare-slider/compare-slider.tsx +104 -28
  23. package/templates/compare-slider/index.ts +1 -1
  24. package/templates/context-menu/context-menu.tsx +93 -24
  25. package/templates/dialog/dialog.tsx +53 -14
  26. package/templates/drawer/drawer.tsx +36 -8
  27. package/templates/expandable-card/expandable-card.tsx +70 -43
  28. package/templates/field/field.tsx +7 -1
  29. package/templates/fieldset/fieldset.tsx +2 -0
  30. package/templates/form/form.tsx +1 -0
  31. package/templates/hold-to-confirm/hold-to-confirm.tsx +100 -16
  32. package/templates/hold-to-confirm/index.ts +1 -1
  33. package/templates/input/input.tsx +60 -1
  34. package/templates/label/label.tsx +1 -0
  35. package/templates/link/link.tsx +1 -0
  36. package/templates/load-transition/load-transition.tsx +1 -0
  37. package/templates/marquee/marquee.tsx +1 -0
  38. package/templates/menu/menu.tsx +45 -12
  39. package/templates/menubar/menubar.tsx +41 -11
  40. package/templates/meter/meter.tsx +5 -1
  41. package/templates/navigation-menu/navigation-menu.tsx +79 -24
  42. package/templates/number-field/index.ts +1 -0
  43. package/templates/number-field/number-field.tsx +77 -2
  44. package/templates/number-ticker/number-ticker.tsx +3 -0
  45. package/templates/otp-field/otp-field.tsx +61 -11
  46. package/templates/popover/popover.tsx +36 -7
  47. package/templates/preview-card/preview-card.tsx +27 -5
  48. package/templates/progress/progress.tsx +5 -1
  49. package/templates/progress-ring/progress-ring.tsx +1 -0
  50. package/templates/radio/radio.tsx +74 -6
  51. package/templates/scroll-area/scroll-area.tsx +14 -4
  52. package/templates/scroll-progress/scroll-progress.tsx +1 -0
  53. package/templates/scroll-reveal/scroll-reveal.tsx +1 -0
  54. package/templates/select/select.tsx +241 -12
  55. package/templates/separator/separator.tsx +1 -0
  56. package/templates/skeleton/skeleton.tsx +1 -0
  57. package/templates/slider/slider.tsx +84 -8
  58. package/templates/sortable/sortable.tsx +79 -9
  59. package/templates/stagger-list/stagger-list.tsx +2 -0
  60. package/templates/streaming-text/streaming-text.tsx +1 -0
  61. package/templates/swipeable-row/index.ts +1 -1
  62. package/templates/swipeable-row/swipeable-row.tsx +126 -41
  63. package/templates/switch/switch.tsx +43 -4
  64. package/templates/tabs/tabs.tsx +79 -10
  65. package/templates/text/text.tsx +1 -0
  66. package/templates/text-morph/text-morph.tsx +2 -0
  67. package/templates/text-shimmer/text-shimmer.tsx +1 -0
  68. package/templates/textarea/index.ts +1 -1
  69. package/templates/textarea/textarea.tsx +71 -4
  70. package/templates/toast/toast.tsx +13 -2
  71. package/templates/toggle/toggle.tsx +40 -7
  72. package/templates/toggle-group/toggle-group.tsx +98 -18
  73. package/templates/toolbar/toolbar.tsx +6 -0
  74. package/templates/tooltip/tooltip.tsx +9 -3
package/CHANGELOG.md CHANGED
@@ -5,6 +5,135 @@ All notable changes to `@dinachi/cli` will be documented in this file.
5
5
  The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [1.1.0] - 2026-11-17
11
+
12
+ ### Added
13
+
14
+ - Every exported part that renders an element carries `data-slot` with its
15
+ kebab-case name (`select-trigger`, `slider-thumb`), so styles, tests and agents
16
+ can target a part without a class name.
17
+
18
+ ### Changed
19
+
20
+ - `SelectGroup` and `SelectValue` are thin wrappers instead of re-exports of the
21
+ Base UI parts, so they can carry `data-slot`. Props are unchanged.
22
+
23
+ ## [1.0.0] - 2026-11-15
24
+
25
+ ### Added
26
+
27
+ - **Agent**: `dinachi add agent` installs a bridge that lets an AI agent read and
28
+ operate the page (`snapshot`, `query`, `act`), with an `allow` gate and
29
+ WebMCP registration. Inside `AgentProvider`, Input, Select and Dialog register
30
+ their state and actions directly; everything else is reached through the
31
+ accessibility tree.
32
+ - **Agent**: Textarea, OTPField, NumberField, Slider, CompareSlider, Combobox,
33
+ Autocomplete, Checkbox, CheckboxGroup, RadioGroup, Switch, Toggle and ToggleGroup
34
+ register with the bridge. Each change goes through the component's own callback
35
+ with details the app can cancel. Choices match by label, then by value.
36
+ - **Agent**: a control inside a Field reports the Field's error, and `in` names the
37
+ Fieldset or Form around it. An agent's change to an Input is a real input event,
38
+ so `onChange` and the Field's dirty and filled state see it.
39
+ - **Agent**: `data-agent-part` marks an element that belongs to a registered
40
+ control, so it is not listed twice. `useAgentItem`, `agentChoicesOf` and
41
+ `AgentGroupContext` let a group component register its items.
42
+ - **Agent**: a Slider or NumberField change by an agent also calls
43
+ `onValueCommitted`, and lands on the step without float drift (`agentRound`).
44
+ A refused change leaves Input and Textarea untouched, and a Combobox or
45
+ Autocomplete the agent opened closes again.
46
+ - **Agent**: OTPField reports one redacted value, and a masked field is secret
47
+ whatever its `autoComplete`.
48
+ - **Agent**: AlertDialog, Drawer, Popover, PreviewCard, Collapsible, Accordion,
49
+ ExpandableCard, Menu, ContextMenu, Menubar and NavigationMenu register with the
50
+ bridge, each as one control with `open` and `close`. Menu items take `press`, and
51
+ `setChecked` when they can be checked. A popup with no title of its own goes by
52
+ its trigger's name.
53
+ - **Agent**: Tabs, AnimatedTabs, Carousel (`goTo`), Sortable (`move`), SwipeableRow
54
+ and HoldToConfirm register with the bridge. A HoldToConfirm press completes the
55
+ hold at once and needs a person's approval by default. Plain links (`a[href]`)
56
+ are listed as `link`, with their href as the value.
57
+ - **Agent**: progress bars and meters, including Progress, ProgressRing and Meter,
58
+ are read with `value`, `min` and `max`. A Toast is listed as `toast` with its
59
+ description and `type`, and `dismiss` presses its close button, which
60
+ `data-agent-dismiss` marks. A high-priority toast is listed too, though Base UI
61
+ hides it from assistive tech until focused.
62
+ - **Carousel**: `onIndexChange` also receives cancelable `details` with a `reason`,
63
+ and a `disabled` prop turns off the drag, arrows and dots.
64
+ - **Sortable**: `onValueChange` also receives `details` with a `reason`, and a
65
+ `disabled` prop turns off the handles. It stays controlled: refuse a move by not
66
+ applying `next`.
67
+ - **SwipeableRow**: `onSelect` and `onDismiss` receive cancelable `details`, and an
68
+ action can be `disabled`.
69
+ - **HoldToConfirm**: `onConfirm` receives `details`; `details.cancel()` unwinds
70
+ the hold.
71
+ - **ExpandableCard**: `onOpenChange` also receives `details` with a `reason`, and
72
+ `details.cancel()` keeps the card as it was.
73
+ - **Textarea**: `onValueChange(value, details)`, which an agent's change goes through.
74
+ - **CompareSlider**: a `disabled` prop. `onPositionChange` also receives `details`
75
+ with a `reason`, and `details.cancel()` puts the divider back.
76
+ - **Agent**: `useAgentAction` exposes an app action (`inviteMember`, `archiveProject`)
77
+ whose `input` is any Standard Schema that can describe itself as JSON Schema
78
+ (zod 4.2+, arktype 2.1.28+, or valibot wrapped in `toStandardJsonSchema`).
79
+ Pass `element` to tie it to a card or row, so the same action on many items has
80
+ one target each. Each action is its own tool by default, in `agentToolsFor` and
81
+ in WebMCP; `{ actions: "act" }` keeps them behind `act`. The bridge installs no
82
+ packages.
83
+ - **Agent**: snapshots report where a control sits (`in`), whether it is required
84
+ or invalid with its error text, number and slider bounds, and every choice of a
85
+ closed Select. Dialogs come first, and an open modal hides the page behind it.
86
+ Long values and lists are cut short and say so.
87
+ - **Agent**: `confirm` and `data-agent-confirm` mark a step that needs a person.
88
+ Each entry's `approval` says whether the app will ask (`allow` is set) or only
89
+ the person can do it. Controls inside an alert dialog need approval by default;
90
+ `data-agent-confirm="none"` lifts it.
91
+ - **Agent**: `agent.subscribe` reports when app actions mount or unmount.
92
+ - `add --v1` installs a component as it was before agent registration, by
93
+ running `@dinachi/cli@0.12.0`. It stays frozen there, is deprecated in 1.1 and
94
+ removed in 1.2.
95
+ - **Docs**: an Agents guide, a Safety page and Recipes for Claude, OpenAI, the
96
+ Vercel AI SDK and WebMCP. Each component that registers, or is read from the
97
+ tree, says what the agent sees and can do on its own page.
98
+
99
+ ### Changed
100
+
101
+ - **Input, Select, Dialog**: now depend on `agent` and install it alongside.
102
+ Outside `AgentProvider` they behave as before and render nothing extra. Inside
103
+ it, an agent can pick a Select choice by its label without opening it. `isAgentChange(details)` tells
104
+ an agent's change from a person's in `onValueChange` and `onOpenChange`.
105
+ - **AlertDialog, Drawer, Popover, PreviewCard, Collapsible, Accordion,
106
+ ExpandableCard, Menu, ContextMenu, Menubar, NavigationMenu, Tabs, AnimatedTabs,
107
+ Carousel, Sortable, SwipeableRow, HoldToConfirm**: now depend on
108
+ `agent` and install it alongside. Outside `AgentProvider` nothing changes.
109
+ - **Accordion, NavigationMenu**: an item with no `value` gets one from `useId`, so
110
+ the id `onValueChange` reports for it differs from Base UI's generated one.
111
+ - **ContextMenu**: inside `AgentProvider`, a disabled menu marks its trigger area
112
+ `data-disabled`.
113
+ - **AnimatedTabs**: `details.cancel()` in `onValueChange` now keeps the current tab
114
+ when uncontrolled.
115
+ - **Agent**: a `data-agent-confirm` on an ancestor now overrides a control's own
116
+ default approval, not only one on the element itself.
117
+ - **Agent**: text marked `aria-hidden` is left out of labels, so a decorative
118
+ glyph does not join a control's name.
119
+ - **JSON Render**: installs zod `^4.3.6`, the version the workspace tests against.
120
+ - Templates can import other components; `add` rewrites
121
+ `@/components/ui/<name>` to your configured `ui` alias.
122
+
123
+ ### Fixed
124
+
125
+ - **Dialog, AlertDialog**: `DialogClose`, `AlertDialogAction` and
126
+ `AlertDialogCancel` applied their own styles over an element passed through
127
+ `render`, so `<DialogClose render={<Button />}>` lost the Button's variant. The
128
+ defaults now apply only without `render`.
129
+ - **Menu, ContextMenu, Menubar**: the popup's `z-50` never applied, so a sticky
130
+ header or other `z-50` layer painted over an open menu. It now sits on the
131
+ positioner.
132
+ - **AlertDialog**: the barrel exports `AlertDialogContent` and
133
+ `AlertDialogViewport`.
134
+ - **Toast**: an action's `onClick` ran twice per click. Base UI's `Toast.Action`
135
+ already applies `actionProps`, and the default list passed them again.
136
+
8
137
  ## [0.12.0] - 2026-10-09
9
138
 
10
139
  ### Added
@@ -211,6 +340,8 @@ Re-run `dinachi add select`, `dinachi add slider`, and `dinachi add otp-field`
211
340
  See [git history](https://github.com/raymond-UI/dinachiUI/commits/main/packages/cli)
212
341
  for changes prior to 0.9.0.
213
342
 
343
+ [1.1.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v1.1.0
344
+ [1.0.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v1.0.0
214
345
  [0.12.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v0.12.0
215
346
  [0.11.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v0.11.0
216
347
  [0.10.0]: https://github.com/raymond-UI/dinachiUI/releases/tag/cli-v0.10.0
package/dist/index.js CHANGED
@@ -76,13 +76,21 @@ function getComponentRegistry() {
76
76
  description: "A vertically stacked set of interactive headings that each reveal a section of content.",
77
77
  files: [{ name: "accordion.tsx" }, { name: "index.ts" }],
78
78
  dependencies: ["@base-ui/react", "lucide-react"],
79
+ componentDependencies: ["agent"],
79
80
  utilityDependencies: ["cn"]
80
81
  },
82
+ agent: {
83
+ name: "agent",
84
+ description: "Lets an AI agent read and operate the controls on a page and call actions the app offers, with a gate on every action and optional WebMCP tools.",
85
+ files: [{ name: "agent.tsx" }, { name: "index.ts" }],
86
+ dependencies: []
87
+ },
81
88
  "alert-dialog": {
82
89
  name: "alert-dialog",
83
90
  description: "A modal dialog that interrupts the user with important content and expects a response.",
84
91
  files: [{ name: "alert-dialog.tsx" }, { name: "index.ts" }],
85
92
  dependencies: ["@base-ui/react"],
93
+ componentDependencies: ["agent"],
86
94
  utilityDependencies: ["cn"]
87
95
  },
88
96
  autocomplete: {
@@ -90,6 +98,7 @@ function getComponentRegistry() {
90
98
  description: "A text input with dynamic suggestions that helps users find and select values quickly.",
91
99
  files: [{ name: "autocomplete.tsx" }, { name: "index.ts" }],
92
100
  dependencies: ["@base-ui/react", "lucide-react"],
101
+ componentDependencies: ["agent"],
93
102
  utilityDependencies: ["cn"]
94
103
  },
95
104
  avatar: {
@@ -125,6 +134,7 @@ function getComponentRegistry() {
125
134
  description: "A control that allows the user to select one or more options from a set.",
126
135
  files: [{ name: "checkbox.tsx" }, { name: "index.ts" }],
127
136
  dependencies: ["@base-ui/react", "lucide-react"],
137
+ componentDependencies: ["agent"],
128
138
  utilityDependencies: ["cn"]
129
139
  },
130
140
  "checkbox-group": {
@@ -132,7 +142,7 @@ function getComponentRegistry() {
132
142
  description: "A group of checkboxes that share a common state.",
133
143
  files: [{ name: "checkbox-group.tsx" }, { name: "index.ts" }],
134
144
  dependencies: ["@base-ui/react"],
135
- componentDependencies: ["checkbox"],
145
+ componentDependencies: ["agent", "checkbox"],
136
146
  utilityDependencies: ["cn"]
137
147
  },
138
148
  collapsible: {
@@ -140,6 +150,7 @@ function getComponentRegistry() {
140
150
  description: "A collapsible panel controlled by a button.",
141
151
  files: [{ name: "collapsible.tsx" }, { name: "index.ts" }],
142
152
  dependencies: ["@base-ui/react"],
153
+ componentDependencies: ["agent"],
143
154
  utilityDependencies: ["cn"]
144
155
  },
145
156
  combobox: {
@@ -147,6 +158,7 @@ function getComponentRegistry() {
147
158
  description: "A combobox that combines text input with a selectable popup list of options.",
148
159
  files: [{ name: "combobox.tsx" }, { name: "index.ts" }],
149
160
  dependencies: ["@base-ui/react", "lucide-react"],
161
+ componentDependencies: ["agent"],
150
162
  utilityDependencies: ["cn"]
151
163
  },
152
164
  "context-menu": {
@@ -154,6 +166,7 @@ function getComponentRegistry() {
154
166
  description: "A menu that appears at the pointer on right click or long press.",
155
167
  files: [{ name: "context-menu.tsx" }, { name: "index.ts" }],
156
168
  dependencies: ["@base-ui/react", "lucide-react"],
169
+ componentDependencies: ["agent"],
157
170
  utilityDependencies: ["cn"]
158
171
  },
159
172
  dialog: {
@@ -161,6 +174,7 @@ function getComponentRegistry() {
161
174
  description: "A popup that opens on top of the entire page, providing a modal interface for user interactions.",
162
175
  files: [{ name: "dialog.tsx" }, { name: "index.ts" }],
163
176
  dependencies: ["@base-ui/react"],
177
+ componentDependencies: ["agent"],
164
178
  utilityDependencies: ["cn"]
165
179
  },
166
180
  drawer: {
@@ -168,6 +182,7 @@ function getComponentRegistry() {
168
182
  description: "A panel that slides in from the edge of the screen for focused workflows.",
169
183
  files: [{ name: "drawer.tsx" }, { name: "index.ts" }],
170
184
  dependencies: ["@base-ui/react"],
185
+ componentDependencies: ["agent"],
171
186
  utilityDependencies: ["cn"]
172
187
  },
173
188
  field: {
@@ -196,6 +211,7 @@ function getComponentRegistry() {
196
211
  description: "A customizable input field component with variants and sizes.",
197
212
  files: [{ name: "input.tsx" }, { name: "index.ts" }],
198
213
  dependencies: ["@base-ui/react"],
214
+ componentDependencies: ["agent"],
199
215
  utilityDependencies: ["cn"]
200
216
  },
201
217
  label: {
@@ -217,6 +233,7 @@ function getComponentRegistry() {
217
233
  description: "A popup menu for actions and options triggered by a button.",
218
234
  files: [{ name: "menu.tsx" }, { name: "index.ts" }],
219
235
  dependencies: ["@base-ui/react", "lucide-react"],
236
+ componentDependencies: ["agent"],
220
237
  utilityDependencies: ["cn"]
221
238
  },
222
239
  menubar: {
@@ -224,6 +241,7 @@ function getComponentRegistry() {
224
241
  description: "A visually persistent menu common in desktop applications that provides access to a consistent set of commands.",
225
242
  files: [{ name: "menubar.tsx" }, { name: "index.ts" }],
226
243
  dependencies: ["@base-ui/react", "lucide-react"],
244
+ componentDependencies: ["agent"],
227
245
  utilityDependencies: ["cn"]
228
246
  },
229
247
  meter: {
@@ -238,6 +256,7 @@ function getComponentRegistry() {
238
256
  description: "A collection of links and menus for website navigation.",
239
257
  files: [{ name: "navigation-menu.tsx" }, { name: "index.ts" }],
240
258
  dependencies: ["@base-ui/react", "lucide-react"],
259
+ componentDependencies: ["agent"],
241
260
  utilityDependencies: ["cn"]
242
261
  },
243
262
  "number-field": {
@@ -245,6 +264,7 @@ function getComponentRegistry() {
245
264
  description: "A numeric input with increment, decrement, and optional scrubbing controls.",
246
265
  files: [{ name: "number-field.tsx" }, { name: "index.ts" }],
247
266
  dependencies: ["@base-ui/react", "lucide-react"],
267
+ componentDependencies: ["agent"],
248
268
  utilityDependencies: ["cn"]
249
269
  },
250
270
  "otp-field": {
@@ -252,6 +272,7 @@ function getComponentRegistry() {
252
272
  description: "A one-time password / verification code input with auto-focus, paste handling, and validation.",
253
273
  files: [{ name: "otp-field.tsx" }, { name: "index.ts" }],
254
274
  dependencies: ["@base-ui/react"],
275
+ componentDependencies: ["agent"],
255
276
  utilityDependencies: ["cn"]
256
277
  },
257
278
  popover: {
@@ -259,6 +280,7 @@ function getComponentRegistry() {
259
280
  description: "An anchored floating panel for contextual information and lightweight interactions.",
260
281
  files: [{ name: "popover.tsx" }, { name: "index.ts" }],
261
282
  dependencies: ["@base-ui/react"],
283
+ componentDependencies: ["agent"],
262
284
  utilityDependencies: ["cn"]
263
285
  },
264
286
  "preview-card": {
@@ -266,6 +288,7 @@ function getComponentRegistry() {
266
288
  description: "A popup that appears when a link is hovered, showing a preview for sighted users.",
267
289
  files: [{ name: "preview-card.tsx" }, { name: "index.ts" }],
268
290
  dependencies: ["@base-ui/react"],
291
+ componentDependencies: ["agent"],
269
292
  utilityDependencies: ["cn"]
270
293
  },
271
294
  progress: {
@@ -280,6 +303,7 @@ function getComponentRegistry() {
280
303
  description: "A radio input and group for selecting a single option from a set.",
281
304
  files: [{ name: "radio.tsx" }, { name: "index.ts" }],
282
305
  dependencies: ["@base-ui/react"],
306
+ componentDependencies: ["agent"],
283
307
  utilityDependencies: ["cn"]
284
308
  },
285
309
  "scroll-area": {
@@ -294,6 +318,7 @@ function getComponentRegistry() {
294
318
  description: "A common form component for choosing a predefined value in a dropdown menu.",
295
319
  files: [{ name: "select.tsx" }, { name: "index.ts" }],
296
320
  dependencies: ["@base-ui/react", "lucide-react"],
321
+ componentDependencies: ["agent"],
297
322
  utilityDependencies: ["cn"]
298
323
  },
299
324
  separator: {
@@ -315,6 +340,7 @@ function getComponentRegistry() {
315
340
  description: "An input where the user selects a value from within a given range.",
316
341
  files: [{ name: "slider.tsx" }, { name: "index.ts" }],
317
342
  dependencies: ["@base-ui/react"],
343
+ componentDependencies: ["agent"],
318
344
  utilityDependencies: ["cn"]
319
345
  },
320
346
  switch: {
@@ -322,6 +348,7 @@ function getComponentRegistry() {
322
348
  description: "A control that allows users to toggle a setting on or off.",
323
349
  files: [{ name: "switch.tsx" }, { name: "index.ts" }],
324
350
  dependencies: ["@base-ui/react"],
351
+ componentDependencies: ["agent"],
325
352
  utilityDependencies: ["cn"]
326
353
  },
327
354
  tabs: {
@@ -329,6 +356,7 @@ function getComponentRegistry() {
329
356
  description: "A component for toggling between related panels on the same page.",
330
357
  files: [{ name: "tabs.tsx" }, { name: "index.ts" }],
331
358
  dependencies: ["@base-ui/react"],
359
+ componentDependencies: ["agent"],
332
360
  utilityDependencies: ["cn"]
333
361
  },
334
362
  text: {
@@ -342,7 +370,8 @@ function getComponentRegistry() {
342
370
  name: "textarea",
343
371
  description: "A multi-line text input for longer form content.",
344
372
  files: [{ name: "textarea.tsx" }, { name: "index.ts" }],
345
- dependencies: [],
373
+ dependencies: ["@base-ui/react"],
374
+ componentDependencies: ["agent"],
346
375
  utilityDependencies: ["cn"]
347
376
  },
348
377
  toast: {
@@ -357,6 +386,7 @@ function getComponentRegistry() {
357
386
  description: "A two-state button that can be on or off.",
358
387
  files: [{ name: "toggle.tsx" }, { name: "index.ts" }],
359
388
  dependencies: ["@base-ui/react", "class-variance-authority"],
389
+ componentDependencies: ["agent"],
360
390
  utilityDependencies: ["cn"]
361
391
  },
362
392
  "toggle-group": {
@@ -364,6 +394,7 @@ function getComponentRegistry() {
364
394
  description: "A grouped set of toggles supporting single or multiple pressed states.",
365
395
  files: [{ name: "toggle-group.tsx" }, { name: "index.ts" }],
366
396
  dependencies: ["@base-ui/react", "class-variance-authority"],
397
+ componentDependencies: ["agent"],
367
398
  utilityDependencies: ["cn"]
368
399
  },
369
400
  toolbar: {
@@ -404,6 +435,7 @@ function getComponentRegistry() {
404
435
  description: "Tabs whose active pill travels between triggers using a shared layout animation.",
405
436
  files: [{ name: "animated-tabs.tsx" }, { name: "index.ts" }],
406
437
  dependencies: ["@base-ui/react", "motion"],
438
+ componentDependencies: ["agent"],
407
439
  utilityDependencies: ["cn"],
408
440
  tier: "motion"
409
441
  },
@@ -412,6 +444,7 @@ function getComponentRegistry() {
412
444
  description: "A carousel that snaps to where the flick was aimed, not to where it stopped.",
413
445
  files: [{ name: "carousel.tsx" }, { name: "index.ts" }],
414
446
  dependencies: ["motion"],
447
+ componentDependencies: ["agent"],
415
448
  utilityDependencies: ["cn"],
416
449
  tier: "motion"
417
450
  },
@@ -420,6 +453,7 @@ function getComponentRegistry() {
420
453
  description: "A draggable divider for comparing two layers side by side.",
421
454
  files: [{ name: "compare-slider.tsx" }, { name: "index.ts" }],
422
455
  dependencies: ["motion"],
456
+ componentDependencies: ["agent"],
423
457
  utilityDependencies: ["cn"],
424
458
  tier: "motion"
425
459
  },
@@ -428,6 +462,7 @@ function getComponentRegistry() {
428
462
  description: "A card that opens into its own detail view using a shared layout animation.",
429
463
  files: [{ name: "expandable-card.tsx" }, { name: "index.ts" }],
430
464
  dependencies: ["motion"],
465
+ componentDependencies: ["agent"],
431
466
  utilityDependencies: ["cn"],
432
467
  tier: "motion"
433
468
  },
@@ -436,6 +471,7 @@ function getComponentRegistry() {
436
471
  description: "A destructive action gated behind a deliberate press-and-hold.",
437
472
  files: [{ name: "hold-to-confirm.tsx" }, { name: "index.ts" }],
438
473
  dependencies: ["@base-ui/react", "motion"],
474
+ componentDependencies: ["agent"],
439
475
  utilityDependencies: ["cn"],
440
476
  tier: "motion"
441
477
  },
@@ -492,6 +528,7 @@ function getComponentRegistry() {
492
528
  description: "A list reordered by drag or by keyboard, both ending in the same place.",
493
529
  files: [{ name: "sortable.tsx" }, { name: "index.ts" }],
494
530
  dependencies: ["motion"],
531
+ componentDependencies: ["agent"],
495
532
  utilityDependencies: ["cn"],
496
533
  tier: "motion"
497
534
  },
@@ -516,6 +553,7 @@ function getComponentRegistry() {
516
553
  description: "A row whose actions are revealed by a velocity-projected swipe.",
517
554
  files: [{ name: "swipeable-row.tsx" }, { name: "index.ts" }],
518
555
  dependencies: ["motion"],
556
+ componentDependencies: ["agent"],
519
557
  utilityDependencies: ["cn"],
520
558
  tier: "motion"
521
559
  },
@@ -707,13 +745,34 @@ var DEPENDENCY_VERSION_MAP = {
707
745
  "tailwind-merge": "^3.5.0",
708
746
  "@json-render/core": "^0.14.0",
709
747
  "@json-render/react": "^0.14.0",
710
- "zod": "^4.0.0"
748
+ "zod": "^4.3.6"
711
749
  };
712
750
  function toInstallSpec(dep) {
713
751
  const version = DEPENDENCY_VERSION_MAP[dep];
714
752
  return version ? `${dep}@${version}` : dep;
715
753
  }
716
754
 
755
+ // src/utils/legacy.ts
756
+ import { spawnSync } from "child_process";
757
+ var V1_CLI_VERSION = "0.12.0";
758
+ function runV1Add(argv = process.argv) {
759
+ const windows = process.platform === "win32";
760
+ const args = ["--yes", `@dinachi/cli@${V1_CLI_VERSION}`, "add", ...v1AddArgs(argv)];
761
+ const result = windows ? spawnSync("npx.cmd", args.map(quoteForCmd), { stdio: "inherit", shell: true }) : spawnSync("npx", args, { stdio: "inherit" });
762
+ if (result.error) {
763
+ console.error(`Could not run @dinachi/cli@${V1_CLI_VERSION}: ${result.error.message}`);
764
+ return 1;
765
+ }
766
+ return result.status ?? 1;
767
+ }
768
+ function quoteForCmd(arg) {
769
+ return /^[\w@./:=-]+$/.test(arg) ? arg : `"${arg.replace(/"/g, '""')}"`;
770
+ }
771
+ function v1AddArgs(argv) {
772
+ const at = argv.indexOf("add");
773
+ return at === -1 ? [] : argv.slice(at + 1).filter((arg) => arg !== "--v1");
774
+ }
775
+
717
776
  // src/commands/add.ts
718
777
  var __filename2 = fileURLToPath2(import.meta.url);
719
778
  var __dirname2 = path3.dirname(__filename2);
@@ -814,9 +873,13 @@ function tryResolveAsAlias(absoluteFilePath, compilerConfig) {
814
873
  }
815
874
  return null;
816
875
  }
817
- function rewriteTemplateImports(content, targetFilePath, utilsFilePath, compilerConfig) {
876
+ function rewriteTemplateImports(content, targetFilePath, utilsFilePath, componentDir, compilerConfig) {
818
877
  const utilsImportPath = tryResolveAsAlias(utilsFilePath, compilerConfig) ?? toImportPath(targetFilePath, utilsFilePath);
819
- return content.replace(/(['"])@\/lib\/utils\1/g, `$1${utilsImportPath}$1`);
878
+ const componentImportPath = (name) => {
879
+ const filePath = path3.join(componentDir, `${name}.tsx`);
880
+ return tryResolveAsAlias(filePath, compilerConfig) ?? toImportPath(targetFilePath, filePath);
881
+ };
882
+ return content.replace(/(['"])@\/lib\/utils\1/g, `$1${utilsImportPath}$1`).replace(/(['"])@\/components\/ui\/([a-z0-9-]+)\1/g, (_match, quote, name) => `${quote}${componentImportPath(name)}${quote}`);
820
883
  }
821
884
  function getComponentDependencies(componentName, visited = /* @__PURE__ */ new Set()) {
822
885
  if (visited.has(componentName)) {
@@ -1066,8 +1129,11 @@ function withComponentDependencies(names) {
1066
1129
  }
1067
1130
  return [...resolved];
1068
1131
  }
1069
- var addCommand = new Command("add").description("Add a component to your project").argument("[components...]", "Names of the components to add (optional when using --all or --motion)").option("-y, --yes", "Skip confirmation prompts").option("-o, --overwrite", "Overwrite existing files").option("-a, --all", "Install every core component").option("-m, --motion", "With component names, install their motion build. On its own, install every motion component").option("--skip-install", "Skip package installation").action(
1132
+ var addCommand = new Command("add").description("Add a component to your project").argument("[components...]", "Names of the components to add (optional when using --all or --motion)").option("-y, --yes", "Skip confirmation prompts").option("-o, --overwrite", "Overwrite existing files").option("-a, --all", "Install every core component").option("-m, --motion", "With component names, install their motion build. On its own, install every motion component").option("--skip-install", "Skip package installation").option("--v1", `Install the v1 build, from before components registered with the agent bridge (runs @dinachi/cli@${V1_CLI_VERSION})`).action(
1070
1133
  async (componentNames, options) => {
1134
+ if (options.v1) {
1135
+ process.exit(runV1Add());
1136
+ }
1071
1137
  const spinner = ora("Adding component...").start();
1072
1138
  try {
1073
1139
  const config = await getConfig();
@@ -1187,7 +1253,7 @@ var addCommand = new Command("add").description("Add a component to your project
1187
1253
  spinner.start();
1188
1254
  }
1189
1255
  const templateContent = stripTemplateDirective(await fs3.readFile(sourcePath, "utf-8"));
1190
- const rewrittenContent = rewriteTemplateImports(templateContent, targetPath, utilsFilePath, compilerPathConfig);
1256
+ const rewrittenContent = rewriteTemplateImports(templateContent, targetPath, utilsFilePath, componentDir, compilerPathConfig);
1191
1257
  await fs3.writeFile(targetPath, rewrittenContent);
1192
1258
  allFilesAdded.push({ name: file.name, path: targetPath });
1193
1259
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dinachi/cli",
3
- "version": "0.12.0",
3
+ "version": "1.1.0",
4
4
  "description": "CLI for adding Dinachi UI components to your project",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -2,25 +2,80 @@ import * as React from "react";
2
2
  import { Accordion as BaseAccordion } from "@base-ui/react/accordion";
3
3
  import { cn } from "@/lib/utils";
4
4
  import { ChevronDown } from "lucide-react";
5
+ import { changeAsAgent, useAgentControl, useAgentState, useHasAgent, useMergedRef } from "@/components/ui/agent";
5
6
 
7
+ type Details = BaseAccordion.Root.ChangeEventDetails;
8
+
9
+ interface AccordionAgent {
10
+ value: unknown[];
11
+ multiple: boolean;
12
+ change: (next: unknown[], details: Details) => void;
13
+ }
14
+
15
+ const AccordionAgentContext = React.createContext<AccordionAgent | null>(null);
16
+ type Ref<T> = React.MutableRefObject<T | null>;
17
+ const AccordionPartsContext = React.createContext<{ trigger: Ref<HTMLButtonElement>; panel: Ref<HTMLDivElement> } | null>(null);
18
+
19
+ /**
20
+ * Base UI's root, holding its own value so an agent can open and close items the way a
21
+ * parent would. Controlled use is unchanged, and `onValueChange` sees the agent's changes
22
+ * first and can cancel them.
23
+ */
6
24
  const Accordion = React.forwardRef<
7
25
  React.ComponentRef<typeof BaseAccordion.Root>,
8
26
  React.ComponentProps<typeof BaseAccordion.Root>
9
- >(({ className, ...props }, ref) => (
10
- <BaseAccordion.Root ref={ref} className={cn(className)} {...props} />
11
- ));
27
+ >(({ className, value: valueProp, defaultValue, onValueChange, ...props }, ref) => {
28
+ const [value, change] = useAgentState<unknown[], Details>(valueProp, defaultValue ?? [], onValueChange);
29
+ const agent = { value, multiple: Boolean(props.multiple), change };
30
+ return (
31
+ <AccordionAgentContext.Provider value={useHasAgent() ? agent : null}>
32
+ <BaseAccordion.Root data-slot="accordion" ref={ref} data-agent-in={props["aria-label"]} className={cn(className)} {...props} value={value} onValueChange={change} />
33
+ </AccordionAgentContext.Provider>
34
+ );
35
+ });
12
36
  Accordion.displayName = "Accordion";
13
37
 
38
+ /** Each item is its own disclosure to the agent, standing at its trigger. Open, it reads as its panel's text. */
14
39
  const AccordionItem = React.forwardRef<
15
40
  HTMLDivElement,
16
41
  React.ComponentProps<typeof BaseAccordion.Item>
17
- >(({ className, ...props }, ref) => (
18
- <BaseAccordion.Item
19
- ref={ref}
20
- className={cn("border-b", className)}
21
- {...props}
22
- />
23
- ));
42
+ >(({ className, value: valueProp, ...props }, ref) => {
43
+ const fallback = React.useId();
44
+ const value = valueProp ?? fallback;
45
+ const root = React.useContext(AccordionAgentContext);
46
+ const trigger = React.useRef<HTMLButtonElement | null>(null);
47
+ const panel = React.useRef<HTMLDivElement | null>(null);
48
+ const [parts] = React.useState(() => ({ trigger, panel }));
49
+
50
+ useAgentControl(() => {
51
+ if (!root) return null;
52
+ const open = root.value.includes(value);
53
+ const next = open
54
+ ? root.value.filter((v) => v !== value)
55
+ : root.multiple
56
+ ? [...root.value, value]
57
+ : [value];
58
+ return {
59
+ kind: "disclosure",
60
+ element: trigger.current,
61
+ open,
62
+ value: open ? panel.current?.textContent?.replace(/\s+/g, " ").trim() || undefined : undefined,
63
+ actions: { [open ? "close" : "open"]: () => changeAsAgent(root.change, next) },
64
+ };
65
+ });
66
+
67
+ return (
68
+ <AccordionPartsContext.Provider value={root ? parts : null}>
69
+ <BaseAccordion.Item
70
+ data-slot="accordion-item"
71
+ ref={ref}
72
+ className={cn("border-b", className)}
73
+ value={value}
74
+ {...props}
75
+ />
76
+ </AccordionPartsContext.Provider>
77
+ );
78
+ });
24
79
  AccordionItem.displayName = "AccordionItem";
25
80
 
26
81
  const AccordionHeader = React.forwardRef<
@@ -28,6 +83,7 @@ const AccordionHeader = React.forwardRef<
28
83
  React.ComponentProps<typeof BaseAccordion.Header>
29
84
  >(({ className, ...props }, ref) => (
30
85
  <BaseAccordion.Header
86
+ data-slot="accordion-header"
31
87
  ref={ref}
32
88
  className={cn("flex", className)}
33
89
  {...props}
@@ -42,7 +98,8 @@ const AccordionTrigger = React.forwardRef<
42
98
  }
43
99
  >(({ className, children, ...props }, ref) => (
44
100
  <BaseAccordion.Trigger
45
- ref={ref}
101
+ data-slot="accordion-trigger"
102
+ ref={useMergedRef(ref, React.useContext(AccordionPartsContext)?.trigger)}
46
103
  className={cn(
47
104
  "flex flex-1 items-center justify-between py-4 font-medium transition-colors hover:underline",
48
105
  "[&[data-panel-open]>svg]:rotate-180",
@@ -62,7 +119,8 @@ const AccordionPanel = React.forwardRef<
62
119
  React.ComponentProps<typeof BaseAccordion.Panel>
63
120
  >(({ className, children, ...props }, ref) => (
64
121
  <BaseAccordion.Panel
65
- ref={ref}
122
+ data-slot="accordion-panel"
123
+ ref={useMergedRef(ref, React.useContext(AccordionPartsContext)?.panel)}
66
124
  className={cn(
67
125
  "overflow-hidden text-sm h-[var(--accordion-panel-height)]",
68
126
  "transition-[height] duration-[var(--motion-duration-base,200ms)] ease-[var(--motion-ease-out,cubic-bezier(0.23,1,0.32,1))]",