token-goat 2.6.10 → 2.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/token-goat.mjs +928 -519
- package/package.json +1 -1
package/dist/token-goat.mjs
CHANGED
|
@@ -987,7 +987,7 @@ var require_command = __commonJS({
|
|
|
987
987
|
var EventEmitter3 = __require("node:events").EventEmitter;
|
|
988
988
|
var childProcess2 = __require("node:child_process");
|
|
989
989
|
var path56 = __require("node:path");
|
|
990
|
-
var
|
|
990
|
+
var fs50 = __require("node:fs");
|
|
991
991
|
var process6 = __require("node:process");
|
|
992
992
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
993
993
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1920,10 +1920,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1920
1920
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1921
1921
|
function findFile(baseDir, baseName) {
|
|
1922
1922
|
const localBin = path56.resolve(baseDir, baseName);
|
|
1923
|
-
if (
|
|
1923
|
+
if (fs50.existsSync(localBin)) return localBin;
|
|
1924
1924
|
if (sourceExt.includes(path56.extname(baseName))) return void 0;
|
|
1925
1925
|
const foundExt = sourceExt.find(
|
|
1926
|
-
(ext2) =>
|
|
1926
|
+
(ext2) => fs50.existsSync(`${localBin}${ext2}`)
|
|
1927
1927
|
);
|
|
1928
1928
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1929
1929
|
return void 0;
|
|
@@ -1935,7 +1935,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1935
1935
|
if (this._scriptPath) {
|
|
1936
1936
|
let resolvedScriptPath;
|
|
1937
1937
|
try {
|
|
1938
|
-
resolvedScriptPath =
|
|
1938
|
+
resolvedScriptPath = fs50.realpathSync(this._scriptPath);
|
|
1939
1939
|
} catch (err3) {
|
|
1940
1940
|
resolvedScriptPath = this._scriptPath;
|
|
1941
1941
|
}
|
|
@@ -3163,27 +3163,27 @@ var require_filesystem = __commonJS({
|
|
|
3163
3163
|
"node_modules/detect-libc/lib/filesystem.js"(exports2, module) {
|
|
3164
3164
|
"use strict";
|
|
3165
3165
|
init_define_import_meta_env();
|
|
3166
|
-
var
|
|
3166
|
+
var fs50 = __require("fs");
|
|
3167
3167
|
var LDD_PATH = "/usr/bin/ldd";
|
|
3168
3168
|
var SELF_PATH = "/proc/self/exe";
|
|
3169
3169
|
var MAX_LENGTH = 2048;
|
|
3170
3170
|
var readFileSync39 = (path56) => {
|
|
3171
|
-
const fd2 =
|
|
3171
|
+
const fd2 = fs50.openSync(path56, "r");
|
|
3172
3172
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
3173
|
-
const bytesRead =
|
|
3174
|
-
|
|
3173
|
+
const bytesRead = fs50.readSync(fd2, buffer, 0, MAX_LENGTH, 0);
|
|
3174
|
+
fs50.close(fd2, () => {
|
|
3175
3175
|
});
|
|
3176
3176
|
return buffer.subarray(0, bytesRead);
|
|
3177
3177
|
};
|
|
3178
3178
|
var readFile3 = (path56) => new Promise((resolve20, reject) => {
|
|
3179
|
-
|
|
3179
|
+
fs50.open(path56, "r", (err3, fd2) => {
|
|
3180
3180
|
if (err3) {
|
|
3181
3181
|
reject(err3);
|
|
3182
3182
|
} else {
|
|
3183
3183
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
3184
|
-
|
|
3184
|
+
fs50.read(fd2, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
3185
3185
|
resolve20(buffer.subarray(0, bytesRead));
|
|
3186
|
-
|
|
3186
|
+
fs50.close(fd2, () => {
|
|
3187
3187
|
});
|
|
3188
3188
|
});
|
|
3189
3189
|
}
|
|
@@ -22124,12 +22124,12 @@ var require_dist = __commonJS({
|
|
|
22124
22124
|
throw new Error(`Unknown format "${name2}"`);
|
|
22125
22125
|
return f;
|
|
22126
22126
|
};
|
|
22127
|
-
function addFormats(ajv, list,
|
|
22127
|
+
function addFormats(ajv, list, fs50, exportName) {
|
|
22128
22128
|
var _a10;
|
|
22129
22129
|
var _b3;
|
|
22130
22130
|
(_a10 = (_b3 = ajv.opts.code).formats) !== null && _a10 !== void 0 ? _a10 : _b3.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
22131
22131
|
for (const f of list)
|
|
22132
|
-
ajv.addFormat(f,
|
|
22132
|
+
ajv.addFormat(f, fs50[f]);
|
|
22133
22133
|
}
|
|
22134
22134
|
module.exports = exports2 = formatsPlugin;
|
|
22135
22135
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -22901,8 +22901,8 @@ function blend(fg2, bg, alpha) {
|
|
|
22901
22901
|
return Math.round(alpha * fg2 + (1 - alpha) * bg);
|
|
22902
22902
|
}
|
|
22903
22903
|
async function node_utils_fetchData(url2) {
|
|
22904
|
-
const
|
|
22905
|
-
const data = await
|
|
22904
|
+
const fs50 = process.getBuiltinModule("fs/promises");
|
|
22905
|
+
const data = await fs50.readFile(url2);
|
|
22906
22906
|
return new Uint8Array(data);
|
|
22907
22907
|
}
|
|
22908
22908
|
function convertBlackAndWhiteToRGBA({
|
|
@@ -23541,11 +23541,11 @@ function network_getArrayBuffer(val) {
|
|
|
23541
23541
|
return typeof val !== "string" ? val : stringToBytes(val).buffer;
|
|
23542
23542
|
}
|
|
23543
23543
|
function getReadableStream(url2, opts = null) {
|
|
23544
|
-
const
|
|
23544
|
+
const fs50 = process.getBuiltinModule("fs");
|
|
23545
23545
|
const {
|
|
23546
23546
|
Readable
|
|
23547
23547
|
} = process.getBuiltinModule("stream");
|
|
23548
|
-
const readStream =
|
|
23548
|
+
const readStream = fs50.createReadStream(url2, opts);
|
|
23549
23549
|
return Readable.toWeb(readStream);
|
|
23550
23550
|
}
|
|
23551
23551
|
function getNetworkStream(url2) {
|
|
@@ -40342,8 +40342,8 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
40342
40342
|
url: url2
|
|
40343
40343
|
} = stream._source;
|
|
40344
40344
|
this._isStreamingSupported = !disableStream;
|
|
40345
|
-
const
|
|
40346
|
-
|
|
40345
|
+
const fs50 = process.getBuiltinModule("fs/promises");
|
|
40346
|
+
fs50.lstat(url2).then((stat2) => {
|
|
40347
40347
|
const readableStream = getReadableStream(url2);
|
|
40348
40348
|
this._reader = readableStream.getReader();
|
|
40349
40349
|
const {
|
|
@@ -122336,14 +122336,14 @@ var require_emscripten_module_WASM_RELEASE_SYNC = __commonJS({
|
|
|
122336
122336
|
});
|
|
122337
122337
|
var p = Object.assign({}, a), t = "./this.program", u = "object" == typeof window, v = "function" == typeof importScripts, w = "object" == typeof process && "object" == typeof process.versions && "string" == typeof process.versions.node, x = "", y, z2, A;
|
|
122338
122338
|
if (w) {
|
|
122339
|
-
var
|
|
122339
|
+
var fs50 = __require("fs"), B = __require("path");
|
|
122340
122340
|
x = v ? B.dirname(x) + "/" : __dirname + "/";
|
|
122341
122341
|
y = (b, c) => {
|
|
122342
122342
|
var d = C2(b);
|
|
122343
122343
|
if (d)
|
|
122344
122344
|
return c ? d : d.toString();
|
|
122345
122345
|
b = b.startsWith("file://") ? new URL(b) : B.normalize(b);
|
|
122346
|
-
return
|
|
122346
|
+
return fs50.readFileSync(b, c ? void 0 : "utf8");
|
|
122347
122347
|
};
|
|
122348
122348
|
A = (b) => {
|
|
122349
122349
|
b = y(b, true);
|
|
@@ -122354,7 +122354,7 @@ var require_emscripten_module_WASM_RELEASE_SYNC = __commonJS({
|
|
|
122354
122354
|
var e = C2(b);
|
|
122355
122355
|
e && c(e);
|
|
122356
122356
|
b = b.startsWith("file://") ? new URL(b) : B.normalize(b);
|
|
122357
|
-
|
|
122357
|
+
fs50.readFile(b, function(f, g) {
|
|
122358
122358
|
f ? d(f) : c(g.buffer);
|
|
122359
122359
|
});
|
|
122360
122360
|
};
|
|
@@ -124016,7 +124016,7 @@ var init_chromium = __esm({
|
|
|
124016
124016
|
});
|
|
124017
124017
|
|
|
124018
124018
|
// node_modules/@puppeteer/browsers/lib/esm/browser-data/firefox.js
|
|
124019
|
-
import
|
|
124019
|
+
import fs31 from "fs";
|
|
124020
124020
|
import path38 from "path";
|
|
124021
124021
|
function getFormat(buildId) {
|
|
124022
124022
|
const majorVersion = Number(buildId.split(".").shift());
|
|
@@ -124147,8 +124147,8 @@ async function resolveBuildId3(channel = FirefoxChannel.NIGHTLY) {
|
|
|
124147
124147
|
return channel + "_" + version3;
|
|
124148
124148
|
}
|
|
124149
124149
|
async function createProfile(options) {
|
|
124150
|
-
if (!
|
|
124151
|
-
await
|
|
124150
|
+
if (!fs31.existsSync(options.path)) {
|
|
124151
|
+
await fs31.promises.mkdir(options.path, {
|
|
124152
124152
|
recursive: true
|
|
124153
124153
|
});
|
|
124154
124154
|
}
|
|
@@ -124320,10 +124320,10 @@ function defaultProfilePreferences(extraPrefs) {
|
|
|
124320
124320
|
return Object.assign(defaultPrefs, extraPrefs);
|
|
124321
124321
|
}
|
|
124322
124322
|
async function backupFile2(input) {
|
|
124323
|
-
if (!
|
|
124323
|
+
if (!fs31.existsSync(input)) {
|
|
124324
124324
|
return;
|
|
124325
124325
|
}
|
|
124326
|
-
await
|
|
124326
|
+
await fs31.promises.copyFile(input, input + ".puppeteer");
|
|
124327
124327
|
}
|
|
124328
124328
|
async function syncPreferences(options) {
|
|
124329
124329
|
const prefsPath = path38.join(options.path, "prefs.js");
|
|
@@ -124333,7 +124333,7 @@ async function syncPreferences(options) {
|
|
|
124333
124333
|
});
|
|
124334
124334
|
const result = await Promise.allSettled([
|
|
124335
124335
|
backupFile2(userPath).then(async () => {
|
|
124336
|
-
await
|
|
124336
|
+
await fs31.promises.writeFile(userPath, lines.join("\n"));
|
|
124337
124337
|
}),
|
|
124338
124338
|
backupFile2(prefsPath)
|
|
124339
124339
|
]);
|
|
@@ -124578,7 +124578,7 @@ var init_detectPlatform = __esm({
|
|
|
124578
124578
|
});
|
|
124579
124579
|
|
|
124580
124580
|
// node_modules/@puppeteer/browsers/lib/esm/Cache.js
|
|
124581
|
-
import
|
|
124581
|
+
import fs32 from "fs";
|
|
124582
124582
|
import os14 from "os";
|
|
124583
124583
|
import path39 from "path";
|
|
124584
124584
|
function parseFolderPath(folderPath) {
|
|
@@ -124654,10 +124654,10 @@ var init_Cache = __esm({
|
|
|
124654
124654
|
}
|
|
124655
124655
|
readMetadata(browser) {
|
|
124656
124656
|
const metatadaPath = this.metadataFile(browser);
|
|
124657
|
-
if (!
|
|
124657
|
+
if (!fs32.existsSync(metatadaPath)) {
|
|
124658
124658
|
return { aliases: {} };
|
|
124659
124659
|
}
|
|
124660
|
-
const data = JSON.parse(
|
|
124660
|
+
const data = JSON.parse(fs32.readFileSync(metatadaPath, "utf8"));
|
|
124661
124661
|
if (typeof data !== "object") {
|
|
124662
124662
|
throw new Error(".metadata is not an object");
|
|
124663
124663
|
}
|
|
@@ -124665,8 +124665,8 @@ var init_Cache = __esm({
|
|
|
124665
124665
|
}
|
|
124666
124666
|
writeMetadata(browser, metadata) {
|
|
124667
124667
|
const metatadaPath = this.metadataFile(browser);
|
|
124668
|
-
|
|
124669
|
-
|
|
124668
|
+
fs32.mkdirSync(path39.dirname(metatadaPath), { recursive: true });
|
|
124669
|
+
fs32.writeFileSync(metatadaPath, JSON.stringify(metadata, null, 2));
|
|
124670
124670
|
}
|
|
124671
124671
|
resolveAlias(browser, alias) {
|
|
124672
124672
|
const metadata = this.readMetadata(browser);
|
|
@@ -124679,7 +124679,7 @@ var init_Cache = __esm({
|
|
|
124679
124679
|
return path39.join(this.browserRoot(browser), `${platform}-${buildId}`);
|
|
124680
124680
|
}
|
|
124681
124681
|
clear() {
|
|
124682
|
-
|
|
124682
|
+
fs32.rmSync(this.#rootDir, {
|
|
124683
124683
|
force: true,
|
|
124684
124684
|
recursive: true,
|
|
124685
124685
|
maxRetries: 10,
|
|
@@ -124693,7 +124693,7 @@ var init_Cache = __esm({
|
|
|
124693
124693
|
delete metadata.aliases[alias];
|
|
124694
124694
|
}
|
|
124695
124695
|
}
|
|
124696
|
-
|
|
124696
|
+
fs32.rmSync(this.installationDir(browser, platform, buildId), {
|
|
124697
124697
|
force: true,
|
|
124698
124698
|
recursive: true,
|
|
124699
124699
|
maxRetries: 10,
|
|
@@ -124701,15 +124701,15 @@ var init_Cache = __esm({
|
|
|
124701
124701
|
});
|
|
124702
124702
|
}
|
|
124703
124703
|
getInstalledBrowsers() {
|
|
124704
|
-
if (!
|
|
124704
|
+
if (!fs32.existsSync(this.#rootDir)) {
|
|
124705
124705
|
return [];
|
|
124706
124706
|
}
|
|
124707
|
-
const types2 =
|
|
124707
|
+
const types2 = fs32.readdirSync(this.#rootDir);
|
|
124708
124708
|
const browsers = types2.filter((t) => {
|
|
124709
124709
|
return Object.values(Browser3).includes(t);
|
|
124710
124710
|
});
|
|
124711
124711
|
return browsers.flatMap((browser) => {
|
|
124712
|
-
const files =
|
|
124712
|
+
const files = fs32.readdirSync(this.browserRoot(browser));
|
|
124713
124713
|
return files.map((file2) => {
|
|
124714
124714
|
const result = parseFolderPath(path39.join(this.browserRoot(browser), file2));
|
|
124715
124715
|
if (!result) {
|
|
@@ -125230,9 +125230,9 @@ var require_pump = __commonJS({
|
|
|
125230
125230
|
init_define_import_meta_env();
|
|
125231
125231
|
var once = require_once();
|
|
125232
125232
|
var eos = require_end_of_stream();
|
|
125233
|
-
var
|
|
125233
|
+
var fs50;
|
|
125234
125234
|
try {
|
|
125235
|
-
|
|
125235
|
+
fs50 = __require("fs");
|
|
125236
125236
|
} catch (e) {
|
|
125237
125237
|
}
|
|
125238
125238
|
var noop2 = function() {
|
|
@@ -125243,8 +125243,8 @@ var require_pump = __commonJS({
|
|
|
125243
125243
|
};
|
|
125244
125244
|
var isFS = function(stream) {
|
|
125245
125245
|
if (!ancient) return false;
|
|
125246
|
-
if (!
|
|
125247
|
-
return (stream instanceof (
|
|
125246
|
+
if (!fs50) return false;
|
|
125247
|
+
return (stream instanceof (fs50.ReadStream || noop2) || stream instanceof (fs50.WriteStream || noop2)) && isFn(stream.close);
|
|
125248
125248
|
};
|
|
125249
125249
|
var isRequest = function(stream) {
|
|
125250
125250
|
return stream.setHeader && isFn(stream.abort);
|
|
@@ -125460,7 +125460,7 @@ var require_pend = __commonJS({
|
|
|
125460
125460
|
var require_fd_slicer = __commonJS({
|
|
125461
125461
|
"node_modules/fd-slicer/index.js"(exports2) {
|
|
125462
125462
|
init_define_import_meta_env();
|
|
125463
|
-
var
|
|
125463
|
+
var fs50 = __require("fs");
|
|
125464
125464
|
var util2 = __require("util");
|
|
125465
125465
|
var stream = __require("stream");
|
|
125466
125466
|
var Readable = stream.Readable;
|
|
@@ -125485,7 +125485,7 @@ var require_fd_slicer = __commonJS({
|
|
|
125485
125485
|
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
125486
125486
|
var self2 = this;
|
|
125487
125487
|
self2.pend.go(function(cb) {
|
|
125488
|
-
|
|
125488
|
+
fs50.read(self2.fd, buffer, offset, length, position, function(err3, bytesRead, buffer2) {
|
|
125489
125489
|
cb();
|
|
125490
125490
|
callback(err3, bytesRead, buffer2);
|
|
125491
125491
|
});
|
|
@@ -125494,7 +125494,7 @@ var require_fd_slicer = __commonJS({
|
|
|
125494
125494
|
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
125495
125495
|
var self2 = this;
|
|
125496
125496
|
self2.pend.go(function(cb) {
|
|
125497
|
-
|
|
125497
|
+
fs50.write(self2.fd, buffer, offset, length, position, function(err3, written, buffer2) {
|
|
125498
125498
|
cb();
|
|
125499
125499
|
callback(err3, written, buffer2);
|
|
125500
125500
|
});
|
|
@@ -125515,7 +125515,7 @@ var require_fd_slicer = __commonJS({
|
|
|
125515
125515
|
if (self2.refCount > 0) return;
|
|
125516
125516
|
if (self2.refCount < 0) throw new Error("invalid unref");
|
|
125517
125517
|
if (self2.autoClose) {
|
|
125518
|
-
|
|
125518
|
+
fs50.close(self2.fd, onCloseDone);
|
|
125519
125519
|
}
|
|
125520
125520
|
function onCloseDone(err3) {
|
|
125521
125521
|
if (err3) {
|
|
@@ -125552,7 +125552,7 @@ var require_fd_slicer = __commonJS({
|
|
|
125552
125552
|
self2.context.pend.go(function(cb) {
|
|
125553
125553
|
if (self2.destroyed) return cb();
|
|
125554
125554
|
var buffer = new Buffer(toRead);
|
|
125555
|
-
|
|
125555
|
+
fs50.read(self2.context.fd, buffer, 0, toRead, self2.pos, function(err3, bytesRead) {
|
|
125556
125556
|
if (err3) {
|
|
125557
125557
|
self2.destroy(err3);
|
|
125558
125558
|
} else if (bytesRead === 0) {
|
|
@@ -125599,7 +125599,7 @@ var require_fd_slicer = __commonJS({
|
|
|
125599
125599
|
}
|
|
125600
125600
|
self2.context.pend.go(function(cb) {
|
|
125601
125601
|
if (self2.destroyed) return cb();
|
|
125602
|
-
|
|
125602
|
+
fs50.write(self2.context.fd, buffer, 0, buffer.length, self2.pos, function(err4, bytes) {
|
|
125603
125603
|
if (err4) {
|
|
125604
125604
|
self2.destroy();
|
|
125605
125605
|
cb();
|
|
@@ -126028,7 +126028,7 @@ var require_buffer_crc32 = __commonJS({
|
|
|
126028
126028
|
var require_yauzl = __commonJS({
|
|
126029
126029
|
"node_modules/yauzl/index.js"(exports2) {
|
|
126030
126030
|
init_define_import_meta_env();
|
|
126031
|
-
var
|
|
126031
|
+
var fs50 = __require("fs");
|
|
126032
126032
|
var zlib2 = __require("zlib");
|
|
126033
126033
|
var fd_slicer = require_fd_slicer();
|
|
126034
126034
|
var crc32 = require_buffer_crc32();
|
|
@@ -126058,10 +126058,10 @@ var require_yauzl = __commonJS({
|
|
|
126058
126058
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
126059
126059
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
126060
126060
|
if (callback == null) callback = defaultCallback;
|
|
126061
|
-
|
|
126061
|
+
fs50.open(path56, "r", function(err3, fd2) {
|
|
126062
126062
|
if (err3) return callback(err3);
|
|
126063
126063
|
fromFd(fd2, options, function(err4, zipfile) {
|
|
126064
|
-
if (err4)
|
|
126064
|
+
if (err4) fs50.close(fd2, defaultCallback);
|
|
126065
126065
|
callback(err4, zipfile);
|
|
126066
126066
|
});
|
|
126067
126067
|
});
|
|
@@ -126078,7 +126078,7 @@ var require_yauzl = __commonJS({
|
|
|
126078
126078
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
126079
126079
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
126080
126080
|
if (callback == null) callback = defaultCallback;
|
|
126081
|
-
|
|
126081
|
+
fs50.fstat(fd2, function(err3, stats) {
|
|
126082
126082
|
if (err3) return callback(err3);
|
|
126083
126083
|
var reader = fd_slicer.createFromFd(fd2, { autoClose: true });
|
|
126084
126084
|
fromRandomAccessReader(reader, stats.size, options, callback);
|
|
@@ -126659,7 +126659,7 @@ var require_extract_zip = __commonJS({
|
|
|
126659
126659
|
"node_modules/extract-zip/index.js"(exports2, module) {
|
|
126660
126660
|
init_define_import_meta_env();
|
|
126661
126661
|
var debug5 = require_src()("extract-zip");
|
|
126662
|
-
var { createWriteStream, promises:
|
|
126662
|
+
var { createWriteStream, promises: fs50 } = __require("fs");
|
|
126663
126663
|
var getStream = require_get_stream();
|
|
126664
126664
|
var path56 = __require("path");
|
|
126665
126665
|
var { promisify: promisify2 } = __require("util");
|
|
@@ -126700,8 +126700,8 @@ var require_extract_zip = __commonJS({
|
|
|
126700
126700
|
}
|
|
126701
126701
|
const destDir = path56.dirname(path56.join(this.opts.dir, entry.fileName));
|
|
126702
126702
|
try {
|
|
126703
|
-
await
|
|
126704
|
-
const canonicalDestDir = await
|
|
126703
|
+
await fs50.mkdir(destDir, { recursive: true });
|
|
126704
|
+
const canonicalDestDir = await fs50.realpath(destDir);
|
|
126705
126705
|
const relativeDestDir = path56.relative(this.opts.dir, canonicalDestDir);
|
|
126706
126706
|
if (relativeDestDir.split(path56.sep).includes("..")) {
|
|
126707
126707
|
throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
|
|
@@ -126745,14 +126745,14 @@ var require_extract_zip = __commonJS({
|
|
|
126745
126745
|
mkdirOptions.mode = procMode;
|
|
126746
126746
|
}
|
|
126747
126747
|
debug5("mkdir", { dir: destDir, ...mkdirOptions });
|
|
126748
|
-
await
|
|
126748
|
+
await fs50.mkdir(destDir, mkdirOptions);
|
|
126749
126749
|
if (isDir) return;
|
|
126750
126750
|
debug5("opening read stream", dest);
|
|
126751
126751
|
const readStream = await promisify2(this.zipfile.openReadStream.bind(this.zipfile))(entry);
|
|
126752
126752
|
if (symlink) {
|
|
126753
126753
|
const link = await getStream(readStream);
|
|
126754
126754
|
debug5("creating symlink", link, dest);
|
|
126755
|
-
await
|
|
126755
|
+
await fs50.symlink(link, dest);
|
|
126756
126756
|
} else {
|
|
126757
126757
|
await pipeline(readStream, createWriteStream(dest, { mode: procMode }));
|
|
126758
126758
|
}
|
|
@@ -126784,8 +126784,8 @@ var require_extract_zip = __commonJS({
|
|
|
126784
126784
|
if (!path56.isAbsolute(opts.dir)) {
|
|
126785
126785
|
throw new Error("Target directory is expected to be absolute");
|
|
126786
126786
|
}
|
|
126787
|
-
await
|
|
126788
|
-
opts.dir = await
|
|
126787
|
+
await fs50.mkdir(opts.dir, { recursive: true });
|
|
126788
|
+
opts.dir = await fs50.realpath(opts.dir);
|
|
126789
126789
|
return new Extractor(zipPath, opts).extract();
|
|
126790
126790
|
};
|
|
126791
126791
|
}
|
|
@@ -129233,13 +129233,13 @@ var require_tar_fs = __commonJS({
|
|
|
129233
129233
|
init_define_import_meta_env();
|
|
129234
129234
|
var tar2 = require_tar_stream();
|
|
129235
129235
|
var pump = require_pump();
|
|
129236
|
-
var
|
|
129236
|
+
var fs50 = __require("fs");
|
|
129237
129237
|
var path56 = __require("path");
|
|
129238
129238
|
var win323 = (global.Bare ? global.Bare.platform : process.platform) === "win32";
|
|
129239
129239
|
exports2.pack = function pack(cwd, opts) {
|
|
129240
129240
|
if (!cwd) cwd = ".";
|
|
129241
129241
|
if (!opts) opts = {};
|
|
129242
|
-
const xfs = opts.fs ||
|
|
129242
|
+
const xfs = opts.fs || fs50;
|
|
129243
129243
|
const ignore = opts.ignore || opts.filter || noop2;
|
|
129244
129244
|
const mapStream = opts.mapStream || echo;
|
|
129245
129245
|
const statNext = statAll(xfs, opts.dereference ? xfs.stat : xfs.lstat, cwd, ignore, opts.entries, opts.sort);
|
|
@@ -129327,7 +129327,7 @@ var require_tar_fs = __commonJS({
|
|
|
129327
129327
|
if (!cwd) cwd = ".";
|
|
129328
129328
|
if (!opts) opts = {};
|
|
129329
129329
|
cwd = path56.resolve(cwd);
|
|
129330
|
-
const xfs = opts.fs ||
|
|
129330
|
+
const xfs = opts.fs || fs50;
|
|
129331
129331
|
const ignore = opts.ignore || opts.filter || noop2;
|
|
129332
129332
|
const mapStream = opts.mapStream || echo;
|
|
129333
129333
|
const own = opts.chown !== false && !win323 && processGetuid() === 0;
|
|
@@ -129497,20 +129497,20 @@ var require_tar_fs = __commonJS({
|
|
|
129497
129497
|
});
|
|
129498
129498
|
}
|
|
129499
129499
|
};
|
|
129500
|
-
function validateNotSymlink(
|
|
129500
|
+
function validateNotSymlink(fs51, name2, root, cb) {
|
|
129501
129501
|
if (name2 === root) return cb(null, true);
|
|
129502
129502
|
if (!name2.startsWith(root + path56.sep)) return cb(null, false);
|
|
129503
|
-
|
|
129503
|
+
fs51.lstat(name2, function(err3, st) {
|
|
129504
129504
|
if (err3 && err3.code !== "ENOENT" && err3.code !== "EPERM") return cb(err3);
|
|
129505
|
-
if (err3 || !st.isSymbolicLink()) return validateNotSymlink(
|
|
129505
|
+
if (err3 || !st.isSymbolicLink()) return validateNotSymlink(fs51, path56.join(name2, ".."), root, cb);
|
|
129506
129506
|
cb(null, false);
|
|
129507
129507
|
});
|
|
129508
129508
|
}
|
|
129509
|
-
function validate2(
|
|
129509
|
+
function validate2(fs51, name2, root, cb) {
|
|
129510
129510
|
if (name2 === root) return cb(null, true);
|
|
129511
|
-
|
|
129511
|
+
fs51.lstat(name2, function(err3, st) {
|
|
129512
129512
|
if (err3 && err3.code !== "ENOENT" && err3.code !== "EPERM") return cb(err3);
|
|
129513
|
-
if (err3 || st.isDirectory()) return validate2(
|
|
129513
|
+
if (err3 || st.isDirectory()) return validate2(fs51, path56.join(name2, ".."), root, cb);
|
|
129514
129514
|
cb(null, false);
|
|
129515
129515
|
});
|
|
129516
129516
|
}
|
|
@@ -129525,7 +129525,7 @@ var require_tar_fs = __commonJS({
|
|
|
129525
129525
|
function normalize3(name2) {
|
|
129526
129526
|
return win323 ? name2.replace(/\\/g, "/").replace(/[:?<>|]/g, "_") : name2;
|
|
129527
129527
|
}
|
|
129528
|
-
function statAll(
|
|
129528
|
+
function statAll(fs51, stat2, cwd, ignore, entries, sort) {
|
|
129529
129529
|
if (!entries) entries = ["."];
|
|
129530
129530
|
const queue = entries.slice(0);
|
|
129531
129531
|
const root = path56.resolve(cwd);
|
|
@@ -129534,10 +129534,10 @@ var require_tar_fs = __commonJS({
|
|
|
129534
129534
|
const next = queue.shift();
|
|
129535
129535
|
const nextAbs = path56.join(cwd, next);
|
|
129536
129536
|
if (!inside(root, path56.resolve(cwd, next))) return callback(new Error(next + " is not a valid path"));
|
|
129537
|
-
stat2.call(
|
|
129537
|
+
stat2.call(fs51, nextAbs, function(err3, stat3) {
|
|
129538
129538
|
if (err3) return callback(entries.indexOf(next) === -1 && err3.code === "ENOENT" ? null : err3);
|
|
129539
129539
|
if (!stat3.isDirectory()) return callback(null, next, stat3);
|
|
129540
|
-
|
|
129540
|
+
fs51.readdir(nextAbs, function(err4, files) {
|
|
129541
129541
|
if (err4) return callback(err4);
|
|
129542
129542
|
if (sort) files.sort();
|
|
129543
129543
|
for (let i = 0; i < files.length; i++) {
|
|
@@ -135853,9 +135853,9 @@ For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides
|
|
|
135853
135853
|
});
|
|
135854
135854
|
|
|
135855
135855
|
// node_modules/puppeteer-core/lib/esm/puppeteer/node/util/fs.js
|
|
135856
|
-
import
|
|
135856
|
+
import fs33 from "fs";
|
|
135857
135857
|
async function rm(path56) {
|
|
135858
|
-
await
|
|
135858
|
+
await fs33.promises.rm(path56, rmOptions);
|
|
135859
135859
|
}
|
|
135860
135860
|
var rmOptions;
|
|
135861
135861
|
var init_fs = __esm({
|
|
@@ -136096,7 +136096,7 @@ var init_ChromeLauncher = __esm({
|
|
|
136096
136096
|
});
|
|
136097
136097
|
|
|
136098
136098
|
// node_modules/puppeteer-core/lib/esm/puppeteer/node/FirefoxLauncher.js
|
|
136099
|
-
import
|
|
136099
|
+
import fs34 from "fs";
|
|
136100
136100
|
import { rename, unlink, mkdtemp as mkdtemp2 } from "fs/promises";
|
|
136101
136101
|
import os18 from "os";
|
|
136102
136102
|
import path41 from "path";
|
|
@@ -136212,7 +136212,7 @@ var init_FirefoxLauncher = __esm({
|
|
|
136212
136212
|
const backupFiles = ["prefs.js", "user.js"];
|
|
136213
136213
|
const results = await Promise.allSettled(backupFiles.map(async (file2) => {
|
|
136214
136214
|
const prefsBackupPath = path41.join(userDataDir, file2 + backupSuffix);
|
|
136215
|
-
if (
|
|
136215
|
+
if (fs34.existsSync(prefsBackupPath)) {
|
|
136216
136216
|
const prefsPath = path41.join(userDataDir, file2);
|
|
136217
136217
|
await unlink(prefsPath);
|
|
136218
136218
|
await rename(prefsBackupPath, prefsPath);
|
|
@@ -136954,7 +136954,7 @@ __export(puppeteer_core_exports, {
|
|
|
136954
136954
|
valueFromRemoteObject: () => valueFromRemoteObject,
|
|
136955
136955
|
withSourcePuppeteerURLIfNone: () => withSourcePuppeteerURLIfNone
|
|
136956
136956
|
});
|
|
136957
|
-
import
|
|
136957
|
+
import fs35 from "fs";
|
|
136958
136958
|
import path42 from "path";
|
|
136959
136959
|
var puppeteer, connect, defaultArgs, executablePath, launch2, puppeteer_core_default;
|
|
136960
136960
|
var init_puppeteer_core = __esm({
|
|
@@ -136964,7 +136964,7 @@ var init_puppeteer_core = __esm({
|
|
|
136964
136964
|
init_environment();
|
|
136965
136965
|
init_puppeteer();
|
|
136966
136966
|
environment.value = {
|
|
136967
|
-
fs:
|
|
136967
|
+
fs: fs35,
|
|
136968
136968
|
path: path42,
|
|
136969
136969
|
ScreenRecorder
|
|
136970
136970
|
};
|
|
@@ -142132,9 +142132,9 @@ var require_xlsx = __commonJS({
|
|
|
142132
142132
|
}
|
|
142133
142133
|
return o;
|
|
142134
142134
|
}
|
|
142135
|
-
var
|
|
142135
|
+
var fs50;
|
|
142136
142136
|
function get_fs() {
|
|
142137
|
-
return
|
|
142137
|
+
return fs50 || (fs50 = __require("fs"));
|
|
142138
142138
|
}
|
|
142139
142139
|
function parse6(file2, options) {
|
|
142140
142140
|
if (file2[0] == 80 && file2[1] == 75) return parse_zip2(file2, options);
|
|
@@ -142410,7 +142410,7 @@ var require_xlsx = __commonJS({
|
|
|
142410
142410
|
}
|
|
142411
142411
|
function read_file(filename2, options) {
|
|
142412
142412
|
get_fs();
|
|
142413
|
-
return parse6(
|
|
142413
|
+
return parse6(fs50.readFileSync(filename2), options);
|
|
142414
142414
|
}
|
|
142415
142415
|
function read(blob, options) {
|
|
142416
142416
|
var type = options && options.type;
|
|
@@ -142736,7 +142736,7 @@ var require_xlsx = __commonJS({
|
|
|
142736
142736
|
function write_file(cfb, filename2, options) {
|
|
142737
142737
|
get_fs();
|
|
142738
142738
|
var o = _write(cfb, options);
|
|
142739
|
-
|
|
142739
|
+
fs50.writeFileSync(filename2, o);
|
|
142740
142740
|
}
|
|
142741
142741
|
function a2s2(o) {
|
|
142742
142742
|
var out2 = new Array(o.length);
|
|
@@ -142748,7 +142748,7 @@ var require_xlsx = __commonJS({
|
|
|
142748
142748
|
switch (options && options.type || "buffer") {
|
|
142749
142749
|
case "file":
|
|
142750
142750
|
get_fs();
|
|
142751
|
-
|
|
142751
|
+
fs50.writeFileSync(options.filename, o);
|
|
142752
142752
|
return o;
|
|
142753
142753
|
case "binary":
|
|
142754
142754
|
return typeof o == "string" ? o : a2s2(o);
|
|
@@ -169738,7 +169738,7 @@ var require_xlsx = __commonJS({
|
|
|
169738
169738
|
return out2;
|
|
169739
169739
|
}
|
|
169740
169740
|
var qreg = /"/g;
|
|
169741
|
-
function make_csv_row(sheet, r, R, cols,
|
|
169741
|
+
function make_csv_row(sheet, r, R, cols, fs50, rs, FS, o) {
|
|
169742
169742
|
var isempty = true;
|
|
169743
169743
|
var row = [], txt = "", rr = encode_row(R);
|
|
169744
169744
|
for (var C2 = r.s.c; C2 <= r.e.c; ++C2) {
|
|
@@ -169748,7 +169748,7 @@ var require_xlsx = __commonJS({
|
|
|
169748
169748
|
else if (val.v != null) {
|
|
169749
169749
|
isempty = false;
|
|
169750
169750
|
txt = "" + (o.rawNumbers && val.t == "n" ? val.v : format_cell(val, null, o));
|
|
169751
|
-
for (var i = 0, cc = 0; i !== txt.length; ++i) if ((cc = txt.charCodeAt(i)) ===
|
|
169751
|
+
for (var i = 0, cc = 0; i !== txt.length; ++i) if ((cc = txt.charCodeAt(i)) === fs50 || cc === rs || cc === 34 || o.forceQuotes) {
|
|
169752
169752
|
txt = '"' + txt.replace(qreg, '""') + '"';
|
|
169753
169753
|
break;
|
|
169754
169754
|
}
|
|
@@ -169768,7 +169768,7 @@ var require_xlsx = __commonJS({
|
|
|
169768
169768
|
var o = opts == null ? {} : opts;
|
|
169769
169769
|
if (sheet == null || sheet["!ref"] == null) return "";
|
|
169770
169770
|
var r = safe_decode_range(sheet["!ref"]);
|
|
169771
|
-
var FS = o.FS !== void 0 ? o.FS : ",",
|
|
169771
|
+
var FS = o.FS !== void 0 ? o.FS : ",", fs50 = FS.charCodeAt(0);
|
|
169772
169772
|
var RS = o.RS !== void 0 ? o.RS : "\n", rs = RS.charCodeAt(0);
|
|
169773
169773
|
var endregex = new RegExp((FS == "|" ? "\\|" : FS) + "+$");
|
|
169774
169774
|
var row = "", cols = [];
|
|
@@ -169779,7 +169779,7 @@ var require_xlsx = __commonJS({
|
|
|
169779
169779
|
var w = 0;
|
|
169780
169780
|
for (var R = r.s.r; R <= r.e.r; ++R) {
|
|
169781
169781
|
if ((rowinfo[R] || {}).hidden) continue;
|
|
169782
|
-
row = make_csv_row(sheet, r, R, cols,
|
|
169782
|
+
row = make_csv_row(sheet, r, R, cols, fs50, rs, FS, o);
|
|
169783
169783
|
if (row == null) {
|
|
169784
169784
|
continue;
|
|
169785
169785
|
}
|
|
@@ -170051,7 +170051,7 @@ var require_xlsx = __commonJS({
|
|
|
170051
170051
|
return stream;
|
|
170052
170052
|
}
|
|
170053
170053
|
var r = safe_decode_range(sheet["!ref"]);
|
|
170054
|
-
var FS = o.FS !== void 0 ? o.FS : ",",
|
|
170054
|
+
var FS = o.FS !== void 0 ? o.FS : ",", fs50 = FS.charCodeAt(0);
|
|
170055
170055
|
var RS = o.RS !== void 0 ? o.RS : "\n", rs = RS.charCodeAt(0);
|
|
170056
170056
|
var endregex = new RegExp((FS == "|" ? "\\|" : FS) + "+$");
|
|
170057
170057
|
var row = "", cols = [];
|
|
@@ -170069,7 +170069,7 @@ var require_xlsx = __commonJS({
|
|
|
170069
170069
|
while (R <= r.e.r) {
|
|
170070
170070
|
++R;
|
|
170071
170071
|
if ((rowinfo[R - 1] || {}).hidden) continue;
|
|
170072
|
-
row = make_csv_row(sheet, r, R - 1, cols,
|
|
170072
|
+
row = make_csv_row(sheet, r, R - 1, cols, fs50, rs, FS, o);
|
|
170073
170073
|
if (row != null) {
|
|
170074
170074
|
if (o.strip) row = row.replace(endregex, "");
|
|
170075
170075
|
if (row || o.blankrows !== false) return stream.push((w++ ? RS : "") + row);
|
|
@@ -178679,13 +178679,13 @@ var {
|
|
|
178679
178679
|
} = import_index.default;
|
|
178680
178680
|
|
|
178681
178681
|
// src/cli.ts
|
|
178682
|
-
import * as
|
|
178682
|
+
import * as fs49 from "fs";
|
|
178683
178683
|
import * as path55 from "path";
|
|
178684
178684
|
import { homedir as homedir15 } from "os";
|
|
178685
178685
|
|
|
178686
178686
|
// src/baseline.ts
|
|
178687
178687
|
init_define_import_meta_env();
|
|
178688
|
-
import * as
|
|
178688
|
+
import * as fs4 from "node:fs";
|
|
178689
178689
|
import * as path6 from "node:path";
|
|
178690
178690
|
|
|
178691
178691
|
// src/constants.ts
|
|
@@ -178698,7 +178698,7 @@ init_define_import_meta_env();
|
|
|
178698
178698
|
import { createRequire } from "node:module";
|
|
178699
178699
|
function resolveVersion() {
|
|
178700
178700
|
if (true) {
|
|
178701
|
-
return "2.6.
|
|
178701
|
+
return "2.6.11";
|
|
178702
178702
|
}
|
|
178703
178703
|
const require3 = createRequire(import.meta.url);
|
|
178704
178704
|
const pkg = require3("../package.json");
|
|
@@ -178778,7 +178778,7 @@ var ENV_KEYS = {
|
|
|
178778
178778
|
|
|
178779
178779
|
// src/config.ts
|
|
178780
178780
|
init_define_import_meta_env();
|
|
178781
|
-
import * as
|
|
178781
|
+
import * as fs2 from "node:fs";
|
|
178782
178782
|
|
|
178783
178783
|
// node_modules/smol-toml/dist/index.js
|
|
178784
178784
|
init_define_import_meta_env();
|
|
@@ -179659,9 +179659,28 @@ import * as path3 from "node:path";
|
|
|
179659
179659
|
|
|
179660
179660
|
// src/paths.ts
|
|
179661
179661
|
init_define_import_meta_env();
|
|
179662
|
+
import * as fs from "node:fs";
|
|
179662
179663
|
import * as path2 from "node:path";
|
|
179663
179664
|
var WSL_PATH_RE = /^\/mnt\/([a-zA-Z])\/(.*)$/s;
|
|
179664
179665
|
var UNC_HOST_SHARE_RE = /^\/\/([^/]+)\/([^/]+)/;
|
|
179666
|
+
var SHORT_NAME_RE = /~\d/;
|
|
179667
|
+
function expandShortPath(p) {
|
|
179668
|
+
if (process.platform !== "win32") return p;
|
|
179669
|
+
const segments = p.split("/");
|
|
179670
|
+
let lastShortIdx = -1;
|
|
179671
|
+
for (let i = 0; i < segments.length; i++) {
|
|
179672
|
+
if (SHORT_NAME_RE.test(segments[i])) lastShortIdx = i;
|
|
179673
|
+
}
|
|
179674
|
+
if (lastShortIdx === -1) return p;
|
|
179675
|
+
const prefix = segments.slice(0, lastShortIdx + 1).join("/");
|
|
179676
|
+
const suffix = segments.slice(lastShortIdx + 1).join("/");
|
|
179677
|
+
try {
|
|
179678
|
+
const expandedPrefix = fs.realpathSync.native(prefix).replace(/\\/g, "/");
|
|
179679
|
+
return suffix ? `${expandedPrefix}/${suffix}` : expandedPrefix;
|
|
179680
|
+
} catch {
|
|
179681
|
+
return p;
|
|
179682
|
+
}
|
|
179683
|
+
}
|
|
179665
179684
|
function lowercaseDriveLetter(s) {
|
|
179666
179685
|
if (s.length >= 2 && s[1] === ":") {
|
|
179667
179686
|
const c = s[0];
|
|
@@ -179694,6 +179713,7 @@ function normalizePath(p) {
|
|
|
179694
179713
|
const g = /^\/([a-zA-Z])(\/.*)?$/.exec(s);
|
|
179695
179714
|
if (g) s = `${g[1].toLowerCase()}:${g[2] ?? "/"}`;
|
|
179696
179715
|
}
|
|
179716
|
+
s = expandShortPath(s);
|
|
179697
179717
|
s = lowercaseDriveLetter(s);
|
|
179698
179718
|
return s;
|
|
179699
179719
|
}
|
|
@@ -180197,7 +180217,7 @@ function loadConfig() {
|
|
|
180197
180217
|
const p = configPath();
|
|
180198
180218
|
let currentMtime = 0;
|
|
180199
180219
|
try {
|
|
180200
|
-
currentMtime =
|
|
180220
|
+
currentMtime = fs2.statSync(p).mtimeMs;
|
|
180201
180221
|
} catch {
|
|
180202
180222
|
}
|
|
180203
180223
|
const envFp = configEnvFingerprint();
|
|
@@ -180207,7 +180227,7 @@ function loadConfig() {
|
|
|
180207
180227
|
let raw = {};
|
|
180208
180228
|
if (currentMtime !== 0) {
|
|
180209
180229
|
try {
|
|
180210
|
-
const text =
|
|
180230
|
+
const text = fs2.readFileSync(p, "utf8");
|
|
180211
180231
|
raw = parse(text);
|
|
180212
180232
|
} catch {
|
|
180213
180233
|
}
|
|
@@ -180242,7 +180262,7 @@ function loadPersistedConfig() {
|
|
|
180242
180262
|
const p = configPath();
|
|
180243
180263
|
let raw = {};
|
|
180244
180264
|
try {
|
|
180245
|
-
const text =
|
|
180265
|
+
const text = fs2.readFileSync(p, "utf8");
|
|
180246
180266
|
raw = parse(text);
|
|
180247
180267
|
} catch {
|
|
180248
180268
|
}
|
|
@@ -180668,7 +180688,7 @@ function saveConfig(config3) {
|
|
|
180668
180688
|
|
|
180669
180689
|
// src/db.ts
|
|
180670
180690
|
init_define_import_meta_env();
|
|
180671
|
-
import * as
|
|
180691
|
+
import * as fs3 from "node:fs";
|
|
180672
180692
|
import { createRequire as createRequire2 } from "node:module";
|
|
180673
180693
|
import * as path4 from "node:path";
|
|
180674
180694
|
import Database from "better-sqlite3";
|
|
@@ -180689,8 +180709,21 @@ CREATE TABLE IF NOT EXISTS files (
|
|
|
180689
180709
|
sha TEXT,
|
|
180690
180710
|
mtime REAL,
|
|
180691
180711
|
language TEXT,
|
|
180692
|
-
indexed_at REAL
|
|
180712
|
+
indexed_at REAL,
|
|
180713
|
+
embed_sha TEXT,
|
|
180714
|
+
retry_count INTEGER NOT NULL DEFAULT 0
|
|
180693
180715
|
);
|
|
180716
|
+
-- Expression index on TG_LOWER(path) -- see pathEqClause (sql_path.ts) and TG_LOWER's
|
|
180717
|
+
-- registration above. TG_LOWER is registered { deterministic: true }, which is required for
|
|
180718
|
+
-- SQLite to index an expression at all; without it CREATE INDEX on a function call throws
|
|
180719
|
+
-- "non-deterministic functions prohibited in index expressions". Because pathEqClause emits
|
|
180720
|
+
-- this exact 'TG_LOWER(path) = ?' text for every case-insensitive-filesystem query, the planner
|
|
180721
|
+
-- matches it against this index and uses SEARCH instead of a full table SCAN, without requiring
|
|
180722
|
+
-- any writer to populate a separate folded column (verified via EXPLAIN QUERY PLAN in
|
|
180723
|
+
-- db.test.ts / sql_path.test.ts). CREATE INDEX IF NOT EXISTS is purely additive and safe to run
|
|
180724
|
+
-- against an already-populated table on every connection open, unlike an ALTER TABLE column add
|
|
180725
|
+
-- -- no MIGRATIONS entry or SCHEMA_VERSION bump is needed for this index.
|
|
180726
|
+
CREATE INDEX IF NOT EXISTS idx_files_path_folded ON files(TG_LOWER(path));
|
|
180694
180727
|
|
|
180695
180728
|
CREATE TABLE IF NOT EXISTS symbols (
|
|
180696
180729
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -180705,6 +180738,7 @@ CREATE TABLE IF NOT EXISTS symbols (
|
|
|
180705
180738
|
CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
|
|
180706
180739
|
CREATE INDEX IF NOT EXISTS idx_symbols_file ON symbols(file_path);
|
|
180707
180740
|
CREATE INDEX IF NOT EXISTS idx_symbols_name_kind ON symbols(name, kind);
|
|
180741
|
+
CREATE INDEX IF NOT EXISTS idx_symbols_file_folded ON symbols(TG_LOWER(file_path));
|
|
180708
180742
|
|
|
180709
180743
|
CREATE TABLE IF NOT EXISTS refs (
|
|
180710
180744
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -180716,6 +180750,7 @@ CREATE TABLE IF NOT EXISTS refs (
|
|
|
180716
180750
|
);
|
|
180717
180751
|
CREATE INDEX IF NOT EXISTS idx_refs_name ON refs(name);
|
|
180718
180752
|
CREATE INDEX IF NOT EXISTS idx_refs_file ON refs(file_path);
|
|
180753
|
+
CREATE INDEX IF NOT EXISTS idx_refs_file_folded ON refs(TG_LOWER(file_path));
|
|
180719
180754
|
|
|
180720
180755
|
CREATE TABLE IF NOT EXISTS chunks (
|
|
180721
180756
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -180726,6 +180761,7 @@ CREATE TABLE IF NOT EXISTS chunks (
|
|
|
180726
180761
|
kind TEXT
|
|
180727
180762
|
);
|
|
180728
180763
|
CREATE INDEX IF NOT EXISTS idx_chunks_file ON chunks(file_path);
|
|
180764
|
+
CREATE INDEX IF NOT EXISTS idx_chunks_file_folded ON chunks(TG_LOWER(file_path));
|
|
180729
180765
|
`;
|
|
180730
180766
|
var FTS_SQL = `
|
|
180731
180767
|
CREATE VIRTUAL TABLE IF NOT EXISTS symbols_fts USING fts5(
|
|
@@ -180750,8 +180786,39 @@ CREATE TRIGGER IF NOT EXISTS symbols_au AFTER UPDATE ON symbols BEGIN
|
|
|
180750
180786
|
VALUES (new.id, new.name, new.body, new.docstring);
|
|
180751
180787
|
END;
|
|
180752
180788
|
`;
|
|
180753
|
-
var SCHEMA_VERSION =
|
|
180754
|
-
var MIGRATIONS = {
|
|
180789
|
+
var SCHEMA_VERSION = 3;
|
|
180790
|
+
var MIGRATIONS = {
|
|
180791
|
+
// v1 -> v2: adds files.embed_sha, tracked separately from files.sha so embedding freshness
|
|
180792
|
+
// can be gated independently of parse freshness (see makeIndexer in worker.ts). A pre-existing
|
|
180793
|
+
// v1 database's `files` table predates the column, so it needs an explicit ALTER TABLE here;
|
|
180794
|
+
// a brand-new database already has the column from SCHEMA_SQL's CREATE TABLE above, so the
|
|
180795
|
+
// ALTER TABLE would fail with "duplicate column name" there -- swallow exactly that error and
|
|
180796
|
+
// rethrow anything else, so a genuine ALTER TABLE failure is never silently lost.
|
|
180797
|
+
1: (conn) => {
|
|
180798
|
+
try {
|
|
180799
|
+
conn.exec("ALTER TABLE files ADD COLUMN embed_sha TEXT");
|
|
180800
|
+
} catch (err3) {
|
|
180801
|
+
if (!(err3 instanceof Error) || !/duplicate column/i.test(err3.message)) throw err3;
|
|
180802
|
+
}
|
|
180803
|
+
},
|
|
180804
|
+
// v2 -> v3: adds files.retry_count, a durable per-path counter for consecutive
|
|
180805
|
+
// transient-read-failure requeues (see MAX_TRANSIENT_RETRIES / requeueDirtyPath /
|
|
180806
|
+
// resetTransientRetryCount in worker.ts). Previously this counter lived only in an
|
|
180807
|
+
// in-memory Map inside worker.ts, which meant resetTransientRetryCount -- called from
|
|
180808
|
+
// appendDirtyPath (hooks_index.ts) in the short-lived hook CLI process -- could never
|
|
180809
|
+
// actually reach the long-lived detached daemon process's own copy of that Map: they are
|
|
180810
|
+
// different Node processes with no shared memory, so the reset was a silent no-op in the
|
|
180811
|
+
// real deployed topology. Persisting the counter in `files` makes it visible to both
|
|
180812
|
+
// processes via the one thing they do share: the index DB. Same swallow-duplicate-column
|
|
180813
|
+
// pattern as v1 -> v2 above.
|
|
180814
|
+
2: (conn) => {
|
|
180815
|
+
try {
|
|
180816
|
+
conn.exec("ALTER TABLE files ADD COLUMN retry_count INTEGER NOT NULL DEFAULT 0");
|
|
180817
|
+
} catch (err3) {
|
|
180818
|
+
if (!(err3 instanceof Error) || !/duplicate column/i.test(err3.message)) throw err3;
|
|
180819
|
+
}
|
|
180820
|
+
}
|
|
180821
|
+
};
|
|
180755
180822
|
function runMigrations(conn, fromVersion, toVersion) {
|
|
180756
180823
|
for (let v = fromVersion; v < toVersion; v++) {
|
|
180757
180824
|
MIGRATIONS[v]?.(conn);
|
|
@@ -180806,9 +180873,9 @@ function getDb(dbPath) {
|
|
|
180806
180873
|
if (existing !== void 0) return existing;
|
|
180807
180874
|
const dir = path4.dirname(resolved);
|
|
180808
180875
|
try {
|
|
180809
|
-
|
|
180876
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
180810
180877
|
} catch (e) {
|
|
180811
|
-
if (e.code !== "EEXIST" || !
|
|
180878
|
+
if (e.code !== "EEXIST" || !fs3.existsSync(dir)) throw e;
|
|
180812
180879
|
}
|
|
180813
180880
|
const conn = new Database(resolved);
|
|
180814
180881
|
try {
|
|
@@ -180977,7 +181044,7 @@ function walkProject(rootDir, opts = {}) {
|
|
|
180977
181044
|
if (dir === void 0) break;
|
|
180978
181045
|
let entries;
|
|
180979
181046
|
try {
|
|
180980
|
-
entries =
|
|
181047
|
+
entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
180981
181048
|
} catch {
|
|
180982
181049
|
continue;
|
|
180983
181050
|
}
|
|
@@ -181033,7 +181100,7 @@ function buildProjectMap(rootDir = process.cwd(), opts = {}) {
|
|
|
181033
181100
|
const recentFiles = files.map((f) => {
|
|
181034
181101
|
let mtime;
|
|
181035
181102
|
try {
|
|
181036
|
-
mtime =
|
|
181103
|
+
mtime = fs4.statSync(f).mtimeMs;
|
|
181037
181104
|
} catch {
|
|
181038
181105
|
mtime = 0;
|
|
181039
181106
|
}
|
|
@@ -181742,7 +181809,17 @@ function _renderHeader(stats) {
|
|
|
181742
181809
|
}
|
|
181743
181810
|
return [line];
|
|
181744
181811
|
}
|
|
181745
|
-
function
|
|
181812
|
+
function _renderShortHint() {
|
|
181813
|
+
return [
|
|
181814
|
+
"",
|
|
181815
|
+
`${_M}${fg(...C.TEXT_MUTED)}Run 'token-goat stats --full' for the full breakdown (by source, by command, by day).${RESET}`
|
|
181816
|
+
];
|
|
181817
|
+
}
|
|
181818
|
+
function renderStats(stats, opts) {
|
|
181819
|
+
if (opts?.short) {
|
|
181820
|
+
const sections2 = [_renderHeader(stats), _renderKpiSection(stats), _renderShortHint(), [""]];
|
|
181821
|
+
return sections2.flatMap((s) => s).join("\n");
|
|
181822
|
+
}
|
|
181746
181823
|
const sections = [
|
|
181747
181824
|
_renderHeader(stats),
|
|
181748
181825
|
_renderKpiSection(stats),
|
|
@@ -182023,27 +182100,7 @@ function _plainTextStats(summary) {
|
|
|
182023
182100
|
}
|
|
182024
182101
|
console.log(lines.join("\n"));
|
|
182025
182102
|
}
|
|
182026
|
-
function
|
|
182027
|
-
const windowDays = opts?.windowDays ?? 30;
|
|
182028
|
-
const summary = summarize(windowDays, void 0, opts?.homeDir);
|
|
182029
|
-
if (summary.total_events === 0) {
|
|
182030
|
-
console.log("No stats recorded yet.");
|
|
182031
|
-
return;
|
|
182032
|
-
}
|
|
182033
|
-
_renderShortTotals(summary);
|
|
182034
|
-
}
|
|
182035
|
-
function renderStats2(opts) {
|
|
182036
|
-
const windowDays = opts?.windowDays ?? 30;
|
|
182037
|
-
const summary = summarize(windowDays, void 0, opts?.homeDir);
|
|
182038
|
-
if (summary.total_events === 0) {
|
|
182039
|
-
console.log("No stats recorded yet.");
|
|
182040
|
-
return;
|
|
182041
|
-
}
|
|
182042
|
-
const useTty = process.stdout.isTTY === true && !process.env["NO_COLOR"];
|
|
182043
|
-
if (!useTty) {
|
|
182044
|
-
_plainTextStats(summary);
|
|
182045
|
-
return;
|
|
182046
|
-
}
|
|
182103
|
+
function _buildStatsData(summary, windowDays) {
|
|
182047
182104
|
const now = /* @__PURE__ */ new Date();
|
|
182048
182105
|
const periodStart = windowDays > 0 ? new Date(now.getTime() - windowDays * 24 * 60 * 60 * 1e3) : /* @__PURE__ */ new Date(0);
|
|
182049
182106
|
const sparkDays = [...summary.by_day].reverse().slice(-30);
|
|
@@ -182052,7 +182109,7 @@ function renderStats2(opts) {
|
|
|
182052
182109
|
bytes: sparkDays.map((d) => d.bytes_saved),
|
|
182053
182110
|
tokens: sparkDays.map((d) => d.tokens_saved)
|
|
182054
182111
|
} : null;
|
|
182055
|
-
|
|
182112
|
+
return {
|
|
182056
182113
|
period_start: periodStart,
|
|
182057
182114
|
period_end: now,
|
|
182058
182115
|
version: VERSION,
|
|
@@ -182090,6 +182147,35 @@ function renderStats2(opts) {
|
|
|
182090
182147
|
events: c.events
|
|
182091
182148
|
}))
|
|
182092
182149
|
};
|
|
182150
|
+
}
|
|
182151
|
+
function renderShortStats(opts) {
|
|
182152
|
+
const windowDays = opts?.windowDays ?? 30;
|
|
182153
|
+
const summary = summarize(windowDays, void 0, opts?.homeDir);
|
|
182154
|
+
if (summary.total_events === 0) {
|
|
182155
|
+
console.log("No stats recorded yet.");
|
|
182156
|
+
return;
|
|
182157
|
+
}
|
|
182158
|
+
const useTty = process.stdout.isTTY === true && !process.env["NO_COLOR"];
|
|
182159
|
+
if (!useTty) {
|
|
182160
|
+
_renderShortTotals(summary);
|
|
182161
|
+
return;
|
|
182162
|
+
}
|
|
182163
|
+
const statsData = _buildStatsData(summary, windowDays);
|
|
182164
|
+
process.stdout.write(renderStats(statsData, { short: true }) + "\n");
|
|
182165
|
+
}
|
|
182166
|
+
function renderStats2(opts) {
|
|
182167
|
+
const windowDays = opts?.windowDays ?? 30;
|
|
182168
|
+
const summary = summarize(windowDays, void 0, opts?.homeDir);
|
|
182169
|
+
if (summary.total_events === 0) {
|
|
182170
|
+
console.log("No stats recorded yet.");
|
|
182171
|
+
return;
|
|
182172
|
+
}
|
|
182173
|
+
const useTty = process.stdout.isTTY === true && !process.env["NO_COLOR"];
|
|
182174
|
+
if (!useTty) {
|
|
182175
|
+
_plainTextStats(summary);
|
|
182176
|
+
return;
|
|
182177
|
+
}
|
|
182178
|
+
const statsData = _buildStatsData(summary, windowDays);
|
|
182093
182179
|
process.stdout.write(renderStats(statsData) + "\n");
|
|
182094
182180
|
}
|
|
182095
182181
|
|
|
@@ -182176,14 +182262,17 @@ function queryRefCounts(names, dbPath = globalDbPath()) {
|
|
|
182176
182262
|
}
|
|
182177
182263
|
function getFileEntry(filePath, dbPath = globalDbPath()) {
|
|
182178
182264
|
const db = getDb(dbPath);
|
|
182179
|
-
const row = db.prepare(
|
|
182265
|
+
const row = db.prepare(
|
|
182266
|
+
`SELECT path, sha, mtime, language, indexed_at, embed_sha FROM files WHERE ${pathEqClause("path")}`
|
|
182267
|
+
).get(foldPath(filePath));
|
|
182180
182268
|
if (row === void 0) return null;
|
|
182181
182269
|
return {
|
|
182182
182270
|
filePath: row.path,
|
|
182183
182271
|
sha: row.sha ?? "",
|
|
182184
182272
|
mtime: row.mtime ?? 0,
|
|
182185
182273
|
language: row.language ?? "unknown",
|
|
182186
|
-
indexedAt: row.indexed_at ?? 0
|
|
182274
|
+
indexedAt: row.indexed_at ?? 0,
|
|
182275
|
+
embedSha: row.embed_sha ?? ""
|
|
182187
182276
|
};
|
|
182188
182277
|
}
|
|
182189
182278
|
function sanitizeFtsQuery(query) {
|
|
@@ -182204,7 +182293,7 @@ function searchSymbolsFts(query, limit = 50, dbPath = globalDbPath()) {
|
|
|
182204
182293
|
|
|
182205
182294
|
// src/compact.ts
|
|
182206
182295
|
init_define_import_meta_env();
|
|
182207
|
-
import * as
|
|
182296
|
+
import * as fs11 from "node:fs";
|
|
182208
182297
|
import * as path13 from "node:path";
|
|
182209
182298
|
|
|
182210
182299
|
// src/bridges/index.ts
|
|
@@ -182233,7 +182322,7 @@ function detectHarness() {
|
|
|
182233
182322
|
if (env2["HERMES_SESSION_ID"] || env2["HERMES_HOME"]) {
|
|
182234
182323
|
return "hermes";
|
|
182235
182324
|
}
|
|
182236
|
-
if (env2["TERM_PROGRAM"] === "claude-code" || env2["CLAUDE_CODE_VERSION"] !== void 0 || env2["CLAUDE_CODE_SESSION_ID"]
|
|
182325
|
+
if (env2["TERM_PROGRAM"] === "claude-code" || env2["CLAUDE_CODE_VERSION"] !== void 0 || env2["CLAUDE_CODE_SESSION_ID"]) {
|
|
182237
182326
|
return "claudecode";
|
|
182238
182327
|
}
|
|
182239
182328
|
if (env2["CODEX_SESSION_ID"] !== void 0 || env2["CODEX_SESSION"]) {
|
|
@@ -182248,6 +182337,9 @@ function detectHarness() {
|
|
|
182248
182337
|
if (env2["OPENCLAW_SESSION_ID"] !== void 0) {
|
|
182249
182338
|
return "openclaw";
|
|
182250
182339
|
}
|
|
182340
|
+
if (env2["ANTHROPIC_API_KEY"]) {
|
|
182341
|
+
return "claudecode";
|
|
182342
|
+
}
|
|
182251
182343
|
if (env2["OPENAI_API_KEY"] && !env2["ANTHROPIC_API_KEY"]) {
|
|
182252
182344
|
return "codex";
|
|
182253
182345
|
}
|
|
@@ -182368,13 +182460,13 @@ main()
|
|
|
182368
182460
|
|
|
182369
182461
|
// src/bridges/codex_install.ts
|
|
182370
182462
|
init_define_import_meta_env();
|
|
182371
|
-
import * as
|
|
182463
|
+
import * as fs6 from "node:fs";
|
|
182372
182464
|
import * as os3 from "node:os";
|
|
182373
182465
|
import * as path9 from "node:path";
|
|
182374
182466
|
|
|
182375
182467
|
// src/install.ts
|
|
182376
182468
|
init_define_import_meta_env();
|
|
182377
|
-
import * as
|
|
182469
|
+
import * as fs5 from "node:fs";
|
|
182378
182470
|
import * as os2 from "node:os";
|
|
182379
182471
|
import * as path8 from "node:path";
|
|
182380
182472
|
var HOOK_EVENT_MAP = [
|
|
@@ -182410,7 +182502,7 @@ var SettingsParseError = class extends Error {
|
|
|
182410
182502
|
function readSettings(p, opts = {}) {
|
|
182411
182503
|
let raw;
|
|
182412
182504
|
try {
|
|
182413
|
-
raw =
|
|
182505
|
+
raw = fs5.readFileSync(p, "utf8");
|
|
182414
182506
|
} catch {
|
|
182415
182507
|
return {};
|
|
182416
182508
|
}
|
|
@@ -182540,6 +182632,12 @@ function buildClaudeMdBlock() {
|
|
|
182540
182632
|
'- `token-goat section "file::Heading"` -- one doc or config section',
|
|
182541
182633
|
'- `token-goat semantic "description"` -- find code by meaning',
|
|
182542
182634
|
"- `token-goat outline file` / `token-goat skeleton file` -- signatures without bodies",
|
|
182635
|
+
"- `token-goat map --compact` -- project overview (low-token summary)",
|
|
182636
|
+
"- `token-goat refs file::symbol --callers` -- find callers of a symbol",
|
|
182637
|
+
"- `token-goat changed --symbol` -- symbols changed since a git ref",
|
|
182638
|
+
"- `token-goat config-get file KEY` -- read one config value",
|
|
182639
|
+
"- `token-goat bash-output` / `token-goat web-output` -- re-inspect cached output by ID",
|
|
182640
|
+
"- `token-goat gdrive-sections <file-id>` -- outline a Google Doc by ID",
|
|
182543
182641
|
"",
|
|
182544
182642
|
"Use this before a full-file `Read` or wide `Grep`, and before opening a large image",
|
|
182545
182643
|
"(token-goat hooks shrink oversized images automatically). token-goat commands return",
|
|
@@ -182551,7 +182649,7 @@ function writeClaudeMdBlock(p) {
|
|
|
182551
182649
|
const block = buildClaudeMdBlock();
|
|
182552
182650
|
let existing;
|
|
182553
182651
|
try {
|
|
182554
|
-
existing =
|
|
182652
|
+
existing = fs5.readFileSync(p, "utf8");
|
|
182555
182653
|
} catch {
|
|
182556
182654
|
existing = "";
|
|
182557
182655
|
}
|
|
@@ -182579,7 +182677,7 @@ ${block}
|
|
|
182579
182677
|
function stripClaudeMdBlock(p) {
|
|
182580
182678
|
let existing;
|
|
182581
182679
|
try {
|
|
182582
|
-
existing =
|
|
182680
|
+
existing = fs5.readFileSync(p, "utf8");
|
|
182583
182681
|
} catch {
|
|
182584
182682
|
return false;
|
|
182585
182683
|
}
|
|
@@ -182612,7 +182710,7 @@ function uninstallClaudeMd() {
|
|
|
182612
182710
|
}
|
|
182613
182711
|
var SKILL_MD_CONTENT = `---
|
|
182614
182712
|
name: token-goat
|
|
182615
|
-
description: Use before reading whole files or grepping wide. token-goat commands (symbol, read, section, semantic, outline, skeleton) return narrow slices of code and docs at a fraction of the token cost.
|
|
182713
|
+
description: Use before reading whole files or grepping wide. token-goat commands (symbol, read, section, semantic, outline, skeleton, map, refs, changed, config-get, bash-output, web-output, gdrive-sections) return narrow slices of code and docs at a fraction of the token cost.
|
|
182616
182714
|
---
|
|
182617
182715
|
|
|
182618
182716
|
# token-goat
|
|
@@ -182623,6 +182721,12 @@ Prefer token-goat commands over reading whole files:
|
|
|
182623
182721
|
- \`token-goat section "file::Heading"\` -- one doc or config section
|
|
182624
182722
|
- \`token-goat semantic "description"\` -- find code by meaning
|
|
182625
182723
|
- \`token-goat outline file\` / \`token-goat skeleton file\` -- signatures without bodies
|
|
182724
|
+
- \`token-goat map --compact\` -- project overview (low-token summary)
|
|
182725
|
+
- \`token-goat refs file::symbol --callers\` -- find callers of a symbol
|
|
182726
|
+
- \`token-goat changed --symbol\` -- symbols changed since a git ref
|
|
182727
|
+
- \`token-goat config-get file KEY\` -- read one config value
|
|
182728
|
+
- \`token-goat bash-output\` / \`token-goat web-output\` -- re-inspect cached output by ID
|
|
182729
|
+
- \`token-goat gdrive-sections <file-id>\` -- outline a Google Doc by ID
|
|
182626
182730
|
|
|
182627
182731
|
Read is the right call when the file is under about 200 lines, was never indexed (new or
|
|
182628
182732
|
untracked), or is an image (token-goat's hooks shrink oversized images automatically).
|
|
@@ -182640,7 +182744,7 @@ function installSkill() {
|
|
|
182640
182744
|
const p = skillPath();
|
|
182641
182745
|
let existing = null;
|
|
182642
182746
|
try {
|
|
182643
|
-
existing =
|
|
182747
|
+
existing = fs5.readFileSync(p, "utf8");
|
|
182644
182748
|
} catch {
|
|
182645
182749
|
}
|
|
182646
182750
|
if (existing === SKILL_MD_CONTENT) return { path: p, alreadyInstalled: true };
|
|
@@ -182650,8 +182754,8 @@ function installSkill() {
|
|
|
182650
182754
|
}
|
|
182651
182755
|
function uninstallSkill() {
|
|
182652
182756
|
const dir = skillDir();
|
|
182653
|
-
if (!
|
|
182654
|
-
|
|
182757
|
+
if (!fs5.existsSync(dir)) return false;
|
|
182758
|
+
fs5.rmSync(dir, { recursive: true, force: true });
|
|
182655
182759
|
return true;
|
|
182656
182760
|
}
|
|
182657
182761
|
|
|
@@ -182677,7 +182781,7 @@ function codexHookScriptPath() {
|
|
|
182677
182781
|
function readCodexConfig(p, opts = {}) {
|
|
182678
182782
|
let raw;
|
|
182679
182783
|
try {
|
|
182680
|
-
raw =
|
|
182784
|
+
raw = fs6.readFileSync(p, "utf8");
|
|
182681
182785
|
} catch {
|
|
182682
182786
|
return {};
|
|
182683
182787
|
}
|
|
@@ -182791,7 +182895,7 @@ function uninstallCodex() {
|
|
|
182791
182895
|
removedAny = true;
|
|
182792
182896
|
}
|
|
182793
182897
|
try {
|
|
182794
|
-
|
|
182898
|
+
fs6.unlinkSync(scriptPath);
|
|
182795
182899
|
removedAny = true;
|
|
182796
182900
|
} catch {
|
|
182797
182901
|
}
|
|
@@ -182822,7 +182926,7 @@ function writeAgentsBlock(p) {
|
|
|
182822
182926
|
const block = buildAgentsBlock();
|
|
182823
182927
|
let existing;
|
|
182824
182928
|
try {
|
|
182825
|
-
existing =
|
|
182929
|
+
existing = fs6.readFileSync(p, "utf8");
|
|
182826
182930
|
} catch {
|
|
182827
182931
|
existing = "";
|
|
182828
182932
|
}
|
|
@@ -182850,7 +182954,7 @@ ${block}
|
|
|
182850
182954
|
function stripAgentsBlock(p) {
|
|
182851
182955
|
let existing;
|
|
182852
182956
|
try {
|
|
182853
|
-
existing =
|
|
182957
|
+
existing = fs6.readFileSync(p, "utf8");
|
|
182854
182958
|
} catch {
|
|
182855
182959
|
return false;
|
|
182856
182960
|
}
|
|
@@ -183143,7 +183247,7 @@ process.exitCode = 0
|
|
|
183143
183247
|
|
|
183144
183248
|
// src/bridges/copilot_cli_install.ts
|
|
183145
183249
|
init_define_import_meta_env();
|
|
183146
|
-
import * as
|
|
183250
|
+
import * as fs7 from "node:fs";
|
|
183147
183251
|
import * as os4 from "node:os";
|
|
183148
183252
|
import * as path10 from "node:path";
|
|
183149
183253
|
var COPILOT_CLI_HOOK_EVENTS = [
|
|
@@ -183174,18 +183278,29 @@ function hookCommandFor2(scriptPath, event) {
|
|
|
183174
183278
|
const entryArg = entryPath ? ` "${entryPath}"` : "";
|
|
183175
183279
|
return `"${process.execPath}" "${scriptPath}" ${event}${entryArg}`;
|
|
183176
183280
|
}
|
|
183281
|
+
function hookPowershellCommandFor(scriptPath, event) {
|
|
183282
|
+
return `& ${hookCommandFor2(scriptPath, event)}`;
|
|
183283
|
+
}
|
|
183177
183284
|
var HOOK_TIMEOUT_SEC = 60;
|
|
183178
183285
|
function buildConfig(scriptPath) {
|
|
183179
183286
|
const hooks = {};
|
|
183180
183287
|
for (const event of COPILOT_CLI_HOOK_EVENTS) {
|
|
183181
|
-
hooks[event] = [
|
|
183288
|
+
hooks[event] = [
|
|
183289
|
+
{
|
|
183290
|
+
type: "command",
|
|
183291
|
+
command: hookCommandFor2(scriptPath, event),
|
|
183292
|
+
bash: hookCommandFor2(scriptPath, event),
|
|
183293
|
+
powershell: hookPowershellCommandFor(scriptPath, event),
|
|
183294
|
+
timeoutSec: HOOK_TIMEOUT_SEC
|
|
183295
|
+
}
|
|
183296
|
+
];
|
|
183182
183297
|
}
|
|
183183
183298
|
return { version: 1, hooks };
|
|
183184
183299
|
}
|
|
183185
183300
|
function writeIfDifferent(p, content, backup = false) {
|
|
183186
183301
|
let existing;
|
|
183187
183302
|
try {
|
|
183188
|
-
existing =
|
|
183303
|
+
existing = fs7.readFileSync(p, "utf8");
|
|
183189
183304
|
} catch {
|
|
183190
183305
|
existing = void 0;
|
|
183191
183306
|
}
|
|
@@ -183208,12 +183323,12 @@ function uninstallCopilotCli(opts = {}) {
|
|
|
183208
183323
|
const scriptPath = copilotCliScriptPath(opts);
|
|
183209
183324
|
let removedAny = false;
|
|
183210
183325
|
try {
|
|
183211
|
-
|
|
183326
|
+
fs7.unlinkSync(configPath2);
|
|
183212
183327
|
removedAny = true;
|
|
183213
183328
|
} catch {
|
|
183214
183329
|
}
|
|
183215
183330
|
try {
|
|
183216
|
-
|
|
183331
|
+
fs7.unlinkSync(scriptPath);
|
|
183217
183332
|
removedAny = true;
|
|
183218
183333
|
} catch {
|
|
183219
183334
|
}
|
|
@@ -183222,7 +183337,7 @@ function uninstallCopilotCli(opts = {}) {
|
|
|
183222
183337
|
|
|
183223
183338
|
// src/disk_cache.ts
|
|
183224
183339
|
init_define_import_meta_env();
|
|
183225
|
-
import * as
|
|
183340
|
+
import * as fs8 from "node:fs";
|
|
183226
183341
|
import * as path11 from "node:path";
|
|
183227
183342
|
import * as os5 from "node:os";
|
|
183228
183343
|
var DEFAULT_MAX_COUNT = 200;
|
|
@@ -183275,7 +183390,7 @@ function storeBlob(subdir, id, value, opts = {}) {
|
|
|
183275
183390
|
if (Number.isFinite(maxBytesPerItem) && Buffer.byteLength(json2, "utf-8") > maxBytesPerItem) return false;
|
|
183276
183391
|
try {
|
|
183277
183392
|
const dir = path11.dirname(p);
|
|
183278
|
-
if (!
|
|
183393
|
+
if (!fs8.existsSync(dir)) fs8.mkdirSync(dir, { recursive: true });
|
|
183279
183394
|
atomicWriteText(p, json2);
|
|
183280
183395
|
} catch {
|
|
183281
183396
|
return false;
|
|
@@ -183293,8 +183408,8 @@ function loadBlob(subdir, id) {
|
|
|
183293
183408
|
const p = blobPath(subdir, id);
|
|
183294
183409
|
if (!p) return null;
|
|
183295
183410
|
try {
|
|
183296
|
-
if (!
|
|
183297
|
-
return JSON.parse(
|
|
183411
|
+
if (!fs8.existsSync(p)) return null;
|
|
183412
|
+
return JSON.parse(fs8.readFileSync(p, "utf8"));
|
|
183298
183413
|
} catch {
|
|
183299
183414
|
return null;
|
|
183300
183415
|
}
|
|
@@ -183303,13 +183418,13 @@ function listBlobs(subdir) {
|
|
|
183303
183418
|
const dir = blobDir(subdir);
|
|
183304
183419
|
const out2 = [];
|
|
183305
183420
|
try {
|
|
183306
|
-
if (!
|
|
183307
|
-
for (const file2 of
|
|
183421
|
+
if (!fs8.existsSync(dir)) return out2;
|
|
183422
|
+
for (const file2 of fs8.readdirSync(dir)) {
|
|
183308
183423
|
if (!file2.endsWith(".json")) continue;
|
|
183309
183424
|
const id = file2.slice(0, -5);
|
|
183310
183425
|
let mtime = 0;
|
|
183311
183426
|
try {
|
|
183312
|
-
mtime =
|
|
183427
|
+
mtime = fs8.statSync(path11.join(dir, file2)).mtimeMs;
|
|
183313
183428
|
} catch {
|
|
183314
183429
|
}
|
|
183315
183430
|
const value = loadBlob(subdir, id);
|
|
@@ -183324,16 +183439,16 @@ function pruneBlobs(subdir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX
|
|
|
183324
183439
|
const dir = blobDir(subdir);
|
|
183325
183440
|
let removed = 0;
|
|
183326
183441
|
try {
|
|
183327
|
-
if (!
|
|
183442
|
+
if (!fs8.existsSync(dir)) return 0;
|
|
183328
183443
|
const cutoff = Date.now() - maxAgeMs;
|
|
183329
183444
|
let kept = [];
|
|
183330
183445
|
let protectedEntry;
|
|
183331
|
-
for (const file2 of
|
|
183446
|
+
for (const file2 of fs8.readdirSync(dir)) {
|
|
183332
183447
|
if (!file2.endsWith(".json")) continue;
|
|
183333
183448
|
const full = path11.join(dir, file2);
|
|
183334
183449
|
let stat2;
|
|
183335
183450
|
try {
|
|
183336
|
-
stat2 =
|
|
183451
|
+
stat2 = fs8.statSync(full);
|
|
183337
183452
|
} catch {
|
|
183338
183453
|
continue;
|
|
183339
183454
|
}
|
|
@@ -183343,7 +183458,7 @@ function pruneBlobs(subdir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX
|
|
|
183343
183458
|
}
|
|
183344
183459
|
if (stat2.mtimeMs < cutoff) {
|
|
183345
183460
|
try {
|
|
183346
|
-
|
|
183461
|
+
fs8.unlinkSync(full);
|
|
183347
183462
|
removed++;
|
|
183348
183463
|
} catch {
|
|
183349
183464
|
continue;
|
|
@@ -183359,7 +183474,7 @@ function pruneBlobs(subdir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX
|
|
|
183359
183474
|
kept = kept.slice(kept.length - countBudget);
|
|
183360
183475
|
for (const [full] of excess) {
|
|
183361
183476
|
try {
|
|
183362
|
-
|
|
183477
|
+
fs8.unlinkSync(full);
|
|
183363
183478
|
removed++;
|
|
183364
183479
|
} catch {
|
|
183365
183480
|
continue;
|
|
@@ -183374,7 +183489,7 @@ function pruneBlobs(subdir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX
|
|
|
183374
183489
|
if (!oldest) break;
|
|
183375
183490
|
const [full, , size] = oldest;
|
|
183376
183491
|
try {
|
|
183377
|
-
|
|
183492
|
+
fs8.unlinkSync(full);
|
|
183378
183493
|
removed++;
|
|
183379
183494
|
total -= size;
|
|
183380
183495
|
} catch {
|
|
@@ -183390,13 +183505,13 @@ function pruneBlobs(subdir, maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX
|
|
|
183390
183505
|
|
|
183391
183506
|
// src/session_store.ts
|
|
183392
183507
|
init_define_import_meta_env();
|
|
183393
|
-
import * as
|
|
183508
|
+
import * as fs10 from "node:fs";
|
|
183394
183509
|
import * as path12 from "node:path";
|
|
183395
183510
|
|
|
183396
183511
|
// src/session.ts
|
|
183397
183512
|
init_define_import_meta_env();
|
|
183398
183513
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
183399
|
-
import * as
|
|
183514
|
+
import * as fs9 from "node:fs";
|
|
183400
183515
|
var _files = /* @__PURE__ */ new Map();
|
|
183401
183516
|
var _filesAtLoad = /* @__PURE__ */ new Map();
|
|
183402
183517
|
var _hintsShown = /* @__PURE__ */ new Set();
|
|
@@ -183410,7 +183525,7 @@ var _pendingLargeFileHintsAtLoad = /* @__PURE__ */ new Map();
|
|
|
183410
183525
|
var _sessionId = null;
|
|
183411
183526
|
function fileSize(absPath) {
|
|
183412
183527
|
try {
|
|
183413
|
-
return
|
|
183528
|
+
return fs9.statSync(absPath).size;
|
|
183414
183529
|
} catch {
|
|
183415
183530
|
return 0;
|
|
183416
183531
|
}
|
|
@@ -183548,6 +183663,9 @@ function recordCurlDownload(url2, savedPath) {
|
|
|
183548
183663
|
function getCurlDownloadPath(url2) {
|
|
183549
183664
|
return _curlDownloads.get(url2) ?? null;
|
|
183550
183665
|
}
|
|
183666
|
+
function clearCurlDownload(url2) {
|
|
183667
|
+
_curlDownloads.delete(url2);
|
|
183668
|
+
}
|
|
183551
183669
|
var MAX_RANGES_PER_FILE = 64;
|
|
183552
183670
|
function recordFileLineRange(filePath, start, end) {
|
|
183553
183671
|
const key = foldPath(normalizePath(filePath));
|
|
@@ -183816,8 +183934,8 @@ function capFiles(s, max2) {
|
|
|
183816
183934
|
}
|
|
183817
183935
|
function readDiskState(p) {
|
|
183818
183936
|
try {
|
|
183819
|
-
if (!
|
|
183820
|
-
return coerce(JSON.parse(
|
|
183937
|
+
if (!fs10.existsSync(p)) return null;
|
|
183938
|
+
return coerce(JSON.parse(fs10.readFileSync(p, "utf8")));
|
|
183821
183939
|
} catch {
|
|
183822
183940
|
return null;
|
|
183823
183941
|
}
|
|
@@ -183839,7 +183957,7 @@ function saveSessionState(sessionId) {
|
|
|
183839
183957
|
if (!p) return;
|
|
183840
183958
|
try {
|
|
183841
183959
|
const dir = path12.dirname(p);
|
|
183842
|
-
if (!
|
|
183960
|
+
if (!fs10.existsSync(dir)) fs10.mkdirSync(dir, { recursive: true });
|
|
183843
183961
|
const mem = exportSessionState();
|
|
183844
183962
|
const writeMerged = () => {
|
|
183845
183963
|
const disk = readDiskState(p);
|
|
@@ -183989,7 +184107,7 @@ function getEffectiveAutoTriggerWindow() {
|
|
|
183989
184107
|
}
|
|
183990
184108
|
function isAutoTriggerMultiplierExplicit() {
|
|
183991
184109
|
try {
|
|
183992
|
-
const text =
|
|
184110
|
+
const text = fs11.readFileSync(configPath(), "utf8");
|
|
183993
184111
|
const raw = parse(text);
|
|
183994
184112
|
const ca_raw = raw["compact_assist"];
|
|
183995
184113
|
if (ca_raw === null || typeof ca_raw !== "object" || Array.isArray(ca_raw)) {
|
|
@@ -184067,10 +184185,10 @@ function isNoisePath(inputPath) {
|
|
|
184067
184185
|
function findLatestSessionId() {
|
|
184068
184186
|
try {
|
|
184069
184187
|
const sessionsDir = path13.join(tokenGoatHome(), "sessions");
|
|
184070
|
-
if (!
|
|
184188
|
+
if (!fs11.existsSync(sessionsDir)) {
|
|
184071
184189
|
return null;
|
|
184072
184190
|
}
|
|
184073
|
-
const files =
|
|
184191
|
+
const files = fs11.readdirSync(sessionsDir);
|
|
184074
184192
|
const jsonFiles = files.filter((f) => f.endsWith(".json"));
|
|
184075
184193
|
if (jsonFiles.length === 0) {
|
|
184076
184194
|
return null;
|
|
@@ -184080,9 +184198,9 @@ function findLatestSessionId() {
|
|
|
184080
184198
|
return null;
|
|
184081
184199
|
}
|
|
184082
184200
|
let latestFile = firstFile;
|
|
184083
|
-
let latestMtime =
|
|
184201
|
+
let latestMtime = fs11.statSync(path13.join(sessionsDir, firstFile)).mtimeMs;
|
|
184084
184202
|
for (const file2 of jsonFiles) {
|
|
184085
|
-
const mtime =
|
|
184203
|
+
const mtime = fs11.statSync(path13.join(sessionsDir, file2)).mtimeMs;
|
|
184086
184204
|
if (mtime > latestMtime) {
|
|
184087
184205
|
latestFile = file2;
|
|
184088
184206
|
latestMtime = mtime;
|
|
@@ -184098,36 +184216,36 @@ function writeSessionManifest(projectHash2, sessionId, manifestJson) {
|
|
|
184098
184216
|
const safeSessionId = sessionId.replace(SESSION_ID_SAFE_RE, "_").slice(0, 64);
|
|
184099
184217
|
if (!safeSessionId) return;
|
|
184100
184218
|
const sessionsDir = path13.join(dataDir(), "projects", projectHash2, "sessions");
|
|
184101
|
-
if (!
|
|
184102
|
-
|
|
184219
|
+
if (!fs11.existsSync(sessionsDir)) {
|
|
184220
|
+
fs11.mkdirSync(sessionsDir, { recursive: true });
|
|
184103
184221
|
}
|
|
184104
184222
|
const dest = path13.join(sessionsDir, `${safeSessionId}.json`);
|
|
184105
184223
|
atomicWriteText(dest, JSON.stringify(manifestJson));
|
|
184106
184224
|
}
|
|
184107
184225
|
function readAllSessionManifests(projectHash2, maxAgeSecs = 3600) {
|
|
184108
184226
|
const sessionsDir = path13.join(dataDir(), "projects", projectHash2, "sessions");
|
|
184109
|
-
if (!
|
|
184227
|
+
if (!fs11.existsSync(sessionsDir)) {
|
|
184110
184228
|
return [];
|
|
184111
184229
|
}
|
|
184112
184230
|
const now = Date.now() / 1e3;
|
|
184113
184231
|
const results = [];
|
|
184114
184232
|
try {
|
|
184115
|
-
const files =
|
|
184233
|
+
const files = fs11.readdirSync(sessionsDir);
|
|
184116
184234
|
for (const file2 of files) {
|
|
184117
184235
|
if (!file2.endsWith(".json")) {
|
|
184118
184236
|
continue;
|
|
184119
184237
|
}
|
|
184120
184238
|
try {
|
|
184121
184239
|
const fullPath = path13.join(sessionsDir, file2);
|
|
184122
|
-
const stat2 =
|
|
184240
|
+
const stat2 = fs11.statSync(fullPath);
|
|
184123
184241
|
if (now - stat2.mtimeMs / 1e3 > maxAgeSecs) {
|
|
184124
184242
|
try {
|
|
184125
|
-
|
|
184243
|
+
fs11.unlinkSync(fullPath);
|
|
184126
184244
|
} catch {
|
|
184127
184245
|
}
|
|
184128
184246
|
continue;
|
|
184129
184247
|
}
|
|
184130
|
-
const text =
|
|
184248
|
+
const text = fs11.readFileSync(fullPath, "utf8");
|
|
184131
184249
|
const data = JSON.parse(text);
|
|
184132
184250
|
if (typeof data === "object" && data !== null && "files" in data) {
|
|
184133
184251
|
results.push(data);
|
|
@@ -184360,7 +184478,7 @@ function collectWalkIndexFiles(root) {
|
|
|
184360
184478
|
|
|
184361
184479
|
// src/parser.ts
|
|
184362
184480
|
init_define_import_meta_env();
|
|
184363
|
-
import * as
|
|
184481
|
+
import * as fs13 from "node:fs";
|
|
184364
184482
|
import { createRequire as createRequire4 } from "node:module";
|
|
184365
184483
|
import * as path18 from "node:path";
|
|
184366
184484
|
|
|
@@ -184382,6 +184500,12 @@ function ensureTransformerLoaded() {
|
|
|
184382
184500
|
}
|
|
184383
184501
|
var DEFAULT_MODEL = "Xenova/bge-small-en-v1.5";
|
|
184384
184502
|
var DEFAULT_DIM = 384;
|
|
184503
|
+
var _extractorCache = /* @__PURE__ */ new Map();
|
|
184504
|
+
var _pipelineFnOverride = null;
|
|
184505
|
+
registerReset(() => {
|
|
184506
|
+
_extractorCache.clear();
|
|
184507
|
+
_pipelineFnOverride = null;
|
|
184508
|
+
});
|
|
184385
184509
|
var MIN_CHUNK_CHARS = 50;
|
|
184386
184510
|
var MAX_CHUNK_CHARS = 8e3;
|
|
184387
184511
|
var DEFAULT_DISTANCE_THRESHOLD = 1.2;
|
|
@@ -184430,9 +184554,14 @@ async function embedTexts(texts, modelName = DEFAULT_MODEL) {
|
|
|
184430
184554
|
if (!_transformer || typeof _transformer !== "object") {
|
|
184431
184555
|
throw new Error("Transformer module is unavailable");
|
|
184432
184556
|
}
|
|
184433
|
-
|
|
184434
|
-
|
|
184435
|
-
|
|
184557
|
+
let extractorPromise = _extractorCache.get(modelName);
|
|
184558
|
+
if (!extractorPromise) {
|
|
184559
|
+
const transformerObj = _transformer;
|
|
184560
|
+
const pipelineFn = _pipelineFnOverride ?? transformerObj["pipeline"];
|
|
184561
|
+
extractorPromise = pipelineFn("feature-extraction", modelName);
|
|
184562
|
+
_extractorCache.set(modelName, extractorPromise);
|
|
184563
|
+
}
|
|
184564
|
+
const extractor = await extractorPromise;
|
|
184436
184565
|
const vecs = [];
|
|
184437
184566
|
const expectedDim = DEFAULT_DIM;
|
|
184438
184567
|
try {
|
|
@@ -184822,7 +184951,7 @@ function _isGeneratedPath(filePath) {
|
|
|
184822
184951
|
// src/fingerprint.ts
|
|
184823
184952
|
init_define_import_meta_env();
|
|
184824
184953
|
import { createHash } from "node:crypto";
|
|
184825
|
-
import * as
|
|
184954
|
+
import * as fs12 from "node:fs";
|
|
184826
184955
|
function fingerprintContent(content) {
|
|
184827
184956
|
const hash2 = createHash("sha256");
|
|
184828
184957
|
hash2.update(typeof content === "string" ? Buffer.from(content, "utf-8") : content);
|
|
@@ -184834,7 +184963,7 @@ function shortFingerprint(content) {
|
|
|
184834
184963
|
function fingerprintFile(filePath) {
|
|
184835
184964
|
let data;
|
|
184836
184965
|
try {
|
|
184837
|
-
data =
|
|
184966
|
+
data = fs12.readFileSync(filePath);
|
|
184838
184967
|
} catch {
|
|
184839
184968
|
return null;
|
|
184840
184969
|
}
|
|
@@ -185130,6 +185259,130 @@ function stripStringLiterals(line) {
|
|
|
185130
185259
|
}
|
|
185131
185260
|
return out2;
|
|
185132
185261
|
}
|
|
185262
|
+
function escapeRegExp(s) {
|
|
185263
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
185264
|
+
}
|
|
185265
|
+
function findMultilineCloser(line, from2, state) {
|
|
185266
|
+
switch (state.kind) {
|
|
185267
|
+
case "heredoc":
|
|
185268
|
+
case "nowdoc": {
|
|
185269
|
+
const re = new RegExp(`^[ \\t]*${escapeRegExp(state.identifier)}\\b`);
|
|
185270
|
+
const m = re.exec(line);
|
|
185271
|
+
return m ? { maskEnd: m[0].length } : null;
|
|
185272
|
+
}
|
|
185273
|
+
case "tripleQuote": {
|
|
185274
|
+
const idx = line.indexOf('"""', from2);
|
|
185275
|
+
return idx === -1 ? null : { maskEnd: idx + 3 };
|
|
185276
|
+
}
|
|
185277
|
+
case "verbatim": {
|
|
185278
|
+
let j = from2;
|
|
185279
|
+
while (j < line.length) {
|
|
185280
|
+
if (line[j] === '"') {
|
|
185281
|
+
if (line[j + 1] === '"') {
|
|
185282
|
+
j += 2;
|
|
185283
|
+
continue;
|
|
185284
|
+
}
|
|
185285
|
+
return { maskEnd: j + 1 };
|
|
185286
|
+
}
|
|
185287
|
+
j++;
|
|
185288
|
+
}
|
|
185289
|
+
return null;
|
|
185290
|
+
}
|
|
185291
|
+
case "psHereDouble":
|
|
185292
|
+
return line.startsWith('"@', from2) ? { maskEnd: from2 + 2 } : null;
|
|
185293
|
+
case "psHereSingle":
|
|
185294
|
+
return line.startsWith("'@", from2) ? { maskEnd: from2 + 2 } : null;
|
|
185295
|
+
default:
|
|
185296
|
+
return null;
|
|
185297
|
+
}
|
|
185298
|
+
}
|
|
185299
|
+
function findMultilineOpener(line, from2, lang) {
|
|
185300
|
+
if (lang === "php") {
|
|
185301
|
+
const re = /<<<\s*(['"]?)([A-Za-z_]\w*)\1/g;
|
|
185302
|
+
re.lastIndex = from2;
|
|
185303
|
+
const m = re.exec(line);
|
|
185304
|
+
if (!m || isInsideStringLiteral(line, m.index)) return null;
|
|
185305
|
+
const identifier = m[2] ?? "";
|
|
185306
|
+
const kind = m[1] === "'" ? "nowdoc" : "heredoc";
|
|
185307
|
+
return { openStart: m.index, closesSameLine: null, state: { kind, identifier } };
|
|
185308
|
+
}
|
|
185309
|
+
if (lang === "kotlin") {
|
|
185310
|
+
const idx = line.indexOf('"""', from2);
|
|
185311
|
+
if (idx === -1) return null;
|
|
185312
|
+
const closeIdx = line.indexOf('"""', idx + 3);
|
|
185313
|
+
if (closeIdx !== -1) {
|
|
185314
|
+
return { openStart: idx, closesSameLine: closeIdx + 3, state: { kind: "tripleQuote", identifier: "" } };
|
|
185315
|
+
}
|
|
185316
|
+
return { openStart: idx, closesSameLine: null, state: { kind: "tripleQuote", identifier: "" } };
|
|
185317
|
+
}
|
|
185318
|
+
if (lang === "csharp") {
|
|
185319
|
+
const tripleIdx = line.indexOf('"""', from2);
|
|
185320
|
+
const verbRe = /\$?@\$?"/g;
|
|
185321
|
+
verbRe.lastIndex = from2;
|
|
185322
|
+
const verbM = verbRe.exec(line);
|
|
185323
|
+
const verbIdx = verbM ? verbM.index : -1;
|
|
185324
|
+
if (tripleIdx === -1 && verbIdx === -1) return null;
|
|
185325
|
+
const useTriple = tripleIdx !== -1 && (verbIdx === -1 || tripleIdx < verbIdx);
|
|
185326
|
+
if (useTriple) {
|
|
185327
|
+
const closeIdx = line.indexOf('"""', tripleIdx + 3);
|
|
185328
|
+
if (closeIdx !== -1) {
|
|
185329
|
+
return { openStart: tripleIdx, closesSameLine: closeIdx + 3, state: { kind: "tripleQuote", identifier: "" } };
|
|
185330
|
+
}
|
|
185331
|
+
return { openStart: tripleIdx, closesSameLine: null, state: { kind: "tripleQuote", identifier: "" } };
|
|
185332
|
+
}
|
|
185333
|
+
const quoteIdx = verbIdx + (verbM?.[0].length ?? 1) - 1;
|
|
185334
|
+
const closer = findMultilineCloser(line, quoteIdx + 1, { kind: "verbatim", identifier: "" });
|
|
185335
|
+
if (closer !== null) {
|
|
185336
|
+
return { openStart: verbIdx, closesSameLine: closer.maskEnd, state: { kind: "verbatim", identifier: "" } };
|
|
185337
|
+
}
|
|
185338
|
+
return { openStart: verbIdx, closesSameLine: null, state: { kind: "verbatim", identifier: "" } };
|
|
185339
|
+
}
|
|
185340
|
+
if (lang === "powershell") {
|
|
185341
|
+
const re = /@("|')\s*$/;
|
|
185342
|
+
const tail = line.slice(from2);
|
|
185343
|
+
const m = re.exec(tail);
|
|
185344
|
+
if (!m) return null;
|
|
185345
|
+
const openStart = from2 + m.index;
|
|
185346
|
+
const kind = m[1] === '"' ? "psHereDouble" : "psHereSingle";
|
|
185347
|
+
return { openStart, closesSameLine: null, state: { kind, identifier: "" } };
|
|
185348
|
+
}
|
|
185349
|
+
return null;
|
|
185350
|
+
}
|
|
185351
|
+
function stripMultilineStringSpan(line, state, lang) {
|
|
185352
|
+
let code = "";
|
|
185353
|
+
let i = 0;
|
|
185354
|
+
let cur = state;
|
|
185355
|
+
while (i < line.length) {
|
|
185356
|
+
if (cur !== null) {
|
|
185357
|
+
const closed = findMultilineCloser(line, i, cur);
|
|
185358
|
+
if (closed === null) {
|
|
185359
|
+
code += " ".repeat(line.length - i);
|
|
185360
|
+
i = line.length;
|
|
185361
|
+
continue;
|
|
185362
|
+
}
|
|
185363
|
+
code += " ".repeat(closed.maskEnd - i);
|
|
185364
|
+
i = closed.maskEnd;
|
|
185365
|
+
cur = null;
|
|
185366
|
+
continue;
|
|
185367
|
+
}
|
|
185368
|
+
const opened = findMultilineOpener(line, i, lang);
|
|
185369
|
+
if (opened === null) {
|
|
185370
|
+
code += line.slice(i);
|
|
185371
|
+
break;
|
|
185372
|
+
}
|
|
185373
|
+
code += line.slice(i, opened.openStart);
|
|
185374
|
+
if (opened.closesSameLine !== null) {
|
|
185375
|
+
code += " ".repeat(opened.closesSameLine - opened.openStart);
|
|
185376
|
+
i = opened.closesSameLine;
|
|
185377
|
+
cur = null;
|
|
185378
|
+
} else {
|
|
185379
|
+
code += " ".repeat(line.length - opened.openStart);
|
|
185380
|
+
i = line.length;
|
|
185381
|
+
cur = opened.state;
|
|
185382
|
+
}
|
|
185383
|
+
}
|
|
185384
|
+
return { code, state: cur };
|
|
185385
|
+
}
|
|
185133
185386
|
function makeSymbolEmitter(symbols, sections, seen, filePath, maxSymbols = 500, maxHeadingLen = 120) {
|
|
185134
185387
|
return function emit5(name2, kind, line) {
|
|
185135
185388
|
if (!name2 || name2.length > maxHeadingLen) return;
|
|
@@ -185213,11 +185466,18 @@ function extractCsharp(content, filePath) {
|
|
|
185213
185466
|
const classStack = [];
|
|
185214
185467
|
let braceDepth = 0;
|
|
185215
185468
|
let inComment = false;
|
|
185469
|
+
let mlState = null;
|
|
185216
185470
|
for (let i = 0; i < lines.length; i++) {
|
|
185217
185471
|
const rawLine = lines[i] ?? "";
|
|
185218
185472
|
const lineNum = i + 1;
|
|
185219
185473
|
let openedFrameThisLine = false;
|
|
185220
|
-
|
|
185474
|
+
let mlLine = rawLine;
|
|
185475
|
+
if (mlState !== null || !inComment) {
|
|
185476
|
+
const masked = stripMultilineStringSpan(rawLine, mlState, "csharp");
|
|
185477
|
+
mlLine = masked.code;
|
|
185478
|
+
mlState = masked.state;
|
|
185479
|
+
}
|
|
185480
|
+
const { code: codeLine, inComment: nextInComment } = stripBlockCommentSpan(mlLine, inComment);
|
|
185221
185481
|
inComment = nextInComment;
|
|
185222
185482
|
const line = codeLine.trimEnd();
|
|
185223
185483
|
const stripped = line.trim();
|
|
@@ -185333,13 +185593,20 @@ function extractPhp(content, filePath) {
|
|
|
185333
185593
|
const contextStack = [];
|
|
185334
185594
|
let braceDepth = 0;
|
|
185335
185595
|
let inComment = false;
|
|
185596
|
+
let mlState = null;
|
|
185336
185597
|
function currentClass() {
|
|
185337
185598
|
return contextStack.length > 0 ? contextStack[contextStack.length - 1]?.[0] ?? null : null;
|
|
185338
185599
|
}
|
|
185339
185600
|
for (let i = 0; i < lines.length; i++) {
|
|
185340
185601
|
const rawLine = lines[i] ?? "";
|
|
185341
185602
|
const lineNum = i + 1;
|
|
185342
|
-
|
|
185603
|
+
let mlLine = rawLine;
|
|
185604
|
+
if (mlState !== null || !inComment) {
|
|
185605
|
+
const masked = stripMultilineStringSpan(rawLine, mlState, "php");
|
|
185606
|
+
mlLine = masked.code;
|
|
185607
|
+
mlState = masked.state;
|
|
185608
|
+
}
|
|
185609
|
+
const { code: codeLine, inComment: nextInComment } = stripBlockCommentSpan(mlLine, inComment);
|
|
185343
185610
|
inComment = nextInComment;
|
|
185344
185611
|
const line = codeLine.trimEnd();
|
|
185345
185612
|
const stripped = line.trimStart();
|
|
@@ -185641,10 +185908,17 @@ function extractKotlin(content, filePath) {
|
|
|
185641
185908
|
const classStack = [];
|
|
185642
185909
|
let braceDepth = 0;
|
|
185643
185910
|
let inComment = false;
|
|
185911
|
+
let mlState = null;
|
|
185644
185912
|
for (let i = 0; i < lines.length; i++) {
|
|
185645
185913
|
const rawLine = lines[i] ?? "";
|
|
185646
185914
|
const lineNum = i + 1;
|
|
185647
|
-
|
|
185915
|
+
let mlLine = rawLine;
|
|
185916
|
+
if (mlState !== null || !inComment) {
|
|
185917
|
+
const masked = stripMultilineStringSpan(rawLine, mlState, "kotlin");
|
|
185918
|
+
mlLine = masked.code;
|
|
185919
|
+
mlState = masked.state;
|
|
185920
|
+
}
|
|
185921
|
+
const { code: blockStripped, inComment: nextInComment } = stripBlockCommentSpan(mlLine, inComment);
|
|
185648
185922
|
inComment = nextInComment;
|
|
185649
185923
|
const line = stripLineComment(blockStripped);
|
|
185650
185924
|
const stripped = line.trim();
|
|
@@ -186123,9 +186397,17 @@ function extractPowershell(content, filePath) {
|
|
|
186123
186397
|
let classBodyEntered = false;
|
|
186124
186398
|
let braceDepth = 0;
|
|
186125
186399
|
let inBlockComment = false;
|
|
186400
|
+
let mlState = null;
|
|
186126
186401
|
for (let i = 0; i < lines.length; i++) {
|
|
186127
|
-
const
|
|
186402
|
+
const sourceLine = lines[i] ?? "";
|
|
186128
186403
|
const lineNum = i + 1;
|
|
186404
|
+
let mlLine = sourceLine;
|
|
186405
|
+
if (mlState !== null || !inBlockComment) {
|
|
186406
|
+
const masked = stripMultilineStringSpan(sourceLine, mlState, "powershell");
|
|
186407
|
+
mlLine = masked.code;
|
|
186408
|
+
mlState = masked.state;
|
|
186409
|
+
}
|
|
186410
|
+
const rawLine = mlLine;
|
|
186129
186411
|
let line = rawLine;
|
|
186130
186412
|
let openedBlockCommentThisLine = false;
|
|
186131
186413
|
if (!inBlockComment) {
|
|
@@ -187356,6 +187638,9 @@ function extractWithRegex(content, filePath) {
|
|
|
187356
187638
|
return out2;
|
|
187357
187639
|
}
|
|
187358
187640
|
function parseContent(content, filePath, language) {
|
|
187641
|
+
if (content.charCodeAt(0) === 65279) {
|
|
187642
|
+
content = content.slice(1);
|
|
187643
|
+
}
|
|
187359
187644
|
if (isTreeSitterAvailable(language)) {
|
|
187360
187645
|
try {
|
|
187361
187646
|
const Ctor = loadParserCtor();
|
|
@@ -187469,7 +187754,7 @@ function indexFileSync(filePath, dbPath = globalDbPath()) {
|
|
|
187469
187754
|
const language = detectLanguage(filePath);
|
|
187470
187755
|
let raw;
|
|
187471
187756
|
try {
|
|
187472
|
-
raw =
|
|
187757
|
+
raw = fs13.readFileSync(filePath);
|
|
187473
187758
|
} catch (err3) {
|
|
187474
187759
|
if (err3.code === "ENOENT") return;
|
|
187475
187760
|
throw err3;
|
|
@@ -187493,7 +187778,7 @@ function buildEmbeddingBoundaries(filePath, content, dbPath) {
|
|
|
187493
187778
|
const symbols = querySymbols({ filePath, limit: 1e4 }, dbPath);
|
|
187494
187779
|
return symbols.map((s) => ({ start: s.lineStart, end: s.lineEnd, kind: "symbol" }));
|
|
187495
187780
|
}
|
|
187496
|
-
async function indexFileEmbeddings(filePath, dbPath = globalDbPath()) {
|
|
187781
|
+
async function indexFileEmbeddings(filePath, dbPath = globalDbPath(), sha) {
|
|
187497
187782
|
if (!loadConfig().indexing.embeddings_enabled) return;
|
|
187498
187783
|
if (filePath.toLowerCase().endsWith(".profile-meta.xml")) {
|
|
187499
187784
|
deleteFileEmbeddings(getDb(dbPath), filePath);
|
|
@@ -187501,7 +187786,7 @@ async function indexFileEmbeddings(filePath, dbPath = globalDbPath()) {
|
|
|
187501
187786
|
}
|
|
187502
187787
|
let content;
|
|
187503
187788
|
try {
|
|
187504
|
-
content = await
|
|
187789
|
+
content = await fs13.promises.readFile(filePath, "utf8");
|
|
187505
187790
|
} catch {
|
|
187506
187791
|
return;
|
|
187507
187792
|
}
|
|
@@ -187513,6 +187798,12 @@ async function indexFileEmbeddings(filePath, dbPath = globalDbPath()) {
|
|
|
187513
187798
|
const db = getDb(dbPath);
|
|
187514
187799
|
const boundaries = buildEmbeddingBoundaries(filePath, content, dbPath);
|
|
187515
187800
|
await indexFile(db, filePath, content, boundaries);
|
|
187801
|
+
if (sha !== void 0) {
|
|
187802
|
+
db.prepare(`UPDATE files SET embed_sha = ? WHERE ${pathEqClause("path")}`).run(
|
|
187803
|
+
sha,
|
|
187804
|
+
foldPath(filePath)
|
|
187805
|
+
);
|
|
187806
|
+
}
|
|
187516
187807
|
} catch {
|
|
187517
187808
|
}
|
|
187518
187809
|
}
|
|
@@ -187525,7 +187816,7 @@ function safeSha(filePath) {
|
|
|
187525
187816
|
}
|
|
187526
187817
|
function safeMtime(filePath) {
|
|
187527
187818
|
try {
|
|
187528
|
-
return
|
|
187819
|
+
return fs13.statSync(filePath).mtimeMs / 1e3;
|
|
187529
187820
|
} catch {
|
|
187530
187821
|
return 0;
|
|
187531
187822
|
}
|
|
@@ -187533,7 +187824,7 @@ function safeMtime(filePath) {
|
|
|
187533
187824
|
|
|
187534
187825
|
// src/index_prune.ts
|
|
187535
187826
|
init_define_import_meta_env();
|
|
187536
|
-
import * as
|
|
187827
|
+
import * as fs14 from "node:fs";
|
|
187537
187828
|
function removeFileFromIndex(db, filePath) {
|
|
187538
187829
|
deleteFileRows(db, filePath);
|
|
187539
187830
|
deleteFileEmbeddings(db, filePath);
|
|
@@ -187555,7 +187846,7 @@ function pruneDeletedFiles(rootPrefix, dbPath = globalDbPath()) {
|
|
|
187555
187846
|
if (foldedP !== foldedRootPrefix && !foldedP.startsWith(foldedPrefix)) continue;
|
|
187556
187847
|
let stillExists;
|
|
187557
187848
|
try {
|
|
187558
|
-
stillExists =
|
|
187849
|
+
stillExists = fs14.statSync(p, { throwIfNoEntry: false }) !== void 0;
|
|
187559
187850
|
} catch {
|
|
187560
187851
|
continue;
|
|
187561
187852
|
}
|
|
@@ -187571,7 +187862,7 @@ function pruneDeletedFiles(rootPrefix, dbPath = globalDbPath()) {
|
|
|
187571
187862
|
|
|
187572
187863
|
// src/hooks_index.ts
|
|
187573
187864
|
init_define_import_meta_env();
|
|
187574
|
-
import * as
|
|
187865
|
+
import * as fs17 from "node:fs";
|
|
187575
187866
|
import * as path21 from "node:path";
|
|
187576
187867
|
|
|
187577
187868
|
// src/hook_registry.ts
|
|
@@ -187673,14 +187964,14 @@ function contextOutput(context2) {
|
|
|
187673
187964
|
// src/worker.ts
|
|
187674
187965
|
init_define_import_meta_env();
|
|
187675
187966
|
import { spawn as spawn2 } from "node:child_process";
|
|
187676
|
-
import * as
|
|
187967
|
+
import * as fs16 from "node:fs";
|
|
187677
187968
|
import * as path20 from "node:path";
|
|
187678
187969
|
import { Worker as Worker2, isMainThread, parentPort, workerData } from "node:worker_threads";
|
|
187679
187970
|
import { fileURLToPath } from "node:url";
|
|
187680
187971
|
|
|
187681
187972
|
// src/snapshots.ts
|
|
187682
187973
|
init_define_import_meta_env();
|
|
187683
|
-
import * as
|
|
187974
|
+
import * as fs15 from "node:fs";
|
|
187684
187975
|
import * as path19 from "node:path";
|
|
187685
187976
|
import * as crypto2 from "node:crypto";
|
|
187686
187977
|
var MAX_SNAPSHOTS_PER_SESSION = 150;
|
|
@@ -187719,10 +188010,10 @@ function writeSnapshotKind(sidecarPath, kind) {
|
|
|
187719
188010
|
try {
|
|
187720
188011
|
const safeKind = VALID_KINDS.has(kind) ? kind : KIND_READ;
|
|
187721
188012
|
const dir = path19.dirname(sidecarPath);
|
|
187722
|
-
if (!
|
|
187723
|
-
|
|
188013
|
+
if (!fs15.existsSync(dir)) {
|
|
188014
|
+
fs15.mkdirSync(dir, { recursive: true });
|
|
187724
188015
|
}
|
|
187725
|
-
|
|
188016
|
+
fs15.writeFileSync(sidecarPath, safeKind, "utf8");
|
|
187726
188017
|
return true;
|
|
187727
188018
|
} catch {
|
|
187728
188019
|
return false;
|
|
@@ -187731,12 +188022,12 @@ function writeSnapshotKind(sidecarPath, kind) {
|
|
|
187731
188022
|
function evictOldest(d, maxCount) {
|
|
187732
188023
|
try {
|
|
187733
188024
|
const entries = [];
|
|
187734
|
-
const files =
|
|
188025
|
+
const files = fs15.readdirSync(d);
|
|
187735
188026
|
for (const file2 of files) {
|
|
187736
188027
|
const fullPath = path19.join(d, file2);
|
|
187737
188028
|
if (!file2.endsWith(".bin")) continue;
|
|
187738
188029
|
try {
|
|
187739
|
-
const stat2 =
|
|
188030
|
+
const stat2 = fs15.statSync(fullPath);
|
|
187740
188031
|
entries.push([fullPath, stat2.mtimeMs]);
|
|
187741
188032
|
} catch {
|
|
187742
188033
|
continue;
|
|
@@ -187748,10 +188039,10 @@ function evictOldest(d, maxCount) {
|
|
|
187748
188039
|
const over = entries.length - maxCount;
|
|
187749
188040
|
for (const [p] of entries.slice(0, over)) {
|
|
187750
188041
|
try {
|
|
187751
|
-
|
|
188042
|
+
fs15.unlinkSync(p);
|
|
187752
188043
|
removed++;
|
|
187753
188044
|
try {
|
|
187754
|
-
|
|
188045
|
+
fs15.unlinkSync(kindSidecarPath(p));
|
|
187755
188046
|
} catch {
|
|
187756
188047
|
}
|
|
187757
188048
|
} catch {
|
|
@@ -187780,10 +188071,10 @@ function store(sessionId, filePath, content, opts = {}) {
|
|
|
187780
188071
|
if (!p) return null;
|
|
187781
188072
|
const sha = crypto2.createHash("sha256").update(stored).digest("hex");
|
|
187782
188073
|
try {
|
|
187783
|
-
const isNewEntry = !
|
|
188074
|
+
const isNewEntry = !fs15.existsSync(p);
|
|
187784
188075
|
if (!isNewEntry) {
|
|
187785
188076
|
try {
|
|
187786
|
-
const existing =
|
|
188077
|
+
const existing = fs15.readFileSync(p);
|
|
187787
188078
|
if (Buffer.from(existing).equals(stored)) {
|
|
187788
188079
|
return {
|
|
187789
188080
|
path: p,
|
|
@@ -187795,8 +188086,8 @@ function store(sessionId, filePath, content, opts = {}) {
|
|
|
187795
188086
|
}
|
|
187796
188087
|
}
|
|
187797
188088
|
const dir = path19.dirname(p);
|
|
187798
|
-
if (!
|
|
187799
|
-
|
|
188089
|
+
if (!fs15.existsSync(dir)) {
|
|
188090
|
+
fs15.mkdirSync(dir, { recursive: true });
|
|
187800
188091
|
}
|
|
187801
188092
|
if (isNewEntry) {
|
|
187802
188093
|
evictOldest(dir, MAX_SNAPSHOTS_PER_SESSION - 1);
|
|
@@ -187815,9 +188106,9 @@ function store(sessionId, filePath, content, opts = {}) {
|
|
|
187815
188106
|
}
|
|
187816
188107
|
function load(sessionId, filePath, opts = {}) {
|
|
187817
188108
|
const p = snapshot_path(sessionId, filePath);
|
|
187818
|
-
if (!p || !
|
|
188109
|
+
if (!p || !fs15.existsSync(p)) return null;
|
|
187819
188110
|
try {
|
|
187820
|
-
const stat2 =
|
|
188111
|
+
const stat2 = fs15.statSync(p);
|
|
187821
188112
|
if (stat2.size > MAX_SNAPSHOT_BYTES) {
|
|
187822
188113
|
return null;
|
|
187823
188114
|
}
|
|
@@ -187825,7 +188116,7 @@ function load(sessionId, filePath, opts = {}) {
|
|
|
187825
188116
|
return null;
|
|
187826
188117
|
}
|
|
187827
188118
|
try {
|
|
187828
|
-
const data =
|
|
188119
|
+
const data = fs15.readFileSync(p);
|
|
187829
188120
|
if (opts.expected_sha) {
|
|
187830
188121
|
const actualSha = crypto2.createHash("sha256").update(data).digest("hex");
|
|
187831
188122
|
if (actualSha.toLowerCase() !== opts.expected_sha.toLowerCase()) {
|
|
@@ -187839,30 +188130,30 @@ function load(sessionId, filePath, opts = {}) {
|
|
|
187839
188130
|
}
|
|
187840
188131
|
function cleanup_stale(maxAgeHours = 24) {
|
|
187841
188132
|
const base = path19.join(tokenGoatHome(), "session_snapshots");
|
|
187842
|
-
if (!
|
|
188133
|
+
if (!fs15.existsSync(base)) return 0;
|
|
187843
188134
|
const cutoff = Date.now() - maxAgeHours * 3600 * 1e3;
|
|
187844
188135
|
let removed = 0;
|
|
187845
188136
|
try {
|
|
187846
|
-
const sessionDirs =
|
|
188137
|
+
const sessionDirs = fs15.readdirSync(base);
|
|
187847
188138
|
for (const sessionDir2 of sessionDirs) {
|
|
187848
188139
|
const sessionPath2 = path19.join(base, sessionDir2);
|
|
187849
188140
|
try {
|
|
187850
|
-
const stat2 =
|
|
188141
|
+
const stat2 = fs15.statSync(sessionPath2);
|
|
187851
188142
|
if (!stat2.isDirectory()) continue;
|
|
187852
188143
|
} catch {
|
|
187853
188144
|
continue;
|
|
187854
188145
|
}
|
|
187855
188146
|
try {
|
|
187856
|
-
const files =
|
|
188147
|
+
const files = fs15.readdirSync(sessionPath2);
|
|
187857
188148
|
for (const file2 of files) {
|
|
187858
188149
|
const fullPath = path19.join(sessionPath2, file2);
|
|
187859
188150
|
try {
|
|
187860
|
-
const stat2 =
|
|
188151
|
+
const stat2 = fs15.lstatSync(fullPath);
|
|
187861
188152
|
if ((stat2.mode & 61440) === 40960) {
|
|
187862
188153
|
continue;
|
|
187863
188154
|
}
|
|
187864
188155
|
if (stat2.mtimeMs < cutoff) {
|
|
187865
|
-
|
|
188156
|
+
fs15.unlinkSync(fullPath);
|
|
187866
188157
|
if (file2.endsWith(".bin")) {
|
|
187867
188158
|
removed++;
|
|
187868
188159
|
}
|
|
@@ -187872,7 +188163,7 @@ function cleanup_stale(maxAgeHours = 24) {
|
|
|
187872
188163
|
}
|
|
187873
188164
|
}
|
|
187874
188165
|
try {
|
|
187875
|
-
|
|
188166
|
+
fs15.rmdirSync(sessionPath2);
|
|
187876
188167
|
} catch {
|
|
187877
188168
|
}
|
|
187878
188169
|
} catch {
|
|
@@ -187890,9 +188181,31 @@ var DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
|
187890
188181
|
var SNAPSHOT_CLEANUP_INTERVAL_MS = 60 * 60 * 1e3;
|
|
187891
188182
|
var unclearedDrainingSnapshots = /* @__PURE__ */ new Map();
|
|
187892
188183
|
var MAX_TRANSIENT_RETRIES = 5;
|
|
187893
|
-
|
|
187894
|
-
|
|
187895
|
-
|
|
188184
|
+
function bumpRetryCount(dbPath, absPath) {
|
|
188185
|
+
const db = getDb(dbPath);
|
|
188186
|
+
const folded = foldPath(absPath);
|
|
188187
|
+
const tx = db.transaction(() => {
|
|
188188
|
+
const row = db.prepare(`SELECT retry_count FROM files WHERE ${pathEqClause("path")}`).get(folded);
|
|
188189
|
+
if (row !== void 0) {
|
|
188190
|
+
const next = (row.retry_count ?? 0) + 1;
|
|
188191
|
+
db.prepare(`UPDATE files SET retry_count = ? WHERE ${pathEqClause("path")}`).run(next, folded);
|
|
188192
|
+
return next;
|
|
188193
|
+
}
|
|
188194
|
+
db.prepare("INSERT INTO files (path, retry_count) VALUES (?, 1)").run(absPath);
|
|
188195
|
+
return 1;
|
|
188196
|
+
});
|
|
188197
|
+
return tx();
|
|
188198
|
+
}
|
|
188199
|
+
function clearRetryCount(dbPath, absPath) {
|
|
188200
|
+
try {
|
|
188201
|
+
const db = getDb(dbPath);
|
|
188202
|
+
const folded = foldPath(absPath);
|
|
188203
|
+
db.prepare(`UPDATE files SET retry_count = 0 WHERE ${pathEqClause("path")}`).run(folded);
|
|
188204
|
+
} catch {
|
|
188205
|
+
}
|
|
188206
|
+
}
|
|
188207
|
+
function resetTransientRetryCount(absPath, dbPath = globalDbPath()) {
|
|
188208
|
+
clearRetryCount(dbPath, absPath);
|
|
187896
188209
|
}
|
|
187897
188210
|
function dirtyQueuePathFor(dir) {
|
|
187898
188211
|
return path20.join(dir, "queue", "dirty.txt");
|
|
@@ -187920,7 +188233,7 @@ function workerErrorLogPath(dir) {
|
|
|
187920
188233
|
var INDEX_FAILED = Symbol("indexFailed");
|
|
187921
188234
|
function appendWorkerErrorLog(dir, line) {
|
|
187922
188235
|
try {
|
|
187923
|
-
|
|
188236
|
+
fs16.appendFileSync(workerErrorLogPath(dir), line);
|
|
187924
188237
|
} catch {
|
|
187925
188238
|
}
|
|
187926
188239
|
}
|
|
@@ -187937,9 +188250,8 @@ function logTransientReadFailure(dir, absPath) {
|
|
|
187937
188250
|
);
|
|
187938
188251
|
}
|
|
187939
188252
|
function requeueDirtyPath(dir, absPath) {
|
|
187940
|
-
const
|
|
187941
|
-
const attempts = (
|
|
187942
|
-
transientRetryCounts.set(retryKey, attempts);
|
|
188253
|
+
const dbPath = path20.join(dir, "global.db");
|
|
188254
|
+
const attempts = bumpRetryCount(dbPath, absPath);
|
|
187943
188255
|
if (attempts > MAX_TRANSIENT_RETRIES) {
|
|
187944
188256
|
if (attempts === MAX_TRANSIENT_RETRIES + 1) {
|
|
187945
188257
|
appendWorkerErrorLog(
|
|
@@ -187952,14 +188264,14 @@ function requeueDirtyPath(dir, absPath) {
|
|
|
187952
188264
|
}
|
|
187953
188265
|
const queuePath = dirtyQueuePathFor(dir);
|
|
187954
188266
|
try {
|
|
187955
|
-
|
|
188267
|
+
fs16.mkdirSync(path20.dirname(queuePath), { recursive: true });
|
|
187956
188268
|
let leadingNewline = "";
|
|
187957
188269
|
try {
|
|
187958
|
-
const existing =
|
|
188270
|
+
const existing = fs16.readFileSync(queuePath, "utf8");
|
|
187959
188271
|
if (existing.length > 0 && !existing.endsWith("\n")) leadingNewline = "\n";
|
|
187960
188272
|
} catch {
|
|
187961
188273
|
}
|
|
187962
|
-
|
|
188274
|
+
fs16.appendFileSync(queuePath, `${leadingNewline}${absPath}
|
|
187963
188275
|
`);
|
|
187964
188276
|
} catch {
|
|
187965
188277
|
}
|
|
@@ -187968,9 +188280,16 @@ function makeIndexer(dbPath) {
|
|
|
187968
188280
|
const dir = path20.dirname(dbPath);
|
|
187969
188281
|
return (absPath, sha) => {
|
|
187970
188282
|
try {
|
|
187971
|
-
|
|
187972
|
-
|
|
187973
|
-
|
|
188283
|
+
const entry = getFileEntry(absPath, dbPath);
|
|
188284
|
+
const parseUnchanged = entry?.sha === sha;
|
|
188285
|
+
if (!parseUnchanged) {
|
|
188286
|
+
indexFileSync(absPath, dbPath);
|
|
188287
|
+
}
|
|
188288
|
+
const embedUnchanged = parseUnchanged && entry?.embedSha === sha;
|
|
188289
|
+
if (embedUnchanged) {
|
|
188290
|
+
return false;
|
|
188291
|
+
}
|
|
188292
|
+
return indexFileEmbeddings(absPath, dbPath, sha).catch(() => void 0);
|
|
187974
188293
|
} catch (err3) {
|
|
187975
188294
|
logIndexFailure(dir, absPath, err3);
|
|
187976
188295
|
return INDEX_FAILED;
|
|
@@ -187991,7 +188310,7 @@ function processDirtyBatch(paths, index = makeIndexer(globalDbPath()), remove =
|
|
|
187991
188310
|
for (const p of paths) {
|
|
187992
188311
|
if (!p) continue;
|
|
187993
188312
|
if (isUnderBlockedRoot(p, blockedRoots)) continue;
|
|
187994
|
-
if (!
|
|
188313
|
+
if (!fs16.existsSync(p)) {
|
|
187995
188314
|
remove(p);
|
|
187996
188315
|
continue;
|
|
187997
188316
|
}
|
|
@@ -188001,7 +188320,7 @@ function processDirtyBatch(paths, index = makeIndexer(globalDbPath()), remove =
|
|
|
188001
188320
|
requeueDirtyPath(dir, p);
|
|
188002
188321
|
continue;
|
|
188003
188322
|
}
|
|
188004
|
-
|
|
188323
|
+
clearRetryCount(path20.join(dir, "global.db"), p);
|
|
188005
188324
|
const result = index(p, sha);
|
|
188006
188325
|
if (result !== false && result !== INDEX_FAILED) indexed += 1;
|
|
188007
188326
|
}
|
|
@@ -188020,13 +188339,13 @@ function drainOnce(dir, index, remove) {
|
|
|
188020
188339
|
const indexFn = index ?? makeIndexer(dbPath);
|
|
188021
188340
|
const removeFn = remove ?? makeRemover(dbPath);
|
|
188022
188341
|
let processed = 0;
|
|
188023
|
-
if (
|
|
188342
|
+
if (fs16.existsSync(draining)) {
|
|
188024
188343
|
let drainingContent;
|
|
188025
188344
|
try {
|
|
188026
|
-
drainingContent =
|
|
188345
|
+
drainingContent = fs16.readFileSync(draining, "utf8");
|
|
188027
188346
|
} catch {
|
|
188028
188347
|
try {
|
|
188029
|
-
|
|
188348
|
+
fs16.renameSync(draining, `${draining}.corrupt-${Date.now()}`);
|
|
188030
188349
|
} catch {
|
|
188031
188350
|
}
|
|
188032
188351
|
return 0;
|
|
@@ -188035,22 +188354,22 @@ function drainOnce(dir, index, remove) {
|
|
|
188035
188354
|
processed += processDirtyBatch(parseDirtyQueueLines(drainingContent), indexFn, removeFn, dir);
|
|
188036
188355
|
}
|
|
188037
188356
|
try {
|
|
188038
|
-
|
|
188357
|
+
fs16.rmSync(draining, { force: true });
|
|
188039
188358
|
unclearedDrainingSnapshots.delete(draining);
|
|
188040
188359
|
} catch {
|
|
188041
188360
|
try {
|
|
188042
|
-
|
|
188361
|
+
fs16.renameSync(draining, `${draining}.corrupt-${Date.now()}`);
|
|
188043
188362
|
unclearedDrainingSnapshots.delete(draining);
|
|
188044
188363
|
} catch {
|
|
188045
188364
|
unclearedDrainingSnapshots.set(draining, drainingContent);
|
|
188046
188365
|
}
|
|
188047
188366
|
}
|
|
188048
188367
|
}
|
|
188049
|
-
if (
|
|
188368
|
+
if (fs16.existsSync(queuePath)) {
|
|
188050
188369
|
let claimed = false;
|
|
188051
188370
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
188052
188371
|
try {
|
|
188053
|
-
|
|
188372
|
+
fs16.renameSync(queuePath, draining);
|
|
188054
188373
|
claimed = true;
|
|
188055
188374
|
break;
|
|
188056
188375
|
} catch {
|
|
@@ -188061,17 +188380,17 @@ function drainOnce(dir, index, remove) {
|
|
|
188061
188380
|
let claimedContent = "";
|
|
188062
188381
|
let readOk = false;
|
|
188063
188382
|
try {
|
|
188064
|
-
claimedContent =
|
|
188383
|
+
claimedContent = fs16.readFileSync(draining, "utf8");
|
|
188065
188384
|
readOk = true;
|
|
188066
188385
|
} catch {
|
|
188067
188386
|
}
|
|
188068
188387
|
if (readOk) {
|
|
188069
188388
|
processed += processDirtyBatch(parseDirtyQueueLines(claimedContent), indexFn, removeFn, dir);
|
|
188070
188389
|
try {
|
|
188071
|
-
|
|
188390
|
+
fs16.rmSync(draining, { force: true });
|
|
188072
188391
|
} catch {
|
|
188073
188392
|
try {
|
|
188074
|
-
|
|
188393
|
+
fs16.renameSync(draining, `${draining}.corrupt-${Date.now()}`);
|
|
188075
188394
|
} catch {
|
|
188076
188395
|
unclearedDrainingSnapshots.set(draining, claimedContent);
|
|
188077
188396
|
}
|
|
@@ -188091,7 +188410,7 @@ function pidAlive(pid) {
|
|
|
188091
188410
|
}
|
|
188092
188411
|
function readPidFile(dir) {
|
|
188093
188412
|
try {
|
|
188094
|
-
const raw =
|
|
188413
|
+
const raw = fs16.readFileSync(workerPidPath(dir), "utf8").trim();
|
|
188095
188414
|
if (!/^\d+$/.test(raw)) return null;
|
|
188096
188415
|
return parseInt(raw, 10);
|
|
188097
188416
|
} catch {
|
|
@@ -188114,7 +188433,7 @@ function stopWorker(dir = dataDir()) {
|
|
|
188114
188433
|
}
|
|
188115
188434
|
}
|
|
188116
188435
|
try {
|
|
188117
|
-
|
|
188436
|
+
fs16.rmSync(workerPidPath(dir), { force: true });
|
|
188118
188437
|
} catch {
|
|
188119
188438
|
}
|
|
188120
188439
|
return alive;
|
|
@@ -188128,7 +188447,7 @@ var WorkerAlreadyRunningError = class extends Error {
|
|
|
188128
188447
|
function claimWorkerPidFile(dir, pid) {
|
|
188129
188448
|
const pidPath = workerPidPath(dir);
|
|
188130
188449
|
try {
|
|
188131
|
-
|
|
188450
|
+
fs16.writeFileSync(pidPath, `${pid}
|
|
188132
188451
|
`, { flag: "wx" });
|
|
188133
188452
|
return true;
|
|
188134
188453
|
} catch (e) {
|
|
@@ -188139,11 +188458,11 @@ function claimWorkerPidFile(dir, pid) {
|
|
|
188139
188458
|
return false;
|
|
188140
188459
|
}
|
|
188141
188460
|
try {
|
|
188142
|
-
|
|
188461
|
+
fs16.rmSync(pidPath, { force: true });
|
|
188143
188462
|
} catch {
|
|
188144
188463
|
}
|
|
188145
188464
|
try {
|
|
188146
|
-
|
|
188465
|
+
fs16.writeFileSync(pidPath, `${pid}
|
|
188147
188466
|
`, { flag: "wx" });
|
|
188148
188467
|
return true;
|
|
188149
188468
|
} catch (e2) {
|
|
@@ -188155,9 +188474,9 @@ function startDetachedWorker(opts) {
|
|
|
188155
188474
|
const pollIntervalMs = opts?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
188156
188475
|
const dir = opts?.dataDir ?? dataDir();
|
|
188157
188476
|
try {
|
|
188158
|
-
|
|
188477
|
+
fs16.mkdirSync(dir, { recursive: true });
|
|
188159
188478
|
} catch (e) {
|
|
188160
|
-
if (e.code !== "EEXIST" || !
|
|
188479
|
+
if (e.code !== "EEXIST" || !fs16.existsSync(dir)) throw e;
|
|
188161
188480
|
}
|
|
188162
188481
|
const child = spawn2(
|
|
188163
188482
|
process.execPath,
|
|
@@ -188214,7 +188533,7 @@ function runDetachedWorkerDaemon() {
|
|
|
188214
188533
|
process.on("exit", () => {
|
|
188215
188534
|
if (readPidFile(dir) === process.pid) {
|
|
188216
188535
|
try {
|
|
188217
|
-
|
|
188536
|
+
fs16.rmSync(workerPidPath(dir), { force: true });
|
|
188218
188537
|
} catch {
|
|
188219
188538
|
}
|
|
188220
188539
|
}
|
|
@@ -188246,17 +188565,17 @@ function appendDirtyPath(normalizedPath2) {
|
|
|
188246
188565
|
const queuePath = dirtyQueuePath();
|
|
188247
188566
|
const dir = path21.dirname(queuePath);
|
|
188248
188567
|
try {
|
|
188249
|
-
|
|
188568
|
+
fs17.mkdirSync(dir, { recursive: true });
|
|
188250
188569
|
} catch (e) {
|
|
188251
|
-
if (e.code !== "EEXIST" || !
|
|
188570
|
+
if (e.code !== "EEXIST" || !fs17.existsSync(dir)) throw e;
|
|
188252
188571
|
}
|
|
188253
188572
|
let leadingNewline = "";
|
|
188254
188573
|
try {
|
|
188255
|
-
const existing =
|
|
188574
|
+
const existing = fs17.readFileSync(queuePath, "utf8");
|
|
188256
188575
|
if (existing.length > 0 && !existing.endsWith("\n")) leadingNewline = "\n";
|
|
188257
188576
|
} catch {
|
|
188258
188577
|
}
|
|
188259
|
-
|
|
188578
|
+
fs17.appendFileSync(queuePath, `${leadingNewline}${normalizedPath2}
|
|
188260
188579
|
`);
|
|
188261
188580
|
resetTransientRetryCount(normalizedPath2);
|
|
188262
188581
|
}
|
|
@@ -188264,7 +188583,7 @@ function getDirtyPaths() {
|
|
|
188264
188583
|
const queuePath = dirtyQueuePath();
|
|
188265
188584
|
let raw;
|
|
188266
188585
|
try {
|
|
188267
|
-
raw =
|
|
188586
|
+
raw = fs17.readFileSync(queuePath, "utf8");
|
|
188268
188587
|
} catch {
|
|
188269
188588
|
return [];
|
|
188270
188589
|
}
|
|
@@ -188283,7 +188602,7 @@ function preCompactIndexHandler(_event) {
|
|
|
188283
188602
|
if (paths.length > 0) {
|
|
188284
188603
|
const sidecar = path21.join(dataDir(), "queue", "pending.txt");
|
|
188285
188604
|
try {
|
|
188286
|
-
|
|
188605
|
+
fs17.mkdirSync(path21.dirname(sidecar), { recursive: true });
|
|
188287
188606
|
atomicWriteBytes(sidecar, Buffer.from(`${paths.join("\n")}
|
|
188288
188607
|
`, "utf8"));
|
|
188289
188608
|
} catch {
|
|
@@ -188493,7 +188812,7 @@ var HOOK_EVENTS = [
|
|
|
188493
188812
|
|
|
188494
188813
|
// src/hooks_read.ts
|
|
188495
188814
|
init_define_import_meta_env();
|
|
188496
|
-
import * as
|
|
188815
|
+
import * as fs23 from "node:fs";
|
|
188497
188816
|
import * as path26 from "node:path";
|
|
188498
188817
|
|
|
188499
188818
|
// src/hints.ts
|
|
@@ -188849,6 +189168,10 @@ ${headings.join("\n")}` : "",
|
|
|
188849
189168
|
}
|
|
188850
189169
|
function handleTxt(filePath, content, contentLengthHint) {
|
|
188851
189170
|
if ((contentLengthHint ?? content.length) < FILE_TYPE_THRESHOLDS.txt) return { shouldBlock: false, message: "" };
|
|
189171
|
+
const contentSniff = content.slice(0, 1e3);
|
|
189172
|
+
if (/^\s*<!DOCTYPE\s+html|^\s*<html[\s>]/i.test(contentSniff)) {
|
|
189173
|
+
return handleHtml(filePath, content, contentLengthHint);
|
|
189174
|
+
}
|
|
188852
189175
|
const lines = content.split("\n");
|
|
188853
189176
|
const isLog = /\.(log|out|err|trace)$/i.test(filePath) || filePath.includes("/logs/");
|
|
188854
189177
|
const preview = [
|
|
@@ -188970,7 +189293,7 @@ function dispatchFileTypeHandler(filePath, content, contentLengthHint) {
|
|
|
188970
189293
|
// src/project.ts
|
|
188971
189294
|
init_define_import_meta_env();
|
|
188972
189295
|
import * as crypto3 from "node:crypto";
|
|
188973
|
-
import * as
|
|
189296
|
+
import * as fs18 from "node:fs";
|
|
188974
189297
|
import * as os7 from "node:os";
|
|
188975
189298
|
import * as path22 from "node:path";
|
|
188976
189299
|
var WSL_PREFIX_RE = /^\/mnt\/([a-zA-Z])\/(.*)$/;
|
|
@@ -189018,6 +189341,7 @@ function canonicalize(inputPath, baseDir) {
|
|
|
189018
189341
|
if (isWin32) {
|
|
189019
189342
|
normalized = normalizeShellDrivePrefix(normalized);
|
|
189020
189343
|
}
|
|
189344
|
+
normalized = expandShortPath(normalized);
|
|
189021
189345
|
normalized = lowercaseDriveLetter(normalized);
|
|
189022
189346
|
return normalized;
|
|
189023
189347
|
}
|
|
@@ -189036,7 +189360,7 @@ function makeProjectAt(root) {
|
|
|
189036
189360
|
);
|
|
189037
189361
|
}
|
|
189038
189362
|
try {
|
|
189039
|
-
const stat2 =
|
|
189363
|
+
const stat2 = fs18.statSync(canonical);
|
|
189040
189364
|
if (!stat2.isDirectory()) {
|
|
189041
189365
|
throw new Error(`makeProjectAt: path is not a directory: ${canonical}`);
|
|
189042
189366
|
}
|
|
@@ -189052,14 +189376,14 @@ function makeProjectAt(root) {
|
|
|
189052
189376
|
function isRepoContainer(pathStr) {
|
|
189053
189377
|
let nestedRepos = 0;
|
|
189054
189378
|
try {
|
|
189055
|
-
const entries =
|
|
189379
|
+
const entries = fs18.readdirSync(pathStr, { withFileTypes: true });
|
|
189056
189380
|
for (const entry of entries) {
|
|
189057
189381
|
if (entry.isDirectory()) {
|
|
189058
189382
|
const gitPath = path22.join(pathStr, entry.name, ".git");
|
|
189059
|
-
if (
|
|
189383
|
+
if (fs18.existsSync(gitPath)) {
|
|
189060
189384
|
let isGitDir = false;
|
|
189061
189385
|
try {
|
|
189062
|
-
isGitDir =
|
|
189386
|
+
isGitDir = fs18.statSync(gitPath).isDirectory();
|
|
189063
189387
|
} catch {
|
|
189064
189388
|
}
|
|
189065
189389
|
if (isGitDir) {
|
|
@@ -189079,14 +189403,14 @@ function isRepoContainer(pathStr) {
|
|
|
189079
189403
|
function markerExists(current, marker) {
|
|
189080
189404
|
const markerPath = path22.join(current, marker);
|
|
189081
189405
|
try {
|
|
189082
|
-
if (!
|
|
189406
|
+
if (!fs18.existsSync(markerPath)) {
|
|
189083
189407
|
return false;
|
|
189084
189408
|
}
|
|
189085
|
-
const stat2 =
|
|
189409
|
+
const stat2 = fs18.lstatSync(markerPath);
|
|
189086
189410
|
if (!stat2.isSymbolicLink()) {
|
|
189087
189411
|
return true;
|
|
189088
189412
|
}
|
|
189089
|
-
const resolved =
|
|
189413
|
+
const resolved = fs18.realpathSync(markerPath);
|
|
189090
189414
|
const rel = path22.relative(path22.resolve(current), path22.resolve(resolved));
|
|
189091
189415
|
return !rel.startsWith("..");
|
|
189092
189416
|
} catch {
|
|
@@ -189133,7 +189457,7 @@ function findProject(cwd) {
|
|
|
189133
189457
|
|
|
189134
189458
|
// src/skill_cache.ts
|
|
189135
189459
|
init_define_import_meta_env();
|
|
189136
|
-
import * as
|
|
189460
|
+
import * as fs19 from "fs/promises";
|
|
189137
189461
|
import { createHash as createHash4 } from "crypto";
|
|
189138
189462
|
import { resolve as resolve7 } from "path";
|
|
189139
189463
|
import { homedir as homedir7 } from "os";
|
|
@@ -189156,7 +189480,7 @@ function skillsSourceDir() {
|
|
|
189156
189480
|
}
|
|
189157
189481
|
async function ensureSkillsDir() {
|
|
189158
189482
|
try {
|
|
189159
|
-
await
|
|
189483
|
+
await fs19.mkdir(skillOutputsDir(), { recursive: true });
|
|
189160
189484
|
} catch {
|
|
189161
189485
|
}
|
|
189162
189486
|
}
|
|
@@ -189264,14 +189588,14 @@ function extractNamedSection(body, heading) {
|
|
|
189264
189588
|
async function listOutputs() {
|
|
189265
189589
|
try {
|
|
189266
189590
|
const dir = skillOutputsDir();
|
|
189267
|
-
const entries = await
|
|
189591
|
+
const entries = await fs19.readdir(dir, { withFileTypes: true });
|
|
189268
189592
|
const metas = [];
|
|
189269
189593
|
for (const entry of entries) {
|
|
189270
189594
|
if (!entry.isFile() || !entry.name.endsWith(".meta")) {
|
|
189271
189595
|
continue;
|
|
189272
189596
|
}
|
|
189273
189597
|
try {
|
|
189274
|
-
const content = await
|
|
189598
|
+
const content = await fs19.readFile(resolve7(dir, entry.name), "utf-8");
|
|
189275
189599
|
const meta3 = JSON.parse(content);
|
|
189276
189600
|
metas.push(meta3);
|
|
189277
189601
|
} catch {
|
|
@@ -189308,8 +189632,8 @@ async function findCrossSessionEntry(skillName, contentSha) {
|
|
|
189308
189632
|
const bodyPath = resolve7(dir, `${meta3.outputId}.txt`);
|
|
189309
189633
|
const gzPath = resolve7(dir, `${meta3.outputId}.gz`);
|
|
189310
189634
|
try {
|
|
189311
|
-
const bodyExists = await
|
|
189312
|
-
const gzExists = await
|
|
189635
|
+
const bodyExists = await fs19.access(bodyPath).then(() => true).catch(() => false);
|
|
189636
|
+
const gzExists = await fs19.access(gzPath).then(() => true).catch(() => false);
|
|
189313
189637
|
if (bodyExists || gzExists) {
|
|
189314
189638
|
return meta3;
|
|
189315
189639
|
}
|
|
@@ -189436,7 +189760,7 @@ async function readSkillHits(skillName) {
|
|
|
189436
189760
|
if (!name2) return { count: 0, lastTs: 0 };
|
|
189437
189761
|
const dir = skillOutputsDir();
|
|
189438
189762
|
const hitsFile = resolve7(dir, `${sanitizeSkillId(name2)}.hits`);
|
|
189439
|
-
const content = await
|
|
189763
|
+
const content = await fs19.readFile(hitsFile, "utf-8").catch(() => null);
|
|
189440
189764
|
if (content) {
|
|
189441
189765
|
const parsed = JSON.parse(content);
|
|
189442
189766
|
return parsed;
|
|
@@ -189451,14 +189775,14 @@ var SKILL_HIT_LOCK_STALE_MS = 5e3;
|
|
|
189451
189775
|
async function acquireSkillHitLock(lockPath) {
|
|
189452
189776
|
for (let attempt = 0; attempt < SKILL_HIT_LOCK_MAX_ATTEMPTS; attempt++) {
|
|
189453
189777
|
try {
|
|
189454
|
-
await
|
|
189778
|
+
await fs19.mkdir(lockPath);
|
|
189455
189779
|
return true;
|
|
189456
189780
|
} catch (err3) {
|
|
189457
189781
|
if (err3.code !== "EEXIST") return false;
|
|
189458
189782
|
try {
|
|
189459
|
-
const st = await
|
|
189783
|
+
const st = await fs19.stat(lockPath);
|
|
189460
189784
|
if (Date.now() - st.mtimeMs > SKILL_HIT_LOCK_STALE_MS) {
|
|
189461
|
-
await
|
|
189785
|
+
await fs19.rmdir(lockPath).catch(() => {
|
|
189462
189786
|
});
|
|
189463
189787
|
continue;
|
|
189464
189788
|
}
|
|
@@ -189485,7 +189809,7 @@ async function incrementSkillHit(skillName) {
|
|
|
189485
189809
|
hits.lastTs = Date.now();
|
|
189486
189810
|
await atomicWriteText(hitsFile, JSON.stringify(hits, null, 2));
|
|
189487
189811
|
} finally {
|
|
189488
|
-
if (locked) await
|
|
189812
|
+
if (locked) await fs19.rmdir(lockPath).catch(() => {
|
|
189489
189813
|
});
|
|
189490
189814
|
}
|
|
189491
189815
|
} catch {
|
|
@@ -189520,14 +189844,14 @@ async function listSkills(sessionId) {
|
|
|
189520
189844
|
let compactLen = 0;
|
|
189521
189845
|
let compactText = "";
|
|
189522
189846
|
try {
|
|
189523
|
-
const stat2 = await
|
|
189847
|
+
const stat2 = await fs19.stat(resolve7(dir, compactFileId));
|
|
189524
189848
|
compactLen = stat2.size;
|
|
189525
|
-
compactText = await
|
|
189849
|
+
compactText = await fs19.readFile(resolve7(dir, compactFileId), "utf-8").catch(() => "");
|
|
189526
189850
|
} catch {
|
|
189527
189851
|
compactLen = 0;
|
|
189528
189852
|
}
|
|
189529
189853
|
const hasMarker = extractCompactFromMarker(
|
|
189530
|
-
await
|
|
189854
|
+
await fs19.readFile(resolve7(dir, `${meta3.outputId}.txt`), "utf-8").catch(() => "")
|
|
189531
189855
|
) !== null;
|
|
189532
189856
|
const compactStale = isCompactStale(compactText, meta3.skillName, meta3.contentSha);
|
|
189533
189857
|
const { count: hitCount } = await readSkillHits(meta3.skillName);
|
|
@@ -189567,7 +189891,7 @@ async function installedSkillPath(skillName) {
|
|
|
189567
189891
|
if (!name2) return null;
|
|
189568
189892
|
const diskPath = resolve7(skillsSourceDir(), name2, "SKILL.md");
|
|
189569
189893
|
try {
|
|
189570
|
-
await
|
|
189894
|
+
await fs19.access(diskPath);
|
|
189571
189895
|
return diskPath;
|
|
189572
189896
|
} catch {
|
|
189573
189897
|
return null;
|
|
@@ -189627,7 +189951,7 @@ function pruneSkillOutputs(maxCount = DEFAULT_MAX_COUNT, maxAgeMs = DEFAULT_MAX_
|
|
|
189627
189951
|
|
|
189628
189952
|
// src/image_shrink.ts
|
|
189629
189953
|
init_define_import_meta_env();
|
|
189630
|
-
import * as
|
|
189954
|
+
import * as fs20 from "node:fs";
|
|
189631
189955
|
import * as path23 from "node:path";
|
|
189632
189956
|
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
189633
189957
|
".png",
|
|
@@ -189695,7 +190019,7 @@ async function shrinkImage(input, opts) {
|
|
|
189695
190019
|
}
|
|
189696
190020
|
function statSize(absPath) {
|
|
189697
190021
|
try {
|
|
189698
|
-
const st =
|
|
190022
|
+
const st = fs20.statSync(absPath);
|
|
189699
190023
|
return st.isFile() ? st.size : null;
|
|
189700
190024
|
} catch {
|
|
189701
190025
|
return null;
|
|
@@ -189709,7 +190033,7 @@ async function preReadImageHandler(event) {
|
|
|
189709
190033
|
if (size === null || size < DEFAULT_SIZE_THRESHOLD_BYTES) return passOutput();
|
|
189710
190034
|
let input;
|
|
189711
190035
|
try {
|
|
189712
|
-
input =
|
|
190036
|
+
input = fs20.readFileSync(filePath);
|
|
189713
190037
|
} catch {
|
|
189714
190038
|
return passOutput();
|
|
189715
190039
|
}
|
|
@@ -189726,7 +190050,7 @@ registerHook("pre_tool_use", preReadImageHandler, { toolName: "Read" });
|
|
|
189726
190050
|
|
|
189727
190051
|
// src/doc_compact.ts
|
|
189728
190052
|
init_define_import_meta_env();
|
|
189729
|
-
import * as
|
|
190053
|
+
import * as fs21 from "fs";
|
|
189730
190054
|
import * as crypto4 from "crypto";
|
|
189731
190055
|
import * as path24 from "path";
|
|
189732
190056
|
var defaultSentencesPerSection = 2;
|
|
@@ -189735,7 +190059,7 @@ var headerRegex = /^<!-- token-goat doc-compact source-hash:(\S+) source:(.+?) -
|
|
|
189735
190059
|
var compactSubdir = "doc_compacts";
|
|
189736
190060
|
function sourceHash(filePath) {
|
|
189737
190061
|
try {
|
|
189738
|
-
const data =
|
|
190062
|
+
const data = fs21.readFileSync(filePath);
|
|
189739
190063
|
return crypto4.createHash("sha256").update(data).digest("hex");
|
|
189740
190064
|
} catch {
|
|
189741
190065
|
return "";
|
|
@@ -189749,12 +190073,12 @@ function _compactSlug(absPathStr) {
|
|
|
189749
190073
|
return `${h}_${safeStem}`;
|
|
189750
190074
|
}
|
|
189751
190075
|
function compactPathFor(sourcePath) {
|
|
189752
|
-
const abs = path24.resolve(sourcePath);
|
|
190076
|
+
const abs = normalizePath(path24.resolve(sourcePath));
|
|
189753
190077
|
return path24.join(dataDir(), compactSubdir, `${_compactSlug(abs)}.md`);
|
|
189754
190078
|
}
|
|
189755
190079
|
function readCompactHeader(compactPath) {
|
|
189756
190080
|
try {
|
|
189757
|
-
const text =
|
|
190081
|
+
const text = fs21.readFileSync(compactPath, "utf-8");
|
|
189758
190082
|
const firstLine = text.split("\n")[0] || "";
|
|
189759
190083
|
const m = firstLine.match(headerRegex);
|
|
189760
190084
|
if (!m || !m[1] || !m[2]) return null;
|
|
@@ -189773,8 +190097,8 @@ function isCompactFresh(compactPath, sourcePath) {
|
|
|
189773
190097
|
}
|
|
189774
190098
|
function markCompactStale(compactPath) {
|
|
189775
190099
|
try {
|
|
189776
|
-
if (!
|
|
189777
|
-
const text =
|
|
190100
|
+
if (!fs21.existsSync(compactPath)) return false;
|
|
190101
|
+
const text = fs21.readFileSync(compactPath, "utf-8");
|
|
189778
190102
|
const lines = text.split("\n");
|
|
189779
190103
|
if (!lines[0]) return false;
|
|
189780
190104
|
const m = lines[0].match(headerRegex);
|
|
@@ -189789,7 +190113,7 @@ function markCompactStale(compactPath) {
|
|
|
189789
190113
|
}
|
|
189790
190114
|
function readCompactBody(compactPath) {
|
|
189791
190115
|
try {
|
|
189792
|
-
const text =
|
|
190116
|
+
const text = fs21.readFileSync(compactPath, "utf-8");
|
|
189793
190117
|
const lines = text.split("\n");
|
|
189794
190118
|
if (lines.length < 2) return null;
|
|
189795
190119
|
const body = lines.slice(1).join("\n").trimStart();
|
|
@@ -189806,8 +190130,8 @@ function writeCompact(compactPath, sourcePath, compactBody, sourceRel) {
|
|
|
189806
190130
|
`;
|
|
189807
190131
|
const fullText = header + compactBody.trimStart();
|
|
189808
190132
|
const dir = path24.dirname(compactPath);
|
|
189809
|
-
if (!
|
|
189810
|
-
|
|
190133
|
+
if (!fs21.existsSync(dir)) {
|
|
190134
|
+
fs21.mkdirSync(dir, { recursive: true });
|
|
189811
190135
|
}
|
|
189812
190136
|
atomicWriteText(compactPath, fullText);
|
|
189813
190137
|
}
|
|
@@ -189918,7 +190242,7 @@ function extractDocCompact(body, heading) {
|
|
|
189918
190242
|
}
|
|
189919
190243
|
function compactDoc(filePath, heading) {
|
|
189920
190244
|
try {
|
|
189921
|
-
const body =
|
|
190245
|
+
const body = fs21.readFileSync(filePath, "utf-8");
|
|
189922
190246
|
const compact = extractDocCompact(body, heading);
|
|
189923
190247
|
return compact || null;
|
|
189924
190248
|
} catch {
|
|
@@ -189928,7 +190252,7 @@ function compactDoc(filePath, heading) {
|
|
|
189928
190252
|
|
|
189929
190253
|
// src/notebook_compact.ts
|
|
189930
190254
|
init_define_import_meta_env();
|
|
189931
|
-
import * as
|
|
190255
|
+
import * as fs22 from "node:fs";
|
|
189932
190256
|
import * as path25 from "node:path";
|
|
189933
190257
|
import * as crypto5 from "node:crypto";
|
|
189934
190258
|
var NB_STRIP_MIN_SAVINGS = 4096;
|
|
@@ -189953,20 +190277,20 @@ function pruneSidecars(cacheRoot, maxCount = SIDECAR_DEFAULT_MAX_COUNT, maxAgeMs
|
|
|
189953
190277
|
const nbStripDir = path25.join(cacheRoot, "nb_strip");
|
|
189954
190278
|
let removed = 0;
|
|
189955
190279
|
try {
|
|
189956
|
-
if (!
|
|
190280
|
+
if (!fs22.existsSync(nbStripDir)) return 0;
|
|
189957
190281
|
const cutoff = Date.now() - maxAgeMs;
|
|
189958
190282
|
const kept = [];
|
|
189959
|
-
for (const entry of
|
|
190283
|
+
for (const entry of fs22.readdirSync(nbStripDir)) {
|
|
189960
190284
|
const dir = path25.join(nbStripDir, entry);
|
|
189961
190285
|
let mtime;
|
|
189962
190286
|
try {
|
|
189963
|
-
mtime =
|
|
190287
|
+
mtime = fs22.statSync(dir).mtimeMs;
|
|
189964
190288
|
} catch {
|
|
189965
190289
|
continue;
|
|
189966
190290
|
}
|
|
189967
190291
|
if (mtime < cutoff) {
|
|
189968
190292
|
try {
|
|
189969
|
-
|
|
190293
|
+
fs22.rmSync(dir, { recursive: true, force: true });
|
|
189970
190294
|
removed++;
|
|
189971
190295
|
} catch {
|
|
189972
190296
|
continue;
|
|
@@ -189979,7 +190303,7 @@ function pruneSidecars(cacheRoot, maxCount = SIDECAR_DEFAULT_MAX_COUNT, maxAgeMs
|
|
|
189979
190303
|
kept.sort((a, b) => a[1] - b[1]);
|
|
189980
190304
|
for (const [dir] of kept.slice(0, kept.length - maxCount)) {
|
|
189981
190305
|
try {
|
|
189982
|
-
|
|
190306
|
+
fs22.rmSync(dir, { recursive: true, force: true });
|
|
189983
190307
|
removed++;
|
|
189984
190308
|
} catch {
|
|
189985
190309
|
continue;
|
|
@@ -189995,7 +190319,7 @@ function getOrCreateSidecar(rawBytes, cacheRoot, opts = {}) {
|
|
|
189995
190319
|
const sha = crypto5.createHash("sha256").update(rawBytes).digest("hex");
|
|
189996
190320
|
const sidecarDir = path25.join(cacheRoot, "nb_strip", sha);
|
|
189997
190321
|
const sidecarPath = path25.join(sidecarDir, "stripped.ipynb");
|
|
189998
|
-
if (
|
|
190322
|
+
if (fs22.existsSync(sidecarPath)) {
|
|
189999
190323
|
return [sidecarPath, false];
|
|
190000
190324
|
}
|
|
190001
190325
|
let nb;
|
|
@@ -190010,9 +190334,9 @@ function getOrCreateSidecar(rawBytes, cacheRoot, opts = {}) {
|
|
|
190010
190334
|
const nbDict = nb;
|
|
190011
190335
|
const stripped = stripNotebook(nbDict);
|
|
190012
190336
|
try {
|
|
190013
|
-
|
|
190337
|
+
fs22.mkdirSync(sidecarDir, { recursive: true });
|
|
190014
190338
|
} catch (err3) {
|
|
190015
|
-
if (!
|
|
190339
|
+
if (!fs22.existsSync(sidecarDir)) {
|
|
190016
190340
|
throw err3;
|
|
190017
190341
|
}
|
|
190018
190342
|
}
|
|
@@ -190029,6 +190353,7 @@ function isTsConfigFile(basename17) {
|
|
|
190029
190353
|
}
|
|
190030
190354
|
var LARGE_FILE_BYTES = FILE_TYPE_THRESHOLDS.generic;
|
|
190031
190355
|
var REREAD_DENY_BYTES = 50 * 1024;
|
|
190356
|
+
var TASK_OUTPUT_DENY_BYTES = 20 * 1024;
|
|
190032
190357
|
var DENY_THRESHOLD_TIER_MULTIPLIERS = {
|
|
190033
190358
|
cool: 1,
|
|
190034
190359
|
warm: 0.67,
|
|
@@ -190058,7 +190383,7 @@ function sessionArtifactRecall(filePath) {
|
|
|
190058
190383
|
}
|
|
190059
190384
|
function statSize2(absPath) {
|
|
190060
190385
|
try {
|
|
190061
|
-
return
|
|
190386
|
+
return fs23.statSync(absPath).size;
|
|
190062
190387
|
} catch {
|
|
190063
190388
|
return null;
|
|
190064
190389
|
}
|
|
@@ -190078,7 +190403,7 @@ function scanRequestedSlice(absPath, offset, limit) {
|
|
|
190078
190403
|
const windowEnd = offset + limit;
|
|
190079
190404
|
let fd2;
|
|
190080
190405
|
try {
|
|
190081
|
-
fd2 =
|
|
190406
|
+
fd2 = fs23.openSync(absPath, "r");
|
|
190082
190407
|
} catch {
|
|
190083
190408
|
return null;
|
|
190084
190409
|
}
|
|
@@ -190092,7 +190417,7 @@ function scanRequestedSlice(absPath, offset, limit) {
|
|
|
190092
190417
|
const nearSingleLine = lineNumber < NEAR_SINGLE_LINE_SCAN_THRESHOLD;
|
|
190093
190418
|
return { bytes: sliceBytes, trustworthy: nearSingleLine, nearSingleLine };
|
|
190094
190419
|
}
|
|
190095
|
-
const bytesRead =
|
|
190420
|
+
const bytesRead = fs23.readSync(fd2, buf, 0, buf.length, null);
|
|
190096
190421
|
if (bytesRead === 0) {
|
|
190097
190422
|
return {
|
|
190098
190423
|
bytes: sliceBytes,
|
|
@@ -190111,7 +190436,7 @@ function scanRequestedSlice(absPath, offset, limit) {
|
|
|
190111
190436
|
}
|
|
190112
190437
|
} finally {
|
|
190113
190438
|
try {
|
|
190114
|
-
|
|
190439
|
+
fs23.closeSync(fd2);
|
|
190115
190440
|
} catch {
|
|
190116
190441
|
}
|
|
190117
190442
|
}
|
|
@@ -190269,7 +190594,7 @@ function preReadHandler(event) {
|
|
|
190269
190594
|
const skillName = detectSkillFile(normalized);
|
|
190270
190595
|
if (skillName && basename17 === "SKILL.md") {
|
|
190271
190596
|
try {
|
|
190272
|
-
const body =
|
|
190597
|
+
const body = fs23.readFileSync(normalized, "utf-8");
|
|
190273
190598
|
const bodySha = contentHash(body);
|
|
190274
190599
|
const compact = getCompactAnySessionSync(skillName);
|
|
190275
190600
|
const stale = isCompactStale(compact, skillName, bodySha);
|
|
@@ -190292,7 +190617,7 @@ function preReadHandler(event) {
|
|
|
190292
190617
|
const savedBytes = Math.max(0, fullSize - compactBody.length);
|
|
190293
190618
|
recordStat("session_hint", savedBytes, Math.round(savedBytes / 4));
|
|
190294
190619
|
return denyOutput(
|
|
190295
|
-
"Serving the extractive compact sidecar in place of the full file (source unchanged since the last `compact-doc` build):\n\n" + compactBody + '\n\nUse `token-goat compact-doc "' + normalized + '" --force` to rebuild it, or `token-goat compact-doc "' + normalized + '" --show` to view it directly. To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190620
|
+
"Serving the extractive compact sidecar in place of the full file (source unchanged since the last `compact-doc` build):\n\n" + compactBody + '\n\nUse `token-goat compact-doc "' + normalized + '" --force` to rebuild it, or `token-goat compact-doc "' + normalized + '" --show` to view it directly. To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190296
190621
|
);
|
|
190297
190622
|
}
|
|
190298
190623
|
}
|
|
@@ -190300,15 +190625,15 @@ function preReadHandler(event) {
|
|
|
190300
190625
|
const isNotebook = /\.ipynb$/i.test(basename17);
|
|
190301
190626
|
if (isNotebook) {
|
|
190302
190627
|
try {
|
|
190303
|
-
const rawBytes =
|
|
190628
|
+
const rawBytes = fs23.readFileSync(normalized);
|
|
190304
190629
|
const [sidecarPath] = getOrCreateSidecar(rawBytes, dataDir());
|
|
190305
|
-
const sidecarContent =
|
|
190630
|
+
const sidecarContent = fs23.readFileSync(sidecarPath, "utf-8");
|
|
190306
190631
|
const savedBytes = rawBytes.length - sidecarContent.length;
|
|
190307
190632
|
if (savedBytes >= NB_STRIP_MIN_SAVINGS) {
|
|
190308
190633
|
recordActualRead(event, normalized);
|
|
190309
190634
|
recordStat("session_hint", savedBytes, Math.round(savedBytes / 4));
|
|
190310
190635
|
return denyOutput(
|
|
190311
|
-
"Serving the output-stripped notebook in place of the full file (code-cell outputs and execution counts removed; source and metadata preserved):\n\n" + sidecarContent + '\n\nTo edit it anyway, use `token-goat replace "' + normalized + "
|
|
190636
|
+
"Serving the output-stripped notebook in place of the full file (code-cell outputs and execution counts removed; source and metadata preserved):\n\n" + sidecarContent + '\n\nTo edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190312
190637
|
);
|
|
190313
190638
|
}
|
|
190314
190639
|
} catch {
|
|
@@ -190322,7 +190647,7 @@ function preReadHandler(event) {
|
|
|
190322
190647
|
const sz = statSize2(normalized);
|
|
190323
190648
|
if (sz !== null && sz >= MARKDOWN_SIZE_THRESHOLD) {
|
|
190324
190649
|
markdownSize = sz;
|
|
190325
|
-
fileContent =
|
|
190650
|
+
fileContent = fs23.readFileSync(normalized, "utf8");
|
|
190326
190651
|
}
|
|
190327
190652
|
} catch {
|
|
190328
190653
|
}
|
|
@@ -190338,7 +190663,7 @@ function preReadHandler(event) {
|
|
|
190338
190663
|
let message = hintText + wellKnownText + changelogExtra;
|
|
190339
190664
|
const tooLargeForFirstRead = markdownSize !== null && markdownSize >= largeFileDenyBytes();
|
|
190340
190665
|
if (alreadyRead || tooLargeForFirstRead) {
|
|
190341
|
-
message += ' To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190666
|
+
message += ' To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny.";
|
|
190342
190667
|
return denyOutput(message);
|
|
190343
190668
|
}
|
|
190344
190669
|
return contextOutput(message);
|
|
@@ -190383,7 +190708,7 @@ function preReadHandler(event) {
|
|
|
190383
190708
|
try {
|
|
190384
190709
|
const sz = statSize2(normalized);
|
|
190385
190710
|
if (sz !== null && sz <= 256 * 1024) {
|
|
190386
|
-
const currentContent =
|
|
190711
|
+
const currentContent = fs23.readFileSync(normalized, "utf8");
|
|
190387
190712
|
const TRUNC_MARKER = "\n<snapshot truncated at ";
|
|
190388
190713
|
const oldRaw = oldArtifactSnap.toString("utf8");
|
|
190389
190714
|
const truncIdx = oldRaw.indexOf(TRUNC_MARKER);
|
|
@@ -190415,7 +190740,14 @@ function preReadHandler(event) {
|
|
|
190415
190740
|
);
|
|
190416
190741
|
}
|
|
190417
190742
|
if (/[/\\]tasks[/\\][a-z0-9]+\.output$/i.test(normalized)) {
|
|
190743
|
+
const outputSize = statSize2(normalized);
|
|
190418
190744
|
recordActualRead(event, normalized);
|
|
190745
|
+
if (outputSize !== null && outputSize >= TASK_OUTPUT_DENY_BYTES) {
|
|
190746
|
+
recordStat("session_hint", outputSize, Math.round(outputSize / 4));
|
|
190747
|
+
return denyOutput(
|
|
190748
|
+
"Session transcript is large (" + Math.round(outputSize / 1024) + "KB). " + sessionArtifactRecall(normalized)
|
|
190749
|
+
);
|
|
190750
|
+
}
|
|
190419
190751
|
return contextOutput("Session transcript: " + sessionArtifactRecall(normalized));
|
|
190420
190752
|
}
|
|
190421
190753
|
}
|
|
@@ -190426,7 +190758,7 @@ function preReadHandler(event) {
|
|
|
190426
190758
|
recordActualRead(event, normalized);
|
|
190427
190759
|
recordStat("session_hint", 0, 0);
|
|
190428
190760
|
return denyOutput(
|
|
190429
|
-
'File was truncated on last read (>33K tokens). Use `token-goat skeleton "' + normalized + '"` for structure or `token-goat read "' + normalized + '::SymbolName"` for one function. To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190761
|
+
'File was truncated on last read (>33K tokens). Use `token-goat skeleton "' + normalized + '"` for structure or `token-goat read "' + normalized + '::SymbolName"` for one function. To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190430
190762
|
);
|
|
190431
190763
|
}
|
|
190432
190764
|
const sessionId = getSessionId();
|
|
@@ -190435,7 +190767,7 @@ function preReadHandler(event) {
|
|
|
190435
190767
|
try {
|
|
190436
190768
|
const sz = statSize2(normalized);
|
|
190437
190769
|
if (sz !== null && sz <= 256 * 1024) {
|
|
190438
|
-
const currentContent =
|
|
190770
|
+
const currentContent = fs23.readFileSync(normalized, "utf8");
|
|
190439
190771
|
const TRUNC_MARKER = "\n<snapshot truncated at ";
|
|
190440
190772
|
const oldRaw = oldSnap.toString("utf8");
|
|
190441
190773
|
const truncIdx = oldRaw.indexOf(TRUNC_MARKER);
|
|
@@ -190501,25 +190833,25 @@ function preReadHandler(event) {
|
|
|
190501
190833
|
}
|
|
190502
190834
|
if (wasFileTruncatedThisSession(normalized)) {
|
|
190503
190835
|
return denyOutput(
|
|
190504
|
-
'File was truncated on last read (>33K tokens). Use `token-goat skeleton "' + normalized + '"` for structure or `token-goat read "' + normalized + '::SymbolName"` for one function. To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190836
|
+
'File was truncated on last read (>33K tokens). Use `token-goat skeleton "' + normalized + '"` for structure or `token-goat read "' + normalized + '::SymbolName"` for one function. To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190505
190837
|
);
|
|
190506
190838
|
}
|
|
190507
190839
|
if (/\.(md|mdx|markdown|rst)$/i.test(basename17)) {
|
|
190508
190840
|
return denyOutput(
|
|
190509
|
-
'Markdown file already read this session. Use `token-goat section "' + normalized + '::HeadingName"` to read one section. To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190841
|
+
'Markdown file already read this session. Use `token-goat section "' + normalized + '::HeadingName"` to read one section. To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190510
190842
|
);
|
|
190511
190843
|
}
|
|
190512
190844
|
const isSourceExt = isSourceExtension(basename17);
|
|
190513
190845
|
if (isSourceExt && reads >= 2) {
|
|
190514
190846
|
recordStat("read_count_deny", rereadBytes, Math.round(rereadBytes / 4));
|
|
190515
190847
|
return denyOutput(
|
|
190516
|
-
"Read this file " + reads + ' times already \u2014 use `token-goat read "' + normalized + '::Symbol"`, `token-goat skeleton ' + normalized + "`, or `token-goat outline " + normalized + '` to pull just the part you need. To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190848
|
+
"Read this file " + reads + ' times already \u2014 use `token-goat read "' + normalized + '::Symbol"`, `token-goat skeleton ' + normalized + "`, or `token-goat outline " + normalized + '` to pull just the part you need. To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190517
190849
|
);
|
|
190518
190850
|
}
|
|
190519
190851
|
const hint = _isDocFile(normalized) ? 'Use `token-goat section "' + normalized + '::SectionName"` to read one section.' : "Use token-goat read/section/symbol to re-read surgically.";
|
|
190520
190852
|
if (rereadBytes >= REREAD_DENY_BYTES || reads >= 2) {
|
|
190521
190853
|
return denyOutput(
|
|
190522
|
-
normalized + " was already read this session (" + reads + " " + plural2 + "). " + hint + ' To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190854
|
+
normalized + " was already read this session (" + reads + " " + plural2 + "). " + hint + ' To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190523
190855
|
);
|
|
190524
190856
|
}
|
|
190525
190857
|
return contextOutput(
|
|
@@ -190540,7 +190872,7 @@ function preReadHandler(event) {
|
|
|
190540
190872
|
recordStat("session_hint", size, Math.round(size / 4));
|
|
190541
190873
|
if (gateSize >= largeFileDenyBytes()) {
|
|
190542
190874
|
return denyOutput(
|
|
190543
|
-
normalized + " is very large (" + kb + "KB). " + hint + " " + describeSliceAdvice(slice, normalized) + ' To edit it anyway, use `token-goat replace "' + normalized + "
|
|
190875
|
+
normalized + " is very large (" + kb + "KB). " + hint + " " + describeSliceAdvice(slice, normalized) + ' To edit it anyway, use `token-goat replace "' + normalized + '" --old-from <oldfile> --new-from <newfile>` for a snippet edit, or `token-goat write-file "' + normalized + "\" --from <newfile>` to rewrite the whole file \u2014 Read/Edit's own precondition can't be satisfied after this deny."
|
|
190544
190876
|
);
|
|
190545
190877
|
}
|
|
190546
190878
|
recordActualRead(event, normalized);
|
|
@@ -190558,7 +190890,7 @@ function preReadHandler(event) {
|
|
|
190558
190890
|
let ftContent = "";
|
|
190559
190891
|
if (!BINARY_FILE_TYPE_EXTS.has(fileTypeExt)) {
|
|
190560
190892
|
try {
|
|
190561
|
-
ftContent =
|
|
190893
|
+
ftContent = fs23.readFileSync(normalized, "utf8");
|
|
190562
190894
|
} catch {
|
|
190563
190895
|
}
|
|
190564
190896
|
}
|
|
@@ -190605,7 +190937,7 @@ function postReadHandler(event) {
|
|
|
190605
190937
|
try {
|
|
190606
190938
|
const sz = statSize2(normalized);
|
|
190607
190939
|
if (sz !== null && sz <= 256 * 1024) {
|
|
190608
|
-
const content =
|
|
190940
|
+
const content = fs23.readFileSync(normalized);
|
|
190609
190941
|
store(getSessionId(), normalized, content);
|
|
190610
190942
|
}
|
|
190611
190943
|
} catch {
|
|
@@ -190637,7 +190969,7 @@ function postReadHandler(event) {
|
|
|
190637
190969
|
try {
|
|
190638
190970
|
const sz = statSize2(normalized);
|
|
190639
190971
|
if (sz !== null && sz <= SLICE_ESTIMATE_SCAN_CAP_BYTES) {
|
|
190640
|
-
const lineCount = countTextLines(
|
|
190972
|
+
const lineCount = countTextLines(fs23.readFileSync(normalized, "utf8"));
|
|
190641
190973
|
const minLines = loadConfig().post_read_code_compress.min_lines;
|
|
190642
190974
|
if (lineCount >= minLines) {
|
|
190643
190975
|
recordStat("session_hint", sz, Math.round(sz / 4));
|
|
@@ -190817,7 +191149,7 @@ init_define_import_meta_env();
|
|
|
190817
191149
|
|
|
190818
191150
|
// src/web_cache.ts
|
|
190819
191151
|
init_define_import_meta_env();
|
|
190820
|
-
import
|
|
191152
|
+
import fs24 from "fs";
|
|
190821
191153
|
var WEB_OUTPUT_SUBDIR = "web_outputs";
|
|
190822
191154
|
var _byId = /* @__PURE__ */ new Map();
|
|
190823
191155
|
var _urlIndex = /* @__PURE__ */ new Map();
|
|
@@ -190843,8 +191175,8 @@ function getWebOutput(cacheId) {
|
|
|
190843
191175
|
const p = blobPath(WEB_OUTPUT_SUBDIR, cacheId);
|
|
190844
191176
|
if (p !== null) {
|
|
190845
191177
|
try {
|
|
190846
|
-
if (
|
|
190847
|
-
const stat2 =
|
|
191178
|
+
if (fs24.existsSync(p)) {
|
|
191179
|
+
const stat2 = fs24.statSync(p);
|
|
190848
191180
|
const ageMs = Date.now() - stat2.mtimeMs;
|
|
190849
191181
|
if (ageMs > DEFAULT_MAX_AGE_MS) {
|
|
190850
191182
|
return null;
|
|
@@ -191361,11 +191693,11 @@ function toRegExp(r, i) {
|
|
|
191361
191693
|
if (r.str.length === 0) {
|
|
191362
191694
|
throw new Error(`Rule #${i} ("${r.name}") has empty "str" property, which is not allowed.`);
|
|
191363
191695
|
}
|
|
191364
|
-
return new RegExp(
|
|
191696
|
+
return new RegExp(escapeRegExp2(r.str), "y");
|
|
191365
191697
|
}
|
|
191366
|
-
return new RegExp(
|
|
191698
|
+
return new RegExp(escapeRegExp2(r.name), "y");
|
|
191367
191699
|
}
|
|
191368
|
-
function
|
|
191700
|
+
function escapeRegExp2(str) {
|
|
191369
191701
|
return str.replace(/[-[\]{}()*+!<=:?./\\^$|#\s,]/g, "\\$&");
|
|
191370
191702
|
}
|
|
191371
191703
|
function toSticky(re) {
|
|
@@ -197040,6 +197372,12 @@ var isTestRunnerCommand = (cmd) => isCommandOfType(cmd, "testRunner");
|
|
|
197040
197372
|
var isLintCommand = (cmd) => isCommandOfType(cmd, "lintCommand");
|
|
197041
197373
|
var isNpmRunScriptCommand = (cmd) => isCommandOfType(cmd, "npmRunScript");
|
|
197042
197374
|
var isCatCommand = (cmd) => isCommandOfType(cmd, "catCommand");
|
|
197375
|
+
function isScopedGitStatusOrDiffStatCommand(cmd) {
|
|
197376
|
+
if (!isCommandOfType(cmd, "gitMutable")) return false;
|
|
197377
|
+
if (!isCommandOfType(cmd, "gitDiffScoped")) return false;
|
|
197378
|
+
if (/^\s*git\s+diff\b/i.test(cmd) && !/--stat\b/.test(cmd)) return false;
|
|
197379
|
+
return true;
|
|
197380
|
+
}
|
|
197043
197381
|
function gitStateFingerprintSync(cwd) {
|
|
197044
197382
|
try {
|
|
197045
197383
|
const headResult = runGit(["rev-parse", "HEAD"], { cwd });
|
|
@@ -197161,7 +197499,7 @@ async function commandHash(command2, cwd = null) {
|
|
|
197161
197499
|
}
|
|
197162
197500
|
function computeBashFingerprints(command2, cwd) {
|
|
197163
197501
|
const fingerprints = {};
|
|
197164
|
-
if (cwd && (isGitMutableCommand(command2) || isGitPushCommand(command2) || isTestRunnerCommand(command2) || isLintCommand(command2) || isNpmRunScriptCommand(command2))) {
|
|
197502
|
+
if (cwd && (isGitMutableCommand(command2) || isGitPushCommand(command2) || isTestRunnerCommand(command2) || isLintCommand(command2) || isBuildCommand(command2) || isNpmRunScriptCommand(command2))) {
|
|
197165
197503
|
const fp = gitStateFingerprintSync(cwd);
|
|
197166
197504
|
if (fp) fingerprints.git = fp;
|
|
197167
197505
|
}
|
|
@@ -210628,12 +210966,12 @@ function filterByName(name2) {
|
|
|
210628
210966
|
|
|
210629
210967
|
// src/shell.ts
|
|
210630
210968
|
init_define_import_meta_env();
|
|
210631
|
-
import * as
|
|
210969
|
+
import * as fs25 from "node:fs";
|
|
210632
210970
|
import * as path28 from "node:path";
|
|
210633
210971
|
var WSL_LAUNCHER_SEGMENTS = /* @__PURE__ */ new Set(["system32", "syswow64", "windowsapps"]);
|
|
210634
210972
|
function isExecutable(p) {
|
|
210635
210973
|
try {
|
|
210636
|
-
return
|
|
210974
|
+
return fs25.statSync(p).isFile();
|
|
210637
210975
|
} catch {
|
|
210638
210976
|
return false;
|
|
210639
210977
|
}
|
|
@@ -210770,12 +211108,7 @@ function extractCatSourceFile(cmd) {
|
|
|
210770
211108
|
const m = /^cat\s+(\S+\.(?:java|py|ts|tsx|js|jsx|go|rb|rs|cpp|cc|cxx|c|h|hpp|kt|swift|cs|php|scala|clj|css|scss|sass|less))\s*$/.exec(cmd);
|
|
210771
211109
|
return m?.[1] ?? null;
|
|
210772
211110
|
}
|
|
210773
|
-
function
|
|
210774
|
-
const m = /^(cat|bat|type|Get-Content|gc)(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+))*\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/i.exec(cmd);
|
|
210775
|
-
if (!m) return null;
|
|
210776
|
-
const cmd0 = m[1];
|
|
210777
|
-
const filePath = m[2] ?? m[3] ?? m[4];
|
|
210778
|
-
if (filePath === void 0) return null;
|
|
211111
|
+
function classifyCatPath(filePath, cmd0) {
|
|
210779
211112
|
if (isTempPath(filePath)) return null;
|
|
210780
211113
|
const basename17 = (filePath.includes("/") ? filePath.split("/").at(-1) : filePath.split("\\").at(-1)) ?? filePath;
|
|
210781
211114
|
const isEnvFile = /^\.env(\.\w+)?$/i.test(basename17);
|
|
@@ -210787,6 +211120,25 @@ function extractCatFile(cmd) {
|
|
|
210787
211120
|
const isConfig = /\.(?:json|yaml|yml|toml|conf|cfg|ini|properties)$/i.test(filePath);
|
|
210788
211121
|
return { filePath, isDoc, isEnv, isConfig, isSql, cmd0 };
|
|
210789
211122
|
}
|
|
211123
|
+
function extractCatFile(cmd) {
|
|
211124
|
+
const m = /^(cat|bat|type|Get-Content|gc)(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+))*\s+(?:"([^"]+)"|'([^']+)'|(\S+?))(?:\s+-[a-zA-Z].*)?\s*$/i.exec(cmd);
|
|
211125
|
+
if (!m) return null;
|
|
211126
|
+
const cmd0 = m[1];
|
|
211127
|
+
const filePath = m[2] ?? m[3] ?? m[4];
|
|
211128
|
+
if (filePath === void 0) return null;
|
|
211129
|
+
return classifyCatPath(filePath, cmd0);
|
|
211130
|
+
}
|
|
211131
|
+
function extractCatFilesMulti(cmd) {
|
|
211132
|
+
if (/[|<>;&`]/.test(cmd) || cmd.includes("$(")) return null;
|
|
211133
|
+
const m = /^(cat|bat|type|Get-Content|gc)\s+(.+?)\s*$/i.exec(cmd);
|
|
211134
|
+
if (!m) return null;
|
|
211135
|
+
const cmd0 = m[1];
|
|
211136
|
+
const tokens = m[2].match(/"[^"]+"|'[^']+'|\S+/g) ?? [];
|
|
211137
|
+
const paths = tokens.filter((t) => !/^-/.test(t)).map((t) => t.replace(/^["']|["']$/g, ""));
|
|
211138
|
+
if (paths.length < 2) return null;
|
|
211139
|
+
const out2 = paths.map((p) => classifyCatPath(p, cmd0)).filter((r) => r !== null);
|
|
211140
|
+
return out2.length >= 2 ? out2 : null;
|
|
211141
|
+
}
|
|
210790
211142
|
var POWERSHELL_WRAP_RE = /^(?:powershell|pwsh)(?:\.exe)?(?:\s+-[a-zA-Z]+(?:\s+\S+)?)*\s+(?:-Command|-c|-EncodedCommand)\s+(?:"([^"]*)"|'([^']*)')\s*$/i;
|
|
210791
211143
|
var PS_GETCONTENT_INNER_RE = /^(?:Get-Content|gc|cat|type)(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+))*\s+(?:"([^"]+)"|'([^']+)'|(\S+?))(?:\s+-[a-zA-Z].*)?\s*$/i;
|
|
210792
211144
|
var PS_TEMP_READ_FLOOD_BYTES = 16 * 1024;
|
|
@@ -211443,7 +211795,7 @@ function preBashHandler(event) {
|
|
|
211443
211795
|
recordStat("session_hint", 0, 0);
|
|
211444
211796
|
const tail = n ?? 50;
|
|
211445
211797
|
return denyOutput(
|
|
211446
|
-
"Task output " + id + ' is a JSONL agent transcript on disk. Use `token-goat bash-output --file "' + outPath + '" --transcript` to read the assistant text, then narrow with `--grep PATTERN` or `--tail ' + tail + "`, instead of reading the whole file.
|
|
211798
|
+
"Task output " + id + ' is a JSONL agent transcript on disk. Use `token-goat bash-output --file "' + outPath + '" --transcript` to read the assistant text, then narrow with `--grep PATTERN` or `--tail ' + tail + '`, or read a specific line range (the only way to reach the MIDDLE of a large artifact) with `token-goat read "' + outPath + '@START-END"`, instead of reading the whole file.'
|
|
211447
211799
|
);
|
|
211448
211800
|
}
|
|
211449
211801
|
const findResult = extractFindCommand(cmd);
|
|
@@ -211513,6 +211865,18 @@ function preBashHandler(event) {
|
|
|
211513
211865
|
const hint = isEnv ? 'Use `token-goat config-get "' + hintPath + '" KEY_NAME` to read a specific variable.' : isConfig ? 'Use `token-goat config-get "' + hintPath + '" KEY_NAME` or `token-goat section "' + hintPath + '::sectionName"` to read a specific value.' : isDoc ? 'Use `token-goat section "' + hintPath + '::SectionHeading"` to read one section.' : 'Use `token-goat read "' + hintPath + '::SymbolName"` to read one function or class.';
|
|
211514
211866
|
return cdStripped ? contextOutput("`" + cmd0 + "` loads the entire file into context. " + hint) : denyOutput("`" + cmd0 + "` loads the entire file into context. " + hint);
|
|
211515
211867
|
}
|
|
211868
|
+
const catMulti = extractCatFilesMulti(cmd);
|
|
211869
|
+
if (catMulti !== null) {
|
|
211870
|
+
recordStat("session_hint", 0, 0);
|
|
211871
|
+
const cmd0 = catMulti[0].cmd0;
|
|
211872
|
+
const perPath = catMulti.map(({ filePath, isDoc, isEnv, isConfig, isSql }) => {
|
|
211873
|
+
const hintPath = cdStripped ? resolveCdHintPath(rawCmd, filePath, hintCwd) : filePath;
|
|
211874
|
+
const how = isSql ? 'token-goat section "' + hintPath + '::table_name"' : isEnv || isConfig ? 'token-goat config-get "' + hintPath + '" KEY_NAME' : isDoc ? 'token-goat section "' + hintPath + '::SectionHeading"' : 'token-goat read "' + hintPath + '::SymbolName"';
|
|
211875
|
+
return " " + hintPath + " -> `" + how + "`";
|
|
211876
|
+
});
|
|
211877
|
+
const msg = "`" + cmd0 + "` on multiple files loads them all into context. Read each surgically instead:\n" + perPath.join("\n");
|
|
211878
|
+
return cdStripped ? contextOutput(msg) : denyOutput(msg);
|
|
211879
|
+
}
|
|
211516
211880
|
const psGetContentResult = extractPowerShellWrappedGetContent(cmd);
|
|
211517
211881
|
if (psGetContentResult !== null) {
|
|
211518
211882
|
const { filePath, isDoc, isEnv, isConfig, isSql } = psGetContentResult;
|
|
@@ -211641,7 +212005,9 @@ function preBashHandler(event) {
|
|
|
211641
212005
|
const curlDl = extractCurlDownload(cmd);
|
|
211642
212006
|
if (curlDl !== null) {
|
|
211643
212007
|
const prevPath = getCurlDownloadPath(curlDl.url);
|
|
211644
|
-
if (prevPath !== null) {
|
|
212008
|
+
if (prevPath !== null && !existsSync16(resolveIndexPath(prevPath, preHookCwd ?? process.cwd()))) {
|
|
212009
|
+
clearCurlDownload(curlDl.url);
|
|
212010
|
+
} else if (prevPath !== null) {
|
|
211645
212011
|
recordStat("session_hint", 0, 0);
|
|
211646
212012
|
return denyOutput(
|
|
211647
212013
|
"Already downloaded to " + prevPath + " earlier this session. Use `rg '<pattern>' " + prevPath + '` to search it, or `token-goat read "' + prevPath + '::SectionName"` to read a part of it.'
|
|
@@ -211677,6 +212043,20 @@ function preBashHandler(event) {
|
|
|
211677
212043
|
);
|
|
211678
212044
|
}
|
|
211679
212045
|
}
|
|
212046
|
+
if (isScopedGitStatusOrDiffStatCommand(cmd)) {
|
|
212047
|
+
const gitScopedHash = shortFingerprint(stripOutputPipeline(cmd));
|
|
212048
|
+
const gitScopedOutputId = getBashOutputId(gitScopedHash);
|
|
212049
|
+
const gitScopedEntryRaw = gitScopedOutputId !== null ? getBashOutput(gitScopedOutputId) : null;
|
|
212050
|
+
const gitScopedEntry = gitScopedEntryRaw !== null && !isBashEntryStale(gitScopedEntryRaw, cmd, preHookCwd) ? gitScopedEntryRaw : null;
|
|
212051
|
+
if (gitScopedOutputId !== null && gitScopedEntry !== null) {
|
|
212052
|
+
const gitScopedBytes = gitScopedEntry.sizeBytes;
|
|
212053
|
+
recordStat("bash_compress:recall", gitScopedBytes, Math.round(gitScopedBytes / 4));
|
|
212054
|
+
const gitScopedPreview = cmd.length > 60 ? cmd.slice(0, 57) + "..." : cmd;
|
|
212055
|
+
return contextOutput(
|
|
212056
|
+
"Output from `" + gitScopedPreview + "`" + pipelineDivergenceNote(cmd, gitScopedEntry.command) + " is cached and unchanged (no edits to that path or HEAD since). Use `token-goat bash-output " + gitScopedOutputId + "` to recall it instead of re-running."
|
|
212057
|
+
);
|
|
212058
|
+
}
|
|
212059
|
+
}
|
|
211680
212060
|
const tgRead = extractTgSurgicalRead(cmd, preHookCwd);
|
|
211681
212061
|
if (tgRead !== null) {
|
|
211682
212062
|
const cliKey = tgRead.sub + "::" + tgRead.spec;
|
|
@@ -211804,6 +212184,11 @@ async function postBashHandler(event) {
|
|
|
211804
212184
|
recordStat("session_hint", 0, 0);
|
|
211805
212185
|
return contextOutput(buildGhViewBatchAdvisory(ghView.sub, ghView.ref));
|
|
211806
212186
|
}
|
|
212187
|
+
if (isScopedGitStatusOrDiffStatCommand(cmd) && (exitCode === null || exitCode === 0) && Buffer.byteLength(output, "utf-8") >= cacheMinBytes) {
|
|
212188
|
+
const gitScopedCacheHash = shortFingerprint(stripOutputPipeline(cmd));
|
|
212189
|
+
const gitScopedCacheId = await storeBashOutput(cmd, output, exitCode ?? 0, cwd);
|
|
212190
|
+
recordBashOutput(gitScopedCacheHash, gitScopedCacheId, Buffer.byteLength(output, "utf-8"));
|
|
212191
|
+
}
|
|
211807
212192
|
const isMonitoring = getMonitoringRecallHint(cmd) !== null;
|
|
211808
212193
|
if (!isMonitoring && !isBuildCommand(cmd) && !isCurlGetCommand(cmd)) return passOutput();
|
|
211809
212194
|
if (Buffer.byteLength(output, "utf-8") < cacheMinBytes) return passOutput();
|
|
@@ -212026,9 +212411,14 @@ function buildEvent(eventName, payload) {
|
|
|
212026
212411
|
const toolName = typeof rawToolName === "string" && rawToolName.trim() !== "" ? rawToolName : void 0;
|
|
212027
212412
|
const rawInput = obj["tool_input"];
|
|
212028
212413
|
const toolInput = typeof rawInput === "object" && rawInput !== null && !Array.isArray(rawInput) ? rawInput : {};
|
|
212029
|
-
const rawSession = obj["session_id"];
|
|
212414
|
+
const rawSession = obj["session_id"] ?? obj["sessionId"];
|
|
212030
212415
|
const sessionId = typeof rawSession === "string" ? rawSession : "";
|
|
212031
|
-
|
|
212416
|
+
const rawAgentId = obj["agent_id"] ?? obj["agentId"];
|
|
212417
|
+
const agentId = typeof rawAgentId === "string" && rawAgentId !== "" ? rawAgentId : void 0;
|
|
212418
|
+
return { eventName, toolName, toolInput, sessionId, agentId, raw: obj };
|
|
212419
|
+
}
|
|
212420
|
+
function sessionStateKey(event) {
|
|
212421
|
+
return event.agentId !== void 0 ? `${event.sessionId}:agent:${event.agentId}` : event.sessionId;
|
|
212032
212422
|
}
|
|
212033
212423
|
function harnessForNormalization() {
|
|
212034
212424
|
const detected = detectHarness();
|
|
@@ -212046,13 +212436,14 @@ async function relay(eventName) {
|
|
|
212046
212436
|
const rawPayload = await readStdinJson();
|
|
212047
212437
|
const payload = eventName === "pre_tool_use" || eventName === "post_tool_use" ? normalizePayload(rawPayload, harnessForNormalization()) : rawPayload;
|
|
212048
212438
|
const event = buildEvent(eventName, payload);
|
|
212439
|
+
const stateKey = sessionStateKey(event);
|
|
212049
212440
|
try {
|
|
212050
|
-
loadSessionState(
|
|
212441
|
+
loadSessionState(stateKey);
|
|
212051
212442
|
} catch {
|
|
212052
212443
|
}
|
|
212053
212444
|
const output = await runHook(event);
|
|
212054
212445
|
try {
|
|
212055
|
-
saveSessionState(
|
|
212446
|
+
saveSessionState(stateKey);
|
|
212056
212447
|
} catch {
|
|
212057
212448
|
}
|
|
212058
212449
|
process.stdout.write(serializeOutput(output, event.eventName));
|
|
@@ -212063,7 +212454,7 @@ async function relay(eventName) {
|
|
|
212063
212454
|
|
|
212064
212455
|
// src/bridges/gemini_install.ts
|
|
212065
212456
|
init_define_import_meta_env();
|
|
212066
|
-
import * as
|
|
212457
|
+
import * as fs26 from "node:fs";
|
|
212067
212458
|
import * as os8 from "node:os";
|
|
212068
212459
|
import * as path29 from "node:path";
|
|
212069
212460
|
var GEMINI_LEGACY_COMMAND_MARKER = "token-goat hook";
|
|
@@ -212083,7 +212474,7 @@ function geminiSettingsPath() {
|
|
|
212083
212474
|
function readGeminiSettings(p, opts = {}) {
|
|
212084
212475
|
let raw;
|
|
212085
212476
|
try {
|
|
212086
|
-
raw =
|
|
212477
|
+
raw = fs26.readFileSync(p, "utf8");
|
|
212087
212478
|
} catch {
|
|
212088
212479
|
return {};
|
|
212089
212480
|
}
|
|
@@ -212226,7 +212617,7 @@ function uninstallGemini() {
|
|
|
212226
212617
|
|
|
212227
212618
|
// src/bridges/pi_install.ts
|
|
212228
212619
|
init_define_import_meta_env();
|
|
212229
|
-
import * as
|
|
212620
|
+
import * as fs27 from "node:fs";
|
|
212230
212621
|
import * as os9 from "node:os";
|
|
212231
212622
|
import * as path30 from "node:path";
|
|
212232
212623
|
|
|
@@ -212505,7 +212896,7 @@ function installPi(opts = {}) {
|
|
|
212505
212896
|
const extensionPath = piExtensionPath(opts);
|
|
212506
212897
|
let existing;
|
|
212507
212898
|
try {
|
|
212508
|
-
existing =
|
|
212899
|
+
existing = fs27.readFileSync(extensionPath, "utf8");
|
|
212509
212900
|
} catch {
|
|
212510
212901
|
existing = void 0;
|
|
212511
212902
|
}
|
|
@@ -212524,11 +212915,11 @@ function installPi(opts = {}) {
|
|
|
212524
212915
|
function uninstallPi(opts = {}) {
|
|
212525
212916
|
const extensionPath = piExtensionPath(opts);
|
|
212526
212917
|
try {
|
|
212527
|
-
|
|
212918
|
+
fs27.unlinkSync(piEntrySidecarPath(opts));
|
|
212528
212919
|
} catch {
|
|
212529
212920
|
}
|
|
212530
212921
|
try {
|
|
212531
|
-
|
|
212922
|
+
fs27.unlinkSync(extensionPath);
|
|
212532
212923
|
return true;
|
|
212533
212924
|
} catch {
|
|
212534
212925
|
return false;
|
|
@@ -212537,7 +212928,7 @@ function uninstallPi(opts = {}) {
|
|
|
212537
212928
|
|
|
212538
212929
|
// src/bridges/opencode_install.ts
|
|
212539
212930
|
init_define_import_meta_env();
|
|
212540
|
-
import * as
|
|
212931
|
+
import * as fs28 from "node:fs";
|
|
212541
212932
|
import * as os10 from "node:os";
|
|
212542
212933
|
import * as path31 from "node:path";
|
|
212543
212934
|
|
|
@@ -212776,7 +213167,7 @@ function installOpencode() {
|
|
|
212776
213167
|
const pluginPath = opencodePluginPath();
|
|
212777
213168
|
let existing;
|
|
212778
213169
|
try {
|
|
212779
|
-
existing =
|
|
213170
|
+
existing = fs28.readFileSync(pluginPath, "utf8");
|
|
212780
213171
|
} catch {
|
|
212781
213172
|
existing = void 0;
|
|
212782
213173
|
}
|
|
@@ -212795,11 +213186,11 @@ function installOpencode() {
|
|
|
212795
213186
|
function uninstallOpencode() {
|
|
212796
213187
|
const pluginPath = opencodePluginPath();
|
|
212797
213188
|
try {
|
|
212798
|
-
|
|
213189
|
+
fs28.unlinkSync(opencodeEntrySidecarPath());
|
|
212799
213190
|
} catch {
|
|
212800
213191
|
}
|
|
212801
213192
|
try {
|
|
212802
|
-
|
|
213193
|
+
fs28.unlinkSync(pluginPath);
|
|
212803
213194
|
return true;
|
|
212804
213195
|
} catch {
|
|
212805
213196
|
return false;
|
|
@@ -212808,7 +213199,7 @@ function uninstallOpencode() {
|
|
|
212808
213199
|
|
|
212809
213200
|
// src/bridges/openclaw_install.ts
|
|
212810
213201
|
init_define_import_meta_env();
|
|
212811
|
-
import * as
|
|
213202
|
+
import * as fs29 from "node:fs";
|
|
212812
213203
|
import * as os11 from "node:os";
|
|
212813
213204
|
import * as path32 from "node:path";
|
|
212814
213205
|
|
|
@@ -213018,7 +213409,7 @@ function openclawEntrySidecarPath() {
|
|
|
213018
213409
|
function readOpenclawConfig(p, opts = {}) {
|
|
213019
213410
|
let raw;
|
|
213020
213411
|
try {
|
|
213021
|
-
raw =
|
|
213412
|
+
raw = fs29.readFileSync(p, "utf8");
|
|
213022
213413
|
} catch {
|
|
213023
213414
|
return {};
|
|
213024
213415
|
}
|
|
@@ -213048,7 +213439,7 @@ function installOpenclaw() {
|
|
|
213048
213439
|
const pluginPath = openclawPluginPath();
|
|
213049
213440
|
let existingPlugin;
|
|
213050
213441
|
try {
|
|
213051
|
-
existingPlugin =
|
|
213442
|
+
existingPlugin = fs29.readFileSync(pluginPath, "utf8");
|
|
213052
213443
|
} catch {
|
|
213053
213444
|
existingPlugin = void 0;
|
|
213054
213445
|
}
|
|
@@ -213092,12 +213483,12 @@ function uninstallOpenclaw() {
|
|
|
213092
213483
|
const pluginPath = openclawPluginPath();
|
|
213093
213484
|
let removed = false;
|
|
213094
213485
|
try {
|
|
213095
|
-
|
|
213486
|
+
fs29.unlinkSync(pluginPath);
|
|
213096
213487
|
removed = true;
|
|
213097
213488
|
} catch {
|
|
213098
213489
|
}
|
|
213099
213490
|
try {
|
|
213100
|
-
|
|
213491
|
+
fs29.unlinkSync(openclawEntrySidecarPath());
|
|
213101
213492
|
} catch {
|
|
213102
213493
|
}
|
|
213103
213494
|
const settings = readOpenclawConfig(configPath2);
|
|
@@ -237311,7 +237702,7 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
237311
237702
|
|
|
237312
237703
|
// src/read_commands.ts
|
|
237313
237704
|
init_define_import_meta_env();
|
|
237314
|
-
import * as
|
|
237705
|
+
import * as fs37 from "node:fs";
|
|
237315
237706
|
import * as path44 from "node:path";
|
|
237316
237707
|
|
|
237317
237708
|
// src/section_reader.ts
|
|
@@ -237632,7 +238023,7 @@ function getHintFor(command2) {
|
|
|
237632
238023
|
|
|
237633
238024
|
// src/graph_commands.ts
|
|
237634
238025
|
init_define_import_meta_env();
|
|
237635
|
-
import * as
|
|
238026
|
+
import * as fs30 from "node:fs";
|
|
237636
238027
|
import * as os12 from "node:os";
|
|
237637
238028
|
import * as path33 from "node:path";
|
|
237638
238029
|
import { execFileSync, spawnSync as spawnSync2 } from "node:child_process";
|
|
@@ -237858,7 +238249,7 @@ var SOURCE_EXTENSIONS = [
|
|
|
237858
238249
|
function runDeps(opts) {
|
|
237859
238250
|
let text;
|
|
237860
238251
|
try {
|
|
237861
|
-
text =
|
|
238252
|
+
text = fs30.readFileSync(opts.file, "utf-8");
|
|
237862
238253
|
} catch {
|
|
237863
238254
|
emitErr(`Could not read: ${opts.file}`);
|
|
237864
238255
|
return 1;
|
|
@@ -237872,12 +238263,12 @@ function runDeps(opts) {
|
|
|
237872
238263
|
if (imp.startsWith("./") || imp.startsWith("../")) {
|
|
237873
238264
|
const base = path33.resolve(dir, imp);
|
|
237874
238265
|
let resolved = imp;
|
|
237875
|
-
if (
|
|
238266
|
+
if (fs30.existsSync(base) && fs30.statSync(base).isFile()) {
|
|
237876
238267
|
resolved = base;
|
|
237877
238268
|
} else {
|
|
237878
238269
|
for (const srcExt of SOURCE_EXTENSIONS) {
|
|
237879
238270
|
const candidate = base + srcExt;
|
|
237880
|
-
if (
|
|
238271
|
+
if (fs30.existsSync(candidate)) {
|
|
237881
238272
|
resolved = candidate;
|
|
237882
238273
|
break;
|
|
237883
238274
|
}
|
|
@@ -238121,7 +238512,7 @@ function runArch(opts) {
|
|
|
238121
238512
|
for (const file2 of files) {
|
|
238122
238513
|
let text;
|
|
238123
238514
|
try {
|
|
238124
|
-
text =
|
|
238515
|
+
text = fs30.readFileSync(file2, "utf8");
|
|
238125
238516
|
} catch {
|
|
238126
238517
|
continue;
|
|
238127
238518
|
}
|
|
@@ -238247,7 +238638,7 @@ ANSWER:`;
|
|
|
238247
238638
|
if (result.status === 0) {
|
|
238248
238639
|
if (codexOutPath) {
|
|
238249
238640
|
try {
|
|
238250
|
-
answer =
|
|
238641
|
+
answer = fs30.readFileSync(codexOutPath, "utf8").trim();
|
|
238251
238642
|
} catch {
|
|
238252
238643
|
}
|
|
238253
238644
|
} else {
|
|
@@ -238266,7 +238657,7 @@ ANSWER:`;
|
|
|
238266
238657
|
} finally {
|
|
238267
238658
|
if (codexOutPath) {
|
|
238268
238659
|
try {
|
|
238269
|
-
|
|
238660
|
+
fs30.unlinkSync(codexOutPath);
|
|
238270
238661
|
} catch {
|
|
238271
238662
|
}
|
|
238272
238663
|
}
|
|
@@ -240264,7 +240655,7 @@ async function extractPdfMeta(data) {
|
|
|
240264
240655
|
|
|
240265
240656
|
// src/screenshot.ts
|
|
240266
240657
|
init_define_import_meta_env();
|
|
240267
|
-
import
|
|
240658
|
+
import fs36 from "node:fs";
|
|
240268
240659
|
import path43 from "node:path";
|
|
240269
240660
|
var _puppeteerCache;
|
|
240270
240661
|
async function loadPuppeteer() {
|
|
@@ -240283,7 +240674,7 @@ var PLAYWRIGHT_CHROME_SUBDIRS = ["chrome-win64", "chrome-win"];
|
|
|
240283
240674
|
function findPlaywrightChromium(msPlaywrightDir) {
|
|
240284
240675
|
let entries;
|
|
240285
240676
|
try {
|
|
240286
|
-
entries =
|
|
240677
|
+
entries = fs36.readdirSync(msPlaywrightDir);
|
|
240287
240678
|
} catch {
|
|
240288
240679
|
return [];
|
|
240289
240680
|
}
|
|
@@ -240322,13 +240713,13 @@ function platformCandidatePaths() {
|
|
|
240322
240713
|
return candidates;
|
|
240323
240714
|
}
|
|
240324
240715
|
function resolveBrowserExecutablePath(explicit) {
|
|
240325
|
-
if (explicit &&
|
|
240716
|
+
if (explicit && fs36.existsSync(explicit)) return explicit;
|
|
240326
240717
|
const cfgPath = loadConfig().screenshot.chrome_path;
|
|
240327
|
-
if (cfgPath &&
|
|
240718
|
+
if (cfgPath && fs36.existsSync(cfgPath)) return cfgPath;
|
|
240328
240719
|
const envPath = process.env["TOKEN_GOAT_CHROME_PATH"];
|
|
240329
|
-
if (envPath &&
|
|
240720
|
+
if (envPath && fs36.existsSync(envPath)) return envPath;
|
|
240330
240721
|
for (const candidate of platformCandidatePaths()) {
|
|
240331
|
-
if (
|
|
240722
|
+
if (fs36.existsSync(candidate)) return candidate;
|
|
240332
240723
|
}
|
|
240333
240724
|
return null;
|
|
240334
240725
|
}
|
|
@@ -240364,7 +240755,7 @@ var GREP_MAX_LINES = 200;
|
|
|
240364
240755
|
var FIND_SCAN_LIMIT = 2e4;
|
|
240365
240756
|
function fileExists(p) {
|
|
240366
240757
|
try {
|
|
240367
|
-
|
|
240758
|
+
fs37.statSync(p);
|
|
240368
240759
|
return true;
|
|
240369
240760
|
} catch {
|
|
240370
240761
|
return false;
|
|
@@ -240372,7 +240763,7 @@ function fileExists(p) {
|
|
|
240372
240763
|
}
|
|
240373
240764
|
function readFileText(p) {
|
|
240374
240765
|
try {
|
|
240375
|
-
return
|
|
240766
|
+
return fs37.readFileSync(p, "utf-8");
|
|
240376
240767
|
} catch {
|
|
240377
240768
|
return null;
|
|
240378
240769
|
}
|
|
@@ -240443,7 +240834,7 @@ function runSymbol(opts) {
|
|
|
240443
240834
|
return preview.trim() !== "" ? `${header}
|
|
240444
240835
|
${preview}` : header;
|
|
240445
240836
|
});
|
|
240446
|
-
return { text: blocks.join("\n\n"), code: 0 };
|
|
240837
|
+
return { text: guardText(blocks.join("\n\n"), "symbol"), code: 0 };
|
|
240447
240838
|
}
|
|
240448
240839
|
function parseReadSpec(spec) {
|
|
240449
240840
|
const colonIdx = findSpecSeparator(spec);
|
|
@@ -240662,6 +241053,7 @@ function runRefs(opts) {
|
|
|
240662
241053
|
if (symbols.length <= 1) return runRefsSingle(opts);
|
|
240663
241054
|
const jsonOut = {};
|
|
240664
241055
|
let anyFound = false;
|
|
241056
|
+
const lines = [];
|
|
240665
241057
|
for (const sym of symbols) {
|
|
240666
241058
|
const queryOpts = { name: sym };
|
|
240667
241059
|
if (file2 !== void 0 && opts.callers !== true) queryOpts.filePath = resolveIndexPath(file2);
|
|
@@ -240673,17 +241065,21 @@ function runRefs(opts) {
|
|
|
240673
241065
|
continue;
|
|
240674
241066
|
}
|
|
240675
241067
|
if (results.length === 0) {
|
|
240676
|
-
|
|
241068
|
+
lines.push(`${sym}: (no references found)`);
|
|
240677
241069
|
continue;
|
|
240678
241070
|
}
|
|
240679
|
-
|
|
241071
|
+
lines.push(`${sym}:`);
|
|
240680
241072
|
if (opts.callers === true) {
|
|
240681
|
-
|
|
241073
|
+
lines.push(...renderCallerGroups(results));
|
|
240682
241074
|
} else {
|
|
240683
|
-
for (const ref of results)
|
|
241075
|
+
for (const ref of results) lines.push(` ${ref.filePath}:${ref.line}: ${ref.context}`);
|
|
240684
241076
|
}
|
|
240685
241077
|
}
|
|
240686
|
-
if (opts.json === true)
|
|
241078
|
+
if (opts.json === true) {
|
|
241079
|
+
emit3(JSON.stringify(jsonOut, null, 2));
|
|
241080
|
+
return anyFound ? 0 : 1;
|
|
241081
|
+
}
|
|
241082
|
+
emitGuarded(lines.join("\n"), "symbol");
|
|
240687
241083
|
return anyFound ? 0 : 1;
|
|
240688
241084
|
}
|
|
240689
241085
|
function runRefsSingle(opts) {
|
|
@@ -240701,16 +241097,11 @@ function runRefsSingle(opts) {
|
|
|
240701
241097
|
emit3(JSON.stringify(results, null, 2));
|
|
240702
241098
|
return 0;
|
|
240703
241099
|
}
|
|
240704
|
-
|
|
240705
|
-
|
|
240706
|
-
} else {
|
|
240707
|
-
for (const ref of results) {
|
|
240708
|
-
emit3(`${ref.filePath}:${ref.line}: ${ref.context}`);
|
|
240709
|
-
}
|
|
240710
|
-
}
|
|
241100
|
+
const lines = opts.callers === true ? renderCallerGroups(results) : results.map((ref) => `${ref.filePath}:${ref.line}: ${ref.context}`);
|
|
241101
|
+
emitGuarded(lines.join("\n"), "symbol");
|
|
240711
241102
|
return 0;
|
|
240712
241103
|
}
|
|
240713
|
-
function
|
|
241104
|
+
function renderCallerGroups(refs) {
|
|
240714
241105
|
const byFile = /* @__PURE__ */ new Map();
|
|
240715
241106
|
for (const ref of refs) {
|
|
240716
241107
|
const bucket = byFile.get(ref.filePath);
|
|
@@ -240720,12 +241111,14 @@ function emitCallerGroups(refs) {
|
|
|
240720
241111
|
byFile.set(ref.filePath, [ref]);
|
|
240721
241112
|
}
|
|
240722
241113
|
}
|
|
241114
|
+
const lines = [];
|
|
240723
241115
|
for (const [file2, fileRefs] of byFile) {
|
|
240724
|
-
|
|
241116
|
+
lines.push(`${file2}:`);
|
|
240725
241117
|
for (const ref of fileRefs) {
|
|
240726
|
-
|
|
241118
|
+
lines.push(` :${ref.line} ${ref.context !== "" ? ref.context : "(module scope)"}`);
|
|
240727
241119
|
}
|
|
240728
241120
|
}
|
|
241121
|
+
return lines;
|
|
240729
241122
|
}
|
|
240730
241123
|
function runSkeleton(opts) {
|
|
240731
241124
|
const resolved = resolveIndexPath(opts.file);
|
|
@@ -240761,7 +241154,7 @@ function runSkeleton(opts) {
|
|
|
240761
241154
|
const statsStr = refCounts !== void 0 ? ` [${refCounts.get(sym.name) ?? 0} refs, ${sym.docstring.trim().length > 0 ? "documented" : "undocumented"}]` : "";
|
|
240762
241155
|
lines.push(` ${lineStr} ${sym.kind.padEnd(10)} ${sym.name} ${firstBodyLine(sym.body)}${statsStr}`);
|
|
240763
241156
|
}
|
|
240764
|
-
return { text: lines.join("\n"), code: 0 };
|
|
241157
|
+
return { text: guardText(lines.join("\n"), "symbol"), code: 0 };
|
|
240765
241158
|
}
|
|
240766
241159
|
function runOutline(opts) {
|
|
240767
241160
|
const resolved = resolveIndexPath(opts.file);
|
|
@@ -240797,7 +241190,7 @@ function runOutline(opts) {
|
|
|
240797
241190
|
const statsStr = refCounts !== void 0 ? ` [${refCounts.get(sym.name) ?? 0} refs, ${sym.docstring.trim().length > 0 ? "documented" : "undocumented"}]` : "";
|
|
240798
241191
|
lines.push(` ${rangeStr} ${kindStr} ${sym.name} (${bodyLen}\u2113)${docFirst}${statsStr}`);
|
|
240799
241192
|
}
|
|
240800
|
-
return { text: lines.join("\n"), code: 0 };
|
|
241193
|
+
return { text: guardText(lines.join("\n"), "symbol"), code: 0 };
|
|
240801
241194
|
}
|
|
240802
241195
|
function runCsvQuery(opts) {
|
|
240803
241196
|
const text = readFileText(opts.file);
|
|
@@ -240849,7 +241242,7 @@ async function runPdfExtractText(file2, pagesSpec, layout = false) {
|
|
|
240849
241242
|
if (!fileExists(file2)) {
|
|
240850
241243
|
throw new Error(`Could not read: ${file2}`);
|
|
240851
241244
|
}
|
|
240852
|
-
const data =
|
|
241245
|
+
const data = fs37.readFileSync(file2);
|
|
240853
241246
|
const result = await extractPdfText(new Uint8Array(data), pagesSpec, layout);
|
|
240854
241247
|
return result.text;
|
|
240855
241248
|
}
|
|
@@ -240857,14 +241250,14 @@ async function runPdfOutline(file2) {
|
|
|
240857
241250
|
if (!fileExists(file2)) {
|
|
240858
241251
|
throw new Error(`Could not read: ${file2}`);
|
|
240859
241252
|
}
|
|
240860
|
-
const data =
|
|
241253
|
+
const data = fs37.readFileSync(file2);
|
|
240861
241254
|
return extractPdfOutline(new Uint8Array(data));
|
|
240862
241255
|
}
|
|
240863
241256
|
async function runPdfMeta(file2) {
|
|
240864
241257
|
if (!fileExists(file2)) {
|
|
240865
241258
|
throw new Error(`Could not read: ${file2}`);
|
|
240866
241259
|
}
|
|
240867
|
-
const data =
|
|
241260
|
+
const data = fs37.readFileSync(file2);
|
|
240868
241261
|
return extractPdfMeta(new Uint8Array(data));
|
|
240869
241262
|
}
|
|
240870
241263
|
async function runScreenshot(url2, destPath, opts) {
|
|
@@ -241064,7 +241457,7 @@ function runGrep(opts) {
|
|
|
241064
241457
|
const hits = [];
|
|
241065
241458
|
function searchFile(filePath) {
|
|
241066
241459
|
try {
|
|
241067
|
-
const text =
|
|
241460
|
+
const text = fs37.readFileSync(filePath, "utf-8");
|
|
241068
241461
|
const lines = text.split(/\r?\n/);
|
|
241069
241462
|
lines.forEach((lineText, idx) => {
|
|
241070
241463
|
if (regex.test(lineText)) {
|
|
@@ -241085,10 +241478,10 @@ function runGrep(opts) {
|
|
|
241085
241478
|
}
|
|
241086
241479
|
function searchDir(dir) {
|
|
241087
241480
|
try {
|
|
241088
|
-
for (const entry of
|
|
241481
|
+
for (const entry of fs37.readdirSync(dir)) {
|
|
241089
241482
|
if (entry.startsWith(".")) continue;
|
|
241090
241483
|
const full = path44.join(dir, entry);
|
|
241091
|
-
const stat2 =
|
|
241484
|
+
const stat2 = fs37.statSync(full);
|
|
241092
241485
|
if (stat2.isDirectory()) {
|
|
241093
241486
|
if (SKIP_DIRS.has(entry)) continue;
|
|
241094
241487
|
if (opts.recursive !== false) searchDir(full);
|
|
@@ -241104,7 +241497,7 @@ function runGrep(opts) {
|
|
|
241104
241497
|
emitErr2(`Path not found: ${searchPath}`);
|
|
241105
241498
|
return 1;
|
|
241106
241499
|
}
|
|
241107
|
-
const stat2 =
|
|
241500
|
+
const stat2 = fs37.statSync(searchPath);
|
|
241108
241501
|
if (stat2.isDirectory()) {
|
|
241109
241502
|
searchDir(searchPath);
|
|
241110
241503
|
} else {
|
|
@@ -241138,7 +241531,7 @@ function runGrep(opts) {
|
|
|
241138
241531
|
}
|
|
241139
241532
|
return 0;
|
|
241140
241533
|
}
|
|
241141
|
-
function
|
|
241534
|
+
function escapeRegExp3(s) {
|
|
241142
241535
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
241143
241536
|
}
|
|
241144
241537
|
function lookupYaml(lines, key) {
|
|
@@ -241237,7 +241630,7 @@ function runConfigGet(opts) {
|
|
|
241237
241630
|
if (currentSection !== (sectionPath ?? "")) {
|
|
241238
241631
|
continue;
|
|
241239
241632
|
}
|
|
241240
|
-
if (new RegExp(`^${
|
|
241633
|
+
if (new RegExp(`^${escapeRegExp3(leafKey)}\\s*=`).test(trimmed)) {
|
|
241241
241634
|
const eqIdx = trimmed.indexOf("=");
|
|
241242
241635
|
emit3(trimmed.slice(eqIdx + 1).trim().replace(/^["']|["']$/g, ""));
|
|
241243
241636
|
return 0;
|
|
@@ -241923,7 +242316,7 @@ init_define_import_meta_env();
|
|
|
241923
242316
|
|
|
241924
242317
|
// src/ooxml_extract.ts
|
|
241925
242318
|
init_define_import_meta_env();
|
|
241926
|
-
import * as
|
|
242319
|
+
import * as fs38 from "node:fs";
|
|
241927
242320
|
var _fflateCache;
|
|
241928
242321
|
var _fxpCache;
|
|
241929
242322
|
async function loadFflate() {
|
|
@@ -241952,11 +242345,11 @@ var MAX_OOXML_INPUT_BYTES = 50 * 1024 * 1024;
|
|
|
241952
242345
|
async function readOoxmlZip(filePath) {
|
|
241953
242346
|
const fflate = await loadFflate();
|
|
241954
242347
|
if (!fflate) throw new Error("fflate is not installed; run `npm install fflate` to enable this command");
|
|
241955
|
-
const size =
|
|
242348
|
+
const size = fs38.statSync(filePath).size;
|
|
241956
242349
|
if (size > MAX_OOXML_INPUT_BYTES) {
|
|
241957
242350
|
throw new Error(`${filePath} is ${Math.round(size / (1024 * 1024))}MB, over the ${MAX_OOXML_INPUT_BYTES / (1024 * 1024)}MB limit for OOXML files`);
|
|
241958
242351
|
}
|
|
241959
|
-
const data =
|
|
242352
|
+
const data = fs38.readFileSync(filePath);
|
|
241960
242353
|
return fflate.unzipSync(new Uint8Array(data));
|
|
241961
242354
|
}
|
|
241962
242355
|
function decodeZipEntry(entries, path56) {
|
|
@@ -242216,7 +242609,7 @@ async function docxText(filePath) {
|
|
|
242216
242609
|
|
|
242217
242610
|
// src/sharepoint_resolve.ts
|
|
242218
242611
|
init_define_import_meta_env();
|
|
242219
|
-
import * as
|
|
242612
|
+
import * as fs39 from "node:fs";
|
|
242220
242613
|
import * as os20 from "node:os";
|
|
242221
242614
|
import * as path45 from "node:path";
|
|
242222
242615
|
var TENANT_HOST_RE = /^([a-z0-9-]+?)(-my)?\.sharepoint\.com$/i;
|
|
@@ -242265,7 +242658,7 @@ function candidateRoots(env2, home) {
|
|
|
242265
242658
|
if (commercial !== void 0) roots.push(commercial);
|
|
242266
242659
|
if (personal !== void 0 && personal !== commercial) roots.push(personal);
|
|
242267
242660
|
try {
|
|
242268
|
-
for (const entry of
|
|
242661
|
+
for (const entry of fs39.readdirSync(home, { withFileTypes: true })) {
|
|
242269
242662
|
if (entry.isDirectory() && /onedrive/i.test(entry.name)) {
|
|
242270
242663
|
const full = path45.join(home, entry.name);
|
|
242271
242664
|
if (!roots.includes(full)) roots.push(full);
|
|
@@ -242282,29 +242675,29 @@ function resolveLocalPath(parsed, env2 = process.env, home = os20.homedir()) {
|
|
|
242282
242675
|
for (const root of roots) {
|
|
242283
242676
|
const rawJoined = path45.join(root, ...libSegments);
|
|
242284
242677
|
triedPaths.push(rawJoined);
|
|
242285
|
-
if (
|
|
242678
|
+
if (fs39.existsSync(rawJoined)) return { resolvedPath: rawJoined, triedPaths };
|
|
242286
242679
|
if (libSegments.length > 0) {
|
|
242287
242680
|
const aliasedFirst = normalizeLibrarySegment(libSegments[0]);
|
|
242288
242681
|
if (aliasedFirst !== libSegments[0]) {
|
|
242289
242682
|
const aliasedJoined = path45.join(root, aliasedFirst, ...libSegments.slice(1));
|
|
242290
242683
|
triedPaths.push(aliasedJoined);
|
|
242291
|
-
if (
|
|
242684
|
+
if (fs39.existsSync(aliasedJoined)) return { resolvedPath: aliasedJoined, triedPaths };
|
|
242292
242685
|
}
|
|
242293
242686
|
}
|
|
242294
242687
|
if (parsed.siteType === "site" && parsed.siteName.length > 0) {
|
|
242295
242688
|
try {
|
|
242296
|
-
for (const entry of
|
|
242689
|
+
for (const entry of fs39.readdirSync(root, { withFileTypes: true })) {
|
|
242297
242690
|
if (!entry.isDirectory() || !entry.name.toLowerCase().includes(parsed.siteName.toLowerCase())) continue;
|
|
242298
242691
|
const siteRoot = path45.join(root, entry.name);
|
|
242299
242692
|
const siteJoined = path45.join(siteRoot, ...libSegments);
|
|
242300
242693
|
triedPaths.push(siteJoined);
|
|
242301
|
-
if (
|
|
242694
|
+
if (fs39.existsSync(siteJoined)) return { resolvedPath: siteJoined, triedPaths };
|
|
242302
242695
|
if (libSegments.length > 0) {
|
|
242303
242696
|
const aliasedFirst = normalizeLibrarySegment(libSegments[0]);
|
|
242304
242697
|
if (aliasedFirst !== libSegments[0]) {
|
|
242305
242698
|
const siteAliasedJoined = path45.join(siteRoot, aliasedFirst, ...libSegments.slice(1));
|
|
242306
242699
|
triedPaths.push(siteAliasedJoined);
|
|
242307
|
-
if (
|
|
242700
|
+
if (fs39.existsSync(siteAliasedJoined)) return { resolvedPath: siteAliasedJoined, triedPaths };
|
|
242308
242701
|
}
|
|
242309
242702
|
}
|
|
242310
242703
|
}
|
|
@@ -242365,7 +242758,7 @@ function extractVideoChapters(file2) {
|
|
|
242365
242758
|
|
|
242366
242759
|
// src/transcript_extract.ts
|
|
242367
242760
|
init_define_import_meta_env();
|
|
242368
|
-
import * as
|
|
242761
|
+
import * as fs40 from "node:fs";
|
|
242369
242762
|
var TIMESTAMP_RE = /(\d{1,2}:)?(\d{2}):(\d{2})[.,](\d{1,3})/;
|
|
242370
242763
|
var CUE_LINE_RE = new RegExp(`^\\s*${TIMESTAMP_RE.source}\\s*-->\\s*${TIMESTAMP_RE.source}`);
|
|
242371
242764
|
var V_TAG_RE = /^<v(?:\.\w+)?\s+([^>]+)>\s*(.*)$/;
|
|
@@ -242417,7 +242810,7 @@ function parseTranscript(content) {
|
|
|
242417
242810
|
return cues;
|
|
242418
242811
|
}
|
|
242419
242812
|
function readTranscript(filePath) {
|
|
242420
|
-
const content =
|
|
242813
|
+
const content = fs40.readFileSync(filePath, "utf8");
|
|
242421
242814
|
return parseTranscript(content);
|
|
242422
242815
|
}
|
|
242423
242816
|
function formatTimestamp(seconds) {
|
|
@@ -242477,7 +242870,7 @@ function formatCues(cues) {
|
|
|
242477
242870
|
|
|
242478
242871
|
// src/cli_stats.ts
|
|
242479
242872
|
init_define_import_meta_env();
|
|
242480
|
-
import * as
|
|
242873
|
+
import * as fs41 from "node:fs";
|
|
242481
242874
|
import * as path46 from "node:path";
|
|
242482
242875
|
function writeRaw(text) {
|
|
242483
242876
|
process.stdout.write(ensureNewline(text));
|
|
@@ -242501,11 +242894,11 @@ function renderTopSessionFiles(topN = 5) {
|
|
|
242501
242894
|
function renderTopSessionFilesFromDisk(topN = 5, overrideSessionsDir) {
|
|
242502
242895
|
try {
|
|
242503
242896
|
const sessionsDir = overrideSessionsDir ?? path46.join(dataDir(), "sessions");
|
|
242504
|
-
if (!
|
|
242505
|
-
const files =
|
|
242897
|
+
if (!fs41.existsSync(sessionsDir)) return "";
|
|
242898
|
+
const files = fs41.readdirSync(sessionsDir).filter((f) => f.endsWith(".json")).map((f) => ({ name: f, mtime: fs41.statSync(path46.join(sessionsDir, f)).mtimeMs })).sort((a, b) => b.mtime - a.mtime).slice(0, 3);
|
|
242506
242899
|
for (const { name: name2 } of files) {
|
|
242507
242900
|
try {
|
|
242508
|
-
const raw =
|
|
242901
|
+
const raw = fs41.readFileSync(path46.join(sessionsDir, name2), "utf-8");
|
|
242509
242902
|
const data = JSON.parse(raw);
|
|
242510
242903
|
const filesList = data["files"];
|
|
242511
242904
|
if (!Array.isArray(filesList)) continue;
|
|
@@ -242560,19 +242953,19 @@ function runStats(opts = {}) {
|
|
|
242560
242953
|
|
|
242561
242954
|
// src/cli_doctor.ts
|
|
242562
242955
|
init_define_import_meta_env();
|
|
242563
|
-
import * as
|
|
242956
|
+
import * as fs44 from "fs";
|
|
242564
242957
|
import * as path49 from "path";
|
|
242565
242958
|
import { execSync, spawnSync as spawnSync6 } from "child_process";
|
|
242566
242959
|
|
|
242567
242960
|
// src/cli_context_stats.ts
|
|
242568
242961
|
init_define_import_meta_env();
|
|
242569
|
-
import * as
|
|
242962
|
+
import * as fs43 from "node:fs";
|
|
242570
242963
|
import * as os21 from "node:os";
|
|
242571
242964
|
import * as path48 from "node:path";
|
|
242572
242965
|
|
|
242573
242966
|
// src/memory_prune.ts
|
|
242574
242967
|
init_define_import_meta_env();
|
|
242575
|
-
import * as
|
|
242968
|
+
import * as fs42 from "node:fs";
|
|
242576
242969
|
import * as path47 from "node:path";
|
|
242577
242970
|
var ENTRY_RE = /^\s*-\s*\[(?<title>[^\]]+)\]\((?<target>[^)]+?\.md)\)/;
|
|
242578
242971
|
function parseIndex(text) {
|
|
@@ -242620,7 +243013,7 @@ function pruneIndex(memoryDir, opts) {
|
|
|
242620
243013
|
const memoryMd = path47.join(memoryDir, "MEMORY.md");
|
|
242621
243014
|
let text;
|
|
242622
243015
|
try {
|
|
242623
|
-
text =
|
|
243016
|
+
text = fs42.readFileSync(memoryMd, "utf-8");
|
|
242624
243017
|
} catch {
|
|
242625
243018
|
return result;
|
|
242626
243019
|
}
|
|
@@ -242632,7 +243025,7 @@ function pruneIndex(memoryDir, opts) {
|
|
|
242632
243025
|
for (const entry of entries) {
|
|
242633
243026
|
const targetPath = path47.join(memoryDir, entry.target);
|
|
242634
243027
|
const foldedTarget = foldPath(entry.target);
|
|
242635
|
-
if (!
|
|
243028
|
+
if (!fs42.existsSync(targetPath)) {
|
|
242636
243029
|
dead.push(entry);
|
|
242637
243030
|
} else if (seenTargets.has(foldedTarget)) {
|
|
242638
243031
|
dups.push(entry);
|
|
@@ -242672,7 +243065,7 @@ function pruneIndex(memoryDir, opts) {
|
|
|
242672
243065
|
// src/cli_context_stats.ts
|
|
242673
243066
|
function tok(filePath) {
|
|
242674
243067
|
try {
|
|
242675
|
-
const size =
|
|
243068
|
+
const size = fs43.statSync(filePath).size;
|
|
242676
243069
|
return Math.floor(size / 4);
|
|
242677
243070
|
} catch {
|
|
242678
243071
|
return 0;
|
|
@@ -242684,7 +243077,7 @@ function findClaudeMdFiles(projectRoot) {
|
|
|
242684
243077
|
let current = path48.resolve(projectRoot);
|
|
242685
243078
|
while (true) {
|
|
242686
243079
|
const candidate = path48.join(current, "CLAUDE.md");
|
|
242687
|
-
if (!seen.has(candidate) &&
|
|
243080
|
+
if (!seen.has(candidate) && fs43.existsSync(candidate)) {
|
|
242688
243081
|
found.push(candidate);
|
|
242689
243082
|
seen.add(candidate);
|
|
242690
243083
|
}
|
|
@@ -242693,7 +243086,7 @@ function findClaudeMdFiles(projectRoot) {
|
|
|
242693
243086
|
current = parent;
|
|
242694
243087
|
}
|
|
242695
243088
|
const globalMd = path48.join(os21.homedir(), ".claude", "CLAUDE.md");
|
|
242696
|
-
if (!seen.has(globalMd) &&
|
|
243089
|
+
if (!seen.has(globalMd) && fs43.existsSync(globalMd)) {
|
|
242697
243090
|
found.push(globalMd);
|
|
242698
243091
|
}
|
|
242699
243092
|
return found;
|
|
@@ -242701,11 +243094,11 @@ function findClaudeMdFiles(projectRoot) {
|
|
|
242701
243094
|
function findMemoryMd(projectRoot) {
|
|
242702
243095
|
try {
|
|
242703
243096
|
const projectsDir = path48.join(os21.homedir(), ".claude", "projects");
|
|
242704
|
-
if (!
|
|
243097
|
+
if (!fs43.existsSync(projectsDir)) return null;
|
|
242705
243098
|
const rootStr = path48.resolve(projectRoot);
|
|
242706
243099
|
const expectedSlug = rootStr.replace(/[^A-Za-z0-9]/g, "-");
|
|
242707
243100
|
const candidate = path48.join(projectsDir, expectedSlug, "memory", "MEMORY.md");
|
|
242708
|
-
if (
|
|
243101
|
+
if (fs43.existsSync(candidate)) return candidate;
|
|
242709
243102
|
return null;
|
|
242710
243103
|
} catch {
|
|
242711
243104
|
return null;
|
|
@@ -242804,24 +243197,24 @@ function checkWorkerRunning() {
|
|
|
242804
243197
|
}
|
|
242805
243198
|
function checkDbExists(dataDir2) {
|
|
242806
243199
|
const dbPath = path49.join(dataDir2, "global.db");
|
|
242807
|
-
if (!
|
|
243200
|
+
if (!fs44.existsSync(dbPath)) {
|
|
242808
243201
|
return {
|
|
242809
243202
|
name: "Database",
|
|
242810
243203
|
status: "warn",
|
|
242811
243204
|
message: `global.db not found at ${dbPath}`
|
|
242812
243205
|
};
|
|
242813
243206
|
}
|
|
242814
|
-
const sizeBytes =
|
|
243207
|
+
const sizeBytes = fs44.statSync(dbPath).size;
|
|
242815
243208
|
const SQLITE_HEADER = "SQLite format 3\0";
|
|
242816
243209
|
let header = "";
|
|
242817
243210
|
try {
|
|
242818
|
-
const fd2 =
|
|
243211
|
+
const fd2 = fs44.openSync(dbPath, "r");
|
|
242819
243212
|
try {
|
|
242820
243213
|
const buf = Buffer.alloc(SQLITE_HEADER.length);
|
|
242821
|
-
const bytesRead =
|
|
243214
|
+
const bytesRead = fs44.readSync(fd2, buf, 0, buf.length, 0);
|
|
242822
243215
|
header = buf.toString("latin1", 0, bytesRead);
|
|
242823
243216
|
} finally {
|
|
242824
|
-
|
|
243217
|
+
fs44.closeSync(fd2);
|
|
242825
243218
|
}
|
|
242826
243219
|
} catch {
|
|
242827
243220
|
}
|
|
@@ -242855,7 +243248,7 @@ function checkInstall() {
|
|
|
242855
243248
|
}
|
|
242856
243249
|
}
|
|
242857
243250
|
function checkConfigValid(configPath2) {
|
|
242858
|
-
if (!
|
|
243251
|
+
if (!fs44.existsSync(configPath2)) {
|
|
242859
243252
|
return {
|
|
242860
243253
|
name: "Config",
|
|
242861
243254
|
status: "warn",
|
|
@@ -242863,7 +243256,7 @@ function checkConfigValid(configPath2) {
|
|
|
242863
243256
|
};
|
|
242864
243257
|
}
|
|
242865
243258
|
try {
|
|
242866
|
-
const content =
|
|
243259
|
+
const content = fs44.readFileSync(configPath2, "utf-8");
|
|
242867
243260
|
parse(content);
|
|
242868
243261
|
return {
|
|
242869
243262
|
name: "Config",
|
|
@@ -242889,9 +243282,9 @@ function formatDiskSpace(bytes) {
|
|
|
242889
243282
|
return `${value.toFixed(1)} ${units[unitIndex]}`;
|
|
242890
243283
|
}
|
|
242891
243284
|
function checkDiskSpace(dataDir2) {
|
|
242892
|
-
if (typeof
|
|
243285
|
+
if (typeof fs44.statfsSync === "function") {
|
|
242893
243286
|
try {
|
|
242894
|
-
const stats =
|
|
243287
|
+
const stats = fs44.statfsSync(dataDir2);
|
|
242895
243288
|
const availableBytes = stats.bavail * stats.bsize;
|
|
242896
243289
|
return { name: "Disk Space", status: "ok", message: `${formatDiskSpace(availableBytes)} available` };
|
|
242897
243290
|
} catch {
|
|
@@ -242915,12 +243308,12 @@ function checkDiskSpace(dataDir2) {
|
|
|
242915
243308
|
return { name: "Disk Space", status: "warn", message: "disk space check unavailable on this platform" };
|
|
242916
243309
|
}
|
|
242917
243310
|
function checkCopilotCli(configPath2, scriptPath) {
|
|
242918
|
-
if (!
|
|
243311
|
+
if (!fs44.existsSync(configPath2) || !fs44.existsSync(scriptPath)) {
|
|
242919
243312
|
return null;
|
|
242920
243313
|
}
|
|
242921
243314
|
let config3;
|
|
242922
243315
|
try {
|
|
242923
|
-
config3 = JSON.parse(
|
|
243316
|
+
config3 = JSON.parse(fs44.readFileSync(configPath2, "utf-8"));
|
|
242924
243317
|
} catch (err3) {
|
|
242925
243318
|
return {
|
|
242926
243319
|
name: "Copilot CLI",
|
|
@@ -242937,7 +243330,7 @@ function checkCopilotCli(configPath2, scriptPath) {
|
|
|
242937
243330
|
};
|
|
242938
243331
|
}
|
|
242939
243332
|
const bakedExecPath = /^"([^"]+)"/.exec(preToolUseCommand)?.[1];
|
|
242940
|
-
if (bakedExecPath !== void 0 && !
|
|
243333
|
+
if (bakedExecPath !== void 0 && !fs44.existsSync(bakedExecPath)) {
|
|
242941
243334
|
return {
|
|
242942
243335
|
name: "Copilot CLI",
|
|
242943
243336
|
status: "fail",
|
|
@@ -243025,16 +243418,16 @@ function runDoctorAndExit(opts) {
|
|
|
243025
243418
|
try {
|
|
243026
243419
|
const dir = skillOutputsDir();
|
|
243027
243420
|
const pregenPath = path49.join(dir, "pregen.json");
|
|
243028
|
-
if (
|
|
243029
|
-
const content = JSON.parse(
|
|
243421
|
+
if (fs44.existsSync(pregenPath)) {
|
|
243422
|
+
const content = JSON.parse(fs44.readFileSync(pregenPath, "utf-8"));
|
|
243030
243423
|
const pregenNames = new Set(content.names || []);
|
|
243031
243424
|
const skills = [];
|
|
243032
243425
|
try {
|
|
243033
|
-
const entries =
|
|
243426
|
+
const entries = fs44.readdirSync(dir, { withFileTypes: true });
|
|
243034
243427
|
for (const entry of entries) {
|
|
243035
243428
|
if (!entry.isFile() || !entry.name.endsWith(".meta")) continue;
|
|
243036
243429
|
try {
|
|
243037
|
-
const meta3 = JSON.parse(
|
|
243430
|
+
const meta3 = JSON.parse(fs44.readFileSync(path49.join(dir, entry.name), "utf-8"));
|
|
243038
243431
|
if (meta3.skillName && !pregenNames.has(meta3.skillName)) {
|
|
243039
243432
|
skills.push(meta3.skillName);
|
|
243040
243433
|
}
|
|
@@ -243154,7 +243547,7 @@ async function getSectionContent(fileId, heading) {
|
|
|
243154
243547
|
|
|
243155
243548
|
// src/pack.ts
|
|
243156
243549
|
init_define_import_meta_env();
|
|
243157
|
-
import * as
|
|
243550
|
+
import * as fs45 from "node:fs";
|
|
243158
243551
|
import * as path51 from "node:path";
|
|
243159
243552
|
|
|
243160
243553
|
// node_modules/minimatch/dist/esm/index.js
|
|
@@ -245046,24 +245439,24 @@ function isPathWithinRoot(rootReal, resolvedPath) {
|
|
|
245046
245439
|
function openWithinRoot(rootReal, p) {
|
|
245047
245440
|
let fd2;
|
|
245048
245441
|
try {
|
|
245049
|
-
fd2 =
|
|
245442
|
+
fd2 = fs45.openSync(p, "r");
|
|
245050
245443
|
} catch {
|
|
245051
245444
|
return null;
|
|
245052
245445
|
}
|
|
245053
245446
|
let ownershipTransferred = false;
|
|
245054
245447
|
try {
|
|
245055
|
-
const stat2 =
|
|
245448
|
+
const stat2 = fs45.fstatSync(fd2);
|
|
245056
245449
|
if (!stat2.isFile()) return null;
|
|
245057
245450
|
let realPath;
|
|
245058
245451
|
try {
|
|
245059
|
-
realPath =
|
|
245452
|
+
realPath = fs45.realpathSync(p);
|
|
245060
245453
|
} catch {
|
|
245061
245454
|
return "outside-root";
|
|
245062
245455
|
}
|
|
245063
245456
|
if (!isPathWithinRoot(rootReal, realPath)) return "outside-root";
|
|
245064
245457
|
let realStat;
|
|
245065
245458
|
try {
|
|
245066
|
-
realStat =
|
|
245459
|
+
realStat = fs45.statSync(realPath);
|
|
245067
245460
|
} catch {
|
|
245068
245461
|
return "outside-root";
|
|
245069
245462
|
}
|
|
@@ -245073,7 +245466,7 @@ function openWithinRoot(rootReal, p) {
|
|
|
245073
245466
|
} finally {
|
|
245074
245467
|
if (!ownershipTransferred) {
|
|
245075
245468
|
try {
|
|
245076
|
-
|
|
245469
|
+
fs45.closeSync(fd2);
|
|
245077
245470
|
} catch {
|
|
245078
245471
|
}
|
|
245079
245472
|
}
|
|
@@ -245180,7 +245573,7 @@ function collectFiles(projectRoot, patterns, opts = {}) {
|
|
|
245180
245573
|
const rootResolved = path51.resolve(projectRoot);
|
|
245181
245574
|
let rootReal;
|
|
245182
245575
|
try {
|
|
245183
|
-
rootReal =
|
|
245576
|
+
rootReal = fs45.realpathSync(rootResolved);
|
|
245184
245577
|
} catch {
|
|
245185
245578
|
rootReal = rootResolved;
|
|
245186
245579
|
}
|
|
@@ -245219,7 +245612,7 @@ function collectFiles(projectRoot, patterns, opts = {}) {
|
|
|
245219
245612
|
}
|
|
245220
245613
|
let content;
|
|
245221
245614
|
try {
|
|
245222
|
-
content =
|
|
245615
|
+
content = fs45.readFileSync(fd2, "utf8");
|
|
245223
245616
|
} catch {
|
|
245224
245617
|
result.skipped.push(`${rel} (unreadable)`);
|
|
245225
245618
|
continue;
|
|
@@ -245241,14 +245634,14 @@ function collectFiles(projectRoot, patterns, opts = {}) {
|
|
|
245241
245634
|
result.total_lines += lines;
|
|
245242
245635
|
result.total_tokens += tokens;
|
|
245243
245636
|
} finally {
|
|
245244
|
-
|
|
245637
|
+
fs45.closeSync(fd2);
|
|
245245
245638
|
}
|
|
245246
245639
|
}
|
|
245247
245640
|
}
|
|
245248
245641
|
return result;
|
|
245249
245642
|
}
|
|
245250
245643
|
function collectFromStdin(projectRoot, opts = {}) {
|
|
245251
|
-
const input =
|
|
245644
|
+
const input = fs45.readFileSync(0, "utf8");
|
|
245252
245645
|
const paths = input.split("\n").map((ln2) => ln2.trim()).filter((ln2) => ln2.length > 0);
|
|
245253
245646
|
return collectFiles(projectRoot, paths, opts);
|
|
245254
245647
|
}
|
|
@@ -245378,7 +245771,7 @@ function estimateBudget(projectRoot, patterns, opts = {}) {
|
|
|
245378
245771
|
const rootResolved = path51.resolve(projectRoot);
|
|
245379
245772
|
let rootReal;
|
|
245380
245773
|
try {
|
|
245381
|
-
rootReal =
|
|
245774
|
+
rootReal = fs45.realpathSync(rootResolved);
|
|
245382
245775
|
} catch {
|
|
245383
245776
|
rootReal = rootResolved;
|
|
245384
245777
|
}
|
|
@@ -245418,7 +245811,7 @@ function estimateBudget(projectRoot, patterns, opts = {}) {
|
|
|
245418
245811
|
let lines;
|
|
245419
245812
|
let tokens;
|
|
245420
245813
|
try {
|
|
245421
|
-
const data =
|
|
245814
|
+
const data = fs45.readFileSync(fd2);
|
|
245422
245815
|
const sampleSize = Math.min(1e3, data.length);
|
|
245423
245816
|
const sampleLines = (data.toString("utf8", 0, sampleSize).match(/\n/g) || []).length;
|
|
245424
245817
|
lines = data.length > sampleSize ? Math.ceil(sampleLines * (data.length / sampleSize)) : sampleLines + 1;
|
|
@@ -245434,7 +245827,7 @@ function estimateBudget(projectRoot, patterns, opts = {}) {
|
|
|
245434
245827
|
result.total_lines += lines;
|
|
245435
245828
|
result.total_tokens += tokens;
|
|
245436
245829
|
} finally {
|
|
245437
|
-
|
|
245830
|
+
fs45.closeSync(fd2);
|
|
245438
245831
|
}
|
|
245439
245832
|
}
|
|
245440
245833
|
}
|
|
@@ -245713,12 +246106,12 @@ function formatFailuresJson(result) {
|
|
|
245713
246106
|
|
|
245714
246107
|
// src/text_commands.ts
|
|
245715
246108
|
init_define_import_meta_env();
|
|
245716
|
-
import * as
|
|
246109
|
+
import * as fs47 from "fs";
|
|
245717
246110
|
import * as path53 from "path";
|
|
245718
246111
|
|
|
245719
246112
|
// src/project_memory.ts
|
|
245720
246113
|
init_define_import_meta_env();
|
|
245721
|
-
import * as
|
|
246114
|
+
import * as fs46 from "node:fs";
|
|
245722
246115
|
import * as os22 from "node:os";
|
|
245723
246116
|
import * as path52 from "node:path";
|
|
245724
246117
|
var MAX_ENTRIES = 30;
|
|
@@ -245767,10 +246160,10 @@ function parseTOML(content) {
|
|
|
245767
246160
|
}
|
|
245768
246161
|
function loadRaw(filePath) {
|
|
245769
246162
|
try {
|
|
245770
|
-
if (!
|
|
246163
|
+
if (!fs46.existsSync(filePath)) {
|
|
245771
246164
|
return {};
|
|
245772
246165
|
}
|
|
245773
|
-
const content =
|
|
246166
|
+
const content = fs46.readFileSync(filePath, "utf-8");
|
|
245774
246167
|
return parseTOML(content);
|
|
245775
246168
|
} catch {
|
|
245776
246169
|
return {};
|
|
@@ -245820,15 +246213,15 @@ function unsetEntry(projectHash2, key) {
|
|
|
245820
246213
|
}
|
|
245821
246214
|
function clearAll(projectHash2) {
|
|
245822
246215
|
const p = memoryPath(projectHash2);
|
|
245823
|
-
if (
|
|
246216
|
+
if (fs46.existsSync(p)) {
|
|
245824
246217
|
save(p, {});
|
|
245825
246218
|
}
|
|
245826
246219
|
}
|
|
245827
246220
|
|
|
245828
246221
|
// src/text_commands.ts
|
|
245829
246222
|
function readInput(src) {
|
|
245830
|
-
if (src !== void 0) return
|
|
245831
|
-
return
|
|
246223
|
+
if (src !== void 0) return fs47.readFileSync(src, "utf8");
|
|
246224
|
+
return fs47.readFileSync(0, "utf8");
|
|
245832
246225
|
}
|
|
245833
246226
|
function splitLines(text) {
|
|
245834
246227
|
return text.split(/\r?\n/);
|
|
@@ -245853,17 +246246,17 @@ function isInsideStringLiteral3(line, markerIndex) {
|
|
|
245853
246246
|
const sqCount = countUnescapedQuotes2(before, "'");
|
|
245854
246247
|
return dqCount % 2 !== 0 || sqCount % 2 !== 0;
|
|
245855
246248
|
}
|
|
245856
|
-
function
|
|
246249
|
+
function escapeRegExp4(s) {
|
|
245857
246250
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
245858
246251
|
}
|
|
245859
246252
|
function scanFileForTodos(filePath, kindSet) {
|
|
245860
246253
|
let text;
|
|
245861
246254
|
try {
|
|
245862
|
-
text =
|
|
246255
|
+
text = fs47.readFileSync(filePath, "utf8");
|
|
245863
246256
|
} catch {
|
|
245864
246257
|
return [];
|
|
245865
246258
|
}
|
|
245866
|
-
const kindPattern = [...kindSet].map(
|
|
246259
|
+
const kindPattern = [...kindSet].map(escapeRegExp4).join("|");
|
|
245867
246260
|
const re = new RegExp(`\\b(${kindPattern})\\s*:?\\s*(.*)`, "i");
|
|
245868
246261
|
const items = [];
|
|
245869
246262
|
const lines = splitLines(text);
|
|
@@ -245883,7 +246276,7 @@ function collectTodoFiles(patterns) {
|
|
|
245883
246276
|
for (const p of patterns) {
|
|
245884
246277
|
const abs = path53.resolve(p);
|
|
245885
246278
|
try {
|
|
245886
|
-
const stat2 =
|
|
246279
|
+
const stat2 = fs47.statSync(abs);
|
|
245887
246280
|
if (stat2.isDirectory()) {
|
|
245888
246281
|
results.push(...walkProject(abs).files);
|
|
245889
246282
|
} else {
|
|
@@ -246101,15 +246494,15 @@ var LOCK_PRIORITY = [
|
|
|
246101
246494
|
"Cargo.lock"
|
|
246102
246495
|
];
|
|
246103
246496
|
function findLockfile(startPath) {
|
|
246104
|
-
const stat2 =
|
|
246105
|
-
const dir = stat2?.isDirectory() !== false &&
|
|
246497
|
+
const stat2 = fs47.statSync(startPath, { throwIfNoEntry: false });
|
|
246498
|
+
const dir = stat2?.isDirectory() !== false && fs47.existsSync(startPath) && fs47.statSync(startPath).isDirectory() ? startPath : path53.dirname(startPath);
|
|
246106
246499
|
const found = [];
|
|
246107
246500
|
for (const name2 of LOCK_PRIORITY) {
|
|
246108
246501
|
const candidate = path53.join(dir, name2);
|
|
246109
|
-
if (
|
|
246502
|
+
if (fs47.existsSync(candidate)) found.push(candidate);
|
|
246110
246503
|
}
|
|
246111
246504
|
try {
|
|
246112
|
-
const entries =
|
|
246505
|
+
const entries = fs47.readdirSync(dir);
|
|
246113
246506
|
for (const e of entries) {
|
|
246114
246507
|
if (/^requirements.*\.txt$/.test(e)) {
|
|
246115
246508
|
const p = path53.join(dir, e);
|
|
@@ -246227,7 +246620,7 @@ function parseRequirementsTxt(content) {
|
|
|
246227
246620
|
}
|
|
246228
246621
|
function parseLockFile(filePath) {
|
|
246229
246622
|
const base = path53.basename(filePath);
|
|
246230
|
-
const content =
|
|
246623
|
+
const content = fs47.readFileSync(filePath, "utf8");
|
|
246231
246624
|
if (base === "package-lock.json") return { format: "npm", deps: parsePackageLockJson(content) };
|
|
246232
246625
|
if (base === "yarn.lock") return { format: "yarn", deps: parseYarnLock(content) };
|
|
246233
246626
|
if (base === "poetry.lock") return { format: "poetry", deps: parseTomlPackages(content) };
|
|
@@ -246325,7 +246718,7 @@ function loadAllSessionReadCounts() {
|
|
|
246325
246718
|
const totals = /* @__PURE__ */ new Map();
|
|
246326
246719
|
let entries;
|
|
246327
246720
|
try {
|
|
246328
|
-
entries =
|
|
246721
|
+
entries = fs47.readdirSync(sessionsDir, { withFileTypes: true });
|
|
246329
246722
|
} catch {
|
|
246330
246723
|
return totals;
|
|
246331
246724
|
}
|
|
@@ -246334,7 +246727,7 @@ function loadAllSessionReadCounts() {
|
|
|
246334
246727
|
const filePath = path53.join(sessionsDir, entry.name);
|
|
246335
246728
|
let raw;
|
|
246336
246729
|
try {
|
|
246337
|
-
raw = JSON.parse(
|
|
246730
|
+
raw = JSON.parse(fs47.readFileSync(filePath, "utf8"));
|
|
246338
246731
|
} catch {
|
|
246339
246732
|
continue;
|
|
246340
246733
|
}
|
|
@@ -246408,7 +246801,7 @@ function detectWalkMode(cwd) {
|
|
|
246408
246801
|
if (project?.marker === ".git") return "git";
|
|
246409
246802
|
let cur = cwd;
|
|
246410
246803
|
while (true) {
|
|
246411
|
-
if (
|
|
246804
|
+
if (fs47.existsSync(path53.join(cur, ".git"))) return "git";
|
|
246412
246805
|
const parent = path53.dirname(cur);
|
|
246413
246806
|
if (parent === cur) break;
|
|
246414
246807
|
cur = parent;
|
|
@@ -246790,7 +247183,7 @@ function cmdBaseline(opts) {
|
|
|
246790
247183
|
|
|
246791
247184
|
// src/config_commands.ts
|
|
246792
247185
|
init_define_import_meta_env();
|
|
246793
|
-
import * as
|
|
247186
|
+
import * as fs48 from "node:fs";
|
|
246794
247187
|
import * as os23 from "node:os";
|
|
246795
247188
|
import * as path54 from "node:path";
|
|
246796
247189
|
|
|
@@ -247243,7 +247636,7 @@ function cmdConfig(opts) {
|
|
|
247243
247636
|
let raw = {};
|
|
247244
247637
|
let parseErr = null;
|
|
247245
247638
|
try {
|
|
247246
|
-
const text =
|
|
247639
|
+
const text = fs48.readFileSync(cfgFile, "utf8");
|
|
247247
247640
|
raw = parse(text);
|
|
247248
247641
|
} catch (e) {
|
|
247249
247642
|
const code = e.code;
|
|
@@ -247347,7 +247740,7 @@ function cmdProject(opts) {
|
|
|
247347
247740
|
const before = cfg.worker.blocked_roots;
|
|
247348
247741
|
const after = before.filter((r) => {
|
|
247349
247742
|
try {
|
|
247350
|
-
return
|
|
247743
|
+
return fs48.existsSync(r);
|
|
247351
247744
|
} catch {
|
|
247352
247745
|
return false;
|
|
247353
247746
|
}
|
|
@@ -247397,7 +247790,7 @@ function cmdCompactDoc(opts) {
|
|
|
247397
247790
|
if (opts.force === true || !fresh) {
|
|
247398
247791
|
let sourceText;
|
|
247399
247792
|
try {
|
|
247400
|
-
sourceText =
|
|
247793
|
+
sourceText = fs48.readFileSync(resolved, "utf-8");
|
|
247401
247794
|
} catch {
|
|
247402
247795
|
emitErr4(`compact-doc: could not read or compact '${resolved}'`);
|
|
247403
247796
|
throw new Error(`could not compact: ${resolved}`);
|
|
@@ -247468,7 +247861,7 @@ async function cmdFetchImage(opts) {
|
|
|
247468
247861
|
outData = buf;
|
|
247469
247862
|
shrunkBytes = originalBytes;
|
|
247470
247863
|
}
|
|
247471
|
-
|
|
247864
|
+
fs48.writeFileSync(outPath, outData);
|
|
247472
247865
|
if (opts.json === true) {
|
|
247473
247866
|
emit4(JSON.stringify({ url: opts.url, out: outPath, originalBytes, shrunkBytes, wasShrunk }, null, 2));
|
|
247474
247867
|
return;
|
|
@@ -247577,24 +247970,40 @@ async function cmdIndex(pathArg, opts = {}) {
|
|
|
247577
247970
|
const blockedRoots = loadConfig().worker.blocked_roots;
|
|
247578
247971
|
let indexed = 0;
|
|
247579
247972
|
let failed = 0;
|
|
247973
|
+
let skipped = 0;
|
|
247580
247974
|
for (const f of files) {
|
|
247581
247975
|
const key = resolveIndexPath(f);
|
|
247582
247976
|
if (isUnderBlockedRoot(key, blockedRoots)) continue;
|
|
247583
247977
|
if (detectLanguage(key) === "unknown") continue;
|
|
247584
|
-
|
|
247585
|
-
|
|
247586
|
-
|
|
247587
|
-
|
|
247588
|
-
|
|
247978
|
+
const sha = fingerprintFile(key);
|
|
247979
|
+
const entry = sha !== null ? getFileEntry(key, dbPath) : null;
|
|
247980
|
+
const parseUnchanged = sha !== null && entry?.sha === sha;
|
|
247981
|
+
const embedUnchanged = parseUnchanged && entry?.embedSha === sha;
|
|
247982
|
+
if (parseUnchanged && embedUnchanged) {
|
|
247983
|
+
skipped += 1;
|
|
247589
247984
|
continue;
|
|
247590
247985
|
}
|
|
247591
|
-
|
|
247986
|
+
if (!parseUnchanged) {
|
|
247987
|
+
try {
|
|
247988
|
+
indexFileSync(key, dbPath);
|
|
247989
|
+
} catch (e) {
|
|
247990
|
+
failed += 1;
|
|
247991
|
+
err2(`token-goat: index: failed to index '${key}': ${extractErrorMessage(e)}`);
|
|
247992
|
+
continue;
|
|
247993
|
+
}
|
|
247994
|
+
}
|
|
247995
|
+
if (!embedUnchanged) {
|
|
247996
|
+
await indexFileEmbeddings(key, dbPath, sha ?? void 0);
|
|
247997
|
+
}
|
|
247592
247998
|
indexed += 1;
|
|
247593
247999
|
}
|
|
247594
248000
|
const pruned = pruneDeletedFiles(resolveIndexPath(root), dbPath);
|
|
247595
248001
|
out(
|
|
247596
|
-
`Indexed ${indexed} files into the symbol index.${pruned > 0 ? ` Pruned ${pruned} deleted file(s).` : ""}${failed > 0 ? ` Failed to index ${failed} file(s) (see stderr).` : ""}`
|
|
248002
|
+
`Indexed ${indexed} files into the symbol index.${skipped > 0 ? ` Skipped ${skipped} unchanged file(s).` : ""}${pruned > 0 ? ` Pruned ${pruned} deleted file(s).` : ""}${failed > 0 ? ` Failed to index ${failed} file(s) (see stderr).` : ""}`
|
|
247597
248003
|
);
|
|
248004
|
+
if (indexed === 0 && failed > 0) {
|
|
248005
|
+
process.exitCode = 1;
|
|
248006
|
+
}
|
|
247598
248007
|
}
|
|
247599
248008
|
function cmdMap(opts) {
|
|
247600
248009
|
const compact = opts.compact === true;
|
|
@@ -247684,15 +248093,15 @@ async function cmdInstall(opts) {
|
|
|
247684
248093
|
}
|
|
247685
248094
|
try {
|
|
247686
248095
|
const skillDir2 = path55.join(homedir15(), ".claude", "skills");
|
|
247687
|
-
if (
|
|
247688
|
-
const entries =
|
|
248096
|
+
if (fs49.existsSync(skillDir2)) {
|
|
248097
|
+
const entries = fs49.readdirSync(skillDir2, { withFileTypes: true });
|
|
247689
248098
|
const skillNames = [];
|
|
247690
248099
|
const sessionId = getSessionId();
|
|
247691
248100
|
for (const entry of entries) {
|
|
247692
248101
|
if (!entry.isDirectory()) continue;
|
|
247693
248102
|
const skillFile = path55.join(skillDir2, entry.name, "SKILL.md");
|
|
247694
|
-
if (
|
|
247695
|
-
const body =
|
|
248103
|
+
if (fs49.existsSync(skillFile)) {
|
|
248104
|
+
const body = fs49.readFileSync(skillFile, "utf-8");
|
|
247696
248105
|
const compact = extractCompactFromMarker(body);
|
|
247697
248106
|
if (compact === null) continue;
|
|
247698
248107
|
const sourceSha = contentHash(body);
|
|
@@ -247702,10 +248111,10 @@ async function cmdInstall(opts) {
|
|
|
247702
248111
|
}
|
|
247703
248112
|
if (skillNames.length > 0) {
|
|
247704
248113
|
const dir = skillOutputsDir();
|
|
247705
|
-
await
|
|
248114
|
+
await fs49.promises.mkdir(dir, { recursive: true });
|
|
247706
248115
|
const pregenPath = path55.join(dir, "pregen.json");
|
|
247707
248116
|
const pregenData = { ts: Date.now(), names: skillNames };
|
|
247708
|
-
await
|
|
248117
|
+
await fs49.promises.writeFile(pregenPath, JSON.stringify(pregenData, null, 2));
|
|
247709
248118
|
out(`Pre-generated ${skillNames.length} skill compacts.`);
|
|
247710
248119
|
}
|
|
247711
248120
|
}
|
|
@@ -247870,11 +248279,11 @@ function cmdBashOutput(id, opts) {
|
|
|
247870
248279
|
}
|
|
247871
248280
|
let content;
|
|
247872
248281
|
try {
|
|
247873
|
-
const st =
|
|
248282
|
+
const st = fs49.statSync(opts.file);
|
|
247874
248283
|
if (st.isFIFO() || st.isSocket()) {
|
|
247875
248284
|
throw new CliError(`--file '${opts.file}' is a special file (FIFO or socket) \u2014 only regular files are supported`);
|
|
247876
248285
|
}
|
|
247877
|
-
content =
|
|
248286
|
+
content = fs49.readFileSync(opts.file, "utf-8");
|
|
247878
248287
|
} catch (e) {
|
|
247879
248288
|
if (e instanceof CliError) throw e;
|
|
247880
248289
|
throw new CliError(`cannot read file: ${opts.file}`);
|
|
@@ -248106,7 +248515,7 @@ async function cmdSkillBody(name2, opts) {
|
|
|
248106
248515
|
if (filePath === null) {
|
|
248107
248516
|
throw new CliError(`skill '${name2}' not found`);
|
|
248108
248517
|
}
|
|
248109
|
-
const body =
|
|
248518
|
+
const body = fs49.readFileSync(filePath, "utf-8");
|
|
248110
248519
|
if (opts.compact === true) {
|
|
248111
248520
|
out(extractCompactFromMarker(body) ?? body);
|
|
248112
248521
|
} else {
|
|
@@ -248123,7 +248532,7 @@ async function cmdSkillCompact(name2, opts) {
|
|
|
248123
248532
|
for (const skill of skills) {
|
|
248124
248533
|
const filePath = await getSkillFilePath(skill.name);
|
|
248125
248534
|
if (!filePath) continue;
|
|
248126
|
-
const body2 =
|
|
248535
|
+
const body2 = fs49.readFileSync(filePath, "utf-8");
|
|
248127
248536
|
const compact2 = extractCompactFromMarker(body2);
|
|
248128
248537
|
if (compact2 === null) continue;
|
|
248129
248538
|
const sourceSha2 = contentHash(body2);
|
|
@@ -248141,10 +248550,10 @@ async function cmdSkillCompact(name2, opts) {
|
|
|
248141
248550
|
let cacheName;
|
|
248142
248551
|
let sourcePath;
|
|
248143
248552
|
if (opts.path !== void 0 && opts.path !== "") {
|
|
248144
|
-
if (!
|
|
248553
|
+
if (!fs49.existsSync(opts.path)) {
|
|
248145
248554
|
throw new CliError(`skill file not found: ${opts.path}`);
|
|
248146
248555
|
}
|
|
248147
|
-
body =
|
|
248556
|
+
body = fs49.readFileSync(opts.path, "utf-8");
|
|
248148
248557
|
cacheName = name2 ?? path55.basename(path55.dirname(path55.resolve(opts.path)));
|
|
248149
248558
|
sourcePath = path55.resolve(opts.path);
|
|
248150
248559
|
} else {
|
|
@@ -248155,7 +248564,7 @@ async function cmdSkillCompact(name2, opts) {
|
|
|
248155
248564
|
if (filePath === null) {
|
|
248156
248565
|
throw new CliError(`skill '${name2}' not found`);
|
|
248157
248566
|
}
|
|
248158
|
-
body =
|
|
248567
|
+
body = fs49.readFileSync(filePath, "utf-8");
|
|
248159
248568
|
cacheName = name2;
|
|
248160
248569
|
sourcePath = filePath;
|
|
248161
248570
|
}
|
|
@@ -248264,8 +248673,8 @@ async function cmdSkillDiff(name2) {
|
|
|
248264
248673
|
}
|
|
248265
248674
|
const newer = versions[0];
|
|
248266
248675
|
const older = versions[1];
|
|
248267
|
-
const newerBody = await
|
|
248268
|
-
const olderBody = await
|
|
248676
|
+
const newerBody = await fs49.promises.readFile(path55.resolve(dir, `${newer.outputId}.txt`), "utf-8").catch(() => null);
|
|
248677
|
+
const olderBody = await fs49.promises.readFile(path55.resolve(dir, `${older.outputId}.txt`), "utf-8").catch(() => null);
|
|
248269
248678
|
if (newerBody === null || olderBody === null) {
|
|
248270
248679
|
out(`only one cached version of '${name2}'`);
|
|
248271
248680
|
return;
|
|
@@ -248294,7 +248703,7 @@ async function cmdSkillSection(nameHeading, headingArg) {
|
|
|
248294
248703
|
if (!filePath) {
|
|
248295
248704
|
throw new CliError(`skill '${skillName}' not found`);
|
|
248296
248705
|
}
|
|
248297
|
-
const body =
|
|
248706
|
+
const body = fs49.readFileSync(filePath, "utf-8");
|
|
248298
248707
|
const extracted = extractNamedSection(body, heading);
|
|
248299
248708
|
if (!extracted) {
|
|
248300
248709
|
process.exitCode = 1;
|
|
@@ -248304,7 +248713,7 @@ async function cmdSkillSection(nameHeading, headingArg) {
|
|
|
248304
248713
|
}
|
|
248305
248714
|
function atomicWriteBuffer(dest, data) {
|
|
248306
248715
|
try {
|
|
248307
|
-
if (
|
|
248716
|
+
if (fs49.statSync(dest).isDirectory()) {
|
|
248308
248717
|
const e = Object.assign(new Error(`EISDIR: illegal operation on a directory, open '${dest}'`), { code: "EISDIR", path: dest });
|
|
248309
248718
|
throw e;
|
|
248310
248719
|
}
|
|
@@ -248314,15 +248723,15 @@ function atomicWriteBuffer(dest, data) {
|
|
|
248314
248723
|
const rnd = Math.random().toString(36).slice(2, 8);
|
|
248315
248724
|
const tmp = path55.join(path55.dirname(path55.resolve(dest)), `.tmp.${process.pid}.${rnd}`);
|
|
248316
248725
|
try {
|
|
248317
|
-
|
|
248726
|
+
fs49.writeFileSync(tmp, data, { mode: 384 });
|
|
248318
248727
|
withRetryOnLock(() => {
|
|
248319
248728
|
try {
|
|
248320
|
-
|
|
248729
|
+
fs49.renameSync(tmp, dest);
|
|
248321
248730
|
} catch (e) {
|
|
248322
248731
|
if (e.code === "EXDEV") {
|
|
248323
|
-
|
|
248732
|
+
fs49.copyFileSync(tmp, dest);
|
|
248324
248733
|
try {
|
|
248325
|
-
|
|
248734
|
+
fs49.unlinkSync(tmp);
|
|
248326
248735
|
} catch (ue) {
|
|
248327
248736
|
process.stderr.write(`token-goat write-file: warning: could not remove temp file ${tmp}: ${ue.message}
|
|
248328
248737
|
`);
|
|
@@ -248334,7 +248743,7 @@ function atomicWriteBuffer(dest, data) {
|
|
|
248334
248743
|
});
|
|
248335
248744
|
} catch (e) {
|
|
248336
248745
|
try {
|
|
248337
|
-
|
|
248746
|
+
fs49.unlinkSync(tmp);
|
|
248338
248747
|
} catch {
|
|
248339
248748
|
}
|
|
248340
248749
|
throw e;
|
|
@@ -248462,7 +248871,7 @@ function readFileBoundedRaw(filePath, label, allowStdIn = false) {
|
|
|
248462
248871
|
throw new CliError(`${label} ${filePath} requires piped input; use ${altLabel} for interactive use`);
|
|
248463
248872
|
}
|
|
248464
248873
|
try {
|
|
248465
|
-
const st =
|
|
248874
|
+
const st = fs49.statSync(filePath);
|
|
248466
248875
|
if (st.isFIFO() || st.isSocket()) {
|
|
248467
248876
|
throw new CliError(`${label} '${filePath}' is a special file (FIFO or socket) \u2014 only regular files are supported`);
|
|
248468
248877
|
}
|
|
@@ -248470,7 +248879,7 @@ function readFileBoundedRaw(filePath, label, allowStdIn = false) {
|
|
|
248470
248879
|
if (st.size > maxBytes) {
|
|
248471
248880
|
throw new CliError(`${label} '${filePath}' exceeds size limit (${Math.round(st.size / 1024 / 1024)} MB); set TOKEN_GOAT_MAX_STDIN_MB to override`);
|
|
248472
248881
|
}
|
|
248473
|
-
return
|
|
248882
|
+
return fs49.readFileSync(filePath);
|
|
248474
248883
|
} catch (e) {
|
|
248475
248884
|
if (e instanceof CliError) throw e;
|
|
248476
248885
|
mapFsError(e, filePath);
|
|
@@ -248671,7 +249080,7 @@ ${content}`);
|
|
|
248671
249080
|
}
|
|
248672
249081
|
function expandGlobs(root, patterns) {
|
|
248673
249082
|
const out2 = [];
|
|
248674
|
-
const globFn =
|
|
249083
|
+
const globFn = fs49["globSync"];
|
|
248675
249084
|
for (const p of patterns) {
|
|
248676
249085
|
if (globFn !== void 0 && (p.includes("*") || p.includes("?") || p.includes("{"))) {
|
|
248677
249086
|
try {
|
|
@@ -248718,14 +249127,14 @@ function cmdPack(patterns, opts) {
|
|
|
248718
249127
|
}
|
|
248719
249128
|
let instruction;
|
|
248720
249129
|
if (opts.instructionFile !== void 0) {
|
|
248721
|
-
instruction =
|
|
249130
|
+
instruction = fs49.readFileSync(opts.instructionFile, "utf8");
|
|
248722
249131
|
}
|
|
248723
249132
|
const formatted = formatPack(result, style, {
|
|
248724
249133
|
...opts.lineNumbers === true ? { line_numbers: true } : {},
|
|
248725
249134
|
...instruction !== void 0 ? { instruction } : {}
|
|
248726
249135
|
});
|
|
248727
249136
|
if (opts.output !== void 0) {
|
|
248728
|
-
|
|
249137
|
+
fs49.writeFileSync(opts.output, formatted, "utf8");
|
|
248729
249138
|
} else {
|
|
248730
249139
|
out(formatted);
|
|
248731
249140
|
}
|
|
@@ -248805,7 +249214,7 @@ function cmdBudget(patterns, opts) {
|
|
|
248805
249214
|
}
|
|
248806
249215
|
function cmdFailures(src, opts) {
|
|
248807
249216
|
try {
|
|
248808
|
-
const text = src !== void 0 ?
|
|
249217
|
+
const text = src !== void 0 ? fs49.readFileSync(src, "utf8") : fs49.readFileSync(0, "utf8");
|
|
248809
249218
|
const result = extractFailures(text, opts.runner !== void 0 ? { runner: opts.runner } : {});
|
|
248810
249219
|
out(opts.json === true ? formatFailuresJson(result) : formatFailuresText(result));
|
|
248811
249220
|
process.exitCode = 0;
|