token-goat 2.9.28 → 2.9.30

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 (134) hide show
  1. package/README.md +36 -40
  2. package/SECURITY.md +28 -10
  3. package/THIRD_PARTY_NOTICES.md +40 -3
  4. package/dist/native/linux-arm64/tg-hook +0 -0
  5. package/dist/native/linux-x64/tg-hook +0 -0
  6. package/dist/ort-wasm-simd-threaded.mjs +59 -0
  7. package/dist/token-goat-chunk-3CHUNJ2O.mjs +53 -0
  8. package/dist/token-goat-chunk-3Z5S4KGM.mjs +918 -0
  9. package/dist/token-goat-chunk-4FVIAHSI.mjs +211 -0
  10. package/dist/{token-goat-chunk-66LODAUT.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
  11. package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
  12. package/dist/token-goat-chunk-54K3EUV3.mjs +35 -0
  13. package/dist/token-goat-chunk-56EIMS3E.mjs +159 -0
  14. package/dist/token-goat-chunk-5BCIJXMO.mjs +609 -0
  15. package/dist/token-goat-chunk-5KDMCMF2.mjs +362 -0
  16. package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
  17. package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
  18. package/dist/{token-goat-chunk-NILVK7XM.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -6
  19. package/dist/{token-goat-chunk-LEG3JNJ6.mjs → token-goat-chunk-664RTTUV.mjs} +31 -15
  20. package/dist/token-goat-chunk-67TQJ76B.mjs +57 -0
  21. package/dist/token-goat-chunk-6QMAS7AB.mjs +42 -0
  22. package/dist/token-goat-chunk-7BXSNBY5.mjs +253 -0
  23. package/dist/{token-goat-chunk-F7QZRIWM.mjs → token-goat-chunk-7F2UBPD3.mjs} +42 -35
  24. package/dist/{token-goat-chunk-CC2PYJM7.mjs → token-goat-chunk-7IN2MKDS.mjs} +718 -595
  25. package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
  26. package/dist/{token-goat-chunk-6SGLIPQB.mjs → token-goat-chunk-A3CK6N5Z.mjs} +621 -72
  27. package/dist/{token-goat-chunk-HXNAC4ZF.mjs → token-goat-chunk-AFLYLHDH.mjs} +48 -33
  28. package/dist/token-goat-chunk-AM5V6GSX.mjs +367 -0
  29. package/dist/{token-goat-chunk-I7CB3X4K.mjs → token-goat-chunk-APGZXSPS.mjs} +44 -148
  30. package/dist/{token-goat-chunk-BJBRGPBX.mjs → token-goat-chunk-ARDNEC2U.mjs} +11 -7
  31. package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
  32. package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
  33. package/dist/{token-goat-chunk-QM76S6YS.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -5
  34. package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
  35. package/dist/{token-goat-chunk-GGLEE35R.mjs → token-goat-chunk-C63JQV5K.mjs} +49 -10
  36. package/dist/{token-goat-chunk-RJH64KQH.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
  37. package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
  38. package/dist/token-goat-chunk-CYCEYAEO.mjs +265 -0
  39. package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
  40. package/dist/token-goat-chunk-DZX2YDPT.mjs +15 -0
  41. package/dist/token-goat-chunk-E3OQX2XT.mjs +824 -0
  42. package/dist/token-goat-chunk-EFHMMIGP.mjs +68 -0
  43. package/dist/token-goat-chunk-ETBHVDB6.mjs +328 -0
  44. package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
  45. package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
  46. package/dist/{token-goat-chunk-6Z5ULNE5.mjs → token-goat-chunk-FBNQNSJK.mjs} +2490 -4957
  47. package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
  48. package/dist/{token-goat-chunk-XI2VFAV6.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
  49. package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
  50. package/dist/{token-goat-chunk-VE27HPIF.mjs → token-goat-chunk-GFBSN7BD.mjs} +30 -398
  51. package/dist/{token-goat-chunk-L45ZQRT7.mjs → token-goat-chunk-GOLEOXZP.mjs} +780 -786
  52. package/dist/token-goat-chunk-H2K3QP6H.mjs +24 -0
  53. package/dist/token-goat-chunk-H2PHHGM5.mjs +188 -0
  54. package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
  55. package/dist/token-goat-chunk-HG45AF2B.mjs +2228 -0
  56. package/dist/{token-goat-chunk-CBMY2FGI.mjs → token-goat-chunk-HOJLCGDP.mjs} +17113 -15554
  57. package/dist/{token-goat-chunk-HUDC5GS5.mjs → token-goat-chunk-HYBFA5X3.mjs} +120 -19
  58. package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
  59. package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
  60. package/dist/{token-goat-chunk-UBUKHVYW.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
  61. package/dist/{token-goat-chunk-4JMWPWCS.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
  62. package/dist/{token-goat-chunk-Q4S3UQGO.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
  63. package/dist/{token-goat-chunk-7R2XYKC5.mjs → token-goat-chunk-JDU3EXSU.mjs} +14 -10
  64. package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
  65. package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-JN4XMLSD.mjs} +7 -4
  66. package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
  67. package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
  68. package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
  69. package/dist/{token-goat-chunk-4RN64ZND.mjs → token-goat-chunk-KWPNJBDH.mjs} +28 -3
  70. package/dist/token-goat-chunk-LOBGHXPB.mjs +242 -0
  71. package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
  72. package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
  73. package/dist/{token-goat-chunk-YWSP6IU7.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
  74. package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
  75. package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
  76. package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
  77. package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
  78. package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
  79. package/dist/{token-goat-chunk-VWZKZPSR.mjs → token-goat-chunk-PU7V3FD6.mjs} +8752 -11098
  80. package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
  81. package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
  82. package/dist/{token-goat-chunk-IHKZ3QNA.mjs → token-goat-chunk-QCLDAQTS.mjs} +33 -19
  83. package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
  84. package/dist/{token-goat-chunk-4STDIGYC.mjs → token-goat-chunk-RC35RBUL.mjs} +7 -5
  85. package/dist/{token-goat-chunk-D5ICEPSB.mjs → token-goat-chunk-RHXKCZX3.mjs} +887 -507
  86. package/dist/{token-goat-chunk-RSS3TLXU.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
  87. package/dist/{token-goat-chunk-MAMQPC43.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
  88. package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
  89. package/dist/{token-goat-chunk-EL7M26WP.mjs → token-goat-chunk-SQSSNQPE.mjs} +2100 -1442
  90. package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-T4FK7VOV.mjs} +3 -3
  91. package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
  92. package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
  93. package/dist/{token-goat-chunk-XKY4VKJ4.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
  94. package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
  95. package/dist/token-goat-chunk-VES7EL7O.mjs +205 -0
  96. package/dist/{token-goat-chunk-M56BWPBN.mjs → token-goat-chunk-VL3YIFHZ.mjs} +550 -49
  97. package/dist/{token-goat-chunk-IZXKVT4A.mjs → token-goat-chunk-VPBBTSJR.mjs} +362 -128
  98. package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
  99. package/dist/{token-goat-chunk-FSTWAOW6.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -5
  100. package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
  101. package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
  102. package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
  103. package/dist/{token-goat-chunk-6CCQDAYY.mjs → token-goat-chunk-Y776AENC.mjs} +138 -33
  104. package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
  105. package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
  106. package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-Z44YO3QZ.mjs} +12 -6
  107. package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
  108. package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-ZCDTCVIS.mjs} +49 -30
  109. package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -0
  110. package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
  111. package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
  112. package/dist/{token-goat-chunk-SJEKA7Y2.mjs → token-goat-chunk-ZQSJMO2R.mjs} +381 -201
  113. package/dist/token-goat-hook-client.cjs +539 -0
  114. package/dist/token-goat-hook-client.mjs +26 -0
  115. package/dist/token-goat-hook.mjs +48 -28
  116. package/dist/token-goat.core.mjs +10 -45
  117. package/docs/C4_RUNTIME_ARCHITECTURE.md +3 -3
  118. package/docs/cli.md +82 -47
  119. package/docs/install.md +58 -23
  120. package/docs/security.md +7 -7
  121. package/package.json +17 -7
  122. package/scripts/verify-native-dist.mjs +386 -0
  123. package/dist/token-goat-chunk-4JJBFT7V.mjs +0 -20
  124. package/dist/token-goat-chunk-5NNYIUGV.mjs +0 -143
  125. package/dist/token-goat-chunk-6DQNNFJ6.mjs +0 -294
  126. package/dist/token-goat-chunk-7MAFDRVR.mjs +0 -47
  127. package/dist/token-goat-chunk-BCN2YQC6.mjs +0 -32
  128. package/dist/token-goat-chunk-D7GHQKQD.mjs +0 -30
  129. package/dist/token-goat-chunk-GMOUBOX4.mjs +0 -386
  130. package/dist/token-goat-chunk-IFORDBGC.mjs +0 -192
  131. package/dist/token-goat-chunk-JXK2HQXS.mjs +0 -318
  132. package/dist/token-goat-chunk-L7SDVGBT.mjs +0 -430
  133. package/dist/token-goat-chunk-MMLMALWK.mjs +0 -1381
  134. package/dist/token-goat-chunk-MVSWBNMD.mjs +0 -1985
@@ -2,22 +2,21 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  getDb
5
- } from "./token-goat-chunk-M56BWPBN.mjs";
5
+ } from "./token-goat-chunk-VL3YIFHZ.mjs";
6
6
  import {
7
7
  foldPath,
8
- globalDbPath,
9
8
  isCaseInsensitiveFs
10
- } from "./token-goat-chunk-L45ZQRT7.mjs";
9
+ } from "./token-goat-chunk-AM5V6GSX.mjs";
11
10
  import {
12
11
  normalizePath
13
- } from "./token-goat-chunk-NMTKNYGF.mjs";
12
+ } from "./token-goat-chunk-FNFBKLRD.mjs";
13
+ import {
14
+ globalDbPath
15
+ } from "./token-goat-chunk-VES7EL7O.mjs";
14
16
  import {
15
17
  init_define_import_meta_env
16
18
  } from "./token-goat-chunk-A37V4PBF.mjs";
17
19
 
18
- // src/index_reader.ts
19
- init_define_import_meta_env();
20
-
21
20
  // src/sql_path.ts
22
21
  init_define_import_meta_env();
23
22
  function pathEqClause(column) {
@@ -49,6 +48,100 @@ function projectScopeClause(column) {
49
48
  };
50
49
  }
51
50
 
51
+ // src/index_reader.ts
52
+ init_define_import_meta_env();
53
+
54
+ // src/nested_worktrees.ts
55
+ init_define_import_meta_env();
56
+ import fs from "node:fs";
57
+ import path from "node:path";
58
+ var cache = /* @__PURE__ */ new Map();
59
+ function commonGitDir(root) {
60
+ const dotGit = path.join(root, ".git");
61
+ let st;
62
+ try {
63
+ st = fs.statSync(dotGit);
64
+ } catch {
65
+ return null;
66
+ }
67
+ if (st.isDirectory()) return dotGit;
68
+ if (!st.isFile()) return null;
69
+ try {
70
+ const m = /^gitdir:(.*)$/m.exec(fs.readFileSync(dotGit, "utf8"));
71
+ const target = m?.[1]?.trim();
72
+ if (target === void 0 || target === "") return null;
73
+ const gitDir = path.resolve(root, target);
74
+ const common = fs.readFileSync(path.join(gitDir, "commondir"), "utf8").trim();
75
+ return path.resolve(gitDir, common);
76
+ } catch {
77
+ return null;
78
+ }
79
+ }
80
+ function strictlyInside(child, parent) {
81
+ const base = parent.endsWith("/") ? parent : `${parent}/`;
82
+ return child.startsWith(base) && child.length > base.length;
83
+ }
84
+ function nestedWorktreeRoots(root) {
85
+ const common = commonGitDir(root);
86
+ if (common === null) return [];
87
+ const listDir = path.join(common, "worktrees");
88
+ let listMtimeMs;
89
+ try {
90
+ listMtimeMs = fs.statSync(listDir).mtimeMs;
91
+ } catch {
92
+ return [];
93
+ }
94
+ const hit = cache.get(root);
95
+ if (hit?.listMtimeMs === listMtimeMs) return hit.roots;
96
+ const rootPath = normalizePath(root);
97
+ const rootKey = foldPath(rootPath);
98
+ let realPath;
99
+ try {
100
+ realPath = normalizePath(fs.realpathSync.native(root));
101
+ } catch {
102
+ realPath = null;
103
+ }
104
+ const roots = [];
105
+ let names;
106
+ try {
107
+ names = fs.readdirSync(listDir);
108
+ } catch {
109
+ names = [];
110
+ }
111
+ for (const name of names) {
112
+ const entryDir = path.join(listDir, name);
113
+ let target;
114
+ try {
115
+ target = fs.readFileSync(path.join(entryDir, "gitdir"), "utf8").trim();
116
+ } catch {
117
+ continue;
118
+ }
119
+ if (target === "") continue;
120
+ const wtRoot = normalizePath(path.dirname(path.resolve(entryDir, target)));
121
+ if (strictlyInside(foldPath(wtRoot), rootKey)) roots.push(wtRoot);
122
+ else if (realPath !== null && strictlyInside(foldPath(wtRoot), foldPath(realPath))) roots.push(rootPath.replace(/\/+$/, "") + wtRoot.slice(realPath.replace(/\/+$/, "").length));
123
+ }
124
+ roots.sort();
125
+ cache.set(root, { listMtimeMs, roots });
126
+ return roots;
127
+ }
128
+ function ownProjectScope(column, root) {
129
+ const scope = projectScopeClause(column);
130
+ const excluded = nestedWorktreeExclusions(column, root);
131
+ if (excluded.clauses.length === 0) return { clause: scope.clause, params: scope.params(root) };
132
+ return { clause: `(${[scope.clause, ...excluded.clauses].join(" AND ")})`, params: [...scope.params(root), ...excluded.params] };
133
+ }
134
+ function nestedWorktreeExclusions(column, root) {
135
+ const scope = projectScopeClause(column);
136
+ const clauses = [];
137
+ const params = [];
138
+ for (const wt of nestedWorktreeRoots(root)) {
139
+ clauses.push(`NOT ${scope.clause}`);
140
+ params.push(...scope.params(wt));
141
+ }
142
+ return { clauses, params };
143
+ }
144
+
52
145
  // src/index_reader.ts
53
146
  function indexKey(p) {
54
147
  return normalizePath(p);
@@ -76,9 +169,9 @@ function toRefEntry(row) {
76
169
  }
77
170
  function applyRootDirScope(rootDir, column, where, params) {
78
171
  if (rootDir === void 0) return;
79
- const { clause, params: bounds } = projectScopeClause(column);
80
- where.push(clause);
81
- params.push(...bounds(indexKey(rootDir)));
172
+ const scope = ownProjectScope(column, indexKey(rootDir));
173
+ where.push(scope.clause);
174
+ params.push(...scope.params);
82
175
  }
83
176
  function buildSymbolWhere(opts) {
84
177
  const where = [];
@@ -194,9 +287,15 @@ function queryRefCounts(names, dbPath = globalDbPath(), rootDir) {
194
287
  return counts;
195
288
  }
196
289
  function getProjectFileEntries(rootDir, dbPath = globalDbPath()) {
197
- const db = getDb(dbPath);
198
290
  const { clause, params } = projectScopeClause("path");
199
- const rows = db.prepare(`SELECT path, sha, mtime, language, indexed_at, embed_sha, parser_sha FROM files WHERE ${clause}`).all(...params(indexKey(rootDir)));
291
+ return fileEntriesWhere(clause, params(indexKey(rootDir)), dbPath);
292
+ }
293
+ function getOwnProjectFileEntries(rootDir, dbPath = globalDbPath()) {
294
+ const { clause, params } = ownProjectScope("path", indexKey(rootDir));
295
+ return fileEntriesWhere(clause, params, dbPath);
296
+ }
297
+ function fileEntriesWhere(clause, params, dbPath) {
298
+ const rows = getDb(dbPath).prepare(`SELECT path, sha, mtime, language, indexed_at, embed_sha, parser_sha FROM files WHERE ${clause}`).all(...params);
200
299
  const out = /* @__PURE__ */ new Map();
201
300
  for (const row of rows) {
202
301
  out.set(foldPath(row.path), {
@@ -238,12 +337,10 @@ function sanitizeFtsQuery(query, join = "AND") {
238
337
  const terms = query.split(/\s+/).filter((t) => t.length > 0).map((t) => '"' + t.replace(/"/g, '""') + '"');
239
338
  return terms.join(join === "OR" ? " OR " : " ");
240
339
  }
241
- function runFtsQuery(db, match, limit, scope, rootDir) {
340
+ function runFtsQuery(db, match, limit, scope) {
242
341
  const sql = `SELECT s.file_path, s.name, s.kind, s.line_start, s.line_end, s.body, s.docstring, s.parent FROM symbols_fts JOIN symbols s ON s.id = symbols_fts.rowid WHERE symbols_fts MATCH ?${scope !== void 0 ? ` AND ${scope.clause}` : ""} ORDER BY bm25(symbols_fts) LIMIT ?`;
243
342
  const params = [match];
244
- if (scope !== void 0 && rootDir !== void 0) {
245
- params.push(...scope.params(rootDir));
246
- }
343
+ if (scope !== void 0) params.push(...scope.params);
247
344
  params.push(limit);
248
345
  const rows = db.prepare(sql).all(...params);
249
346
  return rows.map(toSymbolEntry);
@@ -252,13 +349,13 @@ function searchSymbolsFts(query, limit = 50, dbPath = globalDbPath(), rootDir) {
252
349
  const andMatch = sanitizeFtsQuery(query, "AND");
253
350
  if (andMatch === "") return [];
254
351
  const db = getDb(dbPath);
255
- const scope = rootDir !== void 0 ? projectScopeClause("s.file_path") : void 0;
352
+ const scope = rootDir !== void 0 ? ownProjectScope("s.file_path", indexKey(rootDir)) : void 0;
256
353
  try {
257
- const andResults = runFtsQuery(db, andMatch, limit, scope, rootDir);
354
+ const andResults = runFtsQuery(db, andMatch, limit, scope);
258
355
  if (andResults.length > 0) return andResults;
259
356
  const orMatch = sanitizeFtsQuery(query, "OR");
260
357
  if (orMatch === andMatch) return andResults;
261
- return runFtsQuery(db, orMatch, limit, scope, rootDir);
358
+ return runFtsQuery(db, orMatch, limit, scope);
262
359
  } catch {
263
360
  return [];
264
361
  }
@@ -266,7 +363,10 @@ function searchSymbolsFts(query, limit = 50, dbPath = globalDbPath(), rootDir) {
266
363
 
267
364
  export {
268
365
  pathEqClause,
366
+ pathSuffixClause,
269
367
  projectScopeClause,
368
+ ownProjectScope,
369
+ nestedWorktreeExclusions,
270
370
  DEFAULT_QUERY_LIMIT,
271
371
  querySymbols,
272
372
  distinctSymbolKinds,
@@ -276,6 +376,7 @@ export {
276
376
  queryRefsByContext,
277
377
  queryRefCounts,
278
378
  getProjectFileEntries,
379
+ getOwnProjectFileEntries,
279
380
  getFileEntry,
280
381
  sanitizeFtsQuery,
281
382
  searchSymbolsFts
@@ -0,0 +1,48 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ INSTALL_INDEX_ENV,
5
+ formatInstallIndexResult,
6
+ queueInstallIndex
7
+ } from "./token-goat-chunk-56EIMS3E.mjs";
8
+ import "./token-goat-chunk-7BXSNBY5.mjs";
9
+ import "./token-goat-chunk-FBNQNSJK.mjs";
10
+ import "./token-goat-chunk-MNWKPRAL.mjs";
11
+ import "./token-goat-chunk-H2PHHGM5.mjs";
12
+ import "./token-goat-chunk-P4QMM4WK.mjs";
13
+ import "./token-goat-chunk-5KDMCMF2.mjs";
14
+ import "./token-goat-chunk-ATCPY7EQ.mjs";
15
+ import "./token-goat-chunk-VPBBTSJR.mjs";
16
+ import "./token-goat-chunk-Y776AENC.mjs";
17
+ import "./token-goat-chunk-SJHWVNDQ.mjs";
18
+ import "./token-goat-chunk-AFLYLHDH.mjs";
19
+ import "./token-goat-chunk-BPGCUMR7.mjs";
20
+ import "./token-goat-chunk-C63JQV5K.mjs";
21
+ import "./token-goat-chunk-JB6QN6VF.mjs";
22
+ import "./token-goat-chunk-RHXKCZX3.mjs";
23
+ import "./token-goat-chunk-EVMZJ27Z.mjs";
24
+ import "./token-goat-chunk-HYBFA5X3.mjs";
25
+ import "./token-goat-chunk-5Y6ZYL6U.mjs";
26
+ import "./token-goat-chunk-ARDNEC2U.mjs";
27
+ import "./token-goat-chunk-3Z5S4KGM.mjs";
28
+ import "./token-goat-chunk-VL3YIFHZ.mjs";
29
+ import "./token-goat-chunk-XB5KKOCG.mjs";
30
+ import "./token-goat-chunk-3BTK54F3.mjs";
31
+ import "./token-goat-chunk-4FVIAHSI.mjs";
32
+ import "./token-goat-chunk-7IN2MKDS.mjs";
33
+ import "./token-goat-chunk-U4N3BN2W.mjs";
34
+ import "./token-goat-chunk-YZAAZU2S.mjs";
35
+ import "./token-goat-chunk-IVE6U7KV.mjs";
36
+ import "./token-goat-chunk-Y4AFKTHK.mjs";
37
+ import "./token-goat-chunk-GOLEOXZP.mjs";
38
+ import "./token-goat-chunk-AM5V6GSX.mjs";
39
+ import "./token-goat-chunk-FNFBKLRD.mjs";
40
+ import "./token-goat-chunk-VES7EL7O.mjs";
41
+ import "./token-goat-chunk-KWPNJBDH.mjs";
42
+ import "./token-goat-chunk-HAVAOB3S.mjs";
43
+ import "./token-goat-chunk-A37V4PBF.mjs";
44
+ export {
45
+ INSTALL_INDEX_ENV,
46
+ formatInstallIndexResult,
47
+ queueInstallIndex
48
+ };
@@ -0,0 +1,53 @@
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/env.ts
8
+ init_define_import_meta_env();
9
+ var FALSY_ENV_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
10
+ var TRUTHY_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
11
+ function envStr(key, defaultVal) {
12
+ const raw = process.env[key];
13
+ if (raw === void 0) return defaultVal;
14
+ const trimmed = raw.trim();
15
+ return trimmed === "" ? defaultVal : trimmed;
16
+ }
17
+ function envBool(key, defaultVal) {
18
+ const raw = process.env[key];
19
+ if (raw === void 0) return defaultVal;
20
+ const norm = raw.trim().toLowerCase();
21
+ if (norm === "") return defaultVal;
22
+ if (TRUTHY_ENV_VALUES.has(norm)) return true;
23
+ if (FALSY_ENV_VALUES.has(norm)) return false;
24
+ return defaultVal;
25
+ }
26
+ function envInt(key, defaultVal, min, max) {
27
+ const raw = process.env[key];
28
+ if (raw === void 0) return defaultVal;
29
+ const norm = raw.trim();
30
+ if (norm === "") return defaultVal;
31
+ if (!/^[+-]?\d+$/.test(norm)) return defaultVal;
32
+ const val = parseInt(norm, 10);
33
+ if (!Number.isFinite(val)) return defaultVal;
34
+ let clamped = val;
35
+ if (min !== void 0) clamped = Math.max(min, clamped);
36
+ if (max !== void 0) clamped = Math.min(max, clamped);
37
+ return clamped;
38
+ }
39
+ function envStrList(key, defaultVal, delimiter) {
40
+ const raw = process.env[key];
41
+ if (raw === void 0) return defaultVal;
42
+ const entries = raw.split(delimiter).map((s) => s.trim()).filter((s) => s !== "");
43
+ return entries.length > 0 ? entries : defaultVal;
44
+ }
45
+
46
+ export {
47
+ FALSY_ENV_VALUES,
48
+ TRUTHY_ENV_VALUES,
49
+ envStr,
50
+ envBool,
51
+ envInt,
52
+ envStrList
53
+ };
@@ -10,13 +10,13 @@ import {
10
10
  import {
11
11
  createLazyModuleLoader
12
12
  } from "./token-goat-chunk-AH6QILZM.mjs";
13
- import {
14
- pushAll
15
- } from "./token-goat-chunk-L45ZQRT7.mjs";
16
13
  import {
17
14
  DocumentRefusedError,
18
15
  MAX_DOCUMENT_WORK_MILLIS
19
16
  } from "./token-goat-chunk-Y4AFKTHK.mjs";
17
+ import {
18
+ pushAll
19
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
20
20
  import {
21
21
  init_define_import_meta_env
22
22
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -2,12 +2,14 @@ import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
3
  import {
4
4
  classifyContent,
5
- guardDivisor,
6
- stripAnsiEscapes
7
- } from "./token-goat-chunk-MVSWBNMD.mjs";
5
+ guardDivisor
6
+ } from "./token-goat-chunk-3Z5S4KGM.mjs";
8
7
  import {
9
8
  safeSlice
10
- } from "./token-goat-chunk-L45ZQRT7.mjs";
9
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
10
+ import {
11
+ stripAnsiEscapes
12
+ } from "./token-goat-chunk-HAVAOB3S.mjs";
11
13
  import {
12
14
  init_define_import_meta_env
13
15
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -1,5 +1,11 @@
1
1
  import { createRequire as __cjsRequire } from 'node:module';
2
2
  const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ redactSecrets
5
+ } from "./token-goat-chunk-4FVIAHSI.mjs";
6
+ import {
7
+ loadConfig
8
+ } from "./token-goat-chunk-7IN2MKDS.mjs";
3
9
  import {
4
10
  NotAnOfficeDocumentError,
5
11
  assertOoxmlWithinDeadline,
@@ -12,10 +18,10 @@ import {
12
18
  parseOoxmlPart,
13
19
  readOoxmlZip,
14
20
  sortNumberedParts
15
- } from "./token-goat-chunk-UBUKHVYW.mjs";
21
+ } from "./token-goat-chunk-IVKIZWAB.mjs";
16
22
  import {
17
23
  compileGuardedRegex
18
- } from "./token-goat-chunk-GMOUBOX4.mjs";
24
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
19
25
  import {
20
26
  init_define_import_meta_env
21
27
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -194,10 +200,11 @@ async function pptxTextGrep(filePath, pattern, deadline = ooxmlWorkDeadline()) {
194
200
  if (!guarded.ok) throw new Error(`invalid --grep pattern: ${pattern} -- the pattern ${guarded.reason}`);
195
201
  const re = guarded.re;
196
202
  const out = [];
203
+ const config = loadConfig();
197
204
  for (let i = 0; i < slidePaths.length; i++) {
198
205
  assertOoxmlWithinDeadline(deadline, "Narrow the read to specific slides with pptx-slide, or use a smaller deck.");
199
206
  const parsed = await parseSlide(entries, slidePaths[i], budget);
200
- const text = flatSlideText(parsed);
207
+ const text = redactSecrets(flatSlideText(parsed), config).text;
201
208
  if (re.test(text)) {
202
209
  const idx = text.search(re);
203
210
  const snippet = text.slice(Math.max(0, idx - 40), idx + 80).trim();
@@ -20,20 +20,24 @@ import {
20
20
  setOcrTimeoutForTesting,
21
21
  setTesseractEntryForTesting,
22
22
  verifyOcrLangCache
23
- } from "./token-goat-chunk-4STDIGYC.mjs";
24
- import "./token-goat-chunk-BJBRGPBX.mjs";
25
- import "./token-goat-chunk-MVSWBNMD.mjs";
26
- import "./token-goat-chunk-M56BWPBN.mjs";
23
+ } from "./token-goat-chunk-RC35RBUL.mjs";
24
+ import "./token-goat-chunk-ARDNEC2U.mjs";
25
+ import "./token-goat-chunk-3Z5S4KGM.mjs";
26
+ import "./token-goat-chunk-VL3YIFHZ.mjs";
27
+ import "./token-goat-chunk-XB5KKOCG.mjs";
28
+ import "./token-goat-chunk-4FVIAHSI.mjs";
27
29
  import {
28
30
  DEFAULT_OCR_LANG,
29
31
  isSupportedOcrLang,
30
32
  resolveOcrLangs
31
- } from "./token-goat-chunk-CC2PYJM7.mjs";
32
- import "./token-goat-chunk-EEIDFMEM.mjs";
33
- import "./token-goat-chunk-OSUFN2FV.mjs";
34
- import "./token-goat-chunk-L45ZQRT7.mjs";
35
- import "./token-goat-chunk-NMTKNYGF.mjs";
36
- import "./token-goat-chunk-GMOUBOX4.mjs";
33
+ } from "./token-goat-chunk-7IN2MKDS.mjs";
34
+ import "./token-goat-chunk-U4N3BN2W.mjs";
35
+ import "./token-goat-chunk-YZAAZU2S.mjs";
36
+ import "./token-goat-chunk-IVE6U7KV.mjs";
37
+ import "./token-goat-chunk-GOLEOXZP.mjs";
38
+ import "./token-goat-chunk-AM5V6GSX.mjs";
39
+ import "./token-goat-chunk-FNFBKLRD.mjs";
40
+ import "./token-goat-chunk-VES7EL7O.mjs";
37
41
  import "./token-goat-chunk-A37V4PBF.mjs";
38
42
  export {
39
43
  DEFAULT_OCR_LANG,
@@ -0,0 +1,253 @@
1
+ import { createRequire as __cjsRequire } from 'node:module';
2
+ const require = __cjsRequire(import.meta.url);
3
+ import {
4
+ GROK_HOOK_SCRIPT,
5
+ grokConfigPath,
6
+ grokHookScriptPath,
7
+ installAntigravity,
8
+ installGemini,
9
+ installGrok,
10
+ installKimi,
11
+ installOpenclaw,
12
+ installOpencode,
13
+ installPi,
14
+ installQwen,
15
+ isAntigravityInstalled,
16
+ isGeminiInstalled,
17
+ isGrokInstalled,
18
+ isKimiInstalled,
19
+ isOpenclawInstalled,
20
+ isOpencodeInstalled,
21
+ isPiInstalled,
22
+ isQwenInstalled,
23
+ kimiConfigPath,
24
+ kimiHookScriptPath,
25
+ wiredGrokHookWords,
26
+ wiredKimiHookWords
27
+ } from "./token-goat-chunk-HG45AF2B.mjs";
28
+ import {
29
+ CLAUDECODE_HOOK_SCRIPT,
30
+ CODEX_HOOK_SCRIPT,
31
+ COPILOT_CLI_HOOK_SCRIPT,
32
+ claudeHookScriptPath,
33
+ codexConfigPath,
34
+ codexHookScriptPath,
35
+ copilotCliConfigPath,
36
+ copilotCliHooksDir,
37
+ copilotCliInstructionsPath,
38
+ copilotCliScriptPath,
39
+ hookEventGaps,
40
+ installCodex,
41
+ installCopilotHooksFile,
42
+ installHooks,
43
+ isCodexInstalled,
44
+ isCopilotCliInstalled,
45
+ isInstalled,
46
+ wiredCodexHookWords,
47
+ wiredCopilotHookWords,
48
+ writeCopilotInstructionsBlock
49
+ } from "./token-goat-chunk-OJBNYTJP.mjs";
50
+ import "./token-goat-chunk-B2RZZCSS.mjs";
51
+ import "./token-goat-chunk-XKI4SEMX.mjs";
52
+ import "./token-goat-chunk-G5PJ7AGM.mjs";
53
+ import "./token-goat-chunk-P4QMM4WK.mjs";
54
+ import "./token-goat-chunk-VPBBTSJR.mjs";
55
+ import "./token-goat-chunk-BPGCUMR7.mjs";
56
+ import "./token-goat-chunk-JB6QN6VF.mjs";
57
+ import "./token-goat-chunk-3Z5S4KGM.mjs";
58
+ import "./token-goat-chunk-VL3YIFHZ.mjs";
59
+ import "./token-goat-chunk-XB5KKOCG.mjs";
60
+ import "./token-goat-chunk-4FVIAHSI.mjs";
61
+ import "./token-goat-chunk-7IN2MKDS.mjs";
62
+ import "./token-goat-chunk-U4N3BN2W.mjs";
63
+ import "./token-goat-chunk-YZAAZU2S.mjs";
64
+ import "./token-goat-chunk-IVE6U7KV.mjs";
65
+ import {
66
+ extractErrorMessage
67
+ } from "./token-goat-chunk-GOLEOXZP.mjs";
68
+ import "./token-goat-chunk-AM5V6GSX.mjs";
69
+ import "./token-goat-chunk-FNFBKLRD.mjs";
70
+ import "./token-goat-chunk-VES7EL7O.mjs";
71
+ import "./token-goat-chunk-HAVAOB3S.mjs";
72
+ import {
73
+ init_define_import_meta_env
74
+ } from "./token-goat-chunk-A37V4PBF.mjs";
75
+
76
+ // src/cli_doctor_hooks.ts
77
+ init_define_import_meta_env();
78
+ import * as fs from "node:fs";
79
+ import * as path from "node:path";
80
+ function shimIsCurrent(scriptPath, expected) {
81
+ try {
82
+ return fs.readFileSync(scriptPath, "utf-8").replace(/\r\n/g, "\n") === expected.replace(/\r\n/g, "\n");
83
+ } catch {
84
+ return false;
85
+ }
86
+ }
87
+ function hasHookEventGaps(gaps) {
88
+ return gaps !== null && (gaps.missing.length > 0 || gaps.outdated.length > 0 || gaps.broken.length > 0);
89
+ }
90
+ function repairHarnessHooks(rootDir = process.cwd()) {
91
+ const repairs = [];
92
+ const errors = [];
93
+ const projectRoot = path.resolve(rootDir ?? process.cwd());
94
+ try {
95
+ const userShim = claudeHookScriptPath();
96
+ const userInstalled = isInstalled("user") || fs.existsSync(userShim);
97
+ if (userInstalled) {
98
+ const isStaleShim = fs.existsSync(userShim) && !shimIsCurrent(userShim, CLAUDECODE_HOOK_SCRIPT);
99
+ if (isStaleShim || hasHookEventGaps(hookEventGaps("user"))) {
100
+ installHooks("user");
101
+ repairs.push("Repaired Claude Code (user) hooks and shim");
102
+ }
103
+ }
104
+ } catch (e) {
105
+ errors.push(`Failed to repair Claude Code (user) hooks: ${extractErrorMessage(e)}`);
106
+ }
107
+ try {
108
+ const projShim = claudeHookScriptPath();
109
+ const projInstalled = isInstalled("project");
110
+ if (projInstalled) {
111
+ const isStaleShim = fs.existsSync(projShim) && !shimIsCurrent(projShim, CLAUDECODE_HOOK_SCRIPT);
112
+ if (isStaleShim || hasHookEventGaps(hookEventGaps("project"))) {
113
+ installHooks("project");
114
+ repairs.push("Repaired Claude Code (project) hooks and shim");
115
+ }
116
+ }
117
+ } catch (e) {
118
+ errors.push(`Failed to repair Claude Code (project) hooks: ${extractErrorMessage(e)}`);
119
+ }
120
+ try {
121
+ const userShim = copilotCliScriptPath();
122
+ const userConfig = copilotCliConfigPath();
123
+ const userInstalled = isCopilotCliInstalled() || fs.existsSync(userConfig) || fs.existsSync(userShim);
124
+ if (userInstalled) {
125
+ const isStaleShim = fs.existsSync(userShim) && !shimIsCurrent(userShim, COPILOT_CLI_HOOK_SCRIPT);
126
+ const hasOutdatedEntries = wiredCopilotHookWords().some((e) => e.current === false);
127
+ if (isStaleShim || hasOutdatedEntries) {
128
+ installCopilotHooksFile(copilotCliHooksDir(), "copilot");
129
+ writeCopilotInstructionsBlock(copilotCliInstructionsPath());
130
+ repairs.push("Repaired Copilot CLI (user) hooks and shim");
131
+ }
132
+ }
133
+ } catch (e) {
134
+ errors.push(`Failed to repair Copilot CLI (user) hooks: ${extractErrorMessage(e)}`);
135
+ }
136
+ try {
137
+ const copilotLocalOpts = { local: true, projectRoot };
138
+ const projShim = copilotCliScriptPath(copilotLocalOpts);
139
+ const projConfig = copilotCliConfigPath(copilotLocalOpts);
140
+ const projInstalled = isCopilotCliInstalled(copilotLocalOpts) || fs.existsSync(projConfig) || fs.existsSync(projShim);
141
+ if (projInstalled) {
142
+ const isStaleShim = fs.existsSync(projShim) && !shimIsCurrent(projShim, COPILOT_CLI_HOOK_SCRIPT);
143
+ const hasOutdatedEntries = wiredCopilotHookWords(copilotLocalOpts).some((e) => e.current === false);
144
+ if (isStaleShim || hasOutdatedEntries) {
145
+ installCopilotHooksFile(copilotCliHooksDir(copilotLocalOpts), "copilot");
146
+ writeCopilotInstructionsBlock(copilotCliInstructionsPath(copilotLocalOpts));
147
+ repairs.push("Repaired Copilot CLI (project) hooks and shim");
148
+ }
149
+ }
150
+ } catch (e) {
151
+ errors.push(`Failed to repair Copilot CLI (project) hooks: ${extractErrorMessage(e)}`);
152
+ }
153
+ try {
154
+ const codexShim = codexHookScriptPath();
155
+ const codexCfg = codexConfigPath();
156
+ const codexInstalled = isCodexInstalled() || fs.existsSync(codexCfg) || fs.existsSync(codexShim);
157
+ if (codexInstalled) {
158
+ const isStaleShim = fs.existsSync(codexShim) && !shimIsCurrent(codexShim, CODEX_HOOK_SCRIPT);
159
+ const hasOutdatedEntries = wiredCodexHookWords().some((e) => e.current === false);
160
+ if (isStaleShim || hasOutdatedEntries) {
161
+ installCodex();
162
+ repairs.push("Repaired Codex CLI hooks and shim");
163
+ }
164
+ }
165
+ } catch (e) {
166
+ errors.push(`Failed to repair Codex CLI hooks: ${extractErrorMessage(e)}`);
167
+ }
168
+ try {
169
+ const grokShim = grokHookScriptPath();
170
+ const grokCfg = grokConfigPath();
171
+ const grokInstalled = isGrokInstalled() || fs.existsSync(grokCfg) || fs.existsSync(grokShim);
172
+ if (grokInstalled) {
173
+ const isStaleShim = fs.existsSync(grokShim) && !shimIsCurrent(grokShim, GROK_HOOK_SCRIPT);
174
+ const hasOutdatedEntries = wiredGrokHookWords().some((e) => e.current === false);
175
+ if (isStaleShim || hasOutdatedEntries) {
176
+ installGrok();
177
+ repairs.push("Repaired Grok CLI hooks and shim");
178
+ }
179
+ }
180
+ } catch (e) {
181
+ errors.push(`Failed to repair Grok CLI hooks: ${extractErrorMessage(e)}`);
182
+ }
183
+ try {
184
+ const kimiShim = kimiHookScriptPath();
185
+ const kimiCfg = kimiConfigPath();
186
+ const kimiInstalled = isKimiInstalled() || fs.existsSync(kimiCfg) || fs.existsSync(kimiShim);
187
+ if (kimiInstalled) {
188
+ const hasOutdatedEntries = wiredKimiHookWords().some((e) => e.current === false);
189
+ if (hasOutdatedEntries || fs.existsSync(kimiShim) && fs.statSync(kimiShim).size === 0) {
190
+ installKimi();
191
+ repairs.push("Repaired Kimi Code hooks and shim");
192
+ }
193
+ }
194
+ } catch (e) {
195
+ errors.push(`Failed to repair Kimi Code hooks: ${extractErrorMessage(e)}`);
196
+ }
197
+ try {
198
+ if (isGeminiInstalled()) {
199
+ const res = installGemini();
200
+ if (!res.alreadyInstalled) repairs.push("Repaired Gemini CLI hooks");
201
+ }
202
+ } catch (e) {
203
+ errors.push(`Failed to repair Gemini CLI hooks: ${extractErrorMessage(e)}`);
204
+ }
205
+ try {
206
+ if (isQwenInstalled()) {
207
+ const res = installQwen();
208
+ if (!res.alreadyInstalled) repairs.push("Repaired Qwen Code hooks");
209
+ }
210
+ } catch (e) {
211
+ errors.push(`Failed to repair Qwen Code hooks: ${extractErrorMessage(e)}`);
212
+ }
213
+ try {
214
+ if (isOpencodeInstalled()) {
215
+ const res = installOpencode();
216
+ if (!res.alreadyInstalled) repairs.push("Repaired opencode plugin");
217
+ }
218
+ } catch (e) {
219
+ errors.push(`Failed to repair opencode plugin: ${extractErrorMessage(e)}`);
220
+ }
221
+ try {
222
+ if (isOpenclawInstalled()) {
223
+ const res = installOpenclaw();
224
+ if (!res.alreadyInstalled) repairs.push("Repaired OpenClaw plugin");
225
+ }
226
+ } catch (e) {
227
+ errors.push(`Failed to repair OpenClaw plugin: ${extractErrorMessage(e)}`);
228
+ }
229
+ try {
230
+ if (isPiInstalled()) {
231
+ const res = installPi();
232
+ if (!res.alreadyInstalled) repairs.push("Repaired pi extension");
233
+ } else if (isPiInstalled({ local: true })) {
234
+ const res = installPi({ local: true });
235
+ if (!res.alreadyInstalled) repairs.push("Repaired pi (project) extension");
236
+ }
237
+ } catch (e) {
238
+ errors.push(`Failed to repair pi extension: ${extractErrorMessage(e)}`);
239
+ }
240
+ try {
241
+ if (isAntigravityInstalled()) {
242
+ const res = installAntigravity();
243
+ if (!res.alreadyInstalled) repairs.push("Repaired Antigravity CLI integration");
244
+ }
245
+ } catch (e) {
246
+ errors.push(`Failed to repair Antigravity CLI integration: ${extractErrorMessage(e)}`);
247
+ }
248
+ return { repairs, errors };
249
+ }
250
+ export {
251
+ repairHarnessHooks,
252
+ shimIsCurrent
253
+ };