Skip to content

ephor/prompteng

Repository files navigation

PromptEng

Type-safe prompt templating, testing, and tooling for LLM apps. This monorepo contains the Core engine, a CLI, and a VSCode extension.

  • Core (@prompteng/core) — LiquidJS-powered, safe prompt templates, multi-output sections, constraint tags, and first-class tests.
  • CLI (@prompteng/cli) — Init project structure, run prompt tests, generate TypeScript types.
  • VSCode Extension — Syntax highlighting and commands for templates/tests.

If you just want to use PromptEng in your app, start with the Core docs:

Quick start

Use as a library (Core)

Install:

npm i @prompteng/core
# or
pnpm add @prompteng/core

Minimal template (prompts/templates/email-welcome.ptemplate):

---
name: "email-welcome"
description: "Welcome email generator"
variables:
  - name: recipientName
    type: string
    required: true
  - name: productName
    type: string
    required: true
---
{% section 'system' %}
You are a helpful assistant writing concise, friendly emails.
{% endsection %}

{% section 'prompt' %}
Write a short welcome email for {{ recipientName }} to introduce {{ productName }}.
{% endsection %}

Render it:

import { PromptEngine } from '@prompteng/core';

const engine = new PromptEngine('prompts/templates');
const { sections } = await engine.renderWithMeta('email-welcome', {
  recipientName: 'Ada',
  productName: 'Acme'
});
// sections.system, sections.prompt

Write a simple prompt test (prompts/tests/email-welcome.ptest):

template: "email-welcome"
description: "Welcome email basic test"
providers:
  - name: "mock"
    model: "mock-1"

test_cases:
  - name: "Simple welcome"
    variables:
      recipientName: "Ada"
      productName: "Acme"
    assertions:
      - contains: "Acme"
      - not_contains: "unsubscribe"

Run tests (Vitest under the hood via our runner):

pnpm -F @prompteng/core test

For more examples, custom tags/filters, and type generation, see the Core README:

Examples

  • 📂 prompts/ — example templates and tests you can run and modify.

Work in this monorepo

Prerequisites: Node 18+, pnpm >= 9

Install dependencies and build:

pnpm install
pnpm -F @prompteng/core build

Packages:

  • packages/core — Core rendering engine, providers, testing framework
  • packages/cli — Command-line interface for init/test/generate-types
  • packages/vscode-extension — VSCode extension: syntax highlighting and commands

CLI examples (from repo):

# Build CLI
pnpm -F @prompteng/cli build

# Initialize a prompts workspace
node packages/cli/lib/index.js init

# Run prompt tests (optionally set a real provider key)
export OPENAI_API_KEY=sk-...
node packages/cli/lib/index.js test

# Generate TypeScript types from templates
node packages/cli/lib/index.js generate-types

VSCode Extension:

pnpm -F prompteng-vscode build

Launch VSCode and press F5 to start the Extension Development Host. The extension provides:

  • Prompt Template syntax highlighting (.ptemplate)
  • Prompt Test syntax highlighting (.ptest)
  • Explorer views: "Prompt Templates" and "Prompt Tests"
  • Commands: Run Prompt, Run Tests, Generate TypeScript Types

Conventions

  • Testing uses Vitest.
  • Templates live under prompts/templates/.
  • Tests live under prompts/tests/.

Roadmap

  • Provider adapters beyond OpenAI

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors