diff --git a/.claude/commands/review.md b/.claude/commands/review.md index 6d7c4fe..9678871 100644 --- a/.claude/commands/review.md +++ b/.claude/commands/review.md @@ -15,6 +15,8 @@ git branch --show-current 若 staged 無任何變更,輸出「⚠️ 無 staged 變更,請先 git add 後再執行 /review」並停止。 +若 `git diff --staged --stat` 顯示總變更超過 **2000 行**,以 `--stat` 摘要取代完整 diff 傳入 Agent(避免 context 超載)。 + 依變更檔案決定本次審查的 Agent 集合(路由規則見下方)。 --- @@ -42,12 +44,13 @@ bash scripts/tg_notify.sh info "🔍 Code Review 啟動 | 條件 | 觸發 Agent | |------|-----------| -| 任何 `.py` / `.html` / `.js` 變更 | **critic**(必跑) | +| 任何 `.py` / `.html` / `.js` / `.sh` 變更 | **critic**(必跑) | | `migrations/*.sql` 或 `database/` 變更 | **db-expert** | | `requirements.txt` / `Dockerfile` / `docker-compose.yml` 變更 | **migration-engineer** | | `.claude/hooks/` / `settings.json` / `.claude/` 變更 | **tool-expert** | -| Python 檔案變更 ≥ 10 個 | 改派 **refactor-specialist**(取代 critic 為主審) | -| critic 報告含任何 🔴 Critical | 追加 **vuln-verifier**(Phase B,序列執行) | +| `.gitea/` / `.github/` / `*.yaml` / `*.yml`(非 docker-compose.yml)變更 | **tool-expert**(並行加入) | +| Python 檔案變更 ≥ 10 個 | **refactor-specialist** 並行加入(不取代 critic) | +| 任一主審 Agent 報告含 🔴 Critical | 追加 **vuln-verifier**(Phase B,序列執行) | 最多同時跑 4 個獨立 Agent(Phase A),vuln-verifier 為條件觸發的 Phase B。 @@ -84,7 +87,7 @@ diff 內容:[貼入相關 diff]」 ## 階段 2.5:每個 Agent 完成後立即發 Telegram -每個 Agent 完成後,**立即**(不等其他 Agent)發送節點通知: +Phase A Agent 全部回報後,**逐一**為每個 Agent 發送節點通知(不批量合併): ```bash bash scripts/tg_notify.sh "[ 完成] @@ -100,12 +103,12 @@ level 對應:BLOCKED → error;CAUTION → warn;APPROVED → info ## 階段 3:Phase B — vuln-verifier(條件觸發) -**只有** critic 報告含 🔴 Critical 才執行此階段。 +**只有**任一主審 Agent 報告含 🔴 Critical 才執行此階段。 先發 Telegram: ```bash bash scripts/tg_notify.sh warn "🔬 VULN-VERIFIER 啟動 -觸發原因:critic 發現 個 Critical 問題 +觸發原因: 發現 個 Critical 問題 正在驗證漏洞可利用性..." ``` diff --git a/scripts/tg_notify.sh b/scripts/tg_notify.sh index 2c7e3c2..35c4e78 100755 --- a/scripts/tg_notify.sh +++ b/scripts/tg_notify.sh @@ -34,12 +34,17 @@ else CHAT_IDS=$(echo "$CHAT_IDS_RAW" | tr -d '[]" ' | tr ',' '\n') fi +if [[ -z "$CHAT_IDS" ]]; then + echo "[tg_notify] CHAT_IDS 解析結果為空,跳過通知" >&2 + exit 0 +fi + while IFS= read -r CHAT_ID; do [[ -z "$CHAT_ID" ]] && continue - curl -s --max-time 10 -X POST \ + printf '%s' "$FULL_MSG" | curl -s --max-time 10 -X POST \ "https://api.telegram.org/bot${TOKEN}/sendMessage" \ -d "chat_id=${CHAT_ID}" \ - --data-urlencode "text=${FULL_MSG}" \ + --data-urlencode "text@-" \ -d "parse_mode=HTML" > /dev/null || \ echo "[tg_notify] 發送到 ${CHAT_ID} 失敗(不阻斷流程)" >&2 done <<< "$CHAT_IDS"