worktree

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package worktree is a stateless wrapper over `git worktree` for the sandboxes the agent works in. The lifecycle lives in app.Conversation.

Index

Constants

This section is empty.

Variables

View Source
var DefaultIncludes = []string{".env", ".env.local"}

DefaultIncludes are gitignored files copied into a new worktree, which a clean checkout would lack; a missing .env is the usual reason a sandboxed build fails.

Functions

func CopyIncludes

func CopyIncludes(repoRoot, dir string, patterns []string) (failed []string, err error)

CopyIncludes returns the files it found but could not copy, so the caller can warn; err means the lookup itself failed. Missing files are not failures.

func Create

func Create(repoRoot, slug string) (dir, branch string, err error)

Create fails if slug is taken, so the caller can ask for another name.

func CurrentBranch

func CurrentBranch(dir string) string

func HasChanges

func HasChanges(dir string) (bool, error)

func IsRepo

func IsRepo(dir string) bool

func Remove

func Remove(repoRoot, dir, branch string, force bool) (branchKept bool, err error)

Remove without force never loses work: git refuses to remove a dirty checkout or delete a branch with unmerged commits. branchKept reports that the checkout is gone but the branch stayed because the agent committed to it, so the caller can tell the user where the work is.

func Root

func Root(repoRoot string) string

Root is under .codebot/, which is gitignored, so worktrees stay out of the user's git status.

func Slug

func Slug(name string) string

Types

type Info

type Info struct {
	Path   string
	Branch string // "" when detached
}

func List

func List(repoRoot string) ([]Info, error)

List returns only codebot's worktrees.

Jump to

Keyboard shortcuts

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