Documentation
¶
Overview ¶
Package worktree manages git worktrees for term-llm sessions.
Index ¶
- Variables
- func Diff(dir string) (string, error)
- func IsGitRepo(dir string) bool
- func MainRepoRoot(dir string) (string, error)
- func ManagedRoot(repoRoot string) (string, error)
- func ManagedRootBase() (string, error)
- func Promote(ctx context.Context, dir, branch string) error
- func Remove(ctx context.Context, dir string, opts RemoveOptions) error
- func TouchLastBound(dir string) error
- type AssistedMergeOptions
- type AssistedMergeResult
- type CreateOptions
- type InUseSession
- type MergeOptions
- type MergeResult
- type Progress
- type PromoteOptions
- type PromoteResult
- type RemoveOptions
- type Status
- type Worktree
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func MainRepoRoot ¶
MainRepoRoot returns the canonical main checkout root for any worktree in the repo.
func ManagedRoot ¶
ManagedRoot returns the bucket for managed worktrees for repoRoot.
func ManagedRootBase ¶
ManagedRootBase returns the global worktree data directory.
func Remove ¶
func Remove(ctx context.Context, dir string, opts RemoveOptions) error
Remove removes a managed worktree and prunes git's worktree metadata.
func TouchLastBound ¶
TouchLastBound records that a session bound this worktree now.
Types ¶
type AssistedMergeOptions ¶
AssistedMergeOptions configures StartAssistedMerge.
type AssistedMergeResult ¶
type AssistedMergeResult struct {
RootDir string `json:"root_dir,omitempty"`
WorktreeDir string `json:"worktree_dir,omitempty"`
WorktreeName string `json:"worktree_name,omitempty"`
Branch string `json:"branch,omitempty"`
PreviousRootRef string `json:"previous_root_ref,omitempty"`
PreviousRootBranch string `json:"previous_root_branch,omitempty"`
Base string `json:"base,omitempty"`
RootHead string `json:"root_head,omitempty"`
WorktreeHead string `json:"worktree_head,omitempty"`
SnapshotCommit string `json:"snapshot_commit,omitempty"`
ChangedFiles []string `json:"changed_files,omitempty"`
Conflicts []string `json:"conflicts,omitempty"`
RootStatus string `json:"root_status,omitempty"`
Applied bool `json:"applied"`
NeedsResolution bool `json:"needs_resolution"`
Message string `json:"message,omitempty"`
}
AssistedMergeResult describes a recovery branch prepared for LLM-assisted merge resolution.
func StartAssistedMerge ¶
func StartAssistedMerge(ctx context.Context, dir string, opts AssistedMergeOptions) (AssistedMergeResult, error)
StartAssistedMerge prepares a safe root recovery branch for LLM-assisted resolution. It applies the worktree snapshot with cherry-pick -n and leaves conflicts in place on the recovery branch when they occur.
type CreateOptions ¶
type CreateOptions struct {
Name string
Base string
Branch string
SetupScript string
SetupTimeout time.Duration
CopyFiles []string
ProgressFn func(message string)
Progress chan<- Progress
}
CreateOptions configures Create.
type InUseSession ¶
type InUseSession struct {
ID string `json:"id"`
Number int64 `json:"number,omitempty"`
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
}
InUseSession describes a session bound to a worktree.
type MergeOptions ¶
MergeOptions configures MergeBack.
type MergeResult ¶
type MergeResult struct {
Applied bool `json:"applied"`
Committed bool `json:"committed"`
SnapshotCommit string `json:"snapshot_commit,omitempty"`
Conflicts []string `json:"conflicts,omitempty"`
Message string `json:"message,omitempty"`
WorktreeDir string `json:"worktree_dir,omitempty"`
RootDir string `json:"root_dir,omitempty"`
WorktreeName string `json:"worktree_name,omitempty"`
Base string `json:"base,omitempty"`
WorktreeHead string `json:"worktree_head,omitempty"`
RootHead string `json:"root_head,omitempty"`
RootStatus string `json:"root_status,omitempty"`
ChangedFiles []string `json:"changed_files,omitempty"`
ConflictReset bool `json:"conflict_reset,omitempty"`
ConflictCleanupError string `json:"conflict_cleanup_error,omitempty"`
}
MergeResult describes the result of MergeBack.
func MergeBack ¶
func MergeBack(ctx context.Context, dir string, opts MergeOptions) (MergeResult, error)
MergeBack snapshots the worktree and cherry-picks it into the root checkout staged and uncommitted by default.
type Progress ¶
type Progress struct {
Message string `json:"message"`
}
Progress is emitted by long-running worktree operations.
type PromoteOptions ¶
type PromoteOptions struct {
Message string
}
PromoteOptions configures PromoteToRoot.
type PromoteResult ¶
type PromoteResult struct {
RootDir string `json:"root_dir,omitempty"`
WorktreeDir string `json:"worktree_dir,omitempty"`
WorktreeName string `json:"worktree_name,omitempty"`
Branch string `json:"branch,omitempty"`
PreviousRootRef string `json:"previous_root_ref,omitempty"`
PreviousRootBranch string `json:"previous_root_branch,omitempty"`
WorktreeHead string `json:"worktree_head,omitempty"`
SnapshotCommit string `json:"snapshot_commit,omitempty"`
ChangedFiles []string `json:"changed_files,omitempty"`
RootStatus string `json:"root_status,omitempty"`
Applied bool `json:"applied"`
OriginalWorktreeStillExists bool `json:"original_worktree_still_exists"`
}
PromoteResult describes the result of PromoteToRoot.
func PromoteToRoot ¶
func PromoteToRoot(ctx context.Context, dir, branch string, opts PromoteOptions) (PromoteResult, error)
PromoteToRoot creates a branch from the worktree HEAD, checks it out in the root checkout, and applies dirty worktree changes there staged and uncommitted. The original linked worktree is left in place.
type RemoveOptions ¶
RemoveOptions configures Remove.
type Worktree ¶
type Worktree struct {
Name string `json:"name"`
Dir string `json:"dir"`
RepoRoot string `json:"repo_root,omitempty"`
Branch string `json:"branch,omitempty"`
Base string `json:"base"` // full base SHA
Detached bool `json:"detached"`
Status Status `json:"status"`
DirtyFiles int `json:"dirty_files"`
HeadSHA string `json:"head_sha"`
CreatedAt time.Time `json:"created_at,omitempty"`
LastBoundAt time.Time `json:"last_bound_at,omitempty"`
Orphaned bool `json:"orphaned,omitempty"`
}
Worktree describes a managed git worktree.