mta-mcp 1.0.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 +818 -0
- package/agents/_TEMPLATE.md +153 -0
- package/agents/flutter.agent.md +222 -0
- package/agents/i18n.agent.md +78 -0
- package/agents/logicflow.agent.md +97 -0
- package/agents/vue3.agent.md +176 -0
- package/agents/wechat-miniprogram.agent.md +89 -0
- package/bin/mta.cjs +132 -0
- package/common/i18n.md +385 -0
- package/common/typescript-strict.md +186 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +6493 -0
- package/dist/index.js.map +1 -0
- package/package.json +81 -0
- package/standards/README.md +194 -0
- package/standards/core/code-generation.md +421 -0
- package/standards/core/code-style.md +308 -0
- package/standards/core/dart-base.md +572 -0
- package/standards/core/mandatory-rules.md +103 -0
- package/standards/core/typescript-base.md +179 -0
- package/standards/frameworks/flutter-ui-system.md +497 -0
- package/standards/frameworks/flutter.md +1268 -0
- package/standards/frameworks/pinia.md +172 -0
- package/standards/frameworks/vue3-composition.md +779 -0
- package/standards/frameworks/wechat-miniprogram.md +2177 -0
- package/standards/libraries/element-plus.md +1128 -0
- package/standards/libraries/i18n.md +360 -0
- package/standards/libraries/logicflow.md +1007 -0
- package/standards/patterns/api-layer.md +187 -0
- package/standards/patterns/component-design.md +200 -0
- package/standards/patterns/design-system-restoration.md +570 -0
- package/standards/patterns/vue-api-mock-layer.md +958 -0
- package/standards/patterns/vue-css-nesting.md +604 -0
- package/standards/troubleshooting-cases/flutter/textfield-vertical-centering.md +107 -0
- package/standards/workflows/design-restoration-guide.md +164 -0
- package/standards/workflows/large-project-split.md +359 -0
- package/standards/workflows/problem-diagnosis.md +280 -0
- package/standards/workflows/textfield-centering-guide.md +157 -0
- package/templates/README.md +144 -0
- package/templates/common/types/_CONFIG.md +12 -0
- package/templates/common/types/api.ts +39 -0
- package/templates/common/types/common.ts +70 -0
- package/templates/config-templates/agents-section.md +9 -0
- package/templates/config-templates/custom-section.md +6 -0
- package/templates/config-templates/header.md +29 -0
- package/templates/config-templates/workflow-minimal.md +44 -0
- package/templates/copilot-instructions-mcp-optimized.md +158 -0
- package/templates/vue/api-layer/_CONFIG.md +145 -0
- package/templates/vue/api-layer/index.ts +58 -0
- package/templates/vue/api-layer/mock/index.ts +122 -0
- package/templates/vue/api-layer/modules/_template.ts +109 -0
- package/templates/vue/api-layer/modules/index.ts +16 -0
- package/templates/vue/api-layer/request.ts +279 -0
- package/templates/vue/api-layer/types.ts +80 -0
- package/troubleshooting/README.md +368 -0
- package/troubleshooting/USAGE_GUIDE.md +289 -0
- package/troubleshooting/flutter/clip-/351/230/264/345/275/261/350/243/201/345/211/252.md +244 -0
- package/troubleshooting/flutter/component-/351/200/232/347/224/250/345/214/226/346/217/220/345/217/226.md +269 -0
- package/troubleshooting/flutter/input-/345/255/227/346/256/265/347/274/272/345/244/261.md +240 -0
- package/troubleshooting/flutter/input-/350/276/271/346/241/206/351/227/256/351/242/230.md +236 -0
- package/troubleshooting/flutter/layout-/345/260/272/345/257/270/344/270/215/345/214/271/351/205/215.md +214 -0
- package/troubleshooting/flutter/shadow-/351/200/217/345/207/272/351/227/256/351/242/230.md +172 -0
- package/troubleshooting/flutter/sketch-/345/210/227/350/241/250item/345/214/272/345/237/237.md +212 -0
- package/troubleshooting/flutter/sketch-/345/233/276/346/240/207/345/260/272/345/257/270.md +135 -0
- package/troubleshooting/flutter/sketch-/345/256/214/346/225/264/346/217/220/345/217/226.md +201 -0
- package/troubleshooting/flutter/sketch-/345/261/236/346/200/247/346/234/252/344/275/277/347/224/250.md +139 -0
- package/troubleshooting/flutter/sketch-/350/203/214/346/231/257/345/261/202/351/253/230/345/272/246.md +264 -0
- package/troubleshooting/flutter/svg-/346/234/252/345/261/205/344/270/255.md +120 -0
- package/troubleshooting/flutter/svg-/351/242/234/350/211/262/345/274/202/345/270/270.md +117 -0
- package/troubleshooting/flutter/tabbar-/345/212/250/347/224/273/345/220/214/346/255/245.md +107 -0
- package/troubleshooting/flutter/withopacity-/345/274/203/347/224/250.md +81 -0
- package/troubleshooting/vue3/cascader-/350/257/257/346/233/277/346/215/242.md +130 -0
- package/troubleshooting/vue3/drawer-input-/346/240/267/345/274/217.md +181 -0
- package/troubleshooting/vue3/table-/347/274/226/350/276/221/345/217/226/346/266/210.md +148 -0
- package/troubleshooting/vue3/table-/350/276/271/346/241/206/351/227/256/351/242/230.md +178 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Vue 3 + TypeScript 开发代理
|
|
2
|
+
|
|
3
|
+
> 此 Agent 引导 AI 通过 MCP 工具获取 npm 包中的详细规范
|
|
4
|
+
> 版本: v3.0.0 | 最后更新: 2026-01-16
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🔴 问题诊断优先(最高优先级)
|
|
9
|
+
|
|
10
|
+
**当用户描述任何问题时,必须首先调用:**
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
troubleshoot({ problem: "用户描述的问题" })
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
案例库包含经过验证的解决方案,可避免无效尝试。
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📚 规范获取指引
|
|
21
|
+
|
|
22
|
+
**⚠️ 核心原则:写代码前,必须先通过 MCP 工具获取规范!**
|
|
23
|
+
|
|
24
|
+
### 按文件类型获取
|
|
25
|
+
|
|
26
|
+
| 场景 | MCP 调用 |
|
|
27
|
+
|------|----------|
|
|
28
|
+
| Vue 组件 | `get_standard_by_id({ id: 'vue3-composition' })` |
|
|
29
|
+
| TypeScript | `get_standard_by_id({ id: 'typescript-base' })` |
|
|
30
|
+
| Dart/Flutter | `get_standard_by_id({ id: 'flutter' })` |
|
|
31
|
+
|
|
32
|
+
### 按使用的库获取
|
|
33
|
+
|
|
34
|
+
| 库 | MCP 调用 |
|
|
35
|
+
|----|----------|
|
|
36
|
+
| Element Plus | `get_standard_by_id({ id: 'element-plus' })` |
|
|
37
|
+
| Pinia | `get_standard_by_id({ id: 'pinia' })` |
|
|
38
|
+
| Vue Router | `get_standard_by_id({ id: 'vue-router' })` |
|
|
39
|
+
| vue-i18n | `get_standard_by_id({ id: 'i18n' })` |
|
|
40
|
+
| LogicFlow | `get_standard_by_id({ id: 'logicflow' })` |
|
|
41
|
+
|
|
42
|
+
### 按场景获取
|
|
43
|
+
|
|
44
|
+
| 场景 | MCP 调用 |
|
|
45
|
+
|------|----------|
|
|
46
|
+
| CSS 样式 | `get_standard_by_id({ id: 'vue-css-nesting' })` |
|
|
47
|
+
| API 调用 | `get_standard_by_id({ id: 'api-layer' })` |
|
|
48
|
+
| 代码风格 | `get_standard_by_id({ id: 'code-style' })` |
|
|
49
|
+
|
|
50
|
+
### 智能获取(推荐)
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
// 根据当前文件自动匹配规范
|
|
54
|
+
get_compact_standards({ currentFile: "当前文件路径" })
|
|
55
|
+
|
|
56
|
+
// 获取多个规范
|
|
57
|
+
get_standard_by_id({ ids: ['vue3-composition', 'element-plus', 'i18n'] })
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🎯 Vue 3 快速提示
|
|
63
|
+
|
|
64
|
+
> 以下是简要提示,**详细规范请通过上述 MCP 工具获取**
|
|
65
|
+
|
|
66
|
+
### 必须遵守
|
|
67
|
+
|
|
68
|
+
- ✅ 使用 Composition API (`<script setup lang="ts">`)
|
|
69
|
+
- ✅ Props/Emits 必须定义 TypeScript 类型
|
|
70
|
+
- ✅ 所有用户可见文本必须国际化 `$t('...')`
|
|
71
|
+
- ✅ 单文件组件只能有一个 `<style>` 标签
|
|
72
|
+
|
|
73
|
+
### 禁止
|
|
74
|
+
|
|
75
|
+
- ❌ 使用 `any` 类型
|
|
76
|
+
- ❌ 使用 Options API
|
|
77
|
+
- ❌ 硬编码文本(必须用 `$t()`)
|
|
78
|
+
- ❌ 多个 `<style>` 标签
|
|
79
|
+
|
|
80
|
+
### Element Plus 单行书写(如项目要求)
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<!-- ✅ 正确 -->
|
|
84
|
+
<el-table v-loading="loading" :data="list" border highlight-current-row>
|
|
85
|
+
|
|
86
|
+
<!-- ❌ 错误 -->
|
|
87
|
+
<el-table
|
|
88
|
+
v-loading="loading"
|
|
89
|
+
:data="list">
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 🔧 标准工作流
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
1. 用户提出需求
|
|
98
|
+
↓
|
|
99
|
+
2. 检查是否是问题描述 → 是 → 调用 troubleshoot()
|
|
100
|
+
↓ 否
|
|
101
|
+
3. 识别需要的规范类型(Vue/Element Plus/Pinia 等)
|
|
102
|
+
↓
|
|
103
|
+
4. 调用对应的 get_standard_by_id() 获取详细规范
|
|
104
|
+
↓
|
|
105
|
+
5. 根据获取的规范编写代码
|
|
106
|
+
↓
|
|
107
|
+
6. 验证代码符合规范
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 📋 可用规范列表
|
|
113
|
+
|
|
114
|
+
通过 `get_standard_by_id({ id: 'xxx' })` 获取:
|
|
115
|
+
|
|
116
|
+
**核心规范**
|
|
117
|
+
- `mandatory-rules` - 底层必须规则(自动注入)
|
|
118
|
+
- `code-style` - 代码风格规范
|
|
119
|
+
- `typescript-base` - TypeScript 基础规范
|
|
120
|
+
- `code-generation` - 代码生成规范
|
|
121
|
+
|
|
122
|
+
**框架规范**
|
|
123
|
+
- `vue3-composition` - Vue 3 Composition API
|
|
124
|
+
- `pinia` - Pinia 状态管理
|
|
125
|
+
- `flutter` - Flutter 开发规范
|
|
126
|
+
|
|
127
|
+
**库规范**
|
|
128
|
+
- `element-plus` - Element Plus 组件库
|
|
129
|
+
- `i18n` - 国际化规范
|
|
130
|
+
- `logicflow` - LogicFlow 流程图
|
|
131
|
+
|
|
132
|
+
**模式规范**
|
|
133
|
+
- `vue-css-nesting` - Vue CSS 嵌套写法
|
|
134
|
+
- `api-layer` - API 层封装模式
|
|
135
|
+
- `design-tokens` - 设计 Token 系统
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 🎨 设计稿还原强制规范(跨平台通用)
|
|
140
|
+
|
|
141
|
+
> ⚠️ 还原 Sketch/Figma 设计稿时必须遵守
|
|
142
|
+
|
|
143
|
+
### 🔴 全局样式优先(最高优先级)
|
|
144
|
+
|
|
145
|
+
**在还原任何 UI 前,必须首先检查项目是否存在全局样式规范!**
|
|
146
|
+
|
|
147
|
+
#### 检查顺序
|
|
148
|
+
|
|
149
|
+
1. **检查项目设计 Token** - 如 `design_constants.dart`、`design-tokens.ts`
|
|
150
|
+
2. **优先使用语义化常量** - 而非硬编码数值
|
|
151
|
+
3. **颜色/圆角/阴影/间距** - 必须使用全局定义
|
|
152
|
+
|
|
153
|
+
#### 常见样式对照表
|
|
154
|
+
|
|
155
|
+
| 类型 | 常见值 | 应使用 |
|
|
156
|
+
|------|--------|--------|
|
|
157
|
+
| **圆角** | 16px | `$radius.lg` / CSS 变量 `--radius-lg` |
|
|
158
|
+
| **圆角** | 12px | `$radius.base` |
|
|
159
|
+
| **圆角** | 8px | `$radius.xs` |
|
|
160
|
+
| **按钮高度** | 56px | `$button.heightCTA` |
|
|
161
|
+
| **按钮高度** | 40px | `$button.heightMedium` |
|
|
162
|
+
| **按钮高度** | 32px | `$button.heightSmall` |
|
|
163
|
+
| **阴影** | 拟物卡片 | `$shadow.card` |
|
|
164
|
+
| **主色** | 红色CTA | `$color.primary` |
|
|
165
|
+
| **文字色** | 深色 | `$color.textPrimary` |
|
|
166
|
+
|
|
167
|
+
#### 禁止事项
|
|
168
|
+
- ❌ 硬编码 `border-radius: 16px` - 应使用 CSS 变量或常量
|
|
169
|
+
- ❌ 硬编码 `height: 56px` - 应使用按钮尺寸常量
|
|
170
|
+
- ❌ 硬编码 `color: #1C2B45` - 应使用颜色变量
|
|
171
|
+
- ❌ 手写 `box-shadow` - 应使用预设阴影 mixin
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
**维护团队**: MTA工作室
|
|
176
|
+
**设计理念**: Agent 只提供获取指引,详细规范由 MCP 工具从 npm 包动态获取
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# 微信小程序开发代理
|
|
2
|
+
|
|
3
|
+
> 此 Agent 引导 AI 通过 MCP 工具获取 npm 包中的详细规范
|
|
4
|
+
> 版本: v3.0.0 | 最后更新: 2026-01-16
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🔴 问题诊断优先(最高优先级)
|
|
9
|
+
|
|
10
|
+
**当用户描述任何问题时,必须首先调用:**
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
troubleshoot({ problem: "用户描述的问题" })
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 📚 规范获取指引
|
|
19
|
+
|
|
20
|
+
**⚠️ 核心原则:开发小程序代码前,必须先获取规范!**
|
|
21
|
+
|
|
22
|
+
### 按场景获取
|
|
23
|
+
|
|
24
|
+
| 场景 | MCP 调用 |
|
|
25
|
+
|------|----------|
|
|
26
|
+
| 页面开发 | `get_standard_by_id({ id: 'wechat-miniprogram' })` |
|
|
27
|
+
| 组件开发 | `get_standard_by_id({ id: 'wechat-miniprogram' })` |
|
|
28
|
+
| 网络请求 | `get_standard_by_id({ id: 'wechat-miniprogram' })` |
|
|
29
|
+
| 云开发 | `get_standard_by_id({ id: 'wechat-cloud' })` |
|
|
30
|
+
|
|
31
|
+
### 智能获取(推荐)
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
// 根据当前文件自动匹配
|
|
35
|
+
get_compact_standards({
|
|
36
|
+
currentFile: "pages/index/index.js",
|
|
37
|
+
imports: ["wx"]
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🎯 快速提示
|
|
44
|
+
|
|
45
|
+
> 以下是简要提示,**详细规范请通过上述 MCP 工具获取**
|
|
46
|
+
|
|
47
|
+
### 目录结构
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
miniprogram/
|
|
51
|
+
├── app.js / app.json / app.wxss
|
|
52
|
+
├── pages/ # 页面目录
|
|
53
|
+
├── components/ # 组件目录
|
|
54
|
+
├── utils/ # 工具函数
|
|
55
|
+
├── api/ # API 管理
|
|
56
|
+
└── config/ # 配置文件
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 必须遵守
|
|
60
|
+
|
|
61
|
+
- ✅ 使用 Component 构建自定义组件
|
|
62
|
+
- ✅ 合理使用 setData(避免频繁调用)
|
|
63
|
+
- ✅ 异步操作使用 Promise 封装
|
|
64
|
+
- ✅ 遵循小程序生命周期
|
|
65
|
+
|
|
66
|
+
### 禁止
|
|
67
|
+
|
|
68
|
+
- ❌ 直接操作 DOM
|
|
69
|
+
- ❌ 同步阻塞操作
|
|
70
|
+
- ❌ setData 传递大量数据
|
|
71
|
+
- ❌ 未处理的 Promise reject
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 📋 可用规范列表
|
|
76
|
+
|
|
77
|
+
通过 `get_standard_by_id({ id: 'xxx' })` 获取:
|
|
78
|
+
|
|
79
|
+
**核心规范**
|
|
80
|
+
- `wechat-miniprogram` - 小程序完整开发规范
|
|
81
|
+
|
|
82
|
+
**配套规范**
|
|
83
|
+
- `api-layer` - API 层封装模式
|
|
84
|
+
- `component-design` - 组件设计模式
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
**维护团队**: MTA工作室
|
|
89
|
+
**设计理念**: Agent 只提供获取指引,详细规范由 MCP 工具从 npm 包动态获取
|
package/bin/mta.cjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MTA MCP Server 入口
|
|
5
|
+
* 最低要求: Node.js 16+ (由 @modelcontextprotocol/sdk 决定)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { existsSync, readdirSync, readFileSync } = require('fs');
|
|
9
|
+
const { join } = require('path');
|
|
10
|
+
const { pathToFileURL } = require('url');
|
|
11
|
+
|
|
12
|
+
// 检测 Node.js 版本
|
|
13
|
+
const nodeVersion = process.versions.node;
|
|
14
|
+
const majorVersion = parseInt(nodeVersion.split('.')[0]);
|
|
15
|
+
|
|
16
|
+
// 最低版本检查
|
|
17
|
+
if (majorVersion < 16) {
|
|
18
|
+
console.error(`[MCP Error] Node.js 版本过低: v${nodeVersion}`);
|
|
19
|
+
console.error('[MCP Error] mta-mcp 需要 Node.js 16.0.0 或更高版本');
|
|
20
|
+
console.error('[MCP Error] 请升级 Node.js: https://nodejs.org/');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 获取包根目录
|
|
25
|
+
const packageRoot = join(__dirname, '..');
|
|
26
|
+
|
|
27
|
+
// 处理 CLI 参数
|
|
28
|
+
const args = process.argv.slice(2);
|
|
29
|
+
|
|
30
|
+
// --get-agent <id>: 获取指定 Agent 的完整内容
|
|
31
|
+
const getAgentIndex = args.indexOf('--get-agent');
|
|
32
|
+
if (getAgentIndex !== -1) {
|
|
33
|
+
const agentId = args[getAgentIndex + 1];
|
|
34
|
+
|
|
35
|
+
if (!agentId) {
|
|
36
|
+
console.log(JSON.stringify({ error: '请提供 Agent ID', content: null }));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const agentsDir = join(packageRoot, 'agents');
|
|
41
|
+
const agentFile = join(agentsDir, `${agentId}.agent.md`);
|
|
42
|
+
|
|
43
|
+
if (!existsSync(agentFile)) {
|
|
44
|
+
console.log(JSON.stringify({ error: `Agent 不存在: ${agentId}`, content: null }));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const content = readFileSync(agentFile, 'utf-8');
|
|
50
|
+
console.log(JSON.stringify({ content }));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.log(JSON.stringify({ error: `读取 Agent 失败: ${e.message}`, content: null }));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// --list-agents: 列出所有可用的 Agents
|
|
60
|
+
if (args.includes('--list-agents')) {
|
|
61
|
+
const agentsDir = join(packageRoot, 'agents');
|
|
62
|
+
|
|
63
|
+
if (!existsSync(agentsDir)) {
|
|
64
|
+
console.error(JSON.stringify({ error: 'Agents 目录不存在', agents: [] }));
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const agents = [];
|
|
69
|
+
const files = readdirSync(agentsDir).filter(f => f.endsWith('.agent.md') && !f.endsWith('.bak'));
|
|
70
|
+
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
try {
|
|
73
|
+
const content = readFileSync(join(agentsDir, file), 'utf-8');
|
|
74
|
+
const lines = content.split('\n');
|
|
75
|
+
|
|
76
|
+
// 提取 ID
|
|
77
|
+
const id = file.replace('.agent.md', '');
|
|
78
|
+
|
|
79
|
+
// 提取标题
|
|
80
|
+
let title = id;
|
|
81
|
+
const titleLine = lines.find(l => l.trim().startsWith('# '));
|
|
82
|
+
if (titleLine) {
|
|
83
|
+
title = titleLine.replace(/^#\s*/, '').trim();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 提取描述
|
|
87
|
+
let description = '暂无描述';
|
|
88
|
+
const descLine = lines.find(l => l.trim().startsWith('> '));
|
|
89
|
+
if (descLine) {
|
|
90
|
+
description = descLine.replace(/^>\s*/, '').trim();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 提取标签
|
|
94
|
+
const tags = [];
|
|
95
|
+
const tagsLine = lines.find(l =>
|
|
96
|
+
l.includes('**标签**') ||
|
|
97
|
+
l.includes('**关键词**') ||
|
|
98
|
+
l.includes('**Tags**')
|
|
99
|
+
);
|
|
100
|
+
if (tagsLine) {
|
|
101
|
+
const tagsMatch = tagsLine.match(/[::]\s*(.+)/);
|
|
102
|
+
if (tagsMatch) {
|
|
103
|
+
tags.push(...tagsMatch[1].split(/[,,、]/).map(t => t.trim()));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
agents.push({ id, title, description, tags });
|
|
108
|
+
} catch (e) {
|
|
109
|
+
// 忽略解析失败的文件
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 输出 JSON
|
|
114
|
+
console.log(JSON.stringify({ agents }, null, 2));
|
|
115
|
+
process.exit(0);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 默认行为:启动 MCP 服务器
|
|
119
|
+
const esmPath = join(packageRoot, 'dist', 'index.js');
|
|
120
|
+
|
|
121
|
+
if (!existsSync(esmPath)) {
|
|
122
|
+
console.error(`[MCP Error] 未找到构建版本: ${esmPath}`);
|
|
123
|
+
console.error('[MCP Error] 请确保已运行: npm run build');
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 加载 ES Module - 在 Windows 上必须转换为 file:// URL
|
|
128
|
+
const esmUrl = pathToFileURL(esmPath).href;
|
|
129
|
+
import(esmUrl).catch(err => {
|
|
130
|
+
console.error('[MCP Error] 启动失败:', err.message);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
});
|