@dexto/tools-filesystem 1.16.5 → 1.17.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.
- package/dist/blocked-path-check.cjs +62 -0
- package/dist/blocked-path-check.d.ts +11 -0
- package/dist/blocked-path-check.d.ts.map +1 -0
- package/dist/blocked-path-check.js +27 -0
- package/dist/blocked-path-check.test.cjs +117 -0
- package/dist/blocked-path-check.test.d.ts +2 -0
- package/dist/blocked-path-check.test.d.ts.map +1 -0
- package/dist/blocked-path-check.test.js +116 -0
- package/dist/directory-approval.integration.test.cjs +12 -11
- package/dist/directory-approval.integration.test.js +12 -11
- package/dist/edit-file-tool.cjs +48 -27
- package/dist/edit-file-tool.d.ts +2 -1
- package/dist/edit-file-tool.d.ts.map +1 -1
- package/dist/edit-file-tool.js +48 -27
- package/dist/edit-file-tool.test.cjs +161 -30
- package/dist/edit-file-tool.test.js +161 -30
- package/dist/file-size.cjs +47 -0
- package/dist/file-size.d.ts +12 -0
- package/dist/file-size.d.ts.map +1 -0
- package/dist/file-size.js +22 -0
- package/dist/glob-files-tool.cjs +9 -4
- package/dist/glob-files-tool.d.ts +2 -1
- package/dist/glob-files-tool.d.ts.map +1 -1
- package/dist/glob-files-tool.js +9 -4
- package/dist/glob-files-tool.test.cjs +72 -4
- package/dist/glob-files-tool.test.js +72 -4
- package/dist/grep-content-tool.cjs +4 -1
- package/dist/grep-content-tool.d.ts +2 -1
- package/dist/grep-content-tool.d.ts.map +1 -1
- package/dist/grep-content-tool.js +4 -1
- package/dist/grep-content-tool.test.cjs +5 -4
- package/dist/grep-content-tool.test.js +5 -4
- package/dist/index.d.cts +12 -5
- package/dist/path-validator.cjs +26 -1
- package/dist/path-validator.d.ts.map +1 -1
- package/dist/path-validator.js +26 -1
- package/dist/path-validator.test.cjs +75 -0
- package/dist/path-validator.test.js +75 -0
- package/dist/read-file-tool.cjs +14 -2
- package/dist/read-file-tool.d.ts +2 -1
- package/dist/read-file-tool.d.ts.map +1 -1
- package/dist/read-file-tool.js +14 -2
- package/dist/read-file-tool.test.cjs +54 -5
- package/dist/read-file-tool.test.js +54 -5
- package/dist/test-helpers.cjs +28 -0
- package/dist/test-helpers.d.ts +4 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +4 -0
- package/dist/tool-factory-config.d.ts +2 -2
- package/dist/tool-factory.cjs +9 -5
- package/dist/tool-factory.d.ts.map +1 -1
- package/dist/tool-factory.js +9 -5
- package/dist/workspace-paths.cjs +5 -1
- package/dist/workspace-paths.d.ts.map +1 -1
- package/dist/workspace-paths.js +5 -1
- package/dist/write-file-tool.cjs +8 -1
- package/dist/write-file-tool.d.ts +2 -1
- package/dist/write-file-tool.d.ts.map +1 -1
- package/dist/write-file-tool.js +8 -1
- package/dist/write-file-tool.test.cjs +18 -17
- package/dist/write-file-tool.test.js +18 -17
- package/package.json +4 -3
|
@@ -22,6 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
var import_vitest = require("vitest");
|
|
25
|
+
var import_test_helpers = require("./test-helpers.js");
|
|
25
26
|
var path = __toESM(require("node:path"), 1);
|
|
26
27
|
var fs = __toESM(require("node:fs/promises"), 1);
|
|
27
28
|
var os = __toESM(require("node:os"), 1);
|
|
@@ -112,7 +113,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
112
113
|
}
|
|
113
114
|
(0, import_vitest.describe)("write_file tool", () => {
|
|
114
115
|
(0, import_vitest.it)("resolves the final activity from typed file display data", async () => {
|
|
115
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn());
|
|
116
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn(), import_test_helpers.allowAllPaths);
|
|
116
117
|
const input = tool.inputSchema.parse({ file_path: "config.json", content: "{}" });
|
|
117
118
|
const context = createToolContext(createMockLogger());
|
|
118
119
|
(0, import_vitest.expect)(tool.presentation?.activity).toEqual(import_core.TOOL_ACTIVITY.writeFile);
|
|
@@ -170,7 +171,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
170
171
|
const getFileSystemService = import_vitest.vi.fn(async () => {
|
|
171
172
|
throw new Error("write_file execute must not use FileSystemService");
|
|
172
173
|
});
|
|
173
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(getFileSystemService);
|
|
174
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(getFileSystemService, import_test_helpers.allowAllPaths);
|
|
174
175
|
const parsedInput = tool.inputSchema.parse({
|
|
175
176
|
file_path: "workspace.txt",
|
|
176
177
|
content: "workspace write"
|
|
@@ -183,7 +184,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
183
184
|
);
|
|
184
185
|
});
|
|
185
186
|
(0, import_vitest.it)("creates missing parent directories by default", async () => {
|
|
186
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn());
|
|
187
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn(), import_test_helpers.allowAllPaths);
|
|
187
188
|
const parsedInput = tool.inputSchema.parse({
|
|
188
189
|
file_path: "missing-parent/file.txt",
|
|
189
190
|
content: "content"
|
|
@@ -199,7 +200,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
199
200
|
).resolves.toBe("content");
|
|
200
201
|
});
|
|
201
202
|
(0, import_vitest.it)("rejects obsolete create_dirs input", async () => {
|
|
202
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn());
|
|
203
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn(), import_test_helpers.allowAllPaths);
|
|
203
204
|
(0, import_vitest.expect)(
|
|
204
205
|
() => tool.inputSchema.parse({
|
|
205
206
|
file_path: "file.txt",
|
|
@@ -232,7 +233,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
232
233
|
}
|
|
233
234
|
}))
|
|
234
235
|
};
|
|
235
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn());
|
|
236
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn(), import_test_helpers.allowAllPaths);
|
|
236
237
|
const context = createToolContext(mockLogger, {
|
|
237
238
|
services: {
|
|
238
239
|
...createWorkspaceServices(tempDir),
|
|
@@ -252,7 +253,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
252
253
|
const getFileSystemService = import_vitest.vi.fn(async () => {
|
|
253
254
|
throw new Error("write_file preview must not use FileSystemService in workspace mode");
|
|
254
255
|
});
|
|
255
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(getFileSystemService);
|
|
256
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(getFileSystemService, import_test_helpers.allowAllPaths);
|
|
256
257
|
const preview = await tool.presentation.preview(
|
|
257
258
|
tool.inputSchema.parse({
|
|
258
259
|
file_path: "workspace-new.txt",
|
|
@@ -290,7 +291,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
290
291
|
}
|
|
291
292
|
}))
|
|
292
293
|
};
|
|
293
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn());
|
|
294
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn(), import_test_helpers.allowAllPaths);
|
|
294
295
|
const context = createToolContext(mockLogger, {
|
|
295
296
|
services: {
|
|
296
297
|
...createWorkspaceServices(tempDir),
|
|
@@ -331,7 +332,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
331
332
|
}
|
|
332
333
|
}))
|
|
333
334
|
};
|
|
334
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn());
|
|
335
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(import_vitest.vi.fn(), import_test_helpers.allowAllPaths);
|
|
335
336
|
const context = createToolContext(mockLogger, {
|
|
336
337
|
services: {
|
|
337
338
|
...createWorkspaceServices(tempDir),
|
|
@@ -348,7 +349,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
348
349
|
});
|
|
349
350
|
(0, import_vitest.describe)("File Modification Detection - Existing Files", () => {
|
|
350
351
|
(0, import_vitest.it)("should generate preview for existing files outside config-allowed roots (preview read only)", async () => {
|
|
351
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
352
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
352
353
|
const rawExternalDir = await fs.mkdtemp(
|
|
353
354
|
path.join(os.tmpdir(), "dexto-write-outside-allowed-")
|
|
354
355
|
);
|
|
@@ -384,7 +385,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
384
385
|
}
|
|
385
386
|
});
|
|
386
387
|
(0, import_vitest.it)("should succeed when existing file is not modified between preview and execute", async () => {
|
|
387
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
388
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
388
389
|
const testFile = path.join(tempDir, "test.txt");
|
|
389
390
|
await fs.writeFile(testFile, "original content");
|
|
390
391
|
const toolCallId = "test-call-123";
|
|
@@ -414,7 +415,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
414
415
|
(0, import_vitest.expect)(content).toBe("new content");
|
|
415
416
|
});
|
|
416
417
|
(0, import_vitest.it)("should fail when existing file is modified between preview and execute", async () => {
|
|
417
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
418
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
418
419
|
const testFile = path.join(tempDir, "test.txt");
|
|
419
420
|
await fs.writeFile(testFile, "original content");
|
|
420
421
|
const toolCallId = "test-call-456";
|
|
@@ -441,7 +442,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
441
442
|
(0, import_vitest.expect)(content).toBe("user modified this");
|
|
442
443
|
});
|
|
443
444
|
(0, import_vitest.it)("should fail when existing file is deleted between preview and execute", async () => {
|
|
444
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
445
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
445
446
|
const testFile = path.join(tempDir, "test.txt");
|
|
446
447
|
await fs.writeFile(testFile, "original content");
|
|
447
448
|
const toolCallId = "test-call-deleted";
|
|
@@ -484,7 +485,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
484
485
|
mockLogger
|
|
485
486
|
);
|
|
486
487
|
await fileSystemServiceForHome.initialize();
|
|
487
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemServiceForHome);
|
|
488
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemServiceForHome, import_test_helpers.allowAllPaths);
|
|
488
489
|
try {
|
|
489
490
|
const parsedInput = tool.inputSchema.parse({
|
|
490
491
|
file_path: "nested/new-file.txt",
|
|
@@ -504,7 +505,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
504
505
|
}
|
|
505
506
|
});
|
|
506
507
|
(0, import_vitest.it)("should succeed when creating new file that still does not exist", async () => {
|
|
507
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
508
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
508
509
|
const testFile = path.join(tempDir, "new-file.txt");
|
|
509
510
|
const toolCallId = "test-call-new";
|
|
510
511
|
const input = {
|
|
@@ -542,7 +543,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
542
543
|
(0, import_vitest.expect)(content).toBe("brand new content");
|
|
543
544
|
});
|
|
544
545
|
(0, import_vitest.it)("should fail when file is created by someone else between preview and execute", async () => {
|
|
545
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
546
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
546
547
|
const previewFn = tool.presentation?.preview;
|
|
547
548
|
(0, import_vitest.expect)(previewFn).toBeDefined();
|
|
548
549
|
const testFile = path.join(tempDir, "race-condition.txt");
|
|
@@ -573,7 +574,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
573
574
|
});
|
|
574
575
|
(0, import_vitest.describe)("Cache Cleanup", () => {
|
|
575
576
|
(0, import_vitest.it)("should clean up hash cache after successful execution", async () => {
|
|
576
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
577
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
577
578
|
const testFile = path.join(tempDir, "test.txt");
|
|
578
579
|
await fs.writeFile(testFile, "original");
|
|
579
580
|
const toolCallId = "test-call-cleanup";
|
|
@@ -604,7 +605,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
604
605
|
(0, import_vitest.expect)(content).toBe("second write");
|
|
605
606
|
});
|
|
606
607
|
(0, import_vitest.it)("should clean up hash cache after failed execution", async () => {
|
|
607
|
-
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService);
|
|
608
|
+
const tool = (0, import_write_file_tool.createWriteFileTool)(async () => fileSystemService, import_test_helpers.allowAllPaths);
|
|
608
609
|
const testFile = path.join(tempDir, "test.txt");
|
|
609
610
|
await fs.writeFile(testFile, "original");
|
|
610
611
|
const toolCallId = "test-call-fail";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
2
|
+
import { allowAllPaths } from "./test-helpers.js";
|
|
2
3
|
import * as path from "node:path";
|
|
3
4
|
import * as fs from "node:fs/promises";
|
|
4
5
|
import * as os from "node:os";
|
|
@@ -89,7 +90,7 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
89
90
|
}
|
|
90
91
|
describe("write_file tool", () => {
|
|
91
92
|
it("resolves the final activity from typed file display data", async () => {
|
|
92
|
-
const tool = createWriteFileTool(vi.fn());
|
|
93
|
+
const tool = createWriteFileTool(vi.fn(), allowAllPaths);
|
|
93
94
|
const input = tool.inputSchema.parse({ file_path: "config.json", content: "{}" });
|
|
94
95
|
const context = createToolContext(createMockLogger());
|
|
95
96
|
expect(tool.presentation?.activity).toEqual(TOOL_ACTIVITY.writeFile);
|
|
@@ -147,7 +148,7 @@ describe("write_file tool", () => {
|
|
|
147
148
|
const getFileSystemService = vi.fn(async () => {
|
|
148
149
|
throw new Error("write_file execute must not use FileSystemService");
|
|
149
150
|
});
|
|
150
|
-
const tool = createWriteFileTool(getFileSystemService);
|
|
151
|
+
const tool = createWriteFileTool(getFileSystemService, allowAllPaths);
|
|
151
152
|
const parsedInput = tool.inputSchema.parse({
|
|
152
153
|
file_path: "workspace.txt",
|
|
153
154
|
content: "workspace write"
|
|
@@ -160,7 +161,7 @@ describe("write_file tool", () => {
|
|
|
160
161
|
);
|
|
161
162
|
});
|
|
162
163
|
it("creates missing parent directories by default", async () => {
|
|
163
|
-
const tool = createWriteFileTool(vi.fn());
|
|
164
|
+
const tool = createWriteFileTool(vi.fn(), allowAllPaths);
|
|
164
165
|
const parsedInput = tool.inputSchema.parse({
|
|
165
166
|
file_path: "missing-parent/file.txt",
|
|
166
167
|
content: "content"
|
|
@@ -176,7 +177,7 @@ describe("write_file tool", () => {
|
|
|
176
177
|
).resolves.toBe("content");
|
|
177
178
|
});
|
|
178
179
|
it("rejects obsolete create_dirs input", async () => {
|
|
179
|
-
const tool = createWriteFileTool(vi.fn());
|
|
180
|
+
const tool = createWriteFileTool(vi.fn(), allowAllPaths);
|
|
180
181
|
expect(
|
|
181
182
|
() => tool.inputSchema.parse({
|
|
182
183
|
file_path: "file.txt",
|
|
@@ -209,7 +210,7 @@ describe("write_file tool", () => {
|
|
|
209
210
|
}
|
|
210
211
|
}))
|
|
211
212
|
};
|
|
212
|
-
const tool = createWriteFileTool(vi.fn());
|
|
213
|
+
const tool = createWriteFileTool(vi.fn(), allowAllPaths);
|
|
213
214
|
const context = createToolContext(mockLogger, {
|
|
214
215
|
services: {
|
|
215
216
|
...createWorkspaceServices(tempDir),
|
|
@@ -229,7 +230,7 @@ describe("write_file tool", () => {
|
|
|
229
230
|
const getFileSystemService = vi.fn(async () => {
|
|
230
231
|
throw new Error("write_file preview must not use FileSystemService in workspace mode");
|
|
231
232
|
});
|
|
232
|
-
const tool = createWriteFileTool(getFileSystemService);
|
|
233
|
+
const tool = createWriteFileTool(getFileSystemService, allowAllPaths);
|
|
233
234
|
const preview = await tool.presentation.preview(
|
|
234
235
|
tool.inputSchema.parse({
|
|
235
236
|
file_path: "workspace-new.txt",
|
|
@@ -267,7 +268,7 @@ describe("write_file tool", () => {
|
|
|
267
268
|
}
|
|
268
269
|
}))
|
|
269
270
|
};
|
|
270
|
-
const tool = createWriteFileTool(vi.fn());
|
|
271
|
+
const tool = createWriteFileTool(vi.fn(), allowAllPaths);
|
|
271
272
|
const context = createToolContext(mockLogger, {
|
|
272
273
|
services: {
|
|
273
274
|
...createWorkspaceServices(tempDir),
|
|
@@ -308,7 +309,7 @@ describe("write_file tool", () => {
|
|
|
308
309
|
}
|
|
309
310
|
}))
|
|
310
311
|
};
|
|
311
|
-
const tool = createWriteFileTool(vi.fn());
|
|
312
|
+
const tool = createWriteFileTool(vi.fn(), allowAllPaths);
|
|
312
313
|
const context = createToolContext(mockLogger, {
|
|
313
314
|
services: {
|
|
314
315
|
...createWorkspaceServices(tempDir),
|
|
@@ -325,7 +326,7 @@ describe("write_file tool", () => {
|
|
|
325
326
|
});
|
|
326
327
|
describe("File Modification Detection - Existing Files", () => {
|
|
327
328
|
it("should generate preview for existing files outside config-allowed roots (preview read only)", async () => {
|
|
328
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
329
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
329
330
|
const rawExternalDir = await fs.mkdtemp(
|
|
330
331
|
path.join(os.tmpdir(), "dexto-write-outside-allowed-")
|
|
331
332
|
);
|
|
@@ -361,7 +362,7 @@ describe("write_file tool", () => {
|
|
|
361
362
|
}
|
|
362
363
|
});
|
|
363
364
|
it("should succeed when existing file is not modified between preview and execute", async () => {
|
|
364
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
365
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
365
366
|
const testFile = path.join(tempDir, "test.txt");
|
|
366
367
|
await fs.writeFile(testFile, "original content");
|
|
367
368
|
const toolCallId = "test-call-123";
|
|
@@ -391,7 +392,7 @@ describe("write_file tool", () => {
|
|
|
391
392
|
expect(content).toBe("new content");
|
|
392
393
|
});
|
|
393
394
|
it("should fail when existing file is modified between preview and execute", async () => {
|
|
394
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
395
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
395
396
|
const testFile = path.join(tempDir, "test.txt");
|
|
396
397
|
await fs.writeFile(testFile, "original content");
|
|
397
398
|
const toolCallId = "test-call-456";
|
|
@@ -418,7 +419,7 @@ describe("write_file tool", () => {
|
|
|
418
419
|
expect(content).toBe("user modified this");
|
|
419
420
|
});
|
|
420
421
|
it("should fail when existing file is deleted between preview and execute", async () => {
|
|
421
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
422
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
422
423
|
const testFile = path.join(tempDir, "test.txt");
|
|
423
424
|
await fs.writeFile(testFile, "original content");
|
|
424
425
|
const toolCallId = "test-call-deleted";
|
|
@@ -461,7 +462,7 @@ describe("write_file tool", () => {
|
|
|
461
462
|
mockLogger
|
|
462
463
|
);
|
|
463
464
|
await fileSystemServiceForHome.initialize();
|
|
464
|
-
const tool = createWriteFileTool(async () => fileSystemServiceForHome);
|
|
465
|
+
const tool = createWriteFileTool(async () => fileSystemServiceForHome, allowAllPaths);
|
|
465
466
|
try {
|
|
466
467
|
const parsedInput = tool.inputSchema.parse({
|
|
467
468
|
file_path: "nested/new-file.txt",
|
|
@@ -481,7 +482,7 @@ describe("write_file tool", () => {
|
|
|
481
482
|
}
|
|
482
483
|
});
|
|
483
484
|
it("should succeed when creating new file that still does not exist", async () => {
|
|
484
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
485
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
485
486
|
const testFile = path.join(tempDir, "new-file.txt");
|
|
486
487
|
const toolCallId = "test-call-new";
|
|
487
488
|
const input = {
|
|
@@ -519,7 +520,7 @@ describe("write_file tool", () => {
|
|
|
519
520
|
expect(content).toBe("brand new content");
|
|
520
521
|
});
|
|
521
522
|
it("should fail when file is created by someone else between preview and execute", async () => {
|
|
522
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
523
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
523
524
|
const previewFn = tool.presentation?.preview;
|
|
524
525
|
expect(previewFn).toBeDefined();
|
|
525
526
|
const testFile = path.join(tempDir, "race-condition.txt");
|
|
@@ -550,7 +551,7 @@ describe("write_file tool", () => {
|
|
|
550
551
|
});
|
|
551
552
|
describe("Cache Cleanup", () => {
|
|
552
553
|
it("should clean up hash cache after successful execution", async () => {
|
|
553
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
554
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
554
555
|
const testFile = path.join(tempDir, "test.txt");
|
|
555
556
|
await fs.writeFile(testFile, "original");
|
|
556
557
|
const toolCallId = "test-call-cleanup";
|
|
@@ -581,7 +582,7 @@ describe("write_file tool", () => {
|
|
|
581
582
|
expect(content).toBe("second write");
|
|
582
583
|
});
|
|
583
584
|
it("should clean up hash cache after failed execution", async () => {
|
|
584
|
-
const tool = createWriteFileTool(async () => fileSystemService);
|
|
585
|
+
const tool = createWriteFileTool(async () => fileSystemService, allowAllPaths);
|
|
585
586
|
const testFile = path.join(tempDir, "test.txt");
|
|
586
587
|
await fs.writeFile(testFile, "original");
|
|
587
588
|
const toolCallId = "test-call-fail";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/tools-filesystem",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "FileSystem tools factory for Dexto agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"diff": "^8.0.3",
|
|
22
22
|
"glob": "^14.0.3",
|
|
23
|
+
"minimatch": "^10.2.4",
|
|
23
24
|
"safe-regex": "^2.1.1",
|
|
24
25
|
"zod": "^4.3.6",
|
|
25
|
-
"@dexto/agent-config": "1.
|
|
26
|
-
"@dexto/core": "1.
|
|
26
|
+
"@dexto/agent-config": "1.17.0",
|
|
27
|
+
"@dexto/core": "1.17.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@types/diff": "^5.2.3",
|