@blueking/bkui-knowledge 0.0.1-beta.1 → 0.0.1-beta.3

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 CHANGED
@@ -10,17 +10,35 @@
10
10
 
11
11
  只需添加 MCP 服务配置:
12
12
 
13
+ **方式一:npx(推荐)**
14
+
13
15
  ```json
14
16
  {
15
17
  "mcpServers": {
16
18
  "bkui-knowledge": {
17
19
  "command": "npx",
18
- "args": ["-y", "@blueking/bkui-knowledge"]
20
+ "args": ["-y", "@blueking/bkui-knowledge", "${workspaceFolder}"]
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ **方式二:本地开发**
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "bkui-knowledge": {
32
+ "command": "node",
33
+ "args": ["/path/to/bkui-knowledge/bin/bkui-knowledge.js"],
34
+ "cwd": "/path/to/your-project"
19
35
  }
20
36
  }
21
37
  }
22
38
  ```
23
39
 
40
+ > ⚠️ 必须传递项目路径,否则 skills 无法同步到正确位置
41
+
24
42
  **特性:**
25
43
  - ✅ 首次启动自动同步推荐 skills 到 `.cursor/skills/`
26
44
  - ✅ 自动生成 `.cursor/rules/bkui.mdc`(规则自动注入 AI 上下文)
@@ -11,11 +11,16 @@
11
11
  * "mcpServers": {
12
12
  * "bkui-knowledge": {
13
13
  * "command": "npx",
14
- * "args": ["-y", "@blueking/bkui-knowledge"]
14
+ * "args": ["-y", "@blueking/bkui-knowledge", "${workspaceFolder}"]
15
15
  * }
16
16
  * }
17
17
  * }
18
18
  *
19
+ * 项目路径传递方式(优先级从高到低):
20
+ * 1. 命令行参数: npx @blueking/bkui-knowledge /path/to/project
21
+ * 2. 环境变量: BKUI_PROJECT_ROOT=/path/to/project
22
+ * 3. 当前工作目录 (cwd)
23
+ *
19
24
  * 更新机制:
20
25
  * - skills 内置在 npm 包中
21
26
  * - 更新 skills 时:修改代码 → npm publish
@@ -42,9 +47,19 @@ function log(msg) {
42
47
  }
43
48
 
44
49
  /**
45
- * 获取用户项目根目录(cwd)
50
+ * 获取用户项目根目录
51
+ * 优先级:命令行参数 > 环境变量 > cwd
46
52
  */
47
53
  function getProjectRoot() {
54
+ // 1. 命令行参数: node bkui-knowledge.js /path/to/project
55
+ if (process.argv[2] && !process.argv[2].startsWith('-')) {
56
+ return process.argv[2];
57
+ }
58
+ // 2. 环境变量: BKUI_PROJECT_ROOT=/path/to/project
59
+ if (process.env.BKUI_PROJECT_ROOT) {
60
+ return process.env.BKUI_PROJECT_ROOT;
61
+ }
62
+ // 3. 默认使用 cwd
48
63
  return process.cwd();
49
64
  }
50
65
 
@@ -308,6 +323,9 @@ async function startMcpServer() {
308
323
  async function main() {
309
324
  const projectRoot = getProjectRoot();
310
325
 
326
+ // 调试:输出实际的工作目录
327
+ log(`工作目录: ${projectRoot}`);
328
+
311
329
  // 1. 同步 skills(同步执行,从 npm 包读取)
312
330
  syncSkills(projectRoot);
313
331
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bkui-knowledge",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.1-beta.3",
4
4
  "description": "蓝鲸前端知识库 MCP 服务 - 自动同步 skills,支持 Cursor/VSCode",
5
5
  "main": "server/mcp-core.js",
6
6
  "bin": {