codebuddy-stats 1.3.4 → 1.3.6
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/dist/index.js +1 -1
- package/dist/lib/data-loader.js +11 -1
- package/dist/lib/pricing.js +21 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -197,7 +197,7 @@ async function main() {
|
|
|
197
197
|
const width = Number(screen.width) || 80;
|
|
198
198
|
const note = state.currentSource === 'code'
|
|
199
199
|
? `针对 CodeBuddy Code < 2.20.0 版本产生的数据,由于没有请求级别的 model ID,用量是基于当前 CodeBuddy Code 设置的 model ID(${state.data.defaultModelId})计算价格的`
|
|
200
|
-
: 'IDE 的 usage
|
|
200
|
+
: 'IDE 的 usage 不包含缓存 token 明细,成本默认按 60% 缓存命中率估算';
|
|
201
201
|
const screenHeight = Number(screen.height) || 24;
|
|
202
202
|
const contentBoxHeight = Math.max(1, screenHeight - 5); // 对应 contentBox: height = '100%-5'
|
|
203
203
|
const paddingTop = Number(contentBox.padding?.top ?? 0);
|
package/dist/lib/data-loader.js
CHANGED
|
@@ -682,10 +682,16 @@ async function loadIdeUsageData(options = {}) {
|
|
|
682
682
|
continue;
|
|
683
683
|
const inferredModelId = await inferIdeModelIdForRequest(conversationDir, req, messageModelCache);
|
|
684
684
|
const usedModelId = inferredModelId || defaultModelId;
|
|
685
|
+
// IDE 的 usage 不包含缓存 token 明细,按默认 60% 缓存命中率估算
|
|
686
|
+
const safeInput = Math.max(0, inputTokens);
|
|
687
|
+
const estimatedCacheHit = Math.round(safeInput * 0.6);
|
|
688
|
+
const estimatedCacheMiss = safeInput - estimatedCacheHit;
|
|
685
689
|
const rawUsage = {
|
|
686
|
-
prompt_tokens:
|
|
690
|
+
prompt_tokens: safeInput,
|
|
687
691
|
completion_tokens: Math.max(0, outputTokens),
|
|
688
692
|
total_tokens: Math.max(0, totalTokens),
|
|
693
|
+
prompt_cache_hit_tokens: estimatedCacheHit,
|
|
694
|
+
prompt_cache_miss_tokens: estimatedCacheMiss,
|
|
689
695
|
};
|
|
690
696
|
const { cost, stats } = computeUsageCost(rawUsage, usedModelId);
|
|
691
697
|
const projectName = workspaceHash;
|
|
@@ -694,6 +700,8 @@ async function loadIdeUsageData(options = {}) {
|
|
|
694
700
|
dayStats.promptTokens += stats.promptTokens;
|
|
695
701
|
dayStats.completionTokens += stats.completionTokens;
|
|
696
702
|
dayStats.totalTokens += stats.totalTokens;
|
|
703
|
+
dayStats.cacheHitTokens += stats.cacheHitTokens;
|
|
704
|
+
dayStats.cacheMissTokens += stats.cacheMissTokens;
|
|
697
705
|
dayStats.requests += 1;
|
|
698
706
|
modelTotals[usedModelId] ??= { cost: 0, tokens: 0, requests: 0 };
|
|
699
707
|
modelTotals[usedModelId].cost += cost;
|
|
@@ -706,6 +714,8 @@ async function loadIdeUsageData(options = {}) {
|
|
|
706
714
|
grandTotal.cost += cost;
|
|
707
715
|
grandTotal.tokens += stats.totalTokens;
|
|
708
716
|
grandTotal.requests += 1;
|
|
717
|
+
grandTotal.cacheHitTokens += stats.cacheHitTokens;
|
|
718
|
+
grandTotal.cacheMissTokens += stats.cacheMissTokens;
|
|
709
719
|
}
|
|
710
720
|
}
|
|
711
721
|
}
|
package/dist/lib/pricing.js
CHANGED
|
@@ -31,6 +31,24 @@ export const MODEL_PRICING = {
|
|
|
31
31
|
"gpt-5.1-codex-mini": createPricing(0.25, 0.025, 2.0),
|
|
32
32
|
"gpt-5-codex": createPricing(1.25, 0.125, 10.0),
|
|
33
33
|
// Claude 系列
|
|
34
|
+
"claude-sonnet-4.6": {
|
|
35
|
+
prompt: [
|
|
36
|
+
{ limit: 200_000, pricePerMTok: 3.0 },
|
|
37
|
+
{ limit: Number.POSITIVE_INFINITY, pricePerMTok: 6.0 },
|
|
38
|
+
],
|
|
39
|
+
completion: [
|
|
40
|
+
{ limit: 200_000, pricePerMTok: 15.0 },
|
|
41
|
+
{ limit: Number.POSITIVE_INFINITY, pricePerMTok: 22.5 },
|
|
42
|
+
],
|
|
43
|
+
cacheRead: [
|
|
44
|
+
{ limit: 200_000, pricePerMTok: 0.3 },
|
|
45
|
+
{ limit: Number.POSITIVE_INFINITY, pricePerMTok: 0.6 },
|
|
46
|
+
],
|
|
47
|
+
cacheWrite: [
|
|
48
|
+
{ limit: 200_000, pricePerMTok: 6.0 },
|
|
49
|
+
{ limit: Number.POSITIVE_INFINITY, pricePerMTok: 12.0 },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
34
52
|
"claude-opus-4.6": {
|
|
35
53
|
prompt: [
|
|
36
54
|
{ limit: 200_000, pricePerMTok: 5.0 },
|
|
@@ -107,6 +125,8 @@ export const MODEL_PRICING = {
|
|
|
107
125
|
{ limit: Number.POSITIVE_INFINITY, pricePerMTok: 0.25 },
|
|
108
126
|
],
|
|
109
127
|
},
|
|
128
|
+
// MiniMax
|
|
129
|
+
"minimax-m2.5": createPricing(0.3, 0.03, 1.2),
|
|
110
130
|
// GLM 系列 (价格从人民币转换: 1 USD = 7 CNY)
|
|
111
131
|
// 按上下文长度分段定价:[0,32K), [32K,200K)
|
|
112
132
|
"glm-5.0": {
|
|
@@ -186,6 +206,7 @@ export const MODEL_PRICING = {
|
|
|
186
206
|
"kimi-k2.5": createPricing(0.58, 0.1, 3),
|
|
187
207
|
"kimi-k2-thinking": createPricing(0.6, 0.15, 2.5),
|
|
188
208
|
// iOA 免费模型
|
|
209
|
+
"minimax-m2.5-ioa": createPricing(0, 0, 0),
|
|
189
210
|
"kimi-k2.5-ioa": createPricing(0, 0, 0),
|
|
190
211
|
"glm-5.0-ioa": createPricing(0, 0, 0),
|
|
191
212
|
"glm-4.7-ioa": createPricing(0, 0, 0),
|