Implement PromptTemplate models with ContentMacro parsing and analysis.
Core Features:
- PromptTemplate extending Artifact for template-specific operations
- ContentMacro model supporting REQUIRED, OPTIONAL, GENERATE kinds
- MacroParser for extracting macros from template content
- TemplateAnalyzer for dependency extraction and validation
- TemplateService for high-level template operations
- Template metadata for model hints and expected inputs
Macro Syntax:
- {{require:artifact-name}} - Required dependency
- {{optional:artifact-name}} - Optional dependency
- {{generate:template-name|param=value}} - Nested generation
Tests (38 passing):
- 18 template model tests (macros, templates, metadata)
- 20 parser tests (parsing, validation, parameters, aliases)
Implements:
- FR-2.1: PromptTemplate as content artifact with macros
- FR-2.2: ContentMacro detection and extraction
- FR-2.3: Required/Optional/Generate macro kinds
Files Created:
- markitect/prompts/templates/models.py
- markitect/prompts/templates/parser.py
- markitect/prompts/templates/analyzer.py
- markitect/prompts/services/template_service.py
- tests/unit/prompts/test_template_models.py
- tests/unit/prompts/test_macro_parser.py
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
580 B
Python
25 lines
580 B
Python
"""
|
|
Template and macro management for Prompt Dependency Resolution.
|
|
|
|
This package provides PromptTemplate definitions, macro parsing,
|
|
and template analysis for dependency extraction.
|
|
"""
|
|
|
|
from markitect.prompts.templates.models import (
|
|
PromptTemplate,
|
|
ContentMacro,
|
|
MacroKind,
|
|
TemplateMetadata,
|
|
)
|
|
from markitect.prompts.templates.parser import MacroParser
|
|
from markitect.prompts.templates.analyzer import TemplateAnalyzer
|
|
|
|
__all__ = [
|
|
"PromptTemplate",
|
|
"ContentMacro",
|
|
"MacroKind",
|
|
"TemplateMetadata",
|
|
"MacroParser",
|
|
"TemplateAnalyzer",
|
|
]
|