Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/specify_cli/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ def render_frontmatter(fm: dict) -> str:
return ""

yaml_str = yaml.dump(
fm, default_flow_style=False, sort_keys=False, allow_unicode=True
fm,
default_flow_style=False,
sort_keys=False,
allow_unicode=True,
width=float("inf"),
)
return f"---\n{yaml_str}---\n"

Expand Down
25 changes: 25 additions & 0 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import tempfile
import shutil
import tomllib
import yaml
from contextlib import contextmanager
from pathlib import Path
from datetime import datetime, timezone
Expand Down Expand Up @@ -2996,6 +2997,30 @@ def test_render_frontmatter_unicode(self):
assert "Prüfe Konformität" in output
assert "\\u" not in output

def test_render_frontmatter_keeps_long_description_on_one_line(self):
"""A long description must not be folded across lines.

PyYAML wraps plain scalars at ~80 columns by default, which splits a
long ``description`` onto a continuation line. The YAML stays valid,
but the rendered frontmatter then differs in shape from the
hand-written core command templates, where ``description`` is always a
single line -- and consumers that read frontmatter line-wise see a
truncated description followed by a stray line.
"""
long_description = (
"Execute the implementation plan by processing and executing all "
"tasks defined in tasks.md"
)
frontmatter = {"name": "speckit-implement", "description": long_description}

registrar = CommandRegistrar()
output = registrar.render_frontmatter(frontmatter)

assert f"description: {long_description}\n" in output

body = output.split("---\n")[1]
assert yaml.safe_load(body)["description"] == long_description

def test_adjust_script_paths_does_not_mutate_input(self):
"""Path adjustments should not mutate caller-owned frontmatter dicts."""
from specify_cli.agents import CommandRegistrar as AgentCommandRegistrar
Expand Down