Documentation
¶
Index ¶
- func NormalizeSlug(slug string) (string, error)
- type EnterWorktreeOutput
- type EnterWorktreeTool
- func (t *EnterWorktreeTool) Description() string
- func (t *EnterWorktreeTool) Execute(ctx context.Context, input map[string]any) (types.ToolResult, error)
- func (t *EnterWorktreeTool) Name() string
- func (t *EnterWorktreeTool) Schema() types.JSONSchema
- func (t *EnterWorktreeTool) ToolMetadata(map[string]any) types.ToolMetadata
- type ExitWorktreeOutput
- type ExitWorktreeTool
- func (t *ExitWorktreeTool) Description() string
- func (t *ExitWorktreeTool) Execute(ctx context.Context, input map[string]any) (types.ToolResult, error)
- func (t *ExitWorktreeTool) MapToolResultToToolResultBlock(data any, toolUseID string) types.ToolResultBlock
- func (t *ExitWorktreeTool) Name() string
- func (t *ExitWorktreeTool) Schema() types.JSONSchema
- func (t *ExitWorktreeTool) ToolMetadata(input map[string]any) types.ToolMetadata
- type InMemoryWorktreeHookBridge
- type LifecycleEvent
- type LifecycleEventType
- type LifecycleFactory
- type LifecyclePublisher
- type LifecyclePublisherFunc
- type WorktreeHook
- type WorktreeHookBridge
- type WorktreeHookResult
- type WorktreeManager
- type WorktreeRuntime
- type WorktreeState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeSlug ¶
Types ¶
type EnterWorktreeOutput ¶
type EnterWorktreeTool ¶
type EnterWorktreeTool struct {
State *WorktreeState
Manager *WorktreeManager
Runtime *WorktreeRuntime
SessionID func() string
HookBridge WorktreeHookBridge
}
EnterWorktreeTool creates an isolated git worktree and records state.
func (*EnterWorktreeTool) Description ¶
func (t *EnterWorktreeTool) Description() string
func (*EnterWorktreeTool) Execute ¶
func (t *EnterWorktreeTool) Execute(ctx context.Context, input map[string]any) (types.ToolResult, error)
func (*EnterWorktreeTool) Name ¶
func (t *EnterWorktreeTool) Name() string
func (*EnterWorktreeTool) Schema ¶
func (t *EnterWorktreeTool) Schema() types.JSONSchema
func (*EnterWorktreeTool) ToolMetadata ¶
func (t *EnterWorktreeTool) ToolMetadata(map[string]any) types.ToolMetadata
type ExitWorktreeOutput ¶
type ExitWorktreeOutput struct {
Action string `json:"action"`
OriginalCWD string `json:"originalCwd"`
WorktreePath string `json:"worktreePath"`
WorktreeBranch string `json:"worktreeBranch,omitempty"`
TmuxSessionName string `json:"tmuxSessionName,omitempty"`
DiscardedFiles *int `json:"discardedFiles,omitempty"`
DiscardedCommits *int `json:"discardedCommits,omitempty"`
CleanupIncomplete bool `json:"cleanupIncomplete,omitempty"`
CleanupIssueCount int `json:"cleanupIssueCount,omitempty"`
Message string `json:"message"`
}
type ExitWorktreeTool ¶
type ExitWorktreeTool struct {
State *WorktreeState
Manager *WorktreeManager
Runtime *WorktreeRuntime
SessionID func() string
HookBridge WorktreeHookBridge
// contains filtered or unexported fields
}
ExitWorktreeTool leaves the current worktree, optionally removing it.
func (*ExitWorktreeTool) Description ¶
func (t *ExitWorktreeTool) Description() string
func (*ExitWorktreeTool) Execute ¶
func (t *ExitWorktreeTool) Execute(ctx context.Context, input map[string]any) (types.ToolResult, error)
func (*ExitWorktreeTool) MapToolResultToToolResultBlock ¶
func (t *ExitWorktreeTool) MapToolResultToToolResultBlock(data any, toolUseID string) types.ToolResultBlock
func (*ExitWorktreeTool) Name ¶
func (t *ExitWorktreeTool) Name() string
func (*ExitWorktreeTool) Schema ¶
func (t *ExitWorktreeTool) Schema() types.JSONSchema
func (*ExitWorktreeTool) ToolMetadata ¶
func (t *ExitWorktreeTool) ToolMetadata(input map[string]any) types.ToolMetadata
type InMemoryWorktreeHookBridge ¶
type InMemoryWorktreeHookBridge struct {
// contains filtered or unexported fields
}
func LoadWorktreeHookBridge ¶
func LoadWorktreeHookBridge(cwd string) (*InMemoryWorktreeHookBridge, error)
LoadWorktreeHookBridge reads project settings. Worktree hooks use the documented command-hook format and execute through the shell, matching the general hook runtime's command semantics.
func NewInMemoryWorktreeHookBridge ¶
func NewInMemoryWorktreeHookBridge() *InMemoryWorktreeHookBridge
func (*InMemoryWorktreeHookBridge) Lookup ¶
func (b *InMemoryWorktreeHookBridge) Lookup(name string) (WorktreeHook, bool)
func (*InMemoryWorktreeHookBridge) RunWithResult ¶
func (b *InMemoryWorktreeHookBridge) RunWithResult(ctx context.Context, name string, payload map[string]any) (WorktreeHookResult, error)
type LifecycleEvent ¶
type LifecycleEventType ¶
type LifecycleEventType string
const ( LifecycleEnter LifecycleEventType = "worktree_enter" LifecycleExit LifecycleEventType = "worktree_exit" )
type LifecycleFactory ¶
type LifecycleFactory func(repoRoot string) LifecyclePublisher
type LifecyclePublisher ¶
type LifecyclePublisher interface {
PublishWorktreeLifecycle(context.Context, LifecycleEvent) error
}
type LifecyclePublisherFunc ¶
type LifecyclePublisherFunc func(context.Context, LifecycleEvent) error
func (LifecyclePublisherFunc) PublishWorktreeLifecycle ¶
func (fn LifecyclePublisherFunc) PublishWorktreeLifecycle(ctx context.Context, event LifecycleEvent) error
type WorktreeHook ¶
type WorktreeHookBridge ¶
type WorktreeHookBridge interface {
Lookup(name string) (WorktreeHook, bool)
RunWithResult(ctx context.Context, name string, payload map[string]any) (WorktreeHookResult, error)
}
type WorktreeHookResult ¶
type WorktreeManager ¶
type WorktreeManager struct {
// contains filtered or unexported fields
}
WorktreeManager owns session state and serializes git worktree mutations per canonical repository. Session state is keyed explicitly; two registries in the same process never share the active flag merely because they share a repo.
func NewWorktreeManager ¶
func NewWorktreeManager() *WorktreeManager
type WorktreeRuntime ¶
type WorktreeRuntime struct {
// contains filtered or unexported fields
}
WorktreeRuntime owns the session-local working directory. The context-aware switcher lets the registry update every cwd-aware tool in one operation. It deliberately never calls os.Chdir: process cwd is shared by all sessions.
func NewWorktreeRuntime ¶
func NewWorktreeRuntime(cwd string) *WorktreeRuntime
func (*WorktreeRuntime) CurrentCWD ¶
func (r *WorktreeRuntime) CurrentCWD() string
func (*WorktreeRuntime) SetContextSwitcher ¶
func (r *WorktreeRuntime) SetContextSwitcher(switcher func(context.Context, string) error)
SetContextSwitcher installs the authoritative production transition.
func (*WorktreeRuntime) SwitchCWDContext ¶
func (r *WorktreeRuntime) SwitchCWDContext(ctx context.Context, cwd string) error
SwitchCWDContext lets production wiring authorize a worktree retarget against the exact loop-owned tool execution.
type WorktreeState ¶
type WorktreeState struct {
SessionID string // owning runtime session
Active bool
Path string // worktree directory
Name string // user-visible worktree slug
Branch string // branch name
OriginalDir string // where we came from
OriginalHeadCommit string
RepoRoot string // canonical repo root
StateFile string // persisted session state
CreatedHere bool // true if EnterWorktree created this worktree (vs entered an existing one)
HookBased bool
TmuxSessionName string
LifecycleFactory LifecycleFactory
// contains filtered or unexported fields
}
WorktreeState holds shared state across EnterWorktree / ExitWorktree calls.