fluxflow-cli 3.16.5 → 3.16.6
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/fluxflow.js +298 -299
- package/package.json +3 -2
package/dist/fluxflow.js
CHANGED
|
@@ -10240,9 +10240,8 @@ ${finalResults}`;
|
|
|
10240
10240
|
|
|
10241
10241
|
// src/tools/web_scrape.js
|
|
10242
10242
|
import puppeteer2 from "puppeteer";
|
|
10243
|
-
import fs13 from "fs";
|
|
10244
|
-
import path12 from "path";
|
|
10245
10243
|
import TurndownService from "turndown";
|
|
10244
|
+
import { gfm } from "turndown-plugin-gfm";
|
|
10246
10245
|
var web_scrape;
|
|
10247
10246
|
var init_web_scrape = __esm({
|
|
10248
10247
|
"src/tools/web_scrape.js"() {
|
|
@@ -10284,7 +10283,7 @@ var init_web_scrape = __esm({
|
|
|
10284
10283
|
await page.goto(url, { waitUntil: "networkidle2", timeout: 18e4 });
|
|
10285
10284
|
await new Promise((r) => setTimeout(r, 5e3));
|
|
10286
10285
|
let htmlContent = await page.evaluate(() => {
|
|
10287
|
-
const junk = document.querySelectorAll("script, style,
|
|
10286
|
+
const junk = document.querySelectorAll("script, style, noscript, svg, canvas, iframe, ad, .ads, link, meta, img");
|
|
10288
10287
|
junk.forEach((el) => el.remove());
|
|
10289
10288
|
const iterator = document.createNodeIterator(document.body, NodeFilter.SHOW_COMMENT);
|
|
10290
10289
|
let currentNode;
|
|
@@ -10330,6 +10329,7 @@ var init_web_scrape = __esm({
|
|
|
10330
10329
|
headingStyle: "atx",
|
|
10331
10330
|
codeBlockStyle: "fenced"
|
|
10332
10331
|
});
|
|
10332
|
+
turndownService.use(gfm);
|
|
10333
10333
|
const rawMarkdown = turndownService.turndown(cleanedHtml).replace(/\.\s*\n/g, "\n").replace(/ +/g, " ").replace(/\t/g, " ").replace(/\n\s+/g, "\n").replace(/\n{3,}/g, "\n\n");
|
|
10334
10334
|
const markdown = rawMarkdown.substring(0, 5e4);
|
|
10335
10335
|
await browser.close();
|
|
@@ -10339,7 +10339,6 @@ ${markdown}${rawMarkdown.length > 5e4 ? "\n\n[TRUNCATED AT 50K CHARS]" : ""}`;
|
|
|
10339
10339
|
} catch (err) {
|
|
10340
10340
|
lastError = err;
|
|
10341
10341
|
if (browser) await browser.close();
|
|
10342
|
-
fs13.writeFileSync(path12.join(LOGS_DIR, "web_tools", "scrape", "standard_mode", "ERROR.txt"), err.message);
|
|
10343
10342
|
if (attempt < maxRetries) {
|
|
10344
10343
|
const backoff = Math.pow(2, attempt) * 1e3;
|
|
10345
10344
|
await new Promise((r) => setTimeout(r, backoff));
|
|
@@ -10463,8 +10462,8 @@ var init_chat = __esm({
|
|
|
10463
10462
|
});
|
|
10464
10463
|
|
|
10465
10464
|
// src/tools/view_file.js
|
|
10466
|
-
import
|
|
10467
|
-
import
|
|
10465
|
+
import fs13 from "fs";
|
|
10466
|
+
import path12 from "path";
|
|
10468
10467
|
var view_file;
|
|
10469
10468
|
var init_view_file = __esm({
|
|
10470
10469
|
"src/tools/view_file.js"() {
|
|
@@ -10478,16 +10477,16 @@ var init_view_file = __esm({
|
|
|
10478
10477
|
let finalStart = sLine || 1;
|
|
10479
10478
|
let finalEnd = eLine || (sLine ? sLine + 800 : 800);
|
|
10480
10479
|
if (!targetPath) return 'ERROR: Missing "path" argument for view_file.';
|
|
10481
|
-
const absolutePath =
|
|
10480
|
+
const absolutePath = path12.resolve(process.cwd(), targetPath);
|
|
10482
10481
|
try {
|
|
10483
|
-
if (!
|
|
10482
|
+
if (!fs13.existsSync(absolutePath)) {
|
|
10484
10483
|
return `ERROR: File [${targetPath}] does not exist.`;
|
|
10485
10484
|
}
|
|
10486
|
-
const stats =
|
|
10485
|
+
const stats = fs13.statSync(absolutePath);
|
|
10487
10486
|
if (stats.isDirectory()) {
|
|
10488
10487
|
return `ERROR: Path [${targetPath}] is a directory. Use list_files instead.`;
|
|
10489
10488
|
}
|
|
10490
|
-
const ext =
|
|
10489
|
+
const ext = path12.extname(targetPath).toLowerCase();
|
|
10491
10490
|
const videoExtensions = [".mp4", ".mkv", ".avi", ".mov", ".webm", ".flv", ".wmv", ".mpeg", ".mpg"];
|
|
10492
10491
|
if (videoExtensions.includes(ext)) {
|
|
10493
10492
|
const format = ext.slice(1).toUpperCase();
|
|
@@ -10507,7 +10506,7 @@ var init_view_file = __esm({
|
|
|
10507
10506
|
if (!isMultiModal) {
|
|
10508
10507
|
return `ERROR: Multimodality is not supported for the current model. Unable to load [${targetPath}].`;
|
|
10509
10508
|
}
|
|
10510
|
-
const buffer =
|
|
10509
|
+
const buffer = fs13.readFileSync(absolutePath);
|
|
10511
10510
|
const base64 = buffer.toString("base64");
|
|
10512
10511
|
const mimeType = mimeMap[ext];
|
|
10513
10512
|
return {
|
|
@@ -10520,7 +10519,7 @@ var init_view_file = __esm({
|
|
|
10520
10519
|
}
|
|
10521
10520
|
};
|
|
10522
10521
|
}
|
|
10523
|
-
let content =
|
|
10522
|
+
let content = fs13.readFileSync(absolutePath, "utf8");
|
|
10524
10523
|
if (content.startsWith("\uFEFF")) {
|
|
10525
10524
|
content = content.slice(1);
|
|
10526
10525
|
}
|
|
@@ -10548,8 +10547,8 @@ ${code}`;
|
|
|
10548
10547
|
});
|
|
10549
10548
|
|
|
10550
10549
|
// src/tools/write_file.js
|
|
10551
|
-
import
|
|
10552
|
-
import
|
|
10550
|
+
import fs14 from "fs";
|
|
10551
|
+
import path13 from "path";
|
|
10553
10552
|
var write_file;
|
|
10554
10553
|
var init_write_file = __esm({
|
|
10555
10554
|
"src/tools/write_file.js"() {
|
|
@@ -10560,14 +10559,14 @@ var init_write_file = __esm({
|
|
|
10560
10559
|
if (!targetPath) return 'ERROR: Missing "path" argument for write_file.';
|
|
10561
10560
|
if (content === void 0) return 'ERROR: Missing "content" argument for write_file.';
|
|
10562
10561
|
content = content.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
10563
|
-
const absolutePath =
|
|
10564
|
-
const parentDir =
|
|
10562
|
+
const absolutePath = path13.resolve(process.cwd(), targetPath);
|
|
10563
|
+
const parentDir = path13.dirname(absolutePath);
|
|
10565
10564
|
try {
|
|
10566
10565
|
await RevertManager.recordFileChange(absolutePath);
|
|
10567
10566
|
let ancestry = "";
|
|
10568
|
-
if (
|
|
10567
|
+
if (fs14.existsSync(absolutePath)) {
|
|
10569
10568
|
try {
|
|
10570
|
-
const oldData =
|
|
10569
|
+
const oldData = fs14.readFileSync(absolutePath, "utf8");
|
|
10571
10570
|
const lines = oldData.split(/\r?\n/);
|
|
10572
10571
|
ancestry = `Old File contents:
|
|
10573
10572
|
${lines.map((l, i) => `${i + 1} | ${l}`).join("\n")}
|
|
@@ -10579,16 +10578,16 @@ ${lines.map((l, i) => `${i + 1} | ${l}`).join("\n")}
|
|
|
10579
10578
|
`;
|
|
10580
10579
|
}
|
|
10581
10580
|
}
|
|
10582
|
-
if (!
|
|
10583
|
-
|
|
10581
|
+
if (!fs14.existsSync(parentDir)) {
|
|
10582
|
+
fs14.mkdirSync(parentDir, { recursive: true });
|
|
10584
10583
|
}
|
|
10585
10584
|
const strip = (t) => t.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
10586
10585
|
const processedContent = strip(content);
|
|
10587
10586
|
const finalContent = processedContent.endsWith("\n") ? processedContent : processedContent + "\n";
|
|
10588
10587
|
const lineCount = finalContent.split(/\r?\n/).length;
|
|
10589
10588
|
const originalSize = Buffer.byteLength(finalContent, "utf8");
|
|
10590
|
-
|
|
10591
|
-
let verifiedContent =
|
|
10589
|
+
fs14.writeFileSync(absolutePath, finalContent, "utf8");
|
|
10590
|
+
let verifiedContent = fs14.readFileSync(absolutePath, "utf8");
|
|
10592
10591
|
const verifiedSize = Buffer.byteLength(verifiedContent, "utf8");
|
|
10593
10592
|
const verifiedLines = verifiedContent.split(/\r?\n/);
|
|
10594
10593
|
const verifiedLineCount = verifiedLines.length;
|
|
@@ -10623,8 +10622,8 @@ ${snippet}`;
|
|
|
10623
10622
|
});
|
|
10624
10623
|
|
|
10625
10624
|
// src/tools/update_file.js
|
|
10626
|
-
import
|
|
10627
|
-
import
|
|
10625
|
+
import fs15 from "fs";
|
|
10626
|
+
import path14 from "path";
|
|
10628
10627
|
var update_file;
|
|
10629
10628
|
var init_update_file = __esm({
|
|
10630
10629
|
"src/tools/update_file.js"() {
|
|
@@ -10641,12 +10640,12 @@ var init_update_file = __esm({
|
|
|
10641
10640
|
return "ERROR: No valid replacement pairs found. Use replaceContent1, newContent1, etc.";
|
|
10642
10641
|
}
|
|
10643
10642
|
const allowMultiple = parsed.allowMultiple !== void 0 ? parsed.allowMultiple === true || String(parsed.allowMultiple).toLowerCase() === "true" : parsedAllowMultiple;
|
|
10644
|
-
const absolutePath =
|
|
10643
|
+
const absolutePath = path14.resolve(process.cwd(), targetPath);
|
|
10645
10644
|
try {
|
|
10646
|
-
if (!
|
|
10645
|
+
if (!fs15.existsSync(absolutePath)) {
|
|
10647
10646
|
return `ERROR: File [${targetPath}] does not exist. Use WriteFile instead.`;
|
|
10648
10647
|
}
|
|
10649
|
-
let diskContent = context.forcedContent ||
|
|
10648
|
+
let diskContent = context.forcedContent || fs15.readFileSync(absolutePath, "utf8");
|
|
10650
10649
|
if (diskContent.startsWith("\uFEFF")) diskContent = diskContent.slice(1);
|
|
10651
10650
|
const originalContent = diskContent.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
10652
10651
|
const { content: finalContent, results } = applyPatches(originalContent, patchPairs, { allowMultiple });
|
|
@@ -10657,7 +10656,7 @@ var init_update_file = __esm({
|
|
|
10657
10656
|
${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
|
|
10658
10657
|
}
|
|
10659
10658
|
await RevertManager.recordFileChange(absolutePath, originalContent);
|
|
10660
|
-
|
|
10659
|
+
fs15.writeFileSync(absolutePath, finalContent, "utf8");
|
|
10661
10660
|
const diffText = generateHighFidelityDiff(originalContent, finalContent, results, 12);
|
|
10662
10661
|
if (failures.length > 0) {
|
|
10663
10662
|
return `SUCCESS: File [${targetPath}] updated with some blocks failed. [${successes.length}/${patchPairs.length}] blocks applied.
|
|
@@ -10679,8 +10678,8 @@ ${diffText}`;
|
|
|
10679
10678
|
});
|
|
10680
10679
|
|
|
10681
10680
|
// src/tools/read_folder.js
|
|
10682
|
-
import
|
|
10683
|
-
import
|
|
10681
|
+
import fs16 from "fs";
|
|
10682
|
+
import path15 from "path";
|
|
10684
10683
|
var EXCLUDED_DIRS, isExcludedDir, formatMtime, read_folder;
|
|
10685
10684
|
var init_read_folder = __esm({
|
|
10686
10685
|
"src/tools/read_folder.js"() {
|
|
@@ -10857,26 +10856,26 @@ var init_read_folder = __esm({
|
|
|
10857
10856
|
}
|
|
10858
10857
|
}
|
|
10859
10858
|
recurseDepth = Math.max(1, Math.min(3, recurseDepth));
|
|
10860
|
-
const absolutePath =
|
|
10859
|
+
const absolutePath = path15.resolve(process.cwd(), targetPath);
|
|
10861
10860
|
try {
|
|
10862
|
-
if (!
|
|
10861
|
+
if (!fs16.existsSync(absolutePath)) {
|
|
10863
10862
|
return `ERROR: Path [${targetPath}] does not exist.`;
|
|
10864
10863
|
}
|
|
10865
|
-
const stats =
|
|
10864
|
+
const stats = fs16.statSync(absolutePath);
|
|
10866
10865
|
if (!stats.isDirectory()) {
|
|
10867
10866
|
return `ERROR: Path [${targetPath}] is a file, not a directory. Use ReadFile instead.`;
|
|
10868
10867
|
}
|
|
10869
10868
|
if (recurseDepth === 1) {
|
|
10870
|
-
const files =
|
|
10869
|
+
const files = fs16.readdirSync(absolutePath);
|
|
10871
10870
|
const totalItems = files.length;
|
|
10872
10871
|
const maxDisplay = 150;
|
|
10873
10872
|
const displayItems = files.slice(0, maxDisplay);
|
|
10874
10873
|
const folderData = [];
|
|
10875
10874
|
for (const file of displayItems) {
|
|
10876
|
-
const fPath =
|
|
10875
|
+
const fPath = path15.join(absolutePath, file);
|
|
10877
10876
|
let info = { name: file, type: "unknown", size: "N/A", mtime: "N/A" };
|
|
10878
10877
|
try {
|
|
10879
|
-
const fStats =
|
|
10878
|
+
const fStats = fs16.statSync(fPath);
|
|
10880
10879
|
info = {
|
|
10881
10880
|
name: file,
|
|
10882
10881
|
type: fStats.isDirectory() ? "directory" : "file",
|
|
@@ -10918,7 +10917,7 @@ ${formatted}${footer2}`;
|
|
|
10918
10917
|
if (currentDepth > recurseDepth || truncated) return [];
|
|
10919
10918
|
let entries = [];
|
|
10920
10919
|
try {
|
|
10921
|
-
entries =
|
|
10920
|
+
entries = fs16.readdirSync(dirPath);
|
|
10922
10921
|
} catch (e) {
|
|
10923
10922
|
const indent2 = " ".repeat(depth - 1);
|
|
10924
10923
|
return [`${indent2}[Inaccessible Directory]`];
|
|
@@ -10926,10 +10925,10 @@ ${formatted}${footer2}`;
|
|
|
10926
10925
|
const subDirs = [];
|
|
10927
10926
|
const fileEntries = [];
|
|
10928
10927
|
for (const name of entries) {
|
|
10929
|
-
const fullPath =
|
|
10928
|
+
const fullPath = path15.join(dirPath, name);
|
|
10930
10929
|
let isDir = false;
|
|
10931
10930
|
try {
|
|
10932
|
-
isDir =
|
|
10931
|
+
isDir = fs16.statSync(fullPath).isDirectory();
|
|
10933
10932
|
} catch (e) {
|
|
10934
10933
|
}
|
|
10935
10934
|
if (isDir) {
|
|
@@ -10967,7 +10966,7 @@ ${formatted}${footer2}`;
|
|
|
10967
10966
|
totalFiles++;
|
|
10968
10967
|
let sizeStr = "N/A";
|
|
10969
10968
|
try {
|
|
10970
|
-
const fStats =
|
|
10969
|
+
const fStats = fs16.statSync(file.fullPath);
|
|
10971
10970
|
sizeStr = (fStats.size / 1024).toFixed(1) + "KB";
|
|
10972
10971
|
} catch (e) {
|
|
10973
10972
|
}
|
|
@@ -11042,8 +11041,8 @@ var init_ask_user = __esm({
|
|
|
11042
11041
|
|
|
11043
11042
|
// src/tools/write_pdf.js
|
|
11044
11043
|
import puppeteer3 from "puppeteer";
|
|
11045
|
-
import
|
|
11046
|
-
import
|
|
11044
|
+
import path16 from "path";
|
|
11045
|
+
import fs17 from "fs-extra";
|
|
11047
11046
|
import { PDFDocument } from "pdf-lib";
|
|
11048
11047
|
var write_pdf;
|
|
11049
11048
|
var init_write_pdf = __esm({
|
|
@@ -11060,10 +11059,10 @@ var init_write_pdf = __esm({
|
|
|
11060
11059
|
} = parseArgs(args);
|
|
11061
11060
|
if (!targetPath) return 'ERROR: Missing "path" argument for write_pdf.';
|
|
11062
11061
|
if (!content) return 'ERROR: Missing "content" (HTML/CSS) for write_pdf.';
|
|
11063
|
-
const absolutePath =
|
|
11062
|
+
const absolutePath = path16.resolve(process.cwd(), targetPath);
|
|
11064
11063
|
let browser = null;
|
|
11065
11064
|
try {
|
|
11066
|
-
await
|
|
11065
|
+
await fs17.ensureDir(path16.dirname(absolutePath));
|
|
11067
11066
|
await RevertManager.recordFileChange(absolutePath);
|
|
11068
11067
|
const pptrConfig = getPuppeteerConfig();
|
|
11069
11068
|
browser = await puppeteer3.launch({
|
|
@@ -11084,11 +11083,11 @@ var init_write_pdf = __esm({
|
|
|
11084
11083
|
return null;
|
|
11085
11084
|
}
|
|
11086
11085
|
try {
|
|
11087
|
-
const imgPath =
|
|
11088
|
-
if (await
|
|
11089
|
-
const ext =
|
|
11086
|
+
const imgPath = path16.resolve(process.cwd(), originalSrc);
|
|
11087
|
+
if (await fs17.pathExists(imgPath)) {
|
|
11088
|
+
const ext = path16.extname(imgPath).toLowerCase().replace(".", "") || "png";
|
|
11090
11089
|
const mime = ext === "jpg" ? "jpeg" : ext === "svg" ? "svg+xml" : ext;
|
|
11091
|
-
const base64 = await
|
|
11090
|
+
const base64 = await fs17.readFile(imgPath, "base64");
|
|
11092
11091
|
return `data:image/${mime};base64,${base64}`;
|
|
11093
11092
|
}
|
|
11094
11093
|
} catch (e) {
|
|
@@ -11103,9 +11102,9 @@ var init_write_pdf = __esm({
|
|
|
11103
11102
|
const fullTag = match[0];
|
|
11104
11103
|
if (originalHref && fullTag.toLowerCase().includes("stylesheet") && !originalHref.startsWith("http://") && !originalHref.startsWith("https://") && !originalHref.startsWith("data:")) {
|
|
11105
11104
|
try {
|
|
11106
|
-
const cssPath =
|
|
11107
|
-
if (await
|
|
11108
|
-
const cssContent = await
|
|
11105
|
+
const cssPath = path16.resolve(process.cwd(), originalHref);
|
|
11106
|
+
if (await fs17.pathExists(cssPath)) {
|
|
11107
|
+
const cssContent = await fs17.readFile(cssPath, "utf-8");
|
|
11109
11108
|
cssCache[fullTag] = `<style>${cssContent}</style>`;
|
|
11110
11109
|
}
|
|
11111
11110
|
} catch (e) {
|
|
@@ -11186,7 +11185,7 @@ var init_write_pdf = __esm({
|
|
|
11186
11185
|
printBackground: true
|
|
11187
11186
|
});
|
|
11188
11187
|
const pdfDoc = await PDFDocument.load(pdfBytes);
|
|
11189
|
-
const fileName =
|
|
11188
|
+
const fileName = path16.basename(targetPath);
|
|
11190
11189
|
pdfDoc.setTitle(`FluxFlow_${fileName}`);
|
|
11191
11190
|
pdfDoc.setAuthor("FluxFlow CLI");
|
|
11192
11191
|
pdfDoc.setSubject("Generated with Agentic AI System");
|
|
@@ -11194,8 +11193,8 @@ var init_write_pdf = __esm({
|
|
|
11194
11193
|
pdfDoc.setCreator("FluxFlow PDF Engine");
|
|
11195
11194
|
pdfDoc.setProducer("FluxFlow (Generative AI)");
|
|
11196
11195
|
const finalPdfBytes = await pdfDoc.save();
|
|
11197
|
-
await
|
|
11198
|
-
const stats = await
|
|
11196
|
+
await fs17.writeFile(absolutePath, finalPdfBytes);
|
|
11197
|
+
const stats = await fs17.stat(absolutePath);
|
|
11199
11198
|
return `SUCCESS: PDF generated successfully at [${targetPath}] (${(stats.size / 1024).toFixed(2)} KB).`;
|
|
11200
11199
|
} catch (err) {
|
|
11201
11200
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
@@ -11208,8 +11207,8 @@ var init_write_pdf = __esm({
|
|
|
11208
11207
|
});
|
|
11209
11208
|
|
|
11210
11209
|
// src/tools/write_docx.js
|
|
11211
|
-
import
|
|
11212
|
-
import
|
|
11210
|
+
import fs18 from "fs-extra";
|
|
11211
|
+
import path17 from "path";
|
|
11213
11212
|
import HTMLtoDOCX from "html-to-docx";
|
|
11214
11213
|
var write_docx;
|
|
11215
11214
|
var init_write_docx = __esm({
|
|
@@ -11223,11 +11222,11 @@ var init_write_docx = __esm({
|
|
|
11223
11222
|
} = parseArgs(args);
|
|
11224
11223
|
if (!targetPath) return 'ERROR: Missing "path" argument for write_docx.';
|
|
11225
11224
|
if (!content) return 'ERROR: Missing "content" (HTML) for write_docx.';
|
|
11226
|
-
const absolutePath =
|
|
11225
|
+
const absolutePath = path17.resolve(process.cwd(), targetPath);
|
|
11227
11226
|
try {
|
|
11228
|
-
await
|
|
11227
|
+
await fs18.ensureDir(path17.dirname(absolutePath));
|
|
11229
11228
|
await RevertManager.recordFileChange(absolutePath);
|
|
11230
|
-
const fileName =
|
|
11229
|
+
const fileName = path17.basename(targetPath);
|
|
11231
11230
|
const fullHtml = content.includes("<html") ? content : `
|
|
11232
11231
|
<!DOCTYPE html>
|
|
11233
11232
|
<html lang="en">
|
|
@@ -11248,7 +11247,7 @@ var init_write_docx = __esm({
|
|
|
11248
11247
|
footer: true,
|
|
11249
11248
|
pageNumber: true
|
|
11250
11249
|
});
|
|
11251
|
-
await
|
|
11250
|
+
await fs18.writeFile(absolutePath, docxBuffer);
|
|
11252
11251
|
return `SUCCESS: Word document [${targetPath}] generated successfully.
|
|
11253
11252
|
- Size: ${(docxBuffer.length / 1024).toFixed(1)} KB`;
|
|
11254
11253
|
} catch (err) {
|
|
@@ -11260,22 +11259,22 @@ var init_write_docx = __esm({
|
|
|
11260
11259
|
});
|
|
11261
11260
|
|
|
11262
11261
|
// src/tools/search_keyword.js
|
|
11263
|
-
import
|
|
11264
|
-
import
|
|
11262
|
+
import fs19 from "fs/promises";
|
|
11263
|
+
import path18 from "path";
|
|
11265
11264
|
import fg from "fast-glob";
|
|
11266
11265
|
async function getFilesRecursively(dir, excludes, baseDir = dir, depth = 1) {
|
|
11267
11266
|
if (depth > 12) return [];
|
|
11268
11267
|
let results = [];
|
|
11269
11268
|
let list;
|
|
11270
11269
|
try {
|
|
11271
|
-
list = await
|
|
11270
|
+
list = await fs19.readdir(dir, { withFileTypes: true });
|
|
11272
11271
|
} catch {
|
|
11273
11272
|
return [];
|
|
11274
11273
|
}
|
|
11275
11274
|
for (const file of list) {
|
|
11276
|
-
const fullPath =
|
|
11277
|
-
const relativePath =
|
|
11278
|
-
const pathSegments = relativePath.split(
|
|
11275
|
+
const fullPath = path18.join(dir, file.name);
|
|
11276
|
+
const relativePath = path18.relative(baseDir, fullPath);
|
|
11277
|
+
const pathSegments = relativePath.split(path18.sep).map((s) => s.toLowerCase());
|
|
11279
11278
|
const fileNameLower = file.name.toLowerCase();
|
|
11280
11279
|
const isExcluded = excludes.some((ex) => {
|
|
11281
11280
|
const exLower = ex.toLowerCase();
|
|
@@ -11568,7 +11567,7 @@ var init_search_keyword = __esm({
|
|
|
11568
11567
|
}
|
|
11569
11568
|
if (matchedPaths.length === 0 && (hasRegexSyntax || fg.isDynamicPattern(posixPath))) {
|
|
11570
11569
|
const baseDirMatch = posixPath.match(/^([^\*\?\(\)\|\[\]\s]+)\//);
|
|
11571
|
-
const scanDir = baseDirMatch && !/[\*\?\(\)\|\[\]]/.test(baseDirMatch[1]) ?
|
|
11570
|
+
const scanDir = baseDirMatch && !/[\*\?\(\)\|\[\]]/.test(baseDirMatch[1]) ? path18.resolve(rootDir, baseDirMatch[1]) : rootDir;
|
|
11572
11571
|
const allFiles = await getFilesRecursively(scanDir, excludes, rootDir);
|
|
11573
11572
|
try {
|
|
11574
11573
|
let cleanRegexStr = posixPath.replace(/^\.\//, "");
|
|
@@ -11586,21 +11585,21 @@ var init_search_keyword = __esm({
|
|
|
11586
11585
|
}
|
|
11587
11586
|
} else {
|
|
11588
11587
|
filesToSearch = matchedPaths.map((relP) => ({
|
|
11589
|
-
fullPath:
|
|
11588
|
+
fullPath: path18.resolve(rootDir, relP),
|
|
11590
11589
|
relativePath: relP
|
|
11591
11590
|
}));
|
|
11592
11591
|
}
|
|
11593
11592
|
} else {
|
|
11594
11593
|
const normalised = pathArg.replace(/[\/\\]+$/, "");
|
|
11595
|
-
const fullPath =
|
|
11594
|
+
const fullPath = path18.resolve(rootDir, normalised);
|
|
11596
11595
|
try {
|
|
11597
|
-
const stat = await
|
|
11596
|
+
const stat = await fs19.stat(fullPath);
|
|
11598
11597
|
if (stat.isDirectory()) {
|
|
11599
11598
|
pathArgType = "dir";
|
|
11600
11599
|
filesToSearch = await getFilesRecursively(fullPath, excludes, rootDir);
|
|
11601
11600
|
} else if (stat.isFile()) {
|
|
11602
11601
|
pathArgType = "file";
|
|
11603
|
-
filesToSearch.push({ fullPath, relativePath:
|
|
11602
|
+
filesToSearch.push({ fullPath, relativePath: path18.relative(rootDir, fullPath) });
|
|
11604
11603
|
} else {
|
|
11605
11604
|
return `ERROR: Path is neither a file nor a directory: ${pathArg}`;
|
|
11606
11605
|
}
|
|
@@ -11613,7 +11612,7 @@ var init_search_keyword = __esm({
|
|
|
11613
11612
|
}
|
|
11614
11613
|
const searchPromises = filesToSearch.map(async (fileObj) => {
|
|
11615
11614
|
try {
|
|
11616
|
-
const content = await
|
|
11615
|
+
const content = await fs19.readFile(fileObj.fullPath, "utf-8");
|
|
11617
11616
|
if (content.includes("\0")) return [];
|
|
11618
11617
|
const lines = content.split(/\r?\n/);
|
|
11619
11618
|
const fileMatches = [];
|
|
@@ -11683,8 +11682,8 @@ var init_search_keyword = __esm({
|
|
|
11683
11682
|
});
|
|
11684
11683
|
|
|
11685
11684
|
// src/tools/generate_image.js
|
|
11686
|
-
import
|
|
11687
|
-
import
|
|
11685
|
+
import fs20 from "fs-extra";
|
|
11686
|
+
import path19 from "path";
|
|
11688
11687
|
var injectPngMetadata, generate_image;
|
|
11689
11688
|
var init_generate_image = __esm({
|
|
11690
11689
|
"src/tools/generate_image.js"() {
|
|
@@ -11863,12 +11862,12 @@ var init_generate_image = __esm({
|
|
|
11863
11862
|
"Seed": String(seed)
|
|
11864
11863
|
};
|
|
11865
11864
|
finalBuffer = injectPngMetadata(finalBuffer, metadata);
|
|
11866
|
-
const absolutePath =
|
|
11867
|
-
await
|
|
11865
|
+
const absolutePath = path19.resolve(process.cwd(), outputPath);
|
|
11866
|
+
await fs20.ensureDir(path19.dirname(absolutePath));
|
|
11868
11867
|
await RevertManager.recordFileChange(absolutePath);
|
|
11869
|
-
await
|
|
11868
|
+
await fs20.writeFile(absolutePath, finalBuffer);
|
|
11870
11869
|
await recordImageGeneration(settings);
|
|
11871
|
-
const ext =
|
|
11870
|
+
const ext = path19.extname(outputPath).toLowerCase();
|
|
11872
11871
|
const mimeMap = {
|
|
11873
11872
|
".jpg": "image/jpeg",
|
|
11874
11873
|
".jpeg": "image/jpeg",
|
|
@@ -11983,13 +11982,13 @@ var init_addMemScore = __esm({
|
|
|
11983
11982
|
});
|
|
11984
11983
|
|
|
11985
11984
|
// src/utils/parsers.js
|
|
11986
|
-
import
|
|
11987
|
-
import
|
|
11985
|
+
import fs21 from "fs-extra";
|
|
11986
|
+
import path20 from "path";
|
|
11988
11987
|
import https from "https";
|
|
11989
11988
|
async function downloadWasm(wasmFile, targetUrl = null) {
|
|
11990
11989
|
const url = targetUrl || `https://unpkg.com/tree-sitter-wasms@0.1.13/out/${wasmFile}`;
|
|
11991
|
-
const localPath =
|
|
11992
|
-
await
|
|
11990
|
+
const localPath = path20.join(PARSER_DIR, wasmFile);
|
|
11991
|
+
await fs21.ensureDir(PARSER_DIR);
|
|
11993
11992
|
return new Promise((resolve, reject) => {
|
|
11994
11993
|
const options = {
|
|
11995
11994
|
headers: {
|
|
@@ -12010,27 +12009,27 @@ async function downloadWasm(wasmFile, targetUrl = null) {
|
|
|
12010
12009
|
reject(new Error(`Failed to download ${wasmFile}: HTTP ${response.statusCode}`));
|
|
12011
12010
|
return;
|
|
12012
12011
|
}
|
|
12013
|
-
const file =
|
|
12012
|
+
const file = fs21.createWriteStream(localPath);
|
|
12014
12013
|
response.pipe(file);
|
|
12015
12014
|
file.on("finish", () => {
|
|
12016
12015
|
file.close();
|
|
12017
12016
|
resolve();
|
|
12018
12017
|
});
|
|
12019
12018
|
}).on("error", (err) => {
|
|
12020
|
-
if (
|
|
12019
|
+
if (fs21.existsSync(localPath)) fs21.unlink(localPath, () => {
|
|
12021
12020
|
});
|
|
12022
12021
|
reject(err);
|
|
12023
12022
|
});
|
|
12024
12023
|
});
|
|
12025
12024
|
}
|
|
12026
12025
|
function isParserInstalled(wasmFile) {
|
|
12027
|
-
const localPath =
|
|
12028
|
-
return
|
|
12026
|
+
const localPath = path20.join(PARSER_DIR, wasmFile);
|
|
12027
|
+
return fs21.existsSync(localPath);
|
|
12029
12028
|
}
|
|
12030
12029
|
async function deleteParser(wasmFile) {
|
|
12031
|
-
const localPath =
|
|
12032
|
-
if (
|
|
12033
|
-
await
|
|
12030
|
+
const localPath = path20.join(PARSER_DIR, wasmFile);
|
|
12031
|
+
if (fs21.existsSync(localPath)) {
|
|
12032
|
+
await fs21.unlink(localPath);
|
|
12034
12033
|
}
|
|
12035
12034
|
}
|
|
12036
12035
|
var EXTENSION_TO_WASM;
|
|
@@ -12052,8 +12051,8 @@ var init_parsers = __esm({
|
|
|
12052
12051
|
});
|
|
12053
12052
|
|
|
12054
12053
|
// src/tools/file_map.js
|
|
12055
|
-
import
|
|
12056
|
-
import
|
|
12054
|
+
import fs22 from "fs-extra";
|
|
12055
|
+
import path21 from "path";
|
|
12057
12056
|
import { createRequire as createRequire2 } from "module";
|
|
12058
12057
|
function sanitize(text, limit = 50) {
|
|
12059
12058
|
if (!text) return "";
|
|
@@ -12245,17 +12244,17 @@ var init_file_map = __esm({
|
|
|
12245
12244
|
if (!filePath) {
|
|
12246
12245
|
return 'ERROR: No file path provided. Use [tool:functions.FileMap(path="...")]';
|
|
12247
12246
|
}
|
|
12248
|
-
const absolutePath =
|
|
12249
|
-
if (!
|
|
12247
|
+
const absolutePath = path21.isAbsolute(filePath) ? filePath : path21.resolve(process.cwd(), filePath);
|
|
12248
|
+
if (!fs22.existsSync(absolutePath)) {
|
|
12250
12249
|
return `ERROR: File not found: ${filePath}`;
|
|
12251
12250
|
}
|
|
12252
|
-
const ext =
|
|
12251
|
+
const ext = path21.extname(absolutePath).slice(1).toLowerCase();
|
|
12253
12252
|
const wasmFile = EXTENSION_TO_WASM[ext];
|
|
12254
12253
|
if (!wasmFile) {
|
|
12255
12254
|
return `ERROR: Unsupported file extension: .${ext}`;
|
|
12256
12255
|
}
|
|
12257
|
-
const wasmPath =
|
|
12258
|
-
if (!
|
|
12256
|
+
const wasmPath = path21.resolve(PARSER_DIR, wasmFile);
|
|
12257
|
+
if (!fs22.existsSync(wasmPath)) {
|
|
12259
12258
|
return `ERROR: Parser for .${ext} not found. Please download it in Settings > Other.`;
|
|
12260
12259
|
}
|
|
12261
12260
|
try {
|
|
@@ -12263,9 +12262,9 @@ var init_file_map = __esm({
|
|
|
12263
12262
|
if (!isParserInitialized) {
|
|
12264
12263
|
let tsWasmPath;
|
|
12265
12264
|
try {
|
|
12266
|
-
tsWasmPath =
|
|
12265
|
+
tsWasmPath = path21.join(path21.dirname(require3.resolve("web-tree-sitter")), "tree-sitter.wasm");
|
|
12267
12266
|
} catch (e) {
|
|
12268
|
-
tsWasmPath =
|
|
12267
|
+
tsWasmPath = path21.join(process.cwd(), "node_modules", "web-tree-sitter", "tree-sitter.wasm");
|
|
12269
12268
|
}
|
|
12270
12269
|
await Parser.init({
|
|
12271
12270
|
locateFile: (p) => {
|
|
@@ -12280,7 +12279,7 @@ var init_file_map = __esm({
|
|
|
12280
12279
|
const parser = new Parser();
|
|
12281
12280
|
const Lang = await TreeSitter.Language.load(wasmPath);
|
|
12282
12281
|
parser.setLanguage(Lang);
|
|
12283
|
-
const sourceCode = await
|
|
12282
|
+
const sourceCode = await fs22.readFile(absolutePath, "utf8");
|
|
12284
12283
|
const lines = sourceCode.split("\n").length;
|
|
12285
12284
|
let maxDepth = 12;
|
|
12286
12285
|
if (lines > 1e4) maxDepth = 2;
|
|
@@ -12303,8 +12302,8 @@ Stack: ${err.stack}` : "";
|
|
|
12303
12302
|
});
|
|
12304
12303
|
|
|
12305
12304
|
// src/tools/todo.js
|
|
12306
|
-
import
|
|
12307
|
-
import
|
|
12305
|
+
import fs23 from "fs";
|
|
12306
|
+
import path22 from "path";
|
|
12308
12307
|
var todo;
|
|
12309
12308
|
var init_todo = __esm({
|
|
12310
12309
|
"src/tools/todo.js"() {
|
|
@@ -12315,8 +12314,8 @@ var init_todo = __esm({
|
|
|
12315
12314
|
const { method, tasks, markDone } = parseArgs(args);
|
|
12316
12315
|
const chatId = context.chatId || "default";
|
|
12317
12316
|
if (!method) return 'ERROR: Missing "method" argument for todo tool (create/append/get).';
|
|
12318
|
-
const todoDir =
|
|
12319
|
-
const todoFile =
|
|
12317
|
+
const todoDir = path22.join(DATA_DIR, "plan", chatId);
|
|
12318
|
+
const todoFile = path22.join(todoDir, "todo.md");
|
|
12320
12319
|
const parseMessyArray = (input) => {
|
|
12321
12320
|
if (!input || Array.isArray(input)) return input;
|
|
12322
12321
|
const trimmed = String(input).trim();
|
|
@@ -12376,8 +12375,8 @@ var init_todo = __esm({
|
|
|
12376
12375
|
};
|
|
12377
12376
|
};
|
|
12378
12377
|
try {
|
|
12379
|
-
if (!
|
|
12380
|
-
|
|
12378
|
+
if (!fs23.existsSync(todoDir)) {
|
|
12379
|
+
fs23.mkdirSync(todoDir, { recursive: true });
|
|
12381
12380
|
}
|
|
12382
12381
|
if (method === "create") {
|
|
12383
12382
|
if (!tasks) return 'ERROR: Missing "tasks" for create method.';
|
|
@@ -12389,7 +12388,7 @@ var init_todo = __esm({
|
|
|
12389
12388
|
markedCount = result.markedCount;
|
|
12390
12389
|
}
|
|
12391
12390
|
await RevertManager.recordFileChange(todoFile);
|
|
12392
|
-
|
|
12391
|
+
fs23.writeFileSync(todoFile, content, "utf8");
|
|
12393
12392
|
const total = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("- [ ]") || l.startsWith("- [x]") || l.startsWith("- [X]")).length;
|
|
12394
12393
|
if (markedCount > 0) {
|
|
12395
12394
|
const completed = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("- [x]") || l.startsWith("- [X]")).length;
|
|
@@ -12403,8 +12402,8 @@ ${content}`;
|
|
|
12403
12402
|
if (!tasks) return 'ERROR: Missing "tasks" for append method.';
|
|
12404
12403
|
const appendContent = getTasksString(tasks);
|
|
12405
12404
|
await RevertManager.recordFileChange(todoFile);
|
|
12406
|
-
|
|
12407
|
-
const fullContent =
|
|
12405
|
+
fs23.appendFileSync(todoFile, appendContent, "utf8");
|
|
12406
|
+
const fullContent = fs23.readFileSync(todoFile, "utf8");
|
|
12408
12407
|
const lines = fullContent.split(/\r?\n/).map((l) => l.trim());
|
|
12409
12408
|
const total = lines.filter((l) => l.startsWith("- [ ]") || l.startsWith("- [x]") || l.startsWith("- [X]")).length;
|
|
12410
12409
|
const completed = lines.filter((l) => l.startsWith("- [x]") || l.startsWith("- [X]")).length;
|
|
@@ -12413,10 +12412,10 @@ ${content}`;
|
|
|
12413
12412
|
${fullContent}`;
|
|
12414
12413
|
}
|
|
12415
12414
|
if (method === "get") {
|
|
12416
|
-
if (!
|
|
12415
|
+
if (!fs23.existsSync(todoFile)) {
|
|
12417
12416
|
return "TODO GET: No task list found for this session.";
|
|
12418
12417
|
}
|
|
12419
|
-
let content =
|
|
12418
|
+
let content = fs23.readFileSync(todoFile, "utf8");
|
|
12420
12419
|
let markedCount = 0;
|
|
12421
12420
|
if (markDone) {
|
|
12422
12421
|
const result = applyMarkDone(content, markDone);
|
|
@@ -12424,7 +12423,7 @@ ${fullContent}`;
|
|
|
12424
12423
|
content = result.content;
|
|
12425
12424
|
markedCount = result.markedCount;
|
|
12426
12425
|
await RevertManager.recordFileChange(todoFile);
|
|
12427
|
-
|
|
12426
|
+
fs23.writeFileSync(todoFile, content, "utf8");
|
|
12428
12427
|
}
|
|
12429
12428
|
}
|
|
12430
12429
|
const totalLines = content.split(/\r?\n/).map((l) => l.trim());
|
|
@@ -12820,20 +12819,20 @@ var init_await = __esm({
|
|
|
12820
12819
|
});
|
|
12821
12820
|
|
|
12822
12821
|
// src/utils/advanceRevert.js
|
|
12823
|
-
import
|
|
12824
|
-
import
|
|
12822
|
+
import fs24 from "fs-extra";
|
|
12823
|
+
import path23 from "path";
|
|
12825
12824
|
async function scanWorkspace(dir, baseDir = dir) {
|
|
12826
12825
|
const manifest = {};
|
|
12827
|
-
const entries = await
|
|
12826
|
+
const entries = await fs24.readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
12828
12827
|
for (const entry of entries) {
|
|
12829
12828
|
if (JUNK_DIRECTORIES.includes(entry.name)) continue;
|
|
12830
|
-
const fullPath =
|
|
12831
|
-
const relPath =
|
|
12829
|
+
const fullPath = path23.join(dir, entry.name);
|
|
12830
|
+
const relPath = path23.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
12832
12831
|
if (entry.isDirectory()) {
|
|
12833
12832
|
const sub = await scanWorkspace(fullPath, baseDir);
|
|
12834
12833
|
Object.assign(manifest, sub);
|
|
12835
12834
|
} else {
|
|
12836
|
-
const stats = await
|
|
12835
|
+
const stats = await fs24.stat(fullPath).catch(() => null);
|
|
12837
12836
|
if (stats) {
|
|
12838
12837
|
manifest[relPath] = {
|
|
12839
12838
|
size: stats.size,
|
|
@@ -12845,34 +12844,34 @@ async function scanWorkspace(dir, baseDir = dir) {
|
|
|
12845
12844
|
return manifest;
|
|
12846
12845
|
}
|
|
12847
12846
|
async function copyWorkspaceFiles(destDir, manifest) {
|
|
12848
|
-
await
|
|
12847
|
+
await fs24.ensureDir(destDir);
|
|
12849
12848
|
for (const relPath of Object.keys(manifest)) {
|
|
12850
|
-
const srcPath =
|
|
12851
|
-
const destPath =
|
|
12852
|
-
await
|
|
12853
|
-
await
|
|
12849
|
+
const srcPath = path23.join(process.cwd(), relPath);
|
|
12850
|
+
const destPath = path23.join(destDir, relPath);
|
|
12851
|
+
await fs24.ensureDir(path23.dirname(destPath));
|
|
12852
|
+
await fs24.copyFile(srcPath, destPath).catch(() => {
|
|
12854
12853
|
});
|
|
12855
12854
|
}
|
|
12856
12855
|
}
|
|
12857
12856
|
async function restoreSnapshotDir(srcDir, destDir, stats = null, baseDir = null) {
|
|
12858
|
-
if (!await
|
|
12857
|
+
if (!await fs24.pathExists(srcDir)) return;
|
|
12859
12858
|
if (!baseDir) baseDir = srcDir;
|
|
12860
|
-
const entries = await
|
|
12859
|
+
const entries = await fs24.readdir(srcDir, { withFileTypes: true }).catch(() => []);
|
|
12861
12860
|
for (const entry of entries) {
|
|
12862
|
-
const srcPath =
|
|
12863
|
-
const destPath =
|
|
12861
|
+
const srcPath = path23.join(srcDir, entry.name);
|
|
12862
|
+
const destPath = path23.join(destDir, entry.name);
|
|
12864
12863
|
if (entry.isDirectory()) {
|
|
12865
12864
|
await restoreSnapshotDir(srcPath, destPath, stats, baseDir);
|
|
12866
12865
|
} else {
|
|
12867
|
-
const relPath =
|
|
12868
|
-
const existed = await
|
|
12866
|
+
const relPath = path23.relative(baseDir, srcPath).replace(/\\/g, "/");
|
|
12867
|
+
const existed = await fs24.pathExists(destPath);
|
|
12869
12868
|
if (existed) {
|
|
12870
|
-
await
|
|
12869
|
+
await fs24.chmod(destPath, 438).catch(() => {
|
|
12871
12870
|
});
|
|
12872
12871
|
}
|
|
12873
|
-
await
|
|
12874
|
-
const ok = await
|
|
12875
|
-
await
|
|
12872
|
+
await fs24.ensureDir(path23.dirname(destPath));
|
|
12873
|
+
const ok = await fs24.copyFile(srcPath, destPath).then(() => true).catch(() => false);
|
|
12874
|
+
await fs24.chmod(destPath, 438).catch(() => {
|
|
12876
12875
|
});
|
|
12877
12876
|
if (stats) {
|
|
12878
12877
|
if (!ok) {
|
|
@@ -12910,12 +12909,12 @@ var init_advanceRevert = __esm({
|
|
|
12910
12909
|
AdvanceRevertManager = {
|
|
12911
12910
|
async takeInitialSnapshot(chatId) {
|
|
12912
12911
|
try {
|
|
12913
|
-
const snapshotsDir =
|
|
12914
|
-
await
|
|
12912
|
+
const snapshotsDir = path23.join(DATA_DIR, "snapshots", chatId);
|
|
12913
|
+
await fs24.remove(snapshotsDir).catch(() => {
|
|
12915
12914
|
});
|
|
12916
|
-
await
|
|
12915
|
+
await fs24.ensureDir(snapshotsDir);
|
|
12917
12916
|
const manifest = await scanWorkspace(process.cwd());
|
|
12918
|
-
await copyWorkspaceFiles(
|
|
12917
|
+
await copyWorkspaceFiles(path23.join(snapshotsDir, "initial"), manifest);
|
|
12919
12918
|
const ledger = readEncryptedJson(LEDGER_ADVANCE_FILE, {});
|
|
12920
12919
|
ledger[chatId] = {
|
|
12921
12920
|
initialManifest: manifest,
|
|
@@ -12964,7 +12963,7 @@ var init_advanceRevert = __esm({
|
|
|
12964
12963
|
for (const file of changedFiles) {
|
|
12965
12964
|
deltaManifest[file] = currentManifest[file];
|
|
12966
12965
|
}
|
|
12967
|
-
const turnDir =
|
|
12966
|
+
const turnDir = path23.join(DATA_DIR, "snapshots", chatId, `turn_${turnNumber}`);
|
|
12968
12967
|
await copyWorkspaceFiles(turnDir, deltaManifest);
|
|
12969
12968
|
}
|
|
12970
12969
|
session.checkpoints.push({
|
|
@@ -12998,28 +12997,28 @@ var init_advanceRevert = __esm({
|
|
|
12998
12997
|
const checkpoints = session.checkpoints || [];
|
|
12999
12998
|
const targetIdx = checkpoints.findIndex((c) => c.id === checkpointId);
|
|
13000
12999
|
if (targetIdx === -1) throw new Error(`Checkpoint [${checkpointId}] not found.`);
|
|
13001
|
-
const snapshotsDir =
|
|
13000
|
+
const snapshotsDir = path23.join(DATA_DIR, "snapshots", chatId);
|
|
13002
13001
|
const stats = { restored: 0, replaced: 0, failed: [] };
|
|
13003
13002
|
const currentFiles = await scanWorkspace(process.cwd());
|
|
13004
13003
|
for (const relPath of Object.keys(currentFiles)) {
|
|
13005
|
-
const fullPath =
|
|
13006
|
-
await
|
|
13004
|
+
const fullPath = path23.join(process.cwd(), relPath);
|
|
13005
|
+
await fs24.chmod(fullPath, 438).catch(() => {
|
|
13007
13006
|
});
|
|
13008
|
-
await
|
|
13007
|
+
await fs24.remove(fullPath).catch(() => {
|
|
13009
13008
|
});
|
|
13010
13009
|
}
|
|
13011
|
-
const initialDir =
|
|
13010
|
+
const initialDir = path23.join(snapshotsDir, "initial");
|
|
13012
13011
|
await restoreSnapshotDir(initialDir, process.cwd(), stats, initialDir);
|
|
13013
13012
|
for (let i = 1; i <= targetIdx; i++) {
|
|
13014
13013
|
const cp = checkpoints[i];
|
|
13015
|
-
const turnDir =
|
|
13014
|
+
const turnDir = path23.join(snapshotsDir, cp.id);
|
|
13016
13015
|
await restoreSnapshotDir(turnDir, process.cwd(), stats, turnDir);
|
|
13017
13016
|
if (cp.deletedFiles && cp.deletedFiles.length > 0) {
|
|
13018
13017
|
for (const delFile of cp.deletedFiles) {
|
|
13019
|
-
const fullPath =
|
|
13020
|
-
await
|
|
13018
|
+
const fullPath = path23.join(process.cwd(), delFile);
|
|
13019
|
+
await fs24.chmod(fullPath, 438).catch(() => {
|
|
13021
13020
|
});
|
|
13022
|
-
await
|
|
13021
|
+
await fs24.remove(fullPath).catch(() => {
|
|
13023
13022
|
});
|
|
13024
13023
|
}
|
|
13025
13024
|
}
|
|
@@ -13051,8 +13050,8 @@ var init_advanceRevert = __esm({
|
|
|
13051
13050
|
},
|
|
13052
13051
|
async cleanup(chatId) {
|
|
13053
13052
|
try {
|
|
13054
|
-
const snapshotsDir =
|
|
13055
|
-
await
|
|
13053
|
+
const snapshotsDir = path23.join(DATA_DIR, "snapshots", chatId);
|
|
13054
|
+
await fs24.remove(snapshotsDir).catch(() => {
|
|
13056
13055
|
});
|
|
13057
13056
|
const ledger = readEncryptedJson(LEDGER_ADVANCE_FILE, {});
|
|
13058
13057
|
if (ledger[chatId]) {
|
|
@@ -13392,14 +13391,14 @@ var init_editor = __esm({
|
|
|
13392
13391
|
});
|
|
13393
13392
|
|
|
13394
13393
|
// src/utils/getDirTree/indentation.js
|
|
13395
|
-
import
|
|
13396
|
-
import
|
|
13394
|
+
import path24 from "path";
|
|
13395
|
+
import fs25 from "fs";
|
|
13397
13396
|
var safeReaddirWithTypesDefault, getDirTreeIndentation;
|
|
13398
13397
|
var init_indentation = __esm({
|
|
13399
13398
|
"src/utils/getDirTree/indentation.js"() {
|
|
13400
13399
|
safeReaddirWithTypesDefault = (dir) => {
|
|
13401
13400
|
try {
|
|
13402
|
-
return
|
|
13401
|
+
return fs25.readdirSync(dir, { withFileTypes: true });
|
|
13403
13402
|
} catch (e) {
|
|
13404
13403
|
return [];
|
|
13405
13404
|
}
|
|
@@ -13408,7 +13407,7 @@ var init_indentation = __esm({
|
|
|
13408
13407
|
const entries = preFetchedEntries || safeReaddir(dir);
|
|
13409
13408
|
const indent = " ".repeat(depth - 1);
|
|
13410
13409
|
if (entries.length > 100) {
|
|
13411
|
-
return `${indent}${
|
|
13410
|
+
return `${indent}${path24.basename(dir)}/ (>100 files)
|
|
13412
13411
|
`;
|
|
13413
13412
|
}
|
|
13414
13413
|
let result = "";
|
|
@@ -13422,7 +13421,7 @@ var init_indentation = __esm({
|
|
|
13422
13421
|
const subDirs = filtered.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
|
|
13423
13422
|
const files = filtered.filter((e) => !e.isDirectory()).map((e) => e.name).sort();
|
|
13424
13423
|
for (const subDir of subDirs) {
|
|
13425
|
-
const filePath =
|
|
13424
|
+
const filePath = path24.join(dir, subDir.name);
|
|
13426
13425
|
if (depth > maxDepth) {
|
|
13427
13426
|
result += `${indent}${subDir.name}/ (max depth)
|
|
13428
13427
|
`;
|
|
@@ -13448,23 +13447,23 @@ var init_indentation = __esm({
|
|
|
13448
13447
|
});
|
|
13449
13448
|
|
|
13450
13449
|
// src/utils/getDirTree/box.js
|
|
13451
|
-
import
|
|
13452
|
-
import
|
|
13450
|
+
import path25 from "path";
|
|
13451
|
+
import fs26 from "fs";
|
|
13453
13452
|
var safeReaddirWithTypesDefault2, getDirTreeBox;
|
|
13454
13453
|
var init_box = __esm({
|
|
13455
13454
|
"src/utils/getDirTree/box.js"() {
|
|
13456
13455
|
safeReaddirWithTypesDefault2 = (dir) => {
|
|
13457
13456
|
try {
|
|
13458
|
-
return
|
|
13457
|
+
return fs26.readdirSync(dir, { withFileTypes: true });
|
|
13459
13458
|
} catch (e) {
|
|
13460
13459
|
return [];
|
|
13461
13460
|
}
|
|
13462
13461
|
};
|
|
13463
13462
|
getDirTreeBox = (dir, maxDepth, prefix = "", depth = 1, safeReaddir = safeReaddirWithTypesDefault2, collapsedDirs = []) => {
|
|
13464
13463
|
const entries = safeReaddir(dir);
|
|
13465
|
-
const sep =
|
|
13464
|
+
const sep = path25.sep;
|
|
13466
13465
|
if (entries.length > 100) {
|
|
13467
|
-
return `${prefix}\u2514\u2500\u2500 ${
|
|
13466
|
+
return `${prefix}\u2514\u2500\u2500 ${path25.basename(dir)}${sep} ...100+ files...
|
|
13468
13467
|
`;
|
|
13469
13468
|
}
|
|
13470
13469
|
let result = "";
|
|
@@ -13482,7 +13481,7 @@ var init_box = __esm({
|
|
|
13482
13481
|
];
|
|
13483
13482
|
finalItems.forEach((item, index) => {
|
|
13484
13483
|
const isLast = index === finalItems.length - 1;
|
|
13485
|
-
const filePath =
|
|
13484
|
+
const filePath = path25.join(dir, item.name);
|
|
13486
13485
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
13487
13486
|
const childPrefix = prefix + (isLast ? " " : "\u2502 ");
|
|
13488
13487
|
if (item.isCollapsed) {
|
|
@@ -13531,8 +13530,8 @@ __export(ai_exports, {
|
|
|
13531
13530
|
});
|
|
13532
13531
|
import dotenv from "dotenv";
|
|
13533
13532
|
import { GoogleGenAI, ThinkingLevel, HarmBlockThreshold, HarmCategory } from "@google/genai";
|
|
13534
|
-
import
|
|
13535
|
-
import
|
|
13533
|
+
import path26, { normalize } from "path";
|
|
13534
|
+
import fs27 from "fs";
|
|
13536
13535
|
var RE_STUTTER_CODE_BLOCK_CLOSED, RE_STUTTER_CODE_BLOCK_OPEN, RE_STUTTER_INLINE_CODE, RE_STUTTER_TABLE_ROW, RE_STUTTER_WORD_BOUNDARY, RE_STUTTER_NON_ALNUM, RE_TOOL_CALL_FUNC, RE_TOOL_PARTIAL_ARGS_FALLBACK, RE_STRIP_QUOTES, RE_BACKSLASH_SLASH, client, globalSettings, systemInstructionCache, colorMainWords, withRetry, TERMINATION_SIGNAL, getCleanGroupedLength, stripAnsi2, fetchWithBackoff, getDeepSeekStream, getMistralStream, getNVIDIAStream, wrapNvidiaStreamWithQueueDepth, getOpenRouterStream, signalTermination, isTerminationSignaled, TOOL_LABELS2, getToolDetail, runJanitorTask, getActiveToolContext, getContextSafeText, contextSafeReplace, getSanitizedText, translateKimiToolCalls, REGEX_PLACEHOLDER_ARG, REGEX_PLACEHOLDER_VAL, isPlaceholderVal, detectToolCalls, initAI, generateSimpleContent, consolidatePastMemories, compressHistory, deleteChatSummary, getAIStream, runSubagent;
|
|
13537
13536
|
var init_ai = __esm({
|
|
13538
13537
|
async "src/utils/ai.js"() {
|
|
@@ -14515,7 +14514,7 @@ var init_ai = __esm({
|
|
|
14515
14514
|
return pArgs.id || pArgs.taskId;
|
|
14516
14515
|
}
|
|
14517
14516
|
const filePath = pArgs.path || pArgs.targetFile || pArgs.TargetFile || pArgs.directory;
|
|
14518
|
-
return filePath ?
|
|
14517
|
+
return filePath ? path26.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/")) : null;
|
|
14519
14518
|
} catch (e) {
|
|
14520
14519
|
return null;
|
|
14521
14520
|
}
|
|
@@ -14782,9 +14781,9 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
|
|
|
14782
14781
|
}
|
|
14783
14782
|
})() : String(err);
|
|
14784
14783
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
14785
|
-
const janitorErrDir =
|
|
14786
|
-
if (!
|
|
14787
|
-
|
|
14784
|
+
const janitorErrDir = path26.join(LOGS_DIR, "janitor");
|
|
14785
|
+
if (!fs27.existsSync(janitorErrDir)) fs27.mkdirSync(janitorErrDir, { recursive: true });
|
|
14786
|
+
fs27.appendFileSync(path26.join(janitorErrDir, "error.log"), `ERROR [Attempt ${attempts}/${MAX_JANITOR_RETRIES + 1}] [${date}]: ${errLog}
|
|
14788
14787
|
|
|
14789
14788
|
`);
|
|
14790
14789
|
if (attempts > MAX_JANITOR_RETRIES) break;
|
|
@@ -14793,8 +14792,8 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
|
|
|
14793
14792
|
}
|
|
14794
14793
|
}
|
|
14795
14794
|
if (attempts) {
|
|
14796
|
-
const janitorErrDir =
|
|
14797
|
-
|
|
14795
|
+
const janitorErrDir = path26.join(LOGS_DIR, "janitor");
|
|
14796
|
+
fs27.appendFileSync(path26.join(janitorErrDir, "error.log"), `-----------------------------------------------------------------------------
|
|
14798
14797
|
|
|
14799
14798
|
`);
|
|
14800
14799
|
}
|
|
@@ -15340,10 +15339,10 @@ ${newMemoryListStr}
|
|
|
15340
15339
|
}
|
|
15341
15340
|
})() : String(err);
|
|
15342
15341
|
;
|
|
15343
|
-
const janitorLogDir =
|
|
15344
|
-
if (!
|
|
15345
|
-
|
|
15346
|
-
|
|
15342
|
+
const janitorLogDir = path26.join(LOGS_DIR, "janitor");
|
|
15343
|
+
if (!fs27.existsSync(janitorLogDir)) fs27.mkdirSync(janitorLogDir, { recursive: true });
|
|
15344
|
+
fs27.appendFileSync(
|
|
15345
|
+
path26.join(janitorLogDir, "error.log"),
|
|
15347
15346
|
`[${(/* @__PURE__ */ new Date()).toLocaleString()}] Past memory batch consolidation error: ${errLog}
|
|
15348
15347
|
`
|
|
15349
15348
|
);
|
|
@@ -15351,7 +15350,7 @@ ${newMemoryListStr}
|
|
|
15351
15350
|
};
|
|
15352
15351
|
compressHistory = async (settings, history, isAuto = false) => {
|
|
15353
15352
|
const { chatId, aiProvider = "Google" } = settings;
|
|
15354
|
-
const summariesFile =
|
|
15353
|
+
const summariesFile = path26.join(SECRET_DIR, "chat-summaries.json");
|
|
15355
15354
|
const flattenContext = (hist) => {
|
|
15356
15355
|
return hist.filter(
|
|
15357
15356
|
(m) => (m.role === "user" || m.role === "agent" || m.role === "system") && m.role !== "think" && !m.isVisualFeedback && !m.isMeta && !m.isTerminalRecord && !(m.text && m.text.includes("[TERMINAL_RECORD]")) && !String(m.id).startsWith("welcome")
|
|
@@ -15434,8 +15433,8 @@ Provide a consolidated summary of the entire session.`;
|
|
|
15434
15433
|
};
|
|
15435
15434
|
deleteChatSummary = (chatId) => {
|
|
15436
15435
|
try {
|
|
15437
|
-
const summariesFile =
|
|
15438
|
-
if (
|
|
15436
|
+
const summariesFile = path26.join(SECRET_DIR, "chat-summaries.json");
|
|
15437
|
+
if (fs27.existsSync(summariesFile)) {
|
|
15439
15438
|
const summaries = readEncryptedJson(summariesFile, {});
|
|
15440
15439
|
if (summaries[chatId]) {
|
|
15441
15440
|
delete summaries[chatId];
|
|
@@ -15451,7 +15450,7 @@ Provide a consolidated summary of the entire session.`;
|
|
|
15451
15450
|
if (!client && aiProvider === "Google") throw new Error("AI not initialized");
|
|
15452
15451
|
const isMemoryEnabled = systemSettings?.memory !== false;
|
|
15453
15452
|
const originalText = history[history.length - 1].text;
|
|
15454
|
-
const summariesFile =
|
|
15453
|
+
const summariesFile = path26.join(SECRET_DIR, "chat-summaries.json");
|
|
15455
15454
|
let wasCompressedInStream = false;
|
|
15456
15455
|
const isFirstPrompt = history.filter((m) => m.role === "user").length === 1;
|
|
15457
15456
|
const hasTitleSignal = originalText.includes("[TITLE-UPDATE]");
|
|
@@ -15703,7 +15702,7 @@ Provide a consolidated summary of the entire session.`;
|
|
|
15703
15702
|
];
|
|
15704
15703
|
const safeReaddirWithTypes = (dir) => {
|
|
15705
15704
|
try {
|
|
15706
|
-
return
|
|
15705
|
+
return fs27.readdirSync(dir, { withFileTypes: true });
|
|
15707
15706
|
} catch (e) {
|
|
15708
15707
|
return [];
|
|
15709
15708
|
}
|
|
@@ -15716,7 +15715,7 @@ Provide a consolidated summary of the entire session.`;
|
|
|
15716
15715
|
if (COLLAPSED_DIRS_GLOBAL.includes(entry.name) || entry.name.startsWith(".")) continue;
|
|
15717
15716
|
if (entry.isDirectory()) {
|
|
15718
15717
|
currentCount.value++;
|
|
15719
|
-
countFolders(
|
|
15718
|
+
countFolders(path26.join(dir, entry.name), currentCount, depth + 1);
|
|
15720
15719
|
}
|
|
15721
15720
|
}
|
|
15722
15721
|
return currentCount.value;
|
|
@@ -15782,10 +15781,10 @@ ${currentSummary}
|
|
|
15782
15781
|
if (isBridgeConnected()) {
|
|
15783
15782
|
ideBlock = "\n[ADDITIONAL IDE CONTEXT]\n";
|
|
15784
15783
|
if (ideCtx.file_focused !== "none") {
|
|
15785
|
-
const relFocused =
|
|
15784
|
+
const relFocused = path26.relative(process.cwd(), ideCtx.file_focused);
|
|
15786
15785
|
const relOpened = (ideCtx.opened_editors || []).map((p) => {
|
|
15787
|
-
const rel =
|
|
15788
|
-
return rel.startsWith("..") ? `[External] ${
|
|
15786
|
+
const rel = path26.relative(process.cwd(), p);
|
|
15787
|
+
return rel.startsWith("..") ? `[External] ${path26.basename(p)}` : rel;
|
|
15789
15788
|
});
|
|
15790
15789
|
ideBlock += `Focused File: ${relFocused}
|
|
15791
15790
|
Cursor Line: ${ideCtx.cursor_line}
|
|
@@ -15827,7 +15826,7 @@ Cursor Line: ${ideCtx.cursor_line}
|
|
|
15827
15826
|
}
|
|
15828
15827
|
const getSumForLimit = (limit, activeFiles2) => {
|
|
15829
15828
|
return activeFiles2.reduce((sum, f) => {
|
|
15830
|
-
const isFocused = ideCtx.file_focused && (f.path === ideCtx.file_focused ||
|
|
15829
|
+
const isFocused = ideCtx.file_focused && (f.path === ideCtx.file_focused || path26.resolve(process.cwd(), f.path) === path26.resolve(ideCtx.file_focused));
|
|
15831
15830
|
const fileLimit = isFocused ? Math.ceil(limit * 1.2) : limit;
|
|
15832
15831
|
return sum + Math.min(f.edits.length, fileLimit);
|
|
15833
15832
|
}, 0);
|
|
@@ -15861,7 +15860,7 @@ Cursor Line: ${ideCtx.cursor_line}
|
|
|
15861
15860
|
}
|
|
15862
15861
|
}
|
|
15863
15862
|
for (const file of activeFiles) {
|
|
15864
|
-
const isFocused = ideCtx.file_focused && (file.path === ideCtx.file_focused ||
|
|
15863
|
+
const isFocused = ideCtx.file_focused && (file.path === ideCtx.file_focused || path26.resolve(process.cwd(), file.path) === path26.resolve(ideCtx.file_focused));
|
|
15865
15864
|
const fileLimit = isFocused ? Math.ceil(chosenLimit * 1.2) : chosenLimit;
|
|
15866
15865
|
if (file.edits.length > fileLimit) {
|
|
15867
15866
|
file.edits = file.edits.slice(-fileLimit);
|
|
@@ -15948,9 +15947,9 @@ ${ideCtx.warnings}
|
|
|
15948
15947
|
endLine = matchRange[2] ? parseInt(matchRange[2], 10) : startLine;
|
|
15949
15948
|
filePath = tagClean.slice(0, matchRange.index);
|
|
15950
15949
|
}
|
|
15951
|
-
const absPath =
|
|
15952
|
-
if (
|
|
15953
|
-
const stats =
|
|
15950
|
+
const absPath = path26.resolve(process.cwd(), filePath);
|
|
15951
|
+
if (fs27.existsSync(absPath)) {
|
|
15952
|
+
const stats = fs27.statSync(absPath);
|
|
15954
15953
|
if (stats.isFile()) {
|
|
15955
15954
|
const pathLower = filePath.toLowerCase();
|
|
15956
15955
|
const isPdf = pathLower.endsWith(".pdf");
|
|
@@ -15959,7 +15958,7 @@ ${ideCtx.warnings}
|
|
|
15959
15958
|
const isMultimodalFile = isImage || isPdf || isOfficeFile;
|
|
15960
15959
|
const isSupported = aiProvider === "Google" || isModelMultimodal(modelName);
|
|
15961
15960
|
if (isMultimodalFile && !isSupported) {
|
|
15962
|
-
const label = `\u2718 Unsupported Modality: ${
|
|
15961
|
+
const label = `\u2718 Unsupported Modality: ${path26.basename(filePath)}`;
|
|
15963
15962
|
let terminalWidth = 115;
|
|
15964
15963
|
if (process.stdout.isTTY) {
|
|
15965
15964
|
terminalWidth = process.stdout.columns - 5 || 120;
|
|
@@ -15975,11 +15974,11 @@ ${ideCtx.warnings}
|
|
|
15975
15974
|
if (startLine === null && !isMultimodalFile) {
|
|
15976
15975
|
let lineCount = 0;
|
|
15977
15976
|
try {
|
|
15978
|
-
lineCount =
|
|
15977
|
+
lineCount = fs27.readFileSync(absPath, "utf8").split(/\r\n|\r|\n/).length;
|
|
15979
15978
|
} catch (e) {
|
|
15980
15979
|
}
|
|
15981
15980
|
if (lineCount > 300) {
|
|
15982
|
-
const label = `\u21B7 Skipped (Too Large): ${
|
|
15981
|
+
const label = `\u21B7 Skipped (Too Large): ${path26.basename(filePath)}`;
|
|
15983
15982
|
let terminalWidth = 115;
|
|
15984
15983
|
if (process.stdout.isTTY) {
|
|
15985
15984
|
terminalWidth = process.stdout.columns - 5 || 120;
|
|
@@ -16020,13 +16019,13 @@ ${ideCtx.warnings}
|
|
|
16020
16019
|
if (!isError) {
|
|
16021
16020
|
let label = "";
|
|
16022
16021
|
if (isImage) {
|
|
16023
|
-
label = `\u2714 Processed: ${
|
|
16022
|
+
label = `\u2714 Processed: ${path26.basename(filePath)}`;
|
|
16024
16023
|
attachedBinaryPart = binPart;
|
|
16025
16024
|
} else if (isPdf || isOfficeFile) {
|
|
16026
|
-
label = `\u2714 Auto-Analysed: ${
|
|
16025
|
+
label = `\u2714 Auto-Analysed: ${path26.basename(filePath)}`;
|
|
16027
16026
|
attachedBinaryPart = binPart;
|
|
16028
16027
|
} else {
|
|
16029
|
-
label = `\u2714 Auto-Read: ${
|
|
16028
|
+
label = `\u2714 Auto-Read: ${path26.basename(filePath)}`;
|
|
16030
16029
|
taggedContextBlocks.push(textResult);
|
|
16031
16030
|
}
|
|
16032
16031
|
if (label) {
|
|
@@ -16716,7 +16715,7 @@ ${ideErr} [/ERROR]`;
|
|
|
16716
16715
|
if (keyword !== void 0 && keyword !== null) {
|
|
16717
16716
|
detail = String(keyword).replace(RE_STRIP_QUOTES, "");
|
|
16718
16717
|
} else if (filePath) {
|
|
16719
|
-
detail =
|
|
16718
|
+
detail = path26.basename(String(filePath).replace(RE_STRIP_QUOTES, "").replace(RE_BACKSLASH_SLASH, "/"));
|
|
16720
16719
|
} else if (title && (potentialTool === "invoke" || potentialTool === "invoke_sync")) {
|
|
16721
16720
|
detail = String(title).replace(RE_STRIP_QUOTES, "").substring(0, 30);
|
|
16722
16721
|
} else if (id && potentialTool === "get_progress") {
|
|
@@ -16745,7 +16744,7 @@ ${ideErr} [/ERROR]`;
|
|
|
16745
16744
|
if (potentialTool === "invoke" || potentialTool === "invoke_sync" || potentialTool === "get_progress") {
|
|
16746
16745
|
detail = val.substring(0, 30);
|
|
16747
16746
|
} else {
|
|
16748
|
-
detail = potentialTool === "search_keyword" || potentialTool === "file_map" ? val :
|
|
16747
|
+
detail = potentialTool === "search_keyword" || potentialTool === "file_map" ? val : path26.basename(val.replace(RE_BACKSLASH_SLASH, "/"));
|
|
16749
16748
|
}
|
|
16750
16749
|
}
|
|
16751
16750
|
}
|
|
@@ -16951,9 +16950,9 @@ ${ideErr} [/ERROR]`;
|
|
|
16951
16950
|
let totalLines = "...";
|
|
16952
16951
|
let actualEndLine = eLine;
|
|
16953
16952
|
try {
|
|
16954
|
-
const absPath =
|
|
16955
|
-
if (
|
|
16956
|
-
const content =
|
|
16953
|
+
const absPath = path26.resolve(process.cwd(), targetPath2);
|
|
16954
|
+
if (fs27.existsSync(absPath)) {
|
|
16955
|
+
const content = fs27.readFileSync(absPath, "utf8");
|
|
16957
16956
|
const lines = content.split("\n").length;
|
|
16958
16957
|
totalLines = lines;
|
|
16959
16958
|
if (!rawStart && !rawEnd && lines > 800) {
|
|
@@ -16969,30 +16968,30 @@ ${ideErr} [/ERROR]`;
|
|
|
16969
16968
|
const isOfficeFile = pathLower.endsWith(".docx") || pathLower.endsWith(".doc") || pathLower.endsWith(".ppt") || pathLower.endsWith(".pptx") || pathLower.endsWith(".xls") || pathLower.endsWith(".xlsx");
|
|
16970
16969
|
const isImage = /\.(png|jpg|jpeg|webp|gif|bmp)$/.test(pathLower);
|
|
16971
16970
|
if (isPdf || isOfficeFile) {
|
|
16972
|
-
label = `${targetPath2.length > 0 ? "\u2714" : "\u2718"} ${targetPath2 ? `Analyzed: ${
|
|
16971
|
+
label = `${targetPath2.length > 0 ? "\u2714" : "\u2718"} ${targetPath2 ? `Analyzed: ${path26.basename(targetPath2)}` : "Analyzed: File Not Found"}`;
|
|
16973
16972
|
} else if (isImage) {
|
|
16974
|
-
label = `${targetPath2.length > 0 ? "\u2714" : "\u2718"} ${targetPath2 ? `Processed: ${
|
|
16973
|
+
label = `${targetPath2.length > 0 ? "\u2714" : "\u2718"} ${targetPath2 ? `Processed: ${path26.basename(targetPath2)}` : "Processed: File Not Found"}`;
|
|
16975
16974
|
} else {
|
|
16976
|
-
label = `${totalLines !== "..." ? "\u2714" : "\u2718"} Read: ${targetPath2 ? `${
|
|
16975
|
+
label = `${totalLines !== "..." ? "\u2714" : "\u2718"} Read: ${targetPath2 ? `${path26.basename(targetPath2)} \u2192 ${totalLines !== "..." ? `Lines ${sLine} - ${actualEndLine} of ${totalLines}` : "File Not Found"}` : "File Not Found"}`;
|
|
16977
16976
|
}
|
|
16978
16977
|
} else if (normToolName === "list_files" || normToolName === "read_folder") {
|
|
16979
16978
|
const action = normToolName === "list_files" ? "List" : "Browsed";
|
|
16980
|
-
const
|
|
16979
|
+
const path28 = parseArgs(toolCall.args).path || null;
|
|
16981
16980
|
const recurse = parseArgs(toolCall.args).recurse || 1;
|
|
16982
|
-
label = `${
|
|
16981
|
+
label = `${path28 ? "\u2714" : "\u2718"} ${action}: ${path28 ? `${path28 === "." ? `./${recurse > 1 ? "*" : ""}` : `${path28.replaceAll("\\", "/")}${recurse > 1 ? `${path28.endsWith("/") ? `*` : `/*`}` : `${path28.endsWith("/") ? "" : "/"}`}`}` : "No Folder Selected"}`;
|
|
16983
16982
|
} else if (normToolName === "write_file" || normToolName === "update_file") {
|
|
16984
16983
|
const action = normToolName === "write_file" ? "Created" : "Edited";
|
|
16985
|
-
const
|
|
16986
|
-
label = `${
|
|
16984
|
+
const path28 = parseArgs(toolCall.args).path || null;
|
|
16985
|
+
label = `${path28 ? "\u2714" : "\u2718"} ${action}: ${path28.replaceAll("\\", "/") || "No File Changes"}`;
|
|
16987
16986
|
} else if (normToolName === "write_pdf") {
|
|
16988
|
-
const
|
|
16989
|
-
label = `${
|
|
16987
|
+
const path28 = parseArgs(toolCall.args).path || null;
|
|
16988
|
+
label = `${path28 ? "\u2714" : "\u2718"} Generated: ${path28.replaceAll("\\", "/") || "No PDF Generated"}`;
|
|
16990
16989
|
} else if (normToolName === "write_docx") {
|
|
16991
|
-
const
|
|
16992
|
-
label = `${
|
|
16990
|
+
const path28 = parseArgs(toolCall.args).path || null;
|
|
16991
|
+
label = `${path28 ? "\u2714" : "\u2718"} Generated: ${path28.replaceAll("\\", "/") || "No Docx Generated"}`;
|
|
16993
16992
|
} else if (normToolName === "file_map") {
|
|
16994
|
-
const
|
|
16995
|
-
label = `${
|
|
16993
|
+
const path28 = parseArgs(toolCall.args).path;
|
|
16994
|
+
label = `${path28 ? "\u2714" : "\u2718"} Indexed: ${path28.replaceAll("\\", "/") ? "" + path28 : "File Not Found"}`;
|
|
16996
16995
|
} else if (normToolName.toLowerCase() === "search_keyword" || normToolName.toLowerCase() === "todo") {
|
|
16997
16996
|
label = "";
|
|
16998
16997
|
} else if (normToolName.toLowerCase() === "generate_image") {
|
|
@@ -17066,7 +17065,7 @@ ${ideErr} [/ERROR]`;
|
|
|
17066
17065
|
const { command } = parseArgs(toolCall.args);
|
|
17067
17066
|
if (command && settings.systemSettings && settings.systemSettings.allowExternalAccess === false) {
|
|
17068
17067
|
const riskyPatterns = [/[a-zA-Z]:[\\\/]/i, /^\//, /\.\.[\\\/]/, /\/etc\//, /\/var\//, /\/root\//, /\/bin\//, /\/usr\//];
|
|
17069
|
-
const currentDrive =
|
|
17068
|
+
const currentDrive = path26.resolve(process.cwd()).substring(0, 3).toLowerCase();
|
|
17070
17069
|
const splitCommands = (cmdString) => {
|
|
17071
17070
|
const commands = [];
|
|
17072
17071
|
let current = "";
|
|
@@ -17195,8 +17194,8 @@ ${ideErr} [/ERROR]`;
|
|
|
17195
17194
|
const targetPath = parsedArgs.path || parsedArgs.targetPath || null;
|
|
17196
17195
|
if (targetPath) {
|
|
17197
17196
|
const isExternalOff = settings.systemSettings && settings.systemSettings.allowExternalAccess === false;
|
|
17198
|
-
const absoluteTarget =
|
|
17199
|
-
const absoluteCwd =
|
|
17197
|
+
const absoluteTarget = path26.resolve(targetPath);
|
|
17198
|
+
const absoluteCwd = path26.resolve(process.cwd());
|
|
17200
17199
|
if (isExternalOff && !absoluteTarget.startsWith(absoluteCwd)) {
|
|
17201
17200
|
const denyMsg = `Access Denied. You are not allowed to access files outside the current workspace.`;
|
|
17202
17201
|
if (normToolName === "write_file" || normToolName === "update_file") {
|
|
@@ -17385,7 +17384,7 @@ ${ideErr} [/ERROR]`;
|
|
|
17385
17384
|
const toolArgs = parseArgs(toolCall.args);
|
|
17386
17385
|
const { path: filePath } = toolArgs;
|
|
17387
17386
|
if (filePath) {
|
|
17388
|
-
const absPath =
|
|
17387
|
+
const absPath = path26.resolve(process.cwd(), filePath);
|
|
17389
17388
|
const normalize2 = (p) => p ? p.toLowerCase().replace(/\\/g, "/").replace(/^[a-z]:/, (m) => m.toUpperCase()) : "";
|
|
17390
17389
|
const normAbsPath = normalize2(absPath);
|
|
17391
17390
|
let originalContent = "";
|
|
@@ -17395,8 +17394,8 @@ ${ideErr} [/ERROR]`;
|
|
|
17395
17394
|
if (currentIDE && normFocused === normAbsPath && currentIDE.full_content) {
|
|
17396
17395
|
originalContent = currentIDE.full_content;
|
|
17397
17396
|
hasOriginal = true;
|
|
17398
|
-
} else if (
|
|
17399
|
-
originalContent =
|
|
17397
|
+
} else if (fs27.existsSync(absPath)) {
|
|
17398
|
+
originalContent = fs27.readFileSync(absPath, "utf8");
|
|
17400
17399
|
hasOriginal = true;
|
|
17401
17400
|
}
|
|
17402
17401
|
originalContentForReporting = originalContent;
|
|
@@ -17424,9 +17423,9 @@ ${ideErr} [/ERROR]`;
|
|
|
17424
17423
|
const successes = patchResults.filter((r) => r.success);
|
|
17425
17424
|
const failures = patchResults.filter((r) => !r.success);
|
|
17426
17425
|
if (successes.length === 0) {
|
|
17427
|
-
const errorMsg = `[TOOL RESULT]: ERROR: Failed to apply patches to [${
|
|
17426
|
+
const errorMsg = `[TOOL RESULT]: ERROR: Failed to apply patches to [${path26.basename(absPath)}].
|
|
17428
17427
|
${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
|
|
17429
|
-
const errorLabel = `\u2714 Edited: ${
|
|
17428
|
+
const errorLabel = `\u2714 Edited: ${path26.basename(absPath.replaceAll("\\", "/"))}`;
|
|
17430
17429
|
let terminalWidth = 115;
|
|
17431
17430
|
if (process.stdout.isTTY) {
|
|
17432
17431
|
terminalWidth = process.stdout.columns - 5 || 120;
|
|
@@ -17443,19 +17442,19 @@ ${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
|
|
|
17443
17442
|
continue;
|
|
17444
17443
|
}
|
|
17445
17444
|
}
|
|
17446
|
-
yield { type: "status", content: `Opening Diff in IDE: ${
|
|
17445
|
+
yield { type: "status", content: `Opening Diff in IDE: ${path26.basename(absPath)}` };
|
|
17447
17446
|
showDiffInIDE(absPath, originalContent, modifiedContent);
|
|
17448
17447
|
diffOpened = true;
|
|
17449
17448
|
await new Promise((r) => setTimeout(r, 50));
|
|
17450
17449
|
} else if (normToolName === "write_file") {
|
|
17451
17450
|
const rawContent = toolArgs.content || toolArgs.newContent || "";
|
|
17452
17451
|
const modifiedContent = rawContent.endsWith("\n") ? rawContent : rawContent + "\n";
|
|
17453
|
-
if (!
|
|
17452
|
+
if (!fs27.existsSync(absPath)) {
|
|
17454
17453
|
isNewFileCreated = true;
|
|
17455
|
-
|
|
17456
|
-
|
|
17454
|
+
fs27.mkdirSync(path26.dirname(absPath), { recursive: true });
|
|
17455
|
+
fs27.writeFileSync(absPath, "", "utf8");
|
|
17457
17456
|
}
|
|
17458
|
-
yield { type: "status", content: `Opening New File Diff in IDE: ${
|
|
17457
|
+
yield { type: "status", content: `Opening New File Diff in IDE: ${path26.basename(absPath)}` };
|
|
17459
17458
|
showDiffInIDE(absPath, "", modifiedContent);
|
|
17460
17459
|
diffOpened = true;
|
|
17461
17460
|
await new Promise((r) => setTimeout(r, 50));
|
|
@@ -17491,11 +17490,11 @@ ${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
|
|
|
17491
17490
|
if (normToolName === "write_file" || normToolName === "update_file") {
|
|
17492
17491
|
const { path: filePath } = parseArgs(toolCall.args);
|
|
17493
17492
|
if (filePath) {
|
|
17494
|
-
const absPath =
|
|
17493
|
+
const absPath = path26.resolve(process.cwd(), filePath);
|
|
17495
17494
|
closeDiffInIDE(absPath, approval);
|
|
17496
|
-
if (approval === "deny" && isNewFileCreated &&
|
|
17495
|
+
if (approval === "deny" && isNewFileCreated && fs27.existsSync(absPath)) {
|
|
17497
17496
|
try {
|
|
17498
|
-
|
|
17497
|
+
fs27.unlinkSync(absPath);
|
|
17499
17498
|
} catch (e) {
|
|
17500
17499
|
}
|
|
17501
17500
|
}
|
|
@@ -17507,18 +17506,18 @@ ${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
|
|
|
17507
17506
|
}
|
|
17508
17507
|
if (approval === "allow" && diffOpened && isBridgeConnected()) {
|
|
17509
17508
|
const { path: filePath } = parseArgs(toolCall.args);
|
|
17510
|
-
const absPath =
|
|
17511
|
-
const normPath = (p) => p ?
|
|
17509
|
+
const absPath = path26.resolve(process.cwd(), filePath);
|
|
17510
|
+
const normPath = (p) => p ? path26.resolve(p).replace(/\\/g, "/").toLowerCase() : "";
|
|
17512
17511
|
const finalIDE = await getIDEContext();
|
|
17513
17512
|
let finalContent = "";
|
|
17514
17513
|
if (finalIDE && finalIDE.file_focused && normPath(finalIDE.file_focused) === normPath(absPath) && finalIDE.full_content) {
|
|
17515
17514
|
finalContent = finalIDE.full_content;
|
|
17516
17515
|
}
|
|
17517
|
-
if (!finalContent &&
|
|
17518
|
-
finalContent =
|
|
17516
|
+
if (!finalContent && fs27.existsSync(absPath)) {
|
|
17517
|
+
finalContent = fs27.readFileSync(absPath, "utf8");
|
|
17519
17518
|
if (!finalContent) {
|
|
17520
17519
|
await new Promise((r) => setTimeout(r, 100));
|
|
17521
|
-
finalContent =
|
|
17520
|
+
finalContent = fs27.readFileSync(absPath, "utf8");
|
|
17522
17521
|
}
|
|
17523
17522
|
}
|
|
17524
17523
|
const verifiedLines = finalContent.split(/\r?\n/);
|
|
@@ -17679,7 +17678,7 @@ ${snippet2}`;
|
|
|
17679
17678
|
try {
|
|
17680
17679
|
const { path: filePath } = parseArgs(toolCall.args);
|
|
17681
17680
|
if (filePath) {
|
|
17682
|
-
const absPath =
|
|
17681
|
+
const absPath = path26.resolve(process.cwd(), filePath);
|
|
17683
17682
|
const currentIDE = await getIDEContext();
|
|
17684
17683
|
if (currentIDE && currentIDE.file_focused === absPath && currentIDE.full_content) {
|
|
17685
17684
|
execToolContext.forcedContent = currentIDE.full_content;
|
|
@@ -17693,7 +17692,7 @@ ${snippet2}`;
|
|
|
17693
17692
|
if ((normToolName === "write_file" || normToolName === "update_file") && result.startsWith("SUCCESS")) {
|
|
17694
17693
|
const { path: filePath } = parseArgs(toolCall.args);
|
|
17695
17694
|
if (filePath) {
|
|
17696
|
-
const absPath =
|
|
17695
|
+
const absPath = path26.resolve(process.cwd(), filePath);
|
|
17697
17696
|
openFileInEditor(absPath);
|
|
17698
17697
|
}
|
|
17699
17698
|
}
|
|
@@ -17710,7 +17709,7 @@ ${snippet2}`;
|
|
|
17710
17709
|
result = result.text;
|
|
17711
17710
|
}
|
|
17712
17711
|
if (normToolName === "search_keyword") {
|
|
17713
|
-
const { keyword, path:
|
|
17712
|
+
const { keyword, path: path28 } = parseArgs(toolCall.args);
|
|
17714
17713
|
const _isGlob = typeof result === "string" && result.startsWith("[GLOB]");
|
|
17715
17714
|
if (_isGlob) result = result.slice(6).trimStart();
|
|
17716
17715
|
const _isDir = typeof result === "string" && result.startsWith("[DIR]");
|
|
@@ -17722,8 +17721,8 @@ ${snippet2}`;
|
|
|
17722
17721
|
matchCount = parseInt(m[1]);
|
|
17723
17722
|
}
|
|
17724
17723
|
}
|
|
17725
|
-
const _sp =
|
|
17726
|
-
const displayPath = _sp && _sp !== "." ? `"${_isGlob ?
|
|
17724
|
+
const _sp = path28 ? path28.replace(/[\/\\]+$/, "") : null;
|
|
17725
|
+
const displayPath = _sp && _sp !== "." ? `"${_isGlob ? path28 : _isDir ? `${_sp}/*` : _sp}"` : "./";
|
|
17727
17726
|
const postLabel = `${keyword ? "\u2714" : "\u2718"} Searched: "${keyword ? keyword : ""}" in ${displayPath.replaceAll("\\", "/")} \u2192 ${matchCount} Match${matchCount === 1 ? "" : "es"}`;
|
|
17728
17727
|
let terminalWidth = 115;
|
|
17729
17728
|
if (process.stdout.isTTY) {
|
|
@@ -17962,9 +17961,9 @@ ${snippet2}`;
|
|
|
17962
17961
|
})() : String(err);
|
|
17963
17962
|
;
|
|
17964
17963
|
const date = (/* @__PURE__ */ new Date()).toLocaleString();
|
|
17965
|
-
const agentErrDir =
|
|
17966
|
-
if (!
|
|
17967
|
-
|
|
17964
|
+
const agentErrDir = path26.join(LOGS_DIR, "agent");
|
|
17965
|
+
if (!fs27.existsSync(agentErrDir)) fs27.mkdirSync(agentErrDir, { recursive: true });
|
|
17966
|
+
fs27.appendFileSync(path26.join(agentErrDir, "error.log"), `ERROR [${date}]: ${errLog}
|
|
17968
17967
|
|
|
17969
17968
|
----------------------------------------------------------------------
|
|
17970
17969
|
|
|
@@ -18011,7 +18010,7 @@ ${recoveryText}`
|
|
|
18011
18010
|
yield { type: "status", content: `Error Occured. Recovering Stream...` };
|
|
18012
18011
|
} else {
|
|
18013
18012
|
throw new Error(`Stream collapsed too many times. (Failed to resolve ${MAX_RETRIES} times)
|
|
18014
|
-
Error Log can be found in ${
|
|
18013
|
+
Error Log can be found in ${path26.join(LOGS_DIR, "agent", "error.log")}`);
|
|
18015
18014
|
}
|
|
18016
18015
|
} else {
|
|
18017
18016
|
if (retryCount <= MAX_RETRIES) {
|
|
@@ -18029,7 +18028,7 @@ Error Log can be found in ${path27.join(LOGS_DIR, "agent", "error.log")}`);
|
|
|
18029
18028
|
yield { type: "status", content: `Trying to reach ${modelName}` };
|
|
18030
18029
|
} else {
|
|
18031
18030
|
throw new Error(`Model ${modelName} cannot be reached. (Failed ${MAX_RETRIES} times)
|
|
18032
|
-
Error Log can be found in ${
|
|
18031
|
+
Error Log can be found in ${path26.join(LOGS_DIR, "agent", "error.log")}`);
|
|
18033
18032
|
}
|
|
18034
18033
|
}
|
|
18035
18034
|
}
|
|
@@ -18148,10 +18147,10 @@ Error Log can be found in ${path27.join(LOGS_DIR, "agent", "error.log")}`);
|
|
|
18148
18147
|
}
|
|
18149
18148
|
})() : String(err);
|
|
18150
18149
|
const date = (/* @__PURE__ */ new Date()).toLocaleString();
|
|
18151
|
-
const agentErrDir =
|
|
18150
|
+
const agentErrDir = path26.join(LOGS_DIR, "agent");
|
|
18152
18151
|
yield { type: "text", content: `\u274C CRITICAL ERROR: ${errLog.includes("fetch failed") ? "Failed to Connect. Check your Internet Connection or Wait a moment" : errLog}` };
|
|
18153
|
-
if (!
|
|
18154
|
-
|
|
18152
|
+
if (!fs27.existsSync(agentErrDir)) fs27.mkdirSync(agentErrDir, { recursive: true });
|
|
18153
|
+
fs27.appendFileSync(path26.join(agentErrDir, "error.log"), `CRITICAL ERROR [${date}]: ${err}
|
|
18155
18154
|
|
|
18156
18155
|
----------------------------------------------------------------------
|
|
18157
18156
|
|
|
@@ -18383,25 +18382,25 @@ ${cleanResponse}
|
|
|
18383
18382
|
const keywordPath = pArgs.path || "";
|
|
18384
18383
|
label = `${keyword ? "\u2714" : "\u2718"} \x1B[95mSearched\x1B[0m: ${keyword || "No Query"}${keywordPath ? ` \u2192 ${keywordPath.replaceAll("\\", "/")}` : ""}`;
|
|
18385
18384
|
} else if (normalizedToolName === "view_file" || normalizedToolName === "viewfile" || normalizedToolName === "readfile") {
|
|
18386
|
-
const
|
|
18387
|
-
label = `\u2714 \x1B[95mRead\x1B[0m: ${
|
|
18385
|
+
const path28 = parseArgs(toolCall.args).path || "";
|
|
18386
|
+
label = `\u2714 \x1B[95mRead\x1B[0m: ${path28.replaceAll("\\", "/")}`;
|
|
18388
18387
|
} else if (normalizedToolName === "list_files" || normalizedToolName === "read_folder" || normalizedToolName === "readfolder") {
|
|
18389
|
-
const
|
|
18388
|
+
const path28 = parseArgs(toolCall.args).path || null;
|
|
18390
18389
|
const recurse = parseArgs(toolCall.args).recurse || 0;
|
|
18391
|
-
label = `${
|
|
18390
|
+
label = `${path28 ? "\u2714" : "\u2718"} \x1B[95mBrowsed\x1B[0m: ${path28 ? `${path28.replaceAll("\\", "/")}${recurse > 0 ? `${path28.endsWith("/") ? `*${recurse}` : `/*${recurse}`}` : `${path28.endsWith("/") ? "" : "/"}`}` : ""}`;
|
|
18392
18391
|
} else if (normalizedToolName === "write_file" || normalizedToolName === "writefile") {
|
|
18393
|
-
const
|
|
18394
|
-
label = `${
|
|
18392
|
+
const path28 = parseArgs(toolCall.args).path || null;
|
|
18393
|
+
label = `${path28 ? "\u2714" : "\u2718"} \x1B[95mCreated\x1B[0m: ${path28 ? `${path28.replaceAll("\\", "/")}` : "No File Changes"}`;
|
|
18395
18394
|
} else if (normalizedToolName === "update_file" || normalizedToolName === "updatefile" || normalizedToolName === "patchfile" || normalizedToolName === "patch_file" || normalizedToolName === "patchfile" || normalizedToolName === "updatefile") {
|
|
18396
|
-
const
|
|
18395
|
+
const path28 = parseArgs(toolCall.args).path || null;
|
|
18397
18396
|
const content = parseArgs(toolCall.args).content || null;
|
|
18398
|
-
label = `${
|
|
18397
|
+
label = `${path28 ? "\u2714" : "\u2718"} \x1B[95mEdited\x1B[0m: ${path28 ? `${path28.replaceAll("\\", "/")}` : "No File Changes"}`;
|
|
18399
18398
|
} else if (normalizedToolName === "exec_command" || normalizedToolName === "execcommand" || normalizedToolName === "run") {
|
|
18400
18399
|
const command = parseArgs(toolCall.args).command || null;
|
|
18401
18400
|
label = `${command ? "\u2714" : "\u2718"} \x1B[95mExecuted\x1B[0m: ${command ? command.slice(0, 100) + (command.length > 100 ? "..." : "") : "No Command"}`;
|
|
18402
18401
|
} else if (normalizedToolName === "file_map" || normalizedToolName === "filemap") {
|
|
18403
|
-
const
|
|
18404
|
-
label = `${
|
|
18402
|
+
const path28 = parseArgs(toolCall.args).path || "";
|
|
18403
|
+
label = `${path28 ? "\u2714" : "\u2718"} \x1B[95mIndexed\x1B[0m: ${path28 ? `${path28.replaceAll("\\", "/")}` : "File Not Found"}`;
|
|
18405
18404
|
} else if (normalizedToolName === "await") {
|
|
18406
18405
|
const { time: time2 } = parseArgs(toolCall.args);
|
|
18407
18406
|
let sec = parseFloat(time2) || 0;
|
|
@@ -19397,7 +19396,7 @@ var init_RevertModal = __esm({
|
|
|
19397
19396
|
import puppeteer4 from "puppeteer";
|
|
19398
19397
|
import { exec } from "child_process";
|
|
19399
19398
|
import { promisify } from "util";
|
|
19400
|
-
import
|
|
19399
|
+
import fs28 from "fs";
|
|
19401
19400
|
var execAsync, checkPuppeteerReady, installPuppeteerBrowser;
|
|
19402
19401
|
var init_setup = __esm({
|
|
19403
19402
|
"src/utils/setup.js"() {
|
|
@@ -19406,11 +19405,11 @@ var init_setup = __esm({
|
|
|
19406
19405
|
checkPuppeteerReady = () => {
|
|
19407
19406
|
try {
|
|
19408
19407
|
const pptrConfig = getPuppeteerConfig();
|
|
19409
|
-
if (pptrConfig.executablePath &&
|
|
19408
|
+
if (pptrConfig.executablePath && fs28.existsSync(pptrConfig.executablePath)) {
|
|
19410
19409
|
return true;
|
|
19411
19410
|
}
|
|
19412
19411
|
const exePath = puppeteer4.executablePath();
|
|
19413
|
-
const exists = exePath &&
|
|
19412
|
+
const exists = exePath && fs28.existsSync(exePath);
|
|
19414
19413
|
if (exists) return true;
|
|
19415
19414
|
} catch (e) {
|
|
19416
19415
|
return false;
|
|
@@ -19497,8 +19496,8 @@ __export(app_exports, {
|
|
|
19497
19496
|
import os4 from "os";
|
|
19498
19497
|
import React16, { useState as useState15, useEffect as useEffect12, useRef as useRef4, useMemo as useMemo2 } from "react";
|
|
19499
19498
|
import { Box as Box14, Text as Text16, useInput as useInput9, useStdout as useStdout2, Static } from "ink";
|
|
19500
|
-
import
|
|
19501
|
-
import
|
|
19499
|
+
import fs29 from "fs-extra";
|
|
19500
|
+
import path27 from "path";
|
|
19502
19501
|
import { exec as exec2 } from "child_process";
|
|
19503
19502
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
19504
19503
|
import TextInput4 from "ink-text-input";
|
|
@@ -19928,10 +19927,10 @@ function App({ args = [] }) {
|
|
|
19928
19927
|
const kbPath = getKeybindingsPath(ideName);
|
|
19929
19928
|
if (!kbPath) return;
|
|
19930
19929
|
try {
|
|
19931
|
-
await
|
|
19930
|
+
await fs29.ensureDir(path27.dirname(kbPath));
|
|
19932
19931
|
let bindings = [];
|
|
19933
|
-
if (
|
|
19934
|
-
const content =
|
|
19932
|
+
if (fs29.existsSync(kbPath)) {
|
|
19933
|
+
const content = fs29.readFileSync(kbPath, "utf8").trim();
|
|
19935
19934
|
if (content) {
|
|
19936
19935
|
try {
|
|
19937
19936
|
bindings = parseJsonc(content);
|
|
@@ -19951,7 +19950,7 @@ function App({ args = [] }) {
|
|
|
19951
19950
|
},
|
|
19952
19951
|
"when": "terminalFocus"
|
|
19953
19952
|
});
|
|
19954
|
-
|
|
19953
|
+
fs29.writeFileSync(kbPath, JSON.stringify(bindings, null, 4), "utf8");
|
|
19955
19954
|
cachedShortcut = "Shift + Enter";
|
|
19956
19955
|
setMessages((prev) => {
|
|
19957
19956
|
setCompletedIndex(prev.length + 1);
|
|
@@ -20686,7 +20685,7 @@ function App({ args = [] }) {
|
|
|
20686
20685
|
useEffect12(() => {
|
|
20687
20686
|
async function init() {
|
|
20688
20687
|
try {
|
|
20689
|
-
const pkg = JSON.parse(
|
|
20688
|
+
const pkg = JSON.parse(fs29.readFileSync(path27.join(process.cwd(), "package.json"), "utf8"));
|
|
20690
20689
|
initBridge(versionFluxflow || pkg.version || "2.0.0");
|
|
20691
20690
|
} catch (e) {
|
|
20692
20691
|
initBridge("2.0.0");
|
|
@@ -20800,7 +20799,7 @@ function App({ args = [] }) {
|
|
|
20800
20799
|
if (!parsedArgs.playground) {
|
|
20801
20800
|
deleteChat(PLAYGROUND_CHAT_ID).catch(() => {
|
|
20802
20801
|
});
|
|
20803
|
-
|
|
20802
|
+
fs29.remove(path27.join(DATA_DIR, "playground")).catch(() => {
|
|
20804
20803
|
});
|
|
20805
20804
|
}
|
|
20806
20805
|
performVersionCheck(false, freshSettings);
|
|
@@ -20834,9 +20833,9 @@ function App({ args = [] }) {
|
|
|
20834
20833
|
}
|
|
20835
20834
|
}
|
|
20836
20835
|
if (parsedArgs.playground) {
|
|
20837
|
-
const playgroundDir =
|
|
20836
|
+
const playgroundDir = path27.join(DATA_DIR, "playground");
|
|
20838
20837
|
try {
|
|
20839
|
-
|
|
20838
|
+
fs29.ensureDirSync(playgroundDir);
|
|
20840
20839
|
process.chdir(playgroundDir);
|
|
20841
20840
|
} catch (e) {
|
|
20842
20841
|
}
|
|
@@ -20877,8 +20876,8 @@ function App({ args = [] }) {
|
|
|
20877
20876
|
if (kbPath) {
|
|
20878
20877
|
try {
|
|
20879
20878
|
let bindings = [];
|
|
20880
|
-
if (
|
|
20881
|
-
const content =
|
|
20879
|
+
if (fs29.existsSync(kbPath)) {
|
|
20880
|
+
const content = fs29.readFileSync(kbPath, "utf8").trim();
|
|
20882
20881
|
if (content) {
|
|
20883
20882
|
bindings = parseJsonc(content);
|
|
20884
20883
|
}
|
|
@@ -21257,22 +21256,22 @@ ${cleanText}`, color: "magenta" }];
|
|
|
21257
21256
|
});
|
|
21258
21257
|
break;
|
|
21259
21258
|
}
|
|
21260
|
-
const src =
|
|
21261
|
-
const dest =
|
|
21259
|
+
const src = path27.join(DATA_DIR, "playground");
|
|
21260
|
+
const dest = path27.join(parsedArgs.originalCwd, "playground-export");
|
|
21262
21261
|
const moveFiles = async () => {
|
|
21263
21262
|
try {
|
|
21264
21263
|
setMessages((prev) => {
|
|
21265
21264
|
setCompletedIndex(prev.length + 1);
|
|
21266
21265
|
return [...prev, { id: Date.now(), role: "system", text: `[PLAYGROUND] Exporting playground content to ${dest}`, isMeta: true }];
|
|
21267
21266
|
});
|
|
21268
|
-
await
|
|
21267
|
+
await fs29.ensureDir(dest);
|
|
21269
21268
|
const excludeDirs = ["node_modules", ".git", ".venv", "venv", "env", ".next", "dist", "build", ".cache"];
|
|
21270
|
-
await
|
|
21269
|
+
await fs29.copy(src, dest, {
|
|
21271
21270
|
overwrite: true,
|
|
21272
21271
|
filter: (srcPath) => {
|
|
21273
|
-
const relative =
|
|
21272
|
+
const relative = path27.relative(src, srcPath);
|
|
21274
21273
|
if (!relative) return true;
|
|
21275
|
-
const parts2 = relative.split(
|
|
21274
|
+
const parts2 = relative.split(path27.sep);
|
|
21276
21275
|
return !parts2.some((part) => excludeDirs.includes(part));
|
|
21277
21276
|
}
|
|
21278
21277
|
});
|
|
@@ -21334,7 +21333,7 @@ ${cleanText}`, color: "magenta" }];
|
|
|
21334
21333
|
}
|
|
21335
21334
|
}
|
|
21336
21335
|
setTimeout(() => {
|
|
21337
|
-
|
|
21336
|
+
fs29.emptyDir(path27.join(DATA_DIR, "playground")).catch((err) => {
|
|
21338
21337
|
setMessages((prev) => {
|
|
21339
21338
|
const newMsgs = [...prev, {
|
|
21340
21339
|
id: "playground-" + Date.now(),
|
|
@@ -21724,12 +21723,12 @@ ${list || "No saved chats found."}`, isMeta: true }];
|
|
|
21724
21723
|
setCompletedIndex(prev.length + 1);
|
|
21725
21724
|
return [...prev, { id: Date.now(), role: "system", text: "[NUCLEAR] Initiating reset...", isMeta: true }];
|
|
21726
21725
|
});
|
|
21727
|
-
if (
|
|
21728
|
-
if (
|
|
21729
|
-
if (
|
|
21726
|
+
if (fs29.existsSync(LOGS_DIR)) fs29.removeSync(LOGS_DIR);
|
|
21727
|
+
if (fs29.existsSync(SECRET_DIR)) fs29.removeSync(SECRET_DIR);
|
|
21728
|
+
if (fs29.existsSync(SETTINGS_FILE)) fs29.removeSync(SETTINGS_FILE);
|
|
21730
21729
|
try {
|
|
21731
|
-
const items =
|
|
21732
|
-
if (items.length === 0)
|
|
21730
|
+
const items = fs29.readdirSync(FLUXFLOW_DIR);
|
|
21731
|
+
if (items.length === 0) fs29.removeSync(FLUXFLOW_DIR);
|
|
21733
21732
|
} catch (e) {
|
|
21734
21733
|
}
|
|
21735
21734
|
setTimeout(() => {
|
|
@@ -21851,15 +21850,15 @@ ${list || "No saved chats found."}`, isMeta: true }];
|
|
|
21851
21850
|
# SKILLS & WORKFLOWS
|
|
21852
21851
|
- [Define custom step-by-step recipes for this project here]
|
|
21853
21852
|
`;
|
|
21854
|
-
const filePath =
|
|
21855
|
-
if (
|
|
21853
|
+
const filePath = path27.join(process.cwd(), "FluxFlow.md");
|
|
21854
|
+
if (fs29.pathExistsSync(filePath)) {
|
|
21856
21855
|
setMessages((prev) => {
|
|
21857
21856
|
setCompletedIndex(prev.length + 1);
|
|
21858
21857
|
return [...prev, { id: "init-err-" + Date.now(), role: "system", text: "ERROR: FluxFlow.md already exists in this directory.", isMeta: true }];
|
|
21859
21858
|
});
|
|
21860
21859
|
} else {
|
|
21861
21860
|
try {
|
|
21862
|
-
|
|
21861
|
+
fs29.writeFileSync(filePath, template);
|
|
21863
21862
|
setMessages((prev) => {
|
|
21864
21863
|
setCompletedIndex(prev.length + 1);
|
|
21865
21864
|
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 }];
|
|
@@ -21973,19 +21972,19 @@ ${list || "No saved chats found."}`, isMeta: true }];
|
|
|
21973
21972
|
if (!fullTextStr.startsWith("[TOOL RESULT]:")) {
|
|
21974
21973
|
return m;
|
|
21975
21974
|
}
|
|
21976
|
-
if (fullTextStr.startsWith("[TOOL RESULT]: ERROR") || fullTextStr.startsWith("[TOOL RESULT]: DENIED") || fullTextStr.includes("...Result Truncated by System on User
|
|
21975
|
+
if (fullTextStr.startsWith("[TOOL RESULT]: ERROR") || fullTextStr.startsWith("[TOOL RESULT]: DENIED") || fullTextStr.includes("...Result Truncated by System on User Command")) {
|
|
21977
21976
|
return m;
|
|
21978
21977
|
}
|
|
21979
21978
|
truncatedCount++;
|
|
21980
21979
|
if (fullTextStr.startsWith("[TOOL RESULT]: SUCCESS")) {
|
|
21981
21980
|
return {
|
|
21982
21981
|
...m,
|
|
21983
|
-
fullText: "[TOOL RESULT]: SUCCESS: ...Result Truncated by System on User
|
|
21982
|
+
fullText: "[TOOL RESULT]: SUCCESS: ...Result Truncated by System on User Command"
|
|
21984
21983
|
};
|
|
21985
21984
|
}
|
|
21986
21985
|
return {
|
|
21987
21986
|
...m,
|
|
21988
|
-
fullText: "[TOOL RESULT]: ...Result Truncated by System on User
|
|
21987
|
+
fullText: "[TOOL RESULT]: ...Result Truncated by System on User Command"
|
|
21989
21988
|
};
|
|
21990
21989
|
});
|
|
21991
21990
|
const finalMsgs = [...updatedMessages, {
|
|
@@ -24238,11 +24237,11 @@ var init_app = __esm({
|
|
|
24238
24237
|
if (process.platform === "win32") {
|
|
24239
24238
|
const appData = process.env.APPDATA;
|
|
24240
24239
|
if (!appData) return null;
|
|
24241
|
-
return
|
|
24240
|
+
return path27.join(appData, dirName, "User", "keybindings.json");
|
|
24242
24241
|
} else if (process.platform === "darwin") {
|
|
24243
|
-
return
|
|
24242
|
+
return path27.join(home, "Library", "Application Support", dirName, "User", "keybindings.json");
|
|
24244
24243
|
} else {
|
|
24245
|
-
return
|
|
24244
|
+
return path27.join(home, ".config", dirName, "User", "keybindings.json");
|
|
24246
24245
|
}
|
|
24247
24246
|
};
|
|
24248
24247
|
parseJsonc = (content) => {
|
|
@@ -24286,8 +24285,8 @@ var init_app = __esm({
|
|
|
24286
24285
|
SESSION_START_TIME = Date.now();
|
|
24287
24286
|
CHANGELOG_URL = "https://fluxflow-cli.onrender.com/changelog";
|
|
24288
24287
|
DOCS_URL = "https://fluxflow-cli.onrender.com/";
|
|
24289
|
-
packageJsonPath =
|
|
24290
|
-
packageJson = JSON.parse(
|
|
24288
|
+
packageJsonPath = path27.join(path27.dirname(fileURLToPath3(import.meta.url)), "../package.json");
|
|
24289
|
+
packageJson = JSON.parse(fs29.readFileSync(packageJsonPath, "utf8"));
|
|
24291
24290
|
versionFluxflow = packageJson.version;
|
|
24292
24291
|
updatedOn = packageJson.date || "2026-05-20";
|
|
24293
24292
|
ResolutionModal = ({ data, onResolve, onEdit, theme = "Dark" }) => {
|
|
@@ -24321,20 +24320,20 @@ var init_app = __esm({
|
|
|
24321
24320
|
const scan = (currentDir) => {
|
|
24322
24321
|
if (fileList.length >= 2e3) return;
|
|
24323
24322
|
try {
|
|
24324
|
-
const files =
|
|
24323
|
+
const files = fs29.readdirSync(currentDir);
|
|
24325
24324
|
for (const file of files) {
|
|
24326
24325
|
if (fileList.length >= 2e3) return;
|
|
24327
24326
|
if (["node_modules", ".git", ".gemini", "dist", "build", ".next", ".cache", "out"].includes(file)) {
|
|
24328
24327
|
continue;
|
|
24329
24328
|
}
|
|
24330
|
-
const filePath =
|
|
24331
|
-
const stat =
|
|
24329
|
+
const filePath = path27.join(currentDir, file);
|
|
24330
|
+
const stat = fs29.statSync(filePath);
|
|
24332
24331
|
if (stat.isDirectory()) {
|
|
24333
24332
|
scan(filePath);
|
|
24334
24333
|
} else {
|
|
24335
24334
|
fileList.push({
|
|
24336
24335
|
name: flattenString(file),
|
|
24337
|
-
relativePath: flattenString(
|
|
24336
|
+
relativePath: flattenString(path27.relative(process.cwd(), filePath))
|
|
24338
24337
|
});
|
|
24339
24338
|
}
|
|
24340
24339
|
}
|
|
@@ -24534,11 +24533,11 @@ if (isBundled && !process.execArgv.some((arg) => arg.includes("max-old-space-siz
|
|
|
24534
24533
|
const isUpdate = args[0] === "--update";
|
|
24535
24534
|
const isExport = args[0] === "--export";
|
|
24536
24535
|
if (isVersion || isHelp || isHelpCommands || isUpdate || isExport) {
|
|
24537
|
-
const
|
|
24538
|
-
const
|
|
24536
|
+
const fs30 = await import("fs");
|
|
24537
|
+
const path28 = await import("path");
|
|
24539
24538
|
const { fileURLToPath: fileURLToPath5 } = await import("url");
|
|
24540
|
-
const packageJsonPath2 =
|
|
24541
|
-
const packageJson2 = JSON.parse(
|
|
24539
|
+
const packageJsonPath2 = path28.join(path28.dirname(fileURLToPath5(import.meta.url)), "../package.json");
|
|
24540
|
+
const packageJson2 = JSON.parse(fs30.readFileSync(packageJsonPath2, "utf8"));
|
|
24542
24541
|
const versionFluxflow2 = packageJson2.version;
|
|
24543
24542
|
if (isExport) {
|
|
24544
24543
|
const subArg = (args[1] || "").toLowerCase();
|