Documentation
¶
Index ¶
- func DetectLineEnding(content string) string
- func DetectSupportedImageMimeType(buffer []byte) string
- func ExpandPath(filePath string) (string, error)
- func FormatDimensionNote(result ResizedImage) string
- func GenerateUnifiedPatch(path, oldContent, newContent string, contextLines int) (string, error)
- func GetShellEnv() (map[string]string, error)
- func KillProcessTree(pid int)
- func KillTrackedDetachedChildren()
- func ManagedFDPath() string
- func NewBashTool(cwd string, options *BashToolOptions) agent.AgentTool
- func NewCodingTools(cwd string, options *ToolsOptions) []agent.AgentTool
- func NewEditTool(cwd string, options *EditToolOptions) agent.AgentTool
- func NewFindTool(cwd string, options *FindToolOptions) agent.AgentTool
- func NewGrepTool(cwd string, options *GrepToolOptions) agent.AgentTool
- func NewLsTool(cwd string, options *LsToolOptions) agent.AgentTool
- func NewReadOnlyTools(cwd string, options *ToolsOptions) []agent.AgentTool
- func NewReadTool(cwd string, options *ReadToolOptions) agent.AgentTool
- func NewWriteTool(cwd string, options *WriteToolOptions) agent.AgentTool
- func NormalizeForFuzzyMatch(text string) string
- func NormalizeToLF(text string) string
- func PathExists(filePath string) bool
- func ResolveReadPath(filePath, cwd string) (string, error)
- func ResolveToCwd(filePath, cwd string) (string, error)
- func RestoreLineEndings(text, ending string) string
- func ShortenPath(path string) string
- func StripBOM(content string) (bom, text string)
- func TrackDetachedChildPID(pid int)
- func UntrackDetachedChildPID(pid int)
- func WithFileMutationQueue[T any](filePath string, fn func() (T, error)) (T, error)
- type AppliedEditsResult
- type BashExecOptions
- type BashExecResult
- type BashOperations
- type BashResult
- type BashSessionEnvironment
- type BashSessionEnvironmentBinder
- type BashSessionEnvironmentSource
- type BashSpawnContext
- type BashSpawnHook
- type BashToolDetails
- type BashToolInput
- type BashToolOptions
- type DiffResult
- type Edit
- type EditOperations
- type EditToolDetails
- type EditToolInput
- type EditToolOptions
- type FindGlobOptions
- type FindOperations
- type FindToolDetails
- type FindToolInput
- type FindToolOptions
- type FuzzyMatchResult
- type GrepOperations
- type GrepToolDetails
- type GrepToolInput
- type GrepToolOptions
- type ImageResizeOptions
- type LocalBashOperationsOptions
- type LsOperations
- type LsPathStat
- type LsToolDetails
- type LsToolInput
- type LsToolOptions
- type OutputAccumulator
- func (output *OutputAccumulator) Append(data []byte) error
- func (output *OutputAccumulator) CloseTempFile() error
- func (output *OutputAccumulator) Finish() error
- func (output *OutputAccumulator) LastLineBytes() int
- func (output *OutputAccumulator) Snapshot(options ...OutputSnapshotOptions) (OutputSnapshot, error)
- type OutputAccumulatorOptions
- type OutputSnapshot
- type OutputSnapshotOptions
- type PlainTextRenderer
- type ProcessImageOptions
- type ProcessImageResult
- type ReadImageOperations
- type ReadOperations
- type ReadToolDetails
- type ReadToolInput
- type ReadToolOptions
- type ResizedImage
- type ShellCommandTransport
- type ShellConfig
- type ToolsOptions
- type WriteOperations
- type WriteToolInput
- type WriteToolOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectLineEnding ¶
func ExpandPath ¶
ExpandPath applies the path-input normalization used by the built-in tools.
func FormatDimensionNote ¶
func FormatDimensionNote(result ResizedImage) string
func GenerateUnifiedPatch ¶
func GetShellEnv ¶
func KillProcessTree ¶
func KillProcessTree(pid int)
func KillTrackedDetachedChildren ¶
func KillTrackedDetachedChildren()
func ManagedFDPath ¶ added in v0.4.6
func ManagedFDPath() string
ManagedFDPath returns an already-installed fd, preferring the managed binary over a system one, or "" when neither is present. It never downloads and never spawns a probe process, so callers on interactive render paths can call it freely.
func NewBashTool ¶
func NewBashTool(cwd string, options *BashToolOptions) agent.AgentTool
func NewCodingTools ¶
func NewCodingTools(cwd string, options *ToolsOptions) []agent.AgentTool
NewCodingTools mirrors upstream createCodingTools: read, bash, edit, write.
func NewEditTool ¶
func NewEditTool(cwd string, options *EditToolOptions) agent.AgentTool
func NewFindTool ¶
func NewFindTool(cwd string, options *FindToolOptions) agent.AgentTool
func NewGrepTool ¶
func NewGrepTool(cwd string, options *GrepToolOptions) agent.AgentTool
func NewReadOnlyTools ¶
func NewReadOnlyTools(cwd string, options *ToolsOptions) []agent.AgentTool
NewReadOnlyTools mirrors upstream createReadOnlyTools: read, grep, find, ls.
func NewReadTool ¶
func NewReadTool(cwd string, options *ReadToolOptions) agent.AgentTool
func NewWriteTool ¶
func NewWriteTool(cwd string, options *WriteToolOptions) agent.AgentTool
func NormalizeForFuzzyMatch ¶
func NormalizeToLF ¶
func PathExists ¶
PathExists reports whether a filesystem entry exists at filePath.
func ResolveReadPath ¶
ResolveReadPath adds the filename fallbacks used for macOS-generated files.
func ResolveToCwd ¶
ResolveToCwd resolves a normalized tool path relative to cwd.
func RestoreLineEndings ¶
func ShortenPath ¶
ShortenPath abbreviates a home-relative path with "~" for tool headers, matching upstream render-utils shortenPath.
func TrackDetachedChildPID ¶
func TrackDetachedChildPID(pid int)
func UntrackDetachedChildPID ¶
func UntrackDetachedChildPID(pid int)
Types ¶
type AppliedEditsResult ¶
type AppliedEditsResult struct {
BaseContent string `json:"baseContent"`
NewContent string `json:"newContent"`
}
func ApplyEditsToNormalizedContent ¶
func ApplyEditsToNormalizedContent(normalizedContent string, edits []Edit, path string) (AppliedEditsResult, error)
type BashExecOptions ¶
type BashExecResult ¶
type BashExecResult struct {
ExitCode *int
}
type BashOperations ¶
type BashOperations interface {
Exec(context.Context, string, string, BashExecOptions) (BashExecResult, error)
}
BashOperations is the command-execution delegation seam used by local and remote backends.
func NewLocalBashOperations ¶
func NewLocalBashOperations(options ...LocalBashOperationsOptions) BashOperations
type BashResult ¶
type BashResult struct {
Output string `json:"output"`
ExitCode *int `json:"exitCode,omitempty"`
Cancelled bool `json:"cancelled"`
Truncated bool `json:"truncated"`
FullOutputPath string `json:"fullOutputPath,omitempty"`
}
func ExecuteBash ¶
func ExecuteBash(ctx context.Context, command, cwd, prefix, shellPath string, onChunk func(string)) (BashResult, error)
ExecuteBash mirrors the session-level bash executor rather than the bash tool: a non-zero exit is data in RPC mode, while cancellation is reported in the result instead of becoming a tool error. onChunk receives each sanitized output chunk as it streams.
type BashSessionEnvironment ¶ added in v0.4.7
type BashSessionEnvironment struct {
SessionID string
SessionFile string
Provider string
Model string
ReasoningLevel string
}
BashSessionEnvironment carries the session metadata exposed to bash commands as PI_* environment variables. It mirrors what the upstream bash tool reads from the ExtensionContext in resolveSpawnContext.
type BashSessionEnvironmentBinder ¶ added in v0.4.7
type BashSessionEnvironmentBinder interface {
BindSessionEnvironment(BashSessionEnvironmentSource)
}
BashSessionEnvironmentBinder is the pigo counterpart of upstream tools receiving the ExtensionContext at execute time: built-ins implement agent.AgentTool directly, so the session runtime binds a source instead.
type BashSessionEnvironmentSource ¶ added in v0.4.7
type BashSessionEnvironmentSource func() *BashSessionEnvironment
BashSessionEnvironmentSource resolves the current session metadata at execution time. A nil result means no session context is available (the upstream `ctx === undefined` case).
type BashSpawnContext ¶
type BashSpawnHook ¶
type BashSpawnHook func(BashSpawnContext) BashSpawnContext
type BashToolDetails ¶
type BashToolInput ¶
type BashToolOptions ¶
type BashToolOptions struct {
Operations BashOperations
CommandPrefix string
ShellPath string
// ExposeSessionEnvironment exposes current Pi session metadata as PI_*
// environment variables. Default: true.
ExposeSessionEnvironment *bool
SpawnHook BashSpawnHook
}
type DiffResult ¶
type DiffResult struct {
Diff string `json:"diff"`
FirstChangedLine *int `json:"firstChangedLine,omitempty"`
}
func ComputeEditDiff ¶
func ComputeEditDiff(path, oldText, newText, cwd string) (DiffResult, error)
func ComputeEditsDiff ¶
func ComputeEditsDiff(path string, edits []Edit, cwd string) (DiffResult, error)
func GenerateDiffString ¶
func GenerateDiffString(oldContent, newContent string, contextLines int) DiffResult
type EditOperations ¶
type EditOperations interface {
ReadFile(context.Context, string) ([]byte, error)
WriteFile(context.Context, string, string) error
Access(context.Context, string) error
}
EditOperations is the delegation seam for the edit tool.
type EditToolDetails ¶
type EditToolInput ¶
type EditToolOptions ¶
type EditToolOptions struct {
Operations EditOperations
}
type FindGlobOptions ¶
type FindOperations ¶
type FindOperations interface {
Exists(context.Context, string) (bool, error)
Glob(context.Context, string, string, FindGlobOptions) ([]string, error)
}
FindOperations is the delegation seam for remote file discovery.
type FindToolDetails ¶
type FindToolInput ¶
type FindToolOptions ¶
type FindToolOptions struct {
Operations FindOperations
}
type FuzzyMatchResult ¶
type FuzzyMatchResult struct {
Found bool `json:"found"`
Index int `json:"index"`
MatchLength int `json:"matchLength"`
UsedFuzzyMatch bool `json:"usedFuzzyMatch"`
ContentForReplacement string `json:"contentForReplacement"`
}
func FuzzyFindText ¶
func FuzzyFindText(content, oldText string) FuzzyMatchResult
type GrepOperations ¶
type GrepOperations interface {
IsDirectory(context.Context, string) (bool, error)
ReadFile(context.Context, string) (string, error)
}
GrepOperations is the delegation seam for grep file metadata and context reads.
type GrepToolDetails ¶
type GrepToolInput ¶
type GrepToolInput struct {
Pattern string `json:"pattern"`
Path *string `json:"path,omitempty"`
Glob *string `json:"glob,omitempty"`
IgnoreCase *bool `json:"ignoreCase,omitempty"`
Literal *bool `json:"literal,omitempty"`
Context *float64 `json:"context,omitempty"`
Limit *float64 `json:"limit,omitempty"`
}
type GrepToolOptions ¶
type GrepToolOptions struct {
Operations GrepOperations
}
type ImageResizeOptions ¶
type LocalBashOperationsOptions ¶
type LocalBashOperationsOptions struct {
ShellPath string
}
type LsOperations ¶
type LsOperations interface {
Exists(context.Context, string) (bool, error)
Stat(context.Context, string) (LsPathStat, error)
ReadDir(context.Context, string) ([]string, error)
}
LsOperations is the delegation seam for the ls tool.
type LsPathStat ¶
type LsPathStat struct {
Directory bool
}
func (LsPathStat) IsDirectory ¶
func (stat LsPathStat) IsDirectory() bool
type LsToolDetails ¶
type LsToolInput ¶
type LsToolOptions ¶
type LsToolOptions struct {
Operations LsOperations
}
type OutputAccumulator ¶
type OutputAccumulator struct {
// contains filtered or unexported fields
}
OutputAccumulator incrementally retains a bounded decoded tail while preserving the original byte stream if the output crosses either limit.
func NewOutputAccumulator ¶
func NewOutputAccumulator(options ...OutputAccumulatorOptions) *OutputAccumulator
func (*OutputAccumulator) Append ¶
func (output *OutputAccumulator) Append(data []byte) error
func (*OutputAccumulator) CloseTempFile ¶
func (output *OutputAccumulator) CloseTempFile() error
func (*OutputAccumulator) Finish ¶
func (output *OutputAccumulator) Finish() error
func (*OutputAccumulator) LastLineBytes ¶
func (output *OutputAccumulator) LastLineBytes() int
func (*OutputAccumulator) Snapshot ¶
func (output *OutputAccumulator) Snapshot(options ...OutputSnapshotOptions) (OutputSnapshot, error)
type OutputSnapshot ¶
type OutputSnapshotOptions ¶
type OutputSnapshotOptions struct {
PersistIfTruncated bool
}
type PlainTextRenderer ¶
type PlainTextRenderer interface {
RenderCall(args any) string
RenderResult(result agent.AgentToolResult) string
}
PlainTextRenderer is the tool-rendering seam used until the Phase 4 TUI replaces these strings with components.
type ProcessImageOptions ¶
type ProcessImageOptions struct {
AutoResizeImages *bool
ResizeOptions *ImageResizeOptions
}
type ProcessImageResult ¶
type ProcessImageResult struct {
OK bool
Data string
MimeType string
Hints []string
Message string
}
func ProcessImage ¶
func ProcessImage(input []byte, mimeType string, options *ProcessImageOptions) ProcessImageResult
type ReadImageOperations ¶
ReadImageOperations is the optional image-detection extension used by delegated filesystems that cannot be sniffed locally before reading.
type ReadOperations ¶
type ReadOperations interface {
ReadFile(context.Context, string) ([]byte, error)
Access(context.Context, string) error
}
ReadOperations is the delegation seam for the read tool.
type ReadToolDetails ¶
type ReadToolInput ¶
type ReadToolOptions ¶
type ReadToolOptions struct {
Operations ReadOperations
AutoResizeImages *bool
}
type ResizedImage ¶
type ResizedImage struct {
Data string
MimeType string
OriginalWidth int
OriginalHeight int
Width int
Height int
WasResized bool
}
func ResizeImage ¶
func ResizeImage(input []byte, mimeType string, options *ImageResizeOptions) *ResizedImage
type ShellCommandTransport ¶
type ShellCommandTransport string
const ( ShellCommandArgv ShellCommandTransport = "argv" ShellCommandStdin ShellCommandTransport = "stdin" )
type ShellConfig ¶
type ShellConfig struct {
Shell string
Args []string
CommandTransport ShellCommandTransport
}
func GetShellConfig ¶
func GetShellConfig(customShellPath string) (ShellConfig, error)
type ToolsOptions ¶
type ToolsOptions struct {
Read *ReadToolOptions
Bash *BashToolOptions
Edit *EditToolOptions
Write *WriteToolOptions
Grep *GrepToolOptions
Find *FindToolOptions
Ls *LsToolOptions
}
ToolsOptions carries per-tool options for the bundle constructors (upstream core/tools ToolsOptions).
type WriteOperations ¶
type WriteOperations interface {
WriteFile(context.Context, string, string) error
MkdirAll(context.Context, string) error
}
WriteOperations is the delegation seam for the write tool.
type WriteToolInput ¶
type WriteToolOptions ¶
type WriteToolOptions struct {
Operations WriteOperations
}