build

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package build orchestrates the coding agent integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdvanceStep

func AdvanceStep(db *store.DB, session *SessionState) error

AdvanceStep marks the current step as complete and moves to the next.

func LogActivity

func LogActivity(specID, entry string) error

LogActivity appends an entry to both the SQLite activity log and the session file.

func SaveSession

func SaveSession(db *store.DB, session *SessionState) error

SaveSession persists a session to the database.

func SessionDir

func SessionDir(specID string) string

SessionDir returns the path to the session directory.

func SetActivityDB

func SetActivityDB(db *store.DB)

SetActivityDB sets the database used for activity logging.

func ToolDefinitions

func ToolDefinitions() []map[string]interface{}

ToolDefinitions returns the MCP tool definitions for advertising.

func WriteContextFile

func WriteContextFile(ctx *BuildContext, outputPath string) error

WriteContextFile writes a consolidated context markdown file for non-MCP agents.

Types

type BuildContext

type BuildContext struct {
	SpecPath     string
	SpecContent  string
	PriorDiffs   []string
	FailingTests string
	Conventions  string
	CurrentStep  PRStep
	SystemPrompt string
}

BuildContext is the assembled context payload passed to an agent.

func AssembleContext

func AssembleContext(specPath string, session *SessionState, conventions string) (*BuildContext, error)

AssembleContext builds the full context payload for an agent.

type Engine

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

Engine orchestrates the build process.

func NewEngine

func NewEngine(db *store.DB, agent adapter.AgentAdapter) *Engine

NewEngine creates a new build engine.

func (*Engine) StartOrResume

func (e *Engine) StartOrResume(ctx context.Context, specID, specPath, workDir string) error

StartOrResume begins or continues a build session for a spec.

type MCPResource

type MCPResource struct {
	URI     string `json:"uri"`
	Name    string `json:"name"`
	Content string `json:"content"`
}

MCPResource represents a resource served by the MCP server.

type MCPServer

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

MCPServer serves spec context to MCP-compatible agents. This is a simplified implementation that handles the core resource/tool protocol.

func NewMCPServer

func NewMCPServer(session *SessionState, buildCtx *BuildContext, db *store.DB, specPath string) *MCPServer

NewMCPServer creates a new MCP server for a build session.

func (*MCPServer) CallTool

func (s *MCPServer) CallTool(name string, args json.RawMessage) (*MCPToolResult, error)

CallTool executes an MCP tool.

func (*MCPServer) GetResource

func (s *MCPServer) GetResource(uri string) (*MCPResource, error)

GetResource returns a specific resource by URI.

func (*MCPServer) ListResources

func (s *MCPServer) ListResources() []MCPResource

ListResources returns all available resources.

type MCPToolResult

type MCPToolResult struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

MCPToolResult represents the result of an MCP tool call.

type PRStep

type PRStep struct {
	Number      int    `yaml:"number" json:"number"`
	Repo        string `yaml:"repo" json:"repo"`
	Description string `yaml:"description" json:"description"`
	Branch      string `yaml:"branch" json:"branch"`
	Status      string `yaml:"status" json:"status"` // "pending", "in-progress", "complete"
}

PRStep represents one step in the PR stack plan.

func ParsePRStack

func ParsePRStack(content string) ([]PRStep, error)

ParsePRStack extracts PR steps from the §7.3 PR Stack Plan section.

func ParsePRStackFromFile

func ParsePRStackFromFile(path string) ([]PRStep, error)

ParsePRStackFromFile reads a spec file and extracts PR steps.

type SessionState

type SessionState struct {
	SpecID       string    `json:"spec_id"`
	CurrentStep  int       `json:"current_step"`
	Branch       string    `json:"branch"`
	Repo         string    `json:"repo"`
	WorkDir      string    `json:"work_dir"`
	LastActivity time.Time `json:"last_activity"`
	Steps        []PRStep  `json:"steps"`
}

SessionState persists the build session for `spec do` resume.

func CreateSession

func CreateSession(db *store.DB, specID string, steps []PRStep, workDir string) (*SessionState, error)

CreateSession creates a new build session.

func LoadSession

func LoadSession(db *store.DB, specID string) (*SessionState, error)

LoadSession loads a session from the database.

func (*SessionState) CurrentPRStep

func (s *SessionState) CurrentPRStep() *PRStep

CurrentPRStep returns the current step, or nil if complete.

func (*SessionState) IsComplete

func (s *SessionState) IsComplete() bool

IsComplete returns true if all steps are done.

Jump to

Keyboard shortcuts

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