teamsmith 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +69 -0
- package/skills/teamsmith/SKILL.md +20 -13
- package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
- package/skills/teamsmith/extension/team-notify.ts +37 -6
- package/skills/teamsmith/extension/team.ts +438 -0
- package/skills/teamsmith/references/config.md +39 -6
- package/skills/teamsmith/references/migration.md +197 -47
- package/skills/teamsmith/references/protocol.md +201 -30
- package/skills/teamsmith/references/troubleshooting.md +130 -10
- package/skills/teamsmith/references/workflows.md +36 -2
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +318 -23
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +2 -2
- package/skills/teamsmith/scripts/lib/cmd-config.sh +349 -67
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
- package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
- package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
- package/skills/teamsmith/scripts/lib/cmd-project.sh +30 -103
- package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +3 -3
- package/skills/teamsmith/scripts/lib/cmd-review.sh +182 -32
- package/skills/teamsmith/scripts/lib/cmd-status.sh +234 -21
- package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +564 -46
- package/skills/teamsmith/scripts/lib/common.sh +1004 -245
- package/skills/teamsmith/scripts/lib/gate-lock.sh +582 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +211 -211
- package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +12 -5
- package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
- package/skills/teamsmith/scripts/panel/src/data.ts +51 -5
- package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
- package/skills/teamsmith/scripts/panel/src/main.tsx +37 -8
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +39 -29
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +41 -31
- package/skills/teamsmith/scripts/panel/src/types.ts +28 -3
- package/skills/teamsmith/scripts/replies.mjs +4 -1
- package/skills/teamsmith/scripts/shim/killall +10 -0
- package/skills/teamsmith/scripts/shim/pgrep +10 -0
- package/skills/teamsmith/scripts/shim/pidof +10 -0
- package/skills/teamsmith/scripts/shim/pkill +10 -0
- package/skills/teamsmith/scripts/shim/signal-gate +108 -31
- package/skills/teamsmith/scripts/shim/tmux +18 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
- package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
- package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
- package/skills/teamsmith/scripts/team +19 -6
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +8 -1
- package/skills/teamsmith/templates/config.sh.tmpl +20 -1
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +21 -0
- package/skills/teamsmith/tests/README.md +31 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
- package/skills/teamsmith/tests/bg-ledger.sh +168 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +83 -54
- package/skills/teamsmith/tests/config-cli.sh +184 -32
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
- package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
- package/skills/teamsmith/tests/flip-m33.sh +5 -3
- package/skills/teamsmith/tests/flip-p158.sh +2 -1
- package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
- package/skills/teamsmith/tests/flip-p310-lock.sh +210 -0
- package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
- package/skills/teamsmith/tests/gate-guard.sh +52 -79
- package/skills/teamsmith/tests/help-surface.sh +1664 -0
- package/skills/teamsmith/tests/install-shape.sh +359 -22
- package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
- package/skills/teamsmith/tests/key-replies-ui.sh +2 -8
- package/skills/teamsmith/tests/key-replies.sh +281 -28
- package/skills/teamsmith/tests/ledger-ban.sh +5 -4
- package/skills/teamsmith/tests/ledger-claim.sh +2 -1
- package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +4 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +51 -0
- package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
- package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
- package/skills/teamsmith/tests/lib/section-guard.sh +316 -164
- package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
- package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
- package/skills/teamsmith/tests/lib/tmux-iso.sh +31 -13
- package/skills/teamsmith/tests/loop-inventory.tsv +83 -77
- package/skills/teamsmith/tests/panel-b2.sh +430 -352
- package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
- package/skills/teamsmith/tests/panel-b3.sh +314 -62
- package/skills/teamsmith/tests/panel-choices.sh +11 -6
- package/skills/teamsmith/tests/panel-cpu.sh +43 -130
- package/skills/teamsmith/tests/panel-p21.sh +251 -265
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +187 -396
- package/skills/teamsmith/tests/routes.sh +440 -117
- package/skills/teamsmith/tests/seat-interrupt.sh +1012 -0
- package/skills/teamsmith/tests/seat-visibility.sh +675 -0
- package/skills/teamsmith/tests/section-guard.sh +13 -102
- package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
- package/skills/teamsmith/tests/section-paths.tsv +32 -18
- package/skills/teamsmith/tests/section-select.sh +371 -19
- package/skills/teamsmith/tests/signal-gate.sh +249 -27
- package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
- package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
- package/skills/teamsmith/tests/slash-team.sh +617 -0
- package/skills/teamsmith/tests/slice-coverage.sh +206 -0
- package/skills/teamsmith/tests/smoke.sh +3595 -788
- package/skills/teamsmith/tests/task-model-routing.sh +530 -15
- package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
- package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
- package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
- package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
- package/skills/teamsmith/tests/workflow-entry.sh +207 -0
- package/skills/teamsmith-init/SKILL.md +12 -12
- package/skills/teamsmith-init/references/bootstrap.md +3 -3
- package/skills/teamsmith/tests/flip-glue.sh +0 -162
- package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
- package/skills/teamsmith/tests/flip-m12.sh +0 -185
- package/skills/teamsmith/tests/flip-m16.sh +0 -166
- package/skills/teamsmith/tests/flip-m17.sh +0 -204
- package/skills/teamsmith/tests/flip-m34.sh +0 -96
- package/skills/teamsmith/tests/flip-m37.sh +0 -185
- package/skills/teamsmith/tests/flip-m4.3.sh +0 -375
- package/skills/teamsmith/tests/flip-m43.sh +0 -128
- package/skills/teamsmith/tests/flip-m45.sh +0 -244
- package/skills/teamsmith/tests/flip-m46.sh +0 -238
- package/skills/teamsmith/tests/flip-m48.sh +0 -304
- package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
- package/skills/teamsmith/tests/flip-m6.3.sh +0 -283
- package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
- package/skills/teamsmith/tests/flip-m6.5.sh +0 -113
- package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
- package/skills/teamsmith/tests/flip-m7.2.sh +0 -321
- package/skills/teamsmith/tests/flip-p144.sh +0 -112
- package/skills/teamsmith/tests/flip-p156.sh +0 -133
- package/skills/teamsmith/tests/flip-p160.sh +0 -182
- package/skills/teamsmith/tests/flip-p171.sh +0 -249
- package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
- package/skills/teamsmith/tests/flip-p20.sh +0 -286
- package/skills/teamsmith/tests/flip-p201.sh +0 -249
- package/skills/teamsmith/tests/flip-p210.sh +0 -239
- package/skills/teamsmith/tests/flip-p211.sh +0 -152
- package/skills/teamsmith/tests/flip-p217.sh +0 -288
- package/skills/teamsmith/tests/flip-p22.sh +0 -123
- package/skills/teamsmith/tests/flip-p23.sh +0 -239
- package/skills/teamsmith/tests/flip-p25.sh +0 -165
- package/skills/teamsmith/tests/flip-p71.sh +0 -184
- package/skills/teamsmith/tests/flip-p72.sh +0 -202
- package/skills/teamsmith/tests/load-experiment.sh +0 -290
- package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
- package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
- package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
- package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
- package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
- package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
- package/skills/teamsmith/tests/panel-knobs.sh +0 -83
- package/skills/teamsmith/tests/section-budgets.tsv +0 -154
- package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
# teamsmith · team interrupt(P292 · change: seat-interrupt-entry · delta: boundary)
|
|
2
|
+
#
|
|
3
|
+
# 合同:openspec/changes/seat-interrupt-entry/specs/boundary/spec.md 的两条 ADDED。
|
|
4
|
+
# 设计:openspec/changes/seat-interrupt-entry/design.md(对象证明链 §3、判据 §4、审计行 §5、理由投递 §6)。
|
|
5
|
+
#
|
|
6
|
+
# 与既有入口的分工(既有语义一个字都不改):
|
|
7
|
+
# · reap = 孤儿席位进程(窗口没了、进程还在),按 pid 清理;
|
|
8
|
+
# · interrupt = **一个还在跑的席位回合**:对象由「席位自己的派单记录里的窗口 → pane → pid → 身份与
|
|
9
|
+
# 启动时刻」证明出来,先投递理由、再发信号、然后恰好一行审计;
|
|
10
|
+
# · resume = 回来的路(语义不变;本命令只**打印**它,不替 PM 做第二步)。
|
|
11
|
+
#
|
|
12
|
+
# 三条硬边界(与 reap 同源):
|
|
13
|
+
# ① **只按 pid**:pid 只能来自该席位记录里那个窗口的 pane(前台进程,或那个本项目 agent 可执行
|
|
14
|
+
# 文件的直接子进程),再按普查用的**同一套身份判据**证明;没有名字/模式/父子/进程组的进程选择。
|
|
15
|
+
# ② `--yes` 是**唯一**授权:没有它就是一个计划(打印对象/证据/将发的信号,零信号零写盘);配置键、
|
|
16
|
+
# 环境变量、继承值都不能让一个信号默认发出(照 reap:只看这次 argv 上有没有它)。
|
|
17
|
+
# ③ **跨项目零点名**:别的项目的项目名/席位名/工作树/pid 一个都不打印(这份读数会被抄进公开账本)。
|
|
18
|
+
#
|
|
19
|
+
# 与 long-job-suspend 的关系:长**作业**有账本(state/bg.log)也有叫醒;长**回合**两者都没有,本条
|
|
20
|
+
# 补的是后者。被打断席位的后台作业不受影响(detached),续跑后按既有纪律先查 `team bg list`。
|
|
21
|
+
|
|
22
|
+
# 新鲜窗口的秒数(判据两侧:比它更新的席位磁盘证据 → 拒绝)。它是**有界默认值**,不是契约键
|
|
23
|
+
# (与 TEAM_REAP_GRACE_SEC 同族:合同只要求「有界」,所以不进 cmd-config.sh 的 schema);非数字退回默认。
|
|
24
|
+
team_interrupt_fresh_sec() {
|
|
25
|
+
local v="${TEAM_INTERRUPT_FRESH_SEC:-3600}"
|
|
26
|
+
case "$v" in ''|*[!0-9]*) v=3600 ;; esac
|
|
27
|
+
printf '%s\n' "$v"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# SIGTERM 之后的有界等待(秒;与 reap 的 5 秒同族)。
|
|
31
|
+
team_interrupt_grace() {
|
|
32
|
+
local v="${TEAM_INTERRUPT_GRACE_SEC:-5}"
|
|
33
|
+
case "$v" in ''|*[!0-9]*) v=5 ;; esac
|
|
34
|
+
printf '%s\n' "$v"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# 审计日志:一次**授权的**打断恰好一行(计划态与被拒绝的打断一个字都不写)。
|
|
38
|
+
team_interrupt_log_path() { printf '%s\n' "${TEAM_STATE_DIR:-}/interrupt.log"; }
|
|
39
|
+
|
|
40
|
+
# 一句话理由:审计行的形状是固定的,所以理由里的换行/控制字符折叠成单个空格(合同明文要求单行)。
|
|
41
|
+
team_interrupt_one_line() {
|
|
42
|
+
printf '%s' "${1:-}" | tr '\n\r\t' ' ' | tr -d '[:cntrl:]' | tr -s ' ' | sed -e 's/^ *//' -e 's/ *$//'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
team_interrupt_iso() { # <epoch|-> → ISO8601 Z(非数字 → -,不编造)
|
|
46
|
+
local e="${1:-}"
|
|
47
|
+
case "$e" in
|
|
48
|
+
''|*[!0-9]*) printf '%s\n' '-' ;;
|
|
49
|
+
*) date -u -d "@$e" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || printf '%s\n' '-' ;;
|
|
50
|
+
esac
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
team_interrupt_mtime() { # <file> → epoch 秒;读不到 → 空(调用方跳过,不填 0)
|
|
54
|
+
[ -n "${1:-}" ] || return 0
|
|
55
|
+
stat -c %Y -- "$1" 2>/dev/null || stat -f %m -- "$1" 2>/dev/null || true
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# 「还在跑吗」:kill -0 成功但进程已是僵尸 → 它的回合**已经结束**(僵尸只是一个还没被回收的号)。
|
|
59
|
+
# 为什么本命令要认这一条:信号路径用「还在不在」决定要不要 SIGKILL、以及审计里的 outcome;把僵尸算
|
|
60
|
+
# 活着会让一次成功的打断被写成 still-alive(假红),而僵尸不占回合、也收不到信号。
|
|
61
|
+
team_interrupt_alive() { # <pid> → 0 = 还在跑
|
|
62
|
+
local pid="${1:-}" st
|
|
63
|
+
[ -n "$pid" ] || return 1
|
|
64
|
+
kill -0 "$pid" 2>/dev/null || return 1
|
|
65
|
+
st="$(awk '{print $3}' "/proc/$pid/stat" 2>/dev/null || true)"
|
|
66
|
+
[ "$st" = "Z" ] && return 1
|
|
67
|
+
return 0
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# ---------------------------------------------------------------- 对象证明链(design §3)
|
|
71
|
+
# 名册 → 派单记录 → 记录里的窗口 → pane 里的 pid → 身份(普查的同一套判据)+ 记录里的工作树 + 启动时刻。
|
|
72
|
+
# 身份判据**不新造第二套**:形状复用 team_orphan_shape_match(含 pm.pid.spawn / dispatch-*.spawn 排除),
|
|
73
|
+
# 归属复用进程**自己** environ 里的 TEAM_MAIN_ROOT/TEAM_ROOT(team_orphan_* 的同一份读法),再加一条本
|
|
74
|
+
# 入口自己的要求:TEAM_ROOT 必须等于派单记录里的工作树(记录说的是哪个席位进程,就是哪个)。
|
|
75
|
+
# 0 = 成立;否则 TEAM_INTERRUPT_ID 是机器可读的原因(shape|noenv|anon|foreign|other-tree|invalid)。
|
|
76
|
+
team_interrupt_identity() { # <pid> <记录里的 worktree>
|
|
77
|
+
local pid="${1:-}" want="${2:-}" args envtext line mr r nmr nr
|
|
78
|
+
TEAM_INTERRUPT_ID=""
|
|
79
|
+
[ -n "$pid" ] || { TEAM_INTERRUPT_ID=invalid; return 1; }
|
|
80
|
+
# 命令行快照与普查同源(真 /proc 用一次 ps;夹具根读 cmdline)——同时闭掉两次读的竞态。
|
|
81
|
+
args="$(team_reap_argv_of "$pid" 2>/dev/null || true)"
|
|
82
|
+
[ -n "$args" ] || { TEAM_INTERRUPT_ID=shape; return 1; }
|
|
83
|
+
team_orphan_ctx_init
|
|
84
|
+
if ! team_orphan_shape_match "$pid" "$args"; then TEAM_INTERRUPT_ID=shape; return 1; fi
|
|
85
|
+
envtext="$(team_orphan_read_environ "$pid" 2>/dev/null || true)"
|
|
86
|
+
[ -n "$envtext" ] || { TEAM_INTERRUPT_ID=noenv; return 1; }
|
|
87
|
+
mr=''; r=''
|
|
88
|
+
while IFS= read -r line; do
|
|
89
|
+
case "$line" in
|
|
90
|
+
TEAM_MAIN_ROOT=*) mr="${line#TEAM_MAIN_ROOT=}" ;;
|
|
91
|
+
TEAM_ROOT=*) r="${line#TEAM_ROOT=}" ;;
|
|
92
|
+
esac
|
|
93
|
+
done <<< "$envtext"
|
|
94
|
+
[ -n "$mr" ] && [ -n "$r" ] || { TEAM_INTERRUPT_ID=anon; return 1; }
|
|
95
|
+
nmr="$(team_orphan_norm_path "$mr" 2>/dev/null || printf '%s' "$mr")"
|
|
96
|
+
nr="$(team_orphan_norm_path "$r" 2>/dev/null || printf '%s' "$r")"
|
|
97
|
+
if [ -z "${TEAM_ORPHAN_SELF_MAIN:-}" ] || [ "$nmr" != "$TEAM_ORPHAN_SELF_MAIN" ]; then
|
|
98
|
+
TEAM_INTERRUPT_ID=foreign; return 1
|
|
99
|
+
fi
|
|
100
|
+
if [ -n "$want" ] && [ "$nr" != "$(team_orphan_norm_path "$want" 2>/dev/null || printf '%s' "$want")" ]; then
|
|
101
|
+
TEAM_INTERRUPT_ID=other-tree; return 1
|
|
102
|
+
fi
|
|
103
|
+
TEAM_INTERRUPT_ID=own
|
|
104
|
+
return 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# 这个席位有没有「窗口没了、进程还在」的孤儿(拒绝时要说清该走 reap 而不是 resume)。
|
|
108
|
+
# 判据是普查的原样输出(kind=own + seat 命中 + judge=orphan),不新造第二套**只读**。
|
|
109
|
+
team_interrupt_orphan_present() { # <seat> → 0 = 有
|
|
110
|
+
local seat="${1:-}" rec pid kind s task start rss judge
|
|
111
|
+
[ -n "$seat" ] || return 1
|
|
112
|
+
team_orphan_ctx_init
|
|
113
|
+
while IFS=$'\t' read -r pid kind s task start rss judge; do
|
|
114
|
+
[ "$kind" = "own" ] || continue
|
|
115
|
+
[ "$s" = "$seat" ] || continue
|
|
116
|
+
[ "$judge" = "orphan" ] && return 0
|
|
117
|
+
done < <(team_orphan_census 2>/dev/null)
|
|
118
|
+
return 1
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# ---------------------------------------------------------------- 判据的证据(design §4)
|
|
122
|
+
# 两份证据一次读全:①该席位那次会话的会话文件(派单记录里的 sid 解析出来的那份)的 mtime;
|
|
123
|
+
# ②工作树里 git 报为改动的文件(`--porcelain -z`:路径按原始字节读,重命名/复制的第二段跳掉)的
|
|
124
|
+
# mtime 与**条数**。同一读既给审计的 `uncommitted=` 又给新鲜窗口的判据。
|
|
125
|
+
team_interrupt_evidence() { # <worktree> <sid>
|
|
126
|
+
local wt="${1:-}" sid="${2:-}" f m entry x y path mm
|
|
127
|
+
TEAM_INTERRUPT_SESSION_FILE=""; TEAM_INTERRUPT_SESSION_LAST=""
|
|
128
|
+
TEAM_INTERRUPT_UNCOMMITTED=0
|
|
129
|
+
TEAM_INTERRUPT_WT_FILE=""; TEAM_INTERRUPT_WT_MTIME=""
|
|
130
|
+
if [ -n "$sid" ] && [ -n "$wt" ]; then
|
|
131
|
+
f="$(team_session_file "$sid" "$wt" 2>/dev/null || true)"
|
|
132
|
+
if [ -n "$f" ]; then
|
|
133
|
+
m="$(team_interrupt_mtime "$f")"
|
|
134
|
+
TEAM_INTERRUPT_SESSION_FILE="$f"
|
|
135
|
+
TEAM_INTERRUPT_SESSION_LAST="$m"
|
|
136
|
+
fi
|
|
137
|
+
fi
|
|
138
|
+
if [ -n "$wt" ] && [ -d "$wt" ] && team_have_cmd git; then
|
|
139
|
+
while IFS= read -r -d '' entry; do
|
|
140
|
+
[ -n "$entry" ] || continue
|
|
141
|
+
x="${entry:0:1}"; y="${entry:1:1}"; path="${entry:3}"
|
|
142
|
+
# -z 的路径是原始字节;R/C 的条目后面**还有**一段「原路径」,它不是第二个文件
|
|
143
|
+
case "$x$y" in *R*|*C*) IFS= read -r -d '' _ || true ;; esac
|
|
144
|
+
TEAM_INTERRUPT_UNCOMMITTED=$((TEAM_INTERRUPT_UNCOMMITTED + 1))
|
|
145
|
+
[ -n "$path" ] || continue
|
|
146
|
+
mm="$(team_interrupt_mtime "$wt/$path")"
|
|
147
|
+
[ -n "$mm" ] || continue
|
|
148
|
+
if [ -z "$TEAM_INTERRUPT_WT_MTIME" ] || [ "$mm" -gt "$TEAM_INTERRUPT_WT_MTIME" ]; then
|
|
149
|
+
TEAM_INTERRUPT_WT_MTIME="$mm"; TEAM_INTERRUPT_WT_FILE="$path"
|
|
150
|
+
fi
|
|
151
|
+
done < <(git -C "$wt" status --porcelain -z --untracked-files=all 2>/dev/null)
|
|
152
|
+
fi
|
|
153
|
+
return 0
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# 两份证据里**最新**的那份比窗口更新 → 拒绝(返回 1;TEAM_INTERRUPT_FRESH_FILE / _AGE 是要点名的数)。
|
|
157
|
+
# 没有证据(两份都读不到)→ 放行(缺证据不编造:它正是 D188 的形状,也是本入口存在的理由)。
|
|
158
|
+
team_interrupt_fresh_check() { # <now> <window-sec>
|
|
159
|
+
local now="${1:-0}" win="${2:-0}" m="" f=""
|
|
160
|
+
TEAM_INTERRUPT_FRESH_FILE=""; TEAM_INTERRUPT_FRESH_AGE=""
|
|
161
|
+
if [ -n "${TEAM_INTERRUPT_SESSION_LAST:-}" ]; then
|
|
162
|
+
f="${TEAM_INTERRUPT_SESSION_FILE}"; m="$TEAM_INTERRUPT_SESSION_LAST"
|
|
163
|
+
fi
|
|
164
|
+
if [ -n "${TEAM_INTERRUPT_WT_MTIME:-}" ]; then
|
|
165
|
+
if [ -z "$m" ] || [ "$TEAM_INTERRUPT_WT_MTIME" -gt "$m" ]; then
|
|
166
|
+
m="$TEAM_INTERRUPT_WT_MTIME"; f="${TEAM_INTERRUPT_WT_FILE}"
|
|
167
|
+
fi
|
|
168
|
+
fi
|
|
169
|
+
[ -n "$m" ] || return 0
|
|
170
|
+
TEAM_INTERRUPT_FRESH_FILE="$f"
|
|
171
|
+
TEAM_INTERRUPT_FRESH_AGE=$(( now - m ))
|
|
172
|
+
[ "$TEAM_INTERRUPT_FRESH_AGE" -ge "$win" ] && return 0
|
|
173
|
+
return 1
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
# ---------------------------------------------------------------- 发信号(与 reap 同一套纪律)
|
|
177
|
+
# 发信号**之前**的复验:仍是记录里那个窗口、pane 里的 agent 进程仍是同一个 pid、身份仍成立、
|
|
178
|
+
# 启动时刻与本次读到的计划值一致。任何一条不成立 → 拒发并给出理由(TEAM_INTERRUPT_RE)。
|
|
179
|
+
team_interrupt_reverify() { # <window> <pid> <planned-start> <worktree>
|
|
180
|
+
local win="${1:-}" pid="${2:-}" planned="${3:-}" wt="${4:-}" now_pid now_start
|
|
181
|
+
TEAM_INTERRUPT_RE=""
|
|
182
|
+
if ! team_tmux_has_window "$TEAM_SESSION" "$win"; then
|
|
183
|
+
TEAM_INTERRUPT_RE="窗口 $TEAM_SESSION:$win 已经不在了(回合早已结束)"
|
|
184
|
+
return 1
|
|
185
|
+
fi
|
|
186
|
+
now_pid="$(team_pane_agent_pid "$TEAM_SESSION:$win" 2>/dev/null || true)"
|
|
187
|
+
if [ "$now_pid" != "$pid" ]; then
|
|
188
|
+
TEAM_INTERRUPT_RE="窗口里的 agent 进程已经不是计划时那个 pid(计划=$pid 现在=${now_pid:-无})—— 它不再是那个被证明过的进程"
|
|
189
|
+
return 1
|
|
190
|
+
fi
|
|
191
|
+
if ! team_interrupt_identity "$pid" "$wt"; then
|
|
192
|
+
case "${TEAM_INTERRUPT_ID:-}" in
|
|
193
|
+
foreign) TEAM_INTERRUPT_RE="pid $pid 的身份在读它的时候变成了**别的项目**的(跨项目零点名)" ;;
|
|
194
|
+
anon) TEAM_INTERRUPT_RE="pid $pid 的身份读不到了(没有 teamsmith 身份)" ;;
|
|
195
|
+
other-tree) TEAM_INTERRUPT_RE="pid $pid 的 TEAM_ROOT 与派单记录的工作树不一致" ;;
|
|
196
|
+
*) TEAM_INTERRUPT_RE="pid $pid 不再是席位形状的进程(命令行/身份读不到)" ;;
|
|
197
|
+
esac
|
|
198
|
+
return 1
|
|
199
|
+
fi
|
|
200
|
+
now_start="$(team_orphan_start_epoch "$pid" 2>/dev/null || true)"
|
|
201
|
+
if [ -z "$now_start" ]; then
|
|
202
|
+
TEAM_INTERRUPT_RE="pid $pid 的启动时刻读不到 —— 判不出就不猜"
|
|
203
|
+
return 1
|
|
204
|
+
fi
|
|
205
|
+
if [ -n "$planned" ] && [ "$now_start" != "$planned" ]; then
|
|
206
|
+
TEAM_INTERRUPT_RE="pid $pid 的启动时刻与计划时不一致(计划=$planned 现在=$now_start:pid 可能已被内核回收)"
|
|
207
|
+
return 1
|
|
208
|
+
fi
|
|
209
|
+
return 0
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
# SIGTERM → 有界等待 → 仍活着再 SIGKILL。结果写进 TEAM_INTERRUPT_SIGNAL / TEAM_INTERRUPT_OUTCOME。
|
|
213
|
+
team_interrupt_signal() { # <pid> → 0 = 目标已退出
|
|
214
|
+
local pid="${1:-}" grace ticks i
|
|
215
|
+
grace="$(team_interrupt_grace)"
|
|
216
|
+
TEAM_INTERRUPT_SIGNAL=""; TEAM_INTERRUPT_OUTCOME=""
|
|
217
|
+
if ! kill -TERM "$pid" 2>/dev/null; then
|
|
218
|
+
TEAM_INTERRUPT_SIGNAL="SIGTERM"; TEAM_INTERRUPT_OUTCOME="failed"
|
|
219
|
+
team_err "interrupt: pid $pid 的 SIGTERM 发不出去(进程刚好消失了?)"
|
|
220
|
+
return 1
|
|
221
|
+
fi
|
|
222
|
+
TEAM_INTERRUPT_SIGNAL="SIGTERM"
|
|
223
|
+
ticks=$(( grace * 10 )); i=0
|
|
224
|
+
while [ "$i" -lt "$ticks" ]; do
|
|
225
|
+
team_interrupt_alive "$pid" || break
|
|
226
|
+
sleep 0.1
|
|
227
|
+
i=$((i + 1))
|
|
228
|
+
done
|
|
229
|
+
if ! team_interrupt_alive "$pid"; then TEAM_INTERRUPT_OUTCOME="gone"; return 0; fi
|
|
230
|
+
TEAM_INTERRUPT_SIGNAL="SIGTERM→SIGKILL"
|
|
231
|
+
if ! kill -KILL "$pid" 2>/dev/null; then
|
|
232
|
+
TEAM_INTERRUPT_OUTCOME="failed"
|
|
233
|
+
team_err "interrupt: pid $pid 的 SIGKILL 发不出去"
|
|
234
|
+
return 1
|
|
235
|
+
fi
|
|
236
|
+
i=0
|
|
237
|
+
while [ "$i" -lt 100 ]; do
|
|
238
|
+
team_interrupt_alive "$pid" || break
|
|
239
|
+
sleep 0.1
|
|
240
|
+
i=$((i + 1))
|
|
241
|
+
done
|
|
242
|
+
if team_interrupt_alive "$pid"; then
|
|
243
|
+
TEAM_INTERRUPT_OUTCOME="still-alive"
|
|
244
|
+
team_err "interrupt: pid $pid 在 SIGKILL 之后仍然活着(不可中断 / D 状态?)"
|
|
245
|
+
return 1
|
|
246
|
+
fi
|
|
247
|
+
TEAM_INTERRUPT_OUTCOME="gone"
|
|
248
|
+
return 0
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
# 一行审计(design §5):一次打断一行;`session_last` 与 `uncommitted` 是**发信号之前**读到的那一份。
|
|
252
|
+
team_interrupt_audit() { # <actor> <seat> <pid> <session_last> <uncommitted> <guard> <reason> <signal> <outcome>
|
|
253
|
+
local f; f="$(team_interrupt_log_path)"
|
|
254
|
+
printf '%s actor=%s seat=%s pid=%s session_last=%s uncommitted=%s guard=%s reason=%s signal=%s outcome=%s\n' \
|
|
255
|
+
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "${1:--}" "${2:--}" "${3:--}" "${4:--}" "${5:--}" "${6:--}" \
|
|
256
|
+
"${7:--}" "${8:--}" "${9:--}" >> "$f" || return 1
|
|
257
|
+
return 0
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
# 理由投递(design §6):席位续跑后读的三步里,第二步就是它自己的线程(dispatch 的提示词里逐字写着
|
|
261
|
+
# threads/<seat>.md);收件箱那一行是同一件事的持续通知。写不进去就返回 1 —— 调用方据此拒发。
|
|
262
|
+
# 它是独立的一层,为的是让「先写理由、后发信号」这条顺序能被单独推翻与验证(红侧)。
|
|
263
|
+
# 线程追加:单独一层。为什么不能写在一个 `if ! { …; } >> "$f"` 里 —— bash 对「复合命令的重定向失败」
|
|
264
|
+
# 在 `!` 位上的状态会看不见(实测:rc=1 但 `if !` 走 else,=> “写不进去”被当成写成功了)。
|
|
265
|
+
# 单独一层用 `||` 拿状态就没这个陷阱,也能被红侧单独推翻。
|
|
266
|
+
team_interrupt_thread_append() { # <线程文件> <条目文本>
|
|
267
|
+
{ [ -s "$1" ] && printf '\n'; printf '%s' "$2"; } >> "$1" 2>/dev/null || return 1
|
|
268
|
+
return 0
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
team_interrupt_deliver_reason() { # <actor> <seat> <task> <pid> <reason> → 0 = 两处都写好了
|
|
272
|
+
local actor="${1:-}" seat="${2:-}" task="${3:-}" pid="${4:-}" reason="${5:-}"
|
|
273
|
+
local thread_file="$TEAM_DOCS_ABS/threads/$seat.md" inbox_file="$TEAM_DOCS_ABS/inbox/$seat.md" body entry
|
|
274
|
+
body="$(printf '回合被打断(interrupt):%s 在 %s 结束了该席位正在跑的回合(pid=%s,理由:%s)。\n磁盘状态都在:工作树里未提交的改动、它那次会话的会话文件与派单记录一个字节没动。\n先做什么:先看这一段(本线程最新一条)与 `git status`,确认打断前后的状态;再按任务书继续 %s。回到同一会话:`team resume --agent %s`;后台作业先 `team bg list`。' \
|
|
275
|
+
"$actor" "$(team_timestamp)" "$pid" "$reason" "${task:-<本任务>}" "$seat")"
|
|
276
|
+
entry="$(printf '### %s · from: %s · re: %s\n%s\n' "$(team_timestamp)" "$actor" "${task:--}" "$body")"
|
|
277
|
+
if ! team_interrupt_thread_append "$thread_file" "$entry"; then
|
|
278
|
+
team_err "interrupt: 理由写不进该席位的线程($thread_file)—— 拒发(没有理由的打断不许发生)"
|
|
279
|
+
return 1
|
|
280
|
+
fi
|
|
281
|
+
if ! team_inbox_append "$seat" "interrupt" "(回合被打断:$actor · pid=$pid)$reason" "$actor" 2>/dev/null; then
|
|
282
|
+
team_err "interrupt: 理由写不进该席位的收件箱($inbox_file)—— 拒发(线程里已写、信号没发)"
|
|
283
|
+
return 1
|
|
284
|
+
fi
|
|
285
|
+
return 0
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
team_interrupt_usage() {
|
|
289
|
+
printf '用法:team interrupt <seat> --reason <一句话> [--force] [--yes]\n'
|
|
290
|
+
printf ' 结束该席位**当前的回合**(对它自己被证明过的进程发 SIGTERM,有界等待后仍活着再 SIGKILL);\n'
|
|
291
|
+
printf ' 磁盘状态保留(未提交改动 / 会话文件 / 派单记录),回来的路是 team resume --agent <seat>。\n'
|
|
292
|
+
printf ' 没有 --yes 是计划:打印对象、证据与将发的信号,一个信号都不发、一个字都不写。\n'
|
|
293
|
+
printf ' --reason 必填:发信号**之前**写进该席位的线程(它续跑时的第二步就是读它)与收件箱。\n'
|
|
294
|
+
printf ' --force 只越过「席位正在写盘」这一条:最新的磁盘证据比新鲜窗口(默认 3600s,'
|
|
295
|
+
printf 'TEAM_INTERRUPT_FRESH_SEC 可调)更新时本命令拒绝,越权会写进那一行审计(guard=forced)。\n'
|
|
296
|
+
printf ' --yes 是唯一授权:配置键、环境变量、继承值都不能让一个信号默认发出。\n'
|
|
297
|
+
printf ' 不属于本入口的:没有在跑的回合 → team resume --agent <seat>;窗口没了而进程还在(孤儿)→ team reap --orphans。\n'
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
# ---------------------------------------------------------------- 入口
|
|
301
|
+
team_cmd_interrupt() {
|
|
302
|
+
local seat="" reason="" reason_set=0 force=0 yes=0
|
|
303
|
+
# `--yes` 是**唯一**授权:只看这次 argv 上有没有它(scripts/team 的全局解析器把它落成 TEAM_YES_ARGV=1)。
|
|
304
|
+
# 显式不看 TEAM_CONFIRM_WRITES / TEAM_ASSUME_YES —— 它们都不是「人这次说了要动手」的证据。
|
|
305
|
+
[ "${TEAM_YES_ARGV:-0}" = "1" ] && yes=1
|
|
306
|
+
while [ $# -gt 0 ]; do
|
|
307
|
+
case "$1" in
|
|
308
|
+
--yes) yes=1; shift ;;
|
|
309
|
+
--force) force=1; shift ;;
|
|
310
|
+
--reason) [ $# -ge 2 ] || team_usage_die "interrupt: --reason 需要一句话"; reason="$2"; reason_set=1; shift 2 ;;
|
|
311
|
+
--reason=*) reason="${1#*=}"; reason_set=1; shift ;;
|
|
312
|
+
-h|--help) team_interrupt_usage; return 0 ;;
|
|
313
|
+
-*) team_usage_die "interrupt: 未知参数 $1" ;;
|
|
314
|
+
*) if [ -z "$seat" ]; then seat="$1"; shift; else team_usage_die "interrupt: 多余参数 $1"; fi ;;
|
|
315
|
+
esac
|
|
316
|
+
done
|
|
317
|
+
[ -n "$seat" ] || team_usage_die "interrupt: 需要席位名(interrupt <seat> --reason <一句话> [--force] [--yes])"
|
|
318
|
+
|
|
319
|
+
# ① 理由必填:在任何写入与信号之前拒绝(没有理由就没有这一族动作 —— 与「一次打断一句话理由」同源)。
|
|
320
|
+
if [ "$reason_set" != 1 ]; then
|
|
321
|
+
team_err "interrupt: 缺少 --reason(每次打断都要一句话理由)—— 什么都没写、什么都没发"
|
|
322
|
+
return 2
|
|
323
|
+
fi
|
|
324
|
+
reason="$(team_interrupt_one_line "$reason")"
|
|
325
|
+
if [ -z "$reason" ]; then
|
|
326
|
+
team_err "interrupt: --reason 是空的(要一句话理由)—— 什么都没写、什么都没发"
|
|
327
|
+
return 2
|
|
328
|
+
fi
|
|
329
|
+
|
|
330
|
+
# ② actor 从运行时目录解析(审计的第一件事是「谁」);解析不出来就拒绝,身份不许猜。
|
|
331
|
+
local actor; actor="$(team_sender_resolve 2>/dev/null || true)"
|
|
332
|
+
if [ -z "$actor" ]; then
|
|
333
|
+
team_err "interrupt: actor 解析不出来(运行时目录不在本项目的工作树里)—— 审计的第一格是「谁」,不猜;什么都没写、什么都没发"
|
|
334
|
+
return 2
|
|
335
|
+
fi
|
|
336
|
+
|
|
337
|
+
# ③ 名册:入口参数是**本项目的席位名**(这是唯一的「名字」,它映射到本项目自己的记录与窗口)。
|
|
338
|
+
if ! team_agent_known "$seat"; then
|
|
339
|
+
team_err "interrupt: 「$seat」不在名册($(team_agents | tr '\n' ' '))—— 名册由 team add-agent <名字> --register 维护"
|
|
340
|
+
return 2
|
|
341
|
+
fi
|
|
342
|
+
|
|
343
|
+
# ④ 派单记录:窗口 / 工作树 / 会话 id 都从它来(没有记录就没有对象证明链,也没有回来的路)。
|
|
344
|
+
if ! team_assignment_load "$seat"; then
|
|
345
|
+
team_err "interrupt: 席位 $seat 没有可读的派单记录(state/$seat.env:${TEAM_ASSIGN_DIAGNOSTIC:-?})—— 没有记录就没有对象证明链"
|
|
346
|
+
team_dim " 它没有在跑的回合:team resume --agent $seat(或 team dispatch 重新派)" >&2
|
|
347
|
+
return 2
|
|
348
|
+
fi
|
|
349
|
+
local wt="${TEAM_ASSIGN[worktree]:-}" win="${TEAM_ASSIGN[window]:-}" sid="${TEAM_ASSIGN[sid]:-}" \
|
|
350
|
+
task="${TEAM_ASSIGN[task]:-}" mode="${TEAM_ASSIGN[mode]:-}"
|
|
351
|
+
[ -n "$win" ] || win="$seat"
|
|
352
|
+
local target="$TEAM_SESSION:$win"
|
|
353
|
+
|
|
354
|
+
# ⑤ 存活与拒绝集合各自给出路:进程不在 → resume;窗口没了而进程还在(孤儿)→ reap。
|
|
355
|
+
if ! team_tmux_has_window "$TEAM_SESSION" "$win"; then
|
|
356
|
+
if team_interrupt_orphan_present "$seat"; then
|
|
357
|
+
team_err "interrupt: 席位 $seat 的窗口 $win 没了、进程还活着(孤儿)—— 走 team reap --orphans"
|
|
358
|
+
else
|
|
359
|
+
team_err "interrupt: 席位 $seat 没有在跑的回合(窗口 $target 不存在)—— 走 team resume --agent $seat"
|
|
360
|
+
fi
|
|
361
|
+
return 2
|
|
362
|
+
fi
|
|
363
|
+
local pid; pid="$(team_pane_agent_pid "$target" 2>/dev/null || true)"
|
|
364
|
+
if [ -z "$pid" ]; then
|
|
365
|
+
team_err "interrupt: 窗口 $target 里没有证明是本项目 agent 的进程(回合已经结束了)—— 走 team resume --agent $seat"
|
|
366
|
+
return 2
|
|
367
|
+
fi
|
|
368
|
+
|
|
369
|
+
# ⑥ 调用者自己与它的祖先:拒发(那不是席位,是起你的那个壳)。--force 也越不过这一条。
|
|
370
|
+
if team_reap_is_self_or_ancestor "$pid"; then
|
|
371
|
+
team_err "interrupt: pid $pid 是调用者自己或它的祖先 —— 拒发(本入口只结束**别的**进程的回合)"
|
|
372
|
+
return 2
|
|
373
|
+
fi
|
|
374
|
+
|
|
375
|
+
# ⑦ 身份:过程自己的 TEAM_MAIN_ROOT(本项目)+ TEAM_ROOT(= 记录里的工作树)+ 形状(本项目 agent 可执行文件)。
|
|
376
|
+
if ! team_interrupt_identity "$pid" "$wt"; then
|
|
377
|
+
case "${TEAM_INTERRUPT_ID:-}" in
|
|
378
|
+
foreign)
|
|
379
|
+
team_err "interrupt: 窗口里的进程身份属于**别的项目** —— 拒发(跨项目零点名:它的项目名/席位名/工作树/pid 都不打印)" ;;
|
|
380
|
+
anon)
|
|
381
|
+
team_err "interrupt: 窗口里的进程没有 teamsmith 身份 —— 拒发(它可能不是任何项目的席位)" ;;
|
|
382
|
+
other-tree)
|
|
383
|
+
team_err "interrupt: 窗口里的进程是**本项目别的**工作树里的席位进程(与派单记录的工作树不一致)—— 拒发(对象不是记录里那个席位进程)" ;;
|
|
384
|
+
*)
|
|
385
|
+
team_err "interrupt: 窗口里的进程不是本项目配置的 agent 可执行文件(或它的命令行/身份读不到)—— 拒发" ;;
|
|
386
|
+
esac
|
|
387
|
+
return 2
|
|
388
|
+
fi
|
|
389
|
+
local planned_start; planned_start="$(team_orphan_start_epoch "$pid" 2>/dev/null || true)"
|
|
390
|
+
|
|
391
|
+
# ⑧ 判据:发信号**之前**的读数(会话最后落盘 + 工作树未提交条数 + 最新那份证据)。
|
|
392
|
+
team_interrupt_evidence "$wt" "$sid"
|
|
393
|
+
local now fresh_sec fresh_ok=0 guard="clear"
|
|
394
|
+
now="$(date +%s)"
|
|
395
|
+
fresh_sec="$(team_interrupt_fresh_sec)"
|
|
396
|
+
team_interrupt_fresh_check "$now" "$fresh_sec" || fresh_ok=1
|
|
397
|
+
if [ "$fresh_ok" = 1 ] && [ "$force" != 1 ]; then
|
|
398
|
+
team_err "interrupt: 席位 $seat 正在写盘 —— 最新的一份磁盘证据比新鲜窗口(${fresh_sec}s)更新:"
|
|
399
|
+
team_err " $TEAM_INTERRUPT_FRESH_FILE(${TEAM_INTERRUPT_FRESH_AGE}s 前)"
|
|
400
|
+
team_dim " 要越过它:--force + 一句话理由(越权会写进那一行审计 guard=forced)。--force 越不过身份/存活/名册/跨项目/自身。" >&2
|
|
401
|
+
return 2
|
|
402
|
+
fi
|
|
403
|
+
[ "$fresh_ok" = 1 ] && guard="forced"
|
|
404
|
+
|
|
405
|
+
# ── 计划态(默认):证据全部读出来、一个信号都不发、一个字都不写 ──
|
|
406
|
+
if [ "$yes" != 1 ]; then
|
|
407
|
+
printf 'interrupt 计划(席位 %s;**未授权** —— 一个信号都不会发、一个字都不会写;加 --yes 执行):\n' "$seat"
|
|
408
|
+
printf ' 对象:pid=%s(窗口 %s 里的 agent 进程;身份=本项目席位、TEAM_ROOT=%s)\n' "$pid" "$target" "$wt"
|
|
409
|
+
printf ' 启动:%s(启动时刻;发信号前会与它比对)\n' "$(team_interrupt_iso "${planned_start:--}")"
|
|
410
|
+
printf ' 证据:会话最后落盘=%s' "$(team_interrupt_iso "${TEAM_INTERRUPT_SESSION_LAST:--}")"
|
|
411
|
+
[ -n "$TEAM_INTERRUPT_SESSION_FILE" ] && printf '(%s)' "$TEAM_INTERRUPT_SESSION_FILE"
|
|
412
|
+
printf ';工作树未提交=%s 个\n' "$TEAM_INTERRUPT_UNCOMMITTED"
|
|
413
|
+
if [ -n "$TEAM_INTERRUPT_FRESH_FILE" ]; then
|
|
414
|
+
printf ' 最新磁盘证据:%s(%ss 前;新鲜窗口 %ss,guard=%s)\n' \
|
|
415
|
+
"$TEAM_INTERRUPT_FRESH_FILE" "$TEAM_INTERRUPT_FRESH_AGE" "$fresh_sec" "$guard"
|
|
416
|
+
else
|
|
417
|
+
printf ' 最新磁盘证据:(读不到 —— 缺证据不编造;新鲜窗口 %ss,guard=%s)\n' "$fresh_sec" "$guard"
|
|
418
|
+
fi
|
|
419
|
+
printf ' 将发信号:SIGTERM → %ss 后仍活着再 SIGKILL(只对这一个 pid)\n' "$(team_interrupt_grace)"
|
|
420
|
+
printf ' 理由:%s\n' "$reason"
|
|
421
|
+
printf ' 之后:team resume --agent %s(回到记录里的会话 sid=%s,mode=%s)\n' "$seat" "${sid:--}" "${mode:--}"
|
|
422
|
+
printf ' 审计:%s(执行时恰好一行;计划态不写)\n' "$(team_interrupt_log_path)"
|
|
423
|
+
return 0
|
|
424
|
+
fi
|
|
425
|
+
|
|
426
|
+
# ── 执行态(--yes)────────────────────────────────────────────────────────────────────────
|
|
427
|
+
# ① 复验(发信号**之前**;不过 → 拒绝,thread/inbox/审计一个字节都不动)。
|
|
428
|
+
if ! team_interrupt_reverify "$win" "$pid" "$planned_start" "$wt"; then
|
|
429
|
+
team_err "interrupt: 复验不过,拒发 —— $TEAM_INTERRUPT_RE"
|
|
430
|
+
team_dim " 一个信号都没发;该席位的线程、收件箱与审计日志都没有变。" >&2
|
|
431
|
+
return 2
|
|
432
|
+
fi
|
|
433
|
+
|
|
434
|
+
# ② 理由投递:**先写理由、后发信号**(写不进去就拒绝,绝不出现「杀了它,但它不知道为什么」)。
|
|
435
|
+
# 线程是席位阅读顺序的第二步(dispatch 的提示词里逐字写着 threads/<seat>.md)。
|
|
436
|
+
team_interrupt_deliver_reason "$actor" "$seat" "$task" "$pid" "$reason" || return 2
|
|
437
|
+
|
|
438
|
+
# ③ 审计日志先就绪(授权之后才写盘;写不了就拒绝,绝不发一个没有记录可查的信号)。
|
|
439
|
+
: >> "$(team_interrupt_log_path)" 2>/dev/null || {
|
|
440
|
+
team_err "interrupt: 审计日志写不了($(team_interrupt_log_path))—— 拒发(没有记录就没有动作)"
|
|
441
|
+
return 2
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
# ④ 信号:只对这一个 pid。
|
|
445
|
+
local rc=0
|
|
446
|
+
printf 'interrupt 执行(--yes;席位 %s pid=%s):\n' "$seat" "$pid"
|
|
447
|
+
printf ' 理由已写进线程 %s 与收件箱 %s(在发信号之前)\n' "$TEAM_DOCS_ABS/threads/$seat.md" "$TEAM_DOCS_ABS/inbox/$seat.md"
|
|
448
|
+
team_interrupt_signal "$pid" || rc=1
|
|
449
|
+
if ! team_interrupt_audit "$actor" "$seat" "$pid" "$(team_interrupt_iso "${TEAM_INTERRUPT_SESSION_LAST:--}")" \
|
|
450
|
+
"$TEAM_INTERRUPT_UNCOMMITTED" "$guard" "$reason" "${TEAM_INTERRUPT_SIGNAL:--}" "${TEAM_INTERRUPT_OUTCOME:--}"; then
|
|
451
|
+
team_err "interrupt: 审计写不进去($(team_interrupt_log_path))—— 动作已经做了,但**没有记录可查**,请 PM 手工补一行"
|
|
452
|
+
rc=1
|
|
453
|
+
fi
|
|
454
|
+
if [ "$rc" = 0 ]; then
|
|
455
|
+
team_ok "interrupt: pid $pid 的回合已结束(${TEAM_INTERRUPT_SIGNAL} → ${TEAM_INTERRUPT_OUTCOME});审计 $(team_interrupt_log_path) 1 行"
|
|
456
|
+
else
|
|
457
|
+
team_err "interrupt: pid $pid 没有收干净(${TEAM_INTERRUPT_SIGNAL:--} → ${TEAM_INTERRUPT_OUTCOME:--});审计 $(team_interrupt_log_path) 1 行"
|
|
458
|
+
fi
|
|
459
|
+
printf ' 之后:team resume --agent %s(回到记录里的会话 sid=%s,mode=%s)\n' "$seat" "${sid:--}" "${mode:--}"
|
|
460
|
+
return "$rc"
|
|
461
|
+
}
|
|
@@ -259,31 +259,8 @@ team_cmd_meeting() {
|
|
|
259
259
|
esac
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
team_meeting_help() {
|
|
263
|
-
|
|
264
|
-
team meeting —— 跨项目会议(peer 交流,不是指挥通道)
|
|
265
|
-
|
|
266
|
-
open <slug> --with <项目>[:<session>] --topic "…" [--ttl 72] [--force] [--yes]
|
|
267
|
-
开会(需要 --yes:这是写共享状态)。发起方 = 当前项目($TEAM_PROJECT)。
|
|
268
|
-
--ttl 是正整数小时(默认 $(team_meeting_ttl_default),>8760 按 8760 计;非法值直接拒绝);到期后只读。
|
|
269
|
-
say <slug> --intent <info|question|report|proposal|request> "…" [--knock]
|
|
270
|
-
发言:先写共享区 transcript(唯一真相),--knock 才提醒对方 PM 窗口(需 TEAM_MEETING_KNOCK=1)。
|
|
271
|
-
**没有 command/order 这类 intent** —— 机制上不提供"下令"动作。
|
|
272
|
-
read <slug> [--since N] [--peek] 读发言(默认读到哪标记到哪;--peek 不标记)
|
|
273
|
-
inbox 哪些会议在等我回应
|
|
274
|
-
list [--all] 我在参与的会议
|
|
275
|
-
peer <slug> <项目>:<session> [--window <名>] [--repo <仓库名>]
|
|
276
|
-
登记一方的 session/PM 窗口/仓库名(各管各的行;敲门按对方那一行解析目标窗口)
|
|
277
|
-
knock <slug> 重敲最后一条发言(载荷带 [meeting:<slug>#<N>])
|
|
278
|
-
propose <slug> "接口契约…" [--sides "我方:X / 对方:Y"] 提议一条共识
|
|
279
|
-
agree <slug> <A1> [--note "我方落地:T4.2"] 对方确认(不能自己确认自己提的)
|
|
280
|
-
close <slug> [--summary "结论与遗留"] 关闭(唯一收尾动作;过期后仍可用它收尾)
|
|
281
|
-
close --stale 关闭本项目所有“已过期未关闭”的会议;一个都没有时非 0 且不写任何东西
|
|
282
|
-
|
|
283
|
-
规则:只写共享区($(team_meetings_dir)),不动对方仓库;共识由双方各自 agree;
|
|
284
|
-
用户是唯一能跨项目下指令的人(人类终端可 team meeting say --as-user)。
|
|
285
|
-
HELP
|
|
286
|
-
return 0
|
|
262
|
+
team_meeting_help() { # cli-help:meeting 的整页与 `team help meeting` 是同一个渲染出口
|
|
263
|
+
team_help_command_page meeting
|
|
287
264
|
}
|
|
288
265
|
|
|
289
266
|
team_meeting_open() {
|