Commit 3f8bf59
authored
feat: worktree-native workspace for parallel branch work (#22)
* feat: worktree-native workspace for parallel branch work
Add four new abilities — workspace-worktree-add|list|remove|prune — and a
matching "workspace worktree" CLI subcommand. The workspace now stores each
branch in its own directory at <workspace>/<repo>@<branch-slug>, so multiple
agent sessions can edit different branches of the same repo simultaneously
without stepping on each other.
All existing read/write/git abilities accept the new <repo>@<branch-slug>
handle alongside bare repo names; resolution happens through Workspace::
parse_handle() and a single resolve_repo_path() call site.
Mutating ops on the primary checkout (bare <repo>) now require
allow_primary_mutation=true / --allow-primary-mutation. The default-deny
codifies the "primary tracks the deployed branch, hands off" rule that
lived as informal discipline before. Worktrees are always allowed.
clone rejects @-suffixed names; remove refuses to delete a primary that has
linked worktrees attached; git push only enforces fixed_branch on the
primary, freeing worktrees to push any branch.
Includes pure-PHP smoke test for handle parsing/slugify (tests/
smoke-worktree-handles.php, 32/32 passing) and a manual end-to-end test
plan (tests/TESTING.md). AGENTS.md generator and README updated to teach
the worktree-first workflow.
* fix: live-test fixups from dogfooding on intelligence-chubes4
Found and fixed during end-to-end testing on the intelligence-chubes4
site (DATAMACHINE_WORKSPACE_PATH=~/Developer):
- Ability callbacks now declare `array|WP_Error` return types so the
primary-mutation guard (and other WP_Error returns) propagate cleanly
instead of throwing a TypeError in WorkspaceAbilities::*.
- Add `--allow-primary-mutation` to the `workspace git` CLI docblock
so WP-CLI accepts the flag.
- `workspace list` now surfaces `kind` (primary|worktree) and `repo`
columns so the new on-disk model is visible.
- `workspace-worktree-list` allows `branch_slug` and `branch` to be
null in its output schema (primaries have no slug; detached heads have
no branch).
- New `external` field on worktree-list output. Worktrees outside the
workspace path (e.g. /private/tmp/dm-worktrees/post-tracking from a
manual `git worktree add`) now report their absolute path as the
handle instead of a mangled relative slice.
- New `Workspace::resolve_default_base()` helper. `worktree add` defaults
to `origin/HEAD` when --from is omitted (per design), with a safe
fallback to plain HEAD if origin/HEAD is unset.
Live test summary on intelligence-chubes4:
- ✓ workspace list shows primary/worktree split
- ✓ worktree add data-machine-code test/smoke (created)
- ✓ worktree list discovers both in-workspace and external worktrees
- ✓ git status data-machine-code@test-smoke
- ✓ primary mutation guard fires (blocked by existing write_enabled
policy first; both gates work)
- ✓ clone --name=foo@bar rejected (`@` reserved for worktrees)
- ✓ worktree remove cleans the directory and prunes the registry
- ✓ end-to-end on mcp-context-wporg with explicit --from=origin/main
Note: workspace read/write/edit/ls still hit the pre-existing Studio
WASM mount limitation when paths are outside the site folder. Tracked
elsewhere; unrelated to this PR.1 parent 6725718 commit 3f8bf59
8 files changed
Lines changed: 1369 additions & 151 deletions
File tree
- docs
- inc
- Abilities
- Cli/Commands
- Workspace
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
60 | 87 | | |
61 | 88 | | |
62 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
300 | 302 | | |
301 | 303 | | |
302 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
5 | 21 | | |
6 | 22 | | |
7 | 23 | | |
| |||
0 commit comments