@chosengeneration/light-code 0.139.0 → 0.140.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.
- package/dist/cli.cjs +95320 -4
- package/dist/server.cjs +1303 -797
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -494,14 +494,14 @@ var require_util = __commonJS({
|
|
|
494
494
|
}
|
|
495
495
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
496
496
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol}//${url2.hostname}:${port}`;
|
|
497
|
-
let
|
|
497
|
+
let path60 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
498
498
|
if (origin.endsWith("/")) {
|
|
499
499
|
origin = origin.substring(0, origin.length - 1);
|
|
500
500
|
}
|
|
501
|
-
if (
|
|
502
|
-
|
|
501
|
+
if (path60 && !path60.startsWith("/")) {
|
|
502
|
+
path60 = `/${path60}`;
|
|
503
503
|
}
|
|
504
|
-
url2 = new URL(origin +
|
|
504
|
+
url2 = new URL(origin + path60);
|
|
505
505
|
}
|
|
506
506
|
return url2;
|
|
507
507
|
}
|
|
@@ -2115,20 +2115,20 @@ var require_parseParams = __commonJS({
|
|
|
2115
2115
|
var require_basename = __commonJS({
|
|
2116
2116
|
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) {
|
|
2117
2117
|
"use strict";
|
|
2118
|
-
module2.exports = function basename(
|
|
2119
|
-
if (typeof
|
|
2118
|
+
module2.exports = function basename(path60) {
|
|
2119
|
+
if (typeof path60 !== "string") {
|
|
2120
2120
|
return "";
|
|
2121
2121
|
}
|
|
2122
|
-
for (var i =
|
|
2123
|
-
switch (
|
|
2122
|
+
for (var i = path60.length - 1; i >= 0; --i) {
|
|
2123
|
+
switch (path60.charCodeAt(i)) {
|
|
2124
2124
|
case 47:
|
|
2125
2125
|
// '/'
|
|
2126
2126
|
case 92:
|
|
2127
|
-
|
|
2128
|
-
return
|
|
2127
|
+
path60 = path60.slice(i + 1);
|
|
2128
|
+
return path60 === ".." || path60 === "." ? "" : path60;
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
return
|
|
2131
|
+
return path60 === ".." || path60 === "." ? "" : path60;
|
|
2132
2132
|
};
|
|
2133
2133
|
}
|
|
2134
2134
|
});
|
|
@@ -5158,7 +5158,7 @@ var require_request = __commonJS({
|
|
|
5158
5158
|
}
|
|
5159
5159
|
var Request = class _Request {
|
|
5160
5160
|
constructor(origin, {
|
|
5161
|
-
path:
|
|
5161
|
+
path: path60,
|
|
5162
5162
|
method,
|
|
5163
5163
|
body,
|
|
5164
5164
|
headers,
|
|
@@ -5172,11 +5172,11 @@ var require_request = __commonJS({
|
|
|
5172
5172
|
throwOnError,
|
|
5173
5173
|
expectContinue
|
|
5174
5174
|
}, handler) {
|
|
5175
|
-
if (typeof
|
|
5175
|
+
if (typeof path60 !== "string") {
|
|
5176
5176
|
throw new InvalidArgumentError("path must be a string");
|
|
5177
|
-
} else if (
|
|
5177
|
+
} else if (path60[0] !== "/" && !(path60.startsWith("http://") || path60.startsWith("https://")) && method !== "CONNECT") {
|
|
5178
5178
|
throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
|
|
5179
|
-
} else if (invalidPathRegex.exec(
|
|
5179
|
+
} else if (invalidPathRegex.exec(path60) !== null) {
|
|
5180
5180
|
throw new InvalidArgumentError("invalid request path");
|
|
5181
5181
|
}
|
|
5182
5182
|
if (typeof method !== "string") {
|
|
@@ -5239,7 +5239,7 @@ var require_request = __commonJS({
|
|
|
5239
5239
|
this.completed = false;
|
|
5240
5240
|
this.aborted = false;
|
|
5241
5241
|
this.upgrade = upgrade || null;
|
|
5242
|
-
this.path = query ? util.buildURL(
|
|
5242
|
+
this.path = query ? util.buildURL(path60, query) : path60;
|
|
5243
5243
|
this.origin = origin;
|
|
5244
5244
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
5245
5245
|
this.blocking = blocking == null ? false : blocking;
|
|
@@ -6247,9 +6247,9 @@ var require_RedirectHandler = __commonJS({
|
|
|
6247
6247
|
return this.handler.onHeaders(statusCode, headers, resume, statusText);
|
|
6248
6248
|
}
|
|
6249
6249
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
6250
|
-
const
|
|
6250
|
+
const path60 = search ? `${pathname}${search}` : pathname;
|
|
6251
6251
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
6252
|
-
this.opts.path =
|
|
6252
|
+
this.opts.path = path60;
|
|
6253
6253
|
this.opts.origin = origin;
|
|
6254
6254
|
this.opts.maxRedirections = 0;
|
|
6255
6255
|
this.opts.query = null;
|
|
@@ -7489,7 +7489,7 @@ var require_client = __commonJS({
|
|
|
7489
7489
|
writeH2(client, client[kHTTP2Session], request);
|
|
7490
7490
|
return;
|
|
7491
7491
|
}
|
|
7492
|
-
const { body, method, path:
|
|
7492
|
+
const { body, method, path: path60, host, upgrade, headers, blocking, reset } = request;
|
|
7493
7493
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7494
7494
|
if (body && typeof body.read === "function") {
|
|
7495
7495
|
body.read(0);
|
|
@@ -7539,7 +7539,7 @@ var require_client = __commonJS({
|
|
|
7539
7539
|
if (blocking) {
|
|
7540
7540
|
socket[kBlocking] = true;
|
|
7541
7541
|
}
|
|
7542
|
-
let header2 = `${method} ${
|
|
7542
|
+
let header2 = `${method} ${path60} HTTP/1.1\r
|
|
7543
7543
|
`;
|
|
7544
7544
|
if (typeof host === "string") {
|
|
7545
7545
|
header2 += `host: ${host}\r
|
|
@@ -7602,7 +7602,7 @@ upgrade: ${upgrade}\r
|
|
|
7602
7602
|
return true;
|
|
7603
7603
|
}
|
|
7604
7604
|
function writeH2(client, session, request) {
|
|
7605
|
-
const { body, method, path:
|
|
7605
|
+
const { body, method, path: path60, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
|
|
7606
7606
|
let headers;
|
|
7607
7607
|
if (typeof reqHeaders === "string") headers = Request[kHTTP2CopyHeaders](reqHeaders.trim());
|
|
7608
7608
|
else headers = reqHeaders;
|
|
@@ -7645,7 +7645,7 @@ upgrade: ${upgrade}\r
|
|
|
7645
7645
|
});
|
|
7646
7646
|
return true;
|
|
7647
7647
|
}
|
|
7648
|
-
headers[HTTP2_HEADER_PATH] =
|
|
7648
|
+
headers[HTTP2_HEADER_PATH] = path60;
|
|
7649
7649
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
7650
7650
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
7651
7651
|
if (body && typeof body.read === "function") {
|
|
@@ -9885,20 +9885,20 @@ var require_mock_utils = __commonJS({
|
|
|
9885
9885
|
}
|
|
9886
9886
|
return true;
|
|
9887
9887
|
}
|
|
9888
|
-
function safeUrl(
|
|
9889
|
-
if (typeof
|
|
9890
|
-
return
|
|
9888
|
+
function safeUrl(path60) {
|
|
9889
|
+
if (typeof path60 !== "string") {
|
|
9890
|
+
return path60;
|
|
9891
9891
|
}
|
|
9892
|
-
const pathSegments =
|
|
9892
|
+
const pathSegments = path60.split("?");
|
|
9893
9893
|
if (pathSegments.length !== 2) {
|
|
9894
|
-
return
|
|
9894
|
+
return path60;
|
|
9895
9895
|
}
|
|
9896
9896
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
9897
9897
|
qp.sort();
|
|
9898
9898
|
return [...pathSegments, qp.toString()].join("?");
|
|
9899
9899
|
}
|
|
9900
|
-
function matchKey(mockDispatch2, { path:
|
|
9901
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
9900
|
+
function matchKey(mockDispatch2, { path: path60, method, body, headers }) {
|
|
9901
|
+
const pathMatch = matchValue(mockDispatch2.path, path60);
|
|
9902
9902
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
9903
9903
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
9904
9904
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -9916,7 +9916,7 @@ var require_mock_utils = __commonJS({
|
|
|
9916
9916
|
function getMockDispatch(mockDispatches, key2) {
|
|
9917
9917
|
const basePath = key2.query ? buildURL(key2.path, key2.query) : key2.path;
|
|
9918
9918
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
9919
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
9919
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path60 }) => matchValue(safeUrl(path60), resolvedPath));
|
|
9920
9920
|
if (matchedMockDispatches.length === 0) {
|
|
9921
9921
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
9922
9922
|
}
|
|
@@ -9953,9 +9953,9 @@ var require_mock_utils = __commonJS({
|
|
|
9953
9953
|
}
|
|
9954
9954
|
}
|
|
9955
9955
|
function buildKey(opts) {
|
|
9956
|
-
const { path:
|
|
9956
|
+
const { path: path60, method, body, headers, query } = opts;
|
|
9957
9957
|
return {
|
|
9958
|
-
path:
|
|
9958
|
+
path: path60,
|
|
9959
9959
|
method,
|
|
9960
9960
|
body,
|
|
9961
9961
|
headers,
|
|
@@ -10404,10 +10404,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
10404
10404
|
}
|
|
10405
10405
|
format(pendingInterceptors) {
|
|
10406
10406
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
10407
|
-
({ method, path:
|
|
10407
|
+
({ method, path: path60, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
10408
10408
|
Method: method,
|
|
10409
10409
|
Origin: origin,
|
|
10410
|
-
Path:
|
|
10410
|
+
Path: path60,
|
|
10411
10411
|
"Status code": statusCode,
|
|
10412
10412
|
Persistent: persist ? "\u2705" : "\u274C",
|
|
10413
10413
|
Invocations: timesInvoked,
|
|
@@ -15027,8 +15027,8 @@ var require_util6 = __commonJS({
|
|
|
15027
15027
|
}
|
|
15028
15028
|
}
|
|
15029
15029
|
}
|
|
15030
|
-
function validateCookiePath(
|
|
15031
|
-
for (const char of
|
|
15030
|
+
function validateCookiePath(path60) {
|
|
15031
|
+
for (const char of path60) {
|
|
15032
15032
|
const code = char.charCodeAt(0);
|
|
15033
15033
|
if (code < 33 || char === ";") {
|
|
15034
15034
|
throw new Error("Invalid cookie path");
|
|
@@ -16708,11 +16708,11 @@ var require_undici = __commonJS({
|
|
|
16708
16708
|
if (typeof opts.path !== "string") {
|
|
16709
16709
|
throw new InvalidArgumentError("invalid opts.path");
|
|
16710
16710
|
}
|
|
16711
|
-
let
|
|
16711
|
+
let path60 = opts.path;
|
|
16712
16712
|
if (!opts.path.startsWith("/")) {
|
|
16713
|
-
|
|
16713
|
+
path60 = `/${path60}`;
|
|
16714
16714
|
}
|
|
16715
|
-
url2 = new URL(util.parseOrigin(url2).origin +
|
|
16715
|
+
url2 = new URL(util.parseOrigin(url2).origin + path60);
|
|
16716
16716
|
} else {
|
|
16717
16717
|
if (!opts) {
|
|
16718
16718
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -19983,8 +19983,8 @@ var require_utils2 = __commonJS({
|
|
|
19983
19983
|
}
|
|
19984
19984
|
return ind;
|
|
19985
19985
|
}
|
|
19986
|
-
function removeDotSegments(
|
|
19987
|
-
let input =
|
|
19986
|
+
function removeDotSegments(path60) {
|
|
19987
|
+
let input = path60;
|
|
19988
19988
|
const output = [];
|
|
19989
19989
|
let nextSlash = -1;
|
|
19990
19990
|
let len = 0;
|
|
@@ -20236,8 +20236,8 @@ var require_schemes = __commonJS({
|
|
|
20236
20236
|
wsComponent.secure = void 0;
|
|
20237
20237
|
}
|
|
20238
20238
|
if (wsComponent.resourceName) {
|
|
20239
|
-
const [
|
|
20240
|
-
wsComponent.path =
|
|
20239
|
+
const [path60, query] = wsComponent.resourceName.split("?");
|
|
20240
|
+
wsComponent.path = path60 && path60 !== "/" ? path60 : void 0;
|
|
20241
20241
|
wsComponent.query = query;
|
|
20242
20242
|
wsComponent.resourceName = void 0;
|
|
20243
20243
|
}
|
|
@@ -23636,12 +23636,12 @@ var require_dist = __commonJS({
|
|
|
23636
23636
|
throw new Error(`Unknown format "${name}"`);
|
|
23637
23637
|
return f;
|
|
23638
23638
|
};
|
|
23639
|
-
function addFormats(ajv, list,
|
|
23639
|
+
function addFormats(ajv, list, fs41, exportName) {
|
|
23640
23640
|
var _a3;
|
|
23641
23641
|
var _b;
|
|
23642
23642
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
23643
23643
|
for (const f of list)
|
|
23644
|
-
ajv.addFormat(f,
|
|
23644
|
+
ajv.addFormat(f, fs41[f]);
|
|
23645
23645
|
}
|
|
23646
23646
|
module2.exports = exports2 = formatsPlugin;
|
|
23647
23647
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -23654,8 +23654,8 @@ var require_windows = __commonJS({
|
|
|
23654
23654
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports2, module2) {
|
|
23655
23655
|
module2.exports = isexe;
|
|
23656
23656
|
isexe.sync = sync;
|
|
23657
|
-
var
|
|
23658
|
-
function checkPathExt(
|
|
23657
|
+
var fs41 = require("fs");
|
|
23658
|
+
function checkPathExt(path60, options) {
|
|
23659
23659
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
23660
23660
|
if (!pathext) {
|
|
23661
23661
|
return true;
|
|
@@ -23666,25 +23666,25 @@ var require_windows = __commonJS({
|
|
|
23666
23666
|
}
|
|
23667
23667
|
for (var i = 0; i < pathext.length; i++) {
|
|
23668
23668
|
var p = pathext[i].toLowerCase();
|
|
23669
|
-
if (p &&
|
|
23669
|
+
if (p && path60.substr(-p.length).toLowerCase() === p) {
|
|
23670
23670
|
return true;
|
|
23671
23671
|
}
|
|
23672
23672
|
}
|
|
23673
23673
|
return false;
|
|
23674
23674
|
}
|
|
23675
|
-
function checkStat(stat,
|
|
23675
|
+
function checkStat(stat, path60, options) {
|
|
23676
23676
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
23677
23677
|
return false;
|
|
23678
23678
|
}
|
|
23679
|
-
return checkPathExt(
|
|
23679
|
+
return checkPathExt(path60, options);
|
|
23680
23680
|
}
|
|
23681
|
-
function isexe(
|
|
23682
|
-
|
|
23683
|
-
cb(er, er ? false : checkStat(stat,
|
|
23681
|
+
function isexe(path60, options, cb) {
|
|
23682
|
+
fs41.stat(path60, function(er, stat) {
|
|
23683
|
+
cb(er, er ? false : checkStat(stat, path60, options));
|
|
23684
23684
|
});
|
|
23685
23685
|
}
|
|
23686
|
-
function sync(
|
|
23687
|
-
return checkStat(
|
|
23686
|
+
function sync(path60, options) {
|
|
23687
|
+
return checkStat(fs41.statSync(path60), path60, options);
|
|
23688
23688
|
}
|
|
23689
23689
|
}
|
|
23690
23690
|
});
|
|
@@ -23694,14 +23694,14 @@ var require_mode = __commonJS({
|
|
|
23694
23694
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports2, module2) {
|
|
23695
23695
|
module2.exports = isexe;
|
|
23696
23696
|
isexe.sync = sync;
|
|
23697
|
-
var
|
|
23698
|
-
function isexe(
|
|
23699
|
-
|
|
23697
|
+
var fs41 = require("fs");
|
|
23698
|
+
function isexe(path60, options, cb) {
|
|
23699
|
+
fs41.stat(path60, function(er, stat) {
|
|
23700
23700
|
cb(er, er ? false : checkStat(stat, options));
|
|
23701
23701
|
});
|
|
23702
23702
|
}
|
|
23703
|
-
function sync(
|
|
23704
|
-
return checkStat(
|
|
23703
|
+
function sync(path60, options) {
|
|
23704
|
+
return checkStat(fs41.statSync(path60), options);
|
|
23705
23705
|
}
|
|
23706
23706
|
function checkStat(stat, options) {
|
|
23707
23707
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -23725,7 +23725,7 @@ var require_mode = __commonJS({
|
|
|
23725
23725
|
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
23726
23726
|
var require_isexe = __commonJS({
|
|
23727
23727
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports2, module2) {
|
|
23728
|
-
var
|
|
23728
|
+
var fs41 = require("fs");
|
|
23729
23729
|
var core;
|
|
23730
23730
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
23731
23731
|
core = require_windows();
|
|
@@ -23734,7 +23734,7 @@ var require_isexe = __commonJS({
|
|
|
23734
23734
|
}
|
|
23735
23735
|
module2.exports = isexe;
|
|
23736
23736
|
isexe.sync = sync;
|
|
23737
|
-
function isexe(
|
|
23737
|
+
function isexe(path60, options, cb) {
|
|
23738
23738
|
if (typeof options === "function") {
|
|
23739
23739
|
cb = options;
|
|
23740
23740
|
options = {};
|
|
@@ -23744,7 +23744,7 @@ var require_isexe = __commonJS({
|
|
|
23744
23744
|
throw new TypeError("callback not provided");
|
|
23745
23745
|
}
|
|
23746
23746
|
return new Promise(function(resolve, reject2) {
|
|
23747
|
-
isexe(
|
|
23747
|
+
isexe(path60, options || {}, function(er, is) {
|
|
23748
23748
|
if (er) {
|
|
23749
23749
|
reject2(er);
|
|
23750
23750
|
} else {
|
|
@@ -23753,7 +23753,7 @@ var require_isexe = __commonJS({
|
|
|
23753
23753
|
});
|
|
23754
23754
|
});
|
|
23755
23755
|
}
|
|
23756
|
-
core(
|
|
23756
|
+
core(path60, options || {}, function(er, is) {
|
|
23757
23757
|
if (er) {
|
|
23758
23758
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
23759
23759
|
er = null;
|
|
@@ -23763,9 +23763,9 @@ var require_isexe = __commonJS({
|
|
|
23763
23763
|
cb(er, is);
|
|
23764
23764
|
});
|
|
23765
23765
|
}
|
|
23766
|
-
function sync(
|
|
23766
|
+
function sync(path60, options) {
|
|
23767
23767
|
try {
|
|
23768
|
-
return core.sync(
|
|
23768
|
+
return core.sync(path60, options || {});
|
|
23769
23769
|
} catch (er) {
|
|
23770
23770
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
23771
23771
|
return false;
|
|
@@ -23781,7 +23781,7 @@ var require_isexe = __commonJS({
|
|
|
23781
23781
|
var require_which = __commonJS({
|
|
23782
23782
|
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports2, module2) {
|
|
23783
23783
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
23784
|
-
var
|
|
23784
|
+
var path60 = require("path");
|
|
23785
23785
|
var COLON = isWindows ? ";" : ":";
|
|
23786
23786
|
var isexe = require_isexe();
|
|
23787
23787
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -23819,7 +23819,7 @@ var require_which = __commonJS({
|
|
|
23819
23819
|
return opt.all && found2.length ? resolve(found2) : reject2(getNotFoundError(cmd));
|
|
23820
23820
|
const ppRaw = pathEnv[i];
|
|
23821
23821
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23822
|
-
const pCmd =
|
|
23822
|
+
const pCmd = path60.join(pathPart, cmd);
|
|
23823
23823
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23824
23824
|
resolve(subStep(p, i, 0));
|
|
23825
23825
|
});
|
|
@@ -23846,7 +23846,7 @@ var require_which = __commonJS({
|
|
|
23846
23846
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
23847
23847
|
const ppRaw = pathEnv[i];
|
|
23848
23848
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23849
|
-
const pCmd =
|
|
23849
|
+
const pCmd = path60.join(pathPart, cmd);
|
|
23850
23850
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23851
23851
|
for (let j = 0; j < pathExt.length; j++) {
|
|
23852
23852
|
const cur = p + pathExt[j];
|
|
@@ -23894,7 +23894,7 @@ var require_path_key = __commonJS({
|
|
|
23894
23894
|
var require_resolveCommand = __commonJS({
|
|
23895
23895
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
23896
23896
|
"use strict";
|
|
23897
|
-
var
|
|
23897
|
+
var path60 = require("path");
|
|
23898
23898
|
var which = require_which();
|
|
23899
23899
|
var getPathKey = require_path_key();
|
|
23900
23900
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -23912,7 +23912,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23912
23912
|
try {
|
|
23913
23913
|
resolved = which.sync(parsed.command, {
|
|
23914
23914
|
path: env2[getPathKey({ env: env2 })],
|
|
23915
|
-
pathExt: withoutPathExt ?
|
|
23915
|
+
pathExt: withoutPathExt ? path60.delimiter : void 0
|
|
23916
23916
|
});
|
|
23917
23917
|
} catch (e) {
|
|
23918
23918
|
} finally {
|
|
@@ -23921,7 +23921,7 @@ var require_resolveCommand = __commonJS({
|
|
|
23921
23921
|
}
|
|
23922
23922
|
}
|
|
23923
23923
|
if (resolved) {
|
|
23924
|
-
resolved =
|
|
23924
|
+
resolved = path60.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
23925
23925
|
}
|
|
23926
23926
|
return resolved;
|
|
23927
23927
|
}
|
|
@@ -23975,8 +23975,8 @@ var require_shebang_command = __commonJS({
|
|
|
23975
23975
|
if (!match) {
|
|
23976
23976
|
return null;
|
|
23977
23977
|
}
|
|
23978
|
-
const [
|
|
23979
|
-
const binary =
|
|
23978
|
+
const [path60, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
23979
|
+
const binary = path60.split("/").pop();
|
|
23980
23980
|
if (binary === "env") {
|
|
23981
23981
|
return argument;
|
|
23982
23982
|
}
|
|
@@ -23989,16 +23989,16 @@ var require_shebang_command = __commonJS({
|
|
|
23989
23989
|
var require_readShebang = __commonJS({
|
|
23990
23990
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
23991
23991
|
"use strict";
|
|
23992
|
-
var
|
|
23992
|
+
var fs41 = require("fs");
|
|
23993
23993
|
var shebangCommand = require_shebang_command();
|
|
23994
23994
|
function readShebang(command) {
|
|
23995
23995
|
const size = 150;
|
|
23996
23996
|
const buffer = Buffer.alloc(size);
|
|
23997
23997
|
let fd;
|
|
23998
23998
|
try {
|
|
23999
|
-
fd =
|
|
24000
|
-
|
|
24001
|
-
|
|
23999
|
+
fd = fs41.openSync(command, "r");
|
|
24000
|
+
fs41.readSync(fd, buffer, 0, size, 0);
|
|
24001
|
+
fs41.closeSync(fd);
|
|
24002
24002
|
} catch (e) {
|
|
24003
24003
|
}
|
|
24004
24004
|
return shebangCommand(buffer.toString());
|
|
@@ -24011,7 +24011,7 @@ var require_readShebang = __commonJS({
|
|
|
24011
24011
|
var require_parse2 = __commonJS({
|
|
24012
24012
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
24013
24013
|
"use strict";
|
|
24014
|
-
var
|
|
24014
|
+
var path60 = require("path");
|
|
24015
24015
|
var resolveCommand = require_resolveCommand();
|
|
24016
24016
|
var escape4 = require_escape();
|
|
24017
24017
|
var readShebang = require_readShebang();
|
|
@@ -24036,7 +24036,7 @@ var require_parse2 = __commonJS({
|
|
|
24036
24036
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
24037
24037
|
if (parsed.options.forceShell || needsShell) {
|
|
24038
24038
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
24039
|
-
parsed.command =
|
|
24039
|
+
parsed.command = path60.normalize(parsed.command);
|
|
24040
24040
|
parsed.command = escape4.command(parsed.command);
|
|
24041
24041
|
parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
|
|
24042
24042
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -24257,10 +24257,10 @@ __export(server_exports, {
|
|
|
24257
24257
|
startServer: () => startServer
|
|
24258
24258
|
});
|
|
24259
24259
|
module.exports = __toCommonJS(server_exports);
|
|
24260
|
-
var
|
|
24260
|
+
var import_promises34 = __toESM(require("node:fs/promises"), 1);
|
|
24261
24261
|
var import_node_fs14 = require("node:fs");
|
|
24262
24262
|
var import_node_http = require("node:http");
|
|
24263
|
-
var
|
|
24263
|
+
var import_node_path60 = __toESM(require("node:path"), 1);
|
|
24264
24264
|
|
|
24265
24265
|
// ../../packages/core/dist/platform/http.js
|
|
24266
24266
|
var import_node_crypto = require("node:crypto");
|
|
@@ -25421,10 +25421,10 @@ function mergeDefs(...defs) {
|
|
|
25421
25421
|
function cloneDef(schema8) {
|
|
25422
25422
|
return mergeDefs(schema8._zod.def);
|
|
25423
25423
|
}
|
|
25424
|
-
function getElementAtPath(obj,
|
|
25425
|
-
if (!
|
|
25424
|
+
function getElementAtPath(obj, path60) {
|
|
25425
|
+
if (!path60)
|
|
25426
25426
|
return obj;
|
|
25427
|
-
return
|
|
25427
|
+
return path60.reduce((acc, key2) => acc?.[key2], obj);
|
|
25428
25428
|
}
|
|
25429
25429
|
function promiseAllObject(promisesObj) {
|
|
25430
25430
|
const keys = Object.keys(promisesObj);
|
|
@@ -25833,11 +25833,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
25833
25833
|
}
|
|
25834
25834
|
return false;
|
|
25835
25835
|
}
|
|
25836
|
-
function prefixIssues(
|
|
25836
|
+
function prefixIssues(path60, issues) {
|
|
25837
25837
|
return issues.map((iss) => {
|
|
25838
25838
|
var _a3;
|
|
25839
25839
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
25840
|
-
iss.path.unshift(
|
|
25840
|
+
iss.path.unshift(path60);
|
|
25841
25841
|
return iss;
|
|
25842
25842
|
});
|
|
25843
25843
|
}
|
|
@@ -25984,16 +25984,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
25984
25984
|
}
|
|
25985
25985
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
25986
25986
|
const fieldErrors = { _errors: [] };
|
|
25987
|
-
const processError = (error52,
|
|
25987
|
+
const processError = (error52, path60 = []) => {
|
|
25988
25988
|
for (const issue2 of error52.issues) {
|
|
25989
25989
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
25990
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
25990
|
+
issue2.errors.map((issues) => processError({ issues }, [...path60, ...issue2.path]));
|
|
25991
25991
|
} else if (issue2.code === "invalid_key") {
|
|
25992
|
-
processError({ issues: issue2.issues }, [...
|
|
25992
|
+
processError({ issues: issue2.issues }, [...path60, ...issue2.path]);
|
|
25993
25993
|
} else if (issue2.code === "invalid_element") {
|
|
25994
|
-
processError({ issues: issue2.issues }, [...
|
|
25994
|
+
processError({ issues: issue2.issues }, [...path60, ...issue2.path]);
|
|
25995
25995
|
} else {
|
|
25996
|
-
const fullpath = [...
|
|
25996
|
+
const fullpath = [...path60, ...issue2.path];
|
|
25997
25997
|
if (fullpath.length === 0) {
|
|
25998
25998
|
fieldErrors._errors.push(mapper(issue2));
|
|
25999
25999
|
} else {
|
|
@@ -26020,17 +26020,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26020
26020
|
}
|
|
26021
26021
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
26022
26022
|
const result = { errors: [] };
|
|
26023
|
-
const processError = (error52,
|
|
26023
|
+
const processError = (error52, path60 = []) => {
|
|
26024
26024
|
var _a3, _b;
|
|
26025
26025
|
for (const issue2 of error52.issues) {
|
|
26026
26026
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
26027
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
26027
|
+
issue2.errors.map((issues) => processError({ issues }, [...path60, ...issue2.path]));
|
|
26028
26028
|
} else if (issue2.code === "invalid_key") {
|
|
26029
|
-
processError({ issues: issue2.issues }, [...
|
|
26029
|
+
processError({ issues: issue2.issues }, [...path60, ...issue2.path]);
|
|
26030
26030
|
} else if (issue2.code === "invalid_element") {
|
|
26031
|
-
processError({ issues: issue2.issues }, [...
|
|
26031
|
+
processError({ issues: issue2.issues }, [...path60, ...issue2.path]);
|
|
26032
26032
|
} else {
|
|
26033
|
-
const fullpath = [...
|
|
26033
|
+
const fullpath = [...path60, ...issue2.path];
|
|
26034
26034
|
if (fullpath.length === 0) {
|
|
26035
26035
|
result.errors.push(mapper(issue2));
|
|
26036
26036
|
continue;
|
|
@@ -26062,8 +26062,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
26062
26062
|
}
|
|
26063
26063
|
function toDotPath(_path) {
|
|
26064
26064
|
const segs = [];
|
|
26065
|
-
const
|
|
26066
|
-
for (const seg of
|
|
26065
|
+
const path60 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
26066
|
+
for (const seg of path60) {
|
|
26067
26067
|
if (typeof seg === "number")
|
|
26068
26068
|
segs.push(`[${seg}]`);
|
|
26069
26069
|
else if (typeof seg === "symbol")
|
|
@@ -38755,13 +38755,13 @@ function resolveRef(ref, ctx) {
|
|
|
38755
38755
|
if (!ref.startsWith("#")) {
|
|
38756
38756
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
38757
38757
|
}
|
|
38758
|
-
const
|
|
38759
|
-
if (
|
|
38758
|
+
const path60 = ref.slice(1).split("/").filter(Boolean);
|
|
38759
|
+
if (path60.length === 0) {
|
|
38760
38760
|
return ctx.rootSchema;
|
|
38761
38761
|
}
|
|
38762
38762
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
38763
|
-
if (
|
|
38764
|
-
const key2 =
|
|
38763
|
+
if (path60[0] === defsKey) {
|
|
38764
|
+
const key2 = path60[1];
|
|
38765
38765
|
if (!key2 || !ctx.defs[key2]) {
|
|
38766
38766
|
throw new Error(`Reference not found: ${ref}`);
|
|
38767
38767
|
}
|
|
@@ -39383,7 +39383,12 @@ var stdioServerSchema = external_exports.object({
|
|
|
39383
39383
|
* Bare names, matching `disabledTools`, so both halves of a server's per-tool configuration are
|
|
39384
39384
|
* keyed the same way and a namespaced name pasted here does not silently fail to match.
|
|
39385
39385
|
*/
|
|
39386
|
-
toolTimeouts: external_exports.record(external_exports.string(), external_exports.number().positive().max(3600)).optional()
|
|
39386
|
+
toolTimeouts: external_exports.record(external_exports.string(), external_exports.number().positive().max(3600)).optional(),
|
|
39387
|
+
/**
|
|
39388
|
+
* Set when this server is an installed add-on (`addons/discover.ts`): which package, and the
|
|
39389
|
+
* version that was enabled. Another installed version leaves the server off until enabled again.
|
|
39390
|
+
*/
|
|
39391
|
+
addon: external_exports.object({ package: external_exports.string().min(1), version: external_exports.string().min(1) }).optional()
|
|
39387
39392
|
});
|
|
39388
39393
|
var httpServerSchema = external_exports.object({
|
|
39389
39394
|
url: external_exports.string().min(1).url(),
|
|
@@ -40532,6 +40537,17 @@ var configSchema = external_exports.object({
|
|
|
40532
40537
|
* **User-scope only** (invariant 5): it names programs to run. A repository able to set a command
|
|
40533
40538
|
* here would run a program of its choosing the first time a file in that language was edited.
|
|
40534
40539
|
*/
|
|
40540
|
+
/**
|
|
40541
|
+
* Add-ons (`addons/discover.ts`): installed Node packages labelled `lightCode.addon` that run an
|
|
40542
|
+
* MCP server. `folders` are looked in as well as npm's global folder - a folder of packages, or
|
|
40543
|
+
* one add-on being written. Enabling one writes an ordinary `mcpServers` entry.
|
|
40544
|
+
*
|
|
40545
|
+
* **User-scope only** (invariant 5): it decides where programs to run are found. A repository
|
|
40546
|
+
* able to add a folder could offer its own add-on under a familiar name.
|
|
40547
|
+
*/
|
|
40548
|
+
addons: external_exports.object({
|
|
40549
|
+
folders: external_exports.array(external_exports.string().min(1)).max(50)
|
|
40550
|
+
}).partial(),
|
|
40535
40551
|
lsp: external_exports.object({
|
|
40536
40552
|
enabled: external_exports.boolean(),
|
|
40537
40553
|
servers: external_exports.record(external_exports.string(), external_exports.union([external_exports.literal(false), external_exports.object({ command: external_exports.string().min(1), args: external_exports.array(external_exports.string()).optional() })]))
|
|
@@ -41318,6 +41334,8 @@ var USER_SCOPE_ONLY_KEYS = [
|
|
|
41318
41334
|
"office",
|
|
41319
41335
|
// Names language-server programs to run when a file is edited.
|
|
41320
41336
|
"lsp",
|
|
41337
|
+
// Names folders where add-ons - programs to run - are found.
|
|
41338
|
+
"addons",
|
|
41321
41339
|
// Names folders of the user's mail to read, embed and send to whichever store is configured.
|
|
41322
41340
|
// The same threat as `embedder`, with the user's correspondence as the payload.
|
|
41323
41341
|
"mail",
|
|
@@ -43996,8 +44014,8 @@ var SUPERSEDED_MARKER = "[Superseded: this file was read again later in the conv
|
|
|
43996
44014
|
function readFilePath(argumentsJson) {
|
|
43997
44015
|
try {
|
|
43998
44016
|
const parsed = JSON.parse(argumentsJson.length > 0 ? argumentsJson : "{}");
|
|
43999
|
-
const
|
|
44000
|
-
return typeof
|
|
44017
|
+
const path60 = parsed.path;
|
|
44018
|
+
return typeof path60 === "string" && path60.length > 0 ? path60 : void 0;
|
|
44001
44019
|
} catch {
|
|
44002
44020
|
return void 0;
|
|
44003
44021
|
}
|
|
@@ -44010,8 +44028,8 @@ function dropSupersededReads(messages) {
|
|
|
44010
44028
|
for (const toolCall of message4.toolCalls ?? []) {
|
|
44011
44029
|
if (toolCall.name !== "read_file")
|
|
44012
44030
|
continue;
|
|
44013
|
-
const
|
|
44014
|
-
if (
|
|
44031
|
+
const path60 = readFilePath(toolCall.arguments);
|
|
44032
|
+
if (path60 === void 0)
|
|
44015
44033
|
continue;
|
|
44016
44034
|
keyByCallId.set(toolCall.id, toolCall.arguments);
|
|
44017
44035
|
}
|
|
@@ -44964,6 +44982,9 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
|
|
|
44964
44982
|
"- Before asking, check what is here: the imports and existing calls in this workspace are",
|
|
44965
44983
|
" evidence about the version actually installed, and a skill may already describe it."
|
|
44966
44984
|
);
|
|
44985
|
+
if (options.codebaseInstructions !== void 0 && options.codebaseInstructions.length > 0) {
|
|
44986
|
+
lines.push("", options.codebaseInstructions);
|
|
44987
|
+
}
|
|
44967
44988
|
if (options.skills !== void 0 && options.skills.length > 0) {
|
|
44968
44989
|
lines.push("", options.skills);
|
|
44969
44990
|
}
|
|
@@ -46852,13 +46873,13 @@ var OpenSearchClient = class {
|
|
|
46852
46873
|
* `_bulk`, `_delete_by_query`, index creation — is refused here rather than merely
|
|
46853
46874
|
* unused, so no future edit or crafted argument can turn a read client into a writer.
|
|
46854
46875
|
*/
|
|
46855
|
-
async request(
|
|
46876
|
+
async request(path60, options = {}) {
|
|
46856
46877
|
const method = options.method ?? "GET";
|
|
46857
|
-
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(
|
|
46878
|
+
const isSearchPost = method === "POST" && /\/_search(\?|$)/.test(path60);
|
|
46858
46879
|
if (method !== "GET" && !isSearchPost) {
|
|
46859
|
-
throw new OpenSearchError(`Refusing ${method} ${
|
|
46880
|
+
throw new OpenSearchError(`Refusing ${method} ${path60}: this client is read-only. Indexing goes through the indexer, which the user starts from Settings.`);
|
|
46860
46881
|
}
|
|
46861
|
-
const url2 = `${this.base}${
|
|
46882
|
+
const url2 = `${this.base}${path60}`;
|
|
46862
46883
|
const request = {
|
|
46863
46884
|
method,
|
|
46864
46885
|
headers: this.headers()
|
|
@@ -47025,11 +47046,11 @@ function collectFields(properties, prefix, out) {
|
|
|
47025
47046
|
return;
|
|
47026
47047
|
for (const [name, raw] of Object.entries(properties)) {
|
|
47027
47048
|
const field2 = raw;
|
|
47028
|
-
const
|
|
47049
|
+
const path60 = prefix.length > 0 ? `${prefix}.${name}` : name;
|
|
47029
47050
|
if (typeof field2.type === "string")
|
|
47030
|
-
out[
|
|
47051
|
+
out[path60] = field2.type;
|
|
47031
47052
|
if (field2.properties !== void 0)
|
|
47032
|
-
collectFields(field2.properties,
|
|
47053
|
+
collectFields(field2.properties, path60, out);
|
|
47033
47054
|
}
|
|
47034
47055
|
}
|
|
47035
47056
|
function describeStatus(status2, url2, body) {
|
|
@@ -47048,23 +47069,23 @@ function describeStatus(status2, url2, body) {
|
|
|
47048
47069
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "match_only_text", "search_as_you_type", "wildcard"]);
|
|
47049
47070
|
var KEYWORD_TYPES = /* @__PURE__ */ new Set(["keyword", "constant_keyword"]);
|
|
47050
47071
|
var NOISE_FIELDS = /* @__PURE__ */ new Set(["@version", "ecs", "tags", "stream", "input", "agent", "host", "event"]);
|
|
47051
|
-
function leafName(
|
|
47052
|
-
const parts =
|
|
47053
|
-
return parts[parts.length - 1] ??
|
|
47072
|
+
function leafName(path60) {
|
|
47073
|
+
const parts = path60.split(".");
|
|
47074
|
+
return parts[parts.length - 1] ?? path60;
|
|
47054
47075
|
}
|
|
47055
47076
|
function selectQueryFields(mapping, limit = 25) {
|
|
47056
47077
|
const text = [];
|
|
47057
47078
|
const keyword = [];
|
|
47058
|
-
for (const [
|
|
47059
|
-
if (NOISE_FIELDS.has(leafName(
|
|
47079
|
+
for (const [path60, type] of Object.entries(mapping)) {
|
|
47080
|
+
if (NOISE_FIELDS.has(leafName(path60)) || NOISE_FIELDS.has(path60.split(".")[0] ?? ""))
|
|
47060
47081
|
continue;
|
|
47061
47082
|
if (TEXT_TYPES.has(type)) {
|
|
47062
|
-
text.push(
|
|
47083
|
+
text.push(path60);
|
|
47063
47084
|
} else if (KEYWORD_TYPES.has(type)) {
|
|
47064
|
-
const parent =
|
|
47065
|
-
if (
|
|
47085
|
+
const parent = path60.replace(/\.keyword$/, "");
|
|
47086
|
+
if (path60.endsWith(".keyword") && TEXT_TYPES.has(mapping[parent] ?? ""))
|
|
47066
47087
|
continue;
|
|
47067
|
-
keyword.push(
|
|
47088
|
+
keyword.push(path60);
|
|
47068
47089
|
}
|
|
47069
47090
|
}
|
|
47070
47091
|
const byDepth = (a, b) => a.split(".").length - b.split(".").length || a.localeCompare(b);
|
|
@@ -47206,8 +47227,8 @@ var OpenSearchIndexWriter = class {
|
|
|
47206
47227
|
}
|
|
47207
47228
|
return headers;
|
|
47208
47229
|
}
|
|
47209
|
-
async request(
|
|
47210
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
47230
|
+
async request(path60, method, body, signal) {
|
|
47231
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path60}`;
|
|
47211
47232
|
const request = { method, headers: this.headers() };
|
|
47212
47233
|
if (body !== void 0) {
|
|
47213
47234
|
if (typeof body === "string") {
|
|
@@ -47421,13 +47442,13 @@ var OpenSearchIndexWriter = class {
|
|
|
47421
47442
|
for (const hit of hits) {
|
|
47422
47443
|
const source = hit._source ?? {};
|
|
47423
47444
|
const vector = source.vector;
|
|
47424
|
-
const
|
|
47425
|
-
if (typeof
|
|
47445
|
+
const path60 = source.path;
|
|
47446
|
+
if (typeof path60 !== "string" || !Array.isArray(vector))
|
|
47426
47447
|
continue;
|
|
47427
47448
|
documents.push({
|
|
47428
47449
|
id: hit._id ?? "",
|
|
47429
47450
|
text: typeof source.text === "string" ? source.text : "",
|
|
47430
|
-
path:
|
|
47451
|
+
path: path60,
|
|
47431
47452
|
startLine: typeof source.startLine === "number" ? source.startLine : 1,
|
|
47432
47453
|
endLine: typeof source.endLine === "number" ? source.endLine : 1,
|
|
47433
47454
|
vector
|
|
@@ -47501,8 +47522,8 @@ var RestTransport = class {
|
|
|
47501
47522
|
* threw would push every caller into catching and re-inspecting an error to find out
|
|
47502
47523
|
* whether it was really an error. `expectOk` is there for the cases that are.
|
|
47503
47524
|
*/
|
|
47504
|
-
async send(
|
|
47505
|
-
const url2 = `${this.connection.url.replace(/\/+$/, "")}${
|
|
47525
|
+
async send(path60, method, body, signal) {
|
|
47526
|
+
const url2 = `${this.connection.url.replace(/\/+$/, "")}${path60}`;
|
|
47506
47527
|
const request = { method, headers: this.headers() };
|
|
47507
47528
|
if (body !== void 0)
|
|
47508
47529
|
request.body = JSON.stringify(body);
|
|
@@ -47528,11 +47549,11 @@ var RestTransport = class {
|
|
|
47528
47549
|
return { status: response.status, body: parsed };
|
|
47529
47550
|
}
|
|
47530
47551
|
/** Sends, and throws unless the status is 2xx. */
|
|
47531
|
-
async expectOk(
|
|
47532
|
-
const result = await this.send(
|
|
47552
|
+
async expectOk(path60, method, body, signal) {
|
|
47553
|
+
const result = await this.send(path60, method, body, signal);
|
|
47533
47554
|
if (result.status < 200 || result.status >= 300) {
|
|
47534
47555
|
const detail = typeof result.body === "string" ? result.body : JSON.stringify(result.body ?? "");
|
|
47535
|
-
throw new VectorStoreError(`${method} ${
|
|
47556
|
+
throw new VectorStoreError(`${method} ${path60} on ${this.label} returned HTTP ${String(result.status)}. ${detail.slice(0, 300)}`, result.status);
|
|
47536
47557
|
}
|
|
47537
47558
|
return result.body;
|
|
47538
47559
|
}
|
|
@@ -47640,10 +47661,10 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
47640
47661
|
const matches = [];
|
|
47641
47662
|
for (let index = 0; index < ids.length; index++) {
|
|
47642
47663
|
const metadata = metadatas[index] ?? {};
|
|
47643
|
-
const
|
|
47644
|
-
if (
|
|
47664
|
+
const path60 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
47665
|
+
if (path60 === void 0)
|
|
47645
47666
|
continue;
|
|
47646
|
-
if (prefix !== void 0 && prefix.length > 0 && !
|
|
47667
|
+
if (prefix !== void 0 && prefix.length > 0 && !path60.startsWith(prefix))
|
|
47647
47668
|
continue;
|
|
47648
47669
|
if (projectHere && typeof metadata.project === "string" && !options.project?.names.includes(metadata.project))
|
|
47649
47670
|
continue;
|
|
@@ -47657,7 +47678,7 @@ var ChromaSearcher = class extends ChromaBase {
|
|
|
47657
47678
|
*/
|
|
47658
47679
|
score: typeof distance === "number" ? 1 / (1 + Math.max(0, distance)) : 0,
|
|
47659
47680
|
text: documents[index] ?? (typeof metadata.text === "string" ? metadata.text : ""),
|
|
47660
|
-
path:
|
|
47681
|
+
path: path60
|
|
47661
47682
|
};
|
|
47662
47683
|
if (typeof metadata.startLine === "number")
|
|
47663
47684
|
match.startLine = metadata.startLine;
|
|
@@ -47768,13 +47789,13 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
47768
47789
|
for (let index = 0; index < ids.length; index++) {
|
|
47769
47790
|
const metadata = result.metadatas?.[index] ?? {};
|
|
47770
47791
|
const vector = result.embeddings?.[index];
|
|
47771
|
-
const
|
|
47772
|
-
if (
|
|
47792
|
+
const path60 = typeof metadata.path === "string" ? metadata.path : void 0;
|
|
47793
|
+
if (path60 === void 0 || !Array.isArray(vector))
|
|
47773
47794
|
continue;
|
|
47774
47795
|
documents.push({
|
|
47775
47796
|
id: ids[index] ?? "",
|
|
47776
47797
|
text: result.documents?.[index] ?? "",
|
|
47777
|
-
path:
|
|
47798
|
+
path: path60,
|
|
47778
47799
|
startLine: typeof metadata.startLine === "number" ? metadata.startLine : 1,
|
|
47779
47800
|
endLine: typeof metadata.endLine === "number" ? metadata.endLine : 1,
|
|
47780
47801
|
vector
|
|
@@ -47791,9 +47812,9 @@ var ChromaIndexWriter = class extends ChromaBase {
|
|
|
47791
47812
|
const result = await this.rest.expectOk(`${this.base}/collections/${found2.id}/get`, "POST", { include: ["metadatas"], limit }, options.signal);
|
|
47792
47813
|
const paths = /* @__PURE__ */ new Set();
|
|
47793
47814
|
for (const metadata of result.metadatas ?? []) {
|
|
47794
|
-
const
|
|
47795
|
-
if (typeof
|
|
47796
|
-
paths.add(
|
|
47815
|
+
const path60 = metadata?.path;
|
|
47816
|
+
if (typeof path60 === "string")
|
|
47817
|
+
paths.add(path60);
|
|
47797
47818
|
}
|
|
47798
47819
|
return [...paths];
|
|
47799
47820
|
}
|
|
@@ -47820,14 +47841,14 @@ var MARKER_ID = "5f6d2a41-0000-5000-8000-6c69676874c0";
|
|
|
47820
47841
|
var MARKER_MARK = "light-code";
|
|
47821
47842
|
function toMatch(point) {
|
|
47822
47843
|
const payload = point.payload ?? {};
|
|
47823
|
-
const
|
|
47824
|
-
if (
|
|
47844
|
+
const path60 = typeof payload.path === "string" ? payload.path : void 0;
|
|
47845
|
+
if (path60 === void 0)
|
|
47825
47846
|
return void 0;
|
|
47826
47847
|
const match = {
|
|
47827
47848
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
47828
47849
|
score: typeof point.score === "number" ? point.score : 0,
|
|
47829
47850
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
47830
|
-
path:
|
|
47851
|
+
path: path60
|
|
47831
47852
|
};
|
|
47832
47853
|
if (typeof payload.startLine === "number")
|
|
47833
47854
|
match.startLine = payload.startLine;
|
|
@@ -48021,13 +48042,13 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48021
48042
|
const documents = [];
|
|
48022
48043
|
for (const point of result.body.result?.points ?? []) {
|
|
48023
48044
|
const payload = point.payload ?? {};
|
|
48024
|
-
const
|
|
48025
|
-
if (
|
|
48045
|
+
const path60 = typeof payload.path === "string" ? payload.path : void 0;
|
|
48046
|
+
if (path60 === void 0 || !Array.isArray(point.vector))
|
|
48026
48047
|
continue;
|
|
48027
48048
|
documents.push({
|
|
48028
48049
|
id: typeof payload.chunkId === "string" ? payload.chunkId : point.id,
|
|
48029
48050
|
text: typeof payload.text === "string" ? payload.text : "",
|
|
48030
|
-
path:
|
|
48051
|
+
path: path60,
|
|
48031
48052
|
startLine: typeof payload.startLine === "number" ? payload.startLine : 1,
|
|
48032
48053
|
endLine: typeof payload.endLine === "number" ? payload.endLine : 1,
|
|
48033
48054
|
vector: point.vector
|
|
@@ -48054,9 +48075,9 @@ var QdrantIndexWriter = class extends QdrantBase {
|
|
|
48054
48075
|
throw new VectorStoreError(`Could not list "${collection}" (HTTP ${String(result.status)}).`, result.status);
|
|
48055
48076
|
}
|
|
48056
48077
|
for (const point of result.body.result?.points ?? []) {
|
|
48057
|
-
const
|
|
48058
|
-
if (typeof
|
|
48059
|
-
paths.add(
|
|
48078
|
+
const path60 = point.payload?.path;
|
|
48079
|
+
if (typeof path60 === "string")
|
|
48080
|
+
paths.add(path60);
|
|
48060
48081
|
}
|
|
48061
48082
|
offset = result.body.result?.next_page_offset;
|
|
48062
48083
|
if (offset === void 0 || offset === null)
|
|
@@ -48590,8 +48611,8 @@ function teamSkillDocument(skill, body, vector, attribution) {
|
|
|
48590
48611
|
vector
|
|
48591
48612
|
};
|
|
48592
48613
|
}
|
|
48593
|
-
function nameFromPath(
|
|
48594
|
-
return
|
|
48614
|
+
function nameFromPath(path60) {
|
|
48615
|
+
return path60.startsWith("skill:") ? path60.slice("skill:".length) : path60;
|
|
48595
48616
|
}
|
|
48596
48617
|
function toHit(match, self) {
|
|
48597
48618
|
return {
|
|
@@ -51673,8 +51694,8 @@ function createMailCoverageTool(options) {
|
|
|
51673
51694
|
}
|
|
51674
51695
|
};
|
|
51675
51696
|
}
|
|
51676
|
-
function normaliseFolder(
|
|
51677
|
-
return
|
|
51697
|
+
function normaliseFolder(path60) {
|
|
51698
|
+
return path60.toLowerCase().replace(/[\\/]+/g, "\\");
|
|
51678
51699
|
}
|
|
51679
51700
|
function haystackOf(record2) {
|
|
51680
51701
|
return `${record2.subject}
|
|
@@ -52170,7 +52191,7 @@ async function refreshMail(options) {
|
|
|
52170
52191
|
const limit = options.batchLimit ?? 2e3;
|
|
52171
52192
|
const previewChars = options.previewChars ?? 400;
|
|
52172
52193
|
const sinceMs = Date.now() - options.days * 24 * 60 * 60 * 1e3;
|
|
52173
|
-
const harvested = await options.harvest(options.folders.map((
|
|
52194
|
+
const harvested = await options.harvest(options.folders.map((path60) => ({ path: path60, sinceMs })), { limit, previewChars });
|
|
52174
52195
|
const fetched = harvested.messages.map(toRecord);
|
|
52175
52196
|
if (fetched.length === 0) {
|
|
52176
52197
|
return { added: 0, more: false, total: known.length, embedded: 0, backfilled: 0, complete: [] };
|
|
@@ -52211,9 +52232,9 @@ async function syncMail(options) {
|
|
|
52211
52232
|
const backfillDone = await options.store.loadBackfillState();
|
|
52212
52233
|
const limit = options.batchLimit ?? 500;
|
|
52213
52234
|
const previewChars = options.previewChars ?? 400;
|
|
52214
|
-
const forwardRequests = options.folders.map((
|
|
52215
|
-
const mark = marks.get(
|
|
52216
|
-
return mark === void 0 ? { path:
|
|
52235
|
+
const forwardRequests = options.folders.map((path60) => {
|
|
52236
|
+
const mark = marks.get(path60);
|
|
52237
|
+
return mark === void 0 ? { path: path60 } : { path: path60, sinceMs: mark.newest - 1e3 };
|
|
52217
52238
|
});
|
|
52218
52239
|
const forward = await options.harvest(forwardRequests, { limit, previewChars });
|
|
52219
52240
|
let candidates = forward.messages.map(toRecord);
|
|
@@ -52222,15 +52243,15 @@ async function syncMail(options) {
|
|
|
52222
52243
|
let more = forward.truncated;
|
|
52223
52244
|
const remaining = limit - candidates.length;
|
|
52224
52245
|
const floor = options.retentionMonths === void 0 ? void 0 : monthsBefore(options.now ?? Date.now(), options.retentionMonths);
|
|
52225
|
-
const outstanding = options.folders.filter((
|
|
52226
|
-
const atFloor = floor === void 0 ? [] : outstanding.filter((
|
|
52227
|
-
const behind = outstanding.filter((
|
|
52246
|
+
const outstanding = options.folders.filter((path60) => marks.has(path60) && backfillDone[path60] !== true);
|
|
52247
|
+
const atFloor = floor === void 0 ? [] : outstanding.filter((path60) => marks.get(path60).oldest <= floor);
|
|
52248
|
+
const behind = outstanding.filter((path60) => !atFloor.includes(path60));
|
|
52228
52249
|
completed.push(...atFloor);
|
|
52229
52250
|
if (remaining > 0 && behind.length > 0 && options.signal?.aborted !== true) {
|
|
52230
|
-
const backRequests = behind.map((
|
|
52231
|
-
path:
|
|
52251
|
+
const backRequests = behind.map((path60) => ({
|
|
52252
|
+
path: path60,
|
|
52232
52253
|
// Strictly older, so the oldest held message is not fetched again every pass.
|
|
52233
|
-
beforeMs: marks.get(
|
|
52254
|
+
beforeMs: marks.get(path60).oldest,
|
|
52234
52255
|
// And no older than retention wants. The harvest ANDs the two into one window.
|
|
52235
52256
|
...floor === void 0 ? {} : { sinceMs: floor }
|
|
52236
52257
|
}));
|
|
@@ -52238,9 +52259,9 @@ async function syncMail(options) {
|
|
|
52238
52259
|
backfilled = backward.messages.length;
|
|
52239
52260
|
candidates = [...candidates, ...backward.messages.map(toRecord)];
|
|
52240
52261
|
const returnedFor = new Set(backward.messages.map((message4) => message4.folder));
|
|
52241
|
-
for (const
|
|
52242
|
-
if (!returnedFor.has(
|
|
52243
|
-
completed.push(
|
|
52262
|
+
for (const path60 of behind) {
|
|
52263
|
+
if (!returnedFor.has(path60))
|
|
52264
|
+
completed.push(path60);
|
|
52244
52265
|
}
|
|
52245
52266
|
if (backward.truncated || backfilled > 0)
|
|
52246
52267
|
more = true;
|
|
@@ -52248,7 +52269,7 @@ async function syncMail(options) {
|
|
|
52248
52269
|
if (completed.length > 0) {
|
|
52249
52270
|
await options.store.saveBackfillState({
|
|
52250
52271
|
...backfillDone,
|
|
52251
|
-
...Object.fromEntries(completed.map((
|
|
52272
|
+
...Object.fromEntries(completed.map((path60) => [path60, true]))
|
|
52252
52273
|
});
|
|
52253
52274
|
}
|
|
52254
52275
|
const fresh = withoutKnown(candidates, known);
|
|
@@ -52582,14 +52603,14 @@ function formatBytes(size) {
|
|
|
52582
52603
|
return `${(size / (1 << 10)).toFixed(1)}KB`;
|
|
52583
52604
|
return `${String(size)}B`;
|
|
52584
52605
|
}
|
|
52585
|
-
async function readTail(
|
|
52606
|
+
async function readTail(fs41, path60, size, count3) {
|
|
52586
52607
|
let span = Math.min(size, CHUNK);
|
|
52587
52608
|
let text;
|
|
52588
52609
|
let start;
|
|
52589
52610
|
for (; ; ) {
|
|
52590
52611
|
start = Math.max(0, size - span);
|
|
52591
52612
|
const decoder = new import_node_string_decoder.StringDecoder("utf8");
|
|
52592
|
-
text = decoder.write(await
|
|
52613
|
+
text = decoder.write(await fs41.readBytesSlice(path60, start, size)) + decoder.end();
|
|
52593
52614
|
const enough = text.split("\n").length > count3;
|
|
52594
52615
|
if (enough || start === 0 || span >= size)
|
|
52595
52616
|
break;
|
|
@@ -52607,7 +52628,7 @@ async function readTail(fs39, path58, size, count3) {
|
|
|
52607
52628
|
hasMoreAfter: false
|
|
52608
52629
|
};
|
|
52609
52630
|
}
|
|
52610
|
-
async function readLineWindow(
|
|
52631
|
+
async function readLineWindow(fs41, path60, size, from, count3) {
|
|
52611
52632
|
const decoder = new import_node_string_decoder.StringDecoder("utf8");
|
|
52612
52633
|
const lines = [];
|
|
52613
52634
|
let pending = "";
|
|
@@ -52622,7 +52643,7 @@ async function readLineWindow(fs39, path58, size, from, count3) {
|
|
|
52622
52643
|
};
|
|
52623
52644
|
scan: while (position < size) {
|
|
52624
52645
|
const end = Math.min(size, position + CHUNK);
|
|
52625
|
-
pending += decoder.write(await
|
|
52646
|
+
pending += decoder.write(await fs41.readBytesSlice(path60, position, end));
|
|
52626
52647
|
position = end;
|
|
52627
52648
|
const parts = pending.split(/\r\n|\r|\n/);
|
|
52628
52649
|
pending = parts.pop() ?? "";
|
|
@@ -52645,13 +52666,13 @@ async function readLineWindow(fs39, path58, size, from, count3) {
|
|
|
52645
52666
|
hasMoreAfter: !reachedEnd || lineNumber > from + lines.length
|
|
52646
52667
|
};
|
|
52647
52668
|
}
|
|
52648
|
-
async function countLines(
|
|
52669
|
+
async function countLines(fs41, path60, size) {
|
|
52649
52670
|
let newlines = 0;
|
|
52650
52671
|
let position = 0;
|
|
52651
52672
|
let lastByte = -1;
|
|
52652
52673
|
while (position < size) {
|
|
52653
52674
|
const end = Math.min(size, position + CHUNK);
|
|
52654
|
-
const buffer = await
|
|
52675
|
+
const buffer = await fs41.readBytesSlice(path60, position, end);
|
|
52655
52676
|
for (const byte of buffer)
|
|
52656
52677
|
if (byte === 10)
|
|
52657
52678
|
newlines += 1;
|
|
@@ -52998,9 +53019,9 @@ async function indexWorkspace(options) {
|
|
|
52998
53019
|
var import_node_child_process3 = require("node:child_process");
|
|
52999
53020
|
var import_promises8 = __toESM(require("node:fs/promises"), 1);
|
|
53000
53021
|
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
53001
|
-
function runGit(args, cwd) {
|
|
53022
|
+
function runGit(args, cwd, env2) {
|
|
53002
53023
|
return new Promise((resolve, reject2) => {
|
|
53003
|
-
(0, import_node_child_process3.execFile)("git", args, { cwd, maxBuffer: 32 * 1024 * 1024 }, (error51, stdout, stderr) => {
|
|
53024
|
+
(0, import_node_child_process3.execFile)("git", args, { cwd, maxBuffer: 32 * 1024 * 1024, ...env2 !== void 0 ? { env: env2 } : {} }, (error51, stdout, stderr) => {
|
|
53004
53025
|
if (error51 && typeof error51.code !== "number") {
|
|
53005
53026
|
reject2(error51);
|
|
53006
53027
|
return;
|
|
@@ -53012,12 +53033,29 @@ function runGit(args, cwd) {
|
|
|
53012
53033
|
var ShadowGit = class {
|
|
53013
53034
|
workspaceRoot;
|
|
53014
53035
|
shadowDir;
|
|
53015
|
-
|
|
53036
|
+
sharedObjects;
|
|
53037
|
+
constructor(workspaceRoot, shadowDir, sharedObjects) {
|
|
53016
53038
|
this.workspaceRoot = workspaceRoot;
|
|
53017
53039
|
this.shadowDir = shadowDir;
|
|
53040
|
+
this.sharedObjects = sharedObjects;
|
|
53018
53041
|
}
|
|
53019
53042
|
gitArgs(args) {
|
|
53020
|
-
|
|
53043
|
+
const base = ["-c", "core.autocrlf=false", "-c", "core.safecrlf=false"];
|
|
53044
|
+
if (this.sharedObjects !== void 0)
|
|
53045
|
+
base.push("-c", "gc.auto=0");
|
|
53046
|
+
return [...base, "--git-dir", this.shadowDir, "--work-tree", this.workspaceRoot, ...args];
|
|
53047
|
+
}
|
|
53048
|
+
sharedReady;
|
|
53049
|
+
async git(args) {
|
|
53050
|
+
if (this.sharedObjects === void 0)
|
|
53051
|
+
return runGit(this.gitArgs(args), this.workspaceRoot);
|
|
53052
|
+
this.sharedReady ??= import_promises8.default.mkdir(this.sharedObjects, { recursive: true });
|
|
53053
|
+
await this.sharedReady;
|
|
53054
|
+
return runGit(this.gitArgs(args), this.workspaceRoot, {
|
|
53055
|
+
...process.env,
|
|
53056
|
+
GIT_OBJECT_DIRECTORY: this.sharedObjects,
|
|
53057
|
+
GIT_ALTERNATE_OBJECT_DIRECTORIES: import_node_path19.default.join(this.shadowDir, "objects")
|
|
53058
|
+
});
|
|
53021
53059
|
}
|
|
53022
53060
|
/**
|
|
53023
53061
|
* The workspace's own .gitattributes would still apply eol and filter rules; in the shadow repo's
|
|
@@ -53040,9 +53078,9 @@ var ShadowGit = class {
|
|
|
53040
53078
|
return;
|
|
53041
53079
|
await import_promises8.default.mkdir(import_node_path19.default.dirname(this.shadowDir), { recursive: true });
|
|
53042
53080
|
await runGit(["init", "--bare", this.shadowDir], this.workspaceRoot);
|
|
53043
|
-
await
|
|
53044
|
-
await
|
|
53045
|
-
await
|
|
53081
|
+
await this.git(["config", "user.name", "Light Code"]);
|
|
53082
|
+
await this.git(["config", "user.email", "light-code@localhost"]);
|
|
53083
|
+
await this.git(["config", "core.excludesFile", ""]);
|
|
53046
53084
|
}
|
|
53047
53085
|
async isInitialized() {
|
|
53048
53086
|
try {
|
|
@@ -53055,12 +53093,12 @@ var ShadowGit = class {
|
|
|
53055
53093
|
async snapshot() {
|
|
53056
53094
|
await this.init();
|
|
53057
53095
|
await this.keepBytes();
|
|
53058
|
-
await
|
|
53059
|
-
const commit = await
|
|
53096
|
+
await this.git(["add", "-A"]);
|
|
53097
|
+
const commit = await this.git(["commit", "--allow-empty", "-m", `checkpoint ${(/* @__PURE__ */ new Date()).toISOString()}`]);
|
|
53060
53098
|
if (commit.code !== 0 && !commit.stdout.includes("nothing to commit")) {
|
|
53061
53099
|
throw new Error(`Could not create checkpoint: ${commit.stderr || commit.stdout}`);
|
|
53062
53100
|
}
|
|
53063
|
-
const head = await
|
|
53101
|
+
const head = await this.git(["rev-parse", "HEAD"]);
|
|
53064
53102
|
if (head.code !== 0) {
|
|
53065
53103
|
throw new Error(`Could not read checkpoint commit: ${head.stderr}`);
|
|
53066
53104
|
}
|
|
@@ -53071,11 +53109,11 @@ var ShadowGit = class {
|
|
|
53071
53109
|
* too — otherwise "rollback" would leave the workspace in a state that never existed.
|
|
53072
53110
|
*/
|
|
53073
53111
|
async restore(checkpoint) {
|
|
53074
|
-
const restore = await
|
|
53112
|
+
const restore = await this.git(["restore", "--source", checkpoint.commit, "--worktree", "."]);
|
|
53075
53113
|
if (restore.code !== 0) {
|
|
53076
53114
|
throw new Error(`Could not roll back to checkpoint: ${restore.stderr || restore.stdout}`);
|
|
53077
53115
|
}
|
|
53078
|
-
await
|
|
53116
|
+
await this.git(["clean", "-fd"]);
|
|
53079
53117
|
}
|
|
53080
53118
|
/**
|
|
53081
53119
|
* Restores only these files to the snapshot - for a codebase several chats share (Fire Code),
|
|
@@ -53086,14 +53124,18 @@ var ShadowGit = class {
|
|
|
53086
53124
|
async restoreFiles(checkpoint, files) {
|
|
53087
53125
|
const restored = [];
|
|
53088
53126
|
const removed = [];
|
|
53127
|
+
const readable2 = await this.git(["cat-file", "-e", `${checkpoint.commit}^{commit}`]);
|
|
53128
|
+
if (readable2.code !== 0) {
|
|
53129
|
+
throw new Error(`The checkpoint ${checkpoint.commit.slice(0, 12)} cannot be read, so nothing was rolled back: ${readable2.stderr.trim()}`);
|
|
53130
|
+
}
|
|
53089
53131
|
for (const file2 of files) {
|
|
53090
53132
|
const relative = import_node_path19.default.relative(this.workspaceRoot, file2);
|
|
53091
53133
|
if (relative.startsWith("..") || import_node_path19.default.isAbsolute(relative))
|
|
53092
53134
|
continue;
|
|
53093
53135
|
const spec = relative.split(import_node_path19.default.sep).join("/");
|
|
53094
|
-
const existed = await
|
|
53136
|
+
const existed = await this.git(["cat-file", "-e", `${checkpoint.commit}:${spec}`]);
|
|
53095
53137
|
if (existed.code === 0) {
|
|
53096
|
-
const result = await
|
|
53138
|
+
const result = await this.git(["restore", "--source", checkpoint.commit, "--worktree", "--", spec]);
|
|
53097
53139
|
if (result.code !== 0)
|
|
53098
53140
|
throw new Error(`Could not roll back ${spec}: ${result.stderr || result.stdout}`);
|
|
53099
53141
|
restored.push(spec);
|
|
@@ -59918,13 +59960,13 @@ function appendSkillImages(body, images) {
|
|
|
59918
59960
|
const trimmed = body.replace(/\s+$/, "");
|
|
59919
59961
|
return [trimmed, "", "## Images", "", ...missing.map(renderSkillImage)].join("\n");
|
|
59920
59962
|
}
|
|
59921
|
-
async function listSkillImages(skillFilePath,
|
|
59963
|
+
async function listSkillImages(skillFilePath, fs41) {
|
|
59922
59964
|
const asPosix = skillFilePath.split(String.fromCharCode(92)).join("/");
|
|
59923
59965
|
if (!asPosix.toLowerCase().endsWith("/skill.md"))
|
|
59924
59966
|
return [];
|
|
59925
59967
|
const dir = `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_IMAGE_DIR}`;
|
|
59926
59968
|
try {
|
|
59927
|
-
const entries = await
|
|
59969
|
+
const entries = await fs41.readdir(dir);
|
|
59928
59970
|
return entries.filter((entry) => !entry.isDirectory && skillImageType(entry.name) !== void 0).map((entry) => entry.name).sort();
|
|
59929
59971
|
} catch {
|
|
59930
59972
|
return [];
|
|
@@ -59974,12 +60016,12 @@ function skillFilesDir(skillFilePath) {
|
|
|
59974
60016
|
return void 0;
|
|
59975
60017
|
return `${skillFilePath.slice(0, skillFilePath.length - "SKILL.md".length)}${SKILL_FILE_DIR}`;
|
|
59976
60018
|
}
|
|
59977
|
-
async function listSkillFiles(skillFilePath,
|
|
60019
|
+
async function listSkillFiles(skillFilePath, fs41) {
|
|
59978
60020
|
const dir = skillFilesDir(skillFilePath);
|
|
59979
60021
|
if (dir === void 0)
|
|
59980
60022
|
return [];
|
|
59981
60023
|
try {
|
|
59982
|
-
const entries = await
|
|
60024
|
+
const entries = await fs41.readdir(dir);
|
|
59983
60025
|
return entries.filter((entry) => !entry.isDirectory).map((entry) => entry.name).sort();
|
|
59984
60026
|
} catch {
|
|
59985
60027
|
return [];
|
|
@@ -60576,13 +60618,13 @@ function buildExport(config2, selected) {
|
|
|
60576
60618
|
if (has(config2, key2))
|
|
60577
60619
|
exported[key2] = config2[key2];
|
|
60578
60620
|
}
|
|
60579
|
-
for (const
|
|
60580
|
-
stripPath(exported,
|
|
60621
|
+
for (const path60 of section.strip ?? [])
|
|
60622
|
+
stripPath(exported, path60);
|
|
60581
60623
|
}
|
|
60582
60624
|
return exported;
|
|
60583
60625
|
}
|
|
60584
|
-
function stripPath(target,
|
|
60585
|
-
const [head, ...rest] =
|
|
60626
|
+
function stripPath(target, path60) {
|
|
60627
|
+
const [head, ...rest] = path60.split(".");
|
|
60586
60628
|
if (head === void 0)
|
|
60587
60629
|
return;
|
|
60588
60630
|
const value = target[head];
|
|
@@ -60610,14 +60652,14 @@ function applyImport(existing, imported, selected) {
|
|
|
60610
60652
|
else
|
|
60611
60653
|
delete merged[key2];
|
|
60612
60654
|
}
|
|
60613
|
-
for (const
|
|
60614
|
-
carryPath(existing, merged,
|
|
60655
|
+
for (const path60 of section.strip ?? []) {
|
|
60656
|
+
carryPath(existing, merged, path60);
|
|
60615
60657
|
}
|
|
60616
60658
|
}
|
|
60617
60659
|
return merged;
|
|
60618
60660
|
}
|
|
60619
|
-
function carryPath(from, to,
|
|
60620
|
-
const [head, ...rest] =
|
|
60661
|
+
function carryPath(from, to, path60) {
|
|
60662
|
+
const [head, ...rest] = path60.split(".");
|
|
60621
60663
|
if (head === void 0)
|
|
60622
60664
|
return;
|
|
60623
60665
|
const source = from[head];
|
|
@@ -61593,7 +61635,7 @@ var PythonManager = class {
|
|
|
61593
61635
|
this.venvIsUvManaged = discovered.uvManaged;
|
|
61594
61636
|
interpreter = discovered.interpreter;
|
|
61595
61637
|
} else {
|
|
61596
|
-
this.venvPath = import_node_path27.default.join(this.options.storageDir, "python-venv");
|
|
61638
|
+
this.venvPath = import_node_path27.default.join(this.options.venvRoot ?? this.options.storageDir, "python-venv");
|
|
61597
61639
|
this.venvSource = "created";
|
|
61598
61640
|
this.venvIsUvManaged = true;
|
|
61599
61641
|
interpreter = await ensureVenv({ uv: this.uv, venvDir: this.venvPath, env: env2 });
|
|
@@ -62916,7 +62958,7 @@ The conversation is longer than this model accepts, and it could not be shortene
|
|
|
62916
62958
|
}
|
|
62917
62959
|
|
|
62918
62960
|
// ../../packages/core/dist/host/bridge.js
|
|
62919
|
-
var
|
|
62961
|
+
var import_node_crypto14 = require("node:crypto");
|
|
62920
62962
|
|
|
62921
62963
|
// ../../packages/core/dist/atlassian/autosysGateway.js
|
|
62922
62964
|
function withBasicCredentials(auth2, headerName, username, password) {
|
|
@@ -63037,7 +63079,7 @@ function gatewayFromSettings(input, stored) {
|
|
|
63037
63079
|
// ../../packages/core/dist/host/bridge.js
|
|
63038
63080
|
var import_node_fs10 = require("node:fs");
|
|
63039
63081
|
var import_node_child_process14 = require("node:child_process");
|
|
63040
|
-
var
|
|
63082
|
+
var import_promises27 = __toESM(require("node:fs/promises"), 1);
|
|
63041
63083
|
|
|
63042
63084
|
// ../../packages/core/dist/jupyter/spec.js
|
|
63043
63085
|
var jupyterHubSpecSchema = external_exports.object({
|
|
@@ -63846,8 +63888,405 @@ var FileMachineApprovals = class {
|
|
|
63846
63888
|
}
|
|
63847
63889
|
};
|
|
63848
63890
|
|
|
63849
|
-
// ../../packages/core/dist/
|
|
63891
|
+
// ../../packages/core/dist/addons/discover.js
|
|
63850
63892
|
var import_promises18 = __toESM(require("node:fs/promises"), 1);
|
|
63893
|
+
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
63894
|
+
function defaultAddonFolders(env2, execPath, platform) {
|
|
63895
|
+
const folders = [];
|
|
63896
|
+
const prefix = env2["npm_config_prefix"] ?? env2["NPM_CONFIG_PREFIX"];
|
|
63897
|
+
if (platform === "win32") {
|
|
63898
|
+
if (prefix !== void 0 && prefix.length > 0)
|
|
63899
|
+
folders.push(import_node_path31.default.join(prefix, "node_modules"));
|
|
63900
|
+
if (env2["APPDATA"] !== void 0)
|
|
63901
|
+
folders.push(import_node_path31.default.join(env2["APPDATA"], "npm", "node_modules"));
|
|
63902
|
+
} else {
|
|
63903
|
+
if (prefix !== void 0 && prefix.length > 0)
|
|
63904
|
+
folders.push(import_node_path31.default.join(prefix, "lib", "node_modules"));
|
|
63905
|
+
folders.push(import_node_path31.default.join(import_node_path31.default.dirname(import_node_path31.default.dirname(execPath)), "lib", "node_modules"));
|
|
63906
|
+
}
|
|
63907
|
+
return [...new Set(folders.map((folder) => import_node_path31.default.resolve(folder)))];
|
|
63908
|
+
}
|
|
63909
|
+
function addonServerName(pkg) {
|
|
63910
|
+
const bare = pkg.replace(/^@[^/]+\//, "").replace(/^(light-code|lightcode|fire-code)-addon-/i, "");
|
|
63911
|
+
const slug = bare.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
63912
|
+
return `addon-${slug.length > 0 ? slug : "unnamed"}`;
|
|
63913
|
+
}
|
|
63914
|
+
async function readAddon(dir) {
|
|
63915
|
+
let manifest;
|
|
63916
|
+
try {
|
|
63917
|
+
manifest = JSON.parse((await import_promises18.default.readFile(import_node_path31.default.join(dir, "package.json"), "utf8")).replace(/^\uFEFF/, ""));
|
|
63918
|
+
} catch {
|
|
63919
|
+
return void 0;
|
|
63920
|
+
}
|
|
63921
|
+
const label = manifest["lightCode"]?.["addon"];
|
|
63922
|
+
if (label === void 0)
|
|
63923
|
+
return void 0;
|
|
63924
|
+
const pkg = typeof manifest["name"] === "string" ? manifest["name"] : import_node_path31.default.basename(dir);
|
|
63925
|
+
const fail = (problem) => ({ dir, package: pkg, problem });
|
|
63926
|
+
if (label === null || typeof label !== "object" || Array.isArray(label)) {
|
|
63927
|
+
return fail('"lightCode.addon" in package.json must be an object, e.g. { "main": "server.js" }.');
|
|
63928
|
+
}
|
|
63929
|
+
const fields = label;
|
|
63930
|
+
const version2 = typeof manifest["version"] === "string" ? manifest["version"] : "0.0.0";
|
|
63931
|
+
const mainField = typeof fields["main"] === "string" ? fields["main"] : typeof manifest["main"] === "string" ? manifest["main"] : void 0;
|
|
63932
|
+
if (mainField === void 0)
|
|
63933
|
+
return fail('No server script: set "lightCode.addon.main" to the MCP server file.');
|
|
63934
|
+
const main = import_node_path31.default.resolve(dir, mainField);
|
|
63935
|
+
const relative = import_node_path31.default.relative(dir, main);
|
|
63936
|
+
if (relative.startsWith("..") || import_node_path31.default.isAbsolute(relative))
|
|
63937
|
+
return fail(`"${mainField}" is outside the package folder.`);
|
|
63938
|
+
try {
|
|
63939
|
+
if (!(await import_promises18.default.stat(main)).isFile())
|
|
63940
|
+
return fail(`${mainField} is not a file.`);
|
|
63941
|
+
} catch {
|
|
63942
|
+
return fail(`${mainField} does not exist - was the package built?`);
|
|
63943
|
+
}
|
|
63944
|
+
const args = Array.isArray(fields["args"]) ? fields["args"].filter((arg) => typeof arg === "string") : [];
|
|
63945
|
+
const displayName = typeof fields["displayName"] === "string" && fields["displayName"].trim().length > 0 ? fields["displayName"].trim() : pkg;
|
|
63946
|
+
const description = typeof fields["description"] === "string" ? fields["description"] : typeof manifest["description"] === "string" ? manifest["description"] : void 0;
|
|
63947
|
+
return {
|
|
63948
|
+
package: pkg,
|
|
63949
|
+
version: version2,
|
|
63950
|
+
displayName,
|
|
63951
|
+
...description !== void 0 ? { description } : {},
|
|
63952
|
+
dir,
|
|
63953
|
+
main,
|
|
63954
|
+
args,
|
|
63955
|
+
server: addonServerName(pkg)
|
|
63956
|
+
};
|
|
63957
|
+
}
|
|
63958
|
+
async function discoverAddons(folders) {
|
|
63959
|
+
const addons = [];
|
|
63960
|
+
const problems = [];
|
|
63961
|
+
const seen = /* @__PURE__ */ new Set();
|
|
63962
|
+
const consider = async (dir) => {
|
|
63963
|
+
const found2 = await readAddon(dir);
|
|
63964
|
+
if (found2 === void 0)
|
|
63965
|
+
return;
|
|
63966
|
+
if ("problem" in found2) {
|
|
63967
|
+
problems.push(found2);
|
|
63968
|
+
return;
|
|
63969
|
+
}
|
|
63970
|
+
if (seen.has(found2.package))
|
|
63971
|
+
return;
|
|
63972
|
+
seen.add(found2.package);
|
|
63973
|
+
addons.push(found2);
|
|
63974
|
+
};
|
|
63975
|
+
for (const folder of folders) {
|
|
63976
|
+
const before = addons.length + problems.length;
|
|
63977
|
+
await consider(folder);
|
|
63978
|
+
if (addons.length + problems.length > before)
|
|
63979
|
+
continue;
|
|
63980
|
+
let entries;
|
|
63981
|
+
try {
|
|
63982
|
+
entries = await import_promises18.default.readdir(folder);
|
|
63983
|
+
} catch {
|
|
63984
|
+
continue;
|
|
63985
|
+
}
|
|
63986
|
+
for (const entry of entries.sort()) {
|
|
63987
|
+
if (entry.startsWith("."))
|
|
63988
|
+
continue;
|
|
63989
|
+
const full = import_node_path31.default.join(folder, entry);
|
|
63990
|
+
if (entry.startsWith("@")) {
|
|
63991
|
+
let scoped;
|
|
63992
|
+
try {
|
|
63993
|
+
scoped = await import_promises18.default.readdir(full);
|
|
63994
|
+
} catch {
|
|
63995
|
+
continue;
|
|
63996
|
+
}
|
|
63997
|
+
for (const name of scoped.sort())
|
|
63998
|
+
await consider(import_node_path31.default.join(full, name));
|
|
63999
|
+
} else {
|
|
64000
|
+
await consider(full);
|
|
64001
|
+
}
|
|
64002
|
+
}
|
|
64003
|
+
}
|
|
64004
|
+
return { addons, problems };
|
|
64005
|
+
}
|
|
64006
|
+
function addonServerEntry(addon, previous) {
|
|
64007
|
+
const kept = {};
|
|
64008
|
+
if (previous !== void 0 && "command" in previous) {
|
|
64009
|
+
for (const key2 of ["env", "disabledTools", "deny", "timeout", "toolTimeouts"]) {
|
|
64010
|
+
if (previous[key2] !== void 0)
|
|
64011
|
+
kept[key2] = previous[key2];
|
|
64012
|
+
}
|
|
64013
|
+
}
|
|
64014
|
+
return {
|
|
64015
|
+
...kept,
|
|
64016
|
+
// Informative only: `runnableServers` runs the package from wherever it is installed on this
|
|
64017
|
+
// machine, with this host's own runtime, so the entry works in a settings file VS Code and
|
|
64018
|
+
// Fire Code share, and in one imported from a colleague.
|
|
64019
|
+
command: "node",
|
|
64020
|
+
args: [addon.main, ...addon.args],
|
|
64021
|
+
cwd: addon.dir,
|
|
64022
|
+
addon: { package: addon.package, version: addon.version }
|
|
64023
|
+
};
|
|
64024
|
+
}
|
|
64025
|
+
function addonState(addon, servers) {
|
|
64026
|
+
const tag = tagOf(servers[addon.server]);
|
|
64027
|
+
if (tag === void 0 || tag.package !== addon.package)
|
|
64028
|
+
return "available";
|
|
64029
|
+
return tag.version === addon.version ? "enabled" : "updated";
|
|
64030
|
+
}
|
|
64031
|
+
function missingAddons(addons, servers) {
|
|
64032
|
+
const installed = new Set(addons.map((addon) => addon.package));
|
|
64033
|
+
return Object.entries(servers).map(([server, entry]) => ({ server, tag: tagOf(entry) })).filter((row) => row.tag !== void 0 && !installed.has(row.tag.package));
|
|
64034
|
+
}
|
|
64035
|
+
function tagOf(entry) {
|
|
64036
|
+
const tag = entry?.addon;
|
|
64037
|
+
return typeof tag?.package === "string" && typeof tag.version === "string" ? { package: tag.package, version: tag.version } : void 0;
|
|
64038
|
+
}
|
|
64039
|
+
function runnableServers(servers, addons, runtime, repositoryServers = []) {
|
|
64040
|
+
const out = {};
|
|
64041
|
+
for (const [name, entry] of Object.entries(servers)) {
|
|
64042
|
+
const tag = tagOf(entry);
|
|
64043
|
+
if (tag === void 0 || !("command" in entry)) {
|
|
64044
|
+
out[name] = entry;
|
|
64045
|
+
continue;
|
|
64046
|
+
}
|
|
64047
|
+
const installed = addons.find((addon) => addon.package === tag.package);
|
|
64048
|
+
if (installed === void 0 || installed.version !== tag.version || repositoryServers.includes(name)) {
|
|
64049
|
+
out[name] = { ...entry, disabled: true };
|
|
64050
|
+
continue;
|
|
64051
|
+
}
|
|
64052
|
+
out[name] = {
|
|
64053
|
+
...entry,
|
|
64054
|
+
command: runtime.execPath,
|
|
64055
|
+
args: [installed.main, ...installed.args],
|
|
64056
|
+
cwd: installed.dir,
|
|
64057
|
+
...runtime.electron ? { env: { ...entry.env ?? {}, ELECTRON_RUN_AS_NODE: "1" } } : {}
|
|
64058
|
+
};
|
|
64059
|
+
}
|
|
64060
|
+
return out;
|
|
64061
|
+
}
|
|
64062
|
+
|
|
64063
|
+
// ../../packages/core/dist/agent/codebaseInstructions.js
|
|
64064
|
+
var import_node_crypto12 = require("node:crypto");
|
|
64065
|
+
var import_promises19 = __toESM(require("node:fs/promises"), 1);
|
|
64066
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
64067
|
+
|
|
64068
|
+
// ../../packages/core/dist/usage/events.js
|
|
64069
|
+
var import_node_crypto11 = require("node:crypto");
|
|
64070
|
+
var import_node_fs5 = require("node:fs");
|
|
64071
|
+
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
64072
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
64073
|
+
function isUsageEvent(value) {
|
|
64074
|
+
if (value === null || typeof value !== "object")
|
|
64075
|
+
return false;
|
|
64076
|
+
const event = value;
|
|
64077
|
+
return typeof event["t"] === "number" && typeof event["u"] === "string" && (event["k"] === "skill" || event["k"] === "tool") && typeof event["n"] === "string";
|
|
64078
|
+
}
|
|
64079
|
+
function parseUsageLines(text) {
|
|
64080
|
+
const events = [];
|
|
64081
|
+
for (const line of text.split(/\r?\n/)) {
|
|
64082
|
+
if (line.trim().length === 0)
|
|
64083
|
+
continue;
|
|
64084
|
+
try {
|
|
64085
|
+
const parsed = JSON.parse(line);
|
|
64086
|
+
if (isUsageEvent(parsed))
|
|
64087
|
+
events.push(parsed);
|
|
64088
|
+
} catch {
|
|
64089
|
+
}
|
|
64090
|
+
}
|
|
64091
|
+
return events;
|
|
64092
|
+
}
|
|
64093
|
+
function usageDay(t) {
|
|
64094
|
+
return new Date(t).toISOString().slice(0, 10);
|
|
64095
|
+
}
|
|
64096
|
+
function usageInstanceId(storageDir) {
|
|
64097
|
+
return (0, import_node_crypto11.createHash)("sha256").update(`${import_node_os4.default.hostname()}
|
|
64098
|
+
${import_node_path32.default.resolve(storageDir).toLowerCase()}`).digest("hex").slice(0, 12);
|
|
64099
|
+
}
|
|
64100
|
+
async function writeFileAtomically(target, text) {
|
|
64101
|
+
await import_node_fs5.promises.mkdir(import_node_path32.default.dirname(target), { recursive: true });
|
|
64102
|
+
const temporary = `${target}.${(0, import_node_crypto11.randomBytes)(6).toString("hex")}.tmp`;
|
|
64103
|
+
await import_node_fs5.promises.writeFile(temporary, text, "utf8");
|
|
64104
|
+
try {
|
|
64105
|
+
await replaceFile(temporary, target);
|
|
64106
|
+
} finally {
|
|
64107
|
+
await import_node_fs5.promises.rm(temporary, { force: true }).catch(() => void 0);
|
|
64108
|
+
}
|
|
64109
|
+
}
|
|
64110
|
+
var QUEUE_FILE = /^(\d{4}-\d{2}-\d{2})__([A-Za-z0-9-]+)\.jsonl$/;
|
|
64111
|
+
var UsageLog = class {
|
|
64112
|
+
storageDir;
|
|
64113
|
+
queueDir;
|
|
64114
|
+
manifestFile;
|
|
64115
|
+
rolledFile;
|
|
64116
|
+
legacyFile;
|
|
64117
|
+
session;
|
|
64118
|
+
constructor(storageDir, session) {
|
|
64119
|
+
this.storageDir = storageDir;
|
|
64120
|
+
this.queueDir = import_node_path32.default.join(storageDir, "usage", "queue");
|
|
64121
|
+
this.manifestFile = import_node_path32.default.join(storageDir, "usage", "pushed.json");
|
|
64122
|
+
this.rolledFile = import_node_path32.default.join(storageDir, "usage", "rolled.json");
|
|
64123
|
+
this.legacyFile = import_node_path32.default.join(storageDir, "usage-events.jsonl");
|
|
64124
|
+
this.session = session ?? (0, import_node_crypto11.randomBytes)(6).toString("hex");
|
|
64125
|
+
}
|
|
64126
|
+
async append(event) {
|
|
64127
|
+
await import_node_fs5.promises.mkdir(this.queueDir, { recursive: true });
|
|
64128
|
+
await import_node_fs5.promises.appendFile(import_node_path32.default.join(this.queueDir, `${usageDay(event.t)}__${this.session}.jsonl`), `${JSON.stringify(event)}
|
|
64129
|
+
`, "utf8");
|
|
64130
|
+
}
|
|
64131
|
+
/**
|
|
64132
|
+
* Replaces one fixed-name file of a day - the import of past conversations writes these. Replaced,
|
|
64133
|
+
* never appended, so two sessions importing at once leave one copy rather than two.
|
|
64134
|
+
*/
|
|
64135
|
+
async writeFixed(day, name, events) {
|
|
64136
|
+
await writeFileAtomically(import_node_path32.default.join(this.queueDir, `${day}__${name}.jsonl`), events.map((event) => JSON.stringify(event)).join("\n") + (events.length > 0 ? "\n" : ""));
|
|
64137
|
+
}
|
|
64138
|
+
/**
|
|
64139
|
+
* Moves a 0.156/0.157 single queue file into the per-day layout, once. Deterministic names, so two
|
|
64140
|
+
* sessions doing it at once write the same files; the old file is then renamed away by whichever
|
|
64141
|
+
* gets there first.
|
|
64142
|
+
*/
|
|
64143
|
+
async migrateLegacy() {
|
|
64144
|
+
let text;
|
|
64145
|
+
try {
|
|
64146
|
+
text = await import_node_fs5.promises.readFile(this.legacyFile, "utf8");
|
|
64147
|
+
} catch {
|
|
64148
|
+
return;
|
|
64149
|
+
}
|
|
64150
|
+
const byDay = /* @__PURE__ */ new Map();
|
|
64151
|
+
for (const event of parseUsageLines(text))
|
|
64152
|
+
byDay.set(usageDay(event.t), [...byDay.get(usageDay(event.t)) ?? [], event]);
|
|
64153
|
+
for (const [day, events] of byDay)
|
|
64154
|
+
await this.writeFixed(day, "legacy", events);
|
|
64155
|
+
await import_node_fs5.promises.rename(this.legacyFile, `${this.legacyFile}.migrated`).catch(() => void 0);
|
|
64156
|
+
await import_node_fs5.promises.rm(import_node_path32.default.join(this.storageDir, "usage-sync.json"), { force: true }).catch(() => void 0);
|
|
64157
|
+
}
|
|
64158
|
+
/** Every day with local files, and its signature. */
|
|
64159
|
+
async days() {
|
|
64160
|
+
const days = /* @__PURE__ */ new Map();
|
|
64161
|
+
let names;
|
|
64162
|
+
try {
|
|
64163
|
+
names = await import_node_fs5.promises.readdir(this.queueDir);
|
|
64164
|
+
} catch {
|
|
64165
|
+
return days;
|
|
64166
|
+
}
|
|
64167
|
+
for (const name of names) {
|
|
64168
|
+
const match = QUEUE_FILE.exec(name);
|
|
64169
|
+
if (match === null)
|
|
64170
|
+
continue;
|
|
64171
|
+
const size = await import_node_fs5.promises.stat(import_node_path32.default.join(this.queueDir, name)).then((stat) => stat.size).catch(() => void 0);
|
|
64172
|
+
if (size === void 0)
|
|
64173
|
+
continue;
|
|
64174
|
+
const entry = days.get(match[1]) ?? { files: [], signature: "" };
|
|
64175
|
+
entry.files.push({ name, size });
|
|
64176
|
+
days.set(match[1], entry);
|
|
64177
|
+
}
|
|
64178
|
+
for (const entry of days.values()) {
|
|
64179
|
+
entry.files.sort((a, b) => a.name.localeCompare(b.name));
|
|
64180
|
+
entry.signature = entry.files.map((file2) => `${file2.name}:${String(file2.size)}`).join("|");
|
|
64181
|
+
}
|
|
64182
|
+
return days;
|
|
64183
|
+
}
|
|
64184
|
+
/** The signature of one day as it is now. */
|
|
64185
|
+
async daySignature(day) {
|
|
64186
|
+
return (await this.days()).get(day)?.signature ?? "";
|
|
64187
|
+
}
|
|
64188
|
+
/** Every event of one day, from every session's file. */
|
|
64189
|
+
async readDay(day) {
|
|
64190
|
+
const entry = (await this.days()).get(day);
|
|
64191
|
+
if (entry === void 0)
|
|
64192
|
+
return [];
|
|
64193
|
+
const texts = await Promise.all(entry.files.map((file2) => import_node_fs5.promises.readFile(import_node_path32.default.join(this.queueDir, file2.name), "utf8").catch(() => "")));
|
|
64194
|
+
return texts.flatMap(parseUsageLines).sort((a, b) => a.t - b.t);
|
|
64195
|
+
}
|
|
64196
|
+
/** Every queued event (the last few weeks), for finding names worth looking up. */
|
|
64197
|
+
async all() {
|
|
64198
|
+
const days = [...(await this.days()).keys()].sort();
|
|
64199
|
+
return (await Promise.all(days.map((day) => this.readDay(day)))).flat();
|
|
64200
|
+
}
|
|
64201
|
+
/** What has been pushed to `target`, by day. A different target has had nothing pushed. */
|
|
64202
|
+
async pushed(target) {
|
|
64203
|
+
try {
|
|
64204
|
+
const saved = JSON.parse(await import_node_fs5.promises.readFile(this.manifestFile, "utf8"));
|
|
64205
|
+
return saved.target === target && saved.days !== null && typeof saved.days === "object" ? saved.days : {};
|
|
64206
|
+
} catch {
|
|
64207
|
+
return {};
|
|
64208
|
+
}
|
|
64209
|
+
}
|
|
64210
|
+
/** Records a day as pushed with the signature that was pushed. Merged with the file as it is now. */
|
|
64211
|
+
async markPushed(target, day, signature) {
|
|
64212
|
+
const days = { ...await this.pushed(target), [day]: signature };
|
|
64213
|
+
await writeFileAtomically(this.manifestFile, JSON.stringify({ target, days }));
|
|
64214
|
+
}
|
|
64215
|
+
/** Months this install has rolled up in `target` (`usage/rollup.ts`): their late days go into the month. */
|
|
64216
|
+
async rolledMonths(target) {
|
|
64217
|
+
try {
|
|
64218
|
+
const saved = JSON.parse(await import_node_fs5.promises.readFile(this.rolledFile, "utf8"));
|
|
64219
|
+
return new Set(saved.target === target && Array.isArray(saved.months) ? saved.months.filter((month) => typeof month === "string") : []);
|
|
64220
|
+
} catch {
|
|
64221
|
+
return /* @__PURE__ */ new Set();
|
|
64222
|
+
}
|
|
64223
|
+
}
|
|
64224
|
+
async markRolled(target, month) {
|
|
64225
|
+
const months = await this.rolledMonths(target);
|
|
64226
|
+
if (months.has(month))
|
|
64227
|
+
return;
|
|
64228
|
+
months.add(month);
|
|
64229
|
+
await writeFileAtomically(this.rolledFile, JSON.stringify({ target, months: [...months].sort() }));
|
|
64230
|
+
}
|
|
64231
|
+
/** Deletes whole files of days older than `keepDays` that were pushed as they are. */
|
|
64232
|
+
async prune(target, keepDays, now = Date.now()) {
|
|
64233
|
+
const cutoff = usageDay(now - keepDays * 864e5);
|
|
64234
|
+
const pushed = await this.pushed(target);
|
|
64235
|
+
let removed = 0;
|
|
64236
|
+
for (const [day, entry] of await this.days()) {
|
|
64237
|
+
if (day >= cutoff || pushed[day] !== entry.signature)
|
|
64238
|
+
continue;
|
|
64239
|
+
for (const file2 of entry.files) {
|
|
64240
|
+
await import_node_fs5.promises.rm(import_node_path32.default.join(this.queueDir, file2.name), { force: true }).catch(() => void 0);
|
|
64241
|
+
removed++;
|
|
64242
|
+
}
|
|
64243
|
+
}
|
|
64244
|
+
return removed;
|
|
64245
|
+
}
|
|
64246
|
+
};
|
|
64247
|
+
|
|
64248
|
+
// ../../packages/core/dist/agent/codebaseInstructions.js
|
|
64249
|
+
var CODEBASE_INSTRUCTIONS_FILE = "codebase-instructions.md";
|
|
64250
|
+
var CODEBASE_INSTRUCTIONS_LIMIT = 2e4;
|
|
64251
|
+
function codebaseInstructionsPath(options) {
|
|
64252
|
+
if (options.codebaseDir !== void 0)
|
|
64253
|
+
return import_node_path33.default.join(options.codebaseDir, "instructions", CODEBASE_INSTRUCTIONS_FILE);
|
|
64254
|
+
if (options.workspaceRoot === void 0)
|
|
64255
|
+
return void 0;
|
|
64256
|
+
const resolved = import_node_path33.default.resolve(options.workspaceRoot);
|
|
64257
|
+
const key2 = process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
64258
|
+
const digest = (0, import_node_crypto12.createHash)("sha256").update(key2).digest("hex").slice(0, 12);
|
|
64259
|
+
const slug = import_node_path33.default.basename(resolved).toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "workspace";
|
|
64260
|
+
return import_node_path33.default.join(options.storageDir, "codebases", `${slug}-${digest}`, CODEBASE_INSTRUCTIONS_FILE);
|
|
64261
|
+
}
|
|
64262
|
+
async function readCodebaseInstructions(file2) {
|
|
64263
|
+
if (file2 === void 0)
|
|
64264
|
+
return "";
|
|
64265
|
+
try {
|
|
64266
|
+
return (await import_promises19.default.readFile(file2, "utf8")).replace(/^\uFEFF/, "").trim();
|
|
64267
|
+
} catch {
|
|
64268
|
+
return "";
|
|
64269
|
+
}
|
|
64270
|
+
}
|
|
64271
|
+
function renderCodebaseInstructions(text) {
|
|
64272
|
+
const trimmed = text.trim();
|
|
64273
|
+
if (trimmed.length === 0)
|
|
64274
|
+
return "";
|
|
64275
|
+
const cut = trimmed.length > CODEBASE_INSTRUCTIONS_LIMIT;
|
|
64276
|
+
return [
|
|
64277
|
+
"## Codebase instructions",
|
|
64278
|
+
"",
|
|
64279
|
+
"The user wrote these for this codebase, and every chat on it receives them. They come before",
|
|
64280
|
+
"the standing instructions below: where the two disagree, follow these. What the user says in",
|
|
64281
|
+
"this conversation overrides both.",
|
|
64282
|
+
"",
|
|
64283
|
+
cut ? trimmed.slice(0, CODEBASE_INSTRUCTIONS_LIMIT) : trimmed,
|
|
64284
|
+
...cut ? ["", `(Cut at ${String(CODEBASE_INSTRUCTIONS_LIMIT)} characters. Tell the user these instructions are too long to send in full.)`] : []
|
|
64285
|
+
].join("\n");
|
|
64286
|
+
}
|
|
64287
|
+
|
|
64288
|
+
// ../../packages/core/dist/python/toolCredentials.js
|
|
64289
|
+
var import_promises20 = __toESM(require("node:fs/promises"), 1);
|
|
63851
64290
|
|
|
63852
64291
|
// ../../packages/core/dist/secrets/credentials.js
|
|
63853
64292
|
var CREDENTIAL_PREFIX = "credential:";
|
|
@@ -63890,7 +64329,7 @@ async function readToolCredential(options) {
|
|
|
63890
64329
|
throw new Error("Only an approved Python tool can read a saved credential.");
|
|
63891
64330
|
let source;
|
|
63892
64331
|
try {
|
|
63893
|
-
source = await
|
|
64332
|
+
source = await import_promises20.default.readFile(tool.filePath, "utf8");
|
|
63894
64333
|
} catch {
|
|
63895
64334
|
throw new Error(`${caller} could not be read back to check what it declares.`);
|
|
63896
64335
|
}
|
|
@@ -63917,8 +64356,8 @@ async function readToolCredential(options) {
|
|
|
63917
64356
|
}
|
|
63918
64357
|
|
|
63919
64358
|
// ../../packages/core/dist/jupyter/tools.js
|
|
63920
|
-
var
|
|
63921
|
-
var
|
|
64359
|
+
var import_promises21 = __toESM(require("node:fs/promises"), 1);
|
|
64360
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
63922
64361
|
var RUN_DEFAULT_SECONDS = 300;
|
|
63923
64362
|
var SCRIPT_PREVIEW_CHARS = 6e3;
|
|
63924
64363
|
var runSchema = external_exports.object({
|
|
@@ -63969,7 +64408,7 @@ async function plan(runtime, context, params3) {
|
|
|
63969
64408
|
].join("\n");
|
|
63970
64409
|
let script;
|
|
63971
64410
|
try {
|
|
63972
|
-
script = await
|
|
64411
|
+
script = await import_promises21.default.readFile(where.local, "utf8");
|
|
63973
64412
|
} catch {
|
|
63974
64413
|
return { ok: false, message: `${params3.file} does not exist.` };
|
|
63975
64414
|
}
|
|
@@ -64140,7 +64579,7 @@ ${pending.map((p) => `- ${p.local} (${p.kind}${p.kind === "deleted" ? " here; st
|
|
|
64140
64579
|
for (const file2 of pending.files) {
|
|
64141
64580
|
const result = await runtime.mirror.push(file2, context.signal);
|
|
64142
64581
|
failed2 ||= !result.saved;
|
|
64143
|
-
lines.push(`- ${
|
|
64582
|
+
lines.push(`- ${import_node_path34.default.relative(runtime.mirror.root, file2).split(import_node_path34.default.sep).join("/")}: ${result.message}`);
|
|
64144
64583
|
}
|
|
64145
64584
|
return { content: lines.length > 0 ? lines.join("\n") : "Nothing to save.", ...failed2 ? { isError: true } : {} };
|
|
64146
64585
|
}
|
|
@@ -64179,7 +64618,7 @@ async function pendingFor(runtime, context, target) {
|
|
|
64179
64618
|
const pending = (await runtime.mirror.pending()).filter((p) => p.kind !== "deleted");
|
|
64180
64619
|
return {
|
|
64181
64620
|
ok: true,
|
|
64182
|
-
files: pending.map((p) =>
|
|
64621
|
+
files: pending.map((p) => import_node_path34.default.join(runtime.mirror.root, ...p.local.split("/"))),
|
|
64183
64622
|
changes: pending.map((p) => `${p.local} \u2192 ${p.remote} (${p.kind})`)
|
|
64184
64623
|
};
|
|
64185
64624
|
}
|
|
@@ -64229,7 +64668,7 @@ if __SOURCE__:
|
|
|
64229
64668
|
`;
|
|
64230
64669
|
|
|
64231
64670
|
// ../../packages/core/dist/jupyter/hubGit.js
|
|
64232
|
-
var
|
|
64671
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
64233
64672
|
var MARKER = "__LC_HUBGIT__";
|
|
64234
64673
|
var LISTED = 40;
|
|
64235
64674
|
var py2 = (value) => JSON.stringify(value);
|
|
@@ -64344,7 +64783,7 @@ async function hubGitStatus(runtime, signal) {
|
|
|
64344
64783
|
total.upstream &&= one.upstream;
|
|
64345
64784
|
if (total.branch === void 0 && one.branch !== void 0)
|
|
64346
64785
|
total.branch = one.branch;
|
|
64347
|
-
const prefix = results.length > 1 ? `${
|
|
64786
|
+
const prefix = results.length > 1 ? `${import_node_path35.default.posix.basename(repo.repo)}/` : "";
|
|
64348
64787
|
for (const file2 of one.files)
|
|
64349
64788
|
if (total.files.length < LISTED)
|
|
64350
64789
|
total.files.push(`${file2.slice(0, 2)}${prefix}${file2.slice(2)}`);
|
|
@@ -64357,7 +64796,7 @@ async function hubGitCommitPush(runtime, message4, signal) {
|
|
|
64357
64796
|
return { ok: false, text: "Write a commit message first." };
|
|
64358
64797
|
const pending = await runtime.mirror.pending();
|
|
64359
64798
|
for (const change of pending.filter((p) => p.kind !== "deleted")) {
|
|
64360
|
-
const saved = await runtime.mirror.push(
|
|
64799
|
+
const saved = await runtime.mirror.push(import_node_path35.default.join(runtime.mirror.root, ...change.local.split("/")), signal);
|
|
64361
64800
|
if (!saved.saved)
|
|
64362
64801
|
return { ok: false, text: `Nothing was committed: ${change.local} could not be saved to the hub first (${saved.message}).` };
|
|
64363
64802
|
}
|
|
@@ -64370,7 +64809,7 @@ async function hubGitCommitPush(runtime, message4, signal) {
|
|
|
64370
64809
|
const lines = [];
|
|
64371
64810
|
let ok = true;
|
|
64372
64811
|
for (const repo of results) {
|
|
64373
|
-
const name = results.length > 1 ? `${
|
|
64812
|
+
const name = results.length > 1 ? `${import_node_path35.default.posix.basename(repo.repo)}: ` : "";
|
|
64374
64813
|
const committed = repo.commit?.ok === true;
|
|
64375
64814
|
const nothing = /nothing to commit/.test(`${repo.commit?.out ?? ""}${repo.commit?.err ?? ""}`);
|
|
64376
64815
|
if (repo.add?.ok !== true) {
|
|
@@ -64400,7 +64839,7 @@ async function hubGitPull(runtime, signal) {
|
|
|
64400
64839
|
const lines = [];
|
|
64401
64840
|
let ok = true;
|
|
64402
64841
|
for (const repo of results) {
|
|
64403
|
-
const name = results.length > 1 ? `${
|
|
64842
|
+
const name = results.length > 1 ? `${import_node_path35.default.posix.basename(repo.repo)}: ` : "";
|
|
64404
64843
|
const all = `${repo.pull?.out ?? ""}${repo.pull?.err ?? ""}`;
|
|
64405
64844
|
if (repo.pull?.ok === true)
|
|
64406
64845
|
lines.push(`${name}${/Already up.to.date/i.test(all) ? "Already up to date." : "Pulled on the hub."}`);
|
|
@@ -64582,7 +65021,7 @@ function pick2(hubs, name) {
|
|
|
64582
65021
|
|
|
64583
65022
|
// ../../packages/core/dist/host/bridge.js
|
|
64584
65023
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
64585
|
-
var
|
|
65024
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
64586
65025
|
|
|
64587
65026
|
// ../../packages/core/dist/modes/autoGuidance.js
|
|
64588
65027
|
function idiomsFor(environment) {
|
|
@@ -64677,14 +65116,14 @@ function buildAutoGuidance(environment) {
|
|
|
64677
65116
|
}
|
|
64678
65117
|
|
|
64679
65118
|
// ../../packages/core/dist/migrate/folders.js
|
|
64680
|
-
var
|
|
64681
|
-
var
|
|
65119
|
+
var import_promises22 = __toESM(require("node:fs/promises"), 1);
|
|
65120
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
64682
65121
|
function nameOf(entry, kind) {
|
|
64683
65122
|
return kind === "skills" ? entry.replace(/\.md$/i, "") : entry.replace(/\.py$/i, "");
|
|
64684
65123
|
}
|
|
64685
65124
|
async function isDirectory(candidate) {
|
|
64686
65125
|
try {
|
|
64687
|
-
return (await
|
|
65126
|
+
return (await import_promises22.default.stat(candidate)).isDirectory();
|
|
64688
65127
|
} catch {
|
|
64689
65128
|
return false;
|
|
64690
65129
|
}
|
|
@@ -64693,7 +65132,7 @@ async function namesAt(dir, kind) {
|
|
|
64693
65132
|
const found2 = /* @__PURE__ */ new Set();
|
|
64694
65133
|
let entries;
|
|
64695
65134
|
try {
|
|
64696
|
-
entries = await
|
|
65135
|
+
entries = await import_promises22.default.readdir(dir);
|
|
64697
65136
|
} catch {
|
|
64698
65137
|
return found2;
|
|
64699
65138
|
}
|
|
@@ -64703,7 +65142,7 @@ async function namesAt(dir, kind) {
|
|
|
64703
65142
|
if (kind === "skills") {
|
|
64704
65143
|
if (entry.toLowerCase().endsWith(".md"))
|
|
64705
65144
|
found2.add(nameOf(entry, kind));
|
|
64706
|
-
else if (await isDirectory(
|
|
65145
|
+
else if (await isDirectory(import_node_path36.default.join(dir, entry)))
|
|
64707
65146
|
found2.add(entry);
|
|
64708
65147
|
} else if (entry.toLowerCase().endsWith(".py")) {
|
|
64709
65148
|
found2.add(nameOf(entry, kind));
|
|
@@ -64715,26 +65154,26 @@ async function planMigration(options) {
|
|
|
64715
65154
|
const { from, to, kind } = options;
|
|
64716
65155
|
const copy = [];
|
|
64717
65156
|
const skip = [];
|
|
64718
|
-
if (
|
|
65157
|
+
if (import_node_path36.default.resolve(from) === import_node_path36.default.resolve(to))
|
|
64719
65158
|
return { copy, skip };
|
|
64720
65159
|
const existing = await namesAt(to, kind);
|
|
64721
65160
|
let entries;
|
|
64722
65161
|
try {
|
|
64723
|
-
entries = await
|
|
65162
|
+
entries = await import_promises22.default.readdir(from);
|
|
64724
65163
|
} catch {
|
|
64725
65164
|
return { copy, skip };
|
|
64726
65165
|
}
|
|
64727
65166
|
for (const entry of entries) {
|
|
64728
65167
|
if (entry.startsWith("."))
|
|
64729
65168
|
continue;
|
|
64730
|
-
const source =
|
|
65169
|
+
const source = import_node_path36.default.join(from, entry);
|
|
64731
65170
|
const directory = await isDirectory(source);
|
|
64732
65171
|
if (kind === "skills") {
|
|
64733
65172
|
if (!directory && !entry.toLowerCase().endsWith(".md"))
|
|
64734
65173
|
continue;
|
|
64735
65174
|
if (directory) {
|
|
64736
65175
|
try {
|
|
64737
|
-
await
|
|
65176
|
+
await import_promises22.default.stat(import_node_path36.default.join(source, "SKILL.md"));
|
|
64738
65177
|
} catch {
|
|
64739
65178
|
continue;
|
|
64740
65179
|
}
|
|
@@ -64747,7 +65186,7 @@ async function planMigration(options) {
|
|
|
64747
65186
|
skip.push(name);
|
|
64748
65187
|
continue;
|
|
64749
65188
|
}
|
|
64750
|
-
copy.push({ name, source, destination:
|
|
65189
|
+
copy.push({ name, source, destination: import_node_path36.default.join(to, entry), directory });
|
|
64751
65190
|
}
|
|
64752
65191
|
copy.sort((a, b) => a.name.localeCompare(b.name));
|
|
64753
65192
|
skip.sort();
|
|
@@ -64758,8 +65197,8 @@ async function runMigration(plan2) {
|
|
|
64758
65197
|
const failed2 = [];
|
|
64759
65198
|
for (const item of plan2.copy) {
|
|
64760
65199
|
try {
|
|
64761
|
-
await
|
|
64762
|
-
await
|
|
65200
|
+
await import_promises22.default.mkdir(import_node_path36.default.dirname(item.destination), { recursive: true });
|
|
65201
|
+
await import_promises22.default.cp(item.source, item.destination, {
|
|
64763
65202
|
recursive: item.directory,
|
|
64764
65203
|
force: false,
|
|
64765
65204
|
errorOnExist: true
|
|
@@ -64784,8 +65223,8 @@ function describeMigration(result, kind) {
|
|
|
64784
65223
|
}
|
|
64785
65224
|
|
|
64786
65225
|
// ../../packages/core/dist/platform/node/shell.js
|
|
64787
|
-
var
|
|
64788
|
-
var
|
|
65226
|
+
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
65227
|
+
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
64789
65228
|
function windowsExtensions(env2) {
|
|
64790
65229
|
const raw = env2["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
|
|
64791
65230
|
return raw.split(";").filter((entry) => entry.length > 0);
|
|
@@ -64799,8 +65238,8 @@ function onPath(name, env2 = process.env) {
|
|
|
64799
65238
|
continue;
|
|
64800
65239
|
for (const extension of extensions) {
|
|
64801
65240
|
try {
|
|
64802
|
-
const candidate =
|
|
64803
|
-
if (
|
|
65241
|
+
const candidate = import_node_path37.default.join(directory, name + extension);
|
|
65242
|
+
if (import_node_fs6.default.statSync(candidate).isFile())
|
|
64804
65243
|
return true;
|
|
64805
65244
|
} catch {
|
|
64806
65245
|
continue;
|
|
@@ -64821,7 +65260,7 @@ function resolveShell(configured, env2 = process.env) {
|
|
|
64821
65260
|
return { command: void 0, kind: "posix", label: env2["SHELL"] ?? "/bin/sh" };
|
|
64822
65261
|
}
|
|
64823
65262
|
function kindOf(command) {
|
|
64824
|
-
const base =
|
|
65263
|
+
const base = import_node_path37.default.basename(command).toLowerCase().replace(/\.exe$/, "");
|
|
64825
65264
|
if (base === "pwsh")
|
|
64826
65265
|
return "pwsh";
|
|
64827
65266
|
if (base === "powershell")
|
|
@@ -64831,7 +65270,7 @@ function kindOf(command) {
|
|
|
64831
65270
|
return "posix";
|
|
64832
65271
|
}
|
|
64833
65272
|
function labelFor(command) {
|
|
64834
|
-
const base =
|
|
65273
|
+
const base = import_node_path37.default.basename(command).toLowerCase().replace(/\.exe$/, "");
|
|
64835
65274
|
if (base === "pwsh")
|
|
64836
65275
|
return "PowerShell 7 (pwsh)";
|
|
64837
65276
|
if (base === "powershell")
|
|
@@ -64913,7 +65352,7 @@ function fastFsCapabilities(exe, timeoutMs = 5e3) {
|
|
|
64913
65352
|
var import_node_child_process9 = require("node:child_process");
|
|
64914
65353
|
|
|
64915
65354
|
// ../../packages/core/dist/tools/readStamps.js
|
|
64916
|
-
var
|
|
65355
|
+
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
64917
65356
|
async function stamp(context, realPath) {
|
|
64918
65357
|
try {
|
|
64919
65358
|
const s = await context.fs.stat(realPath);
|
|
@@ -64958,14 +65397,14 @@ async function staleFilesNamedIn(context, command) {
|
|
|
64958
65397
|
};
|
|
64959
65398
|
const stale = [];
|
|
64960
65399
|
for (const [key2, known] of context.readStamps) {
|
|
64961
|
-
const relative =
|
|
64962
|
-
const names = [key2, relative, relative.split(
|
|
65400
|
+
const relative = import_node_path38.default.relative(root, key2);
|
|
65401
|
+
const names = [key2, relative, relative.split(import_node_path38.default.sep).join("/"), import_node_path38.default.basename(key2)].map((n) => n.toLowerCase());
|
|
64963
65402
|
if (!names.some(stands))
|
|
64964
65403
|
continue;
|
|
64965
65404
|
try {
|
|
64966
65405
|
const s = await context.fs.stat(key2);
|
|
64967
65406
|
if (`${String(s.mtimeMs)}:${String(s.size)}` !== known)
|
|
64968
|
-
stale.push(relative.split(
|
|
65407
|
+
stale.push(relative.split(import_node_path38.default.sep).join("/"));
|
|
64969
65408
|
} catch {
|
|
64970
65409
|
}
|
|
64971
65410
|
}
|
|
@@ -66437,7 +66876,7 @@ function composeHandoff(note, facts, previousTitle) {
|
|
|
66437
66876
|
}
|
|
66438
66877
|
|
|
66439
66878
|
// ../../packages/core/dist/checkpoints/changeLedger.js
|
|
66440
|
-
var
|
|
66879
|
+
var import_promises23 = require("node:fs/promises");
|
|
66441
66880
|
var ChangeLedger = class {
|
|
66442
66881
|
file;
|
|
66443
66882
|
chat;
|
|
@@ -66446,16 +66885,16 @@ var ChangeLedger = class {
|
|
|
66446
66885
|
this.chat = chat;
|
|
66447
66886
|
}
|
|
66448
66887
|
/** Best effort: a ledger that cannot be written must never fail an edit that happened. */
|
|
66449
|
-
record(
|
|
66450
|
-
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(
|
|
66451
|
-
void (0,
|
|
66888
|
+
record(path60) {
|
|
66889
|
+
const line = JSON.stringify({ chat: this.chat, path: normalizeForComparison(path60), at: Date.now() });
|
|
66890
|
+
void (0, import_promises23.appendFile)(this.file, `${line}
|
|
66452
66891
|
`).catch(() => void 0);
|
|
66453
66892
|
}
|
|
66454
66893
|
/** For each of `paths`, the other chats that changed it after `since`. */
|
|
66455
66894
|
async othersSince(paths, since2) {
|
|
66456
66895
|
const wanted = new Map(paths.map((p) => [normalizeForComparison(p), p]));
|
|
66457
66896
|
const found2 = /* @__PURE__ */ new Map();
|
|
66458
|
-
const text = await (0,
|
|
66897
|
+
const text = await (0, import_promises23.readFile)(this.file, "utf8").catch(() => void 0);
|
|
66459
66898
|
if (text === void 0)
|
|
66460
66899
|
return found2;
|
|
66461
66900
|
for (const line of text.split("\n")) {
|
|
@@ -66494,8 +66933,8 @@ var RecordedChanges = class extends Set {
|
|
|
66494
66933
|
|
|
66495
66934
|
// ../../packages/core/dist/office/bridge.js
|
|
66496
66935
|
var import_node_child_process11 = require("node:child_process");
|
|
66497
|
-
var
|
|
66498
|
-
var
|
|
66936
|
+
var import_promises24 = __toESM(require("node:fs/promises"), 1);
|
|
66937
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
66499
66938
|
|
|
66500
66939
|
// ../../packages/core/dist/office/workerSource.js
|
|
66501
66940
|
var OFFICE_WORKER_SOURCE = `# Light Code office worker.
|
|
@@ -69229,10 +69668,10 @@ var OfficeBridge = class {
|
|
|
69229
69668
|
return this.starting;
|
|
69230
69669
|
}
|
|
69231
69670
|
async start() {
|
|
69232
|
-
const target =
|
|
69233
|
-
await
|
|
69671
|
+
const target = import_node_path39.default.join(this.options.storageDir, "office-worker.ps1");
|
|
69672
|
+
await import_promises24.default.mkdir(this.options.storageDir, { recursive: true });
|
|
69234
69673
|
const BOM = "\uFEFF";
|
|
69235
|
-
await
|
|
69674
|
+
await import_promises24.default.writeFile(target, `${BOM}${OFFICE_WORKER_SOURCE}`, "utf8");
|
|
69236
69675
|
this.scriptPath = target;
|
|
69237
69676
|
const child = (0, import_node_child_process11.spawn)(
|
|
69238
69677
|
"powershell.exe",
|
|
@@ -69295,7 +69734,7 @@ var OfficeBridge = class {
|
|
|
69295
69734
|
child?.stdin?.end();
|
|
69296
69735
|
child?.kill();
|
|
69297
69736
|
if (this.scriptPath !== void 0) {
|
|
69298
|
-
await
|
|
69737
|
+
await import_promises24.default.rm(this.scriptPath, { force: true }).catch(() => void 0);
|
|
69299
69738
|
}
|
|
69300
69739
|
}
|
|
69301
69740
|
};
|
|
@@ -69735,8 +70174,8 @@ function createDeleteRoleTool(access) {
|
|
|
69735
70174
|
}
|
|
69736
70175
|
|
|
69737
70176
|
// ../../packages/core/dist/rag/indexNaming.js
|
|
69738
|
-
var
|
|
69739
|
-
var
|
|
70177
|
+
var import_node_crypto13 = __toESM(require("node:crypto"), 1);
|
|
70178
|
+
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
69740
70179
|
var DEFAULT_INDEX_PREFIX = "light-code";
|
|
69741
70180
|
var DOMAIN_OR_PATH = /[\\/]/;
|
|
69742
70181
|
function normaliseOwner(owner) {
|
|
@@ -69751,15 +70190,15 @@ function ownerSlug(owner) {
|
|
|
69751
70190
|
function deriveIndexName(input) {
|
|
69752
70191
|
const prefix = input.prefix ?? DEFAULT_INDEX_PREFIX;
|
|
69753
70192
|
const slug = ownerSlug(input.owner);
|
|
69754
|
-
const root =
|
|
70193
|
+
const root = import_node_path40.default.resolve(input.workspaceRoot).toLowerCase();
|
|
69755
70194
|
const identity = input.owner === void 0 ? "" : normaliseOwner(input.owner);
|
|
69756
|
-
const digest =
|
|
70195
|
+
const digest = import_node_crypto13.default.createHash("sha256").update(`${identity}\0${root}`).digest("hex").slice(0, 16);
|
|
69757
70196
|
const base = slug === void 0 ? `${prefix}-${digest}` : `${prefix}-${slug}-${digest}`;
|
|
69758
70197
|
return input.project === void 0 ? base : `${input.project}-${base}`;
|
|
69759
70198
|
}
|
|
69760
70199
|
|
|
69761
70200
|
// ../../packages/core/dist/tools/exportConfig.js
|
|
69762
|
-
var
|
|
70201
|
+
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
69763
70202
|
var sectionIds = SHARE_SECTIONS.map((section) => section.id);
|
|
69764
70203
|
var paramsSchema11 = external_exports.object({
|
|
69765
70204
|
path: external_exports.string().min(1).describe('Where to write it in the workspace, e.g. "onboarding/light-code-team.json".'),
|
|
@@ -69799,7 +70238,7 @@ function createExportConfigTool(options) {
|
|
|
69799
70238
|
if (!resolved.ok)
|
|
69800
70239
|
return { content: resolved.message, isError: true };
|
|
69801
70240
|
const { json: json2, notes } = prepare(await options.loadConfig(), params3);
|
|
69802
|
-
await context.fs.mkdir(
|
|
70241
|
+
await context.fs.mkdir(import_node_path41.default.dirname(resolved.realPath));
|
|
69803
70242
|
await context.fs.writeFile(resolved.realPath, json2);
|
|
69804
70243
|
return { content: `Wrote ${params3.path}. ${notes}`, path: resolved.realPath };
|
|
69805
70244
|
}
|
|
@@ -69968,7 +70407,7 @@ function describeAtlassianFailure(product, doing, status2, body) {
|
|
|
69968
70407
|
}
|
|
69969
70408
|
|
|
69970
70409
|
// ../../packages/core/dist/atlassian/uploads.js
|
|
69971
|
-
var
|
|
70410
|
+
var import_node_path42 = __toESM(require("node:path"), 1);
|
|
69972
70411
|
|
|
69973
70412
|
// ../../packages/core/dist/diagrams/layout.js
|
|
69974
70413
|
var NODE_HEIGHT = 52;
|
|
@@ -70610,7 +71049,7 @@ async function prepareUploads(params3, context) {
|
|
|
70610
71049
|
const resolved = await resolveToolPath(context, attachment.path);
|
|
70611
71050
|
if (!resolved.ok)
|
|
70612
71051
|
return { ok: false, message: resolved.message };
|
|
70613
|
-
const name = attachment.name ??
|
|
71052
|
+
const name = attachment.name ?? import_node_path42.default.basename(resolved.realPath);
|
|
70614
71053
|
const problem = claim(name);
|
|
70615
71054
|
if (problem !== void 0)
|
|
70616
71055
|
return { ok: false, message: problem };
|
|
@@ -70794,10 +71233,10 @@ function isSafeSegment(value) {
|
|
|
70794
71233
|
function isSafeTagName(name) {
|
|
70795
71234
|
return /^[A-Za-z0-9._/-]+$/.test(name) && !name.startsWith("-") && !name.startsWith("/") && !name.endsWith("/") && !name.endsWith(".") && !name.endsWith(".lock") && !name.includes("..") && !name.includes("//") && !name.split("/").some((part) => part.startsWith("."));
|
|
70796
71235
|
}
|
|
70797
|
-
function encodeRepoPath(
|
|
70798
|
-
const segments =
|
|
71236
|
+
function encodeRepoPath(path60) {
|
|
71237
|
+
const segments = path60.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0);
|
|
70799
71238
|
if (segments.length === 0 || segments.some((segment) => segment === ".." || segment === ".")) {
|
|
70800
|
-
throw new AtlassianError(`"${
|
|
71239
|
+
throw new AtlassianError(`"${path60}" is not a file path inside the repository.`);
|
|
70801
71240
|
}
|
|
70802
71241
|
return segments.map(encodeURIComponent).join("/");
|
|
70803
71242
|
}
|
|
@@ -70882,24 +71321,24 @@ var BitbucketClient = class {
|
|
|
70882
71321
|
* redirect was followed, the login page came back, and the file "could not be read" although
|
|
70883
71322
|
* pull requests on the same repository could. `browse` is REST, so it authenticates like those.
|
|
70884
71323
|
*/
|
|
70885
|
-
async file(repo,
|
|
70886
|
-
const target = encodeRepoPath(
|
|
71324
|
+
async file(repo, path60, ref, signal) {
|
|
71325
|
+
const target = encodeRepoPath(path60);
|
|
70887
71326
|
const lines = [];
|
|
70888
71327
|
let start = 0;
|
|
70889
71328
|
for (let page = 0; page < MAX_FILE_PAGES; page += 1) {
|
|
70890
71329
|
const query = new URLSearchParams({ start: String(start), limit: String(FILE_PAGE_LINES) });
|
|
70891
71330
|
if (ref !== void 0 && ref.length > 0)
|
|
70892
71331
|
query.set("at", ref);
|
|
70893
|
-
const body = await this.rest.json(`reading ${
|
|
71332
|
+
const body = await this.rest.json(`reading ${path60}`, `${this.repoPath(repo)}/browse/${target}?${query.toString()}`, { method: "GET" }, signal);
|
|
70894
71333
|
if (body.children !== void 0) {
|
|
70895
71334
|
const names = (body.children.values ?? []).map((child) => {
|
|
70896
71335
|
const name = child.path?.toString ?? child.path?.name ?? "?";
|
|
70897
71336
|
return child.type === "DIRECTORY" ? `${name}/` : name;
|
|
70898
71337
|
});
|
|
70899
|
-
throw new AtlassianError(`${
|
|
71338
|
+
throw new AtlassianError(`${path60} is a folder, not a file. It holds: ${names.join(", ") || "nothing"}.`);
|
|
70900
71339
|
}
|
|
70901
71340
|
if (body.binary === true)
|
|
70902
|
-
throw new AtlassianError(`${
|
|
71341
|
+
throw new AtlassianError(`${path60} is a binary file, so there is no text to read.`);
|
|
70903
71342
|
for (const line of body.lines ?? [])
|
|
70904
71343
|
lines.push(line.text ?? "");
|
|
70905
71344
|
if (body.isLastPage !== false || body.nextPageStart === void 0 || body.nextPageStart <= start)
|
|
@@ -71477,8 +71916,8 @@ ${text.slice(-2e4)}`);
|
|
|
71477
71916
|
}
|
|
71478
71917
|
/** Queues a build, then follows the queue item briefly to learn its number. */
|
|
71479
71918
|
async startBuild(job, parameters, signal) {
|
|
71480
|
-
const
|
|
71481
|
-
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${
|
|
71919
|
+
const path60 = jobPath(job, this.base);
|
|
71920
|
+
const response = await this.post(`starting ${job}`, parameters !== void 0 && Object.keys(parameters).length > 0 ? `${path60}/buildWithParameters` : `${path60}/build`, parameters ?? {}, signal);
|
|
71482
71921
|
const location = response.headers["location"];
|
|
71483
71922
|
const queueId = location === void 0 ? void 0 : /\/queue\/item\/(\d+)/.exec(location)?.[1];
|
|
71484
71923
|
if (queueId === void 0)
|
|
@@ -71804,14 +72243,14 @@ ${client.base}${jobPath(job, client.base)}/${buildRef(params3.build)}/`
|
|
|
71804
72243
|
};
|
|
71805
72244
|
return tool;
|
|
71806
72245
|
}
|
|
71807
|
-
async function readJenkinsfile(
|
|
71808
|
-
const resolved = await resolveToolPath(context,
|
|
72246
|
+
async function readJenkinsfile(path60, context) {
|
|
72247
|
+
const resolved = await resolveToolPath(context, path60);
|
|
71809
72248
|
if (!resolved.ok)
|
|
71810
72249
|
return { ok: false, message: resolved.message };
|
|
71811
72250
|
try {
|
|
71812
72251
|
return { ok: true, text: await context.fs.readFile(resolved.realPath), realPath: resolved.realPath };
|
|
71813
72252
|
} catch (error51) {
|
|
71814
|
-
return { ok: false, message: `Could not read ${
|
|
72253
|
+
return { ok: false, message: `Could not read ${path60}: ${error51 instanceof Error ? error51.message : String(error51)}` };
|
|
71815
72254
|
}
|
|
71816
72255
|
}
|
|
71817
72256
|
var checkSchema = external_exports.object({
|
|
@@ -72080,8 +72519,8 @@ var AutosysClient = class {
|
|
|
72080
72519
|
async runInfo(pattern, signal) {
|
|
72081
72520
|
if (!isAutosysName(pattern, true))
|
|
72082
72521
|
throw new AtlassianError(`"${pattern}" is not a job name or pattern.`);
|
|
72083
|
-
const
|
|
72084
|
-
return asList(await this.rest.json(`reading the status of ${pattern}`,
|
|
72522
|
+
const path60 = pattern.includes("*") ? fill(this.paths.runInfo, { pattern }) : fill(this.paths.jobRunInfo, { job: pattern });
|
|
72523
|
+
return asList(await this.rest.json(`reading the status of ${pattern}`, path60, { method: "GET" }, signal)).map(toRun);
|
|
72085
72524
|
}
|
|
72086
72525
|
/** A job's log, or undefined when this server has no log endpoint (404). */
|
|
72087
72526
|
async log(name, runNum, type, signal) {
|
|
@@ -74082,7 +74521,7 @@ function message2(error51) {
|
|
|
74082
74521
|
}
|
|
74083
74522
|
function filesIn(params3) {
|
|
74084
74523
|
return [
|
|
74085
|
-
...(params3.attachments ?? []).map((
|
|
74524
|
+
...(params3.attachments ?? []).map((path60) => ({ path: path60, inline: false })),
|
|
74086
74525
|
...(params3.inlineImages ?? []).map((image) => ({ path: image.path, inline: true }))
|
|
74087
74526
|
];
|
|
74088
74527
|
}
|
|
@@ -74763,19 +75202,19 @@ var WebviewApprovalGate = class {
|
|
|
74763
75202
|
};
|
|
74764
75203
|
|
|
74765
75204
|
// ../../packages/core/dist/platform/node/filesystem.js
|
|
74766
|
-
var
|
|
75205
|
+
var import_promises25 = __toESM(require("node:fs/promises"), 1);
|
|
74767
75206
|
var NodeFileSystem = class {
|
|
74768
|
-
async readFile(
|
|
74769
|
-
return
|
|
75207
|
+
async readFile(path60) {
|
|
75208
|
+
return import_promises25.default.readFile(path60, "utf8");
|
|
74770
75209
|
}
|
|
74771
|
-
async readBytes(
|
|
74772
|
-
return
|
|
75210
|
+
async readBytes(path60) {
|
|
75211
|
+
return import_promises25.default.readFile(path60);
|
|
74773
75212
|
}
|
|
74774
|
-
async readBytesSlice(
|
|
75213
|
+
async readBytesSlice(path60, start, end) {
|
|
74775
75214
|
const length = Math.max(0, end - start);
|
|
74776
75215
|
if (length === 0)
|
|
74777
75216
|
return Buffer.alloc(0);
|
|
74778
|
-
const handle = await
|
|
75217
|
+
const handle = await import_promises25.default.open(path60, "r");
|
|
74779
75218
|
try {
|
|
74780
75219
|
const buffer = Buffer.alloc(length);
|
|
74781
75220
|
const { bytesRead } = await handle.read(buffer, 0, length, start);
|
|
@@ -74784,18 +75223,18 @@ var NodeFileSystem = class {
|
|
|
74784
75223
|
await handle.close();
|
|
74785
75224
|
}
|
|
74786
75225
|
}
|
|
74787
|
-
async writeFile(
|
|
74788
|
-
await
|
|
75226
|
+
async writeFile(path60, contents) {
|
|
75227
|
+
await import_promises25.default.writeFile(path60, contents, "utf8");
|
|
74789
75228
|
}
|
|
74790
75229
|
/** The counterpart of `readBytes`, and deliberately as bare as `writeFile` beside it. */
|
|
74791
|
-
async writeBytes(
|
|
74792
|
-
await
|
|
75230
|
+
async writeBytes(path60, contents) {
|
|
75231
|
+
await import_promises25.default.writeFile(path60, contents);
|
|
74793
75232
|
}
|
|
74794
75233
|
async rename(from, to) {
|
|
74795
75234
|
await replaceFile(from, to);
|
|
74796
75235
|
}
|
|
74797
|
-
async stat(
|
|
74798
|
-
const stat = await
|
|
75236
|
+
async stat(path60) {
|
|
75237
|
+
const stat = await import_promises25.default.lstat(path60);
|
|
74799
75238
|
return {
|
|
74800
75239
|
size: stat.size,
|
|
74801
75240
|
mtimeMs: stat.mtimeMs,
|
|
@@ -74804,8 +75243,8 @@ var NodeFileSystem = class {
|
|
|
74804
75243
|
isSymbolicLink: stat.isSymbolicLink()
|
|
74805
75244
|
};
|
|
74806
75245
|
}
|
|
74807
|
-
async readdir(
|
|
74808
|
-
const entries = await
|
|
75246
|
+
async readdir(path60) {
|
|
75247
|
+
const entries = await import_promises25.default.readdir(path60, { withFileTypes: true });
|
|
74809
75248
|
return entries.map((entry) => ({
|
|
74810
75249
|
name: entry.name,
|
|
74811
75250
|
isFile: entry.isFile(),
|
|
@@ -74813,21 +75252,21 @@ var NodeFileSystem = class {
|
|
|
74813
75252
|
isSymbolicLink: entry.isSymbolicLink()
|
|
74814
75253
|
}));
|
|
74815
75254
|
}
|
|
74816
|
-
async exists(
|
|
75255
|
+
async exists(path60) {
|
|
74817
75256
|
try {
|
|
74818
|
-
await
|
|
75257
|
+
await import_promises25.default.access(path60);
|
|
74819
75258
|
return true;
|
|
74820
75259
|
} catch {
|
|
74821
75260
|
return false;
|
|
74822
75261
|
}
|
|
74823
75262
|
}
|
|
74824
|
-
async mkdir(
|
|
74825
|
-
await
|
|
75263
|
+
async mkdir(path60) {
|
|
75264
|
+
await import_promises25.default.mkdir(path60, { recursive: true });
|
|
74826
75265
|
}
|
|
74827
75266
|
};
|
|
74828
75267
|
|
|
74829
75268
|
// ../../packages/core/dist/config/project.js
|
|
74830
|
-
var
|
|
75269
|
+
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
74831
75270
|
function configuredProjectName(config2) {
|
|
74832
75271
|
const name = config2?.project?.name?.trim();
|
|
74833
75272
|
return name !== void 0 && name.length > 0 ? name : void 0;
|
|
@@ -74836,7 +75275,7 @@ function projectName(config2, workspaceRoot) {
|
|
|
74836
75275
|
const configured = configuredProjectName(config2);
|
|
74837
75276
|
if (configured !== void 0)
|
|
74838
75277
|
return configured;
|
|
74839
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
75278
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path43.default.basename(import_node_path43.default.resolve(workspaceRoot));
|
|
74840
75279
|
}
|
|
74841
75280
|
function projectSlug(name) {
|
|
74842
75281
|
if (name === void 0)
|
|
@@ -74846,8 +75285,8 @@ function projectSlug(name) {
|
|
|
74846
75285
|
}
|
|
74847
75286
|
|
|
74848
75287
|
// ../../packages/core/dist/rag/renameIndexes.js
|
|
74849
|
-
var
|
|
74850
|
-
var
|
|
75288
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
75289
|
+
var import_node_fs7 = require("node:fs");
|
|
74851
75290
|
function planIndexRenames(names) {
|
|
74852
75291
|
const plans = [];
|
|
74853
75292
|
for (const kind of ["codebase", "docs", "skills"]) {
|
|
@@ -74899,7 +75338,7 @@ async function copyIndex(options) {
|
|
|
74899
75338
|
async function copyBookkeeping(directory, from, to, storeId) {
|
|
74900
75339
|
let entries;
|
|
74901
75340
|
try {
|
|
74902
|
-
entries = await
|
|
75341
|
+
entries = await import_node_fs7.promises.readdir(directory);
|
|
74903
75342
|
} catch {
|
|
74904
75343
|
return [];
|
|
74905
75344
|
}
|
|
@@ -74910,7 +75349,7 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
74910
75349
|
continue;
|
|
74911
75350
|
const target = `${to}@${storeId}.${entry.slice(prefix.length)}`;
|
|
74912
75351
|
try {
|
|
74913
|
-
await
|
|
75352
|
+
await import_node_fs7.promises.copyFile(import_node_path44.default.join(directory, entry), import_node_path44.default.join(directory, target), import_node_fs7.constants.COPYFILE_EXCL);
|
|
74914
75353
|
copied.push(target);
|
|
74915
75354
|
} catch {
|
|
74916
75355
|
}
|
|
@@ -74919,8 +75358,8 @@ async function copyBookkeeping(directory, from, to, storeId) {
|
|
|
74919
75358
|
}
|
|
74920
75359
|
|
|
74921
75360
|
// ../../packages/core/dist/tools/nativeSearch.js
|
|
74922
|
-
var
|
|
74923
|
-
var
|
|
75361
|
+
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
75362
|
+
var import_node_path45 = __toESM(require("node:path"), 1);
|
|
74924
75363
|
var ALWAYS_SKIPPED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
74925
75364
|
var DEFAULT_MAX_FILES = 5e4;
|
|
74926
75365
|
var caseFlag = process.platform === "win32" ? "i" : "";
|
|
@@ -75019,40 +75458,40 @@ function isIgnored(rules, relative, isDirectory2) {
|
|
|
75019
75458
|
}
|
|
75020
75459
|
return ignored;
|
|
75021
75460
|
}
|
|
75022
|
-
async function repositoryWideRules(
|
|
75461
|
+
async function repositoryWideRules(fs41, root, globalIgnoreFile) {
|
|
75023
75462
|
const sources = [
|
|
75024
|
-
globalIgnoreFile ??
|
|
75025
|
-
|
|
75463
|
+
globalIgnoreFile ?? import_node_path45.default.join(process.env["XDG_CONFIG_HOME"] ?? import_node_path45.default.join(import_node_os5.default.homedir(), ".config"), "git", "ignore"),
|
|
75464
|
+
import_node_path45.default.join(root, ".git", "info", "exclude")
|
|
75026
75465
|
];
|
|
75027
75466
|
const rules = [];
|
|
75028
75467
|
for (const source of sources) {
|
|
75029
75468
|
try {
|
|
75030
|
-
rules.push(...parseIgnoreFile(await
|
|
75469
|
+
rules.push(...parseIgnoreFile(await fs41.readFile(source), ""));
|
|
75031
75470
|
} catch {
|
|
75032
75471
|
}
|
|
75033
75472
|
}
|
|
75034
75473
|
return rules;
|
|
75035
75474
|
}
|
|
75036
|
-
async function walkFiles(
|
|
75475
|
+
async function walkFiles(fs41, root, options) {
|
|
75037
75476
|
const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
|
|
75038
75477
|
const files = [];
|
|
75039
|
-
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(
|
|
75478
|
+
const baseRules = options.includeIgnored ? [] : await repositoryWideRules(fs41, root, options.globalIgnoreFile);
|
|
75040
75479
|
const pending = [{ relative: "", rules: baseRules }];
|
|
75041
75480
|
while (pending.length > 0) {
|
|
75042
75481
|
if (options.signal?.aborted === true)
|
|
75043
75482
|
break;
|
|
75044
75483
|
const { relative, rules: inherited } = pending.pop();
|
|
75045
|
-
const absolute = relative.length > 0 ?
|
|
75484
|
+
const absolute = relative.length > 0 ? import_node_path45.default.join(root, ...relative.split("/")) : root;
|
|
75046
75485
|
let entries;
|
|
75047
75486
|
try {
|
|
75048
|
-
entries = await
|
|
75487
|
+
entries = await fs41.readdir(absolute);
|
|
75049
75488
|
} catch {
|
|
75050
75489
|
continue;
|
|
75051
75490
|
}
|
|
75052
75491
|
let rules = inherited;
|
|
75053
75492
|
if (!options.includeIgnored && entries.some((entry) => entry.name === ".gitignore" && !entry.isDirectory)) {
|
|
75054
75493
|
try {
|
|
75055
|
-
const text = await
|
|
75494
|
+
const text = await fs41.readFile(import_node_path45.default.join(absolute, ".gitignore"));
|
|
75056
75495
|
rules = [...inherited, ...parseIgnoreFile(text, relative)];
|
|
75057
75496
|
} catch {
|
|
75058
75497
|
}
|
|
@@ -75114,12 +75553,12 @@ function fileFilter(filePattern) {
|
|
|
75114
75553
|
const regex = globToRegExp(glob.startsWith("/") ? glob.slice(1) : glob, anchored);
|
|
75115
75554
|
return (relative) => regex.test(relative) !== exclude;
|
|
75116
75555
|
}
|
|
75117
|
-
async function searchFiles(
|
|
75556
|
+
async function searchFiles(fs41, root, options) {
|
|
75118
75557
|
const regex = compilePattern(options.pattern);
|
|
75119
75558
|
const admits = fileFilter(options.filePattern);
|
|
75120
75559
|
const context = options.contextLines ?? 2;
|
|
75121
75560
|
const maxOutput = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT;
|
|
75122
|
-
const { files, truncated: walkTruncated } = await walkFiles(
|
|
75561
|
+
const { files, truncated: walkTruncated } = await walkFiles(fs41, root, options);
|
|
75123
75562
|
const separator = process.platform === "win32" ? "\\" : "/";
|
|
75124
75563
|
const chunks = [];
|
|
75125
75564
|
let size = 0;
|
|
@@ -75129,13 +75568,13 @@ async function searchFiles(fs39, root, options) {
|
|
|
75129
75568
|
break;
|
|
75130
75569
|
if (!admits(relative))
|
|
75131
75570
|
continue;
|
|
75132
|
-
const absolute =
|
|
75571
|
+
const absolute = import_node_path45.default.join(root, ...relative.split("/"));
|
|
75133
75572
|
let bytes;
|
|
75134
75573
|
try {
|
|
75135
|
-
const stat = await
|
|
75574
|
+
const stat = await fs41.stat(absolute);
|
|
75136
75575
|
if (stat.size > MAX_FILE_BYTES)
|
|
75137
75576
|
continue;
|
|
75138
|
-
bytes = await
|
|
75577
|
+
bytes = await fs41.readBytes(absolute);
|
|
75139
75578
|
} catch {
|
|
75140
75579
|
continue;
|
|
75141
75580
|
}
|
|
@@ -75253,8 +75692,8 @@ var NodeTerminal = class {
|
|
|
75253
75692
|
};
|
|
75254
75693
|
|
|
75255
75694
|
// ../../packages/core/dist/platform/node/taskStore.js
|
|
75256
|
-
var
|
|
75257
|
-
var
|
|
75695
|
+
var import_promises26 = __toESM(require("node:fs/promises"), 1);
|
|
75696
|
+
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
75258
75697
|
|
|
75259
75698
|
// ../../packages/core/dist/history/types.js
|
|
75260
75699
|
function taskSummary(task) {
|
|
@@ -75277,7 +75716,7 @@ var JsonTaskStore = class {
|
|
|
75277
75716
|
constructor(globalStoragePath, truncationStore, logger) {
|
|
75278
75717
|
this.truncationStore = truncationStore;
|
|
75279
75718
|
this.logger = logger;
|
|
75280
|
-
this.directory =
|
|
75719
|
+
this.directory = import_node_path46.default.join(globalStoragePath, "tasks");
|
|
75281
75720
|
}
|
|
75282
75721
|
async list(workspaceRoot) {
|
|
75283
75722
|
const index = await this.readIndex();
|
|
@@ -75293,7 +75732,7 @@ var JsonTaskStore = class {
|
|
|
75293
75732
|
if (!isValidId(id))
|
|
75294
75733
|
return void 0;
|
|
75295
75734
|
try {
|
|
75296
|
-
const raw = await
|
|
75735
|
+
const raw = await import_promises26.default.readFile(this.fileFor(id), "utf8");
|
|
75297
75736
|
return parseTask(raw);
|
|
75298
75737
|
} catch (error51) {
|
|
75299
75738
|
if (error51.code !== "ENOENT") {
|
|
@@ -75305,10 +75744,10 @@ var JsonTaskStore = class {
|
|
|
75305
75744
|
async save(task) {
|
|
75306
75745
|
if (!isValidId(task.id))
|
|
75307
75746
|
throw new Error(`Refusing to save a task with an unexpected id: ${task.id}`);
|
|
75308
|
-
await
|
|
75747
|
+
await import_promises26.default.mkdir(this.directory, { recursive: true });
|
|
75309
75748
|
const target = this.fileFor(task.id);
|
|
75310
75749
|
const temporary = `${target}.tmp`;
|
|
75311
|
-
await
|
|
75750
|
+
await import_promises26.default.writeFile(temporary, JSON.stringify(task, null, 2), "utf8");
|
|
75312
75751
|
await replaceFile(temporary, target);
|
|
75313
75752
|
const index = await this.readIndex();
|
|
75314
75753
|
const entry = { ...taskSummary(task), workspaceRoot: task.workspaceRoot };
|
|
@@ -75321,16 +75760,16 @@ var JsonTaskStore = class {
|
|
|
75321
75760
|
if (task !== void 0 && task.resultHandles.length > 0) {
|
|
75322
75761
|
await this.truncationStore.deleteMany(task.resultHandles);
|
|
75323
75762
|
}
|
|
75324
|
-
await
|
|
75763
|
+
await import_promises26.default.rm(this.fileFor(id), { force: true });
|
|
75325
75764
|
const index = await this.readIndex();
|
|
75326
75765
|
await this.writeIndex(index.filter((entry) => entry.id !== id));
|
|
75327
75766
|
}
|
|
75328
75767
|
fileFor(id) {
|
|
75329
|
-
return
|
|
75768
|
+
return import_node_path46.default.join(this.directory, `${id}.json`);
|
|
75330
75769
|
}
|
|
75331
75770
|
async readIndex() {
|
|
75332
75771
|
try {
|
|
75333
|
-
const raw = await
|
|
75772
|
+
const raw = await import_promises26.default.readFile(import_node_path46.default.join(this.directory, INDEX_FILE), "utf8");
|
|
75334
75773
|
const parsed = JSON.parse(raw);
|
|
75335
75774
|
if (Array.isArray(parsed))
|
|
75336
75775
|
return parsed.filter(isIndexEntry);
|
|
@@ -75347,7 +75786,7 @@ var JsonTaskStore = class {
|
|
|
75347
75786
|
async rebuildIndex() {
|
|
75348
75787
|
let names;
|
|
75349
75788
|
try {
|
|
75350
|
-
names = await
|
|
75789
|
+
names = await import_promises26.default.readdir(this.directory);
|
|
75351
75790
|
} catch {
|
|
75352
75791
|
return [];
|
|
75353
75792
|
}
|
|
@@ -75364,10 +75803,10 @@ var JsonTaskStore = class {
|
|
|
75364
75803
|
return entries;
|
|
75365
75804
|
}
|
|
75366
75805
|
async writeIndex(entries) {
|
|
75367
|
-
await
|
|
75368
|
-
const target =
|
|
75806
|
+
await import_promises26.default.mkdir(this.directory, { recursive: true });
|
|
75807
|
+
const target = import_node_path46.default.join(this.directory, INDEX_FILE);
|
|
75369
75808
|
const temporary = `${target}.tmp`;
|
|
75370
|
-
await
|
|
75809
|
+
await import_promises26.default.writeFile(temporary, JSON.stringify(entries, null, 2), "utf8");
|
|
75371
75810
|
await replaceFile(temporary, target);
|
|
75372
75811
|
}
|
|
75373
75812
|
};
|
|
@@ -75395,189 +75834,9 @@ function parseTask(raw) {
|
|
|
75395
75834
|
};
|
|
75396
75835
|
}
|
|
75397
75836
|
|
|
75398
|
-
// ../../packages/core/dist/usage/events.js
|
|
75399
|
-
var import_node_crypto12 = require("node:crypto");
|
|
75400
|
-
var import_node_fs7 = require("node:fs");
|
|
75401
|
-
var import_node_os5 = __toESM(require("node:os"), 1);
|
|
75402
|
-
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
75403
|
-
function isUsageEvent(value) {
|
|
75404
|
-
if (value === null || typeof value !== "object")
|
|
75405
|
-
return false;
|
|
75406
|
-
const event = value;
|
|
75407
|
-
return typeof event["t"] === "number" && typeof event["u"] === "string" && (event["k"] === "skill" || event["k"] === "tool") && typeof event["n"] === "string";
|
|
75408
|
-
}
|
|
75409
|
-
function parseUsageLines(text) {
|
|
75410
|
-
const events = [];
|
|
75411
|
-
for (const line of text.split(/\r?\n/)) {
|
|
75412
|
-
if (line.trim().length === 0)
|
|
75413
|
-
continue;
|
|
75414
|
-
try {
|
|
75415
|
-
const parsed = JSON.parse(line);
|
|
75416
|
-
if (isUsageEvent(parsed))
|
|
75417
|
-
events.push(parsed);
|
|
75418
|
-
} catch {
|
|
75419
|
-
}
|
|
75420
|
-
}
|
|
75421
|
-
return events;
|
|
75422
|
-
}
|
|
75423
|
-
function usageDay(t) {
|
|
75424
|
-
return new Date(t).toISOString().slice(0, 10);
|
|
75425
|
-
}
|
|
75426
|
-
function usageInstanceId(storageDir) {
|
|
75427
|
-
return (0, import_node_crypto12.createHash)("sha256").update(`${import_node_os5.default.hostname()}
|
|
75428
|
-
${import_node_path44.default.resolve(storageDir).toLowerCase()}`).digest("hex").slice(0, 12);
|
|
75429
|
-
}
|
|
75430
|
-
async function writeFileAtomically(target, text) {
|
|
75431
|
-
await import_node_fs7.promises.mkdir(import_node_path44.default.dirname(target), { recursive: true });
|
|
75432
|
-
const temporary = `${target}.${(0, import_node_crypto12.randomBytes)(6).toString("hex")}.tmp`;
|
|
75433
|
-
await import_node_fs7.promises.writeFile(temporary, text, "utf8");
|
|
75434
|
-
try {
|
|
75435
|
-
await replaceFile(temporary, target);
|
|
75436
|
-
} finally {
|
|
75437
|
-
await import_node_fs7.promises.rm(temporary, { force: true }).catch(() => void 0);
|
|
75438
|
-
}
|
|
75439
|
-
}
|
|
75440
|
-
var QUEUE_FILE = /^(\d{4}-\d{2}-\d{2})__([A-Za-z0-9-]+)\.jsonl$/;
|
|
75441
|
-
var UsageLog = class {
|
|
75442
|
-
storageDir;
|
|
75443
|
-
queueDir;
|
|
75444
|
-
manifestFile;
|
|
75445
|
-
rolledFile;
|
|
75446
|
-
legacyFile;
|
|
75447
|
-
session;
|
|
75448
|
-
constructor(storageDir, session) {
|
|
75449
|
-
this.storageDir = storageDir;
|
|
75450
|
-
this.queueDir = import_node_path44.default.join(storageDir, "usage", "queue");
|
|
75451
|
-
this.manifestFile = import_node_path44.default.join(storageDir, "usage", "pushed.json");
|
|
75452
|
-
this.rolledFile = import_node_path44.default.join(storageDir, "usage", "rolled.json");
|
|
75453
|
-
this.legacyFile = import_node_path44.default.join(storageDir, "usage-events.jsonl");
|
|
75454
|
-
this.session = session ?? (0, import_node_crypto12.randomBytes)(6).toString("hex");
|
|
75455
|
-
}
|
|
75456
|
-
async append(event) {
|
|
75457
|
-
await import_node_fs7.promises.mkdir(this.queueDir, { recursive: true });
|
|
75458
|
-
await import_node_fs7.promises.appendFile(import_node_path44.default.join(this.queueDir, `${usageDay(event.t)}__${this.session}.jsonl`), `${JSON.stringify(event)}
|
|
75459
|
-
`, "utf8");
|
|
75460
|
-
}
|
|
75461
|
-
/**
|
|
75462
|
-
* Replaces one fixed-name file of a day - the import of past conversations writes these. Replaced,
|
|
75463
|
-
* never appended, so two sessions importing at once leave one copy rather than two.
|
|
75464
|
-
*/
|
|
75465
|
-
async writeFixed(day, name, events) {
|
|
75466
|
-
await writeFileAtomically(import_node_path44.default.join(this.queueDir, `${day}__${name}.jsonl`), events.map((event) => JSON.stringify(event)).join("\n") + (events.length > 0 ? "\n" : ""));
|
|
75467
|
-
}
|
|
75468
|
-
/**
|
|
75469
|
-
* Moves a 0.156/0.157 single queue file into the per-day layout, once. Deterministic names, so two
|
|
75470
|
-
* sessions doing it at once write the same files; the old file is then renamed away by whichever
|
|
75471
|
-
* gets there first.
|
|
75472
|
-
*/
|
|
75473
|
-
async migrateLegacy() {
|
|
75474
|
-
let text;
|
|
75475
|
-
try {
|
|
75476
|
-
text = await import_node_fs7.promises.readFile(this.legacyFile, "utf8");
|
|
75477
|
-
} catch {
|
|
75478
|
-
return;
|
|
75479
|
-
}
|
|
75480
|
-
const byDay = /* @__PURE__ */ new Map();
|
|
75481
|
-
for (const event of parseUsageLines(text))
|
|
75482
|
-
byDay.set(usageDay(event.t), [...byDay.get(usageDay(event.t)) ?? [], event]);
|
|
75483
|
-
for (const [day, events] of byDay)
|
|
75484
|
-
await this.writeFixed(day, "legacy", events);
|
|
75485
|
-
await import_node_fs7.promises.rename(this.legacyFile, `${this.legacyFile}.migrated`).catch(() => void 0);
|
|
75486
|
-
await import_node_fs7.promises.rm(import_node_path44.default.join(this.storageDir, "usage-sync.json"), { force: true }).catch(() => void 0);
|
|
75487
|
-
}
|
|
75488
|
-
/** Every day with local files, and its signature. */
|
|
75489
|
-
async days() {
|
|
75490
|
-
const days = /* @__PURE__ */ new Map();
|
|
75491
|
-
let names;
|
|
75492
|
-
try {
|
|
75493
|
-
names = await import_node_fs7.promises.readdir(this.queueDir);
|
|
75494
|
-
} catch {
|
|
75495
|
-
return days;
|
|
75496
|
-
}
|
|
75497
|
-
for (const name of names) {
|
|
75498
|
-
const match = QUEUE_FILE.exec(name);
|
|
75499
|
-
if (match === null)
|
|
75500
|
-
continue;
|
|
75501
|
-
const size = await import_node_fs7.promises.stat(import_node_path44.default.join(this.queueDir, name)).then((stat) => stat.size).catch(() => void 0);
|
|
75502
|
-
if (size === void 0)
|
|
75503
|
-
continue;
|
|
75504
|
-
const entry = days.get(match[1]) ?? { files: [], signature: "" };
|
|
75505
|
-
entry.files.push({ name, size });
|
|
75506
|
-
days.set(match[1], entry);
|
|
75507
|
-
}
|
|
75508
|
-
for (const entry of days.values()) {
|
|
75509
|
-
entry.files.sort((a, b) => a.name.localeCompare(b.name));
|
|
75510
|
-
entry.signature = entry.files.map((file2) => `${file2.name}:${String(file2.size)}`).join("|");
|
|
75511
|
-
}
|
|
75512
|
-
return days;
|
|
75513
|
-
}
|
|
75514
|
-
/** The signature of one day as it is now. */
|
|
75515
|
-
async daySignature(day) {
|
|
75516
|
-
return (await this.days()).get(day)?.signature ?? "";
|
|
75517
|
-
}
|
|
75518
|
-
/** Every event of one day, from every session's file. */
|
|
75519
|
-
async readDay(day) {
|
|
75520
|
-
const entry = (await this.days()).get(day);
|
|
75521
|
-
if (entry === void 0)
|
|
75522
|
-
return [];
|
|
75523
|
-
const texts = await Promise.all(entry.files.map((file2) => import_node_fs7.promises.readFile(import_node_path44.default.join(this.queueDir, file2.name), "utf8").catch(() => "")));
|
|
75524
|
-
return texts.flatMap(parseUsageLines).sort((a, b) => a.t - b.t);
|
|
75525
|
-
}
|
|
75526
|
-
/** Every queued event (the last few weeks), for finding names worth looking up. */
|
|
75527
|
-
async all() {
|
|
75528
|
-
const days = [...(await this.days()).keys()].sort();
|
|
75529
|
-
return (await Promise.all(days.map((day) => this.readDay(day)))).flat();
|
|
75530
|
-
}
|
|
75531
|
-
/** What has been pushed to `target`, by day. A different target has had nothing pushed. */
|
|
75532
|
-
async pushed(target) {
|
|
75533
|
-
try {
|
|
75534
|
-
const saved = JSON.parse(await import_node_fs7.promises.readFile(this.manifestFile, "utf8"));
|
|
75535
|
-
return saved.target === target && saved.days !== null && typeof saved.days === "object" ? saved.days : {};
|
|
75536
|
-
} catch {
|
|
75537
|
-
return {};
|
|
75538
|
-
}
|
|
75539
|
-
}
|
|
75540
|
-
/** Records a day as pushed with the signature that was pushed. Merged with the file as it is now. */
|
|
75541
|
-
async markPushed(target, day, signature) {
|
|
75542
|
-
const days = { ...await this.pushed(target), [day]: signature };
|
|
75543
|
-
await writeFileAtomically(this.manifestFile, JSON.stringify({ target, days }));
|
|
75544
|
-
}
|
|
75545
|
-
/** Months this install has rolled up in `target` (`usage/rollup.ts`): their late days go into the month. */
|
|
75546
|
-
async rolledMonths(target) {
|
|
75547
|
-
try {
|
|
75548
|
-
const saved = JSON.parse(await import_node_fs7.promises.readFile(this.rolledFile, "utf8"));
|
|
75549
|
-
return new Set(saved.target === target && Array.isArray(saved.months) ? saved.months.filter((month) => typeof month === "string") : []);
|
|
75550
|
-
} catch {
|
|
75551
|
-
return /* @__PURE__ */ new Set();
|
|
75552
|
-
}
|
|
75553
|
-
}
|
|
75554
|
-
async markRolled(target, month) {
|
|
75555
|
-
const months = await this.rolledMonths(target);
|
|
75556
|
-
if (months.has(month))
|
|
75557
|
-
return;
|
|
75558
|
-
months.add(month);
|
|
75559
|
-
await writeFileAtomically(this.rolledFile, JSON.stringify({ target, months: [...months].sort() }));
|
|
75560
|
-
}
|
|
75561
|
-
/** Deletes whole files of days older than `keepDays` that were pushed as they are. */
|
|
75562
|
-
async prune(target, keepDays, now = Date.now()) {
|
|
75563
|
-
const cutoff = usageDay(now - keepDays * 864e5);
|
|
75564
|
-
const pushed = await this.pushed(target);
|
|
75565
|
-
let removed = 0;
|
|
75566
|
-
for (const [day, entry] of await this.days()) {
|
|
75567
|
-
if (day >= cutoff || pushed[day] !== entry.signature)
|
|
75568
|
-
continue;
|
|
75569
|
-
for (const file2 of entry.files) {
|
|
75570
|
-
await import_node_fs7.promises.rm(import_node_path44.default.join(this.queueDir, file2.name), { force: true }).catch(() => void 0);
|
|
75571
|
-
removed++;
|
|
75572
|
-
}
|
|
75573
|
-
}
|
|
75574
|
-
return removed;
|
|
75575
|
-
}
|
|
75576
|
-
};
|
|
75577
|
-
|
|
75578
75837
|
// ../../packages/core/dist/usage/store.js
|
|
75579
75838
|
var import_node_fs8 = require("node:fs");
|
|
75580
|
-
var
|
|
75839
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
75581
75840
|
|
|
75582
75841
|
// ../../packages/core/dist/s3/keys.js
|
|
75583
75842
|
function normalisePrefix(prefix) {
|
|
@@ -75710,7 +75969,7 @@ var FolderShardStore = class {
|
|
|
75710
75969
|
await this.ask({ action: "write", user: shardSegment(shard.user), day: shard.day, instance: shard.instance, events });
|
|
75711
75970
|
return;
|
|
75712
75971
|
}
|
|
75713
|
-
await this.writeAtomically(
|
|
75972
|
+
await this.writeAtomically(import_node_path47.default.join(this.root, shardSegment(shard.user), `${shard.day}__${shard.instance}.jsonl`), shardText(events));
|
|
75714
75973
|
}
|
|
75715
75974
|
async read(fromDay, toDay) {
|
|
75716
75975
|
this.lastProblems = [];
|
|
@@ -75730,8 +75989,8 @@ var FolderShardStore = class {
|
|
|
75730
75989
|
}
|
|
75731
75990
|
const files = await this.listFiles();
|
|
75732
75991
|
const wanted = selectShards(files, fromDay, toDay);
|
|
75733
|
-
const texts = await pooled(wanted, 8, (file2) => import_node_fs8.promises.readFile(
|
|
75734
|
-
this.lastProblems.push(`${
|
|
75992
|
+
const texts = await pooled(wanted, 8, (file2) => import_node_fs8.promises.readFile(import_node_path47.default.join(this.root, file2.user, file2.name), "utf8").catch((error51) => {
|
|
75993
|
+
this.lastProblems.push(`${import_node_path47.default.join(this.root, file2.user, file2.name)}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
75735
75994
|
return "";
|
|
75736
75995
|
}));
|
|
75737
75996
|
return texts.flatMap(parseUsageLines);
|
|
@@ -75748,7 +76007,7 @@ var FolderShardStore = class {
|
|
|
75748
76007
|
}
|
|
75749
76008
|
const files = [];
|
|
75750
76009
|
for (const user of users) {
|
|
75751
|
-
const folder =
|
|
76010
|
+
const folder = import_node_path47.default.join(this.root, user);
|
|
75752
76011
|
let names;
|
|
75753
76012
|
try {
|
|
75754
76013
|
names = await import_node_fs8.promises.readdir(folder);
|
|
@@ -75767,7 +76026,7 @@ var FolderShardStore = class {
|
|
|
75767
76026
|
}
|
|
75768
76027
|
async readShard(shard) {
|
|
75769
76028
|
try {
|
|
75770
|
-
return parseUsageLines(await import_node_fs8.promises.readFile(
|
|
76029
|
+
return parseUsageLines(await import_node_fs8.promises.readFile(import_node_path47.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), "utf8"));
|
|
75771
76030
|
} catch (error51) {
|
|
75772
76031
|
if (error51.code === "ENOENT")
|
|
75773
76032
|
return void 0;
|
|
@@ -75775,10 +76034,10 @@ var FolderShardStore = class {
|
|
|
75775
76034
|
}
|
|
75776
76035
|
}
|
|
75777
76036
|
async putMonth(shard, events) {
|
|
75778
|
-
await this.writeAtomically(
|
|
76037
|
+
await this.writeAtomically(import_node_path47.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), shardText(events));
|
|
75779
76038
|
}
|
|
75780
76039
|
async removeShard(shard) {
|
|
75781
|
-
await import_node_fs8.promises.rm(
|
|
76040
|
+
await import_node_fs8.promises.rm(import_node_path47.default.join(this.root, shardSegment(shard.user), shardFileName(shard)), { force: true });
|
|
75782
76041
|
}
|
|
75783
76042
|
async putProfile(user, profile) {
|
|
75784
76043
|
this.profilesFromRead = void 0;
|
|
@@ -75786,7 +76045,7 @@ var FolderShardStore = class {
|
|
|
75786
76045
|
await this.ask({ action: "writeProfile", user: shardSegment(user), profile: cleanProfile(profile) });
|
|
75787
76046
|
return;
|
|
75788
76047
|
}
|
|
75789
|
-
await this.writeAtomically(
|
|
76048
|
+
await this.writeAtomically(import_node_path47.default.join(this.root, "_profiles", `${shardSegment(user)}.json`), JSON.stringify(cleanProfile(profile)));
|
|
75790
76049
|
}
|
|
75791
76050
|
async readProfiles() {
|
|
75792
76051
|
if (this.profilesFromRead !== void 0)
|
|
@@ -75795,13 +76054,13 @@ var FolderShardStore = class {
|
|
|
75795
76054
|
await this.read("9999-12-31", "9999-12-31");
|
|
75796
76055
|
return this.profilesFromRead ?? {};
|
|
75797
76056
|
}
|
|
75798
|
-
const folder =
|
|
76057
|
+
const folder = import_node_path47.default.join(this.root, "_profiles");
|
|
75799
76058
|
const profiles = {};
|
|
75800
76059
|
for (const name of await import_node_fs8.promises.readdir(folder).catch(() => [])) {
|
|
75801
76060
|
if (!name.endsWith(".json"))
|
|
75802
76061
|
continue;
|
|
75803
76062
|
try {
|
|
75804
|
-
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs8.promises.readFile(
|
|
76063
|
+
profiles[name.slice(0, -5)] = cleanProfile(JSON.parse(await import_node_fs8.promises.readFile(import_node_path47.default.join(folder, name), "utf8")));
|
|
75805
76064
|
} catch {
|
|
75806
76065
|
}
|
|
75807
76066
|
}
|
|
@@ -76550,7 +76809,7 @@ function usageCollectionOn(config2, choice) {
|
|
|
76550
76809
|
|
|
76551
76810
|
// ../../packages/core/dist/usage/backfill.js
|
|
76552
76811
|
var import_node_fs9 = require("node:fs");
|
|
76553
|
-
var
|
|
76812
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
76554
76813
|
function comparablePath(value) {
|
|
76555
76814
|
return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
76556
76815
|
}
|
|
@@ -76560,7 +76819,7 @@ function eventsFromTask(task, context) {
|
|
|
76560
76819
|
return [];
|
|
76561
76820
|
const created = typeof task.createdAt === "number" && task.createdAt <= updated ? task.createdAt : updated;
|
|
76562
76821
|
const root = typeof task.workspaceRoot === "string" ? task.workspaceRoot : void 0;
|
|
76563
|
-
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ?
|
|
76822
|
+
const project = root !== void 0 && context.workspaceRoot !== void 0 && comparablePath(root) === comparablePath(context.workspaceRoot) ? context.project : root !== void 0 ? import_node_path48.default.basename(root.replace(/\\/g, "/")) : void 0;
|
|
76564
76823
|
const skillsByPath = new Map(context.skills.map((skill) => [comparablePath(skill.filePath), skill]));
|
|
76565
76824
|
const skip = new Set(context.skip);
|
|
76566
76825
|
const calls = [];
|
|
@@ -76597,7 +76856,7 @@ function eventsFromTask(task, context) {
|
|
|
76597
76856
|
let skill;
|
|
76598
76857
|
if (call.name === "read_file" && typeof call.args["path"] === "string") {
|
|
76599
76858
|
const requested2 = call.args["path"];
|
|
76600
|
-
const absolute =
|
|
76859
|
+
const absolute = import_node_path48.default.isAbsolute(requested2) || /^[A-Za-z]:[\\/]/.test(requested2) || root === void 0 ? requested2 : import_node_path48.default.join(root, requested2);
|
|
76601
76860
|
skill = skillsByPath.get(comparablePath(absolute));
|
|
76602
76861
|
}
|
|
76603
76862
|
if (call.name === "use_skill_file" && typeof call.args["skill"] === "string") {
|
|
@@ -76642,7 +76901,7 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
76642
76901
|
let unreadable = 0;
|
|
76643
76902
|
for (const name of names) {
|
|
76644
76903
|
try {
|
|
76645
|
-
events.push(...eventsFromTask(JSON.parse(await import_node_fs9.promises.readFile(
|
|
76904
|
+
events.push(...eventsFromTask(JSON.parse(await import_node_fs9.promises.readFile(import_node_path48.default.join(tasksDir, name), "utf8")), context));
|
|
76646
76905
|
} catch {
|
|
76647
76906
|
unreadable++;
|
|
76648
76907
|
}
|
|
@@ -76650,13 +76909,13 @@ async function backfillFromTasks(tasksDir, context, helper) {
|
|
|
76650
76909
|
return { events, tasks: names.length, unreadable, via: "node" };
|
|
76651
76910
|
}
|
|
76652
76911
|
async function backfillOnce(options) {
|
|
76653
|
-
const doneFile =
|
|
76912
|
+
const doneFile = import_node_path48.default.join(options.usageDir, "backfill.json");
|
|
76654
76913
|
for (const file2 of [doneFile, ...options.legacyDoneFile !== void 0 ? [options.legacyDoneFile] : []]) {
|
|
76655
76914
|
if (await import_node_fs9.promises.stat(file2).then(() => true, () => false))
|
|
76656
76915
|
return { ran: false };
|
|
76657
76916
|
}
|
|
76658
76917
|
await import_node_fs9.promises.mkdir(options.usageDir, { recursive: true });
|
|
76659
|
-
const startFile =
|
|
76918
|
+
const startFile = import_node_path48.default.join(options.usageDir, "backfill-start.json");
|
|
76660
76919
|
let before;
|
|
76661
76920
|
try {
|
|
76662
76921
|
before = (options.now ?? Date.now)();
|
|
@@ -77065,12 +77324,19 @@ function wireChatBridge(services) {
|
|
|
77065
77324
|
let cachedSecretValues = [];
|
|
77066
77325
|
const droppedFilesRoot2 = droppedFilesRoot();
|
|
77067
77326
|
const mailAttachmentsRoot2 = mailAttachmentsRoot();
|
|
77068
|
-
const droppedFilesDir =
|
|
77069
|
-
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(
|
|
77327
|
+
const droppedFilesDir = import_node_path49.default.join(droppedFilesRoot2, (0, import_node_crypto14.randomUUID)().slice(0, 8));
|
|
77328
|
+
const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(import_node_path49.default.join(storageDir, "tool-results"), () => cachedSecretValues));
|
|
77070
77329
|
const taskStore = new JsonTaskStore(storageDir, truncationStore, logger);
|
|
77330
|
+
const manifestsRoot = services.codebaseDir ?? storageDir;
|
|
77331
|
+
const codebaseInstructionsFile = codebaseInstructionsPath({ codebaseDir: services.codebaseDir, storageDir, workspaceRoot });
|
|
77332
|
+
if (services.codebaseDir !== void 0) {
|
|
77333
|
+
const shared = import_node_path49.default.join(services.codebaseDir, "index-manifests");
|
|
77334
|
+
void import_promises27.default.access(shared).catch(() => import_promises27.default.cp(import_node_path49.default.join(storageDir, "index-manifests"), shared, { recursive: true, errorOnExist: false, force: false })).catch(() => void 0);
|
|
77335
|
+
}
|
|
77071
77336
|
const python = new PythonManager({
|
|
77072
77337
|
workspaceRoot,
|
|
77073
77338
|
storageDir,
|
|
77339
|
+
...services.codebaseDir !== void 0 ? { venvRoot: services.codebaseDir } : {},
|
|
77074
77340
|
logger,
|
|
77075
77341
|
// Fire Code: one review per tool's code on this machine, however many codebases hold it.
|
|
77076
77342
|
...services.machineApprovalsFile !== void 0 ? { machineApprovals } : {},
|
|
@@ -77191,7 +77457,7 @@ ${preview.text}` } : {}
|
|
|
77191
77457
|
void postDatasetStatus();
|
|
77192
77458
|
}
|
|
77193
77459
|
});
|
|
77194
|
-
const defaultSkillsDir = workspaceRoot !== void 0 ?
|
|
77460
|
+
const defaultSkillsDir = workspaceRoot !== void 0 ? import_node_path49.default.join(workspaceRoot, ".lightcode", "skills") : void 0;
|
|
77195
77461
|
let skillsDir = defaultSkillsDir;
|
|
77196
77462
|
let localSkillsDir = defaultSkillsDir;
|
|
77197
77463
|
let extraSkillDirs = [];
|
|
@@ -77214,9 +77480,9 @@ ${preview.text}` } : {}
|
|
|
77214
77480
|
const trimmed = entry.trim();
|
|
77215
77481
|
if (trimmed.length === 0)
|
|
77216
77482
|
return void 0;
|
|
77217
|
-
if (
|
|
77218
|
-
return
|
|
77219
|
-
return workspaceRoot === void 0 ? void 0 :
|
|
77483
|
+
if (import_node_path49.default.isAbsolute(trimmed))
|
|
77484
|
+
return import_node_path49.default.resolve(trimmed);
|
|
77485
|
+
return workspaceRoot === void 0 ? void 0 : import_node_path49.default.resolve(workspaceRoot, trimmed);
|
|
77220
77486
|
}
|
|
77221
77487
|
function skillSearchPath() {
|
|
77222
77488
|
return [skillsDir, ...extraSkillDirs].filter((dir) => dir !== void 0);
|
|
@@ -77248,7 +77514,7 @@ ${preview.text}` } : {}
|
|
|
77248
77514
|
function watchSkillFolders() {
|
|
77249
77515
|
stopWatchingSkills();
|
|
77250
77516
|
const dirs = skillSearchPath();
|
|
77251
|
-
for (const dir of [...dirs, ...dirs.map((entry) =>
|
|
77517
|
+
for (const dir of [...dirs, ...dirs.map((entry) => import_node_path49.default.dirname(entry))]) {
|
|
77252
77518
|
try {
|
|
77253
77519
|
skillWatchers.push(
|
|
77254
77520
|
// Recursive, because a skill may be a folder with SKILL.md inside — a non-recursive
|
|
@@ -77275,7 +77541,7 @@ ${preview.text}` } : {}
|
|
|
77275
77541
|
// instruction on the wire twice.
|
|
77276
77542
|
skills: await Promise.all(skills.map(async (skill) => {
|
|
77277
77543
|
const readdir = async (dir) => {
|
|
77278
|
-
const entries = await
|
|
77544
|
+
const entries = await import_promises27.default.readdir(dir, { withFileTypes: true });
|
|
77279
77545
|
return entries.map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
|
|
77280
77546
|
};
|
|
77281
77547
|
const images = await listSkillImages(skill.filePath, { readdir });
|
|
@@ -77319,7 +77585,7 @@ ${preview.text}` } : {}
|
|
|
77319
77585
|
await openInPanelEditor(filePath);
|
|
77320
77586
|
return;
|
|
77321
77587
|
}
|
|
77322
|
-
const real = await confineToAny(
|
|
77588
|
+
const real = await confineToAny(import_node_path49.default.resolve(filePath), roots);
|
|
77323
77589
|
await ui.openFile?.(real);
|
|
77324
77590
|
} catch (error51) {
|
|
77325
77591
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -77330,7 +77596,9 @@ ${preview.text}` } : {}
|
|
|
77330
77596
|
python.toolsDirectory(),
|
|
77331
77597
|
...skillsDir === void 0 ? [] : [skillsDir],
|
|
77332
77598
|
...extraSkillDirs.filter((dir) => dir !== void 0),
|
|
77333
|
-
|
|
77599
|
+
import_node_path49.default.join(storageDir, "reports"),
|
|
77600
|
+
// Its own folder: nothing else lives there.
|
|
77601
|
+
...codebaseInstructionsFile === void 0 ? [] : [import_node_path49.default.dirname(codebaseInstructionsFile)]
|
|
77334
77602
|
].filter((dir) => dir.length > 0);
|
|
77335
77603
|
}
|
|
77336
77604
|
function mostlyCrlf(text) {
|
|
@@ -77339,32 +77607,32 @@ ${preview.text}` } : {}
|
|
|
77339
77607
|
}
|
|
77340
77608
|
const EDITOR_MAX_BYTES = 2 * 1024 * 1024;
|
|
77341
77609
|
async function openInPanelEditor(filePath) {
|
|
77342
|
-
const real = await confineToAny(
|
|
77343
|
-
const stat = await
|
|
77610
|
+
const real = await confineToAny(import_node_path49.default.resolve(filePath), managedRoots());
|
|
77611
|
+
const stat = await import_promises27.default.stat(real);
|
|
77344
77612
|
if (stat.size > EDITOR_MAX_BYTES)
|
|
77345
|
-
throw new Error(`${
|
|
77346
|
-
const raw = await
|
|
77613
|
+
throw new Error(`${import_node_path49.default.basename(real)} is too large to edit here (${String(Math.round(stat.size / 1024))} KB).`);
|
|
77614
|
+
const raw = await import_promises27.default.readFile(real, "utf8");
|
|
77347
77615
|
const crlf = mostlyCrlf(raw);
|
|
77348
|
-
post({ type: "editorFile", path: real, name:
|
|
77616
|
+
post({ type: "editorFile", path: real, name: import_node_path49.default.basename(real), content: raw.split("\r\n").join("\n"), mtimeMs: stat.mtimeMs, eol: crlf ? "crlf" : "lf" });
|
|
77349
77617
|
}
|
|
77350
77618
|
async function handleSaveEditorFile(filePath, content, mtimeMs) {
|
|
77351
77619
|
try {
|
|
77352
|
-
const real = await confineToAny(
|
|
77353
|
-
const current = await
|
|
77620
|
+
const real = await confineToAny(import_node_path49.default.resolve(filePath), managedRoots());
|
|
77621
|
+
const current = await import_promises27.default.stat(real).catch(() => void 0);
|
|
77354
77622
|
if (current !== void 0 && Math.abs(current.mtimeMs - mtimeMs) > 1) {
|
|
77355
77623
|
post({
|
|
77356
77624
|
type: "editorSaved",
|
|
77357
77625
|
path: real,
|
|
77358
77626
|
ok: false,
|
|
77359
77627
|
conflict: true,
|
|
77360
|
-
message: `${
|
|
77628
|
+
message: `${import_node_path49.default.basename(real)} was changed on disk after you opened it. Copy your text, close the editor, and open it again to see the new version.`
|
|
77361
77629
|
});
|
|
77362
77630
|
return;
|
|
77363
77631
|
}
|
|
77364
|
-
const before = current === void 0 ? "" : await
|
|
77632
|
+
const before = current === void 0 ? "" : await import_promises27.default.readFile(real, "utf8");
|
|
77365
77633
|
const crlf = mostlyCrlf(before);
|
|
77366
77634
|
await writeFileAtomically(real, crlf ? content.split("\r\n").join("\n").split("\n").join("\r\n") : content);
|
|
77367
|
-
const saved = await
|
|
77635
|
+
const saved = await import_promises27.default.stat(real);
|
|
77368
77636
|
post({ type: "editorSaved", path: real, ok: true, mtimeMs: saved.mtimeMs });
|
|
77369
77637
|
await postSkills().catch(() => void 0);
|
|
77370
77638
|
} catch (error51) {
|
|
@@ -77381,10 +77649,10 @@ ${preview.text}` } : {}
|
|
|
77381
77649
|
await handleOpenManagedFile(existing.filePath);
|
|
77382
77650
|
return;
|
|
77383
77651
|
}
|
|
77384
|
-
const target =
|
|
77652
|
+
const target = import_node_path49.default.join(skillsDir, "standing-instructions.md");
|
|
77385
77653
|
try {
|
|
77386
|
-
await
|
|
77387
|
-
await
|
|
77654
|
+
await import_promises27.default.mkdir(skillsDir, { recursive: true });
|
|
77655
|
+
await import_promises27.default.writeFile(target, STANDING_SKILL_TEMPLATE, { encoding: "utf8", flag: "wx" });
|
|
77388
77656
|
} catch (error51) {
|
|
77389
77657
|
const code = error51.code;
|
|
77390
77658
|
if (code !== "EEXIST") {
|
|
@@ -77395,6 +77663,22 @@ ${preview.text}` } : {}
|
|
|
77395
77663
|
await postSkills();
|
|
77396
77664
|
await handleOpenManagedFile(target);
|
|
77397
77665
|
}
|
|
77666
|
+
async function handleOpenCodebaseInstructions() {
|
|
77667
|
+
if (codebaseInstructionsFile === void 0) {
|
|
77668
|
+
ui.showWarning("Open a folder first - codebase instructions belong to a codebase.");
|
|
77669
|
+
return;
|
|
77670
|
+
}
|
|
77671
|
+
try {
|
|
77672
|
+
await import_promises27.default.mkdir(import_node_path49.default.dirname(codebaseInstructionsFile), { recursive: true });
|
|
77673
|
+
await import_promises27.default.writeFile(codebaseInstructionsFile, "", { encoding: "utf8", flag: "wx" });
|
|
77674
|
+
} catch (error51) {
|
|
77675
|
+
if (error51.code !== "EEXIST") {
|
|
77676
|
+
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
77677
|
+
return;
|
|
77678
|
+
}
|
|
77679
|
+
}
|
|
77680
|
+
await handleOpenManagedFile(codebaseInstructionsFile);
|
|
77681
|
+
}
|
|
77398
77682
|
async function handleDeletePythonTool(name, filePath) {
|
|
77399
77683
|
try {
|
|
77400
77684
|
const dir = python.toolsDirectory();
|
|
@@ -77402,15 +77686,15 @@ ${preview.text}` } : {}
|
|
|
77402
77686
|
return;
|
|
77403
77687
|
if (!isValidToolName(name))
|
|
77404
77688
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
77405
|
-
const ownCopy =
|
|
77689
|
+
const ownCopy = import_node_path49.default.join(dir, toolFileName(name));
|
|
77406
77690
|
if (filePath !== void 0) {
|
|
77407
|
-
const same2 = (a, b) => normalizeForComparison(
|
|
77691
|
+
const same2 = (a, b) => normalizeForComparison(import_node_path49.default.resolve(a)) === normalizeForComparison(import_node_path49.default.resolve(b));
|
|
77408
77692
|
if (!same2(filePath, ownCopy)) {
|
|
77409
|
-
const fromBucket = mirroredToolsDirs.some((mirror) => same2(
|
|
77693
|
+
const fromBucket = mirroredToolsDirs.some((mirror) => same2(import_node_path49.default.dirname(filePath), mirror));
|
|
77410
77694
|
throw new Error(fromBucket ? `"${name}" at ${filePath} comes from a bucket folder, so deleting it here would be undone by the next sync. Decline it to hide this version, or remove it from the bucket to remove it for everyone.` : `${filePath} is not in the tools folder this machine writes to (${dir}), so it was not deleted.`);
|
|
77411
77695
|
}
|
|
77412
77696
|
}
|
|
77413
|
-
await
|
|
77697
|
+
await import_promises27.default.rm(ownCopy, { force: true });
|
|
77414
77698
|
await forgetTool(dir, name);
|
|
77415
77699
|
await python.refresh();
|
|
77416
77700
|
await postPython();
|
|
@@ -77423,7 +77707,7 @@ ${preview.text}` } : {}
|
|
|
77423
77707
|
return `"${name}" is not a valid tool name.`;
|
|
77424
77708
|
const onDisk = async (candidate) => {
|
|
77425
77709
|
try {
|
|
77426
|
-
await
|
|
77710
|
+
await import_promises27.default.stat(candidate);
|
|
77427
77711
|
return true;
|
|
77428
77712
|
} catch {
|
|
77429
77713
|
return false;
|
|
@@ -77432,7 +77716,7 @@ ${preview.text}` } : {}
|
|
|
77432
77716
|
let dir;
|
|
77433
77717
|
let filePath = "";
|
|
77434
77718
|
for (const candidate of python.toolDirectories()) {
|
|
77435
|
-
const attempt =
|
|
77719
|
+
const attempt = import_node_path49.default.join(candidate, toolFileName(name));
|
|
77436
77720
|
if (await onDisk(attempt)) {
|
|
77437
77721
|
dir = candidate;
|
|
77438
77722
|
filePath = attempt;
|
|
@@ -77441,7 +77725,7 @@ ${preview.text}` } : {}
|
|
|
77441
77725
|
}
|
|
77442
77726
|
if (dir === void 0)
|
|
77443
77727
|
return `no file for "${name}" in any configured tools folder`;
|
|
77444
|
-
const source = await
|
|
77728
|
+
const source = await import_promises27.default.readFile(filePath, "utf8");
|
|
77445
77729
|
const described = await python.describe(name, filePath);
|
|
77446
77730
|
if (described === void 0)
|
|
77447
77731
|
return `"${name}" could not be loaded, so it was not approved`;
|
|
@@ -77463,7 +77747,7 @@ ${preview.text}` } : {}
|
|
|
77463
77747
|
function samePath(a, b) {
|
|
77464
77748
|
if (a === void 0 || b === void 0)
|
|
77465
77749
|
return false;
|
|
77466
|
-
const norm2 = (value) => process.platform === "win32" ?
|
|
77750
|
+
const norm2 = (value) => process.platform === "win32" ? import_node_path49.default.resolve(value).toLowerCase() : import_node_path49.default.resolve(value);
|
|
77467
77751
|
return norm2(a) === norm2(b);
|
|
77468
77752
|
}
|
|
77469
77753
|
function publishFolder(kind, mirrors) {
|
|
@@ -77548,12 +77832,12 @@ ${preview.text}` } : {}
|
|
|
77548
77832
|
const suffix = kind === "skills" ? ".md" : ".py";
|
|
77549
77833
|
let entries = [];
|
|
77550
77834
|
try {
|
|
77551
|
-
entries = (await
|
|
77835
|
+
entries = (await import_promises27.default.readdir(dir)).filter((entry) => !entry.startsWith(".") && entry.toLowerCase().endsWith(suffix));
|
|
77552
77836
|
} catch {
|
|
77553
77837
|
entries = [];
|
|
77554
77838
|
}
|
|
77555
77839
|
if (entries.length === 0) {
|
|
77556
|
-
const exists2 = await
|
|
77840
|
+
const exists2 = await import_promises27.default.stat(dir).then(() => true).catch(() => false);
|
|
77557
77841
|
ui.showInfo(exists2 ? `Nothing in ${dir} to upload.` : `${dir} does not exist yet, so there is nothing to upload.`);
|
|
77558
77842
|
return;
|
|
77559
77843
|
}
|
|
@@ -77568,7 +77852,7 @@ ${preview.text}` } : {}
|
|
|
77568
77852
|
target,
|
|
77569
77853
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
|
|
77570
77854
|
relative: entry,
|
|
77571
|
-
contents: await
|
|
77855
|
+
contents: await import_promises27.default.readFile(import_node_path49.default.join(dir, entry))
|
|
77572
77856
|
});
|
|
77573
77857
|
uploaded += 1;
|
|
77574
77858
|
} catch (error51) {
|
|
@@ -77590,9 +77874,9 @@ ${preview.text}` } : {}
|
|
|
77590
77874
|
if (!isValidToolName(name))
|
|
77591
77875
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
77592
77876
|
for (const candidate of python.toolDirectories()) {
|
|
77593
|
-
const attempt =
|
|
77877
|
+
const attempt = import_node_path49.default.join(candidate, toolFileName(name));
|
|
77594
77878
|
try {
|
|
77595
|
-
post({ type: "pythonToolSource", name, source: await
|
|
77879
|
+
post({ type: "pythonToolSource", name, source: await import_promises27.default.readFile(attempt, "utf8") });
|
|
77596
77880
|
return;
|
|
77597
77881
|
} catch {
|
|
77598
77882
|
}
|
|
@@ -77643,7 +77927,7 @@ ${preview.text}` } : {}
|
|
|
77643
77927
|
continue;
|
|
77644
77928
|
for (const candidate of python.toolDirectories()) {
|
|
77645
77929
|
try {
|
|
77646
|
-
const source = await
|
|
77930
|
+
const source = await import_promises27.default.readFile(import_node_path49.default.join(candidate, toolFileName(name)), "utf8");
|
|
77647
77931
|
declined[name] = hashSource(source);
|
|
77648
77932
|
recorded += 1;
|
|
77649
77933
|
break;
|
|
@@ -77692,7 +77976,7 @@ ${preview.text}` } : {}
|
|
|
77692
77976
|
throw new Error(`"${name}" is not a valid tool name.`);
|
|
77693
77977
|
const onDisk = async (candidate) => {
|
|
77694
77978
|
try {
|
|
77695
|
-
await
|
|
77979
|
+
await import_promises27.default.stat(candidate);
|
|
77696
77980
|
return true;
|
|
77697
77981
|
} catch {
|
|
77698
77982
|
return false;
|
|
@@ -77701,7 +77985,7 @@ ${preview.text}` } : {}
|
|
|
77701
77985
|
let dir;
|
|
77702
77986
|
let filePath = "";
|
|
77703
77987
|
for (const candidate of python.toolDirectories()) {
|
|
77704
|
-
const attempt =
|
|
77988
|
+
const attempt = import_node_path49.default.join(candidate, toolFileName(name));
|
|
77705
77989
|
if (await onDisk(attempt)) {
|
|
77706
77990
|
dir = candidate;
|
|
77707
77991
|
filePath = attempt;
|
|
@@ -77711,7 +77995,7 @@ ${preview.text}` } : {}
|
|
|
77711
77995
|
if (dir === void 0) {
|
|
77712
77996
|
throw new Error(`No file for "${name}" was found in any configured tools folder.`);
|
|
77713
77997
|
}
|
|
77714
|
-
const source = await
|
|
77998
|
+
const source = await import_promises27.default.readFile(filePath, "utf8");
|
|
77715
77999
|
const described = await python.describe(name, filePath);
|
|
77716
78000
|
if (described === void 0) {
|
|
77717
78001
|
throw new Error(`"${name}" could not be loaded, so it was not approved. Fix the file and try again.`);
|
|
@@ -77727,7 +78011,7 @@ ${preview.text}` } : {}
|
|
|
77727
78011
|
function mirrorForDir(sourceDir) {
|
|
77728
78012
|
if (sourceDir === void 0)
|
|
77729
78013
|
return void 0;
|
|
77730
|
-
const wanted =
|
|
78014
|
+
const wanted = import_node_path49.default.resolve(sourceDir).toLowerCase();
|
|
77731
78015
|
for (const mirror of cachedSkillMirrors) {
|
|
77732
78016
|
if (mirror.enabled !== true)
|
|
77733
78017
|
continue;
|
|
@@ -77737,7 +78021,7 @@ ${preview.text}` } : {}
|
|
|
77737
78021
|
kind: "skills",
|
|
77738
78022
|
...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
|
|
77739
78023
|
});
|
|
77740
|
-
if (
|
|
78024
|
+
if (import_node_path49.default.resolve(localDir).toLowerCase() === wanted)
|
|
77741
78025
|
return { mirror, localDir };
|
|
77742
78026
|
}
|
|
77743
78027
|
return void 0;
|
|
@@ -77802,8 +78086,8 @@ ${preview.text}` } : {}
|
|
|
77802
78086
|
});
|
|
77803
78087
|
let localProblem;
|
|
77804
78088
|
try {
|
|
77805
|
-
await
|
|
77806
|
-
await
|
|
78089
|
+
await import_promises27.default.rm(import_node_path49.default.join(found2.localDir, `${name}.md`), { force: true });
|
|
78090
|
+
await import_promises27.default.rm(import_node_path49.default.join(found2.localDir, name), { recursive: true, force: true });
|
|
77807
78091
|
} catch (error51) {
|
|
77808
78092
|
localProblem = error51 instanceof Error ? error51.message : String(error51);
|
|
77809
78093
|
}
|
|
@@ -77836,7 +78120,7 @@ ${preview.text}` } : {}
|
|
|
77836
78120
|
if (existing !== void 0 && existing.sourceDir !== void 0 && existing.sourceDir !== skillsDir) {
|
|
77837
78121
|
throw new Error(`"${name}" lives in ${existing.sourceDir}, which is a read-only skills folder. Delete the file there, or remove the folder in Settings.`);
|
|
77838
78122
|
}
|
|
77839
|
-
await
|
|
78123
|
+
await import_promises27.default.rm(import_node_path49.default.join(skillsDir, skillFileName(name)), { force: true });
|
|
77840
78124
|
await postSkills();
|
|
77841
78125
|
} catch (error51) {
|
|
77842
78126
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -78016,7 +78300,7 @@ ${preview.text}` } : {}
|
|
|
78016
78300
|
let scheduleToolAccess;
|
|
78017
78301
|
const approvalsKey = workspaceRoot ?? "__no_workspace__";
|
|
78018
78302
|
function comparableApprovalsKey(key2) {
|
|
78019
|
-
return key2 === "__no_workspace__" ? key2 : normalizeForComparison(
|
|
78303
|
+
return key2 === "__no_workspace__" ? key2 : normalizeForComparison(import_node_path49.default.resolve(key2));
|
|
78020
78304
|
}
|
|
78021
78305
|
function approvalsFrom(stored) {
|
|
78022
78306
|
if (stored === void 0)
|
|
@@ -78227,14 +78511,14 @@ ${preview.text}` } : {}
|
|
|
78227
78511
|
...taskExpertEstimate === void 0 ? {} : { estimate: taskExpertEstimate }
|
|
78228
78512
|
});
|
|
78229
78513
|
}
|
|
78230
|
-
const expertEventsPath =
|
|
78514
|
+
const expertEventsPath = import_node_path49.default.join(storageDir, "expert-events.jsonl");
|
|
78231
78515
|
let expertEvents;
|
|
78232
78516
|
let juniorTurnWithoutExpert = false;
|
|
78233
78517
|
async function loadExpertEvents() {
|
|
78234
78518
|
if (expertEvents !== void 0)
|
|
78235
78519
|
return expertEvents;
|
|
78236
78520
|
try {
|
|
78237
|
-
const raw = await
|
|
78521
|
+
const raw = await import_promises27.default.readFile(expertEventsPath, "utf8");
|
|
78238
78522
|
const parsed = [];
|
|
78239
78523
|
for (const line of raw.split("\n")) {
|
|
78240
78524
|
if (line.trim().length === 0)
|
|
@@ -78255,8 +78539,8 @@ ${preview.text}` } : {}
|
|
|
78255
78539
|
try {
|
|
78256
78540
|
const events = await loadExpertEvents();
|
|
78257
78541
|
events.push(event);
|
|
78258
|
-
await
|
|
78259
|
-
await
|
|
78542
|
+
await import_promises27.default.mkdir(import_node_path49.default.dirname(expertEventsPath), { recursive: true });
|
|
78543
|
+
await import_promises27.default.appendFile(expertEventsPath, `${JSON.stringify(event)}
|
|
78260
78544
|
`, "utf8");
|
|
78261
78545
|
} catch (error51) {
|
|
78262
78546
|
logger.warn(`could not record expert spend: ${String(error51)}`);
|
|
@@ -78529,8 +78813,8 @@ ${preview.text}` } : {}
|
|
|
78529
78813
|
function contextMentionPath(file2) {
|
|
78530
78814
|
if (workspaceRoot === void 0)
|
|
78531
78815
|
return file2;
|
|
78532
|
-
const relative =
|
|
78533
|
-
return relative.length > 0 && !relative.startsWith("..") && !
|
|
78816
|
+
const relative = import_node_path49.default.relative(workspaceRoot, file2);
|
|
78817
|
+
return relative.length > 0 && !relative.startsWith("..") && !import_node_path49.default.isAbsolute(relative) ? relative.split(import_node_path49.default.sep).join("/") : file2;
|
|
78534
78818
|
}
|
|
78535
78819
|
function hostCapabilities() {
|
|
78536
78820
|
return {
|
|
@@ -79026,12 +79310,115 @@ ${preview.text}` } : {}
|
|
|
79026
79310
|
lastToolNames = combined.list().map((tool) => tool.name);
|
|
79027
79311
|
return combined;
|
|
79028
79312
|
}
|
|
79313
|
+
let installedAddons = [];
|
|
79314
|
+
let addonProblems = [];
|
|
79315
|
+
function addonFolders(config2) {
|
|
79316
|
+
return {
|
|
79317
|
+
configured: (config2.addons?.folders ?? []).map((folder) => import_node_path49.default.resolve(folder)),
|
|
79318
|
+
defaults: defaultAddonFolders(process.env, process.execPath, process.platform)
|
|
79319
|
+
};
|
|
79320
|
+
}
|
|
79321
|
+
async function rescanAddons(config2) {
|
|
79322
|
+
const folders = addonFolders(config2);
|
|
79323
|
+
const found2 = await discoverAddons([...folders.configured, ...folders.defaults]);
|
|
79324
|
+
installedAddons = found2.addons;
|
|
79325
|
+
addonProblems = found2.problems;
|
|
79326
|
+
}
|
|
79327
|
+
async function configureMcp(servers) {
|
|
79328
|
+
const { workspaceMcpServers } = await configManager.load();
|
|
79329
|
+
await mcp.configure(runnableServers(servers, installedAddons, { execPath: process.execPath, electron: process.versions["electron"] !== void 0 }, workspaceMcpServers));
|
|
79330
|
+
}
|
|
79029
79331
|
async function syncMcpFromConfig(config2) {
|
|
79030
79332
|
const servers = config2.mcpServers ?? {};
|
|
79031
79333
|
setMcpServersState(servers);
|
|
79032
|
-
await
|
|
79334
|
+
await rescanAddons(config2).catch(() => void 0);
|
|
79335
|
+
await configureMcp(servers);
|
|
79336
|
+
}
|
|
79337
|
+
async function postAddons(error51) {
|
|
79338
|
+
const { config: config2 } = await configManager.load();
|
|
79339
|
+
await rescanAddons(config2);
|
|
79340
|
+
const servers = config2.mcpServers ?? {};
|
|
79341
|
+
const folders = addonFolders(config2);
|
|
79342
|
+
const addons = installedAddons.map((addon) => {
|
|
79343
|
+
const state = addonState(addon, servers);
|
|
79344
|
+
const enabled = servers[addon.server]?.addon?.version;
|
|
79345
|
+
return {
|
|
79346
|
+
package: addon.package,
|
|
79347
|
+
version: addon.version,
|
|
79348
|
+
displayName: addon.displayName,
|
|
79349
|
+
...addon.description !== void 0 ? { description: addon.description } : {},
|
|
79350
|
+
dir: addon.dir,
|
|
79351
|
+
main: addon.main,
|
|
79352
|
+
server: addon.server,
|
|
79353
|
+
state,
|
|
79354
|
+
...state === "updated" && enabled !== void 0 ? { enabledVersion: enabled } : {}
|
|
79355
|
+
};
|
|
79356
|
+
});
|
|
79357
|
+
post({
|
|
79358
|
+
type: "addons",
|
|
79359
|
+
addons,
|
|
79360
|
+
problems: addonProblems,
|
|
79361
|
+
missing: missingAddons(installedAddons, servers).map((row) => ({
|
|
79362
|
+
server: row.server,
|
|
79363
|
+
package: row.tag.package,
|
|
79364
|
+
version: row.tag.version
|
|
79365
|
+
})),
|
|
79366
|
+
folders: folders.configured,
|
|
79367
|
+
defaultFolders: folders.defaults,
|
|
79368
|
+
...error51 !== void 0 ? { error: error51 } : {}
|
|
79369
|
+
});
|
|
79370
|
+
}
|
|
79371
|
+
async function handleEnableAddon(pkg) {
|
|
79372
|
+
const { config: config2 } = await configManager.load();
|
|
79373
|
+
await rescanAddons(config2);
|
|
79374
|
+
const addon = installedAddons.find((candidate) => candidate.package === pkg);
|
|
79375
|
+
if (addon === void 0) {
|
|
79376
|
+
await postAddons(`${pkg} is not installed in any add-on folder any more.`);
|
|
79377
|
+
return;
|
|
79378
|
+
}
|
|
79379
|
+
const servers = config2.mcpServers ?? {};
|
|
79380
|
+
const existing = servers[addon.server];
|
|
79381
|
+
const existingTag = existing?.addon?.package;
|
|
79382
|
+
if (existing !== void 0 && existingTag !== addon.package) {
|
|
79383
|
+
await postAddons(`An MCP server named "${addon.server}" already exists and is not this add-on. Rename it first.`);
|
|
79384
|
+
return;
|
|
79385
|
+
}
|
|
79386
|
+
const next = { ...servers, [addon.server]: addonServerEntry(addon, existing) };
|
|
79387
|
+
await configManager.save("user", { mcpServers: next });
|
|
79388
|
+
setMcpServersState(next);
|
|
79389
|
+
await configureMcp(next);
|
|
79390
|
+
postMcp();
|
|
79391
|
+
await postAddons();
|
|
79392
|
+
await mcp.ensureConnected();
|
|
79393
|
+
}
|
|
79394
|
+
async function handleRemoveAddon(server) {
|
|
79395
|
+
const { config: config2 } = await configManager.load();
|
|
79396
|
+
const servers = { ...config2.mcpServers ?? {} };
|
|
79397
|
+
if (servers[server]?.addon === void 0) {
|
|
79398
|
+
await postAddons(`"${server}" is not an add-on. Remove it from the server list instead.`);
|
|
79399
|
+
return;
|
|
79400
|
+
}
|
|
79401
|
+
delete servers[server];
|
|
79402
|
+
await configManager.save("user", { mcpServers: servers });
|
|
79403
|
+
setMcpServersState(servers);
|
|
79404
|
+
await configureMcp(servers);
|
|
79405
|
+
postMcp();
|
|
79406
|
+
await postAddons();
|
|
79033
79407
|
}
|
|
79034
|
-
|
|
79408
|
+
async function handleSaveAddonFolders(folders) {
|
|
79409
|
+
const cleaned = [...new Set(folders.map((folder) => folder.trim()).filter((folder) => folder.length > 0))];
|
|
79410
|
+
const relative = cleaned.find((folder) => !import_node_path49.default.isAbsolute(folder));
|
|
79411
|
+
if (relative !== void 0) {
|
|
79412
|
+
await postAddons(`"${relative}" is not a full path. Add-on folders are full paths, such as C:\\addons.`);
|
|
79413
|
+
return;
|
|
79414
|
+
}
|
|
79415
|
+
const { config: config2 } = await configManager.load();
|
|
79416
|
+
await configManager.save("user", { addons: { ...config2.addons ?? {}, folders: cleaned } });
|
|
79417
|
+
await syncMcpFromConfig((await configManager.load()).config);
|
|
79418
|
+
postMcp();
|
|
79419
|
+
await postAddons();
|
|
79420
|
+
}
|
|
79421
|
+
const shadowGit = workspaceRoot !== void 0 ? new ShadowGit(workspaceRoot, import_node_path49.default.join(storageDir, "checkpoints", "shadow.git"), services.codebaseDir !== void 0 ? import_node_path49.default.join(services.codebaseDir, "checkpoint-objects") : void 0) : void 0;
|
|
79035
79422
|
async function postProfiles() {
|
|
79036
79423
|
const { config: config2 } = await configManager.load();
|
|
79037
79424
|
const profiles = await Promise.all((config2.profiles ?? []).map((profile) => toSummary(profile, secrets)));
|
|
@@ -79088,7 +79475,7 @@ ${preview.text}` } : {}
|
|
|
79088
79475
|
if (workspaceRoot === void 0 || conversation.isEmpty())
|
|
79089
79476
|
return;
|
|
79090
79477
|
if (activeTaskId === void 0) {
|
|
79091
|
-
await setActiveTaskId((0,
|
|
79478
|
+
await setActiveTaskId((0, import_node_crypto14.randomUUID)());
|
|
79092
79479
|
activeTaskCreatedAt = Date.now();
|
|
79093
79480
|
truncationStore.startTask();
|
|
79094
79481
|
}
|
|
@@ -79288,6 +79675,7 @@ ${preview.text}` } : {}
|
|
|
79288
79675
|
const mailSearch = mailCollection === void 0 ? void 0 : await resolveMailSearch(config2);
|
|
79289
79676
|
const searchIndexes = search?.opensearch !== void 0 ? await search.opensearch.listIndexes().then((list) => list.map((i) => i.name)).catch(() => []) : [];
|
|
79290
79677
|
await refreshSkills();
|
|
79678
|
+
const codebaseInstructions = renderCodebaseInstructions(await readCodebaseInstructions(codebaseInstructionsFile));
|
|
79291
79679
|
const activeMode = findMode(config2.modeId);
|
|
79292
79680
|
juniorTurnWithoutExpert = activeMode.id === "junior" && schedule === void 0;
|
|
79293
79681
|
const scheduledGuidance = schedule === void 0 ? void 0 : scheduledRunGuidance(schedule, filterToolsForSchedule(currentToolRegistry(void 0, void 0, void 0, void 0, false).list(), schedule).map((tool) => tool.name).filter((name) => name !== "attempt_completion"));
|
|
@@ -79317,6 +79705,7 @@ ${preview.text}` } : {}
|
|
|
79317
79705
|
].filter((section) => section.length > 0).join("\n\n") : renderSkillsForPrompt(turnSkills),
|
|
79318
79706
|
skillsSearchable,
|
|
79319
79707
|
canWriteSkills: skillsDir !== void 0,
|
|
79708
|
+
codebaseInstructions,
|
|
79320
79709
|
// Last in the prompt, and the most specific thing in it — see `agent/plan.ts`.
|
|
79321
79710
|
...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {},
|
|
79322
79711
|
// Only when a pool actually exists: telling the model about a tool it has not been given
|
|
@@ -79842,7 +80231,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
79842
80231
|
try {
|
|
79843
80232
|
const { config: config2 } = await configManager.load();
|
|
79844
80233
|
const profiles = config2.profiles ?? [];
|
|
79845
|
-
const id = input.id ?? (0,
|
|
80234
|
+
const id = input.id ?? (0, import_node_crypto14.randomUUID)();
|
|
79846
80235
|
const existing = profiles.find((p) => p.id === id);
|
|
79847
80236
|
const auth2 = await buildAuthFromInput(input, id);
|
|
79848
80237
|
const saved = {
|
|
@@ -79880,7 +80269,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
79880
80269
|
post({ type: "error", message: `Profile "${id}" no longer exists.` });
|
|
79881
80270
|
return;
|
|
79882
80271
|
}
|
|
79883
|
-
const newId = (0,
|
|
80272
|
+
const newId = (0, import_node_crypto14.randomUUID)();
|
|
79884
80273
|
async function copySecret(fromRef, toRef) {
|
|
79885
80274
|
if (fromRef === void 0)
|
|
79886
80275
|
return false;
|
|
@@ -80697,7 +81086,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
80697
81086
|
return { mode: cachedSearchScope, author: cachedAttribution.author };
|
|
80698
81087
|
}
|
|
80699
81088
|
function currentProjectNames() {
|
|
80700
|
-
const names = [cachedAttribution.project, workspaceRoot !== void 0 ?
|
|
81089
|
+
const names = [cachedAttribution.project, workspaceRoot !== void 0 ? import_node_path49.default.basename(workspaceRoot) : void 0];
|
|
80701
81090
|
return names.filter((name) => name !== void 0 && name.length > 0);
|
|
80702
81091
|
}
|
|
80703
81092
|
function indexProject(config2) {
|
|
@@ -80800,8 +81189,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
80800
81189
|
limit: limits.limit,
|
|
80801
81190
|
previewChars: limits.previewChars
|
|
80802
81191
|
});
|
|
80803
|
-
for (const
|
|
80804
|
-
skipped.add(
|
|
81192
|
+
for (const path60 of answer.skipped ?? [])
|
|
81193
|
+
skipped.add(path60);
|
|
80805
81194
|
return { messages: answer.messages, truncated: answer.truncated };
|
|
80806
81195
|
},
|
|
80807
81196
|
...embedder !== void 0 && search !== void 0 && collection !== void 0 ? {
|
|
@@ -81100,9 +81489,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81100
81489
|
});
|
|
81101
81490
|
const all = result.folders.map((entry) => entry.path);
|
|
81102
81491
|
const wanted = new Set(chosen);
|
|
81103
|
-
for (const
|
|
81104
|
-
if (chosen.some((root) =>
|
|
81105
|
-
wanted.add(
|
|
81492
|
+
for (const path60 of all) {
|
|
81493
|
+
if (chosen.some((root) => path60 === root || path60.startsWith(`${root}\\`)))
|
|
81494
|
+
wanted.add(path60);
|
|
81106
81495
|
}
|
|
81107
81496
|
return [...wanted];
|
|
81108
81497
|
} catch {
|
|
@@ -81110,10 +81499,10 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81110
81499
|
}
|
|
81111
81500
|
}
|
|
81112
81501
|
async function handleRequestOutlookFolders(depth, force = false) {
|
|
81113
|
-
const cachePath =
|
|
81502
|
+
const cachePath = import_node_path49.default.join(storageDir, "outlook-folders.json");
|
|
81114
81503
|
let served = false;
|
|
81115
81504
|
try {
|
|
81116
|
-
const cached2 = JSON.parse(await
|
|
81505
|
+
const cached2 = JSON.parse(await import_promises27.default.readFile(cachePath, "utf8"));
|
|
81117
81506
|
post({
|
|
81118
81507
|
type: "outlookFolders",
|
|
81119
81508
|
folders: cached2.folders,
|
|
@@ -81130,8 +81519,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81130
81519
|
const scannedAt = Date.now();
|
|
81131
81520
|
post({ type: "outlookFolders", folders: result.folders, scannedAt });
|
|
81132
81521
|
try {
|
|
81133
|
-
await
|
|
81134
|
-
await
|
|
81522
|
+
await import_promises27.default.mkdir(import_node_path49.default.dirname(cachePath), { recursive: true });
|
|
81523
|
+
await import_promises27.default.writeFile(cachePath, JSON.stringify({ scannedAt, folders: result.folders }), "utf8");
|
|
81135
81524
|
} catch {
|
|
81136
81525
|
}
|
|
81137
81526
|
} catch (error51) {
|
|
@@ -81375,7 +81764,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81375
81764
|
if (auth2.clientId === void 0 || auth2.clientSecretRef === void 0) {
|
|
81376
81765
|
throw new AtlassianError("AutoSys uses the API gateway but the client id or secret is missing. Settings \u2192 DevOps \u2192 AutoSys \u2192 API gateway: enter both and save.");
|
|
81377
81766
|
}
|
|
81378
|
-
const key2 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0,
|
|
81767
|
+
const key2 = JSON.stringify({ auth: auth2, baseUrl: config2.autosys?.baseUrl, tls: tls2 === void 0 ? 0 : (0, import_node_crypto14.createHash)("sha256").update(JSON.stringify(tls2)).digest("hex") });
|
|
81379
81768
|
if (autosysGateway?.key === key2)
|
|
81380
81769
|
return autosysGateway.strategy;
|
|
81381
81770
|
const secretRef = auth2.clientSecretRef;
|
|
@@ -81796,8 +82185,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81796
82185
|
approvalStamps.set("machine", stamp2);
|
|
81797
82186
|
}
|
|
81798
82187
|
for (const dir of python.toolDirectories()) {
|
|
81799
|
-
const file2 =
|
|
81800
|
-
const stamp2 = await
|
|
82188
|
+
const file2 = import_node_path49.default.join(dir, REGISTRY_FILE);
|
|
82189
|
+
const stamp2 = await import_promises27.default.stat(file2).then((stat) => stat.mtimeMs, () => 0);
|
|
81801
82190
|
if (approvalStamps.has(file2) && approvalStamps.get(file2) !== stamp2)
|
|
81802
82191
|
changed = true;
|
|
81803
82192
|
approvalStamps.set(file2, stamp2);
|
|
@@ -81878,7 +82267,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81878
82267
|
try {
|
|
81879
82268
|
const available = await listSkillImages(skill.filePath, {
|
|
81880
82269
|
readdir: async (dir) => {
|
|
81881
|
-
const entries = await
|
|
82270
|
+
const entries = await import_promises27.default.readdir(dir, { withFileTypes: true });
|
|
81882
82271
|
return entries.map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
|
|
81883
82272
|
}
|
|
81884
82273
|
});
|
|
@@ -81887,7 +82276,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81887
82276
|
return;
|
|
81888
82277
|
}
|
|
81889
82278
|
const folder = skill.filePath.slice(0, skill.filePath.length - "SKILL.md".length);
|
|
81890
|
-
const bytes = await
|
|
82279
|
+
const bytes = await import_promises27.default.readFile(import_node_path49.default.join(folder, SKILL_IMAGE_DIR, image));
|
|
81891
82280
|
const dataUri = skillImageDataUri(image, bytes);
|
|
81892
82281
|
post({
|
|
81893
82282
|
type: "skillImage",
|
|
@@ -81982,7 +82371,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
81982
82371
|
for (const skill of skills) {
|
|
81983
82372
|
let body = "";
|
|
81984
82373
|
try {
|
|
81985
|
-
body = await
|
|
82374
|
+
body = await import_promises27.default.readFile(skill.filePath, "utf8");
|
|
81986
82375
|
} catch {
|
|
81987
82376
|
continue;
|
|
81988
82377
|
}
|
|
@@ -82080,7 +82469,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82080
82469
|
return { name: skill.name, state: "missing" };
|
|
82081
82470
|
let body;
|
|
82082
82471
|
try {
|
|
82083
|
-
body = await
|
|
82472
|
+
body = await import_promises27.default.readFile(skill.filePath, "utf8");
|
|
82084
82473
|
} catch {
|
|
82085
82474
|
return { name: skill.name, state: "stale" };
|
|
82086
82475
|
}
|
|
@@ -82215,17 +82604,17 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82215
82604
|
}
|
|
82216
82605
|
function docsFingerprintPath(index, storeId, kind) {
|
|
82217
82606
|
const suffix = kind === void 0 ? "docs" : `docs.${kind}`;
|
|
82218
|
-
return
|
|
82607
|
+
return import_node_path49.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.${suffix}.json`);
|
|
82219
82608
|
}
|
|
82220
82609
|
function manifestKey(index, storeId) {
|
|
82221
82610
|
return `${index}@${storeId}`;
|
|
82222
82611
|
}
|
|
82223
82612
|
function manifestPath(index, storeId) {
|
|
82224
|
-
return
|
|
82613
|
+
return import_node_path49.default.join(manifestsRoot, "index-manifests", `${manifestKey(index, storeId)}.json`);
|
|
82225
82614
|
}
|
|
82226
82615
|
async function readDocsFingerprint(index, storeId, kind) {
|
|
82227
82616
|
try {
|
|
82228
|
-
const raw = JSON.parse(await
|
|
82617
|
+
const raw = JSON.parse(await import_promises27.default.readFile(docsFingerprintPath(index, storeId, kind), "utf8"));
|
|
82229
82618
|
return typeof raw.fingerprint === "string" ? raw.fingerprint : void 0;
|
|
82230
82619
|
} catch {
|
|
82231
82620
|
return void 0;
|
|
@@ -82251,7 +82640,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82251
82640
|
});
|
|
82252
82641
|
const wanted = options.kind;
|
|
82253
82642
|
const entries = wanted === void 0 ? all : all.filter((entry) => entry.kind === wanted);
|
|
82254
|
-
const fingerprint = (0,
|
|
82643
|
+
const fingerprint = (0, import_node_crypto14.createHash)("sha256").update(`${wanted ?? "all"}:${embedder.model}:${String(embedder.dimensions)}`).update(entries.map((entry) => `${entry.id}\0${entry.text}`).join("")).digest("hex");
|
|
82255
82644
|
if (!options.force && fingerprint === await readDocsFingerprint(index, search.id, wanted)) {
|
|
82256
82645
|
return { unchanged: true, index, indexed: entries.length };
|
|
82257
82646
|
}
|
|
@@ -82285,10 +82674,10 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82285
82674
|
}
|
|
82286
82675
|
options.report?.("Writing", { done: 0, total: documents.length });
|
|
82287
82676
|
await writer.upsert(index, documents);
|
|
82288
|
-
await
|
|
82677
|
+
await import_promises27.default.mkdir(import_node_path49.default.dirname(docsFingerprintPath(index, search.id, wanted)), {
|
|
82289
82678
|
recursive: true
|
|
82290
82679
|
});
|
|
82291
|
-
await
|
|
82680
|
+
await import_promises27.default.writeFile(docsFingerprintPath(index, search.id, wanted), JSON.stringify({ fingerprint, indexedAt: Date.now(), count: documents.length }), "utf8");
|
|
82292
82681
|
return { indexed: documents.length, index };
|
|
82293
82682
|
} catch (error51) {
|
|
82294
82683
|
return { error: error51 instanceof Error ? error51.message : String(error51) };
|
|
@@ -82459,7 +82848,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82459
82848
|
}
|
|
82460
82849
|
post({ type: "storeSync", running: true, fromLabel: source.label });
|
|
82461
82850
|
const sourcePath = manifestPath(index, fromId);
|
|
82462
|
-
const manifest = await
|
|
82851
|
+
const manifest = await import_promises27.default.readFile(sourcePath, "utf8").then((raw) => JSON.parse(raw)).catch(() => void 0);
|
|
82463
82852
|
const result = await syncVectorStores({
|
|
82464
82853
|
from: createVectorIndexWriter(httpClient, source, await vectorStoreConnectionFor(source, fromId)),
|
|
82465
82854
|
to: createVectorIndexWriter(httpClient, target.store, await vectorStoreConnectionFor(target.store, target.id)),
|
|
@@ -82475,8 +82864,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82475
82864
|
});
|
|
82476
82865
|
if (manifest !== void 0) {
|
|
82477
82866
|
const targetPath = manifestPath(index, target.id);
|
|
82478
|
-
await
|
|
82479
|
-
await
|
|
82867
|
+
await import_promises27.default.mkdir(import_node_path49.default.dirname(targetPath), { recursive: true });
|
|
82868
|
+
await import_promises27.default.writeFile(targetPath, JSON.stringify(manifest), "utf8");
|
|
82480
82869
|
}
|
|
82481
82870
|
post({ type: "storeSync", running: false, copied: result.copied, fromLabel: source.label });
|
|
82482
82871
|
} catch (error51) {
|
|
@@ -82524,7 +82913,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82524
82913
|
type: "project",
|
|
82525
82914
|
hasWorkspace: workspaceRoot !== void 0,
|
|
82526
82915
|
...configured !== void 0 ? { configured } : {},
|
|
82527
|
-
...workspaceRoot !== void 0 ? { folder:
|
|
82916
|
+
...workspaceRoot !== void 0 ? { folder: import_node_path49.default.basename(workspaceRoot) } : {},
|
|
82528
82917
|
...author !== void 0 ? { author } : {},
|
|
82529
82918
|
...index !== void 0 ? { indexName: index } : {},
|
|
82530
82919
|
...ownerConfigured !== void 0 && ownerConfigured.length > 0 ? { ownerConfigured } : {},
|
|
@@ -82664,8 +83053,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82664
83053
|
if (workspaceRoot === void 0)
|
|
82665
83054
|
return found2;
|
|
82666
83055
|
const root = workspaceRoot;
|
|
82667
|
-
const relative =
|
|
82668
|
-
if (relative.startsWith("..") ||
|
|
83056
|
+
const relative = import_node_path49.default.relative(root, folder);
|
|
83057
|
+
if (relative.startsWith("..") || import_node_path49.default.isAbsolute(relative))
|
|
82669
83058
|
return found2;
|
|
82670
83059
|
const output = await new Promise((resolve) => {
|
|
82671
83060
|
const child = (0, import_node_child_process14.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
|
|
@@ -82682,7 +83071,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82682
83071
|
if (line.startsWith("@@"))
|
|
82683
83072
|
author = line.slice(2).trim();
|
|
82684
83073
|
else if (line.trim().length > 0 && author !== void 0 && author.length > 0) {
|
|
82685
|
-
found2.set(normalizeForComparison(
|
|
83074
|
+
found2.set(normalizeForComparison(import_node_path49.default.resolve(root, line.trim())), author);
|
|
82686
83075
|
}
|
|
82687
83076
|
}
|
|
82688
83077
|
return found2;
|
|
@@ -82697,14 +83086,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82697
83086
|
const toolFolders = ours([folders.toolsDir ?? localTools, localTools]);
|
|
82698
83087
|
const candidates = [];
|
|
82699
83088
|
const consider = async (kind, name, filePath, folder, location) => {
|
|
82700
|
-
const source = await
|
|
83089
|
+
const source = await import_promises27.default.readFile(filePath, "utf8");
|
|
82701
83090
|
const missing = missingAttribution(kind, source);
|
|
82702
83091
|
if (missing.length === 0)
|
|
82703
83092
|
return;
|
|
82704
83093
|
if (kind === "skill" && !/^---\r?\n/.test(source))
|
|
82705
83094
|
return;
|
|
82706
83095
|
const current = readAttribution(kind, source);
|
|
82707
|
-
const modified = (await
|
|
83096
|
+
const modified = (await import_promises27.default.stat(filePath)).mtime;
|
|
82708
83097
|
const automatic = {
|
|
82709
83098
|
...missing.includes("version") ? { version: 1 } : {},
|
|
82710
83099
|
...missing.includes("updated") ? { updated: attributionTimestamp(modified) } : {}
|
|
@@ -82726,7 +83115,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82726
83115
|
},
|
|
82727
83116
|
source,
|
|
82728
83117
|
folder,
|
|
82729
|
-
relative:
|
|
83118
|
+
relative: import_node_path49.default.relative(folder, filePath).split(import_node_path49.default.sep).join("/")
|
|
82730
83119
|
});
|
|
82731
83120
|
};
|
|
82732
83121
|
for (const folder of skillFolders) {
|
|
@@ -82737,14 +83126,14 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82737
83126
|
}
|
|
82738
83127
|
for (const folder of toolFolders) {
|
|
82739
83128
|
const location = samePath(folder, localTools) ? "project" : "bucket";
|
|
82740
|
-
const entries = await
|
|
83129
|
+
const entries = await import_promises27.default.readdir(folder).catch(() => []);
|
|
82741
83130
|
for (const entry of entries) {
|
|
82742
83131
|
if (entry.startsWith(".") || !entry.endsWith(".py"))
|
|
82743
83132
|
continue;
|
|
82744
83133
|
const name = entry.slice(0, -3);
|
|
82745
83134
|
if (!isValidToolName(name))
|
|
82746
83135
|
continue;
|
|
82747
|
-
await consider("tool", name,
|
|
83136
|
+
await consider("tool", name, import_node_path49.default.join(folder, entry), folder, location);
|
|
82748
83137
|
}
|
|
82749
83138
|
}
|
|
82750
83139
|
const readOnly = skills.filter((skill) => skill.sourceDir !== void 0 && !skillFolders.some((folder) => samePath(folder, skill.sourceDir))).length;
|
|
@@ -82776,7 +83165,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82776
83165
|
} catch {
|
|
82777
83166
|
}
|
|
82778
83167
|
}
|
|
82779
|
-
const gitAuthor = gitAuthors.get(normalizeForComparison(
|
|
83168
|
+
const gitAuthor = gitAuthors.get(normalizeForComparison(import_node_path49.default.resolve(candidate.entry.filePath)));
|
|
82780
83169
|
if (gitAuthor !== void 0) {
|
|
82781
83170
|
candidate.entry.suggestion = { author: gitAuthor, source: "git: the commit that added this file" };
|
|
82782
83171
|
}
|
|
@@ -82813,7 +83202,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82813
83202
|
const next = fillAttribution(candidate.entry.kind, candidate.source, values);
|
|
82814
83203
|
if (next === candidate.source)
|
|
82815
83204
|
continue;
|
|
82816
|
-
await
|
|
83205
|
+
await import_promises27.default.writeFile(candidate.entry.filePath, next, "utf8");
|
|
82817
83206
|
written += 1;
|
|
82818
83207
|
if (candidate.entry.kind === "tool" && candidate.entry.approved === true) {
|
|
82819
83208
|
await repinApproval(candidate.folder, candidate.entry.name, candidate.source, next);
|
|
@@ -82885,7 +83274,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82885
83274
|
aliases: plan2.kind === "codebase" ? codebaseAliases(config2) : plan2.kind === "skills" ? skillAliases(config2) : [],
|
|
82886
83275
|
onProgress: (count3) => post({ type: "indexRenames", running: true, plans, store, current: plan2.to, copied: count3 })
|
|
82887
83276
|
});
|
|
82888
|
-
await copyBookkeeping(
|
|
83277
|
+
await copyBookkeeping(import_node_path49.default.join(manifestsRoot, "index-manifests"), plan2.from, plan2.to, search.id);
|
|
82889
83278
|
done.push({ ...plan2, copied });
|
|
82890
83279
|
}
|
|
82891
83280
|
post({ type: "indexRenames", running: false, plans: [], store, done });
|
|
@@ -82898,7 +83287,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82898
83287
|
const legacy = codebaseIndexName(config2, false);
|
|
82899
83288
|
if (current === void 0 || legacy === void 0 || current === legacy)
|
|
82900
83289
|
return;
|
|
82901
|
-
const exists2 = async (file2) =>
|
|
83290
|
+
const exists2 = async (file2) => import_promises27.default.stat(file2).then(() => true, () => false);
|
|
82902
83291
|
if (await exists2(manifestPath(current, search.id)))
|
|
82903
83292
|
return;
|
|
82904
83293
|
if (!await exists2(manifestPath(legacy, search.id)))
|
|
@@ -82915,7 +83304,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82915
83304
|
project: projectName(config2, workspaceRoot),
|
|
82916
83305
|
aliases: codebaseAliases(config2)
|
|
82917
83306
|
});
|
|
82918
|
-
await copyBookkeeping(
|
|
83307
|
+
await copyBookkeeping(import_node_path49.default.join(manifestsRoot, "index-manifests"), legacy, current, search.id);
|
|
82919
83308
|
post({ type: "indexRenames", running: false, plans: [], done: [{ kind: "codebase", from: legacy, to: current, copied }] });
|
|
82920
83309
|
logger.info(`copied ${String(copied)} chunks from ${legacy} to ${current} rather than re-embedding them`);
|
|
82921
83310
|
}
|
|
@@ -82933,7 +83322,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82933
83322
|
const writer = createVectorIndexWriter(httpClient, search.store, await vectorStoreConnectionFor(search.store, search.id));
|
|
82934
83323
|
const paths = await writer.listPaths(index, { signal });
|
|
82935
83324
|
await deleteInBatches(writer, index, paths, (done, total) => reportIndexing("codebase", "Removing", { done, total }), signal);
|
|
82936
|
-
await
|
|
83325
|
+
await import_promises27.default.rm(manifestPath(index, search.id), { force: true });
|
|
82937
83326
|
post({
|
|
82938
83327
|
type: "indexResult",
|
|
82939
83328
|
result: {
|
|
@@ -82972,7 +83361,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
82972
83361
|
const existing = kind === void 0 ? all : all.filter((id) => parseDocEntryId(id)?.kind === kind);
|
|
82973
83362
|
if (existing.length > 0)
|
|
82974
83363
|
await writer.deleteByPaths(index, existing);
|
|
82975
|
-
await Promise.all([void 0, ...kind === void 0 ? ["tool", "skill"] : [kind]].map((each) =>
|
|
83364
|
+
await Promise.all([void 0, ...kind === void 0 ? ["tool", "skill"] : [kind]].map((each) => import_promises27.default.rm(docsFingerprintPath(index, search.id, each), { force: true })));
|
|
82976
83365
|
post({ type: "docsIndexed", indexed: 0, index });
|
|
82977
83366
|
logger.info(`cleared ${String(existing.length)} documentation entries from "${index}"`);
|
|
82978
83367
|
} catch (error51) {
|
|
@@ -83081,8 +83470,8 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83081
83470
|
denylist,
|
|
83082
83471
|
manifest,
|
|
83083
83472
|
saveManifest: async (next) => {
|
|
83084
|
-
await
|
|
83085
|
-
await
|
|
83473
|
+
await import_promises27.default.mkdir(import_node_path49.default.dirname(manifestFile), { recursive: true });
|
|
83474
|
+
await import_promises27.default.writeFile(manifestFile, JSON.stringify(next), "utf8");
|
|
83086
83475
|
},
|
|
83087
83476
|
...isIgnored2 !== void 0 ? { isIgnored: isIgnored2 } : {},
|
|
83088
83477
|
/*
|
|
@@ -83110,7 +83499,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83110
83499
|
}
|
|
83111
83500
|
async function loadIndexManifest(file2, embedder) {
|
|
83112
83501
|
try {
|
|
83113
|
-
return JSON.parse(await
|
|
83502
|
+
return JSON.parse(await import_promises27.default.readFile(file2, "utf8"));
|
|
83114
83503
|
} catch {
|
|
83115
83504
|
return {
|
|
83116
83505
|
model: embedder.model,
|
|
@@ -83128,9 +83517,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83128
83517
|
}
|
|
83129
83518
|
const usageLog = new UsageLog(storageDir);
|
|
83130
83519
|
const usageInstance = usageInstanceId(storageDir);
|
|
83131
|
-
const usageProfileFile =
|
|
83132
|
-
const legacyBackfillFile =
|
|
83133
|
-
const usageDir =
|
|
83520
|
+
const usageProfileFile = import_node_path49.default.join(storageDir, "usage-profile.json");
|
|
83521
|
+
const legacyBackfillFile = import_node_path49.default.join(storageDir, "usage-backfill.json");
|
|
83522
|
+
const usageDir = import_node_path49.default.join(storageDir, "usage");
|
|
83134
83523
|
const toolStartedAt = /* @__PURE__ */ new Map();
|
|
83135
83524
|
let usagePushTimer;
|
|
83136
83525
|
let usagePushing;
|
|
@@ -83148,7 +83537,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83148
83537
|
return (request) => runFastFs(exe, request);
|
|
83149
83538
|
}
|
|
83150
83539
|
function skillAtPath(requested2) {
|
|
83151
|
-
const absolute =
|
|
83540
|
+
const absolute = import_node_path49.default.isAbsolute(requested2) ? requested2 : workspaceRoot === void 0 ? void 0 : import_node_path49.default.resolve(workspaceRoot, requested2);
|
|
83152
83541
|
if (absolute === void 0)
|
|
83153
83542
|
return void 0;
|
|
83154
83543
|
return skills.find((skill) => samePath(skill.filePath, absolute));
|
|
@@ -83221,7 +83610,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83221
83610
|
const folder = chosen.path?.trim();
|
|
83222
83611
|
if (folder === void 0 || folder.length === 0)
|
|
83223
83612
|
return { problem: "The shared folder has no path." };
|
|
83224
|
-
if (!
|
|
83613
|
+
if (!import_node_path49.default.isAbsolute(folder))
|
|
83225
83614
|
return { problem: `"${folder}" is not an absolute path. Use the full path of a folder everybody can reach, such as a network share.` };
|
|
83226
83615
|
const helper = usageHelper();
|
|
83227
83616
|
return { store: new FolderShardStore(folder, ...helper !== void 0 ? [helper] : []), target };
|
|
@@ -83250,7 +83639,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83250
83639
|
}
|
|
83251
83640
|
async function readUsageBackfill() {
|
|
83252
83641
|
try {
|
|
83253
|
-
const text = await
|
|
83642
|
+
const text = await import_promises27.default.readFile(import_node_path49.default.join(usageDir, "backfill.json"), "utf8").catch(() => import_promises27.default.readFile(legacyBackfillFile, "utf8"));
|
|
83254
83643
|
const saved = JSON.parse(text);
|
|
83255
83644
|
if (typeof saved.at !== "number")
|
|
83256
83645
|
return void 0;
|
|
@@ -83266,7 +83655,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83266
83655
|
legacyDoneFile: legacyBackfillFile,
|
|
83267
83656
|
run: async (before) => {
|
|
83268
83657
|
const status2 = python.status();
|
|
83269
|
-
return backfillFromTasks(
|
|
83658
|
+
return backfillFromTasks(import_node_path49.default.join(storageDir, "tasks"), {
|
|
83270
83659
|
user: cachedAttribution.author ?? "unknown",
|
|
83271
83660
|
project: cachedAttribution.project,
|
|
83272
83661
|
workspaceRoot,
|
|
@@ -83326,7 +83715,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83326
83715
|
}
|
|
83327
83716
|
async function readLocalProfile() {
|
|
83328
83717
|
try {
|
|
83329
|
-
const saved = JSON.parse(await
|
|
83718
|
+
const saved = JSON.parse(await import_promises27.default.readFile(usageProfileFile, "utf8"));
|
|
83330
83719
|
return saved.user === (cachedAttribution.author ?? "unknown") ? cleanProfile(saved.profile) : void 0;
|
|
83331
83720
|
} catch {
|
|
83332
83721
|
return void 0;
|
|
@@ -83362,9 +83751,9 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83362
83751
|
});
|
|
83363
83752
|
async function contentHash(file2) {
|
|
83364
83753
|
try {
|
|
83365
|
-
const text = (await
|
|
83754
|
+
const text = (await import_promises27.default.readFile(file2, "utf8")).replace(/\r\n/g, "\n");
|
|
83366
83755
|
const meaningful = text.split("\n").filter((line) => !/^(author|project|version|updated)\s*:/i.test(line) && !/^__(author|project|version|updated)__\s*=/.test(line)).join("\n").trim();
|
|
83367
|
-
return (0,
|
|
83756
|
+
return (0, import_node_crypto14.createHash)("sha256").update(meaningful).digest("hex").slice(0, 16);
|
|
83368
83757
|
} catch {
|
|
83369
83758
|
return void 0;
|
|
83370
83759
|
}
|
|
@@ -83439,18 +83828,18 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83439
83828
|
kind: "tool",
|
|
83440
83829
|
name: issue2.name,
|
|
83441
83830
|
filePath: issue2.filePath,
|
|
83442
|
-
deletable: samePath(
|
|
83443
|
-
location: where(
|
|
83831
|
+
deletable: samePath(import_node_path49.default.dirname(issue2.filePath), status2.toolsDir),
|
|
83832
|
+
location: where(import_node_path49.default.dirname(issue2.filePath), status2.toolsDir),
|
|
83444
83833
|
issue: issue2.kind === "unapproved" ? "waiting for approval" : issue2.kind === "hash-mismatch" ? "changed since approval" : issue2.detail.split("\n")[0] ?? "not loaded"
|
|
83445
83834
|
});
|
|
83446
83835
|
}
|
|
83447
83836
|
return items;
|
|
83448
83837
|
}
|
|
83449
|
-
const usageDirectoryFile =
|
|
83838
|
+
const usageDirectoryFile = import_node_path49.default.join(storageDir, "usage-directory.json");
|
|
83450
83839
|
let directoryRunning;
|
|
83451
83840
|
async function readDirectoryCache() {
|
|
83452
83841
|
try {
|
|
83453
|
-
const saved = JSON.parse(await
|
|
83842
|
+
const saved = JSON.parse(await import_promises27.default.readFile(usageDirectoryFile, "utf8"));
|
|
83454
83843
|
return { ...saved, people: saved.people ?? {} };
|
|
83455
83844
|
} catch {
|
|
83456
83845
|
return { people: {} };
|
|
@@ -83778,7 +84167,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
83778
84167
|
let indexedFiles = 0;
|
|
83779
84168
|
if (index !== void 0) {
|
|
83780
84169
|
try {
|
|
83781
|
-
const manifest = JSON.parse(await
|
|
84170
|
+
const manifest = JSON.parse(await import_promises27.default.readFile(import_node_path49.default.join(manifestsRoot, "index-manifests", `${index}.json`), "utf8"));
|
|
83782
84171
|
indexedFiles = Object.keys(manifest.files ?? {}).length;
|
|
83783
84172
|
} catch {
|
|
83784
84173
|
}
|
|
@@ -84050,7 +84439,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84050
84439
|
return;
|
|
84051
84440
|
}
|
|
84052
84441
|
const { config: config2 } = await configManager.load();
|
|
84053
|
-
const id = input.id ?? (0,
|
|
84442
|
+
const id = input.id ?? (0, import_node_crypto14.randomUUID)();
|
|
84054
84443
|
if (input.username !== void 0 && input.username.length > 0)
|
|
84055
84444
|
await secrets.set(searchUserRefFor(id), input.username);
|
|
84056
84445
|
if (input.password !== void 0 && input.password.length > 0)
|
|
@@ -84228,7 +84617,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84228
84617
|
const source = await ui.showOpenDialog({ kind: "file", extensions: ["json"] });
|
|
84229
84618
|
if (source === void 0)
|
|
84230
84619
|
return;
|
|
84231
|
-
const imported = parseConfig(await
|
|
84620
|
+
const imported = parseConfig(await import_promises27.default.readFile(source, "utf8"));
|
|
84232
84621
|
post({
|
|
84233
84622
|
type: "shareSections",
|
|
84234
84623
|
direction: "import",
|
|
@@ -84250,7 +84639,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84250
84639
|
if (archive === void 0)
|
|
84251
84640
|
return;
|
|
84252
84641
|
try {
|
|
84253
|
-
await
|
|
84642
|
+
await import_promises27.default.access(archive.path);
|
|
84254
84643
|
} catch {
|
|
84255
84644
|
post({
|
|
84256
84645
|
type: "error",
|
|
@@ -84262,7 +84651,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84262
84651
|
const target = await ui.showSaveDialog({ defaultName: archive.defaultName, extensions: ["zip"] });
|
|
84263
84652
|
if (target === void 0)
|
|
84264
84653
|
return;
|
|
84265
|
-
await
|
|
84654
|
+
await import_promises27.default.copyFile(archive.path, target);
|
|
84266
84655
|
ui.showInfo(`Saved the Light Code source to ${target}. Extract it, open the folder in VS Code, and follow START_HERE.md \u2014 it builds as it stands.`);
|
|
84267
84656
|
} catch (error51) {
|
|
84268
84657
|
post({ type: "error", message: `Could not save the source: ${error51 instanceof Error ? error51.message : String(error51)}` });
|
|
@@ -84279,7 +84668,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84279
84668
|
});
|
|
84280
84669
|
if (target === void 0)
|
|
84281
84670
|
return;
|
|
84282
|
-
await
|
|
84671
|
+
await import_promises27.default.writeFile(target, JSON.stringify(exported, null, 2), "utf8");
|
|
84283
84672
|
const written = describeSections(exported).filter((section) => section.present);
|
|
84284
84673
|
const needed = written.flatMap((section) => section.secretRefs);
|
|
84285
84674
|
ui.showInfo(needed.length === 0 ? `Exported ${String(written.length)} section(s) to ${target}.` : `Exported ${String(written.length)} section(s) to ${target}. Whoever imports it will need to enter: ${needed.join(", ")}.`);
|
|
@@ -84292,7 +84681,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84292
84681
|
const source = request.path ?? await ui.showOpenDialog({ kind: "file", extensions: ["json"] });
|
|
84293
84682
|
if (source === void 0)
|
|
84294
84683
|
return;
|
|
84295
|
-
const raw = await
|
|
84684
|
+
const raw = await import_promises27.default.readFile(source, "utf8");
|
|
84296
84685
|
const imported = parseConfig(raw);
|
|
84297
84686
|
const chosen = request.sections ?? SHARE_SECTIONS.map((section) => section.id);
|
|
84298
84687
|
const { config: existing } = await configManager.load();
|
|
@@ -84346,7 +84735,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84346
84735
|
if (changeLedger !== void 0) {
|
|
84347
84736
|
const shared = await changeLedger.othersSince(targets, taskCheckpoint.createdAt);
|
|
84348
84737
|
if (shared.size > 0) {
|
|
84349
|
-
const shown2 = (file2) =>
|
|
84738
|
+
const shown2 = (file2) => import_node_path49.default.relative(workspaceRoot ?? "", file2).split(import_node_path49.default.sep).join("/");
|
|
84350
84739
|
const detail = [...shared].map(([file2, chats]) => `${shown2(file2)} (${chats.join(", ")})`).join("; ");
|
|
84351
84740
|
const all = await ui.showActionMessage(`Another chat also changed ${String(shared.size)} of these files after this chat started: ${detail}. Rolling them back would undo that chat's changes too.`, "Roll those back too", "warning");
|
|
84352
84741
|
if (!all) {
|
|
@@ -84544,7 +84933,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84544
84933
|
const pathRequest = pendingPathApprovals.get(id);
|
|
84545
84934
|
userGate.resolve(id, "approve");
|
|
84546
84935
|
if (pathRequest !== void 0) {
|
|
84547
|
-
const folder =
|
|
84936
|
+
const folder = import_node_path49.default.dirname(pathRequest);
|
|
84548
84937
|
sessionPathGrants.add(normalizeForComparison(pathRequest));
|
|
84549
84938
|
if (scope === "folder" && !cachedReadRoots.includes(folder)) {
|
|
84550
84939
|
const { config: config2 } = await configManager.load();
|
|
@@ -84588,7 +84977,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84588
84977
|
const next = { ...servers, [name]: change(existing) };
|
|
84589
84978
|
await configManager.save("user", { mcpServers: next });
|
|
84590
84979
|
setMcpServersState(next);
|
|
84591
|
-
await
|
|
84980
|
+
await configureMcp(next);
|
|
84592
84981
|
}
|
|
84593
84982
|
async function handleSetToolTimeoutFor(name, seconds) {
|
|
84594
84983
|
try {
|
|
@@ -84708,7 +85097,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84708
85097
|
}
|
|
84709
85098
|
try {
|
|
84710
85099
|
await configManager.save("user", { mcpServers: result.data });
|
|
84711
|
-
await
|
|
85100
|
+
await configureMcp(result.data);
|
|
84712
85101
|
setMcpServersState(result.data);
|
|
84713
85102
|
postMcp();
|
|
84714
85103
|
await mcp.ensureConnected();
|
|
@@ -84734,7 +85123,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84734
85123
|
}
|
|
84735
85124
|
await configManager.save("user", { mcpServers: result.data });
|
|
84736
85125
|
setMcpServersState(result.data);
|
|
84737
|
-
await
|
|
85126
|
+
await configureMcp(result.data);
|
|
84738
85127
|
postMcp();
|
|
84739
85128
|
post({ type: "mcpServerSaved", name });
|
|
84740
85129
|
await mcp.ensureConnected();
|
|
@@ -84745,7 +85134,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84745
85134
|
async function handleProbePythonEnv(venvDir, script) {
|
|
84746
85135
|
const exists2 = async (candidate) => {
|
|
84747
85136
|
try {
|
|
84748
|
-
return (await
|
|
85137
|
+
return (await import_promises27.default.stat(candidate)).isFile();
|
|
84749
85138
|
} catch {
|
|
84750
85139
|
return false;
|
|
84751
85140
|
}
|
|
@@ -84784,10 +85173,10 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84784
85173
|
});
|
|
84785
85174
|
return;
|
|
84786
85175
|
}
|
|
84787
|
-
let dir =
|
|
85176
|
+
let dir = import_node_path49.default.dirname(import_node_path49.default.resolve(scriptPath));
|
|
84788
85177
|
for (let depth = 0; depth < 3; depth++) {
|
|
84789
85178
|
for (const name of VENV_DIR_NAMES) {
|
|
84790
|
-
const candidate =
|
|
85179
|
+
const candidate = import_node_path49.default.join(dir, name);
|
|
84791
85180
|
const found2 = await search(candidate);
|
|
84792
85181
|
if (found2 !== void 0) {
|
|
84793
85182
|
post({
|
|
@@ -84799,7 +85188,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84799
85188
|
return;
|
|
84800
85189
|
}
|
|
84801
85190
|
}
|
|
84802
|
-
const parent =
|
|
85191
|
+
const parent = import_node_path49.default.dirname(dir);
|
|
84803
85192
|
if (parent === dir)
|
|
84804
85193
|
break;
|
|
84805
85194
|
dir = parent;
|
|
@@ -84847,7 +85236,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84847
85236
|
servers[copy] = { ...source, disabled: true };
|
|
84848
85237
|
await configManager.save("user", { mcpServers: servers });
|
|
84849
85238
|
setMcpServersState(servers);
|
|
84850
|
-
await
|
|
85239
|
+
await configureMcp(servers);
|
|
84851
85240
|
postMcp();
|
|
84852
85241
|
post({ type: "mcpServerSaved", name: copy });
|
|
84853
85242
|
} catch (error51) {
|
|
@@ -84863,7 +85252,7 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
84863
85252
|
delete servers[name];
|
|
84864
85253
|
await configManager.save("user", { mcpServers: servers });
|
|
84865
85254
|
setMcpServersState(servers);
|
|
84866
|
-
await
|
|
85255
|
+
await configureMcp(servers);
|
|
84867
85256
|
postMcp();
|
|
84868
85257
|
} catch (error51) {
|
|
84869
85258
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
@@ -85117,6 +85506,16 @@ ${redact(shown2, cachedSecretValues)}` }
|
|
|
85117
85506
|
reportFailure("handleClearCodebaseIndex", handleClearCodebaseIndex());
|
|
85118
85507
|
} else if (message4.type === "openStandingSkill") {
|
|
85119
85508
|
reportFailure("handleOpenStandingSkill", handleOpenStandingSkill());
|
|
85509
|
+
} else if (message4.type === "requestAddons") {
|
|
85510
|
+
reportFailure("postAddons", postAddons());
|
|
85511
|
+
} else if (message4.type === "enableAddon") {
|
|
85512
|
+
reportFailure("handleEnableAddon", handleEnableAddon(message4.package));
|
|
85513
|
+
} else if (message4.type === "removeAddon") {
|
|
85514
|
+
reportFailure("handleRemoveAddon", handleRemoveAddon(message4.server));
|
|
85515
|
+
} else if (message4.type === "saveAddonFolders") {
|
|
85516
|
+
reportFailure("handleSaveAddonFolders", handleSaveAddonFolders(message4.folders));
|
|
85517
|
+
} else if (message4.type === "openCodebaseInstructions") {
|
|
85518
|
+
reportFailure("handleOpenCodebaseInstructions", handleOpenCodebaseInstructions());
|
|
85120
85519
|
} else if (message4.type === "requestAtlassian") {
|
|
85121
85520
|
reportFailure("postAtlassian", postAtlassian());
|
|
85122
85521
|
} else if (message4.type === "saveAtlassian") {
|
|
@@ -85620,12 +86019,12 @@ Could not be drawn: ${entry.message}`);
|
|
|
85620
86019
|
let lastReportPath;
|
|
85621
86020
|
async function saveReport(title, contents) {
|
|
85622
86021
|
try {
|
|
85623
|
-
const directory =
|
|
85624
|
-
await
|
|
86022
|
+
const directory = import_node_path49.default.join(storageDir, "reports");
|
|
86023
|
+
await import_promises27.default.mkdir(directory, { recursive: true });
|
|
85625
86024
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
85626
86025
|
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
85627
|
-
const target =
|
|
85628
|
-
await
|
|
86026
|
+
const target = import_node_path49.default.join(directory, `${stamp2}${slug.length > 0 ? `-${slug}` : ""}.md`);
|
|
86027
|
+
await import_promises27.default.writeFile(target, `# ${title}
|
|
85629
86028
|
|
|
85630
86029
|
${contents}
|
|
85631
86030
|
`, "utf8");
|
|
@@ -85638,9 +86037,9 @@ ${contents}
|
|
|
85638
86037
|
}
|
|
85639
86038
|
async function pruneReports(directory) {
|
|
85640
86039
|
const keep = 100;
|
|
85641
|
-
const entries = (await
|
|
86040
|
+
const entries = (await import_promises27.default.readdir(directory)).filter((name) => name.endsWith(".md")).sort();
|
|
85642
86041
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
85643
|
-
await
|
|
86042
|
+
await import_promises27.default.rm(import_node_path49.default.join(directory, name), { force: true });
|
|
85644
86043
|
}
|
|
85645
86044
|
}
|
|
85646
86045
|
let scheduleTimer;
|
|
@@ -85713,7 +86112,7 @@ ${contents}
|
|
|
85713
86112
|
async function handleSaveSchedule(schedule) {
|
|
85714
86113
|
try {
|
|
85715
86114
|
const schedules = await loadSchedules();
|
|
85716
|
-
const id = schedule.id.length > 0 ? schedule.id : (0,
|
|
86115
|
+
const id = schedule.id.length > 0 ? schedule.id : (0, import_node_crypto14.createHash)("sha256").update(`${schedule.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
85717
86116
|
const armed = { ...schedule, id, nextRunAt: nextFireTime(schedule, Date.now()) };
|
|
85718
86117
|
await saveSchedules({ ...schedules, [id]: armed });
|
|
85719
86118
|
} catch (error51) {
|
|
@@ -85722,7 +86121,7 @@ ${contents}
|
|
|
85722
86121
|
}
|
|
85723
86122
|
async function createScheduleFromProposal(proposal) {
|
|
85724
86123
|
const schedules = await loadSchedules();
|
|
85725
|
-
const id = (0,
|
|
86124
|
+
const id = (0, import_node_crypto14.createHash)("sha256").update(`${proposal.name}:${String(Date.now())}`).digest("hex").slice(0, 12);
|
|
85726
86125
|
const schedule = {
|
|
85727
86126
|
id,
|
|
85728
86127
|
name: proposal.name,
|
|
@@ -85753,11 +86152,11 @@ ${contents}
|
|
|
85753
86152
|
}
|
|
85754
86153
|
const CLAIM_STALE_MS = 60 * 60 * 1e3;
|
|
85755
86154
|
async function claimSchedule(id) {
|
|
85756
|
-
const claimPath =
|
|
86155
|
+
const claimPath = import_node_path49.default.join(storageDir, "schedule-claims", `${id}.json`);
|
|
85757
86156
|
const mine = JSON.stringify({ pid: process.pid, at: Date.now() });
|
|
85758
86157
|
try {
|
|
85759
|
-
await
|
|
85760
|
-
await
|
|
86158
|
+
await import_promises27.default.mkdir(import_node_path49.default.dirname(claimPath), { recursive: true });
|
|
86159
|
+
await import_promises27.default.writeFile(claimPath, mine, { encoding: "utf8", flag: "wx" });
|
|
85761
86160
|
return true;
|
|
85762
86161
|
} catch (error51) {
|
|
85763
86162
|
if (error51.code !== "EEXIST") {
|
|
@@ -85766,22 +86165,22 @@ ${contents}
|
|
|
85766
86165
|
}
|
|
85767
86166
|
}
|
|
85768
86167
|
try {
|
|
85769
|
-
const held = JSON.parse(await
|
|
86168
|
+
const held = JSON.parse(await import_promises27.default.readFile(claimPath, "utf8"));
|
|
85770
86169
|
const at = typeof held.at === "number" ? held.at : 0;
|
|
85771
86170
|
if (Date.now() - at < CLAIM_STALE_MS) {
|
|
85772
86171
|
logger.info(`schedule ${id} is already running in another window`);
|
|
85773
86172
|
return false;
|
|
85774
86173
|
}
|
|
85775
86174
|
logger.warn(`taking over a stale claim on schedule ${id}`);
|
|
85776
|
-
await
|
|
86175
|
+
await import_promises27.default.writeFile(claimPath, mine, "utf8");
|
|
85777
86176
|
return true;
|
|
85778
86177
|
} catch {
|
|
85779
|
-
await
|
|
86178
|
+
await import_promises27.default.writeFile(claimPath, mine, "utf8").catch(() => void 0);
|
|
85780
86179
|
return true;
|
|
85781
86180
|
}
|
|
85782
86181
|
}
|
|
85783
86182
|
async function releaseSchedule(id) {
|
|
85784
|
-
await
|
|
86183
|
+
await import_promises27.default.rm(import_node_path49.default.join(storageDir, "schedule-claims", `${id}.json`), { force: true }).catch(() => void 0);
|
|
85785
86184
|
}
|
|
85786
86185
|
async function runSchedule(id, reason) {
|
|
85787
86186
|
if (reason === "due" && !await claimSchedule(id))
|
|
@@ -86448,12 +86847,12 @@ function createShowDiagramTool() {
|
|
|
86448
86847
|
}
|
|
86449
86848
|
|
|
86450
86849
|
// ../../packages/core/dist/lsp/manager.js
|
|
86451
|
-
var
|
|
86452
|
-
var
|
|
86850
|
+
var import_promises28 = __toESM(require("node:fs/promises"), 1);
|
|
86851
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
86453
86852
|
|
|
86454
86853
|
// ../../packages/core/dist/lsp/catalog.js
|
|
86455
86854
|
var import_node_fs11 = require("node:fs");
|
|
86456
|
-
var
|
|
86855
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
86457
86856
|
var c = (command, ...args) => ({ command, args });
|
|
86458
86857
|
var LSP_LANGUAGES = [
|
|
86459
86858
|
{ id: "python", label: "Python", extensions: ["py", "pyi"], candidates: [c("pyright-langserver", "--stdio"), c("basedpyright-langserver", "--stdio"), c("pylsp"), c("jedi-language-server")] },
|
|
@@ -86501,16 +86900,16 @@ var LSP_LANGUAGES = [
|
|
|
86501
86900
|
{ id: "sql", label: "SQL", extensions: ["sql"], candidates: [c("sql-language-server", "up", "--method", "stdio")] }
|
|
86502
86901
|
];
|
|
86503
86902
|
function languageFor(file2) {
|
|
86504
|
-
const ext =
|
|
86903
|
+
const ext = import_node_path50.default.extname(file2).slice(1).toLowerCase();
|
|
86505
86904
|
return LSP_LANGUAGES.find((l) => l.extensions.includes(ext));
|
|
86506
86905
|
}
|
|
86507
86906
|
function languageIdFor(language, file2) {
|
|
86508
|
-
const ext =
|
|
86907
|
+
const ext = import_node_path50.default.extname(file2).slice(1).toLowerCase();
|
|
86509
86908
|
return language.languageIdFor?.(ext) ?? language.id;
|
|
86510
86909
|
}
|
|
86511
86910
|
var found = /* @__PURE__ */ new Map();
|
|
86512
86911
|
function findOnPath(command, env2 = process.env) {
|
|
86513
|
-
if (
|
|
86912
|
+
if (import_node_path50.default.isAbsolute(command))
|
|
86514
86913
|
return (0, import_node_fs11.existsSync)(command) ? command : void 0;
|
|
86515
86914
|
if (env2 !== process.env)
|
|
86516
86915
|
return searchPath(command, env2);
|
|
@@ -86522,11 +86921,11 @@ function findOnPath(command, env2 = process.env) {
|
|
|
86522
86921
|
return value;
|
|
86523
86922
|
}
|
|
86524
86923
|
function searchPath(command, env2) {
|
|
86525
|
-
const dirs = (env2.PATH ?? env2.Path ?? "").split(
|
|
86924
|
+
const dirs = (env2.PATH ?? env2.Path ?? "").split(import_node_path50.default.delimiter).filter((d) => d.length > 0);
|
|
86526
86925
|
const exts = process.platform === "win32" ? ["", ...(env2.PATHEXT ?? ".EXE;.CMD;.BAT").toLowerCase().split(";")] : [""];
|
|
86527
86926
|
for (const dir of dirs) {
|
|
86528
86927
|
for (const ext of exts) {
|
|
86529
|
-
const candidate =
|
|
86928
|
+
const candidate = import_node_path50.default.join(dir, command + ext);
|
|
86530
86929
|
if ((0, import_node_fs11.existsSync)(candidate) && (process.platform !== "win32" || ext !== "" || /\.(exe|cmd|bat)$/i.test(candidate)))
|
|
86531
86930
|
return candidate;
|
|
86532
86931
|
}
|
|
@@ -86758,7 +87157,7 @@ var LspManager = class {
|
|
|
86758
87157
|
return void 0;
|
|
86759
87158
|
const args = [...found2.candidate.args];
|
|
86760
87159
|
if (language.id === "java" && !args.includes("-data"))
|
|
86761
|
-
args.push("-data",
|
|
87160
|
+
args.push("-data", import_node_path51.default.join(this.storageDir, "jdtls-workspace"));
|
|
86762
87161
|
try {
|
|
86763
87162
|
client = new LspClient(found2.executable, args, this.root, this.log);
|
|
86764
87163
|
this.clients.set(language.id, client);
|
|
@@ -86769,7 +87168,7 @@ var LspManager = class {
|
|
|
86769
87168
|
}
|
|
86770
87169
|
let text;
|
|
86771
87170
|
try {
|
|
86772
|
-
text = await
|
|
87171
|
+
text = await import_promises28.default.readFile(file2, "utf8");
|
|
86773
87172
|
} catch {
|
|
86774
87173
|
return void 0;
|
|
86775
87174
|
}
|
|
@@ -86779,7 +87178,7 @@ var LspManager = class {
|
|
|
86779
87178
|
this.failed.set(language.id, client.lastError ?? "stopped");
|
|
86780
87179
|
return void 0;
|
|
86781
87180
|
}
|
|
86782
|
-
return { server:
|
|
87181
|
+
return { server: import_node_path51.default.basename(client.executable).replace(/\.(exe|cmd|bat)$/i, ""), diagnostics: diagnostics ?? [] };
|
|
86783
87182
|
} catch (error51) {
|
|
86784
87183
|
this.failed.set(language.id, error51 instanceof Error ? error51.message : String(error51));
|
|
86785
87184
|
client.dispose();
|
|
@@ -89052,8 +89451,114 @@ every column - by two to three times on 8 cores; a light filtered count is limit
|
|
|
89052
89451
|
reads the one stopped at a breakpoint - call stack, variables, recent output - through the same private
|
|
89053
89452
|
link Copilot uses. Read-only: it cannot step or continue. IntelliJ and PyCharm are not supported yet.
|
|
89054
89453
|
|
|
89454
|
+
**Memory and disk.** Each chat is its own agent process. A chat page you are not looking at is
|
|
89455
|
+
**unloaded after a few idle minutes** while its agent keeps running (Settings \u2192 *Unload hidden chat
|
|
89456
|
+
pages after*; never while it is working or waiting for you), and a whole codebase **sleeps** after
|
|
89457
|
+
the idle time set there. The chats of one codebase **share** its checkpoint store, its Python venv
|
|
89458
|
+
and its index bookkeeping, so a new chat no longer adds another copy of the codebase's snapshots.
|
|
89459
|
+
WebView2's cache is capped at 32 MB.
|
|
89460
|
+
|
|
89055
89461
|
**Not in Fire Code**: editor file pickers \u2014 paths are typed. Fire Code's
|
|
89056
89462
|
Settings \u2192 Export source code saves the whole repository as a zip that builds offline.
|
|
89463
|
+
`
|
|
89464
|
+
},
|
|
89465
|
+
{
|
|
89466
|
+
id: "addons",
|
|
89467
|
+
title: "Add-ons",
|
|
89468
|
+
keywords: [
|
|
89469
|
+
"addon",
|
|
89470
|
+
"add-on",
|
|
89471
|
+
"add-ons",
|
|
89472
|
+
"addons",
|
|
89473
|
+
"plugin",
|
|
89474
|
+
"plugins",
|
|
89475
|
+
"extension",
|
|
89476
|
+
"extend",
|
|
89477
|
+
"extendable",
|
|
89478
|
+
"more tools",
|
|
89479
|
+
"my own tools",
|
|
89480
|
+
"node app",
|
|
89481
|
+
"node package",
|
|
89482
|
+
"npm package",
|
|
89483
|
+
"install tools",
|
|
89484
|
+
"npm i -g",
|
|
89485
|
+
"write an addon",
|
|
89486
|
+
"create an addon",
|
|
89487
|
+
"build an addon",
|
|
89488
|
+
"lightcode addon",
|
|
89489
|
+
"package.json",
|
|
89490
|
+
"addon for fire code",
|
|
89491
|
+
"fire code addon",
|
|
89492
|
+
"addon for light code",
|
|
89493
|
+
"light code addon",
|
|
89494
|
+
"addon tools"
|
|
89495
|
+
],
|
|
89496
|
+
body: `
|
|
89497
|
+
**An add-on is an npm package that runs an MCP server**, labelled in its \`package.json\`:
|
|
89498
|
+
|
|
89499
|
+
{
|
|
89500
|
+
"name": "light-code-addon-weather",
|
|
89501
|
+
"version": "1.0.0",
|
|
89502
|
+
"type": "module",
|
|
89503
|
+
"lightCode": { "addon": { "main": "server.js", "displayName": "Weather" } },
|
|
89504
|
+
"dependencies": { "@modelcontextprotocol/sdk": "^1.30.0", "zod": "^3.25.0" }
|
|
89505
|
+
}
|
|
89506
|
+
|
|
89507
|
+
\`main\` is an MCP server over stdio, written with \`@modelcontextprotocol/sdk\` (\`McpServer\`,
|
|
89508
|
+
\`registerTool\`, \`StdioServerTransport\`). \`examples/light-code-addon-hello\` in the source is a
|
|
89509
|
+
complete one. Light Code, Fire Code, the Node host and the JetBrains plugin all use the same add-ons.
|
|
89510
|
+
|
|
89511
|
+
**Install it** with \`npm i -g <package or folder>\`, then **Settings \u2192 MCP \u2192 Add-ons**. Light Code
|
|
89512
|
+
looks in npm's global folder and in any folders listed there (a folder of packages, or one add-on you
|
|
89513
|
+
are writing). **Installed is not enabled**: press Enable, read the program it will run, and confirm.
|
|
89514
|
+
Its tools then appear as \`addon-<name>__<tool>\` and are asked about like every other tool, with the
|
|
89515
|
+
usual Always / Ask / Never, timeouts and deny rules in the MCP tab.
|
|
89516
|
+
|
|
89517
|
+
**An update stays off until you enable the new version** - new code is looked at first. An add-on
|
|
89518
|
+
that is no longer installed stays off and is listed so you can remove it. Enabling writes an ordinary
|
|
89519
|
+
\`mcpServers\` entry, so export and the JSON editor carry it; on another machine it runs only if that
|
|
89520
|
+
machine has the add-on installed, and from wherever it is installed there. A repository's own settings
|
|
89521
|
+
can never switch an add-on on. \`addons.folders\` is user-scope only.
|
|
89522
|
+
|
|
89523
|
+
**Add-ons run as you and can do anything you can.** Only install ones you trust. They run with the
|
|
89524
|
+
editor's own Node inside VS Code, so no Node install is needed there; Fire Code uses its Node.
|
|
89525
|
+
`
|
|
89526
|
+
},
|
|
89527
|
+
{
|
|
89528
|
+
id: "codebase-instructions",
|
|
89529
|
+
title: "Codebase instructions",
|
|
89530
|
+
keywords: [
|
|
89531
|
+
"codebase instructions",
|
|
89532
|
+
"project instructions",
|
|
89533
|
+
"instructions for this codebase",
|
|
89534
|
+
"every chat",
|
|
89535
|
+
"all chats",
|
|
89536
|
+
"instructions for all chats",
|
|
89537
|
+
"always tell it",
|
|
89538
|
+
"remember for this project",
|
|
89539
|
+
"agents.md",
|
|
89540
|
+
"claude.md",
|
|
89541
|
+
"rules for this repo",
|
|
89542
|
+
"house rules",
|
|
89543
|
+
"system prompt",
|
|
89544
|
+
"custom instructions",
|
|
89545
|
+
"edit codebase instructions",
|
|
89546
|
+
"codebase instructions in fire code"
|
|
89547
|
+
],
|
|
89548
|
+
body: `
|
|
89549
|
+
**Three levels**, most specific first: what you say **in the chat**, then **codebase instructions**,
|
|
89550
|
+
then **standing instructions**. Every chat on a codebase gets the codebase instructions with every
|
|
89551
|
+
message, ahead of the standing instructions; where they disagree the codebase instructions win.
|
|
89552
|
+
|
|
89553
|
+
**Codebase instructions** are about one codebase and are kept on this machine, not in the repository,
|
|
89554
|
+
so a cloned repository cannot write them. Edit them in **Settings \u2192 Skills \u2192 Codebase instructions**,
|
|
89555
|
+
or in **Fire Code** from a codebase's right-click menu \u2192 **Codebase instructions\u2026**. A save reaches every
|
|
89556
|
+
chat on that codebase from its next message - nothing restarts. Only the first 20,000 characters are
|
|
89557
|
+
sent; keep them short, they are paid for on every request.
|
|
89558
|
+
|
|
89559
|
+
**Standing instructions** are a skill with \`always: true\` (Settings \u2192 Skills \u2192 Standing
|
|
89560
|
+
instructions). They can live in the repository or a shared bucket, so they can apply to many
|
|
89561
|
+
codebases and a whole team. Fire Code's dialog has a button that opens them too.
|
|
89057
89562
|
`
|
|
89058
89563
|
},
|
|
89059
89564
|
{
|
|
@@ -89893,7 +90398,7 @@ function createLightCodeHelpTool() {
|
|
|
89893
90398
|
|
|
89894
90399
|
// ../../packages/core/dist/tools/listFiles.js
|
|
89895
90400
|
var import_node_child_process16 = require("node:child_process");
|
|
89896
|
-
var
|
|
90401
|
+
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
89897
90402
|
|
|
89898
90403
|
// ../../packages/core/dist/tools/ripgrepError.js
|
|
89899
90404
|
function ripgrepDidNotStart(error51) {
|
|
@@ -89974,7 +90479,7 @@ var listFilesTool = {
|
|
|
89974
90479
|
});
|
|
89975
90480
|
if (files.length === 0)
|
|
89976
90481
|
return noFiles;
|
|
89977
|
-
const listed = files.map((file2) => file2.split("/").join(
|
|
90482
|
+
const listed = files.map((file2) => file2.split("/").join(import_node_path52.default.sep)).join("\n");
|
|
89978
90483
|
return { content: truncated ? `${listed}
|
|
89979
90484
|
(listing cut short \u2014 list a narrower folder)` : listed };
|
|
89980
90485
|
}
|
|
@@ -90041,10 +90546,10 @@ function readSmall(raw, params3) {
|
|
|
90041
90546
|
const end = params3.limit !== void 0 ? start + params3.limit : lines.length;
|
|
90042
90547
|
return number4(lines.slice(start, end), start + 1);
|
|
90043
90548
|
}
|
|
90044
|
-
async function readLarge(
|
|
90549
|
+
async function readLarge(fs41, realPath, params3, size) {
|
|
90045
90550
|
const human = formatBytes(size);
|
|
90046
90551
|
if (params3.tail !== void 0) {
|
|
90047
|
-
const part = await readTail(
|
|
90552
|
+
const part = await readTail(fs41, realPath, size, params3.tail);
|
|
90048
90553
|
return [
|
|
90049
90554
|
`${human} file \u2014 last ${String(part.lines.length)} lines.`,
|
|
90050
90555
|
/*
|
|
@@ -90059,7 +90564,7 @@ async function readLarge(fs39, realPath, params3, size) {
|
|
|
90059
90564
|
}
|
|
90060
90565
|
if (params3.offset !== void 0) {
|
|
90061
90566
|
const limit = params3.limit ?? DEFAULT_LARGE_LIMIT;
|
|
90062
|
-
const part = await readLineWindow(
|
|
90567
|
+
const part = await readLineWindow(fs41, realPath, size, params3.offset, limit);
|
|
90063
90568
|
const shown2 = part.lines.length;
|
|
90064
90569
|
return [
|
|
90065
90570
|
`${human} file \u2014 lines ${String(params3.offset)}\u2013${String(params3.offset + shown2 - 1)}${part.hasMoreAfter ? ", more follows" : " (end of file)"}.`,
|
|
@@ -90067,7 +90572,7 @@ async function readLarge(fs39, realPath, params3, size) {
|
|
|
90067
90572
|
number4(part.lines, params3.offset)
|
|
90068
90573
|
].join("\n");
|
|
90069
90574
|
}
|
|
90070
|
-
const total = await countLines(
|
|
90575
|
+
const total = await countLines(fs41, realPath, size);
|
|
90071
90576
|
return [
|
|
90072
90577
|
`${realPathName(realPath)} is ${human} (${total.toLocaleString()} lines) \u2014 too large to read at once.`,
|
|
90073
90578
|
"",
|
|
@@ -90202,7 +90707,7 @@ var searchFilesTool = {
|
|
|
90202
90707
|
};
|
|
90203
90708
|
|
|
90204
90709
|
// ../../packages/core/dist/tools/writeToFile.js
|
|
90205
|
-
var
|
|
90710
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
90206
90711
|
var paramsSchema23 = external_exports.object({
|
|
90207
90712
|
path: external_exports.string().min(1).describe("Path to the file, relative to the workspace root."),
|
|
90208
90713
|
content: external_exports.string().describe("Full file content to write.")
|
|
@@ -90230,7 +90735,7 @@ var writeToFileTool = {
|
|
|
90230
90735
|
return { content: changed, isError: true, path: params3.path };
|
|
90231
90736
|
}
|
|
90232
90737
|
if (!exists2) {
|
|
90233
|
-
await context.fs.mkdir(
|
|
90738
|
+
await context.fs.mkdir(import_node_path53.default.dirname(resolved.realPath));
|
|
90234
90739
|
}
|
|
90235
90740
|
await context.fs.writeFile(resolved.realPath, params3.content);
|
|
90236
90741
|
await recordWrite(context, resolved.realPath);
|
|
@@ -90331,21 +90836,21 @@ function createDefaultToolRegistry() {
|
|
|
90331
90836
|
}
|
|
90332
90837
|
|
|
90333
90838
|
// ../../packages/core/dist/dataset/store.js
|
|
90334
|
-
var
|
|
90335
|
-
var
|
|
90839
|
+
var import_promises29 = __toESM(require("node:fs/promises"), 1);
|
|
90840
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
90336
90841
|
var DatasetStore = class {
|
|
90337
90842
|
filePath;
|
|
90338
90843
|
statePath;
|
|
90339
90844
|
constructor(storageDir, datasetId) {
|
|
90340
90845
|
const safe = datasetId.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
90341
|
-
this.filePath =
|
|
90342
|
-
this.statePath =
|
|
90846
|
+
this.filePath = import_node_path54.default.join(storageDir, "datasets", `${safe}.jsonl`);
|
|
90847
|
+
this.statePath = import_node_path54.default.join(storageDir, "datasets", `${safe}.state.json`);
|
|
90343
90848
|
}
|
|
90344
90849
|
/** Every record. A malformed line is skipped — one bad line costs one record, not the corpus. */
|
|
90345
90850
|
async load() {
|
|
90346
90851
|
let raw;
|
|
90347
90852
|
try {
|
|
90348
|
-
raw = await
|
|
90853
|
+
raw = await import_promises29.default.readFile(this.filePath, "utf8");
|
|
90349
90854
|
} catch {
|
|
90350
90855
|
return [];
|
|
90351
90856
|
}
|
|
@@ -90367,18 +90872,18 @@ var DatasetStore = class {
|
|
|
90367
90872
|
async append(records) {
|
|
90368
90873
|
if (records.length === 0)
|
|
90369
90874
|
return;
|
|
90370
|
-
await
|
|
90371
|
-
await
|
|
90875
|
+
await import_promises29.default.mkdir(import_node_path54.default.dirname(this.filePath), { recursive: true });
|
|
90876
|
+
await import_promises29.default.writeFile(this.filePath, "", { flag: "a" });
|
|
90372
90877
|
const lines = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
90373
|
-
await
|
|
90878
|
+
await import_promises29.default.appendFile(this.filePath, `${lines}
|
|
90374
90879
|
`, "utf8");
|
|
90375
90880
|
}
|
|
90376
90881
|
/** Rewrites with exactly these. Temp-and-rename, so an interrupted prune leaves the old file. */
|
|
90377
90882
|
async replace(records) {
|
|
90378
|
-
await
|
|
90883
|
+
await import_promises29.default.mkdir(import_node_path54.default.dirname(this.filePath), { recursive: true });
|
|
90379
90884
|
const temporary = `${this.filePath}.tmp`;
|
|
90380
90885
|
const body = records.map((record2) => JSON.stringify(record2)).join("\n");
|
|
90381
|
-
await
|
|
90886
|
+
await import_promises29.default.writeFile(temporary, records.length === 0 ? "" : `${body}
|
|
90382
90887
|
`, "utf8");
|
|
90383
90888
|
await replaceFile(temporary, this.filePath);
|
|
90384
90889
|
}
|
|
@@ -90392,7 +90897,7 @@ var DatasetStore = class {
|
|
|
90392
90897
|
async compact() {
|
|
90393
90898
|
let before;
|
|
90394
90899
|
try {
|
|
90395
|
-
before = (await
|
|
90900
|
+
before = (await import_promises29.default.readFile(this.filePath, "utf8")).split("\n").filter((line) => line.trim().length > 0).length;
|
|
90396
90901
|
} catch {
|
|
90397
90902
|
return { before: 0, after: 0 };
|
|
90398
90903
|
}
|
|
@@ -90403,12 +90908,12 @@ var DatasetStore = class {
|
|
|
90403
90908
|
return { before, after: records.length };
|
|
90404
90909
|
}
|
|
90405
90910
|
async clear() {
|
|
90406
|
-
await
|
|
90407
|
-
await
|
|
90911
|
+
await import_promises29.default.rm(this.filePath, { force: true });
|
|
90912
|
+
await import_promises29.default.rm(this.statePath, { force: true });
|
|
90408
90913
|
}
|
|
90409
90914
|
async sizeBytes() {
|
|
90410
90915
|
try {
|
|
90411
|
-
return (await
|
|
90916
|
+
return (await import_promises29.default.stat(this.filePath)).size;
|
|
90412
90917
|
} catch {
|
|
90413
90918
|
return 0;
|
|
90414
90919
|
}
|
|
@@ -90422,16 +90927,16 @@ var DatasetStore = class {
|
|
|
90422
90927
|
*/
|
|
90423
90928
|
async lastSyncedAt() {
|
|
90424
90929
|
try {
|
|
90425
|
-
const parsed = JSON.parse(await
|
|
90930
|
+
const parsed = JSON.parse(await import_promises29.default.readFile(this.statePath, "utf8"));
|
|
90426
90931
|
return typeof parsed.lastSyncedAt === "number" ? parsed.lastSyncedAt : void 0;
|
|
90427
90932
|
} catch {
|
|
90428
90933
|
return void 0;
|
|
90429
90934
|
}
|
|
90430
90935
|
}
|
|
90431
90936
|
async recordSync(at) {
|
|
90432
|
-
await
|
|
90937
|
+
await import_promises29.default.mkdir(import_node_path54.default.dirname(this.statePath), { recursive: true });
|
|
90433
90938
|
const temporary = `${this.statePath}.tmp`;
|
|
90434
|
-
await
|
|
90939
|
+
await import_promises29.default.writeFile(temporary, JSON.stringify({ lastSyncedAt: at }), "utf8");
|
|
90435
90940
|
await replaceFile(temporary, this.statePath);
|
|
90436
90941
|
}
|
|
90437
90942
|
};
|
|
@@ -90766,8 +91271,8 @@ That is a fault in the tool itself, or the source is unreachable from here. Fix
|
|
|
90766
91271
|
}
|
|
90767
91272
|
|
|
90768
91273
|
// ../../packages/core/dist/s3/sigv4.js
|
|
90769
|
-
var
|
|
90770
|
-
var EMPTY_PAYLOAD_SHA256 = (0,
|
|
91274
|
+
var import_node_crypto15 = require("node:crypto");
|
|
91275
|
+
var EMPTY_PAYLOAD_SHA256 = (0, import_node_crypto15.createHash)("sha256").update("").digest("hex");
|
|
90771
91276
|
function encodeSegment(segment) {
|
|
90772
91277
|
return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
90773
91278
|
}
|
|
@@ -90791,10 +91296,10 @@ function amzDate(now) {
|
|
|
90791
91296
|
return `${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z`;
|
|
90792
91297
|
}
|
|
90793
91298
|
function signingKey(secretAccessKey, date5, region, service) {
|
|
90794
|
-
const dateKey = (0,
|
|
90795
|
-
const regionKey = (0,
|
|
90796
|
-
const serviceKey = (0,
|
|
90797
|
-
return (0,
|
|
91299
|
+
const dateKey = (0, import_node_crypto15.createHmac)("sha256", `AWS4${secretAccessKey}`).update(date5).digest();
|
|
91300
|
+
const regionKey = (0, import_node_crypto15.createHmac)("sha256", dateKey).update(region).digest();
|
|
91301
|
+
const serviceKey = (0, import_node_crypto15.createHmac)("sha256", regionKey).update(service).digest();
|
|
91302
|
+
return (0, import_node_crypto15.createHmac)("sha256", serviceKey).update("aws4_request").digest();
|
|
90798
91303
|
}
|
|
90799
91304
|
function signRequest(input) {
|
|
90800
91305
|
const service = input.service ?? "s3";
|
|
@@ -90803,7 +91308,7 @@ function signRequest(input) {
|
|
|
90803
91308
|
const date5 = timestamp.slice(0, 8);
|
|
90804
91309
|
const url2 = new URL(input.url);
|
|
90805
91310
|
const body = input.body ?? Buffer.alloc(0);
|
|
90806
|
-
const payloadHash = (0,
|
|
91311
|
+
const payloadHash = (0, import_node_crypto15.createHash)("sha256").update(body).digest("hex");
|
|
90807
91312
|
const headers = {
|
|
90808
91313
|
...input.headers,
|
|
90809
91314
|
host: url2.host,
|
|
@@ -90827,9 +91332,9 @@ function signRequest(input) {
|
|
|
90827
91332
|
"AWS4-HMAC-SHA256",
|
|
90828
91333
|
timestamp,
|
|
90829
91334
|
scope,
|
|
90830
|
-
(0,
|
|
91335
|
+
(0, import_node_crypto15.createHash)("sha256").update(canonicalRequest).digest("hex")
|
|
90831
91336
|
].join("\n");
|
|
90832
|
-
const signature = (0,
|
|
91337
|
+
const signature = (0, import_node_crypto15.createHmac)("sha256", signingKey(input.secretAccessKey, date5, input.region, service)).update(stringToSign).digest("hex");
|
|
90833
91338
|
return {
|
|
90834
91339
|
headers: {
|
|
90835
91340
|
...headers,
|
|
@@ -90859,8 +91364,8 @@ var S3Client = class {
|
|
|
90859
91364
|
const host = inPath ? origin.host : `${bucket}.${origin.host}`;
|
|
90860
91365
|
const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
|
|
90861
91366
|
const prefix = inPath ? `${mount}/${bucket}` : mount;
|
|
90862
|
-
const
|
|
90863
|
-
const url2 = new URL(`${origin.protocol}//${host}${prefix}${
|
|
91367
|
+
const path60 = key2 === "" ? "" : `/${key2.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
|
|
91368
|
+
const url2 = new URL(`${origin.protocol}//${host}${prefix}${path60}`);
|
|
90864
91369
|
for (const [name, value] of Object.entries(call.query ?? {}))
|
|
90865
91370
|
url2.searchParams.set(name, value);
|
|
90866
91371
|
return url2.toString();
|
|
@@ -91127,9 +91632,9 @@ async function syncFromS3(options) {
|
|
|
91127
91632
|
return result;
|
|
91128
91633
|
}
|
|
91129
91634
|
var MANIFEST_NAME = ".lightcode-sync.json";
|
|
91130
|
-
async function readManifest(
|
|
91635
|
+
async function readManifest(fs41, manifestPath) {
|
|
91131
91636
|
try {
|
|
91132
|
-
const parsed = JSON.parse((await
|
|
91637
|
+
const parsed = JSON.parse((await fs41.readBytes(manifestPath)).toString("utf8"));
|
|
91133
91638
|
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
91134
91639
|
} catch {
|
|
91135
91640
|
return {};
|
|
@@ -91147,14 +91652,14 @@ function join(dir, relative) {
|
|
|
91147
91652
|
const left = dir.replace(/[\\/]+$/, "");
|
|
91148
91653
|
return `${left}/${relative}`;
|
|
91149
91654
|
}
|
|
91150
|
-
async function writeWhole2(
|
|
91151
|
-
if (
|
|
91152
|
-
await
|
|
91655
|
+
async function writeWhole2(fs41, target, bytes) {
|
|
91656
|
+
if (fs41.rename === void 0) {
|
|
91657
|
+
await fs41.writeBytes(target, bytes);
|
|
91153
91658
|
return;
|
|
91154
91659
|
}
|
|
91155
91660
|
const temporary = `${target}.${String(process.pid)}.${String(Date.now())}.part`;
|
|
91156
|
-
await
|
|
91157
|
-
await
|
|
91661
|
+
await fs41.writeBytes(temporary, bytes);
|
|
91662
|
+
await fs41.rename(temporary, target);
|
|
91158
91663
|
}
|
|
91159
91664
|
function dirname(filePath) {
|
|
91160
91665
|
const cut = filePath.lastIndexOf("/");
|
|
@@ -91350,15 +91855,15 @@ function createS3Tools(targets) {
|
|
|
91350
91855
|
}
|
|
91351
91856
|
|
|
91352
91857
|
// ../../packages/core/dist/s3/localFolder.js
|
|
91353
|
-
var
|
|
91858
|
+
var import_node_crypto16 = require("node:crypto");
|
|
91354
91859
|
function mirrorFolder(options) {
|
|
91355
91860
|
const connection = safeSegment(options.connectionId);
|
|
91356
|
-
const digest = (0,
|
|
91861
|
+
const digest = (0, import_node_crypto16.createHash)("sha256").update((options.prefix ?? "").trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
91357
91862
|
return join2(options.storageDir, "s3", connection, `${options.kind}-${digest}`);
|
|
91358
91863
|
}
|
|
91359
91864
|
function safeSegment(id) {
|
|
91360
91865
|
const cleaned = id.replace(/[^a-zA-Z0-9._-]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 40);
|
|
91361
|
-
const suffix = (0,
|
|
91866
|
+
const suffix = (0, import_node_crypto16.createHash)("sha256").update(id).digest("hex").slice(0, 6);
|
|
91362
91867
|
return `${cleaned === "" ? "connection" : cleaned}-${suffix}`;
|
|
91363
91868
|
}
|
|
91364
91869
|
function join2(...parts) {
|
|
@@ -91445,13 +91950,13 @@ function reachableOrigins(hosts, extra = []) {
|
|
|
91445
91950
|
}
|
|
91446
91951
|
|
|
91447
91952
|
// src/identity.ts
|
|
91448
|
-
var
|
|
91953
|
+
var import_node_crypto17 = __toESM(require("node:crypto"), 1);
|
|
91449
91954
|
var SingleUserIdentity = class _SingleUserIdentity {
|
|
91450
91955
|
describe;
|
|
91451
91956
|
static PRINCIPAL = { id: "local", displayName: "Local user" };
|
|
91452
91957
|
principal;
|
|
91453
91958
|
/** Long-lived, minted per server run, only ever sent in an `Authorization` header. */
|
|
91454
|
-
sessionToken =
|
|
91959
|
+
sessionToken = import_node_crypto17.default.randomBytes(32).toString("base64url");
|
|
91455
91960
|
/**
|
|
91456
91961
|
* Single-use and short-lived, because it travels in the launch URL's fragment where it
|
|
91457
91962
|
* can end up in shell history or a terminal scrollback (§14).
|
|
@@ -91461,7 +91966,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
91461
91966
|
* raises it, and what that costs is stated where it is set: a longer window is a longer time in
|
|
91462
91967
|
* which somebody reading that scrollback can use it before you do.
|
|
91463
91968
|
*/
|
|
91464
|
-
handoffToken =
|
|
91969
|
+
handoffToken = import_node_crypto17.default.randomBytes(32).toString("base64url");
|
|
91465
91970
|
handoffExpiresAt;
|
|
91466
91971
|
handoffSeconds;
|
|
91467
91972
|
/**
|
|
@@ -91491,7 +91996,7 @@ var SingleUserIdentity = class _SingleUserIdentity {
|
|
|
91491
91996
|
* which is the same person it was printed to in the first place.
|
|
91492
91997
|
*/
|
|
91493
91998
|
remintHandoff() {
|
|
91494
|
-
this.handoffToken =
|
|
91999
|
+
this.handoffToken = import_node_crypto17.default.randomBytes(32).toString("base64url");
|
|
91495
92000
|
this.handoffExpiresAt = Date.now() + this.handoffSeconds * 1e3;
|
|
91496
92001
|
return this.handoffToken;
|
|
91497
92002
|
}
|
|
@@ -91530,10 +92035,10 @@ function timingSafeEquals(a, b) {
|
|
|
91530
92035
|
const left = Buffer.from(a);
|
|
91531
92036
|
const right = Buffer.from(b);
|
|
91532
92037
|
if (left.length !== right.length) return false;
|
|
91533
|
-
return
|
|
92038
|
+
return import_node_crypto17.default.timingSafeEqual(left, right);
|
|
91534
92039
|
}
|
|
91535
92040
|
function storageKeyFor(principal) {
|
|
91536
|
-
return
|
|
92041
|
+
return import_node_crypto17.default.createHash("sha256").update(principal.id).digest("hex").slice(0, 32);
|
|
91537
92042
|
}
|
|
91538
92043
|
var OpenIdentity = class _OpenIdentity {
|
|
91539
92044
|
describe = "single user, no token (--no-token)";
|
|
@@ -91801,23 +92306,23 @@ async function readJsonBody(request, maxBytes = 32 * 1024 * 1024) {
|
|
|
91801
92306
|
}
|
|
91802
92307
|
|
|
91803
92308
|
// src/fileSecretStore.ts
|
|
91804
|
-
var
|
|
91805
|
-
var
|
|
92309
|
+
var import_promises30 = __toESM(require("node:fs/promises"), 1);
|
|
92310
|
+
var import_node_path55 = __toESM(require("node:path"), 1);
|
|
91806
92311
|
|
|
91807
92312
|
// src/vaultCrypto.ts
|
|
91808
|
-
var
|
|
92313
|
+
var import_node_crypto18 = require("node:crypto");
|
|
91809
92314
|
function isVaultEnvelope(value) {
|
|
91810
92315
|
const v = value;
|
|
91811
92316
|
return typeof v === "object" && v !== null && v.sunVault === 1 && typeof v.iv === "string" && typeof v.tag === "string" && typeof v.data === "string";
|
|
91812
92317
|
}
|
|
91813
92318
|
function sealSecrets(secrets, key2) {
|
|
91814
|
-
const iv = (0,
|
|
91815
|
-
const cipher = (0,
|
|
92319
|
+
const iv = (0, import_node_crypto18.randomBytes)(12);
|
|
92320
|
+
const cipher = (0, import_node_crypto18.createCipheriv)("aes-256-gcm", key2, iv);
|
|
91816
92321
|
const data = Buffer.concat([cipher.update(JSON.stringify(secrets), "utf8"), cipher.final()]);
|
|
91817
92322
|
return { sunVault: 1, iv: iv.toString("base64"), tag: cipher.getAuthTag().toString("base64"), data: data.toString("base64") };
|
|
91818
92323
|
}
|
|
91819
92324
|
function openSecrets(envelope, key2) {
|
|
91820
|
-
const decipher = (0,
|
|
92325
|
+
const decipher = (0, import_node_crypto18.createDecipheriv)("aes-256-gcm", key2, Buffer.from(envelope.iv, "base64"));
|
|
91821
92326
|
decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
|
|
91822
92327
|
const plain = Buffer.concat([decipher.update(Buffer.from(envelope.data, "base64")), decipher.final()]);
|
|
91823
92328
|
const parsed = JSON.parse(plain.toString("utf8"));
|
|
@@ -91856,7 +92361,7 @@ var FileSecretStore = class {
|
|
|
91856
92361
|
sealedShut = false;
|
|
91857
92362
|
async currentStamp() {
|
|
91858
92363
|
try {
|
|
91859
|
-
const stat = await
|
|
92364
|
+
const stat = await import_promises30.default.stat(this.filePath);
|
|
91860
92365
|
return `${String(stat.mtimeMs)}:${String(stat.size)}`;
|
|
91861
92366
|
} catch {
|
|
91862
92367
|
return void 0;
|
|
@@ -91867,7 +92372,7 @@ var FileSecretStore = class {
|
|
|
91867
92372
|
if (this.cache !== void 0 && stamp2 === this.stamp) return this.cache;
|
|
91868
92373
|
this.stamp = stamp2;
|
|
91869
92374
|
try {
|
|
91870
|
-
const raw = await
|
|
92375
|
+
const raw = await import_promises30.default.readFile(this.filePath, "utf8");
|
|
91871
92376
|
const parsed = JSON.parse(raw.replace(/^\uFEFF/, ""));
|
|
91872
92377
|
this.sealedShut = false;
|
|
91873
92378
|
if (isVaultEnvelope(parsed)) {
|
|
@@ -91900,10 +92405,10 @@ var FileSecretStore = class {
|
|
|
91900
92405
|
);
|
|
91901
92406
|
}
|
|
91902
92407
|
mutate(secrets);
|
|
91903
|
-
await
|
|
92408
|
+
await import_promises30.default.mkdir(import_node_path55.default.dirname(this.filePath), { recursive: true });
|
|
91904
92409
|
const temp = `${this.filePath}.${process.pid}.tmp`;
|
|
91905
92410
|
const body = this.key === void 0 ? secrets : sealSecrets(secrets, this.key);
|
|
91906
|
-
await
|
|
92411
|
+
await import_promises30.default.writeFile(temp, JSON.stringify(body, null, 2), { encoding: "utf8", mode: 384 });
|
|
91907
92412
|
await replaceFile(temp, this.filePath);
|
|
91908
92413
|
this.stamp = await this.currentStamp();
|
|
91909
92414
|
});
|
|
@@ -91935,9 +92440,9 @@ var FileSecretStore = class {
|
|
|
91935
92440
|
};
|
|
91936
92441
|
|
|
91937
92442
|
// src/reviewQueue.ts
|
|
91938
|
-
var
|
|
91939
|
-
var
|
|
91940
|
-
var
|
|
92443
|
+
var import_node_crypto19 = __toESM(require("node:crypto"), 1);
|
|
92444
|
+
var import_promises31 = __toESM(require("node:fs/promises"), 1);
|
|
92445
|
+
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
91941
92446
|
var ReviewQueue = class {
|
|
91942
92447
|
constructor(filePath) {
|
|
91943
92448
|
this.filePath = filePath;
|
|
@@ -91947,7 +92452,7 @@ var ReviewQueue = class {
|
|
|
91947
92452
|
async load() {
|
|
91948
92453
|
if (this.cache !== void 0) return this.cache;
|
|
91949
92454
|
try {
|
|
91950
|
-
const parsed = JSON.parse(await
|
|
92455
|
+
const parsed = JSON.parse(await import_promises31.default.readFile(this.filePath, "utf8"));
|
|
91951
92456
|
this.cache = Array.isArray(parsed) ? parsed : [];
|
|
91952
92457
|
} catch {
|
|
91953
92458
|
this.cache = [];
|
|
@@ -91956,9 +92461,9 @@ var ReviewQueue = class {
|
|
|
91956
92461
|
}
|
|
91957
92462
|
async persist(items) {
|
|
91958
92463
|
this.cache = items;
|
|
91959
|
-
await
|
|
92464
|
+
await import_promises31.default.mkdir(import_node_path56.default.dirname(this.filePath), { recursive: true });
|
|
91960
92465
|
const temporary = `${this.filePath}.tmp`;
|
|
91961
|
-
await
|
|
92466
|
+
await import_promises31.default.writeFile(temporary, JSON.stringify(items, null, 2), { encoding: "utf8", mode: 384 });
|
|
91962
92467
|
await replaceFile(temporary, this.filePath);
|
|
91963
92468
|
}
|
|
91964
92469
|
async list() {
|
|
@@ -91974,7 +92479,7 @@ var ReviewQueue = class {
|
|
|
91974
92479
|
);
|
|
91975
92480
|
const queued = {
|
|
91976
92481
|
...request,
|
|
91977
|
-
id:
|
|
92482
|
+
id: import_node_crypto19.default.randomUUID(),
|
|
91978
92483
|
submittedAt: Date.now(),
|
|
91979
92484
|
status: "pending"
|
|
91980
92485
|
};
|
|
@@ -92196,9 +92701,9 @@ var RoutedSecretStore = class {
|
|
|
92196
92701
|
};
|
|
92197
92702
|
|
|
92198
92703
|
// src/userVariables.ts
|
|
92199
|
-
var
|
|
92704
|
+
var import_promises32 = __toESM(require("node:fs/promises"), 1);
|
|
92200
92705
|
var import_node_fs12 = require("node:fs");
|
|
92201
|
-
var
|
|
92706
|
+
var import_node_path57 = __toESM(require("node:path"), 1);
|
|
92202
92707
|
var UserVariableStore = class {
|
|
92203
92708
|
constructor(filePath) {
|
|
92204
92709
|
this.filePath = filePath;
|
|
@@ -92213,9 +92718,9 @@ var UserVariableStore = class {
|
|
|
92213
92718
|
}
|
|
92214
92719
|
async save(variables) {
|
|
92215
92720
|
const parsed = sessionVariablesSchema.parse(variables);
|
|
92216
|
-
await
|
|
92721
|
+
await import_promises32.default.mkdir(import_node_path57.default.dirname(this.filePath), { recursive: true });
|
|
92217
92722
|
const temporary = `${this.filePath}.tmp`;
|
|
92218
|
-
await
|
|
92723
|
+
await import_promises32.default.writeFile(temporary, JSON.stringify({ variables: parsed }, null, 2), {
|
|
92219
92724
|
encoding: "utf8",
|
|
92220
92725
|
mode: 384
|
|
92221
92726
|
});
|
|
@@ -92224,10 +92729,10 @@ var UserVariableStore = class {
|
|
|
92224
92729
|
}
|
|
92225
92730
|
};
|
|
92226
92731
|
function userVariableStoreFor(dataDir, principal) {
|
|
92227
|
-
return new UserVariableStore(userVariablesPath(
|
|
92732
|
+
return new UserVariableStore(userVariablesPath(import_node_path57.default.join(dataDir, "users", storageKeyFor(principal))));
|
|
92228
92733
|
}
|
|
92229
92734
|
function userVariablesPath(userDir) {
|
|
92230
|
-
return
|
|
92735
|
+
return import_node_path57.default.join(userDir, "variables.json");
|
|
92231
92736
|
}
|
|
92232
92737
|
function readVariablesFile(filePath) {
|
|
92233
92738
|
try {
|
|
@@ -92256,12 +92761,12 @@ function hostedUser(env2 = process.env) {
|
|
|
92256
92761
|
|
|
92257
92762
|
// src/session.ts
|
|
92258
92763
|
var import_node_fs13 = require("node:fs");
|
|
92259
|
-
var
|
|
92260
|
-
var
|
|
92764
|
+
var import_promises33 = __toESM(require("node:fs/promises"), 1);
|
|
92765
|
+
var import_node_path59 = __toESM(require("node:path"), 1);
|
|
92261
92766
|
|
|
92262
92767
|
// src/credentialTool.ts
|
|
92263
92768
|
var import_node_child_process18 = require("node:child_process");
|
|
92264
|
-
var
|
|
92769
|
+
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
92265
92770
|
var CREDENTIAL_PREFIX2 = "tool:";
|
|
92266
92771
|
var WRAPPER = [
|
|
92267
92772
|
"import importlib.util, json, sys",
|
|
@@ -92281,7 +92786,7 @@ async function fetchCredential(options, reference) {
|
|
|
92281
92786
|
if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
|
|
92282
92787
|
const budget = options.timeoutMs ?? 3e4;
|
|
92283
92788
|
const run3 = await new Promise((resolve) => {
|
|
92284
|
-
const child = (0, import_node_child_process18.spawn)(options.interpreter, ["-c", WRAPPER,
|
|
92789
|
+
const child = (0, import_node_child_process18.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path58.default.resolve(options.file), name], {
|
|
92285
92790
|
windowsHide: true,
|
|
92286
92791
|
// The environment this was started in, as with the identity function: the libraries that
|
|
92287
92792
|
// hold credentials are configured through it, and nothing here is model-authored.
|
|
@@ -92466,7 +92971,7 @@ var FileConfigStore = class {
|
|
|
92466
92971
|
const filePath = this.pathFor(scope);
|
|
92467
92972
|
if (filePath === void 0) return void 0;
|
|
92468
92973
|
try {
|
|
92469
|
-
return await
|
|
92974
|
+
return await import_promises33.default.readFile(filePath, "utf8");
|
|
92470
92975
|
} catch (error51) {
|
|
92471
92976
|
if (error51.code === "ENOENT") return void 0;
|
|
92472
92977
|
throw error51;
|
|
@@ -92477,13 +92982,13 @@ var FileConfigStore = class {
|
|
|
92477
92982
|
const filePath = this.pathFor(scope);
|
|
92478
92983
|
if (filePath === void 0)
|
|
92479
92984
|
throw new Error(`Cannot write ${scope} config: no workspace is open`);
|
|
92480
|
-
await
|
|
92985
|
+
await import_promises33.default.mkdir(import_node_path59.default.dirname(filePath), { recursive: true });
|
|
92481
92986
|
const temporary = `${filePath}.${process.pid.toString(36)}.tmp`;
|
|
92482
|
-
await
|
|
92987
|
+
await import_promises33.default.writeFile(temporary, contents, { encoding: "utf8", mode: 384 });
|
|
92483
92988
|
await replaceFile(temporary, filePath);
|
|
92484
92989
|
try {
|
|
92485
92990
|
const backupTemp = `${configBackupPath(filePath)}.tmp`;
|
|
92486
|
-
await
|
|
92991
|
+
await import_promises33.default.writeFile(backupTemp, contents, { encoding: "utf8", mode: 384 });
|
|
92487
92992
|
await replaceFile(backupTemp, configBackupPath(filePath));
|
|
92488
92993
|
} catch {
|
|
92489
92994
|
}
|
|
@@ -92492,7 +92997,7 @@ var FileConfigStore = class {
|
|
|
92492
92997
|
const filePath = this.pathFor(scope);
|
|
92493
92998
|
if (filePath === void 0) return void 0;
|
|
92494
92999
|
try {
|
|
92495
|
-
return await
|
|
93000
|
+
return await import_promises33.default.readFile(configBackupPath(filePath), "utf8");
|
|
92496
93001
|
} catch {
|
|
92497
93002
|
return void 0;
|
|
92498
93003
|
}
|
|
@@ -92502,7 +93007,7 @@ var FileConfigStore = class {
|
|
|
92502
93007
|
if (filePath === void 0) return void 0;
|
|
92503
93008
|
const target = `${filePath}.corrupt-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
|
|
92504
93009
|
try {
|
|
92505
|
-
await
|
|
93010
|
+
await import_promises33.default.rename(filePath, target);
|
|
92506
93011
|
return target;
|
|
92507
93012
|
} catch {
|
|
92508
93013
|
return void 0;
|
|
@@ -92514,8 +93019,8 @@ var FileConfigStore = class {
|
|
|
92514
93019
|
};
|
|
92515
93020
|
let watcher;
|
|
92516
93021
|
try {
|
|
92517
|
-
watcher = (0, import_node_fs13.watch)(
|
|
92518
|
-
if (filename ===
|
|
93022
|
+
watcher = (0, import_node_fs13.watch)(import_node_path59.default.dirname(filePath), (_event, filename) => {
|
|
93023
|
+
if (filename === import_node_path59.default.basename(filePath)) onChange();
|
|
92519
93024
|
});
|
|
92520
93025
|
} catch {
|
|
92521
93026
|
}
|
|
@@ -92530,7 +93035,7 @@ var FileWorkspaceState = class {
|
|
|
92530
93035
|
values = {};
|
|
92531
93036
|
async load() {
|
|
92532
93037
|
try {
|
|
92533
|
-
const parsed = JSON.parse(await
|
|
93038
|
+
const parsed = JSON.parse(await import_promises33.default.readFile(this.filePath, "utf8"));
|
|
92534
93039
|
if (typeof parsed === "object" && parsed !== null)
|
|
92535
93040
|
this.values = parsed;
|
|
92536
93041
|
} catch {
|
|
@@ -92543,8 +93048,8 @@ var FileWorkspaceState = class {
|
|
|
92543
93048
|
async set(key2, value) {
|
|
92544
93049
|
if (value === void 0) delete this.values[key2];
|
|
92545
93050
|
else this.values[key2] = value;
|
|
92546
|
-
await
|
|
92547
|
-
await
|
|
93051
|
+
await import_promises33.default.mkdir(import_node_path59.default.dirname(this.filePath), { recursive: true });
|
|
93052
|
+
await import_promises33.default.writeFile(this.filePath, JSON.stringify(this.values, null, 2), {
|
|
92548
93053
|
encoding: "utf8",
|
|
92549
93054
|
mode: 384
|
|
92550
93055
|
});
|
|
@@ -92592,7 +93097,7 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
|
|
|
92592
93097
|
openFile: async (filePath) => {
|
|
92593
93098
|
try {
|
|
92594
93099
|
post(
|
|
92595
|
-
[`[info] ${
|
|
93100
|
+
[`[info] ${import_node_path59.default.basename(filePath)}`, "", await import_promises33.default.readFile(filePath, "utf8")].join("\n")
|
|
92596
93101
|
);
|
|
92597
93102
|
} catch (error51) {
|
|
92598
93103
|
post(`[warning] Could not read ${filePath}: ${String(error51)}`);
|
|
@@ -92627,14 +93132,14 @@ function createBrowserUi(workspaceRoot, post, fastFs) {
|
|
|
92627
93132
|
if (found2.length >= limit || level > 12 || depth !== void 0 && level > depth) return;
|
|
92628
93133
|
let entries;
|
|
92629
93134
|
try {
|
|
92630
|
-
entries = await
|
|
93135
|
+
entries = await import_promises33.default.readdir(dir, { withFileTypes: true });
|
|
92631
93136
|
} catch {
|
|
92632
93137
|
return;
|
|
92633
93138
|
}
|
|
92634
93139
|
for (const entry of entries) {
|
|
92635
93140
|
if (found2.length >= limit) return;
|
|
92636
93141
|
if (entry.name.startsWith(".") && entry.name !== ".env") continue;
|
|
92637
|
-
const full =
|
|
93142
|
+
const full = import_node_path59.default.join(dir, entry.name);
|
|
92638
93143
|
if (entry.isDirectory()) {
|
|
92639
93144
|
if (!skip.has(entry.name)) await walk(full, level + 1);
|
|
92640
93145
|
} else if (depth !== void 0 && level !== depth) {
|
|
@@ -92670,11 +93175,11 @@ var SHARED_COLLECTIONS = [
|
|
|
92670
93175
|
{ key: "mcpServers" }
|
|
92671
93176
|
];
|
|
92672
93177
|
async function createSession(options) {
|
|
92673
|
-
const userDir =
|
|
92674
|
-
await
|
|
93178
|
+
const userDir = import_node_path59.default.join(options.dataDir, "users", storageKeyFor(options.principal));
|
|
93179
|
+
await import_promises33.default.mkdir(userDir, { recursive: true, mode: 448 });
|
|
92675
93180
|
const variableStore = new UserVariableStore(userVariablesPath(userDir));
|
|
92676
93181
|
const userVariables = () => variableStore.read();
|
|
92677
|
-
const workspaceState = new FileWorkspaceState(
|
|
93182
|
+
const workspaceState = new FileWorkspaceState(import_node_path59.default.join(userDir, "workspace-state.json"));
|
|
92678
93183
|
await workspaceState.load();
|
|
92679
93184
|
const services = {
|
|
92680
93185
|
/*
|
|
@@ -92738,6 +93243,7 @@ async function createSession(options) {
|
|
|
92738
93243
|
...options.siblings !== void 0 && options.siblings.length > 0 ? { siblings: options.siblings } : {},
|
|
92739
93244
|
...options.changeLedger !== void 0 ? { changeLedger: options.changeLedger } : {},
|
|
92740
93245
|
...options.mirrorRoot !== void 0 ? { mirrorRoot: options.mirrorRoot } : {},
|
|
93246
|
+
...options.codebaseDir !== void 0 ? { codebaseDir: options.codebaseDir } : {},
|
|
92741
93247
|
...options.mentionName !== void 0 ? { mentionName: options.mentionName } : {},
|
|
92742
93248
|
...options.jupyterHub !== void 0 ? { jupyterHub: options.jupyterHub } : {},
|
|
92743
93249
|
...options.siblingHubs !== void 0 ? { siblingHubs: options.siblingHubs } : {},
|
|
@@ -92761,16 +93267,16 @@ async function createSession(options) {
|
|
|
92761
93267
|
*/
|
|
92762
93268
|
secrets: new CredentialPointerStore(
|
|
92763
93269
|
withCredentialTool(
|
|
92764
|
-
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ??
|
|
92765
|
-
new FileSecretStore(options.secretsFile ??
|
|
93270
|
+
options.sharedSecrets === void 0 ? new FileSecretStore(options.secretsFile ?? import_node_path59.default.join(userDir, "secrets.json"), options.secretsKey) : new RoutedSecretStore(
|
|
93271
|
+
new FileSecretStore(options.secretsFile ?? import_node_path59.default.join(userDir, "secrets.json"), options.secretsKey),
|
|
92766
93272
|
options.sharedSecrets
|
|
92767
93273
|
),
|
|
92768
93274
|
options
|
|
92769
93275
|
)
|
|
92770
93276
|
),
|
|
92771
93277
|
configStore: withSharedEntries(
|
|
92772
|
-
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ??
|
|
92773
|
-
new FileConfigStore(options.configFile ??
|
|
93278
|
+
options.sharedProfiles === void 0 ? new FileConfigStore(options.configFile ?? import_node_path59.default.join(userDir, "config.json"), options.workspaceRoot) : new SharedProfileConfigStore(
|
|
93279
|
+
new FileConfigStore(options.configFile ?? import_node_path59.default.join(userDir, "config.json"), options.workspaceRoot),
|
|
92774
93280
|
options.sharedProfiles
|
|
92775
93281
|
),
|
|
92776
93282
|
options
|
|
@@ -92888,8 +93394,8 @@ async function startServer(options) {
|
|
|
92888
93394
|
));
|
|
92889
93395
|
const roles = options.roles ?? SINGLE_USER_POLICY;
|
|
92890
93396
|
const sharedStore = options.sharedConfig;
|
|
92891
|
-
const sharedSecretStore = new FileSecretStore(
|
|
92892
|
-
const reviews = new ReviewQueue(
|
|
93397
|
+
const sharedSecretStore = new FileSecretStore(import_node_path60.default.join(options.dataDir, "shared-secrets.json"));
|
|
93398
|
+
const reviews = new ReviewQueue(import_node_path60.default.join(options.dataDir, "reviews.json"));
|
|
92893
93399
|
let sharedCache = {
|
|
92894
93400
|
variables: [],
|
|
92895
93401
|
adminIds: [],
|
|
@@ -93265,14 +93771,14 @@ async function startServer(options) {
|
|
|
93265
93771
|
return "No workspace is open, so there is nowhere to write it.";
|
|
93266
93772
|
try {
|
|
93267
93773
|
if (item.kind === "skill") {
|
|
93268
|
-
const dir2 =
|
|
93269
|
-
await
|
|
93270
|
-
await
|
|
93774
|
+
const dir2 = import_node_path60.default.join(options.workspaceRoot, ".lightcode", "skills");
|
|
93775
|
+
await import_promises34.default.mkdir(dir2, { recursive: true });
|
|
93776
|
+
await import_promises34.default.writeFile(import_node_path60.default.join(dir2, `${item.name}.md`), item.content, "utf8");
|
|
93271
93777
|
return void 0;
|
|
93272
93778
|
}
|
|
93273
|
-
const dir =
|
|
93274
|
-
await
|
|
93275
|
-
await
|
|
93779
|
+
const dir = import_node_path60.default.join(options.workspaceRoot, ".lightcode", "tools");
|
|
93780
|
+
await import_promises34.default.mkdir(dir, { recursive: true });
|
|
93781
|
+
await import_promises34.default.writeFile(import_node_path60.default.join(dir, `${item.name}.py`), item.content, "utf8");
|
|
93276
93782
|
return void 0;
|
|
93277
93783
|
} catch (error51) {
|
|
93278
93784
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -93295,7 +93801,7 @@ async function startServer(options) {
|
|
|
93295
93801
|
async function readCredentials() {
|
|
93296
93802
|
if (options.credentialsFile === void 0) return [];
|
|
93297
93803
|
try {
|
|
93298
|
-
const parsed = JSON.parse(await
|
|
93804
|
+
const parsed = JSON.parse(await import_promises34.default.readFile(options.credentialsFile, "utf8"));
|
|
93299
93805
|
const list = Array.isArray(parsed.credentials) ? parsed.credentials : [];
|
|
93300
93806
|
return list.flatMap((entry) => {
|
|
93301
93807
|
const c2 = entry;
|
|
@@ -93421,7 +93927,7 @@ async function startServer(options) {
|
|
|
93421
93927
|
return;
|
|
93422
93928
|
}
|
|
93423
93929
|
response.writeHead(200, {
|
|
93424
|
-
"Content-Type": CONTENT_TYPES2[
|
|
93930
|
+
"Content-Type": CONTENT_TYPES2[import_node_path60.default.extname(asset)] ?? "application/octet-stream",
|
|
93425
93931
|
...securityHeaders()
|
|
93426
93932
|
});
|
|
93427
93933
|
response.end(body);
|