@douyinfe/semi-mcp 1.0.3 → 1.0.4
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 +37 -18
- package/dist/index.js +14 -71
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,29 +94,48 @@ Get specific component documentation:
|
|
|
94
94
|
|
|
95
95
|
**Response Format:**
|
|
96
96
|
|
|
97
|
+
All responses are returned as plain text for AI-friendly consumption.
|
|
98
|
+
|
|
97
99
|
When getting component list:
|
|
98
|
-
```json
|
|
99
|
-
{
|
|
100
|
-
"version": "2.89.2-alpha.3",
|
|
101
|
-
"components": ["button", "input", "select", ...],
|
|
102
|
-
"count": 70
|
|
103
|
-
}
|
|
104
100
|
```
|
|
101
|
+
Semi Design 组件列表 (版本 2.89.2-alpha.3),共 70 个组件:
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"version": "2.89.2-alpha.3",
|
|
111
|
-
"category": "basic",
|
|
112
|
-
"documents": ["index.md", "index-en-us.md"],
|
|
113
|
-
"count": 2,
|
|
114
|
-
"allComponents": ["button", "input", "select", ...],
|
|
115
|
-
"allComponentsCount": 70
|
|
116
|
-
}
|
|
103
|
+
button, input, select, table, ...
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
When getting small component documentation (< 888 lines):
|
|
117
107
|
```
|
|
108
|
+
===== index.md =====
|
|
118
109
|
|
|
119
|
-
|
|
110
|
+
---
|
|
111
|
+
title: Button
|
|
112
|
+
...
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Usage
|
|
116
|
+
...
|
|
117
|
+
|
|
118
|
+
===== index-en-US.md =====
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
title: Button
|
|
122
|
+
...
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Usage
|
|
126
|
+
...
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
When getting large component documentation (> 888 lines), the tool automatically saves to temp directory:
|
|
130
|
+
```
|
|
131
|
+
组件 Table (版本 2.89.2-alpha.3) 文档较大,已保存到临时目录。
|
|
132
|
+
|
|
133
|
+
文档文件列表:
|
|
134
|
+
- /tmp/semi-docs-table-2.89.2-alpha.3-1234567890/index.md (6,055 行)
|
|
135
|
+
- /tmp/semi-docs-table-2.89.2-alpha.3-1234567890/index-en-US.md (5,660 行)
|
|
136
|
+
|
|
137
|
+
请使用文件读取工具查看文档内容。
|
|
138
|
+
```
|
|
120
139
|
|
|
121
140
|
### Resources
|
|
122
141
|
|
package/dist/index.js
CHANGED
|
@@ -280,15 +280,7 @@ async function handleGetSemiDocument(args) {
|
|
|
280
280
|
content: [
|
|
281
281
|
{
|
|
282
282
|
type: 'text',
|
|
283
|
-
text:
|
|
284
|
-
componentName: componentName.toLowerCase(),
|
|
285
|
-
version,
|
|
286
|
-
error: '未找到组件文档',
|
|
287
|
-
documents: [],
|
|
288
|
-
count: 0,
|
|
289
|
-
allComponents,
|
|
290
|
-
allComponentsCount: allComponents.length
|
|
291
|
-
}, null, 2)
|
|
283
|
+
text: `未找到组件 "${componentName}" 的文档 (版本 ${version})。\n\n可用组件列表:${allComponents.join(', ')}`
|
|
292
284
|
}
|
|
293
285
|
]
|
|
294
286
|
};
|
|
@@ -306,68 +298,32 @@ async function handleGetSemiDocument(args) {
|
|
|
306
298
|
await mkdir(tempDir, {
|
|
307
299
|
recursive: true
|
|
308
300
|
});
|
|
309
|
-
const filePaths = [];
|
|
310
301
|
for (const doc of result.documents){
|
|
311
302
|
const filePath = join(tempDir, doc.name);
|
|
312
303
|
await writeFile(filePath, doc.content, 'utf-8');
|
|
313
|
-
filePaths.push(filePath);
|
|
314
|
-
}
|
|
315
|
-
const largeDocs = documentsWithLines.filter((doc)=>doc.lines > 888);
|
|
316
|
-
let message = `文档已保存到临时目录: ${tempDir}\n请使用文件读取工具查看文档内容。`;
|
|
317
|
-
if (hasLargeDocument && !userExplicitlySetGetPath) {
|
|
318
|
-
const largeDocNames = largeDocs.map((doc)=>`${doc.name} (${doc.lines.toLocaleString()} 行)`).join(', ');
|
|
319
|
-
message = `文档已保存到临时目录: ${tempDir}\n注意:以下文档文件较大,已自动保存到临时目录:${largeDocNames}\n请使用文件读取工具查看文档内容。`;
|
|
320
|
-
} else if (hasLargeDocument) {
|
|
321
|
-
const largeDocNames = largeDocs.map((doc)=>`${doc.name} (${doc.lines.toLocaleString()} 行)`).join(', ');
|
|
322
|
-
message = `文档已保存到临时目录: ${tempDir}\n注意:以下文档文件较大:${largeDocNames}\n请使用文件读取工具查看文档内容。`;
|
|
323
304
|
}
|
|
305
|
+
const fileList = documentsWithLines.map((doc)=>` - ${join(tempDir, doc.name)} (${doc.lines.toLocaleString()} 行)`).join('\n');
|
|
306
|
+
const message = `组件 ${componentName} (版本 ${version}) 文档较大,已保存到临时目录。
|
|
307
|
+
|
|
308
|
+
文档文件列表:
|
|
309
|
+
${fileList}
|
|
310
|
+
|
|
311
|
+
请使用文件读取工具查看文档内容。`;
|
|
324
312
|
return {
|
|
325
313
|
content: [
|
|
326
314
|
{
|
|
327
315
|
type: 'text',
|
|
328
|
-
text:
|
|
329
|
-
componentName: componentName.toLowerCase(),
|
|
330
|
-
version,
|
|
331
|
-
category: result.category,
|
|
332
|
-
tempDirectory: tempDir,
|
|
333
|
-
files: documentsWithLines.map((doc)=>({
|
|
334
|
-
name: doc.name,
|
|
335
|
-
path: join(tempDir, doc.name),
|
|
336
|
-
contentLength: doc.content.length,
|
|
337
|
-
lines: doc.lines
|
|
338
|
-
})),
|
|
339
|
-
count: result.documents.length,
|
|
340
|
-
message,
|
|
341
|
-
autoGetPath: hasLargeDocument && !userExplicitlySetGetPath,
|
|
342
|
-
allComponents,
|
|
343
|
-
allComponentsCount: allComponents.length
|
|
344
|
-
}, null, 2)
|
|
316
|
+
text: message
|
|
345
317
|
}
|
|
346
318
|
]
|
|
347
319
|
};
|
|
348
320
|
}
|
|
321
|
+
const docContents = result.documents.map((doc)=>`===== ${doc.name} =====\n\n${doc.content}`).join('\n\n');
|
|
349
322
|
return {
|
|
350
323
|
content: [
|
|
351
324
|
{
|
|
352
325
|
type: 'text',
|
|
353
|
-
text:
|
|
354
|
-
componentName: componentName.toLowerCase(),
|
|
355
|
-
version,
|
|
356
|
-
category: result.category,
|
|
357
|
-
documents: result.documents.map((doc)=>({
|
|
358
|
-
name: doc.name,
|
|
359
|
-
path: doc.path,
|
|
360
|
-
contentLength: doc.content.length
|
|
361
|
-
})),
|
|
362
|
-
contents: result.documents.map((doc)=>({
|
|
363
|
-
name: doc.name,
|
|
364
|
-
path: doc.path,
|
|
365
|
-
content: doc.content
|
|
366
|
-
})),
|
|
367
|
-
count: result.documents.length,
|
|
368
|
-
allComponents,
|
|
369
|
-
allComponentsCount: allComponents.length
|
|
370
|
-
}, null, 2)
|
|
326
|
+
text: docContents
|
|
371
327
|
}
|
|
372
328
|
]
|
|
373
329
|
};
|
|
@@ -378,12 +334,7 @@ async function handleGetSemiDocument(args) {
|
|
|
378
334
|
content: [
|
|
379
335
|
{
|
|
380
336
|
type: 'text',
|
|
381
|
-
text:
|
|
382
|
-
version,
|
|
383
|
-
error: `未找到组件列表,请检查版本号 ${version} 是否正确`,
|
|
384
|
-
components: [],
|
|
385
|
-
count: 0
|
|
386
|
-
}, null, 2)
|
|
337
|
+
text: `未找到组件列表,请检查版本号 ${version} 是否正确`
|
|
387
338
|
}
|
|
388
339
|
],
|
|
389
340
|
isError: true
|
|
@@ -392,11 +343,7 @@ async function handleGetSemiDocument(args) {
|
|
|
392
343
|
content: [
|
|
393
344
|
{
|
|
394
345
|
type: 'text',
|
|
395
|
-
text:
|
|
396
|
-
version,
|
|
397
|
-
components,
|
|
398
|
-
count: components.length
|
|
399
|
-
}, null, 2)
|
|
346
|
+
text: `Semi Design 组件列表 (版本 ${version}),共 ${components.length} 个组件:\n\n${components.join(', ')}`
|
|
400
347
|
}
|
|
401
348
|
]
|
|
402
349
|
};
|
|
@@ -407,11 +354,7 @@ async function handleGetSemiDocument(args) {
|
|
|
407
354
|
content: [
|
|
408
355
|
{
|
|
409
356
|
type: 'text',
|
|
410
|
-
text:
|
|
411
|
-
error: errorMessage,
|
|
412
|
-
componentName: componentName?.toLowerCase(),
|
|
413
|
-
version
|
|
414
|
-
}, null, 2)
|
|
357
|
+
text: `获取文档失败: ${errorMessage}`
|
|
415
358
|
}
|
|
416
359
|
],
|
|
417
360
|
isError: true
|
package/package.json
CHANGED