@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/cli.js
CHANGED
|
@@ -3222,8 +3222,8 @@ var require_utils = __commonJS({
|
|
|
3222
3222
|
}
|
|
3223
3223
|
return ind;
|
|
3224
3224
|
}
|
|
3225
|
-
function removeDotSegments(
|
|
3226
|
-
let input =
|
|
3225
|
+
function removeDotSegments(path12) {
|
|
3226
|
+
let input = path12;
|
|
3227
3227
|
const output = [];
|
|
3228
3228
|
let nextSlash = -1;
|
|
3229
3229
|
let len = 0;
|
|
@@ -3422,8 +3422,8 @@ var require_schemes = __commonJS({
|
|
|
3422
3422
|
wsComponent.secure = void 0;
|
|
3423
3423
|
}
|
|
3424
3424
|
if (wsComponent.resourceName) {
|
|
3425
|
-
const [
|
|
3426
|
-
wsComponent.path =
|
|
3425
|
+
const [path12, query] = wsComponent.resourceName.split("?");
|
|
3426
|
+
wsComponent.path = path12 && path12 !== "/" ? path12 : void 0;
|
|
3427
3427
|
wsComponent.query = query;
|
|
3428
3428
|
wsComponent.resourceName = void 0;
|
|
3429
3429
|
}
|
|
@@ -6785,12 +6785,12 @@ var require_dist = __commonJS({
|
|
|
6785
6785
|
throw new Error(`Unknown format "${name}"`);
|
|
6786
6786
|
return f;
|
|
6787
6787
|
};
|
|
6788
|
-
function addFormats(ajv, list,
|
|
6788
|
+
function addFormats(ajv, list, fs7, exportName) {
|
|
6789
6789
|
var _a;
|
|
6790
6790
|
var _b;
|
|
6791
6791
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6792
6792
|
for (const f of list)
|
|
6793
|
-
ajv.addFormat(f,
|
|
6793
|
+
ajv.addFormat(f, fs7[f]);
|
|
6794
6794
|
}
|
|
6795
6795
|
module.exports = exports = formatsPlugin;
|
|
6796
6796
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6847,8 +6847,18 @@ function findMatchingBrace(text2, openingBraceIndex, openChar = "{", closeChar =
|
|
|
6847
6847
|
var __filename = fileURLToPath(import.meta.url);
|
|
6848
6848
|
var __dirname = path.dirname(__filename);
|
|
6849
6849
|
var IDE_CONFIG = {
|
|
6850
|
-
claude: {
|
|
6851
|
-
|
|
6850
|
+
claude: {
|
|
6851
|
+
dir: null,
|
|
6852
|
+
file: ".mcp.json",
|
|
6853
|
+
name: "Claude Code",
|
|
6854
|
+
rootKey: "mcpServers"
|
|
6855
|
+
},
|
|
6856
|
+
cursor: {
|
|
6857
|
+
dir: ".cursor",
|
|
6858
|
+
file: "mcp.json",
|
|
6859
|
+
name: "Cursor",
|
|
6860
|
+
rootKey: "mcpServers"
|
|
6861
|
+
},
|
|
6852
6862
|
vscode: {
|
|
6853
6863
|
dir: ".vscode",
|
|
6854
6864
|
file: "mcp.json",
|
|
@@ -6871,7 +6881,9 @@ function getMcpServerPath(projectRoot) {
|
|
|
6871
6881
|
if (fs2.existsSync(nodeModulesPath)) return relativePath;
|
|
6872
6882
|
const absolutePath = path.resolve(__dirname, "cli.js");
|
|
6873
6883
|
if (fs2.existsSync(absolutePath)) return absolutePath;
|
|
6874
|
-
throw new Error(
|
|
6884
|
+
throw new Error(
|
|
6885
|
+
"Could not find lib-mcp. Make sure @aleph-alpha/lib-mcp is installed."
|
|
6886
|
+
);
|
|
6875
6887
|
}
|
|
6876
6888
|
function configureIDE(ide, projectRoot, mcpPath) {
|
|
6877
6889
|
const { dir, file, name, rootKey, extraFields } = IDE_CONFIG[ide];
|
|
@@ -6882,7 +6894,11 @@ function configureIDE(ide, projectRoot, mcpPath) {
|
|
|
6882
6894
|
}
|
|
6883
6895
|
const settings = readJsonFile(settingsFile) ?? {};
|
|
6884
6896
|
const servers = settings[rootKey] ?? {};
|
|
6885
|
-
servers["ui-library"] = {
|
|
6897
|
+
servers["ui-library"] = {
|
|
6898
|
+
command: "node",
|
|
6899
|
+
args: [mcpPath, "serve"],
|
|
6900
|
+
...extraFields
|
|
6901
|
+
};
|
|
6886
6902
|
settings[rootKey] = servers;
|
|
6887
6903
|
const tempFile = `${settingsFile}.tmp`;
|
|
6888
6904
|
try {
|
|
@@ -7413,8 +7429,8 @@ function getErrorMap() {
|
|
|
7413
7429
|
|
|
7414
7430
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
7415
7431
|
var makeIssue = (params) => {
|
|
7416
|
-
const { data, path:
|
|
7417
|
-
const fullPath = [...
|
|
7432
|
+
const { data, path: path12, errorMaps, issueData } = params;
|
|
7433
|
+
const fullPath = [...path12, ...issueData.path || []];
|
|
7418
7434
|
const fullIssue = {
|
|
7419
7435
|
...issueData,
|
|
7420
7436
|
path: fullPath
|
|
@@ -7530,11 +7546,11 @@ var errorUtil;
|
|
|
7530
7546
|
|
|
7531
7547
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
7532
7548
|
var ParseInputLazyPath = class {
|
|
7533
|
-
constructor(parent, value,
|
|
7549
|
+
constructor(parent, value, path12, key) {
|
|
7534
7550
|
this._cachedPath = [];
|
|
7535
7551
|
this.parent = parent;
|
|
7536
7552
|
this.data = value;
|
|
7537
|
-
this._path =
|
|
7553
|
+
this._path = path12;
|
|
7538
7554
|
this._key = key;
|
|
7539
7555
|
}
|
|
7540
7556
|
get path() {
|
|
@@ -10965,14 +10981,14 @@ var ostring = () => stringType().optional();
|
|
|
10965
10981
|
var onumber = () => numberType().optional();
|
|
10966
10982
|
var oboolean = () => booleanType().optional();
|
|
10967
10983
|
var coerce = {
|
|
10968
|
-
string: (arg) => ZodString.create({ ...arg, coerce: true }),
|
|
10969
|
-
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
|
|
10970
|
-
boolean: (arg) => ZodBoolean.create({
|
|
10984
|
+
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
10985
|
+
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
10986
|
+
boolean: ((arg) => ZodBoolean.create({
|
|
10971
10987
|
...arg,
|
|
10972
10988
|
coerce: true
|
|
10973
|
-
}),
|
|
10974
|
-
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
10975
|
-
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
10989
|
+
})),
|
|
10990
|
+
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
10991
|
+
date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
|
|
10976
10992
|
};
|
|
10977
10993
|
var NEVER = INVALID;
|
|
10978
10994
|
|
|
@@ -11172,10 +11188,10 @@ function assignProp(target, prop, value) {
|
|
|
11172
11188
|
configurable: true
|
|
11173
11189
|
});
|
|
11174
11190
|
}
|
|
11175
|
-
function getElementAtPath(obj,
|
|
11176
|
-
if (!
|
|
11191
|
+
function getElementAtPath(obj, path12) {
|
|
11192
|
+
if (!path12)
|
|
11177
11193
|
return obj;
|
|
11178
|
-
return
|
|
11194
|
+
return path12.reduce((acc, key) => acc?.[key], obj);
|
|
11179
11195
|
}
|
|
11180
11196
|
function promiseAllObject(promisesObj) {
|
|
11181
11197
|
const keys = Object.keys(promisesObj);
|
|
@@ -11495,11 +11511,11 @@ function aborted(x, startIndex = 0) {
|
|
|
11495
11511
|
}
|
|
11496
11512
|
return false;
|
|
11497
11513
|
}
|
|
11498
|
-
function prefixIssues(
|
|
11514
|
+
function prefixIssues(path12, issues) {
|
|
11499
11515
|
return issues.map((iss) => {
|
|
11500
11516
|
var _a;
|
|
11501
11517
|
(_a = iss).path ?? (_a.path = []);
|
|
11502
|
-
iss.path.unshift(
|
|
11518
|
+
iss.path.unshift(path12);
|
|
11503
11519
|
return iss;
|
|
11504
11520
|
});
|
|
11505
11521
|
}
|
|
@@ -14806,10 +14822,10 @@ var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
|
14806
14822
|
};
|
|
14807
14823
|
inst.clone = (_def, params) => clone(inst, _def, params);
|
|
14808
14824
|
inst.brand = () => inst;
|
|
14809
|
-
inst.register = (reg, meta) => {
|
|
14825
|
+
inst.register = ((reg, meta) => {
|
|
14810
14826
|
reg.add(inst, meta);
|
|
14811
14827
|
return inst;
|
|
14812
|
-
};
|
|
14828
|
+
});
|
|
14813
14829
|
});
|
|
14814
14830
|
var ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
|
|
14815
14831
|
$ZodObject.init(inst, def);
|
|
@@ -15072,10 +15088,10 @@ var ZodType2 = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
15072
15088
|
};
|
|
15073
15089
|
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
15074
15090
|
inst.brand = () => inst;
|
|
15075
|
-
inst.register = (reg, meta) => {
|
|
15091
|
+
inst.register = ((reg, meta) => {
|
|
15076
15092
|
reg.add(inst, meta);
|
|
15077
15093
|
return inst;
|
|
15078
|
-
};
|
|
15094
|
+
});
|
|
15079
15095
|
inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
|
|
15080
15096
|
inst.safeParse = (data, params) => safeParse3(inst, data, params);
|
|
15081
15097
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
@@ -17032,11 +17048,13 @@ function assertCompleteRequestPrompt(request) {
|
|
|
17032
17048
|
if (request.params.ref.type !== "ref/prompt") {
|
|
17033
17049
|
throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
|
|
17034
17050
|
}
|
|
17051
|
+
void request;
|
|
17035
17052
|
}
|
|
17036
17053
|
function assertCompleteRequestResourceTemplate(request) {
|
|
17037
17054
|
if (request.params.ref.type !== "ref/resource") {
|
|
17038
17055
|
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
|
|
17039
17056
|
}
|
|
17057
|
+
void request;
|
|
17040
17058
|
}
|
|
17041
17059
|
var CompleteResultSchema = ResultSchema.extend({
|
|
17042
17060
|
completion: looseObject({
|
|
@@ -21170,7 +21188,7 @@ function extractType(text2, startIndex) {
|
|
|
21170
21188
|
function parseInterface(content, interfaceName) {
|
|
21171
21189
|
const props = [];
|
|
21172
21190
|
const interfaceRegex = new RegExp(
|
|
21173
|
-
`(?:export\\s+)?${TYPE_OR_INTERFACE}\\s+${interfaceName}\\s*(?:extends\\s+[^{]+)?(?:=\\s*)?\\{([\\s\\S]*?)\\n\\}`,
|
|
21191
|
+
`(?:export\\s+)?${TYPE_OR_INTERFACE}\\s+${interfaceName}\\s*(?:<(?:\\{[^}]*\\}|[^>])*>)?\\s*(?:extends\\s+[^{]+)?(?:=\\s*)?\\{([\\s\\S]*?)\\n\\}`,
|
|
21174
21192
|
"m"
|
|
21175
21193
|
);
|
|
21176
21194
|
const match = content.match(interfaceRegex);
|
|
@@ -21185,7 +21203,10 @@ function parseInterface(content, interfaceName) {
|
|
|
21185
21203
|
const propName = propMatch[2];
|
|
21186
21204
|
const isOptional = !!propMatch[3];
|
|
21187
21205
|
const typeStartIndex = propMatch.index + propMatch[0].length;
|
|
21188
|
-
const { type: propType, endIndex } = extractType(
|
|
21206
|
+
const { type: propType, endIndex } = extractType(
|
|
21207
|
+
interfaceBody,
|
|
21208
|
+
typeStartIndex
|
|
21209
|
+
);
|
|
21189
21210
|
propStartRegex.lastIndex = endIndex + 1;
|
|
21190
21211
|
const jsdoc = parseJSDoc(jsdocComment);
|
|
21191
21212
|
props.push({
|
|
@@ -21202,7 +21223,9 @@ function parseInterface(content, interfaceName) {
|
|
|
21202
21223
|
function extractComponentDescription(content, interfaceName) {
|
|
21203
21224
|
const lines = content.split("\n");
|
|
21204
21225
|
const interfaceLineIndex = lines.findIndex(
|
|
21205
|
-
(line) => line.match(
|
|
21226
|
+
(line) => line.match(
|
|
21227
|
+
new RegExp(`export\\s+${TYPE_OR_INTERFACE}\\s+${interfaceName}`)
|
|
21228
|
+
)
|
|
21206
21229
|
);
|
|
21207
21230
|
if (interfaceLineIndex === -1) {
|
|
21208
21231
|
return "";
|
|
@@ -21228,7 +21251,9 @@ function extractComponentDescription(content, interfaceName) {
|
|
|
21228
21251
|
return "";
|
|
21229
21252
|
}
|
|
21230
21253
|
function resolveUnionOrIntersectionProps(content, typeName) {
|
|
21231
|
-
const typeDefRegex = new RegExp(
|
|
21254
|
+
const typeDefRegex = new RegExp(
|
|
21255
|
+
`export\\s+type\\s+${typeName}\\s*=\\s*([^;]+)`
|
|
21256
|
+
);
|
|
21232
21257
|
const match = content.match(typeDefRegex);
|
|
21233
21258
|
if (!match) return [];
|
|
21234
21259
|
const referencedTypes = match[1].split(/[|&]/).map((t) => t.trim()).filter((t) => t.endsWith("Props"));
|
|
@@ -21256,7 +21281,9 @@ function readTypesFile(filePath, componentName) {
|
|
|
21256
21281
|
return null;
|
|
21257
21282
|
}
|
|
21258
21283
|
const resolvedName = componentName || path2.basename(path2.dirname(filePath));
|
|
21259
|
-
const exactRegex = new RegExp(
|
|
21284
|
+
const exactRegex = new RegExp(
|
|
21285
|
+
`export\\s+${TYPE_OR_INTERFACE}\\s+(${resolvedName}Props)\\b`
|
|
21286
|
+
);
|
|
21260
21287
|
let propsInterfaceMatch = content.match(exactRegex);
|
|
21261
21288
|
if (!propsInterfaceMatch) {
|
|
21262
21289
|
const prefixRegex = new RegExp(
|
|
@@ -21300,20 +21327,39 @@ import * as path3 from "node:path";
|
|
|
21300
21327
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
21301
21328
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
21302
21329
|
var __dirname2 = path3.dirname(__filename2);
|
|
21303
|
-
function
|
|
21304
|
-
|
|
21305
|
-
|
|
21306
|
-
path3.
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21310
|
-
path3.
|
|
21330
|
+
function findInMonorepo(startDir, packageName) {
|
|
21331
|
+
let current = startDir;
|
|
21332
|
+
for (let i = 0; i < 10; i++) {
|
|
21333
|
+
const candidate = path3.join(current, "packages", packageName);
|
|
21334
|
+
if (fs3.existsSync(path3.join(candidate, "package.json"))) {
|
|
21335
|
+
return candidate;
|
|
21336
|
+
}
|
|
21337
|
+
const parent = path3.dirname(current);
|
|
21338
|
+
if (parent === current) break;
|
|
21339
|
+
current = parent;
|
|
21340
|
+
}
|
|
21341
|
+
return null;
|
|
21342
|
+
}
|
|
21343
|
+
function resolveWorkspacePackage(packageName, scope = "@aleph-alpha") {
|
|
21344
|
+
const fromDirname = findInMonorepo(__dirname2, packageName);
|
|
21345
|
+
if (fromDirname) return fromDirname;
|
|
21346
|
+
const fromCwd = findInMonorepo(process.cwd(), packageName);
|
|
21347
|
+
if (fromCwd) return fromCwd;
|
|
21348
|
+
const nodeModulesCandidates = [
|
|
21349
|
+
path3.resolve(__dirname2, `../../${scope}/${packageName}`),
|
|
21350
|
+
path3.resolve(__dirname2, `../../../${scope}/${packageName}`),
|
|
21351
|
+
path3.join(process.cwd(), `node_modules/${scope}/${packageName}`)
|
|
21311
21352
|
];
|
|
21312
|
-
for (const pkgPath of
|
|
21353
|
+
for (const pkgPath of nodeModulesCandidates) {
|
|
21313
21354
|
if (fs3.existsSync(path3.join(pkgPath, "package.json"))) {
|
|
21314
21355
|
return pkgPath;
|
|
21315
21356
|
}
|
|
21316
21357
|
}
|
|
21358
|
+
return null;
|
|
21359
|
+
}
|
|
21360
|
+
function findUiLibraryRoot() {
|
|
21361
|
+
const pkgPath = resolveWorkspacePackage("ui-library");
|
|
21362
|
+
if (pkgPath) return pkgPath;
|
|
21317
21363
|
throw new Error("Could not find @aleph-alpha/ui-library. Is it installed?");
|
|
21318
21364
|
}
|
|
21319
21365
|
function getLibraryRootPath() {
|
|
@@ -21329,6 +21375,21 @@ function getLibrarySourcePath() {
|
|
|
21329
21375
|
"Could not find UI library source directory. Is the package installed correctly?"
|
|
21330
21376
|
);
|
|
21331
21377
|
}
|
|
21378
|
+
function findChatKitRoot() {
|
|
21379
|
+
const pkgPath = resolveWorkspacePackage("chat-kit");
|
|
21380
|
+
if (pkgPath) return pkgPath;
|
|
21381
|
+
throw new Error("Could not find @aleph-alpha/chat-kit. Is it installed?");
|
|
21382
|
+
}
|
|
21383
|
+
function getChatKitSourcePath() {
|
|
21384
|
+
const chatKitRoot = findChatKitRoot();
|
|
21385
|
+
const srcPath = path3.join(chatKitRoot, "src");
|
|
21386
|
+
if (fs3.existsSync(srcPath)) {
|
|
21387
|
+
return srcPath;
|
|
21388
|
+
}
|
|
21389
|
+
throw new Error(
|
|
21390
|
+
"Could not find chat-kit source directory. Is the package installed correctly?"
|
|
21391
|
+
);
|
|
21392
|
+
}
|
|
21332
21393
|
function getMcpDirPath() {
|
|
21333
21394
|
const possiblePaths = [
|
|
21334
21395
|
// Bundled: from dist/utils -> package root
|
|
@@ -21351,6 +21412,12 @@ function getPackageRoot() {
|
|
|
21351
21412
|
return process.cwd();
|
|
21352
21413
|
}
|
|
21353
21414
|
|
|
21415
|
+
// src/utils/constants.ts
|
|
21416
|
+
var COMPONENT_PREFIX = "Ui";
|
|
21417
|
+
var CHAT_KIT_PREFIX = "Ck";
|
|
21418
|
+
var INTERNAL_DIRS = ["shadcn"];
|
|
21419
|
+
var TYPE_SUFFIXES = ["Props", "Variant", "Size"];
|
|
21420
|
+
|
|
21354
21421
|
// src/constants.ts
|
|
21355
21422
|
function detectCategoryDirs() {
|
|
21356
21423
|
const srcPath = getSrcPath();
|
|
@@ -21358,11 +21425,15 @@ function detectCategoryDirs() {
|
|
|
21358
21425
|
return [];
|
|
21359
21426
|
}
|
|
21360
21427
|
const entries = fs4.readdirSync(srcPath, { withFileTypes: true });
|
|
21361
|
-
return entries.filter((entry) => entry.isDirectory()).filter(
|
|
21428
|
+
return entries.filter((entry) => entry.isDirectory()).filter(
|
|
21429
|
+
(entry) => !entry.name.startsWith(".") && entry.name !== "node_modules"
|
|
21430
|
+
).filter((entry) => {
|
|
21362
21431
|
try {
|
|
21363
21432
|
const dirPath = path4.join(srcPath, entry.name);
|
|
21364
21433
|
const subEntries = fs4.readdirSync(dirPath, { withFileTypes: true });
|
|
21365
|
-
return subEntries.some(
|
|
21434
|
+
return subEntries.some(
|
|
21435
|
+
(sub) => sub.isDirectory() && sub.name.startsWith(COMPONENT_PREFIX)
|
|
21436
|
+
);
|
|
21366
21437
|
} catch {
|
|
21367
21438
|
return false;
|
|
21368
21439
|
}
|
|
@@ -21374,6 +21445,47 @@ function getCategoryDirs() {
|
|
|
21374
21445
|
cachedCategoryDirs = detectCategoryDirs();
|
|
21375
21446
|
return cachedCategoryDirs;
|
|
21376
21447
|
}
|
|
21448
|
+
function detectChatKitCategoryDirs() {
|
|
21449
|
+
const srcPath = getChatKitSrcPath();
|
|
21450
|
+
if (!srcPath || !fs4.existsSync(srcPath)) {
|
|
21451
|
+
return [];
|
|
21452
|
+
}
|
|
21453
|
+
const categories = [];
|
|
21454
|
+
const walk = (dir, relative, depth) => {
|
|
21455
|
+
let entries;
|
|
21456
|
+
try {
|
|
21457
|
+
entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
21458
|
+
} catch {
|
|
21459
|
+
return;
|
|
21460
|
+
}
|
|
21461
|
+
const hasChatKitSubdirs = entries.some(
|
|
21462
|
+
(sub) => sub.isDirectory() && sub.name.startsWith(CHAT_KIT_PREFIX)
|
|
21463
|
+
);
|
|
21464
|
+
if (hasChatKitSubdirs && relative) {
|
|
21465
|
+
categories.push(relative);
|
|
21466
|
+
return;
|
|
21467
|
+
}
|
|
21468
|
+
if (depth >= 2) return;
|
|
21469
|
+
for (const entry of entries) {
|
|
21470
|
+
if (!entry.isDirectory()) continue;
|
|
21471
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
21472
|
+
if (entry.name.startsWith(CHAT_KIT_PREFIX)) continue;
|
|
21473
|
+
walk(
|
|
21474
|
+
path4.join(dir, entry.name),
|
|
21475
|
+
relative ? path4.join(relative, entry.name) : entry.name,
|
|
21476
|
+
depth + 1
|
|
21477
|
+
);
|
|
21478
|
+
}
|
|
21479
|
+
};
|
|
21480
|
+
walk(srcPath, "", 0);
|
|
21481
|
+
return categories;
|
|
21482
|
+
}
|
|
21483
|
+
var cachedChatKitCategoryDirs = null;
|
|
21484
|
+
function getChatKitCategoryDirs() {
|
|
21485
|
+
if (cachedChatKitCategoryDirs) return cachedChatKitCategoryDirs;
|
|
21486
|
+
cachedChatKitCategoryDirs = detectChatKitCategoryDirs();
|
|
21487
|
+
return cachedChatKitCategoryDirs;
|
|
21488
|
+
}
|
|
21377
21489
|
function getSrcPath() {
|
|
21378
21490
|
try {
|
|
21379
21491
|
return getLibrarySourcePath();
|
|
@@ -21381,6 +21493,13 @@ function getSrcPath() {
|
|
|
21381
21493
|
return null;
|
|
21382
21494
|
}
|
|
21383
21495
|
}
|
|
21496
|
+
function getChatKitSrcPath() {
|
|
21497
|
+
try {
|
|
21498
|
+
return getChatKitSourcePath();
|
|
21499
|
+
} catch {
|
|
21500
|
+
return null;
|
|
21501
|
+
}
|
|
21502
|
+
}
|
|
21384
21503
|
var cachedMeta = null;
|
|
21385
21504
|
function loadComponentsMeta() {
|
|
21386
21505
|
if (cachedMeta) return cachedMeta;
|
|
@@ -21389,6 +21508,14 @@ function loadComponentsMeta() {
|
|
|
21389
21508
|
cachedMeta = readJsonFile(metaPath) ?? {};
|
|
21390
21509
|
return cachedMeta;
|
|
21391
21510
|
}
|
|
21511
|
+
var cachedChatKitMeta = null;
|
|
21512
|
+
function loadChatKitComponentsMeta() {
|
|
21513
|
+
if (cachedChatKitMeta) return cachedChatKitMeta;
|
|
21514
|
+
const mcpDir = getMcpDirPath();
|
|
21515
|
+
const metaPath = path4.join(mcpDir, "chat-kit-components-meta.json");
|
|
21516
|
+
cachedChatKitMeta = readJsonFile(metaPath) ?? {};
|
|
21517
|
+
return cachedChatKitMeta;
|
|
21518
|
+
}
|
|
21392
21519
|
function getPackageVersion() {
|
|
21393
21520
|
const pkgRoot = getPackageRoot();
|
|
21394
21521
|
const pkgPath = path4.join(pkgRoot, "package.json");
|
|
@@ -21396,11 +21523,6 @@ function getPackageVersion() {
|
|
|
21396
21523
|
return pkg?.version ?? "0.0.0";
|
|
21397
21524
|
}
|
|
21398
21525
|
|
|
21399
|
-
// src/utils/constants.ts
|
|
21400
|
-
var COMPONENT_PREFIX = "Ui";
|
|
21401
|
-
var INTERNAL_DIRS = ["shadcn"];
|
|
21402
|
-
var TYPE_SUFFIXES = ["Props", "Variant", "Size"];
|
|
21403
|
-
|
|
21404
21526
|
// src/utils/component-name.ts
|
|
21405
21527
|
function normalizeComponentName(name) {
|
|
21406
21528
|
if (name.startsWith(COMPONENT_PREFIX)) {
|
|
@@ -21436,7 +21558,11 @@ function scanCategoryDirectory(categoryDir) {
|
|
|
21436
21558
|
return {
|
|
21437
21559
|
name: componentName,
|
|
21438
21560
|
category: componentMeta?.category ?? "Uncategorized",
|
|
21439
|
-
description: getComponentDescription(
|
|
21561
|
+
description: getComponentDescription(
|
|
21562
|
+
componentName,
|
|
21563
|
+
componentMeta,
|
|
21564
|
+
componentDir
|
|
21565
|
+
)
|
|
21440
21566
|
};
|
|
21441
21567
|
});
|
|
21442
21568
|
}
|
|
@@ -21493,7 +21619,9 @@ function extractStories(content) {
|
|
|
21493
21619
|
if (storyName === "default") continue;
|
|
21494
21620
|
const storyStart = match.index;
|
|
21495
21621
|
const remainingContent = content.substring(storyStart);
|
|
21496
|
-
const templateRefMatch = remainingContent.match(
|
|
21622
|
+
const templateRefMatch = remainingContent.match(
|
|
21623
|
+
/code:\s*(\w+TemplateSource)/
|
|
21624
|
+
);
|
|
21497
21625
|
if (templateRefMatch) {
|
|
21498
21626
|
stories.set(storyName, templateRefMatch[1]);
|
|
21499
21627
|
}
|
|
@@ -21766,7 +21894,12 @@ function getComponentDocs(componentName) {
|
|
|
21766
21894
|
import * as path8 from "node:path";
|
|
21767
21895
|
function getSetupGuide() {
|
|
21768
21896
|
const libraryRoot = getLibraryRootPath();
|
|
21769
|
-
const quickStartPath = path8.join(
|
|
21897
|
+
const quickStartPath = path8.join(
|
|
21898
|
+
libraryRoot,
|
|
21899
|
+
"docs",
|
|
21900
|
+
"public-docs",
|
|
21901
|
+
"quick-start.md"
|
|
21902
|
+
);
|
|
21770
21903
|
const quickStart = readTextFile(quickStartPath);
|
|
21771
21904
|
if (quickStart) {
|
|
21772
21905
|
return quickStart;
|
|
@@ -21779,8 +21912,287 @@ function getSetupGuide() {
|
|
|
21779
21912
|
return null;
|
|
21780
21913
|
}
|
|
21781
21914
|
|
|
21915
|
+
// src/tools/list-chat-kit-components.ts
|
|
21916
|
+
import * as fs6 from "node:fs";
|
|
21917
|
+
import * as path10 from "node:path";
|
|
21918
|
+
|
|
21919
|
+
// src/readers/chat-kit-types-reader.ts
|
|
21920
|
+
import * as path9 from "node:path";
|
|
21921
|
+
var TYPE_OR_INTERFACE2 = "(?:interface|type)";
|
|
21922
|
+
function parseJSDoc2(comment) {
|
|
21923
|
+
const lines = comment.replace(/\/\*\*|\*\/|\*/g, "").split("\n").map((line) => line.trim()).filter(Boolean);
|
|
21924
|
+
let description = "";
|
|
21925
|
+
let defaultValue;
|
|
21926
|
+
let example;
|
|
21927
|
+
for (const line of lines) {
|
|
21928
|
+
if (line.startsWith("@default")) {
|
|
21929
|
+
defaultValue = line.replace("@default", "").trim().replace(/^['"]|['"]$/g, "");
|
|
21930
|
+
} else if (line.startsWith("@example")) {
|
|
21931
|
+
example = line.replace("@example", "").trim();
|
|
21932
|
+
} else if (!line.startsWith("@")) {
|
|
21933
|
+
description += (description ? " " : "") + line;
|
|
21934
|
+
}
|
|
21935
|
+
}
|
|
21936
|
+
return { description, default: defaultValue, example };
|
|
21937
|
+
}
|
|
21938
|
+
function extractType2(text2, startIndex) {
|
|
21939
|
+
let depth = 0;
|
|
21940
|
+
let i = startIndex;
|
|
21941
|
+
while (i < text2.length) {
|
|
21942
|
+
const char = text2[i];
|
|
21943
|
+
const prevChar = i > 0 ? text2[i - 1] : "";
|
|
21944
|
+
if (char === "<" || char === "{" || char === "(" || char === "[") {
|
|
21945
|
+
depth++;
|
|
21946
|
+
} else if (char === "}" || char === ")" || char === "]") {
|
|
21947
|
+
depth = Math.max(0, depth - 1);
|
|
21948
|
+
} else if (char === ">") {
|
|
21949
|
+
if (prevChar !== "=") {
|
|
21950
|
+
depth = Math.max(0, depth - 1);
|
|
21951
|
+
}
|
|
21952
|
+
} else if (char === ";" && depth === 0) {
|
|
21953
|
+
return { type: text2.slice(startIndex, i).trim(), endIndex: i };
|
|
21954
|
+
}
|
|
21955
|
+
i++;
|
|
21956
|
+
}
|
|
21957
|
+
return { type: text2.slice(startIndex).trim(), endIndex: text2.length };
|
|
21958
|
+
}
|
|
21959
|
+
function parseInterface2(content, interfaceName) {
|
|
21960
|
+
const props = [];
|
|
21961
|
+
const interfaceRegex = new RegExp(
|
|
21962
|
+
`(?:export\\s+)?${TYPE_OR_INTERFACE2}\\s+${interfaceName}\\s*(?:<(?:\\{[^}]*\\}|[^>])*>)?\\s*(?:extends\\s+[^{]+)?(?:=\\s*)?\\{([\\s\\S]*?)\\n\\}`,
|
|
21963
|
+
"m"
|
|
21964
|
+
);
|
|
21965
|
+
const match = content.match(interfaceRegex);
|
|
21966
|
+
if (!match) {
|
|
21967
|
+
return props;
|
|
21968
|
+
}
|
|
21969
|
+
const interfaceBody = match[1];
|
|
21970
|
+
const propStartRegex = /(?:\/\*\*([\s\S]*?)\*\/\s*)?([\w]+)(\?)?:\s*/g;
|
|
21971
|
+
let propMatch;
|
|
21972
|
+
while ((propMatch = propStartRegex.exec(interfaceBody)) !== null) {
|
|
21973
|
+
const jsdocComment = propMatch[1] || "";
|
|
21974
|
+
const propName = propMatch[2];
|
|
21975
|
+
const isOptional = !!propMatch[3];
|
|
21976
|
+
const typeStartIndex = propMatch.index + propMatch[0].length;
|
|
21977
|
+
const { type: propType, endIndex } = extractType2(
|
|
21978
|
+
interfaceBody,
|
|
21979
|
+
typeStartIndex
|
|
21980
|
+
);
|
|
21981
|
+
propStartRegex.lastIndex = endIndex + 1;
|
|
21982
|
+
const jsdoc = parseJSDoc2(jsdocComment);
|
|
21983
|
+
props.push({
|
|
21984
|
+
name: propName,
|
|
21985
|
+
type: propType,
|
|
21986
|
+
required: !isOptional,
|
|
21987
|
+
description: jsdoc.description,
|
|
21988
|
+
default: jsdoc.default,
|
|
21989
|
+
example: jsdoc.example
|
|
21990
|
+
});
|
|
21991
|
+
}
|
|
21992
|
+
return props;
|
|
21993
|
+
}
|
|
21994
|
+
function extractComponentDescription2(content, interfaceName) {
|
|
21995
|
+
const lines = content.split("\n");
|
|
21996
|
+
const interfaceLineIndex = lines.findIndex(
|
|
21997
|
+
(line) => line.match(
|
|
21998
|
+
new RegExp(`export\\s+${TYPE_OR_INTERFACE2}\\s+${interfaceName}`)
|
|
21999
|
+
)
|
|
22000
|
+
);
|
|
22001
|
+
if (interfaceLineIndex === -1) {
|
|
22002
|
+
return "";
|
|
22003
|
+
}
|
|
22004
|
+
let jsdocEndIndex = -1;
|
|
22005
|
+
for (let i = interfaceLineIndex - 1; i >= 0; i--) {
|
|
22006
|
+
const line = lines[i].trim();
|
|
22007
|
+
if (line === "" || line === "*/") {
|
|
22008
|
+
if (line === "*/") {
|
|
22009
|
+
jsdocEndIndex = i;
|
|
22010
|
+
}
|
|
22011
|
+
continue;
|
|
22012
|
+
}
|
|
22013
|
+
if (!line.startsWith("*") && !line.startsWith("/**")) {
|
|
22014
|
+
break;
|
|
22015
|
+
}
|
|
22016
|
+
if (line.startsWith("/**")) {
|
|
22017
|
+
const jsdocLines = lines.slice(i, jsdocEndIndex + 1);
|
|
22018
|
+
const jsdocContent = jsdocLines.join("\n");
|
|
22019
|
+
return parseJSDoc2(jsdocContent).description;
|
|
22020
|
+
}
|
|
22021
|
+
}
|
|
22022
|
+
return "";
|
|
22023
|
+
}
|
|
22024
|
+
function resolveUnionOrIntersectionProps2(content, typeName) {
|
|
22025
|
+
const typeDefRegex = new RegExp(
|
|
22026
|
+
`export\\s+type\\s+${typeName}\\s*=\\s*([^;]+)`
|
|
22027
|
+
);
|
|
22028
|
+
const match = content.match(typeDefRegex);
|
|
22029
|
+
if (!match) return [];
|
|
22030
|
+
const referencedTypes = match[1].split(/[|&]/).map((t) => t.trim()).filter((t) => t.endsWith("Props"));
|
|
22031
|
+
if (referencedTypes.length === 0) return [];
|
|
22032
|
+
const firstBranch = referencedTypes[0];
|
|
22033
|
+
const extendsRegex = new RegExp(
|
|
22034
|
+
`(?:export\\s+)?${TYPE_OR_INTERFACE2}\\s+${firstBranch}\\s+extends\\s+(\\w+)`
|
|
22035
|
+
);
|
|
22036
|
+
const extendsMatch = content.match(extendsRegex);
|
|
22037
|
+
const allProps = [];
|
|
22038
|
+
if (extendsMatch) {
|
|
22039
|
+
allProps.push(...parseInterface2(content, extendsMatch[1]));
|
|
22040
|
+
}
|
|
22041
|
+
allProps.push(...parseInterface2(content, firstBranch));
|
|
22042
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22043
|
+
return allProps.filter((p) => {
|
|
22044
|
+
if (seen.has(p.name)) return false;
|
|
22045
|
+
seen.add(p.name);
|
|
22046
|
+
return true;
|
|
22047
|
+
});
|
|
22048
|
+
}
|
|
22049
|
+
function readChatKitTypesFile(filePath, componentName) {
|
|
22050
|
+
const content = readTextFile(filePath);
|
|
22051
|
+
if (!content) {
|
|
22052
|
+
return null;
|
|
22053
|
+
}
|
|
22054
|
+
const resolvedName = componentName || path9.basename(path9.dirname(filePath));
|
|
22055
|
+
const exactRegex = new RegExp(
|
|
22056
|
+
`export\\s+${TYPE_OR_INTERFACE2}\\s+(${resolvedName}Props)\\b`
|
|
22057
|
+
);
|
|
22058
|
+
let propsInterfaceMatch = content.match(exactRegex);
|
|
22059
|
+
if (!propsInterfaceMatch) {
|
|
22060
|
+
const prefixRegex = new RegExp(
|
|
22061
|
+
`export\\s+${TYPE_OR_INTERFACE2}\\s+(${resolvedName}\\w*Props)\\b`
|
|
22062
|
+
);
|
|
22063
|
+
propsInterfaceMatch = content.match(prefixRegex);
|
|
22064
|
+
}
|
|
22065
|
+
if (!propsInterfaceMatch) {
|
|
22066
|
+
propsInterfaceMatch = content.match(
|
|
22067
|
+
new RegExp(`export\\s+${TYPE_OR_INTERFACE2}\\s+(Ck\\w+Props)\\b`)
|
|
22068
|
+
);
|
|
22069
|
+
}
|
|
22070
|
+
if (!propsInterfaceMatch) {
|
|
22071
|
+
return null;
|
|
22072
|
+
}
|
|
22073
|
+
const interfaceName = propsInterfaceMatch[1];
|
|
22074
|
+
const matchedComponentName = interfaceName.replace("Props", "");
|
|
22075
|
+
const description = extractComponentDescription2(content, interfaceName);
|
|
22076
|
+
let props = parseInterface2(content, interfaceName);
|
|
22077
|
+
if (props.length === 0) {
|
|
22078
|
+
props = resolveUnionOrIntersectionProps2(content, interfaceName);
|
|
22079
|
+
}
|
|
22080
|
+
return {
|
|
22081
|
+
name: matchedComponentName,
|
|
22082
|
+
description,
|
|
22083
|
+
props
|
|
22084
|
+
};
|
|
22085
|
+
}
|
|
22086
|
+
function readChatKitComponentTypes(componentDir) {
|
|
22087
|
+
const typesPath = path9.join(componentDir, "types.ts");
|
|
22088
|
+
return readChatKitTypesFile(typesPath, path9.basename(componentDir));
|
|
22089
|
+
}
|
|
22090
|
+
|
|
22091
|
+
// src/tools/list-chat-kit-components.ts
|
|
22092
|
+
function isChatKitComponent(dirName) {
|
|
22093
|
+
return dirName.startsWith(CHAT_KIT_PREFIX);
|
|
22094
|
+
}
|
|
22095
|
+
function getDescription(componentName, componentMeta, componentDir) {
|
|
22096
|
+
if (componentMeta?.description) return componentMeta.description;
|
|
22097
|
+
const typeInfo = readChatKitComponentTypes(componentDir);
|
|
22098
|
+
if (typeInfo?.description) return typeInfo.description;
|
|
22099
|
+
return `${componentName} component`;
|
|
22100
|
+
}
|
|
22101
|
+
function matchesFilter2(component, filter) {
|
|
22102
|
+
const filterLower = filter.toLowerCase();
|
|
22103
|
+
return component.name.toLowerCase().includes(filterLower) || component.category.toLowerCase().includes(filterLower) || component.description.toLowerCase().includes(filterLower);
|
|
22104
|
+
}
|
|
22105
|
+
function listChatKitComponents(filter) {
|
|
22106
|
+
const srcPath = getChatKitSourcePath();
|
|
22107
|
+
const meta = loadChatKitComponentsMeta();
|
|
22108
|
+
const allComponents = getChatKitCategoryDirs().flatMap((category) => {
|
|
22109
|
+
const categoryPath = path10.join(srcPath, category);
|
|
22110
|
+
if (!isDirectory(categoryPath)) return [];
|
|
22111
|
+
return fs6.readdirSync(categoryPath, { withFileTypes: true }).filter((e) => e.isDirectory() && isChatKitComponent(e.name)).map((e) => {
|
|
22112
|
+
const componentDir = path10.join(categoryPath, e.name);
|
|
22113
|
+
const componentMeta = meta[e.name];
|
|
22114
|
+
return {
|
|
22115
|
+
name: e.name,
|
|
22116
|
+
category: componentMeta?.category ?? "Uncategorized",
|
|
22117
|
+
description: getDescription(e.name, componentMeta, componentDir)
|
|
22118
|
+
};
|
|
22119
|
+
});
|
|
22120
|
+
});
|
|
22121
|
+
allComponents.sort((a, b) => a.name.localeCompare(b.name));
|
|
22122
|
+
return filter ? allComponents.filter((c) => matchesFilter2(c, filter)) : allComponents;
|
|
22123
|
+
}
|
|
22124
|
+
|
|
22125
|
+
// src/tools/get-chat-kit-docs.ts
|
|
22126
|
+
import * as path11 from "node:path";
|
|
22127
|
+
function normalizeChatKitName(name) {
|
|
22128
|
+
return name.startsWith(CHAT_KIT_PREFIX) ? name : `${CHAT_KIT_PREFIX}${name}`;
|
|
22129
|
+
}
|
|
22130
|
+
function findChatKitComponentDir(componentName) {
|
|
22131
|
+
const srcPath = getChatKitSourcePath();
|
|
22132
|
+
for (const category of getChatKitCategoryDirs()) {
|
|
22133
|
+
const dir = path11.join(srcPath, category, componentName);
|
|
22134
|
+
if (isDirectory(dir)) return dir;
|
|
22135
|
+
}
|
|
22136
|
+
return null;
|
|
22137
|
+
}
|
|
22138
|
+
function isTypeSuffix2(name) {
|
|
22139
|
+
return TYPE_SUFFIXES.some((suffix) => name.endsWith(suffix));
|
|
22140
|
+
}
|
|
22141
|
+
function extractSubComponents2(indexPath, mainComponentName) {
|
|
22142
|
+
const content = readTextFile(indexPath);
|
|
22143
|
+
if (!content) return [];
|
|
22144
|
+
const subComponents = /* @__PURE__ */ new Set();
|
|
22145
|
+
const exportRegex = /export\s*\{[^}]*(?:default\s+as\s+)?(\w+)[^}]*\}/g;
|
|
22146
|
+
let match;
|
|
22147
|
+
while ((match = exportRegex.exec(content)) !== null) {
|
|
22148
|
+
const exportName = match[1];
|
|
22149
|
+
if (exportName.startsWith(mainComponentName) && exportName !== mainComponentName && !isTypeSuffix2(exportName)) {
|
|
22150
|
+
subComponents.add(exportName);
|
|
22151
|
+
}
|
|
22152
|
+
}
|
|
22153
|
+
return Array.from(subComponents).sort();
|
|
22154
|
+
}
|
|
22155
|
+
function getChatKitComponentDocs(componentName) {
|
|
22156
|
+
const name = normalizeChatKitName(componentName);
|
|
22157
|
+
const componentDir = findChatKitComponentDir(name);
|
|
22158
|
+
if (!componentDir) return null;
|
|
22159
|
+
const typeInfo = readChatKitComponentTypes(componentDir);
|
|
22160
|
+
const props = typeInfo?.props || [];
|
|
22161
|
+
let description = typeInfo?.description || "";
|
|
22162
|
+
const storiesInfo = readComponentStories(componentDir);
|
|
22163
|
+
const examples = storiesInfo?.examples || [];
|
|
22164
|
+
const usageGuidance = storiesInfo?.usageGuidance || [];
|
|
22165
|
+
if (!description && usageGuidance.length > 0) {
|
|
22166
|
+
description = usageGuidance[0];
|
|
22167
|
+
}
|
|
22168
|
+
if (!description) {
|
|
22169
|
+
description = `${name} component from @aleph-alpha/chat-kit`;
|
|
22170
|
+
}
|
|
22171
|
+
const indexPath = path11.join(componentDir, "index.ts");
|
|
22172
|
+
const subComponents = readTextFile(indexPath) ? extractSubComponents2(indexPath, name) : void 0;
|
|
22173
|
+
if (storiesInfo?.argTypes) {
|
|
22174
|
+
for (const argType of storiesInfo.argTypes) {
|
|
22175
|
+
const prop = props.find((p) => p.name === argType.name);
|
|
22176
|
+
if (prop && !prop.description && argType.description) {
|
|
22177
|
+
prop.description = argType.description;
|
|
22178
|
+
}
|
|
22179
|
+
}
|
|
22180
|
+
}
|
|
22181
|
+
return {
|
|
22182
|
+
name,
|
|
22183
|
+
description,
|
|
22184
|
+
props,
|
|
22185
|
+
examples,
|
|
22186
|
+
usageGuidance: [...new Set(usageGuidance)],
|
|
22187
|
+
subComponents: subComponents && subComponents.length > 0 ? subComponents : void 0,
|
|
22188
|
+
defaultArgs: storiesInfo?.defaultArgs
|
|
22189
|
+
};
|
|
22190
|
+
}
|
|
22191
|
+
|
|
21782
22192
|
// src/server.ts
|
|
21783
|
-
var text = (t) => ({
|
|
22193
|
+
var text = (t) => ({
|
|
22194
|
+
content: [{ type: "text", text: t }]
|
|
22195
|
+
});
|
|
21784
22196
|
var error2 = (msg) => ({ ...text(msg), isError: true });
|
|
21785
22197
|
function handleError(e) {
|
|
21786
22198
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -21805,11 +22217,13 @@ function formatComponentDocs(docs) {
|
|
|
21805
22217
|
docs.props.forEach((prop) => sections.push(...formatProp(prop)));
|
|
21806
22218
|
}
|
|
21807
22219
|
if (docs.defaultArgs && Object.keys(docs.defaultArgs).length > 0) {
|
|
21808
|
-
const filteredArgs = Object.entries(docs.defaultArgs).filter(
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
21812
|
-
|
|
22220
|
+
const filteredArgs = Object.entries(docs.defaultArgs).filter(
|
|
22221
|
+
([key, value]) => {
|
|
22222
|
+
const prop = docs.props.find((p) => p.name === key);
|
|
22223
|
+
if (!prop?.default) return true;
|
|
22224
|
+
return String(value) !== prop.default;
|
|
22225
|
+
}
|
|
22226
|
+
);
|
|
21813
22227
|
if (filteredArgs.length > 0) {
|
|
21814
22228
|
sections.push("## Storybook Defaults", "");
|
|
21815
22229
|
sections.push(
|
|
@@ -21848,11 +22262,16 @@ function formatComponentDocs(docs) {
|
|
|
21848
22262
|
return sections.join("\n").trim();
|
|
21849
22263
|
}
|
|
21850
22264
|
async function startServer() {
|
|
21851
|
-
const server = new McpServer({
|
|
22265
|
+
const server = new McpServer({
|
|
22266
|
+
name: "ui-library",
|
|
22267
|
+
version: getPackageVersion()
|
|
22268
|
+
});
|
|
21852
22269
|
server.tool(
|
|
21853
22270
|
"list_components",
|
|
21854
22271
|
"List all UI components. Optionally filter by name, category, or description.",
|
|
21855
|
-
{
|
|
22272
|
+
{
|
|
22273
|
+
filter: external_exports.string().optional().describe("Filter by name/category/description")
|
|
22274
|
+
},
|
|
21856
22275
|
async ({ filter }) => {
|
|
21857
22276
|
try {
|
|
21858
22277
|
const components = listComponents(filter);
|
|
@@ -21885,7 +22304,9 @@ async function startServer() {
|
|
|
21885
22304
|
server.tool(
|
|
21886
22305
|
"get_component_docs",
|
|
21887
22306
|
"Get full documentation for a component including props, examples, and usage.",
|
|
21888
|
-
{
|
|
22307
|
+
{
|
|
22308
|
+
componentName: external_exports.string().describe('Component name (e.g., "UiButton" or "Button")')
|
|
22309
|
+
},
|
|
21889
22310
|
async ({ componentName }) => {
|
|
21890
22311
|
try {
|
|
21891
22312
|
const docs = getComponentDocs(componentName);
|
|
@@ -21896,6 +22317,60 @@ async function startServer() {
|
|
|
21896
22317
|
}
|
|
21897
22318
|
}
|
|
21898
22319
|
);
|
|
22320
|
+
server.tool(
|
|
22321
|
+
"list_chat_kit_components",
|
|
22322
|
+
"List all Chat Kit components. Optionally filter by name, category, or description.",
|
|
22323
|
+
{
|
|
22324
|
+
filter: external_exports.string().optional().describe("Filter by name/category/description")
|
|
22325
|
+
},
|
|
22326
|
+
async ({ filter }) => {
|
|
22327
|
+
try {
|
|
22328
|
+
const components = listChatKitComponents(filter);
|
|
22329
|
+
if (components.length === 0) {
|
|
22330
|
+
const message = filter ? `No chat-kit components matching "${filter}".` : "No chat-kit components found.";
|
|
22331
|
+
return text(message);
|
|
22332
|
+
}
|
|
22333
|
+
const grouped = components.reduce(
|
|
22334
|
+
(acc, component) => {
|
|
22335
|
+
(acc[component.category] ??= []).push(component);
|
|
22336
|
+
return acc;
|
|
22337
|
+
},
|
|
22338
|
+
{}
|
|
22339
|
+
);
|
|
22340
|
+
const sections = [
|
|
22341
|
+
`Found ${components.length} chat-kit component(s):`,
|
|
22342
|
+
""
|
|
22343
|
+
];
|
|
22344
|
+
Object.entries(grouped).forEach(([category, comps]) => {
|
|
22345
|
+
sections.push(`## ${category}`, "");
|
|
22346
|
+
comps.forEach((comp) => {
|
|
22347
|
+
sections.push(`- **${comp.name}**: ${comp.description}`);
|
|
22348
|
+
});
|
|
22349
|
+
sections.push("");
|
|
22350
|
+
});
|
|
22351
|
+
return text(sections.join("\n").trim());
|
|
22352
|
+
} catch (e) {
|
|
22353
|
+
return handleError(e);
|
|
22354
|
+
}
|
|
22355
|
+
}
|
|
22356
|
+
);
|
|
22357
|
+
server.tool(
|
|
22358
|
+
"get_chat_kit_docs",
|
|
22359
|
+
"Get full documentation for a Chat Kit component including props, examples, and usage.",
|
|
22360
|
+
{
|
|
22361
|
+
componentName: external_exports.string().describe('Component name (e.g., "CkChatBubble" or "ChatBubble")')
|
|
22362
|
+
},
|
|
22363
|
+
async ({ componentName }) => {
|
|
22364
|
+
try {
|
|
22365
|
+
const docs = getChatKitComponentDocs(componentName);
|
|
22366
|
+
if (!docs)
|
|
22367
|
+
return error2(`Chat Kit component "${componentName}" not found.`);
|
|
22368
|
+
return text(formatComponentDocs(docs));
|
|
22369
|
+
} catch (e) {
|
|
22370
|
+
return handleError(e);
|
|
22371
|
+
}
|
|
22372
|
+
}
|
|
22373
|
+
);
|
|
21899
22374
|
server.tool(
|
|
21900
22375
|
"get_setup_guide",
|
|
21901
22376
|
"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.",
|
|
@@ -21903,7 +22378,10 @@ async function startServer() {
|
|
|
21903
22378
|
async () => {
|
|
21904
22379
|
try {
|
|
21905
22380
|
const guide = getSetupGuide();
|
|
21906
|
-
if (!guide)
|
|
22381
|
+
if (!guide)
|
|
22382
|
+
return error2(
|
|
22383
|
+
"Setup guide not found. Is @aleph-alpha/ui-library installed?"
|
|
22384
|
+
);
|
|
21907
22385
|
return text(guide);
|
|
21908
22386
|
} catch (e) {
|
|
21909
22387
|
return handleError(e);
|