Documentation
¶
Index ¶
- Constants
- Variables
- func PhasesSummary() string
- func RecoveryGuidance() string
- type APIError
- type APIResponse
- type Agent
- type ClaudeClient
- type Config
- type Content
- type Message
- type Phase
- type PhaseError
- type PhaseManager
- func (pm *PhaseManager) AdvancePhase() (*Phase, error)
- func (pm *PhaseManager) CurrentPhase() *Phase
- func (pm *PhaseManager) GetPhaseNames() []string
- func (pm *PhaseManager) GetState() *State
- func (pm *PhaseManager) HasTransitioned() bool
- func (pm *PhaseManager) IsComplete() bool
- func (pm *PhaseManager) PhaseTransitionTool() ToolExecutor
- func (pm *PhaseManager) ResetTransitionFlag()
- func (pm *PhaseManager) RestoreDiscoveredInfo(info map[string]string)
- func (pm *PhaseManager) RestoreSetupProgress(progress map[string]bool)
- func (pm *PhaseManager) SetPreviousProgress(progress string)
- func (pm *PhaseManager) SkipToPhase(phaseName string) bool
- func (pm *PhaseManager) StateAsContext() string
- func (pm *PhaseManager) UpdateState(results map[string]interface{})
- type PhaseTool
- type ProcessManager
- type State
- type StreamCallback
- type StreamEvent
- type TUIModel
- func (m *TUIModel) GetFinalOutput() string
- func (m *TUIModel) Init() tea.Cmd
- func (m *TUIModel) RequestPermission(program *tea.Program, toolName string, preview string) string
- func (m *TUIModel) RequestPortConflict(program *tea.Program, port int) bool
- func (m *TUIModel) RequestUserInput(program *tea.Program, question string) string
- func (m *TUIModel) SendAborted(program *tea.Program, reason string)
- func (m *TUIModel) SendAgentText(program *tea.Program, text string, streaming bool)
- func (m *TUIModel) SendCompleted(program *tea.Program)
- func (m *TUIModel) SendError(program *tea.Program, err error)
- func (m *TUIModel) SendFatalError(program *tea.Program, err error)
- func (m *TUIModel) SendPhaseChange(program *tea.Program, name, desc string, num, total int)
- func (m *TUIModel) SendRerunConfirm(program *tea.Program, responseCh chan bool)
- func (m *TUIModel) SendSidebarUpdate(program *tea.Program, key, value string)
- func (m *TUIModel) SendThinking(program *tea.Program, thinking bool)
- func (m *TUIModel) SendToolComplete(program *tea.Program, name string, success bool, output string)
- func (m *TUIModel) SendToolStart(program *tea.Program, name, input string)
- func (m *TUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *TUIModel) View() string
- type Tool
- type ToolDefinition
- type ToolExecutor
- type ToolName
- type ToolRegistry
- type Usage
Constants ¶
const ( PhaseTimeout = 15 * time.Minute // Max time per phase APITimeout = 5 * time.Minute // Max time for a single API call ToolTimeout = 3 * time.Minute // Max time for a single tool execution DefaultMaxIterations = 50 // Default max iterations if phase doesn't specify MaxTotalTokens = 500000 // Max total tokens before warning MaxAPIRetries = 3 // Max retries for API errors )
Timeouts
const ( ErrMaxIterations = "exceeded maximum iterations without completing phase" ErrMaxTokens = "exceeded maximum token usage" )
Error messages
Variables ¶
var PhaseCheckCompatibilityPrompt string
var PhaseComplexTestPrompt string
var PhaseConfirmAppStartsPrompt string
var PhaseCreateConfigPrompt string
var PhaseDetectLanguagePrompt string
var PhaseGatherInfoNodejsPrompt string
var PhaseInstrumentSDKPrompt string
var PhaseSimpleTestPrompt string
var PhaseSummaryPrompt string
var SystemPrompt string
Functions ¶
func RecoveryGuidance ¶
func RecoveryGuidance() string
RecoveryGuidance returns a message explaining how to resume after a failure
Types ¶
type APIResponse ¶
type APIResponse struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []Content `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason"` // "end_turn", "tool_use", "max_tokens"
StopSequence *string `json:"stop_sequence"`
Usage Usage `json:"usage"`
}
APIResponse from Claude API
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent orchestrates the AI-powered setup process
func (*Agent) SetTracker ¶
SetTracker sets the analytics tracker for the agent
type ClaudeClient ¶
type ClaudeClient struct {
// contains filtered or unexported fields
}
ClaudeClient handles communication with the Claude API
func NewClaudeClient ¶
func NewClaudeClient(apiKey, model string) (*ClaudeClient, error)
NewClaudeClient creates a new Claude API client
func (*ClaudeClient) CreateMessage ¶
func (c *ClaudeClient) CreateMessage( ctx context.Context, system string, messages []Message, tools []Tool, ) (*APIResponse, error)
CreateMessage sends a message to Claude and returns the response (non-streaming)
func (*ClaudeClient) CreateMessageStreaming ¶
func (c *ClaudeClient) CreateMessageStreaming( ctx context.Context, system string, messages []Message, tools []Tool, callback StreamCallback, ) (*APIResponse, error)
CreateMessageStreaming sends a message to Claude and streams the response
type Config ¶
type Config struct {
APIKey string
Model string
SystemPrompt string
MaxTokens int
WorkDir string
SkipPermissions bool // Skip permission prompts for consequential actions
DisableSandbox bool // Disable fence sandboxing for commands
DisableProgress bool // Don't save or resume from PROGRESS.md
}
Config holds agent configuration
type Content ¶
type Content struct {
Type string `json:"type"` // "text", "tool_use", "tool_result"
Text string `json:"text,omitempty"`
ID string `json:"id,omitempty"` // For tool_use
Name string `json:"name,omitempty"` // For tool_use
Input json.RawMessage `json:"input,omitempty"` // For tool_use
ToolUseID string `json:"tool_use_id,omitempty"` // For tool_result
Content string `json:"content,omitempty"` // For tool_result (as string)
IsError bool `json:"is_error,omitempty"` // For tool_result
}
Content represents a content block in a message
type Message ¶
type Message struct {
Role string `json:"role"` // "user", "assistant"
Content []Content `json:"content"`
}
Message represents a conversation message
type Phase ¶
type Phase struct {
ID string
Name string
Description string
Instructions string
Tools []PhaseTool // Which tools are available in this phase
Required bool // Must complete, or can skip?
MaxIterations int // Max iterations for this phase (0 = use default)
// OnEnter is called when entering this phase, returns additional context to append to instructions
OnEnter func(state *State) string
}
Phase represents a distinct phase in the agent's workflow
type PhaseError ¶
type PhaseError struct {
Phase string `json:"phase"`
Message string `json:"message"`
Fatal bool `json:"fatal"`
}
PhaseError represents an error that occurred during a phase
type PhaseManager ¶
type PhaseManager struct {
// contains filtered or unexported fields
}
PhaseManager manages the agent's progress through phases
func NewPhaseManager ¶
func NewPhaseManager() *PhaseManager
NewPhaseManager creates a new PhaseManager with default phases
func (*PhaseManager) AdvancePhase ¶
func (pm *PhaseManager) AdvancePhase() (*Phase, error)
AdvancePhase moves to the next phase
func (*PhaseManager) CurrentPhase ¶
func (pm *PhaseManager) CurrentPhase() *Phase
CurrentPhase returns the current phase
func (*PhaseManager) GetPhaseNames ¶
func (pm *PhaseManager) GetPhaseNames() []string
GetPhaseNames returns all phase names in order
func (*PhaseManager) GetState ¶
func (pm *PhaseManager) GetState() *State
GetState returns the current state
func (*PhaseManager) HasTransitioned ¶
func (pm *PhaseManager) HasTransitioned() bool
HasTransitioned returns true if a transition occurred this iteration
func (*PhaseManager) IsComplete ¶
func (pm *PhaseManager) IsComplete() bool
IsComplete returns true if all phases are done
func (*PhaseManager) PhaseTransitionTool ¶
func (pm *PhaseManager) PhaseTransitionTool() ToolExecutor
PhaseTransitionTool creates the transition_phase tool executor
func (*PhaseManager) ResetTransitionFlag ¶
func (pm *PhaseManager) ResetTransitionFlag()
ResetTransitionFlag resets the transition flag
func (*PhaseManager) RestoreDiscoveredInfo ¶
func (pm *PhaseManager) RestoreDiscoveredInfo(info map[string]string)
RestoreDiscoveredInfo restores discovered information from parsed progress file
func (*PhaseManager) RestoreSetupProgress ¶
func (pm *PhaseManager) RestoreSetupProgress(progress map[string]bool)
RestoreSetupProgress restores setup progress flags from parsed progress file
func (*PhaseManager) SetPreviousProgress ¶
func (pm *PhaseManager) SetPreviousProgress(progress string)
SetPreviousProgress sets the progress from a previous interrupted run
func (*PhaseManager) SkipToPhase ¶
func (pm *PhaseManager) SkipToPhase(phaseName string) bool
SkipToPhase skips to a specific phase by name, returning true if found
func (*PhaseManager) StateAsContext ¶
func (pm *PhaseManager) StateAsContext() string
StateAsContext returns the current state as a string for the prompt
func (*PhaseManager) UpdateState ¶
func (pm *PhaseManager) UpdateState(results map[string]interface{})
UpdateState updates the state with results from a phase
type PhaseTool ¶
type PhaseTool struct {
Name ToolName
RequiresConfirmation bool // Require user confirmation before executing
CustomTimeout time.Duration // Override default timeout (0 = use default)
}
PhaseTool represents a tool available in a phase with optional configuration
func GetPhaseToolConfig ¶
GetPhaseToolConfig returns the PhaseTool config for a given tool in a phase (for checking confirmation, timeout, etc.)
func Tools ¶
Tools is a helper to create []PhaseTool from ToolName constants (simple case, no config)
func (PhaseTool) WithConfirmation ¶
WithConfirmation returns a copy of the PhaseTool that requires user confirmation
type ProcessManager ¶
type ProcessManager = tools.ProcessManager
ProcessManager wraps the tools.ProcessManager for external access
func NewProcessManager ¶
func NewProcessManager(workDir string) *ProcessManager
NewProcessManager creates a new ProcessManager
func NewProcessManagerWithOptions ¶
func NewProcessManagerWithOptions(workDir string, disableSandbox bool) *ProcessManager
NewProcessManagerWithOptions creates a new ProcessManager with options
type State ¶
type State struct {
// Discovery results
ProjectType string `json:"project_type"` // "nodejs", "python", "go", etc.
PackageManager string `json:"package_manager"` // "npm", "yarn", "pnpm", "pip", etc.
ModuleSystem string `json:"module_system"` // "esm", "cjs" (Node.js specific)
EntryPoint string `json:"entry_point"` // e.g., "src/server.ts", "main.py"
StartCommand string `json:"start_command"` // e.g., "npm run start"
Port string `json:"port"` // e.g., "3000"
HealthEndpoint string `json:"health_endpoint"` // e.g., "/health"
DockerType string `json:"docker_type"` // "none", "dockerfile", "compose"
ServiceName string `json:"service_name"` // e.g., "my-service"
HasExternalCalls bool `json:"has_external_calls"` // Does it make outbound HTTP/DB calls?
// Compatibility check results
CompatibilityWarnings []string `json:"compatibility_warnings"` // e.g., ["mongodb@6.3.0 not instrumented"]
// Progress tracking
AppStartsWithoutSDK bool `json:"app_starts_without_sdk"`
SDKInstalled bool `json:"sdk_installed"`
SDKInstrumented bool `json:"sdk_instrumented"`
ConfigCreated bool `json:"config_created"`
SimpleTestPassed bool `json:"simple_test_passed"`
ComplexTestPassed bool `json:"complex_test_passed"`
// Error tracking
Errors []PhaseError `json:"errors"`
Warnings []string `json:"warnings"`
}
State tracks what the agent has learned and done
type StreamCallback ¶
type StreamCallback func(event StreamEvent)
StreamCallback is called with streaming updates
type StreamEvent ¶
type StreamEvent struct {
Type string // "text", "tool_use_start", "tool_use_input", "done"
Text string
ToolName string
ToolID string
ToolInput string
StopReason string
}
StreamEvent represents a streaming event
type TUIModel ¶
type TUIModel struct {
// contains filtered or unexported fields
}
TUIModel is the bubbletea model for the agent TUI
func NewTUIModel ¶
func NewTUIModel(ctx context.Context, cancel context.CancelFunc) *TUIModel
NewTUIModel creates a new TUI model
func (*TUIModel) GetFinalOutput ¶
GetFinalOutput returns the log content for printing after exit
func (*TUIModel) RequestPermission ¶
RequestPermission asks the user for permission to execute a tool. Returns "approve", "approve_all", or "deny".
func (*TUIModel) RequestPortConflict ¶
func (*TUIModel) RequestUserInput ¶
func (*TUIModel) SendAgentText ¶
func (*TUIModel) SendCompleted ¶
func (*TUIModel) SendFatalError ¶
func (*TUIModel) SendPhaseChange ¶
func (*TUIModel) SendRerunConfirm ¶
func (*TUIModel) SendSidebarUpdate ¶
func (*TUIModel) SendThinking ¶
func (*TUIModel) SendToolComplete ¶
func (*TUIModel) SendToolStart ¶
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema json.RawMessage `json:"input_schema"`
}
Tool defines a tool the agent can use
func FilterToolsForPhase ¶
FilterToolsForPhase filters tool definitions to only those available in the current phase
func RegisterTools ¶
func RegisterTools(workDir string, pm *ProcessManager, phaseMgr *PhaseManager) ([]Tool, map[string]ToolExecutor)
RegisterTools initializes the tool registry with executors and returns API-compatible formats
type ToolDefinition ¶
type ToolDefinition struct {
Name ToolName
Description string
InputSchema json.RawMessage
Executor ToolExecutor // Set at runtime via RegisterTools
RequiresConfirmation bool // Whether this tool requires user confirmation by default
}
ToolDefinition is the single source of truth for a tool's metadata and implementation
type ToolExecutor ¶
type ToolExecutor func(input json.RawMessage) (string, error)
ToolExecutor executes a tool and returns the result
type ToolName ¶
type ToolName string
ToolName is a type-safe identifier for tools
const ( ToolReadFile ToolName = "read_file" ToolWriteFile ToolName = "write_file" ToolListDirectory ToolName = "list_directory" ToolGrep ToolName = "grep" ToolPatchFile ToolName = "patch_file" ToolRunCommand ToolName = "run_command" ToolStartBackgroundProcess ToolName = "start_background_process" ToolStopBackgroundProcess ToolName = "stop_background_process" ToolGetProcessLogs ToolName = "get_process_logs" ToolWaitForReady ToolName = "wait_for_ready" ToolHTTPRequest ToolName = "http_request" ToolAskUser ToolName = "ask_user" ToolTuskList ToolName = "tusk_list" ToolTuskRun ToolName = "tusk_run" ToolTransitionPhase ToolName = "transition_phase" ToolAbortSetup ToolName = "abort_setup" )
Tool name constants - use these instead of raw strings for type safety
func GetToolsForPhase ¶
GetToolsForPhase returns the tool names available for a phase
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
ToolRegistry holds all tool definitions, keyed by name
func GetRegistry ¶
func GetRegistry() *ToolRegistry
GetRegistry returns the global tool registry (available after RegisterTools is called)
func (*ToolRegistry) All ¶
func (r *ToolRegistry) All() []*ToolDefinition
All returns all tool definitions
func (*ToolRegistry) Get ¶
func (r *ToolRegistry) Get(name ToolName) *ToolDefinition
Get returns a tool definition by name