feat: Nexus-owned git worktrees with session-as-branch naming (closes #10) #13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "worktree-issue-10-nexus-worktrees"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #10.
Summary
Nexus takes over git worktree lifecycle so the session name becomes the git branch name directly — no hardcoded
worktree-prefix.A session named
auth-rewritenow lives at/workspace/.nexus/worktrees/auth-rewriteon a branch calledauth-rewrite.claude --remote-controlis launched with cwd set to that worktree (no--worktreeflag), which sidesteps claude-code's prefix limitation entirely.What changed
createSessionnow: validates the session name againstgit check-ref-format --branchrules → pre-creates the worktree withgit worktree add -b <name>→ applies.worktreeinclude(best-effort) → seeds workspace trust for the new path → launches the tmux window. Retry-once cleanup ifgit worktree addhits stale state. Symmetric catch-block teardown on any failure.deleteSessionmirrors creation:tmux kill-window→git worktree remove --force→git branch -D. All best-effort.buildLaunchCommanddrops--worktree,cds into the Nexus worktree, and tags the Remote Control identifier as<workspace-label> · <session-name>so claude.ai/code disambiguates sessions across workspaces.apply-worktreeinclude.sh(new, inworker/) reimplements the gitignored-file copy contract usinggit ls-files --others --ignored --exclude-from=.....nexus/to/workspace/.gitignoreidempotently on boot.Two helpers extracted
lib/git-ref.ts—validateGitRefName()(26 tests, table-driven)lib/docker-exec.ts—execAndCapture()demuxes dockerode's framed stdout/stderr; throws on poll-timeout rather than silently returning exit 0What stays unchanged
worktree-*rows keep their existing branches until naturally deleted.branch/worktree_namecolumns — all the bare session name (git-ref safe).<workspace> · <session>prefix.Test plan
pnpm test); typecheck clean (pnpm exec tsc --noEmit).auth-rewrite→ verifygit branchshows bare name,/workspace/.nexus/worktrees/auth-rewriteexists, claude.ai/code shows<workspace> · auth-rewrite.feature/login).bad:name) returns 400..nexus/worktrees/<name>, re-create with same name, verify it cleans up and succeeds.Commits
13 commits, each focused. Two were review-driven fixes for issues caught in-loop (regex hardening in
git-ref.ts, stdout fallback on createSession throws).