Skip to content

Commit 6b17af4

Browse files
refactor(agents): delegate render_yaml_command to YamlIntegration
Remove the duplicate header dict, yaml.safe_dump call, body indentation, and _human_title logic from CommandRegistrar.render_yaml_command(). Delegate to YamlIntegration._render_yaml() and _human_title() so YAML recipe output stays consistent across the init-time generation and command-registration code paths.
1 parent 40d6353 commit 6b17af4

1 file changed

Lines changed: 4 additions & 28 deletions

File tree

src/specify_cli/agents.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -242,42 +242,18 @@ def render_yaml_command(
242242
Returns:
243243
Formatted YAML recipe file content
244244
"""
245-
246-
def _human_title(identifier: str) -> str:
247-
text = identifier
248-
if text.startswith("speckit."):
249-
text = text[len("speckit.") :]
250-
return text.replace(".", " ").replace("-", " ").replace("_", " ").title()
245+
from specify_cli.integrations.base import YamlIntegration
251246

252247
title = frontmatter.get("title", "") or frontmatter.get("name", "")
253248
if not title and cmd_name:
254-
title = _human_title(cmd_name)
249+
title = YamlIntegration._human_title(cmd_name)
255250
if not title and source_id:
256-
title = _human_title(Path(str(source_id)).stem)
251+
title = YamlIntegration._human_title(Path(str(source_id)).stem)
257252
if not title:
258253
title = "Command"
259254

260255
description = frontmatter.get("description", "")
261-
262-
header = {
263-
"version": "1.0.0",
264-
"title": title,
265-
"description": description,
266-
"author": {"contact": "spec-kit"},
267-
"extensions": [{"type": "builtin", "name": "developer"}],
268-
"activities": ["Spec-Driven Development"],
269-
}
270-
271-
header_yaml = yaml.safe_dump(
272-
header,
273-
sort_keys=False,
274-
allow_unicode=True,
275-
default_flow_style=False,
276-
).strip()
277-
278-
indented = "\n".join(f" {line}" for line in body.split("\n"))
279-
lines = [header_yaml, "prompt: |", indented, "", f"# Source: {source_id}"]
280-
return "\n".join(lines)
256+
return YamlIntegration._render_yaml(title, description, body, source_id)
281257

282258
def render_skill_command(
283259
self,

0 commit comments

Comments
 (0)