Documentation
¶
Index ¶
- Constants
- type EnterPlanModeConfig
- type EnterPlanModeTool
- func (t *EnterPlanModeTool) BackfillInput(ctx context.Context, input map[string]any) map[string]any
- func (t *EnterPlanModeTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)
- func (t *EnterPlanModeTool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
- func (t *EnterPlanModeTool) Definition() tool.Definition
- func (t *EnterPlanModeTool) Description(ctx context.Context) (string, error)
- func (t *EnterPlanModeTool) FormatResult(data any) string
- func (t *EnterPlanModeTool) IsConcurrencySafe(input map[string]any) bool
- func (t *EnterPlanModeTool) IsEnabled() bool
- func (t *EnterPlanModeTool) IsReadOnly(input map[string]any) bool
- func (t *EnterPlanModeTool) Prompt() string
- func (t *EnterPlanModeTool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)
- type ExitPlanModeConfig
- type ExitPlanModeOutput
- type ExitPlanModeTool
- func (t *ExitPlanModeTool) BackfillInput(ctx context.Context, input map[string]any) map[string]any
- func (t *ExitPlanModeTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)
- func (t *ExitPlanModeTool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
- func (t *ExitPlanModeTool) Definition() tool.Definition
- func (t *ExitPlanModeTool) Description(ctx context.Context) (string, error)
- func (t *ExitPlanModeTool) ExecutesInPlanMode(input map[string]any) bool
- func (t *ExitPlanModeTool) FormatResult(data any) string
- func (t *ExitPlanModeTool) IsConcurrencySafe(input map[string]any) bool
- func (t *ExitPlanModeTool) IsEnabled() bool
- func (t *ExitPlanModeTool) IsReadOnly(input map[string]any) bool
- func (t *ExitPlanModeTool) Prompt() string
- func (t *ExitPlanModeTool) RequiresUserInteraction() bool
- func (t *ExitPlanModeTool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)
- type PlanPersistFn
- type SubmitPlanConfig
- type SubmitPlanOutput
- type SubmitPlanTool
- func (t *SubmitPlanTool) BackfillInput(_ context.Context, input map[string]any) map[string]any
- func (t *SubmitPlanTool) Call(ctx context.Context, input tool.CallInput, _ types.CanUseToolFn) (tool.CallResult, error)
- func (t *SubmitPlanTool) CheckPermissions(_ context.Context, _ map[string]any, _ tool.ToolUseContext) types.PermissionResult
- func (t *SubmitPlanTool) Definition() tool.Definition
- func (t *SubmitPlanTool) Description(ctx context.Context) (string, error)
- func (t *SubmitPlanTool) ExecutesInPlanMode(_ map[string]any) bool
- func (t *SubmitPlanTool) FormatResult(data any) string
- func (t *SubmitPlanTool) IsConcurrencySafe(_ map[string]any) bool
- func (t *SubmitPlanTool) IsEnabled() bool
- func (t *SubmitPlanTool) IsReadOnly(_ map[string]any) bool
- func (t *SubmitPlanTool) Prompt() string
- func (t *SubmitPlanTool) RequiresUserInteraction() bool
- func (t *SubmitPlanTool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)
Constants ¶
const ( ToolNameEnterPlanMode = "enter_plan_mode" ToolNameExitPlanMode = "exit_plan_mode" ToolNameSubmitPlan = "submit_plan" )
Tool name constants
const ( SearchHintEnterPlanMode = "switch to plan mode to design an approach before coding" SearchHintExitPlanMode = "exit plan mode to get user approval for your plan" SearchHintSubmitPlan = "submit the implementation plan for user review and approval" )
Search hints
const ( DescriptionEnterPlanMode = "" /* 155-byte string literal not displayed */ DescriptionExitPlanMode = "" /* 129-byte string literal not displayed */ DescriptionSubmitPlan = "" /* 226-byte string literal not displayed */ )
Descriptions
const EnterPlanModePrompt = `Use this tool before implementation when the task requires analysis and user alignment before you touch any file.
If the user explicitly asks you to enter plan mode, call ` + "`enter_plan_mode`" + ` before continuing with analysis or implementation.
## Enter plan mode when
- The task is a feature, refactor, migration, or broad bug fix
- Multiple valid approaches exist and the right one is unclear
- The change spans several files or subsystems and you need to explore first
- The request is ambiguous enough that starting without alignment risks wasted work
- The task involves risky or irreversible operations (DB migrations, auth changes, major deletions)
## Do NOT enter plan mode when
- The task is a small, obvious, bounded fix
- The user already gave you explicit step-by-step instructions
- The request is pure research or reading with no planned implementation
- You already have enough context to start immediately and the risk is low
## What to do in plan mode
1. Explore the relevant code using read-only tools (Read, Bash with ls/cat/git log, grep)
2. Clarify ambiguous requirements with ask_user_question if needed
3. Design a concrete, ordered implementation plan
4. Call ` + "`submit_plan`" + ` with the full plan content and a short slug
5. Wait for the user to review — they may send feedback (revise and resubmit) or approve
6. When you receive approval, call ` + "`exit_plan_mode`" + ` and immediately create your task list
DO NOT edit or create source files while in plan mode.
The plan is presented to the user as an interactive artifact for review and approval.`
EnterPlanModePrompt is the system prompt for the EnterPlanMode tool.
const ExitPlanModePrompt = `` /* 729-byte string literal not displayed */
ExitPlanModePrompt is the system prompt for the ExitPlanMode tool.
const SubmitPlanPrompt = `` /* 1618-byte string literal not displayed */
SubmitPlanPrompt is the system prompt for the SubmitPlan tool.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnterPlanModeConfig ¶
Config represents tool configuration.
func DefaultEnterPlanModeConfig ¶
func DefaultEnterPlanModeConfig(sessionID types.SessionID) *EnterPlanModeConfig
DefaultEnterPlanModeConfig returns default configuration.
type EnterPlanModeTool ¶
type EnterPlanModeTool struct {
// contains filtered or unexported fields
}
EnterPlanModeTool represents the EnterPlanMode tool.
func NewEnterPlanModeTool ¶
func NewEnterPlanModeTool(config *EnterPlanModeConfig) *EnterPlanModeTool
NewEnterPlanModeTool creates a new EnterPlanMode tool. Session ID may be provided later by the runtime tool context.
func (*EnterPlanModeTool) BackfillInput ¶
BackfillInput enriches the input with derived fields.
func (*EnterPlanModeTool) Call ¶
func (t *EnterPlanModeTool) Call( ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn, ) (tool.CallResult, error)
Call executes the tool. Aligned with OpenClaude's EnterPlanModeTool.call
func (*EnterPlanModeTool) CheckPermissions ¶
func (t *EnterPlanModeTool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
CheckPermissions performs tool-specific permission checks.
func (*EnterPlanModeTool) Definition ¶
func (t *EnterPlanModeTool) Definition() tool.Definition
Definition returns the tool definition.
func (*EnterPlanModeTool) Description ¶
func (t *EnterPlanModeTool) Description(ctx context.Context) (string, error)
Description returns a human-readable description.
func (*EnterPlanModeTool) FormatResult ¶
func (t *EnterPlanModeTool) FormatResult(data any) string
FormatResult serialises the tool output.
func (*EnterPlanModeTool) IsConcurrencySafe ¶
func (t *EnterPlanModeTool) IsConcurrencySafe(input map[string]any) bool
IsConcurrencySafe returns whether this tool use can run concurrently.
func (*EnterPlanModeTool) IsEnabled ¶
func (t *EnterPlanModeTool) IsEnabled() bool
IsEnabled returns whether this tool is currently active.
func (*EnterPlanModeTool) IsReadOnly ¶
func (t *EnterPlanModeTool) IsReadOnly(input map[string]any) bool
IsReadOnly returns whether this tool use is read-only.
func (*EnterPlanModeTool) Prompt ¶
func (t *EnterPlanModeTool) Prompt() string
Prompt returns the system prompt for this tool.
func (*EnterPlanModeTool) ValidateInput ¶
func (t *EnterPlanModeTool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)
ValidateInput validates and normalizes input.
type ExitPlanModeConfig ¶
ExitPlanModeConfig represents tool configuration.
func DefaultExitPlanModeConfig ¶
func DefaultExitPlanModeConfig(sessionID types.SessionID) *ExitPlanModeConfig
DefaultExitPlanModeConfig returns default configuration.
type ExitPlanModeOutput ¶
type ExitPlanModeOutput struct {
Plan string `json:"plan"`
FilePath string `json:"file_path,omitempty"`
IsAgent bool `json:"is_agent"`
}
Output represents the result of exiting execution mode.
type ExitPlanModeTool ¶
type ExitPlanModeTool struct {
// contains filtered or unexported fields
}
ExitPlanModeTool represents the ExitPlanMode tool.
func NewExitPlanModeTool ¶
func NewExitPlanModeTool(config *ExitPlanModeConfig) *ExitPlanModeTool
NewExitPlanModeTool creates a new ExitPlanMode tool. Session ID may be provided later by the runtime tool context.
func (*ExitPlanModeTool) BackfillInput ¶
BackfillInput enriches the input with derived fields.
func (*ExitPlanModeTool) Call ¶
func (t *ExitPlanModeTool) Call( ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn, ) (tool.CallResult, error)
Call executes the tool. Aligned with OpenClaude's ExitPlanModeV2Tool.call
func (*ExitPlanModeTool) CheckPermissions ¶
func (t *ExitPlanModeTool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
CheckPermissions performs tool-specific permission checks.
func (*ExitPlanModeTool) Definition ¶
func (t *ExitPlanModeTool) Definition() tool.Definition
Definition returns the tool definition.
func (*ExitPlanModeTool) Description ¶
func (t *ExitPlanModeTool) Description(ctx context.Context) (string, error)
Description returns a human-readable description.
func (*ExitPlanModeTool) ExecutesInPlanMode ¶
func (t *ExitPlanModeTool) ExecutesInPlanMode(input map[string]any) bool
ExecutesInPlanMode allows ExitPlanMode to run while the session is in plan mode so it can restore the previous permission state.
func (*ExitPlanModeTool) FormatResult ¶
func (t *ExitPlanModeTool) FormatResult(data any) string
FormatResult serialises the tool output.
func (*ExitPlanModeTool) IsConcurrencySafe ¶
func (t *ExitPlanModeTool) IsConcurrencySafe(input map[string]any) bool
IsConcurrencySafe returns whether this tool use can run concurrently.
func (*ExitPlanModeTool) IsEnabled ¶
func (t *ExitPlanModeTool) IsEnabled() bool
IsEnabled returns whether this tool is currently active.
func (*ExitPlanModeTool) IsReadOnly ¶
func (t *ExitPlanModeTool) IsReadOnly(input map[string]any) bool
IsReadOnly returns whether this tool use is read-only.
func (*ExitPlanModeTool) Prompt ¶
func (t *ExitPlanModeTool) Prompt() string
Prompt returns the system prompt for this tool.
func (*ExitPlanModeTool) RequiresUserInteraction ¶
func (t *ExitPlanModeTool) RequiresUserInteraction() bool
RequiresUserInteraction returns whether this tool requires explicit user interaction.
func (*ExitPlanModeTool) ValidateInput ¶
func (t *ExitPlanModeTool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)
ValidateInput validates and normalizes input.
type PlanPersistFn ¶
type PlanPersistFn func(ctx context.Context, planID, sessionID, userID, slug, filename, content string) (id string, version int, err error)
PlanPersistFn is the callback the submit_plan tool uses to persist a plan document. Returns the plan ID (new or existing), version, and any error.
type SubmitPlanConfig ¶
type SubmitPlanConfig struct {
SessionID types.SessionID
AgentID *types.AgentID
UserID string
PersistFn PlanPersistFn
}
SubmitPlanConfig holds the dependencies for SubmitPlanTool.
type SubmitPlanOutput ¶
type SubmitPlanOutput struct {
PlanID string `json:"plan_id"`
Slug string `json:"slug"`
Filename string `json:"filename"`
Version int `json:"version"`
Status string `json:"status"`
Content string `json:"-"`
}
SubmitPlanOutput is the result returned to the agent.
type SubmitPlanTool ¶
type SubmitPlanTool struct {
// contains filtered or unexported fields
}
SubmitPlanTool implements submit_plan.
func NewSubmitPlanTool ¶
func NewSubmitPlanTool(config *SubmitPlanConfig) *SubmitPlanTool
func (*SubmitPlanTool) BackfillInput ¶
func (*SubmitPlanTool) Call ¶
func (t *SubmitPlanTool) Call( ctx context.Context, input tool.CallInput, _ types.CanUseToolFn, ) (tool.CallResult, error)
func (*SubmitPlanTool) CheckPermissions ¶
func (t *SubmitPlanTool) CheckPermissions(_ context.Context, _ map[string]any, _ tool.ToolUseContext) types.PermissionResult
func (*SubmitPlanTool) Definition ¶
func (t *SubmitPlanTool) Definition() tool.Definition
func (*SubmitPlanTool) Description ¶
func (t *SubmitPlanTool) Description(ctx context.Context) (string, error)
func (*SubmitPlanTool) ExecutesInPlanMode ¶
func (t *SubmitPlanTool) ExecutesInPlanMode(_ map[string]any) bool
func (*SubmitPlanTool) FormatResult ¶
func (t *SubmitPlanTool) FormatResult(data any) string
func (*SubmitPlanTool) IsConcurrencySafe ¶
func (t *SubmitPlanTool) IsConcurrencySafe(_ map[string]any) bool
func (*SubmitPlanTool) IsEnabled ¶
func (t *SubmitPlanTool) IsEnabled() bool
func (*SubmitPlanTool) IsReadOnly ¶
func (t *SubmitPlanTool) IsReadOnly(_ map[string]any) bool
func (*SubmitPlanTool) Prompt ¶
func (t *SubmitPlanTool) Prompt() string
func (*SubmitPlanTool) RequiresUserInteraction ¶
func (t *SubmitPlanTool) RequiresUserInteraction() bool