@stellar_ai/mcp_fossil_scm 0.2.0 → 0.2.2

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.
@@ -1,10 +1,11 @@
1
- import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
2
- import path from 'node:path';
3
1
  import { z } from 'zod';
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';
2
+ import { renderOutcome, renderSections, runFossil } from '../core/fossil.js';
7
3
  import { clean, workspaceParam, filesParam, flag, pushOption } from './common.js';
4
+ const repoOptionParam = z
5
+ .string()
6
+ .min(1)
7
+ .optional()
8
+ .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
9
  /** Version-control tools: status, diff, history, commit, branch and workspace state. */
9
10
  /** Join glob patterns into one fossil GLOBLIST argument, quoting patterns that hold a comma. */
10
11
  function globList(patterns) {
@@ -15,8 +16,7 @@ function globList(patterns) {
15
16
  export function registerVersionControlTools(server) {
16
17
  server.registerTool('fossil_status', {
17
18
  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.',
19
+ description: 'Show the change set of the check-out (modified/added/deleted files) plus the list of untracked files.',
20
20
  inputSchema: z.object({
21
21
  dotfiles: flag('Include dot-files in the change and untracked lists (--dotfiles).'),
22
22
  brief: flag('List only the changed file names (fossil changes).'),
@@ -85,10 +85,10 @@ export function registerVersionControlTools(server) {
85
85
  extraArgs.push('--abs-paths');
86
86
  if (rel_paths)
87
87
  extraArgs.push('--rel-paths');
88
- const [status, extra] = await Promise.all([
89
- runFossil(args, { workspace }),
90
- runFossil(extraArgs, { workspace }),
91
- ]);
88
+ // Sequential: two fossil processes on the same repository can collide on
89
+ // the SQLite write lock ("database is locked").
90
+ const status = await runFossil(args, { workspace });
91
+ const extra = await runFossil(extraArgs, { workspace });
92
92
  return renderSections([
93
93
  { title: 'STATUS', outcome: status },
94
94
  { title: 'UNTRACKED (EXTRA)', outcome: extra },
@@ -111,6 +111,8 @@ export function registerVersionControlTools(server) {
111
111
  undo: flag('Diff against the undo buffer (--undo).'),
112
112
  ignore_whitespace: flag('Ignore whitespace-only changes (-w).'),
113
113
  ignore_trailing_space: flag('Ignore changes to end-of-line whitespace (-Z).'),
114
+ strip_trailing_cr: flag('Treat CR at the end of each line as insignificant (--strip-trailing-cr).'),
115
+ new_file: flag('Treat added files as if they already existed with empty content (-N).'),
114
116
  internal: flag('Use the internal diff logic (-i).'),
115
117
  unified: flag('Print a unified diff (--unified).'),
116
118
  versions_header: flag('Show the compared versions in the diff header (-h).'),
@@ -119,7 +121,7 @@ export function registerVersionControlTools(server) {
119
121
  workspace: workspaceParam,
120
122
  }),
121
123
  annotations: { readOnlyHint: true },
122
- }, async ({ from_version, to_version, files, branch, checkin, brief, stat, context: contextLines, side_by_side, verbose, undo, ignore_whitespace, ignore_trailing_space, internal, unified, versions_header, json, width, workspace, }) => {
124
+ }, 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, }) => {
123
125
  const args = ['diff'];
124
126
  pushOption(args, '--from', from_version);
125
127
  pushOption(args, '--to', to_version);
@@ -141,6 +143,10 @@ export function registerVersionControlTools(server) {
141
143
  args.push('-w');
142
144
  if (ignore_trailing_space)
143
145
  args.push('-Z');
146
+ if (strip_trailing_cr)
147
+ args.push('--strip-trailing-cr');
148
+ if (new_file)
149
+ args.push('-N');
144
150
  if (internal)
145
151
  args.push('-i');
146
152
  if (unified)
@@ -155,20 +161,6 @@ export function registerVersionControlTools(server) {
155
161
  args.push(...files);
156
162
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No differences found.' });
157
163
  });
158
- server.registerTool('fossil_cat', {
159
- title: 'Cat file revision',
160
- description: 'Print the content of a file at a given revision.',
161
- inputSchema: z.object({
162
- file: z.string().min(1).describe('File path/name inside the repository.'),
163
- revision: z.string().min(1).optional().describe('Check-in or revision (-r). Defaults to the checked-out version.'),
164
- workspace: workspaceParam,
165
- }),
166
- annotations: { readOnlyHint: true },
167
- }, async ({ file, revision, workspace }) => {
168
- const args = ['cat', file];
169
- pushOption(args, '-r', revision);
170
- return renderOutcome(await runFossil(args, { workspace }));
171
- });
172
164
  server.registerTool('fossil_finfo', {
173
165
  title: 'File history',
174
166
  description: 'Show the change history of one file, or switch to the artifact facts, status line or file content view.',
@@ -385,6 +377,20 @@ export function registerVersionControlTools(server) {
385
377
  branch: z.string().min(1).optional().describe('Place the new check-in on this branch (--branch).'),
386
378
  no_warnings: flag('Omit content warnings (--no-warnings).'),
387
379
  allow_empty: flag('Allow a check-in with no file changes (--allow-empty).'),
380
+ allow_fork: flag('Allow the check-in to fork the branch (--allow-fork).'),
381
+ allow_conflict: flag('Commit with unresolved merge conflicts (--allow-conflict).'),
382
+ allow_older: flag('Store a timestamp older than the ancestor check-in (--allow-older).'),
383
+ integrate: flag('Close every branch merged into this one (--integrate).'),
384
+ private_checkin: flag('Keep the check-in out of pushes (--private).'),
385
+ hash: flag('Detect file changes by hashing instead of size+mtime (--hash).'),
386
+ no_verify: flag('Skip the before-commit hooks (--no-verify).'),
387
+ dry_run: flag('Show what would be committed without writing (--dry-run).'),
388
+ message_file: z
389
+ .string()
390
+ .min(1)
391
+ .optional()
392
+ .describe('Read the commit message from this file (-M); takes precedence over `message`.'),
393
+ mimetype: z.string().min(1).optional().describe('Mimetype of the commit message (--mimetype).'),
388
394
  user_override: z.string().min(1).optional().describe('Record this login as the author (--user-override).'),
389
395
  tags: z.array(z.string().min(1)).optional().describe('Tags to attach to the new check-in (--tag).'),
390
396
  close: flag('Close the branch being committed (--close).'),
@@ -396,13 +402,31 @@ export function registerVersionControlTools(server) {
396
402
  .describe('Check-in timestamp to store instead of now, e.g. "2026-11-17 12:00:00" (--date-override).'),
397
403
  workspace: workspaceParam,
398
404
  }),
399
- }, async ({ message, files, branch, no_warnings, allow_empty, user_override, tags, close, bgcolor, date_override, workspace }) => {
405
+ }, 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 }) => {
400
406
  const args = ['commit', '-m', message];
401
- pushOption(args, '--branch', branch);
407
+ pushOption(args, '-M', message_file);
408
+ pushOption(args, '--mimetype', mimetype);
402
409
  if (no_warnings)
403
410
  args.push('--no-warnings');
404
411
  if (allow_empty)
405
412
  args.push('--allow-empty');
413
+ if (allow_fork)
414
+ args.push('--allow-fork');
415
+ if (allow_conflict)
416
+ args.push('--allow-conflict');
417
+ if (allow_older)
418
+ args.push('--allow-older');
419
+ if (integrate)
420
+ args.push('--integrate');
421
+ if (private_checkin)
422
+ args.push('--private');
423
+ if (hash)
424
+ args.push('--hash');
425
+ if (no_verify)
426
+ args.push('--no-verify');
427
+ if (dry_run)
428
+ args.push('--dry-run');
429
+ pushOption(args, '--branch', branch);
406
430
  if (close)
407
431
  args.push('--close');
408
432
  pushOption(args, '--bgcolor', bgcolor);
@@ -577,11 +601,16 @@ export function registerVersionControlTools(server) {
577
601
  temp: flag('Remove only Fossil-generated temporary files (--temp).'),
578
602
  dirs_only: flag('Remove empty directories only, no files (--dirsonly).'),
579
603
  empty_dirs: flag('Remove empty directories after deleting files (--emptydirs).'),
604
+ keep: z.string().min(1).optional().describe('Comma-separated globs of files to spare beyond ignore-glob (--keep).'),
605
+ disable_undo: flag('Do not keep a copy that `fossil undo` can restore (--disable-undo).'),
606
+ all_checkouts: flag('Apply the empty-directory scan to every open check-out (--allckouts).'),
607
+ prompt: flag('Ask before deleting each file (-i).'),
608
+ case_sensitive: z.boolean().optional().describe('Override the case-sensitive setting (--case-sensitive).'),
580
609
  verbose: flag('Report each file as it is removed (-v).'),
581
610
  workspace: workspaceParam,
582
611
  }),
583
612
  annotations: { destructiveHint: true },
584
- }, async ({ all_files, dry_run, dotfiles, ignore, clean: cleanGlob, verily, temp, dirs_only, empty_dirs, verbose, workspace }) => {
613
+ }, 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 }) => {
585
614
  const args = ['clean'];
586
615
  if (dry_run)
587
616
  args.push('-n');
@@ -601,6 +630,16 @@ export function registerVersionControlTools(server) {
601
630
  args.push('--dirsonly');
602
631
  if (empty_dirs)
603
632
  args.push('--emptydirs');
633
+ if (keep)
634
+ args.push('--keep', keep);
635
+ if (disable_undo)
636
+ args.push('--disable-undo');
637
+ if (all_checkouts)
638
+ args.push('--allckouts');
639
+ if (prompt)
640
+ args.push('-i');
641
+ if (case_sensitive !== undefined)
642
+ args.push('--case-sensitive', case_sensitive ? '1' : '0');
604
643
  if (verbose)
605
644
  args.push('-v');
606
645
  return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'Nothing to clean.' });
@@ -631,11 +670,13 @@ export function registerVersionControlTools(server) {
631
670
  verbose: flag('List the files changed by each check-in (-v).'),
632
671
  offset: z.number().int().min(0).optional().describe('Skip this many entries before reporting (--offset).'),
633
672
  width: z.number().int().min(20).optional().describe('Width of the output lines (-W).'),
673
+ repository: repoOptionParam,
634
674
  workspace: workspaceParam,
635
675
  }),
636
676
  annotations: { readOnlyHint: true },
637
- }, async ({ limit, path: targetPath, type_filter, branch, current_branch, when, checkin, format, verbose, offset, width, workspace, }) => {
677
+ }, async ({ limit, path: targetPath, type_filter, branch, current_branch, when, checkin, format, verbose, offset, width, repository, workspace, }) => {
638
678
  const args = ['timeline', '-n', String(limit ?? 20)];
679
+ pushOption(args, '-R', repository);
639
680
  pushOption(args, '-p', targetPath);
640
681
  pushOption(args, '-t', type_filter);
641
682
  pushOption(args, '-b', branch);
@@ -660,12 +701,14 @@ export function registerVersionControlTools(server) {
660
701
  inputSchema: z.object({
661
702
  target: z.string().optional().describe('File name, check-in hash or branch. Omit for general repository info.'),
662
703
  verbose: flag('Show extra details, such as the SQLite version and repository size (-v).'),
704
+ repository: repoOptionParam,
663
705
  workspace: workspaceParam,
664
706
  }),
665
707
  annotations: { readOnlyHint: true },
666
- }, async ({ target, verbose, workspace }) => {
708
+ }, async ({ target, verbose, repository, workspace }) => {
667
709
  const targetValue = clean(target);
668
710
  const args = targetValue ? ['info', targetValue] : ['info'];
711
+ pushOption(args, '-R', repository);
669
712
  if (verbose)
670
713
  args.push('-v');
671
714
  return renderOutcome(await runFossil(args, { workspace }));
@@ -803,11 +846,13 @@ export function registerVersionControlTools(server) {
803
846
  set_mtime: flag('Stamp every file with its last-check-in time (--setmtime).'),
804
847
  keep_merge_files: flag('Keep the temporary merge files (-K).'),
805
848
  force_missing: flag('Update even when content of one side is missing (--force-missing).'),
849
+ case_sensitive: z.boolean().optional().describe('Override the case-sensitive setting (--case-sensitive).'),
850
+ width: z.number().int().nonnegative().optional().describe('Output width in columns (-W).'),
806
851
  verbose: flag('Report the state of every file (-v).'),
807
852
  workspace: workspaceParam,
808
853
  }),
809
854
  annotations: { destructiveHint: true },
810
- }, async ({ target, latest, dry_run, no_sync, set_mtime, keep_merge_files, force_missing, verbose, workspace }) => {
855
+ }, async ({ target, latest, dry_run, no_sync, set_mtime, keep_merge_files, force_missing, case_sensitive, width, verbose, workspace }) => {
811
856
  const args = ['update'];
812
857
  if (latest)
813
858
  args.push('--latest');
@@ -821,6 +866,10 @@ export function registerVersionControlTools(server) {
821
866
  args.push('-K');
822
867
  if (force_missing)
823
868
  args.push('--force-missing');
869
+ if (case_sensitive !== undefined)
870
+ args.push('--case-sensitive', case_sensitive ? '1' : '0');
871
+ if (width !== undefined)
872
+ args.push('-W', String(width));
824
873
  if (verbose)
825
874
  args.push('-v');
826
875
  const targetValue = clean(target);
@@ -858,6 +907,9 @@ export function registerVersionControlTools(server) {
858
907
  all: flag('Every managed file, i.e. all change types (--all).'),
859
908
  classify: flag('Start each line with the change type (--classify).'),
860
909
  no_merge: flag('Hide merge contributors (--no-merge).'),
910
+ ignore: z.string().min(1).optional().describe('Ignore files matching these globs (--ignore).'),
911
+ no_classify: flag('Skip the per-file change type (--no-classify).'),
912
+ merge: flag('Show only files with merge conflict markers (--merge).'),
861
913
  hash: flag('Verify file status by hashing instead of size and mtime (--hash).'),
862
914
  header: flag('Print the repository name above a non-empty report (--header).'),
863
915
  verbose: flag('Print "(none)" when the report is empty (-v).'),
@@ -867,7 +919,7 @@ export function registerVersionControlTools(server) {
867
919
  workspace: workspaceParam,
868
920
  }),
869
921
  annotations: { readOnlyHint: true },
870
- }, async ({ files, edited, updated, added, deleted, renamed, conflict, meta, changed, missing, unchanged, extra, differ, all, classify, no_merge, hash, header, verbose, dotfiles, absolute_paths, relative_paths, workspace, }) => {
922
+ }, 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, }) => {
871
923
  const args = ['changes'];
872
924
  const filters = [
873
925
  [edited, '--edited'],
@@ -891,6 +943,11 @@ export function registerVersionControlTools(server) {
891
943
  args.push('--classify');
892
944
  if (no_merge)
893
945
  args.push('--no-merge');
946
+ pushOption(args, '--ignore', ignore);
947
+ if (no_classify)
948
+ args.push('--no-classify');
949
+ if (merge)
950
+ args.push('--merge');
894
951
  if (hash)
895
952
  args.push('--hash');
896
953
  if (header)
@@ -943,63 +1000,6 @@ export function registerVersionControlTools(server) {
943
1000
  args.push(file);
944
1001
  return renderOutcome(await runFossil(args, { workspace }));
945
1002
  });
946
- server.registerTool('fossil_grep', {
947
- title: 'Grep history',
948
- description: 'Match a POSIX extended regular expression over every historical version of the named files, ' +
949
- 'starting at the newest version of each file.',
950
- inputSchema: z.object({
951
- pattern: z.string().min(1).describe('POSIX extended regular expression.'),
952
- files: z.array(z.string().min(1)).min(1).describe('Files to search, newest version first.'),
953
- ignore_case: flag('Case-insensitive match (-i).'),
954
- count: flag('Print the number of matching files only (-c).'),
955
- files_with_matches: flag('Print one artifact hash per matching file instead of the lines (-l).'),
956
- once: flag('Stop at the first match (--once).'),
957
- invert_match: flag('Show only files without a match (-v).'),
958
- no_messages: flag('Suppress messages about unreadable files (-s).'),
959
- verbose: flag('Report each file as it is analysed (--verbose).'),
960
- workspace: workspaceParam,
961
- }),
962
- annotations: { readOnlyHint: true },
963
- }, async ({ pattern, files, ignore_case, count, files_with_matches, once, invert_match, no_messages, verbose, workspace, }) => {
964
- const args = ['grep'];
965
- if (ignore_case)
966
- args.push('-i');
967
- if (count)
968
- args.push('-c');
969
- if (files_with_matches)
970
- args.push('-l');
971
- if (once)
972
- args.push('--once');
973
- if (invert_match)
974
- args.push('-v');
975
- if (no_messages)
976
- args.push('-s');
977
- if (verbose)
978
- args.push('--verbose');
979
- args.push(pattern, ...files);
980
- return renderOutcome(await runFossil(args, { workspace }), { emptyText: 'No matches.' });
981
- });
982
- server.registerTool('fossil_whatis', {
983
- title: 'What is',
984
- description: 'Resolve a name (tag, branch, hash prefix, or with file: the content hash) to its artifact hash and role.',
985
- inputSchema: z.object({
986
- name: z.string().min(1).describe('Symbol to resolve: tag, branch, hash prefix or filename.'),
987
- file: flag('Treat name as a file whose content hash is looked up (-f).'),
988
- type: z.enum(['ci', 't', 'w', 'g', 'e']).optional().describe('Only match this artifact type (--type).'),
989
- verbose: flag('Include the internal record id (-v).'),
990
- workspace: workspaceParam,
991
- }),
992
- annotations: { readOnlyHint: true },
993
- }, async ({ name, file, type, verbose, workspace }) => {
994
- const args = ['whatis'];
995
- if (file)
996
- args.push('-f');
997
- pushOption(args, '--type', type);
998
- if (verbose)
999
- args.push('-v');
1000
- args.push(name);
1001
- return renderOutcome(await runFossil(args, { workspace }));
1002
- });
1003
1003
  server.registerTool('fossil_merge_base', {
1004
1004
  title: 'Merge base',
1005
1005
  description: 'Find the common ancestor check-in of two or more versions, as a hypothetical merge would.',
@@ -1023,12 +1023,13 @@ export function registerVersionControlTools(server) {
1023
1023
  all: flag('Include closed leaves as well (-a).'),
1024
1024
  closed: flag('Only closed leaves (-c).'),
1025
1025
  multiple: flag('Only branches with more than one leaf (-m).'),
1026
+ recompute: flag('Recalculate the leaves instead of reading the cache (--recompute).'),
1026
1027
  by_branch: flag('Order the output by branch name (--bybranch).'),
1027
1028
  width: z.number().int().nonnegative().optional().describe('Output width in columns (-W); 0 means one line per entry.'),
1028
1029
  workspace: workspaceParam,
1029
1030
  }),
1030
1031
  annotations: { readOnlyHint: true },
1031
- }, async ({ all, closed, multiple, by_branch, width, workspace }) => {
1032
+ }, async ({ all, closed, multiple, recompute, by_branch, width, workspace }) => {
1032
1033
  const args = ['leaves'];
1033
1034
  if (all)
1034
1035
  args.push('-a');
@@ -1036,6 +1037,8 @@ export function registerVersionControlTools(server) {
1036
1037
  args.push('-c');
1037
1038
  if (multiple)
1038
1039
  args.push('-m');
1040
+ if (recompute)
1041
+ args.push('--recompute');
1039
1042
  if (by_branch)
1040
1043
  args.push('--bybranch');
1041
1044
  if (width !== undefined)
@@ -1048,11 +1051,13 @@ export function registerVersionControlTools(server) {
1048
1051
  inputSchema: z.object({
1049
1052
  checkin: z.string().min(1).optional().describe('Check-in to start from. Omit for the check-out version.'),
1050
1053
  width: z.number().int().nonnegative().optional().describe('Output width in columns (-W); 0 means one line per entry.'),
1054
+ repository: repoOptionParam,
1051
1055
  workspace: workspaceParam,
1052
1056
  }),
1053
1057
  annotations: { readOnlyHint: true },
1054
- }, async ({ checkin, width, workspace }) => {
1058
+ }, async ({ checkin, width, repository, workspace }) => {
1055
1059
  const args = ['descendants'];
1060
+ pushOption(args, '-R', repository);
1056
1061
  const target = clean(checkin);
1057
1062
  if (target)
1058
1063
  args.push(target);
@@ -1071,68 +1076,6 @@ export function registerVersionControlTools(server) {
1071
1076
  }, async ({ all, workspace }) => renderOutcome(await runFossil(all ? ['unpublished', '--all'] : ['unpublished'], { workspace }), {
1072
1077
  emptyText: 'No unpublished artifacts.',
1073
1078
  }));
1074
- server.registerTool('fossil_ignore_from_gitignore', {
1075
- title: 'Ignore glob from .gitignore',
1076
- description: 'Convert a .gitignore file into the ignore-glob patterns Fossil matches against check-out paths, ' +
1077
- 'and optionally write them to .fossil-settings/ignore-glob.',
1078
- inputSchema: z.object({
1079
- source: z.string().min(1).default('.gitignore').describe('File to convert, relative to the workspace.'),
1080
- write: flag('Write the patterns to .fossil-settings/ignore-glob.'),
1081
- overwrite: flag('Replace an existing .fossil-settings/ignore-glob.'),
1082
- workspace: workspaceParam,
1083
- }),
1084
- }, async ({ source, write, overwrite, workspace }) => {
1085
- const root = resolveWorkspace(workspace);
1086
- const sourcePath = path.resolve(root, source);
1087
- const relative = path.relative(root, sourcePath);
1088
- if (relative.startsWith('..') || path.isAbsolute(relative)) {
1089
- return {
1090
- content: [{ type: 'text', text: `ERROR: \`source\` must stay inside the workspace (${root}).` }],
1091
- isError: true,
1092
- };
1093
- }
1094
- let content;
1095
- try {
1096
- content = await readFile(sourcePath, 'utf8');
1097
- }
1098
- catch (error) {
1099
- const code = error.code ?? 'unknown error';
1100
- return {
1101
- content: [{ type: 'text', text: `ERROR: cannot read ${relative}: ${code}.` }],
1102
- isError: true,
1103
- };
1104
- }
1105
- const directory = path.dirname(relative);
1106
- const conversion = convertGitignore(content, { prefix: directory === '.' ? '' : directory });
1107
- const lines = [
1108
- `Converted ${conversion.lineCount} rules from ${relative} into ${conversion.patterns.length} ignore-glob patterns.`,
1109
- '',
1110
- ...conversion.patterns,
1111
- ];
1112
- if (conversion.warnings.length > 0) {
1113
- lines.push('', ...conversion.warnings.map((warning) => `NOTE: ${warning}.`));
1114
- }
1115
- if (!write)
1116
- return { content: [{ type: 'text', text: lines.join('\n') }] };
1117
- const settingsDir = path.join(root, '.fossil-settings');
1118
- const target = path.join(settingsDir, 'ignore-glob');
1119
- const exists = await stat(target).then(() => true, () => false);
1120
- if (exists && !overwrite) {
1121
- return {
1122
- content: [
1123
- {
1124
- type: 'text',
1125
- text: 'ERROR: .fossil-settings/ignore-glob already exists; pass `overwrite: true` to replace it.',
1126
- },
1127
- ],
1128
- isError: true,
1129
- };
1130
- }
1131
- await mkdir(settingsDir, { recursive: true });
1132
- await writeFile(target, renderGlobFile(conversion), 'utf8');
1133
- lines.splice(1, 0, 'Wrote .fossil-settings/ignore-glob.');
1134
- return { content: [{ type: 'text', text: lines.join('\n') }] };
1135
- });
1136
1079
  server.registerTool('fossil_ls', {
1137
1080
  title: 'List files',
1138
1081
  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.',
@@ -1143,11 +1086,13 @@ export function registerVersionControlTools(server) {
1143
1086
  verbose: flag('Show extra information, including change status (--verbose).'),
1144
1087
  time_order: flag('Sort by time instead of name (-t).'),
1145
1088
  hash: flag('Verify file status by hashing instead of size and mtime (--hash); adds --verbose.'),
1089
+ repository: repoOptionParam,
1146
1090
  workspace: workspaceParam,
1147
1091
  }),
1148
1092
  annotations: { readOnlyHint: true },
1149
- }, async ({ paths, revision, age, verbose, time_order, hash, workspace }) => {
1093
+ }, async ({ paths, revision, age, verbose, time_order, hash, repository, workspace }) => {
1150
1094
  const args = ['ls'];
1095
+ pushOption(args, '-R', repository);
1151
1096
  pushOption(args, '-r', revision);
1152
1097
  if (age)
1153
1098
  args.push('--age');
@@ -1161,42 +1106,6 @@ export function registerVersionControlTools(server) {
1161
1106
  args.push(...paths);
1162
1107
  return renderOutcome(await runFossil(args, { workspace }));
1163
1108
  });
1164
- server.registerTool('fossil_search', {
1165
- title: 'Search timeline',
1166
- description: 'Search check-in and other timeline comments for every given word and print the best matches.',
1167
- inputSchema: z.object({
1168
- pattern: z.string().min(1).describe('Words to look for; all of them must match.'),
1169
- all: flag('Print every match instead of only the best scoring ones (--all).'),
1170
- limit: z.number().int().min(1).optional().describe('Maximum number of matches (-n).'),
1171
- width: z.number().int().min(0).optional().describe('Output width in columns; 0 means no wrapping (-W).'),
1172
- workspace: workspaceParam,
1173
- }),
1174
- annotations: { readOnlyHint: true },
1175
- }, async ({ pattern, all, limit, width, workspace }) => {
1176
- const args = ['search'];
1177
- if (all)
1178
- args.push('-a');
1179
- if (limit !== undefined)
1180
- args.push('-n', String(limit));
1181
- if (width !== undefined)
1182
- args.push('-W', String(width));
1183
- args.push(pattern);
1184
- const outcome = await runFossil(args, { workspace });
1185
- // fossil reports an empty result set as "+++ no more data (0) +++".
1186
- if (outcome.ok && /^\+{3} no more data \(0\) \+{3}$/.test(outcome.stdout.trim())) {
1187
- return { content: [{ type: 'text', text: 'No matches.' }] };
1188
- }
1189
- return renderOutcome(outcome, { emptyText: 'No matches.' });
1190
- });
1191
- server.registerTool('fossil_artifact', {
1192
- title: 'Artifact content',
1193
- 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.',
1194
- inputSchema: z.object({
1195
- artifact: z.string().min(1).describe('Artifact hash, or a unique prefix of it.'),
1196
- workspace: workspaceParam,
1197
- }),
1198
- annotations: { readOnlyHint: true },
1199
- }, async ({ artifact, workspace }) => renderOutcome(await runFossil(['artifact', artifact], { workspace })));
1200
1109
  server.registerTool('fossil_describe', {
1201
1110
  title: 'Describe version',
1202
1111
  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.',
@@ -1501,53 +1410,4 @@ export function registerVersionControlTools(server) {
1501
1410
  }
1502
1411
  return renderOutcome(await runFossil(args, { workspace }));
1503
1412
  });
1504
- server.registerTool('fossil_sql', {
1505
- title: 'SQL query',
1506
- 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`.',
1507
- inputSchema: z.object({
1508
- query: z.string().min(1).describe('SQL statement, e.g. "SELECT name FROM blob LIMIT 5".'),
1509
- repository: z
1510
- .string()
1511
- .min(1)
1512
- .optional()
1513
- .describe('Repository database to query instead of the one of the check-out (-R).'),
1514
- workspace: workspaceParam,
1515
- }),
1516
- annotations: { readOnlyHint: true },
1517
- }, async ({ query, repository, workspace }) => {
1518
- const trimmed = query.trim().replace(/;+\s*$/, '');
1519
- if (!/^(select|with|pragma|explain)\b/i.test(trimmed)) {
1520
- return {
1521
- isError: true,
1522
- content: [
1523
- {
1524
- type: 'text',
1525
- text: 'ERROR: the query must start with SELECT, WITH, PRAGMA or EXPLAIN.',
1526
- },
1527
- ],
1528
- };
1529
- }
1530
- const result = await runSql(trimmed, { workspace, readonly: true, repository });
1531
- if (!result.ok)
1532
- return { isError: true, content: [{ type: 'text', text: result.error }] };
1533
- if (result.rows.length === 0)
1534
- return { content: [{ type: 'text', text: 'No rows.' }] };
1535
- const columns = Object.keys(result.rows[0] ?? {});
1536
- const cell = (value) => {
1537
- if (value === null || value === undefined)
1538
- return 'NULL';
1539
- if (typeof value === 'object')
1540
- return JSON.stringify(value);
1541
- return String(value);
1542
- };
1543
- const lines = [columns.join('\t'), ...result.rows.map((row) => columns.map((column) => cell(row[column])).join('\t'))];
1544
- return {
1545
- content: [
1546
- {
1547
- type: 'text',
1548
- text: truncateOutput(`${lines.join('\n')}\n\n${result.rows.length} row(s).`),
1549
- },
1550
- ],
1551
- };
1552
- });
1553
1413
  }
package/docs/README.md CHANGED
@@ -1,16 +1,17 @@
1
1
  # 文件索引
2
2
 
3
3
  按能力分冊,每冊包含:能力概覽表、通用約定、逐工具的參數表與真實 argv/輸出、典型流程、已知邊界、原始碼位置。
4
- 所有內容在 fossil 2.21 + `@stellar_ai/mcp_fossil_scm@0.2.0` 上實測。
4
+ 所有內容在 fossil 2.21 + `@stellar_ai/mcp_fossil_scm@0.2.2` 上實測。
5
5
 
6
6
  | 文件 | 能力 | `-c` | 工具數 |
7
7
  | --- | --- | --- | --- |
8
8
  | [admin.md](./admin.md) | 倉庫管理 | `a` | 11 |
9
- | [vcs.md](./vcs.md) | 版本控制:status / diff / commit / branch / blame / grep / … | `v` | 40 |
10
- | [forum.md](./forum.md) | 論壇 | `f` | 3 |
9
+ | [utils.md](./utils.md) | 通用工具:cat / grep / whatis / search / artifact / sql / .gitignore 轉換 | `u` | 7 |
10
+ | [vcs.md](./vcs.md) | 版本控制:status / diff / commit / branch / blame / … | `v` | 33 |
11
11
  | [tickets.md](./tickets.md) | 工單 | `t` | 4 |
12
- | [wiki.md](./wiki.md) | Wiki 頁面 | `w` | 3 |
13
12
  | [chat.md](./chat.md) | 聊天室 | `c` | 4 |
13
+ | [forum.md](./forum.md) | 論壇 | `f` | 3 |
14
+ | [wiki.md](./wiki.md) | Wiki 頁面 | `w` | 3 |
14
15
  | [prompts.md](./prompts.md) | MCP 提示(`prompts/list` / `prompts/get`) | — | 8 |
15
16
 
16
17
  合計 65 個工具;`-c All` 啟用全部。
@@ -19,7 +20,7 @@
19
20
 
20
21
  1. [admin.md](./admin.md) §2 —— `workspace` 與 `repository` 兩個概念,所有能力共用,先看這裡。
21
22
  2. [prompts.md](./prompts.md) —— 內建的 MCP 提示,把常用的多步流程寫成一段指示。
22
- 3. 然後按需跳到具體能力分冊。VCS 與內容類能力(`v/f/t/w/c`)以 check-out 為前提;`fossil_sql` 可用 `repository` 直接查詢。
23
+ 3. 然後按需跳到具體能力分冊。VCS 與內容類能力(`v/t/c/f/w`)以 check-out 為前提;`fossil_cat`、`fossil_artifact`、`fossil_sql`、`fossil_rebuild` 與部分 VCS 只讀工具可用 `repository` 直接讀倉庫檔。
23
24
 
24
25
  ## 約定速查
25
26