Documentation
¶
Index ¶
- type ApplyUnifiedDiffArgs
- type ApplyUnifiedDiffFileOut
- type ApplyUnifiedDiffFileTarget
- type ApplyUnifiedDiffOut
- type ApplyUnifiedDiffStatus
- type ApplyUnifiedDiffSummary
- type DeleteTextArgs
- type DeleteTextOut
- type FindTextArgs
- type FindTextLine
- type FindTextMatch
- type FindTextOut
- type InsertTextArgs
- type InsertTextOut
- type ReadTextRangeArgs
- type ReadTextRangeLine
- type ReadTextRangeOut
- type ReplaceTextArgs
- type ReplaceTextOut
- type TextTool
- func (tt *TextTool) ApplyUnifiedDiff(ctx context.Context, args ApplyUnifiedDiffArgs) (*ApplyUnifiedDiffOut, error)
- func (tt *TextTool) ApplyUnifiedDiffTool() spec.Tool
- func (tt *TextTool) DeleteText(ctx context.Context, args DeleteTextArgs) (*DeleteTextOut, error)
- func (tt *TextTool) DeleteTextTool() spec.Tool
- func (tt *TextTool) FindText(ctx context.Context, args FindTextArgs) (*FindTextOut, error)
- func (tt *TextTool) FindTextTool() spec.Tool
- func (tt *TextTool) InsertText(ctx context.Context, args InsertTextArgs) (*InsertTextOut, error)
- func (tt *TextTool) InsertTextTool() spec.Tool
- func (tt *TextTool) ReadTextRange(ctx context.Context, args ReadTextRangeArgs) (*ReadTextRangeOut, error)
- func (tt *TextTool) ReadTextRangeTool() spec.Tool
- func (tt *TextTool) ReplaceText(ctx context.Context, args ReplaceTextArgs) (*ReplaceTextOut, error)
- func (tt *TextTool) ReplaceTextTool() spec.Tool
- type TextToolOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyUnifiedDiffArgs ¶ added in v0.21.0
type ApplyUnifiedDiffArgs struct {
DiffText string `json:"diffText"`
// Default false. If true, only checks and returns reusable FileTargets.
DryRun bool `json:"dryRun,omitempty"`
// Default false. If true, disables fuzzy matching.
Strict bool `json:"strict,omitempty"`
// Optional explicit path mappings.
FileTargets []ApplyUnifiedDiffFileTarget `json:"fileTargets,omitempty"`
// Optional local paths to consider when diff paths do not resolve.
CandidatePaths []string `json:"candidatePaths,omitempty"`
}
type ApplyUnifiedDiffFileOut ¶ added in v0.21.0
type ApplyUnifiedDiffFileOut struct {
OK bool `json:"ok"`
FileKey string `json:"fileKey"`
OldPath string `json:"oldPath,omitempty"`
NewPath string `json:"newPath,omitempty"`
TargetPath string `json:"targetPath,omitempty"`
ResolvedPath string `json:"resolvedPath,omitempty"`
Status ApplyUnifiedDiffStatus `json:"status"`
Message string `json:"message,omitempty"`
CandidatePaths []string `json:"candidatePaths,omitempty"`
Diagnostics []string `json:"diagnostics,omitempty"`
Hunks int `json:"hunks"`
AppliedHunks int `json:"appliedHunks"`
AlreadyAppliedHunks int `json:"alreadyAppliedHunks"`
AddedLines int `json:"addedLines"`
DeletedLines int `json:"deletedLines"`
}
type ApplyUnifiedDiffFileTarget ¶ added in v0.21.0
type ApplyUnifiedDiffOut ¶ added in v0.21.0
type ApplyUnifiedDiffOut struct {
OK bool `json:"ok"`
DryRun bool `json:"dryRun"`
Status ApplyUnifiedDiffStatus `json:"status"`
Message string `json:"message,omitempty"`
Diagnostics []string `json:"diagnostics,omitempty"`
Summary ApplyUnifiedDiffSummary `json:"summary"`
// Reusable as ApplyUnifiedDiffArgs.FileTargets.
FileTargets []ApplyUnifiedDiffFileTarget `json:"fileTargets,omitempty"`
Files []ApplyUnifiedDiffFileOut `json:"files,omitempty"`
}
type ApplyUnifiedDiffStatus ¶ added in v0.21.0
type ApplyUnifiedDiffStatus string
const ( ApplyUnifiedDiffStatusApplicable ApplyUnifiedDiffStatus = "applicable" ApplyUnifiedDiffStatusApplied ApplyUnifiedDiffStatus = "applied" ApplyUnifiedDiffStatusAlreadyApplied ApplyUnifiedDiffStatus = "already_applied" ApplyUnifiedDiffStatusNeedsInfo ApplyUnifiedDiffStatus = "needs_info" ApplyUnifiedDiffStatusConflict ApplyUnifiedDiffStatus = "conflict" ApplyUnifiedDiffStatusError ApplyUnifiedDiffStatus = "error" )
type ApplyUnifiedDiffSummary ¶ added in v0.21.0
type DeleteTextArgs ¶ added in v0.17.0
type DeleteTextArgs struct {
Path string `json:"path"`
// Required. Nil means omitted. Must not be the empty string.
OldText *string `json:"oldText"`
// Optional. Must not be the empty string if provided.
TextAbove *string `json:"textAbove,omitempty"`
// Optional. Must not be the empty string if provided.
TextBelow *string `json:"textBelow,omitempty"`
// Optional 1-based hint for the start line of oldText.
// May only be used when ExpectedCount is omitted or 1.
LineHint *int `json:"lineHint,omitempty"`
// Default 1.
ExpectedCount *int `json:"expectedCount,omitempty"`
}
type DeleteTextOut ¶ added in v0.17.0
type FindTextArgs ¶
type FindTextArgs struct {
Path string `json:"path"`
QueryType string `json:"queryType,omitempty"` // substring (default) | regex
Query string `json:"query"` // required, may contain newlines
ContextLines int `json:"contextLines,omitempty"` // default 1, effective min 1
MaxMatches int `json:"maxMatches,omitempty"` // default 10
}
type FindTextLine ¶
type FindTextMatch ¶
type FindTextMatch struct {
MatchStartLine int `json:"matchStartLine"` // 1-based
MatchStartColumn int `json:"matchStartColumn"` // 1-based UTF-8 rune column, inclusive
MatchEndLine int `json:"matchEndLine"` // 1-based
MatchEndColumn int `json:"matchEndColumn"` // 1-based UTF-8 rune column, exclusive
Context []FindTextLine `json:"context,omitempty"` // includes matched lines as well
}
type FindTextOut ¶
type FindTextOut struct {
ReachedMaxMatches bool `json:"reachedMaxMatches"`
AdditionalMatchesOmitted int `json:"additionalMatchesOmitted,omitempty"`
MatchesReturned int `json:"matchesReturned"`
Matches []FindTextMatch `json:"matches"`
}
type InsertTextArgs ¶ added in v0.17.0
type InsertTextOut ¶ added in v0.17.0
type InsertTextOut struct {
InsertedAtLine int `json:"insertedAtLine"` // 1-based, where insertion begins
InsertedLineCount int `json:"insertedLineCount"`
TextAboveMatchedAtLine *int `json:"textAboveMatchedAtLine,omitempty"` // 1-based start line of the matched textAbove boundary block used in the original file
TextBelowMatchedAtLine *int `json:"textBelowMatchedAtLine,omitempty"` // 1-based start line of the matched textBelow boundary block used in the original file
}
type ReadTextRangeArgs ¶
type ReadTextRangeLine ¶
type ReadTextRangeOut ¶
type ReadTextRangeOut struct {
StartLine int `json:"startLine,omitempty"` // 1-based; zero for empty output
EndLine int `json:"endLine,omitempty"` // 1-based; zero for empty output
LinesReturned int `json:"linesReturned"`
Lines []ReadTextRangeLine `json:"lines"`
EOFReached bool `json:"eofReached"` // true if returned range reaches EOF
}
type ReplaceTextArgs ¶ added in v0.17.0
type ReplaceTextArgs struct {
Path string `json:"path"`
// Required. Nil means omitted. Must not be the empty string.
OldText *string `json:"oldText"`
// Required. Nil means omitted. Must not be the empty string.
NewText *string `json:"newText"`
// Optional. Must not be the empty string if provided.
TextAbove *string `json:"textAbove,omitempty"`
// Optional. Must not be the empty string if provided.
TextBelow *string `json:"textBelow,omitempty"`
// Optional 1-based hint for the start line of oldText.
// May only be used when ExpectedCount is omitted or 1.
LineHint *int `json:"lineHint,omitempty"`
// Default 1.
ExpectedCount *int `json:"expectedCount,omitempty"`
}
type ReplaceTextOut ¶ added in v0.17.0
type TextTool ¶ added in v0.7.0
type TextTool struct {
// contains filtered or unexported fields
}
TextTool is an instance-owned text tool runner. It centralizes path resolution and sandbox policy:
- workBaseDir: base for resolving relative paths
- allowedRoots: optional restriction; if empty/nil, allow all
- blockSymlinks: blocks symlink traversal (if enforced downstream).
func NewTextTool ¶ added in v0.7.0
func NewTextTool(opts ...TextToolOption) (*TextTool, error)
func (*TextTool) ApplyUnifiedDiff ¶ added in v0.21.0
func (tt *TextTool) ApplyUnifiedDiff(ctx context.Context, args ApplyUnifiedDiffArgs) (*ApplyUnifiedDiffOut, error)
func (*TextTool) ApplyUnifiedDiffTool ¶ added in v0.21.0
func (*TextTool) DeleteText ¶ added in v0.17.0
func (tt *TextTool) DeleteText(ctx context.Context, args DeleteTextArgs) (*DeleteTextOut, error)
func (*TextTool) DeleteTextTool ¶ added in v0.17.0
func (*TextTool) FindText ¶ added in v0.7.0
func (tt *TextTool) FindText(ctx context.Context, args FindTextArgs) (*FindTextOut, error)
func (*TextTool) FindTextTool ¶ added in v0.7.0
func (*TextTool) InsertText ¶ added in v0.17.0
func (tt *TextTool) InsertText(ctx context.Context, args InsertTextArgs) (*InsertTextOut, error)
func (*TextTool) InsertTextTool ¶ added in v0.17.0
func (*TextTool) ReadTextRange ¶ added in v0.7.0
func (tt *TextTool) ReadTextRange(ctx context.Context, args ReadTextRangeArgs) (*ReadTextRangeOut, error)
func (*TextTool) ReadTextRangeTool ¶ added in v0.7.0
func (*TextTool) ReplaceText ¶ added in v0.17.0
func (tt *TextTool) ReplaceText(ctx context.Context, args ReplaceTextArgs) (*ReplaceTextOut, error)
func (*TextTool) ReplaceTextTool ¶ added in v0.17.0
type TextToolOption ¶ added in v0.7.0
func WithAllowedRoots ¶ added in v0.7.0
func WithAllowedRoots(roots []string) TextToolOption
func WithBlockSymlinks ¶ added in v0.10.0
func WithBlockSymlinks(block bool) TextToolOption
WithBlockSymlinks configures whether symlink traversal should be blocked (if supported downstream).
func WithWorkBaseDir ¶ added in v0.7.0
func WithWorkBaseDir(base string) TextToolOption
Click to show internal directories.
Click to hide internal directories.