@dexto/tools-filesystem 1.5.8 → 1.6.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/directory-approval.cjs +98 -0
- package/dist/directory-approval.d.ts +24 -0
- package/dist/directory-approval.d.ts.map +1 -0
- package/dist/directory-approval.integration.test.cjs +175 -390
- package/dist/directory-approval.integration.test.d.ts +14 -2
- package/dist/directory-approval.integration.test.d.ts.map +1 -0
- package/dist/directory-approval.integration.test.js +178 -390
- package/dist/directory-approval.js +63 -0
- package/dist/edit-file-tool.cjs +109 -120
- package/dist/edit-file-tool.d.ts +22 -9
- package/dist/edit-file-tool.d.ts.map +1 -0
- package/dist/edit-file-tool.js +116 -110
- package/dist/edit-file-tool.test.cjs +109 -29
- package/dist/edit-file-tool.test.d.ts +7 -2
- package/dist/edit-file-tool.test.d.ts.map +1 -0
- package/dist/edit-file-tool.test.js +109 -29
- package/dist/error-codes.cjs +4 -0
- package/dist/error-codes.d.ts +6 -3
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +4 -0
- package/dist/errors.cjs +48 -0
- package/dist/errors.d.ts +20 -7
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +48 -0
- package/dist/file-tool-types.d.ts +8 -40
- package/dist/file-tool-types.d.ts.map +1 -0
- package/dist/filesystem-service.cjs +325 -10
- package/dist/filesystem-service.d.ts +41 -12
- package/dist/filesystem-service.d.ts.map +1 -0
- package/dist/filesystem-service.js +326 -11
- package/dist/filesystem-service.test.cjs +10 -2
- package/dist/filesystem-service.test.d.ts +7 -2
- package/dist/filesystem-service.test.d.ts.map +1 -0
- package/dist/filesystem-service.test.js +10 -2
- package/dist/glob-files-tool.cjs +32 -46
- package/dist/glob-files-tool.d.ts +19 -9
- package/dist/glob-files-tool.d.ts.map +1 -0
- package/dist/glob-files-tool.js +33 -47
- package/dist/grep-content-tool.cjs +40 -45
- package/dist/grep-content-tool.d.ts +28 -9
- package/dist/grep-content-tool.d.ts.map +1 -0
- package/dist/grep-content-tool.js +41 -46
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +852 -14
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -2
- package/dist/path-validator.cjs +28 -2
- package/dist/path-validator.d.ts +20 -9
- package/dist/path-validator.d.ts.map +1 -0
- package/dist/path-validator.js +28 -2
- package/dist/path-validator.test.d.ts +7 -2
- package/dist/path-validator.test.d.ts.map +1 -0
- package/dist/read-file-tool.cjs +26 -59
- package/dist/read-file-tool.d.ts +19 -9
- package/dist/read-file-tool.d.ts.map +1 -0
- package/dist/read-file-tool.js +27 -50
- package/dist/tool-factory-config.cjs +61 -0
- package/dist/{tool-provider.d.ts → tool-factory-config.d.ts} +13 -30
- package/dist/tool-factory-config.d.ts.map +1 -0
- package/dist/tool-factory-config.js +36 -0
- package/dist/tool-factory.cjs +123 -0
- package/dist/tool-factory.d.ts +4 -0
- package/dist/tool-factory.d.ts.map +1 -0
- package/dist/tool-factory.js +102 -0
- package/dist/types.d.ts +82 -18
- package/dist/types.d.ts.map +1 -0
- package/dist/write-file-tool.cjs +93 -99
- package/dist/write-file-tool.d.ts +22 -9
- package/dist/write-file-tool.d.ts.map +1 -0
- package/dist/write-file-tool.js +97 -91
- package/dist/write-file-tool.test.cjs +139 -33
- package/dist/write-file-tool.test.d.ts +7 -2
- package/dist/write-file-tool.test.d.ts.map +1 -0
- package/dist/write-file-tool.test.js +139 -33
- package/package.json +5 -4
- package/dist/directory-approval.integration.test.d.cts +0 -2
- package/dist/edit-file-tool.d.cts +0 -17
- package/dist/edit-file-tool.test.d.cts +0 -2
- package/dist/error-codes.d.cts +0 -32
- package/dist/errors.d.cts +0 -112
- package/dist/file-tool-types.d.cts +0 -46
- package/dist/filesystem-service.d.cts +0 -112
- package/dist/filesystem-service.test.d.cts +0 -2
- package/dist/glob-files-tool.d.cts +0 -17
- package/dist/grep-content-tool.d.cts +0 -17
- package/dist/path-validator.d.cts +0 -97
- package/dist/path-validator.test.d.cts +0 -2
- package/dist/read-file-tool.d.cts +0 -17
- package/dist/tool-provider.cjs +0 -123
- package/dist/tool-provider.d.cts +0 -77
- package/dist/tool-provider.js +0 -99
- package/dist/types.d.cts +0 -178
- package/dist/write-file-tool.d.cts +0 -17
- package/dist/write-file-tool.test.d.cts +0 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const DEFAULT_ALLOWED_PATHS = ["."];
|
|
3
|
+
const DEFAULT_BLOCKED_PATHS = [".git", "node_modules/.bin", ".env"];
|
|
4
|
+
const DEFAULT_BLOCKED_EXTENSIONS = [".exe", ".dll", ".so"];
|
|
5
|
+
const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
6
|
+
const DEFAULT_ENABLE_BACKUPS = false;
|
|
7
|
+
const DEFAULT_BACKUP_RETENTION_DAYS = 7;
|
|
8
|
+
const FILESYSTEM_TOOL_NAMES = [
|
|
9
|
+
"read_file",
|
|
10
|
+
"write_file",
|
|
11
|
+
"edit_file",
|
|
12
|
+
"glob_files",
|
|
13
|
+
"grep_content"
|
|
14
|
+
];
|
|
15
|
+
const FileSystemToolsConfigSchema = z.object({
|
|
16
|
+
type: z.literal("filesystem-tools"),
|
|
17
|
+
allowedPaths: z.array(z.string()).default(DEFAULT_ALLOWED_PATHS).describe("List of allowed base paths for file operations"),
|
|
18
|
+
blockedPaths: z.array(z.string()).default(DEFAULT_BLOCKED_PATHS).describe("List of blocked paths to exclude from operations"),
|
|
19
|
+
blockedExtensions: z.array(z.string()).default(DEFAULT_BLOCKED_EXTENSIONS).describe("List of blocked file extensions"),
|
|
20
|
+
maxFileSize: z.number().int().positive().default(DEFAULT_MAX_FILE_SIZE).describe(
|
|
21
|
+
`Maximum file size in bytes (default: ${DEFAULT_MAX_FILE_SIZE / 1024 / 1024}MB)`
|
|
22
|
+
),
|
|
23
|
+
workingDirectory: z.string().optional().describe("Working directory for file operations (defaults to process.cwd())"),
|
|
24
|
+
enableBackups: z.boolean().default(DEFAULT_ENABLE_BACKUPS).describe("Enable automatic backups of modified files"),
|
|
25
|
+
backupPath: z.string().optional().describe("Absolute path for storing file backups (if enableBackups is true)"),
|
|
26
|
+
backupRetentionDays: z.number().int().positive().default(DEFAULT_BACKUP_RETENTION_DAYS).describe(
|
|
27
|
+
`Number of days to retain backup files (default: ${DEFAULT_BACKUP_RETENTION_DAYS})`
|
|
28
|
+
),
|
|
29
|
+
enabledTools: z.array(z.enum(FILESYSTEM_TOOL_NAMES)).optional().describe(
|
|
30
|
+
`Subset of tools to enable. If not specified, all tools are enabled. Available: ${FILESYSTEM_TOOL_NAMES.join(", ")}`
|
|
31
|
+
)
|
|
32
|
+
}).strict();
|
|
33
|
+
export {
|
|
34
|
+
FILESYSTEM_TOOL_NAMES,
|
|
35
|
+
FileSystemToolsConfigSchema
|
|
36
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tool_factory_exports = {};
|
|
20
|
+
__export(tool_factory_exports, {
|
|
21
|
+
fileSystemToolsFactory: () => fileSystemToolsFactory
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tool_factory_exports);
|
|
24
|
+
var import_core = require("@dexto/core");
|
|
25
|
+
var import_filesystem_service = require("./filesystem-service.js");
|
|
26
|
+
var import_read_file_tool = require("./read-file-tool.js");
|
|
27
|
+
var import_write_file_tool = require("./write-file-tool.js");
|
|
28
|
+
var import_edit_file_tool = require("./edit-file-tool.js");
|
|
29
|
+
var import_glob_files_tool = require("./glob-files-tool.js");
|
|
30
|
+
var import_grep_content_tool = require("./grep-content-tool.js");
|
|
31
|
+
var import_tool_factory_config = require("./tool-factory-config.js");
|
|
32
|
+
const fileSystemToolsFactory = {
|
|
33
|
+
configSchema: import_tool_factory_config.FileSystemToolsConfigSchema,
|
|
34
|
+
metadata: {
|
|
35
|
+
displayName: "Filesystem Tools",
|
|
36
|
+
description: "File system operations (read, write, edit, glob, grep)",
|
|
37
|
+
category: "filesystem"
|
|
38
|
+
},
|
|
39
|
+
create: (config) => {
|
|
40
|
+
const fileSystemConfig = {
|
|
41
|
+
allowedPaths: config.allowedPaths,
|
|
42
|
+
blockedPaths: config.blockedPaths,
|
|
43
|
+
blockedExtensions: config.blockedExtensions,
|
|
44
|
+
maxFileSize: config.maxFileSize,
|
|
45
|
+
workingDirectory: config.workingDirectory ?? process.cwd(),
|
|
46
|
+
enableBackups: config.enableBackups,
|
|
47
|
+
backupPath: config.backupPath,
|
|
48
|
+
backupRetentionDays: config.backupRetentionDays
|
|
49
|
+
};
|
|
50
|
+
let fileSystemService;
|
|
51
|
+
const resolveWorkingDirectory = (context) => context.workspace?.path ?? fileSystemConfig.workingDirectory ?? process.cwd();
|
|
52
|
+
const applyWorkspace = (context, service) => {
|
|
53
|
+
const workingDirectory = resolveWorkingDirectory(context);
|
|
54
|
+
service.setWorkingDirectory(workingDirectory);
|
|
55
|
+
};
|
|
56
|
+
const resolveInjectedService = (context) => {
|
|
57
|
+
const candidate = context.services?.filesystemService;
|
|
58
|
+
if (!candidate) return null;
|
|
59
|
+
if (candidate instanceof import_filesystem_service.FileSystemService) return candidate;
|
|
60
|
+
const hasMethods = typeof candidate.readFile === "function" && typeof candidate.writeFile === "function" && typeof candidate.setWorkingDirectory === "function" && typeof candidate.setDirectoryApprovalChecker === "function";
|
|
61
|
+
return hasMethods ? candidate : null;
|
|
62
|
+
};
|
|
63
|
+
const getFileSystemService = async (context) => {
|
|
64
|
+
const injectedService = resolveInjectedService(context);
|
|
65
|
+
if (injectedService) {
|
|
66
|
+
const approvalManager2 = context.services?.approval;
|
|
67
|
+
if (!approvalManager2) {
|
|
68
|
+
throw import_core.ToolError.configInvalid(
|
|
69
|
+
"filesystem-tools requires ToolExecutionContext.services.approval"
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
injectedService.setDirectoryApprovalChecker(
|
|
73
|
+
(filePath) => approvalManager2.isDirectoryApproved(filePath)
|
|
74
|
+
);
|
|
75
|
+
applyWorkspace(context, injectedService);
|
|
76
|
+
return injectedService;
|
|
77
|
+
}
|
|
78
|
+
if (fileSystemService) {
|
|
79
|
+
const approvalManager2 = context.services?.approval;
|
|
80
|
+
if (!approvalManager2) {
|
|
81
|
+
throw import_core.ToolError.configInvalid(
|
|
82
|
+
"filesystem-tools requires ToolExecutionContext.services.approval"
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
fileSystemService.setDirectoryApprovalChecker(
|
|
86
|
+
(filePath) => approvalManager2.isDirectoryApproved(filePath)
|
|
87
|
+
);
|
|
88
|
+
applyWorkspace(context, fileSystemService);
|
|
89
|
+
return fileSystemService;
|
|
90
|
+
}
|
|
91
|
+
const logger = context.logger;
|
|
92
|
+
fileSystemService = new import_filesystem_service.FileSystemService(fileSystemConfig, logger);
|
|
93
|
+
const approvalManager = context.services?.approval;
|
|
94
|
+
if (!approvalManager) {
|
|
95
|
+
throw import_core.ToolError.configInvalid(
|
|
96
|
+
"filesystem-tools requires ToolExecutionContext.services.approval"
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
fileSystemService.setDirectoryApprovalChecker(
|
|
100
|
+
(filePath) => approvalManager.isDirectoryApproved(filePath)
|
|
101
|
+
);
|
|
102
|
+
applyWorkspace(context, fileSystemService);
|
|
103
|
+
fileSystemService.initialize().catch((error) => {
|
|
104
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
105
|
+
logger.error(`Failed to initialize FileSystemService: ${message}`);
|
|
106
|
+
});
|
|
107
|
+
return fileSystemService;
|
|
108
|
+
};
|
|
109
|
+
const toolCreators = {
|
|
110
|
+
read_file: () => (0, import_read_file_tool.createReadFileTool)(getFileSystemService),
|
|
111
|
+
write_file: () => (0, import_write_file_tool.createWriteFileTool)(getFileSystemService),
|
|
112
|
+
edit_file: () => (0, import_edit_file_tool.createEditFileTool)(getFileSystemService),
|
|
113
|
+
glob_files: () => (0, import_glob_files_tool.createGlobFilesTool)(getFileSystemService),
|
|
114
|
+
grep_content: () => (0, import_grep_content_tool.createGrepContentTool)(getFileSystemService)
|
|
115
|
+
};
|
|
116
|
+
const toolsToCreate = config.enabledTools ?? import_tool_factory_config.FILESYSTEM_TOOL_NAMES;
|
|
117
|
+
return toolsToCreate.map((toolName) => toolCreators[toolName]());
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
+
0 && (module.exports = {
|
|
122
|
+
fileSystemToolsFactory
|
|
123
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-factory.d.ts","sourceRoot":"","sources":["../src/tool-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AASvD,OAAO,EAGH,KAAK,qBAAqB,EAC7B,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,qBAAqB,CA8GrE,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ToolError } from "@dexto/core";
|
|
2
|
+
import { FileSystemService } from "./filesystem-service.js";
|
|
3
|
+
import { createReadFileTool } from "./read-file-tool.js";
|
|
4
|
+
import { createWriteFileTool } from "./write-file-tool.js";
|
|
5
|
+
import { createEditFileTool } from "./edit-file-tool.js";
|
|
6
|
+
import { createGlobFilesTool } from "./glob-files-tool.js";
|
|
7
|
+
import { createGrepContentTool } from "./grep-content-tool.js";
|
|
8
|
+
import {
|
|
9
|
+
FILESYSTEM_TOOL_NAMES,
|
|
10
|
+
FileSystemToolsConfigSchema
|
|
11
|
+
} from "./tool-factory-config.js";
|
|
12
|
+
const fileSystemToolsFactory = {
|
|
13
|
+
configSchema: FileSystemToolsConfigSchema,
|
|
14
|
+
metadata: {
|
|
15
|
+
displayName: "Filesystem Tools",
|
|
16
|
+
description: "File system operations (read, write, edit, glob, grep)",
|
|
17
|
+
category: "filesystem"
|
|
18
|
+
},
|
|
19
|
+
create: (config) => {
|
|
20
|
+
const fileSystemConfig = {
|
|
21
|
+
allowedPaths: config.allowedPaths,
|
|
22
|
+
blockedPaths: config.blockedPaths,
|
|
23
|
+
blockedExtensions: config.blockedExtensions,
|
|
24
|
+
maxFileSize: config.maxFileSize,
|
|
25
|
+
workingDirectory: config.workingDirectory ?? process.cwd(),
|
|
26
|
+
enableBackups: config.enableBackups,
|
|
27
|
+
backupPath: config.backupPath,
|
|
28
|
+
backupRetentionDays: config.backupRetentionDays
|
|
29
|
+
};
|
|
30
|
+
let fileSystemService;
|
|
31
|
+
const resolveWorkingDirectory = (context) => context.workspace?.path ?? fileSystemConfig.workingDirectory ?? process.cwd();
|
|
32
|
+
const applyWorkspace = (context, service) => {
|
|
33
|
+
const workingDirectory = resolveWorkingDirectory(context);
|
|
34
|
+
service.setWorkingDirectory(workingDirectory);
|
|
35
|
+
};
|
|
36
|
+
const resolveInjectedService = (context) => {
|
|
37
|
+
const candidate = context.services?.filesystemService;
|
|
38
|
+
if (!candidate) return null;
|
|
39
|
+
if (candidate instanceof FileSystemService) return candidate;
|
|
40
|
+
const hasMethods = typeof candidate.readFile === "function" && typeof candidate.writeFile === "function" && typeof candidate.setWorkingDirectory === "function" && typeof candidate.setDirectoryApprovalChecker === "function";
|
|
41
|
+
return hasMethods ? candidate : null;
|
|
42
|
+
};
|
|
43
|
+
const getFileSystemService = async (context) => {
|
|
44
|
+
const injectedService = resolveInjectedService(context);
|
|
45
|
+
if (injectedService) {
|
|
46
|
+
const approvalManager2 = context.services?.approval;
|
|
47
|
+
if (!approvalManager2) {
|
|
48
|
+
throw ToolError.configInvalid(
|
|
49
|
+
"filesystem-tools requires ToolExecutionContext.services.approval"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
injectedService.setDirectoryApprovalChecker(
|
|
53
|
+
(filePath) => approvalManager2.isDirectoryApproved(filePath)
|
|
54
|
+
);
|
|
55
|
+
applyWorkspace(context, injectedService);
|
|
56
|
+
return injectedService;
|
|
57
|
+
}
|
|
58
|
+
if (fileSystemService) {
|
|
59
|
+
const approvalManager2 = context.services?.approval;
|
|
60
|
+
if (!approvalManager2) {
|
|
61
|
+
throw ToolError.configInvalid(
|
|
62
|
+
"filesystem-tools requires ToolExecutionContext.services.approval"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
fileSystemService.setDirectoryApprovalChecker(
|
|
66
|
+
(filePath) => approvalManager2.isDirectoryApproved(filePath)
|
|
67
|
+
);
|
|
68
|
+
applyWorkspace(context, fileSystemService);
|
|
69
|
+
return fileSystemService;
|
|
70
|
+
}
|
|
71
|
+
const logger = context.logger;
|
|
72
|
+
fileSystemService = new FileSystemService(fileSystemConfig, logger);
|
|
73
|
+
const approvalManager = context.services?.approval;
|
|
74
|
+
if (!approvalManager) {
|
|
75
|
+
throw ToolError.configInvalid(
|
|
76
|
+
"filesystem-tools requires ToolExecutionContext.services.approval"
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
fileSystemService.setDirectoryApprovalChecker(
|
|
80
|
+
(filePath) => approvalManager.isDirectoryApproved(filePath)
|
|
81
|
+
);
|
|
82
|
+
applyWorkspace(context, fileSystemService);
|
|
83
|
+
fileSystemService.initialize().catch((error) => {
|
|
84
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
85
|
+
logger.error(`Failed to initialize FileSystemService: ${message}`);
|
|
86
|
+
});
|
|
87
|
+
return fileSystemService;
|
|
88
|
+
};
|
|
89
|
+
const toolCreators = {
|
|
90
|
+
read_file: () => createReadFileTool(getFileSystemService),
|
|
91
|
+
write_file: () => createWriteFileTool(getFileSystemService),
|
|
92
|
+
edit_file: () => createEditFileTool(getFileSystemService),
|
|
93
|
+
glob_files: () => createGlobFilesTool(getFileSystemService),
|
|
94
|
+
grep_content: () => createGrepContentTool(getFileSystemService)
|
|
95
|
+
};
|
|
96
|
+
const toolsToCreate = config.enabledTools ?? FILESYSTEM_TOOL_NAMES;
|
|
97
|
+
return toolsToCreate.map((toolName) => toolCreators[toolName]());
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
fileSystemToolsFactory
|
|
102
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Types and interfaces for file system operations including reading, writing,
|
|
5
5
|
* searching, and validation.
|
|
6
6
|
*/
|
|
7
|
-
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
|
7
|
+
export type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
|
8
8
|
/**
|
|
9
9
|
* File content with metadata
|
|
10
10
|
*/
|
|
11
|
-
interface FileContent {
|
|
11
|
+
export interface FileContent {
|
|
12
12
|
content: string;
|
|
13
13
|
lines: number;
|
|
14
14
|
encoding: string;
|
|
@@ -19,7 +19,7 @@ interface FileContent {
|
|
|
19
19
|
/**
|
|
20
20
|
* Options for reading files
|
|
21
21
|
*/
|
|
22
|
-
interface ReadFileOptions {
|
|
22
|
+
export interface ReadFileOptions {
|
|
23
23
|
/** Maximum number of lines to read */
|
|
24
24
|
limit?: number | undefined;
|
|
25
25
|
/** Starting line number (1-based) */
|
|
@@ -30,16 +30,81 @@ interface ReadFileOptions {
|
|
|
30
30
|
/**
|
|
31
31
|
* File metadata for glob results
|
|
32
32
|
*/
|
|
33
|
-
interface FileMetadata {
|
|
33
|
+
export interface FileMetadata {
|
|
34
34
|
path: string;
|
|
35
35
|
size: number;
|
|
36
36
|
modified: Date;
|
|
37
37
|
isDirectory: boolean;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Directory entry metadata
|
|
41
|
+
*/
|
|
42
|
+
export interface DirectoryEntry {
|
|
43
|
+
name: string;
|
|
44
|
+
path: string;
|
|
45
|
+
isDirectory: boolean;
|
|
46
|
+
size: number;
|
|
47
|
+
modified: Date;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for listing directory contents
|
|
51
|
+
*/
|
|
52
|
+
export interface ListDirectoryOptions {
|
|
53
|
+
/** Include hidden files/directories (dotfiles) */
|
|
54
|
+
includeHidden?: boolean | undefined;
|
|
55
|
+
/** Include stat metadata */
|
|
56
|
+
includeMetadata?: boolean | undefined;
|
|
57
|
+
/** Maximum number of entries to return */
|
|
58
|
+
maxEntries?: number | undefined;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Directory listing result
|
|
62
|
+
*/
|
|
63
|
+
export interface ListDirectoryResult {
|
|
64
|
+
path: string;
|
|
65
|
+
entries: DirectoryEntry[];
|
|
66
|
+
truncated: boolean;
|
|
67
|
+
totalEntries: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Options for creating directories
|
|
71
|
+
*/
|
|
72
|
+
export interface CreateDirectoryOptions {
|
|
73
|
+
/** Create intermediate directories if they don't exist */
|
|
74
|
+
recursive?: boolean | undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create directory result
|
|
78
|
+
*/
|
|
79
|
+
export interface CreateDirectoryResult {
|
|
80
|
+
path: string;
|
|
81
|
+
created: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Options for deleting paths
|
|
85
|
+
*/
|
|
86
|
+
export interface DeletePathOptions {
|
|
87
|
+
/** Recursively delete directories */
|
|
88
|
+
recursive?: boolean | undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Delete path result
|
|
92
|
+
*/
|
|
93
|
+
export interface DeletePathResult {
|
|
94
|
+
path: string;
|
|
95
|
+
deleted: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Rename path result
|
|
99
|
+
*/
|
|
100
|
+
export interface RenamePathResult {
|
|
101
|
+
from: string;
|
|
102
|
+
to: string;
|
|
103
|
+
}
|
|
39
104
|
/**
|
|
40
105
|
* Options for glob operations
|
|
41
106
|
*/
|
|
42
|
-
interface GlobOptions {
|
|
107
|
+
export interface GlobOptions {
|
|
43
108
|
/** Base directory to search from */
|
|
44
109
|
cwd?: string | undefined;
|
|
45
110
|
/** Maximum number of results */
|
|
@@ -50,7 +115,7 @@ interface GlobOptions {
|
|
|
50
115
|
/**
|
|
51
116
|
* Glob result
|
|
52
117
|
*/
|
|
53
|
-
interface GlobResult {
|
|
118
|
+
export interface GlobResult {
|
|
54
119
|
files: FileMetadata[];
|
|
55
120
|
truncated: boolean;
|
|
56
121
|
totalFound: number;
|
|
@@ -58,7 +123,7 @@ interface GlobResult {
|
|
|
58
123
|
/**
|
|
59
124
|
* Search match with context
|
|
60
125
|
*/
|
|
61
|
-
interface SearchMatch {
|
|
126
|
+
export interface SearchMatch {
|
|
62
127
|
file: string;
|
|
63
128
|
lineNumber: number;
|
|
64
129
|
line: string;
|
|
@@ -70,7 +135,7 @@ interface SearchMatch {
|
|
|
70
135
|
/**
|
|
71
136
|
* Options for content search (grep)
|
|
72
137
|
*/
|
|
73
|
-
interface GrepOptions {
|
|
138
|
+
export interface GrepOptions {
|
|
74
139
|
/** Base directory to search */
|
|
75
140
|
path?: string | undefined;
|
|
76
141
|
/** Glob pattern to filter files */
|
|
@@ -87,7 +152,7 @@ interface GrepOptions {
|
|
|
87
152
|
/**
|
|
88
153
|
* Search result
|
|
89
154
|
*/
|
|
90
|
-
interface SearchResult {
|
|
155
|
+
export interface SearchResult {
|
|
91
156
|
matches: SearchMatch[];
|
|
92
157
|
totalMatches: number;
|
|
93
158
|
truncated: boolean;
|
|
@@ -96,7 +161,7 @@ interface SearchResult {
|
|
|
96
161
|
/**
|
|
97
162
|
* Options for writing files
|
|
98
163
|
*/
|
|
99
|
-
interface WriteFileOptions {
|
|
164
|
+
export interface WriteFileOptions {
|
|
100
165
|
/** Create parent directories if they don't exist */
|
|
101
166
|
createDirs?: boolean | undefined;
|
|
102
167
|
/** File encoding (default: utf-8) */
|
|
@@ -107,7 +172,7 @@ interface WriteFileOptions {
|
|
|
107
172
|
/**
|
|
108
173
|
* Write result
|
|
109
174
|
*/
|
|
110
|
-
interface WriteResult {
|
|
175
|
+
export interface WriteResult {
|
|
111
176
|
success: boolean;
|
|
112
177
|
path: string;
|
|
113
178
|
bytesWritten: number;
|
|
@@ -118,7 +183,7 @@ interface WriteResult {
|
|
|
118
183
|
/**
|
|
119
184
|
* Edit operation
|
|
120
185
|
*/
|
|
121
|
-
interface EditOperation {
|
|
186
|
+
export interface EditOperation {
|
|
122
187
|
oldString: string;
|
|
123
188
|
newString: string;
|
|
124
189
|
replaceAll?: boolean | undefined;
|
|
@@ -126,7 +191,7 @@ interface EditOperation {
|
|
|
126
191
|
/**
|
|
127
192
|
* Options for editing files
|
|
128
193
|
*/
|
|
129
|
-
interface EditFileOptions {
|
|
194
|
+
export interface EditFileOptions {
|
|
130
195
|
/** Create backup before editing */
|
|
131
196
|
backup?: boolean;
|
|
132
197
|
/** File encoding */
|
|
@@ -135,7 +200,7 @@ interface EditFileOptions {
|
|
|
135
200
|
/**
|
|
136
201
|
* Edit result
|
|
137
202
|
*/
|
|
138
|
-
interface EditResult {
|
|
203
|
+
export interface EditResult {
|
|
139
204
|
success: boolean;
|
|
140
205
|
path: string;
|
|
141
206
|
changesCount: number;
|
|
@@ -148,7 +213,7 @@ interface EditResult {
|
|
|
148
213
|
/**
|
|
149
214
|
* Path validation result
|
|
150
215
|
*/
|
|
151
|
-
interface PathValidation {
|
|
216
|
+
export interface PathValidation {
|
|
152
217
|
isValid: boolean;
|
|
153
218
|
error?: string;
|
|
154
219
|
normalizedPath?: string;
|
|
@@ -156,7 +221,7 @@ interface PathValidation {
|
|
|
156
221
|
/**
|
|
157
222
|
* File system configuration
|
|
158
223
|
*/
|
|
159
|
-
interface FileSystemConfig {
|
|
224
|
+
export interface FileSystemConfig {
|
|
160
225
|
/** Allowed base paths */
|
|
161
226
|
allowedPaths: string[];
|
|
162
227
|
/** Blocked paths (relative to allowed paths) */
|
|
@@ -174,5 +239,4 @@ interface FileSystemConfig {
|
|
|
174
239
|
/** Working directory for glob/grep operations (defaults to process.cwd()) */
|
|
175
240
|
workingDirectory?: string | undefined;
|
|
176
241
|
}
|
|
177
|
-
|
|
178
|
-
export type { BufferEncoding, EditFileOptions, EditOperation, EditResult, FileContent, FileMetadata, FileSystemConfig, GlobOptions, GlobResult, GrepOptions, PathValidation, ReadFileOptions, SearchMatch, SearchResult, WriteFileOptions, WriteResult };
|
|
242
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,cAAc,GACpB,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,QAA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