@create-ui/cli 0.1.0-beta.1 → 0.5.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.
@@ -0,0 +1,253 @@
1
+ # Styling & tokens
2
+
3
+ Create UI ships one unified styling system driven by semantic design tokens. Style with those tokens and each component's built-in props — never reach for raw Tailwind colors or hand-rolled class overrides.
4
+
5
+ See [customization.md](../customization.md) for theming, CSS variables, and adding custom colors.
6
+
7
+ ## Contents
8
+
9
+ - Semantic color tokens
10
+ - Status & state colors
11
+ - Built-in props first
12
+ - className for layout only
13
+ - Semantic spacing tokens
14
+ - No space-x-* / space-y-*
15
+ - Prefer size-* over w-* h-* when equal
16
+ - Prefer truncate shorthand
17
+ - No manual dark: color overrides
18
+ - Use cn() for conditional classes
19
+ - Focus uses outline-*, never ring-*
20
+ - No manual z-index on overlay components
21
+
22
+ ---
23
+
24
+ ## Semantic color tokens
25
+
26
+ Create UI's tokens are HEX-backed CSS variables that swap automatically between light and dark via the `.dark` class. Use the semantic token names — never raw palette colors and never invented utility names.
27
+
28
+ - Surfaces (weak → strong): `bg-weakest`, `bg-weak`, `bg-light`, `bg-medium`, `bg-heavy`, `bg-strong`, `bg-strongest`. Theme-swapping page/card surface: `bg-static`.
29
+ - Text: `text-body` (primary), `text-placeholder` (hints/secondary), `text-disabled`, `text-strongest` (high-contrast). Never-swap text: `text-static`, `text-static-white`.
30
+ - Borders: `border-weakest` … `border-strongest` (commonly `border-light` / `border-medium`).
31
+ - Primary scale: `bg-primary-500` (= `bg-primary-base`), `text-primary-base`, `bg-primary-alpha-16`, `bg-primary-alpha-48`.
32
+
33
+ **Incorrect:**
34
+
35
+ ```tsx
36
+ <div className="bg-blue-500 text-white">
37
+ <p className="text-gray-600">Secondary text</p>
38
+ </div>
39
+ ```
40
+
41
+ **Correct:**
42
+
43
+ ```tsx
44
+ <div className="bg-static text-body">
45
+ <p className="text-placeholder">Secondary text</p>
46
+ </div>
47
+ ```
48
+
49
+ Quick translation from generic utility names to Create UI tokens:
50
+
51
+ | Generic intent | Create UI token |
52
+ | --- | --- |
53
+ | page / card surface | `bg-static` (or `bg-weakest` for subtle surfaces) |
54
+ | primary text | `text-body` |
55
+ | secondary / muted text | `text-placeholder` |
56
+ | primary accent fill | `bg-primary-base` (or `bg-primary-500`) |
57
+ | text on a solid primary fill | `text-white` |
58
+ | default border | `border-light` or `border-medium` |
59
+ | subtle / muted fill | `bg-weak` |
60
+ | accent tint background | `bg-primary-alpha-16` |
61
+
62
+ ---
63
+
64
+ ## Status & state colors
65
+
66
+ Each status family (`error`, `success`, `warning`, `info`) exposes `-weakest` … `-strongest` plus `-base`. Prefer these semantic tokens — or a `StatusBadge` — for positive, negative, and informational indicators.
67
+
68
+ **Incorrect:**
69
+
70
+ ```tsx
71
+ <span className="text-emerald-600">Active</span>
72
+ <span className="text-red-700">Payment failed</span>
73
+ ```
74
+
75
+ **Correct:**
76
+
77
+ ```tsx
78
+ <span className="text-success-base">Active</span>
79
+ <span className="text-error-base">Payment failed</span>
80
+ ```
81
+
82
+ Create UI's own `Button` implements its `danger` / `success` variants with the raw red/green scales (`bg-red-600`, `bg-green-600`, `bg-red-alpha-16`), so those scales are acceptable for status work — but prefer the semantic token (`text-error-base`, `bg-success-base`) unless you are intentionally matching that variant's exact look. For full status affordances, reach for `StatusBadge` rather than styling a raw `<span>`.
83
+
84
+ ---
85
+
86
+ ## Built-in props first
87
+
88
+ Every primitive exposes its full visual range through typed props. Drive appearance through those props, not through manual `border` / `bg` / `hover:` class overrides.
89
+
90
+ `Button` has four styling axes (verify any other component by reading its source in `apps/v4/registry/ui/<name>.tsx`):
91
+
92
+ - `variant`: `primary` (default), `neutral-solid`, `neutral-light`, `danger`, `success`, `inverse-solid`, `inverse-light`
93
+ - `appearance`: `solid` (default), `outline`, `ghost`, `soft`
94
+ - `size`: `xs`, `sm`, `md`, `lg` (default), `xl`
95
+ - `shape`: `rounded` (default), `pill`, `square`
96
+
97
+ There is no `variant="outline"` / `variant="destructive"` / `variant="secondary"`. An outline style is `appearance="outline"`; a destructive button is `variant="danger"`; a ghost button is `appearance="ghost"`.
98
+
99
+ **Incorrect:**
100
+
101
+ ```tsx
102
+ <Button className="border border-medium bg-transparent hover:bg-weak">
103
+ Click me
104
+ </Button>
105
+ ```
106
+
107
+ **Correct:**
108
+
109
+ ```tsx
110
+ <Button appearance="outline">Click me</Button>
111
+ ```
112
+
113
+ `Button` also has a real `loading` prop — it renders a `Spinner` and blocks interaction automatically. Don't hand-compose a spinner.
114
+
115
+ **Incorrect:**
116
+
117
+ ```tsx
118
+ <Button disabled>
119
+ <Spinner /> Saving…
120
+ </Button>
121
+ ```
122
+
123
+ **Correct:**
124
+
125
+ ```tsx
126
+ <Button loading>Saving…</Button>
127
+ ```
128
+
129
+ ---
130
+
131
+ ## className for layout only
132
+
133
+ Use `className` for layout (e.g. `max-w-md`, `mx-auto`, `mt-4`), **not** for overriding component colors or typography. To change appearance, prefer these in order:
134
+
135
+ 1. **Built-in props** — `appearance="outline"`, `variant="danger"`, `size="sm"`, etc.
136
+ 2. **Semantic tokens** — `bg-static`, `text-placeholder`, `bg-primary-base`.
137
+ 3. **CSS variables** — define or override `--color-*` in the project's global CSS file (see [customization.md](../customization.md)).
138
+
139
+ **Incorrect:**
140
+
141
+ ```tsx
142
+ <Card className="bg-sky-100 text-sky-900 font-bold">
143
+ <CardContent>Dashboard</CardContent>
144
+ </Card>
145
+ ```
146
+
147
+ **Correct:**
148
+
149
+ ```tsx
150
+ <Card className="mx-auto max-w-md">
151
+ <CardContent>Dashboard</CardContent>
152
+ </Card>
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Semantic spacing tokens
158
+
159
+ Create UI mirrors Figma's spacing variables as Tailwind utilities: `gap-component-sm` (8px), `p-component-md` (12px), `gap-component-lg` (16px), `gap-layout-md` (64px), `p-layout-sm` (48px), and so on.
160
+
161
+ Use a semantic spacing class **only when Figma references that semantic token** (e.g. `var(--component/sm,8px)` → `gap-component-sm`). When Figma shows a static value (e.g. `space-space-4`), use the standard Tailwind class (`gap-4`). These tokens rescale across themes/breakpoints, so don't apply them where a fixed gap is intended, and never add `md:` / `xl:` prefixes to them — they auto-scale.
162
+
163
+ Prefer `px-component-none` over `px-0` when it is an intentional "no horizontal padding" override of a token, to keep the intent explicit.
164
+
165
+ ---
166
+
167
+ ## No space-x-* / space-y-*
168
+
169
+ Use `gap-*` instead. `space-y-4` → `flex flex-col gap-4`; `space-x-2` → `flex gap-2`.
170
+
171
+ ```tsx
172
+ <div className="flex flex-col gap-4">
173
+ <Input />
174
+ <Input />
175
+ <Button>Submit</Button>
176
+ </div>
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Prefer size-* over w-* h-* when equal
182
+
183
+ `size-10` not `w-10 h-10`. Applies to icons, avatars, skeletons, etc.
184
+
185
+ ---
186
+
187
+ ## Prefer truncate shorthand
188
+
189
+ `truncate` not `overflow-hidden text-ellipsis whitespace-nowrap`.
190
+
191
+ ---
192
+
193
+ ## No manual dark: color overrides
194
+
195
+ Semantic tokens already swap with the `.dark` class — don't write parallel `dark:` color utilities.
196
+
197
+ **Incorrect:**
198
+
199
+ ```tsx
200
+ <div className="bg-white text-gray-900 dark:bg-zinc-950 dark:text-zinc-50">
201
+ ```
202
+
203
+ **Correct:**
204
+
205
+ ```tsx
206
+ <div className="bg-static text-body">
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Use cn() for conditional classes
212
+
213
+ Use `cn()` for conditional or merged class names instead of template-string ternaries. Import it from `@/lib/utils` in a user project (in this monorepo, components import from `@/registry/lib/utils`).
214
+
215
+ **Incorrect:**
216
+
217
+ ```tsx
218
+ <div className={`flex items-center ${isActive ? "bg-primary-alpha-16 text-primary-base" : "bg-weak"}`}>
219
+ ```
220
+
221
+ **Correct:**
222
+
223
+ ```tsx
224
+ import { cn } from "@/lib/utils"
225
+
226
+ <div className={cn("flex items-center", isActive ? "bg-primary-alpha-16 text-primary-base" : "bg-weak")}>
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Focus uses outline-*, never ring-*
232
+
233
+ Create UI focus styling is built on `outline`, not `ring`. The base is `outline-2 outline-transparent`, and the visible focus state is an `outline` color.
234
+
235
+ **Incorrect:**
236
+
237
+ ```tsx
238
+ <button className="focus-visible:ring-2 focus-visible:ring-primary-500">
239
+ ```
240
+
241
+ **Correct:**
242
+
243
+ ```tsx
244
+ <button className="outline-2 outline-transparent focus-visible:outline-primary-700">
245
+ ```
246
+
247
+ Use `outline-primary-700` (or `outline-primary-500`) for primary controls and `outline-strong` / `outline-strongest` for neutral ones. Primitives already wire this up — you rarely need to set it yourself.
248
+
249
+ ---
250
+
251
+ ## No manual z-index on overlay components
252
+
253
+ `Dialog`, `Sheet`, `Drawer`, `AlertDialog`, `DropdownMenu`, `Popover`, `Tooltip`, and `HoverCard` manage their own stacking. Never add `z-50` or `z-[999]`.
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-VQCXAURP.js';import {X as X$1}from'../chunk-UPXNWTZZ.js';export{C as transformMenu}from'../chunk-UPXNWTZZ.js';import'../chunk-Y7WZRQWW.js';import J from'postcss';import M from'postcss-selector-parser';import {z as z$1}from'zod';import {Project,ScriptKind,SyntaxKind,Node}from'ts-morph';var A="cn-",V=z$1.record(z$1.string().startsWith(A),z$1.string());function v(t){let e=J.parse(t),r={};return e.walkRules(n=>{let s=n.selectors??[];if(s.length===0)return;let i=F(n);if(i)for(let g of s){let l=R(g);M(o=>{o.each(a=>{let f=$(a);if(!f)return;let u=f.value;u.startsWith(A)&&(r[u]=r[u]?`${i} ${r[u]}`:i);});}).processSync(l);}}),V.parse(r)}function R(t){return t.replace(/\s*&\s*/g,"").trim()}function F(t){let e=[];for(let r of t.nodes||[])if(r.type==="atrule"&&r.name==="apply"){let n=r.params.trim();n&&e.push(n);}return e.length===0?null:e.join(" ")}function $(t){let e=[];return t.walkClasses(r=>{r.value.startsWith(A)&&e.push(r);}),e.length===0?null:e[e.length-1]}var z=new Set(["cn-menu-target"]);function p(t){return Node.isStringLiteral(t)||Node.isNoSubstitutionTemplateLiteral(t)}var O=async({sourceFile:t,styleMap:e})=>{let r=new Set;return W(t,e,r),w(t,e,r),_(t,e,r),t};function E(t,e,r){let n=t.getLiteralText(),s=y(n);if(s.length===0)return;let i=s.filter(l=>!r.has(l));if(i.length===0){let l=m(n);t.setLiteralValue(l);return}let g=i.map(l=>e[l]).filter(l=>!!l);if(g.length>0){let l=g.join(" "),o=m(d(l,n));t.setLiteralValue(o),i.forEach(a=>r.add(a));}else {let l=m(n);t.setLiteralValue(l);}}function W(t,e,r){t.forEachDescendant(n=>{if(!Node.isCallExpression(n))return;let s=n.getExpression();if(!Node.isIdentifier(s)||s.getText()!=="cva")return;let i=n.getArguments()[0];Node.isStringLiteral(i)&&E(i,e,r);let g=n.getArguments()[1];if(!g||!Node.isObjectLiteralExpression(g))return;let l=g.getProperties().find(a=>Node.isPropertyAssignment(a)&&Node.isIdentifier(a.getNameNode())&&a.getNameNode().getText()==="variants");if(!l||!Node.isPropertyAssignment(l))return;let o=l.getInitializer();!o||!Node.isObjectLiteralExpression(o)||o.getProperties().forEach(a=>{if(!Node.isPropertyAssignment(a))return;let f=a.getInitializer();!f||!Node.isObjectLiteralExpression(f)||f.getProperties().forEach(u=>{if(!Node.isPropertyAssignment(u))return;let x=u.getInitializer();x&&Node.isStringLiteral(x)&&E(x,e,r);});});});}function w(t,e,r){t.forEachDescendant(n=>{if(!Node.isJsxAttribute(n)||n.getNameNode().getText()!=="className")return;let s=n.getInitializer();if(!s)return;let i=D(s);if(i.length===0)return;let g=n.getParent()?.getParent();if(!g||!Node.isJsxOpeningElement(g)&&!Node.isJsxSelfClosingElement(g))return;let l=i.filter(a=>!r.has(a));if(l.length===0){I(s);return}let o=l.map(a=>e[a]).filter(a=>!!a);if(o.length>0){let a=o.join(" ");B(g,a);}else I(s);});}function D(t){let e=[];if(p(t))return y(t.getLiteralText());if(!Node.isJsxExpression(t))return e;let r=t.getExpression();if(!r)return e;if(p(r))return y(r.getLiteralText());if(Node.isCallExpression(r)&&T(r))for(let n of r.getArguments())p(n)&&e.push(...y(n.getLiteralText()));return e}function I(t){if(p(t)){let r=m(t.getLiteralText());t.setLiteralValue(r);return}if(!Node.isJsxExpression(t))return;let e=t.getExpression();if(e){if(p(e)){let r=m(e.getLiteralText());e.setLiteralValue(r);return}if(Node.isCallExpression(e)&&T(e)){for(let r of e.getArguments())if(p(r)){let n=m(r.getLiteralText());r.setLiteralValue(n);}C(e);}}}function y(t){let e=t.matchAll(/\bcn-[\w-]+\b/g);return Array.from(e,r=>r[0])}function m(t){return t.replace(/\bcn-[\w-]+\b/g,e=>z.has(e)?e:"").replace(/\s+/g," ").trim()}function C(t){if(!T(t))return;let e=t.getArguments(),r=e.filter(n=>p(n)?n.getLiteralText().trim()!=="":true);if(r.length!==e.length){let n=r.map(i=>i.getText()),s=t.getParent();s&&Node.isJsxExpression(s)?s.replaceWithText(`{cn(${n.join(", ")})}`):t.replaceWithText(`cn(${n.join(", ")})`);}}function B(t,e){if(!Node.isJsxOpeningElement(t)&&!Node.isJsxSelfClosingElement(t))return;let r=t.getAttributes().find(i=>Node.isJsxAttribute(i)&&i.getNameNode().getText()==="className");if(!r||!Node.isJsxAttribute(r)){t.addAttribute({name:"className",initializer:`{cn(${JSON.stringify(e)})}`});return}let n=r.getInitializer();if(!n){r.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(p(n)){let i=n.getLiteralText(),g=m(d(e,i));n.setLiteralValue(g);return}if(!Node.isJsxExpression(n))return;let s=n.getExpression();if(!s){r.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(p(s)){let i=s.getLiteralText(),g=m(d(e,i));s.setLiteralValue(g);return}if(Node.isCallExpression(s)&&T(s)){let i=s.getArguments()[0];if(p(i)){let o=i.getLiteralText(),a=m(d(e,o));i.setLiteralValue(a);for(let f=1;f<s.getArguments().length;f++){let u=s.getArguments()[f];if(p(u)){let x=u.getLiteralText(),S=m(x);S!==x&&u.setLiteralValue(S);}}C(s);return}let g=s.getArguments().map(o=>{if(p(o)){let a=m(o.getLiteralText());return a?JSON.stringify(a):null}return o.getText()}).filter(o=>o!==null),l=[JSON.stringify(e),...g];r.setInitializer(`{cn(${l.join(", ")})}`);return}r.setInitializer(`{cn(${JSON.stringify(e)}, ${s.getText()})}`);}function d(t,e){let r=e.split(/\s+/).filter(Boolean);return [...t.split(/\s+/).filter(Boolean),...r].join(" ").trim()}function T(t){let e=t.getExpression();return Node.isIdentifier(e)&&e.getText()==="cn"}function _(t,e,r){t.forEachDescendant(n=>{if(!Node.isCallExpression(n))return;let s=n.getExpression();if(!(!Node.isIdentifier(s)||s.getText()!=="mergeProps"))for(let i of n.getArguments()){if(!Node.isObjectLiteralExpression(i))continue;let g=i.getProperties().find(o=>Node.isPropertyAssignment(o)&&Node.isIdentifier(o.getNameNode())&&o.getNameNode().getText()==="className");if(!g||!Node.isPropertyAssignment(g))continue;let l=g.getInitializer();if(l&&Node.isCallExpression(l)&&T(l)){let o=k(l);if(o.length===0)continue;let a=o.filter(u=>!r.has(u));if(a.length===0){b(l);continue}let f=a.map(u=>e[u]).filter(u=>!!u);if(f.length>0){let u=f.join(" ");K(l,u,r,a);}else b(l);}}});}function k(t){let e=[];for(let r of t.getArguments())p(r)&&e.push(...y(r.getLiteralText()));return e}function b(t){for(let e of t.getArguments())if(p(e)){let r=m(e.getLiteralText());e.setLiteralValue(r);}C(t);}function K(t,e,r,n){let s=t.getArguments()[0];if(p(s)){let o=s.getLiteralText(),a=m(d(e,o));s.setLiteralValue(a),n.forEach(f=>r.add(f));for(let f=1;f<t.getArguments().length;f++){let u=t.getArguments()[f];if(p(u)){let x=u.getLiteralText(),S=m(x);S!==x&&u.setLiteralValue(S);}}C(t);return}let i=t.getArguments().map(o=>{if(p(o)){let a=m(o.getLiteralText());return a?JSON.stringify(a):null}return o.getText()}).filter(o=>o!==null),g=[JSON.stringify(e),...i];n.forEach(o=>r.add(o)),t.getParent()&&t.replaceWithText(`cn(${g.join(", ")})`);}async function X(t,{styleMap:e,transformers:r=[O]}){let s=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",t,{scriptKind:ScriptKind.TSX,overwrite:true});for(let i of r)await i({sourceFile:s,styleMap:e});return s.getText()}var P="lucide",q=async({sourceFile:t,config:e})=>{if(!e.iconLibrary||!(e.iconLibrary in a))return t;let r=P,n=e.iconLibrary;if(r===n)return t;let s=await X$1(),i=[];for(let g of t.getImportDeclarations()??[])if(g.getModuleSpecifier()?.getText()===`"${a[P].import}"`){for(let l of g.getNamedImports()??[]){let o=l.getName(),a=s[o]?.[n];!a||i.includes(a)||(i.push(a),l.remove(),t.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).filter(f=>f.getTagNameNode()?.getText()===o).forEach(f=>f.getTagNameNode()?.replaceWithText(a)));}g.getNamedImports()?.length===0&&g.remove();}if(i.length>0){let g=t.addImportDeclaration({moduleSpecifier:a[n]?.import,namedImports:i.map(l=>({name:l}))});H(t)||g.replaceWithText(g.getText().replace(";",""));}return t};function H(t){return t.getImportDeclarations()?.[0]?.getText().endsWith(";")??false}export{v as createStyleMap,q as transformIcons,X as transformStyle};//# sourceMappingURL=index.js.map
1
+ import {a}from'../chunk-VQCXAURP.js';import {W as W$1}from'../chunk-EWAP55CF.js';export{B as transformMenu}from'../chunk-EWAP55CF.js';import'../chunk-Y7WZRQWW.js';import J from'postcss';import M from'postcss-selector-parser';import {z as z$1}from'zod';import {Project,ScriptKind,SyntaxKind,Node}from'ts-morph';var A="cn-",V=z$1.record(z$1.string().startsWith(A),z$1.string());function v(t){let e=J.parse(t),r={};return e.walkRules(n=>{let s=n.selectors??[];if(s.length===0)return;let i=F(n);if(i)for(let g of s){let l=R(g);M(o=>{o.each(a=>{let f=$(a);if(!f)return;let u=f.value;u.startsWith(A)&&(r[u]=r[u]?`${i} ${r[u]}`:i);});}).processSync(l);}}),V.parse(r)}function R(t){return t.replace(/\s*&\s*/g,"").trim()}function F(t){let e=[];for(let r of t.nodes||[])if(r.type==="atrule"&&r.name==="apply"){let n=r.params.trim();n&&e.push(n);}return e.length===0?null:e.join(" ")}function $(t){let e=[];return t.walkClasses(r=>{r.value.startsWith(A)&&e.push(r);}),e.length===0?null:e[e.length-1]}var z=new Set(["cn-menu-target"]);function p(t){return Node.isStringLiteral(t)||Node.isNoSubstitutionTemplateLiteral(t)}var O=async({sourceFile:t,styleMap:e})=>{let r=new Set;return W(t,e,r),w(t,e,r),_(t,e,r),t};function E(t,e,r){let n=t.getLiteralText(),s=y(n);if(s.length===0)return;let i=s.filter(l=>!r.has(l));if(i.length===0){let l=m(n);t.setLiteralValue(l);return}let g=i.map(l=>e[l]).filter(l=>!!l);if(g.length>0){let l=g.join(" "),o=m(d(l,n));t.setLiteralValue(o),i.forEach(a=>r.add(a));}else {let l=m(n);t.setLiteralValue(l);}}function W(t,e,r){t.forEachDescendant(n=>{if(!Node.isCallExpression(n))return;let s=n.getExpression();if(!Node.isIdentifier(s)||s.getText()!=="cva")return;let i=n.getArguments()[0];Node.isStringLiteral(i)&&E(i,e,r);let g=n.getArguments()[1];if(!g||!Node.isObjectLiteralExpression(g))return;let l=g.getProperties().find(a=>Node.isPropertyAssignment(a)&&Node.isIdentifier(a.getNameNode())&&a.getNameNode().getText()==="variants");if(!l||!Node.isPropertyAssignment(l))return;let o=l.getInitializer();!o||!Node.isObjectLiteralExpression(o)||o.getProperties().forEach(a=>{if(!Node.isPropertyAssignment(a))return;let f=a.getInitializer();!f||!Node.isObjectLiteralExpression(f)||f.getProperties().forEach(u=>{if(!Node.isPropertyAssignment(u))return;let x=u.getInitializer();x&&Node.isStringLiteral(x)&&E(x,e,r);});});});}function w(t,e,r){t.forEachDescendant(n=>{if(!Node.isJsxAttribute(n)||n.getNameNode().getText()!=="className")return;let s=n.getInitializer();if(!s)return;let i=D(s);if(i.length===0)return;let g=n.getParent()?.getParent();if(!g||!Node.isJsxOpeningElement(g)&&!Node.isJsxSelfClosingElement(g))return;let l=i.filter(a=>!r.has(a));if(l.length===0){I(s);return}let o=l.map(a=>e[a]).filter(a=>!!a);if(o.length>0){let a=o.join(" ");B(g,a);}else I(s);});}function D(t){let e=[];if(p(t))return y(t.getLiteralText());if(!Node.isJsxExpression(t))return e;let r=t.getExpression();if(!r)return e;if(p(r))return y(r.getLiteralText());if(Node.isCallExpression(r)&&T(r))for(let n of r.getArguments())p(n)&&e.push(...y(n.getLiteralText()));return e}function I(t){if(p(t)){let r=m(t.getLiteralText());t.setLiteralValue(r);return}if(!Node.isJsxExpression(t))return;let e=t.getExpression();if(e){if(p(e)){let r=m(e.getLiteralText());e.setLiteralValue(r);return}if(Node.isCallExpression(e)&&T(e)){for(let r of e.getArguments())if(p(r)){let n=m(r.getLiteralText());r.setLiteralValue(n);}C(e);}}}function y(t){let e=t.matchAll(/\bcn-[\w-]+\b/g);return Array.from(e,r=>r[0])}function m(t){return t.replace(/\bcn-[\w-]+\b/g,e=>z.has(e)?e:"").replace(/\s+/g," ").trim()}function C(t){if(!T(t))return;let e=t.getArguments(),r=e.filter(n=>p(n)?n.getLiteralText().trim()!=="":true);if(r.length!==e.length){let n=r.map(i=>i.getText()),s=t.getParent();s&&Node.isJsxExpression(s)?s.replaceWithText(`{cn(${n.join(", ")})}`):t.replaceWithText(`cn(${n.join(", ")})`);}}function B(t,e){if(!Node.isJsxOpeningElement(t)&&!Node.isJsxSelfClosingElement(t))return;let r=t.getAttributes().find(i=>Node.isJsxAttribute(i)&&i.getNameNode().getText()==="className");if(!r||!Node.isJsxAttribute(r)){t.addAttribute({name:"className",initializer:`{cn(${JSON.stringify(e)})}`});return}let n=r.getInitializer();if(!n){r.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(p(n)){let i=n.getLiteralText(),g=m(d(e,i));n.setLiteralValue(g);return}if(!Node.isJsxExpression(n))return;let s=n.getExpression();if(!s){r.setInitializer(`{cn(${JSON.stringify(e)})}`);return}if(p(s)){let i=s.getLiteralText(),g=m(d(e,i));s.setLiteralValue(g);return}if(Node.isCallExpression(s)&&T(s)){let i=s.getArguments()[0];if(p(i)){let o=i.getLiteralText(),a=m(d(e,o));i.setLiteralValue(a);for(let f=1;f<s.getArguments().length;f++){let u=s.getArguments()[f];if(p(u)){let x=u.getLiteralText(),S=m(x);S!==x&&u.setLiteralValue(S);}}C(s);return}let g=s.getArguments().map(o=>{if(p(o)){let a=m(o.getLiteralText());return a?JSON.stringify(a):null}return o.getText()}).filter(o=>o!==null),l=[JSON.stringify(e),...g];r.setInitializer(`{cn(${l.join(", ")})}`);return}r.setInitializer(`{cn(${JSON.stringify(e)}, ${s.getText()})}`);}function d(t,e){let r=e.split(/\s+/).filter(Boolean);return [...t.split(/\s+/).filter(Boolean),...r].join(" ").trim()}function T(t){let e=t.getExpression();return Node.isIdentifier(e)&&e.getText()==="cn"}function _(t,e,r){t.forEachDescendant(n=>{if(!Node.isCallExpression(n))return;let s=n.getExpression();if(!(!Node.isIdentifier(s)||s.getText()!=="mergeProps"))for(let i of n.getArguments()){if(!Node.isObjectLiteralExpression(i))continue;let g=i.getProperties().find(o=>Node.isPropertyAssignment(o)&&Node.isIdentifier(o.getNameNode())&&o.getNameNode().getText()==="className");if(!g||!Node.isPropertyAssignment(g))continue;let l=g.getInitializer();if(l&&Node.isCallExpression(l)&&T(l)){let o=k(l);if(o.length===0)continue;let a=o.filter(u=>!r.has(u));if(a.length===0){b(l);continue}let f=a.map(u=>e[u]).filter(u=>!!u);if(f.length>0){let u=f.join(" ");K(l,u,r,a);}else b(l);}}});}function k(t){let e=[];for(let r of t.getArguments())p(r)&&e.push(...y(r.getLiteralText()));return e}function b(t){for(let e of t.getArguments())if(p(e)){let r=m(e.getLiteralText());e.setLiteralValue(r);}C(t);}function K(t,e,r,n){let s=t.getArguments()[0];if(p(s)){let o=s.getLiteralText(),a=m(d(e,o));s.setLiteralValue(a),n.forEach(f=>r.add(f));for(let f=1;f<t.getArguments().length;f++){let u=t.getArguments()[f];if(p(u)){let x=u.getLiteralText(),S=m(x);S!==x&&u.setLiteralValue(S);}}C(t);return}let i=t.getArguments().map(o=>{if(p(o)){let a=m(o.getLiteralText());return a?JSON.stringify(a):null}return o.getText()}).filter(o=>o!==null),g=[JSON.stringify(e),...i];n.forEach(o=>r.add(o)),t.getParent()&&t.replaceWithText(`cn(${g.join(", ")})`);}async function X(t,{styleMap:e,transformers:r=[O]}){let s=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",t,{scriptKind:ScriptKind.TSX,overwrite:true});for(let i of r)await i({sourceFile:s,styleMap:e});return s.getText()}var P="lucide",q=async({sourceFile:t,config:e})=>{if(!e.iconLibrary||!(e.iconLibrary in a))return t;let r=P,n=e.iconLibrary;if(r===n)return t;let s=await W$1(),i=[];for(let g of t.getImportDeclarations()??[])if(g.getModuleSpecifier()?.getText()===`"${a[P].import}"`){for(let l of g.getNamedImports()??[]){let o=l.getName(),a=s[o]?.[n];!a||i.includes(a)||(i.push(a),l.remove(),t.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).filter(f=>f.getTagNameNode()?.getText()===o).forEach(f=>f.getTagNameNode()?.replaceWithText(a)));}g.getNamedImports()?.length===0&&g.remove();}if(i.length>0){let g=t.addImportDeclaration({moduleSpecifier:a[n]?.import,namedImports:i.map(l=>({name:l}))});H(t)||g.replaceWithText(g.getText().replace(";",""));}return t};function H(t){return t.getImportDeclarations()?.[0]?.getText().endsWith(";")??false}export{v as createStyleMap,q as transformIcons,X as transformStyle};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@create-ui/cli",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.5.0",
4
4
  "description": "Add components to your apps.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,7 +10,7 @@
10
10
  "name": "createui",
11
11
  "url": "https://twitter.com/createui"
12
12
  },
13
- "homepage": "https://dev.createui.co",
13
+ "homepage": "https://createui.co",
14
14
  "files": [
15
15
  "dist"
16
16
  ],
@@ -74,6 +74,7 @@
74
74
  "fs-extra": "^11.3.1",
75
75
  "fuzzysort": "^3.1.0",
76
76
  "https-proxy-agent": "^7.0.6",
77
+ "jsonc-parser": "^3.3.1",
77
78
  "kleur": "^4.1.5",
78
79
  "msw": "^2.10.4",
79
80
  "node-fetch": "^3.3.2",
@@ -106,7 +107,7 @@
106
107
  "typecheck": "tsc --noEmit",
107
108
  "clean": "rimraf dist && rimraf components",
108
109
  "start:dev": "cross-env REGISTRY_URL=http://localhost:4000/r node dist/index.js",
109
- "start:prod": "cross-env REGISTRY_URL=https://dev.createui.co/r node dist/index.js",
110
+ "start:prod": "cross-env REGISTRY_URL=https://createui.co/r node dist/index.js",
110
111
  "start": "node dist/index.js",
111
112
  "format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
112
113
  "format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/get-package-manager.ts","../src/mcp/utils.ts","../src/mcp/index.ts"],"names":["getPackageManager","targetDir","withFallback","packageManager","detect","userAgent","getPackageRunner","cwd","createui_CLI_COMMAND","npxcreateui","command","normalizeRegistryItemName","item","getMcpConfig","config","getConfig","configWithDefaults","formatSearchResultsWithPagination","results","options","query","registries","formattedItems","parts","header","showingRange","output","formatRegistryItems","items","formatItemExamples","sections","file","server","Server","ListToolsRequestSchema","zodToJsonSchema","z","CallToolRequestSchema","request","dedent","args","searchRegistries","registryItems","getRegistryItems","itemNames","fullItems","error","e","RegistryError","errorMessage"],"mappings":"4WAEA,eAAsBA,CAAAA,CACpBC,CAAAA,CACA,CAAE,YAAA,CAAAC,CAAa,CAAA,CAAgC,CAC7C,YAAA,CAAc,KAChB,CAAA,CACmD,CACnD,IAAMC,CAAAA,CAAiB,MAAMC,MAAAA,CAAO,CAAE,YAAA,CAAc,IAAA,CAAM,GAAA,CAAKH,CAAU,CAAC,CAAA,CAE1E,GAAIE,CAAAA,GAAmB,YAAA,CAAc,OAAO,MA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,CAAAA,CAAM,OAAA,CAAU,OAAOA,CAAK,CAAA,CAC1E,OAAO,CACL,OAAA,CAAS,CACP,CACE,IAAA,CAAM,MAAA,CACN,IAAA,CAAMP,CAAAA,CAAAA,OAAAA,EAAgBU,CAAY,CAAA,CACpC,CACF,CAAA,CACA,OAAA,CAAS,IACX,CACF,CACF,CAAC,CAAA","file":"chunk-HRI6QVOR.js","sourcesContent":["import { detect } from \"@antfu/ni\"\n\nexport async function getPackageManager(\n targetDir: string,\n { withFallback }: { withFallback?: boolean } = {\n withFallback: false,\n }\n): Promise<\"yarn\" | \"pnpm\" | \"bun\" | \"npm\" | \"deno\"> {\n const packageManager = await detect({ programmatic: true, cwd: targetDir })\n\n if (packageManager === \"yarn@berry\") return \"yarn\"\n if (packageManager === \"pnpm@6\") return \"pnpm\"\n if (packageManager === \"bun\") return \"bun\"\n if (packageManager === \"deno\") return \"deno\"\n if (!withFallback) {\n return packageManager ?? \"npm\"\n }\n\n // Fallback to user agent if not detected.\n const userAgent = process.env.npm_config_user_agent || \"\"\n\n if (userAgent.startsWith(\"yarn\")) {\n return \"yarn\"\n }\n\n if (userAgent.startsWith(\"pnpm\")) {\n return \"pnpm\"\n }\n\n if (userAgent.startsWith(\"bun\")) {\n return \"bun\"\n }\n\n return \"npm\"\n}\n\nexport async function getPackageRunner(cwd: string) {\n const packageManager = await getPackageManager(cwd)\n\n if (packageManager === \"pnpm\") return \"pnpm dlx\"\n\n if (packageManager === \"bun\") return \"bunx\"\n\n return \"npx\"\n}\n","import { configWithDefaults } from \"@/src/registry/config\"\nimport { registryItemSchema, searchResultsSchema } from \"@/src/schema\"\nimport { getConfig } from \"@/src/utils/get-config\"\nimport { getPackageRunner } from \"@/src/utils/get-package-manager\"\nimport { z } from \"zod\"\n\nconst createui_CLI_COMMAND = \"@create-ui/cli@beta\"\n\nexport async function npxcreateui(command: string) {\n const packageRunner = await getPackageRunner(process.cwd())\n return `${packageRunner} ${createui_CLI_COMMAND} ${command}`\n}\n\n// Single-provider: items resolve by bare name (e.g. \"button\"). The MCP tools\n// historically accepted a \"@registry/item\" convention, so strip an optional\n// leading \"@registry/\" prefix. URLs and local file paths are returned untouched.\nexport function normalizeRegistryItemName(item: string) {\n if (item.startsWith(\"@\") && item.includes(\"/\")) {\n return item.slice(item.indexOf(\"/\") + 1)\n }\n\n return item\n}\n\nexport async function getMcpConfig(cwd = process.cwd()) {\n try {\n const config = await getConfig(cwd)\n if (config) {\n return config\n }\n } catch {\n // Fall back to defaults when components.json is missing or invalid.\n }\n\n return configWithDefaults({})\n}\n\nexport async function formatSearchResultsWithPagination(\n results: z.infer<typeof searchResultsSchema>,\n options?: {\n query?: string\n registries?: string[]\n }\n) {\n const { query, registries } = options || {}\n\n const formattedItems = await Promise.all(\n results.items.map(async (item) => {\n const parts: string[] = [`- ${item.name}`]\n\n if (item.type) {\n parts.push(`(${item.type})`)\n }\n\n if (item.description) {\n parts.push(`- ${item.description}`)\n }\n\n if (item.registry) {\n parts.push(`[${item.registry}]`)\n }\n\n parts.push(\n `\\n Add command: \\`${await npxcreateui(\n `add ${item.addCommandArgument}`\n )}\\``\n )\n\n return parts.join(\" \")\n })\n )\n\n let header = `Found ${results.pagination.total} items`\n if (query) {\n header += ` matching \"${query}\"`\n }\n if (registries && registries.length > 0) {\n header += ` in registries ${registries.join(\", \")}`\n }\n header += \":\"\n\n const showingRange = `Showing items ${\n results.pagination.offset + 1\n }-${Math.min(\n results.pagination.offset + results.pagination.limit,\n results.pagination.total\n )} of ${results.pagination.total}:`\n\n let output = `${header}\\n\\n${showingRange}\\n\\n${formattedItems.join(\"\\n\\n\")}`\n\n if (results.pagination.hasMore) {\n output += `\\n\\nMore items available. Use offset: ${\n results.pagination.offset + results.pagination.limit\n } to see the next page.`\n }\n\n return output\n}\n\nexport function formatRegistryItems(\n items: z.infer<typeof registryItemSchema>[]\n) {\n return items.map((item) => {\n const parts: string[] = [\n `## ${item.name}`,\n item.description ? `\\n${item.description}\\n` : \"\",\n item.type ? `**Type:** ${item.type}` : \"\",\n item.files && item.files.length > 0\n ? `**Files:** ${item.files.length} file(s)`\n : \"\",\n item.dependencies && item.dependencies.length > 0\n ? `**Dependencies:** ${item.dependencies.join(\", \")}`\n : \"\",\n item.devDependencies && item.devDependencies.length > 0\n ? `**Dev Dependencies:** ${item.devDependencies.join(\", \")}`\n : \"\",\n ]\n return parts.filter(Boolean).join(\"\\n\")\n })\n}\n\nexport function formatItemExamples(\n items: z.infer<typeof registryItemSchema>[],\n query: string\n) {\n const sections = items.map((item) => {\n const parts: string[] = [\n `## Example: ${item.name}`,\n item.description ? `\\n${item.description}\\n` : \"\",\n ]\n\n if (item.files?.length) {\n item.files.forEach((file) => {\n if (file.content) {\n parts.push(`### Code (${file.path}):\\n`)\n parts.push(\"```tsx\")\n parts.push(file.content)\n parts.push(\"```\")\n }\n })\n }\n\n return parts.filter(Boolean).join(\"\\n\")\n })\n\n const header = `# Usage Examples\\n\\nFound ${items.length} example${\n items.length > 1 ? \"s\" : \"\"\n } matching \"${query}\":\\n`\n\n return header + sections.join(\"\\n\\n---\\n\\n\")\n}\n","import { getRegistryItems, searchRegistries } from \"@/src/registry\"\nimport { RegistryError } from \"@/src/registry/errors\"\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\"\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\"\nimport dedent from \"dedent\"\nimport { z } from \"zod\"\nimport { zodToJsonSchema } from \"zod-to-json-schema\"\n\nimport {\n formatItemExamples,\n formatRegistryItems,\n formatSearchResultsWithPagination,\n getMcpConfig,\n normalizeRegistryItemName,\n npxcreateui,\n} from \"./utils\"\n\nexport const server = new Server(\n {\n name: \"createui\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n resources: {},\n tools: {},\n },\n }\n)\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"get_project_registries\",\n description:\n \"Get the registry used by this project. createui uses a single built-in @createui registry.\",\n inputSchema: zodToJsonSchema(z.object({})),\n },\n {\n name: \"list_items_in_registries\",\n description:\n \"List items from registries (requires components.json - use init_project if missing)\",\n inputSchema: zodToJsonSchema(\n z.object({\n registries: z\n .array(z.string())\n .describe(\n \"Array of registry names to search (e.g., ['@createui', '@acme'])\"\n ),\n limit: z\n .number()\n .optional()\n .describe(\"Maximum number of items to return\"),\n offset: z\n .number()\n .optional()\n .describe(\"Number of items to skip for pagination\"),\n })\n ),\n },\n {\n name: \"search_items_in_registries\",\n description:\n \"Search for components in registries using fuzzy matching (requires components.json). After finding an item, use get_item_examples_from_registries to see usage examples.\",\n inputSchema: zodToJsonSchema(\n z.object({\n registries: z\n .array(z.string())\n .describe(\n \"Array of registry names to search (e.g., ['@createui', '@acme'])\"\n ),\n query: z\n .string()\n .describe(\n \"Search query string for fuzzy matching against item names and descriptions\"\n ),\n limit: z\n .number()\n .optional()\n .describe(\"Maximum number of items to return\"),\n offset: z\n .number()\n .optional()\n .describe(\"Number of items to skip for pagination\"),\n })\n ),\n },\n {\n name: \"view_items_in_registries\",\n description:\n \"View detailed information about specific registry items including the name, description, type and files content. For usage examples, use get_item_examples_from_registries instead.\",\n inputSchema: zodToJsonSchema(\n z.object({\n items: z\n .array(z.string())\n .describe(\n \"Array of item names (e.g., ['button', 'card']). A '@createui/' prefix is also accepted.\"\n ),\n })\n ),\n },\n {\n name: \"get_item_examples_from_registries\",\n description:\n \"Find usage examples and demos with their complete code. Search for patterns like 'accordion-demo', 'button example', 'card-demo', etc. Returns full implementation code with dependencies.\",\n inputSchema: zodToJsonSchema(\n z.object({\n registries: z\n .array(z.string())\n .describe(\n \"Array of registry names to search (e.g., ['@createui', '@acme'])\"\n ),\n query: z\n .string()\n .describe(\n \"Search query for examples (e.g., 'accordion-demo', 'button demo', 'card example', 'tooltip-demo', 'example-booking-form', 'example-hero'). Common patterns: '{item-name}-demo', '{item-name} example', 'example {item-name}'\"\n ),\n })\n ),\n },\n {\n name: \"get_add_command_for_items\",\n description:\n \"Get the createui CLI add command for specific items in a registry. This is useful for adding one or more components to your project.\",\n inputSchema: zodToJsonSchema(\n z.object({\n items: z\n .array(z.string())\n .describe(\n \"Array of items to get the add command for (e.g., ['button', 'card']). A '@createui/' prefix is also accepted.\"\n ),\n })\n ),\n },\n {\n name: \"get_audit_checklist\",\n description:\n \"After creating new components or generating new code files, use this tool for a quick checklist to verify that everything is working as expected. Make sure to run the tool after all required steps have been completed.\",\n inputSchema: zodToJsonSchema(z.object({})),\n },\n ],\n }\n})\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n try {\n if (!request.params.arguments) {\n throw new Error(\"No tool arguments provided.\")\n }\n\n switch (request.params.name) {\n case \"get_project_registries\": {\n return {\n content: [\n {\n type: \"text\",\n text: dedent`This project uses the built-in \\`@createui\\` registry.\n\n You can view an item by running:\n \\`${await npxcreateui(\"view <item-name>\")}\\`\n\n For example: \\`${await npxcreateui(\"view button\")}\\`.`,\n },\n ],\n }\n }\n\n case \"search_items_in_registries\": {\n const inputSchema = z.object({\n registries: z.array(z.string()),\n query: z.string(),\n limit: z.number().optional(),\n offset: z.number().optional(),\n })\n\n const args = inputSchema.parse(request.params.arguments)\n const results = await searchRegistries(args.registries, {\n query: args.query,\n limit: args.limit,\n offset: args.offset,\n config: await getMcpConfig(process.cwd()),\n useCache: false,\n })\n\n if (results.items.length === 0) {\n return {\n content: [\n {\n type: \"text\",\n text: dedent`No items found matching \"${\n args.query\n }\" in registries ${args.registries.join(\n \", \"\n )}, Try searching with a different query or registry.`,\n },\n ],\n }\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: await formatSearchResultsWithPagination(results, {\n query: args.query,\n registries: args.registries,\n }),\n },\n ],\n }\n }\n\n case \"list_items_in_registries\": {\n const inputSchema = z.object({\n registries: z.array(z.string()),\n limit: z.number().optional(),\n offset: z.number().optional(),\n cwd: z.string().optional(),\n })\n\n const args = inputSchema.parse(request.params.arguments)\n const results = await searchRegistries(args.registries, {\n limit: args.limit,\n offset: args.offset,\n config: await getMcpConfig(process.cwd()),\n useCache: false,\n })\n\n if (results.items.length === 0) {\n return {\n content: [\n {\n type: \"text\",\n text: dedent`No items found in registries ${args.registries.join(\n \", \"\n )}.`,\n },\n ],\n }\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: await formatSearchResultsWithPagination(results, {\n registries: args.registries,\n }),\n },\n ],\n }\n }\n\n case \"view_items_in_registries\": {\n const inputSchema = z.object({\n items: z.array(z.string()),\n })\n\n const args = inputSchema.parse(request.params.arguments)\n const registryItems = await getRegistryItems(\n args.items.map(normalizeRegistryItemName),\n {\n config: await getMcpConfig(process.cwd()),\n useCache: false,\n }\n )\n\n if (registryItems?.length === 0) {\n return {\n content: [\n {\n type: \"text\",\n text: dedent`No items found for: ${args.items.join(\", \")}\n\n Make sure the item names are correct (e.g., button, card).`,\n },\n ],\n }\n }\n\n const formattedItems = formatRegistryItems(registryItems)\n\n return {\n content: [\n {\n type: \"text\",\n text: dedent`Item Details:\n\n ${formattedItems.join(\"\\n\\n---\\n\\n\")}`,\n },\n ],\n }\n }\n\n case \"get_item_examples_from_registries\": {\n const inputSchema = z.object({\n query: z.string(),\n registries: z.array(z.string()),\n })\n\n const args = inputSchema.parse(request.params.arguments)\n const config = await getMcpConfig()\n\n const results = await searchRegistries(args.registries, {\n query: args.query,\n config,\n useCache: false,\n })\n\n if (results.items.length === 0) {\n return {\n content: [\n {\n type: \"text\",\n text: dedent`No examples found for query \"${args.query}\".\n\n Try searching with patterns like:\n - \"accordion-demo\" for accordion examples\n - \"button demo\" or \"button example\"\n - Component name followed by \"-demo\" or \"example\"\n\n You can also:\n 1. Use search_items_in_registries to find all items matching your query\n 2. View the main component with view_items_in_registries for inline usage documentation`,\n },\n ],\n }\n }\n\n const itemNames = results.items.map((item) => item.addCommandArgument)\n const fullItems = await getRegistryItems(itemNames, {\n config,\n useCache: false,\n })\n\n return {\n content: [\n {\n type: \"text\",\n text: formatItemExamples(fullItems, args.query),\n },\n ],\n }\n }\n\n case \"get_add_command_for_items\": {\n const args = z\n .object({\n items: z.array(z.string()),\n })\n .parse(request.params.arguments)\n\n return {\n content: [\n {\n type: \"text\",\n text: await npxcreateui(\n `add ${args.items.map(normalizeRegistryItemName).join(\" \")}`\n ),\n },\n ],\n }\n }\n\n case \"get_audit_checklist\": {\n return {\n content: [\n {\n type: \"text\",\n text: dedent`## Component Audit Checklist\n\n After adding or generating components, check the following common issues:\n\n - [ ] Ensure imports are correct i.e named vs default imports\n - [ ] If using next/image, ensure images.remotePatterns next.config.js is configured correctly.\n - [ ] Ensure all dependencies are installed.\n - [ ] Check for linting errors or warnings\n - [ ] Check for TypeScript errors\n - [ ] Use the Playwright MCP if available.\n `,\n },\n ],\n }\n }\n\n default:\n throw new Error(`Tool ${request.params.name} not found`)\n }\n } catch (error) {\n if (error instanceof z.ZodError) {\n return {\n content: [\n {\n type: \"text\",\n text: dedent`Invalid input parameters:\n ${error.errors\n .map((e) => `- ${e.path.join(\".\")}: ${e.message}`)\n .join(\"\\n\")}\n `,\n },\n ],\n isError: true,\n }\n }\n\n if (error instanceof RegistryError) {\n let errorMessage = error.message\n\n if (error.suggestion) {\n errorMessage += `\\n\\n💡 ${error.suggestion}`\n }\n\n if (error.context) {\n errorMessage += `\\n\\nContext: ${JSON.stringify(error.context, null, 2)}`\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: dedent`Error (${error.code}): ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n\n const errorMessage = error instanceof Error ? error.message : String(error)\n return {\n content: [\n {\n type: \"text\",\n text: dedent`Error: ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"]}
@@ -1,3 +0,0 @@
1
- import {S}from'./chunk-UPXNWTZZ.js';import {u}from'./chunk-Y7WZRQWW.js';import R from'fuzzysort';import {z as z$1}from'zod';async function I(r,t){let{query:a,limit:n,offset:g,useCache:i}=t||{},e=[];for(let u of r){let y=((await S(u,{useCache:i})).items||[]).map(l=>({name:l.name,type:l.type,description:l.description,registry:u,addCommandArgument:E(l.name,u)}));e=e.concat(y);}a&&(e=z(e,{query:a,limit:e.length,keys:["name","description"]}));let s=g||0,m=n||e.length,c=e.length,f={pagination:{total:c,offset:s,limit:m,hasMore:s+m<c},items:e.slice(s,s+m)};return u.parse(f)}var x=z$1.object({name:z$1.string(),type:z$1.string().optional(),description:z$1.string().optional(),registry:z$1.string().optional(),addCommandArgument:z$1.string().optional()}).passthrough();function z(r,t){t={limit:100,threshold:-1e4,...t};let n=R.go(t.query,r,{keys:t.keys,threshold:t.threshold,limit:t.limit}).map(g=>g.obj);return z$1.array(x).parse(n)}function A(r){try{return new URL(r),!0}catch{return false}}function E(r,t){if(!A(t))return r;let a=t.indexOf("://")+3,n=t.indexOf("/",a);if(n===-1){let h=t.indexOf("?",a);if(h!==-1){let y=t.substring(0,h),b=t.substring(h).replace(/\bregistry\b/g,r);return y+b}return t}let g=t.substring(0,n),i=t.substring(n),e=i.indexOf("?")!==-1?i.indexOf("?"):i.length,s=i.substring(0,e),m=i.substring(e),c=s.lastIndexOf("registry"),f=s;c!==-1&&(f=s.substring(0,c)+r+s.substring(c+8));let u=m.replace(/\bregistry\b/g,r);return g+f+u}
2
- export{I as a};//# sourceMappingURL=chunk-RJOEUUDA.js.map
3
- //# sourceMappingURL=chunk-RJOEUUDA.js.map