Skip to content

[AI审查][Bug] SKILL.md 进化流程调用了不存在的 version_manager.py --action backup,存档步骤必然失败 #25

Description

@josephmqiu

Important

🤖 AI 代码审查声明:本 issue 由 AI 模型 Claude Fable 5(Anthropic,运行于 Claude Code)在一次完整代码审查中发现并撰写,经 @josephmqiu 授权提交。审查基于当前 main 分支 HEAD(commit c5ece53),下述复现步骤已在本地实际运行验证。

问题描述

SKILL.md 的「进化模式:追加文件」流程要求在更新前先存档当前版本,调用的是:

python3 ${CLAUDE_SKILL_DIR}/tools/version_manager.py --action backup --slug {slug} --base-dir ./exes

(中文版 SKILL.md 第 318 行,英文版第 587 行)

version_manager.py 根本没有 backup 这个 action —— argparse 的 choices 只有三个(version_manager.py:110):

parser.add_argument("--action", required=True, choices=["list", "rollback", "cleanup"])

复现步骤(已实际验证)

在仓库根目录执行:

python3 tools/version_manager.py --action backup --slug example_xiaomei --base-dir ./exes

实际输出:

usage: version_manager.py [-h] --action {list,rollback,cleanup} --slug SLUG
                          [--version VERSION] [--base-dir BASE_DIR]
version_manager.py: error: argument --action: invalid choice: 'backup' (choose from 'list', 'rollback', 'cleanup')

退出码 2,每次必然失败

影响

  • 进化流程的第 4 步(存档)永远报错。如果 agent 忽略报错继续执行第 5-7 步,更新就在没有任何存档的情况下落盘。
  • 后果是 README 宣传的「版本管理 —— 每次更新自动存档,支持回滚到任意历史版本」实际上无法兑现:rollbackversions/ 目录里没有东西可回滚。
  • 存档逻辑其实已经写好了,但只存在于 skill_writer.pyupdate_skill() 里(skill_writer.py:208-214)——而 SKILL.md 的进化流程没有调用它,用的是直接 Edit 文件。

修复建议

两个方向,任选其一:

方案 A(推荐):给 version_manager.py 补上 backup action,与 SKILL.md 现有指令保持一致:

def backup(skill_dir: Path) -> Path | None:
    """存档当前版本到 versions/{current_version}/"""
    meta_path = skill_dir / "meta.json"
    if not meta_path.exists():
        print(f"错误:找不到 {meta_path}", file=sys.stderr)
        return None
    meta = json.loads(meta_path.read_text(encoding="utf-8"))
    current_version = meta.get("version", "v1")
    backup_dir = skill_dir / "versions" / current_version
    backup_dir.mkdir(parents=True, exist_ok=True)
    for fname in ("SKILL.md", "memories.md", "persona.md"):
        src = skill_dir / fname
        if src.exists():
            shutil.copy2(src, backup_dir / fname)
    print(f"已存档当前版本到 {backup_dir}")
    return backup_dir

并在 main() 中:

parser.add_argument("--action", required=True, choices=["list", "rollback", "cleanup", "backup"])
...
elif args.action == "backup":
    backup(skill_dir)

方案 B:修改 SKILL.md,把进化流程改为调用已有的 skill_writer.py --action update(它内部自带存档)。缺点是 update 的语义是「追加 patch」,与 SKILL.md 现在「Edit 精确修改」的流程不完全一致。

如需要,我可以提交对应的 PR(含方案 A 的实现 + SKILL.md 中英文两处的核对)。


English TL;DR: SKILL.md's evolution flow invokes version_manager.py --action backup, but that action does not exist (argparse choices are list/rollback/cleanup only), so the archive-before-update step always exits with code 2 and the advertised rollback feature has nothing to roll back to. Repro verified locally at commit c5ece53. Suggested fix: add a backup action (implementation sketch above) or route the flow through skill_writer.py --action update.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions