coding

package
v0.93.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package coding provides agent tools for terminal control, file I/O, web search, and code execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveToolNames

func ActiveToolNames() []string

ActiveToolNames returns the default active coding tool names.

func RegisterAll

func RegisterAll(registry *tool.Registry, ws Workspace, executionEnv env.ExecutionEnv) error

RegisterAll registers chat assistant tools on the registry.

Types

type ReadFileTool

type ReadFileTool struct {
	Workspace Workspace
	Env       env.ExecutionEnv
}

ReadFileTool reads file contents from the workspace.

func (ReadFileTool) Description

func (ReadFileTool) Description() string

Description explains the tool to the model.

func (ReadFileTool) Execute

Execute reads the requested file.

func (ReadFileTool) Name

func (ReadFileTool) Name() string

Name returns the tool identifier.

func (ReadFileTool) Parameters

func (ReadFileTool) Parameters() map[string]any

Parameters returns the JSON schema for tool arguments.

type RunCodeTool

type RunCodeTool struct {
	Workspace Workspace
	Env       env.ExecutionEnv
}

RunCodeTool executes source code by writing a temporary file and invoking an interpreter.

func (RunCodeTool) Description

func (RunCodeTool) Description() string

Description explains the tool to the model.

func (RunCodeTool) Execute

func (t RunCodeTool) Execute(ctx context.Context, id string, args map[string]any, onUpdate tool.UpdateHandler) (msg.ToolResultMessage, error)

Execute runs the provided code snippet.

func (RunCodeTool) Name

func (RunCodeTool) Name() string

Name returns the tool identifier.

func (RunCodeTool) Parameters

func (RunCodeTool) Parameters() map[string]any

Parameters returns the JSON schema for tool arguments.

type RunTerminalTool

type RunTerminalTool struct {
	Workspace Workspace
	Env       env.ExecutionEnv
}

RunTerminalTool executes shell commands inside the workspace.

func (RunTerminalTool) Description

func (RunTerminalTool) Description() string

Description explains the tool to the model.

func (RunTerminalTool) Execute

func (t RunTerminalTool) Execute(ctx context.Context, id string, args map[string]any, onUpdate tool.UpdateHandler) (msg.ToolResultMessage, error)

Execute runs the requested command.

func (RunTerminalTool) Name

func (RunTerminalTool) Name() string

Name returns the tool identifier.

func (RunTerminalTool) Parameters

func (RunTerminalTool) Parameters() map[string]any

Parameters returns the JSON schema for tool arguments.

type WebSearchTool

type WebSearchTool struct {
	HTTPClient *http.Client
	MaxOutput  int
	// BaseURL overrides the DuckDuckGo endpoint for tests.
	BaseURL string
}

WebSearchTool searches the web using DuckDuckGo Instant Answer API.

func (WebSearchTool) Description

func (WebSearchTool) Description() string

Description explains the tool to the model.

func (WebSearchTool) Execute

func (t WebSearchTool) Execute(ctx context.Context, id string, args map[string]any, onUpdate tool.UpdateHandler) (msg.ToolResultMessage, error)

Execute performs the web search.

func (WebSearchTool) Name

func (WebSearchTool) Name() string

Name returns the tool identifier.

func (WebSearchTool) Parameters

func (WebSearchTool) Parameters() map[string]any

Parameters returns the JSON schema for tool arguments.

type Workspace

type Workspace struct {
	// Root is the absolute workspace path.
	Root string
	// Timeout limits shell and code execution duration.
	Timeout time.Duration
	// MaxOutput truncates tool stdout/stderr beyond this byte count.
	MaxOutput int
}

Workspace bounds file and shell operations to a single root directory.

func (Workspace) ResolvePath

func (w Workspace) ResolvePath(path string) result.Result[string, result.FileError]

ResolvePath maps a relative or absolute path into the workspace root.

func (Workspace) TruncateOutput

func (w Workspace) TruncateOutput(text string) string

TruncateOutput limits output size for model context safety.

type WriteFileTool

type WriteFileTool struct {
	Workspace Workspace
	Env       env.ExecutionEnv
}

WriteFileTool writes or overwrites a file in the workspace.

func (WriteFileTool) Description

func (WriteFileTool) Description() string

Description explains the tool to the model.

func (WriteFileTool) Execute

Execute writes the requested file.

func (WriteFileTool) Name

func (WriteFileTool) Name() string

Name returns the tool identifier.

func (WriteFileTool) Parameters

func (WriteFileTool) Parameters() map[string]any

Parameters returns the JSON schema for tool arguments.

Jump to

Keyboard shortcuts

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