$ErrorActionPreference = 'Stop' $workspace = [IO.Path]::GetFullPath('C:\Users\vince\Documents\Projects\TikZRefinery') $scratch = [IO.Path]::GetFullPath((Join-Path $workspace 'work\undo-redo-package')) if ($scratch -ne (Join-Path $workspace 'work\undo-redo-package') -or !$scratch.StartsWith($workspace + '\work\', [StringComparison]::OrdinalIgnoreCase)) { throw 'Unexpected cleanup target' } $required = @('code\packages\0.1.4-alpha\TikZRefinery.exe', 'documents\TikZRefinery.pdf','documents\TikZRefinery-Developers-Edition.pdf', 'code\tests\evidence\undo-redo-2026-11-24\prior-uncommitted.patch', 'documents\assets\undo-redo-2026-11-24\checks.json') foreach ($relative in $required) { if (!(Test-Path -LiteralPath (Join-Path $workspace $relative) -PathType Leaf)) { throw "Missing $relative" } } $items = @(Get-ChildItem -LiteralPath $scratch -Recurse -File) $bytes = ($items | Measure-Object -Property Length -Sum).Sum $count = $items.Count Remove-Item -LiteralPath $scratch -Recurse -Force foreach ($relative in $required) { if (!(Test-Path -LiteralPath (Join-Path $workspace $relative) -PathType Leaf)) { throw "Missing after cleanup: $relative" } } $record = [ordered]@{ removed = $scratch removedFiles = $count reclaimedBytes = $bytes retained = 'Runnable package, both reports/archives, source, prior-work patch, native captures, compact document review, final logs and incremental Debug build' } $record | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $workspace 'documents\assets\undo-redo-2026-11-24\cleanup.json') -Encoding utf8 $record | ConvertTo-Json