@shaohui_jin/git-cockpit-mcp-server 0.1.18 → 0.1.19
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/chunk-DPQSSEDA.js +515 -0
- package/dist/chunk-DPQSSEDA.js.map +1 -0
- package/dist/{chunk-363R2SNK.js → chunk-K7XHGELU.js} +7 -2
- package/dist/chunk-K7XHGELU.js.map +1 -0
- package/dist/{chunk-XARI6A27.js → chunk-M7EO3ZCZ.js} +3 -3
- package/dist/cli-entry.js +3 -3
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +2 -15
- package/dist/index.js +3 -3
- package/dist/mcpServer.js +1 -1
- package/dist/web/assets/index-D2QIyWM5.js +345 -0
- package/dist/web/assets/{index-DcQxEG_7.css → index-xXbPEo1p.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/webServer.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-363R2SNK.js.map +0 -1
- package/dist/chunk-HUTQV5AS.js +0 -1300
- package/dist/chunk-HUTQV5AS.js.map +0 -1
- package/dist/web/assets/index-CcuMDi_Q.js +0 -345
- /package/dist/{chunk-XARI6A27.js.map → chunk-M7EO3ZCZ.js.map} +0 -0
package/dist/chunk-HUTQV5AS.js
DELETED
|
@@ -1,1300 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/mcpServer.ts
|
|
4
|
-
import { randomUUID } from "crypto";
|
|
5
|
-
import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
8
|
-
|
|
9
|
-
// package.json
|
|
10
|
-
var version = "0.1.18";
|
|
11
|
-
|
|
12
|
-
// src/tools/format.ts
|
|
13
|
-
import { suggestNext } from "@shaohui_jin/git-cockpit-core";
|
|
14
|
-
var FILE_CONTENT_LIMIT = 64 * 1024;
|
|
15
|
-
function wantsDetail(args) {
|
|
16
|
-
return args?.detail === true;
|
|
17
|
-
}
|
|
18
|
-
function hasPath(args) {
|
|
19
|
-
return typeof args?.path === "string" && args.path.trim().length > 0;
|
|
20
|
-
}
|
|
21
|
-
function asRecord(value) {
|
|
22
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
23
|
-
}
|
|
24
|
-
function stripDiffPatch(diff) {
|
|
25
|
-
const d = asRecord(diff);
|
|
26
|
-
if (!d || !("rawPatch" in d)) return diff;
|
|
27
|
-
const { rawPatch: _raw, ...rest } = d;
|
|
28
|
-
return { ...rest, detailAvailable: true };
|
|
29
|
-
}
|
|
30
|
-
function stripRehearseBodies(result) {
|
|
31
|
-
const r = asRecord(result);
|
|
32
|
-
if (!r) return result;
|
|
33
|
-
const files = Array.isArray(r.conflictFiles) ? r.conflictFiles : [];
|
|
34
|
-
const paths = files.map((f) => {
|
|
35
|
-
const row = asRecord(f);
|
|
36
|
-
return {
|
|
37
|
-
path: row?.path ?? "",
|
|
38
|
-
contentConflict: row?.contentConflict ?? true,
|
|
39
|
-
hunks: []
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
return {
|
|
43
|
-
...r,
|
|
44
|
-
conflictFiles: paths,
|
|
45
|
-
detailAvailable: true
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function attachNext(tool, result, args, dryRun2) {
|
|
49
|
-
const rec = asRecord(result);
|
|
50
|
-
if (!rec) return result;
|
|
51
|
-
if (Array.isArray(rec.next) && rec.next.length) return result;
|
|
52
|
-
const next = suggestNext(tool, result, args, { dryRun: dryRun2 });
|
|
53
|
-
if (!next.length) return result;
|
|
54
|
-
return { ...rec, next };
|
|
55
|
-
}
|
|
56
|
-
function summarizeForAgent(tool, result, args = {}, dryRun2 = false) {
|
|
57
|
-
if (result == null) return result;
|
|
58
|
-
const detail2 = wantsDetail(args);
|
|
59
|
-
const pathSet = hasPath(args);
|
|
60
|
-
let summarized = result;
|
|
61
|
-
if (tool === "git_diff" || tool === "git_stash_show") {
|
|
62
|
-
summarized = detail2 || pathSet ? result : stripDiffPatch(result);
|
|
63
|
-
} else if (tool === "git_show") {
|
|
64
|
-
if (detail2 || pathSet) {
|
|
65
|
-
summarized = result;
|
|
66
|
-
} else {
|
|
67
|
-
const row = asRecord(result);
|
|
68
|
-
summarized = row ? { ...row, diff: stripDiffPatch(row.diff) } : result;
|
|
69
|
-
}
|
|
70
|
-
} else if (tool === "git_merge_rehearse") {
|
|
71
|
-
summarized = detail2 || pathSet ? result : stripRehearseBodies(result);
|
|
72
|
-
} else if (tool === "git_repo_overview") {
|
|
73
|
-
if (!detail2) {
|
|
74
|
-
const row = asRecord(result);
|
|
75
|
-
const repos = Array.isArray(row?.repos) ? row.repos : [];
|
|
76
|
-
summarized = {
|
|
77
|
-
...row,
|
|
78
|
-
repos: repos.map((item) => {
|
|
79
|
-
const rec = asRecord(item);
|
|
80
|
-
if (!rec) return item;
|
|
81
|
-
const { activity: _days, ...rest } = rec;
|
|
82
|
-
return rest;
|
|
83
|
-
})
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
} else if (tool === "git_file_content") {
|
|
87
|
-
if (!detail2) {
|
|
88
|
-
const row = asRecord(result);
|
|
89
|
-
const content = typeof row?.content === "string" ? row.content : "";
|
|
90
|
-
const bytes = Buffer.byteLength(content, "utf8");
|
|
91
|
-
if (bytes > FILE_CONTENT_LIMIT) {
|
|
92
|
-
summarized = {
|
|
93
|
-
path: args.path,
|
|
94
|
-
truncated: true,
|
|
95
|
-
bytes,
|
|
96
|
-
detailAvailable: true
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return attachNext(tool, summarized, args, dryRun2);
|
|
102
|
-
}
|
|
103
|
-
function formatResultForMcp(exec) {
|
|
104
|
-
if (!exec.success) {
|
|
105
|
-
const prefix = exec.error?.requiredApproval ? "\u9700\u8981\u5BA1\u6279" : "\u64CD\u4F5C\u5931\u8D25";
|
|
106
|
-
return `${prefix}\uFF1A${exec.error?.message ?? "\u672A\u77E5\u9519\u8BEF"}`;
|
|
107
|
-
}
|
|
108
|
-
const parts = [];
|
|
109
|
-
if (exec.dryRun) {
|
|
110
|
-
parts.push("[dry-run \u9884\u89C8] \u672A\u5B9E\u9645\u6267\u884C\u4EFB\u4F55\u64CD\u4F5C");
|
|
111
|
-
}
|
|
112
|
-
if (exec.backupCreated) {
|
|
113
|
-
parts.push(
|
|
114
|
-
`[\u81EA\u52A8\u5907\u4EFD] \u5206\u652F ${exec.backupCreated.branch ?? "(\u672A\u521B\u5EFA)"}${exec.backupCreated.stashRef ? `\uFF0Cstash ${exec.backupCreated.stashRef}` : ""}`
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
const summarized = summarizeForAgent(exec.tool, exec.result, exec.args ?? {}, exec.dryRun);
|
|
118
|
-
const rec = asRecord(summarized);
|
|
119
|
-
const next = Array.isArray(rec?.next) ? rec.next : [];
|
|
120
|
-
if (next.length) {
|
|
121
|
-
const names = next.map((step) => asRecord(step)?.tool).filter((n) => typeof n === "string" && n.length > 0);
|
|
122
|
-
if (names.length) parts.push(`next: ${names.join(" \u2192 ")}`);
|
|
123
|
-
}
|
|
124
|
-
const payload = typeof summarized === "string" ? summarized : JSON.stringify(summarized);
|
|
125
|
-
parts.push(payload);
|
|
126
|
-
return parts.join("\n\n");
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// src/tools/handlers.ts
|
|
130
|
-
import { executeCapability } from "@shaohui_jin/git-cockpit-core";
|
|
131
|
-
|
|
132
|
-
// src/host.ts
|
|
133
|
-
import { GitOperationError } from "@shaohui_jin/git-cockpit-core";
|
|
134
|
-
|
|
135
|
-
// src/overview.ts
|
|
136
|
-
import { emptyActivity } from "@shaohui_jin/git-cockpit-core";
|
|
137
|
-
var CONCURRENCY = 4;
|
|
138
|
-
function unavailableOverview(path, extra = {}) {
|
|
139
|
-
const name = path.replace(/[\\/]+$/, "").split(/[\\/]/).pop() || path;
|
|
140
|
-
return {
|
|
141
|
-
path,
|
|
142
|
-
name,
|
|
143
|
-
available: false,
|
|
144
|
-
current: "",
|
|
145
|
-
tracking: null,
|
|
146
|
-
ahead: 0,
|
|
147
|
-
behind: 0,
|
|
148
|
-
dirtyCount: 0,
|
|
149
|
-
conflictCount: 0,
|
|
150
|
-
operation: "none",
|
|
151
|
-
tempMergeBranchCount: 0,
|
|
152
|
-
...emptyActivity(),
|
|
153
|
-
...extra
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
async function mapPool(items, n, fn) {
|
|
157
|
-
const out = new Array(items.length);
|
|
158
|
-
let i = 0;
|
|
159
|
-
async function worker() {
|
|
160
|
-
while (i < items.length) {
|
|
161
|
-
const idx = i++;
|
|
162
|
-
out[idx] = await fn(items[idx]);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const workers = Math.min(n, items.length);
|
|
166
|
-
await Promise.all(Array.from({ length: workers }, () => worker()));
|
|
167
|
-
return out;
|
|
168
|
-
}
|
|
169
|
-
async function collectRepoOverviews(runtime) {
|
|
170
|
-
const repos = runtime.repoManager.list();
|
|
171
|
-
if (!repos.length) return [];
|
|
172
|
-
return mapPool(repos, CONCURRENCY, async (r) => {
|
|
173
|
-
try {
|
|
174
|
-
const handle = await runtime.repoManager.getById(r.id);
|
|
175
|
-
if (!handle) return unavailableOverview(r.path, { id: r.id, lastOpenedAt: r.lastOpenedAt });
|
|
176
|
-
const o = await handle.service.getOverview();
|
|
177
|
-
return { ...o, id: r.id, lastOpenedAt: r.lastOpenedAt };
|
|
178
|
-
} catch {
|
|
179
|
-
return unavailableOverview(r.path, { id: r.id, lastOpenedAt: r.lastOpenedAt });
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/host.ts
|
|
185
|
-
function hostFromRuntime(runtime) {
|
|
186
|
-
return {
|
|
187
|
-
config: runtime.config,
|
|
188
|
-
permissions: runtime.permissions,
|
|
189
|
-
auditLogger: runtime.auditLogger,
|
|
190
|
-
eventBus: runtime.eventBus,
|
|
191
|
-
jobs: runtime.jobs,
|
|
192
|
-
async resolveRepo({ repoId, repoPath: repoPath2, argsPath }) {
|
|
193
|
-
if (repoId !== void 0) {
|
|
194
|
-
const handle = await runtime.repoManager.getById(repoId);
|
|
195
|
-
if (handle) return { git: handle.service, repoPath: handle.service.repoPath };
|
|
196
|
-
throw new GitOperationError(`\u4ED3\u5E93\u4E0D\u5B58\u5728: id=${repoId}`, "REPO_NOT_FOUND");
|
|
197
|
-
}
|
|
198
|
-
if (repoPath2) {
|
|
199
|
-
const handle = runtime.repoManager.getByPath(repoPath2);
|
|
200
|
-
return { git: handle.service, repoPath: handle.service.repoPath };
|
|
201
|
-
}
|
|
202
|
-
if (argsPath) {
|
|
203
|
-
const handle = await runtime.repoManager.open(argsPath);
|
|
204
|
-
return { git: handle.service, repoPath: handle.service.repoPath };
|
|
205
|
-
}
|
|
206
|
-
const current = await runtime.repoManager.getCurrent();
|
|
207
|
-
if (!current) {
|
|
208
|
-
throw new GitOperationError("\u5C1A\u672A\u6253\u5F00\u4EFB\u4F55\u4ED3\u5E93\u3002\u8BF7\u5148\u6253\u5F00\u4ED3\u5E93\u6216\u63D0\u4F9B repoPath \u53C2\u6570\u3002", "NO_ACTIVE_REPO");
|
|
209
|
-
}
|
|
210
|
-
return { git: current.service, repoPath: current.service.repoPath };
|
|
211
|
-
},
|
|
212
|
-
listOverviews: () => collectRepoOverviews(runtime)
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// src/tools/handlers.ts
|
|
217
|
-
async function executeTool(def, rawArgs, ctx) {
|
|
218
|
-
return executeCapability(def, rawArgs, {
|
|
219
|
-
source: ctx.source,
|
|
220
|
-
repoId: ctx.repoId,
|
|
221
|
-
repoPath: ctx.repoPath,
|
|
222
|
-
host: hostFromRuntime(ctx.runtime)
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// src/tools/bindMcp.ts
|
|
227
|
-
function bindMcpTools(server, runtime, capabilities) {
|
|
228
|
-
for (const def of capabilities) {
|
|
229
|
-
const register = server.registerTool.bind(server);
|
|
230
|
-
register(
|
|
231
|
-
def.name,
|
|
232
|
-
{ description: def.description, inputSchema: def.schema },
|
|
233
|
-
async (args) => {
|
|
234
|
-
const exec = await executeTool(def, args ?? {}, {
|
|
235
|
-
runtime,
|
|
236
|
-
source: "mcp"
|
|
237
|
-
});
|
|
238
|
-
return {
|
|
239
|
-
content: [{ type: "text", text: formatResultForMcp(exec) }],
|
|
240
|
-
isError: !exec.success
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// src/tools/index.ts
|
|
248
|
-
import {
|
|
249
|
-
enrichPrepareMr,
|
|
250
|
-
createPullOrMergeRequest,
|
|
251
|
-
BackupManager,
|
|
252
|
-
GitOperationError as GitOperationError2,
|
|
253
|
-
SURVEY_ASYNC_THRESHOLD,
|
|
254
|
-
getCapabilityRegistry
|
|
255
|
-
} from "@shaohui_jin/git-cockpit-core";
|
|
256
|
-
|
|
257
|
-
// src/tools/schemas.ts
|
|
258
|
-
import { z } from "zod";
|
|
259
|
-
var repoPath = z.string().optional().describe("\u4ED3\u5E93\u7EDD\u5BF9\u8DEF\u5F84\u3002\u4E0D\u63D0\u4F9B\u65F6\u4F7F\u7528\u5F53\u524D\u6253\u5F00\u7684\u4ED3\u5E93\u3002");
|
|
260
|
-
var dryRun = z.boolean().optional().describe("\u4E3A true \u65F6\u4EC5\u8FD4\u56DE\u5C06\u6267\u884C\u7684\u547D\u4EE4\u4E0E\u5F71\u54CD\u8303\u56F4\uFF08\u9884\u89C8/\u5E72\u8FD0\u884C\uFF09\uFF0C\u4E0D\u771F\u6B63\u4FEE\u6539\u4ED3\u5E93\u3002");
|
|
261
|
-
var detail = z.boolean().optional().describe("\u4E3A true \u65F6 MCP \u8FD4\u56DE\u5B8C\u6574\u6B63\u6587\uFF1B\u9ED8\u8BA4\u53EA\u56DE\u6458\u8981\uFF08\u8DEF\u5F84/\u7EDF\u8BA1\uFF09\u3002\u7F51\u9875 GET \u4E0D\u53D7\u5F71\u54CD\u3002");
|
|
262
|
-
var maxCount = z.number().int().min(1).max(1e4).optional().describe("\u6700\u591A\u8FD4\u56DE\u7684\u63D0\u4EA4\u6570\u91CF\u3002");
|
|
263
|
-
var readonlyBase = { repoPath };
|
|
264
|
-
var GitStatusSchema = z.object({ ...readonlyBase });
|
|
265
|
-
var GitLogSchema = z.object({
|
|
266
|
-
...readonlyBase,
|
|
267
|
-
maxCount,
|
|
268
|
-
from: z.string().optional().describe("\u8D77\u59CB\u63D0\u4EA4\uFF08\u542B\uFF09\uFF1B\u4E0E to \u914D\u5408\u8868\u793A\u8303\u56F4 from..to"),
|
|
269
|
-
to: z.string().optional().describe("\u7ED3\u675F\u63D0\u4EA4\uFF08\u542B\uFF09"),
|
|
270
|
-
author: z.string().optional().describe("\u6309\u4F5C\u8005\u8FC7\u6EE4\uFF08\u652F\u6301\u5B50\u4E32\uFF09"),
|
|
271
|
-
path: z.string().optional().describe("\u4EC5\u67E5\u770B\u8BE5\u8DEF\u5F84\u7684\u5386\u53F2"),
|
|
272
|
-
all: z.boolean().optional().describe("\u5305\u542B\u6240\u6709\u5206\u652F\uFF08--all\uFF09")
|
|
273
|
-
});
|
|
274
|
-
var GitDiffSchema = z.object({
|
|
275
|
-
...readonlyBase,
|
|
276
|
-
from: z.string().optional().describe("\u8D77\u70B9\u63D0\u4EA4"),
|
|
277
|
-
to: z.string().optional().describe("\u7EC8\u70B9\u63D0\u4EA4"),
|
|
278
|
-
path: z.string().optional().describe("\u9650\u5B9A\u7684\u6587\u4EF6\u8DEF\u5F84"),
|
|
279
|
-
staged: z.boolean().optional().describe("\u67E5\u770B\u5DF2\u6682\u5B58\uFF08\u7D22\u5F15\uFF09\u5DEE\u5F02"),
|
|
280
|
-
maxPatchBytes: z.number().int().positive().optional().describe("diff \u6B63\u6587\u6700\u5927\u5B57\u8282\u6570\uFF0C\u8D85\u51FA\u622A\u65AD"),
|
|
281
|
-
detail
|
|
282
|
-
});
|
|
283
|
-
var GitShowSchema = z.object({
|
|
284
|
-
...readonlyBase,
|
|
285
|
-
commit: z.string().describe("\u8981\u67E5\u770B\u7684\u63D0\u4EA4 hash"),
|
|
286
|
-
path: z.string().optional().describe("\u9650\u5B9A\u6587\u4EF6"),
|
|
287
|
-
maxPatchBytes: z.number().int().positive().optional(),
|
|
288
|
-
detail
|
|
289
|
-
});
|
|
290
|
-
var GitBranchListSchema = z.object({ ...readonlyBase });
|
|
291
|
-
var GitTagListSchema = z.object({ ...readonlyBase });
|
|
292
|
-
var GitRemoteListSchema = z.object({ ...readonlyBase });
|
|
293
|
-
var GitFileContentSchema = z.object({
|
|
294
|
-
...readonlyBase,
|
|
295
|
-
commit: z.string().describe("\u63D0\u4EA4 hash\uFF08\u5982 HEAD\u3001main\uFF09"),
|
|
296
|
-
path: z.string().describe("\u4ED3\u5E93\u5185\u6587\u4EF6\u76F8\u5BF9\u8DEF\u5F84"),
|
|
297
|
-
detail
|
|
298
|
-
});
|
|
299
|
-
var GitGraphSchema = z.object({
|
|
300
|
-
...readonlyBase,
|
|
301
|
-
maxCount: z.number().int().min(1).max(5e3).optional().describe("\u6700\u5927\u63D0\u4EA4\u6570")
|
|
302
|
-
});
|
|
303
|
-
var GitBranchGraphSchema = z.object({
|
|
304
|
-
...readonlyBase,
|
|
305
|
-
maxNodes: z.number().int().min(1).max(2e3).optional().describe("rev-list \u6700\u591A\u679A\u4E3E\u7684\u63D0\u4EA4\u6570\uFF0C\u7F3A\u7701 200"),
|
|
306
|
-
into: z.string().optional().describe("\u5408\u5165\u76EE\u6807\uFF08\u7EBF\u4E0A / ours\uFF09\u3002\u4E0E from \u4E00\u8D77\u65F6\u8FD4\u56DE lineage"),
|
|
307
|
-
from: z.string().optional().describe("\u6211\u7684\u5206\u652F\uFF08theirs\uFF09\u3002\u4E0E into \u4E00\u8D77\u65F6\u8FD4\u56DE lineage")
|
|
308
|
-
});
|
|
309
|
-
var GitReflogSchema = z.object({
|
|
310
|
-
...readonlyBase,
|
|
311
|
-
maxCount: z.number().int().min(1).max(500).optional().describe("\u6700\u591A\u8FD4\u56DE\u6761\u6570\uFF0C\u7F3A\u7701 50")
|
|
312
|
-
});
|
|
313
|
-
var mergeIntoFrom = {
|
|
314
|
-
into: z.string().min(1).describe("\u5408\u5165\u76EE\u6807\uFF08\u7EBF\u4E0A / ours / \u9884\u6F14\u5DE6\u4FA7\uFF09\u3002\u4F8B\u5982 origin/main"),
|
|
315
|
-
from: z.string().min(1).describe("\u6211\u7684\u5206\u652F\uFF08theirs / \u9884\u6F14\u53F3\u4FA7\uFF09\u3002\u4F8B\u5982 feature/x"),
|
|
316
|
-
fetch: z.boolean().optional().describe("\u662F\u5426\u5148\u975E\u4EA4\u4E92 fetch\u3002\u7F3A\u7701 true\uFF1B\u5931\u8D25\u5219\u7528\u672C\u5730\u5F15\u7528\u5E76\u6807\u660E stale"),
|
|
317
|
-
remote: z.string().optional().describe("fetch/push \u4F7F\u7528\u7684\u8FDC\u7A0B\u540D\uFF0C\u7F3A\u7701 origin"),
|
|
318
|
-
path: z.string().optional().describe("\u4EC5\u5173\u5FC3\u8BE5\u51B2\u7A81\u6587\u4EF6\u8DEF\u5F84")
|
|
319
|
-
};
|
|
320
|
-
var GitMergePreviewSchema = z.object({
|
|
321
|
-
...readonlyBase,
|
|
322
|
-
...mergeIntoFrom
|
|
323
|
-
});
|
|
324
|
-
var GitMergeRehearseSchema = z.object({
|
|
325
|
-
...readonlyBase,
|
|
326
|
-
...mergeIntoFrom,
|
|
327
|
-
maxFiles: z.number().int().min(1).max(100).optional().describe("\u6700\u591A\u751F\u6210\u51B2\u7A81\u6B63\u6587\u7684\u6587\u4EF6\u6570\uFF0C\u7F3A\u7701 20"),
|
|
328
|
-
detail
|
|
329
|
-
});
|
|
330
|
-
var GitMergeBlameSchema = z.object({
|
|
331
|
-
...readonlyBase,
|
|
332
|
-
into: z.string().min(1).describe("\u5408\u5165\u76EE\u6807\uFF08\u7EBF\u4E0A / ours\uFF09"),
|
|
333
|
-
from: z.string().min(1).describe("\u6211\u7684\u5206\u652F\uFF08theirs\uFF09"),
|
|
334
|
-
path: z.string().min(1).describe("\u8981\u6EAF\u6E90\u7684\u51B2\u7A81\u6587\u4EF6\u8DEF\u5F84"),
|
|
335
|
-
fetch: z.boolean().optional().describe("\u662F\u5426\u5148\u975E\u4EA4\u4E92 fetch\u3002\u7F3A\u7701 false\uFF08\u9884\u6F14\u4E4B\u540E\u6309\u9700\u62C9\uFF09"),
|
|
336
|
-
remote: z.string().optional().describe("fetch \u4F7F\u7528\u7684\u8FDC\u7A0B\u540D\uFF0C\u7F3A\u7701 origin")
|
|
337
|
-
});
|
|
338
|
-
var GitMergeSurveySchema = z.object({
|
|
339
|
-
...readonlyBase,
|
|
340
|
-
intos: z.array(z.string().min(1)).min(1).describe("\u5408\u5165\u76EE\u6807\uFF08\u7EBF\u4E0A / ours\uFF09\u5217\u8868"),
|
|
341
|
-
froms: z.array(z.string().min(1)).min(1).describe("\u6211\u7684\u5206\u652F\uFF08theirs\uFF09\u5217\u8868"),
|
|
342
|
-
fetch: z.boolean().optional().describe("\u662F\u5426\u5148\u975E\u4EA4\u4E92 fetch\u3002\u7F3A\u7701 true\uFF1B\u6574\u6279\u53EA fetch \u4E00\u6B21"),
|
|
343
|
-
remote: z.string().optional().describe("fetch \u4F7F\u7528\u7684\u8FDC\u7A0B\u540D\uFF0C\u7F3A\u7701 origin"),
|
|
344
|
-
async: z.boolean().optional().describe("\u4E3A true \u6216\u683C\u5B50\u6570>20 \u65F6\u540E\u53F0\u8DD1\uFF0C\u7ACB\u5373\u8FD4\u56DE jobId\uFF0C\u7528 git_job_get \u67E5\u7ED3\u679C")
|
|
345
|
-
});
|
|
346
|
-
var GitMergeOrderSchema = z.object({
|
|
347
|
-
...readonlyBase,
|
|
348
|
-
into: z.string().min(1).describe("\u5408\u5165\u76EE\u6807\uFF08\u7EBF\u4E0A / ours\uFF09"),
|
|
349
|
-
branches: z.array(z.string().min(1)).min(2).describe("\u5F85\u4F9D\u6B21\u5408\u5165\u7684\u6765\u6E90\u5206\u652F\uFF08\u81F3\u5C11 2 \u4E2A\uFF09"),
|
|
350
|
-
fetch: z.boolean().optional().describe("\u662F\u5426\u5148\u975E\u4EA4\u4E92 fetch\u3002\u7F3A\u7701 true"),
|
|
351
|
-
remote: z.string().optional().describe("fetch \u4F7F\u7528\u7684\u8FDC\u7A0B\u540D\uFF0C\u7F3A\u7701 origin")
|
|
352
|
-
});
|
|
353
|
-
var writeBase = { repoPath, dryRun };
|
|
354
|
-
var pathsField = z.array(z.string()).default([]).describe("\u6587\u4EF6\u8DEF\u5F84\u5217\u8868\uFF1B\u7F3A\u7701\u4E3A\u7A7A\u5373\u5168\u90E8\u6587\u4EF6");
|
|
355
|
-
var GitAddSchema = z.object({ ...writeBase, paths: pathsField });
|
|
356
|
-
var GitUnstageSchema = z.object({ ...writeBase, paths: pathsField });
|
|
357
|
-
var GitCommitSchema = z.object({
|
|
358
|
-
...writeBase,
|
|
359
|
-
message: z.string().min(1).describe("\u63D0\u4EA4\u4FE1\u606F"),
|
|
360
|
-
paths: z.array(z.string()).optional().describe("\u4EC5\u63D0\u4EA4\u8FD9\u4E9B\u8DEF\u5F84\uFF08\u53EF\u7A7A\uFF09"),
|
|
361
|
-
allowEmpty: z.boolean().optional().describe("\u5141\u8BB8\u7A7A\u63D0\u4EA4\uFF08--allow-empty\uFF09")
|
|
362
|
-
});
|
|
363
|
-
var GitCheckoutSchema = z.object({
|
|
364
|
-
...writeBase,
|
|
365
|
-
branch: z.string().describe("\u8981\u5207\u6362\u5230\u7684\u5206\u652F\u540D")
|
|
366
|
-
});
|
|
367
|
-
var GitBranchCreateSchema = z.object({
|
|
368
|
-
...writeBase,
|
|
369
|
-
name: z.string().describe("\u65B0\u5206\u652F\u540D"),
|
|
370
|
-
startPoint: z.string().optional().describe("\u521B\u5EFA\u8D77\u70B9\uFF08\u63D0\u4EA4/\u5206\u652F\uFF09\uFF0C\u7F3A\u7701\u4E3A\u5F53\u524D HEAD")
|
|
371
|
-
});
|
|
372
|
-
var GitBranchDeleteSchema = z.object({
|
|
373
|
-
...writeBase,
|
|
374
|
-
name: z.string().describe("\u8981\u5220\u9664\u7684\u5206\u652F\u540D\uFF08\u672A\u5408\u5E76\u5206\u652F\u4F1A\u88AB\u62D2\u7EDD\uFF09")
|
|
375
|
-
});
|
|
376
|
-
var GitMergeSchema = z.object({
|
|
377
|
-
...writeBase,
|
|
378
|
-
branch: z.string().describe("\u8981\u5408\u5E76\u8FDB\u6765\u7684\u5206\u652F\u540D")
|
|
379
|
-
});
|
|
380
|
-
var GitPullSchema = z.object({
|
|
381
|
-
...writeBase,
|
|
382
|
-
remote: z.string().optional().describe("\u8FDC\u7A0B\u540D\uFF08\u7F3A\u7701 origin\uFF09"),
|
|
383
|
-
branch: z.string().optional().describe("\u8FDC\u7AEF\u5206\u652F\u540D")
|
|
384
|
-
});
|
|
385
|
-
var GitFetchSchema = z.object({
|
|
386
|
-
...writeBase,
|
|
387
|
-
remote: z.string().optional().describe("\u8FDC\u7A0B\u540D\uFF08\u7F3A\u7701 origin\uFF09")
|
|
388
|
-
});
|
|
389
|
-
var continueFiles = z.array(
|
|
390
|
-
z.object({
|
|
391
|
-
path: z.string().describe("\u4ED3\u5E93\u5185\u76F8\u5BF9\u8DEF\u5F84"),
|
|
392
|
-
resolvedContent: z.string().describe("\u8BE5\u6587\u4EF6\u89E3\u51B3\u540E\u7684\u5B8C\u6574\u5185\u5BB9")
|
|
393
|
-
})
|
|
394
|
-
).optional().describe("\u5DF2\u89E3\u51B3\u51B2\u7A81\u7684\u6587\u4EF6\uFF1B\u5199\u5165\u5DE5\u4F5C\u533A\u5E76 git add \u540E\u518D continue\u3002\u5DF2\u5728\u7F16\u8F91\u5668\u89E3\u51B3\u5E76\u53EF\u4E3A\u7A7A");
|
|
395
|
-
var GitMergeAbortSchema = z.object({ ...writeBase });
|
|
396
|
-
var GitMergeContinueSchema = z.object({
|
|
397
|
-
...writeBase,
|
|
398
|
-
files: continueFiles
|
|
399
|
-
});
|
|
400
|
-
var GitRebaseAbortSchema = z.object({ ...writeBase });
|
|
401
|
-
var GitRebaseContinueSchema = z.object({
|
|
402
|
-
...writeBase,
|
|
403
|
-
files: continueFiles
|
|
404
|
-
});
|
|
405
|
-
var GitPushSchema = z.object({
|
|
406
|
-
...writeBase,
|
|
407
|
-
remote: z.string().optional().describe("\u8FDC\u7A0B\u540D\uFF08\u7F3A\u7701 origin\uFF09"),
|
|
408
|
-
branch: z.string().optional().describe("\u5206\u652F\u540D")
|
|
409
|
-
});
|
|
410
|
-
var GitTagCreateSchema = z.object({
|
|
411
|
-
...writeBase,
|
|
412
|
-
name: z.string().describe("\u6807\u7B7E\u540D"),
|
|
413
|
-
message: z.string().optional().describe("\u9644\u6CE8\u6807\u7B7E\u6D88\u606F\uFF08\u5E26\u5219\u521B\u5EFA annotated tag\uFF09"),
|
|
414
|
-
commit: z.string().optional().describe("\u6253\u6807\u7B7E\u7684\u63D0\u4EA4\uFF0C\u7F3A\u7701\u4E3A HEAD")
|
|
415
|
-
});
|
|
416
|
-
var GitStashSchema = z.object({
|
|
417
|
-
...writeBase,
|
|
418
|
-
message: z.string().optional().describe("stash \u6D88\u606F"),
|
|
419
|
-
includeUntracked: z.boolean().optional().describe("\u5305\u542B\u672A\u8DDF\u8E2A\u6587\u4EF6\uFF08-u\uFF09"),
|
|
420
|
-
paths: pathsField.describe("\u4EC5\u6682\u5B58\u8FD9\u4E9B\u6587\u4EF6\uFF08\u5BF9\u5E94 WebStorm Shelve \u7684\u9009\u62E9\u6027\u6682\u5B58\uFF1B\u7A7A\u5219\u6682\u5B58\u5168\u90E8\uFF09")
|
|
421
|
-
});
|
|
422
|
-
var GitStashListSchema = z.object({ ...readonlyBase });
|
|
423
|
-
var GitStashShowSchema = z.object({
|
|
424
|
-
...readonlyBase,
|
|
425
|
-
index: z.number().int().min(0).optional().describe("stash \u5E8F\u53F7\uFF0C\u7F3A\u7701\u4E3A stash@{0}"),
|
|
426
|
-
maxPatchBytes: z.number().int().positive().optional().describe("diff \u6B63\u6587\u6700\u5927\u5B57\u8282\u6570\uFF0C\u8D85\u51FA\u622A\u65AD"),
|
|
427
|
-
detail
|
|
428
|
-
});
|
|
429
|
-
var GitRepoOverviewSchema = z.object({ ...readonlyBase, detail });
|
|
430
|
-
var GitJobListSchema = z.object({ ...readonlyBase });
|
|
431
|
-
var GitJobGetSchema = z.object({
|
|
432
|
-
...readonlyBase,
|
|
433
|
-
id: z.string().min(1).describe("\u540E\u53F0\u4EFB\u52A1 id")
|
|
434
|
-
});
|
|
435
|
-
var GitJobCancelSchema = z.object({
|
|
436
|
-
...writeBase,
|
|
437
|
-
id: z.string().min(1).describe("\u8981\u53D6\u6D88\u7684\u540E\u53F0\u4EFB\u52A1 id")
|
|
438
|
-
});
|
|
439
|
-
var GitStashApplySchema = z.object({
|
|
440
|
-
...writeBase,
|
|
441
|
-
index: z.number().int().min(0).optional().describe("stash \u5E8F\u53F7\uFF0C\u7F3A\u7701\u4E3A stash@{0}")
|
|
442
|
-
});
|
|
443
|
-
var GitStashDropSchema = z.object({
|
|
444
|
-
...writeBase,
|
|
445
|
-
index: z.number().int().min(0).optional().describe("stash \u5E8F\u53F7\uFF0C\u7F3A\u7701\u4E3A stash@{0}")
|
|
446
|
-
});
|
|
447
|
-
var GitStashPopSchema = z.object({
|
|
448
|
-
...writeBase,
|
|
449
|
-
index: z.number().int().min(0).optional().describe("stash \u5E8F\u53F7\uFF0C\u7F3A\u7701\u4E3A\u6700\u65B0\u7684 stash@{0}")
|
|
450
|
-
});
|
|
451
|
-
var GitApplyResolveSchema = z.object({
|
|
452
|
-
...writeBase,
|
|
453
|
-
into: z.string().min(1).describe("\u5408\u5165\u76EE\u6807\uFF08\u7EBF\u4E0A / ours\uFF09\u3002\u4F8B\u5982 origin/main"),
|
|
454
|
-
from: z.string().min(1).describe("\u6211\u7684\u5206\u652F\uFF08theirs\uFF09\u3002\u4F8B\u5982 feature/x"),
|
|
455
|
-
remote: z.string().optional().describe("push \u4F7F\u7528\u7684\u8FDC\u7A0B\u540D\uFF0C\u7F3A\u7701 origin"),
|
|
456
|
-
files: z.array(
|
|
457
|
-
z.object({
|
|
458
|
-
path: z.string().describe("\u4ED3\u5E93\u5185\u76F8\u5BF9\u8DEF\u5F84"),
|
|
459
|
-
resolvedContent: z.string().describe("\u8BE5\u6587\u4EF6\u89E3\u51B3\u540E\u7684\u5B8C\u6574\u5185\u5BB9")
|
|
460
|
-
})
|
|
461
|
-
).optional().describe("\u5DF2\u89E3\u51B3\u51B2\u7A81\u7684\u6587\u4EF6\u3002\u5E72\u51C0\u5408\u5E76\u53EF\u7701\u7565\u6216\u4F20\u7A7A\u6570\u7EC4"),
|
|
462
|
-
push: z.boolean().optional().describe("\u662F\u5426\u63A8\u9001\u4E34\u65F6\u5206\u652F\uFF0C\u7F3A\u7701 true"),
|
|
463
|
-
keepLocal: z.boolean().optional().describe("\u63A8\u9001\u5931\u8D25\u65F6\u4ECD\u4FDD\u7559\u672C\u5730\u4E34\u65F6\u5206\u652F"),
|
|
464
|
-
tempBranch: z.string().optional().describe("\u81EA\u5B9A\u4E49\u4E34\u65F6\u5206\u652F\u540D\uFF1B\u7F3A\u7701 merge/<from>-into-<into>")
|
|
465
|
-
});
|
|
466
|
-
var mrIntoFrom = {
|
|
467
|
-
into: z.string().min(1).describe("\u5408\u5165\u76EE\u6807\uFF08\u7EBF\u4E0A / ours\uFF09\u3002\u4F8B\u5982 origin/main"),
|
|
468
|
-
from: z.string().min(1).describe("\u6211\u7684\u5206\u652F\uFF08theirs\uFF09\u3002\u4F8B\u5982 feature/x"),
|
|
469
|
-
remote: z.string().optional().describe("\u8FDC\u7A0B\u540D\uFF0C\u7F3A\u7701 origin"),
|
|
470
|
-
sourceBranch: z.string().optional().describe("PR \u6E90\u5206\u652F\uFF1B\u7F3A\u7701\u5DF2\u6709\u4E34\u65F6\u5206\u652F merge/<from>-into-<into>\uFF0C\u5426\u5219 from")
|
|
471
|
-
};
|
|
472
|
-
var GitMrPrepareSchema = z.object({
|
|
473
|
-
...readonlyBase,
|
|
474
|
-
...mrIntoFrom
|
|
475
|
-
});
|
|
476
|
-
var GitMrCreateSchema = z.object({
|
|
477
|
-
...writeBase,
|
|
478
|
-
...mrIntoFrom,
|
|
479
|
-
title: z.string().optional().describe("PR \u6807\u9898\uFF1B\u7F3A\u7701 Merge <source> into <target>"),
|
|
480
|
-
body: z.string().optional().describe("PR \u6B63\u6587"),
|
|
481
|
-
reviewers: z.array(z.string()).optional().describe("\u5BA1\u6838\u4EBA/\u6307\u6D3E\u4EBA\u7528\u6237\u540D\uFF1BGitLab \u4F1A\u89E3\u6790\u6210\u6570\u5B57 id\u3002Token \u4E0D\u5728\u6B64\u4F20\u5165")
|
|
482
|
-
});
|
|
483
|
-
var GitResetHardSchema = z.object({ ...writeBase, target: z.string().describe("\u8981\u91CD\u7F6E\u5230\u7684\u63D0\u4EA4") });
|
|
484
|
-
var GitCleanSchema = z.object({ ...writeBase });
|
|
485
|
-
var GitPushForceSchema = z.object({
|
|
486
|
-
...writeBase,
|
|
487
|
-
remote: z.string().optional(),
|
|
488
|
-
branch: z.string().optional()
|
|
489
|
-
});
|
|
490
|
-
var GitBranchDeleteForceSchema = z.object({
|
|
491
|
-
...writeBase,
|
|
492
|
-
name: z.string().describe("\u8981\u5F3A\u5236\u5220\u9664\u7684\u5206\u652F\u540D")
|
|
493
|
-
});
|
|
494
|
-
var GitRebaseSchema = z.object({
|
|
495
|
-
...writeBase,
|
|
496
|
-
branch: z.string().describe("\u8981\u53D8\u57FA\u5230\u7684\u5206\u652F/\u63D0\u4EA4")
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
// src/tools/index.ts
|
|
500
|
-
var TOOL_DEFS = [
|
|
501
|
-
// ---------------------------------------------------------------------------
|
|
502
|
-
// 只读工具(默认开放)
|
|
503
|
-
// ---------------------------------------------------------------------------
|
|
504
|
-
{
|
|
505
|
-
name: "git_status",
|
|
506
|
-
description: "\u83B7\u53D6\u5F53\u524D\u4ED3\u5E93\u7684\u5DE5\u4F5C\u533A\u72B6\u6001\uFF1A\u5F53\u524D\u5206\u652F\u3001\u5DF2\u6682\u5B58/\u672A\u6682\u5B58/\u672A\u8DDF\u8E2A\u6587\u4EF6\u3001\u51B2\u7A81\u6587\u4EF6\u3001\u9886\u5148/\u843D\u540E\u4E8E\u4E0A\u6E38\u7B49\u3002",
|
|
507
|
-
risk: "readonly",
|
|
508
|
-
schema: GitStatusSchema,
|
|
509
|
-
handler: async (_args, ctx) => ctx.git.getStatus()
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
name: "git_log",
|
|
513
|
-
description: "\u83B7\u53D6\u63D0\u4EA4\u5386\u53F2\uFF08\u9ED8\u8BA4 HEAD \u8D77\uFF0C\u6700\u591A\u8FD4\u56DE maxCount \u6761\uFF09\u3002\u652F\u6301\u6309\u4F5C\u8005\u3001\u8DEF\u5F84\u3001\u63D0\u4EA4\u8303\u56F4\u8FC7\u6EE4\u3002",
|
|
514
|
-
risk: "readonly",
|
|
515
|
-
schema: GitLogSchema,
|
|
516
|
-
handler: async (args, ctx) => ctx.git.getLog({
|
|
517
|
-
maxCount: args.maxCount,
|
|
518
|
-
from: args.from,
|
|
519
|
-
to: args.to,
|
|
520
|
-
author: args.author,
|
|
521
|
-
path: args.path,
|
|
522
|
-
all: args.all
|
|
523
|
-
})
|
|
524
|
-
},
|
|
525
|
-
{
|
|
526
|
-
name: "git_diff",
|
|
527
|
-
description: "\u83B7\u53D6\u5DE5\u4F5C\u533A/\u6682\u5B58\u533A/\u63D0\u4EA4\u8303\u56F4\u7684\u5DEE\u5F02\u3002\u652F\u6301\u6307\u5B9A\u6587\u4EF6\u3001staged\u3001\u5927 diff \u622A\u65AD\u3002\u8FD4\u56DE\u6587\u4EF6\u7EA7\u7EDF\u8BA1\u4E0E\u5B8C\u6574 unified diff \u6587\u672C\u3002",
|
|
528
|
-
risk: "readonly",
|
|
529
|
-
schema: GitDiffSchema,
|
|
530
|
-
handler: async (args, ctx) => ctx.git.getDiff({
|
|
531
|
-
from: args.from,
|
|
532
|
-
to: args.to,
|
|
533
|
-
path: args.path,
|
|
534
|
-
staged: args.staged,
|
|
535
|
-
maxPatchBytes: args.maxPatchBytes
|
|
536
|
-
})
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
name: "git_show",
|
|
540
|
-
description: "\u663E\u793A\u67D0\u4E2A\u63D0\u4EA4\u7684\u8BE6\u7EC6\u4FE1\u606F\uFF08\u5143\u4FE1\u606F + \u76F8\u5BF9\u7236\u63D0\u4EA4\u7684 diff\uFF09\u3002",
|
|
541
|
-
risk: "readonly",
|
|
542
|
-
schema: GitShowSchema,
|
|
543
|
-
handler: async (args, ctx) => ctx.git.getShow(args.commit, {
|
|
544
|
-
path: args.path,
|
|
545
|
-
maxPatchBytes: args.maxPatchBytes
|
|
546
|
-
})
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
name: "git_branch_list",
|
|
550
|
-
description: "\u5217\u51FA\u6240\u6709\u672C\u5730\u4E0E\u8FDC\u7A0B\u5206\u652F\uFF0C\u6807\u6CE8\u5F53\u524D\u5206\u652F\u53CA\u5176\u6307\u5411\u7684\u63D0\u4EA4\u3002",
|
|
551
|
-
risk: "readonly",
|
|
552
|
-
schema: GitBranchListSchema,
|
|
553
|
-
handler: async (_args, ctx) => ctx.git.listBranches()
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
name: "git_tag_list",
|
|
557
|
-
description: "\u5217\u51FA\u6240\u6709\u6807\u7B7E\uFF08\u6309\u521B\u5EFA\u65F6\u95F4\u5012\u5E8F\uFF09\u3002",
|
|
558
|
-
risk: "readonly",
|
|
559
|
-
schema: GitTagListSchema,
|
|
560
|
-
handler: async (_args, ctx) => ctx.git.listTags()
|
|
561
|
-
},
|
|
562
|
-
{
|
|
563
|
-
name: "git_remote_list",
|
|
564
|
-
description: "\u5217\u51FA\u8FDC\u7A0B\u4ED3\u5E93\u4FE1\u606F\uFF08\u540D\u79F0\u3001fetch/push URL\uFF09\u3002",
|
|
565
|
-
risk: "readonly",
|
|
566
|
-
schema: GitRemoteListSchema,
|
|
567
|
-
handler: async (_args, ctx) => ctx.git.listRemotes()
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
name: "git_file_content",
|
|
571
|
-
description: "\u8BFB\u53D6\u6307\u5B9A\u63D0\u4EA4\u4E2D\u67D0\u4E2A\u6587\u4EF6\u7684\u5185\u5BB9\uFF08\u5927\u6587\u4EF6\u81EA\u52A8\u622A\u65AD 2MB\uFF09\u3002",
|
|
572
|
-
risk: "readonly",
|
|
573
|
-
schema: GitFileContentSchema,
|
|
574
|
-
handler: async (args, ctx) => ctx.git.getFileContent(args.commit, args.path)
|
|
575
|
-
},
|
|
576
|
-
{
|
|
577
|
-
name: "git_graph",
|
|
578
|
-
description: "\u83B7\u53D6\u5168\u90E8\u5206\u652F\u7684\u63D0\u4EA4\u5217\u8868\uFF08hash/parent/subject/refs/HEAD\uFF09\uFF0C\u7ED9\u9700\u8981\u7EBF\u6027\u5386\u53F2\u7684\u573A\u666F\u3002\u72B6\u6001\u9875 G6 \u5206\u652F\u56FE\u8BF7\u7528 git_branch_graph\uFF08tip DAG\uFF09\u3002",
|
|
579
|
-
risk: "readonly",
|
|
580
|
-
schema: GitGraphSchema,
|
|
581
|
-
handler: async (args, ctx) => ctx.git.getGraph(args.maxCount)
|
|
582
|
-
},
|
|
583
|
-
{
|
|
584
|
-
name: "git_branch_graph",
|
|
585
|
-
description: "\u5206\u652F tip DAG\uFF1Afor-each-ref + rev-list --parents\u3002\u8282\u70B9\u662F\u5404\u5206\u652F tip\uFF0C\u8FB9\u662F\u6700\u8FD1\u7956\u5148 tip\u3002\u4E0E Git Insight \u753B\u5E03\u540C\u4E00\u53E3\u5F84\u3002\u4E0D\u6539\u5DE5\u4F5C\u533A\u3002",
|
|
586
|
-
risk: "readonly",
|
|
587
|
-
schema: GitBranchGraphSchema,
|
|
588
|
-
handler: async (args, ctx) => ctx.git.getBranchGraph({
|
|
589
|
-
maxNodes: args.maxNodes,
|
|
590
|
-
into: args.into,
|
|
591
|
-
from: args.from
|
|
592
|
-
})
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
name: "git_reflog",
|
|
596
|
-
description: "\u53EA\u8BFB\u5217\u51FA git reflog\uFF08HEAD \u79FB\u52A8\u8BB0\u5F55\uFF09\u3002",
|
|
597
|
-
risk: "readonly",
|
|
598
|
-
schema: GitReflogSchema,
|
|
599
|
-
handler: async (args, ctx) => ctx.git.getReflog(args.maxCount)
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
name: "git_backup_list",
|
|
603
|
-
description: "\u5217\u51FA\u9AD8\u5371\u64CD\u4F5C\u524D\u81EA\u52A8\u521B\u5EFA\u7684 backup/pre-op-* \u5206\u652F\uFF0C\u4EE5\u53CA\u8BF4\u660E\u542B git-cockpit backup \u7684 stash\u3002",
|
|
604
|
-
risk: "readonly",
|
|
605
|
-
schema: GitStatusSchema,
|
|
606
|
-
handler: async (_args, ctx) => new BackupManager(ctx.git).listBackups()
|
|
607
|
-
},
|
|
608
|
-
{
|
|
609
|
-
name: "git_merge_preview",
|
|
610
|
-
description: "\u7528 git merge-tree \u9884\u6F14\u628A from \u5408\u5165 into\uFF08\u4E0D\u6539\u5DE5\u4F5C\u533A\uFF09\u3002into=\u5408\u5165\u76EE\u6807/\u7EBF\u4E0A/ours\uFF0Cfrom=\u6211\u7684\u5206\u652F/theirs\u3002\u8FD4\u56DE\u662F\u5426\u53EF\u5E72\u51C0\u5408\u5E76\u53CA\u51B2\u7A81\u6587\u4EF6\u5217\u8868\u3002\u7981\u6B62\u7528 git_merge \u505A\u9884\u6F14\u3002Git >= 2.38\u3002",
|
|
611
|
-
risk: "readonly",
|
|
612
|
-
schema: GitMergePreviewSchema,
|
|
613
|
-
handler: async (args, ctx) => ctx.git.previewMerge({
|
|
614
|
-
into: args.into,
|
|
615
|
-
from: args.from,
|
|
616
|
-
fetch: args.fetch,
|
|
617
|
-
remote: args.remote,
|
|
618
|
-
path: args.path
|
|
619
|
-
})
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
name: "git_merge_rehearse",
|
|
623
|
-
description: "\u5B8C\u6574\u5408\u5E76\u9884\u6F14\uFF1A\u51B2\u7A81\u6587\u4EF6 + diff3 \u51B2\u7A81\u6B63\u6587 + ours/theirs/base\uFF08\u4ECD\u4E0D\u6539\u5DE5\u4F5C\u533A\uFF09\u3002MCP \u9ED8\u8BA4\u53EA\u56DE\u8DEF\u5F84\u6458\u8981\uFF1B\u8981\u6B63\u6587\u8BF7\u5E26 path \u6216 detail=true\u3002\u9009\u8FB9\u540E\u628A files \u4EA4\u7ED9 git_apply_resolve\u3002into/from \u540C git_merge_preview\u3002",
|
|
624
|
-
risk: "readonly",
|
|
625
|
-
schema: GitMergeRehearseSchema,
|
|
626
|
-
handler: async (args, ctx) => {
|
|
627
|
-
const wantBody = args.detail === true || typeof args.path === "string" && args.path.trim().length > 0;
|
|
628
|
-
if (!wantBody) {
|
|
629
|
-
return ctx.git.previewMerge({
|
|
630
|
-
into: args.into,
|
|
631
|
-
from: args.from,
|
|
632
|
-
fetch: args.fetch,
|
|
633
|
-
remote: args.remote,
|
|
634
|
-
path: args.path
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
return ctx.git.rehearseMerge({
|
|
638
|
-
into: args.into,
|
|
639
|
-
from: args.from,
|
|
640
|
-
fetch: args.fetch,
|
|
641
|
-
remote: args.remote,
|
|
642
|
-
path: args.path,
|
|
643
|
-
maxFiles: args.maxFiles
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
name: "git_merge_blame",
|
|
649
|
-
description: "\u5BF9\u5355\u4E2A\u51B2\u7A81\u6587\u4EF6\u4E24\u4FA7 tip \u8DD1 git blame\uFF08\u4E0D\u6539\u5DE5\u4F5C\u533A\uFF09\u3002\u8FD4\u56DE\u7EA2\u5757\u76F8\u5173\u533A\u95F4\u7684\u4F5C\u8005/\u8BF4\u660E/\u65F6\u95F4\uFF0C\u4F9B\u9009\u8FB9\u53C2\u8003\u3002\u4E0D\u662F\u81EA\u52A8\u9009\u8FB9\u3002into/from \u540C git_merge_preview\u3002",
|
|
650
|
-
risk: "readonly",
|
|
651
|
-
schema: GitMergeBlameSchema,
|
|
652
|
-
handler: async (args, ctx) => ctx.git.blameConflictFile({
|
|
653
|
-
into: args.into,
|
|
654
|
-
from: args.from,
|
|
655
|
-
path: args.path,
|
|
656
|
-
fetch: args.fetch,
|
|
657
|
-
remote: args.remote
|
|
658
|
-
})
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
name: "git_merge_survey",
|
|
662
|
-
description: "\u6279\u91CF\u9884\u6F14\u77E9\u9635\uFF1Aintos \xD7 froms \u6BCF\u5BF9\u8DD1\u4E00\u6B21 merge-tree\uFF0C\u6574\u6279\u53EA fetch \u4E00\u6B21\u3002\u53EA\u8FD4\u56DE\u7ED3\u8BBA\u4E0E\u51B2\u7A81\u8DEF\u5F84\u3002\u683C\u5B50>20 \u6216 async=true \u65F6\u540E\u53F0\u8DD1\u5E76\u8FD4\u56DE jobId\uFF08git_job_get\uFF09\u3002\u7981\u6B62\u7528 git_merge \u505A\u9884\u6F14\u3002",
|
|
663
|
-
risk: "readonly",
|
|
664
|
-
schema: GitMergeSurveySchema,
|
|
665
|
-
handler: async (args, ctx) => {
|
|
666
|
-
const intos = args.intos;
|
|
667
|
-
const froms = args.froms;
|
|
668
|
-
const asyncWanted = args.async === true || intos.length * froms.length > SURVEY_ASYNC_THRESHOLD;
|
|
669
|
-
if (asyncWanted) {
|
|
670
|
-
const job = ctx.host.jobs.startSurvey({
|
|
671
|
-
repoPath: ctx.repoPath,
|
|
672
|
-
intos,
|
|
673
|
-
froms,
|
|
674
|
-
fetch: args.fetch,
|
|
675
|
-
remote: args.remote,
|
|
676
|
-
git: ctx.git
|
|
677
|
-
});
|
|
678
|
-
return { jobId: job.id, status: job.status, async: true, title: job.title };
|
|
679
|
-
}
|
|
680
|
-
return ctx.git.surveyMerges({
|
|
681
|
-
intos,
|
|
682
|
-
froms,
|
|
683
|
-
fetch: args.fetch,
|
|
684
|
-
remote: args.remote
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
name: "git_merge_order",
|
|
690
|
-
description: "\u5EFA\u8BAE\u628A\u591A\u4E2A from \u5408\u5165\u540C\u4E00\u4E2A into \u7684\u987A\u5E8F\u3002\u5BF9\u8C61\u5E93\u5185 merge-tree + commit-tree \u4E32\u884C\u6A21\u62DF\uFF0C\u4E0D\u6539\u5DE5\u4F5C\u533A\u3001\u4E0D\u5EFA\u5206\u652F\u3002\u8FD4\u56DE\u5EFA\u8BAE\u987A\u5E8F\u3001\u80FD\u8FDE\u7EED\u5E72\u51C0\u5408\u5165\u51E0\u4E2A\u3001\u4ECE\u54EA\u4E00\u6B65\u5F00\u59CB\u8981\u4EBA\u5DE5\u3002",
|
|
691
|
-
risk: "readonly",
|
|
692
|
-
schema: GitMergeOrderSchema,
|
|
693
|
-
handler: async (args, ctx) => ctx.git.suggestMergeOrder({
|
|
694
|
-
into: args.into,
|
|
695
|
-
branches: args.branches,
|
|
696
|
-
fetch: args.fetch,
|
|
697
|
-
remote: args.remote
|
|
698
|
-
})
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
name: "git_mr_prepare",
|
|
702
|
-
description: "\u53EA\u8BFB\uFF1A\u89E3\u6790\u5F00 PR/MR \u7684\u6E90/\u76EE\u6807\u3001\u6D4F\u89C8\u5668\u521B\u5EFA\u9875\u3001\u672C\u673A gh/glab \u662F\u5426\u53EF\u7528\uFF08\u627E\u4E0D\u5230\u4F1A\u5E26\u5B98\u65B9\u5B89\u88C5\u5730\u5740\uFF09\u3001\u53EF\u9009\u5BA1\u6838\u4EBA\u5217\u8868\u3002Token \u4E0D\u8FDB\u53C2\u6570\u3002into/from \u540C git_merge_preview\u3002",
|
|
703
|
-
risk: "readonly",
|
|
704
|
-
schema: GitMrPrepareSchema,
|
|
705
|
-
handler: async (args, ctx) => {
|
|
706
|
-
const mr = ctx.host.config.mr;
|
|
707
|
-
const prep = await ctx.git.prepareMr({
|
|
708
|
-
into: args.into,
|
|
709
|
-
from: args.from,
|
|
710
|
-
remote: args.remote?.trim() || void 0,
|
|
711
|
-
sourceBranch: args.sourceBranch
|
|
712
|
-
});
|
|
713
|
-
return enrichPrepareMr({ prep, mr, cwd: ctx.git.repoPath });
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
{
|
|
717
|
-
name: "git_repo_overview",
|
|
718
|
-
description: "\u5DF2\u6253\u5F00\u4ED3\u5E93\u8109\u640F\uFF1A\u5206\u652F\u3001\u810F\u6587\u4EF6\u6570\u3001ahead/behind\u3001\u5DE5\u4F5C\u533A operation\u3001\u672C\u5730 merge/* \u6570\u3001\u8FD1 12 \u5468\u63D0\u4EA4\u603B\u6570\u3002\u9ED8\u8BA4\u4E0D\u542B\u6BCF\u65E5\u683C\u5B50\uFF1Bdetail=true \u624D\u56DE activity[]\u3002\u4E0D\u56DE diff\u3002",
|
|
719
|
-
risk: "readonly",
|
|
720
|
-
needsRepo: false,
|
|
721
|
-
schema: GitRepoOverviewSchema,
|
|
722
|
-
handler: async (_args, ctx) => ({ repos: await ctx.host.listOverviews() })
|
|
723
|
-
},
|
|
724
|
-
{
|
|
725
|
-
name: "git_job_list",
|
|
726
|
-
description: "\u5217\u51FA\u540E\u53F0\u4EFB\u52A1\u6458\u8981\uFF08\u514B\u9686 / survey / fetch\uFF09\u3002",
|
|
727
|
-
risk: "readonly",
|
|
728
|
-
needsRepo: false,
|
|
729
|
-
schema: GitJobListSchema,
|
|
730
|
-
handler: async (_args, ctx) => ({ jobs: ctx.host.jobs.list().map((j) => ctx.host.jobs.summary(j)) })
|
|
731
|
-
},
|
|
732
|
-
{
|
|
733
|
-
name: "git_job_get",
|
|
734
|
-
description: "\u67E5\u770B\u4E00\u6761\u540E\u53F0\u4EFB\u52A1\uFF08\u65E5\u5FD7 + \u5B8C\u6210\u65F6\u7684 result \u6458\u8981\uFF09\u3002",
|
|
735
|
-
risk: "readonly",
|
|
736
|
-
needsRepo: false,
|
|
737
|
-
schema: GitJobGetSchema,
|
|
738
|
-
handler: async (args, ctx) => {
|
|
739
|
-
const job = ctx.host.jobs.get(args.id);
|
|
740
|
-
if (!job) throw new GitOperationError2("\u4EFB\u52A1\u4E0D\u5B58\u5728", "JOB_NOT_FOUND");
|
|
741
|
-
return ctx.host.jobs.detail(job);
|
|
742
|
-
}
|
|
743
|
-
},
|
|
744
|
-
// ---------------------------------------------------------------------------
|
|
745
|
-
// 写操作工具(默认开放,需预览/确认)
|
|
746
|
-
// ---------------------------------------------------------------------------
|
|
747
|
-
{
|
|
748
|
-
name: "git_add",
|
|
749
|
-
description: "\u6682\u5B58\u6307\u5B9A\u6587\u4EF6\uFF1Bpaths \u4E3A\u7A7A\u8868\u793A\u6682\u5B58\u5168\u90E8\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
750
|
-
risk: "write",
|
|
751
|
-
schema: GitAddSchema,
|
|
752
|
-
handler: async (args, ctx) => ctx.git.add(args.paths ?? [], { dryRun: args.dryRun })
|
|
753
|
-
},
|
|
754
|
-
{
|
|
755
|
-
name: "git_unstage",
|
|
756
|
-
description: "\u53D6\u6D88\u6682\u5B58\u6307\u5B9A\u6587\u4EF6\uFF08git reset HEAD -- <paths>\uFF09\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
757
|
-
risk: "write",
|
|
758
|
-
schema: GitUnstageSchema,
|
|
759
|
-
handler: async (args, ctx) => ctx.git.unstage(args.paths ?? [], { dryRun: args.dryRun })
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
name: "git_commit",
|
|
763
|
-
description: "\u521B\u5EFA\u63D0\u4EA4\u3002\u9700\u8981\u6307\u5B9A message\uFF1Bpaths \u53EF\u9650\u5B9A\u4EC5\u63D0\u4EA4\u90E8\u5206\u6587\u4EF6\uFF1BallowEmpty \u5141\u8BB8\u7A7A\u63D0\u4EA4\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
764
|
-
risk: "write",
|
|
765
|
-
schema: GitCommitSchema,
|
|
766
|
-
handler: async (args, ctx) => ctx.git.commit(args.message, {
|
|
767
|
-
dryRun: args.dryRun,
|
|
768
|
-
allowEmpty: args.allowEmpty,
|
|
769
|
-
paths: args.paths
|
|
770
|
-
})
|
|
771
|
-
},
|
|
772
|
-
{
|
|
773
|
-
name: "git_checkout",
|
|
774
|
-
description: "\u5207\u6362\u5230\u6307\u5B9A\u5206\u652F\u3002\u82E5\u672C\u5730\u66F4\u6539\u4F1A\u88AB\u8986\u76D6\u5C06\u62D2\u7EDD\u5E76\u7ED9\u51FA\u63D0\u793A\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
775
|
-
risk: "write",
|
|
776
|
-
schema: GitCheckoutSchema,
|
|
777
|
-
handler: async (args, ctx) => ctx.git.checkoutBranch(args.branch, { dryRun: args.dryRun })
|
|
778
|
-
},
|
|
779
|
-
{
|
|
780
|
-
name: "git_branch_create",
|
|
781
|
-
description: "\u521B\u5EFA\u65B0\u5206\u652F\uFF08\u9ED8\u8BA4\u4ECE\u5F53\u524D HEAD\uFF1BstartPoint \u53EF\u6307\u5B9A\u8D77\u70B9\uFF09\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
782
|
-
risk: "write",
|
|
783
|
-
schema: GitBranchCreateSchema,
|
|
784
|
-
handler: async (args, ctx) => ctx.git.createBranch(args.name, {
|
|
785
|
-
dryRun: args.dryRun,
|
|
786
|
-
startPoint: args.startPoint
|
|
787
|
-
})
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
name: "git_branch_delete",
|
|
791
|
-
description: "\u5B89\u5168\u5220\u9664\u5206\u652F\uFF08-d\uFF0C\u672A\u5408\u5E76\u5206\u652F\u4F1A\u62D2\u7EDD\uFF09\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
792
|
-
risk: "write",
|
|
793
|
-
schema: GitBranchDeleteSchema,
|
|
794
|
-
handler: async (args, ctx) => ctx.git.deleteBranch(args.name, { dryRun: args.dryRun })
|
|
795
|
-
},
|
|
796
|
-
{
|
|
797
|
-
name: "git_merge",
|
|
798
|
-
description: "\u628A\u6307\u5B9A\u5206\u652F\u5408\u5E76\u5230\u5F53\u524D\u5206\u652F\uFF08\u666E\u901A\u5408\u5E76\uFF09\u3002\u4EA7\u751F\u51B2\u7A81\u65F6\u4F1A\u63D0\u793A\u89E3\u51B3\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
799
|
-
risk: "write",
|
|
800
|
-
schema: GitMergeSchema,
|
|
801
|
-
handler: async (args, ctx) => ctx.git.merge(args.branch, { dryRun: args.dryRun })
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
name: "git_merge_abort",
|
|
805
|
-
description: "\u4E2D\u6B62\u5F53\u524D\u5DE5\u4F5C\u533A merge\uFF08git merge --abort\uFF09\u3002\u53EA\u7528\u4E8E\u5DF2\u7ECF\u5F00\u59CB\u7684\u5DE5\u4F5C\u533A\u5408\u5E76\uFF0C\u7981\u6B62\u62FF\u6765\u4EE3\u66FF merge-tree \u9884\u6F14\u3002",
|
|
806
|
-
risk: "write",
|
|
807
|
-
schema: GitMergeAbortSchema,
|
|
808
|
-
handler: async (args, ctx) => ctx.git.mergeAbort({ dryRun: args.dryRun })
|
|
809
|
-
},
|
|
810
|
-
{
|
|
811
|
-
name: "git_merge_continue",
|
|
812
|
-
description: "\u7EE7\u7EED\u5F53\u524D\u5DE5\u4F5C\u533A merge\u3002\u53EF\u628A files[{path,resolvedContent}] \u5199\u5165\u5DE5\u4F5C\u533A\u5E76 git add \u540E\u518D continue\u3002\u4E0D\u662F git_apply_resolve\u3002",
|
|
813
|
-
risk: "write",
|
|
814
|
-
schema: GitMergeContinueSchema,
|
|
815
|
-
handler: async (args, ctx) => ctx.git.mergeContinue({
|
|
816
|
-
dryRun: args.dryRun,
|
|
817
|
-
files: args.files
|
|
818
|
-
})
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
name: "git_pull",
|
|
822
|
-
description: "\u4ECE\u8FDC\u7A0B\u62C9\u53D6\u5E76\u5408\u5E76\uFF08\u975E\u5F3A\u5236\uFF09\u3002\u8FDC\u7A0B\u6709\u51B2\u7A81\u5C06\u63D0\u793A\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
823
|
-
risk: "write",
|
|
824
|
-
schema: GitPullSchema,
|
|
825
|
-
handler: async (args, ctx) => ctx.git.pull({
|
|
826
|
-
dryRun: args.dryRun,
|
|
827
|
-
remote: args.remote,
|
|
828
|
-
branch: args.branch
|
|
829
|
-
})
|
|
830
|
-
},
|
|
831
|
-
{
|
|
832
|
-
name: "git_fetch",
|
|
833
|
-
description: "\u4ECE\u8FDC\u7A0B\u6293\u53D6\u8DDF\u8E2A\u5206\u652F\uFF08git fetch --prune --no-tags\uFF09\uFF0C\u4E0D\u6539\u5DE5\u4F5C\u533A\u3001\u4E0D\u5408\u5E76\u3002\u66F4\u65B0 origin/xxx \u540E\u518D\u505A\u9884\u6F14\u6216\u5206\u652F\u56FE\u5BF9\u6BD4\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
834
|
-
risk: "write",
|
|
835
|
-
schema: GitFetchSchema,
|
|
836
|
-
handler: async (args, ctx) => ctx.git.fetch({
|
|
837
|
-
dryRun: args.dryRun,
|
|
838
|
-
remote: args.remote
|
|
839
|
-
})
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
name: "git_push",
|
|
843
|
-
description: "\u63A8\u9001\u5230\u8FDC\u7A0B\uFF08\u975E\u5F3A\u5236\uFF09\u3002\u63A8\u9001\u88AB\u62D2\u7EDD\uFF08\u8FDC\u7A0B\u6709\u65B0\u63D0\u4EA4\uFF09\u4F1A\u7ED9\u51FA\u63D0\u793A\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
844
|
-
risk: "write",
|
|
845
|
-
schema: GitPushSchema,
|
|
846
|
-
handler: async (args, ctx) => ctx.git.push({
|
|
847
|
-
dryRun: args.dryRun,
|
|
848
|
-
remote: args.remote,
|
|
849
|
-
branch: args.branch
|
|
850
|
-
})
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
name: "git_tag_create",
|
|
854
|
-
description: "\u521B\u5EFA\u6807\u7B7E\uFF1B\u63D0\u4F9B message \u5219\u521B\u5EFA\u9644\u6CE8\u6807\u7B7E\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
855
|
-
risk: "write",
|
|
856
|
-
schema: GitTagCreateSchema,
|
|
857
|
-
handler: async (args, ctx) => ctx.git.createTag(args.name, {
|
|
858
|
-
dryRun: args.dryRun,
|
|
859
|
-
message: args.message,
|
|
860
|
-
commit: args.commit
|
|
861
|
-
})
|
|
862
|
-
},
|
|
863
|
-
{
|
|
864
|
-
name: "git_stash",
|
|
865
|
-
description: "\u6682\u5B58\uFF08stash\uFF09\u5F53\u524D\u5DE5\u4F5C\u533A\u66F4\u6539\uFF0C\u53EF\u9009\u5305\u542B\u672A\u8DDF\u8E2A\u6587\u4EF6\uFF08-u\uFF09\uFF1Bpaths \u53EF\u6307\u5B9A\u4EC5\u6682\u5B58\u90E8\u5206\u6587\u4EF6\uFF08\u5BF9\u5E94 WebStorm Shelve \u7684\u9009\u62E9\u6027\u6682\u5B58\uFF09\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
866
|
-
risk: "write",
|
|
867
|
-
schema: GitStashSchema,
|
|
868
|
-
handler: async (args, ctx) => ctx.git.stash(args.message, {
|
|
869
|
-
dryRun: args.dryRun,
|
|
870
|
-
includeUntracked: args.includeUntracked,
|
|
871
|
-
paths: args.paths ?? []
|
|
872
|
-
})
|
|
873
|
-
},
|
|
874
|
-
{
|
|
875
|
-
name: "git_stash_list",
|
|
876
|
-
description: "\u5217\u51FA\u5168\u90E8 stash \u8BB0\u5F55\uFF08stash@{n} / \u8BF4\u660E / \u65F6\u95F4\uFF09\u3002",
|
|
877
|
-
risk: "readonly",
|
|
878
|
-
schema: GitStashListSchema,
|
|
879
|
-
handler: async (_args, ctx) => ctx.git.listStashes()
|
|
880
|
-
},
|
|
881
|
-
{
|
|
882
|
-
name: "git_stash_show",
|
|
883
|
-
description: "\u67E5\u770B\u67D0\u6761 stash \u7684\u5DEE\u5F02\u5185\u5BB9\uFF08\u4E0D\u4FEE\u6539\u4ED3\u5E93\uFF09\u3002",
|
|
884
|
-
risk: "readonly",
|
|
885
|
-
schema: GitStashShowSchema,
|
|
886
|
-
handler: async (args, ctx) => ctx.git.stashShow({
|
|
887
|
-
index: args.index,
|
|
888
|
-
maxPatchBytes: args.maxPatchBytes
|
|
889
|
-
})
|
|
890
|
-
},
|
|
891
|
-
{
|
|
892
|
-
name: "git_stash_apply",
|
|
893
|
-
description: "\u5E94\u7528\u67D0\u6761 stash\uFF08\u4FDD\u7559\u8BB0\u5F55\uFF0C\u53EF\u53CD\u590D\u5E94\u7528\uFF09\u3002\u4EA7\u751F\u51B2\u7A81\u4F1A\u63D0\u793A\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
894
|
-
risk: "write",
|
|
895
|
-
schema: GitStashApplySchema,
|
|
896
|
-
handler: async (args, ctx) => ctx.git.stashApply({ dryRun: args.dryRun, index: args.index })
|
|
897
|
-
},
|
|
898
|
-
{
|
|
899
|
-
name: "git_stash_drop",
|
|
900
|
-
description: "\u5220\u9664\u67D0\u6761 stash \u8BB0\u5F55\uFF08\u5220\u9664\u540E\u4E0D\u53EF\u76F4\u63A5\u6062\u590D\uFF09\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
901
|
-
risk: "write",
|
|
902
|
-
schema: GitStashDropSchema,
|
|
903
|
-
handler: async (args, ctx) => ctx.git.stashDrop({ dryRun: args.dryRun, index: args.index })
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
name: "git_stash_pop",
|
|
907
|
-
description: "\u6062\u590D\u6700\u65B0\uFF08\u6216\u6307\u5B9A index\uFF09\u7684 stash\u3002\u6062\u590D\u4EA7\u751F\u51B2\u7A81\u4F1A\u63D0\u793A\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
908
|
-
risk: "write",
|
|
909
|
-
schema: GitStashPopSchema,
|
|
910
|
-
handler: async (args, ctx) => ctx.git.stashPop({ dryRun: args.dryRun, index: args.index })
|
|
911
|
-
},
|
|
912
|
-
{
|
|
913
|
-
name: "git_apply_resolve",
|
|
914
|
-
description: "\u5728\u72EC\u7ACB git worktree \u4E2D\u628A from \u5408\u5165 into \u5E76\u63D0\u4EA4\u5230\u4E34\u65F6\u5206\u652F\uFF08\u4E3B\u5DE5\u4F5C\u533A\u4E0D\u5207\u6362\uFF09\u3002\u5E72\u51C0\u5408\u5E76 files \u53EF\u7A7A\uFF1B\u6709\u51B2\u7A81\u5FC5\u987B\u63D0\u4F9B files\u3002\u9ED8\u8BA4 push \u4E34\u65F6\u5206\u652F\u3002\u4E0D\u8981\u7528\u5DE5\u4F5C\u533A git_merge \u4EE3\u66FF\u672C\u5DE5\u5177\u3002",
|
|
915
|
-
risk: "write",
|
|
916
|
-
schema: GitApplyResolveSchema,
|
|
917
|
-
handler: async (args, ctx) => ctx.git.applyResolve({
|
|
918
|
-
into: args.into,
|
|
919
|
-
from: args.from,
|
|
920
|
-
files: args.files,
|
|
921
|
-
remote: args.remote,
|
|
922
|
-
push: args.push,
|
|
923
|
-
keepLocal: args.keepLocal,
|
|
924
|
-
tempBranch: args.tempBranch,
|
|
925
|
-
dryRun: args.dryRun
|
|
926
|
-
})
|
|
927
|
-
},
|
|
928
|
-
{
|
|
929
|
-
name: "git_mr_create",
|
|
930
|
-
description: "\u6309\u8BBE\u7F6E MR \u914D\u7F6E\u5F00 PR/MR\uFF1AToken REST\u3001\u672C\u673A gh/glab\uFF0C\u6216\u6D4F\u89C8\u5668\u521B\u5EFA\u9875\u3002Token \u4E0D\u8FDB\u672C\u5DE5\u5177\u53C2\u6570\u3002\u627E\u4E0D\u5230 CLI \u65F6\u7ED3\u679C\u91CC\u5E26\u5B98\u65B9\u5B89\u88C5\u5730\u5740\u3002dry_run \u53EF\u9884\u89C8\u3002",
|
|
931
|
-
risk: "write",
|
|
932
|
-
schema: GitMrCreateSchema,
|
|
933
|
-
handler: async (args, ctx) => {
|
|
934
|
-
const mr = ctx.host.config.mr;
|
|
935
|
-
const prep = await ctx.git.prepareMr({
|
|
936
|
-
into: args.into,
|
|
937
|
-
from: args.from,
|
|
938
|
-
remote: args.remote?.trim() || void 0,
|
|
939
|
-
sourceBranch: args.sourceBranch
|
|
940
|
-
});
|
|
941
|
-
return createPullOrMergeRequest({
|
|
942
|
-
prep,
|
|
943
|
-
mr,
|
|
944
|
-
cwd: ctx.git.repoPath,
|
|
945
|
-
title: args.title,
|
|
946
|
-
body: args.body,
|
|
947
|
-
reviewers: args.reviewers,
|
|
948
|
-
dryRun: args.dryRun
|
|
949
|
-
});
|
|
950
|
-
}
|
|
951
|
-
},
|
|
952
|
-
{
|
|
953
|
-
name: "git_job_cancel",
|
|
954
|
-
description: "\u53D6\u6D88\u8FDB\u884C\u4E2D\u7684\u540E\u53F0\u4EFB\u52A1\u3002\u514B\u9686\u4F1A\u6740\u8FDB\u7A0B\u5E76\u5220\u9664\u4E0D\u5B8C\u6574\u76EE\u5F55\u3002",
|
|
955
|
-
risk: "write",
|
|
956
|
-
needsRepo: false,
|
|
957
|
-
schema: GitJobCancelSchema,
|
|
958
|
-
handler: async (args, ctx) => {
|
|
959
|
-
if (args.dryRun) {
|
|
960
|
-
return {
|
|
961
|
-
dryRun: true,
|
|
962
|
-
command: "job cancel",
|
|
963
|
-
args: [args.id],
|
|
964
|
-
risk: "low",
|
|
965
|
-
note: "\u5C06\u53D6\u6D88\u8FDB\u884C\u4E2D\u7684\u540E\u53F0\u4EFB\u52A1"
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
return ctx.host.jobs.summary(ctx.host.jobs.cancel(args.id));
|
|
969
|
-
}
|
|
970
|
-
},
|
|
971
|
-
// ---------------------------------------------------------------------------
|
|
972
|
-
// 高风险工具(默认禁用,需开启/审批;自动备份)
|
|
973
|
-
// ---------------------------------------------------------------------------
|
|
974
|
-
{
|
|
975
|
-
name: "git_reset_hard",
|
|
976
|
-
description: "\u786C\u91CD\u7F6E\u5230\u6307\u5B9A\u63D0\u4EA4\uFF08\u4E22\u5F03\u7D22\u5F15\u4E0E\u5DE5\u4F5C\u533A\u66F4\u6539\uFF0C\u9AD8\u98CE\u9669\u4E0D\u53EF\u9006\uFF0C\u6267\u884C\u524D\u81EA\u52A8\u5907\u4EFD\uFF09\u3002",
|
|
977
|
-
risk: "dangerous",
|
|
978
|
-
schema: GitResetHardSchema,
|
|
979
|
-
handler: async (args, ctx) => ctx.git.resetHard(args.target, { dryRun: args.dryRun })
|
|
980
|
-
},
|
|
981
|
-
{
|
|
982
|
-
name: "git_clean",
|
|
983
|
-
description: "\u6E05\u7406\uFF08\u5220\u9664\uFF09\u6240\u6709\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0E\u76EE\u5F55\uFF08\u9AD8\u98CE\u9669\u4E0D\u53EF\u9006\uFF0C\u6267\u884C\u524D\u81EA\u52A8\u5907\u4EFD\uFF09\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
984
|
-
risk: "dangerous",
|
|
985
|
-
schema: GitCleanSchema,
|
|
986
|
-
handler: async (args, ctx) => ctx.git.clean({ dryRun: args.dryRun })
|
|
987
|
-
},
|
|
988
|
-
{
|
|
989
|
-
name: "git_push_force",
|
|
990
|
-
description: "\u4EE5 --force-with-lease \u5F3A\u5236\u63A8\u9001\uFF08\u8986\u76D6\u8FDC\u7A0B\u5386\u53F2\uFF0C\u9AD8\u98CE\u9669\uFF0C\u6267\u884C\u524D\u81EA\u52A8\u5907\u4EFD\uFF09\u3002",
|
|
991
|
-
risk: "dangerous",
|
|
992
|
-
schema: GitPushForceSchema,
|
|
993
|
-
handler: async (args, ctx) => ctx.git.pushForce({
|
|
994
|
-
dryRun: args.dryRun,
|
|
995
|
-
remote: args.remote,
|
|
996
|
-
branch: args.branch
|
|
997
|
-
})
|
|
998
|
-
},
|
|
999
|
-
{
|
|
1000
|
-
name: "git_branch_delete_force",
|
|
1001
|
-
description: "\u5F3A\u5236\u5220\u9664\u5206\u652F\uFF08-D\uFF0C\u4E0D\u68C0\u67E5\u5408\u5E76\u72B6\u6001\uFF0C\u9AD8\u98CE\u9669\uFF09\u3002\u652F\u6301 dry_run \u9884\u89C8\u3002",
|
|
1002
|
-
risk: "dangerous",
|
|
1003
|
-
schema: GitBranchDeleteForceSchema,
|
|
1004
|
-
handler: async (args, ctx) => ctx.git.deleteBranchForce(args.name, { dryRun: args.dryRun })
|
|
1005
|
-
},
|
|
1006
|
-
{
|
|
1007
|
-
name: "git_rebase",
|
|
1008
|
-
description: "\u628A\u5F53\u524D\u5206\u652F\u53D8\u57FA\u5230\u6307\u5B9A\u5206\u652F\uFF08\u91CD\u5199\u63D0\u4EA4\u5386\u53F2\uFF0C\u9AD8\u98CE\u9669\uFF0C\u4EA7\u751F\u51B2\u7A81\u9700\u624B\u52A8\u89E3\u51B3\u540E git rebase --continue\uFF09\u3002",
|
|
1009
|
-
risk: "dangerous",
|
|
1010
|
-
schema: GitRebaseSchema,
|
|
1011
|
-
handler: async (args, ctx) => ctx.git.rebase(args.branch, { dryRun: args.dryRun })
|
|
1012
|
-
},
|
|
1013
|
-
{
|
|
1014
|
-
name: "git_rebase_abort",
|
|
1015
|
-
description: "\u4E2D\u6B62\u5F53\u524D\u5DE5\u4F5C\u533A rebase\uFF08git rebase --abort\uFF09\u3002\u53EA\u7528\u4E8E\u5DF2\u7ECF\u5F00\u59CB\u7684\u53D8\u57FA\u3002",
|
|
1016
|
-
risk: "write",
|
|
1017
|
-
schema: GitRebaseAbortSchema,
|
|
1018
|
-
handler: async (args, ctx) => ctx.git.rebaseAbort({ dryRun: args.dryRun })
|
|
1019
|
-
},
|
|
1020
|
-
{
|
|
1021
|
-
name: "git_rebase_continue",
|
|
1022
|
-
description: "\u7EE7\u7EED\u5F53\u524D\u5DE5\u4F5C\u533A rebase\u3002\u53EF\u628A files \u5199\u5165\u5DE5\u4F5C\u533A\u5E76 git add \u540E\u518D continue\u3002\u51B2\u7A81\u987B\u5148\u89E3\u51B3\u3002",
|
|
1023
|
-
risk: "write",
|
|
1024
|
-
schema: GitRebaseContinueSchema,
|
|
1025
|
-
handler: async (args, ctx) => ctx.git.rebaseContinue({
|
|
1026
|
-
dryRun: args.dryRun,
|
|
1027
|
-
files: args.files
|
|
1028
|
-
})
|
|
1029
|
-
}
|
|
1030
|
-
];
|
|
1031
|
-
var TOOL_DEF_MAP = new Map(TOOL_DEFS.map((d) => [d.name, d]));
|
|
1032
|
-
getCapabilityRegistry().registerAll(TOOL_DEFS);
|
|
1033
|
-
function toolSummaries() {
|
|
1034
|
-
return TOOL_DEFS.map((d) => ({ name: d.name, description: d.description }));
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// src/tools/prompts.ts
|
|
1038
|
-
var PREAMBLE = [
|
|
1039
|
-
"\u4E0D\u8981\u7528\u7EC8\u7AEF git \u4EE3\u66FF\u300C\u9884\u6F14\u3001\u843D\u76D8\u3001\u5F00 PR\u300D\u3002",
|
|
1040
|
-
"\u9ED8\u8BA4\u53EA\u7ED9\u6458\u8981\uFF1B\u8981\u770B\u67D0\u6587\u4EF6\u6B63\u6587\u65F6\u518D\u8BF4\u8DEF\u5F84\uFF0C\u6216\u52A0 `detail=true`\u3002\u5199\u64CD\u4F5C\u5148\u5E72\u8DD1\uFF08`dry_run=true`\uFF09\u3002\u9AD8\u98CE\u9669\u64CD\u4F5C\u9ED8\u8BA4\u5173\u7740\u3002"
|
|
1041
|
-
].join("\n");
|
|
1042
|
-
var MCP_PROMPTS = [
|
|
1043
|
-
{
|
|
1044
|
-
name: "safe_commit",
|
|
1045
|
-
title: "\u63D0\u4EA4",
|
|
1046
|
-
description: "\u5148\u770B\u6539\u4E86\u4EC0\u4E48\uFF0C\u518D\u6682\u5B58\u3001\u518D\u63D0\u4EA4\u3002\u4E0D\u8981\u4E00\u4E0A\u6765\u5C31\u63D0\u4EA4\u3002",
|
|
1047
|
-
text: [
|
|
1048
|
-
PREAMBLE,
|
|
1049
|
-
"",
|
|
1050
|
-
"1. \u63D0\u4EA4",
|
|
1051
|
-
"\u5148\u770B\u5DE5\u4F5C\u533A\u6709\u6CA1\u6709\u6539\u3001\u6539\u4E86\u4EC0\u4E48\uFF0C\u518D\u6682\u5B58\uFF0C\u518D\u63D0\u4EA4\u3002\u4E0D\u8981\u4E00\u4E0A\u6765\u5C31\u63D0\u4EA4\u3002",
|
|
1052
|
-
"",
|
|
1053
|
-
"\u5BF9\u5E94\u5DE5\u5177\uFF1A`git_status` \u2192 `git_diff` \u2192 \u6309\u9700 `git_add` \u2192 `git_commit`\u3002"
|
|
1054
|
-
].join("\n")
|
|
1055
|
-
},
|
|
1056
|
-
{
|
|
1057
|
-
name: "merge_preview_apply",
|
|
1058
|
-
title: "\u5408\u4E0D\u5408\u5F97\u8FDB\u53BB\uFF0C\u4EE5\u53CA\u5199\u8FDB\u4ED3\u5E93",
|
|
1059
|
-
description: "\u53EA\u505A\u9884\u6F14\uFF0C\u4EBA\u9009\u8FB9\uFF0C\u72EC\u7ACB\u76EE\u5F55\u843D\u76D8\u3002\u5DE5\u4F5C\u533A\u5DF2\u7ECF\u5361\u4F4F\u65F6\u4E0D\u8981\u8D70\u8FD9\u6761\u3002",
|
|
1060
|
-
text: [
|
|
1061
|
-
PREAMBLE,
|
|
1062
|
-
"",
|
|
1063
|
-
"2. \u5408\u4E0D\u5408\u5F97\u8FDB\u53BB\uFF0C\u4EE5\u53CA\u5199\u8FDB\u4ED3\u5E93",
|
|
1064
|
-
"\u5148\u770B\u5DE5\u4F5C\u533A\u662F\u4E0D\u662F\u5DF2\u7ECF\u5361\u5728 merge / rebase \u91CC\u3002\u5361\u4F4F\u4E86\u8D70\u300C\u5DE5\u4F5C\u533A\u5DF2\u7ECF\u5361\u5728 merge \u6216 rebase \u91CC\u300D\uFF0C\u4E0D\u8981\u8D70\u8FD9\u6761\u3002",
|
|
1065
|
-
"",
|
|
1066
|
-
"\u95EE\u80FD\u4E0D\u80FD\u5408\u8FDB\u53BB\u65F6\uFF0C\u53EA\u505A\u9884\u6F14\uFF0C\u4E0D\u8981\u5728\u5F53\u524D\u5DE5\u4F5C\u533A\u6267\u884C merge\u3002`into` \u662F\u8981\u5408\u8FDB\u53BB\u7684\u76EE\u6807\uFF08\u7EBF\u4E0A\uFF09\uFF0C`from` \u662F\u4F60\u7684\u5206\u652F\u3002\u6709\u51B2\u7A81\u65F6\u628A\u6B63\u6587\u7ED9\u4EBA\u770B\u3001\u4EBA\u9009\u8FB9\uFF0C\u4E0D\u8981\u8BA9\u6A21\u578B\u81EA\u52A8\u9009\u3002",
|
|
1067
|
-
"",
|
|
1068
|
-
"\u770B\u5B8C\u8981\u5199\u8FDB\u4ED3\u5E93\uFF1A\u7528\u72EC\u7ACB\u76EE\u5F55\u843D\u76D8\uFF0C\u4E0D\u8981\u5207\u8D70\u4F60\u6B63\u5728\u5E72\u6D3B\u7684\u5206\u652F\u3002",
|
|
1069
|
-
"",
|
|
1070
|
-
"\u5BF9\u5E94\u5DE5\u5177\uFF1A`git_merge_preview` / `git_merge_rehearse`\uFF08\u51B2\u7A81\u884C\u662F\u8C01\u6539\u7684\u7528 `git_merge_blame`\uFF09\u2192 `git_apply_resolve`\u3002\u7981\u6B62\u7528 `git_merge` \u5192\u5145\u9884\u6F14\u3002"
|
|
1071
|
-
].join("\n")
|
|
1072
|
-
},
|
|
1073
|
-
{
|
|
1074
|
-
name: "workspace_continue",
|
|
1075
|
-
title: "\u5DE5\u4F5C\u533A\u5DF2\u7ECF\u5361\u5728 merge \u6216 rebase \u91CC",
|
|
1076
|
-
description: "\u770B\u72B6\u6001\uFF0C\u7136\u540E\u7EE7\u7EED\u6216\u653E\u5F03\u3002\u4E0D\u8981\u7528\u9884\u6F14\u843D\u76D8\u53BB\u6536\u5C3E\u3002",
|
|
1077
|
-
text: [
|
|
1078
|
-
PREAMBLE,
|
|
1079
|
-
"",
|
|
1080
|
-
"3. \u5DE5\u4F5C\u533A\u5DF2\u7ECF\u5361\u5728 merge \u6216 rebase \u91CC",
|
|
1081
|
-
"\u8FD9\u662F\u53E6\u4E00\u56DE\u4E8B\uFF1A\u51B2\u7A81\u5DF2\u7ECF\u53D1\u751F\u5728\u5F53\u524D\u76EE\u5F55\u4E86\u3002\u770B\u72B6\u6001\uFF0C\u7136\u540E\u7EE7\u7EED\u6216\u653E\u5F03\u3002\u4E0D\u8981\u7528\u300C\u5408\u4E0D\u5408\u5F97\u8FDB\u53BB\uFF0C\u4EE5\u53CA\u5199\u8FDB\u4ED3\u5E93\u300D\u7684\u843D\u76D8\u53BB\u6536\u5C3E\u3002",
|
|
1082
|
-
"",
|
|
1083
|
-
"\u5BF9\u5E94\u5DE5\u5177\uFF1A`git_status`\uFF08\u770B `operation`\uFF09\u2192 `git_merge_continue` / `git_rebase_continue` \u6216 abort\u3002\u7981\u6B62\u7528 `git_apply_resolve`\u3002"
|
|
1084
|
-
].join("\n")
|
|
1085
|
-
},
|
|
1086
|
-
{
|
|
1087
|
-
name: "open_mr",
|
|
1088
|
-
title: "\u5F00 Pull Request / Merge Request",
|
|
1089
|
-
description: "\u5148\u51C6\u5907\u6807\u9898\u548C\u76EE\u6807\u5206\u652F\uFF0C\u518D\u521B\u5EFA\u3002Token \u5728\u7F51\u9875\u8BBE\u7F6E\u91CC\uFF0C\u4E0D\u8981\u585E\u8FDB\u5DE5\u5177\u53C2\u6570\u3002",
|
|
1090
|
-
text: [
|
|
1091
|
-
PREAMBLE,
|
|
1092
|
-
"",
|
|
1093
|
-
"4. \u5F00 Pull Request / Merge Request",
|
|
1094
|
-
"\u5148\u51C6\u5907\u6807\u9898\u548C\u76EE\u6807\u5206\u652F\u7B49\u4FE1\u606F\uFF0C\u518D\u521B\u5EFA\u3002\u767B\u5F55\u7528\u7684 Token \u5199\u5728\u7F51\u9875\u8BBE\u7F6E\u91CC\uFF0C\u4E0D\u8981\u585E\u8FDB\u5DE5\u5177\u53C2\u6570\u3002",
|
|
1095
|
-
"",
|
|
1096
|
-
"\u5BF9\u5E94\u5DE5\u5177\uFF1A`git_mr_prepare` \u2192 `git_mr_create`\u3002"
|
|
1097
|
-
].join("\n")
|
|
1098
|
-
}
|
|
1099
|
-
];
|
|
1100
|
-
function registerMcpPrompts(server) {
|
|
1101
|
-
const register = server.registerPrompt.bind(server);
|
|
1102
|
-
for (const p of MCP_PROMPTS) {
|
|
1103
|
-
register(p.name, { title: p.title, description: p.description }, () => ({
|
|
1104
|
-
description: p.description,
|
|
1105
|
-
messages: [{ role: "user", content: { type: "text", text: p.text } }]
|
|
1106
|
-
}));
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
// src/tools/resources.ts
|
|
1111
|
-
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1112
|
-
var MIME = "application/json";
|
|
1113
|
-
function jsonContents(uri, data) {
|
|
1114
|
-
return {
|
|
1115
|
-
contents: [
|
|
1116
|
-
{
|
|
1117
|
-
uri,
|
|
1118
|
-
mimeType: MIME,
|
|
1119
|
-
text: JSON.stringify(data)
|
|
1120
|
-
}
|
|
1121
|
-
]
|
|
1122
|
-
};
|
|
1123
|
-
}
|
|
1124
|
-
function overviewWithoutDays(runtime) {
|
|
1125
|
-
return collectRepoOverviews(runtime).then(
|
|
1126
|
-
(repos) => repos.map((row) => {
|
|
1127
|
-
const { activity: _days, ...rest } = row;
|
|
1128
|
-
return rest;
|
|
1129
|
-
})
|
|
1130
|
-
);
|
|
1131
|
-
}
|
|
1132
|
-
function registerMcpResources(server, runtime) {
|
|
1133
|
-
const register = server.registerResource.bind(server);
|
|
1134
|
-
register(
|
|
1135
|
-
"repos",
|
|
1136
|
-
"git-cockpit://repos",
|
|
1137
|
-
{ title: "\u5DF2\u6253\u5F00\u4ED3\u5E93\u8109\u640F", description: "\u4E0E git_repo_overview \u540C\u6458\u8981\uFF0C\u4E0D\u542B\u6BCF\u65E5\u683C\u5B50", mimeType: MIME },
|
|
1138
|
-
async (uri) => jsonContents(uri.href, { repos: await overviewWithoutDays(runtime) })
|
|
1139
|
-
);
|
|
1140
|
-
register(
|
|
1141
|
-
"repo-current",
|
|
1142
|
-
"git-cockpit://repo/current",
|
|
1143
|
-
{ title: "\u6700\u8FD1\u6253\u5F00\u4ED3", description: "\u6700\u8FD1\u6253\u5F00\u4ED3\u5E93\u7684\u5DE5\u4F5C\u533A\u6458\u8981\uFF0C\u4E0D\u542B\u6587\u4EF6\u5217\u8868\u6B63\u6587", mimeType: MIME },
|
|
1144
|
-
async (uri) => {
|
|
1145
|
-
const handle = await runtime.repoManager.getCurrent();
|
|
1146
|
-
if (!handle) {
|
|
1147
|
-
return jsonContents(uri.href, { available: false, hint: "\u6CA1\u6709\u5DF2\u6253\u5F00\u7684\u4ED3\u5E93" });
|
|
1148
|
-
}
|
|
1149
|
-
const s = await handle.service.getStatus();
|
|
1150
|
-
return jsonContents(uri.href, {
|
|
1151
|
-
available: true,
|
|
1152
|
-
path: handle.record.path,
|
|
1153
|
-
current: s.current,
|
|
1154
|
-
tracking: s.tracking,
|
|
1155
|
-
ahead: s.ahead,
|
|
1156
|
-
behind: s.behind,
|
|
1157
|
-
operation: s.operation,
|
|
1158
|
-
isClean: s.isClean,
|
|
1159
|
-
stagedCount: s.staged.length,
|
|
1160
|
-
unstagedCount: s.unstaged.length,
|
|
1161
|
-
untrackedCount: s.untracked.length,
|
|
1162
|
-
conflictCount: s.conflicted.length,
|
|
1163
|
-
conflicted: s.conflicted.slice(0, 20)
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
);
|
|
1167
|
-
register(
|
|
1168
|
-
"jobs",
|
|
1169
|
-
"git-cockpit://jobs",
|
|
1170
|
-
{ title: "\u540E\u53F0\u4EFB\u52A1\u5217\u8868", description: "\u4E0E git_job_list \u540C\u6458\u8981", mimeType: MIME },
|
|
1171
|
-
async (uri) => jsonContents(uri.href, {
|
|
1172
|
-
jobs: runtime.jobs.list().map((j) => runtime.jobs.summary(j))
|
|
1173
|
-
})
|
|
1174
|
-
);
|
|
1175
|
-
register(
|
|
1176
|
-
"job",
|
|
1177
|
-
new ResourceTemplate("git-cockpit://jobs/{id}", {
|
|
1178
|
-
list: async () => ({
|
|
1179
|
-
resources: runtime.jobs.list().map((j) => ({
|
|
1180
|
-
uri: `git-cockpit://jobs/${j.id}`,
|
|
1181
|
-
name: j.title,
|
|
1182
|
-
description: `${j.kind} ${j.status}`,
|
|
1183
|
-
mimeType: MIME
|
|
1184
|
-
}))
|
|
1185
|
-
})
|
|
1186
|
-
}),
|
|
1187
|
-
{ title: "\u5355\u6761\u540E\u53F0\u4EFB\u52A1", description: "\u72B6\u6001 + \u65E5\u5FD7\u5C3E + result \u6458\u8981", mimeType: MIME },
|
|
1188
|
-
async (uri, variables) => {
|
|
1189
|
-
const id = String(variables.id ?? "");
|
|
1190
|
-
const job = runtime.jobs.get(id);
|
|
1191
|
-
if (!job) {
|
|
1192
|
-
return jsonContents(uri.href, { error: "\u4EFB\u52A1\u4E0D\u5B58\u5728", id });
|
|
1193
|
-
}
|
|
1194
|
-
const summary = runtime.jobs.summary(job);
|
|
1195
|
-
return jsonContents(uri.href, {
|
|
1196
|
-
...summary,
|
|
1197
|
-
logs: job.logs.slice(-20)
|
|
1198
|
-
});
|
|
1199
|
-
}
|
|
1200
|
-
);
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
// src/mcpServer.ts
|
|
1204
|
-
var MCP_SERVER_INFO = { name: "git-cockpit-mcp-server", version };
|
|
1205
|
-
function createMcpServer(runtime) {
|
|
1206
|
-
const server = new McpServer2(
|
|
1207
|
-
{ name: MCP_SERVER_INFO.name, version: MCP_SERVER_INFO.version },
|
|
1208
|
-
{
|
|
1209
|
-
capabilities: { tools: {}, prompts: {}, resources: {} },
|
|
1210
|
-
instructions: [
|
|
1211
|
-
"Git Cockpit MCP Server\uFF1A\u53EF\u89C6\u5316\u7684 Git \u64CD\u4F5C\u5DE5\u5177\u3002",
|
|
1212
|
-
"\u4F7F\u7528\u89C4\u5219\uFF1A",
|
|
1213
|
-
"1. \u5148\u8C03\u7528 git_status \u67E5\u770B\u5DE5\u4F5C\u533A\u72B6\u6001\uFF08\u542B operation=merge/rebase \u65F6\u8D70\u5DE5\u4F5C\u533A\u6536\u5C3E\uFF0C\u4E0D\u8981\u7528\u9884\u6F14\u5DE5\u5177\u5192\u5145\uFF09\uFF1B",
|
|
1214
|
-
"2. \u5199\u64CD\u4F5C\uFF08git_add/git_commit/git_fetch/git_push \u7B49\uFF09\u9ED8\u8BA4\u53EF\u6267\u884C\uFF0C\u4F46\u8BF7\u5148\u4F7F\u7528 dry_run=true \u9884\u89C8\u5F71\u54CD\u8303\u56F4\uFF1B",
|
|
1215
|
-
"3. \u9AD8\u98CE\u9669\u5DE5\u5177\uFF08git_reset_hard/git_clean/git_push_force/git_branch_delete_force/git_rebase\uFF09\u9ED8\u8BA4\u7981\u7528\uFF0C",
|
|
1216
|
-
" \u9700\u7BA1\u7406\u5458\u5728\u914D\u7F6E\u4E2D\u5F00\u542F\uFF1B\u6267\u884C\u65F6\u7CFB\u7EDF\u4F1A\u81EA\u52A8\u5907\u4EFD\u5F53\u524D\u72B6\u6001\uFF1B",
|
|
1217
|
-
"4. \u672A\u6307\u5B9A repoPath \u65F6\u4F7F\u7528\u6700\u8FD1\u6253\u5F00\u7684\u4ED3\u5E93\uFF1B",
|
|
1218
|
-
"5. \u5408\u5E76\u9884\u6F14\u7528 git_merge_preview / git_merge_rehearse\uFF08merge-tree\uFF0C\u4E0D\u6539\u5DE5\u4F5C\u533A\uFF09\uFF0C",
|
|
1219
|
-
" into=\u5408\u5165\u76EE\u6807/\u7EBF\u4E0A\uFF0Cfrom=\u6211\u7684\u5206\u652F\uFF1B\u7981\u6B62\u7528 git_merge \u505A\u9884\u6F14\u3002",
|
|
1220
|
-
" \u51B2\u7A81\u884C\u4F5C\u8005\u7528 git_merge_blame\uFF08\u6309\u6587\u4EF6\u3001\u53EA\u8BFB\uFF09\u3002",
|
|
1221
|
-
" \u591A\u5206\u652F\u626B\u63CF\u7528 git_merge_survey\uFF1B\u5EFA\u8BAE\u5408\u5165\u987A\u5E8F\u7528 git_merge_order\u3002",
|
|
1222
|
-
"6. \u843D\u76D8\u7528 git_apply_resolve\uFF08\u72EC\u7ACB worktree\uFF0C\u4E3B\u533A\u4E0D\u5207\u6362\uFF09\uFF1B\u51B2\u7A81\u65F6\u628A\u9009\u8FB9\u540E\u7684 files \u4E00\u5E76\u4F20\u5165\u3002",
|
|
1223
|
-
"7. \u5DE5\u4F5C\u533A\u5DF2\u7ECF\u51B2\u7A81\uFF1Agit_merge_continue / git_rebase_continue\uFF08\u53EF\u5E26 files\uFF09\u6216 abort\uFF1B\u4E0D\u662F apply_resolve\u3002",
|
|
1224
|
-
"8. \u66F4\u65B0\u8FDC\u7A0B\u8DDF\u8E2A\u5206\u652F\u7528 git_fetch\u3002\u4E24\u5206\u652F\u5206\u53C9\u5BF9\u6BD4\u7528 git_branch_graph \u5E76\u4F20 into/from\u3002",
|
|
1225
|
-
"9. \u5F00 PR/MR \u7528 git_mr_prepare / git_mr_create\u3002\u65B9\u5F0F\u4E0E Token \u5728\u8BBE\u7F6E MR \u914D\u7F6E\uFF08\u4E0D\u8FDB\u5DE5\u5177\u53C2\u6570\uFF09\uFF1A\u672C\u673A gh\xB7glab / Token / \u6D4F\u89C8\u5668\u9875\u3002\u627E\u4E0D\u5230 CLI \u65F6\u7ED3\u679C\u542B\u5B98\u65B9\u5B89\u88C5\u5730\u5740\u3002",
|
|
1226
|
-
"10. \u5927\u7ED3\u679C\u9ED8\u8BA4\u6458\u8981\uFF1Agit_diff / git_show / git_merge_rehearse \u8981\u6B63\u6587\u8BF7\u52A0 path \u6216 detail=true\u3002",
|
|
1227
|
-
"11. \u5DF2\u6253\u5F00\u4ED3\u5E93\u8109\u640F\u7528 git_repo_overview\u3002\u957F\u4EFB\u52A1\u7528 git_job_list / git_job_get / git_job_cancel\u3002",
|
|
1228
|
-
"12. \u63D0\u4EA4 / \u9884\u6F14\u843D\u76D8 / \u5DE5\u4F5C\u533A\u6536\u5C3E / \u5F00 PR \u7528 Prompt\uFF1Asafe_commit\u3001merge_preview_apply\u3001workspace_continue\u3001open_mr\uFF08\u6B63\u6587\u4E0E README\u300CAgent \u8BE5\u600E\u4E48\u7528\u300D\u76F8\u540C\uFF09\u3002",
|
|
1229
|
-
"13. \u53EA\u8BFB\u5217\u8868\u53EF\u8BFB Resource\uFF1Agit-cockpit://repos\u3001git-cockpit://repo/current\u3001git-cockpit://jobs\u3001git-cockpit://jobs/{id}\u3002"
|
|
1230
|
-
].join("\n")
|
|
1231
|
-
}
|
|
1232
|
-
);
|
|
1233
|
-
bindMcpTools(server, runtime, TOOL_DEFS);
|
|
1234
|
-
registerMcpPrompts(server);
|
|
1235
|
-
registerMcpResources(server, runtime);
|
|
1236
|
-
return server;
|
|
1237
|
-
}
|
|
1238
|
-
async function startMcpStdio(runtime) {
|
|
1239
|
-
const server = createMcpServer(runtime);
|
|
1240
|
-
const transport = new StdioServerTransport();
|
|
1241
|
-
await server.connect(transport);
|
|
1242
|
-
}
|
|
1243
|
-
var McpHttpHandler = class {
|
|
1244
|
-
constructor(runtime) {
|
|
1245
|
-
this.runtime = runtime;
|
|
1246
|
-
}
|
|
1247
|
-
runtime;
|
|
1248
|
-
sessions = /* @__PURE__ */ new Map();
|
|
1249
|
-
async handle(req, res, parsedBody) {
|
|
1250
|
-
const headerId = req.headers["mcp-session-id"];
|
|
1251
|
-
if (typeof headerId === "string" && headerId) {
|
|
1252
|
-
const session2 = this.sessions.get(headerId);
|
|
1253
|
-
if (!session2) {
|
|
1254
|
-
res.statusCode = 404;
|
|
1255
|
-
res.end("MCP session not found");
|
|
1256
|
-
return;
|
|
1257
|
-
}
|
|
1258
|
-
await session2.transport.handleRequest(req, res, parsedBody);
|
|
1259
|
-
return;
|
|
1260
|
-
}
|
|
1261
|
-
const transport = new StreamableHTTPServerTransport({
|
|
1262
|
-
sessionIdGenerator: () => randomUUID()
|
|
1263
|
-
});
|
|
1264
|
-
const server = createMcpServer(this.runtime);
|
|
1265
|
-
await server.connect(transport);
|
|
1266
|
-
const session = { id: "", server, transport };
|
|
1267
|
-
transport.onclose = () => {
|
|
1268
|
-
if (session.id) this.sessions.delete(session.id);
|
|
1269
|
-
void server.close().catch(() => void 0);
|
|
1270
|
-
};
|
|
1271
|
-
await transport.handleRequest(req, res, parsedBody);
|
|
1272
|
-
const sid = transport.sessionId;
|
|
1273
|
-
if (sid) {
|
|
1274
|
-
session.id = sid;
|
|
1275
|
-
this.sessions.set(sid, session);
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
dispose() {
|
|
1279
|
-
for (const session of this.sessions.values()) {
|
|
1280
|
-
session.transport.close().catch(() => void 0);
|
|
1281
|
-
}
|
|
1282
|
-
this.sessions.clear();
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
|
-
|
|
1286
|
-
export {
|
|
1287
|
-
collectRepoOverviews,
|
|
1288
|
-
version,
|
|
1289
|
-
formatResultForMcp,
|
|
1290
|
-
executeTool,
|
|
1291
|
-
TOOL_DEFS,
|
|
1292
|
-
TOOL_DEF_MAP,
|
|
1293
|
-
toolSummaries,
|
|
1294
|
-
MCP_PROMPTS,
|
|
1295
|
-
MCP_SERVER_INFO,
|
|
1296
|
-
createMcpServer,
|
|
1297
|
-
startMcpStdio,
|
|
1298
|
-
McpHttpHandler
|
|
1299
|
-
};
|
|
1300
|
-
//# sourceMappingURL=chunk-HUTQV5AS.js.map
|