@adhdev/daemon-standalone 0.9.76-rc.10 → 0.9.76-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +573 -295
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +891 -546
- package/vendor/mcp-server/index.js.map +1 -1
|
@@ -4642,10 +4642,10 @@ function mergeDefs(...defs) {
|
|
|
4642
4642
|
function cloneDef(schema) {
|
|
4643
4643
|
return mergeDefs(schema._zod.def);
|
|
4644
4644
|
}
|
|
4645
|
-
function getElementAtPath(obj,
|
|
4646
|
-
if (!
|
|
4645
|
+
function getElementAtPath(obj, path27) {
|
|
4646
|
+
if (!path27)
|
|
4647
4647
|
return obj;
|
|
4648
|
-
return
|
|
4648
|
+
return path27.reduce((acc, key) => acc?.[key], obj);
|
|
4649
4649
|
}
|
|
4650
4650
|
function promiseAllObject(promisesObj) {
|
|
4651
4651
|
const keys = Object.keys(promisesObj);
|
|
@@ -4957,11 +4957,11 @@ function aborted(x, startIndex = 0) {
|
|
|
4957
4957
|
}
|
|
4958
4958
|
return false;
|
|
4959
4959
|
}
|
|
4960
|
-
function prefixIssues(
|
|
4960
|
+
function prefixIssues(path27, issues) {
|
|
4961
4961
|
return issues.map((iss) => {
|
|
4962
4962
|
var _a2;
|
|
4963
4963
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
4964
|
-
iss.path.unshift(
|
|
4964
|
+
iss.path.unshift(path27);
|
|
4965
4965
|
return iss;
|
|
4966
4966
|
});
|
|
4967
4967
|
}
|
|
@@ -5204,7 +5204,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5204
5204
|
}
|
|
5205
5205
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
5206
5206
|
const result = { errors: [] };
|
|
5207
|
-
const processError = (error49,
|
|
5207
|
+
const processError = (error49, path27 = []) => {
|
|
5208
5208
|
var _a2, _b;
|
|
5209
5209
|
for (const issue2 of error49.issues) {
|
|
5210
5210
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -5214,7 +5214,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5214
5214
|
} else if (issue2.code === "invalid_element") {
|
|
5215
5215
|
processError({ issues: issue2.issues }, issue2.path);
|
|
5216
5216
|
} else {
|
|
5217
|
-
const fullpath = [...
|
|
5217
|
+
const fullpath = [...path27, ...issue2.path];
|
|
5218
5218
|
if (fullpath.length === 0) {
|
|
5219
5219
|
result.errors.push(mapper(issue2));
|
|
5220
5220
|
continue;
|
|
@@ -5246,8 +5246,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
5246
5246
|
}
|
|
5247
5247
|
function toDotPath(_path) {
|
|
5248
5248
|
const segs = [];
|
|
5249
|
-
const
|
|
5250
|
-
for (const seg of
|
|
5249
|
+
const path27 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
5250
|
+
for (const seg of path27) {
|
|
5251
5251
|
if (typeof seg === "number")
|
|
5252
5252
|
segs.push(`[${seg}]`);
|
|
5253
5253
|
else if (typeof seg === "symbol")
|
|
@@ -18011,13 +18011,13 @@ function resolveRef(ref, ctx) {
|
|
|
18011
18011
|
if (!ref.startsWith("#")) {
|
|
18012
18012
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
18013
18013
|
}
|
|
18014
|
-
const
|
|
18015
|
-
if (
|
|
18014
|
+
const path27 = ref.slice(1).split("/").filter(Boolean);
|
|
18015
|
+
if (path27.length === 0) {
|
|
18016
18016
|
return ctx.rootSchema;
|
|
18017
18017
|
}
|
|
18018
18018
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
18019
|
-
if (
|
|
18020
|
-
const key =
|
|
18019
|
+
if (path27[0] === defsKey) {
|
|
18020
|
+
const key = path27[1];
|
|
18021
18021
|
if (!key || !ctx.defs[key]) {
|
|
18022
18022
|
throw new Error(`Reference not found: ${ref}`);
|
|
18023
18023
|
}
|
|
@@ -20780,7 +20780,7 @@ var init_esm = __esm({
|
|
|
20780
20780
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
20781
20781
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
20782
20782
|
if (wantBigintFsStats) {
|
|
20783
|
-
this._stat = (
|
|
20783
|
+
this._stat = (path27) => statMethod(path27, { bigint: true });
|
|
20784
20784
|
} else {
|
|
20785
20785
|
this._stat = statMethod;
|
|
20786
20786
|
}
|
|
@@ -20805,8 +20805,8 @@ var init_esm = __esm({
|
|
|
20805
20805
|
const par = this.parent;
|
|
20806
20806
|
const fil = par && par.files;
|
|
20807
20807
|
if (fil && fil.length > 0) {
|
|
20808
|
-
const { path:
|
|
20809
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
20808
|
+
const { path: path27, depth } = par;
|
|
20809
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path27));
|
|
20810
20810
|
const awaited = await Promise.all(slice);
|
|
20811
20811
|
for (const entry of awaited) {
|
|
20812
20812
|
if (!entry)
|
|
@@ -20846,20 +20846,20 @@ var init_esm = __esm({
|
|
|
20846
20846
|
this.reading = false;
|
|
20847
20847
|
}
|
|
20848
20848
|
}
|
|
20849
|
-
async _exploreDir(
|
|
20849
|
+
async _exploreDir(path27, depth) {
|
|
20850
20850
|
let files;
|
|
20851
20851
|
try {
|
|
20852
|
-
files = await (0, import_promises.readdir)(
|
|
20852
|
+
files = await (0, import_promises.readdir)(path27, this._rdOptions);
|
|
20853
20853
|
} catch (error48) {
|
|
20854
20854
|
this._onError(error48);
|
|
20855
20855
|
}
|
|
20856
|
-
return { files, depth, path:
|
|
20856
|
+
return { files, depth, path: path27 };
|
|
20857
20857
|
}
|
|
20858
|
-
async _formatEntry(dirent,
|
|
20858
|
+
async _formatEntry(dirent, path27) {
|
|
20859
20859
|
let entry;
|
|
20860
20860
|
const basename8 = this._isDirent ? dirent.name : dirent;
|
|
20861
20861
|
try {
|
|
20862
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
20862
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path27, basename8));
|
|
20863
20863
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename8 };
|
|
20864
20864
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
20865
20865
|
} catch (err) {
|
|
@@ -20916,16 +20916,16 @@ var init_esm = __esm({
|
|
|
20916
20916
|
});
|
|
20917
20917
|
|
|
20918
20918
|
// ../../node_modules/chokidar/esm/handler.js
|
|
20919
|
-
function createFsWatchInstance(
|
|
20919
|
+
function createFsWatchInstance(path27, options, listener, errHandler, emitRaw) {
|
|
20920
20920
|
const handleEvent = (rawEvent, evPath) => {
|
|
20921
|
-
listener(
|
|
20922
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
20923
|
-
if (evPath &&
|
|
20924
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
20921
|
+
listener(path27);
|
|
20922
|
+
emitRaw(rawEvent, evPath, { watchedPath: path27 });
|
|
20923
|
+
if (evPath && path27 !== evPath) {
|
|
20924
|
+
fsWatchBroadcast(sysPath.resolve(path27, evPath), KEY_LISTENERS, sysPath.join(path27, evPath));
|
|
20925
20925
|
}
|
|
20926
20926
|
};
|
|
20927
20927
|
try {
|
|
20928
|
-
return (0, import_fs.watch)(
|
|
20928
|
+
return (0, import_fs.watch)(path27, {
|
|
20929
20929
|
persistent: options.persistent
|
|
20930
20930
|
}, handleEvent);
|
|
20931
20931
|
} catch (error48) {
|
|
@@ -21274,12 +21274,12 @@ var init_handler = __esm({
|
|
|
21274
21274
|
listener(val1, val2, val3);
|
|
21275
21275
|
});
|
|
21276
21276
|
};
|
|
21277
|
-
setFsWatchListener = (
|
|
21277
|
+
setFsWatchListener = (path27, fullPath, options, handlers) => {
|
|
21278
21278
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
21279
21279
|
let cont = FsWatchInstances.get(fullPath);
|
|
21280
21280
|
let watcher;
|
|
21281
21281
|
if (!options.persistent) {
|
|
21282
|
-
watcher = createFsWatchInstance(
|
|
21282
|
+
watcher = createFsWatchInstance(path27, options, listener, errHandler, rawEmitter);
|
|
21283
21283
|
if (!watcher)
|
|
21284
21284
|
return;
|
|
21285
21285
|
return watcher.close.bind(watcher);
|
|
@@ -21290,7 +21290,7 @@ var init_handler = __esm({
|
|
|
21290
21290
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
21291
21291
|
} else {
|
|
21292
21292
|
watcher = createFsWatchInstance(
|
|
21293
|
-
|
|
21293
|
+
path27,
|
|
21294
21294
|
options,
|
|
21295
21295
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
21296
21296
|
errHandler,
|
|
@@ -21305,7 +21305,7 @@ var init_handler = __esm({
|
|
|
21305
21305
|
cont.watcherUnusable = true;
|
|
21306
21306
|
if (isWindows && error48.code === "EPERM") {
|
|
21307
21307
|
try {
|
|
21308
|
-
const fd = await (0, import_promises2.open)(
|
|
21308
|
+
const fd = await (0, import_promises2.open)(path27, "r");
|
|
21309
21309
|
await fd.close();
|
|
21310
21310
|
broadcastErr(error48);
|
|
21311
21311
|
} catch (err) {
|
|
@@ -21336,7 +21336,7 @@ var init_handler = __esm({
|
|
|
21336
21336
|
};
|
|
21337
21337
|
};
|
|
21338
21338
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
21339
|
-
setFsWatchFileListener = (
|
|
21339
|
+
setFsWatchFileListener = (path27, fullPath, options, handlers) => {
|
|
21340
21340
|
const { listener, rawEmitter } = handlers;
|
|
21341
21341
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
21342
21342
|
const copts = cont && cont.options;
|
|
@@ -21358,7 +21358,7 @@ var init_handler = __esm({
|
|
|
21358
21358
|
});
|
|
21359
21359
|
const currmtime = curr.mtimeMs;
|
|
21360
21360
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
21361
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
21361
|
+
foreach(cont.listeners, (listener2) => listener2(path27, curr));
|
|
21362
21362
|
}
|
|
21363
21363
|
})
|
|
21364
21364
|
};
|
|
@@ -21386,13 +21386,13 @@ var init_handler = __esm({
|
|
|
21386
21386
|
* @param listener on fs change
|
|
21387
21387
|
* @returns closer for the watcher instance
|
|
21388
21388
|
*/
|
|
21389
|
-
_watchWithNodeFs(
|
|
21389
|
+
_watchWithNodeFs(path27, listener) {
|
|
21390
21390
|
const opts = this.fsw.options;
|
|
21391
|
-
const directory = sysPath.dirname(
|
|
21392
|
-
const basename8 = sysPath.basename(
|
|
21391
|
+
const directory = sysPath.dirname(path27);
|
|
21392
|
+
const basename8 = sysPath.basename(path27);
|
|
21393
21393
|
const parent = this.fsw._getWatchedDir(directory);
|
|
21394
21394
|
parent.add(basename8);
|
|
21395
|
-
const absolutePath = sysPath.resolve(
|
|
21395
|
+
const absolutePath = sysPath.resolve(path27);
|
|
21396
21396
|
const options = {
|
|
21397
21397
|
persistent: opts.persistent
|
|
21398
21398
|
};
|
|
@@ -21402,12 +21402,12 @@ var init_handler = __esm({
|
|
|
21402
21402
|
if (opts.usePolling) {
|
|
21403
21403
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
21404
21404
|
options.interval = enableBin && isBinaryPath(basename8) ? opts.binaryInterval : opts.interval;
|
|
21405
|
-
closer = setFsWatchFileListener(
|
|
21405
|
+
closer = setFsWatchFileListener(path27, absolutePath, options, {
|
|
21406
21406
|
listener,
|
|
21407
21407
|
rawEmitter: this.fsw._emitRaw
|
|
21408
21408
|
});
|
|
21409
21409
|
} else {
|
|
21410
|
-
closer = setFsWatchListener(
|
|
21410
|
+
closer = setFsWatchListener(path27, absolutePath, options, {
|
|
21411
21411
|
listener,
|
|
21412
21412
|
errHandler: this._boundHandleError,
|
|
21413
21413
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -21423,13 +21423,13 @@ var init_handler = __esm({
|
|
|
21423
21423
|
if (this.fsw.closed) {
|
|
21424
21424
|
return;
|
|
21425
21425
|
}
|
|
21426
|
-
const
|
|
21426
|
+
const dirname11 = sysPath.dirname(file2);
|
|
21427
21427
|
const basename8 = sysPath.basename(file2);
|
|
21428
|
-
const parent = this.fsw._getWatchedDir(
|
|
21428
|
+
const parent = this.fsw._getWatchedDir(dirname11);
|
|
21429
21429
|
let prevStats = stats;
|
|
21430
21430
|
if (parent.has(basename8))
|
|
21431
21431
|
return;
|
|
21432
|
-
const listener = async (
|
|
21432
|
+
const listener = async (path27, newStats) => {
|
|
21433
21433
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
21434
21434
|
return;
|
|
21435
21435
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -21443,16 +21443,16 @@ var init_handler = __esm({
|
|
|
21443
21443
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
21444
21444
|
}
|
|
21445
21445
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
21446
|
-
this.fsw._closeFile(
|
|
21446
|
+
this.fsw._closeFile(path27);
|
|
21447
21447
|
prevStats = newStats2;
|
|
21448
21448
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
21449
21449
|
if (closer2)
|
|
21450
|
-
this.fsw._addPathCloser(
|
|
21450
|
+
this.fsw._addPathCloser(path27, closer2);
|
|
21451
21451
|
} else {
|
|
21452
21452
|
prevStats = newStats2;
|
|
21453
21453
|
}
|
|
21454
21454
|
} catch (error48) {
|
|
21455
|
-
this.fsw._remove(
|
|
21455
|
+
this.fsw._remove(dirname11, basename8);
|
|
21456
21456
|
}
|
|
21457
21457
|
} else if (parent.has(basename8)) {
|
|
21458
21458
|
const at = newStats.atimeMs;
|
|
@@ -21479,7 +21479,7 @@ var init_handler = __esm({
|
|
|
21479
21479
|
* @param item basename of this item
|
|
21480
21480
|
* @returns true if no more processing is needed for this entry.
|
|
21481
21481
|
*/
|
|
21482
|
-
async _handleSymlink(entry, directory,
|
|
21482
|
+
async _handleSymlink(entry, directory, path27, item) {
|
|
21483
21483
|
if (this.fsw.closed) {
|
|
21484
21484
|
return;
|
|
21485
21485
|
}
|
|
@@ -21489,7 +21489,7 @@ var init_handler = __esm({
|
|
|
21489
21489
|
this.fsw._incrReadyCount();
|
|
21490
21490
|
let linkPath;
|
|
21491
21491
|
try {
|
|
21492
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
21492
|
+
linkPath = await (0, import_promises2.realpath)(path27);
|
|
21493
21493
|
} catch (e) {
|
|
21494
21494
|
this.fsw._emitReady();
|
|
21495
21495
|
return true;
|
|
@@ -21499,12 +21499,12 @@ var init_handler = __esm({
|
|
|
21499
21499
|
if (dir.has(item)) {
|
|
21500
21500
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
21501
21501
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
21502
|
-
this.fsw._emit(EV.CHANGE,
|
|
21502
|
+
this.fsw._emit(EV.CHANGE, path27, entry.stats);
|
|
21503
21503
|
}
|
|
21504
21504
|
} else {
|
|
21505
21505
|
dir.add(item);
|
|
21506
21506
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
21507
|
-
this.fsw._emit(EV.ADD,
|
|
21507
|
+
this.fsw._emit(EV.ADD, path27, entry.stats);
|
|
21508
21508
|
}
|
|
21509
21509
|
this.fsw._emitReady();
|
|
21510
21510
|
return true;
|
|
@@ -21533,9 +21533,9 @@ var init_handler = __esm({
|
|
|
21533
21533
|
return;
|
|
21534
21534
|
}
|
|
21535
21535
|
const item = entry.path;
|
|
21536
|
-
let
|
|
21536
|
+
let path27 = sysPath.join(directory, item);
|
|
21537
21537
|
current.add(item);
|
|
21538
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
21538
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path27, item)) {
|
|
21539
21539
|
return;
|
|
21540
21540
|
}
|
|
21541
21541
|
if (this.fsw.closed) {
|
|
@@ -21544,8 +21544,8 @@ var init_handler = __esm({
|
|
|
21544
21544
|
}
|
|
21545
21545
|
if (item === target || !target && !previous.has(item)) {
|
|
21546
21546
|
this.fsw._incrReadyCount();
|
|
21547
|
-
|
|
21548
|
-
this._addToNodeFs(
|
|
21547
|
+
path27 = sysPath.join(dir, sysPath.relative(dir, path27));
|
|
21548
|
+
this._addToNodeFs(path27, initialAdd, wh, depth + 1);
|
|
21549
21549
|
}
|
|
21550
21550
|
}).on(EV.ERROR, this._boundHandleError);
|
|
21551
21551
|
return new Promise((resolve18, reject) => {
|
|
@@ -21614,13 +21614,13 @@ var init_handler = __esm({
|
|
|
21614
21614
|
* @param depth Child path actually targeted for watch
|
|
21615
21615
|
* @param target Child path actually targeted for watch
|
|
21616
21616
|
*/
|
|
21617
|
-
async _addToNodeFs(
|
|
21617
|
+
async _addToNodeFs(path27, initialAdd, priorWh, depth, target) {
|
|
21618
21618
|
const ready = this.fsw._emitReady;
|
|
21619
|
-
if (this.fsw._isIgnored(
|
|
21619
|
+
if (this.fsw._isIgnored(path27) || this.fsw.closed) {
|
|
21620
21620
|
ready();
|
|
21621
21621
|
return false;
|
|
21622
21622
|
}
|
|
21623
|
-
const wh = this.fsw._getWatchHelpers(
|
|
21623
|
+
const wh = this.fsw._getWatchHelpers(path27);
|
|
21624
21624
|
if (priorWh) {
|
|
21625
21625
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
21626
21626
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -21636,8 +21636,8 @@ var init_handler = __esm({
|
|
|
21636
21636
|
const follow = this.fsw.options.followSymlinks;
|
|
21637
21637
|
let closer;
|
|
21638
21638
|
if (stats.isDirectory()) {
|
|
21639
|
-
const absPath = sysPath.resolve(
|
|
21640
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
21639
|
+
const absPath = sysPath.resolve(path27);
|
|
21640
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path27) : path27;
|
|
21641
21641
|
if (this.fsw.closed)
|
|
21642
21642
|
return;
|
|
21643
21643
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -21647,29 +21647,29 @@ var init_handler = __esm({
|
|
|
21647
21647
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
21648
21648
|
}
|
|
21649
21649
|
} else if (stats.isSymbolicLink()) {
|
|
21650
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
21650
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path27) : path27;
|
|
21651
21651
|
if (this.fsw.closed)
|
|
21652
21652
|
return;
|
|
21653
21653
|
const parent = sysPath.dirname(wh.watchPath);
|
|
21654
21654
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
21655
21655
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
21656
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
21656
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path27, wh, targetPath);
|
|
21657
21657
|
if (this.fsw.closed)
|
|
21658
21658
|
return;
|
|
21659
21659
|
if (targetPath !== void 0) {
|
|
21660
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
21660
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path27), targetPath);
|
|
21661
21661
|
}
|
|
21662
21662
|
} else {
|
|
21663
21663
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
21664
21664
|
}
|
|
21665
21665
|
ready();
|
|
21666
21666
|
if (closer)
|
|
21667
|
-
this.fsw._addPathCloser(
|
|
21667
|
+
this.fsw._addPathCloser(path27, closer);
|
|
21668
21668
|
return false;
|
|
21669
21669
|
} catch (error48) {
|
|
21670
21670
|
if (this.fsw._handleError(error48)) {
|
|
21671
21671
|
ready();
|
|
21672
|
-
return
|
|
21672
|
+
return path27;
|
|
21673
21673
|
}
|
|
21674
21674
|
}
|
|
21675
21675
|
}
|
|
@@ -21704,26 +21704,26 @@ function createPattern(matcher) {
|
|
|
21704
21704
|
}
|
|
21705
21705
|
return () => false;
|
|
21706
21706
|
}
|
|
21707
|
-
function normalizePath(
|
|
21708
|
-
if (typeof
|
|
21707
|
+
function normalizePath(path27) {
|
|
21708
|
+
if (typeof path27 !== "string")
|
|
21709
21709
|
throw new Error("string expected");
|
|
21710
|
-
|
|
21711
|
-
|
|
21710
|
+
path27 = sysPath2.normalize(path27);
|
|
21711
|
+
path27 = path27.replace(/\\/g, "/");
|
|
21712
21712
|
let prepend = false;
|
|
21713
|
-
if (
|
|
21713
|
+
if (path27.startsWith("//"))
|
|
21714
21714
|
prepend = true;
|
|
21715
21715
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
21716
|
-
while (
|
|
21717
|
-
|
|
21716
|
+
while (path27.match(DOUBLE_SLASH_RE2))
|
|
21717
|
+
path27 = path27.replace(DOUBLE_SLASH_RE2, "/");
|
|
21718
21718
|
if (prepend)
|
|
21719
|
-
|
|
21720
|
-
return
|
|
21719
|
+
path27 = "/" + path27;
|
|
21720
|
+
return path27;
|
|
21721
21721
|
}
|
|
21722
21722
|
function matchPatterns(patterns, testString, stats) {
|
|
21723
|
-
const
|
|
21723
|
+
const path27 = normalizePath(testString);
|
|
21724
21724
|
for (let index = 0; index < patterns.length; index++) {
|
|
21725
21725
|
const pattern = patterns[index];
|
|
21726
|
-
if (pattern(
|
|
21726
|
+
if (pattern(path27, stats)) {
|
|
21727
21727
|
return true;
|
|
21728
21728
|
}
|
|
21729
21729
|
}
|
|
@@ -21788,19 +21788,19 @@ var init_esm2 = __esm({
|
|
|
21788
21788
|
}
|
|
21789
21789
|
return str;
|
|
21790
21790
|
};
|
|
21791
|
-
normalizePathToUnix = (
|
|
21792
|
-
normalizeIgnored = (cwd = "") => (
|
|
21793
|
-
if (typeof
|
|
21794
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
21791
|
+
normalizePathToUnix = (path27) => toUnix(sysPath2.normalize(toUnix(path27)));
|
|
21792
|
+
normalizeIgnored = (cwd = "") => (path27) => {
|
|
21793
|
+
if (typeof path27 === "string") {
|
|
21794
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path27) ? path27 : sysPath2.join(cwd, path27));
|
|
21795
21795
|
} else {
|
|
21796
|
-
return
|
|
21796
|
+
return path27;
|
|
21797
21797
|
}
|
|
21798
21798
|
};
|
|
21799
|
-
getAbsolutePath = (
|
|
21800
|
-
if (sysPath2.isAbsolute(
|
|
21801
|
-
return
|
|
21799
|
+
getAbsolutePath = (path27, cwd) => {
|
|
21800
|
+
if (sysPath2.isAbsolute(path27)) {
|
|
21801
|
+
return path27;
|
|
21802
21802
|
}
|
|
21803
|
-
return sysPath2.join(cwd,
|
|
21803
|
+
return sysPath2.join(cwd, path27);
|
|
21804
21804
|
};
|
|
21805
21805
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
21806
21806
|
DirEntry = class {
|
|
@@ -21855,10 +21855,10 @@ var init_esm2 = __esm({
|
|
|
21855
21855
|
STAT_METHOD_F = "stat";
|
|
21856
21856
|
STAT_METHOD_L = "lstat";
|
|
21857
21857
|
WatchHelper = class {
|
|
21858
|
-
constructor(
|
|
21858
|
+
constructor(path27, follow, fsw) {
|
|
21859
21859
|
this.fsw = fsw;
|
|
21860
|
-
const watchPath =
|
|
21861
|
-
this.path =
|
|
21860
|
+
const watchPath = path27;
|
|
21861
|
+
this.path = path27 = path27.replace(REPLACER_RE, "");
|
|
21862
21862
|
this.watchPath = watchPath;
|
|
21863
21863
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
21864
21864
|
this.dirParts = [];
|
|
@@ -21980,20 +21980,20 @@ var init_esm2 = __esm({
|
|
|
21980
21980
|
this._closePromise = void 0;
|
|
21981
21981
|
let paths = unifyPaths(paths_);
|
|
21982
21982
|
if (cwd) {
|
|
21983
|
-
paths = paths.map((
|
|
21984
|
-
const absPath = getAbsolutePath(
|
|
21983
|
+
paths = paths.map((path27) => {
|
|
21984
|
+
const absPath = getAbsolutePath(path27, cwd);
|
|
21985
21985
|
return absPath;
|
|
21986
21986
|
});
|
|
21987
21987
|
}
|
|
21988
|
-
paths.forEach((
|
|
21989
|
-
this._removeIgnoredPath(
|
|
21988
|
+
paths.forEach((path27) => {
|
|
21989
|
+
this._removeIgnoredPath(path27);
|
|
21990
21990
|
});
|
|
21991
21991
|
this._userIgnored = void 0;
|
|
21992
21992
|
if (!this._readyCount)
|
|
21993
21993
|
this._readyCount = 0;
|
|
21994
21994
|
this._readyCount += paths.length;
|
|
21995
|
-
Promise.all(paths.map(async (
|
|
21996
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
21995
|
+
Promise.all(paths.map(async (path27) => {
|
|
21996
|
+
const res = await this._nodeFsHandler._addToNodeFs(path27, !_internal, void 0, 0, _origAdd);
|
|
21997
21997
|
if (res)
|
|
21998
21998
|
this._emitReady();
|
|
21999
21999
|
return res;
|
|
@@ -22015,17 +22015,17 @@ var init_esm2 = __esm({
|
|
|
22015
22015
|
return this;
|
|
22016
22016
|
const paths = unifyPaths(paths_);
|
|
22017
22017
|
const { cwd } = this.options;
|
|
22018
|
-
paths.forEach((
|
|
22019
|
-
if (!sysPath2.isAbsolute(
|
|
22018
|
+
paths.forEach((path27) => {
|
|
22019
|
+
if (!sysPath2.isAbsolute(path27) && !this._closers.has(path27)) {
|
|
22020
22020
|
if (cwd)
|
|
22021
|
-
|
|
22022
|
-
|
|
22021
|
+
path27 = sysPath2.join(cwd, path27);
|
|
22022
|
+
path27 = sysPath2.resolve(path27);
|
|
22023
22023
|
}
|
|
22024
|
-
this._closePath(
|
|
22025
|
-
this._addIgnoredPath(
|
|
22026
|
-
if (this._watched.has(
|
|
22024
|
+
this._closePath(path27);
|
|
22025
|
+
this._addIgnoredPath(path27);
|
|
22026
|
+
if (this._watched.has(path27)) {
|
|
22027
22027
|
this._addIgnoredPath({
|
|
22028
|
-
path:
|
|
22028
|
+
path: path27,
|
|
22029
22029
|
recursive: true
|
|
22030
22030
|
});
|
|
22031
22031
|
}
|
|
@@ -22089,38 +22089,38 @@ var init_esm2 = __esm({
|
|
|
22089
22089
|
* @param stats arguments to be passed with event
|
|
22090
22090
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
22091
22091
|
*/
|
|
22092
|
-
async _emit(event,
|
|
22092
|
+
async _emit(event, path27, stats) {
|
|
22093
22093
|
if (this.closed)
|
|
22094
22094
|
return;
|
|
22095
22095
|
const opts = this.options;
|
|
22096
22096
|
if (isWindows)
|
|
22097
|
-
|
|
22097
|
+
path27 = sysPath2.normalize(path27);
|
|
22098
22098
|
if (opts.cwd)
|
|
22099
|
-
|
|
22100
|
-
const args = [
|
|
22099
|
+
path27 = sysPath2.relative(opts.cwd, path27);
|
|
22100
|
+
const args = [path27];
|
|
22101
22101
|
if (stats != null)
|
|
22102
22102
|
args.push(stats);
|
|
22103
22103
|
const awf = opts.awaitWriteFinish;
|
|
22104
22104
|
let pw;
|
|
22105
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
22105
|
+
if (awf && (pw = this._pendingWrites.get(path27))) {
|
|
22106
22106
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
22107
22107
|
return this;
|
|
22108
22108
|
}
|
|
22109
22109
|
if (opts.atomic) {
|
|
22110
22110
|
if (event === EVENTS.UNLINK) {
|
|
22111
|
-
this._pendingUnlinks.set(
|
|
22111
|
+
this._pendingUnlinks.set(path27, [event, ...args]);
|
|
22112
22112
|
setTimeout(() => {
|
|
22113
|
-
this._pendingUnlinks.forEach((entry,
|
|
22113
|
+
this._pendingUnlinks.forEach((entry, path28) => {
|
|
22114
22114
|
this.emit(...entry);
|
|
22115
22115
|
this.emit(EVENTS.ALL, ...entry);
|
|
22116
|
-
this._pendingUnlinks.delete(
|
|
22116
|
+
this._pendingUnlinks.delete(path28);
|
|
22117
22117
|
});
|
|
22118
22118
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
22119
22119
|
return this;
|
|
22120
22120
|
}
|
|
22121
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
22121
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path27)) {
|
|
22122
22122
|
event = EVENTS.CHANGE;
|
|
22123
|
-
this._pendingUnlinks.delete(
|
|
22123
|
+
this._pendingUnlinks.delete(path27);
|
|
22124
22124
|
}
|
|
22125
22125
|
}
|
|
22126
22126
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -22138,16 +22138,16 @@ var init_esm2 = __esm({
|
|
|
22138
22138
|
this.emitWithAll(event, args);
|
|
22139
22139
|
}
|
|
22140
22140
|
};
|
|
22141
|
-
this._awaitWriteFinish(
|
|
22141
|
+
this._awaitWriteFinish(path27, awf.stabilityThreshold, event, awfEmit);
|
|
22142
22142
|
return this;
|
|
22143
22143
|
}
|
|
22144
22144
|
if (event === EVENTS.CHANGE) {
|
|
22145
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
22145
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path27, 50);
|
|
22146
22146
|
if (isThrottled)
|
|
22147
22147
|
return this;
|
|
22148
22148
|
}
|
|
22149
22149
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
22150
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
22150
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path27) : path27;
|
|
22151
22151
|
let stats2;
|
|
22152
22152
|
try {
|
|
22153
22153
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -22178,23 +22178,23 @@ var init_esm2 = __esm({
|
|
|
22178
22178
|
* @param timeout duration of time to suppress duplicate actions
|
|
22179
22179
|
* @returns tracking object or false if action should be suppressed
|
|
22180
22180
|
*/
|
|
22181
|
-
_throttle(actionType,
|
|
22181
|
+
_throttle(actionType, path27, timeout) {
|
|
22182
22182
|
if (!this._throttled.has(actionType)) {
|
|
22183
22183
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
22184
22184
|
}
|
|
22185
22185
|
const action = this._throttled.get(actionType);
|
|
22186
22186
|
if (!action)
|
|
22187
22187
|
throw new Error("invalid throttle");
|
|
22188
|
-
const actionPath = action.get(
|
|
22188
|
+
const actionPath = action.get(path27);
|
|
22189
22189
|
if (actionPath) {
|
|
22190
22190
|
actionPath.count++;
|
|
22191
22191
|
return false;
|
|
22192
22192
|
}
|
|
22193
22193
|
let timeoutObject;
|
|
22194
22194
|
const clear = () => {
|
|
22195
|
-
const item = action.get(
|
|
22195
|
+
const item = action.get(path27);
|
|
22196
22196
|
const count = item ? item.count : 0;
|
|
22197
|
-
action.delete(
|
|
22197
|
+
action.delete(path27);
|
|
22198
22198
|
clearTimeout(timeoutObject);
|
|
22199
22199
|
if (item)
|
|
22200
22200
|
clearTimeout(item.timeoutObject);
|
|
@@ -22202,7 +22202,7 @@ var init_esm2 = __esm({
|
|
|
22202
22202
|
};
|
|
22203
22203
|
timeoutObject = setTimeout(clear, timeout);
|
|
22204
22204
|
const thr = { timeoutObject, clear, count: 0 };
|
|
22205
|
-
action.set(
|
|
22205
|
+
action.set(path27, thr);
|
|
22206
22206
|
return thr;
|
|
22207
22207
|
}
|
|
22208
22208
|
_incrReadyCount() {
|
|
@@ -22216,44 +22216,44 @@ var init_esm2 = __esm({
|
|
|
22216
22216
|
* @param event
|
|
22217
22217
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
22218
22218
|
*/
|
|
22219
|
-
_awaitWriteFinish(
|
|
22219
|
+
_awaitWriteFinish(path27, threshold, event, awfEmit) {
|
|
22220
22220
|
const awf = this.options.awaitWriteFinish;
|
|
22221
22221
|
if (typeof awf !== "object")
|
|
22222
22222
|
return;
|
|
22223
22223
|
const pollInterval = awf.pollInterval;
|
|
22224
22224
|
let timeoutHandler;
|
|
22225
|
-
let fullPath =
|
|
22226
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
22227
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
22225
|
+
let fullPath = path27;
|
|
22226
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path27)) {
|
|
22227
|
+
fullPath = sysPath2.join(this.options.cwd, path27);
|
|
22228
22228
|
}
|
|
22229
22229
|
const now = /* @__PURE__ */ new Date();
|
|
22230
22230
|
const writes = this._pendingWrites;
|
|
22231
22231
|
function awaitWriteFinishFn(prevStat) {
|
|
22232
22232
|
(0, import_fs2.stat)(fullPath, (err, curStat) => {
|
|
22233
|
-
if (err || !writes.has(
|
|
22233
|
+
if (err || !writes.has(path27)) {
|
|
22234
22234
|
if (err && err.code !== "ENOENT")
|
|
22235
22235
|
awfEmit(err);
|
|
22236
22236
|
return;
|
|
22237
22237
|
}
|
|
22238
22238
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
22239
22239
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
22240
|
-
writes.get(
|
|
22240
|
+
writes.get(path27).lastChange = now2;
|
|
22241
22241
|
}
|
|
22242
|
-
const pw = writes.get(
|
|
22242
|
+
const pw = writes.get(path27);
|
|
22243
22243
|
const df = now2 - pw.lastChange;
|
|
22244
22244
|
if (df >= threshold) {
|
|
22245
|
-
writes.delete(
|
|
22245
|
+
writes.delete(path27);
|
|
22246
22246
|
awfEmit(void 0, curStat);
|
|
22247
22247
|
} else {
|
|
22248
22248
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
22249
22249
|
}
|
|
22250
22250
|
});
|
|
22251
22251
|
}
|
|
22252
|
-
if (!writes.has(
|
|
22253
|
-
writes.set(
|
|
22252
|
+
if (!writes.has(path27)) {
|
|
22253
|
+
writes.set(path27, {
|
|
22254
22254
|
lastChange: now,
|
|
22255
22255
|
cancelWait: () => {
|
|
22256
|
-
writes.delete(
|
|
22256
|
+
writes.delete(path27);
|
|
22257
22257
|
clearTimeout(timeoutHandler);
|
|
22258
22258
|
return event;
|
|
22259
22259
|
}
|
|
@@ -22264,8 +22264,8 @@ var init_esm2 = __esm({
|
|
|
22264
22264
|
/**
|
|
22265
22265
|
* Determines whether user has asked to ignore this path.
|
|
22266
22266
|
*/
|
|
22267
|
-
_isIgnored(
|
|
22268
|
-
if (this.options.atomic && DOT_RE.test(
|
|
22267
|
+
_isIgnored(path27, stats) {
|
|
22268
|
+
if (this.options.atomic && DOT_RE.test(path27))
|
|
22269
22269
|
return true;
|
|
22270
22270
|
if (!this._userIgnored) {
|
|
22271
22271
|
const { cwd } = this.options;
|
|
@@ -22275,17 +22275,17 @@ var init_esm2 = __esm({
|
|
|
22275
22275
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
22276
22276
|
this._userIgnored = anymatch(list, void 0);
|
|
22277
22277
|
}
|
|
22278
|
-
return this._userIgnored(
|
|
22278
|
+
return this._userIgnored(path27, stats);
|
|
22279
22279
|
}
|
|
22280
|
-
_isntIgnored(
|
|
22281
|
-
return !this._isIgnored(
|
|
22280
|
+
_isntIgnored(path27, stat5) {
|
|
22281
|
+
return !this._isIgnored(path27, stat5);
|
|
22282
22282
|
}
|
|
22283
22283
|
/**
|
|
22284
22284
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
22285
22285
|
* @param path file or directory pattern being watched
|
|
22286
22286
|
*/
|
|
22287
|
-
_getWatchHelpers(
|
|
22288
|
-
return new WatchHelper(
|
|
22287
|
+
_getWatchHelpers(path27) {
|
|
22288
|
+
return new WatchHelper(path27, this.options.followSymlinks, this);
|
|
22289
22289
|
}
|
|
22290
22290
|
// Directory helpers
|
|
22291
22291
|
// -----------------
|
|
@@ -22317,63 +22317,63 @@ var init_esm2 = __esm({
|
|
|
22317
22317
|
* @param item base path of item/directory
|
|
22318
22318
|
*/
|
|
22319
22319
|
_remove(directory, item, isDirectory) {
|
|
22320
|
-
const
|
|
22321
|
-
const fullPath = sysPath2.resolve(
|
|
22322
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
22323
|
-
if (!this._throttle("remove",
|
|
22320
|
+
const path27 = sysPath2.join(directory, item);
|
|
22321
|
+
const fullPath = sysPath2.resolve(path27);
|
|
22322
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path27) || this._watched.has(fullPath);
|
|
22323
|
+
if (!this._throttle("remove", path27, 100))
|
|
22324
22324
|
return;
|
|
22325
22325
|
if (!isDirectory && this._watched.size === 1) {
|
|
22326
22326
|
this.add(directory, item, true);
|
|
22327
22327
|
}
|
|
22328
|
-
const wp = this._getWatchedDir(
|
|
22328
|
+
const wp = this._getWatchedDir(path27);
|
|
22329
22329
|
const nestedDirectoryChildren = wp.getChildren();
|
|
22330
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
22330
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path27, nested));
|
|
22331
22331
|
const parent = this._getWatchedDir(directory);
|
|
22332
22332
|
const wasTracked = parent.has(item);
|
|
22333
22333
|
parent.remove(item);
|
|
22334
22334
|
if (this._symlinkPaths.has(fullPath)) {
|
|
22335
22335
|
this._symlinkPaths.delete(fullPath);
|
|
22336
22336
|
}
|
|
22337
|
-
let relPath =
|
|
22337
|
+
let relPath = path27;
|
|
22338
22338
|
if (this.options.cwd)
|
|
22339
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
22339
|
+
relPath = sysPath2.relative(this.options.cwd, path27);
|
|
22340
22340
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
22341
22341
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
22342
22342
|
if (event === EVENTS.ADD)
|
|
22343
22343
|
return;
|
|
22344
22344
|
}
|
|
22345
|
-
this._watched.delete(
|
|
22345
|
+
this._watched.delete(path27);
|
|
22346
22346
|
this._watched.delete(fullPath);
|
|
22347
22347
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
22348
|
-
if (wasTracked && !this._isIgnored(
|
|
22349
|
-
this._emit(eventName,
|
|
22350
|
-
this._closePath(
|
|
22348
|
+
if (wasTracked && !this._isIgnored(path27))
|
|
22349
|
+
this._emit(eventName, path27);
|
|
22350
|
+
this._closePath(path27);
|
|
22351
22351
|
}
|
|
22352
22352
|
/**
|
|
22353
22353
|
* Closes all watchers for a path
|
|
22354
22354
|
*/
|
|
22355
|
-
_closePath(
|
|
22356
|
-
this._closeFile(
|
|
22357
|
-
const dir = sysPath2.dirname(
|
|
22358
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
22355
|
+
_closePath(path27) {
|
|
22356
|
+
this._closeFile(path27);
|
|
22357
|
+
const dir = sysPath2.dirname(path27);
|
|
22358
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path27));
|
|
22359
22359
|
}
|
|
22360
22360
|
/**
|
|
22361
22361
|
* Closes only file-specific watchers
|
|
22362
22362
|
*/
|
|
22363
|
-
_closeFile(
|
|
22364
|
-
const closers = this._closers.get(
|
|
22363
|
+
_closeFile(path27) {
|
|
22364
|
+
const closers = this._closers.get(path27);
|
|
22365
22365
|
if (!closers)
|
|
22366
22366
|
return;
|
|
22367
22367
|
closers.forEach((closer) => closer());
|
|
22368
|
-
this._closers.delete(
|
|
22368
|
+
this._closers.delete(path27);
|
|
22369
22369
|
}
|
|
22370
|
-
_addPathCloser(
|
|
22370
|
+
_addPathCloser(path27, closer) {
|
|
22371
22371
|
if (!closer)
|
|
22372
22372
|
return;
|
|
22373
|
-
let list = this._closers.get(
|
|
22373
|
+
let list = this._closers.get(path27);
|
|
22374
22374
|
if (!list) {
|
|
22375
22375
|
list = [];
|
|
22376
|
-
this._closers.set(
|
|
22376
|
+
this._closers.set(path27, list);
|
|
22377
22377
|
}
|
|
22378
22378
|
list.push(closer);
|
|
22379
22379
|
}
|
|
@@ -22478,6 +22478,7 @@ __export(dist_exports, {
|
|
|
22478
22478
|
createGitWorkspaceMonitor: () => createGitWorkspaceMonitor,
|
|
22479
22479
|
createInteractionId: () => createInteractionId,
|
|
22480
22480
|
createMesh: () => createMesh,
|
|
22481
|
+
createWorktree: () => createWorktree,
|
|
22481
22482
|
deleteMesh: () => deleteMesh,
|
|
22482
22483
|
detectAllVersions: () => detectAllVersions,
|
|
22483
22484
|
detectCLIs: () => detectCLIs,
|
|
@@ -22530,6 +22531,7 @@ __export(dist_exports, {
|
|
|
22530
22531
|
launchWithCdp: () => launchWithCdp,
|
|
22531
22532
|
listHostedCliRuntimes: () => listHostedCliRuntimes,
|
|
22532
22533
|
listMeshes: () => listMeshes,
|
|
22534
|
+
listWorktrees: () => listWorktrees,
|
|
22533
22535
|
loadConfig: () => loadConfig,
|
|
22534
22536
|
loadState: () => loadState,
|
|
22535
22537
|
logCommand: () => logCommand,
|
|
@@ -22549,6 +22551,7 @@ __export(dist_exports, {
|
|
|
22549
22551
|
normalizeSessionModalFields: () => normalizeSessionModalFields,
|
|
22550
22552
|
parsePorcelainV2Status: () => parsePorcelainV2Status,
|
|
22551
22553
|
parseProviderSourceConfigUpdate: () => parseProviderSourceConfigUpdate,
|
|
22554
|
+
parseWorktreeListOutput: () => parseWorktreeListOutput,
|
|
22552
22555
|
partitionSessionHostDiagnosticsSessions: () => partitionSessionHostDiagnosticsSessions,
|
|
22553
22556
|
partitionSessionHostRecords: () => partitionSessionHostRecords,
|
|
22554
22557
|
prepareSessionChatTailUpdate: () => prepareSessionChatTailUpdate,
|
|
@@ -22558,6 +22561,7 @@ __export(dist_exports, {
|
|
|
22558
22561
|
recordDebugTrace: () => recordDebugTrace,
|
|
22559
22562
|
registerExtensionProviders: () => registerExtensionProviders,
|
|
22560
22563
|
removeNode: () => removeNode,
|
|
22564
|
+
removeWorktree: () => removeWorktree,
|
|
22561
22565
|
resetConfig: () => resetConfig,
|
|
22562
22566
|
resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
|
|
22563
22567
|
resetState: () => resetState,
|
|
@@ -22567,6 +22571,7 @@ __export(dist_exports, {
|
|
|
22567
22571
|
resolveGitRepository: () => resolveGitRepository,
|
|
22568
22572
|
resolveSessionHostAppName: () => resolveSessionHostAppName,
|
|
22569
22573
|
resolveSessionHostAppNameResolution: () => resolveSessionHostAppNameResolution,
|
|
22574
|
+
resolveWorktreePath: () => resolveWorktreePath,
|
|
22570
22575
|
runAsyncBatch: () => runAsyncBatch,
|
|
22571
22576
|
runGit: () => runGit,
|
|
22572
22577
|
saveConfig: () => saveConfig,
|
|
@@ -22586,6 +22591,109 @@ __export(dist_exports, {
|
|
|
22586
22591
|
updateNode: () => updateNode,
|
|
22587
22592
|
upsertSavedProviderSession: () => upsertSavedProviderSession
|
|
22588
22593
|
});
|
|
22594
|
+
function resolveWorktreePath(repoRoot, meshName, branch) {
|
|
22595
|
+
const safeBranch = branch.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
|
|
22596
|
+
const safeMeshName = meshName.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
|
|
22597
|
+
const parentDir = path4.dirname(repoRoot);
|
|
22598
|
+
return path4.join(parentDir, WORKTREE_DIR_NAME, safeMeshName, safeBranch);
|
|
22599
|
+
}
|
|
22600
|
+
async function createWorktree(opts) {
|
|
22601
|
+
const { repoRoot, branch, baseBranch, meshName } = opts;
|
|
22602
|
+
const targetDir = opts.targetDir || resolveWorktreePath(repoRoot, meshName, branch);
|
|
22603
|
+
if ((0, import_fs3.existsSync)(targetDir)) {
|
|
22604
|
+
throw new Error(`Worktree target directory already exists: ${targetDir}`);
|
|
22605
|
+
}
|
|
22606
|
+
await (0, import_promises4.mkdir)(path4.dirname(targetDir), { recursive: true });
|
|
22607
|
+
const args = ["worktree", "add", targetDir, "-b", branch];
|
|
22608
|
+
if (baseBranch) {
|
|
22609
|
+
args.push(baseBranch);
|
|
22610
|
+
}
|
|
22611
|
+
try {
|
|
22612
|
+
await execFileAsync2("git", args, {
|
|
22613
|
+
cwd: repoRoot,
|
|
22614
|
+
encoding: "utf8",
|
|
22615
|
+
timeout: GIT_TIMEOUT_MS,
|
|
22616
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
22617
|
+
windowsHide: true
|
|
22618
|
+
});
|
|
22619
|
+
} catch (error48) {
|
|
22620
|
+
const stderr = typeof error48.stderr === "string" ? error48.stderr : "";
|
|
22621
|
+
if (/already exists/i.test(stderr)) {
|
|
22622
|
+
throw new Error(`Branch '${branch}' already exists or is checked out in another worktree`);
|
|
22623
|
+
}
|
|
22624
|
+
throw new Error(`git worktree add failed: ${stderr.trim() || error48.message}`);
|
|
22625
|
+
}
|
|
22626
|
+
return {
|
|
22627
|
+
success: true,
|
|
22628
|
+
worktreePath: targetDir,
|
|
22629
|
+
branch
|
|
22630
|
+
};
|
|
22631
|
+
}
|
|
22632
|
+
async function removeWorktree(repoRoot, worktreePath) {
|
|
22633
|
+
if (!(0, import_fs3.existsSync)(worktreePath)) {
|
|
22634
|
+
await pruneWorktrees(repoRoot);
|
|
22635
|
+
return { success: true, removedPath: worktreePath };
|
|
22636
|
+
}
|
|
22637
|
+
try {
|
|
22638
|
+
await execFileAsync2("git", ["worktree", "remove", worktreePath, "--force"], {
|
|
22639
|
+
cwd: repoRoot,
|
|
22640
|
+
encoding: "utf8",
|
|
22641
|
+
timeout: GIT_TIMEOUT_MS,
|
|
22642
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
22643
|
+
windowsHide: true
|
|
22644
|
+
});
|
|
22645
|
+
} catch (error48) {
|
|
22646
|
+
const stderr = typeof error48.stderr === "string" ? error48.stderr : "";
|
|
22647
|
+
throw new Error(`git worktree remove failed: ${stderr.trim() || error48.message}`);
|
|
22648
|
+
}
|
|
22649
|
+
return { success: true, removedPath: worktreePath };
|
|
22650
|
+
}
|
|
22651
|
+
async function listWorktrees(repoRoot) {
|
|
22652
|
+
const { stdout } = await execFileAsync2("git", ["worktree", "list", "--porcelain"], {
|
|
22653
|
+
cwd: repoRoot,
|
|
22654
|
+
encoding: "utf8",
|
|
22655
|
+
timeout: GIT_TIMEOUT_MS,
|
|
22656
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
22657
|
+
windowsHide: true
|
|
22658
|
+
});
|
|
22659
|
+
return parseWorktreeListOutput(stdout);
|
|
22660
|
+
}
|
|
22661
|
+
function parseWorktreeListOutput(output) {
|
|
22662
|
+
const entries = [];
|
|
22663
|
+
const blocks = output.trim().split(/\n\n+/);
|
|
22664
|
+
for (const block of blocks) {
|
|
22665
|
+
if (!block.trim()) continue;
|
|
22666
|
+
const lines = block.trim().split("\n");
|
|
22667
|
+
const entry = { path: "", head: "", branch: null, bare: false };
|
|
22668
|
+
for (const line of lines) {
|
|
22669
|
+
if (line.startsWith("worktree ")) {
|
|
22670
|
+
entry.path = line.slice("worktree ".length).trim();
|
|
22671
|
+
} else if (line.startsWith("HEAD ")) {
|
|
22672
|
+
entry.head = line.slice("HEAD ".length).trim();
|
|
22673
|
+
} else if (line.startsWith("branch ")) {
|
|
22674
|
+
const ref = line.slice("branch ".length).trim();
|
|
22675
|
+
entry.branch = ref.replace(/^refs\/heads\//, "");
|
|
22676
|
+
} else if (line === "bare") {
|
|
22677
|
+
entry.bare = true;
|
|
22678
|
+
}
|
|
22679
|
+
}
|
|
22680
|
+
if (entry.path) {
|
|
22681
|
+
entries.push(entry);
|
|
22682
|
+
}
|
|
22683
|
+
}
|
|
22684
|
+
return entries;
|
|
22685
|
+
}
|
|
22686
|
+
async function pruneWorktrees(repoRoot) {
|
|
22687
|
+
try {
|
|
22688
|
+
await execFileAsync2("git", ["worktree", "prune"], {
|
|
22689
|
+
cwd: repoRoot,
|
|
22690
|
+
encoding: "utf8",
|
|
22691
|
+
timeout: GIT_TIMEOUT_MS,
|
|
22692
|
+
windowsHide: true
|
|
22693
|
+
});
|
|
22694
|
+
} catch {
|
|
22695
|
+
}
|
|
22696
|
+
}
|
|
22589
22697
|
function resolveProviderSourceMode(providerSourceMode, legacyDisableUpstream) {
|
|
22590
22698
|
if (providerSourceMode === "normal" || providerSourceMode === "no-upstream") {
|
|
22591
22699
|
return providerSourceMode;
|
|
@@ -22679,8 +22787,8 @@ function ensureMachineId(config2) {
|
|
|
22679
22787
|
}
|
|
22680
22788
|
function getConfigDir() {
|
|
22681
22789
|
const dir = (0, import_path.join)((0, import_os2.homedir)(), ".adhdev");
|
|
22682
|
-
if (!(0,
|
|
22683
|
-
(0,
|
|
22790
|
+
if (!(0, import_fs4.existsSync)(dir)) {
|
|
22791
|
+
(0, import_fs4.mkdirSync)(dir, { recursive: true });
|
|
22684
22792
|
}
|
|
22685
22793
|
return dir;
|
|
22686
22794
|
}
|
|
@@ -22689,7 +22797,7 @@ function getConfigPath() {
|
|
|
22689
22797
|
}
|
|
22690
22798
|
function migrateStateToStateFile(raw) {
|
|
22691
22799
|
const statePath = (0, import_path.join)(getConfigDir(), "state.json");
|
|
22692
|
-
if ((0,
|
|
22800
|
+
if ((0, import_fs4.existsSync)(statePath)) return;
|
|
22693
22801
|
const recentActivity = Array.isArray(raw.recentActivity) ? raw.recentActivity : [];
|
|
22694
22802
|
const savedProviderSessions = Array.isArray(raw.savedProviderSessions) ? raw.savedProviderSessions : [];
|
|
22695
22803
|
const legacySessionReads = isPlainObject2(raw.recentSessionReads) ? raw.recentSessionReads : {};
|
|
@@ -22709,11 +22817,11 @@ function migrateStateToStateFile(raw) {
|
|
|
22709
22817
|
sessionReads: mergedReads,
|
|
22710
22818
|
sessionReadMarkers: cleanedMarkers
|
|
22711
22819
|
};
|
|
22712
|
-
(0,
|
|
22820
|
+
(0, import_fs4.writeFileSync)(statePath, JSON.stringify(state, null, 2), { encoding: "utf-8", mode: 384 });
|
|
22713
22821
|
}
|
|
22714
22822
|
function loadConfig() {
|
|
22715
22823
|
const configPath = getConfigPath();
|
|
22716
|
-
if (!(0,
|
|
22824
|
+
if (!(0, import_fs4.existsSync)(configPath)) {
|
|
22717
22825
|
const initialized = ensureMachineId({ ...DEFAULT_CONFIG });
|
|
22718
22826
|
try {
|
|
22719
22827
|
saveConfig(initialized.config);
|
|
@@ -22722,7 +22830,7 @@ function loadConfig() {
|
|
|
22722
22830
|
return initialized.config;
|
|
22723
22831
|
}
|
|
22724
22832
|
try {
|
|
22725
|
-
const raw = (0,
|
|
22833
|
+
const raw = (0, import_fs4.readFileSync)(configPath, "utf-8");
|
|
22726
22834
|
const parsed = JSON.parse(raw);
|
|
22727
22835
|
migrateStateToStateFile(parsed);
|
|
22728
22836
|
const normalizedInput = normalizeConfig(parsed);
|
|
@@ -22744,12 +22852,12 @@ function saveConfig(config2) {
|
|
|
22744
22852
|
const configPath = getConfigPath();
|
|
22745
22853
|
const dir = getConfigDir();
|
|
22746
22854
|
const normalized = normalizeConfig(config2);
|
|
22747
|
-
if (!(0,
|
|
22748
|
-
(0,
|
|
22855
|
+
if (!(0, import_fs4.existsSync)(dir)) {
|
|
22856
|
+
(0, import_fs4.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
22749
22857
|
}
|
|
22750
|
-
(0,
|
|
22858
|
+
(0, import_fs4.writeFileSync)(configPath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
22751
22859
|
try {
|
|
22752
|
-
(0,
|
|
22860
|
+
(0, import_fs4.chmodSync)(configPath, 384);
|
|
22753
22861
|
} catch {
|
|
22754
22862
|
}
|
|
22755
22863
|
}
|
|
@@ -22780,10 +22888,10 @@ function getMeshConfigPath() {
|
|
|
22780
22888
|
return (0, import_path2.join)(getConfigDir(), "meshes.json");
|
|
22781
22889
|
}
|
|
22782
22890
|
function loadMeshConfig() {
|
|
22783
|
-
const
|
|
22784
|
-
if (!(0,
|
|
22891
|
+
const path27 = getMeshConfigPath();
|
|
22892
|
+
if (!(0, import_fs5.existsSync)(path27)) return { meshes: [] };
|
|
22785
22893
|
try {
|
|
22786
|
-
const raw = JSON.parse((0,
|
|
22894
|
+
const raw = JSON.parse((0, import_fs5.readFileSync)(path27, "utf-8"));
|
|
22787
22895
|
if (!raw || !Array.isArray(raw.meshes)) return { meshes: [] };
|
|
22788
22896
|
return raw;
|
|
22789
22897
|
} catch {
|
|
@@ -22791,16 +22899,16 @@ function loadMeshConfig() {
|
|
|
22791
22899
|
}
|
|
22792
22900
|
}
|
|
22793
22901
|
function saveMeshConfig(config2) {
|
|
22794
|
-
const
|
|
22795
|
-
(0,
|
|
22902
|
+
const path27 = getMeshConfigPath();
|
|
22903
|
+
(0, import_fs5.writeFileSync)(path27, JSON.stringify(config2, null, 2), { encoding: "utf-8", mode: 384 });
|
|
22796
22904
|
}
|
|
22797
22905
|
function normalizeRepoIdentity(remoteUrl) {
|
|
22798
22906
|
let identity = remoteUrl.trim();
|
|
22799
22907
|
if (identity.startsWith("http://") || identity.startsWith("https://")) {
|
|
22800
22908
|
try {
|
|
22801
22909
|
const url2 = new URL(identity);
|
|
22802
|
-
const
|
|
22803
|
-
return `${url2.hostname}/${
|
|
22910
|
+
const path27 = url2.pathname.replace(/^\//, "").replace(/\.git$/, "");
|
|
22911
|
+
return `${url2.hostname}/${path27}`;
|
|
22804
22912
|
} catch {
|
|
22805
22913
|
}
|
|
22806
22914
|
}
|
|
@@ -22875,9 +22983,12 @@ function addNode(meshId, opts) {
|
|
|
22875
22983
|
id: `node_${(0, import_crypto3.randomUUID)().replace(/-/g, "")}`,
|
|
22876
22984
|
workspace: opts.workspace.trim(),
|
|
22877
22985
|
repoRoot: opts.repoRoot,
|
|
22986
|
+
daemonId: opts.daemonId,
|
|
22878
22987
|
userOverrides: opts.userOverrides || {},
|
|
22879
22988
|
policy: opts.policy || {},
|
|
22880
|
-
isLocalWorktree: opts.isLocalWorktree
|
|
22989
|
+
isLocalWorktree: opts.isLocalWorktree,
|
|
22990
|
+
worktreeBranch: opts.worktreeBranch,
|
|
22991
|
+
clonedFromNodeId: opts.clonedFromNodeId
|
|
22881
22992
|
};
|
|
22882
22993
|
mesh.nodes.push(node);
|
|
22883
22994
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -22908,7 +23019,7 @@ function updateNode(meshId, nodeId, opts) {
|
|
|
22908
23019
|
return node;
|
|
22909
23020
|
}
|
|
22910
23021
|
function buildCoordinatorSystemPrompt(ctx) {
|
|
22911
|
-
const { mesh, status, userInstruction } = ctx;
|
|
23022
|
+
const { mesh, status, userInstruction, coordinatorCliType } = ctx;
|
|
22912
23023
|
const sections = [];
|
|
22913
23024
|
sections.push(`You are a **Repo Mesh Coordinator** \u2014 a technical team lead who orchestrates work across multiple agent sessions on a shared Git repository.
|
|
22914
23025
|
|
|
@@ -22922,15 +23033,15 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
22922
23033
|
} else {
|
|
22923
23034
|
sections.push("## Nodes\nNo nodes configured yet. Ask the user to add nodes with `adhdev mesh add-node`.");
|
|
22924
23035
|
}
|
|
22925
|
-
sections.push(buildPolicySection(mesh.policy));
|
|
23036
|
+
sections.push(buildPolicySection({ ...DEFAULT_MESH_POLICY, ...mesh.policy || {} }));
|
|
22926
23037
|
sections.push(TOOLS_SECTION);
|
|
22927
23038
|
sections.push(WORKFLOW_SECTION);
|
|
22928
|
-
sections.push(
|
|
23039
|
+
sections.push(buildRulesSection(coordinatorCliType));
|
|
22929
23040
|
if (userInstruction) {
|
|
22930
23041
|
sections.push(`## Additional Context
|
|
22931
23042
|
${userInstruction}`);
|
|
22932
23043
|
}
|
|
22933
|
-
if (mesh.coordinator
|
|
23044
|
+
if (mesh.coordinator?.systemPromptSuffix) {
|
|
22934
23045
|
sections.push(mesh.coordinator.systemPromptSuffix);
|
|
22935
23046
|
}
|
|
22936
23047
|
return sections.join("\n\n");
|
|
@@ -22975,6 +23086,24 @@ function buildPolicySection(policy) {
|
|
|
22975
23086
|
return `## Policy
|
|
22976
23087
|
${rules.join("\n")}`;
|
|
22977
23088
|
}
|
|
23089
|
+
function buildRulesSection(coordinatorCliType) {
|
|
23090
|
+
const coordinatorNote = coordinatorCliType ? `
|
|
23091
|
+
- **Coordinator runtime is not a delegation default.** This coordinator is running as \`${coordinatorCliType}\`, but delegated node sessions must follow the user's requested provider, not the coordinator's own runtime.` : "";
|
|
23092
|
+
return `## Rules
|
|
23093
|
+
|
|
23094
|
+
- **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly \u2014 delegate all of that to node agents. Your context should stay lean.
|
|
23095
|
+
- **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to a node. Do not do it yourself.
|
|
23096
|
+
- **Respect explicit provider requests.** If the user names an agent/provider, pass the matching provider type to \`mesh_launch_session\`: Hermes \u2192 \`hermes-cli\`, Claude Code/Claude \u2192 \`claude-cli\`, Codex \u2192 \`codex-cli\`, Gemini \u2192 \`gemini-cli\`. Never substitute \`claude-cli\` just because the coordinator itself is Claude Code.
|
|
23097
|
+
- **Front-load the task message.** When calling \`mesh_send_task\`, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
|
|
23098
|
+
- **Don't inspect code.** Trust the agent's output. Verify via \`mesh_git_status\`, not by reading source files.
|
|
23099
|
+
- **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed.
|
|
23100
|
+
- **Handle failures gracefully.** If a task fails, read the chat to understand why, then retry or reassign.
|
|
23101
|
+
- **Keep the user informed.** Report progress after each delegation round \u2014 one or two sentences, not a narration.
|
|
23102
|
+
- **Respect node capabilities.** Don't send build tasks to read-only nodes. Don't push from nodes that aren't allowed to.
|
|
23103
|
+
- **Never fabricate tool results.** Always call the actual tool; never pretend you did.
|
|
23104
|
+
- **Clean up worktree nodes.** After a worktree task completes and its changes are merged or checkpointed, call \`mesh_remove_node\` to free resources.
|
|
23105
|
+
- **Name worktree branches meaningfully.** Use descriptive names like \`feat/auth-refactor\` or \`fix/build-123\`.${coordinatorNote}`;
|
|
23106
|
+
}
|
|
22978
23107
|
function setLogLevel(level) {
|
|
22979
23108
|
currentLevel = level;
|
|
22980
23109
|
daemonLog("Logger", `Log level set to: ${level}`, "info");
|
|
@@ -22989,13 +23118,13 @@ function getDaemonLogDir() {
|
|
|
22989
23118
|
return LOG_DIR;
|
|
22990
23119
|
}
|
|
22991
23120
|
function getCurrentDaemonLogPath(date5 = /* @__PURE__ */ new Date()) {
|
|
22992
|
-
return
|
|
23121
|
+
return path10.join(LOG_DIR, `daemon-${date5.toISOString().slice(0, 10)}.log`);
|
|
22993
23122
|
}
|
|
22994
23123
|
function checkDateRotation() {
|
|
22995
23124
|
const today = getDateStr();
|
|
22996
23125
|
if (today !== currentDate) {
|
|
22997
23126
|
currentDate = today;
|
|
22998
|
-
currentLogFile =
|
|
23127
|
+
currentLogFile = path10.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
22999
23128
|
cleanOldLogs();
|
|
23000
23129
|
}
|
|
23001
23130
|
}
|
|
@@ -23009,7 +23138,7 @@ function cleanOldLogs() {
|
|
|
23009
23138
|
const dateMatch = file2.match(/daemon-(\d{4}-\d{2}-\d{2})/);
|
|
23010
23139
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
23011
23140
|
try {
|
|
23012
|
-
fs2.unlinkSync(
|
|
23141
|
+
fs2.unlinkSync(path10.join(LOG_DIR, file2));
|
|
23013
23142
|
} catch {
|
|
23014
23143
|
}
|
|
23015
23144
|
}
|
|
@@ -23337,14 +23466,14 @@ function buildCliScreenSnapshot(text) {
|
|
|
23337
23466
|
function findBinary(name) {
|
|
23338
23467
|
const trimmed = String(name || "").trim();
|
|
23339
23468
|
if (!trimmed) return trimmed;
|
|
23340
|
-
const expanded = trimmed.startsWith("~") ?
|
|
23341
|
-
if (
|
|
23342
|
-
return
|
|
23469
|
+
const expanded = trimmed.startsWith("~") ? path14.join(os9.homedir(), trimmed.slice(1)) : trimmed;
|
|
23470
|
+
if (path14.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
23471
|
+
return path14.isAbsolute(expanded) ? expanded : path14.resolve(expanded);
|
|
23343
23472
|
}
|
|
23344
23473
|
const isWin = os9.platform() === "win32";
|
|
23345
23474
|
try {
|
|
23346
23475
|
const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
|
|
23347
|
-
return (0,
|
|
23476
|
+
return (0, import_child_process2.execSync)(cmd, {
|
|
23348
23477
|
encoding: "utf-8",
|
|
23349
23478
|
timeout: 5e3,
|
|
23350
23479
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -23355,7 +23484,7 @@ function findBinary(name) {
|
|
|
23355
23484
|
}
|
|
23356
23485
|
}
|
|
23357
23486
|
function isScriptBinary(binaryPath) {
|
|
23358
|
-
if (!
|
|
23487
|
+
if (!path14.isAbsolute(binaryPath)) return false;
|
|
23359
23488
|
try {
|
|
23360
23489
|
const fs16 = __require2("fs");
|
|
23361
23490
|
const resolved = fs16.realpathSync(binaryPath);
|
|
@@ -23371,7 +23500,7 @@ function isScriptBinary(binaryPath) {
|
|
|
23371
23500
|
}
|
|
23372
23501
|
}
|
|
23373
23502
|
function looksLikeMachOOrElf(filePath) {
|
|
23374
|
-
if (!
|
|
23503
|
+
if (!path14.isAbsolute(filePath)) return false;
|
|
23375
23504
|
try {
|
|
23376
23505
|
const fs16 = __require2("fs");
|
|
23377
23506
|
const resolved = fs16.realpathSync(filePath);
|
|
@@ -23568,9 +23697,9 @@ function resolveCliSpawnPlan(options) {
|
|
|
23568
23697
|
const allArgs = [...spawnConfig.args, ...extraArgs];
|
|
23569
23698
|
let shellCmd;
|
|
23570
23699
|
let shellArgs;
|
|
23571
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
23700
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path15.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
23572
23701
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
23573
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
23702
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path15.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
23574
23703
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
23575
23704
|
if (useShell) {
|
|
23576
23705
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -23684,8 +23813,8 @@ async function runGit(repoOrWorkspace, argv, options = {}) {
|
|
|
23684
23813
|
});
|
|
23685
23814
|
}
|
|
23686
23815
|
const cwd = options.cwd ? await validateWorkspace(options.cwd) : await validateWorkspace(repo.workspace);
|
|
23687
|
-
const canonicalRepoRoot = await (0,
|
|
23688
|
-
const canonicalCwd = await (0,
|
|
23816
|
+
const canonicalRepoRoot = await (0, import_promises5.realpath)(repo.repoRoot);
|
|
23817
|
+
const canonicalCwd = await (0, import_promises5.realpath)(cwd);
|
|
23689
23818
|
if (!isPathInside(canonicalRepoRoot, canonicalCwd)) {
|
|
23690
23819
|
throw new GitCommandError("path_outside_repo", "Git cwd is outside the repository root", {
|
|
23691
23820
|
argv,
|
|
@@ -23713,13 +23842,13 @@ async function validateWorkspace(workspace) {
|
|
|
23713
23842
|
}
|
|
23714
23843
|
const normalizedWorkspace = path.resolve(workspace);
|
|
23715
23844
|
try {
|
|
23716
|
-
const info = await (0,
|
|
23845
|
+
const info = await (0, import_promises5.stat)(normalizedWorkspace);
|
|
23717
23846
|
if (!info.isDirectory()) {
|
|
23718
23847
|
throw new GitCommandError("invalid_args", "Workspace must be an existing directory", {
|
|
23719
23848
|
cwd: normalizedWorkspace
|
|
23720
23849
|
});
|
|
23721
23850
|
}
|
|
23722
|
-
await (0,
|
|
23851
|
+
await (0, import_promises5.access)(normalizedWorkspace, import_fs6.constants.R_OK);
|
|
23723
23852
|
} catch (error48) {
|
|
23724
23853
|
if (error48 instanceof GitCommandError) throw error48;
|
|
23725
23854
|
throw new GitCommandError("invalid_args", "Workspace must be an existing directory", {
|
|
@@ -24128,9 +24257,9 @@ async function resolveRepoFilePath(repoRoot, filePath) {
|
|
|
24128
24257
|
if (typeof filePath !== "string" || filePath.length === 0 || filePath.includes("\0")) {
|
|
24129
24258
|
throw new GitCommandError("invalid_args", "File path must be a non-empty path");
|
|
24130
24259
|
}
|
|
24131
|
-
const canonicalRepoRoot = await (0,
|
|
24260
|
+
const canonicalRepoRoot = await (0, import_promises6.realpath)(repoRoot).catch(() => path22.resolve(repoRoot));
|
|
24132
24261
|
const absolutePath = path22.isAbsolute(filePath) ? path22.resolve(filePath) : path22.resolve(repoRoot, filePath);
|
|
24133
|
-
const checkPath = await (0,
|
|
24262
|
+
const checkPath = await (0, import_promises6.realpath)(absolutePath).catch(() => absolutePath);
|
|
24134
24263
|
const relativeBase = isPathInside(canonicalRepoRoot, checkPath) ? canonicalRepoRoot : path22.resolve(repoRoot);
|
|
24135
24264
|
if (!isPathInside(canonicalRepoRoot, checkPath) && !isPathInside(repoRoot, absolutePath)) {
|
|
24136
24265
|
throw new GitCommandError("path_outside_repo", "Selected file path is outside the repository root", {
|
|
@@ -24146,7 +24275,7 @@ async function resolveRepoFilePath(repoRoot, filePath) {
|
|
|
24146
24275
|
return { absolutePath, relativePath };
|
|
24147
24276
|
}
|
|
24148
24277
|
async function buildUntrackedDiff(absolutePath, relativePath, readLimit) {
|
|
24149
|
-
const content = await (0,
|
|
24278
|
+
const content = await (0, import_promises6.readFile)(absolutePath, "utf8");
|
|
24150
24279
|
const limitedContent = content.length > readLimit ? content.slice(0, readLimit) : content;
|
|
24151
24280
|
const lines = limitedContent.length > 0 ? limitedContent.split("\n") : [];
|
|
24152
24281
|
const plusLines = lines.filter((line, index) => index < lines.length - 1 || line.length > 0).map((line) => `+${line}`).join("\n");
|
|
@@ -24723,8 +24852,8 @@ function validateGitLogPath(repoRoot, filePath) {
|
|
|
24723
24852
|
function expandPath(p) {
|
|
24724
24853
|
const t = (p || "").trim();
|
|
24725
24854
|
if (!t) return "";
|
|
24726
|
-
if (t.startsWith("~")) return
|
|
24727
|
-
return
|
|
24855
|
+
if (t.startsWith("~")) return path5.join(os5.homedir(), t.slice(1).replace(/^\//, ""));
|
|
24856
|
+
return path5.resolve(t);
|
|
24728
24857
|
}
|
|
24729
24858
|
function validateWorkspacePath(absPath) {
|
|
24730
24859
|
try {
|
|
@@ -24738,7 +24867,7 @@ function validateWorkspacePath(absPath) {
|
|
|
24738
24867
|
}
|
|
24739
24868
|
}
|
|
24740
24869
|
function defaultWorkspaceLabel(absPath) {
|
|
24741
|
-
const base =
|
|
24870
|
+
const base = path5.basename(absPath) || absPath;
|
|
24742
24871
|
return base;
|
|
24743
24872
|
}
|
|
24744
24873
|
function getDefaultWorkspacePath(config2) {
|
|
@@ -24829,9 +24958,9 @@ function resolveIdeLaunchWorkspace(args, config2) {
|
|
|
24829
24958
|
return getDefaultWorkspacePath(config2) || void 0;
|
|
24830
24959
|
}
|
|
24831
24960
|
function findWorkspaceByPath(config2, rawPath) {
|
|
24832
|
-
const abs =
|
|
24961
|
+
const abs = path5.resolve(expandPath(rawPath));
|
|
24833
24962
|
if (!abs) return void 0;
|
|
24834
|
-
return (config2.workspaces || []).find((w) =>
|
|
24963
|
+
return (config2.workspaces || []).find((w) => path5.resolve(expandPath(w.path)) === abs);
|
|
24835
24964
|
}
|
|
24836
24965
|
function addWorkspaceEntry(config2, rawPath, label, options) {
|
|
24837
24966
|
const abs = expandPath(rawPath);
|
|
@@ -24847,7 +24976,7 @@ function addWorkspaceEntry(config2, rawPath, label, options) {
|
|
|
24847
24976
|
const v = validateWorkspacePath(abs);
|
|
24848
24977
|
if (!v.ok) return { error: v.error };
|
|
24849
24978
|
const list = [...config2.workspaces || []];
|
|
24850
|
-
if (list.some((w) =>
|
|
24979
|
+
if (list.some((w) => path5.resolve(w.path) === abs)) {
|
|
24851
24980
|
return { error: "Workspace already in list" };
|
|
24852
24981
|
}
|
|
24853
24982
|
if (list.length >= MAX_WORKSPACES) {
|
|
@@ -24942,9 +25071,9 @@ function normalizePersistedSummaryMetadata(params) {
|
|
|
24942
25071
|
function normalizeWorkspace(workspace) {
|
|
24943
25072
|
if (!workspace) return "";
|
|
24944
25073
|
try {
|
|
24945
|
-
return
|
|
25074
|
+
return path6.resolve(expandPath(workspace));
|
|
24946
25075
|
} catch {
|
|
24947
|
-
return
|
|
25076
|
+
return path6.resolve(workspace);
|
|
24948
25077
|
}
|
|
24949
25078
|
}
|
|
24950
25079
|
function buildRecentActivityKey(entry) {
|
|
@@ -25113,9 +25242,9 @@ function markSessionSeen(state, sessionId, seenAt = Date.now(), completionMarker
|
|
|
25113
25242
|
function normalizeWorkspace2(workspace) {
|
|
25114
25243
|
if (!workspace) return "";
|
|
25115
25244
|
try {
|
|
25116
|
-
return
|
|
25245
|
+
return path7.resolve(expandPath(workspace));
|
|
25117
25246
|
} catch {
|
|
25118
|
-
return
|
|
25247
|
+
return path7.resolve(workspace);
|
|
25119
25248
|
}
|
|
25120
25249
|
}
|
|
25121
25250
|
function buildSavedProviderSessionKey(providerSessionId) {
|
|
@@ -25251,11 +25380,11 @@ function normalizeState(raw) {
|
|
|
25251
25380
|
}
|
|
25252
25381
|
function loadState() {
|
|
25253
25382
|
const statePath = getStatePath();
|
|
25254
|
-
if (!(0,
|
|
25383
|
+
if (!(0, import_fs7.existsSync)(statePath)) {
|
|
25255
25384
|
return { ...DEFAULT_STATE };
|
|
25256
25385
|
}
|
|
25257
25386
|
try {
|
|
25258
|
-
const raw = (0,
|
|
25387
|
+
const raw = (0, import_fs7.readFileSync)(statePath, "utf-8");
|
|
25259
25388
|
return normalizeState(JSON.parse(raw));
|
|
25260
25389
|
} catch {
|
|
25261
25390
|
return { ...DEFAULT_STATE };
|
|
@@ -25264,7 +25393,7 @@ function loadState() {
|
|
|
25264
25393
|
function saveState(state) {
|
|
25265
25394
|
const statePath = getStatePath();
|
|
25266
25395
|
const normalized = normalizeState(state);
|
|
25267
|
-
(0,
|
|
25396
|
+
(0, import_fs7.writeFileSync)(statePath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
25268
25397
|
}
|
|
25269
25398
|
function resetState() {
|
|
25270
25399
|
saveState({ ...DEFAULT_STATE });
|
|
@@ -25285,13 +25414,13 @@ function getMergedDefinitions() {
|
|
|
25285
25414
|
function findCliCommand(command) {
|
|
25286
25415
|
const trimmed = String(command || "").trim();
|
|
25287
25416
|
if (!trimmed) return null;
|
|
25288
|
-
if (
|
|
25289
|
-
const candidate = trimmed.startsWith("~") ?
|
|
25290
|
-
const resolved =
|
|
25291
|
-
return (0,
|
|
25417
|
+
if (path8.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
|
|
25418
|
+
const candidate = trimmed.startsWith("~") ? path8.join((0, import_os3.homedir)(), trimmed.slice(1)) : trimmed;
|
|
25419
|
+
const resolved = path8.isAbsolute(candidate) ? candidate : path8.resolve(candidate);
|
|
25420
|
+
return (0, import_fs8.existsSync)(resolved) ? resolved : null;
|
|
25292
25421
|
}
|
|
25293
25422
|
try {
|
|
25294
|
-
const result = (0,
|
|
25423
|
+
const result = (0, import_child_process4.execSync)(
|
|
25295
25424
|
(0, import_os3.platform)() === "win32" ? `where ${trimmed}` : `which ${trimmed}`,
|
|
25296
25425
|
{ encoding: "utf-8", timeout: 5e3, stdio: ["pipe", "pipe", "pipe"] }
|
|
25297
25426
|
).trim();
|
|
@@ -25302,7 +25431,7 @@ function findCliCommand(command) {
|
|
|
25302
25431
|
}
|
|
25303
25432
|
function getIdeVersion(cliCommand) {
|
|
25304
25433
|
try {
|
|
25305
|
-
const result = (0,
|
|
25434
|
+
const result = (0, import_child_process4.execSync)(`"${cliCommand}" --version`, {
|
|
25306
25435
|
encoding: "utf-8",
|
|
25307
25436
|
timeout: 1e4,
|
|
25308
25437
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -25315,13 +25444,13 @@ function getIdeVersion(cliCommand) {
|
|
|
25315
25444
|
function checkPathExists(paths) {
|
|
25316
25445
|
const home = (0, import_os3.homedir)();
|
|
25317
25446
|
for (const p of paths) {
|
|
25318
|
-
const normalized = p.startsWith("~") ?
|
|
25447
|
+
const normalized = p.startsWith("~") ? path8.join(home, p.slice(1)) : p;
|
|
25319
25448
|
if (normalized.includes("*")) {
|
|
25320
25449
|
const username = home.split(/[\\/]/).pop() || "";
|
|
25321
25450
|
const resolved = normalized.replace("*", username);
|
|
25322
|
-
if ((0,
|
|
25451
|
+
if ((0, import_fs8.existsSync)(resolved)) return resolved;
|
|
25323
25452
|
} else {
|
|
25324
|
-
if ((0,
|
|
25453
|
+
if ((0, import_fs8.existsSync)(normalized)) return normalized;
|
|
25325
25454
|
}
|
|
25326
25455
|
}
|
|
25327
25456
|
return null;
|
|
@@ -25335,11 +25464,11 @@ async function detectIDEs(providerLoader) {
|
|
|
25335
25464
|
let resolvedCli = cliPath;
|
|
25336
25465
|
if (!resolvedCli && appPath && os21 === "darwin") {
|
|
25337
25466
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
25338
|
-
if ((0,
|
|
25467
|
+
if ((0, import_fs8.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
25339
25468
|
}
|
|
25340
25469
|
if (!resolvedCli && appPath && os21 === "win32") {
|
|
25341
|
-
const { dirname:
|
|
25342
|
-
const appDir =
|
|
25470
|
+
const { dirname: dirname92 } = await import("path");
|
|
25471
|
+
const appDir = dirname92(appPath);
|
|
25343
25472
|
const candidates = [
|
|
25344
25473
|
`${appDir}\\\\bin\\\\${def.cli}.cmd`,
|
|
25345
25474
|
`${appDir}\\\\bin\\\\${def.cli}`,
|
|
@@ -25348,7 +25477,7 @@ async function detectIDEs(providerLoader) {
|
|
|
25348
25477
|
`${appDir}\\\\resources\\\\app\\\\bin\\\\${def.cli}.cmd`
|
|
25349
25478
|
];
|
|
25350
25479
|
for (const c of candidates) {
|
|
25351
|
-
if ((0,
|
|
25480
|
+
if ((0, import_fs8.existsSync)(c)) {
|
|
25352
25481
|
resolvedCli = c;
|
|
25353
25482
|
break;
|
|
25354
25483
|
}
|
|
@@ -25380,25 +25509,25 @@ function shellQuote(value) {
|
|
|
25380
25509
|
function expandHome(value) {
|
|
25381
25510
|
const trimmed = value.trim();
|
|
25382
25511
|
if (!trimmed.startsWith("~")) return trimmed;
|
|
25383
|
-
return
|
|
25512
|
+
return path9.join(os22.homedir(), trimmed.slice(1));
|
|
25384
25513
|
}
|
|
25385
25514
|
function isExplicitCommandPath(command) {
|
|
25386
25515
|
const trimmed = command.trim();
|
|
25387
|
-
return
|
|
25516
|
+
return path9.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
25388
25517
|
}
|
|
25389
25518
|
function resolveCommandPath(command) {
|
|
25390
25519
|
const trimmed = command.trim();
|
|
25391
25520
|
if (!trimmed) return null;
|
|
25392
25521
|
if (isExplicitCommandPath(trimmed)) {
|
|
25393
25522
|
const expanded = expandHome(trimmed);
|
|
25394
|
-
const candidate =
|
|
25395
|
-
return (0,
|
|
25523
|
+
const candidate = path9.isAbsolute(expanded) ? expanded : path9.resolve(expanded);
|
|
25524
|
+
return (0, import_fs9.existsSync)(candidate) ? candidate : null;
|
|
25396
25525
|
}
|
|
25397
25526
|
return null;
|
|
25398
25527
|
}
|
|
25399
25528
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
25400
25529
|
return new Promise((resolve162) => {
|
|
25401
|
-
const child = (0,
|
|
25530
|
+
const child = (0, import_child_process5.exec)(cmd, {
|
|
25402
25531
|
encoding: "utf-8",
|
|
25403
25532
|
timeout: timeoutMs,
|
|
25404
25533
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
@@ -25495,7 +25624,7 @@ async function detectCLI(cliId, providerLoader, options) {
|
|
|
25495
25624
|
function parseDarwinAvailableBytes(totalMem) {
|
|
25496
25625
|
if (os32.platform() !== "darwin") return null;
|
|
25497
25626
|
try {
|
|
25498
|
-
const out = (0,
|
|
25627
|
+
const out = (0, import_child_process6.execSync)("vm_stat", {
|
|
25499
25628
|
encoding: "utf-8",
|
|
25500
25629
|
timeout: 4e3,
|
|
25501
25630
|
maxBuffer: 256 * 1024
|
|
@@ -26344,7 +26473,7 @@ function extractSavedHistorySessionIdFromFile(file2) {
|
|
|
26344
26473
|
function buildSavedHistoryFileSignatureMap(dir, files) {
|
|
26345
26474
|
return new Map(files.map((file2) => {
|
|
26346
26475
|
try {
|
|
26347
|
-
const stat22 = fs3.statSync(
|
|
26476
|
+
const stat22 = fs3.statSync(path11.join(dir, file2));
|
|
26348
26477
|
return [file2, `${file2}:${stat22.size}:${Math.trunc(stat22.mtimeMs)}`];
|
|
26349
26478
|
} catch {
|
|
26350
26479
|
return [file2, `${file2}:missing`];
|
|
@@ -26355,7 +26484,7 @@ function buildSavedHistoryCacheSignature(files, fileSignatures) {
|
|
|
26355
26484
|
return files.map((file2) => fileSignatures.get(file2) || `${file2}:missing`).join("|");
|
|
26356
26485
|
}
|
|
26357
26486
|
function getSavedHistoryIndexFilePath(dir) {
|
|
26358
|
-
return
|
|
26487
|
+
return path11.join(dir, SAVED_HISTORY_INDEX_FILE);
|
|
26359
26488
|
}
|
|
26360
26489
|
function getSavedHistoryIndexLockPath(dir) {
|
|
26361
26490
|
return `${getSavedHistoryIndexFilePath(dir)}${SAVED_HISTORY_INDEX_LOCK_SUFFIX}`;
|
|
@@ -26457,7 +26586,7 @@ function savePersistedSavedHistoryIndex(dir, entries) {
|
|
|
26457
26586
|
}
|
|
26458
26587
|
for (const file2 of Array.from(currentEntries.keys())) {
|
|
26459
26588
|
if (incomingFiles.has(file2)) continue;
|
|
26460
|
-
if (!fs3.existsSync(
|
|
26589
|
+
if (!fs3.existsSync(path11.join(dir, file2))) {
|
|
26461
26590
|
currentEntries.delete(file2);
|
|
26462
26591
|
}
|
|
26463
26592
|
}
|
|
@@ -26483,7 +26612,7 @@ function historyDirectoryHasFilesNewerThanIndex(dir) {
|
|
|
26483
26612
|
const indexStat = fs3.statSync(getSavedHistoryIndexFilePath(dir));
|
|
26484
26613
|
const files = listHistoryFiles(dir);
|
|
26485
26614
|
for (const file2 of files) {
|
|
26486
|
-
const stat22 = fs3.statSync(
|
|
26615
|
+
const stat22 = fs3.statSync(path11.join(dir, file2));
|
|
26487
26616
|
if (stat22.mtimeMs > indexStat.mtimeMs) return true;
|
|
26488
26617
|
}
|
|
26489
26618
|
return false;
|
|
@@ -26493,14 +26622,14 @@ function historyDirectoryHasFilesNewerThanIndex(dir) {
|
|
|
26493
26622
|
}
|
|
26494
26623
|
function buildSavedHistoryFileSignature(dir, file2) {
|
|
26495
26624
|
try {
|
|
26496
|
-
const stat22 = fs3.statSync(
|
|
26625
|
+
const stat22 = fs3.statSync(path11.join(dir, file2));
|
|
26497
26626
|
return `${file2}:${stat22.size}:${Math.trunc(stat22.mtimeMs)}`;
|
|
26498
26627
|
} catch {
|
|
26499
26628
|
return `${file2}:missing`;
|
|
26500
26629
|
}
|
|
26501
26630
|
}
|
|
26502
26631
|
function persistSavedHistoryFileSummaryEntry(agentType, dir, file2, updater) {
|
|
26503
|
-
const filePath =
|
|
26632
|
+
const filePath = path11.join(dir, file2);
|
|
26504
26633
|
const result = withLockedPersistedSavedHistoryIndex(dir, (entries) => {
|
|
26505
26634
|
const currentEntry = entries.get(file2) || null;
|
|
26506
26635
|
const nextSummary = updater(currentEntry?.summary || null);
|
|
@@ -26573,7 +26702,7 @@ function updateSavedHistoryIndexForAppendedMessages(agentType, dir, file2, histo
|
|
|
26573
26702
|
function computeSavedHistoryFileSummary(dir, file2) {
|
|
26574
26703
|
const historySessionId = extractSavedHistorySessionIdFromFile(file2);
|
|
26575
26704
|
if (!historySessionId) return null;
|
|
26576
|
-
const filePath =
|
|
26705
|
+
const filePath = path11.join(dir, file2);
|
|
26577
26706
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
26578
26707
|
const lines = content.split("\n").filter(Boolean);
|
|
26579
26708
|
let messageCount = 0;
|
|
@@ -26660,7 +26789,7 @@ function computeSavedHistorySessionSummaries(agentType, dir, files, fileSignatur
|
|
|
26660
26789
|
const summaryBySessionId = /* @__PURE__ */ new Map();
|
|
26661
26790
|
const nextPersistedEntries = /* @__PURE__ */ new Map();
|
|
26662
26791
|
for (const file2 of files.slice().sort()) {
|
|
26663
|
-
const filePath =
|
|
26792
|
+
const filePath = path11.join(dir, file2);
|
|
26664
26793
|
const signature = fileSignatures.get(file2) || `${file2}:missing`;
|
|
26665
26794
|
const cached2 = savedHistoryFileSummaryCache.get(filePath);
|
|
26666
26795
|
const persisted = persistedEntries.get(file2);
|
|
@@ -26742,13 +26871,13 @@ function pageHistoryRecords(agentType, records, offset = 0, limit = 30, excludeR
|
|
|
26742
26871
|
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0, historyBehavior) {
|
|
26743
26872
|
try {
|
|
26744
26873
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
26745
|
-
const dir =
|
|
26874
|
+
const dir = path11.join(HISTORY_DIR, sanitized);
|
|
26746
26875
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
26747
26876
|
const files = listHistoryFiles(dir, historySessionId);
|
|
26748
26877
|
const allMessages = [];
|
|
26749
26878
|
const seen = /* @__PURE__ */ new Set();
|
|
26750
26879
|
for (const file2 of files) {
|
|
26751
|
-
const filePath =
|
|
26880
|
+
const filePath = path11.join(dir, file2);
|
|
26752
26881
|
const content = fs3.readFileSync(filePath, "utf-8");
|
|
26753
26882
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
26754
26883
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -26772,7 +26901,7 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, ex
|
|
|
26772
26901
|
function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
|
|
26773
26902
|
try {
|
|
26774
26903
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
26775
|
-
const dir =
|
|
26904
|
+
const dir = path11.join(HISTORY_DIR, sanitized);
|
|
26776
26905
|
if (!fs3.existsSync(dir)) {
|
|
26777
26906
|
savedHistorySessionCache.delete(sanitized);
|
|
26778
26907
|
return { sessions: [], hasMore: false };
|
|
@@ -26833,11 +26962,11 @@ function listSavedHistorySessions(agentType, options = {}, historyBehavior) {
|
|
|
26833
26962
|
}
|
|
26834
26963
|
function readExistingSessionStartRecord(agentType, historySessionId) {
|
|
26835
26964
|
try {
|
|
26836
|
-
const dir =
|
|
26965
|
+
const dir = path11.join(HISTORY_DIR, agentType);
|
|
26837
26966
|
if (!fs3.existsSync(dir)) return null;
|
|
26838
26967
|
const files = listHistoryFiles(dir, historySessionId).sort();
|
|
26839
26968
|
for (const file2 of files) {
|
|
26840
|
-
const lines = fs3.readFileSync(
|
|
26969
|
+
const lines = fs3.readFileSync(path11.join(dir, file2), "utf-8").split("\n").filter(Boolean);
|
|
26841
26970
|
for (const line of lines) {
|
|
26842
26971
|
try {
|
|
26843
26972
|
const parsed = JSON.parse(line);
|
|
@@ -26857,16 +26986,16 @@ function readExistingSessionStartRecord(agentType, historySessionId) {
|
|
|
26857
26986
|
function rewriteCanonicalSavedHistory(agentType, historySessionId, records) {
|
|
26858
26987
|
if (records.length === 0) return false;
|
|
26859
26988
|
try {
|
|
26860
|
-
const dir =
|
|
26989
|
+
const dir = path11.join(HISTORY_DIR, agentType);
|
|
26861
26990
|
fs3.mkdirSync(dir, { recursive: true });
|
|
26862
26991
|
const prefix = `${historySessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
|
|
26863
26992
|
for (const file2 of fs3.readdirSync(dir)) {
|
|
26864
26993
|
if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
|
|
26865
|
-
fs3.unlinkSync(
|
|
26994
|
+
fs3.unlinkSync(path11.join(dir, file2));
|
|
26866
26995
|
}
|
|
26867
26996
|
}
|
|
26868
26997
|
const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
|
|
26869
|
-
const filePath =
|
|
26998
|
+
const filePath = path11.join(dir, `${prefix}${targetDate}.jsonl`);
|
|
26870
26999
|
fs3.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
|
|
26871
27000
|
`, "utf-8");
|
|
26872
27001
|
invalidatePersistedSavedHistoryIndex(agentType, dir);
|
|
@@ -28259,7 +28388,7 @@ function buildDebugBundleText(bundle) {
|
|
|
28259
28388
|
}
|
|
28260
28389
|
function getChatDebugBundleDir() {
|
|
28261
28390
|
const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
|
|
28262
|
-
return override ||
|
|
28391
|
+
return override || path12.join(os6.homedir(), ".adhdev", "debug-bundles", "chat");
|
|
28263
28392
|
}
|
|
28264
28393
|
function safeBundleIdSegment(value, fallback) {
|
|
28265
28394
|
const normalized = String(value || fallback).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
@@ -28292,7 +28421,7 @@ function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
|
|
|
28292
28421
|
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
28293
28422
|
const dir = getChatDebugBundleDir();
|
|
28294
28423
|
fs4.mkdirSync(dir, { recursive: true });
|
|
28295
|
-
const savedPath =
|
|
28424
|
+
const savedPath = path12.join(dir, `${bundleId}.json`);
|
|
28296
28425
|
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
28297
28426
|
`;
|
|
28298
28427
|
fs4.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
@@ -29653,25 +29782,25 @@ function resolveSafePath(requestedPath) {
|
|
|
29653
29782
|
const inputPath = rawPath || ".";
|
|
29654
29783
|
const home = os7.homedir();
|
|
29655
29784
|
if (inputPath.startsWith("~")) {
|
|
29656
|
-
return
|
|
29785
|
+
return path13.resolve(path13.join(home, inputPath.slice(1)));
|
|
29657
29786
|
}
|
|
29658
29787
|
if (process.platform === "win32") {
|
|
29659
29788
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
29660
|
-
if (
|
|
29661
|
-
return
|
|
29789
|
+
if (path13.win32.isAbsolute(normalized)) {
|
|
29790
|
+
return path13.win32.normalize(normalized);
|
|
29662
29791
|
}
|
|
29663
|
-
return
|
|
29792
|
+
return path13.win32.resolve(normalized);
|
|
29664
29793
|
}
|
|
29665
|
-
if (
|
|
29666
|
-
return
|
|
29794
|
+
if (path13.isAbsolute(inputPath)) {
|
|
29795
|
+
return path13.normalize(inputPath);
|
|
29667
29796
|
}
|
|
29668
|
-
return
|
|
29797
|
+
return path13.resolve(inputPath);
|
|
29669
29798
|
}
|
|
29670
29799
|
function listDirectoryEntriesSafe(dirPath) {
|
|
29671
29800
|
const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
|
|
29672
29801
|
const files = [];
|
|
29673
29802
|
for (const entry of entries) {
|
|
29674
|
-
const entryPath =
|
|
29803
|
+
const entryPath = path13.join(dirPath, entry.name);
|
|
29675
29804
|
try {
|
|
29676
29805
|
if (entry.isDirectory()) {
|
|
29677
29806
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -29725,7 +29854,7 @@ async function handleFileRead(h, args) {
|
|
|
29725
29854
|
async function handleFileWrite(h, args) {
|
|
29726
29855
|
try {
|
|
29727
29856
|
const filePath = resolveSafePath(args?.path);
|
|
29728
|
-
fs5.mkdirSync(
|
|
29857
|
+
fs5.mkdirSync(path13.dirname(filePath), { recursive: true });
|
|
29729
29858
|
fs5.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
29730
29859
|
return { success: true, path: filePath };
|
|
29731
29860
|
} catch (e) {
|
|
@@ -30406,7 +30535,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
|
|
|
30406
30535
|
}
|
|
30407
30536
|
function getDatabaseSync() {
|
|
30408
30537
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
30409
|
-
const requireFn = typeof __require2 === "function" ? __require2 : (0, import_module.createRequire)(
|
|
30538
|
+
const requireFn = typeof __require2 === "function" ? __require2 : (0, import_module.createRequire)(path16.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
30410
30539
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
30411
30540
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
30412
30541
|
if (!CachedDatabaseSync) {
|
|
@@ -30537,20 +30666,20 @@ function shouldRestoreHostedRuntime(record2, managerTag) {
|
|
|
30537
30666
|
}
|
|
30538
30667
|
function isExplicitCommand(command) {
|
|
30539
30668
|
const trimmed = command.trim();
|
|
30540
|
-
return
|
|
30669
|
+
return path17.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
30541
30670
|
}
|
|
30542
30671
|
function expandExecutable(command) {
|
|
30543
30672
|
const trimmed = command.trim();
|
|
30544
|
-
return trimmed.startsWith("~") ?
|
|
30673
|
+
return trimmed.startsWith("~") ? path17.join(os13.homedir(), trimmed.slice(1)) : trimmed;
|
|
30545
30674
|
}
|
|
30546
30675
|
function commandExists(command) {
|
|
30547
30676
|
const trimmed = command.trim();
|
|
30548
30677
|
if (!trimmed) return false;
|
|
30549
30678
|
if (isExplicitCommand(trimmed)) {
|
|
30550
|
-
return (0,
|
|
30679
|
+
return (0, import_fs10.existsSync)(expandExecutable(trimmed));
|
|
30551
30680
|
}
|
|
30552
30681
|
try {
|
|
30553
|
-
(0,
|
|
30682
|
+
(0, import_child_process7.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
30554
30683
|
stdio: "ignore",
|
|
30555
30684
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
30556
30685
|
});
|
|
@@ -30969,7 +31098,7 @@ function getMacAppProcessPids(ideId) {
|
|
|
30969
31098
|
const appPaths = getIdePathCandidates(ideId);
|
|
30970
31099
|
if (appPaths.length === 0) return [];
|
|
30971
31100
|
try {
|
|
30972
|
-
const output = (0,
|
|
31101
|
+
const output = (0, import_child_process9.execSync)("ps axww -o pid=,args=", {
|
|
30973
31102
|
encoding: "utf-8",
|
|
30974
31103
|
timeout: 3e3,
|
|
30975
31104
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -31043,12 +31172,12 @@ async function killIdeProcess(ideId) {
|
|
|
31043
31172
|
try {
|
|
31044
31173
|
if (plat === "darwin" && appName) {
|
|
31045
31174
|
try {
|
|
31046
|
-
(0,
|
|
31175
|
+
(0, import_child_process9.execSync)(`osascript -e 'tell application "${escapeForAppleScript(appName)}" to quit' 2>/dev/null`, {
|
|
31047
31176
|
timeout: 5e3
|
|
31048
31177
|
});
|
|
31049
31178
|
} catch {
|
|
31050
31179
|
try {
|
|
31051
|
-
(0,
|
|
31180
|
+
(0, import_child_process9.execSync)(`pkill -x "${appName}" 2>/dev/null`, { timeout: 5e3 });
|
|
31052
31181
|
} catch {
|
|
31053
31182
|
}
|
|
31054
31183
|
}
|
|
@@ -31056,20 +31185,20 @@ async function killIdeProcess(ideId) {
|
|
|
31056
31185
|
} else if (plat === "win32" && winProcesses) {
|
|
31057
31186
|
for (const proc of winProcesses) {
|
|
31058
31187
|
try {
|
|
31059
|
-
(0,
|
|
31188
|
+
(0, import_child_process9.execSync)(`taskkill /IM "${proc}" /F 2>nul`, { timeout: 5e3 });
|
|
31060
31189
|
} catch {
|
|
31061
31190
|
}
|
|
31062
31191
|
}
|
|
31063
31192
|
try {
|
|
31064
31193
|
const exeName = winProcesses[0].replace(".exe", "");
|
|
31065
|
-
(0,
|
|
31194
|
+
(0, import_child_process9.execSync)(`powershell -Command "Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue | Stop-Process -Force"`, {
|
|
31066
31195
|
timeout: 1e4
|
|
31067
31196
|
});
|
|
31068
31197
|
} catch {
|
|
31069
31198
|
}
|
|
31070
31199
|
} else {
|
|
31071
31200
|
try {
|
|
31072
|
-
(0,
|
|
31201
|
+
(0, import_child_process9.execSync)(`pkill -f "${ideId}" 2>/dev/null`);
|
|
31073
31202
|
} catch {
|
|
31074
31203
|
}
|
|
31075
31204
|
}
|
|
@@ -31079,14 +31208,14 @@ async function killIdeProcess(ideId) {
|
|
|
31079
31208
|
}
|
|
31080
31209
|
if (plat === "darwin" && appName) {
|
|
31081
31210
|
try {
|
|
31082
|
-
(0,
|
|
31211
|
+
(0, import_child_process9.execSync)(`pkill -9 -x "${appName}" 2>/dev/null`, { timeout: 5e3 });
|
|
31083
31212
|
} catch {
|
|
31084
31213
|
}
|
|
31085
31214
|
killMacAppPathProcesses(ideId, "SIGKILL");
|
|
31086
31215
|
} else if (plat === "win32" && winProcesses) {
|
|
31087
31216
|
for (const proc of winProcesses) {
|
|
31088
31217
|
try {
|
|
31089
|
-
(0,
|
|
31218
|
+
(0, import_child_process9.execSync)(`taskkill /IM "${proc}" /F 2>nul`);
|
|
31090
31219
|
} catch {
|
|
31091
31220
|
}
|
|
31092
31221
|
}
|
|
@@ -31104,7 +31233,7 @@ function isIdeRunning(ideId) {
|
|
|
31104
31233
|
const appName = getMacAppIdentifiers()[ideId];
|
|
31105
31234
|
if (!appName) return getMacAppProcessPids(ideId).length > 0;
|
|
31106
31235
|
try {
|
|
31107
|
-
const result = (0,
|
|
31236
|
+
const result = (0, import_child_process9.execSync)(`pgrep -x "${appName}" 2>/dev/null`, {
|
|
31108
31237
|
encoding: "utf-8",
|
|
31109
31238
|
timeout: 3e3
|
|
31110
31239
|
});
|
|
@@ -31112,7 +31241,7 @@ function isIdeRunning(ideId) {
|
|
|
31112
31241
|
} catch {
|
|
31113
31242
|
}
|
|
31114
31243
|
try {
|
|
31115
|
-
const result = (0,
|
|
31244
|
+
const result = (0, import_child_process9.execSync)(
|
|
31116
31245
|
`osascript -e 'tell application "System Events" to count (every process whose name is "${escapeForAppleScript(appName)}")'`,
|
|
31117
31246
|
{
|
|
31118
31247
|
encoding: "utf-8",
|
|
@@ -31129,14 +31258,14 @@ function isIdeRunning(ideId) {
|
|
|
31129
31258
|
if (!winProcesses) return false;
|
|
31130
31259
|
for (const proc of winProcesses) {
|
|
31131
31260
|
try {
|
|
31132
|
-
const result = (0,
|
|
31261
|
+
const result = (0, import_child_process9.execSync)(`tasklist /FI "IMAGENAME eq ${proc}" /NH 2>nul`, { encoding: "utf-8" });
|
|
31133
31262
|
if (result.includes(proc)) return true;
|
|
31134
31263
|
} catch {
|
|
31135
31264
|
}
|
|
31136
31265
|
}
|
|
31137
31266
|
try {
|
|
31138
31267
|
const exeName = winProcesses[0].replace(".exe", "");
|
|
31139
|
-
const result = (0,
|
|
31268
|
+
const result = (0, import_child_process9.execSync)(
|
|
31140
31269
|
`powershell -Command "(Get-Process -Name '${exeName}' -ErrorAction SilentlyContinue).Count"`,
|
|
31141
31270
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
31142
31271
|
);
|
|
@@ -31145,7 +31274,7 @@ function isIdeRunning(ideId) {
|
|
|
31145
31274
|
}
|
|
31146
31275
|
return false;
|
|
31147
31276
|
} else {
|
|
31148
|
-
const result = (0,
|
|
31277
|
+
const result = (0, import_child_process9.execSync)(`pgrep -f "${ideId}" 2>/dev/null`, { encoding: "utf-8" });
|
|
31149
31278
|
return result.trim().length > 0;
|
|
31150
31279
|
}
|
|
31151
31280
|
} catch {
|
|
@@ -31158,7 +31287,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
31158
31287
|
try {
|
|
31159
31288
|
const appName = getMacAppIdentifiers()[ideId];
|
|
31160
31289
|
if (!appName) return void 0;
|
|
31161
|
-
const result = (0,
|
|
31290
|
+
const result = (0, import_child_process9.execSync)(
|
|
31162
31291
|
`lsof -c "${appName}" 2>/dev/null | grep cwd | head -1 | awk '{print $NF}'`,
|
|
31163
31292
|
{ encoding: "utf-8", timeout: 3e3 }
|
|
31164
31293
|
);
|
|
@@ -31172,8 +31301,8 @@ function detectCurrentWorkspace(ideId) {
|
|
|
31172
31301
|
const appNameMap = getMacAppIdentifiers();
|
|
31173
31302
|
const appName = appNameMap[ideId];
|
|
31174
31303
|
if (appName) {
|
|
31175
|
-
const storagePath =
|
|
31176
|
-
process.env.APPDATA ||
|
|
31304
|
+
const storagePath = path19.join(
|
|
31305
|
+
process.env.APPDATA || path19.join(os15.homedir(), "AppData", "Roaming"),
|
|
31177
31306
|
appName,
|
|
31178
31307
|
"storage.json"
|
|
31179
31308
|
);
|
|
@@ -31321,10 +31450,10 @@ async function launchMacOS(ide, port, workspace, newWindow) {
|
|
|
31321
31450
|
const canUseAppLauncher = !!appName;
|
|
31322
31451
|
const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
|
|
31323
31452
|
if (!useAppLauncher && ide.cliCommand) {
|
|
31324
|
-
(0,
|
|
31453
|
+
(0, import_child_process9.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
31325
31454
|
} else if (appName) {
|
|
31326
31455
|
const openArgs = ["-a", appName, "--args", ...args];
|
|
31327
|
-
(0,
|
|
31456
|
+
(0, import_child_process9.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
|
|
31328
31457
|
} else {
|
|
31329
31458
|
throw new Error(`No app identifier or CLI for ${ide.displayName}`);
|
|
31330
31459
|
}
|
|
@@ -31350,7 +31479,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
31350
31479
|
const args = ["--remote-debugging-port=" + port];
|
|
31351
31480
|
if (newWindow) args.push("--new-window");
|
|
31352
31481
|
if (workspace) args.push(workspace);
|
|
31353
|
-
(0,
|
|
31482
|
+
(0, import_child_process9.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
31354
31483
|
}
|
|
31355
31484
|
function getAvailableIdeIds() {
|
|
31356
31485
|
return getProviderLoader().getAvailableIdeTypes();
|
|
@@ -31378,7 +31507,7 @@ function checkRotation() {
|
|
|
31378
31507
|
const today = getDateStr2();
|
|
31379
31508
|
if (today !== currentDate2) {
|
|
31380
31509
|
currentDate2 = today;
|
|
31381
|
-
currentFile =
|
|
31510
|
+
currentFile = path20.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
31382
31511
|
cleanOldFiles();
|
|
31383
31512
|
}
|
|
31384
31513
|
}
|
|
@@ -31392,7 +31521,7 @@ function cleanOldFiles() {
|
|
|
31392
31521
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
31393
31522
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
31394
31523
|
try {
|
|
31395
|
-
fs8.unlinkSync(
|
|
31524
|
+
fs8.unlinkSync(path20.join(LOG_DIR2, file2));
|
|
31396
31525
|
} catch {
|
|
31397
31526
|
}
|
|
31398
31527
|
}
|
|
@@ -31482,8 +31611,8 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
31482
31611
|
}
|
|
31483
31612
|
const serverName = mcpConfig.serverName?.trim() || DEFAULT_SERVER_NAME;
|
|
31484
31613
|
if (mcpConfig.mode === "auto_import") {
|
|
31485
|
-
const
|
|
31486
|
-
if (!
|
|
31614
|
+
const path27 = mcpConfig.path?.trim();
|
|
31615
|
+
if (!path27) {
|
|
31487
31616
|
return { kind: "unsupported", reason: "Provider auto-import MCP config is missing a config path" };
|
|
31488
31617
|
}
|
|
31489
31618
|
const mcpServer = resolveAdhdevMcpServerLaunch({
|
|
@@ -31500,7 +31629,7 @@ function resolveMeshCoordinatorSetup(options) {
|
|
|
31500
31629
|
return {
|
|
31501
31630
|
kind: "auto_import",
|
|
31502
31631
|
serverName,
|
|
31503
|
-
configPath: (0, import_path4.join)(workspace,
|
|
31632
|
+
configPath: (0, import_path4.join)(workspace, path27),
|
|
31504
31633
|
configFormat: mcpConfig.format,
|
|
31505
31634
|
mcpServer
|
|
31506
31635
|
};
|
|
@@ -31577,8 +31706,8 @@ function resolveAdhdevMcpEntryPath(explicitPath) {
|
|
|
31577
31706
|
}
|
|
31578
31707
|
function normalizeExistingPath(filePath) {
|
|
31579
31708
|
try {
|
|
31580
|
-
if (!(0,
|
|
31581
|
-
return
|
|
31709
|
+
if (!(0, import_fs11.existsSync)(filePath)) return null;
|
|
31710
|
+
return import_fs11.realpathSync.native(filePath);
|
|
31582
31711
|
} catch {
|
|
31583
31712
|
return null;
|
|
31584
31713
|
}
|
|
@@ -31890,9 +32019,9 @@ function buildStatusSnapshot(options) {
|
|
|
31890
32019
|
}
|
|
31891
32020
|
function getUpgradeLogPath() {
|
|
31892
32021
|
const home = os18.homedir();
|
|
31893
|
-
const dir =
|
|
32022
|
+
const dir = path21.join(home, ".adhdev");
|
|
31894
32023
|
fs9.mkdirSync(dir, { recursive: true });
|
|
31895
|
-
return
|
|
32024
|
+
return path21.join(dir, "daemon-upgrade.log");
|
|
31896
32025
|
}
|
|
31897
32026
|
function appendUpgradeLog(message) {
|
|
31898
32027
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
@@ -31903,14 +32032,14 @@ function appendUpgradeLog(message) {
|
|
|
31903
32032
|
}
|
|
31904
32033
|
}
|
|
31905
32034
|
function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
|
|
31906
|
-
const binDir =
|
|
32035
|
+
const binDir = path21.dirname(nodeExecutable);
|
|
31907
32036
|
if (platform10 === "win32") {
|
|
31908
|
-
const npmCliPath =
|
|
32037
|
+
const npmCliPath = path21.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
31909
32038
|
if (fs9.existsSync(npmCliPath)) {
|
|
31910
32039
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
31911
32040
|
}
|
|
31912
32041
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
31913
|
-
const candidatePath =
|
|
32042
|
+
const candidatePath = path21.join(binDir, candidate);
|
|
31914
32043
|
if (fs9.existsSync(candidatePath)) {
|
|
31915
32044
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
31916
32045
|
}
|
|
@@ -31918,7 +32047,7 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
|
|
|
31918
32047
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
31919
32048
|
}
|
|
31920
32049
|
for (const candidate of ["npm"]) {
|
|
31921
|
-
const candidatePath =
|
|
32050
|
+
const candidatePath = path21.join(binDir, candidate);
|
|
31922
32051
|
if (fs9.existsSync(candidatePath)) {
|
|
31923
32052
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
31924
32053
|
}
|
|
@@ -31935,13 +32064,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
31935
32064
|
let currentDir = resolvedPath;
|
|
31936
32065
|
try {
|
|
31937
32066
|
if (fs9.statSync(resolvedPath).isFile()) {
|
|
31938
|
-
currentDir =
|
|
32067
|
+
currentDir = path21.dirname(resolvedPath);
|
|
31939
32068
|
}
|
|
31940
32069
|
} catch {
|
|
31941
|
-
currentDir =
|
|
32070
|
+
currentDir = path21.dirname(resolvedPath);
|
|
31942
32071
|
}
|
|
31943
32072
|
while (true) {
|
|
31944
|
-
const packageJsonPath =
|
|
32073
|
+
const packageJsonPath = path21.join(currentDir, "package.json");
|
|
31945
32074
|
try {
|
|
31946
32075
|
if (fs9.existsSync(packageJsonPath)) {
|
|
31947
32076
|
const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -31952,7 +32081,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
31952
32081
|
}
|
|
31953
32082
|
} catch {
|
|
31954
32083
|
}
|
|
31955
|
-
const parentDir =
|
|
32084
|
+
const parentDir = path21.dirname(currentDir);
|
|
31956
32085
|
if (parentDir === currentDir) {
|
|
31957
32086
|
return null;
|
|
31958
32087
|
}
|
|
@@ -31960,13 +32089,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
31960
32089
|
}
|
|
31961
32090
|
}
|
|
31962
32091
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
31963
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
31964
|
-
if (
|
|
32092
|
+
const nodeModulesDir = packageName.startsWith("@") ? path21.dirname(path21.dirname(packageRoot)) : path21.dirname(packageRoot);
|
|
32093
|
+
if (path21.basename(nodeModulesDir) !== "node_modules") {
|
|
31965
32094
|
return null;
|
|
31966
32095
|
}
|
|
31967
|
-
const maybeLibDir =
|
|
31968
|
-
if (
|
|
31969
|
-
return
|
|
32096
|
+
const maybeLibDir = path21.dirname(nodeModulesDir);
|
|
32097
|
+
if (path21.basename(maybeLibDir) === "lib") {
|
|
32098
|
+
return path21.dirname(maybeLibDir);
|
|
31970
32099
|
}
|
|
31971
32100
|
return maybeLibDir;
|
|
31972
32101
|
}
|
|
@@ -32002,7 +32131,7 @@ function getNpmExecOptions(platform10 = process.platform) {
|
|
|
32002
32131
|
}
|
|
32003
32132
|
function execNpmCommandSync(args, options = {}, surface) {
|
|
32004
32133
|
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
32005
|
-
return (0,
|
|
32134
|
+
return (0, import_child_process10.execFileSync)(
|
|
32006
32135
|
surface?.npmExecutable || "npm",
|
|
32007
32136
|
[...surface?.npmArgsPrefix || [], ...args],
|
|
32008
32137
|
{
|
|
@@ -32015,7 +32144,7 @@ function execNpmCommandSync(args, options = {}, surface) {
|
|
|
32015
32144
|
function killPid(pid) {
|
|
32016
32145
|
try {
|
|
32017
32146
|
if (process.platform === "win32") {
|
|
32018
|
-
(0,
|
|
32147
|
+
(0, import_child_process10.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
32019
32148
|
} else {
|
|
32020
32149
|
process.kill(pid, "SIGTERM");
|
|
32021
32150
|
}
|
|
@@ -32027,7 +32156,7 @@ function killPid(pid) {
|
|
|
32027
32156
|
function getWindowsProcessCommandLine(pid) {
|
|
32028
32157
|
const pidFilter = `ProcessId=${pid}`;
|
|
32029
32158
|
try {
|
|
32030
|
-
const psOut = (0,
|
|
32159
|
+
const psOut = (0, import_child_process10.execFileSync)("powershell.exe", [
|
|
32031
32160
|
"-NoProfile",
|
|
32032
32161
|
"-NonInteractive",
|
|
32033
32162
|
"-ExecutionPolicy",
|
|
@@ -32039,7 +32168,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
32039
32168
|
} catch {
|
|
32040
32169
|
}
|
|
32041
32170
|
try {
|
|
32042
|
-
const wmicOut = (0,
|
|
32171
|
+
const wmicOut = (0, import_child_process10.execFileSync)("wmic", [
|
|
32043
32172
|
"process",
|
|
32044
32173
|
"where",
|
|
32045
32174
|
pidFilter,
|
|
@@ -32055,7 +32184,7 @@ function getProcessCommandLine(pid) {
|
|
|
32055
32184
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
32056
32185
|
if (process.platform === "win32") return getWindowsProcessCommandLine(pid);
|
|
32057
32186
|
try {
|
|
32058
|
-
const text = (0,
|
|
32187
|
+
const text = (0, import_child_process10.execFileSync)("ps", ["-o", "command=", "-p", String(pid)], {
|
|
32059
32188
|
encoding: "utf8",
|
|
32060
32189
|
timeout: 3e3,
|
|
32061
32190
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -32081,7 +32210,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
32081
32210
|
}
|
|
32082
32211
|
}
|
|
32083
32212
|
function stopSessionHostProcesses(appName) {
|
|
32084
|
-
const pidFile =
|
|
32213
|
+
const pidFile = path21.join(os18.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
32085
32214
|
try {
|
|
32086
32215
|
if (fs9.existsSync(pidFile)) {
|
|
32087
32216
|
const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
|
|
@@ -32098,7 +32227,7 @@ function stopSessionHostProcesses(appName) {
|
|
|
32098
32227
|
}
|
|
32099
32228
|
}
|
|
32100
32229
|
function removeDaemonPidFile() {
|
|
32101
|
-
const pidFile =
|
|
32230
|
+
const pidFile = path21.join(os18.homedir(), ".adhdev", "daemon.pid");
|
|
32102
32231
|
try {
|
|
32103
32232
|
fs9.unlinkSync(pidFile);
|
|
32104
32233
|
} catch {
|
|
@@ -32109,7 +32238,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
32109
32238
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
32110
32239
|
if (!npmRoot) return;
|
|
32111
32240
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
32112
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
32241
|
+
const binDir = process.platform === "win32" ? npmPrefix : path21.join(npmPrefix, "bin");
|
|
32113
32242
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
32114
32243
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
32115
32244
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -32117,31 +32246,31 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
32117
32246
|
}
|
|
32118
32247
|
if (pkgName.startsWith("@")) {
|
|
32119
32248
|
const [scope, name] = pkgName.split("/");
|
|
32120
|
-
const scopeDir =
|
|
32249
|
+
const scopeDir = path21.join(npmRoot, scope);
|
|
32121
32250
|
if (!fs9.existsSync(scopeDir)) return;
|
|
32122
32251
|
for (const entry of fs9.readdirSync(scopeDir)) {
|
|
32123
32252
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
32124
|
-
fs9.rmSync(
|
|
32125
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
32253
|
+
fs9.rmSync(path21.join(scopeDir, entry), { recursive: true, force: true });
|
|
32254
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path21.join(scopeDir, entry)}`);
|
|
32126
32255
|
}
|
|
32127
32256
|
} else {
|
|
32128
32257
|
for (const entry of fs9.readdirSync(npmRoot)) {
|
|
32129
32258
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
32130
|
-
fs9.rmSync(
|
|
32131
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
32259
|
+
fs9.rmSync(path21.join(npmRoot, entry), { recursive: true, force: true });
|
|
32260
|
+
appendUpgradeLog(`Removed stale staging dir: ${path21.join(npmRoot, entry)}`);
|
|
32132
32261
|
}
|
|
32133
32262
|
}
|
|
32134
32263
|
if (fs9.existsSync(binDir)) {
|
|
32135
32264
|
for (const entry of fs9.readdirSync(binDir)) {
|
|
32136
32265
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
32137
|
-
fs9.rmSync(
|
|
32138
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
32266
|
+
fs9.rmSync(path21.join(binDir, entry), { recursive: true, force: true });
|
|
32267
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path21.join(binDir, entry)}`);
|
|
32139
32268
|
}
|
|
32140
32269
|
}
|
|
32141
32270
|
}
|
|
32142
32271
|
function spawnDetachedDaemonUpgradeHelper(payload) {
|
|
32143
32272
|
const env2 = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
|
|
32144
|
-
const child = (0,
|
|
32273
|
+
const child = (0, import_child_process11.spawn)(process.execPath, process.argv.slice(1), {
|
|
32145
32274
|
detached: true,
|
|
32146
32275
|
stdio: "ignore",
|
|
32147
32276
|
windowsHide: true,
|
|
@@ -32171,7 +32300,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
32171
32300
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
32172
32301
|
const spec = `${payload.packageName}@${payload.targetVersion || "latest"}`;
|
|
32173
32302
|
appendUpgradeLog(`Installing ${spec}`);
|
|
32174
|
-
const installOutput = (0,
|
|
32303
|
+
const installOutput = (0, import_child_process10.execFileSync)(
|
|
32175
32304
|
installCommand.command,
|
|
32176
32305
|
installCommand.args,
|
|
32177
32306
|
{
|
|
@@ -32193,7 +32322,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
32193
32322
|
const env2 = { ...process.env };
|
|
32194
32323
|
delete env2[UPGRADE_HELPER_ENV];
|
|
32195
32324
|
appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
|
|
32196
|
-
const child = (0,
|
|
32325
|
+
const child = (0, import_child_process11.spawn)(process.execPath, restartArgv, {
|
|
32197
32326
|
detached: true,
|
|
32198
32327
|
stdio: "ignore",
|
|
32199
32328
|
windowsHide: true,
|
|
@@ -32493,7 +32622,7 @@ function projectHotChatSessionStatesFromProviderState(state) {
|
|
|
32493
32622
|
}
|
|
32494
32623
|
function runCommand(cmd, timeout = 1e4) {
|
|
32495
32624
|
try {
|
|
32496
|
-
return (0,
|
|
32625
|
+
return (0, import_child_process12.execSync)(cmd, {
|
|
32497
32626
|
encoding: "utf-8",
|
|
32498
32627
|
timeout,
|
|
32499
32628
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -32542,7 +32671,7 @@ function checkPathExists2(paths) {
|
|
|
32542
32671
|
for (const p of paths) {
|
|
32543
32672
|
if (p.includes("*")) {
|
|
32544
32673
|
const home = os19.homedir();
|
|
32545
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
32674
|
+
const resolved = p.replace(/\*/g, home.split(path222.sep).pop() || "");
|
|
32546
32675
|
if (fs11.existsSync(resolved)) return resolved;
|
|
32547
32676
|
} else {
|
|
32548
32677
|
if (fs11.existsSync(p)) return p;
|
|
@@ -32552,7 +32681,7 @@ function checkPathExists2(paths) {
|
|
|
32552
32681
|
}
|
|
32553
32682
|
function getMacAppVersion(appPath) {
|
|
32554
32683
|
if ((0, import_os4.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
32555
|
-
const plistPath =
|
|
32684
|
+
const plistPath = path222.join(appPath, "Contents", "Info.plist");
|
|
32556
32685
|
if (!fs11.existsSync(plistPath)) return null;
|
|
32557
32686
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
32558
32687
|
return raw || null;
|
|
@@ -32578,7 +32707,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
32578
32707
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
32579
32708
|
let resolvedBin = cliBin;
|
|
32580
32709
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
32581
|
-
const bundled =
|
|
32710
|
+
const bundled = path222.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
32582
32711
|
if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
|
|
32583
32712
|
}
|
|
32584
32713
|
info.installed = !!(appPath || resolvedBin);
|
|
@@ -33133,17 +33262,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
33133
33262
|
return;
|
|
33134
33263
|
}
|
|
33135
33264
|
let scriptsPath = "";
|
|
33136
|
-
const directScripts =
|
|
33265
|
+
const directScripts = path23.join(dir, "scripts.js");
|
|
33137
33266
|
if (fs12.existsSync(directScripts)) {
|
|
33138
33267
|
scriptsPath = directScripts;
|
|
33139
33268
|
} else {
|
|
33140
|
-
const scriptsDir =
|
|
33269
|
+
const scriptsDir = path23.join(dir, "scripts");
|
|
33141
33270
|
if (fs12.existsSync(scriptsDir)) {
|
|
33142
33271
|
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
33143
|
-
return fs12.statSync(
|
|
33272
|
+
return fs12.statSync(path23.join(scriptsDir, d)).isDirectory();
|
|
33144
33273
|
}).sort().reverse();
|
|
33145
33274
|
for (const ver of versions) {
|
|
33146
|
-
const p =
|
|
33275
|
+
const p = path23.join(scriptsDir, ver, "scripts.js");
|
|
33147
33276
|
if (fs12.existsSync(p)) {
|
|
33148
33277
|
scriptsPath = p;
|
|
33149
33278
|
break;
|
|
@@ -33978,11 +34107,11 @@ function getCliFixtureDir(ctx, type) {
|
|
|
33978
34107
|
if (!providerDir) {
|
|
33979
34108
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
33980
34109
|
}
|
|
33981
|
-
return
|
|
34110
|
+
return path24.join(providerDir, "fixtures");
|
|
33982
34111
|
}
|
|
33983
34112
|
function readCliFixture(ctx, type, name) {
|
|
33984
34113
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
33985
|
-
const filePath =
|
|
34114
|
+
const filePath = path24.join(fixtureDir, `${name}.json`);
|
|
33986
34115
|
if (!fs13.existsSync(filePath)) {
|
|
33987
34116
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
33988
34117
|
}
|
|
@@ -34749,7 +34878,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
34749
34878
|
},
|
|
34750
34879
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
34751
34880
|
};
|
|
34752
|
-
const filePath =
|
|
34881
|
+
const filePath = path24.join(fixtureDir, `${name}.json`);
|
|
34753
34882
|
fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
34754
34883
|
ctx.json(res, 200, {
|
|
34755
34884
|
saved: true,
|
|
@@ -34773,7 +34902,7 @@ async function handleCliFixtureList(ctx, type, _req, res) {
|
|
|
34773
34902
|
return;
|
|
34774
34903
|
}
|
|
34775
34904
|
const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
34776
|
-
const fullPath =
|
|
34905
|
+
const fullPath = path24.join(fixtureDir, file2);
|
|
34777
34906
|
try {
|
|
34778
34907
|
const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
|
|
34779
34908
|
return {
|
|
@@ -34954,22 +35083,22 @@ function getLatestScriptVersionDir(scriptsDir) {
|
|
|
34954
35083
|
if (!fs14.existsSync(scriptsDir)) return null;
|
|
34955
35084
|
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
34956
35085
|
try {
|
|
34957
|
-
return fs14.statSync(
|
|
35086
|
+
return fs14.statSync(path25.join(scriptsDir, d)).isDirectory();
|
|
34958
35087
|
} catch {
|
|
34959
35088
|
return false;
|
|
34960
35089
|
}
|
|
34961
35090
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
34962
35091
|
if (versions.length === 0) return null;
|
|
34963
|
-
return
|
|
35092
|
+
return path25.join(scriptsDir, versions[0]);
|
|
34964
35093
|
}
|
|
34965
35094
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
34966
|
-
const canonicalUserDir =
|
|
34967
|
-
const desiredDir = requestedDir ?
|
|
34968
|
-
const upstreamRoot =
|
|
34969
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
35095
|
+
const canonicalUserDir = path25.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
35096
|
+
const desiredDir = requestedDir ? path25.resolve(requestedDir) : canonicalUserDir;
|
|
35097
|
+
const upstreamRoot = path25.resolve(ctx.providerLoader.getUpstreamDir());
|
|
35098
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path25.sep}`)) {
|
|
34970
35099
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
34971
35100
|
}
|
|
34972
|
-
if (
|
|
35101
|
+
if (path25.basename(desiredDir) !== type) {
|
|
34973
35102
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
34974
35103
|
}
|
|
34975
35104
|
const sourceDir = ctx.findProviderDir(type);
|
|
@@ -34977,11 +35106,11 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
34977
35106
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
34978
35107
|
}
|
|
34979
35108
|
if (!fs14.existsSync(desiredDir)) {
|
|
34980
|
-
fs14.mkdirSync(
|
|
35109
|
+
fs14.mkdirSync(path25.dirname(desiredDir), { recursive: true });
|
|
34981
35110
|
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
34982
35111
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
34983
35112
|
}
|
|
34984
|
-
const providerJson =
|
|
35113
|
+
const providerJson = path25.join(desiredDir, "provider.json");
|
|
34985
35114
|
if (!fs14.existsSync(providerJson)) {
|
|
34986
35115
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
34987
35116
|
}
|
|
@@ -34992,13 +35121,13 @@ function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
|
34992
35121
|
const refDir = ctx.findProviderDir(referenceType);
|
|
34993
35122
|
if (!refDir || !fs14.existsSync(refDir)) return {};
|
|
34994
35123
|
const referenceScripts = {};
|
|
34995
|
-
const scriptsDir =
|
|
35124
|
+
const scriptsDir = path25.join(refDir, "scripts");
|
|
34996
35125
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
34997
35126
|
if (!latestDir) return referenceScripts;
|
|
34998
35127
|
for (const file2 of fs14.readdirSync(latestDir)) {
|
|
34999
35128
|
if (!file2.endsWith(".js")) continue;
|
|
35000
35129
|
try {
|
|
35001
|
-
referenceScripts[file2] = fs14.readFileSync(
|
|
35130
|
+
referenceScripts[file2] = fs14.readFileSync(path25.join(latestDir, file2), "utf-8");
|
|
35002
35131
|
} catch {
|
|
35003
35132
|
}
|
|
35004
35133
|
}
|
|
@@ -35106,9 +35235,9 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
35106
35235
|
});
|
|
35107
35236
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
35108
35237
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
35109
|
-
const tmpDir =
|
|
35238
|
+
const tmpDir = path25.join(os20.tmpdir(), "adhdev-autoimpl");
|
|
35110
35239
|
if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
|
|
35111
|
-
const promptFile =
|
|
35240
|
+
const promptFile = path25.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
35112
35241
|
fs14.writeFileSync(promptFile, prompt, "utf-8");
|
|
35113
35242
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
35114
35243
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
@@ -35540,7 +35669,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
35540
35669
|
setMode: "set_mode.js"
|
|
35541
35670
|
};
|
|
35542
35671
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
35543
|
-
const scriptsDir =
|
|
35672
|
+
const scriptsDir = path25.join(providerDir, "scripts");
|
|
35544
35673
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
35545
35674
|
if (latestScriptsDir) {
|
|
35546
35675
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -35551,7 +35680,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
35551
35680
|
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
35552
35681
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
35553
35682
|
try {
|
|
35554
|
-
const content = fs14.readFileSync(
|
|
35683
|
+
const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
|
|
35555
35684
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
35556
35685
|
lines.push("```javascript");
|
|
35557
35686
|
lines.push(content);
|
|
@@ -35568,7 +35697,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
35568
35697
|
lines.push("");
|
|
35569
35698
|
for (const file2 of refFiles) {
|
|
35570
35699
|
try {
|
|
35571
|
-
const content = fs14.readFileSync(
|
|
35700
|
+
const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
|
|
35572
35701
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
35573
35702
|
lines.push("```javascript");
|
|
35574
35703
|
lines.push(content);
|
|
@@ -35609,10 +35738,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
35609
35738
|
lines.push("");
|
|
35610
35739
|
}
|
|
35611
35740
|
}
|
|
35612
|
-
const docsDir =
|
|
35741
|
+
const docsDir = path25.join(providerDir, "../../docs");
|
|
35613
35742
|
const loadGuide = (name) => {
|
|
35614
35743
|
try {
|
|
35615
|
-
const p =
|
|
35744
|
+
const p = path25.join(docsDir, name);
|
|
35616
35745
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
35617
35746
|
} catch {
|
|
35618
35747
|
}
|
|
@@ -35849,7 +35978,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
35849
35978
|
parseApproval: "parse_approval.js"
|
|
35850
35979
|
};
|
|
35851
35980
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
35852
|
-
const scriptsDir =
|
|
35981
|
+
const scriptsDir = path25.join(providerDir, "scripts");
|
|
35853
35982
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
35854
35983
|
if (latestScriptsDir) {
|
|
35855
35984
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -35861,7 +35990,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
35861
35990
|
if (!file2.endsWith(".js")) continue;
|
|
35862
35991
|
if (!targetFileNames.has(file2)) continue;
|
|
35863
35992
|
try {
|
|
35864
|
-
const content = fs14.readFileSync(
|
|
35993
|
+
const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
|
|
35865
35994
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
35866
35995
|
lines.push("```javascript");
|
|
35867
35996
|
lines.push(content);
|
|
@@ -35877,7 +36006,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
35877
36006
|
lines.push("");
|
|
35878
36007
|
for (const file2 of refFiles) {
|
|
35879
36008
|
try {
|
|
35880
|
-
const content = fs14.readFileSync(
|
|
36009
|
+
const content = fs14.readFileSync(path25.join(latestScriptsDir, file2), "utf-8");
|
|
35881
36010
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
35882
36011
|
lines.push("```javascript");
|
|
35883
36012
|
lines.push(content);
|
|
@@ -35910,10 +36039,10 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
35910
36039
|
lines.push("");
|
|
35911
36040
|
}
|
|
35912
36041
|
}
|
|
35913
|
-
const docsDir =
|
|
36042
|
+
const docsDir = path25.join(providerDir, "../../docs");
|
|
35914
36043
|
const loadGuide = (name) => {
|
|
35915
36044
|
try {
|
|
35916
|
-
const p =
|
|
36045
|
+
const p = path25.join(docsDir, name);
|
|
35917
36046
|
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
35918
36047
|
} catch {
|
|
35919
36048
|
}
|
|
@@ -36353,7 +36482,7 @@ function shouldAutoRestoreHostedSessionsOnStartup(env2 = process.env) {
|
|
|
36353
36482
|
function isExtensionInstalled(ide, marketplaceId) {
|
|
36354
36483
|
if (!ide.cliCommand) return false;
|
|
36355
36484
|
try {
|
|
36356
|
-
const result = (0,
|
|
36485
|
+
const result = (0, import_child_process13.execSync)(`"${ide.cliCommand}" --list-extensions`, {
|
|
36357
36486
|
encoding: "utf-8",
|
|
36358
36487
|
timeout: 15e3,
|
|
36359
36488
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -36394,7 +36523,7 @@ async function installExtension(ide, extension) {
|
|
|
36394
36523
|
fs16.writeFileSync(vsixPath, buffer);
|
|
36395
36524
|
return new Promise((resolve162) => {
|
|
36396
36525
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
36397
|
-
(0,
|
|
36526
|
+
(0, import_child_process13.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
36398
36527
|
resolve162({
|
|
36399
36528
|
extensionId: extension.id,
|
|
36400
36529
|
marketplaceId: extension.marketplaceId,
|
|
@@ -36410,7 +36539,7 @@ async function installExtension(ide, extension) {
|
|
|
36410
36539
|
}
|
|
36411
36540
|
return new Promise((resolve162) => {
|
|
36412
36541
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
36413
|
-
(0,
|
|
36542
|
+
(0, import_child_process13.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
|
|
36414
36543
|
if (error48) {
|
|
36415
36544
|
resolve162({
|
|
36416
36545
|
extensionId: extension.id,
|
|
@@ -36447,7 +36576,7 @@ function launchIDE(ide, workspacePath) {
|
|
|
36447
36576
|
if (!ide.cliCommand) return false;
|
|
36448
36577
|
try {
|
|
36449
36578
|
const args = workspacePath ? `"${workspacePath}"` : "";
|
|
36450
|
-
(0,
|
|
36579
|
+
(0, import_child_process13.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
|
|
36451
36580
|
return true;
|
|
36452
36581
|
} catch {
|
|
36453
36582
|
return false;
|
|
@@ -36716,121 +36845,126 @@ async function shutdownDaemonComponents(components) {
|
|
|
36716
36845
|
}
|
|
36717
36846
|
cdpManagers.clear();
|
|
36718
36847
|
}
|
|
36719
|
-
var import_os2, import_path,
|
|
36848
|
+
var path4, import_promises4, import_fs3, import_child_process, import_util3, import_os2, import_path, import_fs4, import_crypto2, import_fs5, import_path2, import_crypto3, fs2, path10, os4, os8, os9, path14, import_child_process2, os10, path15, os11, import_child_process3, import_fs6, import_promises5, path, import_util4, import_promises6, path22, path32, fs, os5, path5, import_crypto4, path6, path7, import_fs7, import_path3, import_child_process4, import_fs8, import_os3, path8, import_child_process5, os22, path9, import_fs9, os32, import_child_process6, http, crypto2, fs3, path11, os52, fs4, os6, path12, import_crypto5, fs5, path13, os7, os13, path17, crypto4, import_fs10, import_child_process7, os12, path16, crypto3, fs6, import_module, import_stream2, import_child_process8, import_child_process9, net2, os15, path19, fs7, path18, os14, fs8, path20, os16, import_fs11, import_module2, import_path4, os17, import_child_process10, import_child_process11, fs9, os18, path21, fs10, fs11, path222, os19, import_child_process12, import_os4, http2, fs15, path26, fs12, path23, fs13, path24, fs14, path25, os20, import_child_process13, __defProp2, __getOwnPropDesc2, __getOwnPropNames2, __hasOwnProp2, __require2, __esm2, __export2, __copyProps2, __toCommonJS2, DEFAULT_MESH_POLICY, init_repo_mesh_types, git_worktree_exports, execFileAsync2, WORKTREE_DIR_NAME, GIT_TIMEOUT_MS, GIT_MAX_BUFFER, init_git_worktree, config_exports, DEFAULT_CONFIG, MACHINE_ID_PREFIX, init_config, mesh_config_exports, init_mesh_config, coordinator_prompt_exports, TOOLS_SECTION, WORKFLOW_SECTION, init_coordinator_prompt, LEVEL_NUM, LEVEL_LABEL, currentLevel, LOG_DIR, MAX_LOG_SIZE, MAX_LOG_DAYS, currentDate, currentLogFile, writeCount, RING_BUFFER_SIZE, ringBuffer, origConsoleLog, origConsoleError, origConsoleWarn, LOG, interceptorInstalled, LOG_PATH, init_logger, NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig, init_debug_config, DEFAULT_BINDING_CANDIDATES, cachedBinding, cachedBindingError, GhosttyVtTerminalBackend, init_ghostty_vt_backend, TerminalCtor, XtermTerminalBackend, init_xterm_backend, DEFAULT_SCROLLBACK, loggedTerminalBackends, TerminalScreen, init_terminal_screen, init_spawn_env, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory, init_pty_transport, buildCliSpawnEnv, init_provider_cli_shared, init_provider_cli_parse, init_provider_cli_config, init_provider_cli_runtime, provider_cli_adapter_exports, ProviderCliAdapter, init_provider_cli_adapter, execFileAsync, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BUFFER, GitCommandError, DEFAULT_MAX_FILES, DEFAULT_MAX_BYTES, summarizeGitStatus, InMemoryGitSnapshotStore, DEFAULT_GIT_WORKSPACE_POLL_INTERVAL_MS, MIN_GIT_WORKSPACE_POLL_INTERVAL_MS, GitWorkspaceMonitor, GIT_COMMAND_NAMES, SNAPSHOT_REASONS, FAILURE_REASONS, defaultSnapshotStore, defaultGitCommandServices, BUSY_STATUSES, TERMINAL_STATUSES, TurnSnapshotTracker, MAX_WORKSPACES, MAX_ACTIVITY, MAX_SAVED_SESSIONS, DEFAULT_STATE, BUILTIN_IDE_DEFINITIONS, registeredIDEs, LIVE_LIFECYCLES, DEFAULT_ACTIVE_CHAT_POLL_STATUSES, DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS, LIVE_RUNTIME_LIFECYCLES, DaemonCdpManager, CdpDomHandlers, DEFAULT_MONITOR_CONFIG, StatusMonitor, BUILTIN_CHAT_MESSAGE_KINDS, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, ChatHistoryWriter, IDE_PROVIDER_SESSION_CAPABILITIES_BASE, EXTENSION_PROVIDER_SESSION_CAPABILITIES_BASE, ExtensionProviderInstance, VALID_STATUSES, VALID_ROLES, VALID_BUBBLE_STATES, VALID_TURN_STATUSES, DEFAULT_APPROVAL_POSITIVE_HINTS, IdeProviderInstance, DEFAULT_CDP_SCAN_INTERVAL_MS, DEFAULT_CDP_DISCOVERY_INTERVAL_MS, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS, MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_READY_TIMEOUT_MS, STANDALONE_CDP_SCAN_INTERVAL_MS, DaemonCdpScanner, DaemonCdpInitializer, WORKING_STATUSES, FULL_STATUS_ACTIVE_CHAT_OPTIONS, LIVE_STATUS_ACTIVE_CHAT_OPTIONS, STATUS_MODAL_MESSAGE_LIMIT, STATUS_MODAL_BUTTON_LIMIT, IDE_SESSION_CAPABILITIES, EXTENSION_SESSION_CAPABILITIES, PTY_SESSION_CAPABILITIES, CLI_CHAT_SESSION_CAPABILITIES, ACP_SESSION_CAPABILITIES, VALID_INPUT_MEDIA_TYPES, globalStore, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN, KEY_TO_VK, COMMAND_DEBUG_LEVELS, DaemonCommandHandler, CachedDatabaseSync, CliProviderInstance, AcpProviderInstance, chalkModule, chalkApi, DaemonCliManager, VALID_CAPABILITY_MEDIA_TYPES, KNOWN_PROVIDER_FIELDS, VALUE_CONTROL_TYPES, ProviderLoader, _providerLoader, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS, DEFAULT_SERVER_NAME, DEFAULT_ADHDEV_MCP_COMMAND, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession, UPGRADE_HELPER_ENV, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter, DaemonStatusReporter, DEFAULT_DAEMON_PORT, DAEMON_WS_PATH, ProviderStreamAdapter, DaemonAgentStreamManager, AgentStreamPoller, ProviderInstanceManager, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive, DEV_SERVER_PORT, DevServer, SessionHostRuntimeTransport, SessionHostPtyTransportFactory, DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME, STARTUP_TIMEOUT_MS, STARTUP_POLL_MS, EXTENSION_CATALOG, SessionRegistry;
|
|
36720
36849
|
var init_dist2 = __esm({
|
|
36721
36850
|
"../daemon-core/dist/index.mjs"() {
|
|
36722
36851
|
"use strict";
|
|
36852
|
+
path4 = __toESM(require("path"), 1);
|
|
36853
|
+
import_promises4 = require("fs/promises");
|
|
36854
|
+
import_fs3 = require("fs");
|
|
36855
|
+
import_child_process = require("child_process");
|
|
36856
|
+
import_util3 = require("util");
|
|
36723
36857
|
import_os2 = require("os");
|
|
36724
36858
|
import_path = require("path");
|
|
36725
|
-
import_fs3 = require("fs");
|
|
36726
|
-
import_crypto2 = require("crypto");
|
|
36727
36859
|
import_fs4 = require("fs");
|
|
36860
|
+
import_crypto2 = require("crypto");
|
|
36861
|
+
import_fs5 = require("fs");
|
|
36728
36862
|
import_path2 = require("path");
|
|
36729
36863
|
import_crypto3 = require("crypto");
|
|
36730
36864
|
fs2 = __toESM(require("fs"), 1);
|
|
36731
|
-
|
|
36865
|
+
path10 = __toESM(require("path"), 1);
|
|
36732
36866
|
os4 = __toESM(require("os"), 1);
|
|
36733
36867
|
init_dist();
|
|
36734
36868
|
os8 = __toESM(require("os"), 1);
|
|
36735
36869
|
os9 = __toESM(require("os"), 1);
|
|
36736
|
-
path13 = __toESM(require("path"), 1);
|
|
36737
|
-
import_child_process = require("child_process");
|
|
36738
|
-
os10 = __toESM(require("os"), 1);
|
|
36739
36870
|
path14 = __toESM(require("path"), 1);
|
|
36871
|
+
import_child_process2 = require("child_process");
|
|
36872
|
+
os10 = __toESM(require("os"), 1);
|
|
36873
|
+
path15 = __toESM(require("path"), 1);
|
|
36740
36874
|
init_dist();
|
|
36741
36875
|
os11 = __toESM(require("os"), 1);
|
|
36742
|
-
|
|
36743
|
-
|
|
36744
|
-
import_promises4 = require("fs/promises");
|
|
36745
|
-
path = __toESM(require("path"), 1);
|
|
36746
|
-
import_util3 = require("util");
|
|
36876
|
+
import_child_process3 = require("child_process");
|
|
36877
|
+
import_fs6 = require("fs");
|
|
36747
36878
|
import_promises5 = require("fs/promises");
|
|
36879
|
+
path = __toESM(require("path"), 1);
|
|
36880
|
+
import_util4 = require("util");
|
|
36881
|
+
import_promises6 = require("fs/promises");
|
|
36748
36882
|
path22 = __toESM(require("path"), 1);
|
|
36749
36883
|
path32 = __toESM(require("path"), 1);
|
|
36750
36884
|
fs = __toESM(require("fs"), 1);
|
|
36751
36885
|
os5 = __toESM(require("os"), 1);
|
|
36752
|
-
path4 = __toESM(require("path"), 1);
|
|
36753
|
-
import_crypto4 = require("crypto");
|
|
36754
36886
|
path5 = __toESM(require("path"), 1);
|
|
36887
|
+
import_crypto4 = require("crypto");
|
|
36755
36888
|
path6 = __toESM(require("path"), 1);
|
|
36756
|
-
import_fs6 = require("fs");
|
|
36757
|
-
import_path3 = require("path");
|
|
36758
|
-
import_child_process3 = require("child_process");
|
|
36759
|
-
import_fs7 = require("fs");
|
|
36760
|
-
import_os3 = require("os");
|
|
36761
36889
|
path7 = __toESM(require("path"), 1);
|
|
36890
|
+
import_fs7 = require("fs");
|
|
36891
|
+
import_path3 = require("path");
|
|
36762
36892
|
import_child_process4 = require("child_process");
|
|
36763
|
-
os22 = __toESM(require("os"), 1);
|
|
36764
|
-
path8 = __toESM(require("path"), 1);
|
|
36765
36893
|
import_fs8 = require("fs");
|
|
36766
|
-
|
|
36894
|
+
import_os3 = require("os");
|
|
36895
|
+
path8 = __toESM(require("path"), 1);
|
|
36767
36896
|
import_child_process5 = require("child_process");
|
|
36897
|
+
os22 = __toESM(require("os"), 1);
|
|
36898
|
+
path9 = __toESM(require("path"), 1);
|
|
36899
|
+
import_fs9 = require("fs");
|
|
36900
|
+
os32 = __toESM(require("os"), 1);
|
|
36901
|
+
import_child_process6 = require("child_process");
|
|
36768
36902
|
init_wrapper();
|
|
36769
36903
|
http = __toESM(require("http"), 1);
|
|
36770
36904
|
crypto2 = __toESM(require("crypto"), 1);
|
|
36771
36905
|
fs3 = __toESM(require("fs"), 1);
|
|
36772
|
-
|
|
36906
|
+
path11 = __toESM(require("path"), 1);
|
|
36773
36907
|
os52 = __toESM(require("os"), 1);
|
|
36774
36908
|
fs4 = __toESM(require("fs"), 1);
|
|
36775
36909
|
os6 = __toESM(require("os"), 1);
|
|
36776
|
-
|
|
36910
|
+
path12 = __toESM(require("path"), 1);
|
|
36777
36911
|
import_crypto5 = require("crypto");
|
|
36778
36912
|
fs5 = __toESM(require("fs"), 1);
|
|
36779
|
-
|
|
36913
|
+
path13 = __toESM(require("path"), 1);
|
|
36780
36914
|
os7 = __toESM(require("os"), 1);
|
|
36781
36915
|
os13 = __toESM(require("os"), 1);
|
|
36782
|
-
|
|
36916
|
+
path17 = __toESM(require("path"), 1);
|
|
36783
36917
|
crypto4 = __toESM(require("crypto"), 1);
|
|
36784
|
-
|
|
36785
|
-
|
|
36918
|
+
import_fs10 = require("fs");
|
|
36919
|
+
import_child_process7 = require("child_process");
|
|
36786
36920
|
init_source();
|
|
36787
36921
|
os12 = __toESM(require("os"), 1);
|
|
36788
|
-
|
|
36922
|
+
path16 = __toESM(require("path"), 1);
|
|
36789
36923
|
crypto3 = __toESM(require("crypto"), 1);
|
|
36790
36924
|
fs6 = __toESM(require("fs"), 1);
|
|
36791
36925
|
import_module = require("module");
|
|
36792
36926
|
import_stream2 = require("stream");
|
|
36793
|
-
import_child_process7 = require("child_process");
|
|
36794
|
-
init_acp();
|
|
36795
36927
|
import_child_process8 = require("child_process");
|
|
36928
|
+
init_acp();
|
|
36929
|
+
import_child_process9 = require("child_process");
|
|
36796
36930
|
net2 = __toESM(require("net"), 1);
|
|
36797
36931
|
os15 = __toESM(require("os"), 1);
|
|
36798
|
-
|
|
36932
|
+
path19 = __toESM(require("path"), 1);
|
|
36799
36933
|
fs7 = __toESM(require("fs"), 1);
|
|
36800
|
-
|
|
36934
|
+
path18 = __toESM(require("path"), 1);
|
|
36801
36935
|
os14 = __toESM(require("os"), 1);
|
|
36802
36936
|
init_esm2();
|
|
36803
36937
|
fs8 = __toESM(require("fs"), 1);
|
|
36804
|
-
|
|
36938
|
+
path20 = __toESM(require("path"), 1);
|
|
36805
36939
|
os16 = __toESM(require("os"), 1);
|
|
36806
|
-
|
|
36940
|
+
import_fs11 = require("fs");
|
|
36807
36941
|
import_module2 = require("module");
|
|
36808
36942
|
import_path4 = require("path");
|
|
36809
36943
|
os17 = __toESM(require("os"), 1);
|
|
36810
|
-
import_child_process9 = require("child_process");
|
|
36811
36944
|
import_child_process10 = require("child_process");
|
|
36945
|
+
import_child_process11 = require("child_process");
|
|
36812
36946
|
fs9 = __toESM(require("fs"), 1);
|
|
36813
36947
|
os18 = __toESM(require("os"), 1);
|
|
36814
|
-
|
|
36948
|
+
path21 = __toESM(require("path"), 1);
|
|
36815
36949
|
fs10 = __toESM(require("fs"), 1);
|
|
36816
36950
|
fs11 = __toESM(require("fs"), 1);
|
|
36817
|
-
|
|
36951
|
+
path222 = __toESM(require("path"), 1);
|
|
36818
36952
|
os19 = __toESM(require("os"), 1);
|
|
36819
|
-
|
|
36953
|
+
import_child_process12 = require("child_process");
|
|
36820
36954
|
import_os4 = require("os");
|
|
36821
36955
|
http2 = __toESM(require("http"), 1);
|
|
36822
36956
|
fs15 = __toESM(require("fs"), 1);
|
|
36823
|
-
|
|
36957
|
+
path26 = __toESM(require("path"), 1);
|
|
36824
36958
|
fs12 = __toESM(require("fs"), 1);
|
|
36825
|
-
path222 = __toESM(require("path"), 1);
|
|
36826
|
-
fs13 = __toESM(require("fs"), 1);
|
|
36827
36959
|
path23 = __toESM(require("path"), 1);
|
|
36828
|
-
|
|
36960
|
+
fs13 = __toESM(require("fs"), 1);
|
|
36829
36961
|
path24 = __toESM(require("path"), 1);
|
|
36962
|
+
fs14 = __toESM(require("fs"), 1);
|
|
36963
|
+
path25 = __toESM(require("path"), 1);
|
|
36830
36964
|
os20 = __toESM(require("os"), 1);
|
|
36831
36965
|
init_dist();
|
|
36832
36966
|
init_dist();
|
|
36833
|
-
|
|
36967
|
+
import_child_process13 = require("child_process");
|
|
36834
36968
|
__defProp2 = Object.defineProperty;
|
|
36835
36969
|
__getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
36836
36970
|
__getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
@@ -36870,6 +37004,23 @@ var init_dist2 = __esm({
|
|
|
36870
37004
|
};
|
|
36871
37005
|
}
|
|
36872
37006
|
});
|
|
37007
|
+
git_worktree_exports = {};
|
|
37008
|
+
__export2(git_worktree_exports, {
|
|
37009
|
+
createWorktree: () => createWorktree,
|
|
37010
|
+
listWorktrees: () => listWorktrees,
|
|
37011
|
+
parseWorktreeListOutput: () => parseWorktreeListOutput,
|
|
37012
|
+
removeWorktree: () => removeWorktree,
|
|
37013
|
+
resolveWorktreePath: () => resolveWorktreePath
|
|
37014
|
+
});
|
|
37015
|
+
init_git_worktree = __esm2({
|
|
37016
|
+
"src/git/git-worktree.ts"() {
|
|
37017
|
+
"use strict";
|
|
37018
|
+
execFileAsync2 = (0, import_util3.promisify)(import_child_process.execFile);
|
|
37019
|
+
WORKTREE_DIR_NAME = ".adhdev-worktrees";
|
|
37020
|
+
GIT_TIMEOUT_MS = 3e4;
|
|
37021
|
+
GIT_MAX_BUFFER = 4 * 1024 * 1024;
|
|
37022
|
+
}
|
|
37023
|
+
});
|
|
36873
37024
|
config_exports = {};
|
|
36874
37025
|
__export2(config_exports, {
|
|
36875
37026
|
generateMachineId: () => generateMachineId,
|
|
@@ -36940,6 +37091,7 @@ var init_dist2 = __esm({
|
|
|
36940
37091
|
init_coordinator_prompt = __esm2({
|
|
36941
37092
|
"src/mesh/coordinator-prompt.ts"() {
|
|
36942
37093
|
"use strict";
|
|
37094
|
+
init_repo_mesh_types();
|
|
36943
37095
|
TOOLS_SECTION = `## Available Tools
|
|
36944
37096
|
|
|
36945
37097
|
| Tool | Purpose |
|
|
@@ -36951,30 +37103,23 @@ var init_dist2 = __esm({
|
|
|
36951
37103
|
| \`mesh_read_chat\` | Read an agent's recent messages to check progress |
|
|
36952
37104
|
| \`mesh_git_status\` | Check git status on a specific node |
|
|
36953
37105
|
| \`mesh_checkpoint\` | Create a git checkpoint on a node |
|
|
36954
|
-
| \`mesh_approve\` | Approve/reject a pending agent action
|
|
37106
|
+
| \`mesh_approve\` | Approve/reject a pending agent action |
|
|
37107
|
+
| \`mesh_clone_node\` | Create a worktree node for isolated parallel branch work |
|
|
37108
|
+
| \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |`;
|
|
36955
37109
|
WORKFLOW_SECTION = `## Orchestration Workflow
|
|
36956
37110
|
|
|
36957
37111
|
1. **Assess** \u2014 Call \`mesh_status\` to see which nodes are healthy and available.
|
|
36958
37112
|
2. **Plan** \u2014 Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist.
|
|
36959
37113
|
3. **Delegate** \u2014 For each task:
|
|
36960
37114
|
a. Pick the best node (consider: health, dirty state, current workload).
|
|
36961
|
-
b. If
|
|
36962
|
-
c.
|
|
37115
|
+
b. If you need branch isolation for parallel work, call \`mesh_clone_node\` to create a worktree node first.
|
|
37116
|
+
c. If no session exists, call \`mesh_launch_session\` to start one.
|
|
37117
|
+
d. Call \`mesh_send_task\` with a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
|
|
36963
37118
|
4. **Monitor** \u2014 Periodically call \`mesh_read_chat\` to check progress. Handle approvals via \`mesh_approve\`.
|
|
36964
37119
|
5. **Verify** \u2014 When a task reports completion, call \`mesh_git_status\` to verify changes were made.
|
|
36965
37120
|
6. **Checkpoint** \u2014 Call \`mesh_checkpoint\` to save the work.
|
|
36966
|
-
7. **
|
|
36967
|
-
|
|
36968
|
-
|
|
36969
|
-
- **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly \u2014 delegate all of that to node agents. Your context should stay lean.
|
|
36970
|
-
- **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to a node. Do not do it yourself.
|
|
36971
|
-
- **Front-load the task message.** When calling \`mesh_send_task\`, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
|
|
36972
|
-
- **Don't inspect code.** Trust the agent's output. Verify via \`mesh_git_status\`, not by reading source files.
|
|
36973
|
-
- **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed.
|
|
36974
|
-
- **Handle failures gracefully.** If a task fails, read the chat to understand why, then retry or reassign.
|
|
36975
|
-
- **Keep the user informed.** Report progress after each delegation round \u2014 one or two sentences, not a narration.
|
|
36976
|
-
- **Respect node capabilities.** Don't send build tasks to read-only nodes. Don't push from nodes that aren't allowed to.
|
|
36977
|
-
- **Never fabricate tool results.** Always call the actual tool; never pretend you did.`;
|
|
37121
|
+
7. **Clean up** \u2014 Remove worktree nodes via \`mesh_remove_node\` after their work is merged or no longer needed.
|
|
37122
|
+
8. **Report** \u2014 Summarize what was done, what changed, and any issues.`;
|
|
36978
37123
|
}
|
|
36979
37124
|
});
|
|
36980
37125
|
init_logger = __esm2({
|
|
@@ -36983,7 +37128,7 @@ var init_dist2 = __esm({
|
|
|
36983
37128
|
LEVEL_NUM = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
36984
37129
|
LEVEL_LABEL = { debug: "DBG", info: "INF", warn: "WRN", error: "ERR" };
|
|
36985
37130
|
currentLevel = "info";
|
|
36986
|
-
LOG_DIR = process.platform === "win32" ?
|
|
37131
|
+
LOG_DIR = process.platform === "win32" ? path10.join(process.env.LOCALAPPDATA || process.env.APPDATA || path10.join(os4.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path10.join(os4.homedir(), "Library", "Logs", "adhdev") : path10.join(os4.homedir(), ".local", "share", "adhdev", "logs");
|
|
36987
37132
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
36988
37133
|
MAX_LOG_DAYS = 7;
|
|
36989
37134
|
try {
|
|
@@ -36991,16 +37136,16 @@ var init_dist2 = __esm({
|
|
|
36991
37136
|
} catch {
|
|
36992
37137
|
}
|
|
36993
37138
|
currentDate = getDateStr();
|
|
36994
|
-
currentLogFile =
|
|
37139
|
+
currentLogFile = path10.join(LOG_DIR, `daemon-${currentDate}.log`);
|
|
36995
37140
|
cleanOldLogs();
|
|
36996
37141
|
try {
|
|
36997
|
-
const oldLog =
|
|
37142
|
+
const oldLog = path10.join(LOG_DIR, "daemon.log");
|
|
36998
37143
|
if (fs2.existsSync(oldLog)) {
|
|
36999
37144
|
const stat22 = fs2.statSync(oldLog);
|
|
37000
37145
|
const oldDate = stat22.mtime.toISOString().slice(0, 10);
|
|
37001
|
-
fs2.renameSync(oldLog,
|
|
37146
|
+
fs2.renameSync(oldLog, path10.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
37002
37147
|
}
|
|
37003
|
-
const oldLogBackup =
|
|
37148
|
+
const oldLogBackup = path10.join(LOG_DIR, "daemon.log.old");
|
|
37004
37149
|
if (fs2.existsSync(oldLogBackup)) {
|
|
37005
37150
|
fs2.unlinkSync(oldLogBackup);
|
|
37006
37151
|
}
|
|
@@ -37032,7 +37177,7 @@ var init_dist2 = __esm({
|
|
|
37032
37177
|
}
|
|
37033
37178
|
};
|
|
37034
37179
|
interceptorInstalled = false;
|
|
37035
|
-
LOG_PATH =
|
|
37180
|
+
LOG_PATH = path10.join(LOG_DIR, `daemon-${getDateStr()}.log`);
|
|
37036
37181
|
}
|
|
37037
37182
|
});
|
|
37038
37183
|
init_debug_config = __esm2({
|
|
@@ -39343,7 +39488,7 @@ ${lastSnapshot}`;
|
|
|
39343
39488
|
}
|
|
39344
39489
|
});
|
|
39345
39490
|
init_repo_mesh_types();
|
|
39346
|
-
execFileAsync = (0,
|
|
39491
|
+
execFileAsync = (0, import_util4.promisify)(import_child_process3.execFile);
|
|
39347
39492
|
DEFAULT_TIMEOUT_MS = 5e3;
|
|
39348
39493
|
DEFAULT_MAX_BUFFER = 1024 * 1024;
|
|
39349
39494
|
GitCommandError = class extends Error {
|
|
@@ -39590,6 +39735,7 @@ ${lastSnapshot}`;
|
|
|
39590
39735
|
this.lastStatus.delete(sessionId);
|
|
39591
39736
|
}
|
|
39592
39737
|
};
|
|
39738
|
+
init_git_worktree();
|
|
39593
39739
|
init_config();
|
|
39594
39740
|
MAX_WORKSPACES = 50;
|
|
39595
39741
|
MAX_ACTIVITY = 30;
|
|
@@ -41044,7 +41190,7 @@ ${lastSnapshot}`;
|
|
|
41044
41190
|
shell: "terminal",
|
|
41045
41191
|
console: "terminal"
|
|
41046
41192
|
};
|
|
41047
|
-
HISTORY_DIR =
|
|
41193
|
+
HISTORY_DIR = path11.join(os52.homedir(), ".adhdev", "history");
|
|
41048
41194
|
RETAIN_DAYS = 30;
|
|
41049
41195
|
SAVED_HISTORY_INDEX_VERSION = 1;
|
|
41050
41196
|
SAVED_HISTORY_INDEX_FILE = ".saved-history-index.json";
|
|
@@ -41126,12 +41272,12 @@ ${lastSnapshot}`;
|
|
|
41126
41272
|
});
|
|
41127
41273
|
}
|
|
41128
41274
|
if (newMessages.length === 0) return;
|
|
41129
|
-
const dir =
|
|
41275
|
+
const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
|
|
41130
41276
|
fs3.mkdirSync(dir, { recursive: true });
|
|
41131
41277
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
41132
41278
|
const filePrefix = effectiveHistoryKey ? `${this.sanitize(effectiveHistoryKey)}_` : "";
|
|
41133
41279
|
const fileName = `${filePrefix}${date5}.jsonl`;
|
|
41134
|
-
const filePath =
|
|
41280
|
+
const filePath = path11.join(dir, fileName);
|
|
41135
41281
|
const lines = newMessages.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
41136
41282
|
fs3.appendFileSync(filePath, lines, "utf-8");
|
|
41137
41283
|
updateSavedHistoryIndexForAppendedMessages(agentType, dir, fileName, effectiveHistoryKey, newMessages);
|
|
@@ -41222,11 +41368,11 @@ ${lastSnapshot}`;
|
|
|
41222
41368
|
const ws = String(workspace || "").trim();
|
|
41223
41369
|
if (!id || !ws) return;
|
|
41224
41370
|
try {
|
|
41225
|
-
const dir =
|
|
41371
|
+
const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
|
|
41226
41372
|
fs3.mkdirSync(dir, { recursive: true });
|
|
41227
41373
|
const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
41228
41374
|
const fileName = `${this.sanitize(id)}_${date5}.jsonl`;
|
|
41229
|
-
const filePath =
|
|
41375
|
+
const filePath = path11.join(dir, fileName);
|
|
41230
41376
|
const record2 = {
|
|
41231
41377
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
41232
41378
|
receivedAt: Date.now(),
|
|
@@ -41272,14 +41418,14 @@ ${lastSnapshot}`;
|
|
|
41272
41418
|
this.lastSeenCounts.set(toDedupKey, Math.max(fromCount, this.lastSeenCounts.get(toDedupKey) || 0));
|
|
41273
41419
|
this.lastSeenCounts.delete(fromDedupKey);
|
|
41274
41420
|
}
|
|
41275
|
-
const dir =
|
|
41421
|
+
const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
|
|
41276
41422
|
if (!fs3.existsSync(dir)) return;
|
|
41277
41423
|
const fromPrefix = `${this.sanitize(fromId)}_`;
|
|
41278
41424
|
const toPrefix = `${this.sanitize(toId)}_`;
|
|
41279
41425
|
const files = fs3.readdirSync(dir).filter((file2) => file2.startsWith(fromPrefix) && file2.endsWith(".jsonl"));
|
|
41280
41426
|
for (const file2 of files) {
|
|
41281
|
-
const sourcePath =
|
|
41282
|
-
const targetPath =
|
|
41427
|
+
const sourcePath = path11.join(dir, file2);
|
|
41428
|
+
const targetPath = path11.join(dir, `${toPrefix}${file2.slice(fromPrefix.length)}`);
|
|
41283
41429
|
const sourceLines = fs3.readFileSync(sourcePath, "utf-8").split("\n").filter(Boolean);
|
|
41284
41430
|
const rewritten = sourceLines.map((line) => {
|
|
41285
41431
|
try {
|
|
@@ -41313,13 +41459,13 @@ ${lastSnapshot}`;
|
|
|
41313
41459
|
const sessionId = String(historySessionId || "").trim();
|
|
41314
41460
|
if (!sessionId) return;
|
|
41315
41461
|
try {
|
|
41316
|
-
const dir =
|
|
41462
|
+
const dir = path11.join(HISTORY_DIR, this.sanitize(agentType));
|
|
41317
41463
|
if (!fs3.existsSync(dir)) return;
|
|
41318
41464
|
const prefix = `${this.sanitize(sessionId)}_`;
|
|
41319
41465
|
const files = fs3.readdirSync(dir).filter((file2) => file2.startsWith(prefix) && file2.endsWith(".jsonl")).sort();
|
|
41320
41466
|
const seen = /* @__PURE__ */ new Set();
|
|
41321
41467
|
for (const file2 of files) {
|
|
41322
|
-
const filePath =
|
|
41468
|
+
const filePath = path11.join(dir, file2);
|
|
41323
41469
|
const lines = fs3.readFileSync(filePath, "utf-8").split("\n").filter(Boolean);
|
|
41324
41470
|
const next = [];
|
|
41325
41471
|
for (const line of lines) {
|
|
@@ -41373,11 +41519,11 @@ ${lastSnapshot}`;
|
|
|
41373
41519
|
const cutoff = Date.now() - RETAIN_DAYS * 24 * 60 * 60 * 1e3;
|
|
41374
41520
|
const agentDirs = fs3.readdirSync(HISTORY_DIR, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
41375
41521
|
for (const dir of agentDirs) {
|
|
41376
|
-
const dirPath =
|
|
41522
|
+
const dirPath = path11.join(HISTORY_DIR, dir.name);
|
|
41377
41523
|
const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
41378
41524
|
let removedAny = false;
|
|
41379
41525
|
for (const file2 of files) {
|
|
41380
|
-
const filePath =
|
|
41526
|
+
const filePath = path11.join(dirPath, file2);
|
|
41381
41527
|
const stat22 = fs3.statSync(filePath);
|
|
41382
41528
|
if (stat22.mtimeMs < cutoff) {
|
|
41383
41529
|
fs3.unlinkSync(filePath);
|
|
@@ -44563,7 +44709,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
44563
44709
|
this.errorMessage = null;
|
|
44564
44710
|
this.errorReason = null;
|
|
44565
44711
|
this.stderrBuffer = [];
|
|
44566
|
-
this.process = (0,
|
|
44712
|
+
this.process = (0, import_child_process8.spawn)(command, args, {
|
|
44567
44713
|
cwd: this.workingDir,
|
|
44568
44714
|
env: env2,
|
|
44569
44715
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -45380,7 +45526,7 @@ ${rawInput}` : rawInput;
|
|
|
45380
45526
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
45381
45527
|
const trimmed = (workingDir || "").trim();
|
|
45382
45528
|
if (!trimmed) throw new Error("working directory required");
|
|
45383
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) :
|
|
45529
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os13.homedir()) : path17.resolve(trimmed);
|
|
45384
45530
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
45385
45531
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
45386
45532
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -45973,7 +46119,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45973
46119
|
try {
|
|
45974
46120
|
if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
|
|
45975
46121
|
return ["ide", "extension", "cli", "acp"].some(
|
|
45976
|
-
(category) => fs7.existsSync(
|
|
46122
|
+
(category) => fs7.existsSync(path18.join(candidate, category))
|
|
45977
46123
|
);
|
|
45978
46124
|
} catch {
|
|
45979
46125
|
return false;
|
|
@@ -45981,20 +46127,20 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
45981
46127
|
}
|
|
45982
46128
|
static hasProviderRootMarker(candidate) {
|
|
45983
46129
|
try {
|
|
45984
|
-
return fs7.existsSync(
|
|
46130
|
+
return fs7.existsSync(path18.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
45985
46131
|
} catch {
|
|
45986
46132
|
return false;
|
|
45987
46133
|
}
|
|
45988
46134
|
}
|
|
45989
46135
|
detectDefaultUserDir() {
|
|
45990
|
-
const fallback =
|
|
46136
|
+
const fallback = path18.join(os14.homedir(), ".adhdev", "providers");
|
|
45991
46137
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
45992
46138
|
const visited = /* @__PURE__ */ new Set();
|
|
45993
46139
|
for (const start of this.probeStarts) {
|
|
45994
|
-
let current =
|
|
46140
|
+
let current = path18.resolve(start);
|
|
45995
46141
|
while (!visited.has(current)) {
|
|
45996
46142
|
visited.add(current);
|
|
45997
|
-
const siblingCandidate =
|
|
46143
|
+
const siblingCandidate = path18.join(path18.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
45998
46144
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
45999
46145
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
46000
46146
|
if (envOptIn || hasMarker) {
|
|
@@ -46016,7 +46162,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46016
46162
|
return { path: siblingCandidate, source };
|
|
46017
46163
|
}
|
|
46018
46164
|
}
|
|
46019
|
-
const parent =
|
|
46165
|
+
const parent = path18.dirname(current);
|
|
46020
46166
|
if (parent === current) break;
|
|
46021
46167
|
current = parent;
|
|
46022
46168
|
}
|
|
@@ -46026,11 +46172,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46026
46172
|
constructor(options) {
|
|
46027
46173
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
46028
46174
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
46029
|
-
this.defaultProvidersDir =
|
|
46175
|
+
this.defaultProvidersDir = path18.join(os14.homedir(), ".adhdev", "providers");
|
|
46030
46176
|
const detected = this.detectDefaultUserDir();
|
|
46031
46177
|
this.userDir = detected.path;
|
|
46032
46178
|
this.userDirSource = detected.source;
|
|
46033
|
-
this.upstreamDir =
|
|
46179
|
+
this.upstreamDir = path18.join(this.defaultProvidersDir, ".upstream");
|
|
46034
46180
|
this.disableUpstream = false;
|
|
46035
46181
|
this.applySourceConfig({
|
|
46036
46182
|
userDir: options?.userDir,
|
|
@@ -46089,7 +46235,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46089
46235
|
this.userDir = detected.path;
|
|
46090
46236
|
this.userDirSource = detected.source;
|
|
46091
46237
|
}
|
|
46092
|
-
this.upstreamDir =
|
|
46238
|
+
this.upstreamDir = path18.join(this.defaultProvidersDir, ".upstream");
|
|
46093
46239
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
46094
46240
|
if (this.explicitProviderDir) {
|
|
46095
46241
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -46103,7 +46249,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46103
46249
|
* Canonical provider directory shape for a given root.
|
|
46104
46250
|
*/
|
|
46105
46251
|
getProviderDir(root, category, type) {
|
|
46106
|
-
return
|
|
46252
|
+
return path18.join(root, category, type);
|
|
46107
46253
|
}
|
|
46108
46254
|
/**
|
|
46109
46255
|
* Canonical user override directory for a provider.
|
|
@@ -46130,7 +46276,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46130
46276
|
resolveProviderFile(type, ...segments) {
|
|
46131
46277
|
const dir = this.findProviderDirInternal(type);
|
|
46132
46278
|
if (!dir) return null;
|
|
46133
|
-
return
|
|
46279
|
+
return path18.join(dir, ...segments);
|
|
46134
46280
|
}
|
|
46135
46281
|
/**
|
|
46136
46282
|
* Load all providers (3-tier priority)
|
|
@@ -46169,7 +46315,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46169
46315
|
if (!fs7.existsSync(this.upstreamDir)) return false;
|
|
46170
46316
|
try {
|
|
46171
46317
|
return fs7.readdirSync(this.upstreamDir).some(
|
|
46172
|
-
(d) => fs7.statSync(
|
|
46318
|
+
(d) => fs7.statSync(path18.join(this.upstreamDir, d)).isDirectory()
|
|
46173
46319
|
);
|
|
46174
46320
|
} catch {
|
|
46175
46321
|
return false;
|
|
@@ -46666,8 +46812,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46666
46812
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
46667
46813
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
46668
46814
|
if (providerDir) {
|
|
46669
|
-
const fullDir =
|
|
46670
|
-
resolved._resolvedScriptsPath = fs7.existsSync(
|
|
46815
|
+
const fullDir = path18.join(providerDir, entry.scriptDir);
|
|
46816
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
|
|
46671
46817
|
}
|
|
46672
46818
|
matched = true;
|
|
46673
46819
|
}
|
|
@@ -46682,8 +46828,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46682
46828
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
46683
46829
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
46684
46830
|
if (providerDir) {
|
|
46685
|
-
const fullDir =
|
|
46686
|
-
resolved._resolvedScriptsPath = fs7.existsSync(
|
|
46831
|
+
const fullDir = path18.join(providerDir, base.defaultScriptDir);
|
|
46832
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
|
|
46687
46833
|
}
|
|
46688
46834
|
}
|
|
46689
46835
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -46700,8 +46846,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46700
46846
|
resolved._resolvedScriptDir = dirOverride;
|
|
46701
46847
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
46702
46848
|
if (providerDir) {
|
|
46703
|
-
const fullDir =
|
|
46704
|
-
resolved._resolvedScriptsPath = fs7.existsSync(
|
|
46849
|
+
const fullDir = path18.join(providerDir, dirOverride);
|
|
46850
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
|
|
46705
46851
|
}
|
|
46706
46852
|
}
|
|
46707
46853
|
} else if (override.scripts) {
|
|
@@ -46717,8 +46863,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46717
46863
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
46718
46864
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
46719
46865
|
if (providerDir) {
|
|
46720
|
-
const fullDir =
|
|
46721
|
-
resolved._resolvedScriptsPath = fs7.existsSync(
|
|
46866
|
+
const fullDir = path18.join(providerDir, base.defaultScriptDir);
|
|
46867
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path18.join(fullDir, "scripts.js")) ? path18.join(fullDir, "scripts.js") : fullDir;
|
|
46722
46868
|
}
|
|
46723
46869
|
}
|
|
46724
46870
|
}
|
|
@@ -46750,14 +46896,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46750
46896
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
46751
46897
|
return null;
|
|
46752
46898
|
}
|
|
46753
|
-
const dir =
|
|
46899
|
+
const dir = path18.join(providerDir, scriptDir);
|
|
46754
46900
|
if (!fs7.existsSync(dir)) {
|
|
46755
46901
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
46756
46902
|
return null;
|
|
46757
46903
|
}
|
|
46758
46904
|
const cached2 = this.scriptsCache.get(dir);
|
|
46759
46905
|
if (cached2) return cached2;
|
|
46760
|
-
const scriptsJs =
|
|
46906
|
+
const scriptsJs = path18.join(dir, "scripts.js");
|
|
46761
46907
|
if (fs7.existsSync(scriptsJs)) {
|
|
46762
46908
|
try {
|
|
46763
46909
|
delete __require2.cache[__require2.resolve(scriptsJs)];
|
|
@@ -46799,7 +46945,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46799
46945
|
return;
|
|
46800
46946
|
}
|
|
46801
46947
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
46802
|
-
this.log(`File changed: ${
|
|
46948
|
+
this.log(`File changed: ${path18.basename(filePath)}, reloading...`);
|
|
46803
46949
|
this.reload();
|
|
46804
46950
|
}
|
|
46805
46951
|
};
|
|
@@ -46854,7 +47000,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46854
47000
|
}
|
|
46855
47001
|
const https = __require2("https");
|
|
46856
47002
|
const { execSync: execSync7 } = __require2("child_process");
|
|
46857
|
-
const metaPath =
|
|
47003
|
+
const metaPath = path18.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
46858
47004
|
let prevEtag = "";
|
|
46859
47005
|
let prevTimestamp = 0;
|
|
46860
47006
|
try {
|
|
@@ -46914,17 +47060,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46914
47060
|
return { updated: false };
|
|
46915
47061
|
}
|
|
46916
47062
|
this.log("Downloading latest providers from GitHub...");
|
|
46917
|
-
const tmpTar =
|
|
46918
|
-
const tmpExtract =
|
|
47063
|
+
const tmpTar = path18.join(os14.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
47064
|
+
const tmpExtract = path18.join(os14.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
46919
47065
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
46920
47066
|
fs7.mkdirSync(tmpExtract, { recursive: true });
|
|
46921
47067
|
execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
46922
47068
|
const extracted = fs7.readdirSync(tmpExtract);
|
|
46923
47069
|
const rootDir = extracted.find(
|
|
46924
|
-
(d) => fs7.statSync(
|
|
47070
|
+
(d) => fs7.statSync(path18.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
46925
47071
|
);
|
|
46926
47072
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
46927
|
-
const sourceDir =
|
|
47073
|
+
const sourceDir = path18.join(tmpExtract, rootDir);
|
|
46928
47074
|
const backupDir = this.upstreamDir + ".bak";
|
|
46929
47075
|
if (fs7.existsSync(this.upstreamDir)) {
|
|
46930
47076
|
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
@@ -46999,8 +47145,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
46999
47145
|
copyDirRecursive(src, dest) {
|
|
47000
47146
|
fs7.mkdirSync(dest, { recursive: true });
|
|
47001
47147
|
for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
|
|
47002
|
-
const srcPath =
|
|
47003
|
-
const destPath =
|
|
47148
|
+
const srcPath = path18.join(src, entry.name);
|
|
47149
|
+
const destPath = path18.join(dest, entry.name);
|
|
47004
47150
|
if (entry.isDirectory()) {
|
|
47005
47151
|
this.copyDirRecursive(srcPath, destPath);
|
|
47006
47152
|
} else {
|
|
@@ -47011,7 +47157,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47011
47157
|
/** .meta.json save */
|
|
47012
47158
|
writeMeta(metaPath, etag, timestamp) {
|
|
47013
47159
|
try {
|
|
47014
|
-
fs7.mkdirSync(
|
|
47160
|
+
fs7.mkdirSync(path18.dirname(metaPath), { recursive: true });
|
|
47015
47161
|
fs7.writeFileSync(metaPath, JSON.stringify({
|
|
47016
47162
|
etag,
|
|
47017
47163
|
timestamp,
|
|
@@ -47028,7 +47174,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47028
47174
|
const scan = (d) => {
|
|
47029
47175
|
try {
|
|
47030
47176
|
for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
|
|
47031
|
-
if (entry.isDirectory()) scan(
|
|
47177
|
+
if (entry.isDirectory()) scan(path18.join(d, entry.name));
|
|
47032
47178
|
else if (entry.name === "provider.json") count++;
|
|
47033
47179
|
}
|
|
47034
47180
|
} catch {
|
|
@@ -47256,17 +47402,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47256
47402
|
for (const root of searchRoots) {
|
|
47257
47403
|
if (!fs7.existsSync(root)) continue;
|
|
47258
47404
|
const candidate = this.getProviderDir(root, cat, type);
|
|
47259
|
-
if (fs7.existsSync(
|
|
47260
|
-
const catDir =
|
|
47405
|
+
if (fs7.existsSync(path18.join(candidate, "provider.json"))) return candidate;
|
|
47406
|
+
const catDir = path18.join(root, cat);
|
|
47261
47407
|
if (fs7.existsSync(catDir)) {
|
|
47262
47408
|
try {
|
|
47263
47409
|
for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
|
|
47264
47410
|
if (!entry.isDirectory()) continue;
|
|
47265
|
-
const jsonPath =
|
|
47411
|
+
const jsonPath = path18.join(catDir, entry.name, "provider.json");
|
|
47266
47412
|
if (fs7.existsSync(jsonPath)) {
|
|
47267
47413
|
try {
|
|
47268
47414
|
const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
|
|
47269
|
-
if (data.type === type) return
|
|
47415
|
+
if (data.type === type) return path18.join(catDir, entry.name);
|
|
47270
47416
|
} catch {
|
|
47271
47417
|
}
|
|
47272
47418
|
}
|
|
@@ -47283,7 +47429,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47283
47429
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
47284
47430
|
*/
|
|
47285
47431
|
buildScriptWrappersFromDir(dir) {
|
|
47286
|
-
const scriptsJs =
|
|
47432
|
+
const scriptsJs = path18.join(dir, "scripts.js");
|
|
47287
47433
|
if (fs7.existsSync(scriptsJs)) {
|
|
47288
47434
|
try {
|
|
47289
47435
|
delete __require2.cache[__require2.resolve(scriptsJs)];
|
|
@@ -47297,7 +47443,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47297
47443
|
for (const file2 of fs7.readdirSync(dir)) {
|
|
47298
47444
|
if (!file2.endsWith(".js")) continue;
|
|
47299
47445
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
47300
|
-
const filePath =
|
|
47446
|
+
const filePath = path18.join(dir, file2);
|
|
47301
47447
|
result[scriptName] = (...args) => {
|
|
47302
47448
|
try {
|
|
47303
47449
|
let content = fs7.readFileSync(filePath, "utf-8");
|
|
@@ -47357,7 +47503,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47357
47503
|
}
|
|
47358
47504
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
47359
47505
|
if (hasJson) {
|
|
47360
|
-
const jsonPath =
|
|
47506
|
+
const jsonPath = path18.join(d, "provider.json");
|
|
47361
47507
|
try {
|
|
47362
47508
|
const raw = fs7.readFileSync(jsonPath, "utf-8");
|
|
47363
47509
|
const mod = JSON.parse(raw);
|
|
@@ -47378,7 +47524,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47378
47524
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
47379
47525
|
} else {
|
|
47380
47526
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
47381
|
-
const scriptsPath =
|
|
47527
|
+
const scriptsPath = path18.join(d, "scripts.js");
|
|
47382
47528
|
if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
|
|
47383
47529
|
try {
|
|
47384
47530
|
delete __require2.cache[__require2.resolve(scriptsPath)];
|
|
@@ -47404,7 +47550,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47404
47550
|
if (!entry.isDirectory()) continue;
|
|
47405
47551
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
47406
47552
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
47407
|
-
scan(
|
|
47553
|
+
scan(path18.join(d, entry.name));
|
|
47408
47554
|
}
|
|
47409
47555
|
}
|
|
47410
47556
|
};
|
|
@@ -47453,7 +47599,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47453
47599
|
_providerLoader = null;
|
|
47454
47600
|
init_config();
|
|
47455
47601
|
init_logger();
|
|
47456
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
47602
|
+
LOG_DIR2 = process.platform === "win32" ? path20.join(process.env.LOCALAPPDATA || process.env.APPDATA || path20.join(os16.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path20.join(os16.homedir(), "Library", "Logs", "adhdev") : path20.join(os16.homedir(), ".local", "share", "adhdev", "logs");
|
|
47457
47603
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
47458
47604
|
MAX_DAYS = 7;
|
|
47459
47605
|
try {
|
|
@@ -47472,7 +47618,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47472
47618
|
"text"
|
|
47473
47619
|
]);
|
|
47474
47620
|
currentDate2 = getDateStr2();
|
|
47475
|
-
currentFile =
|
|
47621
|
+
currentFile = path20.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
47476
47622
|
writeCount2 = 0;
|
|
47477
47623
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
47478
47624
|
"heartbeat",
|
|
@@ -47514,6 +47660,40 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
47514
47660
|
constructor(deps) {
|
|
47515
47661
|
this.deps = deps;
|
|
47516
47662
|
}
|
|
47663
|
+
getCachedInlineMesh(meshId, inlineMesh) {
|
|
47664
|
+
if (inlineMesh && typeof inlineMesh === "object") {
|
|
47665
|
+
this.inlineMeshCache.set(meshId, inlineMesh);
|
|
47666
|
+
return inlineMesh;
|
|
47667
|
+
}
|
|
47668
|
+
return this.inlineMeshCache.get(meshId);
|
|
47669
|
+
}
|
|
47670
|
+
async getMeshForCommand(meshId, inlineMesh) {
|
|
47671
|
+
try {
|
|
47672
|
+
const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
47673
|
+
const mesh = getMesh3(meshId);
|
|
47674
|
+
if (mesh) return { mesh, inline: false };
|
|
47675
|
+
} catch {
|
|
47676
|
+
}
|
|
47677
|
+
const cached2 = this.getCachedInlineMesh(meshId, inlineMesh);
|
|
47678
|
+
return cached2 ? { mesh: cached2, inline: true } : null;
|
|
47679
|
+
}
|
|
47680
|
+
updateInlineMeshNode(meshId, mesh, node) {
|
|
47681
|
+
if (!mesh || !Array.isArray(mesh.nodes) || !node?.id) return;
|
|
47682
|
+
const idx = mesh.nodes.findIndex((entry) => entry?.id === node.id || entry?.nodeId === node.id);
|
|
47683
|
+
if (idx >= 0) mesh.nodes[idx] = node;
|
|
47684
|
+
else mesh.nodes.push(node);
|
|
47685
|
+
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47686
|
+
this.inlineMeshCache.set(meshId, mesh);
|
|
47687
|
+
}
|
|
47688
|
+
removeInlineMeshNode(meshId, mesh, nodeId) {
|
|
47689
|
+
if (!mesh || !Array.isArray(mesh.nodes)) return false;
|
|
47690
|
+
const idx = mesh.nodes.findIndex((entry) => entry?.id === nodeId || entry?.nodeId === nodeId);
|
|
47691
|
+
if (idx === -1) return false;
|
|
47692
|
+
mesh.nodes.splice(idx, 1);
|
|
47693
|
+
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47694
|
+
this.inlineMeshCache.set(meshId, mesh);
|
|
47695
|
+
return true;
|
|
47696
|
+
}
|
|
47517
47697
|
async traceSessionHostAction(action, args, run, summarizeResult) {
|
|
47518
47698
|
const interactionId = typeof args?._interactionId === "string" ? args._interactionId : void 0;
|
|
47519
47699
|
const sessionId = typeof args?.sessionId === "string" ? args.sessionId : void 0;
|
|
@@ -48213,13 +48393,94 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
48213
48393
|
const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
|
|
48214
48394
|
if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
|
|
48215
48395
|
try {
|
|
48216
|
-
const
|
|
48217
|
-
const
|
|
48396
|
+
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
48397
|
+
const mesh = meshRecord?.mesh;
|
|
48398
|
+
const node = mesh?.nodes?.find((n) => n.id === nodeId || n.nodeId === nodeId);
|
|
48399
|
+
if (node?.isLocalWorktree && node.workspace) {
|
|
48400
|
+
try {
|
|
48401
|
+
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => n.id === node.clonedFromNodeId || n.nodeId === node.clonedFromNodeId) : mesh?.nodes.find((n) => !n.isLocalWorktree);
|
|
48402
|
+
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
48403
|
+
if (repoRoot) {
|
|
48404
|
+
const { removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
48405
|
+
await removeWorktree2(repoRoot, node.workspace);
|
|
48406
|
+
}
|
|
48407
|
+
} catch (e) {
|
|
48408
|
+
LOG.warn("MeshNode", `Worktree cleanup failed for ${nodeId}: ${e.message}`);
|
|
48409
|
+
}
|
|
48410
|
+
}
|
|
48411
|
+
let removed = false;
|
|
48412
|
+
if (meshRecord?.inline) {
|
|
48413
|
+
removed = this.removeInlineMeshNode(meshId, mesh, nodeId);
|
|
48414
|
+
} else {
|
|
48415
|
+
const { removeNode: removeNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
48416
|
+
removed = removeNode3(meshId, nodeId);
|
|
48417
|
+
}
|
|
48218
48418
|
return { success: true, removed };
|
|
48219
48419
|
} catch (e) {
|
|
48220
48420
|
return { success: false, error: e.message };
|
|
48221
48421
|
}
|
|
48222
48422
|
}
|
|
48423
|
+
case "clone_mesh_node": {
|
|
48424
|
+
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
48425
|
+
const sourceNodeId = typeof args?.sourceNodeId === "string" ? args.sourceNodeId.trim() : "";
|
|
48426
|
+
const branch = typeof args?.branch === "string" ? args.branch.trim() : "";
|
|
48427
|
+
const baseBranch = typeof args?.baseBranch === "string" ? args.baseBranch.trim() : void 0;
|
|
48428
|
+
if (!meshId) return { success: false, error: "meshId required" };
|
|
48429
|
+
if (!sourceNodeId) return { success: false, error: "sourceNodeId required" };
|
|
48430
|
+
if (!branch) return { success: false, error: "branch required" };
|
|
48431
|
+
try {
|
|
48432
|
+
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
48433
|
+
const mesh = meshRecord?.mesh;
|
|
48434
|
+
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
48435
|
+
const sourceNode = mesh.nodes?.find((n) => n.id === sourceNodeId || n.nodeId === sourceNodeId);
|
|
48436
|
+
if (!sourceNode) return { success: false, error: `Source node '${sourceNodeId}' not found in mesh` };
|
|
48437
|
+
const repoRoot = sourceNode.repoRoot || sourceNode.workspace;
|
|
48438
|
+
const { createWorktree: createWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
48439
|
+
const result = await createWorktree2({
|
|
48440
|
+
repoRoot,
|
|
48441
|
+
branch,
|
|
48442
|
+
baseBranch,
|
|
48443
|
+
meshName: mesh.name
|
|
48444
|
+
});
|
|
48445
|
+
let node;
|
|
48446
|
+
if (meshRecord.inline) {
|
|
48447
|
+
const { randomUUID: randomUUID8 } = await import("crypto");
|
|
48448
|
+
node = {
|
|
48449
|
+
id: `node_${randomUUID8().replace(/-/g, "")}`,
|
|
48450
|
+
workspace: result.worktreePath,
|
|
48451
|
+
repoRoot: result.worktreePath,
|
|
48452
|
+
daemonId: sourceNode.daemonId,
|
|
48453
|
+
userOverrides: { ...sourceNode.userOverrides || {} },
|
|
48454
|
+
policy: { ...sourceNode.policy || {} },
|
|
48455
|
+
isLocalWorktree: true,
|
|
48456
|
+
worktreeBranch: result.branch,
|
|
48457
|
+
clonedFromNodeId: sourceNodeId
|
|
48458
|
+
};
|
|
48459
|
+
this.updateInlineMeshNode(meshId, mesh, node);
|
|
48460
|
+
} else {
|
|
48461
|
+
const { addNode: addNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
48462
|
+
node = addNode3(meshId, {
|
|
48463
|
+
workspace: result.worktreePath,
|
|
48464
|
+
repoRoot: result.worktreePath,
|
|
48465
|
+
daemonId: sourceNode.daemonId,
|
|
48466
|
+
userOverrides: { ...sourceNode.userOverrides || {} },
|
|
48467
|
+
isLocalWorktree: true,
|
|
48468
|
+
worktreeBranch: result.branch,
|
|
48469
|
+
clonedFromNodeId: sourceNodeId,
|
|
48470
|
+
policy: { ...sourceNode.policy || {} }
|
|
48471
|
+
});
|
|
48472
|
+
if (!node) return { success: false, error: "Failed to register worktree node" };
|
|
48473
|
+
}
|
|
48474
|
+
return {
|
|
48475
|
+
success: true,
|
|
48476
|
+
node,
|
|
48477
|
+
worktreePath: result.worktreePath,
|
|
48478
|
+
branch: result.branch
|
|
48479
|
+
};
|
|
48480
|
+
} catch (e) {
|
|
48481
|
+
return { success: false, error: e.message };
|
|
48482
|
+
}
|
|
48483
|
+
}
|
|
48223
48484
|
// ─── Mesh Coordinator Launch ───
|
|
48224
48485
|
case "launch_mesh_coordinator": {
|
|
48225
48486
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
@@ -48288,9 +48549,24 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
48288
48549
|
workspace
|
|
48289
48550
|
};
|
|
48290
48551
|
}
|
|
48291
|
-
|
|
48552
|
+
let systemPrompt = "";
|
|
48553
|
+
try {
|
|
48554
|
+
systemPrompt = buildCoordinatorSystemPrompt2({ mesh, coordinatorCliType: cliType });
|
|
48555
|
+
} catch (error48) {
|
|
48556
|
+
const message = error48?.message || String(error48);
|
|
48557
|
+
LOG.error("MeshCoordinator", `Failed to build coordinator prompt: ${message}`);
|
|
48558
|
+
return {
|
|
48559
|
+
success: false,
|
|
48560
|
+
code: "mesh_coordinator_prompt_failed",
|
|
48561
|
+
error: `Failed to build Repo Mesh coordinator prompt: ${message}`,
|
|
48562
|
+
meshId,
|
|
48563
|
+
cliType,
|
|
48564
|
+
workspace
|
|
48565
|
+
};
|
|
48566
|
+
}
|
|
48567
|
+
const { existsSync: existsSync23, readFileSync: readFileSync15, writeFileSync: writeFileSync12, copyFileSync: copyFileSync3 } = await import("fs");
|
|
48292
48568
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
48293
|
-
const hadExistingMcpConfig =
|
|
48569
|
+
const hadExistingMcpConfig = existsSync23(mcpConfigPath);
|
|
48294
48570
|
let existingMcpConfig = {};
|
|
48295
48571
|
if (hadExistingMcpConfig) {
|
|
48296
48572
|
try {
|
|
@@ -48318,12 +48594,6 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
48318
48594
|
};
|
|
48319
48595
|
writeFileSync12(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf-8");
|
|
48320
48596
|
LOG.info("MeshCoordinator", `Wrote ${mcpConfigPath} with ${coordinatorSetup.serverName} server`);
|
|
48321
|
-
let systemPrompt = "";
|
|
48322
|
-
try {
|
|
48323
|
-
systemPrompt = buildCoordinatorSystemPrompt2({ mesh });
|
|
48324
|
-
} catch {
|
|
48325
|
-
systemPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}". Use the adhdev-mesh MCP tools (mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, etc.) to orchestrate work across ${mesh.nodes.length} node(s).`;
|
|
48326
|
-
}
|
|
48327
48597
|
const cliArgs = [];
|
|
48328
48598
|
if (systemPrompt) {
|
|
48329
48599
|
cliArgs.push("--append-system-prompt", systemPrompt);
|
|
@@ -49790,7 +50060,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49790
50060
|
this.eventListeners = [];
|
|
49791
50061
|
}
|
|
49792
50062
|
};
|
|
49793
|
-
ARCHIVE_PATH =
|
|
50063
|
+
ARCHIVE_PATH = path222.join(os19.homedir(), ".adhdev", "version-history.json");
|
|
49794
50064
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
49795
50065
|
VersionArchive = class {
|
|
49796
50066
|
history = {};
|
|
@@ -49837,7 +50107,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49837
50107
|
}
|
|
49838
50108
|
save() {
|
|
49839
50109
|
try {
|
|
49840
|
-
fs11.mkdirSync(
|
|
50110
|
+
fs11.mkdirSync(path222.dirname(ARCHIVE_PATH), { recursive: true });
|
|
49841
50111
|
fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
49842
50112
|
} catch {
|
|
49843
50113
|
}
|
|
@@ -49947,8 +50217,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
49947
50217
|
}
|
|
49948
50218
|
getEndpointList() {
|
|
49949
50219
|
return this.routes.map((r) => {
|
|
49950
|
-
const
|
|
49951
|
-
return `${r.method.padEnd(5)} ${
|
|
50220
|
+
const path27 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
50221
|
+
return `${r.method.padEnd(5)} ${path27}`;
|
|
49952
50222
|
});
|
|
49953
50223
|
}
|
|
49954
50224
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -50236,12 +50506,12 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50236
50506
|
// ─── DevConsole SPA ───
|
|
50237
50507
|
getConsoleDistDir() {
|
|
50238
50508
|
const candidates = [
|
|
50239
|
-
|
|
50240
|
-
|
|
50241
|
-
|
|
50509
|
+
path26.resolve(__dirname, "../../web-devconsole/dist"),
|
|
50510
|
+
path26.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
50511
|
+
path26.join(process.cwd(), "packages/web-devconsole/dist")
|
|
50242
50512
|
];
|
|
50243
50513
|
for (const dir of candidates) {
|
|
50244
|
-
if (fs15.existsSync(
|
|
50514
|
+
if (fs15.existsSync(path26.join(dir, "index.html"))) return dir;
|
|
50245
50515
|
}
|
|
50246
50516
|
return null;
|
|
50247
50517
|
}
|
|
@@ -50251,7 +50521,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50251
50521
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
50252
50522
|
return;
|
|
50253
50523
|
}
|
|
50254
|
-
const htmlPath =
|
|
50524
|
+
const htmlPath = path26.join(distDir, "index.html");
|
|
50255
50525
|
try {
|
|
50256
50526
|
const html = fs15.readFileSync(htmlPath, "utf-8");
|
|
50257
50527
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -50276,15 +50546,15 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50276
50546
|
this.json(res, 404, { error: "Not found" });
|
|
50277
50547
|
return;
|
|
50278
50548
|
}
|
|
50279
|
-
const safePath =
|
|
50280
|
-
const filePath =
|
|
50549
|
+
const safePath = path26.normalize(pathname).replace(/^\.\.\//, "");
|
|
50550
|
+
const filePath = path26.join(distDir, safePath);
|
|
50281
50551
|
if (!filePath.startsWith(distDir)) {
|
|
50282
50552
|
this.json(res, 403, { error: "Forbidden" });
|
|
50283
50553
|
return;
|
|
50284
50554
|
}
|
|
50285
50555
|
try {
|
|
50286
50556
|
const content = fs15.readFileSync(filePath);
|
|
50287
|
-
const ext =
|
|
50557
|
+
const ext = path26.extname(filePath);
|
|
50288
50558
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
50289
50559
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
50290
50560
|
res.end(content);
|
|
@@ -50397,9 +50667,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50397
50667
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
50398
50668
|
if (entry.isDirectory()) {
|
|
50399
50669
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
50400
|
-
scan(
|
|
50670
|
+
scan(path26.join(d, entry.name), rel);
|
|
50401
50671
|
} else {
|
|
50402
|
-
const stat22 = fs15.statSync(
|
|
50672
|
+
const stat22 = fs15.statSync(path26.join(d, entry.name));
|
|
50403
50673
|
files.push({ path: rel, size: stat22.size, type: "file" });
|
|
50404
50674
|
}
|
|
50405
50675
|
}
|
|
@@ -50422,7 +50692,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50422
50692
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
50423
50693
|
return;
|
|
50424
50694
|
}
|
|
50425
|
-
const fullPath =
|
|
50695
|
+
const fullPath = path26.resolve(dir, path26.normalize(filePath));
|
|
50426
50696
|
if (!fullPath.startsWith(dir)) {
|
|
50427
50697
|
this.json(res, 403, { error: "Forbidden" });
|
|
50428
50698
|
return;
|
|
@@ -50447,14 +50717,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50447
50717
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
50448
50718
|
return;
|
|
50449
50719
|
}
|
|
50450
|
-
const fullPath =
|
|
50720
|
+
const fullPath = path26.resolve(dir, path26.normalize(filePath));
|
|
50451
50721
|
if (!fullPath.startsWith(dir)) {
|
|
50452
50722
|
this.json(res, 403, { error: "Forbidden" });
|
|
50453
50723
|
return;
|
|
50454
50724
|
}
|
|
50455
50725
|
try {
|
|
50456
50726
|
if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
|
|
50457
|
-
fs15.mkdirSync(
|
|
50727
|
+
fs15.mkdirSync(path26.dirname(fullPath), { recursive: true });
|
|
50458
50728
|
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
50459
50729
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
50460
50730
|
this.providerLoader.reload();
|
|
@@ -50471,7 +50741,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50471
50741
|
return;
|
|
50472
50742
|
}
|
|
50473
50743
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
50474
|
-
const p =
|
|
50744
|
+
const p = path26.join(dir, name);
|
|
50475
50745
|
if (fs15.existsSync(p)) {
|
|
50476
50746
|
const source = fs15.readFileSync(p, "utf-8");
|
|
50477
50747
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
@@ -50492,8 +50762,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50492
50762
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
50493
50763
|
return;
|
|
50494
50764
|
}
|
|
50495
|
-
const target = fs15.existsSync(
|
|
50496
|
-
const targetPath =
|
|
50765
|
+
const target = fs15.existsSync(path26.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
50766
|
+
const targetPath = path26.join(dir, target);
|
|
50497
50767
|
try {
|
|
50498
50768
|
if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
|
|
50499
50769
|
fs15.writeFileSync(targetPath, source, "utf-8");
|
|
@@ -50640,7 +50910,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50640
50910
|
}
|
|
50641
50911
|
let targetDir;
|
|
50642
50912
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
50643
|
-
const jsonPath =
|
|
50913
|
+
const jsonPath = path26.join(targetDir, "provider.json");
|
|
50644
50914
|
if (fs15.existsSync(jsonPath)) {
|
|
50645
50915
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
50646
50916
|
return;
|
|
@@ -50652,8 +50922,8 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50652
50922
|
const createdFiles = ["provider.json"];
|
|
50653
50923
|
if (result.files) {
|
|
50654
50924
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
50655
|
-
const fullPath =
|
|
50656
|
-
fs15.mkdirSync(
|
|
50925
|
+
const fullPath = path26.join(targetDir, relPath);
|
|
50926
|
+
fs15.mkdirSync(path26.dirname(fullPath), { recursive: true });
|
|
50657
50927
|
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
50658
50928
|
createdFiles.push(relPath);
|
|
50659
50929
|
}
|
|
@@ -50706,22 +50976,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50706
50976
|
if (!fs15.existsSync(scriptsDir)) return null;
|
|
50707
50977
|
const versions = fs15.readdirSync(scriptsDir).filter((d) => {
|
|
50708
50978
|
try {
|
|
50709
|
-
return fs15.statSync(
|
|
50979
|
+
return fs15.statSync(path26.join(scriptsDir, d)).isDirectory();
|
|
50710
50980
|
} catch {
|
|
50711
50981
|
return false;
|
|
50712
50982
|
}
|
|
50713
50983
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
50714
50984
|
if (versions.length === 0) return null;
|
|
50715
|
-
return
|
|
50985
|
+
return path26.join(scriptsDir, versions[0]);
|
|
50716
50986
|
}
|
|
50717
50987
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
50718
|
-
const canonicalUserDir =
|
|
50719
|
-
const desiredDir = requestedDir ?
|
|
50720
|
-
const upstreamRoot =
|
|
50721
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
50988
|
+
const canonicalUserDir = path26.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
50989
|
+
const desiredDir = requestedDir ? path26.resolve(requestedDir) : canonicalUserDir;
|
|
50990
|
+
const upstreamRoot = path26.resolve(this.providerLoader.getUpstreamDir());
|
|
50991
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path26.sep}`)) {
|
|
50722
50992
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
50723
50993
|
}
|
|
50724
|
-
if (
|
|
50994
|
+
if (path26.basename(desiredDir) !== type) {
|
|
50725
50995
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
50726
50996
|
}
|
|
50727
50997
|
const sourceDir = this.findProviderDir(type);
|
|
@@ -50729,11 +50999,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50729
50999
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
50730
51000
|
}
|
|
50731
51001
|
if (!fs15.existsSync(desiredDir)) {
|
|
50732
|
-
fs15.mkdirSync(
|
|
51002
|
+
fs15.mkdirSync(path26.dirname(desiredDir), { recursive: true });
|
|
50733
51003
|
fs15.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
50734
51004
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
50735
51005
|
}
|
|
50736
|
-
const providerJson =
|
|
51006
|
+
const providerJson = path26.join(desiredDir, "provider.json");
|
|
50737
51007
|
if (!fs15.existsSync(providerJson)) {
|
|
50738
51008
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
50739
51009
|
}
|
|
@@ -50769,7 +51039,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50769
51039
|
setMode: "set_mode.js"
|
|
50770
51040
|
};
|
|
50771
51041
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
50772
|
-
const scriptsDir =
|
|
51042
|
+
const scriptsDir = path26.join(providerDir, "scripts");
|
|
50773
51043
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
50774
51044
|
if (latestScriptsDir) {
|
|
50775
51045
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -50780,7 +51050,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50780
51050
|
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
50781
51051
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
50782
51052
|
try {
|
|
50783
|
-
const content = fs15.readFileSync(
|
|
51053
|
+
const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
|
|
50784
51054
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
50785
51055
|
lines.push("```javascript");
|
|
50786
51056
|
lines.push(content);
|
|
@@ -50797,7 +51067,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50797
51067
|
lines.push("");
|
|
50798
51068
|
for (const file2 of refFiles) {
|
|
50799
51069
|
try {
|
|
50800
|
-
const content = fs15.readFileSync(
|
|
51070
|
+
const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
|
|
50801
51071
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
50802
51072
|
lines.push("```javascript");
|
|
50803
51073
|
lines.push(content);
|
|
@@ -50838,10 +51108,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
50838
51108
|
lines.push("");
|
|
50839
51109
|
}
|
|
50840
51110
|
}
|
|
50841
|
-
const docsDir =
|
|
51111
|
+
const docsDir = path26.join(providerDir, "../../docs");
|
|
50842
51112
|
const loadGuide = (name) => {
|
|
50843
51113
|
try {
|
|
50844
|
-
const p =
|
|
51114
|
+
const p = path26.join(docsDir, name);
|
|
50845
51115
|
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
50846
51116
|
} catch {
|
|
50847
51117
|
}
|
|
@@ -51015,7 +51285,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
51015
51285
|
parseApproval: "parse_approval.js"
|
|
51016
51286
|
};
|
|
51017
51287
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
51018
|
-
const scriptsDir =
|
|
51288
|
+
const scriptsDir = path26.join(providerDir, "scripts");
|
|
51019
51289
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
51020
51290
|
if (latestScriptsDir) {
|
|
51021
51291
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -51027,7 +51297,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
51027
51297
|
if (!file2.endsWith(".js")) continue;
|
|
51028
51298
|
if (!targetFileNames.has(file2)) continue;
|
|
51029
51299
|
try {
|
|
51030
|
-
const content = fs15.readFileSync(
|
|
51300
|
+
const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
|
|
51031
51301
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
51032
51302
|
lines.push("```javascript");
|
|
51033
51303
|
lines.push(content);
|
|
@@ -51043,7 +51313,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
51043
51313
|
lines.push("");
|
|
51044
51314
|
for (const file2 of refFiles) {
|
|
51045
51315
|
try {
|
|
51046
|
-
const content = fs15.readFileSync(
|
|
51316
|
+
const content = fs15.readFileSync(path26.join(latestScriptsDir, file2), "utf-8");
|
|
51047
51317
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
51048
51318
|
lines.push("```javascript");
|
|
51049
51319
|
lines.push(content);
|
|
@@ -51076,10 +51346,10 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
51076
51346
|
lines.push("");
|
|
51077
51347
|
}
|
|
51078
51348
|
}
|
|
51079
|
-
const docsDir =
|
|
51349
|
+
const docsDir = path26.join(providerDir, "../../docs");
|
|
51080
51350
|
const loadGuide = (name) => {
|
|
51081
51351
|
try {
|
|
51082
|
-
const p =
|
|
51352
|
+
const p = path26.join(docsDir, name);
|
|
51083
51353
|
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
51084
51354
|
} catch {
|
|
51085
51355
|
}
|
|
@@ -53277,12 +53547,12 @@ var MESH_READ_CHAT_TOOL = {
|
|
|
53277
53547
|
};
|
|
53278
53548
|
var MESH_LAUNCH_SESSION_TOOL = {
|
|
53279
53549
|
name: "mesh_launch_session",
|
|
53280
|
-
description: "Launch a new agent session on a mesh node. Returns the session ID for subsequent send_task/read_chat calls.",
|
|
53550
|
+
description: "Launch a new agent session on a mesh node. Returns the session ID for subsequent send_task/read_chat calls. If the user names a provider, preserve it exactly: Hermes = hermes-cli, Claude Code/Claude = claude-cli, Codex = codex-cli, Gemini = gemini-cli. Do not default to claude-cli unless the user requested Claude Code or no provider was specified.",
|
|
53281
53551
|
inputSchema: {
|
|
53282
53552
|
type: "object",
|
|
53283
53553
|
properties: {
|
|
53284
53554
|
node_id: { type: "string", description: "Target node ID." },
|
|
53285
|
-
type: { type: "string", description:
|
|
53555
|
+
type: { type: "string", description: "Provider type to launch. Use hermes-cli for Hermes, claude-cli for Claude Code, codex-cli for Codex, gemini-cli for Gemini." }
|
|
53286
53556
|
},
|
|
53287
53557
|
required: ["node_id", "type"]
|
|
53288
53558
|
}
|
|
@@ -53323,6 +53593,30 @@ var MESH_APPROVE_TOOL = {
|
|
|
53323
53593
|
required: ["node_id", "session_id", "action"]
|
|
53324
53594
|
}
|
|
53325
53595
|
};
|
|
53596
|
+
var MESH_CLONE_NODE_TOOL = {
|
|
53597
|
+
name: "mesh_clone_node",
|
|
53598
|
+
description: "Create a new worktree-based node from an existing node for isolated parallel work. Creates a git worktree on a new branch so multiple tasks can run on separate branches simultaneously.",
|
|
53599
|
+
inputSchema: {
|
|
53600
|
+
type: "object",
|
|
53601
|
+
properties: {
|
|
53602
|
+
source_node_id: { type: "string", description: "Node ID to clone from (from mesh_list_nodes)." },
|
|
53603
|
+
branch: { type: "string", description: 'Branch name for the new worktree (e.g. "feat/auth-refactor").' },
|
|
53604
|
+
base_branch: { type: "string", description: "Starting point for the branch (default: current HEAD)." }
|
|
53605
|
+
},
|
|
53606
|
+
required: ["source_node_id", "branch"]
|
|
53607
|
+
}
|
|
53608
|
+
};
|
|
53609
|
+
var MESH_REMOVE_NODE_TOOL = {
|
|
53610
|
+
name: "mesh_remove_node",
|
|
53611
|
+
description: "Remove a node from the mesh. If the node is a worktree, also cleans up the git worktree and directory.",
|
|
53612
|
+
inputSchema: {
|
|
53613
|
+
type: "object",
|
|
53614
|
+
properties: {
|
|
53615
|
+
node_id: { type: "string", description: "Node ID to remove." }
|
|
53616
|
+
},
|
|
53617
|
+
required: ["node_id"]
|
|
53618
|
+
}
|
|
53619
|
+
};
|
|
53326
53620
|
var ALL_MESH_TOOLS = [
|
|
53327
53621
|
MESH_STATUS_TOOL,
|
|
53328
53622
|
MESH_LIST_NODES_TOOL,
|
|
@@ -53331,7 +53625,9 @@ var ALL_MESH_TOOLS = [
|
|
|
53331
53625
|
MESH_LAUNCH_SESSION_TOOL,
|
|
53332
53626
|
MESH_GIT_STATUS_TOOL,
|
|
53333
53627
|
MESH_CHECKPOINT_TOOL,
|
|
53334
|
-
MESH_APPROVE_TOOL
|
|
53628
|
+
MESH_APPROVE_TOOL,
|
|
53629
|
+
MESH_CLONE_NODE_TOOL,
|
|
53630
|
+
MESH_REMOVE_NODE_TOOL
|
|
53335
53631
|
];
|
|
53336
53632
|
async function meshStatus(ctx) {
|
|
53337
53633
|
const { mesh, transport } = ctx;
|
|
@@ -53490,8 +53786,57 @@ async function meshApprove(ctx, args) {
|
|
|
53490
53786
|
return JSON.stringify({ error: "Cloud mesh approve not yet implemented" });
|
|
53491
53787
|
}
|
|
53492
53788
|
}
|
|
53789
|
+
async function meshCloneNode(ctx, args) {
|
|
53790
|
+
const sourceNode = findNode(ctx.mesh, args.source_node_id);
|
|
53791
|
+
if (isLocalTransport(ctx.transport)) {
|
|
53792
|
+
const result = await commandForNode(ctx, sourceNode, "clone_mesh_node", {
|
|
53793
|
+
meshId: ctx.mesh.id,
|
|
53794
|
+
sourceNodeId: args.source_node_id,
|
|
53795
|
+
branch: args.branch,
|
|
53796
|
+
baseBranch: args.base_branch,
|
|
53797
|
+
inlineMesh: ctx.mesh
|
|
53798
|
+
});
|
|
53799
|
+
if (result?.success && result.node?.id) {
|
|
53800
|
+
const existingIndex = ctx.mesh.nodes.findIndex((n) => n.id === result.node.id);
|
|
53801
|
+
if (existingIndex >= 0) ctx.mesh.nodes[existingIndex] = result.node;
|
|
53802
|
+
else ctx.mesh.nodes.push(result.node);
|
|
53803
|
+
ctx.mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
53804
|
+
}
|
|
53805
|
+
return JSON.stringify(result, null, 2);
|
|
53806
|
+
} else {
|
|
53807
|
+
return JSON.stringify({ error: "Cloud mesh clone_node not yet implemented" });
|
|
53808
|
+
}
|
|
53809
|
+
}
|
|
53810
|
+
async function meshRemoveNode(ctx, args) {
|
|
53811
|
+
const node = findNode(ctx.mesh, args.node_id);
|
|
53812
|
+
if (isLocalTransport(ctx.transport)) {
|
|
53813
|
+
const result = await commandForNode(ctx, node, "remove_mesh_node", {
|
|
53814
|
+
meshId: ctx.mesh.id,
|
|
53815
|
+
nodeId: args.node_id,
|
|
53816
|
+
inlineMesh: ctx.mesh
|
|
53817
|
+
});
|
|
53818
|
+
if (result?.success && result.removed !== false) {
|
|
53819
|
+
const idx = ctx.mesh.nodes.findIndex((n) => n.id === args.node_id);
|
|
53820
|
+
if (idx >= 0) {
|
|
53821
|
+
ctx.mesh.nodes.splice(idx, 1);
|
|
53822
|
+
ctx.mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
53823
|
+
}
|
|
53824
|
+
}
|
|
53825
|
+
return JSON.stringify(result, null, 2);
|
|
53826
|
+
} else {
|
|
53827
|
+
return JSON.stringify({ error: "Cloud mesh remove_node not yet implemented" });
|
|
53828
|
+
}
|
|
53829
|
+
}
|
|
53493
53830
|
|
|
53494
53831
|
// src/server.ts
|
|
53832
|
+
async function buildMeshModeCoordinatorPrompt(mesh) {
|
|
53833
|
+
try {
|
|
53834
|
+
const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
53835
|
+
return buildCoordinatorSystemPrompt2({ mesh });
|
|
53836
|
+
} catch (e) {
|
|
53837
|
+
throw new Error(`Failed to build Repo Mesh coordinator prompt: ${e?.message ?? String(e)}`);
|
|
53838
|
+
}
|
|
53839
|
+
}
|
|
53495
53840
|
async function startMcpServer(opts) {
|
|
53496
53841
|
const transport = opts.mode === "cloud" ? new CloudTransport({ apiKey: opts.apiKey, baseUrl: opts.baseUrl }) : opts.mode === "ipc" ? new IpcTransport({ port: opts.port }) : new LocalTransport({ port: opts.port, password: opts.password });
|
|
53497
53842
|
const alive = await transport.ping();
|
|
@@ -53598,13 +53943,7 @@ async function startMcpServer(opts) {
|
|
|
53598
53943
|
process.exit(1);
|
|
53599
53944
|
}
|
|
53600
53945
|
const meshCtx = { mesh, transport };
|
|
53601
|
-
|
|
53602
|
-
try {
|
|
53603
|
-
const { buildCoordinatorSystemPrompt: buildCoordinatorSystemPrompt2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
53604
|
-
coordinatorPrompt = buildCoordinatorSystemPrompt2({ mesh });
|
|
53605
|
-
} catch {
|
|
53606
|
-
coordinatorPrompt = `You are a Repo Mesh Coordinator for "${mesh.name}" (${mesh.repoIdentity}). Use mesh_* tools to orchestrate work.`;
|
|
53607
|
-
}
|
|
53946
|
+
const coordinatorPrompt = await buildMeshModeCoordinatorPrompt(mesh);
|
|
53608
53947
|
const server2 = new import_server.Server(
|
|
53609
53948
|
{ name: "adhdev-mcp-server", version: "0.9.75" },
|
|
53610
53949
|
{ capabilities: { tools: {}, resources: {} } }
|
|
@@ -53655,6 +53994,12 @@ async function startMcpServer(opts) {
|
|
|
53655
53994
|
case "mesh_approve":
|
|
53656
53995
|
text = await meshApprove(meshCtx, a);
|
|
53657
53996
|
break;
|
|
53997
|
+
case "mesh_clone_node":
|
|
53998
|
+
text = await meshCloneNode(meshCtx, a);
|
|
53999
|
+
break;
|
|
54000
|
+
case "mesh_remove_node":
|
|
54001
|
+
text = await meshRemoveNode(meshCtx, a);
|
|
54002
|
+
break;
|
|
53658
54003
|
default:
|
|
53659
54004
|
return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
|
|
53660
54005
|
}
|
|
@@ -53856,7 +54201,7 @@ Environment variables:
|
|
|
53856
54201
|
ADHDEV_MCP_TRANSPORT Transport: local, cloud, or ipc
|
|
53857
54202
|
|
|
53858
54203
|
Standard tools: list_daemons, list_sessions, launch_session, stop_session, check_pending, read_chat, send_chat, approve, git_status, git_log, git_diff, git_checkpoint, git_push, screenshot
|
|
53859
|
-
Mesh tools: mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, mesh_git_status, mesh_checkpoint, mesh_approve
|
|
54204
|
+
Mesh tools: mesh_status, mesh_list_nodes, mesh_send_task, mesh_read_chat, mesh_launch_session, mesh_git_status, mesh_checkpoint, mesh_approve, mesh_clone_node, mesh_remove_node
|
|
53860
54205
|
`.trim());
|
|
53861
54206
|
}
|
|
53862
54207
|
startMcpServer(parseArgs(process.argv)).catch((err) => {
|