refactor(cron): rebrand Cron Recipes -> Automation Blueprints
Product rename across every surface: module/file names (blueprint_catalog, tools/blueprints, blueprint_cmd), slash command /cron-recipe -> /blueprint (alias /bp), dashboard API /api/cron/blueprints, desktop deep-link hermes://blueprint/<key>, docs catalog page + extract script, and the skill frontmatter block metadata.hermes.blueprint. No behavior change.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Tests for the recipes layer (skill frontmatter <-> cron automation bridge).
|
||||
"""Tests for the blueprints layer (skill frontmatter <-> cron automation bridge).
|
||||
|
||||
A recipe is a skill with a metadata.hermes.recipe block. These verify parsing,
|
||||
A blueprint is a skill with a metadata.hermes.blueprint block. These verify parsing,
|
||||
the create-job bridge, and the export round-trip without touching the real
|
||||
cron store.
|
||||
"""
|
||||
@@ -11,24 +11,24 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tools.recipes import (
|
||||
RecipeError,
|
||||
RecipeSpec,
|
||||
create_recipe_job,
|
||||
export_recipe,
|
||||
parse_recipe,
|
||||
recipe_spec_for_installed,
|
||||
from tools.blueprints import (
|
||||
BlueprintError,
|
||||
BlueprintSpec,
|
||||
create_blueprint_job,
|
||||
export_blueprint,
|
||||
parse_blueprint,
|
||||
blueprint_spec_for_installed,
|
||||
)
|
||||
|
||||
|
||||
RECIPE_SKILL = """---
|
||||
BLUEPRINT_SKILL = """---
|
||||
name: morning-brief
|
||||
description: Summarize unread email and calendar every morning.
|
||||
version: 1.0.0
|
||||
metadata:
|
||||
hermes:
|
||||
tags: [recipe, email]
|
||||
recipe:
|
||||
tags: [blueprint, email]
|
||||
blueprint:
|
||||
schedule: "0 8 * * *"
|
||||
deliver: telegram
|
||||
prompt: "Summarize my unread email and today's calendar."
|
||||
@@ -40,22 +40,22 @@ Every morning, gather unread email and the day's calendar and send a digest.
|
||||
"""
|
||||
|
||||
PLAIN_SKILL = """---
|
||||
name: not-a-recipe
|
||||
name: not-a-blueprint
|
||||
description: Just a regular skill.
|
||||
metadata:
|
||||
hermes:
|
||||
tags: [misc]
|
||||
---
|
||||
|
||||
# Not a recipe
|
||||
# Not a blueprint
|
||||
"""
|
||||
|
||||
MALFORMED_RECIPE = """---
|
||||
MALFORMED_BLUEPRINT = """---
|
||||
name: broken
|
||||
description: Recipe with no schedule.
|
||||
description: Blueprint with no schedule.
|
||||
metadata:
|
||||
hermes:
|
||||
recipe:
|
||||
blueprint:
|
||||
deliver: origin
|
||||
---
|
||||
|
||||
@@ -63,49 +63,49 @@ metadata:
|
||||
"""
|
||||
|
||||
|
||||
class TestParseRecipe:
|
||||
def test_parses_full_recipe(self):
|
||||
spec = parse_recipe(RECIPE_SKILL)
|
||||
class TestParseBlueprint:
|
||||
def test_parses_full_blueprint(self):
|
||||
spec = parse_blueprint(BLUEPRINT_SKILL)
|
||||
assert spec is not None
|
||||
assert spec.skill_name == "morning-brief"
|
||||
assert spec.schedule == "0 8 * * *"
|
||||
assert spec.deliver == "telegram"
|
||||
assert spec.prompt is not None and spec.prompt.startswith("Summarize")
|
||||
|
||||
def test_plain_skill_is_not_a_recipe(self):
|
||||
assert parse_recipe(PLAIN_SKILL) is None
|
||||
def test_plain_skill_is_not_a_blueprint(self):
|
||||
assert parse_blueprint(PLAIN_SKILL) is None
|
||||
|
||||
def test_no_frontmatter_is_not_a_recipe(self):
|
||||
assert parse_recipe("just some text, no frontmatter") is None
|
||||
def test_no_frontmatter_is_not_a_blueprint(self):
|
||||
assert parse_blueprint("just some text, no frontmatter") is None
|
||||
|
||||
def test_missing_schedule_raises(self):
|
||||
with pytest.raises(RecipeError):
|
||||
parse_recipe(MALFORMED_RECIPE)
|
||||
with pytest.raises(BlueprintError):
|
||||
parse_blueprint(MALFORMED_BLUEPRINT)
|
||||
|
||||
def test_recipe_not_mapping_raises(self):
|
||||
bad = "---\nname: x\nmetadata:\n hermes:\n recipe: not-a-dict\n---\n\nbody"
|
||||
with pytest.raises(RecipeError):
|
||||
parse_recipe(bad)
|
||||
def test_blueprint_not_mapping_raises(self):
|
||||
bad = "---\nname: x\nmetadata:\n hermes:\n blueprint: not-a-dict\n---\n\nbody"
|
||||
with pytest.raises(BlueprintError):
|
||||
parse_blueprint(bad)
|
||||
|
||||
def test_deliver_defaults_to_origin(self):
|
||||
skill = (
|
||||
"---\nname: r\ndescription: d\nmetadata:\n hermes:\n"
|
||||
' recipe:\n schedule: "every 1h"\n---\n\nbody'
|
||||
' blueprint:\n schedule: "every 1h"\n---\n\nbody'
|
||||
)
|
||||
spec = parse_recipe(skill)
|
||||
spec = parse_blueprint(skill)
|
||||
assert spec is not None
|
||||
assert spec.deliver == "origin"
|
||||
|
||||
|
||||
class TestRecipeSpecForInstalled:
|
||||
def test_finds_and_parses_installed_recipe(self, tmp_path):
|
||||
class TestBlueprintSpecForInstalled:
|
||||
def test_finds_and_parses_installed_blueprint(self, tmp_path):
|
||||
skills_dir = tmp_path / "skills"
|
||||
rec_dir = skills_dir / "productivity" / "morning-brief"
|
||||
rec_dir.mkdir(parents=True)
|
||||
(rec_dir / "SKILL.md").write_text(RECIPE_SKILL, encoding="utf-8")
|
||||
(rec_dir / "SKILL.md").write_text(BLUEPRINT_SKILL, encoding="utf-8")
|
||||
|
||||
with patch("tools.skills_hub.SKILLS_DIR", skills_dir):
|
||||
spec = recipe_spec_for_installed("morning-brief")
|
||||
spec = blueprint_spec_for_installed("morning-brief")
|
||||
assert spec is not None
|
||||
assert spec.schedule == "0 8 * * *"
|
||||
|
||||
@@ -113,20 +113,20 @@ class TestRecipeSpecForInstalled:
|
||||
skills_dir = tmp_path / "skills"
|
||||
skills_dir.mkdir()
|
||||
with patch("tools.skills_hub.SKILLS_DIR", skills_dir):
|
||||
assert recipe_spec_for_installed("nope") is None
|
||||
assert blueprint_spec_for_installed("nope") is None
|
||||
|
||||
def test_plain_skill_returns_none(self, tmp_path):
|
||||
skills_dir = tmp_path / "skills"
|
||||
d = skills_dir / "misc" / "not-a-recipe"
|
||||
d = skills_dir / "misc" / "not-a-blueprint"
|
||||
d.mkdir(parents=True)
|
||||
(d / "SKILL.md").write_text(PLAIN_SKILL, encoding="utf-8")
|
||||
with patch("tools.skills_hub.SKILLS_DIR", skills_dir):
|
||||
assert recipe_spec_for_installed("not-a-recipe") is None
|
||||
assert blueprint_spec_for_installed("not-a-blueprint") is None
|
||||
|
||||
|
||||
class TestCreateRecipeJob:
|
||||
class TestCreateBlueprintJob:
|
||||
def test_bridges_to_create_job(self):
|
||||
spec = parse_recipe(RECIPE_SKILL)
|
||||
spec = parse_blueprint(BLUEPRINT_SKILL)
|
||||
assert spec is not None
|
||||
captured = {}
|
||||
|
||||
@@ -135,7 +135,7 @@ class TestCreateRecipeJob:
|
||||
return {"id": "abc123", **kwargs}
|
||||
|
||||
with patch("cron.jobs.create_job", fake_create_job):
|
||||
job = create_recipe_job(spec, origin={"platform": "telegram"})
|
||||
job = create_blueprint_job(spec, origin={"platform": "telegram"})
|
||||
|
||||
assert captured["schedule"] == "0 8 * * *"
|
||||
assert captured["skills"] == ["morning-brief"]
|
||||
@@ -144,7 +144,7 @@ class TestCreateRecipeJob:
|
||||
assert job["id"] == "abc123"
|
||||
|
||||
|
||||
class TestExportRecipe:
|
||||
class TestExportBlueprint:
|
||||
def test_round_trips_job_to_skill_md(self):
|
||||
job = {
|
||||
"name": "My Morning Brief",
|
||||
@@ -153,19 +153,19 @@ class TestExportRecipe:
|
||||
"deliver": "telegram",
|
||||
"prompt": "Summarize my unread email.",
|
||||
}
|
||||
md = export_recipe(job, "# Morning Brief\n\nDoes the morning digest.")
|
||||
# The exported SKILL.md must itself parse back as a recipe.
|
||||
spec = parse_recipe(md)
|
||||
md = export_blueprint(job, "# Morning Brief\n\nDoes the morning digest.")
|
||||
# The exported SKILL.md must itself parse back as a blueprint.
|
||||
spec = parse_blueprint(md)
|
||||
assert spec is not None
|
||||
assert spec.schedule == "0 8 * * *"
|
||||
assert spec.deliver == "telegram"
|
||||
# Name is sanitized to a valid skill identifier.
|
||||
assert spec.skill_name == "my-morning-brief"
|
||||
|
||||
def test_export_has_recipe_tag(self):
|
||||
def test_export_has_blueprint_tag(self):
|
||||
job = {"name": "x", "schedule_display": "every 2h", "skills": ["x"]}
|
||||
md = export_recipe(job, "body")
|
||||
assert "recipe" in md
|
||||
md = export_blueprint(job, "body")
|
||||
assert "blueprint" in md
|
||||
assert "automation" in md
|
||||
|
||||
def test_export_interval_job_without_display(self):
|
||||
@@ -177,12 +177,12 @@ class TestExportRecipe:
|
||||
"schedule": {"kind": "interval", "minutes": 30},
|
||||
"skills": ["poller"],
|
||||
}
|
||||
md = export_recipe(job, "body")
|
||||
spec = parse_recipe(md)
|
||||
md = export_blueprint(job, "body")
|
||||
spec = parse_blueprint(md)
|
||||
assert spec is not None
|
||||
assert spec.schedule == "every 30m"
|
||||
|
||||
job["schedule"] = {"kind": "interval", "minutes": 120}
|
||||
spec = parse_recipe(export_recipe(job, "body"))
|
||||
spec = parse_blueprint(export_blueprint(job, "body"))
|
||||
assert spec is not None
|
||||
assert spec.schedule == "every 2h"
|
||||
Reference in New Issue
Block a user