Skip to content

feat(agent): use repository PR templates and contributing rules before draft PR creation #77

Description

@dangzitou

背景

当前 OpenMeta 可以完成通用的 PR 创建流程:

  • fork 仓库
  • 创建分支
  • 生成 PR draft
  • 向上游仓库发起 draft PR

但从当前实现看,PR 标题、正文、branch naming、commit message 主要来自 OpenMeta 自己的固定逻辑和模型生成结果,而不是目标仓库的实际贡献规则。

这会带来一个问题:

PR 可能在技术上合理,但在仓库规则层面不合规。

例如:

  • 没有遵循 CONTRIBUTING.md
  • 没有套用 .github/PULL_REQUEST_TEMPLATE.md
  • 没有满足 checklist 要求
  • 分支命名不符合项目约定
  • commit message 不符合仓库规范
  • 缺少 issue linking / changelog / test note / breaking change note
  • 没有遵守“先讨论后提 PR”之类的贡献流程

对于 OpenMeta 来说,这类 PR 很容易变成“低质量自动 PR”,即使改动本身不差,也会降低 merge potential。

问题

OpenMeta 当前更像是在“自己想一个 PR”,而不是“先理解这个仓库希望 PR 怎么写,再去生成 PR”。

这和 OpenMeta 的目标并不完全一致:

  • OpenMeta 不只是要会改代码
  • 还应该尽量减少垃圾 PR
  • 应该尽量像一个认真读过贡献指南的贡献者

建议改进

Prepare workspace / Create draft PR 之间增加一个轻量的 repository contribution rules pass,至少包括:

  1. 检测并读取以下文件(如果存在):

    • CONTRIBUTING.md
    • .github/PULL_REQUEST_TEMPLATE.md
    • .github/pull_request_template.md
    • .github/PULL_REQUEST_TEMPLATE/*
    • CODEOWNERS
    • issue template / discussion policy / release note policy
    • commit convention related docs
  2. 提取结构化规则,例如:

    • PR title format
    • commit message convention
    • branch naming convention
    • required checklist items
    • required validation/tests
    • required linked issue format
    • whether draft PRs are encouraged
    • whether maintainers require prior discussion
  3. 将这些规则注入:

    • PR draft prompt
    • branch name generation
    • contribution commit message generation
    • final PR creation safety checks
  4. 如果检测到强约束但当前 run 不满足:

    • 不要直接开 PR
    • 改为 needs_review / artifact-only
    • 在 trace 和 artifacts 中明确说明缺失项

预期收益

  • 减少 technically-correct but process-invalid 的 PR
  • 提高 PR 的 merge potential
  • 更符合 OpenMeta “减少垃圾 PR” 的定位
  • 让 agent 的行为更接近真实贡献者,而不是只会生成文本

建议验收

  • 仓库存在 PR template 时,生成的 PR body 会显式遵循该模板
  • 仓库存在 CONTRIBUTING 规则时,PR title / commit message / checklist 能体现这些要求
  • 仓库要求特定 issue linking / test note / release note 时,PR draft 会自动补齐
  • 如果规则无法满足,agent 不会盲目开 PR,而是收口为 review/artifacts
  • trace / dossier 能展示本次识别到的 repository PR rules

Background

OpenMeta can already perform the generic PR flow:

  • fork the repository
  • create a branch
  • generate a PR draft
  • open a draft PR against upstream

However, the current behavior appears to rely mostly on OpenMeta’s own fixed conventions and model-generated content, rather than the target repository’s actual contribution rules.

This creates a practical problem:

a PR may be technically reasonable, but still non-compliant with repository-specific contribution expectations.

Examples include:

  • not following CONTRIBUTING.md
  • ignoring .github/PULL_REQUEST_TEMPLATE.md
  • missing required checklist items
  • using a branch name that does not match project conventions
  • using a commit message format that the repo does not accept
  • omitting required issue links / test notes / changelog notes / breaking change notes
  • skipping contribution workflow expectations such as “discuss before opening a PR”

For OpenMeta, this can easily produce “low-quality automated PRs” even when the underlying code change is decent.

Problem

OpenMeta currently behaves more like “generate a PR that seems reasonable” than “understand how this repository expects PRs to be written and submitted”.

That is misaligned with OpenMeta’s product goal:

  • OpenMeta should not just write code
  • it should also minimize low-signal PRs
  • it should behave more like a contributor who actually read the repository’s contribution rules

Proposed improvement

Add a lightweight repository contribution rules pass between Prepare workspace and Create draft PR, including at least:

  1. Detect and read these files when present:

    • CONTRIBUTING.md
    • .github/PULL_REQUEST_TEMPLATE.md
    • .github/pull_request_template.md
    • .github/PULL_REQUEST_TEMPLATE/*
    • CODEOWNERS
    • issue templates / discussion policy / release-note policy
    • commit convention related docs
  2. Extract structured constraints such as:

    • PR title format
    • commit message convention
    • branch naming convention
    • required checklist items
    • required validation/tests
    • required issue-linking format
    • whether draft PRs are encouraged
    • whether prior maintainer discussion is expected
  3. Feed these rules into:

    • the PR draft prompt
    • branch name generation
    • contribution commit message generation
    • final PR creation safety checks
  4. If strong constraints are detected but the current run does not satisfy them:

    • do not open a PR blindly
    • fall back to needs_review / artifact-only mode
    • explain the missing requirements in trace and artifacts

Expected benefit

  • reduce technically-correct but process-invalid PRs
  • improve merge potential
  • better align with OpenMeta’s “avoid garbage PRs” goal
  • make the agent behave more like a real contributor rather than just a text generator

Suggested acceptance criteria

  • if a repository has a PR template, the generated PR body explicitly follows it
  • if a repository has contribution rules, PR title / commit message / checklist reflect them
  • if a repo requires issue linking / test notes / release notes, the PR draft includes them
  • if requirements cannot be satisfied, the agent falls back to review/artifacts instead of blindly opening a PR
  • trace / dossier show the repository PR rules detected for the run

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions