teamsmith 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +67 -0
  4. package/skills/teamsmith/SKILL.md +26 -8
  5. package/skills/teamsmith/extension/team-notify.ts +37 -6
  6. package/skills/teamsmith/extension/team.ts +438 -0
  7. package/skills/teamsmith/references/agent-adapters.md +7 -7
  8. package/skills/teamsmith/references/config.md +65 -18
  9. package/skills/teamsmith/references/migration.md +220 -34
  10. package/skills/teamsmith/references/protocol.md +250 -25
  11. package/skills/teamsmith/references/troubleshooting.md +124 -7
  12. package/skills/teamsmith/references/workflows.md +66 -20
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
  16. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  17. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  18. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  19. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  20. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  21. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  22. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  23. package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
  24. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  25. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  26. package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
  27. package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
  28. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  29. package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
  30. package/skills/teamsmith/scripts/lib/common.sh +1560 -109
  31. package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
  32. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  33. package/skills/teamsmith/scripts/panel/README.md +22 -11
  34. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  35. package/skills/teamsmith/scripts/panel/panel.js +226 -224
  36. package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
  37. package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
  38. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  39. package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
  40. package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
  41. package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
  42. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  43. package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
  44. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
  45. package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
  46. package/skills/teamsmith/scripts/replies.mjs +896 -0
  47. package/skills/teamsmith/scripts/shim/tmux +18 -0
  48. package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
  49. package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
  50. package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
  51. package/skills/teamsmith/scripts/team +20 -6
  52. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
  53. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  54. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  55. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  56. package/skills/teamsmith/templates/config.sh.tmpl +29 -5
  57. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  58. package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
  59. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  60. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  61. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  62. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  63. package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
  64. package/skills/teamsmith/tests/config-cli.sh +320 -300
  65. package/skills/teamsmith/tests/death-cause.sh +5 -2
  66. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  67. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  68. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  69. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  70. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  71. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  72. package/skills/teamsmith/tests/flip-m37.sh +4 -1
  73. package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
  74. package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
  75. package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
  76. package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
  77. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  78. package/skills/teamsmith/tests/flip-p210.sh +4 -1
  79. package/skills/teamsmith/tests/flip-p217.sh +4 -1
  80. package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
  81. package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
  82. package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
  83. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  84. package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
  85. package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
  86. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  87. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  88. package/skills/teamsmith/tests/install-shape.sh +283 -22
  89. package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
  90. package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
  91. package/skills/teamsmith/tests/key-replies.sh +1314 -0
  92. package/skills/teamsmith/tests/ledger-ban.sh +9 -8
  93. package/skills/teamsmith/tests/ledger-claim.sh +248 -0
  94. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  95. package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
  96. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  97. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  98. package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
  99. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  100. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  101. package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
  102. package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
  103. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  104. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  105. package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
  106. package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
  107. package/skills/teamsmith/tests/panel-b2.sh +107 -4
  108. package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
  109. package/skills/teamsmith/tests/panel-b3.sh +189 -29
  110. package/skills/teamsmith/tests/panel-choices.sh +81 -63
  111. package/skills/teamsmith/tests/panel-cpu.sh +3 -2
  112. package/skills/teamsmith/tests/panel-knobs.sh +7 -1
  113. package/skills/teamsmith/tests/panel-p21.sh +445 -241
  114. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  115. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  116. package/skills/teamsmith/tests/perf.sh +122 -31
  117. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  118. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  119. package/skills/teamsmith/tests/routes.sh +364 -109
  120. package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
  121. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  122. package/skills/teamsmith/tests/section-budgets.tsv +26 -12
  123. package/skills/teamsmith/tests/section-guard.sh +6 -1
  124. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  125. package/skills/teamsmith/tests/section-paths.tsv +42 -26
  126. package/skills/teamsmith/tests/section-select.sh +90 -7
  127. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  128. package/skills/teamsmith/tests/slash-team.sh +617 -0
  129. package/skills/teamsmith/tests/smoke.sh +3762 -628
  130. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  131. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  132. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  133. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  134. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  135. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  136. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  137. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  138. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  139. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  140. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  141. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  142. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  143. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  144. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  145. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  146. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  147. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  148. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  149. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  150. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  151. package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
  152. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  153. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  154. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  155. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  156. package/skills/teamsmith-init/SKILL.md +43 -43
  157. package/skills/teamsmith-init/references/bootstrap.md +8 -6
  158. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -0,0 +1,374 @@
1
+ #!/usr/bin/env bash
2
+ # P234 · 关键回复的**真 pty/tmux** 面板夹具(change: pulse-key-replies · apply · tasks.md 3.1–3.3)
3
+ #
4
+ # bash skills/teamsmith/tests/key-replies-pty.sh [--select pages,overview,list,body,mouse,resize,language,async,compose] [--all]
5
+ #
6
+ # 组:
7
+ # pages 第 5 页真实列表帧 / 页签与 panel-page 记忆 / 重启仍可读 / 坏 store 可见不可用不阻断
8
+ # overview 总览的最新回复入口:`5` 键与鼠标目标到第 5 页最新列表,摘要行可点开同一正文视窗
9
+ # list 多页 store:Older 走到 #1 并读出全文,返回保持页/焦点/视口,Newer/r 回到最新
10
+ # body 128KiB 级长正文:End/PgUp/PgDn 滚到最后一行、q 返回列表不收起、坏正文同样有返回路
11
+ # mouse 真实 SGR 鼠标(python pty + tmux 客户端):首点聚焦、再点打开、返回、滚轮
12
+ # resize 窗格 resize 后列表上下文与页签仍在,正文视口被夹回新范围
13
+ # language zh/en 切换后第 5 页的标签/路由仍完整(含 59 列)
14
+ # async 需求读与慢读者:停在总览只有 summary、进页才有 list、开正文才有 body、返回/离开即停;
15
+ # 慢 list 不冻结按键与时钟,晚到的旧响应不会替换当前选择
16
+ # compose 第 5 页上 `m` 仍是人→PM 草稿,不发布、不写 store
17
+ #
18
+ # 数据是真的(真 `team reply post` 写进夹具仓库、真 bundle、真 CLI 包一层记录 argv 的 shim),
19
+ # 失败注入是真损坏(打坏槽位)。私有 tmux + 隔离前置见 lib/tmux-iso.sh;共享机器见 lib/reply-fixture.sh。
20
+ set -uo pipefail
21
+ KR_TAG="pty"
22
+ # shellcheck source=tests/lib/reply-fixture.sh
23
+ . "$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/reply-fixture.sh"
24
+
25
+ PTY_GROUPS=(pages overview list body mouse resize language async compose)
26
+ KR_SEL=(); ALL=0
27
+ while [ $# -gt 0 ]; do
28
+ case "$1" in
29
+ --select) shift; [ $# -gt 0 ] || { printf 'key-replies-pty: --select 需要组名\n' >&2; exit 2; }
30
+ IFS=',' read -r -a _g <<<"$1"; KR_SEL+=("${_g[@]}"); shift ;;
31
+ --select=*) IFS=',' read -r -a _g <<<"${1#*=}"; KR_SEL+=("${_g[@]}"); shift ;;
32
+ --all) ALL=1; shift ;;
33
+ -h|--help) sed -n '2,22p' "$0"; exit 0 ;;
34
+ *) printf 'key-replies-pty.sh:未知参数 %s\n' "$1" >&2; exit 2 ;;
35
+ esac
36
+ done
37
+ if [ "$ALL" = "1" ] || [ "${#KR_SEL[@]}" -eq 0 ]; then KR_SEL=("${PTY_GROUPS[@]}"); fi
38
+ for g in "${KR_SEL[@]}"; do
39
+ hit=0; for k in "${PTY_GROUPS[@]}"; do [ "$g" = "$k" ] && hit=1; done
40
+ [ "$hit" = "1" ] || { printf 'key-replies-pty.sh:未知组 [%s](可选:%s)\n' "$g" "${PTY_GROUPS[*]}" >&2; exit 2; }
41
+ done
42
+ trap reply_fixture_cleanup EXIT
43
+
44
+ # 直驱 pty 的原始 dump → 可见文本(剥掉 OSC/CSI;Ink 只重绘变更行,所以这是「变更内容」而不是整屏)
45
+ kr_chunk_text() { # <dump>
46
+ python3 - "$1" <<'PYF'
47
+ import re, sys
48
+ raw = open(sys.argv[1], 'rb').read().decode('utf-8', 'replace')
49
+ clean = re.sub(r'\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)', '', raw)
50
+ clean = re.sub(r'\x1b\[[0-9;?]*[a-zA-Z]', '', clean)
51
+ sys.stdout.write(clean)
52
+ PYF
53
+ }
54
+
55
+ # ---------------------------------------------------------------- 组:pages
56
+ kr_group_pages() {
57
+ section "pages · 第 5 页 / 重启 / 坏 store(3.1)"
58
+ local b1="$tmp/p1.md" b2="$tmp/p2.md"
59
+ printf '第一份回复:结论与取舍\n\n- 要点一\n' >"$b1"
60
+ printf '第二份回复\n' >"$b2"
61
+ fixture_up pages "dev2|完整结论与取舍|$b1" "verify|第二份回复|$b2"
62
+ start_panel || { bad "pages:面板起不来"; return 1; }
63
+ keys "5"; sleep 0.6
64
+ want_frame list5 "pages:第 5 页列表帧(编号/标题/发布者标签)" "#2 第二份回复" "#1 完整结论与取舍" "关键回复"
65
+ assert_has "$tmp/$current/list5.txt" "「这条回复是写给谁的?」" "pages:第 5 页说明行带着判据的自测题(删整行或只删自测题都会红)"
66
+ assert_has "$tmp/$current/list5.txt" "个编号槽位" "pages:列表带编号槽位计数"
67
+ assert_has "$tmp/$current/list5.txt" "更早" "pages:Older 控件可见"
68
+ ev_save "$tmp/$current/list5.txt" "pty-pages-list5.txt"
69
+ # 原 1–4 页不动 + Tab 回绕:5 → 1
70
+ keys "1"; sleep 0.5
71
+ want_frame ov "pages:按 1 回总览(原页面语义不变)" "最新关键回复"
72
+ keys Tab; sleep 0.5
73
+ want_frame p2 "pages:Tab 从总览到第 2 页(数字键顺序不变)" "工作"
74
+ keys "5"; sleep 0.5
75
+ keys Tab; sleep 0.5
76
+ want_frame wrap "pages:Tab 从第 5 页回绕到第 1 页" "最新关键回复"
77
+ # 重启后仍可读(panel-page 记的是 5)
78
+ keys "5"; sleep 0.4
79
+ start_panel || bad "pages:重启失败"
80
+ want_frame restart "pages:重启后仍在第 5 页且回复可读" "#2 第二份回复" "#1 完整结论与取舍"
81
+ assert_eq "pages:panel-page 记的是 5" "$(tr -d '\n' <"$(page_file)")" "5"
82
+ # 坏 store:不可用可见、页面可用、能回总览、窗格不死
83
+ keys "1"; sleep 0.4
84
+ local size; size="$(stat -c %s "$state/key-replies/index.v1")"
85
+ printf 'ZZZZ' | dd of="$state/key-replies/index.v1" bs=1 seek=$((size - 200)) conv=notrunc status=none
86
+ keys "5"; sleep 0.4; keys "r"; sleep 0.6
87
+ want_frame corrupt "pages:坏槽位显示为不可用行" "不可用" "更早"
88
+ keys "1"; sleep 0.6
89
+ want_frame corrupt_back "pages:坏 store 后仍能回总览(不阻断)" "teamsmith pulse"
90
+ assert_eq "pages:坏 store 期间窗格没死" "$(pty_pane_state | cut -d: -f1)" "0"
91
+ ev_save "$tmp/$current/corrupt.txt" "pty-pages-corrupt.txt"
92
+ }
93
+
94
+ # ---------------------------------------------------------------- 组:overview
95
+ kr_group_overview() {
96
+ section "overview · 总览入口(3.1)"
97
+ local b1="$tmp/o1.md"; printf '总览入口回复\n第二行\n' >"$b1"
98
+ fixture_up overview "dev2|总览入口标题|$b1"
99
+ # 目标表:总览上有到第 5 页的键提示 + 摘要行的打开目标
100
+ "${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$team_cli" --snapshot --page 1 \
101
+ --width 120 --height 28 --lang zh --targets >"$tmp/ov-targets.json" 2>/dev/null
102
+ local kinds; kinds="$(python3 - "$tmp/ov-targets.json" <<'PYT'
103
+ import json, sys
104
+ try:
105
+ data = json.load(open(sys.argv[1]))
106
+ except Exception as e:
107
+ print(f"<unreadable: {e}>")
108
+ else:
109
+ print(",".join(sorted({t["action"]["kind"] for t in data})))
110
+ PYT
111
+ )"
112
+ case "$kinds" in *reply-open-latest*) ok "overview:总览摘要行带打开最新回复的鼠标目标(kinds=$kinds)" ;; *) bad "overview:总览没有 reply-open-latest 目标(kinds=$kinds)" ;; esac
113
+ case "$kinds" in *page*) ok "overview:总览带页面目标(含第 5 页)" ;; *) bad "overview:总览没有页面目标(kinds=$kinds)" ;; esac
114
+ "${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$team_cli" --snapshot --page 1 \
115
+ --width 120 --height 28 --lang zh 2>/dev/null | sed -e 's/\x1b\[[0-9;]*m//g' >"$tmp/ov-snap.txt"
116
+ assert_has "$tmp/ov-snap.txt" "#1 总览入口标题" "overview:总览摘要行显示最新编号与标题"
117
+ assert_has "$tmp/ov-snap.txt" "dev2" "overview:总览摘要行显示发布者标签"
118
+ start_panel || { bad "overview:面板起不来"; return 1; }
119
+ want_frame ov_pane "overview:面板总览上的摘要行" "#1 总览入口标题" "最新关键回复"
120
+ keys "5"; sleep 0.6
121
+ want_frame ov_page5 "overview:按 5 到第 5 页最新列表" "#1 总览入口标题" "个编号槽位"
122
+ keys Enter; sleep 0.6
123
+ want_frame ov_body "overview:列表上 Enter 用同一正文视窗打开" "总览入口回复" "只读 · 按发布的原文显示"
124
+ ev_save "$tmp/$current/ov_pane.txt" "pty-overview-summary.txt"
125
+ }
126
+
127
+ # ---------------------------------------------------------------- 组:list
128
+ kr_group_list() {
129
+ section "list · 多页 cursor 与返回上下文(3.1)"
130
+ local b="$tmp/l.md"; printf '批量回复正文\n' >"$b"
131
+ fixture_up list "dev2|第 1 号|$b"
132
+ local i
133
+ for i in $(seq 2 60); do kr_cli "$ROOT" reply post --from dev2 --title "第 $i 号" --stdin <"$b" >/dev/null; done
134
+ start_panel || { bad "list:面板起不来"; return 1; }
135
+ keys "5"; sleep 0.6
136
+ want_frame page1 "list:第 1 页(最新)" "#60 第 60 号" "个编号槽位"
137
+ keys Left; sleep 1.2
138
+ want_frame page2 "list:Older 拿到更旧的一页(50 个槽位一页,最旧页只剩 10 条)" "#10 第 10 号" "#1 第 1 号"
139
+ keys Left; sleep 1.0
140
+ want_frame page3 "list:再 Older 已在最旧页(不前进、不空帧)" "#10 第 10 号" "#1 第 1 号"
141
+ # 焦点用文档里给的 ↓ 走到底(切换页后焦点落在本页第一行 #10;多按 3 次证明末端被夹住),
142
+ # 同时证明「窗口跟随焦点」——最旧的 #1 在 50 行页里不是一屏内能看到的
143
+ local k
144
+ for k in $(seq 1 12); do keys Down; sleep 0.12; done
145
+ sleep 0.4
146
+ want_frame focus_last "list:连续 ↓ 把焦点移到最旧的 #1(末端夹住,光标在 #1 行)" "› #1 第 1 号"
147
+ keys Enter; sleep 0.8
148
+ want_frame first_body "list:打开最旧的 #1,全文可读" "#1 关键回复" "批量回复正文" "只读 · 按发布的原文显示"
149
+ keys "q"; sleep 0.6
150
+ want_frame back_ctx "list:q 返回列表且仍是同一页与同一焦点" "› #1 第 1 号"
151
+ keys Right; sleep 1.2
152
+ want_frame newer "list:Newer 回到上一页(最新页顶行 #60)" "#60 第 60 号"
153
+ keys "r"; sleep 1.2
154
+ want_frame newest "list:r 回到最新页" "#60 第 60 号" "个编号槽位"
155
+ ev_save "$tmp/$current/page3.txt" "pty-list-oldest.txt"
156
+ }
157
+
158
+ # ---------------------------------------------------------------- 组:body
159
+ kr_group_body() {
160
+ section "body · 长正文滚动与返回(3.2)"
161
+ local long="$tmp/b-long.md"
162
+ { local i; for i in $(seq 1 400); do printf '正文行 %s\n' "$i"; done; printf 'END-MARKER-P234\n'; } >"$long"
163
+ fixture_up body "dev2|长正文|$long"
164
+ start_panel || { bad "body:面板起不来"; return 1; }
165
+ keys "5"; sleep 0.6; keys Enter; sleep 0.8
166
+ want_frame top "body:视窗打开在文首" "长正文" "来自 dev2"
167
+ assert_not "$tmp/$current/top.txt" "END-MARKER-P234" "body:打开时不在结尾(长文不是一次铺满)"
168
+ keys End; sleep 0.6
169
+ want_frame end "body:End 到结尾,END-MARKER 可见" "END-MARKER-P234"
170
+ keys PageUp; sleep 0.6
171
+ want_frame pgup "body:PgUp 向上(结尾标记离开视窗)" "!END-MARKER-P234"
172
+ keys PageDown; sleep 0.6
173
+ want_frame pgdn "body:PgDn 回到结尾" "END-MARKER-P234"
174
+ keys "q"; sleep 0.6
175
+ want_frame ret "body:q 回列表(不是收起控制台)" "个编号槽位"
176
+ assert_eq "body:q 后窗格仍然活着" "$(pty_pane_state | cut -d: -f1)" "0"
177
+ # 坏正文:本地不可用提示 + 同样的返回路
178
+ local KR="$state/key-replies" body_id
179
+ body_id="$(python3 - "$KR/index.v1" <<'PYB'
180
+ import json, sys
181
+ with open(sys.argv[1], 'rb') as f:
182
+ head = f.read(4064)
183
+ n = int.from_bytes(head[:4], 'big')
184
+ print(json.loads(head[4:4+n].decode('utf-8'))['body_id'])
185
+ PYB
186
+ )"
187
+ rm -f "$KR/bodies/$body_id.md"
188
+ # 重启面板清掉块缓存:正文文件已经不在,读它必须报不可用(而不是拿旧缓存冒充可读)
189
+ start_panel || bad "body:坏正文场景重启失败"
190
+ keys "5"; sleep 0.6; keys Enter; sleep 0.8
191
+ want_frame bad "body:坏正文给出不可用提示" "不可用"
192
+ assert_has "$tmp/$current/bad.txt" "返回" "body:坏正文同样有返回路"
193
+ keys "q"; sleep 0.6
194
+ want_frame bad_back "body:坏正文返回后列表仍在" "个编号槽位"
195
+ ev_save "$tmp/$current/end.txt" "pty-body-end.txt"
196
+ }
197
+
198
+ # ---------------------------------------------------------------- 组:mouse
199
+ kr_group_mouse() {
200
+ section "mouse · 真实 SGR 鼠标(3.2)"
201
+ local b="$tmp/m.md"; printf '鼠标夹具正文\n' >"$b"
202
+ fixture_up mouse "dev2|鼠标一号|$b" "verify|鼠标二号|$b"
203
+ local i
204
+ for i in $(seq 3 38); do kr_cli "$ROOT" reply post --from dev2 --title "鼠标 $i 号" --stdin <"$b" >/dev/null; done
205
+ printf 'lang=zh\nmouse=1\n' >"$state/panel.conf"
206
+ start_panel || { bad "mouse:面板起不来"; return 1; }
207
+ keys "5"; sleep 0.6
208
+ want_frame m_list "mouse:列表就绪(38 条,窗口跟随新页第一行)" "#38 鼠标 38 号"
209
+ # 首点聚焦:驱动器自己从 capture 里找目标行,SGR 坐标是(列, 行)
210
+ python3 "$SELF_DIR/panel-b3-pty-tmux-mouse.py" --sock "$sock" --session "$sess" --pane "$sess:panel" \
211
+ --hint "#38 鼠标 38 号" --out "$tmp/m-focus.bin" >"$tmp/m-focus.log" 2>&1
212
+ local rc=$?
213
+ if [ "$rc" = "0" ]; then ok "mouse:首点注入成功($(cat "$tmp/m-focus.log" | tr -d '\n'))"; else bad "mouse:首点注入失败(rc=$rc:$(tail -2 "$tmp/m-focus.log" | tr '\n' ' '))"; fi
214
+ want_frame m_focus "mouse:首点把焦点移到被点的行(光标在 #38)" "› #38 鼠标 38 号"
215
+ # 再点同一行 → 打开正文
216
+ python3 "$SELF_DIR/panel-b3-pty-tmux-mouse.py" --sock "$sock" --session "$sess" --pane "$sess:panel" \
217
+ --hint "#38 鼠标 38 号" --out "$tmp/m-open.bin" >"$tmp/m-open.log" 2>&1
218
+ rc=$?
219
+ if [ "$rc" = "0" ]; then ok "mouse:第二点注入成功"; else bad "mouse:第二点注入失败(rc=$rc)"; fi
220
+ want_frame m_open "mouse:再点同一行打开该号正文(第二次点击才是打开)" "鼠标夹具正文" "只读 · 按发布的原文显示" "#38 关键回复"
221
+ # Back 芯片:单击返回
222
+ python3 "$SELF_DIR/panel-b3-pty-tmux-mouse.py" --sock "$sock" --session "$sess" --pane "$sess:panel" \
223
+ --hint "返回" --out "$tmp/m-back.bin" >"$tmp/m-back.log" 2>&1
224
+ rc=$?
225
+ if [ "$rc" = "0" ]; then ok "mouse:Back 芯片点击注入成功"; else bad "mouse:Back 点击失败(rc=$rc:$(tail -2 "$tmp/m-back.log" | tr '\n' ' '))"; fi
226
+ want_frame m_back "mouse:Back 回到列表(同一页与焦点)" "› #38 鼠标 38 号"
227
+ # 滚轮:tmux 会吃掉滚轮事件(既有测量),所以滚轮走直驱 pty。两条独立运行各证一件事:
228
+ # ① 3 格下滚 → 变更块里的最大编号小于最新号(顶部确实让位给更旧的行)
229
+ # ② 滚 40 格 → 到底被夹住:最旧的 #1 进入窗口、最新号不再重绘(越界不换页、不空帧)
230
+ python3 "$SELF_DIR/panel-b3-pty-mouse.py" --js "$js" --panel "$panel" --root "$ROOT" --state-dir "$state" \
231
+ --team-cli "$team_cli" --out "$tmp/m-wheel.bin" --out2 "$tmp/m-wheel-after.bin" --no-click \
232
+ --send "5" --wheel down --wheel-clicks 3 --expect-enable yes >"$tmp/m-wheel.log" 2>&1
233
+ local rc=$?
234
+ if [ "$rc" = "0" ]; then ok "mouse:直驱 pty 滚轮注入成功"; else bad "mouse:滚轮注入失败(rc=$rc:$(tail -2 "$tmp/m-wheel.log" | tr '\n' ' '))"; fi
235
+ kr_chunk_text "$tmp/m-wheel-after.bin" >"$tmp/m-wheel-chunk.txt"
236
+ assert_not "$tmp/m-wheel-chunk.txt" "#38 鼠标 38 号" "mouse:下滚 3 格后最新行不再重绘(顶部让位)"
237
+ local chunk_max
238
+ chunk_max="$(grep -oE '#[0-9]+ ' "$tmp/m-wheel-chunk.txt" | tr -dc '0-9\n' | sort -n | tail -1)"
239
+ if [ -n "$chunk_max" ] && [ "$chunk_max" -lt 38 ]; then
240
+ ok "mouse:下滚 3 格后变更块里的最大编号是 #$chunk_max(< 最新号 38)"
241
+ else
242
+ bad "mouse:下滚 3 格后变更块里没有更旧的行(最大 #${chunk_max:-?})"
243
+ fi
244
+ python3 "$SELF_DIR/panel-b3-pty-mouse.py" --js "$js" --panel "$panel" --root "$ROOT" --state-dir "$state" \
245
+ --team-cli "$team_cli" --out "$tmp/m-end.bin" --out2 "$tmp/m-end-after.bin" --no-click \
246
+ --send "5" --wheel down --wheel-clicks 40 >"$tmp/m-end.log" 2>&1
247
+ kr_chunk_text "$tmp/m-end-after.bin" >"$tmp/m-end-chunk.txt"
248
+ assert_has "$tmp/m-end-chunk.txt" "#1 鼠标一号" "mouse:滚 40 格到底被夹住(最旧的 #1 进入窗口,不换页)"
249
+ assert_not "$tmp/m-end-chunk.txt" "#38 鼠标 38 号" "mouse:到底后最新号不再在窗口里"
250
+ assert_eq "mouse:滚轮之后 tmux 里那块面板仍活着" "$(pty_pane_state | cut -d: -f1)" "0"
251
+ ev_save "$tmp/$current/m_open.txt" "pty-mouse-open.txt"
252
+ }
253
+
254
+ # ---------------------------------------------------------------- 组:resize
255
+ kr_group_resize() {
256
+ section "resize · 窗格尺寸变化(3.4)"
257
+ local b="$tmp/r.md"; printf '缩放夹具正文\n' >"$b"
258
+ fixture_up resize "dev2|缩放一号|$b"
259
+ start_panel || { bad "resize:面板起不来"; return 1; }
260
+ keys "5"; sleep 0.6
261
+ want_frame before "resize:59 列前先就绪" "#1 缩放一号"
262
+ tmux -L "$sock" resize-window -t "$sess:panel" -x 59 -y 24 2>/dev/null || tmux -L "$sock" resize-pane -t "$sess:panel" -x 59 -y 24 2>/dev/null || true
263
+ sleep 0.8
264
+ want_frame narrow "resize:59 列下页签身份与 Older 仍在" "关键回复" "更早"
265
+ tmux -L "$sock" resize-window -t "$sess:panel" -x 140 -y 34 2>/dev/null || true
266
+ sleep 0.8
267
+ want_frame wide "resize:放大后在仍在第 5 页且列表可用" "#1 缩放一号" "个编号槽位"
268
+ keys Enter; sleep 0.6
269
+ tmux -L "$sock" resize-window -t "$sess:panel" -x 61 -y 18 2>/dev/null || true
270
+ sleep 0.8
271
+ want_frame vres "resize:正文视窗在窄窗里仍可读且可返回" "缩放夹具正文" "返回"
272
+ assert_eq "resize:resize 后窗格没死" "$(pty_pane_state | cut -d: -f1)" "0"
273
+ ev_save "$tmp/$current/vres.txt" "pty-resize-viewer.txt"
274
+ }
275
+
276
+ # ---------------------------------------------------------------- 组:language
277
+ kr_group_language() {
278
+ section "language · zh/en 切换(3.4)"
279
+ local b="$tmp/g.md"; printf '语言夹具正文\n' >"$b"
280
+ fixture_up language "dev2|语言一号|$b"
281
+ printf 'lang=en\n' >"$state/panel.conf"
282
+ start_panel || { bad "language:面板起不来"; return 1; }
283
+ keys "5"; sleep 0.6
284
+ want_frame en "language:en 表下第 5 页标签与路由完整(含说明行的自测题)" "key replies" "Older" "Older" '"who is this reply written for?"'
285
+ printf 'lang=zh\n' >"$state/panel.conf"
286
+ start_panel || bad "language:重启失败"
287
+ keys "5"; sleep 0.6
288
+ want_frame zh "language:zh 表下第 5 页标签与路由完整" "关键回复" "更早"
289
+ ev_save "$tmp/$current/en.txt" "pty-language-en.txt"
290
+ }
291
+
292
+ # ---------------------------------------------------------------- 组:async
293
+ kr_group_async() {
294
+ section "async · 需求读 / 慢读者 / 晚响应(3.3)"
295
+ local b1="$tmp/a1.md" b2="$tmp/a2.md"
296
+ printf '异步一号\n' >"$b1"; printf '异步二号\n' >"$b2"
297
+ fixture_up async "dev2|异步一号|$b1" "dev2|异步二号|$b2"
298
+ start_panel || { bad "async:面板起不来"; return 1; }
299
+ # ① 停在总览:只有 summary
300
+ sleep 1.5
301
+ want_frame ov "async:总览摘要渲染" "最新关键回复"
302
+ assert_eq "async:停在总览时 list 调用为 0" "$(block_calls reply_list)" "0"
303
+ assert_eq "async:停在总览时 body 调用为 0" "$(block_calls reply_body)" "0"
304
+ if [ "$(block_calls reply_summary)" -ge 1 ]; then ok "async:停在总览就调度 reply_summary"; else bad "async:总览没有调度 reply_summary"; fi
305
+ # ② 进第 5 页 → 多一个 list,无 body
306
+ reset_argv
307
+ keys "5"; sleep 1.2
308
+ want_frame list "async:第 5 页列表到达" "个编号槽位"
309
+ assert_eq "async:进第 5 页后 body 仍为 0" "$(block_calls reply_body)" "0"
310
+ assert_match "$(kr_argv)" 'reply_list' "async:list 调用进 argv 日志"
311
+ # ③ 打开正文 → 一个带编号的 body 调用
312
+ reset_argv
313
+ keys Enter; sleep 1.2
314
+ want_frame body "async:正文视窗渲染" "只读 · 按发布的原文显示"
315
+ assert_match "$(kr_argv)" 'reply_body.*--no [0-9]+' "async:body 调用带要读的编号"
316
+ # ④ 返回 → 不再请求 body;离开第 5 页 → list/body 都不再请求
317
+ reset_argv
318
+ keys "q"; sleep 1.0
319
+ assert_eq "async:返回列表后 body 不再被请求" "$(block_calls reply_body)" "0"
320
+ reset_argv
321
+ keys "1"; sleep 1.5
322
+ assert_eq "async:离开第 5 页后 list 不再被请求" "$(block_calls reply_list)" "0"
323
+ assert_eq "async:离开第 5 页后 body 不再被请求" "$(block_calls reply_body)" "0"
324
+ # ⑤ 慢读者:list 子进程睡 6s;期间按键/时钟仍活,晚到的旧响应不替换当前选择
325
+ kr_shim_set_slow reply_list 6
326
+ tmux -L "$sock" kill-window -t "$sess:panel" 2>/dev/null || true
327
+ start_panel || bad "async:慢读者场景面板起不来"
328
+ keys "5"; sleep 0.5
329
+ keys "1"; sleep 0.5
330
+ want_frame slow_ov "async:慢 list 未到时按键仍生效(已回总览)" "teamsmith pulse"
331
+ sleep 7.0
332
+ want_frame slow_late "async:晚到的 list 响应没有把页面换回第 5 页" "最新关键回复"
333
+ assert_eq "async:慢读者场景结束仍停在总览(page 文件)" "$(tr -d '\n' <"$(page_file)")" "1"
334
+ # 时钟没有冻结:两次 capture 的时钟不同(或至少都带时分秒形状)
335
+ local t1 t2
336
+ t1="$(cap | grep -oE '[0-9]{2}:[0-9]{2}:[0-9]{2}' | head -1)"
337
+ sleep 1.2
338
+ t2="$(cap | grep -oE '[0-9]{2}:[0-9]{2}:[0-9]{2}' | head -1)"
339
+ if [ -n "$t1" ] && [ -n "$t2" ] && [ "$t1" != "$t2" ]; then ok "async:慢读期间时钟继续走($t1 → $t2)"; else bad "async:时钟没有前进($t1 → $t2)"; fi
340
+ kr_shim_set_slow -
341
+ ev_save "$(kr_argv)" "pty-async-argv.log"
342
+ }
343
+
344
+ # ---------------------------------------------------------------- 组:compose
345
+ kr_group_compose() {
346
+ section "compose · 第 5 页仍是人→PM 通道(3.1)"
347
+ local b="$tmp/c1.md"; printf '写信夹具正文\n' >"$b"
348
+ fixture_up compose "dev2|写信一号|$b"
349
+ start_panel || { bad "compose:面板起不来"; return 1; }
350
+ keys "5"; sleep 0.6
351
+ local before_store
352
+ before_store="$(find "$state/key-replies" -printf '%p %s %T@\n' | sort | sha256sum | cut -d' ' -f1)"
353
+ keys "m"; sleep 0.6
354
+ want_frame draft "compose:第 5 页上 m 打开写信面板" "写信"
355
+ assert_has "$tmp/$current/draft.txt" "Esc" "compose:写信面板带取消提示"
356
+ keys Escape; sleep 0.5
357
+ want_frame after "compose:Esc 回到第 5 页列表" "个编号槽位"
358
+ local after_store
359
+ after_store="$(find "$state/key-replies" -printf '%p %s %T@\n' | sort | sha256sum | cut -d' ' -f1)"
360
+ assert_eq "compose:写信不写 key-replies store(前后哈希一致)" "$after_store" "$before_store"
361
+ assert_eq "compose:写信后没有新增编号" "$(kr_cli "$ROOT" reply list --json | python3 -c 'import json,sys; print(json.load(sys.stdin)["total_slots"])')" "1"
362
+ ev_save "$tmp/$current/draft.txt" "pty-compose-draft.txt"
363
+ }
364
+
365
+ # ---------------------------------------------------------------- 驱动
366
+ for g in "${KR_SEL[@]}"; do
367
+ GROUP_PASS=0; GROUP_FAIL=0
368
+ "kr_group_${g}"
369
+ if [ $((GROUP_PASS + GROUP_FAIL)) -eq 0 ]; then bad "${g}:零断言"; fi
370
+ done
371
+ kr_real_guard
372
+ printf '\n== P234 key-replies-pty 结果 == ✓%s ✗%s SKIP%s\n' "$PASS" "$FAIL" "$SKIP"
373
+ [ "$FAIL" -eq 0 ] || exit 1
374
+ exit 0