API Reference

The @prodara/compiler package exports 200+ functions and types for programmatic access to the compilation pipeline.

npm install @prodara/compiler

Core Pipeline

Top-level compilation functions.

ExportDescription
compile()Run the full compilation pipeline on a set of .prd files.
runPipeline()Execute a custom subset of compilation phases.
PIPELINE_PHASESOrdered array of all 15 compilation phases.

Graph

Product Graph construction and manipulation.

ExportDescription
buildGraph()Build a Product Graph from a bound and type-checked AST.
serializeGraph()Serialize a Product Graph to JSON.
validateGraph()Validate structural integrity and semantic rules.
ProductGraphType representing the full compiled graph.
ProductNodeA node in the Product Graph with semantic ID.
GraphEdgeA typed edge connecting two graph nodes.

Planning

Incremental change analysis and impact propagation.

ExportDescription
diffGraphs()Compare two Product Graphs and produce a change set.
propagateImpact()Follow graph edges to find downstream impacts.
createPlan()Generate an incremental plan with tasks.

Workflow Execution

Build phase orchestration.

ExportDescription
runWorkflow()Execute the full build workflow.
runReviewers()Execute all review phases.
runSpecTests()Run specification-level tests.

Extensions & Presets

Plugin and preset management.

ExportDescription
ExtensionRegistryRegistry for managing loaded extensions.
loadExtensions()Load extensions from the registry.
installExtension()Install an extension package.
loadPresets()Load constitution presets.
installPreset()Install a preset package.

Lexer & Parser

Low-level compilation primitives.

ExportDescription
LexerTokenizer for .prd source files.
ParserAST builder from token streams.
bind()Create symbol table from AST.
checkTypes()Run type checker on bound AST.
validate()Run semantic validation rules.

Diagnostics

Error and warning management.

ExportDescription
DiagnosticBagAccumulator for compiler diagnostics.
DiagnosticA single diagnostic with code, severity, and location.
formatDiagnostics()Format diagnostics for human or JSON output.

Agent & Prompt Generation

AI agent integration and prompt file generation.

ExportDescription
PHASE_RENDERERSMap of 18 template IDs to render functions for prompt generation.
renderTemplate()Render a prompt template for a specific agent.
renderAllTemplates()Generate the complete prompt content for a target agent platform.
AgentPlatformUnion type of all 26 supported AI agent platforms.
PhaseIdUnion type of all template phase identifiers.

Templates

Prompt template system.

ExportDescription
TemplateContextContext object passed to template renderers.
BuildContextContext for the build command template.
ExploreContextContext for the explore mode template.
PartyContextContext for the party mode template.
DesignContextContext for the design mode template.
OnboardContextContext for the onboard mode template.

Configuration

Compiler configuration management.

ExportDescription
loadConfig()Load configuration from prodara.config.json.
resolveConfig()Resolve configuration with defaults and presets.
DEFAULT_CONFIGBuilt-in default configuration values.
ProdaraConfigType representing the full configuration schema.
WorkflowSchemaType for custom workflow definitions.

Marketplace

Extension and preset marketplace.

ExportDescription
searchMarketplace()Search the Prodara marketplace for extensions.
npmInstall()Install an extension package via npm.
npmRemove()Remove an installed extension package.
MarketplaceEntryType representing a marketplace listing.
MarketplaceCategoryCategory enum for marketplace entries.

Reviewers

Review pipeline and built-in reviewer agents.

ExportDescription
runReviewers()Execute all enabled reviewers against the current build.
runReviewFixLoop()Run the review-fix loop with auto-fix capabilities.
DEFAULT_REVIEWERSArray of 9 built-in reviewer agents.
discoverCustomReviewers()Discover custom reviewer definitions from .prodara/reviewers/.
ReviewerAgentType representing a reviewer agent with perspective and prompt.

Proposals

Change proposal management.

ExportDescription
createProposal()Create a new change proposal in .prodara/changes/.
listProposals()List all active proposals.
applyProposal()Apply an approved proposal to the main specification.
archiveProposal()Archive a proposal without applying it.
ChangeProposalType representing a change proposal with metadata.

Usage Example

build.ts
import { compile } from '@prodara/compiler';

const result = await compile({
  rootDir: './my-project',
  format: 'json',
});

if (result.diagnostics.errors.length > 0) {
  console.error('Compilation failed:', result.diagnostics);
  process.exit(1);
}

// Access the Product Graph
const graph = result.graph;
console.log(`Compiled ${graph.modules.length} modules`);
console.log(`${graph.edges.length} edges in graph`);