token-goat 2.9.14 → 2.9.16

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.
Files changed (46) hide show
  1. package/README.md +15 -1
  2. package/dist/{token-goat-chunk-2ESBO4IN.mjs → token-goat-chunk-2IEIBVVD.mjs} +16 -9
  3. package/dist/{token-goat-chunk-RUDOKYPJ.mjs → token-goat-chunk-2PCFAQAS.mjs} +6582 -6194
  4. package/dist/{token-goat-chunk-AMYCQJX4.mjs → token-goat-chunk-3H6FQT62.mjs} +49 -256
  5. package/dist/{token-goat-chunk-PRJVGIC5.mjs → token-goat-chunk-4DC6DDIB.mjs} +7 -5
  6. package/dist/token-goat-chunk-4EXFN2AW.mjs +29 -0
  7. package/dist/{token-goat-chunk-VZYD4OZB.mjs → token-goat-chunk-5USHO7B6.mjs} +416 -4168
  8. package/dist/token-goat-chunk-63QWJ6UM.mjs +277 -0
  9. package/dist/token-goat-chunk-BFNTLGVA.mjs +4547 -0
  10. package/dist/token-goat-chunk-BGHSSJUA.mjs +102 -0
  11. package/dist/{token-goat-chunk-T2IWWTHB.mjs → token-goat-chunk-DMQ32ZSR.mjs} +35 -1142
  12. package/dist/{token-goat-chunk-DBNY4RLN.mjs → token-goat-chunk-EJCY6KHO.mjs} +5 -3
  13. package/dist/token-goat-chunk-ERTXEKB6.mjs +228 -0
  14. package/dist/{token-goat-chunk-Z6UXPYJA.mjs → token-goat-chunk-F2ARFHLJ.mjs} +1 -1
  15. package/dist/{token-goat-chunk-EG3663UT.mjs → token-goat-chunk-GIMGT34T.mjs} +4 -2
  16. package/dist/{token-goat-chunk-XVZ4MNQC.mjs → token-goat-chunk-GMXBQS6O.mjs} +360 -116
  17. package/dist/{token-goat-chunk-SAQ5PG4L.mjs → token-goat-chunk-H3DXI6VD.mjs} +8 -4
  18. package/dist/token-goat-chunk-LJL6FGDS.mjs +35 -0
  19. package/dist/{token-goat-chunk-NEI4NC54.mjs → token-goat-chunk-LKSXAMJB.mjs} +7 -2
  20. package/dist/token-goat-chunk-LMFO66YD.mjs +331 -0
  21. package/dist/{token-goat-chunk-7OGKZ7AP.mjs → token-goat-chunk-M2R4UQ3B.mjs} +5 -3
  22. package/dist/{token-goat-chunk-YHGTGG6K.mjs → token-goat-chunk-MA5BZ2KI.mjs} +68 -7
  23. package/dist/{token-goat-chunk-ASVVF4JV.mjs → token-goat-chunk-MIL62GMN.mjs} +171 -23
  24. package/dist/{token-goat-chunk-ZFM4PWXL.mjs → token-goat-chunk-NAMH252H.mjs} +10 -7
  25. package/dist/{token-goat-chunk-YTQHZJXW.mjs → token-goat-chunk-NOBZV7PM.mjs} +96 -22
  26. package/dist/{token-goat-chunk-4SDX3QP3.mjs → token-goat-chunk-NQZCSVN2.mjs} +13 -5
  27. package/dist/{token-goat-chunk-XEH6KBWW.mjs → token-goat-chunk-OCI25AXY.mjs} +4 -3
  28. package/dist/token-goat-chunk-OSUFN2FV.mjs +326 -0
  29. package/dist/{token-goat-chunk-O5WAMISC.mjs → token-goat-chunk-QMZMHQRR.mjs} +29 -18
  30. package/dist/{token-goat-chunk-POBYR64E.mjs → token-goat-chunk-R3X5TCPB.mjs} +801 -3
  31. package/dist/token-goat-chunk-RRNZMM3A.mjs +3364 -0
  32. package/dist/{token-goat-chunk-PGGDW7DZ.mjs → token-goat-chunk-ULA4WCED.mjs} +9 -6
  33. package/dist/token-goat-chunk-UMXD2M7O.mjs +975 -0
  34. package/dist/{token-goat-chunk-3XQPEJMV.mjs → token-goat-chunk-UXHDBVUR.mjs} +1 -1
  35. package/dist/{token-goat-chunk-EZNVAIR3.mjs → token-goat-chunk-VVIYEFBI.mjs} +4 -3
  36. package/dist/token-goat-chunk-XOHTFRDH.mjs +10760 -0
  37. package/dist/{token-goat-chunk-HF6H7RNK.mjs → token-goat-chunk-YPS64ACE.mjs} +13 -3
  38. package/dist/{token-goat-chunk-DAMXYVIW.mjs → token-goat-chunk-Z5VPAXTC.mjs} +2560 -820
  39. package/dist/{token-goat-chunk-XQF5J25J.mjs → token-goat-chunk-ZEHFYJ7Z.mjs} +5 -4
  40. package/dist/token-goat-hook.mjs +15 -10
  41. package/dist/token-goat.core.mjs +24 -18
  42. package/docs/cli.md +8 -6
  43. package/package.json +1 -1
  44. package/dist/token-goat-chunk-IT6O3PNN.mjs +0 -15463
  45. package/dist/token-goat-chunk-ZD4EM4LR.mjs +0 -30
  46. package/dist/token-goat-chunk-ZYNNQ36L.mjs +0 -479
@@ -25,8 +25,13 @@ import {
25
25
  extractSwift,
26
26
  extractThrift,
27
27
  extractWgsl
28
- } from "./token-goat-chunk-HF6H7RNK.mjs";
28
+ } from "./token-goat-chunk-YPS64ACE.mjs";
29
29
  import {
30
+ extractShellBannerHeading
31
+ } from "./token-goat-chunk-BFNTLGVA.mjs";
32
+ import "./token-goat-chunk-63QWJ6UM.mjs";
33
+ import {
34
+ GENERIC_CLAUSE,
30
35
  assignBraceBlockSpans,
31
36
  assignFlatEndLines,
32
37
  buildLineIndex,
@@ -53,12 +58,17 @@ import {
53
58
  stripMultilineStringSpan,
54
59
  stripStringLiterals,
55
60
  stripXmlComments
56
- } from "./token-goat-chunk-POBYR64E.mjs";
61
+ } from "./token-goat-chunk-R3X5TCPB.mjs";
62
+ import "./token-goat-chunk-H3DXI6VD.mjs";
63
+ import "./token-goat-chunk-EEIDFMEM.mjs";
64
+ import "./token-goat-chunk-OSUFN2FV.mjs";
57
65
  import {
58
66
  countContentLines,
59
67
  escapeRegExp,
60
68
  pushAll
61
- } from "./token-goat-chunk-AMYCQJX4.mjs";
69
+ } from "./token-goat-chunk-3H6FQT62.mjs";
70
+ import "./token-goat-chunk-ERTXEKB6.mjs";
71
+ import "./token-goat-chunk-Y4AFKTHK.mjs";
62
72
  import "./token-goat-chunk-GMOUBOX4.mjs";
63
73
  import {
64
74
  init_define_import_meta_env
@@ -101,6 +111,27 @@ var PROPERTY_RE = new RegExp(
101
111
  var PROPERTY_HEADER_RE = new RegExp(
102
112
  `${MEMBER_INDENT}(?:(?:public|protected|private|internal|static|virtual|override|abstract|sealed|new|readonly)\\s+)*${TYPE_SLOT}\\s+${MEMBER_NAME}\\s*$`
103
113
  );
114
+ var EVENT_RE = new RegExp(
115
+ `${MEMBER_INDENT}(?:(?:public|protected|private|internal|static|virtual|override|abstract|sealed|new|extern|unsafe)\\s+)*event\\s`
116
+ );
117
+ var EVENT_NAME_RE = new RegExp(`(${IDENT})\\s*$`);
118
+ function splitEventDeclarators(decl) {
119
+ const parts = [];
120
+ let depth = 0;
121
+ let start = 0;
122
+ for (let i = 0; i < decl.length; i++) {
123
+ const c = decl[i];
124
+ if (c === "<") depth++;
125
+ else if (c === ">") {
126
+ if (depth > 0) depth--;
127
+ } else if (c === "," && depth === 0) {
128
+ parts.push(decl.slice(start, i));
129
+ start = i + 1;
130
+ }
131
+ }
132
+ parts.push(decl.slice(start));
133
+ return parts;
134
+ }
104
135
  var ALLMAN_ACCESSOR_RE = /^(?:get\s*;\s*set\s*;|set\s*;\s*get\s*;|get\s*;|set\s*;)$/;
105
136
  var ALLMAN_ACCESSOR_BODY_RE = /^(?:get|set)\b/;
106
137
  var PROPERTY_ARROW_RE = new RegExp(
@@ -173,7 +204,7 @@ function extractCsharp(content, filePath) {
173
204
  const delM = DELEGATE_RE.exec(stripLeadingAttributes(stripped));
174
205
  if (delM) {
175
206
  const delegateParent = classStack.length > 0 ? classStack[classStack.length - 1].name : void 0;
176
- symbols.push(makeLineSymbol(filePath, stripVerbatim(delM[1] ?? ""), "interface", lineNum, stripped.slice(0, 200), delegateParent, lines, "c"));
207
+ symbols.push(makeLineSymbol(filePath, stripVerbatim(delM[1] ?? ""), "type", lineNum, stripped.slice(0, 200), delegateParent, lines, "c"));
177
208
  }
178
209
  const cm = CLASS_HEADER_RE.exec(stripLeadingAttributes(stripped));
179
210
  if (cm) {
@@ -196,7 +227,16 @@ function extractCsharp(content, filePath) {
196
227
  symbols.push(makeLineSymbol(filePath, frame.name, "method", lineNum, sig.slice(0, 200), frame.name, lines, "c"));
197
228
  }
198
229
  let isPropertyLine = false;
199
- const propM = PROPERTY_RE.exec(lineNoAttr);
230
+ const eventM = EVENT_RE.exec(lineNoAttr);
231
+ if (eventM) {
232
+ isPropertyLine = true;
233
+ const decl = lineNoAttr.slice(eventM[0].length).split(/[;{]/)[0] ?? "";
234
+ for (const part of splitEventDeclarators(decl)) {
235
+ const declM = EVENT_NAME_RE.exec(part.split("=")[0]?.trim() ?? "");
236
+ if (declM) symbols.push(makeLineSymbol(filePath, stripVerbatim(declM[1] ?? ""), "var", lineNum, stripped.slice(0, 200), frame.name, lines, "c"));
237
+ }
238
+ }
239
+ const propM = isPropertyLine ? null : PROPERTY_RE.exec(lineNoAttr);
200
240
  if (propM) {
201
241
  isPropertyLine = true;
202
242
  symbols.push(makeLineSymbol(filePath, stripVerbatim(propM[1] ?? ""), "var", lineNum, stripped.slice(0, 200), frame.name, lines, "c"));
@@ -309,6 +349,7 @@ function extractPhp(content, filePath) {
309
349
  const lines = maskPhpInlineHtml(content).split(/\r?\n/);
310
350
  const contextStack = [];
311
351
  let braceDepth = 0;
352
+ let parenDepth = 0;
312
353
  let inComment = false;
313
354
  let mlState = null;
314
355
  for (let i = 0; i < lines.length; i++) {
@@ -324,11 +365,17 @@ function extractPhp(content, filePath) {
324
365
  inComment = nextInComment;
325
366
  const line = codeLine.trimEnd();
326
367
  const stripped = line.trimStart();
327
- if (!stripped || stripped.startsWith("//") || stripped.startsWith("#")) continue;
328
- const braceLine = stripStringLiterals(stripLineComment(line, ["//", "#"]));
368
+ const attrOpen = stripped.startsWith("#[");
369
+ if (!stripped || stripped.startsWith("//") || stripped.startsWith("#") && !attrOpen) continue;
370
+ const commentFrom = attrOpen ? line.indexOf("#[") + 2 : 0;
371
+ const braceLine = stripStringLiterals(line.slice(0, commentFrom) + stripLineComment(line.slice(commentFrom), ["//", "#"]));
329
372
  const openB = (braceLine.match(/\{/g) ?? []).length;
330
373
  const closeB = (braceLine.match(/\}/g) ?? []).length;
331
374
  braceDepth += openB - closeB;
375
+ const preLineParenDepth = parenDepth;
376
+ const openP = (braceLine.match(/\(/g) ?? []).length;
377
+ const closeP = (braceLine.match(/\)/g) ?? []).length;
378
+ parenDepth = Math.max(0, parenDepth + openP - closeP);
332
379
  const topFrame = contextStack.length > 0 ? contextStack[contextStack.length - 1] : void 0;
333
380
  if (topFrame !== void 0 && braceDepth > topFrame[1]) {
334
381
  topFrame[2] = true;
@@ -411,7 +458,7 @@ function extractPhp(content, filePath) {
411
458
  const name = propM[1] ?? "";
412
459
  const preLineDepth = braceDepth - openB + closeB;
413
460
  const topFrame2 = contextStack.length > 0 ? contextStack[contextStack.length - 1] : void 0;
414
- if (topFrame2 !== void 0 && preLineDepth === topFrame2[1] + 1) {
461
+ if (topFrame2 !== void 0 && preLineDepth === topFrame2[1] + 1 && preLineParenDepth === 0) {
415
462
  symbols.push(makeLineSymbol(filePath, name, "var", lineNum, stripped.slice(0, 200), topFrame2[0], lines, "c"));
416
463
  }
417
464
  continue;
@@ -634,7 +681,7 @@ function unquoteName(name) {
634
681
  return name.length >= 2 && name.startsWith("`") && name.endsWith("`") ? name.slice(1, -1) : name;
635
682
  }
636
683
  var FUN_RE = new RegExp(
637
- "^\\s*(?:(?:public|internal|protected|private|open|override|abstract|suspend|inline|infix|operator|external|actual|expect|final|sealed|tailrec)\\s+)*fun\\s+(?:<[^>]*>\\s*)?" + RECEIVER_RE + "(" + NAME_RE + ")\\s*[(<]"
684
+ "^\\s*(?:(?:public|internal|protected|private|open|override|abstract|suspend|inline|infix|operator|external|actual|expect|final|sealed|tailrec)\\s+)*fun\\s+(?:" + GENERIC_CLAUSE + "\\s*)?" + RECEIVER_RE + "(" + NAME_RE + ")\\s*[(<]"
638
685
  );
639
686
  var CONST_RE2 = new RegExp(
640
687
  "^\\s*(?:(?:public|internal|protected|private|open|override|abstract|final|actual|expect|const|lateinit|companion|external|inline)\\s+)*(?:const\\s+)?val\\s+([A-Z_][A-Z0-9_]*)\\s*(?::|=)"
@@ -646,10 +693,10 @@ var COMPANION_RE = new RegExp(
646
693
  "^(?:(?:public|internal|protected|private)\\s+)*companion\\s+object\\b(?:\\s+(" + NAME_RE + "))?"
647
694
  );
648
695
  var TYPEALIAS_RE = new RegExp(
649
- "^(?:(?:public|internal|private|actual|expect)\\s+)*typealias\\s+(" + NAME_RE + ")(?:\\s*<[^>]*>)?\\s*="
696
+ "^(?:(?:public|internal|private|actual|expect)\\s+)*typealias\\s+(" + NAME_RE + ")(?:\\s*" + GENERIC_CLAUSE + ")?\\s*="
650
697
  );
651
698
  var TOP_FUN_RE = new RegExp(
652
- "^(?:(?:public|internal|private|suspend|inline|infix|operator|external|actual|expect|tailrec)\\s+)*fun\\s+(?:<[^>]*>\\s*)?" + RECEIVER_RE + "(" + NAME_RE + ")\\s*[(<]"
699
+ "^(?:(?:public|internal|private|suspend|inline|infix|operator|external|actual|expect|tailrec)\\s+)*fun\\s+(?:" + GENERIC_CLAUSE + "\\s*)?" + RECEIVER_RE + "(" + NAME_RE + ")\\s*[(<]"
653
700
  );
654
701
  function extractKotlin(content, filePath) {
655
702
  const symbols = [];
@@ -1147,7 +1194,7 @@ var VB6_PROPERTY_RE = new RegExp(String.raw`^Property\s+(?:Get|Let|Set)\s+(${ID}
1147
1194
  var PROPERTY_RE2 = new RegExp(String.raw`^Property\s+(${ID})`, "i");
1148
1195
  var PROCEDURE_RE = new RegExp(String.raw`^(Sub|Function)\s+(${ID})`, "i");
1149
1196
  var OPERATOR_RE = /^Operator\s+([^\s(]+)\s*\(/i;
1150
- var EVENT_RE = new RegExp(String.raw`^Event\s+(${ID})`, "i");
1197
+ var EVENT_RE2 = new RegExp(String.raw`^Event\s+(${ID})`, "i");
1151
1198
  var CONST_RE3 = /^Const\s+(\S.*)$/i;
1152
1199
  var DIM_RE = /^Dim\s+(\S.*)$/i;
1153
1200
  var FIELD_AFTER_MODIFIERS_RE = new RegExp(String.raw`^(${ID})\s*(?:\(|As\b|=|,|$)`, "i");
@@ -1479,7 +1526,7 @@ function extractVb(content, filePath) {
1479
1526
  open("operator", m[1], "method", stmt);
1480
1527
  continue;
1481
1528
  }
1482
- if ((m = EVENT_RE.exec(rest)) !== null) {
1529
+ if ((m = EVENT_RE2.exec(rest)) !== null) {
1483
1530
  const name = cleanName(m[1]);
1484
1531
  if (modifiers.has("custom") && !inInterface) open("event", name, "event", stmt);
1485
1532
  else emit2(name, "event", stmt);
@@ -1815,16 +1862,16 @@ init_define_import_meta_env();
1815
1862
  var CLASS_RE4 = /^(?:(?:abstract|base|interface|final|sealed|mixin)\s+)*class\s+([A-Za-z_][A-Za-z0-9_]*)/;
1816
1863
  var ENUM_RE2 = /^enum\s+([A-Za-z_][A-Za-z0-9_]*)/;
1817
1864
  var MIXIN_RE = /^(?:base\s+)?mixin\s+([A-Za-z_][A-Za-z0-9_]*)/;
1818
- var EXTENSION_RE = /^extension\s+(?:([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s+)?on\s+/;
1865
+ var EXTENSION_RE = new RegExp("^extension\\s+(?:([A-Za-z_][A-Za-z0-9_]*)\\s*(?:" + GENERIC_CLAUSE + ")?\\s+)?on\\s+");
1819
1866
  var EXTENSION_TYPE_RE = /^extension\s+type\s+([A-Za-z_][A-Za-z0-9_]*)/;
1820
- var FUNC_RE5 = /(?:^|\s)(?:static\s+)?(?:(?:void|Future|Stream|async|external)\s+|[A-Za-z_][A-Za-z0-9_<>]*(?:\s*\?)?\s+)([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(/;
1821
- var GETTER_RE = /^(?:(?:static|external|abstract|covariant)\s+)*(?:[A-Za-z_][A-Za-z0-9_<>,\s]*(?:\s*\?)?\s+)?get\s+([A-Za-z_][A-Za-z0-9_]*)/;
1867
+ var FUNC_RE5 = new RegExp("(?:^|\\s)(?:static\\s+)?(?:(?:void|Future|Stream|async|external)\\s+|[A-Za-z_][A-Za-z0-9_<>?]*(?:\\s*\\?)?\\s+)([A-Za-z_][A-Za-z0-9_]*)\\s*(?:" + GENERIC_CLAUSE + ")?\\s*\\(");
1868
+ var GETTER_RE = /^(?:(?:static|external|abstract|covariant)\s+)*(?:[A-Za-z_][A-Za-z0-9_<>,?\s]*(?:\s*\?)?\s+)?get\s+([A-Za-z_][A-Za-z0-9_]*)/;
1822
1869
  var NAMED_CTOR_RE = /^(?:(?:const|factory|external)\s+)*([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)\s*\(/;
1823
1870
  var UNNAMED_CTOR_RE = /^(?:(?:const|factory|external)\s+)*([A-Za-z_][A-Za-z0-9_]*)\s*\(/;
1824
1871
  var FIELD_START_RE = /^(?:(?:static|covariant|late|external)\s+)*(?:final|var|const)\s/;
1825
- var CLASS_ALIAS_RE = /^(?:(?:abstract|base|interface|final|sealed|mixin)\s+)*class\s+[A-Za-z_][A-Za-z0-9_]*(?:<[^>]*>)?\s*=/;
1826
- var TYPEDEF_RE = /^typedef\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*<.+>)?\s*=/;
1827
- var TYPEDEF_LEGACY_RE = /^typedef\s+[A-Za-z_][A-Za-z0-9_<>,?]*\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*<.+>)?\s*\(/;
1872
+ var CLASS_ALIAS_RE = new RegExp("^(?:(?:abstract|base|interface|final|sealed|mixin)\\s+)*class\\s+[A-Za-z_][A-Za-z0-9_]*(?:" + GENERIC_CLAUSE + ")?\\s*=");
1873
+ var TYPEDEF_RE = new RegExp("^typedef\\s+([A-Za-z_][A-Za-z0-9_]*)(?:\\s*" + GENERIC_CLAUSE + ")?\\s*=");
1874
+ var TYPEDEF_LEGACY_RE = new RegExp("^typedef\\s+[A-Za-z_][A-Za-z0-9_<>,?]*\\s+([A-Za-z_][A-Za-z0-9_]*)(?:\\s*" + GENERIC_CLAUSE + ")?\\s*\\(");
1828
1875
  function extractDart(content, filePath) {
1829
1876
  const symbols = [];
1830
1877
  const imports = [];
@@ -1851,6 +1898,7 @@ function extractDart(content, filePath) {
1851
1898
  braceDepth += (braceLine2.match(/\{/g) ?? []).length - (braceLine2.match(/\}/g) ?? []).length;
1852
1899
  continue;
1853
1900
  }
1901
+ const structural = stripStringLiterals(stripped, { tripleQuotes: true });
1854
1902
  const isIndented = line[0] === " " || line[0] === " ";
1855
1903
  const outerFrame = typeStack.length > 0 ? typeStack[typeStack.length - 1] : null;
1856
1904
  const outerDepthInType = outerFrame !== null ? braceDepth - outerFrame.startDepth : 0;
@@ -1862,7 +1910,8 @@ function extractDart(content, filePath) {
1862
1910
  const cname = cm[1] ?? "";
1863
1911
  const parent = typeStack.length > 0 ? typeStack[typeStack.length - 1].name : void 0;
1864
1912
  symbols.push(makeLineSymbol(filePath, cname, "class", lineNum, stripped.slice(0, 200), parent, lines, "c"));
1865
- if (!CLASS_ALIAS_RE.test(stripped)) {
1913
+ const bracelessDeclaration = !structural.includes("{") && structural.includes(";");
1914
+ if (!CLASS_ALIAS_RE.test(stripped) && !bracelessDeclaration) {
1866
1915
  typeStack.push({ name: cname, startDepth: braceDepth, bodyEntered: false });
1867
1916
  }
1868
1917
  matched = true;
@@ -1929,7 +1978,7 @@ function extractDart(content, filePath) {
1929
1978
  symbols.push(makeLineSymbol(filePath, gm[1] ?? "", "function", lineNum, stripped.slice(0, 200), frame.name, lines, "c"));
1930
1979
  member = true;
1931
1980
  }
1932
- const fm = !member ? FUNC_RE5.exec(stripped) : null;
1981
+ const fm = !member ? FUNC_RE5.exec(structural) : null;
1933
1982
  if (fm) {
1934
1983
  let fname = fm[1] ?? "";
1935
1984
  fname = fname.replace(/^operator\s+/, "");
@@ -1941,7 +1990,7 @@ function extractDart(content, filePath) {
1941
1990
  if (gm) {
1942
1991
  symbols.push(makeLineSymbol(filePath, gm[1] ?? "", "function", lineNum, stripped.slice(0, 200), void 0, lines, "c"));
1943
1992
  }
1944
- const fm = !gm ? FUNC_RE5.exec(stripped) : null;
1993
+ const fm = !gm ? FUNC_RE5.exec(structural) : null;
1945
1994
  if (fm) {
1946
1995
  let fname = fm[1] ?? "";
1947
1996
  fname = fname.replace(/^operator\s+/, "");
@@ -2768,6 +2817,7 @@ function extractBash(content, filePath) {
2768
2817
  let functionBraceDepth = 0;
2769
2818
  let awaitingFunctionBrace = false;
2770
2819
  let openFunctionIndex = null;
2820
+ let openHeadingIndex = null;
2771
2821
  for (let i = 0; i < lines.length; i++) {
2772
2822
  const rawLine = lines[i] ?? "";
2773
2823
  const lineNum = i + 1;
@@ -2775,6 +2825,36 @@ function extractBash(content, filePath) {
2775
2825
  if (rawLine.trim() === heredocs[0]) heredocs.shift();
2776
2826
  continue;
2777
2827
  }
2828
+ if (!inFunction && braceDepth === 0) {
2829
+ const banner = extractShellBannerHeading(rawLine);
2830
+ if (banner !== null) {
2831
+ if (openHeadingIndex !== null) {
2832
+ const prev = symbols[openHeadingIndex];
2833
+ if (prev !== void 0 && lineNum > prev.lineStart) {
2834
+ symbols[openHeadingIndex] = {
2835
+ ...prev,
2836
+ lineEnd: lineNum - 1,
2837
+ body: lines.slice(prev.lineStart - 1, lineNum - 1).join("\n")
2838
+ };
2839
+ }
2840
+ openHeadingIndex = null;
2841
+ }
2842
+ if (symbols.length < MAX_SYMBOLS5) {
2843
+ const pushIdx = symbols.length;
2844
+ symbols.push({
2845
+ filePath,
2846
+ name: banner.heading,
2847
+ kind: "heading",
2848
+ lineStart: lineNum,
2849
+ lineEnd: lineNum,
2850
+ body: rawLine.trim(),
2851
+ docstring: "",
2852
+ parent: ""
2853
+ });
2854
+ openHeadingIndex = pushIdx;
2855
+ }
2856
+ }
2857
+ }
2778
2858
  const noComment = stripBashComment(rawLine);
2779
2859
  const stripped = noComment.trim();
2780
2860
  const opened = findHeredocOpeners(noComment, arithmeticDepth);
@@ -2786,6 +2866,17 @@ function extractBash(content, filePath) {
2786
2866
  const posixMatch = kwMatch === null ? FUNC_POSIX_RE.exec(stripped) : null;
2787
2867
  const funcMatch = kwMatch ?? posixMatch;
2788
2868
  if (funcMatch) {
2869
+ if (openHeadingIndex !== null) {
2870
+ const prev = symbols[openHeadingIndex];
2871
+ if (prev !== void 0 && lineNum > prev.lineStart) {
2872
+ symbols[openHeadingIndex] = {
2873
+ ...prev,
2874
+ lineEnd: lineNum - 1,
2875
+ body: lines.slice(prev.lineStart - 1, lineNum - 1).join("\n")
2876
+ };
2877
+ }
2878
+ openHeadingIndex = null;
2879
+ }
2789
2880
  const fname = funcMatch[1] ?? "";
2790
2881
  let pushedIndex = null;
2791
2882
  if (fname && symbols.length < MAX_SYMBOLS5) {
@@ -2835,6 +2926,16 @@ function extractBash(content, filePath) {
2835
2926
  }
2836
2927
  }
2837
2928
  }
2929
+ if (openHeadingIndex !== null && lines.length > 0) {
2930
+ const prev = symbols[openHeadingIndex];
2931
+ if (prev !== void 0 && lines.length >= prev.lineStart) {
2932
+ symbols[openHeadingIndex] = {
2933
+ ...prev,
2934
+ lineEnd: lines.length,
2935
+ body: lines.slice(prev.lineStart - 1, lines.length).join("\n")
2936
+ };
2937
+ }
2938
+ }
2838
2939
  return symbols;
2839
2940
  }
2840
2941
 
@@ -3310,6 +3411,7 @@ function stripLeadingAttributes2(text) {
3310
3411
  }
3311
3412
  var FUNC_RE7 = new RegExp(`^(?:function|filter|workflow|configuration)\\s+(?:(?:global|local|script|private):)?(${FUNC_IDENT})`, "i");
3312
3413
  var CLASS_RE5 = new RegExp(`^(class|enum)\\s+(${IDENT2})`, "i");
3414
+ var PESTER_RE = /^(Describe|Context|It)\b(?:\s+-[A-Za-z0-9_-]+(?:\s+(?:'[^']*'|"[^"]*"|[^\s{]+))?)*\s*(?:'([^']*)'|"([^"]*)"|([A-Za-z0-9_.-]+))/i;
3313
3415
  var METHOD_NAME_RE = new RegExp(
3314
3416
  `^(?!(?:if|elseif|else|while|for|foreach|do|switch|return|throw|try|catch|finally|param|begin|process|end)\\b)(${IDENT2})\\s*\\(`,
3315
3417
  "i"
@@ -3336,6 +3438,7 @@ function extractPowershell(content, filePath) {
3336
3438
  let inBlockComment = false;
3337
3439
  let mlState = null;
3338
3440
  let openQuote = null;
3441
+ const openBlocks = [];
3339
3442
  const pushInlineMethods = (body, className, lineNum) => {
3340
3443
  for (const piece of body.split(/(?<=[{}])/)) {
3341
3444
  const mname = matchMethodName(piece.replace(/^[{}\s]+/, ""));
@@ -3383,7 +3486,28 @@ function extractPowershell(content, filePath) {
3383
3486
  if (funcMatch) {
3384
3487
  const fname = funcMatch[1] ?? "";
3385
3488
  if (symbols.length < MAX_SYMBOLS9) {
3489
+ const pushIdx = symbols.length;
3386
3490
  symbols.push(makeLineSymbol(filePath, fname, "function", lineNum, line.trimEnd().slice(0, 200), void 0, lines, "hash"));
3491
+ openBlocks.push({ symbolIndex: pushIdx, kind: "function", braceDepth, entered: false });
3492
+ }
3493
+ }
3494
+ }
3495
+ if (currentClass === null) {
3496
+ const pesterTrigger = /^(?:Describe|Context|It)\b/i.exec(stripped);
3497
+ if (pesterTrigger) {
3498
+ const rawLine = sourceLine.trimStart();
3499
+ const pesterMatch = PESTER_RE.exec(rawLine);
3500
+ if (pesterMatch) {
3501
+ const blockType = (pesterMatch[1] ?? "").toLowerCase();
3502
+ const testName = (pesterMatch[2] ?? pesterMatch[3] ?? pesterMatch[4] ?? "").trim();
3503
+ if (testName && symbols.length < MAX_SYMBOLS9) {
3504
+ const kind = blockType === "context" ? "context" : "test";
3505
+ const parentBlock = [...openBlocks].reverse().find((b) => b.kind === "test" || b.kind === "context");
3506
+ const parentName = parentBlock !== void 0 ? symbols[parentBlock.symbolIndex]?.name : void 0;
3507
+ const pushIdx = symbols.length;
3508
+ symbols.push(makeLineSymbol(filePath, testName, kind, lineNum, sourceLine.trimEnd().slice(0, 200), parentName, lines, "hash"));
3509
+ openBlocks.push({ symbolIndex: pushIdx, kind, braceDepth, entered: false });
3510
+ }
3387
3511
  }
3388
3512
  }
3389
3513
  }
@@ -3406,6 +3530,7 @@ function extractPowershell(content, filePath) {
3406
3530
  currentClass = cname;
3407
3531
  classBraceDepth = braceDepth;
3408
3532
  classBodyEntered = false;
3533
+ openBlocks.push({ symbolIndex: symbols.length - 1, kind: "class", braceDepth, entered: false });
3409
3534
  }
3410
3535
  }
3411
3536
  }
@@ -3415,10 +3540,33 @@ function extractPowershell(content, filePath) {
3415
3540
  if (mname !== null && symbols.length < MAX_SYMBOLS9) {
3416
3541
  const sigEnd = line.indexOf("{");
3417
3542
  const sig = sigEnd >= 0 ? line.slice(0, sigEnd).trimEnd() : line.trimEnd();
3543
+ const pushIdx = symbols.length;
3418
3544
  symbols.push(makeLineSymbol(filePath, mname, "method", lineNum, sig.slice(0, 200), currentClass, lines, "hash"));
3545
+ openBlocks.push({ symbolIndex: pushIdx, kind: "method", braceDepth, entered: false });
3546
+ }
3547
+ }
3548
+ const openBraces = (line.match(/\{/g) ?? []).length;
3549
+ const closeBraces = (line.match(/\}/g) ?? []).length;
3550
+ for (const block of openBlocks) {
3551
+ if (braceDepth + openBraces > block.braceDepth) {
3552
+ block.entered = true;
3553
+ }
3554
+ }
3555
+ braceDepth += openBraces - closeBraces;
3556
+ for (let b = openBlocks.length - 1; b >= 0; b--) {
3557
+ const block = openBlocks[b];
3558
+ if (block !== void 0 && block.entered && braceDepth <= block.braceDepth) {
3559
+ openBlocks.splice(b, 1);
3560
+ const sym = symbols[block.symbolIndex];
3561
+ if (sym !== void 0 && lineNum > sym.lineStart) {
3562
+ symbols[block.symbolIndex] = {
3563
+ ...sym,
3564
+ lineEnd: lineNum,
3565
+ body: lines.slice(sym.lineStart - 1, lineNum).join("\n")
3566
+ };
3567
+ }
3419
3568
  }
3420
3569
  }
3421
- braceDepth += (line.match(/\{/g) ?? []).length - (line.match(/\}/g) ?? []).length;
3422
3570
  if (currentClass !== null && braceDepth > classBraceDepth) {
3423
3571
  classBodyEntered = true;
3424
3572
  }
@@ -3,7 +3,7 @@ const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  queryCsv,
5
5
  quoteCsvCell
6
- } from "./token-goat-chunk-EG3663UT.mjs";
6
+ } from "./token-goat-chunk-GIMGT34T.mjs";
7
7
  import {
8
8
  NotAnOfficeDocumentError,
9
9
  assertOoxmlWithinDeadline,
@@ -12,13 +12,13 @@ import {
12
12
  ooxmlWorkDeadline,
13
13
  parseOoxmlPart,
14
14
  readOoxmlZip
15
- } from "./token-goat-chunk-YHGTGG6K.mjs";
15
+ } from "./token-goat-chunk-MA5BZ2KI.mjs";
16
+ import {
17
+ displaySafeText
18
+ } from "./token-goat-chunk-ERTXEKB6.mjs";
16
19
  import {
17
20
  DocumentRefusedError
18
21
  } from "./token-goat-chunk-Y4AFKTHK.mjs";
19
- import {
20
- displaySafeText
21
- } from "./token-goat-chunk-AMYCQJX4.mjs";
22
22
  import {
23
23
  init_define_import_meta_env
24
24
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -158,8 +158,9 @@ function buildCell(c, shared, styles, date1904) {
158
158
  raw = { error: e };
159
159
  text = e;
160
160
  } else {
161
- const n = Number(textOf(c["v"]));
162
- if (!Number.isFinite(n)) {
161
+ const vText = textOf(c["v"]);
162
+ const n = Number(vText);
163
+ if (vText.trim() === "" || !Number.isFinite(n)) {
163
164
  raw = null;
164
165
  text = "";
165
166
  } else if (isDateStyle) {
@@ -364,6 +365,8 @@ function cellText(cell) {
364
365
  if (Array.isArray(obj.richText)) return obj.richText.map((t) => t.text).join("");
365
366
  if (typeof obj.error === "string") return obj.error;
366
367
  if (obj.result !== void 0) {
368
+ if (obj.result === null) return "";
369
+ if (typeof obj.result === "boolean") return obj.result ? "TRUE" : "FALSE";
367
370
  if (obj.result instanceof Date) return formatDateCell(obj.result);
368
371
  if (typeof obj.result === "object" && obj.result !== null && typeof obj.result.error === "string") {
369
372
  return obj.result.error;
@@ -25,48 +25,59 @@ import {
25
25
  runSkeleton,
26
26
  runSymbol,
27
27
  withPinnedReads
28
- } from "./token-goat-chunk-RUDOKYPJ.mjs";
28
+ } from "./token-goat-chunk-2PCFAQAS.mjs";
29
+ import "./token-goat-chunk-EJCY6KHO.mjs";
30
+ import "./token-goat-chunk-LMFO66YD.mjs";
29
31
  import {
30
32
  buildProjectMap,
31
- embeddingsDepsAvailable,
32
33
  formatProjectMap,
33
34
  getDirtyPathsFor,
35
+ getEmbeddingCoverage,
34
36
  getProjectIndexCounts,
35
37
  isWorkerRunning,
36
38
  mapLookupBytesSaved
37
- } from "./token-goat-chunk-IT6O3PNN.mjs";
38
- import "./token-goat-chunk-VZYD4OZB.mjs";
39
- import "./token-goat-chunk-NEI4NC54.mjs";
40
- import "./token-goat-chunk-EG3663UT.mjs";
39
+ } from "./token-goat-chunk-XOHTFRDH.mjs";
40
+ import "./token-goat-chunk-5USHO7B6.mjs";
41
+ import {
42
+ recordStat,
43
+ savedTokensFromBytes
44
+ } from "./token-goat-chunk-DMQ32ZSR.mjs";
45
+ import "./token-goat-chunk-LKSXAMJB.mjs";
46
+ import "./token-goat-chunk-GIMGT34T.mjs";
41
47
  import "./token-goat-chunk-3BTK54F3.mjs";
42
48
  import "./token-goat-chunk-XTQAOTSO.mjs";
43
49
  import "./token-goat-chunk-AH6QILZM.mjs";
44
- import "./token-goat-chunk-Y4AFKTHK.mjs";
45
- import "./token-goat-chunk-DBNY4RLN.mjs";
50
+ import "./token-goat-chunk-YPS64ACE.mjs";
46
51
  import {
47
- getDb,
48
- recordStat,
49
- savedTokensFromBytes
50
- } from "./token-goat-chunk-T2IWWTHB.mjs";
52
+ checkEmbeddingPreflight,
53
+ embeddingsDepsAvailable
54
+ } from "./token-goat-chunk-BFNTLGVA.mjs";
55
+ import "./token-goat-chunk-63QWJ6UM.mjs";
56
+ import {
57
+ getDb
58
+ } from "./token-goat-chunk-R3X5TCPB.mjs";
51
59
  import {
52
60
  envStrList,
53
61
  loadConfig,
54
62
  resolveProjectRoot
55
- } from "./token-goat-chunk-SAQ5PG4L.mjs";
63
+ } from "./token-goat-chunk-H3DXI6VD.mjs";
56
64
  import "./token-goat-chunk-EEIDFMEM.mjs";
57
- import "./token-goat-chunk-HF6H7RNK.mjs";
58
- import "./token-goat-chunk-POBYR64E.mjs";
65
+ import "./token-goat-chunk-OSUFN2FV.mjs";
59
66
  import {
60
67
  ENV_KEYS,
61
68
  VERSION,
62
69
  dataDir,
63
- displaySafeJson,
64
70
  extractErrorMessage,
65
71
  foldCaseForContainment,
66
- globalDbPath,
72
+ globalDbPath
73
+ } from "./token-goat-chunk-3H6FQT62.mjs";
74
+ import {
75
+ displaySafeJson,
67
76
  normalizePath
68
- } from "./token-goat-chunk-AMYCQJX4.mjs";
77
+ } from "./token-goat-chunk-ERTXEKB6.mjs";
78
+ import "./token-goat-chunk-Y4AFKTHK.mjs";
69
79
  import "./token-goat-chunk-GMOUBOX4.mjs";
80
+ import "./token-goat-chunk-RRNZMM3A.mjs";
70
81
  import {
71
82
  init_define_import_meta_env
72
83
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -74,6 +85,7 @@ import {
74
85
  // src/mcp_server.ts
75
86
  init_define_import_meta_env();
76
87
  import * as fs from "fs";
88
+ import * as os from "os";
77
89
  import * as path from "path";
78
90
  var TOKEN_GOAT_RETRY_RE = /token-goat (\w[\w-]*) "([^"]+)"/g;
79
91
  var MCP_MAX_LIMIT = 1e3;
@@ -156,10 +168,40 @@ function resolveToolRoot(projectRoot) {
156
168
  }
157
169
  var RootNotAllowedError = class extends Error {
158
170
  };
171
+ function getStandardAuxiliaryRoots(targetPath) {
172
+ const home = os.homedir();
173
+ const roots = [
174
+ path.join(home, ".claude", "skills"),
175
+ path.join(home, ".copilot", "skills"),
176
+ path.join(home, ".claude", "projects"),
177
+ path.join(home, ".copilot", "session-state")
178
+ ];
179
+ const appData = process.env["APPDATA"] || path.join(home, "AppData", "Roaming");
180
+ roots.push(
181
+ path.join(appData, "Code", "User", "workspaceStorage"),
182
+ path.join(appData, "Code - Insiders", "User", "workspaceStorage"),
183
+ path.join(appData, "Cursor", "User", "workspaceStorage"),
184
+ path.join(home, "Library", "Application Support", "Code", "User", "workspaceStorage"),
185
+ path.join(home, "Library", "Application Support", "Code - Insiders", "User", "workspaceStorage"),
186
+ path.join(home, "Library", "Application Support", "Cursor", "User", "workspaceStorage"),
187
+ path.join(home, ".config", "Code", "User", "workspaceStorage"),
188
+ path.join(home, ".config", "Code - Insiders", "User", "workspaceStorage"),
189
+ path.join(home, ".config", "Cursor", "User", "workspaceStorage")
190
+ );
191
+ if (targetPath) {
192
+ const norm = normalizePath(targetPath);
193
+ const promptIdx = norm.toLowerCase().indexOf("/resources/app/extensions/");
194
+ if (promptIdx !== -1) {
195
+ roots.push(norm.slice(0, promptIdx + "/resources/app/extensions/".length));
196
+ }
197
+ }
198
+ return roots;
199
+ }
159
200
  function assertRootAllowed(resolvedRoot) {
160
201
  const allowedRoots = loadConfig().mcp.allowed_roots;
161
202
  if (allowedRoots.length === 0) return;
162
203
  if (allowedRoots.some((allowed) => checkWithinProjectRoot(resolvedRoot, allowed).inside)) return;
204
+ if (getStandardAuxiliaryRoots(resolvedRoot).some((aux) => checkWithinProjectRoot(resolvedRoot, aux).inside)) return;
163
205
  throw new RootNotAllowedError(
164
206
  `refused: "${resolvedRoot}" is not inside any root listed in mcp.allowed_roots. A caller-supplied projectRoot is untrusted input, so this deployment pins which roots may be named; add the root to mcp.allowed_roots (or TOKEN_GOAT_MCP_ALLOWED_ROOTS) to permit it.`
165
207
  );
@@ -219,6 +261,7 @@ function refusalText(file, resolvedRoot, reason) {
219
261
  }
220
262
  function confineTargets(targets, resolvedRoot, splitCommas = true) {
221
263
  if (!loadConfig(resolvedRoot).mcp.confine_reads_to_project_root) return { ok: true, targets, pins: NO_PINS };
264
+ const allowedRoots = loadConfig().mcp.allowed_roots;
222
265
  const checked = [];
223
266
  const pins = /* @__PURE__ */ new Map();
224
267
  for (const raw of targets) {
@@ -226,7 +269,25 @@ function confineTargets(targets, resolvedRoot, splitCommas = true) {
226
269
  for (const part of parts) {
227
270
  const file = specFilePart(part);
228
271
  if (file === "") continue;
229
- const check = checkWithinProjectRoot(file, resolvedRoot);
272
+ let check = checkWithinProjectRoot(file, resolvedRoot);
273
+ if (!check.inside) {
274
+ for (const allowed of allowedRoots) {
275
+ const altCheck = checkWithinProjectRoot(file, allowed);
276
+ if (altCheck.inside) {
277
+ check = altCheck;
278
+ break;
279
+ }
280
+ }
281
+ }
282
+ if (!check.inside) {
283
+ for (const aux of getStandardAuxiliaryRoots(file)) {
284
+ const auxCheck = checkWithinProjectRoot(file, aux);
285
+ if (auxCheck.inside) {
286
+ check = auxCheck;
287
+ break;
288
+ }
289
+ }
290
+ }
230
291
  if (!check.inside) {
231
292
  return { ok: false, refusal: toCallToolResult({ text: refusalText(file, resolvedRoot, check.reason), code: 1 }) };
232
293
  }
@@ -455,6 +516,8 @@ async function createMcpServer() {
455
516
  limit: z.number().int().positive().max(MCP_MAX_LIMIT).optional().describe("max results (default: 20)"),
456
517
  grep: z.string().optional().describe("filter to hits whose file path matches this regex (literal substring if it does not compile as regex); matched against the path as rendered, same convention as refs --grep"),
457
518
  excludeTests: z.boolean().optional().describe("hide hits whose file is a test file (opt-in; default output is unchanged)"),
519
+ preflight: z.boolean().optional().describe("run semantic embedding preflight check and return status"),
520
+ warm: z.boolean().optional().describe("warm up the embedding model session in memory before query execution"),
458
521
  json: z.boolean().optional().describe("output as JSON"),
459
522
  projectRoot: makeProjectRootField("search")
460
523
  },
@@ -462,13 +525,15 @@ async function createMcpServer() {
462
525
  annotations: { readOnlyHint: true, openWorldHint: false }
463
526
  },
464
527
  async (args) => {
465
- const { query, limit, grep, excludeTests, json, projectRoot } = args;
528
+ const { query, limit, grep, excludeTests, preflight, warm, json, projectRoot } = args;
466
529
  const root = resolveToolRoot(projectRoot);
467
530
  return toCallToolResult(
468
531
  await runSemantic(query, {
469
532
  ...limit !== void 0 ? { limit } : {},
470
533
  ...grep !== void 0 ? { grep } : {},
471
534
  ...excludeTests === true ? { excludeTests: true } : {},
535
+ ...preflight === true ? { preflight: true } : {},
536
+ ...warm === true ? { warm: true } : {},
472
537
  ...json === true ? { json: true } : {},
473
538
  projectRoot: root
474
539
  })
@@ -484,7 +549,7 @@ async function createMcpServer() {
484
549
  },
485
550
  annotations: { readOnlyHint: true, openWorldHint: false }
486
551
  },
487
- (args) => {
552
+ async (args) => {
488
553
  const { projectRoot } = args;
489
554
  const rootDir = resolveToolRoot(projectRoot);
490
555
  const dbPath = globalDbPath();
@@ -505,14 +570,20 @@ async function createMcpServer() {
505
570
  const dirtyQueueDepth = getDirtyPathsFor(resolvedDataDir).length;
506
571
  const workerAlive = isWorkerRunning(resolvedDataDir);
507
572
  let embeddingsAvailable = false;
573
+ let coverage;
508
574
  if (databaseExists && queryError === void 0) {
509
575
  try {
510
576
  embeddingsAvailable = embeddingsDepsAvailable(getDb(dbPath));
577
+ coverage = getEmbeddingCoverage(dbPath, rootDir);
511
578
  } catch {
512
579
  embeddingsAvailable = false;
513
580
  }
514
581
  }
515
582
  const embeddingsEnabled = loadConfig(rootDir).indexing?.embeddings_enabled ?? true;
583
+ const preflight = await checkEmbeddingPreflight({
584
+ projectRoot: rootDir,
585
+ ...coverage !== void 0 ? { coverage } : {}
586
+ });
516
587
  const status = {
517
588
  projectRoot: rootDir,
518
589
  databaseExists,
@@ -523,7 +594,10 @@ async function createMcpServer() {
523
594
  dirtyQueueDepth,
524
595
  workerAlive,
525
596
  embeddingsEnabled,
526
- embeddingsAvailable
597
+ embeddingsAvailable,
598
+ embeddingPreflight: preflight.status,
599
+ embeddingPreflightSummary: preflight.summary,
600
+ ...preflight.actionRequired !== void 0 ? { embeddingPreflightAction: preflight.actionRequired } : {}
527
601
  };
528
602
  return toCallToolResult({ text: displaySafeJson(status), code: 0 });
529
603
  }