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.
- package/README.md +13 -7
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +67 -0
- package/skills/teamsmith/SKILL.md +26 -8
- package/skills/teamsmith/extension/team-notify.ts +37 -6
- package/skills/teamsmith/extension/team.ts +438 -0
- package/skills/teamsmith/references/agent-adapters.md +7 -7
- package/skills/teamsmith/references/config.md +65 -18
- package/skills/teamsmith/references/migration.md +220 -34
- package/skills/teamsmith/references/protocol.md +250 -25
- package/skills/teamsmith/references/troubleshooting.md +124 -7
- package/skills/teamsmith/references/workflows.md +66 -20
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
- package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
- package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
- package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
- package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
- package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
- package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
- package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
- package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
- package/skills/teamsmith/scripts/lib/common.sh +1560 -109
- package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
- package/skills/teamsmith/scripts/monitor.mjs +34 -3
- package/skills/teamsmith/scripts/panel/README.md +22 -11
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +226 -224
- package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
- package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
- package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
- package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
- package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
- package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
- package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
- package/skills/teamsmith/scripts/replies.mjs +896 -0
- package/skills/teamsmith/scripts/shim/tmux +18 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
- package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
- package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
- package/skills/teamsmith/scripts/team +20 -6
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
- package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
- package/skills/teamsmith/templates/config.sh.tmpl +29 -5
- package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
- package/skills/teamsmith/templates/report.md.tmpl +12 -0
- package/skills/teamsmith/templates/task.md.tmpl +4 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
- package/skills/teamsmith/tests/bg-ledger.sh +168 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
- package/skills/teamsmith/tests/config-cli.sh +320 -300
- package/skills/teamsmith/tests/death-cause.sh +5 -2
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
- package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
- package/skills/teamsmith/tests/flip-m33.sh +5 -3
- package/skills/teamsmith/tests/flip-m37.sh +4 -1
- package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
- package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
- package/skills/teamsmith/tests/flip-p158.sh +2 -1
- package/skills/teamsmith/tests/flip-p210.sh +4 -1
- package/skills/teamsmith/tests/flip-p217.sh +4 -1
- package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
- package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
- package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
- package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
- package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
- package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
- package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
- package/skills/teamsmith/tests/help-surface.sh +1664 -0
- package/skills/teamsmith/tests/install-shape.sh +283 -22
- package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
- package/skills/teamsmith/tests/key-replies.sh +1314 -0
- package/skills/teamsmith/tests/ledger-ban.sh +9 -8
- package/skills/teamsmith/tests/ledger-claim.sh +248 -0
- package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
- package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
- package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
- package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
- package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
- package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
- package/skills/teamsmith/tests/panel-b2.sh +107 -4
- package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
- package/skills/teamsmith/tests/panel-b3.sh +189 -29
- package/skills/teamsmith/tests/panel-choices.sh +81 -63
- package/skills/teamsmith/tests/panel-cpu.sh +3 -2
- package/skills/teamsmith/tests/panel-knobs.sh +7 -1
- package/skills/teamsmith/tests/panel-p21.sh +445 -241
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +122 -31
- package/skills/teamsmith/tests/pm-box-real.sh +1 -1
- package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
- package/skills/teamsmith/tests/routes.sh +364 -109
- package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
- package/skills/teamsmith/tests/seat-visibility.sh +675 -0
- package/skills/teamsmith/tests/section-budgets.tsv +26 -12
- package/skills/teamsmith/tests/section-guard.sh +6 -1
- package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
- package/skills/teamsmith/tests/section-paths.tsv +42 -26
- package/skills/teamsmith/tests/section-select.sh +90 -7
- package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
- package/skills/teamsmith/tests/slash-team.sh +617 -0
- package/skills/teamsmith/tests/smoke.sh +3762 -628
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
- package/skills/teamsmith/tests/task-header-model.sh +2 -1
- package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
- package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
- package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
- package/skills/teamsmith-init/SKILL.md +43 -43
- package/skills/teamsmith-init/references/bootstrap.md +8 -6
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# P234 · 关键回复的**读数面**夹具(change: pulse-key-replies · apply · tasks.md 3.3–3.4)
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/key-replies-ui.sh [--select blocks,machine,snapshots,routing-regression] [--all]
|
|
5
|
+
#
|
|
6
|
+
# 组:
|
|
7
|
+
# blocks 三个 console-only 块的装配契约(不需要 tmux):按需起子进程、超时被杀、输出泛滥被
|
|
8
|
+
# 截断、坏源只降级本块、以及「晚到的旧响应不 adopt」(数据层的请求代际)
|
|
9
|
+
# machine 机器出口:--print/--json 不调度任何 reply 块、发布前后逐字节不变(除时钟/时间戳)、
|
|
10
|
+
# 坏 store/别的偏好都不影响
|
|
11
|
+
# snapshots 4 宽 × 2 主题 × 2 语言 × 多状态(summary/empty/list/corrupt/continuation/长文)快照矩阵
|
|
12
|
+
# routing-regression 路由/设置面的既有前门(panel-p21 / panel-choices / panel-strings /
|
|
13
|
+
# panel-contrast)在本树上仍然全绿——第五页不许用删除旧断言换取
|
|
14
|
+
set -uo pipefail
|
|
15
|
+
KR_TAG="ui"
|
|
16
|
+
# shellcheck source=tests/lib/reply-fixture.sh
|
|
17
|
+
. "$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/reply-fixture.sh"
|
|
18
|
+
|
|
19
|
+
UI_GROUPS=(blocks machine snapshots routing-regression)
|
|
20
|
+
KR_SEL=(); ALL=0
|
|
21
|
+
while [ $# -gt 0 ]; do
|
|
22
|
+
case "$1" in
|
|
23
|
+
--select) shift; [ $# -gt 0 ] || { printf 'key-replies-ui: --select 需要组名\n' >&2; exit 2; }
|
|
24
|
+
IFS=',' read -r -a _g <<<"$1"; KR_SEL+=("${_g[@]}"); shift ;;
|
|
25
|
+
--select=*) IFS=',' read -r -a _g <<<"${1#*=}"; KR_SEL+=("${_g[@]}"); shift ;;
|
|
26
|
+
--all) ALL=1; shift ;;
|
|
27
|
+
-h|--help) sed -n '2,20p' "$0"; exit 0 ;;
|
|
28
|
+
*) printf 'key-replies-ui.sh:未知参数 %s\n' "$1" >&2; exit 2 ;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
31
|
+
if [ "$ALL" = "1" ] || [ "${#KR_SEL[@]}" -eq 0 ]; then KR_SEL=("${UI_GROUPS[@]}"); fi
|
|
32
|
+
for g in "${KR_SEL[@]}"; do
|
|
33
|
+
hit=0; for k in "${UI_GROUPS[@]}"; do [ "$g" = "$k" ] && hit=1; done
|
|
34
|
+
[ "$hit" = "1" ] || { printf 'key-replies-ui.sh:未知组 [%s](可选:%s)\n' "$g" "${UI_GROUPS[*]}" >&2; exit 2; }
|
|
35
|
+
done
|
|
36
|
+
trap reply_fixture_cleanup EXIT
|
|
37
|
+
|
|
38
|
+
# 面板的 CLI 走记录 argv 的 shim(真 CLI 前面一行日志):块的逐条调用可查,数据仍是真读数。
|
|
39
|
+
kr_panel_snapshot_raw() { # <页> <额外参数…> → 未剥 ANSI 的原始 stdout
|
|
40
|
+
local page="$1"; shift
|
|
41
|
+
"${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$(kr_shim)" --snapshot --page "$page" "$@" 2>/dev/null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
kr_panel_snapshot() { # <页> <额外参数…> → stdout
|
|
45
|
+
local page="$1"; shift
|
|
46
|
+
"${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$(kr_shim)" --snapshot --page "$page" "$@" 2>/dev/null \
|
|
47
|
+
| sed -e 's/\x1b\[[0-9;]*m//g'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# ---------------------------------------------------------------- 组:blocks
|
|
51
|
+
kr_group_blocks() {
|
|
52
|
+
section "blocks · 三个需求块的装配契约(3.3)"
|
|
53
|
+
local b="$tmp/bl.md"; printf '块夹具正文\n' >"$b"
|
|
54
|
+
fixture_up blocks "dev2|块夹具一号|$b" "verify|块夹具二号|$b"
|
|
55
|
+
# ① 总览一次装配:只有 summary(list/body 不在 wanted 集合里)
|
|
56
|
+
reset_argv
|
|
57
|
+
kr_panel_snapshot 1 --width 120 --height 28 --lang zh >"$tmp/bl-ov.txt"
|
|
58
|
+
assert_eq "blocks:--page 1 快照里 list 调用为 0" "$(block_calls reply_list)" "0"
|
|
59
|
+
assert_eq "blocks:--page 1 快照里 body 调用为 0" "$(block_calls reply_body)" "0"
|
|
60
|
+
# ② 第 5 页:list 恰好一次且带 newest 形态;body 仍为 0
|
|
61
|
+
reset_argv
|
|
62
|
+
kr_panel_snapshot 5 --width 120 --height 28 --lang zh >"$tmp/bl-list.txt"
|
|
63
|
+
assert_eq "blocks:--page 5 快照恰好一次 list 调用" "$(block_calls reply_list)" "1"
|
|
64
|
+
assert_eq "blocks:--page 5 快照仍无 body 调用" "$(block_calls reply_body)" "0"
|
|
65
|
+
assert_has "$tmp/bl-list.txt" "#2 块夹具二号" "blocks:列表渲染两条"
|
|
66
|
+
# ③ cursor 形态:--reply-before 把游标带进 argv,且编号一致
|
|
67
|
+
reset_argv
|
|
68
|
+
kr_panel_snapshot 5 --reply-before 2 --width 120 --height 28 --lang zh >"$tmp/bl-before.txt"
|
|
69
|
+
assert_match "$(kr_argv)" 'reply_list.*--before 2' "blocks:cursor 形态出现在 argv(--before 2)"
|
|
70
|
+
# ④ 视窗形态:--reply-no 带编号,且只读那一号
|
|
71
|
+
reset_argv
|
|
72
|
+
kr_panel_snapshot 5 --reply-no 1 --width 120 --height 28 --lang zh >"$tmp/bl-body.txt"
|
|
73
|
+
assert_match "$(kr_argv)" 'reply_body.*--no 1' "blocks:视窗形态出现在 argv(--no 1)"
|
|
74
|
+
assert_eq "blocks:打开视窗时不调度 list(视窗取代列表)" "$(block_calls reply_list)" "0"
|
|
75
|
+
assert_has "$tmp/bl-body.txt" "块夹具正文" "blocks:正文块渲染出原文"
|
|
76
|
+
# ⑤ 慢块:子进程超时被杀(timeoutMs 10s)→ 只降级本块,其余块照常
|
|
77
|
+
kr_shim_set_slow reply_list 30
|
|
78
|
+
reset_argv
|
|
79
|
+
local t0 t1
|
|
80
|
+
t0="$(date +%s)"
|
|
81
|
+
kr_panel_snapshot 5 --width 120 --height 28 --lang zh >"$tmp/bl-slow.txt"
|
|
82
|
+
t1="$(date +%s)"
|
|
83
|
+
if [ $((t1 - t0)) -le 20 ]; then ok "blocks:慢 list 在超时界内返回($((t1 - t0))s ≤ 20s)"; else bad "blocks:慢 list 拖过了超时界($((t1 - t0))s)"; fi
|
|
84
|
+
assert_has "$tmp/bl-slow.txt" "更早" "blocks:慢 list 只降级本块(页面的导航/其它内容仍在)"
|
|
85
|
+
kr_shim_set_slow -
|
|
86
|
+
# ⑥ 输出泛滥:块 stdout 超过上限 → 该块判失败而不是把巨量内容塞进帧
|
|
87
|
+
cat >"$tmp/$current/bin/flood-team" <<FLOOD
|
|
88
|
+
#!/usr/bin/env bash
|
|
89
|
+
for a in "\$@"; do if [ "\$a" = "reply_summary" ]; then python3 -c 'print("x"*20000000)'; exit 0; fi; done
|
|
90
|
+
exec bash "$team_cli" "\$@"
|
|
91
|
+
FLOOD
|
|
92
|
+
chmod +x "$tmp/$current/bin/flood-team"
|
|
93
|
+
"${clean_env[@]}" node "$panel" --root "$ROOT" \
|
|
94
|
+
--team-cli "$tmp/$current/bin/flood-team" --snapshot --page 1 --width 120 --height 24 --lang zh \
|
|
95
|
+
| sed -e 's/\x1b\[[0-9;]*m//g' >"$tmp/bl-flood.txt" 2>/dev/null
|
|
96
|
+
ev_save "$tmp/bl-flood.txt" "ui-blocks-flood.txt"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# ---------------------------------------------------------------- 组:machine
|
|
100
|
+
kr_group_machine() {
|
|
101
|
+
section "machine · 机器出口零 reply 读(3.3)"
|
|
102
|
+
local b="$tmp/mn.md"; printf '机器出口夹具正文\n' >"$b"
|
|
103
|
+
fixture_up machine
|
|
104
|
+
kr_cli "$ROOT" monitor --print 2>/dev/null | kr_mask_print >"$tmp/m-print-before.txt"
|
|
105
|
+
kr_cli "$ROOT" monitor --json 2>/dev/null | sed -E 's/"timestamp": *"[^"]*"/"timestamp": "T"/' >"$tmp/m-json-before.txt"
|
|
106
|
+
printf 'lang=en\ndefaultPage=5\nmouse=off\n' >"$state/panel.conf"
|
|
107
|
+
kr_cli "$ROOT" reply post --from dev2 --title '发布之后' --stdin <"$b" >/dev/null
|
|
108
|
+
kr_cli "$ROOT" monitor --print 2>/dev/null | kr_mask_print >"$tmp/m-print-after.txt"
|
|
109
|
+
kr_cli "$ROOT" monitor --json 2>/dev/null | sed -E 's/"timestamp": *"[^"]*"/"timestamp": "T"/' >"$tmp/m-json-after.txt"
|
|
110
|
+
if cmp -s "$tmp/m-print-before.txt" "$tmp/m-print-after.txt"; then ok "machine:发布前后 --print 逐字节一致(除时钟)"; else bad "machine:发布改变了 --print"; diff "$tmp/m-print-before.txt" "$tmp/m-print-after.txt" | head -5 >&2; fi
|
|
111
|
+
if cmp -s "$tmp/m-json-before.txt" "$tmp/m-json-after.txt"; then ok "machine:发布前后 --json 逐字节一致(除 timestamp)"; else bad "machine:发布改变了 --json"; fi
|
|
112
|
+
assert_not "$tmp/m-json-after.txt" "reply" "machine:--json 里没有 key-reply 字段"
|
|
113
|
+
reset_argv
|
|
114
|
+
kr_cli "$ROOT" monitor --print >/dev/null 2>&1
|
|
115
|
+
kr_cli "$ROOT" monitor --json >/dev/null 2>&1
|
|
116
|
+
assert_eq "machine:机器出口期间 reply 块调用为 0" "$(blocks_since | grep -c '^reply_' || true)" "0"
|
|
117
|
+
assert_eq "machine:机器出口的 argv 里根本没有 reply_ 字样" "$(grep -c 'reply_' "$(kr_argv)" 2>/dev/null || true)" "0"
|
|
118
|
+
rm -f "$state/key-replies/index.v1"
|
|
119
|
+
mkfifo "$state/key-replies/writer.lock" 2>/dev/null || true
|
|
120
|
+
kr_cli "$ROOT" monitor --print 2>/dev/null | kr_mask_print >"$tmp/m-print-broken.txt"
|
|
121
|
+
if cmp -s "$tmp/m-print-before.txt" "$tmp/m-print-broken.txt"; then ok "machine:store 坏掉/被 FIFO 之后 --print 仍逐字节一致"; else bad "machine:坏 store 改变了 --print"; fi
|
|
122
|
+
ev_save "$tmp/m-print-after.txt" "ui-machine-print.txt"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# ---------------------------------------------------------------- 组:snapshots
|
|
126
|
+
kr_group_snapshots() {
|
|
127
|
+
section "snapshots · 宽度×主题×语言×状态(3.4)"
|
|
128
|
+
local b1="$tmp/s1.md" long="$tmp/s-long.md"
|
|
129
|
+
printf '快照回复一\n第二行\n' >"$b1"
|
|
130
|
+
{ local i; for i in $(seq 1 200); do printf '滚动行 %s\n' "$i"; done; printf 'END-MARKER-P234\n'; } >"$long"
|
|
131
|
+
fixture_up snapshots "dev2|快照标题|$b1" "verify|长文快照|$long"
|
|
132
|
+
local i
|
|
133
|
+
for i in $(seq 1 58); do kr_cli "$ROOT" reply post --from dev2 --title "槽位 $i" --stdin <"$b1" >/dev/null; done
|
|
134
|
+
assert_eq "snapshots:夹具 store 有 60 个编号" "$(kr_cli "$ROOT" reply list --json | python3 -c 'import json,sys;print(json.load(sys.stdin)["total_slots"])')" "60"
|
|
135
|
+
local w t l f over over_rc
|
|
136
|
+
for w in 160 120 99 59; do
|
|
137
|
+
for t in dark light; do
|
|
138
|
+
for l in zh en; do
|
|
139
|
+
f="$tmp/snap-$w-$t-$l.txt"
|
|
140
|
+
kr_panel_snapshot 5 --width "$w" --height 28 --theme "$t" --lang "$l" >"$f"
|
|
141
|
+
over="$(python3 - "$f" "$w" <<'PYW'
|
|
142
|
+
import sys, unicodedata
|
|
143
|
+
path, limit = sys.argv[1], int(sys.argv[2])
|
|
144
|
+
def dw(s):
|
|
145
|
+
n = 0
|
|
146
|
+
for ch in s:
|
|
147
|
+
if unicodedata.combining(ch):
|
|
148
|
+
continue
|
|
149
|
+
n += 2 if unicodedata.east_asian_width(ch) in ('W', 'F') else 1
|
|
150
|
+
return n
|
|
151
|
+
try:
|
|
152
|
+
text = open(path, 'rb').read().decode('utf-8')
|
|
153
|
+
except UnicodeDecodeError as e:
|
|
154
|
+
print(f"TRUNCATED {e}")
|
|
155
|
+
raise SystemExit(0)
|
|
156
|
+
for i, line in enumerate(text.split('\n'), 1):
|
|
157
|
+
if dw(line) > limit:
|
|
158
|
+
print(f"OVER {i}: {dw(line)} 列")
|
|
159
|
+
break
|
|
160
|
+
PYW
|
|
161
|
+
)"; over_rc=$?
|
|
162
|
+
if [ "$over_rc" != "0" ]; then
|
|
163
|
+
bad "snapshots:${w}×${t}×${l} 宽度检查器失败(rc=$over_rc)"
|
|
164
|
+
elif [ -z "$over" ]; then ok "snapshots:${w}×${t}×${l} 没有行超过 ${w} 列(显示宽度)"
|
|
165
|
+
else case "$over" in
|
|
166
|
+
TRUNCATED*) bad "snapshots:${w}×${t}×${l} 是半截帧($over)" ;;
|
|
167
|
+
*) bad "snapshots:${w}×${t}×${l} 有行超宽($over)" ;;
|
|
168
|
+
esac
|
|
169
|
+
fi
|
|
170
|
+
if [ "$l" = "zh" ]; then
|
|
171
|
+
assert_has "$f" "关键回复" "snapshots:${w}×${t}×${l} 活动页身份可见"
|
|
172
|
+
assert_has "$f" "更早" "snapshots:${w}×${t}×${l} Older 可达"
|
|
173
|
+
else
|
|
174
|
+
assert_has "$f" "key replies" "snapshots:${w}×${t}×${l} 活动页身份可见"
|
|
175
|
+
assert_has "$f" "Older" "snapshots:${w}×${t}×${l} Older 可达"
|
|
176
|
+
fi
|
|
177
|
+
done
|
|
178
|
+
done
|
|
179
|
+
done
|
|
180
|
+
# 状态:summary 行 / 空 store / 坏 store / cursor 续页 / 长文视窗
|
|
181
|
+
kr_panel_snapshot 1 --width 160 --height 30 --lang zh >"$tmp/snap-summary.txt"
|
|
182
|
+
assert_has "$tmp/snap-summary.txt" "#60 槽位 58" "snapshots:总览摘要显示最新编号与标题"
|
|
183
|
+
kr_panel_snapshot 5 --reply-before 10 --width 120 --height 24 --lang zh >"$tmp/snap-cont.txt"
|
|
184
|
+
assert_has "$tmp/snap-cont.txt" "#1 " "snapshots:更旧页 cursor 到达 #1"
|
|
185
|
+
kr_panel_snapshot 5 --reply-no 2 --width 120 --height 24 --lang zh >"$tmp/snap-view.txt"
|
|
186
|
+
assert_has "$tmp/snap-view.txt" "长文快照" "snapshots:长文视窗渲染标题"
|
|
187
|
+
local KR="$state/key-replies" size
|
|
188
|
+
size="$(stat -c %s "$KR/index.v1")"
|
|
189
|
+
printf 'ZZZZ' | dd of="$KR/index.v1" bs=1 seek=$((size - 100)) conv=notrunc status=none
|
|
190
|
+
kr_panel_snapshot 5 --width 120 --height 24 --lang zh >"$tmp/snap-corrupt.txt"
|
|
191
|
+
assert_has "$tmp/snap-corrupt.txt" "不可用" "snapshots:坏槽位在快照里是不可用行"
|
|
192
|
+
mv "$KR" "$tmp/store-parked"
|
|
193
|
+
kr_panel_snapshot 5 --width 99 --height 20 --lang zh >"$tmp/snap-empty.txt"
|
|
194
|
+
mv "$tmp/store-parked" "$KR"
|
|
195
|
+
# 半截帧守卫:一次性写出器(`--snapshot`/`--print`/`--json`)走的是同步 raw fd 写,
|
|
196
|
+
# fd 1 是管道时可能只写进去一部分——每个快照都必须是完整 UTF-8 且以换行结尾。
|
|
197
|
+
local half
|
|
198
|
+
half="$(python3 - "$tmp" <<'PYC'
|
|
199
|
+
import sys, pathlib
|
|
200
|
+
bad = []
|
|
201
|
+
for p in sorted(pathlib.Path(sys.argv[1]).glob('snap-*')):
|
|
202
|
+
raw = p.read_bytes()
|
|
203
|
+
try:
|
|
204
|
+
raw.decode('utf-8')
|
|
205
|
+
except UnicodeDecodeError:
|
|
206
|
+
bad.append(p.name + ':utf8')
|
|
207
|
+
continue
|
|
208
|
+
if not raw.endswith(b'\n'):
|
|
209
|
+
bad.append(p.name + ':no-newline')
|
|
210
|
+
print(' '.join(bad))
|
|
211
|
+
PYC
|
|
212
|
+
)"
|
|
213
|
+
if [ -z "$half" ]; then ok "snapshots:所有快照都是完整 UTF-8 且以换行结尾(没有半截帧)"
|
|
214
|
+
else bad "snapshots:有半截帧($half)"; fi
|
|
215
|
+
# 一次性出口的完整性:4 KiB 管道 + 慢读者下,字节数与「写文件」逐字节等长(node 对非阻塞管道
|
|
216
|
+
# 的单次 writeSync 必然短写;写全循环是修复,见本任务报告 §7)。本组的 store 有 60 条,160 列
|
|
217
|
+
# 的整帧 >4 KiB,才撞得上管道容量——这正是实测里丢尾巴的那个组合。
|
|
218
|
+
kr_panel_snapshot_raw 5 --width 160 --height 28 --theme dark --lang en >"$tmp/pipe-ref.txt"
|
|
219
|
+
local ref_bytes probe
|
|
220
|
+
ref_bytes="$(stat -c %s "$tmp/pipe-ref.txt")"
|
|
221
|
+
probe="$(kr_pipe_probe "$panel" "$ROOT" --team-cli "$(kr_shim)" --snapshot --page 5 --width 160 --height 28 --theme dark --lang en)"
|
|
222
|
+
if [ "$probe" = "$ref_bytes" ]; then
|
|
223
|
+
ok "snapshots:4 KiB 管道上一次性出口仍完整($probe 字节 = 文件参考字节数)"
|
|
224
|
+
else
|
|
225
|
+
bad "snapshots:管道上丢了尾巴(probe=$probe 参考=$ref_bytes)"
|
|
226
|
+
fi
|
|
227
|
+
ev_save "$tmp/snap-59-dark-zh.txt" "ui-snapshots-59-dark-zh.txt"
|
|
228
|
+
ev_save "$tmp/snap-160-light-en.txt" "ui-snapshots-160-light-en.txt"
|
|
229
|
+
ev_save "$tmp/snap-empty.txt" "ui-snapshots-empty.txt"
|
|
230
|
+
ev_save "$tmp/snap-corrupt.txt" "ui-snapshots-corrupt.txt"
|
|
231
|
+
ev_save "$tmp/snap-summary.txt" "ui-snapshots-summary.txt"
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
# ---------------------------------------------------------------- 组:routing-regression
|
|
235
|
+
kr_group_routing_regression() {
|
|
236
|
+
section "routing-regression · 既有设置/字符串/对比度前门(3.4–3.5)"
|
|
237
|
+
local log="$tmp/rr.log" rc=0
|
|
238
|
+
: >"$log"
|
|
239
|
+
if [ -f "$SELF_DIR/panel-p21.sh" ]; then
|
|
240
|
+
bash "$SELF_DIR/panel-p21.sh" >>"$log" 2>&1 || rc=1
|
|
241
|
+
# panel-p21 里「遗留配置迁移诊断」那一组依赖 task-model-routing 的 `team config upgrade-models`
|
|
242
|
+
# (该 change 未落地,D92 明确不在本 change 范围):**照原样**在余额树上也是同一组红(本仓
|
|
243
|
+
# 复验记录里有 /tmp/p234-base 的对照)。所以这条 guard 判的是「除已知的 8 条以外没有新红」,
|
|
244
|
+
# 而不是要求 rc=0 —— 用「已知红」清单过滤后必须一条不剩,且绿数不得低于基线 322。
|
|
245
|
+
local p21_ok p21_bad p21_new
|
|
246
|
+
p21_ok="$(grep -ac '✓' "$log" || true)"
|
|
247
|
+
p21_bad="$(grep -ac '✗' "$log" || true)"
|
|
248
|
+
p21_new="$(grep -a '✗' "$log" | grep -v '== 结果 ==' | grep -v -e '遗留配置的迁移诊断' -e 'upgrade-models' -e '--task-models' -e '--dry-run' -e 'TEAM_DEFAULT_MODEL' -e '没能把焦点移到退休键行' -e '退休键' || true)"
|
|
249
|
+
if [ -z "$p21_new" ]; then
|
|
250
|
+
ok "routing-regression:panel-p21 除已知的迁移诊断红($p21_bad 条,余额树上同数)之外无新红(✓$p21_ok)"
|
|
251
|
+
else
|
|
252
|
+
bad "routing-regression:panel-p21 出现新红"; printf '%s\n' "$p21_new" | head -6 | sed 's/^/ /'
|
|
253
|
+
fi
|
|
254
|
+
if [ "${p21_ok:-0}" -ge 322 ]; then ok "routing-regression:panel-p21 绿数不低于基线($p21_ok ≥ 322)"; else bad "routing-regression:panel-p21 绿数低于基线($p21_ok < 322)"; fi
|
|
255
|
+
else
|
|
256
|
+
bad "routing-regression:缺 panel-p21.sh"
|
|
257
|
+
fi
|
|
258
|
+
local log2="$tmp/rr2.log" rc2=0
|
|
259
|
+
if [ -f "$SELF_DIR/panel-choices.sh" ]; then
|
|
260
|
+
bash "$SELF_DIR/panel-choices.sh" >>"$log2" 2>&1 || rc2=1
|
|
261
|
+
if [ "$rc2" = "0" ]; then ok "routing-regression:panel-choices 全绿($(grep -ac '✓' "$log2" || true) 条)"; else bad "routing-regression:panel-choices 红"; grep -a '✗' "$log2" | head -6 | sed 's/^/ /'; fi
|
|
262
|
+
else
|
|
263
|
+
bad "routing-regression:缺 panel-choices.sh"
|
|
264
|
+
fi
|
|
265
|
+
if node "$SELF_DIR/panel-strings.mjs" >"$tmp/rr3.log" 2>&1; then ok "routing-regression:panel-strings 双向守卫绿"; else bad "routing-regression:panel-strings 红"; tail -4 "$tmp/rr3.log" | sed 's/^/ /'; fi
|
|
266
|
+
if node "$SELF_DIR/panel-contrast.mjs" >"$tmp/rr4.log" 2>&1; then ok "routing-regression:panel-contrast 绿"; else bad "routing-regression:panel-contrast 红"; tail -4 "$tmp/rr4.log" | sed 's/^/ /'; fi
|
|
267
|
+
ev_save "$log" "ui-routing-p21.log"
|
|
268
|
+
ev_save "$tmp/rr4.log" "ui-routing-contrast.log"
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
# ---------------------------------------------------------------- 驱动
|
|
272
|
+
# 4 KiB 的管道 + 慢读者:一次性出口(--snapshot/--print/--json)必须仍然完整。
|
|
273
|
+
# 这是**确定性**的:写 5 KB 进 4096 字节的管道时,单次 writeSync 必然只写进去一部分。
|
|
274
|
+
kr_pipe_probe() { # <panel> <root> <args…> → 完整字节数;半截帧打印 TRUNCATED
|
|
275
|
+
python3 - "$@" <<'PYP'
|
|
276
|
+
import fcntl, os, subprocess, sys, time
|
|
277
|
+
panel, root = sys.argv[1], sys.argv[2]
|
|
278
|
+
args = sys.argv[3:]
|
|
279
|
+
env = {k: v for k, v in os.environ.items() if not k.startswith('TEAM_')}
|
|
280
|
+
r, w = os.pipe()
|
|
281
|
+
try:
|
|
282
|
+
fcntl.fcntl(w, 1038, 4096) # F_SETPIPE_SZ: shrink the pipe so a full-frame write must be short
|
|
283
|
+
except OSError:
|
|
284
|
+
pass
|
|
285
|
+
proc = subprocess.Popen([os.environ.get('KR_NODE', 'node'), panel, '--root', root, *args],
|
|
286
|
+
stdout=w, stderr=subprocess.DEVNULL, env=env)
|
|
287
|
+
os.close(w)
|
|
288
|
+
chunks = []
|
|
289
|
+
while True:
|
|
290
|
+
chunk = os.read(r, 1024) # a deliberately small, slightly slow reader
|
|
291
|
+
if not chunk:
|
|
292
|
+
break
|
|
293
|
+
chunks.append(chunk)
|
|
294
|
+
time.sleep(0.002)
|
|
295
|
+
os.close(r)
|
|
296
|
+
proc.wait()
|
|
297
|
+
raw = b''.join(chunks)
|
|
298
|
+
try:
|
|
299
|
+
raw.decode('utf-8')
|
|
300
|
+
except UnicodeDecodeError:
|
|
301
|
+
print('TRUNCATED-mid-character')
|
|
302
|
+
raise SystemExit(0)
|
|
303
|
+
if not raw.endswith(b'\n'):
|
|
304
|
+
print('TRUNCATED-no-newline')
|
|
305
|
+
raise SystemExit(0)
|
|
306
|
+
print(len(raw))
|
|
307
|
+
PYP
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
kr_run_group() { # 组名到函数(`routing-regression` 带连字符,不能靠 $var 展开)
|
|
311
|
+
case "$1" in
|
|
312
|
+
routing-regression) kr_group_routing_regression ;;
|
|
313
|
+
*) "kr_group_$1" ;;
|
|
314
|
+
esac
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
for g in "${KR_SEL[@]}"; do
|
|
318
|
+
GROUP_PASS=0; GROUP_FAIL=0
|
|
319
|
+
kr_run_group "$g"
|
|
320
|
+
if [ $((GROUP_PASS + GROUP_FAIL)) -eq 0 ]; then bad "${g}:零断言"; fi
|
|
321
|
+
done
|
|
322
|
+
kr_real_guard
|
|
323
|
+
printf '\n== P234 key-replies-ui 结果 == ✓%s ✗%s SKIP%s\n' "$PASS" "$FAIL" "$SKIP"
|
|
324
|
+
[ "$FAIL" -eq 0 ] || exit 1
|
|
325
|
+
exit 0
|