自動化程式碼審查

PR Ready

獲取 PR 差異 → 平行分析 → 產生審查意見 → 發布評論。

7 個節點 · 8 條連接pr ready
semantic-kernelcode-reviewgithubllmdevtools
視覺化
獲取 PR 差異api

從 GitHub PR API 提取差異內容與檔案清單。

parallel分析複雜度
parallel檢查模式與安全性
parallel檢查測試覆蓋率
分析複雜度agent

量測循環複雜度、函式長度與巢狀深度。

sequential產生審查報告
檢查模式與安全性agent

掃描反模式、SQL 注入、寫死密鑰與 OWASP 問題。

sequential產生審查報告
檢查測試覆蓋率agent

驗證新增的程式碼路徑是否有對應的測試案例。

sequential產生審查報告
產生審查報告agent

將所有分析結果整合為附有嚴重程度分級的結構化審查報告。

sequential發布審查評論
conditional要求修改
發布審查評論api

透過 GitHub API 提交行內評論與整體審查意見。

要求修改api

發現嚴重問題時,將 PR 標記為「需要修改」。

ex-semantic-kernel-code-review.osop.yaml
# Semantic Kernel Automated Code Review — OSOP Portable Workflow
#
# AI-powered PR review: fetch the diff, analyze complexity and patterns
# in parallel, generate a structured review, post comments on GitHub,
# and request changes if critical issues are found.
#
# Run with Semantic Kernel or validate: osop validate code-review-pipeline.osop.yaml

osop_version: "1.0"
id: "semantic-kernel-code-review"
name:"自動化程式碼審查"
description:"獲取 PR 差異 → 平行分析 → 產生審查意見 → 發布評論。"
version: "1.0.0"
tags: [semantic-kernel, code-review, github, llm, devtools]

nodes:
  - id: "fetch_diff"
    type: "api"
    subtype: "rest"
    name: "獲取 PR 差異"
    description: "從 GitHub PR API 提取差異內容與檔案清單。"
    config:
      url: "https://api.github.com/repos/{owner}/{repo}/pulls/{number}"

  - id: "analyze_complexity"
    type: "agent"
    subtype: "llm"
    name: "分析複雜度"
    description: "量測循環複雜度、函式長度與巢狀深度。"
    config:
      model: "gpt-4o"
      plugins: [code_analysis]

  - id: "check_patterns"
    type: "agent"
    subtype: "llm"
    name: "檢查模式與安全性"
    description: "掃描反模式、SQL 注入、寫死密鑰與 OWASP 問題。"
    config:
      model: "gpt-4o"
      plugins: [security_scanner, pattern_matcher]

  - id: "check_tests"
    type: "agent"
    subtype: "llm"
    name: "檢查測試覆蓋率"
    description: "驗證新增的程式碼路徑是否有對應的測試案例。"
    config:
      model: "gpt-4o"

  - id: "generate_review"
    type: "agent"
    subtype: "llm"
    name: "產生審查報告"
    description: "將所有分析結果整合為附有嚴重程度分級的結構化審查報告。"
    config:
      output_schema:
        summary: "string"
        issues: [{ file: "string", line: "int", severity: "string", message: "string" }]
        verdict: "approve | request_changes"

  - id: "post_comments"
    type: "api"
    subtype: "rest"
    name: "發布審查評論"
    description: "透過 GitHub API 提交行內評論與整體審查意見。"
    config:
      url: "https://api.github.com/repos/{owner}/{repo}/pulls/{number}/reviews"

  - id: "request_changes"
    type: "api"
    subtype: "rest"
    name: "要求修改"
    description: "發現嚴重問題時,將 PR 標記為「需要修改」。"

edges:
  - from: "fetch_diff"
    to: "analyze_complexity"
    mode: "parallel"
  - from: "fetch_diff"
    to: "check_patterns"
    mode: "parallel"
  - from: "fetch_diff"
    to: "check_tests"
    mode: "parallel"
  - from: "analyze_complexity"
    to: "generate_review"
    mode: "sequential"
  - from: "check_patterns"
    to: "generate_review"
    mode: "sequential"
  - from: "check_tests"
    to: "generate_review"
    mode: "sequential"
  - from: "generate_review"
    to: "post_comments"
    mode: "sequential"
  - from: "generate_review"
    to: "request_changes"
    mode: "conditional"
    when: "verdict == 'request_changes'"
    label: "Critical issues found"