Documentation
¶
Index ¶
- Variables
- func CheckCWDSafe(cwd, root, name string) error
- func DetectPkgManager(dir string) string
- func DetectPrimaryCheckout() (bool, error)
- func InstallArgs(pm string) (bin string, args []string)
- func IsCWDInsideWorktree(cwd, wtPath string) bool
- func IsPrimaryCheckout(absGitDir string) bool
- func IsRealWorktree(dir string) bool
- func RunHook(r io.Reader, w io.Writer) error
- func ValidateLinkedCheckout(path string) (string, error)
- func WorktreePath(root, name string) string
- type App
- func (a *App) Cleanup(name string, opts ...CleanupOpts) error
- func (a *App) Create(name string, opts ...CreateOpts) error
- func (a *App) Exec(name string, args []string) error
- func (a *App) HasUnmergedCommits(name string) (bool, error)
- func (a *App) List() error
- func (a *App) Merge(name string, opts ...MergeOpts) error
- func (a *App) MergeRemoteBranch(branch string) error
- func (a *App) Prune() error
- type CleanupOpts
- type CreateOpts
- type DiffResult
- type ExitError
- type HookContext
- type HookDenial
- type MergeConflictError
- type MergeOpts
- type WorktreeEntry
Constants ¶
This section is empty.
Variables ¶
var DetectPrimaryCheckoutFunc = DetectPrimaryCheckout
DetectPrimaryCheckoutFunc is the function used to detect primary checkout. It is a variable to allow test injection.
Functions ¶
func CheckCWDSafe ¶
CheckCWDSafe returns an error if cwd is inside the named worktree.
func DetectPkgManager ¶
DetectPkgManager returns the package manager name based on lock files in dir.
func DetectPrimaryCheckout ¶
DetectPrimaryCheckout resolves the current git dir and classifies checkout type.
func InstallArgs ¶
InstallArgs returns the binary and arguments for installing deps.
func IsCWDInsideWorktree ¶
IsCWDInsideWorktree reports whether cwd is at or below wtPath.
func IsPrimaryCheckout ¶
IsPrimaryCheckout reports whether absGitDir points at the repo's primary checkout.
func IsRealWorktree ¶
IsRealWorktree reports whether dir looks like a valid git worktree (has a .git file or directory).
func RunHook ¶
RunHook reads a PreToolUse JSON payload from r, checks the command, and writes a deny decision to w if the command is blocked. Returns nil on success (including when the command is allowed and nothing is written).
func ValidateLinkedCheckout ¶
ValidateLinkedCheckout resolves and validates a checkout path. It enforces that the path exists, is a git checkout, and is NOT a primary checkout (".git"). This structurally requires linked worktrees for agent work.
func WorktreePath ¶
WorktreePath returns the on-disk path for a named worktree.
Types ¶
type App ¶
type App struct {
Root string
CmdPrefix string // command prefix for user-facing messages (e.g., "noodle worktree")
MergeLockTimeout time.Duration // 0 uses defaultMergeLockTimeout
IntegrationBranch string // override for the integration branch; auto-discovered when empty
Quiet bool // suppress stdout/stderr chatter for programmatic callers
}
App holds the resolved git root and provides worktree operations.
func (*App) Cleanup ¶
func (a *App) Cleanup(name string, opts ...CleanupOpts) error
Cleanup removes a worktree without merging.
func (*App) Create ¶
func (a *App) Create(name string, opts ...CreateOpts) error
Create creates a new worktree and branch, symlinks local settings, and installs deps.
func (*App) MergeRemoteBranch ¶
type CleanupOpts ¶
type CleanupOpts struct {
// Force removes the worktree even when unmerged commits exist.
Force bool
}
CleanupOpts holds optional parameters for Cleanup.
type CreateOpts ¶
type CreateOpts struct {
// From is the branch or commit to base the new worktree on. Empty means HEAD.
From string
}
CreateOpts holds optional parameters for Create.
type DiffResult ¶
DiffResult holds the unified diff and diffstat for a worktree branch.
func DiffWorktree ¶
func DiffWorktree(worktreePath string) (DiffResult, error)
DiffWorktree computes the diff between the worktree's branch HEAD and the base branch (auto-discovered from origin/HEAD, falling back to "main").
type ExitError ¶
type ExitError struct {
Code int
}
ExitError represents a process exit with a specific code.
type HookContext ¶
HookContext captures session and checkout mode for command validation.
type HookDenial ¶
type HookDenial struct {
Reason string
}
HookDenial holds the reason a command was denied.
func CheckCommand ¶
func CheckCommand(cmd string) *HookDenial
CheckCommand inspects a Bash command string and returns a denial if it matches a dangerous worktree pattern, or nil if the command is allowed.
func CheckCommandWithContext ¶
func CheckCommandWithContext(cmd string, ctx HookContext) *HookDenial
CheckCommandWithContext applies static + contextual worktree safety checks.
type MergeConflictError ¶
MergeConflictError marks deterministic git merge/rebase conflicts so callers can avoid retry loops and surface manual resolution paths.
func (*MergeConflictError) Error ¶
func (e *MergeConflictError) Error() string
func (*MergeConflictError) Unwrap ¶
func (e *MergeConflictError) Unwrap() error
type MergeOpts ¶
type MergeOpts struct {
// Into overrides the integration branch for this merge.
Into string
}
MergeOpts holds optional parameters for Merge.
type WorktreeEntry ¶
type WorktreeEntry struct {
Name string // display name (last path component or relative path under .worktrees/)
Path string // absolute on-disk path
Branch string // branch name (empty for detached HEAD)
Source string // "noodle", "claude", "cursor", or "other"
}
WorktreeEntry is a non-main worktree discovered from git metadata.