@uidbai/mcp-server 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +164 -62
  2. package/dist/cli.js +0 -0
  3. package/dist/core/local-fs.d.ts +174 -0
  4. package/dist/core/local-fs.d.ts.map +1 -0
  5. package/dist/core/local-fs.js +263 -0
  6. package/dist/core/local-fs.js.map +1 -0
  7. package/dist/templates/index.d.ts +22 -0
  8. package/dist/templates/index.d.ts.map +1 -0
  9. package/dist/templates/index.js +19 -0
  10. package/dist/templates/index.js.map +1 -0
  11. package/dist/templates/minimal.d.ts +9 -0
  12. package/dist/templates/minimal.d.ts.map +1 -0
  13. package/dist/templates/minimal.js +115 -0
  14. package/dist/templates/minimal.js.map +1 -0
  15. package/dist/templates/standard.d.ts +9 -0
  16. package/dist/templates/standard.d.ts.map +1 -0
  17. package/dist/templates/standard.js +527 -0
  18. package/dist/templates/standard.js.map +1 -0
  19. package/dist/tools/detect-pattern.d.ts +8 -5
  20. package/dist/tools/detect-pattern.d.ts.map +1 -1
  21. package/dist/tools/detect-pattern.js +151 -18
  22. package/dist/tools/detect-pattern.js.map +1 -1
  23. package/dist/tools/get-config.d.ts +1 -1
  24. package/dist/tools/get-config.d.ts.map +1 -1
  25. package/dist/tools/get-config.js +45 -10
  26. package/dist/tools/get-config.js.map +1 -1
  27. package/dist/tools/guide.d.ts +65 -0
  28. package/dist/tools/guide.d.ts.map +1 -0
  29. package/dist/tools/guide.js +304 -0
  30. package/dist/tools/guide.js.map +1 -0
  31. package/dist/tools/index.d.ts +4 -5
  32. package/dist/tools/index.d.ts.map +1 -1
  33. package/dist/tools/index.js +4 -5
  34. package/dist/tools/index.js.map +1 -1
  35. package/dist/tools/init.d.ts +73 -0
  36. package/dist/tools/init.d.ts.map +1 -0
  37. package/dist/tools/init.js +211 -0
  38. package/dist/tools/init.js.map +1 -0
  39. package/dist/tools/list-components.d.ts +18 -3
  40. package/dist/tools/list-components.d.ts.map +1 -1
  41. package/dist/tools/list-components.js +86 -11
  42. package/dist/tools/list-components.js.map +1 -1
  43. package/dist/tools/list-patterns.d.ts +18 -3
  44. package/dist/tools/list-patterns.d.ts.map +1 -1
  45. package/dist/tools/list-patterns.js +85 -10
  46. package/dist/tools/list-patterns.js.map +1 -1
  47. package/dist/tools/registry.d.ts +1 -1
  48. package/dist/tools/registry.d.ts.map +1 -1
  49. package/dist/tools/registry.js +14 -15
  50. package/dist/tools/registry.js.map +1 -1
  51. package/dist/tools/status.d.ts +1 -1
  52. package/dist/tools/status.d.ts.map +1 -1
  53. package/dist/tools/status.js +54 -42
  54. package/dist/tools/status.js.map +1 -1
  55. package/dist/tools/submit-pattern.d.ts +13 -11
  56. package/dist/tools/submit-pattern.d.ts.map +1 -1
  57. package/dist/tools/submit-pattern.js +90 -19
  58. package/dist/tools/submit-pattern.js.map +1 -1
  59. package/dist/tools/update-config.d.ts +16 -8
  60. package/dist/tools/update-config.d.ts.map +1 -1
  61. package/dist/tools/update-config.js +93 -39
  62. package/dist/tools/update-config.js.map +1 -1
  63. package/package.json +1 -1
@@ -0,0 +1,304 @@
1
+ /**
2
+ * UIDB MCP Tool: uidb_guide
3
+ *
4
+ * Unified component guidance tool. Replaces the multi-step ask_intent/ask_question/finalize flow.
5
+ * Reads local .uidb/ files and optionally calls UIDB API for LLM-powered recommendations.
6
+ */
7
+ import { readComponent, readPattern, getDesignSystemSummary, UIDBNotFoundError, } from "../core/local-fs.js";
8
+ import { apiClient } from "../core/api-client.js";
9
+ export const guideTool = {
10
+ name: "uidb_guide",
11
+ description: `Get component guidance for building UI.
12
+
13
+ Analyzes your request against the local design system (.uidb/) and returns:
14
+ - Recommended components with props and examples
15
+ - Matching patterns if available
16
+ - Theme configuration to use
17
+ - Design guidelines to follow
18
+
19
+ This is the primary tool for UI development. Use before building any UI component.
20
+
21
+ Example:
22
+ uidb_guide({ description: "user profile card with avatar and status badge" })`,
23
+ inputSchema: {
24
+ type: "object",
25
+ properties: {
26
+ description: {
27
+ type: "string",
28
+ description: "Describe the UI you want to build",
29
+ },
30
+ context: {
31
+ type: "object",
32
+ properties: {
33
+ file: {
34
+ type: "string",
35
+ description: "Current file being edited",
36
+ },
37
+ existing_components: {
38
+ type: "array",
39
+ items: { type: "string" },
40
+ description: "Components already imported in the file",
41
+ },
42
+ },
43
+ description: "Optional context about the current file",
44
+ },
45
+ use_llm: {
46
+ type: "boolean",
47
+ description: "Use UIDB API for enhanced LLM guidance (default: true)",
48
+ default: true,
49
+ },
50
+ },
51
+ required: ["description"],
52
+ },
53
+ async execute(args) {
54
+ try {
55
+ // Get design system context
56
+ const summary = await getDesignSystemSummary();
57
+ // Try LLM guidance first if enabled
58
+ if (args.use_llm !== false) {
59
+ try {
60
+ const llmResult = await getLLMGuidance(args.description, summary, args.context);
61
+ return {
62
+ content: [
63
+ {
64
+ type: "text",
65
+ text: JSON.stringify(llmResult, null, 2),
66
+ },
67
+ ],
68
+ };
69
+ }
70
+ catch (llmError) {
71
+ // Fall back to local guidance if API fails
72
+ console.error("LLM guidance failed, falling back to local:", llmError);
73
+ }
74
+ }
75
+ // Local guidance (rule-based matching)
76
+ const result = await getLocalGuidance(args.description, summary);
77
+ return {
78
+ content: [
79
+ {
80
+ type: "text",
81
+ text: JSON.stringify(result, null, 2),
82
+ },
83
+ ],
84
+ };
85
+ }
86
+ catch (error) {
87
+ if (error instanceof UIDBNotFoundError) {
88
+ return {
89
+ content: [
90
+ {
91
+ type: "text",
92
+ text: JSON.stringify({
93
+ error: "NOT_INITIALIZED",
94
+ message: "No .uidb folder found. Run uidb_init first.",
95
+ }, null, 2),
96
+ },
97
+ ],
98
+ isError: true,
99
+ };
100
+ }
101
+ return {
102
+ content: [
103
+ {
104
+ type: "text",
105
+ text: JSON.stringify({
106
+ error: "GUIDE_FAILED",
107
+ message: error instanceof Error
108
+ ? error.message
109
+ : "Failed to get guidance",
110
+ }, null, 2),
111
+ },
112
+ ],
113
+ isError: true,
114
+ };
115
+ }
116
+ },
117
+ };
118
+ /**
119
+ * Get guidance from UIDB API (LLM-powered)
120
+ */
121
+ async function getLLMGuidance(description, summary, context) {
122
+ const response = await apiClient.post("/api/guide", {
123
+ description,
124
+ design_system: {
125
+ components: summary.components.map((c) => ({
126
+ id: c.id,
127
+ name: c.name,
128
+ category: c.category,
129
+ })),
130
+ patterns: summary.patterns.map((p) => ({
131
+ id: p.id,
132
+ name: p.name,
133
+ category: p.category,
134
+ })),
135
+ config: summary.config.theme,
136
+ },
137
+ context,
138
+ });
139
+ return response.guidance;
140
+ }
141
+ /**
142
+ * Get guidance using local rule-based matching
143
+ */
144
+ async function getLocalGuidance(description, summary) {
145
+ const descLower = description.toLowerCase();
146
+ // Find matching components based on keywords
147
+ const matchedComponents = [];
148
+ for (const component of summary.components) {
149
+ let score = 0;
150
+ // Check if component name or id is mentioned
151
+ if (descLower.includes(component.id.toLowerCase()))
152
+ score += 10;
153
+ if (descLower.includes(component.name.toLowerCase()))
154
+ score += 10;
155
+ // Check category keywords
156
+ const categoryKeywords = {
157
+ interaction: ["button", "click", "action", "submit", "cancel"],
158
+ form: ["input", "field", "form", "text", "select", "checkbox", "switch", "toggle"],
159
+ layout: ["card", "container", "section", "box", "grid", "flex"],
160
+ navigation: ["menu", "nav", "tab", "link", "dropdown"],
161
+ overlay: ["modal", "dialog", "popup", "popover", "tooltip"],
162
+ feedback: ["alert", "message", "notification", "callout", "toast"],
163
+ "data-display": ["badge", "avatar", "status", "label", "tag"],
164
+ };
165
+ const keywords = categoryKeywords[component.category] || [];
166
+ for (const keyword of keywords) {
167
+ if (descLower.includes(keyword))
168
+ score += 5;
169
+ }
170
+ if (score > 0) {
171
+ matchedComponents.push({ entry: component, score });
172
+ }
173
+ }
174
+ // Sort by score and take top matches
175
+ matchedComponents.sort((a, b) => b.score - a.score);
176
+ const topComponents = matchedComponents.slice(0, 5);
177
+ // Load full details for matched components
178
+ const recommendedComponents = await Promise.all(topComponents.map(async ({ entry }) => {
179
+ try {
180
+ const details = await readComponent(entry.id);
181
+ return {
182
+ id: entry.id,
183
+ name: entry.name,
184
+ reason: `Matches your request for ${entry.category} functionality`,
185
+ props_to_use: getRecommendedProps(details, descLower),
186
+ example: details.examples
187
+ ? Object.values(details.examples)[0] || ""
188
+ : "",
189
+ };
190
+ }
191
+ catch {
192
+ return {
193
+ id: entry.id,
194
+ name: entry.name,
195
+ reason: `Matches your request`,
196
+ props_to_use: {},
197
+ example: "",
198
+ };
199
+ }
200
+ }));
201
+ // Find matching patterns
202
+ const matchedPatterns = [];
203
+ for (const pattern of summary.patterns) {
204
+ let score = 0;
205
+ if (descLower.includes(pattern.id.toLowerCase()))
206
+ score += 10;
207
+ if (descLower.includes(pattern.name.toLowerCase()))
208
+ score += 10;
209
+ // Check description keywords
210
+ const patternKeywords = pattern.description.toLowerCase().split(" ");
211
+ for (const keyword of patternKeywords) {
212
+ if (keyword.length > 3 && descLower.includes(keyword))
213
+ score += 2;
214
+ }
215
+ if (score > 0) {
216
+ matchedPatterns.push({ entry: pattern, score });
217
+ }
218
+ }
219
+ matchedPatterns.sort((a, b) => b.score - a.score);
220
+ const topPatterns = matchedPatterns.slice(0, 3);
221
+ // Load pattern details
222
+ const recommendedPatterns = await Promise.all(topPatterns.map(async ({ entry }) => {
223
+ try {
224
+ const details = await readPattern(entry.id);
225
+ const firstVariant = Object.entries(details.variants)[0];
226
+ return {
227
+ id: entry.id,
228
+ name: entry.name,
229
+ reason: `Matches your UI pattern requirement`,
230
+ variant: firstVariant?.[0] || "default",
231
+ code: firstVariant?.[1]?.code || "",
232
+ };
233
+ }
234
+ catch {
235
+ return {
236
+ id: entry.id,
237
+ name: entry.name,
238
+ reason: `Matches your pattern`,
239
+ variant: "default",
240
+ code: "",
241
+ };
242
+ }
243
+ }));
244
+ // Build guidelines based on components
245
+ const guidelines = [
246
+ `Use accent color "${summary.config.theme.accentColor}" for primary actions`,
247
+ `Use gray color "gray" for secondary/cancel actions`,
248
+ `Apply radius "${summary.config.theme.radius}" via Radix Theme`,
249
+ ];
250
+ if (descLower.includes("form") || descLower.includes("input")) {
251
+ guidelines.push("Always use visible labels for form inputs");
252
+ guidelines.push("Provide clear error messages for validation");
253
+ }
254
+ if (descLower.includes("button") || descLower.includes("action")) {
255
+ guidelines.push("Use solid variant for primary actions, soft for secondary");
256
+ guidelines.push("Icon-only buttons require aria-label");
257
+ }
258
+ if (descLower.includes("dialog") || descLower.includes("modal")) {
259
+ guidelines.push("Always include Dialog.Title for accessibility");
260
+ guidelines.push("Place cancel button left of primary action");
261
+ }
262
+ return {
263
+ recommended_components: recommendedComponents,
264
+ recommended_patterns: recommendedPatterns,
265
+ theme: {
266
+ accentColor: summary.config.theme.accentColor,
267
+ grayColor: summary.config.theme.grayColor,
268
+ radius: summary.config.theme.radius,
269
+ },
270
+ guidelines,
271
+ };
272
+ }
273
+ /**
274
+ * Get recommended props based on description keywords
275
+ */
276
+ function getRecommendedProps(component, description) {
277
+ const props = {};
278
+ // Check semantic intents
279
+ if (component.semantic_intents) {
280
+ for (const [intent, config] of Object.entries(component.semantic_intents)) {
281
+ const intentConfig = config;
282
+ if (intentConfig.use_for) {
283
+ for (const useCase of intentConfig.use_for) {
284
+ if (description.includes(useCase.toLowerCase())) {
285
+ if (intentConfig.color)
286
+ props.color = intentConfig.color;
287
+ if (intentConfig.variant)
288
+ props.variant = intentConfig.variant;
289
+ break;
290
+ }
291
+ }
292
+ }
293
+ }
294
+ }
295
+ // Check for size keywords
296
+ if (description.includes("small") || description.includes("compact")) {
297
+ props.size = "1";
298
+ }
299
+ else if (description.includes("large") || description.includes("hero")) {
300
+ props.size = "4";
301
+ }
302
+ return props;
303
+ }
304
+ //# sourceMappingURL=guide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guide.js","sourceRoot":"","sources":["../../src/tools/guide.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGL,aAAa,EAEb,WAAW,EACX,sBAAsB,EACtB,iBAAiB,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OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -2,17 +2,16 @@
2
2
  * UIDB MCP Server - Tools Module
3
3
  *
4
4
  * Re-exports tool registry and all tools.
5
+ * Tools operate on the local .uidb folder (embedded design system).
5
6
  */
6
7
  export * from "./registry.js";
7
- export { askIntentTool } from "./ask-intent.js";
8
- export { askQuestionTool } from "./ask-question.js";
9
- export { finalizeTool } from "./finalize.js";
8
+ export { initTool } from "./init.js";
9
+ export { guideTool } from "./guide.js";
10
10
  export { listComponentsTool } from "./list-components.js";
11
+ export { listPatternsTool } from "./list-patterns.js";
11
12
  export { detectPatternTool } from "./detect-pattern.js";
12
13
  export { submitPatternTool } from "./submit-pattern.js";
13
- export { listPatternsTool } from "./list-patterns.js";
14
14
  export { getConfigTool } from "./get-config.js";
15
15
  export { updateConfigTool } from "./update-config.js";
16
- export { loginTool } from "./login.js";
17
16
  export { statusTool } from "./status.js";
18
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -2,18 +2,17 @@
2
2
  * UIDB MCP Server - Tools Module
3
3
  *
4
4
  * Re-exports tool registry and all tools.
5
+ * Tools operate on the local .uidb folder (embedded design system).
5
6
  */
6
7
  export * from "./registry.js";
7
8
  // Individual tool exports for direct access if needed
8
- export { askIntentTool } from "./ask-intent.js";
9
- export { askQuestionTool } from "./ask-question.js";
10
- export { finalizeTool } from "./finalize.js";
9
+ export { initTool } from "./init.js";
10
+ export { guideTool } from "./guide.js";
11
11
  export { listComponentsTool } from "./list-components.js";
12
+ export { listPatternsTool } from "./list-patterns.js";
12
13
  export { detectPatternTool } from "./detect-pattern.js";
13
14
  export { submitPatternTool } from "./submit-pattern.js";
14
- export { listPatternsTool } from "./list-patterns.js";
15
15
  export { getConfigTool } from "./get-config.js";
16
16
  export { updateConfigTool } from "./update-config.js";
17
- export { loginTool } from "./login.js";
18
17
  export { statusTool } from "./status.js";
19
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAC;AAE9B,sDAAsD;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAE9B,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * UIDB MCP Tool: uidb_init
3
+ *
4
+ * Initialize a new .uidb design system folder in the current project.
5
+ */
6
+ import { TemplateType } from "../templates/index.js";
7
+ interface InitInput {
8
+ project_name: string;
9
+ template?: TemplateType;
10
+ accent_color?: string;
11
+ gray_color?: string;
12
+ radius?: string;
13
+ appearance?: "light" | "dark";
14
+ }
15
+ export declare const initTool: {
16
+ name: string;
17
+ description: string;
18
+ inputSchema: {
19
+ type: "object";
20
+ properties: {
21
+ project_name: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ template: {
26
+ type: string;
27
+ enum: string[];
28
+ description: string;
29
+ default: string;
30
+ };
31
+ accent_color: {
32
+ type: string;
33
+ enum: readonly ["gray", "gold", "bronze", "brown", "yellow", "amber", "orange", "tomato", "red", "ruby", "crimson", "pink", "plum", "purple", "violet", "iris", "indigo", "blue", "cyan", "teal", "jade", "green", "grass", "lime", "mint", "sky"];
34
+ description: string;
35
+ default: string;
36
+ };
37
+ gray_color: {
38
+ type: string;
39
+ enum: readonly ["gray", "mauve", "slate", "sage", "olive", "sand"];
40
+ description: string;
41
+ default: string;
42
+ };
43
+ radius: {
44
+ type: string;
45
+ enum: readonly ["none", "small", "medium", "large", "full"];
46
+ description: string;
47
+ default: string;
48
+ };
49
+ appearance: {
50
+ type: string;
51
+ enum: string[];
52
+ description: string;
53
+ default: string;
54
+ };
55
+ };
56
+ required: string[];
57
+ };
58
+ execute(args: InitInput): Promise<{
59
+ content: {
60
+ type: "text";
61
+ text: string;
62
+ }[];
63
+ isError: boolean;
64
+ } | {
65
+ content: {
66
+ type: "text";
67
+ text: string;
68
+ }[];
69
+ isError?: undefined;
70
+ }>;
71
+ };
72
+ export {};
73
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/tools/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAe,YAAY,EAAkB,MAAM,uBAAuB,CAAC;AASlF,UAAU,SAAS;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0DC,SAAS;;;;;;;;;;;;;CAwK9B,CAAC"}
@@ -0,0 +1,211 @@
1
+ /**
2
+ * UIDB MCP Tool: uidb_init
3
+ *
4
+ * Initialize a new .uidb design system folder in the current project.
5
+ */
6
+ import { uidbExists, initUIDB } from "../core/local-fs.js";
7
+ import { getTemplate } from "../templates/index.js";
8
+ import { VALID_ACCENT_COLORS, VALID_GRAY_COLORS, VALID_RADIUS_VALUES, } from "../core/types.js";
9
+ import { loadCredentials } from "../core/auth.js";
10
+ import { apiClient } from "../core/api-client.js";
11
+ export const initTool = {
12
+ name: "uidb_init",
13
+ description: `Initialize a new UIDB design system in the current project.
14
+
15
+ Creates a .uidb/ folder with:
16
+ - manifest.json: Project metadata
17
+ - config.json: Theme configuration (accent color, radius, etc.)
18
+ - components/: Component definitions
19
+ - patterns/: Reusable UI patterns
20
+ - rules/: Accessibility and design constraints
21
+
22
+ Templates:
23
+ - "minimal": Just config and empty indices (build your own)
24
+ - "standard": Full set of Radix UI components and common patterns (recommended)
25
+
26
+ After initialization, use uidb_guide for component guidance.`,
27
+ inputSchema: {
28
+ type: "object",
29
+ properties: {
30
+ project_name: {
31
+ type: "string",
32
+ description: "Name of the project (e.g., 'My App')",
33
+ },
34
+ template: {
35
+ type: "string",
36
+ enum: ["minimal", "standard"],
37
+ description: "Template to use. 'standard' is recommended for most projects.",
38
+ default: "standard",
39
+ },
40
+ accent_color: {
41
+ type: "string",
42
+ enum: VALID_ACCENT_COLORS,
43
+ description: "Primary accent color for the theme",
44
+ default: "blue",
45
+ },
46
+ gray_color: {
47
+ type: "string",
48
+ enum: VALID_GRAY_COLORS,
49
+ description: "Gray color palette for neutral elements",
50
+ default: "slate",
51
+ },
52
+ radius: {
53
+ type: "string",
54
+ enum: VALID_RADIUS_VALUES,
55
+ description: "Border radius scale for components",
56
+ default: "medium",
57
+ },
58
+ appearance: {
59
+ type: "string",
60
+ enum: ["light", "dark"],
61
+ description: "Default color scheme",
62
+ default: "light",
63
+ },
64
+ },
65
+ required: ["project_name"],
66
+ },
67
+ async execute(args) {
68
+ try {
69
+ // Check if .uidb already exists
70
+ if (await uidbExists()) {
71
+ return {
72
+ content: [
73
+ {
74
+ type: "text",
75
+ text: JSON.stringify({
76
+ error: "ALREADY_EXISTS",
77
+ message: "A .uidb folder already exists in this project. Use uidb_get_config to view the current configuration.",
78
+ }, null, 2),
79
+ },
80
+ ],
81
+ isError: true,
82
+ };
83
+ }
84
+ // Try to fetch project config from portal if authenticated
85
+ let config;
86
+ let projectName = args.project_name;
87
+ let fetchedFromPortal = false;
88
+ try {
89
+ const credentials = await loadCredentials();
90
+ if (credentials) {
91
+ // Fetch project config from portal
92
+ const projectData = await apiClient.get(`/api/projects/${credentials.projectId}`);
93
+ if (projectData?.config) {
94
+ config = {
95
+ accentColor: projectData.config.accentColor || "blue",
96
+ grayColor: projectData.config.grayColor || "slate",
97
+ radius: projectData.config.radius || "medium",
98
+ appearance: projectData.config.appearance || "light",
99
+ };
100
+ projectName = projectData.name || args.project_name;
101
+ fetchedFromPortal = true;
102
+ // Register connection with portal by updating onboarding step
103
+ try {
104
+ await apiClient.put(`/api/projects/${credentials.projectSlug}/onboarding-step`, {
105
+ step: "connected",
106
+ });
107
+ }
108
+ catch (connError) {
109
+ // Connection registration failed but continue
110
+ console.error("Failed to register connection:", connError);
111
+ }
112
+ }
113
+ else {
114
+ // No config from portal, use arguments or defaults
115
+ config = {
116
+ accentColor: args.accent_color || "blue",
117
+ grayColor: args.gray_color || "slate",
118
+ radius: args.radius || "medium",
119
+ appearance: args.appearance || "light",
120
+ };
121
+ }
122
+ }
123
+ else {
124
+ // Not authenticated, use arguments or defaults
125
+ config = {
126
+ accentColor: args.accent_color || "blue",
127
+ grayColor: args.gray_color || "slate",
128
+ radius: args.radius || "medium",
129
+ appearance: args.appearance || "light",
130
+ };
131
+ }
132
+ }
133
+ catch (authError) {
134
+ // Auth/API failed, use arguments or defaults
135
+ config = {
136
+ accentColor: args.accent_color || "blue",
137
+ grayColor: args.gray_color || "slate",
138
+ radius: args.radius || "medium",
139
+ appearance: args.appearance || "light",
140
+ };
141
+ }
142
+ // Get template
143
+ const templateType = args.template || "standard";
144
+ const template = getTemplate(templateType, config, projectName);
145
+ // Initialize .uidb folder
146
+ const projectRoot = process.cwd();
147
+ await initUIDB(projectRoot, template.files);
148
+ // Build success response
149
+ const componentCount = templateType === "standard"
150
+ ? Object.keys(template.files).filter((f) => f.startsWith("components/") && f !== "components/_index.json").length
151
+ : 0;
152
+ const patternCount = templateType === "standard"
153
+ ? Object.keys(template.files).filter((f) => f.startsWith("patterns/") && f !== "patterns/_index.json").length
154
+ : 0;
155
+ return {
156
+ content: [
157
+ {
158
+ type: "text",
159
+ text: JSON.stringify({
160
+ success: true,
161
+ message: `UIDB design system initialized for "${projectName}"`,
162
+ source: fetchedFromPortal ? "portal" : "manual",
163
+ template: templateType,
164
+ config: {
165
+ accentColor: config.accentColor,
166
+ grayColor: config.grayColor,
167
+ radius: config.radius,
168
+ appearance: config.appearance,
169
+ },
170
+ created: {
171
+ components: componentCount,
172
+ patterns: patternCount,
173
+ },
174
+ ready: true,
175
+ next_steps: fetchedFromPortal
176
+ ? [
177
+ "✅ Connected to UIDB portal",
178
+ "✅ Design system configured with your project theme",
179
+ "✅ You're all set! Start building UI components.",
180
+ "",
181
+ "Use 'uidb_guide' when you need component guidance",
182
+ ]
183
+ : [
184
+ "Import config in your root layout: import config from '../.uidb/config.json'",
185
+ "Pass theme values to Radix Theme component",
186
+ "Use uidb_guide when building UI components",
187
+ ],
188
+ }, null, 2),
189
+ },
190
+ ],
191
+ };
192
+ }
193
+ catch (error) {
194
+ return {
195
+ content: [
196
+ {
197
+ type: "text",
198
+ text: JSON.stringify({
199
+ error: "INIT_FAILED",
200
+ message: error instanceof Error
201
+ ? error.message
202
+ : "Failed to initialize UIDB",
203
+ }, null, 2),
204
+ },
205
+ ],
206
+ isError: true,
207
+ };
208
+ }
209
+ },
210
+ };
211
+ //# sourceMappingURL=init.js.map