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.
- package/bin/mr-claude-stats.js +8 -21
- package/package.json +1 -1
package/bin/mr-claude-stats.js
CHANGED
|
@@ -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.
|
|
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
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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 =
|
|
148
|
+
const usage = getUsageFromInput(input);
|
|
162
149
|
|
|
163
150
|
if (usage) {
|
|
164
151
|
const inputTokens = usage.input_tokens || 0;
|