read

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package read provides file reading operations with line enumeration and range support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inputs

type Inputs struct {
	// Path is the file path to read.
	Path string `json:"path" jsonschema:"required,description=Path to the file to read" validate:"required"`
	// LineStart is the starting line number (1-based index).
	LineStart int `json:"line_start,omitempty" jsonschema:"description=Starting line number (1-based index)" validate:"omitempty,min=1"`
	// LineEnd is the ending line number (inclusive).
	LineEnd int `` /* 127-byte string literal not displayed */
	// Count indicates whether to return only the total line count.
	Count bool `json:"count,omitempty" jsonschema:"description=If true, returns the total number of lines in the file" validate:"omitempty"`
}

Inputs defines the parameters for the Read tool.

type Tool

type Tool struct {
	tool.Base

	// SmallFileTokens is the token threshold below which line ranges are ignored and the full file is returned.
	// Zero uses the default (2000).
	SmallFileTokens int
	// contains filtered or unexported fields
}

Tool implements file reading with enumerated lines.

func New

func New(smallFileTokens int, lspManager *lsp.Manager, estimate func(string) int) *Tool

New creates a new Read tool with the specified small file token threshold. lspManager is optional (nil disables LSP didOpen notifications). estimate is the token estimation function.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, args map[string]any) (string, error)

Execute reads a file and returns its contents.

func (*Tool) Name

func (t *Tool) Name() string

Name returns the tool's identifier.

func (*Tool) Paths

func (t *Tool) Paths(ctx context.Context, args map[string]any) (read, write []string, err error)

Paths returns the filesystem paths this tool call will access.

func (*Tool) Post

func (t *Tool) Post(ctx context.Context, args map[string]any)

Post records that the file was read for edit-before-read enforcement.

func (*Tool) Schema

func (t *Tool) Schema() tool.Schema

Schema returns the provider-agnostic tool definition.

Jump to

Keyboard shortcuts

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