shadcn 4.21.4 → 4.21.5
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.
- package/dist/chunk-NNHTPP2Z.js +75 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.js +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/tailwind.d.ts +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-SILUCKGE.js +0 -75
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';import {searchRegistries,getRegistryItems}from'@shadcn/registry';import {withRegistryContext}from'@shadcn/registry/internal/registry/context';import {RegistryError}from'@shadcn/registry/internal/registry/errors';import {SEARCHABLE_TYPES,resolveSearchRegistries,findUnknownSearchTypes}from'@shadcn/registry/internal/registry/search';import c from'dedent';import {z as z$1}from'zod';import {zodToJsonSchema}from'zod-to-json-schema';import {getPackageRunner}from'@shadcn/registry/internal/get-package-manager';import {getRegistriesConfig}from'@shadcn/registry/internal/registry/api';var A="shadcn@latest";async function u(n){return `${await getPackageRunner(process.cwd())} ${A} ${n}`}async function d(n=process.cwd()){return {registries:(await getRegistriesConfig(n,{useCache:false})).registries}}async function h(n,t){let{query:r,registries:i}=t||{},o=await u("add"),a=n.items.map(g=>{let l=[`- ${g.name}`];return g.type&&l.push(`(${g.type})`),g.description&&l.push(`- ${g.description}`),g.registry&&l.push(`[${g.registry}]`),l.push(`
|
|
2
|
+
Add command: \`${o} ${g.addCommandArgument}\``),l.join(" ")}),s=`Found ${n.pagination.total} items`;r&&(s+=` matching "${r}"`),i&&i.length>0&&(s+=` in registries ${i.join(", ")}`),s+=":";let m=`Showing items ${n.pagination.offset+1}-${Math.min(n.pagination.offset+n.pagination.limit,n.pagination.total)} of ${n.pagination.total}:`,p=`${s}
|
|
3
|
+
|
|
4
|
+
${m}
|
|
5
|
+
|
|
6
|
+
${a.join(`
|
|
7
|
+
|
|
8
|
+
`)}`;return n.pagination.hasMore&&(p+=`
|
|
9
|
+
|
|
10
|
+
More items available. Use offset: ${n.pagination.offset+n.pagination.limit} to see the next page.`),p}function y(n){if(!n?.length)return null;let t=findUnknownSearchTypes(n);return t.length===0?null:`Unknown type${t.length===1?"":"s"}: ${t.join(", ")}. Valid types: ${SEARCHABLE_TYPES.join(", ")}.`}function x(n){if(!n.errors?.length)return "";let t=n.errors.map(r=>`- ${r.registry}: ${r.message}`);return `
|
|
11
|
+
|
|
12
|
+
Skipped ${n.errors.length} registr${n.errors.length===1?"y":"ies"} that failed to load:
|
|
13
|
+
${t.join(`
|
|
14
|
+
`)}`}function j(n){return n.map(t=>[`## ${t.name}`,t.description?`
|
|
15
|
+
${t.description}
|
|
16
|
+
`:"",t.type?`**Type:** ${t.type}`:"",t.files&&t.files.length>0?`**Files:** ${t.files.length} file(s)`:"",t.dependencies&&t.dependencies.length>0?`**Dependencies:** ${t.dependencies.join(", ")}`:"",t.devDependencies&&t.devDependencies.length>0?`**Dev Dependencies:** ${t.devDependencies.join(", ")}`:""].filter(Boolean).join(`
|
|
17
|
+
`))}function b(n,t){let r=n.map(o=>{let a=[`## Example: ${o.name}`,o.description?`
|
|
18
|
+
${o.description}
|
|
19
|
+
`:""];return o.files?.length&&o.files.forEach(s=>{s.content&&(a.push(`### Code (${s.path}):
|
|
20
|
+
`),a.push("```tsx"),a.push(s.content),a.push("```"));}),a.filter(Boolean).join(`
|
|
21
|
+
`)});return `# Usage Examples
|
|
22
|
+
|
|
23
|
+
Found ${n.length} example${n.length>1?"s":""} matching "${t}":
|
|
24
|
+
`+r.join(`
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
`)}var $=new Server({name:"shadcn",version:"1.0.0"},{capabilities:{logging:{},resources:{},tools:{}}});async function O(n){try{await $.sendLoggingMessage({level:"info",data:n});}catch{console.error(n);}}$.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"get_project_registries",description:"Get configured registry names from components.json - Returns error if no components.json exists (use init_project to create one)",inputSchema:zodToJsonSchema(z$1.object({}))},{name:"list_items_in_registries",description:"List items from registries (requires components.json - use init_project if missing)",inputSchema:zodToJsonSchema(z$1.object({registries:z$1.array(z$1.string()).optional().describe("Array of registry names to list (e.g., ['@shadcn', '@acme']). Omit to list from every registry configured in components.json."),types:z$1.array(z$1.string()).optional().describe(`Filter by item type. One of: ${SEARCHABLE_TYPES.join(", ")}.`),limit:z$1.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z$1.number().optional().describe("Number of items to skip for pagination")}))},{name:"search_items_in_registries",description:"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.",inputSchema:zodToJsonSchema(z$1.object({registries:z$1.array(z$1.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z$1.string().describe("Search query string for fuzzy matching against item names and descriptions"),types:z$1.array(z$1.string()).optional().describe(`Filter by item type. One of: ${SEARCHABLE_TYPES.join(", ")}.`),limit:z$1.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z$1.number().optional().describe("Number of items to skip for pagination")}))},{name:"view_items_in_registries",description:"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.",inputSchema:zodToJsonSchema(z$1.object({items:z$1.array(z$1.string()).describe("Array of item names with registry prefix (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_item_examples_from_registries",description:"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.",inputSchema:zodToJsonSchema(z$1.object({registries:z$1.array(z$1.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z$1.string().describe("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}'")}))},{name:"get_add_command_for_items",description:"Get the shadcn CLI add command for specific items in a registry. This is useful for adding one or more components to your project.",inputSchema:zodToJsonSchema(z$1.object({items:z$1.array(z$1.string()).describe("Array of items to get the add command for prefixed with the registry name (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_audit_checklist",description:"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.",inputSchema:zodToJsonSchema(z$1.object({}))}]}));$.setRequestHandler(CallToolRequestSchema,async n=>withRegistryContext(()=>z(n),{onGitHubAuthNotice:O}));async function z(n){try{if(!n.params.arguments)throw new Error("No tool arguments provided.");switch(n.params.name){case "get_project_registries":{let t=await d(process.cwd());return t?.registries?{content:[{type:"text",text:c`The following registries are configured in the current project:
|
|
29
|
+
|
|
30
|
+
${Object.keys(t.registries).map(r=>`- ${r}`).join(`
|
|
31
|
+
`)}
|
|
32
|
+
|
|
33
|
+
You can view the items in a registry by running:
|
|
34
|
+
\`${await u("view @name-of-registry")}\`
|
|
35
|
+
|
|
36
|
+
For example: \`${await u("view @shadcn")}\` or \`${await u("view @shadcn @acme")}\` to view multiple registries.
|
|
37
|
+
`}]}:{content:[{type:"text",text:c`No components.json found or no registries configured.
|
|
38
|
+
|
|
39
|
+
To fix this:
|
|
40
|
+
1. Use the \`init\` command to create a components.json file
|
|
41
|
+
2. Or manually create components.json with a registries section`}]}}case "search_items_in_registries":{let r=z$1.object({registries:z$1.array(z$1.string()).optional(),query:z$1.string(),types:z$1.array(z$1.string()).optional(),limit:z$1.number().optional(),offset:z$1.number().optional()}).parse(n.params.arguments),i=y(r.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await d(process.cwd()),a=!r.registries?.length,s=resolveSearchRegistries(r.registries??[],o);if(s.length===0)return {content:[{type:"text",text:c`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let m=await searchRegistries(s,{query:r.query,types:r.types,limit:r.limit??100,offset:r.offset,config:o,useCache:!1,continueOnError:a}),p=x(m);return m.items.length===0?{content:[{type:"text",text:c`No items found matching "${r.query}" in registries ${s.join(", ")}, Try searching with a different query or registry.${p}`}]}:{content:[{type:"text",text:await h(m,{query:r.query,registries:s})+p}]}}case "list_items_in_registries":{let r=z$1.object({registries:z$1.array(z$1.string()).optional(),types:z$1.array(z$1.string()).optional(),limit:z$1.number().optional(),offset:z$1.number().optional(),cwd:z$1.string().optional()}).parse(n.params.arguments),i=y(r.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await d(process.cwd()),a=!r.registries?.length,s=resolveSearchRegistries(r.registries??[],o);if(s.length===0)return {content:[{type:"text",text:c`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let m=await searchRegistries(s,{types:r.types,limit:r.limit??100,offset:r.offset,config:o,useCache:!1,continueOnError:a}),p=x(m);return m.items.length===0?{content:[{type:"text",text:c`No items found in registries ${s.join(", ")}.${p}`}]}:{content:[{type:"text",text:await h(m,{registries:s})+p}]}}case "view_items_in_registries":{let r=z$1.object({items:z$1.array(z$1.string())}).parse(n.params.arguments),i=await getRegistryItems(r.items,{config:await d(process.cwd()),useCache:!1});if(i?.length===0)return {content:[{type:"text",text:c`No items found for: ${r.items.join(", ")}
|
|
42
|
+
|
|
43
|
+
Make sure the item names are correct and include the registry prefix (e.g., @shadcn/button).`}]};let o=j(i);return {content:[{type:"text",text:c`Item Details:
|
|
44
|
+
|
|
45
|
+
${o.join(`
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
`)}`}]}}case "get_item_examples_from_registries":{let r=z$1.object({query:z$1.string(),registries:z$1.array(z$1.string()).optional()}).parse(n.params.arguments),i=await d(),o=!r.registries?.length,a=resolveSearchRegistries(r.registries??[],i);if(a.length===0)return {content:[{type:"text",text:c`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let s=await searchRegistries(a,{query:r.query,config:i,useCache:!1,continueOnError:o});if(s.items.length===0)return {content:[{type:"text",text:c`No examples found for query "${r.query}".
|
|
50
|
+
|
|
51
|
+
Try searching with patterns like:
|
|
52
|
+
- "accordion-demo" for accordion examples
|
|
53
|
+
- "button demo" or "button example"
|
|
54
|
+
- Component name followed by "-demo" or "example"
|
|
55
|
+
|
|
56
|
+
You can also:
|
|
57
|
+
1. Use search_items_in_registries to find all items matching your query
|
|
58
|
+
2. View the main component with view_items_in_registries for inline usage documentation`}]};let m=s.items.map(g=>g.addCommandArgument),p=await getRegistryItems(m,{config:i,useCache:!1});return {content:[{type:"text",text:b(p,r.query)}]}}case "get_add_command_for_items":{let t=z$1.object({items:z$1.array(z$1.string())}).parse(n.params.arguments);return {content:[{type:"text",text:await u(`add ${t.items.join(" ")}`)}]}}case "get_audit_checklist":return {content:[{type:"text",text:c`## Component Audit Checklist
|
|
59
|
+
|
|
60
|
+
After adding or generating components, check the following common issues:
|
|
61
|
+
|
|
62
|
+
- [ ] Ensure imports are correct i.e named vs default imports
|
|
63
|
+
- [ ] If using next/image, ensure images.remotePatterns next.config.js is configured correctly.
|
|
64
|
+
- [ ] Ensure all dependencies are installed.
|
|
65
|
+
- [ ] Check for linting errors or warnings
|
|
66
|
+
- [ ] Check for TypeScript errors
|
|
67
|
+
- [ ] Use the Playwright MCP if available.
|
|
68
|
+
`}]};default:throw new Error(`Tool ${n.params.name} not found`)}}catch(t){if(t instanceof z$1.ZodError)return {content:[{type:"text",text:c`Invalid input parameters:
|
|
69
|
+
${t.errors.map(i=>`- ${i.path.join(".")}: ${i.message}`).join(`
|
|
70
|
+
`)}
|
|
71
|
+
`}],isError:true};if(t instanceof RegistryError){let i=t.message;return t.suggestion&&(i+=`
|
|
72
|
+
|
|
73
|
+
\u{1F4A1} ${t.suggestion}`),t.context&&(i+=`
|
|
74
|
+
|
|
75
|
+
Context: ${JSON.stringify(t.context,null,2)}`),{content:[{type:"text",text:c`Error (${t.code}): ${i}`}],isError:true}}let r=t instanceof Error?t.message:String(t);return {content:[{type:"text",text:c`Error: ${r}`}],isError:true}}}export{$ as a};
|
package/dist/index.d.ts
CHANGED
|
@@ -17,27 +17,27 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
17
17
|
$schema?: string | undefined;
|
|
18
18
|
tailwind?: {
|
|
19
19
|
config?: {
|
|
20
|
-
theme?: Record<string, any> | undefined;
|
|
21
20
|
content?: string[] | undefined;
|
|
21
|
+
theme?: Record<string, any> | undefined;
|
|
22
22
|
plugins?: string[] | undefined;
|
|
23
23
|
} | undefined;
|
|
24
24
|
} | undefined;
|
|
25
25
|
config?: {
|
|
26
|
-
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
27
|
-
menuAccent?: "subtle" | "bold" | undefined;
|
|
28
|
-
iconLibrary?: string | undefined;
|
|
29
|
-
style?: string | undefined;
|
|
30
26
|
$schema?: string | undefined;
|
|
27
|
+
style?: string | undefined;
|
|
31
28
|
rsc?: boolean | undefined;
|
|
32
29
|
tsx?: boolean | undefined;
|
|
33
30
|
tailwind?: {
|
|
34
|
-
baseColor?: string | undefined;
|
|
35
31
|
config?: string | undefined;
|
|
36
32
|
css?: string | undefined;
|
|
33
|
+
baseColor?: string | undefined;
|
|
37
34
|
cssVariables?: boolean | undefined;
|
|
38
35
|
prefix?: string | undefined;
|
|
39
36
|
} | undefined;
|
|
37
|
+
iconLibrary?: string | undefined;
|
|
40
38
|
rtl?: boolean | undefined;
|
|
39
|
+
menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
|
|
40
|
+
menuAccent?: "subtle" | "bold" | undefined;
|
|
41
41
|
aliases?: {
|
|
42
42
|
components?: string | undefined;
|
|
43
43
|
utils?: string | undefined;
|
|
@@ -61,7 +61,7 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
61
61
|
registryDependencies?: string[] | undefined;
|
|
62
62
|
files?: ({
|
|
63
63
|
path: string;
|
|
64
|
-
type: "registry:
|
|
64
|
+
type: "registry:file" | "registry:page";
|
|
65
65
|
target: string;
|
|
66
66
|
content?: string | undefined;
|
|
67
67
|
} | {
|
|
@@ -80,6 +80,8 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
80
80
|
docs?: string | undefined;
|
|
81
81
|
categories?: string[] | undefined;
|
|
82
82
|
} | {
|
|
83
|
+
type: "registry:font";
|
|
84
|
+
name: string;
|
|
83
85
|
font: {
|
|
84
86
|
family: string;
|
|
85
87
|
provider: "google";
|
|
@@ -90,13 +92,11 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
90
92
|
selector?: string | undefined;
|
|
91
93
|
dependency?: string | undefined;
|
|
92
94
|
};
|
|
93
|
-
type: "registry:font";
|
|
94
|
-
name: string;
|
|
95
95
|
$schema?: string | undefined;
|
|
96
96
|
tailwind?: {
|
|
97
97
|
config?: {
|
|
98
|
-
theme?: Record<string, any> | undefined;
|
|
99
98
|
content?: string[] | undefined;
|
|
99
|
+
theme?: Record<string, any> | undefined;
|
|
100
100
|
plugins?: string[] | undefined;
|
|
101
101
|
} | undefined;
|
|
102
102
|
} | undefined;
|
|
@@ -110,7 +110,7 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
110
110
|
registryDependencies?: string[] | undefined;
|
|
111
111
|
files?: ({
|
|
112
112
|
path: string;
|
|
113
|
-
type: "registry:
|
|
113
|
+
type: "registry:file" | "registry:page";
|
|
114
114
|
target: string;
|
|
115
115
|
content?: string | undefined;
|
|
116
116
|
} | {
|
|
@@ -129,13 +129,13 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
129
129
|
docs?: string | undefined;
|
|
130
130
|
categories?: string[] | undefined;
|
|
131
131
|
} | {
|
|
132
|
-
type: "registry:
|
|
132
|
+
type: "registry:file" | "registry:page" | "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:style" | "registry:item" | "registry:example" | "registry:internal";
|
|
133
133
|
name: string;
|
|
134
134
|
$schema?: string | undefined;
|
|
135
135
|
tailwind?: {
|
|
136
136
|
config?: {
|
|
137
|
-
theme?: Record<string, any> | undefined;
|
|
138
137
|
content?: string[] | undefined;
|
|
138
|
+
theme?: Record<string, any> | undefined;
|
|
139
139
|
plugins?: string[] | undefined;
|
|
140
140
|
} | undefined;
|
|
141
141
|
} | undefined;
|
|
@@ -149,7 +149,7 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
149
149
|
registryDependencies?: string[] | undefined;
|
|
150
150
|
files?: ({
|
|
151
151
|
path: string;
|
|
152
|
-
type: "registry:
|
|
152
|
+
type: "registry:file" | "registry:page";
|
|
153
153
|
target: string;
|
|
154
154
|
content?: string | undefined;
|
|
155
155
|
} | {
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b,c,a as a$1}from'./chunk-3W6BGJGE.js';import {a}from'./chunk-
|
|
2
|
+
import {b,c,a as a$1}from'./chunk-3W6BGJGE.js';import {a}from'./chunk-NNHTPP2Z.js';import*as X from'path';import X__default from'path';import {promises,existsSync}from'fs';import {isMonorepoRoot,getMonorepoTargets,formatMonorepoMessage,parsePnpmWorkspacePackages}from'@shadcn/registry/internal/get-monorepo-info';import {getProjectInfo,getProjectComponents,getProjectConfig,getProjectTailwindVersionFromConfig}from'@shadcn/registry/internal/get-project-info';import {highlighter}from'@shadcn/registry/internal/highlighter';import {logger}from'@shadcn/registry/internal/logger';import {SHADCN_URL,BUILTIN_REGISTRIES,DEPRECATED_COMPONENTS,COMPONENTS_HIDDEN_FROM_SELECTION,BASE_COLORS}from'@shadcn/registry/internal/registry/constants';import {spinner}from'@shadcn/registry/internal/spinner';import F from'fs-extra';import {getRegistryBaseColors,getRegistryItems,getShadcnRegistryIndex,getRegistryBaseColor,getItemTargetPath,getRegistries,getPackageJsonRegistries,getRegistriesIndex}from'@shadcn/registry/internal/registry/api';export*from'@shadcn/registry/internal/registry/api';import {resolveRegistryNamespaces}from'@shadcn/registry/internal/registry/namespaces';import {getBase,getConfig,resolveConfigPaths,getWorkspaceConfig,explorer,DEFAULT_TAILWIND_CSS,DEFAULT_TAILWIND_CONFIG,DEFAULT_COMPONENTS,createConfig,DEFAULT_UTILS}from'@shadcn/registry/internal/get-config';import {buildUrlAndHeadersForRegistryItem}from'@shadcn/registry/internal/registry/builder';import {configWithDefaults}from'@shadcn/registry/internal/registry/config';import Bs from'open';import ae from'prompts';import Eo from'dedent';import Zs,{tmpdir}from'os';import {getPackageManager,getPackageRunnerCommand,getPackageManagerFromUserAgent}from'@shadcn/registry/internal/get-package-manager';import {RegistryError}from'@shadcn/registry/internal/registry/errors';import Ur,{z as z$1}from'zod';import {execa}from'execa';import {addComponents}from'@shadcn/registry/internal/add-components';import {iconLibraries}from'@shadcn/registry/internal/icons/libraries';import {resolveRegistryTree}from'@shadcn/registry/internal/registry/resolver';import {updateCss,transformCss}from'@shadcn/registry/internal/updaters/update-css';import {updateCssVars,transformCssVars as transformCssVars$1,isLocalHSLValue}from'@shadcn/registry/internal/updaters/update-css-vars';import {updateDependencies,installDependencies,removeDependencies}from'@shadcn/registry/internal/updaters/update-dependencies';import {rawConfigSchema,stylesSchema,registryItemSchema,iconsSchema}from'@shadcn/registry/schema';import $o from'deepmerge';import {updateFonts,massageTreeForFonts}from'@shadcn/registry/internal/updaters/update-fonts';import {fetchRegistry}from'@shadcn/registry/internal/registry/fetcher';import {loadEnvFiles}from'@shadcn/registry/internal/env-loader';import {PRESET_BASES,isPresetCode,isPresetBase,decodePreset,parsePresetStyle,PRESET_BASE_COLORS,PRESET_ICON_LIBRARIES,PRESET_MENU_ACCENTS,PRESET_MENU_COLORS,PRESET_FONTS,PRESET_FONT_HEADINGS,PRESET_THEMES,encodePreset,V1_CHART_COLOR_MAP}from'@shadcn/registry/internal/preset/preset';import {clearRegistryContext}from'@shadcn/registry/internal/registry/context';import {isUrl,isUniversalRegistryItem}from'@shadcn/registry/internal/registry/utils';import {Command}from'commander';import {isContentSame}from'@shadcn/registry/internal/compare';import {isEnvFile}from'@shadcn/registry/internal/env-helpers';import {getSupportedFontMarkers}from'@shadcn/registry/internal/font-markers';import {transform}from'@shadcn/registry/internal/transformers/index';import {transformAsChild}from'@shadcn/registry/internal/transformers/transform-aschild';import {transformCleanup}from'@shadcn/registry/internal/transformers/transform-cleanup';import {transformCssVars}from'@shadcn/registry/internal/transformers/transform-css-vars';import {transformFont}from'@shadcn/registry/internal/transformers/transform-font';import {transformIcons}from'@shadcn/registry/internal/transformers/transform-icons';import {transformImport}from'@shadcn/registry/internal/transformers/transform-import';import {transformMenu}from'@shadcn/registry/internal/transformers/transform-menu';import {transformRsc}from'@shadcn/registry/internal/transformers/transform-rsc';import {transformRtl,transformDirection}from'@shadcn/registry/internal/transformers/transform-rtl';import {transformTwPrefixes}from'@shadcn/registry/internal/transformers/transform-tw-prefix';import {getPlannedFilePaths,resolveFilePath,findCommonRoot,rewriteResolvedImportsInContent}from'@shadcn/registry/internal/updaters/update-files';import {loadConfig}from'tsconfig-paths';import {diffLines,structuredPatch,diffWords}from'diff';import {dim,yellow,bold,green,cyan,red}from'kleur/colors';import*as be from'fs/promises';import be__default from'fs/promises';import {readRegistryWithIncludes,createRegistryCatalog,createRegistryItem}from'@shadcn/registry/internal/registry/loader';import {getPackageInfo}from'@shadcn/registry/internal/get-package-info';import lp from'postcss';import {Project,ScriptKind,SyntaxKind,Node}from'ts-morph';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import to from'fast-glob';import {randomBytes}from'crypto';import {resolveGitHubRegistrySource}from'@shadcn/registry/internal/registry/address';import {validateGitHubRegistrySource}from'@shadcn/registry/internal/registry/github';import {validateRegistry}from'@shadcn/registry/internal/registry/validate';import {findUnknownSearchTypes,SEARCHABLE_TYPES,resolveSearchRegistries,searchRegistries,printSearchResults}from'@shadcn/registry/internal/registry/search';import {validateRegistryConfigForItems}from'@shadcn/registry/internal/registry/validator';async function bo(e){let t={};if(!F.existsSync(e.cwd)||!F.existsSync(X__default.resolve(e.cwd,"package.json")))return t["1"]=true,{errors:t,projectInfo:null};let r=spinner("Preflight checks.",{silent:e.silent}).start();F.existsSync(X__default.resolve(e.cwd,"components.json"))&&!e.force&&(r?.fail(),logger.break(),logger.error(`A ${highlighter.info("components.json")} file already exists at ${highlighter.info(e.cwd)}.
|
|
3
3
|
To start over, remove the ${highlighter.info("components.json")} file and run ${highlighter.info("init")} again.`),logger.break(),process.exit(1)),r?.succeed();let o=spinner("Verifying framework.",{silent:e.silent}).start(),n=e.existingConfig?.tailwind,i=await getProjectInfo(e.cwd,{configCssFile:typeof n?.css=="string"?n.css:void 0});if(!i||i?.framework.name==="manual"){if(t["7"]=true,o?.fail(),!e.monorepo&&await isMonorepoRoot(e.cwd)){let l=await getMonorepoTargets(e.cwd);l.length>0&&(formatMonorepoMessage("init",l),process.exit(1));}logger.break(),i?.framework.links.installation&&logger.error(`We could not detect a supported framework at ${highlighter.info(e.cwd)}.
|
|
4
4
|
Visit ${highlighter.info(i?.framework.links.installation)} to manually configure your project.
|
|
5
5
|
Once configured, you can use the cli to add components.`),logger.break(),process.exit(1);}o?.succeed(`Verifying framework. Found ${highlighter.info(i.framework.label)}.`);let s="Validating Tailwind CSS.";i.tailwindVersion==="v4"&&(s=`Validating Tailwind CSS. Found ${highlighter.info("v4")}.`);let a=spinner(s,{silent:e.silent}).start();i.tailwindVersion==="v3"&&(!i?.tailwindConfigFile||!i?.tailwindCssFile)?(t["5"]=true,a?.fail()):i.tailwindVersion==="v4"&&!i?.tailwindCssFile?(t["5"]=true,a?.fail()):i.tailwindVersion?a?.succeed():(t["5"]=true,a?.fail());let c=spinner("Validating import alias.",{silent:e.silent}).start();return i?.aliasPrefix?c?.succeed():(t["6"]=true,c?.fail()),Object.keys(t).length>0&&(t["5"]&&(logger.break(),logger.error(`No Tailwind CSS configuration found at ${highlighter.info(e.cwd)}.`),logger.error("It is likely you do not have Tailwind CSS installed or have an invalid configuration."),logger.error("Install Tailwind CSS then try again."),i?.framework.links.tailwind&&logger.error(`Visit ${highlighter.info(i?.framework.links.tailwind)} to get started.`)),t["6"]&&(logger.break(),logger.error(`Could not find valid path aliases or package imports for ${highlighter.info("init")}.`),logger.error(`Configure path aliases in ${highlighter.info("tsconfig.json")} or imports in ${highlighter.info("package.json")}, then run ${highlighter.info("init")} again.`),logger.error(`Learn more at ${highlighter.info(`${SHADCN_URL}/docs/installation/manual#configure-import-aliases`)}.`)),logger.break(),process.exit(1)),{errors:t,projectInfo:i}}async function _(e,t,r={}){r={silent:false,writeFile:true,...r};let n=(await resolveRegistryNamespaces(e,t)).filter(m=>!t.registries?.[m]&&!Object.keys(BUILTIN_REGISTRIES).includes(m));if(n.length===0)return {config:t,newRegistries:[],discoveredRegistries:{},packageJsonRegistries:{}};let i=await getPackageJsonRegistries(t.resolvedPaths.cwd),s={},a=[];for(let m of n)i[m]?s[m]=i[m]:a.push(m);let c={};if(a.length>0){let m=await getRegistriesIndex({useCache:process.env.NODE_ENV!=="development"});if(m)for(let d of a)m[d]&&(c[d]=m[d]);}let l={...s,...c};if(Object.keys(l).length===0)return {config:t,newRegistries:[],discoveredRegistries:{},packageJsonRegistries:{}};let p=Object.fromEntries(Object.entries(t.registries||{}).filter(([m])=>!Object.keys(BUILTIN_REGISTRIES).includes(m))),f={...t,registries:{...p,...l}};if(r.writeFile&&Object.keys(c).length>0){let m=X__default.resolve(t.resolvedPaths.cwd,"components.json");if(F.existsSync(m)){let d=spinner("Updating components.json.",{silent:r.silent}).start(),u=await F.readJson(m),g={...u,registries:{...u.registries,...c}};await F.writeFile(m,JSON.stringify(g,null,2)+`
|
|
6
|
-
`,"utf-8"),d.succeed();}}return {config:f,newRegistries:Object.keys(l),discoveredRegistries:c,packageJsonRegistries:s}}var J={nova:{title:"Nova",description:"Lucide / Geist",style:"nova",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"geist",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},vega:{title:"Vega",description:"Lucide / Inter",style:"vega",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},maia:{title:"Maia",description:"Hugeicons / Figtree",style:"maia",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"hugeicons",font:"figtree",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},lyra:{title:"Lyra",description:"Phosphor / JetBrains Mono",style:"lyra",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"phosphor",font:"jetbrains-mono",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},mira:{title:"Mira",description:"Hugeicons / Inter",style:"mira",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"hugeicons",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},luma:{title:"Luma",description:"Lucide / Inter",style:"luma",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},sera:{title:"Sera",description:"Lucide / Noto Sans + Playfair Display",style:"sera",baseColor:"taupe",theme:"taupe",chartColor:"taupe",iconLibrary:"lucide",font:"noto-sans",fontHeading:"playfair-display",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},rhea:{title:"Rhea",description:"Lucide / Inter",style:"rhea",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false}};function pr(e){let t=new URL(`${SHADCN_URL}/create`),{rtl:r,pointer:o,...n}=e??{};for(let[i,s]of Object.entries(n))s!==void 0&&t.searchParams.set(i,String(s));return r&&t.searchParams.set("rtl","true"),o&&t.searchParams.set("pointer","true"),t.toString()}async function mr(e){if(logger.break(),logger.log(` Build your custom preset on ${highlighter.info(e.createUrl)}`),logger.log(` ${e.followUp}`),logger.break(),e.prompt===false)return;let{proceed:t}=await ae({type:"confirm",name:"proceed",message:"Open in browser?",initial:true});t&&await Bs(e.createUrl);}function ne(e,t){let r=new URLSearchParams({base:e.base,style:e.style,baseColor:e.baseColor,theme:e.theme,iconLibrary:e.iconLibrary,font:e.font,rtl:String(e.rtl??false),menuAccent:e.menuAccent,menuColor:e.menuColor,radius:e.radius});return e.chartColor&&e.chartColor!=="neutral"&&r.set("chartColor",e.chartColor),e.fontHeading&&e.fontHeading!=="inherit"&&r.set("fontHeading",e.fontHeading),t?.preset&&r.set("preset",t.preset),t?.template&&r.set("template",t.template),t?.only&&r.set("only",t.only),t?.pointer&&r.set("pointer","true"),r.set("track","1"),`${SHADCN_URL}/init?${r.toString()}`}async function Ne(){let{base:e}=await ae({type:"select",name:"base",message:`Select a ${highlighter.info("component library")}`,choices:[{title:"Base UI (Recommended)",value:"base"},{title:"React Aria",value:"aria"},{title:"Radix UI",value:"radix"}]});return e||process.exit(1),e}async function qe(e){let t=Object.entries(J),{selectedPreset:r}=await ae({type:"select",name:"selectedPreset",message:`Which ${highlighter.info("preset")} would you like to use?`,choices:[...t.map(([n,i])=>({title:i.title,description:i.description,value:n})),{title:"Custom",description:`Build your own at ${highlighter.info(`${SHADCN_URL}/create`)}`,value:"custom"}]});if(r||process.exit(1),r==="custom"){let n=pr({command:"init",rtl:e.rtl,pointer:e.pointer,base:e.base,...e.template&&{template:e.template}});await mr({createUrl:n,followUp:`Then ${highlighter.info("copy and run the command")} from ui.shadcn.com.`}),process.exit(0);}let o=J[r];return o||process.exit(1),{url:ne({...o,base:e.base,rtl:e.rtl},{template:e.template,pointer:e.pointer}),base:e.base}}async function he(e,t,r){let o=configWithDefaults(createConfig({resolvedPaths:{cwd:t},...r?.registries&&{registries:r.registries}})),{config:n}=await _([e],o,{silent:true,writeFile:false});o=n,buildUrlAndHeadersForRegistryItem(e,o);let[i]=await getRegistryItems([e],{config:o,useCache:true}),s=i?.type==="registry:base"&&i.config?i.config:void 0,a=e;if(Us(e)){let c=new URL(e);c.searchParams.delete("track"),a=c.toString();}return {registryBaseConfig:s,installStyleIndex:i?.extends!=="none",url:a}}function Us(e){try{return new URL(e).pathname==="/init"&&e.startsWith(SHADCN_URL)}catch{return false}}var Ct={version:"4.21.
|
|
6
|
+
`,"utf-8"),d.succeed();}}return {config:f,newRegistries:Object.keys(l),discoveredRegistries:c,packageJsonRegistries:s}}var J={nova:{title:"Nova",description:"Lucide / Geist",style:"nova",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"geist",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},vega:{title:"Vega",description:"Lucide / Inter",style:"vega",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},maia:{title:"Maia",description:"Hugeicons / Figtree",style:"maia",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"hugeicons",font:"figtree",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},lyra:{title:"Lyra",description:"Phosphor / JetBrains Mono",style:"lyra",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"phosphor",font:"jetbrains-mono",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},mira:{title:"Mira",description:"Hugeicons / Inter",style:"mira",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"hugeicons",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},luma:{title:"Luma",description:"Lucide / Inter",style:"luma",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},sera:{title:"Sera",description:"Lucide / Noto Sans + Playfair Display",style:"sera",baseColor:"taupe",theme:"taupe",chartColor:"taupe",iconLibrary:"lucide",font:"noto-sans",fontHeading:"playfair-display",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},rhea:{title:"Rhea",description:"Lucide / Inter",style:"rhea",baseColor:"neutral",theme:"neutral",chartColor:"neutral",iconLibrary:"lucide",font:"inter",fontHeading:"inherit",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false}};function pr(e){let t=new URL(`${SHADCN_URL}/create`),{rtl:r,pointer:o,...n}=e??{};for(let[i,s]of Object.entries(n))s!==void 0&&t.searchParams.set(i,String(s));return r&&t.searchParams.set("rtl","true"),o&&t.searchParams.set("pointer","true"),t.toString()}async function mr(e){if(logger.break(),logger.log(` Build your custom preset on ${highlighter.info(e.createUrl)}`),logger.log(` ${e.followUp}`),logger.break(),e.prompt===false)return;let{proceed:t}=await ae({type:"confirm",name:"proceed",message:"Open in browser?",initial:true});t&&await Bs(e.createUrl);}function ne(e,t){let r=new URLSearchParams({base:e.base,style:e.style,baseColor:e.baseColor,theme:e.theme,iconLibrary:e.iconLibrary,font:e.font,rtl:String(e.rtl??false),menuAccent:e.menuAccent,menuColor:e.menuColor,radius:e.radius});return e.chartColor&&e.chartColor!=="neutral"&&r.set("chartColor",e.chartColor),e.fontHeading&&e.fontHeading!=="inherit"&&r.set("fontHeading",e.fontHeading),t?.preset&&r.set("preset",t.preset),t?.template&&r.set("template",t.template),t?.only&&r.set("only",t.only),t?.pointer&&r.set("pointer","true"),r.set("track","1"),`${SHADCN_URL}/init?${r.toString()}`}async function Ne(){let{base:e}=await ae({type:"select",name:"base",message:`Select a ${highlighter.info("component library")}`,choices:[{title:"Base UI (Recommended)",value:"base"},{title:"React Aria",value:"aria"},{title:"Radix UI",value:"radix"}]});return e||process.exit(1),e}async function qe(e){let t=Object.entries(J),{selectedPreset:r}=await ae({type:"select",name:"selectedPreset",message:`Which ${highlighter.info("preset")} would you like to use?`,choices:[...t.map(([n,i])=>({title:i.title,description:i.description,value:n})),{title:"Custom",description:`Build your own at ${highlighter.info(`${SHADCN_URL}/create`)}`,value:"custom"}]});if(r||process.exit(1),r==="custom"){let n=pr({command:"init",rtl:e.rtl,pointer:e.pointer,base:e.base,...e.template&&{template:e.template}});await mr({createUrl:n,followUp:`Then ${highlighter.info("copy and run the command")} from ui.shadcn.com.`}),process.exit(0);}let o=J[r];return o||process.exit(1),{url:ne({...o,base:e.base,rtl:e.rtl},{template:e.template,pointer:e.pointer}),base:e.base}}async function he(e,t,r){let o=configWithDefaults(createConfig({resolvedPaths:{cwd:t},...r?.registries&&{registries:r.registries}})),{config:n}=await _([e],o,{silent:true,writeFile:false});o=n,buildUrlAndHeadersForRegistryItem(e,o);let[i]=await getRegistryItems([e],{config:o,useCache:true}),s=i?.type==="registry:base"&&i.config?i.config:void 0,a=e;if(Us(e)){let c=new URL(e);c.searchParams.delete("track"),a=c.toString();}return {registryBaseConfig:s,installStyleIndex:i?.extends!=="none",url:a}}function Us(e){try{return new URL(e).pathname==="/init"&&e.startsWith(SHADCN_URL)}catch{return false}}var Ct={version:"4.21.5"};function k(e){if(logger.break(),logger.error("Something went wrong. Please check the error below for more details."),logger.error("If the problem persists, please open an issue on GitHub."),logger.error(""),typeof e=="string"&&(logger.error(e),Xe()),e instanceof RegistryError&&(e.message&&(logger.error(e.cause?"Error:":"Message:"),logger.error(e.message)),e.cause&&(logger.error(`
|
|
7
7
|
Message:`),logger.error(e.cause)),e.suggestion&&(logger.error(`
|
|
8
8
|
Suggestion:`),logger.error(e.suggestion)),Xe()),e instanceof z$1.ZodError){logger.error("Validation failed:");for(let[t,r]of Object.entries(e.flatten().fieldErrors))logger.error(`- ${highlighter.info(t)}: ${r}`);Xe();}e instanceof Error&&(logger.error(e.message),Xe()),Xe();}function Ys(e){let t=e.match(/^(\d+)\.(\d+)\.\d+/);if(!t)return null;let r=Number.parseInt(t[1],10),o=Number.parseInt(t[2],10);return o===0?null:`${r}.${o-1}.0`}function qs(e=Ct.version,t=process.argv.slice(2)){let r=Ys(e);return r?[...getPackageRunnerCommand(getPackageManagerFromUserAgent()).split(" "),`shadcn@${r}`,...t].map(Xs).join(" "):null}function Xe(){let e=qs();e&&(logger.error(""),logger.error("You can also try a previous version to see if that works:"),logger.error(e)),logger.break(),process.exit(1);}function Xs(e){return /^[a-zA-Z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var ta=process.env.SHADCN_GITHUB_URL??"https://github.com/shadcn-ui/ui.git";function z(e){return {...e,frameworks:e.frameworks??[],scaffold:e.scaffold??vo({title:e.title,templateDir:e.templateDir}),postInit:e.postInit??ia}}function we(e,{monorepo:t}){if(!t||!e.monorepo)return e;let r=e.monorepo,o={...e,templateDir:r.templateDir,defaultProjectName:r.defaultProjectName??r.templateDir,init:r.init??e.init,files:r.files??e.files};return o.scaffold=vo({title:e.title,templateDir:r.templateDir}),o}function ra(e){switch(e){case "pnpm":return ["--no-frozen-lockfile"];case "yarn":return ["--no-immutable"];case "npm":return ["--no-audit","--no-fund"];default:return []}}async function oa(e,t){if(t==="pnpm")return;let r=X__default.join(e,"pnpm-workspace.yaml"),o=X__default.join(e,"package.json"),n=X__default.join(e,"pnpm-lock.yaml");F.existsSync(n)&&await F.remove(n);let i=F.existsSync(r),s=i?parsePnpmWorkspacePackages(await F.readFile(r,"utf8")):[],a=s.length>0;if(F.existsSync(o)){let c=await F.readFile(o,"utf8"),l=JSON.parse(c);a?l.packageManager=await na(t):delete l.packageManager,a&&(l.workspaces=s),await F.writeFile(o,JSON.stringify(l,null,2)+`
|
|
9
9
|
`);}i&&await F.remove(r),a&&t==="npm"&&await So(e);}async function na(e){try{let{stdout:t}=await execa(e,["--version"]);return `${e}@${t.trim()}`}catch{return `${e}@*`}}async function So(e){let t=await F.readdir(e,{withFileTypes:true});for(let r of t){if(r.name==="node_modules")continue;let o=X__default.join(e,r.name);if(r.isDirectory())await So(o);else if(r.name==="package.json"){let n=await F.readFile(o,"utf8");if(!n.includes("workspace:"))continue;let i=JSON.parse(n),s=false;for(let a of ["dependencies","devDependencies","peerDependencies","optionalDependencies"]){let c=i[a];if(c)for(let[l,p]of Object.entries(c))typeof p=="string"&&p.startsWith("workspace:")&&(c[l]="*",s=true);}s&&await F.writeFile(o,JSON.stringify(i,null,2)+`
|
package/dist/mcp/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as server}from'../chunk-
|
|
1
|
+
export{a as server}from'../chunk-NNHTPP2Z.js';
|
package/dist/tailwind.d.ts
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TransformOpts } from '@shadcn/registry/internal/
|
|
1
|
+
import { TransformOpts } from '@shadcn/registry/internal/transformers/index';
|
|
2
2
|
import { SourceFile } from 'ts-morph';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
export { transformDirection } from '@shadcn/registry/internal/
|
|
4
|
+
export { transformDirection } from '@shadcn/registry/internal/transformers/transform-rtl';
|
|
5
5
|
|
|
6
6
|
type SourceFileTransformer = (opts: TransformOpts & {
|
|
7
7
|
sourceFile: SourceFile;
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {transformFont}from'@shadcn/registry/internal/
|
|
1
|
+
import {transformFont}from'@shadcn/registry/internal/transformers/transform-font';import {transformIcons}from'@shadcn/registry/internal/transformers/transform-icons';import {transformMenu}from'@shadcn/registry/internal/transformers/transform-menu';import'path';import {Project,ScriptKind,SyntaxKind,Node}from'ts-morph';import q from'postcss';import G from'postcss-selector-parser';import {z as z$1}from'zod';import {twMerge}from'cn';export{transformDirection}from'@shadcn/registry/internal/transformers/transform-rtl';function A(e){return async({sourceFile:t,...r})=>(X(t,await e(t.getFullText(),r)),t)}function X(e,t){let r=e.getFullText();t!==r&&e.applyTextChanges([{span:{start:0,length:r.length},newText:t}]);}var I="cn-",H=z$1.record(z$1.string().startsWith(I),z$1.string());function Q(e){let t=q.parse(e),r={};return t.walkRules(n=>{let s=n.selectors??[];if(s.length===0)return;let o=Y(n);if(o)for(let l of s){let c=U(l);G(i=>{i.each(g=>{let u=Z(g);if(!u)return;let f=u.value;f.startsWith(I)&&(r[f]=r[f]?`${o} ${r[f]}`:o);});}).processSync(c);}}),H.parse(r)}function U(e){return e.replace(/\s*&\s*/g,"").trim()}function Y(e){let t=[];for(let r of e.nodes||[])if(r.type==="atrule"&&r.name==="apply"){let n=r.params.trim();n&&t.push(n);}return t.length===0?null:t.join(" ")}function Z(e){let t=[];return e.walkClasses(r=>{r.value.startsWith(I)&&t.push(r);}),t.length===0?null:t[t.length-1]}var N=new Set(["cn-menu-target","cn-menu-translucent","cn-logical-sides","cn-rtl-flip","cn-font-heading"]);function m(e){return Node.isStringLiteral(e)||Node.isNoSubstitutionTemplateLiteral(e)}var z=async({sourceFile:e,styleMap:t})=>{let r=new Set;return re(e,t,r),ne(e,t,r),te(e,t,r),ae(e,t,r),e};function te(e,t,r){e.forEachDescendant(n=>{if(!Node.isPropertyAssignment(n)||n.getNameNode().getText()!=="className")return;let s=n.getInitializer();!s||!Node.isCallExpression(s)||d(s)&&j(s,t,r);});}function M(e,t,r){let n=e.getLiteralText(),s=h(n);if(s.length===0)return;let o=s.filter(i=>!r.has(i));if(o.length===0){let i=p(n);e.setLiteralValue(i);return}let c=o.filter(i=>!N.has(i)).map(i=>t[i]).filter(i=>!!i);if(c.length>0){let i=c.join(" "),g=p(E(i,n));e.setLiteralValue(g),o.forEach(u=>r.add(u));}else {let i=p(n);e.setLiteralValue(i);}}function re(e,t,r){e.forEachDescendant(n=>{if(!Node.isCallExpression(n))return;let s=n.getExpression();if(!Node.isIdentifier(s)||s.getText()!=="cva")return;let o=n.getArguments()[0];Node.isStringLiteral(o)&&M(o,t,r);let l=n.getArguments()[1];if(!l||!Node.isObjectLiteralExpression(l))return;let c=l.getProperties().find(g=>Node.isPropertyAssignment(g)&&Node.isIdentifier(g.getNameNode())&&g.getNameNode().getText()==="variants");if(!c||!Node.isPropertyAssignment(c))return;let i=c.getInitializer();!i||!Node.isObjectLiteralExpression(i)||i.getProperties().forEach(g=>{if(!Node.isPropertyAssignment(g))return;let u=g.getInitializer();!u||!Node.isObjectLiteralExpression(u)||u.getProperties().forEach(f=>{if(!Node.isPropertyAssignment(f))return;let x=f.getInitializer();x&&Node.isStringLiteral(x)&&M(x,t,r);});});});}function ne(e,t,r){e.forEachDescendant(n=>{if(!Node.isJsxAttribute(n)||n.getNameNode().getText()!=="className")return;let s=n.getInitializer();if(!s)return;let o=se(s);if(o.length>0){o.forEach(f=>j(f,t,r));return}let l=ie(s);if(l.length===0)return;let c=n.getParent()?.getParent();if(!c||!Node.isJsxOpeningElement(c)&&!Node.isJsxSelfClosingElement(c))return;let i=l.filter(f=>!r.has(f));if(i.length===0){V(s);return}let u=i.filter(f=>!N.has(f)).map(f=>t[f]).filter(f=>!!f);if(u.length>0){let f=u.join(" ");oe(c,f);}else V(s);});}function se(e){if(!Node.isJsxExpression(e))return [];let t=e.getExpression();if(!t||Node.isCallExpression(t)&&d(t))return [];let r=[];return t.forEachDescendant(n=>{Node.isCallExpression(n)&&d(n)&&r.push(n);}),r}function ie(e){let t=[];if(m(e))return h(e.getLiteralText());if(!Node.isJsxExpression(e))return t;let r=e.getExpression();if(!r)return t;if(m(r))return h(r.getLiteralText());if(Node.isCallExpression(r)&&d(r))for(let n of r.getArguments())m(n)&&t.push(...h(n.getLiteralText()));return t}function V(e){if(m(e)){let r=p(e.getLiteralText());e.setLiteralValue(r);return}if(!Node.isJsxExpression(e))return;let t=e.getExpression();if(t){if(m(t)){let r=p(t.getLiteralText());t.setLiteralValue(r);return}if(Node.isCallExpression(t)&&d(t)){for(let r of t.getArguments())if(m(r)){let n=p(r.getLiteralText());r.setLiteralValue(n);}L(t);}}}function h(e){let t=e.matchAll(/\bcn-[\w-]+\b/g);return Array.from(t,r=>r[0])}function p(e){return e.replace(/\bcn-[\w-]+\b/g,t=>N.has(t)?t:"").replace(/\s+/g," ").trim()}function L(e){if(!d(e))return;let t=e.getArguments(),r=t.filter(n=>m(n)?n.getLiteralText().trim()!=="":true);if(r.length!==t.length){let n=r.map(o=>o.getText()),s=e.getParent();s&&Node.isJsxExpression(s)?s.replaceWithText(`{cn(${n.join(", ")})}`):e.replaceWithText(`cn(${n.join(", ")})`);}}function oe(e,t){if(!Node.isJsxOpeningElement(e)&&!Node.isJsxSelfClosingElement(e))return;let r=e.getAttributes().find(o=>Node.isJsxAttribute(o)&&o.getNameNode().getText()==="className");if(!r||!Node.isJsxAttribute(r)){e.addAttribute({name:"className",initializer:`{cn(${JSON.stringify(t)})}`});return}let n=r.getInitializer();if(!n){r.setInitializer(`{cn(${JSON.stringify(t)})}`);return}if(m(n)){let o=n.getLiteralText(),l=p(E(t,o));n.setLiteralValue(l);return}if(!Node.isJsxExpression(n))return;let s=n.getExpression();if(!s){r.setInitializer(`{cn(${JSON.stringify(t)})}`);return}if(m(s)){let o=s.getLiteralText(),l=p(E(t,o));s.setLiteralValue(l);return}if(Node.isCallExpression(s)&&d(s)){let o=s.getArguments()[0];if(m(o)){let i=o.getLiteralText(),g=p(E(t,i));o.setLiteralValue(g);for(let u=1;u<s.getArguments().length;u++){let f=s.getArguments()[u];if(m(f)){let x=f.getLiteralText(),y=p(x);y!==x&&f.setLiteralValue(y);}}L(s);return}let l=s.getArguments().map(i=>{if(m(i)){let g=p(i.getLiteralText());return g?JSON.stringify(g):null}return i.getText()}).filter(i=>i!==null),c=[JSON.stringify(t),...l];r.setInitializer(`{cn(${c.join(", ")})}`);return}r.setInitializer(`{cn(${JSON.stringify(t)}, ${s.getText()})}`);}function E(e,t){return twMerge(e,t)}function d(e){let t=e.getExpression();return Node.isIdentifier(t)&&t.getText()==="cn"}function ae(e,t,r){e.forEachDescendant(n=>{if(!Node.isCallExpression(n))return;let s=n.getExpression();if(!(!Node.isIdentifier(s)||s.getText()!=="mergeProps"))for(let o of n.getArguments()){if(!Node.isObjectLiteralExpression(o))continue;let l=o.getProperties().find(i=>Node.isPropertyAssignment(i)&&Node.isIdentifier(i.getNameNode())&&i.getNameNode().getText()==="className");if(!l||!Node.isPropertyAssignment(l))continue;let c=l.getInitializer();c&&Node.isCallExpression(c)&&d(c)&&j(c,t,r,true);}});}function j(e,t,r,n=false){let s=le(e);if(s.length===0)return;let o=s.filter(i=>!r.has(i));if(o.length===0){v(e);return}let c=o.filter(i=>!N.has(i)).map(i=>t[i]).filter(i=>!!i);if(c.length===0){v(e);return}ce(e,c.join(" ")),n&&o.forEach(i=>r.add(i));}function le(e){let t=[];for(let r of e.getArguments())m(r)&&t.push(...h(r.getLiteralText()));return t}function v(e){for(let t of e.getArguments())if(m(t)){let r=p(t.getLiteralText());t.setLiteralValue(r);}L(e);}function ce(e,t){let r=e.getArguments()[0];if(m(r)){let l=r.getLiteralText(),c=p(E(t,l));r.setLiteralValue(c);for(let i=1;i<e.getArguments().length;i++){let g=e.getArguments()[i];if(m(g)){let u=g.getLiteralText(),f=p(u);f!==u&&g.setLiteralValue(f);}}L(e);return}let n=e.getArguments().map(l=>{if(m(l)){let c=p(l.getLiteralText());return c?JSON.stringify(c):null}return l.getText()}).filter(l=>l!==null),s=[JSON.stringify(t),...n];e.getParent()&&e.replaceWithText(`cn(${s.join(", ")})`);}async function ge(e,{styleMap:t,transformers:r=[z]}){let s=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",e,{scriptKind:ScriptKind.TSX,overwrite:true});for(let o of r)await o({sourceFile:s,styleMap:t});return s.getText()}var K=async({sourceFile:e,config:t})=>{if(!t.style?.startsWith("base-"))return e;let r=[],n=e.getDescendantsOfKind(SyntaxKind.JsxElement);for(let s of n){let o=s.getOpeningElement(),l=o.getAttribute("render");if(!l)continue;let i=s.getJsxChildren().map(S=>S.getText()).join("").trim();if(!i||l.getKind()!==SyntaxKind.JsxAttribute)continue;let u=l.asKindOrThrow(SyntaxKind.JsxAttribute).getInitializer();if(!u||u.getKind()!==SyntaxKind.JsxExpression)continue;let x=u.asKindOrThrow(SyntaxKind.JsxExpression).getExpression();if(!x||x.getKind()!==SyntaxKind.JsxSelfClosingElement)continue;let y=x.asKindOrThrow(SyntaxKind.JsxSelfClosingElement),C=y.getTagNameNode().getText(),J=y.getAttributes().map(S=>S.getText()).join(" "),O=J?`{<${C} ${J}>${i}</${C}>}`:`{<${C}>${i}</${C}>}`,R=o.getTagNameNode().getText(),P=o.getAttributes().filter(S=>S.getKind()===SyntaxKind.JsxAttribute?S.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()!=="render":true).map(S=>S.getText()).join(" "),W=P?`${P} render=${O}`:`render=${O}`,D=`<${R} ${W} />`;r.push({elementStart:s.getStart(),elementEnd:s.getEnd(),newText:D});}for(let s of r.reverse()){let o=e.getFullText(),l=o.substring(0,s.elementStart)+s.newText+o.substring(s.elementEnd);e.replaceWithText(l);}return e};var ze=A(transformFont),Ke=A(transformIcons),Re=A(transformMenu);export{Q as createStyleMap,ze as transformFont,Ke as transformIcons,Re as transformMenu,K as transformRender,ge as transformStyle};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shadcn",
|
|
3
|
-
"version": "4.21.
|
|
3
|
+
"version": "4.21.5",
|
|
4
4
|
"description": "Add components to your apps.",
|
|
5
5
|
"homepage": "https://ui.shadcn.com",
|
|
6
6
|
"publishConfig": {
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
73
73
|
"@babel/preset-typescript": "^7.27.1",
|
|
74
74
|
"@dotenvx/dotenvx": "^1.48.4",
|
|
75
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
75
|
+
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
76
76
|
"@types/validate-npm-package-name": "^4.0.2",
|
|
77
|
-
"browserslist": "^4.
|
|
77
|
+
"browserslist": "^4.29.3",
|
|
78
78
|
"cn": "^0.2.4",
|
|
79
79
|
"commander": "^14.0.0",
|
|
80
80
|
"dedent": "^1.6.0",
|
|
@@ -85,21 +85,21 @@
|
|
|
85
85
|
"fs-extra": "^11.3.1",
|
|
86
86
|
"fuzzysort": "^3.1.0",
|
|
87
87
|
"kleur": "^4.1.5",
|
|
88
|
-
"open": "^11.0.
|
|
88
|
+
"open": "^11.0.4",
|
|
89
89
|
"ora": "^8.2.0",
|
|
90
90
|
"postcss": "^8.5.23",
|
|
91
|
-
"postcss-selector-parser": "^7.1.
|
|
91
|
+
"postcss-selector-parser": "^7.1.6",
|
|
92
92
|
"prompts": "^2.4.2",
|
|
93
93
|
"recast": "^0.23.11",
|
|
94
94
|
"socks": "^2.8.8",
|
|
95
95
|
"stringify-object": "^5.0.0",
|
|
96
96
|
"ts-morph": "^26.0.0",
|
|
97
97
|
"tsconfig-paths": "^4.2.0",
|
|
98
|
-
"undici": "^7.29.
|
|
98
|
+
"undici": "^7.29.1",
|
|
99
99
|
"validate-npm-package-name": "^7.0.1",
|
|
100
100
|
"zod": "^3.24.1",
|
|
101
101
|
"zod-to-json-schema": "^3.24.6",
|
|
102
|
-
"@shadcn/registry": "0.1.
|
|
102
|
+
"@shadcn/registry": "0.1.4"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@antfu/ni": "^25.0.0",
|
package/dist/chunk-SILUCKGE.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';import {searchRegistries,getRegistryItems}from'@shadcn/registry';import {withRegistryContext}from'@shadcn/registry/internal/registry/context';import {RegistryError}from'@shadcn/registry/internal/registry/errors';import {SEARCHABLE_TYPES,resolveSearchRegistries,findUnknownSearchTypes}from'@shadcn/registry/internal/registry/search';import m from'dedent';import {z}from'zod';import {zodToJsonSchema}from'zod-to-json-schema';import {getRegistriesConfig}from'@shadcn/registry/internal/registry/api';import {getPackageRunner}from'@shadcn/registry/internal/utils/get-package-manager';var R="shadcn@latest";async function u(n){return `${await getPackageRunner(process.cwd())} ${R} ${n}`}async function l(n=process.cwd()){return {registries:(await getRegistriesConfig(n,{useCache:false})).registries}}function d(n,t){let{query:r,registries:i}=t||{},o=n.items.map(c=>{let g=[`- ${c.name}`];return c.type&&g.push(`(${c.type})`),c.description&&g.push(`- ${c.description}`),c.registry&&g.push(`[${c.registry}]`),g.push(`
|
|
2
|
-
Add command: \`${u(`add ${c.addCommandArgument}`)}\``),g.join(" ")}),a=`Found ${n.pagination.total} items`;r&&(a+=` matching "${r}"`),i&&i.length>0&&(a+=` in registries ${i.join(", ")}`),a+=":";let s=`Showing items ${n.pagination.offset+1}-${Math.min(n.pagination.offset+n.pagination.limit,n.pagination.total)} of ${n.pagination.total}:`,p=`${a}
|
|
3
|
-
|
|
4
|
-
${s}
|
|
5
|
-
|
|
6
|
-
${o.join(`
|
|
7
|
-
|
|
8
|
-
`)}`;return n.pagination.hasMore&&(p+=`
|
|
9
|
-
|
|
10
|
-
More items available. Use offset: ${n.pagination.offset+n.pagination.limit} to see the next page.`),p}function h(n){if(!n?.length)return null;let t=findUnknownSearchTypes(n);return t.length===0?null:`Unknown type${t.length===1?"":"s"}: ${t.join(", ")}. Valid types: ${SEARCHABLE_TYPES.join(", ")}.`}function y(n){if(!n.errors?.length)return "";let t=n.errors.map(r=>`- ${r.registry}: ${r.message}`);return `
|
|
11
|
-
|
|
12
|
-
Skipped ${n.errors.length} registr${n.errors.length===1?"y":"ies"} that failed to load:
|
|
13
|
-
${t.join(`
|
|
14
|
-
`)}`}function $(n){return n.map(t=>[`## ${t.name}`,t.description?`
|
|
15
|
-
${t.description}
|
|
16
|
-
`:"",t.type?`**Type:** ${t.type}`:"",t.files&&t.files.length>0?`**Files:** ${t.files.length} file(s)`:"",t.dependencies&&t.dependencies.length>0?`**Dependencies:** ${t.dependencies.join(", ")}`:"",t.devDependencies&&t.devDependencies.length>0?`**Dev Dependencies:** ${t.devDependencies.join(", ")}`:""].filter(Boolean).join(`
|
|
17
|
-
`))}function j(n,t){let r=n.map(o=>{let a=[`## Example: ${o.name}`,o.description?`
|
|
18
|
-
${o.description}
|
|
19
|
-
`:""];return o.files?.length&&o.files.forEach(s=>{s.content&&(a.push(`### Code (${s.path}):
|
|
20
|
-
`),a.push("```tsx"),a.push(s.content),a.push("```"));}),a.filter(Boolean).join(`
|
|
21
|
-
`)});return `# Usage Examples
|
|
22
|
-
|
|
23
|
-
Found ${n.length} example${n.length>1?"s":""} matching "${t}":
|
|
24
|
-
`+r.join(`
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
`)}var w=new Server({name:"shadcn",version:"1.0.0"},{capabilities:{logging:{},resources:{},tools:{}}});async function I(n){try{await w.sendLoggingMessage({level:"info",data:n});}catch{console.error(n);}}w.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"get_project_registries",description:"Get configured registry names from components.json - Returns error if no components.json exists (use init_project to create one)",inputSchema:zodToJsonSchema(z.object({}))},{name:"list_items_in_registries",description:"List items from registries (requires components.json - use init_project if missing)",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to list (e.g., ['@shadcn', '@acme']). Omit to list from every registry configured in components.json."),types:z.array(z.string()).optional().describe(`Filter by item type. One of: ${SEARCHABLE_TYPES.join(", ")}.`),limit:z.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"search_items_in_registries",description:"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.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z.string().describe("Search query string for fuzzy matching against item names and descriptions"),types:z.array(z.string()).optional().describe(`Filter by item type. One of: ${SEARCHABLE_TYPES.join(", ")}.`),limit:z.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"view_items_in_registries",description:"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.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of item names with registry prefix (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_item_examples_from_registries",description:"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.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z.string().describe("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}'")}))},{name:"get_add_command_for_items",description:"Get the shadcn CLI add command for specific items in a registry. This is useful for adding one or more components to your project.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of items to get the add command for prefixed with the registry name (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_audit_checklist",description:"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.",inputSchema:zodToJsonSchema(z.object({}))}]}));w.setRequestHandler(CallToolRequestSchema,async n=>withRegistryContext(()=>O(n),{onGitHubAuthNotice:I}));async function O(n){try{if(!n.params.arguments)throw new Error("No tool arguments provided.");switch(n.params.name){case "get_project_registries":{let t=await l(process.cwd());return t?.registries?{content:[{type:"text",text:m`The following registries are configured in the current project:
|
|
29
|
-
|
|
30
|
-
${Object.keys(t.registries).map(r=>`- ${r}`).join(`
|
|
31
|
-
`)}
|
|
32
|
-
|
|
33
|
-
You can view the items in a registry by running:
|
|
34
|
-
\`${await u("view @name-of-registry")}\`
|
|
35
|
-
|
|
36
|
-
For example: \`${await u("view @shadcn")}\` or \`${await u("view @shadcn @acme")}\` to view multiple registries.
|
|
37
|
-
`}]}:{content:[{type:"text",text:m`No components.json found or no registries configured.
|
|
38
|
-
|
|
39
|
-
To fix this:
|
|
40
|
-
1. Use the \`init\` command to create a components.json file
|
|
41
|
-
2. Or manually create components.json with a registries section`}]}}case "search_items_in_registries":{let r=z.object({registries:z.array(z.string()).optional(),query:z.string(),types:z.array(z.string()).optional(),limit:z.number().optional(),offset:z.number().optional()}).parse(n.params.arguments),i=h(r.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await l(process.cwd()),a=!r.registries?.length,s=resolveSearchRegistries(r.registries??[],o);if(s.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let p=await searchRegistries(s,{query:r.query,types:r.types,limit:r.limit??100,offset:r.offset,config:o,useCache:!1,continueOnError:a}),c=y(p);return p.items.length===0?{content:[{type:"text",text:m`No items found matching "${r.query}" in registries ${s.join(", ")}, Try searching with a different query or registry.${c}`}]}:{content:[{type:"text",text:d(p,{query:r.query,registries:s})+c}]}}case "list_items_in_registries":{let r=z.object({registries:z.array(z.string()).optional(),types:z.array(z.string()).optional(),limit:z.number().optional(),offset:z.number().optional(),cwd:z.string().optional()}).parse(n.params.arguments),i=h(r.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await l(process.cwd()),a=!r.registries?.length,s=resolveSearchRegistries(r.registries??[],o);if(s.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let p=await searchRegistries(s,{types:r.types,limit:r.limit??100,offset:r.offset,config:o,useCache:!1,continueOnError:a}),c=y(p);return p.items.length===0?{content:[{type:"text",text:m`No items found in registries ${s.join(", ")}.${c}`}]}:{content:[{type:"text",text:d(p,{registries:s})+c}]}}case "view_items_in_registries":{let r=z.object({items:z.array(z.string())}).parse(n.params.arguments),i=await getRegistryItems(r.items,{config:await l(process.cwd()),useCache:!1});if(i?.length===0)return {content:[{type:"text",text:m`No items found for: ${r.items.join(", ")}
|
|
42
|
-
|
|
43
|
-
Make sure the item names are correct and include the registry prefix (e.g., @shadcn/button).`}]};let o=$(i);return {content:[{type:"text",text:m`Item Details:
|
|
44
|
-
|
|
45
|
-
${o.join(`
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
`)}`}]}}case "get_item_examples_from_registries":{let r=z.object({query:z.string(),registries:z.array(z.string()).optional()}).parse(n.params.arguments),i=await l(),o=!r.registries?.length,a=resolveSearchRegistries(r.registries??[],i);if(a.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let s=await searchRegistries(a,{query:r.query,config:i,useCache:!1,continueOnError:o});if(s.items.length===0)return {content:[{type:"text",text:m`No examples found for query "${r.query}".
|
|
50
|
-
|
|
51
|
-
Try searching with patterns like:
|
|
52
|
-
- "accordion-demo" for accordion examples
|
|
53
|
-
- "button demo" or "button example"
|
|
54
|
-
- Component name followed by "-demo" or "example"
|
|
55
|
-
|
|
56
|
-
You can also:
|
|
57
|
-
1. Use search_items_in_registries to find all items matching your query
|
|
58
|
-
2. View the main component with view_items_in_registries for inline usage documentation`}]};let p=s.items.map(g=>g.addCommandArgument),c=await getRegistryItems(p,{config:i,useCache:!1});return {content:[{type:"text",text:j(c,r.query)}]}}case "get_add_command_for_items":{let t=z.object({items:z.array(z.string())}).parse(n.params.arguments);return {content:[{type:"text",text:await u(`add ${t.items.join(" ")}`)}]}}case "get_audit_checklist":return {content:[{type:"text",text:m`## Component Audit Checklist
|
|
59
|
-
|
|
60
|
-
After adding or generating components, check the following common issues:
|
|
61
|
-
|
|
62
|
-
- [ ] Ensure imports are correct i.e named vs default imports
|
|
63
|
-
- [ ] If using next/image, ensure images.remotePatterns next.config.js is configured correctly.
|
|
64
|
-
- [ ] Ensure all dependencies are installed.
|
|
65
|
-
- [ ] Check for linting errors or warnings
|
|
66
|
-
- [ ] Check for TypeScript errors
|
|
67
|
-
- [ ] Use the Playwright MCP if available.
|
|
68
|
-
`}]};default:throw new Error(`Tool ${n.params.name} not found`)}}catch(t){if(t instanceof z.ZodError)return {content:[{type:"text",text:m`Invalid input parameters:
|
|
69
|
-
${t.errors.map(i=>`- ${i.path.join(".")}: ${i.message}`).join(`
|
|
70
|
-
`)}
|
|
71
|
-
`}],isError:true};if(t instanceof RegistryError){let i=t.message;return t.suggestion&&(i+=`
|
|
72
|
-
|
|
73
|
-
\u{1F4A1} ${t.suggestion}`),t.context&&(i+=`
|
|
74
|
-
|
|
75
|
-
Context: ${JSON.stringify(t.context,null,2)}`),{content:[{type:"text",text:m`Error (${t.code}): ${i}`}],isError:true}}let r=t instanceof Error?t.message:String(t);return {content:[{type:"text",text:m`Error: ${r}`}],isError:true}}}export{w as a};
|