pr-review-ci-fix
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR Review + CI Auto-Fix
PR审核 + CI自动修复
Drive GitHub/GitLab PR reviews and CI triage from the shell using the Composio CLI. No tab-switching between browser, terminal, and chat.
使用Composio CLI从命令行完成GitHub/GitLab PR审核与CI问题排查,无需在浏览器、终端和聊天工具之间来回切换。
When to Use
适用场景
- A PR needs a structured review (correctness, style, risks) with inline comments.
- CI is red and you want the agent to read the logs, patch the code, and recheck.
- You want a single command that cycles: fetch diff → critique → fix → push → rerun.
- 需要对PR进行结构化审核(正确性、代码风格、风险点)并添加行内评论时。
- CI检查失败,希望由Agent读取日志、修补代码并重新验证时。
- 需要一个单一命令完成拉取差异 → 评估 → 修复 → 推送 → 重新运行循环时。
Prereqs
前置条件
bash
curl -fsSL https://composio.dev/install | bash
composio login
composio link github # or: composio link gitlabOptional env for non-interactive runs: .
COMPOSIO_API_KEYbash
curl -fsSL https://composio.dev/install | bash
composio login
composio link github # 或:composio link gitlab非交互式运行可选环境变量:。
COMPOSIO_API_KEYCore Toolkits
核心工具集
Discover slugs with search, then pin them for reuse:
bash
composio search "list pull request files" --toolkits github
composio search "download workflow logs" --toolkits github
composio search "create pr comment" --toolkits gitlabCommon slugs you'll reuse:
GITHUB_GET_A_PULL_REQUESTGITHUB_LIST_PULL_REQUESTS_FILESGITHUB_CREATE_A_REVIEW_FOR_A_PULL_REQUESTGITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORYGITHUB_DOWNLOAD_WORKFLOW_RUN_LOGSGITLAB_GET_SINGLE_MERGE_REQUESTGITLAB_LIST_MERGE_REQUEST_DISCUSSIONSGITLAB_CREATE_NEW_MERGE_REQUEST_NOTE
Always confirm via before first use.
composio execute <SLUG> --get-schema通过搜索发现slug,然后固定以便重复使用:
bash
composio search "list pull request files" --toolkits github
composio search "download workflow logs" --toolkits github
composio search "create pr comment" --toolkits gitlab常用的可重复使用slug:
GITHUB_GET_A_PULL_REQUESTGITHUB_LIST_PULL_REQUESTS_FILESGITHUB_CREATE_A_REVIEW_FOR_A_PULL_REQUESTGITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORYGITHUB_DOWNLOAD_WORKFLOW_RUN_LOGSGITLAB_GET_SINGLE_MERGE_REQUESTGITLAB_LIST_MERGE_REQUEST_DISCUSSIONSGITLAB_CREATE_NEW_MERGE_REQUEST_NOTE
首次使用前,请务必通过确认参数格式。
composio execute <SLUG> --get-schemaReview Workflow
审核工作流
- Pull the PR metadata + diff:
bash
composio execute GITHUB_GET_A_PULL_REQUEST \ -d '{"owner":"acme","repo":"app","pull_number":482}' composio execute GITHUB_LIST_PULL_REQUESTS_FILES \ -d '{"owner":"acme","repo":"app","pull_number":482}' - Summarize risk areas (auth, migrations, public APIs, tests) into a review body.
- Post the review with inline comments:
bash
composio execute GITHUB_CREATE_A_REVIEW_FOR_A_PULL_REQUEST -d '{ "owner":"acme","repo":"app","pull_number":482, "event":"COMMENT", "body":"Overall LGTM with 2 blocking notes.", "comments":[ {"path":"src/auth.ts","line":42,"body":"Missing null check on session"}, {"path":"src/auth.ts","line":88,"body":"Token TTL is hardcoded; move to config"} ] }'
- 拉取PR元数据 + 代码差异:
bash
composio execute GITHUB_GET_A_PULL_REQUEST \ -d '{"owner":"acme","repo":"app","pull_number":482}' composio execute GITHUB_LIST_PULL_REQUESTS_FILES \ -d '{"owner":"acme","repo":"app","pull_number":482}' - 总结风险点(权限验证、数据迁移、公开API、测试)并写入审核内容。
- 发布带行内评论的审核:
bash
composio execute GITHUB_CREATE_A_REVIEW_FOR_A_PULL_REQUEST -d '{ "owner":"acme","repo":"app","pull_number":482, "event":"COMMENT", "body":"整体没问题,但有2个需要修改的要点。", "comments":[ {"path":"src/auth.ts","line":42,"body":"缺少对session的空值检查"}, {"path":"src/auth.ts","line":88,"body":"Token有效期是硬编码的,建议移到配置文件中"} ] }'
CI Auto-Fix Loop
CI自动修复循环
- Find the red run:
bash
composio execute GITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORY \ -d '{"owner":"acme","repo":"app","branch":"feat/billing","status":"failure"}' - Pull logs:
bash
composio execute GITHUB_DOWNLOAD_WORKFLOW_RUN_LOGS \ -d '{"owner":"acme","repo":"app","run_id":123456}' - Parse failure → patch locally (the agent writes the fix into the working tree).
- Commit + push via local , then re-poll step 1 until
git.conclusion=success - Post a PR comment describing each fix commit so the human reviewer sees what changed.
- 找到失败的运行任务:
bash
composio execute GITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORY \ -d '{"owner":"acme","repo":"app","branch":"feat/billing","status":"failure"}' - 拉取日志:
bash
composio execute GITHUB_DOWNLOAD_WORKFLOW_RUN_LOGS \ -d '{"owner":"acme","repo":"app","run_id":123456}' - 解析失败原因 → 本地修补代码(Agent会将修复内容写入工作目录)。
- 通过本地提交并推送,然后重复步骤1轮询,直到
git。conclusion=success - 发布PR评论描述每次修复提交的内容,方便人工审核者查看变更点。
One-Shot Workflow File
一键式工作流文件
Save as and run with :
scripts/review-and-fix.tscomposio run --file ./scripts/review-and-fix.ts -- --pr 482ts
const pr = process.argv.includes("--pr")
? Number(process.argv[process.argv.indexOf("--pr") + 1])
: null;
const meta = await execute("GITHUB_GET_A_PULL_REQUEST", {
owner: "acme", repo: "app", pull_number: pr
});
const files = await execute("GITHUB_LIST_PULL_REQUESTS_FILES", {
owner: "acme", repo: "app", pull_number: pr
});
console.log(JSON.stringify({ meta, files }, null, 2));保存为,并通过运行:
scripts/review-and-fix.tscomposio run --file ./scripts/review-and-fix.ts -- --pr 482ts
const pr = process.argv.includes("--pr")
? Number(process.argv[process.argv.indexOf("--pr") + 1])
: null;
const meta = await execute("GITHUB_GET_A_PULL_REQUEST", {
owner: "acme", repo: "app", pull_number: pr
});
const files = await execute("GITHUB_LIST_PULL_REQUESTS_FILES", {
owner: "acme", repo: "app", pull_number: pr
});
console.log(JSON.stringify({ meta, files }, null, 2));GitLab Variant
GitLab版本
Swap slugs and param names:
bash
composio execute GITLAB_GET_SINGLE_MERGE_REQUEST \
-d '{"id":"acme/app","merge_request_iid":482}'
composio execute GITLAB_CREATE_NEW_MERGE_REQUEST_NOTE \
-d '{"id":"acme/app","merge_request_iid":482,"body":"CI fix pushed as commit deadbeef"}'替换slug和参数名称:
bash
composio execute GITLAB_GET_SINGLE_MERGE_REQUEST \
-d '{"id":"acme/app","merge_request_iid":482}'
composio execute GITLAB_CREATE_NEW_MERGE_REQUEST_NOTE \
-d '{"id":"acme/app","merge_request_iid":482,"body":"CI修复已提交为commit deadbeef"}'Troubleshooting
故障排查
- →
Connection required for githubcomposio link github - Unknown input shape →
composio execute <SLUG> --get-schema - Log download huge → stream via against the raw API and
composio proxylocallygrep - Rate limits → serialize calls or lower poll frequency; avoid for the same repo
--parallel
Full CLI reference: docs.composio.dev/docs/cli
- → 执行
Connection required for githubcomposio link github - Unknown input shape → 执行查看参数格式
composio execute <SLUG> --get-schema - 日志文件过大 → 通过对接原始API流式获取,并在本地用
composio proxy筛选grep - 速率限制 → 序列化调用或降低轮询频率;同一仓库避免使用参数
--parallel
完整CLI文档:docs.composio.dev/docs/cli