token-goat 2.9.29 → 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.
- package/README.md +34 -40
- package/SECURITY.md +28 -10
- package/THIRD_PARTY_NOTICES.md +40 -3
- package/dist/native/linux-arm64/tg-hook +0 -0
- package/dist/native/linux-x64/tg-hook +0 -0
- package/dist/ort-wasm-simd-threaded.mjs +59 -0
- package/dist/token-goat-chunk-3CHUNJ2O.mjs +53 -0
- package/dist/token-goat-chunk-3Z5S4KGM.mjs +918 -0
- package/dist/token-goat-chunk-4FVIAHSI.mjs +211 -0
- package/dist/{token-goat-chunk-PGTH2U4C.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
- package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
- package/dist/{token-goat-chunk-L7H3U27L.mjs → token-goat-chunk-54K3EUV3.mjs} +1 -1
- package/dist/token-goat-chunk-56EIMS3E.mjs +159 -0
- package/dist/token-goat-chunk-5BCIJXMO.mjs +609 -0
- package/dist/token-goat-chunk-5KDMCMF2.mjs +362 -0
- package/dist/token-goat-chunk-5RG5SBL6.mjs +221 -0
- package/dist/{token-goat-chunk-RRNZMM3A.mjs → token-goat-chunk-5Y6ZYL6U.mjs} +21 -2
- package/dist/{token-goat-chunk-GLXRTTLE.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -8
- package/dist/{token-goat-chunk-G23DWHV4.mjs → token-goat-chunk-664RTTUV.mjs} +28 -15
- package/dist/token-goat-chunk-67TQJ76B.mjs +57 -0
- package/dist/token-goat-chunk-6QMAS7AB.mjs +42 -0
- package/dist/token-goat-chunk-7BXSNBY5.mjs +253 -0
- package/dist/{token-goat-chunk-IVWI2OCK.mjs → token-goat-chunk-7F2UBPD3.mjs} +40 -11
- package/dist/{token-goat-chunk-TGOXNAHW.mjs → token-goat-chunk-7IN2MKDS.mjs} +682 -501
- package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
- package/dist/{token-goat-chunk-KOPIR3KZ.mjs → token-goat-chunk-A3CK6N5Z.mjs} +618 -72
- package/dist/{token-goat-chunk-O6I2XU4P.mjs → token-goat-chunk-AFLYLHDH.mjs} +44 -31
- package/dist/{token-goat-chunk-TCQANXYC.mjs → token-goat-chunk-AM5V6GSX.mjs} +18 -2
- package/dist/{token-goat-chunk-E4ZOJIZK.mjs → token-goat-chunk-APGZXSPS.mjs} +39 -146
- package/dist/{token-goat-chunk-D4ETHJD6.mjs → token-goat-chunk-ARDNEC2U.mjs} +9 -7
- package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
- package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
- package/dist/{token-goat-chunk-BGYOZ6DO.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -7
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/{token-goat-chunk-TDUT2CL6.mjs → token-goat-chunk-C63JQV5K.mjs} +45 -6
- package/dist/{token-goat-chunk-ZER6EAXZ.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
- package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
- package/dist/{token-goat-chunk-RQGGMPCR.mjs → token-goat-chunk-CYCEYAEO.mjs} +76 -16
- package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
- package/dist/{token-goat-chunk-ASLWOQ3I.mjs → token-goat-chunk-DZX2YDPT.mjs} +2 -1
- package/dist/token-goat-chunk-E3OQX2XT.mjs +824 -0
- package/dist/token-goat-chunk-EFHMMIGP.mjs +68 -0
- package/dist/token-goat-chunk-ETBHVDB6.mjs +328 -0
- package/dist/token-goat-chunk-EVMZJ27Z.mjs +147 -0
- package/dist/token-goat-chunk-EXKGNHEG.mjs +2096 -0
- package/dist/{token-goat-chunk-RTMVLHWX.mjs → token-goat-chunk-FBNQNSJK.mjs} +2555 -5127
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/{token-goat-chunk-RLP6J7WR.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/{token-goat-chunk-DNRPXHYH.mjs → token-goat-chunk-GFBSN7BD.mjs} +29 -401
- package/dist/{token-goat-chunk-XYWPOSCN.mjs → token-goat-chunk-GOLEOXZP.mjs} +763 -211
- package/dist/token-goat-chunk-H2K3QP6H.mjs +24 -0
- package/dist/token-goat-chunk-H2PHHGM5.mjs +188 -0
- package/dist/token-goat-chunk-HAVAOB3S.mjs +87 -0
- package/dist/token-goat-chunk-HG45AF2B.mjs +2228 -0
- package/dist/{token-goat-chunk-HUYUHODZ.mjs → token-goat-chunk-HOJLCGDP.mjs} +12965 -11748
- package/dist/{token-goat-chunk-435UQTKD.mjs → token-goat-chunk-HYBFA5X3.mjs} +118 -19
- package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
- package/dist/{token-goat-chunk-UXSXQQIY.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
- package/dist/{token-goat-chunk-52NSDWYY.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
- package/dist/{token-goat-chunk-HNFZZHFW.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
- package/dist/{token-goat-chunk-FTP4U4QA.mjs → token-goat-chunk-JDU3EXSU.mjs} +12 -11
- package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
- package/dist/{token-goat-chunk-6AK46ZT7.mjs → token-goat-chunk-JN4XMLSD.mjs} +5 -1
- package/dist/token-goat-chunk-JTQQGXZH.mjs +733 -0
- package/dist/token-goat-chunk-KKUFXAPD.mjs +25 -0
- package/dist/token-goat-chunk-KQNZDCBD.mjs +47 -0
- package/dist/{token-goat-chunk-2WOUYWLM.mjs → token-goat-chunk-KWPNJBDH.mjs} +27 -3
- package/dist/{token-goat-chunk-DPNLUJWB.mjs → token-goat-chunk-LOBGHXPB.mjs} +30 -8
- package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/{token-goat-chunk-DNSPXQXQ.mjs → token-goat-chunk-N2NMER56.mjs} +25 -15
- package/dist/token-goat-chunk-NYKZLXMK.mjs +218 -0
- package/dist/token-goat-chunk-OJBNYTJP.mjs +3087 -0
- package/dist/token-goat-chunk-P4QMM4WK.mjs +295 -0
- package/dist/token-goat-chunk-PD5VKH46.mjs +184 -0
- package/dist/token-goat-chunk-PEPTHRFF.mjs +129 -0
- package/dist/{token-goat-chunk-NMBWLRHW.mjs → token-goat-chunk-PU7V3FD6.mjs} +8721 -11104
- package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
- package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
- package/dist/{token-goat-chunk-67BNIKKO.mjs → token-goat-chunk-QCLDAQTS.mjs} +31 -20
- package/dist/{token-goat-chunk-SE6E4BKJ.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
- package/dist/{token-goat-chunk-VZQEWRVH.mjs → token-goat-chunk-RC35RBUL.mjs} +4 -4
- package/dist/{token-goat-chunk-VMFWNHGR.mjs → token-goat-chunk-RHXKCZX3.mjs} +873 -504
- package/dist/{token-goat-chunk-PYSUADX4.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
- package/dist/{token-goat-chunk-ONXH6NZ5.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
- package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
- package/dist/{token-goat-chunk-QO3LXVVR.mjs → token-goat-chunk-SQSSNQPE.mjs} +2295 -1718
- package/dist/{token-goat-chunk-2AWQ2R5X.mjs → token-goat-chunk-T4FK7VOV.mjs} +2 -2
- package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/{token-goat-chunk-UA5BKWWQ.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
- package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
- package/dist/{token-goat-chunk-MELOKFDJ.mjs → token-goat-chunk-VES7EL7O.mjs} +7 -1
- package/dist/{token-goat-chunk-7CPMDFGB.mjs → token-goat-chunk-VL3YIFHZ.mjs} +389 -14
- package/dist/{token-goat-chunk-E5TK5DNO.mjs → token-goat-chunk-VPBBTSJR.mjs} +356 -129
- package/dist/{token-goat-chunk-YOOVFPTP.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
- package/dist/{token-goat-chunk-LZNBQTDK.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -7
- package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
- package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
- package/dist/{token-goat-chunk-H5J3C56Q.mjs → token-goat-chunk-Y776AENC.mjs} +112 -26
- package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
- package/dist/{token-goat-chunk-S4VSXURL.mjs → token-goat-chunk-Z44YO3QZ.mjs} +4 -0
- package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
- package/dist/{token-goat-chunk-PQ53BSCF.mjs → token-goat-chunk-ZCDTCVIS.mjs} +48 -29
- package/dist/token-goat-chunk-ZEJVMUQH.mjs +48 -0
- package/dist/{token-goat-chunk-BGHSSJUA.mjs → token-goat-chunk-ZFOBKUWH.mjs} +1 -1
- package/dist/token-goat-chunk-ZMBL6UVV.mjs +110 -0
- package/dist/{token-goat-chunk-PKRWMHVP.mjs → token-goat-chunk-ZQSJMO2R.mjs} +338 -170
- package/dist/token-goat-hook-client.cjs +87 -23
- package/dist/token-goat-hook-client.mjs +3 -3
- package/dist/token-goat-hook.mjs +46 -30
- package/dist/token-goat.core.mjs +6 -6
- package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
- package/docs/cli.md +80 -46
- package/docs/install.md +47 -14
- package/docs/security.md +7 -7
- package/package.json +17 -7
- package/scripts/verify-native-dist.mjs +386 -0
- package/dist/token-goat-chunk-2NNUA2LR.mjs +0 -143
- package/dist/token-goat-chunk-44BM7DDQ.mjs +0 -294
- package/dist/token-goat-chunk-C5YPNZKQ.mjs +0 -318
- package/dist/token-goat-chunk-CIQ2FTY3.mjs +0 -1990
- package/dist/token-goat-chunk-EUSDXRXU.mjs +0 -1429
- package/dist/token-goat-chunk-G7IWXCFF.mjs +0 -456
- package/dist/token-goat-chunk-JTKCQMQA.mjs +0 -418
- package/dist/token-goat-chunk-ORNFMIER.mjs +0 -295
- package/dist/token-goat-chunk-VQ6F6T7X.mjs +0 -36
- package/dist/token-goat-chunk-YAGLESS3.mjs +0 -23
- package/dist/token-goat-chunk-YKSRAWUU.mjs +0 -33
- package/dist/token-goat-chunk-Z6KBMOBI.mjs +0 -53
|
@@ -1,131 +1,29 @@
|
|
|
1
1
|
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
enqueueDirtyPathsSafe,
|
|
5
|
-
fenceUntrusted,
|
|
6
|
-
getTrackedFiles,
|
|
7
|
-
scanAndRecord
|
|
8
|
-
} from "./token-goat-chunk-RTMVLHWX.mjs";
|
|
9
3
|
import {
|
|
10
4
|
getToolName
|
|
11
|
-
} from "./token-goat-chunk-
|
|
12
|
-
import {
|
|
13
|
-
RECALL_DEFAULT_LIMIT,
|
|
14
|
-
indexRecallEntry,
|
|
15
|
-
listRecentRecall,
|
|
16
|
-
searchRecall
|
|
17
|
-
} from "./token-goat-chunk-O6I2XU4P.mjs";
|
|
18
|
-
import {
|
|
19
|
-
isBlobStale,
|
|
20
|
-
loadBlob,
|
|
21
|
-
storeBlob
|
|
22
|
-
} from "./token-goat-chunk-D4ETHJD6.mjs";
|
|
5
|
+
} from "./token-goat-chunk-VPBBTSJR.mjs";
|
|
23
6
|
import {
|
|
24
|
-
|
|
25
|
-
} from "./token-goat-chunk-
|
|
26
|
-
import {
|
|
27
|
-
parserFingerprintForLanguage
|
|
28
|
-
} from "./token-goat-chunk-VMFWNHGR.mjs";
|
|
29
|
-
import {
|
|
30
|
-
getProjectFileEntries,
|
|
31
|
-
projectScopeClause
|
|
32
|
-
} from "./token-goat-chunk-435UQTKD.mjs";
|
|
7
|
+
countSymbols
|
|
8
|
+
} from "./token-goat-chunk-HYBFA5X3.mjs";
|
|
33
9
|
import {
|
|
34
10
|
getDb
|
|
35
|
-
} from "./token-goat-chunk-
|
|
36
|
-
import {
|
|
37
|
-
fingerprintFile,
|
|
38
|
-
getDisplayRoot,
|
|
39
|
-
shortFingerprint
|
|
40
|
-
} from "./token-goat-chunk-TGOXNAHW.mjs";
|
|
11
|
+
} from "./token-goat-chunk-VL3YIFHZ.mjs";
|
|
41
12
|
import {
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
compileGuardedRegex,
|
|
14
|
+
extractErrorMessage
|
|
15
|
+
} from "./token-goat-chunk-GOLEOXZP.mjs";
|
|
44
16
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
pad
|
|
48
|
-
} from "./token-goat-chunk-XYWPOSCN.mjs";
|
|
49
|
-
import {
|
|
50
|
-
foldPath
|
|
51
|
-
} from "./token-goat-chunk-TCQANXYC.mjs";
|
|
52
|
-
import {
|
|
53
|
-
UNTRUSTED_TOOL_TAG,
|
|
54
|
-
UNTRUSTED_WEB_TAG,
|
|
55
|
-
displaySafeJson,
|
|
56
|
-
fenceUntrustedContent,
|
|
57
|
-
normalizePath,
|
|
58
|
-
resolveIndexPath,
|
|
59
|
-
toDisplayPath
|
|
60
|
-
} from "./token-goat-chunk-NMTKNYGF.mjs";
|
|
17
|
+
displaySafeJson
|
|
18
|
+
} from "./token-goat-chunk-FNFBKLRD.mjs";
|
|
61
19
|
import {
|
|
62
20
|
SYMBOL_BODY_CHAR_CAP,
|
|
63
21
|
globalDbPath
|
|
64
|
-
} from "./token-goat-chunk-
|
|
65
|
-
import {
|
|
66
|
-
compileGuardedRegex
|
|
67
|
-
} from "./token-goat-chunk-JTKCQMQA.mjs";
|
|
22
|
+
} from "./token-goat-chunk-VES7EL7O.mjs";
|
|
68
23
|
import {
|
|
69
24
|
init_define_import_meta_env
|
|
70
25
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
71
26
|
|
|
72
|
-
// src/web_cache.ts
|
|
73
|
-
init_define_import_meta_env();
|
|
74
|
-
var WEB_OUTPUT_SUBDIR = "web_outputs";
|
|
75
|
-
var _byId = /* @__PURE__ */ new Map();
|
|
76
|
-
var _rawById = /* @__PURE__ */ new Map();
|
|
77
|
-
var _urlIndex = /* @__PURE__ */ new Map();
|
|
78
|
-
function cacheIdForUrl(url) {
|
|
79
|
-
return shortFingerprint(url);
|
|
80
|
-
}
|
|
81
|
-
function storeWebOutput(url, content, dedupKey = url, rawContent) {
|
|
82
|
-
const cacheId = cacheIdForUrl(dedupKey);
|
|
83
|
-
const redactedContent = redactSecrets(content).text;
|
|
84
|
-
_byId.set(cacheId, redactedContent);
|
|
85
|
-
_urlIndex.set(url, cacheId);
|
|
86
|
-
const redactedRaw = rawContent !== void 0 && rawContent !== content ? redactSecrets(rawContent).text : void 0;
|
|
87
|
-
if (redactedRaw !== void 0) _rawById.set(cacheId, redactedRaw);
|
|
88
|
-
else _rawById.delete(cacheId);
|
|
89
|
-
storeBlob(WEB_OUTPUT_SUBDIR, cacheId, redactedRaw !== void 0 ? { url, content: redactedContent, raw: redactedRaw } : { url, content: redactedContent });
|
|
90
|
-
const redactedUrl = redactSecrets(url).text;
|
|
91
|
-
indexRecallEntry("web", cacheId, redactedUrl, `${redactedUrl}
|
|
92
|
-
${redactedContent}`, Date.now());
|
|
93
|
-
return cacheId;
|
|
94
|
-
}
|
|
95
|
-
function coerceWebBlob(raw) {
|
|
96
|
-
if (raw === null || typeof raw !== "object") return null;
|
|
97
|
-
const o = raw;
|
|
98
|
-
if (typeof o["content"] !== "string") return null;
|
|
99
|
-
return { url: typeof o["url"] === "string" ? o["url"] : null, content: o["content"], raw: typeof o["raw"] === "string" ? o["raw"] : null };
|
|
100
|
-
}
|
|
101
|
-
function getWebOutput(cacheId) {
|
|
102
|
-
const hit = _byId.get(cacheId);
|
|
103
|
-
if (hit !== void 0) return hit;
|
|
104
|
-
if (isBlobStale(WEB_OUTPUT_SUBDIR, cacheId)) return null;
|
|
105
|
-
const blob = coerceWebBlob(loadBlob(WEB_OUTPUT_SUBDIR, cacheId));
|
|
106
|
-
if (blob === null) return null;
|
|
107
|
-
_byId.set(cacheId, blob.content);
|
|
108
|
-
if (blob.raw !== null) _rawById.set(cacheId, blob.raw);
|
|
109
|
-
if (blob.url !== null) _urlIndex.set(blob.url, cacheId);
|
|
110
|
-
return blob.content;
|
|
111
|
-
}
|
|
112
|
-
function getWebOutputRaw(cacheId) {
|
|
113
|
-
const cleaned = getWebOutput(cacheId);
|
|
114
|
-
if (cleaned === null) return null;
|
|
115
|
-
return _rawById.get(cacheId) ?? cleaned;
|
|
116
|
-
}
|
|
117
|
-
function getWebOutputByUrlFromDisk(url, dedupKey = url) {
|
|
118
|
-
const cacheId = cacheIdForUrl(dedupKey);
|
|
119
|
-
const content = getWebOutput(cacheId);
|
|
120
|
-
if (content === null) return null;
|
|
121
|
-
return { cacheId, content };
|
|
122
|
-
}
|
|
123
|
-
registerReset(() => {
|
|
124
|
-
_byId = /* @__PURE__ */ new Map();
|
|
125
|
-
_rawById = /* @__PURE__ */ new Map();
|
|
126
|
-
_urlIndex = /* @__PURE__ */ new Map();
|
|
127
|
-
}, { perRequest: true });
|
|
128
|
-
|
|
129
27
|
// src/stdin_json.ts
|
|
130
28
|
init_define_import_meta_env();
|
|
131
29
|
var DEFAULT_STDIN_TIMEOUT_MS = 5e3;
|
|
@@ -542,7 +440,7 @@ async function describeTarget(target, table, opts) {
|
|
|
542
440
|
const absPath = resolve(process.cwd(), target);
|
|
543
441
|
if (existsSync(absPath)) {
|
|
544
442
|
try {
|
|
545
|
-
const { isSqliteFile, getSqliteSchema, formatSqliteSchema } = await import("./token-goat-chunk-
|
|
443
|
+
const { isSqliteFile, getSqliteSchema, formatSqliteSchema } = await import("./token-goat-chunk-T4FK7VOV.mjs");
|
|
546
444
|
if (isSqliteFile(absPath)) {
|
|
547
445
|
const schema = getSqliteSchema(absPath);
|
|
548
446
|
if (table) {
|
|
@@ -564,6 +462,7 @@ async function describeTarget(target, table, opts) {
|
|
|
564
462
|
for (const col of found.columns) {
|
|
565
463
|
lines.push(`| \`${col.name}\` | \`${col.type}\` | ${col.notNull ? "NO" : "YES"} | ${col.defaultValue ?? "NULL"} | ${col.primaryKey ? "YES" : "NO"} |`);
|
|
566
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);
|
|
567
466
|
return { exitCode: 0, text: lines.join("\n") };
|
|
568
467
|
}
|
|
569
468
|
if (opts?.json === true) {
|
|
@@ -661,21 +560,6 @@ async function cmdDescribe(target, table, opts) {
|
|
|
661
560
|
process.exitCode = await runDescribe({ target, table, json: opts?.json });
|
|
662
561
|
}
|
|
663
562
|
|
|
664
|
-
// src/types.ts
|
|
665
|
-
init_define_import_meta_env();
|
|
666
|
-
var HOOK_EVENTS = [
|
|
667
|
-
"pre_tool_use",
|
|
668
|
-
"post_tool_use",
|
|
669
|
-
"notification",
|
|
670
|
-
"stop",
|
|
671
|
-
"pre_compact",
|
|
672
|
-
"post_compact",
|
|
673
|
-
"user_prompt_submit",
|
|
674
|
-
"subagent_stop",
|
|
675
|
-
"session_start",
|
|
676
|
-
"post_tool_use_failure"
|
|
677
|
-
];
|
|
678
|
-
|
|
679
563
|
// src/cli_commands.ts
|
|
680
564
|
init_define_import_meta_env();
|
|
681
565
|
function toEntry(cmd) {
|
|
@@ -769,294 +653,38 @@ function checkSymbolBodySize(dbPath) {
|
|
|
769
653
|
}
|
|
770
654
|
}
|
|
771
655
|
|
|
772
|
-
// src/
|
|
773
|
-
init_define_import_meta_env();
|
|
774
|
-
var MCP_TOOL_PATTERN = "^mcp__";
|
|
775
|
-
|
|
776
|
-
// src/reconcile.ts
|
|
656
|
+
// src/session_reminder.ts
|
|
777
657
|
init_define_import_meta_env();
|
|
778
|
-
|
|
779
|
-
var
|
|
780
|
-
|
|
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;
|
|
781
663
|
try {
|
|
782
|
-
|
|
783
|
-
return row?.last_scanned_path ?? null;
|
|
664
|
+
return countSymbols({ rootDir: cwd }, globalDbPath()) > 0;
|
|
784
665
|
} catch {
|
|
785
|
-
return
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function writeReconcileCursor(dbPath, root, lastScannedPath) {
|
|
789
|
-
try {
|
|
790
|
-
getDb(dbPath).prepare(
|
|
791
|
-
"INSERT INTO reconcile_cursor (root, last_scanned_path, updated_at) VALUES (?, ?, ?) ON CONFLICT(root) DO UPDATE SET last_scanned_path = excluded.last_scanned_path, updated_at = excluded.updated_at"
|
|
792
|
-
).run(root, lastScannedPath, Date.now());
|
|
793
|
-
} catch {
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
function clearReconcileCursor(dbPath, root) {
|
|
797
|
-
try {
|
|
798
|
-
getDb(dbPath).prepare("DELETE FROM reconcile_cursor WHERE root = ?").run(root);
|
|
799
|
-
} catch {
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
function runReconcile(opts = {}) {
|
|
803
|
-
const raw = reconcileProject(opts);
|
|
804
|
-
const root = getDisplayRoot(opts.cwd ?? process.cwd());
|
|
805
|
-
const display = (paths) => paths.map((p) => toDisplayPath(root, p)).sort();
|
|
806
|
-
const result = {
|
|
807
|
-
...raw,
|
|
808
|
-
changed: display(raw.changed),
|
|
809
|
-
added: display(raw.added),
|
|
810
|
-
removed: display(raw.removed)
|
|
811
|
-
};
|
|
812
|
-
if (opts.json === true) {
|
|
813
|
-
process.stdout.write(`${displaySafeJson(result)}
|
|
814
|
-
`);
|
|
815
|
-
return 0;
|
|
816
|
-
}
|
|
817
|
-
const lines = [];
|
|
818
|
-
if (isReconcileClean(result)) {
|
|
819
|
-
if (!result.trackedUnavailable) {
|
|
820
|
-
lines.push(`Index matches disk: ${countNoun(result.scanned, "file")} checked in ${result.elapsedMs}ms.`);
|
|
821
|
-
}
|
|
822
|
-
} else {
|
|
823
|
-
const verb = opts.dryRun === true ? "would reindex" : "queued for reindexing";
|
|
824
|
-
const dropVerb = opts.dryRun === true ? "would drop from the index" : "queued for removal";
|
|
825
|
-
if (result.changed.length > 0) lines.push(`${countNoun(result.changed.length, "file")} changed since indexing (${verb}):`);
|
|
826
|
-
for (const f of result.changed) lines.push(` ~ ${f}`);
|
|
827
|
-
if (result.added.length > 0) lines.push(`${countNoun(result.added.length, "file")} not in the index (${verb}):`);
|
|
828
|
-
for (const f of result.added) lines.push(` + ${f}`);
|
|
829
|
-
if (result.removed.length > 0) lines.push(`${countNoun(result.removed.length, "file")} indexed but gone from disk (${dropVerb}):`);
|
|
830
|
-
for (const f of result.removed) lines.push(` - ${f}`);
|
|
831
|
-
lines.push(`Checked ${countNoun(result.scanned, "file")} in ${result.elapsedMs}ms.`);
|
|
832
|
-
}
|
|
833
|
-
if (result.mtimeOnly > 0) {
|
|
834
|
-
lines.push(`${countNoun(result.mtimeOnly, "file")} had a newer timestamp but identical content, so ${result.mtimeOnly === 1 ? "it was" : "they were"} left alone.`);
|
|
835
|
-
}
|
|
836
|
-
if (result.parserStale > 0) {
|
|
837
|
-
const reparseVerb = opts.dryRun === true ? "would reparse" : "queued for reparse";
|
|
838
|
-
lines.push(`${countNoun(result.parserStale, "file")} of the above ${result.parserStale === 1 ? "was" : "were"} unchanged on disk but indexed by an older parser (${reparseVerb}).`);
|
|
839
|
-
}
|
|
840
|
-
if (result.embedStale > 0) {
|
|
841
|
-
const reembedVerb = opts.dryRun === true ? "would re-embed" : "queued for re-embedding";
|
|
842
|
-
lines.push(`${countNoun(result.embedStale, "file")} of the above ${result.embedStale === 1 ? "was" : "were"} unchanged on disk but held out-of-date embeddings (${reembedVerb}).`);
|
|
843
|
-
}
|
|
844
|
-
if (result.trackedUnavailable) {
|
|
845
|
-
lines.push("This project has an index but git listed no files in it, so nothing on disk was compared against it and changed or new files could not be found. Files gone from disk were still detected. Run token-goat inside the repository, or reindex with --walk if this directory is deliberately not under git.");
|
|
846
|
-
}
|
|
847
|
-
if (result.budgetExhausted) {
|
|
848
|
-
lines.push(`Stopped at the ${result.elapsedMs}ms budget with ${countNoun(result.unscanned, "file")} unchecked, so there may be more drift; deletions were not computed at all, because an unchecked file is indistinguishable from a deleted one. Raise --budget-ms for a complete sweep.`);
|
|
666
|
+
return false;
|
|
849
667
|
}
|
|
850
|
-
process.stdout.write(`${lines.join("\n")}
|
|
851
|
-
`);
|
|
852
|
-
return 0;
|
|
853
668
|
}
|
|
854
|
-
function
|
|
855
|
-
return
|
|
856
|
-
}
|
|
857
|
-
function reconcileProject(opts = {}) {
|
|
858
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
859
|
-
const budgetMs = opts.budgetMs ?? DEFAULT_RECONCILE_BUDGET_MS;
|
|
860
|
-
const startedAt = Date.now();
|
|
861
|
-
const dbPath = opts.dbPath ?? globalDbPath();
|
|
862
|
-
const tracked = getTrackedFiles(cwd);
|
|
863
|
-
const projectRoot = resolveIndexPath(".", cwd);
|
|
864
|
-
const indexed = getProjectFileEntries(projectRoot, dbPath);
|
|
865
|
-
const chunkScope = projectScopeClause("file_path");
|
|
866
|
-
const chunked = new Set(
|
|
867
|
-
getDb(dbPath).prepare(`SELECT DISTINCT file_path FROM chunks WHERE ${chunkScope.clause}`).pluck().all(...chunkScope.params(projectRoot)).map((p) => foldPath(normalizePath(p)))
|
|
868
|
-
);
|
|
869
|
-
let scanOrder = tracked;
|
|
870
|
-
const cursorPath = tracked.length > 0 ? readReconcileCursor(dbPath, projectRoot) : null;
|
|
871
|
-
if (cursorPath !== null) {
|
|
872
|
-
const cursorFolded = foldPath(normalizePath(cursorPath));
|
|
873
|
-
const cursorIdx = tracked.findIndex((f) => foldPath(normalizePath(f)) === cursorFolded);
|
|
874
|
-
if (cursorIdx !== -1) {
|
|
875
|
-
scanOrder = [...tracked.slice(cursorIdx + 1), ...tracked.slice(0, cursorIdx + 1)];
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
const changed = [];
|
|
879
|
-
const added = [];
|
|
880
|
-
const seenOnDisk = /* @__PURE__ */ new Set();
|
|
881
|
-
let mtimeOnly = 0;
|
|
882
|
-
let parserStale = 0;
|
|
883
|
-
let embedStale = 0;
|
|
884
|
-
let scanned = 0;
|
|
885
|
-
let budgetExhausted = false;
|
|
886
|
-
let lastScanned = null;
|
|
887
|
-
for (const file of scanOrder) {
|
|
888
|
-
if (Date.now() - startedAt > budgetMs) {
|
|
889
|
-
budgetExhausted = true;
|
|
890
|
-
break;
|
|
891
|
-
}
|
|
892
|
-
scanned++;
|
|
893
|
-
lastScanned = file;
|
|
894
|
-
const folded = foldPath(normalizePath(file));
|
|
895
|
-
seenOnDisk.add(folded);
|
|
896
|
-
const entry = indexed.get(folded);
|
|
897
|
-
if (entry === void 0) {
|
|
898
|
-
added.push(file);
|
|
899
|
-
continue;
|
|
900
|
-
}
|
|
901
|
-
if (entry.parserSha !== parserFingerprintForLanguage(entry.language)) {
|
|
902
|
-
changed.push(file);
|
|
903
|
-
parserStale++;
|
|
904
|
-
continue;
|
|
905
|
-
}
|
|
906
|
-
if (entry.embedSha === "" && chunked.has(folded)) {
|
|
907
|
-
changed.push(file);
|
|
908
|
-
embedStale++;
|
|
909
|
-
continue;
|
|
910
|
-
}
|
|
911
|
-
let mtimeMs;
|
|
912
|
-
try {
|
|
913
|
-
mtimeMs = fs2.statSync(file).mtimeMs;
|
|
914
|
-
} catch {
|
|
915
|
-
changed.push(file);
|
|
916
|
-
continue;
|
|
917
|
-
}
|
|
918
|
-
if (entry.mtime !== 0 && mtimeMs / 1e3 === entry.mtime) continue;
|
|
919
|
-
const diskSha = fingerprintFile(file);
|
|
920
|
-
if (diskSha === null) {
|
|
921
|
-
changed.push(file);
|
|
922
|
-
continue;
|
|
923
|
-
}
|
|
924
|
-
if (diskSha === entry.sha) {
|
|
925
|
-
mtimeOnly++;
|
|
926
|
-
continue;
|
|
927
|
-
}
|
|
928
|
-
changed.push(file);
|
|
929
|
-
}
|
|
930
|
-
const trackedUnavailable = tracked.length === 0 && indexed.size > 0;
|
|
931
|
-
const removed = [];
|
|
932
|
-
if (!budgetExhausted) {
|
|
933
|
-
for (const [folded, entry] of indexed) {
|
|
934
|
-
if (seenOnDisk.has(folded)) continue;
|
|
935
|
-
if (Date.now() - startedAt > budgetMs) {
|
|
936
|
-
budgetExhausted = true;
|
|
937
|
-
removed.length = 0;
|
|
938
|
-
break;
|
|
939
|
-
}
|
|
940
|
-
try {
|
|
941
|
-
fs2.statSync(entry.filePath);
|
|
942
|
-
} catch (err) {
|
|
943
|
-
const code = err?.code;
|
|
944
|
-
if (code === "ENOENT" || code === "ENOTDIR") removed.push(entry.filePath);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
let enqueued = 0;
|
|
949
|
-
if (opts.dryRun !== true) {
|
|
950
|
-
const toEnqueue = [...changed, ...added, ...removed].map((p) => resolveIndexPath(p, cwd));
|
|
951
|
-
enqueueDirtyPathsSafe(toEnqueue, { alreadyResolved: true });
|
|
952
|
-
enqueued = toEnqueue.length;
|
|
953
|
-
if (budgetExhausted) {
|
|
954
|
-
if (lastScanned !== null) writeReconcileCursor(dbPath, projectRoot, lastScanned);
|
|
955
|
-
} else if (tracked.length > 0) {
|
|
956
|
-
clearReconcileCursor(dbPath, projectRoot);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
return {
|
|
960
|
-
scanned,
|
|
961
|
-
changed,
|
|
962
|
-
added,
|
|
963
|
-
removed,
|
|
964
|
-
mtimeOnly,
|
|
965
|
-
parserStale,
|
|
966
|
-
embedStale,
|
|
967
|
-
budgetExhausted,
|
|
968
|
-
trackedUnavailable,
|
|
969
|
-
unscanned: Math.max(0, tracked.length - scanned),
|
|
970
|
-
enqueued,
|
|
971
|
-
elapsedMs: Date.now() - startedAt
|
|
972
|
-
};
|
|
669
|
+
function buildReminder(indexed) {
|
|
670
|
+
return (indexed ? INDEXED_REMINDER : GENERIC_REMINDER) + NOTE_REMINDER;
|
|
973
671
|
}
|
|
974
672
|
|
|
975
|
-
// src/
|
|
673
|
+
// src/mcp_tool_pattern.ts
|
|
976
674
|
init_define_import_meta_env();
|
|
977
|
-
var
|
|
978
|
-
bash: "bash-output",
|
|
979
|
-
web: "web-output",
|
|
980
|
-
mcp: "mcp-output"
|
|
981
|
-
};
|
|
982
|
-
function fenceTagForCacheType(cacheType) {
|
|
983
|
-
return cacheType === "web" ? UNTRUSTED_WEB_TAG : UNTRUSTED_TOOL_TAG;
|
|
984
|
-
}
|
|
985
|
-
function fenceRecallListing(text, hits) {
|
|
986
|
-
const tags = new Set(hits.map((hit) => fenceTagForCacheType(hit.cacheType)));
|
|
987
|
-
const tag = tags.size === 1 ? [...tags][0] ?? UNTRUSTED_TOOL_TAG : UNTRUSTED_TOOL_TAG;
|
|
988
|
-
return fenceUntrusted(text, tag);
|
|
989
|
-
}
|
|
990
|
-
function fenceSnippetIfMatched(hit) {
|
|
991
|
-
const matches = scanAndRecord(hit.snippet);
|
|
992
|
-
if (matches.length === 0) return hit.snippet;
|
|
993
|
-
return fenceUntrustedContent(hit.snippet, matches, fenceTagForCacheType(hit.cacheType));
|
|
994
|
-
}
|
|
995
|
-
function printHits(query, hits) {
|
|
996
|
-
const w = (text) => {
|
|
997
|
-
process.stdout.write(text);
|
|
998
|
-
};
|
|
999
|
-
if (hits.length === 0) {
|
|
1000
|
-
w(query === void 0 ? "No cache entries yet.\n" : `No cache entries match: ${query}
|
|
1001
|
-
`);
|
|
1002
|
-
return;
|
|
1003
|
-
}
|
|
1004
|
-
const body = hits.map((hit) => {
|
|
1005
|
-
const label = hit.label.length > 80 ? hit.label.slice(0, 77) + "..." : hit.label;
|
|
1006
|
-
const pointer = hit.blobPresent ? ` (token-goat ${RECALL_COMMAND[hit.cacheType]} ${hit.id})` : " (blob expired -- content below is all that remains)";
|
|
1007
|
-
return `[${pad(hit.cacheType, 4)}] ${hit.id}
|
|
1008
|
-
${pointer}
|
|
1009
|
-
${label}
|
|
1010
|
-
${hit.snippet}
|
|
1011
|
-
`;
|
|
1012
|
-
}).join("\n");
|
|
1013
|
-
w(`${fenceRecallListing(body, hits)}
|
|
1014
|
-
`);
|
|
1015
|
-
}
|
|
1016
|
-
function runRecallCommand(query, opts = {}) {
|
|
1017
|
-
const browse = query === void 0 || query.trim() === "";
|
|
1018
|
-
const scope = {
|
|
1019
|
-
...opts.type !== void 0 ? { type: opts.type } : {},
|
|
1020
|
-
...opts.limit !== void 0 ? { limit: opts.limit } : {}
|
|
1021
|
-
};
|
|
1022
|
-
const effectiveLimit = opts.limit ?? RECALL_DEFAULT_LIMIT;
|
|
1023
|
-
const fetched = browse ? listRecentRecall({ ...scope, limit: effectiveLimit + 1 }) : searchRecall(query, { ...scope, limit: effectiveLimit + 1 });
|
|
1024
|
-
const hits = fetched.slice(0, effectiveLimit);
|
|
1025
|
-
if (fetched.length > hits.length) {
|
|
1026
|
-
process.stderr.write(`Showing ${hits.length} entries; more are available (raise --limit to see them).
|
|
1027
|
-
`);
|
|
1028
|
-
}
|
|
1029
|
-
if (opts.json === true) {
|
|
1030
|
-
const fenced = hits.map((hit) => ({ ...hit, snippet: fenceSnippetIfMatched(hit) }));
|
|
1031
|
-
process.stdout.write(`${displaySafeJson(fenced, 0)}
|
|
1032
|
-
`);
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
printHits(browse ? void 0 : query, hits);
|
|
1036
|
-
}
|
|
675
|
+
var MCP_TOOL_PATTERN = "^mcp__";
|
|
1037
676
|
|
|
1038
677
|
export {
|
|
1039
|
-
checkSymbolBodySize,
|
|
1040
|
-
MCP_TOOL_PATTERN,
|
|
1041
|
-
WEB_OUTPUT_SUBDIR,
|
|
1042
|
-
storeWebOutput,
|
|
1043
|
-
getWebOutput,
|
|
1044
|
-
getWebOutputRaw,
|
|
1045
|
-
getWebOutputByUrlFromDisk,
|
|
1046
|
-
DEFAULT_RECONCILE_BUDGET_MS,
|
|
1047
|
-
runReconcile,
|
|
1048
|
-
isReconcileClean,
|
|
1049
|
-
reconcileProject,
|
|
1050
|
-
RECALL_COMMAND,
|
|
1051
|
-
runRecallCommand,
|
|
1052
|
-
MAX_STDIN_BYTES,
|
|
1053
678
|
readStdinJson,
|
|
1054
679
|
diagnoseSqlFailure,
|
|
1055
680
|
cmdSessionSchema,
|
|
1056
681
|
cmdDescribe,
|
|
1057
|
-
HOOK_EVENTS,
|
|
1058
682
|
buildCommandManifest,
|
|
1059
683
|
flattenCommandNames,
|
|
1060
684
|
filterCommandManifest,
|
|
1061
|
-
formatCommandManifest
|
|
685
|
+
formatCommandManifest,
|
|
686
|
+
checkSymbolBodySize,
|
|
687
|
+
isIndexedProject,
|
|
688
|
+
buildReminder,
|
|
689
|
+
MCP_TOOL_PATTERN
|
|
1062
690
|
};
|