texttool

package
v0.20.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 DeleteTextOut struct {
	DeletionsMade  int   `json:"deletionsMade"`
	DeletedAtLines []int `json:"deletedAtLines"` // 1-based start lines of deleted blocks
}

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 FindTextLine struct {
	LineNumber int    `json:"lineNumber"` // 1-based
	Text       string `json:"text"`       // original line, without trailing newline
}

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 InsertTextArgs struct {
	Path      string  `json:"path"`
	Text      *string `json:"text"`
	Position  string  `json:"position"`
	TextAbove *string `json:"textAbove,omitempty"`
	TextBelow *string `json:"textBelow,omitempty"`
	LineHint  *int    `json:"lineHint,omitempty"`
}

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 ReadTextRangeArgs struct {
	Path string `json:"path"`

	// Optional 1-based start line. Defaults to 1.
	StartLine *int `json:"startLine,omitempty"`

	// Optional number of lines to return. Defaults to defaultReadTextRangeLineCount.
	LineCount *int `json:"lineCount,omitempty"`
}

type ReadTextRangeLine

type ReadTextRangeLine struct {
	LineNumber int    `json:"lineNumber"` // 1-based
	Text       string `json:"text"`       // original file line (not trimmed)
}

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 ReplaceTextOut struct {
	ReplacementsMade int   `json:"replacementsMade"`
	ReplacedAtLines  []int `json:"replacedAtLines"` // 1-based start lines of replaced blocks
}

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) 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 (tt *TextTool) DeleteTextTool() spec.Tool

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 (tt *TextTool) FindTextTool() spec.Tool

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 (tt *TextTool) InsertTextTool() spec.Tool

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 (tt *TextTool) ReadTextRangeTool() spec.Tool

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

func (tt *TextTool) ReplaceTextTool() spec.Tool

type TextToolOption added in v0.7.0

type TextToolOption func(*TextTool) error

func WithAllowedRoots added in v0.7.0

func WithAllowedRoots(roots []string) TextToolOption
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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL