@datalyr/wizard 1.0.7 → 1.0.8

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/index.mjs CHANGED
@@ -3309,7 +3309,7 @@ async function executeAgent(params) {
3309
3309
  { role: "user", content: initialMessage }
3310
3310
  ];
3311
3311
  const filesModified = [];
3312
- const maxIterations = 20;
3312
+ const maxIterations = 30;
3313
3313
  let iterations = 0;
3314
3314
  while (iterations < maxIterations) {
3315
3315
  iterations++;
@@ -3481,6 +3481,73 @@ async function executeTool(toolUse, cwd, debug) {
3481
3481
  });
3482
3482
  return { content: files.slice(0, 100).join("\n") };
3483
3483
  }
3484
+ case "edit_file": {
3485
+ if (typeof input2.path !== "string" || !input2.path.trim()) {
3486
+ return { content: "Error: path must be a non-empty string", is_error: true };
3487
+ }
3488
+ if (typeof input2.old_string !== "string") {
3489
+ return { content: "Error: old_string must be a string", is_error: true };
3490
+ }
3491
+ if (typeof input2.new_string !== "string") {
3492
+ return { content: "Error: new_string must be a string", is_error: true };
3493
+ }
3494
+ const path6 = input2.path.trim();
3495
+ const oldString = input2.old_string;
3496
+ const newString = input2.new_string;
3497
+ if (!isPathSafe(cwd, path6)) {
3498
+ return { content: "Error: path traversal detected - access denied", is_error: true };
3499
+ }
3500
+ const fullPath = join(cwd, path6);
3501
+ const content = await readFile2(fullPath, "utf-8");
3502
+ const occurrences = content.split(oldString).length - 1;
3503
+ if (occurrences === 0) {
3504
+ return { content: `Error: old_string not found in ${path6}`, is_error: true };
3505
+ }
3506
+ if (occurrences > 1) {
3507
+ return { content: `Error: old_string found ${occurrences} times in ${path6} - must be unique`, is_error: true };
3508
+ }
3509
+ const newContent = content.replace(oldString, newString);
3510
+ await writeFile2(fullPath, newContent, "utf-8");
3511
+ return { content: `Successfully edited ${path6}` };
3512
+ }
3513
+ case "search_files": {
3514
+ if (typeof input2.pattern !== "string" || !input2.pattern.trim()) {
3515
+ return { content: "Error: pattern must be a non-empty string", is_error: true };
3516
+ }
3517
+ const searchPattern = input2.pattern.trim();
3518
+ const searchPath = typeof input2.path === "string" ? input2.path.trim() : ".";
3519
+ const filePattern = typeof input2.file_pattern === "string" ? input2.file_pattern : "**/*.{ts,tsx,js,jsx,json,md}";
3520
+ if (!isPathSafe(cwd, searchPath)) {
3521
+ return { content: "Error: path traversal detected - access denied", is_error: true };
3522
+ }
3523
+ const fullPath = join(cwd, searchPath);
3524
+ const files = await glob2(filePattern, {
3525
+ cwd: fullPath,
3526
+ nodir: true,
3527
+ maxDepth: 5
3528
+ });
3529
+ const results = [];
3530
+ const regex = new RegExp(searchPattern, "gi");
3531
+ for (const file of files.slice(0, 50)) {
3532
+ try {
3533
+ const filePath = join(fullPath, file);
3534
+ const content = await readFile2(filePath, "utf-8");
3535
+ const lines = content.split("\n");
3536
+ lines.forEach((line, index) => {
3537
+ if (regex.test(line)) {
3538
+ results.push(`${file}:${index + 1}: ${line.trim().slice(0, 100)}`);
3539
+ }
3540
+ regex.lastIndex = 0;
3541
+ });
3542
+ } catch {
3543
+ }
3544
+ if (results.length >= 50) break;
3545
+ }
3546
+ if (results.length === 0) {
3547
+ return { content: `No matches found for "${searchPattern}"` };
3548
+ }
3549
+ return { content: results.join("\n") };
3550
+ }
3484
3551
  default:
3485
3552
  return { content: `Unknown tool: ${name}`, is_error: true };
3486
3553
  }