@dexto/tools-filesystem 1.9.8 → 1.10.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.
- package/dist/edit-file-tool.cjs +1 -0
- package/dist/edit-file-tool.d.ts.map +1 -1
- package/dist/edit-file-tool.js +2 -0
- package/dist/glob-files-tool.cjs +1 -0
- package/dist/glob-files-tool.d.ts.map +1 -1
- package/dist/glob-files-tool.js +7 -1
- package/dist/grep-content-tool.cjs +1 -0
- package/dist/grep-content-tool.d.ts.map +1 -1
- package/dist/grep-content-tool.js +7 -1
- package/dist/read-file-tool.cjs +1 -0
- package/dist/read-file-tool.d.ts.map +1 -1
- package/dist/read-file-tool.js +7 -1
- package/dist/read-media-file-tool.cjs +1 -0
- package/dist/read-media-file-tool.d.ts.map +1 -1
- package/dist/read-media-file-tool.js +7 -1
- package/dist/write-file-tool.cjs +10 -0
- package/dist/write-file-tool.d.ts.map +1 -1
- package/dist/write-file-tool.js +11 -0
- package/dist/write-file-tool.test.cjs +26 -0
- package/dist/write-file-tool.test.js +27 -1
- package/package.json +3 -3
package/dist/edit-file-tool.cjs
CHANGED
|
@@ -68,6 +68,7 @@ function createEditFileTool(getFileSystemService) {
|
|
|
68
68
|
resolvePaths: (input, fileSystemService) => (0, import_directory_approval.resolveFilePath)(fileSystemService.getWorkingDirectory(), input.file_path)
|
|
69
69
|
}),
|
|
70
70
|
presentation: {
|
|
71
|
+
activity: import_tools.TOOL_ACTIVITY.editFile,
|
|
71
72
|
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
72
73
|
title: "Edit",
|
|
73
74
|
argsText: (0, import_tools.truncateForHeader)(input.file_path, 140)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-file-tool.d.ts","sourceRoot":"","sources":["../src/edit-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"edit-file-tool.d.ts","sourceRoot":"","sources":["../src/edit-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,OAAO,KAAK,EAAmB,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AACrF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAmBpE,QAAA,MAAM,mBAAmB;;;;;kBAaZ,CAAC;AA0Bd;;GAEG;AACH,wBAAgB,kBAAkB,CAC9B,oBAAoB,EAAE,uBAAuB,GAC9C,IAAI,CAAC,OAAO,mBAAmB,CAAC,CA6LlC"}
|
package/dist/edit-file-tool.js
CHANGED
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { createPatch } from "diff";
|
|
4
4
|
import {
|
|
5
5
|
createLocalToolCallHeader,
|
|
6
|
+
TOOL_ACTIVITY,
|
|
6
7
|
ToolError,
|
|
7
8
|
ToolErrorCode,
|
|
8
9
|
defineTool,
|
|
@@ -51,6 +52,7 @@ function createEditFileTool(getFileSystemService) {
|
|
|
51
52
|
resolvePaths: (input, fileSystemService) => resolveFilePath(fileSystemService.getWorkingDirectory(), input.file_path)
|
|
52
53
|
}),
|
|
53
54
|
presentation: {
|
|
55
|
+
activity: TOOL_ACTIVITY.editFile,
|
|
54
56
|
describeHeader: (input) => createLocalToolCallHeader({
|
|
55
57
|
title: "Edit",
|
|
56
58
|
argsText: truncateForHeader(input.file_path, 140)
|
package/dist/glob-files-tool.cjs
CHANGED
|
@@ -38,6 +38,7 @@ function createGlobFilesTool(getFileSystemService) {
|
|
|
38
38
|
description: "Find files matching a glob pattern. Supports standard glob syntax like **/*.js for recursive matches, *.ts for files in current directory, and src/**/*.tsx for nested paths. Returns array of file paths with metadata (size, modified date). Results are limited to allowed paths only.",
|
|
39
39
|
inputSchema: GlobFilesInputSchema,
|
|
40
40
|
presentation: {
|
|
41
|
+
activity: import_tools.TOOL_ACTIVITY.searchFiles,
|
|
41
42
|
describeHeader: (input) => {
|
|
42
43
|
const bits = [`pattern=${input.pattern}`];
|
|
43
44
|
if (input.path) bits.push(`path=${input.path}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob-files-tool.d.ts","sourceRoot":"","sources":["../src/glob-files-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"glob-files-tool.d.ts","sourceRoot":"","sources":["../src/glob-files-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAqB,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAKpE,QAAA,MAAM,oBAAoB;;;;kBAiBb,CAAC;AAEd;;GAEG;AACH,wBAAgB,mBAAmB,CAC/B,oBAAoB,EAAE,uBAAuB,GAC9C,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAkEnC"}
|
package/dist/glob-files-tool.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TOOL_ACTIVITY,
|
|
4
|
+
createLocalToolCallHeader,
|
|
5
|
+
defineTool,
|
|
6
|
+
truncateForHeader
|
|
7
|
+
} from "@dexto/core/tools";
|
|
3
8
|
import { createDirectoryAccessApprovalHandlers } from "./directory-approval.js";
|
|
4
9
|
import { resolveUserPath } from "./path-utils.js";
|
|
5
10
|
import { assertWorkspaceRelativeGlob, toWorkspaceRelativePath } from "./workspace-paths.js";
|
|
@@ -15,6 +20,7 @@ function createGlobFilesTool(getFileSystemService) {
|
|
|
15
20
|
description: "Find files matching a glob pattern. Supports standard glob syntax like **/*.js for recursive matches, *.ts for files in current directory, and src/**/*.tsx for nested paths. Returns array of file paths with metadata (size, modified date). Results are limited to allowed paths only.",
|
|
16
21
|
inputSchema: GlobFilesInputSchema,
|
|
17
22
|
presentation: {
|
|
23
|
+
activity: TOOL_ACTIVITY.searchFiles,
|
|
18
24
|
describeHeader: (input) => {
|
|
19
25
|
const bits = [`pattern=${input.pattern}`];
|
|
20
26
|
if (input.path) bits.push(`path=${input.path}`);
|
|
@@ -55,6 +55,7 @@ function createGrepContentTool(getFileSystemService) {
|
|
|
55
55
|
description: 'Search for text patterns in files using regular expressions. Returns matching lines with file path, line number, and optional context lines. Use glob parameter to filter specific file types (e.g., "*.ts"). Supports case-insensitive search. Great for finding code patterns, function definitions, or specific text across multiple files.',
|
|
56
56
|
inputSchema: GrepContentInputSchema,
|
|
57
57
|
presentation: {
|
|
58
|
+
activity: import_tools.TOOL_ACTIVITY.searchFiles,
|
|
58
59
|
describeHeader: (input) => {
|
|
59
60
|
const bits = [`pattern=${input.pattern}`];
|
|
60
61
|
if (input.glob) bits.push(`glob=${input.glob}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grep-content-tool.d.ts","sourceRoot":"","sources":["../src/grep-content-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"grep-content-tool.d.ts","sourceRoot":"","sources":["../src/grep-content-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,KAAK,EAAqB,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAUpE,QAAA,MAAM,sBAAsB;;;;;;;kBAiCf,CAAC;AAEd;;GAEG;AACH,wBAAgB,qBAAqB,CACjC,oBAAoB,EAAE,uBAAuB,GAC9C,IAAI,CAAC,OAAO,sBAAsB,CAAC,CA2GrC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import safeRegex from "safe-regex";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
TOOL_ACTIVITY,
|
|
5
|
+
createLocalToolCallHeader,
|
|
6
|
+
defineTool,
|
|
7
|
+
truncateForHeader
|
|
8
|
+
} from "@dexto/core/tools";
|
|
4
9
|
import { createDirectoryAccessApprovalHandlers } from "./directory-approval.js";
|
|
5
10
|
import { resolveUserPath } from "./path-utils.js";
|
|
6
11
|
import { FileSystemError } from "./errors.js";
|
|
@@ -26,6 +31,7 @@ function createGrepContentTool(getFileSystemService) {
|
|
|
26
31
|
description: 'Search for text patterns in files using regular expressions. Returns matching lines with file path, line number, and optional context lines. Use glob parameter to filter specific file types (e.g., "*.ts"). Supports case-insensitive search. Great for finding code patterns, function definitions, or specific text across multiple files.',
|
|
27
32
|
inputSchema: GrepContentInputSchema,
|
|
28
33
|
presentation: {
|
|
34
|
+
activity: TOOL_ACTIVITY.searchFiles,
|
|
29
35
|
describeHeader: (input) => {
|
|
30
36
|
const bits = [`pattern=${input.pattern}`];
|
|
31
37
|
if (input.glob) bits.push(`glob=${input.glob}`);
|
package/dist/read-file-tool.cjs
CHANGED
|
@@ -37,6 +37,7 @@ function createReadFileTool(getFileSystemService) {
|
|
|
37
37
|
description: "Read the UTF-8 text contents of a file with optional pagination. Returns file content, line count, encoding, MIME type, and whether the output was truncated. Use limit and offset parameters for large files to read specific sections. Use read_media_file for image, audio, video, PDF, and other binary files.",
|
|
38
38
|
inputSchema: ReadFileInputSchema,
|
|
39
39
|
presentation: {
|
|
40
|
+
activity: import_tools.TOOL_ACTIVITY.readFile,
|
|
40
41
|
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
41
42
|
title: "Read",
|
|
42
43
|
argsText: (0, import_tools.truncateForHeader)(input.file_path, 140)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-file-tool.d.ts","sourceRoot":"","sources":["../src/read-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"read-file-tool.d.ts","sourceRoot":"","sources":["../src/read-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAmB,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AACrF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAKpE,QAAA,MAAM,mBAAmB;;;;kBAgBZ,CAAC;AAEd;;GAEG;AACH,wBAAgB,kBAAkB,CAC9B,oBAAoB,EAAE,uBAAuB,GAC9C,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAiElC"}
|
package/dist/read-file-tool.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TOOL_ACTIVITY,
|
|
4
|
+
createLocalToolCallHeader,
|
|
5
|
+
defineTool,
|
|
6
|
+
truncateForHeader
|
|
7
|
+
} from "@dexto/core/tools";
|
|
3
8
|
import { createDirectoryAccessApprovalHandlers, resolveFilePath } from "./directory-approval.js";
|
|
4
9
|
import { toWorkspaceRelativePath } from "./workspace-paths.js";
|
|
5
10
|
const ReadFileInputSchema = z.object({
|
|
@@ -14,6 +19,7 @@ function createReadFileTool(getFileSystemService) {
|
|
|
14
19
|
description: "Read the UTF-8 text contents of a file with optional pagination. Returns file content, line count, encoding, MIME type, and whether the output was truncated. Use limit and offset parameters for large files to read specific sections. Use read_media_file for image, audio, video, PDF, and other binary files.",
|
|
15
20
|
inputSchema: ReadFileInputSchema,
|
|
16
21
|
presentation: {
|
|
22
|
+
activity: TOOL_ACTIVITY.readFile,
|
|
17
23
|
describeHeader: (input) => createLocalToolCallHeader({
|
|
18
24
|
title: "Read",
|
|
19
25
|
argsText: truncateForHeader(input.file_path, 140)
|
|
@@ -34,6 +34,7 @@ function createReadMediaFileTool(getFileSystemService) {
|
|
|
34
34
|
description: "Read an image, audio, video, PDF, or other binary file. Returns MIME-aware base64 data using media/file shapes that multimodal UIs can render directly. Use read_file for UTF-8 text files.",
|
|
35
35
|
inputSchema: ReadMediaFileInputSchema,
|
|
36
36
|
presentation: {
|
|
37
|
+
activity: import_tools.TOOL_ACTIVITY.readFile,
|
|
37
38
|
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
38
39
|
title: "Read Media",
|
|
39
40
|
argsText: (0, import_tools.truncateForHeader)(input.file_path, 140)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-media-file-tool.d.ts","sourceRoot":"","sources":["../src/read-media-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"read-media-file-tool.d.ts","sourceRoot":"","sources":["../src/read-media-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAmB,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AACrF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGpE,QAAA,MAAM,wBAAwB;;kBAOjB,CAAC;AAEd,wBAAgB,uBAAuB,CACnC,oBAAoB,EAAE,uBAAuB,GAC9C,IAAI,CAAC,OAAO,wBAAwB,CAAC,CAmEvC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TOOL_ACTIVITY,
|
|
4
|
+
createLocalToolCallHeader,
|
|
5
|
+
defineTool,
|
|
6
|
+
truncateForHeader
|
|
7
|
+
} from "@dexto/core/tools";
|
|
3
8
|
import { createDirectoryAccessApprovalHandlers, resolveFilePath } from "./directory-approval.js";
|
|
4
9
|
const ReadMediaFileInputSchema = z.object({
|
|
5
10
|
file_path: z.string().min(1).describe("Absolute path to the image, audio, video, PDF, or binary file to read")
|
|
@@ -11,6 +16,7 @@ function createReadMediaFileTool(getFileSystemService) {
|
|
|
11
16
|
description: "Read an image, audio, video, PDF, or other binary file. Returns MIME-aware base64 data using media/file shapes that multimodal UIs can render directly. Use read_file for UTF-8 text files.",
|
|
12
17
|
inputSchema: ReadMediaFileInputSchema,
|
|
13
18
|
presentation: {
|
|
19
|
+
activity: TOOL_ACTIVITY.readFile,
|
|
14
20
|
describeHeader: (input) => createLocalToolCallHeader({
|
|
15
21
|
title: "Read Media",
|
|
16
22
|
argsText: truncateForHeader(input.file_path, 140)
|
package/dist/write-file-tool.cjs
CHANGED
|
@@ -70,6 +70,16 @@ function createWriteFileTool(getFileSystemService) {
|
|
|
70
70
|
resolvePaths: (input, fileSystemService) => (0, import_directory_approval.resolveFilePath)(fileSystemService.getWorkingDirectory(), input.file_path)
|
|
71
71
|
}),
|
|
72
72
|
presentation: {
|
|
73
|
+
activity: import_tools.TOOL_ACTIVITY.writeFile,
|
|
74
|
+
describeResultActivity: (display) => {
|
|
75
|
+
if (display?.type === "file" && display.operation === "create") {
|
|
76
|
+
return import_tools.TOOL_ACTIVITY.createFile;
|
|
77
|
+
}
|
|
78
|
+
if (display?.type === "diff") {
|
|
79
|
+
return import_tools.TOOL_ACTIVITY.editFile;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
},
|
|
73
83
|
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
74
84
|
title: "Write",
|
|
75
85
|
argsText: (0, import_tools.truncateForHeader)(input.file_path, 140)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-file-tool.d.ts","sourceRoot":"","sources":["../src/write-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"write-file-tool.d.ts","sourceRoot":"","sources":["../src/write-file-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,KAAK,EAGR,IAAI,EAEP,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAwBpE,QAAA,MAAM,oBAAoB;;;;;;;;;kBAeb,CAAC;AA0Bd;;GAEG;AACH,wBAAgB,mBAAmB,CAC/B,oBAAoB,EAAE,uBAAuB,GAC9C,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAoOnC"}
|
package/dist/write-file-tool.js
CHANGED
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { createPatch } from "diff";
|
|
4
4
|
import {
|
|
5
5
|
createLocalToolCallHeader,
|
|
6
|
+
TOOL_ACTIVITY,
|
|
6
7
|
ToolError,
|
|
7
8
|
defineTool,
|
|
8
9
|
truncateForHeader
|
|
@@ -52,6 +53,16 @@ function createWriteFileTool(getFileSystemService) {
|
|
|
52
53
|
resolvePaths: (input, fileSystemService) => resolveFilePath(fileSystemService.getWorkingDirectory(), input.file_path)
|
|
53
54
|
}),
|
|
54
55
|
presentation: {
|
|
56
|
+
activity: TOOL_ACTIVITY.writeFile,
|
|
57
|
+
describeResultActivity: (display) => {
|
|
58
|
+
if (display?.type === "file" && display.operation === "create") {
|
|
59
|
+
return TOOL_ACTIVITY.createFile;
|
|
60
|
+
}
|
|
61
|
+
if (display?.type === "diff") {
|
|
62
|
+
return TOOL_ACTIVITY.editFile;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
},
|
|
55
66
|
describeHeader: (input) => createLocalToolCallHeader({
|
|
56
67
|
title: "Write",
|
|
57
68
|
argsText: truncateForHeader(input.file_path, 140)
|
|
@@ -111,6 +111,32 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
(0, import_vitest.describe)("write_file tool", () => {
|
|
114
|
+
(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 input = tool.inputSchema.parse({ file_path: "config.json", content: "{}" });
|
|
117
|
+
const context = createToolContext(createMockLogger());
|
|
118
|
+
(0, import_vitest.expect)(tool.presentation?.activity).toEqual(import_core.TOOL_ACTIVITY.writeFile);
|
|
119
|
+
(0, import_vitest.expect)(
|
|
120
|
+
tool.presentation?.describeResultActivity?.(
|
|
121
|
+
{ type: "file", path: "config.json", operation: "create" },
|
|
122
|
+
input,
|
|
123
|
+
context
|
|
124
|
+
)
|
|
125
|
+
).toEqual(import_core.TOOL_ACTIVITY.createFile);
|
|
126
|
+
(0, import_vitest.expect)(
|
|
127
|
+
tool.presentation?.describeResultActivity?.(
|
|
128
|
+
{
|
|
129
|
+
type: "diff",
|
|
130
|
+
unified: "",
|
|
131
|
+
filename: "config.json",
|
|
132
|
+
additions: 1,
|
|
133
|
+
deletions: 1
|
|
134
|
+
},
|
|
135
|
+
input,
|
|
136
|
+
context
|
|
137
|
+
)
|
|
138
|
+
).toEqual(import_core.TOOL_ACTIVITY.editFile);
|
|
139
|
+
});
|
|
114
140
|
let mockLogger;
|
|
115
141
|
let tempDir;
|
|
116
142
|
let fileSystemService;
|
|
@@ -4,7 +4,7 @@ import * as fs from "node:fs/promises";
|
|
|
4
4
|
import * as os from "node:os";
|
|
5
5
|
import { createWriteFileTool } from "./write-file-tool.js";
|
|
6
6
|
import { FileSystemService } from "./filesystem-service.js";
|
|
7
|
-
import { ToolErrorCode } from "@dexto/core";
|
|
7
|
+
import { TOOL_ACTIVITY, ToolErrorCode } from "@dexto/core";
|
|
8
8
|
import { DextoRuntimeError } from "@dexto/core";
|
|
9
9
|
import { WorkspaceError } from "@dexto/core/workspace";
|
|
10
10
|
const createMockLogger = () => {
|
|
@@ -88,6 +88,32 @@ async function readWorkspaceFile(workspaceRoot, filePath) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
describe("write_file tool", () => {
|
|
91
|
+
it("resolves the final activity from typed file display data", async () => {
|
|
92
|
+
const tool = createWriteFileTool(vi.fn());
|
|
93
|
+
const input = tool.inputSchema.parse({ file_path: "config.json", content: "{}" });
|
|
94
|
+
const context = createToolContext(createMockLogger());
|
|
95
|
+
expect(tool.presentation?.activity).toEqual(TOOL_ACTIVITY.writeFile);
|
|
96
|
+
expect(
|
|
97
|
+
tool.presentation?.describeResultActivity?.(
|
|
98
|
+
{ type: "file", path: "config.json", operation: "create" },
|
|
99
|
+
input,
|
|
100
|
+
context
|
|
101
|
+
)
|
|
102
|
+
).toEqual(TOOL_ACTIVITY.createFile);
|
|
103
|
+
expect(
|
|
104
|
+
tool.presentation?.describeResultActivity?.(
|
|
105
|
+
{
|
|
106
|
+
type: "diff",
|
|
107
|
+
unified: "",
|
|
108
|
+
filename: "config.json",
|
|
109
|
+
additions: 1,
|
|
110
|
+
deletions: 1
|
|
111
|
+
},
|
|
112
|
+
input,
|
|
113
|
+
context
|
|
114
|
+
)
|
|
115
|
+
).toEqual(TOOL_ACTIVITY.editFile);
|
|
116
|
+
});
|
|
91
117
|
let mockLogger;
|
|
92
118
|
let tempDir;
|
|
93
119
|
let fileSystemService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/tools-filesystem",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "FileSystem tools factory for Dexto agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"glob": "^12.0.0",
|
|
23
23
|
"safe-regex": "^2.1.1",
|
|
24
24
|
"zod": "^4.3.6",
|
|
25
|
-
"@dexto/agent-config": "1.
|
|
26
|
-
"@dexto/core": "1.
|
|
25
|
+
"@dexto/agent-config": "1.10.1",
|
|
26
|
+
"@dexto/core": "1.10.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/diff": "^5.2.3",
|