@phren/agent 0.0.1 → 0.1.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.
@@ -1,32 +0,0 @@
1
- /**
2
- * Progress indicators for terminal output.
3
- */
4
- const FILLED = "█";
5
- const EMPTY = "░";
6
- const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
7
- /** Render a progress bar: `[████░░░░] 50%` */
8
- export function renderProgressBar(current, total, width = 20) {
9
- if (total <= 0)
10
- return `[${"░".repeat(width)}] 0%`;
11
- const pct = Math.min(1, Math.max(0, current / total));
12
- const filled = Math.round(pct * width);
13
- const empty = width - filled;
14
- const percent = Math.round(pct * 100);
15
- return `[${FILLED.repeat(filled)}${EMPTY.repeat(empty)}] ${percent}%`;
16
- }
17
- /** Get a braille spinner frame by index (wraps automatically). */
18
- export function renderSpinnerFrame(frame) {
19
- return SPINNER_FRAMES[frame % SPINNER_FRAMES.length];
20
- }
21
- /** Format elapsed time from a start timestamp: `2.1s` or `1m 30s`. */
22
- export function renderElapsed(startMs) {
23
- const elapsed = Date.now() - startMs;
24
- if (elapsed < 1000)
25
- return `${elapsed}ms`;
26
- const secs = elapsed / 1000;
27
- if (secs < 60)
28
- return `${secs.toFixed(1)}s`;
29
- const mins = Math.floor(secs / 60);
30
- const remSecs = Math.round(secs % 60);
31
- return `${mins}m ${remSecs}s`;
32
- }