fix(prompts): fix three infrastructure bugs in prompt dependency resolution
- ContentMacro: add __post_init__ to auto-derive raw_text when built
programmatically, preventing str.replace("", X) corruption
- MacroParser: add @{target} shorthand syntax support mapped to REQUIRED kind,
updating parse, has_macros, count_macros, and find_macro_positions
- Artifact: store content in model and SQLite DB, replace resolver placeholder
with actual artifact content, add migration for existing databases
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,23 @@ class TestContentMacro:
|
||||
)
|
||||
assert macro.parameters == {"language": "python", "framework": "fastapi"}
|
||||
|
||||
def test_programmatic_macro_gets_auto_derived_raw_text(self):
|
||||
"""Test that programmatically-built macro gets auto-derived raw_text."""
|
||||
macro = ContentMacro(
|
||||
kind=MacroKind.REQUIRED,
|
||||
target="glossary",
|
||||
)
|
||||
assert macro.raw_text == "@{glossary}"
|
||||
|
||||
def test_explicit_raw_text_not_overridden(self):
|
||||
"""Test that explicit raw_text is preserved."""
|
||||
macro = ContentMacro(
|
||||
kind=MacroKind.REQUIRED,
|
||||
target="glossary",
|
||||
raw_text="{{require:glossary}}",
|
||||
)
|
||||
assert macro.raw_text == "{{require:glossary}}"
|
||||
|
||||
def test_macro_str_representation(self):
|
||||
"""Test string representation."""
|
||||
macro = ContentMacro(
|
||||
|
||||
Reference in New Issue
Block a user