token-goat 2.9.30 → 2.9.31

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 (172) hide show
  1. package/README.md +24 -7
  2. package/SECURITY.md +10 -2
  3. package/THIRD_PARTY_NOTICES.md +1 -1
  4. package/dist/native/linux-arm64/tg-hook +0 -0
  5. package/dist/native/linux-x64/tg-hook +0 -0
  6. package/dist/native/win32-arm64/tg-hook.exe +0 -0
  7. package/dist/native/win32-x64/tg-hook.exe +0 -0
  8. package/dist/{token-goat-chunk-QSBRTGM2.mjs → token-goat-chunk-25TRAWET.mjs} +17 -7
  9. package/dist/token-goat-chunk-2KXO6V2B.mjs +203 -0
  10. package/dist/{token-goat-chunk-IVKIZWAB.mjs → token-goat-chunk-2M7E4PF7.mjs} +41 -12
  11. package/dist/{token-goat-chunk-SMVRN2HU.mjs → token-goat-chunk-2UPZGKKY.mjs} +2 -2
  12. package/dist/token-goat-chunk-2WLPWKHV.mjs +135 -0
  13. package/dist/token-goat-chunk-2XBMMDBD.mjs +126 -0
  14. package/dist/token-goat-chunk-32ZOY4N5.mjs +23 -0
  15. package/dist/token-goat-chunk-3EZRNKTK.mjs +188 -0
  16. package/dist/token-goat-chunk-4ADZHI7J.mjs +63 -0
  17. package/dist/token-goat-chunk-4GBVPH3D.mjs +242 -0
  18. package/dist/{token-goat-chunk-KWPNJBDH.mjs → token-goat-chunk-4GILLLWY.mjs} +7 -4
  19. package/dist/{token-goat-chunk-67TQJ76B.mjs → token-goat-chunk-4NAPX7BA.mjs} +36 -3
  20. package/dist/{token-goat-chunk-PU7V3FD6.mjs → token-goat-chunk-4SC7UJYV.mjs} +3354 -2553
  21. package/dist/token-goat-chunk-4SMRO4TO.mjs +366 -0
  22. package/dist/{token-goat-chunk-AFLYLHDH.mjs → token-goat-chunk-4ZBFWLXF.mjs} +283 -427
  23. package/dist/{token-goat-chunk-JDWCRD6M.mjs → token-goat-chunk-57BIAXJL.mjs} +73 -40
  24. package/dist/token-goat-chunk-5AC66HNP.mjs +115 -0
  25. package/dist/token-goat-chunk-5IMLKSOP.mjs +145 -0
  26. package/dist/token-goat-chunk-646E6U44.mjs +398 -0
  27. package/dist/token-goat-chunk-65N4RHP4.mjs +33 -0
  28. package/dist/{token-goat-chunk-JN4XMLSD.mjs → token-goat-chunk-6DG6HWP3.mjs} +8 -2
  29. package/dist/token-goat-chunk-6ENQSNRZ.mjs +573 -0
  30. package/dist/token-goat-chunk-6ZY4GNF2.mjs +91 -0
  31. package/dist/{token-goat-chunk-VPBBTSJR.mjs → token-goat-chunk-76FGDLRO.mjs} +262 -255
  32. package/dist/{token-goat-chunk-7IN2MKDS.mjs → token-goat-chunk-7EZTZOMC.mjs} +121 -289
  33. package/dist/{token-goat-chunk-OJBNYTJP.mjs → token-goat-chunk-7MAOA6X4.mjs} +640 -80
  34. package/dist/token-goat-chunk-7R2ZVVAX.mjs +218 -0
  35. package/dist/{token-goat-chunk-PD5VKH46.mjs → token-goat-chunk-AUNGYYQX.mjs} +2 -2
  36. package/dist/{token-goat-chunk-HG45AF2B.mjs → token-goat-chunk-AUQYRMMH.mjs} +794 -37
  37. package/dist/token-goat-chunk-B3PEKBYG.mjs +128 -0
  38. package/dist/{token-goat-chunk-A3CK6N5Z.mjs → token-goat-chunk-BA4HI6BW.mjs} +1309 -110
  39. package/dist/{token-goat-chunk-JB6QN6VF.mjs → token-goat-chunk-BFCWY73P.mjs} +59 -23
  40. package/dist/{token-goat-chunk-B45VMIIH.mjs → token-goat-chunk-BWGFUZZE.mjs} +7 -5
  41. package/dist/{token-goat-chunk-P4QMM4WK.mjs → token-goat-chunk-C75NA7PL.mjs} +50 -23
  42. package/dist/token-goat-chunk-CBIQ7WTD.mjs +87 -0
  43. package/dist/token-goat-chunk-CETM74KC.mjs +307 -0
  44. package/dist/{token-goat-chunk-H2PHHGM5.mjs → token-goat-chunk-CIMQ2BB3.mjs} +57 -12
  45. package/dist/{token-goat-chunk-N2NMER56.mjs → token-goat-chunk-CJLS3CDL.mjs} +46 -4
  46. package/dist/{token-goat-chunk-VES7EL7O.mjs → token-goat-chunk-CO3UYX6G.mjs} +1 -1
  47. package/dist/token-goat-chunk-COPNXRJM.mjs +154 -0
  48. package/dist/token-goat-chunk-CSJ5L3NL.mjs +479 -0
  49. package/dist/{token-goat-chunk-4LCCNRTG.mjs → token-goat-chunk-CVCEVUGK.mjs} +8 -6
  50. package/dist/{token-goat-chunk-B2RZZCSS.mjs → token-goat-chunk-CXHOFN7R.mjs} +37 -20
  51. package/dist/token-goat-chunk-D735C4QM.mjs +603 -0
  52. package/dist/{token-goat-chunk-APGZXSPS.mjs → token-goat-chunk-DGS2LVNA.mjs} +47 -30
  53. package/dist/{token-goat-chunk-54K3EUV3.mjs → token-goat-chunk-DOWRSMWO.mjs} +1 -1
  54. package/dist/token-goat-chunk-E45INMY3.mjs +71 -0
  55. package/dist/token-goat-chunk-EC5F37F4.mjs +244 -0
  56. package/dist/{token-goat-chunk-XTQAOTSO.mjs → token-goat-chunk-EDBDRVH5.mjs} +4 -1
  57. package/dist/{token-goat-chunk-5BCIJXMO.mjs → token-goat-chunk-EELTBKDM.mjs} +14 -10
  58. package/dist/{token-goat-chunk-W3QCJS6G.mjs → token-goat-chunk-F4HYL64R.mjs} +8 -6
  59. package/dist/token-goat-chunk-F6PAUIEK.mjs +624 -0
  60. package/dist/token-goat-chunk-FDSREWLX.mjs +692 -0
  61. package/dist/token-goat-chunk-GGGG7RWB.mjs +236 -0
  62. package/dist/{token-goat-chunk-C63JQV5K.mjs → token-goat-chunk-GL3ETKSC.mjs} +233 -15
  63. package/dist/token-goat-chunk-GVB2MUST.mjs +1298 -0
  64. package/dist/token-goat-chunk-GWFLAUMQ.mjs +307 -0
  65. package/dist/{token-goat-chunk-ZEJVMUQH.mjs → token-goat-chunk-HLPW63A7.mjs} +2 -2
  66. package/dist/{token-goat-chunk-GOLEOXZP.mjs → token-goat-chunk-HU4TORC5.mjs} +44 -26
  67. package/dist/{token-goat-chunk-Z57YODA2.mjs → token-goat-chunk-I7VKZZAW.mjs} +2 -2
  68. package/dist/{token-goat-chunk-NYKZLXMK.mjs → token-goat-chunk-IA6XSPE3.mjs} +6 -6
  69. package/dist/{token-goat-chunk-E3OQX2XT.mjs → token-goat-chunk-IAGXMHIK.mjs} +81 -42
  70. package/dist/{token-goat-chunk-HYBFA5X3.mjs → token-goat-chunk-IK2DRMFX.mjs} +24 -68
  71. package/dist/{token-goat-chunk-COBQGL5S.mjs → token-goat-chunk-INNPTRUX.mjs} +249 -299
  72. package/dist/{token-goat-chunk-7NADEDKJ.mjs → token-goat-chunk-JJ5BX4F4.mjs} +6 -1
  73. package/dist/{token-goat-chunk-PEPTHRFF.mjs → token-goat-chunk-JVFSHVFJ.mjs} +6 -6
  74. package/dist/token-goat-chunk-KGEFFSHD.mjs +50 -0
  75. package/dist/token-goat-chunk-KQBLRPBN.mjs +433 -0
  76. package/dist/{token-goat-chunk-Q5VTGRH7.mjs → token-goat-chunk-LCNQ2CNN.mjs} +55 -319
  77. package/dist/token-goat-chunk-M3LFJDPU.mjs +58 -0
  78. package/dist/token-goat-chunk-M52KPT3C.mjs +87 -0
  79. package/dist/token-goat-chunk-MBEG42H7.mjs +150 -0
  80. package/dist/{token-goat-chunk-EVC4TOLE.mjs → token-goat-chunk-METECDOH.mjs} +3 -12
  81. package/dist/{token-goat-chunk-T4FK7VOV.mjs → token-goat-chunk-MHX7XCC3.mjs} +2 -1
  82. package/dist/token-goat-chunk-N5LSOVSU.mjs +137 -0
  83. package/dist/{token-goat-chunk-LOBGHXPB.mjs → token-goat-chunk-N5MMR2IW.mjs} +1 -1
  84. package/dist/token-goat-chunk-N7B3JQ2C.mjs +160 -0
  85. package/dist/{token-goat-chunk-RHXKCZX3.mjs → token-goat-chunk-NISNMD7T.mjs} +2182 -2959
  86. package/dist/token-goat-chunk-NMD42SFQ.mjs +434 -0
  87. package/dist/token-goat-chunk-NOSS5VWY.mjs +174 -0
  88. package/dist/{token-goat-chunk-KQNZDCBD.mjs → token-goat-chunk-NSNSPPBG.mjs} +25 -3
  89. package/dist/token-goat-chunk-OBOFIHKN.mjs +38 -0
  90. package/dist/token-goat-chunk-OBRFJ5O5.mjs +76 -0
  91. package/dist/{token-goat-chunk-JTQQGXZH.mjs → token-goat-chunk-ODBT2USM.mjs} +124 -57
  92. package/dist/token-goat-chunk-OS5EM5PP.mjs +107 -0
  93. package/dist/token-goat-chunk-OUKDTVNU.mjs +1178 -0
  94. package/dist/token-goat-chunk-OXFMP75N.mjs +566 -0
  95. package/dist/{token-goat-chunk-DZX2YDPT.mjs → token-goat-chunk-OYIYKDDT.mjs} +2 -2
  96. package/dist/{token-goat-chunk-QCLDAQTS.mjs → token-goat-chunk-P6HQSWQ3.mjs} +50 -53
  97. package/dist/token-goat-chunk-P6VGNTQT.mjs +71 -0
  98. package/dist/{token-goat-chunk-7BXSNBY5.mjs → token-goat-chunk-PFWIMH2E.mjs} +23 -15
  99. package/dist/token-goat-chunk-PJZXIS3G.mjs +39 -0
  100. package/dist/token-goat-chunk-PUO5INXP.mjs +606 -0
  101. package/dist/{token-goat-chunk-GFBSN7BD.mjs → token-goat-chunk-PX5PQWTY.mjs} +22 -250
  102. package/dist/token-goat-chunk-Q5QDBC6O.mjs +111 -0
  103. package/dist/token-goat-chunk-QFNQXSDT.mjs +40 -0
  104. package/dist/{token-goat-chunk-FBNQNSJK.mjs → token-goat-chunk-QH7YVYOY.mjs} +2198 -2782
  105. package/dist/{token-goat-chunk-64FBPDTK.mjs → token-goat-chunk-QLMUHEPB.mjs} +12 -9
  106. package/dist/{token-goat-chunk-RZRTDST7.mjs → token-goat-chunk-QQOJIHL3.mjs} +37 -11
  107. package/dist/{token-goat-chunk-XKI4SEMX.mjs → token-goat-chunk-QQTWJY2O.mjs} +19 -0
  108. package/dist/{token-goat-chunk-U4N3BN2W.mjs → token-goat-chunk-QYHO5CPH.mjs} +3 -2
  109. package/dist/token-goat-chunk-RELAVWAD.mjs +27 -0
  110. package/dist/{token-goat-chunk-ETBHVDB6.mjs → token-goat-chunk-RSLPOBKQ.mjs} +22 -11
  111. package/dist/token-goat-chunk-SAMFDIS2.mjs +712 -0
  112. package/dist/token-goat-chunk-SDELXLDM.mjs +48 -0
  113. package/dist/{token-goat-chunk-4JJS54TR.mjs → token-goat-chunk-SOAFZNNZ.mjs} +161 -38
  114. package/dist/{token-goat-chunk-664RTTUV.mjs → token-goat-chunk-SRTHT7KV.mjs} +21 -16
  115. package/dist/{token-goat-chunk-4FVIAHSI.mjs → token-goat-chunk-T5P5ACNQ.mjs} +7 -6
  116. package/dist/token-goat-chunk-T5YGG4V3.mjs +45 -0
  117. package/dist/token-goat-chunk-TAUZ4OFS.mjs +110 -0
  118. package/dist/{token-goat-chunk-COTXZHTS.mjs → token-goat-chunk-TM6MC754.mjs} +4 -3
  119. package/dist/token-goat-chunk-TWUKBOMP.mjs +72 -0
  120. package/dist/{token-goat-chunk-3CHUNJ2O.mjs → token-goat-chunk-U2KSB4SG.mjs} +8 -5
  121. package/dist/{token-goat-chunk-3Z5S4KGM.mjs → token-goat-chunk-U4WHMG6Y.mjs} +29 -49
  122. package/dist/{token-goat-chunk-PY533T7F.mjs → token-goat-chunk-UGJHGR5A.mjs} +21 -15
  123. package/dist/{token-goat-chunk-CYCEYAEO.mjs → token-goat-chunk-UOUDVA5U.mjs} +1 -1
  124. package/dist/{token-goat-chunk-JDHE26RP.mjs → token-goat-chunk-URRJ33GR.mjs} +16 -5
  125. package/dist/{token-goat-chunk-56EIMS3E.mjs → token-goat-chunk-UZOROKIS.mjs} +23 -17
  126. package/dist/{token-goat-chunk-CZ3LUXYZ.mjs → token-goat-chunk-VIHGGGEI.mjs} +427 -308
  127. package/dist/token-goat-chunk-VTJLAA7P.mjs +21 -0
  128. package/dist/token-goat-chunk-VWDXLT4F.mjs +678 -0
  129. package/dist/{token-goat-chunk-YARZFCZS.mjs → token-goat-chunk-VWZA2H4P.mjs} +62 -53
  130. package/dist/{token-goat-chunk-SQSSNQPE.mjs → token-goat-chunk-VXEXMJDL.mjs} +3979 -4745
  131. package/dist/token-goat-chunk-WBA5SKT4.mjs +547 -0
  132. package/dist/{token-goat-chunk-SJHWVNDQ.mjs → token-goat-chunk-WDH44VAU.mjs} +7 -4
  133. package/dist/token-goat-chunk-X2SUP3EI.mjs +107 -0
  134. package/dist/token-goat-chunk-X3BELZSJ.mjs +125 -0
  135. package/dist/{token-goat-chunk-FZ3NEW5O.mjs → token-goat-chunk-XLRBNZCC.mjs} +13 -8
  136. package/dist/{token-goat-chunk-Z44YO3QZ.mjs → token-goat-chunk-XRKUX6CM.mjs} +1 -1
  137. package/dist/token-goat-chunk-XX6O25RN.mjs +82 -0
  138. package/dist/token-goat-chunk-XZSUHBVS.mjs +65 -0
  139. package/dist/{token-goat-chunk-WY3L4DVT.mjs → token-goat-chunk-Y2ZTQOCL.mjs} +13 -8
  140. package/dist/{token-goat-chunk-UQ5UK2T7.mjs → token-goat-chunk-YB4VMGK2.mjs} +1 -1
  141. package/dist/token-goat-chunk-YBIIY3HR.mjs +51 -0
  142. package/dist/{token-goat-chunk-ZQSJMO2R.mjs → token-goat-chunk-YHVDKQBR.mjs} +105 -105
  143. package/dist/{token-goat-chunk-H2K3QP6H.mjs → token-goat-chunk-YJB5XLWI.mjs} +8 -6
  144. package/dist/{token-goat-chunk-ZCDTCVIS.mjs → token-goat-chunk-YKB6AQG3.mjs} +5 -2
  145. package/dist/token-goat-chunk-YMTG2YA5.mjs +35 -0
  146. package/dist/token-goat-chunk-YPBZYQRV.mjs +40 -0
  147. package/dist/{token-goat-chunk-HOJLCGDP.mjs → token-goat-chunk-YY6AVUFL.mjs} +2033 -2251
  148. package/dist/token-goat-chunk-Z7N5OMMP.mjs +98 -0
  149. package/dist/token-goat-chunk-ZNMNUPAZ.mjs +938 -0
  150. package/dist/token-goat-hook-client.cjs +1 -1
  151. package/dist/token-goat-hook-client.mjs +3 -3
  152. package/dist/token-goat-hook.mjs +67 -38
  153. package/dist/token-goat.core.mjs +4 -4
  154. package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
  155. package/docs/cli.md +40 -21
  156. package/docs/install.md +19 -9
  157. package/docs/security.md +5 -3
  158. package/package.json +2 -1
  159. package/dist/token-goat-chunk-5KDMCMF2.mjs +0 -362
  160. package/dist/token-goat-chunk-6QMAS7AB.mjs +0 -42
  161. package/dist/token-goat-chunk-7F2UBPD3.mjs +0 -397
  162. package/dist/token-goat-chunk-ARDNEC2U.mjs +0 -248
  163. package/dist/token-goat-chunk-ATCPY7EQ.mjs +0 -134
  164. package/dist/token-goat-chunk-EFHMMIGP.mjs +0 -68
  165. package/dist/token-goat-chunk-IVALLT3S.mjs +0 -48
  166. package/dist/token-goat-chunk-JDU3EXSU.mjs +0 -65
  167. package/dist/token-goat-chunk-MKPF4CL5.mjs +0 -37
  168. package/dist/token-goat-chunk-RC35RBUL.mjs +0 -312
  169. package/dist/token-goat-chunk-USILZ3T3.mjs +0 -53
  170. package/dist/token-goat-chunk-VL3YIFHZ.mjs +0 -2975
  171. package/dist/token-goat-chunk-XU4P6Z24.mjs +0 -133
  172. package/dist/token-goat-chunk-Y776AENC.mjs +0 -1597
@@ -1,96 +1,25 @@
1
1
  import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
- getToolName
5
- } from "./token-goat-chunk-VPBBTSJR.mjs";
6
- import {
7
- countSymbols
8
- } from "./token-goat-chunk-HYBFA5X3.mjs";
4
+ CliError,
5
+ formatCommandError,
6
+ formatFailedResultText
7
+ } from "./token-goat-chunk-CBIQ7WTD.mjs";
9
8
  import {
10
- getDb
11
- } from "./token-goat-chunk-VL3YIFHZ.mjs";
9
+ getToolName
10
+ } from "./token-goat-chunk-76FGDLRO.mjs";
12
11
  import {
13
- compileGuardedRegex,
14
- extractErrorMessage
15
- } from "./token-goat-chunk-GOLEOXZP.mjs";
12
+ echoedValue,
13
+ fencedCommand,
14
+ quotedArg
15
+ } from "./token-goat-chunk-GGGG7RWB.mjs";
16
16
  import {
17
17
  displaySafeJson
18
18
  } from "./token-goat-chunk-FNFBKLRD.mjs";
19
- import {
20
- SYMBOL_BODY_CHAR_CAP,
21
- globalDbPath
22
- } from "./token-goat-chunk-VES7EL7O.mjs";
23
19
  import {
24
20
  init_define_import_meta_env
25
21
  } from "./token-goat-chunk-A37V4PBF.mjs";
26
22
 
27
- // src/stdin_json.ts
28
- init_define_import_meta_env();
29
- var DEFAULT_STDIN_TIMEOUT_MS = 5e3;
30
- var MAX_STDIN_WALL_MS = 6e4;
31
- var MAX_STDIN_BYTES = 64 * 1024 * 1024;
32
- function readStdinJson(timeoutMs = DEFAULT_STDIN_TIMEOUT_MS, maxBytes = MAX_STDIN_BYTES) {
33
- return new Promise((resolve2, reject) => {
34
- const chunks = [];
35
- let totalBytes = 0;
36
- let settled = false;
37
- const finish = (fn) => {
38
- if (settled) return;
39
- settled = true;
40
- clearTimeout(idleTimer);
41
- clearTimeout(wallTimer);
42
- process.stdin.removeListener("data", onData);
43
- process.stdin.removeListener("end", onEnd);
44
- process.stdin.removeListener("error", onError);
45
- fn();
46
- };
47
- let idleTimer = setTimeout(() => {
48
- finish(() => reject(new Error("readStdinJson: timed out waiting for stdin")));
49
- }, timeoutMs);
50
- const wallTimer = setTimeout(() => {
51
- finish(() => {
52
- process.stdin.destroy();
53
- reject(new Error(`readStdinJson: stdin took longer than ${MAX_STDIN_WALL_MS} ms`));
54
- });
55
- }, MAX_STDIN_WALL_MS);
56
- const onData = (chunk) => {
57
- clearTimeout(idleTimer);
58
- idleTimer = setTimeout(() => {
59
- finish(() => reject(new Error("readStdinJson: timed out waiting for stdin")));
60
- }, timeoutMs);
61
- totalBytes += chunk.length;
62
- if (totalBytes > maxBytes) {
63
- finish(() => {
64
- process.stdin.destroy();
65
- reject(new Error(`readStdinJson: stdin exceeded ${maxBytes} bytes`));
66
- });
67
- return;
68
- }
69
- chunks.push(chunk);
70
- };
71
- const onEnd = () => {
72
- finish(() => {
73
- const text = Buffer.concat(chunks).toString("utf8").trim();
74
- if (text === "") {
75
- reject(new Error("readStdinJson: empty stdin"));
76
- return;
77
- }
78
- try {
79
- resolve2(JSON.parse(text));
80
- } catch (err) {
81
- reject(err instanceof Error ? err : new Error(String(err)));
82
- }
83
- });
84
- };
85
- const onError = (err) => {
86
- finish(() => reject(err instanceof Error ? err : new Error(String(err))));
87
- };
88
- process.stdin.on("data", onData);
89
- process.stdin.on("end", onEnd);
90
- process.stdin.on("error", onError);
91
- });
92
- }
93
-
94
23
  // src/session_store_schema.ts
95
24
  init_define_import_meta_env();
96
25
  import { existsSync } from "node:fs";
@@ -439,46 +368,14 @@ async function describeTarget(target, table, opts) {
439
368
  }
440
369
  const absPath = resolve(process.cwd(), target);
441
370
  if (existsSync(absPath)) {
442
- try {
443
- const { isSqliteFile, getSqliteSchema, formatSqliteSchema } = await import("./token-goat-chunk-T4FK7VOV.mjs");
444
- if (isSqliteFile(absPath)) {
445
- const schema = getSqliteSchema(absPath);
446
- if (table) {
447
- const found = schema.tables.find((t) => t.name.toLowerCase() === table.toLowerCase());
448
- if (!found) {
449
- const avail2 = schema.tables.map((t) => t.name).join(", ");
450
- return { exitCode: 1, text: `Table '${table}' not found in SQLite database ${target}. Available tables: ${avail2}` };
451
- }
452
- if (opts?.json === true) {
453
- return { exitCode: 0, text: displaySafeJson(found) };
454
- }
455
- const lines = [
456
- `# SQLite Table: ${found.name} (${found.kind}) in ${target}`,
457
- `Row Count: ${found.rowCount ?? "unknown"}`,
458
- "",
459
- "| Column | Type | Nullable | Default | PK |",
460
- "| :--- | :--- | :--- | :--- | :--- |"
461
- ];
462
- for (const col of found.columns) {
463
- lines.push(`| \`${col.name}\` | \`${col.type}\` | ${col.notNull ? "NO" : "YES"} | ${col.defaultValue ?? "NULL"} | ${col.primaryKey ? "YES" : "NO"} |`);
464
- }
465
- if (found.createSql !== void 0) lines.push("", `Module ${found.module ?? "?"} is not loaded here, so columns are not available. Declared as:`, found.createSql);
466
- return { exitCode: 0, text: lines.join("\n") };
467
- }
468
- if (opts?.json === true) {
469
- return { exitCode: 0, text: displaySafeJson(schema) };
470
- }
471
- return { exitCode: 0, text: formatSqliteSchema(schema) };
472
- }
473
- } catch (err) {
474
- return { exitCode: 1, text: `Error reading SQLite database ${target}: ${err instanceof Error ? err.message : String(err)}` };
475
- }
371
+ const sqliteResult = await (await import("./token-goat-chunk-OBRFJ5O5.mjs")).describeSqliteFile(target, absPath, table, opts?.json === true);
372
+ if (sqliteResult !== void 0) return sqliteResult;
476
373
  }
477
374
  const avail = SESSION_STORE_TABLES.map((t) => t.name).join(", ");
478
375
  return {
479
376
  exitCode: 1,
480
- text: `Unknown table or SQLite file '${target}'. Available session store tables: ${avail}
481
- Run 'token-goat session-schema' to see all tables.`
377
+ text: `Unknown table or SQLite file ${echoedValue(target)}. Available session store tables: ${avail}
378
+ Run \`token-goat session-schema\` to see all tables.`
482
379
  };
483
380
  }
484
381
  function diagnoseSqlFailure(event, errorText) {
@@ -508,13 +405,13 @@ function diagnoseSqlFailure(event, errorText) {
508
405
  }
509
406
  if (matchedTable) {
510
407
  const validCols = matchedTable.columns.map((c) => c.name).join(", ");
511
- let advice = `[token-goat] Table '${matchedTable.name}' has columns: ${validCols}.`;
408
+ let advice = `[token-goat] Table ${echoedValue(matchedTable.name)} has columns: ${validCols}.`;
512
409
  if (badCol && matchedTable.commonMisnomers && matchedTable.commonMisnomers[badCol]) {
513
- advice += ` (For '${badCol}', use ${matchedTable.commonMisnomers[badCol]}).`;
410
+ advice += ` (For ${echoedValue(badCol)}, use ${matchedTable.commonMisnomers[badCol]}).`;
514
411
  } else if (badCol) {
515
- advice += ` (Column '${badCol}' does not exist on '${matchedTable.name}').`;
412
+ advice += ` (Column ${echoedValue(badCol)} does not exist on ${echoedValue(matchedTable.name)}).`;
516
413
  }
517
- advice += ` Run 'token-goat session-schema ${matchedTable.name}' to inspect full table structure.`;
414
+ advice += ` Run ${fencedCommand("token-goat session-schema " + quotedArg(matchedTable.name))} to inspect full table structure.`;
518
415
  return advice;
519
416
  }
520
417
  if (isTableError) {
@@ -524,7 +421,7 @@ function diagnoseSqlFailure(event, errorText) {
524
421
  return null;
525
422
  }
526
423
  const knownTables = SESSION_STORE_TABLES.map((t) => t.name).join(", ");
527
- return `[token-goat] ${badTable ? `Table '${badTable}' does not exist.` : "Table not found."} Available session store tables: ${knownTables}. Run 'token-goat session-schema' for schema details.`;
424
+ return `[token-goat] ${badTable ? `Table ${echoedValue(badTable)} does not exist.` : "Table not found."} Available session store tables: ${knownTables}. Run \`token-goat session-schema\` for schema details.`;
528
425
  }
529
426
  return null;
530
427
  }
@@ -536,9 +433,7 @@ function runSessionSchema(opts) {
536
433
  const found = getSessionStoreTable(opts.table);
537
434
  if (!found) {
538
435
  const avail = SESSION_STORE_TABLES.map((t) => t.name).join(", ");
539
- process.stderr.write(`Unknown session store table '${opts.table}'. Available tables: ${avail}
540
- Run 'token-goat session-schema' to see all tables.
541
- `);
436
+ process.stderr.write(formatCommandError(new CliError([`Unknown session store table ${echoedValue(opts.table)}. Available tables: ${avail}`, "Run `token-goat session-schema` to see all tables."])) + "\n");
542
437
  return 1;
543
438
  }
544
439
  process.stdout.write(formatSessionStoreTable(found, { json: opts.json }) + "\n");
@@ -547,7 +442,7 @@ Run 'token-goat session-schema' to see all tables.
547
442
  async function runDescribe(opts) {
548
443
  const result = await describeTarget(opts.target, opts.table, { json: opts.json });
549
444
  if (result.exitCode !== 0) {
550
- process.stderr.write(result.text + "\n");
445
+ process.stderr.write(formatFailedResultText(result.text) + "\n");
551
446
  } else {
552
447
  process.stdout.write(result.text + "\n");
553
448
  }
@@ -560,131 +455,8 @@ async function cmdDescribe(target, table, opts) {
560
455
  process.exitCode = await runDescribe({ target, table, json: opts?.json });
561
456
  }
562
457
 
563
- // src/cli_commands.ts
564
- init_define_import_meta_env();
565
- function toEntry(cmd) {
566
- return {
567
- name: cmd.name(),
568
- description: cmd.description(),
569
- aliases: cmd.aliases(),
570
- options: cmd.options.map((o) => ({ flags: o.flags, description: o.description })),
571
- arguments: cmd.registeredArguments.map((a) => ({ name: a.name(), description: a.description, required: a.required })),
572
- subcommands: cmd.commands.filter((sub) => sub.name() !== "help").map(toEntry)
573
- };
574
- }
575
- function buildCommandManifest(program) {
576
- return program.commands.filter((cmd) => cmd.name() !== "help").map(toEntry);
577
- }
578
- function flattenCommandNames(manifest) {
579
- const names = [];
580
- for (const entry of manifest) {
581
- names.push(entry.name);
582
- for (const sub of entry.subcommands) {
583
- names.push(`${entry.name} ${sub.name}`);
584
- }
585
- }
586
- return names;
587
- }
588
- function entryMatches(entry, re, pattern) {
589
- const haystacks = [entry.name, entry.description, ...entry.aliases];
590
- return haystacks.some((h) => re !== null ? re.test(h) : h.includes(pattern));
591
- }
592
- function filterCommandManifest(manifest, pattern) {
593
- const guarded = compileGuardedRegex(pattern);
594
- const re = guarded.ok ? guarded.re : null;
595
- const result = [];
596
- for (const entry of manifest) {
597
- if (entryMatches(entry, re, pattern)) {
598
- result.push(entry);
599
- continue;
600
- }
601
- const matchingSubs = entry.subcommands.filter((sub) => entryMatches(sub, re, pattern));
602
- if (matchingSubs.length > 0) {
603
- result.push({ ...entry, subcommands: matchingSubs });
604
- }
605
- }
606
- return result;
607
- }
608
- function formatCommandManifest(manifest) {
609
- const lines = [];
610
- lines.push("# token-goat commands");
611
- lines.push("");
612
- for (const entry of manifest) {
613
- lines.push(`## ${entry.name}${entry.aliases.length ? " (alias: " + entry.aliases.join(", ") + ")" : ""}${entry.description ? " -- " + entry.description : ""}`);
614
- for (const arg of entry.arguments) {
615
- lines.push(` arg: ${arg.name}${arg.required ? "" : " (optional)"}${arg.description ? " -- " + arg.description : ""}`);
616
- }
617
- for (const opt of entry.options) {
618
- lines.push(` ${opt.flags}${opt.description ? " -- " + opt.description : ""}`);
619
- }
620
- for (const sub of entry.subcommands) {
621
- lines.push(` ${entry.name} ${sub.name}${sub.description ? " -- " + sub.description : ""}`);
622
- }
623
- lines.push("");
624
- }
625
- return lines.join("\n").trimEnd();
626
- }
627
-
628
- // src/symbol_body_probe.ts
629
- init_define_import_meta_env();
630
- import * as fs from "fs";
631
- var OVERSIZED_BODY_PROBE_SQL = `SELECT 1 FROM symbols WHERE LENGTH(body) > ${SYMBOL_BODY_CHAR_CAP} LIMIT 1`;
632
- function checkSymbolBodySize(dbPath) {
633
- if (!fs.existsSync(dbPath)) {
634
- return { name: "Symbol body size", status: "ok", message: "no database yet" };
635
- }
636
- try {
637
- const db = getDb(dbPath);
638
- const row = db.prepare(OVERSIZED_BODY_PROBE_SQL).get();
639
- if (row !== void 0) {
640
- return {
641
- name: "Symbol body size",
642
- status: "warn",
643
- message: `one or more stored symbol bodies exceed the ${SYMBOL_BODY_CHAR_CAP}-char cap enforced by boundSymbolBody -- likely a pre-fix leftover from a minified/generated file. A plain 'token-goat reclaim-index' (VACUUM only) CANNOT remove these rows -- it only reclaims freed pages, it never deletes row content. Only 'token-goat reclaim-index --rebuild' drops and re-derives them under the cap (stop the worker first with 'token-goat worker stop', since reclaim-index refuses to run while it's live); --rebuild reparses and re-embeds every indexed file across every project and can take a long time on a large multi-project index`
644
- };
645
- }
646
- return { name: "Symbol body size", status: "ok", message: "no stored symbol body exceeds the cap" };
647
- } catch (err) {
648
- return {
649
- name: "Symbol body size",
650
- status: "warn",
651
- message: `could not query symbol body size: ${extractErrorMessage(err)}`
652
- };
653
- }
654
- }
655
-
656
- // src/session_reminder.ts
657
- init_define_import_meta_env();
658
- var GENERIC_REMINDER = 'token-goat: prefer surgical reads over the Read/Grep tools on this codebase; shell commands like `rg`, `grep`, `fd`, `sed`, `cat`, `find`, and `ls` are just commands, not tool names -- `token-goat symbol <name>`, `token-goat read "file::symbol"`, `token-goat section "file::Heading"`, `token-goat semantic "description"`, `token-goat outline <file>`. Run `token-goat index .` if this project is not indexed yet.';
659
- var INDEXED_REMINDER = 'token-goat: this project is indexed. Prefer `symbol <name>`, `read "file::symbol"`, `section "file::Heading"`, `semantic "description"`, or `outline <file>` over a full Read/Grep tool call; for JSON/YAML use `json-query file \'a.b.c\'` or `yaml-query` (nested keys are not symbols); shell commands like `rg`, `grep`, `fd`, `sed`, `cat`, `find`, and `ls` are still just commands.';
660
- var NOTE_REMINDER = ' Record a finding that must outlive a compaction with `token-goat note set <key> "<finding>"`; notes come back at every session start.';
661
- function isIndexedProject(cwd) {
662
- if (cwd === void 0) return false;
663
- try {
664
- return countSymbols({ rootDir: cwd }, globalDbPath()) > 0;
665
- } catch {
666
- return false;
667
- }
668
- }
669
- function buildReminder(indexed) {
670
- return (indexed ? INDEXED_REMINDER : GENERIC_REMINDER) + NOTE_REMINDER;
671
- }
672
-
673
- // src/mcp_tool_pattern.ts
674
- init_define_import_meta_env();
675
- var MCP_TOOL_PATTERN = "^mcp__";
676
-
677
458
  export {
678
- readStdinJson,
679
459
  diagnoseSqlFailure,
680
460
  cmdSessionSchema,
681
- cmdDescribe,
682
- buildCommandManifest,
683
- flattenCommandNames,
684
- filterCommandManifest,
685
- formatCommandManifest,
686
- checkSymbolBodySize,
687
- isIndexedProject,
688
- buildReminder,
689
- MCP_TOOL_PATTERN
461
+ cmdDescribe
690
462
  };
@@ -0,0 +1,111 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ init_define_import_meta_env
5
+ } from "./token-goat-chunk-A37V4PBF.mjs";
6
+
7
+ // src/stdin_json.ts
8
+ init_define_import_meta_env();
9
+ var DEFAULT_STDIN_TIMEOUT_MS = 5e3;
10
+ var FIRST_BYTE_GRACE_FACTOR = 4;
11
+ var IDLE_CONFIRM_MS = 50;
12
+ var MAX_STDIN_WALL_MS = 6e4;
13
+ var MAX_STDIN_BYTES = 64 * 1024 * 1024;
14
+ function completeDocument(chunks) {
15
+ const text = Buffer.concat(chunks).toString("utf8").trim();
16
+ if (!text.startsWith("{") && !text.startsWith("[")) return void 0;
17
+ try {
18
+ const value = JSON.parse(text);
19
+ return typeof value === "object" && value !== null ? { value } : void 0;
20
+ } catch {
21
+ return void 0;
22
+ }
23
+ }
24
+ function readStdinJson(timeoutMs = DEFAULT_STDIN_TIMEOUT_MS, maxBytes = MAX_STDIN_BYTES, firstByteGraceFactor = FIRST_BYTE_GRACE_FACTOR) {
25
+ return new Promise((resolve, reject) => {
26
+ const chunks = [];
27
+ let totalBytes = 0;
28
+ let settled = false;
29
+ const finish = (fn) => {
30
+ if (settled) return;
31
+ settled = true;
32
+ clearTimeout(idleTimer);
33
+ clearTimeout(wallTimer);
34
+ process.stdin.removeListener("data", onData);
35
+ process.stdin.removeListener("end", onEnd);
36
+ process.stdin.removeListener("error", onError);
37
+ fn();
38
+ };
39
+ const confirmSilence = (confirmMs) => {
40
+ const seen = totalBytes;
41
+ const armedAt = performance.now();
42
+ idleTimer = setTimeout(() => {
43
+ setImmediate(() => {
44
+ if (totalBytes !== seen) return;
45
+ if (performance.now() - armedAt > confirmMs * 2) {
46
+ confirmSilence(confirmMs);
47
+ return;
48
+ }
49
+ finish(() => {
50
+ const done = completeDocument(chunks);
51
+ if (done !== void 0) resolve(done.value);
52
+ else reject(new Error("readStdinJson: timed out waiting for stdin"));
53
+ });
54
+ });
55
+ }, confirmMs);
56
+ };
57
+ const armIdle = (ms = timeoutMs) => {
58
+ const confirmMs = Math.min(IDLE_CONFIRM_MS, Math.floor(ms / 2));
59
+ return setTimeout(() => confirmSilence(confirmMs), ms - confirmMs);
60
+ };
61
+ let idleTimer = armIdle(timeoutMs * firstByteGraceFactor);
62
+ const wallTimer = setTimeout(() => {
63
+ finish(() => {
64
+ process.stdin.destroy();
65
+ reject(new Error(`readStdinJson: stdin took longer than ${MAX_STDIN_WALL_MS} ms`));
66
+ });
67
+ }, MAX_STDIN_WALL_MS);
68
+ const onData = (chunk) => {
69
+ clearTimeout(idleTimer);
70
+ idleTimer = armIdle();
71
+ totalBytes += chunk.length;
72
+ if (totalBytes > maxBytes) {
73
+ finish(() => {
74
+ process.stdin.destroy();
75
+ reject(new Error(`readStdinJson: stdin exceeded ${maxBytes} bytes`));
76
+ });
77
+ return;
78
+ }
79
+ chunks.push(chunk);
80
+ };
81
+ const onEnd = () => {
82
+ finish(() => {
83
+ const text = Buffer.concat(chunks).toString("utf8").trim();
84
+ if (text === "") {
85
+ reject(new Error("readStdinJson: empty stdin"));
86
+ return;
87
+ }
88
+ try {
89
+ resolve(JSON.parse(text));
90
+ } catch (err) {
91
+ reject(err instanceof Error ? err : new Error(String(err)));
92
+ }
93
+ });
94
+ };
95
+ const onError = (err) => {
96
+ finish(() => reject(err instanceof Error ? err : new Error(String(err))));
97
+ };
98
+ process.stdin.on("data", onData);
99
+ process.stdin.on("end", onEnd);
100
+ process.stdin.on("error", onError);
101
+ });
102
+ }
103
+
104
+ // src/mcp_tool_pattern.ts
105
+ init_define_import_meta_env();
106
+ var MCP_TOOL_PATTERN = "^mcp__";
107
+
108
+ export {
109
+ readStdinJson,
110
+ MCP_TOOL_PATTERN
111
+ };
@@ -0,0 +1,40 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ evaluateVerification,
5
+ exitStatusIsCheckVerdict,
6
+ isVerificationCommand,
7
+ noteFailedVerificationRun,
8
+ noteVerificationRun
9
+ } from "./token-goat-chunk-2WLPWKHV.mjs";
10
+ import "./token-goat-chunk-WBA5SKT4.mjs";
11
+ import "./token-goat-chunk-KQBLRPBN.mjs";
12
+ import "./token-goat-chunk-4ZBFWLXF.mjs";
13
+ import "./token-goat-chunk-GL3ETKSC.mjs";
14
+ import "./token-goat-chunk-IK2DRMFX.mjs";
15
+ import "./token-goat-chunk-U4WHMG6Y.mjs";
16
+ import "./token-goat-chunk-GVB2MUST.mjs";
17
+ import "./token-goat-chunk-XB5KKOCG.mjs";
18
+ import "./token-goat-chunk-OUKDTVNU.mjs";
19
+ import "./token-goat-chunk-4GILLLWY.mjs";
20
+ import "./token-goat-chunk-XX6O25RN.mjs";
21
+ import "./token-goat-chunk-HAVAOB3S.mjs";
22
+ import "./token-goat-chunk-T5P5ACNQ.mjs";
23
+ import "./token-goat-chunk-7EZTZOMC.mjs";
24
+ import "./token-goat-chunk-QYHO5CPH.mjs";
25
+ import "./token-goat-chunk-4GBVPH3D.mjs";
26
+ import "./token-goat-chunk-YZAAZU2S.mjs";
27
+ import "./token-goat-chunk-IVE6U7KV.mjs";
28
+ import "./token-goat-chunk-HU4TORC5.mjs";
29
+ import "./token-goat-chunk-GGGG7RWB.mjs";
30
+ import "./token-goat-chunk-AM5V6GSX.mjs";
31
+ import "./token-goat-chunk-FNFBKLRD.mjs";
32
+ import "./token-goat-chunk-CO3UYX6G.mjs";
33
+ import "./token-goat-chunk-A37V4PBF.mjs";
34
+ export {
35
+ evaluateVerification,
36
+ exitStatusIsCheckVerdict,
37
+ isVerificationCommand,
38
+ noteFailedVerificationRun,
39
+ noteVerificationRun
40
+ };