fluxflow-cli 3.0.18 → 3.0.20

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 (2) hide show
  1. package/dist/fluxflow.js +360 -231
  2. package/package.json +1 -1
package/dist/fluxflow.js CHANGED
@@ -7850,6 +7850,121 @@ var init_usage = __esm({
7850
7850
  }
7851
7851
  });
7852
7852
 
7853
+ // src/utils/puppeteer_helper.js
7854
+ import os4 from "os";
7855
+ import path8 from "path";
7856
+ import fs9 from "fs";
7857
+ import { createRequire } from "module";
7858
+ import { fileURLToPath } from "url";
7859
+ function getPuppeteerConfig() {
7860
+ const platform = os4.platform();
7861
+ const arch = os4.arch();
7862
+ let pptrPlatform = "";
7863
+ let execName = "";
7864
+ let subDir = "";
7865
+ if (platform === "win32") {
7866
+ pptrPlatform = arch === "x64" ? "win64" : "win32";
7867
+ execName = "chrome.exe";
7868
+ subDir = `chrome-${pptrPlatform}`;
7869
+ } else if (platform === "darwin") {
7870
+ pptrPlatform = arch === "arm64" ? "mac_arm" : "mac";
7871
+ const archSuffix = arch === "arm64" ? "arm64" : "x64";
7872
+ execName = "Google Chrome.app/Contents/MacOS/Google Chrome";
7873
+ subDir = `chrome-mac-${archSuffix}`;
7874
+ } else if (platform === "linux") {
7875
+ pptrPlatform = "linux";
7876
+ execName = "chrome";
7877
+ subDir = "chrome-linux64";
7878
+ } else {
7879
+ return {};
7880
+ }
7881
+ let configPath = path8.resolve(__dirname, "..", "..", ".puppeteerrc.cjs");
7882
+ if (!fs9.existsSync(configPath)) {
7883
+ configPath = path8.resolve(__dirname, "..", ".puppeteerrc.cjs");
7884
+ }
7885
+ if (!fs9.existsSync(configPath)) {
7886
+ return {};
7887
+ }
7888
+ try {
7889
+ const config = require2(configPath);
7890
+ const cacheDir = config.cacheDirectory;
7891
+ const version = config.chrome?.version;
7892
+ if (cacheDir) {
7893
+ process.env.PUPPETEER_CACHE_DIR = cacheDir;
7894
+ if (version) {
7895
+ const expectedPath = path8.join(
7896
+ cacheDir,
7897
+ "chrome",
7898
+ `${pptrPlatform}-${version}`,
7899
+ subDir,
7900
+ execName
7901
+ );
7902
+ if (fs9.existsSync(expectedPath)) {
7903
+ return {
7904
+ executablePath: expectedPath,
7905
+ cacheDirectory: cacheDir
7906
+ };
7907
+ }
7908
+ }
7909
+ const findExecutable = (dir) => {
7910
+ if (!fs9.existsSync(dir)) return null;
7911
+ try {
7912
+ const files = fs9.readdirSync(dir);
7913
+ const dirsToSearch = [];
7914
+ for (const file of files) {
7915
+ const fullPath = path8.join(dir, file);
7916
+ let stat;
7917
+ try {
7918
+ stat = fs9.statSync(fullPath);
7919
+ } catch (e) {
7920
+ continue;
7921
+ }
7922
+ if (stat.isDirectory()) {
7923
+ dirsToSearch.push(fullPath);
7924
+ } else if (file.toLowerCase() === execName.toLowerCase()) {
7925
+ if (!version || fullPath.includes(version)) {
7926
+ return fullPath;
7927
+ }
7928
+ }
7929
+ }
7930
+ if (version) {
7931
+ for (const d of dirsToSearch) {
7932
+ if (d.includes(version)) {
7933
+ const found = findExecutable(d);
7934
+ if (found) return found;
7935
+ }
7936
+ }
7937
+ }
7938
+ for (const d of dirsToSearch) {
7939
+ if (!version || !d.includes(version)) {
7940
+ const found = findExecutable(d);
7941
+ if (found) return found;
7942
+ }
7943
+ }
7944
+ } catch (e) {
7945
+ }
7946
+ return null;
7947
+ };
7948
+ const foundPath = findExecutable(cacheDir);
7949
+ if (foundPath) {
7950
+ return {
7951
+ executablePath: foundPath,
7952
+ cacheDirectory: cacheDir
7953
+ };
7954
+ }
7955
+ }
7956
+ } catch (error) {
7957
+ }
7958
+ return {};
7959
+ }
7960
+ var require2, __dirname;
7961
+ var init_puppeteer_helper = __esm({
7962
+ "src/utils/puppeteer_helper.js"() {
7963
+ require2 = createRequire(import.meta.url);
7964
+ __dirname = path8.dirname(fileURLToPath(import.meta.url));
7965
+ }
7966
+ });
7967
+
7853
7968
  // src/tools/web_search.js
7854
7969
  import puppeteer from "puppeteer";
7855
7970
  var web_search;
@@ -7857,6 +7972,7 @@ var init_web_search = __esm({
7857
7972
  "src/tools/web_search.js"() {
7858
7973
  init_arg_parser();
7859
7974
  init_paths();
7975
+ init_puppeteer_helper();
7860
7976
  web_search = async (argsString) => {
7861
7977
  const { query, limit = 10 } = parseArgs(argsString);
7862
7978
  if (!query) return 'ERROR: Missing "query" argument for web_search.';
@@ -7865,8 +7981,10 @@ var init_web_search = __esm({
7865
7981
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
7866
7982
  let browser = null;
7867
7983
  try {
7984
+ const pptrConfig = getPuppeteerConfig();
7868
7985
  browser = await puppeteer.launch({
7869
7986
  headless: true,
7987
+ executablePath: pptrConfig.executablePath || void 0,
7870
7988
  args: [
7871
7989
  "--no-sandbox",
7872
7990
  "--disable-setuid-sandbox",
@@ -7929,6 +8047,7 @@ var web_scrape;
7929
8047
  var init_web_scrape = __esm({
7930
8048
  "src/tools/web_scrape.js"() {
7931
8049
  init_paths();
8050
+ init_puppeteer_helper();
7932
8051
  web_scrape = async (args) => {
7933
8052
  const urlMatch = args.match(/url\s*=\s*["'](.*)["']/);
7934
8053
  const url = urlMatch ? urlMatch[1] : args;
@@ -7937,8 +8056,10 @@ var init_web_scrape = __esm({
7937
8056
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
7938
8057
  let browser = null;
7939
8058
  try {
8059
+ const pptrConfig = getPuppeteerConfig();
7940
8060
  browser = await puppeteer2.launch({
7941
8061
  headless: true,
8062
+ executablePath: pptrConfig.executablePath || void 0,
7942
8063
  args: [
7943
8064
  "--no-sandbox",
7944
8065
  "--disable-setuid-sandbox",
@@ -8121,8 +8242,8 @@ var init_chat = __esm({
8121
8242
  });
8122
8243
 
8123
8244
  // src/tools/view_file.js
8124
- import fs9 from "fs";
8125
- import path8 from "path";
8245
+ import fs10 from "fs";
8246
+ import path9 from "path";
8126
8247
  var view_file;
8127
8248
  var init_view_file = __esm({
8128
8249
  "src/tools/view_file.js"() {
@@ -8134,16 +8255,16 @@ var init_view_file = __esm({
8134
8255
  const finalStart = sLine || 1;
8135
8256
  const finalEnd = eLine || (sLine ? sLine + 800 : 800);
8136
8257
  if (!targetPath) return 'ERROR: Missing "path" argument for view_file.';
8137
- const absolutePath = path8.resolve(process.cwd(), targetPath);
8258
+ const absolutePath = path9.resolve(process.cwd(), targetPath);
8138
8259
  try {
8139
- if (!fs9.existsSync(absolutePath)) {
8260
+ if (!fs10.existsSync(absolutePath)) {
8140
8261
  return `ERROR: File [${targetPath}] does not exist.`;
8141
8262
  }
8142
- const stats = fs9.statSync(absolutePath);
8263
+ const stats = fs10.statSync(absolutePath);
8143
8264
  if (stats.isDirectory()) {
8144
8265
  return `ERROR: Path [${targetPath}] is a directory. Use list_files instead.`;
8145
8266
  }
8146
- const ext = path8.extname(targetPath).toLowerCase();
8267
+ const ext = path9.extname(targetPath).toLowerCase();
8147
8268
  const videoExtensions = [".mp4", ".mkv", ".avi", ".mov", ".webm", ".flv", ".wmv", ".mpeg", ".mpg"];
8148
8269
  if (videoExtensions.includes(ext)) {
8149
8270
  const format = ext.slice(1).toUpperCase();
@@ -8163,7 +8284,7 @@ var init_view_file = __esm({
8163
8284
  if (!isMultiModal) {
8164
8285
  return `ERROR: Multimodality is not supported for the current model. Unable to load [${targetPath}].`;
8165
8286
  }
8166
- const buffer = fs9.readFileSync(absolutePath);
8287
+ const buffer = fs10.readFileSync(absolutePath);
8167
8288
  const base64 = buffer.toString("base64");
8168
8289
  const mimeType = mimeMap[ext];
8169
8290
  return {
@@ -8176,7 +8297,7 @@ var init_view_file = __esm({
8176
8297
  }
8177
8298
  };
8178
8299
  }
8179
- let content = fs9.readFileSync(absolutePath, "utf8");
8300
+ let content = fs10.readFileSync(absolutePath, "utf8");
8180
8301
  if (content.startsWith("\uFEFF")) {
8181
8302
  content = content.slice(1);
8182
8303
  }
@@ -8200,8 +8321,8 @@ ${code}`;
8200
8321
  });
8201
8322
 
8202
8323
  // src/tools/write_file.js
8203
- import fs10 from "fs";
8204
- import path9 from "path";
8324
+ import fs11 from "fs";
8325
+ import path10 from "path";
8205
8326
  var write_file;
8206
8327
  var init_write_file = __esm({
8207
8328
  "src/tools/write_file.js"() {
@@ -8212,14 +8333,14 @@ var init_write_file = __esm({
8212
8333
  if (!targetPath) return 'ERROR: Missing "path" argument for write_file.';
8213
8334
  if (content === void 0) return 'ERROR: Missing "content" argument for write_file.';
8214
8335
  content = content.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
8215
- const absolutePath = path9.resolve(process.cwd(), targetPath);
8216
- const parentDir = path9.dirname(absolutePath);
8336
+ const absolutePath = path10.resolve(process.cwd(), targetPath);
8337
+ const parentDir = path10.dirname(absolutePath);
8217
8338
  try {
8218
8339
  await RevertManager.recordFileChange(absolutePath);
8219
8340
  let ancestry = "";
8220
- if (fs10.existsSync(absolutePath)) {
8341
+ if (fs11.existsSync(absolutePath)) {
8221
8342
  try {
8222
- const oldData = fs10.readFileSync(absolutePath, "utf8");
8343
+ const oldData = fs11.readFileSync(absolutePath, "utf8");
8223
8344
  const lines = oldData.split(/\r?\n/);
8224
8345
  ancestry = `Old File contents:
8225
8346
  ${lines.map((l, i) => `${i + 1} | ${l}`).join("\n")}
@@ -8231,16 +8352,16 @@ ${lines.map((l, i) => `${i + 1} | ${l}`).join("\n")}
8231
8352
  `;
8232
8353
  }
8233
8354
  }
8234
- if (!fs10.existsSync(parentDir)) {
8235
- fs10.mkdirSync(parentDir, { recursive: true });
8355
+ if (!fs11.existsSync(parentDir)) {
8356
+ fs11.mkdirSync(parentDir, { recursive: true });
8236
8357
  }
8237
8358
  const strip = (t) => t.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
8238
8359
  const processedContent = strip(content);
8239
8360
  const finalContent = processedContent.endsWith("\n") ? processedContent : processedContent + "\n";
8240
8361
  const lineCount = finalContent.split(/\r?\n/).length;
8241
8362
  const originalSize = Buffer.byteLength(finalContent, "utf8");
8242
- fs10.writeFileSync(absolutePath, finalContent, "utf8");
8243
- let verifiedContent = fs10.readFileSync(absolutePath, "utf8");
8363
+ fs11.writeFileSync(absolutePath, finalContent, "utf8");
8364
+ let verifiedContent = fs11.readFileSync(absolutePath, "utf8");
8244
8365
  const verifiedSize = Buffer.byteLength(verifiedContent, "utf8");
8245
8366
  const verifiedLines = verifiedContent.split(/\r?\n/);
8246
8367
  const verifiedLineCount = verifiedLines.length;
@@ -8275,8 +8396,8 @@ ${snippet}`;
8275
8396
  });
8276
8397
 
8277
8398
  // src/tools/update_file.js
8278
- import fs11 from "fs";
8279
- import path10 from "path";
8399
+ import fs12 from "fs";
8400
+ import path11 from "path";
8280
8401
  var update_file;
8281
8402
  var init_update_file = __esm({
8282
8403
  "src/tools/update_file.js"() {
@@ -8292,12 +8413,12 @@ var init_update_file = __esm({
8292
8413
  if (patchPairs.length === 0) {
8293
8414
  return "ERROR: No valid replacement pairs found. Use replaceContent1, newContent1, etc.";
8294
8415
  }
8295
- const absolutePath = path10.resolve(process.cwd(), targetPath);
8416
+ const absolutePath = path11.resolve(process.cwd(), targetPath);
8296
8417
  try {
8297
- if (!fs11.existsSync(absolutePath)) {
8418
+ if (!fs12.existsSync(absolutePath)) {
8298
8419
  return `ERROR: File [${targetPath}] does not exist. Use write_file instead.`;
8299
8420
  }
8300
- let diskContent = context.forcedContent || fs11.readFileSync(absolutePath, "utf8");
8421
+ let diskContent = context.forcedContent || fs12.readFileSync(absolutePath, "utf8");
8301
8422
  if (diskContent.startsWith("\uFEFF")) diskContent = diskContent.slice(1);
8302
8423
  const originalContent = diskContent.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
8303
8424
  const { content: finalContent, results } = applyPatches(originalContent, patchPairs);
@@ -8308,7 +8429,7 @@ var init_update_file = __esm({
8308
8429
  ${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
8309
8430
  }
8310
8431
  await RevertManager.recordFileChange(absolutePath, originalContent);
8311
- fs11.writeFileSync(absolutePath, finalContent, "utf8");
8432
+ fs12.writeFileSync(absolutePath, finalContent, "utf8");
8312
8433
  const diffText = generateHighFidelityDiff(originalContent, finalContent, results, 12);
8313
8434
  if (failures.length > 0) {
8314
8435
  return `SUCCESS: File [${targetPath}] updated with some blocks failed. [${successes.length}/${patchPairs.length}] blocks applied.
@@ -8330,34 +8451,34 @@ ${diffText}`;
8330
8451
  });
8331
8452
 
8332
8453
  // src/tools/read_folder.js
8333
- import fs12 from "fs";
8334
- import path11 from "path";
8454
+ import fs13 from "fs";
8455
+ import path12 from "path";
8335
8456
  var read_folder;
8336
8457
  var init_read_folder = __esm({
8337
8458
  "src/tools/read_folder.js"() {
8338
8459
  init_arg_parser();
8339
8460
  read_folder = async (args) => {
8340
8461
  const { path: targetPath = "." } = parseArgs(args);
8341
- const absolutePath = path11.resolve(process.cwd(), targetPath);
8462
+ const absolutePath = path12.resolve(process.cwd(), targetPath);
8342
8463
  try {
8343
- if (!fs12.existsSync(absolutePath)) {
8464
+ if (!fs13.existsSync(absolutePath)) {
8344
8465
  return `ERROR: Path [${targetPath}] does not exist.`;
8345
8466
  }
8346
- const stats = fs12.statSync(absolutePath);
8467
+ const stats = fs13.statSync(absolutePath);
8347
8468
  if (!stats.isDirectory()) {
8348
8469
  return `ERROR: Path [${targetPath}] is a file, not a directory. Use view_file instead.`;
8349
8470
  }
8350
- const files = fs12.readdirSync(absolutePath);
8471
+ const files = fs13.readdirSync(absolutePath);
8351
8472
  const totalItems = files.length;
8352
8473
  const maxDisplay = 100;
8353
8474
  const displayItems = files.slice(0, maxDisplay);
8354
8475
  const folderData = [];
8355
8476
  for (const file of displayItems) {
8356
- const fPath = path11.join(absolutePath, file);
8477
+ const fPath = path12.join(absolutePath, file);
8357
8478
  let indicator = "\u{1F4C4}";
8358
8479
  let info = { name: file, type: "unknown", size: "N/A", mtime: "N/A" };
8359
8480
  try {
8360
- const fStats = fs12.statSync(fPath);
8481
+ const fStats = fs13.statSync(fPath);
8361
8482
  info = {
8362
8483
  name: file,
8363
8484
  type: fStats.isDirectory() ? "directory" : "file",
@@ -8442,14 +8563,15 @@ var init_ask_user = __esm({
8442
8563
 
8443
8564
  // src/tools/write_pdf.js
8444
8565
  import puppeteer3 from "puppeteer";
8445
- import path12 from "path";
8446
- import fs13 from "fs-extra";
8566
+ import path13 from "path";
8567
+ import fs14 from "fs-extra";
8447
8568
  import { PDFDocument } from "pdf-lib";
8448
8569
  var write_pdf;
8449
8570
  var init_write_pdf = __esm({
8450
8571
  "src/tools/write_pdf.js"() {
8451
8572
  init_arg_parser();
8452
8573
  init_revert();
8574
+ init_puppeteer_helper();
8453
8575
  write_pdf = async (args) => {
8454
8576
  const {
8455
8577
  path: targetPath,
@@ -8459,13 +8581,15 @@ var init_write_pdf = __esm({
8459
8581
  } = parseArgs(args);
8460
8582
  if (!targetPath) return 'ERROR: Missing "path" argument for write_pdf.';
8461
8583
  if (!content) return 'ERROR: Missing "content" (HTML/CSS) for write_pdf.';
8462
- const absolutePath = path12.resolve(process.cwd(), targetPath);
8584
+ const absolutePath = path13.resolve(process.cwd(), targetPath);
8463
8585
  let browser = null;
8464
8586
  try {
8465
- await fs13.ensureDir(path12.dirname(absolutePath));
8587
+ await fs14.ensureDir(path13.dirname(absolutePath));
8466
8588
  await RevertManager.recordFileChange(absolutePath);
8589
+ const pptrConfig = getPuppeteerConfig();
8467
8590
  browser = await puppeteer3.launch({
8468
8591
  headless: true,
8592
+ executablePath: pptrConfig.executablePath || void 0,
8469
8593
  args: [
8470
8594
  "--no-sandbox",
8471
8595
  "--disable-setuid-sandbox",
@@ -8481,11 +8605,11 @@ var init_write_pdf = __esm({
8481
8605
  return null;
8482
8606
  }
8483
8607
  try {
8484
- const imgPath = path12.resolve(process.cwd(), originalSrc);
8485
- if (await fs13.pathExists(imgPath)) {
8486
- const ext = path12.extname(imgPath).toLowerCase().replace(".", "") || "png";
8608
+ const imgPath = path13.resolve(process.cwd(), originalSrc);
8609
+ if (await fs14.pathExists(imgPath)) {
8610
+ const ext = path13.extname(imgPath).toLowerCase().replace(".", "") || "png";
8487
8611
  const mime = ext === "jpg" ? "jpeg" : ext === "svg" ? "svg+xml" : ext;
8488
- const base64 = await fs13.readFile(imgPath, "base64");
8612
+ const base64 = await fs14.readFile(imgPath, "base64");
8489
8613
  return `data:image/${mime};base64,${base64}`;
8490
8614
  }
8491
8615
  } catch (e) {
@@ -8500,9 +8624,9 @@ var init_write_pdf = __esm({
8500
8624
  const fullTag = match[0];
8501
8625
  if (originalHref && fullTag.toLowerCase().includes("stylesheet") && !originalHref.startsWith("http://") && !originalHref.startsWith("https://") && !originalHref.startsWith("data:")) {
8502
8626
  try {
8503
- const cssPath = path12.resolve(process.cwd(), originalHref);
8504
- if (await fs13.pathExists(cssPath)) {
8505
- const cssContent = await fs13.readFile(cssPath, "utf-8");
8627
+ const cssPath = path13.resolve(process.cwd(), originalHref);
8628
+ if (await fs14.pathExists(cssPath)) {
8629
+ const cssContent = await fs14.readFile(cssPath, "utf-8");
8506
8630
  cssCache[fullTag] = `<style>${cssContent}</style>`;
8507
8631
  }
8508
8632
  } catch (e) {
@@ -8583,7 +8707,7 @@ var init_write_pdf = __esm({
8583
8707
  printBackground: true
8584
8708
  });
8585
8709
  const pdfDoc = await PDFDocument.load(pdfBytes);
8586
- const fileName = path12.basename(targetPath);
8710
+ const fileName = path13.basename(targetPath);
8587
8711
  pdfDoc.setTitle(`FluxFlow_${fileName}`);
8588
8712
  pdfDoc.setAuthor("FluxFlow CLI");
8589
8713
  pdfDoc.setSubject("Generated with Agentic AI System");
@@ -8591,8 +8715,8 @@ var init_write_pdf = __esm({
8591
8715
  pdfDoc.setCreator("FluxFlow PDF Engine");
8592
8716
  pdfDoc.setProducer("FluxFlow (Generative AI)");
8593
8717
  const finalPdfBytes = await pdfDoc.save();
8594
- await fs13.writeFile(absolutePath, finalPdfBytes);
8595
- const stats = await fs13.stat(absolutePath);
8718
+ await fs14.writeFile(absolutePath, finalPdfBytes);
8719
+ const stats = await fs14.stat(absolutePath);
8596
8720
  return `SUCCESS: PDF generated successfully at [${targetPath}] (${(stats.size / 1024).toFixed(2)} KB).`;
8597
8721
  } catch (err) {
8598
8722
  const errorMsg = err instanceof Error ? err.message : String(err);
@@ -8605,8 +8729,8 @@ var init_write_pdf = __esm({
8605
8729
  });
8606
8730
 
8607
8731
  // src/tools/write_docx.js
8608
- import fs14 from "fs-extra";
8609
- import path13 from "path";
8732
+ import fs15 from "fs-extra";
8733
+ import path14 from "path";
8610
8734
  import HTMLtoDOCX from "html-to-docx";
8611
8735
  var write_docx;
8612
8736
  var init_write_docx = __esm({
@@ -8620,11 +8744,11 @@ var init_write_docx = __esm({
8620
8744
  } = parseArgs(args);
8621
8745
  if (!targetPath) return 'ERROR: Missing "path" argument for write_docx.';
8622
8746
  if (!content) return 'ERROR: Missing "content" (HTML) for write_docx.';
8623
- const absolutePath = path13.resolve(process.cwd(), targetPath);
8747
+ const absolutePath = path14.resolve(process.cwd(), targetPath);
8624
8748
  try {
8625
- await fs14.ensureDir(path13.dirname(absolutePath));
8749
+ await fs15.ensureDir(path14.dirname(absolutePath));
8626
8750
  await RevertManager.recordFileChange(absolutePath);
8627
- const fileName = path13.basename(targetPath);
8751
+ const fileName = path14.basename(targetPath);
8628
8752
  const fullHtml = content.includes("<html") ? content : `
8629
8753
  <!DOCTYPE html>
8630
8754
  <html lang="en">
@@ -8645,7 +8769,7 @@ var init_write_docx = __esm({
8645
8769
  footer: true,
8646
8770
  pageNumber: true
8647
8771
  });
8648
- await fs14.writeFile(absolutePath, docxBuffer);
8772
+ await fs15.writeFile(absolutePath, docxBuffer);
8649
8773
  return `SUCCESS: Word document [${targetPath}] generated successfully.
8650
8774
  - Size: ${(docxBuffer.length / 1024).toFixed(1)} KB`;
8651
8775
  } catch (err) {
@@ -8657,21 +8781,21 @@ var init_write_docx = __esm({
8657
8781
  });
8658
8782
 
8659
8783
  // src/tools/search_keyword.js
8660
- import fs15 from "fs/promises";
8661
- import path14 from "path";
8784
+ import fs16 from "fs/promises";
8785
+ import path15 from "path";
8662
8786
  async function getFilesRecursively(dir, excludes, baseDir = dir, depth = 1) {
8663
8787
  if (depth > 12) return [];
8664
8788
  let results = [];
8665
8789
  let list;
8666
8790
  try {
8667
- list = await fs15.readdir(dir, { withFileTypes: true });
8791
+ list = await fs16.readdir(dir, { withFileTypes: true });
8668
8792
  } catch {
8669
8793
  return [];
8670
8794
  }
8671
8795
  for (const file of list) {
8672
- const fullPath = path14.join(dir, file.name);
8673
- const relativePath = path14.relative(baseDir, fullPath);
8674
- const pathSegments = relativePath.split(path14.sep).map((s) => s.toLowerCase());
8796
+ const fullPath = path15.join(dir, file.name);
8797
+ const relativePath = path15.relative(baseDir, fullPath);
8798
+ const pathSegments = relativePath.split(path15.sep).map((s) => s.toLowerCase());
8675
8799
  const isExcluded = excludes.some((ex) => pathSegments.includes(ex.toLowerCase()));
8676
8800
  if (isExcluded) continue;
8677
8801
  if (file.isDirectory()) {
@@ -8743,11 +8867,11 @@ var init_search_keyword = __esm({
8743
8867
  let filesToSearch = [];
8744
8868
  const rootDir = process.cwd();
8745
8869
  if (file) {
8746
- const fullPath = path14.resolve(rootDir, file);
8870
+ const fullPath = path15.resolve(rootDir, file);
8747
8871
  try {
8748
- const stat = await fs15.stat(fullPath);
8872
+ const stat = await fs16.stat(fullPath);
8749
8873
  if (stat.isFile()) {
8750
- filesToSearch.push({ fullPath, relativePath: path14.relative(rootDir, fullPath) });
8874
+ filesToSearch.push({ fullPath, relativePath: path15.relative(rootDir, fullPath) });
8751
8875
  }
8752
8876
  } catch {
8753
8877
  return `ERROR: File not found: ${file}`;
@@ -8757,7 +8881,7 @@ var init_search_keyword = __esm({
8757
8881
  }
8758
8882
  const searchPromises = filesToSearch.map(async (fileObj) => {
8759
8883
  try {
8760
- const content = await fs15.readFile(fileObj.fullPath, "utf-8");
8884
+ const content = await fs16.readFile(fileObj.fullPath, "utf-8");
8761
8885
  if (content.includes("\0")) return [];
8762
8886
  const lines = content.split(/\r?\n/);
8763
8887
  const fileMatches = [];
@@ -8814,8 +8938,8 @@ var init_search_keyword = __esm({
8814
8938
  });
8815
8939
 
8816
8940
  // src/tools/generate_image.js
8817
- import fs16 from "fs-extra";
8818
- import path15 from "path";
8941
+ import fs17 from "fs-extra";
8942
+ import path16 from "path";
8819
8943
  var injectPngMetadata, generate_image;
8820
8944
  var init_generate_image = __esm({
8821
8945
  "src/tools/generate_image.js"() {
@@ -8994,12 +9118,12 @@ var init_generate_image = __esm({
8994
9118
  "Seed": String(seed)
8995
9119
  };
8996
9120
  finalBuffer = injectPngMetadata(finalBuffer, metadata);
8997
- const absolutePath = path15.resolve(process.cwd(), outputPath);
8998
- await fs16.ensureDir(path15.dirname(absolutePath));
9121
+ const absolutePath = path16.resolve(process.cwd(), outputPath);
9122
+ await fs17.ensureDir(path16.dirname(absolutePath));
8999
9123
  await RevertManager.recordFileChange(absolutePath);
9000
- await fs16.writeFile(absolutePath, finalBuffer);
9124
+ await fs17.writeFile(absolutePath, finalBuffer);
9001
9125
  await recordImageGeneration(settings);
9002
- const ext = path15.extname(outputPath).toLowerCase();
9126
+ const ext = path16.extname(outputPath).toLowerCase();
9003
9127
  const mimeMap = {
9004
9128
  ".jpg": "image/jpeg",
9005
9129
  ".jpeg": "image/jpeg",
@@ -9114,13 +9238,13 @@ var init_addMemScore = __esm({
9114
9238
  });
9115
9239
 
9116
9240
  // src/utils/parsers.js
9117
- import fs17 from "fs-extra";
9118
- import path16 from "path";
9241
+ import fs18 from "fs-extra";
9242
+ import path17 from "path";
9119
9243
  import https from "https";
9120
9244
  async function downloadWasm(wasmFile, targetUrl = null) {
9121
9245
  const url = targetUrl || `https://unpkg.com/tree-sitter-wasms@0.1.13/out/${wasmFile}`;
9122
- const localPath = path16.join(PARSER_DIR, wasmFile);
9123
- await fs17.ensureDir(PARSER_DIR);
9246
+ const localPath = path17.join(PARSER_DIR, wasmFile);
9247
+ await fs18.ensureDir(PARSER_DIR);
9124
9248
  return new Promise((resolve, reject) => {
9125
9249
  const options = {
9126
9250
  headers: {
@@ -9141,27 +9265,27 @@ async function downloadWasm(wasmFile, targetUrl = null) {
9141
9265
  reject(new Error(`Failed to download ${wasmFile}: HTTP ${response.statusCode}`));
9142
9266
  return;
9143
9267
  }
9144
- const file = fs17.createWriteStream(localPath);
9268
+ const file = fs18.createWriteStream(localPath);
9145
9269
  response.pipe(file);
9146
9270
  file.on("finish", () => {
9147
9271
  file.close();
9148
9272
  resolve();
9149
9273
  });
9150
9274
  }).on("error", (err) => {
9151
- if (fs17.existsSync(localPath)) fs17.unlink(localPath, () => {
9275
+ if (fs18.existsSync(localPath)) fs18.unlink(localPath, () => {
9152
9276
  });
9153
9277
  reject(err);
9154
9278
  });
9155
9279
  });
9156
9280
  }
9157
9281
  function isParserInstalled(wasmFile) {
9158
- const localPath = path16.join(PARSER_DIR, wasmFile);
9159
- return fs17.existsSync(localPath);
9282
+ const localPath = path17.join(PARSER_DIR, wasmFile);
9283
+ return fs18.existsSync(localPath);
9160
9284
  }
9161
9285
  async function deleteParser(wasmFile) {
9162
- const localPath = path16.join(PARSER_DIR, wasmFile);
9163
- if (fs17.existsSync(localPath)) {
9164
- await fs17.unlink(localPath);
9286
+ const localPath = path17.join(PARSER_DIR, wasmFile);
9287
+ if (fs18.existsSync(localPath)) {
9288
+ await fs18.unlink(localPath);
9165
9289
  }
9166
9290
  }
9167
9291
  var EXTENSION_TO_WASM;
@@ -9183,9 +9307,9 @@ var init_parsers = __esm({
9183
9307
  });
9184
9308
 
9185
9309
  // src/tools/file_map.js
9186
- import fs18 from "fs-extra";
9187
- import path17 from "path";
9188
- import { createRequire } from "module";
9310
+ import fs19 from "fs-extra";
9311
+ import path18 from "path";
9312
+ import { createRequire as createRequire2 } from "module";
9189
9313
  function sanitize(text, limit = 50) {
9190
9314
  if (!text) return "";
9191
9315
  const clean = text.replace(/\s+/g, " ").trim();
@@ -9309,14 +9433,14 @@ function traverse(node, depth = 0, isLast = true, prefix = "", parentName = null
9309
9433
  }
9310
9434
  return result;
9311
9435
  }
9312
- var require2, TreeSitter, isParserInitialized, INTERESTING_TYPES, PASSTHROUGH_TYPES, file_map;
9436
+ var require3, TreeSitter, isParserInitialized, INTERESTING_TYPES, PASSTHROUGH_TYPES, file_map;
9313
9437
  var init_file_map = __esm({
9314
9438
  "src/tools/file_map.js"() {
9315
9439
  init_parsers();
9316
9440
  init_paths();
9317
9441
  init_arg_parser();
9318
- require2 = createRequire(import.meta.url);
9319
- TreeSitter = require2("web-tree-sitter");
9442
+ require3 = createRequire2(import.meta.url);
9443
+ TreeSitter = require3("web-tree-sitter");
9320
9444
  isParserInitialized = false;
9321
9445
  INTERESTING_TYPES = /* @__PURE__ */ new Set([
9322
9446
  "class_declaration",
@@ -9376,17 +9500,17 @@ var init_file_map = __esm({
9376
9500
  if (!filePath) {
9377
9501
  return 'ERROR: No file path provided. Use [tool:functions.FileMap(path="...")]';
9378
9502
  }
9379
- const absolutePath = path17.isAbsolute(filePath) ? filePath : path17.resolve(process.cwd(), filePath);
9380
- if (!fs18.existsSync(absolutePath)) {
9503
+ const absolutePath = path18.isAbsolute(filePath) ? filePath : path18.resolve(process.cwd(), filePath);
9504
+ if (!fs19.existsSync(absolutePath)) {
9381
9505
  return `ERROR: File not found: ${filePath}`;
9382
9506
  }
9383
- const ext = path17.extname(absolutePath).slice(1).toLowerCase();
9507
+ const ext = path18.extname(absolutePath).slice(1).toLowerCase();
9384
9508
  const wasmFile = EXTENSION_TO_WASM[ext];
9385
9509
  if (!wasmFile) {
9386
9510
  return `ERROR: Unsupported file extension: .${ext}`;
9387
9511
  }
9388
- const wasmPath = path17.resolve(PARSER_DIR, wasmFile);
9389
- if (!fs18.existsSync(wasmPath)) {
9512
+ const wasmPath = path18.resolve(PARSER_DIR, wasmFile);
9513
+ if (!fs19.existsSync(wasmPath)) {
9390
9514
  return `ERROR: Parser for .${ext} not found. Please download it in Settings > Other.`;
9391
9515
  }
9392
9516
  try {
@@ -9394,9 +9518,9 @@ var init_file_map = __esm({
9394
9518
  if (!isParserInitialized) {
9395
9519
  let tsWasmPath;
9396
9520
  try {
9397
- tsWasmPath = path17.join(path17.dirname(require2.resolve("web-tree-sitter")), "tree-sitter.wasm");
9521
+ tsWasmPath = path18.join(path18.dirname(require3.resolve("web-tree-sitter")), "tree-sitter.wasm");
9398
9522
  } catch (e) {
9399
- tsWasmPath = path17.join(process.cwd(), "node_modules", "web-tree-sitter", "tree-sitter.wasm");
9523
+ tsWasmPath = path18.join(process.cwd(), "node_modules", "web-tree-sitter", "tree-sitter.wasm");
9400
9524
  }
9401
9525
  await Parser.init({
9402
9526
  locateFile: (p) => {
@@ -9411,7 +9535,7 @@ var init_file_map = __esm({
9411
9535
  const parser = new Parser();
9412
9536
  const Lang = await TreeSitter.Language.load(wasmPath);
9413
9537
  parser.setLanguage(Lang);
9414
- const sourceCode = await fs18.readFile(absolutePath, "utf8");
9538
+ const sourceCode = await fs19.readFile(absolutePath, "utf8");
9415
9539
  const lines = sourceCode.split("\n").length;
9416
9540
  let maxDepth = 12;
9417
9541
  if (lines > 1e4) maxDepth = 2;
@@ -9434,8 +9558,8 @@ Stack: ${err.stack}` : "";
9434
9558
  });
9435
9559
 
9436
9560
  // src/tools/todo.js
9437
- import fs19 from "fs";
9438
- import path18 from "path";
9561
+ import fs20 from "fs";
9562
+ import path19 from "path";
9439
9563
  var todo;
9440
9564
  var init_todo = __esm({
9441
9565
  "src/tools/todo.js"() {
@@ -9446,8 +9570,8 @@ var init_todo = __esm({
9446
9570
  const { method, tasks, markDone } = parseArgs(args);
9447
9571
  const chatId = context.chatId || "default";
9448
9572
  if (!method) return 'ERROR: Missing "method" argument for todo tool (create/append/get).';
9449
- const todoDir = path18.join(DATA_DIR, "plan", chatId);
9450
- const todoFile = path18.join(todoDir, "todo.md");
9573
+ const todoDir = path19.join(DATA_DIR, "plan", chatId);
9574
+ const todoFile = path19.join(todoDir, "todo.md");
9451
9575
  const parseMessyArray = (input) => {
9452
9576
  if (!input || Array.isArray(input)) return input;
9453
9577
  const trimmed = String(input).trim();
@@ -9507,8 +9631,8 @@ var init_todo = __esm({
9507
9631
  };
9508
9632
  };
9509
9633
  try {
9510
- if (!fs19.existsSync(todoDir)) {
9511
- fs19.mkdirSync(todoDir, { recursive: true });
9634
+ if (!fs20.existsSync(todoDir)) {
9635
+ fs20.mkdirSync(todoDir, { recursive: true });
9512
9636
  }
9513
9637
  if (method === "create") {
9514
9638
  if (!tasks) return 'ERROR: Missing "tasks" for create method.';
@@ -9520,7 +9644,7 @@ var init_todo = __esm({
9520
9644
  markedCount = result.markedCount;
9521
9645
  }
9522
9646
  await RevertManager.recordFileChange(todoFile);
9523
- fs19.writeFileSync(todoFile, content, "utf8");
9647
+ fs20.writeFileSync(todoFile, content, "utf8");
9524
9648
  const total = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("- [ ]") || l.startsWith("- [x]") || l.startsWith("- [X]")).length;
9525
9649
  if (markedCount > 0) {
9526
9650
  const completed = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("- [x]") || l.startsWith("- [X]")).length;
@@ -9534,8 +9658,8 @@ ${content}`;
9534
9658
  if (!tasks) return 'ERROR: Missing "tasks" for append method.';
9535
9659
  const appendContent = getTasksString(tasks);
9536
9660
  await RevertManager.recordFileChange(todoFile);
9537
- fs19.appendFileSync(todoFile, appendContent, "utf8");
9538
- const fullContent = fs19.readFileSync(todoFile, "utf8");
9661
+ fs20.appendFileSync(todoFile, appendContent, "utf8");
9662
+ const fullContent = fs20.readFileSync(todoFile, "utf8");
9539
9663
  const lines = fullContent.split(/\r?\n/).map((l) => l.trim());
9540
9664
  const total = lines.filter((l) => l.startsWith("- [ ]") || l.startsWith("- [x]") || l.startsWith("- [X]")).length;
9541
9665
  const completed = lines.filter((l) => l.startsWith("- [x]") || l.startsWith("- [X]")).length;
@@ -9544,10 +9668,10 @@ ${content}`;
9544
9668
  ${fullContent}`;
9545
9669
  }
9546
9670
  if (method === "get") {
9547
- if (!fs19.existsSync(todoFile)) {
9671
+ if (!fs20.existsSync(todoFile)) {
9548
9672
  return "TODO GET: No task list found for this session.";
9549
9673
  }
9550
- let content = fs19.readFileSync(todoFile, "utf8");
9674
+ let content = fs20.readFileSync(todoFile, "utf8");
9551
9675
  let markedCount = 0;
9552
9676
  if (markDone) {
9553
9677
  const result = applyMarkDone(content, markDone);
@@ -9555,7 +9679,7 @@ ${fullContent}`;
9555
9679
  content = result.content;
9556
9680
  markedCount = result.markedCount;
9557
9681
  await RevertManager.recordFileChange(todoFile);
9558
- fs19.writeFileSync(todoFile, content, "utf8");
9682
+ fs20.writeFileSync(todoFile, content, "utf8");
9559
9683
  }
9560
9684
  }
9561
9685
  const totalLines = content.split(/\r?\n/).map((l) => l.trim());
@@ -10153,8 +10277,8 @@ __export(ai_exports, {
10153
10277
  signalTermination: () => signalTermination
10154
10278
  });
10155
10279
  import { GoogleGenAI, ThinkingLevel, HarmBlockThreshold, HarmCategory } from "@google/genai";
10156
- import path19 from "path";
10157
- import fs20 from "fs";
10280
+ import path20 from "path";
10281
+ import fs21 from "fs";
10158
10282
  var client, globalSettings, colorMainWords, withRetry, TERMINATION_SIGNAL, MULTIMODAL_MODELS, isModelMultimodal, getCleanGroupedLength, stripAnsi2, fetchWithBackoff, getDeepSeekStream, getNVIDIAStream, getOpenRouterStream, signalTermination, TOOL_LABELS2, getToolDetail, runJanitorTask, getActiveToolContext, getContextSafeText, contextSafeReplace, getSanitizedText, translateKimiToolCalls, detectToolCalls, initAI, generateSimpleContent, consolidatePastMemories, compressHistory, deleteChatSummary, getAIStream, runSubagent;
10159
10283
  var init_ai = __esm({
10160
10284
  async "src/utils/ai.js"() {
@@ -10779,7 +10903,7 @@ var init_ai = __esm({
10779
10903
  return pArgs.id || pArgs.taskId;
10780
10904
  }
10781
10905
  const filePath = pArgs.path || pArgs.targetFile || pArgs.TargetFile || pArgs.directory;
10782
- return filePath ? path19.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/")) : null;
10906
+ return filePath ? path20.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/")) : null;
10783
10907
  } catch (e) {
10784
10908
  return null;
10785
10909
  }
@@ -11020,9 +11144,9 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11020
11144
  }
11021
11145
  })() : String(err);
11022
11146
  await new Promise((resolve) => setTimeout(resolve, 1e3));
11023
- const janitorErrDir = path19.join(LOGS_DIR, "janitor");
11024
- if (!fs20.existsSync(janitorErrDir)) fs20.mkdirSync(janitorErrDir, { recursive: true });
11025
- fs20.appendFileSync(path19.join(janitorErrDir, "error.log"), `ERROR [Attempt ${attempts}/${MAX_JANITOR_RETRIES + 1}] [${date}]: ${errLog}
11147
+ const janitorErrDir = path20.join(LOGS_DIR, "janitor");
11148
+ if (!fs21.existsSync(janitorErrDir)) fs21.mkdirSync(janitorErrDir, { recursive: true });
11149
+ fs21.appendFileSync(path20.join(janitorErrDir, "error.log"), `ERROR [Attempt ${attempts}/${MAX_JANITOR_RETRIES + 1}] [${date}]: ${errLog}
11026
11150
 
11027
11151
  `);
11028
11152
  if (attempts > MAX_JANITOR_RETRIES) break;
@@ -11031,8 +11155,8 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11031
11155
  }
11032
11156
  }
11033
11157
  if (attempts) {
11034
- const janitorErrDir = path19.join(LOGS_DIR, "janitor");
11035
- fs20.appendFileSync(path19.join(janitorErrDir, "error.log"), `-----------------------------------------------------------------------------
11158
+ const janitorErrDir = path20.join(LOGS_DIR, "janitor");
11159
+ fs21.appendFileSync(path20.join(janitorErrDir, "error.log"), `-----------------------------------------------------------------------------
11036
11160
 
11037
11161
  `);
11038
11162
  if (attempts >= MAX_JANITOR_RETRIES) {
@@ -11512,10 +11636,10 @@ ${newMemoryListStr}
11512
11636
  }
11513
11637
  })() : String(err);
11514
11638
  ;
11515
- const janitorLogDir = path19.join(LOGS_DIR, "janitor");
11516
- if (!fs20.existsSync(janitorLogDir)) fs20.mkdirSync(janitorLogDir, { recursive: true });
11517
- fs20.appendFileSync(
11518
- path19.join(janitorLogDir, "error.log"),
11639
+ const janitorLogDir = path20.join(LOGS_DIR, "janitor");
11640
+ if (!fs21.existsSync(janitorLogDir)) fs21.mkdirSync(janitorLogDir, { recursive: true });
11641
+ fs21.appendFileSync(
11642
+ path20.join(janitorLogDir, "error.log"),
11519
11643
  `[${(/* @__PURE__ */ new Date()).toLocaleString()}] Past memory batch consolidation error: ${errLog}
11520
11644
  `
11521
11645
  );
@@ -11523,7 +11647,7 @@ ${newMemoryListStr}
11523
11647
  };
11524
11648
  compressHistory = async (settings, history, isAuto = false) => {
11525
11649
  const { chatId, aiProvider = "Google" } = settings;
11526
- const summariesFile = path19.join(SECRET_DIR, "chat-summaries.json");
11650
+ const summariesFile = path20.join(SECRET_DIR, "chat-summaries.json");
11527
11651
  const flattenContext = (hist) => {
11528
11652
  return hist.filter(
11529
11653
  (m) => (m.role === "user" || m.role === "agent" || m.role === "system") && m.role !== "think" && !m.isVisualFeedback && !m.isMeta && !String(m.id).startsWith("welcome")
@@ -11597,8 +11721,8 @@ Provide a consolidated summary of the entire session.`;
11597
11721
  };
11598
11722
  deleteChatSummary = (chatId) => {
11599
11723
  try {
11600
- const summariesFile = path19.join(SECRET_DIR, "chat-summaries.json");
11601
- if (fs20.existsSync(summariesFile)) {
11724
+ const summariesFile = path20.join(SECRET_DIR, "chat-summaries.json");
11725
+ if (fs21.existsSync(summariesFile)) {
11602
11726
  const summaries = readEncryptedJson(summariesFile, {});
11603
11727
  if (summaries[chatId]) {
11604
11728
  delete summaries[chatId];
@@ -11614,7 +11738,7 @@ Provide a consolidated summary of the entire session.`;
11614
11738
  if (!client && aiProvider === "Google") throw new Error("AI not initialized");
11615
11739
  const isMemoryEnabled = systemSettings?.memory !== false;
11616
11740
  const originalText = history[history.length - 1].text;
11617
- const summariesFile = path19.join(SECRET_DIR, "chat-summaries.json");
11741
+ const summariesFile = path20.join(SECRET_DIR, "chat-summaries.json");
11618
11742
  let wasCompressedInStream = false;
11619
11743
  const isFirstPrompt = history.filter((m) => m.role === "user").length === 1;
11620
11744
  const hasTitleSignal = originalText.includes("[TITLE-UPDATE]");
@@ -11850,7 +11974,7 @@ Provide a consolidated summary of the entire session.`;
11850
11974
  ];
11851
11975
  const safeReaddirWithTypes = (dir) => {
11852
11976
  try {
11853
- return fs20.readdirSync(dir, { withFileTypes: true });
11977
+ return fs21.readdirSync(dir, { withFileTypes: true });
11854
11978
  } catch (e) {
11855
11979
  return [];
11856
11980
  }
@@ -11863,16 +11987,16 @@ Provide a consolidated summary of the entire session.`;
11863
11987
  if (COLLAPSED_DIRS_GLOBAL.includes(entry.name)) continue;
11864
11988
  if (entry.isDirectory()) {
11865
11989
  currentCount.value++;
11866
- countFolders(path19.join(dir, entry.name), currentCount, depth + 1);
11990
+ countFolders(path20.join(dir, entry.name), currentCount, depth + 1);
11867
11991
  }
11868
11992
  }
11869
11993
  return currentCount.value;
11870
11994
  };
11871
11995
  const getDirTree = (dir, maxDepth, prefix = "", depth = 1) => {
11872
11996
  const entries = safeReaddirWithTypes(dir);
11873
- const sep = path19.sep;
11997
+ const sep = path20.sep;
11874
11998
  if (entries.length > 100) {
11875
- return `${prefix}\u2514\u2500\u2500 ${path19.basename(dir)}${sep} ...100+ files...
11999
+ return `${prefix}\u2514\u2500\u2500 ${path20.basename(dir)}${sep} ...100+ files...
11876
12000
  `;
11877
12001
  }
11878
12002
  let result = "";
@@ -11890,7 +12014,7 @@ Provide a consolidated summary of the entire session.`;
11890
12014
  ];
11891
12015
  finalItems.forEach((item, index) => {
11892
12016
  const isLast = index === finalItems.length - 1;
11893
- const filePath = path19.join(dir, item.name);
12017
+ const filePath = path20.join(dir, item.name);
11894
12018
  const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
11895
12019
  const childPrefix = prefix + (isLast ? " " : "\u2502 ");
11896
12020
  if (item.isCollapsed) {
@@ -11976,10 +12100,10 @@ ${currentSummary}
11976
12100
  if (isBridgeConnected()) {
11977
12101
  ideBlock = "[IDE CONTEXT]\n";
11978
12102
  if (ideCtx.file_focused !== "none") {
11979
- const relFocused = path19.relative(process.cwd(), ideCtx.file_focused);
12103
+ const relFocused = path20.relative(process.cwd(), ideCtx.file_focused);
11980
12104
  const relOpened = (ideCtx.opened_editors || []).map((p) => {
11981
- const rel = path19.relative(process.cwd(), p);
11982
- return rel.startsWith("..") ? `[External] ${path19.basename(p)}` : rel;
12105
+ const rel = path20.relative(process.cwd(), p);
12106
+ return rel.startsWith("..") ? `[External] ${path20.basename(p)}` : rel;
11983
12107
  });
11984
12108
  ideBlock += `Focused File: ${relFocused}
11985
12109
  Cursor Line: ${ideCtx.cursor_line}
@@ -12021,7 +12145,7 @@ Cursor Line: ${ideCtx.cursor_line}
12021
12145
  }
12022
12146
  const getSumForLimit = (limit, activeFiles2) => {
12023
12147
  return activeFiles2.reduce((sum, f) => {
12024
- const isFocused = ideCtx.file_focused && (f.path === ideCtx.file_focused || path19.resolve(process.cwd(), f.path) === path19.resolve(ideCtx.file_focused));
12148
+ const isFocused = ideCtx.file_focused && (f.path === ideCtx.file_focused || path20.resolve(process.cwd(), f.path) === path20.resolve(ideCtx.file_focused));
12025
12149
  const fileLimit = isFocused ? Math.ceil(limit * 1.2) : limit;
12026
12150
  return sum + Math.min(f.edits.length, fileLimit);
12027
12151
  }, 0);
@@ -12055,7 +12179,7 @@ Cursor Line: ${ideCtx.cursor_line}
12055
12179
  }
12056
12180
  }
12057
12181
  for (const file of activeFiles) {
12058
- const isFocused = ideCtx.file_focused && (file.path === ideCtx.file_focused || path19.resolve(process.cwd(), file.path) === path19.resolve(ideCtx.file_focused));
12182
+ const isFocused = ideCtx.file_focused && (file.path === ideCtx.file_focused || path20.resolve(process.cwd(), file.path) === path20.resolve(ideCtx.file_focused));
12059
12183
  const fileLimit = isFocused ? Math.ceil(chosenLimit * 1.2) : chosenLimit;
12060
12184
  if (file.edits.length > fileLimit) {
12061
12185
  file.edits = file.edits.slice(-fileLimit);
@@ -12139,9 +12263,9 @@ ${ideCtx.warnings}
12139
12263
  endLine = matchRange[2] ? parseInt(matchRange[2], 10) : startLine;
12140
12264
  filePath = tagClean.slice(0, matchRange.index);
12141
12265
  }
12142
- const absPath = path19.resolve(process.cwd(), filePath);
12143
- if (fs20.existsSync(absPath)) {
12144
- const stats = fs20.statSync(absPath);
12266
+ const absPath = path20.resolve(process.cwd(), filePath);
12267
+ if (fs21.existsSync(absPath)) {
12268
+ const stats = fs21.statSync(absPath);
12145
12269
  if (stats.isFile()) {
12146
12270
  const pathLower = filePath.toLowerCase();
12147
12271
  const isPdf = pathLower.endsWith(".pdf");
@@ -12150,7 +12274,7 @@ ${ideCtx.warnings}
12150
12274
  const isMultimodalFile = isImage || isPdf || isOfficeFile;
12151
12275
  const isSupported = aiProvider === "Google" || MULTIMODAL_MODELS.includes(modelName);
12152
12276
  if (isMultimodalFile && !isSupported) {
12153
- const label = `\u2718 Unsupported Modality: ${path19.basename(filePath)}`;
12277
+ const label = `\u2718 Unsupported Modality: ${path20.basename(filePath)}`;
12154
12278
  let terminalWidth = 115;
12155
12279
  if (process.stdout.isTTY) {
12156
12280
  terminalWidth = process.stdout.columns - 5 || 120;
@@ -12203,7 +12327,7 @@ ${boxMid}
12203
12327
  } else {
12204
12328
  let totalLines = "...";
12205
12329
  try {
12206
- const content = fs20.readFileSync(absPath, "utf8");
12330
+ const content = fs21.readFileSync(absPath, "utf8");
12207
12331
  totalLines = content.split("\n").length;
12208
12332
  } catch (e) {
12209
12333
  }
@@ -12847,7 +12971,7 @@ ${ideErr} [/ERROR]`;
12847
12971
  if (keyword) {
12848
12972
  detail = keyword.replace(/["']/g, "");
12849
12973
  } else if (filePath) {
12850
- detail = path19.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/"));
12974
+ detail = path20.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/"));
12851
12975
  } else if (title && (potentialTool === "invoke" || potentialTool === "invoke_sync")) {
12852
12976
  detail = title.replace(/["']/g, "").substring(0, 30);
12853
12977
  } else if (id && potentialTool === "get_progress") {
@@ -12876,7 +13000,7 @@ ${ideErr} [/ERROR]`;
12876
13000
  if (potentialTool === "invoke" || potentialTool === "invoke_sync" || potentialTool === "get_progress") {
12877
13001
  detail = val.substring(0, 30);
12878
13002
  } else {
12879
- detail = potentialTool === "search_keyword" || potentialTool === "file_map" ? val : path19.basename(val.replace(/\\/g, "/"));
13003
+ detail = potentialTool === "search_keyword" || potentialTool === "file_map" ? val : path20.basename(val.replace(/\\/g, "/"));
12880
13004
  }
12881
13005
  }
12882
13006
  }
@@ -13060,9 +13184,9 @@ ${ideErr} [/ERROR]`;
13060
13184
  let totalLines = "...";
13061
13185
  let actualEndLine = eLine;
13062
13186
  try {
13063
- const absPath = path19.resolve(process.cwd(), targetPath2);
13064
- if (fs20.existsSync(absPath)) {
13065
- const content = fs20.readFileSync(absPath, "utf8");
13187
+ const absPath = path20.resolve(process.cwd(), targetPath2);
13188
+ if (fs21.existsSync(absPath)) {
13189
+ const content = fs21.readFileSync(absPath, "utf8");
13066
13190
  const lines = content.split("\n").length;
13067
13191
  totalLines = lines;
13068
13192
  actualEndLine = Math.min(eLine, lines);
@@ -13082,8 +13206,8 @@ ${ideErr} [/ERROR]`;
13082
13206
  }
13083
13207
  } else if (normToolName === "list_files" || normToolName === "read_folder") {
13084
13208
  const action = normToolName === "list_files" ? "List" : "Browsed";
13085
- const path21 = parseArgs(toolCall.args).path;
13086
- label = `\u2714 ${action}: ${path21 === "." ? "./" : path21}`;
13209
+ const path22 = parseArgs(toolCall.args).path;
13210
+ label = `\u2714 ${action}: ${path22 === "." ? "./" : path22}`;
13087
13211
  } else if (normToolName === "write_file" || normToolName === "update_file") {
13088
13212
  const action = normToolName === "write_file" ? "Created" : "Edited";
13089
13213
  label = `\u2714 ${action}: ${parseArgs(toolCall.args).path || "..."}`;
@@ -13136,7 +13260,7 @@ ${ideErr} [/ERROR]`;
13136
13260
  const { command } = parseArgs(toolCall.args);
13137
13261
  if (command && settings.systemSettings && settings.systemSettings.allowExternalAccess === false) {
13138
13262
  const riskyPatterns = [/[a-zA-Z]:[\\\/]/i, /^\//, /\.\.[\\\/]/, /\/etc\//, /\/var\//, /\/root\//, /\/bin\//, /\/usr\//];
13139
- const currentDrive = path19.resolve(process.cwd()).substring(0, 3).toLowerCase();
13263
+ const currentDrive = path20.resolve(process.cwd()).substring(0, 3).toLowerCase();
13140
13264
  const splitCommands = (cmdString) => {
13141
13265
  const commands = [];
13142
13266
  let current = "";
@@ -13265,8 +13389,8 @@ ${ideErr} [/ERROR]`;
13265
13389
  const targetPath = parsedArgs.path || parsedArgs.targetPath || null;
13266
13390
  if (targetPath) {
13267
13391
  const isExternalOff = settings.systemSettings && settings.systemSettings.allowExternalAccess === false;
13268
- const absoluteTarget = path19.resolve(targetPath);
13269
- const absoluteCwd = path19.resolve(process.cwd());
13392
+ const absoluteTarget = path20.resolve(targetPath);
13393
+ const absoluteCwd = path20.resolve(process.cwd());
13270
13394
  if (isExternalOff && !absoluteTarget.startsWith(absoluteCwd)) {
13271
13395
  const denyMsg = `Access Denied. You are not allowed to access files outside the current workspace.`;
13272
13396
  if (normToolName === "write_file" || normToolName === "update_file") {
@@ -13455,7 +13579,7 @@ ${boxMid}`) };
13455
13579
  const toolArgs = parseArgs(toolCall.args);
13456
13580
  const { path: filePath } = toolArgs;
13457
13581
  if (filePath) {
13458
- const absPath = path19.resolve(process.cwd(), filePath);
13582
+ const absPath = path20.resolve(process.cwd(), filePath);
13459
13583
  const normalize = (p) => p ? p.toLowerCase().replace(/\\/g, "/").replace(/^[a-z]:/, (m) => m.toUpperCase()) : "";
13460
13584
  const normAbsPath = normalize(absPath);
13461
13585
  let originalContent = "";
@@ -13465,8 +13589,8 @@ ${boxMid}`) };
13465
13589
  if (currentIDE && normFocused === normAbsPath && currentIDE.full_content) {
13466
13590
  originalContent = currentIDE.full_content;
13467
13591
  hasOriginal = true;
13468
- } else if (fs20.existsSync(absPath)) {
13469
- originalContent = fs20.readFileSync(absPath, "utf8");
13592
+ } else if (fs21.existsSync(absPath)) {
13593
+ originalContent = fs21.readFileSync(absPath, "utf8");
13470
13594
  hasOriginal = true;
13471
13595
  }
13472
13596
  originalContentForReporting = originalContent;
@@ -13493,9 +13617,9 @@ ${boxMid}`) };
13493
13617
  const successes = patchResults.filter((r) => r.success);
13494
13618
  const failures = patchResults.filter((r) => !r.success);
13495
13619
  if (successes.length === 0) {
13496
- const errorMsg = `[TOOL RESULT]: ERROR: Failed to apply patches to [${path19.basename(absPath)}].
13620
+ const errorMsg = `[TOOL RESULT]: ERROR: Failed to apply patches to [${path20.basename(absPath)}].
13497
13621
  ${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
13498
- const errorLabel = `\u2714 Edited: ${path19.basename(absPath)}`.toUpperCase();
13622
+ const errorLabel = `\u2714 Edited: ${path20.basename(absPath)}`.toUpperCase();
13499
13623
  let terminalWidth = 115;
13500
13624
  if (process.stdout.isTTY) {
13501
13625
  terminalWidth = process.stdout.columns - 5 || 120;
@@ -13513,19 +13637,19 @@ ${boxMid}}`) };
13513
13637
  continue;
13514
13638
  }
13515
13639
  }
13516
- yield { type: "status", content: `Opening Diff in IDE: ${path19.basename(absPath)}...` };
13640
+ yield { type: "status", content: `Opening Diff in IDE: ${path20.basename(absPath)}...` };
13517
13641
  showDiffInIDE(absPath, originalContent, modifiedContent);
13518
13642
  diffOpened = true;
13519
13643
  await new Promise((r) => setTimeout(r, 50));
13520
13644
  } else if (normToolName === "write_file") {
13521
13645
  const rawContent = toolArgs.content || toolArgs.newContent || "";
13522
13646
  const modifiedContent = rawContent.endsWith("\n") ? rawContent : rawContent + "\n";
13523
- if (!fs20.existsSync(absPath)) {
13647
+ if (!fs21.existsSync(absPath)) {
13524
13648
  isNewFileCreated = true;
13525
- fs20.mkdirSync(path19.dirname(absPath), { recursive: true });
13526
- fs20.writeFileSync(absPath, "", "utf8");
13649
+ fs21.mkdirSync(path20.dirname(absPath), { recursive: true });
13650
+ fs21.writeFileSync(absPath, "", "utf8");
13527
13651
  }
13528
- yield { type: "status", content: `Opening New File Diff in IDE: ${path19.basename(absPath)}...` };
13652
+ yield { type: "status", content: `Opening New File Diff in IDE: ${path20.basename(absPath)}...` };
13529
13653
  showDiffInIDE(absPath, "", modifiedContent);
13530
13654
  diffOpened = true;
13531
13655
  await new Promise((r) => setTimeout(r, 50));
@@ -13561,11 +13685,11 @@ ${boxMid}}`) };
13561
13685
  if (normToolName === "write_file" || normToolName === "update_file") {
13562
13686
  const { path: filePath } = parseArgs(toolCall.args);
13563
13687
  if (filePath) {
13564
- const absPath = path19.resolve(process.cwd(), filePath);
13688
+ const absPath = path20.resolve(process.cwd(), filePath);
13565
13689
  closeDiffInIDE(absPath, approval);
13566
- if (approval === "deny" && isNewFileCreated && fs20.existsSync(absPath)) {
13690
+ if (approval === "deny" && isNewFileCreated && fs21.existsSync(absPath)) {
13567
13691
  try {
13568
- fs20.unlinkSync(absPath);
13692
+ fs21.unlinkSync(absPath);
13569
13693
  } catch (e) {
13570
13694
  }
13571
13695
  }
@@ -13577,13 +13701,13 @@ ${boxMid}}`) };
13577
13701
  }
13578
13702
  if (approval === "allow" && diffOpened && isBridgeConnected()) {
13579
13703
  const { path: filePath } = parseArgs(toolCall.args);
13580
- const absPath = path19.resolve(process.cwd(), filePath);
13704
+ const absPath = path20.resolve(process.cwd(), filePath);
13581
13705
  const finalIDE = await getIDEContext();
13582
13706
  let finalContent = "";
13583
13707
  if (finalIDE && finalIDE.file_focused === absPath && finalIDE.full_content) {
13584
13708
  finalContent = finalIDE.full_content;
13585
- } else if (fs20.existsSync(absPath)) {
13586
- finalContent = fs20.readFileSync(absPath, "utf8");
13709
+ } else if (fs21.existsSync(absPath)) {
13710
+ finalContent = fs21.readFileSync(absPath, "utf8");
13587
13711
  }
13588
13712
  const verifiedLines = finalContent.split(/\r?\n/);
13589
13713
  const verifiedLineCount = verifiedLines.length;
@@ -13746,7 +13870,7 @@ ${boxBottom}`}`) };
13746
13870
  try {
13747
13871
  const { path: filePath } = parseArgs(toolCall.args);
13748
13872
  if (filePath) {
13749
- const absPath = path19.resolve(process.cwd(), filePath);
13873
+ const absPath = path20.resolve(process.cwd(), filePath);
13750
13874
  const currentIDE = await getIDEContext();
13751
13875
  if (currentIDE && currentIDE.file_focused === absPath && currentIDE.full_content) {
13752
13876
  execToolContext.forcedContent = currentIDE.full_content;
@@ -13760,7 +13884,7 @@ ${boxBottom}`}`) };
13760
13884
  if ((normToolName === "write_file" || normToolName === "update_file") && result.startsWith("SUCCESS")) {
13761
13885
  const { path: filePath } = parseArgs(toolCall.args);
13762
13886
  if (filePath) {
13763
- const absPath = path19.resolve(process.cwd(), filePath);
13887
+ const absPath = path20.resolve(process.cwd(), filePath);
13764
13888
  openFileInEditor(absPath);
13765
13889
  }
13766
13890
  }
@@ -14004,9 +14128,9 @@ ${colorMainWords(output)}` };
14004
14128
  })() : String(err);
14005
14129
  ;
14006
14130
  const date = (/* @__PURE__ */ new Date()).toLocaleString();
14007
- const agentErrDir = path19.join(LOGS_DIR, "agent");
14008
- if (!fs20.existsSync(agentErrDir)) fs20.mkdirSync(agentErrDir, { recursive: true });
14009
- fs20.appendFileSync(path19.join(agentErrDir, "error.log"), `ERROR [${date}]: ${errLog}
14131
+ const agentErrDir = path20.join(LOGS_DIR, "agent");
14132
+ if (!fs21.existsSync(agentErrDir)) fs21.mkdirSync(agentErrDir, { recursive: true });
14133
+ fs21.appendFileSync(path20.join(agentErrDir, "error.log"), `ERROR [${date}]: ${errLog}
14010
14134
 
14011
14135
  ----------------------------------------------------------------------
14012
14136
 
@@ -14053,7 +14177,7 @@ ${recoveryText}`
14053
14177
  yield { type: "status", content: `Error Occured. Recovering Stream...` };
14054
14178
  } else {
14055
14179
  throw new Error(`Stream collapsed too many times. (Failed to resolve ${MAX_RETRIES} times)
14056
- Error Log can be found in ${path19.join(LOGS_DIR, "agent", "error.log")}`);
14180
+ Error Log can be found in ${path20.join(LOGS_DIR, "agent", "error.log")}`);
14057
14181
  }
14058
14182
  } else {
14059
14183
  if (retryCount <= MAX_RETRIES) {
@@ -14071,7 +14195,7 @@ Error Log can be found in ${path19.join(LOGS_DIR, "agent", "error.log")}`);
14071
14195
  yield { type: "status", content: `Trying to reach ${modelName}...` };
14072
14196
  } else {
14073
14197
  throw new Error(`Model ${modelName} cannot be reached. (Failed ${MAX_RETRIES} times)
14074
- Error Log can be found in ${path19.join(LOGS_DIR, "agent", "error.log")}`);
14198
+ Error Log can be found in ${path20.join(LOGS_DIR, "agent", "error.log")}`);
14075
14199
  }
14076
14200
  }
14077
14201
  }
@@ -14174,10 +14298,10 @@ Error Log can be found in ${path19.join(LOGS_DIR, "agent", "error.log")}`);
14174
14298
  }
14175
14299
  })() : String(err);
14176
14300
  const date = (/* @__PURE__ */ new Date()).toLocaleString();
14177
- const agentErrDir = path19.join(LOGS_DIR, "agent");
14301
+ const agentErrDir = path20.join(LOGS_DIR, "agent");
14178
14302
  yield { type: "text", content: `\u274C CRITICAL ERROR: ${errLog}` };
14179
- if (!fs20.existsSync(agentErrDir)) fs20.mkdirSync(agentErrDir, { recursive: true });
14180
- fs20.appendFileSync(path19.join(agentErrDir, "error.log"), `CRITICAL ERROR [${date}]: ${errLog}
14303
+ if (!fs21.existsSync(agentErrDir)) fs21.mkdirSync(agentErrDir, { recursive: true });
14304
+ fs21.appendFileSync(path20.join(agentErrDir, "error.log"), `CRITICAL ERROR [${date}]: ${errLog}
14181
14305
 
14182
14306
  ----------------------------------------------------------------------
14183
14307
 
@@ -14299,11 +14423,11 @@ ${cleanResponse}
14299
14423
  } else if (normalizedToolName === "list_files" || normalizedToolName === "read_folder" || normalizedToolName === "readfolder") {
14300
14424
  label = `\u2714 \x1B[95mBrowsed Folder\x1B[0m`;
14301
14425
  } else if (normalizedToolName === "write_file" || normalizedToolName === "writefile") {
14302
- const path21 = parseArgs(toolCall.args).path || "...";
14303
- label = `\u2714 \x1B[95mFile Created\x1B[0m: ${path21}`;
14426
+ const path22 = parseArgs(toolCall.args).path || "...";
14427
+ label = `\u2714 \x1B[95mFile Created\x1B[0m: ${path22}`;
14304
14428
  } else if (normalizedToolName === "update_file" || normalizedToolName === "updatefile" || normalizedToolName === "patchfile" || normalizedToolName === "patch_file" || normalizedToolName === "patchfile" || normalizedToolName === "updatefile") {
14305
- const path21 = parseArgs(toolCall.args).path || "...";
14306
- label = `\u2714 \x1B[95mFile Edited\x1B[0m: ${path21}`;
14429
+ const path22 = parseArgs(toolCall.args).path || "...";
14430
+ label = `\u2714 \x1B[95mFile Edited\x1B[0m: ${path22}`;
14307
14431
  } else if (normalizedToolName === "file_map" || normalizedToolName === "filemap") {
14308
14432
  label = `\u2714 \x1B[95mIndexed\x1B[0m`;
14309
14433
  } else if (normalizedToolName === "await") {
@@ -15169,15 +15293,20 @@ var init_RevertModal = __esm({
15169
15293
  import puppeteer4 from "puppeteer";
15170
15294
  import { exec } from "child_process";
15171
15295
  import { promisify } from "util";
15172
- import fs21 from "fs";
15296
+ import fs22 from "fs";
15173
15297
  var execAsync, checkPuppeteerReady, installPuppeteerBrowser;
15174
15298
  var init_setup = __esm({
15175
15299
  "src/utils/setup.js"() {
15300
+ init_puppeteer_helper();
15176
15301
  execAsync = promisify(exec);
15177
15302
  checkPuppeteerReady = () => {
15178
15303
  try {
15304
+ const pptrConfig = getPuppeteerConfig();
15305
+ if (pptrConfig.executablePath && fs22.existsSync(pptrConfig.executablePath)) {
15306
+ return true;
15307
+ }
15179
15308
  const exePath = puppeteer4.executablePath();
15180
- const exists = exePath && fs21.existsSync(exePath);
15309
+ const exists = exePath && fs22.existsSync(exePath);
15181
15310
  if (exists) return true;
15182
15311
  } catch (e) {
15183
15312
  return false;
@@ -15207,13 +15336,13 @@ var app_exports = {};
15207
15336
  __export(app_exports, {
15208
15337
  default: () => App
15209
15338
  });
15210
- import os4 from "os";
15339
+ import os5 from "os";
15211
15340
  import React15, { useState as useState14, useEffect as useEffect11, useRef as useRef4, useMemo as useMemo2 } from "react";
15212
15341
  import { Box as Box14, Text as Text15, useInput as useInput9, useStdout as useStdout2, Static } from "ink";
15213
- import fs22 from "fs-extra";
15214
- import path20 from "path";
15342
+ import fs23 from "fs-extra";
15343
+ import path21 from "path";
15215
15344
  import { exec as exec2 } from "child_process";
15216
- import { fileURLToPath } from "url";
15345
+ import { fileURLToPath as fileURLToPath2 } from "url";
15217
15346
  import TextInput4 from "ink-text-input";
15218
15347
  import SelectInput2 from "ink-select-input";
15219
15348
  import gradient2 from "gradient-string";
@@ -15456,10 +15585,10 @@ function App({ args = [] }) {
15456
15585
  const kbPath = getKeybindingsPath(ideName);
15457
15586
  if (!kbPath) return;
15458
15587
  try {
15459
- await fs22.ensureDir(path20.dirname(kbPath));
15588
+ await fs23.ensureDir(path21.dirname(kbPath));
15460
15589
  let bindings = [];
15461
- if (fs22.existsSync(kbPath)) {
15462
- const content = fs22.readFileSync(kbPath, "utf8").trim();
15590
+ if (fs23.existsSync(kbPath)) {
15591
+ const content = fs23.readFileSync(kbPath, "utf8").trim();
15463
15592
  if (content) {
15464
15593
  try {
15465
15594
  bindings = parseJsonc(content);
@@ -15479,7 +15608,7 @@ function App({ args = [] }) {
15479
15608
  },
15480
15609
  "when": "terminalFocus"
15481
15610
  });
15482
- fs22.writeFileSync(kbPath, JSON.stringify(bindings, null, 4), "utf8");
15611
+ fs23.writeFileSync(kbPath, JSON.stringify(bindings, null, 4), "utf8");
15483
15612
  cachedShortcut = "Shift + Enter";
15484
15613
  setMessages((prev) => {
15485
15614
  setCompletedIndex(prev.length + 1);
@@ -15727,7 +15856,7 @@ function App({ args = [] }) {
15727
15856
  useEffect11(() => setEscPressCount(0), [input]);
15728
15857
  const [messages, rawSetMessages] = useState14(() => {
15729
15858
  const logoMsg = { id: "logo-" + Date.now(), role: "system", isLogo: true, isMeta: true };
15730
- const isHomeDir = process.cwd() === os4.homedir();
15859
+ const isHomeDir = process.cwd() === os5.homedir();
15731
15860
  const isSystemDir = (() => {
15732
15861
  const cwd = process.cwd().toLowerCase();
15733
15862
  if (process.platform === "win32") {
@@ -15754,7 +15883,7 @@ function App({ args = [] }) {
15754
15883
  id: "home-warning",
15755
15884
  role: "system",
15756
15885
  text: `[SECURITY ALERT] HOME DIRECTORY DETECTED`,
15757
- subText: `You are currently in ${os4.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,
15886
+ subText: `You are currently in ${os5.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,
15758
15887
  isHomeWarning: true
15759
15888
  });
15760
15889
  }
@@ -16155,7 +16284,7 @@ function App({ args = [] }) {
16155
16284
  useEffect11(() => {
16156
16285
  async function init() {
16157
16286
  try {
16158
- const pkg = JSON.parse(fs22.readFileSync(path20.join(process.cwd(), "package.json"), "utf8"));
16287
+ const pkg = JSON.parse(fs23.readFileSync(path21.join(process.cwd(), "package.json"), "utf8"));
16159
16288
  initBridge(versionFluxflow || pkg.version || "2.0.0");
16160
16289
  } catch (e) {
16161
16290
  initBridge("2.0.0");
@@ -16278,7 +16407,7 @@ function App({ args = [] }) {
16278
16407
  if (!parsedArgs.playground) {
16279
16408
  deleteChat(PLAYGROUND_CHAT_ID).catch(() => {
16280
16409
  });
16281
- fs22.remove(path20.join(DATA_DIR, "playground")).catch(() => {
16410
+ fs23.remove(path21.join(DATA_DIR, "playground")).catch(() => {
16282
16411
  });
16283
16412
  }
16284
16413
  performVersionCheck(false, freshSettings);
@@ -16312,9 +16441,9 @@ function App({ args = [] }) {
16312
16441
  }
16313
16442
  }
16314
16443
  if (parsedArgs.playground) {
16315
- const playgroundDir = path20.join(DATA_DIR, "playground");
16444
+ const playgroundDir = path21.join(DATA_DIR, "playground");
16316
16445
  try {
16317
- fs22.ensureDirSync(playgroundDir);
16446
+ fs23.ensureDirSync(playgroundDir);
16318
16447
  process.chdir(playgroundDir);
16319
16448
  } catch (e) {
16320
16449
  }
@@ -16355,8 +16484,8 @@ function App({ args = [] }) {
16355
16484
  if (kbPath) {
16356
16485
  try {
16357
16486
  let bindings = [];
16358
- if (fs22.existsSync(kbPath)) {
16359
- const content = fs22.readFileSync(kbPath, "utf8").trim();
16487
+ if (fs23.existsSync(kbPath)) {
16488
+ const content = fs23.readFileSync(kbPath, "utf8").trim();
16360
16489
  if (content) {
16361
16490
  bindings = parseJsonc(content);
16362
16491
  }
@@ -16889,22 +17018,22 @@ ${cleanText}`, color: "magenta" }];
16889
17018
  });
16890
17019
  break;
16891
17020
  }
16892
- const src = path20.join(DATA_DIR, "playground");
16893
- const dest = path20.join(parsedArgs.originalCwd, "playground-export");
17021
+ const src = path21.join(DATA_DIR, "playground");
17022
+ const dest = path21.join(parsedArgs.originalCwd, "playground-export");
16894
17023
  const moveFiles = async () => {
16895
17024
  try {
16896
17025
  setMessages((prev) => {
16897
17026
  setCompletedIndex(prev.length + 1);
16898
17027
  return [...prev, { id: Date.now(), role: "system", text: `[PLAYGROUND] Exporting playground content to ${dest}`, isMeta: true }];
16899
17028
  });
16900
- await fs22.ensureDir(dest);
17029
+ await fs23.ensureDir(dest);
16901
17030
  const excludeDirs = ["node_modules", ".git", ".venv", "venv", "env", ".next", "dist", "build", ".cache"];
16902
- await fs22.copy(src, dest, {
17031
+ await fs23.copy(src, dest, {
16903
17032
  overwrite: true,
16904
17033
  filter: (srcPath) => {
16905
- const relative = path20.relative(src, srcPath);
17034
+ const relative = path21.relative(src, srcPath);
16906
17035
  if (!relative) return true;
16907
- const parts2 = relative.split(path20.sep);
17036
+ const parts2 = relative.split(path21.sep);
16908
17037
  return !parts2.some((part) => excludeDirs.includes(part));
16909
17038
  }
16910
17039
  });
@@ -16964,7 +17093,7 @@ ${cleanText}`, color: "magenta" }];
16964
17093
  }
16965
17094
  }
16966
17095
  setTimeout(() => {
16967
- fs22.emptyDir(path20.join(DATA_DIR, "playground")).catch((err) => {
17096
+ fs23.emptyDir(path21.join(DATA_DIR, "playground")).catch((err) => {
16968
17097
  setMessages((prev) => {
16969
17098
  const newMsgs = [...prev, {
16970
17099
  id: "playground-" + Date.now(),
@@ -17261,7 +17390,7 @@ ${cleanText}`, color: "magenta" }];
17261
17390
  }
17262
17391
  case "/export": {
17263
17392
  const exportFile = `export-fluxflow-${chatId}.txt`;
17264
- const exportPath = path20.join(process.cwd(), exportFile);
17393
+ const exportPath = path21.join(process.cwd(), exportFile);
17265
17394
  const exportLines = [];
17266
17395
  let insideAgentBlock = false;
17267
17396
  for (let i = 0; i < messages.length; i++) {
@@ -17313,7 +17442,7 @@ ${cleanText}`, color: "magenta" }];
17313
17442
  }
17314
17443
  const fileContent = exportLines.join("\n");
17315
17444
  try {
17316
- fs22.writeFileSync(exportPath, fileContent, "utf8");
17445
+ fs23.writeFileSync(exportPath, fileContent, "utf8");
17317
17446
  setMessages((prev) => {
17318
17447
  setCompletedIndex(prev.length + 1);
17319
17448
  return [...prev, {
@@ -17360,12 +17489,12 @@ ${list || "No saved chats found."}`, isMeta: true }];
17360
17489
  setCompletedIndex(prev.length + 1);
17361
17490
  return [...prev, { id: Date.now(), role: "system", text: "[NUCLEAR] Initiating reset...", isMeta: true }];
17362
17491
  });
17363
- if (fs22.existsSync(LOGS_DIR)) fs22.removeSync(LOGS_DIR);
17364
- if (fs22.existsSync(SECRET_DIR)) fs22.removeSync(SECRET_DIR);
17365
- if (fs22.existsSync(SETTINGS_FILE)) fs22.removeSync(SETTINGS_FILE);
17492
+ if (fs23.existsSync(LOGS_DIR)) fs23.removeSync(LOGS_DIR);
17493
+ if (fs23.existsSync(SECRET_DIR)) fs23.removeSync(SECRET_DIR);
17494
+ if (fs23.existsSync(SETTINGS_FILE)) fs23.removeSync(SETTINGS_FILE);
17366
17495
  try {
17367
- const items = fs22.readdirSync(FLUXFLOW_DIR);
17368
- if (items.length === 0) fs22.removeSync(FLUXFLOW_DIR);
17496
+ const items = fs23.readdirSync(FLUXFLOW_DIR);
17497
+ if (items.length === 0) fs23.removeSync(FLUXFLOW_DIR);
17369
17498
  } catch (e) {
17370
17499
  }
17371
17500
  setTimeout(() => {
@@ -17487,15 +17616,15 @@ ${list || "No saved chats found."}`, isMeta: true }];
17487
17616
  # SKILLS & WORKFLOWS
17488
17617
  - [Define custom step-by-step recipes for this project here]
17489
17618
  `;
17490
- const filePath = path20.join(process.cwd(), "FluxFlow.md");
17491
- if (fs22.pathExistsSync(filePath)) {
17619
+ const filePath = path21.join(process.cwd(), "FluxFlow.md");
17620
+ if (fs23.pathExistsSync(filePath)) {
17492
17621
  setMessages((prev) => {
17493
17622
  setCompletedIndex(prev.length + 1);
17494
17623
  return [...prev, { id: "init-err-" + Date.now(), role: "system", text: "ERROR: FluxFlow.md already exists in this directory.", isMeta: true }];
17495
17624
  });
17496
17625
  } else {
17497
17626
  try {
17498
- fs22.writeFileSync(filePath, template);
17627
+ fs23.writeFileSync(filePath, template);
17499
17628
  setMessages((prev) => {
17500
17629
  setCompletedIndex(prev.length + 1);
17501
17630
  return [...prev, { id: "init-ok-" + Date.now(), role: "system", text: "[SUCCESS] FluxFlow.md has been initialized. You can now customize it for this project.", isMeta: true }];
@@ -19534,15 +19663,15 @@ var init_app = __esm({
19534
19663
  };
19535
19664
  getKeybindingsPath = (ideName) => {
19536
19665
  const dirName = getIDEDirName(ideName);
19537
- const home = os4.homedir();
19666
+ const home = os5.homedir();
19538
19667
  if (process.platform === "win32") {
19539
19668
  const appData = process.env.APPDATA;
19540
19669
  if (!appData) return null;
19541
- return path20.join(appData, dirName, "User", "keybindings.json");
19670
+ return path21.join(appData, dirName, "User", "keybindings.json");
19542
19671
  } else if (process.platform === "darwin") {
19543
- return path20.join(home, "Library", "Application Support", dirName, "User", "keybindings.json");
19672
+ return path21.join(home, "Library", "Application Support", dirName, "User", "keybindings.json");
19544
19673
  } else {
19545
- return path20.join(home, ".config", dirName, "User", "keybindings.json");
19674
+ return path21.join(home, ".config", dirName, "User", "keybindings.json");
19546
19675
  }
19547
19676
  };
19548
19677
  parseJsonc = (content) => {
@@ -19588,8 +19717,8 @@ var init_app = __esm({
19588
19717
  DOCS_URL = "https://fluxflow-cli.onrender.com/";
19589
19718
  linesAdded = 0;
19590
19719
  linesRemoved = 0;
19591
- packageJsonPath = path20.join(path20.dirname(fileURLToPath(import.meta.url)), "../package.json");
19592
- packageJson = JSON.parse(fs22.readFileSync(packageJsonPath, "utf8"));
19720
+ packageJsonPath = path21.join(path21.dirname(fileURLToPath2(import.meta.url)), "../package.json");
19721
+ packageJson = JSON.parse(fs23.readFileSync(packageJsonPath, "utf8"));
19593
19722
  versionFluxflow = packageJson.version;
19594
19723
  updatedOn = packageJson.date || "2026-05-20";
19595
19724
  ResolutionModal = ({ data, onResolve, onEdit }) => /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "column", borderStyle: "round", borderColor: "grey", padding: 0, width: "100%" }, /* @__PURE__ */ React15.createElement(Box14, { paddingX: 1 }, /* @__PURE__ */ React15.createElement(Text15, { color: "white", bold: true, underline: true }, data.startsWith("/btw") ? "QUESTION" : "STEERING HINT", " RESOLUTION")), /* @__PURE__ */ React15.createElement(Box14, { paddingX: 1, marginTop: 1 }, /* @__PURE__ */ React15.createElement(Text15, null, "The agent already finished the task before your ", data.startsWith("/btw") ? "question" : "hint", " was consumed.")), /* @__PURE__ */ React15.createElement(Box14, { marginTop: 1, backgroundColor: "#222", paddingX: 2, width: "100%" }, /* @__PURE__ */ React15.createElement(Text15, { italic: true, color: "gray" }, '"', data.replace("/btw", "").trim(), '"')), /* @__PURE__ */ React15.createElement(Box14, { paddingX: 1, marginTop: 1 }, /* @__PURE__ */ React15.createElement(Text15, { color: "grey" }, "How would you like to proceed?")), /* @__PURE__ */ React15.createElement(Box14, { marginTop: 0 }, /* @__PURE__ */ React15.createElement(
@@ -19685,19 +19814,19 @@ var init_app = __esm({
19685
19814
  const fileList = [];
19686
19815
  const scan = (currentDir) => {
19687
19816
  try {
19688
- const files = fs22.readdirSync(currentDir);
19817
+ const files = fs23.readdirSync(currentDir);
19689
19818
  for (const file of files) {
19690
19819
  if (["node_modules", ".git", ".gemini", "dist", "build", ".next", ".cache", "out"].includes(file)) {
19691
19820
  continue;
19692
19821
  }
19693
- const filePath = path20.join(currentDir, file);
19694
- const stat = fs22.statSync(filePath);
19822
+ const filePath = path21.join(currentDir, file);
19823
+ const stat = fs23.statSync(filePath);
19695
19824
  if (stat.isDirectory()) {
19696
19825
  scan(filePath);
19697
19826
  } else {
19698
19827
  fileList.push({
19699
19828
  name: file,
19700
- relativePath: path20.relative(process.cwd(), filePath)
19829
+ relativePath: path21.relative(process.cwd(), filePath)
19701
19830
  });
19702
19831
  }
19703
19832
  }
@@ -19781,9 +19910,9 @@ var init_app = __esm({
19781
19910
 
19782
19911
  // src/cli.jsx
19783
19912
  import { spawn as spawn3 } from "child_process";
19784
- import { fileURLToPath as fileURLToPath2 } from "url";
19785
- import os5 from "os";
19786
- var totalSystemRamBytes = os5.totalmem();
19913
+ import { fileURLToPath as fileURLToPath3 } from "url";
19914
+ import os6 from "os";
19915
+ var totalSystemRamBytes = os6.totalmem();
19787
19916
  var totalSystemRamMB = totalSystemRamBytes / (1024 * 1024);
19788
19917
  var SAFETY_MARGIN = 0.5;
19789
19918
  var calculatedLimit = Math.floor(totalSystemRamMB * SAFETY_MARGIN);
@@ -19798,7 +19927,7 @@ if (!isNaN(_allocValue) && _allocValue < 64) {
19798
19927
  }
19799
19928
  var _maxAllowed = Math.floor(totalSystemRamMB * 0.75);
19800
19929
  var HEAP_LIMIT = !isNaN(_allocValue) && _allocValue > 0 ? Math.min(_allocValue, _maxAllowed) : Math.max(1536, Math.min(32768, calculatedLimit));
19801
- var isBundled = fileURLToPath2(import.meta.url).endsWith(".js");
19930
+ var isBundled = fileURLToPath3(import.meta.url).endsWith(".js");
19802
19931
  if (isBundled && !process.execArgv.some((arg) => arg.includes("max-old-space-size"))) {
19803
19932
  if (!Number.isNaN(_allocValue)) {
19804
19933
  console.log(`
@@ -19809,7 +19938,7 @@ if (isBundled && !process.execArgv.some((arg) => arg.includes("max-old-space-siz
19809
19938
  `--max-old-space-size=${HEAP_LIMIT}`,
19810
19939
  `--expose-gc`,
19811
19940
  `--max-semi-space-size=1`,
19812
- fileURLToPath2(import.meta.url),
19941
+ fileURLToPath3(import.meta.url),
19813
19942
  ...process.argv.slice(2)
19814
19943
  ], { stdio: "inherit" });
19815
19944
  cp.on("exit", (code) => process.exit(code || 0));
@@ -19820,11 +19949,11 @@ if (isBundled && !process.execArgv.some((arg) => arg.includes("max-old-space-siz
19820
19949
  const isVersion = args.includes("--version") || args.includes("-v");
19821
19950
  const isUpdate = args[0] === "--update";
19822
19951
  if (isVersion || isHelp || isHelpCommands || isUpdate) {
19823
- const fs23 = await import("fs");
19824
- const path21 = await import("path");
19825
- const { fileURLToPath: fileURLToPath3 } = await import("url");
19826
- const packageJsonPath2 = path21.join(path21.dirname(fileURLToPath3(import.meta.url)), "../package.json");
19827
- const packageJson2 = JSON.parse(fs23.readFileSync(packageJsonPath2, "utf8"));
19952
+ const fs24 = await import("fs");
19953
+ const path22 = await import("path");
19954
+ const { fileURLToPath: fileURLToPath4 } = await import("url");
19955
+ const packageJsonPath2 = path22.join(path22.dirname(fileURLToPath4(import.meta.url)), "../package.json");
19956
+ const packageJson2 = JSON.parse(fs24.readFileSync(packageJsonPath2, "utf8"));
19828
19957
  const versionFluxflow2 = packageJson2.version;
19829
19958
  if (isVersion) {
19830
19959
  console.log(`v${versionFluxflow2}`);