[Bug]: `integration switch` leaves the manifest out of date when a preset overrides a core command

未关闭 适合新手
#5,078 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从 src/specify_cli/integrations/command_switch.py:380-389 开始,将其预设注册流程与 command_upgrade.py:352 和 src/specify_cli/integrations/_helpers.py:486-505 中的 _resync_manifest_after_registration 进行比较。运行 issue 中的复现步骤,并检查 tests/specify_cli/integrations/test_command_upgrade.py:1320-1385,了解现有的回归预期。完成标准是:切换后,manifest 哈希与重写后的预设文件匹配,并且后续升级无需 --force 即可成功。

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

描述

bug-assess invalid triage-must-have
Bug Description

specify integration switch <target> installs the target integration and saves its manifest (src/specify_cli/integrations/command_switch.py:309-316). It then re-registers installed presets for the target (command_switch.py:380-389). A preset that overrides a core command rewrites a file the manifest already tracks, and the manifest is not re-hashed afterwards. As a result integration status reports the file as modified, and a later integration upgrade without --force refuses to run, even though the user changed nothing.

integration upgrade handles the same situation by calling _resync_manifest_after_registration (command_upgrade.py:352, added for #4696). switch does not call it.

Steps to Reproduce

From the root of a fresh clone, after uv sync, save the script below as repro.py and run it with uv run python repro.py.

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

tmp = Path(tempfile.mkdtemp())
project = tmp / "proj"
project.mkdir()
os.chdir(project)
run = lambda *args: CliRunner().invoke(app, list(args))

run("init", "--here", "--integration", "claude", "--script", "sh", "--ignore-agent-tools")

preset = tmp / "tasks-preset"
(preset / "commands").mkdir(parents=True)
(preset / "commands" / "speckit.tasks.md").write_text(
    "---\ndescription: Tasks override\n---\nPreset tasks body\n")
(preset / "preset.yml").write_text("""schema_version: '1.0'
preset: {id: tasks-preset, name: Tasks Preset, version: 1.0.0, description: x}
requires: {speckit_version: '>=0.1.0'}
provides:
  templates:
  - {type: command, name: speckit.tasks, file: commands/speckit.tasks.md}
""")
run("preset", "add", "--dev", str(preset))

r = run("integration", "switch", "codex", "--script", "sh")
print("switch exit code:", r.exit_code)

rel = ".agents/skills/speckit-tasks/SKILL.md"
manifest = json.loads(Path(".specify/integrations/codex.manifest.json").read_text())
on_disk = hashlib.sha256(Path(rel).read_bytes()).hexdigest()
print("preset body in skill:", "Preset tasks body" in Path(rel).read_text())
print("manifest hash matches file:", manifest["files"][rel] == on_disk)

r = run("integration", "upgrade", "codex", "--script", "sh")
print("upgrade exit code:", r.exit_code)
print(r.output.strip())

The script initialises a project with Claude Code, adds a local preset that overrides speckit.tasks, switches to Codex, compares the manifest hash with the file on disk, and then runs integration upgrade codex without --force.

Expected Behavior

After the switch, the manifest hash for .agents/skills/speckit-tasks/SKILL.md matches the file that preset registration wrote, and integration upgrade codex succeeds. The docstring of _resync_manifest_after_registration (src/specify_cli/integrations/_helpers.py:486-505) says files rewritten by registration must be re-hashed "so check_modified() doesn't misreport a legitimate override as tampering", and names switch among the operations it serves. The regression test test_upgrade_force_syncs_manifest_hash_for_preset_overridden_skill (tests/specify_cli/integrations/test_command_upgrade.py:1320-1385) sets the same expectation for upgrade.

Actual Behavior
switch exit code: 0
preset body in skill: True
manifest hash matches file: False
upgrade exit code: 1
⚠  1 file(s) have been modified since installation:
    .agents/skills/speckit-tasks/SKILL.md

Use --force to overwrite modified files, or resolve manually.
Specify CLI Version

1.2.4.dev0 (main at 27d14e2)

AI Agent

Codex CLI

Operating System

Linux 6.18 (Ubuntu container)

Python Version

Python 3.12.3

Error Logs
⚠  1 file(s) have been modified since installation:
    .agents/skills/speckit-tasks/SKILL.md

Use --force to overwrite modified files, or resolve manually.
Additional Context

integration use (src/specify_cli/integrations/command_use.py) also re-registers presets without a manifest resync, so it looks affected in the same way, but I have not reproduced that path. Calling _resync_manifest_after_registration after preset registration in switch (and probably use) would likely fix it.

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
星标
149k
派生
13.4k
平均合并
1 天 5 小时
30 天内合并 PR
223

环境准备

在 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 摘要。