mr-claude-stats 1.3.0 → 1.4.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.
@@ -6,7 +6,7 @@ const fs = require('fs');
6
6
  const path = require('path');
7
7
  const readline = require('readline');
8
8
 
9
- const VERSION = '1.3.0';
9
+ const VERSION = '1.4.0';
10
10
  const BAR_SIZE = 45;
11
11
 
12
12
  // Handle --help and --version
@@ -103,23 +103,11 @@ function writeCache(sessionId, value) {
103
103
  } catch (e) {}
104
104
  }
105
105
 
106
- function findLastUsage(transcriptPath) {
107
- if (!transcriptPath || !fs.existsSync(transcriptPath)) return null;
108
-
109
- try {
110
- const content = fs.readFileSync(transcriptPath, 'utf8');
111
- const lines = content.trim().split('\n').reverse();
112
-
113
- for (const line of lines) {
114
- try {
115
- const entry = JSON.parse(line);
116
- const usage = entry.usage || (entry.message && entry.message.usage);
117
- if (usage && usage.input_tokens !== undefined) {
118
- return usage;
119
- }
120
- } catch (e) {}
121
- }
122
- } catch (e) {}
106
+ function getUsageFromInput(input) {
107
+ const currentUsage = input.context_window?.current_usage;
108
+ if (currentUsage && currentUsage.input_tokens !== undefined) {
109
+ return currentUsage;
110
+ }
123
111
  return null;
124
112
  }
125
113
 
@@ -148,7 +136,6 @@ async function main() {
148
136
 
149
137
  const model = input.model?.display_name || 'Claude';
150
138
  const contextSize = input.context_window?.context_window_size || 200000;
151
- const transcriptPath = input.transcript_path || '';
152
139
  const sessionId = input.session_id || 'default';
153
140
  const cwd = input.cwd || process.cwd();
154
141
 
@@ -156,9 +143,9 @@ async function main() {
156
143
  const lastDir = truncatePath(path.basename(cwd));
157
144
  const modelWithPath = `${model} in /${lastDir}`;
158
145
 
159
- // Calculate total tokens
146
+ // Calculate total tokens from context_window.current_usage
160
147
  let total = 0;
161
- const usage = findLastUsage(transcriptPath);
148
+ const usage = getUsageFromInput(input);
162
149
 
163
150
  if (usage) {
164
151
  const inputTokens = usage.input_tokens || 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mr-claude-stats",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Accurate statusline for Claude Code CLI with colorful progress bar",
5
5
  "bin": {
6
6
  "mr-claude-stats": "./bin/mr-claude-stats.js"