Documentation
¶
Overview ¶
Package codingtools exposes reusable read, edit, and write tool contracts for LLM integrations on top of gbash-owned filesystem abstractions.
It ports the upstream pi-mono coding-agent tool semantics onto github.com/ewhauser/gbash/fs.FileSystem so embedders can run the same tool surface against in-memory, overlay, session, and host-backed filesystems without changing the tool contract.
Index ¶
- Constants
- func FormatSize(bytes int) string
- type Config
- type ContentBlock
- type EditDetails
- type EditRequest
- type EditResponse
- type ReadDetails
- type ReadRequest
- type ReadResponse
- type ToolDefinition
- type Toolset
- func (t *Toolset) Edit(ctx context.Context, req EditRequest) (EditResponse, error)
- func (t *Toolset) EditToolDefinition() ToolDefinition
- func (t *Toolset) Read(ctx context.Context, req ReadRequest) (ReadResponse, error)
- func (t *Toolset) ReadToolDefinition() ToolDefinition
- func (t *Toolset) ToolDefinitions() []ToolDefinition
- func (t *Toolset) Write(ctx context.Context, req WriteRequest) (WriteResponse, error)
- func (t *Toolset) WriteToolDefinition() ToolDefinition
- type TruncationOptions
- type TruncationResult
- type WriteRequest
- type WriteResponse
Constants ¶
const ( // DefaultMaxLines is the default line limit for read output. DefaultMaxLines = 2000 // DefaultMaxBytes is the default byte limit for read output. DefaultMaxBytes = 50 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func FormatSize ¶
FormatSize formats a byte count for user-facing messages.
Types ¶
type Config ¶
type Config struct {
FS gbfs.FileSystem
WorkingDir string
HomeDir string
Truncation TruncationOptions
}
Config configures the coding toolset.
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
}
ContentBlock is one structured tool-response item.
type EditDetails ¶
type EditDetails struct {
Diff string `json:"diff"`
FirstChangedLine int `json:"first_changed_line,omitempty"`
}
EditDetails carries extra edit metadata.
type EditRequest ¶
type EditRequest struct {
Path string `json:"path"`
OldText string `json:"oldText"`
NewText string `json:"newText"`
}
EditRequest is the edit tool input contract.
func ParseEditRequest ¶
func ParseEditRequest(input map[string]any) (EditRequest, error)
ParseEditRequest decodes a provider tool-call payload.
type EditResponse ¶
type EditResponse struct {
Content []ContentBlock `json:"content"`
Details *EditDetails `json:"details,omitempty"`
}
EditResponse is the edit tool result contract.
type ReadDetails ¶
type ReadDetails struct {
Truncation *TruncationResult `json:"truncation,omitempty"`
}
ReadDetails carries extra read metadata.
type ReadRequest ¶
type ReadRequest struct {
Path string `json:"path"`
Offset *int `json:"offset,omitempty"`
Limit *int `json:"limit,omitempty"`
}
ReadRequest is the read tool input contract.
func ParseReadRequest ¶
func ParseReadRequest(input map[string]any) (ReadRequest, error)
ParseReadRequest decodes a provider tool-call payload.
type ReadResponse ¶
type ReadResponse struct {
Content []ContentBlock `json:"content"`
Details *ReadDetails `json:"details,omitempty"`
}
ReadResponse is the read tool result contract.
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"input_schema"`
}
ToolDefinition is a provider-neutral function tool definition.
type Toolset ¶
type Toolset struct {
// contains filtered or unexported fields
}
Toolset owns the coding tools for a specific filesystem view.
func (*Toolset) Edit ¶
func (t *Toolset) Edit(ctx context.Context, req EditRequest) (EditResponse, error)
Edit runs the edit tool.
func (*Toolset) EditToolDefinition ¶
func (t *Toolset) EditToolDefinition() ToolDefinition
EditToolDefinition returns the edit tool definition.
func (*Toolset) Read ¶
func (t *Toolset) Read(ctx context.Context, req ReadRequest) (ReadResponse, error)
Read runs the read tool.
func (*Toolset) ReadToolDefinition ¶
func (t *Toolset) ReadToolDefinition() ToolDefinition
ReadToolDefinition returns the read tool definition.
func (*Toolset) ToolDefinitions ¶
func (t *Toolset) ToolDefinitions() []ToolDefinition
ToolDefinitions returns the provider-neutral tool definitions in upstream order.
func (*Toolset) Write ¶
func (t *Toolset) Write(ctx context.Context, req WriteRequest) (WriteResponse, error)
Write runs the write tool.
func (*Toolset) WriteToolDefinition ¶
func (t *Toolset) WriteToolDefinition() ToolDefinition
WriteToolDefinition returns the write tool definition.
type TruncationOptions ¶
type TruncationOptions struct {
MaxLines int `json:"max_lines,omitempty"`
MaxBytes int `json:"max_bytes,omitempty"`
}
TruncationOptions configures read truncation.
type TruncationResult ¶
type TruncationResult struct {
Content string `json:"content"`
Truncated bool `json:"truncated"`
TruncatedBy string `json:"truncated_by,omitempty"`
TotalLines int `json:"total_lines"`
TotalBytes int `json:"total_bytes"`
OutputLines int `json:"output_lines"`
OutputBytes int `json:"output_bytes"`
LastLinePartial bool `json:"last_line_partial"`
FirstLineExceedsLimit bool `json:"first_line_exceeds_limit"`
MaxLines int `json:"max_lines"`
MaxBytes int `json:"max_bytes"`
}
TruncationResult captures truncation metadata.
func TruncateHead ¶
func TruncateHead(content string, options TruncationOptions) TruncationResult
TruncateHead truncates content from the start without returning partial lines.
type WriteRequest ¶
WriteRequest is the write tool input contract.
func ParseWriteRequest ¶
func ParseWriteRequest(input map[string]any) (WriteRequest, error)
ParseWriteRequest decodes a provider tool-call payload.
type WriteResponse ¶
type WriteResponse struct {
Content []ContentBlock `json:"content"`
}
WriteResponse is the write tool result contract.