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.
Files changed (163) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +69 -0
  4. package/skills/teamsmith/SKILL.md +20 -13
  5. package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
  6. package/skills/teamsmith/extension/team-notify.ts +37 -6
  7. package/skills/teamsmith/extension/team.ts +438 -0
  8. package/skills/teamsmith/references/config.md +39 -6
  9. package/skills/teamsmith/references/migration.md +197 -47
  10. package/skills/teamsmith/references/protocol.md +201 -30
  11. package/skills/teamsmith/references/troubleshooting.md +130 -10
  12. package/skills/teamsmith/references/workflows.md +36 -2
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +318 -23
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +2 -2
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +349 -67
  16. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  17. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  18. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  19. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  20. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  21. package/skills/teamsmith/scripts/lib/cmd-project.sh +30 -103
  22. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  23. package/skills/teamsmith/scripts/lib/cmd-reply.sh +3 -3
  24. package/skills/teamsmith/scripts/lib/cmd-review.sh +182 -32
  25. package/skills/teamsmith/scripts/lib/cmd-status.sh +234 -21
  26. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  27. package/skills/teamsmith/scripts/lib/cmd-watch.sh +564 -46
  28. package/skills/teamsmith/scripts/lib/common.sh +1004 -245
  29. package/skills/teamsmith/scripts/lib/gate-lock.sh +582 -0
  30. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  31. package/skills/teamsmith/scripts/panel/panel.js +211 -211
  32. package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
  33. package/skills/teamsmith/scripts/panel/src/clipboard.ts +12 -5
  34. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  35. package/skills/teamsmith/scripts/panel/src/data.ts +51 -5
  36. package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
  37. package/skills/teamsmith/scripts/panel/src/main.tsx +37 -8
  38. package/skills/teamsmith/scripts/panel/src/strings/en.ts +39 -29
  39. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +41 -31
  40. package/skills/teamsmith/scripts/panel/src/types.ts +28 -3
  41. package/skills/teamsmith/scripts/replies.mjs +4 -1
  42. package/skills/teamsmith/scripts/shim/killall +10 -0
  43. package/skills/teamsmith/scripts/shim/pgrep +10 -0
  44. package/skills/teamsmith/scripts/shim/pidof +10 -0
  45. package/skills/teamsmith/scripts/shim/pkill +10 -0
  46. package/skills/teamsmith/scripts/shim/signal-gate +108 -31
  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 +19 -6
  52. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +8 -1
  53. package/skills/teamsmith/templates/config.sh.tmpl +20 -1
  54. package/skills/teamsmith/templates/pm-prompt.md.tmpl +21 -0
  55. package/skills/teamsmith/tests/README.md +31 -0
  56. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  57. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  58. package/skills/teamsmith/tests/checkout-shape-probe.sh +83 -54
  59. package/skills/teamsmith/tests/config-cli.sh +184 -32
  60. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  61. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  62. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  63. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  64. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  65. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  66. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  67. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  68. package/skills/teamsmith/tests/flip-p310-lock.sh +210 -0
  69. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  70. package/skills/teamsmith/tests/gate-guard.sh +52 -79
  71. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  72. package/skills/teamsmith/tests/install-shape.sh +359 -22
  73. package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
  74. package/skills/teamsmith/tests/key-replies-ui.sh +2 -8
  75. package/skills/teamsmith/tests/key-replies.sh +281 -28
  76. package/skills/teamsmith/tests/ledger-ban.sh +5 -4
  77. package/skills/teamsmith/tests/ledger-claim.sh +2 -1
  78. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  79. package/skills/teamsmith/tests/lib/model-policy.sh +4 -0
  80. package/skills/teamsmith/tests/lib/model-routing-flips.py +51 -0
  81. package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
  82. package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
  83. package/skills/teamsmith/tests/lib/section-guard.sh +316 -164
  84. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  85. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  86. package/skills/teamsmith/tests/lib/tmux-iso.sh +31 -13
  87. package/skills/teamsmith/tests/loop-inventory.tsv +83 -77
  88. package/skills/teamsmith/tests/panel-b2.sh +430 -352
  89. package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
  90. package/skills/teamsmith/tests/panel-b3.sh +314 -62
  91. package/skills/teamsmith/tests/panel-choices.sh +11 -6
  92. package/skills/teamsmith/tests/panel-cpu.sh +43 -130
  93. package/skills/teamsmith/tests/panel-p21.sh +251 -265
  94. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  95. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  96. package/skills/teamsmith/tests/perf.sh +187 -396
  97. package/skills/teamsmith/tests/routes.sh +440 -117
  98. package/skills/teamsmith/tests/seat-interrupt.sh +1012 -0
  99. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  100. package/skills/teamsmith/tests/section-guard.sh +13 -102
  101. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  102. package/skills/teamsmith/tests/section-paths.tsv +32 -18
  103. package/skills/teamsmith/tests/section-select.sh +371 -19
  104. package/skills/teamsmith/tests/signal-gate.sh +249 -27
  105. package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
  106. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  107. package/skills/teamsmith/tests/slash-team.sh +617 -0
  108. package/skills/teamsmith/tests/slice-coverage.sh +206 -0
  109. package/skills/teamsmith/tests/smoke.sh +3595 -788
  110. package/skills/teamsmith/tests/task-model-routing.sh +530 -15
  111. package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
  112. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  113. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  114. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  115. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  116. package/skills/teamsmith/tests/workflow-entry.sh +207 -0
  117. package/skills/teamsmith-init/SKILL.md +12 -12
  118. package/skills/teamsmith-init/references/bootstrap.md +3 -3
  119. package/skills/teamsmith/tests/flip-glue.sh +0 -162
  120. package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
  121. package/skills/teamsmith/tests/flip-m12.sh +0 -185
  122. package/skills/teamsmith/tests/flip-m16.sh +0 -166
  123. package/skills/teamsmith/tests/flip-m17.sh +0 -204
  124. package/skills/teamsmith/tests/flip-m34.sh +0 -96
  125. package/skills/teamsmith/tests/flip-m37.sh +0 -185
  126. package/skills/teamsmith/tests/flip-m4.3.sh +0 -375
  127. package/skills/teamsmith/tests/flip-m43.sh +0 -128
  128. package/skills/teamsmith/tests/flip-m45.sh +0 -244
  129. package/skills/teamsmith/tests/flip-m46.sh +0 -238
  130. package/skills/teamsmith/tests/flip-m48.sh +0 -304
  131. package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
  132. package/skills/teamsmith/tests/flip-m6.3.sh +0 -283
  133. package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
  134. package/skills/teamsmith/tests/flip-m6.5.sh +0 -113
  135. package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
  136. package/skills/teamsmith/tests/flip-m7.2.sh +0 -321
  137. package/skills/teamsmith/tests/flip-p144.sh +0 -112
  138. package/skills/teamsmith/tests/flip-p156.sh +0 -133
  139. package/skills/teamsmith/tests/flip-p160.sh +0 -182
  140. package/skills/teamsmith/tests/flip-p171.sh +0 -249
  141. package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
  142. package/skills/teamsmith/tests/flip-p20.sh +0 -286
  143. package/skills/teamsmith/tests/flip-p201.sh +0 -249
  144. package/skills/teamsmith/tests/flip-p210.sh +0 -239
  145. package/skills/teamsmith/tests/flip-p211.sh +0 -152
  146. package/skills/teamsmith/tests/flip-p217.sh +0 -288
  147. package/skills/teamsmith/tests/flip-p22.sh +0 -123
  148. package/skills/teamsmith/tests/flip-p23.sh +0 -239
  149. package/skills/teamsmith/tests/flip-p25.sh +0 -165
  150. package/skills/teamsmith/tests/flip-p71.sh +0 -184
  151. package/skills/teamsmith/tests/flip-p72.sh +0 -202
  152. package/skills/teamsmith/tests/load-experiment.sh +0 -290
  153. package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
  154. package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
  155. package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
  156. package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
  157. package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
  158. package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
  159. package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
  160. package/skills/teamsmith/tests/panel-knobs.sh +0 -83
  161. package/skills/teamsmith/tests/section-budgets.tsv +0 -154
  162. package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
  163. package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
@@ -1,249 +0,0 @@
1
- #!/usr/bin/env bash
2
- # teamsmith · P171 翻转夹具:真实仓库 state/ 的反向守卫是**白名单**(只看夹具产品自己那族日志
3
- # `signal-calls.log*`),不是 P168 那种「整份 state/ 前后逐字节相同 + 逐条排除活车道」——
4
- # 后者在活仓库里不可满足:巡检每拍都往 state/capacity.log 追加,P168 把 bg.log 补进排除名单后,
5
- # 下一个 tick 就轮到 capacity.log(PM 2026-10-02 的现场:合并 P168 后 `--select 58` 仍红 1 条)。
6
- #
7
- # bash skills/teamsmith/tests/flip-p171.sh # 七面
8
- # bash skills/teamsmith/tests/flip-p171.sh --keep # 保留临时根与七份日志
9
- #
10
- # 本夹具在「真夹具 + 它依赖的 lib/shim/common.sh」的**副本**里跑真夹具(当前树一个字节不动),
11
- # 副本自带一个 fake 仓库根,`.pi/team/state/` 就在副本里 —— 所有写入都落副本。
12
- # 七面:
13
- # ① 受看面红:副本里插一腿「漏钉」的闸门调用(TEAM_SIGNAL_CALLS_LOG 指到真实 state 的配置路径)
14
- # → 必须红,且差异行点名 signal-calls.log(白名单承重:产品真写进来就看得见);
15
- # ② 活车道绿:夹具跑动中往 capacity.log / nudges.log / bg.log / panel.log / dev.env /
16
- # inbox-watch/* 写(今天的现场)→ 必须全绿(白名单只认产品那族,活运行时的车道不进判据);
17
- # ③ 整份快照变异红:把受看面放大成 `*`(修复前那种「整份 state/」判据的最小形状)+ **同一批**写入
18
- # → 必须红,且差异行点名活车道(证明 ② 的写入确实落在两次快照之间,也证明这次修的是承重的那条);
19
- # ④ 还原绿:受看面还原 → 同一批写入又绿(证伪「③的红是夹具自己坏」);
20
- # ⑤ 签名红:往真实 state 的**族外**文件里种诱饵名 → 签名断言必须红(签名扫全树,白名单外也管);
21
- # ⑥ runner 车道里的签名绿:种进 bg/<id>.log → 必须绿(runner 抄的正是本夹具自己的 stdout,
22
- # 不是夹具写了账本;这条就是 P168 那个假红的边界);
23
- # ⑦ 受看面空转变异红:受看面改成一个不存在的名字 → 段尾 watch-shape 探针必须红(判据不是橡皮章)。
24
- # 退出码:0 = 七面都符合预期 | 1 = 期望不成立(日志路径会打印)| 2 = 环境/锚点不成立。
25
- set -uo pipefail
26
-
27
- SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28
- SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
29
- # shellcheck source=lib/tmp-root.sh
30
- . "$SELF_DIR/lib/tmp-root.sh"
31
-
32
- KEEP=0
33
- while [ $# -gt 0 ]; do
34
- case "$1" in
35
- --keep) KEEP=1; shift ;;
36
- -h|--help) sed -n '2,26p' "$0"; exit 0 ;;
37
- *) printf 'flip-p171: 未知参数 %s\n' "$1" >&2; exit 2 ;;
38
- esac
39
- done
40
- [ "$KEEP" = "1" ] && export TEAM_TMP_KEEP=1
41
- TMP="$(tmp_root_create flip-p171)" || exit 3
42
- WRITER_PID=""
43
- cleanup() {
44
- [ "${BASHPID:-$$}" = "$$" ] || return 0
45
- [ -n "$WRITER_PID" ] && kill -TERM "$WRITER_PID" 2>/dev/null || true
46
- [ "$KEEP" = "0" ] && tmp_root_reap_all
47
- return 0
48
- }
49
- trap cleanup EXIT
50
-
51
- PASS=0
52
- FAIL=0
53
- ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
54
- bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
55
- hdr() { printf '\n== %s ==\n' "$1"; }
56
- plain() { sed 's/\x1b\[[0-9;]*m//g' "$1"; }
57
- reds() { plain "$1" | grep -a '^ ✗'; }
58
- has() { plain "$1" | grep -aqF -- "$2"; }
59
- has_re() { plain "$1" | grep -aEq -- "$2"; }
60
- rc_is() { [ "$2" = "$3" ] && ok "$1" || bad "$1(期望 rc=$3,实际 rc=$2)"; }
61
- rc_not() { [ "$2" != "$3" ] && ok "$1" || bad "$1(不该是 rc=$3)"; }
62
-
63
- # ── 副本:真夹具 + 它依赖的 lib / shim / common.sh(当前树一个字节不动)────────────────────────
64
- SCRATCH="$TMP/tree"
65
- STATE="$SCRATCH/.pi/team/state"
66
- FIXTURE="$SCRATCH/skills/teamsmith/tests/signal-gate.sh"
67
- FIXTURE_SRC="$SKILL_DIR/tests/signal-gate.sh"
68
- mkdir -p "$SCRATCH/skills/teamsmith/tests/lib" "$SCRATCH/skills/teamsmith/scripts/lib" || exit 2
69
- cp -a "$SKILL_DIR/scripts/shim" "$SCRATCH/skills/teamsmith/scripts/shim" || exit 2
70
- cp -a "$SKILL_DIR/scripts/lib/common.sh" "$SCRATCH/skills/teamsmith/scripts/lib/common.sh" || exit 2
71
- cp -a "$SKILL_DIR/tests/lib/tmp-root.sh" "$SCRATCH/skills/teamsmith/tests/lib/tmp-root.sh" || exit 2
72
- for f in "$FIXTURE_SRC" "$SCRATCH/skills/teamsmith/scripts/shim/signal-gate" \
73
- "$SCRATCH/skills/teamsmith/scripts/shim/pkill" "$SCRATCH/skills/teamsmith/scripts/shim/killall" \
74
- "$SCRATCH/skills/teamsmith/scripts/lib/common.sh" "$SCRATCH/skills/teamsmith/tests/lib/tmp-root.sh"; do
75
- [ -e "$f" ] || { printf 'flip-p171: 副本缺 %s\n' "$f" >&2; exit 2; }
76
- done
77
- copy_fixture() { cp -a "$FIXTURE_SRC" "$FIXTURE" || return 1; }
78
- # 只改**这一整行**(逐字比较,不用正则 —— 名单那行自带 `*`,sed/grep 的模式会把 `g*` 当成量词)
79
- mutate_fixture() { # <旧整行> <新整行>
80
- awk -v old="$1" -v new="$2" '$0 == old { $0 = new; n++ } { print } END { exit (n == 1 ? 0 : 1) }' \
81
- "$FIXTURE" > "$TMP/fixture-mut.sh" || return 1
82
- cp -a "$TMP/fixture-mut.sh" "$FIXTURE"
83
- }
84
- line_is() { grep -qxF -- "$1" "$FIXTURE"; }
85
-
86
- # 每个用例都从同一份干净 fake state 起步(sentinel.txt 两份快照都含它 —— 它不该造成红)
87
- reset_state() {
88
- rm -rf "$STATE"; mkdir -p "$STATE/bg" "$STATE/inbox-watch" || return 1
89
- printf 'untouched\n' > "$STATE/sentinel.txt"
90
- }
91
-
92
- # ── 锚点:白名单那一行与「私有根」那一行都必须**逐字**长这样,翻转才敢只改/只插一处 ──────────
93
- WATCH_FIXED="FIXTURE_WRITE_WATCH='signal-calls.log*'"
94
- WATCH_BLANKET="FIXTURE_WRITE_WATCH='*'"
95
- WATCH_VACUOUS="FIXTURE_WRITE_WATCH='no-such-watch-family*'"
96
- LEAK_ANCHOR='LOGD="$TMP/logs"; mkdir -p "$LOGD"'
97
- copy_fixture || exit 2
98
- line_is "$WATCH_FIXED" || {
99
- printf 'flip-p171: 副本里没有锚点 %s(夹具的白名单写法变了?)\n' "$WATCH_FIXED" >&2; exit 2; }
100
- line_is "$LEAK_ANCHOR" || {
101
- printf 'flip-p171: 副本里没有锚点 %s(夹具的私有根那一行变了?)\n' "$LEAK_ANCHOR" >&2; exit 2; }
102
-
103
- # ── 活车道写入器:夹具跑动中,活着的运行时每拍都在写这些东西(名字取自真仓库的 state/)──────
104
- writer_start() {
105
- mkdir -p "$TMP/writer" || return 1
106
- (
107
- local i=0
108
- while [ "$i" -lt 3000 ]; do
109
- printf '%s ram=512MB swap=1GB\n' "$(date -u +%FT%TZ)" >> "$STATE/capacity.log"
110
- printf '%s nudge seat=dev\n' "$(date -u +%FT%TZ)" >> "$STATE/nudges.log"
111
- printf '%s wake count=1 ids=w0\n' "$(date -u +%FT%TZ)" >> "$STATE/bg.log"
112
- printf '%s panel page=1\n' "$(date -u +%FT%TZ)" >> "$STATE/panel.log"
113
- printf 'model=x\nwindow=w0\ntask=P171\nbranch=task/P171-apply\n' > "$STATE/dev.env"
114
- printf 'msg %s\n' "$i" >> "$STATE/inbox-watch/w0.msg"
115
- i=$((i + 1)); sleep 0.01
116
- done
117
- ) &
118
- WRITER_PID=$!
119
- }
120
- writer_stop() { # 只收自己 spawn 时记下的那个 pid(纪律:不按名字/模式选进程)
121
- [ -n "$WRITER_PID" ] || return 0
122
- kill -TERM "$WRITER_PID" 2>/dev/null || true
123
- wait "$WRITER_PID" 2>/dev/null || true
124
- WRITER_PID=""
125
- }
126
-
127
- # ── 三种跑法 ──────────────────────────────────────────────────────────────────────────────────
128
- CASE_LOG=""
129
- run_fixture() { # <名字> → 夹具退出码;stdout+stderr 在 $CASE_LOG
130
- CASE_LOG="$TMP/$1.log"
131
- local tdir="$TMP/window-$1"; rm -rf "$tdir"; mkdir -p "$tdir"
132
- ( cd "$SCRATCH" && TMPDIR="$tdir" bash "$FIXTURE" ) >"$CASE_LOG" 2>&1
133
- return $?
134
- }
135
- run_plain() { # <名字> <plant: none|outside|lane>
136
- reset_state || return 99
137
- case "$2" in
138
- outside) printf 'planted %s here\n' "$SIG" >> "$STATE/capacity.log" ;;
139
- lane) printf 'planted %s here\n' "$SIG" >> "$STATE/bg/run-1.log" ;;
140
- esac
141
- run_fixture "$1"
142
- }
143
- run_with_writer() { # <名字>(活车道写入器全程在写)
144
- reset_state || return 99
145
- writer_start || return 99
146
- local rc=0
147
- run_fixture "$1" || rc=$?
148
- writer_stop
149
- return "$rc"
150
- }
151
-
152
- SIG="p159-""decoy-"
153
- GUARD='真实仓库 state/ 受看面'
154
-
155
- # ── ① 受看面红:插一腿「漏钉」的闸门调用 ───────────────────────────────────────────────────────
156
- hdr "① 受看面红:副本里插一腿漏钉的闸门调用(写进真实 state 的 signal-calls.log)→ 必须红"
157
- LEAK_LEG='env PATH="$GATE_DIR:$PATH" TEAM_SIGNAL_REAL="$STUB" TEAM_SIGNAL_CALLS_LOG="$REAL_STATE/signal-calls.log" STUB_LOG="$LOGD/stub-leak.log" "$GATE_DIR/pkill" -f p171-leak >/dev/null 2>&1 || true'
158
- awk -v anchor="$LEAK_ANCHOR" -v leg="$LEAK_LEG" '$0 == anchor { print; print leg; next } { print }' \
159
- "$FIXTURE" > "$TMP/fixture-leak.sh" && cp -a "$TMP/fixture-leak.sh" "$FIXTURE"
160
- grep -qxF "$LEAK_LEG" "$FIXTURE" || { printf 'flip-p171: 漏钉那一腿没插进去\n' >&2; exit 2; }
161
- RC=0; run_plain leak-red none || RC=$?
162
- printf ' 夹具 rc=%s;日志 %s\n' "$RC" "$CASE_LOG"
163
- rc_not "漏钉的闸门调用让夹具非 0 退出" "$RC" "0"
164
- case "$(reds "$CASE_LOG")" in
165
- *"$GUARD"*) ok "红的是反向守卫那条断言" ;;
166
- *) bad "反向守卫没有变红(红的行:$(reds "$CASE_LOG" | head -2 | tr '\n' '|'))" ;;
167
- esac
168
- has_re "$CASE_LOG" '[0-9a-f]{64} signal-calls\.log' \
169
- && ok "快照的「实际」一侧带着 signal-calls.log 的哈希行(白名单确实盯着产品那族)" \
170
- || bad "快照里没有 signal-calls.log 的哈希行"
171
- copy_fixture; RC=0; run_plain leak-restored none || RC=$?
172
- rc_is "把漏钉那一腿去掉(同一份 state)→ 又绿(①的红来自那一腿)" "$RC" "0"
173
- [ -z "$(reds "$CASE_LOG")" ] && ok "还原后整段零 ✗" || bad "还原后还有红:$(reds "$CASE_LOG" | head -3 | tr '\n' '|')"
174
-
175
- # ── ② 活车道绿(今天的现场)───────────────────────────────────────────────────────────────────
176
- hdr "② 活车道绿:夹具跑动中写 capacity.log / nudges.log / bg.log / panel.log / dev.env / inbox-watch/* → 必须全绿"
177
- RC=0; run_with_writer lanes-green || RC=$?
178
- printf ' 夹具 rc=%s;日志 %s\n' "$RC" "$CASE_LOG"
179
- rc_is "夹具全绿(rc=0)" "$RC" "0"
180
- [ -s "$STATE/capacity.log" ] && ok "写入确实发生了(state/capacity.log 非空)" || bad "capacity.log 不在/是空的(写入没生效)"
181
- has "$CASE_LOG" "✓ $GUARD" && ok "反向守卫那条断言是 ✓" || bad "反向守卫那条断言不是 ✓"
182
- [ -z "$(reds "$CASE_LOG")" ] && ok "整段零 ✗" || bad "整段有红:$(reds "$CASE_LOG" | head -3 | tr '\n' '|')"
183
-
184
- # ── ③ 整份快照变异红:受看面放大成 `*` ────────────────────────────────────────────────────────
185
- hdr "③ 整份快照变异红:受看面放大成 $WATCH_BLANKET(修复前那种判据)+ 同一批写入 → 必须红"
186
- mutate_fixture "$WATCH_FIXED" "$WATCH_BLANKET" && line_is "$WATCH_BLANKET" \
187
- || { printf 'flip-p171: 变异没生效\n' >&2; exit 2; }
188
- RC=0; run_with_writer blanket-red || RC=$?
189
- printf ' 夹具 rc=%s;日志 %s\n' "$RC" "$CASE_LOG"
190
- rc_not "「整份 state/」判据下,同一批写入变红(rc≠0)" "$RC" "0"
191
- case "$(reds "$CASE_LOG")" in
192
- *"$GUARD"*) ok "红的是反向守卫那条断言(放大成 * 之后它把活车道也看进去了)" ;;
193
- *) bad "反向守卫没有变红" ;;
194
- esac
195
- has_re "$CASE_LOG" '[0-9a-f]{64} capacity\.log' \
196
- && ok "快照的「实际」一侧带着 capacity.log 的哈希行(② 的写入确实落在两次快照之间)" \
197
- || bad "快照里没有 capacity.log 的哈希行(② 的写入没落在窗口里)"
198
-
199
- # ── ④ 还原绿 ─────────────────────────────────────────────────────────────────────────────────
200
- hdr "④ 还原绿:受看面还原成 $WATCH_FIXED → 同一批写入又绿"
201
- mutate_fixture "$WATCH_BLANKET" "$WATCH_FIXED" && line_is "$WATCH_FIXED" \
202
- || { printf 'flip-p171: 还原没生效\n' >&2; exit 2; }
203
- RC=0; run_with_writer lanes-green-again || RC=$?
204
- printf ' 夹具 rc=%s;日志 %s\n' "$RC" "$CASE_LOG"
205
- rc_is "夹具又全绿(rc=0)" "$RC" "0"
206
- has "$CASE_LOG" "✓ $GUARD" && ok "反向守卫那条断言是 ✓" || bad "反向守卫那条断言不是 ✓"
207
- [ -z "$(reds "$CASE_LOG")" ] && ok "整段零 ✗" || bad "整段有红:$(reds "$CASE_LOG" | head -3 | tr '\n' '|')"
208
-
209
- # ── ⑤ 签名红:族外文件里种诱饵名 ──────────────────────────────────────────────────────────────
210
- hdr "⑤ 签名红:往真实 state 的族外文件(capacity.log)里种诱饵名 → 签名断言必须红"
211
- RC=0; run_plain signature-outside outside || RC=$?
212
- printf ' 夹具 rc=%s;日志 %s\n' "$RC" "$CASE_LOG"
213
- rc_not "种了诱饵名 → 夹具非 0 退出" "$RC" "0"
214
- RED_LINE="$(reds "$CASE_LOG" | grep -aF '诱饵名签名' | head -1)"
215
- case "$RED_LINE" in
216
- *"capacity.log"*) ok "签名断言红且点名 capacity.log(签名扫全树,白名单之外也管)" ;;
217
- *) bad "签名断言没按预期红/点名:${RED_LINE:-无}" ;;
218
- esac
219
-
220
- # ── ⑥ runner 车道里的签名绿 ───────────────────────────────────────────────────────────────────
221
- hdr "⑥ runner 车道绿:诱饵名种进 bg/<id>.log(runner 抄的是夹具自己的 stdout)→ 必须绿"
222
- RC=0; run_plain signature-lane lane || RC=$?
223
- printf ' 夹具 rc=%s;日志 %s\n' "$RC" "$CASE_LOG"
224
- rc_is "夹具全绿(rc=0)" "$RC" "0"
225
- has "$CASE_LOG" "✓ 真实 state(不含 runner 自己的作业车道" && ok "签名断言是 ✓(bg 车道被放过)" \
226
- || bad "签名断言不是 ✓"
227
- [ -z "$(reds "$CASE_LOG")" ] && ok "整段零 ✗" || bad "整段有红:$(reds "$CASE_LOG" | head -3 | tr '\n' '|')"
228
-
229
- # ── ⑦ 受看面空转变异红 ────────────────────────────────────────────────────────────────────────
230
- hdr "⑦ 受看面空转变异红:受看面改成 $WATCH_VACUOUS → watch-shape 探针必须红(判据不是橡皮章)"
231
- mutate_fixture "$WATCH_FIXED" "$WATCH_VACUOUS" && line_is "$WATCH_VACUOUS" \
232
- || { printf 'flip-p171: 空转变异没生效\n' >&2; exit 2; }
233
- RC=0; run_plain vacuous-red none || RC=$?
234
- printf ' 夹具 rc=%s;日志 %s\n' "$RC" "$CASE_LOG"
235
- rc_not "受看面空转 → 夹具非 0 退出" "$RC" "0"
236
- RED_LINE="$(reds "$CASE_LOG" | grep -aF '判据空转' | head -1)"
237
- [ -n "$RED_LINE" ] && ok "形状探针红并点名「判据空转」:${RED_LINE# ✗ }" \
238
- || bad "形状探针没红(受看面空转没被发现):$(reds "$CASE_LOG" | head -2 | tr '\n' '|')"
239
- copy_fixture; line_is "$WATCH_FIXED" || { printf 'flip-p171: 收尾还原没生效\n' >&2; exit 2; }
240
-
241
- # ── 结果 ─────────────────────────────────────────────────────────────────────────────────────
242
- printf '\n== flip-p171 结果 == ✓ %d ✗ %d\n' "$PASS" "$FAIL"
243
- if [ "$FAIL" -eq 0 ]; then
244
- printf '\033[32m七面都符合预期(受看面红 / 活车道绿 / 整份快照变异红 / 还原绿 / 签名红 / runner 车道绿 / 空转红)\033[0m\n'
245
- [ "$KEEP" = "1" ] && printf '现场保留在 %s\n' "$TMP"
246
- exit 0
247
- fi
248
- printf '\033[31m有 %d 条不符合预期(日志在 %s)\033[0m\n' "$FAIL" "$TMP"
249
- exit 1
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env bash
2
- # teamsmith · P18.1 翻转夹具:两栏共享预算(旧 bundle)必须让新夹具变红
3
- #
4
- # bash skills/teamsmith/tests/flip-p18.1.sh # pre 侧 = 最近一次改过 src/layout.ts 的提交的父提交
5
- # bash skills/teamsmith/tests/flip-p18.1.sh --pre-rev <rev> # 指定 pre 侧 revision
6
- # bash skills/teamsmith/tests/flip-p18.1.sh --keep # 保留临时目录与两侧日志
7
- #
8
- # 两侧跑**同一个**检查(tests/panel-snapshots.sh 的 P18.1 段),只换 bundle:
9
- # pre(共享记账 `used = max(两列)`)→ 新夹具红,且**只有它红**(其余 47 条照旧绿);
10
- # 当前树(每列独立记账) → 全绿。
11
- # 这样翻转证明的是「夹具真的在测这次修的那件事」,不是「有人把断言改红了/改绿了」。
12
- #
13
- # 退出码:0 = 翻转成立(pre 红 / 当前绿)|1 = 期望不成立(两侧日志路径会打印)|2 = 环境缺依赖。
14
- set -uo pipefail
15
-
16
- SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
- SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
18
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
19
- . "$SELF_DIR/lib/tmp-root.sh"
20
- TREE="$(cd -P "$SKILL_DIR/../.." && pwd)"
21
- PIN="$SKILL_DIR/scripts/panel/panel.js"
22
- LAYOUT="skills/teamsmith/scripts/panel/src/layout.ts"
23
- PRE_REV=""
24
- KEEP=0
25
- while [ $# -gt 0 ]; do
26
- case "$1" in
27
- --pre-rev) PRE_REV="${2:?--pre-rev 需要 revision}"; shift 2 ;;
28
- --pre-rev=*) PRE_REV="${1#*=}"; shift ;;
29
- --keep) KEEP=1; shift ;;
30
- -h|--help) sed -n '2,16p' "$0"; exit 0 ;;
31
- *) printf 'flip-p18.1: 未知参数 %s\n' "$1" >&2; exit 2 ;;
32
- esac
33
- done
34
-
35
- js="$(command -v node || command -v bun || true)"
36
- [ -n "$js" ] || { printf 'flip-p18.1: 本机没有 node/bun\n' >&2; exit 2; }
37
- command -v git >/dev/null 2>&1 || { printf 'flip-p18.1: 本机没有 git\n' >&2; exit 2; }
38
- [ -s "$PIN" ] || { printf 'flip-p18.1: 找不到 bundle(%s)\n' "$PIN" >&2; exit 2; }
39
- if [ -z "$PRE_REV" ]; then
40
- last="$(git -C "$TREE" log -n1 --format=%H -- "$LAYOUT" 2>/dev/null)"
41
- [ -n "$last" ] || { printf 'flip-p18.1: git 历史里找不到 %s\n' "$LAYOUT" >&2; exit 2; }
42
- PRE_REV="$last^"
43
- fi
44
-
45
- [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
46
- tmp="$(tmp_root_create flip-p18.1)" || exit 3
47
- cleanup() { [ "${BASHPID:-$$}" = "$$" ] && [ "$KEEP" = "0" ] && tmp_root_reap_all; }
48
- trap cleanup EXIT
49
-
50
- pre_bundle="$tmp/pre-panel.js"
51
- if ! git -C "$TREE" show "$PRE_REV:skills/teamsmith/scripts/panel/panel.js" >"$pre_bundle" 2>"$tmp/show.err" || [ ! -s "$pre_bundle" ]; then
52
- printf 'flip-p18.1: 取不到 %s 的 bundle(%s)\n' "$PRE_REV" "$(head -1 "$tmp/show.err" 2>/dev/null)" >&2
53
- exit 2
54
- fi
55
- if cmp -s "$pre_bundle" "$PIN"; then
56
- printf 'flip-p18.1: pre 侧 bundle 与当前树逐字节相同 —— 没有东西可翻(--pre-rev 指一个旧 revision)\n' >&2
57
- exit 2
58
- fi
59
-
60
- run_side() { # <bundle> <log>
61
- TEAM_SNAPSHOTS_PANEL="$1" TEAM_SNAPSHOTS_JS="$js" bash "$SELF_DIR/panel-snapshots.sh" >"$2" 2>&1
62
- }
63
-
64
- printf '\033[1m== flip-p18.1 · pre = %s ==\033[0m\n' "$PRE_REV"
65
- run_side "$pre_bundle" "$tmp/pre.log"; pre_rc=$?
66
- run_side "$PIN" "$tmp/now.log"; now_rc=$?
67
-
68
- sides_ok=1
69
- # 只数「行首两条空格 + ✗」的真失败行:结尾的 `== 结果 == … ✗ N` 汇总行里也有 ✗。
70
- pre_bad="$(grep -E '^ .*✗' "$tmp/pre.log" 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g')"
71
- pre_p181="$(printf '%s\n' "$pre_bad" | grep -c 'P18.1' | tr -d ' ')"
72
- pre_other="$(printf '%s\n' "$pre_bad" | grep -v 'P18.1' | grep -c '✗' | tr -d ' ')"
73
- if [ "$pre_rc" -ne 0 ] && [ "$pre_p181" = "2" ] && [ "$pre_other" = "0" ]; then
74
- printf ' \033[32m✓\033[0m pre(共享记账):P18.1 两条夹具红,其余断言全绿(%s)\n' \
75
- "$(printf '%s\n' "$pre_bad" | head -1 | cut -c1-90)"
76
- else
77
- sides_ok=0
78
- printf ' \033[31m✗\033[0m pre:期望恰好 2 条 P18.1 红 + 0 条其它红,实际 rc=%s / P18.1 红=%s / 其它红=%s\n' \
79
- "$pre_rc" "$pre_p181" "$pre_other"
80
- fi
81
- if [ "$now_rc" -eq 0 ] && grep -q 'panel-snapshots 全绿' "$tmp/now.log"; then
82
- printf ' \033[32m✓\033[0m 当前树(每列独立记账):%s\n' "$(grep '结果' "$tmp/now.log" | sed 's/\x1b\[[0-9;]*m//g' | tail -1)"
83
- else
84
- sides_ok=0
85
- printf ' \033[31m✗\033[0m 当前树没有全绿(rc=%s)\n' "$now_rc"
86
- grep '✗' "$tmp/now.log" | sed 's/\x1b\[[0-9;]*m//g' | head -4
87
- fi
88
-
89
- if [ "$sides_ok" = "1" ]; then
90
- printf '\033[32mflip-p18.1 翻转成立\033[0m\n'
91
- [ "$KEEP" = "1" ] && printf '日志保留:%s\n' "$tmp"
92
- exit 0
93
- fi
94
- printf '\033[31mflip-p18.1 翻转不成立\033[0m —— 两侧日志在 %s\n' "$tmp"
95
- exit 1
@@ -1,286 +0,0 @@
1
- #!/usr/bin/env bash
2
- # teamsmith · P20 flips: every batch's break must turn its own fixture red, and the committed bundle
3
- # must be green — so the fixtures are provably pinned to the thing that batch changed.
4
- #
5
- # bash skills/teamsmith/tests/flip-p20.sh b1 # insertion point / window
6
- # bash skills/teamsmith/tests/flip-p20.sh b2 # word rule / kill ring
7
- # bash skills/teamsmith/tests/flip-p20.sh b3 # multi-line + C-o migration
8
- # bash skills/teamsmith/tests/flip-p20.sh b4 # clipboard failure path
9
- # bash skills/teamsmith/tests/flip-p20.sh b5 # work-page detail return
10
- # bash skills/teamsmith/tests/flip-p20.sh b6 # rename
11
- # bash skills/teamsmith/tests/flip-p20.sh --keep # keep the scratch dirs/logs
12
- #
13
- # Mechanics: a scratch copy of `scripts/panel/src` (with the panel's node_modules symlinked in) gets a
14
- # small textual patch, is rebuilt with bun, and the batch's fixture scenario runs twice — against the
15
- # flipped bundle (`TEAM_B2_PANEL` / `TEAM_B3_PANEL`) and against the committed one. The real sources
16
- # are never touched.
17
- #
18
- # Exit: 0 = the flip holds (flipped red on the expected assertions, committed green)|1 = not|2 = env.
19
- set -uo pipefail
20
-
21
- SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
22
- SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
23
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
24
- . "$SELF_DIR/lib/tmp-root.sh"
25
- TREE="$(cd -P "$SKILL_DIR/../.." && pwd)"
26
- PANEL_DIR="$SKILL_DIR/scripts/panel"
27
- PIN="$PANEL_DIR/panel.js"
28
-
29
- batch="${1:-}"
30
- case "$batch" in
31
- -h|--help) sed -n '2,20p' "$0"; exit 0 ;;
32
- --keep) KEEP=1; batch="${2:-}"; [ -n "$batch" ] || { printf 'flip-p20: --keep 需要 batch\n' >&2; exit 2; } ;;
33
- *) KEEP=0 ;;
34
- esac
35
- case "$batch" in b1|b2|b3|b4|b5|b6) ;; *) printf 'flip-p20: batch 必须是 b1..b6(收到 [%s])\n' "$batch" >&2; exit 2 ;; esac
36
-
37
- js="$(command -v node || command -v bun || true)"
38
- bun="${P20_FLIP_BUN:-}"
39
- [ -n "$bun" ] || bun="$(command -v bun 2>/dev/null || true)"
40
- [ -n "$bun" ] || bun="$HOME/.bun/bin/bun"
41
- [ -x "$bun" ] || { printf 'flip-p20: 需要 bun 重建翻转 bundle(%s)\n' "$bun" >&2; exit 2; }
42
- [ -n "$js" ] || { printf 'flip-p20: 本机没有 node/bun\n' >&2; exit 2; }
43
- [ -s "$PIN" ] || { printf 'flip-p20: 找不到 bundle(%s)\n' "$PIN" >&2; exit 2; }
44
-
45
- INK_PIN="$(sed -n 's/.*"ink": *"\([^"]*\)".*/\1/p' "$PANEL_DIR/package.json")"
46
- REACT_PIN="$(sed -n 's/.*"react": *"\([^"]*\)".*/\1/p' "$PANEL_DIR/package.json")"
47
-
48
- [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
49
- tmp="$(tmp_root_create flip-p20)" || exit 3
50
- cleanup() { [ "${BASHPID:-$$}" = "$$" ] && [ "${KEEP:-0}" = "0" ] && tmp_root_reap_all; }
51
- trap cleanup EXIT
52
-
53
- flip_apply() { # <label> <src dir>:每个 batch 的破坏点(走 Python 的字符串,避开 shell 引号地狱)
54
- local label="$1" d="$2"
55
- case "$label" in
56
- b1)
57
- # The insertion point and the window forced to the draft's end: no window at all.
58
- python3 - "$d" <<'PY'
59
- import sys
60
-
61
- d = sys.argv[1]
62
-
63
-
64
- def edit(name, old, new):
65
- path = f'{d}/{name}'
66
- s = open(path, encoding='utf-8').read()
67
- if s.count(old) != 1:
68
- sys.exit(f'flip-p20: pattern not unique ({s.count(old)}): {old[:70]!r}')
69
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
70
-
71
-
72
- edit('compose.ts', """ let visible = cap
73
- let start = clamp(cur - visible + 1, 0, Math.max(0, rows.length - visible))
74
- if (start > 0 && cap > 1) {
75
- visible = cap - 1
76
- start = clamp(cur - visible + 1, 0, Math.max(0, rows.length - visible))
77
- }""", """ const visible = rows.length // FLIP b1: no window
78
- const start = 0 // FLIP b1: no window""")
79
- edit('compose.ts', " const marker = start > 0 && cap > 1", " const marker = false // FLIP b1")
80
- edit('compose.ts', """ cursorLine: (marker ? 1 : 0) + (cur - start),
81
- cursorColumn: dispWidth(prefix) + dispWidth([...String(draft ?? '')].slice(row.start, at).join('')),""", """ cursorLine: lines.length - 1, // FLIP b1: cursor forced to the end
82
- cursorColumn: dispWidth(lines[lines.length - 1] ?? ''), // FLIP b1""")
83
- PY
84
- ;;
85
- b2)
86
- # The word rule without the platform segmenter (whitespace runs only) and no ring
87
- # accumulation: the segmenter-sensitive punctuation case and the accumulated yank go red.
88
- python3 - "$d" <<'PY'
89
- import sys
90
-
91
- d = sys.argv[1]
92
-
93
-
94
- def edit(name, old, new):
95
- path = f'{d}/{name}'
96
- s = open(path, encoding='utf-8').read()
97
- if s.count(old) != 1:
98
- sys.exit(f'flip-p20: pattern not unique ({s.count(old)}): {old[:70]!r}')
99
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
100
-
101
-
102
- edit('compose.ts', """function segmentsOf(text: string): { segment: string; isWordLike: boolean }[] {
103
- if (!wordSegmenter) wordSegmenter = new Intl.Segmenter(undefined, { granularity: 'word' })
104
- const out: { segment: string; isWordLike: boolean }[] = []
105
- for (const s of wordSegmenter.segment(text)) out.push({ segment: s.segment, isWordLike: s.isWordLike === true })
106
- return out
107
- }""", """function segmentsOf(text: string): { segment: string; isWordLike: boolean }[] {
108
- // FLIP b2: whitespace runs only, no segmenter
109
- const out: { segment: string; isWordLike: boolean }[] = []
110
- for (const m of String(text).matchAll(/\\S+|\\s+/g)) out.push({ segment: m[0], isWordLike: !/^\\s+$/.test(m[0]) })
111
- return out
112
- }""")
113
- edit('compose.ts', """ if (ring.lastDirection === direction && ring.entries.length > 0) {
114
- const head = direction === 'backward' ? text + ring.entries[0] : ring.entries[0] + text
115
- return { entries: [head, ...ring.entries.slice(1)], lastDirection: direction }
116
- }""", " // FLIP b2: no ring accumulation")
117
- PY
118
- ;;
119
- b3)
120
- # (a) the legacy lone `\n` submits again (today's behaviour before B3); (b) the standby
121
- # reason keeps its newline instead of becoming one line.
122
- python3 - "$d" <<'PYB3'
123
- import sys
124
-
125
- d = sys.argv[1]
126
-
127
-
128
- def edit(name, old, new):
129
- path = f'{d}/{name}'
130
- s = open(path, encoding='utf-8').read()
131
- if s.count(old) != 1:
132
- sys.exit(f'flip-p20: pattern not unique ({s.count(old)}): {old[:70]!r}')
133
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
134
-
135
-
136
- edit('compose.ts', " if (ch === '\\n') return { kind: 'newline' }", " if (ch === '\\n') return { kind: 'submit' } // FLIP b3a")
137
- edit('App.tsx', "const flatten = (value: string): string => (mode === 'reason' ? value.replace(/\\n/g, ' ') : value)", "const flatten = (value: string): string => value // FLIP b3b")
138
- PYB3
139
- ;;
140
- b4)
141
- # A failed probe clears the draft and the text fallback is gone: the no-tool and
142
- # text-fallback assertions must go red.
143
- python3 - "$d" <<'PYB4'
144
- import sys
145
-
146
- d = sys.argv[1]
147
-
148
-
149
- def edit(name, old, new):
150
- path = f'{d}/{name}'
151
- s = open(path, encoding='utf-8').read()
152
- if s.count(old) != 1:
153
- sys.exit(f'flip-p20: pattern not unique ({s.count(old)}): {old[:70]!r}')
154
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
155
-
156
-
157
- edit('clipboard.ts', """ const text = await run('wl-paste', ['--no-newline', '--type', 'text'], CLIPBOARD_READ_TIMEOUT_MS)
158
- if (text && text.rc === 0 && text.stdout.length > 0) return { kind: 'text', text: text.stdout.toString('utf8') }
159
- return null""", " return null // FLIP b4: no text fallback")
160
- edit('clipboard.ts', """ const text = await run('xclip', ['-selection', 'clipboard', '-o'], CLIPBOARD_READ_TIMEOUT_MS)
161
- if (text && text.rc === 0 && text.stdout.length > 0) return { kind: 'text', text: text.stdout.toString('utf8') }""", " return null // FLIP b4: no text fallback")
162
- edit('App.tsx', " if (read.kind === 'none' || read.value === '') return", " if (read.kind === 'none' || read.value === '') { updateCompose({ text: '', cursor: 0 }, mode === 'message'); return } // FLIP b4")
163
- PYB4
164
- ;;
165
- b5)
166
- # The rejected implementation: the work page's enter switches to page 4 before opening the
167
- # detail, so closing it dumps the reader on the board page.
168
- python3 - "$d" <<'PYB5'
169
- import sys
170
-
171
- d = sys.argv[1]
172
-
173
-
174
- def edit(name, old, new):
175
- path = f'{d}/{name}'
176
- s = open(path, encoding='utf-8').read()
177
- if s.count(old) != 1:
178
- sys.exit(f'flip-p20: pattern not unique ({s.count(old)}): {old[:70]!r}')
179
- open(path, 'w', encoding='utf-8').write(s.replace(old, new))
180
-
181
-
182
- edit('App.tsx', """ if (page === 2 && key.return) {
183
- // The work page's board rows open the same detail view (P20/B5), on the page it was
184
- // opened from.
185
- openWorkFocused()""", """ if (page === 2 && key.return) {
186
- goPage(4) // FLIP b5: the rejected implementation
187
- openWorkFocused()""")
188
- PYB5
189
- ;;
190
- b6)
191
- # The old label comes back: the messages-page frame assertion and the zh.ts grep go red.
192
- python3 - "$d" <<'PYB6'
193
- import sys
194
-
195
- d = sys.argv[1]
196
- path = f'{d}/strings/zh.ts'
197
- s = open(path, encoding='utf-8').read()
198
- for old, new in (
199
- ("inboxHeading: '收件箱与往来',", "inboxHeading: '收件箱与线程',"),
200
- ("inboxLine: '收件箱 {inbox} 条 · 往来 {thread} 条 · {age}',", "inboxLine: '收件箱 {inbox} 条 · 线程 {thread} 条 · {age}',"),
201
- ("inboxEmpty: '(没有收件箱/往来记录)',", "inboxEmpty: '(没有收件箱/线程记录)',"),
202
- ):
203
- if s.count(old) != 1:
204
- sys.exit(f'flip-p20: pattern not unique ({s.count(old)}): {old!r}')
205
- s = s.replace(old, new)
206
- open(path, 'w', encoding='utf-8').write(s)
207
- PYB6
208
- if grep -q '线程' "$d/strings/zh.ts"; then
209
- printf ' ✓ 翻转源码:zh.ts 里 线程 回来了(grep -c = %s)\n' "$(grep -c '线程' "$d/strings/zh.ts")" >&2
210
- else
211
- printf ' ✗ 翻转源码:b6 补丁没有写进去\n' >&2
212
- return 1
213
- fi
214
- ;;
215
- *)
216
- printf 'flip-p20: batch %s 的破坏点还没写\n' "$label" >&2
217
- return 1
218
- ;;
219
- esac
220
- }
221
-
222
- # Build the flipped bundle from a scratch src copy (node_modules symlinked beside it).
223
- build_flipped() { # <label>
224
- local label="$1" src="$tmp/$1-src"
225
- mkdir -p "$src"
226
- cp -r "$PANEL_DIR/src/." "$src/"
227
- ln -sfn "$PANEL_DIR/node_modules" "$src/node_modules"
228
- flip_apply "$label" "$src" || return 1
229
- ( cd "$PANEL_DIR" && "$bun" build "$src/main.tsx" --target=node --format=esm --minify \
230
- --define "__PIN_INK__=\"$INK_PIN\"" --define "__PIN_REACT__=\"$REACT_PIN\"" \
231
- --outfile "$tmp/$label-panel.js" ) >"$tmp/$label-build.log" 2>&1 || {
232
- printf 'flip-p20: %s 侧构建失败\n' "$label" >&2; tail -3 "$tmp/$label-build.log" >&2; return 1
233
- }
234
- printf '%s' "$tmp/$label-panel.js"
235
- }
236
-
237
- # The batch's scenario(s) against one bundle.
238
- run_side() { # <bundle> <log> <scenario...>
239
- local bundle="$1" log="$2"; shift 2
240
- TEAM_B2_PANEL="$bundle" TEAM_B3_PANEL="$bundle" bash "$runner" "$@" >"$log" 2>&1
241
- }
242
-
243
- case "$batch" in
244
- b1) runner="$SELF_DIR/panel-b2.sh"; scenario=(cursor) ;;
245
- b2) runner="$SELF_DIR/panel-b2.sh"; scenario=(keys) ;;
246
- b3) runner="$SELF_DIR/panel-b2.sh"; scenario=(multiline) ;;
247
- b4) runner="$SELF_DIR/panel-b2.sh"; scenario=(clipboard) ;;
248
- b5) runner="$SELF_DIR/panel-b3.sh"; scenario=(workdetail) ;;
249
- b6) runner="$SELF_DIR/panel-b3.sh"; scenario=(pages) ;;
250
- *) runner="$SELF_DIR/panel-b2.sh"; scenario=(cursor) ;;
251
- esac
252
-
253
- printf '\033[1m== flip-p20 %s · %s ==\033[0m\n' "$batch" "${scenario[*]}"
254
- flipped="$(build_flipped "$batch")" || exit 2
255
- printf ' 翻转 bundle:%s\n' "$flipped"
256
-
257
- run_side "$flipped" "$tmp/$batch-flipped.log" "${scenario[@]}"; flipped_rc=$?
258
- run_side "$PIN" "$tmp/$batch-now.log" "${scenario[@]}"; now_rc=$?
259
-
260
- strip_ansi() { sed 's/\x1b\[[0-9;]*m//g' "$1"; }
261
- flipped_bad="$(strip_ansi "$tmp/$batch-flipped.log" | grep -aE '^ .*✗' || true)"
262
- now_bad="$(strip_ansi "$tmp/$batch-now.log" | grep -aE '^ .*✗' || true)"
263
-
264
- ok=1
265
- if [ "$flipped_rc" -ne 0 ] && [ -n "$flipped_bad" ]; then
266
- printf ' \033[32m✓\033[0m 翻转侧红:\n'
267
- printf '%s\n' "$flipped_bad" | sed 's/^/ /' | head -6
268
- else
269
- ok=0
270
- printf ' \033[31m✗\033[0m 翻转侧没有红(rc=%s)—— 夹具没在测这一批改的东西\n' "$flipped_rc"
271
- fi
272
- if [ "$now_rc" -eq 0 ] && [ -z "$now_bad" ]; then
273
- printf ' \033[32m✓\033[0m 提交的 bundle:全绿(%s)\n' "$(strip_ansi "$tmp/$batch-now.log" | grep '结果' | tail -1 | tr -d ' ')"
274
- else
275
- ok=0
276
- printf ' \033[31m✗\033[0m 提交的 bundle 没有全绿(rc=%s)\n' "$now_rc"
277
- printf '%s\n' "$now_bad" | sed 's/^/ /' | head -6
278
- fi
279
-
280
- if [ "$ok" = "1" ]; then
281
- printf '\033[32mflip-p20 %s 翻转成立\033[0m\n' "$batch"
282
- [ "${KEEP:-0}" = "1" ] && printf '日志保留:%s\n' "$tmp"
283
- exit 0
284
- fi
285
- printf '\033[31mflip-p20 %s 翻转不成立\033[0m —— 两侧日志在 %s\n' "$batch" "$tmp"
286
- exit 1