Documentation
¶
Overview ¶
Package worktreeTool implements EnterWorktree and ExitWorktree tools.
EnterWorktree creates a new git worktree and switches the session's working directory into it. ExitWorktree removes or keeps the worktree and restores the original working directory.
Port of src/tools/EnterWorktreeTool/ and src/tools/ExitWorktreeTool/.
Index ¶
- func IsInsideWorktree(cwd string) bool
- type CwdSetter
- type EnterWorktree
- func (t *EnterWorktree) Description() string
- func (t *EnterWorktree) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)
- func (t *EnterWorktree) InputSchema() json.RawMessage
- func (t *EnterWorktree) IsConcurrencySafe(_ json.RawMessage) bool
- func (t *EnterWorktree) IsReadOnly(_ json.RawMessage) bool
- func (t *EnterWorktree) Name() string
- type ExitWorktree
- func (t *ExitWorktree) Description() string
- func (t *ExitWorktree) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)
- func (t *ExitWorktree) InputSchema() json.RawMessage
- func (t *ExitWorktree) IsConcurrencySafe(_ json.RawMessage) bool
- func (t *ExitWorktree) IsReadOnly(_ json.RawMessage) bool
- func (t *ExitWorktree) Name() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInsideWorktree ¶
IsInsideWorktree returns true if cwd is a git worktree (not the main checkout).
Types ¶
type CwdSetter ¶
CwdSetter is called when the worktree tool needs to change the session cwd. Returns an error if the change was rejected.
type EnterWorktree ¶
type EnterWorktree struct {
// GetCwd returns the current working directory.
GetCwd func() string
// SetCwd changes the session's working directory.
SetCwd CwdSetter
}
EnterWorktree creates a git worktree and switches into it.
func (*EnterWorktree) Description ¶
func (t *EnterWorktree) Description() string
func (*EnterWorktree) Execute ¶
func (t *EnterWorktree) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)
func (*EnterWorktree) InputSchema ¶
func (t *EnterWorktree) InputSchema() json.RawMessage
func (*EnterWorktree) IsConcurrencySafe ¶
func (t *EnterWorktree) IsConcurrencySafe(_ json.RawMessage) bool
func (*EnterWorktree) IsReadOnly ¶
func (t *EnterWorktree) IsReadOnly(_ json.RawMessage) bool
func (*EnterWorktree) Name ¶
func (t *EnterWorktree) Name() string
type ExitWorktree ¶
type ExitWorktree struct {
// GetCwd returns the current working directory.
GetCwd func() string
// SetCwd changes the session's working directory.
SetCwd CwdSetter
// OriginalCwd is the directory to return to on exit.
OriginalCwd string
}
ExitWorktree exits the current worktree and returns to the original directory.
func (*ExitWorktree) Description ¶
func (t *ExitWorktree) Description() string
func (*ExitWorktree) Execute ¶
func (t *ExitWorktree) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)
func (*ExitWorktree) InputSchema ¶
func (t *ExitWorktree) InputSchema() json.RawMessage
func (*ExitWorktree) IsConcurrencySafe ¶
func (t *ExitWorktree) IsConcurrencySafe(_ json.RawMessage) bool
func (*ExitWorktree) IsReadOnly ¶
func (t *ExitWorktree) IsReadOnly(_ json.RawMessage) bool
func (*ExitWorktree) Name ¶
func (t *ExitWorktree) Name() string