tools

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package tools implements deepseekcode's built-in tool surface.

The 12 v0.1 tools live here. MCP-provided tools are bridged into the same Tool interface by internal/mcp so callers see one homogeneous registry.

Schema serialization is deterministic (sorted JSON-Schema keys), which matters because every byte of tool JSON ends up in the prompt prefix and stable bytes are what makes the API-side prompt cache fire.

Index

Constants

View Source
const DefaultMaxResultBytes = 50000

DefaultMaxResultBytes is the upper bound on tool-result Content length fed back to the model. Results exceeding this are truncated by the agent loop so that a single tool call cannot flood the context window.

Variables

This section is empty.

Functions

func ClassifySandboxBlocked

func ClassifySandboxBlocked(sb sandbox.Sandbox, output string) (blocked bool, body string)

ClassifySandboxBlocked is the exported form used by the agent package for background jobs, whose process runner lives outside internal/tools.

func ClosestMatch

func ClosestMatch(needle string, haystack []string, maxDist int) (idx, dist int)

ClosestMatch finds the element in haystack whose line-level distance to needle is smallest. Returns (-1, maxDist+1) if no element is within maxDist.

func DeriveNewContents

func DeriveNewContents(path string, chunks []UpdateChunk, original string) (string, error)

DeriveNewContents applies update chunks to original, returning the new content. Each chunk's OldLines is located in the original via 4-pass fuzzy matching (exact → rstrip → trim → collapse-whitespace). A chunk with empty OldLines is a pure insertion.

func LevenshteinLines

func LevenshteinLines(a, b []string) int

LevenshteinLines computes the line-level Levenshtein distance between a and b. Each element is treated as an atomic token, so the cost is O(len(a)*len(b)).

func MustParams

func MustParams(v any) json.RawMessage

MustParams marshals v to JSON and panics on error. Tools call this from their Parameters() method on a Go struct literal, which can't fail in practice. Keeps each tool definition readable.

func RegisterBuiltins

func RegisterBuiltins(r *Registry, maxReadBytes, maxWriteBytes int64, cwd string)

RegisterBuiltins installs the v0.1 core built-in tools into a fresh Registry. Tools are added in alphabetical order out of habit; the registry sorts on AsLLMTools regardless.

Git tools are registered separately by internal/tools/git so callers can opt out (e.g. the validator pro-side tool list, which is empty).

func RegisterBuiltinsWithSandbox

func RegisterBuiltinsWithSandbox(r *Registry, maxReadBytes, maxWriteBytes int64, cwd string, sb sandbox.Sandbox, profile sandbox.Profile)

func RegisterCodegraphTools added in v0.4.0

func RegisterCodegraphTools(reg *Registry, idx *codegraph.Index)

RegisterCodegraphTools registers all five codegraph tools into reg as TierLazy, matching the pattern used by other index-backed on-demand tools (e.g. struct_search). Call this after creating the Index and before starting the agent loop.

func RegisterMemoryTools added in v0.4.0

func RegisterMemoryTools(r *Registry, store memory.Store)

RegisterMemoryTools installs the remember/recall/forget tools backed by the given Store. This is a separate helper so callers that manage their own memory store (e.g. the agent session) have a single, discoverable registration point.

func ResolveAndCheck

func ResolveAndCheck(raw, cwd string) (string, error)

ResolveAndCheck returns the canonicalized absolute path (symlinks resolved). It rejects paths that escape cwd via symlink traversal. Both cwd and the target path are fully resolved before comparison.

func RunPTYForJob

func RunPTYForJob(ctx context.Context, command string, timeout time.Duration, appender OutputAppender) (string, int, error)

RunPTYForJob runs a command via PTY and appends output to the provided OutputAppender. This is used by the agent for background_bash with pty=true. The appender's AppendOutput method is called with output chunks as they are produced.

func RunPTYForJobWithSandbox

func RunPTYForJobWithSandbox(ctx context.Context, command string, timeout time.Duration, appender OutputAppender, sb sandbox.Sandbox, profile sandbox.Profile) (string, int, error)

Types

type ApplyPatchTool

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

func NewApplyPatchTool

func NewApplyPatchTool(cwd string, maxWriteBytes int64) *ApplyPatchTool

func (*ApplyPatchTool) AffectedPaths

func (t *ApplyPatchTool) AffectedPaths(args json.RawMessage) []string

func (*ApplyPatchTool) Description

func (*ApplyPatchTool) Description() string

func (*ApplyPatchTool) Execute

func (t *ApplyPatchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*ApplyPatchTool) Name

func (*ApplyPatchTool) Name() string

func (*ApplyPatchTool) Parameters

func (*ApplyPatchTool) Parameters() json.RawMessage

type BackgroundBashTool

type BackgroundBashTool struct {
	Sandbox        sandbox.Sandbox
	SandboxProfile sandbox.Profile
	CWD            string
	// contains filtered or unexported fields
}

BackgroundBashTool runs a shell command in the background and returns immediately.

func NewBackgroundBashTool

func NewBackgroundBashTool(c JobController) *BackgroundBashTool

NewBackgroundBashTool creates a BackgroundBashTool backed by the given controller.

func NewBackgroundBashToolWithSandbox

func NewBackgroundBashToolWithSandbox(c JobController, sb sandbox.Sandbox, profile sandbox.Profile, cwd string) *BackgroundBashTool

NewBackgroundBashToolWithSandbox creates a background bash tool that passes sandbox settings to the job controller before the child process starts.

func (*BackgroundBashTool) Description

func (*BackgroundBashTool) Description() string

func (*BackgroundBashTool) Execute

func (t *BackgroundBashTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*BackgroundBashTool) IsReadOnly

func (*BackgroundBashTool) IsReadOnly() bool

IsReadOnly returns false - background_bash can modify the filesystem.

func (*BackgroundBashTool) Name

func (*BackgroundBashTool) Name() string

func (*BackgroundBashTool) Parameters

func (*BackgroundBashTool) Parameters() json.RawMessage

type Bash

type Bash struct {
	Sandbox        sandbox.Sandbox
	SandboxProfile sandbox.Profile
	CWD            string
}

Bash runs a single shell command in the user's default shell. The permission layer must vet `command` before we ever get here.

We always run via the shell rather than parsing the command ourselves because the model is going to write `command1 | grep foo && command2` constantly and we don't want to reimplement the shell.

func (Bash) AffectedPaths

func (Bash) AffectedPaths(args json.RawMessage) []string

AffectedPaths returns nil — bash effects are unknown statically. The snapshot manager handles bash by snapshotting the whole working tree (bounded) when a destructive bash pattern matches.

func (Bash) Description

func (Bash) Description() string

func (Bash) Execute

func (b Bash) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (Bash) Name

func (Bash) Name() string

func (Bash) Parameters

func (Bash) Parameters() json.RawMessage

type BashIntent

type BashIntent int

BashIntent classifies a bash command's risk level.

const (
	BashRead        BashIntent = iota // read-only: ls, cat, grep, git status, etc.
	BashSafe                          // safe-mutating: mkdir, touch, git add/commit, etc.
	BashDestructive                   // destructive: rm, git push --force, sed -i, etc.
	BashUnknown                       // unclear or complex: conservatively treated as ask
)

func ClassifyBash

func ClassifyBash(command string) BashIntent

ClassifyBash categorizes a bash command by intent. It uses a simple first-token heuristic with special handling for subcommands and pipes. For pipe/&&/|| chains, the strictest intent wins.

func (BashIntent) String

func (i BashIntent) String() string

type BashPTY

type BashPTY struct {
	Sandbox        sandbox.Sandbox
	SandboxProfile sandbox.Profile
	CWD            string
}

BashPTY runs a shell command inside a pseudo-terminal (PTY). Use when a command requires a TTY (interactive prompts disabled, color/curses output).

func (BashPTY) AffectedPaths

func (BashPTY) AffectedPaths(args json.RawMessage) []string

AffectedPaths returns nil — bash_pty effects are unknown statically.

func (BashPTY) Description

func (BashPTY) Description() string

func (BashPTY) Execute

func (b BashPTY) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (BashPTY) Name

func (BashPTY) Name() string

func (BashPTY) Parameters

func (BashPTY) Parameters() json.RawMessage

type CheckpointRecorder added in v0.4.0

type CheckpointRecorder interface {
	// RecordCheckpoint names the current step. Returns the step index recorded.
	RecordCheckpoint(name string) int
}

CheckpointRecorder is the narrow callback the CheckpointTool uses. Implemented by *agent.Agent via a thin wrapper to avoid import cycles.

type CheckpointTool added in v0.4.0

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

CheckpointTool lets the model name the current agent step so sessions can be resumed or branched from that point by name.

func NewCheckpointTool added in v0.4.0

func NewCheckpointTool(rec CheckpointRecorder) *CheckpointTool

NewCheckpointTool creates a CheckpointTool backed by rec.

func (*CheckpointTool) Description added in v0.4.0

func (*CheckpointTool) Description() string

func (*CheckpointTool) Execute added in v0.4.0

func (t *CheckpointTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*CheckpointTool) IsReadOnly added in v0.4.0

func (*CheckpointTool) IsReadOnly() bool

IsReadOnly returns false: recording a checkpoint writes to the agent's CheckpointIndex, which is an agent-state mutation even though no files are touched. The repair module's ToolMutating default applies here.

func (*CheckpointTool) Name added in v0.4.0

func (*CheckpointTool) Name() string

func (*CheckpointTool) Parameters added in v0.4.0

func (*CheckpointTool) Parameters() json.RawMessage

type CodegraphCalleesTool added in v0.4.0

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

CodegraphCalleesTool implements Tool for codegraph_callees.

func NewCodegraphCalleesTool added in v0.4.0

func NewCodegraphCalleesTool(idx *codegraph.Index) *CodegraphCalleesTool

func (*CodegraphCalleesTool) Description added in v0.4.0

func (t *CodegraphCalleesTool) Description() string

func (*CodegraphCalleesTool) Execute added in v0.4.0

func (t *CodegraphCalleesTool) Execute(ctx context.Context, params json.RawMessage) (Result, error)

func (*CodegraphCalleesTool) IsReadOnly added in v0.4.0

func (t *CodegraphCalleesTool) IsReadOnly() bool

func (*CodegraphCalleesTool) Name added in v0.4.0

func (t *CodegraphCalleesTool) Name() string

func (*CodegraphCalleesTool) Parameters added in v0.4.0

func (t *CodegraphCalleesTool) Parameters() json.RawMessage

type CodegraphCallersTool added in v0.4.0

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

CodegraphCallersTool implements Tool for codegraph_callers.

func NewCodegraphCallersTool added in v0.4.0

func NewCodegraphCallersTool(idx *codegraph.Index) *CodegraphCallersTool

func (*CodegraphCallersTool) Description added in v0.4.0

func (t *CodegraphCallersTool) Description() string

func (*CodegraphCallersTool) Execute added in v0.4.0

func (t *CodegraphCallersTool) Execute(ctx context.Context, params json.RawMessage) (Result, error)

func (*CodegraphCallersTool) IsReadOnly added in v0.4.0

func (t *CodegraphCallersTool) IsReadOnly() bool

func (*CodegraphCallersTool) Name added in v0.4.0

func (t *CodegraphCallersTool) Name() string

func (*CodegraphCallersTool) Parameters added in v0.4.0

func (t *CodegraphCallersTool) Parameters() json.RawMessage

type CodegraphImpactTool added in v0.4.0

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

CodegraphImpactTool implements Tool for codegraph_impact.

func NewCodegraphImpactTool added in v0.4.0

func NewCodegraphImpactTool(idx *codegraph.Index) *CodegraphImpactTool

func (*CodegraphImpactTool) Description added in v0.4.0

func (t *CodegraphImpactTool) Description() string

func (*CodegraphImpactTool) Execute added in v0.4.0

func (t *CodegraphImpactTool) Execute(ctx context.Context, params json.RawMessage) (Result, error)

func (*CodegraphImpactTool) IsReadOnly added in v0.4.0

func (t *CodegraphImpactTool) IsReadOnly() bool

func (*CodegraphImpactTool) Name added in v0.4.0

func (t *CodegraphImpactTool) Name() string

func (*CodegraphImpactTool) Parameters added in v0.4.0

func (t *CodegraphImpactTool) Parameters() json.RawMessage

type CodegraphNodeTool added in v0.4.0

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

CodegraphNodeTool implements Tool for codegraph_node. It looks up a single node by its fully-qualified NodeID and returns its metadata (kind, file, line) together with the declaration snippet.

func NewCodegraphNodeTool added in v0.4.0

func NewCodegraphNodeTool(idx *codegraph.Index) *CodegraphNodeTool

NewCodegraphNodeTool creates a CodegraphNodeTool backed by idx.

func (*CodegraphNodeTool) Description added in v0.4.0

func (t *CodegraphNodeTool) Description() string

func (*CodegraphNodeTool) Execute added in v0.4.0

func (t *CodegraphNodeTool) Execute(ctx context.Context, params json.RawMessage) (Result, error)

func (*CodegraphNodeTool) IsReadOnly added in v0.4.0

func (t *CodegraphNodeTool) IsReadOnly() bool

func (*CodegraphNodeTool) Name added in v0.4.0

func (t *CodegraphNodeTool) Name() string

func (*CodegraphNodeTool) Parameters added in v0.4.0

func (t *CodegraphNodeTool) Parameters() json.RawMessage

type CodegraphSearchTool added in v0.4.0

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

CodegraphSearchTool implements Tool for codegraph_search.

func NewCodegraphSearchTool added in v0.4.0

func NewCodegraphSearchTool(idx *codegraph.Index) *CodegraphSearchTool

NewCodegraphSearchTool creates a CodegraphSearchTool backed by idx.

func (*CodegraphSearchTool) Description added in v0.4.0

func (t *CodegraphSearchTool) Description() string

func (*CodegraphSearchTool) Execute added in v0.4.0

func (t *CodegraphSearchTool) Execute(ctx context.Context, params json.RawMessage) (Result, error)

func (*CodegraphSearchTool) IsReadOnly added in v0.4.0

func (t *CodegraphSearchTool) IsReadOnly() bool

func (*CodegraphSearchTool) Name added in v0.4.0

func (t *CodegraphSearchTool) Name() string

func (*CodegraphSearchTool) Parameters added in v0.4.0

func (t *CodegraphSearchTool) Parameters() json.RawMessage

type DuckDuckGoHTML

type DuckDuckGoHTML struct {
	HTTPClient *http.Client
	// BaseURL is the endpoint URL (defaults to https://html.duckduckgo.com/html/)
	BaseURL string
}

DuckDuckGoHTML is a search provider that scrapes DuckDuckGo HTML results.

func NewDuckDuckGoHTML

func NewDuckDuckGoHTML() *DuckDuckGoHTML

NewDuckDuckGoHTML creates a DuckDuckGo HTML scraper provider.

func (*DuckDuckGoHTML) Name

func (*DuckDuckGoHTML) Name() string

func (*DuckDuckGoHTML) Search

func (d *DuckDuckGoHTML) Search(ctx context.Context, query string, limit int) ([]SearchHit, error)

type EditFile

type EditFile struct {
	CWD string // project root for path safety; empty means os.Getwd
	// Tracker, when set, rejects an edit to a file that was never read or that
	// changed on disk since the last read (T3.2). nil disables the guard.
	Tracker *FileTracker
}

EditFile is a string-replace editor. It refuses ambiguous matches so the model can't accidentally edit the wrong occurrence. If the user wants every occurrence replaced they must pass replace_all=true.

This mirrors Claude Code's Edit tool semantics, which is now the de facto standard for agent edits.

func (EditFile) AffectedPaths

func (EditFile) AffectedPaths(args json.RawMessage) []string

func (EditFile) Description

func (EditFile) Description() string

func (EditFile) Execute

func (e EditFile) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (EditFile) Name

func (EditFile) Name() string

func (EditFile) Parameters

func (EditFile) Parameters() json.RawMessage

type FileTracker

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

FileTracker records, per session, the on-disk state of files at the moment the agent last read (or wrote) them, so the write tools can reject an edit to a file that was never read or that changed underfoot — a formatter, linter, the user, or a parallel tool editing between the read and the write. It guards against silently clobbering those out-of-band changes (T3.2; mirrors Claude Code readFileState / crush filetracker / Reasonix ReadTracker).

The freshness signal is (mtime, size): every ordinary write updates mtime, so this catches the threat model cheaply with no extra file read. A change that preserves BOTH mtime and size (e.g. a deliberate mtime-restoring rewrite of equal length) is the one blind spot — acceptable for the cost.

All methods are safe for concurrent use (runToolCalls executes tools in parallel) and nil-safe: a nil *FileTracker is a no-op, so tools constructed without a tracker (unit tests) simply skip the guard and behave exactly as before.

One tracker is shared by every tool in a registry AND propagated to its Subset/TierTools/CloneForCWD derivatives, so a subagent built from the parent registry shares the parent's tracker (and its compaction Clear()). The records are keyed by canonical absolute path. Consequence: a parent and a concurrently-running async child can weaken or over-trip each other's guard when they touch the same path — a parent Clear() that wipes a child's stamp only forces a (safe) re-read, so the interaction is fail-toward-reread; it is not a data race (the mutex serializes all access).

func NewFileTracker

func NewFileTracker() *FileTracker

NewFileTracker returns an empty tracker.

func (*FileTracker) CheckFresh

func (t *FileTracker) CheckFresh(path string) error

CheckFresh returns a model-actionable error when path may not be safely written:

  • the file exists on disk but was never read this session, or
  • it exists and its (mtime, size) differ from what was recorded.

It returns nil when the file does not exist (a legitimate create) or matches the recorded stamp. nil tracker → nil (guard disabled).

func (*FileTracker) Clear

func (t *FileTracker) Clear()

Clear drops all records. Called when the conversation is compacted: once the read_file results are folded out of the live transcript the model no longer holds the files' contents, so it must re-read before editing. Clearing all records (rather than only the folded range) is intentionally conservative — compaction is rare on a 1M window, and an extra re-read is cheaper than a clobbered edit.

func (*FileTracker) RecordRead

func (t *FileTracker) RecordRead(path string)

RecordRead stamps path with its current on-disk state. Call it after a successful read so a later write can detect drift. path must be the canonical (resolved) path the write tools will also check. A stat failure (path missing/unstattable) is ignored — there is nothing to stamp.

func (*FileTracker) RecordWrite

func (t *FileTracker) RecordWrite(path string)

RecordWrite re-stamps path after a successful write so a subsequent edit in the same session sees the just-written state as fresh rather than tripping the changed-since-read guard on the agent's own edit.

type ForgetTool added in v0.4.0

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

ForgetTool removes a memory by ID.

func NewForgetTool added in v0.4.0

func NewForgetTool(store memory.Store) *ForgetTool

NewForgetTool returns a ForgetTool backed by the given Store.

func (*ForgetTool) Description added in v0.4.0

func (t *ForgetTool) Description() string

func (*ForgetTool) Execute added in v0.4.0

func (t *ForgetTool) Execute(_ context.Context, args json.RawMessage) (Result, error)

func (*ForgetTool) IsReadOnly added in v0.4.0

func (t *ForgetTool) IsReadOnly() bool

func (*ForgetTool) Name added in v0.4.0

func (t *ForgetTool) Name() string

func (*ForgetTool) Parameters added in v0.4.0

func (t *ForgetTool) Parameters() json.RawMessage

type GitBlame

type GitBlame struct{}

GitBlame returns per-line authorship for a file or range. We pass `--line-porcelain` and reformat to one line per source line:

pkg/auth/jwt.go:42  a3f1c2d Alice Bob   2025-09-01  return token, nil

This is much easier for the model to consume than git's default blame output, which interleaves metadata blocks between source lines.

func (GitBlame) Description

func (GitBlame) Description() string

func (GitBlame) Execute

func (GitBlame) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (GitBlame) IsReadOnly

func (GitBlame) IsReadOnly() bool

func (GitBlame) Name

func (GitBlame) Name() string

func (GitBlame) Parameters

func (GitBlame) Parameters() json.RawMessage

type GitDiff

type GitDiff struct{}

GitDiff returns the diff between two refs (or working tree against HEAD). Output is the raw unified diff. It's "structured" in that we keep it scoped (single path, single ref range) so the model doesn't drown in whole-repo diffs.

func (GitDiff) Description

func (GitDiff) Description() string

func (GitDiff) Execute

func (GitDiff) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (GitDiff) IsReadOnly

func (GitDiff) IsReadOnly() bool

func (GitDiff) Name

func (GitDiff) Name() string

func (GitDiff) Parameters

func (GitDiff) Parameters() json.RawMessage

type GitLog

type GitLog struct{}

GitLog returns recent commits as structured one-liners. Default 20 commits; pass `n` to override. Optional path scopes to commits that touched that file/dir; optional since (e.g. '2 weeks ago') bounds time.

func (GitLog) Description

func (GitLog) Description() string

func (GitLog) Execute

func (GitLog) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (GitLog) IsReadOnly

func (GitLog) IsReadOnly() bool

func (GitLog) Name

func (GitLog) Name() string

func (GitLog) Parameters

func (GitLog) Parameters() json.RawMessage

type GitShow

type GitShow struct{}

GitShow reads a file's content at a specific ref, or shows the content of a commit. Lets the model reason about historical state without checking out a different branch.

func (GitShow) Description

func (GitShow) Description() string

func (GitShow) Execute

func (GitShow) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (GitShow) IsReadOnly

func (GitShow) IsReadOnly() bool

func (GitShow) Name

func (GitShow) Name() string

func (GitShow) Parameters

func (GitShow) Parameters() json.RawMessage

type Glob

type Glob struct{}

Glob lists files matching a doublestar pattern. We use a small in-package matcher to keep the dependency tree thin; the patterns we support are: `*` (any chars except /), `?` (one char except /), `**` (any chars including /), and literal chars.

func (Glob) Description

func (Glob) Description() string

func (Glob) Execute

func (Glob) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (Glob) IsReadOnly

func (Glob) IsReadOnly() bool

func (Glob) Name

func (Glob) Name() string

func (Glob) Parameters

func (Glob) Parameters() json.RawMessage

type Grep

type Grep struct{}

Grep searches file contents for a regex. Shells out to ripgrep when available (much faster, respects .gitignore for free), falls back to a stdlib walker otherwise.

func (Grep) Description

func (Grep) Description() string

func (Grep) Execute

func (Grep) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (Grep) IsReadOnly

func (Grep) IsReadOnly() bool

func (Grep) Name

func (Grep) Name() string

func (Grep) Parameters

func (Grep) Parameters() json.RawMessage

type Hunk

type Hunk struct {
	Op       string        // "add" | "delete" | "update"
	Path     string        // target file path
	MovePath string        // set only when "*** Move to:" declared
	Contents string        // add: full file content (leading '+' stripped)
	Chunks   []UpdateChunk // update: ordered chunks
}

func ParsePatch

func ParsePatch(patchText string) ([]Hunk, error)

ParsePatch parses the *** Begin Patch / *** End Patch envelope into ordered hunks. Returns an error if markers are missing or lines are malformed.

type JobController

type JobController interface {
	StartBashJob(ctx context.Context, command string, usePTY bool, timeoutMs int, sb sandbox.Sandbox, profile sandbox.Profile) (jobID string, err error)
}

JobController is the narrow interface tools use to start background jobs. Implemented by *agent.Agent.

type JobStatusController

type JobStatusController interface {
	JobStatus(id string, tailLines int) (Status, error)
	CancelJob(id string) error
}

JobStatusController is the narrow interface for status queries.

type LSPRegistry

type LSPRegistry interface {
	ClientForURI(uri string) (lsp.Querier, bool)
}

LSPRegistry is the subset of lsp.Registry that the LSP tool needs.

type LSPTool

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

LSPTool exposes LSP features (hover, definition, references, diagnostics) as a single tool with an action parameter.

func NewLSPTool

func NewLSPTool(reg LSPRegistry) *LSPTool

NewLSPTool creates an LSP tool backed by the given registry.

func (LSPTool) Description

func (LSPTool) Description() string

func (*LSPTool) Execute

func (t *LSPTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (LSPTool) IsReadOnly

func (LSPTool) IsReadOnly() bool

func (LSPTool) Name

func (LSPTool) Name() string

func (LSPTool) Parameters

func (LSPTool) Parameters() json.RawMessage

type Ls

type Ls struct{}

Ls lists immediate children of a directory. No recursion — that's what glob is for. Returns a `type indicator + name` per line so the model can distinguish files, directories, and symlinks at a glance.

func (Ls) Description

func (Ls) Description() string

func (Ls) Execute

func (Ls) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (Ls) IsReadOnly

func (Ls) IsReadOnly() bool

func (Ls) Name

func (Ls) Name() string

func (Ls) Parameters

func (Ls) Parameters() json.RawMessage

type Option

type Option struct {
	Label       string `json:"label"`
	Description string `json:"description"`
}

Option is a single selectable answer for a Question.

type OutputAppender

type OutputAppender interface {
	AppendOutput(p []byte)
}

OutputAppender is an interface for appending output to a buffer. Implemented by the agent's Job type.

type PathAware

type PathAware interface {
	AffectedPaths(args json.RawMessage) []string
}

PathAware is an optional interface tools may implement to declare which filesystem paths their invocation will read or write. The snapshot manager and permissions checker both consult this. Returning nil means "no paths known statically" — bash falls into this category.

type PlanController

type PlanController interface {
	EnterPlan(ctx context.Context) error
	ExitPlan(ctx context.Context, plan string) error
}

PlanController is implemented by the agent layer. It manages the agent's plan-mode state machine (enter/exit).

type PlanEnterTool

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

PlanEnterTool transitions the agent into plan mode.

func NewPlanEnterTool

func NewPlanEnterTool(c PlanController) *PlanEnterTool

NewPlanEnterTool creates a PlanEnterTool backed by the given controller.

func (*PlanEnterTool) Description

func (*PlanEnterTool) Description() string

func (*PlanEnterTool) Execute

func (t *PlanEnterTool) Execute(ctx context.Context, _ json.RawMessage) (Result, error)

func (*PlanEnterTool) IsReadOnly

func (*PlanEnterTool) IsReadOnly() bool

func (*PlanEnterTool) Name

func (*PlanEnterTool) Name() string

func (*PlanEnterTool) Parameters

func (*PlanEnterTool) Parameters() json.RawMessage

type PlanEntry added in v0.4.0

type PlanEntry struct{ Subject, Status string }

PlanEntry is one plan entry passed to PlanPublisher. Subject and Status are the raw TodoItem fields; the caller (agent) maps them to the Contract status vocabulary (completed→done) before publishing on the bus.

type PlanExitTool

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

PlanExitTool transitions the agent out of plan mode.

func NewPlanExitTool

func NewPlanExitTool(c PlanController) *PlanExitTool

NewPlanExitTool creates a PlanExitTool backed by the given controller.

func (*PlanExitTool) Description

func (*PlanExitTool) Description() string

func (*PlanExitTool) Execute

func (t *PlanExitTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*PlanExitTool) IsReadOnly

func (*PlanExitTool) IsReadOnly() bool

func (*PlanExitTool) Name

func (*PlanExitTool) Name() string

func (*PlanExitTool) Parameters

func (*PlanExitTool) Parameters() json.RawMessage

type Question

type Question struct {
	Question string   `json:"question"`
	Header   string   `json:"header"` // ≤30 char short label
	Options  []Option `json:"options"`
	Multiple bool     `json:"multiple"` // allow multi-select
}

Question is one question the model wants to ask the user.

type QuestionRequest

type QuestionRequest struct {
	Questions []Question
}

QuestionRequest groups one or more questions to present together.

type QuestionResponse

type QuestionResponse struct {
	Answers [][]string
}

QuestionResponse carries the user's answers, aligned with QuestionRequest.Questions. Each inner slice holds the selected label strings for that question.

type QuestionTool

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

QuestionTool presents questions to the user and returns their answers.

func NewQuestionTool

func NewQuestionTool(q Questioner) *QuestionTool

NewQuestionTool creates a QuestionTool backed by the given Questioner.

func (*QuestionTool) Description

func (*QuestionTool) Description() string

func (*QuestionTool) Execute

func (t *QuestionTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*QuestionTool) IsReadOnly

func (*QuestionTool) IsReadOnly() bool

func (*QuestionTool) Name

func (*QuestionTool) Name() string

func (*QuestionTool) Parameters

func (*QuestionTool) Parameters() json.RawMessage

type Questioner

type Questioner interface {
	AskQuestion(ctx context.Context, req QuestionRequest) (QuestionResponse, error)
}

Questioner is implemented by the agent layer. AskQuestion blocks until the user answers or ctx is cancelled.

type ReadFile

type ReadFile struct {
	MaxBytes int64  // default 5_242_880 (5 MiB); 0 means use default
	MaxLines int    // whole-file read line cap; 0 means defaultWholeReadLineCap
	CWD      string // project root for path safety; empty means os.Getwd
	// Tracker, when set, records the file's on-disk state on a successful read
	// so the write tools can detect out-of-band changes before editing (T3.2).
	// nil disables the freshness guard.
	Tracker *FileTracker
}

ReadFile reads a UTF-8 text file and returns it with cat -n style line numbers. Models do better at reasoning about positions when they see numbers next to lines.

func (ReadFile) AffectedPaths

func (ReadFile) AffectedPaths(args json.RawMessage) []string

func (ReadFile) Description

func (ReadFile) Description() string

func (ReadFile) Execute

func (r ReadFile) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (ReadFile) IsReadOnly

func (ReadFile) IsReadOnly() bool

func (ReadFile) Name

func (ReadFile) Name() string

func (ReadFile) Parameters

func (ReadFile) Parameters() json.RawMessage

type ReadOnlyHint

type ReadOnlyHint interface {
	IsReadOnly() bool
}

ReadOnlyHint is an optional interface tools may implement to declare they never mutate state. The permissions package uses this to short-circuit approval prompts; tools that don't implement it default to "not read-only" (safe default).

type RecallTool added in v0.4.0

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

RecallTool retrieves relevant memories by query.

func NewRecallTool added in v0.4.0

func NewRecallTool(store memory.Store) *RecallTool

NewRecallTool returns a RecallTool backed by the given Store.

func (*RecallTool) Description added in v0.4.0

func (t *RecallTool) Description() string

func (*RecallTool) Execute added in v0.4.0

func (t *RecallTool) Execute(_ context.Context, args json.RawMessage) (Result, error)

func (*RecallTool) IsReadOnly added in v0.4.0

func (t *RecallTool) IsReadOnly() bool

func (*RecallTool) Name added in v0.4.0

func (t *RecallTool) Name() string

func (*RecallTool) Parameters added in v0.4.0

func (t *RecallTool) Parameters() json.RawMessage

type Registry

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

Registry is the set of tools available to the agent for a session.

func New

func New() *Registry

New returns an empty registry.

func NewWithStructSearch

func NewWithStructSearch(root string) *Registry

func (*Registry) All

func (r *Registry) All() []Tool

All returns all registered tools in name-sorted order. Sorting is load-bearing: the LLM request layer serializes tools in this order, and stable order maximizes prompt-cache hits across turns.

func (*Registry) AsLLMTools

func (r *Registry) AsLLMTools() []llm.Tool

AsLLMTools converts the registry contents into the llm.Tool slice the client sends to DeepSeek. Schemas are *not* canonicalized here; request.go's MarshalCacheStable handles that uniformly.

func (*Registry) AsLLMToolsFiltered

func (r *Registry) AsLLMToolsFiltered(tiers ...ToolTier) []llm.Tool

AsLLMToolsFiltered returns only tools belonging to the specified tiers, converted to llm.Tool for the wire request. Tools are name-sorted for cache stability. When no tiers are specified, all tools are returned (same as AsLLMTools).

func (*Registry) ByTier

func (r *Registry) ByTier(tier ToolTier) []Tool

ByTier returns all tools belonging to the given tier, sorted by name.

func (*Registry) CloneForCWD

func (r *Registry) CloneForCWD(cwd string) *Registry

CloneForCWD returns a new Registry where every cwd-aware tool has been cloned with its working directory rebound to cwd. Tools without a cwd dependency are shared with the original registry.

func (*Registry) FileTracker

func (r *Registry) FileTracker() *FileTracker

FileTracker returns the registry's read-before-write tracker, or nil when the registry was built without the file tools. The agent uses it to invalidate read stamps on history compaction.

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

Get returns the named tool or (nil, false).

func (*Registry) Register

func (r *Registry) Register(t Tool)

Register installs a tool. Later registrations of the same name overwrite earlier ones; intentional, so MCP can shadow a built-in if a user wants. The tier is auto-detected from the tool name.

func (*Registry) RegisterWithTier

func (r *Registry) RegisterWithTier(t Tool, tier ToolTier)

RegisterWithTier installs a tool with an explicit tier, overriding the auto-detected default.

func (*Registry) Subset

func (r *Registry) Subset(names []string) *Registry

Subset returns a new Registry containing only the tools whose names appear in names. Unknown names are silently ignored. names being nil or empty returns an empty Registry (not the full set).

func (*Registry) TierOf

func (r *Registry) TierOf(name string) (ToolTier, bool)

TierOf returns the tier for a named tool, or ("", false) if not found.

func (*Registry) TierTools

func (r *Registry) TierTools(tiers ...ToolTier) *Registry

TierTools returns a new Registry containing only tools from the specified tiers. Unknown tiers produce an empty subset.

type RememberTool added in v0.4.0

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

RememberTool stores a fact in long-term memory.

func NewRememberTool added in v0.4.0

func NewRememberTool(store memory.Store) *RememberTool

NewRememberTool returns a RememberTool backed by the given Store.

func (*RememberTool) Description added in v0.4.0

func (t *RememberTool) Description() string

func (*RememberTool) Execute added in v0.4.0

func (t *RememberTool) Execute(_ context.Context, args json.RawMessage) (Result, error)

func (*RememberTool) IsReadOnly added in v0.4.0

func (t *RememberTool) IsReadOnly() bool

func (*RememberTool) Name added in v0.4.0

func (t *RememberTool) Name() string

func (*RememberTool) Parameters added in v0.4.0

func (t *RememberTool) Parameters() json.RawMessage

type Result

type Result struct {
	Content string
	IsError bool
}

Result is what a tool returns to the model after Execute. Content is the text the model will see in the tool-result message. IsError flips the rendering and signals "the tool ran but failed."

func Errf

func Errf(format string, args ...any) Result

Errf is a convenience for "tool ran and produced an error message the model should read." Use Go's standard `error` return value for infrastructure failures the agent should retry or surface to the user.

func (Result) Truncate

func (r Result) Truncate(maxBytes int) Result

Truncate returns a copy of the Result with Content capped at maxBytes. If Content already fits, the original Result is returned unchanged. When truncation occurs the IsError flag is preserved and a footer is appended showing the original and new sizes.

type SearXNG

type SearXNG struct {
	HTTPClient *http.Client
	BaseURL    string
}

SearXNG is a search provider that uses a SearXNG JSON API.

func NewSearXNG

func NewSearXNG(baseURL string) *SearXNG

NewSearXNG creates a SearXNG provider with the given base URL.

func (*SearXNG) Name

func (*SearXNG) Name() string

func (*SearXNG) Search

func (s *SearXNG) Search(ctx context.Context, query string, limit int) ([]SearchHit, error)

type SearchHit

type SearchHit struct {
	Title   string
	URL     string
	Snippet string
}

SearchHit represents a single search result.

type SkillRead

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

SkillRead is the lazy capability dispatcher that loads a skill's full body by name. It exists so the cache-stable static prefix can carry only a short skill directory (name + short description + version_hash) instead of either the full bodies or local absolute paths. The body becomes ordinary conversation state when read, never silently mutating the prefix.

SkillRead is a stable dispatcher: its schema is small and fixed, so adding or editing skills never changes the tool list hash.

func NewSkillReadTool

func NewSkillReadTool(src SkillSource) *SkillRead

NewSkillReadTool builds a skill_read tool backed by src.

func (*SkillRead) Description

func (*SkillRead) Description() string

func (*SkillRead) Execute

func (s *SkillRead) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*SkillRead) IsReadOnly

func (*SkillRead) IsReadOnly() bool

func (*SkillRead) Name

func (*SkillRead) Name() string

func (*SkillRead) Parameters

func (*SkillRead) Parameters() json.RawMessage

type SkillSource

type SkillSource interface {
	// Body returns the full body of the named skill and true, or
	// ("", false) when the skill is unknown.
	Body(name string) (string, bool)
	// Names returns the available skill names (for helpful misses).
	Names() []string
}

SkillSource supplies skill bodies on demand. internal/skills.Store satisfies it. Kept as a tiny interface so the tools package does not depend on the skills package and the tool stays unit-testable with a fake source.

type SpawnBatchTool added in v0.4.0

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

SpawnBatchTool fans out a list of SpawnRequests concurrently on a shared Spawner, capped to maxConcurrency goroutines, then aggregates the results. It reuses the same tools.Spawner interface as SubagentTool so LoopSpawner backs it without modification.

func NewSpawnBatchTool added in v0.4.0

func NewSpawnBatchTool(s Spawner, maxConcurrency int) *SpawnBatchTool

NewSpawnBatchTool creates a SpawnBatchTool. maxConcurrency <= 0 defaults to 4.

func (*SpawnBatchTool) Description added in v0.4.0

func (*SpawnBatchTool) Description() string

func (*SpawnBatchTool) Execute added in v0.4.0

func (t *SpawnBatchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*SpawnBatchTool) IsReadOnly added in v0.4.0

func (*SpawnBatchTool) IsReadOnly() bool

func (*SpawnBatchTool) Name added in v0.4.0

func (*SpawnBatchTool) Name() string

func (*SpawnBatchTool) Parameters added in v0.4.0

func (*SpawnBatchTool) Parameters() json.RawMessage

type SpawnRequest

type SpawnRequest struct {
	Agent       string   // .deepseek/agent/<name>; empty = default generic sub-agent
	Description string   // task description for the sub-agent
	Tools       []string // optional: further restrict beyond agent def whitelist
	Async       bool     // run asynchronously; returns immediately with JobID
}

SpawnRequest describes a sub-agent task.

type SpawnResult

type SpawnResult struct {
	Summary    string
	StepCount  int
	TokenCount int
	JobID      string // set when Async=true
}

SpawnResult is the outcome of a completed sub-agent run.

type Spawner

type Spawner interface {
	Spawn(ctx context.Context, req SpawnRequest) (SpawnResult, error)
}

Spawner is implemented by the agent layer (e.g. agent.LoopSpawner).

type Status

type Status struct {
	ID           string
	Kind         string
	State        string
	StartedAt    time.Time
	FinishedAt   time.Time
	Summary      string
	Tail         string
	DroppedBytes int64
	TotalLines   int
	Truncated    bool
}

Status represents the public status of a background job.

type StructSearchTool

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

func NewStructSearchTool

func NewStructSearchTool(root string) *StructSearchTool

func (*StructSearchTool) Description

func (*StructSearchTool) Description() string

func (*StructSearchTool) Execute

func (t *StructSearchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*StructSearchTool) Name

func (*StructSearchTool) Name() string

func (*StructSearchTool) Parameters

func (*StructSearchTool) Parameters() json.RawMessage

type SubagentTool

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

SubagentTool delegates a subtask to a sub-agent.

func NewSubagentTool

func NewSubagentTool(s Spawner) *SubagentTool

NewSubagentTool creates a SubagentTool backed by the given Spawner.

func (*SubagentTool) Description

func (*SubagentTool) Description() string

func (*SubagentTool) Execute

func (t *SubagentTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*SubagentTool) IsReadOnly

func (*SubagentTool) IsReadOnly() bool

func (*SubagentTool) Name

func (*SubagentTool) Name() string

func (*SubagentTool) Parameters

func (*SubagentTool) Parameters() json.RawMessage

type TaskStatusTool

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

TaskStatusTool queries the status of a background job.

func NewTaskStatusTool

func NewTaskStatusTool(c JobStatusController) *TaskStatusTool

NewTaskStatusTool creates a TaskStatusTool backed by the given controller.

func (*TaskStatusTool) Description

func (*TaskStatusTool) Description() string

func (*TaskStatusTool) Execute

func (t *TaskStatusTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*TaskStatusTool) IsReadOnly

func (*TaskStatusTool) IsReadOnly() bool

func (*TaskStatusTool) Name

func (*TaskStatusTool) Name() string

func (*TaskStatusTool) Parameters

func (*TaskStatusTool) Parameters() json.RawMessage

type TodoItem

type TodoItem struct {
	Subject    string `json:"subject"`
	Status     string `json:"status"` // pending | in_progress | completed
	ActiveForm string `json:"active_form,omitempty"`
}

TodoItem mirrors the schema we expose to the model.

type TodoWrite

type TodoWrite struct {

	// PlanPublisher, when set, is called with a copy of the new plan whenever the
	// list is replaced. The agent sets this to publish EventPlanUpdate on its bus.
	// Items are (subject, status) pairs in the raw TodoItem vocabulary; the agent
	// performs the completed→done mapping before publishing.
	PlanPublisher func([]PlanEntry)
	// contains filtered or unexported fields
}

TodoWrite manages the session's structured plan. The TUI renders the active list inline; the agent reads it back to keep itself on track.

Plan state is per-process (session) only. We don't persist across resume in v0.1 — the model can regenerate the plan from the conversation if it needs to.

func (*TodoWrite) Description

func (t *TodoWrite) Description() string

func (*TodoWrite) Execute

func (t *TodoWrite) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*TodoWrite) Name

func (t *TodoWrite) Name() string

func (*TodoWrite) Parameters

func (t *TodoWrite) Parameters() json.RawMessage

func (*TodoWrite) Snapshot

func (t *TodoWrite) Snapshot() []TodoItem

Snapshot returns a copy of the current todo list. TUI uses this.

type Tool

type Tool interface {
	// Name is the function-call identifier the model uses.
	Name() string

	// Description is a one- to four-sentence English summary. Goes into
	// the prompt; keep it specific.
	Description() string

	// Parameters returns the JSON-Schema describing the tool's args.
	// The bytes do not need to be canonical — the registry canonicalizes
	// during AsLLMTools().
	Parameters() json.RawMessage

	// Execute runs the tool. args is the model's JSON arguments. The
	// returned Result is shown to the model; any non-nil error indicates
	// infrastructure failure the agent should surface (and may retry).
	Execute(ctx context.Context, args json.RawMessage) (Result, error)
}

Tool is the abstract built-in or MCP tool. Implementations are expected to be safe to call from arbitrary goroutines.

func CloneForCWD

func CloneForCWD(t Tool, cwd string) Tool

CloneForCWD returns a copy of t with its working directory rebound to cwd. Tools that are not cwd-aware are returned unchanged. This is used when a sub-agent runs in a git worktree with a different filesystem root, so that relative-path tools resolve against the worktree instead of the parent cwd.

type ToolTier

type ToolTier string

ToolTier classifies when a tool is loaded into the agent.

const (
	TierCore    ToolTier = "core"    // always available
	TierProfile ToolTier = "profile" // available per profile
	TierLazy    ToolTier = "lazy"    // loaded on demand
)

type UpdateChunk

type UpdateChunk struct {
	OldLines    []string // context + removed lines (for locating)
	NewLines    []string // context + added lines (replacement)
	Context     string   // @@ context marker (may be empty)
	IsEndOfFile bool     // chunk terminated by "*** End of File"
}

type WebFetchTool

type WebFetchTool struct {
	HTTPClient   *http.Client
	MaxBytes     int64
	AllowPrivate bool
}

WebFetchTool fetches a URL and converts HTML to markdown.

func NewWebFetchTool

func NewWebFetchTool(allowPrivate bool) *WebFetchTool

NewWebFetchTool creates a WebFetchTool with default settings.

func (*WebFetchTool) Description

func (*WebFetchTool) Description() string

func (*WebFetchTool) Execute

func (t *WebFetchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*WebFetchTool) IsReadOnly

func (*WebFetchTool) IsReadOnly() bool

func (*WebFetchTool) Name

func (*WebFetchTool) Name() string

func (*WebFetchTool) Parameters

func (*WebFetchTool) Parameters() json.RawMessage

type WebSearchProvider

type WebSearchProvider interface {
	Name() string
	Search(ctx context.Context, query string, limit int) ([]SearchHit, error)
}

WebSearchProvider is the interface for search backends.

type WebSearchTool

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

WebSearchTool searches the web using the configured provider.

func NewWebSearchTool

func NewWebSearchTool(p WebSearchProvider) *WebSearchTool

NewWebSearchTool creates a WebSearchTool with the given provider.

func (*WebSearchTool) Description

func (*WebSearchTool) Description() string

func (*WebSearchTool) Execute

func (t *WebSearchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*WebSearchTool) IsReadOnly

func (*WebSearchTool) IsReadOnly() bool

func (*WebSearchTool) Name

func (*WebSearchTool) Name() string

func (*WebSearchTool) Parameters

func (*WebSearchTool) Parameters() json.RawMessage

type WorktreeManager

type WorktreeManager interface {
	Create(ctx context.Context, branch, baseRev string) (worktree.Worktree, error)
	Remove(ctx context.Context, branch string, force bool) error
	List(ctx context.Context) ([]worktree.Worktree, error)
	Prune(ctx context.Context) error
	Status(ctx context.Context, branch string) (worktree.Worktree, error)
}

WorktreeManager is the narrow interface for worktree management. Implemented by *worktree.Manager.

type WorktreeTool

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

WorktreeTool exposes git worktree management as a tool.

func NewWorktreeTool

func NewWorktreeTool(m WorktreeManager) *WorktreeTool

NewWorktreeTool creates a WorktreeTool backed by the given manager.

func (*WorktreeTool) Description

func (*WorktreeTool) Description() string

func (*WorktreeTool) Execute

func (t *WorktreeTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (*WorktreeTool) IsReadOnly

func (*WorktreeTool) IsReadOnly() bool

func (*WorktreeTool) Name

func (*WorktreeTool) Name() string

func (*WorktreeTool) Parameters

func (*WorktreeTool) Parameters() json.RawMessage

type WriteFile

type WriteFile struct {
	MaxBytes int64  // default 5_242_880 (5 MiB); 0 means use default
	CWD      string // project root for path safety; empty means os.Getwd
	// Tracker, when set, refuses to overwrite an existing file that was never
	// read or that changed on disk since the read (T3.2). A new-file create
	// (path absent on disk) always passes. nil disables the guard.
	Tracker *FileTracker
}

WriteFile creates or overwrites a file. Snapshotting is the caller's responsibility — the agent invokes the snapshots manager before each edit/write tool call.

func (WriteFile) AffectedPaths

func (WriteFile) AffectedPaths(args json.RawMessage) []string

func (WriteFile) Description

func (WriteFile) Description() string

func (WriteFile) Execute

func (w WriteFile) Execute(ctx context.Context, args json.RawMessage) (Result, error)

func (WriteFile) Name

func (WriteFile) Name() string

func (WriteFile) Parameters

func (WriteFile) Parameters() json.RawMessage

Jump to

Keyboard shortcuts

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