teamsmith 0.3.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 (101) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +41 -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 +80 -2
  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,318 +0,0 @@
1
- #!/usr/bin/env bash
2
- # panel-flip-p125.sh — the break/fix flips for P125 (change panel-board-cards, panel delta).
3
- #
4
- # bash skills/teamsmith/tests/panel-flip-p125.sh # both flips
5
- # bash skills/teamsmith/tests/panel-flip-p125.sh F-INPLACE # selected flips
6
- #
7
- # Each flip copies `panel/src` to a scratch tree, patches it, builds a mutant bundle with the pinned
8
- # bun, and runs the same P125 frame checks against the mutant (they must go red) and against the
9
- # committed bundle (they must be green). The working tree's sources are never touched — the mutant
10
- # lives in the scratch tree, and the committed `panel.js` is compared byte for byte at the end.
11
- #
12
- # Flips:
13
- # F-INPLACE the side-by-side tier keeps the pre-P125 in-place folded line (natural width, no
14
- # three-column frame) → "folding gives the columns back" reds.
15
- # F-FRAME99 the grouped tier draws the three-column frame instead of the in-place single line
16
- # → "a narrow pane saves rows" reds.
17
- #
18
- # Exit: 0 every selected flip behaved, 1 at least one flip did not, 3 setup failure.
19
- set -uo pipefail
20
-
21
- here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
22
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
23
- . "$here/lib/tmp-root.sh"
24
- tree="$(cd -P "$here/../../.." && pwd)"
25
- skill="$tree/skills/teamsmith"
26
- panel_dir="$skill/scripts/panel"
27
- src="$panel_dir/src"
28
- stub="$here/panel-b3-stub.sh"
29
- committed="$panel_dir/panel.js"
30
- bun_bin="${BUN:-$(command -v bun || true)}"
31
- [ -n "$bun_bin" ] || bun_bin="$HOME/.bun/bin/bun"
32
- js="$(command -v node || command -v bun || true)"
33
- tmp="$(tmp_root_create panel-flip-p125)" || exit 3
34
- PASS=0
35
- FAIL=0
36
- cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; tmp_root_reap_all; }
37
- trap cleanup EXIT
38
-
39
- ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
40
- bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
41
-
42
- SECTIONS=("$@")
43
- [ "${#SECTIONS[@]}" -gt 0 ] || SECTIONS=(F-INPLACE F-FRAME99)
44
- want() { local s; for s in "${SECTIONS[@]}"; do [ "$s" = "$1" ] && return 0; done; return 1; }
45
-
46
- [ -x "$bun_bin" ] || { printf 'panel-flip-p125: bun is required (rebuilds the mutant bundle)\n' >&2; exit 3; }
47
- [ -n "$js" ] || { printf 'panel-flip-p125: node or bun is required (runs the frames)\n' >&2; exit 3; }
48
- [ -d "$panel_dir/node_modules" ] || { printf 'panel-flip-p125: run `bun install --frozen-lockfile` in scripts/panel first\n' >&2; exit 3; }
49
- [ -f "$stub" ] || { printf 'panel-flip-p125: missing %s\n' "$stub" >&2; exit 3; }
50
-
51
- ink_pin="$(sed -n 's/.*"ink": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
52
- react_pin="$(sed -n 's/.*"react": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
53
- [ -n "$ink_pin" ] && [ -n "$react_pin" ] || { printf 'panel-flip-p125: cannot read the pins\n' >&2; exit 3; }
54
-
55
- committed_sha_before="$(sha256sum "$committed" | cut -d' ' -f1)"
56
-
57
- # ---------------------------------------------------------------- the P125 frame checks
58
- # The probe is one python program over a rendered `--snapshot` frame; each mode prints `ok` or the
59
- # concrete problem, so the same function is the green side (committed bundle) and the red side
60
- # (mutant) — a flip cannot pass by moving the yardstick.
61
- p125_probe() {
62
- python3 - "$@" <<'PYP'
63
- import re, sys
64
-
65
- WIDE = [(0x1100, 0x115f), (0x2e80, 0x303e), (0x3041, 0x33ff), (0x3400, 0x4dbf), (0x4e00, 0x9fff),
66
- (0xa000, 0xa4cf), (0xac00, 0xd7a3), (0xf900, 0xfaff), (0xfe10, 0xfe19), (0xfe30, 0xfe6f),
67
- (0xff00, 0xff60), (0xffe0, 0xffe6), (0x1f300, 0x1f64f), (0x1f900, 0x1f9ff)]
68
-
69
- def chw(ch):
70
- cp = ord(ch)
71
- if cp in (0x200d, 0xfe0f) or 0x0300 <= cp <= 0x036f:
72
- return 0
73
- return 2 if any(a <= cp <= b for a, b in WIDE) else 1
74
-
75
- def dw(text):
76
- return sum(chw(c) for c in text)
77
-
78
- def slice_dw(text, start, n):
79
- out, pos = [], 0
80
- for ch in text:
81
- w = chw(ch)
82
- if start <= pos < start + n:
83
- out.append(ch)
84
- pos += w
85
- if pos >= start + n:
86
- break
87
- return "".join(out)
88
-
89
- def read(path):
90
- return [l.rstrip("\n") for l in open(path, encoding="utf-8")]
91
-
92
- mode = sys.argv[1]
93
- problems = []
94
-
95
- if mode == "wide":
96
- path, limit, folded, shown_w = sys.argv[2], int(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5])
97
- rows = read(path)
98
- over = [(i + 1, dw(r)) for i, r in enumerate(rows) if dw(r) > limit]
99
- if over:
100
- problems.append(f"行超过 {limit} 列:{over[:2]}")
101
- top = next((i for i, r in enumerate(rows) if "╭─" in r), -1)
102
- if top < 0:
103
- problems.append("没有车道行(找不到 ╭─)")
104
- else:
105
- row = rows[top]
106
- frames = [dw(row[:m.start()]) for m in re.finditer("╭─╮", row)]
107
- if len(frames) != folded:
108
- problems.append(f"三列小框 {len(frames)} 个,期望 {folded}")
109
- if "(已折叠)" in row:
110
- problems.append("宽档还画了原地折叠行")
111
- for x in frames:
112
- cells, i = [], top
113
- while i < len(rows):
114
- cells.append(slice_dw(rows[i], x, 3))
115
- i += 1
116
- if cells[-1] == "╰─╯":
117
- break
118
- if cells[0] != "╭─╮" or cells[-1] != "╰─╯":
119
- problems.append(f"框的角落 {cells[0]!r}..{cells[-1]!r}")
120
- body = cells[1:-1]
121
- if not body or not all(c in ("│…│", "│⋮│", "│›│") for c in body):
122
- problems.append(f"框体 {set(body)}")
123
- mid = [j for j, c in enumerate(body) if c == "│⋮│"]
124
- want = (len(body) - 1) // 2
125
- if mid != [want]:
126
- problems.append(f"竖省略号在 {mid} 行,期望 [{want}](共 {len(body)} 行)")
127
- if shown_w > 0:
128
- m = re.search("╭─ ▾ 完成", row)
129
- if not m:
130
- problems.append("没有展开的 done 盒子")
131
- else:
132
- x = dw(row[:m.start()])
133
- j = next(j for j in range(x, dw(row)) if slice_dw(row, j, 1) == "╮")
134
- if j - x + 1 != shown_w:
135
- problems.append(f"展开车道宽 {j - x + 1},期望 {shown_w}")
136
-
137
- elif mode == "grouped":
138
- path, limit = sys.argv[2], int(sys.argv[3])
139
- rows = read(path)
140
- over = [(i + 1, dw(r)) for i, r in enumerate(rows) if dw(r) > limit]
141
- if over:
142
- problems.append(f"行超过 {limit} 列:{over[:2]}")
143
- if any("╭" in r for r in rows):
144
- problems.append("分组档出现了三列小框的圆角")
145
- if not any("(已折叠)" in r for r in rows):
146
- problems.append("没有原地折叠行")
147
-
148
- elif mode == "focus":
149
- rows = read(sys.argv[2])
150
- top = next((i for i, r in enumerate(rows) if "╭─" in r), -1)
151
- if top < 0:
152
- problems.append("没有车道行")
153
- else:
154
- cells, i = [], top
155
- while i < len(rows):
156
- cells.append(slice_dw(rows[i], 0, 3))
157
- i += 1
158
- if cells[-1] == "╰─╯":
159
- break
160
- if not cells or cells[0] != "╭─╮":
161
- problems.append("首车道不是三列小框")
162
- elif cells[1] != "│›│":
163
- problems.append(f"聚焦框内第一行为 {cells[1]!r},期望 │›│")
164
- if sum(r.count("›") for r in rows) != 1:
165
- problems.append("焦点光标不是恰好一个")
166
- if "待办 1" not in rows[-1]:
167
- problems.append("底栏没有给出被聚焦折叠车道的标签与计数")
168
- if any("V14" in r for r in rows):
169
- problems.append("折叠车道仍渲染卡片")
170
-
171
- elif mode == "rows":
172
- folded, unfolded = read(sys.argv[2]), read(sys.argv[3])
173
- if any("╭" in r for r in folded):
174
- problems.append("分组档的折叠车道画了三列小框(那里折叠要省行)")
175
- if not any("已放弃" in r for r in folded):
176
- problems.append("折叠 done 后「已放弃」没有进入窗口(没有省下行)")
177
- if any("已放弃" in r for r in unfolded):
178
- problems.append("展开 done 时「已放弃」也在窗口里(对照无效)")
179
-
180
- print("ok" if not problems else ";".join(problems))
181
- PYP
182
- }
183
-
184
- frame_checks() { # <panel.js> <dir>
185
- local p="$1" d="$2" rc=0 verdict
186
- mkdir -p "$d/root/state"
187
- render() { # <out> <w> <h> [conf...]
188
- local out="$1" w="$2" h="$3"; shift 3
189
- rm -f "$d/root/state/panel.conf"
190
- [ $# -gt 0 ] && printf '%s\n' "$@" >"$d/root/state/panel.conf"
191
- # Redirect + sed, never a pipe: the panel exits right after its write and a piped reader can
192
- # lose the tail. The assertions read visible text, so the tone SGR bytes are stripped here.
193
- ( cd "$d" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION \
194
- "$js" "$p" --snapshot --root "$d/root" --state-dir "$d/root/state" \
195
- --team-cli "$stub" --lang zh --theme dark --width "$w" --height "$h" --page 4 ) >"$out.raw" 2>/dev/null
196
- sed 's/\x1b\[[0-9;]*m//g' "$out.raw" >"$out"
197
- }
198
- check() { # <probe...> <label>
199
- local label="${*: -1}" out
200
- local probe=("${@:1:$#-1}")
201
- out="$(p125_probe "${probe[@]}")"
202
- if [ "$out" = "ok" ]; then
203
- printf ' \033[32m✓\033[0m %s\n' "$label"
204
- else
205
- printf ' \033[31m✗\033[0m %s(%s)\n' "$label" "$out"; rc=1
206
- fi
207
- }
208
- # 1) the wide tier: two empty lanes folded by default = two three-column frames; the four shown
209
- # lanes take (185 - 3*2)/4 = 44 columns each (the even share is 30) and no line overruns 190.
210
- render "$d/w190.txt" 190 32
211
- check wide "$d/w190.txt" 190 2 44 "宽档 190:两个三列小框、四条展开车道各 44 列、不超宽"
212
- # 2) all six folded: six frames, still bounded.
213
- render "$d/w190all.txt" 190 32 "boardFold=todo,wip,review,done,blocked,dropped"
214
- check wide "$d/w190all.txt" 190 6 -1 "宽档 190 全折叠:六个三列小框、行不超宽"
215
- # 3) the grouped tier keeps the in-place single line and never draws the frame.
216
- render "$d/g99.txt" 99 32
217
- check grouped "$d/g99.txt" 99 "窄档 99:原地一行、无三列小框、行不超宽"
218
- # 4) a narrow pane saves rows: with done holding 20 cards the fold lets `已放弃` into the window.
219
- export B3_STUB_DONE=20
220
- render "$d/n99show.txt" 99 32 "boardShow=done"
221
- render "$d/n99fold.txt" 99 32 "boardFold=done"
222
- unset B3_STUB_DONE
223
- check rows "$d/n99fold.txt" "$d/n99show.txt" "窄屏省行:折叠 done(20 卡)让「已放弃」进入窗口,展开时进不来"
224
- # 5) a focused folded lane in the wide tier: the frame carries the cursor, the band names it.
225
- render "$d/focus.txt" 190 32 "boardFold=todo"
226
- check focus "$d/focus.txt" "聚焦折叠车道:框内 │›│、恰好一个光标、底栏「待办 1」、卡片不渲染"
227
- return $rc
228
- }
229
-
230
- # ---------------------------------------------------------------- the mutant build
231
- build_mutant() { # <name> <edit script>
232
- local name="$1" edit="$2" tree="$tmp/$1"
233
- rm -rf "$tree"; mkdir -p "$tree"
234
- cp -r "$src/." "$tree/"
235
- ln -sfn "$panel_dir/node_modules" "$tree/node_modules"
236
- if ! FLIP_EDIT="$edit" FLIP_TREE="$tree" python3 - <<'PYEDIT'
237
- import os
238
- tree = os.environ["FLIP_TREE"]
239
- exec(compile(os.environ["FLIP_EDIT"], "<flip>", "exec"))
240
- PYEDIT
241
- then
242
- printf ' \033[31m✗\033[0m %s:源码断点没打上\n' "$name"
243
- return 1
244
- fi
245
- ( cd "$panel_dir" && "$bun_bin" build "$tree/main.tsx" --target=node --format=esm --minify \
246
- --define "__PIN_INK__=\"$ink_pin\"" --define "__PIN_REACT__=\"$react_pin\"" \
247
- --outfile "$tmp/$name.js" ) >"$tmp/$name-build.log" 2>&1 || {
248
- printf ' \033[31m✗\033[0m %s:突变的 bundle 构建失败\n' "$name"; tail -3 "$tmp/$name-build.log" >&2; return 1
249
- }
250
- return 0
251
- }
252
-
253
- # <name> <edit script> <what the flip breaks>
254
- flip() {
255
- local name="$1" edit="$2" what="$3"
256
- printf '\n\033[1m== %s:%s ==\033[0m\n' "$name" "$what"
257
- build_mutant "$name" "$edit" || { FAIL=$((FAIL + 1)); return; }
258
- local green="$tmp/$name-green.log" red="$tmp/$name-red.log"
259
- frame_checks "$committed" "$tmp/$name-green-dir" >"$green" 2>&1; local green_rc=$?
260
- frame_checks "$tmp/$name.js" "$tmp/$name-red-dir" >"$red" 2>&1; local red_rc=$?
261
- if [ "$green_rc" -eq 0 ]; then
262
- ok "$name:提交的 bundle 上同一组检查绿"
263
- else
264
- bad "$name:提交的 bundle 上基线就红了(检查本身坏了)"; sed 's/^/ /' "$green" | grep '✗' | head -3
265
- fi
266
- if [ "$red_rc" -ne 0 ] && grep -q '✗' "$red"; then
267
- ok "$name:突变之后变红($(grep -c '✗' "$red") 条;$(grep '✗' "$red" | head -1 | sed 's/^ *✗ *//' | cut -c1-70))"
268
- else
269
- bad "$name:突变之后居然还是绿的(翻转失效)"; sed 's/^/ /' "$red"
270
- fi
271
- }
272
-
273
- # ---------------------------------------------------------------- the flips
274
- if want F-INPLACE; then
275
- flip F-INPLACE 'p = f"{tree}/layout.ts"
276
- s = open(p, encoding="utf-8").read()
277
- old = " return foldedLaneFrame(ctx, lane, focused, slots + 2)"
278
- new = """ const out: PlacedLine[] = [foldedLaneLine(ctx, lane, cards.length, width, focused)] // FLIP P125
279
- while (out.length < slots + 2) out.push({ line: [] })
280
- return out"""
281
- assert s.count(old) == 1, "anchor: the folded frame branch"
282
- s = s.replace(old, new)
283
- old2 = """ for (const lane of foldedLanes) widths.set(lane, FOLD_FRAME_W)
284
- const eachShown = Math.max(8, Math.floor((usable - FOLD_FRAME_W * foldedLanes.length) / shownLanes.length))"""
285
- new2 = """ let spent = 0 // FLIP P125: the pre-frame algorithm — folded lanes take their line s width
286
- for (const lane of foldedLanes) {
287
- const w = Math.max(1, Math.min(dispWidth(foldedLaneHead(ctx.s, lane, laneCards(rows, lane).length)) + 2, 30))
288
- widths.set(lane, w)
289
- spent += w
290
- }
291
- const eachShown = Math.max(1, Math.floor((usable - spent) / shownLanes.length))"""
292
- assert s.count(old2) == 1, "anchor: the folded width share"
293
- open(p, "w", encoding="utf-8").write(s.replace(old2, new2))
294
- ' "宽档强行用原地一行(自然宽 11–12 列)"
295
- fi
296
-
297
- if want F-FRAME99; then
298
- flip F-FRAME99 'p = f"{tree}/layout.ts"
299
- s = open(p, encoding="utf-8").read()
300
- old = " all.push(foldedLaneLine(ctx, lane, cards.length, width, focused))"
301
- new = " for (const l of foldedLaneFrame(ctx, lane, focused, 3)) all.push(l) // FLIP P125: the grouped tier draws the frame"
302
- assert s.count(old) == 1, "anchor: the grouped fold branch"
303
- open(p, "w", encoding="utf-8").write(s.replace(old, new))
304
- ' "窄档强行用三列小框(不再省行)"
305
- fi
306
-
307
- # ---------------------------------------------------------------- the committed bundle must be untouched
308
- committed_sha_after="$(sha256sum "$committed" | cut -d' ' -f1)"
309
- if [ "$committed_sha_before" = "$committed_sha_after" ]; then
310
- ok "翻转全程没有碰提交的 panel.js(sha256 不变)"
311
- else
312
- bad "翻转改动了提交的 panel.js($committed_sha_before → $committed_sha_after)"
313
- fi
314
-
315
- printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d\n' "$PASS" "$FAIL"
316
- [ "$FAIL" -eq 0 ] && { printf '\033[32mpanel-flip-p125 全绿\033[0m\n'; exit 0; }
317
- printf '\033[31mpanel-flip-p125 有失败项\033[0m\n'
318
- exit 1
@@ -1,259 +0,0 @@
1
- #!/usr/bin/env bash
2
- # panel-flip-p128.sh — the break/fix flip for P128 (change panel-board-cards, panel delta).
3
- #
4
- # bash skills/teamsmith/tests/panel-flip-p128.sh # the flip
5
- # bash skills/teamsmith/tests/panel-flip-p128.sh F-COLUMN # same, named
6
- #
7
- # Copies `panel/src` to a scratch tree, patches the grouped tier's in-place folded line back to the
8
- # lane-header column (the pre-P128 shape), builds the mutant bundle with the pinned bun, and runs
9
- # the P128 checks against the mutant (they must go red) and against the committed bundle (they must
10
- # be green). The working tree's sources are never touched — the mutant lives in the scratch tree —
11
- # and the committed `panel.js` is compared byte for byte at the end.
12
- #
13
- # The checks are the delta scenario "The in-place folded line lines up with the cards it replaces"
14
- # (the folded line's marker in the cards' state-glyph column, the focus cursor in the cards' cursor
15
- # column, the lane header still in its own column) plus the existing narrow-tier shape checks
16
- # (in place, no three-column frame, rows bounded) as the control group.
17
- #
18
- # Flip:
19
- # F-COLUMN the folded line hangs at the lane-header column again (no leading indent, no cursor
20
- # column) → the two alignment checks red, the narrow shape checks stay green.
21
- #
22
- # Exit: 0 the flip behaved, 1 it did not, 3 setup failure.
23
- set -uo pipefail
24
-
25
- here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
27
- . "$here/lib/tmp-root.sh"
28
- tree="$(cd -P "$here/../../.." && pwd)"
29
- skill="$tree/skills/teamsmith"
30
- panel_dir="$skill/scripts/panel"
31
- src="$panel_dir/src"
32
- stub="$here/panel-b3-stub.sh"
33
- committed="$panel_dir/panel.js"
34
- bun_bin="${BUN:-$(command -v bun || true)}"
35
- [ -n "$bun_bin" ] || bun_bin="$HOME/.bun/bin/bun"
36
- js="$(command -v node || command -v bun || true)"
37
- tmp="$(tmp_root_create panel-flip-p128)" || exit 3
38
- PASS=0
39
- FAIL=0
40
- cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; tmp_root_reap_all; }
41
- trap cleanup EXIT
42
-
43
- ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
44
- bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
45
-
46
- SECTIONS=("$@")
47
- [ "${#SECTIONS[@]}" -gt 0 ] || SECTIONS=(F-COLUMN)
48
- want() { local s; for s in "${SECTIONS[@]}"; do [ "$s" = "$1" ] && return 0; done; return 1; }
49
-
50
- [ -x "$bun_bin" ] || { printf 'panel-flip-p128: bun is required (rebuilds the mutant bundle)\n' >&2; exit 3; }
51
- [ -n "$js" ] || { printf 'panel-flip-p128: node or bun is required (runs the frames)\n' >&2; exit 3; }
52
- [ -d "$panel_dir/node_modules" ] || { printf 'panel-flip-p128: run `bun install --frozen-lockfile` in scripts/panel first\n' >&2; exit 3; }
53
- [ -f "$stub" ] || { printf 'panel-flip-p128: missing %s\n' "$stub" >&2; exit 3; }
54
-
55
- ink_pin="$(sed -n 's/.*"ink": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
56
- react_pin="$(sed -n 's/.*"react": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
57
- [ -n "$ink_pin" ] && [ -n "$react_pin" ] || { printf 'panel-flip-p128: cannot read the pins\n' >&2; exit 3; }
58
-
59
- committed_sha_before="$(sha256sum "$committed" | cut -d' ' -f1)"
60
-
61
- # ---------------------------------------------------------------- the P128 frame checks
62
- # One python program over a rendered `--snapshot` frame; each mode prints `ok` or the concrete
63
- # problem, so the same function is the green side (committed bundle) and the red side (mutant) —
64
- # the flip cannot pass by moving the yardstick. Columns are display columns (CJK = 2).
65
- p128_probe() {
66
- python3 - "$@" <<'PYP'
67
- import sys
68
-
69
- WIDE = [(0x1100, 0x115f), (0x2e80, 0x303e), (0x3041, 0x33ff), (0x3400, 0x4dbf), (0x4e00, 0x9fff),
70
- (0xa000, 0xa4cf), (0xac00, 0xd7a3), (0xf900, 0xfaff), (0xfe10, 0xfe19), (0xfe30, 0xfe6f),
71
- (0xff00, 0xff60), (0xffe0, 0xffe6), (0x1f300, 0x1f64f), (0x1f900, 0x1f9ff)]
72
-
73
- def chw(ch):
74
- cp = ord(ch)
75
- if cp in (0x200d, 0xfe0f) or 0x0300 <= cp <= 0x036f:
76
- return 0
77
- return 2 if any(a <= cp <= b for a, b in WIDE) else 1
78
-
79
- def dw(text):
80
- return sum(chw(c) for c in text)
81
-
82
- def col_of(row, ch):
83
- pos = 0
84
- for c in row:
85
- if c == ch:
86
- return pos
87
- pos += chw(c)
88
- return -1
89
-
90
- def read(path):
91
- return [l.rstrip("\n") for l in open(path, encoding="utf-8")]
92
-
93
- mode = sys.argv[1]
94
- problems = []
95
-
96
- if mode == "grouped":
97
- path, limit = sys.argv[2], int(sys.argv[3])
98
- rows = read(path)
99
- over = [(i + 1, dw(r)) for i, r in enumerate(rows) if dw(r) > limit]
100
- if over:
101
- problems.append(f"行超过 {limit} 列:{over[:2]}")
102
- if any("╭" in r for r in rows):
103
- problems.append("分组档出现了三列小框的圆角")
104
- if not any("(已折叠)" in r for r in rows):
105
- problems.append("没有原地折叠行")
106
-
107
- elif mode == "align":
108
- path, kind = sys.argv[2], sys.argv[3]
109
- rows = read(path)
110
- folded = [r for r in rows if "(已折叠)" in r]
111
-
112
- def find(sub):
113
- return next((r for r in rows if sub in r), "")
114
-
115
- # ① the unfolded lane header keeps its own marker column (`' ' + ▾`).
116
- head = find("▾ 进行")
117
- if not head:
118
- problems.append("没有展开的 `▾ 进行` 车道头")
119
- elif col_of(head, "▾") != 1:
120
- problems.append(f"车道头 ▾ 在第 {col_of(head, '▾')} 列,期望 1:{head!r}")
121
- # ② an unfocused card's state glyph sits in column 3.
122
- card = find("P14")
123
- if not card:
124
- problems.append("没有 P14 卡片行")
125
- elif col_of(card, "▸") != 3:
126
- problems.append(f"卡片 ▸ 在第 {col_of(card, '▸')} 列,期望 3:{card!r}")
127
- # ③ every in-place folded line's marker sits in column 3 (the cards' glyph column).
128
- if not folded:
129
- problems.append("没有原地折叠行")
130
- for r in folded:
131
- at = col_of(r, "▸")
132
- if at != 3:
133
- problems.append(f"折叠行 ▸ 在第 {at} 列,期望 3(卡片字形列):{r!r}")
134
- # ④ exactly one focus cursor; its column matches the focused card's cursor column.
135
- cursors = sum(r.count("›") for r in rows)
136
- if cursors != 1:
137
- problems.append(f"焦点光标应当恰好一个,实际 {cursors}")
138
- if kind == "plain":
139
- v14 = find("V14")
140
- if not v14:
141
- problems.append("plain 帧没有 V14 聚焦卡片行")
142
- elif col_of(v14, "›") != 1 or col_of(v14, "·") != 3:
143
- problems.append(f"聚焦卡片 › 在第 {col_of(v14, '›')} 列 / · 在第 {col_of(v14, '·')} 列,期望 1/3:{v14!r}")
144
- else:
145
- fr = next((r for r in folded if "›" in r), "")
146
- if not fr:
147
- problems.append("focus 帧的折叠行没有光标(焦点没落在折叠车道上)")
148
- elif col_of(fr, "›") != 1:
149
- problems.append(f"聚焦折叠行 › 在第 {col_of(fr, '›')} 列,期望 1(与聚焦卡片同列):{fr!r}")
150
- if "待办 1" not in fr:
151
- problems.append(f"聚焦折叠行没有标签与计数:{fr!r}")
152
-
153
- print("ok" if not problems else ";".join(problems))
154
- PYP
155
- }
156
-
157
- frame_checks() { # <panel.js> <dir>
158
- local p="$1" d="$2" rc=0 verdict
159
- mkdir -p "$d/root/state"
160
- render() { # <out> <w> <conf line…>
161
- local out="$1" w="$2"; shift 2
162
- rm -f "$d/root/state/panel.conf"
163
- [ $# -gt 0 ] && printf '%s\n' "$@" >"$d/root/state/panel.conf"
164
- ( cd "$d" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION \
165
- "$js" "$p" --snapshot --root "$d/root" --state-dir "$d/root/state" \
166
- --team-cli "$stub" --lang zh --theme dark --width "$w" --height 32 --page 4 ) >"$out.raw" 2>/dev/null
167
- sed 's/\x1b\[[0-9;]*m//g' "$out.raw" >"$out"
168
- }
169
- check() { # <probe…> <label>
170
- local label="${*: -1}" out
171
- local probe=("${@:1:$#-1}")
172
- out="$(p128_probe "${probe[@]}")"
173
- if [ "$out" = "ok" ]; then
174
- printf ' \033[32m✓\033[0m %s\n' "$label"
175
- else
176
- printf ' \033[31m✗\033[0m %s(%s)\n' "$label" "$out"; rc=1
177
- fi
178
- }
179
- # The control group: the existing narrow-tier shape checks (in place, no frame, bounded).
180
- render "$d/plain99.txt" 99
181
- check grouped "$d/plain99.txt" 99 "窄档 99:原地一行、无三列小框、行不超宽(既有场景复跑)"
182
- render "$d/plain60.txt" 60
183
- check grouped "$d/plain60.txt" 60 "窄档 60(PM 现场档):原地一行、无三列小框、行不超宽"
184
- # The scenario under test: the folded line's columns. Plain frame: the focus is on V14's card.
185
- check align "$d/plain99.txt" plain "对齐 99:车道头 ▾ 第 1 列 / 卡片字形第 3 列 / 折叠行标记第 3 列"
186
- check align "$d/plain60.txt" plain "对齐 60:同 99 —— 折叠行落在卡片列"
187
- # A folded lane the focus lives in: the cursor takes the card rows' cursor column.
188
- render "$d/focus99.txt" 99 "boardFold=todo"
189
- check align "$d/focus99.txt" focus "聚焦折叠行:光标第 1 列(与聚焦卡片同列)、标记第 3 列、恰好一个光标"
190
- return $rc
191
- }
192
-
193
- # ---------------------------------------------------------------- the mutant build
194
- build_mutant() { # <name> <edit script>
195
- local name="$1" edit="$2" tree="$tmp/$1"
196
- rm -rf "$tree"; mkdir -p "$tree"
197
- cp -r "$src/." "$tree/"
198
- ln -sfn "$panel_dir/node_modules" "$tree/node_modules"
199
- if ! FLIP_EDIT="$edit" FLIP_TREE="$tree" python3 - <<'PYEDIT'
200
- import os
201
- tree = os.environ["FLIP_TREE"]
202
- exec(compile(os.environ["FLIP_EDIT"], "<flip>", "exec"))
203
- PYEDIT
204
- then
205
- printf ' \033[31m✗\033[0m %s:源码断点没打上\n' "$name"
206
- return 1
207
- fi
208
- ( cd "$panel_dir" && "$bun_bin" build "$tree/main.tsx" --target=node --format=esm --minify \
209
- --define "__PIN_INK__=\"$ink_pin\"" --define "__PIN_REACT__=\"$react_pin\"" \
210
- --outfile "$tmp/$name.js" ) >"$tmp/$name-build.log" 2>&1 || {
211
- printf ' \033[31m✗\033[0m %s:突变的 bundle 构建失败\n' "$name"; tail -3 "$tmp/$name-build.log" >&2; return 1
212
- }
213
- return 0
214
- }
215
-
216
- # <name> <edit script> <what the flip breaks>
217
- flip() {
218
- local name="$1" edit="$2" what="$3"
219
- printf '\n\033[1m== %s:%s ==\033[0m\n' "$name" "$what"
220
- build_mutant "$name" "$edit" || { FAIL=$((FAIL + 1)); return; }
221
- local green="$tmp/$name-green.log" red="$tmp/$name-red.log"
222
- frame_checks "$committed" "$tmp/$name-green-dir" >"$green" 2>&1; local green_rc=$?
223
- frame_checks "$tmp/$name.js" "$tmp/$name-red-dir" >"$red" 2>&1; local red_rc=$?
224
- if [ "$green_rc" -eq 0 ]; then
225
- ok "$name:提交的 bundle 上同一组检查绿"
226
- else
227
- bad "$name:提交的 bundle 上基线就红了(检查本身坏了)"; sed 's/^/ /' "$green" | grep '✗' | head -3
228
- fi
229
- if [ "$red_rc" -ne 0 ] && grep -q '✗' "$red"; then
230
- ok "$name:突变之后变红($(grep -c '✗' "$red") 条;$(grep '✗' "$red" | head -1 | sed 's/^ *✗ *//' | cut -c1-70))"
231
- else
232
- bad "$name:突变之后居然还是绿的(翻转失效)"; sed 's/^/ /' "$red"
233
- fi
234
- }
235
-
236
- # ---------------------------------------------------------------- the flip
237
- if want F-COLUMN; then
238
- flip F-COLUMN 'p = f"{tree}/layout.ts"
239
- s = open(p, encoding="utf-8").read()
240
- old = """ seg(\x27 \x27),
241
- seg(focused ? `${FOCUS_CURSOR} ` : \x27 \x27, focused ? \x27selected\x27 : \x27dim\x27),"""
242
- new = """ seg(focused ? `${FOCUS_CURSOR} ` : \x27\x27, \x27selected\x27), // FLIP P128: back to the lane-header column"""
243
- assert s.count(old) == 1, "anchor: the card-column indent"
244
- open(p, "w", encoding="utf-8").write(s.replace(old, new))
245
- ' "把折叠行改回车道头那一列(去掉卡片列缩进与光标列)"
246
- fi
247
-
248
- # ---------------------------------------------------------------- the committed bundle must be untouched
249
- committed_sha_after="$(sha256sum "$committed" | cut -d' ' -f1)"
250
- if [ "$committed_sha_before" = "$committed_sha_after" ]; then
251
- ok "翻转全程没有碰提交的 panel.js(sha256 不变)"
252
- else
253
- bad "翻转改动了提交的 panel.js($committed_sha_before → $committed_sha_after)"
254
- fi
255
-
256
- printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d\n' "$PASS" "$FAIL"
257
- [ "$FAIL" -eq 0 ] && { printf '\033[32mpanel-flip-p128 全绿\033[0m\n'; exit 0; }
258
- printf '\033[31mpanel-flip-p128 有失败项\033[0m\n'
259
- exit 1
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env bash
2
- # A deliberately slow `team __panel-data` stand-in for the keystroke fixture (tasks.md 1.4).
3
- #
4
- # The probe calls the tree's own data layer with `--team-cli` pointing here, so the refresh is a
5
- # controlled five seconds instead of a busy repository. Both request shapes are served: the full
6
- # object (pre-change data layer) and one block per call (post-change data layer).
7
- set -euo pipefail
8
-
9
- sleep "${KEYPROBE_STUB_SLEEP:-5}"
10
-
11
- block=""
12
- prev=""
13
- for a in "$@"; do
14
- [ "$prev" = "--block" ] && block="$a"
15
- prev="$a"
16
- done
17
-
18
- emit_full() {
19
- cat <<'JSON'
20
- {"panel": {"project": "keyprobe", "timestamp": "2026-01-01T00:00:00Z", "interval": 900,
21
- "standby": {"on": false, "reason": ""},
22
- "pm": {"state": "absent", "detail": "", "evidence": ""},
23
- "pending": {"inbox": 0, "reports": 0, "todo": 0, "wip": 0, "review": 0, "blocked": 0, "stopped": 0, "total": 0, "text": ""},
24
- "outbox": {"queued": 0, "held": 0, "oldest_age_s": null, "forced": 0},
25
- "capacity": {"ram_avail_mb": 4000, "swap_free_mb": 1024, "agents": 2, "spark": [4000, 4010]},
26
- "agents": [], "recent": [], "activity_source": ""}, "activity": []}
27
- JSON
28
- }
29
-
30
- case "$block" in
31
- "") emit_full ;;
32
- frame) printf '%s\n' '{"project": "keyprobe", "timestamp": "2026-01-01T00:00:00Z", "interval": 900, "standby": {"on": false, "reason": ""}, "activity_source": ""}' ;;
33
- pm) printf '%s\n' '{"state": "absent", "detail": "", "evidence": ""}' ;;
34
- pending) printf '%s\n' '{"inbox": 0, "reports": 0, "todo": 0, "wip": 0, "review": 0, "blocked": 0, "stopped": 0, "total": 0, "text": ""}' ;;
35
- outbox) printf '%s\n' '{"queued": 0, "held": 0, "oldest_age_s": null, "forced": 0}' ;;
36
- capacity) printf '%s\n' '{"ram_avail_mb": 4000, "swap_free_mb": 1024, "agents": 2, "spark": [4000, 4010]}' ;;
37
- agents) printf '%s\n' '[]' ;;
38
- recent) printf '%s\n' '[]' ;;
39
- activity) printf '%s\n' '[]' ;;
40
- *) printf 'keyprobe-stub: unknown block %s\n' "$block" >&2; exit 2 ;;
41
- esac