feat(workspace): add delete primitive (workspace-delete ability + CLI)#65
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #64. Fills a gap where agents had to drop out of the workspace API to remove tracked files (the
git rm/rm -rfworkaround that bypassed containment, sensitive-path, allowlist, and primary-mutation gates).New ability
datamachine/workspace-deleteplus awp datamachine-code workspace delete <repo> <path>CLI subcommand. Tracked paths are removed viagit rmso the deletion lands in working tree and index in one shot. Untracked paths are unlinked from disk; directories require--recursive.What's added
Workspace::delete_path()(inc/Workspace/Workspace.php) — sits next togit_addand reuses its existing gate ladder: traversal, sensitive-path, allowlist, primary-mutation. Detects tracked vs untracked viagit ls-files --error-unmatchand dispatches to eithergit rm [-r]or a recursive filesystem unlink.Workspace::remove_directory_recursive()— private helper that walks an untracked directory deepest-first and reports every removed entry.datamachine/workspace-deleteability (inc/Abilities/WorkspaceAbilities.php) — input{ repo, path, recursive?, allow_primary_mutation? }, output{ success, name, repo, path, deleted[], was_tracked }. Description and category match the existing workspace abilities.wp datamachine-code workspace deletesubcommand (inc/Cli/Commands/WorkspaceCommand.php) — same docblock +@subcommandshape asedit/write.Why a single primitive
Splitting into
delete-file+delete-directorydoubles the surface for no gain.recursiveflag covers directories and makes accidental recursive deletes opt-in (rejecting directories withoutrecursive=truematches POSIXrmsemantics).Verification (live on intelligence-chubes4)
delete homeboy@<branch> tmp.txt→unlink (1 path removed). ✓delete→git statusshowed stagedDentry. ✓--recursive→directory_requires_recursiveerror. ✓--recursive→unlink (4 paths removed)(file + nested file + subdir + dir). ✓.env) →sensitive_patherror. ✓../escape) →invalid_patherror. ✓/abs/path) →invalid_patherror. ✓primary_mutation_not_allowederror. ✓--allow-primary-mutation→ succeeds. ✓not_found(404) error. ✓Out of scope
git_add.workspace-delete-many— agents can call once per path. Add later if it becomes a real need.AI assistance
git_add/workspace editshapes, and live-smoke-testing every gate path on intelligence-chubes4. Chris reviewed the gap framing and authorized the upstream-first fix.