{"id":26111,"library":"promptl-ai","title":"PromptL Compiler","description":"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.","status":"active","version":"0.12.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install promptl-ai","lang":"bash","label":"npm"},{"cmd":"yarn add promptl-ai","lang":"bash","label":"yarn"},{"cmd":"pnpm add promptl-ai","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package. CJS require() will fail.","wrong":"const { compile } = require('promptl-ai')","symbol":"compile","correct":"import { compile } from 'promptl-ai'"},{"note":"TypeScript type import, not a runtime value.","wrong":"import { CompiledPrompt } from 'promptl-ai'","symbol":"CompiledPrompt","correct":"import type { CompiledPrompt } from 'promptl-ai'"},{"note":"Exported from the main module, not a subpath.","wrong":"import { PromptlError } from 'promptl-ai/errors'","symbol":"PromptlError","correct":"import { PromptlError } from 'promptl-ai'"}],"quickstart":{"code":"import { compile } from 'promptl-ai';\n\nconst prompt = `---\nmodel: gpt-4\ntemperature: 0.7\n---\nYou are a helpful AI assistant.\n<user>\n  What is the capital of {{ country }}?\n</user>`;\n\nconst result = compile(prompt, { variables: { country: 'France' } });\nconsole.log(JSON.stringify(result, null, 2));\n/*\n{\n  \"model\": \"gpt-4\",\n  \"temperature\": 0.7,\n  \"messages\": [\n    { \"role\": \"system\", \"content\": \"You are a helpful AI assistant.\" },\n    { \"role\": \"user\", \"content\": \"What is the capital of France?\" }\n  ]\n}\n*/","lang":"typescript","description":"Compiles a PromptL string with variables into a provider-ready JSON object, showing variable interpolation and front-matter parsing."},"warnings":[{"fix":"Access result.messages for the message array and result.config for model/temperature/etc.","message":"compile() now returns an object with { messages, config } instead of a flat messages array as of v0.10.0.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Replace { strict: true } with { mode: 'strict' }.","message":"The 'strict' option in compile() is deprecated and will be removed in v1.0. Use 'mode: 'strict' instead.","severity":"deprecated","affected_versions":">=0.11.0 <1.0.0"},{"fix":"Ensure all variables %7B%7B varName }} are provided in the options.variables object, or set mode to 'loose' to ignore missing variables.","message":"Variables in PromptL are case-sensitive and must be provided exactly as declared. Undefined variables cause a runtime error unless 'mode: 'loose'' is set.","severity":"gotcha","affected_versions":">=0.9.0"},{"fix":"Upgrade Node.js to version 18 or later.","message":"Support for Node.js < 18 removed in v0.12.0.","severity":"breaking","affected_versions":">=0.12.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Add \"type\": \"module\" to your package.json or use dynamic import: await import('promptl-ai')","cause":"Package is ESM-only, but project uses require() or no \"type\": \"module\" in package.json.","error":"Error: Cannot find module 'promptl-ai'"},{"fix":"Use `import { compile } from 'promptl-ai'` instead of `import compile from 'promptl-ai'`","cause":"Import mismatch: using default import instead of named import.","error":"TypeError: compile is not a function"},{"fix":"Pass all required variables during compilation: compile(template, { variables: { country: 'France' } })","cause":"A variable used in the prompt template was not provided in the options.variables object.","error":"PromptlError: Variable \"country\" not found in context"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}