Skip to content
GitHubRSS

src/cli/format.ts — shared formatters

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.

export { formatBytes } from '../util/index.js' // (n: number) => string

Human-readable byte size with B / KB / MB / GB / TB / PB suffixes and one decimal of precision below 10 of any unit. Powers of 1024.

InputOutput
00 B
10231023 B
10241.0 KB
9 * 1024 + 1009.1 KB
10 * 102410 KB
1024 ** 21.0 MB
5 * 1024 ** 35.0 GB
  • vx cache prune output (Pruned N entries (1.3 GB freed), and the orphaned artifacts it reaped).
  • The vx info doctor printout: the cache-size line (cache entries N (1.3 GB)).
  • vx last: each executed task’s peak RSS.
  • The run’s cacheRetention line (vx: cache retention evicted N entries (1.3 GB)).
  • Re-exported from cli/index.ts for 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).