Skip to content

feat: add pi-multi-review action#106

Open
Svtter wants to merge 2 commits into
mainfrom
worktree-pi-multi-review
Open

feat: add pi-multi-review action#106
Svtter wants to merge 2 commits into
mainfrom
worktree-pi-multi-review

Conversation

@Svtter
Copy link
Copy Markdown
Collaborator

@Svtter Svtter commented May 23, 2026

Summary

  • Add pi-multi-review/ action — multi-agent parallel PR review using shaftoe/pi-coding-agent-action + pi-parallel-agents team mode
  • 4 built-in reviewer personas (quality, security, performance, architecture) run in parallel, then a synthesizer merges findings into a single PR comment
  • Supports custom reviewer configs via reviewers-config input
  • Supports both pull_request auto-trigger and /multi-review comment trigger
  • Includes example workflow and full documentation

Context

Previous multi-review/ was removed in #101 due to fundamental design flaw (opencode subprocess can't capture AI review content). This is the alternative approach (方案 E) discussed in #102, leveraging the pi-agent ecosystem instead.

Test plan

  • Verify action triggers on pull_request events
  • Verify /multi-review comment triggers the action
  • Verify default 4 reviewers run in parallel
  • Verify custom reviewers-config overrides defaults
  • Verify synthesizer produces a single PR comment

🤖 Generated with Claude Code

New action that runs multiple reviewer agents (quality, security,
performance, architecture) in parallel via shaftoe/pi-coding-agent-action
with pi-parallel-agents extension. A synthesizer agent merges all findings
into a single structured PR comment.

Closes #102 (alternative approach)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

发现遗漏

总结

PR 实现了核心功能(4 个并行 reviewer + synthesizer 合并、自定义 reviewer 配置、push/comment 两种触发方式、示例 workflow 和文档),但有两处配置项被定义、文档化、传递到脚本后,却从未被实际使用,属于"定义但未接线"的遗漏。


MEDIUM

max-tokens 输入完全失效

  • 该输入在 action.yml:26-29 定义,README 中文档化(默认 4096),build-prompt.py:94 解析为 --max-tokens,但从 main() 第 106 行传入 build_team_dag(config, args.default_model, args.language) 时被完全忽略——build_team_dag() 函数签名只有三个参数,生成的 JSON DAG 中不包含任何 max_tokens 字段。
  • 同时,action.yml:93-105 在调用 pi-coding-agent-action 的步骤中也没有传递 max_tokens 输入。
  • 用户设置的 max-tokens 值被静默丢弃,不产生任何效果。
  • 建议修复: 在 build-prompt.py 中将 max_tokens 传入 build_team_dag() 并写入每个 task 的 JSON 字段;同时在 action.yml 中向 pi-coding-agent-action 传递 max_tokens 输入。

LOW

trigger-phrase 输入是死配置

  • 该输入在 action.yml:54-57 定义,默认 /multi-review,README 文档化。但 composite action 的所有 steps 中没有任何一步引用 ${{ inputs.trigger-phrase }}
  • 触发逻辑完全写在 workflow 的 if 条件中(.github/workflows/pi-multi-review.yml:14 硬编码了 /multi-review),action 自身对此输入不感知。
  • 用户修改 trigger-phrase 输入不会有任何效果(除非手动修改 workflow 文件)。
  • 建议修复: 从 action.yml 中移除此输入,或在 action 中增加逻辑来读取并使用它(但 workflow 级别的触发判断仍需用户手动修改,可能移除更合理)。

New%20session%20-%202026-05-23T15%3A20%3A08.041Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown

以下是对 PR 的代码审查结果:

有条件合并

此次 PR 新增了 pi-multi-review/ 多智能体并行代码审查 action,整体设计合理,代码结构清晰。但存在一些问题需要修复后再合并。

阻塞项:

  1. max-tokens 输入参数在 action.yml(第 26-29 行)中声明并被赋予默认值 4096,也在 build-prompt.py(第 94 行)中被 argparse 解析,但在 build_team_dag() 生成的最终 DAG 中从未使用,也未传递给 pi-coding-agent-action。用户设置了此参数后不会有任何效果,形成误导性的声明式接口。

建议项:

  1. pi-multi-review/action.yml:73 脚本路径 $ACTION_PATH/../pi-multi-review/scripts/build-prompt.py 写法过于复杂,github.action_path 已指向 pi-multi-review 目录,直接使用 $ACTION_PATH/scripts/build-prompt.py 即可。
  2. build-prompt.pybuild_team_dag() 中变量命名 synth_prompt 可读性较低,建议使用完整拼写 synthesizer_prompt
  3. pi-multi-review/action.yml:94 使用 shaftoe/pi-coding-agent-action@${{ inputs.pi-action-version }},默认值为 v2 移动标签,建议在文档或实现中标注推荐的最小 commit SHA,防止上游 breaking change 导致静默失败。
  4. 未将 pi-multi-review 纳入 tests/test_all.py 或 CI smoke test,build-prompt.py 缺少单元测试,建议补充测试覆盖。
  5. pi-multi-review/README.md:31 文档示例使用 Svtter/opencode-actions,而根 README.md:210 使用 sun-praise/opencode-actions,建议统一。
  6. default.yml 中 reviewer prompt 使用了 {{diff}}{{title}} 等模板变量,这些变量需要在 DAG JSON 的嵌套 task 字段中被模板引擎渲染。当前 build-prompt.py 仅替换了 {{language}},其余变量依赖外部引擎处理。建议确认 pi-parallel-agentspi-coding-agent-action 能递归渲染嵌套 JSON 中的模板变量,或者在 build-prompt.py 中一并替代。

New%20session%20-%202026-05-23T15%3A20%3A08.086Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown

架构分析

This PR adds pi-multi-review/, a new action using shaftoe/pi-coding-agent-action + pi-parallel-agents for multi-agent parallel PR review. It's a deliberately different approach from the existing OpenCode-based actions — 方案 E as referenced in #102.

Key architectural observations:

  1. Ecosystem divergence: Unlike all other 8 actions in this repo (which share setup-opencode/github-run-opencode infrastructure), pi-multi-review is a completely standalone action with zero dependency on OpenCode CLI. This is an intentional design choice, but creates a precedent where future actions might also bypass the shared plumbing.

  2. No Linux runner guard: Every other action checks runner.os != 'Linux' and exits; pi-multi-review does not. If run on Windows/macOS, it will fail at python3 or the pi-agent step with a confusing error.

  3. External action dependency: The core runtime is delegated to shaftoe/pi-coding-agent-action@v2 — a third-party action outside this repo's control. Acceptable as a design choice but worth explicit ownership documentation.

  4. Modular structure is clean: The 6-file structure (action.yml, scripts/build-prompt.py, reviewers/default.yml, README.md, workflow, root README update) is well-contained. Adding new reviewer personas is a YAML addition — good localized design.

阻塞项

  1. max-tokens 输入定义但完全未使用 — 从 action.yml:26-29 定义输入,README 文档化,到 build-prompt.py:94argparse 解析为 --max-tokens 参数,再到 action.yml:77 传给脚本——但 build_team_dag() 第 106 行调用时完全忽略了该参数,生成的 team DAG JSON 中不含任何 max_tokens 字段。同时 action.yml:93-105 调用 pi-coding-agent-action 时也未传递 max_tokens。结果是用户设置的 max-tokens 被静默丢弃,action 的公开接口与运行时行为不一致。这是接口契约的严重缺陷,必须修复

建议项

  1. 缺少 Linux runner 检查 — 其他所有 action 都有 if: ${{ runner.os != 'Linux' }} 前置检查。pi-multi-review/action.yml 没有,建议添加以保持一致。

  2. trigger-phrase 输入对 composite action 来说是死配置action.yml:54-57 定义并文档化了 trigger-phrase,但 composite action 的 steps 中没有任何一步引用 ${{ inputs.trigger-phrase }}。触发逻辑完全硬编码在 .github/workflows/pi-multi-review.yml:14。这是 GitHub Actions composite action 的模式限制(无法控制 workflow 级别的 if 条件),建议在 README 中注明此限制,或从 action.yml 移除此输入避免误导。

  3. 外部 action 版本应固定 SHAshaftoe/pi-coding-agent-action@${{ inputs.pi-action-version }}(默认 v2)使用移动 tag。建议文档化建议生产用户固定到具体 SHA,与现有发布策略保持一致(README.md 中已有类似建议)。

New%20session%20-%202026-05-23T15%3A21%3A37.809Z
opencode session  |  github run

- Wire max-tokens through to DAG JSON (was declared but unused)
- Add Linux runner guard (consistent with other actions)
- Remove dead inputs (trigger-phrase, pi-action-version)
- Fix script path (use $ACTION_PATH/scripts/ directly)
- Fix README org name (Svtter → sun-praise)
- Add security note about pinning to commit SHA

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

No API key found for anthropic.

Use /login to log into a provider via OAuth or API key. See:
/home/runner/work/_actions/shaftoe/pi-coding-agent-action/v2/docs/providers.md
/home/runner/work/_actions/shaftoe/pi-coding-agent-action/v2/docs/models.md


View action run | Model: anthropic/claude-sonnet-4-6 (thinking: medium) | Time: 24s | Action v2.17.0

@github-actions
Copy link
Copy Markdown

有条件合并

此次 PR 新增了 pi-multi-review/ 多智能体并行代码审查 action,整体架构合理,代码清晰。但存在一个逻辑错误需要修复。

阻塞项:

  1. 合成器(synthesizer)的 maxTokens 字段忽略了自定义配置build-prompt.py:53-57 中,合成器成员使用硬编码的 max_tokens 参数值,而非像 reviewer 成员那样(第 47 行)通过 synthesizer_cfg.get("maxTokens", max_tokens) 从配置读取。若用户自定义 reviewers-config 中为合成器指定了不同的 maxTokens,该配置会被静默忽略。

建议项:

  1. pi-coding-agent-action 步骤(action.yml:82-93)未传递 max-tokens 输入,虽然 DAG JSON 的 member 对象已包含 maxTokens,但为保持接口一致,建议在 action 层面也传递该值。
  2. build-prompt.py 缺乏单元测试,建议补充以覆盖 reviewer 加载、模板替换、DAG 生成等逻辑。
  3. reviewers-config 自定义 YAML 结构不完整(如缺失 name 字段)时,第 46 行的 r["name"] 会抛出 KeyError,建议增加友好错误提示。
  4. .github/workflows/pi-multi-review.yml 未传递 diff-max-linesdiff-ignore-patternsbase-urlthinking-level 等可选输入,用户需要修改 workflow 文件才能自定义这些参数。

New%20session%20-%202026-05-23T15%3A34%3A40.384Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown

无遗漏

PR 的第二个 commit (8dae0c4) 已修复了早期 review 中发现的全部问题:

  • max-tokens: build_team_dag() 现在接收 max_tokens 参数并写入 DAG 的每个 member 的 "maxTokens" 字段
  • Linux runner guard: 已添加 runner.os != 'Linux' 前置检查
  • 死配置移除: trigger-phrasepi-action-version 两个 input 被删除
  • 脚本路径: 修正为 $ACTION_PATH/scripts/build-prompt.py
  • README org name: 统一为 sun-praise/opencode-actions

当前实现与 PR body 中列出的所有 spec 要求一致:

  1. pi-multi-review/ action 使用 pi-coding-agent-action + pi-parallel-agents
  2. 4 个内置 reviewer(quality, security, performance, architecture)并行运行 ✓
  3. synthesizer 合并结果生成单一 PR 评论 ✓
  4. 支持通过 reviewers-config 自定义 reviewer ✓
  5. 支持 pull_request 自动触发和 /multi-review 评论触发 ✓
  6. 包含示例 workflow 和完整文档 ✓

New%20session%20-%202026-05-23T15%3A34%3A40.846Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown

架构有疑虑

架构分析总结

PR 新增了 pi-multi-review/,是一个基于 shaftoe/pi-coding-agent-action + pi-parallel-agents 的并行多 AI 审查 action。之前 multi-review 失败(#101)后,这是 PR 中描述的方案 E,属于有意的架构转向

正面评价:目录结构符合现有 action 惯例(action.yml, scripts/, reviewers/, README.md),文件布局合理,增加 reviewer 只需修改 default.yml,变更集中在 6 个文件内,工件边界清晰。

核心架构疑虑——生态系统分歧:现有 8 个 action 全部依赖 setup-opencode + opencode github run 的共享基础设施。pi-multi-review 完全抛弃了这套架构,引入了完全不同的第三方执行引擎。这意味着:

  • 仓库维护者需要理解两套不同架构的失效模式和安全更新策略
  • 共享基础设施的改进(如缓存、重试、fallback 模型)对 pi-multi-review 不产生任何影响
  • API key 模型从 setup-opencode 的统一 env 模式变成了 pi-coding-agent-action 的自有输入模式

阻塞项:无

建议项:

  1. 生态系统分歧应文档化:建议在 pi-multi-review/README.md 中明确说明该 action 不依赖 OpenCode CLI 且使用独立架构,帮助用户和未来维护者理解 why。特别说明为什么不能复用现有的 setup-opencode 基础设施(可以简述此前 multi-review 失败的历史原因),避免后来的维护者尝试"统一"两者。

  2. 合成器的 maxTokens 不支持自定义配置覆盖build-prompt.py:56 使用硬绑定 max_tokens 而非 synthesizer_cfg.get("maxTokens", max_tokens),而 reviewers 在 build-prompt.py:47 支持 r.get("maxTokens", max_tokens)。如果用户在自定义 YAML 中为合成器指定了不同于全局的 maxTokens,该配置会被静默忽略。建议对齐二者的行为。

  3. 模板变量渲染责任边界应显式声明build-prompt.py 仅渲染 {{language}},其余变量({{diff}}{{title}}{{body}}{{files}})及合成器的 {task:...} 引用依赖 pi-parallel-agents 的模板引擎。鉴于 DAG JSON 已完全内联到 prompt 输出文本的 team 结构中,建议在代码注释或文档中明确哪些变量由外部系统渲染、哪些由本地脚本处理,降低未来排查模板未渲染问题的成本。

  4. DAG 依赖模型可能导致局部失败全局崩溃:合成器的 depends 字段(build-prompt.py:79)等于所有 reviewer task 的 id,任一 reviewer 失败(超时、API 错误等)将导致整个 synthesizer 不可达。建议在 future iteration 中考虑为 reviewer 设置更细粒度的超时或部分失败处理策略(例如即使部分 reviewer 未返回,合成器仍可处理已有结果)。

New%20session%20-%202026-05-23T15%3A36%3A44.720Z
opencode session  |  github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant