diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml new file mode 100644 index 0000000..e0ec360 --- /dev/null +++ b/.github/workflows/deploy-site.yml @@ -0,0 +1,33 @@ +name: Deploy site to Cloudflare Pages + +# 官网自动部署:site/ 或 skills/ 变更时重建并发布。 +# 需在仓库 Settings → Secrets 配置 CLOUDFLARE_API_TOKEN 与 CLOUDFLARE_ACCOUNT_ID。 +on: + push: + branches: [main] + paths: + - 'site/**' + - 'skills/**' + - '.github/workflows/deploy-site.yml' + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + steps: + # Action 全部 SHA 固定(防供应链/标签劫持,因本 job 持有可写的 Cloudflare token) + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: + node-version: 20 + - name: Build site + run: node site/build.mjs + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy site/dist --project-name=superpowers-zh-site diff --git a/.gitignore b/.gitignore index 39c70c5..8f6e23d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ node_modules/ inspo triage/ +# 官网生成产物(源在 site/build.mjs + site/template/) +site/dist/ + # 安装器生成的 skills 副本(源在 skills/ 目录) .codex/skills/ .gemini/skills/ diff --git a/package.json b/package.json index 3fd26ae..c012d9f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "superpowers-zh": "bin/superpowers-zh.js" }, "scripts": { + "site": "node site/build.mjs", + "site:deploy": "node site/build.mjs && wrangler pages deploy site/dist --project-name=superpowers-zh-site", "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 gemini-extension.json" }, "files": [ diff --git a/site/README.md b/site/README.md new file mode 100644 index 0000000..fd1a52f --- /dev/null +++ b/site/README.md @@ -0,0 +1,77 @@ +# superpowers-zh 官网 + +零依赖静态站生成器。一条命令产出**中/英双语**站点 + 每个 skill 的**详情(操作文档)页**,内容全部来自 `../skills/*/SKILL.md`,与源文件同步、不会漂移。 + +## 构建 / 预览 + +```bash +node site/build.mjs # 生成 site/dist/(42 个页面) +npx serve site/dist # 本地预览(或 python3 -m http.server) +``` + +产物结构: + +``` +dist/ + index.html # 中文首页 + en/index.html # 英文首页 + skills/.html # 中文 skill 详情(操作文档)× 20 + en/skills/.html # 英文 skill 详情 × 20 + styles.css app.js # 深/浅主题 + 交互(原生 JS,零依赖) + assets/ # 图标 + 赞助商 logo + _headers # Cloudflare Pages 缓存策略 +``` + +## 特性 + +- **中英双语**:服务端生成两套真实页面(非前端切换),SEO 友好、无闪烁。导航栏「中文 / EN」互切。 +- **深 / 浅主题**:CSS 变量 + localStorage 记忆,内联脚本在首屏前生效,无白屏闪烁。导航栏 ◐ 按钮切换。 +- **Skill 详情页**:内置零依赖 Markdown 渲染器(`md.mjs`),把每个 `SKILL.md` 渲染成完整操作文档,支持标题/代码块/表格/列表/引用。 +- **安装命令生成器、Skill 搜索 / 分类筛选、一键复制** —— 全部原生 JS。 + +## 改内容改哪里 + +| 想改什么 | 改哪里 | +|---|---| +| Skill 正文 / 文档内容 | **源头** `skills//SKILL.md`(改完重新 `node site/build.mjs`) | +| Skill 中/英标题、英文简介、分组 | `site/build.mjs` 的 `SKILL_META` | +| 首页所有文案(中/英) | `site/build.mjs` 的 `T.zh` / `T.en` | +| 支持工具 / 安装命令 | `site/build.mjs` 的 `TOOLS`(与 `bin/superpowers-zh.js` 的 `TARGETS` 对齐) | +| 样式 / 主题 | `site/template/styles.css` | +| 交互逻辑 | `site/template/app.js` | +| Markdown 渲染规则 | `site/md.mjs` | + +## 部署到 Cloudflare Pages + +发布目录 `site/dist`,三选一: + +### 方式 A — 连接仓库自动构建(推荐,无需密钥) + +Cloudflare Dashboard → Pages → 连接 GitHub 仓库 `jnMetaCode/superpowers-zh`: + +- **Build command**:`node site/build.mjs` +- **Build output directory**:`site/dist` + +之后每次 push 自动重建发布。绑自定义域名(建议 `superpowers.aibuzhiyu.com`)。 + +### 方式 B — 命令行一键发布 + +```bash +npx wrangler login # 浏览器登录(交互,仅首次) +npm run site:deploy # = 构建 + wrangler pages deploy site/dist +``` + +> 在本会话中可用 `!` 前缀直接登录:`!npx wrangler login` + +### 方式 C — GitHub Actions 自动部署 + +仓库已含 `.github/workflows/deploy-site.yml`。在 **Settings → Secrets and variables → Actions** 配置: + +- `CLOUDFLARE_API_TOKEN`(Pages 编辑权限) +- `CLOUDFLARE_ACCOUNT_ID` + +之后 `site/` 或 `skills/` 变更 push 到 `main` 即自动部署。 + +--- + +> 国内访问优先用 Cloudflare Pages + 自定义域名;GitHub Pages 在国内访问较慢,不建议作为主站。 diff --git a/site/build.mjs b/site/build.mjs new file mode 100644 index 0000000..8800b28 --- /dev/null +++ b/site/build.mjs @@ -0,0 +1,599 @@ +#!/usr/bin/env node +// superpowers-zh 官网生成器 —— 零依赖。 +// 服务端生成中/英两套静态页 + 每个 skill 的详情(操作文档)页。 +// skill 卡片与详情正文均直接读取 ../skills/*/SKILL.md,与源文件同步、不漂移。 + +import { + readFileSync, writeFileSync, mkdirSync, readdirSync, + existsSync, copyFileSync, rmSync, +} from 'fs'; +import { resolve, dirname, join } from 'path'; +import { fileURLToPath } from 'url'; +import { createHash } from 'crypto'; +import { renderMarkdown } from './md.mjs'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const ROOT = resolve(__dirname, '..'); +const SKILLS_DIR = join(ROOT, 'skills'); +const DIST = join(__dirname, 'dist'); +const TEMPLATE = join(__dirname, 'template'); +const PKG = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')); + +const esc = s => String(s).replace(/&/g, '&').replace(//g, '>'); + +// ---- frontmatter 解析 ---- +function parseFrontmatter(md) { + const m = md.match(/^---\n([\s\S]*?)\n---/); + if (!m) return {}; + const out = {}; + for (const line of m[1].split('\n')) { + const kv = line.match(/^(\w[\w-]*):\s*(.*)$/); + if (!kv) continue; + let val = kv[2].trim(); + if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) { + val = val.slice(1, -1); + } + out[kv[1]] = val; + } + return out; +} + +// ---- skill 展示元数据:中/英标题 + 英文简介 + 分组 ---- +const SKILL_META = { + 'using-superpowers': { group: 'meta', title: '使用 Superpowers · 引导', titleEn: 'Using Superpowers · Bootstrap', descEn: 'The bootstrap skill — establishes how to discover and invoke skills at the start of every conversation.' }, + 'brainstorming': { group: 'flow', title: '头脑风暴', titleEn: 'Brainstorming', descEn: 'Explore intent, requirements and design before any creative work — feature, component or behavior change.' }, + 'writing-plans': { group: 'flow', title: '编写实现计划', titleEn: 'Writing Plans', descEn: 'Turn a spec into a step-by-step implementation plan before writing any code.' }, + 'executing-plans': { group: 'flow', title: '执行计划', titleEn: 'Executing Plans', descEn: 'Execute a written plan in a separate session with review checkpoints.' }, + 'subagent-driven-development': { group: 'flow', title: '子代理驱动开发', titleEn: 'Subagent-Driven Dev', descEn: 'Run a plan of independent tasks within the current session via subagents.' }, + 'dispatching-parallel-agents': { group: 'flow', title: '并行代理调度', titleEn: 'Dispatching Parallel Agents', descEn: 'Fan out 2+ independent tasks with no shared state or ordering dependency.' }, + 'workflow-runner': { group: 'flow', title: '工作流运行器', titleEn: 'Workflow Runner', descEn: 'Run agency-orchestrator YAML workflows directly using the current session LLM — no API key.' }, + 'test-driven-development': { group: 'quality', title: '测试驱动开发 · TDD', titleEn: 'Test-Driven Development', descEn: 'Write the test before the implementation, for every feature and bug fix.' }, + 'systematic-debugging': { group: 'quality', title: '系统化调试', titleEn: 'Systematic Debugging', descEn: 'Reproduce and locate the root cause before proposing any fix.' }, + 'verification-before-completion':{ group: 'quality', title: '完成前验证', titleEn: 'Verification Before Completion', descEn: 'Run verification and back every claim with evidence before saying it is done.' }, + 'requesting-code-review': { group: 'review', title: '发起代码审查', titleEn: 'Requesting Code Review', descEn: 'Validate work against requirements before merging or shipping.' }, + 'receiving-code-review': { group: 'review', title: '接收代码审查', titleEn: 'Receiving Code Review', descEn: 'Apply review feedback with technical rigor — verify, don\'t blindly comply.' }, + 'using-git-worktrees': { group: 'git', title: 'Git Worktree 隔离', titleEn: 'Using Git Worktrees', descEn: 'Start isolated feature work in a dedicated git worktree.' }, + 'finishing-a-development-branch':{ group: 'git', title: '收尾开发分支', titleEn: 'Finishing a Branch', descEn: 'Wrap up finished work via structured merge / PR / cleanup options.' }, + 'writing-skills': { group: 'meta', title: '编写 Skill', titleEn: 'Writing Skills', descEn: 'Create, edit and validate skills before deploying them.' }, + 'mcp-builder': { group: 'meta', title: 'MCP 服务器构建', titleEn: 'MCP Builder', descEn: 'Methodology for building production-grade MCP servers that connect AI to external tools.' }, + 'chinese-code-review': { group: 'china', title: '中文代码审查', titleEn: 'Chinese Code Review', descEn: 'Chinese review phrasing, severity tiers, and common anti-patterns in domestic teams.' }, + 'chinese-commit-conventions': { group: 'china', title: '中文提交规范', titleEn: 'Chinese Commit Conventions', descEn: 'Conventional Commits adapted for Chinese, with commitlint / husky / changelog templates.' }, + 'chinese-documentation': { group: 'china', title: '中文文档排版', titleEn: 'Chinese Documentation', descEn: 'CN/EN spacing, punctuation, term preservation and Chinese typography conventions.' }, + 'chinese-git-workflow': { group: 'china', title: '国内 Git 平台', titleEn: 'Chinese Git Workflow', descEn: 'Gitee / Coding.net / JiHu GitLab / CNB access, credentials, CI and mirror sync.' }, +}; + +const GROUPS = [ + { id: 'all', zh: '全部', en: 'All' }, + { id: 'flow', zh: '工作流程', en: 'Workflow' }, + { id: 'quality', zh: '质量 · 测试 · 调试', en: 'Quality' }, + { id: 'review', zh: '代码审查', en: 'Code Review' }, + { id: 'git', zh: 'Git · 分支', en: 'Git' }, + { id: 'meta', zh: '元 · 构建', en: 'Meta' }, + { id: 'china', zh: '🇨🇳 中国原创', en: '🇨🇳 China-native' }, +]; + +// ---- 支持的工具(与 bin/superpowers-zh.js 的 TARGETS 对齐) ---- +const TOOLS = [ + { name: 'Claude Code', type: 'CLI', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Cursor', type: 'IDE', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Windsurf', type: 'IDE', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Codex CLI', type: 'CLI', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Gemini CLI', type: 'CLI', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Kiro', type: 'IDE', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Trae', type: 'IDE', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Qoder', type: 'IDE', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Aider', type: 'CLI', cmd: 'npx superpowers-zh', auto: true }, + { name: 'OpenCode', type: 'CLI', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Qwen Code', type: 'IDE', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Antigravity', type: 'CLI', cmd: 'npx superpowers-zh', auto: true }, + { name: 'DeerFlow 2.0', type: 'Agent', cmd: 'npx superpowers-zh', auto: true }, + { name: 'VS Code · Copilot', type: 'IDE', cmd: 'npx superpowers-zh', auto: true }, + { name: 'Copilot CLI', type: 'CLI', cmd: 'npx superpowers-zh --tool copilot', auto: false }, + { name: 'Hermes Agent', type: 'CLI', cmd: 'npx superpowers-zh --tool hermes', auto: false }, + { name: 'Claw Code', type: 'CLI', cmd: 'npx superpowers-zh --tool claw', auto: false }, + { name: 'OpenClaw', type: 'CLI', cmd: 'npx superpowers-zh', auto: true }, +]; + +// ---- 双语文案 ---- +const T = { + zh: { + htmlLang: 'zh-CN', + title: 'superpowers-zh · AI 编程超能力中文增强版', + desc: 'superpowers(159k+ ⭐)完整汉化 + 4 个中国原创 skills,一条 npx 命令为 18 款 AI 编程工具装上系统化工作方法论。', + nav: { why: '特性', install: '安装', skills: 'Skills', tools: '支持工具', faq: 'FAQ', github: 'GitHub ↗' }, + heroBadge: 'superpowers 159k+ ⭐ · 完整汉化 + 中国原创', + heroH1: '给你的 AI 编程工具
装上真正会干活的超能力', + heroLead: '{n} 个经过实战验证的工作方法论 skill —— 从头脑风暴到 TDD,从系统化调试到代码审查。
一条命令,自动识别项目里的工具并安装。', + heroBtn1: '查看安装命令', heroBtn2: 'GitHub 源码', + stats: ['Skills', '中国原创', '支持工具', '当前版本'], + whyTitle: '为什么选择 superpowers-zh?', + whySub: '不是又一套提示词模板 —— 是让 AI 真正按工程方法干活的系统化能力。', + plTitle: '一条龙工作流,每一步都有 skill 把关', + plSub: 'skill 之间彼此衔接,AI 会在合适的节点自动触发对应方法论。', + cmpTitle: '装上之后,AI 不再"上来就写"', + cmpBad: '❌ 没装', cmpGood: '✅ 装了 superpowers-zh', + cmpBadPre: '你:给用户模块加个批量导出功能\nAI:好的,我来实现……(直接开写)\n export async function exportUsers() { … }\n你:等等,格式不对,没分页,\n 大数据量会 OOM……', + cmpGoodPre: '你:给用户模块加个批量导出功能\nAI:先理清需求 —— 导出格式?数据量级?\n 要分页/流式吗?要权限校验吗?\n (触发 brainstorming)\n → 写计划 → TDD → 验证 → 审查', + instTitle: '选你的工具,拿到安装命令', + instSub: '大多数工具 npx superpowers-zh 会自动识别项目目录并安装;识别不出的用 --tool 指定。', + instLabel: '我用的是', + instNoteAuto: '在你的项目根目录运行,自动识别 {name} 并安装。安装后重启工具即可生效。', + instNoteManual: '{name} 无法自动识别,需用 --tool 显式指定。在项目根目录运行,安装后重启工具即可生效。', + skTitle: '{n} 个 Skill,覆盖开发全流程', + skSub: '点击任意卡片查看完整操作文档。', + skSearch: '搜索 skill…(如 调试 / review / TDD)', + skEmpty: '没有匹配的 skill。', + skDetail: '查看文档 →', + tagCn: '中国原创', + ucTitle: '典型使用场景', ucSub: '每个场景背后都是一组协同工作的 skill。', + toolsTitle: '一套 skill,18 款工具通用', toolsSub: '换工具不用换习惯,方法论跟着你走。', + faqTitle: '常见问题', + bookTitle: '装好之后,配上方法论效率翻倍', + bookDesc: '《AI 编程实战 · 方法论三卷书》—— 10 个 AI 编程工具完整教程 + 真实踩坑。在线书 + PDF,永久免费。', + bookBtn: '免费阅读 ↗', + sponsorTitle: '赞助商', + sponsorDesc: '稳定高速的 API 中继服务,为 Claude Code、Codex 等平台提供 API 中继与 AI 生图服务。', + sponsorCta: '🙏 想出现在这里?联系 jnMetaCode@qq.com', + ctaTitle: '准备好让 AI 真正会干活了吗?', + ctaDesc: '一条命令,{n} 个实战方法论装进你的工具。免费、开源、零依赖。', + ctaBtn1: '查看安装命令', ctaBtn2: '⭐ Star on GitHub', + footCols: [ + { h: '产品', links: [['特性', '#why'], ['Skills', '#skills'], ['支持工具', '#tools'], ['FAQ', '#faq']] }, + { h: '资源', links: [['GitHub', 'https://github.com/jnMetaCode/superpowers-zh'], ['npm', 'https://www.npmjs.com/package/superpowers-zh'], ['上游 obra/superpowers', 'https://github.com/obra/superpowers'], ['方法论三卷书', 'https://book.aibuzhiyu.com/']] }, + { h: '社区', links: [['提交 Issue', 'https://github.com/jnMetaCode/superpowers-zh/issues'], ['贡献指南', 'https://github.com/jnMetaCode/superpowers-zh/blob/main/CLAUDE.md']] }, + ], + footTag: 'AI 编程超能力 · 中文增强版 · MIT License', + copyright: '© 2026 superpowers-zh · 基于 obra/superpowers 的中文增强 fork', + copy: '复制', copied: '已复制 ✓', + backToSkills: '← 返回全部 Skill', + detailInstall: '安装此 skill', + detailSource: '在 GitHub 查看源文件 ↗', + features: [ + { icon: '🧠', t: '20 个实战方法论', d: '不是 prompt 模板,是经过跨会话对抗式压力测试调优的工作方法论 —— 从头脑风暴到 TDD、调试、代码审查。' }, + { icon: '🔌', t: '18 款工具通用', d: '一套 skill,Claude Code / Cursor / Codex / Gemini CLI / Windsurf… 全适配,换工具不用换习惯。' }, + { icon: '⚡', t: '一条命令安装', d: 'npx superpowers-zh 自动识别项目里用的是哪款工具并安装,零配置,装完重启即生效。' }, + { icon: '🇨🇳', t: '中国原创 Skills', d: '中文代码审查话术、中文提交规范、中文文档排版、国内 Git 平台(Gitee/Coding/极狐)配置 —— 上游没有。' }, + { icon: '📖', t: '完整汉化上游', d: '同步 obra/superpowers(159k+ ⭐),核心 skill 全部中文母语化,不是机翻,是逐条校准。' }, + { icon: '🔓', t: '零依赖 · MIT 开源', d: '纯 Markdown skill,不引入任何外部依赖、不联网、不上传代码,按需触发零运行时开销。' }, + ], + pipeline: [ + { n: '头脑风暴', d: '动手前先理清意图与需求' }, + { n: '写计划', d: '把需求拆成可执行步骤' }, + { n: 'TDD', d: '先写测试再写实现' }, + { n: '系统化调试', d: '先复现定位再改' }, + { n: '代码审查', d: '合并前严谨验收' }, + { n: '完成前验证', d: '用证据证明真的好了' }, + ], + usecases: [ + { tag: '开发新功能', skills: 'brainstorming → writing-plans → TDD', desc: 'AI 先反问需求、写出实现计划,再用测试驱动落地,而不是上来就糊一坨代码。' }, + { tag: '修 Bug', skills: 'systematic-debugging', desc: '强制先复现、定位根因,再提修复方案 —— 杜绝"猜一个改一下"的瞎试循环。' }, + { tag: '提交 / 合并前', skills: 'verification-before-completion → code-review', desc: '必须跑验证命令、拿证据说话,再走一轮代码审查,才允许声称"完成"。' }, + { tag: '国内团队协作', skills: 'chinese-commit-conventions → chinese-code-review', desc: '中文 commit 规范 + 分级 review 话术,配 Gitee / Coding / 极狐 GitLab 工作流。' }, + ], + faq: [ + { q: 'superpowers-zh 是免费的吗?', a: '完全免费。MIT 协议开源,永久免费,不含任何付费墙或订阅。' }, + { q: '支持哪些 AI 编程工具?', a: '共 18 款:Claude Code、Cursor、Windsurf、Codex CLI、Gemini CLI、Kiro、Trae、Qoder、Aider、OpenCode、Qwen Code、Antigravity、DeerFlow、VS Code(Copilot)、Copilot CLI、Hermes Agent、Claw Code、OpenClaw。' }, + { q: '和上游 obra/superpowers 是什么关系?', a: '本项目是 obra/superpowers(159k+ ⭐)的中文增强 fork:完整汉化上游全部核心 skill,并叠加 4 个面向中国开发者的原创 skill。中文化与中国特色内容只在本 fork 提供。' }, + { q: '安装后怎么生效?', a: 'npx 会把 skill 文件装到你项目对应工具的目录(如 .claude/skills/),重启 AI 工具后,它会在恰当时机自动触发相应 skill —— 无需你每次手动调用。' }, + { q: '会拖慢我的 AI 吗?会上传代码吗?', a: '不会。skill 是按需触发的纯 Markdown,零运行时、不联网、不上传任何代码或数据,全程在本地。' }, + { q: '怎么更新或卸载?', a: '更新:重新运行 npx superpowers-zh 覆盖即可。卸载:npx superpowers-zh --uninstall 清理已安装的 skill 与 bootstrap 文件。' }, + ], + }, + en: { + htmlLang: 'en', + title: 'superpowers-zh · Battle-tested AI coding skills (CN-enhanced)', + desc: 'Full Chinese localization of superpowers (159k+ ⭐) plus 4 China-native skills. One npx command installs systematic workflow methodology into 18 AI coding tools.', + nav: { why: 'Features', install: 'Install', skills: 'Skills', tools: 'Tools', faq: 'FAQ', github: 'GitHub ↗' }, + heroBadge: 'superpowers 159k+ ⭐ · Full CN localization + China-native skills', + heroH1: 'Give your AI coding tools
superpowers that actually ship', + heroLead: '{n} battle-tested workflow skills — from brainstorming to TDD, systematic debugging to code review.
One command auto-detects your tool and installs.', + heroBtn1: 'Get the command', heroBtn2: 'GitHub', + stats: ['Skills', 'China-native', 'Tools', 'Version'], + whyTitle: 'Why superpowers-zh?', + whySub: 'Not another prompt-template pack — real engineering methodology that makes AI work properly.', + plTitle: 'An end-to-end workflow, every step guarded by a skill', + plSub: 'Skills chain together; the AI triggers the right methodology at the right moment.', + cmpTitle: 'After install, AI stops "coding before thinking"', + cmpBad: '❌ Without', cmpGood: '✅ With superpowers-zh', + cmpBadPre: 'You: Add bulk export to the users module\nAI: Sure, implementing… (starts coding)\n export async function exportUsers() { … }\nYou: Wait — wrong format, no paging,\n it OOMs on large data…', + cmpGoodPre: 'You: Add bulk export to the users module\nAI: First, the requirements — what format?\n What data volume? Paging/streaming?\n Permission checks? (triggers brainstorming)\n → plan → TDD → verify → review', + instTitle: 'Pick your tool, get the command', + instSub: 'For most tools npx superpowers-zh auto-detects the project and installs; otherwise pass --tool.', + instLabel: "I'm using", + instNoteAuto: 'Run it in your project root — it auto-detects {name} and installs. Restart the tool to take effect.', + instNoteManual: '{name} can\'t be auto-detected; pass --tool explicitly. Run in the project root, then restart the tool.', + skTitle: '{n} skills, covering the whole dev workflow', + skSub: 'Click any card for the full operating doc.', + skSearch: 'Search skills… (e.g. debug / review / TDD)', + skEmpty: 'No matching skills.', + skDetail: 'Read docs →', + tagCn: 'China-native', + ucTitle: 'Typical use cases', ucSub: 'Each scenario is backed by a set of cooperating skills.', + toolsTitle: 'One skill set, 18 tools', toolsSub: 'Switch tools without switching habits — the methodology follows you.', + faqTitle: 'FAQ', + bookTitle: 'Pair it with the methodology for 2× efficiency', + bookDesc: '"AI Coding in Practice · The Three-Volume Methodology" — full tutorials for 10 AI coding tools plus real-world pitfalls. Online book + PDF, free forever.', + bookBtn: 'Read free ↗', + sponsorTitle: 'Sponsors', + sponsorDesc: 'A fast, reliable API relay for Claude Code, Codex and more — API relay and AI image generation.', + sponsorCta: '🙏 Want to appear here? Contact jnMetaCode@qq.com', + ctaTitle: 'Ready to make your AI actually ship?', + ctaDesc: 'One command installs {n} battle-tested skills into your tool. Free, open-source, zero-dependency.', + ctaBtn1: 'Get the command', ctaBtn2: '⭐ Star on GitHub', + footCols: [ + { h: 'Product', links: [['Features', '#why'], ['Skills', '#skills'], ['Tools', '#tools'], ['FAQ', '#faq']] }, + { h: 'Resources', links: [['GitHub', 'https://github.com/jnMetaCode/superpowers-zh'], ['npm', 'https://www.npmjs.com/package/superpowers-zh'], ['Upstream obra/superpowers', 'https://github.com/obra/superpowers'], ['Methodology book', 'https://book.aibuzhiyu.com/']] }, + { h: 'Community', links: [['Open an Issue', 'https://github.com/jnMetaCode/superpowers-zh/issues'], ['Contributing', 'https://github.com/jnMetaCode/superpowers-zh/blob/main/CLAUDE.md']] }, + ], + footTag: 'AI coding superpowers · Chinese-enhanced · MIT License', + copyright: '© 2026 superpowers-zh · A Chinese-enhanced fork of obra/superpowers', + copy: 'Copy', copied: 'Copied ✓', + backToSkills: '← Back to all skills', + detailInstall: 'Install this skill set', + detailSource: 'View source on GitHub ↗', + features: [ + { icon: '🧠', t: '20 battle-tested methods', d: 'Not prompt templates — workflow methodology hardened by cross-session adversarial testing, from brainstorming to TDD, debugging and review.' }, + { icon: '🔌', t: 'Works in 18 tools', d: 'One skill set for Claude Code / Cursor / Codex / Gemini CLI / Windsurf and more. Switch tools, keep your habits.' }, + { icon: '⚡', t: 'One-command install', d: 'npx superpowers-zh auto-detects your tool and installs. Zero config; restart to take effect.' }, + { icon: '🇨🇳', t: 'China-native skills', d: 'Chinese code-review phrasing, commit conventions, doc typography, and domestic Git platforms (Gitee/Coding/JiHu) — not in upstream.' }, + { icon: '📖', t: 'Fully localized upstream', d: 'Tracks obra/superpowers (159k+ ⭐); every core skill localized into native Chinese — calibrated, not machine-translated.' }, + { icon: '🔓', t: 'Zero-dep · MIT', d: 'Pure Markdown skills. No external deps, no network, no code upload. Triggered on demand with zero runtime cost.' }, + ], + pipeline: [ + { n: 'Brainstorm', d: 'Clarify intent before coding' }, + { n: 'Plan', d: 'Break work into steps' }, + { n: 'TDD', d: 'Test first, then implement' }, + { n: 'Debug', d: 'Reproduce & locate first' }, + { n: 'Review', d: 'Rigorous pre-merge check' }, + { n: 'Verify', d: 'Prove it with evidence' }, + ], + usecases: [ + { tag: 'New feature', skills: 'brainstorming → writing-plans → TDD', desc: 'AI questions the requirements, writes a plan, then builds test-first — instead of dumping code immediately.' }, + { tag: 'Fixing a bug', skills: 'systematic-debugging', desc: 'Forces reproduce-and-locate-root-cause before any fix — no more "guess and tweak" loops.' }, + { tag: 'Before merge', skills: 'verification-before-completion → code-review', desc: 'Must run verification with evidence, then a review pass, before claiming "done".' }, + { tag: 'CN team workflow', skills: 'chinese-commit-conventions → chinese-code-review', desc: 'Chinese commit conventions + tiered review phrasing, wired for Gitee / Coding / JiHu GitLab.' }, + ], + faq: [ + { q: 'Is superpowers-zh free?', a: 'Completely free. MIT-licensed open source, forever, with no paywall or subscription.' }, + { q: 'Which AI coding tools are supported?', a: '18 tools: Claude Code, Cursor, Windsurf, Codex CLI, Gemini CLI, Kiro, Trae, Qoder, Aider, OpenCode, Qwen Code, Antigravity, DeerFlow, VS Code (Copilot), Copilot CLI, Hermes Agent, Claw Code, OpenClaw.' }, + { q: 'How does it relate to obra/superpowers?', a: 'This is a Chinese-enhanced fork of obra/superpowers (159k+ ⭐): a full localization of all core skills plus 4 China-native skills. The localization and China-specific content live only in this fork.' }, + { q: 'How does it take effect after install?', a: 'npx installs skill files into your tool\'s directory (e.g. .claude/skills/). After restarting your AI tool, it auto-triggers the right skill at the right moment — no manual invocation needed.' }, + { q: 'Will it slow my AI down or upload my code?', a: 'No. Skills are on-demand Markdown: zero runtime, no network, no code or data upload — everything stays local.' }, + { q: 'How do I update or uninstall?', a: 'Update: re-run npx superpowers-zh to overwrite. Uninstall: npx superpowers-zh --uninstall removes installed skills and bootstrap files.' }, + ], + }, +}; + +// ---- 读取 skills(含正文) ---- +function loadSkills() { + const skills = []; + for (const entry of readdirSync(SKILLS_DIR, { withFileTypes: true })) { + if (!entry.isDirectory()) continue; + const file = join(SKILLS_DIR, entry.name, 'SKILL.md'); + if (!existsSync(file)) continue; + const raw = readFileSync(file, 'utf8'); + const fm = parseFrontmatter(raw); + const meta = SKILL_META[entry.name] || { title: entry.name, titleEn: entry.name, descEn: '', group: 'flow' }; + skills.push({ + name: fm.name || entry.name, + title: meta.title, titleEn: meta.titleEn, + group: meta.group, + desc: (fm.description || '').trim(), + descEn: meta.descEn || '', + china: meta.group === 'china', + raw, + }); + } + const order = GROUPS.map(g => g.id); + skills.sort((a, b) => { + if (a.name === 'using-superpowers') return -1; + if (b.name === 'using-superpowers') return 1; + return order.indexOf(a.group) - order.indexOf(b.group); + }); + return skills; +} + +// ---- 公共布局 ---- +// base: 资源相对前缀('' / '../' / '../../');langHref: 切换语言的目标 URL +function layout({ lang, base, title, desc, body, langHref, extraHead = '' }) { + const t = T[lang]; + const other = lang === 'zh' ? 'EN' : '中文'; + return ` + + + + +${esc(title)} + + + + + + + +${extraHead} + + +${body} +
+
+
+ superpowers-zh + ${t.footTag} +
+ ${t.footCols.map(col => `

${col.h}

${col.links.map(l => `${l[0]}`).join('')}
`).join('')} +
+ +
+ + +`; +} + +// ---- 首页正文 ---- +function renderLanding(skills, lang) { + const t = T[lang]; + const total = skills.length; + const cnCount = skills.filter(s => s.china).length; + const toolData = JSON.stringify(TOOLS.map(x => ({ name: x.name, cmd: x.cmd, auto: x.auto }))); + const fill = (s, map) => s.replace(/\{(\w+)\}/g, (_, k) => map[k]); + + const cards = skills.map(s => { + const title = lang === 'zh' ? s.title : s.titleEn; + const d = lang === 'zh' ? s.desc : (s.descEn || s.desc); + return ` + +

${esc(title)}

${s.china ? `${t.tagCn}` : ''}
+ ${esc(s.name)} +

${esc(d)}

+ ${t.skDetail} +
`; + }).join(''); + + const filters = GROUPS.map((g, i) => + ``).join(''); + const toolOpts = TOOLS.map((x, i) => ``).join(''); + const toolWall = TOOLS.map(x => `
${esc(x.name)}${esc(x.type)}
`).join(''); + const feats = t.features.map(f => `
${f.icon}

${esc(f.t)}

${esc(f.d)}

`).join(''); + const pipe = t.pipeline.map((p, i) => `
${i + 1}
${esc(p.n)}${esc(p.d)}
${i < t.pipeline.length - 1 ? '
' : ''}`).join(''); + const ucs = t.usecases.map(u => `
${esc(u.tag)}${esc(u.skills)}

${esc(u.desc)}

`).join(''); + const faqs = t.faq.map(f => `
${esc(f.q)}
${esc(f.a)}
`).join(''); + + return ` +
+
+
${t.heroBadge}
+

${t.heroH1}

+

${fill(t.heroLead, { n: total })}

+
$ npx superpowers-zh
+ +
+
${total}${t.stats[0]}
+
${cnCount}${t.stats[1]}
+
18${t.stats[2]}
+
v${PKG.version}${t.stats[3]}
+
+
+ +
+

${t.whyTitle}

+

${t.whySub}

+
${feats}
+
+ +
+

${t.plTitle}

+

${t.plSub}

+
${pipe}
+
+ +
+

${t.cmpTitle}

+
+
${t.cmpBad}
${esc(t.cmpBadPre)}
+
${t.cmpGood}
${esc(t.cmpGoodPre)}
+
+
+ +
+

${t.instTitle}

+

${t.instSub}

+
+ + +
npx superpowers-zh
+

+
+
+ +
+

${fill(t.skTitle, { n: total })}

+

${t.skSub}

+
+ +
${filters}
+
+
${cards}
+ +
+ +
+

${t.ucTitle}

+

${t.ucSub}

+
${ucs}
+
+ +
+

${t.toolsTitle}

+

${t.toolsSub}

+
${toolWall}
+
+ +
+

${t.faqTitle}

+
${faqs}
+
+ +
+

${t.bookTitle}

${t.bookDesc}

+ ${t.bookBtn} +
+ + + +
+

${t.ctaTitle}

${fill(t.ctaDesc, { n: total })}

+
$ npx superpowers-zh
+ +
+
+`; +} + +// ---- skill 详情(操作文档)页正文 ---- +function renderDetail(skill, lang) { + const t = T[lang]; + const title = lang === 'zh' ? skill.title : skill.titleEn; + const bodyHtml = renderMarkdown(skill.raw); + const cnNotice = lang === 'en' + ? '
📖 This skill\'s content is written in Chinese — superpowers-zh is a Chinese-localized toolkit.
' + : ''; + const srcUrl = `https://github.com/jnMetaCode/superpowers-zh/blob/main/skills/${skill.name}/SKILL.md`; + return ` +
+ ${t.backToSkills} +
+
+

${esc(title)}

+ ${esc(skill.name)} + ${skill.china ? `${t.tagCn}` : ''} +
+

${esc(lang === 'zh' ? skill.desc : (skill.descEn || skill.desc))}

+
+
$ npx superpowers-zh
+ ${t.detailSource} +
+
+ ${cnNotice} +
${bodyHtml}
+ ${t.backToSkills} +
+`; +} + +// ---- 构建 ---- +function build() { + const skills = loadSkills(); + rmSync(DIST, { recursive: true, force: true }); + mkdirSync(join(DIST, 'assets', 'sponsors'), { recursive: true }); + mkdirSync(join(DIST, 'skills'), { recursive: true }); + mkdirSync(join(DIST, 'en', 'skills'), { recursive: true }); + + // 资源 + copyFileSync(join(TEMPLATE, 'styles.css'), join(DIST, 'styles.css')); + copyFileSync(join(TEMPLATE, 'app.js'), join(DIST, 'app.js')); + copyFileSync(join(ROOT, 'assets', 'app-icon.png'), join(DIST, 'assets', 'app-icon.png')); + copyFileSync(join(ROOT, 'assets', 'superpowers-small.svg'), join(DIST, 'assets', 'superpowers-small.svg')); + copyFileSync(join(ROOT, 'assets', 'sponsors', '5cookie-code.png'), join(DIST, 'assets', 'sponsors', '5cookie-code.png')); + + // 中文站(根) + writeFileSync(join(DIST, 'index.html'), layout({ + lang: 'zh', base: '', title: T.zh.title, desc: T.zh.desc, + body: renderLanding(skills, 'zh'), langHref: 'en/index.html', + })); + // 英文站(/en/) + writeFileSync(join(DIST, 'en', 'index.html'), layout({ + lang: 'en', base: '../', title: T.en.title, desc: T.en.desc, + body: renderLanding(skills, 'en'), langHref: '../index.html', + })); + + // 详情(操作文档)页 ×2 语言 + for (const s of skills) { + writeFileSync(join(DIST, 'skills', `${s.name}.html`), layout({ + lang: 'zh', base: '../', title: `${s.title} · superpowers-zh`, desc: s.desc, + body: renderDetail(s, 'zh'), langHref: `../en/skills/${s.name}.html`, + })); + writeFileSync(join(DIST, 'en', 'skills', `${s.name}.html`), layout({ + lang: 'en', base: '../../', title: `${s.titleEn} · superpowers-zh`, desc: s.descEn || s.desc, + body: renderDetail(s, 'en'), langHref: `../../skills/${s.name}.html`, + })); + } + + // 收集所有生成页面里的内联