Documentation
¶
Overview ¶
ABOUTME: Selects the codergen backend (Claude Code, agent, mux) from environment variables. ABOUTME: Used by the web server to configure which LLM backend drives pipeline execution.
ABOUTME: Build run types and SSE event formatting for the attractor pipeline runner. ABOUTME: Provides BuildRun for tracking active builds and RunState for pipeline lifecycle.
ABOUTME: Template-friendly diagnostics view that splits DOT validation results by severity. ABOUTME: Provides error/warning counts and messages for the build UI.
ABOUTME: HTTP handler that auto-fixes DOT graph validation errors using an LLM. ABOUTME: Parses, validates, and rewrites the project DOT via the configured backend.
ABOUTME: Adapter layer connecting the editor package to the unified project-scoped web flow. ABOUTME: Mounts editor handlers under /projects/{projectID}/editor and keeps project DOT in sync.
ABOUTME: Resolves filesystem paths to editor template and static asset directories. ABOUTME: Supports both development (source tree) and installed binary layouts.
ABOUTME: HTTP logging middleware for the unified web server with consistent log.Printf style. ABOUTME: Replaces chi's default logger format to align request logs with agent/runtime logs.
ABOUTME: Configures a default interviewer for wait.human nodes in web builds. ABOUTME: Auto-approves review gates so pipelines run unattended in the web UI.
ABOUTME: Project data model representing a mammoth project through its lifecycle. ABOUTME: Includes ProjectStore for in-memory and filesystem-based persistence.
ABOUTME: Unified mammoth HTTP server providing the wizard flow for Spec Builder, ABOUTME: DOT Editor, and Attractor Pipeline Runner behind a single chi router.
ABOUTME: Adapter layer connecting spec/web handlers to the unified mammoth HTTP server. ABOUTME: Provides middleware for URL translation, lazy spec initialization, and API handlers.
ABOUTME: Spec builder options parsed from form input for pipeline configuration. ABOUTME: Controls toggles like human review, scenario testing, TDD, and complexity level.
ABOUTME: Embeds web/static/ CSS and JS files for serving via the unified HTTP server. ABOUTME: Uses explicit subdirectory globs because //go:embed static/* does not recurse.
ABOUTME: TemplateEngine loads embedded HTML templates and renders them with Go's html/template. ABOUTME: Templates are embedded at compile time via go:embed for zero runtime path issues.
ABOUTME: Transition logic connecting the spec builder phase to the DOT editor and build phases. ABOUTME: Exports DOT from spec state, validates it, and routes to the correct project phase.
Index ¶
- Variables
- func TransitionEditorToBuild(project *Project) error
- func TransitionSpecToBuild(project *Project, specState *core.SpecState) error
- func TransitionSpecToEditor(project *Project, specState *core.SpecState) error
- type BuildRun
- type DiagnosticsView
- type PageData
- type Project
- type ProjectPhase
- type ProjectStore
- type RunState
- type SSEEvent
- type Server
- type ServerConfig
- type TemplateEngine
Constants ¶
This section is empty.
Variables ¶
var StaticFS embed.FS
Functions ¶
func TransitionEditorToBuild ¶
TransitionEditorToBuild validates the current DOT and transitions to build. If the DOT has parse or lint errors, it stays in the edit phase and returns an error. If the DOT is clean, it transitions to the build phase.
func TransitionSpecToBuild ¶
TransitionSpecToBuild is the "Build Now" shortcut that skips the editor. If the DOT has no lint errors, it transitions straight to build phase. If there are lint errors, it transitions to edit phase with diagnostics.
func TransitionSpecToEditor ¶
TransitionSpecToEditor generates DOT from a spec state and updates the project for the editor phase. The DOT is exported, parsed for validation, and linted for diagnostics. The project is always set to the edit phase on success.
Types ¶
type BuildRun ¶
type BuildRun struct {
State *RunState
Events chan SSEEvent
Cancel context.CancelFunc
Ctx context.Context
// contains filtered or unexported fields
}
BuildRun holds all state for an active build, including the cancellation context, SSE event channel, and current RunState.
func (*BuildRun) EnsureFanoutStarted ¶
func (r *BuildRun) EnsureFanoutStarted()
EnsureFanoutStarted starts a background broadcaster that fans Events out to all subscribers. Safe to call multiple times.
func (*BuildRun) HistorySnapshot ¶
HistorySnapshot returns a copy of buffered recent events for replay.
func (*BuildRun) Subscribe ¶
Subscribe registers a subscriber channel that receives all future events. The returned function unsubscribes and closes the channel.
func (*BuildRun) SubscribeWithHistory ¶
SubscribeWithHistory atomically snapshots buffered events and subscribes for future events to avoid replay/stream duplication races.
type DiagnosticsView ¶
type DiagnosticsView struct {
BuildBlocked bool
ErrorCount int
WarningCount int
Errors []string
Warnings []string
Other []string
}
DiagnosticsView provides a template-friendly summary split by severity.
type PageData ¶
type PageData struct {
Title string
Project *Project
Projects []*Project
Mode string // "idea" or "dot" for project_new
ActivePhase string // current wizard phase for highlighting
Diagnostics DiagnosticsView
}
PageData holds all data passed to templates for rendering.
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
Phase ProjectPhase `json:"phase"`
SpecID string `json:"spec_id,omitempty"`
DOT string `json:"dot,omitempty"`
Diagnostics []string `json:"diagnostics,omitempty"`
RunID string `json:"run_id,omitempty"`
DataDir string `json:"-"`
}
Project represents a mammoth project spanning the full wizard flow (Spec -> Edit -> Build).
type ProjectPhase ¶
type ProjectPhase string
ProjectPhase represents the current stage of a project in the wizard flow.
const ( PhaseSpec ProjectPhase = "spec" PhaseEdit ProjectPhase = "edit" PhaseBuild ProjectPhase = "build" PhaseDone ProjectPhase = "done" )
type ProjectStore ¶
type ProjectStore struct {
// contains filtered or unexported fields
}
ProjectStore provides in-memory storage with filesystem persistence for projects.
func NewProjectStore ¶
func NewProjectStore(baseDir string) *ProjectStore
NewProjectStore creates a new ProjectStore rooted at the given base directory.
func (*ProjectStore) Create ¶
func (s *ProjectStore) Create(name string) (*Project, error)
Create makes a new project with the given name. It starts in the spec phase.
func (*ProjectStore) Get ¶
func (s *ProjectStore) Get(id string) (*Project, bool)
Get retrieves a project by ID. Returns a copy of the project and true if found, or nil and false if not found. The copy prevents data races when callers modify the returned project concurrently.
func (*ProjectStore) List ¶
func (s *ProjectStore) List() []*Project
List returns all projects sorted by creation time, newest first. Each returned project is a copy to prevent data races from concurrent mutation.
func (*ProjectStore) LoadAll ¶
func (s *ProjectStore) LoadAll() error
LoadAll reads all project.json files from subdirectories of baseDir and populates the in-memory store.
func (*ProjectStore) Save ¶
func (s *ProjectStore) Save(p *Project) error
Save persists a project to disk as JSON in its data directory. It validates the project ID to prevent path traversal attacks before writing.
func (*ProjectStore) Update ¶
func (s *ProjectStore) Update(p *Project) error
Update replaces the stored project with the provided one. The project must already exist in the store (matched by ID).
type RunState ¶
type RunState struct {
ID string `json:"id"`
Status string `json:"status"` // "running", "completed", "failed", "cancelled"
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
CurrentNode string `json:"current_node"`
CompletedNodes []string `json:"completed_nodes"`
Error string `json:"error,omitempty"`
}
RunState tracks the lifecycle state of a pipeline run within the web layer. It mirrors attractor.RunState fields relevant to the UI.
type SSEEvent ¶
type SSEEvent struct {
Event string // event type (e.g. "pipeline.started", "stage.completed")
Data string // JSON-encoded event data
}
SSEEvent represents a server-sent event ready for formatting and transmission.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the unified mammoth HTTP server that provides the wizard flow: Spec Builder -> DOT Editor -> Attractor Pipeline Runner.
func NewServer ¶
func NewServer(cfg ServerConfig) (*Server, error)
NewServer creates a new Server with the given configuration. It initializes the project store and sets up routing.
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server on the configured address with appropriate timeouts to prevent resource exhaustion from slow clients.
type ServerConfig ¶
type ServerConfig struct {
Addr string // listen address (default: "127.0.0.1:2389")
DataDir string // data directory for projects
}
ServerConfig holds the configuration for the unified web server.
type TemplateEngine ¶
type TemplateEngine struct {
// contains filtered or unexported fields
}
TemplateEngine loads and renders embedded HTML templates.
func NewTemplateEngine ¶
func NewTemplateEngine() (*TemplateEngine, error)
NewTemplateEngine parses all embedded templates and returns a ready-to-use engine. Each page template is parsed together with the layout so that the layout wraps every page.
func (*TemplateEngine) Render ¶
func (e *TemplateEngine) Render(w http.ResponseWriter, name string, data any) error
Render executes the named template with the given data and writes the result to w. It sets the Content-Type header to text/html.