worktree

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package worktree manages git worktree lifecycle for agent isolation. Each agent gets its own worktree at .bc/agents/<name>/worktree/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles git worktree lifecycle for agent isolation.

func NewManager

func NewManager(repoRoot string) *Manager

NewManager creates a new worktree manager rooted at the given repository path. It reads BC_HOST_WORKSPACE to determine the host base name for worktree naming.

func (*Manager) ClaudeDir

func (m *Manager) ClaudeDir(agentName string) string

ClaudeDir returns the path to the Claude home directory for the given agent.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, agentName string) (string, error)

Create creates a git worktree for the given agent. It prunes stale worktrees, removes any existing worktree at the path, and creates a new detached worktree to avoid branch conflicts.

func (*Manager) EnsureClaudeDir

func (m *Manager) EnsureClaudeDir(agentName string) error

EnsureClaudeDir creates the Claude home directory for the given agent if it does not already exist.

func (*Manager) Exists

func (m *Manager) Exists(agentName string) bool

Exists checks whether the worktree directory exists for the given agent.

func (*Manager) Name

func (m *Manager) Name(agentName string) string

Name returns the worktree name for an agent: bc-<hostBaseName>-<agentName>.

func (*Manager) Path

func (m *Manager) Path(agentName string) string

Path returns the filesystem path for an agent's worktree. The directory is named bc-<workspace>-<agent> so git's internal worktree name matches the naming convention.

func (*Manager) Prune

func (m *Manager) Prune(ctx context.Context) error

Prune runs git worktree prune to clean stale worktree refs.

func (*Manager) Remove

func (m *Manager) Remove(ctx context.Context, agentName string) error

Remove removes the git worktree for the given agent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL