shadcn 4.21.5 → 4.22.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.
@@ -1,4 +1,4 @@
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(`
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 {getPackageRunner}from'@shadcn/registry/internal/get-package-manager';import {getRegistriesConfig}from'@shadcn/registry/internal/registry/api';var A="shadcn@latest";async function f(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 f("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
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
3
 
4
4
  ${m}
@@ -25,15 +25,15 @@ Found ${n.length} example${n.length>1?"s":""} matching "${t}":
25
25
 
26
26
  ---
27
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:
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);}}function u(n){return z$1.toJSONSchema(n,{target:"draft-7"})}$.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:u(z$1.object({}))},{name:"list_items_in_registries",description:"List items from registries (requires components.json - use init_project if missing)",inputSchema:u(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:u(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:u(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:u(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:u(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:u(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
29
 
30
30
  ${Object.keys(t.registries).map(r=>`- ${r}`).join(`
31
31
  `)}
32
32
 
33
33
  You can view the items in a registry by running:
34
- \`${await u("view @name-of-registry")}\`
34
+ \`${await f("view @name-of-registry")}\`
35
35
 
36
- For example: \`${await u("view @shadcn")}\` or \`${await u("view @shadcn @acme")}\` to view multiple registries.
36
+ For example: \`${await f("view @shadcn")}\` or \`${await f("view @shadcn @acme")}\` to view multiple registries.
37
37
  `}]}:{content:[{type:"text",text:c`No components.json found or no registries configured.
38
38
 
39
39
  To fix this:
@@ -55,7 +55,7 @@ Found ${n.length} example${n.length>1?"s":""} matching "${t}":
55
55
 
56
56
  You can also:
57
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
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 f(`add ${t.items.join(" ")}`)}]}}case "get_audit_checklist":return {content:[{type:"text",text:c`## Component Audit Checklist
59
59
 
60
60
  After adding or generating components, check the following common issues:
61
61
 
@@ -66,7 +66,7 @@ Found ${n.length} example${n.length>1?"s":""} matching "${t}":
66
66
  - [ ] Check for TypeScript errors
67
67
  - [ ] Use the Playwright MCP if available.
68
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(`
69
+ ${t.issues.map(i=>`- ${i.path.join(".")}: ${i.message}`).join(`
70
70
  `)}
71
71
  `}],isError:true};if(t instanceof RegistryError){let i=t.message;return t.suggestion&&(i+=`
72
72
 
package/dist/index.d.ts CHANGED
@@ -12,46 +12,9 @@ declare function getRegistryIcons(): Promise<Record<string, Record<string, strin
12
12
  * @deprecated This function is deprecated and will be removed in a future version.
13
13
  */
14
14
  declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSchema>): Promise<({
15
- type: "registry:base";
16
15
  name: string;
16
+ type: "registry:base";
17
17
  $schema?: string | undefined;
18
- tailwind?: {
19
- config?: {
20
- content?: string[] | undefined;
21
- theme?: Record<string, any> | undefined;
22
- plugins?: string[] | undefined;
23
- } | undefined;
24
- } | undefined;
25
- config?: {
26
- $schema?: string | undefined;
27
- style?: string | undefined;
28
- rsc?: boolean | undefined;
29
- tsx?: boolean | undefined;
30
- tailwind?: {
31
- config?: string | undefined;
32
- css?: string | undefined;
33
- baseColor?: string | undefined;
34
- cssVariables?: boolean | undefined;
35
- prefix?: string | undefined;
36
- } | undefined;
37
- iconLibrary?: string | undefined;
38
- rtl?: boolean | undefined;
39
- menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
40
- menuAccent?: "subtle" | "bold" | undefined;
41
- aliases?: {
42
- components?: string | undefined;
43
- utils?: string | undefined;
44
- ui?: string | undefined;
45
- lib?: string | undefined;
46
- hooks?: string | undefined;
47
- } | undefined;
48
- registries?: Record<string, string | {
49
- url: string;
50
- params?: Record<string, string> | undefined;
51
- headers?: Record<string, string> | undefined;
52
- }> | undefined;
53
- } | undefined;
54
- css?: Record<string, any> | undefined;
55
18
  extends?: string | undefined;
56
19
  title?: string | undefined;
57
20
  author?: string | undefined;
@@ -66,22 +29,59 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
66
29
  content?: string | undefined;
67
30
  } | {
68
31
  path: string;
69
- type: "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:style" | "registry:item" | "registry:base" | "registry:font" | "registry:example" | "registry:internal";
32
+ type: "registry:base" | "registry:font" | "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:style" | "registry:item" | "registry:example" | "registry:internal";
70
33
  content?: string | undefined;
71
34
  target?: string | undefined;
72
35
  })[] | undefined;
36
+ tailwind?: {
37
+ config?: {
38
+ content?: string[] | undefined;
39
+ theme?: Record<string, any> | undefined;
40
+ plugins?: string[] | undefined;
41
+ } | undefined;
42
+ } | undefined;
73
43
  cssVars?: {
74
44
  theme?: Record<string, string> | undefined;
75
45
  light?: Record<string, string> | undefined;
76
46
  dark?: Record<string, string> | undefined;
77
47
  } | undefined;
48
+ css?: Record<string, any> | undefined;
78
49
  envVars?: Record<string, string> | undefined;
79
50
  meta?: Record<string, any> | undefined;
80
51
  docs?: string | undefined;
81
52
  categories?: string[] | undefined;
53
+ config?: {
54
+ $schema?: string | undefined;
55
+ style?: string | undefined;
56
+ iconLibrary?: string | undefined;
57
+ rtl?: boolean | undefined;
58
+ menuColor?: "default" | "inverted" | "default-translucent" | "inverted-translucent" | undefined;
59
+ menuAccent?: "subtle" | "bold" | undefined;
60
+ registries?: Record<string, string | {
61
+ url: string;
62
+ params?: Record<string, string> | undefined;
63
+ headers?: Record<string, string> | undefined;
64
+ }> | undefined;
65
+ rsc?: boolean | undefined;
66
+ tsx?: boolean | undefined;
67
+ tailwind?: {
68
+ config?: string | undefined;
69
+ css?: string | undefined;
70
+ baseColor?: string | undefined;
71
+ prefix?: string | undefined;
72
+ cssVariables?: boolean | undefined;
73
+ } | undefined;
74
+ aliases?: {
75
+ components?: string | undefined;
76
+ utils?: string | undefined;
77
+ ui?: string | undefined;
78
+ lib?: string | undefined;
79
+ hooks?: string | undefined;
80
+ } | undefined;
81
+ } | undefined;
82
82
  } | {
83
- type: "registry:font";
84
83
  name: string;
84
+ type: "registry:font";
85
85
  font: {
86
86
  family: string;
87
87
  provider: "google";
@@ -93,14 +93,6 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
93
93
  dependency?: string | undefined;
94
94
  };
95
95
  $schema?: string | undefined;
96
- tailwind?: {
97
- config?: {
98
- content?: string[] | undefined;
99
- theme?: Record<string, any> | undefined;
100
- plugins?: string[] | undefined;
101
- } | undefined;
102
- } | undefined;
103
- css?: Record<string, any> | undefined;
104
96
  extends?: string | undefined;
105
97
  title?: string | undefined;
106
98
  author?: string | undefined;
@@ -115,31 +107,31 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
115
107
  content?: string | undefined;
116
108
  } | {
117
109
  path: string;
118
- type: "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:style" | "registry:item" | "registry:base" | "registry:font" | "registry:example" | "registry:internal";
110
+ type: "registry:base" | "registry:font" | "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:style" | "registry:item" | "registry:example" | "registry:internal";
119
111
  content?: string | undefined;
120
112
  target?: string | undefined;
121
113
  })[] | undefined;
114
+ tailwind?: {
115
+ config?: {
116
+ content?: string[] | undefined;
117
+ theme?: Record<string, any> | undefined;
118
+ plugins?: string[] | undefined;
119
+ } | undefined;
120
+ } | undefined;
122
121
  cssVars?: {
123
122
  theme?: Record<string, string> | undefined;
124
123
  light?: Record<string, string> | undefined;
125
124
  dark?: Record<string, string> | undefined;
126
125
  } | undefined;
126
+ css?: Record<string, any> | undefined;
127
127
  envVars?: Record<string, string> | undefined;
128
128
  meta?: Record<string, any> | undefined;
129
129
  docs?: string | undefined;
130
130
  categories?: string[] | undefined;
131
131
  } | {
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
132
  name: string;
133
+ 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";
134
134
  $schema?: string | undefined;
135
- tailwind?: {
136
- config?: {
137
- content?: string[] | undefined;
138
- theme?: Record<string, any> | undefined;
139
- plugins?: string[] | undefined;
140
- } | undefined;
141
- } | undefined;
142
- css?: Record<string, any> | undefined;
143
135
  extends?: string | undefined;
144
136
  title?: string | undefined;
145
137
  author?: string | undefined;
@@ -154,15 +146,23 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
154
146
  content?: string | undefined;
155
147
  } | {
156
148
  path: string;
157
- type: "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:style" | "registry:item" | "registry:base" | "registry:font" | "registry:example" | "registry:internal";
149
+ type: "registry:base" | "registry:font" | "registry:lib" | "registry:block" | "registry:component" | "registry:ui" | "registry:hook" | "registry:theme" | "registry:style" | "registry:item" | "registry:example" | "registry:internal";
158
150
  content?: string | undefined;
159
151
  target?: string | undefined;
160
152
  })[] | undefined;
153
+ tailwind?: {
154
+ config?: {
155
+ content?: string[] | undefined;
156
+ theme?: Record<string, any> | undefined;
157
+ plugins?: string[] | undefined;
158
+ } | undefined;
159
+ } | undefined;
161
160
  cssVars?: {
162
161
  theme?: Record<string, string> | undefined;
163
162
  light?: Record<string, string> | undefined;
164
163
  dark?: Record<string, string> | undefined;
165
164
  } | undefined;
165
+ css?: Record<string, any> | undefined;
166
166
  envVars?: Record<string, string> | undefined;
167
167
  meta?: Record<string, any> | undefined;
168
168
  docs?: string | undefined;