Documentation
¶
Index ¶
- func ValidatePath(workspaceRoot, requestedPath string) (string, error)
- type ApprovalGate
- func (g *ApprovalGate) IsAutoApproved(toolName string) bool
- func (g *ApprovalGate) IsDenied(toolName string) bool
- func (g *ApprovalGate) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
- func (g *ApprovalGate) SetPermissions(autoApprove, deny []string)
- func (g *ApprovalGate) WrapExecution(ctx context.Context, tool Tool, args json.RawMessage) (Result, error)
- type CodeSearchTool
- type FilePatchTool
- type FileReadTool
- type FileWriteTool
- type Preview
- type Previewer
- type Registry
- type Result
- type ShellExecTool
- type Tool
- type ToolSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidatePath ¶ added in v0.4.0
ValidatePath ensures that the requested path resolves to a location within the workspace root. It converts relative paths to absolute, cleans them, evaluates symlinks, and rejects any path that escapes the workspace boundary.
Returns the cleaned absolute path if valid.
Types ¶
type ApprovalGate ¶
type ApprovalGate struct {
OnPresent func(toolName string, args json.RawMessage, preview string) (bool, error)
// contains filtered or unexported fields
}
func NewApprovalGate ¶
func NewApprovalGate() *ApprovalGate
func NewApprovalGateWithPermissions ¶ added in v0.2.0
func NewApprovalGateWithPermissions(autoApprove, deny []string) *ApprovalGate
func (*ApprovalGate) IsAutoApproved ¶ added in v0.2.0
func (g *ApprovalGate) IsAutoApproved(toolName string) bool
func (*ApprovalGate) IsDenied ¶ added in v0.2.0
func (g *ApprovalGate) IsDenied(toolName string) bool
func (*ApprovalGate) RequestApproval ¶
func (g *ApprovalGate) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
func (*ApprovalGate) SetPermissions ¶ added in v0.2.0
func (g *ApprovalGate) SetPermissions(autoApprove, deny []string)
func (*ApprovalGate) WrapExecution ¶
func (g *ApprovalGate) WrapExecution(ctx context.Context, tool Tool, args json.RawMessage) (Result, error)
WrapExecution handles the full preview → approval → execute flow. If the tool implements Previewer, a preview is generated first and shown to the user before execution. Denied operations never call Execute.
type CodeSearchTool ¶ added in v0.4.0
type CodeSearchTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
}
CodeSearchTool searches for patterns across workspace files.
func (*CodeSearchTool) Execute ¶ added in v0.4.0
func (c *CodeSearchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*CodeSearchTool) RequiresApproval ¶ added in v0.4.0
func (c *CodeSearchTool) RequiresApproval() bool
func (*CodeSearchTool) Spec ¶ added in v0.4.0
func (c *CodeSearchTool) Spec() ToolSpec
type FilePatchTool ¶
type FilePatchTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
OnModified func(path string)
}
func (*FilePatchTool) Execute ¶
func (f *FilePatchTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
Execute applies the patch. This is called ONLY after approval.
func (*FilePatchTool) Preview ¶ added in v0.4.0
func (f *FilePatchTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview generates a diff preview of the proposed patch WITHOUT modifying any files. This is called before approval.
func (*FilePatchTool) RequiresApproval ¶
func (f *FilePatchTool) RequiresApproval() bool
func (*FilePatchTool) Spec ¶
func (f *FilePatchTool) Spec() ToolSpec
type FileReadTool ¶
type FileReadTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
}
func (*FileReadTool) Execute ¶
func (f *FileReadTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*FileReadTool) RequiresApproval ¶
func (f *FileReadTool) RequiresApproval() bool
func (*FileReadTool) Spec ¶
func (f *FileReadTool) Spec() ToolSpec
type FileWriteTool ¶
type FileWriteTool struct {
IgnoreMatcher ignore.Matcher
SensitiveMatcher *ignore.SensitiveMatcher
WorkspaceRoot string
OnModified func(path string)
}
func (*FileWriteTool) Execute ¶
func (f *FileWriteTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
Execute writes the file. This is called ONLY after approval.
func (*FileWriteTool) Preview ¶ added in v0.4.0
func (f *FileWriteTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview generates a diff preview of the proposed change WITHOUT modifying any files. This is called before approval.
func (*FileWriteTool) RequiresApproval ¶
func (f *FileWriteTool) RequiresApproval() bool
func (*FileWriteTool) Spec ¶
func (f *FileWriteTool) Spec() ToolSpec
type Preview ¶ added in v0.4.0
type Preview struct {
Description string `json:"description,omitempty"`
Diff string `json:"diff,omitempty"`
Command string `json:"command,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
}
Preview contains the information shown to the user before approval.
type Previewer ¶ added in v0.4.0
Previewer is an optional interface that tools can implement to provide a preview of the proposed change before execution. This enables the approval-before-execution flow where the user sees a diff/command preview and approves before any filesystem changes are made.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
type Result ¶
type ShellExecTool ¶
func (*ShellExecTool) Execute ¶
func (s *ShellExecTool) Execute(ctx context.Context, args json.RawMessage) (Result, error)
func (*ShellExecTool) Preview ¶ added in v0.4.0
func (s *ShellExecTool) Preview(ctx context.Context, args json.RawMessage) (Preview, error)
Preview returns command execution metadata without running the command.
func (*ShellExecTool) RequiresApproval ¶
func (s *ShellExecTool) RequiresApproval() bool
func (*ShellExecTool) Spec ¶
func (s *ShellExecTool) Spec() ToolSpec