Documentation
¶
Overview ¶
Package worktree wraps git-worktree operations for per-agent isolation (design 008): give a pane/agent its own git worktree so parallel agents never collide on the same repo — "N agents, N branches, one tab, zero collisions."
This package is the tested git seam. The command surface (##worktree) and the eventual pane-cwd integration live in internal/actors.
Index ¶
- func Add(repoRoot, path, branch string) error
- func DeleteBranch(repoRoot, branch string) error
- func DiffStat(path string) (string, error)
- func Dir(repoRoot, branch string) string
- func IsClean(path string) (bool, error)
- func IsGitRepo(dir string) bool
- func Merge(repoRoot, branch string) (string, error)
- func MergePreview(repoRoot, branch string) (string, error)
- func Prune(repoRoot string) error
- func Remove(repoRoot, path string, force bool) error
- func RepoRoot(dir string) (string, error)
- func SanitizeBranch(branch string) string
- type Info
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add creates a worktree at path on a new branch. If the branch already exists, it is checked out instead of created.
func DeleteBranch ¶
DeleteBranch force-deletes a local branch. Used by the headless CI runner (design 009) to drop the throwaway branch its per-run worktree was created on, so repeated `rysh run --worktree` invocations never accumulate branches.
func Dir ¶
Dir returns the conventional worktree path for a branch under the repo's .rysh/worktrees/ (mirrors the monorepo's own worktrees/ convention).
func Merge ¶
Merge merges branch into the current branch at repoRoot, returning git output. Fails (non-nil error) on conflicts — callers surface it fail-closed.
func MergePreview ¶
MergePreview returns a diff --stat of what merging branch would bring in.
func Prune ¶
Prune drops stale administrative entries — worktrees whose directory was deleted out from under git (crashed agent, manual rm -rf). It never touches a directory that still exists, so it is safe to run unconditionally at session start (design 008's orphan sweep).
func SanitizeBranch ¶
SanitizeBranch turns a branch name into a filesystem-safe directory segment.