teamsmith 0.3.0 → 0.3.2

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 (101) hide show
  1. package/README.md +4 -4
  2. package/package.json +6 -2
  3. package/skills/teamsmith/CHANGELOG.md +56 -0
  4. package/skills/teamsmith/SKILL.md +7 -7
  5. package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
  6. package/skills/teamsmith/references/protocol.md +33 -19
  7. package/skills/teamsmith/references/troubleshooting.md +6 -3
  8. package/skills/teamsmith/scripts/lib/cmd-review.sh +15 -10
  9. package/skills/teamsmith/scripts/lib/cmd-status.sh +8 -4
  10. package/skills/teamsmith/scripts/lib/common.sh +301 -267
  11. package/skills/teamsmith/scripts/lib/gate-lock.sh +66 -28
  12. package/skills/teamsmith/scripts/panel/panel.js +64 -64
  13. package/skills/teamsmith/scripts/panel/src/clipboard.ts +2 -1
  14. package/skills/teamsmith/scripts/panel/src/data.ts +40 -2
  15. package/skills/teamsmith/scripts/panel/src/main.tsx +5 -1
  16. package/skills/teamsmith/scripts/shim/killall +10 -0
  17. package/skills/teamsmith/scripts/shim/pgrep +10 -0
  18. package/skills/teamsmith/scripts/shim/pidof +10 -0
  19. package/skills/teamsmith/scripts/shim/pkill +10 -0
  20. package/skills/teamsmith/scripts/shim/signal-gate +108 -31
  21. package/skills/teamsmith/tests/README.md +31 -0
  22. package/skills/teamsmith/tests/checkout-shape-probe.sh +80 -53
  23. package/skills/teamsmith/tests/config-cli.sh +28 -22
  24. package/skills/teamsmith/tests/flip-p310-lock.sh +3 -9
  25. package/skills/teamsmith/tests/gate-guard.sh +52 -79
  26. package/skills/teamsmith/tests/help-surface.sh +2 -2
  27. package/skills/teamsmith/tests/install-shape.sh +127 -8
  28. package/skills/teamsmith/tests/key-replies-ui.sh +2 -1
  29. package/skills/teamsmith/tests/key-replies.sh +41 -27
  30. package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
  31. package/skills/teamsmith/tests/lib/section-guard.sh +104 -197
  32. package/skills/teamsmith/tests/loop-inventory.tsv +83 -89
  33. package/skills/teamsmith/tests/panel-b2.sh +351 -376
  34. package/skills/teamsmith/tests/panel-b3.sh +139 -43
  35. package/skills/teamsmith/tests/panel-cpu.sh +41 -129
  36. package/skills/teamsmith/tests/panel-p21.sh +96 -193
  37. package/skills/teamsmith/tests/perf.sh +83 -383
  38. package/skills/teamsmith/tests/routes.sh +115 -26
  39. package/skills/teamsmith/tests/seat-interrupt.sh +20 -10
  40. package/skills/teamsmith/tests/seat-visibility.sh +1 -1
  41. package/skills/teamsmith/tests/section-guard.sh +7 -101
  42. package/skills/teamsmith/tests/section-paths.tsv +15 -7
  43. package/skills/teamsmith/tests/section-select.sh +363 -18
  44. package/skills/teamsmith/tests/signal-gate.sh +249 -27
  45. package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
  46. package/skills/teamsmith/tests/slash-team-e2e.sh +4 -4
  47. package/skills/teamsmith/tests/slice-coverage.sh +206 -0
  48. package/skills/teamsmith/tests/smoke.sh +856 -581
  49. package/skills/teamsmith/tests/task-model-routing.sh +25 -7
  50. package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
  51. package/skills/teamsmith/tests/workflow-entry.sh +207 -0
  52. package/skills/teamsmith-init/SKILL.md +1 -1
  53. package/skills/teamsmith/tests/flip-glue.sh +0 -162
  54. package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
  55. package/skills/teamsmith/tests/flip-m12.sh +0 -185
  56. package/skills/teamsmith/tests/flip-m16.sh +0 -166
  57. package/skills/teamsmith/tests/flip-m17.sh +0 -204
  58. package/skills/teamsmith/tests/flip-m34.sh +0 -96
  59. package/skills/teamsmith/tests/flip-m37.sh +0 -188
  60. package/skills/teamsmith/tests/flip-m4.3.sh +0 -378
  61. package/skills/teamsmith/tests/flip-m43.sh +0 -128
  62. package/skills/teamsmith/tests/flip-m45.sh +0 -244
  63. package/skills/teamsmith/tests/flip-m46.sh +0 -238
  64. package/skills/teamsmith/tests/flip-m48.sh +0 -304
  65. package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
  66. package/skills/teamsmith/tests/flip-m6.3.sh +0 -286
  67. package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
  68. package/skills/teamsmith/tests/flip-m6.5.sh +0 -116
  69. package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
  70. package/skills/teamsmith/tests/flip-m7.2.sh +0 -324
  71. package/skills/teamsmith/tests/flip-p144.sh +0 -112
  72. package/skills/teamsmith/tests/flip-p156.sh +0 -133
  73. package/skills/teamsmith/tests/flip-p160.sh +0 -182
  74. package/skills/teamsmith/tests/flip-p171.sh +0 -249
  75. package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
  76. package/skills/teamsmith/tests/flip-p20.sh +0 -286
  77. package/skills/teamsmith/tests/flip-p201.sh +0 -249
  78. package/skills/teamsmith/tests/flip-p210.sh +0 -242
  79. package/skills/teamsmith/tests/flip-p211.sh +0 -152
  80. package/skills/teamsmith/tests/flip-p217.sh +0 -291
  81. package/skills/teamsmith/tests/flip-p22.sh +0 -123
  82. package/skills/teamsmith/tests/flip-p23.sh +0 -239
  83. package/skills/teamsmith/tests/flip-p25.sh +0 -165
  84. package/skills/teamsmith/tests/flip-p287-lock.sh +0 -342
  85. package/skills/teamsmith/tests/flip-p287-name.sh +0 -279
  86. package/skills/teamsmith/tests/flip-p304-read-side.sh +0 -98
  87. package/skills/teamsmith/tests/flip-p309-p162-deep.sh +0 -122
  88. package/skills/teamsmith/tests/flip-p71.sh +0 -184
  89. package/skills/teamsmith/tests/flip-p72.sh +0 -202
  90. package/skills/teamsmith/tests/load-experiment.sh +0 -290
  91. package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
  92. package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
  93. package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
  94. package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
  95. package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
  96. package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
  97. package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
  98. package/skills/teamsmith/tests/panel-knobs.sh +0 -89
  99. package/skills/teamsmith/tests/section-budgets.tsv +0 -164
  100. package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
  101. package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
@@ -1,304 +0,0 @@
1
- #!/usr/bin/env bash
2
- # M48 flips: the duplicate-id work is pinned to the thing that changed, in both halves.
3
- #
4
- # bash skills/teamsmith/tests/flip-m48.sh focus # 控制台:焦点按行身份(翻转 = 改回按 ID 比较)
5
- # bash skills/teamsmith/tests/flip-m48.sh add # CLI:board add 拒绝重复(翻转 = 去掉检查)
6
- # bash skills/teamsmith/tests/flip-m48.sh assign # CLI:assign 原地改 agent(翻转 = 改回「再 add 一行」)
7
- # bash skills/teamsmith/tests/flip-m48.sh # 三个都跑
8
- # bash skills/teamsmith/tests/flip-m48.sh --keep # 保留临时目录(排查)
9
- #
10
- # focus:`src` 的临时副本打补丁(焦点匹配与 ↑/↓ 走路改回裸 ID 比较)→ bun 重建翻转 bundle →
11
- # `tests/panel-b3.sh board` 跑两遍(翻转 bundle 应红在 M48 的重复断言上,提交的 bundle 应绿)。
12
- # 真源码一个字节都不动。
13
- # add:skill 树的临时副本去掉 `team_board_add` 的重复检查 → 用 smoke 的**前导 + §0/§2/§4/§4b/§4c**
14
- # 拼出的聚焦探针(判据就是门禁里的那一份,不是抄的第二份)跑两遍:副本应红在 §4c 的
15
- # 「重复 ID 被拒 / 文件未变」上,真树应绿。
16
- # assign:skill 临时副本把 `team_board_assign` 的写口换成「再 add 一行」(即重复 ID 进来的老路)→
17
- # 同一探针:副本应红在「assign 后行数不变 / T1.1 仍是两行」上,真树应绿。
18
- #
19
- # 退出码:0 = 翻转都成立;1 = 有预期不成立;2 = 环境/前置不满足。
20
- set -uo pipefail
21
-
22
- SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23
- SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
24
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
25
- . "$SELF_DIR/lib/tmp-root.sh"
26
- TREE="$(cd -P "$SKILL_DIR/../.." && pwd)"
27
- SMOKE="$SKILL_DIR/tests/smoke.sh"
28
- PANEL_DIR="$SKILL_DIR/scripts/panel"
29
- PIN="$PANEL_DIR/panel.js"
30
-
31
- mode=""
32
- case "${1:-}" in
33
- "") mode=all ;;
34
- focus|add|assign) mode="$1" ;;
35
- --keep) KEEP=1; mode="${2:-all}" ;;
36
- -h|--help) sed -n '2,20p' "$0"; exit 0 ;;
37
- *) printf 'flip-m48: 未知参数 %s(focus|add|assign|all|--keep)\n' "$1" >&2; exit 2 ;;
38
- esac
39
- case "$mode" in all|focus|add|assign) ;; *) printf 'flip-m48: 未知模式 %s\n' "$mode" >&2; exit 2 ;; esac
40
- KEEP="${KEEP:-0}"
41
-
42
- die2() { printf 'flip-m48: %s\n' "$*" >&2; exit 2; }
43
- pass() { printf ' \033[32m✓\033[0m %s\n' "$*"; }
44
- fail() { printf ' \033[31m✗\033[0m %s\n' "$*"; RC=1; }
45
- plain() { sed 's/\x1b\[[0-9;]*m//g' "$1"; }
46
-
47
- command -v git >/dev/null 2>&1 || die2 "需要 git"
48
- command -v python3 >/dev/null 2>&1 || die2 "需要 python3(打补丁)"
49
- [ -s "$SMOKE" ] || die2 "找不到 $SMOKE"
50
- [ -s "$PIN" ] || die2 "找不到 bundle($PIN)"
51
-
52
- [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
53
- TMP="$(tmp_root_create flip-m48)" || exit 3
54
- cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; [ "$KEEP" = "1" ] || tmp_root_reap_all; return 0; }
55
- trap cleanup EXIT
56
- RC=0
57
-
58
- printf '\033[1m== flip-m48 · 看板重复 ID(%s)==\033[0m\n' "$mode"
59
-
60
- # ---------------------------------------------------------------- focus(控制台)
61
- flip_focus() {
62
- local bun js ink_pin react_pin
63
- bun="${M48_FLIP_BUN:-}"
64
- [ -n "$bun" ] || bun="$(command -v bun 2>/dev/null || true)"
65
- [ -n "$bun" ] || bun="$HOME/.bun/bin/bun"
66
- js="$(command -v node || command -v bun || true)"
67
- [ -x "$bun" ] || { printf ' 跳过 focus:需要 bun 重建翻转 bundle(%s)\n' "$bun" >&2; return 2; }
68
- [ -n "$js" ] || { printf ' 跳过 focus:本机没有 node/bun\n' >&2; return 2; }
69
- command -v tmux >/dev/null 2>&1 || { printf ' 跳过 focus:panel-b3 需要 tmux\n' >&2; return 2; }
70
- ink_pin="$(sed -n 's/.*"ink": *"\([^"]*\)".*/\1/p' "$PANEL_DIR/package.json")"
71
- react_pin="$(sed -n 's/.*"react": *"\([^"]*\)".*/\1/p' "$PANEL_DIR/package.json")"
72
-
73
- local src="$TMP/focus-src" out="$TMP/focus-panel.js"
74
- mkdir -p "$src"
75
- cp -r "$PANEL_DIR/src/." "$src/"
76
- ln -sfn "$PANEL_DIR/node_modules" "$src/node_modules"
77
- python3 - "$src" <<'PY' || return 2
78
- import sys
79
-
80
- d = sys.argv[1]
81
-
82
-
83
- def edit(name, old, new):
84
- path = f'{d}/{name}'
85
- s = open(path, encoding='utf-8').read()
86
- if s.count(old) != 1:
87
- sys.exit(f'flip-m48: pattern not unique ({s.count(old)}): {old[:70]!r}')
88
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
89
-
90
-
91
- # The App's kanban walk goes back to the id lookup: `findIndex` by id always answers with the first
92
- # of two rows sharing an id, and the same-id early return then freezes the cursor on it.
93
- edit('App.tsx', """ const row = focusRow(rows, current)
94
- if (!row) return
95
- const inLane = rows.filter((r) => r.state === current.lane)
96
- const idx = inLane.indexOf(row)
97
- const next = idx < 0 ? undefined : inLane[idx + cardDelta]
98
- if (!next || next === row) return""", """ const inLane = rows.filter((r) => r.state === current.lane) // FLIP m48: id lookup
99
- const idx = inLane.findIndex((r) => r.id === current.id) // FLIP m48
100
- const next = inLane[Math.max(0, Math.min(inLane.length - 1, idx + cardDelta))] // FLIP m48
101
- if (!next || next.id === current.id) return // FLIP m48: the freeze""")
102
- # The card highlight goes back to comparing ids: both duplicates light up at once.
103
- edit('layout.ts', """ for (let i = win.start; i < win.end; i++) {
104
- const card = cards[i]
105
- const focused = card === target""", """ for (let i = win.start; i < win.end; i++) {
106
- const card = cards[i]
107
- const focused = card.id === (target?.id ?? '') // FLIP m48: id match lights both rows""")
108
- edit('layout.ts', """ for (const card of cards) {
109
- const focused = card === target""", """ for (const card of cards) {
110
- const focused = card.id === (target?.id ?? '') // FLIP m48: id match lights both rows""")
111
- PY
112
- ( cd "$PANEL_DIR" && "$bun" build "$src/main.tsx" --target=node --format=esm --minify \
113
- --define "__PIN_INK__=\"$ink_pin\"" --define "__PIN_REACT__=\"$react_pin\"" \
114
- --outfile "$out" ) >"$TMP/focus-build.log" 2>&1 || {
115
- printf ' ✗ focus:翻转 bundle 构建失败\n' >&2; tail -5 "$TMP/focus-build.log" >&2; return 2
116
- }
117
- grep -q 'FLIP m48' "$src/App.tsx" "$src/layout.ts" || { printf ' ✗ focus:补丁没写进去\n' >&2; return 2; }
118
-
119
- local flipped_log="$TMP/focus-flipped.log" now_log="$TMP/focus-now.log" rc rc2
120
- TEAM_B3_PANEL="$out" bash "$SKILL_DIR/tests/panel-b3.sh" board >"$flipped_log" 2>&1; rc=$?
121
- TEAM_B3_PANEL="$PIN" bash "$SKILL_DIR/tests/panel-b3.sh" board >"$now_log" 2>&1; rc2=$?
122
- printf ' 翻转 bundle 的 board 场景:rc=%s(✗ %s 条)|提交 bundle:rc=%s(✗ %s 条)\n' \
123
- "$rc" "$(plain "$flipped_log" | grep -ac '^ .*✗' || true)" "$rc2" "$(plain "$now_log" | grep -ac '^ .*✗' || true)"
124
-
125
- local want_flipped="" l
126
- for l in '✗ M48 重复 ID:↓ 走到同 ID 的第二行(不卡死)' '✗ M48 重复 ID:焦点光标恰好一个(不是两行都亮)'; do
127
- { plain "$flipped_log" || true; } | grep -qF -- "$l" || want_flipped="$want_flipped
128
- $l"
129
- done
130
- if [ -n "$want_flipped" ]; then
131
- fail "focus:翻转 bundle 没有红在预期断言上:$want_flipped"
132
- plain "$flipped_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
133
- else
134
- pass "focus:翻转(改回按 ID 比较)→ 重复 ID 的行走/单光标断言变红"
135
- fi
136
- if [ "$rc2" -eq 0 ] && ! { plain "$now_log" || true; } | grep -q '^ .*✗'; then
137
- pass "focus:提交的 bundle 在同一场景全绿(同一夹具、同一判据红→绿)"
138
- else
139
- fail "focus:提交的 bundle 在 board 场景有失败项(rc=$rc2)"
140
- plain "$now_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
141
- fi
142
- return 0
143
- }
144
-
145
- # ---------------------------------------------------------------- add(CLI 守卫)
146
- extract_section() { # <file> <name> → 打印该 section 的整块
147
- local f="$1" name="$2" start end
148
- start="$(grep -n -F "section \"$name\"" "$f" | head -1 | cut -d: -f1)"
149
- [ -n "$start" ] || return 1
150
- end="$(awk -v s="$start" 'NR>s && /^section "/ { print NR; exit }' "$f")"
151
- if [ -n "$end" ]; then sed -n "${start},$((end-1))p" "$f"; else sed -n "${start},\$p" "$f"; fi
152
- }
153
-
154
- build_probe() { # <out> <skill-dir>:smoke 前导 + §0/§2/§4/§4b/§4c(判据就是门禁里那一份)
155
- local out="$1" sk="$2"
156
- {
157
- awk '/^# -+ 0\. 仓库/{exit} {print}' "$SMOKE"
158
- extract_section "$SMOKE" "0 · 临时仓库"
159
- extract_section "$SMOKE" "2 · init"
160
- extract_section "$SMOKE" "4 · task + board"
161
- extract_section "$SMOKE" "4b · 状态诚实:未知 id 不假装写入 + done 要证据(M6.1 F29/F1)"
162
- extract_section "$SMOKE" "4c · 看板重复 ID(M48):add 拒绝 / --allow-dup / 三处可见"
163
- cat <<'EOS'
164
- section "PROBE-M48-END"
165
- printf '\n== 结果 == ok %d bad %d\n' "$PASS" "$FAIL"
166
- printf 'PROBE-M48-END\n'
167
- [ "$FAIL" -eq 0 ] && exit 0
168
- exit 1
169
- EOS
170
- } | sed "s|^SKILL_DIR=.*|SKILL_DIR=\"$sk\"|" > "$out"
171
- grep -q '^section "4c ' "$out" || die2 "$SMOKE 里没有 §4c(M48 的守卫不在?)"
172
- grep -q '^section "PROBE-M48-END"' "$out" || die2 "探针结尾没写进去"
173
- bash -n "$out" || die2 "探针语法不对(截取写坏了):$out"
174
- return 0
175
- }
176
-
177
- run_probe() { # <probe> <log>
178
- local probe="$1" log="$2"
179
- TEAM_SMOKE_NO_LOCK=1 bash "$probe" > "$log" 2>&1
180
- }
181
-
182
- flip_add() {
183
- local copy="$TMP/add-tree"
184
- mkdir -p "$copy/skills"
185
- # 两个 skill 都要(SKILL_INIT_DIR 是兄弟目录);node_modules 不需要,跳过。
186
- ( cd "$TREE" && tar --exclude='*/node_modules' -cf - skills ) | ( cd "$copy" && tar -xf - ) || return 2
187
- [ -d "$copy/skills/teamsmith-init" ] || { printf ' ✗ add:skill 副本不完整\n' >&2; return 2; }
188
- python3 - "$copy/skills/teamsmith/scripts/lib/common.sh" <<'PY' || return 2
189
- import sys
190
-
191
- path = sys.argv[1]
192
- s = open(path, encoding='utf-8').read()
193
- old = """ if team_board_has "$1"; then
194
- if [ "$allow_dup" != "1" ]; then"""
195
- new = """ if false; then # FLIP m48: the duplicate check removed
196
- if [ "$allow_dup" != "1" ]; then"""
197
- if s.count(old) != 1:
198
- sys.exit(f'flip-m48: pattern not unique ({s.count(old)})')
199
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
200
- PY
201
- grep -q 'FLIP m48: the duplicate check removed' "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ add:补丁没写进去\n' >&2; return 2; }
202
- bash -n "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ add:补丁把脚本改坏了\n' >&2; return 2; }
203
-
204
- local mutated_log="$TMP/add-flipped.log" real_log="$TMP/add-now.log"
205
- build_probe "$TMP/probe-mutated.sh" "$copy/skills/teamsmith" || return 2
206
- build_probe "$TMP/probe-real.sh" "$SKILL_DIR" || return 2
207
- run_probe "$TMP/probe-mutated.sh" "$mutated_log"; local mrc=$?
208
- run_probe "$TMP/probe-real.sh" "$real_log"; local rrc=$?
209
- grep -q '^PROBE-M48-END$' "$mutated_log" || { printf ' ✗ add:翻转侧探针没跑完(%s)\n' "$(tail -1 "$mutated_log")" >&2; return 2; }
210
- grep -q '^PROBE-M48-END$' "$real_log" || { printf ' ✗ add:真树侧探针没跑完(%s)\n' "$(tail -1 "$real_log")" >&2; return 2; }
211
- printf ' 翻转 skill 的 §4c:rc=%s(✗ %s 条)|真树 §4c:rc=%s(✗ %s 条)\n' \
212
- "$mrc" "$(plain "$mutated_log" | grep -ac '^ .*✗' || true)" "$rrc" "$(plain "$real_log" | grep -ac '^ .*✗' || true)"
213
-
214
- if [ "$mrc" -ne 0 ] && { plain "$mutated_log" || true; } | grep -qF '✗ M48:重复 ID 的 board add 应当被拒'; then
215
- pass "add:去掉检查 → §4c 的「重复 ID 应当被拒」变红(守卫测试真的咬在检查上)"
216
- plain "$mutated_log" | grep -aF 'M48:' | grep -aF '✗' | sed 's/^/ /' | head -5
217
- else
218
- fail "add:去掉检查后 §4c 没有红在预期断言上(rc=$mrc)"
219
- plain "$mutated_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -8
220
- fi
221
- if [ "$rrc" -eq 0 ] && ! { plain "$real_log" || true; } | grep -q '^ .*✗'; then
222
- pass "add:真树(带检查)在同一探针上全绿"
223
- else
224
- fail "add:真树在 §4c 探针上有失败项(rc=$rrc)"
225
- plain "$real_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -8
226
- fi
227
- return 0
228
- }
229
-
230
- # ---------------------------------------------------------------- assign(原地指派的正门)
231
- flip_assign() {
232
- local copy="$TMP/assign-tree"
233
- mkdir -p "$copy/skills"
234
- ( cd "$TREE" && tar --exclude='*/node_modules' -cf - skills ) | ( cd "$copy" && tar -xf - ) || return 2
235
- [ -d "$copy/skills/teamsmith-init" ] || { printf ' ✗ assign:skill 副本不完整\n' >&2; return 2; }
236
- # 老路:指派 = 再写一行(重复 ID 就是这么进来的)。真源码一个字节不动。
237
- python3 - "$copy/skills/teamsmith/scripts/lib/common.sh" <<'PY' || return 2
238
- import sys
239
-
240
- path = sys.argv[1]
241
- s = open(path, encoding='utf-8').read()
242
- old = """ team_board_write_col "$id" agent "$ag" || return 1
243
- return 0
244
- }"""
245
- new = """ team_board_add "$id" "指派 $ag" "$ag" "-" "-" 1 || return 1 # FLIP m48: assign by adding a row
246
- return 0
247
- }"""
248
- if s.count(old) != 1:
249
- sys.exit(f'flip-m48: pattern not unique ({s.count(old)})')
250
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
251
- PY
252
- grep -q 'FLIP m48: assign by adding a row' "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ assign:补丁没写进去\n' >&2; return 2; }
253
- bash -n "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ assign:补丁把脚本改坏了\n' >&2; return 2; }
254
-
255
- local mutated_log="$TMP/assign-flipped.log" real_log="$TMP/assign-now.log"
256
- build_probe "$TMP/probe-assign-mutated.sh" "$copy/skills/teamsmith" || return 2
257
- build_probe "$TMP/probe-assign-real.sh" "$SKILL_DIR" || return 2
258
- run_probe "$TMP/probe-assign-mutated.sh" "$mutated_log"; local mrc=$?
259
- run_probe "$TMP/probe-assign-real.sh" "$real_log"; local rrc=$?
260
- grep -q '^PROBE-M48-END$' "$mutated_log" || { printf ' ✗ assign:翻转侧探针没跑完(%s)\n' "$(tail -1 "$mutated_log")" >&2; return 2; }
261
- grep -q '^PROBE-M48-END$' "$real_log" || { printf ' ✗ assign:真树侧探针没跑完(%s)\n' "$(tail -1 "$real_log")" >&2; return 2; }
262
- printf ' 翻转 skill 的 §4c:rc=%s(✗ %s 条)|真树 §4c:rc=%s(✗ %s 条)\n' \
263
- "$mrc" "$(plain "$mutated_log" | grep -ac '^ .*✗' || true)" "$rrc" "$(plain "$real_log" | grep -ac '^ .*✗' || true)"
264
-
265
- local want="" l
266
- for l in '✗ M48:assign 后行数不变(不是又加一行)' '✗ M48:assign 后 T1.1 仍是两行(没有顺手改历史数据)'; do
267
- { plain "$mutated_log" || true; } | grep -qF -- "$l" || want="$want
268
- $l"
269
- done
270
- if [ -n "$want" ]; then
271
- fail "assign:翻转(指派改成再写一行)没有红在预期断言上:$want"
272
- plain "$mutated_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
273
- else
274
- pass "assign:翻转(指派 = 再写一行)→ 行数/去重断言变红(守卫真的咬在「原地改」上)"
275
- fi
276
- if [ "$rrc" -eq 0 ] && ! { plain "$real_log" || true; } | grep -q '^ .*✗'; then
277
- pass "assign:真树(原地改 agent)在同一探针上全绿"
278
- else
279
- fail "assign:真树在 §4c 探针上有失败项(rc=$rrc)"
280
- plain "$real_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
281
- fi
282
- return 0
283
- }
284
-
285
- case "$mode" in
286
- focus) flip_focus || RC=1 ;;
287
- add) flip_add || RC=1 ;;
288
- assign) flip_assign || RC=1 ;;
289
- all)
290
- flip_focus || RC=1
291
- printf '\n'
292
- flip_add || RC=1
293
- printf '\n'
294
- flip_assign || RC=1
295
- ;;
296
- esac
297
-
298
- printf '\n'
299
- if [ "$RC" -eq 0 ]; then
300
- printf '\033[32mflip-m48 全部成立\033[0m\n'
301
- else
302
- printf '\033[31mflip-m48 有翻转不成立\033[0m\n'
303
- fi
304
- exit "$RC"
@@ -1,205 +0,0 @@
1
- #!/usr/bin/env bash
2
- # M6.2 控制实验:同一组用例分别跑在「修复前」和「修复后」两份 skill 上。
3
- #
4
- # bash skills/teamsmith/tests/flip-m6.2.sh # 自动找 M6.2 修复前那一版(分支历史还在时)
5
- # BASE=<sha> bash skills/teamsmith/tests/flip-m6.2.sh # squash 合并后用显式钉住的 revision
6
- #
7
- # 为什么存在:smoke 只证明「现在的实现全绿」,证明不了「如果没有这些守卫,测试会红」。
8
- # 这个脚本把 V4.0 报告里的 9 个 finding 写成可执行断言,对两份 skill 各跑一遍:
9
- # BUG-REPRODUCED → 修复前的缺陷还在(red 侧必须全部是这一种)
10
- # BUG-GONE → 现在的可观测行为已经是 M6.2 要求的(green 侧必须全部是这一种)
11
- # 一切都在 /tmp 的临时仓库里,绝不碰当前项目;red 那版从 `git archive <BASE>` 取出,
12
- # 与工作区无关。
13
- set -uo pipefail
14
-
15
- SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
- SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
17
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
18
- . "$SELF_DIR/lib/tmp-root.sh"
19
- REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
20
- [ -n "$REPO_ROOT" ] || { printf '不在 git 仓库里:%s\n' "$SKILL_DIR" >&2; exit 2; }
21
-
22
- BASE="${BASE:-}"
23
- if [ -z "$BASE" ]; then
24
- # 修复的那一版 = 第一个引入记录读取函数(team_review_record_verdict)的提交
25
- FIRST_FIX="$(git -C "$REPO_ROOT" log --reverse --format=%H -S'team_review_record_verdict' \
26
- -- skills/teamsmith/scripts/lib/cmd-review.sh 2>/dev/null | head -1 || true)"
27
- [ -n "$FIRST_FIX" ] && BASE="$(git -C "$REPO_ROOT" rev-parse --verify --quiet "${FIRST_FIX}^" || true)"
28
- fi
29
- if [ -z "$BASE" ] || ! git -C "$REPO_ROOT" rev-parse --verify --quiet "${BASE}^{commit}" >/dev/null 2>&1; then
30
- printf '找不到「修复前」的 revision:用 BASE=<sha> 指定(例如 BASE=914c334)\n' >&2
31
- exit 2
32
- fi
33
-
34
- [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
35
- WORK="$(tmp_root_create flip-m6.2)" || exit 3
36
- cleanup() {
37
- [ "${BASHPID:-$$}" = "$$" ] || return 0
38
- tmp_root_reap_all
39
- }
40
- trap cleanup EXIT
41
- RED_ROOT="$WORK/red"
42
- mkdir -p "$RED_ROOT"
43
- git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$RED_ROOT"
44
- printf '修复前 (red): %s ← skills/teamsmith @ %s\n' "$RED_ROOT/skills/teamsmith" "$(git -C "$REPO_ROOT" rev-parse --short "$BASE")"
45
- printf '修复后 (green): %s\n' "$SKILL_DIR"
46
-
47
- PASS=0; BUG=0
48
- case_line() { # <finding> <label> <bug|fixed> <detail>
49
- if [ "$3" = "bug" ]; then BUG=$((BUG+1)); printf ' %-5s %-6s BUG-REPRODUCED %s\n' "$1" "$2" "$4"
50
- else PASS=$((PASS+1)); printf ' %-5s %-6s BUG-GONE %s\n' "$1" "$2" "$4"; fi
51
- }
52
-
53
- mkproj() { # <name> [gates] → repo path(一个全新的一次性项目)
54
- local r="$WORK/$1"
55
- mkdir -p "$r"
56
- git -C "$r" init -q -b main
57
- git -C "$r" config user.email flip@m62; git -C "$r" config user.name flip
58
- printf '# %s\n' "$1" > "$r/README.md"
59
- git -C "$r" add -A && git -C "$r" commit -qm init
60
- ( cd "$r" && bash "$CUR_SKILL/scripts/team" init --session "m62flip-$$" --agents dev --gates "${2:-true}" ) >/dev/null 2>&1
61
- git -C "$r" add -A && git -C "$r" commit -qm "chore: teamsmith init"
62
- printf '%s\n' "$r"
63
- }
64
-
65
- mktask() { # <repo> <id>:任务书 + BOARD 行 + 分支/worktree + 报告
66
- local r="$1" id="$2" wt="$1/.worktrees/dev"
67
- ( cd "$r" && bash "$CUR_SKILL/scripts/team" task "$id" --title "flip $id" --agent dev ) >/dev/null 2>&1
68
- git -C "$r" worktree add -q -b "task/$id-smoke" "$wt" main
69
- mkdir -p "$wt/docs/team/reports"
70
- printf '# %s · report\n\nagent: dev 状态: DONE\n' "$id" > "$wt/docs/team/reports/$id-dev.md"
71
- printf 'code\n' > "$wt/code.txt"
72
- git -C "$wt" add -A && git -C "$wt" commit -qm "feat($id): code + report"
73
- }
74
-
75
- review() { # <repo> <args...> → stdout+stderr;退出码在 $?(调用方自己接)
76
- local r="$1"; shift
77
- ( cd "$r" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_SKILL_DIR bash "$CUR_SKILL/scripts/team" review "$@" ) 2>&1
78
- }
79
-
80
- verdict_of() { sed -n 's/.*判定: \*\*\([A-Z]*\)\*\*.*/\1/p' "$1/docs/team/reviews/$2.md" 2>/dev/null | head -1; }
81
-
82
- run_all() { # <label> <skill dir>
83
- local LABEL="$1" OUT
84
- CUR_SKILL="$2"
85
-
86
- # F7 —— --branch 解析不到:记录会不会盖章到一个不存在的 revision
87
- local R D
88
- R="$(mkproj f7-$LABEL)"; mktask "$R" P1
89
- D="$WORK/f7-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
90
- OUT="$(review "$R" P1 --dir "$D" --branch no-such-branch)"; local rc=$?
91
- if [ "$rc" = "0" ]; then case_line F7 "$LABEL" bug "rc=0:不存在的 --branch 也盖章(记录抬头写 no-such-branch)"
92
- else case_line F7 "$LABEL" fixed "rc=$rc:$(printf '%s' "$OUT" | grep -m1 -o '分支解析不到.*' || echo '被拒')"; fi
93
-
94
- # F8 —— ALLOW_DIRTY 覆盖下记录/输出还说不说“干净”
95
- R="$(mkproj f8-$LABEL)"; mktask "$R" P1
96
- D="$WORK/f8-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
97
- printf 'dirty\n' >> "$D/code.txt"
98
- OUT="$(cd "$R" && env TEAM_REVIEW_ALLOW_DIRTY=1 bash "$CUR_SKILL/scripts/team" review P1 --dir "$D" 2>&1)"
99
- if grep -q '干净' <(printf '%s\n%s' "$OUT" "$(cat "$R/docs/team/reviews/P1.md" 2>/dev/null)"); then
100
- case_line F8 "$LABEL" bug "ALLOW_DIRTY 覆盖下仍打印/记录「干净」(记录里没有 dirty 字段)"
101
- else
102
- case_line F8 "$LABEL" fixed "$(grep -m1 -o 'checkout dirty: [0-9]* files (override[^)]*)' "$R/docs/team/reviews/P1.md" 2>/dev/null || echo '记录标注了脏树')"
103
- fi
104
-
105
- # F9 —— 被 .gitignore 忽略的产物(不在提交里)能不能让门禁 PASS
106
- R="$(mkproj f9-$LABEL 'test -f build/marker')"; mktask "$R" P1
107
- printf 'build/\n' > "$R/.worktrees/dev/.gitignore"
108
- git -C "$R/.worktrees/dev" add -A && git -C "$R/.worktrees/dev" commit -qm "chore(P1): ignore build/"
109
- D="$WORK/f9-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
110
- mkdir -p "$D/build" && printf 'not in the commit\n' > "$D/build/marker"
111
- OUT="$(review "$R" P1 --dir "$D")"; local rc9=$?
112
- if [ "$rc9" = "0" ]; then case_line F9 "$LABEL" bug "ignored 产物(status --porcelain 为空)让门禁 PASS 并盖章:$(verdict_of "$R" P1)"
113
- else case_line F9 "$LABEL" fixed "rc=$rc9:$(printf '%s' "$OUT" | grep -m1 -o 'ignored[^)]*' || echo 'ignored 产物被拒')"; fi
114
-
115
- # F10 —— 真挂死:记 TIMEOUT 还是 FAIL
116
- R="$(mkproj "f10-$LABEL" 'echo start; sleep 30')"; mktask "$R" P1
117
- D="$WORK/f10-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
118
- (cd "$R" && env TEAM_REVIEW_TIMEOUT=1 bash "$CUR_SKILL/scripts/team" review P1 --dir "$D") >/dev/null 2>&1
119
- local v10; v10="$(verdict_of "$R" P1)"
120
- if [ "$v10" = "TIMEOUT" ]; then case_line F10 "$LABEL" fixed "挂死门禁 → TIMEOUT(记录含「硬超时终止」×$(grep -c '硬超时终止' "$R/docs/team/reviews/P1.md" 2>/dev/null))"
121
- else case_line F10 "$LABEL" bug "挂死门禁被记成 $v10(GNU timeout 默认不打字,grep 不到)"; fi
122
-
123
- # F11 —— 门禁只是打印 'timeout' 字样 + 普通失败
124
- R="$(mkproj "f11-$LABEL" 'echo "info: using timeout 5 for the probe"; exit 3')"; mktask "$R" P1
125
- D="$WORK/f11-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
126
- (cd "$R" && bash "$CUR_SKILL/scripts/team" review P1 --dir "$D") >/dev/null 2>&1
127
- local v11; v11="$(verdict_of "$R" P1)"
128
- if [ "$v11" = "TIMEOUT" ]; then case_line F11 "$LABEL" bug "普通失败(日志里有 timeout 字样)被记成 TIMEOUT"
129
- else case_line F11 "$LABEL" fixed "普通失败(2 秒)记成 $v11(只认 timeout 包装器退出码)"; fi
130
-
131
- # F12 —— --no-gates 的记录与 PASS 是否可区分
132
- R="$(mkproj f12-$LABEL)"; mktask "$R" P1
133
- D="$WORK/f12-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
134
- (cd "$R" && bash "$CUR_SKILL/scripts/team" review P1 --dir "$D" --no-gates) >/dev/null 2>&1
135
- local DIG STA
136
- DIG="$(cd "$R" && bash "$CUR_SKILL/scripts/team" digest 2>&1)"
137
- STA="$(cd "$R" && bash "$CUR_SKILL/scripts/team" status P1 2>&1)"
138
- if grep -q 'gates: none' <<<"$DIG" && grep -q '判定: SKIPPED' <<<"$STA"; then
139
- case_line F12 "$LABEL" fixed "digest 仍列为待复验(gates: none)|status 打印判定"
140
- else
141
- case_line F12 "$LABEL" bug "SKIPPED 与 PASS 不可区分(digest 里的待复验条目=$(grep -c 'P1-dev' <<<"$DIG"),status 里的判定=$(grep -c '判定' <<<"$STA"))"
142
- fi
143
-
144
- # F13/F14 —— --strong 的证据判定
145
- printf '# P1 · keyword only\n\nThere is no 翻转 evidence here and no 独立验证包: the words appear only in this sentence.\n' > "$WORK/f13-body.md"
146
- printf '# P1 · genuine\n\n## Flip evidence\n\nRed before -> green after: I broke the implementation on purpose and the guard test failed, then I restored it.\n\nThe reproduction lives in an independent verification package (docs/team/reports/P1/pkg) written from scratch; it does not reuse the implementation fixtures.\n' > "$WORK/f14-body.md"
147
- local name
148
- for name in f13 f14; do
149
- R="$(mkproj "s$name-$LABEL")"; mktask "$R" P1
150
- cp "$WORK/$name-body.md" "$R/.worktrees/dev/docs/team/reports/P1-dev.md"
151
- git -C "$R/.worktrees/dev" add -A && git -C "$R/.worktrees/dev" commit -qm "docs(P1): $name"
152
- D="$WORK/s$name-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
153
- (cd "$R" && bash "$CUR_SKILL/scripts/team" review P1 --dir "$D" --strong) >/dev/null 2>&1
154
- local v; v="$(grep -m1 -oE '满足强复验|不满足(不阻塞合并' "$R/docs/team/reviews/P1.md" 2>/dev/null || echo '?')"
155
- if [ "$name" = "f13" ]; then
156
- if [ "$v" = "满足强复验" ]; then case_line F13 "$LABEL" bug "只字面提到关键词 → 判成「$v」"
157
- else case_line F13 "$LABEL" fixed "关键词蒙不过去 → 「$v」"; fi
158
- else
159
- if [ "$v" = "满足强复验" ]; then case_line F14 "$LABEL" fixed "英文-first 的真证据 → 「$v」"
160
- else case_line F14 "$LABEL" bug "真证据被判成「$v」"; fi
161
- fi
162
- done
163
-
164
- # F14b —— 报告不在 checkout 里(只在主工作树/agent worktree):PM 退回 M6.2 时复现的现场
165
- R="$(mkproj f14b-$LABEL)"; mktask "$R" P1
166
- git -C "$R/.worktrees/dev" rm -q "$R/.worktrees/dev/docs/team/reports/P1-dev.md"
167
- git -C "$R/.worktrees/dev" commit -qm "chore(P1): report lives outside the checkout"
168
- mkdir -p "$R/docs/team/reports/P1-dev/pkg"
169
- { printf '# P1 · report\n\n## Flip evidence\nRed before: guard test failed (see pkg/flip)\nGreen after: guard test passed\n\n'
170
- printf '## Independent verification package\npkg/run.sh (written for this task, does not reuse the implementation fixtures)\n'; } > "$R/docs/team/reports/P1-dev.md"
171
- printf '#!/usr/bin/env bash\necho red; echo green\n' > "$R/docs/team/reports/P1-dev/pkg/run.sh"
172
- D="$WORK/f14b-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
173
- (cd "$R" && bash "$CUR_SKILL/scripts/team" review P1 --dir "$D" --strong --no-gates) >/dev/null 2>&1
174
- local v14b; v14b="$(grep -m1 -oE '满足强复验|不满足(不阻塞合并' "$R/docs/team/reviews/P1.md" 2>/dev/null || echo '?')"
175
- if [ "$v14b" = "满足强复验" ]; then case_line F14b "$LABEL" fixed "报告不在 checkout 里也认(采用主工作树那份,并注明不在 checkout)"
176
- else case_line F14b "$LABEL" bug "报告不在 checkout 里 → 判成「$v14b」(只扫 checkout 的老毛病)"; fi
177
-
178
- # F3 —— 记录绑定 revision:验完再交付一格,待复验信号回不回来
179
- R="$(mkproj f3-$LABEL)"; mktask "$R" P1
180
- D="$WORK/f3-$LABEL-dir"; git -C "$R" worktree add -q --detach "$D" task/P1-smoke
181
- (cd "$R" && bash "$CUR_SKILL/scripts/team" review P1 --dir "$D") >/dev/null 2>&1
182
- local A; A="$(sed -n 's/.*HEAD: `\([0-9a-f]*\)`.*/\1/p' "$R/docs/team/reviews/P1.md" | head -1)"
183
- git -C "$R/.worktrees/dev" commit -q --allow-empty -m "feat(P1): delivered after verification"
184
- DIG="$(cd "$R" && bash "$CUR_SKILL/scripts/team" digest 2>&1)"
185
- if grep -q 'stale: verified' <<<"$DIG"; then
186
- case_line F3 "$LABEL" fixed "digest 重新列出:$(grep -m1 -o 'stale: verified [0-9a-f]*, branch now [0-9a-f]*' <<<"$DIG")(记录 HEAD $A)"
187
- else
188
- case_line F3 "$LABEL" bug "记录 HEAD $A 之后分支又动了,digest 的待复验仍为空(记录永久压制待办)"
189
- fi
190
- }
191
-
192
- printf '\n== red(修复前)==\n'
193
- run_all RED "$RED_ROOT/skills/teamsmith"
194
- RED_BUGS=$BUG; RED_FIXED=$PASS
195
- PASS=0; BUG=0
196
- printf '\n== green(修复后)==\n'
197
- run_all GREEN "$SKILL_DIR"
198
- GREEN_BUGS=$BUG; GREEN_FIXED=$PASS
199
-
200
- printf '\n== 结果 ==\n red : BUG-REPRODUCED=%d BUG-GONE=%d (10 个 finding/子用例全部必须复现)\n' "$RED_BUGS" "$RED_FIXED"
201
- printf ' green: BUG-GONE=%d BUG-REPRODUCED=%d (必须全部已修复)\n' "$GREEN_FIXED" "$GREEN_BUGS"
202
- if [ "$RED_BUGS" = "10" ] && [ "$GREEN_BUGS" = "0" ]; then
203
- printf ' ✓ 翻转成立:red 全复现 → green 全消失\n'; exit 0
204
- fi
205
- printf ' ✗ 翻转不成立(看上面的逐条输出)\n'; exit 1