@j0hanz/filesystem-mcp 1.13.1 → 1.14.0

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.
Files changed (65) hide show
  1. package/README.md +117 -100
  2. package/dist/completions.d.ts +0 -11
  3. package/dist/completions.js +1 -1
  4. package/dist/config.d.ts +0 -1
  5. package/dist/lib/constants.d.ts +0 -1
  6. package/dist/lib/constants.js +0 -1
  7. package/dist/lib/errors.d.ts +0 -1
  8. package/dist/lib/errors.js +5 -9
  9. package/dist/lib/file-operations/core.d.ts +3 -2
  10. package/dist/lib/file-operations/metadata.js +9 -3
  11. package/dist/lib/file-operations/search.d.ts +1 -59
  12. package/dist/lib/file-operations/search.js +9 -22
  13. package/dist/lib/file-operations/traversal.d.ts +2 -2
  14. package/dist/lib/fs-helpers.d.ts +1 -2
  15. package/dist/lib/fs-helpers.js +10 -12
  16. package/dist/lib/globs.d.ts +2 -0
  17. package/dist/lib/globs.js +19 -0
  18. package/dist/lib/paths.d.ts +0 -3
  19. package/dist/lib/paths.js +1 -4
  20. package/dist/lib/utils.d.ts +4 -4
  21. package/dist/lib/utils.js +1 -10
  22. package/dist/lib/zod-codecs.d.ts +2 -0
  23. package/dist/lib/zod-codecs.js +18 -0
  24. package/dist/pkg-info.d.ts +1 -0
  25. package/dist/pkg-info.js +2 -2
  26. package/dist/prompts.js +3 -3
  27. package/dist/resources/generated-instructions.js +3 -12
  28. package/dist/resources/tool-catalog.js +10 -41
  29. package/dist/resources/tool-info.d.ts +0 -1
  30. package/dist/resources/tool-info.js +24 -39
  31. package/dist/resources/workflows.js +8 -1
  32. package/dist/schemas.d.ts +179 -481
  33. package/dist/schemas.js +156 -169
  34. package/dist/server/bootstrap.d.ts +0 -10
  35. package/dist/server/bootstrap.js +3 -3
  36. package/dist/server/roots-manager.js +1 -1
  37. package/dist/tools/apply-patch.js +19 -8
  38. package/dist/tools/calculate-hash.js +3 -5
  39. package/dist/tools/create-directory.d.ts +1 -4
  40. package/dist/tools/create-directory.js +2 -2
  41. package/dist/tools/delete-file.js +2 -4
  42. package/dist/tools/diff-files.js +1 -3
  43. package/dist/tools/edit-file.d.ts +1 -7
  44. package/dist/tools/edit-file.js +6 -3
  45. package/dist/tools/list-directory.js +10 -15
  46. package/dist/tools/move-file.d.ts +1 -4
  47. package/dist/tools/move-file.js +15 -27
  48. package/dist/tools/read-multiple.js +12 -7
  49. package/dist/tools/read.js +1 -2
  50. package/dist/tools/replace-in-files.d.ts +1 -10
  51. package/dist/tools/replace-in-files.js +62 -97
  52. package/dist/tools/roots.js +2 -6
  53. package/dist/tools/search-content.js +152 -188
  54. package/dist/tools/search-files.js +10 -13
  55. package/dist/tools/shared.d.ts +10 -3
  56. package/dist/tools/shared.js +53 -12
  57. package/dist/tools/stat-many.js +6 -4
  58. package/dist/tools/stat.js +2 -2
  59. package/dist/tools/task-support.d.ts +0 -7
  60. package/dist/tools/task-support.js +7 -6
  61. package/dist/tools/tree.js +1 -1
  62. package/dist/tools/write-file.js +1 -5
  63. package/dist/tools.d.ts +0 -1
  64. package/dist/tools.js +0 -1
  65. package/package.json +5 -5
@@ -55,11 +55,6 @@ export function getTaskCapableToolNames() {
55
55
  contract.taskSupport === 'required')
56
56
  .map((contract) => contract.name);
57
57
  }
58
- export function getTaskToolNamesBySupport(taskSupport) {
59
- return getSortedToolContracts()
60
- .filter((contract) => contract.taskSupport === taskSupport)
61
- .map((contract) => contract.name);
62
- }
63
58
  export function buildCoreContextPack() {
64
59
  const rows = getSortedToolContracts().map((contract) => {
65
60
  const e = ENTRIES[contract.name];
@@ -88,9 +83,6 @@ function formatTaskSupportLabel(taskSupport) {
88
83
  return 'forbidden';
89
84
  }
90
85
  }
91
- function formatAnnotationValue(value) {
92
- return value ? 'true' : 'false';
93
- }
94
86
  function toJsonSchemaObject(schema, io = 'output') {
95
87
  return z.toJSONSchema(schema, { io });
96
88
  }
@@ -98,6 +90,9 @@ function summarizeSchemaType(schema) {
98
90
  if (Array.isArray(schema.enum) && schema.enum.length > 0) {
99
91
  return `enum(${schema.enum.map((value) => JSON.stringify(value)).join(', ')})`;
100
92
  }
93
+ if (schema.const !== undefined) {
94
+ return `const(${JSON.stringify(schema.const)})`;
95
+ }
101
96
  if (Array.isArray(schema.anyOf) && schema.anyOf.length > 0) {
102
97
  return schema.anyOf.map(summarizeSchemaType).join(' | ');
103
98
  }
@@ -105,11 +100,18 @@ function summarizeSchemaType(schema) {
105
100
  return schema.oneOf.map(summarizeSchemaType).join(' | ');
106
101
  }
107
102
  if (schema.type === 'array') {
103
+ if (Array.isArray(schema.prefixItems) && schema.prefixItems.length > 0) {
104
+ const itemTypes = schema.prefixItems.map(summarizeSchemaType).join(', ');
105
+ return `tuple<${itemTypes}>`;
106
+ }
108
107
  const itemType = schema.items
109
108
  ? summarizeSchemaType(schema.items)
110
109
  : 'unknown';
111
110
  return `array<${itemType}>`;
112
111
  }
112
+ if (schema.type === 'object' && schema.additionalProperties === false) {
113
+ return 'object (strict)';
114
+ }
113
115
  if (typeof schema.type === 'string' && schema.type.length > 0) {
114
116
  return schema.type;
115
117
  }
@@ -129,6 +131,9 @@ function buildSchemaFieldLines(label, schema) {
129
131
  jsonSchema.description.length > 0) {
130
132
  lines.push(`- Schema constraints: ${jsonSchema.description}`);
131
133
  }
134
+ if (jsonSchema.additionalProperties === false) {
135
+ lines.push('- Unknown fields are rejected (`additionalProperties: false`).');
136
+ }
132
137
  if (fieldNames.length === 0) {
133
138
  lines.push('- object with no fields', `</${label}>`);
134
139
  return lines;
@@ -145,29 +150,20 @@ function buildSchemaFieldLines(label, schema) {
145
150
  }), `</${label}>`);
146
151
  return lines;
147
152
  }
148
- function buildProtocolNotes(contract) {
149
- const notes = [
150
- '- Protocol failures use JSON-RPC `error`; execution failures use tool result `isError: true`.',
151
- ];
152
- if (contract.outputSchema) {
153
- notes.push('- Successful responses include `structuredContent` that must match the declared output schema.');
154
- }
155
- if (contract.taskSupport === 'optional') {
156
- notes.push('- Supports inline execution by default and task mode when durable polling or deferred results are needed.');
157
- }
158
- if (contract.taskSupport === 'required') {
159
- notes.push('- Must run in task mode; callers should poll `tasks/get` and fetch the payload via `tasks/result`.');
160
- }
161
- if (contract.taskSupport === 'forbidden') {
162
- notes.push('- Runs inline only; task augmentation is not supported for this tool.');
163
- }
164
- return notes;
165
- }
166
153
  export function buildToolInfo(name) {
167
154
  const contract = CONTRACTS_BY_NAME.get(name);
168
155
  const entry = ENTRIES[name];
169
156
  if (!entry || !contract)
170
157
  return undefined;
158
+ const annotationLines = [];
159
+ if (contract.annotations?.readOnlyHint)
160
+ annotationLines.push('- readOnlyHint: true');
161
+ if (contract.annotations?.idempotentHint)
162
+ annotationLines.push('- idempotentHint: true');
163
+ if (contract.annotations?.destructiveHint)
164
+ annotationLines.push('- destructiveHint: true');
165
+ if (contract.annotations?.openWorldHint)
166
+ annotationLines.push('- openWorldHint: true');
171
167
  const lines = [
172
168
  `<tool_info name="${entry.name}">`,
173
169
  `## ${entry.name}`,
@@ -179,23 +175,12 @@ export function buildToolInfo(name) {
179
175
  `- taskSupport: ${formatTaskSupportLabel(contract.taskSupport)}`,
180
176
  '</execution>',
181
177
  '',
182
- '<annotations>',
183
- `- readOnlyHint: ${formatAnnotationValue(contract.annotations?.readOnlyHint)}`,
184
- `- idempotentHint: ${formatAnnotationValue(contract.annotations?.idempotentHint)}`,
185
- `- destructiveHint: ${formatAnnotationValue(contract.annotations?.destructiveHint)}`,
186
- `- openWorldHint: ${formatAnnotationValue(contract.annotations?.openWorldHint)}`,
187
- '</annotations>',
188
- '',
189
178
  ...buildSchemaFieldLines('input_fields', contract.inputSchema),
190
179
  '',
191
180
  ...buildSchemaFieldLines('output_fields', contract.outputSchema),
192
- '',
193
- '<protocol_notes>',
194
- ...buildProtocolNotes(contract),
195
- '</protocol_notes>',
196
181
  ];
197
- if (entry.annotations && entry.annotations.length > 0) {
198
- lines.push('', `<quick_hints>${entry.annotations.join(' ')}</quick_hints>`);
182
+ if (annotationLines.length > 0) {
183
+ lines.push('', '<annotations>', ...annotationLines, '</annotations>');
199
184
  }
200
185
  if (entry.nuances && entry.nuances.length > 0) {
201
186
  lines.push('', '<nuances>');
@@ -10,7 +10,14 @@ export function buildWorkflowGuide() {
10
10
  'read_many',
11
11
  ]));
12
12
  const searchTools = formatToolNameList(pickAvailableToolNames(['find', 'grep', 'read']));
13
- const editTools = formatToolNameList(pickAvailableToolNames(['edit', 'search_and_replace', 'mv', 'rm', 'mkdir']));
13
+ const editTools = formatToolNameList(pickAvailableToolNames([
14
+ 'edit',
15
+ 'write',
16
+ 'search_and_replace',
17
+ 'mv',
18
+ 'rm',
19
+ 'mkdir',
20
+ ]));
14
21
  return `<workflows>
15
22
  ### A: EXPLORE — directory layout or file content
16
23
  1. ${exploreTools}.