SuperAPI AI 工具集

oss-pr

编程与开发

查看项目

更新于 10-15 22:38

技能介绍

用途:oss-pr 是一个智能提交与 PR 工作流技能,用于在提交变更后或用户调用 /oss-pr 时,自动完成分支管理、质量检查、测试、提交、推送和创建拉取请求。开始时会提示“Using oss-pr skill to commit and open a pull request.”。

主要能力与流程:

  1. 收集信息:运行 git branch --show-current、git diff --name-only HEAD、git status --short、git config user.name。若已在功能分支则直接继续;若在 main 或 master 上,则根据变更文件自动推断类型(feat/fix/refactor/chore)和 2–3 个小写单词的 slug,直接创建并切换到 {username}/{type}/{slug} 分支,无需确认。
  2. 质量检查:按顺序运行 bun run format(始终运行)、bun run lint(仅当有 .ts/.tsx 变更)、bunx tsc --noEmit(仅当有 .ts/.tsx 变更)。若修改了 src/renderer/、locales/ 或 src/common/config/i18n 相关文件,还需运行 bun run i18n:types 和 node scripts/check-i18n.js。lint、tsc 或 i18n:types 失败则停止并报告;check-i18n 退出码 1 则停止,退出码 0(仅警告)则继续。
  3. 运行测试:bunx vitest run,失败则停止并报告。
  4. 提交:git status、git diff,然后 git add -u 暂存所有修改文件(包括 format 自动修复的文件)。使用 conventional commits 格式生成英文提交信息,禁止包含 Co-authored-by 或任何 AI 署名。
  5. 推送:git push -u origin <branch-name>。若因远程拒绝失败则告知用户,未经明确批准绝不强制推送。
  6. 创建 PR:运行 git log main..HEAD --oneline 和 git diff main...HEAD 了解变更,然后使用 gh pr create 创建 PR,标题不超过 70 字符,格式为 <type>(<scope>): <description>,正文包含 Summary 和 Test plan。禁止添加 AI 生成签名、Generated with 或 Co-Authored-By 行。
  7. 完成后输出 PR URL。

适用场景:适用于需要规范化提交和创建 PR 的 Git 仓库,尤其是使用 bun、vitest 和 gh CLI 的项目。

限制:依赖 bun、vitest、gh 等工具;分支命名和提交信息有固定规则;不执行强制推送;不添加 AI 署名。