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:
2026-02-11 20:53:02 +01:00
parent 01b9596ce6
commit 706981c39f
9 changed files with 191 additions and 10 deletions

View File

@@ -89,6 +89,7 @@ class Artifact:
artifact_type: ArtifactType
content_digest: str
content_size: int = 0
content: str = ""
metadata: ArtifactMetadata = field(default_factory=ArtifactMetadata)
created_at: datetime = field(default_factory=datetime.utcnow)
updated_at: datetime = field(default_factory=datetime.utcnow)
@@ -126,6 +127,7 @@ class Artifact:
artifact_type=artifact_type,
content_digest=content_digest,
content_size=content_size,
content=content,
metadata=metadata or ArtifactMetadata(),
)
@@ -136,6 +138,7 @@ class Artifact:
Args:
new_content: New content string
"""
self.content = new_content
self.content_digest = calculate_content_digest(new_content)
self.content_size = len(new_content.encode('utf-8'))
self.updated_at = datetime.utcnow()
@@ -161,6 +164,7 @@ class Artifact:
"artifact_type": self.artifact_type.value,
"content_digest": self.content_digest,
"content_size": self.content_size,
"content": self.content,
"metadata": self.metadata.to_dict(),
"created_at": self.created_at.isoformat(),
"updated_at": self.updated_at.isoformat(),
@@ -176,6 +180,7 @@ class Artifact:
artifact_type=ArtifactType(data["artifact_type"]),
content_digest=data["content_digest"],
content_size=data.get("content_size", 0),
content=data.get("content", ""),
metadata=ArtifactMetadata.from_dict(data.get("metadata", {})),
created_at=datetime.fromisoformat(data["created_at"]),
updated_at=datetime.fromisoformat(data["updated_at"]),