npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@specverse/engine-realize

v4.0.4

Published

SpecVerse realize engine — generate code from specifications

Downloads

833

Readme

@specverse/engine-realize

Generate production-ready code from SpecVerse specifications using instance factories and manifests.

Purpose

The realize engine is the final stage of the SpecVerse pipeline. It takes an inferred specification and a manifest (which declares technology choices) and produces runnable code: Fastify routes, Prisma schemas, React components, CLI commands, VSCode extensions, MCP servers, tools (MCP server, VSCode extension), and project scaffolding. L3 behavior generation (step-conventions, behavior-generator) produces preconditions, postconditions, and events from Quint specs. Code generation is driven by instance factories -- pluggable template modules organized by concern (ORM, controllers, views, etc.) -- resolved against manifest capability declarations.

Installation

npm install @specverse/engine-realize

Dependencies

| Package | Why | |---------|-----| | @specverse/types | Shared type definitions (RealizeEngine, GeneratedOutput, etc.) | | @specverse/engine-parser | Parsed AST structures used as input | | @specverse/engine-generators | AI view optimization for code generation context | | ajv / ajv-formats | JSON Schema validation of manifests and instance factories | | glob | File discovery for instance factory loading | | js-yaml / yaml | YAML parsing for manifests and specs | | semver | Version constraint matching for manifest resolution |

Key Exports

| Export | Type | Description | |--------|------|-------------| | InstanceFactoryLibrary | class | Discovers and indexes all available instance factories | | createDefaultLibrary | function | Creates an InstanceFactoryLibrary with built-in factories | | createResolver | function | Creates a resolver that matches manifest capabilities to factories | | createCodeGenerator | function | Creates the template-based code generator | | loadManifest | function | Loads and validates a manifest YAML file | | engine | instance | Pre-configured engine adapter for EngineRegistry discovery | | SpecVerseRealizeEngine | class | Full realize pipeline: resolve, generate, copy assets |

Usage

import { createDefaultLibrary, createResolver, createCodeGenerator } from '@specverse/engine-realize';
import { loadManifest } from '@specverse/engine-realize';

const library = await createDefaultLibrary(process.cwd());
const manifest = loadManifest('./manifest.yaml');
const resolver = createResolver(library, manifest);
const codeGen = createCodeGenerator();

// Resolve a capability to its instance factory
const ormResolved = resolver.resolveCapability('orm.schema');

// Generate code from a template
const output = await codeGen.generateFromTemplate(
  ormResolved, 'schema', { spec, models }, { outputDir: './output' }
);
// output.code contains generated source, output.filePath is the target path

Architecture

src/
├── engines/                     # Code generation engines
│   ├── code-generator.ts        #   Template-based code generator
│   ├── engine-registry.ts       #   Engine discovery and registration
│   ├── typescript-engine.ts     #   TypeScript-specific generation
│   ├── step-conventions.ts      #   L3 behavior step convention processing
│   └── behavior-generator.ts    #   L3 behavior generation (pre/postconditions, events)
├── library/                     # Instance factory system
│   ├── library.ts               #   Factory discovery and indexing
│   ├── resolver.ts              #   Manifest → factory resolution
│   ├── loader.ts                #   Factory file loading
│   └── validator.ts             #   Factory and manifest validation
├── types/                       # Type definitions
│   ├── instance-factory.ts      #   InstanceFactory, TemplateContext types
│   └── unified-mappings.ts      #   Cross-concern mapping types
├── utils/                       # Utilities
│   ├── manifest-loader.ts       #   YAML manifest loading
│   ├── ai-spec-loader.ts        #   AI-optimized spec loading
│   └── mapping-migration.ts     #   Mapping format migration
└── generators/                  # (Deprecated -- use factory system)

libs/instance-factories/         # Code generation templates (shipped with package)
├── controllers/                 #   Fastify route handlers
├── orms/                        #   Prisma schema generation
├── views/                       #   React components, forms, hooks
├── services/                    #   Service layer generation
├── cli/                         #   CLI command generation
├── tools/                       #   VSCode extension, MCP server generators
│   ├── mcp.yaml                 #   MCP server instance factory
│   └── vscode.yaml              #   VSCode extension instance factory
├── scaffolding/                 #   Project scaffold (package.json, tsconfig, etc.)
├── applications/                #   App entry points (Fastify server wiring)
├── infrastructure/              #   Infrastructure templates
├── testing/                     #   Test generation
├── validation/                  #   Validation helpers
├── sdks/                        #   SDK generation
├── communication/               #   Communication layer
├── storage/                     #   Storage layer
└── shared/                      #   Shared utilities across factories

tsconfig.libs.json               # TypeScript config for compiled instance factory templates

assets/
├── templates/                   #   Project scaffolding templates (init command)
├── examples/                    #   Example specifications
└── examples-decomposed/         #   Decomposed example variants

Extension

To add a new code generation target:

  1. Create an instance factory directory under libs/instance-factories/your-concern/
  2. Add a factory definition JSON with capability declarations and code templates
  3. Register the capability in the manifest schema so manifests can request it
  4. The InstanceFactoryLibrary will auto-discover the factory on initialization

To add a new manifest capability:

  1. Define the capability key (e.g., messaging.broker)
  2. Create an instance factory that implements the capability
  3. Add the capability to the manifest schema in schema/

Note: The JSON Schema used for validation is resolved from @specverse/engine-entities (the single source of truth), not a local copy.

See Also