github / github/spec-kit

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

Closed
#4,554 1 comment 0 reactions 0 assignees View on GitHub
bug-assess severity-low triage-nice-to-have
Dominant language
Python
Stars
137k
Forks
12.3k
Avg merge
2d 12h
Merged PRs (30d)
159

Description

### 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:

```bash
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`:

```yaml
---
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:

```yaml
---
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.*

Contributor guide

Open the contributing guide

Research direction

Start with process_command_template in src/specify_cli/integrations/base.py, then compare CommandRegistrar.register_commands and _register_extension_skills in src/specify_cli/extensions/__init__.py. Trace how extension frontmatter is adjusted and serialized in command mode and skills mode. Done means regression coverage verifies rendered extension commands no longer expose scripts: while script paths remain usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.