@kenkaiiii/gg-boss 4.8.7 → 4.9.0
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.
|
@@ -3225,8 +3225,8 @@ var require_utils = __commonJS({
|
|
|
3225
3225
|
}
|
|
3226
3226
|
return ind;
|
|
3227
3227
|
}
|
|
3228
|
-
function removeDotSegments(
|
|
3229
|
-
let input =
|
|
3228
|
+
function removeDotSegments(path45) {
|
|
3229
|
+
let input = path45;
|
|
3230
3230
|
const output = [];
|
|
3231
3231
|
let nextSlash = -1;
|
|
3232
3232
|
let len = 0;
|
|
@@ -3426,8 +3426,8 @@ var require_schemes = __commonJS({
|
|
|
3426
3426
|
wsComponent.secure = void 0;
|
|
3427
3427
|
}
|
|
3428
3428
|
if (wsComponent.resourceName) {
|
|
3429
|
-
const [
|
|
3430
|
-
wsComponent.path =
|
|
3429
|
+
const [path45, query] = wsComponent.resourceName.split("?");
|
|
3430
|
+
wsComponent.path = path45 && path45 !== "/" ? path45 : void 0;
|
|
3431
3431
|
wsComponent.query = query;
|
|
3432
3432
|
wsComponent.resourceName = void 0;
|
|
3433
3433
|
}
|
|
@@ -6835,12 +6835,12 @@ var require_dist = __commonJS({
|
|
|
6835
6835
|
throw new Error(`Unknown format "${name}"`);
|
|
6836
6836
|
return f;
|
|
6837
6837
|
};
|
|
6838
|
-
function addFormats(ajv, list,
|
|
6838
|
+
function addFormats(ajv, list, fs38, exportName) {
|
|
6839
6839
|
var _a6;
|
|
6840
6840
|
var _b;
|
|
6841
6841
|
(_a6 = (_b = ajv.opts.code).formats) !== null && _a6 !== void 0 ? _a6 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6842
6842
|
for (const f of list)
|
|
6843
|
-
ajv.addFormat(f,
|
|
6843
|
+
ajv.addFormat(f, fs38[f]);
|
|
6844
6844
|
}
|
|
6845
6845
|
module.exports = exports = formatsPlugin;
|
|
6846
6846
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6855,8 +6855,8 @@ var require_windows = __commonJS({
|
|
|
6855
6855
|
init_esm_shims();
|
|
6856
6856
|
module.exports = isexe;
|
|
6857
6857
|
isexe.sync = sync;
|
|
6858
|
-
var
|
|
6859
|
-
function checkPathExt(
|
|
6858
|
+
var fs38 = __require("fs");
|
|
6859
|
+
function checkPathExt(path45, options) {
|
|
6860
6860
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
6861
6861
|
if (!pathext) {
|
|
6862
6862
|
return true;
|
|
@@ -6867,25 +6867,25 @@ var require_windows = __commonJS({
|
|
|
6867
6867
|
}
|
|
6868
6868
|
for (var i = 0; i < pathext.length; i++) {
|
|
6869
6869
|
var p = pathext[i].toLowerCase();
|
|
6870
|
-
if (p &&
|
|
6870
|
+
if (p && path45.substr(-p.length).toLowerCase() === p) {
|
|
6871
6871
|
return true;
|
|
6872
6872
|
}
|
|
6873
6873
|
}
|
|
6874
6874
|
return false;
|
|
6875
6875
|
}
|
|
6876
|
-
function checkStat(stat,
|
|
6876
|
+
function checkStat(stat, path45, options) {
|
|
6877
6877
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
6878
6878
|
return false;
|
|
6879
6879
|
}
|
|
6880
|
-
return checkPathExt(
|
|
6880
|
+
return checkPathExt(path45, options);
|
|
6881
6881
|
}
|
|
6882
|
-
function isexe(
|
|
6883
|
-
|
|
6884
|
-
cb(er, er ? false : checkStat(stat,
|
|
6882
|
+
function isexe(path45, options, cb) {
|
|
6883
|
+
fs38.stat(path45, function(er, stat) {
|
|
6884
|
+
cb(er, er ? false : checkStat(stat, path45, options));
|
|
6885
6885
|
});
|
|
6886
6886
|
}
|
|
6887
|
-
function sync(
|
|
6888
|
-
return checkStat(
|
|
6887
|
+
function sync(path45, options) {
|
|
6888
|
+
return checkStat(fs38.statSync(path45), path45, options);
|
|
6889
6889
|
}
|
|
6890
6890
|
}
|
|
6891
6891
|
});
|
|
@@ -6897,14 +6897,14 @@ var require_mode = __commonJS({
|
|
|
6897
6897
|
init_esm_shims();
|
|
6898
6898
|
module.exports = isexe;
|
|
6899
6899
|
isexe.sync = sync;
|
|
6900
|
-
var
|
|
6901
|
-
function isexe(
|
|
6902
|
-
|
|
6900
|
+
var fs38 = __require("fs");
|
|
6901
|
+
function isexe(path45, options, cb) {
|
|
6902
|
+
fs38.stat(path45, function(er, stat) {
|
|
6903
6903
|
cb(er, er ? false : checkStat(stat, options));
|
|
6904
6904
|
});
|
|
6905
6905
|
}
|
|
6906
|
-
function sync(
|
|
6907
|
-
return checkStat(
|
|
6906
|
+
function sync(path45, options) {
|
|
6907
|
+
return checkStat(fs38.statSync(path45), options);
|
|
6908
6908
|
}
|
|
6909
6909
|
function checkStat(stat, options) {
|
|
6910
6910
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -6930,7 +6930,7 @@ var require_isexe = __commonJS({
|
|
|
6930
6930
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
6931
6931
|
"use strict";
|
|
6932
6932
|
init_esm_shims();
|
|
6933
|
-
var
|
|
6933
|
+
var fs38 = __require("fs");
|
|
6934
6934
|
var core;
|
|
6935
6935
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
6936
6936
|
core = require_windows();
|
|
@@ -6939,7 +6939,7 @@ var require_isexe = __commonJS({
|
|
|
6939
6939
|
}
|
|
6940
6940
|
module.exports = isexe;
|
|
6941
6941
|
isexe.sync = sync;
|
|
6942
|
-
function isexe(
|
|
6942
|
+
function isexe(path45, options, cb) {
|
|
6943
6943
|
if (typeof options === "function") {
|
|
6944
6944
|
cb = options;
|
|
6945
6945
|
options = {};
|
|
@@ -6949,7 +6949,7 @@ var require_isexe = __commonJS({
|
|
|
6949
6949
|
throw new TypeError("callback not provided");
|
|
6950
6950
|
}
|
|
6951
6951
|
return new Promise(function(resolve2, reject) {
|
|
6952
|
-
isexe(
|
|
6952
|
+
isexe(path45, options || {}, function(er, is) {
|
|
6953
6953
|
if (er) {
|
|
6954
6954
|
reject(er);
|
|
6955
6955
|
} else {
|
|
@@ -6958,7 +6958,7 @@ var require_isexe = __commonJS({
|
|
|
6958
6958
|
});
|
|
6959
6959
|
});
|
|
6960
6960
|
}
|
|
6961
|
-
core(
|
|
6961
|
+
core(path45, options || {}, function(er, is) {
|
|
6962
6962
|
if (er) {
|
|
6963
6963
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
6964
6964
|
er = null;
|
|
@@ -6968,9 +6968,9 @@ var require_isexe = __commonJS({
|
|
|
6968
6968
|
cb(er, is);
|
|
6969
6969
|
});
|
|
6970
6970
|
}
|
|
6971
|
-
function sync(
|
|
6971
|
+
function sync(path45, options) {
|
|
6972
6972
|
try {
|
|
6973
|
-
return core.sync(
|
|
6973
|
+
return core.sync(path45, options || {});
|
|
6974
6974
|
} catch (er) {
|
|
6975
6975
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
6976
6976
|
return false;
|
|
@@ -6988,7 +6988,7 @@ var require_which = __commonJS({
|
|
|
6988
6988
|
"use strict";
|
|
6989
6989
|
init_esm_shims();
|
|
6990
6990
|
var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
6991
|
-
var
|
|
6991
|
+
var path45 = __require("path");
|
|
6992
6992
|
var COLON = isWindows3 ? ";" : ":";
|
|
6993
6993
|
var isexe = require_isexe();
|
|
6994
6994
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -7026,7 +7026,7 @@ var require_which = __commonJS({
|
|
|
7026
7026
|
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
7027
7027
|
const ppRaw = pathEnv[i];
|
|
7028
7028
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
7029
|
-
const pCmd =
|
|
7029
|
+
const pCmd = path45.join(pathPart, cmd);
|
|
7030
7030
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
7031
7031
|
resolve2(subStep(p, i, 0));
|
|
7032
7032
|
});
|
|
@@ -7053,7 +7053,7 @@ var require_which = __commonJS({
|
|
|
7053
7053
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
7054
7054
|
const ppRaw = pathEnv[i];
|
|
7055
7055
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
7056
|
-
const pCmd =
|
|
7056
|
+
const pCmd = path45.join(pathPart, cmd);
|
|
7057
7057
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
7058
7058
|
for (let j = 0; j < pathExt.length; j++) {
|
|
7059
7059
|
const cur = p + pathExt[j];
|
|
@@ -7103,7 +7103,7 @@ var require_resolveCommand = __commonJS({
|
|
|
7103
7103
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
7104
7104
|
"use strict";
|
|
7105
7105
|
init_esm_shims();
|
|
7106
|
-
var
|
|
7106
|
+
var path45 = __require("path");
|
|
7107
7107
|
var which = require_which();
|
|
7108
7108
|
var getPathKey = require_path_key();
|
|
7109
7109
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -7121,7 +7121,7 @@ var require_resolveCommand = __commonJS({
|
|
|
7121
7121
|
try {
|
|
7122
7122
|
resolved = which.sync(parsed.command, {
|
|
7123
7123
|
path: env2[getPathKey({ env: env2 })],
|
|
7124
|
-
pathExt: withoutPathExt ?
|
|
7124
|
+
pathExt: withoutPathExt ? path45.delimiter : void 0
|
|
7125
7125
|
});
|
|
7126
7126
|
} catch (e) {
|
|
7127
7127
|
} finally {
|
|
@@ -7130,7 +7130,7 @@ var require_resolveCommand = __commonJS({
|
|
|
7130
7130
|
}
|
|
7131
7131
|
}
|
|
7132
7132
|
if (resolved) {
|
|
7133
|
-
resolved =
|
|
7133
|
+
resolved = path45.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
7134
7134
|
}
|
|
7135
7135
|
return resolved;
|
|
7136
7136
|
}
|
|
@@ -7187,8 +7187,8 @@ var require_shebang_command = __commonJS({
|
|
|
7187
7187
|
if (!match) {
|
|
7188
7188
|
return null;
|
|
7189
7189
|
}
|
|
7190
|
-
const [
|
|
7191
|
-
const binary =
|
|
7190
|
+
const [path45, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
7191
|
+
const binary = path45.split("/").pop();
|
|
7192
7192
|
if (binary === "env") {
|
|
7193
7193
|
return argument;
|
|
7194
7194
|
}
|
|
@@ -7202,16 +7202,16 @@ var require_readShebang = __commonJS({
|
|
|
7202
7202
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
7203
7203
|
"use strict";
|
|
7204
7204
|
init_esm_shims();
|
|
7205
|
-
var
|
|
7205
|
+
var fs38 = __require("fs");
|
|
7206
7206
|
var shebangCommand = require_shebang_command();
|
|
7207
7207
|
function readShebang(command) {
|
|
7208
7208
|
const size = 150;
|
|
7209
7209
|
const buffer = Buffer.alloc(size);
|
|
7210
7210
|
let fd2;
|
|
7211
7211
|
try {
|
|
7212
|
-
fd2 =
|
|
7213
|
-
|
|
7214
|
-
|
|
7212
|
+
fd2 = fs38.openSync(command, "r");
|
|
7213
|
+
fs38.readSync(fd2, buffer, 0, size, 0);
|
|
7214
|
+
fs38.closeSync(fd2);
|
|
7215
7215
|
} catch (e) {
|
|
7216
7216
|
}
|
|
7217
7217
|
return shebangCommand(buffer.toString());
|
|
@@ -7225,7 +7225,7 @@ var require_parse = __commonJS({
|
|
|
7225
7225
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
7226
7226
|
"use strict";
|
|
7227
7227
|
init_esm_shims();
|
|
7228
|
-
var
|
|
7228
|
+
var path45 = __require("path");
|
|
7229
7229
|
var resolveCommand = require_resolveCommand();
|
|
7230
7230
|
var escape4 = require_escape();
|
|
7231
7231
|
var readShebang = require_readShebang();
|
|
@@ -7250,7 +7250,7 @@ var require_parse = __commonJS({
|
|
|
7250
7250
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
7251
7251
|
if (parsed.options.forceShell || needsShell) {
|
|
7252
7252
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
7253
|
-
parsed.command =
|
|
7253
|
+
parsed.command = path45.normalize(parsed.command);
|
|
7254
7254
|
parsed.command = escape4.command(parsed.command);
|
|
7255
7255
|
parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
|
|
7256
7256
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -7342,7 +7342,7 @@ var require_cross_spawn = __commonJS({
|
|
|
7342
7342
|
var cp = __require("child_process");
|
|
7343
7343
|
var parse3 = require_parse();
|
|
7344
7344
|
var enoent = require_enoent();
|
|
7345
|
-
function
|
|
7345
|
+
function spawn9(command, args, options) {
|
|
7346
7346
|
const parsed = parse3(command, args, options);
|
|
7347
7347
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
7348
7348
|
enoent.hookChildProcess(spawned, parsed);
|
|
@@ -7354,8 +7354,8 @@ var require_cross_spawn = __commonJS({
|
|
|
7354
7354
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
7355
7355
|
return result;
|
|
7356
7356
|
}
|
|
7357
|
-
module.exports =
|
|
7358
|
-
module.exports.spawn =
|
|
7357
|
+
module.exports = spawn9;
|
|
7358
|
+
module.exports.spawn = spawn9;
|
|
7359
7359
|
module.exports.sync = spawnSync2;
|
|
7360
7360
|
module.exports._parse = parse3;
|
|
7361
7361
|
module.exports._enoent = enoent;
|
|
@@ -17765,10 +17765,10 @@ var require_react_reconciler_development = __commonJS({
|
|
|
17765
17765
|
fiber = fiber.next, id2--;
|
|
17766
17766
|
return fiber;
|
|
17767
17767
|
}
|
|
17768
|
-
function copyWithSetImpl(obj,
|
|
17769
|
-
if (index >=
|
|
17770
|
-
var key =
|
|
17771
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
17768
|
+
function copyWithSetImpl(obj, path45, index, value) {
|
|
17769
|
+
if (index >= path45.length) return value;
|
|
17770
|
+
var key = path45[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
|
|
17771
|
+
updated[key] = copyWithSetImpl(obj[key], path45, index + 1, value);
|
|
17772
17772
|
return updated;
|
|
17773
17773
|
}
|
|
17774
17774
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -17795,11 +17795,11 @@ var require_react_reconciler_development = __commonJS({
|
|
|
17795
17795
|
);
|
|
17796
17796
|
return updated;
|
|
17797
17797
|
}
|
|
17798
|
-
function copyWithDeleteImpl(obj,
|
|
17799
|
-
var key =
|
|
17800
|
-
if (index + 1 ===
|
|
17798
|
+
function copyWithDeleteImpl(obj, path45, index) {
|
|
17799
|
+
var key = path45[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
|
|
17800
|
+
if (index + 1 === path45.length)
|
|
17801
17801
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
17802
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
17802
|
+
updated[key] = copyWithDeleteImpl(obj[key], path45, index + 1);
|
|
17803
17803
|
return updated;
|
|
17804
17804
|
}
|
|
17805
17805
|
function shouldSuspendImpl() {
|
|
@@ -31076,29 +31076,29 @@ var require_react_reconciler_development = __commonJS({
|
|
|
31076
31076
|
var didWarnAboutNestedUpdates = false;
|
|
31077
31077
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
31078
31078
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, scheduleRetry = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
31079
|
-
overrideHookState = function(fiber, id2,
|
|
31079
|
+
overrideHookState = function(fiber, id2, path45, value) {
|
|
31080
31080
|
id2 = findHook(fiber, id2);
|
|
31081
|
-
null !== id2 && (
|
|
31081
|
+
null !== id2 && (path45 = copyWithSetImpl(id2.memoizedState, path45, 0, value), id2.memoizedState = path45, id2.baseState = path45, fiber.memoizedProps = assign({}, fiber.memoizedProps), path45 = enqueueConcurrentRenderForLane(fiber, 2), null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2));
|
|
31082
31082
|
};
|
|
31083
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
31083
|
+
overrideHookStateDeletePath = function(fiber, id2, path45) {
|
|
31084
31084
|
id2 = findHook(fiber, id2);
|
|
31085
|
-
null !== id2 && (
|
|
31085
|
+
null !== id2 && (path45 = copyWithDeleteImpl(id2.memoizedState, path45, 0), id2.memoizedState = path45, id2.baseState = path45, fiber.memoizedProps = assign({}, fiber.memoizedProps), path45 = enqueueConcurrentRenderForLane(fiber, 2), null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2));
|
|
31086
31086
|
};
|
|
31087
31087
|
overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
|
|
31088
31088
|
id2 = findHook(fiber, id2);
|
|
31089
31089
|
null !== id2 && (oldPath = copyWithRename(id2.memoizedState, oldPath, newPath), id2.memoizedState = oldPath, id2.baseState = oldPath, fiber.memoizedProps = assign({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), null !== oldPath && scheduleUpdateOnFiber(oldPath, fiber, 2));
|
|
31090
31090
|
};
|
|
31091
|
-
overrideProps = function(fiber,
|
|
31092
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
31091
|
+
overrideProps = function(fiber, path45, value) {
|
|
31092
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path45, 0, value);
|
|
31093
31093
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
31094
|
-
|
|
31095
|
-
null !==
|
|
31094
|
+
path45 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
31095
|
+
null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2);
|
|
31096
31096
|
};
|
|
31097
|
-
overridePropsDeletePath = function(fiber,
|
|
31098
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
31097
|
+
overridePropsDeletePath = function(fiber, path45) {
|
|
31098
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path45, 0);
|
|
31099
31099
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
31100
|
-
|
|
31101
|
-
null !==
|
|
31100
|
+
path45 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
31101
|
+
null !== path45 && scheduleUpdateOnFiber(path45, fiber, 2);
|
|
31102
31102
|
};
|
|
31103
31103
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
31104
31104
|
fiber.pendingProps = copyWithRename(
|
|
@@ -34333,15 +34333,15 @@ function redactSensitive(body) {
|
|
|
34333
34333
|
}
|
|
34334
34334
|
return null;
|
|
34335
34335
|
}
|
|
34336
|
-
async function checkCredentialsFileSafety(
|
|
34336
|
+
async function checkCredentialsFileSafety(path45, onWarn = (m) => console.warn(`anthropic-sdk: ${m}`)) {
|
|
34337
34337
|
if (typeof process === "undefined" || process.platform === "win32")
|
|
34338
34338
|
return;
|
|
34339
|
-
const
|
|
34340
|
-
let resolved =
|
|
34339
|
+
const fs38 = await import("fs");
|
|
34340
|
+
let resolved = path45;
|
|
34341
34341
|
let st;
|
|
34342
34342
|
try {
|
|
34343
|
-
resolved = await
|
|
34344
|
-
st = await
|
|
34343
|
+
resolved = await fs38.promises.realpath(path45);
|
|
34344
|
+
st = await fs38.promises.stat(resolved);
|
|
34345
34345
|
} catch {
|
|
34346
34346
|
return;
|
|
34347
34347
|
}
|
|
@@ -34357,27 +34357,27 @@ async function checkCredentialsFileSafety(path43, onWarn = (m) => console.warn(`
|
|
|
34357
34357
|
}
|
|
34358
34358
|
}
|
|
34359
34359
|
async function writeCredentialsFileAtomic(targetPath, data) {
|
|
34360
|
-
const
|
|
34361
|
-
const
|
|
34362
|
-
const dir =
|
|
34363
|
-
await
|
|
34360
|
+
const fs38 = await import("fs");
|
|
34361
|
+
const path45 = await import("path");
|
|
34362
|
+
const dir = path45.dirname(targetPath);
|
|
34363
|
+
await fs38.promises.mkdir(dir, { recursive: true, mode: 448 });
|
|
34364
34364
|
const tmpPath = `${targetPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
34365
34365
|
try {
|
|
34366
|
-
const fh = await
|
|
34366
|
+
const fh = await fs38.promises.open(tmpPath, "w", 384);
|
|
34367
34367
|
try {
|
|
34368
34368
|
await fh.writeFile(JSON.stringify(data, null, 2));
|
|
34369
34369
|
await fh.sync();
|
|
34370
34370
|
} finally {
|
|
34371
34371
|
await fh.close();
|
|
34372
34372
|
}
|
|
34373
|
-
await
|
|
34373
|
+
await fs38.promises.rename(tmpPath, targetPath);
|
|
34374
34374
|
} catch (err) {
|
|
34375
|
-
await
|
|
34375
|
+
await fs38.promises.unlink(tmpPath).catch(() => {
|
|
34376
34376
|
});
|
|
34377
34377
|
throw err;
|
|
34378
34378
|
}
|
|
34379
34379
|
try {
|
|
34380
|
-
const dirFh = await
|
|
34380
|
+
const dirFh = await fs38.promises.open(dir, "r");
|
|
34381
34381
|
try {
|
|
34382
34382
|
await dirFh.sync();
|
|
34383
34383
|
} finally {
|
|
@@ -34679,12 +34679,12 @@ var loadConfigWithSource = async (profile) => {
|
|
|
34679
34679
|
return null;
|
|
34680
34680
|
}
|
|
34681
34681
|
validateProfileName(profileName);
|
|
34682
|
-
const
|
|
34683
|
-
const
|
|
34684
|
-
const configPath =
|
|
34682
|
+
const fs38 = await import("fs");
|
|
34683
|
+
const path45 = await import("path");
|
|
34684
|
+
const configPath = path45.join(rootConfigPath, "configs", `${profileName}.json`);
|
|
34685
34685
|
let configRaw;
|
|
34686
34686
|
try {
|
|
34687
|
-
configRaw = await
|
|
34687
|
+
configRaw = await fs38.promises.readFile(configPath, "utf-8");
|
|
34688
34688
|
} catch (err) {
|
|
34689
34689
|
if (err?.code !== "ENOENT") {
|
|
34690
34690
|
throw new Error(`failed to read config file ${configPath}: ${err}`);
|
|
@@ -34765,14 +34765,14 @@ var getCredentialsPath = async (config2, profile) => {
|
|
|
34765
34765
|
return null;
|
|
34766
34766
|
}
|
|
34767
34767
|
validateProfileName(profileName);
|
|
34768
|
-
const
|
|
34769
|
-
return
|
|
34768
|
+
const path45 = await import("path");
|
|
34769
|
+
return path45.join(rootConfigPath, "credentials", `${profileName}.json`);
|
|
34770
34770
|
};
|
|
34771
34771
|
var getRootConfigPath = async () => {
|
|
34772
34772
|
if (!supportsLocalConfigFiles()) {
|
|
34773
34773
|
return null;
|
|
34774
34774
|
}
|
|
34775
|
-
const
|
|
34775
|
+
const path45 = await import("path");
|
|
34776
34776
|
const configDir = readEnv("ANTHROPIC_CONFIG_DIR");
|
|
34777
34777
|
if (configDir) {
|
|
34778
34778
|
return configDir;
|
|
@@ -34781,21 +34781,21 @@ var getRootConfigPath = async () => {
|
|
|
34781
34781
|
if (os12 === "Windows") {
|
|
34782
34782
|
const appData = readEnv("APPDATA");
|
|
34783
34783
|
if (appData) {
|
|
34784
|
-
return
|
|
34784
|
+
return path45.join(appData, "Anthropic");
|
|
34785
34785
|
}
|
|
34786
34786
|
const userProfile = readEnv("USERPROFILE");
|
|
34787
34787
|
if (userProfile) {
|
|
34788
|
-
return
|
|
34788
|
+
return path45.join(userProfile, "AppData", "Roaming", "Anthropic");
|
|
34789
34789
|
}
|
|
34790
34790
|
return null;
|
|
34791
34791
|
}
|
|
34792
34792
|
const xdgConfigHome = readEnv("XDG_CONFIG_HOME");
|
|
34793
34793
|
if (xdgConfigHome) {
|
|
34794
|
-
return
|
|
34794
|
+
return path45.join(xdgConfigHome, "anthropic");
|
|
34795
34795
|
}
|
|
34796
34796
|
const home = readEnv("HOME");
|
|
34797
34797
|
if (home) {
|
|
34798
|
-
return
|
|
34798
|
+
return path45.join(home, ".config", "anthropic");
|
|
34799
34799
|
}
|
|
34800
34800
|
return null;
|
|
34801
34801
|
};
|
|
@@ -34812,11 +34812,11 @@ var getActiveProfileName = async () => {
|
|
|
34812
34812
|
if (profileName) {
|
|
34813
34813
|
return profileName;
|
|
34814
34814
|
}
|
|
34815
|
-
const
|
|
34816
|
-
const
|
|
34817
|
-
const filePath =
|
|
34815
|
+
const fs38 = await import("fs");
|
|
34816
|
+
const path45 = await import("path");
|
|
34817
|
+
const filePath = path45.join(rootConfigPath, "active_config");
|
|
34818
34818
|
try {
|
|
34819
|
-
return (await
|
|
34819
|
+
return (await fs38.promises.readFile(filePath, "utf-8")).trim() || "default";
|
|
34820
34820
|
} catch (err) {
|
|
34821
34821
|
if (err?.code !== "ENOENT") {
|
|
34822
34822
|
throw new Error(`failed to read ${filePath}: ${err}`);
|
|
@@ -34827,21 +34827,21 @@ var getActiveProfileName = async () => {
|
|
|
34827
34827
|
|
|
34828
34828
|
// ../../node_modules/.pnpm/@anthropic-ai+sdk@0.94.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs
|
|
34829
34829
|
init_esm_shims();
|
|
34830
|
-
function identityTokenFromFile(
|
|
34831
|
-
if (!
|
|
34830
|
+
function identityTokenFromFile(path45) {
|
|
34831
|
+
if (!path45) {
|
|
34832
34832
|
throw new AnthropicError("Identity token file path is empty");
|
|
34833
34833
|
}
|
|
34834
34834
|
return async () => {
|
|
34835
|
-
const
|
|
34835
|
+
const fs38 = await import("fs");
|
|
34836
34836
|
let content;
|
|
34837
34837
|
try {
|
|
34838
|
-
content = await
|
|
34838
|
+
content = await fs38.promises.readFile(path45, "utf-8");
|
|
34839
34839
|
} catch (err) {
|
|
34840
|
-
throw new AnthropicError(`Failed to read identity token file at ${
|
|
34840
|
+
throw new AnthropicError(`Failed to read identity token file at ${path45}: ${err}`);
|
|
34841
34841
|
}
|
|
34842
34842
|
const token = content.trim();
|
|
34843
34843
|
if (!token) {
|
|
34844
|
-
throw new AnthropicError(`Identity token file at ${
|
|
34844
|
+
throw new AnthropicError(`Identity token file at ${path45} is empty`);
|
|
34845
34845
|
}
|
|
34846
34846
|
return token;
|
|
34847
34847
|
};
|
|
@@ -34916,11 +34916,11 @@ function oidcFederationProvider(config2) {
|
|
|
34916
34916
|
init_esm_shims();
|
|
34917
34917
|
function userOAuthProvider(config2) {
|
|
34918
34918
|
return async (opts) => {
|
|
34919
|
-
const
|
|
34919
|
+
const fs38 = await import("fs");
|
|
34920
34920
|
await checkCredentialsFileSafety(config2.credentialsPath, config2.onSafetyWarning);
|
|
34921
34921
|
let raw;
|
|
34922
34922
|
try {
|
|
34923
|
-
raw = await
|
|
34923
|
+
raw = await fs38.promises.readFile(config2.credentialsPath, "utf-8");
|
|
34924
34924
|
} catch (err) {
|
|
34925
34925
|
throw new WorkloadIdentityError(`Credentials file not found at ${config2.credentialsPath}: ${err}`);
|
|
34926
34926
|
}
|
|
@@ -35084,11 +35084,11 @@ function resolveIdentityTokenProvider(auth2) {
|
|
|
35084
35084
|
}
|
|
35085
35085
|
function cachedExchangeProvider(exchange, credentialsPath, onCacheWriteError, onSafetyWarning) {
|
|
35086
35086
|
return async (opts) => {
|
|
35087
|
-
const
|
|
35087
|
+
const fs38 = await import("fs");
|
|
35088
35088
|
await checkCredentialsFileSafety(credentialsPath, onSafetyWarning);
|
|
35089
35089
|
let existing;
|
|
35090
35090
|
try {
|
|
35091
|
-
const raw = await
|
|
35091
|
+
const raw = await fs38.promises.readFile(credentialsPath, "utf-8");
|
|
35092
35092
|
existing = JSON.parse(raw);
|
|
35093
35093
|
const token = existing?.["access_token"];
|
|
35094
35094
|
if (token && !opts?.forceRefresh) {
|
|
@@ -35927,12 +35927,12 @@ function encodeURIPath(str2) {
|
|
|
35927
35927
|
return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
35928
35928
|
}
|
|
35929
35929
|
var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
35930
|
-
var createPathTagFunction = (pathEncoder = encodeURIPath) => function
|
|
35930
|
+
var createPathTagFunction = (pathEncoder = encodeURIPath) => function path45(statics, ...params) {
|
|
35931
35931
|
if (statics.length === 1)
|
|
35932
35932
|
return statics[0];
|
|
35933
35933
|
let postPath = false;
|
|
35934
35934
|
const invalidSegments = [];
|
|
35935
|
-
const
|
|
35935
|
+
const path46 = statics.reduce((previousValue, currentValue, index) => {
|
|
35936
35936
|
if (/[?#]/.test(currentValue)) {
|
|
35937
35937
|
postPath = true;
|
|
35938
35938
|
}
|
|
@@ -35949,7 +35949,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path43(sta
|
|
|
35949
35949
|
}
|
|
35950
35950
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
35951
35951
|
}, "");
|
|
35952
|
-
const pathOnly =
|
|
35952
|
+
const pathOnly = path46.split(/[?#]/, 1)[0];
|
|
35953
35953
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
35954
35954
|
let match;
|
|
35955
35955
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -35970,10 +35970,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path43(sta
|
|
|
35970
35970
|
}, "");
|
|
35971
35971
|
throw new AnthropicError(`Path parameters result in path with invalid segments:
|
|
35972
35972
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
35973
|
-
${
|
|
35973
|
+
${path46}
|
|
35974
35974
|
${underline}`);
|
|
35975
35975
|
}
|
|
35976
|
-
return
|
|
35976
|
+
return path46;
|
|
35977
35977
|
};
|
|
35978
35978
|
var path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
35979
35979
|
|
|
@@ -40734,9 +40734,9 @@ var BaseAnthropic = class {
|
|
|
40734
40734
|
makeStatusError(status, error51, message, headers) {
|
|
40735
40735
|
return APIError.generate(status, error51, message, headers);
|
|
40736
40736
|
}
|
|
40737
|
-
buildURL(
|
|
40737
|
+
buildURL(path45, query, defaultBaseURL) {
|
|
40738
40738
|
const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
40739
|
-
const url2 = isAbsoluteURL(
|
|
40739
|
+
const url2 = isAbsoluteURL(path45) ? new URL(path45) : new URL(baseURL + (baseURL.endsWith("/") && path45.startsWith("/") ? path45.slice(1) : path45));
|
|
40740
40740
|
const defaultQuery = this.defaultQuery();
|
|
40741
40741
|
const pathQuery = Object.fromEntries(url2.searchParams);
|
|
40742
40742
|
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
@@ -40780,24 +40780,24 @@ var BaseAnthropic = class {
|
|
|
40780
40780
|
request.headers = headers;
|
|
40781
40781
|
}
|
|
40782
40782
|
}
|
|
40783
|
-
get(
|
|
40784
|
-
return this.methodRequest("get",
|
|
40783
|
+
get(path45, opts) {
|
|
40784
|
+
return this.methodRequest("get", path45, opts);
|
|
40785
40785
|
}
|
|
40786
|
-
post(
|
|
40787
|
-
return this.methodRequest("post",
|
|
40786
|
+
post(path45, opts) {
|
|
40787
|
+
return this.methodRequest("post", path45, opts);
|
|
40788
40788
|
}
|
|
40789
|
-
patch(
|
|
40790
|
-
return this.methodRequest("patch",
|
|
40789
|
+
patch(path45, opts) {
|
|
40790
|
+
return this.methodRequest("patch", path45, opts);
|
|
40791
40791
|
}
|
|
40792
|
-
put(
|
|
40793
|
-
return this.methodRequest("put",
|
|
40792
|
+
put(path45, opts) {
|
|
40793
|
+
return this.methodRequest("put", path45, opts);
|
|
40794
40794
|
}
|
|
40795
|
-
delete(
|
|
40796
|
-
return this.methodRequest("delete",
|
|
40795
|
+
delete(path45, opts) {
|
|
40796
|
+
return this.methodRequest("delete", path45, opts);
|
|
40797
40797
|
}
|
|
40798
|
-
methodRequest(method,
|
|
40798
|
+
methodRequest(method, path45, opts) {
|
|
40799
40799
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
40800
|
-
return { method, path:
|
|
40800
|
+
return { method, path: path45, ...opts2 };
|
|
40801
40801
|
}));
|
|
40802
40802
|
}
|
|
40803
40803
|
request(options, remainingRetries = null) {
|
|
@@ -40902,8 +40902,8 @@ var BaseAnthropic = class {
|
|
|
40902
40902
|
}));
|
|
40903
40903
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
40904
40904
|
}
|
|
40905
|
-
getAPIList(
|
|
40906
|
-
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
40905
|
+
getAPIList(path45, Page3, opts) {
|
|
40906
|
+
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path45, ...opts2 })) : { method: "get", path: path45, ...opts });
|
|
40907
40907
|
}
|
|
40908
40908
|
requestAPIList(Page3, options) {
|
|
40909
40909
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -40997,14 +40997,14 @@ var BaseAnthropic = class {
|
|
|
40997
40997
|
}
|
|
40998
40998
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
40999
40999
|
const options = { ...inputOptions };
|
|
41000
|
-
const { method, path:
|
|
41000
|
+
const { method, path: path45, query, defaultBaseURL } = options;
|
|
41001
41001
|
if (this._authState.resolution) {
|
|
41002
41002
|
await this._authState.resolution;
|
|
41003
41003
|
}
|
|
41004
41004
|
if (!this._baseURLIsExplicit && this._authState.baseURL && this.baseURL !== this._authState.baseURL) {
|
|
41005
41005
|
this.baseURL = this._authState.baseURL;
|
|
41006
41006
|
}
|
|
41007
|
-
const url2 = this.buildURL(
|
|
41007
|
+
const url2 = this.buildURL(path45, query, defaultBaseURL);
|
|
41008
41008
|
if ("timeout" in options)
|
|
41009
41009
|
validatePositiveInteger("timeout", options.timeout);
|
|
41010
41010
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -41891,10 +41891,10 @@ function mergeDefs(...defs) {
|
|
|
41891
41891
|
function cloneDef(schema) {
|
|
41892
41892
|
return mergeDefs(schema._zod.def);
|
|
41893
41893
|
}
|
|
41894
|
-
function getElementAtPath(obj,
|
|
41895
|
-
if (!
|
|
41894
|
+
function getElementAtPath(obj, path45) {
|
|
41895
|
+
if (!path45)
|
|
41896
41896
|
return obj;
|
|
41897
|
-
return
|
|
41897
|
+
return path45.reduce((acc, key) => acc?.[key], obj);
|
|
41898
41898
|
}
|
|
41899
41899
|
function promiseAllObject(promisesObj) {
|
|
41900
41900
|
const keys = Object.keys(promisesObj);
|
|
@@ -42303,11 +42303,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
42303
42303
|
}
|
|
42304
42304
|
return false;
|
|
42305
42305
|
}
|
|
42306
|
-
function prefixIssues(
|
|
42306
|
+
function prefixIssues(path45, issues) {
|
|
42307
42307
|
return issues.map((iss) => {
|
|
42308
42308
|
var _a6;
|
|
42309
42309
|
(_a6 = iss).path ?? (_a6.path = []);
|
|
42310
|
-
iss.path.unshift(
|
|
42310
|
+
iss.path.unshift(path45);
|
|
42311
42311
|
return iss;
|
|
42312
42312
|
});
|
|
42313
42313
|
}
|
|
@@ -42454,16 +42454,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
42454
42454
|
}
|
|
42455
42455
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
42456
42456
|
const fieldErrors = { _errors: [] };
|
|
42457
|
-
const processError = (error52,
|
|
42457
|
+
const processError = (error52, path45 = []) => {
|
|
42458
42458
|
for (const issue2 of error52.issues) {
|
|
42459
42459
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
42460
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
42460
|
+
issue2.errors.map((issues) => processError({ issues }, [...path45, ...issue2.path]));
|
|
42461
42461
|
} else if (issue2.code === "invalid_key") {
|
|
42462
|
-
processError({ issues: issue2.issues }, [...
|
|
42462
|
+
processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
|
|
42463
42463
|
} else if (issue2.code === "invalid_element") {
|
|
42464
|
-
processError({ issues: issue2.issues }, [...
|
|
42464
|
+
processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
|
|
42465
42465
|
} else {
|
|
42466
|
-
const fullpath = [...
|
|
42466
|
+
const fullpath = [...path45, ...issue2.path];
|
|
42467
42467
|
if (fullpath.length === 0) {
|
|
42468
42468
|
fieldErrors._errors.push(mapper(issue2));
|
|
42469
42469
|
} else {
|
|
@@ -42490,17 +42490,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
42490
42490
|
}
|
|
42491
42491
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
42492
42492
|
const result = { errors: [] };
|
|
42493
|
-
const processError = (error52,
|
|
42493
|
+
const processError = (error52, path45 = []) => {
|
|
42494
42494
|
var _a6, _b;
|
|
42495
42495
|
for (const issue2 of error52.issues) {
|
|
42496
42496
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
42497
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
42497
|
+
issue2.errors.map((issues) => processError({ issues }, [...path45, ...issue2.path]));
|
|
42498
42498
|
} else if (issue2.code === "invalid_key") {
|
|
42499
|
-
processError({ issues: issue2.issues }, [...
|
|
42499
|
+
processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
|
|
42500
42500
|
} else if (issue2.code === "invalid_element") {
|
|
42501
|
-
processError({ issues: issue2.issues }, [...
|
|
42501
|
+
processError({ issues: issue2.issues }, [...path45, ...issue2.path]);
|
|
42502
42502
|
} else {
|
|
42503
|
-
const fullpath = [...
|
|
42503
|
+
const fullpath = [...path45, ...issue2.path];
|
|
42504
42504
|
if (fullpath.length === 0) {
|
|
42505
42505
|
result.errors.push(mapper(issue2));
|
|
42506
42506
|
continue;
|
|
@@ -42532,8 +42532,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
42532
42532
|
}
|
|
42533
42533
|
function toDotPath(_path) {
|
|
42534
42534
|
const segs = [];
|
|
42535
|
-
const
|
|
42536
|
-
for (const seg of
|
|
42535
|
+
const path45 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
42536
|
+
for (const seg of path45) {
|
|
42537
42537
|
if (typeof seg === "number")
|
|
42538
42538
|
segs.push(`[${seg}]`);
|
|
42539
42539
|
else if (typeof seg === "symbol")
|
|
@@ -55306,13 +55306,13 @@ function resolveRef(ref, ctx) {
|
|
|
55306
55306
|
if (!ref.startsWith("#")) {
|
|
55307
55307
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
55308
55308
|
}
|
|
55309
|
-
const
|
|
55310
|
-
if (
|
|
55309
|
+
const path45 = ref.slice(1).split("/").filter(Boolean);
|
|
55310
|
+
if (path45.length === 0) {
|
|
55311
55311
|
return ctx.rootSchema;
|
|
55312
55312
|
}
|
|
55313
55313
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
55314
|
-
if (
|
|
55315
|
-
const key =
|
|
55314
|
+
if (path45[0] === defsKey) {
|
|
55315
|
+
const key = path45[1];
|
|
55316
55316
|
if (!key || !ctx.defs[key]) {
|
|
55317
55317
|
throw new Error(`Reference not found: ${ref}`);
|
|
55318
55318
|
}
|
|
@@ -57541,12 +57541,12 @@ function encodeURIPath2(str2) {
|
|
|
57541
57541
|
return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
57542
57542
|
}
|
|
57543
57543
|
var EMPTY2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
57544
|
-
var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function
|
|
57544
|
+
var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path45(statics, ...params) {
|
|
57545
57545
|
if (statics.length === 1)
|
|
57546
57546
|
return statics[0];
|
|
57547
57547
|
let postPath = false;
|
|
57548
57548
|
const invalidSegments = [];
|
|
57549
|
-
const
|
|
57549
|
+
const path46 = statics.reduce((previousValue, currentValue, index) => {
|
|
57550
57550
|
if (/[?#]/.test(currentValue)) {
|
|
57551
57551
|
postPath = true;
|
|
57552
57552
|
}
|
|
@@ -57563,7 +57563,7 @@ var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path43(s
|
|
|
57563
57563
|
}
|
|
57564
57564
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
57565
57565
|
}, "");
|
|
57566
|
-
const pathOnly =
|
|
57566
|
+
const pathOnly = path46.split(/[?#]/, 1)[0];
|
|
57567
57567
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
57568
57568
|
let match;
|
|
57569
57569
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -57584,10 +57584,10 @@ var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path43(s
|
|
|
57584
57584
|
}, "");
|
|
57585
57585
|
throw new OpenAIError(`Path parameters result in path with invalid segments:
|
|
57586
57586
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
57587
|
-
${
|
|
57587
|
+
${path46}
|
|
57588
57588
|
${underline}`);
|
|
57589
57589
|
}
|
|
57590
|
-
return
|
|
57590
|
+
return path46;
|
|
57591
57591
|
};
|
|
57592
57592
|
var path2 = /* @__PURE__ */ createPathTagFunction2(encodeURIPath2);
|
|
57593
57593
|
|
|
@@ -62713,9 +62713,9 @@ var OpenAI = class {
|
|
|
62713
62713
|
this.apiKey = token;
|
|
62714
62714
|
return true;
|
|
62715
62715
|
}
|
|
62716
|
-
buildURL(
|
|
62716
|
+
buildURL(path45, query, defaultBaseURL) {
|
|
62717
62717
|
const baseURL = !__classPrivateFieldGet2(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
62718
|
-
const url2 = isAbsoluteURL2(
|
|
62718
|
+
const url2 = isAbsoluteURL2(path45) ? new URL(path45) : new URL(baseURL + (baseURL.endsWith("/") && path45.startsWith("/") ? path45.slice(1) : path45));
|
|
62719
62719
|
const defaultQuery = this.defaultQuery();
|
|
62720
62720
|
const pathQuery = Object.fromEntries(url2.searchParams);
|
|
62721
62721
|
if (!isEmptyObj2(defaultQuery) || !isEmptyObj2(pathQuery)) {
|
|
@@ -62740,24 +62740,24 @@ var OpenAI = class {
|
|
|
62740
62740
|
*/
|
|
62741
62741
|
async prepareRequest(request, { url: url2, options }) {
|
|
62742
62742
|
}
|
|
62743
|
-
get(
|
|
62744
|
-
return this.methodRequest("get",
|
|
62743
|
+
get(path45, opts) {
|
|
62744
|
+
return this.methodRequest("get", path45, opts);
|
|
62745
62745
|
}
|
|
62746
|
-
post(
|
|
62747
|
-
return this.methodRequest("post",
|
|
62746
|
+
post(path45, opts) {
|
|
62747
|
+
return this.methodRequest("post", path45, opts);
|
|
62748
62748
|
}
|
|
62749
|
-
patch(
|
|
62750
|
-
return this.methodRequest("patch",
|
|
62749
|
+
patch(path45, opts) {
|
|
62750
|
+
return this.methodRequest("patch", path45, opts);
|
|
62751
62751
|
}
|
|
62752
|
-
put(
|
|
62753
|
-
return this.methodRequest("put",
|
|
62752
|
+
put(path45, opts) {
|
|
62753
|
+
return this.methodRequest("put", path45, opts);
|
|
62754
62754
|
}
|
|
62755
|
-
delete(
|
|
62756
|
-
return this.methodRequest("delete",
|
|
62755
|
+
delete(path45, opts) {
|
|
62756
|
+
return this.methodRequest("delete", path45, opts);
|
|
62757
62757
|
}
|
|
62758
|
-
methodRequest(method,
|
|
62758
|
+
methodRequest(method, path45, opts) {
|
|
62759
62759
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
62760
|
-
return { method, path:
|
|
62760
|
+
return { method, path: path45, ...opts2 };
|
|
62761
62761
|
}));
|
|
62762
62762
|
}
|
|
62763
62763
|
request(options, remainingRetries = null) {
|
|
@@ -62875,8 +62875,8 @@ var OpenAI = class {
|
|
|
62875
62875
|
}));
|
|
62876
62876
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
62877
62877
|
}
|
|
62878
|
-
getAPIList(
|
|
62879
|
-
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
62878
|
+
getAPIList(path45, Page3, opts) {
|
|
62879
|
+
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path45, ...opts2 })) : { method: "get", path: path45, ...opts });
|
|
62880
62880
|
}
|
|
62881
62881
|
requestAPIList(Page3, options) {
|
|
62882
62882
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -62967,8 +62967,8 @@ var OpenAI = class {
|
|
|
62967
62967
|
}
|
|
62968
62968
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
62969
62969
|
const options = { ...inputOptions };
|
|
62970
|
-
const { method, path:
|
|
62971
|
-
const url2 = this.buildURL(
|
|
62970
|
+
const { method, path: path45, query, defaultBaseURL } = options;
|
|
62971
|
+
const url2 = this.buildURL(path45, query, defaultBaseURL);
|
|
62972
62972
|
if ("timeout" in options)
|
|
62973
62973
|
validatePositiveInteger2("timeout", options.timeout);
|
|
62974
62974
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -64703,11 +64703,11 @@ async function* runStream2(options) {
|
|
|
64703
64703
|
}
|
|
64704
64704
|
}
|
|
64705
64705
|
if (getEnvironment()?.GGAI_DUMP_REQUEST) {
|
|
64706
|
-
const
|
|
64706
|
+
const fs38 = await import("fs");
|
|
64707
64707
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
64708
64708
|
const dumpPath = `/tmp/ggai-request-${ts}.json`;
|
|
64709
|
-
|
|
64710
|
-
|
|
64709
|
+
fs38.writeFileSync(dumpPath, JSON.stringify(params, null, 2));
|
|
64710
|
+
fs38.appendFileSync(
|
|
64711
64711
|
"/tmp/ggai-requests.log",
|
|
64712
64712
|
`[${ts}] ${dumpPath} messages=${params.messages.length}
|
|
64713
64713
|
`
|
|
@@ -69290,25 +69290,715 @@ var ProcessManager = class {
|
|
|
69290
69290
|
}
|
|
69291
69291
|
};
|
|
69292
69292
|
|
|
69293
|
+
// ../ggcoder/dist/core/lsp/manager.js
|
|
69294
|
+
init_esm_shims();
|
|
69295
|
+
import path8 from "path";
|
|
69296
|
+
|
|
69297
|
+
// ../ggcoder/dist/core/logger.js
|
|
69298
|
+
init_esm_shims();
|
|
69299
|
+
|
|
69300
|
+
// ../ggcoder/dist/core/lsp/client.js
|
|
69301
|
+
init_esm_shims();
|
|
69302
|
+
import { spawn as spawn3 } from "child_process";
|
|
69303
|
+
import { pathToFileURL } from "url";
|
|
69304
|
+
|
|
69305
|
+
// ../ggcoder/dist/core/lsp/jsonrpc.js
|
|
69306
|
+
init_esm_shims();
|
|
69307
|
+
var JsonRpcRequestError = class extends Error {
|
|
69308
|
+
code;
|
|
69309
|
+
constructor(method, code, message) {
|
|
69310
|
+
super(`${method}: ${message} (code ${code})`);
|
|
69311
|
+
this.name = "JsonRpcRequestError";
|
|
69312
|
+
this.code = code;
|
|
69313
|
+
}
|
|
69314
|
+
};
|
|
69315
|
+
var HEADER_SEPARATOR = "\r\n\r\n";
|
|
69316
|
+
var JsonRpcConnection = class {
|
|
69317
|
+
output;
|
|
69318
|
+
buffer = Buffer.alloc(0);
|
|
69319
|
+
nextId = 1;
|
|
69320
|
+
pending = /* @__PURE__ */ new Map();
|
|
69321
|
+
notificationHandlers = /* @__PURE__ */ new Map();
|
|
69322
|
+
disposed = false;
|
|
69323
|
+
constructor(input, output) {
|
|
69324
|
+
this.output = output;
|
|
69325
|
+
input.on("data", (chunk) => this.onData(chunk));
|
|
69326
|
+
output.on("error", () => {
|
|
69327
|
+
});
|
|
69328
|
+
}
|
|
69329
|
+
onNotification(method, handler) {
|
|
69330
|
+
const handlers = this.notificationHandlers.get(method) ?? [];
|
|
69331
|
+
handlers.push(handler);
|
|
69332
|
+
this.notificationHandlers.set(method, handlers);
|
|
69333
|
+
}
|
|
69334
|
+
request(method, params, timeoutMs) {
|
|
69335
|
+
if (this.disposed) {
|
|
69336
|
+
return Promise.reject(new JsonRpcRequestError(method, -32099, "connection disposed"));
|
|
69337
|
+
}
|
|
69338
|
+
const id2 = this.nextId++;
|
|
69339
|
+
return new Promise((resolve2, reject) => {
|
|
69340
|
+
const timer = setTimeout(() => {
|
|
69341
|
+
this.pending.delete(id2);
|
|
69342
|
+
reject(new JsonRpcRequestError(method, -32803, `timed out after ${timeoutMs}ms`));
|
|
69343
|
+
}, timeoutMs);
|
|
69344
|
+
timer.unref();
|
|
69345
|
+
this.pending.set(id2, (msg) => {
|
|
69346
|
+
clearTimeout(timer);
|
|
69347
|
+
if (msg.error) {
|
|
69348
|
+
reject(new JsonRpcRequestError(method, msg.error.code, msg.error.message));
|
|
69349
|
+
} else {
|
|
69350
|
+
resolve2(msg.result);
|
|
69351
|
+
}
|
|
69352
|
+
});
|
|
69353
|
+
this.send({ jsonrpc: "2.0", id: id2, method, params });
|
|
69354
|
+
});
|
|
69355
|
+
}
|
|
69356
|
+
notify(method, params) {
|
|
69357
|
+
this.send({ jsonrpc: "2.0", method, params });
|
|
69358
|
+
}
|
|
69359
|
+
/** Reject all in-flight requests and stop accepting new work. */
|
|
69360
|
+
dispose() {
|
|
69361
|
+
if (this.disposed)
|
|
69362
|
+
return;
|
|
69363
|
+
this.disposed = true;
|
|
69364
|
+
for (const [id2, settle] of this.pending) {
|
|
69365
|
+
this.pending.delete(id2);
|
|
69366
|
+
settle({ error: { code: -32099, message: "connection disposed" } });
|
|
69367
|
+
}
|
|
69368
|
+
}
|
|
69369
|
+
send(msg) {
|
|
69370
|
+
if (this.disposed)
|
|
69371
|
+
return;
|
|
69372
|
+
const body = JSON.stringify(msg);
|
|
69373
|
+
try {
|
|
69374
|
+
this.output.write(`Content-Length: ${Buffer.byteLength(body)}\r
|
|
69375
|
+
\r
|
|
69376
|
+
${body}`);
|
|
69377
|
+
} catch {
|
|
69378
|
+
}
|
|
69379
|
+
}
|
|
69380
|
+
onData(chunk) {
|
|
69381
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
69382
|
+
for (; ; ) {
|
|
69383
|
+
const headerEnd = this.buffer.indexOf(HEADER_SEPARATOR);
|
|
69384
|
+
if (headerEnd === -1)
|
|
69385
|
+
return;
|
|
69386
|
+
const header = this.buffer.subarray(0, headerEnd).toString();
|
|
69387
|
+
const match = /Content-Length: (\d+)/i.exec(header);
|
|
69388
|
+
if (!match) {
|
|
69389
|
+
this.buffer = this.buffer.subarray(headerEnd + HEADER_SEPARATOR.length);
|
|
69390
|
+
continue;
|
|
69391
|
+
}
|
|
69392
|
+
const length = Number(match[1]);
|
|
69393
|
+
const bodyStart = headerEnd + HEADER_SEPARATOR.length;
|
|
69394
|
+
if (this.buffer.length < bodyStart + length)
|
|
69395
|
+
return;
|
|
69396
|
+
const body = this.buffer.subarray(bodyStart, bodyStart + length).toString();
|
|
69397
|
+
this.buffer = this.buffer.subarray(bodyStart + length);
|
|
69398
|
+
let msg;
|
|
69399
|
+
try {
|
|
69400
|
+
msg = JSON.parse(body);
|
|
69401
|
+
} catch {
|
|
69402
|
+
continue;
|
|
69403
|
+
}
|
|
69404
|
+
this.onMessage(msg);
|
|
69405
|
+
}
|
|
69406
|
+
}
|
|
69407
|
+
onMessage(msg) {
|
|
69408
|
+
if (msg.id !== void 0 && msg.method === void 0) {
|
|
69409
|
+
const settle = typeof msg.id === "number" ? this.pending.get(msg.id) : void 0;
|
|
69410
|
+
if (settle && typeof msg.id === "number") {
|
|
69411
|
+
this.pending.delete(msg.id);
|
|
69412
|
+
settle(msg);
|
|
69413
|
+
}
|
|
69414
|
+
return;
|
|
69415
|
+
}
|
|
69416
|
+
if (msg.id !== void 0 && msg.method !== void 0) {
|
|
69417
|
+
let result = null;
|
|
69418
|
+
if (msg.method === "workspace/configuration") {
|
|
69419
|
+
const items = msg.params?.items ?? [];
|
|
69420
|
+
result = items.map(() => null);
|
|
69421
|
+
}
|
|
69422
|
+
this.send({ jsonrpc: "2.0", id: msg.id, result });
|
|
69423
|
+
return;
|
|
69424
|
+
}
|
|
69425
|
+
if (msg.method !== void 0) {
|
|
69426
|
+
const handlers = this.notificationHandlers.get(msg.method);
|
|
69427
|
+
if (handlers) {
|
|
69428
|
+
for (const handler of handlers)
|
|
69429
|
+
handler(msg.params);
|
|
69430
|
+
}
|
|
69431
|
+
}
|
|
69432
|
+
}
|
|
69433
|
+
};
|
|
69434
|
+
|
|
69435
|
+
// ../ggcoder/dist/core/lsp/client.js
|
|
69436
|
+
var SERVER_CANCELLED = -32802;
|
|
69437
|
+
var METHOD_NOT_FOUND = -32601;
|
|
69438
|
+
var PULL_POLL_INTERVAL_MS = 300;
|
|
69439
|
+
var SHUTDOWN_TIMEOUT_MS = 2e3;
|
|
69440
|
+
var KILL_GRACE_MS = 1500;
|
|
69441
|
+
function sleep4(ms) {
|
|
69442
|
+
return new Promise((resolve2) => {
|
|
69443
|
+
setTimeout(resolve2, ms).unref();
|
|
69444
|
+
});
|
|
69445
|
+
}
|
|
69446
|
+
var LspClient = class {
|
|
69447
|
+
spec;
|
|
69448
|
+
rootPath;
|
|
69449
|
+
proc;
|
|
69450
|
+
conn;
|
|
69451
|
+
versions = /* @__PURE__ */ new Map();
|
|
69452
|
+
published = /* @__PURE__ */ new Map();
|
|
69453
|
+
waiters = [];
|
|
69454
|
+
hasPullDiagnostics = false;
|
|
69455
|
+
alive = true;
|
|
69456
|
+
initializationOptions;
|
|
69457
|
+
constructor(spec, rootPath, command) {
|
|
69458
|
+
this.spec = spec;
|
|
69459
|
+
this.rootPath = rootPath;
|
|
69460
|
+
this.initializationOptions = command.initializationOptions ?? {};
|
|
69461
|
+
this.proc = spawn3(command.command, command.args, {
|
|
69462
|
+
cwd: rootPath,
|
|
69463
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
69464
|
+
env: getSafeToolEnv()
|
|
69465
|
+
});
|
|
69466
|
+
this.proc.on("error", () => this.markDead());
|
|
69467
|
+
this.proc.on("exit", () => this.markDead());
|
|
69468
|
+
const { stdout, stdin } = this.proc;
|
|
69469
|
+
if (!stdout || !stdin) {
|
|
69470
|
+
this.proc.kill("SIGKILL");
|
|
69471
|
+
throw new Error(`failed to open stdio pipes for ${spec.id} language server`);
|
|
69472
|
+
}
|
|
69473
|
+
this.conn = new JsonRpcConnection(stdout, stdin);
|
|
69474
|
+
this.conn.onNotification("textDocument/publishDiagnostics", (params) => {
|
|
69475
|
+
const publish = params;
|
|
69476
|
+
this.published.set(publish.uri, publish.diagnostics);
|
|
69477
|
+
this.waiters = this.waiters.filter((waiter) => {
|
|
69478
|
+
if (waiter.uri !== publish.uri)
|
|
69479
|
+
return true;
|
|
69480
|
+
waiter.resolve(publish.diagnostics);
|
|
69481
|
+
return false;
|
|
69482
|
+
});
|
|
69483
|
+
});
|
|
69484
|
+
}
|
|
69485
|
+
get isAlive() {
|
|
69486
|
+
return this.alive;
|
|
69487
|
+
}
|
|
69488
|
+
async initialize(timeoutMs) {
|
|
69489
|
+
const rootUri = pathToFileURL(this.rootPath).href;
|
|
69490
|
+
const result = await this.conn.request("initialize", {
|
|
69491
|
+
processId: process.pid,
|
|
69492
|
+
rootUri,
|
|
69493
|
+
workspaceFolders: [{ uri: rootUri, name: "ggcoder" }],
|
|
69494
|
+
initializationOptions: this.initializationOptions,
|
|
69495
|
+
capabilities: {
|
|
69496
|
+
textDocument: {
|
|
69497
|
+
synchronization: { didSave: true },
|
|
69498
|
+
publishDiagnostics: { relatedInformation: false },
|
|
69499
|
+
diagnostic: { dynamicRegistration: false, relatedDocumentSupport: false }
|
|
69500
|
+
},
|
|
69501
|
+
workspace: { configuration: true, workspaceFolders: true }
|
|
69502
|
+
}
|
|
69503
|
+
}, timeoutMs);
|
|
69504
|
+
this.hasPullDiagnostics = Boolean(result?.capabilities?.diagnosticProvider);
|
|
69505
|
+
this.conn.notify("initialized", {});
|
|
69506
|
+
}
|
|
69507
|
+
/**
|
|
69508
|
+
* Sync `content` into the server's overlay for `filePath` — didOpen the
|
|
69509
|
+
* first time, didChange (full text) + didSave afterwards. Clears the
|
|
69510
|
+
* push-diagnostics cache for the uri so a subsequent collect waits for a
|
|
69511
|
+
* report computed against THIS content rather than a stale one.
|
|
69512
|
+
*/
|
|
69513
|
+
syncDocument(filePath, content) {
|
|
69514
|
+
const uri = pathToFileURL(filePath).href;
|
|
69515
|
+
this.published.delete(uri);
|
|
69516
|
+
const previousVersion = this.versions.get(uri);
|
|
69517
|
+
if (previousVersion === void 0) {
|
|
69518
|
+
this.versions.set(uri, 1);
|
|
69519
|
+
this.conn.notify("textDocument/didOpen", {
|
|
69520
|
+
textDocument: {
|
|
69521
|
+
uri,
|
|
69522
|
+
languageId: this.spec.languageIdFor(extensionOf(filePath)),
|
|
69523
|
+
version: 1,
|
|
69524
|
+
text: content
|
|
69525
|
+
}
|
|
69526
|
+
});
|
|
69527
|
+
} else {
|
|
69528
|
+
const version2 = previousVersion + 1;
|
|
69529
|
+
this.versions.set(uri, version2);
|
|
69530
|
+
this.conn.notify("textDocument/didChange", {
|
|
69531
|
+
textDocument: { uri, version: version2 },
|
|
69532
|
+
contentChanges: [{ text: content }]
|
|
69533
|
+
});
|
|
69534
|
+
this.conn.notify("textDocument/didSave", { textDocument: { uri }, text: content });
|
|
69535
|
+
}
|
|
69536
|
+
return uri;
|
|
69537
|
+
}
|
|
69538
|
+
/**
|
|
69539
|
+
* Current diagnostics for `uri`, racing the push channel (next
|
|
69540
|
+
* publishDiagnostics after the last sync) against a pull-diagnostics poll
|
|
69541
|
+
* loop when the server supports LSP 3.17 pull. Returns null on timeout.
|
|
69542
|
+
*/
|
|
69543
|
+
async collectDiagnostics(uri, timeoutMs) {
|
|
69544
|
+
const push = this.waitForPublish(uri, timeoutMs);
|
|
69545
|
+
if (!this.hasPullDiagnostics)
|
|
69546
|
+
return push;
|
|
69547
|
+
let stopped = false;
|
|
69548
|
+
const pull = (async () => {
|
|
69549
|
+
const deadline = Date.now() + timeoutMs;
|
|
69550
|
+
while (!stopped && this.alive && Date.now() < deadline) {
|
|
69551
|
+
const items = await this.pullDiagnostics(uri, Math.max(1, deadline - Date.now()));
|
|
69552
|
+
if (items === "unsupported")
|
|
69553
|
+
return push;
|
|
69554
|
+
if (items !== "retry")
|
|
69555
|
+
return items;
|
|
69556
|
+
await sleep4(PULL_POLL_INTERVAL_MS);
|
|
69557
|
+
}
|
|
69558
|
+
return push;
|
|
69559
|
+
})();
|
|
69560
|
+
try {
|
|
69561
|
+
return await Promise.race([push, pull]);
|
|
69562
|
+
} finally {
|
|
69563
|
+
stopped = true;
|
|
69564
|
+
}
|
|
69565
|
+
}
|
|
69566
|
+
/**
|
|
69567
|
+
* Graceful shutdown/exit handshake with SIGKILL fallback. Synchronous so it
|
|
69568
|
+
* is safe inside `process.on("exit")` handlers: the shutdown request and
|
|
69569
|
+
* exit notification are written immediately; the SIGKILL timer covers
|
|
69570
|
+
* servers that ignore them (and stdin EOF reaps them when we die first).
|
|
69571
|
+
*/
|
|
69572
|
+
shutdown() {
|
|
69573
|
+
if (!this.alive)
|
|
69574
|
+
return;
|
|
69575
|
+
void this.conn.request("shutdown", null, SHUTDOWN_TIMEOUT_MS).catch(() => {
|
|
69576
|
+
});
|
|
69577
|
+
this.conn.notify("exit");
|
|
69578
|
+
const killTimer = setTimeout(() => {
|
|
69579
|
+
if (this.alive)
|
|
69580
|
+
this.proc.kill("SIGKILL");
|
|
69581
|
+
}, KILL_GRACE_MS);
|
|
69582
|
+
killTimer.unref();
|
|
69583
|
+
}
|
|
69584
|
+
markDead() {
|
|
69585
|
+
this.alive = false;
|
|
69586
|
+
this.conn.dispose();
|
|
69587
|
+
const waiters = this.waiters;
|
|
69588
|
+
this.waiters = [];
|
|
69589
|
+
for (const waiter of waiters)
|
|
69590
|
+
waiter.resolve([]);
|
|
69591
|
+
}
|
|
69592
|
+
waitForPublish(uri, timeoutMs) {
|
|
69593
|
+
const cached4 = this.published.get(uri);
|
|
69594
|
+
if (cached4 !== void 0)
|
|
69595
|
+
return Promise.resolve(cached4);
|
|
69596
|
+
if (!this.alive)
|
|
69597
|
+
return Promise.resolve(null);
|
|
69598
|
+
return new Promise((resolve2) => {
|
|
69599
|
+
const waiter = {
|
|
69600
|
+
uri,
|
|
69601
|
+
resolve: (diagnostics) => {
|
|
69602
|
+
clearTimeout(timer);
|
|
69603
|
+
resolve2(diagnostics);
|
|
69604
|
+
}
|
|
69605
|
+
};
|
|
69606
|
+
const timer = setTimeout(() => {
|
|
69607
|
+
this.waiters = this.waiters.filter((w) => w !== waiter);
|
|
69608
|
+
resolve2(null);
|
|
69609
|
+
}, timeoutMs);
|
|
69610
|
+
timer.unref();
|
|
69611
|
+
this.waiters.push(waiter);
|
|
69612
|
+
});
|
|
69613
|
+
}
|
|
69614
|
+
async pullDiagnostics(uri, timeoutMs) {
|
|
69615
|
+
try {
|
|
69616
|
+
const report = await this.conn.request("textDocument/diagnostic", { textDocument: { uri } }, timeoutMs);
|
|
69617
|
+
if (report?.kind === "full")
|
|
69618
|
+
return report.items ?? [];
|
|
69619
|
+
if (report?.kind === "unchanged")
|
|
69620
|
+
return this.published.get(uri) ?? [];
|
|
69621
|
+
return "unsupported";
|
|
69622
|
+
} catch (error51) {
|
|
69623
|
+
if (error51 instanceof JsonRpcRequestError) {
|
|
69624
|
+
if (error51.code === SERVER_CANCELLED)
|
|
69625
|
+
return "retry";
|
|
69626
|
+
if (error51.code === METHOD_NOT_FOUND)
|
|
69627
|
+
return "unsupported";
|
|
69628
|
+
}
|
|
69629
|
+
return "unsupported";
|
|
69630
|
+
}
|
|
69631
|
+
}
|
|
69632
|
+
};
|
|
69633
|
+
function extensionOf(filePath) {
|
|
69634
|
+
const dot = filePath.lastIndexOf(".");
|
|
69635
|
+
return dot === -1 ? "" : filePath.slice(dot).toLowerCase();
|
|
69636
|
+
}
|
|
69637
|
+
|
|
69638
|
+
// ../ggcoder/dist/core/lsp/format.js
|
|
69639
|
+
init_esm_shims();
|
|
69640
|
+
var SEVERITY_ERROR = 1;
|
|
69641
|
+
var MAX_DIAGNOSTICS = 5;
|
|
69642
|
+
function formatDiagnostics(relPath, diagnostics) {
|
|
69643
|
+
const errors = diagnostics.filter((d) => (d.severity ?? SEVERITY_ERROR) === SEVERITY_ERROR);
|
|
69644
|
+
if (errors.length === 0)
|
|
69645
|
+
return "";
|
|
69646
|
+
const lines = errors.slice(0, MAX_DIAGNOSTICS).map((d) => {
|
|
69647
|
+
const line = d.range.start.line + 1;
|
|
69648
|
+
const character = d.range.start.character + 1;
|
|
69649
|
+
const message = d.message.split("\n")[0];
|
|
69650
|
+
const source2 = d.source ? ` (${d.source})` : "";
|
|
69651
|
+
return `L${line}:${character} ${message}${source2}`;
|
|
69652
|
+
});
|
|
69653
|
+
const overflow = errors.length > MAX_DIAGNOSTICS ? `
|
|
69654
|
+
\u2026and ${errors.length - MAX_DIAGNOSTICS} more error${errors.length - MAX_DIAGNOSTICS === 1 ? "" : "s"}` : "";
|
|
69655
|
+
return `
|
|
69656
|
+
|
|
69657
|
+
Diagnostics in ${relPath} (informational \u2014 may resolve after related edits):
|
|
69658
|
+
` + lines.join("\n") + overflow;
|
|
69659
|
+
}
|
|
69660
|
+
|
|
69661
|
+
// ../ggcoder/dist/core/lsp/servers.js
|
|
69662
|
+
init_esm_shims();
|
|
69663
|
+
import fs7 from "fs";
|
|
69664
|
+
import path7 from "path";
|
|
69665
|
+
import { fileURLToPath } from "url";
|
|
69666
|
+
var WINDOWS_SUFFIXES = [".cmd", ".exe", ".bat"];
|
|
69667
|
+
function isExecutableFile(candidate) {
|
|
69668
|
+
try {
|
|
69669
|
+
const stat = fs7.statSync(candidate);
|
|
69670
|
+
return stat.isFile();
|
|
69671
|
+
} catch {
|
|
69672
|
+
return false;
|
|
69673
|
+
}
|
|
69674
|
+
}
|
|
69675
|
+
function candidateNames(name) {
|
|
69676
|
+
if (process.platform !== "win32")
|
|
69677
|
+
return [name];
|
|
69678
|
+
return [name, ...WINDOWS_SUFFIXES.map((suffix) => `${name}${suffix}`)];
|
|
69679
|
+
}
|
|
69680
|
+
var MODULE_DIR = path7.dirname(fileURLToPath(import.meta.url));
|
|
69681
|
+
function binDirsUpFrom(start) {
|
|
69682
|
+
const dirs = [];
|
|
69683
|
+
let dir = start;
|
|
69684
|
+
for (; ; ) {
|
|
69685
|
+
dirs.push(path7.join(dir, "node_modules", ".bin"));
|
|
69686
|
+
const parent = path7.dirname(dir);
|
|
69687
|
+
if (parent === dir)
|
|
69688
|
+
break;
|
|
69689
|
+
dir = parent;
|
|
69690
|
+
}
|
|
69691
|
+
return dirs;
|
|
69692
|
+
}
|
|
69693
|
+
function findExecutable(name, projectRoot) {
|
|
69694
|
+
const names = candidateNames(name);
|
|
69695
|
+
const binDirs = [...binDirsUpFrom(projectRoot), ...binDirsUpFrom(MODULE_DIR)];
|
|
69696
|
+
for (const binDir of binDirs) {
|
|
69697
|
+
for (const candidate of names) {
|
|
69698
|
+
const binPath = path7.join(binDir, candidate);
|
|
69699
|
+
if (isExecutableFile(binPath))
|
|
69700
|
+
return binPath;
|
|
69701
|
+
}
|
|
69702
|
+
}
|
|
69703
|
+
const pathEnv = process.env.PATH ?? "";
|
|
69704
|
+
for (const pathDir of pathEnv.split(path7.delimiter)) {
|
|
69705
|
+
if (!pathDir)
|
|
69706
|
+
continue;
|
|
69707
|
+
for (const candidate of names) {
|
|
69708
|
+
const binPath = path7.join(pathDir, candidate);
|
|
69709
|
+
if (isExecutableFile(binPath))
|
|
69710
|
+
return binPath;
|
|
69711
|
+
}
|
|
69712
|
+
}
|
|
69713
|
+
return null;
|
|
69714
|
+
}
|
|
69715
|
+
function findInNodeModulesUp(relPath, start) {
|
|
69716
|
+
let dir = start;
|
|
69717
|
+
for (; ; ) {
|
|
69718
|
+
const candidate = path7.join(dir, "node_modules", relPath);
|
|
69719
|
+
if (fs7.existsSync(candidate))
|
|
69720
|
+
return candidate;
|
|
69721
|
+
const parent = path7.dirname(dir);
|
|
69722
|
+
if (parent === dir)
|
|
69723
|
+
return null;
|
|
69724
|
+
dir = parent;
|
|
69725
|
+
}
|
|
69726
|
+
}
|
|
69727
|
+
function findPackageBinScript(pkgName, binName, start) {
|
|
69728
|
+
const pkgJsonPath = findInNodeModulesUp(path7.join(pkgName, "package.json"), start);
|
|
69729
|
+
if (!pkgJsonPath)
|
|
69730
|
+
return null;
|
|
69731
|
+
try {
|
|
69732
|
+
const pkg = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf8"));
|
|
69733
|
+
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.[binName];
|
|
69734
|
+
if (!bin)
|
|
69735
|
+
return null;
|
|
69736
|
+
const script = path7.join(path7.dirname(pkgJsonPath), bin);
|
|
69737
|
+
return fs7.existsSync(script) ? script : null;
|
|
69738
|
+
} catch {
|
|
69739
|
+
return null;
|
|
69740
|
+
}
|
|
69741
|
+
}
|
|
69742
|
+
function resolveNodeServer(pkgName, binName, projectRoot, args) {
|
|
69743
|
+
const script = findPackageBinScript(pkgName, binName, projectRoot) ?? findPackageBinScript(pkgName, binName, MODULE_DIR);
|
|
69744
|
+
if (script)
|
|
69745
|
+
return { command: process.execPath, args: [script, ...args] };
|
|
69746
|
+
const bin = findExecutable(binName, projectRoot);
|
|
69747
|
+
return bin ? { command: bin, args } : null;
|
|
69748
|
+
}
|
|
69749
|
+
var TSSERVER_REL_PATH = path7.join("typescript", "lib", "tsserver.js");
|
|
69750
|
+
function projectTsserverPath(projectRoot) {
|
|
69751
|
+
return findInNodeModulesUp(TSSERVER_REL_PATH, projectRoot);
|
|
69752
|
+
}
|
|
69753
|
+
function bundledTsserverPath() {
|
|
69754
|
+
return findInNodeModulesUp(TSSERVER_REL_PATH, MODULE_DIR);
|
|
69755
|
+
}
|
|
69756
|
+
var TS_LANGUAGE_IDS = {
|
|
69757
|
+
".ts": "typescript",
|
|
69758
|
+
".mts": "typescript",
|
|
69759
|
+
".cts": "typescript",
|
|
69760
|
+
".tsx": "typescriptreact",
|
|
69761
|
+
".js": "javascript",
|
|
69762
|
+
".mjs": "javascript",
|
|
69763
|
+
".cjs": "javascript",
|
|
69764
|
+
".jsx": "javascriptreact"
|
|
69765
|
+
};
|
|
69766
|
+
var LSP_SERVER_CATALOG = [
|
|
69767
|
+
{
|
|
69768
|
+
id: "typescript",
|
|
69769
|
+
extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"],
|
|
69770
|
+
rootMarkers: [
|
|
69771
|
+
"tsconfig.json",
|
|
69772
|
+
"jsconfig.json",
|
|
69773
|
+
"pnpm-lock.yaml",
|
|
69774
|
+
"package-lock.json",
|
|
69775
|
+
"yarn.lock",
|
|
69776
|
+
"bun.lockb"
|
|
69777
|
+
],
|
|
69778
|
+
languageIdFor: (extension) => TS_LANGUAGE_IDS[extension] ?? "typescript",
|
|
69779
|
+
resolveCommand(projectRoot) {
|
|
69780
|
+
const command = resolveNodeServer("typescript-language-server", "typescript-language-server", projectRoot, ["--stdio"]);
|
|
69781
|
+
if (!command)
|
|
69782
|
+
return null;
|
|
69783
|
+
if (projectTsserverPath(projectRoot))
|
|
69784
|
+
return command;
|
|
69785
|
+
const tsserver = bundledTsserverPath();
|
|
69786
|
+
if (!tsserver)
|
|
69787
|
+
return null;
|
|
69788
|
+
return { ...command, initializationOptions: { tsserver: { path: tsserver } } };
|
|
69789
|
+
}
|
|
69790
|
+
},
|
|
69791
|
+
{
|
|
69792
|
+
id: "python",
|
|
69793
|
+
extensions: [".py"],
|
|
69794
|
+
rootMarkers: [
|
|
69795
|
+
"pyrightconfig.json",
|
|
69796
|
+
"pyproject.toml",
|
|
69797
|
+
"setup.py",
|
|
69798
|
+
"setup.cfg",
|
|
69799
|
+
"requirements.txt",
|
|
69800
|
+
"Pipfile"
|
|
69801
|
+
],
|
|
69802
|
+
languageIdFor: () => "python",
|
|
69803
|
+
resolveCommand(projectRoot) {
|
|
69804
|
+
return resolveNodeServer("pyright", "pyright-langserver", projectRoot, ["--stdio"]);
|
|
69805
|
+
}
|
|
69806
|
+
},
|
|
69807
|
+
{
|
|
69808
|
+
id: "go",
|
|
69809
|
+
extensions: [".go"],
|
|
69810
|
+
rootMarkers: ["go.mod"],
|
|
69811
|
+
languageIdFor: () => "go",
|
|
69812
|
+
resolveCommand(projectRoot) {
|
|
69813
|
+
const bin = findExecutable("gopls", projectRoot);
|
|
69814
|
+
return bin ? { command: bin, args: ["serve"] } : null;
|
|
69815
|
+
}
|
|
69816
|
+
},
|
|
69817
|
+
{
|
|
69818
|
+
id: "rust",
|
|
69819
|
+
extensions: [".rs"],
|
|
69820
|
+
rootMarkers: ["Cargo.toml"],
|
|
69821
|
+
languageIdFor: () => "rust",
|
|
69822
|
+
resolveCommand(projectRoot) {
|
|
69823
|
+
const bin = findExecutable("rust-analyzer", projectRoot);
|
|
69824
|
+
return bin ? { command: bin, args: [] } : null;
|
|
69825
|
+
}
|
|
69826
|
+
},
|
|
69827
|
+
{
|
|
69828
|
+
id: "clangd",
|
|
69829
|
+
extensions: [".c", ".h", ".cc", ".cpp", ".cxx", ".hpp", ".hh"],
|
|
69830
|
+
rootMarkers: ["compile_commands.json", ".clangd", "CMakeLists.txt"],
|
|
69831
|
+
languageIdFor: (extension) => extension === ".c" || extension === ".h" ? "c" : "cpp",
|
|
69832
|
+
resolveCommand(projectRoot) {
|
|
69833
|
+
const bin = findExecutable("clangd", projectRoot);
|
|
69834
|
+
return bin ? { command: bin, args: ["--log=error"] } : null;
|
|
69835
|
+
}
|
|
69836
|
+
}
|
|
69837
|
+
];
|
|
69838
|
+
function serverForFile(filePath, catalog = LSP_SERVER_CATALOG) {
|
|
69839
|
+
const extension = path7.extname(filePath).toLowerCase();
|
|
69840
|
+
if (!extension)
|
|
69841
|
+
return null;
|
|
69842
|
+
return catalog.find((spec) => spec.extensions.includes(extension)) ?? null;
|
|
69843
|
+
}
|
|
69844
|
+
function findProjectRoot(filePath, markers, ceiling) {
|
|
69845
|
+
const fileDir = path7.dirname(path7.resolve(filePath));
|
|
69846
|
+
const cap = path7.resolve(ceiling);
|
|
69847
|
+
const underCeiling = fileDir === cap || fileDir.startsWith(cap + path7.sep);
|
|
69848
|
+
let dir = fileDir;
|
|
69849
|
+
for (; ; ) {
|
|
69850
|
+
for (const marker of markers) {
|
|
69851
|
+
try {
|
|
69852
|
+
fs7.statSync(path7.join(dir, marker));
|
|
69853
|
+
return dir;
|
|
69854
|
+
} catch {
|
|
69855
|
+
}
|
|
69856
|
+
}
|
|
69857
|
+
if (underCeiling && dir === cap)
|
|
69858
|
+
break;
|
|
69859
|
+
const parent = path7.dirname(dir);
|
|
69860
|
+
if (parent === dir)
|
|
69861
|
+
break;
|
|
69862
|
+
dir = parent;
|
|
69863
|
+
}
|
|
69864
|
+
return fileDir;
|
|
69865
|
+
}
|
|
69866
|
+
|
|
69867
|
+
// ../ggcoder/dist/core/lsp/manager.js
|
|
69868
|
+
var DEFAULT_WARM_BUDGET_MS = 3e3;
|
|
69869
|
+
var DEFAULT_FIRST_BUDGET_MS = 8e3;
|
|
69870
|
+
var INIT_TIMEOUT_MS = 1e4;
|
|
69871
|
+
var LspManager = class {
|
|
69872
|
+
cwd;
|
|
69873
|
+
catalog;
|
|
69874
|
+
warmBudgetMs;
|
|
69875
|
+
firstBudgetMs;
|
|
69876
|
+
/** (serverId\0root) → in-flight or settled client; null = broken for session. */
|
|
69877
|
+
clients = /* @__PURE__ */ new Map();
|
|
69878
|
+
/** Keys that have completed at least one diagnostics pass (warm). */
|
|
69879
|
+
warmKeys = /* @__PURE__ */ new Set();
|
|
69880
|
+
shutDown = false;
|
|
69881
|
+
constructor(cwd2, options) {
|
|
69882
|
+
this.cwd = cwd2;
|
|
69883
|
+
this.catalog = options?.catalog ?? LSP_SERVER_CATALOG;
|
|
69884
|
+
this.warmBudgetMs = options?.warmBudgetMs ?? DEFAULT_WARM_BUDGET_MS;
|
|
69885
|
+
this.firstBudgetMs = options?.firstBudgetMs ?? DEFAULT_FIRST_BUDGET_MS;
|
|
69886
|
+
}
|
|
69887
|
+
/**
|
|
69888
|
+
* Diagnostics for `filePath` after its content became `content` on disk.
|
|
69889
|
+
* Returns a formatted informational block, or "" when the file is clean,
|
|
69890
|
+
* unsupported, or anything at all goes wrong (silent graceful degradation).
|
|
69891
|
+
*/
|
|
69892
|
+
async diagnosticsAfterWrite(filePath, content) {
|
|
69893
|
+
if (this.shutDown)
|
|
69894
|
+
return "";
|
|
69895
|
+
try {
|
|
69896
|
+
const spec = serverForFile(filePath, this.catalog);
|
|
69897
|
+
if (!spec)
|
|
69898
|
+
return "";
|
|
69899
|
+
const root = findProjectRoot(filePath, spec.rootMarkers, this.cwd);
|
|
69900
|
+
const key = `${spec.id}\0${root}`;
|
|
69901
|
+
const budgetMs = this.warmKeys.has(key) ? this.warmBudgetMs : this.firstBudgetMs;
|
|
69902
|
+
const work = this.collect(key, spec, root, filePath, content, budgetMs);
|
|
69903
|
+
return await withBudget(work, budgetMs);
|
|
69904
|
+
} catch (error51) {
|
|
69905
|
+
log("WARN", "lsp", `diagnostics failed for ${filePath}`, {
|
|
69906
|
+
error: error51 instanceof Error ? error51.message : String(error51)
|
|
69907
|
+
});
|
|
69908
|
+
return "";
|
|
69909
|
+
}
|
|
69910
|
+
}
|
|
69911
|
+
/** Shut down every pooled server. Safe in process exit handlers. */
|
|
69912
|
+
shutdownAll() {
|
|
69913
|
+
this.shutDown = true;
|
|
69914
|
+
for (const pending of this.clients.values()) {
|
|
69915
|
+
void pending.then((client) => client?.shutdown()).catch(() => {
|
|
69916
|
+
});
|
|
69917
|
+
}
|
|
69918
|
+
this.clients.clear();
|
|
69919
|
+
this.warmKeys.clear();
|
|
69920
|
+
}
|
|
69921
|
+
async collect(key, spec, root, filePath, content, budgetMs) {
|
|
69922
|
+
const client = await this.ensureClient(key, spec, root);
|
|
69923
|
+
if (!client)
|
|
69924
|
+
return "";
|
|
69925
|
+
if (!client.isAlive) {
|
|
69926
|
+
this.clients.set(key, Promise.resolve(null));
|
|
69927
|
+
log("WARN", "lsp", `${spec.id} server died`, { root });
|
|
69928
|
+
return "";
|
|
69929
|
+
}
|
|
69930
|
+
const uri = client.syncDocument(path8.resolve(this.cwd, filePath), content);
|
|
69931
|
+
const diagnostics = await client.collectDiagnostics(uri, budgetMs);
|
|
69932
|
+
this.warmKeys.add(key);
|
|
69933
|
+
if (diagnostics === null)
|
|
69934
|
+
return "";
|
|
69935
|
+
const relPath = path8.relative(this.cwd, path8.resolve(this.cwd, filePath));
|
|
69936
|
+
return formatDiagnostics(relPath, diagnostics);
|
|
69937
|
+
}
|
|
69938
|
+
ensureClient(key, spec, root) {
|
|
69939
|
+
const existing = this.clients.get(key);
|
|
69940
|
+
if (existing)
|
|
69941
|
+
return existing;
|
|
69942
|
+
const pending = (async () => {
|
|
69943
|
+
const command = spec.resolveCommand(root);
|
|
69944
|
+
if (!command) {
|
|
69945
|
+
log("INFO", "lsp", `${spec.id} language server not available`, { root });
|
|
69946
|
+
return null;
|
|
69947
|
+
}
|
|
69948
|
+
try {
|
|
69949
|
+
const startedAt = Date.now();
|
|
69950
|
+
const client = new LspClient(spec, root, command);
|
|
69951
|
+
await client.initialize(INIT_TIMEOUT_MS);
|
|
69952
|
+
log("INFO", "lsp", `${spec.id} server initialized`, {
|
|
69953
|
+
root,
|
|
69954
|
+
ms: String(Date.now() - startedAt)
|
|
69955
|
+
});
|
|
69956
|
+
return client;
|
|
69957
|
+
} catch (error51) {
|
|
69958
|
+
log("WARN", "lsp", `${spec.id} server failed to start`, {
|
|
69959
|
+
root,
|
|
69960
|
+
error: error51 instanceof Error ? error51.message : String(error51)
|
|
69961
|
+
});
|
|
69962
|
+
return null;
|
|
69963
|
+
}
|
|
69964
|
+
})();
|
|
69965
|
+
this.clients.set(key, pending);
|
|
69966
|
+
return pending;
|
|
69967
|
+
}
|
|
69968
|
+
};
|
|
69969
|
+
function withBudget(work, budgetMs) {
|
|
69970
|
+
return new Promise((resolve2) => {
|
|
69971
|
+
const timer = setTimeout(() => resolve2(""), budgetMs);
|
|
69972
|
+
timer.unref();
|
|
69973
|
+
work.then((result) => {
|
|
69974
|
+
clearTimeout(timer);
|
|
69975
|
+
resolve2(result);
|
|
69976
|
+
}).catch(() => {
|
|
69977
|
+
clearTimeout(timer);
|
|
69978
|
+
resolve2("");
|
|
69979
|
+
});
|
|
69980
|
+
});
|
|
69981
|
+
}
|
|
69982
|
+
|
|
69293
69983
|
// ../ggcoder/dist/tools/read.js
|
|
69294
69984
|
init_esm_shims();
|
|
69295
|
-
import
|
|
69296
|
-
import
|
|
69985
|
+
import fs12 from "fs/promises";
|
|
69986
|
+
import path12 from "path";
|
|
69297
69987
|
|
|
69298
69988
|
// ../ggcoder/dist/tools/path-utils.js
|
|
69299
69989
|
init_esm_shims();
|
|
69300
|
-
import
|
|
69301
|
-
import
|
|
69990
|
+
import fs8 from "fs/promises";
|
|
69991
|
+
import path9 from "path";
|
|
69302
69992
|
import os4 from "os";
|
|
69303
69993
|
function resolvePath(cwd2, filePath) {
|
|
69304
69994
|
if (filePath.startsWith("~")) {
|
|
69305
|
-
filePath =
|
|
69995
|
+
filePath = path9.join(os4.homedir(), filePath.slice(1));
|
|
69306
69996
|
}
|
|
69307
|
-
return
|
|
69997
|
+
return path9.resolve(cwd2, filePath);
|
|
69308
69998
|
}
|
|
69309
69999
|
async function rejectSymlink(resolved) {
|
|
69310
70000
|
try {
|
|
69311
|
-
const stat = await
|
|
70001
|
+
const stat = await fs8.lstat(resolved);
|
|
69312
70002
|
if (stat.isSymbolicLink()) {
|
|
69313
70003
|
throw new Error(`Refusing to follow symlink: ${resolved}`);
|
|
69314
70004
|
}
|
|
@@ -69369,34 +70059,34 @@ function truncateTail(content, maxLines = MAX_LINES, maxBytes = MAX_BYTES2) {
|
|
|
69369
70059
|
|
|
69370
70060
|
// ../ggcoder/dist/tools/overflow.js
|
|
69371
70061
|
init_esm_shims();
|
|
69372
|
-
import
|
|
70062
|
+
import fs9 from "fs/promises";
|
|
69373
70063
|
import os5 from "os";
|
|
69374
|
-
import
|
|
70064
|
+
import path10 from "path";
|
|
69375
70065
|
async function writeOverflow(content, prefix) {
|
|
69376
|
-
const filePath =
|
|
69377
|
-
await
|
|
70066
|
+
const filePath = path10.join(os5.tmpdir(), `gg-${prefix}-${Date.now()}.txt`);
|
|
70067
|
+
await fs9.writeFile(filePath, content, { encoding: "utf-8", mode: 384 });
|
|
69378
70068
|
return filePath;
|
|
69379
70069
|
}
|
|
69380
70070
|
|
|
69381
70071
|
// ../ggcoder/dist/tools/operations.js
|
|
69382
70072
|
init_esm_shims();
|
|
69383
|
-
import
|
|
69384
|
-
import { spawn as
|
|
70073
|
+
import fs10 from "fs/promises";
|
|
70074
|
+
import { spawn as spawn4 } from "child_process";
|
|
69385
70075
|
import { createReadStream } from "fs";
|
|
69386
70076
|
var localOperations = {
|
|
69387
|
-
readFile: (
|
|
69388
|
-
writeFile: async (
|
|
70077
|
+
readFile: (path45) => fs10.readFile(path45, "utf-8"),
|
|
70078
|
+
writeFile: async (path45, content) => {
|
|
69389
70079
|
const { dirname: dirname3 } = await import("path");
|
|
69390
|
-
await
|
|
69391
|
-
await
|
|
70080
|
+
await fs10.mkdir(dirname3(path45), { recursive: true });
|
|
70081
|
+
await fs10.writeFile(path45, content, "utf-8");
|
|
69392
70082
|
},
|
|
69393
|
-
stat: (
|
|
69394
|
-
lstat: (
|
|
69395
|
-
readdir: (
|
|
69396
|
-
mkdir: (
|
|
70083
|
+
stat: (path45) => fs10.stat(path45),
|
|
70084
|
+
lstat: (path45) => fs10.lstat(path45),
|
|
70085
|
+
readdir: (path45, options) => fs10.readdir(path45, options),
|
|
70086
|
+
mkdir: (path45) => fs10.mkdir(path45, { recursive: true }).then(() => {
|
|
69397
70087
|
}),
|
|
69398
|
-
createReadStream: (
|
|
69399
|
-
spawn: (command, args, options) =>
|
|
70088
|
+
createReadStream: (path45, encoding) => createReadStream(path45, { encoding }),
|
|
70089
|
+
spawn: (command, args, options) => spawn4(command, args, {
|
|
69400
70090
|
cwd: options.cwd,
|
|
69401
70091
|
env: options.env,
|
|
69402
70092
|
detached: options.detached,
|
|
@@ -69439,9 +70129,9 @@ async function assertFresh(tracker, resolvedPath, ops) {
|
|
|
69439
70129
|
|
|
69440
70130
|
// ../ggcoder/dist/utils/image.js
|
|
69441
70131
|
init_esm_shims();
|
|
69442
|
-
import
|
|
70132
|
+
import fs11 from "fs/promises";
|
|
69443
70133
|
import os6 from "os";
|
|
69444
|
-
import
|
|
70134
|
+
import path11 from "path";
|
|
69445
70135
|
import { execFile } from "child_process";
|
|
69446
70136
|
import { promisify } from "util";
|
|
69447
70137
|
var execFileAsync = promisify(execFile);
|
|
@@ -69489,7 +70179,7 @@ async function compressVideoToFit(inputPath, targetBytes = COMPRESS_TARGET_BYTES
|
|
|
69489
70179
|
}
|
|
69490
70180
|
const totalKbps = Math.floor(targetBytes * 8 / durationSec / 1e3 * 0.9);
|
|
69491
70181
|
const videoKbps = Math.max(COMPRESS_MIN_VIDEO_KBPS, totalKbps - COMPRESS_AUDIO_KBPS);
|
|
69492
|
-
const outPath =
|
|
70182
|
+
const outPath = path11.join(os6.tmpdir(), `ggcoder-compressed-${Date.now()}.mp4`);
|
|
69493
70183
|
try {
|
|
69494
70184
|
await execFileAsync("ffmpeg", [
|
|
69495
70185
|
"-y",
|
|
@@ -69517,7 +70207,7 @@ async function compressVideoToFit(inputPath, targetBytes = COMPRESS_TARGET_BYTES
|
|
|
69517
70207
|
outPath
|
|
69518
70208
|
], { signal, maxBuffer: 16 * 1024 * 1024 });
|
|
69519
70209
|
} catch (err) {
|
|
69520
|
-
await
|
|
70210
|
+
await fs11.unlink(outPath).catch(() => {
|
|
69521
70211
|
});
|
|
69522
70212
|
return {
|
|
69523
70213
|
ok: false,
|
|
@@ -69527,15 +70217,15 @@ async function compressVideoToFit(inputPath, targetBytes = COMPRESS_TARGET_BYTES
|
|
|
69527
70217
|
let compressedBytes;
|
|
69528
70218
|
let originalBytes;
|
|
69529
70219
|
try {
|
|
69530
|
-
compressedBytes = (await
|
|
69531
|
-
originalBytes = (await
|
|
70220
|
+
compressedBytes = (await fs11.stat(outPath)).size;
|
|
70221
|
+
originalBytes = (await fs11.stat(inputPath)).size;
|
|
69532
70222
|
} catch {
|
|
69533
|
-
await
|
|
70223
|
+
await fs11.unlink(outPath).catch(() => {
|
|
69534
70224
|
});
|
|
69535
70225
|
return { ok: false, reason: "compression produced no usable output" };
|
|
69536
70226
|
}
|
|
69537
70227
|
if (compressedBytes > targetBytes) {
|
|
69538
|
-
await
|
|
70228
|
+
await fs11.unlink(outPath).catch(() => {
|
|
69539
70229
|
});
|
|
69540
70230
|
return {
|
|
69541
70231
|
ok: false,
|
|
@@ -69561,7 +70251,7 @@ var VIDEO_MEDIA_TYPES = {
|
|
|
69561
70251
|
};
|
|
69562
70252
|
var MEDIA_TYPES = IMAGE_MEDIA_TYPES;
|
|
69563
70253
|
function isAttachablePath(filePath) {
|
|
69564
|
-
const ext =
|
|
70254
|
+
const ext = path11.extname(filePath).toLowerCase();
|
|
69565
70255
|
return ATTACHABLE_EXTENSIONS.has(ext);
|
|
69566
70256
|
}
|
|
69567
70257
|
function resolvePath2(filePath, cwd2) {
|
|
@@ -69574,9 +70264,9 @@ function resolvePath2(filePath, cwd2) {
|
|
|
69574
70264
|
}
|
|
69575
70265
|
resolved = resolved.replace(/\\(.)/g, "$1");
|
|
69576
70266
|
if (resolved.startsWith("~/")) {
|
|
69577
|
-
resolved =
|
|
69578
|
-
} else if (!
|
|
69579
|
-
resolved =
|
|
70267
|
+
resolved = path11.join(process.env.HOME ?? "/", resolved.slice(2));
|
|
70268
|
+
} else if (!path11.isAbsolute(resolved)) {
|
|
70269
|
+
resolved = path11.join(cwd2, resolved);
|
|
69580
70270
|
}
|
|
69581
70271
|
return resolved;
|
|
69582
70272
|
}
|
|
@@ -69611,7 +70301,7 @@ async function extractImagePaths(text, cwd2) {
|
|
|
69611
70301
|
var extractMediaPaths = extractImagePaths;
|
|
69612
70302
|
async function fileExists(filePath) {
|
|
69613
70303
|
try {
|
|
69614
|
-
const stat = await
|
|
70304
|
+
const stat = await fs11.stat(filePath);
|
|
69615
70305
|
return stat.isFile();
|
|
69616
70306
|
} catch {
|
|
69617
70307
|
return false;
|
|
@@ -69689,13 +70379,13 @@ async function downscaleForPreview(buffer) {
|
|
|
69689
70379
|
}
|
|
69690
70380
|
}
|
|
69691
70381
|
async function readImageFile(filePath) {
|
|
69692
|
-
const ext =
|
|
69693
|
-
const fileName =
|
|
70382
|
+
const ext = path11.extname(filePath).toLowerCase();
|
|
70383
|
+
const fileName = path11.basename(filePath);
|
|
69694
70384
|
if (VIDEO_EXTENSIONS.has(ext)) {
|
|
69695
70385
|
try {
|
|
69696
70386
|
const mediaType = VIDEO_MEDIA_TYPES[ext] ?? "video/mp4";
|
|
69697
|
-
const stat = await
|
|
69698
|
-
const data = stat.size <= MAX_VIDEO_BYTES ? (await
|
|
70387
|
+
const stat = await fs11.stat(filePath);
|
|
70388
|
+
const data = stat.size <= MAX_VIDEO_BYTES ? (await fs11.readFile(filePath)).toString("base64") : "";
|
|
69699
70389
|
return { kind: "video", fileName, filePath, mediaType, data };
|
|
69700
70390
|
} catch (err) {
|
|
69701
70391
|
const reason = err instanceof Error ? err.message : String(err);
|
|
@@ -69710,7 +70400,7 @@ async function readImageFile(filePath) {
|
|
|
69710
70400
|
}
|
|
69711
70401
|
if (TEXT_EXTENSIONS.has(ext)) {
|
|
69712
70402
|
try {
|
|
69713
|
-
const content = await
|
|
70403
|
+
const content = await fs11.readFile(filePath, "utf-8");
|
|
69714
70404
|
return { kind: "text", fileName, filePath, mediaType: "text/plain", data: content };
|
|
69715
70405
|
} catch (err) {
|
|
69716
70406
|
const reason = err instanceof Error ? err.message : String(err);
|
|
@@ -69725,7 +70415,7 @@ async function readImageFile(filePath) {
|
|
|
69725
70415
|
}
|
|
69726
70416
|
try {
|
|
69727
70417
|
const mediaType = MEDIA_TYPES[ext] ?? "image/png";
|
|
69728
|
-
const rawBuffer = await
|
|
70418
|
+
const rawBuffer = await fs11.readFile(filePath);
|
|
69729
70419
|
const { buffer, mediaType: finalMediaType } = await shrinkToFit(rawBuffer, mediaType);
|
|
69730
70420
|
return {
|
|
69731
70421
|
kind: "image",
|
|
@@ -69773,8 +70463,8 @@ function getClipboardImage() {
|
|
|
69773
70463
|
return;
|
|
69774
70464
|
}
|
|
69775
70465
|
try {
|
|
69776
|
-
const rawBuffer = await
|
|
69777
|
-
await
|
|
70466
|
+
const rawBuffer = await fs11.readFile(tmpPath);
|
|
70467
|
+
await fs11.unlink(tmpPath).catch(() => {
|
|
69778
70468
|
});
|
|
69779
70469
|
const { buffer: finalBuffer, mediaType: finalMediaType } = await shrinkToFit(rawBuffer, mediaType);
|
|
69780
70470
|
resolve2({
|
|
@@ -69855,10 +70545,10 @@ function createReadTool(cwd2, readFiles, ops = localOperations, onFileRead, vide
|
|
|
69855
70545
|
async execute({ file_path, offset, limit: limit2 }, context) {
|
|
69856
70546
|
const resolved = resolvePath(cwd2, file_path);
|
|
69857
70547
|
await rejectSymlink(resolved);
|
|
69858
|
-
const ext =
|
|
70548
|
+
const ext = path12.extname(resolved).toLowerCase();
|
|
69859
70549
|
if (IMAGE_EXTENSIONS.has(ext)) {
|
|
69860
70550
|
try {
|
|
69861
|
-
const rawBuffer = await
|
|
70551
|
+
const rawBuffer = await fs12.readFile(resolved);
|
|
69862
70552
|
const mediaType = IMAGE_MEDIA_TYPES[ext] ?? "image/png";
|
|
69863
70553
|
const { buffer, mediaType: finalMediaType } = await shrinkToFit(rawBuffer, mediaType);
|
|
69864
70554
|
const resizedNote = buffer.length < rawBuffer.length ? ` (resized from ${rawBuffer.length} to ${buffer.length} bytes)` : "";
|
|
@@ -69908,7 +70598,7 @@ function createReadTool(cwd2, readFiles, ops = localOperations, onFileRead, vide
|
|
|
69908
70598
|
videoPath = result2.path;
|
|
69909
70599
|
note = ` (auto-compressed from ${(result2.originalBytes / (1024 * 1024)).toFixed(0)} MB to ${(result2.compressedBytes / (1024 * 1024)).toFixed(0)} MB for analysis)`;
|
|
69910
70600
|
}
|
|
69911
|
-
const rawBuffer = await
|
|
70601
|
+
const rawBuffer = await fs12.readFile(videoPath);
|
|
69912
70602
|
const mediaType = VIDEO_MEDIA_TYPES[ext] ?? "video/mp4";
|
|
69913
70603
|
return {
|
|
69914
70604
|
content: [
|
|
@@ -69926,7 +70616,7 @@ function createReadTool(cwd2, readFiles, ops = localOperations, onFileRead, vide
|
|
|
69926
70616
|
return `Could not read video ${resolved}: ${reason}`;
|
|
69927
70617
|
} finally {
|
|
69928
70618
|
if (compressedPath)
|
|
69929
|
-
await
|
|
70619
|
+
await fs12.unlink(compressedPath).catch(() => {
|
|
69930
70620
|
});
|
|
69931
70621
|
}
|
|
69932
70622
|
}
|
|
@@ -69981,8 +70671,8 @@ init_esm_shims();
|
|
|
69981
70671
|
|
|
69982
70672
|
// ../ggcoder/dist/tools/write.js
|
|
69983
70673
|
init_esm_shims();
|
|
69984
|
-
import
|
|
69985
|
-
import
|
|
70674
|
+
import fs13 from "fs/promises";
|
|
70675
|
+
import path13 from "path";
|
|
69986
70676
|
|
|
69987
70677
|
// ../ggcoder/dist/core/runtime-mode.js
|
|
69988
70678
|
init_esm_shims();
|
|
@@ -70004,7 +70694,7 @@ var WriteParams = external_exports.object({
|
|
|
70004
70694
|
file_path: external_exports.string().describe("The file path to write to"),
|
|
70005
70695
|
content: external_exports.string().describe("The content to write")
|
|
70006
70696
|
});
|
|
70007
|
-
function createWriteTool(cwd2, readFiles, ops = localOperations, planModeRefOrOnFileMutated, onFileMutated, onPreFileMutation) {
|
|
70697
|
+
function createWriteTool(cwd2, readFiles, ops = localOperations, planModeRefOrOnFileMutated, onFileMutated, onPreFileMutation, getDiagnostics) {
|
|
70008
70698
|
const planModeRef = isPlanModeRef(planModeRefOrOnFileMutated) ? planModeRefOrOnFileMutated : void 0;
|
|
70009
70699
|
const mutationCallback = isMutationCallback(planModeRefOrOnFileMutated) ? planModeRefOrOnFileMutated : onFileMutated;
|
|
70010
70700
|
return {
|
|
@@ -70016,12 +70706,12 @@ function createWriteTool(cwd2, readFiles, ops = localOperations, planModeRefOrOn
|
|
|
70016
70706
|
const resolved = resolvePath(cwd2, file_path);
|
|
70017
70707
|
await rejectSymlink(resolved);
|
|
70018
70708
|
if (isPlanModeActive(planModeRef)) {
|
|
70019
|
-
const plansDir =
|
|
70020
|
-
const relative =
|
|
70021
|
-
if (relative.startsWith("..") ||
|
|
70709
|
+
const plansDir = path13.join(cwd2, ".gg", "plans");
|
|
70710
|
+
const relative = path13.relative(plansDir, resolved);
|
|
70711
|
+
if (relative.startsWith("..") || path13.isAbsolute(relative)) {
|
|
70022
70712
|
return `Error: write is restricted in plan mode. You can only write to .gg/plans/. Got: ${file_path}`;
|
|
70023
70713
|
}
|
|
70024
|
-
await
|
|
70714
|
+
await fs13.mkdir(plansDir, { recursive: true });
|
|
70025
70715
|
}
|
|
70026
70716
|
if (readFiles) {
|
|
70027
70717
|
const exists = await ops.stat(resolved).then(() => true, () => false);
|
|
@@ -70033,15 +70723,22 @@ function createWriteTool(cwd2, readFiles, ops = localOperations, planModeRefOrOn
|
|
|
70033
70723
|
await ops.writeFile(resolved, content);
|
|
70034
70724
|
await recordWrite(readFiles, resolved, content, ops);
|
|
70035
70725
|
await mutationCallback?.(resolved);
|
|
70726
|
+
let diagnosticsNote = "";
|
|
70727
|
+
if (getDiagnostics) {
|
|
70728
|
+
try {
|
|
70729
|
+
diagnosticsNote = await getDiagnostics(resolved, content);
|
|
70730
|
+
} catch {
|
|
70731
|
+
}
|
|
70732
|
+
}
|
|
70036
70733
|
const lines = content.split("\n").length;
|
|
70037
|
-
return `Wrote ${lines} lines to ${resolved}
|
|
70734
|
+
return `Wrote ${lines} lines to ${resolved}` + diagnosticsNote;
|
|
70038
70735
|
}
|
|
70039
70736
|
};
|
|
70040
70737
|
}
|
|
70041
70738
|
|
|
70042
70739
|
// ../ggcoder/dist/tools/edit.js
|
|
70043
70740
|
init_esm_shims();
|
|
70044
|
-
import
|
|
70741
|
+
import path14 from "path";
|
|
70045
70742
|
|
|
70046
70743
|
// ../ggcoder/dist/tools/edit-diff.js
|
|
70047
70744
|
init_esm_shims();
|
|
@@ -70150,16 +70847,16 @@ var Diff = class {
|
|
|
70150
70847
|
}
|
|
70151
70848
|
}
|
|
70152
70849
|
}
|
|
70153
|
-
addToPath(
|
|
70154
|
-
const last =
|
|
70850
|
+
addToPath(path45, added, removed, oldPosInc, options) {
|
|
70851
|
+
const last = path45.lastComponent;
|
|
70155
70852
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
70156
70853
|
return {
|
|
70157
|
-
oldPos:
|
|
70854
|
+
oldPos: path45.oldPos + oldPosInc,
|
|
70158
70855
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
70159
70856
|
};
|
|
70160
70857
|
} else {
|
|
70161
70858
|
return {
|
|
70162
|
-
oldPos:
|
|
70859
|
+
oldPos: path45.oldPos + oldPosInc,
|
|
70163
70860
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
70164
70861
|
};
|
|
70165
70862
|
}
|
|
@@ -70907,7 +71604,7 @@ function tryMatch(working, old, next, replaceAll) {
|
|
|
70907
71604
|
newWorking: working.slice(0, match.index) + next + working.slice(match.index + match.matchLength)
|
|
70908
71605
|
};
|
|
70909
71606
|
}
|
|
70910
|
-
function createEditTool(cwd2, readFiles, ops = localOperations, planModeRefOrOnFileMutated, onFileMutated, onPreFileMutation) {
|
|
71607
|
+
function createEditTool(cwd2, readFiles, ops = localOperations, planModeRefOrOnFileMutated, onFileMutated, onPreFileMutation, getDiagnostics) {
|
|
70911
71608
|
const planModeRef = isPlanModeRef2(planModeRefOrOnFileMutated) ? planModeRefOrOnFileMutated : void 0;
|
|
70912
71609
|
const mutationCallback = isMutationCallback2(planModeRefOrOnFileMutated) ? planModeRefOrOnFileMutated : onFileMutated;
|
|
70913
71610
|
return {
|
|
@@ -70926,7 +71623,7 @@ function createEditTool(cwd2, readFiles, ops = localOperations, planModeRefOrOnF
|
|
|
70926
71623
|
const hasCRLF = original.includes("\r\n");
|
|
70927
71624
|
const originalNormalized = hasCRLF ? original.replace(/\r\n/g, "\n") : original;
|
|
70928
71625
|
let working = originalNormalized;
|
|
70929
|
-
const fileName =
|
|
71626
|
+
const fileName = path14.basename(resolved);
|
|
70930
71627
|
const outcomes = new Array(edits.length);
|
|
70931
71628
|
for (let i = 0; i < edits.length; i++) {
|
|
70932
71629
|
const { old_text, new_text, replace_all } = edits[i];
|
|
@@ -71028,15 +71725,22 @@ ${f.closestSnippet}`;
|
|
|
71028
71725
|
` : "";
|
|
71029
71726
|
throw new Error(header + formatFailures());
|
|
71030
71727
|
}
|
|
71031
|
-
const relPath =
|
|
71728
|
+
const relPath = path14.relative(cwd2, resolved);
|
|
71032
71729
|
const diff3 = generateDiff(originalNormalized, working, relPath);
|
|
71033
71730
|
const changed = working !== originalNormalized;
|
|
71731
|
+
let diagnosticsNote = "";
|
|
71034
71732
|
if (changed) {
|
|
71035
71733
|
const finalContent = hasCRLF ? working.replace(/\n/g, "\r\n") : working;
|
|
71036
71734
|
await onPreFileMutation?.(resolved);
|
|
71037
71735
|
await ops.writeFile(resolved, finalContent);
|
|
71038
71736
|
await recordWrite(readFiles, resolved, finalContent, ops);
|
|
71039
71737
|
await mutationCallback?.(resolved);
|
|
71738
|
+
if (getDiagnostics) {
|
|
71739
|
+
try {
|
|
71740
|
+
diagnosticsNote = await getDiagnostics(resolved, finalContent);
|
|
71741
|
+
} catch {
|
|
71742
|
+
}
|
|
71743
|
+
}
|
|
71040
71744
|
}
|
|
71041
71745
|
if (failures.length === 0) {
|
|
71042
71746
|
if (!changed) {
|
|
@@ -71044,13 +71748,13 @@ ${f.closestSnippet}`;
|
|
|
71044
71748
|
return { content: summary2, details: { diff: diff3 } };
|
|
71045
71749
|
}
|
|
71046
71750
|
const summary = edits.length > 1 ? `Successfully applied ${edits.length} edits to ${relPath}.` : `Successfully replaced text in ${relPath}.`;
|
|
71047
|
-
return { content: summary, details: { diff: diff3 } };
|
|
71751
|
+
return { content: summary + diagnosticsNote, details: { diff: diff3 } };
|
|
71048
71752
|
}
|
|
71049
71753
|
const noun = failures.length === 1 ? "edit" : "edits";
|
|
71050
71754
|
const content = `Applied ${successCount} of ${edits.length} edits to ${relPath}.
|
|
71051
71755
|
${failures.length} ${noun} skipped \u2014 re-issue ONLY these (the rest are already done, do not redo them):
|
|
71052
71756
|
|
|
71053
|
-
` + formatFailures();
|
|
71757
|
+
` + formatFailures() + diagnosticsNote;
|
|
71054
71758
|
return { content, details: { diff: diff3 } };
|
|
71055
71759
|
}
|
|
71056
71760
|
};
|
|
@@ -71293,8 +71997,8 @@ Failed to spawn: ${err.message}`);
|
|
|
71293
71997
|
|
|
71294
71998
|
// ../ggcoder/dist/tools/find.js
|
|
71295
71999
|
init_esm_shims();
|
|
71296
|
-
import
|
|
71297
|
-
import
|
|
72000
|
+
import fs14 from "fs/promises";
|
|
72001
|
+
import path15 from "path";
|
|
71298
72002
|
var FindParams = external_exports.object({
|
|
71299
72003
|
pattern: external_exports.string().describe("Glob pattern to match files (e.g. '**/*.ts', 'src/**/*.tsx')"),
|
|
71300
72004
|
path: external_exports.string().optional().describe("Directory to search in (defaults to cwd)")
|
|
@@ -71340,7 +72044,7 @@ ${filtered.length} file(s) found`;
|
|
|
71340
72044
|
}
|
|
71341
72045
|
async function loadGitignore(dir) {
|
|
71342
72046
|
try {
|
|
71343
|
-
const content = await
|
|
72047
|
+
const content = await fs14.readFile(path15.join(dir, ".gitignore"), "utf-8");
|
|
71344
72048
|
return content.split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
71345
72049
|
} catch {
|
|
71346
72050
|
return [];
|
|
@@ -71350,7 +72054,7 @@ async function loadGitignore(dir) {
|
|
|
71350
72054
|
// ../ggcoder/dist/tools/grep.js
|
|
71351
72055
|
init_esm_shims();
|
|
71352
72056
|
import readline from "readline";
|
|
71353
|
-
import
|
|
72057
|
+
import path16 from "path";
|
|
71354
72058
|
var GrepParams = external_exports.object({
|
|
71355
72059
|
pattern: external_exports.string().describe("Search pattern (regex supported)"),
|
|
71356
72060
|
path: external_exports.string().optional().describe("File or directory to search (defaults to cwd)"),
|
|
@@ -71406,10 +72110,10 @@ function createGrepTool(cwd2, ops = localOperations) {
|
|
|
71406
72110
|
}
|
|
71407
72111
|
scannedCandidates += 1;
|
|
71408
72112
|
const entry = typeof item === "string" ? item : item.path;
|
|
71409
|
-
const ext =
|
|
72113
|
+
const ext = path16.extname(entry).toLowerCase();
|
|
71410
72114
|
if (BINARY_EXTENSIONS.has(ext))
|
|
71411
72115
|
continue;
|
|
71412
|
-
const filePath =
|
|
72116
|
+
const filePath = path16.join(dir, entry);
|
|
71413
72117
|
const fileResults = await searchFile(filePath, regex2, cwd2, maxResults - results.length, ops);
|
|
71414
72118
|
results.push(...fileResults);
|
|
71415
72119
|
}
|
|
@@ -71419,7 +72123,7 @@ function createGrepTool(cwd2, ops = localOperations) {
|
|
|
71419
72123
|
}
|
|
71420
72124
|
async function searchFile(filePath, regex2, cwd2, maxResults, ops) {
|
|
71421
72125
|
const results = [];
|
|
71422
|
-
const relPath =
|
|
72126
|
+
const relPath = path16.relative(cwd2, filePath);
|
|
71423
72127
|
try {
|
|
71424
72128
|
const fileStat = await ops.stat(filePath);
|
|
71425
72129
|
if (fileStat.size > MAX_FILE_SIZE)
|
|
@@ -71481,7 +72185,7 @@ ${results.length} match(es) found`;
|
|
|
71481
72185
|
|
|
71482
72186
|
// ../ggcoder/dist/tools/ls.js
|
|
71483
72187
|
init_esm_shims();
|
|
71484
|
-
import
|
|
72188
|
+
import path17 from "path";
|
|
71485
72189
|
var LsParams = external_exports.object({
|
|
71486
72190
|
path: external_exports.string().optional().describe("Directory path (defaults to cwd)"),
|
|
71487
72191
|
all: external_exports.boolean().optional().describe("Show hidden files (default: false)")
|
|
@@ -71503,7 +72207,7 @@ function createLsTool(cwd2, ops = localOperations) {
|
|
|
71503
72207
|
}
|
|
71504
72208
|
for (const file2 of files) {
|
|
71505
72209
|
try {
|
|
71506
|
-
const stat = await ops.stat(
|
|
72210
|
+
const stat = await ops.stat(path17.join(resolved, file2.name));
|
|
71507
72211
|
const size = formatSize(stat.size);
|
|
71508
72212
|
const type2 = file2.isSymbolicLink() ? "l" : "f";
|
|
71509
72213
|
lines.push(`${type2} ${size.padStart(8)} ${file2.name}`);
|
|
@@ -71529,13 +72233,8 @@ function formatSize(bytes) {
|
|
|
71529
72233
|
|
|
71530
72234
|
// ../ggcoder/dist/tools/subagent.js
|
|
71531
72235
|
init_esm_shims();
|
|
71532
|
-
import { spawn as
|
|
72236
|
+
import { spawn as spawn5 } from "child_process";
|
|
71533
72237
|
import { createInterface } from "readline";
|
|
71534
|
-
|
|
71535
|
-
// ../ggcoder/dist/core/logger.js
|
|
71536
|
-
init_esm_shims();
|
|
71537
|
-
|
|
71538
|
-
// ../ggcoder/dist/tools/subagent.js
|
|
71539
72238
|
var SUB_AGENT_MAX_TURNS = 10;
|
|
71540
72239
|
var SUB_AGENT_MAX_OUTPUT_CHARS = 1e5;
|
|
71541
72240
|
var SUB_AGENT_MAX_OUTPUT_LINES = 500;
|
|
@@ -71594,7 +72293,7 @@ ${agentList}` : "\n\nNo named agents configured.";
|
|
|
71594
72293
|
}
|
|
71595
72294
|
cliArgs.push(args.task);
|
|
71596
72295
|
const binPath = process.argv[1];
|
|
71597
|
-
const child =
|
|
72296
|
+
const child = spawn5(process.execPath, [binPath, ...cliArgs], {
|
|
71598
72297
|
cwd: cwd2,
|
|
71599
72298
|
stdio: ["ignore", "pipe", "pipe"],
|
|
71600
72299
|
env: { ...process.env }
|
|
@@ -72987,9 +73686,9 @@ function createWebSearchTool() {
|
|
|
72987
73686
|
|
|
72988
73687
|
// ../ggcoder/dist/tools/source-path.js
|
|
72989
73688
|
init_esm_shims();
|
|
72990
|
-
import { spawn as
|
|
72991
|
-
import
|
|
72992
|
-
import { fileURLToPath } from "url";
|
|
73689
|
+
import { spawn as spawn6 } from "child_process";
|
|
73690
|
+
import path18 from "path";
|
|
73691
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
72993
73692
|
var SOURCE_PATH_TIMEOUT_MS = 12e4;
|
|
72994
73693
|
var MAX_STDERR_CHARS = 1e4;
|
|
72995
73694
|
var OPENSRC_BIN_ENV = "GG_CODER_OPENSRC_BIN";
|
|
@@ -73010,7 +73709,7 @@ function createSourcePathTool(cwd2) {
|
|
|
73010
73709
|
cliArgs.push("--verbose");
|
|
73011
73710
|
log("INFO", "source_path", "opensrc path start", { package: args.package, cwd: cwd2 });
|
|
73012
73711
|
return new Promise((resolve2) => {
|
|
73013
|
-
const child =
|
|
73712
|
+
const child = spawn6(process.execPath, [opensrcBin, ...cliArgs], {
|
|
73014
73713
|
cwd: cwd2,
|
|
73015
73714
|
stdio: ["ignore", "pipe", "pipe"],
|
|
73016
73715
|
env: getOpenSrcEnv()
|
|
@@ -73088,8 +73787,8 @@ function getBundledOpenSrcBinPath() {
|
|
|
73088
73787
|
const override = process.env[OPENSRC_BIN_ENV]?.trim();
|
|
73089
73788
|
if (override)
|
|
73090
73789
|
return override;
|
|
73091
|
-
const currentDir =
|
|
73092
|
-
return
|
|
73790
|
+
const currentDir = path18.dirname(fileURLToPath2(import.meta.url));
|
|
73791
|
+
return path18.resolve(currentDir, "../../node_modules/opensrc/bin/opensrc.js");
|
|
73093
73792
|
}
|
|
73094
73793
|
function getOpenSrcEnv() {
|
|
73095
73794
|
return {
|
|
@@ -73337,7 +74036,7 @@ ${list}`;
|
|
|
73337
74036
|
|
|
73338
74037
|
// ../ggcoder/dist/tools/screenshot.js
|
|
73339
74038
|
init_esm_shims();
|
|
73340
|
-
import
|
|
74039
|
+
import path19 from "path";
|
|
73341
74040
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
73342
74041
|
var INSTALL_HINT = "Browser engine not installed. Add the optional dependency and download Chromium:\n pnpm add -w playwright && npx playwright install chromium\nThen retry the screenshot.";
|
|
73343
74042
|
var ActionInput = external_exports.object({
|
|
@@ -73375,7 +74074,7 @@ function isBrowserBinaryMissing(err) {
|
|
|
73375
74074
|
}
|
|
73376
74075
|
function defaultOutPath(cwd2) {
|
|
73377
74076
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
73378
|
-
return
|
|
74077
|
+
return path19.join(cwd2, ".gg", "screenshots", `${stamp}.png`);
|
|
73379
74078
|
}
|
|
73380
74079
|
async function runActions(page, actions) {
|
|
73381
74080
|
for (const action of actions ?? []) {
|
|
@@ -73426,7 +74125,7 @@ function createScreenshotTool(cwd2) {
|
|
|
73426
74125
|
await runActions(page, args.actions);
|
|
73427
74126
|
const raw = await page.screenshot({ fullPage: args.full_page ?? false });
|
|
73428
74127
|
context.signal.removeEventListener("abort", onAbort);
|
|
73429
|
-
await mkdir2(
|
|
74128
|
+
await mkdir2(path19.dirname(outPath), { recursive: true });
|
|
73430
74129
|
await writeFile2(outPath, raw);
|
|
73431
74130
|
const { buffer, mediaType } = await shrinkToFit(raw, "image/png");
|
|
73432
74131
|
const previewBuffer = await downscaleForPreview(buffer);
|
|
@@ -73478,8 +74177,8 @@ function createEnterPlanTool(onEnterPlan) {
|
|
|
73478
74177
|
|
|
73479
74178
|
// ../ggcoder/dist/tools/exit-plan.js
|
|
73480
74179
|
init_esm_shims();
|
|
73481
|
-
import
|
|
73482
|
-
import
|
|
74180
|
+
import fs15 from "fs/promises";
|
|
74181
|
+
import path20 from "path";
|
|
73483
74182
|
var ExitPlanParams = external_exports.object({
|
|
73484
74183
|
plan_path: external_exports.string().describe("Path to the plan markdown file; must be under .gg/plans/")
|
|
73485
74184
|
});
|
|
@@ -73491,13 +74190,13 @@ function createExitPlanTool(cwd2, onExitPlan) {
|
|
|
73491
74190
|
executionMode: "sequential",
|
|
73492
74191
|
async execute({ plan_path }) {
|
|
73493
74192
|
const resolved = resolvePath(cwd2, plan_path);
|
|
73494
|
-
const plansDir =
|
|
73495
|
-
const relative =
|
|
73496
|
-
if (relative.startsWith("..") ||
|
|
74193
|
+
const plansDir = path20.join(cwd2, ".gg", "plans");
|
|
74194
|
+
const relative = path20.relative(plansDir, resolved);
|
|
74195
|
+
if (relative.startsWith("..") || path20.isAbsolute(relative)) {
|
|
73497
74196
|
return `Error: plan_path must be under .gg/plans/. Got: ${plan_path}`;
|
|
73498
74197
|
}
|
|
73499
74198
|
try {
|
|
73500
|
-
const content = await
|
|
74199
|
+
const content = await fs15.readFile(resolved, "utf-8");
|
|
73501
74200
|
if (!content.trim()) {
|
|
73502
74201
|
return "Error: Plan file is empty. Write your plan before calling exit_plan.";
|
|
73503
74202
|
}
|
|
@@ -73515,11 +74214,14 @@ function createTools(cwd2, opts) {
|
|
|
73515
74214
|
const processManager = new ProcessManager();
|
|
73516
74215
|
const ops = opts?.operations ?? localOperations;
|
|
73517
74216
|
const planModeRef = opts?.planModeRef;
|
|
74217
|
+
const lspEnabled = (opts?.lspDiagnostics ?? true) && ops === localOperations;
|
|
74218
|
+
const lspManager = lspEnabled ? new LspManager(cwd2) : void 0;
|
|
74219
|
+
const getDiagnostics = lspManager ? (filePath, content) => lspManager.diagnosticsAfterWrite(filePath, content) : void 0;
|
|
73518
74220
|
const videoByteLimit = opts?.model ? getVideoByteLimit(opts.model) : void 0;
|
|
73519
74221
|
const tools = [
|
|
73520
74222
|
createReadTool(cwd2, readFiles, ops, opts?.onFileRead, videoByteLimit),
|
|
73521
|
-
createWriteTool(cwd2, readFiles, ops, planModeRef, opts?.onFileMutated, opts?.onPreFileMutation),
|
|
73522
|
-
createEditTool(cwd2, readFiles, ops, planModeRef, opts?.onFileMutated, opts?.onPreFileMutation),
|
|
74223
|
+
createWriteTool(cwd2, readFiles, ops, planModeRef, opts?.onFileMutated, opts?.onPreFileMutation, getDiagnostics),
|
|
74224
|
+
createEditTool(cwd2, readFiles, ops, planModeRef, opts?.onFileMutated, opts?.onPreFileMutation, getDiagnostics),
|
|
73523
74225
|
createBashTool(cwd2, processManager, ops, planModeRef),
|
|
73524
74226
|
createFindTool(cwd2),
|
|
73525
74227
|
createGrepTool(cwd2, ops),
|
|
@@ -73548,24 +74250,24 @@ function createTools(cwd2, opts) {
|
|
|
73548
74250
|
tools.push(createExitPlanTool(cwd2, opts.onExitPlan));
|
|
73549
74251
|
}
|
|
73550
74252
|
const rebuildReadTool = (model) => createReadTool(cwd2, readFiles, ops, opts?.onFileRead, getVideoByteLimit(model));
|
|
73551
|
-
return { tools, processManager, rebuildReadTool };
|
|
74253
|
+
return { tools, processManager, rebuildReadTool, lspManager };
|
|
73552
74254
|
}
|
|
73553
74255
|
|
|
73554
74256
|
// ../ggcoder/dist/system-prompt.js
|
|
73555
74257
|
init_esm_shims();
|
|
73556
|
-
import
|
|
73557
|
-
import
|
|
74258
|
+
import fs20 from "fs/promises";
|
|
74259
|
+
import path26 from "path";
|
|
73558
74260
|
|
|
73559
74261
|
// ../ggcoder/dist/core/skills.js
|
|
73560
74262
|
init_esm_shims();
|
|
73561
|
-
import
|
|
73562
|
-
import
|
|
74263
|
+
import fs16 from "fs/promises";
|
|
74264
|
+
import path21 from "path";
|
|
73563
74265
|
async function discoverSkills(options) {
|
|
73564
74266
|
const skills = [];
|
|
73565
74267
|
const globalSkills = await loadSkillsFromDir(options.globalSkillsDir, "global");
|
|
73566
74268
|
skills.push(...globalSkills);
|
|
73567
74269
|
if (options.projectDir) {
|
|
73568
|
-
const projectSkillsDir =
|
|
74270
|
+
const projectSkillsDir = path21.join(options.projectDir, ".gg", "skills");
|
|
73569
74271
|
const projectSkills = await loadSkillsFromDir(projectSkillsDir, "project");
|
|
73570
74272
|
skills.push(...projectSkills);
|
|
73571
74273
|
}
|
|
@@ -73575,27 +74277,27 @@ async function loadSkillsFromDir(dir, source2) {
|
|
|
73575
74277
|
const skills = [];
|
|
73576
74278
|
let dirents;
|
|
73577
74279
|
try {
|
|
73578
|
-
dirents = await
|
|
74280
|
+
dirents = await fs16.readdir(dir, { withFileTypes: true });
|
|
73579
74281
|
} catch {
|
|
73580
74282
|
return skills;
|
|
73581
74283
|
}
|
|
73582
74284
|
for (const entry of dirents) {
|
|
73583
|
-
const entryPath =
|
|
74285
|
+
const entryPath = path21.join(dir, entry.name);
|
|
73584
74286
|
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
73585
74287
|
try {
|
|
73586
|
-
const content = await
|
|
74288
|
+
const content = await fs16.readFile(entryPath, "utf-8");
|
|
73587
74289
|
const skill = parseSkillFile(content, source2);
|
|
73588
74290
|
if (!skill.name)
|
|
73589
|
-
skill.name =
|
|
74291
|
+
skill.name = path21.basename(entry.name, ".md");
|
|
73590
74292
|
skills.push(skill);
|
|
73591
74293
|
} catch {
|
|
73592
74294
|
}
|
|
73593
74295
|
continue;
|
|
73594
74296
|
}
|
|
73595
74297
|
if (entry.isDirectory()) {
|
|
73596
|
-
const skillFile =
|
|
74298
|
+
const skillFile = path21.join(entryPath, "SKILL.md");
|
|
73597
74299
|
try {
|
|
73598
|
-
const content = await
|
|
74300
|
+
const content = await fs16.readFile(skillFile, "utf-8");
|
|
73599
74301
|
const skill = parseSkillFile(content, source2);
|
|
73600
74302
|
if (!skill.name)
|
|
73601
74303
|
skill.name = entry.name;
|
|
@@ -73695,13 +74397,13 @@ var DEFAULT_TOOL_NAMES = [
|
|
|
73695
74397
|
|
|
73696
74398
|
// ../ggcoder/dist/core/style-packs/index.js
|
|
73697
74399
|
init_esm_shims();
|
|
73698
|
-
import
|
|
73699
|
-
import
|
|
74400
|
+
import fs18 from "fs";
|
|
74401
|
+
import path24 from "path";
|
|
73700
74402
|
|
|
73701
74403
|
// ../ggcoder/dist/core/language-detector.js
|
|
73702
74404
|
init_esm_shims();
|
|
73703
|
-
import
|
|
73704
|
-
import
|
|
74405
|
+
import fs17 from "fs";
|
|
74406
|
+
import path23 from "path";
|
|
73705
74407
|
var MARKERS = {
|
|
73706
74408
|
typescript: { manifests: ["tsconfig.json"], extensions: [".ts", ".tsx", ".mts", ".cts"] },
|
|
73707
74409
|
// JS is only flagged when there's a package.json AND no tsconfig — pure JS projects.
|
|
@@ -73989,11 +74691,11 @@ var PACKS = {
|
|
|
73989
74691
|
|
|
73990
74692
|
// ../ggcoder/dist/core/style-packs/index.js
|
|
73991
74693
|
function loadPack(id2, cwd2) {
|
|
73992
|
-
const overridePath =
|
|
74694
|
+
const overridePath = path24.join(cwd2, ".gg", "styles", `${id2}.md`);
|
|
73993
74695
|
try {
|
|
73994
|
-
const stat =
|
|
74696
|
+
const stat = fs18.statSync(overridePath);
|
|
73995
74697
|
if (stat.isFile()) {
|
|
73996
|
-
return
|
|
74698
|
+
return fs18.readFileSync(overridePath, "utf-8").trim();
|
|
73997
74699
|
}
|
|
73998
74700
|
} catch {
|
|
73999
74701
|
}
|
|
@@ -74032,8 +74734,8 @@ Universal rules for agent-written code:
|
|
|
74032
74734
|
|
|
74033
74735
|
// ../ggcoder/dist/core/verify-commands.js
|
|
74034
74736
|
init_esm_shims();
|
|
74035
|
-
import
|
|
74036
|
-
import
|
|
74737
|
+
import fs19 from "fs";
|
|
74738
|
+
import path25 from "path";
|
|
74037
74739
|
function detectVerifyCommands(cwd2, active) {
|
|
74038
74740
|
const cmds = [];
|
|
74039
74741
|
if (active.has("typescript") || active.has("javascript")) {
|
|
@@ -74060,12 +74762,12 @@ function detectVerifyCommands(cwd2, active) {
|
|
|
74060
74762
|
const testScript = pick2("test", "test:unit");
|
|
74061
74763
|
if (testScript)
|
|
74062
74764
|
cmds.push({ label: "test", command: `${runner} ${testScript}`, language: lang });
|
|
74063
|
-
} else if (active.has("typescript") && fileExists2(
|
|
74765
|
+
} else if (active.has("typescript") && fileExists2(path25.join(cwd2, "tsconfig.json"))) {
|
|
74064
74766
|
cmds.push({ label: "typecheck", command: "tsc --noEmit", language: "typescript" });
|
|
74065
74767
|
}
|
|
74066
74768
|
}
|
|
74067
74769
|
if (active.has("python")) {
|
|
74068
|
-
const pyproject = readFileSafe(
|
|
74770
|
+
const pyproject = readFileSafe(path25.join(cwd2, "pyproject.toml"));
|
|
74069
74771
|
if (pyproject) {
|
|
74070
74772
|
if (/\[tool\.ruff/.test(pyproject)) {
|
|
74071
74773
|
cmds.push({ label: "lint", command: "ruff check .", language: "python" });
|
|
@@ -74097,10 +74799,10 @@ function detectVerifyCommands(cwd2, active) {
|
|
|
74097
74799
|
}
|
|
74098
74800
|
if (active.has("java") || active.has("kotlin")) {
|
|
74099
74801
|
const lang = active.has("kotlin") ? "kotlin" : "java";
|
|
74100
|
-
if (fileExists2(
|
|
74802
|
+
if (fileExists2(path25.join(cwd2, "gradlew"))) {
|
|
74101
74803
|
cmds.push({ label: "build", command: "./gradlew build", language: lang });
|
|
74102
74804
|
cmds.push({ label: "test", command: "./gradlew test", language: lang });
|
|
74103
|
-
} else if (fileExists2(
|
|
74805
|
+
} else if (fileExists2(path25.join(cwd2, "pom.xml"))) {
|
|
74104
74806
|
cmds.push({ label: "verify", command: "mvn verify", language: lang });
|
|
74105
74807
|
}
|
|
74106
74808
|
}
|
|
@@ -74114,7 +74816,7 @@ function detectVerifyCommands(cwd2, active) {
|
|
|
74114
74816
|
cmds.push({ label: "test", command: "dotnet test", language: "csharp" });
|
|
74115
74817
|
}
|
|
74116
74818
|
if (active.has("ruby")) {
|
|
74117
|
-
if (fileExists2(
|
|
74819
|
+
if (fileExists2(path25.join(cwd2, "Gemfile"))) {
|
|
74118
74820
|
cmds.push({ label: "lint", command: "bundle exec rubocop", language: "ruby" });
|
|
74119
74821
|
cmds.push({ label: "test", command: "bundle exec rspec", language: "ruby" });
|
|
74120
74822
|
}
|
|
@@ -74124,7 +74826,7 @@ function detectVerifyCommands(cwd2, active) {
|
|
|
74124
74826
|
cmds.push({ label: "test", command: "mix test", language: "elixir" });
|
|
74125
74827
|
}
|
|
74126
74828
|
if (active.has("php")) {
|
|
74127
|
-
if (fileExists2(
|
|
74829
|
+
if (fileExists2(path25.join(cwd2, "composer.json"))) {
|
|
74128
74830
|
cmds.push({ label: "test", command: "composer test", language: "php" });
|
|
74129
74831
|
}
|
|
74130
74832
|
}
|
|
@@ -74143,20 +74845,20 @@ function detectVerifyCommands(cwd2, active) {
|
|
|
74143
74845
|
}
|
|
74144
74846
|
function fileExists2(p) {
|
|
74145
74847
|
try {
|
|
74146
|
-
return
|
|
74848
|
+
return fs19.statSync(p).isFile();
|
|
74147
74849
|
} catch {
|
|
74148
74850
|
return false;
|
|
74149
74851
|
}
|
|
74150
74852
|
}
|
|
74151
74853
|
function readFileSafe(p) {
|
|
74152
74854
|
try {
|
|
74153
|
-
return
|
|
74855
|
+
return fs19.readFileSync(p, "utf-8");
|
|
74154
74856
|
} catch {
|
|
74155
74857
|
return null;
|
|
74156
74858
|
}
|
|
74157
74859
|
}
|
|
74158
74860
|
function readPackageJsonScripts(cwd2) {
|
|
74159
|
-
const raw = readFileSafe(
|
|
74861
|
+
const raw = readFileSafe(path25.join(cwd2, "package.json"));
|
|
74160
74862
|
if (!raw)
|
|
74161
74863
|
return null;
|
|
74162
74864
|
try {
|
|
@@ -74167,11 +74869,11 @@ function readPackageJsonScripts(cwd2) {
|
|
|
74167
74869
|
}
|
|
74168
74870
|
}
|
|
74169
74871
|
function detectNodeRunner(cwd2) {
|
|
74170
|
-
if (fileExists2(
|
|
74872
|
+
if (fileExists2(path25.join(cwd2, "pnpm-lock.yaml")))
|
|
74171
74873
|
return "pnpm";
|
|
74172
|
-
if (fileExists2(
|
|
74874
|
+
if (fileExists2(path25.join(cwd2, "yarn.lock")))
|
|
74173
74875
|
return "yarn";
|
|
74174
|
-
if (fileExists2(
|
|
74876
|
+
if (fileExists2(path25.join(cwd2, "bun.lockb")))
|
|
74175
74877
|
return "bun";
|
|
74176
74878
|
return "npm run";
|
|
74177
74879
|
}
|
|
@@ -74278,7 +74980,7 @@ Explore with read/search/docs tools and read-only bash (e.g. \`git log\`, \`git
|
|
|
74278
74980
|
async function renderApprovedPlanSection(approvedPlanPath) {
|
|
74279
74981
|
if (!approvedPlanPath)
|
|
74280
74982
|
return null;
|
|
74281
|
-
const planContent = await
|
|
74983
|
+
const planContent = await fs20.readFile(approvedPlanPath, "utf-8").catch(() => null);
|
|
74282
74984
|
if (planContent === null)
|
|
74283
74985
|
return null;
|
|
74284
74986
|
if (!planContent.trim())
|
|
@@ -74331,17 +75033,17 @@ async function collectProjectContext(cwd2) {
|
|
|
74331
75033
|
while (!visited.has(dir)) {
|
|
74332
75034
|
visited.add(dir);
|
|
74333
75035
|
for (const name of CONTEXT_FILES) {
|
|
74334
|
-
const filePath =
|
|
75036
|
+
const filePath = path26.join(dir, name);
|
|
74335
75037
|
try {
|
|
74336
|
-
const content = await
|
|
74337
|
-
const relPath =
|
|
75038
|
+
const content = await fs20.readFile(filePath, "utf-8");
|
|
75039
|
+
const relPath = path26.relative(cwd2, filePath) || name;
|
|
74338
75040
|
contextParts.push(`### ${relPath}
|
|
74339
75041
|
|
|
74340
75042
|
${content.trim()}`);
|
|
74341
75043
|
} catch {
|
|
74342
75044
|
}
|
|
74343
75045
|
}
|
|
74344
|
-
const parent =
|
|
75046
|
+
const parent = path26.dirname(dir);
|
|
74345
75047
|
if (parent === dir)
|
|
74346
75048
|
break;
|
|
74347
75049
|
dir = parent;
|
|
@@ -74407,11 +75109,11 @@ async function buildSystemPrompt(cwd2, skills, planMode, approvedPlanPath, toolN
|
|
|
74407
75109
|
|
|
74408
75110
|
// ../ggcoder/dist/session.js
|
|
74409
75111
|
init_esm_shims();
|
|
74410
|
-
import
|
|
74411
|
-
import
|
|
75112
|
+
import fs21 from "fs/promises";
|
|
75113
|
+
import path27 from "path";
|
|
74412
75114
|
import os7 from "os";
|
|
74413
75115
|
import crypto4 from "crypto";
|
|
74414
|
-
var SESSION_DIR =
|
|
75116
|
+
var SESSION_DIR = path27.join(os7.homedir(), ".gg", "sessions");
|
|
74415
75117
|
|
|
74416
75118
|
// ../ggcoder/dist/core/index.js
|
|
74417
75119
|
init_esm_shims();
|
|
@@ -74524,20 +75226,20 @@ init_esm_shims();
|
|
|
74524
75226
|
|
|
74525
75227
|
// ../ggcoder/dist/core/settings-manager.js
|
|
74526
75228
|
init_esm_shims();
|
|
74527
|
-
import
|
|
75229
|
+
import fs23 from "fs/promises";
|
|
74528
75230
|
|
|
74529
75231
|
// ../ggcoder/dist/config.js
|
|
74530
75232
|
init_esm_shims();
|
|
74531
|
-
import
|
|
74532
|
-
import
|
|
75233
|
+
import path28 from "path";
|
|
75234
|
+
import fs22 from "fs/promises";
|
|
74533
75235
|
import fsSync from "fs";
|
|
74534
75236
|
async function ensureAppDirs() {
|
|
74535
75237
|
const paths = getAppPaths();
|
|
74536
|
-
await
|
|
74537
|
-
await
|
|
74538
|
-
await
|
|
74539
|
-
await
|
|
74540
|
-
await
|
|
75238
|
+
await fs22.mkdir(paths.agentDir, { recursive: true, mode: 448 });
|
|
75239
|
+
await fs22.mkdir(paths.sessionsDir, { recursive: true, mode: 448 });
|
|
75240
|
+
await fs22.mkdir(paths.skillsDir, { recursive: true, mode: 448 });
|
|
75241
|
+
await fs22.mkdir(paths.extensionsDir, { recursive: true, mode: 448 });
|
|
75242
|
+
await fs22.mkdir(paths.agentsDir, { recursive: true, mode: 448 });
|
|
74541
75243
|
await seedDefaultAgents(paths.agentsDir);
|
|
74542
75244
|
await seedDefaultSkills(paths.skillsDir);
|
|
74543
75245
|
return paths;
|
|
@@ -74594,11 +75296,11 @@ Rules:
|
|
|
74594
75296
|
`
|
|
74595
75297
|
};
|
|
74596
75298
|
for (const [filename, content] of Object.entries(defaults2)) {
|
|
74597
|
-
const filePath =
|
|
75299
|
+
const filePath = path28.join(agentsDir, filename);
|
|
74598
75300
|
try {
|
|
74599
|
-
await
|
|
75301
|
+
await fs22.access(filePath);
|
|
74600
75302
|
} catch {
|
|
74601
|
-
await
|
|
75303
|
+
await fs22.writeFile(filePath, content, "utf-8");
|
|
74602
75304
|
}
|
|
74603
75305
|
}
|
|
74604
75306
|
}
|
|
@@ -74607,11 +75309,11 @@ async function seedDefaultSkills(skillsDir) {
|
|
|
74607
75309
|
"find-skills.md": FIND_SKILLS_MD
|
|
74608
75310
|
};
|
|
74609
75311
|
for (const [filename, content] of Object.entries(defaults2)) {
|
|
74610
|
-
const filePath =
|
|
75312
|
+
const filePath = path28.join(skillsDir, filename);
|
|
74611
75313
|
try {
|
|
74612
|
-
await
|
|
75314
|
+
await fs22.access(filePath);
|
|
74613
75315
|
} catch {
|
|
74614
|
-
await
|
|
75316
|
+
await fs22.writeFile(filePath, content, "utf-8");
|
|
74615
75317
|
}
|
|
74616
75318
|
}
|
|
74617
75319
|
}
|
|
@@ -74730,6 +75432,8 @@ var SettingsSchema = external_exports.object({
|
|
|
74730
75432
|
]).default("auto"),
|
|
74731
75433
|
showTokenUsage: external_exports.boolean().default(true),
|
|
74732
75434
|
idealReviewEnabled: external_exports.boolean().default(true),
|
|
75435
|
+
/** Append LSP diagnostics to edit/write tool results. */
|
|
75436
|
+
lspDiagnostics: external_exports.boolean().default(true),
|
|
74733
75437
|
enabledTools: external_exports.array(external_exports.string()).optional(),
|
|
74734
75438
|
/** Delete session transcripts older than this many days at startup. 0 disables pruning. */
|
|
74735
75439
|
sessionRetentionDays: external_exports.number().int().min(0).default(30)
|
|
@@ -74743,6 +75447,7 @@ var DEFAULT_SETTINGS = {
|
|
|
74743
75447
|
theme: "auto",
|
|
74744
75448
|
showTokenUsage: true,
|
|
74745
75449
|
idealReviewEnabled: true,
|
|
75450
|
+
lspDiagnostics: true,
|
|
74746
75451
|
sessionRetentionDays: 30
|
|
74747
75452
|
};
|
|
74748
75453
|
var SettingsManager = class {
|
|
@@ -74754,7 +75459,7 @@ var SettingsManager = class {
|
|
|
74754
75459
|
}
|
|
74755
75460
|
async load() {
|
|
74756
75461
|
try {
|
|
74757
|
-
const content = await
|
|
75462
|
+
const content = await fs23.readFile(this.filePath, "utf-8");
|
|
74758
75463
|
const raw = JSON.parse(content);
|
|
74759
75464
|
this.settings = SettingsSchema.parse({ ...DEFAULT_SETTINGS, ...raw });
|
|
74760
75465
|
} catch {
|
|
@@ -74765,7 +75470,7 @@ var SettingsManager = class {
|
|
|
74765
75470
|
}
|
|
74766
75471
|
async save() {
|
|
74767
75472
|
const content = JSON.stringify(this.settings, null, 2);
|
|
74768
|
-
await
|
|
75473
|
+
await fs23.writeFile(this.filePath, content, "utf-8");
|
|
74769
75474
|
}
|
|
74770
75475
|
get(key) {
|
|
74771
75476
|
return this.settings[key];
|
|
@@ -74781,10 +75486,10 @@ var SettingsManager = class {
|
|
|
74781
75486
|
|
|
74782
75487
|
// ../ggcoder/dist/core/session-manager.js
|
|
74783
75488
|
init_esm_shims();
|
|
74784
|
-
import
|
|
75489
|
+
import fs24 from "fs/promises";
|
|
74785
75490
|
import { createReadStream as createReadStream2 } from "fs";
|
|
74786
75491
|
import { createInterface as createInterface2 } from "readline";
|
|
74787
|
-
import
|
|
75492
|
+
import path29 from "path";
|
|
74788
75493
|
import crypto6 from "crypto";
|
|
74789
75494
|
var DISPLAY_ITEM_CUSTOM_KIND = "display_item";
|
|
74790
75495
|
function isCompletedItemLike(value) {
|
|
@@ -74819,15 +75524,15 @@ var SessionManager = class _SessionManager {
|
|
|
74819
75524
|
this.onPersistError?.(err);
|
|
74820
75525
|
}
|
|
74821
75526
|
dirForCwd(cwd2) {
|
|
74822
|
-
return
|
|
75527
|
+
return path29.join(this.sessionsDir, encodeCwd(cwd2));
|
|
74823
75528
|
}
|
|
74824
75529
|
async create(cwd2, provider, model) {
|
|
74825
75530
|
const id2 = crypto6.randomUUID();
|
|
74826
75531
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
74827
75532
|
const dir = this.dirForCwd(cwd2);
|
|
74828
|
-
await
|
|
75533
|
+
await fs24.mkdir(dir, { recursive: true });
|
|
74829
75534
|
const fileName = `${timestamp.replace(/[:.]/g, "-")}_${id2.slice(0, 8)}.jsonl`;
|
|
74830
|
-
const filePath =
|
|
75535
|
+
const filePath = path29.join(dir, fileName);
|
|
74831
75536
|
const header = {
|
|
74832
75537
|
type: "session",
|
|
74833
75538
|
version: 2,
|
|
@@ -74838,7 +75543,7 @@ var SessionManager = class _SessionManager {
|
|
|
74838
75543
|
model,
|
|
74839
75544
|
leafId: null
|
|
74840
75545
|
};
|
|
74841
|
-
await
|
|
75546
|
+
await fs24.appendFile(filePath, JSON.stringify(header) + "\n", "utf-8");
|
|
74842
75547
|
return { id: id2, path: filePath, header };
|
|
74843
75548
|
}
|
|
74844
75549
|
async load(sessionPath) {
|
|
@@ -74891,7 +75596,7 @@ var SessionManager = class _SessionManager {
|
|
|
74891
75596
|
const dir = this.dirForCwd(cwd2);
|
|
74892
75597
|
let files;
|
|
74893
75598
|
try {
|
|
74894
|
-
files = await
|
|
75599
|
+
files = await fs24.readdir(dir);
|
|
74895
75600
|
} catch {
|
|
74896
75601
|
return [];
|
|
74897
75602
|
}
|
|
@@ -74899,7 +75604,7 @@ var SessionManager = class _SessionManager {
|
|
|
74899
75604
|
for (const file2 of files) {
|
|
74900
75605
|
if (!file2.endsWith(".jsonl"))
|
|
74901
75606
|
continue;
|
|
74902
|
-
const filePath =
|
|
75607
|
+
const filePath = path29.join(dir, file2);
|
|
74903
75608
|
try {
|
|
74904
75609
|
const rl = createInterface2({
|
|
74905
75610
|
input: createReadStream2(filePath, { encoding: "utf-8" }),
|
|
@@ -74958,21 +75663,21 @@ var SessionManager = class _SessionManager {
|
|
|
74958
75663
|
if (options.maxAgeDays <= 0)
|
|
74959
75664
|
return result;
|
|
74960
75665
|
const cutoffMs = Date.now() - options.maxAgeDays * 864e5;
|
|
74961
|
-
const keep = new Set((options.keepPaths ?? []).map((p) =>
|
|
75666
|
+
const keep = new Set((options.keepPaths ?? []).map((p) => path29.resolve(p)));
|
|
74962
75667
|
let cwdDirs;
|
|
74963
75668
|
try {
|
|
74964
|
-
cwdDirs = await
|
|
75669
|
+
cwdDirs = await fs24.readdir(this.sessionsDir);
|
|
74965
75670
|
} catch {
|
|
74966
75671
|
return result;
|
|
74967
75672
|
}
|
|
74968
75673
|
for (const dirName of cwdDirs) {
|
|
74969
|
-
const dir =
|
|
75674
|
+
const dir = path29.join(this.sessionsDir, dirName);
|
|
74970
75675
|
let files;
|
|
74971
75676
|
try {
|
|
74972
|
-
const stat = await
|
|
75677
|
+
const stat = await fs24.stat(dir);
|
|
74973
75678
|
if (!stat.isDirectory())
|
|
74974
75679
|
continue;
|
|
74975
|
-
files = await
|
|
75680
|
+
files = await fs24.readdir(dir);
|
|
74976
75681
|
} catch {
|
|
74977
75682
|
continue;
|
|
74978
75683
|
}
|
|
@@ -74980,14 +75685,14 @@ var SessionManager = class _SessionManager {
|
|
|
74980
75685
|
for (const file2 of files) {
|
|
74981
75686
|
if (!file2.endsWith(".jsonl"))
|
|
74982
75687
|
continue;
|
|
74983
|
-
const filePath =
|
|
74984
|
-
if (keep.has(
|
|
75688
|
+
const filePath = path29.join(dir, file2);
|
|
75689
|
+
if (keep.has(path29.resolve(filePath)))
|
|
74985
75690
|
continue;
|
|
74986
75691
|
try {
|
|
74987
|
-
const stat = await
|
|
75692
|
+
const stat = await fs24.stat(filePath);
|
|
74988
75693
|
if (stat.mtimeMs >= cutoffMs)
|
|
74989
75694
|
continue;
|
|
74990
|
-
await
|
|
75695
|
+
await fs24.unlink(filePath);
|
|
74991
75696
|
result.deletedFiles += 1;
|
|
74992
75697
|
result.freedBytes += stat.size;
|
|
74993
75698
|
remaining -= 1;
|
|
@@ -74995,7 +75700,7 @@ var SessionManager = class _SessionManager {
|
|
|
74995
75700
|
}
|
|
74996
75701
|
}
|
|
74997
75702
|
if (remaining === 0) {
|
|
74998
|
-
await
|
|
75703
|
+
await fs24.rmdir(dir).catch(() => {
|
|
74999
75704
|
});
|
|
75000
75705
|
}
|
|
75001
75706
|
}
|
|
@@ -75003,7 +75708,7 @@ var SessionManager = class _SessionManager {
|
|
|
75003
75708
|
}
|
|
75004
75709
|
async appendEntry(sessionPath, entry) {
|
|
75005
75710
|
try {
|
|
75006
|
-
await
|
|
75711
|
+
await fs24.appendFile(sessionPath, JSON.stringify(entry) + "\n", "utf-8");
|
|
75007
75712
|
} catch (error51) {
|
|
75008
75713
|
this.handlePersistError(error51, "appendEntry");
|
|
75009
75714
|
}
|
|
@@ -75016,7 +75721,7 @@ var SessionManager = class _SessionManager {
|
|
|
75016
75721
|
}
|
|
75017
75722
|
}
|
|
75018
75723
|
async updateLeafUnsafe(sessionPath, leafId) {
|
|
75019
|
-
const fd2 = await
|
|
75724
|
+
const fd2 = await fs24.open(sessionPath, "r+");
|
|
75020
75725
|
try {
|
|
75021
75726
|
const buf = Buffer.alloc(4096);
|
|
75022
75727
|
const { bytesRead } = await fd2.read(buf, 0, 4096, 0);
|
|
@@ -75034,9 +75739,9 @@ var SessionManager = class _SessionManager {
|
|
|
75034
75739
|
await fd2.write(newHeaderLine, 0, "utf-8");
|
|
75035
75740
|
} else {
|
|
75036
75741
|
await fd2.close();
|
|
75037
|
-
const content = await
|
|
75742
|
+
const content = await fs24.readFile(sessionPath, "utf-8");
|
|
75038
75743
|
const firstNewline = content.indexOf("\n");
|
|
75039
|
-
await
|
|
75744
|
+
await fs24.writeFile(sessionPath, newHeaderLine + content.slice(firstNewline), "utf-8");
|
|
75040
75745
|
return;
|
|
75041
75746
|
}
|
|
75042
75747
|
} finally {
|
|
@@ -75980,25 +76685,25 @@ function getPromptCommand(name) {
|
|
|
75980
76685
|
|
|
75981
76686
|
// ../ggcoder/dist/core/custom-commands.js
|
|
75982
76687
|
init_esm_shims();
|
|
75983
|
-
import
|
|
75984
|
-
import
|
|
76688
|
+
import fs25 from "fs/promises";
|
|
76689
|
+
import path30 from "path";
|
|
75985
76690
|
async function loadCustomCommands(cwd2) {
|
|
75986
|
-
const commandsDir =
|
|
76691
|
+
const commandsDir = path30.join(cwd2, ".gg", "commands");
|
|
75987
76692
|
const commands = [];
|
|
75988
76693
|
let files;
|
|
75989
76694
|
try {
|
|
75990
|
-
files = await
|
|
76695
|
+
files = await fs25.readdir(commandsDir);
|
|
75991
76696
|
} catch {
|
|
75992
76697
|
return commands;
|
|
75993
76698
|
}
|
|
75994
76699
|
for (const file2 of files) {
|
|
75995
76700
|
if (!file2.endsWith(".md"))
|
|
75996
76701
|
continue;
|
|
75997
|
-
const filePath =
|
|
76702
|
+
const filePath = path30.join(commandsDir, file2);
|
|
75998
76703
|
try {
|
|
75999
|
-
const raw = await
|
|
76704
|
+
const raw = await fs25.readFile(filePath, "utf-8");
|
|
76000
76705
|
const parsed = parseSkillFile(raw, "project");
|
|
76001
|
-
const name = parsed.name ||
|
|
76706
|
+
const name = parsed.name || path30.basename(file2, ".md");
|
|
76002
76707
|
commands.push({
|
|
76003
76708
|
name,
|
|
76004
76709
|
description: parsed.description || `Custom command from .gg/commands/${file2}`,
|
|
@@ -76019,21 +76724,21 @@ init_esm_shims();
|
|
|
76019
76724
|
|
|
76020
76725
|
// ../ggcoder/dist/core/extensions/loader.js
|
|
76021
76726
|
init_esm_shims();
|
|
76022
|
-
import
|
|
76023
|
-
import
|
|
76727
|
+
import fs26 from "fs/promises";
|
|
76728
|
+
import path31 from "path";
|
|
76024
76729
|
var ExtensionLoader = class {
|
|
76025
76730
|
loaded = [];
|
|
76026
76731
|
async loadAll(extensionsDir, context) {
|
|
76027
76732
|
let files;
|
|
76028
76733
|
try {
|
|
76029
|
-
files = await
|
|
76734
|
+
files = await fs26.readdir(extensionsDir);
|
|
76030
76735
|
} catch {
|
|
76031
76736
|
return;
|
|
76032
76737
|
}
|
|
76033
76738
|
for (const file2 of files) {
|
|
76034
76739
|
if (!file2.endsWith(".js"))
|
|
76035
76740
|
continue;
|
|
76036
|
-
const filePath =
|
|
76741
|
+
const filePath = path31.join(extensionsDir, file2);
|
|
76037
76742
|
try {
|
|
76038
76743
|
const mod = await import(filePath);
|
|
76039
76744
|
const factory = typeof mod.default === "function" ? mod.default : mod.createExtension;
|
|
@@ -82438,8 +83143,8 @@ init_esm_shims();
|
|
|
82438
83143
|
|
|
82439
83144
|
// ../ggcoder/dist/core/mcp/store.js
|
|
82440
83145
|
init_esm_shims();
|
|
82441
|
-
import
|
|
82442
|
-
import
|
|
83146
|
+
import path33 from "path";
|
|
83147
|
+
import fs27 from "fs/promises";
|
|
82443
83148
|
var StoredServerEntrySchema = external_exports.object({
|
|
82444
83149
|
type: external_exports.enum(["stdio", "http", "streamable-http", "sse"]).optional(),
|
|
82445
83150
|
url: external_exports.string().optional(),
|
|
@@ -82457,12 +83162,12 @@ function globalMcpPath() {
|
|
|
82457
83162
|
return getAppPaths().mcpFile;
|
|
82458
83163
|
}
|
|
82459
83164
|
function projectMcpPath(cwd2) {
|
|
82460
|
-
return
|
|
83165
|
+
return path33.join(cwd2, ".gg", "mcp.json");
|
|
82461
83166
|
}
|
|
82462
83167
|
async function readMcpFile(filePath) {
|
|
82463
83168
|
let content;
|
|
82464
83169
|
try {
|
|
82465
|
-
content = await
|
|
83170
|
+
content = await fs27.readFile(filePath, "utf-8");
|
|
82466
83171
|
} catch {
|
|
82467
83172
|
return { mcpServers: {} };
|
|
82468
83173
|
}
|
|
@@ -82565,12 +83270,12 @@ init_esm_shims();
|
|
|
82565
83270
|
|
|
82566
83271
|
// ../ggcoder/dist/core/agents.js
|
|
82567
83272
|
init_esm_shims();
|
|
82568
|
-
import
|
|
82569
|
-
import
|
|
83273
|
+
import fs28 from "fs/promises";
|
|
83274
|
+
import path34 from "path";
|
|
82570
83275
|
async function discoverAgents(options) {
|
|
82571
83276
|
const agents = [];
|
|
82572
83277
|
if (options.projectDir) {
|
|
82573
|
-
const projectAgentsDir =
|
|
83278
|
+
const projectAgentsDir = path34.join(options.projectDir, ".gg", "agents");
|
|
82574
83279
|
const projectAgents = await loadAgentsFromDir(projectAgentsDir, "project");
|
|
82575
83280
|
agents.push(...projectAgents);
|
|
82576
83281
|
}
|
|
@@ -82588,19 +83293,19 @@ async function loadAgentsFromDir(dir, source2) {
|
|
|
82588
83293
|
const agents = [];
|
|
82589
83294
|
let files;
|
|
82590
83295
|
try {
|
|
82591
|
-
files = await
|
|
83296
|
+
files = await fs28.readdir(dir);
|
|
82592
83297
|
} catch {
|
|
82593
83298
|
return agents;
|
|
82594
83299
|
}
|
|
82595
83300
|
for (const file2 of files) {
|
|
82596
83301
|
if (!file2.endsWith(".md"))
|
|
82597
83302
|
continue;
|
|
82598
|
-
const filePath =
|
|
83303
|
+
const filePath = path34.join(dir, file2);
|
|
82599
83304
|
try {
|
|
82600
|
-
const content = await
|
|
83305
|
+
const content = await fs28.readFile(filePath, "utf-8");
|
|
82601
83306
|
const agent = parseAgentFile(content, source2);
|
|
82602
83307
|
if (!agent.name) {
|
|
82603
|
-
agent.name =
|
|
83308
|
+
agent.name = path34.basename(file2, ".md");
|
|
82604
83309
|
}
|
|
82605
83310
|
agents.push(agent);
|
|
82606
83311
|
} catch {
|
|
@@ -82733,8 +83438,8 @@ var BUNDLED_AGENTS = [
|
|
|
82733
83438
|
|
|
82734
83439
|
// ../ggcoder/dist/core/agent-session.js
|
|
82735
83440
|
import crypto8 from "crypto";
|
|
82736
|
-
import
|
|
82737
|
-
import
|
|
83441
|
+
import fs29 from "fs/promises";
|
|
83442
|
+
import path35 from "path";
|
|
82738
83443
|
var AgentSession = class {
|
|
82739
83444
|
eventBus = new EventBus();
|
|
82740
83445
|
slashCommands = new SlashCommandRegistry();
|
|
@@ -82747,6 +83452,7 @@ var AgentSession = class {
|
|
|
82747
83452
|
skills = [];
|
|
82748
83453
|
cacheKeyLogged = false;
|
|
82749
83454
|
processManager;
|
|
83455
|
+
lspManager;
|
|
82750
83456
|
mcpManager;
|
|
82751
83457
|
provider;
|
|
82752
83458
|
model;
|
|
@@ -82779,10 +83485,10 @@ var AgentSession = class {
|
|
|
82779
83485
|
this.authStorage = new AuthStorage(paths.authFile);
|
|
82780
83486
|
await this.authStorage.load();
|
|
82781
83487
|
this.sessionManager = new SessionManager(paths.sessionsDir);
|
|
82782
|
-
const localGGDir =
|
|
82783
|
-
await
|
|
82784
|
-
await
|
|
82785
|
-
await
|
|
83488
|
+
const localGGDir = path35.join(this.cwd, ".gg");
|
|
83489
|
+
await fs29.mkdir(path35.join(localGGDir, "skills"), { recursive: true });
|
|
83490
|
+
await fs29.mkdir(path35.join(localGGDir, "commands"), { recursive: true });
|
|
83491
|
+
await fs29.mkdir(path35.join(localGGDir, "agents"), { recursive: true });
|
|
82786
83492
|
this.skills = await discoverSkills({
|
|
82787
83493
|
globalSkillsDir: paths.skillsDir,
|
|
82788
83494
|
projectDir: this.cwd
|
|
@@ -82791,17 +83497,19 @@ var AgentSession = class {
|
|
|
82791
83497
|
globalAgentsDir: paths.agentsDir,
|
|
82792
83498
|
projectDir: this.cwd
|
|
82793
83499
|
});
|
|
82794
|
-
const { tools, processManager } = createTools(this.cwd, {
|
|
83500
|
+
const { tools, processManager, lspManager } = createTools(this.cwd, {
|
|
82795
83501
|
agents,
|
|
82796
83502
|
skills: this.skills,
|
|
82797
83503
|
provider: this.provider,
|
|
82798
83504
|
model: this.model,
|
|
83505
|
+
lspDiagnostics: this.settingsManager.get("lspDiagnostics"),
|
|
82799
83506
|
// Lazy — sessionId isn't assigned yet when createTools() runs, so we
|
|
82800
83507
|
// must defer reading the cache key until the sub-agent actually fires.
|
|
82801
83508
|
getCacheKey: () => this.getPromptCacheKey()
|
|
82802
83509
|
});
|
|
82803
83510
|
this.tools = tools;
|
|
82804
83511
|
this.processManager = processManager;
|
|
83512
|
+
this.lspManager = lspManager;
|
|
82805
83513
|
this.mcpManager = new MCPClientManager();
|
|
82806
83514
|
try {
|
|
82807
83515
|
let apiKey;
|
|
@@ -83134,6 +83842,7 @@ ${parsed.args}` : promptText;
|
|
|
83134
83842
|
}
|
|
83135
83843
|
async dispose() {
|
|
83136
83844
|
this.processManager?.shutdownAll();
|
|
83845
|
+
this.lspManager?.shutdownAll();
|
|
83137
83846
|
await this.mcpManager?.dispose();
|
|
83138
83847
|
await this.extensionLoader.deactivateAll();
|
|
83139
83848
|
this.eventBus.removeAllListeners();
|
|
@@ -84008,7 +84717,7 @@ import process14 from "process";
|
|
|
84008
84717
|
init_esm_shims();
|
|
84009
84718
|
var import_react15 = __toESM(require_react(), 1);
|
|
84010
84719
|
import process13 from "process";
|
|
84011
|
-
import
|
|
84720
|
+
import fs32 from "fs";
|
|
84012
84721
|
|
|
84013
84722
|
// ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/compat/index.mjs
|
|
84014
84723
|
init_esm_shims();
|
|
@@ -86201,7 +86910,7 @@ function wrapAnsi2(string4, columns, options) {
|
|
|
86201
86910
|
init_esm_shims();
|
|
86202
86911
|
import process5 from "process";
|
|
86203
86912
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
86204
|
-
import
|
|
86913
|
+
import fs30 from "fs";
|
|
86205
86914
|
import tty from "tty";
|
|
86206
86915
|
var defaultColumns = 80;
|
|
86207
86916
|
var defaultRows = 24;
|
|
@@ -86231,7 +86940,7 @@ var isForegroundProcess = () => {
|
|
|
86231
86940
|
return true;
|
|
86232
86941
|
}
|
|
86233
86942
|
try {
|
|
86234
|
-
const statContents =
|
|
86943
|
+
const statContents = fs30.readFileSync("/proc/self/stat", "utf8");
|
|
86235
86944
|
const closingParenthesisIndex = statContents.lastIndexOf(") ");
|
|
86236
86945
|
if (closingParenthesisIndex === -1) {
|
|
86237
86946
|
return false;
|
|
@@ -86275,8 +86984,8 @@ function terminalSize() {
|
|
|
86275
86984
|
}
|
|
86276
86985
|
var devTty = () => {
|
|
86277
86986
|
try {
|
|
86278
|
-
const flags = process5.platform === "darwin" ?
|
|
86279
|
-
const { columns, rows } = tty.WriteStream(
|
|
86987
|
+
const flags = process5.platform === "darwin" ? fs30.constants.O_EVTONLY | fs30.constants.O_NONBLOCK : fs30.constants.O_NONBLOCK;
|
|
86988
|
+
const { columns, rows } = tty.WriteStream(fs30.openSync("/dev/tty", flags));
|
|
86280
86989
|
return { columns, rows };
|
|
86281
86990
|
} catch {
|
|
86282
86991
|
}
|
|
@@ -88216,8 +88925,8 @@ var cleanupYogaNode = (node) => {
|
|
|
88216
88925
|
var currentUpdatePriority = import_constants3.NoEventPriority;
|
|
88217
88926
|
var currentRootNode;
|
|
88218
88927
|
async function loadPackageJson() {
|
|
88219
|
-
const
|
|
88220
|
-
const content =
|
|
88928
|
+
const fs38 = await import("fs");
|
|
88929
|
+
const content = fs38.readFileSync(new URL("../package.json", import.meta.url), "utf8");
|
|
88221
88930
|
return JSON.parse(content);
|
|
88222
88931
|
}
|
|
88223
88932
|
var packageJson = isDev() ? await loadPackageJson() : { name: void 0, version: void 0 };
|
|
@@ -89779,7 +90488,7 @@ var import_react13 = __toESM(require_react(), 1);
|
|
|
89779
90488
|
init_esm_shims();
|
|
89780
90489
|
var import_react12 = __toESM(require_react(), 1);
|
|
89781
90490
|
var import_stack_utils = __toESM(require_stack_utils(), 1);
|
|
89782
|
-
import * as
|
|
90491
|
+
import * as fs31 from "fs";
|
|
89783
90492
|
import { cwd } from "process";
|
|
89784
90493
|
|
|
89785
90494
|
// ../../node_modules/.pnpm/code-excerpt@4.0.0/node_modules/code-excerpt/dist/index.js
|
|
@@ -89907,8 +90616,8 @@ function Text({ color: color2, backgroundColor, dimColor = false, bold = false,
|
|
|
89907
90616
|
}
|
|
89908
90617
|
|
|
89909
90618
|
// ../../node_modules/.pnpm/@kenkaiiii+ink@6.8.0-gg.2_@types+react@19.2.14_react@19.2.5/node_modules/@kenkaiiii/ink/build/components/ErrorOverview.js
|
|
89910
|
-
var cleanupPath = (
|
|
89911
|
-
return
|
|
90619
|
+
var cleanupPath = (path45) => {
|
|
90620
|
+
return path45?.replace(`file://${cwd()}/`, "");
|
|
89912
90621
|
};
|
|
89913
90622
|
var stackUtils = new import_stack_utils.default({
|
|
89914
90623
|
cwd: cwd(),
|
|
@@ -89920,8 +90629,8 @@ function ErrorOverview({ error: error51 }) {
|
|
|
89920
90629
|
const filePath = cleanupPath(origin?.file);
|
|
89921
90630
|
let excerpt;
|
|
89922
90631
|
let lineWidth = 0;
|
|
89923
|
-
if (filePath && origin?.line &&
|
|
89924
|
-
const sourceCode =
|
|
90632
|
+
if (filePath && origin?.line && fs31.existsSync(filePath)) {
|
|
90633
|
+
const sourceCode = fs31.readFileSync(filePath, "utf8");
|
|
89925
90634
|
excerpt = dist_default3(sourceCode, origin.line);
|
|
89926
90635
|
if (excerpt) {
|
|
89927
90636
|
for (const { line } of excerpt) {
|
|
@@ -90740,7 +91449,7 @@ var Ink = class {
|
|
|
90740
91449
|
}
|
|
90741
91450
|
if (process13.env["GG_INK_DEBUG"] === "1" && (delta !== 0 || this.framePadDebt > 0)) {
|
|
90742
91451
|
try {
|
|
90743
|
-
|
|
91452
|
+
fs32.appendFileSync("/tmp/gg-ink-debug.log", JSON.stringify({
|
|
90744
91453
|
t: Date.now() % 1e5,
|
|
90745
91454
|
delta,
|
|
90746
91455
|
ins: insertLineCount,
|
|
@@ -92576,9 +93285,9 @@ var taskBarStore = createStore({
|
|
|
92576
93285
|
// ../ggcoder/dist/utils/sound.js
|
|
92577
93286
|
init_esm_shims();
|
|
92578
93287
|
import { execFile as execFile2 } from "child_process";
|
|
92579
|
-
import { fileURLToPath as
|
|
93288
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
92580
93289
|
import { resolve, dirname } from "path";
|
|
92581
|
-
var __dirname2 = dirname(
|
|
93290
|
+
var __dirname2 = dirname(fileURLToPath3(import.meta.url));
|
|
92582
93291
|
var notificationPath = resolve(__dirname2, "../../assets/end-notification.mp3");
|
|
92583
93292
|
|
|
92584
93293
|
// ../ggcoder/dist/ui/hooks/useAgentLoop.js
|
|
@@ -93196,8 +93905,8 @@ function shortenValue(value, maxLength = MAX_DETAIL_LENGTH) {
|
|
|
93196
93905
|
const tailLength = maxLength - 1 - headLength;
|
|
93197
93906
|
return `${normalized.slice(0, headLength)}\u2026${normalized.slice(-tailLength)}`;
|
|
93198
93907
|
}
|
|
93199
|
-
function basename2(
|
|
93200
|
-
const trimmed =
|
|
93908
|
+
function basename2(path45) {
|
|
93909
|
+
const trimmed = path45.replace(/\/+$/u, "");
|
|
93201
93910
|
return trimmed.split("/").filter(Boolean).at(-1) ?? trimmed;
|
|
93202
93911
|
}
|
|
93203
93912
|
function uniqueValues(values) {
|
|
@@ -108180,8 +108889,8 @@ function collapseSubmittedUserText(text) {
|
|
|
108180
108889
|
}
|
|
108181
108890
|
|
|
108182
108891
|
// ../ggcoder/dist/ui/terminal-history.js
|
|
108183
|
-
import
|
|
108184
|
-
import { pathToFileURL } from "url";
|
|
108892
|
+
import path36 from "path";
|
|
108893
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
108185
108894
|
|
|
108186
108895
|
// ../ggcoder/dist/ui/utils/terminal-graphics.js
|
|
108187
108896
|
init_esm_shims();
|
|
@@ -110469,9 +111178,9 @@ init_esm_shims();
|
|
|
110469
111178
|
import { execFile as execFile3 } from "child_process";
|
|
110470
111179
|
import { readFileSync as readFileSync5 } from "fs";
|
|
110471
111180
|
import { dirname as dirname2, join as join3 } from "path";
|
|
110472
|
-
import { fileURLToPath as
|
|
111181
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
110473
111182
|
function resolveCliVersion() {
|
|
110474
|
-
let dir = dirname2(
|
|
111183
|
+
let dir = dirname2(fileURLToPath4(import.meta.url));
|
|
110475
111184
|
for (let i = 0; i < 6; i++) {
|
|
110476
111185
|
try {
|
|
110477
111186
|
const manifest = JSON.parse(readFileSync5(join3(dir, "package.json"), "utf8"));
|
|
@@ -110537,11 +111246,11 @@ import { execFile as execFile4 } from "child_process";
|
|
|
110537
111246
|
|
|
110538
111247
|
// ../ggcoder/dist/core/auto-update.js
|
|
110539
111248
|
init_esm_shims();
|
|
110540
|
-
import
|
|
111249
|
+
import path37 from "path";
|
|
110541
111250
|
import os10 from "os";
|
|
110542
111251
|
var updater = createAutoUpdater({
|
|
110543
111252
|
packageName: "@kenkaiiii/ggcoder",
|
|
110544
|
-
stateFilePath: () =>
|
|
111253
|
+
stateFilePath: () => path37.join(os10.homedir(), ".gg", "update-state.json")
|
|
110545
111254
|
});
|
|
110546
111255
|
var checkAndAutoUpdate = updater.checkAndAutoUpdate;
|
|
110547
111256
|
var getPendingUpdate = updater.getPendingUpdate;
|
|
@@ -110553,10 +111262,10 @@ init_esm_shims();
|
|
|
110553
111262
|
|
|
110554
111263
|
// ../ggcoder/dist/core/setup-history.js
|
|
110555
111264
|
init_esm_shims();
|
|
110556
|
-
import
|
|
110557
|
-
import
|
|
111265
|
+
import fs33 from "fs";
|
|
111266
|
+
import path38 from "path";
|
|
110558
111267
|
import os11 from "os";
|
|
110559
|
-
var HISTORY_PATH =
|
|
111268
|
+
var HISTORY_PATH = path38.join(os11.homedir(), ".gg", "setup-history.json");
|
|
110560
111269
|
|
|
110561
111270
|
// ../ggcoder/dist/ui/components/RewindOverlay.js
|
|
110562
111271
|
init_esm_shims();
|
|
@@ -110806,7 +111515,7 @@ function MessageResponse({ children, height, accentColor }) {
|
|
|
110806
111515
|
|
|
110807
111516
|
// ../ggcoder/dist/ui/utils/highlight.js
|
|
110808
111517
|
init_esm_shims();
|
|
110809
|
-
import
|
|
111518
|
+
import path39 from "path";
|
|
110810
111519
|
var EXT_TO_LANG = {
|
|
110811
111520
|
ts: "typescript",
|
|
110812
111521
|
tsx: "typescript",
|
|
@@ -110834,7 +111543,7 @@ var EXT_TO_LANG = {
|
|
|
110834
111543
|
dockerfile: "dockerfile"
|
|
110835
111544
|
};
|
|
110836
111545
|
function langFromPath(filePath) {
|
|
110837
|
-
const ext =
|
|
111546
|
+
const ext = path39.extname(filePath).replace(/^\./, "").toLowerCase();
|
|
110838
111547
|
return EXT_TO_LANG[ext];
|
|
110839
111548
|
}
|
|
110840
111549
|
var hlModule;
|
|
@@ -112944,17 +113653,17 @@ var EventQueue = class {
|
|
|
112944
113653
|
|
|
112945
113654
|
// src/settings.ts
|
|
112946
113655
|
init_esm_shims();
|
|
112947
|
-
import
|
|
112948
|
-
import
|
|
113656
|
+
import fs34 from "fs/promises";
|
|
113657
|
+
import path40 from "path";
|
|
112949
113658
|
function settingsPath() {
|
|
112950
|
-
return
|
|
113659
|
+
return path40.join(getAppPaths().agentDir, "boss", "settings.json");
|
|
112951
113660
|
}
|
|
112952
113661
|
async function ensureDir() {
|
|
112953
|
-
await
|
|
113662
|
+
await fs34.mkdir(path40.dirname(settingsPath()), { recursive: true, mode: 448 });
|
|
112954
113663
|
}
|
|
112955
113664
|
async function loadSettings() {
|
|
112956
113665
|
try {
|
|
112957
|
-
const content = await
|
|
113666
|
+
const content = await fs34.readFile(settingsPath(), "utf-8");
|
|
112958
113667
|
const parsed = JSON.parse(content);
|
|
112959
113668
|
if (!parsed || typeof parsed !== "object") return {};
|
|
112960
113669
|
return parsed;
|
|
@@ -112969,8 +113678,8 @@ async function saveSettings(patch) {
|
|
|
112969
113678
|
const merged = { ...current, ...patch };
|
|
112970
113679
|
await ensureDir();
|
|
112971
113680
|
const tmp = `${settingsPath()}.${process.pid}.tmp`;
|
|
112972
|
-
await
|
|
112973
|
-
await
|
|
113681
|
+
await fs34.writeFile(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
|
|
113682
|
+
await fs34.rename(tmp, settingsPath());
|
|
112974
113683
|
});
|
|
112975
113684
|
writeChain = next.catch(() => void 0);
|
|
112976
113685
|
await next;
|
|
@@ -113362,18 +114071,18 @@ init_esm_shims();
|
|
|
113362
114071
|
// src/tasks-store.ts
|
|
113363
114072
|
init_esm_shims();
|
|
113364
114073
|
var import_react98 = __toESM(require_react(), 1);
|
|
113365
|
-
import
|
|
113366
|
-
import
|
|
114074
|
+
import fs35 from "fs/promises";
|
|
114075
|
+
import path41 from "path";
|
|
113367
114076
|
import crypto10 from "crypto";
|
|
113368
114077
|
function getPlanPath() {
|
|
113369
|
-
return
|
|
114078
|
+
return path41.join(getAppPaths().agentDir, "boss", "plan.json");
|
|
113370
114079
|
}
|
|
113371
114080
|
async function ensureDir2() {
|
|
113372
|
-
await
|
|
114081
|
+
await fs35.mkdir(path41.dirname(getPlanPath()), { recursive: true, mode: 448 });
|
|
113373
114082
|
}
|
|
113374
114083
|
async function loadPlan() {
|
|
113375
114084
|
try {
|
|
113376
|
-
const content = await
|
|
114085
|
+
const content = await fs35.readFile(getPlanPath(), "utf-8");
|
|
113377
114086
|
const parsed = JSON.parse(content);
|
|
113378
114087
|
return Array.isArray(parsed.tasks) ? parsed.tasks : [];
|
|
113379
114088
|
} catch {
|
|
@@ -113387,8 +114096,8 @@ async function persist(tasks) {
|
|
|
113387
114096
|
await ensureDir2();
|
|
113388
114097
|
const finalPath = getPlanPath();
|
|
113389
114098
|
const tmpPath = `${finalPath}.${process.pid}.tmp`;
|
|
113390
|
-
await
|
|
113391
|
-
await
|
|
114099
|
+
await fs35.writeFile(tmpPath, snapshot, "utf-8");
|
|
114100
|
+
await fs35.rename(tmpPath, finalPath);
|
|
113392
114101
|
});
|
|
113393
114102
|
persistChain = next.catch(() => void 0);
|
|
113394
114103
|
await next;
|
|
@@ -113656,13 +114365,13 @@ function createTaskTools(deps) {
|
|
|
113656
114365
|
|
|
113657
114366
|
// src/audio.ts
|
|
113658
114367
|
init_esm_shims();
|
|
113659
|
-
import { spawn as
|
|
113660
|
-
import { fileURLToPath as
|
|
113661
|
-
import
|
|
113662
|
-
import
|
|
114368
|
+
import { spawn as spawn8, execFileSync as execFileSync4 } from "child_process";
|
|
114369
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
114370
|
+
import path43 from "path";
|
|
114371
|
+
import fs36 from "fs";
|
|
113663
114372
|
function readMp3DurationMs(file2) {
|
|
113664
114373
|
try {
|
|
113665
|
-
const buf =
|
|
114374
|
+
const buf = fs36.readFileSync(file2);
|
|
113666
114375
|
let i = 0;
|
|
113667
114376
|
if (buf.length >= 10 && buf[0] === 73 && buf[1] === 68 && buf[2] === 51) {
|
|
113668
114377
|
const tagSize = (buf[6] & 127) << 21 | (buf[7] & 127) << 14 | (buf[8] & 127) << 7 | buf[9] & 127;
|
|
@@ -113719,10 +114428,10 @@ function getSplashAudioDurationMs() {
|
|
|
113719
114428
|
return ms && ms > 0 ? ms : 1500;
|
|
113720
114429
|
}
|
|
113721
114430
|
function assetPath(name) {
|
|
113722
|
-
const here =
|
|
113723
|
-
const dist =
|
|
113724
|
-
if (
|
|
113725
|
-
return
|
|
114431
|
+
const here = path43.dirname(fileURLToPath5(import.meta.url));
|
|
114432
|
+
const dist = path43.join(here, name);
|
|
114433
|
+
if (fs36.existsSync(dist)) return dist;
|
|
114434
|
+
return path43.join(here, "..", "assets", name);
|
|
113726
114435
|
}
|
|
113727
114436
|
function splashAssetPath() {
|
|
113728
114437
|
return assetPath("splash.mp3");
|
|
@@ -113731,7 +114440,7 @@ function trySpawn(cmd, args) {
|
|
|
113731
114440
|
return new Promise((resolve2) => {
|
|
113732
114441
|
let resolved = false;
|
|
113733
114442
|
try {
|
|
113734
|
-
const child =
|
|
114443
|
+
const child = spawn8(cmd, args, {
|
|
113735
114444
|
detached: true,
|
|
113736
114445
|
stdio: "ignore"
|
|
113737
114446
|
});
|
|
@@ -113762,15 +114471,15 @@ function trySpawn(cmd, args) {
|
|
|
113762
114471
|
}
|
|
113763
114472
|
function isWsl() {
|
|
113764
114473
|
if (process.platform !== "linux") return false;
|
|
113765
|
-
return !!process.env.WSL_DISTRO_NAME ||
|
|
114474
|
+
return !!process.env.WSL_DISTRO_NAME || fs36.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop");
|
|
113766
114475
|
}
|
|
113767
114476
|
async function tryPlayOnWindowsHost(file2) {
|
|
113768
114477
|
try {
|
|
113769
|
-
const here =
|
|
113770
|
-
const devAssets =
|
|
113771
|
-
const resolved =
|
|
113772
|
-
const inDist = resolved === here || resolved.startsWith(here +
|
|
113773
|
-
const inAssets = resolved === devAssets || resolved.startsWith(devAssets +
|
|
114478
|
+
const here = path43.dirname(fileURLToPath5(import.meta.url));
|
|
114479
|
+
const devAssets = path43.resolve(here, "..", "assets");
|
|
114480
|
+
const resolved = path43.resolve(file2);
|
|
114481
|
+
const inDist = resolved === here || resolved.startsWith(here + path43.sep);
|
|
114482
|
+
const inAssets = resolved === devAssets || resolved.startsWith(devAssets + path43.sep);
|
|
113774
114483
|
if (!inDist && !inAssets) {
|
|
113775
114484
|
return false;
|
|
113776
114485
|
}
|
|
@@ -113790,7 +114499,7 @@ async function tryPlayOnWindowsHost(file2) {
|
|
|
113790
114499
|
return new Promise((resolve2) => {
|
|
113791
114500
|
let resolved2 = false;
|
|
113792
114501
|
try {
|
|
113793
|
-
const child =
|
|
114502
|
+
const child = spawn8(
|
|
113794
114503
|
"powershell.exe",
|
|
113795
114504
|
["-NoProfile", "-WindowStyle", "Hidden", "-Command", script],
|
|
113796
114505
|
{
|
|
@@ -113834,7 +114543,7 @@ async function tryPlayOnWindowsHost(file2) {
|
|
|
113834
114543
|
}
|
|
113835
114544
|
}
|
|
113836
114545
|
async function playFile(file2) {
|
|
113837
|
-
if (!
|
|
114546
|
+
if (!fs36.existsSync(file2)) return;
|
|
113838
114547
|
const platform2 = process.platform;
|
|
113839
114548
|
if (platform2 === "darwin") {
|
|
113840
114549
|
await trySpawn("afplay", [file2]);
|
|
@@ -113932,37 +114641,37 @@ function truncateOversizedToolResults2(messages, opts = {}) {
|
|
|
113932
114641
|
|
|
113933
114642
|
// src/sessions.ts
|
|
113934
114643
|
init_esm_shims();
|
|
113935
|
-
import
|
|
113936
|
-
import
|
|
114644
|
+
import fs37 from "fs/promises";
|
|
114645
|
+
import path44 from "path";
|
|
113937
114646
|
import crypto11 from "crypto";
|
|
113938
114647
|
var BOSS_SUBDIR = "boss";
|
|
113939
114648
|
var SESSIONS_SUBDIR = "sessions";
|
|
113940
114649
|
function getBossDir() {
|
|
113941
|
-
return
|
|
114650
|
+
return path44.join(getAppPaths().agentDir, BOSS_SUBDIR);
|
|
113942
114651
|
}
|
|
113943
114652
|
function getSessionsDir() {
|
|
113944
|
-
return
|
|
114653
|
+
return path44.join(getBossDir(), SESSIONS_SUBDIR);
|
|
113945
114654
|
}
|
|
113946
114655
|
async function ensureSessionsDir() {
|
|
113947
114656
|
const dir = getSessionsDir();
|
|
113948
|
-
await
|
|
114657
|
+
await fs37.mkdir(dir, { recursive: true, mode: 448 });
|
|
113949
114658
|
return dir;
|
|
113950
114659
|
}
|
|
113951
114660
|
async function createSession2() {
|
|
113952
114661
|
await ensureSessionsDir();
|
|
113953
114662
|
const id2 = `${Date.now()}-${crypto11.randomBytes(4).toString("hex")}`;
|
|
113954
|
-
const filePath =
|
|
113955
|
-
await
|
|
114663
|
+
const filePath = path44.join(getSessionsDir(), `${id2}.jsonl`);
|
|
114664
|
+
await fs37.writeFile(filePath, "", "utf-8");
|
|
113956
114665
|
return { id: id2, filePath };
|
|
113957
114666
|
}
|
|
113958
114667
|
async function appendMessages(filePath, msgs) {
|
|
113959
114668
|
if (msgs.length === 0) return;
|
|
113960
114669
|
const lines = msgs.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
113961
|
-
await
|
|
114670
|
+
await fs37.appendFile(filePath, lines, "utf-8");
|
|
113962
114671
|
}
|
|
113963
114672
|
async function loadSession2(filePath) {
|
|
113964
114673
|
try {
|
|
113965
|
-
const content = await
|
|
114674
|
+
const content = await fs37.readFile(filePath, "utf-8");
|
|
113966
114675
|
const lines = content.split("\n").filter((l) => l.length > 0);
|
|
113967
114676
|
const messages = [];
|
|
113968
114677
|
for (const line of lines) {
|
|
@@ -113978,8 +114687,8 @@ async function loadSession2(filePath) {
|
|
|
113978
114687
|
}
|
|
113979
114688
|
async function inspectSession(filePath, id2) {
|
|
113980
114689
|
try {
|
|
113981
|
-
const stat = await
|
|
113982
|
-
const content = await
|
|
114690
|
+
const stat = await fs37.stat(filePath);
|
|
114691
|
+
const content = await fs37.readFile(filePath, "utf-8");
|
|
113983
114692
|
const lines = content.split("\n").filter((l) => l.length > 0);
|
|
113984
114693
|
let firstUserMessage;
|
|
113985
114694
|
for (const line of lines) {
|
|
@@ -114012,7 +114721,7 @@ async function listSessions2() {
|
|
|
114012
114721
|
await ensureSessionsDir();
|
|
114013
114722
|
let entries;
|
|
114014
114723
|
try {
|
|
114015
|
-
entries = await
|
|
114724
|
+
entries = await fs37.readdir(getSessionsDir());
|
|
114016
114725
|
} catch {
|
|
114017
114726
|
return [];
|
|
114018
114727
|
}
|
|
@@ -114020,7 +114729,7 @@ async function listSessions2() {
|
|
|
114020
114729
|
for (const name of entries) {
|
|
114021
114730
|
if (!name.endsWith(".jsonl")) continue;
|
|
114022
114731
|
const id2 = name.replace(/\.jsonl$/, "");
|
|
114023
|
-
const info = await inspectSession(
|
|
114732
|
+
const info = await inspectSession(path44.join(getSessionsDir(), name), id2);
|
|
114024
114733
|
if (info) infos.push(info);
|
|
114025
114734
|
}
|
|
114026
114735
|
infos.sort((a, b) => b.lastModified - a.lastModified);
|
|
@@ -114031,7 +114740,7 @@ async function getMostRecent() {
|
|
|
114031
114740
|
return all[0] ?? null;
|
|
114032
114741
|
}
|
|
114033
114742
|
async function getSessionById(id2) {
|
|
114034
|
-
const filePath =
|
|
114743
|
+
const filePath = path44.join(getSessionsDir(), `${id2}.jsonl`);
|
|
114035
114744
|
return inspectSession(filePath, id2);
|
|
114036
114745
|
}
|
|
114037
114746
|
|
|
@@ -114985,4 +115694,4 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
114985
115694
|
* LICENSE file in the root directory of this source tree.
|
|
114986
115695
|
*)
|
|
114987
115696
|
*/
|
|
114988
|
-
//# sourceMappingURL=chunk-
|
|
115697
|
+
//# sourceMappingURL=chunk-QDOB5CCW.js.map
|