Repository navigation
Extension command rendering does not strip scripts: from the agent-facing frontmatter #4554
Description
Activity
- added a commit that references this issue
on Sep 12, 2026 - addedtriage-nice-to-haveVerdict: evidence-backed fix or greenlit feature — land after reviewVerdict: evidence-backed fix or greenlit feature — land after review
on Sep 12, 2026 github-actions commented
on Sep 12, 2026 on Sep 12, 2026 – with GitHub ActionsContributorMore actionsBug assessment — extension-frontmatter: Valid · severity low
Bug Assessment: Extension command rendering does not strip
scripts:from the agent-facing frontmatter- Slug: extension-frontmatter
- Created: 2026-09-12T13:11:33Z
- Source: issue Extension command rendering does not strip
scripts:from the agent-facing frontmatter #4554 - Verdict: valid
- Severity: low
Report (summarized)
The report says core command rendering consumes
scripts:to resolve{SCRIPT}and removes that build-time key from generated agent frontmatter, while extension command rendering resolves the paths but leavesscripts:visible. The supplied reproduction uses Copilot commands mode, installs the bundledgithubextension, and compares the generated.agent.mdfiles. The reported result is cosmetic: paths and command execution are correct, but the two rendering paths produce inconsistent agent-facing metadata.The issue has no additional comments. The issue metadata references an open remediation PR, #4559, but this assessment is based on the checked-out code and report.
Symptom
When an extension command declares a
scripts:frontmatter mapping, the generated extension artifact can expose that internal mapping to the agent after{SCRIPT}has already been substituted. Core-rendered commands remove the same key, so equivalent commands have inconsistent frontmatter. Expected behavior is for both paths to consume and omitscripts:.Reproduction
- Use a project initialized with Copilot commands mode and a selected script type, as described in the report.
- Install the bundled
githubextension withspecify extension add github. - Inspect the generated extension command under
.github/agents/. - Compare it with the equivalent core command under the same project.
The report provides the exact initialization command and generated frontmatter excerpts. [NEEDS CLARIFICATION: the report does not state whether the same leak was independently observed for every non-Copilot command-layout integration.]
Suspected Code Paths
src/specify_cli/integrations/base.py:809-875—IntegrationBase.process_template()explicitly selects a script variant, substitutes{SCRIPT}, and strips thescripts:section; this is the core behavior the report compares against.src/specify_cli/agents.py:616-778—CommandRegistrar.register_commands()parses extension command frontmatter and calls_adjust_script_paths()before rendering command-layout output. The shared path normalizer rewrites values but does not remove thescriptsmapping.src/specify_cli/agents.py:187-203—CommandRegistrar._adjust_script_paths()deep-copies frontmatter and rewrites paths underscripts, leaving the mapping present for serialization.src/specify_cli/extensions/__init__.py:1530-1680—_register_extension_skills()follows the extension skill path, calls_adjust_script_paths(), then serializes generated frontmatter without an explicitscriptsremoval. This is the parallel path that should be checked alongside command mode.src/specify_cli/agents.py:850-885— command-layout rendering serializes the processed frontmatter, while the non-skills post-processing hook runs afterward; whether a given integration removes the key depends on that integration's hook, creating the reported path divergence.
Root Cause Hypothesis
Confidence: high. The shared extension registrar uses
_adjust_script_paths()as a normalization step, but that helper only rewrites script values. The coreprocess_template()has a separate explicit cleanup step that removes the entirescripts:section after substitution. Extension command and skill registration do not apply an equivalent cleanup before frontmatter serialization, so the internal mapping remains visible whenever an extension source declares it.Proposed Remediation
Preferred: Add one shared frontmatter cleanup operation for consumed
scripts:metadata and invoke it in both extension command-layout and extension skill rendering after script placeholders have been resolved, before the output frontmatter is serialized. Preserve the existing path rewriting and selected-script behavior; only remove thescriptskey from the emitted metadata. Ifagent_scriptsis a separate supported internal key, define explicitly whether it is also consumed rather than removing it opportunistically.The implementation should cover both
CommandRegistrar.register_commands()and_register_extension_skills()so command mode and skills mode cannot diverge. Reusing a small helper is preferable to duplicatingfrontmatter.pop("scripts", None)at multiple serialization sites, provided the helper's contract clearly states that script resolution has already occurred.Alternatives:
- Call the existing integration
process_template()or a generalized post-render cleanup from extension registration. Trade-off: this risks reapplying substitutions or path rewrites to already-rendered output and couples extension registration to integration-specific processing. - Remove
scripts:in_adjust_script_paths()itself. Trade-off: the helper is also used before placeholder resolution, so this could discard the mapping before{SCRIPT}or skill placeholder consumers have read it.
Files likely to change:
src/specify_cli/agents.pysrc/specify_cli/extensions/__init__.py- Relevant integration/extension rendering tests, likely
tests/test_post_process.pyand/ortests/test_extensions.py
Tests to add or update:
- Build a minimal extension command whose frontmatter contains
scripts:and whose body contains{SCRIPT}; assert the rendered Copilot command-mode artifact contains the resolved path but not thescripts:key. - Exercise the same source through the skills path and assert the generated
SKILL.mdalso omitsscripts:while retaining the resolved body command. - Cover at least one ordinary Markdown command-layout agent to ensure the cleanup is shared and does not depend on Copilot-specific formatting.
- Retain a regression case for commands without
scripts:and for frontmatter unrelated to script resolution.
Risks & Considerations
- Cleanup must occur after the selected script command has been consumed; doing it earlier would prevent
{SCRIPT}resolution. - Do not remove script mappings from source templates or installed extension files; only generated agent-facing output should change.
- Existing users may have generated files containing
scripts:; the fix should apply on reinstall/upgrade and should not require a migration for a cosmetic artifact. - YAML serialization style differences (
tools:flow versus block style) are separate from the reported key leak and should not be broadened into this fix unless a test demonstrates semantic impact. - The change is low risk and should not alter command invocation or script path semantics.
Open Questions
- [NEEDS CLARIFICATION: Should
agent_scriptsreceive the same treatment, or is it intentionally agent-visible metadata?] - [NEEDS CLARIFICATION: Should cleanup be applied to all extension command formats, including TOML and YAML, or only Markdown/Copilot output? The shared behavior suggests all generated agent-facing formats should be covered.]
Generated by 🐛 Assess Bug from Labeled Issue for #4554 · copilot · gpt52codex · 3.45 AIC · ⌖ 9.37 AIC · ⊞ 25.5K · ◷
- added a commit that references this issue
on Sep 17, 2026
Problem Statement
Command rendering strips the
scripts:key from the agent-facing frontmatter on the core path, but not on the extension path. An extension command that declaresscripts:therefore ships a rendered artifact carrying a key that core's equivalent does not, leaking an internal build detail into the agent-visible file.Split out of #4421 at a maintainer's request, so that stage 1 (#4488) stays additive and this shared-render fix is not smuggled into it.
Reproduction
mainatd848fb4, with the bundledgithubextension from #4488 installed into a Copilot commands-mode project:Extension render —
.github/agents/speckit.github.taskstoissues.agent.md:Core render —
.github/agents/speckit.taskstoissues.agent.md, same project, from a source template that declares the same key:No
scripts:key. The path substitution happened in both —{SCRIPT}is resolved in each body — only the cleanup step differs.Cause
The core path strips the key as step 3 of
process_command_templateinsrc/specify_cli/integrations/base.py, after it has been consumed for{SCRIPT}substitution. The extension path (CommandRegistrar.register_commands/_register_extension_skills,src/specify_cli/extensions/__init__.py) calls_adjust_script_pathsand substitutes{SCRIPT}, but never removes the key before serialising the frontmatter.Why it has gone unnoticed
No bundled extension declared
scripts:before thegithubextension in #4488.agent-contextandgitboth spell their script paths out in prose instead, so this branch of the render had no coverage.Impact
Cosmetic today rather than a functional break — the rendered paths are correct and the commands run. The concerns are that the two render paths disagree where they should agree, and that a build-time key reaches agent-visible output.
One caveat worth checking during the fix:
tools:is emitted inline (flow style) by the core render and block style by the extension render, as visible above. Semantically identical YAML, but it suggests the two paths serialise frontmatter through different code, which may be the right place to look.Suggested Fix
Strip
scripts:in the extension render once it has been consumed, matchingprocess_command_template, and add a regression test asserting the key is absent from rendered extension commands in both command mode and skills mode.Component
Specify CLI (initialization, commands)
Disclosure: I used an AI assistant (Claude Code, model Claude Opus 5) to investigate this and draft this report. The reproduction above was produced by installing the extension into a scratch project against
mainand reading the generated files back; I reviewed the findings before filing.