filereadtool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package filereadtool implements the FileRead tool — reads a file from the local filesystem and returns its contents with line numbers. Mirrors src/tools/FileReadTool/FileReadTool.ts.

M2 scope: text files only (UTF-8), line-number prefix, offset/limit pagination, binary-file detection, max read size (MaxReadBytes). PDF, image, and skills side-effects land in later milestones.

Index

Constants

View Source
const MaxLines = 2000

MaxLines is the maximum number of lines we'll return when no limit is specified (avoids blowing up context on huge files).

View Source
const MaxReadBytes = 2 * 1024 * 1024

MaxReadBytes is the maximum file size we'll read in one call.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	FilePath string `json:"file_path"`
	Offset   int    `json:"offset,omitempty"` // 1-indexed line number to start reading from
	Limit    int    `json:"limit,omitempty"`  // number of lines to read
}

Input is the typed view of the JSON input.

type Tool

type Tool struct{}

Tool implements the Read tool.

func New

func New() *Tool

New returns a fresh FileRead tool.

func (*Tool) Description

func (*Tool) Description() string

Description is the prompt text the model sees.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)

Execute reads the file and returns its contents with line numbers.

func (*Tool) InputSchema

func (*Tool) InputSchema() json.RawMessage

InputSchema is the JSON Schema sent to the model.

func (*Tool) IsConcurrencySafe

func (*Tool) IsConcurrencySafe(json.RawMessage) bool

IsConcurrencySafe: reads are safe to run concurrently.

func (*Tool) IsReadOnly

func (*Tool) IsReadOnly(json.RawMessage) bool

IsReadOnly: reading a file is always read-only.

func (*Tool) Name

func (*Tool) Name() string

Name implements tool.Tool.

Jump to

Keyboard shortcuts

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