Files
ISEP/hooks/investigate-first-stamp.sh
Leo 5ac06abc95 工人有名字+回覆也是派工+未經調查不寫診斷(inkstone/ISEP#86/#87/#88)
三張票同一族(誰在派、派給誰、派的內容住哪裡),做在同一條分支:

#86 工人名單:agents/ 七位有名字的工人+scripts/roster+hooks/roster-guard.sh
    派工用 Task 的 subagent_type 指名,派工單格式一個字都沒改;
    指對名字就把那位的檔案原文注入(你是誰/先讀什麼/你的紅線)。
    【身份】欄同時吃得下工人名字(原本三個角色照舊)。

#87 未經調查不寫診斷:hooks/diagnosis-evidence-guard.sh + investigate-first-stamp.sh
    三個結構訊號(派過人查沒/有沒有走得過去的出處/有沒有份量),
    一個關鍵字比對都沒有;轉述有出處不會被誤擋。

#88 回覆也是派工:不另造閘,把攔截點加掛上去。
    hooks/lib/dispatch_parse.py 的 tool_channel() 一次列全所有通往 subagent 的路
    (SendMessage/雲端 session・trigger/claude -p);擋下來時把那段內容原文印出來。
    subagent 往上回報(to: "main")=交件不是派工,刻意不管。

順手修掉一個真的會咬人的 flake:dispatch-format-guard 原本開四支 python 各讀一個欄位,
機器忙的時候某個欄位會靜靜變空字串(實測連跑 10 次有 1 次「豁免了卻還是被擋」)。
四個欄位改成一次讀完。

版本號待總管定(plugin.json 只更新了描述裡的數字,版本沒動)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ZBu4Sa1cGntKFRBYNZ6xs
2026-08-28 01:15:09 +00:00

47 lines
1.9 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# investigate-first-stamp.sh — PostToolUseAgentTaskSendMessage):
# 記下「這個 session 真的**派人去查過那張票**了」。
#
# 配 diagnosis-evidence-guard.sh 使用(形狀抄自 subagent-first-stamp.shkbdb-asked-stamp.sh
# ——inkstone/ISEP#87 票上就是指定照那個形狀做)。只留時戳,不擋任何東西。
#
# 🔴 為什麼按「session + 票號」分開存,不是只按 session:
# subagent-first-stamp 回答的是「這一輪有沒有派過工」(一個 session 一個答案)。
# 本支要回答的是「**這件事**有沒有派人查過」——那是**每張票各自**的問題。
# 只按 session 存的話,早上派過一次去查 A 票,下午就等於解鎖了 B 票的診斷,
# 這道閘會在第二次派工之後完全失效。
set -eu
INPUT=$(cat 2>/dev/null || echo '{}')
HERE=$(cd "$(dirname "$0")" && pwd)
printf '%s' "$INPUT" | STAMP_LIB="$HERE/lib" python3 -c '
import json, os, re, sys, time
sys.path.insert(0, os.environ.get("STAMP_LIB", ""))
try:
import dispatch_parse
except Exception:
raise SystemExit
try:
d = json.load(sys.stdin)
except Exception:
raise SystemExit
sid = re.sub(r"[^A-Za-z0-9_.-]", "_", str(d.get("session_id") or "nosid"))[:64]
channel, text = dispatch_parse.tool_channel(d)
if not channel:
raise SystemExit
for ref in dispatch_parse.parse_dispatch(text)["refs"]:
# ISEP_STAMP_DIR 只給測試用(不碰 /tmp 的正式戳記)——
# 與 diagnosis-evidence-guard.sh 讀的是同一個變數,兩支要一起改。
stamp_dir = os.environ.get("ISEP_STAMP_DIR", "/tmp")
path = os.path.join(stamp_dir, ".investigated-%s-%s_%s_%s"
% (sid, ref["owner"], ref["repo"], ref["num"]))
try:
with open(path, "w") as f:
f.write(str(int(time.time())))
except Exception:
pass
' 2>/dev/null || true
exit 0