Deepractice Prompt Markup Language
结构化 AI 提示工程的声明式标记语言
Define, validate, and transform AI prompts with XML-like syntax
使用类 XML 语法定义、验证和转换 AI 提示
Declarative · Type Safe · Extensible
声明式 · 类型安全 · 可扩展
AI systems need structured ways to define behaviors: prompts, contexts, instructions, constraints, and more. DPML provides a unified markup language with schema validation and extensible transformers. Everything is declarative.
┌─────────────────────────────────────────────────────────────┐
│ DPML Document │
│ │
│ <prompt role="assistant"> │
│ <context>You are a travel planner</context> │
│ <instruction>Help users plan trips</instruction> │
│ <resource src="arp:text:file://./knowledge.md"/> │
│ </prompt> │
├─────────────────────────────────────────────────────────────┤
│ Processing Pipeline │
│ │
│ Parse → DPML Text → DPMLDocument │
│ Validate → Schema → ValidationResult │
│ Transform → Transformers → Target Format │
├─────────────────────────────────────────────────────────────┤
│ Core Concepts │
│ │
│ Element → <tag>content</tag> │
│ Attribute → name="value" │
│ Schema → Structure & validation rules │
│ Transformer → Convert to any format │
└─────────────────────────────────────────────────────────────┘
npm install dpmlimport{createDPML,defineSchema,defineTransformer}from'dpml';// 1. Define schemaconstschema=defineSchema({element: 'prompt',attributes: [{name: 'role',required: true}],children: {elements: [{element: 'context'},{element: 'instruction'}]},});// 2. Define transformerconsttransformer=defineTransformer({name: 'prompt-extractor',transform: (input)=>({role: input.document.rootNode.attributes.get('role'),context: input.document.rootNode.children[0]?.content,instruction: input.document.rootNode.children[1]?.content,}),});// 3. Compileconstdpml=createDPML({ schema,transformers: [transformer]});constresult=awaitdpml.compile(` <prompt role="assistant"> <context>You are a helpful assistant</context> <instruction>Answer questions clearly</instruction> </prompt>`);// → { role: 'assistant', context: '...', instruction: '...' }- Introduction - Why DPML
- Installation - Setup guide
- Quick Start - 5-minute tutorial
- Architecture Overview - Three-party model
- Syntax - Element, Attribute, Content
- Schema System - Validation & constraints
- Transformer - Data transformation
- Built-in Elements -
<resource>element
- Defining Schema - Schema definition patterns
- Custom Transformer - Transformer development
- Validation - Error handling best practices
- Integration - AI tools & build systems
- dpml API - Main package API
- @dpml/core API - Core library internals
- Errors - Error handling
- Design Decisions - Architecture rationale (ADRs)
- Specification - Language specification
- Whitepaper - Design philosophy
| Package | Description |
|---|---|
dpml | Main package - public API |
@dpml/core | Core library - parse, validate, transform |
Part of the Deepractice AI infrastructure:
- AgentVM - AI Agent runtime
- AgentX - AI Agent framework
- ResourceX - Resource management protocol
- DPML - Prompt markup language (this project)
# Clone & setup
git clone https://github.com/Deepractice/dpml.git
cd dpml && bun install
# Build & test
bun run build
bun run test
bun run test:bddSee Development Guide for BDD workflow.
Contributions welcome! Please read our contributing guidelines before submitting PRs.
Built with care by Deepractice