Skip to content

Commit 74a9b7c

Browse files
committed
修复安装脚本:fallback 补装 agents、错误处理、参数校验
- fallback 安装现在也会安装 agents 到 .claude/agents/ - install 函数添加 try-catch 和 SKILLS_SRC 存在性检查 - 未知 CLI 参数显示警告并输出帮助 - 帮助文本补充 agents 相关说明
1 parent 6fa291f commit 74a9b7c

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

bin/superpowers-zh.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,30 @@ function showHelp() {
3030
superpowers-zh v${PKG.version} — AI 编程超能力中文版
3131
3232
用法:
33-
npx superpowers-zh 安装 skills 到当前项目
33+
npx superpowers-zh 安装 skills(及 agents)到当前项目
3434
npx superpowers-zh --help 显示帮助
3535
npx superpowers-zh --version 显示版本
3636
3737
说明:
3838
自动检测当前项目使用的 AI 编程工具:
3939
Claude Code / Cursor / Codex / Kiro / Trae / Antigravity / VS Code
4040
${countDirs(SKILLS_SRC)} 个 skills 安装到对应目录。
41-
如果未检测到任何工具,默认安装到 .claude/skills/。
41+
Claude Code 还会额外安装 agents 到 .claude/agents/。
42+
如果未检测到任何工具,默认安装到 .claude/skills/ 和 .claude/agents/。
4243
4344
项目:https://github.com/jnMetaCode/superpowers-zh
4445
`);
4546
}
4647

4748
function install() {
49+
try {
4850
console.log(`\n superpowers-zh v${PKG.version} — AI 编程超能力中文版\n`);
51+
52+
if (!existsSync(SKILLS_SRC)) {
53+
console.error(' ❌ 错误:skills 源目录不存在,请重新安装 superpowers-zh。');
54+
process.exit(1);
55+
}
56+
4957
console.log(` 源: ${countDirs(SKILLS_SRC)} 个 skills`);
5058
console.log(` 目标项目: ${PROJECT_DIR}\n`);
5159

@@ -75,16 +83,31 @@ function install() {
7583
mkdirSync(dest, { recursive: true });
7684
cpSync(SKILLS_SRC, dest, { recursive: true });
7785
console.log(` ✅ 默认安装: ${countDirs(dest)} 个 skills -> ${dest}`);
86+
87+
if (existsSync(AGENTS_SRC)) {
88+
const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
89+
mkdirSync(agentsDest, { recursive: true });
90+
cpSync(AGENTS_SRC, agentsDest, { recursive: true });
91+
console.log(` ✅ 默认安装: agents -> ${agentsDest}`);
92+
}
7893
}
7994

8095
console.log('\n 安装完成!重启你的 AI 编程工具即可生效。\n');
96+
} catch (err) {
97+
console.error(` ❌ 安装失败:${err.message}`);
98+
process.exit(1);
99+
}
81100
}
82101

83102
const arg = process.argv[2];
84103
if (arg === '--help' || arg === '-h') {
85104
showHelp();
86105
} else if (arg === '--version' || arg === '-v') {
87106
console.log(PKG.version);
107+
} else if (arg && arg.startsWith('-')) {
108+
console.warn(` 未知参数: ${arg}\n`);
109+
showHelp();
110+
process.exit(1);
88111
} else {
89112
install();
90113
}

0 commit comments

Comments
 (0)