Documentation
¶
Index ¶
- Constants
- type GitDiff
- type StructuredPatchHunk
- type Tool
- func (e *Tool) BackfillInput(ctx context.Context, input map[string]any) map[string]any
- func (e *Tool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)
- func (e *Tool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
- func (e *Tool) Definition() tool.Definition
- func (e *Tool) Description(ctx context.Context) (string, error)
- func (e *Tool) FormatResult(data any) string
- func (e *Tool) GetWorkingDir() string
- func (e *Tool) IsConcurrencySafe(input map[string]any) bool
- func (e *Tool) IsEnabled() bool
- func (e *Tool) IsReadOnly(input map[string]any) bool
- func (e *Tool) SetWorkingDir(dir string)
- func (e *Tool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)
Constants ¶
const ( // ToolName is the name of the edit tool ToolName = "edit_file" // ToolDescription is the description of the edit tool ToolDescription = "Edit an existing file by replacing an exact string with a new one. The canonical tool for all partial modifications to existing files.\n\n" + "## When to use\n\n" + "- Modifying any part of an existing file: function bodies, config values, imports, constants\n" + "- Renaming a symbol across a file (use replace_all)\n" + "- Any edit where you are changing less than the whole file\n\n" + "## When NOT to use\n\n" + "- Complete file rewrites — use FileWrite instead\n" + "- Creating a new file — use FileWrite instead\n\n" + "## Rules\n\n" + "- You must read the file with FileRead before editing. This tool errors if you have not read the file first.\n" + "- Match indentation exactly as it appears in the file (tabs vs. spaces). Never include line-number prefixes from Read output in old_string or new_string.\n" + "- old_string must be unique in the file. If it appears more than once, provide more surrounding lines for context, or use replace_all.\n" + "- Use replace_all to rename a variable or string across the entire file.\n" + "- Use the smallest old_string that is clearly unique — 2–4 adjacent lines is usually enough.\n" )
const SearchHint = "edit text in a file by finding and replacing strings"
SearchHint is a hint for tool search functionality.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StructuredPatchHunk ¶
type StructuredPatchHunk struct {
OldStart int `json:"oldStart"`
OldLines int `json:"oldLines"`
NewStart int `json:"newStart"`
NewLines int `json:"newLines"`
Lines []string `json:"lines"`
}
StructuredPatchHunk represents a single structured diff hunk.
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool implements the edit file tool
func NewEditTool ¶
NewEditTool creates a new edit file tool
func (*Tool) BackfillInput ¶
BackfillInput enriches a shallow clone of the parsed input with derived fields.
func (*Tool) Call ¶
func (e *Tool) Call( ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn, ) (tool.CallResult, error)
Call executes the tool
func (*Tool) CheckPermissions ¶
func (e *Tool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
CheckPermissions performs edit-specific permission checks before the global pipeline.
func (*Tool) Definition ¶
func (e *Tool) Definition() tool.Definition
Definition returns the tool definition
func (*Tool) Description ¶
Description returns the tool description
func (*Tool) FormatResult ¶
FormatResult serialises the tool output into the tool_result content string.
func (*Tool) GetWorkingDir ¶
GetWorkingDir returns the current working directory
func (*Tool) IsConcurrencySafe ¶
IsConcurrencySafe reports that edits are not safe to run concurrently.
func (*Tool) IsReadOnly ¶
IsReadOnly reports that edits modify state.
func (*Tool) SetWorkingDir ¶
SetWorkingDir sets the working directory for the tool