同步上游 v5.0.7:Copilot CLI 支持、OpenCode bootstrap 改进、版本统一

上游同步:
- hooks/session-start: 新增 Copilot CLI 平台检测(COPILOT_CLI 环境变量)
- .opencode/plugins/superpowers.js: bootstrap 从 system prompt 改为 user message 注入,避免 token 膨胀和 Qwen 兼容问题
- skills/using-superpowers: 新增 Copilot CLI 使用说明和工具映射引用
- 新增 references/copilot-tools.md(中文化)

本地优化:
- 清理 OpenCode 插件死代码(normalizePath/os/configDir)
- 统一版本号为 1.1.6(修复插件 JSON 与 package.json 不一致)
- .gitignore 排除安装器生成的 skills 副本
- package.json files 数组精简,避免打包重复的 skills 副本
- 安装器新增 copilot/copilot-cli 别名
- 工具数量更新为 15 款
This commit is contained in:
jiangnan
2026-04-13 19:55:20 +08:00
parent 72db65ad1c
commit fc9a2a40ca
12 changed files with 140 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "superpowers-zh", "name": "superpowers-zh",
"description": "AI 编程超能力中文增强版20 个 skills支持 OpenClaw / Claude Code / Cursor 等 14 款工具", "description": "AI 编程超能力中文增强版20 个 skills支持 OpenClaw / Claude Code / Cursor 等 15 款工具",
"owner": { "owner": {
"name": "jnMetaCode", "name": "jnMetaCode",
"url": "https://github.com/jnMetaCode" "url": "https://github.com/jnMetaCode"
@@ -8,8 +8,8 @@
"plugins": [ "plugins": [
{ {
"name": "superpowers-zh", "name": "superpowers-zh",
"description": "AI 编程超能力中文增强版20 个 skills14 翻译 + 6 中国原创),支持 OpenClaw / Claude Code / Cursor 等 14 款工具", "description": "AI 编程超能力中文增强版20 个 skills14 翻译 + 6 中国原创),支持 OpenClaw / Claude Code / Cursor 等 15 款工具",
"version": "1.1.1", "version": "1.1.6",
"source": "./", "source": "./",
"author": { "author": {
"name": "jnMetaCode", "name": "jnMetaCode",

View File

@@ -1,7 +1,7 @@
{ {
"name": "superpowers-zh", "name": "superpowers-zh",
"description": "AI 编程超能力中文增强版20 个 skills14 翻译 + 6 中国原创),支持 OpenClaw / Claude Code / Cursor 等 14 款工具", "description": "AI 编程超能力中文增强版20 个 skills14 翻译 + 6 中国原创),支持 OpenClaw / Claude Code / Cursor 等 15 款工具",
"version": "1.1.1", "version": "1.1.6",
"author": { "author": {
"name": "jnMetaCode", "name": "jnMetaCode",
"url": "https://github.com/jnMetaCode" "url": "https://github.com/jnMetaCode"

View File

@@ -1,8 +1,8 @@
{ {
"name": "superpowers-zh", "name": "superpowers-zh",
"displayName": "Superpowers 中文版", "displayName": "Superpowers 中文版",
"description": "AI 编程超能力中文增强版20 个 skills14 翻译 + 6 中国原创),支持 OpenClaw / Cursor / Claude Code 等 14 款工具", "description": "AI 编程超能力中文增强版20 个 skills14 翻译 + 6 中国原创),支持 OpenClaw / Cursor / Claude Code 等 15 款工具",
"version": "1.1.1", "version": "1.1.6",
"author": { "author": {
"name": "jnMetaCode", "name": "jnMetaCode",
"url": "https://github.com/jnMetaCode" "url": "https://github.com/jnMetaCode"

5
.gitignore vendored
View File

@@ -5,3 +5,8 @@
node_modules/ node_modules/
inspo inspo
triage/ triage/
# 安装器生成的 skills 副本(源在 skills/ 目录)
.codex/skills/
.gemini/skills/
.opencode/skills/

View File

@@ -1,13 +1,12 @@
/** /**
* Superpowers plugin for OpenCode.ai * Superpowers plugin for OpenCode.ai
* *
* Injects superpowers bootstrap context via system prompt transform. * Injects superpowers bootstrap context via user message transform.
* Auto-registers skills directory via config hook (no symlinks needed). * Auto-registers skills directory via config hook (no symlinks needed).
*/ */
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import os from 'os';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url)); const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -33,24 +32,8 @@ const extractAndStripFrontmatter = (content) => {
return { frontmatter, content: body }; return { frontmatter, content: body };
}; };
// Normalize a path: trim whitespace, expand ~, resolve to absolute
const normalizePath = (p, homeDir) => {
if (!p || typeof p !== 'string') return null;
let normalized = p.trim();
if (!normalized) return null;
if (normalized.startsWith('~/')) {
normalized = path.join(homeDir, normalized.slice(2));
} else if (normalized === '~') {
normalized = homeDir;
}
return path.resolve(normalized);
};
export const SuperpowersPlugin = async ({ client, directory }) => { export const SuperpowersPlugin = async ({ client, directory }) => {
const homeDir = os.homedir();
const superpowersSkillsDir = path.resolve(__dirname, '../../skills'); const superpowersSkillsDir = path.resolve(__dirname, '../../skills');
const envConfigDir = normalizePath(process.env.OPENCODE_CONFIG_DIR, homeDir);
const configDir = envConfigDir || path.join(homeDir, '.config/opencode');
// Helper to generate bootstrap content // Helper to generate bootstrap content
const getBootstrapContent = () => { const getBootstrapContent = () => {
@@ -68,8 +51,6 @@ When skills reference tools you don't have, substitute OpenCode equivalents:
- \`Skill\` tool → OpenCode's native \`skill\` tool - \`Skill\` tool → OpenCode's native \`skill\` tool
- \`Read\`, \`Write\`, \`Edit\`, \`Bash\` → Your native tools - \`Read\`, \`Write\`, \`Edit\`, \`Bash\` → Your native tools
**Skills location:**
Superpowers skills are in \`${configDir}/skills/superpowers/\`
Use OpenCode's native \`skill\` tool to list and load skills.`; Use OpenCode's native \`skill\` tool to list and load skills.`;
return `<EXTREMELY_IMPORTANT> return `<EXTREMELY_IMPORTANT>
@@ -96,12 +77,19 @@ ${toolMapping}
} }
}, },
// Use system prompt transform to inject bootstrap (fixes #226 agent reset bug) // Inject bootstrap into the first user message of each session.
'experimental.chat.system.transform': async (_input, output) => { // Using a user message instead of a system message avoids:
// 1. Token bloat from system messages repeated every turn (#750)
// 2. Multiple system messages breaking Qwen and other models (#894)
'experimental.chat.messages.transform': async (_input, output) => {
const bootstrap = getBootstrapContent(); const bootstrap = getBootstrapContent();
if (bootstrap) { if (!bootstrap || !output.messages.length) return;
(output.system ||= []).push(bootstrap); const firstUser = output.messages.find(m => m.info.role === 'user');
} if (!firstUser || !firstUser.parts.length) return;
// Only inject once
if (firstUser.parts.some(p => p.type === 'text' && p.text.includes('EXTREMELY_IMPORTANT'))) return;
const ref = firstUser.parts[0];
firstUser.parts.unshift({ ...ref, type: 'text', text: bootstrap });
} }
}; };
}; };

View File

@@ -1,2 +1,43 @@
@./skills/using-superpowers/SKILL.md @./skills/using-superpowers/SKILL.md
@./skills/using-superpowers/references/gemini-tools.md @./skills/using-superpowers/references/gemini-tools.md
# Superpowers-ZH 中文增强版
本项目已安装 superpowers-zh 技能框架20 个 skills
## 核心规则
1. **收到任务时,先检查是否有匹配的 skill** — 哪怕只有 1% 的可能性也要检查
2. **设计先于编码** — 收到功能需求时,先用 brainstorming skill 做需求分析
3. **测试先于实现** — 写代码前先写测试TDD
4. **验证先于完成** — 声称完成前必须运行验证命令
## 可用 Skills
Skills 位于 `.gemini/skills/` 目录,每个 skill 有独立的 `SKILL.md` 文件。
- **brainstorming**: 在任何创造性工作之前必须使用此技能——创建功能、构建组件、添加功能或修改行为。在实现之前先探索用户意图、需求和设计。
- **chinese-code-review**: 中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈
- **chinese-commit-conventions**: 中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化
- **chinese-documentation**: 中文技术文档写作规范——排版、术语、结构一步到位,告别机翻味
- **chinese-git-workflow**: 适配国内 Git 平台和团队习惯的工作流规范——Gitee、Coding、极狐 GitLab 全覆盖
- **dispatching-parallel-agents**: 当面对 2 个以上可以独立进行、无共享状态或顺序依赖的任务时使用
- **executing-plans**: 当你有一份书面实现计划需要在单独的会话中执行,并设有审查检查点时使用
- **finishing-a-development-branch**: 当实现完成、所有测试通过、需要决定如何集成工作时使用——通过提供合并、PR 或清理等结构化选项来引导开发工作的收尾
- **mcp-builder**: MCP 服务器构建方法论 — 系统化构建生产级 MCP 工具,让 AI 助手连接外部能力
- **receiving-code-review**: 收到代码审查反馈后、实施建议之前使用,尤其当反馈不明确或技术上有疑问时——需要技术严谨性和验证,而非敷衍附和或盲目执行
- **requesting-code-review**: 完成任务、实现重要功能或合并前使用,用于验证工作成果是否符合要求
- **subagent-driven-development**: 当在当前会话中执行包含独立任务的实现计划时使用
- **systematic-debugging**: 遇到任何 bug、测试失败或异常行为时使用在提出修复方案之前执行
- **test-driven-development**: 在实现任何功能或修复 bug 时使用,在编写实现代码之前
- **using-git-worktrees**: 当需要开始与当前工作区隔离的功能开发或执行实现计划之前使用——创建具有智能目录选择和安全验证的隔离 git 工作树
- **using-superpowers**: 在开始任何对话时使用——确立如何查找和使用技能,要求在任何响应(包括澄清性问题)之前调用 Skill 工具
- **verification-before-completion**: 在宣称工作完成、已修复或测试通过之前使用,在提交或创建 PR 之前——必须运行验证命令并确认输出后才能声称成功;始终用证据支撑断言
- **workflow-runner**: 在 Claude Code / OpenClaw / Cursor 中直接运行 agency-orchestrator YAML 工作流——无需 API key使用当前会话的 LLM 作为执行引擎。当用户提供 .yaml 工作流文件或要求多角色协作完成任务时触发。
- **writing-plans**: 当你有规格说明或需求用于多步骤任务时使用,在动手写代码之前
- **writing-skills**: 当创建新技能、编辑现有技能或在部署前验证技能是否有效时使用
## 如何使用
当任务匹配某个 skill 时,读取对应的 `.gemini/skills/<skill-name>/SKILL.md` 并严格遵循其流程。

View File

@@ -235,6 +235,8 @@ const TOOL_ALIASES = {
'claude': 'Claude Code', 'claude': 'Claude Code',
'claude-code': 'Claude Code', 'claude-code': 'Claude Code',
'claudecode': 'Claude Code', 'claudecode': 'Claude Code',
'copilot': 'Claude Code',
'copilot-cli': 'Claude Code',
'cursor': 'Cursor', 'cursor': 'Cursor',
'codex': 'Codex CLI', 'codex': 'Codex CLI',
'kiro': 'Kiro', 'kiro': 'Kiro',

View File

@@ -1,6 +1,6 @@
{ {
"name": "superpowers-zh", "name": "superpowers-zh",
"description": "AI 编程超能力中文版 — TDD、调试、代码审查等经过实战验证的工作方法论", "description": "AI 编程超能力中文版 — TDD、调试、代码审查等经过实战验证的工作方法论",
"version": "1.1.1", "version": "1.1.6",
"contextFileName": "GEMINI.md" "contextFileName": "GEMINI.md"
} }

View File

@@ -35,23 +35,23 @@ warning_escaped=$(escape_for_json "$warning_message")
session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${using_superpowers_escaped}\n\n${warning_escaped}\n</EXTREMELY_IMPORTANT>" session_context="<EXTREMELY_IMPORTANT>\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${using_superpowers_escaped}\n\n${warning_escaped}\n</EXTREMELY_IMPORTANT>"
# Output context injection as JSON. # Output context injection as JSON.
# Cursor hooks expect additional_context. # Cursor hooks expect additional_context (snake_case).
# Claude Code hooks expect hookSpecificOutput.additionalContext. # Claude Code hooks expect hookSpecificOutput.additionalContext (nested).
# Claude Code reads BOTH fields without deduplication, so we must only # Copilot CLI (v1.0.11+) and others expect additionalContext (top-level, SDK standard).
# emit the field consumed by the current platform to avoid double injection. # Claude Code reads BOTH additional_context and hookSpecificOutput without
# deduplication, so we must emit only the field the current platform consumes.
# #
# Uses printf instead of heredoc (cat <<EOF) to work around a bash 5.3+ # Uses printf instead of heredoc to work around bash 5.3+ heredoc hang.
# bug where heredoc variable expansion hangs when content exceeds ~512 bytes.
# See: https://github.com/obra/superpowers/issues/571 # See: https://github.com/obra/superpowers/issues/571
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
# Cursor sets CURSOR_PLUGIN_ROOT (may also set CLAUDE_PLUGIN_ROOT) — emit additional_context # Cursor sets CURSOR_PLUGIN_ROOT (may also set CLAUDE_PLUGIN_ROOT)
printf '{\n "additional_context": "%s"\n}\n' "$session_context" printf '{\n "additional_context": "%s"\n}\n' "$session_context"
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -z "${COPILOT_CLI:-}" ]; then
# Claude Code sets CLAUDE_PLUGIN_ROOT — emit only hookSpecificOutput # Claude Code sets CLAUDE_PLUGIN_ROOT without COPILOT_CLI
printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context" printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n }\n}\n' "$session_context"
else else
# Other platformsemit additional_context as fallback # Copilot CLI (sets COPILOT_CLI=1) or unknown platform — SDK standard format
printf '{\n "additional_context": "%s"\n}\n' "$session_context" printf '{\n "additionalContext": "%s"\n}\n' "$session_context"
fi fi
exit 0 exit 0

View File

@@ -1,10 +1,10 @@
{ {
"name": "superpowers-zh", "name": "superpowers-zh",
"version": "1.1.5", "version": "1.1.6",
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"
}, },
"description": "AI 编程超能力中文增强版 — superpowers99k+ ⭐)完整汉化 + 6 个中国原创 skills支持 OpenClaw / Claude Code / Cursor / Windsurf / Kiro / Gemini CLI 等 14 款工具", "description": "AI 编程超能力中文增强版 — superpowers99k+ ⭐)完整汉化 + 6 个中国原创 skills支持 Claude Code / Copilot CLI / Cursor / Windsurf / Kiro / Gemini CLI 等 15 款工具",
"type": "module", "type": "module",
"main": ".opencode/plugins/superpowers.js", "main": ".opencode/plugins/superpowers.js",
"bin": { "bin": {
@@ -18,8 +18,9 @@
"hooks/", "hooks/",
".claude-plugin/", ".claude-plugin/",
".cursor-plugin/", ".cursor-plugin/",
".codex/", ".codex/INSTALL.md",
".opencode/", ".opencode/INSTALL.md",
".opencode/plugins/",
"GEMINI.md", "GEMINI.md",
"gemini-extension.json", "gemini-extension.json",
"docs/", "docs/",

View File

@@ -29,13 +29,15 @@ Superpowers 技能覆盖默认系统提示行为,但**用户指令始终具有
**在 Claude Code 中:** 使用 `Skill` 工具。当你调用一个技能时,其内容会被加载并呈现给你——直接遵循即可。绝不要用 Read 工具读取技能文件。 **在 Claude Code 中:** 使用 `Skill` 工具。当你调用一个技能时,其内容会被加载并呈现给你——直接遵循即可。绝不要用 Read 工具读取技能文件。
**在 Copilot CLI 中:** 使用 `skill` 工具。技能从已安装的插件中自动发现。`skill` 工具的工作方式与 Claude Code 的 `Skill` 工具相同。
**在 Gemini CLI 中:** 技能通过 `activate_skill` 工具激活。Gemini 在会话开始时加载技能元数据,并按需激活完整内容。 **在 Gemini CLI 中:** 技能通过 `activate_skill` 工具激活。Gemini 在会话开始时加载技能元数据,并按需激活完整内容。
**在其他环境中:** 查看你的平台文档了解技能的加载方式。 **在其他环境中:** 查看你的平台文档了解技能的加载方式。
## 平台适配 ## 平台适配
技能使用 Claude Code 的工具名称。非 CC 平台:查看 `references/codex-tools.md`Codex了解工具对应关系。Gemini CLI 用户通过 GEMINI.md 自动获得工具映射。 技能使用 Claude Code 的工具名称。非 CC 平台:查看 `references/copilot-tools.md`Copilot CLI`references/codex-tools.md`Codex了解工具对应关系。Gemini CLI 用户通过 GEMINI.md 自动获得工具映射。
# 使用技能 # 使用技能

View File

@@ -0,0 +1,52 @@
# Copilot CLI 工具映射
技能使用 Claude Code 的工具名称。当你在技能中遇到这些工具时,使用你平台的等价工具:
| 技能中引用的工具 | Copilot CLI 等价工具 |
|-----------------|----------------------|
| `Read`(读取文件) | `view` |
| `Write`(创建文件) | `create` |
| `Edit`(编辑文件) | `edit` |
| `Bash`(运行命令) | `bash` |
| `Grep`(搜索文件内容) | `grep` |
| `Glob`(按名称搜索文件) | `glob` |
| `Skill` 工具(调用技能) | `skill` |
| `WebFetch` | `web_fetch` |
| `Task` 工具(分派子智能体) | `task`(参见[智能体类型](#智能体类型) |
| 多个 `Task` 调用(并行) | 多个 `task` 调用 |
| Task 状态/输出 | `read_agent``list_agents` |
| `TodoWrite`(任务跟踪) | `sql` 配合内置 `todos` 表 |
| `WebSearch` | 无等价工具 — 使用 `web_fetch` 配合搜索引擎 URL |
| `EnterPlanMode` / `ExitPlanMode` | 无等价工具 — 留在主会话中 |
## 智能体类型
Copilot CLI 的 `task` 工具接受 `agent_type` 参数:
| Claude Code 智能体 | Copilot CLI 等价 |
|-------------------|----------------------|
| `general-purpose` | `"general-purpose"` |
| `Explore` | `"explore"` |
| 命名的插件智能体(如 `superpowers:code-reviewer` | 从已安装的插件中自动发现 |
## 异步 Shell 会话
Copilot CLI 支持持久化的异步 shell 会话,这在 Claude Code 中没有直接等价物:
| 工具 | 用途 |
|------|---------|
| `bash` 配合 `async: true` | 在后台启动长时间运行的命令 |
| `write_bash` | 向运行中的异步会话发送输入 |
| `read_bash` | 读取异步会话的输出 |
| `stop_bash` | 终止异步会话 |
| `list_bash` | 列出所有活跃的 shell 会话 |
## 额外的 Copilot CLI 工具
| 工具 | 用途 |
|------|---------|
| `store_memory` | 持久化代码库相关事实供未来会话使用 |
| `report_intent` | 更新 UI 状态行显示当前意图 |
| `sql` | 查询会话的 SQLite 数据库(待办、元数据) |
| `fetch_copilot_cli_documentation` | 查阅 Copilot CLI 文档 |
| GitHub MCP 工具(`github-mcp-server-*` | 原生 GitHub API 访问issue、PR、代码搜索 |