@blueking/bkui-knowledge 0.0.1-beta.1 → 0.0.1-beta.10
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 +166 -58
- package/bin/bkui-knowledge.js +147 -82
- package/knowledge/manifest.json +38 -1
- package/knowledge/skills/.template/README.md +1 -1
- package/knowledge/skills/bk-security-redlines/SKILL.md +47 -0
- package/knowledge/skills/bk-security-redlines/references/auth-check.md +73 -0
- package/knowledge/skills/bk-security-redlines/references/data-encryption.md +78 -0
- package/knowledge/skills/bk-security-redlines/references/input-validation.md +96 -0
- package/knowledge/skills/bk-skill-creator/SKILL.md +37 -0
- package/knowledge/skills/bk-skill-creator/references/common-mistakes.md +43 -0
- package/knowledge/skills/bk-skill-creator/references/quick-start.md +42 -0
- package/knowledge/skills/bk-skill-creator/references/skill-checklist.md +93 -0
- package/knowledge/skills/bk-skill-creator/references/structure-guide.md +88 -0
- package/knowledge/skills/bk-skill-creator/references/writing-tips.md +153 -0
- package/knowledge/skills/bkui-quick-start/SKILL.md +52 -0
- package/knowledge/skills/bkui-quick-start/references/components-list.md +17 -0
- package/knowledge/skills/bkui-quick-start/references/skills-index.md +26 -0
- package/knowledge/skills/external/vue-skills/LICENSE +21 -0
- package/knowledge/skills/external/vue-skills/README.md +69 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/SKILL.md +42 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/codeactions-save-performance.md +79 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/data-attributes-config.md +74 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/deep-watch-numeric.md +102 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/define-model-update-event.md +79 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/duplicate-plugin-detection.md +102 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/fallthrough-attributes.md +63 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/hmr-vue-ssr.md +124 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/module-resolution-bundler.md +81 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/pinia-store-mocking.md +159 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/script-setup-jsdoc.md +85 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/strict-css-modules.md +68 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/unplugin-auto-import-conflicts.md +97 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/volar-3-breaking-changes.md +66 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/vue-directive-comments.md +73 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/vue-router-typed-params.md +81 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/vue-tsc-strict-templates.md +69 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/with-defaults-union-types.md +102 -0
- package/knowledge/skills/web-security-guide/SKILL.md +48 -0
- package/knowledge/skills/web-security-guide/references/access-control.md +123 -0
- package/knowledge/skills/web-security-guide/references/auth-session.md +99 -0
- package/knowledge/skills/web-security-guide/references/csrf.md +59 -0
- package/knowledge/skills/web-security-guide/references/data-exposure.md +108 -0
- package/knowledge/skills/web-security-guide/references/deserialization.md +59 -0
- package/knowledge/skills/web-security-guide/references/injection.md +357 -0
- package/knowledge/skills/web-security-guide/references/logging-monitoring.md +47 -0
- package/knowledge/skills/web-security-guide/references/security-config.md +73 -0
- package/knowledge/skills/web-security-guide/references/ssrf.md +55 -0
- package/knowledge/skills/web-security-guide/references/xss.md +134 -0
- package/package.json +3 -3
- package/server/mcp-core.js +48 -33
package/server/mcp-core.js
CHANGED
|
@@ -21,31 +21,17 @@ const KNOWLEDGE_DIR = path.join(ROOT_DIR, 'knowledge');
|
|
|
21
21
|
// 重要: 工具描述会被自动注入到 AI 上下文,因此在此嵌入核心规则
|
|
22
22
|
// ---------------------------------------------------------
|
|
23
23
|
const TOOLS = [
|
|
24
|
-
// L0 工具: 获取索引
|
|
24
|
+
// L0 工具: 获取索引
|
|
25
25
|
{
|
|
26
26
|
name: "get_knowledge_index",
|
|
27
|
-
description:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
## 强制规范
|
|
36
|
-
- 组件库: bkui-vue (前缀 bk-)
|
|
37
|
-
- 语法: Vue 3 <script setup lang="ts">
|
|
38
|
-
- 样式: MagicBox 原子类 (mt10, mb20)
|
|
39
|
-
|
|
40
|
-
## ⚠️ 常见错误
|
|
41
|
-
- bk-navigation 用 default-open,不是 default-open-keys
|
|
42
|
-
- bk-menu 用 opened-keys,不是 default-open-keys
|
|
43
|
-
- bk-dialog 用 v-model:isShow,不是 v-model
|
|
44
|
-
|
|
45
|
-
## 工作流程
|
|
46
|
-
1. 使用 bk- 组件前,先调用 get_component_api 获取 API
|
|
47
|
-
2. 需要页面模板时,调用 get_skill({ skillId: 'bkui-builder' }) 获取规则
|
|
48
|
-
3. 根据布局分析报告按需加载模版资源`,
|
|
27
|
+
description: `【蓝鲸前端知识库】遇到 bk- 组件、bkui-vue、蓝鲸组件库时必须使用。
|
|
28
|
+
|
|
29
|
+
首次使用时,请先读取 .cursor/skills/bkui-quick-start.md 获取完整规范和索引。
|
|
30
|
+
|
|
31
|
+
快速参考:
|
|
32
|
+
- bk-dialog 用 v-model:isShow(不是 v-model)
|
|
33
|
+
- bk-menu 用 opened-keys(不是 default-open-keys)
|
|
34
|
+
- bk-navigation 用 default-open(不是 default-open-keys)`,
|
|
49
35
|
inputSchema: {
|
|
50
36
|
type: "object",
|
|
51
37
|
properties: {
|
|
@@ -61,7 +47,7 @@ const TOOLS = [
|
|
|
61
47
|
// L1 工具: 获取 Skill 详情
|
|
62
48
|
{
|
|
63
49
|
name: "get_skill",
|
|
64
|
-
description: "获取技能文档 (Markdown)。可用 ID: bkui-builder(设计稿还原),
|
|
50
|
+
description: "获取技能文档 (Markdown)。可用 ID: bkui-quick-start(入门指南), bkui-builder(设计稿还原), bkui-cheatsheet(速查表), api-standard(请求封装), pinia-setup(状态管理), vite-migration(Vite迁移), bundle-optimization(构建优化), virtual-list(虚拟滚动), unit-testing(单测), code-review(代码评审)",
|
|
65
51
|
inputSchema: {
|
|
66
52
|
type: "object",
|
|
67
53
|
properties: {
|
|
@@ -119,6 +105,22 @@ const TOOLS = [
|
|
|
119
105
|
type: "object",
|
|
120
106
|
properties: {}
|
|
121
107
|
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// L3 工具: 获取资源文件 (绕过 Cursor FetchMcpResource bug)
|
|
111
|
+
{
|
|
112
|
+
name: "get_resource",
|
|
113
|
+
description: "获取 skill 或 example 资源文件内容。URI 格式: skill://skillId/subDir/path 或 example://componentId/exampleName。用于获取布局模板、代码示例等资源。",
|
|
114
|
+
inputSchema: {
|
|
115
|
+
type: "object",
|
|
116
|
+
properties: {
|
|
117
|
+
uri: {
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "资源 URI,如: skill://bkui-builder/assets/layouts/admin-layout-dark.vue, example://table/basic"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
required: ["uri"]
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
];
|
|
124
126
|
|
|
@@ -167,8 +169,9 @@ function buildResources() {
|
|
|
167
169
|
if (manifest.skills && manifest.skills.items) {
|
|
168
170
|
const skillsBasePath = path.join(KNOWLEDGE_DIR, manifest.skills.base_path);
|
|
169
171
|
manifest.skills.items.forEach(skill => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
// 使用 skill.path 推断目录(支持外部 skill)
|
|
173
|
+
const skillDir = path.join(skillsBasePath, path.dirname(skill.path));
|
|
174
|
+
['scripts', 'references', 'assets', 'rules'].forEach(subDir => {
|
|
172
175
|
const subDirPath = path.join(skillDir, subDir);
|
|
173
176
|
if (fs.existsSync(subDirPath)) {
|
|
174
177
|
scanSkillDir(subDirPath, '').forEach(filePath => {
|
|
@@ -289,7 +292,7 @@ const Handlers = {
|
|
|
289
292
|
|
|
290
293
|
// 检查 skill 目录下的附属资源,生成 skill:// URIs
|
|
291
294
|
const skillDir = path.dirname(filePath);
|
|
292
|
-
const subDirs = ['scripts', 'references', 'assets'];
|
|
295
|
+
const subDirs = ['scripts', 'references', 'assets', 'rules'];
|
|
293
296
|
const availableResources = [];
|
|
294
297
|
|
|
295
298
|
subDirs.forEach(dir => {
|
|
@@ -447,7 +450,6 @@ ${recommendedIds.map(id => {
|
|
|
447
450
|
### 同步位置
|
|
448
451
|
|
|
449
452
|
- \`.cursor/skills/*.md\` - 技能文档
|
|
450
|
-
- \`.cursor/commands/*.md\` - 斜杠指令 (可通过 /${recommendedIds[0]} 调用)
|
|
451
453
|
- \`.cursor/rules/bkui.mdc\` - 规则文件 (自动注入 AI 上下文)
|
|
452
454
|
- \`.cursor/.bkui-knowledge-version\` - 版本标记
|
|
453
455
|
|
|
@@ -462,6 +464,17 @@ ${recommendedIds.map(id => {
|
|
|
462
464
|
return { content: [{ type: "text", text: result }] };
|
|
463
465
|
},
|
|
464
466
|
|
|
467
|
+
// L3: 获取资源文件 (绕过 Cursor FetchMcpResource bug)
|
|
468
|
+
async get_resource({ uri }) {
|
|
469
|
+
const result = await readResource(uri);
|
|
470
|
+
// readResource 返回 { content: string } 或 { contents: [{ text }] }
|
|
471
|
+
const text = result.content || (result.contents && result.contents[0] && result.contents[0].text);
|
|
472
|
+
if (!text) {
|
|
473
|
+
throw new Error(`Resource not found or empty: ${uri}`);
|
|
474
|
+
}
|
|
475
|
+
return { content: [{ type: "text", text }] };
|
|
476
|
+
},
|
|
477
|
+
|
|
465
478
|
// Prompt 处理
|
|
466
479
|
async get_prompt({ name }) {
|
|
467
480
|
if (name === "BKUI-EXPERT") {
|
|
@@ -566,8 +579,8 @@ async function handleExampleResource(uri) {
|
|
|
566
579
|
throw new Error(`Example '${exampleName}' not found for ${componentId}. Available: ${compExamples.examples.map(e => e.name).join(', ')}`);
|
|
567
580
|
}
|
|
568
581
|
|
|
569
|
-
// 读取示例文件
|
|
570
|
-
const examplePath = path.join(
|
|
582
|
+
// 读取示例文件 (base_path 相对于 KNOWLEDGE_DIR)
|
|
583
|
+
const examplePath = path.join(KNOWLEDGE_DIR, manifest.componentExamples.base_path, example.file);
|
|
571
584
|
if (!fs.existsSync(examplePath)) {
|
|
572
585
|
throw new Error(`Example file not found: ${example.file}`);
|
|
573
586
|
}
|
|
@@ -588,8 +601,8 @@ async function handleSkillResource(uri) {
|
|
|
588
601
|
|
|
589
602
|
const [, skillId, subDir, filePath] = match;
|
|
590
603
|
|
|
591
|
-
if (!['scripts', 'references', 'assets'].includes(subDir)) {
|
|
592
|
-
throw new Error(`Invalid skill subDir: ${subDir}. Must be scripts, references, or
|
|
604
|
+
if (!['scripts', 'references', 'assets', 'rules'].includes(subDir)) {
|
|
605
|
+
throw new Error(`Invalid skill subDir: ${subDir}. Must be scripts, references, assets, or rules`);
|
|
593
606
|
}
|
|
594
607
|
|
|
595
608
|
const manifest = loadManifest();
|
|
@@ -598,7 +611,9 @@ async function handleSkillResource(uri) {
|
|
|
598
611
|
throw new Error(`Skill not found: ${skillId}`);
|
|
599
612
|
}
|
|
600
613
|
|
|
601
|
-
|
|
614
|
+
// 使用 skill.path 推断目录(支持外部 skill)
|
|
615
|
+
const skillDir = path.dirname(skill.path);
|
|
616
|
+
const fullPath = path.join(KNOWLEDGE_DIR, manifest.skills.base_path, skillDir, subDir, filePath);
|
|
602
617
|
if (!fs.existsSync(fullPath)) {
|
|
603
618
|
throw new Error(`Skill resource not found: ${subDir}/${filePath}`);
|
|
604
619
|
}
|