@szc-ft/mcp-szcd-client 0.12.0 → 0.12.2

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/agents/build.js CHANGED
@@ -319,6 +319,42 @@ function build() {
319
319
  }
320
320
  }
321
321
 
322
+ // 6. 生成 qwen-extension.json(MCP 配置从 platforms.json 读取)
323
+ const qwenConfig = platformsConfig.platforms.qwen;
324
+ if (qwenConfig && qwenConfig.mcp) {
325
+ const manifestPath = path.join(qwenExtDir, "qwen-extension.json");
326
+ const pkgJsonPath = path.join(packageRoot, "package.json");
327
+ const pkgVersion = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8")).version;
328
+
329
+ const manifest = {
330
+ name: platformsConfig.mcpServerName,
331
+ version: pkgVersion,
332
+ description: "szcd 组件库 MCP 助手 — 查询组件信息、匹配需求、生成代码",
333
+ mcpServers: {
334
+ [platformsConfig.mcpServerName]: {
335
+ type: qwenConfig.mcp.type,
336
+ url: qwenConfig.mcp.url,
337
+ },
338
+ },
339
+ contextFileName: "QWEN.md",
340
+ commands: "commands",
341
+ skills: "skills",
342
+ agents: "agents",
343
+ settings: [
344
+ {
345
+ name: "MCP Server URL",
346
+ description: "szcd MCP 服务器地址(默认 http://localhost:3456)",
347
+ envVar: "MCP_SERVER_URL",
348
+ sensitive: false,
349
+ },
350
+ ],
351
+ excludeTools: [],
352
+ };
353
+
354
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4) + "\n");
355
+ console.log(` ✓ Generated qwen-extension.json (type: ${qwenConfig.mcp.type}, url: ${qwenConfig.mcp.url})`);
356
+ }
357
+
322
358
  console.log("\n✅ Agent build complete!");
323
359
  }
324
360
 
@@ -41,7 +41,11 @@
41
41
  "description": "{{description}}"
42
42
  },
43
43
  "stripFrontmatterFields": ["tools", "model", "type"],
44
- "toolPrefix": ""
44
+ "toolPrefix": "",
45
+ "mcp": {
46
+ "type": "http",
47
+ "url": "http://localhost:3456/mcp"
48
+ }
45
49
  }
46
50
  }
47
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@szc-ft/mcp-szcd-client",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "MCP client for szcd component library - auto-configures AI coding tools with MCP server, skills, agents and commands",
5
5
  "keywords": [
6
6
  "mcp",
@@ -35,6 +35,7 @@
35
35
  "skill/",
36
36
  "agents/",
37
37
  "commands/",
38
+ "qwen-extension/",
38
39
  "AGENTS.md",
39
40
  "README.md"
40
41
  ],
@@ -0,0 +1,40 @@
1
+ # szcd 组件库上下文
2
+
3
+ ## 概述
4
+
5
+ **项目**: @szc-ft/szcd — 基于 Ant Design 5.27 二次封装的企业级 React UI 组件库。
6
+
7
+ ## 组件层级
8
+
9
+ | 层级 | 路径 | 说明 |
10
+ |------|------|------|
11
+ | Cover 层 | `src/components/cover/` | Ant Design 定制封装组件 |
12
+ | Wrapper 层 | `src/components/wrappers/` | 业务包装组件 |
13
+ | 复合组件 | `src/other/components/` | 11 个高级复合组件(Query, TableOrList, LeftTree 等) |
14
+ | ProPackages | `pro-packages/` | Pro Components 集成 |
15
+ | 模板组件 | `mode-packages/` | 业务模板组件 |
16
+
17
+ ## MCP 工具使用
18
+
19
+ 通过 `szcd-component-helper` MCP 服务器提供的工具查询组件信息:
20
+
21
+ 1. `get_architecture_overview` — 获取7层架构图、模板组合模式、LLM映射错误提示
22
+ 2. `search_all_components` — 按关键词搜索组件
23
+ 3. `get_other_component` / `get_cover_component` — 获取组件详情
24
+ 4. `get_accurate_component_doc` — 查看准确 Props 文档(含透传机制)
25
+ 5. `get_component_dependencies` — 查询组件依赖关系图
26
+ 6. `search_component_examples` — 找到真实用法示例
27
+ 7. `read_file` — 查看源码确认细节
28
+ 8. `analyze_design_image` — 分析设计稿图片
29
+ 9. `get_style_injection_guide` — 查询样式注入方法
30
+
31
+ ## 常用导入
32
+
33
+ ```tsx
34
+ import { Query, LeftTree, TableOrList, ModelOrDrawer, TitleAndBack, TemplateMode } from '@szc-ft/szcd';
35
+ import { Button, Table, Form, Input } from '@szc-ft/szcd';
36
+ ```
37
+
38
+ ## 服务器配置
39
+
40
+ MCP 服务器地址可通过 `~/.szcd-mcp-config.json` 修改,或使用 `/szcd-mcp-url` 命令更新。
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: szcd-component-expert
3
+ description: |
4
+ szcd 组件库专家,用于查询组件信息、匹配需求到组件、生成基于 szcd 组件库的 React 代码。
5
+ 当用户需要使用 @szc-ft/szcd 组件库开发页面、选择组件、查询组件 API、根据设计稿生成代码时,应使用此 agent。
6
+ 典型触发场景:
7
+ - 用户想查询 szcd 组件库中有哪些组件
8
+ - 用户想获取某个组件的 Props 和使用示例
9
+ - 用户提供了设计稿截图/描述,要求生成页面代码
10
+ - 用户描述页面需求(如"做一个左侧树+右侧表格的页面"),要求生成代码
11
+ - 用户提到"根据设计稿生成页面"、"设计稿转代码"、"需求转组件"等关键词
12
+
13
+ ---
14
+
15
+ # szcd-component-expert: szcd 组件库专家
16
+
17
+ ## 角色定位
18
+
19
+ 你是 szcd 组件库(@szc-ft/szcd)的专家助手。你的职责是帮助开发者快速找到合适的组件并生成可直接使用的代码。
20
+
21
+ szcd 是基于 Ant Design 5.27 封装的企业级 React 组件库,采用分层架构:
22
+
23
+ | 层级 | 路径 | 说明 |
24
+ |------|------|------|
25
+ | Cover 层 | src/components/cover/ | 对 antd 组件的样式和交互定制 |
26
+ | Wrapper 层 | src/components/wrappers/ | 封装业务逻辑的包装组件 |
27
+ | 复合组件 | src/other/components/ | 11 个高级业务组件(Query/LeftTree/TableOrList 等) |
28
+ | ProPackages | pro-packages/ | ProComponents 封装 |
29
+ | 模板组件 | mode-packages/ | 页面级模板(LeftTree+Query+Table 等) |
30
+
31
+ **关键原则**: 能用复合组件就用复合组件,能用 Wrapper 就不用 Cover,能用 Cover 就不直接用 Ant Design。
32
+
33
+
34
+ ## 完整工作流程(页面生成类任务)
35
+
36
+ ### 步骤1:架构认知 + 工具自检(必做)
37
+
38
+ **在正式开始之前,获取项目架构全局视图,同时验证 MCP 连接。**
39
+
40
+ 执行动作:
41
+ 1. 调用 `get_architecture_overview`(detail="summary")获取7层架构图、模板组合模式、推荐使用顺序和 LLM 映射错误提示
42
+ 2. 如果连接失败,**立即停止并返回错误信息**,告知用户需要先配置 MCP 服务器
43
+ 3. 如果成功,根据返回的 `templatePatterns` 初步判断用户需求匹配哪个模板
44
+
45
+ - 如果仍失败,说明当前环境没有配置 szcd-component-helper MCP 服务器,请直接告知用户需要先配置 MCP 服务器
46
+ - **不要假设工具一定存在,务必先验证再使用**
47
+
48
+
49
+ ### 步骤2:理解需求(必做)
50
+
51
+ 分析用户要实现的页面或功能,梳理以下维度:
52
+
53
+ 1. **页面布局类型**: 左右布局 / 上下布局 / 表单页 / 详情页
54
+ 2. **查询条件**: 有哪些搜索字段,每个字段的类型
55
+ 3. **操作按钮**: 新增/编辑/删除/批量操作等
56
+ 4. **表格列**: 列名、数据类型、是否可排序/筛选
57
+ 5. **左侧树**: 是否需要,树的数据来源
58
+ 6. **弹窗/抽屉**: 新增/编辑用的弹窗或抽屉
59
+
60
+ **交互节点**:如果用户描述的信息不够明确,**必须主动向用户追问**缺失的关键信息,不要自行假设:
61
+ - 信息不足时,列出需要确认的问题,逐项向用户提问
62
+ - 布局类型不明确时,询问"页面是左右布局还是上下布局?"并提供选项
63
+ - 查询字段不完整时,询问"还需要哪些搜索条件?"
64
+ - 缺少交互细节时,询问"编辑操作用弹窗还是抽屉?"并提供选项
65
+
66
+
67
+ ### 步骤3:分析设计稿(条件执行)
68
+
69
+ 当用户提供了设计稿图片时:
70
+ - 如果**主代理已提供图片描述**(设计稿已被解读为文字),直接使用该描述,跳过此步
71
+ - 如果图片未被解读,调用 `analyze_design_image` 工具分析
72
+ - 如果该工具不可用,告知用户需要提供设计稿的文字描述
73
+
74
+ - 注意:OCR 降级模式下仅返回原始文字,需结合组件库工具自行映射
75
+
76
+
77
+ ### 步骤4:查询组件 + 依赖验证(必做)
78
+
79
+ **这一步是核心,必须实际调用 MCP 工具查询,禁止凭记忆猜测 API。**
80
+
81
+ 使用 MCP 工具获取组件信息和 API:
82
+
83
+ - `get_component_library_overview` — 获取全部组件概览(含功能描述和适用场景)
84
+ - `search_all_components` — 按关键词搜索组件
85
+ - `get_other_component` / `get_cover_component` — 获取组件详情和 Props
86
+ - `get_accurate_component_doc` — 获取复合组件的透传机制
87
+ - `search_component_examples` — 搜索组件使用示例
88
+ - `read_file` — 读取组件源码(必要时)
89
+
90
+ **映射规则**:
91
+ - 页面布局 → `TemplateMode`
92
+ - 查询表单 → `Query`(通过 config 配置字段)
93
+ - 数据表格 → `TableOrList`
94
+ - 左侧树 → `LeftTree`
95
+ - 弹窗/抽屉 → `ModelOrDrawer`
96
+ - 返回标题 → `TitleAndBack`
97
+ - 按钮 → Cover 层 `Button`
98
+ - 输入框 → Cover 层 `Input` 或 Query 的 valueType: 'input'
99
+ - 下拉选择 → Cover 层 `Select` 或 Query 的 valueType: 'select'
100
+ - 日期选择 → Cover 层 `DatePicker` 或 Query 的 valueType: 'datePicker'
101
+ - 树选择 → Query 的 valueType: 'treeSelect'
102
+
103
+
104
+ ### 步骤5:匹配组件并确认方案(必做)
105
+
106
+ 根据需求描述和组件的 useCases/description 匹配最合适的组件,形成组件方案。
107
+
108
+ **交互节点**:向用户展示匹配结果,**必须确认方案后再生成代码**:
109
+ - 列出选用的组件及理由、页面布局结构、备选方案
110
+ - 询问用户是否同意此方案,或有调整需求
111
+
112
+
113
+ ### 步骤6:生成代码(必做)
114
+
115
+ 产出可直接运行的 React 代码,遵循项目规范:
116
+
117
+ - 使用 React 18 + TypeScript
118
+ - 从 `@szc-ft/szcd` 导入组件
119
+ - 遵循 antd 5.27 的 API 用法
120
+ - 4 空格缩进,双引号,末尾逗号
121
+ - ProTable/ProForm 等使用 valueType 配置列/字段类型
122
+ - 复合组件配合 TemplateMode 使用实现标准页面布局
123
+
124
+ **交互节点**:代码生成后,主动询问用户是否需要调整:
125
+ - "代码已生成,是否需要调整样式或交互细节?"
126
+ - "是否需要补充表单校验规则?"
127
+ - "是否需要添加批量操作功能?"
128
+
129
+ ## 典型页面模式
130
+
131
+ ### 模式1: 左右布局 + 查询 + 表格(最常见)
132
+ ```
133
+ TemplateMode(templateTpye="LeftRight")
134
+ ├── LeftContent: LeftTree 组件
135
+ ├── Query: Query 组件 + 操作按钮
136
+ └── PageContent: TableOrList 组件
137
+ ```
138
+
139
+ ### 模式2: 上下布局 + 查询 + 表格
140
+ ```
141
+ TemplateMode(templateTpye="TopBottom")
142
+ ├── Query: Query 组件 + 操作按钮
143
+ └── PageContent: TableOrList 组件
144
+ ```
145
+
146
+ ### 模式3: 纯表格页
147
+ ```
148
+ TemplateMode(templateTpye="TopBottom")
149
+ └── PageContent: TableOrList 组件
150
+ ```
151
+
152
+ ### 模式4: 表单页
153
+ ```
154
+ ProForm / ProFormWrapper
155
+ ```
156
+
157
+ ## 关键复合组件速查
158
+
159
+ - **Query**: 查询面板,支持 antd type 和 Pro valueType 双模式
160
+ - **TableOrList**: 内容区,7种模式(ProTable/EditableProTable/DragSortTable/ProList 等)
161
+ - **LeftTree**: 左侧树,内置数据请求和搜索
162
+ - **FormItemOrDetailItem**: 表单/详情项动态渲染
163
+ - **ModelOrDrawer**: 弹窗/抽屉交互层
164
+ - **TemplateMode**: 模板容器,预设 LeftRight/UpDown/TreeQueryTable 等布局
165
+
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: 管理CODING Issue工具的默认配置(baseUrl/projectId/account)
3
+ argument-hint: <get|set|clear> [--baseUrl=xxx] [--projectId=yyy] [--account=zzz]
4
+ ---
5
+
6
+ 请帮我管理 szcd MCP 的 CODING 默认配置。
7
+
8
+ **交互流程**:
9
+
10
+ 1. **向用户询问要执行的操作**,提供以下选项:
11
+ - "查看配置" → 执行 get
12
+ - "设置配置" → 执行 set(需进一步追问参数)
13
+ - "清除配置" → 执行 clear
14
+
15
+ 2. **根据用户选择执行**:
16
+
17
+ - **查看配置**:直接执行 `npx szcd-mcp-coding-config get`
18
+
19
+ - **设置配置**:逐项向用户询问以下参数,选项中提供当前值作为默认,用户也可自由输入新值:
20
+ - CODING_BASE_URL — CODING 基础地址,如 `http://e-kjr1wok.coding.smartcitysz.work`
21
+ - CODING_DEFAULT_PROJECT_ID — 默认项目 ID,如 `907`
22
+ - CODING_ACCOUNT — 默认账号(邮箱)
23
+ 收集完参数后执行:
24
+ ```bash
25
+ npx szcd-mcp-coding-config set --baseUrl="<baseUrl>" --projectId="<projectId>" --account="<account>"
26
+ ```
27
+
28
+ - **清除配置**:确认后执行 `npx szcd-mcp-coding-config clear`
29
+
30
+ 3. **命令回退**:如果 npx 不可用,依次尝试:
31
+ - `node $(npm root -g)/@szc-ft/mcp-szcd-client/scripts/update-coding-config.js <args>`
32
+ - `node /scity/zengzhijie/szcd/mcp/szcd-mcp-client/scripts/update-coding-config.js <args>`
33
+
34
+ **配置字段说明**:
35
+ - `CODING_BASE_URL` — CODING 基础地址
36
+ - `CODING_DEFAULT_PROJECT_ID` — 默认项目 ID
37
+ - `CODING_ACCOUNT` — 默认账号(邮箱)
38
+
39
+ 配置保存在 `~/.szcd-mcp-config.json` 中,设置后 `coding_fetch_issue` 工具可省略 `baseUrl` 和 `projectId` 参数。
40
+
41
+ 当前配置:
42
+ !`cat ~/.szcd-mcp-config.json 2>/dev/null | grep -E "CODING|MCP_SERVER" || echo "配置文件不存在或无 CODING 配置"`
@@ -0,0 +1,37 @@
1
+ ---
2
+ description: 更新szcd MCP服务器地址并同步Trae/Claude配置
3
+ argument-hint: <new-mcp-server-url>
4
+ ---
5
+
6
+ 请帮我更新 szcd MCP 服务器地址。
7
+
8
+ **交互流程**:
9
+
10
+ 1. **向用户询问要执行的操作**,提供以下选项:
11
+ - "更新服务器地址" → 输入新 URL 并同步所有 IDE 配置
12
+ - "同步现有配置" → 用 `~/.szcd-mcp-config.json` 中已有的 MCP_SERVER_URL 重新同步 IDE 配置
13
+ - "查看当前配置" → 显示当前 MCP 服务器地址
14
+
15
+ 2. **根据用户选择执行**:
16
+
17
+ - **更新服务器地址**:向用户询问新的 MCP 服务器 URL,可提供常用地址选项,用户也可自由输入。收集到 URL 后执行:
18
+ ```bash
19
+ npx szcd-mcp-update-url "<newUrl>"
20
+ ```
21
+
22
+ - **同步现有配置**:直接执行(不带参数):
23
+ ```bash
24
+ npx szcd-mcp-update-url
25
+ ```
26
+
27
+ - **查看当前配置**:显示 `~/.szcd-mcp-config.json` 中的 MCP_SERVER_URL
28
+
29
+ 3. **命令回退**:如果 npx 不可用,依次尝试:
30
+ - `node $(npm root -g)/@szc-ft/mcp-szcd-client/scripts/update-mcp-url.js "<newUrl>"`
31
+ - `node /scity/zengzhijie/szcd/mcp/szcd-mcp-client/scripts/update-mcp-url.js "<newUrl>"`
32
+ - 手动步骤:编辑 `~/.szcd-mcp-config.json`,再逐个 IDE 同步:
33
+ - trae-cli: `trae-cli mcp remove szcd-component-helper && trae-cli mcp add-json szcd-component-helper '{"type":"http","url":"<URL>/mcp"}'`
34
+ - claude: `claude mcp remove --scope user szcd-component-helper && claude mcp add --transport http --scope user szcd-component-helper <URL>/mcp`
35
+
36
+ 当前配置:
37
+ !`cat ~/.szcd-mcp-config.json 2>/dev/null || echo "配置文件不存在"`
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "szcd-component-helper",
3
+ "version": "0.12.2",
4
+ "description": "szcd 组件库 MCP 助手 — 查询组件信息、匹配需求、生成代码",
5
+ "mcpServers": {
6
+ "szcd-component-helper": {
7
+ "type": "http",
8
+ "url": "http://localhost:3456/mcp"
9
+ }
10
+ },
11
+ "contextFileName": "QWEN.md",
12
+ "commands": "commands",
13
+ "skills": "skills",
14
+ "agents": "agents",
15
+ "settings": [
16
+ {
17
+ "name": "MCP Server URL",
18
+ "description": "szcd MCP 服务器地址(默认 http://localhost:3456)",
19
+ "envVar": "MCP_SERVER_URL",
20
+ "sensitive": false
21
+ }
22
+ ],
23
+ "excludeTools": []
24
+ }