superpowers-zh 1.1.9 → 1.3.0

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.
@@ -0,0 +1,107 @@
1
+ # Superpowers-ZH 中文版 Release Notes
2
+
3
+ > 本文档记录 `jnMetaCode/superpowers-zh` 中文 fork 自身的 release 历史。
4
+ >
5
+ > 上游 `obra/superpowers` 的英文 release notes 见 [`RELEASE-NOTES.md`](./RELEASE-NOTES.md)(原样保留,未翻译)。
6
+
7
+ ---
8
+
9
+ ## v1.3.0 (2026-05-10)
10
+
11
+ ### 跟上游对齐 (v5.1.0)
12
+
13
+ - **同步上游 v5.1.0 的目录变更**:上游主动删除了 `commands/`(3 个 deprecated stub)和 `agents/code-reviewer.md`(已上升进 `requesting-code-review` skill)。中文 fork 跟随删除以与上游意图对齐。详见上游 [#1188](https://github.com/obra/superpowers/pull/1188) 与 PR #1299。
14
+ - **`bin/superpowers-zh.js`** 移除安装时复制 `agents/` 到 `.claude/agents/` 的逻辑,**保留** uninstall 时的清理逻辑(用于已装用户清理残留 `code-reviewer.md`,防止双 source of truth)。
15
+ - **`.github/workflows/ci.yml`** 删除 "Validate agents" 验证段(`agents/` 已删,验证空目录无意义)。
16
+
17
+ ### 补齐上游遗漏的根级文件
18
+
19
+ - **`CLAUDE.md`** —— 上游 contributor 指南(含 anti-slop-PR 规则)的中文翻译,末尾追加中文 fork 自己的 PR 流程说明。
20
+ - **`AGENTS.md`** —— 软链接 → `CLAUDE.md`(mode 120000,跟上游一致)。Codex CLI 等工具从 `AGENTS.md` 自动加载等同读取 CLAUDE.md。
21
+ - **Known limitation**:`npm pack` 默认不跟随 symlink,因此 npm publish 出来的 tarball 不包含 AGENTS.md。这不影响实际使用:AGENTS.md 是 Codex CLI 在用户自己项目目录读的文件,不是从 `superpowers-zh` 安装包读的;通过 `git clone` 拿到仓库的贡献者会正确解析 symlink。
22
+ - **`RELEASE-NOTES.md`** —— 上游 release notes 原样保留(英文版,1180 行)。
23
+ - **`RELEASE-NOTES.zh.md`** —— 本文件,中文 fork 自身 release 记录。
24
+ - **`.codex-plugin/plugin.json`** —— Codex CLI plugin manifest(中文版本地化:name/description/displayName 改为中文版,URL 指向 `jnMetaCode/superpowers-zh`)。
25
+ - **`.version-bump.json`** —— 上游版本管理配置文件。
26
+ - **`scripts/bump-version.sh`** —— 上游版本同步脚本(含 `--check` 漂移检测、`--audit` 仓库审计)。中文版 npm version 钩子继续用 `scripts/sync-plugin-version.js`,bump-version.sh 作为补充工具引入。
27
+ - **`assets/app-icon.png`** + **`assets/superpowers-small.svg`** —— Codex marketplace 需要的图标资产。
28
+ - **4 个新增上游测试**:`tests/claude-code/test-requesting-code-review.sh`、`tests/claude-code/test-worktree-native-preference.sh`、`tests/opencode/test-bootstrap-caching.{mjs,sh}`。
29
+
30
+ ### 主动修复上游 v5.1.0 的疏忽
31
+
32
+ - **`.cursor-plugin/plugin.json`** 删除 dangling 的 `"agents": "./agents/"` 和 `"commands": "./commands/"` 两行。上游 v5.1.0 删了目录但忘了同步清理 manifest(git blame 显示这两行从 2026-02-13 加入后从未更新)。中文 fork 主动修掉(向上游开 issue 是后续动作)。
33
+
34
+ ### 修中文版自己的老漂移(PR #23)
35
+
36
+ - **`.claude-plugin/marketplace.json`** 的 `plugins[0].version` 卡在 `1.1.8` 的老漂移修复(追上其他 4 个 manifest,1.3.0 release 时统一升到 1.3.0)。原因是中文版简化版 `sync-plugin-version.js` 之前只 match 顶层 `"version":` 字段,跳过嵌套位置;导致 Claude Code marketplace 用户看到的 plugin 版本一直停在 1.1.8,跟 npm 包真实版本不同步。
37
+ - **`scripts/sync-plugin-version.js`** 增强为支持嵌套字段路径(`plugins.0.version`)。`TARGETS` 改为对象数组 `{ path, field }`,对齐上游 `.version-bump.json` 格式。仍使用 regex 替换而非 JSON re-stringify,保留原文件格式(缩进、行内/多行数组等不被破坏)。
38
+
39
+ ### 不引入
40
+
41
+ - 上游 `scripts/sync-to-codex-plugin.sh`(推 OpenAI Codex marketplace 用,硬编码 `prime-radiant-inc/openai-codex-plugins`,中文版用不上)
42
+ - 配套测试 `tests/codex-plugin-sync/test-sync-to-codex-plugin.sh`
43
+
44
+ ### 不动(中文版叠加层全部保留)
45
+
46
+ `bin/` + npx 流程、`docs/` 中文工具文档、4 个 `chinese-*` skill、`mcp-builder`、`workflow-runner`、`README.md` 主推 npx 路径、`.codex/INSTALL.md`、`.opencode/INSTALL.md`、`.gemini/`、`scripts/sync-plugin-version.js` —— 这些是符合"保持上游主流程不变 + 中文版叠加新增"原则的中文 fork 沉淀,全部保留。
47
+
48
+ ---
49
+
50
+ ## v1.2.1 (2026-05-05)
51
+
52
+ ### 修复
53
+
54
+ - **`--uninstall` 数据丢失边界 case** —— 加哨兵注释 + 保守 fallback,杜绝在某些路径上误删用户数据。
55
+
56
+ ---
57
+
58
+ ## v1.2.0 (2026-05-05)
59
+
60
+ ### 新增
61
+
62
+ - **`--uninstall` 子命令** —— `npx superpowers-zh --uninstall` 一条命令清理已安装的 skills(#17)。
63
+ - **HOME 目录守护** —— uninstall 时强校验工作目录非用户 HOME,杜绝误删全局文件。
64
+ - **计数显示修复** —— 安装后输出实际安装的 skill 数量(之前显示固定值)。
65
+
66
+ ---
67
+
68
+ ## v1.1.9 (2026-04-28)
69
+
70
+ ### 修复
71
+
72
+ - **Claude Code bootstrap 修复** —— npx 安装到 CC 目标时自动补上 `CLAUDE.md` bootstrap,根治 skill 不触发问题(#14)。
73
+
74
+ ### 变更
75
+
76
+ - **Node 引擎要求** 提升到 `>=20`(Node 14/16/18 均已 EOL)。
77
+ - **README 重排**:相关项目表挪到显眼位置;姊妹项目区块独立成"相关项目生态"章节,重点推广 orchestrator。
78
+ - **QQ 群** 标识改为 QQ 2群。
79
+
80
+ ---
81
+
82
+ ## v1.1.8 (2026-04-19)
83
+
84
+ ### 新增
85
+
86
+ - **Claw Code 支持**(第 17 款工具,Rust 版 AI CLI)—— auto-detect `.claw/` 或 `CLAW.md`,支持 `--tool claw/claw-code/clawcode`。
87
+ - **CNB(腾讯云原生构建)平台适配** —— `chinese-git-workflow` skill 新增 CNB 章节,含 `.cnb.yml` CI 示例(#6)。
88
+
89
+ ---
90
+
91
+ ## v1.1.0 – v1.1.7 早期开发(2026-03 ~ 2026-04)
92
+
93
+ 中文 fork 在这一时期完成了主要的多工具适配与中文化基建:
94
+
95
+ - 第 1 款 → 第 16 款工具陆续上线:Claude Code、Cursor、Codex CLI、Gemini CLI、Trae、VS Code (Copilot)、Antigravity、Hermes Agent、Copilot CLI、Windsurf、Aider、OpenCode、Qwen Code(通义灵码)、Kiro、OpenClaw、DeerFlow 2.0
96
+ - 4 个中国原创 skill 沉淀:`chinese-code-review`、`chinese-commit-conventions`、`chinese-documentation`、`chinese-git-workflow`
97
+ - `mcp-builder`、`workflow-runner` 两个补充 skill
98
+ - npx 一条命令自动检测项目工具并安装
99
+ - 跨平台兼容性修复:Windows `cpSync` 问题、低版本 Node 兼容、Antigravity/Aider/Gemini CLI 自动生成 bootstrap
100
+
101
+ ---
102
+
103
+ ## v1.0.0 (2026-03-09)
104
+
105
+ - 中文 fork 初始版本,基于上游 `obra/superpowers` v5.0.0 翻译。
106
+ - 完整翻译 14 个上游 skill。
107
+ - 首批支持 Claude Code 一种工具。
Binary file
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><svg id="Calque_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M394.28,207.8c.81,2.41,1.39,4.78,1.8,7.07,1.61,9.03-.93,17.78-5.99,21.74-22.6,17.7-49.85,29.35-75.34,38.6-.59.22-1.09.28-1.4.34-2.22.47-4.95,1.04-7.25,0-1.46-.66-2.25-1.74-2.66-2.3-1.56-2.1-1.59-4.31-1.56-5.13.1-2.67-.01-4.69,0-4.82.45-3.52.91-10.66,1.41-21.28.6-3.87,2.16-9.63,6.94-13.96,4.01-3.62,8.33-4.6,14.59-5.87,10.76-2.19,37.21-8.22,47.42-16.56,1.63-1.33,2.97-2.65,4.19-3.96,3.72-3.99,6.39-7.92,7.93-10.36,3.22,3.22,7.25,8.48,9.92,16.47Z"/><path d="M428.67,185.28c-2.33,11.99-8.91,22.32-15.88,30.38.27-5.5-.05-12.11-1.86-19.08-5.04-19.36-19.74-34.7-37.78-37.78-32.21-9.74-70.59,3.79-99.08,18.29-3.87,1.95-9.52-2.77-11.84-8.16-3.32-7.71-1.63-6.28,2.61-8.49,38.31-20.03,82.01-39.61,123.91-29.7,8.26,1.95,15.96,5.26,23.48,10.54,11.32,7.96,20.21,24.74,16.44,44Z"/><path d="M117.72,304.2c-.81-2.41-1.39-4.78-1.8-7.07-1.61-9.03.93-17.78,5.99-21.74,22.6-17.7,49.85-29.35,75.34-38.6.59-.22,1.09-.28,1.4-.34,2.22-.47,4.95-1.04,7.25,0,1.46.66,2.25,1.74,2.66,2.3,1.56,2.1,1.59,4.31,1.56,5.13-.1,2.67.01,4.69,0,4.82-.45,3.52-.91,10.66-1.41,21.28-.6,3.87-2.16,9.63-6.94,13.96-4.01,3.62-8.33,4.6-14.59,5.87-10.76,2.19-37.21,8.22-47.42,16.56-1.63,1.33-2.97,2.65-4.19,3.96-3.72,3.99-6.39,7.92-7.93,10.36-3.22-3.22-7.25-8.48-9.92-16.47Z"/><path d="M83.33,326.72c2.33-11.99,8.91-22.32,15.88-30.38-.27,5.5.05,12.11,1.86,19.08,5.04,19.36,19.74,34.7,37.78,37.78,32.21,9.74,70.59-3.79,99.08-18.29,3.87-1.95,9.52,2.77,11.84,8.16,3.32,7.71,1.63,6.28-2.61,8.49-38.31,20.03-82.01,39.61-123.91,29.7-8.26-1.95-15.96-5.26-23.48-10.54-11.32-7.96-20.21-24.74-16.44-44Z"/><ellipse cx="255.16" cy="258.86" rx="28.95" ry="28.76"/></svg>
@@ -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;
@@ -37,9 +39,13 @@ function copyDirSync(src, dest) {
37
39
  const __dirname = dirname(fileURLToPath(import.meta.url));
38
40
  const PKG = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8'));
39
41
  const SKILLS_SRC = resolve(__dirname, '..', 'skills');
40
- const AGENTS_SRC = resolve(__dirname, '..', 'agents');
41
42
  const PROJECT_DIR = process.cwd();
42
43
 
44
+ // 历史遗留 agent 文件名 — 用于 --uninstall 清理已装用户机器上的残留。
45
+ // 上游 v5.1.0 把 agents/code-reviewer.md 上升进 requesting-code-review skill,
46
+ // agents/ 目录已删,但旧版本装过的用户机器上仍有残留文件需要清理。
47
+ const LEGACY_AGENT_FILENAMES = ['code-reviewer.md'];
48
+
43
49
  const TARGETS = [
44
50
  { name: 'Claude Code', dir: '.claude/skills', detect: '.claude' },
45
51
  { name: 'Cursor', dir: '.cursor/skills', detect: ['.cursor', '.cursorrules'] },
@@ -86,6 +92,15 @@ function scanSkillEntries(skillsDir) {
86
92
  return entries;
87
93
  }
88
94
 
95
+ // 段落哨兵:v1.2.1+ 安装时把追加内容包在两条 HTML 注释之间,
96
+ // 让卸载可以精确切除,无需依赖标题层级猜测段尾。
97
+ const SENTINEL_BEGIN = '<!-- superpowers-zh:begin (do not edit between these markers) -->';
98
+ const SENTINEL_END = '<!-- superpowers-zh:end -->';
99
+
100
+ function wrapWithSentinel(body) {
101
+ return `${SENTINEL_BEGIN}\n${body.replace(/\n+$/, '')}\n${SENTINEL_END}\n`;
102
+ }
103
+
89
104
  function generateTraeBootstrapRule(projectDir) {
90
105
  const rulesDir = resolve(projectDir, '.trae', 'rules');
91
106
  mkdirSync(rulesDir, { recursive: true });
@@ -190,13 +205,13 @@ ${skillList}
190
205
  if (existsSync(convPath)) {
191
206
  const existing = readFileSync(convPath, 'utf8');
192
207
  if (!existing.includes('superpowers-zh')) {
193
- writeFileSync(convPath, existing + '\n\n' + content, 'utf8');
208
+ writeFileSync(convPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
194
209
  console.log(` ✅ Aider: 追加 skills 引用 -> ${convPath}`);
195
210
  } else {
196
211
  console.log(` ✅ Aider: CONVENTIONS.md 已包含 superpowers-zh 引用`);
197
212
  }
198
213
  } else {
199
- writeFileSync(convPath, content, 'utf8');
214
+ writeFileSync(convPath, wrapWithSentinel(content), 'utf8');
200
215
  console.log(` ✅ Aider: bootstrap -> ${convPath}`);
201
216
  }
202
217
  }
@@ -232,13 +247,13 @@ ${skillList}
232
247
  if (existsSync(geminiPath)) {
233
248
  const existing = readFileSync(geminiPath, 'utf8');
234
249
  if (!existing.includes('superpowers-zh')) {
235
- writeFileSync(geminiPath, existing + '\n\n' + content, 'utf8');
250
+ writeFileSync(geminiPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
236
251
  console.log(` ✅ Gemini CLI: 追加 skills 引用 -> ${geminiPath}`);
237
252
  } else {
238
253
  console.log(` ✅ Gemini CLI: GEMINI.md 已包含 superpowers-zh 引用`);
239
254
  }
240
255
  } else {
241
- writeFileSync(geminiPath, content, 'utf8');
256
+ writeFileSync(geminiPath, wrapWithSentinel(content), 'utf8');
242
257
  console.log(` ✅ Gemini CLI: bootstrap -> ${geminiPath}`);
243
258
  }
244
259
  }
@@ -288,13 +303,13 @@ ${skillList}
288
303
  if (existsSync(hermesPath)) {
289
304
  const existing = readFileSync(hermesPath, 'utf8');
290
305
  if (!existing.includes('superpowers-zh')) {
291
- writeFileSync(hermesPath, existing + '\n\n' + content, 'utf8');
306
+ writeFileSync(hermesPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
292
307
  console.log(` ✅ Hermes Agent: 追加 skills 引用 -> ${hermesPath}`);
293
308
  } else {
294
309
  console.log(` ✅ Hermes Agent: HERMES.md 已包含 superpowers-zh 引用`);
295
310
  }
296
311
  } else {
297
- writeFileSync(hermesPath, content, 'utf8');
312
+ writeFileSync(hermesPath, wrapWithSentinel(content), 'utf8');
298
313
  console.log(` ✅ Hermes Agent: bootstrap -> ${hermesPath}`);
299
314
  }
300
315
  }
@@ -331,13 +346,13 @@ ${skillList}
331
346
  if (existsSync(mdPath)) {
332
347
  const existing = readFileSync(mdPath, 'utf8');
333
348
  if (!existing.includes('superpowers-zh')) {
334
- writeFileSync(mdPath, existing + '\n\n' + content, 'utf8');
349
+ writeFileSync(mdPath, existing.replace(/\s+$/, '') + '\n\n' + wrapWithSentinel(content), 'utf8');
335
350
  console.log(` ✅ Claude Code: 追加 skills 引用 -> ${mdPath}`);
336
351
  } else {
337
352
  console.log(` ✅ Claude Code: CLAUDE.md 已包含 superpowers-zh 引用`);
338
353
  }
339
354
  } else {
340
- writeFileSync(mdPath, content, 'utf8');
355
+ writeFileSync(mdPath, wrapWithSentinel(content), 'utf8');
341
356
  console.log(` ✅ Claude Code: bootstrap -> ${mdPath}`);
342
357
  }
343
358
  }
@@ -380,6 +395,8 @@ function showHelp() {
380
395
  用法:
381
396
  npx superpowers-zh 自动检测工具并安装
382
397
  npx superpowers-zh --tool cursor 指定工具安装(检测不到时使用)
398
+ npx superpowers-zh --uninstall 卸载当前目录下的 superpowers-zh
399
+ npx superpowers-zh --force 允许在用户主目录(~)安装(默认拒绝)
383
400
  npx superpowers-zh --help 显示帮助
384
401
  npx superpowers-zh --version 显示版本
385
402
 
@@ -392,6 +409,9 @@ function showHelp() {
392
409
  npx superpowers-zh --tool cursor
393
410
  npx superpowers-zh --tool trae
394
411
 
412
+ 误装到主目录可以这样清理:
413
+ cd ~ && npx superpowers-zh --uninstall
414
+
395
415
  项目:https://github.com/jnMetaCode/superpowers-zh
396
416
  `);
397
417
  }
@@ -401,8 +421,8 @@ function installForTarget(target) {
401
421
  const srcCount = countDirs(SKILLS_SRC);
402
422
  mkdirSync(dest, { recursive: true });
403
423
  copyDirSync(SKILLS_SRC, dest);
404
- const count = countDirs(dest);
405
- if (srcCount > 0 && count === 0) {
424
+ const totalAfter = countDirs(dest);
425
+ if (srcCount > 0 && totalAfter === 0) {
406
426
  throw new Error(
407
427
  `复制 skills 失败:源目录 ${SKILLS_SRC} 有 ${srcCount} 个 skill,但目标 ${dest} 为空。` +
408
428
  `\n 这通常是 npx 缓存目录权限或路径问题。请尝试:\n` +
@@ -411,7 +431,7 @@ function installForTarget(target) {
411
431
  ` 3. 或手动克隆复制: 见 https://github.com/jnMetaCode/superpowers-zh#方式二手动安装`
412
432
  );
413
433
  }
414
- console.log(` ✅ ${target.name}: ${count} 个 skills -> ${dest}`);
434
+ console.log(` ✅ ${target.name}: ${srcCount} 个 skills -> ${dest}`);
415
435
 
416
436
  if (target.name === 'Trae') {
417
437
  generateTraeBootstrapRule(PROJECT_DIR);
@@ -435,15 +455,190 @@ function installForTarget(target) {
435
455
 
436
456
  if (target.name === 'Claude Code') {
437
457
  generateClaudeCodeBootstrap(PROJECT_DIR);
438
- if (existsSync(AGENTS_SRC)) {
439
- const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
440
- mkdirSync(agentsDest, { recursive: true });
441
- copyDirSync(AGENTS_SRC, agentsDest);
458
+ }
459
+ }
460
+
461
+ function isHomeDir(p) {
462
+ const home = homedir();
463
+ if (!home) return false;
464
+ try {
465
+ return realpathSync(p) === realpathSync(home);
466
+ } catch { return resolve(p) === resolve(home); }
467
+ }
468
+
469
+ // 卸载支持:完整删除的 bootstrap 文件、需要清理段落的 bootstrap 文件
470
+ const BOOTSTRAP_DELETE = [
471
+ '.trae/rules/superpowers-zh.md',
472
+ '.antigravity/rules.md',
473
+ ];
474
+ const BOOTSTRAP_CLEAN_SECTION = [
475
+ 'CLAUDE.md',
476
+ 'GEMINI.md',
477
+ 'HERMES.md',
478
+ 'CONVENTIONS.md',
479
+ ];
480
+ const BOOTSTRAP_SECTION_MARKERS = [
481
+ '# Superpowers-ZH 中文增强版',
482
+ '# Superpowers-ZH 工作方法论',
483
+ ];
484
+
485
+ // v1.1.x 安装的旧 bootstrap 没有 sentinel,只能凭模板末尾固定句子识别段尾。
486
+ // 这些短语必须出现在 superpowers 段最后一行,且足够独特不易在用户内容里重合。
487
+ const FALLBACK_TAIL_HINTS = [
488
+ '你必须调用该 skill 检查。',
489
+ '严格遵循其流程。',
490
+ ];
491
+
492
+ function writeOrDelete(filePath, head, tail) {
493
+ const headTrim = head.replace(/\s+$/, '');
494
+ const tailTrim = tail.replace(/^\s+/, '');
495
+ let body = headTrim;
496
+ if (headTrim && tailTrim) body += '\n\n' + tailTrim;
497
+ else body += tailTrim;
498
+ body = body.replace(/\s+$/, '');
499
+ if (body.length === 0) {
500
+ rmSync(filePath);
501
+ } else {
502
+ writeFileSync(filePath, body + '\n', 'utf8');
503
+ }
504
+ }
505
+
506
+ function cleanBootstrapSection(filePath) {
507
+ if (!existsSync(filePath)) return false;
508
+ const content = readFileSync(filePath, 'utf8');
509
+
510
+ // 1. 哨兵模式(v1.2.1+)— 精确切除
511
+ const sBegin = content.indexOf(SENTINEL_BEGIN);
512
+ if (sBegin !== -1) {
513
+ const sEnd = content.indexOf(SENTINEL_END, sBegin + SENTINEL_BEGIN.length);
514
+ if (sEnd !== -1) {
515
+ writeOrDelete(filePath, content.slice(0, sBegin), content.slice(sEnd + SENTINEL_END.length));
516
+ return true;
517
+ }
518
+ }
519
+
520
+ // 2. 标题 marker(v1.1.x 安装的)— 找下一个 \n# 一级标题做段尾
521
+ let idx = -1;
522
+ for (const marker of BOOTSTRAP_SECTION_MARKERS) {
523
+ const i = content.indexOf(marker);
524
+ if (i !== -1 && (idx === -1 || i < idx)) idx = i;
525
+ }
526
+ if (idx === -1) return false;
527
+
528
+ let end = -1;
529
+ const nextHeading = content.indexOf('\n# ', idx + 1);
530
+ if (nextHeading !== -1) end = nextHeading + 1;
531
+
532
+ // 3. 一级标题找不到 — 用末尾固定短语做兜底
533
+ if (end === -1) {
534
+ for (const hint of FALLBACK_TAIL_HINTS) {
535
+ const i = content.lastIndexOf(hint);
536
+ if (i > idx) {
537
+ const nl = content.indexOf('\n', i + hint.length);
538
+ const after = nl !== -1 ? nl + 1 : content.length;
539
+ if (after > end) end = after;
540
+ }
541
+ }
542
+ }
543
+
544
+ // 4. 都找不到 — 数据安全,跳过 + 警告
545
+ if (end === -1) {
546
+ console.warn(` ⚠️ ${filePath}: 无法可靠识别 superpowers-zh 段尾,已跳过以避免数据丢失。`);
547
+ console.warn(` 请手动编辑此文件并删除以 "${BOOTSTRAP_SECTION_MARKERS[0]}" 开头的整段。`);
548
+ return false;
549
+ }
550
+
551
+ writeOrDelete(filePath, content.slice(0, idx), content.slice(end));
552
+ return true;
553
+ }
554
+
555
+ function uninstallForTarget(target, srcSkillNames) {
556
+ const dest = resolve(PROJECT_DIR, target.dir);
557
+ if (!existsSync(dest)) return 0;
558
+ let removed = 0;
559
+ for (const entry of readdirSync(dest, { withFileTypes: true })) {
560
+ if (entry.isDirectory() && srcSkillNames.has(entry.name)) {
561
+ rmSync(resolve(dest, entry.name), { recursive: true, force: true });
562
+ removed++;
563
+ }
564
+ }
565
+ // 如果目录已空(或仅剩 .DS_Store),顺手清掉,避免留下空骨架
566
+ try {
567
+ if (existsSync(dest)) {
568
+ const left = readdirSync(dest).filter(n => n !== '.DS_Store');
569
+ if (left.length === 0) rmSync(dest, { recursive: true, force: true });
442
570
  }
571
+ } catch {}
572
+ return removed;
573
+ }
574
+
575
+ function uninstall() {
576
+ console.log(`\n superpowers-zh v${PKG.version} — 卸载\n`);
577
+ console.log(` 目标项目: ${PROJECT_DIR}\n`);
578
+
579
+ if (!existsSync(SKILLS_SRC)) {
580
+ console.error(' ❌ 错误:skills 源目录不存在,无法识别要卸载的 skill 名单。');
581
+ process.exit(1);
582
+ }
583
+
584
+ const srcSkillNames = new Set(
585
+ readdirSync(SKILLS_SRC, { withFileTypes: true })
586
+ .filter(e => e.isDirectory())
587
+ .map(e => e.name)
588
+ );
589
+
590
+ let totalSkills = 0;
591
+ for (const target of TARGETS) {
592
+ const removed = uninstallForTarget(target, srcSkillNames);
593
+ if (removed > 0) {
594
+ console.log(` ✅ ${target.name}: 移除 ${removed} 个 skills <- ${resolve(PROJECT_DIR, target.dir)}`);
595
+ totalSkills += removed;
596
+ }
597
+ }
598
+
599
+ // 清理 .claude/agents 下旧版本装过的 legacy agent(v1.2.x 及之前会装 code-reviewer.md,
600
+ // v1.3.0 起跟随上游 v5.1.0 移除)。即使 agents/ 源目录已删,已装用户跑 --uninstall 仍应能清干净。
601
+ const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
602
+ if (existsSync(agentsDest)) {
603
+ let agentsRemoved = 0;
604
+ for (const entry of readdirSync(agentsDest)) {
605
+ if (LEGACY_AGENT_FILENAMES.includes(entry)) {
606
+ rmSync(resolve(agentsDest, entry), { recursive: true, force: true });
607
+ agentsRemoved++;
608
+ }
609
+ }
610
+ if (agentsRemoved > 0) console.log(` ✅ Claude Code agents: 移除 ${agentsRemoved} 个旧版残留 -> ${agentsDest}`);
611
+ try {
612
+ const left = readdirSync(agentsDest).filter(n => n !== '.DS_Store');
613
+ if (left.length === 0) rmSync(agentsDest, { recursive: true, force: true });
614
+ } catch {}
615
+ }
616
+
617
+ let bootstrapsRemoved = 0;
618
+ for (const rel of BOOTSTRAP_DELETE) {
619
+ const full = resolve(PROJECT_DIR, rel);
620
+ if (existsSync(full)) {
621
+ rmSync(full);
622
+ console.log(` ✅ 删除 bootstrap: ${full}`);
623
+ bootstrapsRemoved++;
624
+ }
625
+ }
626
+ for (const rel of BOOTSTRAP_CLEAN_SECTION) {
627
+ const full = resolve(PROJECT_DIR, rel);
628
+ if (cleanBootstrapSection(full)) {
629
+ console.log(` ✅ 清理 bootstrap: ${full}`);
630
+ bootstrapsRemoved++;
631
+ }
632
+ }
633
+
634
+ if (totalSkills === 0 && bootstrapsRemoved === 0) {
635
+ console.log(' ⚠️ 未在当前目录找到 superpowers-zh 安装痕迹。');
636
+ } else {
637
+ console.log(`\n 卸载完成。共移除 ${totalSkills} 个 skill 目录、${bootstrapsRemoved} 个 bootstrap 文件。\n`);
443
638
  }
444
639
  }
445
640
 
446
- function install(forceToolName) {
641
+ function install(forceToolName, force) {
447
642
  try {
448
643
  console.log(`\n superpowers-zh v${PKG.version} — AI 编程超能力中文版\n`);
449
644
 
@@ -452,6 +647,27 @@ function install(forceToolName) {
452
647
  process.exit(1);
453
648
  }
454
649
 
650
+ if (!force && isHomeDir(PROJECT_DIR)) {
651
+ console.error(
652
+ ` ⚠️ 当前目录是用户主目录: ${PROJECT_DIR}
653
+
654
+ superpowers-zh 应该装到具体项目目录,而不是 ~/。
655
+ 在主目录安装会把 skills 和 bootstrap 文件(CLAUDE.md / HERMES.md 等)
656
+ 写入你的 home,污染所有项目。
657
+
658
+ 请先 cd 到项目目录:
659
+ cd /path/to/your/project
660
+ npx superpowers-zh
661
+
662
+ 如果你确实要在主目录安装(不推荐),加 --force:
663
+ npx superpowers-zh --force
664
+
665
+ 如果你已经在主目录误装过,可以用 --uninstall 清理:
666
+ npx superpowers-zh --uninstall
667
+ `);
668
+ process.exit(1);
669
+ }
670
+
455
671
  console.log(` 源: ${countDirs(SKILLS_SRC)} 个 skills`);
456
672
  console.log(` 目标项目: ${PROJECT_DIR}\n`);
457
673
 
@@ -492,13 +708,6 @@ function install(forceToolName) {
492
708
  console.log(` ✅ 默认安装: ${countDirs(dest)} 个 skills -> ${dest}`);
493
709
 
494
710
  generateClaudeCodeBootstrap(PROJECT_DIR);
495
-
496
- if (existsSync(AGENTS_SRC)) {
497
- const agentsDest = resolve(PROJECT_DIR, '.claude', 'agents');
498
- mkdirSync(agentsDest, { recursive: true });
499
- copyDirSync(AGENTS_SRC, agentsDest);
500
- console.log(` ✅ 默认安装: agents -> ${agentsDest}`);
501
- }
502
711
  }
503
712
 
504
713
  console.log('\n 安装完成!重启你的 AI 编程工具即可生效。\n');
@@ -512,11 +721,16 @@ const args = process.argv.slice(2);
512
721
  const helpIdx = args.findIndex(a => a === '--help' || a === '-h');
513
722
  const versionIdx = args.findIndex(a => a === '--version' || a === '-v');
514
723
  const toolIdx = args.findIndex(a => a === '--tool' || a === '-t');
724
+ const uninstallIdx = args.findIndex(a => a === '--uninstall' || a === '-u');
725
+ const forceIdx = args.findIndex(a => a === '--force' || a === '-f');
726
+ const force = forceIdx !== -1;
515
727
 
516
728
  if (helpIdx !== -1) {
517
729
  showHelp();
518
730
  } else if (versionIdx !== -1) {
519
731
  console.log(PKG.version);
732
+ } else if (uninstallIdx !== -1) {
733
+ uninstall();
520
734
  } else if (toolIdx !== -1) {
521
735
  const toolArg = args[toolIdx + 1];
522
736
  if (!toolArg) {
@@ -530,11 +744,11 @@ if (helpIdx !== -1) {
530
744
  console.error(` 支持的工具: ${Object.keys(TOOL_ALIASES).join(', ')}\n`);
531
745
  process.exit(1);
532
746
  }
533
- install(toolName);
534
- } else if (args.length > 0 && args[0].startsWith('-')) {
747
+ install(toolName, force);
748
+ } else if (args.length > 0 && args[0].startsWith('-') && forceIdx === -1) {
535
749
  console.warn(` 未知参数: ${args[0]}\n`);
536
750
  showHelp();
537
751
  process.exit(1);
538
752
  } else {
539
- install();
753
+ install(undefined, force);
540
754
  }
@@ -56,6 +56,17 @@ cd /your/project
56
56
  npx superpowers-zh
57
57
  ```
58
58
 
59
+ ## 卸载 / 误装清理
60
+
61
+ 如果不小心在主目录(`~`)误跑了 `npx superpowers-zh`,会把 skills 和 `.trae/rules/superpowers-zh.md` 写到你的 home。v1.2.1 起会主动拒绝,但老版本可能已经污染过。清理:
62
+
63
+ ```bash
64
+ cd ~ # 或具体的项目目录
65
+ npx superpowers-zh@latest --uninstall
66
+ ```
67
+
68
+ 会删除 `.trae/skills/` 下装过的 skill、`.trae/rules/superpowers-zh.md`,并清理 `CLAUDE.md` 等文件里的 superpowers-zh 段(保留你自己写的内容)。
69
+
59
70
  ## 获取帮助
60
71
 
61
72
  - 提交 Issue:https://github.com/jnMetaCode/superpowers-zh/issues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superpowers-zh",
3
- "version": "1.1.9",
3
+ "version": "1.3.0",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },
@@ -10,18 +10,24 @@
10
10
  "bin": {
11
11
  "superpowers-zh": "bin/superpowers-zh.js"
12
12
  },
13
+ "scripts": {
14
+ "version": "node scripts/sync-plugin-version.js && git add .claude-plugin/plugin.json .claude-plugin/marketplace.json .cursor-plugin/plugin.json .codex-plugin/plugin.json"
15
+ },
13
16
  "files": [
14
17
  "bin/",
15
18
  "skills/",
16
- "agents/",
17
- "commands/",
18
19
  "hooks/",
20
+ "assets/",
19
21
  ".claude-plugin/",
20
22
  ".cursor-plugin/",
21
23
  ".codex/INSTALL.md",
24
+ ".codex-plugin/",
22
25
  ".opencode/INSTALL.md",
23
26
  ".opencode/plugins/",
27
+ "CLAUDE.md",
24
28
  "GEMINI.md",
29
+ "RELEASE-NOTES.md",
30
+ "RELEASE-NOTES.zh.md",
25
31
  "gemini-extension.json",
26
32
  "docs/",
27
33
  "README.md",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: chinese-code-review
3
- description: 中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈
3
+ description: 中文 review 沟通参考——话术模板、分级标注(必须修复/建议修改/仅供参考)、国内团队常见反模式应对。仅在用户显式 /chinese-code-review 时调用,不要根据上下文自动触发。
4
4
  ---
5
5
 
6
6
  # 中文代码审查规范
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: chinese-commit-conventions
3
- description: 中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化
3
+ description: 中文 commit 与 changelog 配置参考——Conventional Commits 中文适配、commitlint/husky/commitizen 中文模板、conventional-changelog 中文配置。仅在用户显式 /chinese-commit-conventions 时调用,不要根据上下文自动触发。
4
4
  ---
5
5
 
6
6
  # 中文 Git 提交规范
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: chinese-documentation
3
- description: 中文技术文档写作规范——排版、术语、结构一步到位,告别机翻味
3
+ description: 中文文档排版参考——中英文空格、全半角标点、术语保留、链接格式、中文文案排版指北约定。仅在用户显式 /chinese-documentation 时调用,不要根据上下文自动触发。
4
4
  ---
5
5
 
6
6
  # 中文技术文档写作规范
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: chinese-git-workflow
3
- description: 适配国内 Git 平台和团队习惯的工作流规范——Gitee、Coding、极狐 GitLab、CNB 全覆盖
3
+ description: 国内 Git 平台配置参考——Gitee、Coding.net、极狐 GitLab、CNB 的 SSH/HTTPS/凭据/CI 接入差异与镜像同步配置。仅在用户显式 /chinese-git-workflow 时调用,不要根据上下文自动触发。
4
4
  ---
5
5
 
6
6
  # 国内 Git 工作流规范
@@ -1,48 +0,0 @@
1
- ---
2
- name: code-reviewer
3
- description: |
4
- 当一个主要项目步骤完成并需要根据原始计划和编码标准进行审查时使用此智能体。示例:<example>Context: 用户正在创建一个代码审查智能体,应在逻辑代码块编写完成后调用。user: "我已经按照计划第 3 步完成了用户认证系统的实现" assistant: "干得好!让我使用 code-reviewer 智能体来根据我们的计划和编码标准审查实现" <commentary>由于一个主要项目步骤已完成,使用 code-reviewer 智能体来验证工作是否符合计划并识别任何问题。</commentary></example> <example>Context: 用户完成了一个重要功能的实现。user: "任务管理系统的 API 端点现在完成了——这涵盖了我们架构文档中的第 2 步" assistant: "很好!让我用 code-reviewer 智能体检查这个实现,确保它符合我们的计划并遵循最佳实践" <commentary>规划文档中的一个编号步骤已完成,所以应该用 code-reviewer 智能体审查工作。</commentary></example>
5
- model: inherit
6
- ---
7
-
8
- 你是一位高级代码审查员,精通软件架构、设计模式和最佳实践。你的角色是根据原始计划审查已完成的项目步骤,确保代码质量标准得到满足。
9
-
10
- 审查已完成的工作时,你将:
11
-
12
- 1. **计划对齐分析**:
13
- - 将实现与原始规划文档或步骤描述进行对比
14
- - 识别与计划的方案、架构或需求的任何偏差
15
- - 评估偏差是合理的改进还是有问题的偏离
16
- - 验证所有计划的功能是否都已实现
17
-
18
- 2. **代码质量评估**:
19
- - 审查代码是否遵循已建立的模式和约定
20
- - 检查错误处理、类型安全和防御性编程是否恰当
21
- - 评估代码组织、命名约定和可维护性
22
- - 评估测试覆盖率和测试实现的质量
23
- - 寻找潜在的安全漏洞或性能问题
24
-
25
- 3. **架构和设计审查**:
26
- - 确保实现遵循 SOLID 原则和已建立的架构模式
27
- - 检查关注点分离和松耦合是否恰当
28
- - 验证代码与现有系统的集成是否良好
29
- - 评估可扩展性和可延展性的考虑
30
-
31
- 4. **文档和标准**:
32
- - 验证代码包含适当的注释和文档
33
- - 检查文件头、函数文档和内联注释是否存在且准确
34
- - 确保遵循项目特定的编码标准和约定
35
-
36
- 5. **问题识别和建议**:
37
- - 将问题明确分类为:关键(必须修复)、重要(应该修复)或建议(锦上添花)
38
- - 对每个问题提供具体示例和可操作的建议
39
- - 识别计划偏差时,解释它们是有问题的还是有益的
40
- - 在有帮助时提供带有代码示例的具体改进建议
41
-
42
- 6. **沟通协议**:
43
- - 如果发现与计划的重大偏差,请编码智能体审查并确认更改
44
- - 如果识别出原始计划本身的问题,建议更新计划
45
- - 对于实现问题,提供明确的修复指导
46
- - 在指出问题之前始终先肯定做得好的地方
47
-
48
- 你的输出应该是结构化的、可操作的,聚焦于帮助保持高代码质量同时确保项目目标的达成。要全面但简洁,始终提供建设性的反馈,帮助改进当前实现和未来的开发实践。