tools

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentTools

func AgentTools(orch *subagent.Orchestrator, onEvent AgentEventCallback) ([]tool.Tool, error)

AgentTools returns tools that require an orchestrator (currently just the agent tool). The optional onEvent callback is invoked for each subagent event.

func CoreTools

func CoreTools(sandbox *Sandbox) ([]tool.Tool, error)

CoreTools returns the core coding agent tools as ADK FunctionTools. The sandbox restricts file-system access to the given root directory.

func LSPTools

func LSPTools(mgr *lsp.Manager) ([]tool.Tool, error)

LSPTools returns the 5 explicit LSP ADK tools.

func NewAgentTool

func NewAgentTool(orch *subagent.Orchestrator, onEvent AgentEventCallback) (tool.Tool, error)

NewAgentTool creates the agent ADK tool wired to an Orchestrator. The optional onEvent callback is invoked for each subagent event.

func NewRestartTool

func NewRestartTool(fn RestartFunc) (tool.Tool, error)

NewRestartTool creates a tool that restarts the pi process.

func NewScreenTool

func NewScreenTool(provider ScreenProvider) (tool.Tool, error)

NewScreenTool creates a tool that captures the current terminal screen.

Types

type AgentEventCallback

type AgentEventCallback func(agentID, eventType, content string)

AgentEventCallback is called for each subagent event to allow the TUI to display live event streams per agent.

type AgentToolInput

type AgentToolInput struct {
	// The type of agent to spawn: explore, plan, designer, reviewer, task, quick_task.
	Type string `json:"type"`
	// The task prompt for the agent.
	Prompt string `json:"prompt"`
}

AgentToolInput defines the parameters for the agent tool.

type AgentToolOutput

type AgentToolOutput struct {
	AgentID  string `json:"agent_id"`
	Type     string `json:"type"`
	Result   string `json:"result"`
	Error    string `json:"error,omitempty"`
	Duration string `json:"duration"`
}

AgentToolOutput is the result from a completed subagent.

type BashInput

type BashInput struct {
	// The shell command to execute.
	Command string `json:"command"`
	// Optional timeout in milliseconds. Default: 120000 (2 minutes). Max: 600000 (10 minutes).
	Timeout int `json:"timeout,omitempty"`
}

BashInput defines the parameters for the bash tool.

type BashOutput

type BashOutput struct {
	// Standard output from the command.
	Stdout string `json:"stdout"`
	// Standard error from the command.
	Stderr string `json:"stderr"`
	// Exit code of the command.
	ExitCode int `json:"exit_code"`
}

BashOutput contains the result of executing a shell command.

type DiagnosticEntry

type DiagnosticEntry struct {
	Line     int    `json:"line"`
	Column   int    `json:"column"`
	Severity string `json:"severity"`
	Message  string `json:"message"`
	Source   string `json:"source,omitempty"`
}

DiagnosticEntry is a single diagnostic for tool output.

type EditInput

type EditInput struct {
	// The absolute path to the file to edit.
	FilePath string `json:"file_path"`
	// The exact string to find and replace.
	OldString string `json:"old_string"`
	// The replacement string.
	NewString string `json:"new_string"`
	// If true, replace all occurrences. Default: replace first occurrence only.
	ReplaceAll bool `json:"replace_all,omitempty"`
}

EditInput defines the parameters for the edit tool.

type EditOutput

type EditOutput struct {
	// The path of the edited file.
	Path string `json:"path"`
	// Number of replacements made.
	Replacements int `json:"replacements"`
}

EditOutput contains the result of editing a file.

type FindInput

type FindInput struct {
	// The glob pattern to match files against (e.g. "**/*.go", "*.ts").
	Pattern string `json:"pattern"`
	// The directory to search in. Defaults to current directory.
	Path string `json:"path,omitempty"`
}

FindInput defines the parameters for the find tool.

type FindOutput

type FindOutput struct {
	// List of matching file paths.
	Files []string `json:"files"`
	// Total matches found (may be more than returned if truncated).
	TotalFiles int `json:"total_files"`
	// Whether results were truncated due to limits.
	Truncated bool `json:"truncated,omitempty"`
}

FindOutput contains the matching file paths.

type GitFileDiffInput

type GitFileDiffInput struct {
	// File path to diff (relative to repo root).
	File string `json:"file"`
	// If true, show staged (cached) diff instead of unstaged. Default: false.
	Staged bool `json:"staged,omitempty"`
}

GitFileDiffInput defines the parameters for the git-file-diff tool.

type GitFileDiffOutput

type GitFileDiffOutput struct {
	// File path that was diffed.
	File string `json:"file"`
	// Unified diff output.
	Diff string `json:"diff"`
	// Diff statistics: lines added.
	LinesAdded int `json:"lines_added"`
	// Diff statistics: lines removed.
	LinesRemoved int `json:"lines_removed"`
	// True if the file is binary.
	Binary bool `json:"binary,omitempty"`
	// True if diff output was truncated.
	Truncated bool `json:"truncated,omitempty"`
}

GitFileDiffOutput contains the unified diff for a single file.

type GitHunkInput

type GitHunkInput struct {
	// File path to inspect hunks for (relative to repo root).
	File string `json:"file"`
	// If true, show hunks from staged diff. Default: false.
	Staged bool `json:"staged,omitempty"`
}

GitHunkInput defines the parameters for the git-hunk tool.

type GitHunkOutput

type GitHunkOutput struct {
	// File path.
	File string `json:"file"`
	// Parsed hunks.
	Hunks []Hunk `json:"hunks"`
	// Total number of hunks.
	TotalHunks int `json:"total_hunks"`
}

GitHunkOutput contains parsed hunks for a file.

type GitOverviewInput

type GitOverviewInput struct {
	// Include staged files in the output. Default: true.
	IncludeStaged *bool `json:"include_staged,omitempty"`
	// Include unstaged modified files in the output. Default: true.
	IncludeUnstaged *bool `json:"include_unstaged,omitempty"`
	// Include untracked files in the output. Default: true.
	IncludeUntracked *bool `json:"include_untracked,omitempty"`
}

GitOverviewInput defines the parameters for the git-overview tool.

type GitOverviewOutput

type GitOverviewOutput struct {
	// Current branch name.
	Branch string `json:"branch"`
	// Recent commits (up to 10, most recent first).
	RecentCommits []string `json:"recent_commits"`
	// Files staged for commit (index column of porcelain).
	StagedFiles []string `json:"staged_files,omitempty"`
	// Files modified but not staged (worktree column of porcelain).
	UnstagedFiles []string `json:"unstaged_files,omitempty"`
	// Untracked files.
	UntrackedFiles []string `json:"untracked_files,omitempty"`
	// Upstream tracking branch (empty if none).
	Upstream string `json:"upstream,omitempty"`
	// Commits ahead of upstream.
	Ahead int `json:"ahead"`
	// Commits behind upstream.
	Behind int `json:"behind"`
}

GitOverviewOutput contains the git repository overview.

type GrepInput

type GrepInput struct {
	// The regex pattern to search for.
	Pattern string `json:"pattern"`
	// The file or directory to search in. Defaults to current directory.
	Path string `json:"path,omitempty"`
	// Glob pattern to filter files (e.g. "*.go", "*.{ts,tsx}").
	Glob string `json:"glob,omitempty"`
	// If true, perform case-insensitive matching.
	CaseInsensitive bool `json:"case_insensitive,omitempty"`
}

GrepInput defines the parameters for the grep tool.

type GrepMatch

type GrepMatch struct {
	File    string `json:"file"`
	Line    int    `json:"line"`
	Content string `json:"content"`
}

GrepMatch represents a single grep match.

type GrepOutput

type GrepOutput struct {
	// List of matches with file path, line number, and content.
	Matches []GrepMatch `json:"matches"`
	// Total number of matches found (may be more than returned if truncated).
	TotalMatches int `json:"total_matches"`
	// Whether results were truncated due to limits.
	Truncated bool `json:"truncated,omitempty"`
}

GrepOutput contains the search results.

type Hunk

type Hunk struct {
	// Hunk header (e.g. "@@ -1,3 +1,5 @@").
	Header string `json:"header"`
	// Raw hunk content (context + added + removed lines).
	Content string `json:"content"`
	// Number of lines added in this hunk.
	Added int `json:"added"`
	// Number of lines removed in this hunk.
	Removed int `json:"removed"`
}

Hunk represents a single diff hunk with metadata.

type LSPDiagnosticsOutput

type LSPDiagnosticsOutput struct {
	File        string            `json:"file"`
	Diagnostics []DiagnosticEntry `json:"diagnostics"`
	Error       string            `json:"error,omitempty"`
}

LSPDiagnosticsOutput is the output of the lsp-diagnostics tool.

type LSPFileInput

type LSPFileInput struct {
	File string `json:"file"`
}

LSPFileInput is shared input for tools that take only a file path.

type LSPHoverOutput

type LSPHoverOutput struct {
	Content string `json:"content"`
	Error   string `json:"error,omitempty"`
}

LSPHoverOutput is the output of the lsp-hover tool.

type LSPLocationsOutput

type LSPLocationsOutput struct {
	Locations []LocationEntry `json:"locations"`
	Error     string          `json:"error,omitempty"`
}

LSPLocationsOutput is the output for definition/references tools.

type LSPPositionInput

type LSPPositionInput struct {
	File   string `json:"file"`
	Line   int    `json:"line"`
	Column int    `json:"column"`
}

LSPPositionInput is shared input for tools that take a file + position.

type LSPSymbolsOutput

type LSPSymbolsOutput struct {
	File    string        `json:"file"`
	Symbols []SymbolEntry `json:"symbols"`
	Error   string        `json:"error,omitempty"`
}

LSPSymbolsOutput is the output of the lsp-symbols tool.

type LocationEntry

type LocationEntry struct {
	File   string `json:"file"`
	Line   int    `json:"line"`
	Column int    `json:"column"`
}

LocationEntry is a single location for tool output.

type LsEntry

type LsEntry struct {
	Name  string `json:"name"`
	IsDir bool   `json:"is_dir"`
	Size  int64  `json:"size"`
}

LsEntry represents a single directory entry.

type LsInput

type LsInput struct {
	// The directory path to list. Defaults to current directory.
	Path string `json:"path,omitempty"`
}

LsInput defines the parameters for the ls tool.

type LsOutput

type LsOutput struct {
	// List of entries in the directory.
	Entries []LsEntry `json:"entries"`
	// Total entries in the directory (may be more than returned if truncated).
	TotalEntries int `json:"total_entries"`
	// Whether results were truncated due to limits.
	Truncated bool `json:"truncated,omitempty"`
}

LsOutput contains the directory listing.

type ReadInput

type ReadInput struct {
	// The absolute path to the file to read.
	FilePath string `json:"file_path"`
	// Optional line offset to start reading from (1-based). Defaults to 1.
	Offset int `json:"offset,omitempty"`
	// Optional maximum number of lines to read. 0 means up to 2000 lines.
	Limit int `json:"limit,omitempty"`
}

ReadInput defines the parameters for the read tool.

type ReadOutput

type ReadOutput struct {
	// The file content with line numbers.
	Content string `json:"content"`
	// Total number of lines in the file.
	TotalLines int `json:"total_lines"`
	// Whether the output was truncated.
	Truncated bool `json:"truncated,omitempty"`
}

ReadOutput contains the result of reading a file.

type RestartFunc

type RestartFunc func()

RestartFunc is called when the agent invokes the restart tool. The TUI provides this callback to trigger a process restart.

type RestartInput

type RestartInput struct {
}

RestartInput defines the parameters for the restart tool (none needed).

type RestartOutput

type RestartOutput struct {
	Status string `json:"status"`
}

RestartOutput contains the result of the restart request.

type Sandbox

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

Sandbox restricts file system access to a directory tree using os.Root.

func NewSandbox

func NewSandbox(dir string) (*Sandbox, error)

NewSandbox opens an os.Root anchored at dir.

func (*Sandbox) Close

func (s *Sandbox) Close() error

Close releases the underlying os.Root file descriptor.

func (*Sandbox) Dir

func (s *Sandbox) Dir() string

Dir returns the absolute path of the sandbox root.

func (*Sandbox) FS

func (s *Sandbox) FS() fs.FS

FS returns an fs.FS scoped to the sandbox root directory.

func (*Sandbox) MkdirAll

func (s *Sandbox) MkdirAll(name string, perm os.FileMode) error

MkdirAll creates a directory path within the sandbox.

func (*Sandbox) Open

func (s *Sandbox) Open(name string) (*os.File, error)

Open opens a file for reading within the sandbox.

func (*Sandbox) ReadDir

func (s *Sandbox) ReadDir(name string) ([]os.DirEntry, error)

ReadDir lists entries in a directory within the sandbox.

func (*Sandbox) ReadFile

func (s *Sandbox) ReadFile(name string) ([]byte, error)

ReadFile reads the named file within the sandbox.

func (*Sandbox) Resolve

func (s *Sandbox) Resolve(name string) (string, error)

Resolve converts an absolute or relative path to a relative path under the sandbox root. os.Root enforces that the resolved path cannot escape the directory tree (via ".." or symlinks).

func (*Sandbox) Stat

func (s *Sandbox) Stat(name string) (os.FileInfo, error)

Stat returns FileInfo for a path within the sandbox.

func (*Sandbox) WriteFile

func (s *Sandbox) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to the named file within the sandbox, creating it if necessary (parent directories are created automatically).

type ScreenInput

type ScreenInput struct {
}

ScreenInput defines the parameters for the screen tool.

type ScreenOutput

type ScreenOutput struct {
	// The current terminal screen content visible to the user.
	Content string `json:"content"`
}

ScreenOutput contains the captured screen content.

type ScreenProvider

type ScreenProvider interface {
	ScreenContent() string
}

ScreenProvider returns the current terminal screen content. Implemented by the TUI to give the LLM visibility into what the user sees.

type SymbolEntry

type SymbolEntry struct {
	Name    string `json:"name"`
	Kind    string `json:"kind"`
	Line    int    `json:"line"`
	EndLine int    `json:"end_line"`
}

SymbolEntry is a single symbol for tool output.

type TreeInput

type TreeInput struct {
	// Directory path to show. Defaults to current directory.
	Path string `json:"path,omitempty"`
	// Maximum depth to recurse. Default 3, max 10.
	Depth int `json:"depth,omitempty"`
}

TreeInput defines the parameters for the tree tool.

type TreeOutput

type TreeOutput struct {
	Tree  string `json:"tree"`
	Dirs  int    `json:"dirs"`
	Files int    `json:"files"`
}

TreeOutput contains the tree listing.

type WriteInput

type WriteInput struct {
	// The absolute path to the file to write.
	FilePath string `json:"file_path"`
	// The content to write to the file.
	Content string `json:"content"`
}

WriteInput defines the parameters for the write tool.

type WriteOutput

type WriteOutput struct {
	// The path of the written file.
	Path string `json:"path"`
	// Number of bytes written.
	BytesWritten int `json:"bytes_written"`
}

WriteOutput contains the result of writing a file.

Jump to

Keyboard shortcuts

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