@reus-able/frontend-helper-mcp 1.0.11 → 1.0.13
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/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { McpServer as
|
|
2
|
+
import { McpServer as R } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport as v } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import i from "fs/promises";
|
|
5
5
|
import a from "path";
|
|
6
6
|
import { fileURLToPath as l } from "url";
|
|
7
|
-
import { ListPromptsRequestSchema as
|
|
7
|
+
import { ListPromptsRequestSchema as h, GetPromptRequestSchema as P, ListResourcesRequestSchema as S, ReadResourceRequestSchema as g, ListToolsRequestSchema as F, CallToolRequestSchema as M } from "@modelcontextprotocol/sdk/types.js";
|
|
8
8
|
import q from "fs";
|
|
9
9
|
function x(r) {
|
|
10
10
|
try {
|
|
@@ -53,18 +53,35 @@ function u(r) {
|
|
|
53
53
|
const e = a.extname(r).toLowerCase();
|
|
54
54
|
return e === ".md" ? "text/markdown" : e === ".json" ? "application/json" : "text/plain";
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const w = {
|
|
57
|
+
"code-refactor": {
|
|
58
|
+
name: "代码重构",
|
|
59
|
+
description: "对代码进行结构调整,不改变功能逻辑"
|
|
60
|
+
},
|
|
61
|
+
"git-commit": {
|
|
62
|
+
name: "Git提交",
|
|
63
|
+
description: "符合约定式提交格式的Git提交"
|
|
64
|
+
},
|
|
65
|
+
"component-refactor": {
|
|
66
|
+
name: "组件重构",
|
|
67
|
+
description: "对组件进行结构调整,不改变功能逻辑"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function C(r) {
|
|
57
71
|
const e = d();
|
|
58
|
-
r.server.setRequestHandler(
|
|
72
|
+
r.server.setRequestHandler(h, async () => {
|
|
59
73
|
try {
|
|
60
|
-
return { prompts: (await m(e)).map((n) =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
return { prompts: (await m(e)).map((n) => {
|
|
75
|
+
const s = a.parse(n).name;
|
|
76
|
+
return {
|
|
77
|
+
name: s,
|
|
78
|
+
description: w[s]?.description || `Content of ${n}`
|
|
79
|
+
};
|
|
80
|
+
}) };
|
|
64
81
|
} catch (o) {
|
|
65
82
|
return console.error("Error listing prompts:", o), { prompts: [] };
|
|
66
83
|
}
|
|
67
|
-
}), r.server.setRequestHandler(
|
|
84
|
+
}), r.server.setRequestHandler(P, async (o) => {
|
|
68
85
|
const t = o.params.name;
|
|
69
86
|
try {
|
|
70
87
|
const n = await f(e, t);
|
|
@@ -86,7 +103,7 @@ function $(r) {
|
|
|
86
103
|
}
|
|
87
104
|
});
|
|
88
105
|
}
|
|
89
|
-
function
|
|
106
|
+
function T(r) {
|
|
90
107
|
const e = d();
|
|
91
108
|
r.server.setRequestHandler(S, async () => {
|
|
92
109
|
try {
|
|
@@ -96,26 +113,26 @@ function C(r) {
|
|
|
96
113
|
uri: `prompt://${s}`,
|
|
97
114
|
name: s,
|
|
98
115
|
mimeType: c,
|
|
99
|
-
description: `Content of ${n}`
|
|
116
|
+
description: w[s]?.description || `Content of ${n}`
|
|
100
117
|
};
|
|
101
118
|
}) };
|
|
102
119
|
} catch (o) {
|
|
103
120
|
return console.error("Error listing resources:", o), { resources: [] };
|
|
104
121
|
}
|
|
105
122
|
}), r.server.setRequestHandler(
|
|
106
|
-
|
|
123
|
+
g,
|
|
107
124
|
async (o) => {
|
|
108
125
|
const t = o.params.uri, n = t.replace(/^prompt:\/\//, "");
|
|
109
126
|
try {
|
|
110
127
|
const s = await f(e, n);
|
|
111
128
|
if (!s)
|
|
112
129
|
throw new Error(`Resource not found: ${t}`);
|
|
113
|
-
const c = await i.readFile(a.join(e, s), "utf-8"),
|
|
130
|
+
const c = await i.readFile(a.join(e, s), "utf-8"), y = u(s);
|
|
114
131
|
return {
|
|
115
132
|
contents: [
|
|
116
133
|
{
|
|
117
134
|
uri: t,
|
|
118
|
-
mimeType:
|
|
135
|
+
mimeType: y,
|
|
119
136
|
text: c
|
|
120
137
|
}
|
|
121
138
|
]
|
|
@@ -126,8 +143,8 @@ function C(r) {
|
|
|
126
143
|
}
|
|
127
144
|
);
|
|
128
145
|
}
|
|
129
|
-
function
|
|
130
|
-
r.server.setRequestHandler(
|
|
146
|
+
function $(r) {
|
|
147
|
+
r.server.setRequestHandler(F, async () => ({ tools: [] })), r.server.setRequestHandler(M, async (e) => ({
|
|
131
148
|
content: [
|
|
132
149
|
{
|
|
133
150
|
type: "text",
|
|
@@ -138,7 +155,7 @@ function T(r) {
|
|
|
138
155
|
}));
|
|
139
156
|
}
|
|
140
157
|
async function D() {
|
|
141
|
-
const r = a.dirname(l(import.meta.url)), e = a.resolve(r, "../package.json"), o = JSON.parse(await i.readFile(e, "utf-8")), t = new
|
|
158
|
+
const r = a.dirname(l(import.meta.url)), e = a.resolve(r, "../package.json"), o = JSON.parse(await i.readFile(e, "utf-8")), t = new R(
|
|
142
159
|
{
|
|
143
160
|
name: o.name,
|
|
144
161
|
version: o.version
|
|
@@ -151,13 +168,13 @@ async function D() {
|
|
|
151
168
|
}
|
|
152
169
|
}
|
|
153
170
|
);
|
|
154
|
-
return
|
|
171
|
+
return C(t), T(t), $(t), t;
|
|
155
172
|
}
|
|
156
|
-
async function
|
|
173
|
+
async function H() {
|
|
157
174
|
console.error("Starting MCP server serving...");
|
|
158
175
|
const r = await D(), e = new v();
|
|
159
176
|
await r.connect(e);
|
|
160
177
|
}
|
|
161
|
-
|
|
178
|
+
H().catch((r) => {
|
|
162
179
|
console.error("Fatal error:", r), process.exit(1);
|
|
163
180
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,46 @@
|
|
|
1
1
|
## 协助用户提交当前变更
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
# 代码提交规范
|
|
4
|
+
创建格式规范的提交记录,搭配约定式提交信息。
|
|
5
|
+
|
|
6
|
+
## 功能特性
|
|
7
|
+
- 默认执行提交前检查(代码检查、项目构建、文档生成)
|
|
8
|
+
- 若未暂存任何文件,则自动暂存合适的文件
|
|
9
|
+
- 采用约定式提交格式
|
|
10
|
+
- 针对不同类型的修改,建议拆分提交记录
|
|
11
|
+
|
|
12
|
+
## 提交类型
|
|
13
|
+
- feat: 新功能
|
|
14
|
+
- fix: 缺陷修复
|
|
15
|
+
- docs: 文档内容变更
|
|
16
|
+
- refactor: 代码重构(不改变功能逻辑)
|
|
17
|
+
- style: 代码格式调整(如补充分号等格式问题)
|
|
18
|
+
- perf: 性能优化
|
|
19
|
+
- test: 新增或修正测试用例
|
|
20
|
+
- chore: 工具配置、项目维护等杂项工作
|
|
21
|
+
- wip: 进行中的工作(未完成提交)
|
|
22
|
+
- remove: 移除代码或文件
|
|
23
|
+
- hotfix: 紧急缺陷修复
|
|
24
|
+
- security: 安全性优化
|
|
25
|
+
|
|
26
|
+
## 执行流程
|
|
27
|
+
1. 检查已暂存的文件变更(执行 `git status` 命令)
|
|
28
|
+
2. 若未暂存任何文件,则筛选并暂存相关文件
|
|
29
|
+
3. 执行提交前检查(使用 `--no-verify` 参数时跳过)
|
|
30
|
+
4. 分析文件变更内容,确定对应的提交类型
|
|
31
|
+
5. 生成描述清晰的提交信息
|
|
32
|
+
6. 若适用,添加作用域信息,格式为:`提交类型(作用域): 描述内容`
|
|
33
|
+
7. 对于复杂的变更,在提交正文部分说明修改原因
|
|
34
|
+
8. 执行提交操作
|
|
35
|
+
|
|
36
|
+
## 最佳实践
|
|
37
|
+
- 保持提交的原子化与目标聚焦(一个提交对应一个功能/问题)
|
|
38
|
+
- 提交信息使用祈使语气(例如用“新增功能”而非“已新增功能”)
|
|
39
|
+
- 说明修改的**原因**,而不只是修改的**内容**
|
|
40
|
+
- 涉及相关需求单/合并请求时,添加对应的引用链接或编号
|
|
41
|
+
- 将不相关的代码变更拆分为多个独立的提交
|
|
42
|
+
|
|
43
|
+
## 关键要求
|
|
44
|
+
**你只需要处理commit操作**
|
|
45
|
+
**在任何情况下不要修改任何文件**
|
|
46
|
+
**如果提交出错,你只需要分析原因并告知用户,不要尝试修复**
|