Documentation
¶
Index ¶
- Constants
- Variables
- func Execute(ctx context.Context, name string, params map[string]any, cwd string) ui.ToolResult
- func GetPlanModeToolSchemas() []provider.Tool
- func GetPlanModeToolSchemasFiltered(disabled map[string]bool) []provider.Tool
- func GetToolSchemas() []provider.Tool
- func GetToolSchemasFiltered(disabled map[string]bool) []provider.Tool
- func Register(tool Tool)
- type AskUserQuestionTool
- func (t *AskUserQuestionTool) Description() string
- func (t *AskUserQuestionTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *AskUserQuestionTool) ExecuteWithResponse(ctx context.Context, params map[string]any, response any, cwd string) ui.ToolResult
- func (t *AskUserQuestionTool) Icon() string
- func (t *AskUserQuestionTool) Name() string
- func (t *AskUserQuestionTool) PrepareInteraction(ctx context.Context, params map[string]any, cwd string) (any, error)
- func (t *AskUserQuestionTool) RequiresInteraction() bool
- type BashTool
- func (t *BashTool) Description() string
- func (t *BashTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *BashTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *BashTool) Icon() string
- func (t *BashTool) Name() string
- func (t *BashTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
- func (t *BashTool) RequiresPermission() bool
- type EditTool
- func (t *EditTool) Description() string
- func (t *EditTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *EditTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *EditTool) Icon() string
- func (t *EditTool) Name() string
- func (t *EditTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
- func (t *EditTool) RequiresPermission() bool
- type EnterPlanModeTool
- func (t *EnterPlanModeTool) Description() string
- func (t *EnterPlanModeTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *EnterPlanModeTool) ExecuteWithResponse(ctx context.Context, params map[string]any, response any, cwd string) ui.ToolResult
- func (t *EnterPlanModeTool) Icon() string
- func (t *EnterPlanModeTool) Name() string
- func (t *EnterPlanModeTool) PrepareInteraction(ctx context.Context, params map[string]any, cwd string) (any, error)
- func (t *EnterPlanModeTool) RequiresInteraction() bool
- type EnterPlanRequest
- type EnterPlanResponse
- type ExitPlanModeTool
- func (t *ExitPlanModeTool) Description() string
- func (t *ExitPlanModeTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *ExitPlanModeTool) ExecuteWithResponse(ctx context.Context, params map[string]any, response any, cwd string) ui.ToolResult
- func (t *ExitPlanModeTool) Icon() string
- func (t *ExitPlanModeTool) Name() string
- func (t *ExitPlanModeTool) PrepareInteraction(ctx context.Context, params map[string]any, cwd string) (any, error)
- func (t *ExitPlanModeTool) RequiresInteraction() bool
- type GlobTool
- type GrepTool
- type InteractiveTool
- type KillShellTool
- type PermissionAwareTool
- type PlanRequest
- type PlanResponse
- type Question
- type QuestionOption
- type QuestionRequest
- type QuestionResponse
- type ReadTool
- type Registry
- type TaskOutputTool
- type TodoWriteTool
- type Tool
- type ToolError
- type ToolInput
- type ToolSchema
- type WebFetchTool
- type WebSearchTool
- type WriteTool
- func (t *WriteTool) Description() string
- func (t *WriteTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *WriteTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
- func (t *WriteTool) Icon() string
- func (t *WriteTool) Name() string
- func (t *WriteTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
- func (t *WriteTool) RequiresPermission() bool
Constants ¶
const (
IconBash = "$"
)
const (
IconEdit = "✏️"
)
const (
IconKillShell = "x"
)
const (
IconTaskOutput = ">"
)
const (
IconWrite = "📝"
)
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global default tool registry
var EnterPlanModeSchema = provider.Tool{ Name: "EnterPlanMode", Description: "Request to enter plan mode for complex implementation tasks. Use this proactively when starting non-trivial tasks that require exploration and planning before making changes. The user must approve entering plan mode.", Parameters: map[string]any{ "type": "object", "properties": map[string]any{ "message": map[string]any{ "type": "string", "description": "Optional message explaining why plan mode is needed for this task.", }, }, "required": []string{}, }, }
EnterPlanModeSchema returns the schema for EnterPlanMode tool
var ExitPlanModeSchema = provider.Tool{ Name: "ExitPlanMode", Description: "Exit plan mode and submit your implementation plan for user approval. Call this when you have finished exploring the codebase and created a complete implementation plan.", Parameters: map[string]any{ "type": "object", "properties": map[string]any{ "plan": map[string]any{ "type": "string", "description": "The complete implementation plan in Markdown format. Should include: Summary, Analysis, Implementation Steps, Testing Strategy, and Risks.", }, }, "required": []string{"plan"}, }, }
ExitPlanModeSchema returns the schema for ExitPlanMode tool
Functions ¶
func GetPlanModeToolSchemas ¶ added in v1.1.0
GetPlanModeToolSchemas returns only the tools available in plan mode Plan mode restricts to read-only tools plus ExitPlanMode
func GetPlanModeToolSchemasFiltered ¶ added in v1.1.0
GetPlanModeToolSchemasFiltered returns plan mode tools excluding disabled tools
func GetToolSchemas ¶
GetToolSchemas returns provider.Tool definitions for all registered tools
func GetToolSchemasFiltered ¶ added in v1.1.0
GetToolSchemasFiltered returns tool schemas excluding disabled tools
Types ¶
type AskUserQuestionTool ¶ added in v1.1.0
type AskUserQuestionTool struct {
// contains filtered or unexported fields
}
AskUserQuestionTool prompts the user for input
func NewAskUserQuestionTool ¶ added in v1.1.0
func NewAskUserQuestionTool() *AskUserQuestionTool
NewAskUserQuestionTool creates a new AskUserQuestionTool
func (*AskUserQuestionTool) Description ¶ added in v1.1.0
func (t *AskUserQuestionTool) Description() string
func (*AskUserQuestionTool) Execute ¶ added in v1.1.0
func (t *AskUserQuestionTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
Execute should not be called directly for interactive tools
func (*AskUserQuestionTool) ExecuteWithResponse ¶ added in v1.1.0
func (t *AskUserQuestionTool) ExecuteWithResponse(ctx context.Context, params map[string]any, response any, cwd string) ui.ToolResult
ExecuteWithResponse formats the user's response for the LLM
func (*AskUserQuestionTool) Icon ¶ added in v1.1.0
func (t *AskUserQuestionTool) Icon() string
func (*AskUserQuestionTool) Name ¶ added in v1.1.0
func (t *AskUserQuestionTool) Name() string
func (*AskUserQuestionTool) PrepareInteraction ¶ added in v1.1.0
func (t *AskUserQuestionTool) PrepareInteraction(ctx context.Context, params map[string]any, cwd string) (any, error)
PrepareInteraction parses parameters and returns a QuestionRequest
func (*AskUserQuestionTool) RequiresInteraction ¶ added in v1.1.0
func (t *AskUserQuestionTool) RequiresInteraction() bool
type BashTool ¶
type BashTool struct{}
BashTool executes shell commands
func (*BashTool) Description ¶
func (*BashTool) ExecuteApproved ¶
func (t *BashTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
ExecuteApproved executes the command after user approval
func (*BashTool) PreparePermission ¶
func (t *BashTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
PreparePermission prepares a permission request with command preview
func (*BashTool) RequiresPermission ¶
RequiresPermission returns true - Bash always requires permission
type EditTool ¶
type EditTool struct{}
EditTool performs string replacement edits on files
func (*EditTool) Description ¶
func (*EditTool) ExecuteApproved ¶
func (t *EditTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
ExecuteApproved performs the file edit after user approval
func (*EditTool) PreparePermission ¶
func (t *EditTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
PreparePermission prepares a permission request with diff information
func (*EditTool) RequiresPermission ¶
RequiresPermission returns true - Edit always requires permission
type EnterPlanModeTool ¶ added in v1.1.0
type EnterPlanModeTool struct {
// contains filtered or unexported fields
}
EnterPlanModeTool allows AI to request entering plan mode
func NewEnterPlanModeTool ¶ added in v1.1.0
func NewEnterPlanModeTool() *EnterPlanModeTool
NewEnterPlanModeTool creates a new EnterPlanModeTool
func (*EnterPlanModeTool) Description ¶ added in v1.1.0
func (t *EnterPlanModeTool) Description() string
func (*EnterPlanModeTool) Execute ¶ added in v1.1.0
func (t *EnterPlanModeTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
Execute should not be called directly for interactive tools
func (*EnterPlanModeTool) ExecuteWithResponse ¶ added in v1.1.0
func (t *EnterPlanModeTool) ExecuteWithResponse(ctx context.Context, params map[string]any, response any, cwd string) ui.ToolResult
ExecuteWithResponse handles the user's approval decision
func (*EnterPlanModeTool) Icon ¶ added in v1.1.0
func (t *EnterPlanModeTool) Icon() string
func (*EnterPlanModeTool) Name ¶ added in v1.1.0
func (t *EnterPlanModeTool) Name() string
func (*EnterPlanModeTool) PrepareInteraction ¶ added in v1.1.0
func (t *EnterPlanModeTool) PrepareInteraction(ctx context.Context, params map[string]any, cwd string) (any, error)
PrepareInteraction parses parameters and returns an EnterPlanRequest
func (*EnterPlanModeTool) RequiresInteraction ¶ added in v1.1.0
func (t *EnterPlanModeTool) RequiresInteraction() bool
type EnterPlanRequest ¶ added in v1.1.0
type EnterPlanRequest struct {
ID string // Unique identifier for this request
Message string // Optional message explaining why plan mode is needed
}
EnterPlanRequest is sent to the TUI to ask user consent to enter plan mode
type EnterPlanResponse ¶ added in v1.1.0
type EnterPlanResponse struct {
RequestID string // ID of the original request
Approved bool // Whether user approved entering plan mode
}
EnterPlanResponse contains the user's decision
type ExitPlanModeTool ¶ added in v1.1.0
type ExitPlanModeTool struct {
// contains filtered or unexported fields
}
ExitPlanModeTool signals completion of plan mode
func NewExitPlanModeTool ¶ added in v1.1.0
func NewExitPlanModeTool() *ExitPlanModeTool
NewExitPlanModeTool creates a new ExitPlanModeTool
func (*ExitPlanModeTool) Description ¶ added in v1.1.0
func (t *ExitPlanModeTool) Description() string
func (*ExitPlanModeTool) Execute ¶ added in v1.1.0
func (t *ExitPlanModeTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
Execute should not be called directly for interactive tools
func (*ExitPlanModeTool) ExecuteWithResponse ¶ added in v1.1.0
func (t *ExitPlanModeTool) ExecuteWithResponse(ctx context.Context, params map[string]any, response any, cwd string) ui.ToolResult
ExecuteWithResponse handles the user's approval decision
func (*ExitPlanModeTool) Icon ¶ added in v1.1.0
func (t *ExitPlanModeTool) Icon() string
func (*ExitPlanModeTool) Name ¶ added in v1.1.0
func (t *ExitPlanModeTool) Name() string
func (*ExitPlanModeTool) PrepareInteraction ¶ added in v1.1.0
func (t *ExitPlanModeTool) PrepareInteraction(ctx context.Context, params map[string]any, cwd string) (any, error)
PrepareInteraction parses parameters and returns a PlanRequest
func (*ExitPlanModeTool) RequiresInteraction ¶ added in v1.1.0
func (t *ExitPlanModeTool) RequiresInteraction() bool
type GlobTool ¶
type GlobTool struct{}
GlobTool finds files matching a pattern
func (*GlobTool) Description ¶
type GrepTool ¶
type GrepTool struct{}
GrepTool searches for patterns in files
func (*GrepTool) Description ¶
type InteractiveTool ¶ added in v1.1.0
type InteractiveTool interface {
Tool
// RequiresInteraction returns true if the tool needs user interaction
RequiresInteraction() bool
// PrepareInteraction prepares an interaction request (e.g., question prompt)
PrepareInteraction(ctx context.Context, params map[string]any, cwd string) (interface{}, error)
// ExecuteWithResponse executes the tool with the user's response
ExecuteWithResponse(ctx context.Context, params map[string]any, response interface{}, cwd string) ui.ToolResult
}
InteractiveTool is a tool that requires user interaction (not just permission) Examples: AskUserQuestion for collecting user input
type KillShellTool ¶ added in v1.1.0
type KillShellTool struct{}
KillShellTool terminates a background task
func (*KillShellTool) Description ¶ added in v1.1.0
func (t *KillShellTool) Description() string
func (*KillShellTool) Execute ¶ added in v1.1.0
func (t *KillShellTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
Execute terminates a background task
func (*KillShellTool) Icon ¶ added in v1.1.0
func (t *KillShellTool) Icon() string
func (*KillShellTool) Name ¶ added in v1.1.0
func (t *KillShellTool) Name() string
type PermissionAwareTool ¶
type PermissionAwareTool interface {
Tool
// RequiresPermission returns true if the tool needs user approval
RequiresPermission() bool
// PreparePermission prepares a permission request (e.g., computes diff)
PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
// ExecuteApproved executes the tool after user approval
ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
}
PermissionAwareTool is a tool that requires user permission before execution
type PlanRequest ¶ added in v1.1.0
type PlanRequest struct {
ID string // Unique identifier for this request
Plan string // The implementation plan content (markdown)
}
PlanRequest is sent to the TUI to display plan for approval
type PlanResponse ¶ added in v1.1.0
type PlanResponse struct {
RequestID string // ID of the original request
Approved bool // Whether user approved the plan
ApproveMode string // "clear-auto" | "auto" | "manual" | "modify"
ModifiedPlan string // Modified plan content (if ApproveMode is "modify")
}
PlanResponse contains the user's decision
type Question ¶ added in v1.1.0
type Question struct {
Question string `json:"question"` // The complete question text
Header string `json:"header"` // Short label (max 12 chars)
Options []QuestionOption `json:"options"` // 2-4 options
MultiSelect bool `json:"multiSelect"` // Allow multiple selections
}
Question represents a question to ask the user
type QuestionOption ¶ added in v1.1.0
type QuestionOption struct {
Label string `json:"label"` // Display text for the option
Description string `json:"description"` // Explanation of what this option means
}
QuestionOption represents a single option for a question
type QuestionRequest ¶ added in v1.1.0
type QuestionRequest struct {
ID string // Unique identifier for this request
Questions []Question // Questions to display
}
QuestionRequest is sent to the TUI to display questions
type QuestionResponse ¶ added in v1.1.0
type QuestionResponse struct {
RequestID string // ID of the original request
Answers map[int][]string // Question index -> selected option labels
Cancelled bool // True if user cancelled
}
QuestionResponse contains the user's answers
type ReadTool ¶
type ReadTool struct{}
ReadTool reads file contents
func (*ReadTool) Description ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages tool registration and execution
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx context.Context, name string, params map[string]any, cwd string) ui.ToolResult
Execute runs a tool by name with the given parameters
type TaskOutputTool ¶ added in v1.1.0
type TaskOutputTool struct{}
TaskOutputTool retrieves output from background tasks
func (*TaskOutputTool) Description ¶ added in v1.1.0
func (t *TaskOutputTool) Description() string
func (*TaskOutputTool) Execute ¶ added in v1.1.0
func (t *TaskOutputTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
Execute retrieves task output
func (*TaskOutputTool) Icon ¶ added in v1.1.0
func (t *TaskOutputTool) Icon() string
func (*TaskOutputTool) Name ¶ added in v1.1.0
func (t *TaskOutputTool) Name() string
type TodoWriteTool ¶ added in v1.1.0
type TodoWriteTool struct{}
TodoWriteTool manages the task list for tracking progress
func NewTodoWriteTool ¶ added in v1.1.0
func NewTodoWriteTool() *TodoWriteTool
NewTodoWriteTool creates a new TodoWriteTool
func (*TodoWriteTool) Description ¶ added in v1.1.0
func (t *TodoWriteTool) Description() string
func (*TodoWriteTool) Execute ¶ added in v1.1.0
func (t *TodoWriteTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
func (*TodoWriteTool) Icon ¶ added in v1.1.0
func (t *TodoWriteTool) Icon() string
func (*TodoWriteTool) Name ¶ added in v1.1.0
func (t *TodoWriteTool) Name() string
type Tool ¶
type Tool interface {
// Name returns the tool name
Name() string
// Description returns a brief description of the tool
Description() string
// Icon returns the tool icon emoji
Icon() string
// Execute runs the tool with the given parameters
Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
}
Tool represents a read-only tool that can be executed
type ToolError ¶
type ToolError struct {
Message string
}
ToolError represents a tool-specific error
type ToolInput ¶
type ToolInput struct {
Name string // Tool name
Args string // Raw argument string
Params map[string]any // Parsed parameters
}
ToolInput represents parsed tool input
type ToolSchema ¶
ToolSchema defines the JSON schema for a tool
type WebFetchTool ¶
type WebFetchTool struct{}
WebFetchTool fetches content from URLs
func (*WebFetchTool) Description ¶
func (t *WebFetchTool) Description() string
func (*WebFetchTool) Execute ¶
func (t *WebFetchTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
func (*WebFetchTool) Icon ¶
func (t *WebFetchTool) Icon() string
func (*WebFetchTool) Name ¶
func (t *WebFetchTool) Name() string
type WebSearchTool ¶
type WebSearchTool struct{}
WebSearchTool searches the web for information
func (*WebSearchTool) Description ¶
func (t *WebSearchTool) Description() string
func (*WebSearchTool) Execute ¶
func (t *WebSearchTool) Execute(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
func (*WebSearchTool) Icon ¶
func (t *WebSearchTool) Icon() string
func (*WebSearchTool) Name ¶
func (t *WebSearchTool) Name() string
type WriteTool ¶
type WriteTool struct{}
WriteTool writes content to files
func (*WriteTool) Description ¶
func (*WriteTool) Execute ¶
Execute implements the Tool interface (for permission-unaware execution)
func (*WriteTool) ExecuteApproved ¶
func (t *WriteTool) ExecuteApproved(ctx context.Context, params map[string]any, cwd string) ui.ToolResult
ExecuteApproved performs the file write after user approval
func (*WriteTool) PreparePermission ¶
func (t *WriteTool) PreparePermission(ctx context.Context, params map[string]any, cwd string) (*permission.PermissionRequest, error)
PreparePermission prepares a permission request with diff information
func (*WriteTool) RequiresPermission ¶
RequiresPermission returns true - Write always requires permission