read

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package read implements the read tool: read file or list directory. One stat call branches on type. Binary files are refused with a clear msg.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() tools.Tool

New returns a fresh read tool with package-default limits (2000 default, 10000 max). Used by non-tiny profiles.

func NewWithLimits

func NewWithLimits(def, max int) tools.Tool

NewWithLimits returns a read tool with custom default/max line caps. Tiny profile passes 100/500 so one read can't torch a 4-8k local-model context.

Types

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool is the read tool. Holds a per-tool (= per-Engine, in practice) cache so repeated reads of unchanged files within one session return a stub instead of replaying the body. defaultLines/maxLines override the package defaults; zero falls back to the package constants.

func (*Tool) Run

func (t *Tool) Run(ctx context.Context, input map[string]any) (tools.Result, error)

Run dispatches to file or directory handling.

func (*Tool) Spec

func (t *Tool) Spec() llm.ToolSpec

Spec advertises the tool to the model. defaultLines/maxLines values are rendered into the limit description so tiny-profile models learn the actual ceiling (was hardcoded "Default 2000" — wrong for tiny, which caps at 500 with default 100).

Jump to

Keyboard shortcuts

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