fix(yaml): add parameter definitions for goose recipe validation#2450
fix(yaml): add parameter definitions for goose recipe validation#2450zichen0116 wants to merge 2 commits intogithub:mainfrom
Conversation
Goose recipe validation requires that all template variables (like {{args}})
have corresponding parameter definitions in the parameters field.
Without this, goose recipe validate fails with:
Missing definitions for parameters in the recipe file: args.
Add the parameters field to generated YAML recipes when {{args}} is used.
Fixes github#2423
There was a problem hiding this comment.
Pull request overview
This PR aims to fix Goose recipe validation by teaching the YAML recipe generator to emit parameter metadata for the {{args}} placeholder used in spec-kit command templates. It fits into the integration layer that materializes agent-specific command files from the shared template set.
Changes:
- Extended
YamlIntegration._render_yaml()to optionally include aparametersheader section. - Updated
YamlIntegration.setup()to detect{{args}}in generated recipe bodies and inject anargsparameter definition. - Kept the rest of the Goose YAML recipe structure unchanged.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Build parameter definitions for template variables used in the body | ||
| params = None | ||
| if "{{args}}" in body: | ||
| params = [ | ||
| { | ||
| "key": "args", | ||
| "input_type": "string", | ||
| "requirement": "user_prompt", | ||
| "description": "Arguments to pass to the command", | ||
| } | ||
| ] | ||
|
|
||
| yaml_content = self._render_yaml( | ||
| title, description, body, f"templates/commands/{src_file.name}" | ||
| title, description, body, f"templates/commands/{src_file.name}", | ||
| parameters=params, |
| # Build parameter definitions for template variables used in the body | ||
| params = None | ||
| if "{{args}}" in body: | ||
| params = [ | ||
| { | ||
| "key": "args", | ||
| "input_type": "string", | ||
| "requirement": "user_prompt", | ||
| "description": "Arguments to pass to the command", | ||
| } | ||
| ] | ||
|
|
||
| yaml_content = self._render_yaml( | ||
| title, description, body, f"templates/commands/{src_file.name}" | ||
| title, description, body, f"templates/commands/{src_file.name}", | ||
| parameters=params, |
mnriem
left a comment
There was a problem hiding this comment.
Please address Copilot feedback. If not applicable, please explain why
…ests
- Fix CommandRegistrar.render_yaml_command() to pass parameters when
{{args}} is present in the body, covering the preset/extension path
- Add regression test for parameters block in generated YAML recipes
- Addresses review feedback on PR github#2450
|
Thanks for the review! I've addressed both issues:
The body already has |
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (3)
src/specify_cli/agents.py:268
- This call to
_render_yaml(...)is on a single long line and is likely to violate the repo’s Ruff default line-length rule (E501). Please wrap the call across multiple lines (or assign to a local variable) to keep lines within the configured limit.
return YamlIntegration._render_yaml(title, description, body, source_id, parameters=params)
src/specify_cli/agents.py:262
- There’s no test coverage for the new behavior here (adding
parameterswhen the args placeholder is present). The integration tests coverYamlIntegration.setup(), but this code path is used when rendering YAML viaCommandRegistrar(e.g., extension/preset overrides), so a focused unit test should be added to prevent regressions.
params = None
if "{{args}}" in body:
params = [
{
"key": "args",
src/specify_cli/integrations/base.py:1301
setup()usesarg_placeholderwhen processing templates, but the parameter injection check is hard-coded to"{{args}}". To avoid drift if the configured args placeholder changes, key this check offarg_placeholder(or a shared helper) instead of a literal string.
params = None
if "{{args}}" in body:
params = [
- Files reviewed: 3/3 changed files
- Comments generated: 2
| description = str(description) if description is not None else "" | ||
| return YamlIntegration._render_yaml(title, description, body, source_id) | ||
| params = None | ||
| if "{{args}}" in body: |
| context_file=self.context_file or "", | ||
| ) | ||
| _, body = self._split_frontmatter(processed) | ||
| # Build parameter definitions for template variables used in the body |
|
Please address Copiot feedback |
Summary
parametersfield to generated YAML recipe files when{{args}}placeholder is usedProblem
When running
goose recipe validateon spec-kit generated recipe files, validation fails with:This happens because the generated YAML recipes use
{{args}}in the prompt body but don't define theargsparameter in the recipe header.Fix
_render_yaml()to accept an optionalparametersargument and include it in the YAML headersetup()to detect{{args}}in the prompt body and pass the corresponding parameter definitionTesting
parametersfield when{{args}}is usedFixes #2423