cctotals 1.0.2 → 1.0.3
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/package.json +1 -1
- package/token-graph.js +38 -45
package/package.json
CHANGED
package/token-graph.js
CHANGED
|
@@ -15,7 +15,6 @@ const stats = JSON.parse(fs.readFileSync(statsPath, 'utf8'));
|
|
|
15
15
|
// Group daily tokens into weeks
|
|
16
16
|
function getWeekKey(dateStr) {
|
|
17
17
|
const date = new Date(dateStr);
|
|
18
|
-
// Get ISO week start (Monday)
|
|
19
18
|
const day = date.getDay();
|
|
20
19
|
const diff = date.getDate() - day + (day === 0 ? -6 : 1);
|
|
21
20
|
const weekStart = new Date(date.setDate(diff));
|
|
@@ -24,7 +23,6 @@ function getWeekKey(dateStr) {
|
|
|
24
23
|
|
|
25
24
|
const weeklyTokens = {};
|
|
26
25
|
|
|
27
|
-
// Process daily model tokens
|
|
28
26
|
for (const dayData of stats.dailyModelTokens) {
|
|
29
27
|
const weekKey = getWeekKey(dayData.date);
|
|
30
28
|
if (!weeklyTokens[weekKey]) {
|
|
@@ -37,67 +35,60 @@ for (const dayData of stats.dailyModelTokens) {
|
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
// Sort weeks chronologically
|
|
41
38
|
const sortedWeeks = Object.keys(weeklyTokens).sort();
|
|
42
|
-
|
|
43
|
-
// Find max for scaling
|
|
44
39
|
const maxTokens = Math.max(...sortedWeeks.map(w => weeklyTokens[w].total));
|
|
45
40
|
|
|
46
|
-
//
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const colors = {
|
|
54
|
-
header: '\x1b[36m', // Cyan
|
|
55
|
-
label: '\x1b[33m', // Yellow
|
|
56
|
-
bar: '\x1b[32m', // Green
|
|
57
|
-
total: '\x1b[35m', // Magenta
|
|
58
|
-
reset: '\x1b[0m'
|
|
41
|
+
// Colors
|
|
42
|
+
const c = {
|
|
43
|
+
hdr: '\x1b[36m',
|
|
44
|
+
lbl: '\x1b[33m',
|
|
45
|
+
bar: '\x1b[32m',
|
|
46
|
+
num: '\x1b[35m',
|
|
47
|
+
res: '\x1b[0m'
|
|
59
48
|
};
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
// Terminal width
|
|
51
|
+
const W = process.stdout.columns || 80;
|
|
52
|
+
const CHART_W = Math.min(50, W - 30);
|
|
53
|
+
const PAD = Math.floor((W - CHART_W - 30) / 2);
|
|
65
54
|
|
|
66
|
-
//
|
|
67
|
-
console.log(
|
|
55
|
+
// Header
|
|
56
|
+
console.log('\n' + c.hdr + '═'.repeat(W));
|
|
57
|
+
console.log(' '.repeat(PAD) + 'WEEKLY TOKEN USAGE GRAPH');
|
|
58
|
+
console.log('═'.repeat(W) + c.res);
|
|
59
|
+
console.log();
|
|
68
60
|
|
|
69
|
-
//
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
console.log(
|
|
61
|
+
// Column headers
|
|
62
|
+
const hdr = ' Week Tokens';
|
|
63
|
+
console.log(c.lbl + hdr + ' '.repeat(CHART_W - hdr.length + 5) + '| Bar' + c.res);
|
|
64
|
+
console.log(c.lbl + '─'.repeat(W) + c.res);
|
|
73
65
|
|
|
74
66
|
let grandTotal = 0;
|
|
75
67
|
for (const week of sortedWeeks) {
|
|
76
68
|
const data = weeklyTokens[week];
|
|
77
|
-
const barLen = Math.max(1, Math.floor(data.total /
|
|
78
|
-
const bar = colors.bar + '█'.repeat(barLen) + colors.reset;
|
|
79
|
-
const label = colors.label + week + colors.reset;
|
|
80
|
-
const spaces = ' '.repeat(Math.max(0, LABEL_WIDTH - label.length));
|
|
69
|
+
const barLen = Math.max(1, Math.floor((data.total / maxTokens) * CHART_W));
|
|
81
70
|
|
|
82
|
-
// Format
|
|
71
|
+
// Format: week left-aligned, tokens right-aligned
|
|
72
|
+
const weekStr = week;
|
|
83
73
|
const tokenStr = data.total.toLocaleString();
|
|
84
|
-
const
|
|
74
|
+
const bar = c.bar + '█'.repeat(barLen) + c.res;
|
|
85
75
|
|
|
86
|
-
|
|
76
|
+
const line = ` ${c.lbl}${weekStr}${c.res} ${c.num}${tokenStr}${c.res} ${bar}`;
|
|
77
|
+
console.log(line);
|
|
87
78
|
grandTotal += data.total;
|
|
88
79
|
}
|
|
89
80
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
console.log(
|
|
94
|
-
console.log(
|
|
81
|
+
console.log(c.lbl + '─'.repeat(W) + c.res);
|
|
82
|
+
|
|
83
|
+
const avg = Math.round(grandTotal / sortedWeeks.length);
|
|
84
|
+
console.log(`\n Total: ${c.num}${grandTotal.toLocaleString()}${c.res} tokens (${sortedWeeks.length} weeks)`);
|
|
85
|
+
console.log(` Average: ${c.num}${avg.toLocaleString()}${c.res} tokens/week`);
|
|
86
|
+
console.log('\n' + c.hdr + '═'.repeat(W) + c.res + '\n');
|
|
95
87
|
|
|
96
|
-
//
|
|
97
|
-
console.log(
|
|
98
|
-
console.log('─'.repeat(
|
|
88
|
+
// Model breakdown
|
|
89
|
+
console.log(c.hdr + ' MODEL BREAKDOWN' + c.res);
|
|
90
|
+
console.log(c.lbl + '─'.repeat(W) + c.res);
|
|
99
91
|
|
|
100
|
-
// Aggregate model stats
|
|
101
92
|
const modelTotals = {};
|
|
102
93
|
for (const week of sortedWeeks) {
|
|
103
94
|
for (const [model, tokens] of Object.entries(weeklyTokens[week].byModel)) {
|
|
@@ -105,8 +96,10 @@ for (const week of sortedWeeks) {
|
|
|
105
96
|
}
|
|
106
97
|
}
|
|
107
98
|
|
|
99
|
+
const maxModelLen = Math.max(...Object.keys(modelTotals).map(m => m.length));
|
|
108
100
|
for (const [model, tokens] of Object.entries(modelTotals)) {
|
|
109
101
|
const pct = ((tokens / grandTotal) * 100).toFixed(1);
|
|
110
|
-
|
|
102
|
+
const padded = model.padEnd(maxModelLen);
|
|
103
|
+
console.log(` ${c.lbl}${padded}${c.res} ${c.num}${tokens.toLocaleString()}${c.res} (${pct}%)`);
|
|
111
104
|
}
|
|
112
105
|
console.log();
|