feat: rewrite multi-review using OpenCode SDK#103
Conversation
Replace the Python subprocess approach with TypeScript + @opencode-ai/sdk. The SDK's createOpencode() manages the server lifecycle, and client.session.prompt() returns structured AI responses — solving the fundamental problem where opencode CLI stdout only contained boilerplate. Architecture: - Single opencode server instance, N parallel reviewer sessions - Each reviewer gets its own isolated session with persona-specific prompt - Coordinator session synthesizes all reviews into one deduplicated report - Posts exactly 1 PR comment via gh CLI Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
不可合并 总评该 PR 将 multi-review 从 Python subprocess 方案重写为 TypeScript SDK 方案,架构设计清晰(1 server → N sessions → coordinator synthesis),整体方向正确。但存在 2 个阻塞级问题导致实际不可用。 阻塞项1.
|
|
发现遗漏 概要PR body 描述的架构( MEDIUM
LOW
architecture reviewer 提示词引用项目上下文文件但未提供
|
|
现在我有了完整的架构分析信息。 架构有问题 架构分析概要该 PR 将 multi-review 从 Python subprocess 方案(与其他 action 一致)重写为 TypeScript + OpenCode SDK 方案,架构模式从 "N × subprocess" 变为 "1 shared server × N sessions"。整体方向合理,但存在 2 个阻塞级架构问题和若干架构不一致。 阻塞项1. if [[ "$ref" =~ refs/pull/([0-]+)/merge ]]; then正则表达式
这是架构层面的数据流断裂 — action.yml 是数据入口契约(输入定义+预处理),预处理阶段的逻辑错误导致整个下游管道(reviewer → coordinator → comment)空转。修复此问题需要在 2. const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), remainingMs);
// ...
client.session.create({ throwOnError: true }); // 未传 signal
client.session.prompt({ ... }); // 未传 signal
client.session.messages({ ... }); // 未传 signal
这是架构层面的错误处理机制失效 — 超时是一个跨切面关注点(cross-cutting concern),应该在 orchestrator 层或请求层统一处理。当前代码声明了超时意图但实现没有落地。 建议项1. action.yml 定义与实现的接口不匹配(架构不一致) 4 个输入定义在 action.yml 但从未被
action.yml 作为该 action 的公共接口契约,定义了用户可配置的输入。实现不消费这些输入意味着接口中存在死代码(dead interface surface),用户设置了但无效果。 2. 当 3. promptTemplate.replace("{{REVIEWS}}", reviewsText);若 promptTemplate.replaceAll("{{REVIEWS}}", () => reviewsText);4. 自定义 5. 架构风格偏差 — 新增 Node.js/TypeScript 维护轴 现有 7 个 action 全部使用 bash+Python 模式( 6. architecture reviewer 的提示词要求 AI "先读取仓库根目录的 AGENTS.md 或 CLAUDE.md",但 |
- Fix regex typo in action.yml: `[0-]+` → `[0-9]+` (PR diff was never fetched) - Add opencode.json generation step for reasoning-effort and enable-thinking - Set read-only permissions in opencode.json (deny git write ops) - Remove unused AbortController in orchestrator.ts Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
发现遗漏 概要PR body 描述的核心架构( MEDIUM
LOW
architecture reviewer 提示词引用项目上下文文件但未提供
|
|
不可合并 总评PR 整体架构方向合理(1 server × N sessions → coordinator synthesis),核心链路完整可用。但存在 1 个阻塞级正确性问题 和 1 个架构级安全隐患,在修复前不应合并。 阻塞项1.
|
|
现在我已掌握完整的架构分析所需信息。以下是最终的技术审阅。 架构有疑虑 架构分析概要该 PR 将 multi-review 从 Python + 阻塞项:无建议项1. 超时机制为装饰性, const timeout = setTimeout(() => {
console.warn(`[${reviewer.name}] Exceeded ${remainingMs}ms, still waiting...`);
}, remainingMs);
这是跨切面关注点(请求超时/取消)的实现断裂。修复方向:确认 SDK 是否支持 2.
3. 架构范式分歧 — 引入 Node.js/TypeScript 维护轴 现有 7 个 action 全部使用 bash + Python + CLI subprocess 模式( 4.
action.yml 作为该 action 的公共接口契约,定义了用户可配置的输入。实现不消费这些输入意味着接口中存在死代码(dead interface surface),用户设置了但无效果。 5. architecture reviewer 的提示词要求 AI "先读取仓库根目录的 AGENTS.md(或 CLAUDE.md)",但 6. 当 7. promptTemplate.replace("{{REVIEWS}}", reviewsText);若 8. 缺少请求重试/退避机制 ( 所有 SDK 调用( |
- Replace decorative setTimeout with Promise.race-based timeout that actually rejects and aborts SDK calls when deadline is exceeded - Implement extra-env parsing: reads MULTI_REVIEW_EXTRA_ENV and injects KEY=VALUE pairs into process.env before SDK initialization - Implement cleanup-error-comments: deletes bot comments from failed runs that contain error indicators matching run ID - Make postPRComment/cleanupErrorComments synchronous (no unnecessary async for execFileSync calls) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
可合并 总结代码整体架构清晰(1 server → N sessions → coordinator → 1 comment),模块职责分离合理,错误处理机制完整,核心数据流正确。与先前 review 版本不同,当前 HEAD 已修复以下问题: 阻塞项:无 建议项1.
|
|
现已掌握完整信息。PR 无关联 issue,PR body 即为 spec。核心架构( 发现遗漏 MEDIUM
LOWarchitecture reviewer 提示词引用
除上述两项外,PR body 描述的核心架构(1 server × 4 reviewers × coordinator → 1 comment)、SDK 生命周期管理、并行审查、协调器合成等核心功能均已完整实现。 |
|
架构有疑虑 架构分析概要PR 将 multi-review 从 Python + 阻塞项阻塞项:无 建议项1. 架构范式分歧 — 引入 Node.js/TypeScript 维护轴(中等)现有 7 个 action 全部使用 bash + Python + CLI subprocess 模式(
需要团队明确是否接受这一额外的维护维度,或考虑将 SDK 模式推广到其他 action。 2.
|
- Use split/join instead of replace for {{REVIEWS}} to avoid special
replacement pattern issues
- Remove unused modelID/providerID from OrchestratorOptions interface
- Remove redundant !runLinkPattern check in cleanupErrorComments
- Warn when model string lacks provider prefix
- Remove false AGENTS.md instruction from architecture.yaml prompt
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
可合并 总评对比此前 review 指出的问题,当前 HEAD 已全部修复或确认: 阻塞项:无 建议项1.
|
|
Bad credentials - https://docs.github.com/rest |
|
现在我掌握了完整的代码。这是我的架构评审: 架构有疑虑 架构分析概要该 PR 将 multi-review 从 Python + 但存在一个突出的架构一致性问题。 阻塞项阻塞项:无 建议项1. 架构范式分歧 — 引入代码库唯一的 Node.js/TypeScript 维护轴(重点)现有 7 个 action ( 具体差异:
虽然技术选型有合理依据(SDK 的 2.
|
…ccuracy - resolveModel() now throws instead of silently returning empty providerID - withTimeout timer uses explicit undefined type for strict TS safety - Recompute remainingMs before each SDK call to avoid timeout drift Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
无遗漏 PR body 描述的核心架构已全部实现:
所有 spec 要求的特性均已覆盖,无需额外实现。 |
|
现在我已充分审阅当前 HEAD 的所有代码。 不可合并 总结PR 整体架构清晰合理(1 server × N sessions × coordinator → 1 comment),模块职责分离良好。对比 previous reviews,以下问题已在当前 HEAD 修复: 阻塞项1.
|
The previous dist/index.js had a bare `import { createOpencode } from
"@opencode-ai/sdk"` which would fail at runtime since node_modules is
not available on the CI runner. Configure tsup with noExternal to
inline the SDK into the bundle (72KB vs 13KB previously).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
架构有问题 架构分析概要PR 整体模块划分清晰( 阻塞项
|
|
可合并 总评当前 HEAD 架构清晰(1 server × N sessions × coordinator → 1 comment),模块职责分离良好。之前 review 指出的所有阻塞问题均已修复:regex 已为正确 阻塞项:无 建议项1.
|
|
无链接的 issue,PR body 即为 spec。我已完整阅读所有源文件。 发现遗漏 MEDIUM
LOW
除上述两项外,PR body 描述的核心架构( |
架构分析概要通过审阅 AGENTS.md 和代码库现有的 7 个 action( 当前 HEAD 相比此前 review 已修复多项问题:SDK 通过 tsup 核心数据流( 架构有疑虑 阻塞项阻塞项:无 建议项1. 架构范式分歧 — 引入代码库唯一的 Node.js/TypeScript 维护轴(重点)这是最值得讨论的架构问题。现有 7 个 action 全部遵循一致的架构模式:
虽然技术选型有合理依据(SDK 的 2.
|

















Summary
multi-review/using@opencode-ai/sdkTypeScript SDK instead of Python subprocesscreateOpencode()管理 server 生命周期,client.session.prompt()返回结构化 AI 响应opencode github runstdout 只包含 CLI 框架噪声,不包含 AI 评审内容Architecture
Key changes
client.session.prompt()(structured)Test plan
cd multi-review && npm run buildsucceedscd multi-review && npx tsc --noEmitpasses🤖 Generated with Claude Code