fix(review): 修復 /review 機制的 7 個審查問題

必修:
- 路由表新增 .sh → critic、.yaml/.yml → tool-expert 兩條規則
- refactor-specialist 改為並行(不取代 critic),確保 vuln-verifier 觸發條件正確
- Phase B 觸發條件從 'critic 含 🔴' 改為 '任一主審 Agent 含 🔴'

選修:
- Stage 0 新增 >2000 行 diff 保護(降級為 --stat 摘要)
- Stage 2.5 移除 '立即' 矛盾描述,改為 'Phase A 全回報後逐一發送'
- tg_notify.sh: 新增 CHAT_IDS 解析後空值守衛
- tg_notify.sh: 改用 printf | --data-urlencode 'text@-' 支援多行訊息

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ogt
2026-04-22 01:39:39 +08:00
parent a45b61f326
commit 4cdf0793a4
2 changed files with 16 additions and 8 deletions

View File

@@ -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 "<b>🔍 Code Review 啟動</b>
| 條件 | 觸發 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 個獨立 AgentPhase Avuln-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 <level> "<b>[<AGENT_NAME> 完成]</b>
@@ -100,12 +103,12 @@ level 對應BLOCKED → errorCAUTION → warnAPPROVED → info
## 階段 3Phase B — vuln-verifier條件觸發
**只有** critic 報告含 🔴 Critical 才執行此階段。
**只有**任一主審 Agent 報告含 🔴 Critical 才執行此階段。
先發 Telegram
```bash
bash scripts/tg_notify.sh warn "<b>🔬 VULN-VERIFIER 啟動</b>
觸發原因:critic 發現 <n> 個 Critical 問題
觸發原因:<Agent 名稱> 發現 <n> 個 Critical 問題
正在驗證漏洞可利用性..."
```

View File

@@ -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"