feat(cli): Add workspace storage purge command#469
Conversation
Add an explicit purge command for reporting, dry-running, and deleting XcodeBuildMCP-managed workspace storage. The command keeps DerivedData cleanup opt-in, supports interactive and scriptable flows, and revalidates deletion candidates under workspace locks. Co-Authored-By: OpenAI Codex <noreply@openai.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Older-than ignores stale contents
- Changed effectiveMtimeMs calculation to use descendant mtime instead of Math.max with directory mtime, ensuring directories with stale contents but fresh metadata are correctly identified as purge candidates.
Or push these changes by commenting:
@cursor push bcbb0e215b
Preview (bcbb0e215b)
diff --git a/src/utils/purge-storage/planning.ts b/src/utils/purge-storage/planning.ts
--- a/src/utils/purge-storage/planning.ts
+++ b/src/utils/purge-storage/planning.ts
@@ -130,8 +130,7 @@
}
const scan = await scanPath(params.candidatePath);
- const effectiveMtimeMs =
- scan.latestMtimeMs === null ? stat.mtimeMs : Math.max(stat.mtimeMs, scan.latestMtimeMs);
+ const effectiveMtimeMs = scan.latestMtimeMs ?? stat.mtimeMs;
const retentionReason = shouldKeepForRetention({
mtimeMs: effectiveMtimeMs,You can send follow-ups to the cloud agent here.
Use newest regular file mtime for non-empty directory-backed purge candidates so harmless directory metadata updates do not defeat --older-than retention. Keep empty directory candidates on directory mtime as the fallback and continue deleting directory candidates atomically. Co-Authored-By: Codex <noreply@openai.com>
Default purge reports labeled the selected scope as all recognized workspaces while enumerating every workspace directory. Pass the resolved scope into enumeration so text and JSON output stay consistent. Add regression coverage for unrecognized workspace directories. Co-Authored-By: OpenAI Codex <noreply@openai.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Invalid workspace dirs crash purge
- Added filtering in listWorkspaceKeys to skip relative path segment directory names (., .., empty) with warnings before they reach normalizeWorkspaceKey validation.
Or push these changes by commenting:
@cursor push 1fe59e7789
Preview (1fe59e7789)
diff --git a/src/utils/purge-storage/enumerate.ts b/src/utils/purge-storage/enumerate.ts
--- a/src/utils/purge-storage/enumerate.ts
+++ b/src/utils/purge-storage/enumerate.ts
@@ -191,6 +191,12 @@
);
continue;
}
+ if (entry.name === '.' || entry.name === '..' || entry.name.trim() === '') {
+ warnings.push(
+ warningForPath(entryPath, 'workspace key is a relative path segment and was skipped'),
+ );
+ continue;
+ }
if (entry.isSymbolicLink()) {
warnings.push(warningForPath(entryPath, 'workspace symbolic link skipped'));
continue;You can send follow-ups to the cloud agent here.
Export interactive purge prompt helpers so tests assert the same strings used by the implementation. This prevents prompt wording changes from drifting between the CLI flow and its interaction tests. Document why confirmation-gated interactive purge includes DerivedData while non-TTY modes keep stricter defaults for scripts and agents. Co-Authored-By: OpenAI Codex <noreply@openai.com>
commit: |
Make report mode use the same default scope as dry-run and delete so a no-scope report previews the current workspace instead of all workspaces. Keep explicit all-workspace reports available through --scope all. Co-Authored-By: OpenAI Codex <noreply@openai.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c6e5e29. Configure here.
Route single-workspace interactive purge through the workspace class menu so users can choose a specific storage class instead of jumping straight to all folders. Reject blank family and workspace-key values before scope resolution. Update stale report-scope coverage to match the current-workspace default introduced by the recent report-default alignment change. Co-Authored-By: OpenAI Codex <noreply@openai.com>


Adds an explicit
xcodebuildmcp purgecommand for reviewing and cleaning XcodeBuildMCP-managed workspace storage. The new command supports report, dry-run, delete, and interactive flows, keeps DerivedData cleanup opt-in, and revalidates deletion candidates under workspace filesystem locks before removing anything.The storage model stays conservative: existing lifecycle cleanup remains narrow, while this command gives users a deliberate path to inspect and clean logs, result bundles, state transients, and explicitly selected DerivedData.
Local validation could not run in this environment because
nodeis missing from PATH, which also blocked the pre-commit hook. CI should be used as the validation source for this draft.