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.
- package/README.md +36 -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-66LODAUT.mjs → token-goat-chunk-4JJS54TR.mjs} +4 -3
- package/dist/token-goat-chunk-4LCCNRTG.mjs +313 -0
- package/dist/token-goat-chunk-54K3EUV3.mjs +35 -0
- 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-NILVK7XM.mjs → token-goat-chunk-64FBPDTK.mjs} +12 -6
- package/dist/{token-goat-chunk-LEG3JNJ6.mjs → token-goat-chunk-664RTTUV.mjs} +31 -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-F7QZRIWM.mjs → token-goat-chunk-7F2UBPD3.mjs} +42 -35
- package/dist/{token-goat-chunk-CC2PYJM7.mjs → token-goat-chunk-7IN2MKDS.mjs} +718 -595
- package/dist/token-goat-chunk-7NADEDKJ.mjs +124 -0
- package/dist/{token-goat-chunk-6SGLIPQB.mjs → token-goat-chunk-A3CK6N5Z.mjs} +621 -72
- package/dist/{token-goat-chunk-HXNAC4ZF.mjs → token-goat-chunk-AFLYLHDH.mjs} +48 -33
- package/dist/token-goat-chunk-AM5V6GSX.mjs +367 -0
- package/dist/{token-goat-chunk-I7CB3X4K.mjs → token-goat-chunk-APGZXSPS.mjs} +44 -148
- package/dist/{token-goat-chunk-BJBRGPBX.mjs → token-goat-chunk-ARDNEC2U.mjs} +11 -7
- package/dist/token-goat-chunk-ATCPY7EQ.mjs +134 -0
- package/dist/token-goat-chunk-B2RZZCSS.mjs +354 -0
- package/dist/{token-goat-chunk-QM76S6YS.mjs → token-goat-chunk-B45VMIIH.mjs} +6 -5
- package/dist/token-goat-chunk-BPGCUMR7.mjs +30 -0
- package/dist/{token-goat-chunk-GGLEE35R.mjs → token-goat-chunk-C63JQV5K.mjs} +49 -10
- package/dist/{token-goat-chunk-RJH64KQH.mjs → token-goat-chunk-COBQGL5S.mjs} +2661 -2440
- package/dist/token-goat-chunk-COTXZHTS.mjs +39 -0
- package/dist/token-goat-chunk-CYCEYAEO.mjs +265 -0
- package/dist/token-goat-chunk-CZ3LUXYZ.mjs +4115 -0
- package/dist/token-goat-chunk-DZX2YDPT.mjs +15 -0
- 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-6Z5ULNE5.mjs → token-goat-chunk-FBNQNSJK.mjs} +2490 -4957
- package/dist/{token-goat-chunk-NMTKNYGF.mjs → token-goat-chunk-FNFBKLRD.mjs} +74 -9
- package/dist/{token-goat-chunk-XI2VFAV6.mjs → token-goat-chunk-FZ3NEW5O.mjs} +33 -19
- package/dist/token-goat-chunk-G5PJ7AGM.mjs +36 -0
- package/dist/{token-goat-chunk-VE27HPIF.mjs → token-goat-chunk-GFBSN7BD.mjs} +30 -398
- package/dist/{token-goat-chunk-L45ZQRT7.mjs → token-goat-chunk-GOLEOXZP.mjs} +780 -786
- 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-CBMY2FGI.mjs → token-goat-chunk-HOJLCGDP.mjs} +17113 -15554
- package/dist/{token-goat-chunk-HUDC5GS5.mjs → token-goat-chunk-HYBFA5X3.mjs} +120 -19
- package/dist/token-goat-chunk-IVALLT3S.mjs +48 -0
- package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
- package/dist/{token-goat-chunk-UBUKHVYW.mjs → token-goat-chunk-IVKIZWAB.mjs} +3 -3
- package/dist/{token-goat-chunk-4JMWPWCS.mjs → token-goat-chunk-JB6QN6VF.mjs} +6 -4
- package/dist/{token-goat-chunk-Q4S3UQGO.mjs → token-goat-chunk-JDHE26RP.mjs} +10 -3
- package/dist/{token-goat-chunk-7R2XYKC5.mjs → token-goat-chunk-JDU3EXSU.mjs} +14 -10
- package/dist/token-goat-chunk-JDWCRD6M.mjs +253 -0
- package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-JN4XMLSD.mjs} +7 -4
- 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-4RN64ZND.mjs → token-goat-chunk-KWPNJBDH.mjs} +28 -3
- package/dist/token-goat-chunk-LOBGHXPB.mjs +242 -0
- package/dist/token-goat-chunk-MKPF4CL5.mjs +37 -0
- package/dist/token-goat-chunk-MNWKPRAL.mjs +13 -0
- package/dist/{token-goat-chunk-YWSP6IU7.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-VWZKZPSR.mjs → token-goat-chunk-PU7V3FD6.mjs} +8752 -11098
- package/dist/token-goat-chunk-PY533T7F.mjs +46 -0
- package/dist/token-goat-chunk-Q5VTGRH7.mjs +761 -0
- package/dist/{token-goat-chunk-IHKZ3QNA.mjs → token-goat-chunk-QCLDAQTS.mjs} +33 -19
- package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-QSBRTGM2.mjs} +9 -2
- package/dist/{token-goat-chunk-4STDIGYC.mjs → token-goat-chunk-RC35RBUL.mjs} +7 -5
- package/dist/{token-goat-chunk-D5ICEPSB.mjs → token-goat-chunk-RHXKCZX3.mjs} +887 -507
- package/dist/{token-goat-chunk-RSS3TLXU.mjs → token-goat-chunk-RZRTDST7.mjs} +17 -7
- package/dist/{token-goat-chunk-MAMQPC43.mjs → token-goat-chunk-SJHWVNDQ.mjs} +15 -21
- package/dist/token-goat-chunk-SMVRN2HU.mjs +188 -0
- package/dist/{token-goat-chunk-EL7M26WP.mjs → token-goat-chunk-SQSSNQPE.mjs} +2100 -1442
- package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-T4FK7VOV.mjs} +3 -3
- package/dist/token-goat-chunk-U4N3BN2W.mjs +92 -0
- package/dist/token-goat-chunk-UA5V6P3P.mjs +122 -0
- package/dist/{token-goat-chunk-XKY4VKJ4.mjs → token-goat-chunk-UQ5UK2T7.mjs} +15 -4
- package/dist/token-goat-chunk-USILZ3T3.mjs +53 -0
- package/dist/token-goat-chunk-VES7EL7O.mjs +205 -0
- package/dist/{token-goat-chunk-M56BWPBN.mjs → token-goat-chunk-VL3YIFHZ.mjs} +550 -49
- package/dist/{token-goat-chunk-IZXKVT4A.mjs → token-goat-chunk-VPBBTSJR.mjs} +362 -128
- package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-W3QCJS6G.mjs} +10 -2
- package/dist/{token-goat-chunk-FSTWAOW6.mjs → token-goat-chunk-WY3L4DVT.mjs} +11 -5
- package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
- package/dist/token-goat-chunk-XKI4SEMX.mjs +66 -0
- package/dist/token-goat-chunk-XU4P6Z24.mjs +133 -0
- package/dist/{token-goat-chunk-6CCQDAYY.mjs → token-goat-chunk-Y776AENC.mjs} +138 -33
- package/dist/token-goat-chunk-YARZFCZS.mjs +359 -0
- package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
- package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-Z44YO3QZ.mjs} +12 -6
- package/dist/token-goat-chunk-Z57YODA2.mjs +35 -0
- package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-ZCDTCVIS.mjs} +49 -30
- 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-SJEKA7Y2.mjs → token-goat-chunk-ZQSJMO2R.mjs} +381 -201
- package/dist/token-goat-hook-client.cjs +539 -0
- package/dist/token-goat-hook-client.mjs +26 -0
- package/dist/token-goat-hook.mjs +48 -28
- package/dist/token-goat.core.mjs +10 -45
- package/docs/C4_RUNTIME_ARCHITECTURE.md +3 -3
- package/docs/cli.md +82 -47
- package/docs/install.md +58 -23
- package/docs/security.md +7 -7
- package/package.json +17 -7
- package/scripts/verify-native-dist.mjs +386 -0
- package/dist/token-goat-chunk-4JJBFT7V.mjs +0 -20
- package/dist/token-goat-chunk-5NNYIUGV.mjs +0 -143
- package/dist/token-goat-chunk-6DQNNFJ6.mjs +0 -294
- package/dist/token-goat-chunk-7MAFDRVR.mjs +0 -47
- package/dist/token-goat-chunk-BCN2YQC6.mjs +0 -32
- package/dist/token-goat-chunk-D7GHQKQD.mjs +0 -30
- package/dist/token-goat-chunk-GMOUBOX4.mjs +0 -386
- package/dist/token-goat-chunk-IFORDBGC.mjs +0 -192
- package/dist/token-goat-chunk-JXK2HQXS.mjs +0 -318
- package/dist/token-goat-chunk-L7SDVGBT.mjs +0 -430
- package/dist/token-goat-chunk-MMLMALWK.mjs +0 -1381
- package/dist/token-goat-chunk-MVSWBNMD.mjs +0 -1985
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
accumulateResidentLine,
|
|
5
|
-
claudeConfigDir,
|
|
6
|
-
createResidentContextStats,
|
|
7
|
-
summarizeResidentContext
|
|
8
|
-
} from "./token-goat-chunk-MAMQPC43.mjs";
|
|
9
|
-
import {
|
|
10
|
-
commandHash,
|
|
11
|
-
getBashOutput,
|
|
12
|
-
normalizeCommandForCacheKey
|
|
13
|
-
} from "./token-goat-chunk-HXNAC4ZF.mjs";
|
|
14
|
-
import {
|
|
15
|
-
estimateTokens
|
|
16
|
-
} from "./token-goat-chunk-4JMWPWCS.mjs";
|
|
17
|
-
import {
|
|
18
|
-
init_define_import_meta_env
|
|
19
|
-
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
20
|
-
|
|
21
|
-
// src/waste.ts
|
|
22
|
-
init_define_import_meta_env();
|
|
23
|
-
import * as fs from "node:fs";
|
|
24
|
-
import * as path from "node:path";
|
|
25
|
-
import { StringDecoder } from "node:string_decoder";
|
|
26
|
-
function projectTranscriptsDir(projectRoot) {
|
|
27
|
-
const rootStr = path.resolve(projectRoot);
|
|
28
|
-
const slug = rootStr.replace(/[^A-Za-z0-9]/g, "-");
|
|
29
|
-
return path.join(claudeConfigDir(), "projects", slug);
|
|
30
|
-
}
|
|
31
|
-
function findLatestTranscript(projectRoot) {
|
|
32
|
-
const dir = projectTranscriptsDir(projectRoot);
|
|
33
|
-
let entries;
|
|
34
|
-
try {
|
|
35
|
-
entries = fs.readdirSync(dir).filter((f) => f.endsWith(".jsonl"));
|
|
36
|
-
} catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
let best = null;
|
|
40
|
-
for (const name of entries) {
|
|
41
|
-
const full = path.join(dir, name);
|
|
42
|
-
let stat;
|
|
43
|
-
try {
|
|
44
|
-
stat = fs.statSync(full);
|
|
45
|
-
} catch {
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (best === null || stat.mtimeMs > best.mtimeMs) best = { file: full, mtimeMs: stat.mtimeMs };
|
|
49
|
-
}
|
|
50
|
-
return best?.file ?? null;
|
|
51
|
-
}
|
|
52
|
-
function safeStringify(value) {
|
|
53
|
-
try {
|
|
54
|
-
return JSON.stringify(value) ?? "";
|
|
55
|
-
} catch {
|
|
56
|
-
return "";
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
var FILE_PATH_TOOLS = /* @__PURE__ */ new Set(["Read", "Edit", "Write", "NotebookEdit", "MultiEdit"]);
|
|
60
|
-
function extractFilePath(name, input) {
|
|
61
|
-
if (!FILE_PATH_TOOLS.has(name)) return null;
|
|
62
|
-
if (input === null || typeof input !== "object") return null;
|
|
63
|
-
const o = input;
|
|
64
|
-
const fp = o["file_path"];
|
|
65
|
-
if (typeof fp === "string") return fp;
|
|
66
|
-
const notebookPath = o["notebook_path"];
|
|
67
|
-
return typeof notebookPath === "string" ? notebookPath : null;
|
|
68
|
-
}
|
|
69
|
-
function extractCommand(name, input) {
|
|
70
|
-
if (name !== "Bash") return null;
|
|
71
|
-
if (input === null || typeof input !== "object") return null;
|
|
72
|
-
const cmd = input["command"];
|
|
73
|
-
return typeof cmd === "string" ? cmd : null;
|
|
74
|
-
}
|
|
75
|
-
function summarizeInput(name, input, filePath, command) {
|
|
76
|
-
if (filePath !== null) return filePath;
|
|
77
|
-
if (command !== null) return command.length > 100 ? `${command.slice(0, 100)}\u2026` : command;
|
|
78
|
-
if (input === null || typeof input !== "object") return "";
|
|
79
|
-
const o = input;
|
|
80
|
-
for (const key of ["pattern", "query", "path", "description", "prompt"]) {
|
|
81
|
-
const v = o[key];
|
|
82
|
-
if (typeof v === "string") return v.length > 100 ? `${v.slice(0, 100)}\u2026` : v;
|
|
83
|
-
}
|
|
84
|
-
const s = safeStringify(input);
|
|
85
|
-
return s.length > 100 ? `${s.slice(0, 100)}\u2026` : s;
|
|
86
|
-
}
|
|
87
|
-
function extractResultText(content) {
|
|
88
|
-
if (typeof content === "string") return content;
|
|
89
|
-
if (Array.isArray(content)) {
|
|
90
|
-
return content.map((b) => {
|
|
91
|
-
if (b !== null && typeof b === "object" && b["type"] === "text") {
|
|
92
|
-
const t = b["text"];
|
|
93
|
-
return typeof t === "string" ? t : "";
|
|
94
|
-
}
|
|
95
|
-
return "";
|
|
96
|
-
}).join("\n");
|
|
97
|
-
}
|
|
98
|
-
return "";
|
|
99
|
-
}
|
|
100
|
-
function* readFileLines(filePath) {
|
|
101
|
-
const fd = fs.openSync(filePath, "r");
|
|
102
|
-
try {
|
|
103
|
-
const buf = Buffer.allocUnsafe(1 << 20);
|
|
104
|
-
const decoder = new StringDecoder("utf8");
|
|
105
|
-
let carry = "";
|
|
106
|
-
for (; ; ) {
|
|
107
|
-
const bytes = fs.readSync(fd, buf, 0, buf.length, null);
|
|
108
|
-
if (bytes === 0) break;
|
|
109
|
-
const lines = (carry + decoder.write(buf.subarray(0, bytes))).split("\n");
|
|
110
|
-
carry = lines.pop() ?? "";
|
|
111
|
-
for (const line of lines) yield line;
|
|
112
|
-
}
|
|
113
|
-
carry += decoder.end();
|
|
114
|
-
if (carry !== "") yield carry;
|
|
115
|
-
} finally {
|
|
116
|
-
fs.closeSync(fd);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function parseTranscript(transcriptPath) {
|
|
120
|
-
const calls = [];
|
|
121
|
-
const resultTextById = /* @__PURE__ */ new Map();
|
|
122
|
-
const assistantTurns = [];
|
|
123
|
-
const resident = createResidentContextStats();
|
|
124
|
-
let seq = 0;
|
|
125
|
-
for (const line of readFileLines(transcriptPath)) {
|
|
126
|
-
const trimmed = line.trim();
|
|
127
|
-
if (trimmed === "") continue;
|
|
128
|
-
let obj;
|
|
129
|
-
try {
|
|
130
|
-
obj = JSON.parse(trimmed);
|
|
131
|
-
} catch {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (obj === null || typeof obj !== "object") continue;
|
|
135
|
-
const o = obj;
|
|
136
|
-
accumulateResidentLine(resident, o, trimmed.length);
|
|
137
|
-
const message = o["message"];
|
|
138
|
-
if (message === null || typeof message !== "object") continue;
|
|
139
|
-
const messageObj = message;
|
|
140
|
-
const content = messageObj["content"];
|
|
141
|
-
if (!Array.isArray(content)) continue;
|
|
142
|
-
const role = typeof messageObj["role"] === "string" ? messageObj["role"] : null;
|
|
143
|
-
const cwd = typeof o["cwd"] === "string" ? o["cwd"] : null;
|
|
144
|
-
let turnTextTokens = 0;
|
|
145
|
-
let sawTextBlock = false;
|
|
146
|
-
for (const block of content) {
|
|
147
|
-
if (block === null || typeof block !== "object") continue;
|
|
148
|
-
const b = block;
|
|
149
|
-
if (b["type"] === "tool_use" && typeof b["id"] === "string" && typeof b["name"] === "string") {
|
|
150
|
-
const name = b["name"];
|
|
151
|
-
const input = b["input"];
|
|
152
|
-
const filePath = extractFilePath(name, input);
|
|
153
|
-
const command = extractCommand(name, input);
|
|
154
|
-
calls.push({
|
|
155
|
-
seq: seq++,
|
|
156
|
-
id: b["id"],
|
|
157
|
-
name,
|
|
158
|
-
input,
|
|
159
|
-
filePath,
|
|
160
|
-
command,
|
|
161
|
-
summary: summarizeInput(name, input, filePath, command),
|
|
162
|
-
cwd
|
|
163
|
-
});
|
|
164
|
-
} else if (b["type"] === "tool_result" && typeof b["tool_use_id"] === "string") {
|
|
165
|
-
const id = b["tool_use_id"];
|
|
166
|
-
if (!resultTextById.has(id)) {
|
|
167
|
-
resultTextById.set(id, extractResultText(b["content"]));
|
|
168
|
-
}
|
|
169
|
-
} else if (role === "assistant" && b["type"] === "text" && typeof b["text"] === "string") {
|
|
170
|
-
sawTextBlock = true;
|
|
171
|
-
turnTextTokens += estimateTokens(b["text"]);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (role === "assistant" && sawTextBlock) assistantTurns.push(turnTextTokens);
|
|
175
|
-
}
|
|
176
|
-
return { calls, resultTextById, assistantTurns, resident };
|
|
177
|
-
}
|
|
178
|
-
function costPerCall(parsed) {
|
|
179
|
-
return parsed.calls.map((c) => ({
|
|
180
|
-
...c,
|
|
181
|
-
tokens: estimateTokens(parsed.resultTextById.get(c.id) ?? "")
|
|
182
|
-
}));
|
|
183
|
-
}
|
|
184
|
-
function aggregateSortedDesc(pairs) {
|
|
185
|
-
return [...pairs].map(([key, tokens]) => ({ key, tokens })).sort((a, b) => b.tokens - a.tokens);
|
|
186
|
-
}
|
|
187
|
-
function tokensByTool(costs) {
|
|
188
|
-
const m = /* @__PURE__ */ new Map();
|
|
189
|
-
for (const c of costs) m.set(c.name, (m.get(c.name) ?? 0) + c.tokens);
|
|
190
|
-
return aggregateSortedDesc(m);
|
|
191
|
-
}
|
|
192
|
-
function tokensByFile(costs) {
|
|
193
|
-
const m = /* @__PURE__ */ new Map();
|
|
194
|
-
for (const c of costs) {
|
|
195
|
-
if (c.filePath === null) continue;
|
|
196
|
-
m.set(c.filePath, (m.get(c.filePath) ?? 0) + c.tokens);
|
|
197
|
-
}
|
|
198
|
-
return aggregateSortedDesc(m);
|
|
199
|
-
}
|
|
200
|
-
function topExpensiveCalls(costs, n) {
|
|
201
|
-
return [...costs].sort((a, b) => b.tokens - a.tokens).slice(0, n);
|
|
202
|
-
}
|
|
203
|
-
function neverTouchedAgain(costs) {
|
|
204
|
-
const readsByFile = /* @__PURE__ */ new Map();
|
|
205
|
-
for (const c of costs) {
|
|
206
|
-
if (c.name !== "Read" || c.filePath === null) continue;
|
|
207
|
-
const arr = readsByFile.get(c.filePath) ?? [];
|
|
208
|
-
arr.push(c);
|
|
209
|
-
readsByFile.set(c.filePath, arr);
|
|
210
|
-
}
|
|
211
|
-
const out = [];
|
|
212
|
-
for (const [filePath, reads] of readsByFile) {
|
|
213
|
-
const firstSeq = Math.min(...reads.map((r) => r.seq));
|
|
214
|
-
const touchedLater = costs.some((c) => {
|
|
215
|
-
if (c.seq <= firstSeq) return false;
|
|
216
|
-
if (c.filePath === filePath) return true;
|
|
217
|
-
return safeStringify(c.input).includes(filePath);
|
|
218
|
-
});
|
|
219
|
-
if (!touchedLater) {
|
|
220
|
-
out.push({ filePath, tokens: reads.reduce((n, r) => n + r.tokens, 0) });
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return out.sort((a, b) => b.tokens - a.tokens);
|
|
224
|
-
}
|
|
225
|
-
async function repeatedUncompressedBashCommands(costs) {
|
|
226
|
-
const groups = /* @__PURE__ */ new Map();
|
|
227
|
-
for (const c of costs) {
|
|
228
|
-
if (c.name !== "Bash" || c.command === null) continue;
|
|
229
|
-
const norm = normalizeCommandForCacheKey(c.command);
|
|
230
|
-
const arr = groups.get(norm) ?? [];
|
|
231
|
-
arr.push(c);
|
|
232
|
-
groups.set(norm, arr);
|
|
233
|
-
}
|
|
234
|
-
const out = [];
|
|
235
|
-
for (const [norm, calls] of groups) {
|
|
236
|
-
if (calls.length < 2) continue;
|
|
237
|
-
let cached = false;
|
|
238
|
-
for (const c of calls) {
|
|
239
|
-
try {
|
|
240
|
-
const hash = await commandHash(c.command, c.cwd);
|
|
241
|
-
if (getBashOutput(hash) !== null) {
|
|
242
|
-
cached = true;
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
} catch {
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
if (cached) continue;
|
|
249
|
-
const totalTokens = calls.reduce((n, c) => n + c.tokens, 0);
|
|
250
|
-
out.push({
|
|
251
|
-
normalized: norm,
|
|
252
|
-
count: calls.length,
|
|
253
|
-
totalTokens,
|
|
254
|
-
avgTokens: Math.round(totalTokens / calls.length)
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
return out.sort((a, b) => b.totalTokens - a.totalTokens);
|
|
258
|
-
}
|
|
259
|
-
function assistantOutputCost(assistantTurns) {
|
|
260
|
-
const turnCount = assistantTurns.length;
|
|
261
|
-
let generatedTokens = 0;
|
|
262
|
-
let resendCeilingTokens = 0;
|
|
263
|
-
for (let i = 0; i < turnCount; i++) {
|
|
264
|
-
const tokens = assistantTurns[i] ?? 0;
|
|
265
|
-
generatedTokens += tokens;
|
|
266
|
-
resendCeilingTokens += tokens * (turnCount - 1 - i);
|
|
267
|
-
}
|
|
268
|
-
return { turnCount, generatedTokens, resendCeilingTokens };
|
|
269
|
-
}
|
|
270
|
-
async function buildWasteReport(transcriptPath, opts = {}) {
|
|
271
|
-
const parsed = parseTranscript(transcriptPath);
|
|
272
|
-
const costs = costPerCall(parsed);
|
|
273
|
-
const topN = opts.topN ?? 10;
|
|
274
|
-
return {
|
|
275
|
-
transcriptPath,
|
|
276
|
-
totalTokens: costs.reduce((n, c) => n + c.tokens, 0),
|
|
277
|
-
tokensByTool: tokensByTool(costs),
|
|
278
|
-
tokensByFile: tokensByFile(costs),
|
|
279
|
-
topCalls: topExpensiveCalls(costs, topN).map((c) => ({ seq: c.seq, name: c.name, summary: c.summary, tokens: c.tokens })),
|
|
280
|
-
neverTouchedAgain: neverTouchedAgain(costs),
|
|
281
|
-
repeatedUncompressedBash: await repeatedUncompressedBashCommands(costs),
|
|
282
|
-
assistantOutput: assistantOutputCost(parsed.assistantTurns),
|
|
283
|
-
residentContext: summarizeResidentContext(parsed.resident)
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export {
|
|
288
|
-
projectTranscriptsDir,
|
|
289
|
-
findLatestTranscript,
|
|
290
|
-
safeStringify,
|
|
291
|
-
extractResultText,
|
|
292
|
-
readFileLines,
|
|
293
|
-
buildWasteReport
|
|
294
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
buildEvent,
|
|
5
|
-
relay,
|
|
6
|
-
relayInProcess
|
|
7
|
-
} from "./token-goat-chunk-EL7M26WP.mjs";
|
|
8
|
-
import "./token-goat-chunk-F7QZRIWM.mjs";
|
|
9
|
-
import "./token-goat-chunk-I7CB3X4K.mjs";
|
|
10
|
-
import {
|
|
11
|
-
MAX_STDIN_BYTES,
|
|
12
|
-
readStdinJson
|
|
13
|
-
} from "./token-goat-chunk-VE27HPIF.mjs";
|
|
14
|
-
import "./token-goat-chunk-6Z5ULNE5.mjs";
|
|
15
|
-
import "./token-goat-chunk-IZXKVT4A.mjs";
|
|
16
|
-
import "./token-goat-chunk-RJH64KQH.mjs";
|
|
17
|
-
import "./token-goat-chunk-6DQNNFJ6.mjs";
|
|
18
|
-
import "./token-goat-chunk-MMLMALWK.mjs";
|
|
19
|
-
import "./token-goat-chunk-L7SDVGBT.mjs";
|
|
20
|
-
import "./token-goat-chunk-6CCQDAYY.mjs";
|
|
21
|
-
import "./token-goat-chunk-GGLEE35R.mjs";
|
|
22
|
-
import "./token-goat-chunk-MAMQPC43.mjs";
|
|
23
|
-
import "./token-goat-chunk-HXNAC4ZF.mjs";
|
|
24
|
-
import "./token-goat-chunk-BJBRGPBX.mjs";
|
|
25
|
-
import "./token-goat-chunk-4JMWPWCS.mjs";
|
|
26
|
-
import "./token-goat-chunk-4RN64ZND.mjs";
|
|
27
|
-
import "./token-goat-chunk-MVSWBNMD.mjs";
|
|
28
|
-
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
29
|
-
import "./token-goat-chunk-D5ICEPSB.mjs";
|
|
30
|
-
import "./token-goat-chunk-HUDC5GS5.mjs";
|
|
31
|
-
import "./token-goat-chunk-M56BWPBN.mjs";
|
|
32
|
-
import "./token-goat-chunk-CC2PYJM7.mjs";
|
|
33
|
-
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
34
|
-
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
35
|
-
import "./token-goat-chunk-L45ZQRT7.mjs";
|
|
36
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
37
|
-
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
38
|
-
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
39
|
-
import "./token-goat-chunk-RRNZMM3A.mjs";
|
|
40
|
-
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
41
|
-
export {
|
|
42
|
-
MAX_STDIN_BYTES,
|
|
43
|
-
buildEvent,
|
|
44
|
-
readStdinJson,
|
|
45
|
-
relay,
|
|
46
|
-
relayInProcess
|
|
47
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
5
|
-
DEFAULT_TIMEOUT_SECONDS,
|
|
6
|
-
MAX_CAPTURE_BYTES,
|
|
7
|
-
resolveFilter,
|
|
8
|
-
run,
|
|
9
|
-
runRaw
|
|
10
|
-
} from "./token-goat-chunk-F7QZRIWM.mjs";
|
|
11
|
-
import "./token-goat-chunk-RJH64KQH.mjs";
|
|
12
|
-
import "./token-goat-chunk-HXNAC4ZF.mjs";
|
|
13
|
-
import "./token-goat-chunk-BJBRGPBX.mjs";
|
|
14
|
-
import "./token-goat-chunk-4RN64ZND.mjs";
|
|
15
|
-
import "./token-goat-chunk-MVSWBNMD.mjs";
|
|
16
|
-
import "./token-goat-chunk-HUDC5GS5.mjs";
|
|
17
|
-
import "./token-goat-chunk-M56BWPBN.mjs";
|
|
18
|
-
import "./token-goat-chunk-CC2PYJM7.mjs";
|
|
19
|
-
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
20
|
-
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
21
|
-
import "./token-goat-chunk-L45ZQRT7.mjs";
|
|
22
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
23
|
-
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
24
|
-
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
25
|
-
export {
|
|
26
|
-
DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
27
|
-
DEFAULT_TIMEOUT_SECONDS,
|
|
28
|
-
MAX_CAPTURE_BYTES,
|
|
29
|
-
resolveFilter,
|
|
30
|
-
run,
|
|
31
|
-
runRaw
|
|
32
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
-
const require = __cjsRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
MAX_RESUME_CHARS,
|
|
5
|
-
MAX_RESUME_TOKENS,
|
|
6
|
-
buildResumePacket
|
|
7
|
-
} from "./token-goat-chunk-XI2VFAV6.mjs";
|
|
8
|
-
import "./token-goat-chunk-L7SDVGBT.mjs";
|
|
9
|
-
import "./token-goat-chunk-6CCQDAYY.mjs";
|
|
10
|
-
import "./token-goat-chunk-GGLEE35R.mjs";
|
|
11
|
-
import "./token-goat-chunk-MAMQPC43.mjs";
|
|
12
|
-
import "./token-goat-chunk-HXNAC4ZF.mjs";
|
|
13
|
-
import "./token-goat-chunk-BJBRGPBX.mjs";
|
|
14
|
-
import "./token-goat-chunk-4JMWPWCS.mjs";
|
|
15
|
-
import "./token-goat-chunk-4RN64ZND.mjs";
|
|
16
|
-
import "./token-goat-chunk-MVSWBNMD.mjs";
|
|
17
|
-
import "./token-goat-chunk-HUDC5GS5.mjs";
|
|
18
|
-
import "./token-goat-chunk-M56BWPBN.mjs";
|
|
19
|
-
import "./token-goat-chunk-CC2PYJM7.mjs";
|
|
20
|
-
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
21
|
-
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
22
|
-
import "./token-goat-chunk-L45ZQRT7.mjs";
|
|
23
|
-
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
24
|
-
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
25
|
-
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
26
|
-
export {
|
|
27
|
-
MAX_RESUME_CHARS,
|
|
28
|
-
MAX_RESUME_TOKENS,
|
|
29
|
-
buildResumePacket
|
|
30
|
-
};
|