teamsmith 0.1.2 → 0.3.0

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.
Files changed (158) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +67 -0
  4. package/skills/teamsmith/SKILL.md +26 -8
  5. package/skills/teamsmith/extension/team-notify.ts +37 -6
  6. package/skills/teamsmith/extension/team.ts +438 -0
  7. package/skills/teamsmith/references/agent-adapters.md +7 -7
  8. package/skills/teamsmith/references/config.md +65 -18
  9. package/skills/teamsmith/references/migration.md +220 -34
  10. package/skills/teamsmith/references/protocol.md +250 -25
  11. package/skills/teamsmith/references/troubleshooting.md +124 -7
  12. package/skills/teamsmith/references/workflows.md +66 -20
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
  16. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  17. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  18. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  19. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  20. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  21. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  22. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  23. package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
  24. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  25. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  26. package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
  27. package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
  28. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  29. package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
  30. package/skills/teamsmith/scripts/lib/common.sh +1560 -109
  31. package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
  32. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  33. package/skills/teamsmith/scripts/panel/README.md +22 -11
  34. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  35. package/skills/teamsmith/scripts/panel/panel.js +226 -224
  36. package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
  37. package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
  38. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  39. package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
  40. package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
  41. package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
  42. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  43. package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
  44. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
  45. package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
  46. package/skills/teamsmith/scripts/replies.mjs +896 -0
  47. package/skills/teamsmith/scripts/shim/tmux +18 -0
  48. package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
  49. package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
  50. package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
  51. package/skills/teamsmith/scripts/team +20 -6
  52. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
  53. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  54. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  55. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  56. package/skills/teamsmith/templates/config.sh.tmpl +29 -5
  57. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  58. package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
  59. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  60. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  61. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  62. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  63. package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
  64. package/skills/teamsmith/tests/config-cli.sh +320 -300
  65. package/skills/teamsmith/tests/death-cause.sh +5 -2
  66. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  67. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  68. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  69. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  70. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  71. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  72. package/skills/teamsmith/tests/flip-m37.sh +4 -1
  73. package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
  74. package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
  75. package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
  76. package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
  77. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  78. package/skills/teamsmith/tests/flip-p210.sh +4 -1
  79. package/skills/teamsmith/tests/flip-p217.sh +4 -1
  80. package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
  81. package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
  82. package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
  83. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  84. package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
  85. package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
  86. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  87. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  88. package/skills/teamsmith/tests/install-shape.sh +283 -22
  89. package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
  90. package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
  91. package/skills/teamsmith/tests/key-replies.sh +1314 -0
  92. package/skills/teamsmith/tests/ledger-ban.sh +9 -8
  93. package/skills/teamsmith/tests/ledger-claim.sh +248 -0
  94. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  95. package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
  96. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  97. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  98. package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
  99. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  100. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  101. package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
  102. package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
  103. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  104. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  105. package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
  106. package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
  107. package/skills/teamsmith/tests/panel-b2.sh +107 -4
  108. package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
  109. package/skills/teamsmith/tests/panel-b3.sh +189 -29
  110. package/skills/teamsmith/tests/panel-choices.sh +81 -63
  111. package/skills/teamsmith/tests/panel-cpu.sh +3 -2
  112. package/skills/teamsmith/tests/panel-knobs.sh +7 -1
  113. package/skills/teamsmith/tests/panel-p21.sh +445 -241
  114. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  115. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  116. package/skills/teamsmith/tests/perf.sh +122 -31
  117. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  118. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  119. package/skills/teamsmith/tests/routes.sh +364 -109
  120. package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
  121. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  122. package/skills/teamsmith/tests/section-budgets.tsv +26 -12
  123. package/skills/teamsmith/tests/section-guard.sh +6 -1
  124. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  125. package/skills/teamsmith/tests/section-paths.tsv +42 -26
  126. package/skills/teamsmith/tests/section-select.sh +90 -7
  127. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  128. package/skills/teamsmith/tests/slash-team.sh +617 -0
  129. package/skills/teamsmith/tests/smoke.sh +3762 -628
  130. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  131. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  132. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  133. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  134. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  135. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  136. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  137. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  138. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  139. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  140. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  141. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  142. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  143. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  144. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  145. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  146. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  147. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  148. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  149. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  150. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  151. package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
  152. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  153. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  154. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  155. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  156. package/skills/teamsmith-init/SKILL.md +43 -43
  157. package/skills/teamsmith-init/references/bootstrap.md +8 -6
  158. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  # P230 · long-job-suspend · A 刀夹具(独立入口:extension 侧的合同,不碰 smoke.sh)
3
3
  #
4
- # bash skills/teamsmith/tests/bg-ledger.sh --select wording,ledger,suspend-shape,owner-scope,flip
5
- # bash skills/teamsmith/tests/bg-ledger.sh # 默认五组全跑
4
+ # bash skills/teamsmith/tests/bg-ledger.sh --select wording,ledger,suspend-shape,owner-scope,merge,detail,wake,flip
5
+ # bash skills/teamsmith/tests/bg-ledger.sh # 默认八组全跑
6
6
  # bash skills/teamsmith/tests/bg-ledger.sh --select flip --evidence <dir> # 把每组原始日志拷进证据目录
7
7
  # bash skills/teamsmith/tests/bg-ledger.sh --keep # 保留临时根排查
8
8
  #
@@ -20,9 +20,17 @@
20
20
  # cwd 必须解析到本会话自己的工作树/cwd 才算「我的作业」;多席位各有作业时各自只认自己的
21
21
  # id;空席位(dev2 与 dev3 两个非拥有者)不被别人的作业打成挂起;缺 cwd / 相对 cwd /
22
22
  # 解析不出来的畸形记录不判挂起(fail-closed);软链与尾斜杠按真实路径归一。
23
+ # merge turn-notice-merge 的写入面(P251):合并键四分量(席位/任务/状态类/awaiting 集合)、
24
+ # 汇总行的形状(最后一条事件的行 + ×N first= last=)与最后一条的值、尾行锚、跨类/跨任务/
25
+ # 跨 awaiting 不合并、去重窗口语义、行计数读者(未读 + --ack)与陈旧判据。
26
+ # detail 明细文件(state/notify.log):一行一事件、先明细后合并(×N 与记录数一致)、
27
+ # TEAM_NOTIFY_DETAIL_MAX 上界与一代轮转(轮转头 + 扩展日志)、`team inbox --detail`
28
+ # 的读面(缺文件/被轮转出去要点名 state/notify.log.1 并非零退出、只读不 ack)。
29
+ # wake P251 的叫醒判据(无限私有 tmux shim):只有**写新行且行可行动**才入队 knock(行身份去重)、
30
+ # 交付/中断敲门、**挂起只记录不敲门**(行与明细都在、合并也不敲)、合并的 settle 零条目
31
+ # (计数抖动不叫醒)、文本逐字相同的两条不同行不互吞、写盘失败不叫醒。
23
32
  # flip 对 scratch 源码做真实破坏必须变红(措辞回退 / 删 start 行 / waited_s 记作业年龄 /
24
- # 去掉身份验证 / 改成读 notify 自己的 root / 删掉归属判据),且同一用例在 pristine
25
- # 树上必须 PASS。
33
+ # 去掉身份验证 / 改成读 notify 自己的 root / 删掉归属判据;P251 的十二个写入面红侧)。
26
34
  #
27
35
  # 纪律(§13c):清掉继承的 TEAM_*/SMOKE_*/TMUX*;写盘前断言 `team paths` 指向夹具仓库;跑后扫描真项目
28
36
  # state/ 与 inbox 的夹具标记(+ 前后快照)。夹具只写 ${TMPDIR:-/tmp} 下的 owned 根;不碰调用者仓库。
@@ -34,7 +42,7 @@ REPO_ROOT="$(cd -P "$SKILL_DIR/../.." && pwd)"
34
42
  # shellcheck source=lib/tmp-root.sh
35
43
  . "$SELF_DIR/lib/tmp-root.sh"
36
44
 
37
- SELECT="wording,ledger,suspend-shape,owner-scope,flip"
45
+ SELECT="wording,ledger,suspend-shape,owner-scope,merge,detail,wake,flip"
38
46
  KEEP=0
39
47
  EVIDENCE=""
40
48
  while [ $# -gt 0 ]; do
@@ -50,7 +58,7 @@ while [ $# -gt 0 ]; do
50
58
  done
51
59
  IFS=',' read -r -a SEL_GROUPS <<<"$SELECT"
52
60
  for _g in "${SEL_GROUPS[@]}"; do
53
- case "$_g" in wording|ledger|suspend-shape|owner-scope|flip) ;; *) printf 'bg-ledger: 未知组 %s(wording|ledger|suspend-shape|owner-scope|flip)\n' "$_g" >&2; exit 2 ;; esac
61
+ case "$_g" in wording|ledger|suspend-shape|owner-scope|merge|detail|wake|flip) ;; *) printf 'bg-ledger: 未知组 %s(wording|ledger|suspend-shape|owner-scope|merge|detail|wake|flip)\n' "$_g" >&2; exit 2 ;; esac
54
62
  done
55
63
  selects() { case ",$SELECT," in *",$1,"*) return 0 ;; esac; return 1; }
56
64
 
@@ -100,7 +108,7 @@ cat > "$FIX/.pi/team/config.sh" <<EOF
100
108
  TEAM_PROJECT="bg-ledger-fixture"
101
109
  TEAM_AGENTS="dev"
102
110
  TEAM_WORKTREES_DIR=".worktrees"
103
- TEAM_NOTIFY_LOG="$FIX/.pi/team/state/notify.log"
111
+ TEAM_NOTIFY_LOG="$FIX/.pi/team/state/notify-ext.log"
104
112
  EOF
105
113
  printf '# bg-ledger fixture\n' > "$FIX/README.md"
106
114
  ( cd "$FIX" && git init -q -b main && git add README.md \
@@ -114,6 +122,21 @@ esac
114
122
 
115
123
  MAIN_ROOT="$(git -C "$REPO_ROOT" rev-parse --path-format=absolute --git-common-dir 2>/dev/null | xargs -r dirname)"
116
124
  [ -n "$MAIN_ROOT" ] || MAIN_ROOT="$REPO_ROOT"
125
+
126
+ # ── 私有 tmux shim(p251 的 wake 组):假 PM 窗口(window=dev / session=team / 在跑 pi),只会在
127
+ # 启动 runner 前以 PATH 前缀的形式给带 wake 的组(bun 启动时缓存 PATH,运行中改无效)。只写自己的 tmp 根。
128
+ KNOCK_SHIM="$TMP/knock-shim"
129
+ mkdir -p "$KNOCK_SHIM"
130
+ cat > "$KNOCK_SHIM/tmux" <<'EOF'
131
+ #!/usr/bin/env bash
132
+ case "$*" in
133
+ *'#{window_name}'*) printf 'dev\n' ;;
134
+ *'#{session_name}'*) printf 'team\n' ;;
135
+ *'#{pane_current_command}'*) printf 'pi\n' ;;
136
+ esac
137
+ exit 0
138
+ EOF
139
+ chmod +x "$KNOCK_SHIM/tmux"
117
140
  real_snapshot() {
118
141
  { for d in "$MAIN_ROOT/.pi/team/state" "$MAIN_ROOT/docs/team/inbox"; do
119
142
  if [ -d "$d" ]; then
@@ -142,8 +165,11 @@ real_marker_hits() { # 真项目里含夹具标记的文件。**排除本入口
142
165
  REAL_BEFORE="$(real_snapshot)"
143
166
 
144
167
  run_harness() { # <tag> <groups> [<bg> <notify>] → rc;stdout+stderr 落 $TMP/h-<tag>.log
145
- local tag="$1" groups="$2" bg="${3:-$BG_EXT}" notify="${4:-$NOTIFY_EXT}"
146
- "$RUNNER" "$HARNESS" --bg "$bg" --notify "$notify" --root "$FIX" --groups "$groups" --marker "$MARKER" \
168
+ # P251:带 wake 的组要「有 PM 窗口」的形状 —— 假 tmux 必须在 runner **启动前**进 PATH(bun 缓存在
169
+ # 启动时读的 PATH,运行中改 process.env.PATH 对子进程查找无效;实测)。只加给带 wake 的组。
170
+ local tag="$1" groups="$2" bg="${3:-$BG_EXT}" notify="${4:-$NOTIFY_EXT}" path_pre="$PATH"
171
+ case ",$groups," in *,wake,*) path_pre="$KNOCK_SHIM:$PATH" ;; esac
172
+ env PATH="$path_pre" "$RUNNER" "$HARNESS" --bg "$bg" --notify "$notify" --root "$FIX" --groups "$groups" --marker "$MARKER" \
147
173
  >"$TMP/h-$tag.log" 2>&1
148
174
  }
149
175
  report_group() { # <tag>
@@ -184,7 +210,7 @@ printf '[bg-ledger-run] %s\n' "$MARKER" # 本入口自己的输出指纹(反
184
210
 
185
211
  # ── wording / ledger / suspend-shape ────────────────────────────────────────────────────
186
212
  SELECTED_GROUPS=""
187
- for _g in wording ledger suspend-shape owner-scope; do
213
+ for _g in wording ledger suspend-shape owner-scope merge detail wake; do
188
214
  if selects "$_g"; then SELECTED_GROUPS="${SELECTED_GROUPS:+$SELECTED_GROUPS,}$_g"; fi
189
215
  done
190
216
  if [ -n "$SELECTED_GROUPS" ]; then
@@ -198,6 +224,9 @@ if selects flip; then
198
224
  section "flip · pristine 树基线(同一批用例必须全绿)"
199
225
  run_harness flip-green "wording,ledger,suspend-shape,owner-scope"
200
226
  report_group flip-green
227
+ section "flip · P251 写入面的 pristine 基线(merge/detail/wake 必须全绿)"
228
+ run_harness flip-green-notify "merge,detail,wake"
229
+ report_group flip-green-notify
201
230
 
202
231
  MUT="$TMP/mut"; mkdir -p "$MUT"
203
232
  flip_mut() { # <tag> <src> <sed 表达式>
@@ -264,10 +293,139 @@ if selects flip; then
264
293
  expect_red flip-owner-scope "owner-scope: a live record with a missing, relative or unresolvable cwd does not suspend (fail-closed)" "$TMP/h-flip-green.log"
265
294
  expect_red flip-owner-scope "owner-scope: a job started from the main worktree does not suspend a seat" "$TMP/h-flip-green.log"
266
295
 
296
+ # ── P251 · turn-notice-merge 的写入面红侧(merge/detail/wake)────────────────────────────
297
+ # 扩展的 skillDir() = 它自己目录的父目录 → CLI 侧的合并/明细代码与扩展侧的叫醒代码必须在**同一棵
298
+ # scratch 树**里破坏($MUT/<tag>/{extension,scripts}),否则扩展找不到 scripts/team,knock 断言是假红。
299
+ TREE_BASE="$TMP/tree-base"
300
+ rm -rf "$TREE_BASE"; mkdir -p "$TREE_BASE/extension"
301
+ cp -a "$SKILL_DIR/scripts" "$TREE_BASE/scripts"
302
+ cp "$NOTIFY_EXT" "$TREE_BASE/extension/team-notify.ts"
303
+ flip_tree() { # <tag> → 建一棵 scratch 树并打印树里的 team-notify.ts
304
+ # 注意:`local a="$1" b="$MUT/$a"` 在 bash 5.3 + set -u 下会把 $a 判成 unbound(实测)—— 分开写。
305
+ local tag="$1"
306
+ local dst="$MUT/$tag"
307
+ rm -rf "$dst"; mkdir -p "$dst"
308
+ cp -a "$TREE_BASE/." "$dst/"
309
+ printf '%s\n' "$dst/extension/team-notify.ts"
310
+ }
311
+ flip_tree_sed() { # <tag> <树内相对路径> <sed 表达式> → 打印变异后的文件
312
+ local tag="$1" rel="$2" expr="$3"
313
+ local f="$MUT/$tag/$rel"
314
+ sed -i "$expr" "$f"
315
+ printf '%s\n' "$f"
316
+ }
317
+
318
+ # ⑦ 去掉键比较(任何非空键都并进尾行)→ 跨类/跨 awaiting 不再新起一行
319
+ M7="$(flip_tree merge-nokey)"
320
+ F7="$(flip_tree_sed merge-nokey scripts/lib/cmd-agents.sh 's#$(team_notify_line_key "$tail_line" 2>/dev/null || true)#$key#')"
321
+ flip_premise merge-nokey "$F7" '&& [ "$key" = "$key" ]; then' has
322
+ run_harness flip-merge-nokey merge "$BG_EXT" "$M7"
323
+ expect_red flip-merge-nokey "merge: a state-class change starts a new line" "$TMP/h-flip-green-notify.log"
324
+ expect_red flip-merge-nokey "merge: a different task or awaiting set starts a new line" "$TMP/h-flip-green-notify.log"
325
+
326
+ # ⑧ 跨类合并(键里的状态类固定成 delivered)→ 只有类变、awaiting 相同的两条不再新起一行
327
+ # (用例「同类不同 awaiting」对类分量不敏感:那个用例里 awaiting 也在变,所以只钉住这一类用例)
328
+ M8="$(flip_tree merge-crossclass)"
329
+ F8="$(flip_tree_sed merge-crossclass scripts/lib/cmd-agents.sh 's#"$seat" "$class" "$t" "$nrm"#"$seat" delivered "$t" "$nrm"#')"
330
+ flip_premise merge-crossclass "$F8" '"$seat" delivered "$t" "$nrm"' has
331
+ run_harness flip-merge-crossclass merge "$BG_EXT" "$M8"
332
+ expect_red flip-merge-crossclass "merge: a class change with the same awaiting set starts a new line" "$TMP/h-flip-green-notify.log"
333
+
334
+ # ⑨ 取第一条的值(汇总行拿旧尾行而不是新事件)→ 最后一条的 uncommitted/tip/last 全错
335
+ M9="$(flip_tree merge-first)"
336
+ F9="$(flip_tree_sed merge-first scripts/lib/cmd-agents.sh 's#team_notify_line_merge "$newcontent"#team_notify_line_merge "$tail_line"#')"
337
+ flip_premise merge-first "$F9" 'team_notify_line_merge "$tail_line"' has
338
+ run_harness flip-merge-first merge "$BG_EXT" "$M9"
339
+ expect_red flip-merge-first "merge: the merged line carries the last event’s values" "$TMP/h-flip-green-notify.log"
340
+
341
+ # ⑩ 穿行重写(锚不再只认尾行,改成文件里最后一条 auto 行)→ 夹在中间的手工通知被吞掉
342
+ M10="$(flip_tree merge-scan)"
343
+ F10="$(flip_tree_sed merge-scan scripts/lib/cmd-agents.sh 's#tail_line="$(tail -n 1 "$file")"#tail_line="$(grep '\''^- .*auto'\'' "$file" | tail -n 1)"#')"
344
+ flip_premise merge-scan "$F10" 'grep '\''^- .*auto'\'' "$file" | tail -n 1' has
345
+ run_harness flip-merge-scan merge "$BG_EXT" "$M10"
346
+ expect_red flip-merge-scan "merge: a notice appended between two events ends the run untouched" "$TMP/h-flip-green-notify.log"
347
+
348
+ # ⑪ 删明细落盘(事件不再进 state/notify.log)→ ×N 与记录数不一致
349
+ M11="$(flip_tree detail-nowrite)"
350
+ F11="$(flip_tree_sed detail-nowrite scripts/lib/cmd-agents.sh 's#if ! team_notify_detail_append "$content" "$detail"; then#if ! true; then#')"
351
+ flip_premise detail-nowrite "$F11" 'if ! true; then' has
352
+ run_harness flip-detail-nowrite detail "$BG_EXT" "$M11"
353
+ expect_red flip-detail-nowrite "detail: a run’s count and its records agree" "$TMP/h-flip-green-notify.log"
354
+
355
+ # ⑫ 越界不轮转 → 轮转头/上一代不再出现,上界断言失败
356
+ M12="$(flip_tree detail-norotate)"
357
+ F12="$(flip_tree_sed detail-norotate scripts/lib/cmd-agents.sh 's#\[ "$count" -ge "$max" \]#[ 1 -eq 0 ]#')"
358
+ flip_premise detail-norotate "$F12" '[ 1 -eq 0 ]' has
359
+ run_harness flip-detail-norotate detail "$BG_EXT" "$M12"
360
+ expect_red flip-detail-norotate "detail: a rotated generation names where the older events went" "$TMP/h-flip-green-notify.log"
361
+
362
+ # ⑬ `--detail` 静默空输出(读了但不打印、永远退出 0)→ 缺口不再点名
363
+ # ⚠ sed 的**替换串**里 `&` = 整个匹配 —— 这个破坏要写 `2>\&1`,否则替换出来的行变成
364
+ # `2>team_inbox_detail "$a"`(把工作树里凭空写一个同名空文件、还改了 rc 语义),P251 实测过。
365
+ M13="$(flip_tree detail-silent)"
366
+ F13="$(flip_tree_sed detail-silent scripts/lib/cmd-status.sh 's#team_inbox_detail "$a" || rc=1#team_inbox_detail "$a" >/dev/null 2>\&1 || true#')"
367
+ flip_premise detail-silent "$F13" 'team_inbox_detail "$a" >/dev/null 2>&1 || true' has
368
+ run_harness flip-detail-silent detail "$BG_EXT" "$M13"
369
+ expect_red flip-detail-silent "detail: a missing record is named, not silent" "$TMP/h-flip-green-notify.log"
370
+
371
+ # ⑭ `--detail` 会 ack(读面变成写面)→ 未读数被默默清掉
372
+ M14="$(flip_tree detail-acks)"
373
+ F14="$(flip_tree_sed detail-acks scripts/lib/cmd-status.sh 's#team_inbox_detail "$a" || rc=1#team_inbox_ack_set "$a" "$(team_inbox_total "$a")"; team_inbox_detail "$a" || rc=1#')"
374
+ flip_premise detail-acks "$F14" 'team_inbox_ack_set "$a" "$(team_inbox_total "$a")"; team_inbox_detail' has
375
+ run_harness flip-detail-acks detail "$BG_EXT" "$M14"
376
+ expect_red flip-detail-acks "detail: detail reading does not acknowledge" "$TMP/h-flip-green-notify.log"
377
+
378
+ # ⑮ 每 settle 都入队 knock(扩展既有 run 也叫醒)→ 计数抖动不再安静
379
+ # 钉住它的是「each new line wakes exactly once」(k 在两次合并后必须仍是 1),不是后面的 churn 用例
380
+ # —— harness 在首个失败用例就退出,后面的用例不会出现。
381
+ M15="$(flip_tree wake-persettle)"
382
+ F15="$(flip_tree_sed wake-persettle extension/team-notify.ts 's#if (writeState !== '\''new'\'') {#if (false) {#')"
383
+ flip_premise wake-persettle "$F15" 'if (false) {' has
384
+ run_harness flip-wake-persettle wake "$BG_EXT" "$M15"
385
+ expect_red flip-wake-persettle "wake: a merged settle does not wake again" "$TMP/h-flip-green-notify.log"
386
+
387
+ # ⑯ 用摘要文本当 knock 去重键 → 文本逐字相同的两条不同行互吞
388
+ M16="$(flip_tree wake-summarykey)"
389
+ F16="$(flip_tree_sed wake-summarykey extension/team-notify.ts 's#const lineIdentity = .*#const lineIdentity = `line|${agent}|${summary}`#')"
390
+ flip_premise wake-summarykey "$F16" 'const lineIdentity = `line|${agent}|${summary}`' has
391
+ run_harness flip-wake-summarykey wake "$BG_EXT" "$M16"
392
+ expect_red flip-wake-summarykey "wake: two text-identical lines are not conflated" "$TMP/h-flip-green-notify.log"
393
+
394
+ # ⑰ 写失败仍叫醒(catch 里伪装成成功)→ 敲门声称有一行、行却不在
395
+ M17="$(flip_tree wake-writefail)"
396
+ F17="$(flip_tree_sed wake-writefail extension/team-notify.ts 's#^ writeOut = ..$# writeOut = "state=new\\nfirst=-\\nkey=-\\n"#')"
397
+ flip_premise wake-writefail "$F17" 'writeOut = "state=new\nfirst=-\nkey=-\n"' has
398
+ run_harness flip-wake-writefail wake "$BG_EXT" "$M17"
399
+ expect_red flip-wake-writefail "wake: a failed inbox write does not wake" "$TMP/h-flip-green-notify.log"
400
+
401
+ # ⑱ 把「挂起也敲门」加回去(去掉挂起守卫)→ 挂起不再安静(用户裁定 2026-10-14)
402
+ # 注意:sed 替换串里的 `&&` 要写成 `\&\&`(裸 `&` 会展开成整个匹配,实测踩过)。
403
+ M18="$(flip_tree wake-suspended)"
404
+ F18="$(flip_tree_sed wake-suspended extension/team-notify.ts 's#if (suspended) {#if (suspended \&\& false) {#')"
405
+ flip_premise wake-suspended "$F18" 'if (suspended && false) {' has
406
+ run_harness flip-wake-suspended wake "$BG_EXT" "$M18"
407
+ expect_red flip-wake-suspended "wake: a suspended line never wakes" "$TMP/h-flip-green-notify.log"
408
+
267
409
  # 还原后绿:pristine 树重跑一遍(上面所有破坏都只写 scratch 副本)
268
410
  section "flip · 还原后绿(pristine 树重跑)"
269
411
  run_harness flip-restored wording
270
412
  report_group flip-restored
413
+ # P251:写入面也要有一个**破坏轮之后**的 pristine 重跑 —— 只有这样才能说「破坏 → 红 → 还原 → 绿」
414
+ # 四步完整(前面的 flip-green-notify 是破坏**前**的基线,不能替它)。
415
+ run_harness flip-restored-notify merge,detail,wake
416
+ report_group flip-restored-notify
417
+ # 破坏只写 scratch 副本:真实工作树在整轮破坏之后必须仍然干净(误伤源码会在这里现形)。
418
+ FLIP_REPO_ROOT="$(git -C "$SKILL_DIR/../.." rev-parse --show-toplevel 2>/dev/null || true)"
419
+ if [ -z "$FLIP_REPO_ROOT" ]; then
420
+ note "flip · 真实工作树检查跳过:$SKILL_DIR 不在 git 工作树里(安装形态)"
421
+ else
422
+ FLIP_TREE_DIRTY="$(git -C "$FLIP_REPO_ROOT" status --porcelain --untracked-files=all 2>/dev/null || echo '?')"
423
+ if [ -z "$FLIP_TREE_DIRTY" ]; then
424
+ ok "flip · 破坏轮之后真实工作树仍然干净($FLIP_REPO_ROOT:git status --porcelain -uall 为空)"
425
+ else
426
+ bad "flip · 破坏轮把真实工作树弄脏了:$(printf '%s' "$FLIP_TREE_DIRTY" | head -3 | tr '\n' ' ')"
427
+ fi
428
+ fi
271
429
  fi
272
430
 
273
431
  # ── 反向守卫:真项目 state/inbox 未动 ────────────────────────────────────────────────────
@@ -35,8 +35,10 @@ SEL="$SKILL_DIR/tests/section-select.sh"
35
35
  CINV="$SKILL_DIR/tests/coverage-inventory.sh"
36
36
  # shellcheck source=tests/lib/checkout-shape.sh
37
37
  . "$SKILL_DIR/tests/lib/checkout-shape.sh"
38
+ # P309:临时根走 product 的解析器(唯一实现),不自己写 ${TMPDIR:-/tmp}
39
+ . "$SKILL_DIR/tests/lib/tmp-root.sh"
38
40
 
39
- T="${TMPDIR:-/tmp}/p148-shape-probe.$$"
41
+ T="$(team_tmp_root)/.teamsmith-p148-shape-probe.$$"
40
42
  rm -rf "$T"; mkdir -p "$T"
41
43
  trap '[ "${P148_SHAPE_KEEP:-0}" = "1" ] || rm -rf "$T"' EXIT
42
44