Add agentws worktree-management binary #4
Reference in New Issue
Block a user
Delete Branch "benvin/agentws"
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?
Why
Agents need isolated git worktrees per branch without disturbing Ben's shared
~/src/prodenvcheckouts.agentwsprovides that, cloning into the source-of-truth checkout so branches stay visible in the main checkout, and isolating agent work under the XDG cache.Changes
cmd/agentwsbinary (ownpackage main/newRootCmd(), mirroringagentpr) with subcommands:new,list,rm,clean,token,credential,version.internal/agent/git.go: small, testable git helpers shelling out to thegitbinary (clone/fetch, worktree add/remove/list/prune, branch + config ops, porcelain parsing, branch-name sanitizing). No go-git dependency; stays CGO-free.agent.GiteaToken()for auth. Tokens (~1h ephemeral) are never persisted in a remote URL or config:agentwswires itself as an ephemeral git credential helper (agentws credential get, git credential protocol on stdin, host-scoped to git.unkin.net).newsetsuser.name/user.email/credential.helperin the per-worktree config (viaextensions.worktreeConfig) so the shared checkout's identity/config is untouched.~/src/prodenv/<repo>so agent branches are visible in the main checkout;rm/cleanfetch there afterwards to keep the default branch current.AGENTWS_SRC_ROOT(default ~/src/prodenv),AGENTWS_ROOT(default ~/.cache/agentws),AGENTWS_OWNER(default unkin).MakefileBINARIES,scripts/build-rpm.sh,packaging/nfpm.yaml(binary + bash/zsh/fish completions),.woodpecker/release.yaml(cross-compile loop + release assets),.gitignore.agentwsinREADME.mdandAGENTS.md.Tests
SanitizeBranch,WorktreeDirName,ParseWorktreeList.cmd/agentwstests: bad input fails before any network call, andcredential getstays silent for non-Gitea hosts (no token minted).gofmt,go vet,go test -race ./...,make build,make completions, andmake rpmall pass locally.