workflow

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

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

func ParsePlan(markdown string) (*m31types.Plan, error)

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

type DiscussState struct {
	Questions []string
	Answers   map[int]string
}

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 (e *Engine) FinalizeDiscuss() error

func (*Engine) HealTask

func (e *Engine) HealTask(ctx context.Context, taskID int) (bool, error)

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

func (e *Engine) PlanContent() string

PlanContent returns the current plan markdown content.

func (*Engine) PlanVersion

func (e *Engine) PlanVersion() int

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) SessionID

func (e *Engine) SessionID() string

SessionID returns the current session ID.

func (*Engine) SetGit

func (e *Engine) SetGit(g *git.Git)

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

func (e *Engine) SetRefinementFeedback(feedback string)

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

func (e *Engine) SetSessionID(id string)

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

func (e *Engine) SkipDiscuss() error

SkipDiscuss fills default (empty) answers and saves.

func (*Engine) SubmitDiscussAnswer

func (e *Engine) SubmitDiscussAnswer(index int, answer string) error

SubmitDiscussAnswer records an answer for a discuss question.

func (*Engine) Transition

func (e *Engine) Transition(ctx context.Context, from, to m31types.WorkflowPhase) error

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

type IntermediateProgressMsg struct {
	Phase   string
	Message string
}

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

type PhaseTransitionCompleteMsg struct {
	From    string
	To      string
	Success bool
	Error   string
}

PhaseTransitionCompleteMsg is emitted when a phase transition completes.

type PhaseTransitionStartMsg

type PhaseTransitionStartMsg struct {
	From    string
	To      string
	Context string
}

PhaseTransitionStartMsg is emitted when a phase transition begins.

type PlanProgressMsg

type PlanProgressMsg struct {
	Version int
	Message string
}

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

type SelfHealCompleteMsg struct {
	TaskID  int
	Attempt int
	Max     int
	Success bool
	Error   string
}

SelfHealCompleteMsg is emitted when a self-heal attempt finishes.

type SelfHealStartMsg

type SelfHealStartMsg struct {
	TaskID  int
	Attempt int
	Max     int
}

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

type TaskStartMsg struct {
	Task m31types.Task
}

TaskStartMsg is emitted when a task begins execution.

type TaskUpdateMsg

type TaskUpdateMsg struct {
	Task   m31types.Task
	Status string
}

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

type ToolCompleteMsg struct {
	ToolName   string
	Success    bool
	DurationMs int64
	Error      string
}

ToolCompleteMsg is emitted when a tool call finishes execution.

type ToolStartMsg

type ToolStartMsg struct {
	ToolName    string
	Description string
}

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.

Jump to

Keyboard shortcuts

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