From 5b6973e11d5185ff5b0ff292ed3ce77fd5a584c2 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 16 Aug 2026 22:57:06 +0200 Subject: [PATCH] Split disk_cleanup_check.sh: extract the helpers and the output blocks 329 -> 230 + 124. The colour constants, human_readable, dir_size_kb, report, confirm and try_clean move to lib/disk_cleanup_common.sh, along with the report-only loop and the summary block as print_report_only and print_summary. The seam passes state -- report accumulates into TOTAL_RECLAIMABLE and confirm reads CLEAN -- so both are set before the source line, and the verification is a trace diff rather than a static check: identical exit status, identical ordered du calls, identical stdout and stderr against a detached worktree at the pre-split commit. Also ran it for real from /tmp (not its own directory) to confirm SCRIPT_DIR resolves the lib from any cwd: 303.7 GB reported reclaimable, nothing deleted. The one shellcheck finding (SC2034 on RED) was fixed by moving the function that uses it, not suppressed. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY --- .../disk-cleanup-check-split-2026-08-16.json | 43 ++++++ meta/scripts/disk_cleanup_check.sh | 113 +--------------- meta/scripts/lib/disk_cleanup_common.sh | 124 ++++++++++++++++++ 3 files changed, 174 insertions(+), 106 deletions(-) create mode 100644 docs/superpowers/evidence/disk-cleanup-check-split-2026-08-16.json create mode 100755 meta/scripts/lib/disk_cleanup_common.sh diff --git a/docs/superpowers/evidence/disk-cleanup-check-split-2026-08-16.json b/docs/superpowers/evidence/disk-cleanup-check-split-2026-08-16.json new file mode 100644 index 00000000..d1416170 --- /dev/null +++ b/docs/superpowers/evidence/disk-cleanup-check-split-2026-08-16.json @@ -0,0 +1,43 @@ +{ + "intent": "Bring meta/scripts/disk_cleanup_check.sh (329 lines) under the 250-line cap by moving its formatting, sizing, confirmation and output helpers into a sourced lib.", + "scope": [ + "meta/scripts/disk_cleanup_check.sh", + "meta/scripts/lib/disk_cleanup_common.sh (new)", + "Non-goal: no change to which directories are checked, what is reported, or what --clean deletes" + ], + "changes": [ + "Move the six colour constants and human_readable/dir_size_kb/report/confirm/try_clean into lib/disk_cleanup_common.sh.", + "Move the report-only loop and the summary block into print_report_only and print_summary in the same lib; the entry script now ends with two calls.", + "Add SCRIPT_DIR resolved from BASH_SOURCE so the source line works from any cwd, and set CLEAN/TOTAL_RECLAIMABLE before sourcing, since confirm reads CLEAN and report accumulates into TOTAL_RECLAIMABLE." + ], + "verification": [ + { + "command": "meta/scripts/trace_shell_split.sh