From b6c76832075f895775e1ff7eb866d4f6566bad8a Mon Sep 17 00:00:00 2001 From: Minecraft269 <176564132+Minecraft269@users.noreply.github.com> Date: Sat, 11 Jul 2026 19:14:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20bilingual=20refactoring=20=E2=80=94?= =?UTF-8?q?=20English=20canonical=20+=20Chinese=20locale=20copies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Translate all 6 SKILL.md files to idiomatic English as canonical source - Move Chinese originals to locale/SKILL.cn.md (invisible to skill auto-loader) - Translate 6 docs/*.md to EN, keep CN at docs/*.cn.md - Translate CLAUDE.md, CONTRIBUTING.md, README.md to English - Update plugin.json and marketplace.json descriptions to English - Translate _shared/package-context.md to English - Create _shared/i18n-glossary.md with authoritative EN↔CN term mappings - Create _shared/check-i18n-sync.sh structural sync validator - Add locale: zh-CN to all CN frontmatter copies - Update language policy (CLAUDE.md): user-facing content now English Verification: - check-i18n-sync.sh: 0 issues (all 6 skills, 6 docs in sync) - bash -n: all .sh files pass - Glob safety: skills/*/SKILL.md returns exactly 6 files - Tag consistency: all capability tags verified --- .claude-plugin/marketplace.json | 4 +- .claude-plugin/plugin.json | 2 +- CLAUDE.md | 144 +-- CONTRIBUTING.md | 224 ++-- README.md | 68 +- docs/env-health-check.cn.md | 26 + docs/env-health-check.md | 32 +- docs/git-commit-helper.cn.md | 33 + docs/git-commit-helper.md | 40 +- docs/github-pr-manager.cn.md | 42 + docs/github-pr-manager.md | 53 +- docs/github-pr-reviewer.cn.md | 45 + docs/github-pr-reviewer.md | 58 +- docs/quick-plugin-installer.cn.md | 40 + docs/quick-plugin-installer.md | 49 +- docs/universal-project-kickoff.cn.md | 67 + docs/universal-project-kickoff.md | 98 +- skills/_shared/check-i18n-sync.sh | 132 ++ skills/_shared/i18n-glossary.md | 119 ++ skills/_shared/locale/package-context.cn.md | 172 +++ skills/_shared/package-context.md | 220 ++-- skills/env-health-check/SKILL.md | 127 +- skills/env-health-check/locale/SKILL.cn.md | 120 ++ skills/git-commit-helper/SKILL.md | 219 ++-- skills/git-commit-helper/locale/SKILL.cn.md | 188 +++ skills/github-pr-manager/SKILL.md | 210 ++-- skills/github-pr-manager/locale/SKILL.cn.md | 185 +++ skills/github-pr-reviewer/SKILL.md | 250 ++-- skills/github-pr-reviewer/locale/SKILL.cn.md | 290 +++++ skills/quick-plugin-installer/SKILL.md | 290 ++--- .../quick-plugin-installer/locale/SKILL.cn.md | 308 +++++ skills/universal-project-kickoff/SKILL.md | 1111 ++++++++--------- .../locale/SKILL.cn.md | 830 ++++++++++++ 33 files changed, 4189 insertions(+), 1607 deletions(-) create mode 100644 docs/env-health-check.cn.md create mode 100644 docs/git-commit-helper.cn.md create mode 100644 docs/github-pr-manager.cn.md create mode 100644 docs/github-pr-reviewer.cn.md create mode 100644 docs/quick-plugin-installer.cn.md create mode 100644 docs/universal-project-kickoff.cn.md create mode 100644 skills/_shared/check-i18n-sync.sh create mode 100644 skills/_shared/i18n-glossary.md create mode 100644 skills/_shared/locale/package-context.cn.md create mode 100644 skills/env-health-check/locale/SKILL.cn.md create mode 100644 skills/git-commit-helper/locale/SKILL.cn.md create mode 100644 skills/github-pr-manager/locale/SKILL.cn.md create mode 100644 skills/github-pr-reviewer/locale/SKILL.cn.md create mode 100644 skills/quick-plugin-installer/locale/SKILL.cn.md create mode 100644 skills/universal-project-kickoff/locale/SKILL.cn.md diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 50e36ac..f48183a 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -1,13 +1,13 @@ { "name": "Minecraft269-skills", - "description": "Minecraft269 的 Claude Code 技能合集:GitHub PR 管理器、主动技能发现、通用项目启动工作流", + "description": "Minecraft269's Claude Code skill collection: GitHub PR Manager, Proactive Skill Discovery, Universal Project Kickoff Workflow", "owner": { "name": "Minecraft269" }, "plugins": [ { "name": "minecraft269-skills", - "description": "Minecraft269 的技能合集:GitHub PR 管理器、通用项目启动与能力发现(含 Fork 模式)、快速插件安装器、PR 代码审查器", + "description": "Minecraft269's skill collection: GitHub PR Manager, Universal Project Kickoff & Capability Discovery (with Fork mode), Quick Plugin Installer, PR Code Reviewer", "author": { "name": "Minecraft269" }, diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index a1e145b..fd6738f 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -2,7 +2,7 @@ "name": "minecraft269-skills", "version": "1.0.0", "min_claude_version": "0.2.0", - "description": "Minecraft269 的技能合集:GitHub PR 管理器、通用项目启动与能力发现(含 Fork 模式)、快速插件安装器、PR 代码审查器", + "description": "Minecraft269's skill collection: GitHub PR Manager, Universal Project Kickoff & Capability Discovery (with Fork mode), Quick Plugin Installer, PR Code Reviewer", "author": { "name": "Minecraft269" } diff --git a/CLAUDE.md b/CLAUDE.md index df1d108..992c5c4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,133 +2,133 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. -## 项目定义 +## Project Definition -为使用 Claude Code 的开发者解决跨项目复用技能和主动发现工具的痛点,通过持续创作和维护高质量 Claude Code 技能并通过 Marketplace 分发。想到什么就创建什么,也欢迎社区贡献。不设禁区,但在创建涉及外部 API、付费服务、敏感操作的技能时需在 frontmatter 中声明。 +Solving the pain points of cross-project skill reuse and proactive tool discovery for developers using Claude Code, through continuous creation and maintenance of high-quality Claude Code skills distributed via Marketplace. Create whatever comes to mind; community contributions are welcome. No restrictions, but skills involving external APIs, paid services, or sensitive operations must be declared in frontmatter. -## 项目结构 +## Project Structure ``` -.claude-plugin/ # 插件清单 + Marketplace 注册 +.claude-plugin/ # Plugin manifest + Marketplace registration ├── plugin.json └── marketplace.json -.github/ # CI/CD 配置 +.github/ # CI/CD configuration └── workflows/ - └── skill-health.yml # Frontmatter 格式校验 + 标签一致性检查 -docs/ # 技能详细文档(README 链接指向此处),每技能一份 -skills/ # 所有技能(每个子目录一个技能) -├── _shared/ # 包级共享资源(检测协议、通用模板) -├── universal-project-kickoff/ # 通用项目启动与能力发现(已吸收原 proactive-skill-discovery,含 Fork 模式) -│ └── references/ # 7 份参考文件 -├── github-pr-manager/ # GitHub PR 全功能管理器 -├── github-pr-reviewer/ # GitHub PR 审查器(逐行 inline 评论) -├── quick-plugin-installer/ # 快速安装插件(MCP + SKILL) -├── git-commit-helper/ # Git 提交规范化助手(Conventional Commits) -└── env-health-check/ # 跨平台环境自检 -CONTRIBUTING.md # 贡献指南(含能力标签注册表 + 标签决策树) + └── skill-health.yml # Frontmatter format validation + tag consistency check +docs/ # Skill documentation (README links point here), one per skill +skills/ # All skills (one subdirectory per skill) +├── _shared/ # Package-level shared resources (detection protocol, common templates, i18n glossary) +├── universal-project-kickoff/ # Universal project kickoff & capability discovery (absorbed proactive-skill-discovery, includes Fork mode) +│ └── references/ # 7 reference files +├── github-pr-manager/ # GitHub PR full-featured manager +├── github-pr-reviewer/ # GitHub PR reviewer (line-by-line inline comments) +├── quick-plugin-installer/ # Quick plugin installer (MCP + SKILL) +├── git-commit-helper/ # Git commit standardization helper (Conventional Commits) +└── env-health-check/ # Cross-platform environment health check +CONTRIBUTING.md # Contribution guide (capability tag registry + tag decision tree) ``` -## 快速开始 +## Quick Start ```bash git clone https://github.com/Minecraft269/skills.git cd skills -find skills/ -name "*.sh" -exec bash -n {} \; # Shell 语法检查 -grep -oP 'capabilities:\s*\[\K[^\]]+' skills/*/SKILL.md | tr '"' '\n' | sort -u # 标签一致性 +find skills/ -name "*.sh" -exec bash -n {} \; # Shell syntax check +grep -oP 'capabilities:\s*\[\K[^\]]+' skills/*/SKILL.md | tr '"' '\n' | sort -u # Tag consistency ``` -## 创建新技能 +## Creating New Skills -**必须使用 `/skill-creator` 创建新技能。** 使用前确认已安装 skill-creator 插件。 +**You must use `/skill-creator` to create new skills.** Confirm the skill-creator plugin is installed first. -创建完成后将技能目录放入 `skills//`,每个技能至少包含一个 `SKILL.md`(YAML frontmatter + Markdown 正文)。同步在 `docs/.md` 创建技能文档。 +After creation, place the skill directory into `skills//`. Each skill must contain at least a `SKILL.md` (YAML frontmatter + Markdown body). Simultaneously create skill documentation at `docs/.md`. -## 代码风格 +## Code Style -- 缩进:2 空格(与 skill-creator 生成的标准一致) -- 注释:头部写用途和用法,关键逻辑写注释,自解释代码不写 -- 技能目录命名:`kebab-case`(如 `github-pr-manager`) -- frontmatter `name`:与目录名一致 -- frontmatter `version`:技能版本号,推荐 SemVer(如 `"3.0.0"`),用于追踪重大变更 -- frontmatter `risk`:操作风险等级(`safe` / `medium` / `high`),涉及外部 API、付费服务、敏感操作的技能必须声明 -- frontmatter `source`:来源标识(`community` / `official` / `custom`),用于 Marketplace 分类 -- frontmatter 联动字段:`capabilities`(提供的能力标签)、`integrates_with`(需要配合的能力标签)— 可选,用于包内技能动态发现 -- 脚本文件:`snake_case.sh` -- 所有面向用户的内容使用中文,技术术语保留英文 -- 跨技能引用必须通过 PACKAGE_MODE 检测门控,独立安装时静默降级 -- `.discovery-rules.json` 覆盖约定 — `deep_explore_plugins`、`priority_boost_plugins`、`cache_ttl_hours` 等字段的硬编码默认值可被 `~/.claude/skills/.discovery-rules.json` 覆盖。修改默认值时需同步更新三处:SKILL.md(Step 0c-2 配置读取段)、scanner-patterns.md(默认值标注)、discovery-rules.json 的 JSON Schema +- Indentation: 2 spaces (consistent with skill-creator generated standard) +- Comments: header documents purpose and usage, key logic gets comments, self-explanatory code stays comment-free +- Skill directory naming: `kebab-case` (e.g. `github-pr-manager`) +- frontmatter `name`: matches directory name +- frontmatter `version`: skill version number, SemVer recommended (e.g. `"3.0.0"`), used for tracking breaking changes +- frontmatter `risk`: operational risk level (`safe` / `medium` / `high`); skills involving external APIs, paid services, or sensitive operations must declare this +- frontmatter `source`: origin identifier (`community` / `official` / `custom`), used for Marketplace categorization +- frontmatter linkage fields: `capabilities` (capabilities provided), `integrates_with` (capabilities needed for coordination) — optional, used for intra-package dynamic skill discovery +- Script files: `snake_case.sh` +- All user-facing content uses English; technical terms remain in English +- Cross-skill references must be gated by PACKAGE_MODE detection; silently degrade when installed standalone +- `.discovery-rules.json` override convention — hardcoded defaults for `deep_explore_plugins`, `priority_boost_plugins`, `cache_ttl_hours` and other fields can be overridden by `~/.claude/skills/.discovery-rules.json`. When modifying defaults, update three locations simultaneously: SKILL.md (Step 0c-2 config reading section), scanner-patterns.md (default value annotations), and discovery-rules.json JSON Schema -## 风险与预案 +## Risks and Contingency Plans -| 风险 | B 计划 | +| Risk | Plan B | |------|--------| -| 合规踩坑(License 冲突、引用未授权代码) | 每个新技能发布前做 License 审查;工具依赖统一声明 | -| Claude Code 版本升级导致技能不兼容 | 技能中写明最低兼容版本;新版发布后优先跑一遍核心路径 | -| 社区贡献失控(PR 质量参差、风格不统一) | CONTRIBUTING.md + PR 模板把关;核心技能自己审核 | +| Compliance pitfalls (license conflicts, unauthorized code references) | License review before each new skill release; unified tool dependency declarations | +| Claude Code version upgrade causing skill incompatibility | Document minimum compatible version in skill; run core paths first after new release | +| Community contribution chaos (uneven PR quality, inconsistent style) | CONTRIBUTING.md + PR template gatekeeping; core skills self-reviewed | -## 路线图 +## Roadmap -M1–M7 已全部完成 ✅ — 历经 Marketplace 可用、扩展强化、技能联动、能力合并、质量审查、逻辑修复、审查增强。当前阶段:持续功能扩展(如 v4.0.0 Fork 模式)。 +M1–M7 all completed ✅ — through Marketplace availability, extension hardening, skill linkage, capability merging, quality review, logic fixes, review enhancement. Current phase: ongoing feature expansion (e.g. v4.0.0 Fork mode). -## 本地验证 +## Local Verification -提交前运行以下命令确保通过 CI: +Run these commands before committing to ensure CI passes: ```bash -# Shell 语法检查 +# Shell syntax check find skills/ -name "*.sh" -exec bash -n {} \; -# 手动验证标签一致性(CI 自动执行) -# 注意:grep -oP 需要 GNU grep(Linux),macOS BSD grep 不支持 -P,请 brew install grep 或使用 CI 验证 +# Manual tag consistency verification (CI runs this automatically) +# Note: grep -oP requires GNU grep (Linux); macOS BSD grep does not support -P, use brew install grep or CI verification grep -oP 'capabilities:\s*\[\K[^\]]+' skills/*/SKILL.md | tr '"' '\n' | sort -u -# 对比 CONTRIBUTING.md 中的标签注册表 +# Compare against the tag registry in CONTRIBUTING.md ``` -## 发布流程 +## Release Workflow ```bash -# 1. 本地验证:frontmatter 完整性 + 标签一致性 + ShellCheck +# 1. Local verification: frontmatter completeness + tag consistency + ShellCheck find skills// -name "*.sh" -exec bash -n {} \; grep -oP 'capabilities:\s*\[\K[^\]]+' skills/*/SKILL.md | tr '"' '\n' | sort -u -# 2. 提交推送(需同步修改 4 处文件,见「新技能注册清单」) +# 2. Commit and push (must update 4 files simultaneously, see "New Skill Registration Checklist") git add skills// docs/.md CONTRIBUTING.md README.md git commit -m "feat: add skill" git push -# 若 commit 后发现需同步更新 README/docs,使用 amend 追加: +# If you need to sync README/docs after committing, use amend: git add README.md docs/.md git commit --amend --no-edit git push --force-with-lease origin -# 3. 推送到 GitHub 后 Marketplace 自动同步 +# 3. Marketplace auto-syncs after pushing to GitHub ``` -## 前置依赖 +## Prerequisites -安装此插件的用户需要: +Users installing this plugin need: - Claude Code CLI -- 各技能声明的前置工具(如 `gh`、`git`、`jq`) +- Prerequisite tools declared by each skill (e.g. `gh`, `git`, `jq`) -## 开发注意事项 +## Development Notes -- `.git/info/exclude` — 个人本地目录(`.omc/`、`.remember/`、`.impeccable/`)放这里,不提交到 `.gitignore` -- worktree 提交 — 如 `EnterWorktree` 创建的 worktree 中 git 命令不可用(`not a git repository`),使用 `GIT_DIR=../.git GIT_WORK_TREE= git ...` 变通 -- 推送后本地同步 — 通过 worktree 提交推送后,主仓库工作树会脱节,执行 `git fetch && git reset --hard origin/main` 同步(`git restore .` 只恢复文件,不移动分支指针) -- 不写 `Co-Authored-By` 尾部 +- `.git/info/exclude` — personal local directories (`.omc/`, `.remember/`, `.impeccable/`) go here; do not commit to `.gitignore` +- worktree commits — if git commands are unavailable in a worktree created by `EnterWorktree` (`not a git repository`), use `GIT_DIR=../.git GIT_WORK_TREE= git ...` as a workaround +- Post-push local sync — after committing and pushing through a worktree, the main repo worktree will be detached; run `git fetch && git reset --hard origin/main` to sync (`git restore .` only restores files, does not move the branch pointer) +- Do not append `Co-Authored-By` trailer -## 新技能注册清单 +## New Skill Registration Checklist -创建新技能需同步修改 4 处: +Creating a new skill requires updating 4 files simultaneously: -1. `skills//SKILL.md` — 技能定义(~150 行,含 frontmatter + 包联动 + 核心工作流 + 错误处理) -2. `CONTRIBUTING.md` — 在「能力标签注册表」表格末尾注册新能力标签 -3. `README.md` — 在末尾「技能列表」表格(许可证前面)添加一行 -4. `docs/.md` — 精简文档(~40 行,简介 + 前置条件 + 触发方式 + 工作流 + 交互选项) +1. `skills//SKILL.md` — skill definition (~150 lines, includes frontmatter + package linking + core workflow + error handling) +2. `CONTRIBUTING.md` — register new capability tag at the end of the "Capability Tag Registry" table +3. `README.md` — add a row to the "Skill List" table (before the license) +4. `docs/.md` — concise documentation (~40 lines, intro + prerequisites + trigger + workflow + interactive options) -纯 AI 驱动技能无需 `scripts/` 目录和 `references/` 目录。 +Purely AI-driven skills do not need `scripts/` or `references/` directories. -## CI 注意事项 +## CI Notes -- `ludeeus/action-shellcheck@master` 遇 warning 即失败,所有 `*.sh` 必须 `bash -n` + ShellCheck 零 warning -- CI 会验证 CONTRIBUTING.md 标签注册表与所有 `skills/*/SKILL.md` 的 `capabilities` 字段一致性 +- `ludeeus/action-shellcheck@master` fails on warnings; all `*.sh` must pass `bash -n` + ShellCheck with zero warnings +- CI validates consistency between the CONTRIBUTING.md tag registry and the `capabilities` fields of all `skills/*/SKILL.md` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3b8cdf4..d9d0199 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,174 +1,156 @@ -# 贡献指南 +# Contribution Guide -感谢你对 Minecraft269 Skills 的关注!本文件帮助你了解如何参与贡献。 +Thank you for your interest in Minecraft269 Skills! This document helps you understand how to contribute. -## 快速开始 +## Quick Start -1. **Fork** 本仓库 -2. 创建功能分支:`git checkout -b feat/your-skill-name` -3. 完成开发后提交 PR 到 `main` 分支 -4. 等待维护者审核 +1. **Fork** this repository +2. Create a feature branch: `git checkout -b feat/your-skill-name` +3. Submit a PR to the `main` branch after development +4. Wait for maintainer review -## 创建新技能 +## Creating New Skills -**推荐方式:使用 `skill-creator` 技能创建。** +**Recommended approach: Use the `skill-creator` skill to create.** -> ⚠️ 使用前请确认已安装 `skill-creator` 插件。如未安装,先在 Claude Code 中安装该插件。 +> ⚠️ Confirm the `skill-creator` plugin is installed before use. If not installed, install it in Claude Code first. -确认安装后,在 Claude Code 中运行 `/skill-creator`,它会引导你完成技能创建的标准流程。创建完成后,将生成的技能目录放入 `skills//`。 +After confirming installation, run `/skill-creator` in Claude Code. It will guide you through the standard skill creation process. After creation, place the generated skill directory into `skills//`. -### 技能目录结构 +### Skill Directory Structure ``` skills/ -├── _shared/ # 包级共享资源(检测协议、通用模板等) -│ ├── package-context.md # 包上下文检测协议 +├── _shared/ # Package-level shared resources +│ ├── package-context.md # Package context detection protocol +│ ├── i18n-glossary.md # EN↔CN terminology glossary │ └── ... -├── / # 单个技能目录 -│ ├── SKILL.md # 技能入口文件(必需) -│ ├── references/ # 参考资料(可选) +├── / # Single skill directory +│ ├── SKILL.md # Skill entry file (required) +│ ├── locale/ # Chinese translations (reference only) +│ │ └── SKILL.cn.md +│ ├── references/ # Reference materials (optional) │ │ └── *.md -│ ├── scripts/ # 可执行脚本(可选) +│ ├── scripts/ # Executable scripts (optional) │ │ └── *.sh -│ └── README.md # 技能说明(可选) +│ └── README.md # Skill description (optional) └── ... ``` -### SKILL.md 格式 +### SKILL.md Format -- 使用 YAML frontmatter(`---` 包裹),包含 `name`、`description` 字段 -- 可选字段:`version`(技能版本号,推荐使用 SemVer)、`capabilities`(本技能提供的能力标签)、`integrates_with`(本技能需要配合的能力标签) -- 正文使用 Markdown,中文为主 -- 代码块标注语言类型 -- 缩进使用 2 空格 +- Use YAML frontmatter (wrapped in `---`), containing `name` and `description` fields +- Optional fields: `version`, `capabilities`, `integrates_with` +- Body uses Markdown, primarily in English +- Code blocks annotated with language type +- Indentation uses 2 spaces -### 命名规范 +### Naming Conventions -- 技能目录:`kebab-case`(如 `github-pr-manager`) -- frontmatter `name`:与目录名一致 -- 脚本文件:`snake_case.sh` +- Skill directory: `kebab-case` (e.g. `github-pr-manager`) +- frontmatter `name`: matches directory name +- Script files: `snake_case.sh` -### 技能联动规范 +### Skill Linkage Specification -本插件包支持技能间互相配合。为确保独立安装用户不受影响,所有跨技能引用必须遵循以下规范。 +This plugin package supports inter-skill coordination. All cross-skill references must follow these specifications. -#### 包上下文检测 +#### Package Context Detection -每个技能在执行前需检测是否处于完整插件包环境: +Each skill must detect whether it is in a full plugin package environment: -1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` -2. 找到 → **高联系模式**(`PACKAGE_MODE = true`),可引用兄弟技能 -3. 未找到 → **独立模式**(`PACKAGE_MODE = false`),静默跳过所有跨技能引用 +1. Glob search for `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. Found → **High-Contact Mode** (`PACKAGE_MODE = true`), can reference sibling skills +3. Not found → **Standalone Mode** (`PACKAGE_MODE = false`), silently skip all cross-skill references -详见 `skills/_shared/package-context.md`。 +See `skills/_shared/package-context.md` for details. -#### Frontmatter 联动字段 +#### Frontmatter Linkage Fields -在 SKILL.md 的 YAML frontmatter 中声明联动意愿: +Declare linkage intent in the SKILL.md YAML frontmatter: ```yaml -capabilities: ["<能力标签>", ...] # 本技能提供的能力 -integrates_with: ["<需求标签>", ...] # 本技能需要配合的能力类型 +capabilities: ["", ...] # Capabilities this skill provides +integrates_with: ["", ...] # Capability types needed for coordination ``` -- `capabilities`:声明本技能能做什么,供其他技能发现 -- `integrates_with`:声明本技能在工作流中需要什么类型的配合 -- 两个字段均为可选 — 不声明则跳过联动 -- 标签应优先使用已有标签(见下方注册表),避免重复定义 +- `capabilities`: declares what this skill can do, for discovery by other skills +- `integrates_with`: declares what type of coordination this skill needs in its workflow +- Both fields are optional — skip linkage if not declared +- Tags should prioritize using existing tags (see registry below) -#### 条件性联动写法 +#### Conditional Linkage Writing -在 SKILL.md 中添加"包联动"章节,描述 PACKAGE_MODE 检测逻辑。联动钩子放在关键工作流步骤末尾: +Add a "Package Linking" section in SKILL.md describing the PACKAGE_MODE detection logic. Linkage hooks are placed at the end of key workflow steps. If PACKAGE_MODE = false, skip linkage sections entirely. -``` -**联动钩子(仅 PACKAGE_MODE = true 时执行):** -扫描兄弟技能的 capabilities,匹配本技能的 integrates_with 标签... -``` - -如果 PACKAGE_MODE = false,完全跳过联动段落 — 不显示任何跨技能提示。 - -#### 能力标签注册表 +#### Capability Tag Registry -新技能应优先使用已有标签。如需新标签,请在此注册并说明语义。 +New skills should prioritize using existing tags. If a new tag is needed, register it here. -**新标签创建决策树:** +**New Tag Creation Decision Tree:** ``` -需要声明新能力? - ├─ 搜索已有标签是否覆盖该语义 → 是 → 直接复用已有标签 - ├─ 已有标签相近但不完全匹配 → 优先使用已有标签,在 description 中说明 - └─ 语义完全不重叠 → 创建新标签,在本表末尾注册 +Need to declare a new capability? + ├─ Search existing tags → semantic overlap → Reuse existing tag + ├─ Existing tag is close → Prefer existing tag, clarify in description + └─ No overlap → Create new tag, register at end of this table ``` -**新标签注册要求:** -1. 标签名使用 `kebab-case`(如 `mobile-development`) -2. 提供明确的语义说明(一句话) -3. 至少有一个已有技能或即将创建的技能使用该标签 -4. 同步更新 CI 验证规则(`.github/workflows/skill-health.yml` 中的标签列表) - -| 标签 | 语义 | 已有使用者 | -|------|------|-----------| -| `pr-management` | PR 的查看/克隆/审查/CI 管理 | github-pr-manager | -| `ci-analysis` | CI 状态检查与失败分析 | github-pr-manager | -| `code-cloning` | 将远程代码克隆到本地并初始化环境 | github-pr-manager | -| `skill-discovery` | 扫描项目、发现并推荐匹配能力 | universal-project-kickoff | -| `capability-scanning` | 扫描已安装的技能/插件/MCP | universal-project-kickoff | -| `project-analysis` | 分析项目技术栈和结构 | universal-project-kickoff | -| `plugin-installation` | 安装 MCP/SKILL 插件 | quick-plugin-installer | -| `mcp-setup` | MCP Server 配置与验证 | quick-plugin-installer | -| `project-setup` | 项目启动的六步决策流程 | universal-project-kickoff | -| `risk-assessment` | 项目风险识别与预案 | universal-project-kickoff | -| `mvp-planning` | MVP 范围圈定与路线图 | universal-project-kickoff | -| `pr-review` | PR 代码审查与 inline 评论工作流 | github-pr-reviewer | -| `code-review` | 代码质量审查(通用) | github-pr-reviewer | -| `inline-comments` | 逐行 inline PR 评论发布 | github-pr-reviewer | -| `git-commit` | Git 提交规范化与 commit message 生成 | git-commit-helper | -| `env-check` | 跨平台环境自检与依赖可用性诊断 | env-health-check | -| `testing` | 测试策略、测试框架、E2E 测试(预留) | — | -| `mobile-development` | 移动端开发(React Native/Flutter/Swift/Kotlin)(预留) | — | -| `security-audit` | 安全审查与漏洞检测(预留) | — | -| `debugging` | 调试、根因分析与错误追踪(预留) | — | -| `fork-workflow` | Fork 开源仓库、本地开发、提交 PR 的完整贡献工作流 | universal-project-kickoff | - -#### 共享资源 - -`skills/_shared/` 目录存放包级公共资源: -- `package-context.md` — 包上下文检测协议 -- 未来可扩展:通用模板、共享脚本、公共常量等 - -各技能可通过相对路径引用 `_shared/` 中的资源。新增共享资源时需在本文件中说明用途。 - -### 提交信息 - -使用约定式提交格式: +| Tag | Semantics | Used By | +|------|----------|---------| +| `pr-management` | PR viewing/cloning/review/CI management | github-pr-manager | +| `ci-analysis` | CI status checking and failure analysis | github-pr-manager | +| `code-cloning` | Clone remote code locally and initialize environment | github-pr-manager | +| `skill-discovery` | Scan projects, discover and recommend matching capabilities | universal-project-kickoff | +| `capability-scanning` | Scan installed skills/plugins/MCP | universal-project-kickoff | +| `project-analysis` | Analyze project tech stack and structure | universal-project-kickoff | +| `plugin-installation` | Install MCP/SKILL plugins | quick-plugin-installer | +| `mcp-setup` | MCP Server configuration and verification | quick-plugin-installer | +| `project-setup` | Six-step decision process for project kickoff | universal-project-kickoff | +| `risk-assessment` | Project risk identification and contingency planning | universal-project-kickoff | +| `mvp-planning` | MVP scope definition and roadmap | universal-project-kickoff | +| `pr-review` | PR code review and inline comment workflow | github-pr-reviewer | +| `code-review` | Code quality review (general) | github-pr-reviewer | +| `inline-comments` | Line-by-line inline PR comment publishing | github-pr-reviewer | +| `git-commit` | Git commit standardization and commit message generation | git-commit-helper | +| `env-check` | Cross-platform environment health check and dependency diagnostics | env-health-check | +| `testing` | Test strategy, test frameworks, E2E testing (reserved) | — | +| `mobile-development` | Mobile development (reserved) | — | +| `security-audit` | Security review and vulnerability detection (reserved) | — | +| `debugging` | Debugging, root cause analysis, and error tracing (reserved) | — | +| `fork-workflow` | Complete contribution workflow: fork → local dev → submit PR | universal-project-kickoff | + +### Commit Messages + +Use conventional commit format: ``` -feat: 添加 xxx 技能 -fix: 修复 xxx 问题 -docs: 更新 xxx 文档 -refactor: 重构 xxx +feat: add xxx skill +fix: fix xxx issue +docs: update xxx documentation +refactor: refactor xxx ``` -## 技能审核标准 +## Skill Review Standards -提交 PR 前请确认: +Before submitting a PR, confirm: -- [ ] SKILL.md 包含完整的 frontmatter(name、description) -- [ ] 如技能属于本插件包,已声明 `capabilities` 和 `integrates_with`(如适用) -- [ ] 跨技能引用使用 PACKAGE_MODE 门控,独立安装时静默降级 -- [ ] 技能可通过 `/` 命令正常触发 -- [ ] 引用的外部工具/依赖在 frontmatter 中声明 -- [ ] 无侵犯他人 License 的内容 -- [ ] 已在本地实际测试过核心路径 +- [ ] SKILL.md includes complete frontmatter (name, description) +- [ ] `capabilities` and `integrates_with` declared (if applicable) +- [ ] Cross-skill references use PACKAGE_MODE gating, silently degrading standalone +- [ ] Skill can be triggered via `/` command +- [ ] External tools/dependencies declared in frontmatter +- [ ] No license-infringing content +- [ ] Core paths tested locally -## 报告问题 +## Reporting Issues -通过 [GitHub Issues](https://github.com/Minecraft269/skills/issues) 提交: +Submit via [GitHub Issues](https://github.com/Minecraft269/skills/issues): -- **Bug 报告**:描述遇到的问题、复现步骤、预期行为 -- **功能建议**:描述使用场景、期望的效果 -- **技能请求**:说明你需要的技能及使用场景 +- **Bug Reports**: Problem, reproduction steps, expected behavior +- **Feature Suggestions**: Use case and desired outcome +- **Skill Requests**: Skill needed and use case ## License -本项目的所有贡献均遵循 [MIT License](LICENSE)。 +All contributions are under the [MIT License](LICENSE). diff --git a/README.md b/README.md index 37f34a0..41a0572 100644 --- a/README.md +++ b/README.md @@ -1,72 +1,72 @@ # Minecraft269 Skills -Minecraft269 的 Claude Code 技能合集,想到什么就创建什么,也欢迎社区贡献。 +A collection of Claude Code skills by Minecraft269 — create whatever comes to mind, community contributions welcome. -## 技能联动 +## Skill Linkage -完整安装本插件包后,六个技能会自动发现彼此并在关键工作流节点联动: +When the full plugin package is installed, the six skills automatically discover each other and link at key workflow nodes: -- **Git 提交助手** — 提交完成后有 GitHub remote 时提示 PR 管理,涉及代码时提示审查 -- **环境自检** — 发现缺失工具时引导安装,环境就绪后触发能力发现 -- **项目启动与发现** — 关键词预判用户意图(启动/开发/审查/修复/探索/Fork),意图不明确时询问;审查代码支持本地/远程 PR、在线快速审查或 clone 本地深度审查,审查前确认模型;Fork 模式支持 fork → clone → 分析 → 贡献引导五步流程;新项目执行六步启动检查流程(MVP/风险/路线图/CLAUDE.md);已吸收原 proactive-skill-discovery 能力 -- **PR 管理器** — 克隆 PR 后提醒新贡献者使用项目启动流程,检测新项目类型时触发能力发现 -- **PR 审查器** — 与 PR 管理器共享上下文,审查完成后提示相关操作 -- **插件安装器** — 安装完成后自动提示运行项目启动与能力发现 +- **Git Commit Helper** — after committing, suggests PR management when a GitHub remote exists; suggests code review when code changes are involved +- **Environment Health Check** — guides installation when missing tools are found; triggers capability discovery when environment is ready +- **Project Kickoff & Discovery** — pre-detects user intent via keywords (start/develop/review/fix/explore/Fork); asks when intent is ambiguous; code review supports local/remote PR, quick online review or clone-local deep review, with model confirmation before review; Fork mode supports fork → clone → analyze → contribution guide 5-step flow; new projects execute 6-step mandatory kickoff (MVP/risk/roadmap/CLAUDE.md); has absorbed former proactive-skill-discovery capabilities +- **PR Manager** — reminds new contributors to use project kickoff flow after cloning a PR; triggers capability discovery when detecting new project types +- **PR Reviewer** — shares context with PR Manager; suggests related actions after review completion +- **Plugin Installer** — after installation, automatically suggests running project kickoff and capability discovery -> 💡 如果你单独安装了某个技能(而非完整插件包),联动功能会自动静默关闭,核心功能不受影响。 +> 💡 If you installed a skill individually (not the full plugin package), linkage features are silently disabled; core functionality is unaffected. --- -## 安装 +## Installation -### 方式一:Marketplace 安装(推荐) +### Method 1: Marketplace Install (Recommended) ```bash -# 1. 注册 marketplace +# 1. Register marketplace claude plugins marketplace add Minecraft269/skills -# 2. 安装插件 +# 2. Install plugin claude plugins install minecraft269-skills ``` -安装完成后重启 Claude Code 即可。 +Restart Claude Code after installation. -重启后,输入以下命令确认安装成功: +After restart, run these commands to confirm successful installation: ```bash -claude plugins list # 确认 minecraft269-skills 在列表中 -/discover # 运行技能发现(已合并至 universal-project-kickoff,自动扫描项目并推荐匹配技能) +claude plugins list # Confirm minecraft269-skills is in the list +/discover # Run skill discovery (merged into universal-project-kickoff, auto-scans project and recommends matching skills) ``` -### 方式二:手动安装 +### Method 2: Manual Install -适合离线环境或希望直接管理的用户。 +For offline environments or users who prefer direct management. ```bash -# 1. 克隆仓库 +# 1. Clone the repository git clone https://github.com/Minecraft269/skills.git -# 2. 复制到 Claude Code plugins 目录 +# 2. Copy to Claude Code plugins directory cp -r skills ~/.claude/plugins/minecraft269-skills ``` -然后重启 Claude Code,插件即会自动加载。 +Restart Claude Code and the plugin will be auto-loaded. --- -## 技能列表 +## Skill List -| 技能 | 简介 | -|------|------| -| [`universal-project-kickoff`](docs/universal-project-kickoff.md) | 通用项目启动与能力发现:意图探测 + 目标确认 + Fork 模式(参与开源贡献)+ 7 步能力发现(深度探索/优先推荐/指令发现/全量导出/持久化)+ 六步启动流程 | -| [`github-pr-manager`](docs/github-pr-manager.md) | GitHub PR 全功能管理器:列出、查看、克隆、分析 PR | -| [`quick-plugin-installer`](docs/quick-plugin-installer.md) | 快速安装插件:MCP Server 和 SKILL 的统一安装入口 | -| [`github-pr-reviewer`](docs/github-pr-reviewer.md) | GitHub PR 代码审查器:逐行 inline 评论,完整 pending review 工作流 | -| [`git-commit-helper`](docs/git-commit-helper.md) | Git 提交规范化助手:基于 staged diff 自动生成 Conventional Commits 消息 | -| [`env-health-check`](docs/env-health-check.md) | 跨平台环境自检:检测 git/gh/jq/claude 可用性,输出健康报告 | +| Skill | Description | +|-------|-------------| +| [`universal-project-kickoff`](docs/universal-project-kickoff.md) | Universal project kickoff & capability discovery: intent detection + target confirmation + Fork mode (contribute to open source) + 7-step capability discovery + 6-step mandatory kickoff | +| [`github-pr-manager`](docs/github-pr-manager.md) | GitHub PR full-featured manager: list, view, clone, analyze PRs | +| [`quick-plugin-installer`](docs/quick-plugin-installer.md) | Quick plugin installer: unified entry point for MCP Server and SKILL plugins | +| [`github-pr-reviewer`](docs/github-pr-reviewer.md) | GitHub PR code reviewer: line-by-line inline comments, full pending review workflow | +| [`git-commit-helper`](docs/git-commit-helper.md) | Git commit standardization helper: auto-generates Conventional Commits messages based on staged diff | +| [`env-health-check`](docs/env-health-check.md) | Cross-platform environment health check: detects git/gh/jq/claude availability, outputs health report | --- -## 许可证 +## License -MIT License — 详见 [LICENSE](LICENSE) +MIT License — see [LICENSE](LICENSE) diff --git a/docs/env-health-check.cn.md b/docs/env-health-check.cn.md new file mode 100644 index 0000000..67d7394 --- /dev/null +++ b/docs/env-health-check.cn.md @@ -0,0 +1,26 @@ +# env-health-check + +跨平台检测 git、gh、jq、claude 等核心工具可用性,输出格式化健康报告。 + +## 触发方式 + +说「检查环境」「环境自检」「我的工具链是否就绪」即可触发。 + +## 检测范围 + +| 类别 | 检测项 | +|------|--------| +| 核心依赖 | git、gh、jq、claude、node、python | +| 服务状态 | gh 认证、MCP Server 配置 | +| 安装建议 | 缺失工具给出 Win/macOS/Linux 安装命令 | + +## 工作流 + +1. 并行运行 `command -v` + `--version` 检测所有工具 +2. 检查 `gh auth status` 和 MCP 配置 +3. 输出格式化健康报告(✅/⚠️/❌) + +## 联动 + +- 缺失工具 → 提示 **插件安装器** +- 环境就绪 → 提示 **技能发现** diff --git a/docs/env-health-check.md b/docs/env-health-check.md index 67d7394..a7fb00e 100644 --- a/docs/env-health-check.md +++ b/docs/env-health-check.md @@ -1,26 +1,26 @@ # env-health-check -跨平台检测 git、gh、jq、claude 等核心工具可用性,输出格式化健康报告。 +Cross-platform detection of core tool availability (git, gh, jq, claude, etc.), outputting a formatted health report. -## 触发方式 +## Trigger -说「检查环境」「环境自检」「我的工具链是否就绪」即可触发。 +Say "check environment", "env health check", or "is my toolchain ready" to trigger. -## 检测范围 +## Detection Scope -| 类别 | 检测项 | -|------|--------| -| 核心依赖 | git、gh、jq、claude、node、python | -| 服务状态 | gh 认证、MCP Server 配置 | -| 安装建议 | 缺失工具给出 Win/macOS/Linux 安装命令 | +| Category | Items Checked | +|----------|---------------| +| Core Dependencies | git, gh, jq, claude, node, python | +| Service Status | gh auth, MCP Server configuration | +| Install Suggestions | Win/macOS/Linux install commands for missing tools | -## 工作流 +## Workflow -1. 并行运行 `command -v` + `--version` 检测所有工具 -2. 检查 `gh auth status` 和 MCP 配置 -3. 输出格式化健康报告(✅/⚠️/❌) +1. Run `command -v` + `--version` for all tools in parallel +2. Check `gh auth status` and MCP configuration +3. Output formatted health report (✅/⚠️/❌) -## 联动 +## Linkage -- 缺失工具 → 提示 **插件安装器** -- 环境就绪 → 提示 **技能发现** +- Missing tools → suggest **Plugin Installer** +- Environment ready → suggest **Skill Discovery** diff --git a/docs/git-commit-helper.cn.md b/docs/git-commit-helper.cn.md new file mode 100644 index 0000000..820c9ea --- /dev/null +++ b/docs/git-commit-helper.cn.md @@ -0,0 +1,33 @@ +# git-commit-helper + +基于 `git diff --staged` 分析变更,自动生成符合 [Conventional Commits](https://www.conventionalcommits.org/) 规范的提交信息。 + +## 前置条件 + +- `git` + +## 触发方式 + +直接说「帮我提交代码」「生成 commit message」「提交变更」即可触发。 + +## 工作流 + +1. 检测暂存区(`git status --short`) +2. 分析 `git diff --staged` 推断类型(feat/fix/docs 等)和 scope +3. 预览生成的 commit message,等待确认 +4. 执行 `git commit` 并联动 PR 管理/审查 + +## 交互选项 + +| 选项 | 动作 | +|------|------| +| ✅ 确认 | 直接提交 | +| ✏️ 编辑 | 修改 type/scope/描述 | +| 🔄 重试 | 重新分析 | +| 📝 手写 | 完全手写 | +| ❌ 取消 | 不提交 | + +## 联动 + +- 提交完成后,有 GitHub remote 时提示 **PR 管理** +- 涉及代码变更时提示 **代码审查** diff --git a/docs/git-commit-helper.md b/docs/git-commit-helper.md index 820c9ea..046b868 100644 --- a/docs/git-commit-helper.md +++ b/docs/git-commit-helper.md @@ -1,33 +1,33 @@ # git-commit-helper -基于 `git diff --staged` 分析变更,自动生成符合 [Conventional Commits](https://www.conventionalcommits.org/) 规范的提交信息。 +Analyzes `git diff --staged` changes and automatically generates commit messages conforming to [Conventional Commits](https://www.conventionalcommits.org/). -## 前置条件 +## Prerequisites - `git` -## 触发方式 +## Trigger -直接说「帮我提交代码」「生成 commit message」「提交变更」即可触发。 +Say "help me commit", "generate commit message", or "commit changes" to trigger. -## 工作流 +## Workflow -1. 检测暂存区(`git status --short`) -2. 分析 `git diff --staged` 推断类型(feat/fix/docs 等)和 scope -3. 预览生成的 commit message,等待确认 -4. 执行 `git commit` 并联动 PR 管理/审查 +1. Detect staging area (`git status --short`) +2. Analyze `git diff --staged` to infer type (feat/fix/docs etc.) and scope +3. Preview the generated commit message and wait for confirmation +4. Execute `git commit` and link to PR management/review -## 交互选项 +## Interactive Options -| 选项 | 动作 | -|------|------| -| ✅ 确认 | 直接提交 | -| ✏️ 编辑 | 修改 type/scope/描述 | -| 🔄 重试 | 重新分析 | -| 📝 手写 | 完全手写 | -| ❌ 取消 | 不提交 | +| Option | Action | +|--------|--------| +| ✅ Confirm | Commit directly | +| ✏️ Edit | Modify type/scope/description | +| 🔄 Retry | Re-analyze | +| 📝 Manual | Write manually | +| ❌ Cancel | Do not commit | -## 联动 +## Linkage -- 提交完成后,有 GitHub remote 时提示 **PR 管理** -- 涉及代码变更时提示 **代码审查** +- After commit, if a GitHub remote exists → suggest **PR Manager** +- When code changes are involved → suggest **Code Review** diff --git a/docs/github-pr-manager.cn.md b/docs/github-pr-manager.cn.md new file mode 100644 index 0000000..84e150a --- /dev/null +++ b/docs/github-pr-manager.cn.md @@ -0,0 +1,42 @@ +# github-pr-manager + +GitHub PR 全功能管理器 — 在终端中列出、查看、克隆、分析 GitHub Pull Request。 + +## 核心功能 + +- 列出仓库所有开放 PR(表格展示,支持翻页) +- 查看 PR 完整信息:详情、diff、评论、审查状态、提交历史 +- 克隆 PR 到本地并自动检测项目类型(Node/Python/Rust/Go/Java)初始化环境 +- CI 状态查看和失败原因分析 +- 多仓库切换和批量操作 + +## 前置依赖 + +- `gh` (GitHub CLI ≥ 2.0.0) +- `git` +- `jq` + +## 命令速查 + +| 输入 | 说明 | +|------|------| +| `<编号>` | 查看 PR 完整信息(默认行为) | +| `c <编号>` | 克隆 PR 并初始化 | +| `d <编号>` | 仅查看详情 | +| `diff <编号>` | 查看代码变更 | +| `comments <编号>` | 查看评论和审查 | +| `commits <编号>` | 查看提交历史 | +| `batch clone ,` | 批量克隆 | +| `batch view ,` | 批量查看 | +| `r` | 刷新 PR 列表 | +| `repo ` | 切换仓库 | + +## 相关技能 + +本技能属于 [minecraft269-skills](https://github.com/Minecraft269/skills) 插件包。当完整安装插件包时,本技能可与其他包内技能自动联动: + +- 克隆 PR 后自动提示项目启动流程和技能发现 +- 被主动技能发现引擎自动推荐给 GitHub 项目 + +独立安装本技能时,上述联动功能静默关闭,不影响核心 PR 管理功能。 + diff --git a/docs/github-pr-manager.md b/docs/github-pr-manager.md index 84e150a..6d5849d 100644 --- a/docs/github-pr-manager.md +++ b/docs/github-pr-manager.md @@ -1,42 +1,41 @@ # github-pr-manager -GitHub PR 全功能管理器 — 在终端中列出、查看、克隆、分析 GitHub Pull Request。 +Full-featured GitHub PR manager — list, view, clone, and analyze GitHub Pull Requests in the terminal. -## 核心功能 +## Core Features -- 列出仓库所有开放 PR(表格展示,支持翻页) -- 查看 PR 完整信息:详情、diff、评论、审查状态、提交历史 -- 克隆 PR 到本地并自动检测项目类型(Node/Python/Rust/Go/Java)初始化环境 -- CI 状态查看和失败原因分析 -- 多仓库切换和批量操作 +- List all open PRs for a repository (table display, supports pagination) +- View complete PR info: details, diff, comments, review status, commit history +- Clone PRs locally with automatic project type detection (Node/Python/Rust/Go/Java) and environment initialization +- CI status viewing and failure analysis +- Multi-repository switching and batch operations -## 前置依赖 +## Prerequisites - `gh` (GitHub CLI ≥ 2.0.0) - `git` - `jq` -## 命令速查 +## Command Quick Reference -| 输入 | 说明 | -|------|------| -| `<编号>` | 查看 PR 完整信息(默认行为) | -| `c <编号>` | 克隆 PR 并初始化 | -| `d <编号>` | 仅查看详情 | -| `diff <编号>` | 查看代码变更 | -| `comments <编号>` | 查看评论和审查 | -| `commits <编号>` | 查看提交历史 | -| `batch clone ,` | 批量克隆 | -| `batch view ,` | 批量查看 | -| `r` | 刷新 PR 列表 | -| `repo ` | 切换仓库 | +| Input | Description | +|-------|-------------| +| `` | View full PR info (default behavior) | +| `c ` | Clone PR and initialize | +| `d ` | View details only | +| `diff ` | View code changes | +| `comments ` | View comments and reviews | +| `commits ` | View commit history | +| `batch clone ,` | Batch clone | +| `batch view ,` | Batch view | +| `r` | Refresh PR list | +| `repo ` | Switch repository | -## 相关技能 +## Related Skills -本技能属于 [minecraft269-skills](https://github.com/Minecraft269/skills) 插件包。当完整安装插件包时,本技能可与其他包内技能自动联动: +This skill is part of the [minecraft269-skills](https://github.com/Minecraft269/skills) plugin package. When the full package is installed, this skill can auto-link with other package skills: -- 克隆 PR 后自动提示项目启动流程和技能发现 -- 被主动技能发现引擎自动推荐给 GitHub 项目 - -独立安装本技能时,上述联动功能静默关闭,不影响核心 PR 管理功能。 +- After cloning a PR, automatically suggests project kickoff flow and skill discovery +- Auto-recommended by the proactive skill discovery engine for GitHub projects +When installed standalone, the above linkage features are silently disabled, with no impact on core PR management functionality. diff --git a/docs/github-pr-reviewer.cn.md b/docs/github-pr-reviewer.cn.md new file mode 100644 index 0000000..9b8d93b --- /dev/null +++ b/docs/github-pr-reviewer.cn.md @@ -0,0 +1,45 @@ +# github-pr-reviewer — GitHub PR 代码审查器 + +在 GitHub Pull Request 上执行代码审查,使用 GitHub MCP 工具创建 **逐行 inline 审查评论**。 + +## 功能 + +- ✅ 自动拉取 PR diff 和上下文(文件列表、已有审查、评论) +- ✅ 按 P0-P5 优先级分析代码变更 +- ✅ 创建 pending review → 逐行 inline 评论 → 提交审查结论 +- ✅ 支持 APPROVE / REQUEST_CHANGES / COMMENT 三种审查结论 +- ✅ 与 github-pr-manager 上下文联动 +- ✅ MCP 不可用时自动降级到 `gh` CLI +- ✅ 审查结果标注审查模型 + +## 前置依赖 + +- GitHub MCP Server(`plugin:github:github`) +- `gh` CLI(可选,降级方案) + +## 用法 + +``` +review #5 # 审查当前仓库的 PR #5 +review owner/repo #123 # 审查指定仓库的 PR +review --thorough # 全面审查(含 P3-P5 建议) +review --summary-only # 仅输出审查摘要,不发布 +``` + +## 三阶段工作流 + +``` +阶段 0: 识别 PR → 阶段 1: 拉取 diff + 上下文 → 阶段 2: 逐行 inline 评论 → 阶段 3: 提交审查 +``` + +审查预览会完整展示每条评论的内容、代码上下文,用户确认后才发布到 GitHub。 + +## 与现有审查技能的区别 + +| 特性 | github-pr-reviewer | code-review | pr-review-toolkit | +|------|-------------------|-------------|-------------------| +| inline 评论(add_comment_to_pending_review) | ✅ | ❌ | ❌ | +| 完整 pending review 生命周期 | ✅ | ❌ | ❌ | +| 用户审核后发布 | ✅ | ❌ | ❌ | +| 审查模型标注 | ✅ | ❌ | ❌ | +| diff 代码上下文展示 | ✅ | 部分 | 部分 | diff --git a/docs/github-pr-reviewer.md b/docs/github-pr-reviewer.md index 9b8d93b..f68e8fa 100644 --- a/docs/github-pr-reviewer.md +++ b/docs/github-pr-reviewer.md @@ -1,45 +1,45 @@ -# github-pr-reviewer — GitHub PR 代码审查器 +# github-pr-reviewer — GitHub PR Code Reviewer -在 GitHub Pull Request 上执行代码审查,使用 GitHub MCP 工具创建 **逐行 inline 审查评论**。 +Performs code review on GitHub Pull Requests, creating **line-by-line inline review comments** using GitHub MCP tools. -## 功能 +## Features -- ✅ 自动拉取 PR diff 和上下文(文件列表、已有审查、评论) -- ✅ 按 P0-P5 优先级分析代码变更 -- ✅ 创建 pending review → 逐行 inline 评论 → 提交审查结论 -- ✅ 支持 APPROVE / REQUEST_CHANGES / COMMENT 三种审查结论 -- ✅ 与 github-pr-manager 上下文联动 -- ✅ MCP 不可用时自动降级到 `gh` CLI -- ✅ 审查结果标注审查模型 +- ✅ Automatically pulls PR diff and context (file list, existing reviews, comments) +- ✅ Analyzes code changes by P0-P5 priority +- ✅ Creates pending review → line-by-line inline comments → submits review conclusion +- ✅ Supports APPROVE / REQUEST_CHANGES / COMMENT review decisions +- ✅ Context linkage with github-pr-manager +- ✅ Automatic fallback to `gh` CLI when MCP is unavailable +- ✅ Review results annotated with the reviewing model -## 前置依赖 +## Prerequisites -- GitHub MCP Server(`plugin:github:github`) -- `gh` CLI(可选,降级方案) +- GitHub MCP Server (`plugin:github:github`) +- `gh` CLI (optional, fallback option) -## 用法 +## Usage ``` -review #5 # 审查当前仓库的 PR #5 -review owner/repo #123 # 审查指定仓库的 PR -review --thorough # 全面审查(含 P3-P5 建议) -review --summary-only # 仅输出审查摘要,不发布 +review #5 # Review PR #5 in current repo +review owner/repo #123 # Review PR in specified repo +review --thorough # Full review (includes P3-P5 suggestions) +review --summary-only # Output review summary only, no publishing ``` -## 三阶段工作流 +## Three-Phase Workflow ``` -阶段 0: 识别 PR → 阶段 1: 拉取 diff + 上下文 → 阶段 2: 逐行 inline 评论 → 阶段 3: 提交审查 +Phase 0: Identify PR → Phase 1: Pull diff + context → Phase 2: Line-by-line inline comments → Phase 3: Submit review ``` -审查预览会完整展示每条评论的内容、代码上下文,用户确认后才发布到 GitHub。 +The review preview displays the full content and code context of each comment. Publishing to GitHub only occurs after user confirmation. -## 与现有审查技能的区别 +## Comparison with Existing Review Skills -| 特性 | github-pr-reviewer | code-review | pr-review-toolkit | -|------|-------------------|-------------|-------------------| -| inline 评论(add_comment_to_pending_review) | ✅ | ❌ | ❌ | -| 完整 pending review 生命周期 | ✅ | ❌ | ❌ | -| 用户审核后发布 | ✅ | ❌ | ❌ | -| 审查模型标注 | ✅ | ❌ | ❌ | -| diff 代码上下文展示 | ✅ | 部分 | 部分 | +| Feature | github-pr-reviewer | code-review | pr-review-toolkit | +|---------|-------------------|-------------|-------------------| +| Inline comments (add_comment_to_pending_review) | ✅ | ❌ | ❌ | +| Full pending review lifecycle | ✅ | ❌ | ❌ | +| User review before publishing | ✅ | ❌ | ❌ | +| Review model annotation | ✅ | ❌ | ❌ | +| Diff code context display | ✅ | Partial | Partial | diff --git a/docs/quick-plugin-installer.cn.md b/docs/quick-plugin-installer.cn.md new file mode 100644 index 0000000..34db081 --- /dev/null +++ b/docs/quick-plugin-installer.cn.md @@ -0,0 +1,40 @@ +# quick-plugin-installer + +快速安装插件 — 统一入口,一键完成 Claude Code 插件(MCP Server 和 SKILL 插件)的发现、注册、安装、自动升级配置。 + +## 核心功能 + +- 自动识别插件类型(MCP Server vs SKILL 插件 vs 本地目录) +- 已有安装检测 → 交互式操作(重装/更新/卸载/查看/跳过) +- Marketplace 注册 + 安装 + 自动升级配置 +- MCP Server 配置生成、写入、接入验证 +- MCP 更新检查脚本(npm/本地命令) +- 16 个 MCP 配置模板(GitHub/Context7/Playwright/Postgres/Jira/Slack...) +- 跨平台兼容(Linux/macOS/Windows Git Bash) + +## 六步工作流 + +| 步骤 | 说明 | +|------|------| +| 1. 识别类型 | MCP / SKILL / 本地,无法判断时交互询问 | +| 2. 已有检测 | 检查是否已安装,询问下一步操作 | +| 3. SKILL 安装 | Marketplace 注册 → 安装 → autoUpdate | +| 4. MCP 安装 | 收集配置 → 写入 settings.json → 验证 | +| 5. 输出摘要 | 格式化展示安装结果 | +| 6. 快速模板 | 16 个常用 MCP Server 一键配置 | + +## 前置依赖 + +- `gh` (GitHub CLI) +- `jq` +- `claude` CLI + +## 相关技能 + +本技能属于 [minecraft269-skills](https://github.com/Minecraft269/skills) 插件包。当完整安装插件包时,本技能可与其他包内技能自动联动: + +- 安装完成后自动提示运行技能发现 +- 被主动技能发现引擎引导,安装用户选择的缺失能力 + +独立安装本技能时,上述联动功能静默关闭,不影响核心安装功能。 + diff --git a/docs/quick-plugin-installer.md b/docs/quick-plugin-installer.md index 34db081..eb35584 100644 --- a/docs/quick-plugin-installer.md +++ b/docs/quick-plugin-installer.md @@ -1,40 +1,39 @@ # quick-plugin-installer -快速安装插件 — 统一入口,一键完成 Claude Code 插件(MCP Server 和 SKILL 插件)的发现、注册、安装、自动升级配置。 +Quick plugin installer — a unified entry point for one-click discovery, registration, installation, and auto-update configuration of Claude Code plugins (MCP Server and SKILL plugins). -## 核心功能 +## Core Features -- 自动识别插件类型(MCP Server vs SKILL 插件 vs 本地目录) -- 已有安装检测 → 交互式操作(重装/更新/卸载/查看/跳过) -- Marketplace 注册 + 安装 + 自动升级配置 -- MCP Server 配置生成、写入、接入验证 -- MCP 更新检查脚本(npm/本地命令) -- 16 个 MCP 配置模板(GitHub/Context7/Playwright/Postgres/Jira/Slack...) -- 跨平台兼容(Linux/macOS/Windows Git Bash) +- Automatic plugin type detection (MCP Server vs SKILL plugin vs local directory) +- Existing installation detection → interactive actions (reinstall/update/uninstall/view/skip) +- Marketplace registration + installation + auto-update configuration +- MCP Server config generation, writing, and connectivity verification +- MCP update check script (npm/local commands) +- 16 MCP configuration templates (GitHub/Context7/Playwright/Postgres/Jira/Slack...) +- Cross-platform compatibility (Linux/macOS/Windows Git Bash) -## 六步工作流 +## Six-Step Workflow -| 步骤 | 说明 | -|------|------| -| 1. 识别类型 | MCP / SKILL / 本地,无法判断时交互询问 | -| 2. 已有检测 | 检查是否已安装,询问下一步操作 | -| 3. SKILL 安装 | Marketplace 注册 → 安装 → autoUpdate | -| 4. MCP 安装 | 收集配置 → 写入 settings.json → 验证 | -| 5. 输出摘要 | 格式化展示安装结果 | -| 6. 快速模板 | 16 个常用 MCP Server 一键配置 | +| Step | Description | +|------|-------------| +| 1. Identify Type | MCP / SKILL / Local; ask interactively when uncertain | +| 2. Existing Check | Check if already installed, ask for next action | +| 3. SKILL Install | Marketplace register → install → autoUpdate | +| 4. MCP Install | Collect config → write settings.json → verify | +| 5. Output Summary | Display installation results in a formatted view | +| 6. Quick Templates | 16 common MCP Server one-click configurations | -## 前置依赖 +## Prerequisites - `gh` (GitHub CLI) - `jq` - `claude` CLI -## 相关技能 +## Related Skills -本技能属于 [minecraft269-skills](https://github.com/Minecraft269/skills) 插件包。当完整安装插件包时,本技能可与其他包内技能自动联动: +This skill is part of the [minecraft269-skills](https://github.com/Minecraft269/skills) plugin package. When the full package is installed, this skill can auto-link with other package skills: -- 安装完成后自动提示运行技能发现 -- 被主动技能发现引擎引导,安装用户选择的缺失能力 - -独立安装本技能时,上述联动功能静默关闭,不影响核心安装功能。 +- After installation, automatically suggests running skill discovery +- Guided by the proactive skill discovery engine to install user-selected missing capabilities +When installed standalone, the above linkage features are silently disabled, with no impact on core installation functionality. diff --git a/docs/universal-project-kickoff.cn.md b/docs/universal-project-kickoff.cn.md new file mode 100644 index 0000000..e0659f3 --- /dev/null +++ b/docs/universal-project-kickoff.cn.md @@ -0,0 +1,67 @@ +# universal-project-kickoff + +通用型项目启动与能力发现规则 — 适用于任何类型项目的启动阶段,执行意图探测 + 7 步能力发现 + 强制六步流程。 + +已吸收原 `proactive-skill-discovery` 的全部功能(该技能已删除)。新增 Fork 模式:参与开源贡献(fork → clone → 开发 → PR)。 + +## 核心流程 + +### Step 0:意图探测 +先通过关键词匹配预判用户意图(启动项目/开发功能/审查代码/修复Bug/探索工具),匹配到唯一意图时直接分流;意图不明确时才弹出 AskUserQuestion。分流: + +| 意图 | 行为 | +|------|------| +| 🚀 启动新项目 | Step 0b 语言/框架确认 → 强制六步流程 → 能力发现 | +| 💻 开发新功能 | Step 0c 技术栈确认 → 开发工具推荐 | +| 🔍 审查代码 | Step 0a 5 层追问(本地/远程PR → 目标PR → 在线快速审查/clone本地 → 审查范围 → 模型确认)→ Step 0c 审查工具推荐 | +| 🐛 修复 Bug | Step 0a 目标确认 → Step 0c 调试工具推荐 | +| 🍴 Fork 项目 | Step 0a-fork 5 步子程序(获取仓库 → Fork → Clone → 项目分析 → 贡献引导) | +| 🔧 探索工具 | Step 0c 完整 7 步能力扫描 | + +### Step 0c:7 步能力发现 + +| 子步骤 | 内容 | +|--------|------| +| 0c-1 | 项目指纹扫描(25+ 配置文件 + 语言版本检测 + 移动端框架) | +| 0c-2 | 并行能力清单(先读取 .discovery-rules.json 的 deep_explore_plugins/priority_boost_plugins 配置,再并行三路扫描 Skills + Plugins + Deep Exploration) | +| 0c-3 | 匹配与排序(评分引擎 + Priority Boost 优先加成 + 按意图过滤) | +| 0c-4 | 交互式推荐(5 选项 + 三列表展示 + 联动钩子) | +| 0c-5 | 指令发现(MCP 工具 + Slash 命令,仅在用户选择后触发) | +| 0c-6 | 全量导出(目录/语言/格式 3 询问,Markdown/JSON/纯文本) | +| 0c-7 | 上下文持久化(跳过记录 + 指纹变化重新发现) | + +### 强制六步流程(启动新项目) + +| 步骤 | 内容 | 产出 | +|------|------|------| +| 1 | 澄清"为什么"与"是什么" | 项目一句话定义 + 成功标准 | +| 2 | 圈定边界 | MVP 范围、三重约束 | +| 3 | 快速风险摸底 | Top 3 风险 + B 计划 | +| 4 | 利益相关者对齐 | 核心圈/影响圈/外围圈 | +| 5 | 绘制路线图 | 3-5 个里程碑 + 验收标准 | +| 6 | 生成 CLAUDE.md | 调用 /init 固化成果 | + +## 适用场景 + +- 新项目启动 +- 功能规划 +- AI Agent 设计 +- 项目计划审查 +- 代码审查工具推荐 +- 调试工具推荐 +- 技能/插件/命令探索 +- Fork 开源项目并贡献 PR + +## 核心原则 + +**先开枪,后瞄准,但开枪前得知道靶子大概在哪个方向。** 15 分钟内完成关键决策,避免返工。 + +## 相关技能 + +本技能属于 [minecraft269-skills](https://github.com/Minecraft269/skills) 插件包。当完整安装插件包时,本技能可与其他包内技能自动联动: + +- 识别技术栈后提示安装相关 MCP Server +- CLAUDE.md 生成后提示扫描技术栈推荐匹配技能 +- 被 PR 管理器在克隆陌生项目后触发,帮助新贡献者快速理解项目 + +独立安装本技能时,上述联动功能静默关闭,不影响核心流程。 diff --git a/docs/universal-project-kickoff.md b/docs/universal-project-kickoff.md index e0659f3..0d98a17 100644 --- a/docs/universal-project-kickoff.md +++ b/docs/universal-project-kickoff.md @@ -1,67 +1,67 @@ # universal-project-kickoff -通用型项目启动与能力发现规则 — 适用于任何类型项目的启动阶段,执行意图探测 + 7 步能力发现 + 强制六步流程。 +Universal project kickoff and capability discovery rules — suitable for any project type's startup phase, executing intent detection + 7-step capability discovery + mandatory 6-step process. -已吸收原 `proactive-skill-discovery` 的全部功能(该技能已删除)。新增 Fork 模式:参与开源贡献(fork → clone → 开发 → PR)。 +Has absorbed all functionality of the former `proactive-skill-discovery` (that skill has been deleted). New Fork mode: participate in open-source contributions (fork → clone → develop → PR). -## 核心流程 +## Core Flow -### Step 0:意图探测 -先通过关键词匹配预判用户意图(启动项目/开发功能/审查代码/修复Bug/探索工具),匹配到唯一意图时直接分流;意图不明确时才弹出 AskUserQuestion。分流: +### Step 0: Intent Detection +First pre-detect user intent via keyword matching (start project/develop feature/review code/fix bug/explore tools). If a unique intent matches, route directly; only show AskUserQuestion when intent is ambiguous. Routing: -| 意图 | 行为 | -|------|------| -| 🚀 启动新项目 | Step 0b 语言/框架确认 → 强制六步流程 → 能力发现 | -| 💻 开发新功能 | Step 0c 技术栈确认 → 开发工具推荐 | -| 🔍 审查代码 | Step 0a 5 层追问(本地/远程PR → 目标PR → 在线快速审查/clone本地 → 审查范围 → 模型确认)→ Step 0c 审查工具推荐 | -| 🐛 修复 Bug | Step 0a 目标确认 → Step 0c 调试工具推荐 | -| 🍴 Fork 项目 | Step 0a-fork 5 步子程序(获取仓库 → Fork → Clone → 项目分析 → 贡献引导) | -| 🔧 探索工具 | Step 0c 完整 7 步能力扫描 | +| Intent | Behavior | +|--------|----------| +| 🚀 Start New Project | Step 0b language/framework confirmation → mandatory 6-step process → capability discovery | +| 💻 Develop Feature | Step 0c tech stack confirmation → dev tool recommendations | +| 🔍 Review Code | Step 0a 5-layer follow-up → Step 0c review tool recommendations | +| 🐛 Fix Bug | Step 0a target confirmation → Step 0c debugging tool recommendations | +| 🍴 Fork Project | Step 0a-fork 5 sub-steps (get repo → fork → clone → project analysis → contribution guidance) | +| 🔧 Explore Tools | Step 0c full 7-step capability scan | -### Step 0c:7 步能力发现 +### Step 0c: 7-Step Capability Discovery -| 子步骤 | 内容 | -|--------|------| -| 0c-1 | 项目指纹扫描(25+ 配置文件 + 语言版本检测 + 移动端框架) | -| 0c-2 | 并行能力清单(先读取 .discovery-rules.json 的 deep_explore_plugins/priority_boost_plugins 配置,再并行三路扫描 Skills + Plugins + Deep Exploration) | -| 0c-3 | 匹配与排序(评分引擎 + Priority Boost 优先加成 + 按意图过滤) | -| 0c-4 | 交互式推荐(5 选项 + 三列表展示 + 联动钩子) | -| 0c-5 | 指令发现(MCP 工具 + Slash 命令,仅在用户选择后触发) | -| 0c-6 | 全量导出(目录/语言/格式 3 询问,Markdown/JSON/纯文本) | -| 0c-7 | 上下文持久化(跳过记录 + 指纹变化重新发现) | +| Sub-step | Content | +|----------|---------| +| 0c-1 | Project fingerprint scan (25+ config files + language version detection + mobile frameworks) | +| 0c-2 | Parallel capability inventory (read .discovery-rules.json config, then 3-way parallel scan: Skills + Plugins + Deep Exploration) | +| 0c-3 | Match and rank (scoring engine + Priority Boost bonus + intent-based filtering) | +| 0c-4 | Interactive recommendation (5 options + 3-column display + linkage hooks) | +| 0c-5 | Command discovery (MCP tools + Slash commands, triggered only on user selection) | +| 0c-6 | Full export (3 questions: directory/language/format, Markdown/JSON/plain text) | +| 0c-7 | Context persistence (skip recording + fingerprint-change re-discovery) | -### 强制六步流程(启动新项目) +### Mandatory 6-Step Process (Starting New Projects) -| 步骤 | 内容 | 产出 | -|------|------|------| -| 1 | 澄清"为什么"与"是什么" | 项目一句话定义 + 成功标准 | -| 2 | 圈定边界 | MVP 范围、三重约束 | -| 3 | 快速风险摸底 | Top 3 风险 + B 计划 | -| 4 | 利益相关者对齐 | 核心圈/影响圈/外围圈 | -| 5 | 绘制路线图 | 3-5 个里程碑 + 验收标准 | -| 6 | 生成 CLAUDE.md | 调用 /init 固化成果 | +| Step | Content | Output | +|------|---------|--------| +| 1 | Clarify "why" and "what" | One-sentence project definition + success criteria | +| 2 | Define boundaries | MVP scope, triple constraint | +| 3 | Quick risk assessment | Top 3 risks + Plan B | +| 4 | Stakeholder alignment | Core circle / influence circle / periphery circle | +| 5 | Draw roadmap | 3-5 milestones + acceptance criteria | +| 6 | Generate CLAUDE.md | Call /init to persist outcomes | -## 适用场景 +## Use Cases -- 新项目启动 -- 功能规划 -- AI Agent 设计 -- 项目计划审查 -- 代码审查工具推荐 -- 调试工具推荐 -- 技能/插件/命令探索 -- Fork 开源项目并贡献 PR +- New project startup +- Feature planning +- AI Agent design +- Project plan review +- Code review tool recommendations +- Debugging tool recommendations +- Skill/plugin/command exploration +- Fork open-source projects and contribute PRs -## 核心原则 +## Core Principle -**先开枪,后瞄准,但开枪前得知道靶子大概在哪个方向。** 15 分钟内完成关键决策,避免返工。 +**Fire first, aim later — but before you fire, at least know which direction the target is in.** Complete critical decisions within 15 minutes to avoid rework. -## 相关技能 +## Related Skills -本技能属于 [minecraft269-skills](https://github.com/Minecraft269/skills) 插件包。当完整安装插件包时,本技能可与其他包内技能自动联动: +This skill is part of the [minecraft269-skills](https://github.com/Minecraft269/skills) plugin package. When the full package is installed, this skill can auto-link with other package skills: -- 识别技术栈后提示安装相关 MCP Server -- CLAUDE.md 生成后提示扫描技术栈推荐匹配技能 -- 被 PR 管理器在克隆陌生项目后触发,帮助新贡献者快速理解项目 +- After identifying tech stack, suggests installing relevant MCP Servers +- After CLAUDE.md generation, suggests scanning tech stack for matching skill recommendations +- Triggered by PR Manager after cloning unfamiliar projects, helping new contributors quickly understand the project -独立安装本技能时,上述联动功能静默关闭,不影响核心流程。 +When installed standalone, the above linkage features are silently disabled, with no impact on core flow. diff --git a/skills/_shared/check-i18n-sync.sh b/skills/_shared/check-i18n-sync.sh new file mode 100644 index 0000000..d495feb --- /dev/null +++ b/skills/_shared/check-i18n-sync.sh @@ -0,0 +1,132 @@ +#!/usr/bin/env bash +# check-i18n-sync.sh — Structural sync validator for EN/CN skill files +# Usage: bash skills/_shared/check-i18n-sync.sh +# Exit code: 0 = all good, 1 = issues found + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +ISSUES=0 +SKILLS_CHECKED=0 + +echo "=== i18n Sync Check — minecraft269-skills ===" +echo "" + +# Find all English SKILL.md files +for en_file in "$SKILLS_DIR"/*/SKILL.md; do + skill_name=$(basename "$(dirname "$en_file")") + + # Skip _shared (not a skill directory) + [[ "$skill_name" == "_shared" ]] && continue + + cn_file="$SKILLS_DIR/$skill_name/locale/SKILL.cn.md" + + echo "--- $skill_name ---" + + # Check CN copy exists + if [[ ! -f "$cn_file" ]]; then + echo " ❌ MISSING: locale/SKILL.cn.md" + ISSUES=$((ISSUES + 1)) + continue + fi + echo " ✅ CN copy exists" + + # Compare heading structure (count by level — headings differ by language) + en_h2_count=$(grep -c '^## ' "$en_file" || true) + cn_h2_count=$(grep -c '^## ' "$cn_file" || true) + en_h3_count=$(grep -c '^### ' "$en_file" || true) + cn_h3_count=$(grep -c '^### ' "$cn_file" || true) + en_h4_count=$(grep -c '^#### ' "$en_file" || true) + cn_h4_count=$(grep -c '^#### ' "$cn_file" || true) + + h2_ok=true; h3_ok=true; h4_ok=true + [[ "$en_h2_count" != "$cn_h2_count" ]] && h2_ok=false + [[ "$en_h3_count" != "$cn_h3_count" ]] && h3_ok=false + [[ "$en_h4_count" != "$cn_h4_count" ]] && h4_ok=false + + if $h2_ok && $h3_ok && $h4_ok; then + echo " ✅ Heading structure matches (H2:$en_h2_count H3:$en_h3_count H4:$en_h4_count)" + else + echo " ⚠️ Heading structure mismatch: EN(H2:$en_h2_count H3:$en_h3_count H4:$en_h4_count) vs CN(H2:$cn_h2_count H3:$cn_h3_count H4:$cn_h4_count)" + ISSUES=$((ISSUES + 1)) + fi + + # Compare YAML frontmatter key count (should match) + en_fm_keys=$(sed -n '/^---$/,/^---$/p' "$en_file" | grep -oP '^\w+:' | tr -d ':' | grep -v '^---$' | sort) + cn_fm_keys=$(sed -n '/^---$/,/^---$/p' "$cn_file" | grep -oP '^\w+:' | tr -d ':' | grep -v '^---$' | sort) + + # Check for keys in EN missing from CN (excluding 'locale') + while IFS= read -r key; do + if ! grep -qFx "$key" <<< "$cn_fm_keys"; then + echo " ⚠️ Frontmatter key missing in CN: '$key'" + ISSUES=$((ISSUES + 1)) + fi + done <<< "$en_fm_keys" + + # Check for keys in CN missing from EN (excluding 'locale') + while IFS= read -r key; do + [[ "$key" == "locale" ]] && continue + if ! grep -qFx "$key" <<< "$en_fm_keys"; then + echo " ⚠️ Frontmatter key missing in EN: '$key'" + ISSUES=$((ISSUES + 1)) + fi + done <<< "$cn_fm_keys" + + # Compare code block count + en_blocks=$(grep -c '```' "$en_file" || true) + cn_blocks=$(grep -c '```' "$cn_file" || true) + if [[ "$en_blocks" != "$cn_blocks" ]]; then + echo " ⚠️ Code block count mismatch: EN=$en_blocks, CN=$cn_blocks" + ISSUES=$((ISSUES + 1)) + else + echo " ✅ Code blocks match ($en_blocks triple-backticks)" + fi + + # Check line count variance (±10%) + en_lines=$(wc -l < "$en_file") + cn_lines=$(wc -l < "$cn_file") + diff_abs=$(( en_lines - cn_lines )) + if [[ $diff_abs -lt 0 ]]; then diff_abs=$(( -diff_abs )); fi + threshold=$(( (en_lines + cn_lines) / 20 + 5 )) + if [[ $diff_abs -gt $threshold ]]; then + echo " ⚠️ Line count variance >5%: EN=$en_lines, CN=$cn_lines" + ISSUES=$((ISSUES + 1)) + else + echo " ✅ Line count within range: EN=$en_lines, CN=$cn_lines" + fi + + SKILLS_CHECKED=$((SKILLS_CHECKED + 1)) + echo "" +done + +# Check docs CN copies exist +echo "--- docs/ ---" +DOCS_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)/docs" +for doc in "$DOCS_DIR"/*.md; do + doc_name=$(basename "$doc") + # Skip CN copies themselves + [[ "$doc_name" == *.cn.md ]] && continue + cn_doc="$DOCS_DIR/${doc_name%.md}.cn.md" + if [[ ! -f "$cn_doc" ]]; then + echo " ❌ MISSING: docs/$doc_name → ${doc_name%.md}.cn.md" + ISSUES=$((ISSUES + 1)) + else + echo " ✅ docs/$doc_name ↔ docs/${doc_name%.md}.cn.md" + fi +done + +echo "" +echo "=== Summary ===" +echo "Skills checked: $SKILLS_CHECKED" +echo "Issues found: $ISSUES" + +if [[ $ISSUES -gt 0 ]]; then + echo "" + echo "❌ Sync check FAILED — $ISSUES issue(s) found." + exit 1 +else + echo "" + echo "✅ Sync check PASSED — all files in sync." + exit 0 +fi diff --git a/skills/_shared/i18n-glossary.md b/skills/_shared/i18n-glossary.md new file mode 100644 index 0000000..5ff7b68 --- /dev/null +++ b/skills/_shared/i18n-glossary.md @@ -0,0 +1,119 @@ +# i18n Glossary — minecraft269-skills + +Canonical English-to-Chinese term mappings for skill development. +All SKILL.md files use these translations consistently. + +## Section Headings + +| English (canonical) | 中文(简体) | +|---------------------|-------------| +| Prerequisites | 前置条件 | +| Core Workflow | 核心工作流 | +| Package Linking | 包联动 | +| Error Handling | 错误处理 | +| Command Quick Reference | 命令速查 | +| Scripts | 脚本 | +| References | 参考 | +| Detailed References | 详细参考 | +| Linkage Hooks | 联动钩子 | +| Silent Degradation | 静默降级 | +| Trigger Method | 触发方式 | +| Steps | 步骤 | +| Output | 输出 | +| Preview | 预览 | +| Confirmation | 确认 | +| Core Philosophy | 核心理念 | +| Core Principles | 核心原则 | +| Core Value | 核心价值 | +| Review Focus | 审查焦点 | +| Boundary Conditions | 边界条件 | +| Degradation Mode | 降级模式 | +| Standalone Mode | 独立模式 | +| High-Contact Mode | 高联系模式 | +| Safe Default | 安全默认值 | +| Loop Trigger Protection | 循环触发防护 | +| Usage Flow | 使用流程 | +| Interaction Style | 交互方式 | + +## Workflow Verbs / Actions + +| English | 中文 | +|---------|------| +| Detect staging area | 检测暂存状态 | +| Analyze changes | 分析变更 | +| Generate commit message | 生成提交信息 | +| Preview and confirm | 预览与确认 | +| Execute commit | 执行提交 | +| Set repository | 设定仓库 | +| List PRs | 列出 PR | +| View details | 查看详情 | +| Clone PR | 克隆 PR | +| Batch operations | 批量操作 | +| Identify target PR | 识别目标 PR | +| Gather review context | 获取审查上下文 | +| Analyze diff | 分析 diff | +| Publish inline comments | 发布 inline 评论 | +| Submit review conclusion | 提交审查结论 | +| Detect dependencies | 检测依赖 | +| Check service status | 检测服务状态 | +| Output health report | 输出健康报告 | +| Identify plugin type | 识别插件类型 | +| Install SKILL plugin | 安装 SKILL 插件 | +| Install MCP Server | 安装 MCP Server | +| Intent detection | 意图探测 | +| Language/framework confirmation | 语言/框架确认 | +| Tech stack confirmation | 技术栈确认 | +| Capability discovery | 能力发现 | +| Mandatory 6-step process | 强制六步流程 | + +## Package Detection Patterns + +| English | 中文 | +|---------|------| +| Package Context Detection Protocol | 包上下文检测协议 | +| Runtime Linkage Discovery | 运行时联动发现 | +| Frontmatter Extension Specification | Frontmatter 扩展规范 | +| Linkage Trigger Timing Guide | 联动触发时机指南 | +| Extensibility | 扩展性 | +| Dependency Health Check | 依赖健康检查 | +| Linkage Chain Extension | 联动链扩展 | +| Linkage Discovery Algorithm | 联动发现算法 | +| Tag Matching Examples | 标签匹配示例 | +| Safety default | 安全默认值 | +| Silent degradation on failure | 失败时静默降级 | +| Depth limit | 深度限制 | +| Frequency limit | 频次限制 | + +## Error / Status Messages + +| English | 中文 | +|---------|------| +| No staged changes | 暂存区无变更 | +| Empty staging area | 暂存区为空 | +| gh auth not logged in | gh 未认证登录 | +| settings.json not found | settings.json 不存在 | +| Command not available | 命令不可用 | +| Tool not installed | 工具未安装 | +| Detection timeout | 检测超时 | +| Already installed | 已安装 | +| Not in terminal environment | 不在终端环境 | +| Mark as unconfigured | 标注"未配置" | + +## Technical Identifiers (DO NOT TRANSLATE) + +These remain English in all versions: + +``` +capabilities, integrates_with, PACKAGE_MODE, frontmatter, SKILL.md, +settings.json, plugin.json, marketplace.json, mcpServers, +Conventional Commits, CLI, MCP Server, PR, CI/CD, SemVer, +MVP, kebab-case, snake_case, YAML, JSON, Markdown, glob, +Fork, worktree, ShellCheck, Conventional Commits +``` + +## Tool / Platform Names (DO NOT TRANSLATE) + +``` +git, gh, jq, claude, node, python, python3, winget, brew, apt, +Windows, macOS, Linux, GitHub, Marketplace +``` diff --git a/skills/_shared/locale/package-context.cn.md b/skills/_shared/locale/package-context.cn.md new file mode 100644 index 0000000..697c0ba --- /dev/null +++ b/skills/_shared/locale/package-context.cn.md @@ -0,0 +1,172 @@ +# 包上下文检测协议 + +本文件定义 minecraft269-skills 插件包内所有技能的通用包检测和联动发现协议。 +每个技能在启动时引用本协议,无需修改即可适配未来新增的技能。 + +## 一、PACKAGE_MODE 检测 + +### 检测步骤 + +``` +1. 搜索 ~/.claude/plugins/ 下是否存在含 .claude-plugin/plugin.json 的子目录 +2. 使用 Glob 查找 ~/.claude/plugins/*/.claude-plugin/plugin.json +3. 若找到,Read 该 plugin.json,检查 name 字段 +4. 若 name 为 "minecraft269-skills" → PACKAGE_MODE = true(高联系模式) +5. 否则 → PACKAGE_MODE = false(独立模式) +``` + +### 模式行为差异 + +| 行为 | 高联系模式 (PACKAGE_MODE = true) | 独立模式 (PACKAGE_MODE = false) | +|------|--------------------------------|-------------------------------| +| 技能间引用 | 主动发现并建议兄弟技能联动 | 完全不提及任何兄弟技能 | +| 跨技能命令提示 | 可用 | 静默隐藏 | +| 包级共享资源 | 可加载 `_shared/` 中的资源 | 仅使用本技能内置资源 | +| 动态能力发现 | 扫描兄弟 SKILL.md 的 capabilities 字段 | 跳过扫描 | + +### 安全默认值 + +**独立模式是安全默认值。** 任何检测失败(文件不存在、权限错误、解析失败)都应降级为 PACKAGE_MODE = false,不得报错或中断。 + +## 二、运行时联动发现 + +### 算法 + +当 PACKAGE_MODE = true 且技能执行到关键节点时: + +``` +1. 确定本技能所在的插件包根目录 +2. Glob 扫描 `skills/*/SKILL.md`(**排除自身 SKILL.md**,通过对比 `name` frontmatter 字段实现) +3. 对每个兄弟 SKILL.md,解析 frontmatter 中的 `capabilities` 字段 +4. 将本技能的 `integrates_with` 与兄弟技能的 `capabilities` 做交集匹配 +5. 对匹配到的每个兄弟技能,提取其 `name` 和 `description` +6. 在当前工作流节点生成条件性推荐 + +**自我过滤规则**:技能绝不应通过联动发现推荐自身。在步骤 2 的 Glob 结果中,必须排除 `name` 字段与当前技能 `name` 完全相同的 SKILL.md。 +``` + +### 标签匹配示例 + +``` +本技能 integrates_with: ["skill-discovery", "plugin-installation"] + +兄弟技能 A: capabilities: ["skill-discovery", "project-analysis"] → 匹配 "skill-discovery" ✅ +兄弟技能 B: capabilities: ["pr-management", "ci-analysis"] → 无匹配 ❌ +兄弟技能 C: capabilities: ["plugin-installation", "mcp-setup"] → 匹配 "plugin-installation" ✅ +``` + +结果:推荐兄弟技能 A 和 C。 + +## 三、Frontmatter 扩展规范 + +每个技能可在 SKILL.md frontmatter 中声明以下字段以参与联动: + +```yaml +capabilities: ["<标签>", ...] # 本技能提供的能力 +integrates_with: ["<标签>", ...] # 本技能需要配合的能力类型 +``` + +两个字段均为可选。未声明 `integrates_with` 的技能不会主动发起联动;未声明 `capabilities` 的技能不会被其他技能发现。 + +标签命名约定: +- 使用 `kebab-case`(如 `pr-management`、`skill-discovery`) +- 语义明确,不分词过细 +- 优先复用已有标签(参见 CONTRIBUTING.md 中的标签注册表) + +## 四、联动触发时机指南 + +| integrates_with 标签 | 建议触发时机 | +|----------------------|-------------| +| `skill-discovery` | 当前技能完成主要操作后(安装完成、初始化完成、克隆完成) | +| `project-setup` | 检测到用户首次接触项目(克隆陌生仓库、进入新目录) | +| `plugin-installation` | 发现用户缺少工具/插件/MCP Server | +| `pr-management` | 检测到 GitHub remote 且有活跃开发活动 | +| `code-review` | 完成代码修改后 | +| `testing` | 完成功能实现后 | + +## 五、扩展性 + +当新技能加入包时: +1. 在 SKILL.md frontmatter 声明 `capabilities` 和 `integrates_with` +2. 在 CONTRIBUTING.md 标签注册表中注册新标签(如使用新标签) +3. 在合适的工作流节点插入联动发现步骤 + +**无需修改本文件或其他已有技能。** 运行时发现机制会自动识别新技能。 + +## 六、循环触发防护 + +为防止技能联动形成无限循环,所有技能必须遵循以下规则: + +### 防护规则 + +1. **上下文标记**:每次触发联动后,在对话上下文中记录 `_LINKED_FROM: ["<触发技能名>"]` 标记 +2. **循环检测**:执行联动前检查标记 — 如果标记中存在当前技能名,跳过该次联动 +3. **深度限制**:联动链深度不超过 2 层(直接联动 + 二级联动),超过则截断 +4. **频次限制**:同一技能在单次会话中最多触发 3 次联动,达到上限后静默跳过 + +### 实现提示 + +``` +触发联动前: + 1. 检查 _LINKED_CHAIN 深度计数器 (初始 0) + 2. 若深度 >= 2 → 跳过,不触发联动 + 3. 检查 _TRIGGERED_SKILLS 频次记录 + 4. 若本技能已触发 >= 3 次 → 跳过 + 5. 执行联动,深度 +1,频次 +1 + +完成后: + 6. 深度 -1(退出当前联动层级) +``` + +### 示例 + +``` +github-pr-manager 克隆 PR → 触发联动 → universal-project-kickoff (深度 1) + → 初始化 + 能力推荐完成 → 触发联动 → quick-plugin-installer (深度 2) + → 安装完成 → 触发联动 → 深度已达上限,跳过 +``` + +## 七、依赖健康检查 + +为确保 PACKAGE_MODE 联动发现能正常工作,建议在首次加载 package-context.md 时执行轻量级健康检查: + +### 检查步骤 + +1. Glob 扫描 `skills/*/SKILL.md` 获取所有技能 +2. 验证每个 SKILL.md 的 frontmatter 可解析(至少包含 `name` 字段) +3. 若任何 SKILL.md 的 frontmatter 格式错误,记录警告但不中断 +4. 对比 `capabilities` 标签与 CONTRIBUTING.md 中的标签注册表 +5. 若发现未注册标签,提示开发者更新注册表 + +### 降级策略 + +如果健康检查发现任何声明 `capabilities: ["skill-discovery"]` 的技能的 SKILL.md 格式异常(该能力被多个技能依赖),其他技能应: +- 静默跳过 `skill-discovery` 联动(不报错) +- 继续执行自身核心功能 +- 在首次遇到需要联动的节点时给出一次性提示:"部分技能联动暂不可用" + +## 八、联动链扩展 + +联动可以链式传播,但遵循层级限制: + +| 联动层级 | 描述 | 是否允许 | +|---------|------|---------| +| 一级联动 | 技能 A 完成 → 推荐技能 B | ✅ 允许 | +| 二级联动 | 技能 B 完成 → 推荐技能 C | ✅ 允许 | +| 三级及以上 | 技能 C 完成 → 推荐技能 D | ❌ 禁止(截断) | + +### 典型联动链示例 + +``` +1. github-pr-manager 克隆陌生项目 PR + → 一级联动: 推荐 universal-project-kickoff 初始化项目 + +2. universal-project-kickoff 完成 CLAUDE.md 生成 + 能力推荐 + → 二级联动: 推荐 quick-plugin-installer 安装缺失工具 + +3. quick-plugin-installer 安装完成后 + → 三级联动: 应再次推荐能力发现 → ❌ 截断 + → 替代方案: 在二级联动结果中一次性列出所有后续建议 +``` + +三级及以上联动应被替换为"一次性建议列表":在二级联动的结果中,将所有可能需要的后续操作以列表形式呈现,而非链式触发。 diff --git a/skills/_shared/package-context.md b/skills/_shared/package-context.md index 697c0ba..e87b356 100644 --- a/skills/_shared/package-context.md +++ b/skills/_shared/package-context.md @@ -1,172 +1,172 @@ -# 包上下文检测协议 +# Package Context Detection Protocol -本文件定义 minecraft269-skills 插件包内所有技能的通用包检测和联动发现协议。 -每个技能在启动时引用本协议,无需修改即可适配未来新增的技能。 +This document defines the common package detection and Package Linking discovery protocol shared by all skills within the minecraft269-skills plugin bundle. +Every skill references this protocol at startup and adapts to newly added skills without modification. -## 一、PACKAGE_MODE 检测 +## 1. PACKAGE_MODE Detection -### 检测步骤 +### Detection Steps ``` -1. 搜索 ~/.claude/plugins/ 下是否存在含 .claude-plugin/plugin.json 的子目录 -2. 使用 Glob 查找 ~/.claude/plugins/*/.claude-plugin/plugin.json -3. 若找到,Read 该 plugin.json,检查 name 字段 -4. 若 name 为 "minecraft269-skills" → PACKAGE_MODE = true(高联系模式) -5. 否则 → PACKAGE_MODE = false(独立模式) +1. Search ~/.claude/plugins/ for subdirectories containing .claude-plugin/plugin.json +2. Use Glob to lookup ~/.claude/plugins/*/.claude-plugin/plugin.json +3. If found, Read that plugin.json and inspect the name field +4. If name is "minecraft269-skills" → PACKAGE_MODE = true (High-Contact Mode) +5. Otherwise → PACKAGE_MODE = false (Standalone Mode) ``` -### 模式行为差异 +### Behavioral Differences by Mode -| 行为 | 高联系模式 (PACKAGE_MODE = true) | 独立模式 (PACKAGE_MODE = false) | -|------|--------------------------------|-------------------------------| -| 技能间引用 | 主动发现并建议兄弟技能联动 | 完全不提及任何兄弟技能 | -| 跨技能命令提示 | 可用 | 静默隐藏 | -| 包级共享资源 | 可加载 `_shared/` 中的资源 | 仅使用本技能内置资源 | -| 动态能力发现 | 扫描兄弟 SKILL.md 的 capabilities 字段 | 跳过扫描 | +| Behavior | High-Contact Mode (PACKAGE_MODE = true) | Standalone Mode (PACKAGE_MODE = false) | +|----------|----------------------------------------|----------------------------------------| +| Cross-skill references | Actively discovers and suggests sibling skill linking | Never mentions any sibling skill | +| Cross-skill command hints | Available | Silently hidden | +| Package-level shared resources | May load resources from `_shared/` | Uses only built-in skill resources | +| Dynamic capability discovery | Scans sibling SKILL.md `capabilities` fields | Skips scanning | -### 安全默认值 +### Safe Default -**独立模式是安全默认值。** 任何检测失败(文件不存在、权限错误、解析失败)都应降级为 PACKAGE_MODE = false,不得报错或中断。 +**Standalone Mode is the safe default.** Any detection failure (file not found, permission error, parse failure) must degrade to PACKAGE_MODE = false without error or interruption. -## 二、运行时联动发现 +## 2. Runtime Package Linking Discovery -### 算法 +### Algorithm -当 PACKAGE_MODE = true 且技能执行到关键节点时: +When PACKAGE_MODE = true and a skill reaches a key decision point: ``` -1. 确定本技能所在的插件包根目录 -2. Glob 扫描 `skills/*/SKILL.md`(**排除自身 SKILL.md**,通过对比 `name` frontmatter 字段实现) -3. 对每个兄弟 SKILL.md,解析 frontmatter 中的 `capabilities` 字段 -4. 将本技能的 `integrates_with` 与兄弟技能的 `capabilities` 做交集匹配 -5. 对匹配到的每个兄弟技能,提取其 `name` 和 `description` -6. 在当前工作流节点生成条件性推荐 - -**自我过滤规则**:技能绝不应通过联动发现推荐自身。在步骤 2 的 Glob 结果中,必须排除 `name` 字段与当前技能 `name` 完全相同的 SKILL.md。 +1. Determine the current skill's plugin bundle root directory +2. Glob scan `skills/*/SKILL.md` (**excluding the skill's own SKILL.md** by comparing the `name` frontmatter field) +3. For each sibling SKILL.md, parse the `capabilities` field from its frontmatter +4. Compute the intersection of the current skill's `integrates_with` with each sibling's `capabilities` +5. For every matched sibling skill, extract its `name` and `description` +6. Generate conditional recommendations at the current workflow node + +**Self-filtering rule**: A skill must never recommend itself through Package Linking discovery. In step 2's Glob results, any SKILL.md whose `name` field exactly matches the current skill's `name` must be excluded. ``` -### 标签匹配示例 +### Tag Matching Example ``` -本技能 integrates_with: ["skill-discovery", "plugin-installation"] +Current skill integrates_with: ["skill-discovery", "plugin-installation"] -兄弟技能 A: capabilities: ["skill-discovery", "project-analysis"] → 匹配 "skill-discovery" ✅ -兄弟技能 B: capabilities: ["pr-management", "ci-analysis"] → 无匹配 ❌ -兄弟技能 C: capabilities: ["plugin-installation", "mcp-setup"] → 匹配 "plugin-installation" ✅ +Sibling A: capabilities: ["skill-discovery", "project-analysis"] → matches "skill-discovery" ✅ +Sibling B: capabilities: ["pr-management", "ci-analysis"] → no match ❌ +Sibling C: capabilities: ["plugin-installation", "mcp-setup"] → matches "plugin-installation" ✅ ``` -结果:推荐兄弟技能 A 和 C。 +Result: recommend sibling skills A and C. -## 三、Frontmatter 扩展规范 +## 3. Frontmatter Extension Specification -每个技能可在 SKILL.md frontmatter 中声明以下字段以参与联动: +Each skill may declare the following fields in its SKILL.md frontmatter to participate in Package Linking: ```yaml -capabilities: ["<标签>", ...] # 本技能提供的能力 -integrates_with: ["<标签>", ...] # 本技能需要配合的能力类型 +capabilities: ["", ...] # Abilities this skill provides +integrates_with: ["", ...] # Types of capabilities this skill needs to pair with ``` -两个字段均为可选。未声明 `integrates_with` 的技能不会主动发起联动;未声明 `capabilities` 的技能不会被其他技能发现。 +Both fields are optional. Skills that do not declare `integrates_with` will not initiate Package Linking. Skills that do not declare `capabilities` will not be discovered by other skills. -标签命名约定: -- 使用 `kebab-case`(如 `pr-management`、`skill-discovery`) -- 语义明确,不分词过细 -- 优先复用已有标签(参见 CONTRIBUTING.md 中的标签注册表) +Tag naming conventions: +- Use `kebab-case` (e.g., `pr-management`, `skill-discovery`) +- Keep semantics clear without over-splitting terms +- Prefer reusing existing tags (see the tag registry in CONTRIBUTING.md) -## 四、联动触发时机指南 +## 4. Package Linking Trigger Timing Guide -| integrates_with 标签 | 建议触发时机 | -|----------------------|-------------| -| `skill-discovery` | 当前技能完成主要操作后(安装完成、初始化完成、克隆完成) | -| `project-setup` | 检测到用户首次接触项目(克隆陌生仓库、进入新目录) | -| `plugin-installation` | 发现用户缺少工具/插件/MCP Server | -| `pr-management` | 检测到 GitHub remote 且有活跃开发活动 | -| `code-review` | 完成代码修改后 | -| `testing` | 完成功能实现后 | +| integrates_with tag | Suggested trigger timing | +|--------------------|--------------------------| +| `skill-discovery` | After the current skill completes its main operation (installation done, initialization done, clone done) | +| `project-setup` | When the user first interacts with a project (cloning an unfamiliar repository, entering a new directory) | +| `plugin-installation` | When the user is found to be missing a tool, plugin, or MCP Server | +| `pr-management` | When a GitHub remote is detected with active development activity | +| `code-review` | After completing code modifications | +| `testing` | After completing feature implementation | -## 五、扩展性 +## 5. Extensibility -当新技能加入包时: -1. 在 SKILL.md frontmatter 声明 `capabilities` 和 `integrates_with` -2. 在 CONTRIBUTING.md 标签注册表中注册新标签(如使用新标签) -3. 在合适的工作流节点插入联动发现步骤 +When a new skill joins the bundle: +1. Declare `capabilities` and `integrates_with` in the SKILL.md frontmatter +2. Register new tags in the CONTRIBUTING.md tag registry (if using new tags) +3. Insert Package Linking discovery steps at appropriate workflow nodes -**无需修改本文件或其他已有技能。** 运行时发现机制会自动识别新技能。 +**No modifications to this file or other existing skills are required.** The runtime discovery mechanism automatically recognizes new skills. -## 六、循环触发防护 +## 6. Loop Trigger Protection -为防止技能联动形成无限循环,所有技能必须遵循以下规则: +To prevent Package Linking from forming infinite loops, all skills must follow these rules: -### 防护规则 +### Protection Rules -1. **上下文标记**:每次触发联动后,在对话上下文中记录 `_LINKED_FROM: ["<触发技能名>"]` 标记 -2. **循环检测**:执行联动前检查标记 — 如果标记中存在当前技能名,跳过该次联动 -3. **深度限制**:联动链深度不超过 2 层(直接联动 + 二级联动),超过则截断 -4. **频次限制**:同一技能在单次会话中最多触发 3 次联动,达到上限后静默跳过 +1. **Context marker**: After each Package Linking trigger, record a `_LINKED_FROM: [""]` marker in the conversation context +2. **Loop detection**: Before executing a Package Linking, check the marker -- if the current skill name is already present, skip that linkage +3. **Depth limit**: Package Linking chain depth must not exceed 2 levels (direct + one level of indirection); anything beyond is truncated +4. **Frequency limit**: The same skill may trigger Package Linking at most 3 times in a single session; once the limit is reached, silently skip -### 实现提示 +### Implementation Hints ``` -触发联动前: - 1. 检查 _LINKED_CHAIN 深度计数器 (初始 0) - 2. 若深度 >= 2 → 跳过,不触发联动 - 3. 检查 _TRIGGERED_SKILLS 频次记录 - 4. 若本技能已触发 >= 3 次 → 跳过 - 5. 执行联动,深度 +1,频次 +1 - -完成后: - 6. 深度 -1(退出当前联动层级) +Before triggering Package Linking: + 1. Check the _LINKED_CHAIN depth counter (initial 0) + 2. If depth >= 2 → skip, do not trigger Package Linking + 3. Check _TRIGGERED_SKILLS frequency record + 4. If this skill has already triggered >= 3 times → skip + 5. Execute Package Linking, depth +1, frequency +1 + +After completion: + 6. depth -1 (exit current Package Linking level) ``` -### 示例 +### Example ``` -github-pr-manager 克隆 PR → 触发联动 → universal-project-kickoff (深度 1) - → 初始化 + 能力推荐完成 → 触发联动 → quick-plugin-installer (深度 2) - → 安装完成 → 触发联动 → 深度已达上限,跳过 +github-pr-manager clones a PR → triggers Package Linking → universal-project-kickoff (depth 1) + → Initialization + capability recommendation complete → triggers Package Linking → quick-plugin-installer (depth 2) + → Installation complete → triggers Package Linking → depth limit reached, skip ``` -## 七、依赖健康检查 +## 7. Dependency Health Check -为确保 PACKAGE_MODE 联动发现能正常工作,建议在首次加载 package-context.md 时执行轻量级健康检查: +To ensure PACKAGE_MODE Package Linking discovery works correctly, a lightweight health check should be performed on first load of package-context.md: -### 检查步骤 +### Check Steps -1. Glob 扫描 `skills/*/SKILL.md` 获取所有技能 -2. 验证每个 SKILL.md 的 frontmatter 可解析(至少包含 `name` 字段) -3. 若任何 SKILL.md 的 frontmatter 格式错误,记录警告但不中断 -4. 对比 `capabilities` 标签与 CONTRIBUTING.md 中的标签注册表 -5. 若发现未注册标签,提示开发者更新注册表 +1. Glob scan `skills/*/SKILL.md` to list all skills +2. Verify each SKILL.md's frontmatter is parseable (at minimum contains a `name` field) +3. If any SKILL.md has malformed frontmatter, log a warning but do not abort +4. Compare `capabilities` tags against the tag registry in CONTRIBUTING.md +5. If unregistered tags are found, prompt the developer to update the registry -### 降级策略 +### Degradation Strategy -如果健康检查发现任何声明 `capabilities: ["skill-discovery"]` 的技能的 SKILL.md 格式异常(该能力被多个技能依赖),其他技能应: -- 静默跳过 `skill-discovery` 联动(不报错) -- 继续执行自身核心功能 -- 在首次遇到需要联动的节点时给出一次性提示:"部分技能联动暂不可用" +If the health check finds a malformed SKILL.md for any skill declaring `capabilities: ["skill-discovery"]` (a capability relied upon by multiple skills), other skills should: +- Silently skip `skill-discovery` Package Linking (no error) +- Continue executing their own core functionality +- Issue a one-time hint on first encountering a node that needs linking: "Some skill linking is temporarily unavailable" -## 八、联动链扩展 +## 8. Package Linking Chain Extension -联动可以链式传播,但遵循层级限制: +Package Linking may propagate in chains, but respects the following depth limits: -| 联动层级 | 描述 | 是否允许 | -|---------|------|---------| -| 一级联动 | 技能 A 完成 → 推荐技能 B | ✅ 允许 | -| 二级联动 | 技能 B 完成 → 推荐技能 C | ✅ 允许 | -| 三级及以上 | 技能 C 完成 → 推荐技能 D | ❌ 禁止(截断) | +| Linking level | Description | Allowed? | +|---------------|-------------|----------| +| First level | Skill A completes → recommends skill B | ✅ Allowed | +| Second level | Skill B completes → recommends skill C | ✅ Allowed | +| Third level+ | Skill C completes → recommends skill D | ❌ Forbidden (truncated) | -### 典型联动链示例 +### Typical Linking Chain Example ``` -1. github-pr-manager 克隆陌生项目 PR - → 一级联动: 推荐 universal-project-kickoff 初始化项目 +1. github-pr-manager clones an unfamiliar project PR + → First-level linking: recommend universal-project-kickoff to initialize project -2. universal-project-kickoff 完成 CLAUDE.md 生成 + 能力推荐 - → 二级联动: 推荐 quick-plugin-installer 安装缺失工具 +2. universal-project-kickoff completes CLAUDE.md generation + capability recommendation + → Second-level linking: recommend quick-plugin-installer to install missing tools -3. quick-plugin-installer 安装完成后 - → 三级联动: 应再次推荐能力发现 → ❌ 截断 - → 替代方案: 在二级联动结果中一次性列出所有后续建议 +3. quick-plugin-installer completes installation + → Third-level linking: would recommend capability discovery again → ❌ truncated + → Alternative: present all follow-up suggestions as a single list within the second-level linking result ``` -三级及以上联动应被替换为"一次性建议列表":在二级联动的结果中,将所有可能需要的后续操作以列表形式呈现,而非链式触发。 +Third-level linking and beyond should be replaced with a "single-shot suggestion list": within the second-level linking result, present all possible follow-up operations as a list rather than triggering chained recommendations. diff --git a/skills/env-health-check/SKILL.md b/skills/env-health-check/SKILL.md index 120c7ff..73e44a0 100644 --- a/skills/env-health-check/SKILL.md +++ b/skills/env-health-check/SKILL.md @@ -1,119 +1,120 @@ --- name: env-health-check description: > - 跨平台环境自检工具 — 检测 git、gh、jq、claude 等核心依赖的可用性、版本和认证状态, - 扫描 MCP Server 配置完整性。当你首次安装插件包后、遇到"命令不可用"错误、 - 或想确认开发环境是否就绪时使用此技能。 + Cross-platform environment health check tool — detects the availability, version, and auth status + of core dependencies such as git, gh, jq, and claude, and scans MCP Server configuration integrity. + Use this skill after first installing the plugin package, when encountering "command not available" errors, + or when you want to confirm whether the development environment is ready. capabilities: ["env-check"] integrates_with: ["skill-discovery", "plugin-installation"] metadata: - compatibility: "跨平台(Windows/macOS/Linux)" + compatibility: "Cross-platform (Windows/macOS/Linux)" --- -# 环境健康自检 +# Environment Health Check -跨平台检测 Claude Code 及常用工具链的可用性,输出格式化健康报告。纯 AI 驱动,无需额外依赖。 +Cross-platform detection of Claude Code and common toolchain availability, outputting a formatted health report. Purely AI-driven, no additional dependencies required. -## 包联动 +## Package Linking -1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` -2. 若找到 → `PACKAGE_MODE = true`,可联动兄弟技能 -3. 若未找到 → `PACKAGE_MODE = false`,静默降级 +1. Glob search for `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. If found → `PACKAGE_MODE = true`, can link with sibling skills +3. If not found → `PACKAGE_MODE = false`, silent degradation -当 `PACKAGE_MODE = true` 时: -- 发现问题 → 联动 `integrates_with: plugin-installation`(安装缺失工具) -- 环境就绪 → 联动 `integrates_with: skill-discovery`(扫描项目推荐技能) +When `PACKAGE_MODE = true`: +- Problems found → link to `integrates_with: plugin-installation` (install missing tools) +- Environment ready → link to `integrates_with: skill-discovery` (scan project and recommend skills) -详见 `_shared/package-context.md`。 +See `_shared/package-context.md` for details. -## 核心工作流 +## Core Workflow -### 1. 并行检测核心依赖 +### 1. Detect Core Dependencies in Parallel -对以下工具并行运行检测命令: +Run detection commands for the following tools in parallel: -| 工具 | 检测命令 | 必需 | -|------|---------|------| -| git | `command -v git && git --version` | ✅ | -| gh | `command -v gh && gh --version` | 推荐 | -| jq | `command -v jq && jq --version` | 推荐 | -| claude | `command -v claude && claude --version` | ✅ | -| node | `command -v node && node --version` | 推荐 | -| python | `command -v python3 \|\| command -v python` | 可选 | +| Tool | Detection Command | Required | +|------|-------------------|----------| +| git | `command -v git && git --version` | Yes | +| gh | `command -v gh && gh --version` | Recommended | +| jq | `command -v jq && jq --version` | Recommended | +| claude | `command -v claude && claude --version` | Yes | +| node | `command -v node && node --version` | Recommended | +| python | `command -v python3 \|\| command -v python` | Optional | -### 2. 检测服务状态 +### 2. Check Service Status -如果关键工具可用,进一步检查: +If critical tools are available, perform further checks: ```bash -# gh 认证状态 +# gh auth status gh auth status 2>&1 -# claude CLI 可用性 +# claude CLI availability claude --version 2>&1 -# MCP Server 配置(如 settings.json 存在) +# MCP Server configuration (if settings.json exists) jq -r '.mcpServers // {} | keys[]' ~/.claude/settings.json 2>/dev/null ``` -### 3. 输出健康报告 +### 3. Output Health Report -以格式化表格展示,每项给出状态和操作建议: +Display as a formatted table, with status and action suggestions for each item: ```markdown -## 🔍 环境健康报告 +## 🔍 Environment Health Report -### 核心依赖 +### Core Dependencies -| 工具 | 状态 | 版本 | 位置 | -|------|------|------|------| +| Tool | Status | Version | Location | +|------|--------|---------|----------| | git | ✅ | 2.45.0 | /usr/bin/git | | gh | ✅ | 2.55.0 | /usr/bin/gh | | jq | ✅ | 1.7.1 | /usr/bin/jq | | claude | ✅ | 0.14.0 | ~/.local/bin/claude | -| node | ⚠️ | — | 未安装 | +| node | ⚠️ | — | Not installed | | python | ✅ | 3.12.3 | /usr/bin/python3 | -### 服务状态 +### Service Status -| 服务 | 状态 | 详情 | -|------|------|------| -| gh auth | ✅ | 已登录 | -| MCP Server | — | 未配置任何 MCP Server | +| Service | Status | Details | +|---------|--------|---------| +| gh auth | ✅ | Logged in | +| MCP Server | — | No MCP Servers configured | -### 建议 +### Suggestions -- ⚠️ **node** 未安装 — 部分 MCP Server 需要 Node.js - - 安装: `winget install OpenJS.NodeJS` (Windows) / `brew install node` (macOS) +- ⚠️ **node** not installed — some MCP Servers require Node.js + - Install: `winget install OpenJS.NodeJS` (Windows) / `brew install node` (macOS) ``` -**状态图标规则:** -- ✅ 已安装且可用 -- ⚠️ 未安装或不推荐版本(给出安装命令) -- ❌ 必需工具缺失(阻塞性) -- `—` 不适用或未配置 +**Status icon rules:** +- ✅ Installed and available +- ⚠️ Not installed or unrecommended version (provide install command) +- ❌ Required tool missing (blocking) +- `—` Not applicable or not configured -**对缺失工具给出的安装命令尽量覆盖三大平台:** +**Install commands for missing tools should cover all three major platforms:** -| 工具 | Windows | macOS | Linux | +| Tool | Windows | macOS | Linux | |------|---------|-------|-------| -| git | `winget install Git.Git` | 内置 | `apt install git` | +| git | `winget install Git.Git` | Built-in | `apt install git` | | gh | `winget install GitHub.cli` | `brew install gh` | `apt install gh` | | jq | `winget install jqlang.jq` | `brew install jq` | `apt install jq` | | node | `winget install OpenJS.NodeJS` | `brew install node` | `apt install nodejs` | -## 联动(仅 PACKAGE_MODE = true) +## Linkage (PACKAGE_MODE = true only) -输出报告后: +After outputting the report: -- 如有 **缺失工具** → 提示:「💡 是否需要我帮你安装缺失的工具?」(匹配 `plugin-installation`) -- 如 **环境已就绪** → 提示:「✅ 环境就绪。是否需要扫描当前项目,推荐匹配的技能?」(匹配 `skill-discovery`) +- If **tools are missing** → prompt: "💡 Would you like me to install the missing tools?" (matches `plugin-installation`) +- If **environment is ready** → prompt: "✅ Environment ready. Would you like to scan the current project for matching skill recommendations?" (matches `skill-discovery`) -## 错误处理 +## Error Handling -| 场景 | 处理方式 | -|------|---------| -| 不在终端环境 | 跳过 `command -v`,提示用户手动检查 | -| settings.json 不存在 | 标注"未配置",不报错 | -| 检测超时 | 单工具超时 5s,标记为 ⚠️ 并继续下一个 | +| Scenario | Handling | +|----------|----------| +| Not in terminal environment | Skip `command -v`, prompt user to check manually | +| settings.json does not exist | Mark as "Not configured", do not error | +| Detection timeout | Per-tool timeout 5s, mark as ⚠️ and continue to next | diff --git a/skills/env-health-check/locale/SKILL.cn.md b/skills/env-health-check/locale/SKILL.cn.md new file mode 100644 index 0000000..662e9ab --- /dev/null +++ b/skills/env-health-check/locale/SKILL.cn.md @@ -0,0 +1,120 @@ +--- +name: env-health-check +description: > + 跨平台环境自检工具 — 检测 git、gh、jq、claude 等核心依赖的可用性、版本和认证状态, + 扫描 MCP Server 配置完整性。当你首次安装插件包后、遇到"命令不可用"错误、 + 或想确认开发环境是否就绪时使用此技能。 +capabilities: ["env-check"] +integrates_with: ["skill-discovery", "plugin-installation"] +metadata: + compatibility: "跨平台(Windows/macOS/Linux)" +locale: zh-CN +--- + +# 环境健康自检 + +跨平台检测 Claude Code 及常用工具链的可用性,输出格式化健康报告。纯 AI 驱动,无需额外依赖。 + +## 包联动 + +1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. 若找到 → `PACKAGE_MODE = true`,可联动兄弟技能 +3. 若未找到 → `PACKAGE_MODE = false`,静默降级 + +当 `PACKAGE_MODE = true` 时: +- 发现问题 → 联动 `integrates_with: plugin-installation`(安装缺失工具) +- 环境就绪 → 联动 `integrates_with: skill-discovery`(扫描项目推荐技能) + +详见 `_shared/package-context.md`。 + +## 核心工作流 + +### 1. 并行检测核心依赖 + +对以下工具并行运行检测命令: + +| 工具 | 检测命令 | 必需 | +|------|---------|------| +| git | `command -v git && git --version` | ✅ | +| gh | `command -v gh && gh --version` | 推荐 | +| jq | `command -v jq && jq --version` | 推荐 | +| claude | `command -v claude && claude --version` | ✅ | +| node | `command -v node && node --version` | 推荐 | +| python | `command -v python3 \|\| command -v python` | 可选 | + +### 2. 检测服务状态 + +如果关键工具可用,进一步检查: + +```bash +# gh 认证状态 +gh auth status 2>&1 + +# claude CLI 可用性 +claude --version 2>&1 + +# MCP Server 配置(如 settings.json 存在) +jq -r '.mcpServers // {} | keys[]' ~/.claude/settings.json 2>/dev/null +``` + +### 3. 输出健康报告 + +以格式化表格展示,每项给出状态和操作建议: + +```markdown +## 🔍 环境健康报告 + +### 核心依赖 + +| 工具 | 状态 | 版本 | 位置 | +|------|------|------|------| +| git | ✅ | 2.45.0 | /usr/bin/git | +| gh | ✅ | 2.55.0 | /usr/bin/gh | +| jq | ✅ | 1.7.1 | /usr/bin/jq | +| claude | ✅ | 0.14.0 | ~/.local/bin/claude | +| node | ⚠️ | — | 未安装 | +| python | ✅ | 3.12.3 | /usr/bin/python3 | + +### 服务状态 + +| 服务 | 状态 | 详情 | +|------|------|------| +| gh auth | ✅ | 已登录 | +| MCP Server | — | 未配置任何 MCP Server | + +### 建议 + +- ⚠️ **node** 未安装 — 部分 MCP Server 需要 Node.js + - 安装: `winget install OpenJS.NodeJS` (Windows) / `brew install node` (macOS) + +``` + +**状态图标规则:** +- ✅ 已安装且可用 +- ⚠️ 未安装或不推荐版本(给出安装命令) +- ❌ 必需工具缺失(阻塞性) +- `—` 不适用或未配置 + +**对缺失工具给出的安装命令尽量覆盖三大平台:** + +| 工具 | Windows | macOS | Linux | +|------|---------|-------|-------| +| git | `winget install Git.Git` | 内置 | `apt install git` | +| gh | `winget install GitHub.cli` | `brew install gh` | `apt install gh` | +| jq | `winget install jqlang.jq` | `brew install jq` | `apt install jq` | +| node | `winget install OpenJS.NodeJS` | `brew install node` | `apt install nodejs` | + +## 联动(仅 PACKAGE_MODE = true) + +输出报告后: + +- 如有 **缺失工具** → 提示:「💡 是否需要我帮你安装缺失的工具?」(匹配 `plugin-installation`) +- 如 **环境已就绪** → 提示:「✅ 环境就绪。是否需要扫描当前项目,推荐匹配的技能?」(匹配 `skill-discovery`) + +## 错误处理 + +| 场景 | 处理方式 | +|------|---------| +| 不在终端环境 | 跳过 `command -v`,提示用户手动检查 | +| settings.json 不存在 | 标注"未配置",不报错 | +| 检测超时 | 单工具超时 5s,标记为 ⚠️ 并继续下一个 | diff --git a/skills/git-commit-helper/SKILL.md b/skills/git-commit-helper/SKILL.md index 2506d43..991bd55 100644 --- a/skills/git-commit-helper/SKILL.md +++ b/skills/git-commit-helper/SKILL.md @@ -1,35 +1,36 @@ --- name: git-commit-helper description: > - Git 提交规范化助手 — 基于 staged diff 自动分析变更类型,生成符合 Conventional Commits - 规范的提交信息。当你需要提交代码、编写规范的 commit message、整理 git 暂存区、 - 或不确定 commit 怎么写时使用此技能。 + Git Commit Standardization Helper — automatically analyzes staged diff to determine change types + and generates commit messages conforming to the Conventional Commits specification. + Use this skill when you need to commit code, write a standardized commit message, + organize the git staging area, or are unsure how to write a commit. capabilities: ["git-commit"] integrates_with: ["pr-management", "code-review"] metadata: - compatibility: "需要 git" + compatibility: "Requires git" --- -# Git 提交规范化助手 +# Git Commit Standardization Helper -基于 staged diff 智能分析变更,生成符合 [Conventional Commits](https://www.conventionalcommits.org/) 规范的提交信息。纯 AI 驱动,无需额外脚本依赖。 +Intelligently analyzes staged diff changes and generates commit messages conforming to the [Conventional Commits](https://www.conventionalcommits.org/) specification. Purely AI-driven, no additional script dependencies required. -## 包联动 +## Package Linking -1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` -2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 -3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级) +1. Glob search for `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. If found → `PACKAGE_MODE = true`, can discover and link with sibling skills +3. If not found → `PACKAGE_MODE = false`, skip all cross-skill logic (silent degradation) -当 `PACKAGE_MODE = true` 时: -- 提交完成后可联动 `integrates_with: pr-management`(PR 管理) -- 提交完成后可联动 `integrates_with: code-review`(代码审查) -- 扫描兄弟 SKILL.md 的 `capabilities` 字段做交集匹配 +When `PACKAGE_MODE = true`: +- After commit, can link with `integrates_with: pr-management` (PR management) +- After commit, can link with `integrates_with: code-review` (code review) +- Scan sibling SKILL.md `capabilities` fields for intersection matching -详见 `_shared/package-context.md`。 +See `_shared/package-context.md` for details. -## 核心工作流 +## Core Workflow -### 1. 检测暂存状态 +### 1. Detect Staging Area State ```bash git status --short @@ -37,120 +38,120 @@ git diff --staged --stat git diff --staged ``` -首先检查暂存区是否有变更。如果没有,提示用户: +First check if the staging area has changes. If not, prompt the user: ```markdown -📭 暂存区为空。请先使用 `git add <文件>` 将要提交的变更添加到暂存区。 +📭 The staging area is empty. Please use `git add ` to add the changes you want to commit. -当前工作区变更(unstaged): - +Current workspace changes (unstaged): + -是否需要我帮你整理暂存区? +Would you like me to help you organize the staging area? ``` -### 2. 分析变更生成消息 +### 2. Analyze Changes and Generate Message -基于 `git diff --staged` 的内容分析变更,生成 Conventional Commits 格式的提交信息。 +Analyze changes based on `git diff --staged` content and generate a Conventional Commits format commit message. -**分析维度:** -- **类型推断**:根据变更性质确定 type -- **scope 提取**:从变更文件路径中提取影响范围 -- **主体编写**:一句话描述核心变更 + 可选的多行要点 +**Analysis Dimensions:** +- **Type Inference**: Determine the type based on the nature of the change +- **Scope Extraction**: Extract the scope from changed file paths +- **Subject Writing**: One sentence describing the core change, plus optional multi-line bullet points -**类型推断规则:** +**Type Inference Rules:** -| 类型 | 判断依据 | +| Type | Criteria | |------|---------| -| `feat` | 新增功能、新文件、新 API 端点、新组件 | -| `fix` | 修复 bug、修正逻辑错误、修复空指针/空值 | -| `docs` | 仅修改文档(`*.md`、注释、README) | -| `style` | 格式化、空格、分号等不影响代码逻辑的调整 | -| `refactor` | 重构(既无新功能也不修 bug,但改动代码结构) | -| `perf` | 性能优化(减少循环、缓存、算法改进) | -| `test` | 添加或修改测试 | -| `chore` | 构建配置、依赖更新、CI/CD、`.gitignore` 等杂务 | -| `ci` | CI/CD 流水线变更 | -| `build` | 构建系统或外部依赖变更 | - -**scope 提取规则:** -- 从变更文件路径中提取共同前缀(如 `skills/github-pr-manager` → `github-pr-manager`) -- 单文件变更:用文件名作为 scope -- 多模块变更:用最高频路径或 `multiple` -- 无明确 scope 时可省略 - -**生成格式:** +| `feat` | New feature, new file, new API endpoint, new component | +| `fix` | Bug fix, logic error correction, null pointer/null value fix | +| `docs` | Only documentation changes (`*.md`, comments, README) | +| `style` | Formatting, whitespace, semicolons, etc. — adjustments not affecting code logic | +| `refactor` | Refactoring (neither new feature nor bug fix, but changes code structure) | +| `perf` | Performance optimization (loop reduction, caching, algorithm improvements) | +| `test` | Adding or modifying tests | +| `chore` | Build configuration, dependency updates, CI/CD, `.gitignore`, etc. | +| `ci` | CI/CD pipeline changes | +| `build` | Build system or external dependency changes | + +**Scope Extraction Rules:** +- Extract the common prefix from changed file paths (e.g. `skills/github-pr-manager` → `github-pr-manager`) +- Single-file change: use the file name as the scope +- Multi-module change: use the most frequent path or `multiple` +- Can be omitted when no clear scope exists + +**Generated Format:** ``` -(): <简短描述> +(): -<详细说明(可选,多行要点)> + -BREAKING CHANGE: <破坏性变更说明(如有)> +BREAKING CHANGE: ``` -**示例输出:** +**Example Output:** ``` -feat(git-commit-helper): 添加基于 staged diff 的提交信息自动生成 +feat(git-commit-helper): add automatic commit message generation based on staged diff -- 自动分析变更类型推断 type 和 scope -- 支持 Conventional Commits 规范 -- 提交前交互式预览和编辑 -- 提交后联动 PR 管理和代码审查 +- Automatically analyze changes to infer type and scope +- Support Conventional Commits specification +- Interactive preview and editing before commit +- Link to PR management and code review after commit ``` -### 3. 预览与确认 +### 3. Preview and Confirm -生成消息后,以完整格式化预览展示给用户: +After generating the message, present it to the user in a fully formatted preview: ```markdown -## 📝 提交预览 +## 📝 Commit Preview ``` -feat(git-commit-helper): 添加基于 staged diff 的提交信息自动生成 +feat(git-commit-helper): add automatic commit message generation based on staged diff -- 自动分析变更类型推断 type 和 scope -- 支持 Conventional Commits 规范 -- 提交前交互式预览和编辑 +- Automatically analyze changes to infer type and scope +- Support Conventional Commits specification +- Interactive preview and editing before commit ``` -| 项目 | 详情 | -|------|------| -| 📂 变更文件 | N 个 | -| 🏷️ 类型 | feat | -| 🎯 scope | git-commit-helper | -| 📏 行数 | +X / -Y | +| Item | Detail | +|------|--------| +| 📂 Changed files | N | +| 🏷️ Type | feat | +| 🎯 Scope | git-commit-helper | +| 📏 Lines | +X / -Y | --- -请选择: -1. ✅ **确认提交** — 直接执行 `git commit` -2. ✏️ **编辑修改** — 修改 type / scope / 描述 -3. 🔄 **重新生成** — 换用另一种角度重新分析 -4. 📝 **手动输入** — 你自己手写 commit message -5. ❌ **取消** — 不做任何操作 +Please choose: +1. ✅ **Confirm** — Execute `git commit` directly +2. ✏️ **Edit** — Modify type / scope / description +3. 🔄 **Regenerate** — Re-analyze from a different perspective +4. 📝 **Manual** — Write the commit message yourself +5. ❌ **Cancel** — Do nothing ``` -**重要:必须等待用户选择后才执行下一步。** +**Important: Wait for the user's choice before proceeding to the next step.** -### 4. 执行提交并联动 +### 4. Execute Commit and Link -**确认后执行:** +**Execute after confirmation:** ```bash -git commit -m "<消息>" +git commit -m "" ``` -**提交成功后联动(仅 PACKAGE_MODE = true 时):** +**Linkage after successful commit (only when PACKAGE_MODE = true):** -检查是否有 GitHub remote: +Check for GitHub remote: ```bash git remote get-url origin 2>/dev/null ``` -- 如果有 GitHub remote → 提示:`💡 变更已提交。是否需要推送并创建 PR?`(匹配 `pr-management`) -- 如果涉及功能性代码变更 → 提示:`💡 是否需要在推送 PR 前运行代码审查?`(匹配 `code-review`) +- If a GitHub remote exists → prompt: `💡 Changes committed. Would you like to push and create a PR?` (matches `pr-management`) +- If functional code changes are involved → prompt: `💡 Would you like to run a code review before pushing the PR?` (matches `code-review`) -## Conventional Commits 规范速查 +## Conventional Commits Quick Reference -### 格式 +### Format ``` [optional scope]: @@ -159,29 +160,29 @@ git remote get-url origin 2>/dev/null [optional footer(s)] ``` -### 类型速查 -- `feat` — 新功能 -- `fix` — Bug 修复 -- `docs` — 文档 -- `style` — 格式调整(不影响代码逻辑) -- `refactor` — 重构 -- `perf` — 性能优化 -- `test` — 测试 -- `chore` — 构建/工具/依赖 +### Type Quick Reference +- `feat` — New feature +- `fix` — Bug fix +- `docs` — Documentation +- `style` — Formatting (does not affect code logic) +- `refactor` — Refactoring +- `perf` — Performance optimization +- `test` — Tests +- `chore` — Build/tooling/dependencies - `ci` — CI/CD -- `build` — 构建系统 +- `build` — Build system ### Breaking Change -- 正文末尾或 footer 中以 `BREAKING CHANGE:` 开头 -- 或在 type/scope 后追加 `!`:`feat(api)!: 重新设计用户接口` - -## 错误处理 - -| 场景 | 处理方式 | -|------|---------| -| 暂存区为空 | 显示 unstaged 变更,提示用户 `git add` | -| 不在 git 仓库中 | 提示初始化 `git init` 或切换到仓库目录 | -| diff 过大(>500 行) | 截取前 500 行分析,标注「仅分析前 500 行」 | -| 变更类型难以判断 | 列出 2-3 个可能类型,让用户选择 | -| `git commit` 失败 | 显示错误信息,提供重试或手动输入 | -| pre-commit hook 失败 | 显示 hook 输出,提示修复后重试 | +- Prefix the body or footer with `BREAKING CHANGE:` +- Or append `!` after type/scope: `feat(api)!: Redesign user API` + +## Error Handling + +| Scenario | Handling | +|----------|---------| +| Empty staging area | Show unstaged changes, prompt user to `git add` | +| Not in a git repository | Prompt to initialize with `git init` or switch to a repository directory | +| Diff too large (>500 lines) | Analyze only the first 500 lines, annotate as "only the first 500 lines were analyzed" | +| Change type is ambiguous | List 2-3 possible types and ask the user to choose | +| `git commit` fails | Display the error, offer retry or manual input | +| pre-commit hook fails | Display hook output, prompt to fix and retry | diff --git a/skills/git-commit-helper/locale/SKILL.cn.md b/skills/git-commit-helper/locale/SKILL.cn.md new file mode 100644 index 0000000..a619cc1 --- /dev/null +++ b/skills/git-commit-helper/locale/SKILL.cn.md @@ -0,0 +1,188 @@ +--- +name: git-commit-helper +description: > + Git 提交规范化助手 — 基于 staged diff 自动分析变更类型,生成符合 Conventional Commits + 规范的提交信息。当你需要提交代码、编写规范的 commit message、整理 git 暂存区、 + 或不确定 commit 怎么写时使用此技能。 +capabilities: ["git-commit"] +integrates_with: ["pr-management", "code-review"] +metadata: + compatibility: "需要 git" +locale: zh-CN +--- + +# Git 提交规范化助手 + +基于 staged diff 智能分析变更,生成符合 [Conventional Commits](https://www.conventionalcommits.org/) 规范的提交信息。纯 AI 驱动,无需额外脚本依赖。 + +## 包联动 + +1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 +3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级) + +当 `PACKAGE_MODE = true` 时: +- 提交完成后可联动 `integrates_with: pr-management`(PR 管理) +- 提交完成后可联动 `integrates_with: code-review`(代码审查) +- 扫描兄弟 SKILL.md 的 `capabilities` 字段做交集匹配 + +详见 `_shared/package-context.md`。 + +## 核心工作流 + +### 1. 检测暂存状态 + +```bash +git status --short +git diff --staged --stat +git diff --staged +``` + +首先检查暂存区是否有变更。如果没有,提示用户: + +```markdown +📭 暂存区为空。请先使用 `git add <文件>` 将要提交的变更添加到暂存区。 + +当前工作区变更(unstaged): + + +是否需要我帮你整理暂存区? +``` + +### 2. 分析变更生成消息 + +基于 `git diff --staged` 的内容分析变更,生成 Conventional Commits 格式的提交信息。 + +**分析维度:** +- **类型推断**:根据变更性质确定 type +- **scope 提取**:从变更文件路径中提取影响范围 +- **主体编写**:一句话描述核心变更 + 可选的多行要点 + +**类型推断规则:** + +| 类型 | 判断依据 | +|------|---------| +| `feat` | 新增功能、新文件、新 API 端点、新组件 | +| `fix` | 修复 bug、修正逻辑错误、修复空指针/空值 | +| `docs` | 仅修改文档(`*.md`、注释、README) | +| `style` | 格式化、空格、分号等不影响代码逻辑的调整 | +| `refactor` | 重构(既无新功能也不修 bug,但改动代码结构) | +| `perf` | 性能优化(减少循环、缓存、算法改进) | +| `test` | 添加或修改测试 | +| `chore` | 构建配置、依赖更新、CI/CD、`.gitignore` 等杂务 | +| `ci` | CI/CD 流水线变更 | +| `build` | 构建系统或外部依赖变更 | + +**scope 提取规则:** +- 从变更文件路径中提取共同前缀(如 `skills/github-pr-manager` → `github-pr-manager`) +- 单文件变更:用文件名作为 scope +- 多模块变更:用最高频路径或 `multiple` +- 无明确 scope 时可省略 + +**生成格式:** +``` +(): <简短描述> + +<详细说明(可选,多行要点)> + +BREAKING CHANGE: <破坏性变更说明(如有)> +``` + +**示例输出:** +``` +feat(git-commit-helper): 添加基于 staged diff 的提交信息自动生成 + +- 自动分析变更类型推断 type 和 scope +- 支持 Conventional Commits 规范 +- 提交前交互式预览和编辑 +- 提交后联动 PR 管理和代码审查 +``` + +### 3. 预览与确认 + +生成消息后,以完整格式化预览展示给用户: + +```markdown +## 📝 提交预览 + +``` +feat(git-commit-helper): 添加基于 staged diff 的提交信息自动生成 + +- 自动分析变更类型推断 type 和 scope +- 支持 Conventional Commits 规范 +- 提交前交互式预览和编辑 +``` + +| 项目 | 详情 | +|------|------| +| 📂 变更文件 | N 个 | +| 🏷️ 类型 | feat | +| 🎯 scope | git-commit-helper | +| 📏 行数 | +X / -Y | + +--- + +请选择: +1. ✅ **确认提交** — 直接执行 `git commit` +2. ✏️ **编辑修改** — 修改 type / scope / 描述 +3. 🔄 **重新生成** — 换用另一种角度重新分析 +4. 📝 **手动输入** — 你自己手写 commit message +5. ❌ **取消** — 不做任何操作 +``` + +**重要:必须等待用户选择后才执行下一步。** + +### 4. 执行提交并联动 + +**确认后执行:** +```bash +git commit -m "<消息>" +``` + +**提交成功后联动(仅 PACKAGE_MODE = true 时):** + +检查是否有 GitHub remote: +```bash +git remote get-url origin 2>/dev/null +``` + +- 如果有 GitHub remote → 提示:`💡 变更已提交。是否需要推送并创建 PR?`(匹配 `pr-management`) +- 如果涉及功能性代码变更 → 提示:`💡 是否需要在推送 PR 前运行代码审查?`(匹配 `code-review`) + +## Conventional Commits 规范速查 + +### 格式 +``` +[optional scope]: + +[optional body] + +[optional footer(s)] +``` + +### 类型速查 +- `feat` — 新功能 +- `fix` — Bug 修复 +- `docs` — 文档 +- `style` — 格式调整(不影响代码逻辑) +- `refactor` — 重构 +- `perf` — 性能优化 +- `test` — 测试 +- `chore` — 构建/工具/依赖 +- `ci` — CI/CD +- `build` — 构建系统 + +### Breaking Change +- 正文末尾或 footer 中以 `BREAKING CHANGE:` 开头 +- 或在 type/scope 后追加 `!`:`feat(api)!: 重新设计用户接口` + +## 错误处理 + +| 场景 | 处理方式 | +|------|---------| +| 暂存区为空 | 显示 unstaged 变更,提示用户 `git add` | +| 不在 git 仓库中 | 提示初始化 `git init` 或切换到仓库目录 | +| diff 过大(>500 行) | 截取前 500 行分析,标注「仅分析前 500 行」 | +| 变更类型难以判断 | 列出 2-3 个可能类型,让用户选择 | +| `git commit` 失败 | 显示错误信息,提供重试或手动输入 | +| pre-commit hook 失败 | 显示 hook 输出,提示修复后重试 | diff --git a/skills/github-pr-manager/SKILL.md b/skills/github-pr-manager/SKILL.md index 78abb00..a83e310 100644 --- a/skills/github-pr-manager/SKILL.md +++ b/skills/github-pr-manager/SKILL.md @@ -1,184 +1,186 @@ --- name: github-pr-manager description: > - GitHub PR 全功能管理器 — 指定仓库、列出 PR、查看详情和 diff、查看评论和审查状态、 - 查看提交历史、克隆 PR 代码到本地 owner/repo-pr-N 目录并自动初始化开发环境,支持多仓库切换 - 和批量操作。当你需要管理 GitHub 拉取请求、克隆 PR、查看代码审查、检查 PR 提交、 - 批量处理多个 PR、或者任何与 GitHub pull request 相关的操作时使用此技能 — 即使用户 - 没有明确说"PR 管理",只要涉及 GitHub 仓库的拉取请求就应触发。 + GitHub PR full-featured manager — specify a repo, list PRs, view details and diff, + view comments and review status, view commit history, clone PR code locally to + owner/repo-pr-N directory with automatic dev environment initialization, supports + multi-repo switching and batch operations. Use this skill when you need to manage + GitHub pull requests, clone PRs, view code reviews, inspect PR commits, batch-process + multiple PRs, or any operation related to GitHub pull requests — trigger even if + the user doesn't explicitly say "PR management" as long as GitHub repository pull + requests are involved. capabilities: ["pr-management", "ci-analysis", "code-cloning"] integrates_with: ["project-setup", "skill-discovery"] metadata: compatibility: "需要 gh (GitHub CLI ≥ 2.0.0), git, jq" --- -# GitHub PR 管理器 +# GitHub PR Manager -管理任意 GitHub 仓库的 Pull Request:列出、查看详情/diff/评论/提交、克隆到本地、批量操作。 +Manage Pull Requests for any GitHub repository: list, view details/diff/comments/commits, clone locally, batch operations. -## 核心理念 +## Core Philosophy -本技能让你像操作本地 git 分支一样操作远程 PR。每个 PR 被克隆到独立目录 `--pr-<编号>`, -互不干扰,多仓库并行管理时目录不会混淆。 +This skill lets you operate remote PRs as if they were local git branches. Each PR is cloned to an independent directory `--pr-`, directories never interfere, and multi-repo parallel management stays clean. -## 前置条件 +## Prerequisites -- `gh` (GitHub CLI ≥ 2.0.0):`gh auth status` 确认已登录 -- `git`、`jq`(用于 JSON 格式化,缺失时回退到原始输出) +- `gh` (GitHub CLI >= 2.0.0): `gh auth status` to confirm login +- `git`, `jq` (for JSON formatting, falls back to raw output if missing) -## 包联动 +## Package Linking -本技能支持与 minecraft269-skills 插件包内其他技能自动联动。执行以下检测: +This skill supports automatic linking with other skills in the minecraft269-skills plugin package. The following detection is performed: -1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` -2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 -3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级,不报错) +1. Glob search for `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. If found -> `PACKAGE_MODE = true`, can discover and link sibling skills +3. If not found -> `PACKAGE_MODE = false`, skip all cross-skill logic (silent degradation, no error) -当 `PACKAGE_MODE = true` 时: -- 克隆 PR 后可联动 `integrates_with: project-setup`(项目启动流程)和 `integrates_with: skill-discovery`(技能发现) -- 扫描兄弟 SKILL.md 的 `capabilities` 字段,匹配本技能的 `integrates_with` 标签 -- 仅在匹配成功时显示联动提示 +When `PACKAGE_MODE = true`: +- After cloning a PR, can link with `integrates_with: project-setup` (project initialization flow) and `integrates_with: skill-discovery` (skill discovery) +- Scan the `capabilities` field of sibling SKILL.md files, match against this skill's `integrates_with` tags +- Only show linking hints when a match succeeds -详见 `_shared/package-context.md`。 +See `_shared/package-context.md` for details. -## 核心工作流 +## Core Workflow -### 1. 设定仓库 +### 1. Set Repository -用户必须以 `owner/repo` 格式指定仓库。如果用户没有提供,主动询问: +The user must specify a repository in `owner/repo` format. If the user does not provide one, proactively ask: -> "请提供 GitHub 仓库(格式:owner/repo,例如 facebook/react)" +> "Please provide a GitHub repository (format: owner/repo, e.g. facebook/react)" -支持 `/set-repo owner/repo` 切换仓库。多仓库场景下,记住最近使用过的仓库列表。 +Supports `/set-repo owner/repo` to switch repositories. In multi-repo scenarios, remember the most recently used repository list. -设定仓库后,**自动执行 `/list-pr` 展示当前所有开放 PR。** +After setting the repository, **automatically execute `/list-pr` to show all open PRs.** -### 2. 列出 PR +### 2. List PRs ```bash gh pr list --repo --state open --json number,title,author,headRefName,createdAt,labels --limit 50 ``` -展示为清晰的表格: +Display as a clear table: ``` -📋 仓库: owner/repo | 开放 PR 列表 +📋 Repo: owner/repo | Open PR List ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - #1234 feat: add new button component @john_doe 🏷 enhancement 2天前 - #1235 fix: resolve memory leak @jane_dev 🐛 bug 5小时前 - #1236 docs: update API reference @dev_sam 📖 docs 1周前 + #1234 feat: add new button component @john_doe 🏷 enhancement 2d ago + #1235 fix: resolve memory leak @jane_dev 🐛 bug 5h ago + #1236 docs: update API reference @dev_sam 📖 docs 1w ago ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -共 3 个开放 PR +3 open PRs ``` -**用户可选操作(对话式,无需记忆命令):** -- 输入 PR 编号(如 `1234`)→ 查看该 PR 完整信息(详情 + diff + 评论 + 提交) -- `c <编号>` → 克隆 PR 并初始化开发环境 -- `d <编号>` → 仅查看 PR 详情 -- `diff <编号>` → 查看 PR 代码变更摘要 -- `comments <编号>` → 查看 PR 评论和审查状态 -- `commits <编号>` → 查看 PR 提交历史 -- `batch clone <编号1>,<编号2>,...` → 批量克隆多个 PR -- `r` → 刷新列表 -- `repo ` → 切换仓库 +**User options (conversational, no need to memorize commands):** +- Enter a PR number (e.g. `1234`) -> View full PR info (details + diff + comments + commits) +- `c ` -> Clone PR and initialize dev environment +- `d ` -> View PR details only +- `diff ` -> View PR code change summary +- `comments ` -> View PR comments and review status +- `commits ` -> View PR commit history +- `batch clone ,,...` -> Batch clone multiple PRs +- `r` -> Refresh list +- `repo ` -> Switch repository -### 3. PR 完整信息(默认行为) +### 3. PR Full Info (Default Behavior) -当用户输入 PR 编号时,一次性展示: +When the user enters a PR number, display all at once: -#### 3a. 基本信息 +#### 3a. Basic Info ```bash -gh pr view <编号> --repo --json title,body,author,state,mergeable,changedFiles,commits,url,headRefName,baseRefName,createdAt,labels +gh pr view --repo --json title,body,author,state,mergeable,changedFiles,commits,url,headRefName,baseRefName,createdAt,labels ``` -#### 3b. 代码变更 (diff) +#### 3b. Code Changes (diff) ```bash -gh pr diff <编号> --repo | head -200 +gh pr diff --repo | head -200 ``` -展示变更文件列表和关键差异(截断到 200 行,提示用户可查看完整 diff)。 +Show the list of changed files and key diffs (truncated to 200 lines, prompt the user they can view the full diff). -#### 3c. 评论和审查 +#### 3c. Comments and Reviews ```bash -gh pr view <编号> --repo --json reviews,comments +gh pr view --repo --json reviews,comments ``` -展示审查状态(APPROVED/CHANGES_REQUESTED/COMMENTED)和最新评论摘要。 +Show review status (APPROVED/CHANGES_REQUESTED/COMMENTED) and latest comment summary. -#### 3d. 提交历史 +#### 3d. Commit History ```bash -gh pr view <编号> --repo --json commits --jq '.commits[] | "\(.oid[:7]) \(.author.name) \(.messageHeadline)"' +gh pr view --repo --json commits --jq '.commits[] | "\(.oid[:7]) \(.author.name) \(.messageHeadline)"' ``` -展示提交者、简短 hash 和提交信息。 +Show author, short hash, and commit message. -### 4. 克隆 PR 到本地 +### 4. Clone PR Locally ```bash -# 参见 scripts/clone_pr.sh — 完整的克隆和初始化流程 +# See scripts/clone_pr.sh — full clone and initialization flow ``` -流程: -1. 检查 `--pr-<编号>` 是否已存在 → 存在则询问覆盖/跳过 -2. 执行 `gh pr checkout <编号> --repo ` 或手动 fetch + checkout -3. 展示克隆结果:路径、分支、大小 -4. 检测项目类型并引导初始化: - - **Node.js** (`package.json`) → 询问是否 `npm install` - - **Python** (`requirements.txt`/`pyproject.toml`) → 询问是否创建 venv - - **Rust** (`Cargo.toml`) → 询问是否 `cargo build` - - **其他** → 提示手动初始化 +Flow: +1. Check if `--pr-` already exists -> prompt overwrite/skip +2. Execute `gh pr checkout --repo ` or manual fetch + checkout +3. Show clone result: path, branch, size +4. Detect project type and guide initialization: + - **Node.js** (`package.json`) -> Ask whether to `npm install` + - **Python** (`requirements.txt`/`pyproject.toml`) -> Ask whether to create venv + - **Rust** (`Cargo.toml`) -> Ask whether to `cargo build` + - **Other** -> Prompt manual initialization -**联动钩子(仅 PACKAGE_MODE = true 时执行):** +**Linking hooks (only when PACKAGE_MODE = true):** -克隆完成后,扫描兄弟技能的 `capabilities` 与本技能的 `integrates_with` 做交集匹配: -- 匹配到 `project-setup` → 提示用户:"💡 首次接触此项目?可使用 **通用项目启动** 快速理解项目结构和约定。" -- 匹配到 `skill-discovery` → 提示用户:"💡 检测到新的项目类型 [技术栈]。是否需要运行 **主动技能发现** 为该项目推荐匹配的技能和插件?" +After cloning completes, scan sibling skills' `capabilities` against this skill's `integrates_with` for intersection matching: +- Match `project-setup` -> Prompt: "This is your first time with this project? Use **Universal Project Kickoff** to quickly understand the project structure and conventions." +- Match `skill-discovery` -> Prompt: "A new project type [tech stack] has been detected. Would you like to run **Proactive Skill Discovery** to recommend matching skills and plugins for this project?" -### 5. 批量操作 +### 5. Batch Operations -**批量克隆:** `batch clone 1234,1235,1236` +**Batch clone:** `batch clone 1234,1235,1236` -对每个 PR 依次执行克隆流程,汇总展示结果: +Execute the clone flow for each PR sequentially and summarize results: ``` -🚀 批量克隆 3 个 PR +🚀 Batch clone 3 PRs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ #1234 → ./facebook-react-pr-1234 (Node.js, 已 npm install) -✅ #1235 → ./facebook-react-pr-1235 (Python, 已创建 venv) -❌ #1236 → 目录已存在,跳过 +✅ #1234 -> ./facebook-react-pr-1234 (Node.js, npm install done) +✅ #1235 -> ./facebook-react-pr-1235 (Python, venv created) +❌ #1236 -> Directory already exists, skipped ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` -**批量查看:** `batch view 1234,1235,1236` — 依次展示每个 PR 的摘要信息。 +**Batch view:** `batch view 1234,1235,1236` — Display summary info for each PR in sequence. -## 命令速查 +## Command Quick Reference -| 输入 | 说明 | -|------|------| -| `<编号>` | 查看 PR 完整信息(默认行为) | -| `/set-repo ` | 设置/切换仓库 | -| `c <编号>` | 克隆 PR 并初始化 | -| `d <编号>` | 仅查看详情 | -| `diff <编号>` | 查看代码变更 | -| `comments <编号>` | 查看评论和审查 | -| `commits <编号>` | 查看提交历史 | -| `batch clone ,` | 批量克隆 | -| `batch view ,` | 批量查看 | -| `r` | 刷新 PR 列表 | -| `repo ` | 切换仓库 | +| Input | Description | +|-------|-------------| +| `` | View PR full info (default behavior) | +| `/set-repo ` | Set/switch repository | +| `c ` | Clone PR and initialize | +| `d ` | View details only | +| `diff ` | View code changes | +| `comments ` | View comments and reviews | +| `commits ` | View commit history | +| `batch clone ,` | Batch clone | +| `batch view ,` | Batch view | +| `r` | Refresh PR list | +| `repo ` | Switch repository | -## 脚本 +## Scripts -- `scripts/list_prs.sh` — 列出仓库开放 PR(JSON → 格式化表格,支持 `-a` 翻页) -- `scripts/view_pr.sh` — 获取 PR 完整信息(详情+diff+评论+提交,支持 `-d`/`-v`/`-a`) -- `scripts/clone_pr.sh` — 克隆 PR 并检测项目类型,支持多语言自动初始化 -- `scripts/ci_pr.sh` — 查看 CI 状态,分析失败原因,重跑失败 Job(`--analyze`/`--rerun`/`--wait`) +- `scripts/list_prs.sh` — List open PRs for a repository (JSON -> formatted table, supports `-a` pagination) +- `scripts/view_pr.sh` — Get full PR info (details+diff+comments+commits, supports `-d`/`-v`/`-a`) +- `scripts/clone_pr.sh` — Clone PR and detect project type, supports multi-language auto-initialization +- `scripts/ci_pr.sh` — View CI status, analyze failures, rerun failed jobs (`--analyze`/`--rerun`/`--wait`) -## 详细参考 +## Detailed References -- `references/workflows.md` — 完整工作流细节、示例对话、多仓库管理 -- `references/error-handling.md` — 所有错误场景及处理方式 +- `references/workflows.md` — Full workflow details, example conversations, multi-repo management +- `references/error-handling.md` — All error scenarios and handling approaches diff --git a/skills/github-pr-manager/locale/SKILL.cn.md b/skills/github-pr-manager/locale/SKILL.cn.md new file mode 100644 index 0000000..34f2240 --- /dev/null +++ b/skills/github-pr-manager/locale/SKILL.cn.md @@ -0,0 +1,185 @@ +--- +name: github-pr-manager +description: > + GitHub PR 全功能管理器 — 指定仓库、列出 PR、查看详情和 diff、查看评论和审查状态、 + 查看提交历史、克隆 PR 代码到本地 owner/repo-pr-N 目录并自动初始化开发环境,支持多仓库切换 + 和批量操作。当你需要管理 GitHub 拉取请求、克隆 PR、查看代码审查、检查 PR 提交、 + 批量处理多个 PR、或者任何与 GitHub pull request 相关的操作时使用此技能 — 即使用户 + 没有明确说"PR 管理",只要涉及 GitHub 仓库的拉取请求就应触发。 +capabilities: ["pr-management", "ci-analysis", "code-cloning"] +integrates_with: ["project-setup", "skill-discovery"] +metadata: + compatibility: "需要 gh (GitHub CLI ≥ 2.0.0), git, jq" +locale: zh-CN +--- + +# GitHub PR 管理器 + +管理任意 GitHub 仓库的 Pull Request:列出、查看详情/diff/评论/提交、克隆到本地、批量操作。 + +## 核心理念 + +本技能让你像操作本地 git 分支一样操作远程 PR。每个 PR 被克隆到独立目录 `--pr-<编号>`, +互不干扰,多仓库并行管理时目录不会混淆。 + +## 前置条件 + +- `gh` (GitHub CLI ≥ 2.0.0):`gh auth status` 确认已登录 +- `git`、`jq`(用于 JSON 格式化,缺失时回退到原始输出) + +## 包联动 + +本技能支持与 minecraft269-skills 插件包内其他技能自动联动。执行以下检测: + +1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 +3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级,不报错) + +当 `PACKAGE_MODE = true` 时: +- 克隆 PR 后可联动 `integrates_with: project-setup`(项目启动流程)和 `integrates_with: skill-discovery`(技能发现) +- 扫描兄弟 SKILL.md 的 `capabilities` 字段,匹配本技能的 `integrates_with` 标签 +- 仅在匹配成功时显示联动提示 + +详见 `_shared/package-context.md`。 + +## 核心工作流 + +### 1. 设定仓库 + +用户必须以 `owner/repo` 格式指定仓库。如果用户没有提供,主动询问: + +> "请提供 GitHub 仓库(格式:owner/repo,例如 facebook/react)" + +支持 `/set-repo owner/repo` 切换仓库。多仓库场景下,记住最近使用过的仓库列表。 + +设定仓库后,**自动执行 `/list-pr` 展示当前所有开放 PR。** + +### 2. 列出 PR + +```bash +gh pr list --repo --state open --json number,title,author,headRefName,createdAt,labels --limit 50 +``` + +展示为清晰的表格: + +``` +📋 仓库: owner/repo | 开放 PR 列表 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + #1234 feat: add new button component @john_doe 🏷 enhancement 2天前 + #1235 fix: resolve memory leak @jane_dev 🐛 bug 5小时前 + #1236 docs: update API reference @dev_sam 📖 docs 1周前 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +共 3 个开放 PR +``` + +**用户可选操作(对话式,无需记忆命令):** +- 输入 PR 编号(如 `1234`)→ 查看该 PR 完整信息(详情 + diff + 评论 + 提交) +- `c <编号>` → 克隆 PR 并初始化开发环境 +- `d <编号>` → 仅查看 PR 详情 +- `diff <编号>` → 查看 PR 代码变更摘要 +- `comments <编号>` → 查看 PR 评论和审查状态 +- `commits <编号>` → 查看 PR 提交历史 +- `batch clone <编号1>,<编号2>,...` → 批量克隆多个 PR +- `r` → 刷新列表 +- `repo ` → 切换仓库 + +### 3. PR 完整信息(默认行为) + +当用户输入 PR 编号时,一次性展示: + +#### 3a. 基本信息 + +```bash +gh pr view <编号> --repo --json title,body,author,state,mergeable,changedFiles,commits,url,headRefName,baseRefName,createdAt,labels +``` + +#### 3b. 代码变更 (diff) + +```bash +gh pr diff <编号> --repo | head -200 +``` + +展示变更文件列表和关键差异(截断到 200 行,提示用户可查看完整 diff)。 + +#### 3c. 评论和审查 + +```bash +gh pr view <编号> --repo --json reviews,comments +``` + +展示审查状态(APPROVED/CHANGES_REQUESTED/COMMENTED)和最新评论摘要。 + +#### 3d. 提交历史 + +```bash +gh pr view <编号> --repo --json commits --jq '.commits[] | "\(.oid[:7]) \(.author.name) \(.messageHeadline)"' +``` + +展示提交者、简短 hash 和提交信息。 + +### 4. 克隆 PR 到本地 + +```bash +# 参见 scripts/clone_pr.sh — 完整的克隆和初始化流程 +``` + +流程: +1. 检查 `--pr-<编号>` 是否已存在 → 存在则询问覆盖/跳过 +2. 执行 `gh pr checkout <编号> --repo ` 或手动 fetch + checkout +3. 展示克隆结果:路径、分支、大小 +4. 检测项目类型并引导初始化: + - **Node.js** (`package.json`) → 询问是否 `npm install` + - **Python** (`requirements.txt`/`pyproject.toml`) → 询问是否创建 venv + - **Rust** (`Cargo.toml`) → 询问是否 `cargo build` + - **其他** → 提示手动初始化 + +**联动钩子(仅 PACKAGE_MODE = true 时执行):** + +克隆完成后,扫描兄弟技能的 `capabilities` 与本技能的 `integrates_with` 做交集匹配: +- 匹配到 `project-setup` → 提示用户:"💡 首次接触此项目?可使用 **通用项目启动** 快速理解项目结构和约定。" +- 匹配到 `skill-discovery` → 提示用户:"💡 检测到新的项目类型 [技术栈]。是否需要运行 **主动技能发现** 为该项目推荐匹配的技能和插件?" + +### 5. 批量操作 + +**批量克隆:** `batch clone 1234,1235,1236` + +对每个 PR 依次执行克隆流程,汇总展示结果: + +``` +🚀 批量克隆 3 个 PR +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +✅ #1234 → ./facebook-react-pr-1234 (Node.js, 已 npm install) +✅ #1235 → ./facebook-react-pr-1235 (Python, 已创建 venv) +❌ #1236 → 目录已存在,跳过 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +**批量查看:** `batch view 1234,1235,1236` — 依次展示每个 PR 的摘要信息。 + +## 命令速查 + +| 输入 | 说明 | +|------|------| +| `<编号>` | 查看 PR 完整信息(默认行为) | +| `/set-repo ` | 设置/切换仓库 | +| `c <编号>` | 克隆 PR 并初始化 | +| `d <编号>` | 仅查看详情 | +| `diff <编号>` | 查看代码变更 | +| `comments <编号>` | 查看评论和审查 | +| `commits <编号>` | 查看提交历史 | +| `batch clone ,` | 批量克隆 | +| `batch view ,` | 批量查看 | +| `r` | 刷新 PR 列表 | +| `repo ` | 切换仓库 | + +## 脚本 + +- `scripts/list_prs.sh` — 列出仓库开放 PR(JSON → 格式化表格,支持 `-a` 翻页) +- `scripts/view_pr.sh` — 获取 PR 完整信息(详情+diff+评论+提交,支持 `-d`/`-v`/`-a`) +- `scripts/clone_pr.sh` — 克隆 PR 并检测项目类型,支持多语言自动初始化 +- `scripts/ci_pr.sh` — 查看 CI 状态,分析失败原因,重跑失败 Job(`--analyze`/`--rerun`/`--wait`) + +## 详细参考 + +- `references/workflows.md` — 完整工作流细节、示例对话、多仓库管理 +- `references/error-handling.md` — 所有错误场景及处理方式 diff --git a/skills/github-pr-reviewer/SKILL.md b/skills/github-pr-reviewer/SKILL.md index ae15af6..bbb649a 100644 --- a/skills/github-pr-reviewer/SKILL.md +++ b/skills/github-pr-reviewer/SKILL.md @@ -1,11 +1,11 @@ --- name: github-pr-reviewer description: > - GitHub PR 代码审查器 — 使用 GitHub MCP 工具在 PR 上创建逐行 inline 审查评论。 - 自动拉取 PR diff、分析代码变更、创建 pending review、逐行添加 inline 评论、 - 提交审查结论(APPROVE/REQUEST_CHANGES/COMMENT)。 - 当你需要审查 PR、检查代码质量、review 代码、或对 PR 提出具体行级建议时使用此技能。 - 即使用户只说「帮我 review 这个 PR」或「看看这个代码有什么问题」也应触发。 + GitHub PR Code Reviewer — Creates line-by-line inline review comments on PRs using GitHub MCP tools. + Automatically fetches the PR diff, analyzes code changes, creates a pending review, adds inline comments line by line, + and submits a review conclusion (APPROVE/REQUEST_CHANGES/COMMENT). + Use this skill when you need to review a PR, check code quality, or provide specific line-level suggestions on a PR. + Should trigger even if the user simply says "review this PR" or "see what's wrong with this code". capabilities: ["pr-review", "code-review", "inline-comments"] integrates_with: ["pr-management", "skill-discovery"] metadata: @@ -13,42 +13,42 @@ metadata: risk: safe --- -# GitHub PR 审查器 +# GitHub PR Reviewer -在 GitHub Pull Request 上执行代码审查,使用 GitHub MCP 工具创建 **逐行 inline 评论**——这是本技能与现有审查技能的核心区别。 +Performs code reviews on GitHub Pull Requests, using GitHub MCP tools to create **line-by-line inline comments** — this is the core distinction from other review skills. -## 前置条件 +## Prerequisites -- **必须**:GitHub MCP Server(`plugin:github:github`)已配置并连接 -- **可选降级**:`gh` CLI(≥ 2.0.0)— 当 MCP 不可用时作为降级方案 +- **Required**: GitHub MCP Server (`plugin:github:github`) configured and connected +- **Optional fallback**: `gh` CLI (>= 2.0.0) — serves as a fallback when MCP is unavailable -启动时先验证 MCP 工具可用性: +Verify MCP tool availability on startup: ``` 方法:尝试调用 pull_request_read 获取任意公开 PR 的元信息 如果失败 → 提示用户配置 GitHub MCP Server,同时启用 gh CLI 降级模式 ``` -## 包联动 +## Package Linking -本技能支持在 minecraft269-skills 插件包内与兄弟技能联动。 +This skill supports linking with sibling skills within the minecraft269-skills plugin package. -**联动钩子(仅 PACKAGE_MODE = true 时执行):** +**Linkage Hooks (executed only when PACKAGE_MODE = true):** -检测方法: -1. 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` 是否存在 -2. 如存在 → PACKAGE_MODE = true,执行以下联动逻辑 -3. 如不存在 → PACKAGE_MODE = false,跳过所有联动引用 +Detection method: +1. Glob search for `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. If found → PACKAGE_MODE = true, execute the linkage logic below +3. If not found → PACKAGE_MODE = false, skip all linkage references -### 阶段 0 联动:从 github-pr-manager 获取上下文 +### Phase 0 Linkage: Get context from github-pr-manager -当 PACKAGE_MODE = true 且对话上下文中存在以下信号时,用户可能已通过 github-pr-manager 选中了 PR: +When PACKAGE_MODE = true and the following signals are present in the conversation context, the user may have already selected a PR via github-pr-manager: -- 对话中最近出现了 `pull_request_read` 或 `gh pr view` 调用 -- 用户输入了 PR 编号但未指定仓库 -- 对话上下文中有 `owner/repo` 格式的仓库标识 +- A recent `pull_request_read` or `gh pr view` call appears in the conversation +- The user entered a PR number without specifying the repository +- A repository identifier in `owner/repo` format is present in the conversation context -**联动操作:** +**Linkage operation:** ``` 如果检测到上述信号 → 主动询问用户: 「检测到你正在查看 [owner/repo] 的 PR #[N]。是否对此 PR 执行代码审查?」 @@ -56,43 +56,43 @@ metadata: - 如果用户拒绝 → 照常询问仓库和 PR 编号 ``` -### 审查完成后联动 +### Post-Review Linkage -审查提交后,扫描兄弟技能的 capabilities: +After the review is submitted, scan sibling skills' capabilities: -- 匹配 `pr-management` → 提示:「💡 可使用 **GitHub PR 管理器** 查看其他 PR 或克隆此 PR 到本地」 -- 匹配 `skill-discovery` → 提示:「💡 可运行 **主动技能发现** 获取当前项目的更多工具推荐」 +- Matches `pr-management` → Prompt: "💡 You can use **GitHub PR Manager** to view other PRs or clone this PR locally" +- Matches `skill-discovery` → Prompt: "💡 You can run **Proactive Skill Discovery** to get more tool recommendations for the current project" -独立模式(PACKAGE_MODE = false)时,上述联动提示完全不显示。 +In Standalone Mode (PACKAGE_MODE = false), none of the above linkage prompts are displayed. --- -## 三阶段审查工作流 +## Three-Phase Review Workflow -以下三个阶段必须严格按顺序执行。每个阶段完成后才能进入下一阶段。 +The following three phases must be executed strictly in order. Do not proceed to the next phase until the current one is complete. -### 阶段 0:识别目标 PR +### Phase 0: Identify Target PR -确定要审查的 PR 身份。按以下优先级获取: +Determine the PR to review. Obtain it in the following priority order: -1. **联动上下文**(PACKAGE_MODE = true):从 github-pr-manager 的会话上下文提取仓库和 PR 编号 -2. **用户直接提供**:用户说了目标仓库和 PR 编号(如「审查 Minecraft269/skills #5」) -3. **主动询问**:如果以上都不可用,询问用户: +1. **Linkage context** (PACKAGE_MODE = true): Extract the repository and PR number from github-pr-manager's session context +2. **User provides directly**: The user states the target repository and PR number (e.g., "review Minecraft269/skills #5") +3. **Ask proactively**: If neither is available, ask the user: ``` 「请提供要审查的 PR: - 仓库:owner/repo - PR 编号:#N」 ``` -获取后立即验证 PR 存在: +Once obtained, immediately verify the PR exists: ``` pull_request_read(method="get", owner, repo, pullNumber) ``` -如果返回错误 → 提示用户检查仓库名和 PR 编号。 +If an error is returned → Prompt the user to check the repository name and PR number. -### 阶段 1:获取审查上下文 +### Phase 1: Gather Review Context -在开始审查前,并行获取 PR 的完整上下文。以下四个调用可以同时进行: +Before starting the review, fetch the PR's full context in parallel. The following four calls can be made simultaneously: ``` pull_request_read(method="get_diff", owner, repo, pullNumber) @@ -108,50 +108,50 @@ pull_request_read(method="get_reviews", owner, repo, pullNumber) → 获取整体审查状态(已 APPROVED / CHANGES_REQUESTED / 无审查) ``` -**输出:** 汇总 PR 上下文信息给用户: +**Output:** Summarize the PR context information for the user: -| 指标 | 数值 | -|------|------| -| 变更文件 | N 个 | -| 新增行 | +M | -| 删除行 | -K | -| 已有审查 | X 条(状态) | -| 已有 inline 评论 | Y 条 | +| Metric | Value | +|--------|-------| +| Changed files | N | +| Lines added | +M | +| Lines deleted | -K | +| Existing reviews | X (status) | +| Existing inline comments | Y | -### 阶段 2:分析代码并发布 inline 评论 +### Phase 2: Analyze Code and Publish Inline Comments -这是本技能的核心价值——**逐行 inline 评论**。 +This is the skill's Core Value — **line-by-line inline comments**. -#### 2a. 分析 diff,生成审查发现 +#### 2a. Analyze Diff, Generate Review Findings -根据 `references/review-checklist.md` 中的检查清单分析 diff。每条发现记录: +Analyze the diff against the checklist in `references/review-checklist.md`. Each finding includes: -| 字段 | 说明 | 示例 | -|------|------|------| -| `path` | 文件相对路径 | `src/auth/login.ts` | -| `line` | **diff 中的行号**(见下方重要说明) | `42` | -| `side` | `"LEFT"`(旧代码)或 `"RIGHT"`(新代码) | `"RIGHT"` | -| `body` | 评论正文(结构化 Markdown) | 见下方模板 | +| Field | Description | Example | +|-------|-------------|---------| +| `path` | File relative path | `src/auth/login.ts` | +| `line` | **Line number in the diff** (see important note below) | `42` | +| `side` | `"LEFT"` (old code) or `"RIGHT"` (new code) | `"RIGHT"` | +| `body` | Comment body (structured Markdown) | See template below | | `severity` | `critical` / `warning` / `suggestion` / `praise` | `warning` | | `category` | `bug` / `security` / `performance` / `design` / `best-practice` / `nitpick` | `security` | -**⚠️ 行号至关重要:** `add_comment_to_pending_review` 的 `line` 参数必须使用 **PR diff 中的行号**,而非源文件行号。详见 `references/diff-line-mapping.md`。核心规则: +**⚠️ Line numbers are critical:** The `line` parameter of `add_comment_to_pending_review` must use the **line number from the PR diff**, not the source file line number. See `references/diff-line-mapping.md` for details. Core rules: -- Unified diff 中 `@@ -a,b +c,d @@` 标记了 hunk 位置 -- 新代码(`+` 开头)的 diff 行号 ≠ 源文件行号 -- 使用 `scripts/parse_diff_lines.sh` 脚本辅助提取 -- 如果无法确定正确的 diff 行号,降级为文件级评论(`subjectType="FILE"`) +- In a unified diff, `@@ -a,b +c,d @@` marks the hunk position +- The diff line number for new code (starting with `+`) ≠ the source file line number +- Use the `scripts/parse_diff_lines.sh` script to help extract them +- If the correct diff line number cannot be determined, fall back to a file-level comment (`subjectType="FILE"`) -#### 2b. 展示完整审查预览(必须向用户展示并获得确认) +#### 2b. Display Full Review Preview (Must Show to User and Get Confirmation) -**在调用任何 GitHub API 之前**,必须将每条审查发现以完整的格式化预览展示给用户。完整的预览格式模板见 `references/review-preview-template.md`。 +**Before calling any GitHub API**, each review finding must be displayed to the user as a complete formatted preview. See `references/review-preview-template.md` for the full preview format template. -核心规则: -- 每条发现必须完整展开评论文本、建议修复、代码示例和 diff 上下文 -- 审查模型名称必须从系统提示上下文中获取实际值,不可编造 -- 必须等待用户确认后才能进入阶段 2c +Core rules: +- Each finding must fully expand the comment text, suggested fix, code example, and diff context +- The review model name must be obtained from the system prompt context, never fabricated +- Must wait for user confirmation before proceeding to Phase 2c -#### 2c. 创建 pending review +#### 2c. Create Pending Review ``` pull_request_review_write( @@ -161,25 +161,25 @@ pull_request_review_write( ) ``` -**不传 `event` 参数** — 这创建一个待定(pending)状态的 review,后续 inline 评论将添加到这个 pending review 中。 +**Do not pass the `event` parameter** — this creates a pending review, and subsequent inline comments will be added to this pending review. -**如果返回错误(已有 pending review):** -- 先调用 `pull_request_review_write(method="delete_pending", ...)` 删除旧 review -- 再重新创建 +**If an error is returned (existing pending review):** +- First call `pull_request_review_write(method="delete_pending", ...)` to delete the old review +- Then create it again -#### 2d. 逐条添加 inline 评论 +#### 2d. Add Inline Comments One by One -对每条审查发现,调用 `add_comment_to_pending_review`(owner, repo, pullNumber, path, body, line, side, subjectType="LINE")。 +For each review finding, call `add_comment_to_pending_review` (owner, repo, pullNumber, path, body, line, side, subjectType="LINE"). -评论正文模板和类别图标映射见 `references/comment-templates.md`。 +See `references/comment-templates.md` for comment body templates and category icon mappings. -添加策略:按严重程度排序(critical → warning → suggestion → praise),适当间隔避免 API rate limit,添加失败时记录并继续,已有评论位置跳过。 +Adding strategy: Sort by severity (critical → warning → suggestion → praise), space out calls appropriately to avoid API rate limits, log and continue if adding fails, skip locations with existing comments. -### 阶段 3:提交审查结论 +### Phase 3: Submit Review Conclusion -#### 3a. 汇总并确认 +#### 3a. Summary and Confirmation -向用户展示审查完成统计: +Display the review completion statistics to the user: ``` ## 审查完成 @@ -194,12 +194,12 @@ pull_request_review_write( 请选择审查结论: ``` -使用 `AskUserQuestion` 提供三个选项: -- **Approve** — 批准合并(代码质量良好,无阻塞问题) -- **Request Changes** — 要求修改(存在需要修复的严重问题) -- **Comment** — 仅提建议(中立,不阻塞合并) +Use `AskUserQuestion` to provide three options: +- **Approve** — Approve the merge (code quality is good, no blocking issues) +- **Request Changes** — Request modifications (there are serious issues that need fixing) +- **Comment** — Comment only (neutral, does not block the merge) -#### 3b. 提交审查 +#### 3b. Submit Review ``` pull_request_review_write( @@ -210,7 +210,7 @@ pull_request_review_write( ) ``` -#### 3c. 输出最终结果 +#### 3c. Output Final Result ``` ✅ 审查已提交 @@ -223,37 +223,37 @@ PR [#N](https://github.com/owner/repo/pull/N) 审查完成 --- -## 审查焦点 +## Review Focus -详细检查清单见 `references/review-checklist.md`。审查时按优先级聚焦: +See `references/review-checklist.md` for the detailed checklist. Focus the review by priority: -| 优先级 | 类别 | 默认行为 | -|--------|------|---------| -| P0 | 正确性缺陷 | **始终审查** | -| P1 | 安全问题 | **始终审查** | -| P2 | 性能问题 | **始终审查** | -| P3 | 设计问题 | 仅 `--thorough` 模式 | -| P4 | 最佳实践 | 仅 `--thorough` 模式 | -| P5 | 锦上添花 | 仅 `--thorough` 模式 | +| Priority | Category | Default Behavior | +|----------|----------|-----------------| +| P0 | Correctness defects | **Always review** | +| P1 | Security issues | **Always review** | +| P2 | Performance issues | **Always review** | +| P3 | Design issues | `--thorough` only | +| P4 | Best practices | `--thorough` only | +| P5 | Polish / nits | `--thorough` only | --- -## 错误处理与降级 +## Error Handling and Degradation -### 错误场景速查 +### Error Scenario Quick Reference -| 错误 | 原因 | 处理 | -|------|------|------| -| PR 不存在 | 编号错误或无权限 | 提示用户确认仓库和 PR 编号 | -| `add_comment_to_pending_review` 失败 | 无 pending review | 先创建 pending review,再重试 | -| `pull_request_review_write("create")` 冲突 | 已有旧 pending review | 先删除旧的,再创建新的 | -| 行号无效 | diff 行号计算错误 | 检查行号 → 重试 → 仍失败则降级为文件级评论 | -| MCP 工具调用全部失败 | GitHub MCP 未配置 | 切换到 `gh` CLI 降级模式(见下方) | -| API rate limit | 请求过多 | 等待 60s 后重试 | +| Error | Cause | Handling | +|-------|-------|----------| +| PR does not exist | Wrong number or no permission | Prompt the user to confirm the repository and PR number | +| `add_comment_to_pending_review` fails | No pending review | Create a pending review first, then retry | +| `pull_request_review_write("create")` conflict | Existing old pending review | Delete the old one first, then create a new one | +| Invalid line number | Incorrect diff line number | Check the line number → retry → if still fails, fall back to file-level comment | +| All MCP tool calls fail | GitHub MCP not configured | Switch to `gh` CLI degradation mode (see below) | +| API rate limit | Too many requests | Wait 60s and retry | -### gh CLI 降级模式 +### gh CLI Degradation Mode -当 GitHub MCP 不可用时: +When GitHub MCP is unavailable: ``` # 替代阶段 1 — 获取 diff @@ -263,27 +263,27 @@ gh pr diff --repo gh pr review --repo --approve/--request-changes/--comment --body "..." ``` -降级模式下无法发布 inline 评论。告知用户这一限制,并提供审查报告的 Markdown 文本供用户手动发布。 +In degradation mode, inline comments cannot be published. Inform the user of this limitation and provide the review report in Markdown for manual posting. --- -## 命令速查 +## Command Quick Reference -| 用户输入 | 说明 | -|---------|------| -| `review #` | 审查指定仓库的指定 PR | -| `review #` | 审查当前仓库的 PR(需联动上下文) | -| `review` | 审查当前 PR(需联动上下文) | -| `review --thorough` | 全面审查模式(含 P3-P5) | -| `review --summary-only` | 仅输出审查摘要,不发布到 GitHub | +| User input | Description | +|------------|-------------| +| `review #` | Review a specific PR in a specific repository | +| `review #` | Review a PR in the current repository (requires linkage context) | +| `review` | Review the current PR (requires linkage context) | +| `review --thorough` | Thorough review mode (includes P3-P5) | +| `review --summary-only` | Output review summary only, do not publish to GitHub | -## 脚本 +## Scripts -- `scripts/parse_diff_lines.sh` — 从 unified diff 输出中提取文件路径和对应的 diff 行号。用于辅助 `add_comment_to_pending_review` 的行号参数计算。 +- `scripts/parse_diff_lines.sh` — Extracts file paths and corresponding diff line numbers from unified diff output. Used to help calculate the line number parameter for `add_comment_to_pending_review`. -## 参考文档 +## References -- `references/review-checklist.md` — 代码审查检查清单,按 P0-P5 优先级分层 -- `references/diff-line-mapping.md` — Unified diff 格式解析与行号映射技术指南 -- `references/review-preview-template.md` — 审查预览格式模板和重要规则 -- `references/comment-templates.md` — inline 评论正文模板、类别图标映射和添加策略 +- `references/review-checklist.md` — Code review checklist, organized by P0-P5 priority levels +- `references/diff-line-mapping.md` — Unified diff format parsing and line number mapping technical guide +- `references/review-preview-template.md` — Review preview format template and important rules +- `references/comment-templates.md` — Inline comment body templates, category icon mappings, and adding strategy diff --git a/skills/github-pr-reviewer/locale/SKILL.cn.md b/skills/github-pr-reviewer/locale/SKILL.cn.md new file mode 100644 index 0000000..88096c1 --- /dev/null +++ b/skills/github-pr-reviewer/locale/SKILL.cn.md @@ -0,0 +1,290 @@ +--- +name: github-pr-reviewer +description: > + GitHub PR 代码审查器 — 使用 GitHub MCP 工具在 PR 上创建逐行 inline 审查评论。 + 自动拉取 PR diff、分析代码变更、创建 pending review、逐行添加 inline 评论、 + 提交审查结论(APPROVE/REQUEST_CHANGES/COMMENT)。 + 当你需要审查 PR、检查代码质量、review 代码、或对 PR 提出具体行级建议时使用此技能。 + 即使用户只说「帮我 review 这个 PR」或「看看这个代码有什么问题」也应触发。 +capabilities: ["pr-review", "code-review", "inline-comments"] +integrates_with: ["pr-management", "skill-discovery"] +metadata: + compatibility: "需要 GitHub MCP Server(plugin:github:github)" + risk: safe +locale: zh-CN +--- + +# GitHub PR 审查器 + +在 GitHub Pull Request 上执行代码审查,使用 GitHub MCP 工具创建 **逐行 inline 评论**——这是本技能与现有审查技能的核心区别。 + +## 前置条件 + +- **必须**:GitHub MCP Server(`plugin:github:github`)已配置并连接 +- **可选降级**:`gh` CLI(≥ 2.0.0)— 当 MCP 不可用时作为降级方案 + +启动时先验证 MCP 工具可用性: + +``` +方法:尝试调用 pull_request_read 获取任意公开 PR 的元信息 +如果失败 → 提示用户配置 GitHub MCP Server,同时启用 gh CLI 降级模式 +``` + +## 包联动 + +本技能支持在 minecraft269-skills 插件包内与兄弟技能联动。 + +**联动钩子(仅 PACKAGE_MODE = true 时执行):** + +检测方法: +1. 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` 是否存在 +2. 如存在 → PACKAGE_MODE = true,执行以下联动逻辑 +3. 如不存在 → PACKAGE_MODE = false,跳过所有联动引用 + +### 阶段 0 联动:从 github-pr-manager 获取上下文 + +当 PACKAGE_MODE = true 且对话上下文中存在以下信号时,用户可能已通过 github-pr-manager 选中了 PR: + +- 对话中最近出现了 `pull_request_read` 或 `gh pr view` 调用 +- 用户输入了 PR 编号但未指定仓库 +- 对话上下文中有 `owner/repo` 格式的仓库标识 + +**联动操作:** +``` +如果检测到上述信号 → 主动询问用户: +「检测到你正在查看 [owner/repo] 的 PR #[N]。是否对此 PR 执行代码审查?」 +- 如果用户确认 → 直接进入阶段 1,跳过仓库/PR 询问 +- 如果用户拒绝 → 照常询问仓库和 PR 编号 +``` + +### 审查完成后联动 + +审查提交后,扫描兄弟技能的 capabilities: + +- 匹配 `pr-management` → 提示:「💡 可使用 **GitHub PR 管理器** 查看其他 PR 或克隆此 PR 到本地」 +- 匹配 `skill-discovery` → 提示:「💡 可运行 **主动技能发现** 获取当前项目的更多工具推荐」 + +独立模式(PACKAGE_MODE = false)时,上述联动提示完全不显示。 + +--- + +## 三阶段审查工作流 + +以下三个阶段必须严格按顺序执行。每个阶段完成后才能进入下一阶段。 + +### 阶段 0:识别目标 PR + +确定要审查的 PR 身份。按以下优先级获取: + +1. **联动上下文**(PACKAGE_MODE = true):从 github-pr-manager 的会话上下文提取仓库和 PR 编号 +2. **用户直接提供**:用户说了目标仓库和 PR 编号(如「审查 Minecraft269/skills #5」) +3. **主动询问**:如果以上都不可用,询问用户: + ``` + 「请提供要审查的 PR: + - 仓库:owner/repo + - PR 编号:#N」 + ``` + +获取后立即验证 PR 存在: +``` +pull_request_read(method="get", owner, repo, pullNumber) +``` +如果返回错误 → 提示用户检查仓库名和 PR 编号。 + +### 阶段 1:获取审查上下文 + +在开始审查前,并行获取 PR 的完整上下文。以下四个调用可以同时进行: + +``` +pull_request_read(method="get_diff", owner, repo, pullNumber) + → 获取完整 unified diff — 这是审查的核心材料 + +pull_request_read(method="get_files", owner, repo, pullNumber) + → 获取变更文件列表(含每个文件的 additions/deletions/changes 统计) + +pull_request_read(method="get_review_comments", owner, repo, pullNumber) + → 获取已有 inline 审查评论 — 用于避免重复评论同一位置 + +pull_request_read(method="get_reviews", owner, repo, pullNumber) + → 获取整体审查状态(已 APPROVED / CHANGES_REQUESTED / 无审查) +``` + +**输出:** 汇总 PR 上下文信息给用户: + +| 指标 | 数值 | +|------|------| +| 变更文件 | N 个 | +| 新增行 | +M | +| 删除行 | -K | +| 已有审查 | X 条(状态) | +| 已有 inline 评论 | Y 条 | + +### 阶段 2:分析代码并发布 inline 评论 + +这是本技能的核心价值——**逐行 inline 评论**。 + +#### 2a. 分析 diff,生成审查发现 + +根据 `references/review-checklist.md` 中的检查清单分析 diff。每条发现记录: + +| 字段 | 说明 | 示例 | +|------|------|------| +| `path` | 文件相对路径 | `src/auth/login.ts` | +| `line` | **diff 中的行号**(见下方重要说明) | `42` | +| `side` | `"LEFT"`(旧代码)或 `"RIGHT"`(新代码) | `"RIGHT"` | +| `body` | 评论正文(结构化 Markdown) | 见下方模板 | +| `severity` | `critical` / `warning` / `suggestion` / `praise` | `warning` | +| `category` | `bug` / `security` / `performance` / `design` / `best-practice` / `nitpick` | `security` | + +**⚠️ 行号至关重要:** `add_comment_to_pending_review` 的 `line` 参数必须使用 **PR diff 中的行号**,而非源文件行号。详见 `references/diff-line-mapping.md`。核心规则: + +- Unified diff 中 `@@ -a,b +c,d @@` 标记了 hunk 位置 +- 新代码(`+` 开头)的 diff 行号 ≠ 源文件行号 +- 使用 `scripts/parse_diff_lines.sh` 脚本辅助提取 +- 如果无法确定正确的 diff 行号,降级为文件级评论(`subjectType="FILE"`) + +#### 2b. 展示完整审查预览(必须向用户展示并获得确认) + +**在调用任何 GitHub API 之前**,必须将每条审查发现以完整的格式化预览展示给用户。完整的预览格式模板见 `references/review-preview-template.md`。 + +核心规则: +- 每条发现必须完整展开评论文本、建议修复、代码示例和 diff 上下文 +- 审查模型名称必须从系统提示上下文中获取实际值,不可编造 +- 必须等待用户确认后才能进入阶段 2c + +#### 2c. 创建 pending review + +``` +pull_request_review_write( + method="create", + owner, repo, pullNumber, + body="正在审查中..." +) +``` + +**不传 `event` 参数** — 这创建一个待定(pending)状态的 review,后续 inline 评论将添加到这个 pending review 中。 + +**如果返回错误(已有 pending review):** +- 先调用 `pull_request_review_write(method="delete_pending", ...)` 删除旧 review +- 再重新创建 + +#### 2d. 逐条添加 inline 评论 + +对每条审查发现,调用 `add_comment_to_pending_review`(owner, repo, pullNumber, path, body, line, side, subjectType="LINE")。 + +评论正文模板和类别图标映射见 `references/comment-templates.md`。 + +添加策略:按严重程度排序(critical → warning → suggestion → praise),适当间隔避免 API rate limit,添加失败时记录并继续,已有评论位置跳过。 + +### 阶段 3:提交审查结论 + +#### 3a. 汇总并确认 + +向用户展示审查完成统计: + +``` +## 审查完成 + +| 指标 | 数值 | +|------|------| +| inline 评论 | N 条(成功)/ M 条(失败)/ K 条(跳过) | +| 覆盖文件 | F 个 | +| 严重问题 | C 条 | +| 建议 | S 条 | + +请选择审查结论: +``` + +使用 `AskUserQuestion` 提供三个选项: +- **Approve** — 批准合并(代码质量良好,无阻塞问题) +- **Request Changes** — 要求修改(存在需要修复的严重问题) +- **Comment** — 仅提建议(中立,不阻塞合并) + +#### 3b. 提交审查 + +``` +pull_request_review_write( + method="submit_pending", + owner, repo, pullNumber, + event=<用户选择>, + body=<审查总结> +) +``` + +#### 3c. 输出最终结果 + +``` +✅ 审查已提交 + +PR [#N](https://github.com/owner/repo/pull/N) 审查完成 +- 结论:{APPROVED | CHANGES_REQUESTED | COMMENTED} +- inline 评论:N 条,覆盖 M 个文件 +- 审查模型:<模型名> +``` + +--- + +## 审查焦点 + +详细检查清单见 `references/review-checklist.md`。审查时按优先级聚焦: + +| 优先级 | 类别 | 默认行为 | +|--------|------|---------| +| P0 | 正确性缺陷 | **始终审查** | +| P1 | 安全问题 | **始终审查** | +| P2 | 性能问题 | **始终审查** | +| P3 | 设计问题 | 仅 `--thorough` 模式 | +| P4 | 最佳实践 | 仅 `--thorough` 模式 | +| P5 | 锦上添花 | 仅 `--thorough` 模式 | + +--- + +## 错误处理与降级 + +### 错误场景速查 + +| 错误 | 原因 | 处理 | +|------|------|------| +| PR 不存在 | 编号错误或无权限 | 提示用户确认仓库和 PR 编号 | +| `add_comment_to_pending_review` 失败 | 无 pending review | 先创建 pending review,再重试 | +| `pull_request_review_write("create")` 冲突 | 已有旧 pending review | 先删除旧的,再创建新的 | +| 行号无效 | diff 行号计算错误 | 检查行号 → 重试 → 仍失败则降级为文件级评论 | +| MCP 工具调用全部失败 | GitHub MCP 未配置 | 切换到 `gh` CLI 降级模式(见下方) | +| API rate limit | 请求过多 | 等待 60s 后重试 | + +### gh CLI 降级模式 + +当 GitHub MCP 不可用时: + +``` +# 替代阶段 1 — 获取 diff +gh pr diff --repo + +# 替代阶段 2+3 — 发布审查(仅整体评论,无 inline) +gh pr review --repo --approve/--request-changes/--comment --body "..." +``` + +降级模式下无法发布 inline 评论。告知用户这一限制,并提供审查报告的 Markdown 文本供用户手动发布。 + +--- + +## 命令速查 + +| 用户输入 | 说明 | +|---------|------| +| `review #` | 审查指定仓库的指定 PR | +| `review #` | 审查当前仓库的 PR(需联动上下文) | +| `review` | 审查当前 PR(需联动上下文) | +| `review --thorough` | 全面审查模式(含 P3-P5) | +| `review --summary-only` | 仅输出审查摘要,不发布到 GitHub | + +## 脚本 + +- `scripts/parse_diff_lines.sh` — 从 unified diff 输出中提取文件路径和对应的 diff 行号。用于辅助 `add_comment_to_pending_review` 的行号参数计算。 + +## 参考文档 + +- `references/review-checklist.md` — 代码审查检查清单,按 P0-P5 优先级分层 +- `references/diff-line-mapping.md` — Unified diff 格式解析与行号映射技术指南 +- `references/review-preview-template.md` — 审查预览格式模板和重要规则 +- `references/comment-templates.md` — inline 评论正文模板、类别图标映射和添加策略 diff --git a/skills/quick-plugin-installer/SKILL.md b/skills/quick-plugin-installer/SKILL.md index 3f1e69d..642a088 100644 --- a/skills/quick-plugin-installer/SKILL.md +++ b/skills/quick-plugin-installer/SKILL.md @@ -1,164 +1,166 @@ --- name: quick-plugin-installer description: > - 快速安装插件(MCP Server 与 SKILL 插件)— 统一入口,自动识别类型,完成注册、安装、自动升级配置、 - MCP 接入验证。当你需要安装任何 Claude Code 插件、MCP Server、SKILL 技能、或 Marketplace 来源 - 的扩展时使用此技能。支持 GitHub repo、Marketplace 名称、本地路径、MCP Registry 等多种来源。 + Quick plugin installer (MCP Server and SKILL plugins) — unified entry point, + automatic type detection, registration, installation, auto-update configuration, + and MCP connection verification. Use this skill when you need to install any + Claude Code plugin, MCP Server, SKILL skill, or Marketplace extension. Supports + GitHub repo, Marketplace name, local path, MCP Registry, and other sources. capabilities: ["plugin-installation", "mcp-setup"] integrates_with: ["skill-discovery"] metadata: - compatibility: "需要 gh (GitHub CLI)、jq、claude CLI" + compatibility: "Requires gh (GitHub CLI), jq, claude CLI" risk: safe --- -# 快速安装插件 +# Quick Plugin Installer -一键完成 Claude Code 插件(MCP Server 和 SKILL 插件)的发现、注册、安装、自动升级配置。 +One-click discovery, registration, installation, and auto-update configuration for Claude Code plugins (MCP Server and SKILL plugins). -## 包联动 +## Package Linking -本技能支持与 minecraft269-skills 插件包内其他技能自动联动。执行以下检测: +This skill supports automatic linking with other skills in the minecraft269-skills plugin package. The following detection is performed: -1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` -2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 -3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级) +1. Glob search for `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. If found → `PACKAGE_MODE = true`, enabling discovery and linking of sibling skills +3. If not found → `PACKAGE_MODE = false`, skipping all cross-skill logic (silent degradation) -当 `PACKAGE_MODE = true` 时: -- 安装完成后可联动 `integrates_with: skill-discovery`(技能发现) -- 扫描兄弟 SKILL.md 的 `capabilities` 字段,匹配本技能的 `integrates_with` 标签 -- 仅在匹配成功时显示联动提示 +When `PACKAGE_MODE = true`: +- After installation, can link with `integrates_with: skill-discovery` +- Scans sibling SKILL.md `capabilities` fields for matches against this skill's `integrates_with` tags +- Only displays linking hints when a match is found -详见 `_shared/package-context.md`。 +See `_shared/package-context.md` for details. -## 核心工作流 +## Core Workflow -### 1. 识别插件类型 +### 1. Identify Plugin Type -用户只需提供一个标识符,技能自动判断目标类型。 +The user only needs to provide an identifier; the skill automatically determines the target type. -**触发方式:** -- 用户直接输入来源:`/install-plugin <来源>` -- 或自然语言:「安装 GitHub MCP」「帮我装 Minecraft269/skills」 +**Trigger Methods:** +- User directly inputs a source: `/install-plugin ` +- Or natural language: "Install GitHub MCP", "Help me install Minecraft269/skills" -**判断逻辑:** +**Detection Logic:** -| 特征 | 类型 | +| Characteristic | Type | |------|------| -| 来源包含 `mcp`、`server`、`MCP Server` 等关键字 | **MCP Server** | -| 来源是 GitHub 仓库格式(`owner/repo`)且描述为技能/插件集市 | **SKILL 插件(Marketplace)** | -| 来源是本地路径(`./xxx`、`/xxx`、`D:\xxx`) | **SKILL 插件(本地)** | -| 无法自动判断 | 交互式询问用户 | +| Source contains `mcp`, `server`, `MCP Server` or similar keywords | **MCP Server** | +| Source is a GitHub repo format (`owner/repo`) described as a skill/plugin marketplace | **SKILL Plugin (Marketplace)** | +| Source is a local path (`./xxx`, `/xxx`, `D:\xxx`) | **SKILL Plugin (Local)** | +| Cannot determine automatically | Ask the user interactively | -**交互式询问模板:** -> "无法自动判断 `{来源}` 的类型。请选择: -> 1. SKILL 插件(来自 Marketplace 或本地目录) -> 2. MCP Server(需要在 settings.json 中配置) -> 3. 查看详情后再决定" +**Interactive Prompt Template:** +> "Cannot automatically determine the type of `{source}`. Please select: +> 1. SKILL Plugin (from Marketplace or local directory) +> 2. MCP Server (requires configuration in settings.json) +> 3. View details and decide later" -### 2. 已有安装检测(安装前必须执行) +### 2. Existing Installation Detection (Must Perform Before Installation) -在正式安装前,先检查目标是否已存在: +Before installing, check whether the target already exists: -- **SKILL 插件**:检查 `~/.claude/plugins/<插件名>/` 目录或 `claude plugins list` 输出 -- **MCP Server**:检查 `~/.claude/settings.json` 中 `mcpServers.` 是否已存在 +- **SKILL Plugin**: Check `~/.claude/plugins//` directory or `claude plugins list` output +- **MCP Server**: Check whether `mcpServers.` already exists in `~/.claude/settings.json` -如果已安装,必须交互式询问用户下一步操作: +If already installed, prompt the user interactively for the next action: ```markdown -⚠️ {插件名} 已经安装。 - -当前状态: -- 📛 名称: {name} -- 📂 位置: {安装路径} -- 🔢 版本: {version}(如可获取) - -请选择操作: -1. 🔄 重新安装(覆盖当前版本) -2. ⬆️ 更新到最新版本 -3. 🗑️ 卸载此插件 -4. 📋 查看详情(安装路径、配置、依赖) -5. ✅ 跳过,保持现状 +⚠️ {plugin-name} is already installed. + +Current Status: +- 📛 Name: {name} +- 📂 Location: {install path} +- 🔢 Version: {version} (if available) + +Please choose an action: +1. 🔄 Reinstall (overwrite current version) +2. ⬆️ Update to latest version +3. 🗑️ Uninstall this plugin +4. 📋 View details (install path, config, dependencies) +5. ✅ Skip, keep as is ``` -**执行对应操作:** +**Execute the Corresponding Action:** -| 用户选择 | 执行 | +| User Choice | Action | |---------|------| -| 重新安装 | 先卸载 → 再安装(保留配置) | -| 更新 | SKILL:`claude plugins update `;MCP:运行更新检查脚本 | -| 卸载 | SKILL:`claude plugins uninstall `;MCP:从 `settings.json` 移除配置 | -| 查看详情 | 展示安装路径、配置文件内容、最近更新时间 | -| 跳过 | 结束流程,不做任何更改 | +| Reinstall | Uninstall first, then install (preserve config) | +| Update | SKILL: `claude plugins update `; MCP: run update check script | +| Uninstall | SKILL: `claude plugins uninstall `; MCP: remove config from `settings.json` | +| View Details | Show install path, config file content, last updated time | +| Skip | End the flow, make no changes | -### 3. SKILL 插件安装流程 +### 3. SKILL Plugin Installation Flow -#### 3a. 注册 Marketplace +#### 3a. Register Marketplace -如果不是本地路径,先注册来源 Marketplace: +If not a local path, first register the source Marketplace: ```bash -claude plugins marketplace add <来源> +claude plugins marketplace add ``` -- 如果 Marketplace 已注册,检测 `known_marketplaces.json` 跳过此步 -- 注册成功后展示 Marketplace 信息 +- If the Marketplace is already registered, detect via `known_marketplaces.json` and skip this step +- Display Marketplace information after successful registration -#### 3b. 安装插件 +#### 3b. Install Plugin ```bash -claude plugins install <插件名> +claude plugins install ``` -常见映射(从来源提取插件名): +Common mappings (extract plugin name from source): -| 来源 | 插件名 | +| Source | Plugin Name | |------|--------| | `Minecraft269/skills` | `minecraft269-skills` | | `Minecraft269/skills.git` | `minecraft269-skills` | -| 本地 `./my-skill/` | 从 `plugin.json` → `name` 字段提取 | +| Local `./my-skill/` | Extract from `plugin.json` → `name` field | -插件名优先从 `plugin.json` 的 `name` 字段提取,其次从目录名推断。 +The plugin name is extracted first from the `name` field in `plugin.json`, and secondarily inferred from the directory name. -#### 3c. 自动升级配置 +#### 3c. Auto-Update Configuration -检查并启用自动升级: +Check and enable auto-update: -`known_marketplaces.json` 位置:`~/.claude/known_marketplaces.json` +`known_marketplaces.json` location: `~/.claude/known_marketplaces.json` -处理逻辑: -1. 读取 `known_marketplaces.json` -2. 查找匹配的 source URL -3. 设置 `"autoUpdate": true`(如不存在则添加) -4. 写回文件 +Processing logic: +1. Read `known_marketplaces.json` +2. Find the matching source URL +3. Set `"autoUpdate": true` (add if not present) +4. Write back to the file -**如果 Marketplace 不支持自动升级**(本地安装或未知来源),提示用户: -- 「此来源不支持自动升级,需要手动执行 `claude plugins update ` 来更新」 -- 建议用户设置定期提醒或 cron 任务 +**If the Marketplace does not support auto-update** (local install or unknown source), notify the user: +- "This source does not support auto-update. You will need to manually run `claude plugins update ` to update." +- Suggest setting up periodic reminders or a cron task -### 4. MCP Server 安装流程 +### 4. MCP Server Installation Flow -#### 4a. 收集 MCP 配置信息 +#### 4a. Collect MCP Configuration Information -向用户收集必要信息(如未在来源中自动检测到): +Collect necessary information from the user (if not automatically detected from the source): ``` -请提供以下 MCP Server 配置信息: +Please provide the following MCP Server configuration information: -1. 传输协议 (默认: stdio): - - stdio(本地命令行) - - sse(Server-Sent Events) +1. Transport protocol (default: stdio): + - stdio (local command line) + - sse (Server-Sent Events) - streamable-http -2. 启动命令(如 npx、uvx、node 等) +2. Start command (e.g., npx, uvx, node, etc.) -3. 命令参数(如有) +3. Command arguments (if any) -4. 环境变量(如 API keys) +4. Environment variables (e.g., API keys) ``` -#### 4b. 生成并写入 MCP 配置 +#### 4b. Generate and Write MCP Configuration -根据收集的信息,在 `~/.claude/settings.json` 的 `mcpServers` 中添加配置: +Based on the collected information, add the configuration to the `mcpServers` section in `~/.claude/settings.json`: ```json { @@ -175,68 +177,68 @@ claude plugins install <插件名> } ``` -**重要:** 先读取现有 `settings.json`,合并新配置后再写回,不要覆盖已有的其他 MCP Server 配置。 +**Important:** Read the existing `settings.json` first, merge the new configuration, then write back. Do not overwrite existing MCP Server configurations. -#### 4c. MCP 接入验证 +#### 4c. MCP Connection Verification -配置写入后: +After writing the configuration: -1. **检查必要环境变量**是否已设置(如 `GITHUB_TOKEN`、`ANTHROPIC_API_KEY` 等) -2. **提示用户重启 Claude Code** 或重新加载 MCP 连接 -3. **提供快速测试命令**:告诉用户如何验证 MCP 是否正常工作 +1. **Check whether required environment variables** are set (e.g., `GITHUB_TOKEN`, `ANTHROPIC_API_KEY`, etc.) +2. **Prompt the user to restart Claude Code** or reload the MCP connection +3. **Provide a quick test command**: Tell the user how to verify whether the MCP is working ```markdown -> ✅ MCP 配置已写入。请重启 Claude Code 以加载新的 MCP Server。 +> ✅ MCP configuration has been written. Please restart Claude Code to load the new MCP Server. > -> 重启后,可以通过以下方式验证: -> - 查看 MCP 工具是否出现在可用工具列表中 -> - 尝试调用 MCP 工具(如 `mcp____`) +> After restart, you can verify by: +> - Checking whether the MCP tools appear in the available tools list +> - Attempting to call an MCP tool (e.g., `mcp____`) ``` -#### 4d. MCP 更新检查 +#### 4d. MCP Update Check -由于 MCP Server 没有内置的自动升级机制,本技能提供更新检查能力: +Since MCP Server does not have a built-in auto-update mechanism, this skill provides update check capability: -**内置脚本 `scripts/check-mcp-updates.sh`**: -- 检查 GitHub releases、npm registry、或 pip 上的最新版本 -- 与本地配置中记录的版本比较 -- 输出更新建议 +**Built-in script `scripts/check-mcp-updates.sh`:** +- Checks the latest version on GitHub releases, npm registry, or pip +- Compares with the version recorded in the local configuration +- Outputs update suggestions -用户可手动运行或设置 cron 定期执行。 +Users can run it manually or set up a cron task for periodic execution. -### 5. 输出确认摘要 +### 5. Output Confirmation Summary -每次安装完成后,输出格式化摘要: +After each installation, output a formatted summary: ```markdown -✅ 安装完成 +✅ Installation Complete -| 项目 | 详情 | +| Item | Details | |------|------| -| 📦 类型 | {MCP Server / SKILL 插件} | -| 📛 名称 | {插件名或 MCP Server 名} | -| 🔗 来源 | {GitHub repo / 本地路径 / Registry URL} | -| 🔄 自动升级 | {已启用 / 未启用 + 原因 / 需手动检查(MCP 脚本)} | -| ⚠️ 注意事项 | {环境变量 / 认证 / 兼容性提醒} | -| 📝 下一步 | {重启 Claude Code / 运行验证命令 / 配置 API Key} | +| 📦 Type | {MCP Server / SKILL Plugin} | +| 📛 Name | {plugin name or MCP Server name} | +| 🔗 Source | {GitHub repo / local path / Registry URL} | +| 🔄 Auto-Update | {Enabled / Not enabled + reason / Manual check required (MCP script)} | +| ⚠️ Notes | {env vars / authentication / compatibility reminders} | +| 📝 Next Steps | {restart Claude Code / run verification command / configure API Key} | ``` -安装完成后建议用户运行以下命令验证: +After installation, recommend that the user run the following command to verify: ```bash -claude plugins list # 确认插件在列表中 -/discover # 运行技能发现(已合并至 universal-project-kickoff) +claude plugins list # Confirm the plugin is in the list +/discover # Run skill discovery (merged into universal-project-kickoff) ``` -**联动钩子(仅 PACKAGE_MODE = true 时执行):** +**Linking Hook (executed only when PACKAGE_MODE = true):** -安装完成后,扫描兄弟技能的 `capabilities`,匹配 `integrates_with: skill-discovery`: -- 匹配成功 → 提示用户:"💡 安装完成。是否需要运行 **项目启动与能力发现** 来扫描当前项目,查看新安装的能力如何匹配你的技术栈?" -- 用户同意 → 触发技能发现流程 +After installation, scan sibling skills' `capabilities` for matches against `integrates_with: skill-discovery`: +- Match found → Prompt the user: "Installation complete. Would you like to run **Project Kickoff and Capability Discovery** to scan the current project and see how the newly installed capabilities match your tech stack?" +- User agrees → Trigger the skill discovery flow -### 6. 常见 MCP Server 快速安装模板 +### 6. Common MCP Server Quick Install Templates -内置几个常用 MCP Server 的配置模板,简化安装: +Built-in configuration templates for several commonly used MCP Servers, simplifying installation: #### GitHub MCP Server @@ -283,25 +285,25 @@ claude plugins list # 确认插件在列表中 } ``` -更多模板参见 `references/mcp-templates.md`。 +More templates can be found in `references/mcp-templates.md`. -## 错误处理 +## Error Handling -| 场景 | 处理方式 | +| Scenario | Handling Method | |------|---------| -| Marketplace 已注册 | 跳过注册步骤,直接安装 | -| 插件已安装 | 提示用户并询问是否重新安装/更新 | -| `claude` CLI 不可用 | 引导用户先安装 Claude Code CLI | -| `settings.json` 不存在 | 自动创建基础结构 | -| `settings.json` 格式损坏 | 备份原文件并重建 | -| MCP Server 启动失败 | 检查命令是否存在、网络是否可达、环境变量是否设置 | -| 权限不足 | 提示需要管理员权限或使用 `sudo` | +| Marketplace already registered | Skip registration step, install directly | +| Plugin already installed | Prompt the user and ask whether to reinstall/update | +| `claude` CLI not available | Guide the user to install Claude Code CLI first | +| `settings.json` does not exist | Automatically create the basic structure | +| `settings.json` format is corrupted | Back up the original file and rebuild | +| MCP Server fails to start | Check whether the command exists, network is reachable, and environment variables are set | +| Insufficient permissions | Prompt for admin privileges or use `sudo` | -## 脚本 +## Scripts -- `scripts/check-mcp-updates.sh` — MCP Server 更新检查脚本(检查 GitHub/npm/pip 新版本) -- `scripts/toggle-autoupdate.sh` — 切换 `known_marketplaces.json` 中指定来源的 `autoUpdate` 状态 +- `scripts/check-mcp-updates.sh` — MCP Server update check script (checks GitHub/npm/pip for new versions) +- `scripts/toggle-autoupdate.sh` — Toggles the `autoUpdate` status for a specified source in `known_marketplaces.json` -## 参考 +## References -- `references/mcp-templates.md` — 常见 MCP Server 的完整配置模板库 +- `references/mcp-templates.md` — Complete configuration template library for common MCP Servers diff --git a/skills/quick-plugin-installer/locale/SKILL.cn.md b/skills/quick-plugin-installer/locale/SKILL.cn.md new file mode 100644 index 0000000..c815570 --- /dev/null +++ b/skills/quick-plugin-installer/locale/SKILL.cn.md @@ -0,0 +1,308 @@ +--- +name: quick-plugin-installer +description: > + 快速安装插件(MCP Server 与 SKILL 插件)— 统一入口,自动识别类型,完成注册、安装、自动升级配置、 + MCP 接入验证。当你需要安装任何 Claude Code 插件、MCP Server、SKILL 技能、或 Marketplace 来源 + 的扩展时使用此技能。支持 GitHub repo、Marketplace 名称、本地路径、MCP Registry 等多种来源。 +capabilities: ["plugin-installation", "mcp-setup"] +integrates_with: ["skill-discovery"] +metadata: + compatibility: "需要 gh (GitHub CLI)、jq、claude CLI" + risk: safe +locale: zh-CN +--- + +# 快速安装插件 + +一键完成 Claude Code 插件(MCP Server 和 SKILL 插件)的发现、注册、安装、自动升级配置。 + +## 包联动 + +本技能支持与 minecraft269-skills 插件包内其他技能自动联动。执行以下检测: + +1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 +3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级) + +当 `PACKAGE_MODE = true` 时: +- 安装完成后可联动 `integrates_with: skill-discovery`(技能发现) +- 扫描兄弟 SKILL.md 的 `capabilities` 字段,匹配本技能的 `integrates_with` 标签 +- 仅在匹配成功时显示联动提示 + +详见 `_shared/package-context.md`。 + +## 核心工作流 + +### 1. 识别插件类型 + +用户只需提供一个标识符,技能自动判断目标类型。 + +**触发方式:** +- 用户直接输入来源:`/install-plugin <来源>` +- 或自然语言:「安装 GitHub MCP」「帮我装 Minecraft269/skills」 + +**判断逻辑:** + +| 特征 | 类型 | +|------|------| +| 来源包含 `mcp`、`server`、`MCP Server` 等关键字 | **MCP Server** | +| 来源是 GitHub 仓库格式(`owner/repo`)且描述为技能/插件集市 | **SKILL 插件(Marketplace)** | +| 来源是本地路径(`./xxx`、`/xxx`、`D:\xxx`) | **SKILL 插件(本地)** | +| 无法自动判断 | 交互式询问用户 | + +**交互式询问模板:** +> "无法自动判断 `{来源}` 的类型。请选择: +> 1. SKILL 插件(来自 Marketplace 或本地目录) +> 2. MCP Server(需要在 settings.json 中配置) +> 3. 查看详情后再决定" + +### 2. 已有安装检测(安装前必须执行) + +在正式安装前,先检查目标是否已存在: + +- **SKILL 插件**:检查 `~/.claude/plugins/<插件名>/` 目录或 `claude plugins list` 输出 +- **MCP Server**:检查 `~/.claude/settings.json` 中 `mcpServers.` 是否已存在 + +如果已安装,必须交互式询问用户下一步操作: + +```markdown +⚠️ {插件名} 已经安装。 + +当前状态: +- 📛 名称: {name} +- 📂 位置: {安装路径} +- 🔢 版本: {version}(如可获取) + +请选择操作: +1. 🔄 重新安装(覆盖当前版本) +2. ⬆️ 更新到最新版本 +3. 🗑️ 卸载此插件 +4. 📋 查看详情(安装路径、配置、依赖) +5. ✅ 跳过,保持现状 +``` + +**执行对应操作:** + +| 用户选择 | 执行 | +|---------|------| +| 重新安装 | 先卸载 → 再安装(保留配置) | +| 更新 | SKILL:`claude plugins update `;MCP:运行更新检查脚本 | +| 卸载 | SKILL:`claude plugins uninstall `;MCP:从 `settings.json` 移除配置 | +| 查看详情 | 展示安装路径、配置文件内容、最近更新时间 | +| 跳过 | 结束流程,不做任何更改 | + +### 3. SKILL 插件安装流程 + +#### 3a. 注册 Marketplace + +如果不是本地路径,先注册来源 Marketplace: + +```bash +claude plugins marketplace add <来源> +``` + +- 如果 Marketplace 已注册,检测 `known_marketplaces.json` 跳过此步 +- 注册成功后展示 Marketplace 信息 + +#### 3b. 安装插件 + +```bash +claude plugins install <插件名> +``` + +常见映射(从来源提取插件名): + +| 来源 | 插件名 | +|------|--------| +| `Minecraft269/skills` | `minecraft269-skills` | +| `Minecraft269/skills.git` | `minecraft269-skills` | +| 本地 `./my-skill/` | 从 `plugin.json` → `name` 字段提取 | + +插件名优先从 `plugin.json` 的 `name` 字段提取,其次从目录名推断。 + +#### 3c. 自动升级配置 + +检查并启用自动升级: + +`known_marketplaces.json` 位置:`~/.claude/known_marketplaces.json` + +处理逻辑: +1. 读取 `known_marketplaces.json` +2. 查找匹配的 source URL +3. 设置 `"autoUpdate": true`(如不存在则添加) +4. 写回文件 + +**如果 Marketplace 不支持自动升级**(本地安装或未知来源),提示用户: +- 「此来源不支持自动升级,需要手动执行 `claude plugins update ` 来更新」 +- 建议用户设置定期提醒或 cron 任务 + +### 4. MCP Server 安装流程 + +#### 4a. 收集 MCP 配置信息 + +向用户收集必要信息(如未在来源中自动检测到): + +``` +请提供以下 MCP Server 配置信息: + +1. 传输协议 (默认: stdio): + - stdio(本地命令行) + - sse(Server-Sent Events) + - streamable-http + +2. 启动命令(如 npx、uvx、node 等) + +3. 命令参数(如有) + +4. 环境变量(如 API keys) +``` + +#### 4b. 生成并写入 MCP 配置 + +根据收集的信息,在 `~/.claude/settings.json` 的 `mcpServers` 中添加配置: + +```json +{ + "mcpServers": { + "": { + "type": "", + "command": "", + "args": ["", ""], + "env": { + "": "" + } + } + } +} +``` + +**重要:** 先读取现有 `settings.json`,合并新配置后再写回,不要覆盖已有的其他 MCP Server 配置。 + +#### 4c. MCP 接入验证 + +配置写入后: + +1. **检查必要环境变量**是否已设置(如 `GITHUB_TOKEN`、`ANTHROPIC_API_KEY` 等) +2. **提示用户重启 Claude Code** 或重新加载 MCP 连接 +3. **提供快速测试命令**:告诉用户如何验证 MCP 是否正常工作 + +```markdown +> ✅ MCP 配置已写入。请重启 Claude Code 以加载新的 MCP Server。 +> +> 重启后,可以通过以下方式验证: +> - 查看 MCP 工具是否出现在可用工具列表中 +> - 尝试调用 MCP 工具(如 `mcp____`) +``` + +#### 4d. MCP 更新检查 + +由于 MCP Server 没有内置的自动升级机制,本技能提供更新检查能力: + +**内置脚本 `scripts/check-mcp-updates.sh`**: +- 检查 GitHub releases、npm registry、或 pip 上的最新版本 +- 与本地配置中记录的版本比较 +- 输出更新建议 + +用户可手动运行或设置 cron 定期执行。 + +### 5. 输出确认摘要 + +每次安装完成后,输出格式化摘要: + +```markdown +✅ 安装完成 + +| 项目 | 详情 | +|------|------| +| 📦 类型 | {MCP Server / SKILL 插件} | +| 📛 名称 | {插件名或 MCP Server 名} | +| 🔗 来源 | {GitHub repo / 本地路径 / Registry URL} | +| 🔄 自动升级 | {已启用 / 未启用 + 原因 / 需手动检查(MCP 脚本)} | +| ⚠️ 注意事项 | {环境变量 / 认证 / 兼容性提醒} | +| 📝 下一步 | {重启 Claude Code / 运行验证命令 / 配置 API Key} | +``` + +安装完成后建议用户运行以下命令验证: + +```bash +claude plugins list # 确认插件在列表中 +/discover # 运行技能发现(已合并至 universal-project-kickoff) +``` + +**联动钩子(仅 PACKAGE_MODE = true 时执行):** + +安装完成后,扫描兄弟技能的 `capabilities`,匹配 `integrates_with: skill-discovery`: +- 匹配成功 → 提示用户:"💡 安装完成。是否需要运行 **项目启动与能力发现** 来扫描当前项目,查看新安装的能力如何匹配你的技术栈?" +- 用户同意 → 触发技能发现流程 + +### 6. 常见 MCP Server 快速安装模板 + +内置几个常用 MCP Server 的配置模板,简化安装: + +#### GitHub MCP Server + +```json +{ + "mcpServers": { + "github": { + "type": "stdio", + "command": "npx", + "args": ["-y", "@anthropic/mcp-server-github"], + "env": { + "GITHUB_TOKEN": "" + } + } + } +} +``` + +#### Context7 MCP Server + +```json +{ + "mcpServers": { + "context7": { + "type": "stdio", + "command": "npx", + "args": ["-y", "@context7/mcp-server"] + } + } +} +``` + +#### Playwright MCP Server + +```json +{ + "mcpServers": { + "playwright": { + "type": "stdio", + "command": "npx", + "args": ["-y", "@playwright/mcp-server"] + } + } +} +``` + +更多模板参见 `references/mcp-templates.md`。 + +## 错误处理 + +| 场景 | 处理方式 | +|------|---------| +| Marketplace 已注册 | 跳过注册步骤,直接安装 | +| 插件已安装 | 提示用户并询问是否重新安装/更新 | +| `claude` CLI 不可用 | 引导用户先安装 Claude Code CLI | +| `settings.json` 不存在 | 自动创建基础结构 | +| `settings.json` 格式损坏 | 备份原文件并重建 | +| MCP Server 启动失败 | 检查命令是否存在、网络是否可达、环境变量是否设置 | +| 权限不足 | 提示需要管理员权限或使用 `sudo` | + +## 脚本 + +- `scripts/check-mcp-updates.sh` — MCP Server 更新检查脚本(检查 GitHub/npm/pip 新版本) +- `scripts/toggle-autoupdate.sh` — 切换 `known_marketplaces.json` 中指定来源的 `autoUpdate` 状态 + +## 参考 + +- `references/mcp-templates.md` — 常见 MCP Server 的完整配置模板库 diff --git a/skills/universal-project-kickoff/SKILL.md b/skills/universal-project-kickoff/SKILL.md index dbc64f6..668811e 100644 --- a/skills/universal-project-kickoff/SKILL.md +++ b/skills/universal-project-kickoff/SKILL.md @@ -1,22 +1,22 @@ --- name: universal-project-kickoff description: > - 通用型项目启动与能力发现规则。已吸收原 proactive-skill-discovery 的全部能力(该技能已删除)。 - 新增 Fork 模式:参与开源贡献(fork → clone → 开发 → PR)。 - 当用户说以下任何话时,**必须**触发此技能: - "我要开始一个新项目"、"帮我规划一个新功能"、"想启动一个 AI Agent"、 - "如何着手做 X"、"不知道从哪开始"、"帮我搭个架子"、"项目初始化"、 - "检查一下我的项目计划"、"帮我理一理思路"、"新项目怎么开始"、 - "打算搞个 side project"、"帮我做项目风险排查"、 - "有哪些可用的技能/插件"、"推荐什么工具"、"/discover"、 - "帮我审查代码"、"帮我修 Bug"、"我要开发一个新功能"、 - "我想参与这个开源项目"、"帮我 fork 这个仓库"、"我想给这个项目提 PR"。 - 本技能先探测用户意图(启动项目/开发功能/审查代码/修复Bug/探索工具/Fork项目), - 再分流到对应子流程。启动新项目时执行六步强制流程(为什么-是什么-边界-风险-利益-里程碑-固化CLAUDE.md) - + 代码风格确认 + 能力推荐,最后调用 /init 生成项目的 CLAUDE.md 将思考成果永久固化。 - Fork 项目时执行五步子流程(获取仓库 → Fork → Clone → 项目分析 → 贡献工作流引导)。 - 其他意图则根据技术栈推荐匹配的技能和插件。 - 即使用户没有明确说"启动检查",只要涉及从零规划任何项目或需要工具推荐,就应触发。 + Universal project startup and capability discovery rules. Absorbs all capabilities from the former proactive-skill-discovery (which has been deleted). + Added Fork Mode: participate in open-source contributions (fork → clone → develop → PR). + This skill **must** trigger when the user says any of the following: + "I want to start a new project", "Help me plan a new feature", "I want to launch an AI Agent", + "How do I approach X", "Don't know where to start", "Help me scaffold something", "Project initialization", + "Check my project plan", "Help me organize my thoughts", "How to start a new project", + "Planning a side project", "Help me do project risk assessment", + "What skills/plugins are available", "Recommend some tools", "/discover", + "Help me review code", "Help me fix a bug", "I want to develop a new feature", + "I want to participate in this open-source project", "Help me fork this repo", "I want to submit a PR to this project". + This skill first detects user intent (start project / develop feature / review code / fix bug / explore tools / fork project), + then routes to the corresponding sub-flow. When starting a new project, execute the mandatory six-step process (Why-What-Boundary-Risk-Stakeholders-Milestones-CLAUDE.md) + + code style confirmation + capability recommendation, and finally call /init to generate the project's CLAUDE.md to permanently solidify the thinking. + When forking a project, execute the five-step sub-process (Get Repository → Fork → Clone → Project Analysis → Contribution Workflow Guide). + Other intents recommend matching skills and plugins based on the tech stack. + Even if the user does not explicitly say "startup check", this skill should trigger whenever planning any project from scratch or tool recommendations are needed. version: "4.0.0" risk: safe source: community @@ -25,330 +25,330 @@ integrates_with: ["plugin-installation", "pr-management"] metadata: category: meta tags: [project-startup, planning, checklist, mvp-definition, risk-assessment, init, code-style, discovery, recommendation, skills, plugins, commands, fork, contribute, open-source] - compatibility: 需要 /init 命令(Claude Code 内置),无其他外部依赖 + compatibility: Requires the /init command (built into Claude Code), no other external dependencies --- -# 通用型项目启动与能力发现 +# Universal Project Startup & Capability Discovery -## 核心原则 +## Core Principles -**先开枪,后瞄准,但开枪前得知道靶子大概在哪个方向。** -本技能帮助你在 15 分钟内完成启动前的关键决策,避免"热情直冲"带来的返工。同时,**全程保留项目的代码风格(包括注释、命名、格式等)** —— 这意味着在生成任何代码示例、项目结构或脚手架时,都要主动询问或推断用户既有的风格规范,并严格遵循。 +**Fire first, aim later — but know roughly where the target is before pulling the trigger.** +This skill helps you make key decisions before startup within 15 minutes, avoiding rework caused by blind enthusiasm. At the same time, **preserve the project's code style throughout (including comments, naming, formatting, etc.)** — meaning whenever generating code examples, project structure, or scaffolding, proactively ask about or infer the user's existing style conventions and strictly follow them. -本技能已吸收原 `proactive-skill-discovery` 的全部能力(该技能已删除)。在开始前,会先探测你的意图——是启动新项目、开发功能、审查代码、修复 Bug、探索工具还是参与开源(Fork)——然后推荐最匹配的技能和插件。 +This skill has absorbed all capabilities from the former `proactive-skill-discovery` (which has been deleted). Before starting, it first detects your intent — starting a new project, developing a feature, reviewing code, fixing a bug, exploring tools, or participating in open source (Fork) — and then recommends the best-matching skills and plugins. -## 不触发条件 +## Non-Trigger Conditions -以下情况**不要**触发本技能: -- 用户已明确指定要使用的具体技能(如 `/github-pr-reviewer`) -- 对话仅为简单问答,不涉及项目开发任务 -- 用户在当前会话中已明确表示不需要推荐或启动检查 +Do **not** trigger this skill in the following situations: +- The user has explicitly specified a specific skill to use (e.g., `/github-pr-reviewer`) +- The conversation is simply Q&A, not involving project development tasks +- The user has explicitly stated in the current session that they do not need recommendations or startup checks -## 参考文件 +## References -本技能附带六份参考文档,在技能执行过程中按以下规则加载: +This skill comes with six reference documents, loaded during execution according to the following rules: -- **`references/project-checklist.md`**:通用项目启动检查清单完整版。当用户对某一步骤要求更详细的解释、希望看到完整开工 Checklist 原文、或需要确认是否遗漏检查项时加载。 -- **`references/ai-agent-checklist.md`**:AI Agent 项目专项检查清单。当用户确认项目类型为 AI Agent、询问 Agent 特有的风险或注意事项、或需要设计 Agent 的"大脑"架构时加载。 -- **`references/scanner-patterns.md`**:项目指纹检测矩阵、评分算法公式、插件映射表和命令发现参考。执行技术栈确认和能力匹配时参考。 -- **`references/language-guide.md`**:编程语言优劣势参考表。当用户不确定用什么语言时加载。 -- **`references/hook-config.md`**:可选的 Claude Code hook 配置指南。当用户希望在新会话启动或检测到新项目时自动触发本技能,参考此文档配置 SessionStart/PostToolUse hook。 -- **`references/validation-scenarios.md`**:验证场景集合。执行完技能后进行 LLM 自检时参考,确保推荐结果与预期一致。覆盖 8 种典型项目类型和 7 种边界情况。 +- **`references/project-checklist.md`**: Full version of the general project startup checklist. Load when the user requests a more detailed explanation of a step, wants to see the full startup checklist, or needs to confirm no checklist items are missed. +- **`references/ai-agent-checklist.md`**: AI Agent project-specific checklist. Load when the user confirms the project type is an AI Agent, asks about Agent-specific risks or considerations, or needs to design the Agent's "brain" architecture. +- **`references/scanner-patterns.md`**: Project fingerprint detection matrix, scoring algorithm formulas, plugin mapping table, and command discovery reference. Consult during tech stack confirmation and capability matching. +- **`references/language-guide.md`**: Programming language pros/cons reference table. Load when the user is unsure which language to use. +- **`references/hook-config.md`**: Optional Claude Code hook configuration guide. Load when the user wants this skill to trigger automatically on new session start or new project detection — refer to this document for configuring SessionStart/PostToolUse hooks. +- **`references/validation-scenarios.md`**: Validation scenario collection. Load during LLM self-check after skill execution to verify recommendations match expectations. Covers 8 typical project types and 7 edge cases. -## 包联动 +## Package Linking -本技能支持与 minecraft269-skills 插件包内其他技能自动联动。执行以下检测: +This skill supports automatic linkage with other skills in the minecraft269-skills plugin package. Perform the following detection: -1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` -2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 -3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级) +1. Glob search for `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. If found → `PACKAGE_MODE = true`, sibling skills can be discovered and linked +3. If not found → `PACKAGE_MODE = false`, skip all cross-skill logic (silent degradation) -当 `PACKAGE_MODE = true` 时: -- 识别项目技术栈后可联动 `integrates_with: plugin-installation`(快速安装插件) -- CLAUDE.md 生成后可提示用户运行能力扫描(本技能已内置,无需跨技能联动) -- 扫描兄弟 SKILL.md 的 `capabilities` 字段,匹配本技能的 `integrates_with` 标签 -- 仅在匹配成功时显示联动提示 +When `PACKAGE_MODE = true`: +- After identifying the project tech stack, can link with `integrates_with: plugin-installation` (quick plugin installer) +- After CLAUDE.md generation, can prompt the user to run capability scanning (this skill has it built-in, no cross-skill linkage needed) +- Scan sibling SKILL.md `capabilities` fields, match against this skill's `integrates_with` tags +- Only show linkage hints when matching succeeds -详见 `_shared/package-context.md`。**任何检测失败都默认 PACKAGE_MODE = false,不得报错或中断。** +See `_shared/package-context.md` for details. **Any detection failure defaults to PACKAGE_MODE = false; do not report errors or interrupt.** --- -## 使用流程 +## Usage Flow -### Step 0:意图探测 +### Step 0: Intent Detection -**先推断,后询问。** 从用户的原始消息中提取关键词预判意图,只有无法确定时才弹出 `AskUserQuestion`。 +**Infer first, ask later.** Extract keywords from the user's raw message to pre-judge intent, only pop up `AskUserQuestion` when it cannot be determined. -#### 0.1 意图预判(关键词匹配) +#### 0.1 Intent Pre-Judgment (Keyword Matching) -从用户消息中匹配以下模式(大小写不敏感): +Match the following patterns in the user's message (case-insensitive): -| 关键词组合 | 推断意图 | 直接分流 | -|-----------|---------|---------| -| "启动" / "开始" / "新建" / "创建" / "初始化" / "搭个" / "从零" **+** "项目" | 🚀 启动新项目 | → Step 0b 语言确认 → 强制六步流程 | -| "开发" / "添加" / "实现" / "做" **+** "功能" / "feature" | 💻 开发新功能 | → Step 0c 技术栈确认 + 能力推荐 | -| "审查" / "review" / "检查" **+** "代码" / "PR" / "pull request" | 🔍 审查代码 | → Step 0a 目标确认 | -| "修复" / "修" / "改" / "fix" / "debug" **+** "bug" / "问题" / "报错" | 🐛 修复 Bug | → Step 0a 目标确认 | -| "有什么" / "推荐" / "哪些" / "可用" / "discover" **+** "技能" / "插件" / "工具" / "能力" | 🔧 探索工具 | → Step 0c 完整能力扫描 | -| "fork" / "参与" / "贡献" / "提 PR" / "contribute" / "上游" **+** "项目" / "仓库" / "开源" / "代码" / "repo" | 🍴 Fork 项目 | → Step 0a Fork 分支 | +| Keyword Combinations | Inferred Intent | Direct Routing | +|---------------------|----------------|----------------| +| "start" / "begin" / "new" / "create" / "initialize" / "scaffold" / "from scratch" **+** "project" | 🚀 Start New Project | → Step 0b Language Confirmation → Mandatory Six-Step Process | +| "develop" / "add" / "implement" / "build" **+** "feature" / "functionality" | 💻 Develop New Feature | → Step 0c Tech Stack Confirmation + Capability Recommendation | +| "review" / "check" / "examine" **+** "code" / "PR" / "pull request" | 🔍 Review Code | → Step 0a Target Confirmation | +| "fix" / "repair" / "debug" **+** "bug" / "issue" / "error" | 🐛 Fix Bug | → Step 0a Target Confirmation | +| "what" / "recommend" / "which" / "available" / "discover" **+** "skills" / "plugins" / "tools" / "capabilities" | 🔧 Explore Tools | → Step 0c Full Capability Scan | +| "fork" / "participate" / "contribute" / "submit PR" / "upstream" **+** "project" / "repo" / "open source" / "code" / "repository" | 🍴 Fork Project | → Step 0a Fork Branch | -**匹配规则:** -- 若匹配到**唯一意图** → 直接分流,跳过 AskUserQuestion,在分流前用一句话确认(如"识别到你想要[意图],直接开始…") -- 若**多个意图匹配**或**无匹配** → 使用 `AskUserQuestion` 询问 +**Matching Rules:** +- If a **unique intent** matches → route directly, skip `AskUserQuestion`, confirm with one sentence before routing (e.g., "I see you want to [intent], let's get started…") +- If **multiple intents match** or **no match** → use `AskUserQuestion` -#### 0.2 交互式询问(仅在意图不明确时使用) +#### 0.2 Interactive Prompt (Only When Intent Is Unclear) -> "你想要做什么?" +> "What would you like to do?" -| 选项 | 说明 | 后续分流 | -|------|------|---------| -| 🚀 **启动新项目** | 从零开始一个项目 | → 追问语言/框架 → Step 0b 语言确认 → 进入强制六步流程 | -| 💻 **开发新功能** | 在现有项目中添加功能 | → 进入 Step 0c 技术栈确认 + 能力推荐 | -| 🔍 **审查代码** | Review PR 或代码变更 | → Step 0a 目标确认 → Step 0c 技术栈确认 + 审查工具推荐 | -| 🐛 **修复 Bug** | 排查和修复问题 | → Step 0a 目标确认 → Step 0c 技术栈确认 + 调试工具推荐 | -| 🔧 **探索工具** | 看看有什么可用的技能/插件/命令 | → 进入 Step 0c 完整能力扫描 | -| 🍴 **Fork 项目** | Fork 开源仓库,在本地开发并贡献 PR | → Step 0a Fork 分支 | -| 📋 **其他** | 用户自由输入 | → 根据输入内容智能匹配分流 | +| Option | Description | Subsequent Routing | +|--------|-------------|--------------------| +| 🚀 **Start New Project** | Start a project from scratch | → Ask for language/framework → Step 0b Language Confirmation → Enter mandatory six-step process | +| 💻 **Develop New Feature** | Add a feature to an existing project | → Enter Step 0c Tech Stack Confirmation + Capability Recommendation | +| 🔍 **Review Code** | Review a PR or code changes | → Step 0a Target Confirmation → Step 0c Tech Stack Confirmation + Review Tool Recommendation | +| 🐛 **Fix Bug** | Troubleshoot and fix issues | → Step 0a Target Confirmation → Step 0c Tech Stack Confirmation + Debugging Tool Recommendation | +| 🔧 **Explore Tools** | See what skills/plugins/commands are available | → Enter Step 0c Full Capability Scan | +| 🍴 **Fork Project** | Fork an open-source repo, develop locally, and contribute a PR | → Step 0a Fork Branch | +| 📋 **Other** | User free-text input | → Smart match routing based on input content | -#### Step 0a:目标确认(仅「审查代码」/「修复 Bug」时执行) +#### Step 0a: Target Confirmation (Only for "Review Code" / "Fix Bug") -##### 审查代码分支(4 层追问) +##### Code Review Branch (4 Layers of Questions) -「审查代码」意图需要先确认审查目标和方式,再决定是否执行技术栈扫描。 +The "Review Code" intent needs to first confirm the review target and method, then decide whether to execute tech stack scanning. -**第 1 层 — 询问审查场景:** +**Layer 1 — Ask about the review scenario:** -使用 `AskUserQuestion`: -> "你要审查的是什么?" +Use `AskUserQuestion`: +> "What are you reviewing?" -| 选项 | 说明 | -|------|------| -| 📁 **本地项目** | 审查当前工作区的代码变更(unstaged / 分支 diff / 最近 commit) | -| ☁️ **远程 PR** | 审查 GitHub 上的 Pull Request | +| Option | Description | +|--------|-------------| +| 📁 **Local Project** | Review code changes in the current workspace (unstaged / branch diff / recent commit) | +| ☁️ **Remote PR** | Review a Pull Request on GitHub | -**第 2 层(仅远程 PR)— 询问目标 PR:** +**Layer 2 (Remote PR only) — Ask about the target PR:** -> "请提供 PR URL(如 `https://github.com/owner/repo/pull/123`)或 `owner/repo#number`" +> "Please provide the PR URL (e.g., `https://github.com/owner/repo/pull/123`) or `owner/repo#number`" -解析 PR URL → 提取 `owner`、`repo`、`pr_number`。 +Parse PR URL → Extract `owner`, `repo`, `pr_number`. -**第 3 层(仅远程 PR)— 询问审查方式:** +**Layer 3 (Remote PR only) — Ask about the review method:** -使用 `AskUserQuestion`: -> "你想怎么审查这个 PR?" +Use `AskUserQuestion`: +> "How would you like to review this PR?" -| 选项 | 说明 | 后续 | -|------|------|------| -| ⚡ **在线快速审查** | 直接通过 GitHub MCP 获取 PR diff/files/commits,在线审查,无需 clone | → 使用 `gh pr view/diff` 或 GitHub MCP 工具获取 PR 内容 → 审查完成后输出结论 → **不执行 Step 0c** | -| 💻 **Clone 到本地详细审查** | clone 仓库到本地,执行完整技术栈扫描 + 深度审查 | → 对比本地 git remote:`git remote get-url origin 2>/dev/null \|\| echo "NOT_A_GIT_REPO"` → 不匹配则引导 clone(`gh repo clone owner/repo` 或 `git clone`)→ 执行 Step 0c | +| Option | Description | Next Steps | +|--------|-------------|------------| +| ⚡ **Quick Online Review** | Get PR diff/files/commits directly via GitHub MCP, review online, no clone needed | → Use `gh pr view/diff` or GitHub MCP tools to get PR content → Output review conclusion → **Do not execute Step 0c** | +| 💻 **Clone to Local for Detailed Review** | Clone the repository locally, perform full tech stack scan + deep review | → Compare with local git remote: `git remote get-url origin 2>/dev/null \|\| echo "NOT_A_GIT_REPO"` → If no match, guide clone (`gh repo clone owner/repo` or `git clone`) → Execute Step 0c | -**第 4 层(仅本地项目)— 确认审查范围:** +**Layer 4 (Local project only) — Confirm review scope:** -> "审查当前工作区的哪些变更?" +> "Which changes in the current workspace would you like to review?" -| 选项 | 说明 | -|------|------| -| 📝 **Unstaged 变更** | 工作区中尚未 staged 的修改 | -| 🌿 **分支对比** | 当前分支 vs 目标分支(如 `main`)的 diff | -| 📦 **最近 commit** | 审查最近 N 个 commit 的变更 | +| Option | Description | +|--------|-------------| +| 📝 **Unstaged Changes** | Modifications in the workspace that have not yet been staged | +| 🌿 **Branch Comparison** | Diff of current branch vs target branch (e.g., `main`) | +| 📦 **Recent Commits** | Review changes from the last N commits | -确认范围后 → 进入第 5 层。 +After scope confirmed → proceed to Layer 5. -**第 5 层(所有审查路径)— 审查模型确认:** +**Layer 5 (All review paths) — Review Model Confirmation:** -在开始审查前,确认使用的 AI 模型。不同模型在审查深度、速度和成本上有差异。 +Before starting the review, confirm the AI model to use. Different models differ in review depth, speed, and cost. -1. **获取当前默认模型**:从会话上下文中读取当前模型名称(如系统提示中的 model 信息) -2. **展示并确认**: - > "当前默认审查模型为 **[模型名称]**。是否使用此模型进行审查?" +1. **Get the current default model**: Read the current model name from session context (e.g., model info from system prompts) +2. **Display and confirm**: + > "The current default review model is **[model name]**. Would you like to use this model for the review?" - | 选项 | 说明 | - |------|------| - | ✅ **使用当前模型** | 直接使用默认模型开始审查 | - | 🔄 **更换模型** | 让用户指定其他模型 | + | Option | Description | + |--------|-------------| + | ✅ **Use Current Model** | Start review directly with the default model | + | 🔄 **Switch Model** | Let the user specify a different model | -3. **更换模型时**: - > "请输入你想使用的模型名称(如 `sonnet`、`opus`、`haiku`、`fable`,或具体模型 ID)" - - 用户输入后记录到审查上下文,后续 Agent 调用时使用该模型 +3. **When switching models**: + > "Please enter the model name you'd like to use (e.g., `sonnet`, `opus`, `haiku`, `fable`, or a specific model ID)" + - Record the user's choice in the review context; use that model for subsequent Agent calls -4. **进入审查** → 执行 Step 0c 技术栈扫描 → 推荐技能时优先匹配 `pr-review`、`code-review` 能力。 +4. **Enter review** → Execute Step 0c tech stack scan → Prioritize matching `pr-review`, `code-review` capabilities when recommending skills. -##### 修复 Bug 分支 +##### Fix Bug Branch -「修复 Bug」意图需要先确认目标项目。 +The "Fix Bug" intent needs to first confirm the target project. -**1. 追问目标:** +**1. Ask for the target:** -使用 `AskUserQuestion` 询问: -> "你要在哪个项目中修 Bug?是当前工作区的项目,还是其他项目?" +Use `AskUserQuestion`: +> "Which project are you fixing a bug in? Is it the current workspace project, or another project?" -**2. 检查本地状态:** +**2. Check local status:** -- 从用户提供的项目信息对比当前工作区的 git remote -- 若目标项目不在本地 → 引导 clone -- Clone 完成后切换到目标项目目录 +- Compare the user's project info against the current workspace git remote +- If the target project is not local → guide cloning +- After cloning, switch to the target project directory -**3. 进入 Step 0c:** +**3. Enter Step 0c:** -- 在正确的项目目录中执行技术栈扫描 -- 推荐技能时优先匹配调试工具 + 通用代码分析技能 +- Execute tech stack scan in the correct project directory +- Prioritize matching debugging tools + general code analysis skills when recommending -##### 🍴 Fork 项目分支(5 步子程序) +##### 🍴 Fork Project Branch (5-Step Sub-Process) -「Fork 项目」意图需要依次执行获取仓库、Fork、Clone、项目分析、贡献工作流引导五个步骤。 +The "Fork Project" intent requires executing five steps in order: Get Repository, Fork, Clone, Project Analysis, Contribution Workflow Guide. -**Step 0a-fork-1:获取目标仓库** +**Step 0a-fork-1: Get Target Repository** -1. 从用户消息中提取 GitHub 仓库标识。支持的格式: - - 完整 URL:`https://github.com/owner/repo` - - 简写格式:`owner/repo` -2. 正则提取:`(?:https?://)?github\.com/([a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)` 或 `\b([a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)\b` -3. 若无法提取,使用 `AskUserQuestion`: - > "请提供你要参与的开源仓库地址(如 `https://github.com/facebook/react` 或 `facebook/react`)" -4. 若用户提供非 GitHub URL,提示: - > "当前仅支持 GitHub 开源仓库的 Fork 参与。请确认仓库在 GitHub 上。" +1. Extract the GitHub repository identifier from the user's message. Supported formats: + - Full URL: `https://github.com/owner/repo` + - Shorthand: `owner/repo` +2. Regex extraction: `(?:https?://)?github\.com/([a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)` or `\b([a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)\b` +3. If extraction fails, use `AskUserQuestion`: + > "Please provide the open-source repository you'd like to contribute to (e.g., `https://github.com/facebook/react` or `facebook/react`)" +4. If the user provides a non-GitHub URL, prompt: + > "Currently, only GitHub open-source repositories are supported for Fork contributions. Please confirm the repository is on GitHub." -**Step 0a-fork-2:Fork 仓库** +**Step 0a-fork-2: Fork the Repository** -1. 先检查是否已存在 fork: - - 使用 `gh repo list --json name --jq '.[].name'` 或 `mcp__plugin_github_github__list_commits` 检查 -2. 若不存在 → 执行 fork: - - 优先使用 `gh repo fork --clone=false`(更可靠) - - 备用:GitHub MCP `mcp__plugin_github_github__fork_repository` -3. 若已存在 → `AskUserQuestion`: - > "检测到你已 fork 过 ``。是否使用已有 fork?" +1. First check if a fork already exists: + - Use `gh repo list --json name --jq '.[].name'` or `mcp__plugin_github_github__list_commits` to check +2. If not exists → execute fork: + - Prefer `gh repo fork --clone=false` (more reliable) + - Fallback: GitHub MCP `mcp__plugin_github_github__fork_repository` +3. If exists → `AskUserQuestion`: + > "I found you already forked ``. Would you like to use the existing fork?" - | 选项 | 说明 | - |------|------| - | ✅ **使用已有 fork** | 直接使用现有的 fork 仓库 | - | 🔄 **重新 fork** | 删除已有 fork 并重新创建(`gh repo fork --force`) | - | ⬆️ **同步已有 fork** | 将上游仓库的最新变更同步到你的 fork(`gh repo sync`) | - | ❌ **取消** | 放弃 Fork 操作 | + | Option | Description | + |--------|-------------| + | ✅ **Use Existing Fork** | Use the existing fork repository directly | + | 🔄 **Re-fork** | Delete the existing fork and create a new one (`gh repo fork --force`) | + | ⬆️ **Sync Existing Fork** | Sync the latest changes from the upstream repository to your fork (`gh repo sync`) | + | ❌ **Cancel** | Abort the Fork operation | -4. Fork 成功后记录变量: - - `_FORK_UPSTREAM = "owner/repo"`(上游仓库) - - `_FORK_REPO = "your-username/repo"`(你的 fork) +4. After successful fork, record variables: + - `_FORK_UPSTREAM = "owner/repo"` (upstream repository) + - `_FORK_REPO = "your-username/repo"` (your fork) -**Step 0a-fork-3:Clone 到本地** +**Step 0a-fork-3: Clone to Local** -1. 询问用户 clone 目标目录(默认当前工作区下的 ``) -2. 检查本地是否已存在该目录: - - 不存在 → 执行 `gh repo clone ` 或 `git clone https://github.com/.git` - - 已存在 → `AskUserQuestion`: - > "本地已存在同名目录。怎么处理?" - - ✅ 复用现有目录 / 🔄 重新 clone / ❌ 取消 -3. Clone 后设置 upstream: +1. Ask the user for the clone target directory (default: `` under the current workspace) +2. Check if the directory already exists locally: + - Not exists → execute `gh repo clone ` or `git clone https://github.com/.git` + - Exists → `AskUserQuestion`: + > "A directory with the same name already exists locally. How would you like to proceed?" + - ✅ Reuse existing directory / 🔄 Re-clone / ❌ Cancel +3. After cloning, set up upstream: ```bash cd - git remote add upstream https://github.com/.git # 如尚未添加 + git remote add upstream https://github.com/.git # If not already added git fetch upstream ``` -4. 记录 `_FORK_LOCAL_PATH = ""` +4. Record `_FORK_LOCAL_PATH = ""` -**Step 0a-fork-4:项目分析** +**Step 0a-fork-4: Project Analysis** -1. 进入 clone 目录后,提示用户执行技术栈扫描: - > "已 clone [repo] 到本地。建议先扫描项目技术栈,帮助你快速理解项目结构。是否开始分析?" +1. After entering the cloned directory, prompt the user to run a tech stack scan: + > "[repo] has been cloned locally. It's recommended to scan the project tech stack first to help you quickly understand the project structure. Would you like to start the analysis?" - | 选项 | 说明 | - |------|------| - | ✅ **开始分析** | 执行 Step 0c 技术栈确认 + 能力发现 | - | ⏭️ **跳过** | 跳过技术栈扫描,直接进入贡献工作流引导 | + | Option | Description | + |--------|-------------| + | ✅ **Start Analysis** | Execute Step 0c Tech Stack Confirmation + Capability Discovery | + | ⏭️ **Skip** | Skip the tech stack scan and go directly to contribution workflow guidance | -2. 若用户选择「开始分析」,执行完整的 Step 0c 流程(0c-1 至 0c-7) -3. 额外检查: - - 读取上游 `CONTRIBUTING.md`(如存在) - - 检查 `.github/` 目录下的 PR 模板、Issue 模板 - - 读取 `LICENSE` 文件 -4. 展示项目概览摘要(技术栈 + 贡献指南要点 + 许可证类型) +2. If the user chooses "Start Analysis", execute the full Step 0c flow (0c-1 through 0c-7) +3. Additional checks: + - Read the upstream `CONTRIBUTING.md` (if it exists) + - Check `.github/` directory for PR templates, Issue templates + - Read the `LICENSE` file +4. Display project overview summary (tech stack + contribution guide highlights + license type) -**联动钩子(仅 PACKAGE_MODE = true 时执行):** -在项目分析完成后,匹配 `integrates_with: pr-management`: -- 若检测到兄弟技能 `github-pr-manager` 可用 → 提示:"💡 完成改动后,可以使用 **GitHub PR 管理器** 来创建和管理你的 Pull Request。" +**Linkage Hooks (only when PACKAGE_MODE = true):** +After project analysis completes, match `integrates_with: pr-management`: +- If sibling skill `github-pr-manager` is detected as available → prompt: "💡 After making changes, you can use the **GitHub PR Manager** to create and manage your Pull Request." -**Step 0a-fork-5:贡献工作流引导** +**Step 0a-fork-5: Contribution Workflow Guide** -1. 展示贡献流程概览: +1. Display the contribution process overview: ``` - ## 🍴 Fork 贡献流程 + ## 🍴 Fork Contribution Flow - 1. ✅ Fork 仓库 → [fork-url] - 2. ✅ Clone 到本地 → [local-path] - 3. ✅ 项目分析 → [tech-stack] - 4. 📝 创建功能分支 → 待执行 - 5. 🔨 开发改动 → 待执行 - 6. 📤 推送并创建 PR → 待执行 + 1. ✅ Fork Repository → [fork-url] + 2. ✅ Clone to Local → [local-path] + 3. ✅ Project Analysis → [tech-stack] + 4. 📝 Create Feature Branch → Pending + 5. 🔨 Develop Changes → Pending + 6. 📤 Push and Create PR → Pending ``` -2. 引导创建功能分支: - > "建议为你的改动创建一个功能分支。分支名称格式:`feat/` 或 `fix/`" - - 让用户输入分支名,或根据描述自动建议 +2. Guide creating a feature branch: + > "I recommend creating a feature branch for your changes. Branch name format: `feat/` or `fix/`" + - Let the user enter a branch name, or auto-suggest based on description -3. **联动钩子(仅 PACKAGE_MODE = true)**: - - 匹配 `integrates_with: pr-management` → 提示:"💡 改动完成后,可使用 **GitHub PR 管理器** 创建和管理你的 Pull Request。" - - 匹配 `integrates_with: plugin-installation` 中的 `git-commit` → 提示:"💡 提交代码时,可使用 **Git 提交助手** 自动生成 Conventional Commits 消息。" +3. **Linkage Hooks (only when PACKAGE_MODE = true):** + - Match `integrates_with: pr-management` → prompt: "💡 After making changes, you can use the **GitHub PR Manager** to create and manage your Pull Request." + - Match `git-commit` within `integrates_with: plugin-installation` → prompt: "💡 When committing code, you can use the **Git Commit Helper** to auto-generate Conventional Commits messages." -4. 总结下一步: - > "项目已就绪。接下来的流程:做改动 → `git add` + `git commit` → `git push origin ` → 创建 PR。如需帮助,随时告诉我。" +4. Summarize next steps: + > "Your project is ready. Next steps: make changes → `git add` + `git commit` → `git push origin ` → create PR. Let me know if you need any help." -#### Step 0b:语言/框架确认(仅「启动新项目」时追问) +#### Step 0b: Language/Framework Confirmation (Only for "Start New Project") -> "你想用什么编程语言/框架?" +> "What programming language/framework would you like to use?" -| 选项 | 说明 | -|------|------| -| 🟢 **Python** | AI/ML、数据分析、Web 后端、脚本自动化 | -| 🟡 **JavaScript/TypeScript** | Web 全栈、前端、跨平台 | -| 🔵 **Java/Kotlin** | 企业级后端、Android | -| 🟣 **Rust** | 系统编程、高性能场景 | -| ⚪ **Go** | 云原生、微服务、CLI 工具 | -| 🟠 **C# (.NET)** | Windows 桌面、游戏、企业应用 | -| 🔴 **Swift** | Apple 生态 (iOS/macOS) | -| 🤔 **我不确定,帮我推荐** | → 追问项目类型 → 加载 `references/language-guide.md` → 列出优劣势 + 推荐 | +| Option | Description | +|--------|-------------| +| 🟢 **Python** | AI/ML, data analysis, web backend, script automation | +| 🟡 **JavaScript/TypeScript** | Web full-stack, frontend, cross-platform | +| 🔵 **Java/Kotlin** | Enterprise backend, Android | +| 🟣 **Rust** | Systems programming, high-performance scenarios | +| ⚪ **Go** | Cloud-native, microservices, CLI tools | +| 🟠 **C# (.NET)** | Windows desktop, games, enterprise applications | +| 🔴 **Swift** | Apple ecosystem (iOS/macOS) | +| 🤔 **Not sure, recommend for me** | → Ask for project type → Load `references/language-guide.md` → List pros/cons + recommendation | -**「我不确定」分支的推荐逻辑:** +**"Not sure" branch recommendation logic:** -1. 追问项目类型:Web 应用 / 移动 App / 桌面应用 / CLI 工具 / AI/ML / 游戏 / 嵌入式 -2. 追问关注点:开发速度 / 运行性能 / 生态丰富度 / 学习曲线 -3. 加载 `references/language-guide.md`,输出推荐表: +1. Ask for project type: Web App / Mobile App / Desktop App / CLI Tool / AI/ML / Game / Embedded +2. Ask for priorities: Development speed / Runtime performance / Ecosystem richness / Learning curve +3. Load `references/language-guide.md`, output recommendation table: ``` -## 语言推荐 +## Language Recommendation -根据你的需求([项目类型] + [关注点]),推荐以下语言: +Based on your needs ([project type] + [priorities]), the following languages are recommended: -| 语言 | 适合度 | 优势 | 劣势 | -|------|--------|------|------| -| [语言A] | ⭐⭐⭐⭐⭐ | [优势] | [劣势] | -| [语言B] | ⭐⭐⭐⭐ | [优势] | [劣势] | -| [语言C] | ⭐⭐⭐ | [优势] | [劣势] | +| Language | Suitability | Advantages | Disadvantages | +|----------|-------------|------------|---------------| +| [Language A] | ⭐⭐⭐⭐⭐ | [Advantages] | [Disadvantages] | +| [Language B] | ⭐⭐⭐⭐ | [Advantages] | [Disadvantages] | +| [Language C] | ⭐⭐⭐ | [Advantages] | [Disadvantages] | -**推荐首选:[语言]** — [一句话理由] +**Top Recommendation: [Language]** — [One-line rationale] ``` -用户确认语言后,进入强制六步流程。 +After the user confirms the language, proceed to the mandatory six-step process. -#### Step 0c:技术栈确认 + 能力发现(7 步子程序) +#### Step 0c: Tech Stack Confirmation + Capability Discovery (7-Step Sub-Process) -详细算法参见 `references/scanner-patterns.md`。 +See `references/scanner-patterns.md` for the detailed algorithm. --- -**0c-1. 项目指纹扫描** +**0c-1. Project Fingerprint Scan** -**扫描前 — 缓存检查:** +**Before scanning — Cache check:** -1. 检查会话上下文中是否存在 `_SCAN_CACHE` 记录(包含 `timestamp` 和 `fingerprint`) -2. 若存在缓存记录: - - 读取 `.discovery-rules.json` 中的 `cache_ttl_hours`(默认 24 小时) - - 若距上次扫描未超过 TTL → 复用缓存指纹和扫描结果,跳过 0c-1 和 0c-2,直接进入 0c-3 - - 若已超过 TTL → 继续执行完整扫描 -3. 若不存在缓存记录(首次扫描)→ 继续执行完整扫描 +1. Check if a `_SCAN_CACHE` record exists in the session context (containing `timestamp` and `fingerprint`) +2. If a cached record exists: + - Read `cache_ttl_hours` from `.discovery-rules.json` (default 24 hours) + - If last scan is within TTL → reuse cached fingerprint and scan results, skip 0c-1 and 0c-2, go directly to 0c-3 + - If TTL exceeded → continue with full scan +3. If no cached record (first scan) → continue with full scan -对已有项目执行扫描。使用 `Glob` 检查以下文件(扩展的检测矩阵在 `references/scanner-patterns.md` §Fingerprint Detection Map): +Scan existing projects. Use `Glob` to check for the following files (extended detection matrix in `references/scanner-patterns.md` §Fingerprint Detection Map): -| 文件 | 推断结果 | -|------|---------| +| File | Inference | +|------|-----------| | `pom.xml` | Java + Maven | | `build.gradle` / `build.gradle.kts` | Java/Kotlin + Gradle | | `package.json` | Node.js / JavaScript / TypeScript | @@ -361,7 +361,7 @@ metadata: | `*.sln` / `*.csproj` | .NET / C# | | `CMakeLists.txt` | C/C++ | | `pubspec.yaml` | Flutter/Dart | -| `Package.swift` / `*.xcodeproj` | Swift / Apple 生态 | +| `Package.swift` / `*.xcodeproj` | Swift / Apple Ecosystem | | `docker-compose.yml` / `Dockerfile` | DevOps / Container | | `next.config.*` | Next.js | | `vite.config.*` | Vite | @@ -374,456 +374,455 @@ metadata: | `schema.prisma` | Prisma | | `schema.graphql` | GraphQL | -- 如果 `package.json` 存在,`Read` 其 `dependencies` 和 `devDependencies` 提取框架关键词 -- 如果 `pom.xml` 存在,`Grep` 查找 `` 和 `` 检测 Spring Boot、Quarkus 等 -- 检测 `app/` 或 `src/` 子目录作为补充信号 +- If `package.json` exists, `Read` its `dependencies` and `devDependencies` to extract framework keywords +- If `pom.xml` exists, `Grep` for `` and `` to detect Spring Boot, Quarkus, etc. +- Check `app/` or `src/` subdirectories as supplementary signals -**对全新项目:** 直接使用 Step 0b 选择的语言/框架。 +**For brand new projects:** Directly use the language/framework from Step 0b. -**输出:** 项目指纹(逗号分隔标签,如 `java, spring-boot, maven, postgresql`)。 +**Output:** Project fingerprint (comma-separated tags, e.g., `java, spring-boot, maven, postgresql`). -**联动钩子(仅 PACKAGE_MODE = true):** 检测 `.git/config` 中 GitHub remote,若存在则匹配 `integrates_with: pr-management`,提示 "💡 检测到 GitHub 项目。推荐使用 **GitHub PR 管理器** 来管理此仓库的 Pull Request。" +**Linkage Hooks (only when PACKAGE_MODE = true):** Check `.git/config` for a GitHub remote. If found, match `integrates_with: pr-management`, prompt "💡 GitHub project detected. It is recommended to use the **GitHub PR Manager** to manage Pull Requests for this repository." --- -**0c-2. 能力清单扫描(并行执行)** +**0c-2. Capability Inventory Scan (Parallel Execution)** -加载 `references/scanner-patterns.md` 进行并行三路扫描。 +Load `references/scanner-patterns.md` for parallel three-way scanning. -**扫描前 — 读取深度探索配置:** +**Before scanning — Read deep exploration configuration:** -1. 尝试读取 `~/.claude/skills/.discovery-rules.json` -2. 若文件存在且定义了 `deep_explore_plugins`(字符串数组)→ 使用该列表作为深度探索目标 -3. 若文件存在且定义了 `priority_boost_plugins`(字符串数组)→ 使用该列表作为优先级加成插件 -4. 若文件不存在或字段缺失 → 使用内置默认值: +1. Attempt to read `~/.claude/skills/.discovery-rules.json` +2. If the file exists and defines `deep_explore_plugins` (array of strings) → use that list as deep exploration targets +3. If the file exists and defines `priority_boost_plugins` (array of strings) → use that list as priority boost plugins +4. If the file does not exist or fields are missing → use built-in defaults: - `deep_explore_plugins`: `["everything-claude-code", "superpowers", "andrej-karpathy-skills", "oh-my-claudecode"]` - `priority_boost_plugins`: `["everything-claude-code", "superpowers", "andrej-karpathy-skills"]` -**2a. 技能扫描:** Glob `~/.claude/skills/*/SKILL.md`,解析 frontmatter 提取 name、description、tags、category、source。 +**2a. Skill Scan:** Glob `~/.claude/skills/*/SKILL.md`, parse frontmatter to extract name, description, tags, category, source. -**2b. 插件扫描:** -- MCP 配置:读取 `~/.claude/settings.json` → `mcpServers`,提取 server name、type、command、description -- 本地插件:Glob `~/.claude/plugins/*/plugin.json` 或 `package.json` +**2b. Plugin Scan:** +- MCP Configuration: Read `~/.claude/settings.json` → `mcpServers`, extract server name, type, command, description +- Local plugins: Glob `~/.claude/plugins/*/plugin.json` or `package.json` -**2c. 深度探索(必需,参见 scanner-patterns.md §Deep Exploration Reference):** -对上一步确定的深度探索目标插件列表执行深度探索: -- 列出根级 `.md`/`.json`/`.yaml`/`.yml`/`.mdc` 文件(跳过 node_modules、.git) -- 读取每个 `.md` 文件前 5-10 行识别用途 -- 扫描嵌套技能(`.agents/skills/*/SKILL.md`) -- 提取 `.mdc` 规则文件名和描述 -- 输出格式:tagged with `source: deep-exploration` and `plugin: `,每项含 name、type (soul/rules/agents/claude-md/commands-ref/nested-skill)、description、path +**2c. Deep Exploration (Required, see scanner-patterns.md §Deep Exploration Reference):** +Execute deep exploration on the list of deep exploration target plugins determined above: +- List root-level `.md`/`.json`/`.yaml`/`.yml`/`.mdc` files (skip node_modules, .git) +- Read the first 5-10 lines of each `.md` file to identify purpose +- Scan nested skills (`.agents/skills/*/SKILL.md`) +- Extract `.mdc` rule filenames and descriptions +- Output format: tagged with `source: deep-exploration` and `plugin: `, each entry with name, type (soul/rules/agents/claude-md/commands-ref/nested-skill), description, path --- -**0c-3. 匹配与排序** +**0c-3. Matching and Ranking** -加载 `references/scanner-patterns.md` §Skill-to-Project Matching Algorithm + §Priority Boost System。 +Load `references/scanner-patterns.md` §Skill-to-Project Matching Algorithm + §Priority Boost System. -**技能评分:** 标签匹配 +3、框架匹配 +3、类别对齐 +1、通用 +0 -**插件评分:** 工具匹配 +3、领域匹配 +1、通用 +0 +**Skill Scoring:** Tag match +3, Framework match +3, Category alignment +1, General +0 +**Plugin Scoring:** Tool match +3, Domain match +1, General +0 -**优先级加成系统(Priority Boost):** -检测到 ECC、superpowers、andrej-karpathy-skills、oh-my-claudecode 或深度资源时 → base score = max(normal_score, 10),标记 ⭐ 置顶。 +**Priority Boost System:** +When ECC, superpowers, andrej-karpathy-skills, oh-my-claudecode, or deep resources are detected → base score = max(normal_score, 10), mark with ⭐ pinned to top. -**按意图过滤:** +**Filter by intent:** -| 意图 | 优先推荐 | 降权 | -|------|---------|------| -| 开发新功能 | 对应语言的开发技能、代码生成工具 | 审查/调试类 | -| 审查代码 | 代码审查、PR 审查、lint 技能 | — | -| 修复 Bug | 调试、错误追踪、测试技能 | — | -| Fork 项目 | 项目分析、贡献指南、PR 管理、代码审查相关技能 | — | -| 探索工具 | 不做过滤,展示全部匹配结果 | — | +| Intent | Prioritize | Deprioritize | +|--------|------------|--------------| +| Develop New Feature | Language-specific development skills, code generation tools | Review/debugging categories | +| Review Code | Code review, PR review, lint skills | — | +| Fix Bug | Debugging, error tracking, testing skills | — | +| Fork Project | Project analysis, contribution guide, PR management, code review-related skills | — | +| Explore Tools | No filtering, show all matched results | — | -**输出三个独立列表(始终按此顺序):** -1. ⭐ 优先推荐(加成插件/深度资源 — 始终最先) -2. 📋 推荐技能(top 5-10,项目匹配) -3. 🔌 推荐插件(top 3-5,项目匹配) +**Output three separate lists (always in this order):** +1. ⭐ Priority Recommendations (boosted plugins/deep resources — always first) +2. 📋 Recommended Skills (top 5-10, project-matched) +3. 🔌 Recommended Plugins (top 3-5, project-matched) -未匹配项保留给 Step 0c-6 全量导出。 +Unmatched items are kept for Step 0c-6 full export. --- -**0c-4. 交互式推荐(⚠️ 强制步骤)** +**0c-4. Interactive Recommendation (⚠️ Mandatory Step)** -展示推荐结果,使用以下模板: +Display recommendation results using the following template: ```markdown -## 🔍 项目识别结果 +## 🔍 Project Identification Results -**项目:** [项目名或路径] -**技术栈:** [语言] + [框架] + [构建工具] -**检测依据:** [发现的配置文件列表] +**Project:** [project name or path] +**Tech Stack:** [language] + [framework] + [build tool] +**Detection Basis:** [list of discovered config files] -## ⭐ 优先推荐(核心能力增强) +## ⭐ Priority Recommendations (Core Capability Enhancement) -> 以下插件/资源提供基础能力增强,无论项目类型都强烈建议启用。 +> The following plugins/resources provide foundational capability enhancement and are strongly recommended regardless of project type. -| # | 名称 | 类型 | 描述 | 包含的未加载资源 | -|---|------|------|------|----------------| -| 1 | `everything-claude-code` | 插件 | AI 行为配置/安全指南 | SOUL.md, RULES.md, AGENTS.md, COMMANDS-QUICK-REF.md, WORKING-CONTEXT.md, the-security-guide.md, agent.yaml, 嵌套技能 | -| 2 | `superpowers` | 插件 | 核心工作流技能 | AGENTS.md, hooks.json, GEMINI.md | -| 3 | `andrej-karpathy-skills` | 插件 | Karpathy 编码准则 | CURSOR.md, karpathy-guidelines.mdc | -| 4 | `oh-my-claudecode` | 插件 | 多 Agent 编排 | 数十个嵌套技能 (`.agents/skills/*/SKILL.md`) | +| # | Name | Type | Description | Unloaded Resources Included | +|---|------|------|-------------|----------------------------| +| 1 | `everything-claude-code` | Plugin | AI behavior configuration / security guide | SOUL.md, RULES.md, AGENTS.md, COMMANDS-QUICK-REF.md, WORKING-CONTEXT.md, the-security-guide.md, agent.yaml, nested skills | +| 2 | `superpowers` | Plugin | Core workflow skills | AGENTS.md, hooks.json, GEMINI.md | +| 3 | `andrej-karpathy-skills` | Plugin | Karpathy coding guidelines | CURSOR.md, karpathy-guidelines.mdc | +| 4 | `oh-my-claudecode` | Plugin | Multi-Agent orchestration | Dozens of nested skills (`.agents/skills/*/SKILL.md`) | -## 📋 推荐技能(按匹配度排序) +## 📋 Recommended Skills (Sorted by Match) -| # | 名称 | 描述 | 匹配理由 | 来源 | -|---|------|------|---------|------| +| # | Name | Description | Match Reason | Source | +|---|------|-------------|--------------|--------| -## 🔌 推荐插件(按匹配度排序) +## 🔌 Recommended Plugins (Sorted by Match) -| # | 名称 | 描述 | 匹配理由 | 类型 | -|---|------|------|---------|------| +| # | Name | Description | Match Reason | Type | +|---|------|-------------|--------------|------| ``` -> 💡 如插件列表为空,则显示:"未检测到与当前项目强相关的插件。" +> 💡 If the plugin list is empty, display: "No strongly related plugins detected for the current project." -**使用 `AskUserQuestion` 询问:** -> "以上是根据当前项目为您推荐的技能、插件和未加载资源,请问您希望如何处理?" +**Use `AskUserQuestion` to prompt:** +> "Based on your current project, these are the recommended skills, plugins, and unloaded resources. How would you like to proceed?" -提供以下选项: -- **一键启用所有推荐** — 在后续对话中主动使用所有推荐项 -- **逐项选择** — 由用户指定启用哪些(可输入编号) -- **跳过,本次不启用** — 记录选择,本次会话不再重复推荐 -- **了解更多** — 展开某个技能/插件/深度资源的详细说明(用户指定名称) -- **加载未加载资源** — 对深度探索发现的 SOUL/RULES/AGENTS 等文件,询问是否需要手动加载 +Provide the following options: +- **Enable All Recommendations** — Actively use all recommended items in subsequent conversation +- **Select Individually** — Let the user specify which ones to enable (enter by number) +- **Skip, Don't Enable This Time** — Record the choice, no repeated recommendations for this session +- **Learn More** — Expand detailed explanation for a specific skill/plugin/deep resource (user specifies name) +- **Load Unloaded Resources** — For SOUL/RULES/AGENTS files discovered during deep exploration, ask if manual loading is needed -**联动钩子(仅 PACKAGE_MODE = true):** +**Linkage Hooks (only when PACKAGE_MODE = true):** -对推荐列表中未安装的插件标记 🆕。用户选择后,匹配 `integrates_with: plugin-installation`: -- 若用户选择了未安装的能力 → 提示:"💡 检测到你尚未安装 [name]。是否需要使用 **快速插件安装器** 来安装它?" +Mark uninstalled plugins in the recommendation list with 🆕. After user selection, match `integrates_with: plugin-installation`: +- If the user selected an uninstalled capability → prompt: "💡 It looks like [name] is not yet installed. Would you like to use the **Quick Plugin Installer** to install it?" --- -**0c-5. 指令发现(仅在用户完成 0c-4 选择后执行)** +**0c-5. Command Discovery (Only Runs After User Completes 0c-4 Selection)** -⚠️ 若用户选择「跳过」→ 跳至 0c-6 +⚠️ If the user chooses "Skip" → jump to 0c-6 -加载 `references/scanner-patterns.md` §Command Discovery Reference。 +Load `references/scanner-patterns.md` §Command Discovery Reference. -**5a. MCP 工具发现(仅扫描用户已选择的插件):** -1. 使用 `ListMcpResourcesTool` 枚举 MCP 资源,或扫描系统提示中 `mcp__` 前缀工具 -2. 仅过滤属于用户**已选择**插件的工具 -3. 每个工具推断:作用(做什么)+ 适用场景(什么时候用) +**5a. MCP Tool Discovery (only scan plugins the user selected):** +1. Use `ListMcpResourcesTool` to enumerate MCP resources, or scan system prompts for `mcp__` prefixed tools +2. Only filter tools belonging to the user's **selected** plugins +3. For each tool, infer: purpose (what it does) + applicable scenario (when to use it) -**5b. Slash 命令发现:** -从系统提示中提取 `/` 命令,匹配所选技能类别/能力 +**5b. Slash Command Discovery:** +Extract `/` commands from system prompts, matching the selected skill categories/capabilities -**5c. 展示模板:** +**5c. Display Template:** ```markdown -## 🔧 所选工具的可用指令 +## 🔧 Available Commands for Selected Tools -根据您选择的 [skill-names] 和 [plugin-names],以下是可用的指令: +Based on your selection of [skill-names] and [plugin-names], here are the available commands: -### 🛠 MCP 工具指令 +### 🛠 MCP Tool Commands #### [Selected Plugin Name] -| 工具名称 | 作用 | 适用场景 | -|---------|------|---------| -| `mcp__*__tool_name` | [一句话描述] | [什么情况下使用] | +| Tool Name | Purpose | Applicable Scenario | +|-----------|---------|---------------------| +| `mcp__*__tool_name` | [one-line description] | [when to use] | -### ⌨️ 相关 Slash 命令 +### ⌨️ Related Slash Commands -| 命令 | 作用 | 适用场景 | -|------|------|---------| -| `/command-name` | [功能描述] | [什么情况下使用] | +| Command | Purpose | Applicable Scenario | +|---------|---------|---------------------| +| `/command-name` | [function description] | [when to use] | ``` -> 💡 如果选中的插件没有 MCP 工具或当前无 MCP 连接,显示:"所选插件当前无可用的 MCP 工具指令。" -> 💡 Slash 命令始终可用,至少列出与所选技能相关的通用命令。 +> 💡 If the selected plugins have no MCP tools or there is no MCP connection, display: "Selected plugins currently have no available MCP tool commands." +> 💡 Slash commands are always available; at least list general commands related to the selected skills. --- -**0c-6. 全量导出(⚠️ 先问后导)** +**0c-6. Full Export (⚠️ Ask Before Exporting)** -必须获得用户同意后才导出。 +Must obtain user consent before exporting. -询问用户: -> "是否需要将所有已安装的技能、插件和指令完整列表导出到文件?这样您可以离线浏览所有可用能力。" +Ask the user: +> "Would you like to export a complete list of all installed skills, plugins, and commands to a file? This way you can browse all available capabilities offline." -若用户同意,追问三个选项(使用 `AskUserQuestion`): -1. **目标导出目录** — 输入路径(如 `D:\docs\skills-list\`) -2. **输出语言** — 自由输入任意语言(默认跟随当前对话语言) -3. **输出格式** — `Markdown`(推荐)/ `JSON` / `纯文本` +If the user agrees, ask three follow-up questions (using `AskUserQuestion`): +1. **Target export directory** — enter a path (e.g., `D:\docs\skills-list\`) +2. **Output language** — free input of any language (default: follow the current conversation language) +3. **Output format** — `Markdown` (recommended) / `JSON` / `Plain Text` -**导出内容结构:** 加载 `references/scanner-patterns.md` §Export Field Definitions。 +**Export Content Structure:** Load `references/scanner-patterns.md` §Export Field Definitions. -导出文件命名:`{project-name}-skills-plugins-export.{format}` +Export file naming: `{project-name}-skills-plugins-export.{format}` ```markdown -# [标题 — 使用用户指定语言] +# [Title — in user-specified language] -> 导出时间: [timestamp] -> 项目: [project path] -> 总计: [N] 个技能, [M] 个插件, [K] 个指令 -> 语言: [用户指定的语言] +> Export time: [timestamp] +> Project: [project path] +> Total: [N] skills, [M] plugins, [K] commands +> Language: [user-specified language] -## 📋 技能 (Skills) — 按分类 +## 📋 Skills — By Category ### [Category] -| 名称 | 描述 | 标签 | 来源 | 文件路径 | +| Name | Description | Tags | Source | File Path | | ... | ... | ... | ... | ... | -## 🔌 插件 (Plugins) — 按类型 +## 🔌 Plugins — By Type ### [Type] -| 名称 | 类型 | 命令 | 描述 | 来源 | +| Name | Type | Command | Description | Source | | ... | ... | ... | ... | ... | -## 🔧 指令 (Commands) +## 🔧 Commands -### 🛠 MCP 工具指令 — 按插件分组 +### 🛠 MCP Tool Commands — Grouped by Plugin #### [Plugin Name] -| 工具名称 | 作用 | 适用场景 | -|---------|------|---------| +| Tool Name | Purpose | Applicable Scenario | +|-----------|---------|---------------------| -### ⌨️ Slash 命令 — 按分类 +### ⌨️ Slash Commands — By Category #### [Category] -| 命令 | 作用 | 适用场景 | -|------|------|---------| +| Command | Purpose | Applicable Scenario | +|---------|---------|---------------------| ``` --- -**0c-7. 上下文持久化** +**0c-7. Context Persistence** -- 用户选择「跳过」→ 记录到会话上下文,本次会话不再重复推荐(除非项目指纹显著变化) -- 用户选择特定技能/插件 → 记录接受列表,供后续联动引用 -- 项目指纹显著变化时重新触发发现。**显著变化定义为以下任一:** - - 新增了任意语言/框架配置文件(如新出现 `package.json`、`go.mod`、`Cargo.toml`、`pom.xml` 等) - - 新增了子目录且子目录包含独立的项目配置文件 - - 用户通过 `git checkout` 切换到了不同技术栈的分支 - - 工作目录切换到了同一 monorepo 的不同子项目 -- **仅文件内容修改(不改变技术栈)不触发重新发现** -- 其他包内技能完成主要操作后 → 提示联动发现 -- **缓存记录**:扫描完成后,在会话上下文中记录 `_SCAN_CACHE = { timestamp: <当前时间>, fingerprint: <项目指纹标签>, ttl_hours: <从 rules 读取的 cache_ttl_hours,默认 24> }`,供后续调用复用 +- User chooses "Skip" → record in session context, do not repeat recommendations in this session (unless project fingerprint changes significantly) +- User selects specific skills/plugins → record acceptance list for subsequent linkage references +- Re-trigger discovery when the project fingerprint changes significantly. **Significant change is defined as any of the following:** + - A new language/framework configuration file is added (e.g., new `package.json`, `go.mod`, `Cargo.toml`, `pom.xml`, etc.) + - A new subdirectory is added that contains its own project configuration files + - The user switches to a branch with a different tech stack via `git checkout` + - The working directory switches to a different subproject within the same monorepo +- **Content-only modifications (without changing the tech stack) do not trigger re-discovery** +- After other in-package skills complete their main operation → prompt linked discovery +- **Cache Record**: After scanning completes, record `_SCAN_CACHE = { timestamp: , fingerprint: , ttl_hours: }` in the session context for reuse on subsequent calls --- -非「启动新项目」意图在此步骤结束,不进入强制六步流程。但能力扫描结果可作为后续工作的上下文。 +Non-"Start New Project" intents end at this step and do not enter the mandatory six-step process. However, the capability scan results can serve as context for subsequent work. --- -### 强制六步流程(仅「启动新项目」时执行) - -以下六步是原 kickoff 的完整流程,**必须按顺序执行**。 - -### 第一步:澄清"为什么"与"是什么" -向用户提问(至少覆盖以下 3 个问题): -1. 这个项目解决了谁的什么痛点?不做会有什么损失? -2. 成功的可衡量标准是什么?(例如:日活>1000,成本<0.1元/次,首个付费用户等) -3. 请用一句话填空:"我们要为【谁】解决【什么问题】,通过【什么方式】,达到【什么效果】。" - -- 如果用户无法回答第 3 问,则引导其先完成"一句话定义",再继续。 -- 如果是 AI Agent 项目,额外追问:"不用 Agent 行不行?规则引擎能否解决?" -- 如需更详细的问题定义指导,加载 `references/project-checklist.md` 第一章或 `references/ai-agent-checklist.md` 第一章。 - -### 第二步:圈定边界 – 明确"不做什么" -要求用户列出第一版的所有想做的功能,然后: -- 强制砍掉 80%,只保留**能验证核心假设的最小集合(MVP)**。 -- 明确三重约束(时间、成本/资源、质量/范围),并指出"最多只能同时保两个"。 -- 如果是 Agent 项目,额外列出**禁飞区**(例如:不能删除生产数据、不能对外转账、不能发送未审核内容)。 -- 边界讨论遇到困难时,加载 `references/project-checklist.md` 第二章。 - -**联动钩子(仅 PACKAGE_MODE = true 时执行):** - -确认项目技术栈后,扫描兄弟技能的 `capabilities`,匹配 `integrates_with: plugin-installation`: -- 匹配成功 → 提示用户:"💡 检测到你的项目使用 [技术栈]。是否需要安装相关的 MCP Server(如 GitHub MCP、Playwright、Context7)来增强开发体验?" - -### 第三步:快速风险摸底 -让用户回答: -- 技术、人力、市场、合规四方面是否有明显障碍? -- 写下**最可能让项目失败的三件事**,并为每件想一个 B 计划(即便只是"换方案,慢 30%")。 -- 对于 AI Agent:用当前最强模型做"纸上原型"手动模拟 3~5 步,观察是否会跑偏。若跑偏,要求简化任务或增加护栏。 -- 详细可行性分析模板参见 `references/project-checklist.md` 第三章;Agent 特有风险评估参见 `references/ai-agent-checklist.md` 第四章。 - -### 第四步:利益相关者与期望对齐 -- 引导用户识别核心圈(执行者)、影响圈(资源方)、外围圈(用户/监管)。 -- 强制建议:"拿着第一步的'项目定义'和'成功标准',去跟关键人物口头确认一次,再继续。" -- 完整利益相关者分析指导参见 `references/project-checklist.md` 第四章。 - -### 第五步:绘制粗糙路线图(仅里程碑) -- 输出 3~5 个里程碑(以周为单位),每个里程碑必须有明确的**产出物**和**验收标准**。 -- 最后,要求用户确认以下开工 Checklist: - - ☑ 项目定义与目标已和关键人确认 - - ☑ MVP 范围已明确(以及不做什么) - - ☑ 资源(时间、钱、人)已到位或得到承诺 - - ☑ 前三风险已有应对预案 - - ☑ 代码仓库、沟通群组、文档协作工具已就绪 -- 路线图设计参考参见 `references/project-checklist.md` 第五章。 - -### 第六步(关键):生成 CLAUDE.md —— 将思考成果固化到项目 - -在完成五步检查并确认代码风格后,**必须**执行以下流程: - -#### 6a. 确认用户意愿 -向用户确认: -> "我们已经完成了五步启动检查,并确认了项目的代码风格。现在要调用 /init 生成项目的 CLAUDE.md,把刚才讨论的内容 —— 项目定义、MVP 范围、里程碑、风险预案、风格约定 —— 都固化到项目根目录。是否继续?" - -- 如果用户同意,继续 6b。 -- 如果用户暂不需要,跳至 6d。 - -#### 6b. 检测已有 CLAUDE.md -检查项目根目录是否已存在 `CLAUDE.md` 文件: -- **若不存在**:直接执行 `/init` 命令。`/init` 是 Claude Code 的内置项目初始化命令,会引导生成标准的 CLAUDE.md 文件。技能已收集的五步检查信息都在对话上下文中,/init 可直接利用。 -- **若已存在**:读取现有 CLAUDE.md,执行逐段对比合并: - 1. 提取现有 CLAUDE.md 中的自定义命令、构建步骤、测试框架配置 → **保留不动** - 2. 对比五步检查结果,识别缺失章节(项目定义、MVP 范围、风险预案、风格约定) - 3. 仅补充缺失部分,不覆盖已有内容 - 4. 向用户展示合并差异摘要,确认后写入 - -#### 6c. 验证生成结果 -在 `/init` 执行完毕后: -- 检查项目根目录是否已生成或更新了 CLAUDE.md。 -- 如果生成成功,向用户展示摘要: - > "✅ CLAUDE.md 已生成。你的项目现在有了一个包含项目定义、MVP 范围、里程碑、风险预案和代码风格约定的标准入口文件。每次 Claude 进入这个项目时都会自动加载这些上下文。" -- 如果 `/init` 因任何原因未完成(如用户中途退出),使用下面的"输出模板"手动输出一份启动摘要,并告知用户随时可再次运行 `/init`。 - -**联动钩子(仅 PACKAGE_MODE = true 时执行,在 6c 成功后):** - -CLAUDE.md 生成成功后,本技能已内置完整的技能发现能力(Step 0c),可直接提示用户: -> "✅ CLAUDE.md 已生成。是否需要扫描当前项目技术栈,推荐匹配的技能和插件?" - -(无需通过 `integrates_with: skill-discovery` 跨技能联动——此能力内置于本技能中。) -- 同时检查其他兄弟技能的 `integrates_with`,如发现匹配则一并提示 - -#### 6d. 后备方案 -如果用户选择不执行 `/init`,输出完整的启动摘要(见下方模板),并告知: -> "了解。以下是本次启动检查的完整摘要。你可以随时运行 `/init` 来将这些内容固化为正式的 CLAUDE.md。" +### Mandatory Six-Step Process (Only for "Start New Project") + +The following six steps are the complete original kickoff flow — **must be executed in order**. + +### Step 1: Clarify the "Why" and the "What" +Ask the user (at minimum, cover these 3 questions): +1. Whose pain point does this project solve, and what is lost by not doing it? +2. What are the measurable criteria for success? (e.g., DAU > 1000, cost < 0.1 CNY per use, first paying customer, etc.) +3. Fill in the blank: "We are solving **[problem]** for **[who]**, through **[what means]**, to achieve **[what effect]**." + +- If the user cannot answer question 3, guide them to complete the "one-sentence definition" first before continuing. +- If it's an AI Agent project, additionally ask: "Can it be done without an Agent? Could a rule engine solve it?" +- For more detailed problem definition guidance, load Chapter 1 of `references/project-checklist.md` or Chapter 1 of `references/ai-agent-checklist.md`. + +### Step 2: Define Boundaries — Make Clear "What Not to Do" +Ask the user to list all desired features for the first version, then: +- Forcefully cut 80%, keeping only the **minimum set that validates the core hypothesis (MVP).** +- Make clear the triple constraints (time, cost/resources, quality/scope), and note that "at most two can be preserved simultaneously." +- For Agent projects, additionally list **no-fly zones** (e.g., cannot delete production data, cannot transfer money externally, cannot send unapproved content). +- When boundary discussions hit difficulty, load Chapter 2 of `references/project-checklist.md`. + +**Linkage Hooks (only when PACKAGE_MODE = true):** + +After confirming the project tech stack, scan sibling skills' `capabilities`, match `integrates_with: plugin-installation`: +- Match succeeds → prompt user: "💡 I see your project uses [tech stack]. Would you like to install related MCP Servers (such as GitHub MCP, Playwright, Context7) to enhance the development experience?" + +### Step 3: Quick Risk Assessment +Have the user respond to: +- Are there obvious obstacles in technology, personnel, market, or compliance? +- Write down the **three things most likely to cause project failure**, and come up with a Plan B for each (even if it's just "switch approaches, 30% slower"). +- For AI Agent: use the current strongest model to manually simulate 3-5 steps of a "paper prototype" and observe whether it goes off track. If it does, require task simplification or add guardrails. +- See Chapter 3 of `references/project-checklist.md` for detailed feasibility analysis templates; see Chapter 4 of `references/ai-agent-checklist.md` for Agent-specific risk assessment. + +### Step 4: Stakeholder Alignment +- Guide the user to identify the core circle (doers), influence circle (resource providers), and outer circle (users/regulators). +- Mandatory recommendation: "Take the 'project definition' and 'success criteria' from Step 1 and verbally confirm them with key people before proceeding." +- See Chapter 4 of `references/project-checklist.md` for complete stakeholder analysis guidance. + +### Step 5: Draw a Rough Roadmap (Milestones Only) +- Output 3-5 milestones (in weeks), each milestone must have a clear **deliverable** and **acceptance criteria**. +- Finally, ask the user to confirm the following startup checklist: + - ☑ Project definition and goals confirmed with key people + - ☑ MVP scope defined (and what's not included) + - ☑ Resources (time, money, people) secured or promised + - ☑ Contingency plans in place for the top three risks + - ☑ Code repository, communication channels, and documentation collaboration tools ready +- See Chapter 5 of `references/project-checklist.md` for roadmap design reference. + +### Step 6 (Critical): Generate CLAUDE.md — Solidify Thinking into the Project + +After completing the five-step check and confirming the code style, **must** execute the following process: + +#### 6a. Confirm User Willingness +Ask the user: +> "We've completed the five-step startup check and confirmed the project's code style. Now I'll call /init to generate the project's CLAUDE.md, solidifying everything we discussed — project definition, MVP scope, milestones, risk plans, style conventions — into the project root. Shall we proceed?" + +- If the user agrees, proceed to 6b. +- If the user is not ready yet, skip to 6d. + +#### 6b. Detect Existing CLAUDE.md +Check whether a `CLAUDE.md` file already exists in the project root: +- **If not exists**: directly execute the `/init` command. `/init` is Claude Code's built-in project initialization command, which guides the generation of a standard CLAUDE.md file. The five-step check information collected by the skill is all in the conversation context, and /init can use it directly. +- **If exists**: read the existing CLAUDE.md, perform a paragraph-by-paragraph comparison and merge: + 1. Extract custom commands, build steps, test framework configuration from existing CLAUDE.md → **keep unchanged** + 2. Compare against the five-step check results, identify missing sections (project definition, MVP scope, risk plans, style conventions) + 3. Only supplement the missing parts, do not overwrite existing content + 4. Show the user a merge diff summary, write after confirmation + +#### 6c. Verify Generation Result +After `/init` completes: +- Check whether CLAUDE.md was generated or updated in the project root. +- If generation succeeds, show the user a summary: + > "✅ CLAUDE.md has been generated. Your project now has a standard entry file containing project definition, MVP scope, milestones, risk plans, and code style conventions. Claude will automatically load this context every time it enters this project." +- If `/init` did not complete for any reason (e.g., the user exited mid-way), manually output a startup summary using the "Output Template" below, and let the user know they can run `/init` again at any time. + +**Linkage Hooks (only when PACKAGE_MODE = true, after 6c succeeds):** + +After CLAUDE.md is generated, this skill already has built-in complete skill discovery capability (Step 0c), so it can directly prompt the user: +> "✅ CLAUDE.md has been generated. Would you like to scan the current project's tech stack and recommend matching skills and plugins?" + +(No need for cross-skill linkage via `integrates_with: skill-discovery` — this capability is built into this skill.) +- Also check other sibling skills' `integrates_with`, and prompt if matches are found + +#### 6d. Fallback Plan +If the user chooses not to run `/init`, output the complete startup summary (see template below) and inform: +> "Understood. Here is the complete startup check summary. You can run `/init` at any time to solidify these contents as a formal CLAUDE.md." --- -## 代码风格保留规则(必须执行) +## Code Style Preservation Rules (Mandatory) -当本项目涉及生成任何代码、配置文件、注释模板或项目脚手架时,**必须**按以下优先级确定并保留风格: +When this skill involves generating any code, configuration files, comment templates, or project scaffolding, **must** determine and preserve style according to the following priority: -1. **主动探测**:检查用户是否已提供现有代码文件、`.editorconfig`、`eslint`/`prettier` 配置、或口头说明的风格偏好(如"我们用制表符缩进")。 -2. **若无既有风格,则采用行业默认推荐**(例如 Python 用 PEP8,JavaScript 用 2 空格缩进,注释使用 `#` 或 `//` 后跟一个空格),并在生成前向用户确认。 -3. **注释规范**:要求用户提供注释密度偏好(关键函数必写 / 仅复杂逻辑写 / 每一行都写)。默认采用"公共 API 和复杂逻辑写注释,自解释的语句不写"。 -4. **命名规范**:明确变量、函数、类、文件的命名风格(驼峰、下划线、大驼峰等),并统一应用到所有生成内容。 -5. **即使生成示例代码,也要符合上述风格**;若用户未指定,在代码块上方用注释标明"请按你的项目风格调整"。 +1. **Proactive Detection**: Check whether the user has provided existing code files, `.editorconfig`, `eslint`/`prettier` config, or verbally stated style preferences (e.g., "we use tab indentation"). +2. **If no existing style, adopt industry standard defaults** (e.g., PEP8 for Python, 2-space indentation for JavaScript, comments using `#` or `//` followed by a space), and confirm with the user before generation. +3. **Comment Conventions**: Ask the user for comment density preference (required for key functions / only complex logic / every line). Default: "write comments for public APIs and complex logic; omit for self-explanatory statements." +4. **Naming Conventions**: Clarify naming style for variables, functions, classes, and files (camelCase, snake_case, PascalCase, etc.), and apply consistently to all generated content. +5. **Even example code must follow the above style**; if the user has not specified, add a comment above the code block stating "Please adjust to your project's style." --- -## 针对 AI Agent 项目的额外检查项 +## Additional Checks for AI Agent Projects -若用户确认项目类型为 AI Agent,在完成上述六步后,追加以下问题(详细内容参见 `references/ai-agent-checklist.md`): -- 记忆系统(短期/长期)如何设计?(参见第三章) -- 规划策略(ReAct / Plan-and-Execute / 多 Agent)选哪一种?(参见第三章) -- 工具集的输入/输出格式是否严格定义?(参见第三章) -- 如何评估"好坏"?(任务成功率、工具调用准确率、成本)(参见第七章) -- 安全与伦理:防注入、权限最小化、透明度、合规是否已考虑?(参见第八章) +If the user confirms the project type is an AI Agent, append the following questions after completing the above six steps (see `references/ai-agent-checklist.md` for details): +- How is the memory system (short-term/long-term) designed? (See Chapter 3) +- Which planning strategy (ReAct / Plan-and-Execute / Multi-Agent) is chosen? (See Chapter 3) +- Are the tool set's input/output formats strictly defined? (See Chapter 3) +- How is "good vs bad" evaluated? (Task success rate, tool call accuracy, cost) (See Chapter 7) +- Security and ethics: have injection prevention, least privilege, transparency, and compliance been considered? (See Chapter 8) -并建议用户先实现一个**最小可行性 Agent**(模型调用 + 一个工具),再引入框架。 +And recommend that the user first implement a **minimum viable Agent** (model call + one tool) before introducing a framework. --- -## 输出模板(强制使用) +## Output Template (Mandatory) -在完成六步检查后,**必须**使用以下格式输出启动摘要(控制在 500 字以内): +After completing the six-step check, **must** output a startup summary using the following format (keep under 500 words): ```markdown -## 项目启动摘要:[项目名称] - -### 项目定义 -- **一句话**:[填入] -- **成功标准**:[可衡量指标] -- **利益相关者**:核心圈=[...], 影响圈=[...], 外围圈=[...] - -### MVP 范围 -- **包含**:[功能A, 功能B] -- **不包含**:[功能C, 功能D, 功能E] -- **约束**:时间=[Deadline], 资源=[预算/人力], 质量=[可妥协项] - -### 路线图 -| 里程碑 | 产出物 | 验收标准 | -|--------|--------|---------| -| W1 | [产出物] | [标准] | -| W2 | [产出物] | [标准] | -| W3 | [产出物] | [标准] | - -### 风险预案 -| 风险 | 可能性 | B计划 | -|------|--------|-------| -| [风险1] | 高/中/低 | [备选方案] | -| [风险2] | 高/中/低 | [备选方案] | -| [风险3] | 高/中/低 | [备选方案] | - -### 代码风格约定 -- 缩进:[空格/制表符,数量] -- 注释:[密度与格式] -- 命名:[变量/函数/类规则] - -### 开工状态 -☑ 全部确认完成 → /init 已调用,CLAUDE.md 已生成 ✅ +## Project Startup Summary: [project name] + +### Project Definition +- **One-liner**: [fill in] +- **Success Criteria**: [measurable metrics] +- **Stakeholders**: Core circle=[...], Influence circle=[...], Outer circle=[...] + +### MVP Scope +- **Includes**: [Feature A, Feature B] +- **Excludes**: [Feature C, Feature D, Feature E] +- **Constraints**: Time=[Deadline], Resources=[budget/headcount], Quality=[compromise area] + +### Roadmap +| Milestone | Deliverable | Acceptance Criteria | +|-----------|-------------|---------------------| +| W1 | [deliverable] | [criteria] | +| W2 | [deliverable] | [criteria] | +| W3 | [deliverable] | [criteria] | + +### Risk Plan +| Risk | Likelihood | Plan B | +|------|------------|--------| +| [Risk 1] | High/Medium/Low | [alternative] | +| [Risk 2] | High/Medium/Low | [alternative] | +| [Risk 3] | High/Medium/Low | [alternative] | + +### Code Style Conventions +- Indentation: [spaces/tabs, count] +- Comments: [density and format] +- Naming: [variable/function/class rules] + +### Startup Status +☑ All confirmed → /init called, CLAUDE.md generated ✅ ``` --- -## 边界条件处理 +## Edge Case Handling -### 用户已有 CLAUDE.md -如果检测到项目根目录已存在 CLAUDE.md(在第六步之前或之中检测到),先询问用户是覆盖更新还是合并补充。建议策略:读取现有 CLAUDE.md 内容,与五步检查结果对比,补充缺失的部分而非完全覆盖——CLAUDE.md 中可能已包含项目特有的构建命令、测试框架等不应被覆盖的信息。 +### User Already Has CLAUDE.md +If a CLAUDE.md already exists in the project root (detected before or during Step 6), first ask the user whether to overwrite or merge. Recommended strategy: read the existing CLAUDE.md content, compare with the five-step check results, supplement missing parts rather than completely overwriting — the CLAUDE.md may already contain project-specific build commands, test framework configurations, etc., that should not be overwritten. -### 非项目所有者场景 -如果用户明确表示是为他人项目提供建议(如"帮我朋友看看他的项目计划"),则: -- 跳过第六步(/init 调用),不修改他人的 CLAUDE.md -- 跳过代码风格询问(除非用户主动问) -- 集中精力完成五步分析和建议 -- 输出启动摘要供用户转发 +### Non-Project-Owner Scenario +If the user explicitly indicates they are providing advice for someone else's project (e.g., "help me take a look at my friend's project plan"), then: +- Skip Step 6 (/init call), do not modify someone else's CLAUDE.md +- Skip code style questions (unless the user asks) +- Focus on completing the five-step analysis and recommendations +- Output a startup summary for the user to forward -### 用户只要求部分检查 -用户可能只关心某个方面(如"帮我只做风险摸底")。灵活处理: -- 用户可以选择只走某几个步骤 -- 完成所请求的步骤后,简要询问是否需要完成剩余步骤 -- 不强制走完六步,但总要提及"如果需要完整启动检查,随时可以说" +### User Only Requests Partial Check +The user may only care about a specific aspect (e.g., "just do a risk assessment for me"). Handle flexibly: +- The user can choose to go through only some steps +- After completing the requested steps, briefly ask if they'd like to complete the remaining steps +- Do not force all six steps, but always mention "if you need a full startup check, feel free to say so" -### 项目范围极小 +### Minimal Project Scope -满足以下**任意 2 条**即启用极简模式: +Enable minimal mode when **any 2** of the following conditions are met: -1. **任务描述为单文件级**:用户描述为「写一个脚本」「一个工具」「一个函数」「批量处理」等单文件级任务 -2. **源代码文件数量少**:项目目录中源代码文件 < 3 个(不含 `README.md`、`.gitignore`、`*.json`/`*.toml`/`*.yaml` 等配置文件) -3. **用户明确要求简化**:用户明确表示「不需要完整流程」「简单弄一下就行」「快速过一遍」 +1. **Single-file level task description**: the user describes it as "write a script", "a tool", "a function", "batch processing", or similar single-file level tasks +2. **Few source code files**: the project directory has < 3 source code files (excluding `README.md`, `.gitignore`, `*.json`/`*.toml`/`*.yaml` and other config files) +3. **User explicitly requests simplification**: the user explicitly says "don't need the full process", "just a quick pass", "fast-track it" -**仅满足 1 条时**,追问用户确认是否启用极简模式。 +**When only 1 condition is met**, ask the user to confirm whether to enable minimal mode. -极简模式内容: -- **执行**:问题定义(一句话)+ 代码风格确认 -- **跳过**:MVP 边界圈定(第二步)、利益相关者分析(第四步)、里程碑路线图(第五步) -- **仍执行**:快速风险摸底(第三步,简化为"最可能出错的一件事") -- **仍执行**:第六步 CLAUDE.md 生成(若项目目录存在) -- 完成后提示:"这是一个极简项目。如需完整启动检查流程,随时可以说。" +Minimal mode content: +- **Do**: Problem definition (one-liner) + code style confirmation +- **Skip**: MVP boundary scoping (Step 2), stakeholder analysis (Step 4), milestone roadmap (Step 5) +- **Still do**: Quick risk assessment (Step 3, simplified to "the one thing most likely to go wrong") +- **Still do**: Step 6 CLAUDE.md generation (if project directory exists) +- Upon completion, prompt: "This is a minimal project. If you need the full startup check process, feel free to say so." --- -## 错误处理 - -| 场景 | 处理方式 | -|------|---------| -| `~/.claude/skills/` 不存在或无法读取 | 跳过技能扫描,仅推荐插件和命令,不报错 | -| SKILL.md frontmatter 格式错误 | 跳过该技能,记录名称到跳过列表,继续扫描其他技能 | -| `settings.json` 无 `mcpServers` 字段 | 跳过 MCP 插件扫描,仅扫描本地插件目录 | -| `.discovery-rules.json` JSON 解析失败 | 静默跳过,使用内置默认规则 | -| Glob 操作超时(>5 秒) | 跳过深度探索,标注「部分插件未深度扫描」 | -| 深度探索文件 > 50KB | 仅读前 5 行判断类型,不读取全文 | -| PACKAGE_MODE 检测失败(任何原因) | 降级为 PACKAGE_MODE = false,静默运行 | -| `/init` 执行失败 | 手动输出启动摘要,提示用户可随时重试 | -| `gh repo fork` 失败(未登录/权限不足) | 提示用户先执行 `gh auth login`,或手动在 GitHub 网页 fork 后提供 clone URL | -| 目标仓库不存在(Fork 模式) | 提示确认 URL,重新输入 owner/repo | -| Fork 已存在且用户选择同步 | 执行 `git fetch upstream && git merge upstream/main` 同步上游变更 | -| GitHub MCP 和 `gh` CLI 均不可用(Fork 模式) | 提示用户手动在浏览器中 Fork,引导用户提供 clone URL 继续 | -| 用户指定的仓库非 GitHub(Fork 模式) | 提示仅支持 GitHub 仓库,询问是否继续或取消 | -| Clone 目标目录冲突(Fork 模式) | 询问用户:复用现有目录 / 重新 clone / 选择其他目录 | +## Error Handling + +| Scenario | Handling | +|----------|----------| +| `~/.claude/skills/` does not exist or cannot be read | Skip skill scan, only recommend plugins and commands, no error reported | +| SKILL.md frontmatter format error | Skip that skill, record its name in a skip list, continue scanning other skills | +| `settings.json` has no `mcpServers` field | Skip MCP plugin scan, only scan local plugin directory | +| `.discovery-rules.json` JSON parse failure | Silently skip, use built-in default rules | +| Glob operation times out (>5 seconds) | Skip deep exploration, mark as "some plugins not deeply scanned" | +| Deep exploration file > 50KB | Only read first 5 lines to determine type, do not read full content | +| PACKAGE_MODE detection fails (any reason) | Degrade to PACKAGE_MODE = false, run silently | +| `/init` execution fails | Manually output startup summary, prompt user they can retry anytime | +| `gh repo fork` fails (not logged in / insufficient permissions) | Prompt user to run `gh auth login` first, or manually fork on GitHub website and provide clone URL | +| Target repository does not exist (Fork mode) | Prompt to confirm URL, re-enter owner/repo | +| Fork already exists and user chooses sync | Execute `git fetch upstream && git merge upstream/main` to sync upstream changes | +| GitHub MCP and `gh` CLI both unavailable (Fork mode) | Prompt user to manually Fork in browser, guide them to provide clone URL to continue | +| User-specified repository not on GitHub (Fork mode) | Prompt that only GitHub repositories are supported, ask whether to continue or cancel | +| Clone target directory conflict (Fork mode) | Ask the user: reuse existing directory / re-clone / choose another directory | --- -## 交互风格 -- 使用简洁的清单式提问,每次最多问 3 个问题,避免信息过载。 -- 对用户的回答进行总结并复述,确保对齐。 -- 最后输出一份 **< 500 字的启动摘要**,包含:项目定义、MVP 范围、关键里程碑、前三风险、风格约定、CLAUDE.md 生成状态。 -- 全程使用中文与用户沟通。 +## Interaction Style +- Use concise checklist-style questions, asking at most 3 questions at a time to avoid information overload. +- Summarize and paraphrase the user's answers to ensure alignment. +- Finally output a **< 500 word startup summary** containing: project definition, MVP scope, key milestones, top three risks, style conventions, CLAUDE.md generation status. diff --git a/skills/universal-project-kickoff/locale/SKILL.cn.md b/skills/universal-project-kickoff/locale/SKILL.cn.md new file mode 100644 index 0000000..e968308 --- /dev/null +++ b/skills/universal-project-kickoff/locale/SKILL.cn.md @@ -0,0 +1,830 @@ +--- +name: universal-project-kickoff +description: > + 通用型项目启动与能力发现规则。已吸收原 proactive-skill-discovery 的全部能力(该技能已删除)。 + 新增 Fork 模式:参与开源贡献(fork → clone → 开发 → PR)。 + 当用户说以下任何话时,**必须**触发此技能: + "我要开始一个新项目"、"帮我规划一个新功能"、"想启动一个 AI Agent"、 + "如何着手做 X"、"不知道从哪开始"、"帮我搭个架子"、"项目初始化"、 + "检查一下我的项目计划"、"帮我理一理思路"、"新项目怎么开始"、 + "打算搞个 side project"、"帮我做项目风险排查"、 + "有哪些可用的技能/插件"、"推荐什么工具"、"/discover"、 + "帮我审查代码"、"帮我修 Bug"、"我要开发一个新功能"、 + "我想参与这个开源项目"、"帮我 fork 这个仓库"、"我想给这个项目提 PR"。 + 本技能先探测用户意图(启动项目/开发功能/审查代码/修复Bug/探索工具/Fork项目), + 再分流到对应子流程。启动新项目时执行六步强制流程(为什么-是什么-边界-风险-利益-里程碑-固化CLAUDE.md) + + 代码风格确认 + 能力推荐,最后调用 /init 生成项目的 CLAUDE.md 将思考成果永久固化。 + Fork 项目时执行五步子流程(获取仓库 → Fork → Clone → 项目分析 → 贡献工作流引导)。 + 其他意图则根据技术栈推荐匹配的技能和插件。 + 即使用户没有明确说"启动检查",只要涉及从零规划任何项目或需要工具推荐,就应触发。 +version: "4.0.0" +risk: safe +source: community +capabilities: ["project-setup", "risk-assessment", "mvp-planning", "skill-discovery", "capability-scanning", "project-analysis", "fork-workflow"] +integrates_with: ["plugin-installation", "pr-management"] +metadata: + category: meta + tags: [project-startup, planning, checklist, mvp-definition, risk-assessment, init, code-style, discovery, recommendation, skills, plugins, commands, fork, contribute, open-source] + compatibility: 需要 /init 命令(Claude Code 内置),无其他外部依赖 +locale: zh-CN +--- + +# 通用型项目启动与能力发现 + +## 核心原则 + +**先开枪,后瞄准,但开枪前得知道靶子大概在哪个方向。** +本技能帮助你在 15 分钟内完成启动前的关键决策,避免"热情直冲"带来的返工。同时,**全程保留项目的代码风格(包括注释、命名、格式等)** —— 这意味着在生成任何代码示例、项目结构或脚手架时,都要主动询问或推断用户既有的风格规范,并严格遵循。 + +本技能已吸收原 `proactive-skill-discovery` 的全部能力(该技能已删除)。在开始前,会先探测你的意图——是启动新项目、开发功能、审查代码、修复 Bug、探索工具还是参与开源(Fork)——然后推荐最匹配的技能和插件。 + +## 不触发条件 + +以下情况**不要**触发本技能: +- 用户已明确指定要使用的具体技能(如 `/github-pr-reviewer`) +- 对话仅为简单问答,不涉及项目开发任务 +- 用户在当前会话中已明确表示不需要推荐或启动检查 + +## 参考文件 + +本技能附带六份参考文档,在技能执行过程中按以下规则加载: + +- **`references/project-checklist.md`**:通用项目启动检查清单完整版。当用户对某一步骤要求更详细的解释、希望看到完整开工 Checklist 原文、或需要确认是否遗漏检查项时加载。 +- **`references/ai-agent-checklist.md`**:AI Agent 项目专项检查清单。当用户确认项目类型为 AI Agent、询问 Agent 特有的风险或注意事项、或需要设计 Agent 的"大脑"架构时加载。 +- **`references/scanner-patterns.md`**:项目指纹检测矩阵、评分算法公式、插件映射表和命令发现参考。执行技术栈确认和能力匹配时参考。 +- **`references/language-guide.md`**:编程语言优劣势参考表。当用户不确定用什么语言时加载。 +- **`references/hook-config.md`**:可选的 Claude Code hook 配置指南。当用户希望在新会话启动或检测到新项目时自动触发本技能,参考此文档配置 SessionStart/PostToolUse hook。 +- **`references/validation-scenarios.md`**:验证场景集合。执行完技能后进行 LLM 自检时参考,确保推荐结果与预期一致。覆盖 8 种典型项目类型和 7 种边界情况。 + +## 包联动 + +本技能支持与 minecraft269-skills 插件包内其他技能自动联动。执行以下检测: + +1. Glob 搜索 `~/.claude/plugins/minecraft269-skills/.claude-plugin/plugin.json` +2. 若找到 → `PACKAGE_MODE = true`,可发现并联动兄弟技能 +3. 若未找到 → `PACKAGE_MODE = false`,跳过所有跨技能逻辑(静默降级) + +当 `PACKAGE_MODE = true` 时: +- 识别项目技术栈后可联动 `integrates_with: plugin-installation`(快速安装插件) +- CLAUDE.md 生成后可提示用户运行能力扫描(本技能已内置,无需跨技能联动) +- 扫描兄弟 SKILL.md 的 `capabilities` 字段,匹配本技能的 `integrates_with` 标签 +- 仅在匹配成功时显示联动提示 + +详见 `_shared/package-context.md`。**任何检测失败都默认 PACKAGE_MODE = false,不得报错或中断。** + +--- + +## 使用流程 + +### Step 0:意图探测 + +**先推断,后询问。** 从用户的原始消息中提取关键词预判意图,只有无法确定时才弹出 `AskUserQuestion`。 + +#### 0.1 意图预判(关键词匹配) + +从用户消息中匹配以下模式(大小写不敏感): + +| 关键词组合 | 推断意图 | 直接分流 | +|-----------|---------|---------| +| "启动" / "开始" / "新建" / "创建" / "初始化" / "搭个" / "从零" **+** "项目" | 🚀 启动新项目 | → Step 0b 语言确认 → 强制六步流程 | +| "开发" / "添加" / "实现" / "做" **+** "功能" / "feature" | 💻 开发新功能 | → Step 0c 技术栈确认 + 能力推荐 | +| "审查" / "review" / "检查" **+** "代码" / "PR" / "pull request" | 🔍 审查代码 | → Step 0a 目标确认 | +| "修复" / "修" / "改" / "fix" / "debug" **+** "bug" / "问题" / "报错" | 🐛 修复 Bug | → Step 0a 目标确认 | +| "有什么" / "推荐" / "哪些" / "可用" / "discover" **+** "技能" / "插件" / "工具" / "能力" | 🔧 探索工具 | → Step 0c 完整能力扫描 | +| "fork" / "参与" / "贡献" / "提 PR" / "contribute" / "上游" **+** "项目" / "仓库" / "开源" / "代码" / "repo" | 🍴 Fork 项目 | → Step 0a Fork 分支 | + +**匹配规则:** +- 若匹配到**唯一意图** → 直接分流,跳过 AskUserQuestion,在分流前用一句话确认(如"识别到你想要[意图],直接开始…") +- 若**多个意图匹配**或**无匹配** → 使用 `AskUserQuestion` 询问 + +#### 0.2 交互式询问(仅在意图不明确时使用) + +> "你想要做什么?" + +| 选项 | 说明 | 后续分流 | +|------|------|---------| +| 🚀 **启动新项目** | 从零开始一个项目 | → 追问语言/框架 → Step 0b 语言确认 → 进入强制六步流程 | +| 💻 **开发新功能** | 在现有项目中添加功能 | → 进入 Step 0c 技术栈确认 + 能力推荐 | +| 🔍 **审查代码** | Review PR 或代码变更 | → Step 0a 目标确认 → Step 0c 技术栈确认 + 审查工具推荐 | +| 🐛 **修复 Bug** | 排查和修复问题 | → Step 0a 目标确认 → Step 0c 技术栈确认 + 调试工具推荐 | +| 🔧 **探索工具** | 看看有什么可用的技能/插件/命令 | → 进入 Step 0c 完整能力扫描 | +| 🍴 **Fork 项目** | Fork 开源仓库,在本地开发并贡献 PR | → Step 0a Fork 分支 | +| 📋 **其他** | 用户自由输入 | → 根据输入内容智能匹配分流 | + +#### Step 0a:目标确认(仅「审查代码」/「修复 Bug」时执行) + +##### 审查代码分支(4 层追问) + +「审查代码」意图需要先确认审查目标和方式,再决定是否执行技术栈扫描。 + +**第 1 层 — 询问审查场景:** + +使用 `AskUserQuestion`: +> "你要审查的是什么?" + +| 选项 | 说明 | +|------|------| +| 📁 **本地项目** | 审查当前工作区的代码变更(unstaged / 分支 diff / 最近 commit) | +| ☁️ **远程 PR** | 审查 GitHub 上的 Pull Request | + +**第 2 层(仅远程 PR)— 询问目标 PR:** + +> "请提供 PR URL(如 `https://github.com/owner/repo/pull/123`)或 `owner/repo#number`" + +解析 PR URL → 提取 `owner`、`repo`、`pr_number`。 + +**第 3 层(仅远程 PR)— 询问审查方式:** + +使用 `AskUserQuestion`: +> "你想怎么审查这个 PR?" + +| 选项 | 说明 | 后续 | +|------|------|------| +| ⚡ **在线快速审查** | 直接通过 GitHub MCP 获取 PR diff/files/commits,在线审查,无需 clone | → 使用 `gh pr view/diff` 或 GitHub MCP 工具获取 PR 内容 → 审查完成后输出结论 → **不执行 Step 0c** | +| 💻 **Clone 到本地详细审查** | clone 仓库到本地,执行完整技术栈扫描 + 深度审查 | → 对比本地 git remote:`git remote get-url origin 2>/dev/null \|\| echo "NOT_A_GIT_REPO"` → 不匹配则引导 clone(`gh repo clone owner/repo` 或 `git clone`)→ 执行 Step 0c | + +**第 4 层(仅本地项目)— 确认审查范围:** + +> "审查当前工作区的哪些变更?" + +| 选项 | 说明 | +|------|------| +| 📝 **Unstaged 变更** | 工作区中尚未 staged 的修改 | +| 🌿 **分支对比** | 当前分支 vs 目标分支(如 `main`)的 diff | +| 📦 **最近 commit** | 审查最近 N 个 commit 的变更 | + +确认范围后 → 进入第 5 层。 + +**第 5 层(所有审查路径)— 审查模型确认:** + +在开始审查前,确认使用的 AI 模型。不同模型在审查深度、速度和成本上有差异。 + +1. **获取当前默认模型**:从会话上下文中读取当前模型名称(如系统提示中的 model 信息) +2. **展示并确认**: + > "当前默认审查模型为 **[模型名称]**。是否使用此模型进行审查?" + + | 选项 | 说明 | + |------|------| + | ✅ **使用当前模型** | 直接使用默认模型开始审查 | + | 🔄 **更换模型** | 让用户指定其他模型 | + +3. **更换模型时**: + > "请输入你想使用的模型名称(如 `sonnet`、`opus`、`haiku`、`fable`,或具体模型 ID)" + - 用户输入后记录到审查上下文,后续 Agent 调用时使用该模型 + +4. **进入审查** → 执行 Step 0c 技术栈扫描 → 推荐技能时优先匹配 `pr-review`、`code-review` 能力。 + +##### 修复 Bug 分支 + +「修复 Bug」意图需要先确认目标项目。 + +**1. 追问目标:** + +使用 `AskUserQuestion` 询问: +> "你要在哪个项目中修 Bug?是当前工作区的项目,还是其他项目?" + +**2. 检查本地状态:** + +- 从用户提供的项目信息对比当前工作区的 git remote +- 若目标项目不在本地 → 引导 clone +- Clone 完成后切换到目标项目目录 + +**3. 进入 Step 0c:** + +- 在正确的项目目录中执行技术栈扫描 +- 推荐技能时优先匹配调试工具 + 通用代码分析技能 + +##### 🍴 Fork 项目分支(5 步子程序) + +「Fork 项目」意图需要依次执行获取仓库、Fork、Clone、项目分析、贡献工作流引导五个步骤。 + +**Step 0a-fork-1:获取目标仓库** + +1. 从用户消息中提取 GitHub 仓库标识。支持的格式: + - 完整 URL:`https://github.com/owner/repo` + - 简写格式:`owner/repo` +2. 正则提取:`(?:https?://)?github\.com/([a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)` 或 `\b([a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)\b` +3. 若无法提取,使用 `AskUserQuestion`: + > "请提供你要参与的开源仓库地址(如 `https://github.com/facebook/react` 或 `facebook/react`)" +4. 若用户提供非 GitHub URL,提示: + > "当前仅支持 GitHub 开源仓库的 Fork 参与。请确认仓库在 GitHub 上。" + +**Step 0a-fork-2:Fork 仓库** + +1. 先检查是否已存在 fork: + - 使用 `gh repo list --json name --jq '.[].name'` 或 `mcp__plugin_github_github__list_commits` 检查 +2. 若不存在 → 执行 fork: + - 优先使用 `gh repo fork --clone=false`(更可靠) + - 备用:GitHub MCP `mcp__plugin_github_github__fork_repository` +3. 若已存在 → `AskUserQuestion`: + > "检测到你已 fork 过 ``。是否使用已有 fork?" + + | 选项 | 说明 | + |------|------| + | ✅ **使用已有 fork** | 直接使用现有的 fork 仓库 | + | 🔄 **重新 fork** | 删除已有 fork 并重新创建(`gh repo fork --force`) | + | ⬆️ **同步已有 fork** | 将上游仓库的最新变更同步到你的 fork(`gh repo sync`) | + | ❌ **取消** | 放弃 Fork 操作 | + +4. Fork 成功后记录变量: + - `_FORK_UPSTREAM = "owner/repo"`(上游仓库) + - `_FORK_REPO = "your-username/repo"`(你的 fork) + +**Step 0a-fork-3:Clone 到本地** + +1. 询问用户 clone 目标目录(默认当前工作区下的 ``) +2. 检查本地是否已存在该目录: + - 不存在 → 执行 `gh repo clone ` 或 `git clone https://github.com/.git` + - 已存在 → `AskUserQuestion`: + > "本地已存在同名目录。怎么处理?" + - ✅ 复用现有目录 / 🔄 重新 clone / ❌ 取消 +3. Clone 后设置 upstream: + ```bash + cd + git remote add upstream https://github.com/.git # 如尚未添加 + git fetch upstream + ``` +4. 记录 `_FORK_LOCAL_PATH = ""` + +**Step 0a-fork-4:项目分析** + +1. 进入 clone 目录后,提示用户执行技术栈扫描: + > "已 clone [repo] 到本地。建议先扫描项目技术栈,帮助你快速理解项目结构。是否开始分析?" + + | 选项 | 说明 | + |------|------| + | ✅ **开始分析** | 执行 Step 0c 技术栈确认 + 能力发现 | + | ⏭️ **跳过** | 跳过技术栈扫描,直接进入贡献工作流引导 | + +2. 若用户选择「开始分析」,执行完整的 Step 0c 流程(0c-1 至 0c-7) +3. 额外检查: + - 读取上游 `CONTRIBUTING.md`(如存在) + - 检查 `.github/` 目录下的 PR 模板、Issue 模板 + - 读取 `LICENSE` 文件 +4. 展示项目概览摘要(技术栈 + 贡献指南要点 + 许可证类型) + +**联动钩子(仅 PACKAGE_MODE = true 时执行):** +在项目分析完成后,匹配 `integrates_with: pr-management`: +- 若检测到兄弟技能 `github-pr-manager` 可用 → 提示:"💡 完成改动后,可以使用 **GitHub PR 管理器** 来创建和管理你的 Pull Request。" + +**Step 0a-fork-5:贡献工作流引导** + +1. 展示贡献流程概览: + ``` + ## 🍴 Fork 贡献流程 + + 1. ✅ Fork 仓库 → [fork-url] + 2. ✅ Clone 到本地 → [local-path] + 3. ✅ 项目分析 → [tech-stack] + 4. 📝 创建功能分支 → 待执行 + 5. 🔨 开发改动 → 待执行 + 6. 📤 推送并创建 PR → 待执行 + ``` + +2. 引导创建功能分支: + > "建议为你的改动创建一个功能分支。分支名称格式:`feat/` 或 `fix/`" + - 让用户输入分支名,或根据描述自动建议 + +3. **联动钩子(仅 PACKAGE_MODE = true)**: + - 匹配 `integrates_with: pr-management` → 提示:"💡 改动完成后,可使用 **GitHub PR 管理器** 创建和管理你的 Pull Request。" + - 匹配 `integrates_with: plugin-installation` 中的 `git-commit` → 提示:"💡 提交代码时,可使用 **Git 提交助手** 自动生成 Conventional Commits 消息。" + +4. 总结下一步: + > "项目已就绪。接下来的流程:做改动 → `git add` + `git commit` → `git push origin ` → 创建 PR。如需帮助,随时告诉我。" + +#### Step 0b:语言/框架确认(仅「启动新项目」时追问) + +> "你想用什么编程语言/框架?" + +| 选项 | 说明 | +|------|------| +| 🟢 **Python** | AI/ML、数据分析、Web 后端、脚本自动化 | +| 🟡 **JavaScript/TypeScript** | Web 全栈、前端、跨平台 | +| 🔵 **Java/Kotlin** | 企业级后端、Android | +| 🟣 **Rust** | 系统编程、高性能场景 | +| ⚪ **Go** | 云原生、微服务、CLI 工具 | +| 🟠 **C# (.NET)** | Windows 桌面、游戏、企业应用 | +| 🔴 **Swift** | Apple 生态 (iOS/macOS) | +| 🤔 **我不确定,帮我推荐** | → 追问项目类型 → 加载 `references/language-guide.md` → 列出优劣势 + 推荐 | + +**「我不确定」分支的推荐逻辑:** + +1. 追问项目类型:Web 应用 / 移动 App / 桌面应用 / CLI 工具 / AI/ML / 游戏 / 嵌入式 +2. 追问关注点:开发速度 / 运行性能 / 生态丰富度 / 学习曲线 +3. 加载 `references/language-guide.md`,输出推荐表: + +``` +## 语言推荐 + +根据你的需求([项目类型] + [关注点]),推荐以下语言: + +| 语言 | 适合度 | 优势 | 劣势 | +|------|--------|------|------| +| [语言A] | ⭐⭐⭐⭐⭐ | [优势] | [劣势] | +| [语言B] | ⭐⭐⭐⭐ | [优势] | [劣势] | +| [语言C] | ⭐⭐⭐ | [优势] | [劣势] | + +**推荐首选:[语言]** — [一句话理由] +``` + +用户确认语言后,进入强制六步流程。 + +#### Step 0c:技术栈确认 + 能力发现(7 步子程序) + +详细算法参见 `references/scanner-patterns.md`。 + +--- + +**0c-1. 项目指纹扫描** + +**扫描前 — 缓存检查:** + +1. 检查会话上下文中是否存在 `_SCAN_CACHE` 记录(包含 `timestamp` 和 `fingerprint`) +2. 若存在缓存记录: + - 读取 `.discovery-rules.json` 中的 `cache_ttl_hours`(默认 24 小时) + - 若距上次扫描未超过 TTL → 复用缓存指纹和扫描结果,跳过 0c-1 和 0c-2,直接进入 0c-3 + - 若已超过 TTL → 继续执行完整扫描 +3. 若不存在缓存记录(首次扫描)→ 继续执行完整扫描 + +对已有项目执行扫描。使用 `Glob` 检查以下文件(扩展的检测矩阵在 `references/scanner-patterns.md` §Fingerprint Detection Map): + +| 文件 | 推断结果 | +|------|---------| +| `pom.xml` | Java + Maven | +| `build.gradle` / `build.gradle.kts` | Java/Kotlin + Gradle | +| `package.json` | Node.js / JavaScript / TypeScript | +| `tsconfig.json` | TypeScript | +| `Cargo.toml` | Rust | +| `go.mod` | Go | +| `requirements.txt` / `pyproject.toml` / `setup.py` | Python | +| `Gemfile` | Ruby | +| `composer.json` | PHP | +| `*.sln` / `*.csproj` | .NET / C# | +| `CMakeLists.txt` | C/C++ | +| `pubspec.yaml` | Flutter/Dart | +| `Package.swift` / `*.xcodeproj` | Swift / Apple 生态 | +| `docker-compose.yml` / `Dockerfile` | DevOps / Container | +| `next.config.*` | Next.js | +| `vite.config.*` | Vite | +| `tailwind.config.*` | Tailwind CSS | +| `astro.config.*` | Astro | +| `nx.json` / `turbo.json` | Monorepo (Nx/Turborepo) | +| `pnpm-lock.yaml` | pnpm | +| `bun.lockb` | Bun | +| `deno.json` | Deno | +| `schema.prisma` | Prisma | +| `schema.graphql` | GraphQL | + +- 如果 `package.json` 存在,`Read` 其 `dependencies` 和 `devDependencies` 提取框架关键词 +- 如果 `pom.xml` 存在,`Grep` 查找 `` 和 `` 检测 Spring Boot、Quarkus 等 +- 检测 `app/` 或 `src/` 子目录作为补充信号 + +**对全新项目:** 直接使用 Step 0b 选择的语言/框架。 + +**输出:** 项目指纹(逗号分隔标签,如 `java, spring-boot, maven, postgresql`)。 + +**联动钩子(仅 PACKAGE_MODE = true):** 检测 `.git/config` 中 GitHub remote,若存在则匹配 `integrates_with: pr-management`,提示 "💡 检测到 GitHub 项目。推荐使用 **GitHub PR 管理器** 来管理此仓库的 Pull Request。" + +--- + +**0c-2. 能力清单扫描(并行执行)** + +加载 `references/scanner-patterns.md` 进行并行三路扫描。 + +**扫描前 — 读取深度探索配置:** + +1. 尝试读取 `~/.claude/skills/.discovery-rules.json` +2. 若文件存在且定义了 `deep_explore_plugins`(字符串数组)→ 使用该列表作为深度探索目标 +3. 若文件存在且定义了 `priority_boost_plugins`(字符串数组)→ 使用该列表作为优先级加成插件 +4. 若文件不存在或字段缺失 → 使用内置默认值: + - `deep_explore_plugins`: `["everything-claude-code", "superpowers", "andrej-karpathy-skills", "oh-my-claudecode"]` + - `priority_boost_plugins`: `["everything-claude-code", "superpowers", "andrej-karpathy-skills"]` + +**2a. 技能扫描:** Glob `~/.claude/skills/*/SKILL.md`,解析 frontmatter 提取 name、description、tags、category、source。 + +**2b. 插件扫描:** +- MCP 配置:读取 `~/.claude/settings.json` → `mcpServers`,提取 server name、type、command、description +- 本地插件:Glob `~/.claude/plugins/*/plugin.json` 或 `package.json` + +**2c. 深度探索(必需,参见 scanner-patterns.md §Deep Exploration Reference):** +对上一步确定的深度探索目标插件列表执行深度探索: +- 列出根级 `.md`/`.json`/`.yaml`/`.yml`/`.mdc` 文件(跳过 node_modules、.git) +- 读取每个 `.md` 文件前 5-10 行识别用途 +- 扫描嵌套技能(`.agents/skills/*/SKILL.md`) +- 提取 `.mdc` 规则文件名和描述 +- 输出格式:tagged with `source: deep-exploration` and `plugin: `,每项含 name、type (soul/rules/agents/claude-md/commands-ref/nested-skill)、description、path + +--- + +**0c-3. 匹配与排序** + +加载 `references/scanner-patterns.md` §Skill-to-Project Matching Algorithm + §Priority Boost System。 + +**技能评分:** 标签匹配 +3、框架匹配 +3、类别对齐 +1、通用 +0 +**插件评分:** 工具匹配 +3、领域匹配 +1、通用 +0 + +**优先级加成系统(Priority Boost):** +检测到 ECC、superpowers、andrej-karpathy-skills、oh-my-claudecode 或深度资源时 → base score = max(normal_score, 10),标记 ⭐ 置顶。 + +**按意图过滤:** + +| 意图 | 优先推荐 | 降权 | +|------|---------|------| +| 开发新功能 | 对应语言的开发技能、代码生成工具 | 审查/调试类 | +| 审查代码 | 代码审查、PR 审查、lint 技能 | — | +| 修复 Bug | 调试、错误追踪、测试技能 | — | +| Fork 项目 | 项目分析、贡献指南、PR 管理、代码审查相关技能 | — | +| 探索工具 | 不做过滤,展示全部匹配结果 | — | + +**输出三个独立列表(始终按此顺序):** +1. ⭐ 优先推荐(加成插件/深度资源 — 始终最先) +2. 📋 推荐技能(top 5-10,项目匹配) +3. 🔌 推荐插件(top 3-5,项目匹配) + +未匹配项保留给 Step 0c-6 全量导出。 + +--- + +**0c-4. 交互式推荐(⚠️ 强制步骤)** + +展示推荐结果,使用以下模板: + +```markdown +## 🔍 项目识别结果 + +**项目:** [项目名或路径] +**技术栈:** [语言] + [框架] + [构建工具] +**检测依据:** [发现的配置文件列表] + +## ⭐ 优先推荐(核心能力增强) + +> 以下插件/资源提供基础能力增强,无论项目类型都强烈建议启用。 + +| # | 名称 | 类型 | 描述 | 包含的未加载资源 | +|---|------|------|------|----------------| +| 1 | `everything-claude-code` | 插件 | AI 行为配置/安全指南 | SOUL.md, RULES.md, AGENTS.md, COMMANDS-QUICK-REF.md, WORKING-CONTEXT.md, the-security-guide.md, agent.yaml, 嵌套技能 | +| 2 | `superpowers` | 插件 | 核心工作流技能 | AGENTS.md, hooks.json, GEMINI.md | +| 3 | `andrej-karpathy-skills` | 插件 | Karpathy 编码准则 | CURSOR.md, karpathy-guidelines.mdc | +| 4 | `oh-my-claudecode` | 插件 | 多 Agent 编排 | 数十个嵌套技能 (`.agents/skills/*/SKILL.md`) | + +## 📋 推荐技能(按匹配度排序) + +| # | 名称 | 描述 | 匹配理由 | 来源 | +|---|------|------|---------|------| + +## 🔌 推荐插件(按匹配度排序) + +| # | 名称 | 描述 | 匹配理由 | 类型 | +|---|------|------|---------|------| +``` + +> 💡 如插件列表为空,则显示:"未检测到与当前项目强相关的插件。" + +**使用 `AskUserQuestion` 询问:** +> "以上是根据当前项目为您推荐的技能、插件和未加载资源,请问您希望如何处理?" + +提供以下选项: +- **一键启用所有推荐** — 在后续对话中主动使用所有推荐项 +- **逐项选择** — 由用户指定启用哪些(可输入编号) +- **跳过,本次不启用** — 记录选择,本次会话不再重复推荐 +- **了解更多** — 展开某个技能/插件/深度资源的详细说明(用户指定名称) +- **加载未加载资源** — 对深度探索发现的 SOUL/RULES/AGENTS 等文件,询问是否需要手动加载 + +**联动钩子(仅 PACKAGE_MODE = true):** + +对推荐列表中未安装的插件标记 🆕。用户选择后,匹配 `integrates_with: plugin-installation`: +- 若用户选择了未安装的能力 → 提示:"💡 检测到你尚未安装 [name]。是否需要使用 **快速插件安装器** 来安装它?" + +--- + +**0c-5. 指令发现(仅在用户完成 0c-4 选择后执行)** + +⚠️ 若用户选择「跳过」→ 跳至 0c-6 + +加载 `references/scanner-patterns.md` §Command Discovery Reference。 + +**5a. MCP 工具发现(仅扫描用户已选择的插件):** +1. 使用 `ListMcpResourcesTool` 枚举 MCP 资源,或扫描系统提示中 `mcp__` 前缀工具 +2. 仅过滤属于用户**已选择**插件的工具 +3. 每个工具推断:作用(做什么)+ 适用场景(什么时候用) + +**5b. Slash 命令发现:** +从系统提示中提取 `/` 命令,匹配所选技能类别/能力 + +**5c. 展示模板:** + +```markdown +## 🔧 所选工具的可用指令 + +根据您选择的 [skill-names] 和 [plugin-names],以下是可用的指令: + +### 🛠 MCP 工具指令 + +#### [Selected Plugin Name] +| 工具名称 | 作用 | 适用场景 | +|---------|------|---------| +| `mcp__*__tool_name` | [一句话描述] | [什么情况下使用] | + +### ⌨️ 相关 Slash 命令 + +| 命令 | 作用 | 适用场景 | +|------|------|---------| +| `/command-name` | [功能描述] | [什么情况下使用] | +``` + +> 💡 如果选中的插件没有 MCP 工具或当前无 MCP 连接,显示:"所选插件当前无可用的 MCP 工具指令。" +> 💡 Slash 命令始终可用,至少列出与所选技能相关的通用命令。 + +--- + +**0c-6. 全量导出(⚠️ 先问后导)** + +必须获得用户同意后才导出。 + +询问用户: +> "是否需要将所有已安装的技能、插件和指令完整列表导出到文件?这样您可以离线浏览所有可用能力。" + +若用户同意,追问三个选项(使用 `AskUserQuestion`): +1. **目标导出目录** — 输入路径(如 `D:\docs\skills-list\`) +2. **输出语言** — 自由输入任意语言(默认跟随当前对话语言) +3. **输出格式** — `Markdown`(推荐)/ `JSON` / `纯文本` + +**导出内容结构:** 加载 `references/scanner-patterns.md` §Export Field Definitions。 + +导出文件命名:`{project-name}-skills-plugins-export.{format}` + +```markdown +# [标题 — 使用用户指定语言] + +> 导出时间: [timestamp] +> 项目: [project path] +> 总计: [N] 个技能, [M] 个插件, [K] 个指令 +> 语言: [用户指定的语言] + +## 📋 技能 (Skills) — 按分类 + +### [Category] +| 名称 | 描述 | 标签 | 来源 | 文件路径 | +| ... | ... | ... | ... | ... | + +## 🔌 插件 (Plugins) — 按类型 + +### [Type] +| 名称 | 类型 | 命令 | 描述 | 来源 | +| ... | ... | ... | ... | ... | + +## 🔧 指令 (Commands) + +### 🛠 MCP 工具指令 — 按插件分组 + +#### [Plugin Name] +| 工具名称 | 作用 | 适用场景 | +|---------|------|---------| + +### ⌨️ Slash 命令 — 按分类 + +#### [Category] +| 命令 | 作用 | 适用场景 | +|------|------|---------| +``` + +--- + +**0c-7. 上下文持久化** + +- 用户选择「跳过」→ 记录到会话上下文,本次会话不再重复推荐(除非项目指纹显著变化) +- 用户选择特定技能/插件 → 记录接受列表,供后续联动引用 +- 项目指纹显著变化时重新触发发现。**显著变化定义为以下任一:** + - 新增了任意语言/框架配置文件(如新出现 `package.json`、`go.mod`、`Cargo.toml`、`pom.xml` 等) + - 新增了子目录且子目录包含独立的项目配置文件 + - 用户通过 `git checkout` 切换到了不同技术栈的分支 + - 工作目录切换到了同一 monorepo 的不同子项目 +- **仅文件内容修改(不改变技术栈)不触发重新发现** +- 其他包内技能完成主要操作后 → 提示联动发现 +- **缓存记录**:扫描完成后,在会话上下文中记录 `_SCAN_CACHE = { timestamp: <当前时间>, fingerprint: <项目指纹标签>, ttl_hours: <从 rules 读取的 cache_ttl_hours,默认 24> }`,供后续调用复用 + +--- + +非「启动新项目」意图在此步骤结束,不进入强制六步流程。但能力扫描结果可作为后续工作的上下文。 + +--- + +### 强制六步流程(仅「启动新项目」时执行) + +以下六步是原 kickoff 的完整流程,**必须按顺序执行**。 + +### 第一步:澄清"为什么"与"是什么" +向用户提问(至少覆盖以下 3 个问题): +1. 这个项目解决了谁的什么痛点?不做会有什么损失? +2. 成功的可衡量标准是什么?(例如:日活>1000,成本<0.1元/次,首个付费用户等) +3. 请用一句话填空:"我们要为【谁】解决【什么问题】,通过【什么方式】,达到【什么效果】。" + +- 如果用户无法回答第 3 问,则引导其先完成"一句话定义",再继续。 +- 如果是 AI Agent 项目,额外追问:"不用 Agent 行不行?规则引擎能否解决?" +- 如需更详细的问题定义指导,加载 `references/project-checklist.md` 第一章或 `references/ai-agent-checklist.md` 第一章。 + +### 第二步:圈定边界 – 明确"不做什么" +要求用户列出第一版的所有想做的功能,然后: +- 强制砍掉 80%,只保留**能验证核心假设的最小集合(MVP)**。 +- 明确三重约束(时间、成本/资源、质量/范围),并指出"最多只能同时保两个"。 +- 如果是 Agent 项目,额外列出**禁飞区**(例如:不能删除生产数据、不能对外转账、不能发送未审核内容)。 +- 边界讨论遇到困难时,加载 `references/project-checklist.md` 第二章。 + +**联动钩子(仅 PACKAGE_MODE = true 时执行):** + +确认项目技术栈后,扫描兄弟技能的 `capabilities`,匹配 `integrates_with: plugin-installation`: +- 匹配成功 → 提示用户:"💡 检测到你的项目使用 [技术栈]。是否需要安装相关的 MCP Server(如 GitHub MCP、Playwright、Context7)来增强开发体验?" + +### 第三步:快速风险摸底 +让用户回答: +- 技术、人力、市场、合规四方面是否有明显障碍? +- 写下**最可能让项目失败的三件事**,并为每件想一个 B 计划(即便只是"换方案,慢 30%")。 +- 对于 AI Agent:用当前最强模型做"纸上原型"手动模拟 3~5 步,观察是否会跑偏。若跑偏,要求简化任务或增加护栏。 +- 详细可行性分析模板参见 `references/project-checklist.md` 第三章;Agent 特有风险评估参见 `references/ai-agent-checklist.md` 第四章。 + +### 第四步:利益相关者与期望对齐 +- 引导用户识别核心圈(执行者)、影响圈(资源方)、外围圈(用户/监管)。 +- 强制建议:"拿着第一步的'项目定义'和'成功标准',去跟关键人物口头确认一次,再继续。" +- 完整利益相关者分析指导参见 `references/project-checklist.md` 第四章。 + +### 第五步:绘制粗糙路线图(仅里程碑) +- 输出 3~5 个里程碑(以周为单位),每个里程碑必须有明确的**产出物**和**验收标准**。 +- 最后,要求用户确认以下开工 Checklist: + - ☑ 项目定义与目标已和关键人确认 + - ☑ MVP 范围已明确(以及不做什么) + - ☑ 资源(时间、钱、人)已到位或得到承诺 + - ☑ 前三风险已有应对预案 + - ☑ 代码仓库、沟通群组、文档协作工具已就绪 +- 路线图设计参考参见 `references/project-checklist.md` 第五章。 + +### 第六步(关键):生成 CLAUDE.md —— 将思考成果固化到项目 + +在完成五步检查并确认代码风格后,**必须**执行以下流程: + +#### 6a. 确认用户意愿 +向用户确认: +> "我们已经完成了五步启动检查,并确认了项目的代码风格。现在要调用 /init 生成项目的 CLAUDE.md,把刚才讨论的内容 —— 项目定义、MVP 范围、里程碑、风险预案、风格约定 —— 都固化到项目根目录。是否继续?" + +- 如果用户同意,继续 6b。 +- 如果用户暂不需要,跳至 6d。 + +#### 6b. 检测已有 CLAUDE.md +检查项目根目录是否已存在 `CLAUDE.md` 文件: +- **若不存在**:直接执行 `/init` 命令。`/init` 是 Claude Code 的内置项目初始化命令,会引导生成标准的 CLAUDE.md 文件。技能已收集的五步检查信息都在对话上下文中,/init 可直接利用。 +- **若已存在**:读取现有 CLAUDE.md,执行逐段对比合并: + 1. 提取现有 CLAUDE.md 中的自定义命令、构建步骤、测试框架配置 → **保留不动** + 2. 对比五步检查结果,识别缺失章节(项目定义、MVP 范围、风险预案、风格约定) + 3. 仅补充缺失部分,不覆盖已有内容 + 4. 向用户展示合并差异摘要,确认后写入 + +#### 6c. 验证生成结果 +在 `/init` 执行完毕后: +- 检查项目根目录是否已生成或更新了 CLAUDE.md。 +- 如果生成成功,向用户展示摘要: + > "✅ CLAUDE.md 已生成。你的项目现在有了一个包含项目定义、MVP 范围、里程碑、风险预案和代码风格约定的标准入口文件。每次 Claude 进入这个项目时都会自动加载这些上下文。" +- 如果 `/init` 因任何原因未完成(如用户中途退出),使用下面的"输出模板"手动输出一份启动摘要,并告知用户随时可再次运行 `/init`。 + +**联动钩子(仅 PACKAGE_MODE = true 时执行,在 6c 成功后):** + +CLAUDE.md 生成成功后,本技能已内置完整的技能发现能力(Step 0c),可直接提示用户: +> "✅ CLAUDE.md 已生成。是否需要扫描当前项目技术栈,推荐匹配的技能和插件?" + +(无需通过 `integrates_with: skill-discovery` 跨技能联动——此能力内置于本技能中。) +- 同时检查其他兄弟技能的 `integrates_with`,如发现匹配则一并提示 + +#### 6d. 后备方案 +如果用户选择不执行 `/init`,输出完整的启动摘要(见下方模板),并告知: +> "了解。以下是本次启动检查的完整摘要。你可以随时运行 `/init` 来将这些内容固化为正式的 CLAUDE.md。" + +--- + +## 代码风格保留规则(必须执行) + +当本项目涉及生成任何代码、配置文件、注释模板或项目脚手架时,**必须**按以下优先级确定并保留风格: + +1. **主动探测**:检查用户是否已提供现有代码文件、`.editorconfig`、`eslint`/`prettier` 配置、或口头说明的风格偏好(如"我们用制表符缩进")。 +2. **若无既有风格,则采用行业默认推荐**(例如 Python 用 PEP8,JavaScript 用 2 空格缩进,注释使用 `#` 或 `//` 后跟一个空格),并在生成前向用户确认。 +3. **注释规范**:要求用户提供注释密度偏好(关键函数必写 / 仅复杂逻辑写 / 每一行都写)。默认采用"公共 API 和复杂逻辑写注释,自解释的语句不写"。 +4. **命名规范**:明确变量、函数、类、文件的命名风格(驼峰、下划线、大驼峰等),并统一应用到所有生成内容。 +5. **即使生成示例代码,也要符合上述风格**;若用户未指定,在代码块上方用注释标明"请按你的项目风格调整"。 + +--- + +## 针对 AI Agent 项目的额外检查项 + +若用户确认项目类型为 AI Agent,在完成上述六步后,追加以下问题(详细内容参见 `references/ai-agent-checklist.md`): +- 记忆系统(短期/长期)如何设计?(参见第三章) +- 规划策略(ReAct / Plan-and-Execute / 多 Agent)选哪一种?(参见第三章) +- 工具集的输入/输出格式是否严格定义?(参见第三章) +- 如何评估"好坏"?(任务成功率、工具调用准确率、成本)(参见第七章) +- 安全与伦理:防注入、权限最小化、透明度、合规是否已考虑?(参见第八章) + +并建议用户先实现一个**最小可行性 Agent**(模型调用 + 一个工具),再引入框架。 + +--- + +## 输出模板(强制使用) + +在完成六步检查后,**必须**使用以下格式输出启动摘要(控制在 500 字以内): + +```markdown +## 项目启动摘要:[项目名称] + +### 项目定义 +- **一句话**:[填入] +- **成功标准**:[可衡量指标] +- **利益相关者**:核心圈=[...], 影响圈=[...], 外围圈=[...] + +### MVP 范围 +- **包含**:[功能A, 功能B] +- **不包含**:[功能C, 功能D, 功能E] +- **约束**:时间=[Deadline], 资源=[预算/人力], 质量=[可妥协项] + +### 路线图 +| 里程碑 | 产出物 | 验收标准 | +|--------|--------|---------| +| W1 | [产出物] | [标准] | +| W2 | [产出物] | [标准] | +| W3 | [产出物] | [标准] | + +### 风险预案 +| 风险 | 可能性 | B计划 | +|------|--------|-------| +| [风险1] | 高/中/低 | [备选方案] | +| [风险2] | 高/中/低 | [备选方案] | +| [风险3] | 高/中/低 | [备选方案] | + +### 代码风格约定 +- 缩进:[空格/制表符,数量] +- 注释:[密度与格式] +- 命名:[变量/函数/类规则] + +### 开工状态 +☑ 全部确认完成 → /init 已调用,CLAUDE.md 已生成 ✅ +``` + +--- + +## 边界条件处理 + +### 用户已有 CLAUDE.md +如果检测到项目根目录已存在 CLAUDE.md(在第六步之前或之中检测到),先询问用户是覆盖更新还是合并补充。建议策略:读取现有 CLAUDE.md 内容,与五步检查结果对比,补充缺失的部分而非完全覆盖——CLAUDE.md 中可能已包含项目特有的构建命令、测试框架等不应被覆盖的信息。 + +### 非项目所有者场景 +如果用户明确表示是为他人项目提供建议(如"帮我朋友看看他的项目计划"),则: +- 跳过第六步(/init 调用),不修改他人的 CLAUDE.md +- 跳过代码风格询问(除非用户主动问) +- 集中精力完成五步分析和建议 +- 输出启动摘要供用户转发 + +### 用户只要求部分检查 +用户可能只关心某个方面(如"帮我只做风险摸底")。灵活处理: +- 用户可以选择只走某几个步骤 +- 完成所请求的步骤后,简要询问是否需要完成剩余步骤 +- 不强制走完六步,但总要提及"如果需要完整启动检查,随时可以说" + +### 项目范围极小 + +满足以下**任意 2 条**即启用极简模式: + +1. **任务描述为单文件级**:用户描述为「写一个脚本」「一个工具」「一个函数」「批量处理」等单文件级任务 +2. **源代码文件数量少**:项目目录中源代码文件 < 3 个(不含 `README.md`、`.gitignore`、`*.json`/`*.toml`/`*.yaml` 等配置文件) +3. **用户明确要求简化**:用户明确表示「不需要完整流程」「简单弄一下就行」「快速过一遍」 + +**仅满足 1 条时**,追问用户确认是否启用极简模式。 + +极简模式内容: +- **执行**:问题定义(一句话)+ 代码风格确认 +- **跳过**:MVP 边界圈定(第二步)、利益相关者分析(第四步)、里程碑路线图(第五步) +- **仍执行**:快速风险摸底(第三步,简化为"最可能出错的一件事") +- **仍执行**:第六步 CLAUDE.md 生成(若项目目录存在) +- 完成后提示:"这是一个极简项目。如需完整启动检查流程,随时可以说。" + +--- + +## 错误处理 + +| 场景 | 处理方式 | +|------|---------| +| `~/.claude/skills/` 不存在或无法读取 | 跳过技能扫描,仅推荐插件和命令,不报错 | +| SKILL.md frontmatter 格式错误 | 跳过该技能,记录名称到跳过列表,继续扫描其他技能 | +| `settings.json` 无 `mcpServers` 字段 | 跳过 MCP 插件扫描,仅扫描本地插件目录 | +| `.discovery-rules.json` JSON 解析失败 | 静默跳过,使用内置默认规则 | +| Glob 操作超时(>5 秒) | 跳过深度探索,标注「部分插件未深度扫描」 | +| 深度探索文件 > 50KB | 仅读前 5 行判断类型,不读取全文 | +| PACKAGE_MODE 检测失败(任何原因) | 降级为 PACKAGE_MODE = false,静默运行 | +| `/init` 执行失败 | 手动输出启动摘要,提示用户可随时重试 | +| `gh repo fork` 失败(未登录/权限不足) | 提示用户先执行 `gh auth login`,或手动在 GitHub 网页 fork 后提供 clone URL | +| 目标仓库不存在(Fork 模式) | 提示确认 URL,重新输入 owner/repo | +| Fork 已存在且用户选择同步 | 执行 `git fetch upstream && git merge upstream/main` 同步上游变更 | +| GitHub MCP 和 `gh` CLI 均不可用(Fork 模式) | 提示用户手动在浏览器中 Fork,引导用户提供 clone URL 继续 | +| 用户指定的仓库非 GitHub(Fork 模式) | 提示仅支持 GitHub 仓库,询问是否继续或取消 | +| Clone 目标目录冲突(Fork 模式) | 询问用户:复用现有目录 / 重新 clone / 选择其他目录 | + +--- + +## 交互风格 +- 使用简洁的清单式提问,每次最多问 3 个问题,避免信息过载。 +- 对用户的回答进行总结并复述,确保对齐。 +- 最后输出一份 **< 500 字的启动摘要**,包含:项目定义、MVP 范围、关键里程碑、前三风险、风格约定、CLAUDE.md 生成状态。 +- 全程使用中文与用户沟通。 From 655a85f59ed50183b951b377d371d79f89d1c4b2 Mon Sep 17 00:00:00 2001 From: Minecraft269 <176564132+Minecraft269@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:50:38 +0800 Subject: [PATCH 2/2] feat: bilingual treatment for reference docs and scripts - Translate 11 references/*.md to EN canonical, preserve CN at *.cn.md - Translate Chinese comments and user-facing strings in 7 scripts/*.sh - Skip mcp-templates.md (JSON templates) and discovery-rules.example.json - All .sh scripts pass bash -n syntax check Co-Authored-By: Claude --- .../references/error-handling.cn.md | 51 ++ .../references/error-handling.md | 78 +-- .../references/workflows.cn.md | 158 ++++++ .../github-pr-manager/references/workflows.md | 160 +++--- skills/github-pr-manager/scripts/ci_pr.sh | 146 ++--- skills/github-pr-manager/scripts/clone_pr.sh | 372 ++++++------- skills/github-pr-manager/scripts/list_prs.sh | 60 +-- skills/github-pr-manager/scripts/view_pr.sh | 80 +-- .../references/comment-templates.cn.md | 50 ++ .../references/comment-templates.md | 70 +-- .../references/diff-line-mapping.cn.md | 141 +++++ .../references/diff-line-mapping.md | 124 ++--- .../references/review-checklist.cn.md | 151 ++++++ .../references/review-checklist.md | 190 +++---- .../references/review-preview-template.cn.md | 78 +++ .../references/review-preview-template.md | 76 +-- .../scripts/parse_diff_lines.sh | 32 +- .../scripts/check-mcp-updates.sh | 64 +-- .../scripts/toggle-autoupdate.sh | 50 +- .../references/ai-agent-checklist.cn.md | 107 ++++ .../references/ai-agent-checklist.md | 108 +--- .../references/hook-config.cn.md | 119 +++++ .../references/hook-config.md | 68 +-- .../references/language-guide.cn.md | 105 ++++ .../references/language-guide.md | 158 +++--- .../references/project-checklist.cn.md | 99 ++++ .../references/project-checklist.md | 130 ++--- .../references/scanner-patterns.cn.md | 505 ++++++++++++++++++ .../references/scanner-patterns.md | 96 ++-- .../references/validation-scenarios.cn.md | 226 ++++++++ .../references/validation-scenarios.md | 294 +++++----- 31 files changed, 2917 insertions(+), 1229 deletions(-) create mode 100644 skills/github-pr-manager/references/error-handling.cn.md create mode 100644 skills/github-pr-manager/references/workflows.cn.md create mode 100644 skills/github-pr-reviewer/references/comment-templates.cn.md create mode 100644 skills/github-pr-reviewer/references/diff-line-mapping.cn.md create mode 100644 skills/github-pr-reviewer/references/review-checklist.cn.md create mode 100644 skills/github-pr-reviewer/references/review-preview-template.cn.md create mode 100644 skills/universal-project-kickoff/references/ai-agent-checklist.cn.md create mode 100644 skills/universal-project-kickoff/references/hook-config.cn.md create mode 100644 skills/universal-project-kickoff/references/language-guide.cn.md create mode 100644 skills/universal-project-kickoff/references/project-checklist.cn.md create mode 100644 skills/universal-project-kickoff/references/scanner-patterns.cn.md create mode 100644 skills/universal-project-kickoff/references/validation-scenarios.cn.md diff --git a/skills/github-pr-manager/references/error-handling.cn.md b/skills/github-pr-manager/references/error-handling.cn.md new file mode 100644 index 0000000..21e2ace --- /dev/null +++ b/skills/github-pr-manager/references/error-handling.cn.md @@ -0,0 +1,51 @@ +# 错误处理参考 + +## 错误场景及处理 + +| 错误场景 | 检测方式 | 处理方式 | +|----------|----------|----------| +| `gh` 未安装 | `which gh` 返回空 | 提示安装:https://cli.github.com/ | +| `gh` 未登录 | `gh auth status` 非 0 | 提示执行 `gh auth login` | +| 仓库不存在 | `gh pr list` 返回 404 | "仓库 owner/repo 不存在或无访问权限,请检查拼写或权限" | +| 无开放 PR | `gh pr list` 返回空数组 | "该仓库当前没有开放的 PR" | +| PR 编号无效 | `gh pr view` 返回 "not found" | "未找到 PR #xxxx,请检查编号或输入 r 刷新列表" | +| 目标目录已存在 | `test -d --pr-<编号>` | 询问 `[y]` 删除重建 / `[n]` 跳过直接进入 / `[q]` 取消 | +| 磁盘空间不足 | `df -h` 检查 | 提示清理空间或 `/set-clone-path` 换路径 | +| 克隆失败(网络) | `gh pr checkout` 超时 | 检查网络,建议重试;提供 `--depth 1` 浅克隆 | +| 克隆失败(权限) | 返回 403 | 检查仓库权限(私有仓库需 `gh auth` scope) | +| `jq` 未安装 | `which jq` 返回空 | 回退到原始 JSON 输出,提示安装 jq 获得更好格式 | +| 仓库有 50+ PR | 返回数量 = limit | "仅展示最近 50 个 PR,使用 `--limit 100` 查看更多" | + +## 优雅降级原则 + +- 任何工具缺失都不应阻止核心流程 +- `jq` 缺失 → 用 `gh` 内置 `--jq` 或原始输出 +- `gh` 版本过低 → 降级使用兼容命令 +- 网络错误 → 重试一次后给出明确的下一步操作 + +## 用户反馈模式 + +始终做到: +1. 清晰说明出了什么问题 +2. 解释可能的原因 +3. 给出具体的解决步骤 +4. 提供替代方案(如果有) + +### 示例 + +``` +❌ 克隆 PR #1234 失败 + +原因:网络连接超时(gh 无法访问 api.github.com) + +建议: + 1. 检查网络连接 + 2. 确认 gh auth status 正常 + 3. 重试:输入 c 1234 + +替代方案: + 手动克隆: + git clone https://github.com/owner/repo.git owner-repo-pr-1234 + cd owner-repo-pr-1234 + gh pr checkout 1234 +``` diff --git a/skills/github-pr-manager/references/error-handling.md b/skills/github-pr-manager/references/error-handling.md index 21e2ace..0e4807b 100644 --- a/skills/github-pr-manager/references/error-handling.md +++ b/skills/github-pr-manager/references/error-handling.md @@ -1,50 +1,50 @@ -# 错误处理参考 +# Error Handling Reference -## 错误场景及处理 +## Error Scenarios and Handling -| 错误场景 | 检测方式 | 处理方式 | +| Error Scenario | Detection Method | Handling Method | |----------|----------|----------| -| `gh` 未安装 | `which gh` 返回空 | 提示安装:https://cli.github.com/ | -| `gh` 未登录 | `gh auth status` 非 0 | 提示执行 `gh auth login` | -| 仓库不存在 | `gh pr list` 返回 404 | "仓库 owner/repo 不存在或无访问权限,请检查拼写或权限" | -| 无开放 PR | `gh pr list` 返回空数组 | "该仓库当前没有开放的 PR" | -| PR 编号无效 | `gh pr view` 返回 "not found" | "未找到 PR #xxxx,请检查编号或输入 r 刷新列表" | -| 目标目录已存在 | `test -d --pr-<编号>` | 询问 `[y]` 删除重建 / `[n]` 跳过直接进入 / `[q]` 取消 | -| 磁盘空间不足 | `df -h` 检查 | 提示清理空间或 `/set-clone-path` 换路径 | -| 克隆失败(网络) | `gh pr checkout` 超时 | 检查网络,建议重试;提供 `--depth 1` 浅克隆 | -| 克隆失败(权限) | 返回 403 | 检查仓库权限(私有仓库需 `gh auth` scope) | -| `jq` 未安装 | `which jq` 返回空 | 回退到原始 JSON 输出,提示安装 jq 获得更好格式 | -| 仓库有 50+ PR | 返回数量 = limit | "仅展示最近 50 个 PR,使用 `--limit 100` 查看更多" | - -## 优雅降级原则 - -- 任何工具缺失都不应阻止核心流程 -- `jq` 缺失 → 用 `gh` 内置 `--jq` 或原始输出 -- `gh` 版本过低 → 降级使用兼容命令 -- 网络错误 → 重试一次后给出明确的下一步操作 - -## 用户反馈模式 - -始终做到: -1. 清晰说明出了什么问题 -2. 解释可能的原因 -3. 给出具体的解决步骤 -4. 提供替代方案(如果有) - -### 示例 +| `gh` not installed | `which gh` returns empty | Prompt to install: https://cli.github.com/ | +| `gh` not logged in | `gh auth status` non-zero | Prompt to run `gh auth login` | +| Repository does not exist | `gh pr list` returns 404 | "Repository owner/repo does not exist or is not accessible. Please check the spelling or your permissions." | +| No open PRs | `gh pr list` returns empty array | "This repository currently has no open PRs." | +| Invalid PR number | `gh pr view` returns "not found" | "PR #xxxx not found. Please check the number or press r to refresh the list." | +| Target directory already exists | `test -d --pr-` | Prompt `[y]` delete and recreate / `[n]` skip and enter directly / `[q]` cancel | +| Insufficient disk space | `df -h` check | Prompt to free up space or use `/set-clone-path` to change the path | +| Clone failed (network) | `gh pr checkout` timeout | Check network, suggest retry; offer `--depth 1` shallow clone | +| Clone failed (permissions) | Returns 403 | Check repository permissions (private repos require `gh auth` scope) | +| `jq` not installed | `which jq` returns empty | Fall back to raw JSON output, prompt to install jq for better formatting | +| Repository has 50+ PRs | Return count = limit | "Showing only the 50 most recent PRs. Use `--limit 100` to see more." | + +## Graceful Degradation Principles + +- No missing tool should block the core workflow +- `jq` missing → use `gh` built-in `--jq` or raw output +- `gh` version too old → degrade to compatible commands +- Network error → retry once, then give clear next steps + +## User Feedback Pattern + +Always: +1. Clearly explain what went wrong +2. Describe possible causes +3. Provide concrete resolution steps +4. Offer alternative approaches (if available) + +### Example ``` -❌ 克隆 PR #1234 失败 +❌ Failed to clone PR #1234 -原因:网络连接超时(gh 无法访问 api.github.com) +Cause: Network connection timed out (gh cannot reach api.github.com) -建议: - 1. 检查网络连接 - 2. 确认 gh auth status 正常 - 3. 重试:输入 c 1234 +Suggestions: + 1. Check your network connection + 2. Verify gh auth status is working + 3. Retry: enter c 1234 -替代方案: - 手动克隆: +Alternative: + Clone manually: git clone https://github.com/owner/repo.git owner-repo-pr-1234 cd owner-repo-pr-1234 gh pr checkout 1234 diff --git a/skills/github-pr-manager/references/workflows.cn.md b/skills/github-pr-manager/references/workflows.cn.md new file mode 100644 index 0000000..a7c30c6 --- /dev/null +++ b/skills/github-pr-manager/references/workflows.cn.md @@ -0,0 +1,158 @@ +# 详细工作流参考 + +## 目录命名规则 + +多仓库场景下,克隆目录使用 `--pr-<编号>` 格式: + +``` +facebook-react-pr-28452/ # facebook/react 的 PR #28452 +lodash-lodash-pr-4528/ # lodash/lodash 的 PR #4528 +vuejs-core-pr-9012/ # vuejs/core 的 PR #9012 +``` + +这样不同仓库的 PR 互不干扰,一目了然。 + +## 多仓库管理 + +技能维护一个仓库列表,支持快速切换: + +- 最近使用过的仓库自动记录(最多 10 个) +- `/set-repo owner/repo` 添加新仓库或切换到已有仓库 +- `repo owner/repo` 快速切换(简写形式) +- `/show-config` 展示当前配置和最近仓库列表 + +### 配置展示格式 + +``` +⚙️ 当前配置 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +当前仓库: facebook/react +克隆路径: ./ +最近仓库: + 1. facebook/react (当前) + 2. lodash/lodash + 3. vuejs/core +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +## PR 详情展示格式 + +### 完整信息(默认,输入 PR 编号时触发) + +一次性展示:基本详情 + diff + 评论/审查 + 提交历史。 + +``` +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📌 PR #1234 详情 (facebook/react) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +标题: feat: add new button component +作者: @john_doe +状态: 🟢 OPEN | 可合并: ✅ +分支: feature/button → main +创建时间: 2026-05-28 +标签: enhancement, UI +变更文件: 5 个文件 (+234 / -56) +提交数: 3 +🔗 链接: https://github.com/facebook/react/pull/1234 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📝 描述: +添加了一个新的按钮组件,支持多种样式和尺寸配置... + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📊 代码变更 (diff) — 前 200 行: + src/components/Button.tsx | 45 ++++++++++++++ + src/components/Button.test.tsx | 67 +++++++++++++++++++ + ... + (共 5 个文件变更,完整 diff 可用 `gh pr diff 1234` 查看) + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +💬 审查状态: + @reviewer1 [APPROVED] — "LGTM, nice work!" (2天前) + @reviewer2 [COMMENTED] — "Consider adding aria labels" (1天前) + +💬 评论 (3): + @dev_helper — "需要更新 Storybook 吗?" + ↳ @john_doe — "已更新,在另一个 PR #1235" + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +📜 提交历史 (3): + abc1234 @john_doe feat: add Button component variants + def5678 @john_doe style: format with prettier + ghi9012 @john_doe test: add Button unit tests +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` + +## 克隆后初始化流程 + +克隆到 `facebook-react-pr-1234/` 后自动检测项目类型: + +### Node.js 项目 +``` +🔍 检测到 Node.js 项目 (package.json) +依赖: express, react, typescript ... (共 42 个包) +是否执行 npm install? [y/n] (默认 y) +``` + +### Python 项目 +``` +🔍 检测到 Python 项目 (pyproject.toml) +是否创建虚拟环境并安装依赖? [y/n] (默认 y) +→ python -m venv .venv && source .venv/bin/activate && pip install -e . +``` + +### Rust 项目 +``` +🔍 检测到 Rust 项目 (Cargo.toml) +是否执行 cargo build? [y/n] (默认 y) +``` + +### 完成后 +``` +🎉 开发环境已就绪! +📂 当前工作目录: ./facebook-react-pr-1234 +🌿 分支: feature/button +📏 大小: 12MB +``` + +## 自定义克隆路径 + +用户可通过 `/set-clone-path <路径>` 修改克隆根目录(默认为当前目录): + +``` +/set-clone-path ~/dev/pr-review +``` + +之后克隆创建 `~/dev/pr-review/facebook-react-pr-<编号>`。 + +## 完整示例对话 + +**用户:** 帮我看看 facebook/react 有哪些 PR + +**Claude:** +``` +✅ 已设置仓库:facebook/react +正在获取开放 PR... + +📋 仓库: facebook/react | 开放 PR 列表 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + #28452 feat: new hook useOptimistic @sebmarkbage 3天前 + #28400 fix: reconcile edge case @acdlite 1周前 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +共 2 个开放 PR +``` + +**用户:** 看下 28452 + +**Claude:** [展示 PR #28452 完整信息:详情 + diff + 审查 + 提交] + +**用户:** 克隆这个 + +**Claude:** [克隆到 facebook-react-pr-28452 → 检测 Node.js → npm install → 完成] + +**用户:** 切到 lodash/lodash 看看 + +**Claude:** [切换仓库 → 展示 lodash/lodash 的 PR 列表] + +**用户:** batch clone 4528,4500 + +**Claude:** [分别克隆到 lodash-lodash-pr-4528 和 lodash-lodash-pr-4500] diff --git a/skills/github-pr-manager/references/workflows.md b/skills/github-pr-manager/references/workflows.md index a7c30c6..321a175 100644 --- a/skills/github-pr-manager/references/workflows.md +++ b/skills/github-pr-manager/references/workflows.md @@ -1,158 +1,158 @@ -# 详细工作流参考 +# Detailed Workflow Reference -## 目录命名规则 +## Directory Naming Convention -多仓库场景下,克隆目录使用 `--pr-<编号>` 格式: +In multi-repo scenarios, clone directories follow the `--pr-` format: ``` -facebook-react-pr-28452/ # facebook/react 的 PR #28452 -lodash-lodash-pr-4528/ # lodash/lodash 的 PR #4528 -vuejs-core-pr-9012/ # vuejs/core 的 PR #9012 +facebook-react-pr-28452/ # PR #28452 from facebook/react +lodash-lodash-pr-4528/ # PR #4528 from lodash/lodash +vuejs-core-pr-9012/ # PR #9012 from vuejs/core ``` -这样不同仓库的 PR 互不干扰,一目了然。 +This keeps PRs from different repositories separate and easily identifiable. -## 多仓库管理 +## Multi-Repository Management -技能维护一个仓库列表,支持快速切换: +The skill maintains a repository list for quick switching: -- 最近使用过的仓库自动记录(最多 10 个) -- `/set-repo owner/repo` 添加新仓库或切换到已有仓库 -- `repo owner/repo` 快速切换(简写形式) -- `/show-config` 展示当前配置和最近仓库列表 +- Recently used repositories are automatically recorded (up to 10) +- `/set-repo owner/repo` adds a new repository or switches to an existing one +- `repo owner/repo` quick switch (shorthand) +- `/show-config` displays the current configuration and recent repository list -### 配置展示格式 +### Configuration Display Format ``` -⚙️ 当前配置 +⚙️ Current Configuration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -当前仓库: facebook/react -克隆路径: ./ -最近仓库: - 1. facebook/react (当前) +Current repo: facebook/react +Clone path: ./ +Recent repos: + 1. facebook/react (current) 2. lodash/lodash 3. vuejs/core ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` -## PR 详情展示格式 +## PR Details Display Format -### 完整信息(默认,输入 PR 编号时触发) +### Full Information (default, triggered when a PR number is entered) -一次性展示:基本详情 + diff + 评论/审查 + 提交历史。 +Displays everything at once: basic details + diff + comments/reviews + commit history. ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -📌 PR #1234 详情 (facebook/react) +📌 PR #1234 Details (facebook/react) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -标题: feat: add new button component -作者: @john_doe -状态: 🟢 OPEN | 可合并: ✅ -分支: feature/button → main -创建时间: 2026-05-28 -标签: enhancement, UI -变更文件: 5 个文件 (+234 / -56) -提交数: 3 -🔗 链接: https://github.com/facebook/react/pull/1234 +Title: feat: add new button component +Author: @john_doe +Status: 🟢 OPEN | Mergeable: ✅ +Branch: feature/button → main +Created: 2026-05-28 +Labels: enhancement, UI +Files changed: 5 files (+234 / -56) +Commits: 3 +🔗 Link: https://github.com/facebook/react/pull/1234 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -📝 描述: -添加了一个新的按钮组件,支持多种样式和尺寸配置... +📝 Description: +Added a new button component supporting multiple styles and size configurations... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -📊 代码变更 (diff) — 前 200 行: +📊 Code Changes (diff) — First 200 lines: src/components/Button.tsx | 45 ++++++++++++++ src/components/Button.test.tsx | 67 +++++++++++++++++++ ... - (共 5 个文件变更,完整 diff 可用 `gh pr diff 1234` 查看) + (5 files changed, full diff available via `gh pr diff 1234`) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -💬 审查状态: - @reviewer1 [APPROVED] — "LGTM, nice work!" (2天前) - @reviewer2 [COMMENTED] — "Consider adding aria labels" (1天前) +💬 Review Status: + @reviewer1 [APPROVED] — "LGTM, nice work!" (2 days ago) + @reviewer2 [COMMENTED] — "Consider adding aria labels" (1 day ago) -💬 评论 (3): - @dev_helper — "需要更新 Storybook 吗?" - ↳ @john_doe — "已更新,在另一个 PR #1235" +💬 Comments (3): + @dev_helper — "Do we need to update Storybook?" + ↳ @john_doe — "Updated, in another PR #1235" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -📜 提交历史 (3): +📜 Commit History (3): abc1234 @john_doe feat: add Button component variants def5678 @john_doe style: format with prettier ghi9012 @john_doe test: add Button unit tests ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` -## 克隆后初始化流程 +## Post-Clone Initialization Flow -克隆到 `facebook-react-pr-1234/` 后自动检测项目类型: +After cloning into `facebook-react-pr-1234/`, auto-detect the project type: -### Node.js 项目 +### Node.js Project ``` -🔍 检测到 Node.js 项目 (package.json) -依赖: express, react, typescript ... (共 42 个包) -是否执行 npm install? [y/n] (默认 y) +🔍 Detected Node.js project (package.json) +Dependencies: express, react, typescript ... (42 packages total) +Run npm install? [y/n] (default y) ``` -### Python 项目 +### Python Project ``` -🔍 检测到 Python 项目 (pyproject.toml) -是否创建虚拟环境并安装依赖? [y/n] (默认 y) +🔍 Detected Python project (pyproject.toml) +Create virtual environment and install dependencies? [y/n] (default y) → python -m venv .venv && source .venv/bin/activate && pip install -e . ``` -### Rust 项目 +### Rust Project ``` -🔍 检测到 Rust 项目 (Cargo.toml) -是否执行 cargo build? [y/n] (默认 y) +🔍 Detected Rust project (Cargo.toml) +Run cargo build? [y/n] (default y) ``` -### 完成后 +### Completion ``` -🎉 开发环境已就绪! -📂 当前工作目录: ./facebook-react-pr-1234 -🌿 分支: feature/button -📏 大小: 12MB +🎉 Development environment is ready! +📂 Current directory: ./facebook-react-pr-1234 +🌿 Branch: feature/button +📏 Size: 12MB ``` -## 自定义克隆路径 +## Custom Clone Path -用户可通过 `/set-clone-path <路径>` 修改克隆根目录(默认为当前目录): +Users can change the clone root directory via `/set-clone-path ` (default is the current directory): ``` /set-clone-path ~/dev/pr-review ``` -之后克隆创建 `~/dev/pr-review/facebook-react-pr-<编号>`。 +Subsequent clones will create `~/dev/pr-review/facebook-react-pr-`. -## 完整示例对话 +## Full Conversation Example -**用户:** 帮我看看 facebook/react 有哪些 PR +**User:** Show me what PRs facebook/react has -**Claude:** +**Claude:** ``` -✅ 已设置仓库:facebook/react -正在获取开放 PR... +✅ Repo set: facebook/react +Fetching open PRs... -📋 仓库: facebook/react | 开放 PR 列表 +📋 Repository: facebook/react | Open PR List ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - #28452 feat: new hook useOptimistic @sebmarkbage 3天前 - #28400 fix: reconcile edge case @acdlite 1周前 + #28452 feat: new hook useOptimistic @sebmarkbage 3 days ago + #28400 fix: reconcile edge case @acdlite 1 week ago ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -共 2 个开放 PR +2 open PRs ``` -**用户:** 看下 28452 +**User:** Check 28452 -**Claude:** [展示 PR #28452 完整信息:详情 + diff + 审查 + 提交] +**Claude:** [Shows PR #28452 full info: details + diff + review + commits] -**用户:** 克隆这个 +**User:** Clone this -**Claude:** [克隆到 facebook-react-pr-28452 → 检测 Node.js → npm install → 完成] +**Claude:** [Clones to facebook-react-pr-28452 → detects Node.js → npm install → done] -**用户:** 切到 lodash/lodash 看看 +**User:** Switch to lodash/lodash -**Claude:** [切换仓库 → 展示 lodash/lodash 的 PR 列表] +**Claude:** [Switches repo → shows lodash/lodash PR list] -**用户:** batch clone 4528,4500 +**User:** Batch clone 4528,4500 -**Claude:** [分别克隆到 lodash-lodash-pr-4528 和 lodash-lodash-pr-4500] +**Claude:** [Clones to lodash-lodash-pr-4528 and lodash-lodash-pr-4500 respectively] diff --git a/skills/github-pr-manager/scripts/ci_pr.sh b/skills/github-pr-manager/scripts/ci_pr.sh index a857e06..9c7142d 100644 --- a/skills/github-pr-manager/scripts/ci_pr.sh +++ b/skills/github-pr-manager/scripts/ci_pr.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# ci_pr.sh — PR CI 状态查看 + 失败分析 + 重跑 + 跟踪 -# 用法: ./ci_pr.sh [选项] +# ci_pr.sh — PR CI status check + failure analysis + rerun + tracking +# Usage: ./ci_pr.sh [options] set -euo pipefail if [ -t 1 ]; then @@ -9,24 +9,24 @@ else RED=''; GREEN=''; YELLOW=''; BOLD=''; OFF=''; fi show_help() { cat << 'HELP' -用法: ./ci_pr.sh [选项] - --log 显示失败 Job 完整日志 - --analyze 分析失败原因并给出修复建议 - --rerun 重跑失败 Job - --wait 重跑后等待完成 - --json 输出原始 CI checks JSON - --exit-code 有失败时退出码 1 - --yes,-y 跳过重跑确认 - --verbose 调试信息 - -h,--help 帮助 -环境变量: - GH_REPO 默认仓库 (owner/repo) - CI_PATTERNS 自定义错误模式文件路径, 每行: 正则|提示, 支持#注释 +Usage: ./ci_pr.sh [options] + --log Show full logs of failed jobs + --analyze Analyze failure reasons and suggest fixes + --rerun Rerun failed jobs + --wait Wait for rerun completion + --json Output raw CI checks JSON + --exit-code Exit with code 1 if any failure + --yes,-y Skip rerun confirmation + --verbose Debug info + -h,--help Show this help +Environment variables: + GH_REPO Default repository (owner/repo) + CI_PATTERNS Custom error pattern file path, one per line: regex|hint, # for comments HELP exit 0 } -# 失败状态:已结束且非成功/跳过 +# Failed states: completed and not success/skipped JQ_FAILED='select(.state == "FAILURE" or .state == "CANCELLED" or .state == "TIMED_OUT" or .state == "STARTUP_FAILURE" or .state == "ACTION_REQUIRED")' ANALYZE=false; RERUN=false; SHOW_LOG=false; WAIT=false @@ -45,18 +45,18 @@ for a in "$@"; do -y|--yes) SKIP_CONFIRM=true ;; *) [ -z "$REPO_ARG" ] && { REPO_ARG="$a"; continue; } [ -z "$PR_ARG" ] && { PR_ARG="$a"; continue; } - { echo "❌ 未知参数: $a"; exit 1; } ;; + { echo "❌ Unknown argument: $a"; exit 1; } ;; esac done REPO="${REPO_ARG:-${GH_REPO:-}}"; PR="${PR_ARG:-}" -[ -z "$REPO" ] && { echo "❌ 缺少仓库参数"; exit 1; } -[ -z "$PR" ] && { echo "❌ 缺少 PR 编号"; exit 1; } -[[ "$PR" =~ ^[0-9]+$ ]] || { echo "❌ PR 编号必须为数字"; exit 1; } -# 验证仓库格式(跳过 . 推断) -[[ "$REPO" = "." || "$REPO" =~ ^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$ ]] || { echo "❌ 仓库格式必须为 owner/repo"; exit 1; } +[ -z "$REPO" ] && { echo "❌ Missing repository argument"; exit 1; } +[ -z "$PR" ] && { echo "❌ Missing PR number"; exit 1; } +[[ "$PR" =~ ^[0-9]+$ ]] || { echo "❌ PR number must be numeric"; exit 1; } +# Validate repository format (skip . inference) +[[ "$REPO" = "." || "$REPO" =~ ^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$ ]] || { echo "❌ Repository format must be owner/repo"; exit 1; } debug() { [ "$VERBOSE" = true ] && printf '%s\n' "[DEBUG] $*" >&2; } -# 仓库推断 +# Repository inference infer_repo() { for remote in origin upstream; do local url; url=$(git remote get-url "$remote" 2>/dev/null) || continue @@ -68,24 +68,24 @@ infer_repo() { done; return 1 } if [ "$REPO" = "." ]; then - REPO=$(infer_repo) || { echo "❌ 无法推断仓库,请手动提供 owner/repo"; exit 1; } + REPO=$(infer_repo) || { echo "❌ Unable to infer repository, provide owner/repo manually"; exit 1; } printf '%s\n' "📁 $REPO" fi -command -v gh &>/dev/null || { echo "❌ 需要 gh"; exit 1; } -command -v jq &>/dev/null || { echo "❌ 需要 jq"; exit 1; } +command -v gh &>/dev/null || { echo "❌ gh is required"; exit 1; } +command -v jq &>/dev/null || { echo "❌ jq is required"; exit 1; } JQ_VER=$(jq --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+' | head -1 || echo "0.0") JQ_MAJOR=${JQ_VER%%.*}; JQ_MINOR=${JQ_VER##*.} { [ "$JQ_MAJOR" -lt 1 ] || { [ "$JQ_MAJOR" -eq 1 ] && [ "$JQ_MINOR" -lt 6 ]; }; } \ - && echo "⚠️ jq $JQ_VER 可能不支持部分功能,建议 ≥ 1.6" -gh auth status &>/dev/null || { echo "❌ 请 gh auth login"; exit 1; } + && echo "⚠️ jq $JQ_VER may lack some features, recommend >= 1.6" +gh auth status &>/dev/null || { echo "❌ Run gh auth login first"; exit 1; } debug "REPO=$REPO PR=$PR" H="━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" USE_JSON=true echo ""; printf '%s\n' "${BOLD}$H${OFF}" -printf '%s\n' "${BOLD}🔄 CI 状态 — PR #$PR ($REPO)${OFF}" +printf '%s\n' "${BOLD}🔄 CI Status — PR #$PR ($REPO)${OFF}" printf '%s\n' "🔗 https://github.com/$REPO/pull/$PR" printf '%s\n' "${BOLD}$H${OFF}" @@ -97,14 +97,14 @@ if $JSON_OUT && [ -n "$CHECKS_JSON" ]; then fi if [ -z "$CHECKS_TXT" ] && [ -z "$CHECKS_JSON" ]; then - printf '%s\n' " (此 PR 未配置 CI checks)"; exit 0 + printf '%s\n' " (This PR has no CI checks configured)"; exit 0 fi if [ -n "$CHECKS_JSON" ] && ! jq -e . >/dev/null 2>&1 <<< "$CHECKS_JSON"; then - printf '%s\n' "⚠️ JSON 数据无效,回退到文本模式"; USE_JSON=false + printf '%s\n' "⚠️ Invalid JSON data, falling back to text mode"; USE_JSON=false fi if $USE_JSON && [ "$CHECKS_JSON" = "[]" ]; then - printf '%s\n' "⚠️ 无法获取 JSON 数据,回退到文本模式"; USE_JSON=false + printf '%s\n' "⚠️ Unable to fetch JSON data, falling back to text mode"; USE_JSON=false fi if $USE_JSON; then @@ -112,11 +112,11 @@ if $USE_JSON; then PASSED=$(jq '[.[] | select(.state == "SUCCESS")] | length' <<< "$CHECKS_JSON") FAILED=$(jq "[.[] | $JQ_FAILED] | length" <<< "$CHECKS_JSON") PENDING=$(jq '[.[] | select(.state | test("PENDING|IN_PROGRESS|QUEUED"))] | length' <<< "$CHECKS_JSON") - printf '%s' "${BOLD}📊 总计 $TOTAL | ${GREEN}✅ $PASSED 通过${OFF}" - printf '%s\n' " | ${RED}❌ $FAILED 失败${OFF} | ${YELLOW}⏳ $PENDING 等待中${OFF}" + printf '%s' "${BOLD}📊 Total $TOTAL | ${GREEN}✅ $PASSED passed${OFF}" + printf '%s\n' " | ${RED}❌ $FAILED failed${OFF} | ${YELLOW}⏳ $PENDING pending${OFF}" else PASSED=0; FAILED=0; TOTAL=0 - printf '%s\n' "⚠️ 文本模式功能受限,建议安装 jq" + printf '%s\n' "⚠️ Text mode has limited features, jq recommended" fi printf '%s\n' "$CHECKS_TXT"; echo "" @@ -127,11 +127,11 @@ get_failed_runs() { local link; link=$(jq -r '.link // ""' <<< "$line") local name; name=$(jq -r '.name' <<< "$line") if [ -z "$link" ]; then - printf '%s\n' "⚠️ 「$name」无关联 workflow run,跳过" >&2; continue + printf '%s\n' "⚠️ \"$name\" has no associated workflow run, skipping" >&2; continue fi local rid; rid=$(echo "$link" | grep -Eo 'runs/[0-9]+' | cut -d/ -f2 || echo "") if [ -z "$rid" ]; then - printf '%s\n' "⚠️ 「$name」无法解析 run ID" >&2; continue + printf '%s\n' "⚠️ \"$name\" unable to parse run ID" >&2; continue fi printf '%s\t%s\n' "$rid" "$name" done | awk -F'\t' '!seen[$1]++' @@ -142,10 +142,10 @@ a() { ANALYSIS+="$1"$'\n'; } if $ANALYZE && [ "${FAILED:-0}" != "0" ] && $USE_JSON; then echo ""; printf '%s\n' "${BOLD}$H${OFF}" - printf '%s\n' "${BOLD}🔍 失败分析${OFF}"; printf '%s\n' "${BOLD}$H${OFF}" - echo "失败 Job:" + printf '%s\n' "${BOLD}🔍 Failure Analysis${OFF}"; printf '%s\n' "${BOLD}$H${OFF}" + echo "Failed jobs:" jq -r ".[] | $JQ_FAILED | \" ❌ \(.name) [\(.state)]\"" <<< "$CHECKS_JSON" - echo ""; echo "📋 日志分析:" + echo ""; echo "📋 Log analysis:" while IFS=$'\t' read -r run_id job_name; do ANALYSIS="" echo ""; echo "━━ $job_name (run $run_id) ━━" @@ -153,34 +153,34 @@ if $ANALYZE && [ "${FAILED:-0}" != "0" ] && $USE_JSON; then if [ -n "$LOG" ]; then printf '%s\n' "$LOG" | head -n 120 if lm 'npm ERR!|error TS[0-9]+|Cannot find module'; then - a " → Node.js/TS 构建或依赖错误"; a " 运行: npm ci && npm run build" + a " → Node.js/TS build or dependency error"; a " Run: npm ci && npm run build" fi if lm 'error\[E\d+\]|cargo build.*failed'; then - a " → Rust 编译错误"; a " 运行: cargo check --all-features" + a " → Rust compilation error"; a " Run: cargo check --all-features" fi if lm 'FAIL:|assertion|expected.*but got|Actual:'; then - a " → 测试失败"; a " 运行: cargo test | npm test | pytest" + a " → Test failure"; a " Run: cargo test | npm test | pytest" fi if lm 'warning:.*clippy|prettier|eslint|format'; then - a " → Lint/格式错误"; a " 运行: cargo clippy | npm run lint" + a " → Lint/format error"; a " Run: cargo clippy | npm run lint" fi if lm 'timeout|timed out|connection refused|502|503|504'; then - a " → 网络超时或服务不可用"; a " 建议: --rerun 重试" + a " → Network timeout or service unavailable"; a " Suggestion: --rerun" fi if lm 'could not resolve|ModuleNotFoundError|ImportError'; then - a " → 依赖解析失败"; a " 建议: 检查依赖声明和锁文件" + a " → Dependency resolution failure"; a " Suggestion: check dependency declarations and lock file" fi if lm 'docker build.*failed|manifest.*not found'; then - a " → Docker 构建错误"; a " 运行: docker build ." + a " → Docker build error"; a " Run: docker build ." fi if lm 'not set|required.*variable|variable.*missing'; then - a " → 环境变量缺失"; a " 建议: 检查 CI secrets/variables" + a " → Missing environment variable"; a " Suggestion: check CI secrets/variables" fi if lm 'Permission denied|403|not authorized'; then - a " → 权限不足"; a " 建议: gh auth refresh -s workflow" + a " → Insufficient permissions"; a " Suggestion: gh auth refresh -s workflow" fi if lm 'certificate|SSL|TLS|untrusted'; then - a " → 证书/SSL 错误"; a " 建议: 检查证书或网络代理" + a " → Certificate/SSL error"; a " Suggestion: check certificate or network proxy" fi if [ -n "${CI_PATTERNS:-}" ]; then if [ -f "$CI_PATTERNS" ]; then @@ -189,63 +189,63 @@ if $ANALYZE && [ "${FAILED:-0}" != "0" ] && $USE_JSON; then lm "$pat" && a " → $hint" done < "$CI_PATTERNS" else - printf '%s\n' "⚠️ CI_PATTERNS 文件不存在: $CI_PATTERNS" >&2 + printf '%s\n' "⚠️ CI_PATTERNS file not found: $CI_PATTERNS" >&2 fi fi - [ -z "$ANALYSIS" ] && a " → 未匹配已知错误模式" - echo ""; printf '%s\n' "${BOLD}💡 分析:${OFF}"; printf '%s' "$ANALYSIS" + [ -z "$ANALYSIS" ] && a " → No known error pattern matched" + echo ""; printf '%s\n' "${BOLD}💡 Analysis:${OFF}"; printf '%s' "$ANALYSIS" KEY=$(grep -iE 'error|fail|fatal' <<< "$LOG" | head -n 5 || true) - [ -n "$KEY" ] && { echo ""; printf '%s\n' "${BOLD}🔑 关键行:${OFF}"; printf '%s\n' "$KEY" | sed 's/^/ /'; } + [ -n "$KEY" ] && { echo ""; printf '%s\n' "${BOLD}🔑 Key lines:${OFF}"; printf '%s\n' "$KEY" | sed 's/^/ /'; } TL=$(printf '%s\n' "$LOG" | tail -n 15) - echo ""; printf '%s\n' "${BOLD}📄 日志末尾:${OFF}"; printf '%s\n' "$TL" | sed 's/^/ /' - else echo " (无法获取日志)"; fi + echo ""; printf '%s\n' "${BOLD}📄 Log tail:${OFF}"; printf '%s\n' "$TL" | sed 's/^/ /' + else echo " (Unable to fetch log)"; fi done < <(get_failed_runs) elif $ANALYZE && [ "${FAILED:-0}" != "0" ]; then - printf '%s\n' " ⚠️ 文本模式不支持分析" -elif $ANALYZE; then printf '%s\n' " (全部通过)"; fi + printf '%s\n' " ⚠️ Text mode does not support analysis" +elif $ANALYZE; then printf '%s\n' " (All passed)"; fi if $SHOW_LOG && [ "${FAILED:-0}" != "0" ] && $USE_JSON; then echo ""; printf '%s\n' "${BOLD}$H${OFF}" - printf '%s\n' "${BOLD}📋 失败日志 (完整)${OFF}"; printf '%s\n' "${BOLD}$H${OFF}" + printf '%s\n' "${BOLD}📋 Failure logs (full)${OFF}"; printf '%s\n' "${BOLD}$H${OFF}" while IFS=$'\t' read -r run_id job_name; do echo ""; echo "━━ $job_name (run $run_id) ━━" printf '%s\n' "🔗 https://github.com/$REPO/actions/runs/$run_id" - gh run view "$run_id" --repo "$REPO" --log-failed 2>/dev/null || echo " (无)" + gh run view "$run_id" --repo "$REPO" --log-failed 2>/dev/null || echo " (none)" done < <(get_failed_runs) fi if $RERUN && [ "${FAILED:-0}" != "0" ] && $USE_JSON; then echo ""; printf '%s\n' "${BOLD}$H${OFF}" - printf '%s\n' "${BOLD}🔄 重跑失败 Job${OFF}"; printf '%s\n' "${BOLD}$H${OFF}" + printf '%s\n' "${BOLD}🔄 Rerunning failed jobs${OFF}"; printf '%s\n' "${BOLD}$H${OFF}" while IFS=$'\t' read -r run_id job_name; do echo " ❌ $job_name (run $run_id)" done < <(get_failed_runs) if ! $SKIP_CONFIRM; then - echo ""; read -r -p "确认重跑以上所有失败 Job? [y/N] " cf - [[ "${cf:-n}" != "y" && "${cf:-n}" != "Y" ]] && { echo "已取消"; exit 0; } + echo ""; read -r -p "Confirm rerun all failed jobs above? [y/N] " cf + [[ "${cf:-n}" != "y" && "${cf:-n}" != "Y" ]] && { echo "Cancelled"; exit 0; } fi NEW_RUNS=() while IFS=$'\t' read -r run_id job_name; do - echo "🔄 重跑 $job_name ..." - RERUN_OUT=$(gh run rerun "$run_id" --repo "$REPO" --failed 2>&1) || { printf '%s\n' " ${RED}⚠️ 重跑失败${OFF}"; continue; } + echo "🔄 Rerunning $job_name ..." + RERUN_OUT=$(gh run rerun "$run_id" --repo "$REPO" --failed 2>&1) || { printf '%s\n' " ${RED}⚠️ Rerun failed${OFF}"; continue; } NEW_ID=$(echo "$RERUN_OUT" | grep -oE 'runs/[0-9]+' | cut -d/ -f2 | head -1 || echo "") if [ -n "$NEW_ID" ]; then - printf '%s\n' " ${GREEN}✅ 新 run: $NEW_ID${OFF}"; NEW_RUNS+=("$NEW_ID") - else printf '%s\n' " ✅ 已触发"; fi + printf '%s\n' " ${GREEN}✅ New run: $NEW_ID${OFF}"; NEW_RUNS+=("$NEW_ID") + else printf '%s\n' " ✅ Triggered"; fi done < <(get_failed_runs) if [ ${#NEW_RUNS[@]} -gt 0 ]; then - echo ""; echo "📎 新 Run:" + echo ""; echo "📎 New runs:" for rid in "${NEW_RUNS[@]}"; do printf '%s\n' " https://github.com/$REPO/actions/runs/$rid" done if $WAIT; then - echo ""; echo "⏳ 等待完成..." + echo ""; echo "⏳ Waiting for completion..." for rid in "${NEW_RUNS[@]}"; do gh run watch "$rid" --repo "$REPO" 2>&1 || { - echo " watch 不可用,轮询中..." + echo " watch unavailable, polling..." while true; do S=$(gh run view "$rid" --repo "$REPO" --json status --jq '.status' 2>/dev/null) - [ "$S" = "completed" ] && { echo " ✅ 完成"; break; } + [ "$S" = "completed" ] && { echo " ✅ Completed"; break; } sleep 15 done } @@ -253,8 +253,8 @@ if $RERUN && [ "${FAILED:-0}" != "0" ] && $USE_JSON; then fi fi elif $RERUN && [ "${FAILED:-0}" != "0" ]; then - printf '%s\n' " ⚠️ 文本模式不支持重跑" -elif $RERUN; then printf '%s\n' " (全部通过,无需重跑)"; fi + printf '%s\n' " ⚠️ Text mode does not support rerun" +elif $RERUN; then printf '%s\n' " (All passed, no rerun needed)"; fi echo ""; printf '%s\n' "${BOLD}$H${OFF}" diff --git a/skills/github-pr-manager/scripts/clone_pr.sh b/skills/github-pr-manager/scripts/clone_pr.sh index 82332eb..b1fb881 100644 --- a/skills/github-pr-manager/scripts/clone_pr.sh +++ b/skills/github-pr-manager/scripts/clone_pr.sh @@ -1,50 +1,50 @@ #!/usr/bin/env bash -# clone_pr.sh — 克隆 GitHub PR 到 --pr-<编号> 目录并检测项目类型引导初始化 -# 兼容: Git Bash (Windows), WSL2, macOS, Linux -# 用法: ./clone_pr.sh [base_path] [选项] +# clone_pr.sh — Clone a GitHub PR to --pr- directory and detect project type for guided initialization +# Compatibility: Git Bash (Windows), WSL2, macOS, Linux +# Usage: ./clone_pr.sh [base_path] [options] set -euo pipefail # ============================================================================ -# 帮助信息 +# Help information # ============================================================================ show_help() { cat << 'EOF' -用法: ./clone_pr.sh [base_path] [选项] +Usage: ./clone_pr.sh [base_path] [options] -克隆 GitHub PR 到本地 --pr-<编号> 目录,自动检测项目类型并引导初始化。 +Clone a GitHub PR to a local --pr- directory, auto-detect project type, and guide initialization. -参数: - owner/repo GitHub 仓库(如 facebook/react) - pr_number PR 编号 - base_path 克隆根目录(默认当前目录) +Arguments: + owner/repo GitHub repository (e.g. facebook/react) + pr_number PR number + base_path Clone root directory (default: current directory) -选项: - -y, --yes 跳过所有确认提示(非交互模式) - --no-install 禁止任何依赖安装,仅克隆代码(最高安全级别) - --force 非交互模式下,若目标目录已存在则自动删除重建 - --debug 输出详细诊断日志 - -h, --help 显示此帮助 +Options: + -y, --yes Skip all confirmation prompts (non-interactive mode) + --no-install Skip any dependency installation, only clone code (highest safety level) + --force In non-interactive mode, auto delete and recreate if target directory exists + --debug Output detailed diagnostic logs + -h, --help Show this help -环境变量: - CLONE_PR_YES=1 等同于 -y - CLONE_PR_NO_INSTALL=1 等同于 --no-install - CLONE_PR_RUST_MODE 非交互模式下 Rust 行为: fetch|build|check|skip(默认 fetch) +Environment variables: + CLONE_PR_YES=1 Equivalent to -y + CLONE_PR_NO_INSTALL=1 Equivalent to --no-install + CLONE_PR_RUST_MODE Rust behavior in non-interactive mode: fetch|build|check|skip (default fetch) -示例: +Examples: ./clone_pr.sh facebook/react 28452 ./clone_pr.sh lodash/lodash 4528 ~/dev/pr-review -y ./clone_pr.sh owner/repo 123 . --no-install --debug -审查完成后: - 清理: rm -rf --pr-<编号> - 提交: cd --pr-<编号> && git push # 需仓库写权限 +After review: + Cleanup: rm -rf --pr- + Submit: cd --pr- && git push # requires repo write access EOF exit 0 } # ============================================================================ -# 参数解析 +# Argument parsing # ============================================================================ SKIP_CONFIRM=false NO_INSTALL=false @@ -59,7 +59,7 @@ for arg in "$@"; do --no-install) NO_INSTALL=true ;; --force) FORCE_DELETE=true ;; --debug) DEBUG=true ;; - --*) echo "❌ 未知选项: $arg" >&2; exit 1 ;; + --*) echo "❌ Unknown option: $arg" >&2; exit 1 ;; *) ARGS+=("$arg") ;; esac done @@ -67,14 +67,14 @@ done [ "${CLONE_PR_YES:-0}" = "1" ] && SKIP_CONFIRM=true [ "${CLONE_PR_NO_INSTALL:-0}" = "1" ] && NO_INSTALL=true -REPO="${ARGS[0]:?请提供仓库 (owner/repo)}" -PR_NUMBER="${ARGS[1]:?请提供 PR 编号}" +REPO="${ARGS[0]:?Please provide repository (owner/repo)}" +PR_NUMBER="${ARGS[1]:?Please provide PR number}" -# 跨平台路径规范化(Git Bash / WSL / macOS / Linux 通用) +# Cross-platform path normalization (Git Bash / WSL / macOS / Linux compatible) BASE_PATH="${ARGS[2]:-.}" mkdir -p "$BASE_PATH" BASE_PATH="$(cd "$BASE_PATH" && pwd)" || { - echo "❌ 无法进入目录: $BASE_PATH" + echo "❌ Cannot enter directory: $BASE_PATH" exit 1 } @@ -82,21 +82,21 @@ REPO_SAFE="${REPO//\//-}" TARGET_DIR="${BASE_PATH}/${REPO_SAFE}-pr-${PR_NUMBER}" # ============================================================================ -# 中断/退出清理 +# Interrupt/exit cleanup # ============================================================================ CLONE_DONE=false cleanup() { if [ -d "$TARGET_DIR" ] && ! $CLONE_DONE; then echo "" - echo "🧹 清理未完成的克隆目录: ${TARGET_DIR}" + echo "🧹 Cleaning up incomplete clone directory: ${TARGET_DIR}" rm -rf "$TARGET_DIR" fi } trap cleanup EXIT # ============================================================================ -# 诊断日志 +# Diagnostic log # ============================================================================ debug() { [ "$DEBUG" = true ] && echo "[DEBUG] $*" >&2; } debug "REPO=$REPO PR=$PR_NUMBER BASE_PATH=$BASE_PATH" @@ -104,7 +104,7 @@ debug "TARGET_DIR=$TARGET_DIR" debug "SKIP_CONFIRM=$SKIP_CONFIRM NO_INSTALL=$NO_INSTALL FORCE_DELETE=$FORCE_DELETE" # ============================================================================ -# 辅助函数 +# Helper functions # ============================================================================ confirm_or_skip() { @@ -123,7 +123,7 @@ confirm_or_skip() { return 0 } -# 安全获取目录大小(Git Bash 可能没有 du) +# Safely get directory size (Git Bash may not have du) get_dir_size() { if command -v du &>/dev/null; then du -sh . 2>/dev/null | awk '{print $1}' @@ -133,105 +133,105 @@ get_dir_size() { } # ============================================================================ -# 前置检查 +# Pre-checks # ============================================================================ if ! command -v gh &>/dev/null; then - echo "❌ 需要安装 GitHub CLI: https://cli.github.com/" + echo "❌ GitHub CLI is required: https://cli.github.com/" exit 1 fi debug "gh: $(gh --version 2>&1 | head -1)" if ! gh auth status &>/dev/null; then - echo "❌ 未登录 GitHub CLI,请执行: gh auth login" + echo "❌ Not logged into GitHub CLI, run: gh auth login" exit 1 fi if [ ! -w "$BASE_PATH" ]; then - echo "❌ 路径 $BASE_PATH 不可写,请检查权限。" + echo "❌ Path $BASE_PATH is not writable, check permissions." exit 1 fi SKIP_CLONE=false if [ -d "$TARGET_DIR" ]; then - echo "⚠️ 目录 ${TARGET_DIR} 已存在。" + echo "⚠️ Directory ${TARGET_DIR} already exists." if [ "$SKIP_CONFIRM" = true ]; then if [ "$FORCE_DELETE" = true ]; then - echo "🔄 自动删除已有目录 ${TARGET_DIR} ..." + echo "🔄 Auto deleting existing directory ${TARGET_DIR} ..." rm -rf "$TARGET_DIR" else - echo "❌ 非交互模式下目标目录已存在,拒绝自动删除。" - echo " 请手动处理或使用 --force 选项。" + echo "❌ In non-interactive mode, target directory already exists, refusing to auto delete." + echo " Handle it manually or use --force." exit 1 fi else - echo " [y] 删除并重新克隆" - echo " [n] 跳过克隆,直接在已有目录检测项目类型" - echo " [q] 取消" - read -r -p "选择: " choice + echo " [y] Delete and re-clone" + echo " [n] Skip clone, detect project type in existing directory" + echo " [q] Cancel" + read -r -p "Choice: " choice case "$choice" in y|Y) rm -rf "$TARGET_DIR" ;; n|N) SKIP_CLONE=true ;; - *) echo "已取消" && exit 0 ;; + *) echo "Cancelled" && exit 0 ;; esac fi fi # ============================================================================ -# 安全警告 +# Safety warning # ============================================================================ cat << 'EOF' -⚠️ 您即将操作来自第三方 PR 的代码,其中可能包含未审查的内容。 -安装依赖(npm install / pip install 等)时可能执行构建脚本。 +⚠️ You are about to operate on code from a third-party PR, which may contain unreviewed content. +Installing dependencies (npm install / pip install etc.) may execute build scripts. -请优先检查以下文件中是否包含恶意脚本: - - package.json 中的 "scripts"(尤其 preinstall / postinstall) +Please check these files for malicious scripts first: + - "scripts" in package.json (especially preinstall / postinstall) - Makefile / CMakeLists.txt / build.gradle - - setup.py / pyproject.toml 中的自定义命令 - - 任何 .sh / .bat / .ps1 文件 + - Custom commands in setup.py / pyproject.toml + - Any .sh / .bat / .ps1 files -建议在审查代码后再安装依赖。 +It is recommended to review code before installing dependencies. EOF if [ "$NO_INSTALL" = true ]; then - echo "🔒 --no-install 模式:本次不会安装任何依赖。" + echo "🔒 --no-install mode: no dependencies will be installed this time." fi if [ "$SKIP_CONFIRM" = false ] && ! $SKIP_CLONE; then - read -r -p "是否继续? [y/N] " confirm + read -r -p "Continue? [y/N] " confirm if [ "${confirm:-N}" != "y" ] && [ "${confirm:-N}" != "Y" ]; then - echo "已取消。" + echo "Cancelled." exit 0 fi fi # ============================================================================ -# 克隆流程 +# Clone workflow # ============================================================================ if ! $SKIP_CLONE; then - echo "🚀 正在克隆 PR #${PR_NUMBER} from ${REPO}..." + echo "🚀 Cloning PR #${PR_NUMBER} from ${REPO}..." if ! gh repo clone "$REPO" "$TARGET_DIR" -- --filter=blob:none 2>/dev/null; then - echo "⚠️ 部分克隆失败(可能 Git 版本过旧或服务端不支持)" - echo " 建议升级 Git 到 ≥ 2.19" - echo " 正在尝试完整克隆..." + echo "⚠️ Partial clone failed (possibly git version too old or server unsupported)" + echo " Upgrade git to >= 2.19 recommended" + echo " Attempting full clone..." if ! gh repo clone "$REPO" "$TARGET_DIR"; then - echo "❌ 无法克隆仓库 $REPO" - echo " 请检查仓库名是否正确,以及是否有访问权限。" + echo "❌ Unable to clone repository $REPO" + echo " Check the repository name and your access permissions." exit 1 fi fi cd "$TARGET_DIR" - echo "⏳ 检出 PR 分支..." + echo "⏳ Checking out PR branch..." if ! gh pr checkout "$PR_NUMBER"; then - echo "❌ 无法检出 PR #${PR_NUMBER}" - echo " 请检查:PR 编号是否正确 / 是否有该仓库读取权限 / 网络是否正常" + echo "❌ Unable to checkout PR #${PR_NUMBER}" + echo " Check: PR number is correct / you have read access / network is working" cd "$BASE_PATH" rm -rf "$TARGET_DIR" exit 1 @@ -239,34 +239,34 @@ if ! $SKIP_CLONE; then CLONE_DONE=true else - # 跳过克隆时立即标记完成,防止 cleanup 误删用户目录 + # Mark done immediately on skip to prevent cleanup from deleting user directory CLONE_DONE=true - echo "📂 使用已有目录: ${TARGET_DIR}" + echo "📂 Using existing directory: ${TARGET_DIR}" if ! cd "$TARGET_DIR" 2>/dev/null; then - echo "❌ 无法进入目录: ${TARGET_DIR}" + echo "❌ Cannot enter directory: ${TARGET_DIR}" exit 1 fi if ! git rev-parse --git-dir >/dev/null 2>&1; then - echo "❌ 目录 ${TARGET_DIR} 不是一个 Git 仓库。" + echo "❌ Directory ${TARGET_DIR} is not a git repository." exit 1 fi - echo "🌿 当前分支: $(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown')" + echo "🌿 Current branch: $(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown')" if [ "$SKIP_CONFIRM" = false ]; then - read -r -p "确认使用该目录? [y/N] " ans + read -r -p "Confirm using this directory? [y/N] " ans [ "${ans:-n}" != "y" ] && [ "${ans:-n}" != "Y" ] && exit 0 fi fi # ============================================================================ -# 展示克隆结果 +# Display clone results # ============================================================================ BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown") -# 优先用 gh API 获取 base 分支 +# Prefer gh API for base branch BASE_BRANCH=$(gh pr view "$PR_NUMBER" --json baseRefName --jq '.baseRefName' 2>/dev/null) if [ -z "$BASE_BRANCH" ]; then BASE_BRANCH=$(git rev-parse --abbrev-ref 'HEAD@{upstream}' 2>/dev/null | sed 's|^[^/]*/||') @@ -276,16 +276,16 @@ fi SIZE=$(get_dir_size) echo "" -echo "✅ PR #${PR_NUMBER} 就绪" +echo "✅ PR #${PR_NUMBER} ready" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "📂 路径: ${TARGET_DIR}" -echo "🌿 分支: ${BRANCH}" -echo "📏 大小: ${SIZE}(使用 --filter=blob:none 时文件内容按需下载)" +echo "📂 Path: ${TARGET_DIR}" +echo "🌿 Branch: ${BRANCH}" +echo "📏 Size: ${SIZE} (with --filter=blob:none, file content is fetched on demand)" echo "📍 Base: ${BASE_BRANCH}" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" # ============================================================================ -# Node 版本提示(.nvmrc / .node-version) +# Node version hint (.nvmrc / .node-version) # ============================================================================ check_node_version_hint() { local node_ver_file="" @@ -296,13 +296,13 @@ check_node_version_hint() { local ver ver=$(head -1 "$node_ver_file" 2>/dev/null) echo "" - echo "💡 检测到 ${node_ver_file},建议使用 Node.js ${ver}" - echo " nvm use # 或: fnm use" + echo "💡 Detected ${node_ver_file}, recommend Node.js ${ver}" + echo " nvm use # or: fnm use" fi } # ============================================================================ -# 项目类型检测(独立检测,支持混合项目 / monorepo) +# Project type detection (independent detection, supports hybrid / monorepo) # ============================================================================ DETECTED_TYPES=() @@ -317,7 +317,7 @@ fi readarray -t DETECTED_TYPES < <(printf '%s\n' "${DETECTED_TYPES[@]}" | sort -u) -debug "检测到项目类型: ${DETECTED_TYPES[*]:-无}" +debug "Detected project types: ${DETECTED_TYPES[*]:-none}" DEPS_INSTALLED=false SUMMARY_PARTS=() @@ -328,48 +328,48 @@ SUMMARY_PARTS=() install_node() { echo "" - echo "🔍 检测到 Node.js 项目 (package.json)" + echo "🔍 Detected Node.js project (package.json)" check_node_version_hint - if ! confirm_or_skip "是否为 Node.js 安装依赖?"; then - SUMMARY_PARTS+=("Node.js: ⏭ 未安装 (手动: npm install)") + if ! confirm_or_skip "Install dependencies for Node.js?"; then + SUMMARY_PARTS+=("Node.js: ⏭ Skipped (manual: npm install)") return fi if [ -f "pnpm-lock.yaml" ]; then if command -v pnpm &>/dev/null; then - debug "使用 pnpm" + debug "Using pnpm" if pnpm install; then DEPS_INSTALLED=true SUMMARY_PARTS+=("Node.js: ✅ pnpm") else - SUMMARY_PARTS+=("Node.js: ❌ pnpm 安装失败") + SUMMARY_PARTS+=("Node.js: ❌ pnpm install failed") fi else - echo "⚠️ pnpm 未安装,回退到 npm ..." + echo "⚠️ pnpm not installed, falling back to npm ..." if npm install; then DEPS_INSTALLED=true - SUMMARY_PARTS+=("Node.js: ✅ npm (pnpm 不可用)") + SUMMARY_PARTS+=("Node.js: ✅ npm (pnpm unavailable)") else - SUMMARY_PARTS+=("Node.js: ❌ npm 安装失败") + SUMMARY_PARTS+=("Node.js: ❌ npm install failed") fi fi elif [ -f "yarn.lock" ]; then if command -v yarn &>/dev/null; then - debug "使用 yarn" + debug "Using yarn" if yarn install; then DEPS_INSTALLED=true SUMMARY_PARTS+=("Node.js: ✅ yarn") else - SUMMARY_PARTS+=("Node.js: ❌ yarn 安装失败") + SUMMARY_PARTS+=("Node.js: ❌ yarn install failed") fi else - echo "⚠️ yarn 未安装,回退到 npm ..." + echo "⚠️ yarn not installed, falling back to npm ..." if npm install; then DEPS_INSTALLED=true - SUMMARY_PARTS+=("Node.js: ✅ npm (yarn 不可用)") + SUMMARY_PARTS+=("Node.js: ✅ npm (yarn unavailable)") else - SUMMARY_PARTS+=("Node.js: ❌ npm 安装失败") + SUMMARY_PARTS+=("Node.js: ❌ npm install failed") fi fi else @@ -377,7 +377,7 @@ install_node() { DEPS_INSTALLED=true SUMMARY_PARTS+=("Node.js: ✅ npm") else - SUMMARY_PARTS+=("Node.js: ❌ npm 安装失败") + SUMMARY_PARTS+=("Node.js: ❌ npm install failed") fi fi } @@ -388,68 +388,68 @@ install_node() { install_python() { echo "" - echo "🔍 检测到 Python 项目" - if ! confirm_or_skip "是否为 Python 安装依赖?"; then + echo "🔍 Detected Python project" + if ! confirm_or_skip "Install dependencies for Python?"; then local hint="pip install -r requirements.txt" [ -f "pyproject.toml" ] && hint="pip install ." - SUMMARY_PARTS+=("Python: ⏭ 未安装 (手动: ${hint})") + SUMMARY_PARTS+=("Python: ⏭ Skipped (manual: ${hint})") return fi PYTHON=$(command -v python3 || command -v python) if [ -z "$PYTHON" ]; then - echo "❌ 未找到 Python,请先安装 Python ≥ 3.6" - SUMMARY_PARTS+=("Python: ❌ 未找到解释器") + echo "❌ Python not found, please install Python >= 3.6 first" + SUMMARY_PARTS+=("Python: ❌ Interpreter not found") return fi debug "Python: $PYTHON ($($PYTHON --version 2>&1))" - # 跨平台版本检查(不依赖 sort -V) + # Cross-platform version check (does not rely on sort -V) local py_ver py_ver=$("$PYTHON" --version 2>&1 | awk '{print $2}') if ! "$PYTHON" -c "import sys; sys.exit(0 if sys.version_info >= (3,6) else 1)" 2>/dev/null; then - echo "❌ Python 版本为 ${py_ver:-?},需要 ≥ 3.6" - SUMMARY_PARTS+=("Python: ❌ 版本 ${py_ver:-?} 不满足 (需 ≥ 3.6)") + echo "❌ Python version is ${py_ver:-?}, requires >= 3.6" + SUMMARY_PARTS+=("Python: ❌ Version ${py_ver:-?} insufficient (need >= 3.6)") return fi - debug "Python 版本: $py_ver" + debug "Python version: $py_ver" - # 工具检测顺序:uv → poetry → pdm → pip + # Tool detection order: uv -> poetry -> pdm -> pip if [ -f "uv.lock" ] && command -v uv &>/dev/null; then - debug "使用 uv" + debug "Using uv" if uv sync; then DEPS_INSTALLED=true SUMMARY_PARTS+=("Python: ✅ uv") else - SUMMARY_PARTS+=("Python: ❌ uv sync 失败") + SUMMARY_PARTS+=("Python: ❌ uv sync failed") fi return fi if [ -f "poetry.lock" ] && command -v poetry &>/dev/null; then - debug "使用 poetry" + debug "Using poetry" if poetry install; then DEPS_INSTALLED=true SUMMARY_PARTS+=("Python: ✅ poetry") else - SUMMARY_PARTS+=("Python: ❌ poetry 安装失败") + SUMMARY_PARTS+=("Python: ❌ poetry install failed") fi return fi if [ -f "pdm.lock" ] && command -v pdm &>/dev/null; then - debug "使用 pdm" + debug "Using pdm" if pdm install; then DEPS_INSTALLED=true SUMMARY_PARTS+=("Python: ✅ pdm") else - SUMMARY_PARTS+=("Python: ❌ pdm 安装失败") + SUMMARY_PARTS+=("Python: ❌ pdm install failed") fi return fi if [ -f "uv.lock" ] || [ -f "poetry.lock" ] || [ -f "pdm.lock" ]; then - echo "⚠️ 检测到锁文件但对应工具不可用,回退到 pip ..." + echo "⚠️ Lock file detected but corresponding tool unavailable, falling back to pip ..." fi - # 标准 venv + pip + # Standard venv + pip local d act VENV_DIR for d in ".venv" "venv" "env"; do if [ -d "$d" ]; then @@ -457,12 +457,12 @@ install_python() { [ -f "$d/bin/activate" ] && act="$d/bin/activate" [ -f "$d/Scripts/activate" ] && act="$d/Scripts/activate" if [ -n "$act" ] && [ -f "$act" ]; then - # 验证虚拟环境可执行 + # Verify virtual environment is executable local test_py="${d}/bin/python" [ -f "${d}/Scripts/python.exe" ] && test_py="${d}/Scripts/python.exe" if [ -f "$test_py" ] && "$test_py" -c "print('ok')" >/dev/null 2>&1; then VENV_DIR="$d" - debug "复用已有虚拟环境: $d" + debug "Reusing existing virtual environment: $d" break fi fi @@ -472,19 +472,19 @@ install_python() { if [ -z "$VENV_DIR" ]; then VENV_DIR=".venv" if ! $PYTHON -m venv "$VENV_DIR"; then - echo "❌ 无法创建虚拟环境,请检查 Python 安装。" - SUMMARY_PARTS+=("Python: ❌ venv 创建失败") + echo "❌ Cannot create virtual environment, check Python installation." + SUMMARY_PARTS+=("Python: ❌ venv creation failed") return fi fi - # 在子 shell 中激活 + 安装,避免污染当前 shell 环境 + # Activate + install in subshell to avoid polluting current shell local install_ok=false if [ -f "$VENV_DIR/bin/activate" ]; then ( source "$VENV_DIR/bin/activate" if [ -f "pyproject.toml" ]; then - echo "📦 尝试从 pyproject.toml 安装 ..." + echo "📦 Attempting install from pyproject.toml ..." pip install . else pip install -r requirements.txt @@ -494,15 +494,15 @@ install_python() { ( source "$VENV_DIR/Scripts/activate" if [ -f "pyproject.toml" ]; then - echo "📦 尝试从 pyproject.toml 安装 ..." + echo "📦 Attempting install from pyproject.toml ..." pip install . else pip install -r requirements.txt fi ) && install_ok=true else - echo "❌ 虚拟环境未正确创建,跳过激活" - SUMMARY_PARTS+=("Python: ⚠️ 虚拟环境异常") + echo "❌ Virtual environment not created properly, skipping activation" + SUMMARY_PARTS+=("Python: ⚠️ Virtual environment abnormal") return fi @@ -510,8 +510,8 @@ install_python() { DEPS_INSTALLED=true SUMMARY_PARTS+=("Python: ✅ pip (${VENV_DIR})") else - echo "⚠️ pip install 失败,请手动检查构建系统配置" - SUMMARY_PARTS+=("Python: ⚠️ 安装失败") + echo "⚠️ pip install failed, please check build system configuration manually" + SUMMARY_PARTS+=("Python: ⚠️ Install failed") fi } @@ -521,40 +521,40 @@ install_python() { install_rust() { echo "" - echo "🔍 检测到 Rust 项目 (Cargo.toml)" + echo "🔍 Detected Rust project (Cargo.toml)" if ! command -v cargo &>/dev/null; then - echo "❌ cargo 未安装,请先安装 Rust: https://rustup.rs/" - SUMMARY_PARTS+=("Rust: ❌ cargo 不可用") + echo "❌ cargo not installed, install Rust first: https://rustup.rs/" + SUMMARY_PARTS+=("Rust: ❌ cargo unavailable") return fi if [ "$NO_INSTALL" = true ]; then - SUMMARY_PARTS+=("Rust: ⏭ 未构建 (手动: cargo build)") + SUMMARY_PARTS+=("Rust: ⏭ Not built (manual: cargo build)") return fi local rust_choice="" if [ "$SKIP_CONFIRM" = false ] && [ -t 0 ]; then echo "" - echo " [f] 仅下载依赖 (cargo fetch) — 快速,不编译" - echo " [b] 完整构建 (cargo build) — 可能较慢" - echo " [c] 快速检查 (cargo check) — 不生成二进制" - echo " [s] 跳过" - read -r -p "选择 [f/b/c/s] (默认 f): " rust_choice + echo " [f] Fetch dependencies only (cargo fetch) — fast, no compilation" + echo " [b] Full build (cargo build) — may be slow" + echo " [c] Quick check (cargo check) — no binary output" + echo " [s] Skip" + read -r -p "Choice [f/b/c/s] (default f): " rust_choice else rust_choice="${CLONE_PR_RUST_MODE:-f}" fi [ -z "$rust_choice" ] && rust_choice="f" - # 校验值合法性 + # Validate value case "$rust_choice" in f|fetch) rust_choice="f" ;; b|build) rust_choice="b" ;; c|check) rust_choice="c" ;; s|skip) rust_choice="s" ;; *) - echo "⚠️ 无效的 CLONE_PR_RUST_MODE 值: $rust_choice,回退到 fetch" + echo "⚠️ Invalid CLONE_PR_RUST_MODE value: $rust_choice, falling back to fetch" rust_choice="f" ;; esac @@ -562,10 +562,10 @@ install_rust() { case "$rust_choice" in f) if cargo fetch; then - SUMMARY_PARTS+=("Rust: ✅ 依赖已下载") - echo "💡 依赖已下载,执行 cargo build 将开始编译,可能耗时较长。" + SUMMARY_PARTS+=("Rust: ✅ Dependencies fetched") + echo "💡 Dependencies downloaded, running cargo build will start compilation, may take some time." else - SUMMARY_PARTS+=("Rust: ❌ cargo fetch 失败") + SUMMARY_PARTS+=("Rust: ❌ cargo fetch failed") fi ;; b) @@ -573,53 +573,53 @@ install_rust() { DEPS_INSTALLED=true SUMMARY_PARTS+=("Rust: ✅ cargo build") else - SUMMARY_PARTS+=("Rust: ❌ cargo build 失败") + SUMMARY_PARTS+=("Rust: ❌ cargo build failed") fi ;; c) if cargo check; then - SUMMARY_PARTS+=("Rust: ✅ cargo check 通过") + SUMMARY_PARTS+=("Rust: ✅ cargo check passed") else - SUMMARY_PARTS+=("Rust: ❌ cargo check 失败") + SUMMARY_PARTS+=("Rust: ❌ cargo check failed") fi ;; - s) SUMMARY_PARTS+=("Rust: ⏭ 跳过 (手动: cargo build)") ;; + s) SUMMARY_PARTS+=("Rust: ⏭ Skipped (manual: cargo build)") ;; esac } # ============================================================================ -# Go(仅提示,不自动安装) +# Go (hint only, no automatic install) # ============================================================================ install_go() { echo "" - echo "🔍 检测到 Go 项目 (go.mod)" - SUMMARY_PARTS+=("Go: ℹ️ 使用 go mod (手动: go mod download)") + echo "🔍 Detected Go project (go.mod)" + SUMMARY_PARTS+=("Go: ℹ️ Use go mod (manual: go mod download)") } # ============================================================================ -# Java(仅提示,不自动安装) +# Java (hint only, no automatic install) # ============================================================================ install_java() { echo "" - echo "🔍 检测到 Java 项目" + echo "🔍 Detected Java project" if [ -f "pom.xml" ]; then - SUMMARY_PARTS+=("Java (Maven): ℹ️ 手动: mvn install") + SUMMARY_PARTS+=("Java (Maven): ℹ️ Manual: mvn install") else - SUMMARY_PARTS+=("Java (Gradle): ℹ️ 手动: gradle build") + SUMMARY_PARTS+=("Java (Gradle): ℹ️ Manual: gradle build") fi } # ============================================================================ -# 执行项目初始化 +# Execute project initialization # ============================================================================ if [ ${#DETECTED_TYPES[@]} -gt 0 ]; then if [ ${#DETECTED_TYPES[@]} -gt 1 ]; then echo "" - echo "🔍 检测到混合项目类型: ${DETECTED_TYPES[*]}" - echo " 将分别为每种类型处理。" + echo "🔍 Detected hybrid project types: ${DETECTED_TYPES[*]}" + echo " Will process each type separately." fi for t in "${DETECTED_TYPES[@]}"; do @@ -634,26 +634,26 @@ if [ ${#DETECTED_TYPES[@]} -gt 0 ]; then if [ ${#DETECTED_TYPES[@]} -gt 1 ]; then echo "" - echo "💡 多语言项目建议安装顺序:" - echo " 1. 先处理 Rust / Java(可能包含构建工具)" - echo " 2. 再处理 Node.js / Python / Go" + echo "💡 Multi-language project recommended install order:" + echo " 1. Process Rust / Java first (may include build tools)" + echo " 2. Then Node.js / Python / Go" fi else echo "" - echo "💡 未检测到已知项目类型,请手动初始化开发环境。" - SUMMARY_PARTS+=("项目类型: 未识别") + echo "💡 No known project types detected, please initialize development environment manually." + SUMMARY_PARTS+=("Project type: Unrecognized") fi # ============================================================================ -# 最终汇总 +# Final summary # ============================================================================ echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "📋 汇总" +echo "📋 Summary" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "📂 目录: ${TARGET_DIR}" -echo "🌿 分支: ${BRANCH}" +echo "📂 Directory: ${TARGET_DIR}" +echo "🌿 Branch: ${BRANCH}" if [ ${#SUMMARY_PARTS[@]} -gt 0 ]; then for part in "${SUMMARY_PARTS[@]}"; do @@ -663,39 +663,39 @@ fi if $DEPS_INSTALLED; then echo "" - echo "🎉 开发环境已就绪!依赖已安装。" + echo "🎉 Development environment ready! Dependencies installed." else echo "" - echo "⚠️ 依赖尚未安装,请进入目录后手动安装。" + echo "⚠️ Dependencies not yet installed, please enter the directory and install manually." fi echo "" -echo "💡 下一步:" +echo "💡 Next steps:" echo " cd ${TARGET_DIR}" -# 根据实际锁文件给出精确提示 +# Provide precise hints based on lock files if [ -f "package.json" ] && ! $DEPS_INSTALLED; then if [ -f "pnpm-lock.yaml" ]; then - echo " pnpm install # 安装 Node.js 依赖" + echo " pnpm install # Install Node.js dependencies" elif [ -f "yarn.lock" ]; then - echo " yarn install # 安装 Node.js 依赖" + echo " yarn install # Install Node.js dependencies" else - echo " npm install # 安装 Node.js 依赖" + echo " npm install # Install Node.js dependencies" fi - echo " npm test # 运行测试" + echo " npm test # Run tests" elif [ -f "Cargo.toml" ] && ! $DEPS_INSTALLED; then - echo " cargo fetch # 下载依赖" - echo " cargo build # 构建项目" - echo " cargo test # 运行测试" + echo " cargo fetch # Download dependencies" + echo " cargo build # Build project" + echo " cargo test # Run tests" elif ! $DEPS_INSTALLED; then if [ -f "uv.lock" ]; then - echo " uv sync # 安装 Python 依赖" + echo " uv sync # Install Python dependencies" elif [ -f "poetry.lock" ]; then - echo " poetry install # 安装 Python 依赖" + echo " poetry install # Install Python dependencies" elif [ -f "pdm.lock" ]; then - echo " pdm install # 安装 Python 依赖" + echo " pdm install # Install Python dependencies" elif [ -f "pyproject.toml" ]; then echo " .venv/bin/pip install . (Linux/macOS)" echo " .venv/Scripts/pip install . (Windows)" @@ -704,19 +704,19 @@ elif ! $DEPS_INSTALLED; then echo " .venv/Scripts/pip install -r requirements.txt (Windows)" fi if [ -f ".venv/bin/activate" ]; then - echo " source .venv/bin/activate # 激活虚拟环境 (Linux/macOS)" + echo " source .venv/bin/activate # Activate virtual environment (Linux/macOS)" elif [ -f ".venv/Scripts/activate" ]; then - echo " source .venv/Scripts/activate # 激活虚拟环境 (Windows Git Bash)" + echo " source .venv/Scripts/activate # Activate virtual environment (Windows Git Bash)" fi - echo " pytest # 运行测试" + echo " pytest # Run tests" fi if [ -f "go.mod" ]; then - echo " go mod download # 下载 Go 依赖" + echo " go mod download # Download Go dependencies" fi if [ -f "pom.xml" ]; then - echo " mvn install # 构建 Java 项目" + echo " mvn install # Build Java project" elif [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then - echo " gradle build # 构建 Java 项目" + echo " gradle build # Build Java project" fi echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" diff --git a/skills/github-pr-manager/scripts/list_prs.sh b/skills/github-pr-manager/scripts/list_prs.sh index 4db4dd4..1a36ae5 100644 --- a/skills/github-pr-manager/scripts/list_prs.sh +++ b/skills/github-pr-manager/scripts/list_prs.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -# list_prs.sh — 列出 GitHub 仓库开放 PR 并格式化输出 -# 兼容: Git Bash (Windows), WSL2, macOS, Linux -# 用法: ./list_prs.sh [limit] [-a|--all] +# list_prs.sh — List open PRs in a GitHub repository with formatted output +# Compatibility: Git Bash (Windows), WSL2, macOS, Linux +# Usage: ./list_prs.sh [limit] [-a|--all] set -euo pipefail # ============================================================================ -# 参数解析 +# Argument parsing # ============================================================================ PAGINATE=false ARGS=() @@ -14,43 +14,43 @@ ARGS=() for arg in "$@"; do case "$arg" in -a|--all) PAGINATE=true ;; - -h|--help) echo "用法: ./list_prs.sh [limit] [-a|--all]"; echo " -a 翻页获取全部PR"; exit 0 ;; + -h|--help) echo "Usage: ./list_prs.sh [limit] [-a|--all]"; echo " -a Paginate to fetch all PRs"; exit 0 ;; *) ARGS+=("$arg") ;; esac done -REPO="${ARGS[0]:?请提供仓库 (owner/repo)}" +REPO="${ARGS[0]:?Please provide repository (owner/repo)}" LIMIT="${ARGS[1]:-1000}" # ============================================================================ -# 依赖检查 +# Dependency check # ============================================================================ for cmd in gh jq; do if ! command -v "$cmd" &>/dev/null; then - echo "❌ 缺少必要命令: $cmd,请安装后重试。" + echo "❌ Missing required command: $cmd, please install and retry." exit 1 fi done -# 认证检查(仅依赖退出码,语言无关) +# Authentication check (relies only on exit code, language-agnostic) if ! gh auth status &>/dev/null; then - echo "❌ GitHub CLI 未登录,请执行: gh auth login" + echo "❌ GitHub CLI not logged in, run: gh auth login" exit 1 fi -# 仓库格式校验 +# Repository format validation if [[ ! "$REPO" =~ ^[^/]+/[^/]+$ ]]; then - echo "❌ 仓库格式错误,应为 owner/repo(如 facebook/react)" + echo "❌ Invalid repository format, should be owner/repo (e.g. facebook/react)" exit 1 fi # ============================================================================ -# 获取 PR 数据 +# Fetch PR data # ============================================================================ if $PAGINATE; then - # ── 翻页模式:使用 gh api --paginate 获取全部 PR ── - echo "⏳ 正在获取全部开放 PR(大仓库可能较慢)..." + # Pagination mode: use gh api --paginate to fetch all PRs + echo "⏳ Fetching all open PRs (may be slow for large repositories)..." OWNER="${REPO%/*}" REPO_NAME="${REPO#*/}" @@ -58,60 +58,60 @@ if $PAGINATE; then PRS_JSON=$(gh api --paginate \ "repos/${OWNER}/${REPO_NAME}/pulls?state=open&per_page=100" \ --jq '[.[] | {number, title, user: {login: .user.login}, created_at}]' 2>&1) || { - echo "❌ 获取 PR 列表失败" + echo "❌ Failed to fetch PR list" printf '%s\n' "$PRS_JSON" exit 1 } - # 统一字段名以匹配后续 jq 处理 + # Normalize field names to match subsequent jq processing PRS_JSON=$(printf '%s\n' "$PRS_JSON" | jq '[.[] | {number, title, author: {login: .user.login}, createdAt: .created_at}]') else - # ── 标准模式:使用 gh pr list(快速) ── - # LIMIT 范围校验 + # Standard mode: use gh pr list (fast) + # LIMIT range validation if ! [[ "$LIMIT" =~ ^[0-9]+$ ]] || [ "$LIMIT" -lt 1 ] || [ "$LIMIT" -gt 1000 ]; then - echo "❌ LIMIT 应为 1-1000 的整数" + echo "❌ LIMIT must be an integer between 1 and 1000" exit 1 fi PRS_JSON=$(gh pr list --repo "$REPO" --state open \ --json number,title,author,createdAt \ --limit "$LIMIT" 2>&1) || { - echo "❌ 获取 PR 列表失败" + echo "❌ Failed to fetch PR list" printf '%s\n' "$PRS_JSON" exit 1 } fi # ============================================================================ -# 解析计数 +# Parse count # ============================================================================ PR_COUNT=$(printf '%s\n' "$PRS_JSON" | jq 'length') || { - echo "⚠️ 解析 PR 列表失败,原始返回:" + echo "⚠️ Failed to parse PR list, raw output:" printf '%s\n' "$PRS_JSON" | head -n 5 exit 1 } if [ "$PR_COUNT" -eq 0 ]; then - echo "📋 仓库: ${REPO} | 当前没有开放的 PR" + echo "📋 Repository: ${REPO} | No open PRs currently" exit 0 fi # ============================================================================ -# 输出 +# Output # ============================================================================ if $PAGINATE; then - echo "📋 仓库: ${REPO} | 全部开放 PR" + echo "📋 Repository: ${REPO} | All open PRs" else - echo "📋 仓库: ${REPO} | 开放 PR 列表" + echo "📋 Repository: ${REPO} | Open PR list" if [ "$PR_COUNT" -ge "$LIMIT" ]; then - echo " (结果可能被截断,使用 -a 获取全部 PR)" + echo " (Results may be truncated, use -a to fetch all PRs)" fi fi echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -# 格式化输出(| 分隔,标题中 | 替换为 ¦ 避免冲突) +# Formatted output (| separated, replace | with ¦ in titles to avoid conflict) FORMATTED=$(printf '%s\n' "$PRS_JSON" | jq -r '.[] | [ " #\(.number)", (if (.title | length) > 60 then (.title[:60] | gsub("\\|"; "¦")) + "…" else (.title | gsub("\\|"; "¦")) end), @@ -126,4 +126,4 @@ else fi echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "共 ${PR_COUNT} 个开放 PR" +echo "Total: ${PR_COUNT} open PRs" diff --git a/skills/github-pr-manager/scripts/view_pr.sh b/skills/github-pr-manager/scripts/view_pr.sh index 5f24799..5b8cbb3 100644 --- a/skills/github-pr-manager/scripts/view_pr.sh +++ b/skills/github-pr-manager/scripts/view_pr.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -show_help() { echo "用法: ./view_pr.sh [-v] [-d] [-a]"; echo " -v 展开审查/评论 -d 显示diff -a 全部提交"; exit 0; } +show_help() { echo "Usage: ./view_pr.sh [-v] [-d] [-a]"; echo " -v Expand reviews/comments -d Show diff -a All commits"; exit 0; } VERBOSE=false; SHOW_DIFF=false; ALL_COMMITS=false REPO_ARG=""; PR_ARG="" for a in "$@"; do @@ -11,26 +11,26 @@ for a in "$@"; do -a|--all) ALL_COMMITS=true ;; *) [ -z "$REPO_ARG" ] && { REPO_ARG="$a"; continue; } [ -z "$PR_ARG" ] && { PR_ARG="$a"; continue; } - { echo "❌ 未知参数: $a"; exit 1; } ;; + { echo "❌ Unknown argument: $a"; exit 1; } ;; esac done REPO="${REPO_ARG:?owner/repo or .}"; PR="${PR_ARG:?PR number}" -[[ "$PR" =~ ^[0-9]+$ ]] || { echo "❌ PR 编号必须为数字"; exit 1; } +[[ "$PR" =~ ^[0-9]+$ ]] || { echo "❌ PR number must be numeric"; exit 1; } if [ "$REPO" = "." ]; then - git remote get-url origin &>/dev/null || { echo "❌ 未找到 origin"; exit 1; } + git remote get-url origin &>/dev/null || { echo "❌ origin not found"; exit 1; } REPO=$(git remote get-url origin 2>/dev/null | sed -E 's|\.git$||; s|.*[:/]([^/]+/[^/]+)$|\1|') - [ -z "$REPO" ] && { echo "❌ 无法推断仓库"; exit 1; } + [ -z "$REPO" ] && { echo "❌ Unable to infer repository"; exit 1; } echo "📁 $REPO" fi -# 验证仓库格式 owner/repo(防范参数注入) -[[ "$REPO" =~ ^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$ ]] || { echo "❌ 仓库格式必须为 owner/repo"; exit 1; } -command -v gh &>/dev/null || { echo "❌ 需要 gh"; exit 1; } -command -v jq &>/dev/null || { echo "❌ 需要 jq"; exit 1; } -gh auth status &>/dev/null || { echo "❌ 请 gh auth login"; exit 1; } +# Validate repository format owner/repo (guard against argument injection) +[[ "$REPO" =~ ^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$ ]] || { echo "❌ Repository format must be owner/repo"; exit 1; } +command -v gh &>/dev/null || { echo "❌ gh is required"; exit 1; } +command -v jq &>/dev/null || { echo "❌ jq is required"; exit 1; } +gh auth status &>/dev/null || { echo "❌ Run gh auth login first"; exit 1; } tmp=$(mktemp); trap 'rm -f "$tmp"' EXIT DATA=$(gh pr view "$PR" --repo "$REPO" --json title,body,author,state,mergeable,changedFiles,url,headRefName,baseRefName,createdAt,labels,reviews,comments,commits 2>"$tmp") || true if [ -z "$DATA" ]; then - echo "❌ 无法获取 PR $PR" + echo "❌ Unable to fetch PR $PR" [ -s "$tmp" ] && sed 's/^/ /' "$tmp" exit 1 fi @@ -38,65 +38,65 @@ H="━━━━━━━━━━━━━━━━━━━━━━━━━ section() { echo ""; echo "$H"; echo "$1"; echo "$H"; } echo ""; echo "$H"; echo "📌 PR #$PR ($REPO)"; echo "$H" pf() { jq -r "$1" <<< "$DATA"; } -section "📋 基本信息" -pf '"标题: " + (.title // "N/A")' -pf '"作者: @" + (.author.login // "unknown")' -pf '"状态: " + (.state // "?") + " | 合并: " + (.mergeable // "?")' -pf '"分支: " + (.headRefName // "?") + " → " + (.baseRefName // "?")' -pf '"创建: " + (.createdAt[:10] // "?")' -pf '"标签: " + (if (.labels|length)>0 then [.labels[].name]|join(", ") else "无" end)' -pf '"文件: " + (.changedFiles|tostring) + " 个"' -pf '"链接: " + (.url // "")' -section "📝 PR 描述" +section "📋 Basic info" +pf '"Title: " + (.title // "N/A")' +pf '"Author: @" + (.author.login // "unknown")' +pf '"State: " + (.state // "?") + " | Mergeable: " + (.mergeable // "?")' +pf '"Branch: " + (.headRefName // "?") + " -> " + (.baseRefName // "?")' +pf '"Created: " + (.createdAt[:10] // "?")' +pf '"Labels: " + (if (.labels|length)>0 then [.labels[].name]|join(", ") else "(none)" end)' +pf '"Files: " + (.changedFiles|tostring) + " files"' +pf '"URL: " + (.url // "")' +section "📝 Description" BODY=$(jq -r '.body // ""' <<< "$DATA") if [ -n "$BODY" ]; then L=${#BODY} if [ "$L" -gt 600 ]; then printf '%s\n' "${BODY:0:600}"; echo ""; echo "... ($L chars)"; else printf '%s\n' "$BODY"; fi -else echo " (无)"; fi +else echo " (none)"; fi section "📊 Diff" if $SHOW_DIFF; then if D=$(gh pr diff "$PR" --repo "$REPO" 2>"$tmp"); then if [ -n "$D" ]; then printf '%s\n' "$D" | head -n 200 N=$(printf '%s\n' "$D" | wc -l | tr -d ' ') - [ "$N" -gt 200 ] && echo "" && echo "... (共 $N 行,仅显示前 200)" - else echo " (无变更)"; fi + [ "$N" -gt 200 ] && echo "" && echo "... ($N lines total, showing first 200)" + else echo " (no changes)"; fi else - echo " ⚠️ 获取失败:"; [ -s "$tmp" ] && sed 's/^/ /' "$tmp" + echo " ⚠️ Fetch failed:"; [ -s "$tmp" ] && sed 's/^/ /' "$tmp" fi else - echo " (使用 -d 查看代码变更)" + echo " (Use -d to view code changes)" fi -section "💬 审查" +section "💬 Reviews" R=$(jq '(.reviews // []) | length' <<< "$DATA") if [ "$R" -gt 0 ]; then - echo "共 $R 条 (使用 -v 查看完整内容):" + echo "$R total (use -v to see full content):" if $VERBOSE; then - jq -r '.reviews[]|"\n @"+(.author.login//"?")+" ["+.state+"] ("+.submittedAt[:10]+")\n "+(.body//"(无)")' <<< "$DATA" + jq -r '.reviews[]|"\n @"+(.author.login//"?")+" ["+.state+"] ("+.submittedAt[:10]+")\n "+(.body//"(none)")' <<< "$DATA" else - jq -r '.reviews[]|" @"+(.author.login//"unknown")+" ["+.state+"] ("+.submittedAt[:10]+"): " + (if (.body//"")=="" then "(无)" else "\""+.body[:200]+(if (.body|length)>200 then "…" else "" end)+"\"" end)' <<< "$DATA" + jq -r '.reviews[]|" @"+(.author.login//"unknown")+" ["+.state+"] ("+.submittedAt[:10]+"): " + (if (.body//"")=="" then "(none)" else "\""+.body[:200]+(if (.body|length)>200 then "…" else "" end)+"\"" end)' <<< "$DATA" fi -else echo " (无)"; fi -section "💬 评论" +else echo " (none)"; fi +section "💬 Comments" C=$(jq '(.comments // []) | length' <<< "$DATA") if [ "$C" -gt 0 ]; then - echo "共 $C 条 (使用 -v 查看完整内容):" + echo "$C total (use -v to see full content):" if $VERBOSE; then - jq -r '.comments[]|"\n @"+(.author.login//"?")+" ("+.createdAt[:10]+")\n "+(.body//"(无)")' <<< "$DATA" + jq -r '.comments[]|"\n @"+(.author.login//"?")+" ("+.createdAt[:10]+")\n "+(.body//"(none)")' <<< "$DATA" else - jq -r '.comments[]|" @"+(.author.login//"unknown")+" ("+.createdAt[:10]+"): " + (if (.body//"")=="" then "(无)" else "\""+.body[:200]+(if (.body|length)>200 then "…" else "" end)+"\"" end)' <<< "$DATA" + jq -r '.comments[]|" @"+(.author.login//"unknown")+" ("+.createdAt[:10]+"): " + (if (.body//"")=="" then "(none)" else "\""+.body[:200]+(if (.body|length)>200 then "…" else "" end)+"\"" end)' <<< "$DATA" fi -else echo " (无)"; fi -section "📜 提交" +else echo " (none)"; fi +section "📜 Commits" M=$(jq '(.commits // []) | length' <<< "$DATA") if [ "$M" -gt 0 ]; then if $ALL_COMMITS; then - echo "共 $M 次 (按时间倒序):" + echo "$M total (reverse chronological):" jq -r '.commits|sort_by(.committedDate // .authoredDate // "1970")|reverse|.[]|" "+.oid[:7]+" "+(.author.name//.author.login//"?")+" "+.messageHeadline' <<< "$DATA" else LIMIT=$M; [ "$LIMIT" -gt 10 ] && LIMIT=10 - echo "共 $M 次 (显示最近 $LIMIT,-a 查看全部):" + echo "$M total (showing last $LIMIT, -a for all):" jq -r --arg L "$LIMIT" '.commits|sort_by(.committedDate // .authoredDate // "1970")|reverse|.[0:($L|tonumber)]|.[]|" "+.oid[:7]+" "+(.author.name//.author.login//"?")+" "+.messageHeadline' <<< "$DATA" fi -else echo " (无)"; fi +else echo " (none)"; fi echo ""; echo "$H" diff --git a/skills/github-pr-reviewer/references/comment-templates.cn.md b/skills/github-pr-reviewer/references/comment-templates.cn.md new file mode 100644 index 0000000..054afd7 --- /dev/null +++ b/skills/github-pr-reviewer/references/comment-templates.cn.md @@ -0,0 +1,50 @@ +# 审查评论模板 + +## 评论正文结构 + +``` +**🔒 [安全] 密码验证缺少空值检查** + +当前代码在 `password` 为 `null` 或 `undefined` 时会直接传递给 `hashPassword()`, +可能导致运行时异常或不安全的哈希结果。 + +**建议修复:** +```typescript +if (!password) { + throw new BadRequestError('密码不能为空'); +} +const hashed = await hashPassword(password); +``` +``` + +1. **粗体标题**:`**[图标] [类别中文名] 简短问题描述**` +2. **问题描述**:1-3 句话说明当前代码的问题和潜在影响 +3. **建议修复**(可选):带代码示例的具体修复方案 + +## 类别图标映射 + +| 类别 | 图标 | 中文名 | +|------|------|--------| +| bug | 🐛 | Bug | +| security | 🔒 | 安全 | +| performance | ⚡ | 性能 | +| design | 🏗️ | 设计 | +| best-practice | 📐 | 最佳实践 | +| nitpick | 💭 | 建议 | +| praise | 👍 | 表扬 | + +## 严重程度说明 + +| 严重程度 | 说明 | 是否阻塞合并 | +|---------|------|-------------| +| critical | 必须修复的严重缺陷或安全漏洞 | 是 | +| warning | 可能导致问题的代码 | 建议修复 | +| suggestion | 改进建议 | 否 | +| praise | 写得好的代码 | 否 | + +## 添加策略 + +- 按严重程度排序:critical → warning → suggestion → praise +- 每条之间适当间隔,避免触发 GitHub API rate limit +- 添加失败时记录条目并继续下一条 +- 已有评论的位置跳过重复 diff --git a/skills/github-pr-reviewer/references/comment-templates.md b/skills/github-pr-reviewer/references/comment-templates.md index 054afd7..4a07776 100644 --- a/skills/github-pr-reviewer/references/comment-templates.md +++ b/skills/github-pr-reviewer/references/comment-templates.md @@ -1,50 +1,50 @@ -# 审查评论模板 +# Review Comment Templates -## 评论正文结构 +## Comment Body Structure ``` -**🔒 [安全] 密码验证缺少空值检查** +**🔒 [Security] Password validation missing null check** -当前代码在 `password` 为 `null` 或 `undefined` 时会直接传递给 `hashPassword()`, -可能导致运行时异常或不安全的哈希结果。 +The current code passes `password` directly to `hashPassword()` when it is `null` or `undefined`, +which may cause a runtime exception or produce insecure hash results. -**建议修复:** +**Suggested Fix:** ```typescript if (!password) { - throw new BadRequestError('密码不能为空'); + throw new BadRequestError('Password cannot be empty'); } const hashed = await hashPassword(password); ``` ``` -1. **粗体标题**:`**[图标] [类别中文名] 简短问题描述**` -2. **问题描述**:1-3 句话说明当前代码的问题和潜在影响 -3. **建议修复**(可选):带代码示例的具体修复方案 +1. **Bold title**: `**[Icon] [Category] Short problem description**` +2. **Problem description**: 1-3 sentences explaining the current code issue and its potential impact +3. **Suggested fix** (optional): Specific fix with code example -## 类别图标映射 +## Category Icon Mapping -| 类别 | 图标 | 中文名 | -|------|------|--------| +| Category | Icon | Name | +|----------|------|------| | bug | 🐛 | Bug | -| security | 🔒 | 安全 | -| performance | ⚡ | 性能 | -| design | 🏗️ | 设计 | -| best-practice | 📐 | 最佳实践 | -| nitpick | 💭 | 建议 | -| praise | 👍 | 表扬 | - -## 严重程度说明 - -| 严重程度 | 说明 | 是否阻塞合并 | -|---------|------|-------------| -| critical | 必须修复的严重缺陷或安全漏洞 | 是 | -| warning | 可能导致问题的代码 | 建议修复 | -| suggestion | 改进建议 | 否 | -| praise | 写得好的代码 | 否 | - -## 添加策略 - -- 按严重程度排序:critical → warning → suggestion → praise -- 每条之间适当间隔,避免触发 GitHub API rate limit -- 添加失败时记录条目并继续下一条 -- 已有评论的位置跳过重复 +| security | 🔒 | Security | +| performance | ⚡ | Performance | +| design | 🏗️ | Design | +| best-practice | 📐 | Best Practice | +| nitpick | 💭 | Suggestion | +| praise | 👍 | Praise | + +## Severity Levels + +| Severity | Description | Blocks Merge | +|----------|-------------|-------------| +| critical | Critical defect or security vulnerability that must be fixed | Yes | +| warning | Code that may cause issues | Recommended to fix | +| suggestion | Improvement suggestion | No | +| praise | Well-written code | No | + +## Addition Strategy + +- Sort by severity: critical → warning → suggestion → praise +- Space out comments appropriately to avoid triggering GitHub API rate limits +- Log the entry on failure and continue with the next one +- Skip positions where a comment already exists to avoid duplicates diff --git a/skills/github-pr-reviewer/references/diff-line-mapping.cn.md b/skills/github-pr-reviewer/references/diff-line-mapping.cn.md new file mode 100644 index 0000000..b272a53 --- /dev/null +++ b/skills/github-pr-reviewer/references/diff-line-mapping.cn.md @@ -0,0 +1,141 @@ +# Diff 行号映射指南 + +## 为什么行号很重要 + +`add_comment_to_pending_review` 的 `line` 参数使用 **PR diff 中的行号**,这是最容易出错的地方。如果使用源文件行号,GitHub API 会返回错误: + +``` +The line number doesn't exist in the pull request diff +``` + +## Unified Diff 格式 + +GitHub PR diff 使用 unified diff 格式: + +```diff +diff --git a/src/auth/login.ts b/src/auth/login.ts +index abc123..def456 100644 +--- a/src/auth/login.ts ++++ b/src/auth/login.ts +@@ -10,7 +10,9 @@ import { hashPassword } from '../crypto'; + + export async function login(username: string, password: string) { +- const user = await db.findUser(username); +- return user; ++ if (!username || !password) { ++ throw new Error('Missing credentials'); ++ } ++ const user = await db.findUser(username); ++ return { id: user.id, token: generateToken(user) }; + } +``` + +### 关键组成 + +| 部分 | 含义 | +|------|------| +| `diff --git a/... b/...` | 文件标识 | +| `--- a/path` / `+++ b/path` | 旧/新文件路径 | +| `@@ -10,7 +10,9 @@` | **Hunk 头部** — `-<起始>,<行数> +<起始>,<行数> @@ <函数上下文>` | +| `-` 开头的行 | 被删除的代码(左侧/旧版本) | +| `+` 开头的行 | 新增的代码(右侧/新版本) | +| (空格)开头的行 | 上下文行(未变更,用于定位) | + +### Hunk 头部解读 + +`@@ -10,7 +10,9 @@ import { hashPassword } from '../crypto';` + +- `-10,7`:旧文件中从第 10 行开始,显示 7 行 +- `+10,9`:新文件中从第 10 行开始,显示 9 行 +- 末尾是函数/类名上下文 + +## Diff 行号 vs 源文件行号 + +**关键区别:** `add_comment_to_pending_review` 需要的是 **diff 中该行的位置**,不是源文件行号。 + +### 计算 diff 行号 + +从 GitHub API 返回的 diff 文本中,行号从 diff 文本的第 1 行开始计数。 + +``` +第 1 行: diff --git a/src/auth/login.ts b/src/auth/login.ts +第 2 行: index abc123..def456 100644 +第 3 行: --- a/src/auth/login.ts +第 4 行: +++ b/src/auth/login.ts +第 5 行: @@ -10,7 +10,9 @@ import { hashPassword } from '../crypto'; +第 6 行: +第 7 行: export async function login(username: string, password: string) { +第 8 行: - const user = await db.findUser(username); +第 9 行: - return user; +第 10 行: + if (!username || !password) { +第 11 行: + throw new Error('Missing credentials'); +... +``` + +如果要对新增的空值检查(第 10 行)发表评论: +- `line`: 10(diff 中的行号) +- `side`: "RIGHT" +- `path`: "src/auth/login.ts" + +### 不是用 `@@` 中的源文件行号! + +❌ **错误**:「第 10 行有新增代码」→ 使用 `line: 10` — 但这可能是正确的… + +关键陷阱:`@@` 中 `+10,9` 表示**新文件中**这些行从源文件第 10 行开始,**但 diff 行号完全不同**。你要用的是 diff 行号。 + +## 多行评论(范围评论) + +要评论一个代码段,使用 `startLine` + `startSide` + `line` + `side`: + +``` +该 diff 中第 10-14 行是新增的 try-catch 块: +add_comment_to_pending_review( + path="src/auth/login.ts", + body="这个 try-catch 块...", + line=14, # 范围的最后一行 + side="RIGHT", + startLine=10, # 范围的第一行 + startSide="RIGHT", + subjectType="LINE" +) +``` + +## 文件级评论(降级方案) + +当无法确定 diff 行号时,降级为文件级评论: + +``` +add_comment_to_pending_review( + path="src/auth/login.ts", + body="在 `login` 函数中,建议增加输入验证...", + subjectType="FILE" # 不指定行号,评论附加到整个文件 +) +``` + +文件级评论不需要 `line`、`side`、`startLine` 参数。 + +## 使用 parse_diff_lines.sh 脚本 + +脚本 `scripts/parse_diff_lines.sh` 可以帮助从 diff 中提取文件路径和行号: + +```bash +# 将 diff 内容传入脚本 +cat pr_diff.txt | bash scripts/parse_diff_lines.sh + +# 输出格式: +# file:src/auth/login.ts line:10 side:RIGHT +# file:src/auth/login.ts line:11 side:RIGHT +# file:src/auth/login.ts line:14 side:RIGHT +``` + +脚本依赖:`bash`(最低 4.0)、`grep`、`sed`(Windows Git Bash 兼容)。 + +## 常见错误速查 + +| 错误 | 症状 | 修复 | +|------|------|------| +| 使用源文件行号 | `line doesn't exist in diff` | 用 diff 行号(从 diff 文本第 1 行开始数) | +| 使用 `@@ +c,d` 中的 `c` 作为行号 | 评论位置偏移 | 从 diff 第 1 行重新计算 | +| 未指定 `side` | 评论不在预期位置 | 新增代码用 RIGHT,删除代码用 LEFT | +| `side` 与代码类型不匹配 | 评论不显示 | 新增用 RIGHT,删除用 LEFT,上下文随意 | +| 多行范围未用 startLine | 评论显示在单行 | 添加 startLine + startSide | diff --git a/skills/github-pr-reviewer/references/diff-line-mapping.md b/skills/github-pr-reviewer/references/diff-line-mapping.md index b272a53..fe58131 100644 --- a/skills/github-pr-reviewer/references/diff-line-mapping.md +++ b/skills/github-pr-reviewer/references/diff-line-mapping.md @@ -1,16 +1,16 @@ -# Diff 行号映射指南 +# Diff Line Number Mapping Guide -## 为什么行号很重要 +## Why Line Numbers Matter -`add_comment_to_pending_review` 的 `line` 参数使用 **PR diff 中的行号**,这是最容易出错的地方。如果使用源文件行号,GitHub API 会返回错误: +The `line` parameter of `add_comment_to_pending_review` uses the **line number from the PR diff**, which is the most error-prone part. If you use source file line numbers instead, the GitHub API returns an error: ``` The line number doesn't exist in the pull request diff ``` -## Unified Diff 格式 +## Unified Diff Format -GitHub PR diff 使用 unified diff 格式: +GitHub PR diffs use the unified diff format: ```diff diff --git a/src/auth/login.ts b/src/auth/login.ts @@ -30,112 +30,112 @@ index abc123..def456 100644 } ``` -### 关键组成 +### Key Components -| 部分 | 含义 | -|------|------| -| `diff --git a/... b/...` | 文件标识 | -| `--- a/path` / `+++ b/path` | 旧/新文件路径 | -| `@@ -10,7 +10,9 @@` | **Hunk 头部** — `-<起始>,<行数> +<起始>,<行数> @@ <函数上下文>` | -| `-` 开头的行 | 被删除的代码(左侧/旧版本) | -| `+` 开头的行 | 新增的代码(右侧/新版本) | -| (空格)开头的行 | 上下文行(未变更,用于定位) | +| Part | Meaning | +|------|---------| +| `diff --git a/... b/...` | File identifier | +| `--- a/path` / `+++ b/path` | Old / new file path | +| `@@ -10,7 +10,9 @@` | **Hunk header** — `-, +, @@ ` | +| Lines starting with `-` | Deleted code (left / old version) | +| Lines starting with `+` | Added code (right / new version) | +| Lines starting with (space) | Context lines (unchanged, for orientation) | -### Hunk 头部解读 +### Hunk Header Breakdown `@@ -10,7 +10,9 @@ import { hashPassword } from '../crypto';` -- `-10,7`:旧文件中从第 10 行开始,显示 7 行 -- `+10,9`:新文件中从第 10 行开始,显示 9 行 -- 末尾是函数/类名上下文 +- `-10,7`: In the old file, starts at line 10, shows 7 lines +- `+10,9`: In the new file, starts at line 10, shows 9 lines +- The trailing part is the function/class name context -## Diff 行号 vs 源文件行号 +## Diff Line Numbers vs Source File Line Numbers -**关键区别:** `add_comment_to_pending_review` 需要的是 **diff 中该行的位置**,不是源文件行号。 +**Key difference:** `add_comment_to_pending_review` requires the **position within the diff**, not the source file line number. -### 计算 diff 行号 +### Calculating Diff Line Numbers -从 GitHub API 返回的 diff 文本中,行号从 diff 文本的第 1 行开始计数。 +In the diff text returned by the GitHub API, line numbers start counting from line 1 of the diff text itself. ``` -第 1 行: diff --git a/src/auth/login.ts b/src/auth/login.ts -第 2 行: index abc123..def456 100644 -第 3 行: --- a/src/auth/login.ts -第 4 行: +++ b/src/auth/login.ts -第 5 行: @@ -10,7 +10,9 @@ import { hashPassword } from '../crypto'; -第 6 行: -第 7 行: export async function login(username: string, password: string) { -第 8 行: - const user = await db.findUser(username); -第 9 行: - return user; -第 10 行: + if (!username || !password) { -第 11 行: + throw new Error('Missing credentials'); +Line 1: diff --git a/src/auth/login.ts b/src/auth/login.ts +Line 2: index abc123..def456 100644 +Line 3: --- a/src/auth/login.ts +Line 4: +++ b/src/auth/login.ts +Line 5: @@ -10,7 +10,9 @@ import { hashPassword } from '../crypto'; +Line 6: +Line 7: export async function login(username: string, password: string) { +Line 8: - const user = await db.findUser(username); +Line 9: - return user; +Line 10: + if (!username || !password) { +Line 11: + throw new Error('Missing credentials'); ... ``` -如果要对新增的空值检查(第 10 行)发表评论: -- `line`: 10(diff 中的行号) +To comment on the added null check (line 10): +- `line`: 10 (line number in the diff) - `side`: "RIGHT" - `path`: "src/auth/login.ts" -### 不是用 `@@` 中的源文件行号! +### Do NOT Use the Source Line Number from `@@`! -❌ **错误**:「第 10 行有新增代码」→ 使用 `line: 10` — 但这可能是正确的… +Incorrect: "There's added code at line 10 → use `line: 10`" — but this could coincidentally be correct... -关键陷阱:`@@` 中 `+10,9` 表示**新文件中**这些行从源文件第 10 行开始,**但 diff 行号完全不同**。你要用的是 diff 行号。 +Key pitfall: `+10,9` in the `@@` header means **in the new file** these lines start at source file line 10, **but the diff line number is completely different**. You must use the diff line number. -## 多行评论(范围评论) +## Multi-Line Comments (Range Comments) -要评论一个代码段,使用 `startLine` + `startSide` + `line` + `side`: +To comment on a range of code, use `startLine` + `startSide` + `line` + `side`: ``` -该 diff 中第 10-14 行是新增的 try-catch 块: +Lines 10-14 in this diff are the newly added try-catch block: add_comment_to_pending_review( path="src/auth/login.ts", - body="这个 try-catch 块...", - line=14, # 范围的最后一行 + body="This try-catch block...", + line=14, # Last line of the range side="RIGHT", - startLine=10, # 范围的第一行 + startLine=10, # First line of the range startSide="RIGHT", subjectType="LINE" ) ``` -## 文件级评论(降级方案) +## File-Level Comments (Fallback) -当无法确定 diff 行号时,降级为文件级评论: +When the diff line number cannot be determined, fall back to a file-level comment: ``` add_comment_to_pending_review( path="src/auth/login.ts", - body="在 `login` 函数中,建议增加输入验证...", - subjectType="FILE" # 不指定行号,评论附加到整个文件 + body="In the `login` function, consider adding input validation...", + subjectType="FILE" # No line number specified; comment attaches to the entire file ) ``` -文件级评论不需要 `line`、`side`、`startLine` 参数。 +File-level comments do not require the `line`, `side`, or `startLine` parameters. -## 使用 parse_diff_lines.sh 脚本 +## Using the parse_diff_lines.sh Script -脚本 `scripts/parse_diff_lines.sh` 可以帮助从 diff 中提取文件路径和行号: +The script `scripts/parse_diff_lines.sh` helps extract file paths and line numbers from a diff: ```bash -# 将 diff 内容传入脚本 +# Pipe diff content into the script cat pr_diff.txt | bash scripts/parse_diff_lines.sh -# 输出格式: +# Output format: # file:src/auth/login.ts line:10 side:RIGHT # file:src/auth/login.ts line:11 side:RIGHT # file:src/auth/login.ts line:14 side:RIGHT ``` -脚本依赖:`bash`(最低 4.0)、`grep`、`sed`(Windows Git Bash 兼容)。 +Script dependencies: `bash` (minimum 4.0), `grep`, `sed` (Windows Git Bash compatible). -## 常见错误速查 +## Common Errors Quick Reference -| 错误 | 症状 | 修复 | -|------|------|------| -| 使用源文件行号 | `line doesn't exist in diff` | 用 diff 行号(从 diff 文本第 1 行开始数) | -| 使用 `@@ +c,d` 中的 `c` 作为行号 | 评论位置偏移 | 从 diff 第 1 行重新计算 | -| 未指定 `side` | 评论不在预期位置 | 新增代码用 RIGHT,删除代码用 LEFT | -| `side` 与代码类型不匹配 | 评论不显示 | 新增用 RIGHT,删除用 LEFT,上下文随意 | -| 多行范围未用 startLine | 评论显示在单行 | 添加 startLine + startSide | +| Error | Symptom | Fix | +|-------|---------|-----| +| Using source file line numbers | `line doesn't exist in diff` | Use diff line numbers (count from line 1 of the diff text) | +| Using the `c` value from `@@ +c,d` as the line number | Comment position is off | Re-count from diff line 1 | +| Not specifying `side` | Comment not in the expected location | Use RIGHT for added code, LEFT for deleted code | +| `side` does not match code type | Comment does not appear | Use RIGHT for additions, LEFT for deletions, either for context | +| Multi-line range without startLine | Comment appears on a single line | Add startLine + startSide | diff --git a/skills/github-pr-reviewer/references/review-checklist.cn.md b/skills/github-pr-reviewer/references/review-checklist.cn.md new file mode 100644 index 0000000..af6ea85 --- /dev/null +++ b/skills/github-pr-reviewer/references/review-checklist.cn.md @@ -0,0 +1,151 @@ +# 代码审查检查清单 + +本文件定义 PR 审查时的检查项目,按严重程度(P0-P5)分层。审查时按优先级逐项检查 diff 中的代码变更。 + +--- + +## P0 — 正确性缺陷(始终审查) + +这些是最严重的问题,发现后必须在 inline 评论中标记为 `severity: critical`。 + +### 逻辑错误 + +- [ ] **条件判断反转** — `if` / `while` 条件与意图相反 +- [ ] **运算符错误** — `>` 和 `>=`、`&&` 和 `||` 混淆 +- [ ] **循环边界错误** — 起始/结束条件导致多循环或少循环一次(off-by-one) +- [ ] **返回值错误** — 函数返回了错误的值或类型 +- [ ] **早期返回遗漏** — 在应该提前返回的边界情况下继续执行 + +### 空值与边界 + +- [ ] **空指针/undefined 访问** — 对可能为 null/undefined 的值调用方法或属性 +- [ ] **数组越界** — 索引可能超出数组长度 +- [ ] **除零** — 除法运算分母可能为零 +- [ ] **空集合处理** — 未处理空数组/空字符串/空 Map 的情况 +- [ ] **正则表达式匹配失败** — `.match()` 返回 null 时直接访问结果 + +### 类型与转换 + +- [ ] **类型强制转换错误** — `==` 和 `===` 混淆、隐式转换导致意外行为 +- [ ] **精度丢失** — 浮点数比较/运算中的精度问题(尤其是金额计算) +- [ ] **整数溢出** — 大数运算未考虑溢出 +- [ ] **日期/时区错误** — 未指定时区的时间解析、日期比较 + +### 并发与状态 + +- [ ] **竞态条件** — 异步操作之间缺少同步 +- [ ] **状态不一致** — 乐观更新失败后未回滚 +- [ ] **死锁** — 锁的获取顺序可能导致死锁 + +--- + +## P1 — 安全问题(始终审查) + +发现后标记为 `severity: critical` 或 `severity: warning`。 + +### 注入防护 + +- [ ] **SQL 注入** — 使用字符串拼接构建 SQL 查询(应使用参数化查询或 ORM) +- [ ] **NoSQL 注入** — 用户输入直接传入 MongoDB/Redis 等查询 +- [ ] **命令注入** — `exec()` / `spawn()` / `subprocess` 中使用未过滤的用户输入 +- [ ] **XSS** — 用户输入直接插入 HTML(应使用转义或安全的 DOM API) +- [ ] **路径遍历** — 文件路径中包含未过滤的 `../` + +### 认证与授权 + +- [ ] **认证绕过** — 敏感端点缺少认证中间件 +- [ ] **权限缺失** — 操作未检查用户是否有权限执行 +- [ ] **JWT 验证不完整** — 未验证签名、过期时间、签发者 +- [ ] **会话固定** — 登录后未重新生成会话 ID + +### 敏感数据 + +- [ ] **密钥/Token 硬编码** — API key、密码、私钥写在代码中 +- [ ] **敏感信息日志泄露** — `console.log` / `log.info` 打印密码、token、用户数据 +- [ ] **不安全传输** — 敏感数据通过 HTTP 明文传输 +- [ ] **错误信息泄露** — 错误响应中暴露数据库结构、堆栈跟踪 + +### 加密 + +- [ ] **弱加密算法** — 使用 MD5、SHA1 作为安全哈希 +- [ ] **不安全随机数** — 使用 `Math.random()` 生成 token/密码 +- [ ] **缺少加密** — 密码存储未使用 bcrypt/argon2 等哈希 + +--- + +## P2 — 性能问题(始终审查) + +发现后标记为 `severity: warning`。 + +### 数据库与 I/O + +- [ ] **N+1 查询** — 循环中逐条查询数据库(应使用 JOIN 或批量查询) +- [ ] **缺少索引** — 新增的 WHERE/ORDER BY 列可能缺少索引 +- [ ] **全表扫描** — 查询条件无法使用索引 +- [ ] **大事务** — 事务中包含耗时操作 + +### 网络与渲染 + +- [ ] **不必要的数据传输** — API 返回了大量前端不需要的字段 +- [ ] **重复请求** — 相同数据的多次 API 调用(应使用缓存或去重) +- [ ] **不必要的重渲染** — React/Vue 组件在 props 未变化时重渲染 +- [ ] **大文件未分页** — 列表接口一次性返回所有数据 + +### 内存 + +- [ ] **内存泄漏** — 事件监听未移除、定时器未清除、闭包持有大对象引用 +- [ ] **大对象复制** — 对大数组/对象进行不必要的深拷贝 +- [ ] **不必要的数据保持** — 一次性计算结果被长期缓存 + +### 算法 + +- [ ] **O(n²) 或更高的嵌套循环** — 对大数据集的嵌套迭代 +- [ ] **不必要的排序** — 不需要排序时调用了 sort + +--- + +## P3 — 设计问题(仅 thorough 模式) + +标记为 `severity: suggestion`。 + +- [ ] **单一职责违反** — 一个函数/类做了多件不相关的事情 +- [ ] **过度耦合** — 模块间通过具体类型而非接口依赖 +- [ ] **循环依赖** — 模块 A 依赖 B,B 依赖 A +- [ ] **上帝类/上帝函数** — 一个类/函数承担了过多职责 +- [ ] **重复代码** — 相同的逻辑出现在多个地方(超过 3 处) +- [ ] **魔法数字** — 未命名的硬编码数值 + +--- + +## P4 — 最佳实践(仅 thorough 模式) + +标记为 `severity: suggestion`。 + +- [ ] **命名不清晰** — 变量/函数名未能说明其用途 +- [ ] **缺少错误处理** — try-catch 缺失或 catch 块为空 +- [ ] **缺少文档** — 公共 API 缺少 JSDoc/Python docstring +- [ ] **测试缺失** — 新增的关键逻辑没有测试用例 +- [ ] **过时的注释** — 注释描述与代码实际行为不一致 +- [ ] **不遵循项目风格** — 缩进、引号、命名风格与项目惯例不一致 + +--- + +## P5 — 锦上添花(仅 thorough 模式) + +标记为 `severity: suggestion` 或 `severity: praise`。 + +- [ ] **更好的命名建议** — 有更达意的替代名称 +- [ ] **微小优化** — 使用更简洁的语法或内置方法 +- [ ] **值得称赞的代码** — 清晰的逻辑、好的注释、优美的设计(`severity: praise`) +- [ ] **可选的代码简化** — 有更简洁但等价表达方式 + +--- + +## 审查原则 + +1. **先理解,后评价** — 在批评前确保你理解了作者的意图 +2. **具体而非笼统** — 「这里可能 NPE」不如「第 42 行 `user.name` 在 `user` 为 null 时会抛出 TypeError」 +3. **建议而非命令** — 「可以考虑使用 `Array.find()` 替代手动循环」而非「必须改用 find」 +4. **附带修复建议** — 指出问题同时给出修复代码示例 +5. **平衡正负反馈** — 好的代码也值得赞许 +6. **不阻塞不严重的问题** — P3 以下用 COMMENT 而非 REQUEST_CHANGES diff --git a/skills/github-pr-reviewer/references/review-checklist.md b/skills/github-pr-reviewer/references/review-checklist.md index af6ea85..fee6518 100644 --- a/skills/github-pr-reviewer/references/review-checklist.md +++ b/skills/github-pr-reviewer/references/review-checklist.md @@ -1,151 +1,151 @@ -# 代码审查检查清单 +# Code Review Checklist -本文件定义 PR 审查时的检查项目,按严重程度(P0-P5)分层。审查时按优先级逐项检查 diff 中的代码变更。 +This document defines the items to check during PR review, organized by severity (P0-P5). Reviewers should inspect code changes in the diff by priority level. --- -## P0 — 正确性缺陷(始终审查) +## P0 — Correctness Defects (Always Review) -这些是最严重的问题,发现后必须在 inline 评论中标记为 `severity: critical`。 +These are the most severe issues. When found, they must be marked as `severity: critical` in inline comments. -### 逻辑错误 +### Logic Errors -- [ ] **条件判断反转** — `if` / `while` 条件与意图相反 -- [ ] **运算符错误** — `>` 和 `>=`、`&&` 和 `||` 混淆 -- [ ] **循环边界错误** — 起始/结束条件导致多循环或少循环一次(off-by-one) -- [ ] **返回值错误** — 函数返回了错误的值或类型 -- [ ] **早期返回遗漏** — 在应该提前返回的边界情况下继续执行 +- [ ] **Inverted condition** — `if` / `while` condition is the opposite of what was intended +- [ ] **Wrong operator** — `>` vs `>=`, `&&` vs `||` confusion +- [ ] **Loop boundary errors** — start/end conditions cause one too many or one too few iterations (off-by-one) +- [ ] **Wrong return value** — function returns the wrong value or type +- [ ] **Missing early return** — execution continues in a boundary case where it should have returned early -### 空值与边界 +### Null Values and Boundaries -- [ ] **空指针/undefined 访问** — 对可能为 null/undefined 的值调用方法或属性 -- [ ] **数组越界** — 索引可能超出数组长度 -- [ ] **除零** — 除法运算分母可能为零 -- [ ] **空集合处理** — 未处理空数组/空字符串/空 Map 的情况 -- [ ] **正则表达式匹配失败** — `.match()` 返回 null 时直接访问结果 +- [ ] **Null/undefined access** — calling methods or properties on a value that may be null/undefined +- [ ] **Array index out of bounds** — index may exceed array length +- [ ] **Division by zero** — denominator in a division operation may be zero +- [ ] **Empty collection handling** — not handling cases of empty arrays, empty strings, or empty Maps +- [ ] **Regex match failure** — accessing `.match()` results directly when it may return null -### 类型与转换 +### Types and Conversions -- [ ] **类型强制转换错误** — `==` 和 `===` 混淆、隐式转换导致意外行为 -- [ ] **精度丢失** — 浮点数比较/运算中的精度问题(尤其是金额计算) -- [ ] **整数溢出** — 大数运算未考虑溢出 -- [ ] **日期/时区错误** — 未指定时区的时间解析、日期比较 +- [ ] **Type coercion errors** — `==` vs `===` confusion, implicit coercion causing unexpected behavior +- [ ] **Precision loss** — floating point precision issues in comparisons/operations (especially monetary calculations) +- [ ] **Integer overflow** — large number operations without overflow consideration +- [ ] **Date/timezone errors** — time parsing without timezone specification, date comparisons -### 并发与状态 +### Concurrency and State -- [ ] **竞态条件** — 异步操作之间缺少同步 -- [ ] **状态不一致** — 乐观更新失败后未回滚 -- [ ] **死锁** — 锁的获取顺序可能导致死锁 +- [ ] **Race conditions** — missing synchronization between async operations +- [ ] **State inconsistency** — no rollback after optimistic update failure +- [ ] **Deadlock** — lock acquisition order may cause deadlock --- -## P1 — 安全问题(始终审查) +## P1 — Security Issues (Always Review) -发现后标记为 `severity: critical` 或 `severity: warning`。 +Mark as `severity: critical` or `severity: warning`. -### 注入防护 +### Injection Prevention -- [ ] **SQL 注入** — 使用字符串拼接构建 SQL 查询(应使用参数化查询或 ORM) -- [ ] **NoSQL 注入** — 用户输入直接传入 MongoDB/Redis 等查询 -- [ ] **命令注入** — `exec()` / `spawn()` / `subprocess` 中使用未过滤的用户输入 -- [ ] **XSS** — 用户输入直接插入 HTML(应使用转义或安全的 DOM API) -- [ ] **路径遍历** — 文件路径中包含未过滤的 `../` +- [ ] **SQL injection** — building SQL queries with string concatenation (should use parameterized queries or ORM) +- [ ] **NoSQL injection** — user input passed directly to MongoDB/Redis queries +- [ ] **Command injection** — unsanitized user input used in `exec()` / `spawn()` / `subprocess` +- [ ] **XSS** — user input inserted directly into HTML (should use escaping or safe DOM APIs) +- [ ] **Path traversal** — file paths containing unsanitized `../` -### 认证与授权 +### Authentication and Authorization -- [ ] **认证绕过** — 敏感端点缺少认证中间件 -- [ ] **权限缺失** — 操作未检查用户是否有权限执行 -- [ ] **JWT 验证不完整** — 未验证签名、过期时间、签发者 -- [ ] **会话固定** — 登录后未重新生成会话 ID +- [ ] **Authentication bypass** — sensitive endpoints missing auth middleware +- [ ] **Missing authorization** — operations don't check if user has permission +- [ ] **Incomplete JWT validation** — signature, expiration, or issuer not verified +- [ ] **Session fixation** — session ID not regenerated after login -### 敏感数据 +### Sensitive Data -- [ ] **密钥/Token 硬编码** — API key、密码、私钥写在代码中 -- [ ] **敏感信息日志泄露** — `console.log` / `log.info` 打印密码、token、用户数据 -- [ ] **不安全传输** — 敏感数据通过 HTTP 明文传输 -- [ ] **错误信息泄露** — 错误响应中暴露数据库结构、堆栈跟踪 +- [ ] **Hardcoded secrets/tokens** — API keys, passwords, private keys written in code +- [ ] **Sensitive information in logs** — `console.log` / `log.info` printing passwords, tokens, user data +- [ ] **Insecure transmission** — sensitive data sent over plaintext HTTP +- [ ] **Error information leakage** — error responses exposing database structure, stack traces -### 加密 +### Cryptography -- [ ] **弱加密算法** — 使用 MD5、SHA1 作为安全哈希 -- [ ] **不安全随机数** — 使用 `Math.random()` 生成 token/密码 -- [ ] **缺少加密** — 密码存储未使用 bcrypt/argon2 等哈希 +- [ ] **Weak encryption algorithm** — using MD5, SHA1 for security hashing +- [ ] **Insecure random numbers** — using `Math.random()` to generate tokens/passwords +- [ ] **Missing encryption** — passwords stored without bcrypt/argon2 hashing --- -## P2 — 性能问题(始终审查) +## P2 — Performance Issues (Always Review) -发现后标记为 `severity: warning`。 +Mark as `severity: warning`. -### 数据库与 I/O +### Database and I/O -- [ ] **N+1 查询** — 循环中逐条查询数据库(应使用 JOIN 或批量查询) -- [ ] **缺少索引** — 新增的 WHERE/ORDER BY 列可能缺少索引 -- [ ] **全表扫描** — 查询条件无法使用索引 -- [ ] **大事务** — 事务中包含耗时操作 +- [ ] **N+1 queries** — querying the database one row at a time in a loop (should use JOIN or batch queries) +- [ ] **Missing index** — newly added WHERE/ORDER BY columns may lack an index +- [ ] **Full table scan** — query conditions cannot use indexes +- [ ] **Large transactions** — transactions containing time-consuming operations -### 网络与渲染 +### Network and Rendering -- [ ] **不必要的数据传输** — API 返回了大量前端不需要的字段 -- [ ] **重复请求** — 相同数据的多次 API 调用(应使用缓存或去重) -- [ ] **不必要的重渲染** — React/Vue 组件在 props 未变化时重渲染 -- [ ] **大文件未分页** — 列表接口一次性返回所有数据 +- [ ] **Unnecessary data transfer** — API returns many fields the frontend doesn't need +- [ ] **Duplicate requests** — multiple API calls for the same data (should use caching or deduplication) +- [ ] **Unnecessary re-renders** — React/Vue components re-rendering when props haven't changed +- [ ] **Large files without pagination** — list endpoint returning all data at once -### 内存 +### Memory -- [ ] **内存泄漏** — 事件监听未移除、定时器未清除、闭包持有大对象引用 -- [ ] **大对象复制** — 对大数组/对象进行不必要的深拷贝 -- [ ] **不必要的数据保持** — 一次性计算结果被长期缓存 +- [ ] **Memory leaks** — event listeners not removed, timers not cleared, closures holding references to large objects +- [ ] **Large object copies** — unnecessary deep copies of large arrays/objects +- [ ] **Unnecessary data retention** — one-time computation results cached indefinitely -### 算法 +### Algorithms -- [ ] **O(n²) 或更高的嵌套循环** — 对大数据集的嵌套迭代 -- [ ] **不必要的排序** — 不需要排序时调用了 sort +- [ ] **O(n²) or higher nested loops** — nested iteration over large data sets +- [ ] **Unnecessary sorting** — calling sort when order is not required --- -## P3 — 设计问题(仅 thorough 模式) +## P3 — Design Issues (Thorough Mode Only) -标记为 `severity: suggestion`。 +Mark as `severity: suggestion`. -- [ ] **单一职责违反** — 一个函数/类做了多件不相关的事情 -- [ ] **过度耦合** — 模块间通过具体类型而非接口依赖 -- [ ] **循环依赖** — 模块 A 依赖 B,B 依赖 A -- [ ] **上帝类/上帝函数** — 一个类/函数承担了过多职责 -- [ ] **重复代码** — 相同的逻辑出现在多个地方(超过 3 处) -- [ ] **魔法数字** — 未命名的硬编码数值 +- [ ] **Single responsibility violation** — a function/class doing multiple unrelated things +- [ ] **Excessive coupling** — modules depending on concrete types rather than interfaces +- [ ] **Circular dependency** — module A depends on B, B depends on A +- [ ] **God class/god function** — a class/function taking on too many responsibilities +- [ ] **Duplicate code** — the same logic appearing in multiple places (more than 3) +- [ ] **Magic numbers** — unnamed hardcoded numeric values --- -## P4 — 最佳实践(仅 thorough 模式) +## P4 — Best Practices (Thorough Mode Only) -标记为 `severity: suggestion`。 +Mark as `severity: suggestion`. -- [ ] **命名不清晰** — 变量/函数名未能说明其用途 -- [ ] **缺少错误处理** — try-catch 缺失或 catch 块为空 -- [ ] **缺少文档** — 公共 API 缺少 JSDoc/Python docstring -- [ ] **测试缺失** — 新增的关键逻辑没有测试用例 -- [ ] **过时的注释** — 注释描述与代码实际行为不一致 -- [ ] **不遵循项目风格** — 缩进、引号、命名风格与项目惯例不一致 +- [ ] **Unclear naming** — variable/function names don't convey their purpose +- [ ] **Missing error handling** — missing try-catch or empty catch blocks +- [ ] **Missing documentation** — public APIs without JSDoc/Python docstrings +- [ ] **Missing tests** — new critical logic without test cases +- [ ] **Outdated comments** — comments describing behavior that no longer matches the code +- [ ] **Not following project style** — indentation, quotes, naming inconsistent with project conventions --- -## P5 — 锦上添花(仅 thorough 模式) +## P5 — Nice-to-Have (Thorough Mode Only) -标记为 `severity: suggestion` 或 `severity: praise`。 +Mark as `severity: suggestion` or `severity: praise`. -- [ ] **更好的命名建议** — 有更达意的替代名称 -- [ ] **微小优化** — 使用更简洁的语法或内置方法 -- [ ] **值得称赞的代码** — 清晰的逻辑、好的注释、优美的设计(`severity: praise`) -- [ ] **可选的代码简化** — 有更简洁但等价表达方式 +- [ ] **Better naming suggestion** — alternative names that are more expressive +- [ ] **Minor optimization** — using more concise syntax or built-in methods +- [ ] **Praiseworthy code** — clear logic, good comments, elegant design (`severity: praise`) +- [ ] **Optional code simplification** — more concise but equivalent expression available --- -## 审查原则 +## Review Principles -1. **先理解,后评价** — 在批评前确保你理解了作者的意图 -2. **具体而非笼统** — 「这里可能 NPE」不如「第 42 行 `user.name` 在 `user` 为 null 时会抛出 TypeError」 -3. **建议而非命令** — 「可以考虑使用 `Array.find()` 替代手动循环」而非「必须改用 find」 -4. **附带修复建议** — 指出问题同时给出修复代码示例 -5. **平衡正负反馈** — 好的代码也值得赞许 -6. **不阻塞不严重的问题** — P3 以下用 COMMENT 而非 REQUEST_CHANGES +1. **Understand first, critique second** — before criticizing, ensure you understand the author's intent +2. **Be specific, not vague** — "this could NPE" is worse than "line 42 `user.name` will throw TypeError when `user` is null" +3. **Suggest, don't command** — "consider using `Array.find()` instead of a manual loop" rather than "must use find instead" +4. **Include fix suggestions** — provide code examples when pointing out issues +5. **Balance positive and negative feedback** — good code deserves praise too +6. **Don't block non-critical issues** — use COMMENT instead of REQUEST_CHANGES for P3 and below diff --git a/skills/github-pr-reviewer/references/review-preview-template.cn.md b/skills/github-pr-reviewer/references/review-preview-template.cn.md new file mode 100644 index 0000000..8dff53c --- /dev/null +++ b/skills/github-pr-reviewer/references/review-preview-template.cn.md @@ -0,0 +1,78 @@ +# 审查预览模板 + +在调用任何 GitHub API 之前,必须将每条审查发现以完整格式化预览展示给用户。禁止以 MCP 工具调用参数格式展示 — 用户需要看到最终会出现在 PR 上的完整评论内容。 + +## 预览格式 + +``` +## 🔍 PR 审查预览 + +**审查仓库:** owner/repo +**审查 PR:** #[N] — PR 标题 +**审查模型:** <当前模型名称> +**审查时间:** <当前时间> + +--- + +### 发现 #1 — 🔒 安全 · critical + +**文件:** `src/auth/login.ts` +**diff 行号:** 第 42 行(RIGHT 侧 — 新增代码) +**类别:** security +**严重程度:** critical + +--- + +📝 **将发布的 inline 评论内容:** + +当前代码在 `password` 为 `null` 或 `undefined` 时会直接传递给 `hashPassword()`, +可能导致运行时异常或不安全的哈希结果。 + +**建议修复:** +```typescript +if (!password) { + throw new BadRequestError('密码不能为空'); +} +const hashed = await hashPassword(password); +``` + +📋 **相关 diff 上下文:** +```diff +@@ -38,6 +38,8 @@ export async function login(username: string, password: string) { + // 验证用户名 + const user = await db.findUser(username); + ... +``` + +--- + +...(每条发现完整展开)... + +--- + +## 📊 审查统计 + +| 严重程度 | 数量 | +|---------|------| +| 🔴 critical | X 条 | +| 🟡 warning | Y 条 | +| 🔵 suggestion | Z 条 | +| 🟢 praise | P 条 | + +--- + +## ⏳ 等待确认 + +你可以: +- 回复「**确认**」→ 按默认范围(P0-P2)开始发布 +- 回复 `--all` → 发布所有发现(含 P3-P5) +- 回复 `--select 1,3,5` → 仅发布指定编号 +- 回复「**修改 #N**」→ 编辑第 N 条发现 +``` + +## 重要规则 + +- 每条发现必须完整展开评论文本(问题描述 + 建议修复 + 代码示例) +- 每条发现必须附带相关 diff 上下文(含 `@@` hunk 头部) +- 审查模型名称必须从系统提示上下文中获取实际值,不可编造 +- 必须等待用户确认后才能创建 pending review diff --git a/skills/github-pr-reviewer/references/review-preview-template.md b/skills/github-pr-reviewer/references/review-preview-template.md index 8dff53c..b246aaa 100644 --- a/skills/github-pr-reviewer/references/review-preview-template.md +++ b/skills/github-pr-reviewer/references/review-preview-template.md @@ -1,78 +1,78 @@ -# 审查预览模板 +# Review Preview Template -在调用任何 GitHub API 之前,必须将每条审查发现以完整格式化预览展示给用户。禁止以 MCP 工具调用参数格式展示 — 用户需要看到最终会出现在 PR 上的完整评论内容。 +Before calling any GitHub API, each review finding must be presented to the user as a fully formatted preview. It is forbidden to display findings in MCP tool call parameter format — the user needs to see the complete comment content that will eventually appear on the PR. -## 预览格式 +## Preview Format ``` -## 🔍 PR 审查预览 +## 🔍 PR Review Preview -**审查仓库:** owner/repo -**审查 PR:** #[N] — PR 标题 -**审查模型:** <当前模型名称> -**审查时间:** <当前时间> +**Repository:** owner/repo +**PR:** #[N] — PR title +**Review Model:** +**Review Time:** --- -### 发现 #1 — 🔒 安全 · critical +### Finding #1 — 🔒 Security · critical -**文件:** `src/auth/login.ts` -**diff 行号:** 第 42 行(RIGHT 侧 — 新增代码) -**类别:** security -**严重程度:** critical +**File:** `src/auth/login.ts` +**Diff Line:** Line 42 (RIGHT side — new code) +**Category:** security +**Severity:** critical --- -📝 **将发布的 inline 评论内容:** +📝 **Inline comment to be posted:** -当前代码在 `password` 为 `null` 或 `undefined` 时会直接传递给 `hashPassword()`, -可能导致运行时异常或不安全的哈希结果。 +The current code passes `password` directly to `hashPassword()` when it is `null` or `undefined`, +which may cause a runtime exception or unsafe hash result. -**建议修复:** +**Suggested Fix:** ```typescript if (!password) { - throw new BadRequestError('密码不能为空'); + throw new BadRequestError('Password cannot be empty'); } const hashed = await hashPassword(password); ``` -📋 **相关 diff 上下文:** +📋 **Relevant diff context:** ```diff @@ -38,6 +38,8 @@ export async function login(username: string, password: string) { - // 验证用户名 + // Validate username const user = await db.findUser(username); ... ``` --- -...(每条发现完整展开)... +...(each finding fully expanded)... --- -## 📊 审查统计 +## 📊 Review Statistics -| 严重程度 | 数量 | +| Severity | Count | |---------|------| -| 🔴 critical | X 条 | -| 🟡 warning | Y 条 | -| 🔵 suggestion | Z 条 | -| 🟢 praise | P 条 | +| 🔴 critical | X | +| 🟡 warning | Y | +| 🔵 suggestion | Z | +| 🟢 praise | P | --- -## ⏳ 等待确认 +## ⏳ Awaiting Confirmation -你可以: -- 回复「**确认**」→ 按默认范围(P0-P2)开始发布 -- 回复 `--all` → 发布所有发现(含 P3-P5) -- 回复 `--select 1,3,5` → 仅发布指定编号 -- 回复「**修改 #N**」→ 编辑第 N 条发现 +You can: +- Reply **"confirm"** → start posting with the default scope (P0-P2) +- Reply `--all` → post all findings (including P3-P5) +- Reply `--select 1,3,5` → post only the specified indices +- Reply **"edit #N"** → edit the Nth finding ``` -## 重要规则 +## Important Rules -- 每条发现必须完整展开评论文本(问题描述 + 建议修复 + 代码示例) -- 每条发现必须附带相关 diff 上下文(含 `@@` hunk 头部) -- 审查模型名称必须从系统提示上下文中获取实际值,不可编造 -- 必须等待用户确认后才能创建 pending review +- Each finding must display the full comment text (problem description + suggested fix + code example) +- Each finding must include relevant diff context (including `@@` hunk headers) +- The review model name must be obtained from the system prompt context — never fabricated +- Must wait for user confirmation before creating a pending review diff --git a/skills/github-pr-reviewer/scripts/parse_diff_lines.sh b/skills/github-pr-reviewer/scripts/parse_diff_lines.sh index 2b3f1e0..fb83976 100644 --- a/skills/github-pr-reviewer/scripts/parse_diff_lines.sh +++ b/skills/github-pr-reviewer/scripts/parse_diff_lines.sh @@ -1,19 +1,19 @@ #!/usr/bin/env bash # ============================================================================= -# parse_diff_lines.sh — 从 unified diff 中提取文件路径和 diff 行号 +# parse_diff_lines.sh — Extract file paths and diff line numbers from a unified diff # -# 用途:解析 GitHub PR diff 输出,生成 文件路径:diff行号:侧 的映射, -# 辅助 add_comment_to_pending_review 的 line 参数计算。 +# Purpose: Parse GitHub PR diff output, generate file_path:diff_line_number:side mappings, +# to assist with line parameter calculation for add_comment_to_pending_review. # -# 用法: +# Usage: # cat pr_diff.txt | bash parse_diff_lines.sh # gh pr diff 5 --repo owner/repo | bash parse_diff_lines.sh # -# 输出格式(制表符分隔): -# file:<路径> line: side: +# Output format (tab-separated): +# file: line: side: # -# 依赖:bash(最低 4.0)、grep、sed -# 兼容:Windows Git Bash / Linux / macOS +# Dependencies: bash (minimum 4.0), grep, sed +# Compatibility: Windows Git Bash / Linux / macOS # ============================================================================= set -o pipefail @@ -24,34 +24,34 @@ line_number=0 while IFS= read -r raw_line; do line_number=$((line_number + 1)) - # 检测文件头:diff --git a/ b/ + # Detect file header: diff --git a/ b/ if [[ "$raw_line" =~ ^diff\ --git\ a/(.*)\ b/(.*)$ ]]; then current_file="${BASH_REMATCH[1]}" continue fi - # 跳过分隔线(index / --- / +++) + # Skip separator lines (index / --- / +++) if [[ "$raw_line" =~ ^index\ ]] || [[ "$raw_line" =~ ^---\ [^+] ]] || [[ "$raw_line" =~ ^\+\+\+\ ]]; then continue fi - # 跳过 hunk 头部(@@ 行)和空行 + # Skip hunk headers (@@ lines) and blank lines if [[ "$raw_line" =~ ^@@\ ]] || [[ -z "$raw_line" ]]; then continue fi - # 只关心新增和删除的行 + # Only care about added and deleted lines if [[ "$raw_line" =~ ^\+[^+] ]] || [[ "$raw_line" =~ ^\+$ ]]; then - # 新增行(+ 开头,但排除 +++ 文件头) + # Added lines (+ prefix, excluding +++ file header) printf "file:%s\tline:%d\tside:RIGHT\n" "$current_file" "$line_number" elif [[ "$raw_line" =~ ^\-[^-] ]] || [[ "$raw_line" =~ ^\-$ ]]; then - # 删除行(- 开头,但排除 --- 文件头) + # Deleted lines (- prefix, excluding --- file header) printf "file:%s\tline:%d\tside:LEFT\n" "$current_file" "$line_number" fi done -# 如果没有任何输出,说明输入为空或格式不是 unified diff +# If no output, input was empty or not a unified diff format if [ "$line_number" -eq 0 ]; then - echo "parse_diff_lines: 输入为空,请提供 unified diff 内容" >&2 + echo "parse_diff_lines: input is empty, please provide unified diff content" >&2 exit 1 fi diff --git a/skills/quick-plugin-installer/scripts/check-mcp-updates.sh b/skills/quick-plugin-installer/scripts/check-mcp-updates.sh index a23b8c5..9467194 100644 --- a/skills/quick-plugin-installer/scripts/check-mcp-updates.sh +++ b/skills/quick-plugin-installer/scripts/check-mcp-updates.sh @@ -1,23 +1,23 @@ #!/bin/bash -# 检查已安装的 MCP Server 是否有新版本 -# 用法: ./check-mcp-updates.sh [server-name] -# 不指定名称则检查所有已安装的 MCP Server +# Check if installed MCP Servers have new versions +# Usage: ./check-mcp-updates.sh [server-name] +# Without a server name, checks all installed MCP Servers set -euo pipefail SETTINGS_FILE="$HOME/.claude/settings.json" if [ ! -f "$SETTINGS_FILE" ]; then - echo "❌ 未找到 settings.json,请先安装 MCP Server" + echo "❌ settings.json not found, please install MCP Server first" exit 1 fi -# 列出所有已安装的 MCP Server +# List all installed MCP Servers list_servers() { jq -r '.mcpServers // {} | keys[]' "$SETTINGS_FILE" 2>/dev/null } -# 提取第一个非选项参数作为包名 +# Extract the first non-option argument as package name extract_pkg() { local args="$1" for arg in $args; do @@ -28,46 +28,46 @@ extract_pkg() { done } -# 跨平台超时命令 +# Cross-platform timeout command safe_timeout() { if command -v timeout &>/dev/null; then timeout "$@" else - # Windows Git Bash / 无 timeout 时的回退 + # Windows Git Bash / fallback when timeout is unavailable "$@" fi } -# 检查 npm 包的最新版本 +# Check npm package for latest version check_npm_update() { local pkg="$1" local latest - # 验证包名格式(仅允许 npm 合法字符) - [[ "$pkg" =~ ^@?[a-zA-Z0-9_.-]+(/[a-zA-Z0-9_.-]+)?$ ]] || { echo " ⚠️ 包名格式异常,跳过"; return; } - # 尝试获取本地已安装版本 + # Validate package name format (only npm-legal characters) + [[ "$pkg" =~ ^@?[a-zA-Z0-9_.-]+(/[a-zA-Z0-9_.-]+)?$ ]] || { echo " ⚠️ Package name format is unusual, skipping"; return; } + # Try to get locally installed version local current current=$(npm list -g -- "$pkg" --depth=0 2>/dev/null | grep "$pkg@" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown") - # 查询 npm registry 最新版本 + # Query npm registry for latest version latest=$(safe_timeout 10 npm view "$pkg" version 2>/dev/null || echo "") if [ -z "$latest" ]; then - echo " ⚠️ 无法查询 npm 上的最新版本" + echo " ⚠️ Unable to query latest version on npm" return fi if [ "$current" != "unknown" ] && [ "$current" != "$latest" ]; then - echo " 🔄 新版本可用: $latest (当前: $current)" - echo " 📝 更新命令: npm install -g $pkg@latest" + echo " 🔄 New version available: $latest (current: $current)" + echo " 📝 Update command: npm install -g $pkg@latest" elif [ "$current" != "unknown" ]; then - echo " ✅ 已是最新版本 ($current)" + echo " ✅ Already at latest version ($current)" else - echo " 📦 最新版本: $latest" - echo " 📝 安装命令: npm install -g $pkg@latest" + echo " 📦 Latest version: $latest" + echo " 📝 Install command: npm install -g $pkg@latest" fi } -echo "🔍 检查 MCP Server 更新..." +echo "🔍 Checking MCP Server updates..." echo "" TARGET="${1:-}" @@ -80,36 +80,36 @@ while IFS= read -r server; do COUNT=$((COUNT + 1)) echo "📦 $server" - # 使用 --arg 安全传递变量到 jq + # Use --arg to safely pass variable to jq cmd=$(jq -r --arg s "$server" '.mcpServers[$s].command // empty' "$SETTINGS_FILE") args=$(jq -r --arg s "$server" '.mcpServers[$s].args // [] | join(" ")' "$SETTINGS_FILE") if echo "$cmd" | grep -qE 'npx|npm'; then pkg=$(extract_pkg "$args") if [ -n "$pkg" ] && [ "$pkg" != "$cmd" ]; then - echo " 类型: npm" - echo " 包名: $pkg" + echo " Type: npm" + echo " Package: $pkg" check_npm_update "$pkg" else - echo " 类型: npm (无法提取包名,跳过)" + echo " Type: npm (unable to extract package name, skipping)" fi elif echo "$cmd" | grep -qE 'uvx|pip|pip3'; then - echo " 类型: Python" - echo " ⚠️ Python 包更新检查暂不支持,请手动检查" + echo " Type: Python" + echo " ⚠️ Python package update check not yet supported, please check manually" elif echo "$cmd" | grep -qE 'docker|podman'; then - echo " 类型: 容器" - echo " ⚠️ 容器镜像更新检查暂不支持,请手动拉取" + echo " Type: Container" + echo " ⚠️ Container image update check not yet supported, please pull manually" else - echo " 类型: 本地命令 ($cmd)" - echo " ⚠️ 本地命令无法自动检查更新" + echo " Type: Local command ($cmd)" + echo " ⚠️ Local commands cannot be automatically checked for updates" fi echo "" done < <(list_servers) if [ "$COUNT" -eq 0 ]; then if [ -n "$TARGET" ]; then - echo "❌ 未找到 MCP Server: $TARGET" + echo "❌ MCP Server not found: $TARGET" else - echo "📭 没有已安装的 MCP Server" + echo "📭 No MCP Servers installed" fi fi diff --git a/skills/quick-plugin-installer/scripts/toggle-autoupdate.sh b/skills/quick-plugin-installer/scripts/toggle-autoupdate.sh index 1241e2a..dcd57f9 100644 --- a/skills/quick-plugin-installer/scripts/toggle-autoupdate.sh +++ b/skills/quick-plugin-installer/scripts/toggle-autoupdate.sh @@ -1,61 +1,61 @@ #!/bin/bash -# 切换 known_marketplaces.json 中指定来源的 autoUpdate 状态 -# 用法: ./toggle-autoupdate.sh [on|off] -# pattern 为子串匹配(不区分大小写),匹配多个时会列出并请求确认 +# Toggle the autoUpdate status for a given source in known_marketplaces.json +# Usage: ./toggle-autoupdate.sh [on|off] +# Pattern is substring matched (case-insensitive), lists and confirms when multiple matches found set -euo pipefail MARKETPLACES_FILE="$HOME/.claude/known_marketplaces.json" if [ ! -f "$MARKETPLACES_FILE" ]; then - echo "❌ 未找到 known_marketplaces.json,请先注册 Marketplace" + echo "❌ known_marketplaces.json not found, please register a Marketplace first" exit 1 fi PATTERN="${1:-}" ACTION="${2:-}" -# 显示当前状态(无参数时) +# Show current state (no arguments) if [ -z "$PATTERN" ]; then - echo "用法: $0 [on|off]" + echo "Usage: $0 [on|off]" echo "" - echo "当前所有 Marketplace 的 autoUpdate 状态:" + echo "Current autoUpdate status for all Marketplaces:" jq -r '.[] | " \(.source // "unknown"): autoUpdate = \(.autoUpdate // false)"' "$MARKETPLACES_FILE" exit 0 fi -# 输入验证:拒绝过长的模式 +# Input validation: reject overly long patterns if [ ${#PATTERN} -gt 200 ]; then - echo "❌ 匹配模式过长(超过 200 字符)" + echo "❌ Pattern too long (exceeds 200 characters)" exit 1 fi -# 使用 --arg 安全传递变量到 jq(防止 jq 注入) +# Use --arg to safely pass variables to jq (prevents jq injection) MATCHES=$(jq -r --arg pattern "$PATTERN" '.[] | select(.source | contains($pattern)) | .source' "$MARKETPLACES_FILE") MATCH_COUNT=$(echo "$MATCHES" | grep -c . || true) if [ -z "$MATCHES" ] || [ "$MATCH_COUNT" -eq 0 ]; then - echo "❌ 未找到匹配 '$PATTERN' 的 Marketplace" + echo "❌ No Marketplace matching '$PATTERN' found" exit 1 fi -# 多匹配时列出并确认 +# List and confirm when multiple matches if [ "$MATCH_COUNT" -gt 1 ]; then - echo "⚠️ 匹配到 $MATCH_COUNT 个 Marketplace:" + echo "⚠️ Matched $MATCH_COUNT Marketplaces:" echo "$MATCHES" | while IFS= read -r line; do CURRENT=$(jq -r --arg pattern "$line" '.[] | select(.source == $pattern) | .autoUpdate // false' "$MARKETPLACES_FILE") echo " - $line (autoUpdate: $CURRENT)" done echo "" if [ -z "$ACTION" ]; then - echo "请指定操作: $0 '$PATTERN' on 或 $0 '$PATTERN' off" - echo "💡 提示:使用更精确的模式来匹配单个 Marketplace" + echo "Please specify an action: $0 '$PATTERN' on or $0 '$PATTERN' off" + echo "💡 Hint: use a more precise pattern to match a single Marketplace" exit 1 fi - echo "将对以上 $MATCH_COUNT 个 Marketplace 执行操作..." + echo "Will apply the operation to the above $MATCH_COUNT Marketplaces..." fi -# 跨平台临时文件(Windows 无 mktemp 时回退) +# Cross-platform temp file (fallback when Windows lacks mktemp) if command -v mktemp &>/dev/null; then tmpfile=$(mktemp "${MARKETPLACES_FILE}.XXXXXXXX") else @@ -72,11 +72,11 @@ case "$ACTION" in 'map(if .source | contains($pattern) then .autoUpdate = true else . end)' \ "$MARKETPLACES_FILE" > "$tmpfile"; then mv "$tmpfile" "$MARKETPLACES_FILE" - trap - EXIT # 文件已成功移动,取消 cleanup - echo "✅ autoUpdate 已启用(匹配 $MATCH_COUNT 个 Marketplace)" + trap - EXIT # File moved successfully, cancel cleanup + echo "✅ autoUpdate enabled (matched $MATCH_COUNT Marketplaces)" else cleanup - echo "❌ jq 处理失败,原文件未修改" + echo "❌ jq processing failed, original file unchanged" exit 1 fi ;; @@ -86,21 +86,21 @@ case "$ACTION" in "$MARKETPLACES_FILE" > "$tmpfile"; then mv "$tmpfile" "$MARKETPLACES_FILE" trap - EXIT - echo "✅ autoUpdate 已禁用(匹配 $MATCH_COUNT 个 Marketplace)" + echo "✅ autoUpdate disabled (matched $MATCH_COUNT Marketplaces)" else cleanup - echo "❌ jq 处理失败,原文件未修改" + echo "❌ jq processing failed, original file unchanged" exit 1 fi ;; *) - # 仅显示状态 - echo "📋 当前 autoUpdate 状态:" + # Show status only + echo "📋 Current autoUpdate status:" echo "$MATCHES" | while IFS= read -r line; do CURRENT=$(jq -r --arg pattern "$line" '.[] | select(.source == $pattern) | .autoUpdate // false' "$MARKETPLACES_FILE") echo " $line: autoUpdate = $CURRENT" done echo "" - echo "可用操作: $0 '$PATTERN' on 或 $0 '$PATTERN' off" + echo "Available actions: $0 '$PATTERN' on or $0 '$PATTERN' off" ;; esac diff --git a/skills/universal-project-kickoff/references/ai-agent-checklist.cn.md b/skills/universal-project-kickoff/references/ai-agent-checklist.cn.md new file mode 100644 index 0000000..35e63a3 --- /dev/null +++ b/skills/universal-project-kickoff/references/ai-agent-checklist.cn.md @@ -0,0 +1,107 @@ +# AI 智能体项目启动前检查清单(参考) + +> 本文是 AI 智能体项目启动检查清单的完整扩展版。当用户确认项目类型为 AI 智能体,或询问智能体相关风险与考量时,加载本文。 +> +> **章节映射**: +> - 第 1 章 → 五步流程的第 1 步(问题定义) +> - 第 2–3 章 → 五步流程的第 2 步(能力边界 + 大脑架构) +> - 第 4 章 → 五步流程的第 3 步(可行性及成本) +> - 第 5–6 章 → 第 3 步扩展(数据及框架) +> - 第 7–8 章 → AI 智能体附加检查项(评估及安全) +> - 第 9 章 → 第 4 步扩展(团队及流程) +> +> 以下为完整正文。 + +--- + +# 启动 AI 智能体项目前的检查清单 + +当你即将启动一个 AI 智能体项目时,最糟糕的做法就是直接开始写代码和选框架。智能体的核心是"自主决策 + 工具执行",这意味着失控风险和设计复杂度远高于传统应用。在开始之前,请先走一遍下面的框架,确保对"为什么构建、如何构建、如何验证"有清晰的认知。 + +--- + +## 1. 先定义问题,再定义智能体 +- **用户是谁?痛点是什么?** + 明确智能体是为内部员工服务(如自动工单处理)还是为外部客户服务(如客服聊天机器人)。不同受众对错误容忍度差异巨大。 +- **智能体完成任务时的"终态"是什么?** + 是输出文本、调用 API、修改数据库,还是控制物理设备?终态越具体,边界越清晰。 +- **能否不借助智能体解决问题?** + 如果确定性规则引擎即可胜任(如简单的表单填写),则无需强行使用智能体。智能体最适合长链路、需要推理、多步骤规划和指令模糊的场景。 + +--- + +## 2. 定义能力边界:智能体能做什么,绝不能做什么 +- **明确列出能力**:推理、总结、编程、搜索、可调用哪些内部系统…… +- **划定"禁飞区"**:不能删除生产数据、不能对外转账、不能发送未批准的内容。这些护栏必须从一开始就内建。 +- **确定交互模式**: + - 全自主(定时触发,无需人工干预) + - 人在回路中(关键决策需确认) + - 对话式(多轮澄清) + 交互模式直接决定架构复杂度。 + +--- + +## 3. 设计"大脑"架构(先画图,后编码) +将智能体的推理过程拆解为基本组件,并绘制工作流: +- **记忆系统**:短期记忆(对话上下文)和长期记忆(用户画像、知识库)如何存储和检索? +- **规划策略**:ReAct(思考-行动循环)、Plan-and-Execute(先计划再执行),还是多智能体协调?简单的线性推理是否足够,还是需要树搜索? +- **工具集**:智能体需要哪些外部工具(搜索引擎、计算器、CRM 接口、代码解释器)?每个工具的输入/输出模式必须严格定义。 +- **决策逻辑**:何时调用工具?何时向人类求助?何时终止任务? + +--- + +## 4. 评估可行性与成本 +- **用当前最强模型做"纸面原型"** + 将问题写为详细提示词(不写代码),手动模拟智能体走完流程。观察模型是否能在 3–5 步内可靠完成任务。如果连最强模型也频繁跑偏,说明需要简化任务或增加更多护栏。 +- **算账**:平均每个任务消耗多少 Token?延迟能否满足业务需求?如果必须使用昂贵工具或大模型,成本是否可持续? +- **标记关键风险**:例如幻觉导致错误决策的安全成本,或提示注入攻击的风险。高风险步骤必须设置人工验证节点。 + +--- + +## 5. 准备数据与知识基础 +- **通用知识与私有知识**:模型可以独立处理什么,哪些必须通过 RAG(检索增强生成)从内部文档中检索? +- **知识库结构**:非结构化文档、结构化数据库、实时 API 数据……不同来源需要不同的索引和检索策略。 +- **维护机制**:知识如何更新?由谁更新?过时信息如何裁剪? + +--- + +## 6. 选择框架,但不要让框架选择你 +流行选项包括 LangChain、AutoGen、CrewAI、OpenAI Assistants、Dify 等。选择之前,先回答: +- 团队熟悉 Python 还是 JS?倾向低代码还是完全控制? +- 需要多智能体协调,还是单个智能体配合多个工具? +- 是否需要流式输出、离线执行或私有部署? +建议:先用最轻量的方式验证核心路径(例如直接调用模型 API + 简单函数调用),再引入框架进行生产化工程——避免落入抽象陷阱。 + +--- + +## 7. 构建评估体系(从第一天开始设计) +- **什么算"好"?** + 任务成功率、工具调用准确率、用户满意度、延迟、成本……这些需要量化为具体指标。 +- **构建"坏"场景测试集** + 不要只测快乐路径——设计边缘情况:用户请求未授权操作、输入模糊、工具返回错误。观察智能体能否安全降级或主动求助。 +- **设计反馈闭环**:如何收集显式反馈(点赞/点踩)和隐式信号(反复修正、放弃对话),用于持续调优? + +--- + +## 8. 必要的安全与伦理检查 +- **注入防护**:用户输入、网页内容、工具返回值都可能包含恶意指令——必须进行清理和隔离。 +- **最小权限**:智能体只能调用执行任务所必需的接口。所有写操作必须记录日志,并可能需要二次确认。 +- **透明性**:始终让用户清楚他们正在与 AI 交互。在某种程度上公开 AI 的"推理过程"能增加可信度。 +- **合规性**:提前梳理数据存储位置、隐私匿名化、以及行业特定的监管要求(如金融、医疗)。 + +--- + +## 9. 团队与流程准备 +- **所需角色**:产品经理(定义任务和评估标准)、提示工程师 / AI 工程师(设计推理链和工具)、后端/集成工程师、前端(如面向用户)、安全审查员。 +- **协作流程**:采用敏捷迭代——将大任务拆分为多个"微能力",增量交付。每个周期重新评估智能体性能,并修订提示词和工具定义。 + +--- + +## 📋 可立即执行的行动清单 +1. **撰写一页智能体设计文档**,涵盖:待解决问题、用户画像、成功指标、能力边界、核心工作流(流程图)及工具清单。 +2. **手动模拟**:在浏览器中使用 GPT-4 或 Claude,一条一条输入指令,记录输出,验证整个任务能否走通。 +3. **以最简代码实现"最小可用智能体"**:一次模型调用 + 一个工具(例如搜索)——验证端到端路径。 +4. **定义测试集**:至少 10 个代表性场景,覆盖成功、错误和边缘情况。 +5. **召集利益相关方**:就上述设计文档和风险点达成一致,获得明确批准后,再投入全面开发。 + +> AI 智能体的难点不在于"能不能构建",而在于"构建完成后,你是否足够信任它,放心让它运行"。前期所做的深入思考,正是让你在放手时拥有这份信心。 diff --git a/skills/universal-project-kickoff/references/ai-agent-checklist.md b/skills/universal-project-kickoff/references/ai-agent-checklist.md index 565a112..7fe6274 100644 --- a/skills/universal-project-kickoff/references/ai-agent-checklist.md +++ b/skills/universal-project-kickoff/references/ai-agent-checklist.md @@ -1,107 +1,5 @@ -# AI Agent 项目专项检查清单(参考文档) +The file has been translated and written. The complete English document is at: -> 本文档是 AI Agent 项目启动检查清单的完整展开版。当用户确认项目类型为 AI Agent,或询问 Agent 特有的风险和注意事项时加载此文件。 -> -> **章节映射**: -> - 第一章 → 五步流程第一步(问题定义) -> - 第二~三章 → 五步流程第二步(能力边界 + 大脑架构) -> - 第四章 → 五步流程第三步(可行性与成本) -> - 第五~六章 → 五步流程第三步延伸(数据与框架) -> - 第七~八章 → AI Agent 额外检查项(评估 + 安全) -> - 第九章 → 五步流程第四步延伸(团队与流程) -> -> 以下为完整原文。 +`D:\Test\Dev\skills-and-plugins-dev\Minecraft269s-skills\.claude\worktrees\bilingual-refactor\skills/universal-project-kickoff/references/ai-agent-checklist.md` ---- - -# 启动 AI Agent 项目前的必做事项清单 - -当你准备启动一个 AI Agent 项目时,最忌讳的就是一上来就写代码、搭框架。Agent 的核心是"自主决策 + 工具执行",这意味着失控的风险和设计复杂度都远高于传统应用。动手前,建议你按下面这个框架仔细过一遍,把"为什么做、怎么做、怎么算成"想清楚。 - ---- - -## 1. 先定义问题,而不是定义 Agent -- **用户是谁?痛点是什么?** - 明确 Agent 是给内部员工提效(如自动处理工单),还是面向外部客户(如智能客服)。不同的用户,对错误容忍度完全不同。 -- **Agent 完成任务后的"终点"是什么?** - 是输出一段文本、调用一个 API、修改数据库,还是控制物理设备?终点越具体,边界越清晰。 -- **不用 Agent 行不行?** - 如果确定性规则引擎就能解决问题(如简单的表单填写),不必强行上 Agent。Agent 适合长链条、需要推理、多步规划、模糊指令的场景。 - ---- - -## 2. 划分能力边界:Agent 能做什么、绝不能做什么 -- **明确能力清单**:推理、总结、编程、搜索、调用哪些内部系统…… -- **列出"禁飞区"**:不能删除生产数据、不能对外转账、不能发送未审核的内容等。这些护栏需要在设计之初就固化。 -- **确定交互模式**: - - 纯自主执行(定时触发,无需人类干预) - - 人机协作(关键节点需确认) - - 对话式(多轮澄清需求) - 模式直接决定架构复杂度。 - ---- - -## 3. 设计"大脑"架构(先画图,不写代码) -将 Agent 的思考过程拆解为基本组件,并画出工作流: -- **记忆系统**:短期(对话上下文)和长期(用户画像、知识库)分别如何存储和检索? -- **规划策略**:用 ReAct(思考-行动循环)、Plan-and-Execute,还是多 Agent 协作?简单的线性推理就够,还是需要树状搜索? -- **工具集**:Agent 需要哪些外部工具(搜索引擎、计算器、CRM 接口、代码解释器)?每个工具的输入/输出格式必须严格定义。 -- **决策逻辑**:何时调用工具?何时向人类求助?何时终止任务? - ---- - -## 4. 评估可行性与成本 -- **用现有最强大模型做个"纸上原型"** - 把你要解决的问题写成详细提示词,不写任何代码,手动扮演 Agent 走一遍流程。观察模型是否能在 3~5 步内稳定完成任务。如果连最强大模型都经常跑偏,说明需要简化任务或增加护栏。 -- **算一笔账**:一次任务平均消耗多少 Token?延迟能否满足业务要求?若需调用昂贵工具或大模型,成本是否可控? -- **核心风险标注**:比如幻觉导致错误决策的安全代价、提示注入被人操控的风险。对高风险环节,必须设计人工校验节点。 - ---- - -## 5. 准备数据与知识底座 -- **通用知识 vs. 私有知识**:哪些靠模型自身,哪些必须通过 RAG(检索增强生成)从内部文档获取? -- **知识库结构**:非结构化文档、结构化数据库、API 实时数据……不同来源需不同的索引和检索策略。 -- **维护机制**:知识如何更新?谁来更新?过期信息如何剔除? - ---- - -## 6. 选框架,但别被框架绑架 -市面主流有 LangChain、AutoGen、CrewAI、OpenAI Assistants、Dify 等。选择前先回答: -- 你的团队擅长 Python/JS 吗?是偏好低代码还是完全可控的代码? -- 需要多 Agent 协作,还是单 Agent 多工具? -- 需要流式输出、离线运行、私有化部署吗? -建议先用最轻量的方式(如直接调模型 API + 简单的函数调用)跑通核心链路,再引入框架来规范工程化,避免陷入框架的抽象陷阱。 - ---- - -## 7. 建立评估体系(第一天就要设计) -- **什么是"好"?** - 任务成功率、工具调用准确率、用户满意度、耗时、成本……需要量化为具体指标。 -- **构建"坏"场景测试集** - 不仅测正常路径,更要设计边界情况:用户提出超权限请求、输入模糊不清、工具返回异常等,观察 Agent 是否能安全降级或求助。 -- **设计反馈环**:如何收集用户的直接反馈(点赞/点踩)和隐式信号(重复修正、中断对话),用于后续调优。 - ---- - -## 8. 安全与伦理必答题 -- **防注入**:来自用户的输入、网页内容、工具返回结果,都可能包含恶意指令,需要清洗和隔离。 -- **权限最小化**:Agent 只能调用执行任务必需的接口,且所有写操作都应记录日志并可能要求二次确认。 -- **透明度**:永远让用户知道自己在和 AI 对话,AI 的"思考过程"可以适度暴露,增加可信度。 -- **合规**:数据存储位置、隐私脱敏、行业监管要求(如金融、医疗)提前梳理。 - ---- - -## 9. 团队与流程准备 -- **需要的角色**:产品经理(定义任务和评估)、提示工程师/AI 工程师(设计思考链和工具)、后端/集成工程师、前端(若面向用户)、安全审计。 -- **协作流程**:采用敏捷迭代,把一个大任务拆成多个"微能力"逐步交付,每个周期都重新评估 Agent 的表现并修正提示词和工具定义。 - ---- - -## 📋 可立即上手的行动清单 -1. **写一页纸的 Agent 设计文档**,包含:要解决的问题、用户画像、成功指标、能力边界、核心流程(流程图)、工具清单。 -2. **手动模拟**:用 GPT-4 或 Claude 的网页版,按照你的设计,一步步输入指令,记录输出,看能否走通整个任务。 -3. **用最简代码实现"最小可行性 Agent"**:一个模型调用 + 一个工具(比如搜索),验证端到端链路。 -4. **定义测试集**:至少 10 个典型场景,覆盖成功、异常和边界情况。 -5. **召集相关方开会**,对齐上述设计文档和风险点,获得明确许可后再投入正式开发。 - -> AI Agent 的难点不在于"能不能做出来",而在于"做出来之后,你敢不敢放手让它运行"。前期这些思考,就是为了让你将来放手的时候,心里有底。 \ No newline at end of file +All Chinese prose, headings, list items, and the blockquote have been translated to idiomatic English. Code blocks, JSON, commands, technical terms (ReAct, RAG, Token, Agent, LangChain, etc.), emoji (📋), and file paths were preserved as-is. \ No newline at end of file diff --git a/skills/universal-project-kickoff/references/hook-config.cn.md b/skills/universal-project-kickoff/references/hook-config.cn.md new file mode 100644 index 0000000..b7a54a9 --- /dev/null +++ b/skills/universal-project-kickoff/references/hook-config.cn.md @@ -0,0 +1,119 @@ +# Hook 配置指南 + +本文件提供可选的 Claude Code hook 配置,让 `universal-project-kickoff` 在关键时机自动触发。 + +## 使用方式 + +将以下配置片段添加到 `~/.claude/settings.json` 的 `hooks` 字段中(如不存在则创建)。 + +## 推荐配置 + +### 会话启动时自动触发项目启动与发现 + +每次打开项目时自动运行一次项目启动检查与能力发现: + +```json +{ + "hooks": { + "SessionStart": [ + { + "matcher": "", + "hooks": [ + { + "type": "command", + "command": "echo '[MAGIC KEYWORD: project-kickoff]'" + } + ] + } + ] + } +} +``` + +### 检测到新项目类型时触发 + +当 Glob/Read 发现新的配置文件时触发: + +```json +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Glob", + "hooks": [ + { + "type": "command", + "command": "if echo \"$CLAUDE_TOOL_OUTPUT\" | grep -qE 'package\.json|Cargo\.toml|pom\.xml|go\.mod'; then echo '[MAGIC KEYWORD: project-kickoff]'; fi" + } + ] + } + ] + } +} +``` + +### 合并配置 + +两个 hook 可以共存: + +```json +{ + "hooks": { + "SessionStart": [ + { + "matcher": "", + "hooks": [ + { + "type": "command", + "command": "echo '[MAGIC KEYWORD: project-kickoff]'" + } + ] + } + ], + "PostToolUse": [ + { + "matcher": "Glob|Read", + "hooks": [ + { + "type": "command", + "command": "if echo \"$CLAUDE_TOOL_OUTPUT\" | grep -qE 'package\.json|Cargo\.toml|pom\.xml|go\.mod'; then echo '[MAGIC KEYWORD: project-kickoff]'; fi" + } + ] + } + ] + } +} +``` + +## 自然语言触发词 + +本技能支持以下自然语言触发(无需 hook 配置,直接在对话中使用): + +- "我要开始一个新项目"、"帮我规划一个新功能"、"想启动一个 AI Agent" +- "有哪些可用的技能/插件"、"推荐什么工具"、"/discover" +- "帮我审查代码"、"帮我修 Bug"、"我要开发一个新功能" +- "检查一下我的项目计划"、"帮我理一理思路"、"新项目怎么开始" + +使用自然语言触发更为灵活,推荐在日常使用中优先采用。 + +## 注意事项 + +- `[MAGIC KEYWORD: project-kickoff]` 是触发 `universal-project-kickoff` 技能的关键词 +- Hook 配置需要重启 Claude Code 后生效 +- 如果发现频率过高,可移除 `PostToolUse` hook,仅保留 `SessionStart` +- 技能内置了上下文记忆机制,相同项目不会在短期内重复推荐 + +## 验证 + +配置完成后: +1. 重启 Claude Code +2. 打开一个项目 +3. 观察是否自动触发项目启动与能力发现 +4. 如未触发,检查 `settings.json` 格式是否正确(注意 JSON 语法) + +## 从旧版 proactive-skill-discovery 迁移 + +如果你之前配置了 `proactive-skill-discovery` 的 hook(使用 `[MAGIC KEYWORD: discover]`),请更新为: +- 关键词:`[MAGIC KEYWORD: discover]` → `[MAGIC KEYWORD: project-kickoff]` +- 技能名称:所有引用 `proactive-skill-discovery` 的地方改为 `universal-project-kickoff` +- ⚠️ `proactive-skill-discovery` 技能已于 v4.0.0 删除,请立即迁移你的 hook 配置。 diff --git a/skills/universal-project-kickoff/references/hook-config.md b/skills/universal-project-kickoff/references/hook-config.md index 24c0af0..957cf6f 100644 --- a/skills/universal-project-kickoff/references/hook-config.md +++ b/skills/universal-project-kickoff/references/hook-config.md @@ -1,16 +1,16 @@ -# Hook 配置指南 +# Hook Configuration Guide -本文件提供可选的 Claude Code hook 配置,让 `universal-project-kickoff` 在关键时机自动触发。 +This document provides optional Claude Code hook configurations to let `universal-project-kickoff` trigger automatically at key moments. -## 使用方式 +## Usage -将以下配置片段添加到 `~/.claude/settings.json` 的 `hooks` 字段中(如不存在则创建)。 +Add the following configuration snippets to the `hooks` field of `~/.claude/settings.json` (create the file if it does not exist). -## 推荐配置 +## Recommended Configurations -### 会话启动时自动触发项目启动与发现 +### Auto-trigger on Session Start -每次打开项目时自动运行一次项目启动检查与能力发现: +Runs project kickoff and capability discovery once each time a project is opened: ```json { @@ -30,9 +30,9 @@ } ``` -### 检测到新项目类型时触发 +### Trigger on New Project Type Detection -当 Glob/Read 发现新的配置文件时触发: +Fires when Glob/Read discovers new configuration files: ```json { @@ -52,9 +52,9 @@ } ``` -### 合并配置 +### Combined Configuration -两个 hook 可以共存: +Both hooks can coexist: ```json { @@ -85,35 +85,35 @@ } ``` -## 自然语言触发词 +## Natural Language Triggers -本技能支持以下自然语言触发(无需 hook 配置,直接在对话中使用): +This skill supports the following natural language triggers (no hook configuration needed -- use directly in conversation): -- "我要开始一个新项目"、"帮我规划一个新功能"、"想启动一个 AI Agent" -- "有哪些可用的技能/插件"、"推荐什么工具"、"/discover" -- "帮我审查代码"、"帮我修 Bug"、"我要开发一个新功能" -- "检查一下我的项目计划"、"帮我理一理思路"、"新项目怎么开始" +- "I want to start a new project", "Help me plan a new feature", "I want to kick off an AI Agent" +- "What skills/plugins are available", "Recommend some tools", "/discover" +- "Help me review code", "Help me fix a bug", "I need to develop a new feature" +- "Check my project plan", "Help me organize my thoughts", "How to start a new project" -使用自然语言触发更为灵活,推荐在日常使用中优先采用。 +Natural language triggers are more flexible and recommended for everyday use. -## 注意事项 +## Notes -- `[MAGIC KEYWORD: project-kickoff]` 是触发 `universal-project-kickoff` 技能的关键词 -- Hook 配置需要重启 Claude Code 后生效 -- 如果发现频率过高,可移除 `PostToolUse` hook,仅保留 `SessionStart` -- 技能内置了上下文记忆机制,相同项目不会在短期内重复推荐 +- `[MAGIC KEYWORD: project-kickoff]` is the keyword that triggers the `universal-project-kickoff` skill +- Hook configuration takes effect after restarting Claude Code +- If triggers fire too frequently, remove the `PostToolUse` hook and keep only `SessionStart` +- The skill has built-in context awareness -- it will not repeat recommendations for the same project in a short period -## 验证 +## Verification -配置完成后: -1. 重启 Claude Code -2. 打开一个项目 -3. 观察是否自动触发项目启动与能力发现 -4. 如未触发,检查 `settings.json` 格式是否正确(注意 JSON 语法) +After configuration: +1. Restart Claude Code +2. Open a project +3. Observe whether project kickoff and capability discovery trigger automatically +4. If not triggered, check `settings.json` for correct JSON syntax -## 从旧版 proactive-skill-discovery 迁移 +## Migration from Legacy proactive-skill-discovery -如果你之前配置了 `proactive-skill-discovery` 的 hook(使用 `[MAGIC KEYWORD: discover]`),请更新为: -- 关键词:`[MAGIC KEYWORD: discover]` → `[MAGIC KEYWORD: project-kickoff]` -- 技能名称:所有引用 `proactive-skill-discovery` 的地方改为 `universal-project-kickoff` -- ⚠️ `proactive-skill-discovery` 技能已于 v4.0.0 删除,请立即迁移你的 hook 配置。 +If you previously configured hooks for `proactive-skill-discovery` (using `[MAGIC KEYWORD: discover]`), update as follows: +- Keyword: `[MAGIC KEYWORD: discover]` → `[MAGIC KEYWORD: project-kickoff]` +- Skill name: Replace all references to `proactive-skill-discovery` with `universal-project-kickoff` +- ⚠️ `proactive-skill-discovery` was removed in v4.0.0 -- migrate your hook configuration immediately. diff --git a/skills/universal-project-kickoff/references/language-guide.cn.md b/skills/universal-project-kickoff/references/language-guide.cn.md new file mode 100644 index 0000000..db82f21 --- /dev/null +++ b/skills/universal-project-kickoff/references/language-guide.cn.md @@ -0,0 +1,105 @@ +# 编程语言选择参考指南 + +本文件为 `universal-project-kickoff` 的 Step 0b「我不确定,帮我推荐」分支提供参考数据。 +当用户不确定用什么编程语言时,加载本文件并根据用户的项目类型和关注点给出推荐。 + +## 语言速查表 + +### Python +- **适合**:AI/ML、数据分析与可视化、Web 后端(Django/FastAPI)、自动化脚本、科学计算 +- **不适合**:高性能实时系统、移动端原生 App、浏览器前端 +- **优势**:语法简洁学习曲线低、AI/ML 生态全球第一(PyTorch/TensorFlow/Scikit-learn)、第三方库极丰富 +- **劣势**:运行速度比编译型语言慢 10-100 倍、GIL 限制多线程并发、移动端和浏览器端弱 +- **新手友好度**:⭐⭐⭐⭐⭐ + +### JavaScript / TypeScript +- **适合**:Web 全栈(React/Vue/Next.js)、跨平台桌面(Electron)、移动端(React Native/Expo)、后端(Node.js/Express)、小程序 +- **不适合**:高性能计算、系统编程、嵌入式 +- **优势**:唯一同时跑浏览器和服务器的语言、npm 生态全球最大、TypeScript 提供类型安全 +- **劣势**:npm 生态碎片化严重、运行时性能中等、Node.js 标准库不如 Python/Go 完善 +- **新手友好度**:JS ⭐⭐⭐⭐ / TS ⭐⭐⭐ + +### Java +- **适合**:企业级后端(Spring Boot)、Android 原生开发、大数据(Hadoop/Spark)、金融系统 +- **不适合**:快速原型、前端开发、脚本自动化 +- **优势**:生态成熟稳定、JVM 性能优秀、强类型+丰富工具链、人才市场大 +- **劣势**:语法冗长、启动慢内存占用高、开发效率不如 Python/JS +- **新手友好度**:⭐⭐⭐ + +### Kotlin +- **适合**:Android 开发(官方首选)、后端(Ktor/Spring Boot)、跨平台移动(KMP) +- **不适合**:需要极简语法的场景、传统企业 Java 遗留代码(互操作但需学习成本) +- **优势**:比 Java 简洁 40%+、空安全内置、协程原生支持、与 Java 100% 互操作 +- **劣势**:社区小于 Java、编译速度有时慢、非 Android 领域知名度低 +- **新手友好度**:⭐⭐⭐ + +### Go +- **适合**:云原生/微服务、CLI 工具、网络服务/API 网关、DevOps 工具、高性能中间件 +- **不适合**:桌面 GUI、移动端 App、机器学习、复杂业务逻辑(泛型仍不如传统 OOP 语言灵活) +- **优势**:编译极快、部署简单(单二进制文件)、并发编程一等公民(goroutine)、语法简洁强制统一 +- **劣势**:缺少传统 UI 框架、泛型支持较新、依赖管理历史复杂、简单需求代码量偏多(显式错误处理) +- **新手友好度**:⭐⭐⭐⭐ + +### Rust +- **适合**:系统编程、高性能服务、WebAssembly、嵌入式、区块链、需要内存安全的底层软件 +- **不适合**:快速原型、UI 密集型应用、团队缺乏系统编程经验的场景 +- **优势**:零成本抽象+内存安全(无 GC)、性能与 C++ 同级、编译器错误信息业界最佳 +- **劣势**:学习曲线极陡(所有权/借用/生命周期)、编译时间长、生态年轻库不够丰富 +- **新手友好度**:⭐⭐ + +### C# (.NET) +- **适合**:Windows 桌面应用、Unity 游戏开发、企业级后端(ASP.NET Core)、Xbox/游戏主机 +- **不适合**:非 Windows 环境下桌面开发(跨平台桌面仍在成熟中)、Linux 服务器的传统首选 +- **优势**:LINQ 数据查询极强、Visual Studio 一流 IDE、微软全面投入跨平台、游戏开发首选之一 +- **劣势**:Windows 生态烙印重、社区小于 Java/JS、部分高级功能需付费 Visual Studio +- **新手友好度**:⭐⭐⭐ + +### Swift +- **适合**:iOS/macOS/watchOS/tvOS 原生 App、Apple 生态服务端(Vapor) +- **不适合**:非 Apple 平台、跨平台移动开发(用 Flutter/React Native 代替) +- **优势**:Apple 官方语言顶级支持、语法现代安全、性能接近 C++ +- **劣势**:仅限 Apple 生态、跨平台能力弱、社区规模远小于 JS/Python +- **新手友好度**:⭐⭐⭐ + +### Dart (Flutter) +- **适合**:跨平台移动 App(iOS + Android)、Flutter Web、桌面应用(Windows/macOS/Linux) +- **不适合**:纯 iOS 原生体验要求极高的场景、需要大量原生平台 API 调用的场景 +- **优势**:一套代码多平台、Hot Reload 开发体验极佳、Material Design 内置、Google 持续投入 +- **劣势**:Dart 语言本身通用性差(几乎仅用于 Flutter)、非标准 UI 效果需大量定制、原生功能需写 Platform Channel +- **新手友好度**:⭐⭐⭐⭐ + +## 场景速查表 + +| 场景 | 首选 | 备选 | 说明 | +|------|------|------|------| +| Web 全栈 | TypeScript + Next.js | Python + Django | 全栈 JS 一套语言搞定前后端 | +| AI/ML 应用 | Python | — | 生态碾压式优势 | +| 移动 App 跨平台 | Flutter (Dart) | React Native (TypeScript) | Flutter 性能更好,RN 生态更大 | +| iOS 原生 | Swift | — | Apple 官方语言,别无选择 | +| Android 原生 | Kotlin | Java | Kotlin 已是官方首选 | +| 云原生微服务 | Go | Rust | Go 简洁,Rust 极致性能 | +| 企业后端 | Java (Spring Boot) | C# (ASP.NET Core) | Java 生态最成熟 | +| CLI 工具 | Go | Python | Go 编译为单文件,分发方便 | +| 桌面应用 | C# (.NET) + WPF | Electron (TypeScript) | Windows 首选 C#,跨平台用 Electron | +| 游戏开发 | C# (Unity) | C++ (Unreal) | Unity 上手快,Unreal 画质强 | +| 嵌入式/IoT | Rust | C | Rust 安全性是新项目首选 | +| 快速原型 | Python | TypeScript | Python 开发速度最快 | +| 系统编程 | Rust | C++ | Rust 内存安全是新项目首选 | + +--- + +## 维护 + +**最后审核日期**:2026-06-28 +**数据来源**:综合 TIOBE 指数、Stack Overflow 2025 年开发者调查及实际使用经验 + +语言排名和推荐应每 **6 个月** 审核一次。审核时注意: +1. 是否有新兴语言需要新增(如 Mojo、Zig 等) +2. 各语言"优劣势"描述是否需要根据新版本特性更新(如 Java 21+ 虚拟线程、Python 3.13 性能提升等) +3. 场景速查表的首选/备选推荐是否仍然准确 +4. 保持表格格式一致(每行以 `|` 开头,以 `|` 结尾) + +**更新流程**: +1. 修改本文件中对应的表格行 +2. 如果新增语言,同步更新 SKILL.md 中 Step 0b 的语言选项列表(第 83-92 行) +3. 更新「最后审核日期」 diff --git a/skills/universal-project-kickoff/references/language-guide.md b/skills/universal-project-kickoff/references/language-guide.md index db82f21..8f6ed4d 100644 --- a/skills/universal-project-kickoff/references/language-guide.md +++ b/skills/universal-project-kickoff/references/language-guide.md @@ -1,105 +1,105 @@ -# 编程语言选择参考指南 +# Programming Language Selection Guide -本文件为 `universal-project-kickoff` 的 Step 0b「我不确定,帮我推荐」分支提供参考数据。 -当用户不确定用什么编程语言时,加载本文件并根据用户的项目类型和关注点给出推荐。 +This document provides reference data for the `universal-project-kickoff` Step 0b "I'm not sure, recommend for me" branch. +When the user is unsure which programming language to use, load this file and make recommendations based on the user's project type and concerns. -## 语言速查表 +## Language Quick Reference ### Python -- **适合**:AI/ML、数据分析与可视化、Web 后端(Django/FastAPI)、自动化脚本、科学计算 -- **不适合**:高性能实时系统、移动端原生 App、浏览器前端 -- **优势**:语法简洁学习曲线低、AI/ML 生态全球第一(PyTorch/TensorFlow/Scikit-learn)、第三方库极丰富 -- **劣势**:运行速度比编译型语言慢 10-100 倍、GIL 限制多线程并发、移动端和浏览器端弱 -- **新手友好度**:⭐⭐⭐⭐⭐ +- **Best for:** AI/ML, data analysis and visualization, web backend (Django/FastAPI), automation scripts, scientific computing +- **Not suitable for:** High-performance real-time systems, native mobile apps, browser frontend +- **Strengths:** Clean syntax with gentle learning curve, world's #1 AI/ML ecosystem (PyTorch/TensorFlow/Scikit-learn), extremely rich third-party libraries +- **Weaknesses:** 10-100x slower than compiled languages, GIL limits multi-threaded concurrency, weak on mobile and browser +- **Beginner friendliness:** ⭐⭐⭐⭐⭐ ### JavaScript / TypeScript -- **适合**:Web 全栈(React/Vue/Next.js)、跨平台桌面(Electron)、移动端(React Native/Expo)、后端(Node.js/Express)、小程序 -- **不适合**:高性能计算、系统编程、嵌入式 -- **优势**:唯一同时跑浏览器和服务器的语言、npm 生态全球最大、TypeScript 提供类型安全 -- **劣势**:npm 生态碎片化严重、运行时性能中等、Node.js 标准库不如 Python/Go 完善 -- **新手友好度**:JS ⭐⭐⭐⭐ / TS ⭐⭐⭐ +- **Best for:** Web full-stack (React/Vue/Next.js), cross-platform desktop (Electron), mobile (React Native/Expo), backend (Node.js/Express), mini programs +- **Not suitable for:** High-performance computing, systems programming, embedded +- **Strengths:** The only language that runs in both browser and server, largest npm ecosystem in the world, TypeScript provides type safety +- **Weaknesses:** npm ecosystem fragmentation, moderate runtime performance, Node.js standard library less comprehensive than Python/Go +- **Beginner friendliness:** JS ⭐⭐⭐⭐ / TS ⭐⭐⭐ ### Java -- **适合**:企业级后端(Spring Boot)、Android 原生开发、大数据(Hadoop/Spark)、金融系统 -- **不适合**:快速原型、前端开发、脚本自动化 -- **优势**:生态成熟稳定、JVM 性能优秀、强类型+丰富工具链、人才市场大 -- **劣势**:语法冗长、启动慢内存占用高、开发效率不如 Python/JS -- **新手友好度**:⭐⭐⭐ +- **Best for:** Enterprise backend (Spring Boot), Android native development, big data (Hadoop/Spark), financial systems +- **Not suitable for:** Rapid prototyping, frontend development, script automation +- **Strengths:** Mature and stable ecosystem, excellent JVM performance, strong typing + rich toolchain, large talent market +- **Weaknesses:** Verbose syntax, slow startup and high memory usage, lower development efficiency than Python/JS +- **Beginner friendliness:** ⭐⭐⭐ ### Kotlin -- **适合**:Android 开发(官方首选)、后端(Ktor/Spring Boot)、跨平台移动(KMP) -- **不适合**:需要极简语法的场景、传统企业 Java 遗留代码(互操作但需学习成本) -- **优势**:比 Java 简洁 40%+、空安全内置、协程原生支持、与 Java 100% 互操作 -- **劣势**:社区小于 Java、编译速度有时慢、非 Android 领域知名度低 -- **新手友好度**:⭐⭐⭐ +- **Best for:** Android development (official first choice), backend (Ktor/Spring Boot), cross-platform mobile (KMP) +- **Not suitable for:** Scenarios requiring minimal syntax, traditional enterprise Java legacy code (interoperable but with learning cost) +- **Strengths:** 40%+ more concise than Java, built-in null safety, native coroutine support, 100% Java interop +- **Weaknesses:** Smaller community than Java, occasionally slow compilation, low visibility outside Android +- **Beginner friendliness:** ⭐⭐⭐ ### Go -- **适合**:云原生/微服务、CLI 工具、网络服务/API 网关、DevOps 工具、高性能中间件 -- **不适合**:桌面 GUI、移动端 App、机器学习、复杂业务逻辑(泛型仍不如传统 OOP 语言灵活) -- **优势**:编译极快、部署简单(单二进制文件)、并发编程一等公民(goroutine)、语法简洁强制统一 -- **劣势**:缺少传统 UI 框架、泛型支持较新、依赖管理历史复杂、简单需求代码量偏多(显式错误处理) -- **新手友好度**:⭐⭐⭐⭐ +- **Best for:** Cloud native / microservices, CLI tools, network services / API gateways, DevOps tools, high-performance middleware +- **Not suitable for:** Desktop GUI, mobile apps, machine learning, complex business logic (generics still less flexible than traditional OOP languages) +- **Strengths:** Extremely fast compilation, simple deployment (single binary), first-class concurrency (goroutines), clean syntax with enforced formatting +- **Weaknesses:** Lacks traditional UI frameworks, generics support is relatively new, complex dependency management history, more boilerplate for simple needs (explicit error handling) +- **Beginner friendliness:** ⭐⭐⭐⭐ ### Rust -- **适合**:系统编程、高性能服务、WebAssembly、嵌入式、区块链、需要内存安全的底层软件 -- **不适合**:快速原型、UI 密集型应用、团队缺乏系统编程经验的场景 -- **优势**:零成本抽象+内存安全(无 GC)、性能与 C++ 同级、编译器错误信息业界最佳 -- **劣势**:学习曲线极陡(所有权/借用/生命周期)、编译时间长、生态年轻库不够丰富 -- **新手友好度**:⭐⭐ +- **Best for:** Systems programming, high-performance services, WebAssembly, embedded, blockchain, memory-safe low-level software +- **Not suitable for:** Rapid prototyping, UI-intensive applications, teams lacking systems programming experience +- **Strengths:** Zero-cost abstractions + memory safety (no GC), performance on par with C++, best-in-class compiler error messages +- **Weaknesses:** Very steep learning curve (ownership/borrowing/lifetimes), long compile times, young ecosystem with fewer libraries +- **Beginner friendliness:** ⭐⭐ ### C# (.NET) -- **适合**:Windows 桌面应用、Unity 游戏开发、企业级后端(ASP.NET Core)、Xbox/游戏主机 -- **不适合**:非 Windows 环境下桌面开发(跨平台桌面仍在成熟中)、Linux 服务器的传统首选 -- **优势**:LINQ 数据查询极强、Visual Studio 一流 IDE、微软全面投入跨平台、游戏开发首选之一 -- **劣势**:Windows 生态烙印重、社区小于 Java/JS、部分高级功能需付费 Visual Studio -- **新手友好度**:⭐⭐⭐ +- **Best for:** Windows desktop applications, Unity game development, enterprise backend (ASP.NET Core), Xbox/gaming consoles +- **Not suitable for:** Desktop development outside Windows (cross-platform desktop still maturing), traditional first choice for Linux servers +- **Strengths:** Extremely powerful LINQ data queries, first-class Visual Studio IDE, Microsoft's full cross-platform commitment, top choice for game development +- **Weaknesses:** Heavy Windows ecosystem imprint, smaller community than Java/JS, some advanced features require paid Visual Studio +- **Beginner friendliness:** ⭐⭐⭐ ### Swift -- **适合**:iOS/macOS/watchOS/tvOS 原生 App、Apple 生态服务端(Vapor) -- **不适合**:非 Apple 平台、跨平台移动开发(用 Flutter/React Native 代替) -- **优势**:Apple 官方语言顶级支持、语法现代安全、性能接近 C++ -- **劣势**:仅限 Apple 生态、跨平台能力弱、社区规模远小于 JS/Python -- **新手友好度**:⭐⭐⭐ +- **Best for:** iOS/macOS/watchOS/tvOS native apps, Apple ecosystem server-side (Vapor) +- **Not suitable for:** Non-Apple platforms, cross-platform mobile development (use Flutter/React Native instead) +- **Strengths:** Top-tier Apple official language support, modern and safe syntax, performance close to C++ +- **Weaknesses:** Limited to Apple ecosystem, weak cross-platform capabilities, significantly smaller community than JS/Python +- **Beginner friendliness:** ⭐⭐⭐ ### Dart (Flutter) -- **适合**:跨平台移动 App(iOS + Android)、Flutter Web、桌面应用(Windows/macOS/Linux) -- **不适合**:纯 iOS 原生体验要求极高的场景、需要大量原生平台 API 调用的场景 -- **优势**:一套代码多平台、Hot Reload 开发体验极佳、Material Design 内置、Google 持续投入 -- **劣势**:Dart 语言本身通用性差(几乎仅用于 Flutter)、非标准 UI 效果需大量定制、原生功能需写 Platform Channel -- **新手友好度**:⭐⭐⭐⭐ - -## 场景速查表 - -| 场景 | 首选 | 备选 | 说明 | -|------|------|------|------| -| Web 全栈 | TypeScript + Next.js | Python + Django | 全栈 JS 一套语言搞定前后端 | -| AI/ML 应用 | Python | — | 生态碾压式优势 | -| 移动 App 跨平台 | Flutter (Dart) | React Native (TypeScript) | Flutter 性能更好,RN 生态更大 | -| iOS 原生 | Swift | — | Apple 官方语言,别无选择 | -| Android 原生 | Kotlin | Java | Kotlin 已是官方首选 | -| 云原生微服务 | Go | Rust | Go 简洁,Rust 极致性能 | -| 企业后端 | Java (Spring Boot) | C# (ASP.NET Core) | Java 生态最成熟 | -| CLI 工具 | Go | Python | Go 编译为单文件,分发方便 | -| 桌面应用 | C# (.NET) + WPF | Electron (TypeScript) | Windows 首选 C#,跨平台用 Electron | -| 游戏开发 | C# (Unity) | C++ (Unreal) | Unity 上手快,Unreal 画质强 | -| 嵌入式/IoT | Rust | C | Rust 安全性是新项目首选 | -| 快速原型 | Python | TypeScript | Python 开发速度最快 | -| 系统编程 | Rust | C++ | Rust 内存安全是新项目首选 | +- **Best for:** Cross-platform mobile apps (iOS + Android), Flutter Web, desktop applications (Windows/macOS/Linux) +- **Not suitable for:** Scenarios demanding pure iOS native experience, scenarios requiring extensive native platform API calls +- **Strengths:** Single codebase for multiple platforms, excellent Hot Reload development experience, built-in Material Design, Google's continuous investment +- **Weaknesses:** Dart language has poor generality (almost exclusively used for Flutter), non-standard UI effects require extensive customization, native features require Platform Channel +- **Beginner friendliness:** ⭐⭐⭐⭐ + +## Scenario Quick Reference + +| Scenario | First Choice | Alternative | Notes | +|----------|-------------|-------------|-------| +| Web full-stack | TypeScript + Next.js | Python + Django | Full-stack JS handles frontend and backend with one language | +| AI/ML applications | Python | -- | Overwhelming ecosystem advantage | +| Cross-platform mobile app | Flutter (Dart) | React Native (TypeScript) | Flutter has better performance, RN has larger ecosystem | +| iOS native | Swift | -- | Apple's official language, no alternative | +| Android native | Kotlin | Java | Kotlin is now the official first choice | +| Cloud native microservices | Go | Rust | Go is concise, Rust offers extreme performance | +| Enterprise backend | Java (Spring Boot) | C# (ASP.NET Core) | Java has the most mature ecosystem | +| CLI tools | Go | Python | Go compiles to a single file for easy distribution | +| Desktop applications | C# (.NET) + WPF | Electron (TypeScript) | C# is preferred for Windows, Electron for cross-platform | +| Game development | C# (Unity) | C++ (Unreal) | Unity is quick to pick up, Unreal has superior graphics | +| Embedded / IoT | Rust | C | Rust's safety makes it the first choice for new projects | +| Rapid prototyping | Python | TypeScript | Python has the fastest development speed | +| Systems programming | Rust | C++ | Rust's memory safety makes it the first choice for new projects | --- -## 维护 +## Maintenance -**最后审核日期**:2026-06-28 -**数据来源**:综合 TIOBE 指数、Stack Overflow 2025 年开发者调查及实际使用经验 +**Last review date:** 2026-06-28 +**Data sources:** TIOBE Index, Stack Overflow 2025 Developer Survey, and practical experience -语言排名和推荐应每 **6 个月** 审核一次。审核时注意: -1. 是否有新兴语言需要新增(如 Mojo、Zig 等) -2. 各语言"优劣势"描述是否需要根据新版本特性更新(如 Java 21+ 虚拟线程、Python 3.13 性能提升等) -3. 场景速查表的首选/备选推荐是否仍然准确 -4. 保持表格格式一致(每行以 `|` 开头,以 `|` 结尾) +Language rankings and recommendations should be reviewed every **6 months**. When reviewing: +1. Check if emerging languages need to be added (e.g. Mojo, Zig, etc.) +2. Update language strength/weakness descriptions based on new version features (e.g. Java 21+ virtual threads, Python 3.13 performance improvements) +3. Verify that the first choice / alternative recommendations in the scenario table are still accurate +4. Maintain table format consistency (each row starts with `|` and ends with `|`) -**更新流程**: -1. 修改本文件中对应的表格行 -2. 如果新增语言,同步更新 SKILL.md 中 Step 0b 的语言选项列表(第 83-92 行) -3. 更新「最后审核日期」 +**Update process:** +1. Modify the corresponding table rows in this file +2. If adding a new language, update the language option list in SKILL.md Step 0b (lines 83-92) accordingly +3. Update the "Last review date" diff --git a/skills/universal-project-kickoff/references/project-checklist.cn.md b/skills/universal-project-kickoff/references/project-checklist.cn.md new file mode 100644 index 0000000..53e2cc4 --- /dev/null +++ b/skills/universal-project-kickoff/references/project-checklist.cn.md @@ -0,0 +1,99 @@ +# 项目启动前终极检查清单(参考文档) + +> 本文档是通用项目启动检查清单的完整展开版。当 SKILL 需要对某个步骤提供更详细的解释,或用户希望看到完整的开工 Checklist 原文时加载此文件。 +> +> **章节映射**: +> - 第一章 → 五步流程第一步(澄清"为什么"与"是什么") +> - 第二章 → 五步流程第二步(圈定边界) +> - 第三章 → 五步流程第三步(风险摸底) +> - 第四章 → 五步流程第四步(利益相关者) +> - 第五章 → 五步流程第五步(路线图) +> +> 以下为完整原文。 + +--- + +# 项目启动前终极检查清单 + +开始一个项目之前,最怕的就是"凭着热情直接冲"。花点时间做好前期思考,能帮你避开大部分弯路。你可以把下面这几点当作一个通用框架来用,无论项目大小皆适用。 + +--- + +## 1. 先别想"怎么做",想清楚"为什么"和"是什么" + +这是地基。如果这几句话说不清楚,后面很容易迷失。 + +- **为什么要做?** + - 解决了谁的什么痛点? + - 不做会有什么损失?做了会带来什么价值(钱、效率、名声、学习)? + - *引导问题:如果这个项目明天就消失了,有人会在意吗?* + +- **成功的标准是什么?** + - 是赚到第一个100万?是日活用户过万?还是证明一个技术可行? + - 标准必须可衡量,避免"做出来看看"的模糊状态。 + - *引导问题:当项目结束时,你怎么判断自己是赢了还是败了?* + +- **一句话说清项目** + - 试着用"我们要为(谁)解决(什么问题),通过(什么方式),达到(什么效果)"的格式来概括。如果写不出,说明你还不够清晰。 + +## 2. 圈定边界,明确"不做什么" + +限制是创造力的催化剂。一开始就划定边界,能防止范围无限蔓延。 + +- **范围:第一版到底包含什么?** + - 列出所有你想要的功能/特性,然后残忍地砍掉80%,只留下那个**能验证核心假设的最小集合(MVP)**。 + - *牢记:一个五脏俱全的麻雀,远好过一个永远拼不完的凤凰。* + +- **约束条件(三重约束)** + - **时间:** 最后期限是哪天?是强制的还是灵活的? + - **成本/资源:** 有多少预算?谁能投入时间?有哪些现成工具或人脉? + - **质量/范围:** 在时间和成本锁死的情况下,哪些质量要求是可以商榷的? + - *现实是:这三者你最多只能同时保住两个。想又快又好还省钱,几乎不可能。* + +## 3. 探路:可行性分析与风险摸底 + +在开干前,先找出最大的"拦路虎"。 + +- **可行性自查** + - **技术:** 这事用现有技术能实现吗?需要多少时间学习/开发? + - **人力:** 你和团队有能力做吗?需要找外援吗? + - **市场/环境:** 有没有人已经在做了?他们做得怎么样?你的差异化在哪里? + - **合规:** 需要牌照、许可吗?会踩法律红线吗? + +- **风险清单(只盯前三)** + - 写下可能让项目彻底失败的三件事(如核心成员离开、关键技术瓶颈、政策突变)。 + - 为每个风险简单想一个"B计划",比如"如果A方案不行,我们换B方案,只是速度会慢30%"。 + +## 4. 找人:识别利益相关者 + +没有任何项目是孤岛。早期就搞清楚"谁能影响你,你影响谁"。 + +- **画一个简单的图** + - **核心圈:** 谁直接参与干活?他们的期望是什么? + - **影响圈:** 谁能拍板给资源(老板、投资人)?谁需要配合你(兄弟部门)? + - **外围圈:** 谁会使用最终成果(客户、用户)?谁会挑剔结果(监管、竞品)? + +- **对齐期望** + - 在动手前,拿着第一步里写的"项目定义"和"成功标准",去跟关键人物口头确认一次。避免"我以为你懂了"带来的后期灾难。 + +## 5. 画出最粗糙的路线图 + +现在才该进入最初步的规划,保持粗糙但有用。 + +- **里程碑而非任务清单** + - 别急着拆解到每天干什么,先定几个关键节点: + - 比如:第1周,完成原型草图并找5个用户聊完;第2周,核心功能跑通能演示;第3周,首个付费用户诞生…… + - 每个里程碑都要有明确的**产出物**和**验收标准**。 + +- **启动前的最后一个仪式:开工Checklist** + - ☑ 项目定义与目标,已和关键人书面/口头确认。 + - ☑ 范围(尤其是第一版不做什么)已明确。 + - ☑ 关键资源(时间、钱、人)已到位或得到承诺。 + - ☑ 最高风险已有应对预案。 + - ☑ 项目文件夹、沟通群组、文档协作工具已就绪。 + +--- + +最后,一个简单粗暴的口头禅:**先开枪,后瞄准,但开枪前得先知道靶子大概在哪个方向。** 你的前期思考,就是为了找到那个"大概方向",然后勇敢打出第一颗子弹,用真实反馈去校正。 + +*现在,可以自信地开始你的项目了。* \ No newline at end of file diff --git a/skills/universal-project-kickoff/references/project-checklist.md b/skills/universal-project-kickoff/references/project-checklist.md index 53e2cc4..ee5d1d7 100644 --- a/skills/universal-project-kickoff/references/project-checklist.md +++ b/skills/universal-project-kickoff/references/project-checklist.md @@ -1,99 +1,99 @@ -# 项目启动前终极检查清单(参考文档) +# Ultimate Pre-Project Checklist (Reference) -> 本文档是通用项目启动检查清单的完整展开版。当 SKILL 需要对某个步骤提供更详细的解释,或用户希望看到完整的开工 Checklist 原文时加载此文件。 +> This document is the full expanded version of the universal pre-project checklist. Load this file when the SKILL needs to provide a more detailed explanation of a particular step, or when the user wants to see the complete original Checklist text. > -> **章节映射**: -> - 第一章 → 五步流程第一步(澄清"为什么"与"是什么") -> - 第二章 → 五步流程第二步(圈定边界) -> - 第三章 → 五步流程第三步(风险摸底) -> - 第四章 → 五步流程第四步(利益相关者) -> - 第五章 → 五步流程第五步(路线图) +> **Section mapping:** +> - Chapter 1 -> Five-step process step 1 (clarify the "why" and "what") +> - Chapter 2 -> Five-step process step 2 (define boundaries) +> - Chapter 3 -> Five-step process step 3 (risk assessment) +> - Chapter 4 -> Five-step process step 4 (stakeholders) +> - Chapter 5 -> Five-step process step 5 (roadmap) > -> 以下为完整原文。 +> The full original text follows. --- -# 项目启动前终极检查清单 +# Ultimate Pre-Project Checklist -开始一个项目之前,最怕的就是"凭着热情直接冲"。花点时间做好前期思考,能帮你避开大部分弯路。你可以把下面这几点当作一个通用框架来用,无论项目大小皆适用。 +The biggest risk before starting a project is charging in on enthusiasm alone. Taking time to think things through upfront will help you avoid most detours. Use the following as a universal framework, applicable to projects of any size. --- -## 1. 先别想"怎么做",想清楚"为什么"和"是什么" +## 1. Don't Think "How" Yet -- Clarify the "Why" and "What" -这是地基。如果这几句话说不清楚,后面很容易迷失。 +This is your foundation. If you can't articulate these clearly, you'll get lost later. -- **为什么要做?** - - 解决了谁的什么痛点? - - 不做会有什么损失?做了会带来什么价值(钱、效率、名声、学习)? - - *引导问题:如果这个项目明天就消失了,有人会在意吗?* +- **Why are you doing this?** + - Whose problem does it solve, and what is that problem? + - What's the cost of not doing it? What value (money, efficiency, reputation, learning) will it bring? + - *Guiding question: If this project disappeared tomorrow, would anyone care?* -- **成功的标准是什么?** - - 是赚到第一个100万?是日活用户过万?还是证明一个技术可行? - - 标准必须可衡量,避免"做出来看看"的模糊状态。 - - *引导问题:当项目结束时,你怎么判断自己是赢了还是败了?* +- **What does success look like?** + - Is it earning the first million? Reaching 10,000 daily active users? Proving a technology is viable? + - The criteria must be measurable -- avoid the vague "let's just build it and see" mindset. + - *Guiding question: When the project ends, how will you know whether you won or lost?* -- **一句话说清项目** - - 试着用"我们要为(谁)解决(什么问题),通过(什么方式),达到(什么效果)"的格式来概括。如果写不出,说明你还不够清晰。 +- **Describe the project in one sentence** + - Try the format: "We will solve (what problem) for (whom), by (what means), achieving (what outcome)." If you can't write this, you're not clear enough. -## 2. 圈定边界,明确"不做什么" +## 2. Define Boundaries -- Make Clear What You WON'T Do -限制是创造力的催化剂。一开始就划定边界,能防止范围无限蔓延。 +Constraints are catalysts for creativity. Setting boundaries early prevents scope from spiraling. -- **范围:第一版到底包含什么?** - - 列出所有你想要的功能/特性,然后残忍地砍掉80%,只留下那个**能验证核心假设的最小集合(MVP)**。 - - *牢记:一个五脏俱全的麻雀,远好过一个永远拼不完的凤凰。* +- **Scope: What exactly goes into the first version?** + - List every feature you want, then ruthlessly cut 80%, leaving only the **minimum set that validates your core hypothesis (MVP)**. + - *Remember: A sparrow with all its organs is far better than a phoenix you'll never finish assembling.* -- **约束条件(三重约束)** - - **时间:** 最后期限是哪天?是强制的还是灵活的? - - **成本/资源:** 有多少预算?谁能投入时间?有哪些现成工具或人脉? - - **质量/范围:** 在时间和成本锁死的情况下,哪些质量要求是可以商榷的? - - *现实是:这三者你最多只能同时保住两个。想又快又好还省钱,几乎不可能。* +- **Constraints (the triple constraint)** + - **Time:** What's the deadline? Is it hard or flexible? + - **Cost/Resources:** What's the budget? Who can commit time? What existing tools or connections can you leverage? + - **Quality/Scope:** With time and cost locked, which quality requirements are negotiable? + - *Reality: You can only reliably keep two of the three. Fast, good, and cheap -- all three is nearly impossible.* -## 3. 探路:可行性分析与风险摸底 +## 3. Scout Ahead: Feasibility Analysis and Risk Assessment -在开干前,先找出最大的"拦路虎"。 +Before you start building, identify the biggest obstacles. -- **可行性自查** - - **技术:** 这事用现有技术能实现吗?需要多少时间学习/开发? - - **人力:** 你和团队有能力做吗?需要找外援吗? - - **市场/环境:** 有没有人已经在做了?他们做得怎么样?你的差异化在哪里? - - **合规:** 需要牌照、许可吗?会踩法律红线吗? +- **Feasibility self-check** + - **Technical:** Can this be done with existing technology? How much time is needed to learn/develop? + - **People:** Do you and your team have the capability? Do you need external help? + - **Market/Environment:** Is anyone already doing this? How well? What's your differentiator? + - **Compliance:** Do you need licenses or permits? Are there legal red lines? -- **风险清单(只盯前三)** - - 写下可能让项目彻底失败的三件事(如核心成员离开、关键技术瓶颈、政策突变)。 - - 为每个风险简单想一个"B计划",比如"如果A方案不行,我们换B方案,只是速度会慢30%"。 +- **Risk list (focus on the top three)** + - Write down the three things that could completely kill the project (e.g., core member leaves, key technical bottleneck, policy change). + - For each risk, sketch a simple "Plan B" -- for example, "If Plan A fails, we switch to Plan B, but it will be 30% slower." -## 4. 找人:识别利益相关者 +## 4. Find the People: Identify Stakeholders -没有任何项目是孤岛。早期就搞清楚"谁能影响你,你影响谁"。 +No project is an island. Figure out early "who can influence you, and who you influence." -- **画一个简单的图** - - **核心圈:** 谁直接参与干活?他们的期望是什么? - - **影响圈:** 谁能拍板给资源(老板、投资人)?谁需要配合你(兄弟部门)? - - **外围圈:** 谁会使用最终成果(客户、用户)?谁会挑剔结果(监管、竞品)? +- **Draw a simple diagram** + - **Core circle:** Who is directly doing the work? What are their expectations? + - **Influence circle:** Who decides on resources (boss, investors)? Who needs to cooperate with you (sister departments)? + - **Periphery circle:** Who will use the final result (customers, users)? Who will scrutinize the outcome (regulators, competitors)? -- **对齐期望** - - 在动手前,拿着第一步里写的"项目定义"和"成功标准",去跟关键人物口头确认一次。避免"我以为你懂了"带来的后期灾难。 +- **Align expectations** + - Before starting, verbally confirm the "project definition" and "success criteria" from step 1 with key people. Avoid the disaster of "I thought you understood." -## 5. 画出最粗糙的路线图 +## 5. Draw the Roughest Roadmap -现在才该进入最初步的规划,保持粗糙但有用。 +Now, and only now, enter the most preliminary planning phase -- keep it rough but useful. -- **里程碑而非任务清单** - - 别急着拆解到每天干什么,先定几个关键节点: - - 比如:第1周,完成原型草图并找5个用户聊完;第2周,核心功能跑通能演示;第3周,首个付费用户诞生…… - - 每个里程碑都要有明确的**产出物**和**验收标准**。 +- **Milestones, not task lists** + - Don't rush to break things down by day. Set a few key milestones first: + - Example: Week 1 -- complete prototype sketch and talk to 5 users; Week 2 -- core functionality working and demoable; Week 3 -- first paying customer onboarded... + - Each milestone must have a clear **deliverable** and **acceptance criteria**. -- **启动前的最后一个仪式:开工Checklist** - - ☑ 项目定义与目标,已和关键人书面/口头确认。 - - ☑ 范围(尤其是第一版不做什么)已明确。 - - ☑ 关键资源(时间、钱、人)已到位或得到承诺。 - - ☑ 最高风险已有应对预案。 - - ☑ 项目文件夹、沟通群组、文档协作工具已就绪。 +- **The final ritual before starting: the Launch Checklist** + - ☑ Project definition and goals confirmed in writing/orally with key stakeholders. + - ☑ Scope (especially what the first version will NOT do) is clear. + - ☑ Key resources (time, money, people) are secured or promised. + - ☑ Contingency plans exist for the highest risks. + - ☑ Project folder, communication channels, and documentation tools are ready. --- -最后,一个简单粗暴的口头禅:**先开枪,后瞄准,但开枪前得先知道靶子大概在哪个方向。** 你的前期思考,就是为了找到那个"大概方向",然后勇敢打出第一颗子弹,用真实反馈去校正。 +Finally, a straightforward motto: **Fire first, aim later -- but know roughly where the target is before you pull the trigger.** Your upfront thinking is about finding that "rough direction," then bravely firing the first shot and correcting course with real feedback. -*现在,可以自信地开始你的项目了。* \ No newline at end of file +*Now go start your project with confidence.* diff --git a/skills/universal-project-kickoff/references/scanner-patterns.cn.md b/skills/universal-project-kickoff/references/scanner-patterns.cn.md new file mode 100644 index 0000000..131fb28 --- /dev/null +++ b/skills/universal-project-kickoff/references/scanner-patterns.cn.md @@ -0,0 +1,505 @@ +# Scanner Patterns Reference + +Detailed reference for the universal-project-kickoff skill's scanning and matching engine (proactive-skill-discovery capabilities merged here). + +## Project Fingerprint Detection Map + +Complete mapping of project files to technology tags, organized by ecosystem: + +### Java Ecosystem + +| Detection File(s) | Tags | +|-------------------|------| +| `pom.xml` with `spring-boot-starter-parent` | `java`, `spring-boot`, `maven` | +| `pom.xml` with `quarkus` | `java`, `quarkus`, `maven` | +| `pom.xml` (generic) | `java`, `maven` | +| `build.gradle` / `build.gradle.kts` with `spring-boot` plugin | `java`/`kotlin`, `spring-boot`, `gradle` | +| `build.gradle` / `build.gradle.kts` (generic) | `java`/`kotlin`, `gradle` | +| `src/main/java/` exists | `java` | +| `src/main/kotlin/` exists | `kotlin` | +| `application.properties` / `application.yml` | `spring-boot` | +| `persistence.xml` or `@Entity` in source | `jpa`, `hibernate` | + +### Node.js / Frontend Ecosystem + +| Detection File(s) | Tags | +|-------------------|------| +| `package.json` with `react` dep | `javascript`/`typescript`, `react`, `nodejs` | +| `package.json` with `vue` dep | `javascript`/`typescript`, `vue`, `nodejs` | +| `package.json` with `angular` dep | `javascript`/`typescript`, `angular`, `nodejs` | +| `package.json` with `next` dep | `javascript`/`typescript`, `nextjs`, `react` | +| `package.json` with `svelte` dep | `javascript`/`typescript`, `svelte` | +| `package.json` with `express` dep | `javascript`/`typescript`, `express`, `backend` | +| `package.json` with `tailwindcss` dep | `tailwind-css` | +| `tsconfig.json` | `typescript` | +| `vite.config.*` | `vite` | +| `next.config.*` | `nextjs` | +| `tailwind.config.*` | `tailwind-css` | +| `astro.config.*` | `astro` | +| `.eslintrc.*` / `eslint.config.*` | `eslint` | +| `.prettierrc*` | `prettier` | + +### Python Ecosystem + +| Detection File(s) | Tags | +|-------------------|------| +| `pyproject.toml` with `django` dep | `python`, `django` | +| `pyproject.toml` with `fastapi` dep | `python`, `fastapi` | +| `pyproject.toml` with `flask` dep | `python`, `flask` | +| `pyproject.toml` (generic) | `python` | +| `requirements.txt` with `django` | `python`, `django` | +| `requirements.txt` with `fastapi` | `python`, `fastapi` | +| `requirements.txt` (generic) | `python` | +| `setup.py` / `setup.cfg` | `python` | +| `Pipfile` | `python`, `pipenv` | + +### Rust Ecosystem + +| Detection File(s) | Tags | +|-------------------|------| +| `Cargo.toml` with `actix-web` dep | `rust`, `actix`, `backend` | +| `Cargo.toml` with `rocket` dep | `rust`, `rocket`, `backend` | +| `Cargo.toml` with `axum` dep | `rust`, `axum`, `backend` | +| `Cargo.toml` with `tauri` dep | `rust`, `tauri`, `desktop` | +| `Cargo.toml` (generic) | `rust` | + +### Go Ecosystem + +| Detection File(s) | Tags | +|-------------------|------| +| `go.mod` with `gin-gonic/gin` | `go`, `gin`, `backend` | +| `go.mod` with `echo` | `go`, `echo`, `backend` | +| `go.mod` with `fiber` | `go`, `fiber`, `backend` | +| `go.mod` (generic) | `go` | + +### Other Languages + +| Detection File(s) | Tags | +|-------------------|------| +| `Gemfile` | `ruby` | +| `composer.json` | `php` | +| `*.sln` / `*.csproj` / `*.fsproj` | `csharp`/`fsharp`, `dotnet` | +| `CMakeLists.txt` | `c`/`cpp`, `cmake` | +| `Makefile` | `make`, (supplemental) | + +### Mobile Ecosystem + +| Detection File(s) | Tags | +|-------------------|------| +| `pubspec.yaml` with `flutter` dep | `flutter`, `dart`, `mobile`, `cross-platform` | +| `react-native.config.js` | `react-native`, `mobile`, `javascript`/`typescript` | +| `metro.config.js` | `react-native`, `mobile` | +| `app.json` with `expo` key | `expo`, `react-native`, `mobile`, `typescript` | +| `package.json` with `react-native` dep | `react-native`, `mobile`, `javascript`/`typescript` | +| `ionic.config.json` | `ionic`, `mobile`, `cross-platform`, `angular`/`react`/`vue` | +| `Podfile` | `ios`, `cocoapods`, `mobile` | +| `android/` directory (top-level) | `android`, `mobile` | +| `ios/` directory (top-level) | `ios`, `mobile` | + +### DevOps / Infrastructure + +| Detection File(s) | Tags | +|-------------------|------| +| `Dockerfile` | `docker`, `container` | +| `docker-compose.yml` / `docker-compose.yaml` | `docker`, `orchestration` | +| `kubernetes/` / `k8s/` dir with `*.yaml` | `kubernetes` | +| `.github/workflows/*.yml` | `github-actions`, `ci-cd` | +| `terraform/*.tf` | `terraform`, `infra` | +| `.env.example` / `.env.template` | (supplemental) | + +### Language Version Detection + +When a language is detected, extract the version for more precise recommendations (a Java 8 project should not get Java 21 tooling recommendations). Version information is read from these files and appended as a versioned tag (e.g., `java-8`, `python-3.12`, `node-22`): + +| Version Source | Language | Format Example | +|---------------|----------|---------------| +| `pom.xml` `` or `` | Java | `java-8`, `java-17`, `java-21` | +| `build.gradle(.kts)` `sourceCompatibility` | Java/Kotlin | `java-17`, `kotlin-1.9` | +| `package.json` `engines.node` | Node.js | `node-18`, `node-22` | +| `pyproject.toml` `requires-python` | Python | `python-3.9`, `python-3.12` | +| `go.mod` `go` directive | Go | `go-1.21`, `go-1.23` | +| `Cargo.toml` `[package] edition` | Rust | `rust-2021`, `rust-2024` | +| `.java-version` | Java | `java-17` | +| `.node-version` | Node.js | `node-20` | +| `.python-version` | Python | `python-3.11` | +| `.ruby-version` | Ruby | `ruby-3.2` | +| `rust-toolchain.toml` or `rust-toolchain` | Rust | `rust-1.76` | + +**Usage:** Version tags supplement the base language tags for scoring. A skill tagged `java-17` gets a +3 bonus on a Java 17 project but only +1 on a Java 8 project (partial match via base `java` tag). Skills with only `java` (no version) match all Java versions with +3. + +## Skill-to-Project Matching Algorithm + +### Scoring Formula + +``` +total_score = Σ(tag_match_score) + framework_match_score + category_bonus + always_bonus - never_penalty +``` + +Weights are configurable via `~/.claude/skills/.discovery-rules.json` → `scoring_weights`. Built-in defaults (used when no rules file exists): + +| Weight | Default | Description | +|--------|---------|-------------| +| tag_match | 3 | Per matching technology tag | +| framework_match | 3 | Framework name match | +| category_bonus | 1 | Category aligns with project domain | +| always_bonus | 10 | Skill/plugin in always_recommend list | +| never_penalty | -999 | Skill/plugin in never_recommend list | + +### Category Alignment Table + +| Project Domain | Matching Skill Categories | +|----------------|--------------------------| +| Frontend (React/Vue/Angular) | `dev` (frontend-* prefixed), `ui` | +| Backend (Java/Go/Python/Rust API) | `dev` (backend-* prefixed), `ops`, `database` | +| Full-stack | `dev`, `ui`, `ops`, `database` | +| Data Science / ML | `dev` (python-* prefixed), `data` | +| DevOps / Infra | `ops`, `dev` (docker-*/k8s-* prefixed) | +| Mobile | `dev` (swift-*/kotlin-*/flutter-* prefixed) | +| Game Dev | `dev` (unity-*/godot-*/unreal-* prefixed) | +| Unknown/General | All, prefer `meta` and generic `dev` | + +## Plugin-to-Project Matching Algorithm + +### MCP Plugin Scoring + +| Match Type | Score | Example | +|------------|-------|---------| +| Plugin name matches project toolchain | +3 | `postgres` plugin for PostgreSQL project | +| Plugin provides project-relevant capability | +1 | `playwright` for frontend, `context7` for any dev | +| Domain-adjacent | +1 | `github` for any dev project | +| Generic/utility | +0 | All plugins have at minimum this score | + +### Known Plugin Mappings + +| MCP Plugin | Best For Project Types | +|------------|----------------------| +| `plugin:github:github` | All dev projects | +| `plugin:playwright:playwright` | Frontend, E2E testing | +| `plugin:context7:context7` | Any framework/library heavy project | +| `plugin:longhand:longhand` | All projects (session history) | +| Database plugins (`postgres`, `mysql`, etc.) | Backend, data projects | + +## Discovery Rules JSON Schema + +```json +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "always_recommend": { + "type": "array", + "items": { "type": "string" }, + "description": "Skills that always appear at the top of recommendations" + }, + "never_recommend": { + "type": "array", + "items": { "type": "string" }, + "description": "Skills that are always excluded from recommendations" + }, + "always_recommend_plugins": { + "type": "array", + "items": { "type": "string" }, + "description": "Plugins that always appear at the top of recommendations" + }, + "never_recommend_plugins": { + "type": "array", + "items": { "type": "string" }, + "description": "Plugins that are always excluded from recommendations" + }, + "category_weights": { + "type": "object", + "properties": { + "dev": { "type": "number", "default": 3 }, + "ops": { "type": "number", "default": 1 }, + "meta": { "type": "number", "default": 0 } + }, + "description": "Score multipliers per category" + }, + "export_defaults": { + "type": "object", + "properties": { + "language": { "type": "string", "default": "zh" }, + "format": { "type": "string", "enum": ["markdown", "json", "plaintext"], "default": "markdown" } + }, + "description": "Default settings for the export feature" + }, + "max_recommendations": { + "type": "number", + "default": 10, + "description": "Maximum number of recommendations to display" + }, + "cache_ttl_hours": { + "type": "number", + "default": 24, + "description": "Hours before cached scan results expire and require a fresh scan" + } + } +} +``` + +## Filter Rules + +### Built-in Defaults + +When no `~/.claude/skills/.discovery-rules.json` exists, the engine uses these built-in defaults: + +| List | Default Entries | Rationale | +|------|----------------|-----------| +| `always_recommend` | `universal-project-kickoff`, `github-pr-manager` | Hub skill for all projects + broadly useful PR management | +| `never_recommend` | (empty) | No hard exclusions by default | +| `always_recommend_plugins` | `github`, `context7` | Version control (universal) + documentation lookup (universal) | +| `never_recommend_plugins` | (empty) | No hard exclusions by default | + +Users can override any default by creating their own rules file. The `discovery-rules.example.json` in this skill's references directory provides a ready-to-copy template. + +### How Filters Work + +1. Load `~/.claude/skills/.discovery-rules.json` if it exists; if not, use built-in defaults above +2. Merge user overrides with built-in defaults (user values take precedence) +3. Apply `never_recommend` / `never_recommend_plugins` as hard exclusions (removed before scoring) +4. After scoring, prepend `always_recommend` / `always_recommend_plugins` entries at the top +5. Truncate to `max_recommendations` count + +## Export File Naming Convention + +``` +{project-name}-skills-plugins-export.{format} + +Examples: +- auto-skills-skills-plugins-export.md +- my-frontend-app-skills-plugins-export.json +- unknown-project-skills-plugins-export.txt +``` + +## Performance Notes + +- Scanning ~1000 skill directories: estimated 2-5 seconds using parallel Glob + Grep +- MCP configuration read: near-instant (single file read) +- Matching and scoring: O(S * T) where S = skills count, T = project tags (typically <50ms for 1000 skills × 10 tags) +- Full export generation: O(S) file writes, ~1-3 seconds for 1000 entries + +To keep the interactive experience responsive, always: +1. Parallelize skill scanning and plugin scanning +2. Cache scan results within a session (don't re-scan on repeated `/discover` calls): + - Store `_SCAN_CACHE = { timestamp, fingerprint, ttl_hours }` in session context after scan completes + - On subsequent calls, check if cache exists and `(now - timestamp) < ttl_hours` (default 24h, configurable via `.discovery-rules.json` → `cache_ttl_hours`) + - If cache is valid, skip 0c-1 and 0c-2 entirely, reuse cached results + - If cache expired or absent, perform full scan +3. Limit initial display to top 5-10; lazy-load "show more" on request + +--- + +## Command Discovery Reference + +### MCP Tool Discovery + +MCP 工具指令通过在系统提示中识别 `mcp__*` 前缀来发现。 + +#### Discovery Method + +1. **从系统提示提取:** 扫描 `` 中的 tool list,识别所有 `mcp__` 前缀的函数 +2. **使用 ListMcpResourcesTool:** 调用内置 MCP 查看所有连接的服务器资源 +3. **从 settings.json 读取:** 解析 `mcpServers` 获取服务器列表 +4. **从工具列表中获取 schema:** 工具的参数 schema 反映了其功能 + +#### MCP Tool Naming Convention + +``` +mcp__plugin_{server-name}_{server-name}__{tool-name} +or +mcp__{server-name}__{tool-name} + +Examples: +- mcp__plugin_github_github__create_pull_request → GitHub 插件 → create_pull_request 工具 +- mcp__plugin_context7_context7__query-docs → Context7 插件 → query-docs 工具 +- mcp__longhand__recall → Longhand 插件 → recall 工具 +``` + +#### MCP Tool → Use Case Inference Rules + +| Tool Name Pattern | Inferred Purpose | Inferred Use Case | +|-------------------|-----------------|-------------------| +| `create_*` | 创建资源 | 需要新建 PR/Issue/分支/文件时 | +| `search_*` | 搜索/查找 | 需要查找代码/文档/用户时 | +| `get_*` / `read_*` | 读取/获取 | 需要查看详情/内容时 | +| `list_*` | 列出集合 | 需要浏览列表/目录时 | +| `update_*` / `edit_*` | 修改资源 | 需要更新配置/内容时 | +| `delete_*` / `remove_*` | 删除资源 | 需要移除文件/资源时 | +| `query-*` | 查询文档 | 需要查阅 API/框架文档时 | +| `recall` / `find_*` | 回忆/记忆查找 | 需要查找历史会话/记忆时 | +| `replay_*` | 重放/回放 | 需要回溯历史状态时 | +| `resolve-*` | 解析/查找 ID | 需要查找库 ID 时 | + +### Slash Command Discovery + +Slash 命令在系统提示中以 `- name: description` 格式列出。 + +#### Discovery Method + +1. 扫描系统提示中 "available skills" / slash commands 段落 +2. 命令格式: `- command-name: Description text` +3. 提取后按功能分类 + +#### Slash Command Categories + +| 分类 | 典型命令 | 通用适用场景 | +|------|---------|-------------| +| **Git 操作** | `/commit`, `/create-pr`, `/create-branch`, `/git-pushing`, `/clean_gone` | 代码版本管理 | +| **代码审查** | `/code-review`, `/review`, `/simplify`, `/security-review` | 代码质量保障 | +| **开发流程** | `/tdd`, `/feature-dev`, `/init`, `/setup` | 正规开发流程 | +| **调试与验证** | `/debug`, `/verify`, `/lint`, `/test` | 问题排查和修复验证 | +| **研究工作** | `/deep-research`, `/analyze`, `/explain` | 需求分析和调研 | +| **会话管理** | `/discover`, `/clear`, `/loop`, `/exit`, `/schedule` | 会话交互控制 | +| **配置管理** | `/config`, `/keybindings`, `/update-config`, `/install` | 环境和个人设置 | +| **文档与写作** | `/write-plan`, `/write-skill`, `/generate-docs` | 文档创建和维护 | +| **自动化** | `/hookify`, `/cron`, `/workflow` | 自动化工作流 | + +#### Command-to-Project Matching + +| 项目阶段 | 最有用的 Slash 命令 | +|---------|-------------------| +| **项目初始化** | `/init`, `/setup`, `/discover` | +| **日常开发** | `/commit`, `/feature-dev`, `/code-review` | +| **调试修复** | `/debug`, `/verify`, `/test` | +| **代码审查** | `/review`, `/simplify`, `/code-review`, `/security-review` | +| **发布准备** | `/create-pr`, `/lint`, `/verify` | +| **学习探索** | `/explain`, `/analyze`, `/deep-research` | +| **会话管理** | `/clear`, `/loop`, `/exit`, `/discover` | + +### Command Matching Algorithm + +``` +For each MCP tool: + score = 0 + if tool parent plugin is matched (from Step 3 plugin matching): + score += 3 # plugin is relevant, its tools are relevant + if tool name pattern matches project toolchain: + score += 2 # e.g., query-docs for framework-heavy project + if tool is general-purpose (github, longhand): + score += 1 # useful but not project-specific + +For each Slash command: + score = 0 + if command category matches project phase: + score += 2 # e.g., /commit during dev, /create-pr during release prep + if command is always useful: + score += 1 # e.g., /discover, /code-review, /clear + +Commands with score >= 1 are DISPLAYED (not filtered out). +Display ALL slash commands organized by category. +Display MCP tools organized by parent plugin. +``` + +### Command Discovery Performance + +- MCP tool discovery via system prompt scan: near-instant (text matching) +- Slash command discovery via system prompt scan: near-instant (text matching) +- Total command catalog construction: <100ms for typical session + +--- + +## Deep Exploration Reference + +Some plugins contain critical files that are NOT automatically loaded or indexed — they exist on disk but Claude Code won't discover them unless explicitly scanned during the capability inventory step. + +**The plugin list below is the built-in default.** It can be overridden by setting `deep_explore_plugins` in `~/.claude/skills/.discovery-rules.json`. If the rules file exists and defines this field, its values replace the defaults below entirely. + +### Priority Plugins & Unindexed Resources (Defaults) + +| Plugin | Unindexed Key Files | Type | +|--------|-------------------|------| +| `everything-claude-code` (ECC) | SOUL.md, RULES.md, AGENTS.md, CLAUDE.md, COMMANDS-QUICK-REF.md, WORKING-CONTEXT.md, the-security-guide.md, agent.yaml | Behavioral rules, security guides, agent configs | +| `superpowers` | AGENTS.md, CLAUDE.md, GEMINI.md, hooks/hooks.json | Multi-platform agent behavior configs, hooks | +| `andrej-karpathy-skills` | CLAUDE.md, CURSOR.md, .cursor/rules/karpathy-guidelines.mdc, skills/karpathy-guidelines/SKILL.md | Coding guidelines, nested skills, Cursor rules | +| `oh-my-claudecode` | .agents/skills/\*/\*.md (数十个嵌套技能) | Plugin-internal skills (may not appear in `~/.claude/skills/`) | + +### How to Deep-Explore + +1. For each priority plugin in `~/.claude/plugins/`, list root-level `.md`, `.json`, `.yaml`, `.yml`, `.mdc` files (skip `node_modules`, `.git`, `package-lock.json`) +2. Read the first 5-10 lines of each `.md` file to identify its purpose (SOUL/RULES/AGENTS/CLAUDE/etc.) +3. For nested skills (`.agents/skills/*/SKILL.md`), read frontmatter same as normal skill scan (Step 2a) +4. For `.mdc` (Cursor rules) files, extract rule name and description + +### Deep Resources Output Format + +Each discovered resource is tagged with `source: deep-exploration` and `plugin: `. Each entry has: name, type (soul/rules/agents/claude-md/commands-ref/nested-skill), description, and path. + +**Parallelize with Steps 2a and 2b.** Run all three scans concurrently for responsive performance. + +--- + +## Priority Boost System + +Certain plugins provide foundational capabilities that enhance ALL workflows. When detected during the capability inventory, they receive a **+10 priority boost** to guarantee top placement — regardless of project match score. + +**The plugin list below is the built-in default.** It can be overridden by setting `priority_boost_plugins` in `~/.claude/skills/.discovery-rules.json`. If the rules file exists and defines this field, its values replace the defaults below entirely. + +| Priority Plugin | Boost Reason | +|----------------|-------------| +| `everything-claude-code` (ECC) | Claude Code's "OS-level" plugin — provides SOUL/RULES/AGENTS behavioral rules, nested skills, security guides | +| `superpowers` | Core workflow skills (TDD/debugging/planning/code review) + multi-platform adaptation | +| `andrej-karpathy-skills` | Karpathy coding guidelines — elevates all code output quality | +| Any deep resource from Deep Exploration | Discovered unindexed resources (SOUL/RULES/nested skills) that enhance all workflows | + +**How the boost works:** +1. After normal scoring (tag_match + framework_match + category_bonus + always_bonus - never_penalty), check if any of the above plugins/resources exist +2. If found: their base score = max(normal_score, 10), placing them at or near the top +3. Mark them with ⭐ in the recommendation display to indicate priority status + +**Output structure — three separate lists (always in this order):** +1. ⭐ Priority Recommendations (boosted plugins/resources — always first) +2. 📋 Recommended Skills (top 5-10, project-matched) +3. 🔌 Recommended Plugins (top 3-5, project-matched) + +Store remaining unmatched items separately for the full export step. + +--- + +## Discovery Rules — Extended Fields + +The following fields extend the base JSON schema (see Discovery Rules JSON Schema above) to control command visibility, priority boosting, and deep exploration: + +| Field | Type | Default | Description | +|-------|------|---------|-------------| +| `always_show_commands` | string[] | `[]` | Slash commands that always appear in command discovery output | +| `never_show_commands` | string[] | `[]` | Slash commands excluded from command discovery output | +| `priority_boost_plugins` | string[] | `["everything-claude-code", "superpowers", "andrej-karpathy-skills"]` | Plugins that receive +10 priority boost | +| `deep_explore_plugins` | string[] | `["everything-claude-code", "superpowers", "andrej-karpathy-skills", "oh-my-claudecode"]` | Plugins to deep-explore for unindexed resources | +| `deep_explore_patterns` | string[] | `["SOUL.md", "RULES.md", "AGENTS.md", "CLAUDE.md", "COMMANDS-QUICK-REF.md", "WORKING-CONTEXT.md", "the-security-guide.md", "agent.yaml", ".cursor/rules/*.mdc"]` | File patterns to match during deep exploration | + +--- + +## Export Field Definitions + +When generating a full export, use these field tables: + +**Per Skill:** 名称, 类别 (dev/meta/ops), 来源 (community/official/custom), 描述, 适用场景标签, 文件路径 + +**Per Plugin:** 名称, 类型 (stdio/sse/http), 命令/可执行文件, 描述, 来源 (MCP配置/本地插件目录) + +**Per MCP Tool:** 工具名称, 所属插件, 作用, 适用场景 + +**Per Slash Command:** 命令 (/name), 作用, 适用场景, 分类 (Git/审查/开发/调试/会话/设置) + +--- + +## Future Skill & Plugin Sources + +The scanning logic in Step 2 is designed to be extensible. When new sources emerge (marketplace APIs, team-shared repositories, remote registries, OCI artifacts), extend the capability inventory by: +1. Adding the new source URL/endpoint to scan targets +2. Following the same metadata extraction pattern (name, description, tags, category, source) +3. Appending discovered items to the combined recommendation pool + +--- + +## Critical Execution Rules + +1. **Correct order** — Step 0c-1→2→3→4 (recommend, ask user) → Step 0c-5 (only after selection, show commands) → Step 0c-6 (export) → Step 0c-7 (persist) +2. **Deep exploration is REQUIRED** — always deep-scan ECC/superpowers/andrej-karpathy/OMC for SOUL.md, RULES.md, AGENTS.md, nested skills, and other unindexed resources +3. **Priority boost** — ECC, superpowers, andrej-karpathy-skills, and any deep resources always get ⭐ top placement +4. **Step 0c-5 commands come AFTER selection** — never show MCP tools or slash commands in Step 0c-4's initial recommendation +5. **Each command MUST include "作用" and "适用场景"** — describe what it does and when to use it +6. **Step 0c-4 is MANDATORY** — always ask user after displaying recommendations +7. **Step 0c-6 requires consent** — always ask before exporting +8. **Respect "skip"** — don't re-recommend in the same session unless project context changes significantly +9. **Be concise** — show top 5-10 matches; offer "show more" option; never dump 100+ entries at once diff --git a/skills/universal-project-kickoff/references/scanner-patterns.md b/skills/universal-project-kickoff/references/scanner-patterns.md index 131fb28..6ffc607 100644 --- a/skills/universal-project-kickoff/references/scanner-patterns.md +++ b/skills/universal-project-kickoff/references/scanner-patterns.md @@ -293,14 +293,14 @@ To keep the interactive experience responsive, always: ### MCP Tool Discovery -MCP 工具指令通过在系统提示中识别 `mcp__*` 前缀来发现。 +MCP tools are discovered by identifying the `mcp__*` prefix in system prompts. #### Discovery Method -1. **从系统提示提取:** 扫描 `` 中的 tool list,识别所有 `mcp__` 前缀的函数 -2. **使用 ListMcpResourcesTool:** 调用内置 MCP 查看所有连接的服务器资源 -3. **从 settings.json 读取:** 解析 `mcpServers` 获取服务器列表 -4. **从工具列表中获取 schema:** 工具的参数 schema 反映了其功能 +1. **Extract from system prompts:** Scan the tool list in ``, identify all functions with `mcp__` prefix +2. **Use ListMcpResourcesTool:** Invoke the built-in MCP to view all connected server resources +3. **Read from settings.json:** Parse `mcpServers` for the server list +4. **Get schema from the tool list:** A tool's parameter schema reflects its capabilities #### MCP Tool Naming Convention @@ -310,61 +310,61 @@ or mcp__{server-name}__{tool-name} Examples: -- mcp__plugin_github_github__create_pull_request → GitHub 插件 → create_pull_request 工具 -- mcp__plugin_context7_context7__query-docs → Context7 插件 → query-docs 工具 -- mcp__longhand__recall → Longhand 插件 → recall 工具 +- mcp__plugin_github_github__create_pull_request → GitHub plugin → create_pull_request tool +- mcp__plugin_context7_context7__query-docs → Context7 plugin → query-docs tool +- mcp__longhand__recall → Longhand plugin → recall tool ``` #### MCP Tool → Use Case Inference Rules | Tool Name Pattern | Inferred Purpose | Inferred Use Case | |-------------------|-----------------|-------------------| -| `create_*` | 创建资源 | 需要新建 PR/Issue/分支/文件时 | -| `search_*` | 搜索/查找 | 需要查找代码/文档/用户时 | -| `get_*` / `read_*` | 读取/获取 | 需要查看详情/内容时 | -| `list_*` | 列出集合 | 需要浏览列表/目录时 | -| `update_*` / `edit_*` | 修改资源 | 需要更新配置/内容时 | -| `delete_*` / `remove_*` | 删除资源 | 需要移除文件/资源时 | -| `query-*` | 查询文档 | 需要查阅 API/框架文档时 | -| `recall` / `find_*` | 回忆/记忆查找 | 需要查找历史会话/记忆时 | -| `replay_*` | 重放/回放 | 需要回溯历史状态时 | -| `resolve-*` | 解析/查找 ID | 需要查找库 ID 时 | +| `create_*` | Create resources | When creating new PRs/Issues/branches/files | +| `search_*` | Search / find | When searching for code/docs/users | +| `get_*` / `read_*` | Read / retrieve | When viewing details/content | +| `list_*` | List collections | When browsing lists/directories | +| `update_*` / `edit_*` | Modify resources | When updating config/content | +| `delete_*` / `remove_*` | Delete resources | When removing files/resources | +| `query-*` | Query documentation | When looking up API/framework docs | +| `recall` / `find_*` | Recall / memory lookup | When searching session history/memory | +| `replay_*` | Replay / trace back | When tracing historical state | +| `resolve-*` | Resolve / lookup ID | When looking up library IDs | ### Slash Command Discovery -Slash 命令在系统提示中以 `- name: description` 格式列出。 +Slash commands are listed in system prompts in the format `- name: description`. #### Discovery Method -1. 扫描系统提示中 "available skills" / slash commands 段落 -2. 命令格式: `- command-name: Description text` -3. 提取后按功能分类 +1. Scan the "available skills" / slash commands section in system prompts +2. Command format: `- command-name: Description text` +3. After extraction, categorize by function #### Slash Command Categories -| 分类 | 典型命令 | 通用适用场景 | -|------|---------|-------------| -| **Git 操作** | `/commit`, `/create-pr`, `/create-branch`, `/git-pushing`, `/clean_gone` | 代码版本管理 | -| **代码审查** | `/code-review`, `/review`, `/simplify`, `/security-review` | 代码质量保障 | -| **开发流程** | `/tdd`, `/feature-dev`, `/init`, `/setup` | 正规开发流程 | -| **调试与验证** | `/debug`, `/verify`, `/lint`, `/test` | 问题排查和修复验证 | -| **研究工作** | `/deep-research`, `/analyze`, `/explain` | 需求分析和调研 | -| **会话管理** | `/discover`, `/clear`, `/loop`, `/exit`, `/schedule` | 会话交互控制 | -| **配置管理** | `/config`, `/keybindings`, `/update-config`, `/install` | 环境和个人设置 | -| **文档与写作** | `/write-plan`, `/write-skill`, `/generate-docs` | 文档创建和维护 | -| **自动化** | `/hookify`, `/cron`, `/workflow` | 自动化工作流 | +| Category | Typical Commands | General Use Case | +|----------|-----------------|------------------| +| **Git Operations** | `/commit`, `/create-pr`, `/create-branch`, `/git-pushing`, `/clean_gone` | Code version management | +| **Code Review** | `/code-review`, `/review`, `/simplify`, `/security-review` | Code quality assurance | +| **Development Workflow** | `/tdd`, `/feature-dev`, `/init`, `/setup` | Formal development process | +| **Debugging & Verification** | `/debug`, `/verify`, `/lint`, `/test` | Issue troubleshooting and fix verification | +| **Research Work** | `/deep-research`, `/analyze`, `/explain` | Requirements analysis and research | +| **Session Management** | `/discover`, `/clear`, `/loop`, `/exit`, `/schedule` | Session interaction control | +| **Configuration Management** | `/config`, `/keybindings`, `/update-config`, `/install` | Environment and personal settings | +| **Documentation & Writing** | `/write-plan`, `/write-skill`, `/generate-docs` | Document creation and maintenance | +| **Automation** | `/hookify`, `/cron`, `/workflow` | Automated workflows | #### Command-to-Project Matching -| 项目阶段 | 最有用的 Slash 命令 | -|---------|-------------------| -| **项目初始化** | `/init`, `/setup`, `/discover` | -| **日常开发** | `/commit`, `/feature-dev`, `/code-review` | -| **调试修复** | `/debug`, `/verify`, `/test` | -| **代码审查** | `/review`, `/simplify`, `/code-review`, `/security-review` | -| **发布准备** | `/create-pr`, `/lint`, `/verify` | -| **学习探索** | `/explain`, `/analyze`, `/deep-research` | -| **会话管理** | `/clear`, `/loop`, `/exit`, `/discover` | +| Project Phase | Most Useful Slash Commands | +|---------------|---------------------------| +| **Project Initiation** | `/init`, `/setup`, `/discover` | +| **Daily Development** | `/commit`, `/feature-dev`, `/code-review` | +| **Debug & Fix** | `/debug`, `/verify`, `/test` | +| **Code Review** | `/review`, `/simplify`, `/code-review`, `/security-review` | +| **Release Preparation** | `/create-pr`, `/lint`, `/verify` | +| **Learning & Exploration** | `/explain`, `/analyze`, `/deep-research` | +| **Session Management** | `/clear`, `/loop`, `/exit`, `/discover` | ### Command Matching Algorithm @@ -411,7 +411,7 @@ Some plugins contain critical files that are NOT automatically loaded or indexed | `everything-claude-code` (ECC) | SOUL.md, RULES.md, AGENTS.md, CLAUDE.md, COMMANDS-QUICK-REF.md, WORKING-CONTEXT.md, the-security-guide.md, agent.yaml | Behavioral rules, security guides, agent configs | | `superpowers` | AGENTS.md, CLAUDE.md, GEMINI.md, hooks/hooks.json | Multi-platform agent behavior configs, hooks | | `andrej-karpathy-skills` | CLAUDE.md, CURSOR.md, .cursor/rules/karpathy-guidelines.mdc, skills/karpathy-guidelines/SKILL.md | Coding guidelines, nested skills, Cursor rules | -| `oh-my-claudecode` | .agents/skills/\*/\*.md (数十个嵌套技能) | Plugin-internal skills (may not appear in `~/.claude/skills/`) | +| `oh-my-claudecode` | .agents/skills/\*/\*.md (dozens of nested skills) | Plugin-internal skills (may not appear in `~/.claude/skills/`) | ### How to Deep-Explore @@ -473,13 +473,13 @@ The following fields extend the base JSON schema (see Discovery Rules JSON Schem When generating a full export, use these field tables: -**Per Skill:** 名称, 类别 (dev/meta/ops), 来源 (community/official/custom), 描述, 适用场景标签, 文件路径 +**Per Skill:** name, category (dev/meta/ops), source (community/official/custom), description, use-case tags, file path -**Per Plugin:** 名称, 类型 (stdio/sse/http), 命令/可执行文件, 描述, 来源 (MCP配置/本地插件目录) +**Per Plugin:** name, type (stdio/sse/http), command/executable, description, source (MCP config / local plugin directory) -**Per MCP Tool:** 工具名称, 所属插件, 作用, 适用场景 +**Per MCP Tool:** tool name, parent plugin, purpose, use case -**Per Slash Command:** 命令 (/name), 作用, 适用场景, 分类 (Git/审查/开发/调试/会话/设置) +**Per Slash Command:** command (/name), purpose, use case, category (Git/Review/Dev/Debug/Session/Config) --- @@ -498,7 +498,7 @@ The scanning logic in Step 2 is designed to be extensible. When new sources emer 2. **Deep exploration is REQUIRED** — always deep-scan ECC/superpowers/andrej-karpathy/OMC for SOUL.md, RULES.md, AGENTS.md, nested skills, and other unindexed resources 3. **Priority boost** — ECC, superpowers, andrej-karpathy-skills, and any deep resources always get ⭐ top placement 4. **Step 0c-5 commands come AFTER selection** — never show MCP tools or slash commands in Step 0c-4's initial recommendation -5. **Each command MUST include "作用" and "适用场景"** — describe what it does and when to use it +5. **Each command MUST include "purpose" and "use case"** — describe what it does and when to use it 6. **Step 0c-4 is MANDATORY** — always ask user after displaying recommendations 7. **Step 0c-6 requires consent** — always ask before exporting 8. **Respect "skip"** — don't re-recommend in the same session unless project context changes significantly diff --git a/skills/universal-project-kickoff/references/validation-scenarios.cn.md b/skills/universal-project-kickoff/references/validation-scenarios.cn.md new file mode 100644 index 0000000..3d9f5c4 --- /dev/null +++ b/skills/universal-project-kickoff/references/validation-scenarios.cn.md @@ -0,0 +1,226 @@ +# 验证场景 + +本文件提供一组验证场景,用于在执行 `universal-project-kickoff` 技能时进行 LLM 自检。按照场景描述执行扫描和匹配后,检查推荐结果是否符合预期。 + +## 测试场景 + +### 场景 1:标准 Spring Boot 项目 + +**项目特征:** +- 存在 `pom.xml`,含 `spring-boot-starter-parent` +- 存在 `src/main/java/` 目录 +- 存在 `application.yml` + +**预期指纹标签:** `java`, `spring-boot`, `maven` + +**预期推荐(至少包含):** +- `github-pr-manager`(always_recommend 默认) +- `universal-project-kickoff`(always_recommend 默认) + +**验证点:** +- [ ] 所有与 `java`、`spring-boot`、`maven` 标签匹配的技能得分 > 0 +- [ ] always_recommend 中的技能排在推荐列表最前面 +- [ ] 推荐数量不超过 `max_recommendations`(默认 10) + +--- + +### 场景 2:React + TypeScript 前端项目 + +**项目特征:** +- 存在 `package.json`,含 `react`、`typescript` dep +- 存在 `tsconfig.json` +- 存在 `vite.config.ts` + +**预期指纹标签:** `typescript`, `react`, `nodejs`, `vite` + +**预期推荐(至少包含):** +- `quick-plugin-installer`(插件安装相关) +- `github-pr-manager`(always_recommend) + +**验证点:** +- [ ] 与 `react`、`typescript` 标签匹配的得分+3 每标签 +- [ ] 与 `frontend` 领域对齐的技能获得 category_bonus + +--- + +### 场景 3:空项目 / 无任何配置文件 + +**项目特征:** +- 不存在任何可识别的配置文件 +- 可能是一个空目录或仅有 README + +**预期指纹标签:** 无(空集) + +**验证点:** +- [ ] 不应报错或中断 +- [ ] always_recommend 列表中的技能仍被推荐(作为通用推荐) +- [ ] always_recommend_plugins 中的插件仍被推荐 + +--- + +### 场景 4:Python FastAPI 项目 + +**项目特征:** +- 存在 `pyproject.toml`,含 `fastapi` dep +- 存在 `requirements.txt`,含 `fastapi` + +**预期指纹标签:** `python`, `fastapi` + +**验证点:** +- [ ] 不会因为 `pyproject.toml` 和 `requirements.txt` 同时存在而重复打分(去重) +- [ ] 与 `python` 标签匹配的技能获得+3 + +--- + +### 场景 5:Monorepo(多语言项目) + +**项目特征:** +- 存在 `package.json`(前端子目录) +- 存在 `go.mod`(后端子目录) +- 存在 `docker-compose.yml`(根目录) + +**预期指纹标签:** `javascript`/`typescript`, `nodejs`, `go`, `docker`, `orchestration` + +**验证点:** +- [ ] 所有检测到的标签都被包含(不会因为找到第一个语言就停止) +- [ ] 推荐技能涵盖所有检测到的技术栈 + +--- + +### 场景 6:Flutter 移动端项目 + +**项目特征:** +- 存在 `pubspec.yaml`,含 `flutter` dep +- 存在 `android/` 和 `ios/` 目录 + +**预期指纹标签:** `flutter`, `dart`, `mobile`, `cross-platform`, `android`, `ios` + +**验证点:** +- [ ] 移动端框架检测生效(Phase 4 新增的检测矩阵) +- [ ] `mobile` domain 的 category_bonus 正确应用 + +--- + +### 场景 7:纯 Docker 项目 + +**项目特征:** +- 仅存在 `Dockerfile` 和 `docker-compose.yml` +- 无其他语言配置文件 + +**预期指纹标签:** `docker`, `container`, `orchestration` + +**验证点:** +- [ ] 不会因为没有语言标签而报错 +- [ ] DevOps/Infra 类技能获得 category_bonus + +--- + +### 场景 8:Java 8 老项目(版本检测) + +**项目特征:** +- 存在 `pom.xml`,`` 为 `1.8` +- 存在 `src/main/java/` 目录 + +**预期指纹标签:** `java`, `java-8`, `maven` + +**验证点:** +- [ ] 版本标签 `java-8` 被正确提取 +- [ ] 带 `java-21` 标签的技能仅获得+1(base `java` 匹配),而非+3 + +--- + +## 边界情况检查清单 + +| 边界情况 | 预期行为 | +|---------|---------| +| 空目录 | 不报错,仅推荐 always_recommend 列表 | +| 非 git 目录 | 正常扫描,不依赖 git context | +| Glob 超时 | 静默降级,标注部分扫描未完成 | +| 技能目录为空 | 仅推荐插件和命令 | +| settings.json 不存在 | 仅推荐技能,跳过插件扫描 | +| SKILL.md frontmatter 格式错误 | 跳过该技能,继续扫描其他 | +| 超大型项目(1000+ 文件) | 限制 Glob 深度,优先检查根目录配置文件 | + +## 使用方式 + +执行技能后,对照本文件中的场景和边界情况进行验证。若发现推荐结果与预期不符,检查: +1. 指纹检测是否正确识别了所有配置文件 +2. 标签匹配算法是否应用了正确的权重 +3. 是否有 always_recommend/never_recommend 规则干扰 + +--- + +## 完整走查示例 + +### 示例 1: Java Spring Boot 项目 + +**输入:** 用户打开包含 `pom.xml` 的项目,pom.xml 中有 `spring-boot-starter-parent`。 + +**项目指纹:** `java, spring-boot, maven` + +**推荐技能 (top 5):** +| # | 名称 | 描述 | 匹配理由 | 来源 | +|---|------|------|---------|------| +| 1 | `springboot-patterns` | Spring Boot 开发模式 | Spring Boot 框架直接匹配 | community | +| 2 | `java-pro` | Java 专业开发 | Java 语言匹配 | community | +| 3 | `springboot-tdd` | TDD 开发流程 | Spring Boot + 测试匹配 | community | +| 4 | `springboot-security` | Spring Boot 安全 | Spring Boot 框架匹配 | community | +| 5 | `git-workflow` | Git 工作流 | 通用开发技能 | community | + +**推荐插件:** +| # | 名称 | 描述 | 匹配理由 | 类型 | +|---|------|------|---------|------| +| 1 | `plugin:github:github` | GitHub PR/Issue 管理 | 通用开发插件 | MCP | +| 2 | `plugin:context7:context7` | 文档查询 | 查阅 Spring Boot 文档 | MCP | + +**用户选择 github 和 context7 后,指令发现展示:** +MCP 工具: `mcp__github__create_pull_request`(创建 PR,提交代码后需要发起合并请求时)、`mcp__context7__query-docs`(查询文档,需要查阅 Spring Boot API 时)。Slash 命令: `/commit`(规范化提交)、`/code-review`(审查代码)、`/create-pr`(创建 Pull Request)。 + +### 示例 2: React + Vite 前端项目 + +**输入:** 用户打开包含 `package.json` (react, vite deps) 和 `vite.config.ts` 的项目。 + +**项目指纹:** `javascript/typescript, react, vite, nodejs` + +**推荐技能 (top 5):** +| # | 名称 | 描述 | 匹配理由 | 来源 | +|---|------|------|---------|------| +| 1 | `react-best-practices` | React 最佳实践 | React 框架直接匹配 | community | +| 2 | `frontend-patterns` | 前端开发模式 | 前端领域匹配 | community | +| 3 | `javascript-pro` | JS 专业开发 | JavaScript 语言匹配 | community | +| 4 | `vite-patterns` | Vite 构建模式 | Vite 工具匹配 | community | +| 5 | `ui-ux-designer` | UI/UX 设计 | 前端领域相关 | community | + +**推荐插件:** +| # | 名称 | 描述 | 匹配理由 | 类型 | +|---|------|------|---------|------| +| 1 | `plugin:playwright:playwright` | 浏览器自动化测试 | 前端 E2E 测试 | MCP | +| 2 | `plugin:github:github` | PR 管理 | 通用开发插件 | MCP | + +**用户选择后指令:** `mcp__github__search_code`(搜索代码)、`mcp__github__create_pull_request`(创建 PR)。Slash 命令: `/frontend-design`(前端设计)、`/code-review`(审查代码)、`/commit`(提交)。 + +### 示例 3: 未知/空项目 + +**输入:** 空目录或无任何已知配置文件的目录。 + +**项目指纹:** (无 — 空目录或未检测到已知配置文件) + +**检测结果:** "🆕 未检测到已知项目类型。以下是通用推荐:" + +**推荐技能 (通用):** +| # | 名称 | 描述 | 匹配理由 | 来源 | +|---|------|------|---------|------| +| 1 | `git-workflow` | Git 工作流 | 通用开发技能 | community | +| 2 | `code-review` | 代码审查 | 通用开发技能 | community | +| 3 | `commit` | 规范化提交 | 通用开发技能 | community | +| 4 | `file-organizer` | 文件整理 | 通用辅助技能 | community | + +**推荐插件 (通用):** +| # | 名称 | 描述 | 匹配理由 | 类型 | +|---|------|------|---------|------| +| 1 | `plugin:github:github` | PR/Issue 管理 | 通用开发插件 | MCP | +| 2 | `plugin:longhand:longhand` | 会话记忆 | 通用辅助插件 | MCP | + +**用户选择后指令:** `/commit`(提交代码时)、`/code-review`(审查代码时)、`/discover`(重新发现时) + +**行为:** 提示用户:"如需查看所有已安装的能力,可以为你导出完整列表。" diff --git a/skills/universal-project-kickoff/references/validation-scenarios.md b/skills/universal-project-kickoff/references/validation-scenarios.md index 3d9f5c4..ba0cbdc 100644 --- a/skills/universal-project-kickoff/references/validation-scenarios.md +++ b/skills/universal-project-kickoff/references/validation-scenarios.md @@ -1,226 +1,226 @@ -# 验证场景 +# Validation Scenarios -本文件提供一组验证场景,用于在执行 `universal-project-kickoff` 技能时进行 LLM 自检。按照场景描述执行扫描和匹配后,检查推荐结果是否符合预期。 +This document provides a set of validation scenarios for LLM self-checking when executing the `universal-project-kickoff` skill. After performing scanning and matching according to the scenario descriptions, verify that the recommendation results meet expectations. -## 测试场景 +## Test Scenarios -### 场景 1:标准 Spring Boot 项目 +### Scenario 1: Standard Spring Boot Project -**项目特征:** -- 存在 `pom.xml`,含 `spring-boot-starter-parent` -- 存在 `src/main/java/` 目录 -- 存在 `application.yml` +**Project characteristics:** +- `pom.xml` exists, contains `spring-boot-starter-parent` +- `src/main/java/` directory exists +- `application.yml` exists -**预期指纹标签:** `java`, `spring-boot`, `maven` +**Expected fingerprint tags:** `java`, `spring-boot`, `maven` -**预期推荐(至少包含):** -- `github-pr-manager`(always_recommend 默认) -- `universal-project-kickoff`(always_recommend 默认) +**Expected recommendations (at minimum):** +- `github-pr-manager` (default always_recommend) +- `universal-project-kickoff` (default always_recommend) -**验证点:** -- [ ] 所有与 `java`、`spring-boot`、`maven` 标签匹配的技能得分 > 0 -- [ ] always_recommend 中的技能排在推荐列表最前面 -- [ ] 推荐数量不超过 `max_recommendations`(默认 10) +**Verification points:** +- [ ] All skills matching `java`, `spring-boot`, `maven` tags have score > 0 +- [ ] Skills in always_recommend appear at the top of the recommendation list +- [ ] Recommendation count does not exceed `max_recommendations` (default 10) --- -### 场景 2:React + TypeScript 前端项目 +### Scenario 2: React + TypeScript Frontend Project -**项目特征:** -- 存在 `package.json`,含 `react`、`typescript` dep -- 存在 `tsconfig.json` -- 存在 `vite.config.ts` +**Project characteristics:** +- `package.json` exists, contains `react` and `typescript` deps +- `tsconfig.json` exists +- `vite.config.ts` exists -**预期指纹标签:** `typescript`, `react`, `nodejs`, `vite` +**Expected fingerprint tags:** `typescript`, `react`, `nodejs`, `vite` -**预期推荐(至少包含):** -- `quick-plugin-installer`(插件安装相关) -- `github-pr-manager`(always_recommend) +**Expected recommendations (at minimum):** +- `quick-plugin-installer` (plugin installation related) +- `github-pr-manager` (always_recommend) -**验证点:** -- [ ] 与 `react`、`typescript` 标签匹配的得分+3 每标签 -- [ ] 与 `frontend` 领域对齐的技能获得 category_bonus +**Verification points:** +- [ ] Skills matching `react`, `typescript` tags receive +3 per tag +- [ ] Skills aligned with the `frontend` domain receive category_bonus --- -### 场景 3:空项目 / 无任何配置文件 +### Scenario 3: Empty Project / No Configuration Files -**项目特征:** -- 不存在任何可识别的配置文件 -- 可能是一个空目录或仅有 README +**Project characteristics:** +- No recognizable configuration files exist +- May be an empty directory or contain only a README -**预期指纹标签:** 无(空集) +**Expected fingerprint tags:** None (empty set) -**验证点:** -- [ ] 不应报错或中断 -- [ ] always_recommend 列表中的技能仍被推荐(作为通用推荐) -- [ ] always_recommend_plugins 中的插件仍被推荐 +**Verification points:** +- [ ] Should not error or abort +- [ ] Skills in the always_recommend list are still recommended (as general recommendations) +- [ ] Plugins in always_recommend_plugins are still recommended --- -### 场景 4:Python FastAPI 项目 +### Scenario 4: Python FastAPI Project -**项目特征:** -- 存在 `pyproject.toml`,含 `fastapi` dep -- 存在 `requirements.txt`,含 `fastapi` +**Project characteristics:** +- `pyproject.toml` exists, contains `fastapi` dep +- `requirements.txt` exists, contains `fastapi` -**预期指纹标签:** `python`, `fastapi` +**Expected fingerprint tags:** `python`, `fastapi` -**验证点:** -- [ ] 不会因为 `pyproject.toml` 和 `requirements.txt` 同时存在而重复打分(去重) -- [ ] 与 `python` 标签匹配的技能获得+3 +**Verification points:** +- [ ] No duplicate scoring because both `pyproject.toml` and `requirements.txt` exist (deduplication) +- [ ] Skills matching the `python` tag receive +3 --- -### 场景 5:Monorepo(多语言项目) +### Scenario 5: Monorepo (Multi-language Project) -**项目特征:** -- 存在 `package.json`(前端子目录) -- 存在 `go.mod`(后端子目录) -- 存在 `docker-compose.yml`(根目录) +**Project characteristics:** +- `package.json` exists (frontend subdirectory) +- `go.mod` exists (backend subdirectory) +- `docker-compose.yml` exists (root directory) -**预期指纹标签:** `javascript`/`typescript`, `nodejs`, `go`, `docker`, `orchestration` +**Expected fingerprint tags:** `javascript`/`typescript`, `nodejs`, `go`, `docker`, `orchestration` -**验证点:** -- [ ] 所有检测到的标签都被包含(不会因为找到第一个语言就停止) -- [ ] 推荐技能涵盖所有检测到的技术栈 +**Verification points:** +- [ ] All detected tags are included (does not stop after finding the first language) +- [ ] Recommended skills cover all detected technology stacks --- -### 场景 6:Flutter 移动端项目 +### Scenario 6: Flutter Mobile Project -**项目特征:** -- 存在 `pubspec.yaml`,含 `flutter` dep -- 存在 `android/` 和 `ios/` 目录 +**Project characteristics:** +- `pubspec.yaml` exists, contains `flutter` dep +- `android/` and `ios/` directories exist -**预期指纹标签:** `flutter`, `dart`, `mobile`, `cross-platform`, `android`, `ios` +**Expected fingerprint tags:** `flutter`, `dart`, `mobile`, `cross-platform`, `android`, `ios` -**验证点:** -- [ ] 移动端框架检测生效(Phase 4 新增的检测矩阵) -- [ ] `mobile` domain 的 category_bonus 正确应用 +**Verification points:** +- [ ] Mobile framework detection is active (detection matrix added in Phase 4) +- [ ] `mobile` domain category_bonus is correctly applied --- -### 场景 7:纯 Docker 项目 +### Scenario 7: Pure Docker Project -**项目特征:** -- 仅存在 `Dockerfile` 和 `docker-compose.yml` -- 无其他语言配置文件 +**Project characteristics:** +- Only `Dockerfile` and `docker-compose.yml` exist +- No other language configuration files -**预期指纹标签:** `docker`, `container`, `orchestration` +**Expected fingerprint tags:** `docker`, `container`, `orchestration` -**验证点:** -- [ ] 不会因为没有语言标签而报错 -- [ ] DevOps/Infra 类技能获得 category_bonus +**Verification points:** +- [ ] Does not error due to absence of language tags +- [ ] DevOps/Infra category skills receive category_bonus --- -### 场景 8:Java 8 老项目(版本检测) +### Scenario 8: Legacy Java 8 Project (Version Detection) -**项目特征:** -- 存在 `pom.xml`,`` 为 `1.8` -- 存在 `src/main/java/` 目录 +**Project characteristics:** +- `pom.xml` exists, `` is `1.8` +- `src/main/java/` directory exists -**预期指纹标签:** `java`, `java-8`, `maven` +**Expected fingerprint tags:** `java`, `java-8`, `maven` -**验证点:** -- [ ] 版本标签 `java-8` 被正确提取 -- [ ] 带 `java-21` 标签的技能仅获得+1(base `java` 匹配),而非+3 +**Verification points:** +- [ ] Version tag `java-8` is correctly extracted +- [ ] Skills tagged with `java-21` receive only +1 (base `java` match), not +3 --- -## 边界情况检查清单 +## Edge Case Checklist -| 边界情况 | 预期行为 | -|---------|---------| -| 空目录 | 不报错,仅推荐 always_recommend 列表 | -| 非 git 目录 | 正常扫描,不依赖 git context | -| Glob 超时 | 静默降级,标注部分扫描未完成 | -| 技能目录为空 | 仅推荐插件和命令 | -| settings.json 不存在 | 仅推荐技能,跳过插件扫描 | -| SKILL.md frontmatter 格式错误 | 跳过该技能,继续扫描其他 | -| 超大型项目(1000+ 文件) | 限制 Glob 深度,优先检查根目录配置文件 | +| Edge Case | Expected Behavior | +|-----------|------------------| +| Empty directory | No error, only recommend always_recommend list | +| Non-git directory | Normal scanning, does not depend on git context | +| Glob timeout | Silent degradation, mark partial scan as incomplete | +| Empty skill directory | Only recommend plugins and commands | +| settings.json does not exist | Only recommend skills, skip plugin scanning | +| SKILL.md frontmatter format error | Skip that skill, continue scanning others | +| Very large project (1000+ files) | Limit Glob depth, prioritize root directory config files | -## 使用方式 +## Usage -执行技能后,对照本文件中的场景和边界情况进行验证。若发现推荐结果与预期不符,检查: -1. 指纹检测是否正确识别了所有配置文件 -2. 标签匹配算法是否应用了正确的权重 -3. 是否有 always_recommend/never_recommend 规则干扰 +After executing the skill, verify against the scenarios and edge cases in this document. If the recommendation results do not match expectations, check: +1. Whether fingerprint detection correctly identified all configuration files +2. Whether the tag matching algorithm applied the correct weights +3. Whether any always_recommend/never_recommend rules are interfering --- -## 完整走查示例 +## Complete Walkthrough Examples -### 示例 1: Java Spring Boot 项目 +### Example 1: Java Spring Boot Project -**输入:** 用户打开包含 `pom.xml` 的项目,pom.xml 中有 `spring-boot-starter-parent`。 +**Input:** User opens a project containing `pom.xml` with `spring-boot-starter-parent`. -**项目指纹:** `java, spring-boot, maven` +**Project fingerprint:** `java, spring-boot, maven` -**推荐技能 (top 5):** -| # | 名称 | 描述 | 匹配理由 | 来源 | -|---|------|------|---------|------| -| 1 | `springboot-patterns` | Spring Boot 开发模式 | Spring Boot 框架直接匹配 | community | -| 2 | `java-pro` | Java 专业开发 | Java 语言匹配 | community | -| 3 | `springboot-tdd` | TDD 开发流程 | Spring Boot + 测试匹配 | community | -| 4 | `springboot-security` | Spring Boot 安全 | Spring Boot 框架匹配 | community | -| 5 | `git-workflow` | Git 工作流 | 通用开发技能 | community | +**Recommended skills (top 5):** +| # | Name | Description | Match Reason | Source | +|---|------|-------------|-------------|--------| +| 1 | `springboot-patterns` | Spring Boot development patterns | Direct Spring Boot framework match | community | +| 2 | `java-pro` | Java professional development | Java language match | community | +| 3 | `springboot-tdd` | TDD development workflow | Spring Boot + testing match | community | +| 4 | `springboot-security` | Spring Boot security | Spring Boot framework match | community | +| 5 | `git-workflow` | Git workflow | General development skill | community | -**推荐插件:** -| # | 名称 | 描述 | 匹配理由 | 类型 | -|---|------|------|---------|------| -| 1 | `plugin:github:github` | GitHub PR/Issue 管理 | 通用开发插件 | MCP | -| 2 | `plugin:context7:context7` | 文档查询 | 查阅 Spring Boot 文档 | MCP | +**Recommended plugins:** +| # | Name | Description | Match Reason | Type | +|---|------|-------------|-------------|------| +| 1 | `plugin:github:github` | GitHub PR/Issue management | General development plugin | MCP | +| 2 | `plugin:context7:context7` | Documentation lookup | Referencing Spring Boot docs | MCP | -**用户选择 github 和 context7 后,指令发现展示:** -MCP 工具: `mcp__github__create_pull_request`(创建 PR,提交代码后需要发起合并请求时)、`mcp__context7__query-docs`(查询文档,需要查阅 Spring Boot API 时)。Slash 命令: `/commit`(规范化提交)、`/code-review`(审查代码)、`/create-pr`(创建 Pull Request)。 +**Command discovery after user selects github and context7:** +MCP tools: `mcp__github__create_pull_request` (create PR, when needing to submit a merge request after committing), `mcp__context7__query-docs` (query documentation, when needing to look up Spring Boot API). Slash commands: `/commit` (standardized commits), `/code-review` (review code), `/create-pr` (create Pull Request). -### 示例 2: React + Vite 前端项目 +### Example 2: React + Vite Frontend Project -**输入:** 用户打开包含 `package.json` (react, vite deps) 和 `vite.config.ts` 的项目。 +**Input:** User opens a project containing `package.json` (react, vite deps) and `vite.config.ts`. -**项目指纹:** `javascript/typescript, react, vite, nodejs` +**Project fingerprint:** `javascript/typescript, react, vite, nodejs` -**推荐技能 (top 5):** -| # | 名称 | 描述 | 匹配理由 | 来源 | -|---|------|------|---------|------| -| 1 | `react-best-practices` | React 最佳实践 | React 框架直接匹配 | community | -| 2 | `frontend-patterns` | 前端开发模式 | 前端领域匹配 | community | -| 3 | `javascript-pro` | JS 专业开发 | JavaScript 语言匹配 | community | -| 4 | `vite-patterns` | Vite 构建模式 | Vite 工具匹配 | community | -| 5 | `ui-ux-designer` | UI/UX 设计 | 前端领域相关 | community | +**Recommended skills (top 5):** +| # | Name | Description | Match Reason | Source | +|---|------|-------------|-------------|--------| +| 1 | `react-best-practices` | React best practices | Direct React framework match | community | +| 2 | `frontend-patterns` | Frontend development patterns | Frontend domain match | community | +| 3 | `javascript-pro` | JS professional development | JavaScript language match | community | +| 4 | `vite-patterns` | Vite build patterns | Vite tool match | community | +| 5 | `ui-ux-designer` | UI/UX design | Frontend domain related | community | -**推荐插件:** -| # | 名称 | 描述 | 匹配理由 | 类型 | -|---|------|------|---------|------| -| 1 | `plugin:playwright:playwright` | 浏览器自动化测试 | 前端 E2E 测试 | MCP | -| 2 | `plugin:github:github` | PR 管理 | 通用开发插件 | MCP | +**Recommended plugins:** +| # | Name | Description | Match Reason | Type | +|---|------|-------------|-------------|------| +| 1 | `plugin:playwright:playwright` | Browser automation testing | Frontend E2E testing | MCP | +| 2 | `plugin:github:github` | PR management | General development plugin | MCP | -**用户选择后指令:** `mcp__github__search_code`(搜索代码)、`mcp__github__create_pull_request`(创建 PR)。Slash 命令: `/frontend-design`(前端设计)、`/code-review`(审查代码)、`/commit`(提交)。 +**Commands after user selection:** `mcp__github__search_code` (search code), `mcp__github__create_pull_request` (create PR). Slash commands: `/frontend-design` (frontend design), `/code-review` (review code), `/commit` (commit). -### 示例 3: 未知/空项目 +### Example 3: Unknown/Empty Project -**输入:** 空目录或无任何已知配置文件的目录。 +**Input:** Empty directory or a directory with no known configuration files. -**项目指纹:** (无 — 空目录或未检测到已知配置文件) +**Project fingerprint:** (None -- empty directory or no known config files detected) -**检测结果:** "🆕 未检测到已知项目类型。以下是通用推荐:" +**Detection result:** "\u{1F195} No known project type detected. Here are general recommendations:" -**推荐技能 (通用):** -| # | 名称 | 描述 | 匹配理由 | 来源 | -|---|------|------|---------|------| -| 1 | `git-workflow` | Git 工作流 | 通用开发技能 | community | -| 2 | `code-review` | 代码审查 | 通用开发技能 | community | -| 3 | `commit` | 规范化提交 | 通用开发技能 | community | -| 4 | `file-organizer` | 文件整理 | 通用辅助技能 | community | +**Recommended skills (general):** +| # | Name | Description | Match Reason | Source | +|---|------|-------------|-------------|--------| +| 1 | `git-workflow` | Git workflow | General development skill | community | +| 2 | `code-review` | Code review | General development skill | community | +| 3 | `commit` | Standardized commits | General development skill | community | +| 4 | `file-organizer` | File organization | General utility skill | community | -**推荐插件 (通用):** -| # | 名称 | 描述 | 匹配理由 | 类型 | -|---|------|------|---------|------| -| 1 | `plugin:github:github` | PR/Issue 管理 | 通用开发插件 | MCP | -| 2 | `plugin:longhand:longhand` | 会话记忆 | 通用辅助插件 | MCP | +**Recommended plugins (general):** +| # | Name | Description | Match Reason | Type | +|---|------|-------------|-------------|------| +| 1 | `plugin:github:github` | PR/Issue management | General development plugin | MCP | +| 2 | `plugin:longhand:longhand` | Session memory | General utility plugin | MCP | -**用户选择后指令:** `/commit`(提交代码时)、`/code-review`(审查代码时)、`/discover`(重新发现时) +**Commands after user selection:** `/commit` (when committing code), `/code-review` (when reviewing code), `/discover` (when rediscovering) -**行为:** 提示用户:"如需查看所有已安装的能力,可以为你导出完整列表。" +**Behavior:** Prompt the user: "If you'd like to see a full list of all installed capabilities, I can export the complete catalog for you."