API Reference
The @prodara/compiler package exports 200+ functions and types for programmatic access to the compilation pipeline.
npm install @prodara/compilerCore Pipeline
Top-level compilation functions.
| Export | Description |
|---|---|
| compile() | Run the full compilation pipeline on a set of .prd files. |
| runPipeline() | Execute a custom subset of compilation phases. |
| PIPELINE_PHASES | Ordered array of all 15 compilation phases. |
Graph
Product Graph construction and manipulation.
| Export | Description |
|---|---|
| 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. |
| ProductGraph | Type representing the full compiled graph. |
| ProductNode | A node in the Product Graph with semantic ID. |
| GraphEdge | A typed edge connecting two graph nodes. |
Planning
Incremental change analysis and impact propagation.
| Export | Description |
|---|---|
| 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.
| Export | Description |
|---|---|
| runWorkflow() | Execute the full build workflow. |
| runReviewers() | Execute all review phases. |
| runSpecTests() | Run specification-level tests. |
Extensions & Presets
Plugin and preset management.
| Export | Description |
|---|---|
| ExtensionRegistry | Registry 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.
| Export | Description |
|---|---|
| Lexer | Tokenizer for .prd source files. |
| Parser | AST 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.
| Export | Description |
|---|---|
| DiagnosticBag | Accumulator for compiler diagnostics. |
| Diagnostic | A 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.
| Export | Description |
|---|---|
| PHASE_RENDERERS | Map 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. |
| AgentPlatform | Union type of all 26 supported AI agent platforms. |
| PhaseId | Union type of all template phase identifiers. |
Templates
Prompt template system.
| Export | Description |
|---|---|
| TemplateContext | Context object passed to template renderers. |
| BuildContext | Context for the build command template. |
| ExploreContext | Context for the explore mode template. |
| PartyContext | Context for the party mode template. |
| DesignContext | Context for the design mode template. |
| OnboardContext | Context for the onboard mode template. |
Configuration
Compiler configuration management.
| Export | Description |
|---|---|
| loadConfig() | Load configuration from prodara.config.json. |
| resolveConfig() | Resolve configuration with defaults and presets. |
| DEFAULT_CONFIG | Built-in default configuration values. |
| ProdaraConfig | Type representing the full configuration schema. |
| WorkflowSchema | Type for custom workflow definitions. |
Marketplace
Extension and preset marketplace.
| Export | Description |
|---|---|
| searchMarketplace() | Search the Prodara marketplace for extensions. |
| npmInstall() | Install an extension package via npm. |
| npmRemove() | Remove an installed extension package. |
| MarketplaceEntry | Type representing a marketplace listing. |
| MarketplaceCategory | Category enum for marketplace entries. |
Reviewers
Review pipeline and built-in reviewer agents.
| Export | Description |
|---|---|
| runReviewers() | Execute all enabled reviewers against the current build. |
| runReviewFixLoop() | Run the review-fix loop with auto-fix capabilities. |
| DEFAULT_REVIEWERS | Array of 9 built-in reviewer agents. |
| discoverCustomReviewers() | Discover custom reviewer definitions from .prodara/reviewers/. |
| ReviewerAgent | Type representing a reviewer agent with perspective and prompt. |
Proposals
Change proposal management.
| Export | Description |
|---|---|
| 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. |
| ChangeProposal | Type 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`);