@dexto/tools-filesystem 1.5.6 → 1.5.7

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.
@@ -267,8 +267,29 @@ class FileSystemService {
267
267
  */
268
268
  async searchContent(pattern, options = {}) {
269
269
  await this.ensureInitialized();
270
- const searchPath = options.path || this.config.workingDirectory || process.cwd();
271
- const globPattern = options.glob || "**/*";
270
+ const basePath = options.path || this.config.workingDirectory || process.cwd();
271
+ let searchPath;
272
+ let globPattern;
273
+ const baseValidation = await this.pathValidator.validatePath(basePath);
274
+ if (!baseValidation.isValid || !baseValidation.normalizedPath) {
275
+ throw import_errors.FileSystemError.invalidPath(basePath, baseValidation.error || "Unknown error");
276
+ }
277
+ const resolvedPath = baseValidation.normalizedPath;
278
+ try {
279
+ const stats = await fs.stat(resolvedPath);
280
+ if (stats.isFile()) {
281
+ searchPath = path.dirname(resolvedPath);
282
+ const fileName = path.basename(resolvedPath);
283
+ const escapedFileName = fileName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
284
+ globPattern = options.glob || escapedFileName;
285
+ } else {
286
+ searchPath = resolvedPath;
287
+ globPattern = options.glob || "**/*";
288
+ }
289
+ } catch {
290
+ searchPath = resolvedPath;
291
+ globPattern = options.glob || "**/*";
292
+ }
272
293
  const maxResults = options.maxResults || DEFAULT_MAX_SEARCH_RESULTS;
273
294
  const contextLines = options.contextLines || 0;
274
295
  try {
@@ -234,8 +234,29 @@ class FileSystemService {
234
234
  */
235
235
  async searchContent(pattern, options = {}) {
236
236
  await this.ensureInitialized();
237
- const searchPath = options.path || this.config.workingDirectory || process.cwd();
238
- const globPattern = options.glob || "**/*";
237
+ const basePath = options.path || this.config.workingDirectory || process.cwd();
238
+ let searchPath;
239
+ let globPattern;
240
+ const baseValidation = await this.pathValidator.validatePath(basePath);
241
+ if (!baseValidation.isValid || !baseValidation.normalizedPath) {
242
+ throw FileSystemError.invalidPath(basePath, baseValidation.error || "Unknown error");
243
+ }
244
+ const resolvedPath = baseValidation.normalizedPath;
245
+ try {
246
+ const stats = await fs.stat(resolvedPath);
247
+ if (stats.isFile()) {
248
+ searchPath = path.dirname(resolvedPath);
249
+ const fileName = path.basename(resolvedPath);
250
+ const escapedFileName = fileName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
251
+ globPattern = options.glob || escapedFileName;
252
+ } else {
253
+ searchPath = resolvedPath;
254
+ globPattern = options.glob || "**/*";
255
+ }
256
+ } catch {
257
+ searchPath = resolvedPath;
258
+ globPattern = options.glob || "**/*";
259
+ }
239
260
  const maxResults = options.maxResults || DEFAULT_MAX_SEARCH_RESULTS;
240
261
  const contextLines = options.contextLines || 0;
241
262
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/tools-filesystem",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "FileSystem tools provider for Dexto agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "glob": "^11.1.0",
23
23
  "safe-regex": "^2.1.1",
24
24
  "zod": "^3.25.0",
25
- "@dexto/core": "1.5.6"
25
+ "@dexto/core": "1.5.7"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/diff": "^5.2.3",