Documentation
¶
Overview ¶
Package build orchestrates the coding agent integration.
Index ¶
- func AdvanceStep(db *store.DB, session *SessionState) error
- func LogActivity(specID, entry string) error
- func SaveSession(db *store.DB, session *SessionState) error
- func SessionDir(specID string) string
- func SetActivityDB(db *store.DB)
- func ToolDefinitions() []map[string]interface{}
- func WriteContextFile(ctx *BuildContext, outputPath string) error
- type BuildContext
- type Engine
- type MCPResource
- type MCPServer
- type MCPToolResult
- type Options
- type PRStep
- type SessionState
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 ¶
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 ¶
SessionDir returns the path to the session directory.
func SetActivityDB ¶
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
// Skills holds the resolved skill bodies (Agent Skills markdown). Empty
// when no skills are present under .spec/agent/skills/ or in config.
Skills []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 (*Engine) StartOrResume ¶
StartOrResume begins or continues a build session for a spec. It walks the PR stack one step at a time, automatically moving into each step's target repository (via configured workspaces) so a multi-repo spec can be executed end-to-end. It advances to the next step only when the current one is completed (via MCP or the interactive prompt); if a step is left unfinished it stops so the user can resume later with `spec do`.
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 ¶
MCPToolResult represents the result of an MCP tool call.
type Options ¶ added in v0.15.0
type Options struct {
// Headless runs the agent autonomously (e.g. `spec fix --auto`).
Headless bool
// SkillRefs are explicit skill paths from config
// (integrations.agent.settings.skill). They take precedence over
// profile.yaml refs and the .spec/agent/skills/ directory.
SkillRefs []string
// TestCommand, when set, is run to populate FailingTests (best-effort).
TestCommand string
// Workspaces maps a PR-step repo name to a local directory, letting the
// engine move into the right repo for each step of a multi-repo build.
Workspaces map[string]string
}
Options configures a build engine beyond its adapters.
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"
// BaseRef is the commit the step branch was created from. Used to capture
// the step's diff for cumulative cross-step context.
BaseRef string `yaml:"base_ref" json:"base_ref,omitempty"`
}
PRStep represents one step in the PR stack plan.
func ParsePRStack ¶
ParsePRStack extracts PR steps from the §7.3 PR Stack Plan section.
func ParsePRStackFromFile ¶
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.