Skip to content

add temp verb for WSL scratch sizing and selective wipe#26

Merged
MaceWindu merged 1 commit into
masterfrom
feat/temp-verb
May 18, 2026
Merged

add temp verb for WSL scratch sizing and selective wipe#26
MaceWindu merged 1 commit into
masterfrom
feat/temp-verb

Conversation

@MaceWindu
Copy link
Copy Markdown
Owner

Summary

New verb claudearium temp [size | clean -Scope <s>] plus a Scratch: row on the central dashboard. Three scopes:

  • tmp (/tmp) — fully safe.
  • cache (/home/claude/.cache) — safe, first-build penalty.
  • claude (/home/claude/.claude) — selectively destructive. Wipes projects/ (transcripts) and shell-snapshots/ by default; preserves todos/, plans/, host-tools/. -IncludeTodos / -IncludePlans widen the wipe. host-tools/ is never wiped (tool-managed).

The dashboard''s du -sb is capped with timeout 3 so a heavy ~/.claude doesn''t block the menu render.

Test plan

  • .\test-claudearium.ps1 -ParseCheck (74 files clean)
  • .\test-claudearium.ps1 -Auto -Only pure -CI (373/373, +7 new)
  • Distro lane via CI — new tests/distro/Temp.Tests.ps1 seeds each scratch dir + asserts the wipe / preserve set
  • Manual: temp against a busy distro, temp clean -Scope cache -Force reclaims real bytes

🤖 Generated with Claude Code

New `claudearium temp [size | clean -Scope <s>] [-IncludeTodos]
[-IncludePlans] [-Force]`. Three scopes:
  tmp     — /tmp (tmpfs, fully safe to wipe)
  cache   — /home/claude/.cache (npm/pip/cargo caches)
  claude  — /home/claude/.claude (Claude Code state). Default wipe:
            projects/ (transcripts) + shell-snapshots/. Preserved:
            todos/, plans/, host-tools/. -IncludeTodos / -IncludePlans
            widen the wipe; host-tools/ is never wiped.

The central dashboard''s status block grows a `Scratch:` row that
surfaces total + per-scope sizes. The in-distro `du -sb` is capped
with `timeout 3` so a power user''s ~/.claude (months of transcripts =
hundreds of thousands of small files) can''t block the menu render.

- modules/Temp.psm1 (new): Get-ScratchSizes (batched du -sb with
  timeout), Clear-Scratch by scope. The claude scope''s preserve set
  (todos/plans/host-tools) lives in a module-local constant so the
  pure tests can pin the contract.
- claudearium.ps1: Invoke-Temp / Invoke-TempSize / Invoke-TempClean
  verbs, central-dashboard Scratch row, -IncludeTodos / -IncludePlans
  script params.
- Tests: pure (du-output parsing, claude-scope wipe-set logic with
  and without -IncludeTodos / -IncludePlans, tmp/cache use mindepth 1
  — 7 cases) + distro (seed every scratch dir with a sentinel, run
  temp clean -Scope all -Force, assert wiped vs preserved set; also
  the -IncludeTodos -IncludePlans extension). Pure: 373/373 locally.
- Docs: usage.md, cookbook.md, architecture.md, testing.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 18, 2026 01:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new temp verb to claudearium.ps1 that surfaces and selectively wipes WSL-side scratch space (/tmp, ~/.cache, ~/.claude), plus a Scratch: row on the central dashboard. The claude scope is selectively destructive — wipes transcripts (projects/) and shell-snapshots/ by default while preserving todos/, plans/, and host-tools/ (the last is never wipeable). Get-ScratchSizes uses a single in-distro batched du -sb capped with timeout 3 to bound dashboard render time.

Changes:

  • New modules/Temp.psm1 exposes Get-ScratchSizes and Clear-Scratch (with -IncludeTodos / -IncludePlans to widen the claude-scope wipe).
  • claudearium.ps1 wires the temp verb (subverbs size / clean) with confirmation, before/after sizing, and a Scratch: row on the central dashboard.
  • Pure + distro Pester coverage with corresponding registry entries and doc updates (usage/cookbook/architecture/testing).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
modules/Temp.psm1 New module providing scratch sizing + scope-aware wipe primitives.
claudearium.ps1 Adds Invoke-Temp / Invoke-TempSize / Invoke-TempClean, dispatch entry, help text, and Scratch dashboard row.
tests/pure/Temp.Tests.ps1 Mocks the in-distro probe to pin parse + claude/tmp/cache wipe-set logic.
tests/distro/Temp.Tests.ps1 End-to-end seeds scratch dirs, runs temp clean, and asserts wipe/preserve contract.
tests/lib/TestRegistry.psm1 Registers new pure/Temp and distro/Temp entries.
docs/usage.md, docs/cookbook.md, docs/architecture.md, docs/testing.md Documents the new verb, examples, module placement, and updated test counts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread claudearium.ps1
Comment on lines +1372 to +1397
if ($scope -in @('claude','all')) {
$wipe = @('projects','shell-snapshots')
if ($IncludeTodos) { $wipe += 'todos' }
if ($IncludePlans) { $wipe += 'plans' }
$preserved = @('todos','plans','host-tools') | Where-Object { $wipe -notcontains $_ }
Write-Host ''
Write-Host ' claude scope:'
Write-Host (" wipe: " + (($wipe | ForEach-Object { "~/.claude/$_/" }) -join ', '))
if ($preserved) {
Write-Host (" preserved: " + (($preserved | ForEach-Object { "~/.claude/$_/" }) -join ', '))
}
}

if (-not $Force) {
$ok = Read-YesNo -Prompt "Wipe the above?" -Default $false -NonInteractive:$NonInteractive
if (-not $ok) { Write-Host 'Aborted.' -ForegroundColor Yellow; return }
}

foreach ($t in $targets) {
$extra = @{}
if ($t -eq 'claude') {
if ($IncludeTodos) { $extra.IncludeTodos = $true }
if ($IncludePlans) { $extra.IncludePlans = $true }
}
$r = Clear-Scratch -DistroName $DistroName -Scope $t @extra
Write-Host (" [$t] removed $($r.Removed) — $($r.PreservedNote)") -ForegroundColor Green
Comment thread claudearium.ps1
Comment on lines +3717 to +3726
# Scratch sizes are one short `du -sb` in-distro — fast on a
# running distro, skipped when it's stopped to avoid waking it.
$scratchLine = '-'
if ($state -eq 'Running') {
try {
$sz = Get-ScratchSizes -DistroName $distro
$scratchLine = ("{0} (tmp {1}, cache {2}, claude {3})" -f `
(Format-Bytes -Bytes $sz.total), (Format-Bytes -Bytes $sz.tmp),
(Format-Bytes -Bytes $sz.cache), (Format-Bytes -Bytes $sz.claude))
} catch { $scratchLine = '?' }
Comment thread tests/pure/Temp.Tests.ps1
BeforeEach {
$script:capturedScript = $null
Mock -ModuleName Temp Invoke-InDistroScript {
param($Name, $User, $Script, $AllowFail)
@MaceWindu MaceWindu merged commit 21db1ad into master May 18, 2026
9 checks passed
@MaceWindu MaceWindu deleted the feat/temp-verb branch May 18, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants