fix(agents): parse frontmatter on the --- delimiter line, not any --- substring#3590
Open
chuenchen309 wants to merge 1 commit into
Open
fix(agents): parse frontmatter on the --- delimiter line, not any --- substring#3590chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
… substring
CommandRegistrar.parse_frontmatter located the closing delimiter with
content.find("---", 3), a raw substring search. It stopped at the first
"---" anywhere after the opening — including one embedded in a
frontmatter value (e.g. a description "Separate sections with ---
markers") or inside an indented literal block — which truncated the
frontmatter and spilled the remainder into the body, silently corrupting
both the parsed metadata and the rendered command body.
Match the closing "---" on line boundaries, mirroring the line-anchored
scan already used by VibeIntegration._inject_frontmatter_flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CommandRegistrar.parse_frontmatterfinds the closing frontmatter delimiter withcontent.find("---", 3)— a raw substring search (src/specify_cli/agents.py). It stops at the first---anywhere after the opening, including one embedded in a frontmatter value or inside an indented YAML literal block, rather than a---that occupies its own line (the actual YAML document-separator).Any command source file whose frontmatter contains
---in a value gets a corrupted description and a corrupted body written into the generated agent files, silently:{'description': 'Separate sections with'}— description truncated,argument-hintsilently dropped, and the rest (markers\nargument-hint: ...\n---\n...) spills into the body.{'description': 'Separate sections with --- markers', 'argument-hint': '[name]'}and bodyReal body starts here.The sibling frontmatter handler in this codebase,
VibeIntegration._inject_frontmatter_flag(src/specify_cli/integrations/vibe/__init__.py), already scans for a line-anchored---;parse_frontmatterwas the only frontmatter reader using a substringfind. This change makes them consistent.parse_frontmatteris called before rendering every command into each agent's directory (register_commands, extensions, and preset/core commands), so the fix covers all of those paths.Testing
uv sync && uv run pytest—tests/test_extensions.py+tests/test_presets.py→ 724 passed; no regression.test_parse_frontmatter_dash_in_value(inTestParseFrontmatter), which fails onmain(assert 'Separate sections with' == '...--- markers') and passes with the fix.ruff check src/specify_cli/agents.py→ clean.AI Disclosure