Skip to content

feat(cli): Add workspace storage purge command#469

Merged
cameroncooke merged 7 commits into
mainfrom
cam/purge-workspace-storage-management
Jul 10, 2026
Merged

feat(cli): Add workspace storage purge command#469
cameroncooke merged 7 commits into
mainfrom
cam/purge-workspace-storage-management

Conversation

@cameroncooke

Copy link
Copy Markdown
Collaborator

Adds an explicit xcodebuildmcp purge command 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 node is missing from PATH, which also blocked the pre-commit hook. CI should be used as the validation source for this draft.

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>
@cameroncooke cameroncooke marked this pull request as ready for review July 10, 2026 09:11

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Create PR

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.

Comment thread src/utils/purge-storage/planning.ts
Comment thread src/cli/commands/purge-interactive-model.ts
Comment thread src/cli/commands/purge.ts Outdated
cameroncooke and others added 3 commits July 10, 2026 10:34
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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Create PR

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.

Comment thread src/utils/purge-storage/enumerate.ts
Comment thread src/cli/commands/__tests__/purge.test.ts Outdated
Comment thread src/cli/commands/purge-interactive.ts
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>
@pkg-pr-new

pkg-pr-new Bot commented Jul 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/xcodebuildmcp@469

commit: 0c602d0

Comment thread src/cli/commands/purge.ts
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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/cli/commands/purge.ts
Comment thread src/cli/commands/purge-interactive.ts
Comment thread src/cli/yargs-app.ts
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>
Comment thread src/utils/purge-storage/execution.ts
@cameroncooke cameroncooke merged commit 6d1fbe6 into main Jul 10, 2026
42 of 45 checks passed
@cameroncooke cameroncooke deleted the cam/purge-workspace-storage-management branch July 10, 2026 18:48
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.

1 participant