src/cli/format.ts — shared formatters
Purpose
Section titled “Purpose”Small string formatters shared by multiple CLI subcommands. The one
formatter lives in util/size.ts since item 658 (a run names what the
workspace’s cacheRetention evicted, and the orchestrator may not
import the CLI); this file re-exports it for the verbs.
Public surface
Section titled “Public surface”export { formatBytes } from '../util/index.js' // (n: number) => stringHuman-readable byte size with B / KB / MB / GB / TB / PB suffixes
and one decimal of precision below 10 of any unit. Powers of 1024.
| Input | Output |
|---|---|
0 | 0 B |
1023 | 1023 B |
1024 | 1.0 KB |
9 * 1024 + 100 | 9.1 KB |
10 * 1024 | 10 KB |
1024 ** 2 | 1.0 MB |
5 * 1024 ** 3 | 5.0 GB |
Use sites
Section titled “Use sites”vx cache pruneoutput (Pruned N entries (1.3 GB freed), and the orphaned artifacts it reaped).- The
vx infodoctor printout: the cache-size line (cache entries N (1.3 GB)). vx last: each executed task’s peak RSS.- The run’s
cacheRetentionline (vx: cache retention evicted N entries (1.3 GB)). - Re-exported from
cli/index.tsfor the verbs a plugin adds.
tests/cli.test.ts includes a formatBytes table-driven case set; the
table above is the function’s output row for row
(tests/module-shape-drift.test.ts).