aoaoe 0.93.0 → 0.94.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/dist/stats.d.ts +3 -0
- package/dist/stats.js +25 -1
- package/package.json +1 -1
package/dist/stats.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface ActionStats {
|
|
|
15
15
|
export interface HistoryStats {
|
|
16
16
|
total: number;
|
|
17
17
|
byTag: Map<string, number>;
|
|
18
|
+
byHour: number[];
|
|
18
19
|
firstTs: number;
|
|
19
20
|
lastTs: number;
|
|
20
21
|
}
|
|
@@ -51,4 +52,6 @@ export declare function formatRate(count: number, spanMs: number): string;
|
|
|
51
52
|
* Format the full stats display for terminal output.
|
|
52
53
|
*/
|
|
53
54
|
export declare function formatStats(stats: CombinedStats, windowLabel?: string): string;
|
|
55
|
+
/** Format a 24-element heatmap as a colored block string. */
|
|
56
|
+
export declare function formatHeatmap(counts: number[]): string;
|
|
54
57
|
//# sourceMappingURL=stats.d.ts.map
|
package/dist/stats.js
CHANGED
|
@@ -59,6 +59,7 @@ export function parseActionStats(lines, maxAgeMs, now) {
|
|
|
59
59
|
export function parseHistoryStats(entries, maxAgeMs, now) {
|
|
60
60
|
const cutoff = maxAgeMs ? (now ?? Date.now()) - maxAgeMs : 0;
|
|
61
61
|
const byTag = new Map();
|
|
62
|
+
const byHour = new Array(24).fill(0);
|
|
62
63
|
let total = 0;
|
|
63
64
|
let firstTs = Infinity;
|
|
64
65
|
let lastTs = 0;
|
|
@@ -71,10 +72,11 @@ export function parseHistoryStats(entries, maxAgeMs, now) {
|
|
|
71
72
|
if (entry.ts > lastTs)
|
|
72
73
|
lastTs = entry.ts;
|
|
73
74
|
byTag.set(entry.tag, (byTag.get(entry.tag) ?? 0) + 1);
|
|
75
|
+
byHour[new Date(entry.ts).getHours()]++;
|
|
74
76
|
}
|
|
75
77
|
if (total === 0)
|
|
76
78
|
return null;
|
|
77
|
-
return { total, byTag, firstTs, lastTs };
|
|
79
|
+
return { total, byTag, byHour, firstTs, lastTs };
|
|
78
80
|
}
|
|
79
81
|
/**
|
|
80
82
|
* Combine action and history stats into a unified stats object.
|
|
@@ -214,8 +216,30 @@ export function formatStats(stats, windowLabel) {
|
|
|
214
216
|
lines.push(` ${color}${tag.padEnd(18)}${RESET} ${String(count).padStart(4)} ${SLATE}${bar}${RESET} ${DIM}${pct}%${RESET}`);
|
|
215
217
|
}
|
|
216
218
|
}
|
|
219
|
+
// hourly heatmap
|
|
220
|
+
if (stats.history && stats.history.total > 0) {
|
|
221
|
+
lines.push("");
|
|
222
|
+
lines.push(` ${BOLD}hourly activity${RESET}`);
|
|
223
|
+
lines.push(` ${formatHeatmap(stats.history.byHour)}`);
|
|
224
|
+
lines.push(` ${DIM}${"0".padEnd(6)}${"6".padEnd(6)}${"12".padEnd(6)}${"18".padEnd(5)}23${RESET}`);
|
|
225
|
+
}
|
|
217
226
|
lines.push(` ${hr}`);
|
|
218
227
|
lines.push("");
|
|
219
228
|
return lines.join("\n");
|
|
220
229
|
}
|
|
230
|
+
// ── Heatmap ──────────────────────────────────────────────────────────────────
|
|
231
|
+
const HEAT_BLOCKS = [" ", "░", "▒", "▓", "█"];
|
|
232
|
+
/** Format a 24-element heatmap as a colored block string. */
|
|
233
|
+
export function formatHeatmap(counts) {
|
|
234
|
+
const max = Math.max(...counts);
|
|
235
|
+
if (max === 0)
|
|
236
|
+
return DIM + HEAT_BLOCKS[0].repeat(24) + RESET;
|
|
237
|
+
return counts.map((c) => {
|
|
238
|
+
if (c === 0)
|
|
239
|
+
return `${SLATE}${HEAT_BLOCKS[0]}${RESET}`;
|
|
240
|
+
const level = Math.min(HEAT_BLOCKS.length - 1, Math.ceil((c / max) * (HEAT_BLOCKS.length - 1)));
|
|
241
|
+
const color = level <= 1 ? SLATE : level <= 2 ? SKY : level <= 3 ? AMBER : LIME;
|
|
242
|
+
return `${color}${HEAT_BLOCKS[level]}${RESET}`;
|
|
243
|
+
}).join("");
|
|
244
|
+
}
|
|
221
245
|
//# sourceMappingURL=stats.js.map
|