Documentation
¶
Index ¶
- func ClassifyPrompt(goal string, workDir string) m31types.ComplexityLevel
- func ParsePlan(markdown string) (*m31types.Plan, error)
- func WorkflowModeForComplexity(c m31types.ComplexityLevel) m31types.WorkflowMode
- type DemonstrationReadyMsg
- type DiffStats
- type DiscussState
- type Engine
- func (e *Engine) BuildSummary() ShipSummary
- func (e *Engine) DiscussState() DiscussState
- func (e *Engine) FinalizeDiscuss() error
- func (e *Engine) HealTask(ctx context.Context, taskID int) (bool, error)
- func (e *Engine) PlanContent() string
- func (e *Engine) PlanVersion() int
- func (e *Engine) RunPhase(ctx context.Context, phase m31types.WorkflowPhase, goal string) (*PhaseResult, error)
- func (e *Engine) SessionID() string
- func (e *Engine) SetGit(g *git.Git)
- func (e *Engine) SetModel(modelID string, p provider.LLMProvider)
- func (e *Engine) SetMsgEmitter(em MsgEmitter)
- func (e *Engine) SetPhaseModel(phase m31types.WorkflowPhase, modelID string)
- func (e *Engine) SetRefinementFeedback(feedback string)
- func (e *Engine) SetSessionID(id string)
- func (e *Engine) SetWorkflowMode(mode m31types.WorkflowMode)
- func (e *Engine) SkipDiscuss() error
- func (e *Engine) SubmitDiscussAnswer(index int, answer string) error
- func (e *Engine) Transition(ctx context.Context, from, to m31types.WorkflowPhase) error
- func (e *Engine) WorkflowMode() m31types.WorkflowMode
- type EngineOptions
- type IntermediateProgressMsg
- type MsgEmitter
- type PhaseResult
- type PhaseTransitionCompleteMsg
- type PhaseTransitionStartMsg
- type PlanProgressMsg
- type PromptRegistry
- type SelfHealCompleteMsg
- type SelfHealStartMsg
- type ShipSummary
- type TaskStartMsg
- type TaskUpdateMsg
- type ThinkingCompleteMsg
- type ThinkingStartMsg
- type ToolCompleteMsg
- type ToolStartMsg
- type VerificationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassifyPrompt ¶
func ClassifyPrompt(goal string, workDir string) m31types.ComplexityLevel
ClassifyPrompt estimates the complexity of a user's goal using heuristics. Factors considered:
- Keyword/phrase matching
- Goal length and sentence count
- Number of existing project files (proxy for project size)
func ParsePlan ¶
ParsePlan extracts a structured Plan from rich markdown content. The markdown is expected to follow the format defined in plan-format.md. Sections that cannot be parsed are left empty rather than causing an error.
func WorkflowModeForComplexity ¶
func WorkflowModeForComplexity(c m31types.ComplexityLevel) m31types.WorkflowMode
WorkflowModeForComplexity maps complexity to a workflow mode. ModeAuto delegates to this mapping.
Types ¶
type DemonstrationReadyMsg ¶
type DemonstrationReadyMsg struct {
Content string
}
DemonstrationReadyMsg carries the generated demonstration content to the TUI.
type DiffStats ¶
type DiffStats struct {
FilesAdded int
FilesModified int
FilesDeleted int
Insertions int
Deletions int
}
DiffStats holds file change statistics from git diff.
type DiscussState ¶
DiscussState holds the questions and collected answers for the discuss phase.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine orchestrates the six-phase workflow.
func NewEngine ¶
func NewEngine(sessionID, workDir, backupDir, planningDir string, p provider.LLMProvider, modelID string, dispatcher *tools.Dispatcher, tokenEst *tokens.Estimator, sessionMgr *session.Manager, cfg *config.Config) (*Engine, error)
NewEngine creates a workflow engine.
func NewEngineFromOptions ¶
func NewEngineFromOptions(opts EngineOptions) (*Engine, error)
NewEngineFromOptions creates a workflow engine from an EngineOptions struct.
func (*Engine) BuildSummary ¶
func (e *Engine) BuildSummary() ShipSummary
BuildSummary creates a ShipSummary from the current session state.
func (*Engine) DiscussState ¶
func (e *Engine) DiscussState() DiscussState
DiscussState returns a copy of the current discuss state. The TUI uses this to read the parsed questions after the discuss phase returns. The returned struct is a value copy so mutations by the TUI do not affect the engine's internal state.
func (*Engine) FinalizeDiscuss ¶
func (*Engine) HealTask ¶
HealTask triggers self-healing for a specific task by ID. Returns true if healing was attempted, false if the task cannot be healed.
func (*Engine) PlanContent ¶
PlanContent returns the current plan markdown content.
func (*Engine) PlanVersion ¶
PlanVersion returns the current plan version number. Version 1 is the initial plan; each refinement increments it.
func (*Engine) RunPhase ¶
func (e *Engine) RunPhase(ctx context.Context, phase m31types.WorkflowPhase, goal string) (*PhaseResult, error)
RunPhase executes the given workflow phase and returns the result.
func (*Engine) SetGit ¶
SetGit sets the git instance on the engine. Required before running any phase that uses git operations.
func (*Engine) SetModel ¶
func (e *Engine) SetModel(modelID string, p provider.LLMProvider)
SetModel updates the active model ID and provider for the engine.
func (*Engine) SetMsgEmitter ¶
func (e *Engine) SetMsgEmitter(em MsgEmitter)
SetMsgEmitter sets the callback for emitting messages back to the TUI.
func (*Engine) SetPhaseModel ¶
func (e *Engine) SetPhaseModel(phase m31types.WorkflowPhase, modelID string)
SetPhaseModel assigns a model ID to a specific workflow phase. This takes the highest priority over AgentsConfig and cfg.Model.Default. Called by the TUI after the user selects Planning/Coding models in the picker.
func (*Engine) SetRefinementFeedback ¶
SetRefinementFeedback stores user feedback for the next plan regeneration. The plan phase reads this field to inject feedback into the LLM context. Duplicate feedback is ignored — only new feedback bumps the plan version.
func (*Engine) SetSessionID ¶
SetSessionID updates the engine's session ID.
func (*Engine) SetWorkflowMode ¶
func (e *Engine) SetWorkflowMode(mode m31types.WorkflowMode)
SetWorkflowMode sets the mode that controls phase-skipping behaviour.
func (*Engine) SkipDiscuss ¶
SkipDiscuss fills default (empty) answers and saves.
func (*Engine) SubmitDiscussAnswer ¶
SubmitDiscussAnswer records an answer for a discuss question.
func (*Engine) Transition ¶
Transition saves a checkpoint and writes STATE.md for the new phase. Validates the transition is allowed by the phase ordering guard.
func (*Engine) WorkflowMode ¶
func (e *Engine) WorkflowMode() m31types.WorkflowMode
WorkflowMode returns the current workflow mode.
type EngineOptions ¶
type EngineOptions struct {
SessionID string
WorkDir string
BackupDir string
PlanningDir string
Provider provider.LLMProvider
ModelID string
Dispatcher *tools.Dispatcher
TokenEst *tokens.Estimator
SessionMgr *session.Manager
Config *config.Config
}
EngineOptions holds all parameters for creating a new Engine.
type IntermediateProgressMsg ¶
IntermediateProgressMsg is emitted during long operations to show progress.
type MsgEmitter ¶
type MsgEmitter interface {
Emit(msg any)
}
MsgEmitter is a callback interface for emitting events back to the TUI. Uses `any` to avoid coupling the workflow to the Bubble Tea framework.
type PhaseResult ¶
type PhaseResult struct {
Phase m31types.WorkflowPhase
Success bool
Messages []m31types.Message
Tasks []m31types.Task
Error string
DurationMs int64
NeedsAnswers bool
RequiresManualInput bool
WorkflowMode m31types.WorkflowMode // mode to use for subsequent transitions
// Execution metrics (populated by Execute/Ship phases)
Usage *m31types.Usage // token usage from LLM calls
Cost float64 // estimated cost
ToolCalls int // number of tool calls made
Commits []git.CommitInfo // commits created during phase
DiffStats DiffStats // file change statistics (Ship phase)
// Manual verification steps from the plan (populated by Verify phase)
ManualVerificationSteps []string
// Demonstration content (populated by Ship phase)
Demonstration string
}
PhaseResult holds the outcome of a workflow phase.
type PhaseTransitionCompleteMsg ¶
PhaseTransitionCompleteMsg is emitted when a phase transition completes.
type PhaseTransitionStartMsg ¶
PhaseTransitionStartMsg is emitted when a phase transition begins.
type PlanProgressMsg ¶
PlanProgressMsg reports plan generation progress with version info.
type PromptRegistry ¶
type PromptRegistry struct {
Base string
ToolUse string
PlanFormat string
ExecuteTask string
Discuss string
SelfHeal string
Demonstration string
Autonomous string
ContextAwareness string
CodeQuality string
CodeIntelligence string
}
PromptRegistry holds all loaded prompt templates.
func LoadPrompts ¶
func LoadPrompts() (*PromptRegistry, error)
LoadPrompts reads all embedded prompt files and returns a registry.
type SelfHealCompleteMsg ¶
SelfHealCompleteMsg is emitted when a self-heal attempt finishes.
type SelfHealStartMsg ¶
SelfHealStartMsg is emitted when a self-heal attempt begins.
type ShipSummary ¶
type ShipSummary struct {
TaskDone int
TaskTotal int
TaskFailed int
TaskSkipped int
Commits []git.CommitInfo
Duration time.Duration
SessionID string
}
ShipSummary holds the session completion summary.
type TaskStartMsg ¶
TaskStartMsg is emitted when a task begins execution.
type TaskUpdateMsg ¶
TaskUpdateMsg is emitted when a task status changes during execution.
type ThinkingCompleteMsg ¶
type ThinkingCompleteMsg struct {
Context string
}
ThinkingCompleteMsg is emitted when LLM processing ends.
type ThinkingStartMsg ¶
type ThinkingStartMsg struct {
Context string
}
ThinkingStartMsg is emitted when LLM processing begins.
type ToolCompleteMsg ¶
ToolCompleteMsg is emitted when a tool call finishes execution.
type ToolStartMsg ¶
ToolStartMsg is emitted when a tool call begins execution.