mode

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mode manages MAXAM operating modes

Package mode manages MAXAM operating modes

Package mode manages MAXAM operating modes

Package mode manages MAXAM operating modes

Index

Constants

View Source
const DefaultPollingInterval = 30 * time.Second

DefaultPollingInterval is the default interval for polling approval status

Variables

View Source
var DefaultIgnoreDirs = []string{
	".git", "node_modules", "vendor", ".venv", "__pycache__",
	"dist", "build", "out", "target", ".next", ".nuxt",
}

DefaultIgnoreDirs are directories to skip during analysis

View Source
var DefaultIgnoreFiles = []string{
	"*.min.js", "*.min.css", "*.map", "*.lock",
}

DefaultIgnoreFiles are file patterns to skip

Functions

func IsCommand

func IsCommand(input string) bool

IsCommand checks if the input starts with a command prefix

Types

type ApprovalNotification

type ApprovalNotification struct {
	IssueNumber int
	ApprovedBy  string
}

ApprovalNotification represents a notification when a plan is approved

type AutoPlanConfig

type AutoPlanConfig struct {
	PollInterval time.Duration
}

AutoPlanConfig holds configuration for AutoPlanHandler

func DefaultAutoPlanConfig

func DefaultAutoPlanConfig() AutoPlanConfig

DefaultAutoPlanConfig returns the default configuration

type AutoPlanHandler

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

AutoPlanHandler manages the automatic plan mode workflow It watches for approval on plan issues and transitions to auto mode when approved

func NewAutoPlanHandler

func NewAutoPlanHandler(
	modeManager *Manager,
	watcher *approval.Watcher,
	poster *approval.QuestionPoster,
) *AutoPlanHandler

NewAutoPlanHandler creates a new AutoPlanHandler

func (*AutoPlanHandler) AskOwnerQuestion

func (h *AutoPlanHandler) AskOwnerQuestion(ctx context.Context, question, agentName string) error

AskOwnerQuestion posts a question to the owner on the current issue

func (*AutoPlanHandler) CheckApproval

func (h *AutoPlanHandler) CheckApproval(ctx context.Context) (bool, string, error)

CheckApproval checks for approval on the current plan Returns true if approved, false otherwise

func (*AutoPlanHandler) PlanIssueNumber

func (h *AutoPlanHandler) PlanIssueNumber() int

PlanIssueNumber returns the current plan issue number

func (*AutoPlanHandler) ReportBlocker

func (h *AutoPlanHandler) ReportBlocker(ctx context.Context, blocker, agentName string) error

ReportBlocker posts a blocker notification to the owner

func (*AutoPlanHandler) SetOnApproved

func (h *AutoPlanHandler) SetOnApproved(fn func(issueNumber int, approvedBy string))

SetOnApproved sets the callback for when a plan is approved

func (*AutoPlanHandler) SetOnTransition

func (h *AutoPlanHandler) SetOnTransition(fn func(from, to config.Mode))

SetOnTransition sets the callback for mode transitions

func (*AutoPlanHandler) StartPlanWorkflow

func (h *AutoPlanHandler) StartPlanWorkflow(ctx context.Context, issueNumber int, planSummary, agentName string) error

StartPlanWorkflow starts the automatic plan workflow 1. Posts the plan to the issue 2. Starts watching for approval 3. When approved, transitions to auto mode

func (*AutoPlanHandler) StartPolling

func (h *AutoPlanHandler) StartPolling(ctx context.Context) <-chan ApprovalNotification

StartPolling starts the polling loop for approval Returns a channel that receives the approval result

func (*AutoPlanHandler) State

func (h *AutoPlanHandler) State() AutoPlanState

State returns the current state

func (*AutoPlanHandler) Stop

func (h *AutoPlanHandler) Stop()

Stop stops the plan workflow and returns to interactive mode

type AutoPlanState

type AutoPlanState string

AutoPlanState represents the state of the auto plan workflow

const (
	// StateIdle means no active plan workflow
	StateIdle AutoPlanState = "idle"
	// StatePlanCreated means a plan has been created and posted
	StatePlanCreated AutoPlanState = "plan_created"
	// StateWaitingApproval means waiting for owner approval
	StateWaitingApproval AutoPlanState = "waiting_approval"
	// StateApproved means the plan has been approved
	StateApproved AutoPlanState = "approved"
	// StateExecuting means the plan is being executed
	StateExecuting AutoPlanState = "executing"
)

type CodeAnalysisResult

type CodeAnalysisResult struct {
	Todos         []TodoItem
	UnusedImports []FileIssue
	LongFiles     []FileIssue
	Summary       string
}

CodeAnalysisResult contains the results of code analysis

type CodeAnalyzer

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

CodeAnalyzer performs static analysis on project code

func NewCodeAnalyzer

func NewCodeAnalyzer(workDir string) *CodeAnalyzer

NewCodeAnalyzer creates a new CodeAnalyzer

func (*CodeAnalyzer) Analyze

func (ca *CodeAnalyzer) Analyze() (*CodeAnalysisResult, error)

Analyze performs code analysis on the project

type Command

type Command string

Command represents a mode-related command

const (
	// CommandPlan enters plan mode
	CommandPlan Command = "/plan"
	// CommandStop stops current mode and returns to interactive
	CommandStop Command = "/stop"
	// CommandStatus shows current mode status
	CommandStatus Command = "/status"
)

type FileIssue

type FileIssue struct {
	File    string
	Message string
}

FileIssue represents an issue found in a specific file

type IssueInfo

type IssueInfo struct {
	Number    int
	Title     string
	CreatedAt time.Time
	Labels    []string
}

IssueInfo contains basic issue information

type Manager

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

Manager manages the current operating mode

func NewManager

func NewManager(defaultMode config.Mode) *Manager

NewManager creates a new mode manager with the given default mode

func (*Manager) AddIssue

func (m *Manager) AddIssue(issueNum int)

AddIssue adds an issue number to the plan context

func (*Manager) Current

func (m *Manager) Current() config.Mode

Current returns the current operating mode

func (*Manager) EnterAutoMode

func (m *Manager) EnterAutoMode(ctx *PlanContext) error

EnterAutoMode transitions to auto mode from plan mode Requires plan approval

func (*Manager) EnterPlanMode

func (m *Manager) EnterPlanMode() error

EnterPlanMode transitions to plan mode from interactive mode

func (*Manager) GetPlanContext

func (m *Manager) GetPlanContext() *PlanContext

GetPlanContext returns the current plan context (nil if not in plan/auto mode)

func (*Manager) IsAuto

func (m *Manager) IsAuto() bool

IsAuto returns true if in auto mode

func (*Manager) IsInteractive

func (m *Manager) IsInteractive() bool

IsInteractive returns true if in interactive mode

func (*Manager) IsPlan

func (m *Manager) IsPlan() bool

IsPlan returns true if in plan mode

func (*Manager) SetPlanApproved

func (m *Manager) SetPlanApproved(approved bool)

SetPlanApproved marks the current plan as approved

func (*Manager) StatusString

func (m *Manager) StatusString() string

StatusString returns a human-readable status string

func (*Manager) Stop

func (m *Manager) Stop()

Stop returns to interactive mode from any mode

type ParseResult

type ParseResult struct {
	IsCommand bool
	Command   Command
	Args      string // remaining text after command
}

ParseResult contains the result of parsing user input for commands

func Parse

func Parse(input string) ParseResult

Parse parses user input and extracts any mode command

type PlanContext

type PlanContext struct {
	DiscussionURL string // URL of approved discussion
	IssueNumbers  []int  // Issue numbers created from the plan
	Approved      bool   // Whether the plan was approved
}

PlanContext stores the context from plan mode

type PlanExecutor

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

PlanExecutor handles plan mode execution

func NewPlanExecutor

func NewPlanExecutor(ghClient *gh.Client, config *PlanModeConfig) *PlanExecutor

NewPlanExecutor creates a new PlanExecutor

func (*PlanExecutor) AnalyzeProject

func (pe *PlanExecutor) AnalyzeProject(ctx context.Context) (*ProjectAnalysis, error)

AnalyzeProject performs a lightweight project analysis

func (*PlanExecutor) CheckApprovalOnce

func (pe *PlanExecutor) CheckApprovalOnce(ctx context.Context, issueNumber int, since time.Time) (*approval.ApprovalResult, error)

CheckApprovalOnce checks for approval without blocking

func (*PlanExecutor) CreatePlanIssue

func (pe *PlanExecutor) CreatePlanIssue(ctx context.Context, analysis *ProjectAnalysis, proposal string) (*PlanIssue, error)

CreatePlanIssue creates an issue with the plan proposal

func (*PlanExecutor) WaitForApproval

func (pe *PlanExecutor) WaitForApproval(ctx context.Context, issueNumber int) (*approval.ApprovalResult, error)

WaitForApproval polls the issue for approval comments

type PlanIssue

type PlanIssue struct {
	IssueNumber int
	Title       string
	Body        string
	CreatedAt   time.Time
	URL         string
}

PlanIssue represents a plan issue created for approval

type PlanModeConfig

type PlanModeConfig struct {
	PollingInterval time.Duration
}

PlanModeConfig holds configuration for plan mode

func DefaultPlanModeConfig

func DefaultPlanModeConfig() *PlanModeConfig

DefaultPlanModeConfig returns the default configuration

type ProjectAnalysis

type ProjectAnalysis struct {
	TotalIssues      int
	OpenIssues       int
	UnassignedIssues int
	OldestOpenIssue  *IssueInfo
	LabelCounts      map[string]int
	Summary          string
}

ProjectAnalysis contains simplified project analysis for plan mode

type TodoItem

type TodoItem struct {
	File    string
	Line    int
	Content string
	Type    string // TODO, FIXME, HACK, XXX
}

TodoItem represents a TODO comment found in code

type TransitionManager

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

TransitionManager manages mode transitions

func NewTransitionManager

func NewTransitionManager(modeManager *Manager, runner *auto.Runner) *TransitionManager

NewTransitionManager creates a new transition manager

func (*TransitionManager) CanTransition

func (t *TransitionManager) CanTransition(from, to config.Mode) bool

CanTransition checks if a transition is valid without performing it

func (*TransitionManager) CurrentMode

func (t *TransitionManager) CurrentMode() config.Mode

CurrentMode returns the current mode

func (*TransitionManager) Runner

func (t *TransitionManager) Runner() *auto.Runner

Runner returns the auto runner

func (*TransitionManager) SetOnError

func (t *TransitionManager) SetOnError(fn func(err error))

SetOnError sets the callback for transition errors

func (*TransitionManager) SetOnTransition

func (t *TransitionManager) SetOnTransition(fn func(from, to config.Mode))

SetOnTransition sets the callback for mode transitions

func (*TransitionManager) Transition

Transition performs a mode transition

func (*TransitionManager) TransitionToAutoAndRun

func (t *TransitionManager) TransitionToAutoAndRun(ctx context.Context, planCtx *PlanContext, issues []auto.IssueInfo) error

TransitionToAutoAndRun transitions to auto mode and starts execution This is a convenience method that combines transition and execution

func (*TransitionManager) ValidTransitions

func (t *TransitionManager) ValidTransitions() []config.Mode

ValidTransitions returns all valid transitions from the current mode

type TransitionRequest

type TransitionRequest struct {
	// From is the expected current mode (optional, for validation)
	From config.Mode
	// To is the target mode
	To config.Mode
	// PlanContext is required when transitioning to auto mode
	PlanContext *PlanContext
	// Issues is the list of issues to execute (for auto mode)
	Issues []auto.IssueInfo
}

TransitionRequest represents a request to transition modes

type TransitionResult

type TransitionResult struct {
	Success bool
	From    config.Mode
	To      config.Mode
	Error   error
}

TransitionResult represents the result of a transition

Jump to

Keyboard shortcuts

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