github / github/spec-kit

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

Đã đóng
#4,554 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug-assess severity-low triage-nice-to-have
Ngôn ngữ chính
Python
Star
137k
Fork
12.3k
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
159

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
78/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.