Summary
The formatMemoryUsage function in packages/core/src/utils/formatters.ts is a general-purpose byte formatting utility that converts byte values to human-readable strings (e.g., 1024 → "1.0 KB").
The current name formatMemoryUsage is misleading as it suggests the function is specific to memory metrics, when it actually formats any byte value.
Proposed Change
Rename formatMemoryUsage → formatBytes within the core package scope only.
Files affected:
packages/core/src/utils/formatters.ts - rename function
packages/core/src/utils/formatters.test.ts - update test suite name
packages/core/src/tools/shell.ts - update import and usage
Why this matters:
- Clarity:
formatBytes accurately describes what the function does
- Reuse: The current name discourages reuse because it sounds memory-specific, even though it's a general byte formatter
- Consistency: Aligns with common naming conventions (
formatBytes is standard across ecosystems)
Scope
This refactor is limited to packages/core/ only. The cli/ package has its own formatMemoryUsage function which remains unchanged (intentional package independence per project conventions).
Summary
The
formatMemoryUsagefunction inpackages/core/src/utils/formatters.tsis a general-purpose byte formatting utility that converts byte values to human-readable strings (e.g.,1024→"1.0 KB").The current name
formatMemoryUsageis misleading as it suggests the function is specific to memory metrics, when it actually formats any byte value.Proposed Change
Rename
formatMemoryUsage→formatByteswithin thecorepackage scope only.Files affected:
packages/core/src/utils/formatters.ts- rename functionpackages/core/src/utils/formatters.test.ts- update test suite namepackages/core/src/tools/shell.ts- update import and usageWhy this matters:
formatBytesaccurately describes what the function doesformatBytesis standard across ecosystems)Scope
This refactor is limited to
packages/core/only. Thecli/package has its ownformatMemoryUsagefunction which remains unchanged (intentional package independence per project conventions).