41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
|
|
"""Claude distributor tests (WP-0007 T02)."""
|
||
|
|
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
|
||
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||
|
|
|
||
|
|
from session_memory.curate.schema import Resolution, SolutionPattern # noqa: E402
|
||
|
|
from session_memory.distribute.claude import ClaudeDistributor # noqa: E402
|
||
|
|
|
||
|
|
|
||
|
|
def _pattern(hints=None):
|
||
|
|
return SolutionPattern(
|
||
|
|
id="sp-read-before-edit", name="Read before edit", version="1.0.0",
|
||
|
|
polarity="problem", problem="Agents edit files they have not read.",
|
||
|
|
resolutions=[Resolution(summary="Read the file first", steps=["Read", "Edit"])],
|
||
|
|
rendering_hints=hints or {"claude": {}},
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def test_default_targets_claude_md():
|
||
|
|
art = ClaudeDistributor().render(_pattern())
|
||
|
|
assert art.flavor == "claude"
|
||
|
|
assert art.target_path == "CLAUDE.md"
|
||
|
|
assert "BEGIN helix-forge pattern:sp-read-before-edit" in art.content
|
||
|
|
assert "### Read before edit" in art.content
|
||
|
|
|
||
|
|
|
||
|
|
def test_skill_mode_emits_skill_stub():
|
||
|
|
art = ClaudeDistributor().render(_pattern({"claude": {"as": "skill"}}))
|
||
|
|
assert "## Skill: Read before edit" in art.content
|
||
|
|
assert "**When:**" in art.content
|
||
|
|
assert " - Read" in art.content
|
||
|
|
|
||
|
|
|
||
|
|
def test_idempotent_marker_present_for_reupsert():
|
||
|
|
art = ClaudeDistributor().render(_pattern())
|
||
|
|
# same id in both renders -> caller can upsert in place
|
||
|
|
art2 = ClaudeDistributor().render(_pattern())
|
||
|
|
assert art.pattern_id == art2.pattern_id == "sp-read-before-edit"
|