token-usage-sync 1.0.0 → 1.2.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/index.js CHANGED
@@ -126,12 +126,13 @@ function calculateUsageForPeriod(entries, hoursAgo) {
126
126
  cacheReadTokens += usage.cache_read_input_tokens || 0;
127
127
  }
128
128
 
129
- // 重み付けトークン計算(Claude API料金ベース)
129
+ // 重み付けトークン計算(Claude Code実測ベース)
130
+ // Cache Read は無料(0x)、Cache Create は 1.0x
130
131
  const weightedTokens = Math.round(
131
132
  inputTokens * 1.0 +
132
133
  outputTokens * 1.0 +
133
- cacheCreationTokens * 1.25 +
134
- cacheReadTokens * 0.1
134
+ cacheCreationTokens * 1.0 +
135
+ cacheReadTokens * 0
135
136
  );
136
137
 
137
138
  return {
@@ -308,9 +309,9 @@ async function main() {
308
309
  console.log('\n📊 Claude Code Usage Summary\n');
309
310
 
310
311
  // 制限値
311
- // 5時間: 重み付けトークン(cache_read=0.1x)
312
+ // 5時間: 重み付けトークン(cache_read=0x, cache_create=1x)
312
313
  // 週間: 生トークン
313
- const LIMIT_5H_WEIGHTED = 4_000_000; // 5時間制限: 4M weighted tokens
314
+ const LIMIT_5H_WEIGHTED = 4_100_000; // 5時間制限: 4.1M weighted tokens
314
315
  const LIMIT_WEEK_RAW = 195_000_000; // 週間制限: 195M raw tokens
315
316
 
316
317
  const pct5h = Math.round((usage.limits.last5Hours.weightedTokens / LIMIT_5H_WEIGHTED) * 100);
@@ -324,8 +325,8 @@ async function main() {
324
325
  console.log('\n=== Last 5 Hours Breakdown ===');
325
326
  console.log(` Input: ${usage.limits.last5Hours.inputTokens.toLocaleString()} × 1.0`);
326
327
  console.log(` Output: ${usage.limits.last5Hours.outputTokens.toLocaleString()} × 1.0`);
327
- console.log(` Cache Create: ${usage.limits.last5Hours.cacheCreationTokens.toLocaleString()} × 1.25`);
328
- console.log(` Cache Read: ${usage.limits.last5Hours.cacheReadTokens.toLocaleString()} × 0.1`);
328
+ console.log(` Cache Create: ${usage.limits.last5Hours.cacheCreationTokens.toLocaleString()} × 1.0`);
329
+ console.log(` Cache Read: ${usage.limits.last5Hours.cacheReadTokens.toLocaleString()} × 0 (free)`);
329
330
 
330
331
  console.log('\n=== All Time Total ===');
331
332
  console.log(`Total Tokens: ${usage.summary.totalTokens.toLocaleString()}`);
@@ -23,12 +23,13 @@ export function calculateUsageForPeriod(entries, hoursAgo, now = new Date()) {
23
23
  cacheReadTokens += usage.cache_read_input_tokens || 0;
24
24
  }
25
25
 
26
- // 重み付けトークン計算(Claude API料金ベース)
26
+ // 重み付けトークン計算(Claude Code実測ベース)
27
+ // Cache Read は無料(0x)、Cache Create は 1.0x
27
28
  const weightedTokens = Math.round(
28
29
  inputTokens * 1.0 +
29
30
  outputTokens * 1.0 +
30
- cacheCreationTokens * 1.25 +
31
- cacheReadTokens * 0.1
31
+ cacheCreationTokens * 1.0 +
32
+ cacheReadTokens * 0
32
33
  );
33
34
 
34
35
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-usage-sync",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Sync Claude Code token usage to your self-hosted dashboard",
5
5
  "type": "module",
6
6
  "bin": {