Documentation
¶
Overview ¶
Package types defines the shared wire contracts for the filesystem tools.
Index ¶
- Constants
- func ApplyEdits(content string, edits []Edit) (string, error)
- type DirectoryTreeArgs
- type DirectoryTreeMeta
- type Edit
- type EditFileArgs
- type EditFileMeta
- type ListDirectoryArgs
- type ListDirectoryMeta
- type ReadFileArgs
- type ReadFileMeta
- type ReadMultipleFilesArgs
- type ReadMultipleFilesMeta
- type SearchFilesContentArgs
- type SearchFilesContentMeta
- type WriteFileArgs
Constants ¶
View Source
const ( ToolNameReadFile = "read_file" ToolNameReadMultipleFiles = "read_multiple_files" ToolNameEditFile = "edit_file" ToolNameWriteFile = "write_file" ToolNameDirectoryTree = "directory_tree" ToolNameListDirectory = "list_directory" ToolNameSearchFilesContent = "search_files_content" ToolNameMkdir = "create_directory" ToolNameRmdir = "remove_directory" )
View Source
const MaxEditFileMetaBytes = 256 * 1024
MaxEditFileMetaBytes leaves room for the event envelope and textual output in SSE frames.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DirectoryTreeArgs ¶
type DirectoryTreeArgs struct {
Path string `json:"path" jsonschema:"Directory to traverse"`
}
type DirectoryTreeMeta ¶
type EditFileArgs ¶
type EditFileArgs struct {
Path string `json:"path" jsonschema:"File to edit"`
Edits []Edit `json:"edits" jsonschema:"Edits to apply"`
}
func ParseEditFileArgs ¶
func ParseEditFileArgs(data []byte) (EditFileArgs, error)
ParseEditFileArgs parses LLM-generated edit_file arguments, handling two common failure modes:
- The outer JSON itself is malformed — typically extra closing braces/brackets or stray escape sequences caused by the model losing track of nesting depth when the text payload contains structural characters (e.g. YAML, Dockerfiles).
- The "edits" field is double-serialized (a JSON string instead of an array).
type EditFileMeta ¶ added in v1.162.0
type EditFileMeta struct {
Path string `json:"path"`
Hunks []*udiff.Hunk `json:"hunks"`
Added int `json:"added"`
Removed int `json:"removed"`
Truncated bool `json:"truncated,omitempty"`
}
EditFileMeta records the file change at execution time, independently of later edits.
func DecodeEditFileMeta ¶ added in v1.162.0
func DecodeEditFileMeta(value any) (EditFileMeta, bool)
DecodeEditFileMeta accepts both in-process metadata and JSON-decoded session/API results.
func NewEditFileMeta ¶ added in v1.162.0
func NewEditFileMeta(path, before, after string) (EditFileMeta, error)
type ListDirectoryArgs ¶
type ListDirectoryArgs struct {
Path string `json:"path" jsonschema:"Directory to list"`
}
type ListDirectoryMeta ¶
type ReadFileArgs ¶
type ReadFileArgs struct {
Path string `json:"path" jsonschema:"File to read"`
// Line and Limit are pointers so an omitted value is distinguishable
// from an explicit (invalid) zero.
Line *int `json:"line,omitempty" jsonschema:"1-based line number to start reading from (text files only; defaults to the first line)"`
Limit *int `` /* 134-byte string literal not displayed */
}
type ReadFileMeta ¶
type ReadMultipleFilesArgs ¶
type ReadMultipleFilesMeta ¶
type ReadMultipleFilesMeta struct {
Files []ReadFileMeta `json:"files"`
}
type SearchFilesContentArgs ¶
type SearchFilesContentArgs struct {
Path string `json:"path" jsonschema:"Starting directory"`
Query string `json:"query" jsonschema:"Text or regex to search"`
IsRegex bool `json:"is_regex,omitempty" jsonschema:"Treat query as regex"`
ExcludePatterns []string `json:"excludePatterns,omitempty" jsonschema:"Patterns to exclude"`
}
type SearchFilesContentMeta ¶
type WriteFileArgs ¶
Click to show internal directories.
Click to hide internal directories.