github / github/spec-kit

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

已关闭
#4,554 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug-assess severity-low triage-nice-to-have
主要语言
Python
星标
137k
派生
12.3k
平均合并
2 天 12 小时
30 天内合并 PR
159

描述

### 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.*

贡献指南

打开贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
cli
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
描述清楚
新手友好度
78/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。