Documentation
¶
Index ¶
- func ClassifyIntent(ctx context.Context, p provider.LLMProvider, modelID string, input string, ...) (*m31types.IntentResult, error)
- func ClassifyPrompt(goal string, workDir string) m31types.ComplexityLevel
- func FallbackClassifyIntent(goal string, workDir string) *m31types.IntentResult
- func ParsePlan(markdown string) (*m31types.Plan, error)
- func ShouldStartWorkflow(result *m31types.IntentResult) bool
- func WorkflowModeForComplexity(c m31types.ComplexityLevel) m31types.WorkflowMode
- type DemonstrationReadyMsg
- type DiffStats
- type DiscussCompleteness
- type DiscussCompletenessMsg
- type DiscussIssue
- type DiscussQualityMsg
- type DiscussState
- type Engine
- func (e *Engine) BuildSummary() ShipSummary
- func (e *Engine) CheckDiscussCompleteness() DiscussCompleteness
- func (e *Engine) DiscussState() DiscussState
- func (e *Engine) FinalizeDiscuss() error
- func (e *Engine) GenerateFollowUpsIfNeeded(ctx context.Context) ([]string, error)
- func (e *Engine) HealTask(ctx context.Context, taskID int) (bool, error)
- func (e *Engine) IntentResult() *m31types.IntentResult
- 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) SetIntentResult(ir *m31types.IntentResult)
- func (e *Engine) SetLedger(l *ledger.Ledger)
- 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 ExecuteLoopDetectMsg
- type ExecutePreflightMsg
- type ExecutePreflightResult
- type ExecuteQualityGateMsg
- type InitAnalysisMsg
- type InitPreflightMsg
- type IntermediateProgressMsg
- type MsgEmitter
- type PhaseResult
- type PhaseTransitionCompleteMsg
- type PhaseTransitionStartMsg
- type PlanCheckMsg
- type PlanCheckResult
- type PlanChunkProgressMsg
- type PlanIssue
- type PlanOutline
- type PlanProgressMsg
- type PlanRevisionMsg
- type PreflightCheck
- type ProjectAnalysis
- type PromptRegistry
- type QualityGateResult
- type ResearchProgressMsg
- type SecurityFinding
- type SelfHealCompleteMsg
- type SelfHealStartMsg
- type ShipChangelogMsg
- type ShipPreflightMsg
- type ShipPreflightResult
- type ShipSummary
- type TaskStartMsg
- type TaskStub
- type TaskUpdateMsg
- type ThinkingCompleteMsg
- type ThinkingStartMsg
- type ToolCallTracker
- type ToolCompleteMsg
- type ToolStartMsg
- type VerificationResult
- type VerifyReport
- type VerifyReportMsg
- type VerifyTaskReport
- type WaveOutline
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassifyIntent ¶ added in v1.2.0
func ClassifyIntent(ctx context.Context, p provider.LLMProvider, modelID string, input string, prompts *PromptRegistry) (*m31types.IntentResult, error)
ClassifyIntent uses an LLM to classify the user's input intent. Falls back to the keyword-based ClassifyPrompt on failure or timeout.
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 FallbackClassifyIntent ¶ added in v1.2.0
func FallbackClassifyIntent(goal string, workDir string) *m31types.IntentResult
FallbackClassifyIntent converts the keyword-based ClassifyPrompt result into an IntentResult for consistent downstream handling.
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 ShouldStartWorkflow ¶ added in v1.2.0
func ShouldStartWorkflow(result *m31types.IntentResult) bool
ShouldStartWorkflow returns true when the classified intent warrants a structured workflow (feature, bugfix, refactor, chore) with sufficient confidence (≥ 0.7).
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 DiscussCompleteness ¶ added in v1.2.0
type DiscussCompleteness struct {
Score int // 0-100
Answered int
Skipped int
Total int
MissingAreas []string
}
DiscussCompleteness holds the result of an answer completeness check.
type DiscussCompletenessMsg ¶ added in v1.2.0
DiscussCompletenessMsg is emitted after the answer completeness check.
type DiscussIssue ¶ added in v1.2.0
type DiscussIssue struct {
Severity string // "blocker" or "warning"
Category string // yes_no, vague, duplicate, redundant
Message string
QuestionIndex int
}
DiscussIssue represents a quality issue found in generated questions.
type DiscussQualityMsg ¶ added in v1.2.0
DiscussQualityMsg is emitted after the question quality checker runs.
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) CheckDiscussCompleteness ¶ added in v1.2.0
func (e *Engine) CheckDiscussCompleteness() DiscussCompleteness
CheckDiscussCompleteness evaluates how well the collected answers cover the goal. Called by the TUI after all answers are collected, before proceeding to Plan.
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) GenerateFollowUpsIfNeeded ¶ added in v1.2.0
GenerateFollowUpsIfNeeded creates follow-up questions when answers are incomplete. Called by the TUI after CheckDiscussCompleteness if score is low.
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) IntentResult ¶ added in v1.2.0
func (e *Engine) IntentResult() *m31types.IntentResult
IntentResult returns the stored intent classification result, or nil if unset.
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) SetIntentResult ¶ added in v1.2.0
func (e *Engine) SetIntentResult(ir *m31types.IntentResult)
SetIntentResult stores the LLM-classified intent result for downstream enrichment.
func (*Engine) SetLedger ¶ added in v1.1.0
SetLedger sets the shared ledger instance on the engine so the ship phase writes session records to the application-configured path instead of creating a new ledger at a hardcoded location.
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 ExecuteLoopDetectMsg ¶ added in v1.2.0
ExecuteLoopDetectMsg is emitted when a tool call loop is detected.
type ExecutePreflightMsg ¶ added in v1.2.0
ExecutePreflightMsg is emitted after pre-execution validation.
type ExecutePreflightResult ¶ added in v1.2.0
ExecutePreflightResult holds the outcome of pre-execution validation.
type ExecuteQualityGateMsg ¶ added in v1.2.0
ExecuteQualityGateMsg is emitted after per-task acceptance criteria check.
type InitAnalysisMsg ¶ added in v1.2.0
type InitAnalysisMsg struct {
ProjectType string
Framework string
Language string
DependencyCount int
TestFileRatio float64
FileCount int
HealthScore int // 0-100
}
InitAnalysisMsg is emitted when deep project analysis completes.
type InitPreflightMsg ¶ added in v1.2.0
type InitPreflightMsg struct {
Passed bool
RuntimeVersion string
DiskSpaceOK bool
GitRemoteOK bool
Issues []string
}
InitPreflightMsg is emitted when environment pre-flight checks complete.
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 PlanCheckMsg ¶ added in v1.2.0
PlanCheckMsg is emitted after the plan checker reviews the plan.
type PlanCheckResult ¶ added in v1.2.0
PlanCheckResult holds the outcome of the plan checker review.
type PlanChunkProgressMsg ¶ added in v1.2.0
PlanChunkProgressMsg is emitted during chunked plan generation.
type PlanIssue ¶ added in v1.2.0
type PlanIssue struct {
Severity string // "blocker" or "warning"
Category string // granularity, acceptance, dependency, coverage, alignment, concreteness, security, gap
Message string
TaskID int // 0 if not task-specific
}
PlanIssue represents a single issue found by the plan checker or coverage gates.
type PlanOutline ¶ added in v1.2.0
type PlanOutline struct {
Title string `json:"title"`
Waves []WaveOutline `json:"waves"`
TotalTasks int `json:"total_tasks"`
}
PlanOutline represents the high-level structure of a chunked plan.
type PlanProgressMsg ¶
PlanProgressMsg reports plan generation progress with version info.
type PlanRevisionMsg ¶ added in v1.2.0
PlanRevisionMsg is emitted during each plan revision iteration.
type PreflightCheck ¶ added in v1.2.0
type PreflightCheck struct {
Passed bool
RuntimeVersion string
DiskSpaceOK bool
GitRemoteOK bool
Issues []string
}
PreflightCheck holds the results of environment pre-flight checks.
type ProjectAnalysis ¶ added in v1.2.0
type ProjectAnalysis struct {
ProjectType string
Framework string
Language string
DependencyCount int
TestFileRatio float64
FileCount int
HealthScore int
Details []string
}
ProjectAnalysis holds the results of deep project analysis.
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
Research string
PlanCheck string
PlanRevise string
PlanOutline string
DiscussFollowup string
IntentClassify string
}
PromptRegistry holds all loaded prompt templates.
func LoadPrompts ¶
func LoadPrompts() (*PromptRegistry, error)
LoadPrompts reads all embedded prompt files and returns a registry.
type QualityGateResult ¶ added in v1.2.0
QualityGateResult holds the outcome of checking acceptance criteria against file state.
type ResearchProgressMsg ¶ added in v1.2.0
ResearchProgressMsg is emitted during the pre-plan research sub-step.
type SecurityFinding ¶ added in v1.2.0
type SecurityFinding struct {
Severity string // "high", "medium", "low"
File string
Line int
Pattern string
Message string
}
SecurityFinding holds a security-related finding from scanning task files.
type SelfHealCompleteMsg ¶
SelfHealCompleteMsg is emitted when a self-heal attempt finishes.
type SelfHealStartMsg ¶
SelfHealStartMsg is emitted when a self-heal attempt begins.
type ShipChangelogMsg ¶ added in v1.2.0
ShipChangelogMsg is emitted when the changelog is generated.
type ShipPreflightMsg ¶ added in v1.2.0
ShipPreflightMsg is emitted when the pre-ship checklist runs.
type ShipPreflightResult ¶ added in v1.2.0
ShipPreflightResult holds the outcome of the pre-ship checklist.
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 TaskStub ¶ added in v1.2.0
type TaskStub struct {
ID int `json:"id"`
Action string `json:"action"`
Description string `json:"description"`
Dependencies []int `json:"dependencies"`
Category string `json:"category"`
}
TaskStub is a minimal task representation for the outline phase.
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 ToolCallTracker ¶ added in v1.2.0
type ToolCallTracker struct {
// contains filtered or unexported fields
}
ToolCallTracker tracks tool call patterns across iterations to detect loops.
func NewToolCallTracker ¶ added in v1.2.0
func NewToolCallTracker(maxLoop int) *ToolCallTracker
NewToolCallTracker creates a tracker with the given loop threshold.
func (*ToolCallTracker) Count ¶ added in v1.2.0
func (t *ToolCallTracker) Count() int
Count returns total tool calls recorded.
func (*ToolCallTracker) LastLoopTool ¶ added in v1.2.0
func (t *ToolCallTracker) LastLoopTool() string
LastLoopTool returns the tool name involved in the most recent loop, or empty.
func (*ToolCallTracker) Record ¶ added in v1.2.0
func (t *ToolCallTracker) Record(name, input string) bool
Record adds a tool call to the history and returns true if a loop is detected.
type ToolCompleteMsg ¶
type ToolCompleteMsg struct {
ToolName string
Success bool
DurationMs int64
Error string
FilePath string // populated for file-writing tools (FileWrite, Edit, FileDelete, FileMove)
}
ToolCompleteMsg is emitted when a tool call finishes execution.
type ToolStartMsg ¶
ToolStartMsg is emitted when a tool call begins execution.
type VerificationResult ¶
type VerificationResult struct {
TaskID int
FilesExist bool
SyntaxOK bool
TestsOK bool
Errors []string
}
VerificationResult holds the outcome of verifying a task.
type VerifyReport ¶ added in v1.2.0
type VerifyReport struct {
SessionID string
Timestamp time.Time
Total int
Passed int
Failed int
Skipped int
Results []VerifyTaskReport
Security []SecurityFinding
ManualSteps []string
}
VerifyReport holds the structured verification report.
type VerifyReportMsg ¶ added in v1.2.0
VerifyReportMsg is emitted when the verification report is generated.
type VerifyTaskReport ¶ added in v1.2.0
type VerifyTaskReport struct {
TaskID int
Description string
Status string
FilesExist bool
BuildOK bool
TestsOK bool
Errors []string
Duration time.Duration
}
VerifyTaskReport holds per-task verification results.
type WaveOutline ¶ added in v1.2.0
WaveOutline groups tasks by execution wave.
Source Files
¶
- classify.go
- coverage_gates.go
- discuss.go
- discuss_check.go
- engine.go
- engine_messages.go
- engine_parse.go
- engine_verify.go
- execute.go
- execute_preflight.go
- execute_quality.go
- init_deep.go
- initialize.go
- intent.go
- plan.go
- plan_check.go
- plan_chunk.go
- plan_parser.go
- research.go
- ship.go
- ship_lock_unix.go
- ship_preflight.go
- verify.go
- verify_report.go