superpowers-zh 1.1.8 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  🌐 **简体中文** | [English (upstream)](https://github.com/obra/superpowers)
4
4
 
5
- > 🦸 **superpowers(116k+ ⭐)完整汉化 + 6 个中国原创 skills** — 让 Claude Code / Copilot CLI / Hermes Agent / Cursor / Windsurf / Kiro / Gemini CLI 等 **17 款 AI 编程工具**真正会干活。从头脑风暴到代码审查,从 TDD 到调试,每个 skill 都是经过实战验证的工作方法论。
5
+ > 🦸 **superpowers(159k+ ⭐)完整汉化 + 6 个中国原创 skills** — 让 Claude Code / Copilot CLI / Hermes Agent / Cursor / Windsurf / Kiro / Gemini CLI 等 **17 款 AI 编程工具**真正会干活。从头脑风暴到代码审查,从 TDD 到调试,每个 skill 都是经过实战验证的工作方法论。
6
6
 
7
7
  Chinese community edition of [superpowers](https://github.com/obra/superpowers) — 20 skills across 16 AI coding tools, including full translations and China-specific development skills.
8
8
 
@@ -49,10 +49,33 @@ AI:在开始实现之前,我需要了解几个关键问题:
49
49
 
50
50
  ## 这是什么?
51
51
 
52
- [superpowers](https://github.com/obra/superpowers) 是目前最火的 AI 编程 skills 框架(116k+ stars),为 AI 编程工具提供**系统化的工作方法论**。
52
+ [superpowers](https://github.com/obra/superpowers) 是目前最火的 AI 编程 skills 框架(159k+ stars),为 AI 编程工具提供**系统化的工作方法论**。
53
53
 
54
54
  **superpowers-zh** 在完整翻译的基础上,新增了面向中国开发者的特色 skills。
55
55
 
56
+ ### 🆚 与英文上游的区别(老被问,一次说清)
57
+
58
+ | 维度 | superpowers(英文上游) | superpowers-zh(中文增强版) |
59
+ |------|----------------------|---------------------------|
60
+ | ⭐ Star 数 | 159k+ | — |
61
+ | 📦 Skills 总数 | 14 | **20**(14 翻译 + 6 国产原创) |
62
+ | 🌐 语言 | 英文 | 中文(技术术语保留英文) |
63
+ | 🤖 **支持工具** | **6 款**:Claude Code / Cursor / Codex / OpenCode / Copilot CLI / Gemini CLI | **17 款**:上述 6 款 + Hermes Agent / Trae / Kiro / Qwen Code(通义灵码)/ OpenClaw / Claw Code / Antigravity / DeerFlow / VS Code / Windsurf / Aider |
64
+ | ⚡ **安装方式** | 按工具分别装(每款一条不同的 plugin marketplace 命令) | **`npx superpowers-zh` 一条命令自动识别项目里的工具并安装**;识别不出可 `--tool <name>` 显式指定 |
65
+ | 🇨🇳 Git 平台 | GitHub 为主 | GitHub + Gitee + Coding + 极狐 GitLab + **CNB(腾讯云原生构建)** |
66
+ | 🇨🇳 CI/CD 示例 | GitHub Actions | GitHub Actions + Gitee Go + Coding CI + 极狐 CI + `.cnb.yml` |
67
+ | 🇨🇳 代码审查风格 | 西方直接风格 | 适配国内团队沟通文化 |
68
+ | 🇨🇳 Git 提交规范 | 无 | Conventional Commits 中文适配 |
69
+ | 🇨🇳 中文文档规范 | 无 | 中文排版 + 中英混排规则 + 告别机翻味 |
70
+ | ➕ MCP 服务器构建 | 无 | 独立 `mcp-builder` skill |
71
+ | ➕ 工作流执行器 | 无 | 独立 `workflow-runner` skill(多角色 YAML 编排) |
72
+ | 🔄 版本跟进 | 独立迭代 | **同步上游 + 国产增量叠加** |
73
+ | 🤝 接受新 skill PR | 一般不接受(原文:*"we don't generally accept contributions of new skills"*) | 欢迎 PR(中国开发者痛点优先) |
74
+ | 💬 社区 | Discord | 微信公众号「AI不止语」+ 微信群 + QQ 群 |
75
+ | 📜 License | MIT | MIT |
76
+
77
+ **一句话总结:** 英文上游 = 方法论内核;中文增强版 = 方法论内核 **+** 17 款工具一键适配 **+** 国内 Git/CI 生态 **+** 中文化表达习惯。
78
+
56
79
  ### 🤖 支持 17 款主流 AI 编程工具
57
80
 
58
81
  | 工具 | 类型 | 一键安装 | 手动安装 |
@@ -171,21 +194,6 @@ cp -r superpowers-zh/skills /your/project/.claw/skills # Claw Code(Rust
171
194
 
172
195
  ---
173
196
 
174
- ## 对比上游
175
-
176
- | 特性 | superpowers (英文) | superpowers-zh (中文) |
177
- |------|-------------------|----------------------|
178
- | Skills 数量 | 14 | **20**(14 翻译 + 6 原创) |
179
- | 语言 | 英文 | 中文(技术术语保留英文) |
180
- | 代码审查规范 | 西方直接风格 | 适配国内团队沟通文化 |
181
- | Git 平台 | GitHub 为主 | GitHub + Gitee + Coding + 极狐 |
182
- | Git 提交规范 | 无 | Conventional Commits 中文适配 |
183
- | 文档规范 | 英文 | 中文排版规范 + 中英混排 |
184
- | MCP 构建 | 无 | MCP 服务器构建方法论 |
185
- | 社区 | Discord | 微信公众号 + 微信群 |
186
-
187
- ---
188
-
189
197
  ## 贡献
190
198
 
191
199
  欢迎参与!翻译改进、新增 skills、Bug 修复都可以。
@@ -208,20 +216,44 @@ cp -r superpowers-zh/skills /your/project/.claw/skills # Claw Code(Rust
208
216
 
209
217
  | 渠道 | 加入方式 |
210
218
  |------|---------|
211
- | QQ 群 | [点击加入](https://qm.qq.com/q/EeNQA9xCxy)(群号 1071280067) |
219
+ | QQ 2群 | [点击加入](https://qm.qq.com/q/EeNQA9xCxy)(群号 1071280067) |
212
220
  | 微信群 | 关注公众号后回复「群」获取入群方式 |
213
221
 
214
222
  ---
215
223
 
224
+ ## 🌟 相关项目生态
225
+
226
+ **五个项目组合使用,覆盖 AI 编程从"方法论 → 角色 → 协作 → 教程 → 安全"的完整链路。**
227
+
228
+ | 项目 | 定位 | 一句话 |
229
+ |------|------|-------|
230
+ | **[superpowers-zh](https://github.com/jnMetaCode/superpowers-zh)**(本项目) ![](https://img.shields.io/github/stars/jnMetaCode/superpowers-zh?style=flat&label=⭐) | 🧠 工作方法论 | 20 个 skills 教 AI 怎么干活(TDD / 调试 / 代码审查等) |
231
+ | **[agency-agents-zh](https://github.com/jnMetaCode/agency-agents-zh)** ![](https://img.shields.io/github/stars/jnMetaCode/agency-agents-zh?style=flat&label=⭐) | 🎭 专家角色库 | 211 个**即插即用** AI 专家,含 46 中国原创(小红书 / 抖音 / 飞书 / 钉钉) |
232
+ | **[agency-orchestrator](https://github.com/jnMetaCode/agency-orchestrator)** | 🚀 编排引擎 | 一句话 → 211 专家协作,**几分钟出方案**(9 家 LLM / 6 免费) |
233
+ | **[ai-coding-guide](https://github.com/jnMetaCode/ai-coding-guide)** | 📖 实战教程 | 66 个 Claude Code 技巧 + 9 款工具最佳实践 + 配置模板 |
234
+ | **[shellward](https://github.com/jnMetaCode/shellward)** | 🛡️ 安全中间件 | 8 层防御 + DLP 数据流 + 注入检测,**零依赖**(含 MCP Server) |
235
+
236
+ ---
237
+
238
+ ### 🔥 重点推荐:[agency-orchestrator](https://github.com/jnMetaCode/agency-orchestrator) — 一句话调度 211 个 AI 专家协作,几分钟交付完整方案
239
+
240
+ 以前写个方案:你当指挥官,把 AI 轮流扮演 5 个角色,复制粘贴 10 次,1 小时没了。
241
+
242
+ **现在:** 丢一句话进去 `"做一个电商退款流程"`,**产品 → 架构 → 安全 → 测试 → DBA 自动接力**,几分钟完整方案落地。
243
+
244
+ - 🎭 **211+ 专家角色**(含 46 个中国市场原创:小红书 / 抖音 / 微信 / 飞书 / 钉钉)
245
+ - 🧩 **零代码 YAML**,一行 prompt 就能跑
246
+ - 💰 **9 家 LLM 可选**(DeepSeek / Claude / OpenAI / Ollama 等,**6 家免费**)
247
+ - 🔗 **与 superpowers-zh 互补**:本项目管"**怎么做**"(方法论),orchestrator 管"**谁来做**"(角色协作)
248
+
249
+ 👉 **[立即体验 agency-orchestrator →](https://github.com/jnMetaCode/agency-orchestrator)**
250
+
251
+ ---
252
+
216
253
  ## 致谢
217
254
 
218
255
  - 原始英文版:[obra/superpowers](https://github.com/obra/superpowers)(MIT 协议)
219
256
  - 感谢 [@obra](https://github.com/obra) 创建了这个优秀的项目
220
- - 姊妹项目:
221
- - [ai-coding-guide](https://github.com/jnMetaCode/ai-coding-guide) — AI 编程工具实战指南 — 66 个 Claude Code 技巧 + 9 款工具最佳实践 + 可复制配置模板
222
- - [agency-agents-zh](https://github.com/jnMetaCode/agency-agents-zh) — 187 个专业角色,让 AI 变成安全工程师、DBA、产品经理等
223
- - [agency-orchestrator](https://github.com/jnMetaCode/agency-orchestrator) — 多智能体编排引擎 — 用 YAML 编排 187 个角色协作,支持 DeepSeek/Claude/OpenAI/Ollama,零代码
224
- - [shellward](https://github.com/jnMetaCode/shellward) — AI 智能体安全中间件 — 注入检测、数据防泄露、命令安全、零依赖、MCP Server
225
257
 
226
258
  ---
227
259
 
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, copyFileSync, lstatSync, realpathSync } from 'fs';
3
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, copyFileSync, lstatSync, realpathSync, rmSync } from 'fs';
4
4
  import { resolve, dirname, join } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
+ import { homedir } from 'os';
6
7
 
7
8
  // 手动递归复制:跨 Node 版本和操作系统行为一致
8
9
  // 不使用 cpSync —— 在 Windows + npx 缓存(含 junction)+ Node 16.7-18 下不稳定
@@ -14,6 +15,7 @@ function copyDirSync(src, dest) {
14
15
  mkdirSync(dest, { recursive: true });
15
16
  const entries = readdirSync(realSrc, { withFileTypes: true });
16
17
  for (const entry of entries) {
18
+ if (entry.name === '.DS_Store') continue;
17
19
  const srcPath = join(realSrc, entry.name);
18
20
  const destPath = join(dest, entry.name);
19
21
  let stat;
@@ -86,6 +88,15 @@ function scanSkillEntries(skillsDir) {
86
88
  return entries;
87
89
  }
88
90
 
91
+ // 段落哨兵:v1.2.1+ 安装时把追加内容包在两条 HTML 注释之间,
92
+ // 让卸载可以精确切除,无需依赖标题层级猜测段尾。
93
+ const SENTINEL_BEGIN = '<!-- superpowers-zh:begin (do not edit between these markers) -->';
94
+ const SENTINEL_END = '<!-- superpowers-zh:end -->';
95
+
96
+ function wrapWithSentinel(body) {
97
+ return `${SENTINEL_BEGIN}\n${body.replace(/\n+$/, '')}\n${SENTINEL_END}\n`;
98
+ }
99
+
89
100
  function generateTraeBootstrapRule(projectDir) {
90
101
  const rulesDir = resolve(projectDir, '.trae', 'rules');
91
102
  mkdirSync(rulesDir, { recursive: true });
@@ -190,13 +201,13 @@ ${skillList}
190
201
  if (existsSync(convPath)) {
191
202
  const existing = readFileSync(convPath, 'utf8');
192
203
  if (!existing.includes('superpowers-zh')) {
193
- writeFileSync(convPath, existing + '\n\n' + content, 'utf8');
204
+ writeFileSync(convPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
194
205
  console.log(` ✅ Aider: 追加 skills 引用 -> ${convPath}`);
195
206
  } else {
196
207
  console.log(` ✅ Aider: CONVENTIONS.md 已包含 superpowers-zh 引用`);
197
208
  }
198
209
  } else {
199
- writeFileSync(convPath, content, 'utf8');
210
+ writeFileSync(convPath, wrapWithSentinel(content), 'utf8');
200
211
  console.log(` ✅ Aider: bootstrap -> ${convPath}`);
201
212
  }
202
213
  }
@@ -232,13 +243,13 @@ ${skillList}
232
243
  if (existsSync(geminiPath)) {
233
244
  const existing = readFileSync(geminiPath, 'utf8');
234
245
  if (!existing.includes('superpowers-zh')) {
235
- writeFileSync(geminiPath, existing + '\n\n' + content, 'utf8');
246
+ writeFileSync(geminiPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
236
247
  console.log(` ✅ Gemini CLI: 追加 skills 引用 -> ${geminiPath}`);
237
248
  } else {
238
249
  console.log(` ✅ Gemini CLI: GEMINI.md 已包含 superpowers-zh 引用`);
239
250
  }
240
251
  } else {
241
- writeFileSync(geminiPath, content, 'utf8');
252
+ writeFileSync(geminiPath, wrapWithSentinel(content), 'utf8');
242
253
  console.log(` ✅ Gemini CLI: bootstrap -> ${geminiPath}`);
243
254
  }
244
255
  }
@@ -288,17 +299,60 @@ ${skillList}
288
299
  if (existsSync(hermesPath)) {
289
300
  const existing = readFileSync(hermesPath, 'utf8');
290
301
  if (!existing.includes('superpowers-zh')) {
291
- writeFileSync(hermesPath, existing + '\n\n' + content, 'utf8');
302
+ writeFileSync(hermesPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
292
303
  console.log(` ✅ Hermes Agent: 追加 skills 引用 -> ${hermesPath}`);
293
304
  } else {
294
305
  console.log(` ✅ Hermes Agent: HERMES.md 已包含 superpowers-zh 引用`);
295
306
  }
296
307
  } else {
297
- writeFileSync(hermesPath, content, 'utf8');
308
+ writeFileSync(hermesPath, wrapWithSentinel(content), 'utf8');
298
309
  console.log(` ✅ Hermes Agent: bootstrap -> ${hermesPath}`);
299
310
  }
300
311
  }
301
312
 
313
+ function generateClaudeCodeBootstrap(projectDir) {
314
+ const skillEntries = scanSkillEntries(SKILLS_SRC);
315
+ const skillList = skillEntries.map(s => `- **${s.name}**: ${s.desc}`).join('\n');
316
+
317
+ const content = `# Superpowers-ZH 中文增强版
318
+
319
+ 本项目已安装 superpowers-zh 技能框架(${skillEntries.length} 个 skills)。
320
+
321
+ ## 核心规则
322
+
323
+ 1. **收到任务时,先检查是否有匹配的 skill** — 哪怕只有 1% 的可能性也要检查
324
+ 2. **设计先于编码** — 收到功能需求时,先用 brainstorming skill 做需求分析
325
+ 3. **测试先于实现** — 写代码前先写测试(TDD)
326
+ 4. **验证先于完成** — 声称完成前必须运行验证命令
327
+
328
+ ## 可用 Skills
329
+
330
+ Skills 位于 \`.claude/skills/\` 目录,每个 skill 有独立的 \`SKILL.md\` 文件。
331
+
332
+ ${skillList}
333
+
334
+ ## 如何使用
335
+
336
+ 当任务匹配某个 skill 时,使用 \`Skill\` 工具加载对应 skill 并严格遵循其流程。绝不要用 Read 工具读取 SKILL.md 文件。
337
+
338
+ 如果你认为哪怕只有 1% 的可能性某个 skill 适用于你正在做的事情,你必须调用该 skill 检查。
339
+ `;
340
+
341
+ const mdPath = resolve(projectDir, 'CLAUDE.md');
342
+ if (existsSync(mdPath)) {
343
+ const existing = readFileSync(mdPath, 'utf8');
344
+ if (!existing.includes('superpowers-zh')) {
345
+ writeFileSync(mdPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
346
+ console.log(` ✅ Claude Code: 追加 skills 引用 -> ${mdPath}`);
347
+ } else {
348
+ console.log(` ✅ Claude Code: CLAUDE.md 已包含 superpowers-zh 引用`);
349
+ }
350
+ } else {
351
+ writeFileSync(mdPath, wrapWithSentinel(content), 'utf8');
352
+ console.log(` ✅ Claude Code: bootstrap -> ${mdPath}`);
353
+ }
354
+ }
355
+
302
356
  // 工具名称别名映射(用户输入 -> TARGETS.name)
303
357
  const TOOL_ALIASES = {
304
358
  'claude': 'Claude Code',
@@ -337,6 +391,8 @@ function showHelp() {
337
391
  用法:
338
392
  npx superpowers-zh 自动检测工具并安装
339
393
  npx superpowers-zh --tool cursor 指定工具安装(检测不到时使用)
394
+ npx superpowers-zh --uninstall 卸载当前目录下的 superpowers-zh
395
+ npx superpowers-zh --force 允许在用户主目录(~)安装(默认拒绝)
340
396
  npx superpowers-zh --help 显示帮助
341
397
  npx superpowers-zh --version 显示版本
342
398
 
@@ -349,6 +405,9 @@ function showHelp() {
349
405
  npx superpowers-zh --tool cursor
350
406
  npx superpowers-zh --tool trae
351
407
 
408
+ 误装到主目录可以这样清理:
409
+ cd ~ && npx superpowers-zh --uninstall
410
+
352
411
  项目:https://github.com/jnMetaCode/superpowers-zh
353
412
  `);
354
413
  }
@@ -358,8 +417,8 @@ function installForTarget(target) {
358
417
  const srcCount = countDirs(SKILLS_SRC);
359
418
  mkdirSync(dest, { recursive: true });
360
419
  copyDirSync(SKILLS_SRC, dest);
361
- const count = countDirs(dest);
362
- if (srcCount > 0 && count === 0) {
420
+ const totalAfter = countDirs(dest);
421
+ if (srcCount > 0 && totalAfter === 0) {
363
422
  throw new Error(
364
423
  `复制 skills 失败:源目录 ${SKILLS_SRC} 有 ${srcCount} 个 skill,但目标 ${dest} 为空。` +
365
424
  `\n 这通常是 npx 缓存目录权限或路径问题。请尝试:\n` +
@@ -368,7 +427,7 @@ function installForTarget(target) {
368
427
  ` 3. 或手动克隆复制: 见 https://github.com/jnMetaCode/superpowers-zh#方式二手动安装`
369
428
  );
370
429
  }
371
- console.log(` ✅ ${target.name}: ${count} 个 skills -> ${dest}`);
430
+ console.log(` ✅ ${target.name}: ${srcCount} 个 skills -> ${dest}`);
372
431
 
373
432
  if (target.name === 'Trae') {
374
433
  generateTraeBootstrapRule(PROJECT_DIR);
@@ -390,14 +449,197 @@ function installForTarget(target) {
390
449
  generateHermesBootstrap(PROJECT_DIR);
391
450
  }
392
451
 
393
- if (target.name === 'Claude Code' && existsSync(AGENTS_SRC)) {
394
- const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
395
- mkdirSync(agentsDest, { recursive: true });
396
- copyDirSync(AGENTS_SRC, agentsDest);
452
+ if (target.name === 'Claude Code') {
453
+ generateClaudeCodeBootstrap(PROJECT_DIR);
454
+ if (existsSync(AGENTS_SRC)) {
455
+ const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
456
+ mkdirSync(agentsDest, { recursive: true });
457
+ copyDirSync(AGENTS_SRC, agentsDest);
458
+ }
397
459
  }
398
460
  }
399
461
 
400
- function install(forceToolName) {
462
+ function isHomeDir(p) {
463
+ const home = homedir();
464
+ if (!home) return false;
465
+ try {
466
+ return realpathSync(p) === realpathSync(home);
467
+ } catch { return resolve(p) === resolve(home); }
468
+ }
469
+
470
+ // 卸载支持:完整删除的 bootstrap 文件、需要清理段落的 bootstrap 文件
471
+ const BOOTSTRAP_DELETE = [
472
+ '.trae/rules/superpowers-zh.md',
473
+ '.antigravity/rules.md',
474
+ ];
475
+ const BOOTSTRAP_CLEAN_SECTION = [
476
+ 'CLAUDE.md',
477
+ 'GEMINI.md',
478
+ 'HERMES.md',
479
+ 'CONVENTIONS.md',
480
+ ];
481
+ const BOOTSTRAP_SECTION_MARKERS = [
482
+ '# Superpowers-ZH 中文增强版',
483
+ '# Superpowers-ZH 工作方法论',
484
+ ];
485
+
486
+ // v1.1.x 安装的旧 bootstrap 没有 sentinel,只能凭模板末尾固定句子识别段尾。
487
+ // 这些短语必须出现在 superpowers 段最后一行,且足够独特不易在用户内容里重合。
488
+ const FALLBACK_TAIL_HINTS = [
489
+ '你必须调用该 skill 检查。',
490
+ '严格遵循其流程。',
491
+ ];
492
+
493
+ function writeOrDelete(filePath, head, tail) {
494
+ const headTrim = head.replace(/\s+$/, '');
495
+ const tailTrim = tail.replace(/^\s+/, '');
496
+ let body = headTrim;
497
+ if (headTrim && tailTrim) body += '\n\n' + tailTrim;
498
+ else body += tailTrim;
499
+ body = body.replace(/\s+$/, '');
500
+ if (body.length === 0) {
501
+ rmSync(filePath);
502
+ } else {
503
+ writeFileSync(filePath, body + '\n', 'utf8');
504
+ }
505
+ }
506
+
507
+ function cleanBootstrapSection(filePath) {
508
+ if (!existsSync(filePath)) return false;
509
+ const content = readFileSync(filePath, 'utf8');
510
+
511
+ // 1. 哨兵模式(v1.2.1+)— 精确切除
512
+ const sBegin = content.indexOf(SENTINEL_BEGIN);
513
+ if (sBegin !== -1) {
514
+ const sEnd = content.indexOf(SENTINEL_END, sBegin + SENTINEL_BEGIN.length);
515
+ if (sEnd !== -1) {
516
+ writeOrDelete(filePath, content.slice(0, sBegin), content.slice(sEnd + SENTINEL_END.length));
517
+ return true;
518
+ }
519
+ }
520
+
521
+ // 2. 标题 marker(v1.1.x 安装的)— 找下一个 \n# 一级标题做段尾
522
+ let idx = -1;
523
+ for (const marker of BOOTSTRAP_SECTION_MARKERS) {
524
+ const i = content.indexOf(marker);
525
+ if (i !== -1 && (idx === -1 || i < idx)) idx = i;
526
+ }
527
+ if (idx === -1) return false;
528
+
529
+ let end = -1;
530
+ const nextHeading = content.indexOf('\n# ', idx + 1);
531
+ if (nextHeading !== -1) end = nextHeading + 1;
532
+
533
+ // 3. 一级标题找不到 — 用末尾固定短语做兜底
534
+ if (end === -1) {
535
+ for (const hint of FALLBACK_TAIL_HINTS) {
536
+ const i = content.lastIndexOf(hint);
537
+ if (i > idx) {
538
+ const nl = content.indexOf('\n', i + hint.length);
539
+ const after = nl !== -1 ? nl + 1 : content.length;
540
+ if (after > end) end = after;
541
+ }
542
+ }
543
+ }
544
+
545
+ // 4. 都找不到 — 数据安全,跳过 + 警告
546
+ if (end === -1) {
547
+ console.warn(` ⚠️ ${filePath}: 无法可靠识别 superpowers-zh 段尾,已跳过以避免数据丢失。`);
548
+ console.warn(` 请手动编辑此文件并删除以 "${BOOTSTRAP_SECTION_MARKERS[0]}" 开头的整段。`);
549
+ return false;
550
+ }
551
+
552
+ writeOrDelete(filePath, content.slice(0, idx), content.slice(end));
553
+ return true;
554
+ }
555
+
556
+ function uninstallForTarget(target, srcSkillNames) {
557
+ const dest = resolve(PROJECT_DIR, target.dir);
558
+ if (!existsSync(dest)) return 0;
559
+ let removed = 0;
560
+ for (const entry of readdirSync(dest, { withFileTypes: true })) {
561
+ if (entry.isDirectory() && srcSkillNames.has(entry.name)) {
562
+ rmSync(resolve(dest, entry.name), { recursive: true, force: true });
563
+ removed++;
564
+ }
565
+ }
566
+ // 如果目录已空(或仅剩 .DS_Store),顺手清掉,避免留下空骨架
567
+ try {
568
+ if (existsSync(dest)) {
569
+ const left = readdirSync(dest).filter(n => n !== '.DS_Store');
570
+ if (left.length === 0) rmSync(dest, { recursive: true, force: true });
571
+ }
572
+ } catch {}
573
+ return removed;
574
+ }
575
+
576
+ function uninstall() {
577
+ console.log(`\n superpowers-zh v${PKG.version} — 卸载\n`);
578
+ console.log(` 目标项目: ${PROJECT_DIR}\n`);
579
+
580
+ if (!existsSync(SKILLS_SRC)) {
581
+ console.error(' ❌ 错误:skills 源目录不存在,无法识别要卸载的 skill 名单。');
582
+ process.exit(1);
583
+ }
584
+
585
+ const srcSkillNames = new Set(
586
+ readdirSync(SKILLS_SRC, { withFileTypes: true })
587
+ .filter(e => e.isDirectory())
588
+ .map(e => e.name)
589
+ );
590
+
591
+ let totalSkills = 0;
592
+ for (const target of TARGETS) {
593
+ const removed = uninstallForTarget(target, srcSkillNames);
594
+ if (removed > 0) {
595
+ console.log(` ✅ ${target.name}: 移除 ${removed} 个 skills <- ${resolve(PROJECT_DIR, target.dir)}`);
596
+ totalSkills += removed;
597
+ }
598
+ }
599
+
600
+ // 顺带清理 .claude/agents 下我们装过的 agent(agents 源是平铺的文件,例如 code-reviewer.md)
601
+ const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
602
+ if (existsSync(AGENTS_SRC) && existsSync(agentsDest)) {
603
+ const srcAgentNames = new Set(readdirSync(AGENTS_SRC).filter(n => n !== '.DS_Store'));
604
+ let agentsRemoved = 0;
605
+ for (const entry of readdirSync(agentsDest)) {
606
+ if (srcAgentNames.has(entry)) {
607
+ rmSync(resolve(agentsDest, entry), { recursive: true, force: true });
608
+ agentsRemoved++;
609
+ }
610
+ }
611
+ if (agentsRemoved > 0) console.log(` ✅ Claude Code agents: 移除 ${agentsRemoved} 个 -> ${agentsDest}`);
612
+ try {
613
+ const left = readdirSync(agentsDest).filter(n => n !== '.DS_Store');
614
+ if (left.length === 0) rmSync(agentsDest, { recursive: true, force: true });
615
+ } catch {}
616
+ }
617
+
618
+ let bootstrapsRemoved = 0;
619
+ for (const rel of BOOTSTRAP_DELETE) {
620
+ const full = resolve(PROJECT_DIR, rel);
621
+ if (existsSync(full)) {
622
+ rmSync(full);
623
+ console.log(` ✅ 删除 bootstrap: ${full}`);
624
+ bootstrapsRemoved++;
625
+ }
626
+ }
627
+ for (const rel of BOOTSTRAP_CLEAN_SECTION) {
628
+ const full = resolve(PROJECT_DIR, rel);
629
+ if (cleanBootstrapSection(full)) {
630
+ console.log(` ✅ 清理 bootstrap: ${full}`);
631
+ bootstrapsRemoved++;
632
+ }
633
+ }
634
+
635
+ if (totalSkills === 0 && bootstrapsRemoved === 0) {
636
+ console.log(' ⚠️ 未在当前目录找到 superpowers-zh 安装痕迹。');
637
+ } else {
638
+ console.log(`\n 卸载完成。共移除 ${totalSkills} 个 skill 目录、${bootstrapsRemoved} 个 bootstrap 文件。\n`);
639
+ }
640
+ }
641
+
642
+ function install(forceToolName, force) {
401
643
  try {
402
644
  console.log(`\n superpowers-zh v${PKG.version} — AI 编程超能力中文版\n`);
403
645
 
@@ -406,6 +648,27 @@ function install(forceToolName) {
406
648
  process.exit(1);
407
649
  }
408
650
 
651
+ if (!force && isHomeDir(PROJECT_DIR)) {
652
+ console.error(
653
+ ` ⚠️ 当前目录是用户主目录: ${PROJECT_DIR}
654
+
655
+ superpowers-zh 应该装到具体项目目录,而不是 ~/。
656
+ 在主目录安装会把 skills 和 bootstrap 文件(CLAUDE.md / HERMES.md 等)
657
+ 写入你的 home,污染所有项目。
658
+
659
+ 请先 cd 到项目目录:
660
+ cd /path/to/your/project
661
+ npx superpowers-zh
662
+
663
+ 如果你确实要在主目录安装(不推荐),加 --force:
664
+ npx superpowers-zh --force
665
+
666
+ 如果你已经在主目录误装过,可以用 --uninstall 清理:
667
+ npx superpowers-zh --uninstall
668
+ `);
669
+ process.exit(1);
670
+ }
671
+
409
672
  console.log(` 源: ${countDirs(SKILLS_SRC)} 个 skills`);
410
673
  console.log(` 目标项目: ${PROJECT_DIR}\n`);
411
674
 
@@ -445,6 +708,8 @@ function install(forceToolName) {
445
708
  copyDirSync(SKILLS_SRC, dest);
446
709
  console.log(` ✅ 默认安装: ${countDirs(dest)} 个 skills -> ${dest}`);
447
710
 
711
+ generateClaudeCodeBootstrap(PROJECT_DIR);
712
+
448
713
  if (existsSync(AGENTS_SRC)) {
449
714
  const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
450
715
  mkdirSync(agentsDest, { recursive: true });
@@ -464,11 +729,16 @@ const args = process.argv.slice(2);
464
729
  const helpIdx = args.findIndex(a => a === '--help' || a === '-h');
465
730
  const versionIdx = args.findIndex(a => a === '--version' || a === '-v');
466
731
  const toolIdx = args.findIndex(a => a === '--tool' || a === '-t');
732
+ const uninstallIdx = args.findIndex(a => a === '--uninstall' || a === '-u');
733
+ const forceIdx = args.findIndex(a => a === '--force' || a === '-f');
734
+ const force = forceIdx !== -1;
467
735
 
468
736
  if (helpIdx !== -1) {
469
737
  showHelp();
470
738
  } else if (versionIdx !== -1) {
471
739
  console.log(PKG.version);
740
+ } else if (uninstallIdx !== -1) {
741
+ uninstall();
472
742
  } else if (toolIdx !== -1) {
473
743
  const toolArg = args[toolIdx + 1];
474
744
  if (!toolArg) {
@@ -482,11 +752,11 @@ if (helpIdx !== -1) {
482
752
  console.error(` 支持的工具: ${Object.keys(TOOL_ALIASES).join(', ')}\n`);
483
753
  process.exit(1);
484
754
  }
485
- install(toolName);
486
- } else if (args.length > 0 && args[0].startsWith('-')) {
755
+ install(toolName, force);
756
+ } else if (args.length > 0 && args[0].startsWith('-') && forceIdx === -1) {
487
757
  console.warn(` 未知参数: ${args[0]}\n`);
488
758
  showHelp();
489
759
  process.exit(1);
490
760
  } else {
491
- install();
761
+ install(undefined, force);
492
762
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "superpowers-zh",
3
- "version": "1.1.8",
3
+ "version": "1.2.1",
4
4
  "engines": {
5
- "node": ">=14.0.0"
5
+ "node": ">=20.0.0"
6
6
  },
7
7
  "description": "AI 编程超能力中文增强版 — superpowers(99k+ ⭐)完整汉化 + 6 个中国原创 skills,支持 Claude Code / Copilot CLI / Hermes Agent / Cursor / Claw Code / Windsurf / Kiro / Gemini CLI 等 17 款工具",
8
8
  "type": "module",