fileditor-mcp 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/1781792324448_PixelTunnelSender.exe +0 -0
- package/LICENSE +21 -21
- package/README.md +128 -128
- package/docs/MCP-INTERFACE.cn.md +975 -1061
- package/docs/MCP-INTERFACE.en.md +881 -974
- package/docs/README.cn.md +128 -128
- package/package.json +30 -31
- package/src/handlers/applyDiff.js +298 -324
- package/src/handlers/insertContent.js +179 -153
- package/src/handlers/listFiles.js +65 -54
- package/src/handlers/readFile.js +109 -109
- package/src/handlers/searchAndReplace.js +198 -217
- package/src/handlers/setWorkspace.js +26 -26
- package/src/handlers/writeFile.js +97 -91
- package/src/index.js +22 -22
- package/src/server.js +85 -85
- package/src/tools/toolDefinitions.js +291 -301
- package/src/utils/fileUtils.js +238 -716
- package/test/ApplyDiffHandler.test.js +754 -754
- package/test/InsertContentHandler.test.js +371 -369
- package/test/ListFilesHandler.test.js +302 -300
- package/test/ReadFileHandler.test.js +213 -213
- package/test/SearchAndReplaceHandler.test.js +505 -505
- package/test/SetWorkspaceHandler.test.js +290 -290
- package/test/WriteFileHandler.test.js +289 -289
- package/test/runAllTests.js +233 -233
|
@@ -1,301 +1,291 @@
|
|
|
1
|
-
// Tool definitions and Schema configuration
|
|
2
|
-
export const toolDefinitions = [
|
|
3
|
-
{
|
|
4
|
-
name: "set_workspace",
|
|
5
|
-
description: "Set the workspace root directory. All relative path operations will be based on this directory. You must call this tool to set the correct workspace before performing any file operations.",
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: "object",
|
|
8
|
-
properties: {
|
|
9
|
-
path: {
|
|
10
|
-
type: "string",
|
|
11
|
-
description: "The absolute path to the workspace root directory (e.g., the directory opened by VSCode)"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
required: ["path"]
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "read_files",
|
|
19
|
-
description: "Read the entire or partial content of the specified file(s). Supports reading single or multiple files at once. The returned content includes line numbers in the format 'line | content'.",
|
|
20
|
-
inputSchema: {
|
|
21
|
-
type: "object",
|
|
22
|
-
properties: {
|
|
23
|
-
path: {
|
|
24
|
-
oneOf: [
|
|
25
|
-
{
|
|
26
|
-
type: "string",
|
|
27
|
-
description: "The path of the single file to read. The path can be an absolute path or a workspace-relative path."
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
type: "array",
|
|
31
|
-
items: {
|
|
32
|
-
type: "string"
|
|
33
|
-
},
|
|
34
|
-
description: "An array of file paths to read. Each path can be an absolute path or a workspace-relative path."
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
line_range: {
|
|
39
|
-
type: "string",
|
|
40
|
-
description: "Optional line range, format 'start-end' (only for single file)",
|
|
41
|
-
pattern: "^\\d+-\\d+$"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
required: ["path"]
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "write_files",
|
|
49
|
-
description: "Create new files or completely overwrite existing files. Supports single or multiple files at once.",
|
|
50
|
-
inputSchema: {
|
|
51
|
-
type: "object",
|
|
52
|
-
properties: {
|
|
53
|
-
path: {
|
|
54
|
-
oneOf: [
|
|
55
|
-
{
|
|
56
|
-
type: "string",
|
|
57
|
-
description: "The path of the single target file. The path can be an absolute path or a workspace-relative path."
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: "array",
|
|
61
|
-
items: {
|
|
62
|
-
type: "string"
|
|
63
|
-
},
|
|
64
|
-
description: "An array of target file paths. Each path can be an absolute path or a workspace-relative path."
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
content: {
|
|
69
|
-
oneOf: [
|
|
70
|
-
{
|
|
71
|
-
type: "string",
|
|
72
|
-
description: "The full content to write, for single file or same content for all files"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
type: "array",
|
|
76
|
-
items: {
|
|
77
|
-
type: "string"
|
|
78
|
-
},
|
|
79
|
-
description: "An array of content for each file, for different content per file"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
line_count: {
|
|
84
|
-
oneOf: [
|
|
85
|
-
{
|
|
86
|
-
type: "integer",
|
|
87
|
-
description: "Total number of lines in the file, for single file or same for all files",
|
|
88
|
-
minimum: 0
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
type: "array",
|
|
92
|
-
items: {
|
|
93
|
-
type: "integer",
|
|
94
|
-
minimum: 0
|
|
95
|
-
},
|
|
96
|
-
description: "An array of line counts for each file, for different line counts per file"
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
required: ["path", "content", "line_count"]
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
type: "
|
|
279
|
-
description: "
|
|
280
|
-
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
type: "
|
|
284
|
-
description: "
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
end_line: {
|
|
293
|
-
type: "integer",
|
|
294
|
-
description: "The ending line of the search range",
|
|
295
|
-
minimum: 1
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
required: ["path", "search", "replace"]
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
];
|
|
1
|
+
// Tool definitions and Schema configuration
|
|
2
|
+
export const toolDefinitions = [
|
|
3
|
+
{
|
|
4
|
+
name: "set_workspace",
|
|
5
|
+
description: "Set the workspace root directory. All relative path operations will be based on this directory. You must call this tool to set the correct workspace before performing any file operations.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
path: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "The absolute path to the workspace root directory (e.g., the directory opened by VSCode)"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
required: ["path"]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "read_files",
|
|
19
|
+
description: "Read the entire or partial content of the specified file(s). Supports reading single or multiple files at once. The returned content includes line numbers in the format 'line | content'.",
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
path: {
|
|
24
|
+
oneOf: [
|
|
25
|
+
{
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "The path of the single file to read. The path can be an absolute path or a workspace-relative path."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "array",
|
|
31
|
+
items: {
|
|
32
|
+
type: "string"
|
|
33
|
+
},
|
|
34
|
+
description: "An array of file paths to read. Each path can be an absolute path or a workspace-relative path."
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
line_range: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Optional line range, format 'start-end' (only for single file)",
|
|
41
|
+
pattern: "^\\d+-\\d+$"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
required: ["path"]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "write_files",
|
|
49
|
+
description: "Create new files or completely overwrite existing files. Supports single or multiple files at once.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
path: {
|
|
54
|
+
oneOf: [
|
|
55
|
+
{
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "The path of the single target file. The path can be an absolute path or a workspace-relative path."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "array",
|
|
61
|
+
items: {
|
|
62
|
+
type: "string"
|
|
63
|
+
},
|
|
64
|
+
description: "An array of target file paths. Each path can be an absolute path or a workspace-relative path."
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
content: {
|
|
69
|
+
oneOf: [
|
|
70
|
+
{
|
|
71
|
+
type: "string",
|
|
72
|
+
description: "The full content to write, for single file or same content for all files"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "array",
|
|
76
|
+
items: {
|
|
77
|
+
type: "string"
|
|
78
|
+
},
|
|
79
|
+
description: "An array of content for each file, for different content per file"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
line_count: {
|
|
84
|
+
oneOf: [
|
|
85
|
+
{
|
|
86
|
+
type: "integer",
|
|
87
|
+
description: "Total number of lines in the file, for single file or same for all files",
|
|
88
|
+
minimum: 0
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: "array",
|
|
92
|
+
items: {
|
|
93
|
+
type: "integer",
|
|
94
|
+
minimum: 0
|
|
95
|
+
},
|
|
96
|
+
description: "An array of line counts for each file, for different line counts per file"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
required: ["path", "content", "line_count"]
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "list_files",
|
|
106
|
+
description: "List the files and subdirectories in the specified directory.",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
path: {
|
|
111
|
+
type: "string",
|
|
112
|
+
description: "The directory path to list contents of. The path can be an absolute path or a workspace-relative path."
|
|
113
|
+
},
|
|
114
|
+
recursive: {
|
|
115
|
+
type: "boolean",
|
|
116
|
+
description: "Whether to recursively list subdirectory contents",
|
|
117
|
+
default: false
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
required: ["path"]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "insert_contents",
|
|
125
|
+
description: "Insert new content at the specified position in the file. Supports editing single or multiple files at once. Negative line numbers are supported for insertion from the end.",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: {
|
|
129
|
+
path: {
|
|
130
|
+
oneOf: [
|
|
131
|
+
{
|
|
132
|
+
type: "string",
|
|
133
|
+
description: "The path of the single target file. The path can be an absolute path or a workspace-relative path."
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: "array",
|
|
137
|
+
items: {
|
|
138
|
+
type: "string"
|
|
139
|
+
},
|
|
140
|
+
description: "An array of target file paths. Each path can be an absolute path or a workspace-relative path."
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
line: {
|
|
145
|
+
oneOf: [
|
|
146
|
+
{
|
|
147
|
+
type: "integer",
|
|
148
|
+
description: "The line number to insert (positive: 1-based, 0: end of file, negative: from end, -1 before last line), for single file"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: "array",
|
|
152
|
+
items: {
|
|
153
|
+
type: "integer"
|
|
154
|
+
},
|
|
155
|
+
description: "An array of line numbers for each file (positive: insert, 0: end, negative: from end), for multiple files"
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
content: {
|
|
160
|
+
oneOf: [
|
|
161
|
+
{
|
|
162
|
+
type: "string",
|
|
163
|
+
description: "The content to insert, for single file or same content for all files"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
type: "array",
|
|
167
|
+
items: {
|
|
168
|
+
type: "string"
|
|
169
|
+
},
|
|
170
|
+
description: "An array of content for each file, for different content per file"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
required: ["path", "line", "content"]
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "apply_diffs",
|
|
180
|
+
description: "Perform precise block-based search and replace operations on existing files. Supports single or multiple diff operations on a single file. When processing multiple diffs, the tool automatically handles line number offsets - all start_line values should be based on the original file structure. By default, operates in atomic mode for safe batch operations.",
|
|
181
|
+
inputSchema: {
|
|
182
|
+
type: "object",
|
|
183
|
+
properties: {
|
|
184
|
+
path: {
|
|
185
|
+
type: "string",
|
|
186
|
+
description: "The path of the file to modify. The path can be an absolute path or a workspace-relative path."
|
|
187
|
+
},
|
|
188
|
+
search_content: {
|
|
189
|
+
oneOf: [
|
|
190
|
+
{
|
|
191
|
+
type: "string",
|
|
192
|
+
description: "The original content to match precisely (for single diff)"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: "array",
|
|
196
|
+
items: {
|
|
197
|
+
type: "string"
|
|
198
|
+
},
|
|
199
|
+
description: "Array of original content to match precisely (for multiple diffs)"
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
replace_content: {
|
|
204
|
+
oneOf: [
|
|
205
|
+
{
|
|
206
|
+
type: "string",
|
|
207
|
+
description: "The new content to replace with (for single diff)"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
type: "array",
|
|
211
|
+
items: {
|
|
212
|
+
type: "string"
|
|
213
|
+
},
|
|
214
|
+
description: "Array of new content to replace with (for multiple diffs)"
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
start_line: {
|
|
219
|
+
oneOf: [
|
|
220
|
+
{
|
|
221
|
+
type: "integer",
|
|
222
|
+
description: "The starting line number for searching content (for single diff, 1-based line number from original file)",
|
|
223
|
+
minimum: 1
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
type: "array",
|
|
227
|
+
items: {
|
|
228
|
+
type: "integer",
|
|
229
|
+
minimum: 1
|
|
230
|
+
},
|
|
231
|
+
description: "Array of starting line numbers for searching content (for multiple diffs, all 1-based line numbers from original file - tool automatically handles line offset adjustments during processing)"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
atomic: {
|
|
236
|
+
type: "boolean",
|
|
237
|
+
description: "Whether to use atomic mode (all-or-nothing). When true (default), validates all diffs before applying any. When false, applies diffs one by one, continuing on failures.",
|
|
238
|
+
default: true
|
|
239
|
+
},
|
|
240
|
+
trim: {
|
|
241
|
+
type: "boolean",
|
|
242
|
+
description: "Whether to trim whitespace from the beginning and end of each line when comparing search_content with file content. Only affects search and matching - replace_content is inserted exactly as provided. Default is false.",
|
|
243
|
+
default: false
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
required: ["path", "search_content", "replace_content", "start_line"]
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "search_and_replace",
|
|
251
|
+
description: "Search and replace text or regular expressions in a single file.",
|
|
252
|
+
inputSchema: {
|
|
253
|
+
type: "object",
|
|
254
|
+
properties: {
|
|
255
|
+
path: {
|
|
256
|
+
type: "string",
|
|
257
|
+
description: "The target file path. The path can be an absolute path or a workspace-relative path."
|
|
258
|
+
},
|
|
259
|
+
search: {
|
|
260
|
+
type: "string",
|
|
261
|
+
description: "The text or regular expression to search for"
|
|
262
|
+
},
|
|
263
|
+
replace: {
|
|
264
|
+
type: "string",
|
|
265
|
+
description: "The text to replace with"
|
|
266
|
+
},
|
|
267
|
+
use_regex: {
|
|
268
|
+
type: "boolean",
|
|
269
|
+
description: "Whether to use regular expressions for searching",
|
|
270
|
+
default: false
|
|
271
|
+
},
|
|
272
|
+
ignore_case: {
|
|
273
|
+
type: "boolean",
|
|
274
|
+
description: "Whether to ignore case when searching",
|
|
275
|
+
default: false
|
|
276
|
+
},
|
|
277
|
+
start_line: {
|
|
278
|
+
type: "integer",
|
|
279
|
+
description: "The starting line of the search range",
|
|
280
|
+
minimum: 1
|
|
281
|
+
},
|
|
282
|
+
end_line: {
|
|
283
|
+
type: "integer",
|
|
284
|
+
description: "The ending line of the search range",
|
|
285
|
+
minimum: 1
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
required: ["path", "search", "replace"]
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
];
|