Skip to content

fix(integrations): escape control characters in SKILL.md frontmatter#3399

Merged
mnriem merged 1 commit into
github:mainfrom
marcelsafin:fix/3391-skill-frontmatter-quoting
Jul 9, 2026
Merged

fix(integrations): escape control characters in SKILL.md frontmatter#3399
mnriem merged 1 commit into
github:mainfrom
marcelsafin:fix/3391-skill-frontmatter-quoting

Conversation

@marcelsafin

Copy link
Copy Markdown
Contributor

Summary

Fixes #3391

SkillsIntegration.setup() and the hermes skill builder quoted SKILL.md frontmatter values with a hand-rolled helper that only escaped \ and ". A template description containing a newline or a control character (for example a YAML escape like \a in the source frontmatter, which parses to a real control byte) produced a broken or lossy SKILL.md: the newline split the quoted scalar across lines and the control byte was emitted raw, which is invalid in double-quoted YAML.

Changes

  • New module-level yaml_quote() in integrations/base.py: delegates to yaml.safe_dump(default_style='"'), which handles every escape case per spec. Output is byte-identical to the old helper for plain strings.
  • Both copies of the inline _quote helper (base.py skill builder and hermes) now use it, removing the duplicated logic.
  • New regression tests: unit tests for yaml_quote plus integration tests that render SKILL.md from hostile templates and re-parse the frontmatter with yaml.safe_load.

Testing

  • uv run pytest tests/integrations/test_skill_frontmatter_quoting.py — 6 new tests
  • Full suite: 3808 passed, 105 skipped
  • uvx ruff check — clean

Checklist

  • Tests pass locally
  • Lint passes
  • I did use AI assistance for this contribution

yaml.safe_dump with default_style='"' replaces the hand-rolled quote
helpers in base.py and hermes, so newlines and control characters in
template descriptions round-trip instead of producing unparseable YAML.

Fixes github#3391

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 20:12
@marcelsafin marcelsafin requested a review from mnriem as a code owner July 7, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes SKILL.md frontmatter generation for skills-based integrations by ensuring descriptions (and other frontmatter values) are emitted as valid, single-line, double-quoted YAML scalars even when the source contains newlines or control characters (per issue #3391).

Changes:

  • Introduces yaml_quote() in src/specify_cli/integrations/base.py, delegating escaping/quoting to yaml.safe_dump(default_style='"') to correctly handle newlines and control characters.
  • Replaces the duplicated, hand-rolled _quote implementations in both SkillsIntegration.setup() and the Hermes integration with yaml_quote().
  • Adds regression tests to verify round-tripping of multiline and control-character descriptions, including end-to-end SKILL.md generation and YAML frontmatter parsing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/integrations/test_skill_frontmatter_quoting.py Adds regression coverage for yaml_quote() and for generated SKILL.md frontmatter round-tripping hostile descriptions.
src/specify_cli/integrations/hermes/init.py Switches Hermes SKILL.md frontmatter quoting to yaml_quote() to avoid invalid YAML for multiline/control characters.
src/specify_cli/integrations/base.py Adds yaml_quote() and applies it to SkillsIntegration’s SKILL.md frontmatter generation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Low

@mnriem mnriem merged commit 8e2e2d2 into github:main Jul 9, 2026
12 checks passed
@mnriem

mnriem commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

kanfil added a commit to tikalk/agentic-sdlc-spec-kit that referenced this pull request Jul 11, 2026
Upstream merge (30 commits, 3 releases 0.12.9-0.12.11):
- invoke_separator parse-success fix (github#3304)
- Windows Store python3 stub skip + _interpreter_runs() probe (github#3385)
- SKILL.md frontmatter control char escape via yaml_quote() (github#3399)
- chained expression filters left-to-right refactor (github#3339)
- refresh_shared_templates preserves recovered files (github#3378)
- Goose yaml skill placeholder resolution (github#3374)
- bundled version pin enforcement (github#3377)
- integration test home isolation (github#3144)
- py: script type in command templates (github#3403)
- configurable shell step timeout (github#3404)
- find plans in nested spec directories (github#3405)
- plan.md phase numbering fix (github#3416)
- PowerShell -Number 0 honor via ContainsKey (github#3412)
- workflow.yml non-string scalar validation (github#3421)
- plan-template.md self-referencing path fix (github#3417)
- pre-commit config + trailing whitespace cleanup (github#3430)
- malformed URL error handling (github#3433/github#3435/github#3437)
- agent-context nested plan.md discovery (github#3301)
- community catalog additions (EARS, Figma) (github#3407/github#3408)

9 conflicts resolved: pyproject.toml, integrations/base.py, agents.py,
forge/__init__.py, hermes/__init__.py, create-new-feature-branch.ps1,
test_git_extension.py, test_base.py, test_integration_devin.py.

Template-to-preset alignment: added py: script lines to 6 preset commands,
removed stale Phase 1 agent context line from plan preset, fixed phase
numbering. Pre-merge fix: wrapped bare make_typer import with fallback.

Assisted-by: opencode (model: glm-5.2, autonomous)
kanfil added a commit to tikalk/agentic-sdlc-spec-kit that referenced this pull request Jul 11, 2026
Upstream merge (30 commits, 3 releases 0.12.9-0.12.11):
- invoke_separator parse-success fix (github#3304)
- Windows Store python3 stub skip + _interpreter_runs() probe (github#3385)
- SKILL.md frontmatter control char escape via yaml_quote() (github#3399)
- chained expression filters left-to-right refactor (github#3339)
- refresh_shared_templates preserves recovered files (github#3378)
- Goose yaml skill placeholder resolution (github#3374)
- bundled version pin enforcement (github#3377)
- integration test home isolation (github#3144)
- py: script type in command templates (github#3403)
- configurable shell step timeout (github#3404)
- find plans in nested spec directories (github#3405)
- plan.md phase numbering fix (github#3416)
- PowerShell -Number 0 honor via ContainsKey (github#3412)
- workflow.yml non-string scalar validation (github#3421)
- plan-template.md self-referencing path fix (github#3417)
- pre-commit config + trailing whitespace cleanup (github#3430)
- malformed URL error handling (github#3433/github#3435/github#3437)
- agent-context nested plan.md discovery (github#3301)
- community catalog additions (EARS, Figma) (github#3407/github#3408)

9 conflicts resolved: pyproject.toml, integrations/base.py, agents.py,
forge/__init__.py, hermes/__init__.py, create-new-feature-branch.ps1,
test_git_extension.py, test_base.py, test_integration_devin.py.

Template-to-preset alignment: added py: script lines to 6 preset commands,
removed stale Phase 1 agent context line from plan preset, fixed phase
numbering. Pre-merge fix: wrapped bare make_typer import with fallback.

Assisted-by: opencode (model: glm-5.2, autonomous)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SKILL.md frontmatter corrupts multiline descriptions and breaks on control characters

3 participants