token-goat 2.9.18 → 2.9.20
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 +5 -1
- package/dist/token-goat-chunk-2CLWWRFR.mjs +26 -0
- package/dist/{token-goat-chunk-LTYWLKAG.mjs → token-goat-chunk-2Q3N5KUQ.mjs} +1283 -1012
- package/dist/{token-goat-chunk-6LGVCCMY.mjs → token-goat-chunk-3OGZOFLS.mjs} +26 -16
- package/dist/{token-goat-chunk-QML7ITHJ.mjs → token-goat-chunk-3VTJC7KU.mjs} +693 -438
- package/dist/{token-goat-chunk-QIDLJGXZ.mjs → token-goat-chunk-6LJNM4ZZ.mjs} +29 -5
- package/dist/{token-goat-chunk-CA6V36KW.mjs → token-goat-chunk-74ADIZZX.mjs} +68 -50
- package/dist/{token-goat-chunk-52IMXJ2L.mjs → token-goat-chunk-ASTBLE2R.mjs} +4 -4
- package/dist/token-goat-chunk-AU2K2QHR.mjs +20 -0
- package/dist/token-goat-chunk-BQIC3AVL.mjs +292 -0
- package/dist/token-goat-chunk-CBXLE54Q.mjs +30 -0
- package/dist/{token-goat-chunk-LMFO66YD.mjs → token-goat-chunk-DA43OE7L.mjs} +1 -1
- package/dist/{token-goat-chunk-ARNRFR6M.mjs → token-goat-chunk-DNAF26L4.mjs} +1 -1
- package/dist/{token-goat-chunk-BFEWOMA3.mjs → token-goat-chunk-DPHJU3P7.mjs} +1186 -4573
- package/dist/{token-goat-chunk-OWSJJY5R.mjs → token-goat-chunk-DW4VKU7D.mjs} +5 -5
- package/dist/token-goat-chunk-DYUBZZNP.mjs +198 -0
- package/dist/{token-goat-chunk-W3E65QOW.mjs → token-goat-chunk-ERGHDBC6.mjs} +310 -47
- package/dist/token-goat-chunk-EUZKG7ZO.mjs +304 -0
- package/dist/{token-goat-chunk-5MMJAJF3.mjs → token-goat-chunk-FWYZVS3E.mjs} +324 -31
- package/dist/token-goat-chunk-G6SYQQO7.mjs +41 -0
- package/dist/{token-goat-chunk-YQZE5NS6.mjs → token-goat-chunk-GIPMOGOI.mjs} +6 -6
- package/dist/{token-goat-chunk-BWCRC23L.mjs → token-goat-chunk-H4VC5TR6.mjs} +29 -20
- package/dist/{token-goat-chunk-V3ZWBEHM.mjs → token-goat-chunk-I5PQRHFE.mjs} +103 -24
- package/dist/token-goat-chunk-ITWYDOKP.mjs +341 -0
- package/dist/{token-goat-chunk-I67CPTDD.mjs → token-goat-chunk-K3ZNBN4U.mjs} +19 -14
- package/dist/{token-goat-chunk-HPOFR6QX.mjs → token-goat-chunk-K5XPIUVB.mjs} +222 -61
- package/dist/token-goat-chunk-KT75DZK4.mjs +1989 -0
- package/dist/{token-goat-chunk-H3FONFBO.mjs → token-goat-chunk-MNJWG2ZO.mjs} +3 -3
- package/dist/{token-goat-chunk-GRI6HWX3.mjs → token-goat-chunk-MUJV7BR3.mjs} +1 -1
- package/dist/{token-goat-chunk-ERTXEKB6.mjs → token-goat-chunk-NMTKNYGF.mjs} +2 -0
- package/dist/{token-goat-chunk-LA3O4JGD.mjs → token-goat-chunk-ODF7H7WS.mjs} +3 -3
- package/dist/{token-goat-chunk-K4DG6EEF.mjs → token-goat-chunk-ONMU7BON.mjs} +7 -8
- package/dist/{token-goat-chunk-4EXFN2AW.mjs → token-goat-chunk-OZRSREKR.mjs} +2 -2
- package/dist/{token-goat-chunk-EPXNOKIV.mjs → token-goat-chunk-P4XBHZXU.mjs} +2 -2
- package/dist/{token-goat-chunk-CTOYJ232.mjs → token-goat-chunk-PAVWB4L4.mjs} +173 -1840
- package/dist/{token-goat-chunk-UENEL6KX.mjs → token-goat-chunk-PTW22MRC.mjs} +2 -2
- package/dist/token-goat-chunk-SL454EN5.mjs +1816 -0
- package/dist/token-goat-chunk-SP5QR2HN.mjs +1379 -0
- package/dist/{token-goat-chunk-7VLWNQDQ.mjs → token-goat-chunk-T46UKRFM.mjs} +1 -1
- package/dist/{token-goat-chunk-L7VCX33I.mjs → token-goat-chunk-T63VHOL3.mjs} +40 -10
- package/dist/token-goat-chunk-VSJGPEBB.mjs +248 -0
- package/dist/{token-goat-chunk-HIZXQVNU.mjs → token-goat-chunk-VYXGHGUY.mjs} +4 -4
- package/dist/token-goat-chunk-W6QYCWAT.mjs +128 -0
- package/dist/{token-goat-chunk-WFX2V3OF.mjs → token-goat-chunk-Z4ALQADF.mjs} +579 -422
- package/dist/token-goat-chunk-ZHFM4DHJ.mjs +324 -0
- package/dist/token-goat-hook.mjs +18 -12
- package/dist/token-goat.core.mjs +29 -20
- package/docs/C4_RUNTIME_ARCHITECTURE.md +1 -1
- package/docs/cli.md +15 -13
- package/docs/install.md +1 -1
- package/docs/security.md +2 -2
- package/package.json +3 -2
- package/dist/token-goat-chunk-2KTZ6J7T.mjs +0 -173
- package/dist/token-goat-chunk-34OUJ2IE.mjs +0 -35
- package/dist/token-goat-chunk-RHHFEXKF.mjs +0 -93
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
querySheet,
|
|
11
11
|
rangeSheet,
|
|
12
12
|
xlsxColumns
|
|
13
|
-
} from "./token-goat-chunk-
|
|
14
|
-
import "./token-goat-chunk-
|
|
13
|
+
} from "./token-goat-chunk-ODF7H7WS.mjs";
|
|
14
|
+
import "./token-goat-chunk-P4XBHZXU.mjs";
|
|
15
15
|
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
16
|
-
import "./token-goat-chunk-
|
|
16
|
+
import "./token-goat-chunk-T46UKRFM.mjs";
|
|
17
17
|
import "./token-goat-chunk-XTQAOTSO.mjs";
|
|
18
18
|
import "./token-goat-chunk-AH6QILZM.mjs";
|
|
19
|
-
import "./token-goat-chunk-
|
|
20
|
-
import "./token-goat-chunk-
|
|
19
|
+
import "./token-goat-chunk-6LJNM4ZZ.mjs";
|
|
20
|
+
import "./token-goat-chunk-NMTKNYGF.mjs";
|
|
21
21
|
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
22
22
|
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
23
23
|
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
buildCopilotWasteReport,
|
|
5
|
+
findProjectSession,
|
|
6
|
+
isCopilotTranscript
|
|
7
|
+
} from "./token-goat-chunk-EUZKG7ZO.mjs";
|
|
8
|
+
import {
|
|
9
|
+
buildWasteReport
|
|
10
|
+
} from "./token-goat-chunk-BQIC3AVL.mjs";
|
|
11
|
+
import "./token-goat-chunk-SP5QR2HN.mjs";
|
|
12
|
+
import "./token-goat-chunk-ZHFM4DHJ.mjs";
|
|
13
|
+
import "./token-goat-chunk-SL454EN5.mjs";
|
|
14
|
+
import "./token-goat-chunk-K5XPIUVB.mjs";
|
|
15
|
+
import "./token-goat-chunk-K3ZNBN4U.mjs";
|
|
16
|
+
import "./token-goat-chunk-T63VHOL3.mjs";
|
|
17
|
+
import {
|
|
18
|
+
resolveProjectRoot
|
|
19
|
+
} from "./token-goat-chunk-74ADIZZX.mjs";
|
|
20
|
+
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
21
|
+
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
22
|
+
import "./token-goat-chunk-6LJNM4ZZ.mjs";
|
|
23
|
+
import {
|
|
24
|
+
displaySafeJson
|
|
25
|
+
} from "./token-goat-chunk-NMTKNYGF.mjs";
|
|
26
|
+
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
27
|
+
import {
|
|
28
|
+
init_define_import_meta_env
|
|
29
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
30
|
+
|
|
31
|
+
// src/cli_audit.ts
|
|
32
|
+
init_define_import_meta_env();
|
|
33
|
+
import * as fs from "node:fs";
|
|
34
|
+
import * as path from "node:path";
|
|
35
|
+
function buildFeedbackCardFromClaude(report) {
|
|
36
|
+
const preAudit = [];
|
|
37
|
+
const fixes = [];
|
|
38
|
+
if (report.neverTouchedAgain.length > 0) {
|
|
39
|
+
const files = report.neverTouchedAgain.map((f) => path.basename(f.filePath)).join(", ");
|
|
40
|
+
preAudit.push(`Whole-file reads without reuse: ${files} (${report.neverTouchedAgain.length} file(s) read once via Read)`);
|
|
41
|
+
fixes.push('Prefer `token-goat symbol` or `read "file::symbol"` instead of reading whole files.');
|
|
42
|
+
}
|
|
43
|
+
if (report.repeatedUncompressedBash.length > 0) {
|
|
44
|
+
const cmds = report.repeatedUncompressedBash.map((b) => `"${b.normalized.slice(0, 40)}" (${b.count}x)`).join(", ");
|
|
45
|
+
preAudit.push(`Repeated uncompressed terminal commands: ${cmds}`);
|
|
46
|
+
fixes.push("Use token-goat bash-output cache or compress flags for repetitive terminal invocations.");
|
|
47
|
+
}
|
|
48
|
+
if (preAudit.length === 0) {
|
|
49
|
+
preAudit.push("Pre-audit session: No missed surgical reads or friction detected; gate adhered to cleanly.");
|
|
50
|
+
}
|
|
51
|
+
if (fixes.length === 0) {
|
|
52
|
+
fixes.push("Maintain current surgical read and caching discipline.");
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
taskSummary: `Engineering session in project (${report.totalTokens.toLocaleString()} tokens recorded across tool invocations).`,
|
|
56
|
+
preAuditFindings: preAudit,
|
|
57
|
+
auditExecutionFindings: [],
|
|
58
|
+
recommendedFix: fixes
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function buildFeedbackCardFromCopilot(report) {
|
|
62
|
+
const preAudit = [];
|
|
63
|
+
const fixes = [];
|
|
64
|
+
const repeatedBlocks = report.blocks.filter((b) => b.repeatCount > 0);
|
|
65
|
+
if (repeatedBlocks.length > 0) {
|
|
66
|
+
const kinds = repeatedBlocks.map((b) => `${b.kind} (${b.repeatCount}x repeat, ${b.repeatBytes} B)`).join(", ");
|
|
67
|
+
preAudit.push(`Repeated prompt blocks across turns: ${kinds}`);
|
|
68
|
+
fixes.push("Deduplicate repeated prompt instructions or context blocks across turns.");
|
|
69
|
+
}
|
|
70
|
+
if (report.mcpTools && report.mcpTools.servers.length > 0) {
|
|
71
|
+
const totalMcpTokens = report.mcpTools.servers.reduce((sum, s) => sum + s.estimatedTokens, 0);
|
|
72
|
+
const heavy = report.mcpTools.servers.filter((s) => s.estimatedTokens > 1e3);
|
|
73
|
+
if (heavy.length > 0 || totalMcpTokens > 1500) {
|
|
74
|
+
const details = report.mcpTools.servers.map((s) => `${s.serverName} (${s.toolCount} tool(s), ~${s.estimatedTokens.toLocaleString()} tok/turn)`).join(", ");
|
|
75
|
+
const turns = Math.max(1, report.turns);
|
|
76
|
+
const cumulative = totalMcpTokens * turns;
|
|
77
|
+
preAudit.push(
|
|
78
|
+
`High fixed MCP tool definition overhead: ${details}; total ~${totalMcpTokens.toLocaleString()} tok/turn re-sent across ${turns} turn(s) (~${cumulative.toLocaleString()} cumulative tokens).`
|
|
79
|
+
);
|
|
80
|
+
const heavyNames = (heavy.length > 0 ? heavy : report.mcpTools.servers).map((s) => s.serverName).join(", ");
|
|
81
|
+
fixes.push(
|
|
82
|
+
`Disable unused MCP server(s) (${heavyNames}) via 'copilot mcp disable <name>' or exclude individual tools with '--excluded-tools'.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (preAudit.length === 0) {
|
|
87
|
+
preAudit.push("Pre-audit session: No missed surgical reads or friction detected; gate adhered to cleanly.");
|
|
88
|
+
}
|
|
89
|
+
if (fixes.length === 0) {
|
|
90
|
+
fixes.push("Maintain current token-efficient tooling and MCP server configuration.");
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
taskSummary: `Copilot CLI session (${report.turns} turn(s) recorded in ${report.sessionId}).`,
|
|
94
|
+
preAuditFindings: preAudit,
|
|
95
|
+
auditExecutionFindings: [],
|
|
96
|
+
recommendedFix: fixes
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function formatMaintainerCard(card) {
|
|
100
|
+
const lines = [
|
|
101
|
+
"Maintainer Feedback Card",
|
|
102
|
+
"",
|
|
103
|
+
`\u2022 Task Summary: ${card.taskSummary}`,
|
|
104
|
+
"\u2022 Friction & Missed Savings:"
|
|
105
|
+
];
|
|
106
|
+
for (const f of card.preAuditFindings) {
|
|
107
|
+
lines.push(` - ${f}`);
|
|
108
|
+
}
|
|
109
|
+
if (card.auditExecutionFindings.length > 0) {
|
|
110
|
+
for (const a of card.auditExecutionFindings) {
|
|
111
|
+
lines.push(` - Audit Execution: ${a}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
lines.push("\u2022 Recommended Fix:");
|
|
115
|
+
for (const r of card.recommendedFix) {
|
|
116
|
+
lines.push(` - ${r}`);
|
|
117
|
+
}
|
|
118
|
+
return lines.join("\n") + "\n";
|
|
119
|
+
}
|
|
120
|
+
async function runAuditCommand(opts = {}) {
|
|
121
|
+
const projectRoot = resolveProjectRoot(opts.project !== void 0 ? { project: opts.project } : {});
|
|
122
|
+
if (opts.transcript !== void 0) {
|
|
123
|
+
const resolved = path.resolve(opts.transcript);
|
|
124
|
+
if (!fs.existsSync(resolved)) {
|
|
125
|
+
const err = `transcript not found: ${resolved}`;
|
|
126
|
+
if (opts.json === true) {
|
|
127
|
+
process.stdout.write(`${displaySafeJson({ error: err }, 0)}
|
|
128
|
+
`);
|
|
129
|
+
} else {
|
|
130
|
+
process.stderr.write(`token-goat: ${err}
|
|
131
|
+
`);
|
|
132
|
+
}
|
|
133
|
+
process.exitCode = 1;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (isCopilotTranscript(resolved)) {
|
|
137
|
+
const report3 = buildCopilotWasteReport(resolved);
|
|
138
|
+
const card3 = buildFeedbackCardFromCopilot(report3);
|
|
139
|
+
if (opts.json === true) {
|
|
140
|
+
process.stdout.write(`${displaySafeJson(card3, 0)}
|
|
141
|
+
`);
|
|
142
|
+
} else {
|
|
143
|
+
process.stdout.write(formatMaintainerCard(card3));
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const report2 = await buildWasteReport(resolved);
|
|
148
|
+
const card2 = buildFeedbackCardFromClaude(report2);
|
|
149
|
+
if (opts.json === true) {
|
|
150
|
+
process.stdout.write(`${displaySafeJson(card2, 0)}
|
|
151
|
+
`);
|
|
152
|
+
} else {
|
|
153
|
+
process.stdout.write(formatMaintainerCard(card2));
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const detected = findProjectSession(projectRoot);
|
|
158
|
+
if (detected === null) {
|
|
159
|
+
const err = "no session transcript found for project";
|
|
160
|
+
if (opts.json === true) {
|
|
161
|
+
process.stdout.write(`${displaySafeJson({ error: err, project: projectRoot }, 0)}
|
|
162
|
+
`);
|
|
163
|
+
} else {
|
|
164
|
+
process.stdout.write(`
|
|
165
|
+
# token-goat audit
|
|
166
|
+
Project: ${projectRoot}
|
|
167
|
+
No session transcript found. Pass --transcript <path> to specify one explicitly.
|
|
168
|
+
`);
|
|
169
|
+
}
|
|
170
|
+
process.exitCode = 1;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (detected.kind === "copilot") {
|
|
174
|
+
const report2 = buildCopilotWasteReport(detected.path);
|
|
175
|
+
const card2 = buildFeedbackCardFromCopilot(report2);
|
|
176
|
+
if (opts.json === true) {
|
|
177
|
+
process.stdout.write(`${displaySafeJson(card2, 0)}
|
|
178
|
+
`);
|
|
179
|
+
} else {
|
|
180
|
+
process.stdout.write(formatMaintainerCard(card2));
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const report = await buildWasteReport(detected.path);
|
|
185
|
+
const card = buildFeedbackCardFromClaude(report);
|
|
186
|
+
if (opts.json === true) {
|
|
187
|
+
process.stdout.write(`${displaySafeJson(card, 0)}
|
|
188
|
+
`);
|
|
189
|
+
} else {
|
|
190
|
+
process.stdout.write(formatMaintainerCard(card));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
buildFeedbackCardFromClaude,
|
|
195
|
+
buildFeedbackCardFromCopilot,
|
|
196
|
+
formatMaintainerCard,
|
|
197
|
+
runAuditCommand
|
|
198
|
+
};
|