@dexto/tools-filesystem 1.6.0 → 1.6.2

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 (73) hide show
  1. package/dist/directory-approval.cjs +44 -40
  2. package/dist/directory-approval.d.ts +8 -4
  3. package/dist/directory-approval.d.ts.map +1 -1
  4. package/dist/directory-approval.integration.test.cjs +107 -356
  5. package/dist/directory-approval.integration.test.d.ts +6 -6
  6. package/dist/directory-approval.integration.test.js +109 -360
  7. package/dist/directory-approval.js +45 -41
  8. package/dist/edit-file-tool.cjs +69 -47
  9. package/dist/edit-file-tool.d.ts.map +1 -1
  10. package/dist/edit-file-tool.js +77 -48
  11. package/dist/edit-file-tool.test.cjs +54 -11
  12. package/dist/edit-file-tool.test.js +54 -11
  13. package/dist/error-codes.cjs +4 -0
  14. package/dist/error-codes.d.ts +4 -0
  15. package/dist/error-codes.d.ts.map +1 -1
  16. package/dist/error-codes.js +4 -0
  17. package/dist/errors.cjs +48 -0
  18. package/dist/errors.d.ts +16 -0
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/errors.js +48 -0
  21. package/dist/filesystem-service.cjs +307 -9
  22. package/dist/filesystem-service.d.ts +28 -1
  23. package/dist/filesystem-service.d.ts.map +1 -1
  24. package/dist/filesystem-service.js +308 -10
  25. package/dist/glob-files-tool.cjs +12 -1
  26. package/dist/glob-files-tool.d.ts.map +1 -1
  27. package/dist/glob-files-tool.js +13 -2
  28. package/dist/grep-content-tool.cjs +13 -1
  29. package/dist/grep-content-tool.d.ts.map +1 -1
  30. package/dist/grep-content-tool.js +14 -2
  31. package/dist/index.cjs +3 -0
  32. package/dist/index.d.cts +852 -16
  33. package/dist/index.d.ts +2 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/path-validator.cjs +28 -2
  37. package/dist/path-validator.d.ts +14 -0
  38. package/dist/path-validator.d.ts.map +1 -1
  39. package/dist/path-validator.js +28 -2
  40. package/dist/read-file-tool.cjs +7 -1
  41. package/dist/read-file-tool.d.ts.map +1 -1
  42. package/dist/read-file-tool.js +8 -2
  43. package/dist/tool-factory.cjs +21 -0
  44. package/dist/tool-factory.d.ts.map +1 -1
  45. package/dist/tool-factory.js +21 -0
  46. package/dist/types.d.ts +65 -0
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/write-file-tool.cjs +60 -38
  49. package/dist/write-file-tool.d.ts +1 -1
  50. package/dist/write-file-tool.d.ts.map +1 -1
  51. package/dist/write-file-tool.js +67 -39
  52. package/dist/write-file-tool.test.cjs +75 -13
  53. package/dist/write-file-tool.test.js +75 -13
  54. package/package.json +6 -6
  55. package/dist/directory-approval.d.cts +0 -22
  56. package/dist/directory-approval.integration.test.d.cts +0 -2
  57. package/dist/edit-file-tool.d.cts +0 -34
  58. package/dist/edit-file-tool.test.d.cts +0 -2
  59. package/dist/error-codes.d.cts +0 -32
  60. package/dist/errors.d.cts +0 -112
  61. package/dist/file-tool-types.d.cts +0 -18
  62. package/dist/filesystem-service.d.cts +0 -117
  63. package/dist/filesystem-service.test.d.cts +0 -2
  64. package/dist/glob-files-tool.d.cts +0 -31
  65. package/dist/grep-content-tool.d.cts +0 -40
  66. package/dist/path-validator.d.cts +0 -97
  67. package/dist/path-validator.test.d.cts +0 -2
  68. package/dist/read-file-tool.d.cts +0 -31
  69. package/dist/tool-factory-config.d.cts +0 -63
  70. package/dist/tool-factory.d.cts +0 -7
  71. package/dist/types.d.cts +0 -178
  72. package/dist/write-file-tool.d.cts +0 -34
  73. package/dist/write-file-tool.test.d.cts +0 -2
package/dist/types.d.cts DELETED
@@ -1,178 +0,0 @@
1
- /**
2
- * FileSystem Service Types
3
- *
4
- * Types and interfaces for file system operations including reading, writing,
5
- * searching, and validation.
6
- */
7
- type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
8
- /**
9
- * File content with metadata
10
- */
11
- interface FileContent {
12
- content: string;
13
- lines: number;
14
- encoding: string;
15
- mimeType?: string;
16
- truncated: boolean;
17
- size: number;
18
- }
19
- /**
20
- * Options for reading files
21
- */
22
- interface ReadFileOptions {
23
- /** Maximum number of lines to read */
24
- limit?: number | undefined;
25
- /** Starting line number (1-based) */
26
- offset?: number | undefined;
27
- /** File encoding (default: utf-8) */
28
- encoding?: BufferEncoding | undefined;
29
- }
30
- /**
31
- * File metadata for glob results
32
- */
33
- interface FileMetadata {
34
- path: string;
35
- size: number;
36
- modified: Date;
37
- isDirectory: boolean;
38
- }
39
- /**
40
- * Options for glob operations
41
- */
42
- interface GlobOptions {
43
- /** Base directory to search from */
44
- cwd?: string | undefined;
45
- /** Maximum number of results */
46
- maxResults?: number | undefined;
47
- /** Include file metadata */
48
- includeMetadata?: boolean | undefined;
49
- }
50
- /**
51
- * Glob result
52
- */
53
- interface GlobResult {
54
- files: FileMetadata[];
55
- truncated: boolean;
56
- totalFound: number;
57
- }
58
- /**
59
- * Search match with context
60
- */
61
- interface SearchMatch {
62
- file: string;
63
- lineNumber: number;
64
- line: string;
65
- context?: {
66
- before: string[];
67
- after: string[];
68
- };
69
- }
70
- /**
71
- * Options for content search (grep)
72
- */
73
- interface GrepOptions {
74
- /** Base directory to search */
75
- path?: string | undefined;
76
- /** Glob pattern to filter files */
77
- glob?: string | undefined;
78
- /** Number of context lines before/after match */
79
- contextLines?: number | undefined;
80
- /** Case-insensitive search */
81
- caseInsensitive?: boolean | undefined;
82
- /** Maximum number of results */
83
- maxResults?: number | undefined;
84
- /** Include line numbers */
85
- lineNumbers?: boolean | undefined;
86
- }
87
- /**
88
- * Search result
89
- */
90
- interface SearchResult {
91
- matches: SearchMatch[];
92
- totalMatches: number;
93
- truncated: boolean;
94
- filesSearched: number;
95
- }
96
- /**
97
- * Options for writing files
98
- */
99
- interface WriteFileOptions {
100
- /** Create parent directories if they don't exist */
101
- createDirs?: boolean | undefined;
102
- /** File encoding (default: utf-8) */
103
- encoding?: BufferEncoding | undefined;
104
- /** Create backup before overwriting */
105
- backup?: boolean | undefined;
106
- }
107
- /**
108
- * Write result
109
- */
110
- interface WriteResult {
111
- success: boolean;
112
- path: string;
113
- bytesWritten: number;
114
- backupPath?: string | undefined;
115
- /** Original content if file was overwritten (undefined for new files) */
116
- originalContent?: string | undefined;
117
- }
118
- /**
119
- * Edit operation
120
- */
121
- interface EditOperation {
122
- oldString: string;
123
- newString: string;
124
- replaceAll?: boolean | undefined;
125
- }
126
- /**
127
- * Options for editing files
128
- */
129
- interface EditFileOptions {
130
- /** Create backup before editing */
131
- backup?: boolean;
132
- /** File encoding */
133
- encoding?: BufferEncoding;
134
- }
135
- /**
136
- * Edit result
137
- */
138
- interface EditResult {
139
- success: boolean;
140
- path: string;
141
- changesCount: number;
142
- backupPath?: string | undefined;
143
- /** Original content before edit (for diff generation) */
144
- originalContent: string;
145
- /** New content after edit (for diff generation) */
146
- newContent: string;
147
- }
148
- /**
149
- * Path validation result
150
- */
151
- interface PathValidation {
152
- isValid: boolean;
153
- error?: string;
154
- normalizedPath?: string;
155
- }
156
- /**
157
- * File system configuration
158
- */
159
- interface FileSystemConfig {
160
- /** Allowed base paths */
161
- allowedPaths: string[];
162
- /** Blocked paths (relative to allowed paths) */
163
- blockedPaths: string[];
164
- /** Blocked file extensions */
165
- blockedExtensions: string[];
166
- /** Maximum file size in bytes */
167
- maxFileSize: number;
168
- /** Enable automatic backups */
169
- enableBackups: boolean;
170
- /** Backup directory absolute path (required when enableBackups is true - provided by CLI enrichment) */
171
- backupPath?: string | undefined;
172
- /** Backup retention period in days (default: 7) */
173
- backupRetentionDays: number;
174
- /** Working directory for glob/grep operations (defaults to process.cwd()) */
175
- workingDirectory?: string | undefined;
176
- }
177
-
178
- export type { BufferEncoding, EditFileOptions, EditOperation, EditResult, FileContent, FileMetadata, FileSystemConfig, GlobOptions, GlobResult, GrepOptions, PathValidation, ReadFileOptions, SearchMatch, SearchResult, WriteFileOptions, WriteResult };
@@ -1,34 +0,0 @@
1
- import { z } from 'zod';
2
- import { Tool } from '@dexto/core';
3
- import { FileSystemServiceGetter } from './file-tool-types.cjs';
4
- import './filesystem-service.cjs';
5
- import './types.cjs';
6
-
7
- /**
8
- * Write File Tool
9
- *
10
- * Internal tool for writing content to files (requires approval)
11
- */
12
-
13
- declare const WriteFileInputSchema: z.ZodObject<{
14
- file_path: z.ZodString;
15
- content: z.ZodString;
16
- create_dirs: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
17
- encoding: z.ZodDefault<z.ZodOptional<z.ZodEnum<["utf-8", "ascii", "latin1", "utf16le"]>>>;
18
- }, "strict", z.ZodTypeAny, {
19
- encoding: "ascii" | "utf-8" | "utf16le" | "latin1";
20
- content: string;
21
- file_path: string;
22
- create_dirs: boolean;
23
- }, {
24
- content: string;
25
- file_path: string;
26
- encoding?: "ascii" | "utf-8" | "utf16le" | "latin1" | undefined;
27
- create_dirs?: boolean | undefined;
28
- }>;
29
- /**
30
- * Create the write_file internal tool with directory approval support
31
- */
32
- declare function createWriteFileTool(getFileSystemService: FileSystemServiceGetter): Tool<typeof WriteFileInputSchema>;
33
-
34
- export { createWriteFileTool };
@@ -1,2 +0,0 @@
1
-
2
- export { }