Skip to content

Extension command rendering does not strip scripts: from the agent-facing frontmatter #4554

Description

@Yash-Chindam

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 declares scripts: 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

main at d848fb4, with the bundled github extension from #4488 installed into a Copilot commands-mode project:

specify init proj --integration copilot --integration-options="--commands" --script sh
cd proj && specify extension add github

Extension render.github/agents/speckit.github.taskstoissues.agent.md:

---
description: Convert existing tasks into actionable, dependency-ordered GitHub issues ...
tools:
- github/github-mcp-server/list_issues
- github/github-mcp-server/issue_write
scripts:
  sh: .specify/extensions/github/scripts/bash/resolve-tasks.sh --json
  ps: .specify/extensions/github/scripts/powershell/resolve-tasks.ps1 -Json
  py: .specify/extensions/github/scripts/python/resolve_tasks.py --json
---

Core render.github/agents/speckit.taskstoissues.agent.md, same project, from a source template that declares the same key:

---
description: Convert existing tasks into actionable, dependency-ordered GitHub issues ...
tools: ['github/github-mcp-server/list_issues', 'github/github-mcp-server/issue_write']
---

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_template in src/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_paths and substitutes {SCRIPT}, but never removes the key before serialising the frontmatter.

Why it has gone unnoticed

No bundled extension declared scripts: before the github extension in #4488. agent-context and git both 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, matching process_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 main and reading the generated files back; I reviewed the findings before filing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions