[Bug]: `specify preset set-priority` does not update agent command files that are already written

未關閉 適合新手
#5,087 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@mikamikasuki 已經在處理了。

開始於 2026年10月25日。

  • #5113 來自 @mikamikasuki —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
77/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
cli

研究方向

閱讀 src/specify_cli/presets/command_set_priority.py,並將其中的協調呼叫與 src/specify_cli/presets/_manager.py 中的 install 和 remove 進行比較。首先追蹤 preset_set_priority 和現有的命令協調路徑。完成標準是:變更優先順序後,agent 命令檔會更新為與 specify preset resolve 回報的勝出項目一致;issue 中包含一個可透過 uv run python -I repro.py 執行的重現指令碼。

由索引模型根據 Issue 內容生成。

描述

triage-must-have
Bug Description

When two installed presets override the same command, specify preset set-priority changes which one wins resolution, but the agent's command file keeps the previous winner's content. preset_set_priority updates the registry and then calls only reconcile_constitution (src/specify_cli/presets/command_set_priority.py:55-59). Install and remove also call _reconcile_composed_commands and _reconcile_skills "so that install order doesn't determine the winning command file" (src/specify_cli/presets/_manager.py:479-489, :899-912). After set-priority, specify preset resolve therefore shows one winner while the agent runs the other.

The documentation only names install, remove and integration use as the times command files are rewritten (docs/reference/presets.md, "File Resolution"), and does not mention set-priority. Maintainers may therefore treat this as a documentation gap rather than a code bug. Either way, the current behaviour is not described anywhere, and the set-priority section reads as if it applies to every file a preset provides.

Steps to Reproduce

From a fresh clone after uv sync, save the following as repro.py and run uv run python -I repro.py:

import json, os, pathlib, tempfile
from typer.testing import CliRunner
from specify_cli import app

base = pathlib.Path(tempfile.mkdtemp())
proj = base / "proj"
(proj / ".specify" / "templates" / "commands").mkdir(parents=True)
(proj / ".specify" / "templates" / "commands" / "demo.md").write_text(
    "---\ndescription: core\n---\nCORE\n")
(proj / ".specify" / "init-options.json").write_text(json.dumps({"ai": "gemini"}))
(proj / ".gemini" / "commands").mkdir(parents=True)

def make_preset(pid, body):
    src = base / pid
    (src / "commands").mkdir(parents=True)
    (src / "commands" / "speckit.demo.md").write_text(f"---\ndescription: {pid}\n---\n{body}\n")
    (src / "preset.yml").write_text(
        'schema_version: "1.0"\n'
        f'preset:\n  id: {pid}\n  name: {pid}\n  version: "1.0.0"\n  description: d\n'
        'requires:\n  speckit_version: ">=0.0.1"\n'
        'provides:\n  templates:\n    - type: command\n      name: speckit.demo\n'
        '      file: commands/speckit.demo.md\n')
    return src

os.chdir(proj)
run = lambda *a: CliRunner().invoke(app, list(a))
agent_file = proj / ".gemini" / "commands" / "speckit.demo.toml"
body = lambda: "A" if "BODY-FROM-A" in agent_file.read_text() else "B"
print("add pa:", run("preset", "add", "--dev", str(make_preset("pa", "BODY-FROM-A")), "--priority", "10").exit_code)
print("add pb:", run("preset", "add", "--dev", str(make_preset("pb", "BODY-FROM-B")), "--priority", "20").exit_code)
print("agent file body after installs:", body())
print("set-priority pb 1:", run("preset", "set-priority", "pb", "1").exit_code)
r = run("preset", "resolve", "speckit.demo")
print("resolve:", [l.strip() for l in r.output.splitlines() if "from:" in l])
print("agent file body after set-priority:", body())
Expected Behavior

docs/reference/presets.md:229 says set-priority "Changes the resolution priority of an installed preset. Lower numbers take precedence. When multiple presets provide the same file, the one with the lowest priority number wins." The FAQ (docs/reference/presets.md:416) says to "Use specify preset set-priority to control the order". After set-priority pb 1, .gemini/commands/speckit.demo.toml should contain pb's body. If that is not intended, the docs should say that command files keep their content until the next install or removal, as the disable FAQ already does for preset disable (docs/reference/presets.md:424).

Actual Behavior

preset resolve reports pb as the top layer, but the Gemini command file still contains pa's body:

add pa: 0
add pb: 0
agent file body after installs: A
set-priority pb 1: 0
resolve: ['(top layer from: pb v1.0.0)']
agent file body after set-priority: A
Specify CLI Version

1.2.4.dev0 (main at 27d14e2)

AI Agent

Gemini CLI

Operating System

Linux 6.18 (Ubuntu container)

Python Version

Python 3.12.3

Additional Context

Running the same command and skill reconciliation that install and remove use, for the commands the re-prioritised preset provides, would bring set-priority into line with them.

Related: a test docstring in #4709 notes that preset commands "stay stale until removal", but that pull request does not change set-priority.

Also reproduced on macOS (Darwin 25.6, arm64) with Python 3.14.4 and uv run python -I repro.py against 27d14e2; the output matches the above.

AI Disclosure

Found and reproduced with Claude Code (model: Claude Opus 4.8), run autonomously under human supervision. The human reporter re-ran every reproduction above before filing.

主要語言
Python
星號
144k
分支
12.9k
平均合併
1 天 4 小時
30 天內合併 PR
181

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

github/spec-kit 的其他 Issue

查看 github/spec-kit 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。