texttool

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteTextLinesArgs

type DeleteTextLinesArgs struct {
	Path              string   `json:"path"`
	MatchLines        []string `json:"matchLines"`
	BeforeLines       []string `json:"beforeLines,omitempty"`
	AfterLines        []string `json:"afterLines,omitempty"`
	ExpectedDeletions int      `json:"expectedDeletions,omitempty"` // default 1
}

type DeleteTextLinesOut

type DeleteTextLinesOut struct {
	DeletionsMade  int   `json:"deletionsMade"`
	DeletedAtLines []int `json:"deletedAtLines"` // 1-based start line of each deleted block
}

type FindTextArgs

type FindTextArgs struct {
	Path string `json:"path"`

	QueryType string `json:"queryType,omitempty"` // substring (default) | regex | lineBlock
	Query     string `json:"query,omitempty"`     // required for substring/regex

	MatchLines []string `json:"matchLines,omitempty"` // required for lineBlock

	ContextLines int `json:"contextLines,omitempty"` // default 5
	MaxMatches   int `json:"maxMatches,omitempty"`   // default 10
}

type FindTextLine

type FindTextLine struct {
	LineNumber int    `json:"lineNumber"` // 1-based
	Text       string `json:"text"`       // original line
}

type FindTextMatch

type FindTextMatch struct {
	MatchStartLine          int            `json:"matchStartLine"`          // 1-based
	MatchEndLine            int            `json:"matchEndLine"`            // 1-based
	MatchedLinesWithContext []FindTextLine `json:"matchedLinesWithContext"` // includes matched lines as well (window around match)
}

type FindTextOut

type FindTextOut struct {
	ReachedMaxMatches bool            `json:"reachedMaxMatches"`
	MatchesReturned   int             `json:"matchesReturned"`
	Matches           []FindTextMatch `json:"matches"`
}

type InsertTextLinesArgs

type InsertTextLinesArgs struct {
	Path             string   `json:"path"`
	Position         string   `json:"position,omitempty"` // default "end"
	LinesToInsert    []string `json:"linesToInsert"`
	AnchorMatchLines []string `json:"anchorMatchLines,omitempty"`
}

type InsertTextLinesOut

type InsertTextLinesOut struct {
	InsertedAtLine      int  `json:"insertedAtLine"` // 1-based, where insertion begins
	InsertedLineCount   int  `json:"insertedLineCount"`
	AnchorMatchedAtLine *int `json:"anchorMatchedAtLine,omitempty"` // 1-based start line of anchor block
}

type ReadTextRangeArgs

type ReadTextRangeArgs struct {
	Path string `json:"path"`

	StartMatchLines []string `json:"startMatchLines,omitempty"`
	EndMatchLines   []string `json:"endMatchLines,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
	EndLine       int                 `json:"endLine,omitempty"`   // 1-based
	LinesReturned int                 `json:"linesReturned"`
	Lines         []ReadTextRangeLine `json:"lines"`
}

type ReplaceTextLinesArgs

type ReplaceTextLinesArgs struct {
	Path string `json:"path"`

	MatchLines []string `json:"matchLines"`

	// Required; must contain at least one line.
	// This tool does NOT support deletion (use deletetextlines).
	ReplaceWithLines []string `json:"replaceWithLines"`

	BeforeLines []string `json:"beforeLines,omitempty"`
	AfterLines  []string `json:"afterLines,omitempty"`

	// Pointer is used so we can distinguish "omitted" (default to 1) from "explicit 0" (error).
	ExpectedReplacements *int `json:"expectedReplacements,omitempty"` // default 1; minimum 1
}

type ReplaceTextLinesOut

type ReplaceTextLinesOut struct {
	ReplacementsMade int   `json:"replacementsMade"`
	ReplacedAtLines  []int `json:"replacedAtLines"` // 1-based start line of each replacement
}

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) DeleteTextLines added in v0.7.0

func (tt *TextTool) DeleteTextLines(ctx context.Context, args DeleteTextLinesArgs) (*DeleteTextLinesOut, error)

func (*TextTool) DeleteTextLinesTool added in v0.7.0

func (tt *TextTool) DeleteTextLinesTool() 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) InsertTextLines added in v0.7.0

func (tt *TextTool) InsertTextLines(ctx context.Context, args InsertTextLinesArgs) (*InsertTextLinesOut, error)

func (*TextTool) InsertTextLinesTool added in v0.7.0

func (tt *TextTool) InsertTextLinesTool() 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) ReplaceTextLines added in v0.7.0

func (tt *TextTool) ReplaceTextLines(ctx context.Context, args ReplaceTextLinesArgs) (*ReplaceTextLinesOut, error)

func (*TextTool) ReplaceTextLinesTool added in v0.7.0

func (tt *TextTool) ReplaceTextLinesTool() 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