@keystoneui/mcp 0.2.0-beta.5 → 0.2.0-beta.7

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,612 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/config.ts
4
- import { existsSync, readFileSync } from "fs";
5
- import { resolve } from "path";
6
- var DEFAULT_DOCS_URL = "https://keystoneui.io";
7
- var DEFAULT_REGISTRY_URL = `${DEFAULT_DOCS_URL}/r`;
8
- function resolveDocsUrl() {
9
- return process.env.KEYSTONEUI_URL ?? DEFAULT_DOCS_URL;
10
- }
11
- function loadProjectConfig() {
12
- const docsUrl = resolveDocsUrl();
13
- const derivedRegistryUrl = docsUrl === DEFAULT_DOCS_URL ? DEFAULT_REGISTRY_URL : `${docsUrl}/r`;
14
- const registryUrlEnv = process.env.KEYSTONEUI_REGISTRY_URL;
15
- if (registryUrlEnv) {
16
- return { docsUrl, registry: { url: registryUrlEnv } };
17
- }
18
- const cwd = process.cwd();
19
- const configPath = resolve(cwd, "components.json");
20
- if (existsSync(configPath)) {
21
- try {
22
- const raw = JSON.parse(readFileSync(configPath, "utf-8"));
23
- const registryUrl = raw?.registries?.["@keystoneui"]?.url ?? derivedRegistryUrl;
24
- return { docsUrl, registry: { url: registryUrl } };
25
- } catch {
26
- }
27
- }
28
- return { docsUrl, registry: { url: derivedRegistryUrl } };
29
- }
30
-
31
- // src/package-version.ts
32
- import { readFileSync as readFileSync2 } from "fs";
33
- import { fileURLToPath } from "url";
34
- function readPackageVersion() {
35
- try {
36
- const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
37
- const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
38
- return pkg.version ?? "unknown";
39
- } catch {
40
- return "unknown";
41
- }
42
- }
43
-
44
- // src/tools.ts
45
- import { z } from "zod";
46
-
47
- // src/display-url.ts
48
- import { inspect } from "util";
49
- var DISPLAYED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "file:"]);
50
- var PATH_AFTER_AUTHORITY = /^[\0- ]*[a-z][a-z\d+.-]*:[/\\]{2}[^/\\?#]*[/\\]/i;
51
- function displayUrl(raw) {
52
- let url;
53
- try {
54
- url = new URL(raw);
55
- } catch {
56
- return "<unparseable URL>";
57
- }
58
- if (!DISPLAYED_PROTOCOLS.has(url.protocol)) {
59
- return "<unsupported URL>";
60
- }
61
- if (!(url.username || url.password || url.search || url.hash)) {
62
- return raw;
63
- }
64
- url.username = "";
65
- url.password = "";
66
- url.hash = "";
67
- const keys = [...url.searchParams.keys()];
68
- url.search = keys.map((key) => `${encodeURIComponent(key)}=REDACTED`).join("&");
69
- if (url.host && url.pathname === "/" && !PATH_AFTER_AUTHORITY.test(raw)) {
70
- return `${url.protocol}//${url.host}${url.search}`;
71
- }
72
- return url.href;
73
- }
74
- var LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
75
- function wellFormed(text) {
76
- return text.replace(LONE_SURROGATE, "\uFFFD");
77
- }
78
- function redactUrlInError(error, url) {
79
- const forms = [.../* @__PURE__ */ new Set([url, wellFormed(url)])];
80
- const full = inspect(error, { depth: 10 });
81
- if (!forms.some((form) => full.includes(form))) {
82
- return error;
83
- }
84
- const shown = displayUrl(url);
85
- let message = error instanceof Error ? error.message : String(error ?? "Unknown error");
86
- for (const form of forms) {
87
- message = message.replaceAll(form, () => shown);
88
- }
89
- return error instanceof TypeError ? new TypeError(message) : new Error(message);
90
- }
91
-
92
- // src/fetcher.ts
93
- var cache = /* @__PURE__ */ new Map();
94
- var CACHE_TTL_MS = 5 * 60 * 1e3;
95
- async function fetchJson(url) {
96
- const cached = cache.get(url);
97
- if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
98
- return cached.data;
99
- }
100
- let response;
101
- try {
102
- response = await fetch(url);
103
- } catch (error) {
104
- throw redactUrlInError(error, url);
105
- }
106
- if (!response.ok) {
107
- throw new Error(`Failed to fetch ${displayUrl(url)}: ${response.status}`);
108
- }
109
- const data = await response.json();
110
- cache.set(url, { data, timestamp: Date.now() });
111
- return data;
112
- }
113
- function fetchManifest(registryUrl) {
114
- return fetchJson(`${registryUrl}/registry.json`);
115
- }
116
- function fetchItem(registryUrl, name) {
117
- return fetchJson(`${registryUrl}/${name}.json`);
118
- }
119
- function fetchExamples(registryUrl, name) {
120
- return fetchJson(`${registryUrl}/demos/${name}`);
121
- }
122
-
123
- // src/project-context.ts
124
- import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
125
- import { resolve as resolve2 } from "path";
126
- function readJson(path) {
127
- if (!existsSync2(path)) {
128
- return null;
129
- }
130
- try {
131
- return JSON.parse(readFileSync3(path, "utf-8"));
132
- } catch {
133
- return null;
134
- }
135
- }
136
- function detectPackageManager(cwd, manifest) {
137
- const declared = manifest?.packageManager;
138
- if (typeof declared === "string" && declared.length > 0) {
139
- return declared.split("@")[0];
140
- }
141
- const lockfiles = [
142
- ["pnpm-lock.yaml", "pnpm"],
143
- ["bun.lock", "bun"],
144
- ["bun.lockb", "bun"],
145
- ["yarn.lock", "yarn"],
146
- ["package-lock.json", "npm"]
147
- ];
148
- for (const [file, name] of lockfiles) {
149
- if (existsSync2(resolve2(cwd, file))) {
150
- return name;
151
- }
152
- }
153
- return null;
154
- }
155
- function detectProjectContext(cwd = process.cwd()) {
156
- const manifest = readJson(resolve2(cwd, "package.json"));
157
- const components = readJson(resolve2(cwd, "components.json"));
158
- const deps = {
159
- ...manifest?.dependencies,
160
- ...manifest?.devDependencies
161
- };
162
- const keystoneVersion = deps["@keystoneui/react"] ?? null;
163
- let installMode = "unknown";
164
- if (keystoneVersion) {
165
- installMode = "package";
166
- } else if (components) {
167
- installMode = "registry";
168
- }
169
- const tailwind = components?.tailwind;
170
- const css = tailwind?.css;
171
- return {
172
- installMode,
173
- aliases: components?.aliases ?? null,
174
- tailwindCssFile: typeof css === "string" && css.length > 0 ? css : null,
175
- iconLibrary: typeof components?.iconLibrary === "string" ? components.iconLibrary : null,
176
- isRSC: typeof components?.rsc === "boolean" ? components.rsc : null,
177
- packageManager: detectPackageManager(cwd, manifest),
178
- keystoneVersion
179
- };
180
- }
181
- function importLineFor(name, ctx) {
182
- if (ctx.installMode === "registry") {
183
- const ui = ctx.aliases?.ui ?? "@/components/ui";
184
- return `import { \u2026 } from "${ui}/${name}";`;
185
- }
186
- return `import { \u2026 } from "@keystoneui/react/${name}";`;
187
- }
188
- function describeInstallMode(ctx) {
189
- if (ctx.installMode === "package") {
190
- const version = ctx.keystoneVersion ? ` (${ctx.keystoneVersion})` : "";
191
- return `**package** -- \`@keystoneui/react\`${version} is a dependency. Import from subpaths.`;
192
- }
193
- if (ctx.installMode === "registry") {
194
- const ui = ctx.aliases?.ui ?? "@/components/ui";
195
- return `**registry** -- source is vendored via shadcn. Import from \`${ui}\`.`;
196
- }
197
- return "**unknown** -- neither `@keystoneui/react` in dependencies nor a `components.json`. Ask before writing imports.";
198
- }
199
- function describeRsc(isRSC) {
200
- if (isRSC === null) {
201
- return "_unknown_";
202
- }
203
- return isRSC ? 'yes -- interactive files need `"use client"`' : "no";
204
- }
205
- function formatProjectContext(ctx) {
206
- const rows = [
207
- `| install mode | ${describeInstallMode(ctx)} |`,
208
- `| ui alias | ${ctx.aliases?.ui ?? "_unknown_"} |`,
209
- `| theme CSS file | ${ctx.tailwindCssFile ?? "_unknown_ -- ask which file owns the tokens"} |`,
210
- `| icon library | ${ctx.iconLibrary ?? "_unknown_ -- ask before importing icons"} |`,
211
- `| RSC | ${describeRsc(ctx.isRSC)} |`,
212
- `| package manager | ${ctx.packageManager ?? "_unknown_"} |`
213
- ];
214
- return [
215
- "# Project context",
216
- "",
217
- "| field | value |",
218
- "|---|---|",
219
- ...rows,
220
- "",
221
- `Example import: \`${importLineFor("button", ctx)}\``
222
- ].join("\n");
223
- }
224
-
225
- // src/search.ts
226
- import fuzzysort from "fuzzysort";
227
- function applyFilters(items, type, category) {
228
- let filtered = items;
229
- if (type) {
230
- filtered = filtered.filter((i) => i.type === `registry:${type}`);
231
- }
232
- if (category) {
233
- filtered = filtered.filter((i) => i.categories?.includes(category));
234
- }
235
- return filtered;
236
- }
237
- function searchItems(manifest, query, opts = {}) {
238
- const { limit = 20, offset = 0, type, category } = opts;
239
- const items = applyFilters(manifest.items, type, category);
240
- const targets = items.map((item) => ({
241
- item,
242
- searchable: `${item.name} ${item.title ?? ""} ${item.description ?? ""} ${(item.categories ?? []).join(" ")}`
243
- }));
244
- const results = fuzzysort.go(query, targets, {
245
- key: "searchable",
246
- threshold: -1e4
247
- }).map((r) => ({ item: r.obj.item, score: r.score }));
248
- return {
249
- results: results.slice(offset, offset + limit),
250
- total: results.length
251
- };
252
- }
253
- function listItems(manifest, opts = {}) {
254
- const { limit = 20, offset = 0, type, category } = opts;
255
- const items = applyFilters(manifest.items, type, category);
256
- return {
257
- items: items.slice(offset, offset + limit),
258
- total: items.length
259
- };
260
- }
261
-
262
- // src/tools.ts
263
- function formatItemSummary(item) {
264
- const parts = [`**${item.title ?? item.name}** (\`${item.name}\`)`];
265
- if (item.description) {
266
- parts.push(item.description);
267
- }
268
- if (item.categories?.length) {
269
- parts.push(`Categories: ${item.categories.join(", ")}`);
270
- }
271
- if (item.dependencies?.length) {
272
- parts.push(`Dependencies: ${item.dependencies.join(", ")}`);
273
- }
274
- if (item.registryDependencies?.length) {
275
- parts.push(
276
- `Registry dependencies: ${item.registryDependencies.join(", ")}`
277
- );
278
- }
279
- return parts.join("\n");
280
- }
281
- function formatItemDetail(item) {
282
- const sections = [formatItemSummary(item)];
283
- if (item.files?.length) {
284
- for (const file of item.files) {
285
- if (file.content) {
286
- sections.push(`### ${file.path}
287
- \`\`\`tsx
288
- ${file.content}\`\`\``);
289
- }
290
- }
291
- }
292
- return sections.join("\n\n");
293
- }
294
- var listComponentsSchema = z.object({
295
- limit: z.number().min(1).max(100).default(20).describe("Maximum number of items to return"),
296
- offset: z.number().min(0).default(0).describe("Number of items to skip"),
297
- type: z.enum(["ui", "block", "example"]).optional().describe(
298
- "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants like 'table-with-pagination'"
299
- ),
300
- category: z.string().optional().describe(
301
- "Filter by category (e.g. 'authentication', 'login', 'signup', 'navigation', 'data', 'dashboard', 'admin', 'betting'). Currently only block items carry categories."
302
- )
303
- });
304
- async function listComponentsTool(config, input) {
305
- const manifest = await fetchManifest(config.registry.url);
306
- const { items, total } = listItems(manifest, input);
307
- const lines = items.map(formatItemSummary);
308
- lines.push(`
309
- ---
310
- Showing ${items.length} of ${total} items.`);
311
- if (input.offset + items.length < total) {
312
- lines.push(`Use offset: ${input.offset + items.length} to see more.`);
313
- }
314
- return lines.join("\n\n");
315
- }
316
- var searchComponentsSchema = z.object({
317
- query: z.string().describe("Search query (name, description, or keywords)"),
318
- limit: z.number().min(1).max(50).default(10).describe("Maximum number of results"),
319
- type: z.enum(["ui", "block", "example"]).optional().describe(
320
- "Filter by item type: 'ui' for components, 'block' for full-page blocks, 'example' for named demo variants"
321
- ),
322
- category: z.string().optional().describe(
323
- "Filter by category (e.g. 'authentication', 'login'). Currently only block items carry categories."
324
- )
325
- });
326
- async function searchComponentsTool(config, input) {
327
- const manifest = await fetchManifest(config.registry.url);
328
- const { results, total } = searchItems(manifest, input.query, {
329
- limit: input.limit,
330
- type: input.type,
331
- category: input.category
332
- });
333
- if (results.length === 0) {
334
- return `No results found for "${input.query}".`;
335
- }
336
- const lines = results.map((r) => formatItemSummary(r.item));
337
- lines.push(`
338
- ---
339
- ${total} result${total === 1 ? "" : "s"} found.`);
340
- return lines.join("\n\n");
341
- }
342
- var viewComponentSchema = z.object({
343
- names: z.array(z.string()).min(1).max(5).describe(
344
- 'Component names to view (e.g. ["button", "card"]). Returns full source code.'
345
- )
346
- });
347
- async function viewComponentTool(config, input) {
348
- const results = await Promise.all(
349
- input.names.map(async (name) => {
350
- try {
351
- const item = await fetchItem(config.registry.url, name);
352
- return formatItemDetail(item);
353
- } catch {
354
- return `**${name}**: Not found in registry.`;
355
- }
356
- })
357
- );
358
- return results.join("\n\n---\n\n");
359
- }
360
- var getAddCommandSchema = z.object({
361
- names: z.array(z.string()).min(1).max(20).describe("Component names to generate install commands for")
362
- });
363
- function getAddCommandTool(config, input) {
364
- const urls = input.names.map((name) => `${config.registry.url}/${name}.json`);
365
- const lines = [
366
- "Install these components with the shadcn CLI:",
367
- "",
368
- "```bash",
369
- `npx shadcn@latest add ${urls.join(" ")}`,
370
- "```",
371
- "",
372
- "Or install individually:",
373
- ""
374
- ];
375
- for (const url of urls) {
376
- lines.push(`\`\`\`bash
377
- npx shadcn@latest add ${url}
378
- \`\`\``);
379
- }
380
- return lines.join("\n");
381
- }
382
- var getExamplesSchema = z.object({
383
- name: z.string().describe(
384
- 'Component or block name (e.g. "button", "signin-01", "tickets-01")'
385
- )
386
- });
387
- async function getExamplesTool(config, input) {
388
- try {
389
- const bundle = await fetchExamples(config.registry.url, input.name);
390
- if (!bundle.files.length) {
391
- return `**${input.name}**: no example files found.`;
392
- }
393
- const sections = [
394
- `# ${input.name} examples`,
395
- `${bundle.files.length} file${bundle.files.length === 1 ? "" : "s"}:`,
396
- ""
397
- ];
398
- for (const file of bundle.files) {
399
- const ext = file.path.includes(".") ? file.path.split(".").pop() : "tsx";
400
- sections.push(`### ${file.path}`);
401
- sections.push(`\`\`\`${ext}
402
- ${file.content}
403
- \`\`\``);
404
- }
405
- return sections.join("\n\n");
406
- } catch {
407
- return `**${input.name}**: examples not found in registry.`;
408
- }
409
- }
410
- function getThemeInfoTool(config) {
411
- const registryUrl = config.registry.url;
412
- const themeCtx = detectProjectContext();
413
- return `# Keystone UI Theme
414
-
415
- ## CSS Setup
416
-
417
- Add these to \`${themeCtx.tailwindCssFile ?? "your global CSS file"}\` -- edit that
418
- file rather than creating a new one, or the tokens will not reach the components.
419
-
420
- \`\`\`css
421
- @import "tailwindcss";
422
- @import "@keystoneui/react/base.css";
423
- \`\`\`
424
-
425
- ## Semantic Color Tokens (OKLCH)
426
-
427
- | Token | Light | Dark | Usage |
428
- |---|---|---|---|
429
- | \`--primary\` | \`oklch(0.21 0.006 285)\` | \`oklch(0.92 0.004 286)\` | Main actions, CTAs |
430
- | \`--secondary\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Alternative actions |
431
- | \`--destructive\` | \`oklch(0.577 0.245 27)\` | \`oklch(0.704 0.191 22)\` | Destructive actions, a metric that got worse |
432
- | \`--success\` | \`oklch(0.627 0.194 149)\` | \`oklch(0.723 0.19 150)\` | Positive status, a metric that improved |
433
- | \`--warning\` | \`oklch(0.769 0.188 70)\` | \`oklch(0.828 0.189 84)\` | Caution and threshold states only |
434
- | \`--info\` | \`oklch(0.546 0.245 263)\` | \`oklch(0.707 0.165 255)\` | Neutral notices (info Alert, info Toast) |
435
- | \`--muted\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Subdued elements |
436
- | \`--accent\` | \`oklch(0.967 0.001 286)\` | \`oklch(0.274 0.006 286)\` | Highlights |
437
- | \`--background\` | \`oklch(1 0 0)\` | \`oklch(0.141 0.005 286)\` | Page background |
438
- | \`--border\` | \`oklch(0.92 0.004 286)\` | \`oklch(1 0 0 / 10%)\` | Border color |
439
- | \`--ring\` | \`oklch(0.21 0.006 286)\` | \`oklch(0.92 0.004 286)\` | Focus ring |
440
-
441
- ## Radius Scale
442
-
443
- Base: \`--radius: 0.625rem\` (10px). Derived values:
444
- - \`rounded-sm\`: \`--radius * 0.6\` (6px)
445
- - \`rounded-md\`: \`--radius * 0.8\` (8px)
446
- - \`rounded-lg\`: \`--radius\` (10px, base)
447
- - \`rounded-xl\`: \`--radius * 1.4\` (14px)
448
-
449
- Ratios, not pixel offsets \u2014 the scale stays proportional at any base.
450
-
451
- ## Custom Tokens
452
-
453
- - \`--input-bg\`: Form control background (transparent light, 5% white dark)
454
- - \`--popup-ring\`: Subtle popup container ring
455
- - \`--border-muted\`: Lower-contrast separator inside popups, and Card's filled ring
456
- - \`--success-foreground\` / \`--warning-foreground\`: Text on a success/warning fill. \`--warning-foreground\` is dark, not near-white \u2014 near-white on amber-500 is ~1.9:1 and fails WCAG
457
- - \`--sidebar\` + 7 \`--sidebar-*\`: Read by an imported shadcn sidebar (keystone ships none). Declared as aliases, so the sidebar follows the active keystone theme
458
-
459
- Use \`text-success\` / \`bg-warning\` rather than raw \`emerald\`/\`amber\` classes, and never add a \`dark:\` override to a status token.
460
-
461
- ## Dark Mode
462
-
463
- Add the \`dark\` class to a parent element.
464
-
465
- ## Registry
466
-
467
- Get the full style definition:
468
- \`\`\`bash
469
- npx shadcn@latest add ${registryUrl}/default.json
470
- \`\`\`
471
-
472
- ## Custom themes
473
-
474
- The theme builder (${config.docsUrl}/theme-builder) encodes a theme as a code,
475
- \`k1_<base>_<L>_<C>_<H>_<radius>_<font>\`, served as a \`registry:theme\` item.
476
- Install one, or only its colours (\`?only=theme\`) or font (\`?only=font\`):
477
- \`\`\`bash
478
- npx shadcn@latest add ${registryUrl}/theme/<code>.json
479
- \`\`\`
480
- \`keystoneui theme <code>\` prints the decoded settings and this command.`;
481
- }
482
- function auditChecklistTool() {
483
- const ctx = detectProjectContext();
484
- const registryMode = ctx.installMode === "registry";
485
- const uiAlias = ctx.aliases?.ui ?? "@/components/ui";
486
- const cssFile = ctx.tailwindCssFile ?? "your CSS entry point";
487
- const iconPkg = iconPackageFor(ctx.iconLibrary);
488
- return `# Post-Install Audit Checklist
489
-
490
- ## 1. CSS Setup (\`${cssFile}\`)
491
- - [ ] \`@import "tailwindcss"\` is present in \`${cssFile}\`
492
- - [ ] \`@import "@keystoneui/react/base.css"\` is imported AFTER tailwindcss
493
- - [ ] Dark mode variant is configured: \`@custom-variant dark (&:is(.dark *))\`
494
-
495
- ## 2. Tailwind Configuration
496
- - [ ] Using Tailwind CSS v4.1+
497
- - [ ] Content paths include your component files
498
-
499
- ## 3. Dependencies
500
- - [ ] \`@keystoneui/react\` is installed
501
- - [ ] Component-specific peer dependencies are installed (check each component's \`dependencies\` field)
502
- - [ ] Using React 19+
503
-
504
- ## 4. Import Pattern (install mode: ${ctx.installMode})
505
- ${registryMode ? `- [ ] Importing from the project alias: \`import { Button } from "${uiAlias}/button"\`
506
- - [ ] NOT importing from \`@keystoneui/react\` -- it is not a dependency in this project` : `- [ ] Using subpath imports: \`import { Button } from "@keystoneui/react/button"\`
507
- - [ ] NOT using barrel imports from \`@keystoneui/react\``}
508
-
509
- ## 5. Theme Variables
510
- - [ ] CSS custom properties are defined in \`:root\` (see \`get_theme_info\` for the full list)
511
- - [ ] Dark mode variables are defined in \`.dark\` selector
512
-
513
- ## 6. Icon Library
514
- - [ ] Using \`${iconPkg}\` for icons, matching this project's configured icon library
515
-
516
- ## 7. Common Issues
517
- - [ ] If hover styles feel "sticky" on mobile: ensure \`base.css\` is imported (it gates \`hover:\` with \`@media (hover: hover)\`)
518
- - [ ] If buttons don't show pointer cursor: Tailwind v4 changed the default \u2014 Keystone UI handles this internally
519
- - [ ] If focus rings look wrong: don't mix outline-based and ring-based focus patterns`;
520
- }
521
- var ICON_PACKAGES = {
522
- lucide: "lucide-react",
523
- tabler: "@tabler/icons-react",
524
- hugeicons: "@hugeicons/react",
525
- remix: "@remixicon/react"
526
- };
527
- function iconPackageFor(library) {
528
- if (library === null) {
529
- return "lucide-react";
530
- }
531
- return ICON_PACKAGES[library] ?? library;
532
- }
533
- var getDocsSchema = z.object({
534
- name: z.string().describe('Component or block name (e.g. "select", "signin-01")'),
535
- type: z.enum(["component", "block"]).default("component").describe("Which docs section to read from")
536
- });
537
- async function getDocsTool(config, input) {
538
- const section = input.type === "block" ? "blocks" : "components";
539
- const url = `${config.docsUrl}/llms.mdx/docs/${section}/${input.name}`;
540
- try {
541
- const response = await fetch(url, {
542
- headers: { "User-Agent": "keystoneui-mcp" },
543
- signal: AbortSignal.timeout(3e4)
544
- });
545
- if (!response.ok) {
546
- return `**${input.name}**: no ${input.type} docs found (${response.status}). Try search_components to find the right name.`;
547
- }
548
- return await response.text();
549
- } catch {
550
- return `**${input.name}**: could not reach ${displayUrl(url)}.`;
551
- }
552
- }
553
- var emptySchema = z.object({});
554
- var TOOL_SPECS = {
555
- list_components: {
556
- description: "List all available Keystone UI components, blocks, and named examples with pagination. Returns name, description, categories, and dependency info for each item.",
557
- schema: listComponentsSchema
558
- },
559
- search_components: {
560
- description: "Fuzzy search components, blocks, and named examples (e.g., `table-with-pagination`, `card-with-image`). Categories (e.g. 'authentication', 'login') participate in fuzzy matching. Use when the exact name isn't known; pair with `view_component` or `get_examples` to see code.",
561
- schema: searchComponentsSchema
562
- },
563
- view_component: {
564
- description: "Get full details for one or more Keystone UI components, including complete source code, dependencies, and registry dependencies. Use this to understand how a component works before using or customizing it.",
565
- schema: viewComponentSchema
566
- },
567
- get_add_command: {
568
- description: "Generate the shadcn CLI command to install one or more Keystone UI components into a project.",
569
- schema: getAddCommandSchema
570
- },
571
- get_examples: {
572
- description: "Fetch live demo files for a Keystone UI component or block. Returns the TSX source for every example/demo associated with the name (e.g. button, signin-01, tickets-01). Use after view_component to see real-world usage patterns.",
573
- schema: getExamplesSchema
574
- },
575
- get_docs: {
576
- description: "Fetch the full documentation page for a component or block, including its Composition tree (the parts hierarchy, and nestings Base UI rejects) and its API Reference table. Read it before composing any compound component. Props are documented ONLY here -- not in the registry -- so view_component alone will not give you a prop's type or default. Previews arrive resolved to inline TSX, so one call returns prose and working code.",
577
- schema: getDocsSchema
578
- },
579
- get_project_context: {
580
- description: "Read this project's Keystone UI setup: install mode (npm package vs vendored registry source), path aliases, which CSS file owns the theme tokens, icon library, whether React Server Components are in use, and the package manager. Call this FIRST -- import style and which file to edit both depend on it, and guessing wrong is the most common source of broken output.",
581
- schema: emptySchema
582
- },
583
- get_theme_info: {
584
- description: "Get Keystone UI theme configuration: CSS setup, semantic color tokens (OKLCH), radius scale, dark mode setup, and custom tokens.",
585
- schema: emptySchema
586
- },
587
- audit_checklist: {
588
- description: "Get a post-install audit checklist to verify Keystone UI is correctly configured in your project. Covers CSS setup, Tailwind config, dependencies, imports, and common issues.",
589
- schema: emptySchema
590
- }
591
- };
592
- function getProjectContextTool() {
593
- return formatProjectContext(detectProjectContext());
594
- }
595
-
596
- export {
597
- loadProjectConfig,
598
- displayUrl,
599
- redactUrlInError,
600
- readPackageVersion,
601
- detectProjectContext,
602
- listComponentsTool,
603
- searchComponentsTool,
604
- viewComponentTool,
605
- getAddCommandTool,
606
- getExamplesTool,
607
- getThemeInfoTool,
608
- auditChecklistTool,
609
- getDocsTool,
610
- TOOL_SPECS,
611
- getProjectContextTool
612
- };