token-goat 2.8.0 → 2.8.1
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/README.md +5 -3
- package/dist/{token-goat-chunk-2F6TFBZE.mjs → token-goat-chunk-2G6RAB4G.mjs} +119 -13
- package/dist/{token-goat-chunk-FBGBTICM.mjs → token-goat-chunk-73MF6YWW.mjs} +3 -3
- package/dist/{token-goat-chunk-TUPJRK7R.mjs → token-goat-chunk-7JDXDERZ.mjs} +1 -1
- package/dist/{token-goat-chunk-LVCBDJVE.mjs → token-goat-chunk-AOBZUFNJ.mjs} +5 -5
- package/dist/{token-goat-chunk-44Y77VHR.mjs → token-goat-chunk-ELDJRLHZ.mjs} +128 -6
- package/dist/{token-goat-chunk-4KZILRZN.mjs → token-goat-chunk-I6TOUPLP.mjs} +2 -2
- package/dist/{token-goat-chunk-SRAR6DOK.mjs → token-goat-chunk-RMDQFTQD.mjs} +95 -11
- package/dist/{token-goat-chunk-VXSYZGBA.mjs → token-goat-chunk-VBXBLGTO.mjs} +217 -16
- package/dist/{token-goat-chunk-AO6MFFTW.mjs → token-goat-chunk-XEDQH5DA.mjs} +2 -2
- package/dist/{token-goat-chunk-J35AKWEQ.mjs → token-goat-chunk-Y2SYNH3S.mjs} +5 -5
- package/dist/{token-goat-chunk-A62K4XW2.mjs → token-goat-chunk-YUGNM3KL.mjs} +5 -5
- package/dist/token-goat-hook.mjs +5 -5
- package/dist/token-goat.core.mjs +5 -5
- package/package.json +4 -2
|
@@ -2,6 +2,7 @@ import { createRequire as __cjsRequire } from 'node:module';
|
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
IMPORT_RE,
|
|
5
|
+
ImageDecodeError,
|
|
5
6
|
MAX_OVER_FETCH,
|
|
6
7
|
OVER_FETCH_FACTOR,
|
|
7
8
|
SKIP_DIRS,
|
|
@@ -25,9 +26,11 @@ import {
|
|
|
25
26
|
isBlobStale,
|
|
26
27
|
isImagePath,
|
|
27
28
|
isIndexEmptyForProject,
|
|
29
|
+
isOcrEngineAvailable,
|
|
28
30
|
isTextHeavy,
|
|
29
31
|
lineOpenDelimiterAfter,
|
|
30
32
|
loadBlob,
|
|
33
|
+
locatePdfPages,
|
|
31
34
|
mergeNearbyHits,
|
|
32
35
|
ocrImage,
|
|
33
36
|
parseWhereSpecs,
|
|
@@ -51,7 +54,7 @@ import {
|
|
|
51
54
|
walkProject,
|
|
52
55
|
yamlLineClosesQuote,
|
|
53
56
|
yamlOpenQuoteAfter
|
|
54
|
-
} from "./token-goat-chunk-
|
|
57
|
+
} from "./token-goat-chunk-2G6RAB4G.mjs";
|
|
55
58
|
import {
|
|
56
59
|
Database,
|
|
57
60
|
PER_FILE_COUNTERFACTUAL_CEILING,
|
|
@@ -103,7 +106,7 @@ import {
|
|
|
103
106
|
unsupportedLanguageName,
|
|
104
107
|
windowsCmdQuoteArg,
|
|
105
108
|
withExtension
|
|
106
|
-
} from "./token-goat-chunk-
|
|
109
|
+
} from "./token-goat-chunk-ELDJRLHZ.mjs";
|
|
107
110
|
import {
|
|
108
111
|
registerReset
|
|
109
112
|
} from "./token-goat-chunk-AO2QD2AG.mjs";
|
|
@@ -3451,6 +3454,33 @@ function mergeParameters(pathLevelParams, ownParams) {
|
|
|
3451
3454
|
});
|
|
3452
3455
|
return [...inheritedParams, ...ownParams];
|
|
3453
3456
|
}
|
|
3457
|
+
function resolveJsonPointer(root, ref) {
|
|
3458
|
+
const parts = ref.slice(2).split("/").map((p) => p.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
3459
|
+
let cur = root;
|
|
3460
|
+
for (const part of parts) {
|
|
3461
|
+
if (typeof cur !== "object" || cur === null) return null;
|
|
3462
|
+
cur = cur[part];
|
|
3463
|
+
if (cur === void 0) return null;
|
|
3464
|
+
}
|
|
3465
|
+
return cur;
|
|
3466
|
+
}
|
|
3467
|
+
function dereferenceLocalRefs(node, root, seen) {
|
|
3468
|
+
if (Array.isArray(node)) return node.map((item) => dereferenceLocalRefs(item, root, seen));
|
|
3469
|
+
if (typeof node !== "object" || node === null) return node;
|
|
3470
|
+
const rec = node;
|
|
3471
|
+
const ref = rec["$ref"];
|
|
3472
|
+
if (typeof ref === "string" && ref.startsWith("#/")) {
|
|
3473
|
+
if (seen.has(ref)) return node;
|
|
3474
|
+
const target = resolveJsonPointer(root, ref);
|
|
3475
|
+
if (target === void 0 || target === null) return node;
|
|
3476
|
+
return dereferenceLocalRefs(target, root, /* @__PURE__ */ new Set([...seen, ref]));
|
|
3477
|
+
}
|
|
3478
|
+
const out = {};
|
|
3479
|
+
for (const [key, value] of Object.entries(rec)) {
|
|
3480
|
+
out[key] = dereferenceLocalRefs(value, root, seen);
|
|
3481
|
+
}
|
|
3482
|
+
return out;
|
|
3483
|
+
}
|
|
3454
3484
|
function extractOperations(spec) {
|
|
3455
3485
|
if (typeof spec !== "object" || spec === null) return [];
|
|
3456
3486
|
const paths = spec["paths"];
|
|
@@ -3473,9 +3503,9 @@ function extractOperations(spec) {
|
|
|
3473
3503
|
...typeof op["summary"] === "string" ? { summary: op["summary"] } : {},
|
|
3474
3504
|
...typeof op["description"] === "string" ? { description: op["description"] } : {},
|
|
3475
3505
|
...tags !== void 0 && tags.length > 0 ? { tags } : {},
|
|
3476
|
-
parameters: mergeParameters(pathLevelParams, ownParams),
|
|
3477
|
-
...op["requestBody"] !== void 0 ? { requestBody: op["requestBody"] } : {},
|
|
3478
|
-
responses: typeof op["responses"] === "object" && op["responses"] !== null ? op["responses"] : {}
|
|
3506
|
+
parameters: dereferenceLocalRefs(mergeParameters(pathLevelParams, ownParams), spec, /* @__PURE__ */ new Set()),
|
|
3507
|
+
...op["requestBody"] !== void 0 ? { requestBody: dereferenceLocalRefs(op["requestBody"], spec, /* @__PURE__ */ new Set()) } : {},
|
|
3508
|
+
responses: typeof op["responses"] === "object" && op["responses"] !== null ? dereferenceLocalRefs(op["responses"], spec, /* @__PURE__ */ new Set()) : {}
|
|
3479
3509
|
});
|
|
3480
3510
|
}
|
|
3481
3511
|
}
|
|
@@ -5105,6 +5135,7 @@ function findIdentifierNearPosition(ts, sourceFile, line0, position, name) {
|
|
|
5105
5135
|
|
|
5106
5136
|
// src/read_commands.ts
|
|
5107
5137
|
var DIDYOUMEAN_LIMIT = 5;
|
|
5138
|
+
var SYMBOL_PREVIEW_LINES = 5;
|
|
5108
5139
|
var AMBIGUOUS_HEADING_LIMIT = 10;
|
|
5109
5140
|
var TYPO_TWO_EDIT_MIN_LEN = 8;
|
|
5110
5141
|
var TYPO_MAX_QUERY_LEN = 64;
|
|
@@ -5657,9 +5688,13 @@ ${emptyIndexMessage(emptyIndexRoot)}`;
|
|
|
5657
5688
|
const goneTag = fileIsGone(sym.filePath) ? ` ${DELETED_TAG}` : "";
|
|
5658
5689
|
const header = `# ${sym.name} (${sym.kind}) \u2014 ${toDisplayPath(symbolDisplayRoot, sym.filePath)}:${sym.lineStart}-${sym.lineEnd}${statsStr}${goneTag}`;
|
|
5659
5690
|
const body = resolveBody(sym);
|
|
5660
|
-
const
|
|
5691
|
+
const bodyLines = body.split(/\r?\n/);
|
|
5692
|
+
const preview = bodyLines.slice(0, SYMBOL_PREVIEW_LINES).join("\n");
|
|
5693
|
+
const dropped = bodyLines.length - SYMBOL_PREVIEW_LINES;
|
|
5694
|
+
const elided = dropped > 0 ? `
|
|
5695
|
+
...(${countNoun(dropped, "more line")}; full body: token-goat read "${toDisplayPath(symbolDisplayRoot, sym.filePath)}::${sym.name}")` : "";
|
|
5661
5696
|
return preview.trim() !== "" ? `${header}
|
|
5662
|
-
${preview}` : header;
|
|
5697
|
+
${preview}${elided}` : header;
|
|
5663
5698
|
});
|
|
5664
5699
|
const warning = opts.file !== void 0 ? staleWarning(resolveIndexPath(opts.file, opts.projectRoot ?? process.cwd())) : "";
|
|
5665
5700
|
const text = guardText(warning + blocks.join("\n\n"), "symbol");
|
|
@@ -6773,8 +6808,29 @@ function runQueryCommand(opts, parse, formatLabel, guardTag, kind) {
|
|
|
6773
6808
|
function runJsonQuery(opts) {
|
|
6774
6809
|
return runQueryCommand(opts, JSON.parse, "JSON", "json-query", "json_query");
|
|
6775
6810
|
}
|
|
6811
|
+
function isPlainObject2(v) {
|
|
6812
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && Object.getPrototypeOf(v) === Object.prototype;
|
|
6813
|
+
}
|
|
6814
|
+
function resolveYamlMergeKeys(node) {
|
|
6815
|
+
if (Array.isArray(node)) return node.map(resolveYamlMergeKeys);
|
|
6816
|
+
if (!isPlainObject2(node)) return node;
|
|
6817
|
+
const merged = {};
|
|
6818
|
+
const mergeVal = node["<<"];
|
|
6819
|
+
if (mergeVal !== void 0) {
|
|
6820
|
+
const sources = Array.isArray(mergeVal) ? mergeVal : [mergeVal];
|
|
6821
|
+
for (const src of [...sources].reverse()) {
|
|
6822
|
+
const resolved = resolveYamlMergeKeys(src);
|
|
6823
|
+
if (isPlainObject2(resolved)) Object.assign(merged, resolved);
|
|
6824
|
+
}
|
|
6825
|
+
}
|
|
6826
|
+
for (const [key, value] of Object.entries(node)) {
|
|
6827
|
+
if (key === "<<") continue;
|
|
6828
|
+
merged[key] = resolveYamlMergeKeys(value);
|
|
6829
|
+
}
|
|
6830
|
+
return merged;
|
|
6831
|
+
}
|
|
6776
6832
|
function parseYamlDocument(text) {
|
|
6777
|
-
const docs = loadAll(text);
|
|
6833
|
+
const docs = loadAll(text).map(resolveYamlMergeKeys);
|
|
6778
6834
|
return docs.length === 1 ? docs[0] : docs;
|
|
6779
6835
|
}
|
|
6780
6836
|
function runYamlOutline(opts) {
|
|
@@ -7277,6 +7333,13 @@ async function runPdfMeta(file) {
|
|
|
7277
7333
|
const data = fs5.readFileSync(file);
|
|
7278
7334
|
return extractPdfMeta(new Uint8Array(data));
|
|
7279
7335
|
}
|
|
7336
|
+
async function runPdfLocate(file, pattern, opts) {
|
|
7337
|
+
if (!fileExists(file)) {
|
|
7338
|
+
throw new Error(`Could not read: ${file}`);
|
|
7339
|
+
}
|
|
7340
|
+
const data = fs5.readFileSync(file);
|
|
7341
|
+
return locatePdfPages(new Uint8Array(data), pattern, opts);
|
|
7342
|
+
}
|
|
7280
7343
|
async function runImageMeta(file) {
|
|
7281
7344
|
if (!fileExists(file)) {
|
|
7282
7345
|
throw new Error(`Could not read: ${file}`);
|
|
@@ -7286,7 +7349,15 @@ async function runImageMeta(file) {
|
|
|
7286
7349
|
}
|
|
7287
7350
|
const data = fs5.readFileSync(file);
|
|
7288
7351
|
const bytes = data.length;
|
|
7289
|
-
|
|
7352
|
+
let probe;
|
|
7353
|
+
try {
|
|
7354
|
+
probe = await probeImageMeta(data);
|
|
7355
|
+
} catch (e) {
|
|
7356
|
+
if (e instanceof ImageDecodeError) {
|
|
7357
|
+
throw new Error(`${file} is not a readable image: ${e.message}`, { cause: e });
|
|
7358
|
+
}
|
|
7359
|
+
throw e;
|
|
7360
|
+
}
|
|
7290
7361
|
if (probe === null) {
|
|
7291
7362
|
return { width: 0, height: 0, format: null, bytes, sharpAvailable: false, wouldShrink: false, shrunkBytes: null };
|
|
7292
7363
|
}
|
|
@@ -7311,6 +7382,9 @@ async function runImageText(file) {
|
|
|
7311
7382
|
const data = fs5.readFileSync(file);
|
|
7312
7383
|
const ocr = await ocrImage(data);
|
|
7313
7384
|
if (ocr === null) {
|
|
7385
|
+
if (isOcrEngineAvailable()) {
|
|
7386
|
+
throw new Error(`${file} could not be processed by OCR (unreadable image, timeout, or offline model fetch)`);
|
|
7387
|
+
}
|
|
7314
7388
|
return { ocrAvailable: false, confidence: 0, chars: 0, textHeavy: false, text: null };
|
|
7315
7389
|
}
|
|
7316
7390
|
const minConfidence = loadConfig().image_shrink.ocr_min_confidence;
|
|
@@ -9753,6 +9827,14 @@ function runScope(opts) {
|
|
|
9753
9827
|
const filePath = resolveIndexPath(file);
|
|
9754
9828
|
const syms = querySymbols({ filePath, limit: ALL_SYMBOLS_IN_FILE_LIMIT });
|
|
9755
9829
|
const enclosing = syms.filter((s) => s.lineStart <= line && line <= s.lineEnd).sort((a, b) => b.lineStart - a.lineStart);
|
|
9830
|
+
if (syms.length === 0) {
|
|
9831
|
+
if (!fs6.existsSync(filePath)) {
|
|
9832
|
+
emitErr2(`Could not read: ${file}`);
|
|
9833
|
+
return 1;
|
|
9834
|
+
}
|
|
9835
|
+
emitErr2(`No indexed symbols in '${file}' \u2014 the file exists but nothing is indexed for it, so every line looks empty`);
|
|
9836
|
+
return 1;
|
|
9837
|
+
}
|
|
9756
9838
|
if (enclosing.length === 0) {
|
|
9757
9839
|
emitErr2(`No symbols enclosing line ${line} in '${file}'`);
|
|
9758
9840
|
return 1;
|
|
@@ -10088,9 +10170,9 @@ function runBlame(opts) {
|
|
|
10088
10170
|
}
|
|
10089
10171
|
if (opts.json === true) {
|
|
10090
10172
|
const lines = raw.split("\n").filter((l) => l.length > 0).map((l) => {
|
|
10091
|
-
const m = /^([0-9a-f]+)\s+\((.+?)\s+(\d{4}-\d{2}-\d{2}[^)]*)\s+(\d+)\)(.*)/.exec(l);
|
|
10173
|
+
const m = /^(\^?)([0-9a-f]+)\s+\((.+?)\s+(\d{4}-\d{2}-\d{2}[^)]*)\s+(\d+)\)(.*)/.exec(l);
|
|
10092
10174
|
if (!m) return { raw: l };
|
|
10093
|
-
return { commit: m[1], author: (m[
|
|
10175
|
+
return { commit: m[2], boundary: m[1] === "^", author: (m[3] ?? "").trim(), date: (m[4] ?? "").trim(), line: Number.parseInt(m[5] ?? "0", 10), content: m[6] };
|
|
10094
10176
|
});
|
|
10095
10177
|
emit2(JSON.stringify({ symbol: sym.name, file: filePath, lines }, null, 2));
|
|
10096
10178
|
return 0;
|
|
@@ -10334,6 +10416,7 @@ export {
|
|
|
10334
10416
|
upsertNote,
|
|
10335
10417
|
isAvailable2 as isAvailable,
|
|
10336
10418
|
loadError,
|
|
10419
|
+
AMBIGUOUS_HEADING_LIMIT,
|
|
10337
10420
|
ConfinementIdentityError,
|
|
10338
10421
|
ABSENT_PIN,
|
|
10339
10422
|
pinKey,
|
|
@@ -10373,6 +10456,7 @@ export {
|
|
|
10373
10456
|
runPdfExtractText,
|
|
10374
10457
|
runPdfOutline,
|
|
10375
10458
|
runPdfMeta,
|
|
10459
|
+
runPdfLocate,
|
|
10376
10460
|
runImageMeta,
|
|
10377
10461
|
runImageText,
|
|
10378
10462
|
runScreenshot,
|