@ramtinj95/opencode-tokenscope 1.5.1 → 1.6.0
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 +38 -12
- package/dist/tokenscope-lib/analyzer.d.ts +2 -0
- package/dist/tokenscope-lib/analyzer.d.ts.map +1 -1
- package/dist/tokenscope-lib/analyzer.js +68 -23
- package/dist/tokenscope-lib/analyzer.js.map +1 -1
- package/dist/tokenscope-lib/config.d.ts.map +1 -1
- package/dist/tokenscope-lib/config.js +21 -11
- package/dist/tokenscope-lib/config.js.map +1 -1
- package/dist/tokenscope-lib/context.d.ts +4 -5
- package/dist/tokenscope-lib/context.d.ts.map +1 -1
- package/dist/tokenscope-lib/context.js +47 -42
- package/dist/tokenscope-lib/context.js.map +1 -1
- package/dist/tokenscope-lib/cost.d.ts +4 -0
- package/dist/tokenscope-lib/cost.d.ts.map +1 -1
- package/dist/tokenscope-lib/cost.js +38 -8
- package/dist/tokenscope-lib/cost.js.map +1 -1
- package/dist/tokenscope-lib/formatter.d.ts +3 -0
- package/dist/tokenscope-lib/formatter.d.ts.map +1 -1
- package/dist/tokenscope-lib/formatter.js +91 -21
- package/dist/tokenscope-lib/formatter.js.map +1 -1
- package/dist/tokenscope-lib/opencode.d.ts +4 -0
- package/dist/tokenscope-lib/opencode.d.ts.map +1 -0
- package/dist/tokenscope-lib/opencode.js +25 -0
- package/dist/tokenscope-lib/opencode.js.map +1 -0
- package/dist/tokenscope-lib/skill.d.ts +43 -5
- package/dist/tokenscope-lib/skill.d.ts.map +1 -1
- package/dist/tokenscope-lib/skill.js +435 -50
- package/dist/tokenscope-lib/skill.js.map +1 -1
- package/dist/tokenscope-lib/subagent.d.ts +4 -4
- package/dist/tokenscope-lib/subagent.d.ts.map +1 -1
- package/dist/tokenscope-lib/subagent.js +29 -24
- package/dist/tokenscope-lib/subagent.js.map +1 -1
- package/dist/tokenscope-lib/tokenizer.d.ts +3 -0
- package/dist/tokenscope-lib/tokenizer.d.ts.map +1 -1
- package/dist/tokenscope-lib/tokenizer.js +8 -2
- package/dist/tokenscope-lib/tokenizer.js.map +1 -1
- package/dist/tokenscope-lib/types.d.ts +30 -2
- package/dist/tokenscope-lib/types.d.ts.map +1 -1
- package/dist/tokenscope-lib/types.js.map +1 -1
- package/dist/tokenscope-lib/warnings.d.ts +8 -0
- package/dist/tokenscope-lib/warnings.d.ts.map +1 -0
- package/dist/tokenscope-lib/warnings.js +31 -0
- package/dist/tokenscope-lib/warnings.js.map +1 -0
- package/dist/tokenscope.d.ts.map +1 -1
- package/dist/tokenscope.js +125 -57
- package/dist/tokenscope.js.map +1 -1
- package/models.json +30922 -232
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// ContextAnalyzer - analyzes context breakdown from opencode export
|
|
2
|
+
import { formatErrorMessage } from "./warnings";
|
|
2
3
|
export class ContextAnalyzer {
|
|
4
|
+
warnings;
|
|
3
5
|
tokenizerManager;
|
|
4
|
-
constructor(tokenizerManager) {
|
|
6
|
+
constructor(tokenizerManager, warnings) {
|
|
7
|
+
this.warnings = warnings;
|
|
5
8
|
this.tokenizerManager = tokenizerManager;
|
|
6
9
|
}
|
|
7
10
|
/**
|
|
@@ -24,7 +27,7 @@ export class ContextAnalyzer {
|
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
catch (error) {
|
|
27
|
-
|
|
30
|
+
this.warnings?.add(`Context analysis was skipped for session ${sessionID}: ${formatErrorMessage(error)}`, `context-analysis:${sessionID}`);
|
|
28
31
|
}
|
|
29
32
|
return result;
|
|
30
33
|
}
|
|
@@ -39,13 +42,13 @@ export class ContextAnalyzer {
|
|
|
39
42
|
const { stdout } = await $ `opencode export ${sessionID}`.quiet();
|
|
40
43
|
const result = stdout.toString();
|
|
41
44
|
if (!result.trim()) {
|
|
42
|
-
|
|
45
|
+
this.warnings?.add(`OpenCode export returned no data for session ${sessionID}. Context sections were skipped.`, `export-empty:${sessionID}`);
|
|
43
46
|
return null;
|
|
44
47
|
}
|
|
45
48
|
return JSON.parse(result);
|
|
46
49
|
}
|
|
47
50
|
catch (error) {
|
|
48
|
-
|
|
51
|
+
this.warnings?.add(`OpenCode export failed for session ${sessionID}. Context sections were skipped: ${formatErrorMessage(error)}`, `export-failed:${sessionID}`);
|
|
49
52
|
return null;
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -108,24 +111,21 @@ export class ContextAnalyzer {
|
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
// Check for project tree with <
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
// Check for project tree with modern <directories> tags
|
|
115
|
+
// (fallback to legacy <files> tags)
|
|
116
|
+
if (promptLower.includes("<directories>") || promptLower.includes("<files>")) {
|
|
117
|
+
const treeMatch = prompt.match(/<directories>[\s\S]*?<\/directories>/i) ?? prompt.match(/<files>[\s\S]*?<\/files>/i);
|
|
118
|
+
if (treeMatch) {
|
|
119
|
+
const filesTokens = await this.tokenizerManager.countTokens(treeMatch[0], tokenModel);
|
|
116
120
|
breakdown.projectTree.tokens += filesTokens;
|
|
117
121
|
breakdown.projectTree.identified = true;
|
|
118
|
-
|
|
119
|
-
const fileMatches = filesMatch[0].match(/\n\s+[\w\-\.]+\.[a-z]{1,5}/g);
|
|
120
|
-
if (fileMatches) {
|
|
121
|
-
breakdown.projectTree.fileCount += fileMatches.length;
|
|
122
|
-
}
|
|
122
|
+
breakdown.projectTree.fileCount += this.countProjectTreeEntries(treeMatch[0]);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
// Check for custom instructions
|
|
126
126
|
if (promptLower.includes("instructions from:") || promptLower.includes("agents.md")) {
|
|
127
127
|
// Try to extract just the instructions section
|
|
128
|
-
const instructionMatches = prompt.match(/Instructions from:[\s\S]*?(?=Instructions from:|<env>|<files>|$)/gi);
|
|
128
|
+
const instructionMatches = prompt.match(/Instructions from:[\s\S]*?(?=Instructions from:|<env>|<files>|<directories>|$)/gi);
|
|
129
129
|
if (instructionMatches) {
|
|
130
130
|
for (const match of instructionMatches) {
|
|
131
131
|
const instrTokens = await this.tokenizerManager.countTokens(match, tokenModel);
|
|
@@ -170,6 +170,7 @@ export class ContextAnalyzer {
|
|
|
170
170
|
(promptLower.includes("assistant") && promptLower.includes("software engineering"))) &&
|
|
171
171
|
!promptLower.includes("<env>") &&
|
|
172
172
|
!promptLower.includes("<files>") &&
|
|
173
|
+
!promptLower.includes("<directories>") &&
|
|
173
174
|
!promptLower.includes("<functions>")) {
|
|
174
175
|
breakdown.baseSystemPrompt.tokens += tokens;
|
|
175
176
|
breakdown.baseSystemPrompt.identified = true;
|
|
@@ -178,6 +179,7 @@ export class ContextAnalyzer {
|
|
|
178
179
|
else if (prompt.length > 500 &&
|
|
179
180
|
!promptLower.includes("<env>") &&
|
|
180
181
|
!promptLower.includes("<files>") &&
|
|
182
|
+
!promptLower.includes("<directories>") &&
|
|
181
183
|
!promptLower.includes("<functions>") &&
|
|
182
184
|
!promptLower.includes("instructions from:")) {
|
|
183
185
|
breakdown.baseSystemPrompt.tokens += tokens;
|
|
@@ -196,18 +198,35 @@ export class ContextAnalyzer {
|
|
|
196
198
|
*/
|
|
197
199
|
extractSystemPrompts(exported) {
|
|
198
200
|
const prompts = new Set();
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (
|
|
204
|
-
prompts.add(
|
|
201
|
+
const addPrompt = (value) => {
|
|
202
|
+
if (Array.isArray(value)) {
|
|
203
|
+
for (const prompt of value) {
|
|
204
|
+
const trimmed = (prompt ?? "").trim();
|
|
205
|
+
if (trimmed) {
|
|
206
|
+
prompts.add(trimmed);
|
|
205
207
|
}
|
|
206
208
|
}
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const trimmed = (value ?? "").trim();
|
|
212
|
+
if (trimmed) {
|
|
213
|
+
prompts.add(trimmed);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
for (const message of exported.messages) {
|
|
217
|
+
if (message.info.role === "user" || message.info.role === "assistant") {
|
|
218
|
+
addPrompt(message.info.system);
|
|
207
219
|
}
|
|
208
220
|
}
|
|
209
221
|
return Array.from(prompts);
|
|
210
222
|
}
|
|
223
|
+
countProjectTreeEntries(section) {
|
|
224
|
+
return section
|
|
225
|
+
.split(/\r?\n/)
|
|
226
|
+
.map((line) => line.trim())
|
|
227
|
+
.filter((line) => line.length > 0)
|
|
228
|
+
.filter((line) => !/^<\/?(files|directories)>$/i.test(line)).length;
|
|
229
|
+
}
|
|
211
230
|
/**
|
|
212
231
|
* Estimate context breakdown from cache token counts when system prompts aren't available.
|
|
213
232
|
*
|
|
@@ -255,23 +274,6 @@ export class ContextAnalyzer {
|
|
|
255
274
|
breakdown.totalCachedContext = totalCachedTokens;
|
|
256
275
|
return breakdown;
|
|
257
276
|
}
|
|
258
|
-
/**
|
|
259
|
-
* Check if content looks like a file tree
|
|
260
|
-
*/
|
|
261
|
-
looksLikeFileTree(content) {
|
|
262
|
-
const lines = content.split("\n");
|
|
263
|
-
let indentedLines = 0;
|
|
264
|
-
let filePatternLines = 0;
|
|
265
|
-
for (const line of lines) {
|
|
266
|
-
if (/^\s{2,}[\w\-\.]+/.test(line)) {
|
|
267
|
-
indentedLines++;
|
|
268
|
-
}
|
|
269
|
-
if (/\.(ts|js|md|json|py|go|rs|java|c|cpp|h|css|html|tsx|jsx)$/i.test(line)) {
|
|
270
|
-
filePatternLines++;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return indentedLines > 5 && filePatternLines > 3;
|
|
274
|
-
}
|
|
275
277
|
/**
|
|
276
278
|
* Estimate tool schema tokens from tool calls in the session
|
|
277
279
|
*/
|
|
@@ -422,12 +424,15 @@ export class ContextAnalyzer {
|
|
|
422
424
|
totalCacheWrite += Number(tokens.cache?.write) || 0;
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
|
-
const totalInputTokens = totalCacheRead + totalFreshInput;
|
|
426
|
-
|
|
427
|
-
|
|
427
|
+
const totalInputTokens = totalCacheRead + totalFreshInput + totalCacheWrite;
|
|
428
|
+
const cacheableInputTokens = totalCacheRead + totalFreshInput;
|
|
429
|
+
// Cache hit rate (read-hit ratio over cacheable input)
|
|
430
|
+
const cacheHitRate = cacheableInputTokens > 0 ? (totalCacheRead / cacheableInputTokens) * 100 : 0;
|
|
428
431
|
// Cost calculations
|
|
429
432
|
const costWithoutCaching = (totalInputTokens / 1_000_000) * pricing.input;
|
|
430
|
-
const costWithCaching = (totalFreshInput / 1_000_000) * pricing.input +
|
|
433
|
+
const costWithCaching = (totalFreshInput / 1_000_000) * pricing.input +
|
|
434
|
+
(totalCacheRead / 1_000_000) * pricing.cacheRead +
|
|
435
|
+
(totalCacheWrite / 1_000_000) * pricing.cacheWrite;
|
|
431
436
|
const costSavings = costWithoutCaching - costWithCaching;
|
|
432
437
|
const savingsPercent = costWithoutCaching > 0 ? (costSavings / costWithoutCaching) * 100 : 0;
|
|
433
438
|
// Effective rate (what you're actually paying per token)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../tokenscope-lib/context.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAiBpE,MAAM,OAAO,eAAe;IAClB,gBAAgB,CAAkB;IAE1C,YAAY,gBAAkC;QAC5C,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,SAAiB,EACjB,UAAsB,EACtB,OAAqB,EACrB,MAAwB;QAExB,MAAM,MAAM,GAA0B,EAAE,CAAA;QAExC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;YAChD,IAAI,CAAC,QAAQ;gBAAE,OAAO,MAAM,CAAA;YAE5B,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAClC,MAAM,CAAC,gB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ricingData: Record<string, ModelPricing>);
|
|
5
5
|
calculateCost(analysis: TokenAnalysis): CostEstimate;
|
|
6
|
+
buildLookupKey(providerID?: string, modelID?: string): string;
|
|
6
7
|
getPricing(modelName: string): ModelPricing;
|
|
8
|
+
hasPricing(modelName: string): boolean;
|
|
9
|
+
private findPricing;
|
|
10
|
+
private findLongestPrefixMatch;
|
|
7
11
|
private normalizeModelName;
|
|
8
12
|
}
|
|
9
13
|
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../tokenscope-lib/cost.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAExE,qBAAa,cAAc;IACb,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;IAE7D,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,YAAY;IAiCpD,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY;
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../tokenscope-lib/cost.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAExE,qBAAa,cAAc;IACb,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;IAE7D,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,YAAY;IAiCpD,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAc7D,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY;IAI3C,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAItC,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,kBAAkB;CAG3B"}
|
|
@@ -5,8 +5,8 @@ export class CostCalculator {
|
|
|
5
5
|
this.pricingData = pricingData;
|
|
6
6
|
}
|
|
7
7
|
calculateCost(analysis) {
|
|
8
|
-
const pricing = this.getPricing(analysis.model.name);
|
|
9
|
-
const hasActivity = analysis.
|
|
8
|
+
const pricing = this.getPricing(analysis.pricingModelName ?? analysis.model.name);
|
|
9
|
+
const hasActivity = analysis.apiCallCount > 0 && (analysis.inputTokens > 0 || analysis.outputTokens > 0);
|
|
10
10
|
const isSubscription = hasActivity && analysis.sessionCost === 0;
|
|
11
11
|
const estimatedInputCost = (analysis.inputTokens / 1_000_000) * pricing.input;
|
|
12
12
|
const estimatedOutputCost = ((analysis.outputTokens + analysis.reasoningTokens) / 1_000_000) * pricing.output;
|
|
@@ -33,19 +33,49 @@ export class CostCalculator {
|
|
|
33
33
|
cacheWriteTokens: analysis.cacheWriteTokens,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
buildLookupKey(providerID, modelID) {
|
|
37
|
+
const provider = providerID?.trim();
|
|
38
|
+
const model = modelID?.trim();
|
|
39
|
+
if (!provider)
|
|
40
|
+
return model ?? "";
|
|
41
|
+
if (!model)
|
|
42
|
+
return provider;
|
|
43
|
+
const normalizedProvider = provider.toLowerCase();
|
|
44
|
+
const normalizedModel = model.toLowerCase();
|
|
45
|
+
if (normalizedModel.startsWith(`${normalizedProvider}/`))
|
|
46
|
+
return model;
|
|
47
|
+
return `${provider}/${model}`;
|
|
48
|
+
}
|
|
36
49
|
getPricing(modelName) {
|
|
37
|
-
|
|
50
|
+
return this.findPricing(modelName) ?? this.pricingData["default"] ?? { input: 1, output: 3, cacheWrite: 0, cacheRead: 0 };
|
|
51
|
+
}
|
|
52
|
+
hasPricing(modelName) {
|
|
53
|
+
return this.findPricing(modelName) !== undefined;
|
|
54
|
+
}
|
|
55
|
+
findPricing(modelName) {
|
|
56
|
+
const rawName = modelName.trim().toLowerCase();
|
|
57
|
+
if (!rawName)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (this.pricingData[rawName])
|
|
60
|
+
return this.pricingData[rawName];
|
|
61
|
+
const normalizedName = this.normalizeModelName(rawName);
|
|
38
62
|
if (this.pricingData[normalizedName])
|
|
39
63
|
return this.pricingData[normalizedName];
|
|
40
|
-
|
|
64
|
+
return this.findLongestPrefixMatch(rawName) ?? this.findLongestPrefixMatch(normalizedName);
|
|
65
|
+
}
|
|
66
|
+
findLongestPrefixMatch(modelName) {
|
|
67
|
+
let bestMatchLength = -1;
|
|
68
|
+
let bestPricing;
|
|
41
69
|
for (const [key, pricing] of Object.entries(this.pricingData)) {
|
|
42
|
-
if (
|
|
43
|
-
|
|
70
|
+
if (modelName.startsWith(key.toLowerCase()) && key.length > bestMatchLength) {
|
|
71
|
+
bestMatchLength = key.length;
|
|
72
|
+
bestPricing = pricing;
|
|
73
|
+
}
|
|
44
74
|
}
|
|
45
|
-
return
|
|
75
|
+
return bestPricing;
|
|
46
76
|
}
|
|
47
77
|
normalizeModelName(modelName) {
|
|
48
|
-
return modelName.includes("/") ? modelName.split("/").pop() || modelName : modelName;
|
|
78
|
+
return modelName.includes("/") ? modelName.split("/").pop()?.trim().toLowerCase() || modelName : modelName.trim().toLowerCase();
|
|
49
79
|
}
|
|
50
80
|
}
|
|
51
81
|
//# sourceMappingURL=cost.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../../tokenscope-lib/cost.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAIxD,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,WAAyC;QAAzC,gBAAW,GAAX,WAAW,CAA8B;IAAG,CAAC;IAEjE,aAAa,CAAC,QAAuB;QACnC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../../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AC,WAAW,EAAE,CAAA;IACjI,CAAC;CACF"}
|
|
@@ -11,6 +11,8 @@ export declare class OutputFormatter {
|
|
|
11
11
|
private readonly TOOL_ESTIMATE_LABEL_WIDTH;
|
|
12
12
|
private readonly SKILL_NAME_WIDTH;
|
|
13
13
|
private readonly SKILL_DESC_WIDTH;
|
|
14
|
+
private readonly SUBAGENT_NAME_WIDTH;
|
|
15
|
+
private readonly SUBAGENT_DESC_WIDTH;
|
|
14
16
|
private config;
|
|
15
17
|
constructor(costCalculator: CostCalculator);
|
|
16
18
|
setConfig(config: TokenscopeConfig): void;
|
|
@@ -24,6 +26,7 @@ export declare class OutputFormatter {
|
|
|
24
26
|
private formatEfficiencyBar;
|
|
25
27
|
private formatAvailableSkills;
|
|
26
28
|
private formatLoadedSkills;
|
|
29
|
+
private formatAvailableSubagents;
|
|
27
30
|
private collectTopEntries;
|
|
28
31
|
private formatNumber;
|
|
29
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../tokenscope-lib/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAOb,gBAAgB,EAEjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAEvC,qBAAa,eAAe;
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../tokenscope-lib/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAOb,gBAAgB,EAEjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAEvC,qBAAa,eAAe;IAed,OAAO,CAAC,cAAc;IAdlC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAK;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAK;IACnC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAI;IACzC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAK;IACtC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAK;IACjD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAK;IACzC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAK;IAC/C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAK;IACtC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAK;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAK;IACzC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAK;IAEzC,OAAO,CAAC,MAAM,CAAgC;gBAE1B,cAAc,EAAE,cAAc;IAElD,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAIzC,OAAO,CAAC,iBAAiB;IA2BzB,MAAM,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM;IA4DvC,OAAO,CAAC,kBAAkB;IAmT1B,OAAO,CAAC,sBAAsB;IAwE9B,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,mBAAmB;IAgC3B,OAAO,CAAC,qBAAqB;IAoD7B,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,qBAAqB;IA8D7B,OAAO,CAAC,kBAAkB;IAwC1B,OAAO,CAAC,wBAAwB;IA+ChC,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -10,6 +10,8 @@ export class OutputFormatter {
|
|
|
10
10
|
TOOL_ESTIMATE_LABEL_WIDTH = 18;
|
|
11
11
|
SKILL_NAME_WIDTH = 22;
|
|
12
12
|
SKILL_DESC_WIDTH = 45;
|
|
13
|
+
SUBAGENT_NAME_WIDTH = 22;
|
|
14
|
+
SUBAGENT_DESC_WIDTH = 50;
|
|
13
15
|
config = null;
|
|
14
16
|
constructor(costCalculator) {
|
|
15
17
|
this.costCalculator = costCalculator;
|
|
@@ -46,6 +48,7 @@ export class OutputFormatter {
|
|
|
46
48
|
{ label: "REASONING", tokens: analysis.categories.reasoning.totalTokens },
|
|
47
49
|
];
|
|
48
50
|
const topEntries = this.collectTopEntries(analysis, 5);
|
|
51
|
+
const hasInferredSystemEstimate = analysis.categories.system.entries.some((entry) => entry.label.toLowerCase().includes("inferred"));
|
|
49
52
|
const toolStats = new Map();
|
|
50
53
|
for (const [toolName, calls] of analysis.toolCallCounts.entries()) {
|
|
51
54
|
toolStats.set(toolName, { tokens: 0, calls });
|
|
@@ -58,9 +61,9 @@ export class OutputFormatter {
|
|
|
58
61
|
.map(([label, stats]) => ({ label, tokens: stats.tokens, calls: stats.calls }))
|
|
59
62
|
.sort((a, b) => b.tokens - a.tokens);
|
|
60
63
|
const costEstimate = this.costCalculator.calculateCost(analysis);
|
|
61
|
-
return this.formatVisualOutput(analysis.sessionID, analysis.model.name, analysis.totalTokens, analysis.inputTokens, analysis.outputTokens, analysis.reasoningTokens, analysis.cacheReadTokens, analysis.cacheWriteTokens, analysis.assistantMessageCount, analysis.mostRecentInput, analysis.mostRecentOutput, analysis.mostRecentReasoning, analysis.mostRecentCacheRead, analysis.mostRecentCacheWrite, inputCategories, outputCategories, topEntries, toolEntries, costEstimate, analysis.subagentAnalysis, analysis.contextBreakdown, analysis.toolEstimates, analysis.cacheEfficiency, analysis.skillAnalysis);
|
|
64
|
+
return this.formatVisualOutput(analysis.sessionID, analysis.model.name, analysis.warnings, analysis.totalTokens, analysis.inputTokens, analysis.outputTokens, analysis.reasoningTokens, analysis.cacheReadTokens, analysis.cacheWriteTokens, analysis.assistantMessageCount, analysis.apiCallCount, analysis.mostRecentInput, analysis.mostRecentOutput, analysis.mostRecentReasoning, analysis.mostRecentCacheRead, analysis.mostRecentCacheWrite, inputCategories, outputCategories, topEntries, toolEntries, hasInferredSystemEstimate, costEstimate, analysis.subagentAnalysis, analysis.contextBreakdown, analysis.toolEstimates, analysis.cacheEfficiency, analysis.skillAnalysis);
|
|
62
65
|
}
|
|
63
|
-
formatVisualOutput(sessionID, modelName, totalTokens, inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWriteTokens, assistantMessageCount, mostRecentInput, mostRecentOutput, mostRecentReasoning, mostRecentCacheRead, mostRecentCacheWrite, inputCategories, outputCategories, topEntries, toolEntries, cost, subagentAnalysis, contextBreakdown, toolEstimates, cacheEfficiency, skillAnalysis) {
|
|
66
|
+
formatVisualOutput(sessionID, modelName, warnings, totalTokens, inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWriteTokens, assistantMessageCount, apiCallCount, mostRecentInput, mostRecentOutput, mostRecentReasoning, mostRecentCacheRead, mostRecentCacheWrite, inputCategories, outputCategories, topEntries, toolEntries, hasInferredSystemEstimate, cost, subagentAnalysis, contextBreakdown, toolEstimates, cacheEfficiency, skillAnalysis) {
|
|
64
67
|
const lines = [];
|
|
65
68
|
const sessionTotal = inputTokens + cacheReadTokens + cacheWriteTokens + outputTokens + reasoningTokens;
|
|
66
69
|
const mainCost = cost.isSubscription ? cost.estimatedSessionCost : cost.apiSessionCost;
|
|
@@ -70,6 +73,14 @@ export class OutputFormatter {
|
|
|
70
73
|
lines.push(`Model: ${modelName}`);
|
|
71
74
|
lines.push(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
72
75
|
lines.push(``);
|
|
76
|
+
if (warnings.length > 0) {
|
|
77
|
+
lines.push(`WARNINGS`);
|
|
78
|
+
lines.push(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
79
|
+
for (const warning of warnings) {
|
|
80
|
+
lines.push(`- ${warning}`);
|
|
81
|
+
}
|
|
82
|
+
lines.push(``);
|
|
83
|
+
}
|
|
73
84
|
// 1. TOKEN BREAKDOWN BY CATEGORY
|
|
74
85
|
lines.push(`TOKEN BREAKDOWN BY CATEGORY`);
|
|
75
86
|
lines.push(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
@@ -84,6 +95,9 @@ export class OutputFormatter {
|
|
|
84
95
|
}
|
|
85
96
|
lines.push(``);
|
|
86
97
|
lines.push(` Subtotal: ${this.formatNumber(inputTotal)} estimated input tokens`);
|
|
98
|
+
if (hasInferredSystemEstimate) {
|
|
99
|
+
lines.push(` Note: inferred system/overhead values are heuristic estimates from API telemetry.`);
|
|
100
|
+
}
|
|
87
101
|
lines.push(``);
|
|
88
102
|
const outputTotal = outputCategories.reduce((sum, cat) => sum + cat.tokens, 0);
|
|
89
103
|
lines.push(`Output Categories:`);
|
|
@@ -143,9 +157,13 @@ export class OutputFormatter {
|
|
|
143
157
|
// 5. SESSION TOTALS
|
|
144
158
|
lines.push(``);
|
|
145
159
|
lines.push(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
146
|
-
lines.push(`SESSION TOTALS (All ${
|
|
160
|
+
lines.push(`SESSION TOTALS (All ${apiCallCount} API calls)`);
|
|
147
161
|
lines.push(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
148
162
|
lines.push(``);
|
|
163
|
+
if (assistantMessageCount !== apiCallCount) {
|
|
164
|
+
lines.push(`Assistant messages observed: ${assistantMessageCount} (structural count)`);
|
|
165
|
+
lines.push(``);
|
|
166
|
+
}
|
|
149
167
|
lines.push(`Total tokens processed across the entire session (for cost calculation):`);
|
|
150
168
|
lines.push(``);
|
|
151
169
|
lines.push(` Input tokens: ${this.formatNumber(inputTokens).padStart(10)} (fresh tokens across all calls)`);
|
|
@@ -218,6 +236,9 @@ export class OutputFormatter {
|
|
|
218
236
|
if (skillAnalysis.availableSkills.length > 0) {
|
|
219
237
|
lines.push(...this.formatAvailableSkills(skillAnalysis));
|
|
220
238
|
}
|
|
239
|
+
if (skillAnalysis.availableSubagents.length > 0) {
|
|
240
|
+
lines.push(...this.formatAvailableSubagents(skillAnalysis));
|
|
241
|
+
}
|
|
221
242
|
if (skillAnalysis.loadedSkills.length > 0) {
|
|
222
243
|
lines.push(...this.formatLoadedSkills(skillAnalysis));
|
|
223
244
|
}
|
|
@@ -246,7 +267,7 @@ export class OutputFormatter {
|
|
|
246
267
|
const costStr = cost.isSubscription
|
|
247
268
|
? `$${subagent.estimatedCost.toFixed(4)}`
|
|
248
269
|
: `$${subagent.apiCost.toFixed(4)}`;
|
|
249
|
-
const tokensStr = `(${this.formatNumber(subagent.totalTokens)} tokens, ${subagent.
|
|
270
|
+
const tokensStr = `(${this.formatNumber(subagent.totalTokens)} tokens, ${subagent.apiCallCount} calls)`;
|
|
250
271
|
lines.push(` ${label} ${costStr.padStart(10)} ${tokensStr}`);
|
|
251
272
|
}
|
|
252
273
|
lines.push(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
@@ -265,14 +286,14 @@ export class OutputFormatter {
|
|
|
265
286
|
: subagentAnalysis.totalApiCost;
|
|
266
287
|
const grandTotalCost = mainCost + subagentTotalCost;
|
|
267
288
|
const grandTotalTokens = sessionTotal + subagentAnalysis.totalTokens;
|
|
268
|
-
const grandTotalApiCalls =
|
|
269
|
-
lines.push(` Main session: $${mainCost.toFixed(4).padStart(10)} ${this.formatNumber(sessionTotal).padStart(10)} ${
|
|
289
|
+
const grandTotalApiCalls = apiCallCount + subagentAnalysis.totalApiCalls;
|
|
290
|
+
lines.push(` Main session: $${mainCost.toFixed(4).padStart(10)} ${this.formatNumber(sessionTotal).padStart(10)} ${apiCallCount.toString().padStart(5)}`);
|
|
270
291
|
lines.push(` Subagents: $${subagentTotalCost.toFixed(4).padStart(10)} ${this.formatNumber(subagentAnalysis.totalTokens).padStart(10)} ${subagentAnalysis.totalApiCalls.toString().padStart(5)}`);
|
|
271
292
|
lines.push(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
272
293
|
lines.push(` TOTAL: $${grandTotalCost.toFixed(4).padStart(10)} ${this.formatNumber(grandTotalTokens).padStart(10)} ${grandTotalApiCalls.toString().padStart(5)}`);
|
|
273
294
|
}
|
|
274
295
|
else {
|
|
275
|
-
lines.push(` Session: $${mainCost.toFixed(4).padStart(10)} ${this.formatNumber(sessionTotal).padStart(10)} ${
|
|
296
|
+
lines.push(` Session: $${mainCost.toFixed(4).padStart(10)} ${this.formatNumber(sessionTotal).padStart(10)} ${apiCallCount.toString().padStart(5)}`);
|
|
276
297
|
}
|
|
277
298
|
lines.push(``);
|
|
278
299
|
lines.push(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
@@ -390,13 +411,18 @@ export class OutputFormatter {
|
|
|
390
411
|
const freshPct = total > 0 ? ((efficiency.freshInputTokens / total) * 100).toFixed(1) : "0.0";
|
|
391
412
|
const freshBar = this.formatEfficiencyBar(efficiency.freshInputTokens, total);
|
|
392
413
|
lines.push(` Fresh Input: ${this.formatNumber(efficiency.freshInputTokens).padStart(10)} tokens ${freshBar} ${freshPct}%`);
|
|
414
|
+
if (efficiency.cacheWriteTokens > 0) {
|
|
415
|
+
const cacheWritePct = total > 0 ? ((efficiency.cacheWriteTokens / total) * 100).toFixed(1) : "0.0";
|
|
416
|
+
const cacheWriteBar = this.formatEfficiencyBar(efficiency.cacheWriteTokens, total);
|
|
417
|
+
lines.push(` Cache Write: ${this.formatNumber(efficiency.cacheWriteTokens).padStart(10)} tokens ${cacheWriteBar} ${cacheWritePct}%`);
|
|
418
|
+
}
|
|
393
419
|
lines.push(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
394
|
-
lines.push(` Cache Hit Rate: ${efficiency.cacheHitRate.toFixed(1)}
|
|
420
|
+
lines.push(` Cache Hit Rate: ${efficiency.cacheHitRate.toFixed(1)}% (cache read / (cache read + fresh input))`);
|
|
395
421
|
lines.push(``);
|
|
396
422
|
// Cost analysis
|
|
397
|
-
lines.push(` Cost Analysis (${modelName} @ $${cost.pricePerMillionInput.toFixed(2)}/M input, $${cost.pricePerMillionCacheRead.toFixed(2)}/M cache read):`);
|
|
423
|
+
lines.push(` Cost Analysis (${modelName} @ $${cost.pricePerMillionInput.toFixed(2)}/M input, $${cost.pricePerMillionCacheRead.toFixed(2)}/M cache read, $${cost.pricePerMillionCacheWrite.toFixed(2)}/M cache write):`);
|
|
398
424
|
lines.push(` Without caching: $${efficiency.costWithoutCaching.toFixed(4)} (${this.formatNumber(total)} tokens x $${cost.pricePerMillionInput.toFixed(2)}/M)`);
|
|
399
|
-
lines.push(` With caching: $${efficiency.costWithCaching.toFixed(4)} (fresh x $${cost.pricePerMillionInput.toFixed(2)}/M +
|
|
425
|
+
lines.push(` With caching: $${efficiency.costWithCaching.toFixed(4)} (fresh x $${cost.pricePerMillionInput.toFixed(2)}/M + cache read x $${cost.pricePerMillionCacheRead.toFixed(2)}/M + cache write x $${cost.pricePerMillionCacheWrite.toFixed(2)}/M)`);
|
|
400
426
|
lines.push(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
401
427
|
lines.push(` Cost Savings: $${efficiency.costSavings.toFixed(4)} (${efficiency.savingsPercent.toFixed(1)}% reduction)`);
|
|
402
428
|
lines.push(` Effective Rate: $${efficiency.effectiveRate.toFixed(2)}/M tokens (vs. $${efficiency.standardRate.toFixed(2)}/M standard)`);
|
|
@@ -410,34 +436,47 @@ export class OutputFormatter {
|
|
|
410
436
|
formatAvailableSkills(analysis) {
|
|
411
437
|
const lines = [];
|
|
412
438
|
const total = analysis.totalAvailableTokens;
|
|
439
|
+
const hasSystemPromptCatalog = analysis.availableSkillsContextTokens > 0;
|
|
413
440
|
lines.push(``);
|
|
414
|
-
lines.push(
|
|
415
|
-
lines.push(`AVAILABLE SKILLS (
|
|
416
|
-
lines.push(
|
|
441
|
+
lines.push(`══════════════════════════════════════════════════════════════════════════`);
|
|
442
|
+
lines.push(`AVAILABLE SKILLS (always-available context)`);
|
|
443
|
+
lines.push(`─────────────────────────────────────────────────────────────────────────`);
|
|
417
444
|
lines.push(``);
|
|
418
|
-
|
|
445
|
+
if (hasSystemPromptCatalog) {
|
|
446
|
+
lines.push(`OpenCode currently includes a verbose skill catalog in the system prompt on every API call.`);
|
|
447
|
+
lines.push(`The rows below estimate the per-skill XML entries inside that shared catalog.`);
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
lines.push(`These skills were recovered from the skill tool metadata available to this session.`);
|
|
451
|
+
}
|
|
419
452
|
lines.push(``);
|
|
420
|
-
// Header
|
|
421
453
|
const nameHeader = "Skill".padEnd(this.SKILL_NAME_WIDTH);
|
|
422
454
|
const descHeader = "Description".padEnd(this.SKILL_DESC_WIDTH);
|
|
423
455
|
lines.push(` ${nameHeader} ${descHeader} Tokens`);
|
|
424
|
-
lines.push(`
|
|
425
|
-
// Sort by tokens descending
|
|
456
|
+
lines.push(` ───────────────────────────────────────────────────────────────────────`);
|
|
426
457
|
const sortedSkills = [...analysis.availableSkills].sort((a, b) => b.tokens - a.tokens);
|
|
427
458
|
for (const skill of sortedSkills) {
|
|
428
459
|
const name = skill.name.length > this.SKILL_NAME_WIDTH
|
|
429
|
-
? skill.name.substring(0, this.SKILL_NAME_WIDTH - 1) + "
|
|
460
|
+
? skill.name.substring(0, this.SKILL_NAME_WIDTH - 1) + "…"
|
|
430
461
|
: skill.name.padEnd(this.SKILL_NAME_WIDTH);
|
|
431
462
|
const desc = skill.description.length > this.SKILL_DESC_WIDTH
|
|
432
|
-
? skill.description.substring(0, this.SKILL_DESC_WIDTH - 1) + "
|
|
463
|
+
? skill.description.substring(0, this.SKILL_DESC_WIDTH - 1) + "…"
|
|
433
464
|
: skill.description.padEnd(this.SKILL_DESC_WIDTH);
|
|
434
465
|
const tokens = `~${this.formatNumber(skill.tokens)}`.padStart(7);
|
|
435
466
|
lines.push(` ${name} ${desc} ${tokens}`);
|
|
436
467
|
}
|
|
437
|
-
lines.push(`
|
|
468
|
+
lines.push(` ───────────────────────────────────────────────────────────────────────`);
|
|
438
469
|
lines.push(` Total: ~${this.formatNumber(total)} tokens (${analysis.availableSkills.length} skills available)`);
|
|
439
470
|
lines.push(``);
|
|
440
|
-
|
|
471
|
+
if (hasSystemPromptCatalog) {
|
|
472
|
+
lines.push(` Note: Full system-prompt skill catalog is ~${this.formatNumber(analysis.availableSkillsContextTokens)} tokens (includes shared wrapper/preamble).`);
|
|
473
|
+
if (analysis.skillToolDescriptionTokens > 0) {
|
|
474
|
+
lines.push(` Compact skill tool description adds ~${this.formatNumber(analysis.skillToolDescriptionTokens)} tokens more.`);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
else if (analysis.skillToolDescriptionTokens > 0) {
|
|
478
|
+
lines.push(` Note: Full skill tool description is ~${this.formatNumber(analysis.skillToolDescriptionTokens)} tokens (includes boilerplate).`);
|
|
479
|
+
}
|
|
441
480
|
return lines;
|
|
442
481
|
}
|
|
443
482
|
formatLoadedSkills(analysis) {
|
|
@@ -469,6 +508,37 @@ export class OutputFormatter {
|
|
|
469
508
|
lines.push(` Note: Loaded skill content stays in context (protected from pruning).`);
|
|
470
509
|
return lines;
|
|
471
510
|
}
|
|
511
|
+
formatAvailableSubagents(analysis) {
|
|
512
|
+
const lines = [];
|
|
513
|
+
const total = analysis.totalAvailableSubagentTokens;
|
|
514
|
+
lines.push(``);
|
|
515
|
+
lines.push(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
516
|
+
lines.push(`AVAILABLE SUBAGENTS (in task tool definition)`);
|
|
517
|
+
lines.push(`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
518
|
+
lines.push(``);
|
|
519
|
+
lines.push(`These subagents are embedded in the task tool description and consume tokens on every API call.`);
|
|
520
|
+
lines.push(``);
|
|
521
|
+
const nameHeader = "Subagent".padEnd(this.SUBAGENT_NAME_WIDTH);
|
|
522
|
+
const descHeader = "Description".padEnd(this.SUBAGENT_DESC_WIDTH);
|
|
523
|
+
lines.push(` ${nameHeader} ${descHeader} Tokens`);
|
|
524
|
+
lines.push(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
525
|
+
const sortedSubagents = [...analysis.availableSubagents].sort((a, b) => b.tokens - a.tokens);
|
|
526
|
+
for (const subagent of sortedSubagents) {
|
|
527
|
+
const name = subagent.name.length > this.SUBAGENT_NAME_WIDTH
|
|
528
|
+
? subagent.name.substring(0, this.SUBAGENT_NAME_WIDTH - 1) + "\u2026"
|
|
529
|
+
: subagent.name.padEnd(this.SUBAGENT_NAME_WIDTH);
|
|
530
|
+
const desc = subagent.description.length > this.SUBAGENT_DESC_WIDTH
|
|
531
|
+
? subagent.description.substring(0, this.SUBAGENT_DESC_WIDTH - 1) + "\u2026"
|
|
532
|
+
: subagent.description.padEnd(this.SUBAGENT_DESC_WIDTH);
|
|
533
|
+
const tokens = `~${this.formatNumber(subagent.tokens)}`.padStart(7);
|
|
534
|
+
lines.push(` ${name} ${desc} ${tokens}`);
|
|
535
|
+
}
|
|
536
|
+
lines.push(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
537
|
+
lines.push(` Total: ~${this.formatNumber(total)} tokens (${analysis.availableSubagents.length} subagents available)`);
|
|
538
|
+
lines.push(``);
|
|
539
|
+
lines.push(` Note: Full task tool description is ~${this.formatNumber(analysis.taskToolDescriptionTokens)} tokens (includes instructions/examples).`);
|
|
540
|
+
return lines;
|
|
541
|
+
}
|
|
472
542
|
collectTopEntries(analysis, limit) {
|
|
473
543
|
const pool = [
|
|
474
544
|
...analysis.categories.system.allEntries,
|