@aleph-alpha/lib-mcp 1.7.0 → 2.1.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.
- package/README.md +75 -14
- package/chat-kit-components-meta.json +546 -0
- package/components-meta.json +79 -77
- package/dist/cli.js +541 -63
- package/dist/scripts/generate-component-meta.js +162 -25
- package/dist/server.js +521 -59
- package/package.json +14 -5
package/dist/server.js
CHANGED
|
@@ -3221,8 +3221,8 @@ var require_utils = __commonJS({
|
|
|
3221
3221
|
}
|
|
3222
3222
|
return ind;
|
|
3223
3223
|
}
|
|
3224
|
-
function removeDotSegments(
|
|
3225
|
-
let input =
|
|
3224
|
+
function removeDotSegments(path11) {
|
|
3225
|
+
let input = path11;
|
|
3226
3226
|
const output = [];
|
|
3227
3227
|
let nextSlash = -1;
|
|
3228
3228
|
let len = 0;
|
|
@@ -3421,8 +3421,8 @@ var require_schemes = __commonJS({
|
|
|
3421
3421
|
wsComponent.secure = void 0;
|
|
3422
3422
|
}
|
|
3423
3423
|
if (wsComponent.resourceName) {
|
|
3424
|
-
const [
|
|
3425
|
-
wsComponent.path =
|
|
3424
|
+
const [path11, query] = wsComponent.resourceName.split("?");
|
|
3425
|
+
wsComponent.path = path11 && path11 !== "/" ? path11 : void 0;
|
|
3426
3426
|
wsComponent.query = query;
|
|
3427
3427
|
wsComponent.resourceName = void 0;
|
|
3428
3428
|
}
|
|
@@ -6784,12 +6784,12 @@ var require_dist = __commonJS({
|
|
|
6784
6784
|
throw new Error(`Unknown format "${name}"`);
|
|
6785
6785
|
return f;
|
|
6786
6786
|
};
|
|
6787
|
-
function addFormats(ajv, list,
|
|
6787
|
+
function addFormats(ajv, list, fs6, exportName) {
|
|
6788
6788
|
var _a;
|
|
6789
6789
|
var _b;
|
|
6790
6790
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6791
6791
|
for (const f of list)
|
|
6792
|
-
ajv.addFormat(f,
|
|
6792
|
+
ajv.addFormat(f, fs6[f]);
|
|
6793
6793
|
}
|
|
6794
6794
|
module.exports = exports = formatsPlugin;
|
|
6795
6795
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -7275,8 +7275,8 @@ function getErrorMap() {
|
|
|
7275
7275
|
|
|
7276
7276
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
7277
7277
|
var makeIssue = (params) => {
|
|
7278
|
-
const { data, path:
|
|
7279
|
-
const fullPath = [...
|
|
7278
|
+
const { data, path: path11, errorMaps, issueData } = params;
|
|
7279
|
+
const fullPath = [...path11, ...issueData.path || []];
|
|
7280
7280
|
const fullIssue = {
|
|
7281
7281
|
...issueData,
|
|
7282
7282
|
path: fullPath
|
|
@@ -7392,11 +7392,11 @@ var errorUtil;
|
|
|
7392
7392
|
|
|
7393
7393
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
7394
7394
|
var ParseInputLazyPath = class {
|
|
7395
|
-
constructor(parent, value,
|
|
7395
|
+
constructor(parent, value, path11, key) {
|
|
7396
7396
|
this._cachedPath = [];
|
|
7397
7397
|
this.parent = parent;
|
|
7398
7398
|
this.data = value;
|
|
7399
|
-
this._path =
|
|
7399
|
+
this._path = path11;
|
|
7400
7400
|
this._key = key;
|
|
7401
7401
|
}
|
|
7402
7402
|
get path() {
|
|
@@ -10827,14 +10827,14 @@ var ostring = () => stringType().optional();
|
|
|
10827
10827
|
var onumber = () => numberType().optional();
|
|
10828
10828
|
var oboolean = () => booleanType().optional();
|
|
10829
10829
|
var coerce = {
|
|
10830
|
-
string: (arg) => ZodString.create({ ...arg, coerce: true }),
|
|
10831
|
-
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
|
|
10832
|
-
boolean: (arg) => ZodBoolean.create({
|
|
10830
|
+
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
10831
|
+
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
10832
|
+
boolean: ((arg) => ZodBoolean.create({
|
|
10833
10833
|
...arg,
|
|
10834
10834
|
coerce: true
|
|
10835
|
-
}),
|
|
10836
|
-
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
10837
|
-
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
10835
|
+
})),
|
|
10836
|
+
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
10837
|
+
date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
|
|
10838
10838
|
};
|
|
10839
10839
|
var NEVER = INVALID;
|
|
10840
10840
|
|
|
@@ -11034,10 +11034,10 @@ function assignProp(target, prop, value) {
|
|
|
11034
11034
|
configurable: true
|
|
11035
11035
|
});
|
|
11036
11036
|
}
|
|
11037
|
-
function getElementAtPath(obj,
|
|
11038
|
-
if (!
|
|
11037
|
+
function getElementAtPath(obj, path11) {
|
|
11038
|
+
if (!path11)
|
|
11039
11039
|
return obj;
|
|
11040
|
-
return
|
|
11040
|
+
return path11.reduce((acc, key) => acc?.[key], obj);
|
|
11041
11041
|
}
|
|
11042
11042
|
function promiseAllObject(promisesObj) {
|
|
11043
11043
|
const keys = Object.keys(promisesObj);
|
|
@@ -11357,11 +11357,11 @@ function aborted(x, startIndex = 0) {
|
|
|
11357
11357
|
}
|
|
11358
11358
|
return false;
|
|
11359
11359
|
}
|
|
11360
|
-
function prefixIssues(
|
|
11360
|
+
function prefixIssues(path11, issues) {
|
|
11361
11361
|
return issues.map((iss) => {
|
|
11362
11362
|
var _a;
|
|
11363
11363
|
(_a = iss).path ?? (_a.path = []);
|
|
11364
|
-
iss.path.unshift(
|
|
11364
|
+
iss.path.unshift(path11);
|
|
11365
11365
|
return iss;
|
|
11366
11366
|
});
|
|
11367
11367
|
}
|
|
@@ -14668,10 +14668,10 @@ var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
|
14668
14668
|
};
|
|
14669
14669
|
inst.clone = (_def, params) => clone(inst, _def, params);
|
|
14670
14670
|
inst.brand = () => inst;
|
|
14671
|
-
inst.register = (reg, meta) => {
|
|
14671
|
+
inst.register = ((reg, meta) => {
|
|
14672
14672
|
reg.add(inst, meta);
|
|
14673
14673
|
return inst;
|
|
14674
|
-
};
|
|
14674
|
+
});
|
|
14675
14675
|
});
|
|
14676
14676
|
var ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
|
|
14677
14677
|
$ZodObject.init(inst, def);
|
|
@@ -14934,10 +14934,10 @@ var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
14934
14934
|
};
|
|
14935
14935
|
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
14936
14936
|
inst.brand = () => inst;
|
|
14937
|
-
inst.register = (reg, meta) => {
|
|
14937
|
+
inst.register = ((reg, meta) => {
|
|
14938
14938
|
reg.add(inst, meta);
|
|
14939
14939
|
return inst;
|
|
14940
|
-
};
|
|
14940
|
+
});
|
|
14941
14941
|
inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
|
|
14942
14942
|
inst.safeParse = (data, params) => safeParse3(inst, data, params);
|
|
14943
14943
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
@@ -16894,11 +16894,13 @@ function assertCompleteRequestPrompt(request) {
|
|
|
16894
16894
|
if (request.params.ref.type !== "ref/prompt") {
|
|
16895
16895
|
throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
|
|
16896
16896
|
}
|
|
16897
|
+
void request;
|
|
16897
16898
|
}
|
|
16898
16899
|
function assertCompleteRequestResourceTemplate(request) {
|
|
16899
16900
|
if (request.params.ref.type !== "ref/resource") {
|
|
16900
16901
|
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
|
|
16901
16902
|
}
|
|
16903
|
+
void request;
|
|
16902
16904
|
}
|
|
16903
16905
|
var CompleteResultSchema = ResultSchema.extend({
|
|
16904
16906
|
completion: looseObject({
|
|
@@ -21074,7 +21076,7 @@ function extractType(text2, startIndex) {
|
|
|
21074
21076
|
function parseInterface(content, interfaceName) {
|
|
21075
21077
|
const props = [];
|
|
21076
21078
|
const interfaceRegex = new RegExp(
|
|
21077
|
-
`(?:export\\s+)?${TYPE_OR_INTERFACE}\\s+${interfaceName}\\s*(?:extends\\s+[^{]+)?(?:=\\s*)?\\{([\\s\\S]*?)\\n\\}`,
|
|
21079
|
+
`(?:export\\s+)?${TYPE_OR_INTERFACE}\\s+${interfaceName}\\s*(?:<(?:\\{[^}]*\\}|[^>])*>)?\\s*(?:extends\\s+[^{]+)?(?:=\\s*)?\\{([\\s\\S]*?)\\n\\}`,
|
|
21078
21080
|
"m"
|
|
21079
21081
|
);
|
|
21080
21082
|
const match = content.match(interfaceRegex);
|
|
@@ -21089,7 +21091,10 @@ function parseInterface(content, interfaceName) {
|
|
|
21089
21091
|
const propName = propMatch[2];
|
|
21090
21092
|
const isOptional = !!propMatch[3];
|
|
21091
21093
|
const typeStartIndex = propMatch.index + propMatch[0].length;
|
|
21092
|
-
const { type: propType, endIndex } = extractType(
|
|
21094
|
+
const { type: propType, endIndex } = extractType(
|
|
21095
|
+
interfaceBody,
|
|
21096
|
+
typeStartIndex
|
|
21097
|
+
);
|
|
21093
21098
|
propStartRegex.lastIndex = endIndex + 1;
|
|
21094
21099
|
const jsdoc = parseJSDoc(jsdocComment);
|
|
21095
21100
|
props.push({
|
|
@@ -21106,7 +21111,9 @@ function parseInterface(content, interfaceName) {
|
|
|
21106
21111
|
function extractComponentDescription(content, interfaceName) {
|
|
21107
21112
|
const lines = content.split("\n");
|
|
21108
21113
|
const interfaceLineIndex = lines.findIndex(
|
|
21109
|
-
(line) => line.match(
|
|
21114
|
+
(line) => line.match(
|
|
21115
|
+
new RegExp(`export\\s+${TYPE_OR_INTERFACE}\\s+${interfaceName}`)
|
|
21116
|
+
)
|
|
21110
21117
|
);
|
|
21111
21118
|
if (interfaceLineIndex === -1) {
|
|
21112
21119
|
return "";
|
|
@@ -21132,7 +21139,9 @@ function extractComponentDescription(content, interfaceName) {
|
|
|
21132
21139
|
return "";
|
|
21133
21140
|
}
|
|
21134
21141
|
function resolveUnionOrIntersectionProps(content, typeName) {
|
|
21135
|
-
const typeDefRegex = new RegExp(
|
|
21142
|
+
const typeDefRegex = new RegExp(
|
|
21143
|
+
`export\\s+type\\s+${typeName}\\s*=\\s*([^;]+)`
|
|
21144
|
+
);
|
|
21136
21145
|
const match = content.match(typeDefRegex);
|
|
21137
21146
|
if (!match) return [];
|
|
21138
21147
|
const referencedTypes = match[1].split(/[|&]/).map((t) => t.trim()).filter((t) => t.endsWith("Props"));
|
|
@@ -21160,7 +21169,9 @@ function readTypesFile(filePath, componentName) {
|
|
|
21160
21169
|
return null;
|
|
21161
21170
|
}
|
|
21162
21171
|
const resolvedName = componentName || path.basename(path.dirname(filePath));
|
|
21163
|
-
const exactRegex = new RegExp(
|
|
21172
|
+
const exactRegex = new RegExp(
|
|
21173
|
+
`export\\s+${TYPE_OR_INTERFACE}\\s+(${resolvedName}Props)\\b`
|
|
21174
|
+
);
|
|
21164
21175
|
let propsInterfaceMatch = content.match(exactRegex);
|
|
21165
21176
|
if (!propsInterfaceMatch) {
|
|
21166
21177
|
const prefixRegex = new RegExp(
|
|
@@ -21204,20 +21215,39 @@ import * as path2 from "node:path";
|
|
|
21204
21215
|
import { fileURLToPath } from "node:url";
|
|
21205
21216
|
var __filename = fileURLToPath(import.meta.url);
|
|
21206
21217
|
var __dirname = path2.dirname(__filename);
|
|
21207
|
-
function
|
|
21208
|
-
|
|
21209
|
-
|
|
21210
|
-
path2.
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
21214
|
-
path2.
|
|
21218
|
+
function findInMonorepo(startDir, packageName) {
|
|
21219
|
+
let current = startDir;
|
|
21220
|
+
for (let i = 0; i < 10; i++) {
|
|
21221
|
+
const candidate = path2.join(current, "packages", packageName);
|
|
21222
|
+
if (fs2.existsSync(path2.join(candidate, "package.json"))) {
|
|
21223
|
+
return candidate;
|
|
21224
|
+
}
|
|
21225
|
+
const parent = path2.dirname(current);
|
|
21226
|
+
if (parent === current) break;
|
|
21227
|
+
current = parent;
|
|
21228
|
+
}
|
|
21229
|
+
return null;
|
|
21230
|
+
}
|
|
21231
|
+
function resolveWorkspacePackage(packageName, scope = "@aleph-alpha") {
|
|
21232
|
+
const fromDirname = findInMonorepo(__dirname, packageName);
|
|
21233
|
+
if (fromDirname) return fromDirname;
|
|
21234
|
+
const fromCwd = findInMonorepo(process.cwd(), packageName);
|
|
21235
|
+
if (fromCwd) return fromCwd;
|
|
21236
|
+
const nodeModulesCandidates = [
|
|
21237
|
+
path2.resolve(__dirname, `../../${scope}/${packageName}`),
|
|
21238
|
+
path2.resolve(__dirname, `../../../${scope}/${packageName}`),
|
|
21239
|
+
path2.join(process.cwd(), `node_modules/${scope}/${packageName}`)
|
|
21215
21240
|
];
|
|
21216
|
-
for (const pkgPath of
|
|
21241
|
+
for (const pkgPath of nodeModulesCandidates) {
|
|
21217
21242
|
if (fs2.existsSync(path2.join(pkgPath, "package.json"))) {
|
|
21218
21243
|
return pkgPath;
|
|
21219
21244
|
}
|
|
21220
21245
|
}
|
|
21246
|
+
return null;
|
|
21247
|
+
}
|
|
21248
|
+
function findUiLibraryRoot() {
|
|
21249
|
+
const pkgPath = resolveWorkspacePackage("ui-library");
|
|
21250
|
+
if (pkgPath) return pkgPath;
|
|
21221
21251
|
throw new Error("Could not find @aleph-alpha/ui-library. Is it installed?");
|
|
21222
21252
|
}
|
|
21223
21253
|
function getLibraryRootPath() {
|
|
@@ -21233,6 +21263,21 @@ function getLibrarySourcePath() {
|
|
|
21233
21263
|
"Could not find UI library source directory. Is the package installed correctly?"
|
|
21234
21264
|
);
|
|
21235
21265
|
}
|
|
21266
|
+
function findChatKitRoot() {
|
|
21267
|
+
const pkgPath = resolveWorkspacePackage("chat-kit");
|
|
21268
|
+
if (pkgPath) return pkgPath;
|
|
21269
|
+
throw new Error("Could not find @aleph-alpha/chat-kit. Is it installed?");
|
|
21270
|
+
}
|
|
21271
|
+
function getChatKitSourcePath() {
|
|
21272
|
+
const chatKitRoot = findChatKitRoot();
|
|
21273
|
+
const srcPath = path2.join(chatKitRoot, "src");
|
|
21274
|
+
if (fs2.existsSync(srcPath)) {
|
|
21275
|
+
return srcPath;
|
|
21276
|
+
}
|
|
21277
|
+
throw new Error(
|
|
21278
|
+
"Could not find chat-kit source directory. Is the package installed correctly?"
|
|
21279
|
+
);
|
|
21280
|
+
}
|
|
21236
21281
|
function getMcpDirPath() {
|
|
21237
21282
|
const possiblePaths = [
|
|
21238
21283
|
// Bundled: from dist/utils -> package root
|
|
@@ -21255,6 +21300,12 @@ function getPackageRoot() {
|
|
|
21255
21300
|
return process.cwd();
|
|
21256
21301
|
}
|
|
21257
21302
|
|
|
21303
|
+
// src/utils/constants.ts
|
|
21304
|
+
var COMPONENT_PREFIX = "Ui";
|
|
21305
|
+
var CHAT_KIT_PREFIX = "Ck";
|
|
21306
|
+
var INTERNAL_DIRS = ["shadcn"];
|
|
21307
|
+
var TYPE_SUFFIXES = ["Props", "Variant", "Size"];
|
|
21308
|
+
|
|
21258
21309
|
// src/constants.ts
|
|
21259
21310
|
function detectCategoryDirs() {
|
|
21260
21311
|
const srcPath = getSrcPath();
|
|
@@ -21262,11 +21313,15 @@ function detectCategoryDirs() {
|
|
|
21262
21313
|
return [];
|
|
21263
21314
|
}
|
|
21264
21315
|
const entries = fs3.readdirSync(srcPath, { withFileTypes: true });
|
|
21265
|
-
return entries.filter((entry) => entry.isDirectory()).filter(
|
|
21316
|
+
return entries.filter((entry) => entry.isDirectory()).filter(
|
|
21317
|
+
(entry) => !entry.name.startsWith(".") && entry.name !== "node_modules"
|
|
21318
|
+
).filter((entry) => {
|
|
21266
21319
|
try {
|
|
21267
21320
|
const dirPath = path3.join(srcPath, entry.name);
|
|
21268
21321
|
const subEntries = fs3.readdirSync(dirPath, { withFileTypes: true });
|
|
21269
|
-
return subEntries.some(
|
|
21322
|
+
return subEntries.some(
|
|
21323
|
+
(sub) => sub.isDirectory() && sub.name.startsWith(COMPONENT_PREFIX)
|
|
21324
|
+
);
|
|
21270
21325
|
} catch {
|
|
21271
21326
|
return false;
|
|
21272
21327
|
}
|
|
@@ -21278,6 +21333,47 @@ function getCategoryDirs() {
|
|
|
21278
21333
|
cachedCategoryDirs = detectCategoryDirs();
|
|
21279
21334
|
return cachedCategoryDirs;
|
|
21280
21335
|
}
|
|
21336
|
+
function detectChatKitCategoryDirs() {
|
|
21337
|
+
const srcPath = getChatKitSrcPath();
|
|
21338
|
+
if (!srcPath || !fs3.existsSync(srcPath)) {
|
|
21339
|
+
return [];
|
|
21340
|
+
}
|
|
21341
|
+
const categories = [];
|
|
21342
|
+
const walk = (dir, relative, depth) => {
|
|
21343
|
+
let entries;
|
|
21344
|
+
try {
|
|
21345
|
+
entries = fs3.readdirSync(dir, { withFileTypes: true });
|
|
21346
|
+
} catch {
|
|
21347
|
+
return;
|
|
21348
|
+
}
|
|
21349
|
+
const hasChatKitSubdirs = entries.some(
|
|
21350
|
+
(sub) => sub.isDirectory() && sub.name.startsWith(CHAT_KIT_PREFIX)
|
|
21351
|
+
);
|
|
21352
|
+
if (hasChatKitSubdirs && relative) {
|
|
21353
|
+
categories.push(relative);
|
|
21354
|
+
return;
|
|
21355
|
+
}
|
|
21356
|
+
if (depth >= 2) return;
|
|
21357
|
+
for (const entry of entries) {
|
|
21358
|
+
if (!entry.isDirectory()) continue;
|
|
21359
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
21360
|
+
if (entry.name.startsWith(CHAT_KIT_PREFIX)) continue;
|
|
21361
|
+
walk(
|
|
21362
|
+
path3.join(dir, entry.name),
|
|
21363
|
+
relative ? path3.join(relative, entry.name) : entry.name,
|
|
21364
|
+
depth + 1
|
|
21365
|
+
);
|
|
21366
|
+
}
|
|
21367
|
+
};
|
|
21368
|
+
walk(srcPath, "", 0);
|
|
21369
|
+
return categories;
|
|
21370
|
+
}
|
|
21371
|
+
var cachedChatKitCategoryDirs = null;
|
|
21372
|
+
function getChatKitCategoryDirs() {
|
|
21373
|
+
if (cachedChatKitCategoryDirs) return cachedChatKitCategoryDirs;
|
|
21374
|
+
cachedChatKitCategoryDirs = detectChatKitCategoryDirs();
|
|
21375
|
+
return cachedChatKitCategoryDirs;
|
|
21376
|
+
}
|
|
21281
21377
|
function getSrcPath() {
|
|
21282
21378
|
try {
|
|
21283
21379
|
return getLibrarySourcePath();
|
|
@@ -21285,6 +21381,13 @@ function getSrcPath() {
|
|
|
21285
21381
|
return null;
|
|
21286
21382
|
}
|
|
21287
21383
|
}
|
|
21384
|
+
function getChatKitSrcPath() {
|
|
21385
|
+
try {
|
|
21386
|
+
return getChatKitSourcePath();
|
|
21387
|
+
} catch {
|
|
21388
|
+
return null;
|
|
21389
|
+
}
|
|
21390
|
+
}
|
|
21288
21391
|
var cachedMeta = null;
|
|
21289
21392
|
function loadComponentsMeta() {
|
|
21290
21393
|
if (cachedMeta) return cachedMeta;
|
|
@@ -21293,6 +21396,14 @@ function loadComponentsMeta() {
|
|
|
21293
21396
|
cachedMeta = readJsonFile(metaPath) ?? {};
|
|
21294
21397
|
return cachedMeta;
|
|
21295
21398
|
}
|
|
21399
|
+
var cachedChatKitMeta = null;
|
|
21400
|
+
function loadChatKitComponentsMeta() {
|
|
21401
|
+
if (cachedChatKitMeta) return cachedChatKitMeta;
|
|
21402
|
+
const mcpDir = getMcpDirPath();
|
|
21403
|
+
const metaPath = path3.join(mcpDir, "chat-kit-components-meta.json");
|
|
21404
|
+
cachedChatKitMeta = readJsonFile(metaPath) ?? {};
|
|
21405
|
+
return cachedChatKitMeta;
|
|
21406
|
+
}
|
|
21296
21407
|
function getPackageVersion() {
|
|
21297
21408
|
const pkgRoot = getPackageRoot();
|
|
21298
21409
|
const pkgPath = path3.join(pkgRoot, "package.json");
|
|
@@ -21300,11 +21411,6 @@ function getPackageVersion() {
|
|
|
21300
21411
|
return pkg?.version ?? "0.0.0";
|
|
21301
21412
|
}
|
|
21302
21413
|
|
|
21303
|
-
// src/utils/constants.ts
|
|
21304
|
-
var COMPONENT_PREFIX = "Ui";
|
|
21305
|
-
var INTERNAL_DIRS = ["shadcn"];
|
|
21306
|
-
var TYPE_SUFFIXES = ["Props", "Variant", "Size"];
|
|
21307
|
-
|
|
21308
21414
|
// src/utils/component-name.ts
|
|
21309
21415
|
function normalizeComponentName(name) {
|
|
21310
21416
|
if (name.startsWith(COMPONENT_PREFIX)) {
|
|
@@ -21340,7 +21446,11 @@ function scanCategoryDirectory(categoryDir) {
|
|
|
21340
21446
|
return {
|
|
21341
21447
|
name: componentName,
|
|
21342
21448
|
category: componentMeta?.category ?? "Uncategorized",
|
|
21343
|
-
description: getComponentDescription(
|
|
21449
|
+
description: getComponentDescription(
|
|
21450
|
+
componentName,
|
|
21451
|
+
componentMeta,
|
|
21452
|
+
componentDir
|
|
21453
|
+
)
|
|
21344
21454
|
};
|
|
21345
21455
|
});
|
|
21346
21456
|
}
|
|
@@ -21397,7 +21507,9 @@ function extractStories(content) {
|
|
|
21397
21507
|
if (storyName === "default") continue;
|
|
21398
21508
|
const storyStart = match.index;
|
|
21399
21509
|
const remainingContent = content.substring(storyStart);
|
|
21400
|
-
const templateRefMatch = remainingContent.match(
|
|
21510
|
+
const templateRefMatch = remainingContent.match(
|
|
21511
|
+
/code:\s*(\w+TemplateSource)/
|
|
21512
|
+
);
|
|
21401
21513
|
if (templateRefMatch) {
|
|
21402
21514
|
stories.set(storyName, templateRefMatch[1]);
|
|
21403
21515
|
}
|
|
@@ -21670,7 +21782,12 @@ function getComponentDocs(componentName) {
|
|
|
21670
21782
|
import * as path7 from "node:path";
|
|
21671
21783
|
function getSetupGuide() {
|
|
21672
21784
|
const libraryRoot = getLibraryRootPath();
|
|
21673
|
-
const quickStartPath = path7.join(
|
|
21785
|
+
const quickStartPath = path7.join(
|
|
21786
|
+
libraryRoot,
|
|
21787
|
+
"docs",
|
|
21788
|
+
"public-docs",
|
|
21789
|
+
"quick-start.md"
|
|
21790
|
+
);
|
|
21674
21791
|
const quickStart = readTextFile(quickStartPath);
|
|
21675
21792
|
if (quickStart) {
|
|
21676
21793
|
return quickStart;
|
|
@@ -21683,8 +21800,287 @@ function getSetupGuide() {
|
|
|
21683
21800
|
return null;
|
|
21684
21801
|
}
|
|
21685
21802
|
|
|
21803
|
+
// src/tools/list-chat-kit-components.ts
|
|
21804
|
+
import * as fs5 from "node:fs";
|
|
21805
|
+
import * as path9 from "node:path";
|
|
21806
|
+
|
|
21807
|
+
// src/readers/chat-kit-types-reader.ts
|
|
21808
|
+
import * as path8 from "node:path";
|
|
21809
|
+
var TYPE_OR_INTERFACE2 = "(?:interface|type)";
|
|
21810
|
+
function parseJSDoc2(comment) {
|
|
21811
|
+
const lines = comment.replace(/\/\*\*|\*\/|\*/g, "").split("\n").map((line) => line.trim()).filter(Boolean);
|
|
21812
|
+
let description = "";
|
|
21813
|
+
let defaultValue;
|
|
21814
|
+
let example;
|
|
21815
|
+
for (const line of lines) {
|
|
21816
|
+
if (line.startsWith("@default")) {
|
|
21817
|
+
defaultValue = line.replace("@default", "").trim().replace(/^['"]|['"]$/g, "");
|
|
21818
|
+
} else if (line.startsWith("@example")) {
|
|
21819
|
+
example = line.replace("@example", "").trim();
|
|
21820
|
+
} else if (!line.startsWith("@")) {
|
|
21821
|
+
description += (description ? " " : "") + line;
|
|
21822
|
+
}
|
|
21823
|
+
}
|
|
21824
|
+
return { description, default: defaultValue, example };
|
|
21825
|
+
}
|
|
21826
|
+
function extractType2(text2, startIndex) {
|
|
21827
|
+
let depth = 0;
|
|
21828
|
+
let i = startIndex;
|
|
21829
|
+
while (i < text2.length) {
|
|
21830
|
+
const char = text2[i];
|
|
21831
|
+
const prevChar = i > 0 ? text2[i - 1] : "";
|
|
21832
|
+
if (char === "<" || char === "{" || char === "(" || char === "[") {
|
|
21833
|
+
depth++;
|
|
21834
|
+
} else if (char === "}" || char === ")" || char === "]") {
|
|
21835
|
+
depth = Math.max(0, depth - 1);
|
|
21836
|
+
} else if (char === ">") {
|
|
21837
|
+
if (prevChar !== "=") {
|
|
21838
|
+
depth = Math.max(0, depth - 1);
|
|
21839
|
+
}
|
|
21840
|
+
} else if (char === ";" && depth === 0) {
|
|
21841
|
+
return { type: text2.slice(startIndex, i).trim(), endIndex: i };
|
|
21842
|
+
}
|
|
21843
|
+
i++;
|
|
21844
|
+
}
|
|
21845
|
+
return { type: text2.slice(startIndex).trim(), endIndex: text2.length };
|
|
21846
|
+
}
|
|
21847
|
+
function parseInterface2(content, interfaceName) {
|
|
21848
|
+
const props = [];
|
|
21849
|
+
const interfaceRegex = new RegExp(
|
|
21850
|
+
`(?:export\\s+)?${TYPE_OR_INTERFACE2}\\s+${interfaceName}\\s*(?:<(?:\\{[^}]*\\}|[^>])*>)?\\s*(?:extends\\s+[^{]+)?(?:=\\s*)?\\{([\\s\\S]*?)\\n\\}`,
|
|
21851
|
+
"m"
|
|
21852
|
+
);
|
|
21853
|
+
const match = content.match(interfaceRegex);
|
|
21854
|
+
if (!match) {
|
|
21855
|
+
return props;
|
|
21856
|
+
}
|
|
21857
|
+
const interfaceBody = match[1];
|
|
21858
|
+
const propStartRegex = /(?:\/\*\*([\s\S]*?)\*\/\s*)?([\w]+)(\?)?:\s*/g;
|
|
21859
|
+
let propMatch;
|
|
21860
|
+
while ((propMatch = propStartRegex.exec(interfaceBody)) !== null) {
|
|
21861
|
+
const jsdocComment = propMatch[1] || "";
|
|
21862
|
+
const propName = propMatch[2];
|
|
21863
|
+
const isOptional = !!propMatch[3];
|
|
21864
|
+
const typeStartIndex = propMatch.index + propMatch[0].length;
|
|
21865
|
+
const { type: propType, endIndex } = extractType2(
|
|
21866
|
+
interfaceBody,
|
|
21867
|
+
typeStartIndex
|
|
21868
|
+
);
|
|
21869
|
+
propStartRegex.lastIndex = endIndex + 1;
|
|
21870
|
+
const jsdoc = parseJSDoc2(jsdocComment);
|
|
21871
|
+
props.push({
|
|
21872
|
+
name: propName,
|
|
21873
|
+
type: propType,
|
|
21874
|
+
required: !isOptional,
|
|
21875
|
+
description: jsdoc.description,
|
|
21876
|
+
default: jsdoc.default,
|
|
21877
|
+
example: jsdoc.example
|
|
21878
|
+
});
|
|
21879
|
+
}
|
|
21880
|
+
return props;
|
|
21881
|
+
}
|
|
21882
|
+
function extractComponentDescription2(content, interfaceName) {
|
|
21883
|
+
const lines = content.split("\n");
|
|
21884
|
+
const interfaceLineIndex = lines.findIndex(
|
|
21885
|
+
(line) => line.match(
|
|
21886
|
+
new RegExp(`export\\s+${TYPE_OR_INTERFACE2}\\s+${interfaceName}`)
|
|
21887
|
+
)
|
|
21888
|
+
);
|
|
21889
|
+
if (interfaceLineIndex === -1) {
|
|
21890
|
+
return "";
|
|
21891
|
+
}
|
|
21892
|
+
let jsdocEndIndex = -1;
|
|
21893
|
+
for (let i = interfaceLineIndex - 1; i >= 0; i--) {
|
|
21894
|
+
const line = lines[i].trim();
|
|
21895
|
+
if (line === "" || line === "*/") {
|
|
21896
|
+
if (line === "*/") {
|
|
21897
|
+
jsdocEndIndex = i;
|
|
21898
|
+
}
|
|
21899
|
+
continue;
|
|
21900
|
+
}
|
|
21901
|
+
if (!line.startsWith("*") && !line.startsWith("/**")) {
|
|
21902
|
+
break;
|
|
21903
|
+
}
|
|
21904
|
+
if (line.startsWith("/**")) {
|
|
21905
|
+
const jsdocLines = lines.slice(i, jsdocEndIndex + 1);
|
|
21906
|
+
const jsdocContent = jsdocLines.join("\n");
|
|
21907
|
+
return parseJSDoc2(jsdocContent).description;
|
|
21908
|
+
}
|
|
21909
|
+
}
|
|
21910
|
+
return "";
|
|
21911
|
+
}
|
|
21912
|
+
function resolveUnionOrIntersectionProps2(content, typeName) {
|
|
21913
|
+
const typeDefRegex = new RegExp(
|
|
21914
|
+
`export\\s+type\\s+${typeName}\\s*=\\s*([^;]+)`
|
|
21915
|
+
);
|
|
21916
|
+
const match = content.match(typeDefRegex);
|
|
21917
|
+
if (!match) return [];
|
|
21918
|
+
const referencedTypes = match[1].split(/[|&]/).map((t) => t.trim()).filter((t) => t.endsWith("Props"));
|
|
21919
|
+
if (referencedTypes.length === 0) return [];
|
|
21920
|
+
const firstBranch = referencedTypes[0];
|
|
21921
|
+
const extendsRegex = new RegExp(
|
|
21922
|
+
`(?:export\\s+)?${TYPE_OR_INTERFACE2}\\s+${firstBranch}\\s+extends\\s+(\\w+)`
|
|
21923
|
+
);
|
|
21924
|
+
const extendsMatch = content.match(extendsRegex);
|
|
21925
|
+
const allProps = [];
|
|
21926
|
+
if (extendsMatch) {
|
|
21927
|
+
allProps.push(...parseInterface2(content, extendsMatch[1]));
|
|
21928
|
+
}
|
|
21929
|
+
allProps.push(...parseInterface2(content, firstBranch));
|
|
21930
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21931
|
+
return allProps.filter((p) => {
|
|
21932
|
+
if (seen.has(p.name)) return false;
|
|
21933
|
+
seen.add(p.name);
|
|
21934
|
+
return true;
|
|
21935
|
+
});
|
|
21936
|
+
}
|
|
21937
|
+
function readChatKitTypesFile(filePath, componentName) {
|
|
21938
|
+
const content = readTextFile(filePath);
|
|
21939
|
+
if (!content) {
|
|
21940
|
+
return null;
|
|
21941
|
+
}
|
|
21942
|
+
const resolvedName = componentName || path8.basename(path8.dirname(filePath));
|
|
21943
|
+
const exactRegex = new RegExp(
|
|
21944
|
+
`export\\s+${TYPE_OR_INTERFACE2}\\s+(${resolvedName}Props)\\b`
|
|
21945
|
+
);
|
|
21946
|
+
let propsInterfaceMatch = content.match(exactRegex);
|
|
21947
|
+
if (!propsInterfaceMatch) {
|
|
21948
|
+
const prefixRegex = new RegExp(
|
|
21949
|
+
`export\\s+${TYPE_OR_INTERFACE2}\\s+(${resolvedName}\\w*Props)\\b`
|
|
21950
|
+
);
|
|
21951
|
+
propsInterfaceMatch = content.match(prefixRegex);
|
|
21952
|
+
}
|
|
21953
|
+
if (!propsInterfaceMatch) {
|
|
21954
|
+
propsInterfaceMatch = content.match(
|
|
21955
|
+
new RegExp(`export\\s+${TYPE_OR_INTERFACE2}\\s+(Ck\\w+Props)\\b`)
|
|
21956
|
+
);
|
|
21957
|
+
}
|
|
21958
|
+
if (!propsInterfaceMatch) {
|
|
21959
|
+
return null;
|
|
21960
|
+
}
|
|
21961
|
+
const interfaceName = propsInterfaceMatch[1];
|
|
21962
|
+
const matchedComponentName = interfaceName.replace("Props", "");
|
|
21963
|
+
const description = extractComponentDescription2(content, interfaceName);
|
|
21964
|
+
let props = parseInterface2(content, interfaceName);
|
|
21965
|
+
if (props.length === 0) {
|
|
21966
|
+
props = resolveUnionOrIntersectionProps2(content, interfaceName);
|
|
21967
|
+
}
|
|
21968
|
+
return {
|
|
21969
|
+
name: matchedComponentName,
|
|
21970
|
+
description,
|
|
21971
|
+
props
|
|
21972
|
+
};
|
|
21973
|
+
}
|
|
21974
|
+
function readChatKitComponentTypes(componentDir) {
|
|
21975
|
+
const typesPath = path8.join(componentDir, "types.ts");
|
|
21976
|
+
return readChatKitTypesFile(typesPath, path8.basename(componentDir));
|
|
21977
|
+
}
|
|
21978
|
+
|
|
21979
|
+
// src/tools/list-chat-kit-components.ts
|
|
21980
|
+
function isChatKitComponent(dirName) {
|
|
21981
|
+
return dirName.startsWith(CHAT_KIT_PREFIX);
|
|
21982
|
+
}
|
|
21983
|
+
function getDescription(componentName, componentMeta, componentDir) {
|
|
21984
|
+
if (componentMeta?.description) return componentMeta.description;
|
|
21985
|
+
const typeInfo = readChatKitComponentTypes(componentDir);
|
|
21986
|
+
if (typeInfo?.description) return typeInfo.description;
|
|
21987
|
+
return `${componentName} component`;
|
|
21988
|
+
}
|
|
21989
|
+
function matchesFilter2(component, filter) {
|
|
21990
|
+
const filterLower = filter.toLowerCase();
|
|
21991
|
+
return component.name.toLowerCase().includes(filterLower) || component.category.toLowerCase().includes(filterLower) || component.description.toLowerCase().includes(filterLower);
|
|
21992
|
+
}
|
|
21993
|
+
function listChatKitComponents(filter) {
|
|
21994
|
+
const srcPath = getChatKitSourcePath();
|
|
21995
|
+
const meta = loadChatKitComponentsMeta();
|
|
21996
|
+
const allComponents = getChatKitCategoryDirs().flatMap((category) => {
|
|
21997
|
+
const categoryPath = path9.join(srcPath, category);
|
|
21998
|
+
if (!isDirectory(categoryPath)) return [];
|
|
21999
|
+
return fs5.readdirSync(categoryPath, { withFileTypes: true }).filter((e) => e.isDirectory() && isChatKitComponent(e.name)).map((e) => {
|
|
22000
|
+
const componentDir = path9.join(categoryPath, e.name);
|
|
22001
|
+
const componentMeta = meta[e.name];
|
|
22002
|
+
return {
|
|
22003
|
+
name: e.name,
|
|
22004
|
+
category: componentMeta?.category ?? "Uncategorized",
|
|
22005
|
+
description: getDescription(e.name, componentMeta, componentDir)
|
|
22006
|
+
};
|
|
22007
|
+
});
|
|
22008
|
+
});
|
|
22009
|
+
allComponents.sort((a, b) => a.name.localeCompare(b.name));
|
|
22010
|
+
return filter ? allComponents.filter((c) => matchesFilter2(c, filter)) : allComponents;
|
|
22011
|
+
}
|
|
22012
|
+
|
|
22013
|
+
// src/tools/get-chat-kit-docs.ts
|
|
22014
|
+
import * as path10 from "node:path";
|
|
22015
|
+
function normalizeChatKitName(name) {
|
|
22016
|
+
return name.startsWith(CHAT_KIT_PREFIX) ? name : `${CHAT_KIT_PREFIX}${name}`;
|
|
22017
|
+
}
|
|
22018
|
+
function findChatKitComponentDir(componentName) {
|
|
22019
|
+
const srcPath = getChatKitSourcePath();
|
|
22020
|
+
for (const category of getChatKitCategoryDirs()) {
|
|
22021
|
+
const dir = path10.join(srcPath, category, componentName);
|
|
22022
|
+
if (isDirectory(dir)) return dir;
|
|
22023
|
+
}
|
|
22024
|
+
return null;
|
|
22025
|
+
}
|
|
22026
|
+
function isTypeSuffix2(name) {
|
|
22027
|
+
return TYPE_SUFFIXES.some((suffix) => name.endsWith(suffix));
|
|
22028
|
+
}
|
|
22029
|
+
function extractSubComponents2(indexPath, mainComponentName) {
|
|
22030
|
+
const content = readTextFile(indexPath);
|
|
22031
|
+
if (!content) return [];
|
|
22032
|
+
const subComponents = /* @__PURE__ */ new Set();
|
|
22033
|
+
const exportRegex = /export\s*\{[^}]*(?:default\s+as\s+)?(\w+)[^}]*\}/g;
|
|
22034
|
+
let match;
|
|
22035
|
+
while ((match = exportRegex.exec(content)) !== null) {
|
|
22036
|
+
const exportName = match[1];
|
|
22037
|
+
if (exportName.startsWith(mainComponentName) && exportName !== mainComponentName && !isTypeSuffix2(exportName)) {
|
|
22038
|
+
subComponents.add(exportName);
|
|
22039
|
+
}
|
|
22040
|
+
}
|
|
22041
|
+
return Array.from(subComponents).sort();
|
|
22042
|
+
}
|
|
22043
|
+
function getChatKitComponentDocs(componentName) {
|
|
22044
|
+
const name = normalizeChatKitName(componentName);
|
|
22045
|
+
const componentDir = findChatKitComponentDir(name);
|
|
22046
|
+
if (!componentDir) return null;
|
|
22047
|
+
const typeInfo = readChatKitComponentTypes(componentDir);
|
|
22048
|
+
const props = typeInfo?.props || [];
|
|
22049
|
+
let description = typeInfo?.description || "";
|
|
22050
|
+
const storiesInfo = readComponentStories(componentDir);
|
|
22051
|
+
const examples = storiesInfo?.examples || [];
|
|
22052
|
+
const usageGuidance = storiesInfo?.usageGuidance || [];
|
|
22053
|
+
if (!description && usageGuidance.length > 0) {
|
|
22054
|
+
description = usageGuidance[0];
|
|
22055
|
+
}
|
|
22056
|
+
if (!description) {
|
|
22057
|
+
description = `${name} component from @aleph-alpha/chat-kit`;
|
|
22058
|
+
}
|
|
22059
|
+
const indexPath = path10.join(componentDir, "index.ts");
|
|
22060
|
+
const subComponents = readTextFile(indexPath) ? extractSubComponents2(indexPath, name) : void 0;
|
|
22061
|
+
if (storiesInfo?.argTypes) {
|
|
22062
|
+
for (const argType of storiesInfo.argTypes) {
|
|
22063
|
+
const prop = props.find((p) => p.name === argType.name);
|
|
22064
|
+
if (prop && !prop.description && argType.description) {
|
|
22065
|
+
prop.description = argType.description;
|
|
22066
|
+
}
|
|
22067
|
+
}
|
|
22068
|
+
}
|
|
22069
|
+
return {
|
|
22070
|
+
name,
|
|
22071
|
+
description,
|
|
22072
|
+
props,
|
|
22073
|
+
examples,
|
|
22074
|
+
usageGuidance: [...new Set(usageGuidance)],
|
|
22075
|
+
subComponents: subComponents && subComponents.length > 0 ? subComponents : void 0,
|
|
22076
|
+
defaultArgs: storiesInfo?.defaultArgs
|
|
22077
|
+
};
|
|
22078
|
+
}
|
|
22079
|
+
|
|
21686
22080
|
// src/server.ts
|
|
21687
|
-
var text = (t) => ({
|
|
22081
|
+
var text = (t) => ({
|
|
22082
|
+
content: [{ type: "text", text: t }]
|
|
22083
|
+
});
|
|
21688
22084
|
var error2 = (msg) => ({ ...text(msg), isError: true });
|
|
21689
22085
|
function handleError(e) {
|
|
21690
22086
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -21709,11 +22105,13 @@ function formatComponentDocs(docs) {
|
|
|
21709
22105
|
docs.props.forEach((prop) => sections.push(...formatProp(prop)));
|
|
21710
22106
|
}
|
|
21711
22107
|
if (docs.defaultArgs && Object.keys(docs.defaultArgs).length > 0) {
|
|
21712
|
-
const filteredArgs = Object.entries(docs.defaultArgs).filter(
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
|
|
22108
|
+
const filteredArgs = Object.entries(docs.defaultArgs).filter(
|
|
22109
|
+
([key, value]) => {
|
|
22110
|
+
const prop = docs.props.find((p) => p.name === key);
|
|
22111
|
+
if (!prop?.default) return true;
|
|
22112
|
+
return String(value) !== prop.default;
|
|
22113
|
+
}
|
|
22114
|
+
);
|
|
21717
22115
|
if (filteredArgs.length > 0) {
|
|
21718
22116
|
sections.push("## Storybook Defaults", "");
|
|
21719
22117
|
sections.push(
|
|
@@ -21752,11 +22150,16 @@ function formatComponentDocs(docs) {
|
|
|
21752
22150
|
return sections.join("\n").trim();
|
|
21753
22151
|
}
|
|
21754
22152
|
async function startServer() {
|
|
21755
|
-
const server = new McpServer({
|
|
22153
|
+
const server = new McpServer({
|
|
22154
|
+
name: "ui-library",
|
|
22155
|
+
version: getPackageVersion()
|
|
22156
|
+
});
|
|
21756
22157
|
server.tool(
|
|
21757
22158
|
"list_components",
|
|
21758
22159
|
"List all UI components. Optionally filter by name, category, or description.",
|
|
21759
|
-
{
|
|
22160
|
+
{
|
|
22161
|
+
filter: external_exports.string().optional().describe("Filter by name/category/description")
|
|
22162
|
+
},
|
|
21760
22163
|
async ({ filter }) => {
|
|
21761
22164
|
try {
|
|
21762
22165
|
const components = listComponents(filter);
|
|
@@ -21789,7 +22192,9 @@ async function startServer() {
|
|
|
21789
22192
|
server.tool(
|
|
21790
22193
|
"get_component_docs",
|
|
21791
22194
|
"Get full documentation for a component including props, examples, and usage.",
|
|
21792
|
-
{
|
|
22195
|
+
{
|
|
22196
|
+
componentName: external_exports.string().describe('Component name (e.g., "UiButton" or "Button")')
|
|
22197
|
+
},
|
|
21793
22198
|
async ({ componentName }) => {
|
|
21794
22199
|
try {
|
|
21795
22200
|
const docs = getComponentDocs(componentName);
|
|
@@ -21800,6 +22205,60 @@ async function startServer() {
|
|
|
21800
22205
|
}
|
|
21801
22206
|
}
|
|
21802
22207
|
);
|
|
22208
|
+
server.tool(
|
|
22209
|
+
"list_chat_kit_components",
|
|
22210
|
+
"List all Chat Kit components. Optionally filter by name, category, or description.",
|
|
22211
|
+
{
|
|
22212
|
+
filter: external_exports.string().optional().describe("Filter by name/category/description")
|
|
22213
|
+
},
|
|
22214
|
+
async ({ filter }) => {
|
|
22215
|
+
try {
|
|
22216
|
+
const components = listChatKitComponents(filter);
|
|
22217
|
+
if (components.length === 0) {
|
|
22218
|
+
const message = filter ? `No chat-kit components matching "${filter}".` : "No chat-kit components found.";
|
|
22219
|
+
return text(message);
|
|
22220
|
+
}
|
|
22221
|
+
const grouped = components.reduce(
|
|
22222
|
+
(acc, component) => {
|
|
22223
|
+
(acc[component.category] ??= []).push(component);
|
|
22224
|
+
return acc;
|
|
22225
|
+
},
|
|
22226
|
+
{}
|
|
22227
|
+
);
|
|
22228
|
+
const sections = [
|
|
22229
|
+
`Found ${components.length} chat-kit component(s):`,
|
|
22230
|
+
""
|
|
22231
|
+
];
|
|
22232
|
+
Object.entries(grouped).forEach(([category, comps]) => {
|
|
22233
|
+
sections.push(`## ${category}`, "");
|
|
22234
|
+
comps.forEach((comp) => {
|
|
22235
|
+
sections.push(`- **${comp.name}**: ${comp.description}`);
|
|
22236
|
+
});
|
|
22237
|
+
sections.push("");
|
|
22238
|
+
});
|
|
22239
|
+
return text(sections.join("\n").trim());
|
|
22240
|
+
} catch (e) {
|
|
22241
|
+
return handleError(e);
|
|
22242
|
+
}
|
|
22243
|
+
}
|
|
22244
|
+
);
|
|
22245
|
+
server.tool(
|
|
22246
|
+
"get_chat_kit_docs",
|
|
22247
|
+
"Get full documentation for a Chat Kit component including props, examples, and usage.",
|
|
22248
|
+
{
|
|
22249
|
+
componentName: external_exports.string().describe('Component name (e.g., "CkChatBubble" or "ChatBubble")')
|
|
22250
|
+
},
|
|
22251
|
+
async ({ componentName }) => {
|
|
22252
|
+
try {
|
|
22253
|
+
const docs = getChatKitComponentDocs(componentName);
|
|
22254
|
+
if (!docs)
|
|
22255
|
+
return error2(`Chat Kit component "${componentName}" not found.`);
|
|
22256
|
+
return text(formatComponentDocs(docs));
|
|
22257
|
+
} catch (e) {
|
|
22258
|
+
return handleError(e);
|
|
22259
|
+
}
|
|
22260
|
+
}
|
|
22261
|
+
);
|
|
21803
22262
|
server.tool(
|
|
21804
22263
|
"get_setup_guide",
|
|
21805
22264
|
"Get the setup and installation guide for integrating the UI library into a project. Returns UnoCSS config, Vite config, required dependencies, and MCP setup instructions.",
|
|
@@ -21807,7 +22266,10 @@ async function startServer() {
|
|
|
21807
22266
|
async () => {
|
|
21808
22267
|
try {
|
|
21809
22268
|
const guide = getSetupGuide();
|
|
21810
|
-
if (!guide)
|
|
22269
|
+
if (!guide)
|
|
22270
|
+
return error2(
|
|
22271
|
+
"Setup guide not found. Is @aleph-alpha/ui-library installed?"
|
|
22272
|
+
);
|
|
21811
22273
|
return text(guide);
|
|
21812
22274
|
} catch (e) {
|
|
21813
22275
|
return handleError(e);
|