snow-ai 0.5.19 → 0.5.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.
- package/bundle/cli.mjs +1400 -1349
- package/bundle/package.json +1 -1
- package/package.json +1 -1
package/bundle/cli.mjs
CHANGED
|
@@ -28457,7 +28457,7 @@ var require_extension = __commonJS({
|
|
|
28457
28457
|
var require_websocket = __commonJS({
|
|
28458
28458
|
"node_modules/ws/lib/websocket.js"(exports2, module2) {
|
|
28459
28459
|
"use strict";
|
|
28460
|
-
var
|
|
28460
|
+
var EventEmitter10 = __require("events");
|
|
28461
28461
|
var https2 = __require("https");
|
|
28462
28462
|
var http2 = __require("http");
|
|
28463
28463
|
var net = __require("net");
|
|
@@ -28489,7 +28489,7 @@ var require_websocket = __commonJS({
|
|
|
28489
28489
|
var protocolVersions = [8, 13];
|
|
28490
28490
|
var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
28491
28491
|
var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
28492
|
-
var WebSocket3 = class _WebSocket extends
|
|
28492
|
+
var WebSocket3 = class _WebSocket extends EventEmitter10 {
|
|
28493
28493
|
/**
|
|
28494
28494
|
* Create a new `WebSocket`.
|
|
28495
28495
|
*
|
|
@@ -29483,7 +29483,7 @@ var require_subprotocol = __commonJS({
|
|
|
29483
29483
|
var require_websocket_server = __commonJS({
|
|
29484
29484
|
"node_modules/ws/lib/websocket-server.js"(exports2, module2) {
|
|
29485
29485
|
"use strict";
|
|
29486
|
-
var
|
|
29486
|
+
var EventEmitter10 = __require("events");
|
|
29487
29487
|
var http2 = __require("http");
|
|
29488
29488
|
var { Duplex } = __require("stream");
|
|
29489
29489
|
var { createHash: createHash3 } = __require("crypto");
|
|
@@ -29496,7 +29496,7 @@ var require_websocket_server = __commonJS({
|
|
|
29496
29496
|
var RUNNING = 0;
|
|
29497
29497
|
var CLOSING = 1;
|
|
29498
29498
|
var CLOSED = 2;
|
|
29499
|
-
var WebSocketServer2 = class extends
|
|
29499
|
+
var WebSocketServer2 = class extends EventEmitter10 {
|
|
29500
29500
|
/**
|
|
29501
29501
|
* Create a `WebSocketServer` instance.
|
|
29502
29502
|
*
|
|
@@ -33349,6 +33349,32 @@ var init_build2 = __esm({
|
|
|
33349
33349
|
}
|
|
33350
33350
|
});
|
|
33351
33351
|
|
|
33352
|
+
// dist/utils/ui/updateNotice.js
|
|
33353
|
+
import { EventEmitter as EventEmitter3 } from "events";
|
|
33354
|
+
function setUpdateNotice(notice) {
|
|
33355
|
+
currentNotice = notice ? { ...notice, checkedAt: Date.now() } : null;
|
|
33356
|
+
updateNoticeEmitter.emit(UPDATE_NOTICE_EVENT, currentNotice);
|
|
33357
|
+
}
|
|
33358
|
+
function getUpdateNotice() {
|
|
33359
|
+
return currentNotice;
|
|
33360
|
+
}
|
|
33361
|
+
function onUpdateNotice(handler) {
|
|
33362
|
+
updateNoticeEmitter.on(UPDATE_NOTICE_EVENT, handler);
|
|
33363
|
+
return () => {
|
|
33364
|
+
updateNoticeEmitter.off(UPDATE_NOTICE_EVENT, handler);
|
|
33365
|
+
};
|
|
33366
|
+
}
|
|
33367
|
+
var UPDATE_NOTICE_EVENT, updateNoticeEmitter, currentNotice;
|
|
33368
|
+
var init_updateNotice = __esm({
|
|
33369
|
+
"dist/utils/ui/updateNotice.js"() {
|
|
33370
|
+
"use strict";
|
|
33371
|
+
UPDATE_NOTICE_EVENT = "update-notice";
|
|
33372
|
+
updateNoticeEmitter = new EventEmitter3();
|
|
33373
|
+
updateNoticeEmitter.setMaxListeners(20);
|
|
33374
|
+
currentNotice = null;
|
|
33375
|
+
}
|
|
33376
|
+
});
|
|
33377
|
+
|
|
33352
33378
|
// node_modules/ink-spinner/node_modules/cli-spinners/spinners.json
|
|
33353
33379
|
var require_spinners = __commonJS({
|
|
33354
33380
|
"node_modules/ink-spinner/node_modules/cli-spinners/spinners.json"(exports2, module2) {
|
|
@@ -50507,10 +50533,10 @@ var require_wrap_handler = __commonJS({
|
|
|
50507
50533
|
var require_dispatcher = __commonJS({
|
|
50508
50534
|
"node_modules/undici/lib/dispatcher/dispatcher.js"(exports2, module2) {
|
|
50509
50535
|
"use strict";
|
|
50510
|
-
var
|
|
50536
|
+
var EventEmitter10 = __require("node:events");
|
|
50511
50537
|
var WrapHandler = require_wrap_handler();
|
|
50512
50538
|
var wrapInterceptor = (dispatch) => (opts, handler) => dispatch(opts, WrapHandler.wrap(handler));
|
|
50513
|
-
var Dispatcher = class extends
|
|
50539
|
+
var Dispatcher = class extends EventEmitter10 {
|
|
50514
50540
|
dispatch() {
|
|
50515
50541
|
throw new Error("not implemented");
|
|
50516
50542
|
}
|
|
@@ -60380,11 +60406,11 @@ var require_snapshot_recorder = __commonJS({
|
|
|
60380
60406
|
caseSensitive = false
|
|
60381
60407
|
} = matchOptions;
|
|
60382
60408
|
const filtered = {};
|
|
60383
|
-
const { ignore:
|
|
60409
|
+
const { ignore: ignore2, exclude, match: match2 } = headerFilters;
|
|
60384
60410
|
for (const [key, value] of Object.entries(headers)) {
|
|
60385
60411
|
const headerKey = caseSensitive ? key : key.toLowerCase();
|
|
60386
60412
|
if (exclude.has(headerKey)) continue;
|
|
60387
|
-
if (
|
|
60413
|
+
if (ignore2.has(headerKey)) continue;
|
|
60388
60414
|
if (match2.size !== 0) {
|
|
60389
60415
|
if (!match2.has(headerKey)) continue;
|
|
60390
60416
|
}
|
|
@@ -62913,9 +62939,9 @@ var require_memory_cache_store = __commonJS({
|
|
|
62913
62939
|
"node_modules/undici/lib/cache/memory-cache-store.js"(exports2, module2) {
|
|
62914
62940
|
"use strict";
|
|
62915
62941
|
var { Writable } = __require("node:stream");
|
|
62916
|
-
var { EventEmitter:
|
|
62942
|
+
var { EventEmitter: EventEmitter10 } = __require("node:events");
|
|
62917
62943
|
var { assertCacheKey, assertCacheValue } = require_cache();
|
|
62918
|
-
var MemoryCacheStore = class extends
|
|
62944
|
+
var MemoryCacheStore = class extends EventEmitter10 {
|
|
62919
62945
|
#maxCount = 1024;
|
|
62920
62946
|
#maxSize = 104857600;
|
|
62921
62947
|
// 100MB
|
|
@@ -80978,6 +81004,11 @@ var init_en = __esm({
|
|
|
80978
81004
|
themeSettingsInfo: "Configure theme and preview DiffViewer",
|
|
80979
81005
|
hooksSettings: "Hooks Settings",
|
|
80980
81006
|
hooksSettingsInfo: "Configure hooks for customizing AI workflow",
|
|
81007
|
+
updateNoticeTitle: "Update available",
|
|
81008
|
+
updateNoticeCurrent: "Current",
|
|
81009
|
+
updateNoticeLatest: "Latest",
|
|
81010
|
+
updateNoticeRun: "Run",
|
|
81011
|
+
updateNoticeGithub: "GitHub",
|
|
80981
81012
|
exit: "Exit",
|
|
80982
81013
|
exitInfo: "Exit the application"
|
|
80983
81014
|
},
|
|
@@ -81885,6 +81916,11 @@ var init_zh = __esm({
|
|
|
81885
81916
|
themeSettingsInfo: "\u914D\u7F6E\u4E3B\u9898\u5E76\u9884\u89C8\u5DEE\u5F02\u67E5\u770B\u5668",
|
|
81886
81917
|
hooksSettings: "Hooks \u8BBE\u7F6E",
|
|
81887
81918
|
hooksSettingsInfo: "\u914D\u7F6E Hooks \u4EE5\u81EA\u5B9A\u4E49 AI \u5DE5\u4F5C\u6D41",
|
|
81919
|
+
updateNoticeTitle: "\u53D1\u73B0\u65B0\u7248\u672C",
|
|
81920
|
+
updateNoticeCurrent: "\u5F53\u524D\u7248\u672C",
|
|
81921
|
+
updateNoticeLatest: "\u6700\u65B0\u7248\u672C",
|
|
81922
|
+
updateNoticeRun: "\u66F4\u65B0\u547D\u4EE4",
|
|
81923
|
+
updateNoticeGithub: "\u9879\u76EE\u5730\u5740",
|
|
81888
81924
|
exit: "\u9000\u51FA",
|
|
81889
81925
|
exitInfo: "\u9000\u51FA\u5E94\u7528\u7A0B\u5E8F"
|
|
81890
81926
|
},
|
|
@@ -82792,6 +82828,11 @@ var init_zh_TW = __esm({
|
|
|
82792
82828
|
themeSettingsInfo: "\u8A2D\u5B9A\u4E3B\u984C\u4E26\u9810\u89BD\u5DEE\u7570\u6AA2\u8996\u5668",
|
|
82793
82829
|
hooksSettings: "Hooks \u8A2D\u5B9A",
|
|
82794
82830
|
hooksSettingsInfo: "\u8A2D\u5B9A Hooks \u4EE5\u81EA\u8A02 AI \u5DE5\u4F5C\u6D41\u7A0B",
|
|
82831
|
+
updateNoticeTitle: "\u6709\u65B0\u7248\u672C\u53EF\u7528",
|
|
82832
|
+
updateNoticeCurrent: "\u76EE\u524D\u7248\u672C",
|
|
82833
|
+
updateNoticeLatest: "\u6700\u65B0\u7248\u672C",
|
|
82834
|
+
updateNoticeRun: "\u66F4\u65B0\u6307\u4EE4",
|
|
82835
|
+
updateNoticeGithub: "\u5C08\u6848\u7DB2\u5740",
|
|
82795
82836
|
exit: "\u9000\u51FA",
|
|
82796
82837
|
exitInfo: "\u9000\u51FA\u61C9\u7528\u7A0B\u5F0F"
|
|
82797
82838
|
},
|
|
@@ -83694,6 +83735,11 @@ var init_ja = __esm({
|
|
|
83694
83735
|
themeSettingsInfo: "\u30C6\u30FC\u30DE\u3092\u8A2D\u5B9A\u3057\u3066\u5DEE\u5206\u30D3\u30E5\u30FC\u30EF\u30FC\u3092\u30D7\u30EC\u30D3\u30E5\u30FC",
|
|
83695
83736
|
hooksSettings: "Hooks\u8A2D\u5B9A",
|
|
83696
83737
|
hooksSettingsInfo: "AI\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u3092\u30AB\u30B9\u30BF\u30DE\u30A4\u30BA\u3059\u308B\u305F\u3081\u306EHooks\u3092\u8A2D\u5B9A",
|
|
83738
|
+
updateNoticeTitle: "\u66F4\u65B0\u304C\u5229\u7528\u53EF\u80FD\u3067\u3059",
|
|
83739
|
+
updateNoticeCurrent: "\u73FE\u5728",
|
|
83740
|
+
updateNoticeLatest: "\u6700\u65B0",
|
|
83741
|
+
updateNoticeRun: "\u5B9F\u884C",
|
|
83742
|
+
updateNoticeGithub: "GitHub",
|
|
83697
83743
|
exit: "\u7D42\u4E86",
|
|
83698
83744
|
exitInfo: "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3092\u7D42\u4E86"
|
|
83699
83745
|
},
|
|
@@ -84596,6 +84642,11 @@ var init_ko = __esm({
|
|
|
84596
84642
|
themeSettingsInfo: "\uD14C\uB9C8\uB97C \uAD6C\uC131\uD558\uACE0 \uCC28\uC774\uC810 \uBDF0\uC5B4\uB97C \uBBF8\uB9AC \uBCF4\uAE30",
|
|
84597
84643
|
hooksSettings: "Hooks \uC124\uC815",
|
|
84598
84644
|
hooksSettingsInfo: "AI \uC6CC\uD06C\uD50C\uB85C\uC6B0\uB97C \uC0AC\uC6A9\uC790 \uC815\uC758\uD558\uAE30 \uC704\uD55C Hooks \uAD6C\uC131",
|
|
84645
|
+
updateNoticeTitle: "\uC5C5\uB370\uC774\uD2B8\uAC00 \uC788\uC2B5\uB2C8\uB2E4",
|
|
84646
|
+
updateNoticeCurrent: "\uD604\uC7AC",
|
|
84647
|
+
updateNoticeLatest: "\uCD5C\uC2E0",
|
|
84648
|
+
updateNoticeRun: "\uC2E4\uD589",
|
|
84649
|
+
updateNoticeGithub: "GitHub",
|
|
84599
84650
|
exit: "\uC885\uB8CC",
|
|
84600
84651
|
exitInfo: "\uC560\uD50C\uB9AC\uCF00\uC774\uC158 \uC885\uB8CC"
|
|
84601
84652
|
},
|
|
@@ -85498,6 +85549,11 @@ var init_es = __esm({
|
|
|
85498
85549
|
themeSettingsInfo: "Configurar tema y vista previa del visor de diferencias",
|
|
85499
85550
|
hooksSettings: "Configuraci\xF3n de Hooks",
|
|
85500
85551
|
hooksSettingsInfo: "Configurar hooks para personalizar el flujo de trabajo de IA",
|
|
85552
|
+
updateNoticeTitle: "Actualizaci\xF3n disponible",
|
|
85553
|
+
updateNoticeCurrent: "Actual",
|
|
85554
|
+
updateNoticeLatest: "\xDAltima",
|
|
85555
|
+
updateNoticeRun: "Ejecuta",
|
|
85556
|
+
updateNoticeGithub: "GitHub",
|
|
85501
85557
|
exit: "Salir",
|
|
85502
85558
|
exitInfo: "Salir de la aplicaci\xF3n"
|
|
85503
85559
|
},
|
|
@@ -86532,7 +86588,7 @@ var init_useGlobalExit = __esm({
|
|
|
86532
86588
|
});
|
|
86533
86589
|
|
|
86534
86590
|
// dist/hooks/integration/useGlobalNavigation.js
|
|
86535
|
-
import { EventEmitter as
|
|
86591
|
+
import { EventEmitter as EventEmitter4 } from "events";
|
|
86536
86592
|
function navigateTo(destination) {
|
|
86537
86593
|
navigationEmitter.emit(NAVIGATION_EVENT, { destination });
|
|
86538
86594
|
}
|
|
@@ -86546,7 +86602,7 @@ var navigationEmitter, NAVIGATION_EVENT;
|
|
|
86546
86602
|
var init_useGlobalNavigation = __esm({
|
|
86547
86603
|
"dist/hooks/integration/useGlobalNavigation.js"() {
|
|
86548
86604
|
"use strict";
|
|
86549
|
-
navigationEmitter = new
|
|
86605
|
+
navigationEmitter = new EventEmitter4();
|
|
86550
86606
|
navigationEmitter.setMaxListeners(20);
|
|
86551
86607
|
NAVIGATION_EVENT = "navigate";
|
|
86552
86608
|
}
|
|
@@ -236029,7 +236085,7 @@ ${fromBody}`;
|
|
|
236029
236085
|
"src/common/create-ignorer.js"(exports22, module22) {
|
|
236030
236086
|
"use strict";
|
|
236031
236087
|
var path49 = __require("path");
|
|
236032
|
-
var
|
|
236088
|
+
var ignore2 = require_ignore2().default;
|
|
236033
236089
|
var getFileContentOrNull = require_get_file_content_or_null();
|
|
236034
236090
|
async function createIgnorer(ignorePath, withNodeModules) {
|
|
236035
236091
|
const ignoreContent = ignorePath ? await getFileContentOrNull(path49.resolve(ignorePath)) : null;
|
|
@@ -236040,7 +236096,7 @@ ${fromBody}`;
|
|
|
236040
236096
|
return _createIgnorer(ignoreContent, withNodeModules);
|
|
236041
236097
|
};
|
|
236042
236098
|
function _createIgnorer(ignoreContent, withNodeModules) {
|
|
236043
|
-
const ignorer =
|
|
236099
|
+
const ignorer = ignore2({
|
|
236044
236100
|
allowRelativePaths: true
|
|
236045
236101
|
}).add(ignoreContent || "");
|
|
236046
236102
|
if (!withNodeModules) {
|
|
@@ -236833,8 +236889,8 @@ ${fromBody}`;
|
|
|
236833
236889
|
return utils2.pattern.getPositivePatterns(patterns);
|
|
236834
236890
|
}
|
|
236835
236891
|
exports22.getPositivePatterns = getPositivePatterns;
|
|
236836
|
-
function getNegativePatternsAsPositive(patterns,
|
|
236837
|
-
const negative = utils2.pattern.getNegativePatterns(patterns).concat(
|
|
236892
|
+
function getNegativePatternsAsPositive(patterns, ignore2) {
|
|
236893
|
+
const negative = utils2.pattern.getNegativePatterns(patterns).concat(ignore2);
|
|
236838
236894
|
const positive = negative.map(utils2.pattern.convertToPositivePattern);
|
|
236839
236895
|
return positive;
|
|
236840
236896
|
}
|
|
@@ -259452,7 +259508,7 @@ var require_util9 = __commonJS({
|
|
|
259452
259508
|
function markAsOriginatingFromRejection(e) {
|
|
259453
259509
|
try {
|
|
259454
259510
|
notEnumerableProp(e, "isOperational", true);
|
|
259455
|
-
} catch (
|
|
259511
|
+
} catch (ignore2) {
|
|
259456
259512
|
}
|
|
259457
259513
|
}
|
|
259458
259514
|
function originatesFromRejection(e) {
|
|
@@ -259489,7 +259545,7 @@ var require_util9 = __commonJS({
|
|
|
259489
259545
|
if (filter3(key)) {
|
|
259490
259546
|
try {
|
|
259491
259547
|
es5.defineProperty(to, key, es5.getDescriptor(from2, key));
|
|
259492
|
-
} catch (
|
|
259548
|
+
} catch (ignore2) {
|
|
259493
259549
|
}
|
|
259494
259550
|
}
|
|
259495
259551
|
}
|
|
@@ -353111,6 +353167,345 @@ var init_notebookManager = __esm({
|
|
|
353111
353167
|
}
|
|
353112
353168
|
});
|
|
353113
353169
|
|
|
353170
|
+
// dist/utils/codebase/conversationContext.js
|
|
353171
|
+
var conversationContext_exports = {};
|
|
353172
|
+
__export(conversationContext_exports, {
|
|
353173
|
+
clearConversationContext: () => clearConversationContext,
|
|
353174
|
+
getConversationContext: () => getConversationContext,
|
|
353175
|
+
setConversationContext: () => setConversationContext
|
|
353176
|
+
});
|
|
353177
|
+
function setConversationContext(sessionId, messageIndex) {
|
|
353178
|
+
currentSessionId = sessionId;
|
|
353179
|
+
currentMessageIndex = messageIndex;
|
|
353180
|
+
}
|
|
353181
|
+
function getConversationContext() {
|
|
353182
|
+
if (currentSessionId !== void 0 && currentMessageIndex !== void 0) {
|
|
353183
|
+
return { sessionId: currentSessionId, messageIndex: currentMessageIndex };
|
|
353184
|
+
}
|
|
353185
|
+
return void 0;
|
|
353186
|
+
}
|
|
353187
|
+
function clearConversationContext() {
|
|
353188
|
+
currentSessionId = void 0;
|
|
353189
|
+
currentMessageIndex = void 0;
|
|
353190
|
+
}
|
|
353191
|
+
var currentSessionId, currentMessageIndex;
|
|
353192
|
+
var init_conversationContext = __esm({
|
|
353193
|
+
"dist/utils/codebase/conversationContext.js"() {
|
|
353194
|
+
"use strict";
|
|
353195
|
+
}
|
|
353196
|
+
});
|
|
353197
|
+
|
|
353198
|
+
// dist/utils/session/projectUtils.js
|
|
353199
|
+
import path17 from "path";
|
|
353200
|
+
import crypto3 from "crypto";
|
|
353201
|
+
function getProjectId(projectPath) {
|
|
353202
|
+
const cwd2 = projectPath || process.cwd();
|
|
353203
|
+
const dirName = path17.basename(cwd2);
|
|
353204
|
+
const pathHash = crypto3.createHash("sha256").update(cwd2).digest("hex").slice(0, 6);
|
|
353205
|
+
const safeDirName = sanitizeProjectName(dirName);
|
|
353206
|
+
return `${safeDirName}-${pathHash}`;
|
|
353207
|
+
}
|
|
353208
|
+
function getProjectPath() {
|
|
353209
|
+
return process.cwd();
|
|
353210
|
+
}
|
|
353211
|
+
function sanitizeProjectName(name) {
|
|
353212
|
+
return name.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_").replace(/\s+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").slice(0, 100);
|
|
353213
|
+
}
|
|
353214
|
+
function formatDateCompact(date) {
|
|
353215
|
+
const year = date.getFullYear();
|
|
353216
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
353217
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
353218
|
+
return `${year}${month}${day}`;
|
|
353219
|
+
}
|
|
353220
|
+
function isDateFolder(folderName) {
|
|
353221
|
+
return /^\d{4}-?\d{2}-?\d{2}$/.test(folderName);
|
|
353222
|
+
}
|
|
353223
|
+
function isProjectFolder(folderName) {
|
|
353224
|
+
return /^.+-[a-f0-9]{6}$/.test(folderName);
|
|
353225
|
+
}
|
|
353226
|
+
var init_projectUtils = __esm({
|
|
353227
|
+
"dist/utils/session/projectUtils.js"() {
|
|
353228
|
+
"use strict";
|
|
353229
|
+
}
|
|
353230
|
+
});
|
|
353231
|
+
|
|
353232
|
+
// dist/utils/codebase/hashBasedSnapshot.js
|
|
353233
|
+
var hashBasedSnapshot_exports = {};
|
|
353234
|
+
__export(hashBasedSnapshot_exports, {
|
|
353235
|
+
hashBasedSnapshotManager: () => hashBasedSnapshotManager
|
|
353236
|
+
});
|
|
353237
|
+
import fs16 from "fs/promises";
|
|
353238
|
+
import path18 from "path";
|
|
353239
|
+
import os8 from "os";
|
|
353240
|
+
import crypto4 from "crypto";
|
|
353241
|
+
var HashBasedSnapshotManager, hashBasedSnapshotManager;
|
|
353242
|
+
var init_hashBasedSnapshot = __esm({
|
|
353243
|
+
"dist/utils/codebase/hashBasedSnapshot.js"() {
|
|
353244
|
+
"use strict";
|
|
353245
|
+
init_logger();
|
|
353246
|
+
init_projectUtils();
|
|
353247
|
+
HashBasedSnapshotManager = class {
|
|
353248
|
+
constructor() {
|
|
353249
|
+
Object.defineProperty(this, "snapshotsDir", {
|
|
353250
|
+
enumerable: true,
|
|
353251
|
+
configurable: true,
|
|
353252
|
+
writable: true,
|
|
353253
|
+
value: void 0
|
|
353254
|
+
});
|
|
353255
|
+
const projectId = getProjectId();
|
|
353256
|
+
this.snapshotsDir = path18.join(os8.homedir(), ".snow", "snapshots", projectId);
|
|
353257
|
+
}
|
|
353258
|
+
/**
|
|
353259
|
+
* Ensure snapshots directory exists
|
|
353260
|
+
*/
|
|
353261
|
+
async ensureSnapshotsDir() {
|
|
353262
|
+
await fs16.mkdir(this.snapshotsDir, { recursive: true });
|
|
353263
|
+
}
|
|
353264
|
+
/**
|
|
353265
|
+
* Get snapshot file path
|
|
353266
|
+
*/
|
|
353267
|
+
getSnapshotPath(sessionId, messageIndex) {
|
|
353268
|
+
return path18.join(this.snapshotsDir, `${sessionId}_${messageIndex}.json`);
|
|
353269
|
+
}
|
|
353270
|
+
/**
|
|
353271
|
+
* Backup a file before modification or creation
|
|
353272
|
+
* @param sessionId Current session ID
|
|
353273
|
+
* @param messageIndex Current message index
|
|
353274
|
+
* @param filePath File path (relative to workspace root)
|
|
353275
|
+
* @param workspaceRoot Workspace root directory
|
|
353276
|
+
* @param existed Whether the file existed before (false for new files)
|
|
353277
|
+
* @param originalContent Original file content (undefined for new files)
|
|
353278
|
+
*/
|
|
353279
|
+
async backupFile(sessionId, messageIndex, filePath, workspaceRoot, existed, originalContent) {
|
|
353280
|
+
try {
|
|
353281
|
+
logger.info(`[Snapshot] backupFile called: sessionId=${sessionId}, messageIndex=${messageIndex}, filePath=${filePath}, existed=${existed}`);
|
|
353282
|
+
await this.ensureSnapshotsDir();
|
|
353283
|
+
const snapshotPath = this.getSnapshotPath(sessionId, messageIndex);
|
|
353284
|
+
logger.info(`[Snapshot] snapshotPath=${snapshotPath}`);
|
|
353285
|
+
const relativePath = path18.isAbsolute(filePath) ? path18.relative(workspaceRoot, filePath) : filePath;
|
|
353286
|
+
const backup = {
|
|
353287
|
+
path: relativePath,
|
|
353288
|
+
content: existed ? originalContent ?? null : null,
|
|
353289
|
+
existed,
|
|
353290
|
+
hash: originalContent ? crypto4.createHash("sha256").update(originalContent).digest("hex") : ""
|
|
353291
|
+
};
|
|
353292
|
+
let metadata;
|
|
353293
|
+
try {
|
|
353294
|
+
const content = await fs16.readFile(snapshotPath, "utf-8");
|
|
353295
|
+
metadata = JSON.parse(content);
|
|
353296
|
+
} catch {
|
|
353297
|
+
metadata = {
|
|
353298
|
+
sessionId,
|
|
353299
|
+
messageIndex,
|
|
353300
|
+
timestamp: Date.now(),
|
|
353301
|
+
workspaceRoot,
|
|
353302
|
+
backups: []
|
|
353303
|
+
};
|
|
353304
|
+
}
|
|
353305
|
+
const existingBackupIndex = metadata.backups.findIndex((b) => b.path === relativePath);
|
|
353306
|
+
if (existingBackupIndex === -1) {
|
|
353307
|
+
metadata.backups.push(backup);
|
|
353308
|
+
await this.saveSnapshotMetadata(metadata);
|
|
353309
|
+
logger.info(`[Snapshot] Backed up file ${relativePath} for session ${sessionId} message ${messageIndex}`);
|
|
353310
|
+
}
|
|
353311
|
+
} catch (error) {
|
|
353312
|
+
logger.warn(`[Snapshot] Failed to backup file ${filePath}:`, error);
|
|
353313
|
+
}
|
|
353314
|
+
}
|
|
353315
|
+
/**
|
|
353316
|
+
* Remove a specific file backup from snapshot (for failed operations)
|
|
353317
|
+
* @param sessionId Current session ID
|
|
353318
|
+
* @param messageIndex Current message index
|
|
353319
|
+
* @param filePath File path to remove from backup
|
|
353320
|
+
*/
|
|
353321
|
+
async removeFileBackup(sessionId, messageIndex, filePath, workspaceRoot) {
|
|
353322
|
+
try {
|
|
353323
|
+
const snapshotPath = this.getSnapshotPath(sessionId, messageIndex);
|
|
353324
|
+
try {
|
|
353325
|
+
const content = await fs16.readFile(snapshotPath, "utf-8");
|
|
353326
|
+
const metadata = JSON.parse(content);
|
|
353327
|
+
const relativePath = path18.isAbsolute(filePath) ? path18.relative(workspaceRoot, filePath) : filePath;
|
|
353328
|
+
const originalLength = metadata.backups.length;
|
|
353329
|
+
metadata.backups = metadata.backups.filter((b) => b.path !== relativePath);
|
|
353330
|
+
if (metadata.backups.length < originalLength) {
|
|
353331
|
+
if (metadata.backups.length === 0) {
|
|
353332
|
+
await fs16.unlink(snapshotPath);
|
|
353333
|
+
logger.info(`[Snapshot] Deleted empty snapshot ${sessionId}_${messageIndex}`);
|
|
353334
|
+
} else {
|
|
353335
|
+
await this.saveSnapshotMetadata(metadata);
|
|
353336
|
+
logger.info(`[Snapshot] Removed backup for ${relativePath} from snapshot ${sessionId}_${messageIndex}`);
|
|
353337
|
+
}
|
|
353338
|
+
}
|
|
353339
|
+
} catch (error) {
|
|
353340
|
+
}
|
|
353341
|
+
} catch (error) {
|
|
353342
|
+
logger.warn(`[Snapshot] Failed to remove file backup ${filePath}:`, error);
|
|
353343
|
+
}
|
|
353344
|
+
}
|
|
353345
|
+
/**
|
|
353346
|
+
* Save snapshot to disk
|
|
353347
|
+
*/
|
|
353348
|
+
async saveSnapshotMetadata(metadata) {
|
|
353349
|
+
await this.ensureSnapshotsDir();
|
|
353350
|
+
const snapshotPath = this.getSnapshotPath(metadata.sessionId, metadata.messageIndex);
|
|
353351
|
+
await fs16.writeFile(snapshotPath, JSON.stringify(metadata, null, 2));
|
|
353352
|
+
}
|
|
353353
|
+
/**
|
|
353354
|
+
* List all snapshots for a session
|
|
353355
|
+
*/
|
|
353356
|
+
async listSnapshots(sessionId) {
|
|
353357
|
+
await this.ensureSnapshotsDir();
|
|
353358
|
+
const snapshots = [];
|
|
353359
|
+
try {
|
|
353360
|
+
const files = await fs16.readdir(this.snapshotsDir);
|
|
353361
|
+
for (const file of files) {
|
|
353362
|
+
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
353363
|
+
const snapshotPath = path18.join(this.snapshotsDir, file);
|
|
353364
|
+
const content = await fs16.readFile(snapshotPath, "utf-8");
|
|
353365
|
+
const metadata = JSON.parse(content);
|
|
353366
|
+
snapshots.push({
|
|
353367
|
+
messageIndex: metadata.messageIndex,
|
|
353368
|
+
timestamp: metadata.timestamp,
|
|
353369
|
+
fileCount: metadata.backups.length
|
|
353370
|
+
});
|
|
353371
|
+
}
|
|
353372
|
+
}
|
|
353373
|
+
} catch (error) {
|
|
353374
|
+
logger.error("Failed to list snapshots:", error);
|
|
353375
|
+
}
|
|
353376
|
+
return snapshots.sort((a, b) => b.messageIndex - a.messageIndex);
|
|
353377
|
+
}
|
|
353378
|
+
/**
|
|
353379
|
+
* Get list of files affected by rollback
|
|
353380
|
+
*/
|
|
353381
|
+
async getFilesToRollback(sessionId, targetMessageIndex) {
|
|
353382
|
+
await this.ensureSnapshotsDir();
|
|
353383
|
+
try {
|
|
353384
|
+
const files = await fs16.readdir(this.snapshotsDir);
|
|
353385
|
+
const filesToRollback = /* @__PURE__ */ new Set();
|
|
353386
|
+
for (const file of files) {
|
|
353387
|
+
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
353388
|
+
const snapshotPath = path18.join(this.snapshotsDir, file);
|
|
353389
|
+
const content = await fs16.readFile(snapshotPath, "utf-8");
|
|
353390
|
+
const metadata = JSON.parse(content);
|
|
353391
|
+
if (metadata.messageIndex >= targetMessageIndex) {
|
|
353392
|
+
for (const backup of metadata.backups) {
|
|
353393
|
+
filesToRollback.add(backup.path);
|
|
353394
|
+
}
|
|
353395
|
+
}
|
|
353396
|
+
}
|
|
353397
|
+
}
|
|
353398
|
+
return Array.from(filesToRollback).sort();
|
|
353399
|
+
} catch (error) {
|
|
353400
|
+
logger.error("Failed to get files to rollback:", error);
|
|
353401
|
+
return [];
|
|
353402
|
+
}
|
|
353403
|
+
}
|
|
353404
|
+
/**
|
|
353405
|
+
* Rollback to a specific message index
|
|
353406
|
+
* Uses streaming approach to minimize memory usage
|
|
353407
|
+
*/
|
|
353408
|
+
async rollbackToMessageIndex(sessionId, targetMessageIndex, selectedFiles) {
|
|
353409
|
+
await this.ensureSnapshotsDir();
|
|
353410
|
+
try {
|
|
353411
|
+
const files = await fs16.readdir(this.snapshotsDir);
|
|
353412
|
+
const snapshotFiles = [];
|
|
353413
|
+
for (const file of files) {
|
|
353414
|
+
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
353415
|
+
const snapshotPath = path18.join(this.snapshotsDir, file);
|
|
353416
|
+
const content = await fs16.readFile(snapshotPath, "utf-8");
|
|
353417
|
+
const metadata = JSON.parse(content);
|
|
353418
|
+
if (metadata.messageIndex >= targetMessageIndex) {
|
|
353419
|
+
snapshotFiles.push({
|
|
353420
|
+
messageIndex: metadata.messageIndex,
|
|
353421
|
+
path: snapshotPath
|
|
353422
|
+
});
|
|
353423
|
+
}
|
|
353424
|
+
}
|
|
353425
|
+
}
|
|
353426
|
+
snapshotFiles.sort((a, b) => b.messageIndex - a.messageIndex);
|
|
353427
|
+
let totalFilesRolledBack = 0;
|
|
353428
|
+
for (const snapshotFile of snapshotFiles) {
|
|
353429
|
+
const content = await fs16.readFile(snapshotFile.path, "utf-8");
|
|
353430
|
+
const metadata = JSON.parse(content);
|
|
353431
|
+
for (const backup of metadata.backups) {
|
|
353432
|
+
if (selectedFiles && selectedFiles.length > 0 && !selectedFiles.includes(backup.path)) {
|
|
353433
|
+
continue;
|
|
353434
|
+
}
|
|
353435
|
+
const fullPath = path18.join(metadata.workspaceRoot, backup.path);
|
|
353436
|
+
try {
|
|
353437
|
+
if (backup.existed && backup.content !== null) {
|
|
353438
|
+
await fs16.writeFile(fullPath, backup.content, "utf-8");
|
|
353439
|
+
totalFilesRolledBack++;
|
|
353440
|
+
} else if (!backup.existed) {
|
|
353441
|
+
try {
|
|
353442
|
+
await fs16.unlink(fullPath);
|
|
353443
|
+
totalFilesRolledBack++;
|
|
353444
|
+
} catch {
|
|
353445
|
+
}
|
|
353446
|
+
}
|
|
353447
|
+
} catch (error) {
|
|
353448
|
+
logger.error(`Failed to restore file ${backup.path}:`, error);
|
|
353449
|
+
}
|
|
353450
|
+
}
|
|
353451
|
+
}
|
|
353452
|
+
return totalFilesRolledBack;
|
|
353453
|
+
} catch (error) {
|
|
353454
|
+
logger.error("Failed to rollback to message index:", error);
|
|
353455
|
+
return 0;
|
|
353456
|
+
}
|
|
353457
|
+
}
|
|
353458
|
+
/**
|
|
353459
|
+
* Delete snapshots from a specific message index onwards
|
|
353460
|
+
*/
|
|
353461
|
+
async deleteSnapshotsFromIndex(sessionId, targetMessageIndex) {
|
|
353462
|
+
await this.ensureSnapshotsDir();
|
|
353463
|
+
try {
|
|
353464
|
+
const files = await fs16.readdir(this.snapshotsDir);
|
|
353465
|
+
let deletedCount = 0;
|
|
353466
|
+
for (const file of files) {
|
|
353467
|
+
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
353468
|
+
const snapshotPath = path18.join(this.snapshotsDir, file);
|
|
353469
|
+
const content = await fs16.readFile(snapshotPath, "utf-8");
|
|
353470
|
+
const metadata = JSON.parse(content);
|
|
353471
|
+
if (metadata.messageIndex >= targetMessageIndex) {
|
|
353472
|
+
try {
|
|
353473
|
+
await fs16.unlink(snapshotPath);
|
|
353474
|
+
deletedCount++;
|
|
353475
|
+
} catch (error) {
|
|
353476
|
+
logger.error(`Failed to delete snapshot file ${snapshotPath}:`, error);
|
|
353477
|
+
}
|
|
353478
|
+
}
|
|
353479
|
+
}
|
|
353480
|
+
}
|
|
353481
|
+
return deletedCount;
|
|
353482
|
+
} catch (error) {
|
|
353483
|
+
logger.error("Failed to delete snapshots from index:", error);
|
|
353484
|
+
return 0;
|
|
353485
|
+
}
|
|
353486
|
+
}
|
|
353487
|
+
/**
|
|
353488
|
+
* Clear all snapshots for a session
|
|
353489
|
+
*/
|
|
353490
|
+
async clearAllSnapshots(sessionId) {
|
|
353491
|
+
await this.ensureSnapshotsDir();
|
|
353492
|
+
try {
|
|
353493
|
+
const files = await fs16.readdir(this.snapshotsDir);
|
|
353494
|
+
for (const file of files) {
|
|
353495
|
+
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
353496
|
+
const filePath = path18.join(this.snapshotsDir, file);
|
|
353497
|
+
await fs16.unlink(filePath);
|
|
353498
|
+
}
|
|
353499
|
+
}
|
|
353500
|
+
} catch (error) {
|
|
353501
|
+
logger.error("Failed to clear snapshots:", error);
|
|
353502
|
+
}
|
|
353503
|
+
}
|
|
353504
|
+
};
|
|
353505
|
+
hashBasedSnapshotManager = new HashBasedSnapshotManager();
|
|
353506
|
+
}
|
|
353507
|
+
});
|
|
353508
|
+
|
|
353114
353509
|
// dist/mcp/filesystem.js
|
|
353115
353510
|
var filesystem_exports = {};
|
|
353116
353511
|
__export(filesystem_exports, {
|
|
@@ -353118,8 +353513,8 @@ __export(filesystem_exports, {
|
|
|
353118
353513
|
filesystemService: () => filesystemService,
|
|
353119
353514
|
mcpTools: () => mcpTools
|
|
353120
353515
|
});
|
|
353121
|
-
import { promises as
|
|
353122
|
-
import * as
|
|
353516
|
+
import { promises as fs17 } from "fs";
|
|
353517
|
+
import * as path19 from "path";
|
|
353123
353518
|
var prettier, resolve4, dirname6, isAbsolute3, extname3, FilesystemMCPService, filesystemService, mcpTools;
|
|
353124
353519
|
var init_filesystem = __esm({
|
|
353125
353520
|
"dist/mcp/filesystem.js"() {
|
|
@@ -353136,7 +353531,7 @@ var init_filesystem = __esm({
|
|
|
353136
353531
|
init_office_parser_utils();
|
|
353137
353532
|
init_symbol_utils();
|
|
353138
353533
|
init_notebookManager();
|
|
353139
|
-
({ resolve: resolve4, dirname: dirname6, isAbsolute: isAbsolute3, extname: extname3 } =
|
|
353534
|
+
({ resolve: resolve4, dirname: dirname6, isAbsolute: isAbsolute3, extname: extname3 } = path19);
|
|
353140
353535
|
FilesystemMCPService = class {
|
|
353141
353536
|
constructor(basePath = process.cwd()) {
|
|
353142
353537
|
Object.defineProperty(this, "basePath", {
|
|
@@ -353212,7 +353607,7 @@ var init_filesystem = __esm({
|
|
|
353212
353607
|
if (ext === ".svg") {
|
|
353213
353608
|
try {
|
|
353214
353609
|
const sharp = (await import("sharp")).default;
|
|
353215
|
-
const buffer2 = await
|
|
353610
|
+
const buffer2 = await fs17.readFile(fullPath);
|
|
353216
353611
|
const pngBuffer = await sharp(buffer2).png().toBuffer();
|
|
353217
353612
|
const base64Data2 = pngBuffer.toString("base64");
|
|
353218
353613
|
return {
|
|
@@ -353222,7 +353617,7 @@ var init_filesystem = __esm({
|
|
|
353222
353617
|
// Return as PNG
|
|
353223
353618
|
};
|
|
353224
353619
|
} catch (svgError) {
|
|
353225
|
-
const buffer2 = await
|
|
353620
|
+
const buffer2 = await fs17.readFile(fullPath);
|
|
353226
353621
|
const base64Data2 = buffer2.toString("base64");
|
|
353227
353622
|
return {
|
|
353228
353623
|
type: "image",
|
|
@@ -353231,7 +353626,7 @@ var init_filesystem = __esm({
|
|
|
353231
353626
|
};
|
|
353232
353627
|
}
|
|
353233
353628
|
}
|
|
353234
|
-
const buffer = await
|
|
353629
|
+
const buffer = await fs17.readFile(fullPath);
|
|
353235
353630
|
const base64Data = buffer.toString("base64");
|
|
353236
353631
|
return {
|
|
353237
353632
|
type: "image",
|
|
@@ -353354,7 +353749,7 @@ ${exportList}`);
|
|
|
353354
353749
|
if (!isAbsolute3(file)) {
|
|
353355
353750
|
await this.validatePath(fullPath2);
|
|
353356
353751
|
}
|
|
353357
|
-
const stats2 = await
|
|
353752
|
+
const stats2 = await fs17.stat(fullPath2);
|
|
353358
353753
|
if (stats2.isDirectory()) {
|
|
353359
353754
|
const dirFiles = await this.listFiles(file);
|
|
353360
353755
|
const fileList = dirFiles.join("\n");
|
|
@@ -353403,7 +353798,7 @@ ${fileList}`
|
|
|
353403
353798
|
continue;
|
|
353404
353799
|
}
|
|
353405
353800
|
}
|
|
353406
|
-
const content2 = await
|
|
353801
|
+
const content2 = await fs17.readFile(fullPath2, "utf-8");
|
|
353407
353802
|
const lines2 = content2.split("\n");
|
|
353408
353803
|
const totalLines2 = lines2.length;
|
|
353409
353804
|
const actualStartLine2 = fileStartLine ?? 1;
|
|
@@ -353474,7 +353869,7 @@ ${numberedLines3.join("\n")}`;
|
|
|
353474
353869
|
if (!isAbsolute3(filePath)) {
|
|
353475
353870
|
await this.validatePath(fullPath);
|
|
353476
353871
|
}
|
|
353477
|
-
const stats = await
|
|
353872
|
+
const stats = await fs17.stat(fullPath);
|
|
353478
353873
|
if (stats.isDirectory()) {
|
|
353479
353874
|
const files = await this.listFiles(filePath);
|
|
353480
353875
|
const fileList = files.join("\n");
|
|
@@ -353520,7 +353915,7 @@ ${fileList}`,
|
|
|
353520
353915
|
};
|
|
353521
353916
|
}
|
|
353522
353917
|
}
|
|
353523
|
-
const content = await
|
|
353918
|
+
const content = await fs17.readFile(fullPath, "utf-8");
|
|
353524
353919
|
const lines = content.split("\n");
|
|
353525
353920
|
const totalLines = lines.length;
|
|
353526
353921
|
const actualStartLine = startLine ?? 1;
|
|
@@ -353563,7 +353958,7 @@ ${fileList}`,
|
|
|
353563
353958
|
if (fixedPath && fixedPath !== filePath) {
|
|
353564
353959
|
const fixedFullPath = this.resolvePath(fixedPath);
|
|
353565
353960
|
try {
|
|
353566
|
-
await
|
|
353961
|
+
await fs17.access(fixedFullPath);
|
|
353567
353962
|
throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}
|
|
353568
353963
|
\u{1F4A1} Tip: File not found. Did you mean "${fixedPath}"? Please use the correct path.`);
|
|
353569
353964
|
} catch {
|
|
@@ -353585,18 +353980,35 @@ ${fileList}`,
|
|
|
353585
353980
|
try {
|
|
353586
353981
|
const fullPath = this.resolvePath(filePath);
|
|
353587
353982
|
try {
|
|
353588
|
-
await
|
|
353983
|
+
await fs17.access(fullPath);
|
|
353589
353984
|
throw new Error(`File already exists: ${filePath}`);
|
|
353590
353985
|
} catch (error) {
|
|
353591
353986
|
if (error.code !== "ENOENT") {
|
|
353592
353987
|
throw error;
|
|
353593
353988
|
}
|
|
353594
353989
|
}
|
|
353990
|
+
try {
|
|
353991
|
+
const { getConversationContext: getConversationContext2 } = await Promise.resolve().then(() => (init_conversationContext(), conversationContext_exports));
|
|
353992
|
+
const context2 = getConversationContext2();
|
|
353993
|
+
if (context2) {
|
|
353994
|
+
const { hashBasedSnapshotManager: hashBasedSnapshotManager2 } = await Promise.resolve().then(() => (init_hashBasedSnapshot(), hashBasedSnapshot_exports));
|
|
353995
|
+
await hashBasedSnapshotManager2.backupFile(
|
|
353996
|
+
context2.sessionId,
|
|
353997
|
+
context2.messageIndex,
|
|
353998
|
+
filePath,
|
|
353999
|
+
this.basePath,
|
|
354000
|
+
false,
|
|
354001
|
+
// File didn't exist
|
|
354002
|
+
void 0
|
|
354003
|
+
);
|
|
354004
|
+
}
|
|
354005
|
+
} catch (backupError) {
|
|
354006
|
+
}
|
|
353595
354007
|
if (createDirectories) {
|
|
353596
354008
|
const dir = dirname6(fullPath);
|
|
353597
|
-
await
|
|
354009
|
+
await fs17.mkdir(dir, { recursive: true });
|
|
353598
354010
|
}
|
|
353599
|
-
await
|
|
354011
|
+
await fs17.writeFile(fullPath, content, "utf-8");
|
|
353600
354012
|
return `File created successfully: ${filePath}`;
|
|
353601
354013
|
} catch (error) {
|
|
353602
354014
|
throw new Error(`Failed to create file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -353615,11 +354027,11 @@ ${fileList}`,
|
|
|
353615
354027
|
if (!isAbsolute3(dirPath)) {
|
|
353616
354028
|
await this.validatePath(fullPath);
|
|
353617
354029
|
}
|
|
353618
|
-
const stats = await
|
|
354030
|
+
const stats = await fs17.stat(fullPath);
|
|
353619
354031
|
if (!stats.isDirectory()) {
|
|
353620
354032
|
throw new Error(`Path is not a directory: ${dirPath}`);
|
|
353621
354033
|
}
|
|
353622
|
-
const files = await
|
|
354034
|
+
const files = await fs17.readdir(fullPath);
|
|
353623
354035
|
return files;
|
|
353624
354036
|
} catch (error) {
|
|
353625
354037
|
throw new Error(`Failed to list files in ${dirPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -353633,7 +354045,7 @@ ${fileList}`,
|
|
|
353633
354045
|
async exists(filePath) {
|
|
353634
354046
|
try {
|
|
353635
354047
|
const fullPath = this.resolvePath(filePath);
|
|
353636
|
-
await
|
|
354048
|
+
await fs17.access(fullPath);
|
|
353637
354049
|
return true;
|
|
353638
354050
|
} catch {
|
|
353639
354051
|
return false;
|
|
@@ -353649,7 +354061,7 @@ ${fileList}`,
|
|
|
353649
354061
|
try {
|
|
353650
354062
|
const fullPath = this.resolvePath(filePath);
|
|
353651
354063
|
await this.validatePath(fullPath);
|
|
353652
|
-
const stats = await
|
|
354064
|
+
const stats = await fs17.stat(fullPath);
|
|
353653
354065
|
return {
|
|
353654
354066
|
size: stats.size,
|
|
353655
354067
|
isFile: stats.isFile(),
|
|
@@ -353695,8 +354107,25 @@ ${fileList}`,
|
|
|
353695
354107
|
if (!isAbsolute3(filePath)) {
|
|
353696
354108
|
await this.validatePath(fullPath);
|
|
353697
354109
|
}
|
|
353698
|
-
const content = await
|
|
354110
|
+
const content = await fs17.readFile(fullPath, "utf-8");
|
|
353699
354111
|
const lines = content.split("\n");
|
|
354112
|
+
try {
|
|
354113
|
+
const { getConversationContext: getConversationContext2 } = await Promise.resolve().then(() => (init_conversationContext(), conversationContext_exports));
|
|
354114
|
+
const context2 = getConversationContext2();
|
|
354115
|
+
if (context2) {
|
|
354116
|
+
const { hashBasedSnapshotManager: hashBasedSnapshotManager2 } = await Promise.resolve().then(() => (init_hashBasedSnapshot(), hashBasedSnapshot_exports));
|
|
354117
|
+
await hashBasedSnapshotManager2.backupFile(
|
|
354118
|
+
context2.sessionId,
|
|
354119
|
+
context2.messageIndex,
|
|
354120
|
+
filePath,
|
|
354121
|
+
this.basePath,
|
|
354122
|
+
true,
|
|
354123
|
+
// File existed
|
|
354124
|
+
content
|
|
354125
|
+
);
|
|
354126
|
+
}
|
|
354127
|
+
} catch (backupError) {
|
|
354128
|
+
}
|
|
353700
354129
|
let normalizedSearch = searchContent.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
353701
354130
|
const normalizedContent = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
353702
354131
|
let searchLines = normalizedSearch.split("\n");
|
|
@@ -353862,12 +354291,12 @@ ${diffMsg}
|
|
|
353862
354291
|
const lineNum = contextStart + idx2;
|
|
353863
354292
|
return `${lineNum}\u2192${normalizeForDisplay(line)}`;
|
|
353864
354293
|
}).join("\n");
|
|
353865
|
-
await
|
|
354294
|
+
await fs17.writeFile(fullPath, modifiedContent, "utf-8");
|
|
353866
354295
|
let finalContent = modifiedContent;
|
|
353867
354296
|
let finalLines = modifiedLines;
|
|
353868
354297
|
let finalTotalLines = modifiedLines.length;
|
|
353869
354298
|
let finalContextEnd = Math.min(finalTotalLines, contextEnd + lineDifference);
|
|
353870
|
-
const fileExtension =
|
|
354299
|
+
const fileExtension = path19.extname(fullPath).toLowerCase();
|
|
353871
354300
|
const shouldFormat = this.prettierSupportedExtensions.includes(fileExtension);
|
|
353872
354301
|
if (shouldFormat) {
|
|
353873
354302
|
try {
|
|
@@ -353876,7 +354305,7 @@ ${diffMsg}
|
|
|
353876
354305
|
filepath: fullPath,
|
|
353877
354306
|
...prettierConfig
|
|
353878
354307
|
});
|
|
353879
|
-
await
|
|
354308
|
+
await fs17.writeFile(fullPath, finalContent, "utf-8");
|
|
353880
354309
|
finalLines = finalContent.split("\n");
|
|
353881
354310
|
finalTotalLines = finalLines.length;
|
|
353882
354311
|
finalContextEnd = Math.min(finalTotalLines, contextStart + (contextEnd - contextStart) + lineDifference);
|
|
@@ -354018,9 +354447,26 @@ ${formattedDiagnostics}`;
|
|
|
354018
354447
|
if (!isAbsolute3(filePath)) {
|
|
354019
354448
|
await this.validatePath(fullPath);
|
|
354020
354449
|
}
|
|
354021
|
-
const content = await
|
|
354450
|
+
const content = await fs17.readFile(fullPath, "utf-8");
|
|
354022
354451
|
const lines = content.split("\n");
|
|
354023
354452
|
const totalLines = lines.length;
|
|
354453
|
+
try {
|
|
354454
|
+
const { getConversationContext: getConversationContext2 } = await Promise.resolve().then(() => (init_conversationContext(), conversationContext_exports));
|
|
354455
|
+
const context2 = getConversationContext2();
|
|
354456
|
+
if (context2) {
|
|
354457
|
+
const { hashBasedSnapshotManager: hashBasedSnapshotManager2 } = await Promise.resolve().then(() => (init_hashBasedSnapshot(), hashBasedSnapshot_exports));
|
|
354458
|
+
await hashBasedSnapshotManager2.backupFile(
|
|
354459
|
+
context2.sessionId,
|
|
354460
|
+
context2.messageIndex,
|
|
354461
|
+
filePath,
|
|
354462
|
+
this.basePath,
|
|
354463
|
+
true,
|
|
354464
|
+
// File existed
|
|
354465
|
+
content
|
|
354466
|
+
);
|
|
354467
|
+
}
|
|
354468
|
+
} catch (backupError) {
|
|
354469
|
+
}
|
|
354024
354470
|
if (startLine < 1 || endLine < 1) {
|
|
354025
354471
|
throw new Error("Line numbers must be greater than 0");
|
|
354026
354472
|
}
|
|
@@ -354055,12 +354501,12 @@ ${formattedDiagnostics}`;
|
|
|
354055
354501
|
const lineNum = contextStart + idx2;
|
|
354056
354502
|
return `${lineNum}\u2192${normalizeForDisplay(line)}`;
|
|
354057
354503
|
}).join("\n");
|
|
354058
|
-
await
|
|
354504
|
+
await fs17.writeFile(fullPath, modifiedLines.join("\n"), "utf-8");
|
|
354059
354505
|
let finalLines = modifiedLines;
|
|
354060
354506
|
let finalTotalLines = newTotalLines;
|
|
354061
354507
|
let finalContextEnd = newContextEnd;
|
|
354062
354508
|
let finalContextContent = newContextContent;
|
|
354063
|
-
const fileExtension =
|
|
354509
|
+
const fileExtension = path19.extname(fullPath).toLowerCase();
|
|
354064
354510
|
const shouldFormat = this.prettierSupportedExtensions.includes(fileExtension);
|
|
354065
354511
|
if (shouldFormat) {
|
|
354066
354512
|
try {
|
|
@@ -354070,7 +354516,7 @@ ${formattedDiagnostics}`;
|
|
|
354070
354516
|
filepath: fullPath,
|
|
354071
354517
|
...prettierConfig
|
|
354072
354518
|
});
|
|
354073
|
-
await
|
|
354519
|
+
await fs17.writeFile(fullPath, formattedContent, "utf-8");
|
|
354074
354520
|
finalLines = formattedContent.split("\n");
|
|
354075
354521
|
finalTotalLines = finalLines.length;
|
|
354076
354522
|
finalContextEnd = Math.min(finalTotalLines, contextStart + (newContextEnd - contextStart));
|
|
@@ -354186,13 +354632,13 @@ ${formattedDiagnostics}`;
|
|
|
354186
354632
|
* @private
|
|
354187
354633
|
*/
|
|
354188
354634
|
resolvePath(filePath, contextPath) {
|
|
354189
|
-
const isAbs =
|
|
354635
|
+
const isAbs = path19.isAbsolute(filePath);
|
|
354190
354636
|
if (isAbs) {
|
|
354191
354637
|
return resolve4(filePath);
|
|
354192
354638
|
}
|
|
354193
354639
|
const relativePath = filePath.replace(/^[\/\\]+/, "");
|
|
354194
|
-
if (contextPath &&
|
|
354195
|
-
return resolve4(
|
|
354640
|
+
if (contextPath && path19.isAbsolute(contextPath)) {
|
|
354641
|
+
return resolve4(path19.dirname(contextPath), relativePath);
|
|
354196
354642
|
}
|
|
354197
354643
|
return resolve4(this.basePath, relativePath);
|
|
354198
354644
|
}
|
|
@@ -355607,8 +356053,8 @@ var init_fzf_es = __esm({
|
|
|
355607
356053
|
});
|
|
355608
356054
|
|
|
355609
356055
|
// dist/mcp/utils/aceCodeSearch/filesystem.utils.js
|
|
355610
|
-
import { promises as
|
|
355611
|
-
import * as
|
|
356056
|
+
import { promises as fs18 } from "fs";
|
|
356057
|
+
import * as path20 from "path";
|
|
355612
356058
|
function shouldExcludeDirectory(dirName, fullPath, basePath, customExcludes, regexCache) {
|
|
355613
356059
|
if (DEFAULT_EXCLUDES.includes(dirName)) {
|
|
355614
356060
|
return true;
|
|
@@ -355616,7 +356062,7 @@ function shouldExcludeDirectory(dirName, fullPath, basePath, customExcludes, reg
|
|
|
355616
356062
|
if (dirName.startsWith(".")) {
|
|
355617
356063
|
return true;
|
|
355618
356064
|
}
|
|
355619
|
-
const relativePath =
|
|
356065
|
+
const relativePath = path20.relative(basePath, fullPath);
|
|
355620
356066
|
for (const pattern of customExcludes) {
|
|
355621
356067
|
if (pattern.includes("*")) {
|
|
355622
356068
|
let regex2 = regexCache.get(pattern);
|
|
@@ -355653,7 +356099,7 @@ function shouldExcludeFile(fileName, fullPath, basePath, customExcludes, regexCa
|
|
|
355653
356099
|
return true;
|
|
355654
356100
|
}
|
|
355655
356101
|
}
|
|
355656
|
-
const relativePath =
|
|
356102
|
+
const relativePath = path20.relative(basePath, fullPath);
|
|
355657
356103
|
for (const pattern of customExcludes) {
|
|
355658
356104
|
if (pattern.endsWith("/")) {
|
|
355659
356105
|
continue;
|
|
@@ -355681,9 +356127,9 @@ function shouldExcludeFile(fileName, fullPath, basePath, customExcludes, regexCa
|
|
|
355681
356127
|
}
|
|
355682
356128
|
async function loadExclusionPatterns(basePath) {
|
|
355683
356129
|
const patterns = [];
|
|
355684
|
-
const gitignorePath =
|
|
356130
|
+
const gitignorePath = path20.join(basePath, ".gitignore");
|
|
355685
356131
|
try {
|
|
355686
|
-
const gitignoreContent = await
|
|
356132
|
+
const gitignoreContent = await fs18.readFile(gitignorePath, "utf-8");
|
|
355687
356133
|
const lines = gitignoreContent.split("\n");
|
|
355688
356134
|
for (const line of lines) {
|
|
355689
356135
|
const trimmed = line.trim();
|
|
@@ -355696,9 +356142,9 @@ async function loadExclusionPatterns(basePath) {
|
|
|
355696
356142
|
}
|
|
355697
356143
|
} catch {
|
|
355698
356144
|
}
|
|
355699
|
-
const snowignorePath =
|
|
356145
|
+
const snowignorePath = path20.join(basePath, ".snowignore");
|
|
355700
356146
|
try {
|
|
355701
|
-
const snowignoreContent = await
|
|
356147
|
+
const snowignoreContent = await fs18.readFile(snowignorePath, "utf-8");
|
|
355702
356148
|
const lines = snowignoreContent.split("\n");
|
|
355703
356149
|
for (const line of lines) {
|
|
355704
356150
|
const trimmed = line.trim();
|
|
@@ -355714,13 +356160,13 @@ async function loadExclusionPatterns(basePath) {
|
|
|
355714
356160
|
return patterns;
|
|
355715
356161
|
}
|
|
355716
356162
|
async function readFileWithCache(filePath, fileContentCache, maxCacheSize = 50) {
|
|
355717
|
-
const stats = await
|
|
356163
|
+
const stats = await fs18.stat(filePath);
|
|
355718
356164
|
const mtime = stats.mtimeMs;
|
|
355719
356165
|
const cached = fileContentCache.get(filePath);
|
|
355720
356166
|
if (cached && cached.mtime === mtime) {
|
|
355721
356167
|
return cached.content;
|
|
355722
356168
|
}
|
|
355723
|
-
const content = await
|
|
356169
|
+
const content = await fs18.readFile(filePath, "utf-8");
|
|
355724
356170
|
if (fileContentCache.size >= maxCacheSize) {
|
|
355725
356171
|
const firstKey = fileContentCache.keys().next().value;
|
|
355726
356172
|
if (firstKey) {
|
|
@@ -355754,7 +356200,7 @@ var init_filesystem_utils = __esm({
|
|
|
355754
356200
|
// dist/mcp/utils/aceCodeSearch/search.utils.js
|
|
355755
356201
|
import { spawn as spawn2 } from "child_process";
|
|
355756
356202
|
import { EOL } from "os";
|
|
355757
|
-
import * as
|
|
356203
|
+
import * as path21 from "path";
|
|
355758
356204
|
function isCommandAvailable(command) {
|
|
355759
356205
|
return new Promise((resolve10) => {
|
|
355760
356206
|
try {
|
|
@@ -355796,10 +356242,10 @@ function parseGrepOutput(output2, basePath) {
|
|
|
355796
356242
|
const lineNumber = parseInt(lineNumberStr, 10);
|
|
355797
356243
|
if (isNaN(lineNumber))
|
|
355798
356244
|
continue;
|
|
355799
|
-
const absoluteFilePath =
|
|
355800
|
-
const relativeFilePath =
|
|
356245
|
+
const absoluteFilePath = path21.resolve(basePath, filePathRaw);
|
|
356246
|
+
const relativeFilePath = path21.relative(basePath, absoluteFilePath);
|
|
355801
356247
|
results.push({
|
|
355802
|
-
filePath: relativeFilePath ||
|
|
356248
|
+
filePath: relativeFilePath || path21.basename(absoluteFilePath),
|
|
355803
356249
|
line: lineNumber,
|
|
355804
356250
|
column: 1,
|
|
355805
356251
|
// grep doesn't provide column info, default to 1
|
|
@@ -355842,8 +356288,8 @@ __export(aceCodeSearch_exports, {
|
|
|
355842
356288
|
aceCodeSearchService: () => aceCodeSearchService,
|
|
355843
356289
|
mcpTools: () => mcpTools3
|
|
355844
356290
|
});
|
|
355845
|
-
import { promises as
|
|
355846
|
-
import * as
|
|
356291
|
+
import { promises as fs19 } from "fs";
|
|
356292
|
+
import * as path22 from "path";
|
|
355847
356293
|
import { spawn as spawn3 } from "child_process";
|
|
355848
356294
|
var ACECodeSearchService, aceCodeSearchService, mcpTools3;
|
|
355849
356295
|
var init_aceCodeSearch = __esm({
|
|
@@ -355918,7 +356364,7 @@ var init_aceCodeSearch = __esm({
|
|
|
355918
356364
|
writable: true,
|
|
355919
356365
|
value: /* @__PURE__ */ new Map()
|
|
355920
356366
|
});
|
|
355921
|
-
this.basePath =
|
|
356367
|
+
this.basePath = path22.resolve(basePath);
|
|
355922
356368
|
}
|
|
355923
356369
|
/**
|
|
355924
356370
|
* Load custom exclusion patterns from .gitignore and .snowignore
|
|
@@ -355934,8 +356380,8 @@ var init_aceCodeSearch = __esm({
|
|
|
355934
356380
|
*/
|
|
355935
356381
|
async isGitRepository(directory = this.basePath) {
|
|
355936
356382
|
try {
|
|
355937
|
-
const gitDir =
|
|
355938
|
-
const stats = await
|
|
356383
|
+
const gitDir = path22.join(directory, ".git");
|
|
356384
|
+
const stats = await fs19.stat(gitDir);
|
|
355939
356385
|
return stats.isDirectory();
|
|
355940
356386
|
} catch {
|
|
355941
356387
|
return false;
|
|
@@ -355959,9 +356405,9 @@ var init_aceCodeSearch = __esm({
|
|
|
355959
356405
|
const filesToProcess = [];
|
|
355960
356406
|
const searchInDirectory = async (dirPath) => {
|
|
355961
356407
|
try {
|
|
355962
|
-
const entries = await
|
|
356408
|
+
const entries = await fs19.readdir(dirPath, { withFileTypes: true });
|
|
355963
356409
|
for (const entry of entries) {
|
|
355964
|
-
const fullPath =
|
|
356410
|
+
const fullPath = path22.join(dirPath, entry.name);
|
|
355965
356411
|
if (entry.isDirectory()) {
|
|
355966
356412
|
if (shouldExcludeDirectory(entry.name, fullPath, this.basePath, this.customExcludes, this.regexCache)) {
|
|
355967
356413
|
continue;
|
|
@@ -355971,7 +356417,7 @@ var init_aceCodeSearch = __esm({
|
|
|
355971
356417
|
const language = detectLanguage(fullPath);
|
|
355972
356418
|
if (language) {
|
|
355973
356419
|
try {
|
|
355974
|
-
const stats = await
|
|
356420
|
+
const stats = await fs19.stat(fullPath);
|
|
355975
356421
|
const currentMtime = stats.mtimeMs;
|
|
355976
356422
|
const cachedMtime = this.fileModTimes.get(fullPath);
|
|
355977
356423
|
if (cachedMtime === void 0 || currentMtime > cachedMtime) {
|
|
@@ -356010,7 +356456,7 @@ var init_aceCodeSearch = __esm({
|
|
|
356010
356456
|
}
|
|
356011
356457
|
for (const cachedPath of Array.from(this.indexCache.keys())) {
|
|
356012
356458
|
try {
|
|
356013
|
-
await
|
|
356459
|
+
await fs19.access(cachedPath);
|
|
356014
356460
|
} catch {
|
|
356015
356461
|
this.indexCache.delete(cachedPath);
|
|
356016
356462
|
this.fileModTimes.delete(cachedPath);
|
|
@@ -356168,13 +356614,13 @@ var init_aceCodeSearch = __esm({
|
|
|
356168
356614
|
return;
|
|
356169
356615
|
}
|
|
356170
356616
|
try {
|
|
356171
|
-
const entries = await
|
|
356617
|
+
const entries = await fs19.readdir(dirPath, { withFileTypes: true });
|
|
356172
356618
|
for (const entry of entries) {
|
|
356173
356619
|
if (shouldStop || references.length >= maxResults) {
|
|
356174
356620
|
shouldStop = true;
|
|
356175
356621
|
return;
|
|
356176
356622
|
}
|
|
356177
|
-
const fullPath =
|
|
356623
|
+
const fullPath = path22.join(dirPath, entry.name);
|
|
356178
356624
|
if (entry.isDirectory()) {
|
|
356179
356625
|
if (shouldExcludeDirectory(entry.name, fullPath, this.basePath, this.customExcludes, this.regexCache)) {
|
|
356180
356626
|
continue;
|
|
@@ -356215,7 +356661,7 @@ var init_aceCodeSearch = __esm({
|
|
|
356215
356661
|
}
|
|
356216
356662
|
references.push({
|
|
356217
356663
|
symbol: symbolName,
|
|
356218
|
-
filePath:
|
|
356664
|
+
filePath: path22.relative(this.basePath, fullPath),
|
|
356219
356665
|
line: i + 1,
|
|
356220
356666
|
column: match2.index + 1,
|
|
356221
356667
|
context: getContext(lines, i, 1),
|
|
@@ -356240,7 +356686,7 @@ var init_aceCodeSearch = __esm({
|
|
|
356240
356686
|
async findDefinition(symbolName, contextFile) {
|
|
356241
356687
|
await this.buildIndex();
|
|
356242
356688
|
if (contextFile) {
|
|
356243
|
-
const fullPath =
|
|
356689
|
+
const fullPath = path22.resolve(this.basePath, contextFile);
|
|
356244
356690
|
const fileSymbols = this.indexCache.get(fullPath);
|
|
356245
356691
|
if (fileSymbols) {
|
|
356246
356692
|
const symbol = fileSymbols.find((s) => s.name === symbolName && (s.type === "function" || s.type === "class" || s.type === "variable"));
|
|
@@ -356433,11 +356879,11 @@ var init_aceCodeSearch = __esm({
|
|
|
356433
356879
|
if (results.length >= maxResults)
|
|
356434
356880
|
return;
|
|
356435
356881
|
try {
|
|
356436
|
-
const entries = await
|
|
356882
|
+
const entries = await fs19.readdir(dirPath, { withFileTypes: true });
|
|
356437
356883
|
for (const entry of entries) {
|
|
356438
356884
|
if (results.length >= maxResults)
|
|
356439
356885
|
break;
|
|
356440
|
-
const fullPath =
|
|
356886
|
+
const fullPath = path22.join(dirPath, entry.name);
|
|
356441
356887
|
if (entry.isDirectory()) {
|
|
356442
356888
|
if (shouldExcludeDirectory(entry.name, fullPath, this.basePath, this.customExcludes, this.regexCache)) {
|
|
356443
356889
|
continue;
|
|
@@ -356445,17 +356891,17 @@ var init_aceCodeSearch = __esm({
|
|
|
356445
356891
|
await searchInDirectory(fullPath);
|
|
356446
356892
|
} else if (entry.isFile()) {
|
|
356447
356893
|
if (globRegex) {
|
|
356448
|
-
const relativePath =
|
|
356894
|
+
const relativePath = path22.relative(this.basePath, fullPath).replace(/\\/g, "/");
|
|
356449
356895
|
if (!globRegex.test(relativePath)) {
|
|
356450
356896
|
continue;
|
|
356451
356897
|
}
|
|
356452
356898
|
}
|
|
356453
|
-
const ext =
|
|
356899
|
+
const ext = path22.extname(entry.name).toLowerCase();
|
|
356454
356900
|
if (binaryExts.has(ext)) {
|
|
356455
356901
|
continue;
|
|
356456
356902
|
}
|
|
356457
356903
|
try {
|
|
356458
|
-
const content = await
|
|
356904
|
+
const content = await fs19.readFile(fullPath, "utf-8");
|
|
356459
356905
|
const lines = content.split("\n");
|
|
356460
356906
|
for (let i = 0; i < lines.length; i++) {
|
|
356461
356907
|
if (results.length >= maxResults)
|
|
@@ -356467,7 +356913,7 @@ var init_aceCodeSearch = __esm({
|
|
|
356467
356913
|
const match2 = searchRegex.exec(line);
|
|
356468
356914
|
if (match2) {
|
|
356469
356915
|
results.push({
|
|
356470
|
-
filePath:
|
|
356916
|
+
filePath: path22.relative(this.basePath, fullPath),
|
|
356471
356917
|
line: i + 1,
|
|
356472
356918
|
column: match2.index + 1,
|
|
356473
356919
|
content: line.trim()
|
|
@@ -356527,8 +356973,8 @@ var init_aceCodeSearch = __esm({
|
|
|
356527
356973
|
const recentThreshold = 24 * 60 * 60 * 1e3;
|
|
356528
356974
|
const uniqueFiles = Array.from(new Set(results.map((r) => r.filePath)));
|
|
356529
356975
|
const statResults = await Promise.allSettled(uniqueFiles.map(async (filePath) => {
|
|
356530
|
-
const fullPath =
|
|
356531
|
-
const stats = await
|
|
356976
|
+
const fullPath = path22.resolve(this.basePath, filePath);
|
|
356977
|
+
const stats = await fs19.stat(fullPath);
|
|
356532
356978
|
return { filePath, mtimeMs: stats.mtimeMs };
|
|
356533
356979
|
}));
|
|
356534
356980
|
const fileModTimes = /* @__PURE__ */ new Map();
|
|
@@ -356557,9 +357003,9 @@ var init_aceCodeSearch = __esm({
|
|
|
356557
357003
|
* Get code outline for a file (all symbols in the file)
|
|
356558
357004
|
*/
|
|
356559
357005
|
async getFileOutline(filePath, options3) {
|
|
356560
|
-
const fullPath =
|
|
357006
|
+
const fullPath = path22.resolve(this.basePath, filePath);
|
|
356561
357007
|
try {
|
|
356562
|
-
const content = await
|
|
357008
|
+
const content = await fs19.readFile(fullPath, "utf-8");
|
|
356563
357009
|
let symbols = await parseFileSymbols(fullPath, content, this.basePath);
|
|
356564
357010
|
if ((options3 == null ? void 0 : options3.symbolTypes) && options3.symbolTypes.length > 0) {
|
|
356565
357011
|
symbols = symbols.filter((s) => options3.symbolTypes.includes(s.type));
|
|
@@ -359435,12 +359881,12 @@ var init_disposable = __esm({
|
|
|
359435
359881
|
});
|
|
359436
359882
|
|
|
359437
359883
|
// node_modules/puppeteer-core/lib/esm/puppeteer/common/EventEmitter.js
|
|
359438
|
-
var
|
|
359884
|
+
var EventEmitter5;
|
|
359439
359885
|
var init_EventEmitter = __esm({
|
|
359440
359886
|
"node_modules/puppeteer-core/lib/esm/puppeteer/common/EventEmitter.js"() {
|
|
359441
359887
|
init_mitt();
|
|
359442
359888
|
init_disposable();
|
|
359443
|
-
|
|
359889
|
+
EventEmitter5 = class {
|
|
359444
359890
|
#emitter;
|
|
359445
359891
|
#handlers = /* @__PURE__ */ new Map();
|
|
359446
359892
|
/**
|
|
@@ -360743,7 +361189,7 @@ var init_Browser = __esm({
|
|
|
360743
361189
|
// chrome-specific permissions we have.
|
|
360744
361190
|
["midi-sysex", "midiSysex"]
|
|
360745
361191
|
]);
|
|
360746
|
-
Browser = class extends
|
|
361192
|
+
Browser = class extends EventEmitter5 {
|
|
360747
361193
|
/**
|
|
360748
361194
|
* @internal
|
|
360749
361195
|
*/
|
|
@@ -361015,7 +361461,7 @@ var init_BrowserContext = __esm({
|
|
|
361015
361461
|
init_util2();
|
|
361016
361462
|
init_disposable();
|
|
361017
361463
|
init_Mutex();
|
|
361018
|
-
BrowserContext = class extends
|
|
361464
|
+
BrowserContext = class extends EventEmitter5 {
|
|
361019
361465
|
/**
|
|
361020
361466
|
* @internal
|
|
361021
361467
|
*/
|
|
@@ -361168,7 +361614,7 @@ var init_CDPSession = __esm({
|
|
|
361168
361614
|
CDPSessionEvent2.SessionAttached = "sessionattached";
|
|
361169
361615
|
CDPSessionEvent2.SessionDetached = "sessiondetached";
|
|
361170
361616
|
})(CDPSessionEvent || (CDPSessionEvent = {}));
|
|
361171
|
-
CDPSession = class extends
|
|
361617
|
+
CDPSession = class extends EventEmitter5 {
|
|
361172
361618
|
/**
|
|
361173
361619
|
* @internal
|
|
361174
361620
|
*/
|
|
@@ -362849,7 +363295,7 @@ var init_locators = __esm({
|
|
|
362849
363295
|
(function(LocatorEvent2) {
|
|
362850
363296
|
LocatorEvent2["Action"] = "action";
|
|
362851
363297
|
})(LocatorEvent || (LocatorEvent = {}));
|
|
362852
|
-
Locator = class extends
|
|
363298
|
+
Locator = class extends EventEmitter5 {
|
|
362853
363299
|
/**
|
|
362854
363300
|
* Creates a race between multiple locators trying to locate elements in
|
|
362855
363301
|
* parallel but ensures that only a single element receives the action.
|
|
@@ -364891,7 +365337,7 @@ var init_Frame = __esm({
|
|
|
364891
365337
|
});
|
|
364892
365338
|
Frame = (() => {
|
|
364893
365339
|
var __document, _Frame_instances, document_fn, _a21;
|
|
364894
|
-
let _classSuper =
|
|
365340
|
+
let _classSuper = EventEmitter5;
|
|
364895
365341
|
let _instanceExtraInitializers = [];
|
|
364896
365342
|
let _frameElement_decorators;
|
|
364897
365343
|
let _evaluateHandle_decorators;
|
|
@@ -366317,7 +366763,7 @@ var init_Page = __esm({
|
|
|
366317
366763
|
});
|
|
366318
366764
|
Page = (() => {
|
|
366319
366765
|
var _requestHandlers, _inflight$, _screencastSessionCount, _startScreencastPromise, _Page_instances, getNativePixelDimensions_fn, _a21;
|
|
366320
|
-
let _classSuper =
|
|
366766
|
+
let _classSuper = EventEmitter5;
|
|
366321
366767
|
let _instanceExtraInitializers = [];
|
|
366322
366768
|
let _screenshot_decorators;
|
|
366323
366769
|
return _a21 = class extends _classSuper {
|
|
@@ -367895,7 +368341,7 @@ var init_WebWorker = __esm({
|
|
|
367895
368341
|
init_EventEmitter();
|
|
367896
368342
|
init_TimeoutSettings();
|
|
367897
368343
|
init_util2();
|
|
367898
|
-
WebWorker = class extends
|
|
368344
|
+
WebWorker = class extends EventEmitter5 {
|
|
367899
368345
|
/**
|
|
367900
368346
|
* @internal
|
|
367901
368347
|
*/
|
|
@@ -369028,7 +369474,7 @@ var init_Connection = __esm({
|
|
|
369028
369474
|
init_CdpSession();
|
|
369029
369475
|
debugProtocolSend = debug("puppeteer:protocol:SEND \u25BA");
|
|
369030
369476
|
debugProtocolReceive = debug("puppeteer:protocol:RECV \u25C0");
|
|
369031
|
-
Connection = class extends
|
|
369477
|
+
Connection = class extends EventEmitter5 {
|
|
369032
369478
|
#url;
|
|
369033
369479
|
#transport;
|
|
369034
369480
|
#delay;
|
|
@@ -369385,7 +369831,7 @@ var init_Coverage = __esm({
|
|
|
369385
369831
|
this.#scriptURLs.clear();
|
|
369386
369832
|
this.#scriptSources.clear();
|
|
369387
369833
|
this.#subscriptions = new DisposableStack();
|
|
369388
|
-
const clientEmitter = this.#subscriptions.use(new
|
|
369834
|
+
const clientEmitter = this.#subscriptions.use(new EventEmitter5(this.#client));
|
|
369389
369835
|
clientEmitter.on("Debugger.scriptParsed", this.#onScriptParsed.bind(this));
|
|
369390
369836
|
clientEmitter.on("Runtime.executionContextsCleared", this.#onExecutionContextsCleared.bind(this));
|
|
369391
369837
|
await Promise.all([
|
|
@@ -369482,7 +369928,7 @@ var init_Coverage = __esm({
|
|
|
369482
369928
|
this.#stylesheetURLs.clear();
|
|
369483
369929
|
this.#stylesheetSources.clear();
|
|
369484
369930
|
this.#eventListeners = new DisposableStack();
|
|
369485
|
-
const clientEmitter = this.#eventListeners.use(new
|
|
369931
|
+
const clientEmitter = this.#eventListeners.use(new EventEmitter5(this.#client));
|
|
369486
369932
|
clientEmitter.on("CSS.styleSheetAdded", this.#onStyleSheet.bind(this));
|
|
369487
369933
|
clientEmitter.on("Runtime.executionContextsCleared", this.#onExecutionContextsCleared.bind(this));
|
|
369488
369934
|
await Promise.all([
|
|
@@ -370747,7 +371193,7 @@ var init_ExecutionContext = __esm({
|
|
|
370747
371193
|
return elements;
|
|
370748
371194
|
}, ...await AsyncIterableUtil.collect(results));
|
|
370749
371195
|
}), "");
|
|
370750
|
-
ExecutionContext = class extends
|
|
371196
|
+
ExecutionContext = class extends EventEmitter5 {
|
|
370751
371197
|
#client;
|
|
370752
371198
|
#world;
|
|
370753
371199
|
#id;
|
|
@@ -370761,7 +371207,7 @@ var init_ExecutionContext = __esm({
|
|
|
370761
371207
|
if (contextPayload.name) {
|
|
370762
371208
|
this.#name = contextPayload.name;
|
|
370763
371209
|
}
|
|
370764
|
-
const clientEmitter = this.#disposables.use(new
|
|
371210
|
+
const clientEmitter = this.#disposables.use(new EventEmitter5(this.#client));
|
|
370765
371211
|
clientEmitter.on("Runtime.bindingCalled", this.#onBindingCalled.bind(this));
|
|
370766
371212
|
clientEmitter.on("Runtime.executionContextDestroyed", async (event) => {
|
|
370767
371213
|
if (event.executionContextId === this.#id) {
|
|
@@ -371129,7 +371575,7 @@ var init_IsolatedWorld = __esm({
|
|
|
371129
371575
|
init_JSHandle2();
|
|
371130
371576
|
IsolatedWorld = class extends Realm {
|
|
371131
371577
|
#context;
|
|
371132
|
-
#emitter = new
|
|
371578
|
+
#emitter = new EventEmitter5();
|
|
371133
371579
|
#frameOrWorker;
|
|
371134
371580
|
constructor(frameOrWorker, timeoutSettings) {
|
|
371135
371581
|
super(timeoutSettings);
|
|
@@ -371321,15 +371767,15 @@ var init_LifecycleWatcher = __esm({
|
|
|
371321
371767
|
});
|
|
371322
371768
|
this.#frame = frame;
|
|
371323
371769
|
this.#timeout = timeout2;
|
|
371324
|
-
const frameManagerEmitter = this.#subscriptions.use(new
|
|
371770
|
+
const frameManagerEmitter = this.#subscriptions.use(new EventEmitter5(frame._frameManager));
|
|
371325
371771
|
frameManagerEmitter.on(FrameManagerEvent.LifecycleEvent, this.#checkLifecycleComplete.bind(this));
|
|
371326
|
-
const frameEmitter = this.#subscriptions.use(new
|
|
371772
|
+
const frameEmitter = this.#subscriptions.use(new EventEmitter5(frame));
|
|
371327
371773
|
frameEmitter.on(FrameEvent.FrameNavigatedWithinDocument, this.#navigatedWithinDocument.bind(this));
|
|
371328
371774
|
frameEmitter.on(FrameEvent.FrameNavigated, this.#navigated.bind(this));
|
|
371329
371775
|
frameEmitter.on(FrameEvent.FrameSwapped, this.#frameSwapped.bind(this));
|
|
371330
371776
|
frameEmitter.on(FrameEvent.FrameSwappedByActivation, this.#frameSwapped.bind(this));
|
|
371331
371777
|
frameEmitter.on(FrameEvent.FrameDetached, this.#onFrameDetached.bind(this));
|
|
371332
|
-
const networkManagerEmitter = this.#subscriptions.use(new
|
|
371778
|
+
const networkManagerEmitter = this.#subscriptions.use(new EventEmitter5(networkManager));
|
|
371333
371779
|
networkManagerEmitter.on(NetworkManagerEvent.Request, this.#onRequest.bind(this));
|
|
371334
371780
|
networkManagerEmitter.on(NetworkManagerEvent.Response, this.#onResponse.bind(this));
|
|
371335
371781
|
networkManagerEmitter.on(NetworkManagerEvent.RequestFailed, this.#onRequestFailed.bind(this));
|
|
@@ -372381,7 +372827,7 @@ var init_NetworkManager = __esm({
|
|
|
372381
372827
|
init_HTTPRequest2();
|
|
372382
372828
|
init_HTTPResponse2();
|
|
372383
372829
|
init_NetworkEventManager();
|
|
372384
|
-
NetworkManager2 = class extends
|
|
372830
|
+
NetworkManager2 = class extends EventEmitter5 {
|
|
372385
372831
|
#frameManager;
|
|
372386
372832
|
#networkEventManager = new NetworkEventManager();
|
|
372387
372833
|
#extraHTTPHeaders;
|
|
@@ -372422,7 +372868,7 @@ var init_NetworkManager = __esm({
|
|
|
372422
372868
|
}
|
|
372423
372869
|
const subscriptions = new DisposableStack();
|
|
372424
372870
|
this.#clients.set(client, subscriptions);
|
|
372425
|
-
const clientEmitter = subscriptions.use(new
|
|
372871
|
+
const clientEmitter = subscriptions.use(new EventEmitter5(client));
|
|
372426
372872
|
for (const [event, handler] of this.#handlers) {
|
|
372427
372873
|
clientEmitter.on(event, (arg) => {
|
|
372428
372874
|
return handler.bind(this)(client, arg);
|
|
@@ -372900,7 +373346,7 @@ var init_FrameManager = __esm({
|
|
|
372900
373346
|
init_IsolatedWorlds();
|
|
372901
373347
|
init_NetworkManager();
|
|
372902
373348
|
TIME_FOR_WAITING_FOR_SWAP = 100;
|
|
372903
|
-
FrameManager = class extends
|
|
373349
|
+
FrameManager = class extends EventEmitter5 {
|
|
372904
373350
|
#page;
|
|
372905
373351
|
#networkManager;
|
|
372906
373352
|
#timeoutSettings;
|
|
@@ -374512,7 +374958,7 @@ var init_Page2 = __esm({
|
|
|
374512
374958
|
this.#tracing = new Tracing(client);
|
|
374513
374959
|
this.#coverage = new Coverage(client);
|
|
374514
374960
|
this.#viewport = null;
|
|
374515
|
-
const frameManagerEmitter = new
|
|
374961
|
+
const frameManagerEmitter = new EventEmitter5(this.#frameManager);
|
|
374516
374962
|
frameManagerEmitter.on(FrameManagerEvent.FrameAttached, (frame) => {
|
|
374517
374963
|
this.emit("frameattached", frame);
|
|
374518
374964
|
});
|
|
@@ -374528,7 +374974,7 @@ var init_Page2 = __esm({
|
|
|
374528
374974
|
frameManagerEmitter.on(FrameManagerEvent.BindingCalled, ([world, event]) => {
|
|
374529
374975
|
void this.#onBindingCalled(world, event);
|
|
374530
374976
|
});
|
|
374531
|
-
const networkManagerEmitter = new
|
|
374977
|
+
const networkManagerEmitter = new EventEmitter5(this.#frameManager.networkManager);
|
|
374532
374978
|
networkManagerEmitter.on(NetworkManagerEvent.Request, (request3) => {
|
|
374533
374979
|
this.emit("request", request3);
|
|
374534
374980
|
});
|
|
@@ -374600,7 +375046,7 @@ var init_Page2 = __esm({
|
|
|
374600
375046
|
* during a navigation to a prerended page.
|
|
374601
375047
|
*/
|
|
374602
375048
|
#setupPrimaryTargetListeners() {
|
|
374603
|
-
const clientEmitter = new
|
|
375049
|
+
const clientEmitter = new EventEmitter5(this.#primaryTargetClient);
|
|
374604
375050
|
clientEmitter.on(CDPSessionEvent.Ready, this.#onAttachedToTarget);
|
|
374605
375051
|
clientEmitter.on(CDPSessionEvent.Disconnected, () => {
|
|
374606
375052
|
this.#sessionCloseDeferred.reject(new TargetCloseError("Target closed"));
|
|
@@ -375669,7 +376115,7 @@ var init_TargetManager = __esm({
|
|
|
375669
376115
|
init_Deferred();
|
|
375670
376116
|
init_CdpSession();
|
|
375671
376117
|
init_Target2();
|
|
375672
|
-
TargetManager = class extends
|
|
376118
|
+
TargetManager = class extends EventEmitter5 {
|
|
375673
376119
|
#connection;
|
|
375674
376120
|
/**
|
|
375675
376121
|
* Keeps track of the following events: 'Target.targetCreated',
|
|
@@ -377992,7 +378438,7 @@ var require_EventEmitter = __commonJS({
|
|
|
377992
378438
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
377993
378439
|
exports2.EventEmitter = void 0;
|
|
377994
378440
|
var mitt_1 = __importDefault2((init_mitt2(), __toCommonJS(mitt_exports)));
|
|
377995
|
-
var
|
|
378441
|
+
var EventEmitter10 = class {
|
|
377996
378442
|
#emitter = (0, mitt_1.default)();
|
|
377997
378443
|
on(type, handler) {
|
|
377998
378444
|
this.#emitter.on(type, handler);
|
|
@@ -378040,7 +378486,7 @@ var require_EventEmitter = __commonJS({
|
|
|
378040
378486
|
return this;
|
|
378041
378487
|
}
|
|
378042
378488
|
};
|
|
378043
|
-
exports2.EventEmitter =
|
|
378489
|
+
exports2.EventEmitter = EventEmitter10;
|
|
378044
378490
|
}
|
|
378045
378491
|
});
|
|
378046
378492
|
|
|
@@ -389835,7 +390281,7 @@ var init_Connection2 = __esm({
|
|
|
389835
390281
|
init_CDPSession2();
|
|
389836
390282
|
debugProtocolSend2 = debug("puppeteer:webDriverBiDi:SEND \u25BA");
|
|
389837
390283
|
debugProtocolReceive2 = debug("puppeteer:webDriverBiDi:RECV \u25C0");
|
|
389838
|
-
BidiConnection = class extends
|
|
390284
|
+
BidiConnection = class extends EventEmitter5 {
|
|
389839
390285
|
#url;
|
|
389840
390286
|
#transport;
|
|
389841
390287
|
#delay;
|
|
@@ -390144,7 +390590,7 @@ var init_Navigation = __esm({
|
|
|
390144
390590
|
Navigation = (() => {
|
|
390145
390591
|
var _request, _navigation, _browsingContext, _disposables, _id, _Navigation_instances, initialize_fn2, matches_fn, session_get, _a22;
|
|
390146
390592
|
var _a21;
|
|
390147
|
-
let _classSuper =
|
|
390593
|
+
let _classSuper = EventEmitter5;
|
|
390148
390594
|
let _instanceExtraInitializers = [];
|
|
390149
390595
|
let _dispose_decorators;
|
|
390150
390596
|
return _a22 = class extends _classSuper {
|
|
@@ -390181,7 +390627,7 @@ var init_Navigation = __esm({
|
|
|
390181
390627
|
super[disposeSymbol]();
|
|
390182
390628
|
}
|
|
390183
390629
|
}, _request = new WeakMap(), _navigation = new WeakMap(), _browsingContext = new WeakMap(), _disposables = new WeakMap(), _id = new WeakMap(), _Navigation_instances = new WeakSet(), initialize_fn2 = function() {
|
|
390184
|
-
const browsingContextEmitter = __privateGet(this, _disposables).use(new
|
|
390630
|
+
const browsingContextEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _browsingContext)));
|
|
390185
390631
|
browsingContextEmitter.once("closed", () => {
|
|
390186
390632
|
this.emit("failed", {
|
|
390187
390633
|
url: __privateGet(this, _browsingContext).url,
|
|
@@ -390197,12 +390643,12 @@ var init_Navigation = __esm({
|
|
|
390197
390643
|
}
|
|
390198
390644
|
__privateSet(this, _request, request3);
|
|
390199
390645
|
this.emit("request", request3);
|
|
390200
|
-
const requestEmitter = __privateGet(this, _disposables).use(new
|
|
390646
|
+
const requestEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _request)));
|
|
390201
390647
|
requestEmitter.on("redirect", (request4) => {
|
|
390202
390648
|
__privateSet(this, _request, request4);
|
|
390203
390649
|
});
|
|
390204
390650
|
});
|
|
390205
|
-
const sessionEmitter = __privateGet(this, _disposables).use(new
|
|
390651
|
+
const sessionEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _Navigation_instances, session_get)));
|
|
390206
390652
|
sessionEmitter.on("browsingContext.navigationStarted", (info2) => {
|
|
390207
390653
|
if (info2.context !== __privateGet(this, _browsingContext).id || __privateGet(this, _navigation) !== void 0) {
|
|
390208
390654
|
return;
|
|
@@ -390306,7 +390752,7 @@ var init_Realm2 = __esm({
|
|
|
390306
390752
|
};
|
|
390307
390753
|
Realm2 = (() => {
|
|
390308
390754
|
var _reason, _a21;
|
|
390309
|
-
let _classSuper =
|
|
390755
|
+
let _classSuper = EventEmitter5;
|
|
390310
390756
|
let _instanceExtraInitializers = [];
|
|
390311
390757
|
let _dispose_decorators;
|
|
390312
390758
|
let _disown_decorators;
|
|
@@ -390404,11 +390850,11 @@ var init_Realm2 = __esm({
|
|
|
390404
390850
|
this.sandbox = sandbox;
|
|
390405
390851
|
}
|
|
390406
390852
|
#initialize() {
|
|
390407
|
-
const browsingContextEmitter = this.disposables.use(new
|
|
390853
|
+
const browsingContextEmitter = this.disposables.use(new EventEmitter5(this.browsingContext));
|
|
390408
390854
|
browsingContextEmitter.on("closed", ({ reason }) => {
|
|
390409
390855
|
this.dispose(reason);
|
|
390410
390856
|
});
|
|
390411
|
-
const sessionEmitter = this.disposables.use(new
|
|
390857
|
+
const sessionEmitter = this.disposables.use(new EventEmitter5(this.session));
|
|
390412
390858
|
sessionEmitter.on("script.realmCreated", (info2) => {
|
|
390413
390859
|
if (info2.type !== "window" || info2.context !== this.browsingContext.id || info2.sandbox !== this.sandbox) {
|
|
390414
390860
|
return;
|
|
@@ -390427,7 +390873,7 @@ var init_Realm2 = __esm({
|
|
|
390427
390873
|
}
|
|
390428
390874
|
const realm = DedicatedWorkerRealm.from(this, info2.realm, info2.origin);
|
|
390429
390875
|
this.#workers.set(realm.id, realm);
|
|
390430
|
-
const realmEmitter = this.disposables.use(new
|
|
390876
|
+
const realmEmitter = this.disposables.use(new EventEmitter5(realm));
|
|
390431
390877
|
realmEmitter.once("destroyed", () => {
|
|
390432
390878
|
realmEmitter.removeAllListeners();
|
|
390433
390879
|
this.#workers.delete(realm.id);
|
|
@@ -390455,7 +390901,7 @@ var init_Realm2 = __esm({
|
|
|
390455
390901
|
this.owners = /* @__PURE__ */ new Set([owner]);
|
|
390456
390902
|
}
|
|
390457
390903
|
#initialize() {
|
|
390458
|
-
const sessionEmitter = this.disposables.use(new
|
|
390904
|
+
const sessionEmitter = this.disposables.use(new EventEmitter5(this.session));
|
|
390459
390905
|
sessionEmitter.on("script.realmDestroyed", (info2) => {
|
|
390460
390906
|
if (info2.realm !== this.id) {
|
|
390461
390907
|
return;
|
|
@@ -390471,7 +390917,7 @@ var init_Realm2 = __esm({
|
|
|
390471
390917
|
}
|
|
390472
390918
|
const realm = _a18.from(this, info2.realm, info2.origin);
|
|
390473
390919
|
this.#workers.set(realm.id, realm);
|
|
390474
|
-
const realmEmitter = this.disposables.use(new
|
|
390920
|
+
const realmEmitter = this.disposables.use(new EventEmitter5(realm));
|
|
390475
390921
|
realmEmitter.once("destroyed", () => {
|
|
390476
390922
|
this.#workers.delete(realm.id);
|
|
390477
390923
|
});
|
|
@@ -390496,7 +390942,7 @@ var init_Realm2 = __esm({
|
|
|
390496
390942
|
this.browser = browser;
|
|
390497
390943
|
}
|
|
390498
390944
|
#initialize() {
|
|
390499
|
-
const sessionEmitter = this.disposables.use(new
|
|
390945
|
+
const sessionEmitter = this.disposables.use(new EventEmitter5(this.session));
|
|
390500
390946
|
sessionEmitter.on("script.realmDestroyed", (info2) => {
|
|
390501
390947
|
if (info2.realm !== this.id) {
|
|
390502
390948
|
return;
|
|
@@ -390512,7 +390958,7 @@ var init_Realm2 = __esm({
|
|
|
390512
390958
|
}
|
|
390513
390959
|
const realm = DedicatedWorkerRealm.from(this, info2.realm, info2.origin);
|
|
390514
390960
|
this.#workers.set(realm.id, realm);
|
|
390515
|
-
const realmEmitter = this.disposables.use(new
|
|
390961
|
+
const realmEmitter = this.disposables.use(new EventEmitter5(realm));
|
|
390516
390962
|
realmEmitter.once("destroyed", () => {
|
|
390517
390963
|
this.#workers.delete(realm.id);
|
|
390518
390964
|
});
|
|
@@ -390577,7 +391023,7 @@ var init_Request = __esm({
|
|
|
390577
391023
|
Request = (() => {
|
|
390578
391024
|
var _responseContentPromise, _requestBodyPromise, _error, _redirect, _response, _browsingContext, _disposables, _event, _Request_instances, initialize_fn2, session_get, _a22;
|
|
390579
391025
|
var _a21;
|
|
390580
|
-
let _classSuper =
|
|
391026
|
+
let _classSuper = EventEmitter5;
|
|
390581
391027
|
let _instanceExtraInitializers = [];
|
|
390582
391028
|
let _dispose_decorators;
|
|
390583
391029
|
return _a22 = class extends _classSuper {
|
|
@@ -390747,13 +391193,13 @@ var init_Request = __esm({
|
|
|
390747
391193
|
return __privateGet(this, _event).request.timings;
|
|
390748
391194
|
}
|
|
390749
391195
|
}, _responseContentPromise = new WeakMap(), _requestBodyPromise = new WeakMap(), _error = new WeakMap(), _redirect = new WeakMap(), _response = new WeakMap(), _browsingContext = new WeakMap(), _disposables = new WeakMap(), _event = new WeakMap(), _Request_instances = new WeakSet(), initialize_fn2 = function() {
|
|
390750
|
-
const browsingContextEmitter = __privateGet(this, _disposables).use(new
|
|
391196
|
+
const browsingContextEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _browsingContext)));
|
|
390751
391197
|
browsingContextEmitter.once("closed", ({ reason }) => {
|
|
390752
391198
|
__privateSet(this, _error, reason);
|
|
390753
391199
|
this.emit("error", __privateGet(this, _error));
|
|
390754
391200
|
this.dispose();
|
|
390755
391201
|
});
|
|
390756
|
-
const sessionEmitter = __privateGet(this, _disposables).use(new
|
|
391202
|
+
const sessionEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _Request_instances, session_get)));
|
|
390757
391203
|
sessionEmitter.on("network.beforeRequestSent", (event) => {
|
|
390758
391204
|
if (event.context !== __privateGet(this, _browsingContext).id || event.request.request !== this.id) {
|
|
390759
391205
|
return;
|
|
@@ -390858,7 +391304,7 @@ var init_UserPrompt = __esm({
|
|
|
390858
391304
|
};
|
|
390859
391305
|
UserPrompt = (() => {
|
|
390860
391306
|
var _reason, _result, _disposables, _UserPrompt_instances, initialize_fn2, session_get, _a21;
|
|
390861
|
-
let _classSuper =
|
|
391307
|
+
let _classSuper = EventEmitter5;
|
|
390862
391308
|
let _instanceExtraInitializers = [];
|
|
390863
391309
|
let _dispose_decorators;
|
|
390864
391310
|
let _handle_decorators;
|
|
@@ -390915,11 +391361,11 @@ var init_UserPrompt = __esm({
|
|
|
390915
391361
|
super[disposeSymbol]();
|
|
390916
391362
|
}
|
|
390917
391363
|
}, _reason = new WeakMap(), _result = new WeakMap(), _disposables = new WeakMap(), _UserPrompt_instances = new WeakSet(), initialize_fn2 = function() {
|
|
390918
|
-
const browserContextEmitter = __privateGet(this, _disposables).use(new
|
|
391364
|
+
const browserContextEmitter = __privateGet(this, _disposables).use(new EventEmitter5(this.browsingContext));
|
|
390919
391365
|
browserContextEmitter.once("closed", ({ reason }) => {
|
|
390920
391366
|
this.dispose(`User prompt already closed: ${reason}`);
|
|
390921
391367
|
});
|
|
390922
|
-
const sessionEmitter = __privateGet(this, _disposables).use(new
|
|
391368
|
+
const sessionEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _UserPrompt_instances, session_get)));
|
|
390923
391369
|
sessionEmitter.on("browsingContext.userPromptClosed", (parameters) => {
|
|
390924
391370
|
if (parameters.context !== this.browsingContext.id) {
|
|
390925
391371
|
return;
|
|
@@ -390993,7 +391439,7 @@ var init_BrowsingContext = __esm({
|
|
|
390993
391439
|
BrowsingContext = (() => {
|
|
390994
391440
|
var _navigation, _reason, _url2, _children, _disposables, _realms, _requests, _emulationState, _BrowsingContext_instances, initialize_fn2, session_get, createWindowRealm_fn, _a22;
|
|
390995
391441
|
var _a21;
|
|
390996
|
-
let _classSuper =
|
|
391442
|
+
let _classSuper = EventEmitter5;
|
|
390997
391443
|
let _instanceExtraInitializers = [];
|
|
390998
391444
|
let _dispose_decorators;
|
|
390999
391445
|
let _activate_decorators;
|
|
@@ -391321,11 +391767,11 @@ var init_BrowsingContext = __esm({
|
|
|
391321
391767
|
return __privateGet(this, _emulationState).javaScriptEnabled;
|
|
391322
391768
|
}
|
|
391323
391769
|
}, _navigation = new WeakMap(), _reason = new WeakMap(), _url2 = new WeakMap(), _children = new WeakMap(), _disposables = new WeakMap(), _realms = new WeakMap(), _requests = new WeakMap(), _emulationState = new WeakMap(), _BrowsingContext_instances = new WeakSet(), initialize_fn2 = function() {
|
|
391324
|
-
const userContextEmitter = __privateGet(this, _disposables).use(new
|
|
391770
|
+
const userContextEmitter = __privateGet(this, _disposables).use(new EventEmitter5(this.userContext));
|
|
391325
391771
|
userContextEmitter.once("closed", ({ reason }) => {
|
|
391326
391772
|
this.dispose(`Browsing context already closed: ${reason}`);
|
|
391327
391773
|
});
|
|
391328
|
-
const sessionEmitter = __privateGet(this, _disposables).use(new
|
|
391774
|
+
const sessionEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _BrowsingContext_instances, session_get)));
|
|
391329
391775
|
sessionEmitter.on("input.fileDialogOpened", (info2) => {
|
|
391330
391776
|
if (this.id !== info2.context) {
|
|
391331
391777
|
return;
|
|
@@ -391338,7 +391784,7 @@ var init_BrowsingContext = __esm({
|
|
|
391338
391784
|
}
|
|
391339
391785
|
const browsingContext = _a22.from(this.userContext, this, info2.context, info2.url, info2.originalOpener);
|
|
391340
391786
|
__privateGet(this, _children).set(info2.context, browsingContext);
|
|
391341
|
-
const browsingContextEmitter = __privateGet(this, _disposables).use(new
|
|
391787
|
+
const browsingContextEmitter = __privateGet(this, _disposables).use(new EventEmitter5(browsingContext));
|
|
391342
391788
|
browsingContextEmitter.once("closed", () => {
|
|
391343
391789
|
browsingContextEmitter.removeAllListeners();
|
|
391344
391790
|
__privateGet(this, _children).delete(browsingContext.id);
|
|
@@ -391385,7 +391831,7 @@ var init_BrowsingContext = __esm({
|
|
|
391385
391831
|
return;
|
|
391386
391832
|
}
|
|
391387
391833
|
__privateSet(this, _navigation, Navigation.from(this));
|
|
391388
|
-
const navigationEmitter2 = __privateGet(this, _disposables).use(new
|
|
391834
|
+
const navigationEmitter2 = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _navigation)));
|
|
391389
391835
|
for (const eventName of ["fragment", "failed", "aborted"]) {
|
|
391390
391836
|
navigationEmitter2.once(eventName, ({ url }) => {
|
|
391391
391837
|
navigationEmitter2[disposeSymbol]();
|
|
@@ -391517,7 +391963,7 @@ var init_UserContext = __esm({
|
|
|
391517
391963
|
};
|
|
391518
391964
|
UserContext = (() => {
|
|
391519
391965
|
var _a21, _reason, _browsingContexts, _disposables, _id, _UserContext_instances, initialize_fn2, session_get;
|
|
391520
|
-
let _classSuper =
|
|
391966
|
+
let _classSuper = EventEmitter5;
|
|
391521
391967
|
let _instanceExtraInitializers = [];
|
|
391522
391968
|
let _dispose_decorators;
|
|
391523
391969
|
let _createBrowsingContext_decorators;
|
|
@@ -391627,14 +392073,14 @@ var init_UserContext = __esm({
|
|
|
391627
392073
|
super[disposeSymbol]();
|
|
391628
392074
|
}
|
|
391629
392075
|
}, _reason = new WeakMap(), _browsingContexts = new WeakMap(), _disposables = new WeakMap(), _id = new WeakMap(), _UserContext_instances = new WeakSet(), initialize_fn2 = function() {
|
|
391630
|
-
const browserEmitter = __privateGet(this, _disposables).use(new
|
|
392076
|
+
const browserEmitter = __privateGet(this, _disposables).use(new EventEmitter5(this.browser));
|
|
391631
392077
|
browserEmitter.once("closed", ({ reason }) => {
|
|
391632
392078
|
this.dispose(`User context was closed: ${reason}`);
|
|
391633
392079
|
});
|
|
391634
392080
|
browserEmitter.once("disconnected", ({ reason }) => {
|
|
391635
392081
|
this.dispose(`User context was closed: ${reason}`);
|
|
391636
392082
|
});
|
|
391637
|
-
const sessionEmitter = __privateGet(this, _disposables).use(new
|
|
392083
|
+
const sessionEmitter = __privateGet(this, _disposables).use(new EventEmitter5(__privateGet(this, _UserContext_instances, session_get)));
|
|
391638
392084
|
sessionEmitter.on("browsingContext.contextCreated", (info2) => {
|
|
391639
392085
|
if (info2.parent) {
|
|
391640
392086
|
return;
|
|
@@ -391644,7 +392090,7 @@ var init_UserContext = __esm({
|
|
|
391644
392090
|
}
|
|
391645
392091
|
const browsingContext = BrowsingContext.from(this, void 0, info2.context, info2.url, info2.originalOpener);
|
|
391646
392092
|
__privateGet(this, _browsingContexts).set(browsingContext.id, browsingContext);
|
|
391647
|
-
const browsingContextEmitter = __privateGet(this, _disposables).use(new
|
|
392093
|
+
const browsingContextEmitter = __privateGet(this, _disposables).use(new EventEmitter5(browsingContext));
|
|
391648
392094
|
browsingContextEmitter.on("closed", () => {
|
|
391649
392095
|
browsingContextEmitter.removeAllListeners();
|
|
391650
392096
|
__privateGet(this, _browsingContexts).delete(browsingContext.id);
|
|
@@ -392151,7 +392597,7 @@ var init_ExposedFunction = __esm({
|
|
|
392151
392597
|
ownership: "root"
|
|
392152
392598
|
}
|
|
392153
392599
|
};
|
|
392154
|
-
const connectionEmitter = this.#disposables.use(new
|
|
392600
|
+
const connectionEmitter = this.#disposables.use(new EventEmitter5(connection));
|
|
392155
392601
|
connectionEmitter.on("script.message", this.#handleMessage);
|
|
392156
392602
|
const functionDeclaration = stringifyFunction(interpolateFunction((callback) => {
|
|
392157
392603
|
Object.assign(globalThis, {
|
|
@@ -394553,7 +394999,7 @@ var init_Page3 = __esm({
|
|
|
394553
394999
|
constructor(browserContext, browsingContext) {
|
|
394554
395000
|
super();
|
|
394555
395001
|
__privateAdd(this, _BidiPage_instances);
|
|
394556
|
-
__privateAdd(this, _trustedEmitter_accessor_storage, __runInitializers17(this, _trustedEmitter_initializers, new
|
|
395002
|
+
__privateAdd(this, _trustedEmitter_accessor_storage, __runInitializers17(this, _trustedEmitter_initializers, new EventEmitter5()));
|
|
394557
395003
|
__privateAdd(this, _browserContext, __runInitializers17(this, _trustedEmitter_extraInitializers));
|
|
394558
395004
|
__privateAdd(this, _frame);
|
|
394559
395005
|
__privateAdd(this, _viewport, null);
|
|
@@ -395454,7 +395900,7 @@ var init_BrowserContext3 = __esm({
|
|
|
395454
395900
|
constructor(browser, userContext, options3) {
|
|
395455
395901
|
super();
|
|
395456
395902
|
__privateAdd(this, _BidiBrowserContext_instances);
|
|
395457
|
-
__privateAdd(this, _trustedEmitter_accessor_storage, __runInitializers18(this, _trustedEmitter_initializers, new
|
|
395903
|
+
__privateAdd(this, _trustedEmitter_accessor_storage, __runInitializers18(this, _trustedEmitter_initializers, new EventEmitter5()));
|
|
395458
395904
|
__privateAdd(this, _browser, __runInitializers18(this, _trustedEmitter_extraInitializers));
|
|
395459
395905
|
__privateAdd(this, _defaultViewport);
|
|
395460
395906
|
// This is public because of cookies.
|
|
@@ -395786,7 +396232,7 @@ var init_Browser3 = __esm({
|
|
|
395786
396232
|
});
|
|
395787
396233
|
Browser2 = (() => {
|
|
395788
396234
|
var _closed, _reason, _disposables, _userContexts, _sharedWorkers, _Browser_instances, initialize_fn2, syncUserContexts_fn, syncBrowsingContexts_fn, createUserContext_fn, _a21;
|
|
395789
|
-
let _classSuper =
|
|
396235
|
+
let _classSuper = EventEmitter5;
|
|
395790
396236
|
let _instanceExtraInitializers = [];
|
|
395791
396237
|
let _dispose_decorators;
|
|
395792
396238
|
let _close_decorators;
|
|
@@ -395929,7 +396375,7 @@ var init_Browser3 = __esm({
|
|
|
395929
396375
|
super[disposeSymbol]();
|
|
395930
396376
|
}
|
|
395931
396377
|
}, _closed = new WeakMap(), _reason = new WeakMap(), _disposables = new WeakMap(), _userContexts = new WeakMap(), _sharedWorkers = new WeakMap(), _Browser_instances = new WeakSet(), initialize_fn2 = async function() {
|
|
395932
|
-
const sessionEmitter = __privateGet(this, _disposables).use(new
|
|
396378
|
+
const sessionEmitter = __privateGet(this, _disposables).use(new EventEmitter5(this.session));
|
|
395933
396379
|
sessionEmitter.once("ended", ({ reason }) => {
|
|
395934
396380
|
this.dispose(reason);
|
|
395935
396381
|
});
|
|
@@ -395952,7 +396398,7 @@ var init_Browser3 = __esm({
|
|
|
395952
396398
|
{
|
|
395953
396399
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
395954
396400
|
try {
|
|
395955
|
-
const sessionEmitter = __addDisposableResource19(env_1, new
|
|
396401
|
+
const sessionEmitter = __addDisposableResource19(env_1, new EventEmitter5(this.session), false);
|
|
395956
396402
|
sessionEmitter.on("browsingContext.contextCreated", (info2) => {
|
|
395957
396403
|
contextIds.add(info2.context);
|
|
395958
396404
|
});
|
|
@@ -395976,7 +396422,7 @@ var init_Browser3 = __esm({
|
|
|
395976
396422
|
}, createUserContext_fn = function(id) {
|
|
395977
396423
|
const userContext = UserContext.create(this, id);
|
|
395978
396424
|
__privateGet(this, _userContexts).set(userContext.id, userContext);
|
|
395979
|
-
const userContextEmitter = __privateGet(this, _disposables).use(new
|
|
396425
|
+
const userContextEmitter = __privateGet(this, _disposables).use(new EventEmitter5(userContext));
|
|
395980
396426
|
userContextEmitter.once("closed", () => {
|
|
395981
396427
|
userContextEmitter.removeAllListeners();
|
|
395982
396428
|
__privateGet(this, _userContexts).delete(userContext.id);
|
|
@@ -396047,7 +396493,7 @@ var init_Session = __esm({
|
|
|
396047
396493
|
};
|
|
396048
396494
|
Session = (() => {
|
|
396049
396495
|
var _reason, _disposables, _info, _connection_accessor_storage, _Session_instances, initialize_fn2, _a21;
|
|
396050
|
-
let _classSuper =
|
|
396496
|
+
let _classSuper = EventEmitter5;
|
|
396051
396497
|
let _instanceExtraInitializers = [];
|
|
396052
396498
|
let _connection_decorators;
|
|
396053
396499
|
let _connection_initializers = [];
|
|
@@ -396242,7 +396688,7 @@ var init_Browser4 = __esm({
|
|
|
396242
396688
|
super();
|
|
396243
396689
|
__privateAdd(this, _BidiBrowser_instances);
|
|
396244
396690
|
__publicField(this, "protocol", "webDriverBiDi");
|
|
396245
|
-
__privateAdd(this, _trustedEmitter_accessor_storage, __runInitializers21(this, _private_trustedEmitter_initializers, new
|
|
396691
|
+
__privateAdd(this, _trustedEmitter_accessor_storage, __runInitializers21(this, _private_trustedEmitter_initializers, new EventEmitter5()));
|
|
396246
396692
|
__privateAdd(this, _process, __runInitializers21(this, _private_trustedEmitter_extraInitializers));
|
|
396247
396693
|
__privateAdd(this, _closeCallback);
|
|
396248
396694
|
__privateAdd(this, _browserCore);
|
|
@@ -424380,7 +424826,7 @@ var init_httpUtil = __esm({
|
|
|
424380
424826
|
|
|
424381
424827
|
// node_modules/@puppeteer/browsers/lib/esm/browser-data/chrome.js
|
|
424382
424828
|
import { execSync as execSync2 } from "node:child_process";
|
|
424383
|
-
import
|
|
424829
|
+
import path23 from "node:path";
|
|
424384
424830
|
function folder(platform5) {
|
|
424385
424831
|
switch (platform5) {
|
|
424386
424832
|
case BrowserPlatform.LINUX_ARM:
|
|
@@ -424406,13 +424852,13 @@ function relativeExecutablePath(platform5, _buildId) {
|
|
|
424406
424852
|
switch (platform5) {
|
|
424407
424853
|
case BrowserPlatform.MAC:
|
|
424408
424854
|
case BrowserPlatform.MAC_ARM:
|
|
424409
|
-
return
|
|
424855
|
+
return path23.join("chrome-" + folder(platform5), "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing");
|
|
424410
424856
|
case BrowserPlatform.LINUX_ARM:
|
|
424411
424857
|
case BrowserPlatform.LINUX:
|
|
424412
|
-
return
|
|
424858
|
+
return path23.join("chrome-linux64", "chrome");
|
|
424413
424859
|
case BrowserPlatform.WIN32:
|
|
424414
424860
|
case BrowserPlatform.WIN64:
|
|
424415
|
-
return
|
|
424861
|
+
return path23.join("chrome-" + folder(platform5), "chrome.exe");
|
|
424416
424862
|
}
|
|
424417
424863
|
}
|
|
424418
424864
|
async function getLastKnownGoodReleaseForChannel(channel) {
|
|
@@ -424464,7 +424910,7 @@ function getChromeWindowsLocation(channel, locationsPrefixes) {
|
|
|
424464
424910
|
break;
|
|
424465
424911
|
}
|
|
424466
424912
|
return [...locationsPrefixes.values()].map((l2) => {
|
|
424467
|
-
return
|
|
424913
|
+
return path23.win32.join(l2, suffix);
|
|
424468
424914
|
});
|
|
424469
424915
|
}
|
|
424470
424916
|
function getWslLocation(channel) {
|
|
@@ -424592,7 +425038,7 @@ var init_chrome = __esm({
|
|
|
424592
425038
|
});
|
|
424593
425039
|
|
|
424594
425040
|
// node_modules/@puppeteer/browsers/lib/esm/browser-data/chrome-headless-shell.js
|
|
424595
|
-
import
|
|
425041
|
+
import path24 from "node:path";
|
|
424596
425042
|
function folder2(platform5) {
|
|
424597
425043
|
switch (platform5) {
|
|
424598
425044
|
case BrowserPlatform.LINUX_ARM:
|
|
@@ -424622,13 +425068,13 @@ function relativeExecutablePath2(platform5, _buildId) {
|
|
|
424622
425068
|
switch (platform5) {
|
|
424623
425069
|
case BrowserPlatform.MAC:
|
|
424624
425070
|
case BrowserPlatform.MAC_ARM:
|
|
424625
|
-
return
|
|
425071
|
+
return path24.join("chrome-headless-shell-" + folder2(platform5), "chrome-headless-shell");
|
|
424626
425072
|
case BrowserPlatform.LINUX_ARM:
|
|
424627
425073
|
case BrowserPlatform.LINUX:
|
|
424628
|
-
return
|
|
425074
|
+
return path24.join("chrome-headless-shell-linux64", "chrome-headless-shell");
|
|
424629
425075
|
case BrowserPlatform.WIN32:
|
|
424630
425076
|
case BrowserPlatform.WIN64:
|
|
424631
|
-
return
|
|
425077
|
+
return path24.join("chrome-headless-shell-" + folder2(platform5), "chrome-headless-shell.exe");
|
|
424632
425078
|
}
|
|
424633
425079
|
}
|
|
424634
425080
|
var init_chrome_headless_shell = __esm({
|
|
@@ -424639,7 +425085,7 @@ var init_chrome_headless_shell = __esm({
|
|
|
424639
425085
|
});
|
|
424640
425086
|
|
|
424641
425087
|
// node_modules/@puppeteer/browsers/lib/esm/browser-data/chromedriver.js
|
|
424642
|
-
import
|
|
425088
|
+
import path25 from "node:path";
|
|
424643
425089
|
function folder3(platform5) {
|
|
424644
425090
|
switch (platform5) {
|
|
424645
425091
|
case BrowserPlatform.LINUX_ARM:
|
|
@@ -424665,13 +425111,13 @@ function relativeExecutablePath3(platform5, _buildId) {
|
|
|
424665
425111
|
switch (platform5) {
|
|
424666
425112
|
case BrowserPlatform.MAC:
|
|
424667
425113
|
case BrowserPlatform.MAC_ARM:
|
|
424668
|
-
return
|
|
425114
|
+
return path25.join("chromedriver-" + folder3(platform5), "chromedriver");
|
|
424669
425115
|
case BrowserPlatform.LINUX_ARM:
|
|
424670
425116
|
case BrowserPlatform.LINUX:
|
|
424671
|
-
return
|
|
425117
|
+
return path25.join("chromedriver-linux64", "chromedriver");
|
|
424672
425118
|
case BrowserPlatform.WIN32:
|
|
424673
425119
|
case BrowserPlatform.WIN64:
|
|
424674
|
-
return
|
|
425120
|
+
return path25.join("chromedriver-" + folder3(platform5), "chromedriver.exe");
|
|
424675
425121
|
}
|
|
424676
425122
|
}
|
|
424677
425123
|
var init_chromedriver = __esm({
|
|
@@ -424682,7 +425128,7 @@ var init_chromedriver = __esm({
|
|
|
424682
425128
|
});
|
|
424683
425129
|
|
|
424684
425130
|
// node_modules/@puppeteer/browsers/lib/esm/browser-data/chromium.js
|
|
424685
|
-
import
|
|
425131
|
+
import path26 from "node:path";
|
|
424686
425132
|
function archive(platform5, buildId) {
|
|
424687
425133
|
switch (platform5) {
|
|
424688
425134
|
case BrowserPlatform.LINUX_ARM:
|
|
@@ -424721,13 +425167,13 @@ function relativeExecutablePath4(platform5, _buildId) {
|
|
|
424721
425167
|
switch (platform5) {
|
|
424722
425168
|
case BrowserPlatform.MAC:
|
|
424723
425169
|
case BrowserPlatform.MAC_ARM:
|
|
424724
|
-
return
|
|
425170
|
+
return path26.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium");
|
|
424725
425171
|
case BrowserPlatform.LINUX_ARM:
|
|
424726
425172
|
case BrowserPlatform.LINUX:
|
|
424727
|
-
return
|
|
425173
|
+
return path26.join("chrome-linux", "chrome");
|
|
424728
425174
|
case BrowserPlatform.WIN32:
|
|
424729
425175
|
case BrowserPlatform.WIN64:
|
|
424730
|
-
return
|
|
425176
|
+
return path26.join("chrome-win", "chrome.exe");
|
|
424731
425177
|
}
|
|
424732
425178
|
}
|
|
424733
425179
|
async function resolveBuildId2(platform5) {
|
|
@@ -424744,8 +425190,8 @@ var init_chromium = __esm({
|
|
|
424744
425190
|
});
|
|
424745
425191
|
|
|
424746
425192
|
// node_modules/@puppeteer/browsers/lib/esm/browser-data/firefox.js
|
|
424747
|
-
import
|
|
424748
|
-
import
|
|
425193
|
+
import fs20 from "node:fs";
|
|
425194
|
+
import path27 from "node:path";
|
|
424749
425195
|
function getFormat(buildId) {
|
|
424750
425196
|
const majorVersion = Number(buildId.split(".").shift());
|
|
424751
425197
|
return majorVersion >= 135 ? "xz" : "bz2";
|
|
@@ -424841,13 +425287,13 @@ function relativeExecutablePath5(platform5, buildId) {
|
|
|
424841
425287
|
switch (platform5) {
|
|
424842
425288
|
case BrowserPlatform.MAC_ARM:
|
|
424843
425289
|
case BrowserPlatform.MAC:
|
|
424844
|
-
return
|
|
425290
|
+
return path27.join("Firefox Nightly.app", "Contents", "MacOS", "firefox");
|
|
424845
425291
|
case BrowserPlatform.LINUX_ARM:
|
|
424846
425292
|
case BrowserPlatform.LINUX:
|
|
424847
|
-
return
|
|
425293
|
+
return path27.join("firefox", "firefox");
|
|
424848
425294
|
case BrowserPlatform.WIN32:
|
|
424849
425295
|
case BrowserPlatform.WIN64:
|
|
424850
|
-
return
|
|
425296
|
+
return path27.join("firefox", "firefox.exe");
|
|
424851
425297
|
}
|
|
424852
425298
|
case FirefoxChannel.BETA:
|
|
424853
425299
|
case FirefoxChannel.DEVEDITION:
|
|
@@ -424856,13 +425302,13 @@ function relativeExecutablePath5(platform5, buildId) {
|
|
|
424856
425302
|
switch (platform5) {
|
|
424857
425303
|
case BrowserPlatform.MAC_ARM:
|
|
424858
425304
|
case BrowserPlatform.MAC:
|
|
424859
|
-
return
|
|
425305
|
+
return path27.join("Firefox.app", "Contents", "MacOS", "firefox");
|
|
424860
425306
|
case BrowserPlatform.LINUX_ARM:
|
|
424861
425307
|
case BrowserPlatform.LINUX:
|
|
424862
|
-
return
|
|
425308
|
+
return path27.join("firefox", "firefox");
|
|
424863
425309
|
case BrowserPlatform.WIN32:
|
|
424864
425310
|
case BrowserPlatform.WIN64:
|
|
424865
|
-
return
|
|
425311
|
+
return path27.join("core", "firefox.exe");
|
|
424866
425312
|
}
|
|
424867
425313
|
}
|
|
424868
425314
|
}
|
|
@@ -424882,8 +425328,8 @@ async function resolveBuildId3(channel = FirefoxChannel.NIGHTLY) {
|
|
|
424882
425328
|
return channel + "_" + version2;
|
|
424883
425329
|
}
|
|
424884
425330
|
async function createProfile2(options3) {
|
|
424885
|
-
if (!
|
|
424886
|
-
await
|
|
425331
|
+
if (!fs20.existsSync(options3.path)) {
|
|
425332
|
+
await fs20.promises.mkdir(options3.path, {
|
|
424887
425333
|
recursive: true
|
|
424888
425334
|
});
|
|
424889
425335
|
}
|
|
@@ -425060,20 +425506,20 @@ function defaultProfilePreferences(extraPrefs) {
|
|
|
425060
425506
|
return Object.assign(defaultPrefs, extraPrefs);
|
|
425061
425507
|
}
|
|
425062
425508
|
async function backupFile(input2) {
|
|
425063
|
-
if (!
|
|
425509
|
+
if (!fs20.existsSync(input2)) {
|
|
425064
425510
|
return;
|
|
425065
425511
|
}
|
|
425066
|
-
await
|
|
425512
|
+
await fs20.promises.copyFile(input2, input2 + ".puppeteer");
|
|
425067
425513
|
}
|
|
425068
425514
|
async function syncPreferences(options3) {
|
|
425069
|
-
const prefsPath =
|
|
425070
|
-
const userPath =
|
|
425515
|
+
const prefsPath = path27.join(options3.path, "prefs.js");
|
|
425516
|
+
const userPath = path27.join(options3.path, "user.js");
|
|
425071
425517
|
const lines = Object.entries(options3.preferences).map(([key, value]) => {
|
|
425072
425518
|
return `user_pref(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
|
|
425073
425519
|
});
|
|
425074
425520
|
const result2 = await Promise.allSettled([
|
|
425075
425521
|
backupFile(userPath).then(async () => {
|
|
425076
|
-
await
|
|
425522
|
+
await fs20.promises.writeFile(userPath, lines.join("\n"));
|
|
425077
425523
|
}),
|
|
425078
425524
|
backupFile(prefsPath)
|
|
425079
425525
|
]);
|
|
@@ -425284,10 +425730,10 @@ var init_browser_data = __esm({
|
|
|
425284
425730
|
});
|
|
425285
425731
|
|
|
425286
425732
|
// node_modules/@puppeteer/browsers/lib/esm/detectPlatform.js
|
|
425287
|
-
import
|
|
425733
|
+
import os9 from "node:os";
|
|
425288
425734
|
function detectBrowserPlatform() {
|
|
425289
|
-
const platform5 =
|
|
425290
|
-
const arch =
|
|
425735
|
+
const platform5 = os9.platform();
|
|
425736
|
+
const arch = os9.arch();
|
|
425291
425737
|
switch (platform5) {
|
|
425292
425738
|
case "darwin":
|
|
425293
425739
|
return arch === "arm64" ? BrowserPlatform.MAC_ARM : BrowserPlatform.MAC;
|
|
@@ -425295,7 +425741,7 @@ function detectBrowserPlatform() {
|
|
|
425295
425741
|
return arch === "arm64" ? BrowserPlatform.LINUX_ARM : BrowserPlatform.LINUX;
|
|
425296
425742
|
case "win32":
|
|
425297
425743
|
return arch === "x64" || // Windows 11 for ARM supports x64 emulation
|
|
425298
|
-
arch === "arm64" && isWindows11(
|
|
425744
|
+
arch === "arm64" && isWindows11(os9.release()) ? BrowserPlatform.WIN64 : BrowserPlatform.WIN32;
|
|
425299
425745
|
default:
|
|
425300
425746
|
return void 0;
|
|
425301
425747
|
}
|
|
@@ -425317,11 +425763,11 @@ var init_detectPlatform = __esm({
|
|
|
425317
425763
|
});
|
|
425318
425764
|
|
|
425319
425765
|
// node_modules/@puppeteer/browsers/lib/esm/Cache.js
|
|
425320
|
-
import
|
|
425321
|
-
import
|
|
425322
|
-
import
|
|
425766
|
+
import fs21 from "node:fs";
|
|
425767
|
+
import os10 from "node:os";
|
|
425768
|
+
import path28 from "node:path";
|
|
425323
425769
|
function parseFolderPath(folderPath) {
|
|
425324
|
-
const name =
|
|
425770
|
+
const name = path28.basename(folderPath);
|
|
425325
425771
|
const splits = name.split("-");
|
|
425326
425772
|
if (splits.length !== 2) {
|
|
425327
425773
|
return;
|
|
@@ -425385,17 +425831,17 @@ var init_Cache = __esm({
|
|
|
425385
425831
|
return this.#rootDir;
|
|
425386
425832
|
}
|
|
425387
425833
|
browserRoot(browser) {
|
|
425388
|
-
return
|
|
425834
|
+
return path28.join(this.#rootDir, browser);
|
|
425389
425835
|
}
|
|
425390
425836
|
metadataFile(browser) {
|
|
425391
|
-
return
|
|
425837
|
+
return path28.join(this.browserRoot(browser), ".metadata");
|
|
425392
425838
|
}
|
|
425393
425839
|
readMetadata(browser) {
|
|
425394
425840
|
const metatadaPath = this.metadataFile(browser);
|
|
425395
|
-
if (!
|
|
425841
|
+
if (!fs21.existsSync(metatadaPath)) {
|
|
425396
425842
|
return { aliases: {} };
|
|
425397
425843
|
}
|
|
425398
|
-
const data = JSON.parse(
|
|
425844
|
+
const data = JSON.parse(fs21.readFileSync(metatadaPath, "utf8"));
|
|
425399
425845
|
if (typeof data !== "object") {
|
|
425400
425846
|
throw new Error(".metadata is not an object");
|
|
425401
425847
|
}
|
|
@@ -425403,8 +425849,8 @@ var init_Cache = __esm({
|
|
|
425403
425849
|
}
|
|
425404
425850
|
writeMetadata(browser, metadata) {
|
|
425405
425851
|
const metatadaPath = this.metadataFile(browser);
|
|
425406
|
-
|
|
425407
|
-
|
|
425852
|
+
fs21.mkdirSync(path28.dirname(metatadaPath), { recursive: true });
|
|
425853
|
+
fs21.writeFileSync(metatadaPath, JSON.stringify(metadata, null, 2));
|
|
425408
425854
|
}
|
|
425409
425855
|
resolveAlias(browser, alias) {
|
|
425410
425856
|
const metadata = this.readMetadata(browser);
|
|
@@ -425414,10 +425860,10 @@ var init_Cache = __esm({
|
|
|
425414
425860
|
return metadata.aliases[alias];
|
|
425415
425861
|
}
|
|
425416
425862
|
installationDir(browser, platform5, buildId) {
|
|
425417
|
-
return
|
|
425863
|
+
return path28.join(this.browserRoot(browser), `${platform5}-${buildId}`);
|
|
425418
425864
|
}
|
|
425419
425865
|
clear() {
|
|
425420
|
-
|
|
425866
|
+
fs21.rmSync(this.#rootDir, {
|
|
425421
425867
|
force: true,
|
|
425422
425868
|
recursive: true,
|
|
425423
425869
|
maxRetries: 10,
|
|
@@ -425431,7 +425877,7 @@ var init_Cache = __esm({
|
|
|
425431
425877
|
delete metadata.aliases[alias];
|
|
425432
425878
|
}
|
|
425433
425879
|
}
|
|
425434
|
-
|
|
425880
|
+
fs21.rmSync(this.installationDir(browser, platform5, buildId), {
|
|
425435
425881
|
force: true,
|
|
425436
425882
|
recursive: true,
|
|
425437
425883
|
maxRetries: 10,
|
|
@@ -425439,17 +425885,17 @@ var init_Cache = __esm({
|
|
|
425439
425885
|
});
|
|
425440
425886
|
}
|
|
425441
425887
|
getInstalledBrowsers() {
|
|
425442
|
-
if (!
|
|
425888
|
+
if (!fs21.existsSync(this.#rootDir)) {
|
|
425443
425889
|
return [];
|
|
425444
425890
|
}
|
|
425445
|
-
const types =
|
|
425891
|
+
const types = fs21.readdirSync(this.#rootDir);
|
|
425446
425892
|
const browsers = types.filter((t) => {
|
|
425447
425893
|
return Object.values(Browser3).includes(t);
|
|
425448
425894
|
});
|
|
425449
425895
|
return browsers.flatMap((browser) => {
|
|
425450
|
-
const files =
|
|
425896
|
+
const files = fs21.readdirSync(this.browserRoot(browser));
|
|
425451
425897
|
return files.map((file) => {
|
|
425452
|
-
const result2 = parseFolderPath(
|
|
425898
|
+
const result2 = parseFolderPath(path28.join(this.browserRoot(browser), file));
|
|
425453
425899
|
if (!result2) {
|
|
425454
425900
|
return null;
|
|
425455
425901
|
}
|
|
@@ -425462,7 +425908,7 @@ var init_Cache = __esm({
|
|
|
425462
425908
|
computeExecutablePath(options3) {
|
|
425463
425909
|
options3.platform ??= detectBrowserPlatform();
|
|
425464
425910
|
if (!options3.platform) {
|
|
425465
|
-
throw new Error(`Cannot download a binary for the provided platform: ${
|
|
425911
|
+
throw new Error(`Cannot download a binary for the provided platform: ${os10.platform()} (${os10.arch()})`);
|
|
425466
425912
|
}
|
|
425467
425913
|
try {
|
|
425468
425914
|
options3.buildId = this.resolveAlias(options3.browser, options3.buildId) ?? options3.buildId;
|
|
@@ -425470,7 +425916,7 @@ var init_Cache = __esm({
|
|
|
425470
425916
|
debugCache("could not read .metadata file for the browser");
|
|
425471
425917
|
}
|
|
425472
425918
|
const installationDir = this.installationDir(options3.browser, options3.platform, options3.buildId);
|
|
425473
|
-
return
|
|
425919
|
+
return path28.join(installationDir, executablePathByBrowser[options3.browser](options3.platform, options3.buildId));
|
|
425474
425920
|
}
|
|
425475
425921
|
};
|
|
425476
425922
|
}
|
|
@@ -425486,9 +425932,9 @@ var init_debug = __esm({
|
|
|
425486
425932
|
|
|
425487
425933
|
// node_modules/@puppeteer/browsers/lib/esm/launch.js
|
|
425488
425934
|
import childProcess from "node:child_process";
|
|
425489
|
-
import { EventEmitter as
|
|
425935
|
+
import { EventEmitter as EventEmitter7 } from "node:events";
|
|
425490
425936
|
import { accessSync } from "node:fs";
|
|
425491
|
-
import
|
|
425937
|
+
import os11 from "node:os";
|
|
425492
425938
|
import readline from "node:readline";
|
|
425493
425939
|
function computeExecutablePath(options3) {
|
|
425494
425940
|
if (options3.cacheDir === null) {
|
|
@@ -425503,7 +425949,7 @@ function computeExecutablePath(options3) {
|
|
|
425503
425949
|
function computeSystemExecutablePath(options3) {
|
|
425504
425950
|
options3.platform ??= detectBrowserPlatform();
|
|
425505
425951
|
if (!options3.platform) {
|
|
425506
|
-
throw new Error(`Cannot download a binary for the provided platform: ${
|
|
425952
|
+
throw new Error(`Cannot download a binary for the provided platform: ${os11.platform()} (${os11.arch()})`);
|
|
425507
425953
|
}
|
|
425508
425954
|
const paths = resolveSystemExecutablePaths2(options3.browser, options3.platform, options3.channel);
|
|
425509
425955
|
for (const path49 of paths) {
|
|
@@ -425610,7 +426056,7 @@ var init_launch = __esm({
|
|
|
425610
426056
|
#browserProcessExiting;
|
|
425611
426057
|
#logs = [];
|
|
425612
426058
|
#maxLogLinesSize = 1e3;
|
|
425613
|
-
#lineEmitter = new
|
|
426059
|
+
#lineEmitter = new EventEmitter7();
|
|
425614
426060
|
constructor(opts) {
|
|
425615
426061
|
var _a21, _b14;
|
|
425616
426062
|
this.#executablePath = opts.executablePath;
|
|
@@ -425966,7 +426412,7 @@ var require_progress = __commonJS({
|
|
|
425966
426412
|
import { spawnSync, spawn as spawn4 } from "node:child_process";
|
|
425967
426413
|
import { createReadStream } from "node:fs";
|
|
425968
426414
|
import { mkdir as mkdir3, readdir as readdir2 } from "node:fs/promises";
|
|
425969
|
-
import * as
|
|
426415
|
+
import * as path29 from "node:path";
|
|
425970
426416
|
import { Stream as Stream2 } from "node:stream";
|
|
425971
426417
|
var import_debug4, debugFileUtil;
|
|
425972
426418
|
var init_fileUtil = __esm({
|
|
@@ -425981,12 +426427,12 @@ import assert3 from "node:assert";
|
|
|
425981
426427
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
425982
426428
|
import { existsSync as existsSync15, readFileSync as readFileSync14 } from "node:fs";
|
|
425983
426429
|
import { mkdir as mkdir4, unlink as unlink2 } from "node:fs/promises";
|
|
425984
|
-
import
|
|
425985
|
-
import
|
|
426430
|
+
import os12 from "node:os";
|
|
426431
|
+
import path30 from "node:path";
|
|
425986
426432
|
async function uninstall(options3) {
|
|
425987
426433
|
options3.platform ??= detectBrowserPlatform();
|
|
425988
426434
|
if (!options3.platform) {
|
|
425989
|
-
throw new Error(`Cannot detect the browser platform for: ${
|
|
426435
|
+
throw new Error(`Cannot detect the browser platform for: ${os12.platform()} (${os12.arch()})`);
|
|
425990
426436
|
}
|
|
425991
426437
|
new Cache(options3.cacheDir).uninstall(options3.browser, options3.platform, options3.buildId);
|
|
425992
426438
|
}
|
|
@@ -426053,7 +426499,7 @@ var init_PipeTransport = __esm({
|
|
|
426053
426499
|
const pipeReadEmitter = this.#subscriptions.use(
|
|
426054
426500
|
// NodeJS event emitters don't support `*` so we need to typecast
|
|
426055
426501
|
// As long as we don't use it we should be OK.
|
|
426056
|
-
new
|
|
426502
|
+
new EventEmitter5(pipeRead)
|
|
426057
426503
|
);
|
|
426058
426504
|
pipeReadEmitter.on("data", (buffer) => {
|
|
426059
426505
|
return this.#dispatch(buffer);
|
|
@@ -426067,7 +426513,7 @@ var init_PipeTransport = __esm({
|
|
|
426067
426513
|
const pipeWriteEmitter = this.#subscriptions.use(
|
|
426068
426514
|
// NodeJS event emitters don't support `*` so we need to typecast
|
|
426069
426515
|
// As long as we don't use it we should be OK.
|
|
426070
|
-
new
|
|
426516
|
+
new EventEmitter5(pipeWrite)
|
|
426071
426517
|
);
|
|
426072
426518
|
pipeWriteEmitter.on("error", debugError);
|
|
426073
426519
|
}
|
|
@@ -426416,9 +426862,9 @@ For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides
|
|
|
426416
426862
|
});
|
|
426417
426863
|
|
|
426418
426864
|
// node_modules/puppeteer-core/lib/esm/puppeteer/node/util/fs.js
|
|
426419
|
-
import
|
|
426865
|
+
import fs22 from "node:fs";
|
|
426420
426866
|
async function rm(path49) {
|
|
426421
|
-
await
|
|
426867
|
+
await fs22.promises.rm(path49, rmOptions);
|
|
426422
426868
|
}
|
|
426423
426869
|
var rmOptions;
|
|
426424
426870
|
var init_fs = __esm({
|
|
@@ -426433,8 +426879,8 @@ var init_fs = __esm({
|
|
|
426433
426879
|
|
|
426434
426880
|
// node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js
|
|
426435
426881
|
import { mkdtemp } from "node:fs/promises";
|
|
426436
|
-
import
|
|
426437
|
-
import
|
|
426882
|
+
import os13 from "node:os";
|
|
426883
|
+
import path31 from "node:path";
|
|
426438
426884
|
function convertPuppeteerChannelToBrowsersChannel(channel) {
|
|
426439
426885
|
switch (channel) {
|
|
426440
426886
|
case "chrome":
|
|
@@ -426484,7 +426930,7 @@ var init_ChromeLauncher = __esm({
|
|
|
426484
426930
|
launch(options3 = {}) {
|
|
426485
426931
|
var _a21;
|
|
426486
426932
|
if (this.puppeteer.configuration.logLevel === "warn" && process.platform === "darwin" && process.arch === "x64") {
|
|
426487
|
-
const cpus =
|
|
426933
|
+
const cpus = os13.cpus();
|
|
426488
426934
|
if ((_a21 = cpus[0]) == null ? void 0 : _a21.model.includes("Apple")) {
|
|
426489
426935
|
console.warn([
|
|
426490
426936
|
"\x1B[1m\x1B[43m\x1B[30m",
|
|
@@ -426629,7 +427075,7 @@ var init_ChromeLauncher = __esm({
|
|
|
426629
427075
|
});
|
|
426630
427076
|
const { devtools = false, headless = !devtools, args: args2 = [], userDataDir, enableExtensions = false } = options3;
|
|
426631
427077
|
if (userDataDir) {
|
|
426632
|
-
chromeArguments.push(`--user-data-dir=${
|
|
427078
|
+
chromeArguments.push(`--user-data-dir=${path31.resolve(userDataDir)}`);
|
|
426633
427079
|
}
|
|
426634
427080
|
if (devtools) {
|
|
426635
427081
|
chromeArguments.push("--auto-open-devtools-for-tabs");
|
|
@@ -426661,10 +427107,10 @@ var init_ChromeLauncher = __esm({
|
|
|
426661
427107
|
});
|
|
426662
427108
|
|
|
426663
427109
|
// node_modules/puppeteer-core/lib/esm/puppeteer/node/FirefoxLauncher.js
|
|
426664
|
-
import
|
|
427110
|
+
import fs23 from "node:fs";
|
|
426665
427111
|
import { rename, unlink as unlink3, mkdtemp as mkdtemp2 } from "node:fs/promises";
|
|
426666
|
-
import
|
|
426667
|
-
import
|
|
427112
|
+
import os14 from "node:os";
|
|
427113
|
+
import path32 from "node:path";
|
|
426668
427114
|
var FirefoxLauncher;
|
|
426669
427115
|
var init_FirefoxLauncher = __esm({
|
|
426670
427116
|
"node_modules/puppeteer-core/lib/esm/puppeteer/node/FirefoxLauncher.js"() {
|
|
@@ -426759,9 +427205,9 @@ var init_FirefoxLauncher = __esm({
|
|
|
426759
427205
|
const backupSuffix = ".puppeteer";
|
|
426760
427206
|
const backupFiles = ["prefs.js", "user.js"];
|
|
426761
427207
|
const results = await Promise.allSettled(backupFiles.map(async (file) => {
|
|
426762
|
-
const prefsBackupPath =
|
|
426763
|
-
if (
|
|
426764
|
-
const prefsPath =
|
|
427208
|
+
const prefsBackupPath = path32.join(userDataDir, file + backupSuffix);
|
|
427209
|
+
if (fs23.existsSync(prefsBackupPath)) {
|
|
427210
|
+
const prefsPath = path32.join(userDataDir, file);
|
|
426765
427211
|
await unlink3(prefsPath);
|
|
426766
427212
|
await rename(prefsBackupPath, prefsPath);
|
|
426767
427213
|
}
|
|
@@ -426786,7 +427232,7 @@ var init_FirefoxLauncher = __esm({
|
|
|
426786
427232
|
defaultArgs(options3 = {}) {
|
|
426787
427233
|
const { devtools = false, headless = !devtools, args: args2 = [], userDataDir = null } = options3;
|
|
426788
427234
|
const firefoxArguments = [];
|
|
426789
|
-
switch (
|
|
427235
|
+
switch (os14.platform()) {
|
|
426790
427236
|
case "darwin":
|
|
426791
427237
|
firefoxArguments.push("--foreground");
|
|
426792
427238
|
break;
|
|
@@ -427074,8 +427520,8 @@ var init_PuppeteerNode = __esm({
|
|
|
427074
427520
|
|
|
427075
427521
|
// node_modules/puppeteer-core/lib/esm/puppeteer/node/ScreenRecorder.js
|
|
427076
427522
|
import { spawn as spawn5, spawnSync as spawnSync3 } from "node:child_process";
|
|
427077
|
-
import
|
|
427078
|
-
import
|
|
427523
|
+
import fs24 from "node:fs";
|
|
427524
|
+
import os15 from "node:os";
|
|
427079
427525
|
import { dirname as dirname7 } from "node:path";
|
|
427080
427526
|
import { PassThrough as PassThrough3 } from "node:stream";
|
|
427081
427527
|
var import_debug6, __runInitializers23, __esDecorate23, __setFunctionName6, CRF_VALUE, DEFAULT_FPS, debugFfmpeg, ScreenRecorder;
|
|
@@ -427184,7 +427630,7 @@ var init_ScreenRecorder = __esm({
|
|
|
427184
427630
|
filters.push(formatArgs.splice(vf, 2).at(-1) ?? "");
|
|
427185
427631
|
}
|
|
427186
427632
|
if (path49) {
|
|
427187
|
-
|
|
427633
|
+
fs24.mkdirSync(dirname7(path49), { recursive: overwrite });
|
|
427188
427634
|
}
|
|
427189
427635
|
__privateSet(this, _process, spawn5(
|
|
427190
427636
|
ffmpegPath,
|
|
@@ -427288,7 +427734,7 @@ var init_ScreenRecorder = __esm({
|
|
|
427288
427734
|
"-deadline",
|
|
427289
427735
|
"realtime",
|
|
427290
427736
|
"-cpu-used",
|
|
427291
|
-
`${Math.min(
|
|
427737
|
+
`${Math.min(os15.cpus().length / 2, 8)}`
|
|
427292
427738
|
]
|
|
427293
427739
|
];
|
|
427294
427740
|
switch (format4) {
|
|
@@ -427369,8 +427815,8 @@ var init_puppeteer = __esm({
|
|
|
427369
427815
|
});
|
|
427370
427816
|
|
|
427371
427817
|
// node_modules/puppeteer-core/lib/esm/puppeteer/puppeteer-core.js
|
|
427372
|
-
import
|
|
427373
|
-
import
|
|
427818
|
+
import fs25 from "node:fs";
|
|
427819
|
+
import path33 from "node:path";
|
|
427374
427820
|
var puppeteer, connect, defaultArgs, executablePath, launch2, puppeteer_core_default;
|
|
427375
427821
|
var init_puppeteer_core = __esm({
|
|
427376
427822
|
"node_modules/puppeteer-core/lib/esm/puppeteer/puppeteer-core.js"() {
|
|
@@ -427378,8 +427824,8 @@ var init_puppeteer_core = __esm({
|
|
|
427378
427824
|
init_environment2();
|
|
427379
427825
|
init_puppeteer();
|
|
427380
427826
|
environment.value = {
|
|
427381
|
-
fs:
|
|
427382
|
-
path:
|
|
427827
|
+
fs: fs25,
|
|
427828
|
+
path: path33,
|
|
427383
427829
|
ScreenRecorder
|
|
427384
427830
|
};
|
|
427385
427831
|
puppeteer = new PuppeteerNode({
|
|
@@ -430011,8 +430457,8 @@ var codebaseDatabase_exports = {};
|
|
|
430011
430457
|
__export(codebaseDatabase_exports, {
|
|
430012
430458
|
CodebaseDatabase: () => CodebaseDatabase
|
|
430013
430459
|
});
|
|
430014
|
-
import
|
|
430015
|
-
import
|
|
430460
|
+
import path34 from "node:path";
|
|
430461
|
+
import fs26 from "node:fs";
|
|
430016
430462
|
var import_sql, CodebaseDatabase;
|
|
430017
430463
|
var init_codebaseDatabase = __esm({
|
|
430018
430464
|
"dist/utils/codebase/codebaseDatabase.js"() {
|
|
@@ -430039,11 +430485,11 @@ var init_codebaseDatabase = __esm({
|
|
|
430039
430485
|
writable: true,
|
|
430040
430486
|
value: false
|
|
430041
430487
|
});
|
|
430042
|
-
const snowDir =
|
|
430043
|
-
if (!
|
|
430044
|
-
|
|
430488
|
+
const snowDir = path34.join(projectRoot, ".snow", "codebase");
|
|
430489
|
+
if (!fs26.existsSync(snowDir)) {
|
|
430490
|
+
fs26.mkdirSync(snowDir, { recursive: true });
|
|
430045
430491
|
}
|
|
430046
|
-
this.dbPath =
|
|
430492
|
+
this.dbPath = path34.join(snowDir, "embeddings.db");
|
|
430047
430493
|
}
|
|
430048
430494
|
/**
|
|
430049
430495
|
* Initialize database and create tables
|
|
@@ -430053,8 +430499,8 @@ var init_codebaseDatabase = __esm({
|
|
|
430053
430499
|
return;
|
|
430054
430500
|
try {
|
|
430055
430501
|
const SQL = await (0, import_sql.default)();
|
|
430056
|
-
if (
|
|
430057
|
-
const buffer =
|
|
430502
|
+
if (fs26.existsSync(this.dbPath)) {
|
|
430503
|
+
const buffer = fs26.readFileSync(this.dbPath);
|
|
430058
430504
|
this.db = new SQL.Database(buffer);
|
|
430059
430505
|
} else {
|
|
430060
430506
|
this.db = new SQL.Database();
|
|
@@ -430113,7 +430559,7 @@ var init_codebaseDatabase = __esm({
|
|
|
430113
430559
|
if (!this.db)
|
|
430114
430560
|
return;
|
|
430115
430561
|
const data = this.db.export();
|
|
430116
|
-
|
|
430562
|
+
fs26.writeFileSync(this.dbPath, data);
|
|
430117
430563
|
}
|
|
430118
430564
|
/**
|
|
430119
430565
|
* Insert or update code chunks (batch operation)
|
|
@@ -430590,12 +431036,12 @@ var init_embedding = __esm({
|
|
|
430590
431036
|
});
|
|
430591
431037
|
|
|
430592
431038
|
// dist/utils/codebase/codebaseSearchEvents.js
|
|
430593
|
-
import { EventEmitter as
|
|
431039
|
+
import { EventEmitter as EventEmitter8 } from "events";
|
|
430594
431040
|
var CodebaseSearchEventEmitter, codebaseSearchEvents;
|
|
430595
431041
|
var init_codebaseSearchEvents = __esm({
|
|
430596
431042
|
"dist/utils/codebase/codebaseSearchEvents.js"() {
|
|
430597
431043
|
"use strict";
|
|
430598
|
-
CodebaseSearchEventEmitter = class extends
|
|
431044
|
+
CodebaseSearchEventEmitter = class extends EventEmitter8 {
|
|
430599
431045
|
emitSearchEvent(event) {
|
|
430600
431046
|
this.emit("codebase-search", event);
|
|
430601
431047
|
}
|
|
@@ -430610,48 +431056,14 @@ var init_codebaseSearchEvents = __esm({
|
|
|
430610
431056
|
}
|
|
430611
431057
|
});
|
|
430612
431058
|
|
|
430613
|
-
// dist/utils/session/projectUtils.js
|
|
430614
|
-
import path33 from "path";
|
|
430615
|
-
import crypto3 from "crypto";
|
|
430616
|
-
function getProjectId(projectPath) {
|
|
430617
|
-
const cwd2 = projectPath || process.cwd();
|
|
430618
|
-
const dirName = path33.basename(cwd2);
|
|
430619
|
-
const pathHash = crypto3.createHash("sha256").update(cwd2).digest("hex").slice(0, 6);
|
|
430620
|
-
const safeDirName = sanitizeProjectName(dirName);
|
|
430621
|
-
return `${safeDirName}-${pathHash}`;
|
|
430622
|
-
}
|
|
430623
|
-
function getProjectPath() {
|
|
430624
|
-
return process.cwd();
|
|
430625
|
-
}
|
|
430626
|
-
function sanitizeProjectName(name) {
|
|
430627
|
-
return name.replace(/[<>:"/\\|?*\x00-\x1F]/g, "_").replace(/\s+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").slice(0, 100);
|
|
430628
|
-
}
|
|
430629
|
-
function formatDateCompact(date) {
|
|
430630
|
-
const year = date.getFullYear();
|
|
430631
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
430632
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
430633
|
-
return `${year}${month}${day}`;
|
|
430634
|
-
}
|
|
430635
|
-
function isDateFolder(folderName) {
|
|
430636
|
-
return /^\d{4}-?\d{2}-?\d{2}$/.test(folderName);
|
|
430637
|
-
}
|
|
430638
|
-
function isProjectFolder(folderName) {
|
|
430639
|
-
return /^.+-[a-f0-9]{6}$/.test(folderName);
|
|
430640
|
-
}
|
|
430641
|
-
var init_projectUtils = __esm({
|
|
430642
|
-
"dist/utils/session/projectUtils.js"() {
|
|
430643
|
-
"use strict";
|
|
430644
|
-
}
|
|
430645
|
-
});
|
|
430646
|
-
|
|
430647
431059
|
// dist/utils/session/sessionManager.js
|
|
430648
431060
|
var sessionManager_exports = {};
|
|
430649
431061
|
__export(sessionManager_exports, {
|
|
430650
431062
|
sessionManager: () => sessionManager
|
|
430651
431063
|
});
|
|
430652
|
-
import
|
|
430653
|
-
import
|
|
430654
|
-
import
|
|
431064
|
+
import fs27 from "fs/promises";
|
|
431065
|
+
import path35 from "path";
|
|
431066
|
+
import os16 from "os";
|
|
430655
431067
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
430656
431068
|
var SessionManager, sessionManager;
|
|
430657
431069
|
var init_sessionManager = __esm({
|
|
@@ -430699,7 +431111,7 @@ var init_sessionManager = __esm({
|
|
|
430699
431111
|
writable: true,
|
|
430700
431112
|
value: void 0
|
|
430701
431113
|
});
|
|
430702
|
-
this.sessionsDir =
|
|
431114
|
+
this.sessionsDir = path35.join(os16.homedir(), ".snow", "sessions");
|
|
430703
431115
|
this.currentProjectId = getProjectId();
|
|
430704
431116
|
this.currentProjectPath = getProjectPath();
|
|
430705
431117
|
}
|
|
@@ -430708,17 +431120,17 @@ var init_sessionManager = __esm({
|
|
|
430708
431120
|
* 路径结构: ~/.snow/sessions/项目名/YYYYMMDD/
|
|
430709
431121
|
*/
|
|
430710
431122
|
getProjectSessionsDir() {
|
|
430711
|
-
return
|
|
431123
|
+
return path35.join(this.sessionsDir, this.currentProjectId);
|
|
430712
431124
|
}
|
|
430713
431125
|
async ensureSessionsDir(date) {
|
|
430714
431126
|
try {
|
|
430715
|
-
await
|
|
431127
|
+
await fs27.mkdir(this.sessionsDir, { recursive: true });
|
|
430716
431128
|
const projectDir = this.getProjectSessionsDir();
|
|
430717
|
-
await
|
|
431129
|
+
await fs27.mkdir(projectDir, { recursive: true });
|
|
430718
431130
|
if (date) {
|
|
430719
431131
|
const dateFolder = formatDateCompact(date);
|
|
430720
|
-
const sessionDir =
|
|
430721
|
-
await
|
|
431132
|
+
const sessionDir = path35.join(projectDir, dateFolder);
|
|
431133
|
+
await fs27.mkdir(sessionDir, { recursive: true });
|
|
430722
431134
|
}
|
|
430723
431135
|
} catch (error) {
|
|
430724
431136
|
}
|
|
@@ -430731,8 +431143,8 @@ var init_sessionManager = __esm({
|
|
|
430731
431143
|
const sessionDate = date || /* @__PURE__ */ new Date();
|
|
430732
431144
|
const dateFolder = formatDateCompact(sessionDate);
|
|
430733
431145
|
const targetProjectId = projectId || this.currentProjectId;
|
|
430734
|
-
const sessionDir =
|
|
430735
|
-
return
|
|
431146
|
+
const sessionDir = path35.join(this.sessionsDir, targetProjectId, dateFolder);
|
|
431147
|
+
return path35.join(sessionDir, `${sessionId}.json`);
|
|
430736
431148
|
}
|
|
430737
431149
|
/**
|
|
430738
431150
|
* 获取当前项目ID
|
|
@@ -430801,7 +431213,7 @@ var init_sessionManager = __esm({
|
|
|
430801
431213
|
const sessionDate = new Date(session.createdAt);
|
|
430802
431214
|
await this.ensureSessionsDir(sessionDate);
|
|
430803
431215
|
const sessionPath = this.getSessionPath(session.id, sessionDate, session.projectId);
|
|
430804
|
-
await
|
|
431216
|
+
await fs27.writeFile(sessionPath, JSON.stringify(session, null, 2));
|
|
430805
431217
|
}
|
|
430806
431218
|
/**
|
|
430807
431219
|
* 清理未完成的 tool_calls
|
|
@@ -430850,8 +431262,8 @@ var init_sessionManager = __esm({
|
|
|
430850
431262
|
this.lastLoadHookError = void 0;
|
|
430851
431263
|
this.lastLoadHookWarning = void 0;
|
|
430852
431264
|
try {
|
|
430853
|
-
const oldSessionPath =
|
|
430854
|
-
const data = await
|
|
431265
|
+
const oldSessionPath = path35.join(this.sessionsDir, `${sessionId}.json`);
|
|
431266
|
+
const data = await fs27.readFile(oldSessionPath, "utf-8");
|
|
430855
431267
|
const session = JSON.parse(data);
|
|
430856
431268
|
this.cleanIncompleteToolCalls(session);
|
|
430857
431269
|
const hookResult = await this.executeSessionStartHook(session.messages);
|
|
@@ -430894,15 +431306,15 @@ var init_sessionManager = __esm({
|
|
|
430894
431306
|
*/
|
|
430895
431307
|
async findSessionInDateFolders(sessionId) {
|
|
430896
431308
|
try {
|
|
430897
|
-
const files = await
|
|
431309
|
+
const files = await fs27.readdir(this.sessionsDir);
|
|
430898
431310
|
const currentProjectDir = this.getProjectSessionsDir();
|
|
430899
431311
|
const sessionFromCurrentProject = await this.findSessionInProjectDir(currentProjectDir, sessionId);
|
|
430900
431312
|
if (sessionFromCurrentProject) {
|
|
430901
431313
|
return sessionFromCurrentProject;
|
|
430902
431314
|
}
|
|
430903
431315
|
for (const file of files) {
|
|
430904
|
-
const filePath =
|
|
430905
|
-
const stat4 = await
|
|
431316
|
+
const filePath = path35.join(this.sessionsDir, file);
|
|
431317
|
+
const stat4 = await fs27.stat(filePath);
|
|
430906
431318
|
if (!stat4.isDirectory())
|
|
430907
431319
|
continue;
|
|
430908
431320
|
if (file === this.currentProjectId)
|
|
@@ -430913,9 +431325,9 @@ var init_sessionManager = __esm({
|
|
|
430913
431325
|
return session;
|
|
430914
431326
|
}
|
|
430915
431327
|
if (isDateFolder(file)) {
|
|
430916
|
-
const sessionPath =
|
|
431328
|
+
const sessionPath = path35.join(filePath, `${sessionId}.json`);
|
|
430917
431329
|
try {
|
|
430918
|
-
const data = await
|
|
431330
|
+
const data = await fs27.readFile(sessionPath, "utf-8");
|
|
430919
431331
|
const session = JSON.parse(data);
|
|
430920
431332
|
return session;
|
|
430921
431333
|
} catch (error) {
|
|
@@ -430932,13 +431344,13 @@ var init_sessionManager = __esm({
|
|
|
430932
431344
|
*/
|
|
430933
431345
|
async findSessionInProjectDir(projectDir, sessionId) {
|
|
430934
431346
|
try {
|
|
430935
|
-
const dateFolders = await
|
|
431347
|
+
const dateFolders = await fs27.readdir(projectDir);
|
|
430936
431348
|
for (const dateFolder of dateFolders) {
|
|
430937
431349
|
if (!isDateFolder(dateFolder))
|
|
430938
431350
|
continue;
|
|
430939
|
-
const sessionPath =
|
|
431351
|
+
const sessionPath = path35.join(projectDir, dateFolder, `${sessionId}.json`);
|
|
430940
431352
|
try {
|
|
430941
|
-
const data = await
|
|
431353
|
+
const data = await fs27.readFile(sessionPath, "utf-8");
|
|
430942
431354
|
const session = JSON.parse(data);
|
|
430943
431355
|
return session;
|
|
430944
431356
|
} catch (error) {
|
|
@@ -430961,11 +431373,11 @@ var init_sessionManager = __esm({
|
|
|
430961
431373
|
try {
|
|
430962
431374
|
const projectDir = this.getProjectSessionsDir();
|
|
430963
431375
|
try {
|
|
430964
|
-
const dateFolders = await
|
|
431376
|
+
const dateFolders = await fs27.readdir(projectDir);
|
|
430965
431377
|
for (const dateFolder of dateFolders) {
|
|
430966
431378
|
if (!isDateFolder(dateFolder))
|
|
430967
431379
|
continue;
|
|
430968
|
-
const datePath =
|
|
431380
|
+
const datePath = path35.join(projectDir, dateFolder);
|
|
430969
431381
|
await this.readSessionsFromDir(datePath, sessions);
|
|
430970
431382
|
}
|
|
430971
431383
|
for (const s of sessions) {
|
|
@@ -430975,10 +431387,10 @@ var init_sessionManager = __esm({
|
|
|
430975
431387
|
}
|
|
430976
431388
|
if (sessions.length === 0) {
|
|
430977
431389
|
try {
|
|
430978
|
-
const files = await
|
|
431390
|
+
const files = await fs27.readdir(this.sessionsDir);
|
|
430979
431391
|
for (const file of files) {
|
|
430980
|
-
const filePath =
|
|
430981
|
-
const stat4 = await
|
|
431392
|
+
const filePath = path35.join(this.sessionsDir, file);
|
|
431393
|
+
const stat4 = await fs27.stat(filePath);
|
|
430982
431394
|
if (stat4.isDirectory() && isDateFolder(file) && !isProjectFolder(file)) {
|
|
430983
431395
|
await this.readLegacySessionsFromDir(filePath, sessions, seenIds);
|
|
430984
431396
|
}
|
|
@@ -430999,11 +431411,11 @@ var init_sessionManager = __esm({
|
|
|
430999
431411
|
*/
|
|
431000
431412
|
async readLegacySessionsFromDir(dirPath, sessions, seenIds) {
|
|
431001
431413
|
try {
|
|
431002
|
-
const files = await
|
|
431414
|
+
const files = await fs27.readdir(dirPath);
|
|
431003
431415
|
for (const file of files) {
|
|
431004
431416
|
if (!file.endsWith(".json"))
|
|
431005
431417
|
continue;
|
|
431006
|
-
const filePath =
|
|
431418
|
+
const filePath = path35.join(dirPath, file);
|
|
431007
431419
|
await this.readLegacySessionFile(filePath, sessions, seenIds);
|
|
431008
431420
|
}
|
|
431009
431421
|
} catch (error) {
|
|
@@ -431014,7 +431426,7 @@ var init_sessionManager = __esm({
|
|
|
431014
431426
|
*/
|
|
431015
431427
|
async readLegacySessionFile(filePath, sessions, seenIds) {
|
|
431016
431428
|
try {
|
|
431017
|
-
const data = await
|
|
431429
|
+
const data = await fs27.readFile(filePath, "utf-8");
|
|
431018
431430
|
const session = JSON.parse(data);
|
|
431019
431431
|
if (seenIds.has(session.id)) {
|
|
431020
431432
|
return;
|
|
@@ -431066,12 +431478,12 @@ var init_sessionManager = __esm({
|
|
|
431066
431478
|
}
|
|
431067
431479
|
async readSessionsFromDir(dirPath, sessions) {
|
|
431068
431480
|
try {
|
|
431069
|
-
const files = await
|
|
431481
|
+
const files = await fs27.readdir(dirPath);
|
|
431070
431482
|
for (const file of files) {
|
|
431071
431483
|
if (file.endsWith(".json")) {
|
|
431072
431484
|
try {
|
|
431073
|
-
const sessionPath =
|
|
431074
|
-
const data = await
|
|
431485
|
+
const sessionPath = path35.join(dirPath, file);
|
|
431486
|
+
const data = await fs27.readFile(sessionPath, "utf-8");
|
|
431075
431487
|
const session = JSON.parse(data);
|
|
431076
431488
|
sessions.push({
|
|
431077
431489
|
id: session.id,
|
|
@@ -431184,8 +431596,8 @@ var init_sessionManager = __esm({
|
|
|
431184
431596
|
async deleteSession(sessionId) {
|
|
431185
431597
|
let sessionDeleted = false;
|
|
431186
431598
|
try {
|
|
431187
|
-
const oldSessionPath =
|
|
431188
|
-
await
|
|
431599
|
+
const oldSessionPath = path35.join(this.sessionsDir, `${sessionId}.json`);
|
|
431600
|
+
await fs27.unlink(oldSessionPath);
|
|
431189
431601
|
sessionDeleted = true;
|
|
431190
431602
|
} catch (error) {
|
|
431191
431603
|
}
|
|
@@ -431194,12 +431606,12 @@ var init_sessionManager = __esm({
|
|
|
431194
431606
|
}
|
|
431195
431607
|
if (!sessionDeleted) {
|
|
431196
431608
|
try {
|
|
431197
|
-
const files = await
|
|
431609
|
+
const files = await fs27.readdir(this.sessionsDir);
|
|
431198
431610
|
for (const file of files) {
|
|
431199
431611
|
if (sessionDeleted)
|
|
431200
431612
|
break;
|
|
431201
|
-
const filePath =
|
|
431202
|
-
const stat4 = await
|
|
431613
|
+
const filePath = path35.join(this.sessionsDir, file);
|
|
431614
|
+
const stat4 = await fs27.stat(filePath);
|
|
431203
431615
|
if (!stat4.isDirectory())
|
|
431204
431616
|
continue;
|
|
431205
431617
|
if (file === this.currentProjectId)
|
|
@@ -431210,9 +431622,9 @@ var init_sessionManager = __esm({
|
|
|
431210
431622
|
break;
|
|
431211
431623
|
}
|
|
431212
431624
|
if (isDateFolder(file)) {
|
|
431213
|
-
const sessionPath =
|
|
431625
|
+
const sessionPath = path35.join(filePath, `${sessionId}.json`);
|
|
431214
431626
|
try {
|
|
431215
|
-
await
|
|
431627
|
+
await fs27.unlink(sessionPath);
|
|
431216
431628
|
sessionDeleted = true;
|
|
431217
431629
|
break;
|
|
431218
431630
|
} catch (error) {
|
|
@@ -431238,13 +431650,13 @@ var init_sessionManager = __esm({
|
|
|
431238
431650
|
*/
|
|
431239
431651
|
async deleteSessionFromProjectDir(projectDir, sessionId) {
|
|
431240
431652
|
try {
|
|
431241
|
-
const dateFolders = await
|
|
431653
|
+
const dateFolders = await fs27.readdir(projectDir);
|
|
431242
431654
|
for (const dateFolder of dateFolders) {
|
|
431243
431655
|
if (!isDateFolder(dateFolder))
|
|
431244
431656
|
continue;
|
|
431245
|
-
const sessionPath =
|
|
431657
|
+
const sessionPath = path35.join(projectDir, dateFolder, `${sessionId}.json`);
|
|
431246
431658
|
try {
|
|
431247
|
-
await
|
|
431659
|
+
await fs27.unlink(sessionPath);
|
|
431248
431660
|
return true;
|
|
431249
431661
|
} catch (error) {
|
|
431250
431662
|
continue;
|
|
@@ -431320,8 +431732,8 @@ __export(codebaseSearch_exports, {
|
|
|
431320
431732
|
codebaseSearchService: () => codebaseSearchService,
|
|
431321
431733
|
mcpTools: () => mcpTools6
|
|
431322
431734
|
});
|
|
431323
|
-
import
|
|
431324
|
-
import
|
|
431735
|
+
import path36 from "node:path";
|
|
431736
|
+
import fs28 from "node:fs";
|
|
431325
431737
|
var CodebaseSearchService, codebaseSearchService, mcpTools6;
|
|
431326
431738
|
var init_codebaseSearch = __esm({
|
|
431327
431739
|
"dist/mcp/codebaseSearch.js"() {
|
|
@@ -431340,8 +431752,8 @@ var init_codebaseSearch = __esm({
|
|
|
431340
431752
|
async isCodebaseIndexAvailable() {
|
|
431341
431753
|
try {
|
|
431342
431754
|
const projectRoot = process.cwd();
|
|
431343
|
-
const dbPath =
|
|
431344
|
-
if (!
|
|
431755
|
+
const dbPath = path36.join(projectRoot, ".snow", "codebase", "embeddings.db");
|
|
431756
|
+
if (!fs28.existsSync(dbPath)) {
|
|
431345
431757
|
return {
|
|
431346
431758
|
available: false,
|
|
431347
431759
|
reason: "Codebase index not found. Please run codebase indexing first."
|
|
@@ -431659,8 +432071,8 @@ var init_date_utils = __esm({
|
|
|
431659
432071
|
});
|
|
431660
432072
|
|
|
431661
432073
|
// dist/mcp/todo.js
|
|
431662
|
-
import
|
|
431663
|
-
import
|
|
432074
|
+
import fs29 from "fs/promises";
|
|
432075
|
+
import path37 from "path";
|
|
431664
432076
|
var TodoService;
|
|
431665
432077
|
var init_todo = __esm({
|
|
431666
432078
|
"dist/mcp/todo.js"() {
|
|
@@ -431684,21 +432096,21 @@ var init_todo = __esm({
|
|
|
431684
432096
|
this.getCurrentSessionId = getCurrentSessionId;
|
|
431685
432097
|
}
|
|
431686
432098
|
async initialize() {
|
|
431687
|
-
await
|
|
432099
|
+
await fs29.mkdir(this.todoDir, { recursive: true });
|
|
431688
432100
|
}
|
|
431689
432101
|
getTodoPath(sessionId, date) {
|
|
431690
432102
|
const sessionDate = date || /* @__PURE__ */ new Date();
|
|
431691
432103
|
const dateFolder = formatDateForFolder(sessionDate);
|
|
431692
|
-
const todoDir =
|
|
431693
|
-
return
|
|
432104
|
+
const todoDir = path37.join(this.todoDir, dateFolder);
|
|
432105
|
+
return path37.join(todoDir, `${sessionId}.json`);
|
|
431694
432106
|
}
|
|
431695
432107
|
async ensureTodoDir(date) {
|
|
431696
432108
|
try {
|
|
431697
|
-
await
|
|
432109
|
+
await fs29.mkdir(this.todoDir, { recursive: true });
|
|
431698
432110
|
if (date) {
|
|
431699
432111
|
const dateFolder = formatDateForFolder(date);
|
|
431700
|
-
const todoDir =
|
|
431701
|
-
await
|
|
432112
|
+
const todoDir = path37.join(this.todoDir, dateFolder);
|
|
432113
|
+
await fs29.mkdir(todoDir, { recursive: true });
|
|
431702
432114
|
}
|
|
431703
432115
|
} catch (error) {
|
|
431704
432116
|
}
|
|
@@ -431712,7 +432124,7 @@ var init_todo = __esm({
|
|
|
431712
432124
|
await this.ensureTodoDir(sessionDate);
|
|
431713
432125
|
const todoPath = this.getTodoPath(sessionId, sessionDate);
|
|
431714
432126
|
try {
|
|
431715
|
-
const content = await
|
|
432127
|
+
const content = await fs29.readFile(todoPath, "utf-8");
|
|
431716
432128
|
existingList = JSON.parse(content);
|
|
431717
432129
|
} catch {
|
|
431718
432130
|
}
|
|
@@ -431723,7 +432135,7 @@ var init_todo = __esm({
|
|
|
431723
432135
|
createdAt: (existingList == null ? void 0 : existingList.createdAt) ?? now,
|
|
431724
432136
|
updatedAt: now
|
|
431725
432137
|
};
|
|
431726
|
-
await
|
|
432138
|
+
await fs29.writeFile(todoPath, JSON.stringify(todoList, null, 2));
|
|
431727
432139
|
return todoList;
|
|
431728
432140
|
}
|
|
431729
432141
|
/**
|
|
@@ -431731,8 +432143,8 @@ var init_todo = __esm({
|
|
|
431731
432143
|
*/
|
|
431732
432144
|
async getTodoList(sessionId) {
|
|
431733
432145
|
try {
|
|
431734
|
-
const oldTodoPath =
|
|
431735
|
-
const content = await
|
|
432146
|
+
const oldTodoPath = path37.join(this.todoDir, `${sessionId}.json`);
|
|
432147
|
+
const content = await fs29.readFile(oldTodoPath, "utf-8");
|
|
431736
432148
|
return JSON.parse(content);
|
|
431737
432149
|
} catch (error) {
|
|
431738
432150
|
}
|
|
@@ -431745,14 +432157,14 @@ var init_todo = __esm({
|
|
|
431745
432157
|
}
|
|
431746
432158
|
async findTodoInDateFolders(sessionId) {
|
|
431747
432159
|
try {
|
|
431748
|
-
const files = await
|
|
432160
|
+
const files = await fs29.readdir(this.todoDir);
|
|
431749
432161
|
for (const file of files) {
|
|
431750
|
-
const filePath =
|
|
431751
|
-
const stat4 = await
|
|
432162
|
+
const filePath = path37.join(this.todoDir, file);
|
|
432163
|
+
const stat4 = await fs29.stat(filePath);
|
|
431752
432164
|
if (stat4.isDirectory() && /^\d{4}-\d{2}-\d{2}$/.test(file)) {
|
|
431753
|
-
const todoPath =
|
|
432165
|
+
const todoPath = path37.join(filePath, `${sessionId}.json`);
|
|
431754
432166
|
try {
|
|
431755
|
-
const content = await
|
|
432167
|
+
const content = await fs29.readFile(todoPath, "utf-8");
|
|
431756
432168
|
return JSON.parse(content);
|
|
431757
432169
|
} catch (error) {
|
|
431758
432170
|
continue;
|
|
@@ -431829,20 +432241,20 @@ var init_todo = __esm({
|
|
|
431829
432241
|
*/
|
|
431830
432242
|
async deleteTodoList(sessionId) {
|
|
431831
432243
|
try {
|
|
431832
|
-
const oldTodoPath =
|
|
431833
|
-
await
|
|
432244
|
+
const oldTodoPath = path37.join(this.todoDir, `${sessionId}.json`);
|
|
432245
|
+
await fs29.unlink(oldTodoPath);
|
|
431834
432246
|
return true;
|
|
431835
432247
|
} catch (error) {
|
|
431836
432248
|
}
|
|
431837
432249
|
try {
|
|
431838
|
-
const files = await
|
|
432250
|
+
const files = await fs29.readdir(this.todoDir);
|
|
431839
432251
|
for (const file of files) {
|
|
431840
|
-
const filePath =
|
|
431841
|
-
const stat4 = await
|
|
432252
|
+
const filePath = path37.join(this.todoDir, file);
|
|
432253
|
+
const stat4 = await fs29.stat(filePath);
|
|
431842
432254
|
if (stat4.isDirectory() && /^\d{4}-\d{2}-\d{2}$/.test(file)) {
|
|
431843
|
-
const todoPath =
|
|
432255
|
+
const todoPath = path37.join(filePath, `${sessionId}.json`);
|
|
431844
432256
|
try {
|
|
431845
|
-
await
|
|
432257
|
+
await fs29.unlink(todoPath);
|
|
431846
432258
|
return true;
|
|
431847
432259
|
} catch (error) {
|
|
431848
432260
|
continue;
|
|
@@ -438493,12 +438905,12 @@ __export(mcpToolsManager_exports, {
|
|
|
438493
438905
|
reconnectMCPService: () => reconnectMCPService,
|
|
438494
438906
|
refreshMCPToolsCache: () => refreshMCPToolsCache
|
|
438495
438907
|
});
|
|
438496
|
-
import
|
|
438497
|
-
import
|
|
438908
|
+
import os17 from "os";
|
|
438909
|
+
import path38 from "path";
|
|
438498
438910
|
function getTodoService() {
|
|
438499
438911
|
if (!todoService) {
|
|
438500
438912
|
const projectId = sessionManager.getProjectId();
|
|
438501
|
-
const basePath =
|
|
438913
|
+
const basePath = path38.join(os17.homedir(), ".snow", "todos", projectId);
|
|
438502
438914
|
todoService = new TodoService(basePath, () => {
|
|
438503
438915
|
const session = sessionManager.getCurrentSession();
|
|
438504
438916
|
return session ? session.id : null;
|
|
@@ -438787,7 +439199,7 @@ async function refreshToolsCache() {
|
|
|
438787
439199
|
const codebaseConfig = loadCodebaseConfig2();
|
|
438788
439200
|
if (codebaseConfig.enabled) {
|
|
438789
439201
|
const projectRoot2 = process.cwd();
|
|
438790
|
-
const dbPath =
|
|
439202
|
+
const dbPath = path38.join(projectRoot2, ".snow", "codebase", "embeddings.db");
|
|
438791
439203
|
const fs41 = await import("node:fs");
|
|
438792
439204
|
if (fs41.existsSync(dbPath)) {
|
|
438793
439205
|
const { CodebaseDatabase: CodebaseDatabase2 } = await Promise.resolve().then(() => (init_codebaseDatabase(), codebaseDatabase_exports));
|
|
@@ -444198,6 +444610,7 @@ function WelcomeScreen({ version: version2 = "1.0.0", onMenuSelect, defaultMenuI
|
|
|
444198
444610
|
const { t } = useI18n();
|
|
444199
444611
|
const [infoText, setInfoText] = (0, import_react76.useState)(t.welcome.startChatInfo);
|
|
444200
444612
|
const [inlineView, setInlineView] = (0, import_react76.useState)("menu");
|
|
444613
|
+
const [updateNotice, setUpdateNoticeState] = (0, import_react76.useState)(getUpdateNotice());
|
|
444201
444614
|
const [editingAgentId, setEditingAgentId] = (0, import_react76.useState)();
|
|
444202
444615
|
const { columns: terminalWidth } = useTerminalSize();
|
|
444203
444616
|
const { stdout } = use_stdout_default();
|
|
@@ -444208,6 +444621,12 @@ function WelcomeScreen({ version: version2 = "1.0.0", onMenuSelect, defaultMenuI
|
|
|
444208
444621
|
(0, import_react76.useEffect)(() => {
|
|
444209
444622
|
setCurrentMenuIndex(defaultMenuIndex);
|
|
444210
444623
|
}, [defaultMenuIndex]);
|
|
444624
|
+
(0, import_react76.useEffect)(() => {
|
|
444625
|
+
const unsubscribe = onUpdateNotice((notice) => {
|
|
444626
|
+
setUpdateNoticeState(notice);
|
|
444627
|
+
});
|
|
444628
|
+
return unsubscribe;
|
|
444629
|
+
}, []);
|
|
444211
444630
|
const menuOptions = (0, import_react76.useMemo)(() => [
|
|
444212
444631
|
{
|
|
444213
444632
|
label: t.welcome.startChat,
|
|
@@ -444402,6 +444821,51 @@ function WelcomeScreen({ version: version2 = "1.0.0", onMenuSelect, defaultMenuI
|
|
|
444402
444821
|
)
|
|
444403
444822
|
)
|
|
444404
444823
|
] }, (item) => item),
|
|
444824
|
+
inlineView === "menu" && updateNotice && import_react76.default.createElement(
|
|
444825
|
+
Box_default,
|
|
444826
|
+
{ paddingX: 1, marginBottom: 1 },
|
|
444827
|
+
import_react76.default.createElement(
|
|
444828
|
+
Box_default,
|
|
444829
|
+
{ borderStyle: "double", borderColor: "cyan", paddingX: 2, paddingY: 1, width: terminalWidth - 2 },
|
|
444830
|
+
import_react76.default.createElement(
|
|
444831
|
+
Box_default,
|
|
444832
|
+
{ flexDirection: "column" },
|
|
444833
|
+
import_react76.default.createElement(Text, { bold: true, color: "cyan" }, t.welcome.updateNoticeTitle),
|
|
444834
|
+
import_react76.default.createElement(
|
|
444835
|
+
Text,
|
|
444836
|
+
{ color: "gray", dimColor: true },
|
|
444837
|
+
t.welcome.updateNoticeCurrent,
|
|
444838
|
+
":",
|
|
444839
|
+
" ",
|
|
444840
|
+
import_react76.default.createElement(Text, { color: "gray" }, updateNotice.currentVersion)
|
|
444841
|
+
),
|
|
444842
|
+
import_react76.default.createElement(
|
|
444843
|
+
Text,
|
|
444844
|
+
{ color: "gray", dimColor: true },
|
|
444845
|
+
t.welcome.updateNoticeLatest,
|
|
444846
|
+
":",
|
|
444847
|
+
" ",
|
|
444848
|
+
import_react76.default.createElement(Text, { color: "yellow", bold: true }, updateNotice.latestVersion)
|
|
444849
|
+
),
|
|
444850
|
+
import_react76.default.createElement(
|
|
444851
|
+
Text,
|
|
444852
|
+
{ color: "gray", dimColor: true },
|
|
444853
|
+
t.welcome.updateNoticeRun,
|
|
444854
|
+
":",
|
|
444855
|
+
" ",
|
|
444856
|
+
import_react76.default.createElement(Text, { color: "yellow", bold: true }, "snow --update")
|
|
444857
|
+
),
|
|
444858
|
+
import_react76.default.createElement(
|
|
444859
|
+
Text,
|
|
444860
|
+
{ color: "gray", dimColor: true },
|
|
444861
|
+
t.welcome.updateNoticeGithub,
|
|
444862
|
+
":",
|
|
444863
|
+
" ",
|
|
444864
|
+
"https://github.com/MayDay-wpf/snow-cli"
|
|
444865
|
+
)
|
|
444866
|
+
)
|
|
444867
|
+
)
|
|
444868
|
+
),
|
|
444405
444869
|
onMenuSelect && inlineView === "menu" && import_react76.default.createElement(
|
|
444406
444870
|
Box_default,
|
|
444407
444871
|
{ paddingX: 1 },
|
|
@@ -444535,6 +444999,7 @@ var init_WelcomeScreen = __esm({
|
|
|
444535
444999
|
await init_Menu();
|
|
444536
445000
|
init_useTerminalSize();
|
|
444537
445001
|
init_i18n();
|
|
445002
|
+
init_updateNotice();
|
|
444538
445003
|
ConfigScreen2 = import_react76.default.lazy(() => init_ConfigScreen().then(() => ConfigScreen_exports));
|
|
444539
445004
|
ProxyConfigScreen2 = import_react76.default.lazy(() => init_ProxyConfigScreen().then(() => ProxyConfigScreen_exports));
|
|
444540
445005
|
SubAgentConfigScreen2 = import_react76.default.lazy(() => init_SubAgentConfigScreen().then(() => SubAgentConfigScreen_exports));
|
|
@@ -445137,9 +445602,9 @@ var init_useInputBuffer = __esm({
|
|
|
445137
445602
|
});
|
|
445138
445603
|
|
|
445139
445604
|
// dist/utils/session/commandUsageManager.js
|
|
445140
|
-
import
|
|
445141
|
-
import
|
|
445142
|
-
import
|
|
445605
|
+
import fs30 from "fs/promises";
|
|
445606
|
+
import path39 from "path";
|
|
445607
|
+
import os18 from "os";
|
|
445143
445608
|
var CommandUsageManager, commandUsageManager;
|
|
445144
445609
|
var init_commandUsageManager = __esm({
|
|
445145
445610
|
"dist/utils/session/commandUsageManager.js"() {
|
|
@@ -445177,16 +445642,16 @@ var init_commandUsageManager = __esm({
|
|
|
445177
445642
|
writable: true,
|
|
445178
445643
|
value: 1e3
|
|
445179
445644
|
});
|
|
445180
|
-
const snowDir =
|
|
445181
|
-
this.usageFile =
|
|
445645
|
+
const snowDir = path39.join(os18.homedir(), ".snow");
|
|
445646
|
+
this.usageFile = path39.join(snowDir, "command-usage.json");
|
|
445182
445647
|
}
|
|
445183
445648
|
/**
|
|
445184
445649
|
* 确保 .snow 目录存在
|
|
445185
445650
|
*/
|
|
445186
445651
|
async ensureSnowDir() {
|
|
445187
445652
|
try {
|
|
445188
|
-
const snowDir =
|
|
445189
|
-
await
|
|
445653
|
+
const snowDir = path39.dirname(this.usageFile);
|
|
445654
|
+
await fs30.mkdir(snowDir, { recursive: true });
|
|
445190
445655
|
} catch {
|
|
445191
445656
|
}
|
|
445192
445657
|
}
|
|
@@ -445198,7 +445663,7 @@ var init_commandUsageManager = __esm({
|
|
|
445198
445663
|
return;
|
|
445199
445664
|
try {
|
|
445200
445665
|
await this.ensureSnowDir();
|
|
445201
|
-
const data = await
|
|
445666
|
+
const data = await fs30.readFile(this.usageFile, "utf-8");
|
|
445202
445667
|
this.usageData = JSON.parse(data);
|
|
445203
445668
|
} catch {
|
|
445204
445669
|
this.usageData = {
|
|
@@ -445227,7 +445692,7 @@ var init_commandUsageManager = __esm({
|
|
|
445227
445692
|
try {
|
|
445228
445693
|
await this.ensureSnowDir();
|
|
445229
445694
|
this.usageData.lastUpdated = Date.now();
|
|
445230
|
-
await
|
|
445695
|
+
await fs30.writeFile(this.usageFile, JSON.stringify(this.usageData, null, 2), "utf-8");
|
|
445231
445696
|
this.isDirty = false;
|
|
445232
445697
|
} catch (error) {
|
|
445233
445698
|
logger.error("Failed to save command usage:", error);
|
|
@@ -445683,16 +446148,16 @@ __export(fileUtils_exports, {
|
|
|
445683
446148
|
getFileLineCount: () => getFileLineCount,
|
|
445684
446149
|
parseAndValidateFileReferences: () => parseAndValidateFileReferences
|
|
445685
446150
|
});
|
|
445686
|
-
import
|
|
445687
|
-
import
|
|
446151
|
+
import fs31 from "fs";
|
|
446152
|
+
import path40 from "path";
|
|
445688
446153
|
function getFileLineCount(filePath) {
|
|
445689
446154
|
return new Promise((resolve10) => {
|
|
445690
446155
|
try {
|
|
445691
|
-
if (!
|
|
446156
|
+
if (!fs31.existsSync(filePath)) {
|
|
445692
446157
|
resolve10(0);
|
|
445693
446158
|
return;
|
|
445694
446159
|
}
|
|
445695
|
-
const content =
|
|
446160
|
+
const content = fs31.readFileSync(filePath, "utf-8");
|
|
445696
446161
|
const lines = content.split("\n").length;
|
|
445697
446162
|
resolve10(lines);
|
|
445698
446163
|
} catch (error) {
|
|
@@ -445710,11 +446175,11 @@ function isImageFile(filePath) {
|
|
|
445710
446175
|
".bmp",
|
|
445711
446176
|
".svg"
|
|
445712
446177
|
];
|
|
445713
|
-
const ext =
|
|
446178
|
+
const ext = path40.extname(filePath).toLowerCase();
|
|
445714
446179
|
return imageExtensions.includes(ext);
|
|
445715
446180
|
}
|
|
445716
446181
|
function getMimeType(filePath) {
|
|
445717
|
-
const ext =
|
|
446182
|
+
const ext = path40.extname(filePath).toLowerCase();
|
|
445718
446183
|
const mimeTypes = {
|
|
445719
446184
|
".png": "image/png",
|
|
445720
446185
|
".jpg": "image/jpeg",
|
|
@@ -445731,16 +446196,16 @@ async function getFileInfo(filePath) {
|
|
|
445731
446196
|
const pathsToTry = [
|
|
445732
446197
|
filePath,
|
|
445733
446198
|
// Original path as provided
|
|
445734
|
-
|
|
446199
|
+
path40.resolve(process.cwd(), filePath),
|
|
445735
446200
|
// Relative to current working directory
|
|
445736
|
-
|
|
446201
|
+
path40.resolve(filePath)
|
|
445737
446202
|
// Absolute resolution
|
|
445738
446203
|
];
|
|
445739
446204
|
const uniquePaths = [...new Set(pathsToTry)];
|
|
445740
446205
|
let actualPath = filePath;
|
|
445741
446206
|
let exists = false;
|
|
445742
446207
|
for (const tryPath of uniquePaths) {
|
|
445743
|
-
if (
|
|
446208
|
+
if (fs31.existsSync(tryPath)) {
|
|
445744
446209
|
actualPath = tryPath;
|
|
445745
446210
|
exists = true;
|
|
445746
446211
|
break;
|
|
@@ -445752,7 +446217,7 @@ async function getFileInfo(filePath) {
|
|
|
445752
446217
|
let lineCount = 0;
|
|
445753
446218
|
if (exists) {
|
|
445754
446219
|
if (isImage) {
|
|
445755
|
-
const buffer =
|
|
446220
|
+
const buffer = fs31.readFileSync(actualPath);
|
|
445756
446221
|
const base64 = buffer.toString("base64");
|
|
445757
446222
|
mimeType = getMimeType(actualPath);
|
|
445758
446223
|
imageData = `data:${mimeType};base64,${base64}`;
|
|
@@ -445880,9 +446345,9 @@ var init_fileUtils = __esm({
|
|
|
445880
446345
|
});
|
|
445881
446346
|
|
|
445882
446347
|
// dist/utils/session/historyManager.js
|
|
445883
|
-
import
|
|
445884
|
-
import
|
|
445885
|
-
import
|
|
446348
|
+
import fs32 from "fs/promises";
|
|
446349
|
+
import path41 from "path";
|
|
446350
|
+
import os19 from "os";
|
|
445886
446351
|
var HistoryManager, historyManager;
|
|
445887
446352
|
var init_historyManager = __esm({
|
|
445888
446353
|
"dist/utils/session/historyManager.js"() {
|
|
@@ -445933,18 +446398,18 @@ var init_historyManager = __esm({
|
|
|
445933
446398
|
writable: true,
|
|
445934
446399
|
value: []
|
|
445935
446400
|
});
|
|
445936
|
-
const snowDir =
|
|
446401
|
+
const snowDir = path41.join(os19.homedir(), ".snow");
|
|
445937
446402
|
this.currentProjectId = getProjectId();
|
|
445938
|
-
this.historyDir =
|
|
445939
|
-
this.historyFile =
|
|
446403
|
+
this.historyDir = path41.join(snowDir, "history", this.currentProjectId);
|
|
446404
|
+
this.historyFile = path41.join(this.historyDir, "history.json");
|
|
445940
446405
|
}
|
|
445941
446406
|
/**
|
|
445942
446407
|
* Ensure the .snow directory exists
|
|
445943
446408
|
*/
|
|
445944
446409
|
async ensureSnowDir() {
|
|
445945
446410
|
try {
|
|
445946
|
-
const snowDir =
|
|
445947
|
-
await
|
|
446411
|
+
const snowDir = path41.dirname(this.historyFile);
|
|
446412
|
+
await fs32.mkdir(snowDir, { recursive: true });
|
|
445948
446413
|
} catch (error) {
|
|
445949
446414
|
}
|
|
445950
446415
|
}
|
|
@@ -445957,16 +446422,16 @@ var init_historyManager = __esm({
|
|
|
445957
446422
|
try {
|
|
445958
446423
|
await this.ensureSnowDir();
|
|
445959
446424
|
try {
|
|
445960
|
-
const data = await
|
|
446425
|
+
const data = await fs32.readFile(this.historyFile, "utf-8");
|
|
445961
446426
|
this.historyData = JSON.parse(data);
|
|
445962
446427
|
await this.cleanupOldEntries();
|
|
445963
446428
|
return this.historyData.entries;
|
|
445964
446429
|
} catch (error) {
|
|
445965
446430
|
}
|
|
445966
|
-
const snowDir =
|
|
445967
|
-
const oldHistoryFile =
|
|
446431
|
+
const snowDir = path41.join(os19.homedir(), ".snow");
|
|
446432
|
+
const oldHistoryFile = path41.join(snowDir, "history.json");
|
|
445968
446433
|
try {
|
|
445969
|
-
const data = await
|
|
446434
|
+
const data = await fs32.readFile(oldHistoryFile, "utf-8");
|
|
445970
446435
|
const oldData = JSON.parse(data);
|
|
445971
446436
|
this.legacyEntries = oldData.entries;
|
|
445972
446437
|
logger.debug(`Loaded ${this.legacyEntries.length} legacy history entries as read-only backup`);
|
|
@@ -446051,7 +446516,7 @@ var init_historyManager = __esm({
|
|
|
446051
446516
|
}
|
|
446052
446517
|
try {
|
|
446053
446518
|
await this.ensureSnowDir();
|
|
446054
|
-
await
|
|
446519
|
+
await fs32.writeFile(this.historyFile, JSON.stringify(this.historyData, null, 2), "utf-8");
|
|
446055
446520
|
} catch (error) {
|
|
446056
446521
|
logger.error("Failed to save history:", error);
|
|
446057
446522
|
}
|
|
@@ -447186,8 +447651,8 @@ var init_useAgentPicker = __esm({
|
|
|
447186
447651
|
});
|
|
447187
447652
|
|
|
447188
447653
|
// dist/utils/core/todoScanner.js
|
|
447189
|
-
import
|
|
447190
|
-
import
|
|
447654
|
+
import fs33 from "fs";
|
|
447655
|
+
import path42 from "path";
|
|
447191
447656
|
function shouldIgnore(filePath) {
|
|
447192
447657
|
const relativePath = filePath;
|
|
447193
447658
|
return IGNORE_PATTERNS.some((pattern) => {
|
|
@@ -447200,7 +447665,7 @@ function shouldIgnore(filePath) {
|
|
|
447200
447665
|
}
|
|
447201
447666
|
function scanFileForTodos(filePath, rootDir) {
|
|
447202
447667
|
try {
|
|
447203
|
-
const content =
|
|
447668
|
+
const content = fs33.readFileSync(filePath, "utf-8");
|
|
447204
447669
|
const lines = content.split("\n");
|
|
447205
447670
|
const todos = [];
|
|
447206
447671
|
lines.forEach((line, index) => {
|
|
@@ -447209,7 +447674,7 @@ function scanFileForTodos(filePath, rootDir) {
|
|
|
447209
447674
|
const match2 = line.match(pattern);
|
|
447210
447675
|
if (match2) {
|
|
447211
447676
|
const todoContent = ((_a21 = match2[1]) == null ? void 0 : _a21.trim()) || "";
|
|
447212
|
-
const relativePath =
|
|
447677
|
+
const relativePath = path42.relative(rootDir, filePath);
|
|
447213
447678
|
todos.push({
|
|
447214
447679
|
id: `${relativePath}:${index + 1}`,
|
|
447215
447680
|
file: relativePath,
|
|
@@ -447229,17 +447694,17 @@ function scanFileForTodos(filePath, rootDir) {
|
|
|
447229
447694
|
function scanDirectory(dir, rootDir) {
|
|
447230
447695
|
let todos = [];
|
|
447231
447696
|
try {
|
|
447232
|
-
const entries =
|
|
447697
|
+
const entries = fs33.readdirSync(dir, { withFileTypes: true });
|
|
447233
447698
|
for (const entry of entries) {
|
|
447234
|
-
const fullPath =
|
|
447235
|
-
const relativePath =
|
|
447699
|
+
const fullPath = path42.join(dir, entry.name);
|
|
447700
|
+
const relativePath = path42.relative(rootDir, fullPath);
|
|
447236
447701
|
if (shouldIgnore(relativePath)) {
|
|
447237
447702
|
continue;
|
|
447238
447703
|
}
|
|
447239
447704
|
if (entry.isDirectory()) {
|
|
447240
447705
|
todos = todos.concat(scanDirectory(fullPath, rootDir));
|
|
447241
447706
|
} else if (entry.isFile()) {
|
|
447242
|
-
const ext =
|
|
447707
|
+
const ext = path42.extname(entry.name).toLowerCase();
|
|
447243
447708
|
const textExtensions = [
|
|
447244
447709
|
".ts",
|
|
447245
447710
|
".tsx",
|
|
@@ -447727,8 +448192,8 @@ var FileList_exports = {};
|
|
|
447727
448192
|
__export(FileList_exports, {
|
|
447728
448193
|
default: () => FileList_default
|
|
447729
448194
|
});
|
|
447730
|
-
import
|
|
447731
|
-
import
|
|
448195
|
+
import fs34 from "fs";
|
|
448196
|
+
import path43 from "path";
|
|
447732
448197
|
var import_react88, FileList, FileList_default;
|
|
447733
448198
|
var init_FileList = __esm({
|
|
447734
448199
|
async "dist/ui/components/tools/FileList.js"() {
|
|
@@ -447757,10 +448222,10 @@ var init_FileList = __esm({
|
|
|
447757
448222
|
let globalMaxDepth = 0;
|
|
447758
448223
|
for (const workingDir of workingDirs) {
|
|
447759
448224
|
const dirPath = workingDir.path;
|
|
447760
|
-
const gitignorePath =
|
|
448225
|
+
const gitignorePath = path43.join(dirPath, ".gitignore");
|
|
447761
448226
|
let gitignorePatterns = [];
|
|
447762
448227
|
try {
|
|
447763
|
-
const content = await
|
|
448228
|
+
const content = await fs34.promises.readFile(gitignorePath, "utf-8");
|
|
447764
448229
|
gitignorePatterns = content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.replace(/\/$/, ""));
|
|
447765
448230
|
} catch {
|
|
447766
448231
|
}
|
|
@@ -447769,7 +448234,7 @@ var init_FileList = __esm({
|
|
|
447769
448234
|
return { files: [], maxDepthReached: depth - 1 };
|
|
447770
448235
|
}
|
|
447771
448236
|
try {
|
|
447772
|
-
const entries = await
|
|
448237
|
+
const entries = await fs34.promises.readdir(dir, {
|
|
447773
448238
|
withFileTypes: true
|
|
447774
448239
|
});
|
|
447775
448240
|
let result2 = [];
|
|
@@ -447808,17 +448273,17 @@ var init_FileList = __esm({
|
|
|
447808
448273
|
if (entry.name.startsWith(".") || ignorePatterns.includes(entry.name)) {
|
|
447809
448274
|
continue;
|
|
447810
448275
|
}
|
|
447811
|
-
const fullPath =
|
|
448276
|
+
const fullPath = path43.join(dir, entry.name);
|
|
447812
448277
|
try {
|
|
447813
|
-
const stats = await
|
|
448278
|
+
const stats = await fs34.promises.stat(fullPath);
|
|
447814
448279
|
if (!entry.isDirectory() && stats.size > 10 * 1024 * 1024) {
|
|
447815
448280
|
continue;
|
|
447816
448281
|
}
|
|
447817
448282
|
} catch {
|
|
447818
448283
|
continue;
|
|
447819
448284
|
}
|
|
447820
|
-
let relativePath =
|
|
447821
|
-
if (!relativePath.startsWith(".") && !
|
|
448285
|
+
let relativePath = path43.relative(dirPath, fullPath);
|
|
448286
|
+
if (!relativePath.startsWith(".") && !path43.isAbsolute(relativePath)) {
|
|
447822
448287
|
relativePath = "./" + relativePath;
|
|
447823
448288
|
}
|
|
447824
448289
|
relativePath = relativePath.replace(/\\/g, "/");
|
|
@@ -447911,7 +448376,7 @@ var init_FileList = __esm({
|
|
|
447911
448376
|
const filesToSearch = files.filter((f) => {
|
|
447912
448377
|
if (f.isDirectory)
|
|
447913
448378
|
return false;
|
|
447914
|
-
const ext =
|
|
448379
|
+
const ext = path43.extname(f.path).toLowerCase();
|
|
447915
448380
|
return textExtensions.has(ext);
|
|
447916
448381
|
});
|
|
447917
448382
|
const batchSize = 10;
|
|
@@ -447924,8 +448389,8 @@ var init_FileList = __esm({
|
|
|
447924
448389
|
const fileResults = [];
|
|
447925
448390
|
try {
|
|
447926
448391
|
const baseDir = file.sourceDir || rootPath;
|
|
447927
|
-
const fullPath =
|
|
447928
|
-
const content = await
|
|
448392
|
+
const fullPath = path43.join(baseDir, file.path);
|
|
448393
|
+
const content = await fs34.promises.readFile(fullPath, "utf-8");
|
|
447929
448394
|
const lines = content.split("\n");
|
|
447930
448395
|
for (let i = 0; i < lines.length; i++) {
|
|
447931
448396
|
if (fileResults.length >= 10) {
|
|
@@ -448038,7 +448503,7 @@ var init_FileList = __esm({
|
|
|
448038
448503
|
if (allFilteredFiles.length > 0 && selectedIndex < allFilteredFiles.length && allFilteredFiles[selectedIndex]) {
|
|
448039
448504
|
const selectedFile = allFilteredFiles[selectedIndex];
|
|
448040
448505
|
const baseDir = selectedFile.sourceDir || rootPath;
|
|
448041
|
-
const fullPath =
|
|
448506
|
+
const fullPath = path43.join(baseDir, selectedFile.path);
|
|
448042
448507
|
if (selectedFile.lineNumber !== void 0) {
|
|
448043
448508
|
return `${fullPath}:${selectedFile.lineNumber}`;
|
|
448044
448509
|
}
|
|
@@ -449520,7 +449985,7 @@ var init_build6 = __esm({
|
|
|
449520
449985
|
});
|
|
449521
449986
|
|
|
449522
449987
|
// dist/ui/components/tools/ToolConfirmation.js
|
|
449523
|
-
import
|
|
449988
|
+
import fs35 from "fs";
|
|
449524
449989
|
function formatArgumentValue(value, maxLength = 100) {
|
|
449525
449990
|
if (value === null || value === void 0) {
|
|
449526
449991
|
return String(value);
|
|
@@ -449644,16 +450109,16 @@ Output: ${combinedOutput}`);
|
|
|
449644
450109
|
for (const fileConfig of filePathData) {
|
|
449645
450110
|
const filePath = typeof fileConfig === "string" ? fileConfig : fileConfig.path;
|
|
449646
450111
|
const newContent = typeof fileConfig === "string" ? parsed.newContent : fileConfig.newContent;
|
|
449647
|
-
if (typeof filePath === "string" && newContent &&
|
|
449648
|
-
const originalContent =
|
|
450112
|
+
if (typeof filePath === "string" && newContent && fs35.existsSync(filePath)) {
|
|
450113
|
+
const originalContent = fs35.readFileSync(filePath, "utf-8");
|
|
449649
450114
|
promises.push(vscodeConnection.showDiff(filePath, originalContent, newContent, "Edit").catch(() => {
|
|
449650
450115
|
}));
|
|
449651
450116
|
}
|
|
449652
450117
|
}
|
|
449653
450118
|
} else if (typeof parsed.filePath === "string" && parsed.newContent) {
|
|
449654
450119
|
const filePath = parsed.filePath;
|
|
449655
|
-
if (
|
|
449656
|
-
const originalContent =
|
|
450120
|
+
if (fs35.existsSync(filePath)) {
|
|
450121
|
+
const originalContent = fs35.readFileSync(filePath, "utf-8");
|
|
449657
450122
|
promises.push(vscodeConnection.showDiff(filePath, originalContent, parsed.newContent, "Edit").catch(() => {
|
|
449658
450123
|
}));
|
|
449659
450124
|
}
|
|
@@ -449672,8 +450137,8 @@ Output: ${combinedOutput}`);
|
|
|
449672
450137
|
const filePath = typeof fileConfig === "string" ? fileConfig : fileConfig.path;
|
|
449673
450138
|
const searchContent = typeof fileConfig === "string" ? parsed.searchContent : fileConfig.searchContent;
|
|
449674
450139
|
const replaceContent = typeof fileConfig === "string" ? parsed.replaceContent : fileConfig.replaceContent;
|
|
449675
|
-
if (typeof filePath === "string" && searchContent && replaceContent &&
|
|
449676
|
-
const originalContent =
|
|
450140
|
+
if (typeof filePath === "string" && searchContent && replaceContent && fs35.existsSync(filePath)) {
|
|
450141
|
+
const originalContent = fs35.readFileSync(filePath, "utf-8");
|
|
449677
450142
|
const newContent = originalContent.replace(searchContent, replaceContent);
|
|
449678
450143
|
promises.push(vscodeConnection.showDiff(filePath, originalContent, newContent, "Search & Replace").catch(() => {
|
|
449679
450144
|
}));
|
|
@@ -449681,8 +450146,8 @@ Output: ${combinedOutput}`);
|
|
|
449681
450146
|
}
|
|
449682
450147
|
} else if (typeof parsed.filePath === "string" && parsed.searchContent && parsed.replaceContent) {
|
|
449683
450148
|
const filePath = parsed.filePath;
|
|
449684
|
-
if (
|
|
449685
|
-
const originalContent =
|
|
450149
|
+
if (fs35.existsSync(filePath)) {
|
|
450150
|
+
const originalContent = fs35.readFileSync(filePath, "utf-8");
|
|
449686
450151
|
const newContent = originalContent.replace(parsed.searchContent, parsed.replaceContent);
|
|
449687
450152
|
promises.push(vscodeConnection.showDiff(filePath, originalContent, newContent, "Search & Replace").catch(() => {
|
|
449688
450153
|
}));
|
|
@@ -527427,9 +527892,9 @@ var UsagePanel_exports = {};
|
|
|
527427
527892
|
__export(UsagePanel_exports, {
|
|
527428
527893
|
default: () => UsagePanel
|
|
527429
527894
|
});
|
|
527430
|
-
import
|
|
527431
|
-
import
|
|
527432
|
-
import
|
|
527895
|
+
import fs36 from "fs/promises";
|
|
527896
|
+
import path44 from "path";
|
|
527897
|
+
import os20 from "os";
|
|
527433
527898
|
function getModelShortName(modelName, maxLength = 20) {
|
|
527434
527899
|
let name = modelName;
|
|
527435
527900
|
name = name.replace(/-?\d{8}$/g, "");
|
|
@@ -527492,22 +527957,22 @@ function getModelShortName(modelName, maxLength = 20) {
|
|
|
527492
527957
|
return result2.length > maxLength ? result2.slice(0, maxLength) : result2;
|
|
527493
527958
|
}
|
|
527494
527959
|
async function loadUsageData() {
|
|
527495
|
-
const homeDir =
|
|
527496
|
-
const usageDir =
|
|
527960
|
+
const homeDir = os20.homedir();
|
|
527961
|
+
const usageDir = path44.join(homeDir, ".snow", "usage");
|
|
527497
527962
|
try {
|
|
527498
527963
|
const entries = [];
|
|
527499
|
-
const dateDirs = await
|
|
527964
|
+
const dateDirs = await fs36.readdir(usageDir);
|
|
527500
527965
|
for (const dateDir of dateDirs) {
|
|
527501
|
-
const datePath =
|
|
527502
|
-
const stats = await
|
|
527966
|
+
const datePath = path44.join(usageDir, dateDir);
|
|
527967
|
+
const stats = await fs36.stat(datePath);
|
|
527503
527968
|
if (!stats.isDirectory())
|
|
527504
527969
|
continue;
|
|
527505
|
-
const files = await
|
|
527970
|
+
const files = await fs36.readdir(datePath);
|
|
527506
527971
|
for (const file of files) {
|
|
527507
527972
|
if (!file.endsWith(".jsonl"))
|
|
527508
527973
|
continue;
|
|
527509
|
-
const filePath =
|
|
527510
|
-
const content = await
|
|
527974
|
+
const filePath = path44.join(datePath, file);
|
|
527975
|
+
const content = await fs36.readFile(filePath, "utf-8");
|
|
527511
527976
|
const lines = content.trim().split("\n").filter((l2) => l2.trim());
|
|
527512
527977
|
for (const line of lines) {
|
|
527513
527978
|
try {
|
|
@@ -528942,844 +529407,6 @@ var init_toolDisplayConfig = __esm({
|
|
|
528942
529407
|
}
|
|
528943
529408
|
});
|
|
528944
529409
|
|
|
528945
|
-
// node_modules/ignore/index.js
|
|
528946
|
-
var require_ignore = __commonJS({
|
|
528947
|
-
"node_modules/ignore/index.js"(exports2, module2) {
|
|
528948
|
-
function makeArray(subject) {
|
|
528949
|
-
return Array.isArray(subject) ? subject : [subject];
|
|
528950
|
-
}
|
|
528951
|
-
var UNDEFINED = void 0;
|
|
528952
|
-
var EMPTY2 = "";
|
|
528953
|
-
var SPACE = " ";
|
|
528954
|
-
var ESCAPE = "\\";
|
|
528955
|
-
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
528956
|
-
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
528957
|
-
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
528958
|
-
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
528959
|
-
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
528960
|
-
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
528961
|
-
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
528962
|
-
var SLASH2 = "/";
|
|
528963
|
-
var TMP_KEY_IGNORE = "node-ignore";
|
|
528964
|
-
if (typeof Symbol !== "undefined") {
|
|
528965
|
-
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
528966
|
-
}
|
|
528967
|
-
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
528968
|
-
var define2 = (object2, key, value) => {
|
|
528969
|
-
Object.defineProperty(object2, key, { value });
|
|
528970
|
-
return value;
|
|
528971
|
-
};
|
|
528972
|
-
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
528973
|
-
var RETURN_FALSE = () => false;
|
|
528974
|
-
var sanitizeRange = (range2) => range2.replace(
|
|
528975
|
-
REGEX_REGEXP_RANGE,
|
|
528976
|
-
(match2, from2, to) => from2.charCodeAt(0) <= to.charCodeAt(0) ? match2 : EMPTY2
|
|
528977
|
-
);
|
|
528978
|
-
var cleanRangeBackSlash = (slashes) => {
|
|
528979
|
-
const { length } = slashes;
|
|
528980
|
-
return slashes.slice(0, length - length % 2);
|
|
528981
|
-
};
|
|
528982
|
-
var REPLACERS = [
|
|
528983
|
-
[
|
|
528984
|
-
// Remove BOM
|
|
528985
|
-
// TODO:
|
|
528986
|
-
// Other similar zero-width characters?
|
|
528987
|
-
/^\uFEFF/,
|
|
528988
|
-
() => EMPTY2
|
|
528989
|
-
],
|
|
528990
|
-
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
528991
|
-
[
|
|
528992
|
-
// (a\ ) -> (a )
|
|
528993
|
-
// (a ) -> (a)
|
|
528994
|
-
// (a ) -> (a)
|
|
528995
|
-
// (a \ ) -> (a )
|
|
528996
|
-
/((?:\\\\)*?)(\\?\s+)$/,
|
|
528997
|
-
(_3, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY2)
|
|
528998
|
-
],
|
|
528999
|
-
// Replace (\ ) with ' '
|
|
529000
|
-
// (\ ) -> ' '
|
|
529001
|
-
// (\\ ) -> '\\ '
|
|
529002
|
-
// (\\\ ) -> '\\ '
|
|
529003
|
-
[
|
|
529004
|
-
/(\\+?)\s/g,
|
|
529005
|
-
(_3, m1) => {
|
|
529006
|
-
const { length } = m1;
|
|
529007
|
-
return m1.slice(0, length - length % 2) + SPACE;
|
|
529008
|
-
}
|
|
529009
|
-
],
|
|
529010
|
-
// Escape metacharacters
|
|
529011
|
-
// which is written down by users but means special for regular expressions.
|
|
529012
|
-
// > There are 12 characters with special meanings:
|
|
529013
|
-
// > - the backslash \,
|
|
529014
|
-
// > - the caret ^,
|
|
529015
|
-
// > - the dollar sign $,
|
|
529016
|
-
// > - the period or dot .,
|
|
529017
|
-
// > - the vertical bar or pipe symbol |,
|
|
529018
|
-
// > - the question mark ?,
|
|
529019
|
-
// > - the asterisk or star *,
|
|
529020
|
-
// > - the plus sign +,
|
|
529021
|
-
// > - the opening parenthesis (,
|
|
529022
|
-
// > - the closing parenthesis ),
|
|
529023
|
-
// > - and the opening square bracket [,
|
|
529024
|
-
// > - the opening curly brace {,
|
|
529025
|
-
// > These special characters are often called "metacharacters".
|
|
529026
|
-
[
|
|
529027
|
-
/[\\$.|*+(){^]/g,
|
|
529028
|
-
(match2) => `\\${match2}`
|
|
529029
|
-
],
|
|
529030
|
-
[
|
|
529031
|
-
// > a question mark (?) matches a single character
|
|
529032
|
-
/(?!\\)\?/g,
|
|
529033
|
-
() => "[^/]"
|
|
529034
|
-
],
|
|
529035
|
-
// leading slash
|
|
529036
|
-
[
|
|
529037
|
-
// > A leading slash matches the beginning of the pathname.
|
|
529038
|
-
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
529039
|
-
// A leading slash matches the beginning of the pathname
|
|
529040
|
-
/^\//,
|
|
529041
|
-
() => "^"
|
|
529042
|
-
],
|
|
529043
|
-
// replace special metacharacter slash after the leading slash
|
|
529044
|
-
[
|
|
529045
|
-
/\//g,
|
|
529046
|
-
() => "\\/"
|
|
529047
|
-
],
|
|
529048
|
-
[
|
|
529049
|
-
// > A leading "**" followed by a slash means match in all directories.
|
|
529050
|
-
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
529051
|
-
// > the same as pattern "foo".
|
|
529052
|
-
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
529053
|
-
// > under directory "foo".
|
|
529054
|
-
// Notice that the '*'s have been replaced as '\\*'
|
|
529055
|
-
/^\^*\\\*\\\*\\\//,
|
|
529056
|
-
// '**/foo' <-> 'foo'
|
|
529057
|
-
() => "^(?:.*\\/)?"
|
|
529058
|
-
],
|
|
529059
|
-
// starting
|
|
529060
|
-
[
|
|
529061
|
-
// there will be no leading '/'
|
|
529062
|
-
// (which has been replaced by section "leading slash")
|
|
529063
|
-
// If starts with '**', adding a '^' to the regular expression also works
|
|
529064
|
-
/^(?=[^^])/,
|
|
529065
|
-
function startingReplacer() {
|
|
529066
|
-
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
529067
|
-
}
|
|
529068
|
-
],
|
|
529069
|
-
// two globstars
|
|
529070
|
-
[
|
|
529071
|
-
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
529072
|
-
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
529073
|
-
// Zero, one or several directories
|
|
529074
|
-
// should not use '*', or it will be replaced by the next replacer
|
|
529075
|
-
// Check if it is not the last `'/**'`
|
|
529076
|
-
(_3, index, str2) => index + 6 < str2.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
529077
|
-
],
|
|
529078
|
-
// normal intermediate wildcards
|
|
529079
|
-
[
|
|
529080
|
-
// Never replace escaped '*'
|
|
529081
|
-
// ignore rule '\*' will match the path '*'
|
|
529082
|
-
// 'abc.*/' -> go
|
|
529083
|
-
// 'abc.*' -> skip this rule,
|
|
529084
|
-
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
529085
|
-
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
529086
|
-
// '*.js' matches '.js'
|
|
529087
|
-
// '*.js' doesn't match 'abc'
|
|
529088
|
-
(_3, p1, p2) => {
|
|
529089
|
-
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
529090
|
-
return p1 + unescaped;
|
|
529091
|
-
}
|
|
529092
|
-
],
|
|
529093
|
-
[
|
|
529094
|
-
// unescape, revert step 3 except for back slash
|
|
529095
|
-
// For example, if a user escape a '\\*',
|
|
529096
|
-
// after step 3, the result will be '\\\\\\*'
|
|
529097
|
-
/\\\\\\(?=[$.|*+(){^])/g,
|
|
529098
|
-
() => ESCAPE
|
|
529099
|
-
],
|
|
529100
|
-
[
|
|
529101
|
-
// '\\\\' -> '\\'
|
|
529102
|
-
/\\\\/g,
|
|
529103
|
-
() => ESCAPE
|
|
529104
|
-
],
|
|
529105
|
-
[
|
|
529106
|
-
// > The range notation, e.g. [a-zA-Z],
|
|
529107
|
-
// > can be used to match one of the characters in a range.
|
|
529108
|
-
// `\` is escaped by step 3
|
|
529109
|
-
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
529110
|
-
(match2, leadEscape, range2, endEscape, close) => leadEscape === ESCAPE ? `\\[${range2}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range2)}${endEscape}]` : "[]" : "[]"
|
|
529111
|
-
],
|
|
529112
|
-
// ending
|
|
529113
|
-
[
|
|
529114
|
-
// 'js' will not match 'js.'
|
|
529115
|
-
// 'ab' will not match 'abc'
|
|
529116
|
-
/(?:[^*])$/,
|
|
529117
|
-
// WTF!
|
|
529118
|
-
// https://git-scm.com/docs/gitignore
|
|
529119
|
-
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
529120
|
-
// which re-fixes #24, #38
|
|
529121
|
-
// > If there is a separator at the end of the pattern then the pattern
|
|
529122
|
-
// > will only match directories, otherwise the pattern can match both
|
|
529123
|
-
// > files and directories.
|
|
529124
|
-
// 'js*' will not match 'a.js'
|
|
529125
|
-
// 'js/' will not match 'a.js'
|
|
529126
|
-
// 'js' will match 'a.js' and 'a.js/'
|
|
529127
|
-
(match2) => /\/$/.test(match2) ? `${match2}$` : `${match2}(?=$|\\/$)`
|
|
529128
|
-
]
|
|
529129
|
-
];
|
|
529130
|
-
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
|
|
529131
|
-
var MODE_IGNORE = "regex";
|
|
529132
|
-
var MODE_CHECK_IGNORE = "checkRegex";
|
|
529133
|
-
var UNDERSCORE = "_";
|
|
529134
|
-
var TRAILING_WILD_CARD_REPLACERS = {
|
|
529135
|
-
[MODE_IGNORE](_3, p1) {
|
|
529136
|
-
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
529137
|
-
return `${prefix}(?=$|\\/$)`;
|
|
529138
|
-
},
|
|
529139
|
-
[MODE_CHECK_IGNORE](_3, p1) {
|
|
529140
|
-
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
529141
|
-
return `${prefix}(?=$|\\/$)`;
|
|
529142
|
-
}
|
|
529143
|
-
};
|
|
529144
|
-
var makeRegexPrefix = (pattern) => REPLACERS.reduce(
|
|
529145
|
-
(prev, [matcher2, replacer]) => prev.replace(matcher2, replacer.bind(pattern)),
|
|
529146
|
-
pattern
|
|
529147
|
-
);
|
|
529148
|
-
var isString4 = (subject) => typeof subject === "string";
|
|
529149
|
-
var checkPattern = (pattern) => pattern && isString4(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
529150
|
-
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
529151
|
-
var IgnoreRule = class {
|
|
529152
|
-
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
529153
|
-
this.pattern = pattern;
|
|
529154
|
-
this.mark = mark;
|
|
529155
|
-
this.negative = negative;
|
|
529156
|
-
define2(this, "body", body);
|
|
529157
|
-
define2(this, "ignoreCase", ignoreCase);
|
|
529158
|
-
define2(this, "regexPrefix", prefix);
|
|
529159
|
-
}
|
|
529160
|
-
get regex() {
|
|
529161
|
-
const key = UNDERSCORE + MODE_IGNORE;
|
|
529162
|
-
if (this[key]) {
|
|
529163
|
-
return this[key];
|
|
529164
|
-
}
|
|
529165
|
-
return this._make(MODE_IGNORE, key);
|
|
529166
|
-
}
|
|
529167
|
-
get checkRegex() {
|
|
529168
|
-
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
529169
|
-
if (this[key]) {
|
|
529170
|
-
return this[key];
|
|
529171
|
-
}
|
|
529172
|
-
return this._make(MODE_CHECK_IGNORE, key);
|
|
529173
|
-
}
|
|
529174
|
-
_make(mode, key) {
|
|
529175
|
-
const str2 = this.regexPrefix.replace(
|
|
529176
|
-
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
529177
|
-
// It does not need to bind pattern
|
|
529178
|
-
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
529179
|
-
);
|
|
529180
|
-
const regex2 = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
|
|
529181
|
-
return define2(this, key, regex2);
|
|
529182
|
-
}
|
|
529183
|
-
};
|
|
529184
|
-
var createRule = ({
|
|
529185
|
-
pattern,
|
|
529186
|
-
mark
|
|
529187
|
-
}, ignoreCase) => {
|
|
529188
|
-
let negative = false;
|
|
529189
|
-
let body = pattern;
|
|
529190
|
-
if (body.indexOf("!") === 0) {
|
|
529191
|
-
negative = true;
|
|
529192
|
-
body = body.substr(1);
|
|
529193
|
-
}
|
|
529194
|
-
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
529195
|
-
const regexPrefix = makeRegexPrefix(body);
|
|
529196
|
-
return new IgnoreRule(
|
|
529197
|
-
pattern,
|
|
529198
|
-
mark,
|
|
529199
|
-
body,
|
|
529200
|
-
ignoreCase,
|
|
529201
|
-
negative,
|
|
529202
|
-
regexPrefix
|
|
529203
|
-
);
|
|
529204
|
-
};
|
|
529205
|
-
var RuleManager = class {
|
|
529206
|
-
constructor(ignoreCase) {
|
|
529207
|
-
this._ignoreCase = ignoreCase;
|
|
529208
|
-
this._rules = [];
|
|
529209
|
-
}
|
|
529210
|
-
_add(pattern) {
|
|
529211
|
-
if (pattern && pattern[KEY_IGNORE]) {
|
|
529212
|
-
this._rules = this._rules.concat(pattern._rules._rules);
|
|
529213
|
-
this._added = true;
|
|
529214
|
-
return;
|
|
529215
|
-
}
|
|
529216
|
-
if (isString4(pattern)) {
|
|
529217
|
-
pattern = {
|
|
529218
|
-
pattern
|
|
529219
|
-
};
|
|
529220
|
-
}
|
|
529221
|
-
if (checkPattern(pattern.pattern)) {
|
|
529222
|
-
const rule = createRule(pattern, this._ignoreCase);
|
|
529223
|
-
this._added = true;
|
|
529224
|
-
this._rules.push(rule);
|
|
529225
|
-
}
|
|
529226
|
-
}
|
|
529227
|
-
// @param {Array<string> | string | Ignore} pattern
|
|
529228
|
-
add(pattern) {
|
|
529229
|
-
this._added = false;
|
|
529230
|
-
makeArray(
|
|
529231
|
-
isString4(pattern) ? splitPattern(pattern) : pattern
|
|
529232
|
-
).forEach(this._add, this);
|
|
529233
|
-
return this._added;
|
|
529234
|
-
}
|
|
529235
|
-
// Test one single path without recursively checking parent directories
|
|
529236
|
-
//
|
|
529237
|
-
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
529238
|
-
// setting `checkUnignored` to `false` could reduce additional
|
|
529239
|
-
// path matching.
|
|
529240
|
-
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
529241
|
-
// @returns {TestResult} true if a file is ignored
|
|
529242
|
-
test(path49, checkUnignored, mode) {
|
|
529243
|
-
let ignored = false;
|
|
529244
|
-
let unignored = false;
|
|
529245
|
-
let matchedRule;
|
|
529246
|
-
this._rules.forEach((rule) => {
|
|
529247
|
-
const { negative } = rule;
|
|
529248
|
-
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
529249
|
-
return;
|
|
529250
|
-
}
|
|
529251
|
-
const matched = rule[mode].test(path49);
|
|
529252
|
-
if (!matched) {
|
|
529253
|
-
return;
|
|
529254
|
-
}
|
|
529255
|
-
ignored = !negative;
|
|
529256
|
-
unignored = negative;
|
|
529257
|
-
matchedRule = negative ? UNDEFINED : rule;
|
|
529258
|
-
});
|
|
529259
|
-
const ret2 = {
|
|
529260
|
-
ignored,
|
|
529261
|
-
unignored
|
|
529262
|
-
};
|
|
529263
|
-
if (matchedRule) {
|
|
529264
|
-
ret2.rule = matchedRule;
|
|
529265
|
-
}
|
|
529266
|
-
return ret2;
|
|
529267
|
-
}
|
|
529268
|
-
};
|
|
529269
|
-
var throwError = (message, Ctor) => {
|
|
529270
|
-
throw new Ctor(message);
|
|
529271
|
-
};
|
|
529272
|
-
var checkPath = (path49, originalPath, doThrow) => {
|
|
529273
|
-
if (!isString4(path49)) {
|
|
529274
|
-
return doThrow(
|
|
529275
|
-
`path must be a string, but got \`${originalPath}\``,
|
|
529276
|
-
TypeError
|
|
529277
|
-
);
|
|
529278
|
-
}
|
|
529279
|
-
if (!path49) {
|
|
529280
|
-
return doThrow(`path must not be empty`, TypeError);
|
|
529281
|
-
}
|
|
529282
|
-
if (checkPath.isNotRelative(path49)) {
|
|
529283
|
-
const r = "`path.relative()`d";
|
|
529284
|
-
return doThrow(
|
|
529285
|
-
`path should be a ${r} string, but got "${originalPath}"`,
|
|
529286
|
-
RangeError
|
|
529287
|
-
);
|
|
529288
|
-
}
|
|
529289
|
-
return true;
|
|
529290
|
-
};
|
|
529291
|
-
var isNotRelative = (path49) => REGEX_TEST_INVALID_PATH.test(path49);
|
|
529292
|
-
checkPath.isNotRelative = isNotRelative;
|
|
529293
|
-
checkPath.convert = (p) => p;
|
|
529294
|
-
var Ignore = class {
|
|
529295
|
-
constructor({
|
|
529296
|
-
ignorecase = true,
|
|
529297
|
-
ignoreCase = ignorecase,
|
|
529298
|
-
allowRelativePaths = false
|
|
529299
|
-
} = {}) {
|
|
529300
|
-
define2(this, KEY_IGNORE, true);
|
|
529301
|
-
this._rules = new RuleManager(ignoreCase);
|
|
529302
|
-
this._strictPathCheck = !allowRelativePaths;
|
|
529303
|
-
this._initCache();
|
|
529304
|
-
}
|
|
529305
|
-
_initCache() {
|
|
529306
|
-
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
529307
|
-
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
529308
|
-
}
|
|
529309
|
-
add(pattern) {
|
|
529310
|
-
if (this._rules.add(pattern)) {
|
|
529311
|
-
this._initCache();
|
|
529312
|
-
}
|
|
529313
|
-
return this;
|
|
529314
|
-
}
|
|
529315
|
-
// legacy
|
|
529316
|
-
addPattern(pattern) {
|
|
529317
|
-
return this.add(pattern);
|
|
529318
|
-
}
|
|
529319
|
-
// @returns {TestResult}
|
|
529320
|
-
_test(originalPath, cache4, checkUnignored, slices) {
|
|
529321
|
-
const path49 = originalPath && checkPath.convert(originalPath);
|
|
529322
|
-
checkPath(
|
|
529323
|
-
path49,
|
|
529324
|
-
originalPath,
|
|
529325
|
-
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
529326
|
-
);
|
|
529327
|
-
return this._t(path49, cache4, checkUnignored, slices);
|
|
529328
|
-
}
|
|
529329
|
-
checkIgnore(path49) {
|
|
529330
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(path49)) {
|
|
529331
|
-
return this.test(path49);
|
|
529332
|
-
}
|
|
529333
|
-
const slices = path49.split(SLASH2).filter(Boolean);
|
|
529334
|
-
slices.pop();
|
|
529335
|
-
if (slices.length) {
|
|
529336
|
-
const parent = this._t(
|
|
529337
|
-
slices.join(SLASH2) + SLASH2,
|
|
529338
|
-
this._testCache,
|
|
529339
|
-
true,
|
|
529340
|
-
slices
|
|
529341
|
-
);
|
|
529342
|
-
if (parent.ignored) {
|
|
529343
|
-
return parent;
|
|
529344
|
-
}
|
|
529345
|
-
}
|
|
529346
|
-
return this._rules.test(path49, false, MODE_CHECK_IGNORE);
|
|
529347
|
-
}
|
|
529348
|
-
_t(path49, cache4, checkUnignored, slices) {
|
|
529349
|
-
if (path49 in cache4) {
|
|
529350
|
-
return cache4[path49];
|
|
529351
|
-
}
|
|
529352
|
-
if (!slices) {
|
|
529353
|
-
slices = path49.split(SLASH2).filter(Boolean);
|
|
529354
|
-
}
|
|
529355
|
-
slices.pop();
|
|
529356
|
-
if (!slices.length) {
|
|
529357
|
-
return cache4[path49] = this._rules.test(path49, checkUnignored, MODE_IGNORE);
|
|
529358
|
-
}
|
|
529359
|
-
const parent = this._t(
|
|
529360
|
-
slices.join(SLASH2) + SLASH2,
|
|
529361
|
-
cache4,
|
|
529362
|
-
checkUnignored,
|
|
529363
|
-
slices
|
|
529364
|
-
);
|
|
529365
|
-
return cache4[path49] = parent.ignored ? parent : this._rules.test(path49, checkUnignored, MODE_IGNORE);
|
|
529366
|
-
}
|
|
529367
|
-
ignores(path49) {
|
|
529368
|
-
return this._test(path49, this._ignoreCache, false).ignored;
|
|
529369
|
-
}
|
|
529370
|
-
createFilter() {
|
|
529371
|
-
return (path49) => !this.ignores(path49);
|
|
529372
|
-
}
|
|
529373
|
-
filter(paths) {
|
|
529374
|
-
return makeArray(paths).filter(this.createFilter());
|
|
529375
|
-
}
|
|
529376
|
-
// @returns {TestResult}
|
|
529377
|
-
test(path49) {
|
|
529378
|
-
return this._test(path49, this._testCache, true);
|
|
529379
|
-
}
|
|
529380
|
-
};
|
|
529381
|
-
var factory = (options3) => new Ignore(options3);
|
|
529382
|
-
var isPathValid = (path49) => checkPath(path49 && checkPath.convert(path49), path49, RETURN_FALSE);
|
|
529383
|
-
var setupWindows = () => {
|
|
529384
|
-
const makePosix = (str2) => /^\\\\\?\\/.test(str2) || /["<>|\u0000-\u001F]+/u.test(str2) ? str2 : str2.replace(/\\/g, "/");
|
|
529385
|
-
checkPath.convert = makePosix;
|
|
529386
|
-
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
529387
|
-
checkPath.isNotRelative = (path49) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path49) || isNotRelative(path49);
|
|
529388
|
-
};
|
|
529389
|
-
if (
|
|
529390
|
-
// Detect `process` so that it can run in browsers.
|
|
529391
|
-
typeof process !== "undefined" && process.platform === "win32"
|
|
529392
|
-
) {
|
|
529393
|
-
setupWindows();
|
|
529394
|
-
}
|
|
529395
|
-
module2.exports = factory;
|
|
529396
|
-
factory.default = factory;
|
|
529397
|
-
module2.exports.isPathValid = isPathValid;
|
|
529398
|
-
define2(module2.exports, Symbol.for("setupWindows"), setupWindows);
|
|
529399
|
-
}
|
|
529400
|
-
});
|
|
529401
|
-
|
|
529402
|
-
// dist/utils/codebase/hashBasedSnapshot.js
|
|
529403
|
-
import fs36 from "fs/promises";
|
|
529404
|
-
import fssync from "fs";
|
|
529405
|
-
import path44 from "path";
|
|
529406
|
-
import os20 from "os";
|
|
529407
|
-
import crypto4 from "crypto";
|
|
529408
|
-
var import_ignore, HashBasedSnapshotManager, hashBasedSnapshotManager;
|
|
529409
|
-
var init_hashBasedSnapshot = __esm({
|
|
529410
|
-
"dist/utils/codebase/hashBasedSnapshot.js"() {
|
|
529411
|
-
"use strict";
|
|
529412
|
-
import_ignore = __toESM(require_ignore(), 1);
|
|
529413
|
-
init_logger();
|
|
529414
|
-
init_projectUtils();
|
|
529415
|
-
HashBasedSnapshotManager = class {
|
|
529416
|
-
constructor() {
|
|
529417
|
-
Object.defineProperty(this, "snapshotsDir", {
|
|
529418
|
-
enumerable: true,
|
|
529419
|
-
configurable: true,
|
|
529420
|
-
writable: true,
|
|
529421
|
-
value: void 0
|
|
529422
|
-
});
|
|
529423
|
-
Object.defineProperty(this, "activeSnapshots", {
|
|
529424
|
-
enumerable: true,
|
|
529425
|
-
configurable: true,
|
|
529426
|
-
writable: true,
|
|
529427
|
-
value: /* @__PURE__ */ new Map()
|
|
529428
|
-
});
|
|
529429
|
-
Object.defineProperty(this, "ignoreFilter", {
|
|
529430
|
-
enumerable: true,
|
|
529431
|
-
configurable: true,
|
|
529432
|
-
writable: true,
|
|
529433
|
-
value: void 0
|
|
529434
|
-
});
|
|
529435
|
-
const projectId = getProjectId();
|
|
529436
|
-
this.snapshotsDir = path44.join(os20.homedir(), ".snow", ".git", "snapshots", projectId);
|
|
529437
|
-
this.ignoreFilter = (0, import_ignore.default)();
|
|
529438
|
-
this.loadIgnorePatterns();
|
|
529439
|
-
}
|
|
529440
|
-
/**
|
|
529441
|
-
* Load .gitignore patterns
|
|
529442
|
-
*/
|
|
529443
|
-
loadIgnorePatterns() {
|
|
529444
|
-
const workspaceRoot = process.cwd();
|
|
529445
|
-
const gitignorePath = path44.join(workspaceRoot, ".gitignore");
|
|
529446
|
-
if (fssync.existsSync(gitignorePath)) {
|
|
529447
|
-
try {
|
|
529448
|
-
const content = fssync.readFileSync(gitignorePath, "utf-8");
|
|
529449
|
-
this.ignoreFilter.add(content);
|
|
529450
|
-
} catch (error) {
|
|
529451
|
-
logger.warn("Failed to load .gitignore:", error);
|
|
529452
|
-
}
|
|
529453
|
-
}
|
|
529454
|
-
}
|
|
529455
|
-
/**
|
|
529456
|
-
* Scan directory recursively and collect file states (metadata only, no content)
|
|
529457
|
-
*/
|
|
529458
|
-
async scanDirectory(dirPath, workspaceRoot, fileStates, includeContent = false) {
|
|
529459
|
-
try {
|
|
529460
|
-
const entries = await fs36.readdir(dirPath, { withFileTypes: true });
|
|
529461
|
-
for (const entry of entries) {
|
|
529462
|
-
const fullPath = path44.join(dirPath, entry.name);
|
|
529463
|
-
const relativePath = path44.relative(workspaceRoot, fullPath);
|
|
529464
|
-
if (relativePath && this.ignoreFilter.ignores(relativePath)) {
|
|
529465
|
-
continue;
|
|
529466
|
-
}
|
|
529467
|
-
if (entry.isDirectory()) {
|
|
529468
|
-
await this.scanDirectory(fullPath, workspaceRoot, fileStates, includeContent);
|
|
529469
|
-
} else if (entry.isFile()) {
|
|
529470
|
-
try {
|
|
529471
|
-
const stats = await fs36.stat(fullPath);
|
|
529472
|
-
let content = "";
|
|
529473
|
-
let hash = "";
|
|
529474
|
-
if (includeContent) {
|
|
529475
|
-
content = await fs36.readFile(fullPath, "utf-8");
|
|
529476
|
-
hash = crypto4.createHash("sha256").update(content).digest("hex");
|
|
529477
|
-
} else {
|
|
529478
|
-
const buffer = await fs36.readFile(fullPath);
|
|
529479
|
-
hash = crypto4.createHash("sha256").update(buffer).digest("hex");
|
|
529480
|
-
}
|
|
529481
|
-
fileStates.set(relativePath, {
|
|
529482
|
-
path: relativePath,
|
|
529483
|
-
hash,
|
|
529484
|
-
size: stats.size,
|
|
529485
|
-
mtime: stats.mtimeMs,
|
|
529486
|
-
content: includeContent ? content : ""
|
|
529487
|
-
// Only store content if requested
|
|
529488
|
-
});
|
|
529489
|
-
} catch (error) {
|
|
529490
|
-
}
|
|
529491
|
-
}
|
|
529492
|
-
}
|
|
529493
|
-
} catch (error) {
|
|
529494
|
-
}
|
|
529495
|
-
}
|
|
529496
|
-
/**
|
|
529497
|
-
* Scan workspace and build file state map
|
|
529498
|
-
*/
|
|
529499
|
-
async scanWorkspace(workspaceRoot = process.cwd()) {
|
|
529500
|
-
const fileStates = /* @__PURE__ */ new Map();
|
|
529501
|
-
await this.scanDirectory(workspaceRoot, workspaceRoot, fileStates);
|
|
529502
|
-
return fileStates;
|
|
529503
|
-
}
|
|
529504
|
-
/**
|
|
529505
|
-
* Ensure snapshots directory exists
|
|
529506
|
-
*/
|
|
529507
|
-
async ensureSnapshotsDir() {
|
|
529508
|
-
await fs36.mkdir(this.snapshotsDir, { recursive: true });
|
|
529509
|
-
}
|
|
529510
|
-
/**
|
|
529511
|
-
* Get snapshot file path
|
|
529512
|
-
*/
|
|
529513
|
-
getSnapshotPath(sessionId, messageIndex) {
|
|
529514
|
-
return path44.join(this.snapshotsDir, `${sessionId}_${messageIndex}.json`);
|
|
529515
|
-
}
|
|
529516
|
-
/**
|
|
529517
|
-
* Create snapshot before message processing
|
|
529518
|
-
* Captures current workspace state by hash
|
|
529519
|
-
*/
|
|
529520
|
-
async createSnapshot(sessionId, messageIndex, workspaceRoot = process.cwd()) {
|
|
529521
|
-
const beforeStateMap = await this.scanWorkspace(workspaceRoot);
|
|
529522
|
-
const snapshotKey = `${sessionId}:${messageIndex}`;
|
|
529523
|
-
this.activeSnapshots.set(snapshotKey, {
|
|
529524
|
-
metadata: {
|
|
529525
|
-
sessionId,
|
|
529526
|
-
messageIndex,
|
|
529527
|
-
timestamp: Date.now(),
|
|
529528
|
-
workspaceRoot,
|
|
529529
|
-
backups: []
|
|
529530
|
-
},
|
|
529531
|
-
beforeStateMap
|
|
529532
|
-
});
|
|
529533
|
-
logger.info(`[Snapshot] Created snapshot for session ${sessionId} message ${messageIndex}`);
|
|
529534
|
-
}
|
|
529535
|
-
/**
|
|
529536
|
-
* Commit snapshot after message processing
|
|
529537
|
-
* Compares current workspace state with snapshot and saves changes
|
|
529538
|
-
* @param sessionId The session ID (required for session isolation)
|
|
529539
|
-
* @param messageIndex The message index to commit (if not provided, commits the oldest snapshot for this session)
|
|
529540
|
-
* @returns Object with fileCount and messageIndex, or null if no active snapshot
|
|
529541
|
-
*/
|
|
529542
|
-
async commitSnapshot(sessionId, messageIndex) {
|
|
529543
|
-
if (messageIndex === void 0) {
|
|
529544
|
-
const keys2 = Array.from(this.activeSnapshots.keys());
|
|
529545
|
-
const sessionKeys = keys2.filter((key) => key.startsWith(`${sessionId}:`)).map((key) => {
|
|
529546
|
-
const parts = key.split(":");
|
|
529547
|
-
return parseInt(parts[1] || "0", 10);
|
|
529548
|
-
}).filter((index) => !isNaN(index));
|
|
529549
|
-
if (sessionKeys.length === 0) {
|
|
529550
|
-
return null;
|
|
529551
|
-
}
|
|
529552
|
-
messageIndex = Math.min(...sessionKeys);
|
|
529553
|
-
}
|
|
529554
|
-
const snapshotKey = `${sessionId}:${messageIndex}`;
|
|
529555
|
-
const snapshot = this.activeSnapshots.get(snapshotKey);
|
|
529556
|
-
if (!snapshot) {
|
|
529557
|
-
logger.warn(`[Snapshot] No active snapshot found for session ${sessionId} message ${messageIndex}`);
|
|
529558
|
-
return null;
|
|
529559
|
-
}
|
|
529560
|
-
const { metadata, beforeStateMap } = snapshot;
|
|
529561
|
-
const workspaceRoot = metadata.workspaceRoot;
|
|
529562
|
-
const afterStateMap = await this.scanWorkspace(workspaceRoot);
|
|
529563
|
-
const changedFiles = [];
|
|
529564
|
-
for (const [relativePath, beforeState] of beforeStateMap) {
|
|
529565
|
-
const afterState = afterStateMap.get(relativePath);
|
|
529566
|
-
const fullPath = path44.join(workspaceRoot, relativePath);
|
|
529567
|
-
if (!afterState) {
|
|
529568
|
-
try {
|
|
529569
|
-
const content = await fs36.readFile(fullPath, "utf-8");
|
|
529570
|
-
changedFiles.push({
|
|
529571
|
-
path: relativePath,
|
|
529572
|
-
content,
|
|
529573
|
-
existed: true,
|
|
529574
|
-
hash: beforeState.hash
|
|
529575
|
-
});
|
|
529576
|
-
} catch {
|
|
529577
|
-
changedFiles.push({
|
|
529578
|
-
path: relativePath,
|
|
529579
|
-
content: null,
|
|
529580
|
-
existed: true,
|
|
529581
|
-
hash: beforeState.hash
|
|
529582
|
-
});
|
|
529583
|
-
}
|
|
529584
|
-
} else if (beforeState.hash !== afterState.hash) {
|
|
529585
|
-
try {
|
|
529586
|
-
const content = await fs36.readFile(fullPath, "utf-8");
|
|
529587
|
-
changedFiles.push({
|
|
529588
|
-
path: relativePath,
|
|
529589
|
-
content,
|
|
529590
|
-
existed: true,
|
|
529591
|
-
hash: beforeState.hash
|
|
529592
|
-
});
|
|
529593
|
-
} catch (error) {
|
|
529594
|
-
logger.warn(`Failed to read modified file ${relativePath}:`, error);
|
|
529595
|
-
}
|
|
529596
|
-
}
|
|
529597
|
-
}
|
|
529598
|
-
for (const [relativePath, afterState] of afterStateMap) {
|
|
529599
|
-
if (!beforeStateMap.has(relativePath)) {
|
|
529600
|
-
changedFiles.push({
|
|
529601
|
-
path: relativePath,
|
|
529602
|
-
content: null,
|
|
529603
|
-
// No need to store content for new files
|
|
529604
|
-
existed: false,
|
|
529605
|
-
hash: afterState.hash
|
|
529606
|
-
});
|
|
529607
|
-
}
|
|
529608
|
-
}
|
|
529609
|
-
if (changedFiles.length > 0) {
|
|
529610
|
-
metadata.backups = changedFiles;
|
|
529611
|
-
await this.saveSnapshotMetadata(metadata);
|
|
529612
|
-
logger.info(`[Snapshot] Committed: ${changedFiles.length} files changed for session ${sessionId} message ${messageIndex}`);
|
|
529613
|
-
} else {
|
|
529614
|
-
logger.info(`[Snapshot] No changes detected for session ${sessionId} message ${messageIndex}`);
|
|
529615
|
-
}
|
|
529616
|
-
this.activeSnapshots.delete(snapshotKey);
|
|
529617
|
-
return { fileCount: changedFiles.length, messageIndex };
|
|
529618
|
-
}
|
|
529619
|
-
/**
|
|
529620
|
-
* Save snapshot to disk
|
|
529621
|
-
*/
|
|
529622
|
-
async saveSnapshotMetadata(metadata) {
|
|
529623
|
-
await this.ensureSnapshotsDir();
|
|
529624
|
-
const snapshotPath = this.getSnapshotPath(metadata.sessionId, metadata.messageIndex);
|
|
529625
|
-
await fs36.writeFile(snapshotPath, JSON.stringify(metadata, null, 2));
|
|
529626
|
-
}
|
|
529627
|
-
/**
|
|
529628
|
-
* List all snapshots for a session
|
|
529629
|
-
*/
|
|
529630
|
-
async listSnapshots(sessionId) {
|
|
529631
|
-
await this.ensureSnapshotsDir();
|
|
529632
|
-
const snapshots = [];
|
|
529633
|
-
try {
|
|
529634
|
-
const files = await fs36.readdir(this.snapshotsDir);
|
|
529635
|
-
for (const file of files) {
|
|
529636
|
-
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
529637
|
-
const snapshotPath = path44.join(this.snapshotsDir, file);
|
|
529638
|
-
const content = await fs36.readFile(snapshotPath, "utf-8");
|
|
529639
|
-
const metadata = JSON.parse(content);
|
|
529640
|
-
snapshots.push({
|
|
529641
|
-
messageIndex: metadata.messageIndex,
|
|
529642
|
-
timestamp: metadata.timestamp,
|
|
529643
|
-
fileCount: metadata.backups.length
|
|
529644
|
-
});
|
|
529645
|
-
}
|
|
529646
|
-
}
|
|
529647
|
-
} catch (error) {
|
|
529648
|
-
logger.error("Failed to list snapshots:", error);
|
|
529649
|
-
}
|
|
529650
|
-
return snapshots.sort((a, b) => b.messageIndex - a.messageIndex);
|
|
529651
|
-
}
|
|
529652
|
-
/**
|
|
529653
|
-
* Get list of files affected by rollback
|
|
529654
|
-
*/
|
|
529655
|
-
async getFilesToRollback(sessionId, targetMessageIndex) {
|
|
529656
|
-
await this.ensureSnapshotsDir();
|
|
529657
|
-
try {
|
|
529658
|
-
const files = await fs36.readdir(this.snapshotsDir);
|
|
529659
|
-
const filesToRollback = /* @__PURE__ */ new Set();
|
|
529660
|
-
for (const file of files) {
|
|
529661
|
-
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
529662
|
-
const snapshotPath = path44.join(this.snapshotsDir, file);
|
|
529663
|
-
const content = await fs36.readFile(snapshotPath, "utf-8");
|
|
529664
|
-
const metadata = JSON.parse(content);
|
|
529665
|
-
if (metadata.messageIndex >= targetMessageIndex) {
|
|
529666
|
-
for (const backup of metadata.backups) {
|
|
529667
|
-
filesToRollback.add(backup.path);
|
|
529668
|
-
}
|
|
529669
|
-
}
|
|
529670
|
-
}
|
|
529671
|
-
}
|
|
529672
|
-
return Array.from(filesToRollback).sort();
|
|
529673
|
-
} catch (error) {
|
|
529674
|
-
logger.error("Failed to get files to rollback:", error);
|
|
529675
|
-
return [];
|
|
529676
|
-
}
|
|
529677
|
-
}
|
|
529678
|
-
/**
|
|
529679
|
-
* Rollback to a specific message index
|
|
529680
|
-
* Uses streaming approach to minimize memory usage
|
|
529681
|
-
*/
|
|
529682
|
-
async rollbackToMessageIndex(sessionId, targetMessageIndex, selectedFiles) {
|
|
529683
|
-
await this.ensureSnapshotsDir();
|
|
529684
|
-
try {
|
|
529685
|
-
const files = await fs36.readdir(this.snapshotsDir);
|
|
529686
|
-
const snapshotFiles = [];
|
|
529687
|
-
for (const file of files) {
|
|
529688
|
-
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
529689
|
-
const snapshotPath = path44.join(this.snapshotsDir, file);
|
|
529690
|
-
const content = await fs36.readFile(snapshotPath, "utf-8");
|
|
529691
|
-
const metadata = JSON.parse(content);
|
|
529692
|
-
if (metadata.messageIndex >= targetMessageIndex) {
|
|
529693
|
-
snapshotFiles.push({
|
|
529694
|
-
messageIndex: metadata.messageIndex,
|
|
529695
|
-
path: snapshotPath
|
|
529696
|
-
});
|
|
529697
|
-
}
|
|
529698
|
-
}
|
|
529699
|
-
}
|
|
529700
|
-
snapshotFiles.sort((a, b) => b.messageIndex - a.messageIndex);
|
|
529701
|
-
let totalFilesRolledBack = 0;
|
|
529702
|
-
for (const snapshotFile of snapshotFiles) {
|
|
529703
|
-
const content = await fs36.readFile(snapshotFile.path, "utf-8");
|
|
529704
|
-
const metadata = JSON.parse(content);
|
|
529705
|
-
for (const backup of metadata.backups) {
|
|
529706
|
-
if (selectedFiles && selectedFiles.length > 0 && !selectedFiles.includes(backup.path)) {
|
|
529707
|
-
continue;
|
|
529708
|
-
}
|
|
529709
|
-
const fullPath = path44.join(metadata.workspaceRoot, backup.path);
|
|
529710
|
-
try {
|
|
529711
|
-
if (backup.existed && backup.content !== null) {
|
|
529712
|
-
await fs36.writeFile(fullPath, backup.content, "utf-8");
|
|
529713
|
-
totalFilesRolledBack++;
|
|
529714
|
-
} else if (!backup.existed) {
|
|
529715
|
-
try {
|
|
529716
|
-
await fs36.unlink(fullPath);
|
|
529717
|
-
totalFilesRolledBack++;
|
|
529718
|
-
} catch {
|
|
529719
|
-
}
|
|
529720
|
-
}
|
|
529721
|
-
} catch (error) {
|
|
529722
|
-
logger.error(`Failed to restore file ${backup.path}:`, error);
|
|
529723
|
-
}
|
|
529724
|
-
}
|
|
529725
|
-
}
|
|
529726
|
-
return totalFilesRolledBack;
|
|
529727
|
-
} catch (error) {
|
|
529728
|
-
logger.error("Failed to rollback to message index:", error);
|
|
529729
|
-
return 0;
|
|
529730
|
-
}
|
|
529731
|
-
}
|
|
529732
|
-
/**
|
|
529733
|
-
* Delete snapshots from a specific message index onwards
|
|
529734
|
-
*/
|
|
529735
|
-
async deleteSnapshotsFromIndex(sessionId, targetMessageIndex) {
|
|
529736
|
-
await this.ensureSnapshotsDir();
|
|
529737
|
-
try {
|
|
529738
|
-
const files = await fs36.readdir(this.snapshotsDir);
|
|
529739
|
-
let deletedCount = 0;
|
|
529740
|
-
for (const file of files) {
|
|
529741
|
-
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
529742
|
-
const snapshotPath = path44.join(this.snapshotsDir, file);
|
|
529743
|
-
const content = await fs36.readFile(snapshotPath, "utf-8");
|
|
529744
|
-
const metadata = JSON.parse(content);
|
|
529745
|
-
if (metadata.messageIndex >= targetMessageIndex) {
|
|
529746
|
-
try {
|
|
529747
|
-
await fs36.unlink(snapshotPath);
|
|
529748
|
-
deletedCount++;
|
|
529749
|
-
} catch (error) {
|
|
529750
|
-
logger.error(`Failed to delete snapshot file ${snapshotPath}:`, error);
|
|
529751
|
-
}
|
|
529752
|
-
}
|
|
529753
|
-
}
|
|
529754
|
-
}
|
|
529755
|
-
return deletedCount;
|
|
529756
|
-
} catch (error) {
|
|
529757
|
-
logger.error("Failed to delete snapshots from index:", error);
|
|
529758
|
-
return 0;
|
|
529759
|
-
}
|
|
529760
|
-
}
|
|
529761
|
-
/**
|
|
529762
|
-
* Clear all snapshots for a session
|
|
529763
|
-
*/
|
|
529764
|
-
async clearAllSnapshots(sessionId) {
|
|
529765
|
-
await this.ensureSnapshotsDir();
|
|
529766
|
-
try {
|
|
529767
|
-
const files = await fs36.readdir(this.snapshotsDir);
|
|
529768
|
-
for (const file of files) {
|
|
529769
|
-
if (file.startsWith(sessionId) && file.endsWith(".json")) {
|
|
529770
|
-
const filePath = path44.join(this.snapshotsDir, file);
|
|
529771
|
-
await fs36.unlink(filePath);
|
|
529772
|
-
}
|
|
529773
|
-
}
|
|
529774
|
-
} catch (error) {
|
|
529775
|
-
logger.error("Failed to clear snapshots:", error);
|
|
529776
|
-
}
|
|
529777
|
-
}
|
|
529778
|
-
};
|
|
529779
|
-
hashBasedSnapshotManager = new HashBasedSnapshotManager();
|
|
529780
|
-
}
|
|
529781
|
-
});
|
|
529782
|
-
|
|
529783
529410
|
// dist/utils/core/contextCompressor.js
|
|
529784
529411
|
function findPreserveStartIndex(messages) {
|
|
529785
529412
|
if (messages.length === 0) {
|
|
@@ -531052,6 +530679,15 @@ async function handleConversationWithTools(options3) {
|
|
|
531052
530679
|
} catch (error) {
|
|
531053
530680
|
console.error("Failed to save user message:", error);
|
|
531054
530681
|
}
|
|
530682
|
+
try {
|
|
530683
|
+
const { setConversationContext: setConversationContext2 } = await Promise.resolve().then(() => (init_conversationContext(), conversationContext_exports));
|
|
530684
|
+
const updatedSession = sessionManager.getCurrentSession();
|
|
530685
|
+
if (updatedSession) {
|
|
530686
|
+
setConversationContext2(updatedSession.id, updatedSession.messages.length);
|
|
530687
|
+
}
|
|
530688
|
+
} catch (error) {
|
|
530689
|
+
console.error("Failed to set conversation context:", error);
|
|
530690
|
+
}
|
|
531055
530691
|
let encoder;
|
|
531056
530692
|
let encoderFreed = false;
|
|
531057
530693
|
const freeEncoder = () => {
|
|
@@ -531925,8 +531561,8 @@ async function handleConversationWithTools(options3) {
|
|
|
531925
531561
|
streaming: false
|
|
531926
531562
|
};
|
|
531927
531563
|
setMessages((prev) => [...prev, compressingMessage]);
|
|
531928
|
-
const
|
|
531929
|
-
const compressionResult = await performAutoCompression(
|
|
531564
|
+
const session2 = sessionManager.getCurrentSession();
|
|
531565
|
+
const compressionResult = await performAutoCompression(session2 == null ? void 0 : session2.id);
|
|
531930
531566
|
if (compressionResult && compressionResult.hookFailed) {
|
|
531931
531567
|
setMessages((prev) => [
|
|
531932
531568
|
...prev,
|
|
@@ -531955,9 +531591,9 @@ async function handleConversationWithTools(options3) {
|
|
|
531955
531591
|
accumulatedUsage = compressionResult.usage;
|
|
531956
531592
|
}
|
|
531957
531593
|
conversationMessages = [];
|
|
531958
|
-
const
|
|
531959
|
-
if (
|
|
531960
|
-
conversationMessages.push(...
|
|
531594
|
+
const session3 = sessionManager.getCurrentSession();
|
|
531595
|
+
if (session3 && session3.messages.length > 0) {
|
|
531596
|
+
conversationMessages.push(...session3.messages);
|
|
531961
531597
|
}
|
|
531962
531598
|
}
|
|
531963
531599
|
} catch (error) {
|
|
@@ -531971,15 +531607,6 @@ async function handleConversationWithTools(options3) {
|
|
|
531971
531607
|
data: img.data,
|
|
531972
531608
|
mimeType: img.mimeType
|
|
531973
531609
|
}));
|
|
531974
|
-
const session2 = sessionManager.getCurrentSession();
|
|
531975
|
-
let pendingMessageIndex = 0;
|
|
531976
|
-
if (session2) {
|
|
531977
|
-
options3.setMessages((prev) => {
|
|
531978
|
-
pendingMessageIndex = prev.length;
|
|
531979
|
-
return prev;
|
|
531980
|
-
});
|
|
531981
|
-
await hashBasedSnapshotManager.createSnapshot(session2.id, pendingMessageIndex);
|
|
531982
|
-
}
|
|
531983
531610
|
const userMessage = {
|
|
531984
531611
|
role: "user",
|
|
531985
531612
|
content: combinedMessage,
|
|
@@ -531991,13 +531618,20 @@ async function handleConversationWithTools(options3) {
|
|
|
531991
531618
|
content: combinedMessage,
|
|
531992
531619
|
images: allPendingImages.length > 0 ? allPendingImages : void 0
|
|
531993
531620
|
});
|
|
531994
|
-
|
|
531995
|
-
|
|
531996
|
-
|
|
531997
|
-
|
|
531998
|
-
|
|
531621
|
+
try {
|
|
531622
|
+
await saveMessage({
|
|
531623
|
+
role: "user",
|
|
531624
|
+
content: combinedMessage,
|
|
531625
|
+
images: allPendingImages.length > 0 ? allPendingImages : void 0
|
|
531626
|
+
});
|
|
531627
|
+
const { setConversationContext: setConversationContext2 } = await Promise.resolve().then(() => (init_conversationContext(), conversationContext_exports));
|
|
531628
|
+
const updatedSession = sessionManager.getCurrentSession();
|
|
531629
|
+
if (updatedSession) {
|
|
531630
|
+
setConversationContext2(updatedSession.id, updatedSession.messages.length);
|
|
531631
|
+
}
|
|
531632
|
+
} catch (error) {
|
|
531999
531633
|
console.error("Failed to save pending user message:", error);
|
|
532000
|
-
}
|
|
531634
|
+
}
|
|
532001
531635
|
}
|
|
532002
531636
|
}
|
|
532003
531637
|
continue;
|
|
@@ -532098,20 +531732,10 @@ async function handleConversationWithTools(options3) {
|
|
|
532098
531732
|
if (options3.setIsStreaming) {
|
|
532099
531733
|
options3.setIsStreaming(false);
|
|
532100
531734
|
}
|
|
532101
|
-
|
|
532102
|
-
|
|
532103
|
-
|
|
532104
|
-
|
|
532105
|
-
if (!result2)
|
|
532106
|
-
break;
|
|
532107
|
-
if (result2.fileCount > 0 && options3.setSnapshotFileCount) {
|
|
532108
|
-
options3.setSnapshotFileCount((prev) => {
|
|
532109
|
-
const newCounts = new Map(prev);
|
|
532110
|
-
newCounts.set(result2.messageIndex, result2.fileCount);
|
|
532111
|
-
return newCounts;
|
|
532112
|
-
});
|
|
532113
|
-
}
|
|
532114
|
-
}
|
|
531735
|
+
try {
|
|
531736
|
+
const { clearConversationContext: clearConversationContext2 } = await Promise.resolve().then(() => (init_conversationContext(), conversationContext_exports));
|
|
531737
|
+
clearConversationContext2();
|
|
531738
|
+
} catch (error) {
|
|
532115
531739
|
}
|
|
532116
531740
|
freeEncoder();
|
|
532117
531741
|
}
|
|
@@ -532137,7 +531761,6 @@ var init_useConversation = __esm({
|
|
|
532137
531761
|
init_messageFormatter();
|
|
532138
531762
|
init_resourceMonitor();
|
|
532139
531763
|
init_toolDisplayConfig();
|
|
532140
|
-
init_hashBasedSnapshot();
|
|
532141
531764
|
await init_autoCompress();
|
|
532142
531765
|
}
|
|
532143
531766
|
});
|
|
@@ -532545,8 +532168,8 @@ function useChatLogic(props) {
|
|
|
532545
532168
|
streaming: false
|
|
532546
532169
|
};
|
|
532547
532170
|
setMessages((prev) => [...prev, compressingMessage]);
|
|
532548
|
-
const
|
|
532549
|
-
const compressionResult = await performAutoCompression(
|
|
532171
|
+
const session = sessionManager.getCurrentSession();
|
|
532172
|
+
const compressionResult = await performAutoCompression(session == null ? void 0 : session.id);
|
|
532550
532173
|
if (compressionResult) {
|
|
532551
532174
|
clearSavedMessages();
|
|
532552
532175
|
setMessages(compressionResult.uiMessages);
|
|
@@ -532606,12 +532229,6 @@ ${errorMsg}`,
|
|
|
532606
532229
|
setMessages((prev) => [...prev, userMessage]);
|
|
532607
532230
|
}
|
|
532608
532231
|
streamingState.setIsStreaming(true);
|
|
532609
|
-
const session = sessionManager.getCurrentSession();
|
|
532610
|
-
if (session) {
|
|
532611
|
-
hashBasedSnapshotManager.createSnapshot(session.id, messages.length).catch((error) => {
|
|
532612
|
-
logger.warn("Failed to create snapshot:", error);
|
|
532613
|
-
});
|
|
532614
|
-
}
|
|
532615
532232
|
const controller = new AbortController();
|
|
532616
532233
|
streamingState.setAbortController(controller);
|
|
532617
532234
|
let originalMessage = message;
|
|
@@ -532676,18 +532293,6 @@ ${errorMsg}`,
|
|
|
532676
532293
|
setCurrentModel: streamingState.setCurrentModel
|
|
532677
532294
|
});
|
|
532678
532295
|
} finally {
|
|
532679
|
-
const session2 = sessionManager.getCurrentSession();
|
|
532680
|
-
let result2 = null;
|
|
532681
|
-
if (session2) {
|
|
532682
|
-
result2 = await hashBasedSnapshotManager.commitSnapshot(session2.id, messages.length);
|
|
532683
|
-
}
|
|
532684
|
-
if (result2 && result2.fileCount > 0) {
|
|
532685
|
-
if (session2) {
|
|
532686
|
-
const newCounts = new Map(snapshotState.snapshotFileCount);
|
|
532687
|
-
newCounts.set(result2.messageIndex, result2.fileCount);
|
|
532688
|
-
snapshotState.setSnapshotFileCount(newCounts);
|
|
532689
|
-
}
|
|
532690
|
-
}
|
|
532691
532296
|
}
|
|
532692
532297
|
} catch (error) {
|
|
532693
532298
|
if (!controller.signal.aborted && !userInterruptedRef.current) {
|
|
@@ -532701,11 +532306,11 @@ ${errorMsg}`,
|
|
|
532701
532306
|
}
|
|
532702
532307
|
} finally {
|
|
532703
532308
|
if (userInterruptedRef.current) {
|
|
532704
|
-
const
|
|
532705
|
-
if (
|
|
532309
|
+
const session = sessionManager.getCurrentSession();
|
|
532310
|
+
if (session && session.messages.length > 0) {
|
|
532706
532311
|
(async () => {
|
|
532707
532312
|
try {
|
|
532708
|
-
const messages2 =
|
|
532313
|
+
const messages2 = session.messages;
|
|
532709
532314
|
let truncateIndex = messages2.length;
|
|
532710
532315
|
for (let i = messages2.length - 1; i >= 0; i--) {
|
|
532711
532316
|
const msg = messages2[i];
|
|
@@ -532862,18 +532467,6 @@ ${errorMsg}`,
|
|
|
532862
532467
|
setCurrentModel: streamingState.setCurrentModel
|
|
532863
532468
|
});
|
|
532864
532469
|
} finally {
|
|
532865
|
-
const session = sessionManager.getCurrentSession();
|
|
532866
|
-
let result2 = null;
|
|
532867
|
-
if (session) {
|
|
532868
|
-
result2 = await hashBasedSnapshotManager.commitSnapshot(session.id);
|
|
532869
|
-
}
|
|
532870
|
-
if (result2 && result2.fileCount > 0) {
|
|
532871
|
-
if (session) {
|
|
532872
|
-
const newCounts = new Map(snapshotState.snapshotFileCount);
|
|
532873
|
-
newCounts.set(result2.messageIndex, result2.fileCount);
|
|
532874
|
-
snapshotState.setSnapshotFileCount(newCounts);
|
|
532875
|
-
}
|
|
532876
|
-
}
|
|
532877
532470
|
}
|
|
532878
532471
|
} catch (error) {
|
|
532879
532472
|
if (!controller.signal.aborted && !userInterruptedRef.current) {
|
|
@@ -533515,6 +533108,463 @@ var init_gitignoreValidator = __esm({
|
|
|
533515
533108
|
}
|
|
533516
533109
|
});
|
|
533517
533110
|
|
|
533111
|
+
// node_modules/ignore/index.js
|
|
533112
|
+
var require_ignore = __commonJS({
|
|
533113
|
+
"node_modules/ignore/index.js"(exports2, module2) {
|
|
533114
|
+
function makeArray(subject) {
|
|
533115
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
533116
|
+
}
|
|
533117
|
+
var UNDEFINED = void 0;
|
|
533118
|
+
var EMPTY2 = "";
|
|
533119
|
+
var SPACE = " ";
|
|
533120
|
+
var ESCAPE = "\\";
|
|
533121
|
+
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
533122
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
533123
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
533124
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
533125
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
533126
|
+
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
533127
|
+
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
533128
|
+
var SLASH2 = "/";
|
|
533129
|
+
var TMP_KEY_IGNORE = "node-ignore";
|
|
533130
|
+
if (typeof Symbol !== "undefined") {
|
|
533131
|
+
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
533132
|
+
}
|
|
533133
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
533134
|
+
var define2 = (object2, key, value) => {
|
|
533135
|
+
Object.defineProperty(object2, key, { value });
|
|
533136
|
+
return value;
|
|
533137
|
+
};
|
|
533138
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
533139
|
+
var RETURN_FALSE = () => false;
|
|
533140
|
+
var sanitizeRange = (range2) => range2.replace(
|
|
533141
|
+
REGEX_REGEXP_RANGE,
|
|
533142
|
+
(match2, from2, to) => from2.charCodeAt(0) <= to.charCodeAt(0) ? match2 : EMPTY2
|
|
533143
|
+
);
|
|
533144
|
+
var cleanRangeBackSlash = (slashes) => {
|
|
533145
|
+
const { length } = slashes;
|
|
533146
|
+
return slashes.slice(0, length - length % 2);
|
|
533147
|
+
};
|
|
533148
|
+
var REPLACERS = [
|
|
533149
|
+
[
|
|
533150
|
+
// Remove BOM
|
|
533151
|
+
// TODO:
|
|
533152
|
+
// Other similar zero-width characters?
|
|
533153
|
+
/^\uFEFF/,
|
|
533154
|
+
() => EMPTY2
|
|
533155
|
+
],
|
|
533156
|
+
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
533157
|
+
[
|
|
533158
|
+
// (a\ ) -> (a )
|
|
533159
|
+
// (a ) -> (a)
|
|
533160
|
+
// (a ) -> (a)
|
|
533161
|
+
// (a \ ) -> (a )
|
|
533162
|
+
/((?:\\\\)*?)(\\?\s+)$/,
|
|
533163
|
+
(_3, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY2)
|
|
533164
|
+
],
|
|
533165
|
+
// Replace (\ ) with ' '
|
|
533166
|
+
// (\ ) -> ' '
|
|
533167
|
+
// (\\ ) -> '\\ '
|
|
533168
|
+
// (\\\ ) -> '\\ '
|
|
533169
|
+
[
|
|
533170
|
+
/(\\+?)\s/g,
|
|
533171
|
+
(_3, m1) => {
|
|
533172
|
+
const { length } = m1;
|
|
533173
|
+
return m1.slice(0, length - length % 2) + SPACE;
|
|
533174
|
+
}
|
|
533175
|
+
],
|
|
533176
|
+
// Escape metacharacters
|
|
533177
|
+
// which is written down by users but means special for regular expressions.
|
|
533178
|
+
// > There are 12 characters with special meanings:
|
|
533179
|
+
// > - the backslash \,
|
|
533180
|
+
// > - the caret ^,
|
|
533181
|
+
// > - the dollar sign $,
|
|
533182
|
+
// > - the period or dot .,
|
|
533183
|
+
// > - the vertical bar or pipe symbol |,
|
|
533184
|
+
// > - the question mark ?,
|
|
533185
|
+
// > - the asterisk or star *,
|
|
533186
|
+
// > - the plus sign +,
|
|
533187
|
+
// > - the opening parenthesis (,
|
|
533188
|
+
// > - the closing parenthesis ),
|
|
533189
|
+
// > - and the opening square bracket [,
|
|
533190
|
+
// > - the opening curly brace {,
|
|
533191
|
+
// > These special characters are often called "metacharacters".
|
|
533192
|
+
[
|
|
533193
|
+
/[\\$.|*+(){^]/g,
|
|
533194
|
+
(match2) => `\\${match2}`
|
|
533195
|
+
],
|
|
533196
|
+
[
|
|
533197
|
+
// > a question mark (?) matches a single character
|
|
533198
|
+
/(?!\\)\?/g,
|
|
533199
|
+
() => "[^/]"
|
|
533200
|
+
],
|
|
533201
|
+
// leading slash
|
|
533202
|
+
[
|
|
533203
|
+
// > A leading slash matches the beginning of the pathname.
|
|
533204
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
533205
|
+
// A leading slash matches the beginning of the pathname
|
|
533206
|
+
/^\//,
|
|
533207
|
+
() => "^"
|
|
533208
|
+
],
|
|
533209
|
+
// replace special metacharacter slash after the leading slash
|
|
533210
|
+
[
|
|
533211
|
+
/\//g,
|
|
533212
|
+
() => "\\/"
|
|
533213
|
+
],
|
|
533214
|
+
[
|
|
533215
|
+
// > A leading "**" followed by a slash means match in all directories.
|
|
533216
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
533217
|
+
// > the same as pattern "foo".
|
|
533218
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
533219
|
+
// > under directory "foo".
|
|
533220
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
533221
|
+
/^\^*\\\*\\\*\\\//,
|
|
533222
|
+
// '**/foo' <-> 'foo'
|
|
533223
|
+
() => "^(?:.*\\/)?"
|
|
533224
|
+
],
|
|
533225
|
+
// starting
|
|
533226
|
+
[
|
|
533227
|
+
// there will be no leading '/'
|
|
533228
|
+
// (which has been replaced by section "leading slash")
|
|
533229
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
533230
|
+
/^(?=[^^])/,
|
|
533231
|
+
function startingReplacer() {
|
|
533232
|
+
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
533233
|
+
}
|
|
533234
|
+
],
|
|
533235
|
+
// two globstars
|
|
533236
|
+
[
|
|
533237
|
+
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
533238
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
533239
|
+
// Zero, one or several directories
|
|
533240
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
533241
|
+
// Check if it is not the last `'/**'`
|
|
533242
|
+
(_3, index, str2) => index + 6 < str2.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
533243
|
+
],
|
|
533244
|
+
// normal intermediate wildcards
|
|
533245
|
+
[
|
|
533246
|
+
// Never replace escaped '*'
|
|
533247
|
+
// ignore rule '\*' will match the path '*'
|
|
533248
|
+
// 'abc.*/' -> go
|
|
533249
|
+
// 'abc.*' -> skip this rule,
|
|
533250
|
+
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
533251
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
533252
|
+
// '*.js' matches '.js'
|
|
533253
|
+
// '*.js' doesn't match 'abc'
|
|
533254
|
+
(_3, p1, p2) => {
|
|
533255
|
+
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
533256
|
+
return p1 + unescaped;
|
|
533257
|
+
}
|
|
533258
|
+
],
|
|
533259
|
+
[
|
|
533260
|
+
// unescape, revert step 3 except for back slash
|
|
533261
|
+
// For example, if a user escape a '\\*',
|
|
533262
|
+
// after step 3, the result will be '\\\\\\*'
|
|
533263
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
533264
|
+
() => ESCAPE
|
|
533265
|
+
],
|
|
533266
|
+
[
|
|
533267
|
+
// '\\\\' -> '\\'
|
|
533268
|
+
/\\\\/g,
|
|
533269
|
+
() => ESCAPE
|
|
533270
|
+
],
|
|
533271
|
+
[
|
|
533272
|
+
// > The range notation, e.g. [a-zA-Z],
|
|
533273
|
+
// > can be used to match one of the characters in a range.
|
|
533274
|
+
// `\` is escaped by step 3
|
|
533275
|
+
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
533276
|
+
(match2, leadEscape, range2, endEscape, close) => leadEscape === ESCAPE ? `\\[${range2}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range2)}${endEscape}]` : "[]" : "[]"
|
|
533277
|
+
],
|
|
533278
|
+
// ending
|
|
533279
|
+
[
|
|
533280
|
+
// 'js' will not match 'js.'
|
|
533281
|
+
// 'ab' will not match 'abc'
|
|
533282
|
+
/(?:[^*])$/,
|
|
533283
|
+
// WTF!
|
|
533284
|
+
// https://git-scm.com/docs/gitignore
|
|
533285
|
+
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
533286
|
+
// which re-fixes #24, #38
|
|
533287
|
+
// > If there is a separator at the end of the pattern then the pattern
|
|
533288
|
+
// > will only match directories, otherwise the pattern can match both
|
|
533289
|
+
// > files and directories.
|
|
533290
|
+
// 'js*' will not match 'a.js'
|
|
533291
|
+
// 'js/' will not match 'a.js'
|
|
533292
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
533293
|
+
(match2) => /\/$/.test(match2) ? `${match2}$` : `${match2}(?=$|\\/$)`
|
|
533294
|
+
]
|
|
533295
|
+
];
|
|
533296
|
+
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
|
|
533297
|
+
var MODE_IGNORE = "regex";
|
|
533298
|
+
var MODE_CHECK_IGNORE = "checkRegex";
|
|
533299
|
+
var UNDERSCORE = "_";
|
|
533300
|
+
var TRAILING_WILD_CARD_REPLACERS = {
|
|
533301
|
+
[MODE_IGNORE](_3, p1) {
|
|
533302
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
533303
|
+
return `${prefix}(?=$|\\/$)`;
|
|
533304
|
+
},
|
|
533305
|
+
[MODE_CHECK_IGNORE](_3, p1) {
|
|
533306
|
+
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
533307
|
+
return `${prefix}(?=$|\\/$)`;
|
|
533308
|
+
}
|
|
533309
|
+
};
|
|
533310
|
+
var makeRegexPrefix = (pattern) => REPLACERS.reduce(
|
|
533311
|
+
(prev, [matcher2, replacer]) => prev.replace(matcher2, replacer.bind(pattern)),
|
|
533312
|
+
pattern
|
|
533313
|
+
);
|
|
533314
|
+
var isString4 = (subject) => typeof subject === "string";
|
|
533315
|
+
var checkPattern = (pattern) => pattern && isString4(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
533316
|
+
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
533317
|
+
var IgnoreRule = class {
|
|
533318
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
533319
|
+
this.pattern = pattern;
|
|
533320
|
+
this.mark = mark;
|
|
533321
|
+
this.negative = negative;
|
|
533322
|
+
define2(this, "body", body);
|
|
533323
|
+
define2(this, "ignoreCase", ignoreCase);
|
|
533324
|
+
define2(this, "regexPrefix", prefix);
|
|
533325
|
+
}
|
|
533326
|
+
get regex() {
|
|
533327
|
+
const key = UNDERSCORE + MODE_IGNORE;
|
|
533328
|
+
if (this[key]) {
|
|
533329
|
+
return this[key];
|
|
533330
|
+
}
|
|
533331
|
+
return this._make(MODE_IGNORE, key);
|
|
533332
|
+
}
|
|
533333
|
+
get checkRegex() {
|
|
533334
|
+
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
533335
|
+
if (this[key]) {
|
|
533336
|
+
return this[key];
|
|
533337
|
+
}
|
|
533338
|
+
return this._make(MODE_CHECK_IGNORE, key);
|
|
533339
|
+
}
|
|
533340
|
+
_make(mode, key) {
|
|
533341
|
+
const str2 = this.regexPrefix.replace(
|
|
533342
|
+
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
533343
|
+
// It does not need to bind pattern
|
|
533344
|
+
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
533345
|
+
);
|
|
533346
|
+
const regex2 = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
|
|
533347
|
+
return define2(this, key, regex2);
|
|
533348
|
+
}
|
|
533349
|
+
};
|
|
533350
|
+
var createRule = ({
|
|
533351
|
+
pattern,
|
|
533352
|
+
mark
|
|
533353
|
+
}, ignoreCase) => {
|
|
533354
|
+
let negative = false;
|
|
533355
|
+
let body = pattern;
|
|
533356
|
+
if (body.indexOf("!") === 0) {
|
|
533357
|
+
negative = true;
|
|
533358
|
+
body = body.substr(1);
|
|
533359
|
+
}
|
|
533360
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
533361
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
533362
|
+
return new IgnoreRule(
|
|
533363
|
+
pattern,
|
|
533364
|
+
mark,
|
|
533365
|
+
body,
|
|
533366
|
+
ignoreCase,
|
|
533367
|
+
negative,
|
|
533368
|
+
regexPrefix
|
|
533369
|
+
);
|
|
533370
|
+
};
|
|
533371
|
+
var RuleManager = class {
|
|
533372
|
+
constructor(ignoreCase) {
|
|
533373
|
+
this._ignoreCase = ignoreCase;
|
|
533374
|
+
this._rules = [];
|
|
533375
|
+
}
|
|
533376
|
+
_add(pattern) {
|
|
533377
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
533378
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
533379
|
+
this._added = true;
|
|
533380
|
+
return;
|
|
533381
|
+
}
|
|
533382
|
+
if (isString4(pattern)) {
|
|
533383
|
+
pattern = {
|
|
533384
|
+
pattern
|
|
533385
|
+
};
|
|
533386
|
+
}
|
|
533387
|
+
if (checkPattern(pattern.pattern)) {
|
|
533388
|
+
const rule = createRule(pattern, this._ignoreCase);
|
|
533389
|
+
this._added = true;
|
|
533390
|
+
this._rules.push(rule);
|
|
533391
|
+
}
|
|
533392
|
+
}
|
|
533393
|
+
// @param {Array<string> | string | Ignore} pattern
|
|
533394
|
+
add(pattern) {
|
|
533395
|
+
this._added = false;
|
|
533396
|
+
makeArray(
|
|
533397
|
+
isString4(pattern) ? splitPattern(pattern) : pattern
|
|
533398
|
+
).forEach(this._add, this);
|
|
533399
|
+
return this._added;
|
|
533400
|
+
}
|
|
533401
|
+
// Test one single path without recursively checking parent directories
|
|
533402
|
+
//
|
|
533403
|
+
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
533404
|
+
// setting `checkUnignored` to `false` could reduce additional
|
|
533405
|
+
// path matching.
|
|
533406
|
+
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
533407
|
+
// @returns {TestResult} true if a file is ignored
|
|
533408
|
+
test(path49, checkUnignored, mode) {
|
|
533409
|
+
let ignored = false;
|
|
533410
|
+
let unignored = false;
|
|
533411
|
+
let matchedRule;
|
|
533412
|
+
this._rules.forEach((rule) => {
|
|
533413
|
+
const { negative } = rule;
|
|
533414
|
+
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
533415
|
+
return;
|
|
533416
|
+
}
|
|
533417
|
+
const matched = rule[mode].test(path49);
|
|
533418
|
+
if (!matched) {
|
|
533419
|
+
return;
|
|
533420
|
+
}
|
|
533421
|
+
ignored = !negative;
|
|
533422
|
+
unignored = negative;
|
|
533423
|
+
matchedRule = negative ? UNDEFINED : rule;
|
|
533424
|
+
});
|
|
533425
|
+
const ret2 = {
|
|
533426
|
+
ignored,
|
|
533427
|
+
unignored
|
|
533428
|
+
};
|
|
533429
|
+
if (matchedRule) {
|
|
533430
|
+
ret2.rule = matchedRule;
|
|
533431
|
+
}
|
|
533432
|
+
return ret2;
|
|
533433
|
+
}
|
|
533434
|
+
};
|
|
533435
|
+
var throwError = (message, Ctor) => {
|
|
533436
|
+
throw new Ctor(message);
|
|
533437
|
+
};
|
|
533438
|
+
var checkPath = (path49, originalPath, doThrow) => {
|
|
533439
|
+
if (!isString4(path49)) {
|
|
533440
|
+
return doThrow(
|
|
533441
|
+
`path must be a string, but got \`${originalPath}\``,
|
|
533442
|
+
TypeError
|
|
533443
|
+
);
|
|
533444
|
+
}
|
|
533445
|
+
if (!path49) {
|
|
533446
|
+
return doThrow(`path must not be empty`, TypeError);
|
|
533447
|
+
}
|
|
533448
|
+
if (checkPath.isNotRelative(path49)) {
|
|
533449
|
+
const r = "`path.relative()`d";
|
|
533450
|
+
return doThrow(
|
|
533451
|
+
`path should be a ${r} string, but got "${originalPath}"`,
|
|
533452
|
+
RangeError
|
|
533453
|
+
);
|
|
533454
|
+
}
|
|
533455
|
+
return true;
|
|
533456
|
+
};
|
|
533457
|
+
var isNotRelative = (path49) => REGEX_TEST_INVALID_PATH.test(path49);
|
|
533458
|
+
checkPath.isNotRelative = isNotRelative;
|
|
533459
|
+
checkPath.convert = (p) => p;
|
|
533460
|
+
var Ignore = class {
|
|
533461
|
+
constructor({
|
|
533462
|
+
ignorecase = true,
|
|
533463
|
+
ignoreCase = ignorecase,
|
|
533464
|
+
allowRelativePaths = false
|
|
533465
|
+
} = {}) {
|
|
533466
|
+
define2(this, KEY_IGNORE, true);
|
|
533467
|
+
this._rules = new RuleManager(ignoreCase);
|
|
533468
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
533469
|
+
this._initCache();
|
|
533470
|
+
}
|
|
533471
|
+
_initCache() {
|
|
533472
|
+
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
533473
|
+
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
533474
|
+
}
|
|
533475
|
+
add(pattern) {
|
|
533476
|
+
if (this._rules.add(pattern)) {
|
|
533477
|
+
this._initCache();
|
|
533478
|
+
}
|
|
533479
|
+
return this;
|
|
533480
|
+
}
|
|
533481
|
+
// legacy
|
|
533482
|
+
addPattern(pattern) {
|
|
533483
|
+
return this.add(pattern);
|
|
533484
|
+
}
|
|
533485
|
+
// @returns {TestResult}
|
|
533486
|
+
_test(originalPath, cache4, checkUnignored, slices) {
|
|
533487
|
+
const path49 = originalPath && checkPath.convert(originalPath);
|
|
533488
|
+
checkPath(
|
|
533489
|
+
path49,
|
|
533490
|
+
originalPath,
|
|
533491
|
+
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
533492
|
+
);
|
|
533493
|
+
return this._t(path49, cache4, checkUnignored, slices);
|
|
533494
|
+
}
|
|
533495
|
+
checkIgnore(path49) {
|
|
533496
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path49)) {
|
|
533497
|
+
return this.test(path49);
|
|
533498
|
+
}
|
|
533499
|
+
const slices = path49.split(SLASH2).filter(Boolean);
|
|
533500
|
+
slices.pop();
|
|
533501
|
+
if (slices.length) {
|
|
533502
|
+
const parent = this._t(
|
|
533503
|
+
slices.join(SLASH2) + SLASH2,
|
|
533504
|
+
this._testCache,
|
|
533505
|
+
true,
|
|
533506
|
+
slices
|
|
533507
|
+
);
|
|
533508
|
+
if (parent.ignored) {
|
|
533509
|
+
return parent;
|
|
533510
|
+
}
|
|
533511
|
+
}
|
|
533512
|
+
return this._rules.test(path49, false, MODE_CHECK_IGNORE);
|
|
533513
|
+
}
|
|
533514
|
+
_t(path49, cache4, checkUnignored, slices) {
|
|
533515
|
+
if (path49 in cache4) {
|
|
533516
|
+
return cache4[path49];
|
|
533517
|
+
}
|
|
533518
|
+
if (!slices) {
|
|
533519
|
+
slices = path49.split(SLASH2).filter(Boolean);
|
|
533520
|
+
}
|
|
533521
|
+
slices.pop();
|
|
533522
|
+
if (!slices.length) {
|
|
533523
|
+
return cache4[path49] = this._rules.test(path49, checkUnignored, MODE_IGNORE);
|
|
533524
|
+
}
|
|
533525
|
+
const parent = this._t(
|
|
533526
|
+
slices.join(SLASH2) + SLASH2,
|
|
533527
|
+
cache4,
|
|
533528
|
+
checkUnignored,
|
|
533529
|
+
slices
|
|
533530
|
+
);
|
|
533531
|
+
return cache4[path49] = parent.ignored ? parent : this._rules.test(path49, checkUnignored, MODE_IGNORE);
|
|
533532
|
+
}
|
|
533533
|
+
ignores(path49) {
|
|
533534
|
+
return this._test(path49, this._ignoreCache, false).ignored;
|
|
533535
|
+
}
|
|
533536
|
+
createFilter() {
|
|
533537
|
+
return (path49) => !this.ignores(path49);
|
|
533538
|
+
}
|
|
533539
|
+
filter(paths) {
|
|
533540
|
+
return makeArray(paths).filter(this.createFilter());
|
|
533541
|
+
}
|
|
533542
|
+
// @returns {TestResult}
|
|
533543
|
+
test(path49) {
|
|
533544
|
+
return this._test(path49, this._testCache, true);
|
|
533545
|
+
}
|
|
533546
|
+
};
|
|
533547
|
+
var factory = (options3) => new Ignore(options3);
|
|
533548
|
+
var isPathValid = (path49) => checkPath(path49 && checkPath.convert(path49), path49, RETURN_FALSE);
|
|
533549
|
+
var setupWindows = () => {
|
|
533550
|
+
const makePosix = (str2) => /^\\\\\?\\/.test(str2) || /["<>|\u0000-\u001F]+/u.test(str2) ? str2 : str2.replace(/\\/g, "/");
|
|
533551
|
+
checkPath.convert = makePosix;
|
|
533552
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
533553
|
+
checkPath.isNotRelative = (path49) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path49) || isNotRelative(path49);
|
|
533554
|
+
};
|
|
533555
|
+
if (
|
|
533556
|
+
// Detect `process` so that it can run in browsers.
|
|
533557
|
+
typeof process !== "undefined" && process.platform === "win32"
|
|
533558
|
+
) {
|
|
533559
|
+
setupWindows();
|
|
533560
|
+
}
|
|
533561
|
+
module2.exports = factory;
|
|
533562
|
+
factory.default = factory;
|
|
533563
|
+
module2.exports.isPathValid = isPathValid;
|
|
533564
|
+
define2(module2.exports, Symbol.for("setupWindows"), setupWindows);
|
|
533565
|
+
}
|
|
533566
|
+
});
|
|
533567
|
+
|
|
533518
533568
|
// node_modules/readdirp/esm/index.js
|
|
533519
533569
|
import { stat, lstat, readdir as readdir3, realpath } from "node:fs/promises";
|
|
533520
533570
|
import { Readable } from "node:stream";
|
|
@@ -534503,7 +534553,7 @@ var init_handler = __esm({
|
|
|
534503
534553
|
// node_modules/chokidar/esm/index.js
|
|
534504
534554
|
import { stat as statcb } from "fs";
|
|
534505
534555
|
import { stat as stat3, readdir as readdir4 } from "fs/promises";
|
|
534506
|
-
import { EventEmitter as
|
|
534556
|
+
import { EventEmitter as EventEmitter9 } from "events";
|
|
534507
534557
|
import * as sysPath2 from "path";
|
|
534508
534558
|
function arrify(item) {
|
|
534509
534559
|
return Array.isArray(item) ? item : [item];
|
|
@@ -534705,7 +534755,7 @@ var init_esm4 = __esm({
|
|
|
534705
534755
|
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
|
534706
534756
|
}
|
|
534707
534757
|
};
|
|
534708
|
-
FSWatcher = class extends
|
|
534758
|
+
FSWatcher = class extends EventEmitter9 {
|
|
534709
534759
|
// Not indenting methods for history sake; for now.
|
|
534710
534760
|
constructor(_opts = {}) {
|
|
534711
534761
|
super();
|
|
@@ -535225,11 +535275,11 @@ var init_esm4 = __esm({
|
|
|
535225
535275
|
import path47 from "node:path";
|
|
535226
535276
|
import fs39 from "node:fs";
|
|
535227
535277
|
import crypto5 from "node:crypto";
|
|
535228
|
-
var
|
|
535278
|
+
var import_ignore, CodebaseIndexAgent;
|
|
535229
535279
|
var init_codebaseIndexAgent = __esm({
|
|
535230
535280
|
"dist/agents/codebaseIndexAgent.js"() {
|
|
535231
535281
|
"use strict";
|
|
535232
|
-
|
|
535282
|
+
import_ignore = __toESM(require_ignore(), 1);
|
|
535233
535283
|
init_esm4();
|
|
535234
535284
|
init_logger();
|
|
535235
535285
|
init_codebaseDatabase();
|
|
@@ -535307,7 +535357,7 @@ var init_codebaseIndexAgent = __esm({
|
|
|
535307
535357
|
this.projectRoot = projectRoot;
|
|
535308
535358
|
this.config = loadCodebaseConfig();
|
|
535309
535359
|
this.db = new CodebaseDatabase(projectRoot);
|
|
535310
|
-
this.ignoreFilter = (0,
|
|
535360
|
+
this.ignoreFilter = (0, import_ignore.default)();
|
|
535311
535361
|
this.loadGitignore();
|
|
535312
535362
|
this.addDefaultIgnorePatterns();
|
|
535313
535363
|
}
|
|
@@ -537303,7 +537353,7 @@ function HeadlessModeScreen({ prompt, sessionId, onComplete }) {
|
|
|
537303
537353
|
const processMessage = async () => {
|
|
537304
537354
|
try {
|
|
537305
537355
|
let loadedMessages = [];
|
|
537306
|
-
let
|
|
537356
|
+
let currentSessionId2 = sessionId;
|
|
537307
537357
|
if (sessionId) {
|
|
537308
537358
|
console.log(`
|
|
537309
537359
|
\x1B[96m Loading session: ${sessionId}\x1B[0m`);
|
|
@@ -537325,7 +537375,7 @@ function HeadlessModeScreen({ prompt, sessionId, onComplete }) {
|
|
|
537325
537375
|
} else {
|
|
537326
537376
|
console.log(`\x1B[33m\u26A0 Session not found, starting new session\x1B[0m
|
|
537327
537377
|
`);
|
|
537328
|
-
|
|
537378
|
+
currentSessionId2 = void 0;
|
|
537329
537379
|
}
|
|
537330
537380
|
}
|
|
537331
537381
|
const { cleanContent, validFiles } = await parseAndValidateFileReferences(prompt);
|
|
@@ -537347,7 +537397,7 @@ function HeadlessModeScreen({ prompt, sessionId, onComplete }) {
|
|
|
537347
537397
|
if (loadedMessages.length > 0) {
|
|
537348
537398
|
console.log(`
|
|
537349
537399
|
\x1B[36m\u250C\u2500 Continuing Session\x1B[0m`);
|
|
537350
|
-
console.log(`\x1B[90m\u2502 Session ID: ${
|
|
537400
|
+
console.log(`\x1B[90m\u2502 Session ID: ${currentSessionId2}\x1B[0m`);
|
|
537351
537401
|
console.log(`\x1B[90m\u2502 Previous messages: ${loadedMessages.length}\x1B[0m`);
|
|
537352
537402
|
}
|
|
537353
537403
|
console.log(`
|
|
@@ -538860,6 +538910,7 @@ var init_taskExecutor = __esm({
|
|
|
538860
538910
|
// dist/cli.js
|
|
538861
538911
|
var import_react133 = __toESM(require_react(), 1);
|
|
538862
538912
|
await init_build2();
|
|
538913
|
+
init_updateNotice();
|
|
538863
538914
|
await init_build3();
|
|
538864
538915
|
|
|
538865
538916
|
// node_modules/meow/index.js
|
|
@@ -539716,13 +539767,12 @@ async function checkForUpdates(currentVersion2) {
|
|
|
539716
539767
|
});
|
|
539717
539768
|
const latestVersion = stdout.trim();
|
|
539718
539769
|
if (latestVersion && latestVersion !== currentVersion2) {
|
|
539719
|
-
|
|
539720
|
-
|
|
539721
|
-
|
|
539722
|
-
console.log(' Run "snow --update" to update\n');
|
|
539723
|
-
console.log(" Github: https://github.com/MayDay-wpf/snow-cli");
|
|
539770
|
+
setUpdateNotice({ currentVersion: currentVersion2, latestVersion });
|
|
539771
|
+
} else {
|
|
539772
|
+
setUpdateNotice(null);
|
|
539724
539773
|
}
|
|
539725
|
-
} catch
|
|
539774
|
+
} catch {
|
|
539775
|
+
setUpdateNotice(null);
|
|
539726
539776
|
}
|
|
539727
539777
|
}
|
|
539728
539778
|
var cli = meow_default(`
|
|
@@ -539823,6 +539873,7 @@ var Startup = ({ version: version2, skipWelcome, autoResume, headlessPrompt, hea
|
|
|
539823
539873
|
const init = async () => {
|
|
539824
539874
|
const deps = await loadDependencies();
|
|
539825
539875
|
execAsync2 = deps.promisify(deps.exec);
|
|
539876
|
+
setUpdateNotice(null);
|
|
539826
539877
|
try {
|
|
539827
539878
|
deps.initializeProfiles();
|
|
539828
539879
|
} catch (error) {
|