Registry / llm-agents / promptl-ai

promptl-ai

JSON →
library0.12.0jsnpmunverified

Official JavaScript/TypeScript compiler for PromptL, a language for defining dynamic LLM prompts with variables and control flow. Current version 0.12.0, actively developed by Latitude. Ships TypeScript types natively. Compiles PromptL syntax into structured JSON messages compatible with major LLM providers like OpenAI. Unlike raw template strings, PromptL provides a validated grammar, front-matter for model config, and built-in support for multi-turn conversations. Release cadence is weekly to bi-weekly. Key differentiator: human-readable prompt files with dynamic logic, compiled to provider-native formats without runtime dependencies.

npm install promptl-ai
INSTALL
IMPORT
SIG · PROMPTL-AI
P
promptl-ai
llm-agentsjavascriptv0.12.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
✓ import { compile } from 'promptl-ai'
✗ const { compile } = require('promptl-ai')
ESM-only package. CJS require() will fail.
CompiledPrompt
✓ import type { CompiledPrompt } from 'promptl-ai'
✗ import { CompiledPrompt } from 'promptl-ai'
TypeScript type import, not a runtime value.
PromptlError
✓ import { PromptlError } from 'promptl-ai'
✗ import { PromptlError } from 'promptl-ai/errors'
Exported from the main module, not a subpath.

Compiles a PromptL string with variables into a provider-ready JSON object, showing variable interpolation and front-matter parsing.

import { compile } from 'promptl-ai'; const prompt = `--- model: gpt-4 temperature: 0.7 --- You are a helpful AI assistant. <user> What is the capital of {{ country }}? </user>`; const result = compile(prompt, { variables: { country: 'France' } }); console.log(JSON.stringify(result, null, 2)); /* { "model": "gpt-4", "temperature": 0.7, "messages": [ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "What is the capital of France?" } ] } */
Debug
Known issues
breakingcompile() now returns an object with { messages, config } instead of a flat messages array as of v0.10.0.
fix
Access result.messages for the message array and result.config for model/temperature/etc.
affects: >=0.10.0
deprecatedThe 'strict' option in compile() is deprecated and will be removed in v1.0. Use 'mode: 'strict' instead.
fix
Replace { strict: true } with { mode: 'strict' }.
affects: >=0.11.0 <1.0.0
gotchaVariables in PromptL are case-sensitive and must be provided exactly as declared. Undefined variables cause a runtime error unless 'mode: 'loose'' is set.
fix
Ensure all variables %7B%7B varName }} are provided in the options.variables object, or set mode to 'loose' to ignore missing variables.
affects: >=0.9.0
breakingSupport for Node.js < 18 removed in v0.12.0.
fix
Upgrade Node.js to version 18 or later.
affects: >=0.12.0
Errors
Common errors & fixes
Error: Cannot find module 'promptl-ai'
Package is ESM-only, but project uses require() or no "type": "module" in package.json.
fix
Add "type": "module" to your package.json or use dynamic import: await import('promptl-ai')
TypeError: compile is not a function
Import mismatch: using default import instead of named import.
fix
Use `import { compile } from 'promptl-ai'` instead of `import compile from 'promptl-ai'`
PromptlError: Variable "country" not found in context
A variable used in the prompt template was not provided in the options.variables object.
fix
Pass all required variables during compilation: compile(template, { variables: { country: 'France' } })
Upgrade
Version history
0.12.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
promptl-ai — npm install promptl-ai · libregistry