feat(prompts): implement Phase 2 - Templates & Macros (FR-2)
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>
This commit is contained in:
24
markitect/prompts/templates/__init__.py
Normal file
24
markitect/prompts/templates/__init__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
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",
|
||||
]
|
||||
Reference in New Issue
Block a user