@stellar_ai/mcp_fossil_scm 0.1.3 → 0.2.1

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.
@@ -5,6 +5,11 @@ import { renderOutcome, renderSections, resolveWorkspace, runFossil, truncateOut
5
5
  import { convertGitignore, renderGlobFile } from '../core/gitignore.js';
6
6
  import { runSql } from '../core/sql.js';
7
7
  import { clean, workspaceParam, filesParam, flag, pushOption } from './common.js';
8
+ const repoOptionParam = z
9
+ .string()
10
+ .min(1)
11
+ .optional()
12
+ .describe('Repository database file to read instead of the open check-out, e.g. `repos/app.fossil` (-R). Absolute paths are used verbatim; relative paths resolve against the workspace.');
8
13
  /** Version-control tools: status, diff, history, commit, branch and workspace state. */
9
14
  /** Join glob patterns into one fossil GLOBLIST argument, quoting patterns that hold a comma. */
10
15
  function globList(patterns) {
@@ -15,27 +20,79 @@ function globList(patterns) {
15
20
  export function registerVersionControlTools(server) {
16
21
  server.registerTool('fossil_status', {
17
22
  title: 'Status',
18
- description: 'Show the change set of the check-out (modified/added/deleted files) plus the list of untracked files. ' +
19
- 'Both queries run in parallel.',
23
+ description: 'Show the change set of the check-out (modified/added/deleted files) plus the list of untracked files.',
20
24
  inputSchema: z.object({
21
- dotfiles: flag('Include dot-files in the untracked (extra) list.'),
22
- brief: flag('Use -b to print a single status keyword.'),
23
- ignore: z.string().min(1).optional().describe('Comma-separated glob patterns of extra files to ignore.'),
25
+ dotfiles: flag('Include dot-files in the change and untracked lists (--dotfiles).'),
26
+ brief: flag('List only the changed file names (fossil changes).'),
27
+ ignore: z.string().min(1).optional().describe('Comma-separated glob patterns of extra files to ignore (--ignore).'),
28
+ select: z
29
+ .array(z.enum([
30
+ 'edited',
31
+ 'updated',
32
+ 'changed',
33
+ 'missing',
34
+ 'added',
35
+ 'deleted',
36
+ 'renamed',
37
+ 'conflict',
38
+ 'meta',
39
+ 'unchanged',
40
+ 'all',
41
+ 'differ',
42
+ 'extra',
43
+ ]))
44
+ .optional()
45
+ .describe('Report only these change groups, e.g. ["changed", "extra"] (--edited, --added, --all, --differ, …). ' +
46
+ 'Omit to report the default change set plus untracked files.'),
47
+ classify: flag('Start each line with the change type; changes mode only (--classify).'),
48
+ hash: flag('Verify file status by hashing instead of size and mtime (--hash).'),
49
+ header: flag('Print the repository name above a non-empty report; changes mode only (--header).'),
50
+ verbose: flag('Print "(none)" when the report is empty; changes mode only (-v).'),
51
+ abs_paths: flag('Print absolute pathnames (--abs-paths).'),
52
+ rel_paths: flag('Print pathnames relative to the current directory (--rel-paths).'),
24
53
  workspace: workspaceParam,
25
54
  }),
26
55
  annotations: { readOnlyHint: true },
27
- }, async ({ dotfiles, brief, ignore, workspace }) => {
28
- const statusArgs = ['status'];
29
- if (brief)
30
- statusArgs.push('-b');
56
+ }, async ({ dotfiles, brief, ignore, select, classify, hash, header, verbose, abs_paths, rel_paths, workspace, }) => {
57
+ const command = brief ? 'changes' : 'status';
58
+ const args = [command];
59
+ if (dotfiles)
60
+ args.push('--dotfiles');
61
+ pushOption(args, '--ignore', ignore);
62
+ for (const group of select ?? [])
63
+ args.push(`--${group}`);
64
+ if (command === 'changes') {
65
+ if (classify)
66
+ args.push('--classify');
67
+ if (header)
68
+ args.push('--header');
69
+ if (verbose)
70
+ args.push('-v');
71
+ }
72
+ if (hash)
73
+ args.push('--hash');
74
+ if (abs_paths)
75
+ args.push('--abs-paths');
76
+ if (rel_paths)
77
+ args.push('--rel-paths');
78
+ const includesExtra = (select ?? []).some((group) => group === 'extra' || group === 'differ');
79
+ if (select?.length && includesExtra) {
80
+ return renderSections([{ title: 'STATUS', outcome: await runFossil(args, { workspace }) }]);
81
+ }
31
82
  const extraArgs = ['extra'];
32
83
  if (dotfiles)
33
84
  extraArgs.push('--dotfiles');
34
85
  pushOption(extraArgs, '--ignore', ignore);
35
- const [status, extra] = await Promise.all([
36
- runFossil(statusArgs, { workspace }),
37
- runFossil(extraArgs, { workspace }),
38
- ]);
86
+ if (hash)
87
+ extraArgs.push('--hash');
88
+ if (abs_paths)
89
+ extraArgs.push('--abs-paths');
90
+ if (rel_paths)
91
+ extraArgs.push('--rel-paths');
92
+ // Sequential: two fossil processes on the same repository can collide on
93
+ // the SQLite write lock ("database is locked").
94
+ const status = await runFossil(args, { workspace });
95
+ const extra = await runFossil(extraArgs, { workspace });
39
96
  return renderSections([
40
97
  { title: 'STATUS', outcome: status },
41
98
  { title: 'UNTRACKED (EXTRA)', outcome: extra },
@@ -57,10 +114,18 @@ export function registerVersionControlTools(server) {
57
114
  verbose: flag('Print the complete text of added or deleted files (-v).'),
58
115
  undo: flag('Diff against the undo buffer (--undo).'),
59
116
  ignore_whitespace: flag('Ignore whitespace-only changes (-w).'),
117
+ ignore_trailing_space: flag('Ignore changes to end-of-line whitespace (-Z).'),
118
+ strip_trailing_cr: flag('Treat CR at the end of each line as insignificant (--strip-trailing-cr).'),
119
+ new_file: flag('Treat added files as if they already existed with empty content (-N).'),
120
+ internal: flag('Use the internal diff logic (-i).'),
121
+ unified: flag('Print a unified diff (--unified).'),
122
+ versions_header: flag('Show the compared versions in the diff header (-h).'),
123
+ json: flag('Print the diff as JSON (--json).'),
124
+ width: z.number().int().min(20).optional().describe('Width of side-by-side lines (-W).'),
60
125
  workspace: workspaceParam,
61
126
  }),
62
127
  annotations: { readOnlyHint: true },
63
- }, async ({ from_version, to_version, files, branch, checkin, brief, stat, context: contextLines, side_by_side, verbose, undo, ignore_whitespace, workspace, }) => {
128
+ }, async ({ from_version, to_version, files, branch, checkin, brief, stat, context: contextLines, side_by_side, verbose, undo, ignore_whitespace, ignore_trailing_space, strip_trailing_cr, new_file, internal, unified, versions_header, json, width, workspace, }) => {
64
129
  const args = ['diff'];
65
130
  pushOption(args, '--from', from_version);
66
131
  pushOption(args, '--to', to_version);
@@ -80,6 +145,22 @@ export function registerVersionControlTools(server) {
80
145
  args.push('--undo');
81
146
  if (ignore_whitespace)
82
147
  args.push('-w');
148
+ if (ignore_trailing_space)
149
+ args.push('-Z');
150
+ if (strip_trailing_cr)
151
+ args.push('--strip-trailing-cr');
152
+ if (new_file)
153
+ args.push('-N');
154
+ if (internal)
155
+ args.push('-i');
156
+ if (unified)
157
+ args.push('--unified');
158
+ if (versions_header)
159
+ args.push('-h');
160
+ if (json)
161
+ args.push('--json');
162
+ if (width !== undefined)
163
+ args.push('-W', String(width));
83
164
  if (files?.length)
84
165
  args.push(...files);
85
166
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No differences found.' });
@@ -90,11 +171,13 @@ export function registerVersionControlTools(server) {
90
171
  inputSchema: z.object({
91
172
  file: z.string().min(1).describe('File path/name inside the repository.'),
92
173
  revision: z.string().min(1).optional().describe('Check-in or revision (-r). Defaults to the checked-out version.'),
174
+ repository: repoOptionParam,
93
175
  workspace: workspaceParam,
94
176
  }),
95
177
  annotations: { readOnlyHint: true },
96
- }, async ({ file, revision, workspace }) => {
178
+ }, async ({ file, revision, repository, workspace }) => {
97
179
  const args = ['cat', file];
180
+ pushOption(args, '-R', repository);
98
181
  pushOption(args, '-r', revision);
99
182
  return renderOutcome(await runFossil(args, { workspace }));
100
183
  });
@@ -117,13 +200,20 @@ export function registerVersionControlTools(server) {
117
200
  annotations: { readOnlyHint: true },
118
201
  }, async ({ file, mode, brief, limit, offset, revision, verbose, workspace }) => {
119
202
  const args = ['finfo'];
120
- if (mode === 'id')
203
+ if (mode === 'id') {
121
204
  args.push('-i');
122
- else if (mode === 'status')
205
+ pushOption(args, '-r', revision);
206
+ if (verbose)
207
+ args.push('-v');
208
+ }
209
+ else if (mode === 'status') {
123
210
  args.push('-s');
124
- else if (mode === 'print')
211
+ }
212
+ else if (mode === 'print') {
125
213
  args.push('-p');
126
- if (mode === 'log') {
214
+ pushOption(args, '-r', revision);
215
+ }
216
+ else {
127
217
  if (brief)
128
218
  args.push('-b');
129
219
  if (limit !== undefined)
@@ -131,9 +221,6 @@ export function registerVersionControlTools(server) {
131
221
  if (offset !== undefined)
132
222
  args.push('--offset', String(offset));
133
223
  }
134
- pushOption(args, '-r', revision);
135
- if (verbose)
136
- args.push('-v');
137
224
  args.push(file);
138
225
  return renderOutcome(await runFossil(args, { workspace }));
139
226
  });
@@ -179,35 +266,88 @@ export function registerVersionControlTools(server) {
179
266
  });
180
267
  server.registerTool('fossil_tag', {
181
268
  title: 'Tags',
182
- description: 'List, add or cancel Fossil tags (symbolic labels attached to check-ins).',
269
+ description: 'List, find, add or cancel Fossil tags (symbolic labels attached to check-ins and other artifacts).',
183
270
  inputSchema: z.object({
184
- action: z.enum(['ls', 'add', 'cancel']).default('ls').describe('Tag sub-command.'),
185
- tag_name: z.string().min(1).optional().describe('Tag name (required for add/cancel).'),
271
+ action: z.enum(['ls', 'find', 'add', 'cancel']).default('ls').describe('Tag sub-command.'),
272
+ tag_name: z.string().min(1).optional().describe('Tag name (required for find/add/cancel).'),
186
273
  checkin: z
187
274
  .string()
188
275
  .min(1)
189
276
  .optional()
190
- .describe('Target check-in (required for add; defaults to tip for cancel).'),
277
+ .describe('Target check-in or artifact (required for add; defaults to tip for cancel, optional for list).'),
278
+ raw: flag('Use the raw tag name instead of a branch name (--raw).'),
279
+ propagate: flag('Propagate the tag to all descendants of the artifact; used with `add` (--propagate).'),
280
+ date_override: z
281
+ .string()
282
+ .min(1)
283
+ .optional()
284
+ .describe('Tag timestamp to store, e.g. "2026-11-17 12:00:00"; used with `add`/`cancel` (--date-override).'),
285
+ user_override: z
286
+ .string()
287
+ .min(1)
288
+ .optional()
289
+ .describe('Login to record as the tag author; used with `add`/`cancel` (--user-override).'),
290
+ dry_run: flag('Print the control artifact without writing it; used with `add`/`cancel` (-n).'),
291
+ type: z
292
+ .enum(['ci', 'w', 'e', 'f', 't'])
293
+ .optional()
294
+ .describe('Artifact type to match; used with `find` (-t).'),
295
+ limit: z.number().int().min(1).optional().describe('Maximum number of results; used with `find` (-n).'),
296
+ tagtype: z
297
+ .enum(['propagated', 'singleton', 'cancel'])
298
+ .optional()
299
+ .describe('List only tags of this type; used with `ls` (--tagtype).'),
300
+ inverse: flag('Invert the `tagtype` filter; used with `ls` (-v).'),
301
+ prefix: z.string().min(1).optional().describe('List only tags with this prefix; used with `ls` (--prefix).'),
191
302
  workspace: workspaceParam,
192
303
  }),
193
304
  annotations: { idempotentHint: true },
194
- }, async ({ action, tag_name, checkin, workspace }) => {
305
+ }, async ({ action, tag_name, checkin, raw, propagate, date_override, user_override, dry_run, type, limit, tagtype, inverse, prefix, workspace, }) => {
195
306
  const name = clean(tag_name);
196
307
  const target = clean(checkin);
197
- if (action === 'add' && (!name || !target)) {
308
+ const subcommand = action ?? 'ls';
309
+ if (subcommand === 'add' && (!name || !target)) {
198
310
  return { content: [{ type: 'text', text: "ERROR: 'tag_name' and 'checkin' are required for action 'add'." }], isError: true };
199
311
  }
200
- if (action === 'cancel' && !name) {
201
- return { content: [{ type: 'text', text: "ERROR: 'tag_name' is required for action 'cancel'." }], isError: true };
312
+ if ((subcommand === 'cancel' || subcommand === 'find') && !name) {
313
+ return {
314
+ content: [{ type: 'text', text: `ERROR: 'tag_name' is required for action '${subcommand}'.` }],
315
+ isError: true,
316
+ };
202
317
  }
203
- const args = ['tag', action ?? 'ls'];
204
- // `fossil tag cancel` always needs an artifact id; 'tip' is the sane default.
205
- if (action === 'add') {
206
- if (name && target)
207
- args.push(name, target);
318
+ const args = ['tag', subcommand];
319
+ if (subcommand === 'ls') {
320
+ if (raw)
321
+ args.push('--raw');
322
+ pushOption(args, '--tagtype', tagtype);
323
+ if (inverse)
324
+ args.push('-v');
325
+ pushOption(args, '--prefix', prefix);
326
+ if (target)
327
+ args.push(target);
208
328
  }
209
- else if (action === 'cancel') {
329
+ else if (subcommand === 'find') {
330
+ if (raw)
331
+ args.push('--raw');
332
+ pushOption(args, '-t', type);
333
+ if (limit !== undefined)
334
+ args.push('-n', String(limit));
210
335
  if (name)
336
+ args.push(name);
337
+ }
338
+ else {
339
+ if (raw)
340
+ args.push('--raw');
341
+ if (subcommand === 'add' && propagate)
342
+ args.push('--propagate');
343
+ pushOption(args, '--date-override', date_override);
344
+ pushOption(args, '--user-override', user_override);
345
+ if (dry_run)
346
+ args.push('-n');
347
+ // `fossil tag cancel` always needs an artifact id; 'tip' is the sane default.
348
+ if (subcommand === 'add' && name && target)
349
+ args.push(name, target);
350
+ else if (subcommand === 'cancel' && name)
211
351
  args.push(name, target ?? 'tip');
212
352
  }
213
353
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No tags.' });
@@ -221,18 +361,27 @@ export function registerVersionControlTools(server) {
221
361
  clean: z.string().min(1).optional().describe('Comma-separated glob patterns of clean files to ignore (--clean).'),
222
362
  reset: flag('Reset the ADDED/DELETED state of the check-out instead (--reset).'),
223
363
  dry_run: flag('Show what would be staged without changing anything (-n/--dry-run).'),
364
+ case_sensitive: z
365
+ .boolean()
366
+ .optional()
367
+ .describe('Override the case-sensitive setting (--case-sensitive).'),
368
+ verbose: flag('Report each file while resetting, with reset: true (-v).'),
224
369
  workspace: workspaceParam,
225
370
  }),
226
- }, async ({ dotfiles, ignore, clean: cleanGlob, reset, dry_run, workspace }) => {
371
+ }, async ({ dotfiles, ignore, clean: cleanGlob, reset, dry_run, case_sensitive, verbose, workspace }) => {
227
372
  const args = ['addremove'];
228
373
  if (dry_run)
229
374
  args.push('-n');
230
375
  if (reset) {
231
376
  args.push('--reset');
377
+ if (verbose)
378
+ args.push('-v');
232
379
  }
233
380
  else {
234
381
  if (dotfiles)
235
382
  args.push('--dotfiles');
383
+ if (case_sensitive !== undefined)
384
+ args.push('--case-sensitive', case_sensitive ? '1' : '0');
236
385
  pushOption(args, '--ignore', ignore);
237
386
  pushOption(args, '--clean', cleanGlob);
238
387
  }
@@ -240,38 +389,77 @@ export function registerVersionControlTools(server) {
240
389
  });
241
390
  server.registerTool('fossil_commit', {
242
391
  title: 'Commit',
243
- description: 'Create a check-in from the staged/current changes. Answers the interactive "commit anyhow" prompt with ' +
244
- "'a' (all) automatically.",
392
+ description: 'Create a check-in from the staged/current changes. Answers the interactive "continue" and "commit anyhow" ' +
393
+ 'prompts automatically.',
245
394
  inputSchema: z.object({
246
395
  message: z.string().min(1).describe('Commit message.'),
247
396
  files: filesParam.describe('Files to commit. Omit to commit everything that changed.'),
248
397
  branch: z.string().min(1).optional().describe('Place the new check-in on this branch (--branch).'),
249
398
  no_warnings: flag('Omit content warnings (--no-warnings).'),
250
399
  allow_empty: flag('Allow a check-in with no file changes (--allow-empty).'),
400
+ allow_fork: flag('Allow the check-in to fork the branch (--allow-fork).'),
401
+ allow_conflict: flag('Commit with unresolved merge conflicts (--allow-conflict).'),
402
+ allow_older: flag('Store a timestamp older than the ancestor check-in (--allow-older).'),
403
+ integrate: flag('Close every branch merged into this one (--integrate).'),
404
+ private_checkin: flag('Keep the check-in out of pushes (--private).'),
405
+ hash: flag('Detect file changes by hashing instead of size+mtime (--hash).'),
406
+ no_verify: flag('Skip the before-commit hooks (--no-verify).'),
407
+ dry_run: flag('Show what would be committed without writing (--dry-run).'),
408
+ message_file: z
409
+ .string()
410
+ .min(1)
411
+ .optional()
412
+ .describe('Read the commit message from this file (-M); takes precedence over `message`.'),
413
+ mimetype: z.string().min(1).optional().describe('Mimetype of the commit message (--mimetype).'),
251
414
  user_override: z.string().min(1).optional().describe('Record this login as the author (--user-override).'),
252
415
  tags: z.array(z.string().min(1)).optional().describe('Tags to attach to the new check-in (--tag).'),
253
416
  close: flag('Close the branch being committed (--close).'),
254
417
  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).'),
418
+ date_override: z
419
+ .string()
420
+ .min(1)
421
+ .optional()
422
+ .describe('Check-in timestamp to store instead of now, e.g. "2026-11-17 12:00:00" (--date-override).'),
256
423
  workspace: workspaceParam,
257
424
  }),
258
- }, async ({ message, files, branch, no_warnings, allow_empty, user_override, tags, close, bgcolor, mtime, workspace }) => {
425
+ }, async ({ message, files, branch, no_warnings, allow_empty, allow_fork, allow_conflict, allow_older, integrate, private_checkin, hash, no_verify, dry_run, message_file, mimetype, user_override, tags, close, bgcolor, date_override, workspace }) => {
259
426
  const args = ['commit', '-m', message];
260
- pushOption(args, '--branch', branch);
427
+ pushOption(args, '-M', message_file);
428
+ pushOption(args, '--mimetype', mimetype);
261
429
  if (no_warnings)
262
430
  args.push('--no-warnings');
263
431
  if (allow_empty)
264
432
  args.push('--allow-empty');
433
+ if (allow_fork)
434
+ args.push('--allow-fork');
435
+ if (allow_conflict)
436
+ args.push('--allow-conflict');
437
+ if (allow_older)
438
+ args.push('--allow-older');
439
+ if (integrate)
440
+ args.push('--integrate');
441
+ if (private_checkin)
442
+ args.push('--private');
443
+ if (hash)
444
+ args.push('--hash');
445
+ if (no_verify)
446
+ args.push('--no-verify');
447
+ if (dry_run)
448
+ args.push('--dry-run');
449
+ pushOption(args, '--branch', branch);
265
450
  if (close)
266
451
  args.push('--close');
267
452
  pushOption(args, '--bgcolor', bgcolor);
268
- pushOption(args, '--mtime', mtime);
453
+ pushOption(args, '--date-override', date_override);
269
454
  for (const tag of tags ?? [])
270
455
  args.push('--tag', tag);
271
456
  pushOption(args, '--user-override', user_override);
272
457
  if (files?.length)
273
458
  args.push(...files);
274
- return renderOutcome(await runFossil(args, { workspace, input: 'a\n' }));
459
+ // Fossil asks "continue (y/N)?" for unknown file arguments and
460
+ // "Commit anyhow (a=all/y/N)?" for warned files. "y" then "a" answers
461
+ // both, and a single prompt just consumes the first line.
462
+ return renderOutcome(await runFossil(args, { workspace, input: 'y\na\n' }));
275
463
  });
276
464
  server.registerTool('fossil_add', {
277
465
  title: 'Add files',
@@ -285,10 +473,16 @@ export function registerVersionControlTools(server) {
285
473
  force: z.boolean().default(true).describe('Add even when a file matches ignore-glob, without prompting (-f).'),
286
474
  reset: flag('Reset the ADDED state instead of adding files (--reset).'),
287
475
  ignore: z.string().min(1).optional().describe('Ignore unmanaged files matching these globs (--ignore).'),
476
+ clean: z.string().min(1).optional().describe('Also ignore files matching these globs (--clean).'),
477
+ case_sensitive: z
478
+ .boolean()
479
+ .optional()
480
+ .describe('Override the case-sensitive setting (--case-sensitive).'),
481
+ allow_reserved: flag('Add file names that Windows reserves, such as `CON` or `NUL` (--allow-reserved).'),
288
482
  verbose: flag('Report each file while resetting, with reset: true (-v).'),
289
483
  workspace: workspaceParam,
290
484
  }),
291
- }, async ({ files, dotfiles, force, reset, ignore, verbose, workspace }) => {
485
+ }, async ({ files, dotfiles, force, reset, ignore, clean: cleanGlob, case_sensitive, allow_reserved, verbose, workspace }) => {
292
486
  const args = ['add'];
293
487
  if (reset) {
294
488
  args.push('--reset');
@@ -308,7 +502,12 @@ export function registerVersionControlTools(server) {
308
502
  args.push('--dotfiles');
309
503
  if (force !== false)
310
504
  args.push('-f');
505
+ if (case_sensitive !== undefined)
506
+ args.push('--case-sensitive', case_sensitive ? '1' : '0');
507
+ if (allow_reserved)
508
+ args.push('--allow-reserved');
311
509
  pushOption(args, '--ignore', ignore);
510
+ pushOption(args, '--clean', cleanGlob);
312
511
  args.push(...files);
313
512
  return renderOutcome(await runFossil(args, { workspace }));
314
513
  });
@@ -318,25 +517,39 @@ export function registerVersionControlTools(server) {
318
517
  inputSchema: z.object({
319
518
  files: z.array(z.string().min(1)).min(1).describe('Files or directories to remove.'),
320
519
  force: flag('Also delete from disk (--hard).'),
321
- keep: flag('Keep files on disk (--soft).'),
520
+ keep: flag('Keep files on disk (--soft); takes precedence over `force`.'),
322
521
  dry_run: flag('Show what would be removed without changing anything (-n).'),
323
522
  reset: flag('Reset the DELETED state instead of removing files (--reset).'),
324
- verbose: flag('Report each file when resetting (--verbose).'),
523
+ verbose: flag('Report each file when resetting (--verbose); used with `reset`.'),
524
+ case_sensitive: z
525
+ .boolean()
526
+ .optional()
527
+ .describe('Override the case-sensitive setting (--case-sensitive).'),
325
528
  workspace: workspaceParam,
326
529
  }),
327
530
  annotations: { destructiveHint: true },
328
- }, async ({ files, force, keep, dry_run, reset, verbose, workspace }) => {
531
+ }, async ({ files, force, keep, dry_run, reset, verbose, case_sensitive, workspace }) => {
329
532
  const args = ['rm'];
330
- if (force)
331
- args.push('--hard');
332
- if (keep)
333
- args.push('--soft');
334
- if (reset)
533
+ if (reset) {
335
534
  args.push('--reset');
336
- if (verbose)
337
- args.push('--verbose');
338
- if (dry_run)
339
- args.push('-n');
535
+ if (verbose)
536
+ args.push('--verbose');
537
+ if (dry_run)
538
+ args.push('-n');
539
+ }
540
+ else if (keep) {
541
+ args.push('--soft');
542
+ if (dry_run)
543
+ args.push('-n');
544
+ }
545
+ else {
546
+ if (force)
547
+ args.push('--hard');
548
+ if (dry_run)
549
+ args.push('-n');
550
+ }
551
+ if (case_sensitive !== undefined)
552
+ args.push('--case-sensitive', case_sensitive ? '1' : '0');
340
553
  args.push(...files);
341
554
  return renderOutcome(await runFossil(args, { workspace }));
342
555
  });
@@ -351,12 +564,15 @@ export function registerVersionControlTools(server) {
351
564
  .boolean()
352
565
  .optional()
353
566
  .describe('Explicitly set the case-sensitive behaviour (--case-sensitive 1/0).'),
567
+ dry_run: flag('Print the RENAME event without changing anything (-n).'),
354
568
  workspace: workspaceParam,
355
569
  }),
356
- }, async ({ old_name, new_name, hard, case_sensitive, workspace }) => {
570
+ }, async ({ old_name, new_name, hard, case_sensitive, dry_run, workspace }) => {
357
571
  const args = ['mv', hard !== false ? '--hard' : '--soft'];
358
572
  if (case_sensitive !== undefined)
359
573
  args.push('--case-sensitive', case_sensitive ? '1' : '0');
574
+ if (dry_run)
575
+ args.push('-n');
360
576
  args.push(old_name, new_name);
361
577
  return renderOutcome(await runFossil(args, { workspace }));
362
578
  });
@@ -396,13 +612,56 @@ export function registerVersionControlTools(server) {
396
612
  description: 'Delete untracked files from the workspace. Destructive: preview with dry_run first. ' +
397
613
  'Without flags it runs non-interactively (--no-prompt).',
398
614
  inputSchema: z.object({
399
- all_files: flag('Force deletion without confirmation (-f).'),
615
+ all_files: flag('Delete every unmanaged file without confirmation (-f).'),
400
616
  dry_run: flag('Only list what would be deleted (-n).'),
617
+ dotfiles: flag('Include files and directories whose name starts with a dot (--dotfiles).'),
618
+ ignore: z.string().min(1).optional().describe('Keep unmanaged files matching these globs (--ignore).'),
619
+ clean: z.string().min(1).optional().describe('Delete matching files without prompting (--clean).'),
620
+ verily: flag('Remove everything that is not managed, including dot-files and ignored files, without the undo buffer (-x).'),
621
+ temp: flag('Remove only Fossil-generated temporary files (--temp).'),
622
+ dirs_only: flag('Remove empty directories only, no files (--dirsonly).'),
623
+ empty_dirs: flag('Remove empty directories after deleting files (--emptydirs).'),
624
+ keep: z.string().min(1).optional().describe('Comma-separated globs of files to spare beyond ignore-glob (--keep).'),
625
+ disable_undo: flag('Do not keep a copy that `fossil undo` can restore (--disable-undo).'),
626
+ all_checkouts: flag('Apply the empty-directory scan to every open check-out (--allckouts).'),
627
+ prompt: flag('Ask before deleting each file (-i).'),
628
+ case_sensitive: z.boolean().optional().describe('Override the case-sensitive setting (--case-sensitive).'),
629
+ verbose: flag('Report each file as it is removed (-v).'),
401
630
  workspace: workspaceParam,
402
631
  }),
403
632
  annotations: { destructiveHint: true },
404
- }, async ({ all_files, dry_run, workspace }) => {
405
- const args = ['clean', dry_run ? '-n' : all_files ? '-f' : '--no-prompt'];
633
+ }, async ({ all_files, dry_run, dotfiles, ignore, clean: cleanGlob, verily, temp, dirs_only, empty_dirs, keep, disable_undo, all_checkouts, prompt, case_sensitive, verbose, workspace }) => {
634
+ const args = ['clean'];
635
+ if (dry_run)
636
+ args.push('-n');
637
+ else if (all_files)
638
+ args.push('-f');
639
+ else if (!verily)
640
+ args.push('--no-prompt');
641
+ if (dotfiles)
642
+ args.push('--dotfiles');
643
+ pushOption(args, '--ignore', ignore);
644
+ pushOption(args, '--clean', cleanGlob);
645
+ if (verily)
646
+ args.push('-x');
647
+ if (temp)
648
+ args.push('--temp');
649
+ if (dirs_only)
650
+ args.push('--dirsonly');
651
+ if (empty_dirs)
652
+ args.push('--emptydirs');
653
+ if (keep)
654
+ args.push('--keep', keep);
655
+ if (disable_undo)
656
+ args.push('--disable-undo');
657
+ if (all_checkouts)
658
+ args.push('--allckouts');
659
+ if (prompt)
660
+ args.push('-i');
661
+ if (case_sensitive !== undefined)
662
+ args.push('--case-sensitive', case_sensitive ? '1' : '0');
663
+ if (verbose)
664
+ args.push('-v');
406
665
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'Nothing to clean.' });
407
666
  });
408
667
  server.registerTool('fossil_timeline', {
@@ -429,11 +688,15 @@ export function registerVersionControlTools(server) {
429
688
  .optional()
430
689
  .describe("Entry format (-F), e.g. 'oneline' or '%h %d %c'."),
431
690
  verbose: flag('List the files changed by each check-in (-v).'),
691
+ offset: z.number().int().min(0).optional().describe('Skip this many entries before reporting (--offset).'),
692
+ width: z.number().int().min(20).optional().describe('Width of the output lines (-W).'),
693
+ repository: repoOptionParam,
432
694
  workspace: workspaceParam,
433
695
  }),
434
696
  annotations: { readOnlyHint: true },
435
- }, async ({ limit, path: targetPath, type_filter, branch, current_branch, when, checkin, format, verbose, workspace }) => {
697
+ }, async ({ limit, path: targetPath, type_filter, branch, current_branch, when, checkin, format, verbose, offset, width, repository, workspace, }) => {
436
698
  const args = ['timeline', '-n', String(limit ?? 20)];
699
+ pushOption(args, '-R', repository);
437
700
  pushOption(args, '-p', targetPath);
438
701
  pushOption(args, '-t', type_filter);
439
702
  pushOption(args, '-b', branch);
@@ -446,6 +709,10 @@ export function registerVersionControlTools(server) {
446
709
  pushOption(args, '-F', format);
447
710
  if (verbose)
448
711
  args.push('-v');
712
+ if (offset !== undefined)
713
+ args.push('--offset', String(offset));
714
+ if (width !== undefined)
715
+ args.push('-W', String(width));
449
716
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No events.' });
450
717
  });
451
718
  server.registerTool('fossil_info', {
@@ -453,36 +720,100 @@ export function registerVersionControlTools(server) {
453
720
  description: 'Repository/check-out metadata, or details about a specific file, check-in or branch.',
454
721
  inputSchema: z.object({
455
722
  target: z.string().optional().describe('File name, check-in hash or branch. Omit for general repository info.'),
723
+ verbose: flag('Show extra details, such as the SQLite version and repository size (-v).'),
724
+ repository: repoOptionParam,
456
725
  workspace: workspaceParam,
457
726
  }),
458
727
  annotations: { readOnlyHint: true },
459
- }, async ({ target, workspace }) => {
728
+ }, async ({ target, verbose, repository, workspace }) => {
460
729
  const targetValue = clean(target);
461
730
  const args = targetValue ? ['info', targetValue] : ['info'];
731
+ pushOption(args, '-R', repository);
732
+ if (verbose)
733
+ args.push('-v');
462
734
  return renderOutcome(await runFossil(args, { workspace }));
463
735
  });
464
736
  server.registerTool('fossil_branch', {
465
737
  title: 'Branches',
466
- description: 'List branches or create a new one from an optional basis.',
738
+ description: 'List, inspect, create, close, reopen, hide or unhide branches.',
467
739
  inputSchema: z.object({
468
- action: z.enum(['ls', 'new']).default('ls').describe("'ls' lists branches, 'new' creates one."),
469
- branch_name: z.string().min(1).optional().describe("Required for action 'new'."),
740
+ action: z
741
+ .enum(['ls', 'new', 'info', 'current', 'close', 'reopen', 'hide', 'unhide'])
742
+ .default('ls')
743
+ .describe("Branch sub-command: 'ls' lists branches, 'new' creates one, 'info'/'current' report"),
744
+ branch_name: z
745
+ .string()
746
+ .min(1)
747
+ .optional()
748
+ .describe("Branch to act on (required for 'new', 'info', 'close', 'reopen', 'hide' and 'unhide')."),
470
749
  basis: z
471
750
  .string()
472
751
  .min(1)
473
752
  .optional()
474
753
  .describe("Starting point for the new branch (check-in or branch). Defaults to 'current'."),
754
+ all: flag('List all branches, including closed ones (-a).'),
755
+ closed: flag('List only closed branches (-c).'),
756
+ private_branches: flag('List only private branches (-p).'),
757
+ reverse: flag('Reverse the sort order (-r).'),
758
+ time_order: flag('Show recently changed branches first (-t).'),
759
+ dry_run: flag('Print the control artifact without committing it; used with close/reopen/hide/unhide (-n).'),
760
+ verbose: flag('Report more detail; used with close/reopen (-v).'),
761
+ date_override: z
762
+ .string()
763
+ .min(1)
764
+ .optional()
765
+ .describe('Timestamp to store instead of now (--date-override).'),
766
+ user_override: z
767
+ .string()
768
+ .min(1)
769
+ .optional()
770
+ .describe('Login to record as the author (--user-override).'),
771
+ bgcolor: z.string().min(1).optional().describe('Background colour for the new branch (--bgcolor).'),
772
+ private_branch: flag('Keep the new branch local; used with `new` (--private).'),
475
773
  workspace: workspaceParam,
476
774
  }),
477
- }, async ({ action, branch_name, basis, workspace }) => {
775
+ }, async ({ action, branch_name, basis, all, closed, private_branches, reverse, time_order, dry_run, verbose, date_override, user_override, bgcolor, private_branch, workspace, }) => {
478
776
  const name = clean(branch_name);
479
- if (action === 'new' && !name) {
480
- return { content: [{ type: 'text', text: "ERROR: 'branch_name' is required for action 'new'." }], isError: true };
777
+ const subcommand = action ?? 'ls';
778
+ if (['new', 'info', 'close', 'reopen', 'hide', 'unhide'].includes(subcommand) && !name) {
779
+ return {
780
+ content: [{ type: 'text', text: `ERROR: 'branch_name' is required for action '${subcommand}'.` }],
781
+ isError: true,
782
+ };
783
+ }
784
+ const args = ['branch', subcommand];
785
+ if (subcommand === 'ls') {
786
+ if (all)
787
+ args.push('-a');
788
+ if (closed)
789
+ args.push('-c');
790
+ if (private_branches)
791
+ args.push('-p');
792
+ if (reverse)
793
+ args.push('-r');
794
+ if (time_order)
795
+ args.push('-t');
481
796
  }
482
- const args = ['branch', action ?? 'ls'];
483
- // Fossil requires an explicit basis, 'current' means the checked-out branch.
484
- if (action === 'new' && name)
797
+ else if (subcommand === 'new' && name) {
798
+ // Fossil requires an explicit basis, 'current' means the checked-out branch.
485
799
  args.push(name, clean(basis) ?? 'current');
800
+ if (private_branch)
801
+ args.push('--private');
802
+ pushOption(args, '--bgcolor', bgcolor);
803
+ }
804
+ else if (name) {
805
+ args.push(name);
806
+ if (['close', 'reopen', 'hide', 'unhide'].includes(subcommand)) {
807
+ if (dry_run)
808
+ args.push('-n');
809
+ if (verbose)
810
+ args.push('-v');
811
+ }
812
+ }
813
+ if (subcommand !== 'ls' && subcommand !== 'current') {
814
+ pushOption(args, '--date-override', date_override);
815
+ pushOption(args, '--user-override', user_override);
816
+ }
486
817
  return renderOutcome(await runFossil(args, { workspace }));
487
818
  });
488
819
  server.registerTool('fossil_merge', {
@@ -497,6 +828,7 @@ export function registerVersionControlTools(server) {
497
828
  baseline: z.string().min(1).optional().describe('Use this version as the merge pivot (--baseline).'),
498
829
  binary: z.string().min(1).optional().describe('Skip parallel changes of files matching this glob (--binary).'),
499
830
  force: flag('Force the merge even if it would be a no-op (-f).'),
831
+ force_missing: flag('Merge even when content of one side is missing (--force-missing).'),
500
832
  keep_merge_files: flag('Keep the temporary merge files on conflict (-K).'),
501
833
  verbose: flag('Report each file as it is merged (-v).'),
502
834
  workspace: workspaceParam,
@@ -533,11 +865,14 @@ export function registerVersionControlTools(server) {
533
865
  no_sync: flag('Skip the automatic sync before updating (--nosync).'),
534
866
  set_mtime: flag('Stamp every file with its last-check-in time (--setmtime).'),
535
867
  keep_merge_files: flag('Keep the temporary merge files (-K).'),
868
+ force_missing: flag('Update even when content of one side is missing (--force-missing).'),
869
+ case_sensitive: z.boolean().optional().describe('Override the case-sensitive setting (--case-sensitive).'),
870
+ width: z.number().int().nonnegative().optional().describe('Output width in columns (-W).'),
536
871
  verbose: flag('Report the state of every file (-v).'),
537
872
  workspace: workspaceParam,
538
873
  }),
539
874
  annotations: { destructiveHint: true },
540
- }, async ({ target, latest, dry_run, no_sync, set_mtime, keep_merge_files, verbose, workspace }) => {
875
+ }, async ({ target, latest, dry_run, no_sync, set_mtime, keep_merge_files, force_missing, case_sensitive, width, verbose, workspace }) => {
541
876
  const args = ['update'];
542
877
  if (latest)
543
878
  args.push('--latest');
@@ -549,6 +884,12 @@ export function registerVersionControlTools(server) {
549
884
  args.push('--setmtime');
550
885
  if (keep_merge_files)
551
886
  args.push('-K');
887
+ if (force_missing)
888
+ args.push('--force-missing');
889
+ if (case_sensitive !== undefined)
890
+ args.push('--case-sensitive', case_sensitive ? '1' : '0');
891
+ if (width !== undefined)
892
+ args.push('-W', String(width));
552
893
  if (verbose)
553
894
  args.push('-v');
554
895
  const targetValue = clean(target);
@@ -578,14 +919,27 @@ export function registerVersionControlTools(server) {
578
919
  renamed: flag('Only renamed files (--renamed).'),
579
920
  conflict: flag('Only files with merge conflicts (--conflict).'),
580
921
  meta: flag('Only files with metadata changes (--meta).'),
922
+ changed: flag('Edited and updated files together (--changed).'),
923
+ missing: flag('Only missing files (--missing).'),
924
+ unchanged: flag('Only unchanged files (--unchanged).'),
925
+ extra: flag('Only unmanaged files (--extra).'),
926
+ differ: flag('All differences against the check-out, including unmanaged files (--differ).'),
927
+ all: flag('Every managed file, i.e. all change types (--all).'),
581
928
  classify: flag('Start each line with the change type (--classify).'),
582
929
  no_merge: flag('Hide merge contributors (--no-merge).'),
930
+ ignore: z.string().min(1).optional().describe('Ignore files matching these globs (--ignore).'),
931
+ no_classify: flag('Skip the per-file change type (--no-classify).'),
932
+ merge: flag('Show only files with merge conflict markers (--merge).'),
933
+ hash: flag('Verify file status by hashing instead of size and mtime (--hash).'),
934
+ header: flag('Print the repository name above a non-empty report (--header).'),
935
+ verbose: flag('Print "(none)" when the report is empty (-v).'),
583
936
  dotfiles: flag('Include unmanaged files whose name starts with a dot (--dotfiles).'),
584
937
  absolute_paths: flag('Print absolute pathnames (--abs-paths).'),
938
+ relative_paths: flag('Print pathnames relative to the current directory (--rel-paths).'),
585
939
  workspace: workspaceParam,
586
940
  }),
587
941
  annotations: { readOnlyHint: true },
588
- }, async ({ files, edited, updated, added, deleted, renamed, conflict, meta, classify, no_merge, dotfiles, absolute_paths, workspace, }) => {
942
+ }, async ({ files, edited, updated, added, deleted, renamed, conflict, meta, changed, missing, unchanged, extra, differ, all, classify, no_merge, ignore, no_classify, merge, hash, header, verbose, dotfiles, absolute_paths, relative_paths, workspace, }) => {
589
943
  const args = ['changes'];
590
944
  const filters = [
591
945
  [edited, '--edited'],
@@ -595,6 +949,12 @@ export function registerVersionControlTools(server) {
595
949
  [renamed, '--renamed'],
596
950
  [conflict, '--conflict'],
597
951
  [meta, '--meta'],
952
+ [changed, '--changed'],
953
+ [missing, '--missing'],
954
+ [unchanged, '--unchanged'],
955
+ [extra, '--extra'],
956
+ [differ, '--differ'],
957
+ [all, '--all'],
598
958
  ];
599
959
  for (const [enabled, option] of filters)
600
960
  if (enabled)
@@ -603,10 +963,23 @@ export function registerVersionControlTools(server) {
603
963
  args.push('--classify');
604
964
  if (no_merge)
605
965
  args.push('--no-merge');
966
+ pushOption(args, '--ignore', ignore);
967
+ if (no_classify)
968
+ args.push('--no-classify');
969
+ if (merge)
970
+ args.push('--merge');
971
+ if (hash)
972
+ args.push('--hash');
973
+ if (header)
974
+ args.push('--header');
975
+ if (verbose)
976
+ args.push('-v');
606
977
  if (dotfiles)
607
978
  args.push('--dotfiles');
608
979
  if (absolute_paths)
609
980
  args.push('--abs-paths');
981
+ if (relative_paths)
982
+ args.push('--rel-paths');
610
983
  if (files?.length)
611
984
  args.push(...files);
612
985
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No changes.' });
@@ -727,12 +1100,13 @@ export function registerVersionControlTools(server) {
727
1100
  all: flag('Include closed leaves as well (-a).'),
728
1101
  closed: flag('Only closed leaves (-c).'),
729
1102
  multiple: flag('Only branches with more than one leaf (-m).'),
1103
+ recompute: flag('Recalculate the leaves instead of reading the cache (--recompute).'),
730
1104
  by_branch: flag('Order the output by branch name (--bybranch).'),
731
1105
  width: z.number().int().nonnegative().optional().describe('Output width in columns (-W); 0 means one line per entry.'),
732
1106
  workspace: workspaceParam,
733
1107
  }),
734
1108
  annotations: { readOnlyHint: true },
735
- }, async ({ all, closed, multiple, by_branch, width, workspace }) => {
1109
+ }, async ({ all, closed, multiple, recompute, by_branch, width, workspace }) => {
736
1110
  const args = ['leaves'];
737
1111
  if (all)
738
1112
  args.push('-a');
@@ -740,6 +1114,8 @@ export function registerVersionControlTools(server) {
740
1114
  args.push('-c');
741
1115
  if (multiple)
742
1116
  args.push('-m');
1117
+ if (recompute)
1118
+ args.push('--recompute');
743
1119
  if (by_branch)
744
1120
  args.push('--bybranch');
745
1121
  if (width !== undefined)
@@ -752,11 +1128,13 @@ export function registerVersionControlTools(server) {
752
1128
  inputSchema: z.object({
753
1129
  checkin: z.string().min(1).optional().describe('Check-in to start from. Omit for the check-out version.'),
754
1130
  width: z.number().int().nonnegative().optional().describe('Output width in columns (-W); 0 means one line per entry.'),
1131
+ repository: repoOptionParam,
755
1132
  workspace: workspaceParam,
756
1133
  }),
757
1134
  annotations: { readOnlyHint: true },
758
- }, async ({ checkin, width, workspace }) => {
1135
+ }, async ({ checkin, width, repository, workspace }) => {
759
1136
  const args = ['descendants'];
1137
+ pushOption(args, '-R', repository);
760
1138
  const target = clean(checkin);
761
1139
  if (target)
762
1140
  args.push(target);
@@ -846,16 +1224,18 @@ export function registerVersionControlTools(server) {
846
1224
  age: flag('Show when each file was committed (--age).'),
847
1225
  verbose: flag('Show extra information, including change status (--verbose).'),
848
1226
  time_order: flag('Sort by time instead of name (-t).'),
849
- hash: flag('Verify file status by hashing instead of size and mtime (--hash).'),
1227
+ hash: flag('Verify file status by hashing instead of size and mtime (--hash); adds --verbose.'),
1228
+ repository: repoOptionParam,
850
1229
  workspace: workspaceParam,
851
1230
  }),
852
1231
  annotations: { readOnlyHint: true },
853
- }, async ({ paths, revision, age, verbose, time_order, hash, workspace }) => {
1232
+ }, async ({ paths, revision, age, verbose, time_order, hash, repository, workspace }) => {
854
1233
  const args = ['ls'];
1234
+ pushOption(args, '-R', repository);
855
1235
  pushOption(args, '-r', revision);
856
1236
  if (age)
857
1237
  args.push('--age');
858
- if (verbose)
1238
+ if (verbose || hash)
859
1239
  args.push('-v');
860
1240
  if (time_order)
861
1241
  args.push('-t');
@@ -897,10 +1277,11 @@ export function registerVersionControlTools(server) {
897
1277
  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
1278
  inputSchema: z.object({
899
1279
  artifact: z.string().min(1).describe('Artifact hash, or a unique prefix of it.'),
1280
+ repository: repoOptionParam,
900
1281
  workspace: workspaceParam,
901
1282
  }),
902
1283
  annotations: { readOnlyHint: true },
903
- }, async ({ artifact, workspace }) => renderOutcome(await runFossil(['artifact', artifact], { workspace })));
1284
+ }, async ({ artifact, repository, workspace }) => renderOutcome(await runFossil(repository ? ['artifact', '-R', repository, artifact] : ['artifact', artifact], { workspace })));
904
1285
  server.registerTool('fossil_describe', {
905
1286
  title: 'Describe version',
906
1287
  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.',
@@ -961,29 +1342,58 @@ export function registerVersionControlTools(server) {
961
1342
  });
962
1343
  server.registerTool('fossil_unversioned', {
963
1344
  title: 'Unversioned files',
964
- description: 'List, print, add, remove or timestamp the unversioned files the repository keeps without history.',
1345
+ description: 'List, print, add, remove or timestamp the unversioned files the repository keeps without history, ' +
1346
+ 'and sync or revert them against a remote.',
965
1347
  inputSchema: z.object({
966
1348
  action: z
967
- .enum(['list', 'cat', 'add', 'remove', 'touch'])
1349
+ .enum(['list', 'cat', 'add', 'remove', 'touch', 'sync', 'revert'])
968
1350
  .default('list')
969
- .describe('list: show them; cat: print content; add/remove: change the set; touch: update timestamps.'),
1351
+ .describe('list: show them; cat: print content; add/remove: change the set; touch: update timestamps; ' +
1352
+ 'sync/revert: exchange them with a remote.'),
970
1353
  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).'),
1354
+ glob: z
1355
+ .string()
1356
+ .min(1)
1357
+ .optional()
1358
+ .describe('Match names by this glob, in `list` and `remove` (--glob).'),
1359
+ like: z
1360
+ .string()
1361
+ .min(1)
1362
+ .optional()
1363
+ .describe('Match names like this pattern, in `list` and `remove` (--like).'),
1364
+ url: z.string().min(1).optional().describe('Remote URL for `sync` and `revert`; defaults to the configured remote.'),
1365
+ mtime: z
1366
+ .string()
1367
+ .min(1)
1368
+ .optional()
1369
+ .describe('Timestamp to store instead of now, for add/remove/touch (--mtime).'),
1370
+ verbose: flag('Report extra diagnostics; used with `sync` and `revert` (-v).'),
1371
+ dry_run: flag('Show what would happen without changing anything; used with `sync` and `revert` (-n).'),
973
1372
  workspace: workspaceParam,
974
1373
  }),
975
1374
  annotations: {},
976
- }, async ({ action, files, glob, like, workspace }) => {
1375
+ }, async ({ action, files, glob, like, url, mtime, verbose, dry_run, workspace }) => {
977
1376
  const args = ['unversioned', action];
978
- pushOption(args, '--glob', glob);
979
- pushOption(args, '--like', like);
1377
+ if (action === 'list' || action === 'remove') {
1378
+ pushOption(args, '--glob', glob);
1379
+ pushOption(args, '--like', like);
1380
+ }
1381
+ pushOption(args, '--mtime', mtime);
1382
+ if (action === 'sync' || action === 'revert') {
1383
+ if (verbose)
1384
+ args.push('-v');
1385
+ if (dry_run)
1386
+ args.push('-n');
1387
+ if (url)
1388
+ args.push(url);
1389
+ }
980
1390
  if (files && files.length > 0)
981
1391
  args.push(...files);
982
- const needsFiles = action !== 'list' && !(files && files.length > 0) && !glob && !like;
983
- if (needsFiles) {
1392
+ const needsFiles = ['cat', 'add', 'touch'].includes(action);
1393
+ if (needsFiles && !(files && files.length > 0)) {
984
1394
  return {
985
1395
  isError: true,
986
- content: [{ type: 'text', text: `ERROR: action '${action}' needs \`files\`, \`glob\` or \`like\`.` }],
1396
+ content: [{ type: 'text', text: `ERROR: action '${action}' needs \`files\`.` }],
987
1397
  };
988
1398
  }
989
1399
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No unversioned files.' });
@@ -997,15 +1407,36 @@ export function registerVersionControlTools(server) {
997
1407
  .enum(['now', 'checkin', 'checkout'])
998
1408
  .default('now')
999
1409
  .describe('now: current time; checkin: last check-in that modified each file; checkout: the checked-out version.'),
1410
+ glob: z
1411
+ .string()
1412
+ .min(1)
1413
+ .optional()
1414
+ .describe('Comma-separated glob patterns, evaluated from the top of the source tree (-g).'),
1415
+ glob_file: z
1416
+ .string()
1417
+ .min(1)
1418
+ .optional()
1419
+ .describe('Fossil glob-list file to read patterns from (-G).'),
1420
+ verbose: flag('Report the globs and each file touched (-v).'),
1421
+ dry_run: flag('List the files that need touching without touching them (-n).'),
1422
+ quiet: flag('Suppress warnings about skipped unmanaged or out-of-tree files (-q).'),
1000
1423
  workspace: workspaceParam,
1001
1424
  }),
1002
1425
  annotations: {},
1003
- }, async ({ files, mode, workspace }) => {
1426
+ }, async ({ files, mode, glob, glob_file, verbose, dry_run, quiet, workspace }) => {
1004
1427
  const args = ['touch'];
1005
1428
  if (mode === 'checkin')
1006
1429
  args.push('-c');
1007
1430
  else if (mode === 'checkout')
1008
1431
  args.push('-C');
1432
+ pushOption(args, '-g', glob);
1433
+ pushOption(args, '-G', glob_file);
1434
+ if (verbose)
1435
+ args.push('-v');
1436
+ if (dry_run)
1437
+ args.push('-n');
1438
+ if (quiet)
1439
+ args.push('-q');
1009
1440
  if (files && files.length > 0)
1010
1441
  args.push(...files);
1011
1442
  return renderOutcome(await runFossil(args, { workspace }));
@@ -1016,8 +1447,21 @@ export function registerVersionControlTools(server) {
1016
1447
  inputSchema: z.object({
1017
1448
  checkin: z.string().min(1).describe('Check-in to amend, such as tip or a hash.'),
1018
1449
  comment: z.string().min(1).optional().describe('Replacement comment (-m).'),
1450
+ message_file: z
1451
+ .string()
1452
+ .min(1)
1453
+ .optional()
1454
+ .describe('File to read the replacement comment from, in the workspace (-M).'),
1019
1455
  author: z.string().min(1).optional().describe('Replacement author (--author).'),
1020
1456
  date: z.string().min(1).optional().describe('Replacement check-in time, or now (--date).'),
1457
+ bgcolor: z.string().min(1).optional().describe('Background colour for this check-in (--bgcolor).'),
1458
+ branchcolor: flag('Apply the colour to the whole branch (--branchcolor).'),
1459
+ date_override: z
1460
+ .string()
1461
+ .min(1)
1462
+ .optional()
1463
+ .describe('Change time of the control artifact (--date-override).'),
1464
+ user_override: z.string().min(1).optional().describe('Login recorded on the control artifact (--user-override).'),
1021
1465
  tag: z.array(z.string().min(1)).optional().describe('Tags to add (--tag, repeatable).'),
1022
1466
  cancel: z.array(z.string().min(1)).optional().describe('Tags to remove (--cancel, repeatable).'),
1023
1467
  branch: z.string().min(1).optional().describe('Start a branch at this check-in (--branch).'),
@@ -1027,13 +1471,19 @@ export function registerVersionControlTools(server) {
1027
1471
  workspace: workspaceParam,
1028
1472
  }),
1029
1473
  annotations: { destructiveHint: true },
1030
- }, async ({ checkin, comment, author, date, tag, cancel, branch, hide, close, dry_run, workspace }) => {
1474
+ }, async ({ checkin, comment, message_file, author, date, bgcolor, branchcolor, date_override, user_override, tag, cancel, branch, hide, close, dry_run, workspace, }) => {
1031
1475
  const args = ['amend', checkin];
1032
1476
  if (dry_run)
1033
1477
  args.push('-n');
1034
1478
  pushOption(args, '-m', comment);
1479
+ pushOption(args, '-M', message_file);
1035
1480
  pushOption(args, '--author', author);
1036
1481
  pushOption(args, '--date', date);
1482
+ pushOption(args, '--bgcolor', bgcolor);
1483
+ if (branchcolor && bgcolor)
1484
+ args.push('--branchcolor', bgcolor);
1485
+ pushOption(args, '--date-override', date_override);
1486
+ pushOption(args, '--user-override', user_override);
1037
1487
  for (const value of tag ?? [])
1038
1488
  args.push('--tag', value);
1039
1489
  for (const value of cancel ?? [])
@@ -1043,14 +1493,25 @@ export function registerVersionControlTools(server) {
1043
1493
  args.push('--hide');
1044
1494
  if (close)
1045
1495
  args.push('--close');
1046
- const changed = comment || author || date || branch || hide || close || (tag?.length ?? 0) > 0 || (cancel?.length ?? 0) > 0;
1496
+ const changed = comment ||
1497
+ message_file ||
1498
+ author ||
1499
+ date ||
1500
+ bgcolor ||
1501
+ date_override ||
1502
+ user_override ||
1503
+ branch ||
1504
+ hide ||
1505
+ close ||
1506
+ (tag?.length ?? 0) > 0 ||
1507
+ (cancel?.length ?? 0) > 0;
1047
1508
  if (!changed) {
1048
1509
  return {
1049
1510
  isError: true,
1050
1511
  content: [
1051
1512
  {
1052
1513
  type: 'text',
1053
- text: 'ERROR: pass at least one of `comment`, `author`, `date`, `tag`, `cancel`, `branch`, `hide` or `close`.',
1514
+ text: 'ERROR: pass at least one of `comment`, `message_file`, `author`, `date`, `tag`, `cancel`, `branch`, `hide` or `close`.',
1054
1515
  },
1055
1516
  ],
1056
1517
  };
@@ -1064,8 +1525,8 @@ export function registerVersionControlTools(server) {
1064
1525
  action: z.enum(['create', 'apply', 'diff']).default('create').describe('create, apply or show the patch.'),
1065
1526
  file: z.string().min(1).describe('Patch file path; relative paths resolve against the workspace.'),
1066
1527
  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).'),
1528
+ dry_run: flag('Print what `apply` would do without doing it (-n).'),
1529
+ verbose: flag('Explain what `apply` does (-v).'),
1069
1530
  workspace: workspaceParam,
1070
1531
  }),
1071
1532
  annotations: { destructiveHint: true },
@@ -1073,10 +1534,12 @@ export function registerVersionControlTools(server) {
1073
1534
  const args = ['patch', action];
1074
1535
  if (force)
1075
1536
  args.push('-f');
1076
- if (dry_run)
1077
- args.push('-n');
1078
- if (verbose)
1079
- args.push('-v');
1537
+ if (action === 'apply') {
1538
+ if (dry_run)
1539
+ args.push('-n');
1540
+ if (verbose)
1541
+ args.push('-v');
1542
+ }
1080
1543
  args.push(file);
1081
1544
  return renderOutcome(await runFossil(args, { workspace }));
1082
1545
  });
@@ -1132,11 +1595,16 @@ export function registerVersionControlTools(server) {
1132
1595
  .string()
1133
1596
  .min(1)
1134
1597
  .optional()
1135
- .describe('Repository database to query instead of the one of the check-out (-R).'),
1598
+ .describe('Repository database file, e.g. `repos/app.fossil`, to query instead of the one of the check-out (-R).'),
1599
+ database: z
1600
+ .string()
1601
+ .min(1)
1602
+ .optional()
1603
+ .describe('Standalone SQLite file to query in place of a repository (--no-repository), e.g. a chat archive.'),
1136
1604
  workspace: workspaceParam,
1137
1605
  }),
1138
1606
  annotations: { readOnlyHint: true },
1139
- }, async ({ query, repository, workspace }) => {
1607
+ }, async ({ query, repository, database, workspace }) => {
1140
1608
  const trimmed = query.trim().replace(/;+\s*$/, '');
1141
1609
  if (!/^(select|with|pragma|explain)\b/i.test(trimmed)) {
1142
1610
  return {
@@ -1149,7 +1617,7 @@ export function registerVersionControlTools(server) {
1149
1617
  ],
1150
1618
  };
1151
1619
  }
1152
- const result = await runSql(trimmed, { workspace, readonly: true, repository });
1620
+ const result = await runSql(trimmed, { workspace, readonly: true, repository, database });
1153
1621
  if (!result.ok)
1154
1622
  return { isError: true, content: [{ type: 'text', text: result.error }] };
1155
1623
  if (result.rows.length === 0)