1实现原理 · 为什么它能做到
先跑诊断脚本做机械排查:diagnose_plugins.py 读本地 ~/.claude 插件状态文件(installed_plugins.json、settings.json 的 enabledPlugins、known_marketplaces.json),比对‘已装未启用’清单并检查缓存新鲜度。
Run the diagnostic script to identify common issues: ```bash python3 scripts/diagnose_plugins.py
诊断核心判据:以 known_marketplaces.json 的 lastUpdated 为唯一新鲜度来源(严格 ISO-8601 带时区解析,缺失/畸形/无时区/未来时间戳都算无效),不信任 cache 目录 mtime。
never guess freshness from the unreliable cache-directory mtime.
修复路径分两层:官方 CLI(claude plugin enable/disable/update)与直接编辑 settings.json 的 enabledPlugins;并提供批量启用脚本 enable_all_plugins.py(按 marketplace 后缀匹配,写前交互确认)。
claude plugin enable plugin-name@marketplace-name
知识库支撑:references/architecture.md 描述插件生命周期与激活流(装→拷 cache→注册→手动 enable→启动读 enabledPlugins),references/known_issues.md 追踪 GitHub 上游 issue(#17832 等),SKILL.md 内嵌 4 个 Common Issues 的根因与解法。
https://github.com/anthropics/claude-code/issues/17832
对‘Skill 与 Command 两套扩展’做了架构澄清:skills/ 自动按描述匹配激活,commands/ 需 /command-name 显式调用,若要显式可调需补 command 文件。
If a skill should be explicitly invocable, add a corresponding command file.
2核心能力
3外部依赖
| Kind | Dependency / Endpoint |
|---|---|
| cli | python3 |
| cli | claude(官方 CLI:plugin enable/disable/install/uninstall/marketplace update) |
| cli | jq(诊断命令参考中读 JSON) |
| network | GitHub(issue 引用与 marketplace 内容源) |
4管控建议与判定依据
- scripts/: 执行本地脚本或命令: scripts/diagnose_plugins.py
- 网络端点: 声明外部网络访问: (SKILL 指引的用户动作)claude plugin marketplace update —— 官方 CLI 从已注册 marketplace
- 本地工作目录: 文件读写与工件输出: ~/.claude/settings.json 的 enabledPlugins(仅 enable_all_plugins.py 交互确认后整文件回写
5第二遍独立确认
- [ok] 无网络外发(脚本层) — 两脚本零网络;https 只出现在 SKILL/known_issues 文档链接
- [ok] diagnose 只读声明属实 — 全文仅 json.load + print,无写文件路径
- [ok] enable_all 写前确认属实 — 写入前 input("Enable all these plugins? [y/N] "),非 y 即取消
- [ok] lastUpdated 唯一新鲜度来源规则三方一致 — SKILL.md / architecture.md / diagnose_plugins.py 同口径(时区必需、mtime 不可信、7 天过期、未来时间戳无效)
- [ok] 诊断退出码语义 — main() 末尾 missing/stale/invalid 任一成立打印 Action needed 并 return 1,与 SKILL 'exits nonzero' 一致
- [ok] settings.json 含密钥时的接触面 — enable_all 整文件 json.load/json.dump 回写;密钥字段原样保留不处理——按统一分档‘接触即 orange’上浮边界,本档定 yellow 因脚本从不读取/传递密钥字段,reason 已注明触发条件
6结论
3f56dc20d44cb7a1…