tools

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DestructiveCommands = []DestructiveCommand{

	{Pattern: `^\s*rm\s+-rf?\s+`, Description: "Recursive file deletion", RiskLevel: "high"},
	{Pattern: `^\s*rm\s+-fr\s+`, Description: "Recursive file deletion", RiskLevel: "high"},
	{Pattern: `^\s*rm\s+.*\*`, Description: "Wildcard file deletion", RiskLevel: "high"},
	{Pattern: `^\s*rmdir\s+.*/`, Description: "Directory deletion", RiskLevel: "high"},
	{Pattern: `^\s*dd\s+`, Description: "Disk/device manipulation", RiskLevel: "high"},
	{Pattern: `^\s*mv\s+.*\s+/dev/null`, Description: "Redirect to /dev/null", RiskLevel: "high"},
	{Pattern: `^\s*>\s+.*`, Description: "File truncation/overwrite", RiskLevel: "high"},

	{Pattern: `^\s*git\s+checkout\s+`, Description: "Git checkout (potential data loss)", RiskLevel: "medium"},
	{Pattern: `^\s*git\s+reset\s+--hard`, Description: "Hard git reset", RiskLevel: "medium"},
	{Pattern: `^\s*git\s+clean\s+-fd`, Description: "Git clean with force", RiskLevel: "medium"},
	{Pattern: `^\s*chmod\s+[0-7]{3,4}\s+`, Description: "File permission changes", RiskLevel: "medium"},
	{Pattern: `^\s*chown\s+`, Description: "File ownership changes", RiskLevel: "medium"},

	{Pattern: `^\s*kill\s+`, Description: "Process termination", RiskLevel: "low"},
	{Pattern: `^\s*pkill\s+`, Description: "Process termination by name", RiskLevel: "low"},
	{Pattern: `^\s*reboot\s+`, Description: "System reboot", RiskLevel: "low"},
	{Pattern: `^\s*shutdown\s+`, Description: "System shutdown", RiskLevel: "low"},
}

DestructiveCommands is a list of patterns that match potentially destructive commands

Functions

func AddBulkTodos

func AddBulkTodos(todos []struct {
	Title       string
	Description string
	Priority    string
}) string

AddBulkTodos adds multiple todo items at once

func AddTodo

func AddTodo(title, description, priority string) string

AddTodo adds a new todo item

func AnalyzeImage

func AnalyzeImage(imagePath string, analysisPrompt string, analysisMode string) (string, error)

AnalyzeImage is the tool function called by the agent for image analysis

func ArchiveCompleted

func ArchiveCompleted() string

ArchiveCompleted removes completed todos from active memory to reduce context bloat

func AskUser

func AskUser(question string) (string, error)

AskUser prompts the user with a question and reads input from stdin.

func ClearLastVisionUsage

func ClearLastVisionUsage()

ClearLastVisionUsage clears the stored vision usage information

func ClearTodos

func ClearTodos() string

ClearTodos clears all todos (for new sessions)

func EditFile

func EditFile(ctx context.Context, filePath, oldString, newString string) (string, error)

func ExecuteShellCommand

func ExecuteShellCommand(ctx context.Context, command string) (string, error)

ExecuteShellCommand executes a shell command with safety checks

func ExecuteShellCommandWithSafety added in v0.7.0

func ExecuteShellCommandWithSafety(ctx context.Context, command string, interactiveMode bool, sessionID string) (string, error)

ExecuteShellCommandWithSafety executes a shell command with configurable safety checks

func FetchURL

func FetchURL(url string, cfg *configuration.Manager) (string, error)

FetchURL fetches content from a specific URL using the webcontent fetcher. This provides direct URL access as an agent tool.

func FindTodoIDByTitle added in v0.8.3

func FindTodoIDByTitle(title string) (string, bool)

FindTodoIDByTitle performs a case-insensitive exact title match and returns the ID if found.

func GetActiveTodosCompact

func GetActiveTodosCompact() string

GetActiveTodosCompact returns minimal format focused on current work

func GetCommandRiskLevel added in v0.7.0

func GetCommandRiskLevel(command string) string

GetCommandRiskLevel returns the risk level of a command

func GetCompletedTasks

func GetCompletedTasks() []string

GetCompletedTasks returns a list of completed task descriptions for session continuity

func GetNextTodo

func GetNextTodo() string

GetNextTodo returns the next logical todo based on current state

func GetTaskSummary

func GetTaskSummary() string

GetTaskSummary generates a markdown summary of completed work

func GetTodoListMarkdown added in v0.6.0

func GetTodoListMarkdown() string

GetTodoListMarkdown returns a markdown-formatted todo list for UI display

func GetVisionCacheStats

func GetVisionCacheStats() map[string]interface{}

GetVisionCacheStats returns statistics about vision result caching

func GetVisionModelForProvider added in v0.8.3

func GetVisionModelForProvider(providerType api.ClientType) string

GetVisionModelForProvider returns the appropriate vision model for a given provider

func HasVisionCapability

func HasVisionCapability() bool

HasVisionCapability checks if vision processing is available

func IsFileDeletionCommand added in v0.7.0

func IsFileDeletionCommand(command string) bool

IsFileDeletionCommand checks if a command will delete files

func ListAllTodos

func ListAllTodos() string

ListAllTodos returns verbose format when full context is needed

func ListTodos

func ListTodos() string

ListTodos returns a markdown-formatted list of all todos for UI display

func ReadFile

func ReadFile(ctx context.Context, filePath string) (string, error)

func ReadFileWithRange

func ReadFileWithRange(ctx context.Context, filePath string, startLine, endLine int) (string, error)

func UpdateTodoStatus

func UpdateTodoStatus(id, status string) string

UpdateTodoStatus updates the status of a todo item

func UpdateTodoStatusBulk

func UpdateTodoStatusBulk(updates []struct {
	ID     string
	Status string
}) string

UpdateTodoStatusBulk updates multiple todos at once to reduce tool calls

func ValidateBuild added in v0.6.0

func ValidateBuild() (string, error)

ValidateBuild runs project-specific build validation commands

func WebSearch

func WebSearch(query string, cfg *configuration.Manager) (string, error)

WebSearch performs a web search and returns raw search results. The agent can then decide which URLs to fetch and process.

func WriteFile

func WriteFile(ctx context.Context, filePath, content string) (string, error)

Types

type DestructiveCommand added in v0.7.0

type DestructiveCommand struct {
	Pattern     string
	Description string
	RiskLevel   string // "high", "medium", "low"
}

DestructiveCommand represents a potentially destructive command

func IsDestructiveCommand added in v0.7.0

func IsDestructiveCommand(command string) (*DestructiveCommand, bool)

IsDestructiveCommand checks if a command is potentially destructive

type RollbackResult added in v0.8.3

type RollbackResult struct {
	Output   string
	Metadata map[string]interface{}
	Success  bool
}

RollbackResult captures the output, metadata, and success state for rollback operations.

func RollbackChanges added in v0.8.3

func RollbackChanges(revisionID string, filePath string, confirm bool) (RollbackResult, error)

RollbackChanges previews or performs a rollback for a revision or file.

type TodoItem

type TodoItem struct {
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description,omitempty"`
	Status      string    `json:"status"`             // pending, in_progress, completed, cancelled
	Priority    string    `json:"priority,omitempty"` // high, medium, low
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

TodoItem represents a single todo item

type TodoManager

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

TodoManager manages the todo list for the current session

type UIElement

type UIElement struct {
	Type        string `json:"type"`             // button, input, text, etc.
	Description string `json:"description"`      // what it looks like
	Position    string `json:"position"`         // approximate location
	Issues      string `json:"issues,omitempty"` // any problems noted
}

UIElement represents a UI element detected in an image

type ViewHistoryResult added in v0.8.3

type ViewHistoryResult struct {
	Output   string
	Metadata map[string]interface{}
}

ViewHistoryResult captures the output and metadata for history views.

func ViewHistory added in v0.8.3

func ViewHistory(limit int, fileFilter string, since *time.Time, showContent bool) (ViewHistoryResult, error)

ViewHistory returns a formatted history view based on the provided filters.

type VisionAnalysis

type VisionAnalysis struct {
	ImagePath   string      `json:"image_path"`
	Description string      `json:"description"`
	Elements    []UIElement `json:"elements,omitempty"`
	Issues      []string    `json:"issues,omitempty"`
	Suggestions []string    `json:"suggestions,omitempty"`
}

VisionAnalysis represents the result of vision model analysis

type VisionProcessor

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

VisionProcessor handles image analysis using vision-capable models

func NewVisionProcessorWithMode

func NewVisionProcessorWithMode(debug bool, mode string) (*VisionProcessor, error)

NewVisionProcessorWithMode creates a vision processor optimized for specific analysis mode

func NewVisionProcessorWithProvider added in v0.8.3

func NewVisionProcessorWithProvider(debug bool, providerType api.ClientType) (*VisionProcessor, error)

NewVisionProcessorWithProvider creates a vision processor using the specified provider

func (*VisionProcessor) ProcessImagesInText

func (vp *VisionProcessor) ProcessImagesInText(text string) (string, []VisionAnalysis, error)

ProcessImagesInText detects images in text and processes them with vision models

type VisionUsageInfo

type VisionUsageInfo struct {
	PromptTokens     int     `json:"prompt_tokens"`
	CompletionTokens int     `json:"completion_tokens"`
	TotalTokens      int     `json:"total_tokens"`
	EstimatedCost    float64 `json:"estimated_cost"`
}

VisionUsageInfo contains token usage and cost information from vision model calls

func GetLastVisionUsage

func GetLastVisionUsage() *VisionUsageInfo

GetLastVisionUsage returns the usage information from the last vision model call

Jump to

Keyboard shortcuts

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