From 74a9b7c1f08aa312de70a404cb26bb7f8a3c5b57 Mon Sep 17 00:00:00 2001 From: jiangnan <1394485448@qq.com> Date: Sat, 21 Mar 2026 00:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=89=E8=A3=85=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=9Afallback=20=E8=A1=A5=E8=A3=85=20agents?= =?UTF-8?q?=E3=80=81=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=E3=80=81=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fallback 安装现在也会安装 agents 到 .claude/agents/ - install 函数添加 try-catch 和 SKILLS_SRC 存在性检查 - 未知 CLI 参数显示警告并输出帮助 - 帮助文本补充 agents 相关说明 --- bin/superpowers-zh.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/bin/superpowers-zh.js b/bin/superpowers-zh.js index 64b5127..bbcef19 100755 --- a/bin/superpowers-zh.js +++ b/bin/superpowers-zh.js @@ -30,7 +30,7 @@ function showHelp() { superpowers-zh v${PKG.version} — AI 编程超能力中文版 用法: - npx superpowers-zh 安装 skills 到当前项目 + npx superpowers-zh 安装 skills(及 agents)到当前项目 npx superpowers-zh --help 显示帮助 npx superpowers-zh --version 显示版本 @@ -38,14 +38,22 @@ function showHelp() { 自动检测当前项目使用的 AI 编程工具: Claude Code / Cursor / Codex / Kiro / Trae / Antigravity / VS Code 将 ${countDirs(SKILLS_SRC)} 个 skills 安装到对应目录。 - 如果未检测到任何工具,默认安装到 .claude/skills/。 + Claude Code 还会额外安装 agents 到 .claude/agents/。 + 如果未检测到任何工具,默认安装到 .claude/skills/ 和 .claude/agents/。 项目:https://github.com/jnMetaCode/superpowers-zh `); } function install() { + try { console.log(`\n superpowers-zh v${PKG.version} — AI 编程超能力中文版\n`); + + if (!existsSync(SKILLS_SRC)) { + console.error(' ❌ 错误:skills 源目录不存在,请重新安装 superpowers-zh。'); + process.exit(1); + } + console.log(` 源: ${countDirs(SKILLS_SRC)} 个 skills`); console.log(` 目标项目: ${PROJECT_DIR}\n`); @@ -75,9 +83,20 @@ function install() { mkdirSync(dest, { recursive: true }); cpSync(SKILLS_SRC, dest, { recursive: true }); console.log(` ✅ 默认安装: ${countDirs(dest)} 个 skills -> ${dest}`); + + if (existsSync(AGENTS_SRC)) { + const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents'); + mkdirSync(agentsDest, { recursive: true }); + cpSync(AGENTS_SRC, agentsDest, { recursive: true }); + console.log(` ✅ 默认安装: agents -> ${agentsDest}`); + } } console.log('\n 安装完成!重启你的 AI 编程工具即可生效。\n'); + } catch (err) { + console.error(` ❌ 安装失败:${err.message}`); + process.exit(1); + } } const arg = process.argv[2]; @@ -85,6 +104,10 @@ if (arg === '--help' || arg === '-h') { showHelp(); } else if (arg === '--version' || arg === '-v') { console.log(PKG.version); +} else if (arg && arg.startsWith('-')) { + console.warn(` 未知参数: ${arg}\n`); + showHelp(); + process.exit(1); } else { install(); }