@datalyr/wizard 1.0.6 → 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.
@@ -2135,8 +2135,12 @@ async function runAgentWizard(_config, options = {}) {
2135
2135
  enableServerSideConversions: false
2136
2136
  };
2137
2137
  if (!p.isCancel(runningAds) && runningAds) {
2138
+ p.note(
2139
+ `${import_chalk.default.dim("Use")} ${import_chalk.default.cyan("\u2191\u2193")} ${import_chalk.default.dim("to navigate,")} ${import_chalk.default.cyan("Space")} ${import_chalk.default.dim("to select,")} ${import_chalk.default.cyan("Enter")} ${import_chalk.default.dim("to confirm")}`,
2140
+ "Controls"
2141
+ );
2138
2142
  const adPlatformChoices = await p.multiselect({
2139
- message: "Select your ad platforms:",
2143
+ message: "Select your ad platforms (Space to toggle, Enter to confirm):",
2140
2144
  options: AD_PLATFORMS.filter((p2) => p2.id !== "none").map((platform) => ({
2141
2145
  value: platform.id,
2142
2146
  label: platform.label,
@@ -2228,7 +2232,7 @@ ${import_chalk.default.bold("High-value events")} are the key actions that matte
2228
2232
  "Suggested Events"
2229
2233
  );
2230
2234
  const selectedEventNames = await p.multiselect({
2231
- message: "Select events to track:",
2235
+ message: "Select events to track (Space to toggle, Enter to confirm):",
2232
2236
  options: eventOptions,
2233
2237
  initialValues: ["__all_recommended__"],
2234
2238
  required: false
@@ -2361,7 +2365,7 @@ async function executeAgent(params) {
2361
2365
  { role: "user", content: initialMessage }
2362
2366
  ];
2363
2367
  const filesModified = [];
2364
- const maxIterations = 20;
2368
+ const maxIterations = 30;
2365
2369
  let iterations = 0;
2366
2370
  while (iterations < maxIterations) {
2367
2371
  iterations++;
@@ -2533,6 +2537,73 @@ async function executeTool(toolUse, cwd, debug) {
2533
2537
  });
2534
2538
  return { content: files.slice(0, 100).join("\n") };
2535
2539
  }
2540
+ case "edit_file": {
2541
+ if (typeof input.path !== "string" || !input.path.trim()) {
2542
+ return { content: "Error: path must be a non-empty string", is_error: true };
2543
+ }
2544
+ if (typeof input.old_string !== "string") {
2545
+ return { content: "Error: old_string must be a string", is_error: true };
2546
+ }
2547
+ if (typeof input.new_string !== "string") {
2548
+ return { content: "Error: new_string must be a string", is_error: true };
2549
+ }
2550
+ const path3 = input.path.trim();
2551
+ const oldString = input.old_string;
2552
+ const newString = input.new_string;
2553
+ if (!isPathSafe(cwd, path3)) {
2554
+ return { content: "Error: path traversal detected - access denied", is_error: true };
2555
+ }
2556
+ const fullPath = (0, import_path3.join)(cwd, path3);
2557
+ const content = await (0, import_promises.readFile)(fullPath, "utf-8");
2558
+ const occurrences = content.split(oldString).length - 1;
2559
+ if (occurrences === 0) {
2560
+ return { content: `Error: old_string not found in ${path3}`, is_error: true };
2561
+ }
2562
+ if (occurrences > 1) {
2563
+ return { content: `Error: old_string found ${occurrences} times in ${path3} - must be unique`, is_error: true };
2564
+ }
2565
+ const newContent = content.replace(oldString, newString);
2566
+ await (0, import_promises.writeFile)(fullPath, newContent, "utf-8");
2567
+ return { content: `Successfully edited ${path3}` };
2568
+ }
2569
+ case "search_files": {
2570
+ if (typeof input.pattern !== "string" || !input.pattern.trim()) {
2571
+ return { content: "Error: pattern must be a non-empty string", is_error: true };
2572
+ }
2573
+ const searchPattern = input.pattern.trim();
2574
+ const searchPath = typeof input.path === "string" ? input.path.trim() : ".";
2575
+ const filePattern = typeof input.file_pattern === "string" ? input.file_pattern : "**/*.{ts,tsx,js,jsx,json,md}";
2576
+ if (!isPathSafe(cwd, searchPath)) {
2577
+ return { content: "Error: path traversal detected - access denied", is_error: true };
2578
+ }
2579
+ const fullPath = (0, import_path3.join)(cwd, searchPath);
2580
+ const files = await (0, import_glob2.glob)(filePattern, {
2581
+ cwd: fullPath,
2582
+ nodir: true,
2583
+ maxDepth: 5
2584
+ });
2585
+ const results = [];
2586
+ const regex = new RegExp(searchPattern, "gi");
2587
+ for (const file of files.slice(0, 50)) {
2588
+ try {
2589
+ const filePath = (0, import_path3.join)(fullPath, file);
2590
+ const content = await (0, import_promises.readFile)(filePath, "utf-8");
2591
+ const lines = content.split("\n");
2592
+ lines.forEach((line, index) => {
2593
+ if (regex.test(line)) {
2594
+ results.push(`${file}:${index + 1}: ${line.trim().slice(0, 100)}`);
2595
+ }
2596
+ regex.lastIndex = 0;
2597
+ });
2598
+ } catch {
2599
+ }
2600
+ if (results.length >= 50) break;
2601
+ }
2602
+ if (results.length === 0) {
2603
+ return { content: `No matches found for "${searchPattern}"` };
2604
+ }
2605
+ return { content: results.join("\n") };
2606
+ }
2536
2607
  default:
2537
2608
  return { content: `Unknown tool: ${name}`, is_error: true };
2538
2609
  }