@stellar_ai/mcp_fossil_scm 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +140 -113
- package/dist/capabilities.js +6 -7
- package/dist/cli.js +28 -24
- package/dist/config.js +7 -32
- package/dist/core/fossil.js +67 -79
- package/dist/core/gitignore.js +136 -0
- package/dist/core/sql.js +3 -2
- package/dist/index.js +8 -7
- package/dist/prompts.js +167 -0
- package/dist/server.js +6 -5
- package/dist/tools/admin.js +454 -86
- package/dist/tools/chat.js +22 -26
- package/dist/tools/common.js +14 -5
- package/dist/tools/forum.js +37 -29
- package/dist/tools/tickets.js +32 -11
- package/dist/tools/version-control.js +880 -105
- package/dist/tools/wiki.js +17 -18
- package/docs/README.md +31 -0
- package/docs/admin.md +663 -0
- package/docs/chat.md +152 -0
- package/docs/forum.md +146 -0
- package/docs/prompts.md +39 -0
- package/docs/tickets.md +179 -0
- package/docs/vcs.md +1089 -0
- package/docs/wiki.md +140 -0
- package/package.json +11 -6
- package/dist/capabilities.d.ts +0 -32
- package/dist/capabilities.js.map +0 -1
- package/dist/cli.d.ts +0 -27
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts +0 -27
- package/dist/config.js.map +0 -1
- package/dist/core/fossil.d.ts +0 -104
- package/dist/core/fossil.js.map +0 -1
- package/dist/core/sql.d.ts +0 -29
- package/dist/core/sql.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/server.d.ts +0 -13
- package/dist/server.js.map +0 -1
- package/dist/tools/admin.d.ts +0 -3
- package/dist/tools/admin.js.map +0 -1
- package/dist/tools/chat.d.ts +0 -10
- package/dist/tools/chat.js.map +0 -1
- package/dist/tools/common.d.ts +0 -9
- package/dist/tools/common.js.map +0 -1
- package/dist/tools/forum.d.ts +0 -3
- package/dist/tools/forum.js.map +0 -1
- package/dist/tools/tickets.d.ts +0 -8
- package/dist/tools/tickets.js.map +0 -1
- package/dist/tools/version-control.d.ts +0 -3
- package/dist/tools/version-control.js.map +0 -1
- package/dist/tools/wiki.d.ts +0 -3
- package/dist/tools/wiki.js.map +0 -1
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
1
3
|
import { z } from 'zod';
|
|
2
|
-
import { renderOutcome, renderSections, runFossil } from '../core/fossil.js';
|
|
3
|
-
import {
|
|
4
|
+
import { renderOutcome, renderSections, resolveWorkspace, runFossil, truncateOutput } from '../core/fossil.js';
|
|
5
|
+
import { convertGitignore, renderGlobFile } from '../core/gitignore.js';
|
|
6
|
+
import { runSql } from '../core/sql.js';
|
|
7
|
+
import { clean, workspaceParam, filesParam, flag, pushOption } from './common.js';
|
|
4
8
|
/** Version-control tools: status, diff, history, commit, branch and workspace state. */
|
|
9
|
+
/** Join glob patterns into one fossil GLOBLIST argument, quoting patterns that hold a comma. */
|
|
10
|
+
function globList(patterns) {
|
|
11
|
+
return patterns
|
|
12
|
+
.map((pattern) => (pattern.includes(',') ? `"${pattern}"` : pattern))
|
|
13
|
+
.join(',');
|
|
14
|
+
}
|
|
5
15
|
export function registerVersionControlTools(server) {
|
|
6
16
|
server.registerTool('fossil_status', {
|
|
7
17
|
title: 'Status',
|
|
@@ -11,21 +21,20 @@ export function registerVersionControlTools(server) {
|
|
|
11
21
|
dotfiles: flag('Include dot-files in the untracked (extra) list.'),
|
|
12
22
|
brief: flag('Use -b to print a single status keyword.'),
|
|
13
23
|
ignore: z.string().min(1).optional().describe('Comma-separated glob patterns of extra files to ignore.'),
|
|
14
|
-
|
|
24
|
+
workspace: workspaceParam,
|
|
15
25
|
}),
|
|
16
26
|
annotations: { readOnlyHint: true },
|
|
17
|
-
}, async ({ dotfiles, brief, ignore,
|
|
27
|
+
}, async ({ dotfiles, brief, ignore, workspace }) => {
|
|
18
28
|
const statusArgs = ['status'];
|
|
19
29
|
if (brief)
|
|
20
30
|
statusArgs.push('-b');
|
|
21
31
|
const extraArgs = ['extra'];
|
|
22
32
|
if (dotfiles)
|
|
23
33
|
extraArgs.push('--dotfiles');
|
|
24
|
-
|
|
25
|
-
extraArgs.push('--ignore', ignore.trim());
|
|
34
|
+
pushOption(extraArgs, '--ignore', ignore);
|
|
26
35
|
const [status, extra] = await Promise.all([
|
|
27
|
-
runFossil(statusArgs, {
|
|
28
|
-
runFossil(extraArgs, {
|
|
36
|
+
runFossil(statusArgs, { workspace }),
|
|
37
|
+
runFossil(extraArgs, { workspace }),
|
|
29
38
|
]);
|
|
30
39
|
return renderSections([
|
|
31
40
|
{ title: 'STATUS', outcome: status },
|
|
@@ -40,68 +49,109 @@ export function registerVersionControlTools(server) {
|
|
|
40
49
|
to_version: z.string().min(1).optional().describe('Ending check-in/revision (--to).'),
|
|
41
50
|
files: filesParam.describe('Optional list of files to diff.'),
|
|
42
51
|
branch: z.string().min(1).optional().describe('Diff across a branch (--branch).'),
|
|
52
|
+
checkin: z.string().min(1).optional().describe('Diff all changes introduced by this check-in (-ci).'),
|
|
43
53
|
brief: flag('Only list the changed file names (--brief).'),
|
|
54
|
+
stat: flag('Show only the number of added and deleted lines (--numstat).'),
|
|
55
|
+
context: z.number().int().min(0).max(100).optional().describe('Lines of context around each change (-c).'),
|
|
56
|
+
side_by_side: flag('Print a side-by-side diff (-y).'),
|
|
57
|
+
verbose: flag('Print the complete text of added or deleted files (-v).'),
|
|
58
|
+
undo: flag('Diff against the undo buffer (--undo).'),
|
|
44
59
|
ignore_whitespace: flag('Ignore whitespace-only changes (-w).'),
|
|
45
|
-
|
|
60
|
+
workspace: workspaceParam,
|
|
46
61
|
}),
|
|
47
62
|
annotations: { readOnlyHint: true },
|
|
48
|
-
}, async ({ from_version, to_version, files, branch, brief, ignore_whitespace,
|
|
63
|
+
}, async ({ from_version, to_version, files, branch, checkin, brief, stat, context: contextLines, side_by_side, verbose, undo, ignore_whitespace, workspace, }) => {
|
|
49
64
|
const args = ['diff'];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (clean(branch))
|
|
55
|
-
args.push('--branch', branch.trim());
|
|
65
|
+
pushOption(args, '--from', from_version);
|
|
66
|
+
pushOption(args, '--to', to_version);
|
|
67
|
+
pushOption(args, '--branch', branch);
|
|
68
|
+
pushOption(args, '-ci', checkin);
|
|
56
69
|
if (brief)
|
|
57
70
|
args.push('--brief');
|
|
71
|
+
if (stat)
|
|
72
|
+
args.push('--numstat');
|
|
73
|
+
if (contextLines !== undefined)
|
|
74
|
+
args.push('-c', String(contextLines));
|
|
75
|
+
if (side_by_side)
|
|
76
|
+
args.push('-y');
|
|
77
|
+
if (verbose)
|
|
78
|
+
args.push('-v');
|
|
79
|
+
if (undo)
|
|
80
|
+
args.push('--undo');
|
|
58
81
|
if (ignore_whitespace)
|
|
59
82
|
args.push('-w');
|
|
60
83
|
if (files?.length)
|
|
61
84
|
args.push(...files);
|
|
62
|
-
return renderOutcome(await runFossil(args, {
|
|
85
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No differences found.' });
|
|
63
86
|
});
|
|
64
87
|
server.registerTool('fossil_cat', {
|
|
65
88
|
title: 'Cat file revision',
|
|
66
|
-
description: 'Print the content of a file at a given revision
|
|
89
|
+
description: 'Print the content of a file at a given revision.',
|
|
67
90
|
inputSchema: z.object({
|
|
68
91
|
file: z.string().min(1).describe('File path/name inside the repository.'),
|
|
69
92
|
revision: z.string().min(1).optional().describe('Check-in or revision (-r). Defaults to the checked-out version.'),
|
|
70
|
-
|
|
93
|
+
workspace: workspaceParam,
|
|
71
94
|
}),
|
|
72
95
|
annotations: { readOnlyHint: true },
|
|
73
|
-
}, async ({ file, revision,
|
|
96
|
+
}, async ({ file, revision, workspace }) => {
|
|
74
97
|
const args = ['cat', file];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return renderOutcome(await runFossil(args, { cwd }));
|
|
98
|
+
pushOption(args, '-r', revision);
|
|
99
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
78
100
|
});
|
|
79
101
|
server.registerTool('fossil_finfo', {
|
|
80
102
|
title: 'File history',
|
|
81
|
-
description: 'Show the
|
|
103
|
+
description: 'Show the change history of one file, or switch to the artifact facts, status line or file content view.',
|
|
82
104
|
inputSchema: z.object({
|
|
83
105
|
file: z.string().min(1).describe('File to inspect.'),
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
mode: z
|
|
107
|
+
.enum(['log', 'id', 'status', 'print'])
|
|
108
|
+
.default('log')
|
|
109
|
+
.describe('log: revisions with comments; id: artifact facts; status: one-line status; print: file content.'),
|
|
110
|
+
brief: flag('One line per revision, in log mode (-b).'),
|
|
111
|
+
limit: z.number().int().min(1).max(1000).default(20).describe('Number of revisions to show, in log mode (-n).'),
|
|
112
|
+
offset: z.number().int().min(0).optional().describe('Revisions to skip, in log mode (--offset).'),
|
|
113
|
+
revision: z.string().min(1).optional().describe('Revision the id and print modes describe (-r).'),
|
|
114
|
+
verbose: flag('In id mode, show every check-in that uses the file (-v).'),
|
|
115
|
+
workspace: workspaceParam,
|
|
86
116
|
}),
|
|
87
117
|
annotations: { readOnlyHint: true },
|
|
88
|
-
}, async ({ file,
|
|
118
|
+
}, async ({ file, mode, brief, limit, offset, revision, verbose, workspace }) => {
|
|
119
|
+
const args = ['finfo'];
|
|
120
|
+
if (mode === 'id')
|
|
121
|
+
args.push('-i');
|
|
122
|
+
else if (mode === 'status')
|
|
123
|
+
args.push('-s');
|
|
124
|
+
else if (mode === 'print')
|
|
125
|
+
args.push('-p');
|
|
126
|
+
if (mode === 'log') {
|
|
127
|
+
if (brief)
|
|
128
|
+
args.push('-b');
|
|
129
|
+
if (limit !== undefined)
|
|
130
|
+
args.push('-n', String(limit));
|
|
131
|
+
if (offset !== undefined)
|
|
132
|
+
args.push('--offset', String(offset));
|
|
133
|
+
}
|
|
134
|
+
pushOption(args, '-r', revision);
|
|
135
|
+
if (verbose)
|
|
136
|
+
args.push('-v');
|
|
137
|
+
args.push(file);
|
|
138
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
139
|
+
});
|
|
89
140
|
server.registerTool('fossil_revert', {
|
|
90
141
|
title: 'Revert changes',
|
|
91
142
|
description: 'Revert uncommitted local changes. Destructive: the workspace is restored from the repository.',
|
|
92
143
|
inputSchema: z.object({
|
|
93
144
|
files: filesParam.describe('Files to revert. Omit to revert the whole check-out.'),
|
|
94
145
|
revision: z.string().min(1).optional().describe('Revision to revert to (-r).'),
|
|
95
|
-
|
|
146
|
+
workspace: workspaceParam,
|
|
96
147
|
}),
|
|
97
148
|
annotations: { destructiveHint: true },
|
|
98
|
-
}, async ({ files, revision,
|
|
149
|
+
}, async ({ files, revision, workspace }) => {
|
|
99
150
|
const args = ['revert'];
|
|
100
|
-
|
|
101
|
-
args.push('-r', revision.trim());
|
|
151
|
+
pushOption(args, '-r', revision);
|
|
102
152
|
if (files?.length)
|
|
103
153
|
args.push(...files);
|
|
104
|
-
return renderOutcome(await runFossil(args, {
|
|
154
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
105
155
|
});
|
|
106
156
|
server.registerTool('fossil_stash', {
|
|
107
157
|
title: 'Stash',
|
|
@@ -113,17 +163,19 @@ export function registerVersionControlTools(server) {
|
|
|
113
163
|
.describe('Stash sub-command.'),
|
|
114
164
|
comment: z.string().optional().describe('Comment used by save/snapshot (-m).'),
|
|
115
165
|
stash_id: z.string().min(1).optional().describe('Stash id used by pop/apply/drop/diff.'),
|
|
116
|
-
|
|
166
|
+
workspace: workspaceParam,
|
|
117
167
|
}),
|
|
118
|
-
}, async ({ action, comment, stash_id,
|
|
168
|
+
}, async ({ action, comment, stash_id, workspace }) => {
|
|
119
169
|
const args = ['stash', action ?? 'ls'];
|
|
120
170
|
if ((action === 'save' || action === 'snapshot') && comment !== undefined) {
|
|
121
171
|
args.push('-m', comment);
|
|
122
172
|
}
|
|
123
|
-
else
|
|
124
|
-
|
|
173
|
+
else {
|
|
174
|
+
const stashId = clean(stash_id);
|
|
175
|
+
if (stashId)
|
|
176
|
+
args.push(stashId);
|
|
125
177
|
}
|
|
126
|
-
return renderOutcome(await runFossil(args, {
|
|
178
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No stashed changes.' });
|
|
127
179
|
});
|
|
128
180
|
server.registerTool('fossil_tag', {
|
|
129
181
|
title: 'Tags',
|
|
@@ -136,10 +188,10 @@ export function registerVersionControlTools(server) {
|
|
|
136
188
|
.min(1)
|
|
137
189
|
.optional()
|
|
138
190
|
.describe('Target check-in (required for add; defaults to tip for cancel).'),
|
|
139
|
-
|
|
191
|
+
workspace: workspaceParam,
|
|
140
192
|
}),
|
|
141
193
|
annotations: { idempotentHint: true },
|
|
142
|
-
}, async ({ action, tag_name, checkin,
|
|
194
|
+
}, async ({ action, tag_name, checkin, workspace }) => {
|
|
143
195
|
const name = clean(tag_name);
|
|
144
196
|
const target = clean(checkin);
|
|
145
197
|
if (action === 'add' && (!name || !target)) {
|
|
@@ -149,12 +201,16 @@ export function registerVersionControlTools(server) {
|
|
|
149
201
|
return { content: [{ type: 'text', text: "ERROR: 'tag_name' is required for action 'cancel'." }], isError: true };
|
|
150
202
|
}
|
|
151
203
|
const args = ['tag', action ?? 'ls'];
|
|
152
|
-
if (action === 'add')
|
|
153
|
-
args.push(name, target);
|
|
154
204
|
// `fossil tag cancel` always needs an artifact id; 'tip' is the sane default.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
205
|
+
if (action === 'add') {
|
|
206
|
+
if (name && target)
|
|
207
|
+
args.push(name, target);
|
|
208
|
+
}
|
|
209
|
+
else if (action === 'cancel') {
|
|
210
|
+
if (name)
|
|
211
|
+
args.push(name, target ?? 'tip');
|
|
212
|
+
}
|
|
213
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No tags.' });
|
|
158
214
|
});
|
|
159
215
|
server.registerTool('fossil_addremove', {
|
|
160
216
|
title: 'Add/remove scan',
|
|
@@ -164,67 +220,97 @@ export function registerVersionControlTools(server) {
|
|
|
164
220
|
ignore: z.string().min(1).optional().describe('Comma-separated glob patterns to ignore (--ignore).'),
|
|
165
221
|
clean: z.string().min(1).optional().describe('Comma-separated glob patterns of clean files to ignore (--clean).'),
|
|
166
222
|
reset: flag('Reset the ADDED/DELETED state of the check-out instead (--reset).'),
|
|
167
|
-
|
|
223
|
+
dry_run: flag('Show what would be staged without changing anything (-n/--dry-run).'),
|
|
224
|
+
workspace: workspaceParam,
|
|
168
225
|
}),
|
|
169
|
-
}, async ({ dotfiles, ignore, clean: cleanGlob, reset,
|
|
226
|
+
}, async ({ dotfiles, ignore, clean: cleanGlob, reset, dry_run, workspace }) => {
|
|
170
227
|
const args = ['addremove'];
|
|
228
|
+
if (dry_run)
|
|
229
|
+
args.push('-n');
|
|
171
230
|
if (reset) {
|
|
172
231
|
args.push('--reset');
|
|
173
232
|
}
|
|
174
233
|
else {
|
|
175
234
|
if (dotfiles)
|
|
176
235
|
args.push('--dotfiles');
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (clean(cleanGlob))
|
|
180
|
-
args.push('--clean', cleanGlob.trim());
|
|
236
|
+
pushOption(args, '--ignore', ignore);
|
|
237
|
+
pushOption(args, '--clean', cleanGlob);
|
|
181
238
|
}
|
|
182
|
-
return renderOutcome(await runFossil(args, {
|
|
239
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
183
240
|
});
|
|
184
241
|
server.registerTool('fossil_commit', {
|
|
185
242
|
title: 'Commit',
|
|
186
243
|
description: 'Create a check-in from the staged/current changes. Answers the interactive "commit anyhow" prompt with ' +
|
|
187
|
-
"'a' (all) automatically
|
|
244
|
+
"'a' (all) automatically.",
|
|
188
245
|
inputSchema: z.object({
|
|
189
246
|
message: z.string().min(1).describe('Commit message.'),
|
|
190
247
|
files: filesParam.describe('Files to commit. Omit to commit everything that changed.'),
|
|
191
248
|
branch: z.string().min(1).optional().describe('Place the new check-in on this branch (--branch).'),
|
|
192
|
-
no_warnings: flag('Omit content warnings (--no-warnings)
|
|
249
|
+
no_warnings: flag('Omit content warnings (--no-warnings).'),
|
|
193
250
|
allow_empty: flag('Allow a check-in with no file changes (--allow-empty).'),
|
|
194
251
|
user_override: z.string().min(1).optional().describe('Record this login as the author (--user-override).'),
|
|
195
|
-
|
|
252
|
+
tags: z.array(z.string().min(1)).optional().describe('Tags to attach to the new check-in (--tag).'),
|
|
253
|
+
close: flag('Close the branch being committed (--close).'),
|
|
254
|
+
bgcolor: z.string().min(1).optional().describe('Background colour for this one check-in (--bgcolor).'),
|
|
255
|
+
mtime: z.string().min(1).optional().describe('Check-in timestamp, e.g. "2026-11-17 12:00:00" (--mtime).'),
|
|
256
|
+
workspace: workspaceParam,
|
|
196
257
|
}),
|
|
197
|
-
}, async ({ message, files, branch, no_warnings, allow_empty, user_override,
|
|
258
|
+
}, async ({ message, files, branch, no_warnings, allow_empty, user_override, tags, close, bgcolor, mtime, workspace }) => {
|
|
198
259
|
const args = ['commit', '-m', message];
|
|
199
|
-
|
|
200
|
-
args.push('--branch', branch.trim());
|
|
260
|
+
pushOption(args, '--branch', branch);
|
|
201
261
|
if (no_warnings)
|
|
202
262
|
args.push('--no-warnings');
|
|
203
263
|
if (allow_empty)
|
|
204
264
|
args.push('--allow-empty');
|
|
205
|
-
if (
|
|
206
|
-
args.push('--
|
|
265
|
+
if (close)
|
|
266
|
+
args.push('--close');
|
|
267
|
+
pushOption(args, '--bgcolor', bgcolor);
|
|
268
|
+
pushOption(args, '--mtime', mtime);
|
|
269
|
+
for (const tag of tags ?? [])
|
|
270
|
+
args.push('--tag', tag);
|
|
271
|
+
pushOption(args, '--user-override', user_override);
|
|
207
272
|
if (files?.length)
|
|
208
273
|
args.push(...files);
|
|
209
|
-
return renderOutcome(await runFossil(args, {
|
|
274
|
+
return renderOutcome(await runFossil(args, { workspace, input: 'a\n' }));
|
|
210
275
|
});
|
|
211
276
|
server.registerTool('fossil_add', {
|
|
212
277
|
title: 'Add files',
|
|
213
278
|
description: 'Start tracking one or more files or directories.',
|
|
214
279
|
inputSchema: z.object({
|
|
215
|
-
files: z
|
|
280
|
+
files: z
|
|
281
|
+
.array(z.string().min(1))
|
|
282
|
+
.optional()
|
|
283
|
+
.describe('Files or directories to add. Required unless reset is true.'),
|
|
216
284
|
dotfiles: flag('Recurse into dot-files/directories (--dotfiles).'),
|
|
217
285
|
force: z.boolean().default(true).describe('Add even when a file matches ignore-glob, without prompting (-f).'),
|
|
218
|
-
|
|
286
|
+
reset: flag('Reset the ADDED state instead of adding files (--reset).'),
|
|
287
|
+
ignore: z.string().min(1).optional().describe('Ignore unmanaged files matching these globs (--ignore).'),
|
|
288
|
+
verbose: flag('Report each file while resetting, with reset: true (-v).'),
|
|
289
|
+
workspace: workspaceParam,
|
|
219
290
|
}),
|
|
220
|
-
}, async ({ files, dotfiles, force,
|
|
291
|
+
}, async ({ files, dotfiles, force, reset, ignore, verbose, workspace }) => {
|
|
221
292
|
const args = ['add'];
|
|
293
|
+
if (reset) {
|
|
294
|
+
args.push('--reset');
|
|
295
|
+
if (verbose)
|
|
296
|
+
args.push('-v');
|
|
297
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
298
|
+
}
|
|
299
|
+
if (!files?.length) {
|
|
300
|
+
return {
|
|
301
|
+
isError: true,
|
|
302
|
+
content: [
|
|
303
|
+
{ type: 'text', text: 'ERROR: `files` is required unless `reset` is true.' },
|
|
304
|
+
],
|
|
305
|
+
};
|
|
306
|
+
}
|
|
222
307
|
if (dotfiles)
|
|
223
308
|
args.push('--dotfiles');
|
|
224
309
|
if (force !== false)
|
|
225
310
|
args.push('-f');
|
|
311
|
+
pushOption(args, '--ignore', ignore);
|
|
226
312
|
args.push(...files);
|
|
227
|
-
return renderOutcome(await runFossil(args, {
|
|
313
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
228
314
|
});
|
|
229
315
|
server.registerTool('fossil_rm', {
|
|
230
316
|
title: 'Remove files',
|
|
@@ -233,17 +319,26 @@ export function registerVersionControlTools(server) {
|
|
|
233
319
|
files: z.array(z.string().min(1)).min(1).describe('Files or directories to remove.'),
|
|
234
320
|
force: flag('Also delete from disk (--hard).'),
|
|
235
321
|
keep: flag('Keep files on disk (--soft).'),
|
|
236
|
-
|
|
322
|
+
dry_run: flag('Show what would be removed without changing anything (-n).'),
|
|
323
|
+
reset: flag('Reset the DELETED state instead of removing files (--reset).'),
|
|
324
|
+
verbose: flag('Report each file when resetting (--verbose).'),
|
|
325
|
+
workspace: workspaceParam,
|
|
237
326
|
}),
|
|
238
327
|
annotations: { destructiveHint: true },
|
|
239
|
-
}, async ({ files, force, keep,
|
|
328
|
+
}, async ({ files, force, keep, dry_run, reset, verbose, workspace }) => {
|
|
240
329
|
const args = ['rm'];
|
|
241
330
|
if (force)
|
|
242
331
|
args.push('--hard');
|
|
243
332
|
if (keep)
|
|
244
333
|
args.push('--soft');
|
|
334
|
+
if (reset)
|
|
335
|
+
args.push('--reset');
|
|
336
|
+
if (verbose)
|
|
337
|
+
args.push('--verbose');
|
|
338
|
+
if (dry_run)
|
|
339
|
+
args.push('-n');
|
|
245
340
|
args.push(...files);
|
|
246
|
-
return renderOutcome(await runFossil(args, {
|
|
341
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
247
342
|
});
|
|
248
343
|
server.registerTool('fossil_mv', {
|
|
249
344
|
title: 'Move/rename',
|
|
@@ -256,14 +351,14 @@ export function registerVersionControlTools(server) {
|
|
|
256
351
|
.boolean()
|
|
257
352
|
.optional()
|
|
258
353
|
.describe('Explicitly set the case-sensitive behaviour (--case-sensitive 1/0).'),
|
|
259
|
-
|
|
354
|
+
workspace: workspaceParam,
|
|
260
355
|
}),
|
|
261
|
-
}, async ({ old_name, new_name, hard, case_sensitive,
|
|
356
|
+
}, async ({ old_name, new_name, hard, case_sensitive, workspace }) => {
|
|
262
357
|
const args = ['mv', hard !== false ? '--hard' : '--soft'];
|
|
263
358
|
if (case_sensitive !== undefined)
|
|
264
359
|
args.push('--case-sensitive', case_sensitive ? '1' : '0');
|
|
265
360
|
args.push(old_name, new_name);
|
|
266
|
-
return renderOutcome(await runFossil(args, {
|
|
361
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
267
362
|
});
|
|
268
363
|
server.registerTool('fossil_extras', {
|
|
269
364
|
title: 'List extras',
|
|
@@ -271,16 +366,30 @@ export function registerVersionControlTools(server) {
|
|
|
271
366
|
inputSchema: z.object({
|
|
272
367
|
dotfiles: flag('Include dot-files (--dotfiles).'),
|
|
273
368
|
ignore: z.string().min(1).optional().describe('Comma-separated glob patterns to ignore.'),
|
|
274
|
-
|
|
369
|
+
abs_paths: flag('Print absolute path names (--abs-paths).'),
|
|
370
|
+
rel_paths: flag('Print paths relative to the current directory (--rel-paths).'),
|
|
371
|
+
header: flag('Prefix the list with the repository name (--header).'),
|
|
372
|
+
case_sensitive: z
|
|
373
|
+
.boolean()
|
|
374
|
+
.optional()
|
|
375
|
+
.describe('Override the case-sensitive setting (--case-sensitive 1|0).'),
|
|
376
|
+
workspace: workspaceParam,
|
|
275
377
|
}),
|
|
276
378
|
annotations: { readOnlyHint: true },
|
|
277
|
-
}, async ({ dotfiles, ignore,
|
|
379
|
+
}, async ({ dotfiles, ignore, abs_paths, rel_paths, header, case_sensitive, workspace }) => {
|
|
278
380
|
const args = ['extras'];
|
|
279
381
|
if (dotfiles)
|
|
280
382
|
args.push('--dotfiles');
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
383
|
+
pushOption(args, '--ignore', ignore);
|
|
384
|
+
if (abs_paths)
|
|
385
|
+
args.push('--abs-paths');
|
|
386
|
+
if (rel_paths)
|
|
387
|
+
args.push('--rel-paths');
|
|
388
|
+
if (header)
|
|
389
|
+
args.push('--header');
|
|
390
|
+
if (case_sensitive !== undefined)
|
|
391
|
+
args.push('--case-sensitive', case_sensitive ? '1' : '0');
|
|
392
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No untracked files.' });
|
|
284
393
|
});
|
|
285
394
|
server.registerTool('fossil_clean', {
|
|
286
395
|
title: 'Clean untracked files',
|
|
@@ -289,12 +398,12 @@ export function registerVersionControlTools(server) {
|
|
|
289
398
|
inputSchema: z.object({
|
|
290
399
|
all_files: flag('Force deletion without confirmation (-f).'),
|
|
291
400
|
dry_run: flag('Only list what would be deleted (-n).'),
|
|
292
|
-
|
|
401
|
+
workspace: workspaceParam,
|
|
293
402
|
}),
|
|
294
403
|
annotations: { destructiveHint: true },
|
|
295
|
-
}, async ({ all_files, dry_run,
|
|
404
|
+
}, async ({ all_files, dry_run, workspace }) => {
|
|
296
405
|
const args = ['clean', dry_run ? '-n' : all_files ? '-f' : '--no-prompt'];
|
|
297
|
-
return renderOutcome(await runFossil(args, {
|
|
406
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'Nothing to clean.' });
|
|
298
407
|
});
|
|
299
408
|
server.registerTool('fossil_timeline', {
|
|
300
409
|
title: 'Timeline',
|
|
@@ -306,29 +415,51 @@ export function registerVersionControlTools(server) {
|
|
|
306
415
|
.string()
|
|
307
416
|
.min(1)
|
|
308
417
|
.optional()
|
|
309
|
-
.describe("Event type
|
|
310
|
-
|
|
418
|
+
.describe("Event type (-t), e.g. 'ci' for check-ins, 't' for tickets, 'w' for wiki."),
|
|
419
|
+
branch: z.string().min(1).optional().describe('Only events on this branch (-b).'),
|
|
420
|
+
current_branch: flag('Only events on the current branch (-c).'),
|
|
421
|
+
when: z
|
|
422
|
+
.enum(['before', 'after', 'descendants', 'children', 'ancestors', 'parents'])
|
|
423
|
+
.optional()
|
|
424
|
+
.describe('Timeline direction relative to `checkin`.'),
|
|
425
|
+
checkin: z.string().min(1).optional().describe('Check-in hash or date the `when` keyword applies to.'),
|
|
426
|
+
format: z
|
|
427
|
+
.string()
|
|
428
|
+
.min(1)
|
|
429
|
+
.optional()
|
|
430
|
+
.describe("Entry format (-F), e.g. 'oneline' or '%h %d %c'."),
|
|
431
|
+
verbose: flag('List the files changed by each check-in (-v).'),
|
|
432
|
+
workspace: workspaceParam,
|
|
311
433
|
}),
|
|
312
434
|
annotations: { readOnlyHint: true },
|
|
313
|
-
}, async ({ limit, path: targetPath, type_filter,
|
|
435
|
+
}, async ({ limit, path: targetPath, type_filter, branch, current_branch, when, checkin, format, verbose, workspace }) => {
|
|
314
436
|
const args = ['timeline', '-n', String(limit ?? 20)];
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
437
|
+
pushOption(args, '-p', targetPath);
|
|
438
|
+
pushOption(args, '-t', type_filter);
|
|
439
|
+
pushOption(args, '-b', branch);
|
|
440
|
+
if (current_branch)
|
|
441
|
+
args.push('-c');
|
|
442
|
+
if (when)
|
|
443
|
+
args.push(when);
|
|
444
|
+
if (checkin)
|
|
445
|
+
args.push(checkin);
|
|
446
|
+
pushOption(args, '-F', format);
|
|
447
|
+
if (verbose)
|
|
448
|
+
args.push('-v');
|
|
449
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No events.' });
|
|
320
450
|
});
|
|
321
451
|
server.registerTool('fossil_info', {
|
|
322
452
|
title: 'Info',
|
|
323
453
|
description: 'Repository/check-out metadata, or details about a specific file, check-in or branch.',
|
|
324
454
|
inputSchema: z.object({
|
|
325
455
|
target: z.string().optional().describe('File name, check-in hash or branch. Omit for general repository info.'),
|
|
326
|
-
|
|
456
|
+
workspace: workspaceParam,
|
|
327
457
|
}),
|
|
328
458
|
annotations: { readOnlyHint: true },
|
|
329
|
-
}, async ({ target,
|
|
330
|
-
const
|
|
331
|
-
|
|
459
|
+
}, async ({ target, workspace }) => {
|
|
460
|
+
const targetValue = clean(target);
|
|
461
|
+
const args = targetValue ? ['info', targetValue] : ['info'];
|
|
462
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
332
463
|
});
|
|
333
464
|
server.registerTool('fossil_branch', {
|
|
334
465
|
title: 'Branches',
|
|
@@ -341,18 +472,18 @@ export function registerVersionControlTools(server) {
|
|
|
341
472
|
.min(1)
|
|
342
473
|
.optional()
|
|
343
474
|
.describe("Starting point for the new branch (check-in or branch). Defaults to 'current'."),
|
|
344
|
-
|
|
475
|
+
workspace: workspaceParam,
|
|
345
476
|
}),
|
|
346
|
-
}, async ({ action, branch_name, basis,
|
|
477
|
+
}, async ({ action, branch_name, basis, workspace }) => {
|
|
347
478
|
const name = clean(branch_name);
|
|
348
479
|
if (action === 'new' && !name) {
|
|
349
480
|
return { content: [{ type: 'text', text: "ERROR: 'branch_name' is required for action 'new'." }], isError: true };
|
|
350
481
|
}
|
|
351
482
|
const args = ['branch', action ?? 'ls'];
|
|
352
483
|
// Fossil requires an explicit basis, 'current' means the checked-out branch.
|
|
353
|
-
if (action === 'new')
|
|
484
|
+
if (action === 'new' && name)
|
|
354
485
|
args.push(name, clean(basis) ?? 'current');
|
|
355
|
-
return renderOutcome(await runFossil(args, {
|
|
486
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
356
487
|
});
|
|
357
488
|
server.registerTool('fossil_merge', {
|
|
358
489
|
title: 'Merge',
|
|
@@ -360,17 +491,36 @@ export function registerVersionControlTools(server) {
|
|
|
360
491
|
inputSchema: z.object({
|
|
361
492
|
branch_or_version: z.string().min(1).describe('Branch name or check-in hash to merge.'),
|
|
362
493
|
integrate: flag('Close the source branch after merging (--integrate).'),
|
|
494
|
+
cherrypick: flag('Merge only the changes of this single check-in (--cherrypick).'),
|
|
495
|
+
backout: flag('Remove the changes of this single check-in (--backout).'),
|
|
363
496
|
dry_run: flag('Simulate the merge without touching files (-n).'),
|
|
364
|
-
|
|
497
|
+
baseline: z.string().min(1).optional().describe('Use this version as the merge pivot (--baseline).'),
|
|
498
|
+
binary: z.string().min(1).optional().describe('Skip parallel changes of files matching this glob (--binary).'),
|
|
499
|
+
force: flag('Force the merge even if it would be a no-op (-f).'),
|
|
500
|
+
keep_merge_files: flag('Keep the temporary merge files on conflict (-K).'),
|
|
501
|
+
verbose: flag('Report each file as it is merged (-v).'),
|
|
502
|
+
workspace: workspaceParam,
|
|
365
503
|
}),
|
|
366
|
-
}, async ({ branch_or_version, integrate, dry_run,
|
|
504
|
+
}, async ({ branch_or_version, integrate, cherrypick, backout, dry_run, baseline, binary, force, keep_merge_files, verbose, workspace, }) => {
|
|
367
505
|
const args = ['merge'];
|
|
368
506
|
if (dry_run)
|
|
369
507
|
args.push('-n');
|
|
370
508
|
if (integrate)
|
|
371
509
|
args.push('--integrate');
|
|
510
|
+
if (cherrypick)
|
|
511
|
+
args.push('--cherrypick');
|
|
512
|
+
if (backout)
|
|
513
|
+
args.push('--backout');
|
|
514
|
+
pushOption(args, '--baseline', baseline);
|
|
515
|
+
pushOption(args, '--binary', binary);
|
|
516
|
+
if (force)
|
|
517
|
+
args.push('-f');
|
|
518
|
+
if (keep_merge_files)
|
|
519
|
+
args.push('-K');
|
|
520
|
+
if (verbose)
|
|
521
|
+
args.push('-v');
|
|
372
522
|
args.push(branch_or_version);
|
|
373
|
-
return renderOutcome(await runFossil(args, {
|
|
523
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
374
524
|
});
|
|
375
525
|
server.registerTool('fossil_update', {
|
|
376
526
|
title: 'Update check-out',
|
|
@@ -378,23 +528,648 @@ export function registerVersionControlTools(server) {
|
|
|
378
528
|
'Overrides local workspace state - obtain user confirmation first.',
|
|
379
529
|
inputSchema: z.object({
|
|
380
530
|
target: z.string().optional().describe('Version or branch to update to. Omit to update the current branch.'),
|
|
381
|
-
|
|
531
|
+
latest: flag('Update to the latest version instead of a named one (--latest).'),
|
|
532
|
+
dry_run: flag('Show what would change without touching the workspace (-n).'),
|
|
533
|
+
no_sync: flag('Skip the automatic sync before updating (--nosync).'),
|
|
534
|
+
set_mtime: flag('Stamp every file with its last-check-in time (--setmtime).'),
|
|
535
|
+
keep_merge_files: flag('Keep the temporary merge files (-K).'),
|
|
536
|
+
verbose: flag('Report the state of every file (-v).'),
|
|
537
|
+
workspace: workspaceParam,
|
|
382
538
|
}),
|
|
383
539
|
annotations: { destructiveHint: true },
|
|
384
|
-
}, async ({ target,
|
|
540
|
+
}, async ({ target, latest, dry_run, no_sync, set_mtime, keep_merge_files, verbose, workspace }) => {
|
|
385
541
|
const args = ['update'];
|
|
386
|
-
if (
|
|
387
|
-
args.push(
|
|
388
|
-
|
|
542
|
+
if (latest)
|
|
543
|
+
args.push('--latest');
|
|
544
|
+
if (dry_run)
|
|
545
|
+
args.push('-n');
|
|
546
|
+
if (no_sync)
|
|
547
|
+
args.push('--nosync');
|
|
548
|
+
if (set_mtime)
|
|
549
|
+
args.push('--setmtime');
|
|
550
|
+
if (keep_merge_files)
|
|
551
|
+
args.push('-K');
|
|
552
|
+
if (verbose)
|
|
553
|
+
args.push('-v');
|
|
554
|
+
const targetValue = clean(target);
|
|
555
|
+
if (targetValue)
|
|
556
|
+
args.push(targetValue);
|
|
557
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
389
558
|
});
|
|
390
559
|
server.registerTool('fossil_undo', {
|
|
391
560
|
title: 'Undo',
|
|
392
561
|
description: 'WARNING: destructive. Undo the last update/revert/merge in the workspace. Preview with dry_run (-n) first.',
|
|
393
562
|
inputSchema: z.object({
|
|
394
563
|
dry_run: flag('Simulate the undo (-n) without modifying files.'),
|
|
395
|
-
|
|
564
|
+
workspace: workspaceParam,
|
|
565
|
+
}),
|
|
566
|
+
annotations: { destructiveHint: true },
|
|
567
|
+
}, async ({ dry_run, workspace }) => renderOutcome(await runFossil(dry_run ? ['undo', '-n'] : ['undo'], { workspace })));
|
|
568
|
+
server.registerTool('fossil_changes', {
|
|
569
|
+
title: 'Changes',
|
|
570
|
+
description: 'Report the change status of files in the check-out, optionally restricted to one or more change types ' +
|
|
571
|
+
'(edited, updated, added, deleted, renamed, conflict, meta) and/or to explicit paths.',
|
|
572
|
+
inputSchema: z.object({
|
|
573
|
+
files: filesParam,
|
|
574
|
+
edited: flag('Only edited, merged and conflicted files (--edited).'),
|
|
575
|
+
updated: flag('Only files updated by merge/integrate (--updated).'),
|
|
576
|
+
added: flag('Only added files (--added).'),
|
|
577
|
+
deleted: flag('Only deleted files (--deleted).'),
|
|
578
|
+
renamed: flag('Only renamed files (--renamed).'),
|
|
579
|
+
conflict: flag('Only files with merge conflicts (--conflict).'),
|
|
580
|
+
meta: flag('Only files with metadata changes (--meta).'),
|
|
581
|
+
classify: flag('Start each line with the change type (--classify).'),
|
|
582
|
+
no_merge: flag('Hide merge contributors (--no-merge).'),
|
|
583
|
+
dotfiles: flag('Include unmanaged files whose name starts with a dot (--dotfiles).'),
|
|
584
|
+
absolute_paths: flag('Print absolute pathnames (--abs-paths).'),
|
|
585
|
+
workspace: workspaceParam,
|
|
586
|
+
}),
|
|
587
|
+
annotations: { readOnlyHint: true },
|
|
588
|
+
}, async ({ files, edited, updated, added, deleted, renamed, conflict, meta, classify, no_merge, dotfiles, absolute_paths, workspace, }) => {
|
|
589
|
+
const args = ['changes'];
|
|
590
|
+
const filters = [
|
|
591
|
+
[edited, '--edited'],
|
|
592
|
+
[updated, '--updated'],
|
|
593
|
+
[added, '--added'],
|
|
594
|
+
[deleted, '--deleted'],
|
|
595
|
+
[renamed, '--renamed'],
|
|
596
|
+
[conflict, '--conflict'],
|
|
597
|
+
[meta, '--meta'],
|
|
598
|
+
];
|
|
599
|
+
for (const [enabled, option] of filters)
|
|
600
|
+
if (enabled)
|
|
601
|
+
args.push(option);
|
|
602
|
+
if (classify)
|
|
603
|
+
args.push('--classify');
|
|
604
|
+
if (no_merge)
|
|
605
|
+
args.push('--no-merge');
|
|
606
|
+
if (dotfiles)
|
|
607
|
+
args.push('--dotfiles');
|
|
608
|
+
if (absolute_paths)
|
|
609
|
+
args.push('--abs-paths');
|
|
610
|
+
if (files?.length)
|
|
611
|
+
args.push(...files);
|
|
612
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No changes.' });
|
|
613
|
+
});
|
|
614
|
+
server.registerTool('fossil_annotate', {
|
|
615
|
+
title: 'Annotate',
|
|
616
|
+
description: 'Show a file line by line with the check-in that last changed each line' +
|
|
617
|
+
' (annotate: line numbers, blame/praise: author names).',
|
|
618
|
+
inputSchema: z.object({
|
|
619
|
+
file: z.string().min(1).describe('File to annotate, relative to the check-out.'),
|
|
620
|
+
command: z
|
|
621
|
+
.enum(['blame', 'annotate', 'praise'])
|
|
622
|
+
.default('blame')
|
|
623
|
+
.describe('blame/praise print the author, annotate prints line numbers only.'),
|
|
624
|
+
revision: z.string().min(1).optional().describe('Check-in containing the file version to annotate (-r).'),
|
|
625
|
+
origin: z.string().min(1).optional().describe('Future check-in to annotate towards (-o); e.g. trunk.'),
|
|
626
|
+
limit: z.string().min(1).optional().describe('Version limit: a count, a duration like "2s", or "none" (-n).'),
|
|
627
|
+
filevers: flag('Show file versions instead of check-in versions (--filevers).'),
|
|
628
|
+
log: flag('List every version analysed (-l).'),
|
|
629
|
+
ignore_all_space: flag('Ignore all whitespace when matching lines (-w).'),
|
|
630
|
+
ignore_trailing_space: flag('Ignore trailing whitespace (-Z).'),
|
|
631
|
+
workspace: workspaceParam,
|
|
632
|
+
}),
|
|
633
|
+
annotations: { readOnlyHint: true },
|
|
634
|
+
}, async ({ file, command, revision, origin, limit, filevers, log, ignore_all_space, ignore_trailing_space, workspace, }) => {
|
|
635
|
+
const args = [command];
|
|
636
|
+
pushOption(args, '-r', revision);
|
|
637
|
+
pushOption(args, '-o', origin);
|
|
638
|
+
pushOption(args, '-n', limit);
|
|
639
|
+
if (filevers)
|
|
640
|
+
args.push('--filevers');
|
|
641
|
+
if (log)
|
|
642
|
+
args.push('-l');
|
|
643
|
+
if (ignore_all_space)
|
|
644
|
+
args.push('-w');
|
|
645
|
+
if (ignore_trailing_space)
|
|
646
|
+
args.push('-Z');
|
|
647
|
+
args.push(file);
|
|
648
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
649
|
+
});
|
|
650
|
+
server.registerTool('fossil_grep', {
|
|
651
|
+
title: 'Grep history',
|
|
652
|
+
description: 'Match a POSIX extended regular expression over every historical version of the named files, ' +
|
|
653
|
+
'starting at the newest version of each file.',
|
|
654
|
+
inputSchema: z.object({
|
|
655
|
+
pattern: z.string().min(1).describe('POSIX extended regular expression.'),
|
|
656
|
+
files: z.array(z.string().min(1)).min(1).describe('Files to search, newest version first.'),
|
|
657
|
+
ignore_case: flag('Case-insensitive match (-i).'),
|
|
658
|
+
count: flag('Print the number of matching files only (-c).'),
|
|
659
|
+
files_with_matches: flag('Print one artifact hash per matching file instead of the lines (-l).'),
|
|
660
|
+
once: flag('Stop at the first match (--once).'),
|
|
661
|
+
invert_match: flag('Show only files without a match (-v).'),
|
|
662
|
+
no_messages: flag('Suppress messages about unreadable files (-s).'),
|
|
663
|
+
verbose: flag('Report each file as it is analysed (--verbose).'),
|
|
664
|
+
workspace: workspaceParam,
|
|
665
|
+
}),
|
|
666
|
+
annotations: { readOnlyHint: true },
|
|
667
|
+
}, async ({ pattern, files, ignore_case, count, files_with_matches, once, invert_match, no_messages, verbose, workspace, }) => {
|
|
668
|
+
const args = ['grep'];
|
|
669
|
+
if (ignore_case)
|
|
670
|
+
args.push('-i');
|
|
671
|
+
if (count)
|
|
672
|
+
args.push('-c');
|
|
673
|
+
if (files_with_matches)
|
|
674
|
+
args.push('-l');
|
|
675
|
+
if (once)
|
|
676
|
+
args.push('--once');
|
|
677
|
+
if (invert_match)
|
|
678
|
+
args.push('-v');
|
|
679
|
+
if (no_messages)
|
|
680
|
+
args.push('-s');
|
|
681
|
+
if (verbose)
|
|
682
|
+
args.push('--verbose');
|
|
683
|
+
args.push(pattern, ...files);
|
|
684
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No matches.' });
|
|
685
|
+
});
|
|
686
|
+
server.registerTool('fossil_whatis', {
|
|
687
|
+
title: 'What is',
|
|
688
|
+
description: 'Resolve a name (tag, branch, hash prefix, or with file: the content hash) to its artifact hash and role.',
|
|
689
|
+
inputSchema: z.object({
|
|
690
|
+
name: z.string().min(1).describe('Symbol to resolve: tag, branch, hash prefix or filename.'),
|
|
691
|
+
file: flag('Treat name as a file whose content hash is looked up (-f).'),
|
|
692
|
+
type: z.enum(['ci', 't', 'w', 'g', 'e']).optional().describe('Only match this artifact type (--type).'),
|
|
693
|
+
verbose: flag('Include the internal record id (-v).'),
|
|
694
|
+
workspace: workspaceParam,
|
|
695
|
+
}),
|
|
696
|
+
annotations: { readOnlyHint: true },
|
|
697
|
+
}, async ({ name, file, type, verbose, workspace }) => {
|
|
698
|
+
const args = ['whatis'];
|
|
699
|
+
if (file)
|
|
700
|
+
args.push('-f');
|
|
701
|
+
pushOption(args, '--type', type);
|
|
702
|
+
if (verbose)
|
|
703
|
+
args.push('-v');
|
|
704
|
+
args.push(name);
|
|
705
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
706
|
+
});
|
|
707
|
+
server.registerTool('fossil_merge_base', {
|
|
708
|
+
title: 'Merge base',
|
|
709
|
+
description: 'Find the common ancestor check-in of two or more versions, as a hypothetical merge would.',
|
|
710
|
+
inputSchema: z.object({
|
|
711
|
+
versions: z.array(z.string().min(1)).min(2).describe('Two or more versions; the first is the primary.'),
|
|
712
|
+
ignore_merges: flag('Ignore merge arcs when looking for name pivots (--ignore-merges).'),
|
|
713
|
+
workspace: workspaceParam,
|
|
714
|
+
}),
|
|
715
|
+
annotations: { readOnlyHint: true },
|
|
716
|
+
}, async ({ versions, ignore_merges, workspace }) => {
|
|
717
|
+
const args = ['merge-base'];
|
|
718
|
+
if (ignore_merges)
|
|
719
|
+
args.push('--ignore-merges');
|
|
720
|
+
args.push(...versions);
|
|
721
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
722
|
+
});
|
|
723
|
+
server.registerTool('fossil_leaves', {
|
|
724
|
+
title: 'Leaves',
|
|
725
|
+
description: 'List the leaf check-ins of every branch, i.e. heads that have no children.',
|
|
726
|
+
inputSchema: z.object({
|
|
727
|
+
all: flag('Include closed leaves as well (-a).'),
|
|
728
|
+
closed: flag('Only closed leaves (-c).'),
|
|
729
|
+
multiple: flag('Only branches with more than one leaf (-m).'),
|
|
730
|
+
by_branch: flag('Order the output by branch name (--bybranch).'),
|
|
731
|
+
width: z.number().int().nonnegative().optional().describe('Output width in columns (-W); 0 means one line per entry.'),
|
|
732
|
+
workspace: workspaceParam,
|
|
733
|
+
}),
|
|
734
|
+
annotations: { readOnlyHint: true },
|
|
735
|
+
}, async ({ all, closed, multiple, by_branch, width, workspace }) => {
|
|
736
|
+
const args = ['leaves'];
|
|
737
|
+
if (all)
|
|
738
|
+
args.push('-a');
|
|
739
|
+
if (closed)
|
|
740
|
+
args.push('-c');
|
|
741
|
+
if (multiple)
|
|
742
|
+
args.push('-m');
|
|
743
|
+
if (by_branch)
|
|
744
|
+
args.push('--bybranch');
|
|
745
|
+
if (width !== undefined)
|
|
746
|
+
args.push('-W', String(width));
|
|
747
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
748
|
+
});
|
|
749
|
+
server.registerTool('fossil_descendants', {
|
|
750
|
+
title: 'Descendants',
|
|
751
|
+
description: 'List every leaf descendant of a check-in (default: the check-out version).',
|
|
752
|
+
inputSchema: z.object({
|
|
753
|
+
checkin: z.string().min(1).optional().describe('Check-in to start from. Omit for the check-out version.'),
|
|
754
|
+
width: z.number().int().nonnegative().optional().describe('Output width in columns (-W); 0 means one line per entry.'),
|
|
755
|
+
workspace: workspaceParam,
|
|
756
|
+
}),
|
|
757
|
+
annotations: { readOnlyHint: true },
|
|
758
|
+
}, async ({ checkin, width, workspace }) => {
|
|
759
|
+
const args = ['descendants'];
|
|
760
|
+
const target = clean(checkin);
|
|
761
|
+
if (target)
|
|
762
|
+
args.push(target);
|
|
763
|
+
if (width !== undefined)
|
|
764
|
+
args.push('-W', String(width));
|
|
765
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
766
|
+
});
|
|
767
|
+
server.registerTool('fossil_unpublished', {
|
|
768
|
+
title: 'Unpublished',
|
|
769
|
+
description: 'List unpublished check-ins (private artifacts that a push will not send).',
|
|
770
|
+
inputSchema: z.object({
|
|
771
|
+
all: flag('Include every unpublished artifact, not only check-ins (--all).'),
|
|
772
|
+
workspace: workspaceParam,
|
|
773
|
+
}),
|
|
774
|
+
annotations: { readOnlyHint: true },
|
|
775
|
+
}, async ({ all, workspace }) => renderOutcome(await runFossil(all ? ['unpublished', '--all'] : ['unpublished'], { workspace }), {
|
|
776
|
+
emptyText: 'No unpublished artifacts.',
|
|
777
|
+
}));
|
|
778
|
+
server.registerTool('fossil_ignore_from_gitignore', {
|
|
779
|
+
title: 'Ignore glob from .gitignore',
|
|
780
|
+
description: 'Convert a .gitignore file into the ignore-glob patterns Fossil matches against check-out paths, ' +
|
|
781
|
+
'and optionally write them to .fossil-settings/ignore-glob.',
|
|
782
|
+
inputSchema: z.object({
|
|
783
|
+
source: z.string().min(1).default('.gitignore').describe('File to convert, relative to the workspace.'),
|
|
784
|
+
write: flag('Write the patterns to .fossil-settings/ignore-glob.'),
|
|
785
|
+
overwrite: flag('Replace an existing .fossil-settings/ignore-glob.'),
|
|
786
|
+
workspace: workspaceParam,
|
|
787
|
+
}),
|
|
788
|
+
}, async ({ source, write, overwrite, workspace }) => {
|
|
789
|
+
const root = resolveWorkspace(workspace);
|
|
790
|
+
const sourcePath = path.resolve(root, source);
|
|
791
|
+
const relative = path.relative(root, sourcePath);
|
|
792
|
+
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
793
|
+
return {
|
|
794
|
+
content: [{ type: 'text', text: `ERROR: \`source\` must stay inside the workspace (${root}).` }],
|
|
795
|
+
isError: true,
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
let content;
|
|
799
|
+
try {
|
|
800
|
+
content = await readFile(sourcePath, 'utf8');
|
|
801
|
+
}
|
|
802
|
+
catch (error) {
|
|
803
|
+
const code = error.code ?? 'unknown error';
|
|
804
|
+
return {
|
|
805
|
+
content: [{ type: 'text', text: `ERROR: cannot read ${relative}: ${code}.` }],
|
|
806
|
+
isError: true,
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
const directory = path.dirname(relative);
|
|
810
|
+
const conversion = convertGitignore(content, { prefix: directory === '.' ? '' : directory });
|
|
811
|
+
const lines = [
|
|
812
|
+
`Converted ${conversion.lineCount} rules from ${relative} into ${conversion.patterns.length} ignore-glob patterns.`,
|
|
813
|
+
'',
|
|
814
|
+
...conversion.patterns,
|
|
815
|
+
];
|
|
816
|
+
if (conversion.warnings.length > 0) {
|
|
817
|
+
lines.push('', ...conversion.warnings.map((warning) => `NOTE: ${warning}.`));
|
|
818
|
+
}
|
|
819
|
+
if (!write)
|
|
820
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
821
|
+
const settingsDir = path.join(root, '.fossil-settings');
|
|
822
|
+
const target = path.join(settingsDir, 'ignore-glob');
|
|
823
|
+
const exists = await stat(target).then(() => true, () => false);
|
|
824
|
+
if (exists && !overwrite) {
|
|
825
|
+
return {
|
|
826
|
+
content: [
|
|
827
|
+
{
|
|
828
|
+
type: 'text',
|
|
829
|
+
text: 'ERROR: .fossil-settings/ignore-glob already exists; pass `overwrite: true` to replace it.',
|
|
830
|
+
},
|
|
831
|
+
],
|
|
832
|
+
isError: true,
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
await mkdir(settingsDir, { recursive: true });
|
|
836
|
+
await writeFile(target, renderGlobFile(conversion), 'utf8');
|
|
837
|
+
lines.splice(1, 0, 'Wrote .fossil-settings/ignore-glob.');
|
|
838
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
839
|
+
});
|
|
840
|
+
server.registerTool('fossil_ls', {
|
|
841
|
+
title: 'List files',
|
|
842
|
+
description: 'List the files of the check-out, or of a given check-in, optionally limited to some paths and enriched with age, status or time ordering.',
|
|
843
|
+
inputSchema: z.object({
|
|
844
|
+
paths: filesParam,
|
|
845
|
+
revision: z.string().min(1).optional().describe('Check-in to list (-r) instead of the check-out contents.'),
|
|
846
|
+
age: flag('Show when each file was committed (--age).'),
|
|
847
|
+
verbose: flag('Show extra information, including change status (--verbose).'),
|
|
848
|
+
time_order: flag('Sort by time instead of name (-t).'),
|
|
849
|
+
hash: flag('Verify file status by hashing instead of size and mtime (--hash).'),
|
|
850
|
+
workspace: workspaceParam,
|
|
851
|
+
}),
|
|
852
|
+
annotations: { readOnlyHint: true },
|
|
853
|
+
}, async ({ paths, revision, age, verbose, time_order, hash, workspace }) => {
|
|
854
|
+
const args = ['ls'];
|
|
855
|
+
pushOption(args, '-r', revision);
|
|
856
|
+
if (age)
|
|
857
|
+
args.push('--age');
|
|
858
|
+
if (verbose)
|
|
859
|
+
args.push('-v');
|
|
860
|
+
if (time_order)
|
|
861
|
+
args.push('-t');
|
|
862
|
+
if (hash)
|
|
863
|
+
args.push('--hash');
|
|
864
|
+
if (paths && paths.length > 0)
|
|
865
|
+
args.push(...paths);
|
|
866
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
867
|
+
});
|
|
868
|
+
server.registerTool('fossil_search', {
|
|
869
|
+
title: 'Search timeline',
|
|
870
|
+
description: 'Search check-in and other timeline comments for every given word and print the best matches.',
|
|
871
|
+
inputSchema: z.object({
|
|
872
|
+
pattern: z.string().min(1).describe('Words to look for; all of them must match.'),
|
|
873
|
+
all: flag('Print every match instead of only the best scoring ones (--all).'),
|
|
874
|
+
limit: z.number().int().min(1).optional().describe('Maximum number of matches (-n).'),
|
|
875
|
+
width: z.number().int().min(0).optional().describe('Output width in columns; 0 means no wrapping (-W).'),
|
|
876
|
+
workspace: workspaceParam,
|
|
877
|
+
}),
|
|
878
|
+
annotations: { readOnlyHint: true },
|
|
879
|
+
}, async ({ pattern, all, limit, width, workspace }) => {
|
|
880
|
+
const args = ['search'];
|
|
881
|
+
if (all)
|
|
882
|
+
args.push('-a');
|
|
883
|
+
if (limit !== undefined)
|
|
884
|
+
args.push('-n', String(limit));
|
|
885
|
+
if (width !== undefined)
|
|
886
|
+
args.push('-W', String(width));
|
|
887
|
+
args.push(pattern);
|
|
888
|
+
const outcome = await runFossil(args, { workspace });
|
|
889
|
+
// fossil reports an empty result set as "+++ no more data (0) +++".
|
|
890
|
+
if (outcome.ok && /^\+{3} no more data \(0\) \+{3}$/.test(outcome.stdout.trim())) {
|
|
891
|
+
return { content: [{ type: 'text', text: 'No matches.' }] };
|
|
892
|
+
}
|
|
893
|
+
return renderOutcome(outcome, { emptyText: 'No matches.' });
|
|
894
|
+
});
|
|
895
|
+
server.registerTool('fossil_artifact', {
|
|
896
|
+
title: 'Artifact content',
|
|
897
|
+
description: 'Print the raw content of an artifact by its hash, such as the manifest of a check-in or the blob of a file version.',
|
|
898
|
+
inputSchema: z.object({
|
|
899
|
+
artifact: z.string().min(1).describe('Artifact hash, or a unique prefix of it.'),
|
|
900
|
+
workspace: workspaceParam,
|
|
901
|
+
}),
|
|
902
|
+
annotations: { readOnlyHint: true },
|
|
903
|
+
}, async ({ artifact, workspace }) => renderOutcome(await runFossil(['artifact', artifact], { workspace })));
|
|
904
|
+
server.registerTool('fossil_describe', {
|
|
905
|
+
title: 'Describe version',
|
|
906
|
+
description: 'Describe a version as the closest non-propagating tag, the commit count since it and the short hash, or just the hash when no tag applies.',
|
|
907
|
+
inputSchema: z.object({
|
|
908
|
+
version: z.string().min(1).optional().describe('Version to describe; defaults to the checked-out version.'),
|
|
909
|
+
digits: z.number().int().min(4).max(40).optional().describe('Hex digits of the hash to show (--digits).'),
|
|
910
|
+
dirty: flag('Also show whether there are uncommitted changes (--dirty).'),
|
|
911
|
+
long: flag('Always show tag, count and hash, even when they collapse (--long).'),
|
|
912
|
+
match: z.string().min(1).optional().describe('Only consider non-propagating tags matching this glob (--match).'),
|
|
913
|
+
workspace: workspaceParam,
|
|
914
|
+
}),
|
|
915
|
+
annotations: { readOnlyHint: true },
|
|
916
|
+
}, async ({ version, digits, dirty, long, match, workspace }) => {
|
|
917
|
+
const args = ['describe'];
|
|
918
|
+
if (version)
|
|
919
|
+
args.push(version);
|
|
920
|
+
if (digits !== undefined)
|
|
921
|
+
args.push('--digits', String(digits));
|
|
922
|
+
if (dirty)
|
|
923
|
+
args.push('--dirty');
|
|
924
|
+
if (long)
|
|
925
|
+
args.push('--long');
|
|
926
|
+
if (match)
|
|
927
|
+
args.push('--match', match);
|
|
928
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
929
|
+
});
|
|
930
|
+
server.registerTool('fossil_archive', {
|
|
931
|
+
title: 'Archive check-in',
|
|
932
|
+
description: 'Generate a tarball or ZIP archive of a check-in, or list the files the archive would contain.',
|
|
933
|
+
inputSchema: z.object({
|
|
934
|
+
format: z.enum(['tarball', 'zip']).default('tarball').describe('Archive format.'),
|
|
935
|
+
version: z.string().min(1).default('tip').describe('Check-in to archive.'),
|
|
936
|
+
output: z
|
|
937
|
+
.string()
|
|
938
|
+
.min(1)
|
|
939
|
+
.optional()
|
|
940
|
+
.describe('Archive path, relative to the workspace. Omit to list the files instead.'),
|
|
941
|
+
name: z.string().min(1).optional().describe('Top-level directory name inside the archive (--name).'),
|
|
942
|
+
exclude: z.array(z.string().min(1)).optional().describe('Glob patterns to leave out (-X).'),
|
|
943
|
+
include: z.array(z.string().min(1)).optional().describe('Glob patterns to keep (--include).'),
|
|
944
|
+
workspace: workspaceParam,
|
|
945
|
+
}),
|
|
946
|
+
annotations: {},
|
|
947
|
+
}, async ({ format, version, output, name, exclude, include, workspace }) => {
|
|
948
|
+
const args = [format, version, output ?? '/dev/null'];
|
|
949
|
+
if (!output)
|
|
950
|
+
args.push('-l');
|
|
951
|
+
pushOption(args, '--name', name);
|
|
952
|
+
if (exclude && exclude.length > 0)
|
|
953
|
+
args.push('-X', globList(exclude));
|
|
954
|
+
if (include && include.length > 0)
|
|
955
|
+
args.push('--include', globList(include));
|
|
956
|
+
const outcome = await runFossil(args, { workspace });
|
|
957
|
+
if (outcome.ok && output) {
|
|
958
|
+
return renderOutcome({ ...outcome, stdout: `Wrote ${output} from ${version}.` });
|
|
959
|
+
}
|
|
960
|
+
return renderOutcome(outcome, { emptyText: 'The archive would be empty.' });
|
|
961
|
+
});
|
|
962
|
+
server.registerTool('fossil_unversioned', {
|
|
963
|
+
title: 'Unversioned files',
|
|
964
|
+
description: 'List, print, add, remove or timestamp the unversioned files the repository keeps without history.',
|
|
965
|
+
inputSchema: z.object({
|
|
966
|
+
action: z
|
|
967
|
+
.enum(['list', 'cat', 'add', 'remove', 'touch'])
|
|
968
|
+
.default('list')
|
|
969
|
+
.describe('list: show them; cat: print content; add/remove: change the set; touch: update timestamps.'),
|
|
970
|
+
files: filesParam.describe('Files the action applies to.'),
|
|
971
|
+
glob: z.string().min(1).optional().describe('Only match names by this glob (--glob).'),
|
|
972
|
+
like: z.string().min(1).optional().describe('Only match names like this pattern (--like).'),
|
|
973
|
+
workspace: workspaceParam,
|
|
974
|
+
}),
|
|
975
|
+
annotations: {},
|
|
976
|
+
}, async ({ action, files, glob, like, workspace }) => {
|
|
977
|
+
const args = ['unversioned', action];
|
|
978
|
+
pushOption(args, '--glob', glob);
|
|
979
|
+
pushOption(args, '--like', like);
|
|
980
|
+
if (files && files.length > 0)
|
|
981
|
+
args.push(...files);
|
|
982
|
+
const needsFiles = action !== 'list' && !(files && files.length > 0) && !glob && !like;
|
|
983
|
+
if (needsFiles) {
|
|
984
|
+
return {
|
|
985
|
+
isError: true,
|
|
986
|
+
content: [{ type: 'text', text: `ERROR: action '${action}' needs \`files\`, \`glob\` or \`like\`.` }],
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No unversioned files.' });
|
|
990
|
+
});
|
|
991
|
+
server.registerTool('fossil_touch', {
|
|
992
|
+
title: 'Touch files',
|
|
993
|
+
description: "Update file timestamps so that Fossil's size and mtime based change detection sees the files again.",
|
|
994
|
+
inputSchema: z.object({
|
|
995
|
+
files: filesParam.describe('Files or glob patterns to touch. Omit to touch every managed file.'),
|
|
996
|
+
mode: z
|
|
997
|
+
.enum(['now', 'checkin', 'checkout'])
|
|
998
|
+
.default('now')
|
|
999
|
+
.describe('now: current time; checkin: last check-in that modified each file; checkout: the checked-out version.'),
|
|
1000
|
+
workspace: workspaceParam,
|
|
1001
|
+
}),
|
|
1002
|
+
annotations: {},
|
|
1003
|
+
}, async ({ files, mode, workspace }) => {
|
|
1004
|
+
const args = ['touch'];
|
|
1005
|
+
if (mode === 'checkin')
|
|
1006
|
+
args.push('-c');
|
|
1007
|
+
else if (mode === 'checkout')
|
|
1008
|
+
args.push('-C');
|
|
1009
|
+
if (files && files.length > 0)
|
|
1010
|
+
args.push(...files);
|
|
1011
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
1012
|
+
});
|
|
1013
|
+
server.registerTool('fossil_amend', {
|
|
1014
|
+
title: 'Amend check-in',
|
|
1015
|
+
description: 'Change the comment, author, date, tags, branch or visibility of an existing check-in.',
|
|
1016
|
+
inputSchema: z.object({
|
|
1017
|
+
checkin: z.string().min(1).describe('Check-in to amend, such as tip or a hash.'),
|
|
1018
|
+
comment: z.string().min(1).optional().describe('Replacement comment (-m).'),
|
|
1019
|
+
author: z.string().min(1).optional().describe('Replacement author (--author).'),
|
|
1020
|
+
date: z.string().min(1).optional().describe('Replacement check-in time, or now (--date).'),
|
|
1021
|
+
tag: z.array(z.string().min(1)).optional().describe('Tags to add (--tag, repeatable).'),
|
|
1022
|
+
cancel: z.array(z.string().min(1)).optional().describe('Tags to remove (--cancel, repeatable).'),
|
|
1023
|
+
branch: z.string().min(1).optional().describe('Start a branch at this check-in (--branch).'),
|
|
1024
|
+
hide: flag('Hide the branch starting at this check-in (--hide).'),
|
|
1025
|
+
close: flag('Mark this leaf as closed (--close).'),
|
|
1026
|
+
dry_run: flag('Print the control artifact without changing anything (-n).'),
|
|
1027
|
+
workspace: workspaceParam,
|
|
1028
|
+
}),
|
|
1029
|
+
annotations: { destructiveHint: true },
|
|
1030
|
+
}, async ({ checkin, comment, author, date, tag, cancel, branch, hide, close, dry_run, workspace }) => {
|
|
1031
|
+
const args = ['amend', checkin];
|
|
1032
|
+
if (dry_run)
|
|
1033
|
+
args.push('-n');
|
|
1034
|
+
pushOption(args, '-m', comment);
|
|
1035
|
+
pushOption(args, '--author', author);
|
|
1036
|
+
pushOption(args, '--date', date);
|
|
1037
|
+
for (const value of tag ?? [])
|
|
1038
|
+
args.push('--tag', value);
|
|
1039
|
+
for (const value of cancel ?? [])
|
|
1040
|
+
args.push('--cancel', value);
|
|
1041
|
+
pushOption(args, '--branch', branch);
|
|
1042
|
+
if (hide)
|
|
1043
|
+
args.push('--hide');
|
|
1044
|
+
if (close)
|
|
1045
|
+
args.push('--close');
|
|
1046
|
+
const changed = comment || author || date || branch || hide || close || (tag?.length ?? 0) > 0 || (cancel?.length ?? 0) > 0;
|
|
1047
|
+
if (!changed) {
|
|
1048
|
+
return {
|
|
1049
|
+
isError: true,
|
|
1050
|
+
content: [
|
|
1051
|
+
{
|
|
1052
|
+
type: 'text',
|
|
1053
|
+
text: 'ERROR: pass at least one of `comment`, `author`, `date`, `tag`, `cancel`, `branch`, `hide` or `close`.',
|
|
1054
|
+
},
|
|
1055
|
+
],
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
1059
|
+
});
|
|
1060
|
+
server.registerTool('fossil_patch', {
|
|
1061
|
+
title: 'Binary patch',
|
|
1062
|
+
description: 'Create a binary patch from uncommitted changes, show it as a diff, or apply it to the check-out.',
|
|
1063
|
+
inputSchema: z.object({
|
|
1064
|
+
action: z.enum(['create', 'apply', 'diff']).default('create').describe('create, apply or show the patch.'),
|
|
1065
|
+
file: z.string().min(1).describe('Patch file path; relative paths resolve against the workspace.'),
|
|
1066
|
+
force: flag('Overwrite an existing patch, or apply over unsaved changes (-f).'),
|
|
1067
|
+
dry_run: flag('Print what would happen without doing it (-n).'),
|
|
1068
|
+
verbose: flag('Explain what happens (-v).'),
|
|
1069
|
+
workspace: workspaceParam,
|
|
396
1070
|
}),
|
|
397
1071
|
annotations: { destructiveHint: true },
|
|
398
|
-
}, async ({
|
|
1072
|
+
}, async ({ action, file, force, dry_run, verbose, workspace }) => {
|
|
1073
|
+
const args = ['patch', action];
|
|
1074
|
+
if (force)
|
|
1075
|
+
args.push('-f');
|
|
1076
|
+
if (dry_run)
|
|
1077
|
+
args.push('-n');
|
|
1078
|
+
if (verbose)
|
|
1079
|
+
args.push('-v');
|
|
1080
|
+
args.push(file);
|
|
1081
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
1082
|
+
});
|
|
1083
|
+
server.registerTool('fossil_bisect', {
|
|
1084
|
+
title: 'Bisect',
|
|
1085
|
+
description: 'Search the history for the check-in that introduced or fixed a problem: mark versions good/bad/skip, ask for the next candidate or review the log. WARNING: `run` executes the given command repeatedly; obtain user confirmation first.',
|
|
1086
|
+
inputSchema: z.object({
|
|
1087
|
+
action: z
|
|
1088
|
+
.enum(['good', 'bad', 'skip', 'next', 'log', 'chart', 'options', 'reset', 'run'])
|
|
1089
|
+
.describe('Bisect subcommand.'),
|
|
1090
|
+
version: z.string().min(1).optional().describe('Version to mark (good/bad/skip); omit for the current check-out.'),
|
|
1091
|
+
command: z
|
|
1092
|
+
.string()
|
|
1093
|
+
.min(1)
|
|
1094
|
+
.optional()
|
|
1095
|
+
.describe('Command that decides good (exit 0), skip (125) or bad (anything else); required by `run`.'),
|
|
1096
|
+
interactive: flag('Ask for the decision after each step instead of using the exit code (--interactive).'),
|
|
1097
|
+
option: z.string().min(1).optional().describe('Bisect option name for `options`.'),
|
|
1098
|
+
value: z.string().min(1).optional().describe('New value for `option`.'),
|
|
1099
|
+
workspace: workspaceParam,
|
|
1100
|
+
}),
|
|
1101
|
+
annotations: { idempotentHint: false },
|
|
1102
|
+
}, async ({ action, version, command, interactive, option, value, workspace }) => {
|
|
1103
|
+
if (action === 'run' && !command) {
|
|
1104
|
+
return {
|
|
1105
|
+
isError: true,
|
|
1106
|
+
content: [{ type: 'text', text: 'ERROR: `run` requires `command`.' }],
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
const args = ['bisect', action];
|
|
1110
|
+
if (action === 'run') {
|
|
1111
|
+
if (interactive)
|
|
1112
|
+
args.push('-i');
|
|
1113
|
+
args.push(command);
|
|
1114
|
+
}
|
|
1115
|
+
else if (action === 'options') {
|
|
1116
|
+
if (option)
|
|
1117
|
+
args.push(option);
|
|
1118
|
+
if (option && value)
|
|
1119
|
+
args.push(value);
|
|
1120
|
+
}
|
|
1121
|
+
else if (version) {
|
|
1122
|
+
args.push(version);
|
|
1123
|
+
}
|
|
1124
|
+
return renderOutcome(await runFossil(args, { workspace }));
|
|
1125
|
+
});
|
|
1126
|
+
server.registerTool('fossil_sql', {
|
|
1127
|
+
title: 'SQL query',
|
|
1128
|
+
description: 'Run a read-only query against the repository database and return the rows as a table. Pass `limit` inside the SQL, e.g. `SELECT ... LIMIT 20`.',
|
|
1129
|
+
inputSchema: z.object({
|
|
1130
|
+
query: z.string().min(1).describe('SQL statement, e.g. "SELECT name FROM blob LIMIT 5".'),
|
|
1131
|
+
repository: z
|
|
1132
|
+
.string()
|
|
1133
|
+
.min(1)
|
|
1134
|
+
.optional()
|
|
1135
|
+
.describe('Repository database to query instead of the one of the check-out (-R).'),
|
|
1136
|
+
workspace: workspaceParam,
|
|
1137
|
+
}),
|
|
1138
|
+
annotations: { readOnlyHint: true },
|
|
1139
|
+
}, async ({ query, repository, workspace }) => {
|
|
1140
|
+
const trimmed = query.trim().replace(/;+\s*$/, '');
|
|
1141
|
+
if (!/^(select|with|pragma|explain)\b/i.test(trimmed)) {
|
|
1142
|
+
return {
|
|
1143
|
+
isError: true,
|
|
1144
|
+
content: [
|
|
1145
|
+
{
|
|
1146
|
+
type: 'text',
|
|
1147
|
+
text: 'ERROR: the query must start with SELECT, WITH, PRAGMA or EXPLAIN.',
|
|
1148
|
+
},
|
|
1149
|
+
],
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
const result = await runSql(trimmed, { workspace, readonly: true, repository });
|
|
1153
|
+
if (!result.ok)
|
|
1154
|
+
return { isError: true, content: [{ type: 'text', text: result.error }] };
|
|
1155
|
+
if (result.rows.length === 0)
|
|
1156
|
+
return { content: [{ type: 'text', text: 'No rows.' }] };
|
|
1157
|
+
const columns = Object.keys(result.rows[0] ?? {});
|
|
1158
|
+
const cell = (value) => {
|
|
1159
|
+
if (value === null || value === undefined)
|
|
1160
|
+
return 'NULL';
|
|
1161
|
+
if (typeof value === 'object')
|
|
1162
|
+
return JSON.stringify(value);
|
|
1163
|
+
return String(value);
|
|
1164
|
+
};
|
|
1165
|
+
const lines = [columns.join('\t'), ...result.rows.map((row) => columns.map((column) => cell(row[column])).join('\t'))];
|
|
1166
|
+
return {
|
|
1167
|
+
content: [
|
|
1168
|
+
{
|
|
1169
|
+
type: 'text',
|
|
1170
|
+
text: truncateOutput(`${lines.join('\n')}\n\n${result.rows.length} row(s).`),
|
|
1171
|
+
},
|
|
1172
|
+
],
|
|
1173
|
+
};
|
|
1174
|
+
});
|
|
399
1175
|
}
|
|
400
|
-
//# sourceMappingURL=version-control.js.map
|