Dev pr

From pdl-openair/OpenAIR · View interactive version

Dev pr is an AI agent skill from the GitHub repository pdl-openair/OpenAIR. 开发者准备创建 Pull Request 时触发。当用户说"建 PR"、"PR description"、 "写 PR body"、"create pull request"、"PR 文案"、"生成 PR 描述"时使用本 skill。 基于真实 git diff 填充项目 PR 模板;标题与正文须用 reviewer 可读的能力描述, 禁止以 P07/P08/P2.6b 等内部代号作主语。不自动创建 PR,除非用户明确要求。

How to use this skill

Skill file

Dev: PR Description Generation

When to use

开发者准备创建 PR,需要基于 diff 生成 PR description。

本地门禁提示:pre-commit 钩子经 python scripts/gates/run_local.py 运行,依赖 PATH python 装有 ruff/mypy——缺失时钩子降级为警告放行,CI 兜底强制(见 CONTRIBUTING.md 第 8 节)。

Step 1: Read diff and extract changes

  1. Run git log <base>..HEAD --oneline to see all commits
  2. Run git diff <base>...HEAD to see full diff
  3. From the diff, extract:

Step 2: Link GitHub Issues (conditional: required when gh CLI is available)

Generate the diff summary, then match open Issues in the repo to fill the「关联任务」section.

Gate 0 — Tool check: run gh --version. If it fails, skip this entire step and append a note to the PR description:

💡 未检测到 gh CLI,无法自动关联 Issue。安装方式:https://cli.github.com ,安装后可用 gh issue list 查看 Issue。

If it succeeds, must complete all sub-steps below before proceeding.

Steps

  1. Fetch open Issues (tool already confirmed at Gate 0):

```bash

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

gh issue list --repo <owner/repo> --state open --limit 50 --json number,title,labels --output /tmp/gh_issues.json

```

> PowerShell 编码问题:JSON 输出中文可能乱码,需要 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8,或用 --json 写文件后读取。

  1. Semantic matching: compare PR diff summary with each Issue's title / labels:
  1. Determine Ref / Closes:
  1. Write into「关联任务」section of the PR description

Example output

## 关联任务

Closes #12
Ref #13

Gate: Issue linking confirmation

Only after confirming all items, proceed to Step 3.

Step 3: Link Feishu tasks (conditional: required when lark-cli is available)

Match PR changes against Feishu Bitable tasks and prompt user about completion status and next actions.

Gate 0 — Tool check: run lark-cli --version. If it fails, skip this entire step and append a note to the PR description:

💡 未检测到 lark-cli,无法自动关联飞书任务。安装方式:https://www.feishu.cn/feishu-cli ,安装后可读取飞书多维表格任务。

If it succeeds, must complete all sub-steps below before proceeding.

Steps

  1. Locate target Bitable (tool already confirmed at Gate 0):
  1. Parse Wiki link and read table:

```bash

# Wiki token → Base token

lark-cli wiki spaces get_node --params "@./tmp_params.json" --as user

# Read field structure

lark-cli base +field-list --base-token "<obj_token>" --table-id "<tbl...>" --as user

# Read records

lark-cli base +record-list --base-token "<obj_token>" --table-id "<tbl...>" --view-id "<vew...>" --as user --limit 200

```

> PowerShell 注意事项:中文需设 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;--params 用文件传参避免转义问题;字段名含空格时用字段 ID。

  1. Semantic matching: compare PR diff summary with Feishu subtasks (subtask number + name + description).
  2. Output match results, including:

Example output

## 飞书任务关联

匹配到飞书任务:

| 子任务编号 | 子任务名称 | 当前状态 | 负责人 |
|-----------|-----------|---------|-------|
| S01-02-01 | 确定首批联调样例范围 | 待核查 | xxx |
| S01-02-02 | 准备正常流程样例 | 待核查 | xxx |

验收标准检查:
- [ ] S01-02-02: 正常流程样例数据尚未提交(fixtures/recorded_runs/ 下无新增)

建议:S01-02-02 完成后,在飞书表格中将状态从「待核查」更新为「已完成」。

Gate: Feishu task linking confirmation

Only after confirming all items, proceed to Step 4.

Step 4: Generate PR description

Rules source

Read before generating:

PR 证据合同要点(会咬人的硬事实,权威见 pr-workflow.md)

Style (concise-first)

可读性:禁止内部代号当主语(必须)

PR 标题与「改了什么」面向 未读过 task spec 的 reviewer,不得假设对方懂内部编号。

禁止:

必须:

OpenTrajectory 对照(可类推其他 pack):

| 内部代号 | PR 中应写 |

|---|---|

| P07 链路 | 执行验证阶段:检索 → 阅读 → 证据模型 → 证据抽取 → 机制链 |

| P07a | 学术文献检索 |

| P07b | DeepXiv 渐进式阅读 |

| P07c | 证据节点抽取(含逐字引用校验) |

| P07d | 机制链合成 |

| P07f | 证据模型(EvidenceSchema)设计 |

| P08b-1c | bounded live smoke 编排(默认 dry-run,不触发真实 API) |

| P2.6b | Workbench 证据产物来源恢复(复制链接/来源信息) |

标题示例:

Step 4 出口 Gate:

Co-author(必须)

PR 关联的 commit 必须在 commit message 中加 Co-authored-by 标记协作 Agent。

格式:

Co-authored-by: qoder <qoder@users.noreply.github.com>
Co-authored-by: cursor <cursor@users.noreply.github.com>
Co-authored-by: claude-code <claude-code@users.noreply.github.com>
Co-authored-by: gpt <gpt@users.noreply.github.com>

规则:

Output

Filled PR template with: what changed, linked tasks (GitHub + 飞书), modified files, how to verify, impact checklist.

Step 5: Assign Reviewer & 飞书通知(conditional: gh + lark-cli available)

PR 创建后,必须 assign 一名 reviewer(不能是自己),并通过飞书通知被 assign 的人。

5.1 确定 Reviewer

选择规则:

5.2 Assign Reviewer(gh CLI)

Gate 0 — Tool check: run gh --version. If it fails, skip and remind:

💡 未检测到 gh CLI,请手动在 GitHub PR 页面 assign reviewer。

gh pr edit <pr_number> --add-reviewer <reviewer_github_username>

5.3 飞书通知 Reviewer(lark-cli)

查找通知对象
  1. 从 PR 作者 / Issue assignee / spec 负责人提取 GitHub 用户名
  2. 优先查本地映射:读取 docs/dev_skills/github-feishu-mapping.md,按 GitHub 用户名匹配飞书 open_id
  3. 本地映射未命中时,用 lark-cli contact +search-user --query "姓名" --as user --format json 查找对应飞书 open_id
  4. 搜不到时:用 AskUserQuestion 请用户提供飞书姓名,不要直接放弃
  5. 找到新映射后,补充到 github-feishu-mapping.md 中,后续直接复用
  6. 记录 open_id(ou_xxx 格式),供后续发消息使用

Gate 1 — Tool check: run lark-cli --version. If it fails, skip and remind:

💡 未检测到 lark-cli,无法自动发送飞书通知,请手动提醒 reviewer。

If available:

  1. 确定 reviewer 的飞书 user_id(从团队通讯录或项目配置获取)
  2. 生成通知消息:
📬 你被指派为 PR #{pr_number} 的 Reviewer
标题:{pr_title}
仓库:{repo}
链接:{pr_url}
提交人:{author}
请及时审阅,谢谢!
  1. 发送:
# lark-cli 发消息的正确用法(注意:不是 lark-cli message send)
# 发给个人(用 open_id)
lark-cli im +messages-send --user-id "<reviewer_open_id>" --text '消息内容' --as user

# 发到群聊(用 chat_id)
lark-cli im +messages-send --chat-id "<chat_id>" --text '消息内容' --as user

# Markdown 富文本
lark-cli im +messages-send --user-id "<reviewer_open_id>" --markdown '**标题**\n内容' --as user

常见错误:不要使用 lark-cli message send(不存在)、--receive-id-type(不存在)、--receive-id(不存在)。正确子命令是 lark-cli im +messages-send,用 --user-id 或 --chat-id 指定接收者。

发送前必须确认用户同意(列出消息内容和发送对象,等确认后执行)。

Gate: Reviewer assignment & notification

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.