codingtools

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package codingtools defines Plasmid's native ADK coding tools and their wire arguments and result objects.

Index

Constants

View Source
const (
	// ReadDescription is the model-facing read tool description.
	ReadDescription = "" /* 271-byte string literal not displayed */

	// WriteDescription is the model-facing write tool description.
	WriteDescription = "" /* 384-byte string literal not displayed */

	// EditDescription is the model-facing edit tool description.
	EditDescription = "" /* 436-byte string literal not displayed */

	// BashDescription is the model-facing bash tool description.
	BashDescription = "" /* 551-byte string literal not displayed */

	// GrepDescription is the model-facing grep tool description.
	GrepDescription = "" /* 393-byte string literal not displayed */

	// FindDescription is the model-facing find tool description.
	FindDescription = "" /* 312-byte string literal not displayed */

	// ListDescription is the model-facing ls tool description.
	ListDescription = "" /* 369-byte string literal not displayed */
)
View Source
const (
	// DiagnosticsResultKey is reserved for structured LSP diagnostics added by
	// the native after-tool callback.
	DiagnosticsResultKey = "diagnostics"
	// DiagnosticsTextResultKey is reserved for the bounded model-facing LSP
	// diagnostic rendering added by the native after-tool callback.
	DiagnosticsTextResultKey = "diagnostics_text"
)
View Source
const MaxTouchEvents = 256

MaxTouchEvents bounds search fan-out into context and LSP observers.

Variables

View Source
var (
	// File sentinels preserve the workspace contract's errors.Is identity.
	ErrPathOutsideRoot = workspace.ErrOutsideRoot
	ErrFileNotFound    = workspace.ErrNotFound
	ErrIsDirectory     = workspace.ErrIsDirectory
	ErrBinaryFile      = workspace.ErrBinaryFile
	ErrFileTooLarge    = workspace.ErrTooLarge
	ErrNeverRead       = workspace.ErrNeverRead
	ErrStaleRead       = workspace.ErrStaleRead

	// Edit sentinels preserve the deterministic matcher's errors.Is identity.
	ErrNoMatch        = textmatch.ErrNoMatch
	ErrAmbiguousMatch = textmatch.ErrAmbiguousMatch

	// ErrNoShell preserves the shell executor's errors.Is identity.
	ErrNoShell = shellexec.ErrNoShell

	// ErrUnsupportedPattern classifies search syntax outside the portable
	// regexp and glob subset. Handlers add the rejected construct and remedy.
	ErrUnsupportedPattern = errors.New("coding tools: unsupported pattern")
)

Functions

func BashInputSchema

func BashInputSchema() json.RawMessage

BashInputSchema returns an independent copy of the bash input schema.

func EditInputSchema

func EditInputSchema() json.RawMessage

EditInputSchema returns an independent copy of the edit input schema.

func FindInputSchema

func FindInputSchema() json.RawMessage

FindInputSchema returns an independent copy of the find input schema.

func GrepInputSchema

func GrepInputSchema() json.RawMessage

GrepInputSchema returns an independent copy of the grep input schema.

func ListInputSchema

func ListInputSchema() json.RawMessage

ListInputSchema returns an independent copy of the ls input schema.

func NewBashTool

func NewBashTool(cfg Config) (adktool.Tool, error)

NewBashTool validates the shared executor dependencies and constructs a bash tool.

func NewEditTool

func NewEditTool(cfg Config) (adktool.Tool, error)

NewEditTool validates the shared mutation dependencies and constructs an edit tool.

func NewFindTool

func NewFindTool(cfg Config) (adktool.Tool, error)

NewFindTool constructs the native ADK find tool.

func NewGrepTool

func NewGrepTool(cfg Config) (adktool.Tool, error)

NewGrepTool validates shared search dependencies and constructs a grep tool.

func NewListTool

func NewListTool(cfg Config) (adktool.Tool, error)

NewListTool validates the listing dependencies and constructs an ls tool.

func NewReadTool

func NewReadTool(cfg Config) (adktool.Tool, error)

NewReadTool validates the read dependencies and constructs a read tool.

func NewWriteTool

func NewWriteTool(cfg Config) (adktool.Tool, error)

NewWriteTool validates the shared mutation dependencies and constructs a write tool.

func ReadInputSchema

func ReadInputSchema() json.RawMessage

ReadInputSchema returns an independent copy of the read input schema.

func ToolSpecifier

func ToolSpecifier(toolName string, input map[string]any) string

ToolSpecifier returns the primary subject of a known coding-tool call.

func WriteInputSchema

func WriteInputSchema() json.RawMessage

WriteInputSchema returns an independent copy of the write input schema.

Types

type BashArgs

type BashArgs struct {
	Command   string `json:"command"`
	Dir       string `json:"dir"`
	TimeoutMS int    `json:"timeout_ms"`
}

BashArgs describes one fresh, non-interactive shell invocation. An empty Dir and a zero TimeoutMS select the schema defaults.

type BashResult

type BashResult struct {
	Stdout       string             `json:"stdout"`
	Stderr       string             `json:"stderr"`
	ExitCode     int                `json:"exit_code"`
	Signal       string             `json:"signal"`
	TimedOut     bool               `json:"timed_out"`
	Killed       bool               `json:"killed"`
	Truncated    bool               `json:"truncated"`
	StdoutReport outputlimit.Report `json:"stdout_report"`
	StderrReport outputlimit.Report `json:"stderr_report"`
}

BashResult is the portable projection of shellexec.Result. Process duration and the resolved host directory are deliberately excluded from the wire.

type Config

type Config struct {
	Root               *workspace.Root
	Queue              *workspace.MutationQueue
	Ledger             *workspace.Ledger
	Touch              *workspace.TouchBus
	Shell              *shellexec.Executor
	Output             outputlimit.Policy
	Budget             *outputlimit.Budget
	Logger             *slog.Logger
	WarningSink        warning.Warner
	MaxReadBytes       int64
	MaxWriteBytes      int64
	MaxGrepFileBytes   int64
	MaxTouchEvents     int
	DefaultBashTimeout time.Duration
}

Config contains the shared dependencies and limits used by coding tools.

type EditArgs

type EditArgs struct {
	Path       string `json:"path"`
	OldText    string `json:"old_text"`
	NewText    string `json:"new_text"`
	ReplaceAll bool   `json:"replace_all"`
}

EditArgs describes one deterministic text replacement. ReplaceAll defaults to false.

type EditResult

type EditResult struct {
	Path         string             `json:"path"`
	Replacements int                `json:"replacements"`
	MatchTier    string             `json:"match_tier"`
	Diff         string             `json:"diff"`
	Truncated    bool               `json:"truncated"`
	Report       outputlimit.Report `json:"report"`
}

EditResult reports the selected matching tier and bounded unified diff.

type FindArgs

type FindArgs struct {
	Path       string `json:"path"`
	Glob       string `json:"glob"`
	Type       string `json:"type"`
	SortBy     string `json:"sort_by"`
	MaxResults int    `json:"max_results"`
}

FindArgs configures a bounded workspace glob search. Zero optional values select the schema defaults.

type FindResult

type FindResult struct {
	Paths     []string `json:"paths"`
	Truncated bool     `json:"truncated"`
}

FindResult contains sorted slash-separated workspace-relative paths.

type GrepArgs

type GrepArgs struct {
	Pattern         string `json:"pattern"`
	Path            string `json:"path"`
	Glob            string `json:"glob"`
	Literal         bool   `json:"literal"`
	CaseInsensitive bool   `json:"case_insensitive"`
	ContextLines    int    `json:"context_lines"`
	MaxResults      int    `json:"max_results"`
}

GrepArgs configures a bounded text search. Zero optional values select the schema defaults.

type GrepMatch

type GrepMatch struct {
	Path   string   `json:"path"`
	Line   int      `json:"line"`
	Text   string   `json:"text"`
	Before []string `json:"before"`
	After  []string `json:"after"`
}

GrepMatch contains a full matching line and its requested surrounding context. Path is slash-separated and workspace-relative.

type GrepResult

type GrepResult struct {
	Matches          []GrepMatch `json:"matches"`
	MatchCount       int         `json:"match_count"`
	Files            int         `json:"files"`
	Truncated        bool        `json:"truncated"`
	SkippedBinary    int         `json:"skipped_binary"`
	SkippedTooLarge  int         `json:"skipped_too_large"`
	SkippedLongLines int         `json:"skipped_long_lines"`
}

GrepResult contains sorted matches and explicit skip counts.

type ListArgs

type ListArgs struct {
	Path       string `json:"path"`
	MaxDepth   int    `json:"max_depth"`
	ShowHidden bool   `json:"show_hidden"`
	MaxResults int    `json:"max_results"`
}

ListArgs configures a bounded directory listing. Zero optional values select the schema defaults.

type ListEntry

type ListEntry struct {
	Path    string `json:"path"`
	Type    string `json:"type"`
	Size    int64  `json:"size"`
	ModTime string `json:"mod_time"`
}

ListEntry is a portable projection of one workspace entry. ModTime is encoded as RFC3339 text; host file modes are deliberately excluded.

type ListResult

type ListResult struct {
	Entries   []ListEntry `json:"entries"`
	Truncated bool        `json:"truncated"`
}

ListResult contains directory-first entries in deterministic name order.

type ReadArgs

type ReadArgs struct {
	Path   string `json:"path"`
	Offset int    `json:"offset"`
	Limit  int    `json:"limit"`
}

ReadArgs selects a one-based line window from a text file. Zero Offset and Limit values select the schema defaults.

type ReadResult

type ReadResult struct {
	Path       string             `json:"path"`
	Content    string             `json:"content"`
	StartLine  int                `json:"start_line"`
	EndLine    int                `json:"end_line"`
	TotalLines int                `json:"total_lines"`
	Truncated  bool               `json:"truncated"`
	Report     outputlimit.Report `json:"report"`
}

ReadResult contains numbered text and the actual source window rendered from a workspace-relative path.

type Set

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

Set is the fixed, ordered collection of built-in coding tools.

func New

func New(cfg Config) (*Set, error)

New constructs the built-in coding tools in their stable wire order.

func (*Set) Names

func (s *Set) Names() []string

Names returns stable tool names in tool order. The returned slice is owned by the caller.

func (*Set) Tool

func (s *Set) Tool(name string) (adktool.Tool, bool)

Tool returns the tool with an exact wire name.

func (*Set) Tools

func (s *Set) Tools() []adktool.Tool

Tools returns the tools in stable wire order. The returned slice is owned by the caller.

type ToolSpecifierFunc

type ToolSpecifierFunc = func(string, map[string]any) string

ToolSpecifierFunc adapts a function to a tool-call specifier.

type WriteArgs

type WriteArgs struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

WriteArgs supplies the complete contents of a file.

type WriteResult

type WriteResult struct {
	Path         string             `json:"path"`
	BytesWritten int                `json:"bytes_written"`
	Diff         string             `json:"diff"`
	Truncated    bool               `json:"truncated"`
	Report       outputlimit.Report `json:"report"`
}

WriteResult reports the durable content size and bounded unified diff.

Directories

Path Synopsis
internal
walk
Package walk provides deterministic, filtered directory traversal.
Package walk provides deterministic, filtered directory traversal.

Jump to

Keyboard shortcuts

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