Files
superpowers-zh/bin/superpowers-zh.js
jiangnan 80bc100625 superpowers 中文社区版:14 个翻译 + 5 个中国特色原创 skills
基于 obra/superpowers (MIT) 完整汉化,新增中国开发者专属 skills:
- 中文代码审查:适配国内团队沟通文化
- 中文 Git 工作流:支持 Gitee/Coding/极狐 GitLab
- 中文技术文档:中英混排规范、排版标准
- 中文提交规范:Conventional Commits 中文适配 + commitlint 配置
- MCP 服务器构建:生产级 MCP 工具开发方法论

支持工具:CC / Cursor / Codex CLI / Gemini
安装:npx superpowers-zh
2026-03-20 11:32:25 +08:00

86 lines
2.8 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
import { existsSync, mkdirSync, cpSync, readdirSync, readFileSync } from 'fs';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const PKG = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8'));
const SKILLS_SRC = resolve(__dirname, '..', 'skills');
const AGENTS_SRC = resolve(__dirname, '..', 'agents');
const PROJECT_DIR = process.cwd();
const TARGETS = [
{ name: 'Claude Code', dir: '.claude/skills' },
{ name: 'Cursor', dir: '.cursor/skills' },
{ name: 'Codex CLI', dir: '.codex/skills' },
];
function countDirs(dir) {
if (!existsSync(dir)) return 0;
return readdirSync(dir, { withFileTypes: true }).filter(e => e.isDirectory()).length;
}
function showHelp() {
console.log(`
superpowers-zh v${PKG.version} — AI 编程超能力中文版
用法:
npx superpowers-zh 安装 skills 到当前项目
npx superpowers-zh --help 显示帮助
npx superpowers-zh --version 显示版本
说明:
自动检测当前项目使用的 AI 编程工具(.claude/ .cursor/ .codex/
${countDirs(SKILLS_SRC)} 个 skills 安装到对应目录。
如果未检测到任何工具,默认安装到 .claude/skills/。
项目https://github.com/jnMetaCode/superpowers-zh
`);
}
function install() {
console.log(`\n superpowers-zh v${PKG.version} — AI 编程超能力中文版\n`);
console.log(` 源: ${countDirs(SKILLS_SRC)} 个 skills`);
console.log(` 目标项目: ${PROJECT_DIR}\n`);
let installed = 0;
for (const target of TARGETS) {
const configDir = resolve(PROJECT_DIR, target.dir.split('/')[0]);
const dest = resolve(PROJECT_DIR, target.dir);
if (existsSync(configDir) || installed === 0) {
mkdirSync(dest, { recursive: true });
cpSync(SKILLS_SRC, dest, { recursive: true });
const count = countDirs(dest);
console.log(`${target.name}: ${count} 个 skills -> ${dest}`);
installed++;
if (target.name === 'Claude Code' && existsSync(AGENTS_SRC)) {
const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
mkdirSync(agentsDest, { recursive: true });
cpSync(AGENTS_SRC, agentsDest, { recursive: true });
}
}
}
if (installed === 0) {
const dest = resolve(PROJECT_DIR, '.claude', 'skills');
mkdirSync(dest, { recursive: true });
cpSync(SKILLS_SRC, dest, { recursive: true });
console.log(` ✅ 默认安装: ${countDirs(dest)} 个 skills -> ${dest}`);
}
console.log('\n 安装完成!重启你的 AI 编程工具即可生效。\n');
}
const arg = process.argv[2];
if (arg === '--help' || arg === '-h') {
showHelp();
} else if (arg === '--version' || arg === '-v') {
console.log(PKG.version);
} else {
install();
}