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,367 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# reply-fixture.sh — P234 两个真面板夹具(key-replies-pty.sh / key-replies-ui.sh)共用的底座。
|
|
4
|
+
#
|
|
5
|
+
# 内容:断言器与计数、隔离守卫、夹具仓库(真 `team init` + 真 `team reply post`)、记录 argv 的
|
|
6
|
+
# CLI shim、私有 tmux server 的起停与稳定帧等待、面板的起/捕/按键。夹具本体只写各自的场景。
|
|
7
|
+
#
|
|
8
|
+
# 调用方契约:先 source 本文件(它会 source tmp-root / tmux-iso / pty-wait),再定组;变量
|
|
9
|
+
# sock/sess/tmp/ROOT/state/current 由 fixture_up 维护;TEAM_REPLY_EVIDENCE 指到仓外证据包。
|
|
10
|
+
set -uo pipefail
|
|
11
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
12
|
+
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
13
|
+
. "$SELF_DIR/lib/tmp-root.sh"
|
|
14
|
+
. "$SELF_DIR/lib/tmux-iso.sh"
|
|
15
|
+
. "$SELF_DIR/lib/pty-wait.sh"
|
|
16
|
+
. "$SELF_DIR/lib/proc-io.sh"
|
|
17
|
+
|
|
18
|
+
# 本轮的身份/临时根(每个夹具进程一份;sock/sess 用调用方给的 KR_TAG 前缀,便于 tmux 审计归因)
|
|
19
|
+
sock="p234kr-${KR_TAG:-$$}-$$"
|
|
20
|
+
sess="p234kr-${KR_TAG:-$$}-$$"
|
|
21
|
+
tmp="$(tmp_root_create "p234-reply-${KR_TAG:-fixture}")" || exit 3
|
|
22
|
+
ROOT=""; state=""; current=""; KR_EV="${TEAM_REPLY_EVIDENCE:-}"
|
|
23
|
+
|
|
24
|
+
# 收尾:先证明私有 socket 生效再 kill-server(同 panel-b3 的纪律),然后回收临时根。
|
|
25
|
+
reply_fixture_cleanup() {
|
|
26
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0
|
|
27
|
+
tmux_iso_guard_soft "reply-fixture" "收尾:私有 server" --tmpdir "${TMUX_TMPDIR:-}" --sock-name "$sock" \
|
|
28
|
+
&& tmux -L "$sock" kill-server 2>/dev/null || true
|
|
29
|
+
rm -f "${TMUX_TMPDIR:-/tmp}/tmux-$(id -u)/$sock" 2>/dev/null || true
|
|
30
|
+
tmp_root_reap_all
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
command -v tmux >/dev/null 2>&1 || { printf 'reply-fixture: 需要 tmux\n' >&2; exit 2; }
|
|
34
|
+
js="$(command -v node || true)"; [ -n "$js" ] || js="$(command -v bun || true)"
|
|
35
|
+
[ -n "$js" ] || { printf 'reply-fixture: 需要 node/bun\n' >&2; exit 2; }
|
|
36
|
+
# Fixture-only overrides so a flip can point the fixtures at a mutated copy's bundle/CLI
|
|
37
|
+
# (defaults are the tree's own committed artefacts).
|
|
38
|
+
panel="${KR_PANEL:-$SKILL_DIR/scripts/panel/panel.js}"
|
|
39
|
+
[ -f "$panel" ] || { printf 'reply-fixture: 缺 bundle %s\n' "$panel" >&2; exit 3; }
|
|
40
|
+
team_cli="${KR_TEAM_CLI:-$SKILL_DIR/scripts/team}"
|
|
41
|
+
[ -f "$team_cli" ] || { printf 'reply-fixture: 缺 CLI %s\n' "$team_cli" >&2; exit 3; }
|
|
42
|
+
|
|
43
|
+
PASS=0; FAIL=0; SKIP=0
|
|
44
|
+
GROUP_PASS=0; GROUP_FAIL=0
|
|
45
|
+
|
|
46
|
+
section() { printf '\n\033[1m== %s ==\033[0m\n' "$1"; }
|
|
47
|
+
ok() { PASS=$((PASS + 1)); GROUP_PASS=$((GROUP_PASS + 1)); printf ' \033[32m✓\033[0m %s\n' "$1"; }
|
|
48
|
+
bad() { FAIL=$((FAIL + 1)); GROUP_FAIL=$((GROUP_FAIL + 1)); printf ' \033[31m✗\033[0m %s\n' "$1"; }
|
|
49
|
+
skip(){ SKIP=$((SKIP + 1)); printf ' \033[33mSKIP\033[0m %s\n' "$1"; }
|
|
50
|
+
assert_eq() { [ "$2" = "$3" ] && ok "$1" || bad "$1(期望 [$3] 实际 [$2])"; }
|
|
51
|
+
assert_has() { grep -qF -- "$2" "$1" 2>/dev/null && ok "$3" || bad "$3(缺 [$2]:$(head -c 200 "$1" 2>/dev/null | tr '\n' '|'))"; }
|
|
52
|
+
assert_not() { grep -qF -- "$2" "$1" 2>/dev/null && bad "$3(不该出现 [$2])" || ok "$3"; }
|
|
53
|
+
assert_match() { grep -qE -- "$2" "$1" 2>/dev/null && ok "$3" || bad "$3(没有匹配 [$2])"; }
|
|
54
|
+
ev_note() { [ -n "$KR_EV" ] || return 0; mkdir -p "$KR_EV" 2>/dev/null || true; printf '%s\n' "$*" >>"$KR_EV/panel-commands.log" 2>/dev/null || true; }
|
|
55
|
+
ev_save() { [ -n "$KR_EV" ] || return 0; [ -f "$1" ] || return 0; mkdir -p "$KR_EV" 2>/dev/null || true; cp "$1" "$KR_EV/$2" 2>/dev/null || true; }
|
|
56
|
+
|
|
57
|
+
clean_env=(env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION -u TEAM_STATE_DIR
|
|
58
|
+
-u TEAM_DOCS_ABS -u TEAM_DOCS_DIR -u TEAM_SKILL_DIR -u TEAM_ALLOW_FOREIGN_IDENTITY -u TEAM_JS_BIN)
|
|
59
|
+
|
|
60
|
+
kr_cli() { local r="$1"; shift; ( cd "$r" && "${clean_env[@]}" bash "$team_cli" --root "$r" "$@" ); }
|
|
61
|
+
# `--print` 的时钟在行中间:用固定形状把它掩掉再比对(除时钟逐字节一致)。
|
|
62
|
+
kr_mask_print() { sed -E 's/[0-9]{2}:[0-9]{2}:[0-9]{2}/HH:MM:SS/g'; }
|
|
63
|
+
|
|
64
|
+
# ---------------------------------------------------------------- real-repo isolation guard
|
|
65
|
+
# 夹具只在临时根里的私有仓库跑真 CLI;每个仓库开写前 `kr_new_proj` → `kr_paths_check` 断言
|
|
66
|
+
# `team paths` 的 main_root **逐字等于**夹具仓库,跑完再断言真实仓库(这个 worktree 自己,
|
|
67
|
+
# 可用 TEAM_REPLY_REAL_ROOT 覆盖)的账本面内容哈希前后一致。
|
|
68
|
+
REAL_ROOT="${TEAM_REPLY_REAL_ROOT:-$(cd -P "$SELF_DIR/../../.." && pwd)}"
|
|
69
|
+
kr_tree_hash() { # <目录> → 内容 sha256(不存在 → missing)
|
|
70
|
+
local d="$1"
|
|
71
|
+
if [ ! -e "$d" ]; then printf 'missing\n'; return 0; fi
|
|
72
|
+
( cd "$d" 2>/dev/null && find . -type f -print0 2>/dev/null | sort -z | xargs -0 -r sha256sum 2>/dev/null | sha256sum | cut -d' ' -f1 )
|
|
73
|
+
}
|
|
74
|
+
REAL_INBOX_BEFORE="$(kr_tree_hash "$REAL_ROOT/docs/team/inbox")"
|
|
75
|
+
REAL_STATE_BEFORE="$(kr_tree_hash "$REAL_ROOT/.pi/team/state")"
|
|
76
|
+
kr_real_guard() {
|
|
77
|
+
local inbox_after state_after
|
|
78
|
+
inbox_after="$(kr_tree_hash "$REAL_ROOT/docs/team/inbox")"
|
|
79
|
+
state_after="$(kr_tree_hash "$REAL_ROOT/.pi/team/state")"
|
|
80
|
+
if [ "$inbox_after" = "$REAL_INBOX_BEFORE" ] && [ "$state_after" = "$REAL_STATE_BEFORE" ]; then
|
|
81
|
+
ok "隔离守卫:真实仓库 $REAL_ROOT 的 inbox/state 前后逐字节不变"
|
|
82
|
+
else
|
|
83
|
+
bad "隔离守卫:真实仓库被改动了!inbox $REAL_INBOX_BEFORE → $inbox_after | state $REAL_STATE_BEFORE → $state_after"
|
|
84
|
+
fi
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# ---------------------------------------------------------------- fixture project + store
|
|
88
|
+
fixture_up() { # <name> <replies…> 每份回复是 `<label>:<title>:<bodyfile>`
|
|
89
|
+
current="$1"
|
|
90
|
+
ROOT="$tmp/$1/root"
|
|
91
|
+
shift
|
|
92
|
+
mkdir -p "$ROOT/docs/team" "$ROOT/.pi/team/state"
|
|
93
|
+
( cd "$ROOT" && git init -q -b main && git config user.email kr@teamsmith && git config user.name kr \
|
|
94
|
+
&& echo "# $1" > README.md && git add -A && git commit -qm init ) >/dev/null 2>&1
|
|
95
|
+
tmux_iso_require "key-replies-panel" "重起私有 server 前的 kill-server" --tmpdir "${TMUX_TMPDIR:-}" --sock-name "$sock"
|
|
96
|
+
tmux -L "$sock" kill-server 2>/dev/null || true
|
|
97
|
+
rm -f "${TMUX_TMPDIR:-/tmp}/tmux-$(id -u)/$sock" 2>/dev/null || true
|
|
98
|
+
( cd "$ROOT" && bash "$team_cli" init --session "$sess" --agents "dev verify" --vcs local --gates "true" \
|
|
99
|
+
--docs docs/team --task-models 'routine=deepseek/deepseek-flash' --pm-model 'deepseek/deepseek-flash' ) \
|
|
100
|
+
>"$tmp/$current/init.log" 2>&1 || { printf 'key-replies-panel: team init 失败\n' >&2; tail -3 "$tmp/$current/init.log" >&2; exit 3; }
|
|
101
|
+
state="$ROOT/.pi/team/state"
|
|
102
|
+
mkdir -p "$ROOT/docs/team" "$state"
|
|
103
|
+
local spec label title body
|
|
104
|
+
for spec in "$@"; do
|
|
105
|
+
IFS='|' read -r label title body <<<"$spec"
|
|
106
|
+
kr_cli "$ROOT" reply post --from "$label" --title "$title" --stdin <"$body" >/dev/null 2>&1 \
|
|
107
|
+
|| { printf 'reply-fixture: 夹具回复发布失败(%s)\n' "$title" >&2; exit 3; }
|
|
108
|
+
done
|
|
109
|
+
# 记录 argv 的 CLI shim:真 CLI 前面加一行日志(`__panel-data --block …` 的逐条调用可查)
|
|
110
|
+
kr_shim_set_slow -
|
|
111
|
+
tmux -L "$sock" new-session -d -s "$sess" -x 120 -y 32 -n bootstrap -c "$ROOT" 'sleep 900'
|
|
112
|
+
tmux -L "$sock" set -g window-size manual 2>/dev/null || true
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
kr_shim() { printf '%s/%s/bin/team' "$tmp" "$current"; }
|
|
116
|
+
# 慢块旋钮(夹具用):KR_SLOW_BLOCK=<块名> 时 shim 在请求该块前先睡 KR_SLOW_SEC(默认 5)秒。
|
|
117
|
+
kr_shim_set_slow() { # <块名|-> [秒]:请求该块前先睡 N 秒(慢读者夹具;- = 正常 shim)
|
|
118
|
+
local block="$1" sec="${2:-5}" f="$tmp/$current/bin/team"
|
|
119
|
+
mkdir -p "$tmp/$current/bin"
|
|
120
|
+
cat >"$f" <<SHIM
|
|
121
|
+
#!/usr/bin/env bash
|
|
122
|
+
printf '%s\n' "\$*" >>"$(kr_argv)"
|
|
123
|
+
SHIM
|
|
124
|
+
if [ "$block" != "-" ]; then
|
|
125
|
+
printf 'for a in "$@"; do [ "$a" = %q ] && sleep %s && break; done\n' "$block" "$sec" >>"$f"
|
|
126
|
+
fi
|
|
127
|
+
printf 'exec bash %q "$@"\n' "$team_cli" >>"$f"
|
|
128
|
+
chmod +x "$f"
|
|
129
|
+
}
|
|
130
|
+
kr_argv() { printf '%s/%s/argv.log' "$tmp" "$current"; }
|
|
131
|
+
|
|
132
|
+
start_panel() { # [面板额外参数…]
|
|
133
|
+
local cli="${KR_PANEL_CLI:-$(kr_shim)}"
|
|
134
|
+
tmux -L "$sock" kill-window -t "$sess:panel" 2>/dev/null || true
|
|
135
|
+
tmux -L "$sock" new-window -d -t "$sess" -n panel -c "$ROOT" \
|
|
136
|
+
"TEAM_JS_BIN=$(printf '%q' "$js") exec '$js' '$panel' --root '$ROOT' --state-dir '$state' \
|
|
137
|
+
--team-cli '$cli' --no-pulse --interval 1 $*"
|
|
138
|
+
wait_panel
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
wait_panel() {
|
|
142
|
+
local i
|
|
143
|
+
for i in $(seq 1 80); do
|
|
144
|
+
if tmux -L "$sock" capture-pane -p -t "$sess:panel" 2>/dev/null | grep -qF 'teamsmith pulse'; then sleep 0.4; return 0; fi
|
|
145
|
+
sleep 0.25
|
|
146
|
+
done
|
|
147
|
+
printf 'key-replies-panel: 面板窗格没有渲染出来(%s)\n' "$current" >&2
|
|
148
|
+
tmux -L "$sock" capture-pane -p -t "$sess:panel" 2>/dev/null | tail -5 >&2
|
|
149
|
+
return 1
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
cap() { tmux -L "$sock" capture-pane -p -t "$sess:panel" -S -400 2>/dev/null; }
|
|
153
|
+
cap_to() { cap >"$tmp/$current/${1:-cap}.txt"; }
|
|
154
|
+
keys() { tmux -L "$sock" send-keys -t "$sess:panel" "$@" 2>/dev/null; }
|
|
155
|
+
pty_cap() { cap; }
|
|
156
|
+
pty_keys() { keys "$@"; }
|
|
157
|
+
pty_pane_state() { tmux -L "$sock" list-panes -t "$sess:panel" -F '#{pane_dead}:#{pane_dead_status}' 2>/dev/null | head -1; }
|
|
158
|
+
# 等稳定帧后落到 <file>(needle 以 `!` 开头 = 必须缺席);返回 pty-wait 的 rc(0 绿 / 3 可见 SKIP / 其它红)
|
|
159
|
+
wait_cap() { # <file> <label> <needle…>
|
|
160
|
+
local _out="$1" _label="$2"; shift 2
|
|
161
|
+
PTY_WAIT_ITERS="${KR_FRAME_ITERS:-60}" PTY_WAIT_PAUSE=0.4 PTY_SETTLE_PAUSE=0.25 pty_wait_frame "$_out" "$_label" "$@"
|
|
162
|
+
}
|
|
163
|
+
verdict() { # <rc> <应绿断言> <应红断言>
|
|
164
|
+
case "$1" in
|
|
165
|
+
0) ok "$2" ;;
|
|
166
|
+
3) skip "$2(机器读数超前提:稳定帧等不到,场景仍在绘制,D33 的可见 SKIP)" ;;
|
|
167
|
+
*) bad "$3" ;;
|
|
168
|
+
esac
|
|
169
|
+
}
|
|
170
|
+
want_frame() { # <name> <label> <needle…>
|
|
171
|
+
local f="$tmp/$current/$1.txt"; shift; local label="$1"; shift
|
|
172
|
+
wait_cap "$f" "$label" "$@"; local rc=$?
|
|
173
|
+
verdict $rc "$label" "$label(稳定帧里没等到 [$*])"
|
|
174
|
+
return 0
|
|
175
|
+
}
|
|
176
|
+
page_file() { printf '%s/panel-page' "$state"; }
|
|
177
|
+
|
|
178
|
+
reset_argv() { : >"$(kr_argv)" 2>/dev/null || true; }
|
|
179
|
+
blocks_since() { awk '{for(i=1;i<=NF;i++) if($i=="--block" && (i+1)<=NF) print $(i+1)}' "$(kr_argv)" 2>/dev/null; }
|
|
180
|
+
block_calls() { # <块名> → 调用次数
|
|
181
|
+
local n; n="$(blocks_since | grep -c -x -- "$1" || true)"; printf '%s' "${n:-0}"
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
# ---------------------------------------------------------------- 组:pane(真面板)
|
|
185
|
+
kr_group_pane() {
|
|
186
|
+
section "pane · 真 tmux 面板(第 5 页 / 长正文 / 重启 / 坏 store)"
|
|
187
|
+
local body1="$tmp/pane-a.md" body2="$tmp/pane-b.md" long="$tmp/pane-long.md"
|
|
188
|
+
printf '第一份回复:结论与取舍\n\n- 要点一\n- 要点二\n' >"$body1"
|
|
189
|
+
printf '第二份回复\n尾巴带换行\n' >"$body2"
|
|
190
|
+
{ local i; for i in $(seq 1 300); do printf '第 %s 行:长正文滚动测试\n' "$i"; done; printf 'END-MARKER-P234\n'; } >"$long"
|
|
191
|
+
fixture_up pane "dev2|完整结论与取舍|$body1" "verify|第二份回复|$body2" "dev2|长正文|$long"
|
|
192
|
+
start_panel || { bad "pane:面板起不来"; return 1; }
|
|
193
|
+
|
|
194
|
+
# ① 第 5 页:列表帧(两行 + 页签身份)
|
|
195
|
+
keys "5"; sleep 0.6
|
|
196
|
+
want_frame list5 "pane:第 5 页列表帧(编号 + 标题 + 发布者标签)" "#3 长正文" "#2 第二份回复" "#1 完整结论与取舍" "关键回复"
|
|
197
|
+
assert_has "$tmp/$current/list5.txt" "关键回复" "pane:页签显示第 5 页身份"
|
|
198
|
+
assert_has "$tmp/$current/list5.txt" "个编号槽位" "pane:列表带编号槽位计数(不冒充可读回复数)"
|
|
199
|
+
ev_save "$tmp/$current/list5.txt" "pane-list5.txt"
|
|
200
|
+
# ② Enter 打开焦点(最新号)→ 正文视窗;End 滚到最后一行,END-MARKER 可达
|
|
201
|
+
keys Enter; sleep 0.6
|
|
202
|
+
want_frame viewer "pane:Enter 打开焦点号的完整正文" "长正文" "来自 dev2"
|
|
203
|
+
assert_has "$tmp/$current/viewer.txt" "只读 · 按发布的原文显示" "pane:正文视窗只读且按发布的原文显示(没有限定词)"
|
|
204
|
+
assert_not "$tmp/$current/viewer.txt" "END-MARKER-P234" "pane:视窗打开时停在文首(长文没有被一次性铺满)"
|
|
205
|
+
keys End; sleep 0.6
|
|
206
|
+
want_frame viewer_end "pane:End 滚到长正文结尾,END-MARKER 可达" "END-MARKER-P234"
|
|
207
|
+
keys PageUp; sleep 0.6
|
|
208
|
+
want_frame viewer_pgup "pane:PgUp 向上滚动(结尾标记离开视窗)" "!END-MARKER-P234"
|
|
209
|
+
keys PageDown; sleep 0.6
|
|
210
|
+
want_frame viewer_pgdn "pane:PgDn 滚回结尾(标记再次出现)" "END-MARKER-P234"
|
|
211
|
+
ev_save "$tmp/$current/viewer_end.txt" "pane-viewer-end.txt"
|
|
212
|
+
# ③ q 返回列表(不是收起整个控制台):列表在、窗格没死
|
|
213
|
+
keys "q"; sleep 0.6
|
|
214
|
+
want_frame back "pane:q 回到列表(同页状态)" "#3 长正文" "个编号槽位"
|
|
215
|
+
assert_eq "pane:q 后窗格仍然活着(0 表示活)" "$(pty_pane_state | cut -d: -f1)" "0"
|
|
216
|
+
# ④ 重启后仍可读:面板页记的是第 5 页,store 不变 → 列表照旧
|
|
217
|
+
start_panel || bad "pane:重启失败"
|
|
218
|
+
want_frame restart "pane:重启后仍在第 5 页且回复可读" "#3 长正文" "#1 完整结论与取舍"
|
|
219
|
+
assert_eq "pane:panel-page 记的是 5" "$(tr -d '\n' <"$(page_file)")" "5"
|
|
220
|
+
ev_save "$tmp/$current/restart.txt" "pane-restart.txt"
|
|
221
|
+
# ⑤ 坏 store 可见不可用,但不阻断正常答复/导航:把最新槽位打坏
|
|
222
|
+
keys "1"; sleep 0.4
|
|
223
|
+
local KR="$state/key-replies" size
|
|
224
|
+
size="$(stat -c %s "$KR/index.v1")"
|
|
225
|
+
printf 'ZZZZ' | dd of="$KR/index.v1" bs=1 seek=$((size - 200)) conv=notrunc status=none
|
|
226
|
+
keys "5"; sleep 0.4
|
|
227
|
+
keys "r"; sleep 0.6
|
|
228
|
+
want_frame corrupt "pane:坏槽位显示为不可用行且页面仍可用" "不可用" "更早"
|
|
229
|
+
keys "1"; sleep 0.6
|
|
230
|
+
want_frame corrupt_back "pane:坏 store 后仍能回到总览(不阻断)" "总览" "teamsmith pulse"
|
|
231
|
+
assert_eq "pane:坏 store 期间窗格没死" "$(pty_pane_state | cut -d: -f1)" "0"
|
|
232
|
+
ev_save "$tmp/$current/corrupt.txt" "pane-corrupt.txt"
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
# ---------------------------------------------------------------- 组:demand(需求读)
|
|
236
|
+
kr_group_demand() {
|
|
237
|
+
section "demand · 三个块按需读(记录 argv)"
|
|
238
|
+
local b1="$tmp/d1.md" b2="$tmp/d2.md"
|
|
239
|
+
printf '一份答复\n' >"$b1"; printf '另一份\n' >"$b2"
|
|
240
|
+
fixture_up demand "dev2|答复一|$b1" "dev2|答复二|$b2"
|
|
241
|
+
start_panel || { bad "demand:面板起不来"; return 1; }
|
|
242
|
+
# ① 停在总览:只有 summary(没有 list/body)。启动阶段就已经调度过 summary,所以这里不清日志。
|
|
243
|
+
sleep 2.0
|
|
244
|
+
want_frame ov "demand:总览渲染出最新回复摘要" "最新关键回复"
|
|
245
|
+
assert_eq "demand:停在总览时 list 调用为 0" "$(block_calls reply_list)" "0"
|
|
246
|
+
assert_eq "demand:停在总览时 body 调用为 0" "$(block_calls reply_body)" "0"
|
|
247
|
+
if [ "$(block_calls reply_summary)" -ge 1 ]; then ok "demand:停在总览就调度 reply_summary($(block_calls reply_summary) 次)"; else bad "demand:总览没有调度 reply_summary(argv 里 $(wc -l <"$(kr_argv)" 2>/dev/null || echo 0) 行)"; fi
|
|
248
|
+
# ② 进第 5 页:多一个 reply_list(带 cursor 或 newest 形态)
|
|
249
|
+
reset_argv
|
|
250
|
+
keys "5"; sleep 1.5
|
|
251
|
+
want_frame list "demand:第 5 页列表到达" "个编号槽位"
|
|
252
|
+
assert_eq "demand:进第 5 页后 body 调用仍为 0" "$(block_calls reply_body)" "0"
|
|
253
|
+
if [ "$(block_calls reply_list)" -ge 1 ]; then ok "demand:进第 5 页后 list 被调度($(block_calls reply_list) 次)"; else bad "demand:进第 5 页后没有 list 调用"; fi
|
|
254
|
+
assert_has "$(kr_argv)" 'reply_list' "demand:argv 日志里能看到 reply_list 的真实参数"
|
|
255
|
+
# ③ 打开某号:多一个 reply_body --no <no>
|
|
256
|
+
reset_argv
|
|
257
|
+
keys Down; sleep 0.3; keys Enter; sleep 1.5
|
|
258
|
+
want_frame body "demand:打开某号后正文视窗渲染" "只读 · 按发布的原文显示"
|
|
259
|
+
assert_eq "demand:打开正文时没有 list 的新调用" "$(block_calls reply_list)" "0"
|
|
260
|
+
if [ "$(block_calls reply_body)" -ge 1 ]; then ok "demand:打开正文后 body 被调度($(block_calls reply_body) 次)"; else bad "demand:打开正文后没有 body 调用"; fi
|
|
261
|
+
assert_match "$(kr_argv)" 'reply_body.*--no [0-9]+' "demand:body 调用带上了要读的编号(argv 可查)"
|
|
262
|
+
# ④ 返回列表:不再请求 body
|
|
263
|
+
reset_argv
|
|
264
|
+
keys "q"; sleep 1.2
|
|
265
|
+
want_frame back "demand:返回列表" "个编号槽位"
|
|
266
|
+
assert_eq "demand:返回列表后 body 不再被请求" "$(block_calls reply_body)" "0"
|
|
267
|
+
# ⑤ 离开第 5 页:list/body 都不再请求
|
|
268
|
+
reset_argv
|
|
269
|
+
keys "1"; sleep 1.5
|
|
270
|
+
assert_eq "demand:离开第 5 页后 list 不再被请求" "$(block_calls reply_list)" "0"
|
|
271
|
+
assert_eq "demand:离开第 5 页后 body 不再被请求" "$(block_calls reply_body)" "0"
|
|
272
|
+
ev_save "$(kr_argv)" "demand-argv.log"
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
# ---------------------------------------------------------------- 组:noise(机器出口)
|
|
276
|
+
kr_group_noise() {
|
|
277
|
+
section "noise · 机器出口不被回复影响"
|
|
278
|
+
local b1="$tmp/n1.md"
|
|
279
|
+
printf '噪声夹具正文\n' >"$b1"
|
|
280
|
+
fixture_up noise
|
|
281
|
+
local pr1 pr2 js1 js2
|
|
282
|
+
kr_cli "$ROOT" monitor --print 2>/dev/null | kr_mask_print >"$tmp/n-print-before.txt"
|
|
283
|
+
kr_cli "$ROOT" monitor --json 2>/dev/null | sed -E 's/"timestamp": *"[^"]*"/"timestamp": "T"/' >"$tmp/n-json-before.txt"
|
|
284
|
+
# 面板偏好 + 坏 store 同时存在,机器出口也必须一样
|
|
285
|
+
printf 'lang=en\ndefaultPage=5\nmouse=off\n' >"$state/panel.conf"
|
|
286
|
+
kr_cli "$ROOT" reply post --from dev2 --title '发布之后' --stdin <"$b1" >/dev/null
|
|
287
|
+
kr_cli "$ROOT" monitor --print 2>/dev/null | kr_mask_print >"$tmp/n-print-after.txt"
|
|
288
|
+
kr_cli "$ROOT" monitor --json 2>/dev/null | sed -E 's/"timestamp": *"[^"]*"/"timestamp": "T"/' >"$tmp/n-json-after.txt"
|
|
289
|
+
if cmp -s "$tmp/n-print-before.txt" "$tmp/n-print-after.txt"; then ok "noise:发布前后 --print 逐字节一致(除时钟)"; else bad "noise:发布改变了 --print"; diff "$tmp/n-print-before.txt" "$tmp/n-print-after.txt" | head -5 >&2; fi
|
|
290
|
+
if cmp -s "$tmp/n-json-before.txt" "$tmp/n-json-after.txt"; then ok "noise:发布前后 --json 逐字节一致(除 timestamp)"; else bad "noise:发布改变了 --json"; fi
|
|
291
|
+
assert_not "$tmp/n-json-after.txt" "reply" "noise:--json 里没有 key-reply 字段"
|
|
292
|
+
# 记录 argv:机器出口零 reply 块
|
|
293
|
+
reset_argv
|
|
294
|
+
kr_cli "$ROOT" monitor --print >/dev/null 2>&1
|
|
295
|
+
kr_cli "$ROOT" monitor --json >/dev/null 2>&1
|
|
296
|
+
assert_eq "noise:--print/--json 期间 reply 块调用为 0" "$(blocks_since | grep -c '^reply_' || true)" "0"
|
|
297
|
+
assert_eq "noise:--print 的 argv 里根本没有 --block reply_*" "$(grep -c 'reply_' "$(kr_argv)" 2>/dev/null || true)" "0"
|
|
298
|
+
# 坏 store + 阻塞的 state 目录也不影响机器出口
|
|
299
|
+
rm -f "$state/key-replies/index.v1"
|
|
300
|
+
mkfifo "$state/key-replies/writer.lock" 2>/dev/null || true
|
|
301
|
+
kr_cli "$ROOT" monitor --print 2>/dev/null | kr_mask_print >"$tmp/n-print-broken.txt"
|
|
302
|
+
if cmp -s "$tmp/n-print-before.txt" "$tmp/n-print-broken.txt"; then ok "noise:store 坏掉/被 FIFO 之后 --print 仍逐字节一致"; else bad "noise:坏 store 改变了 --print"; fi
|
|
303
|
+
ev_save "$tmp/n-print-after.txt" "noise-print-after.txt"
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
# ---------------------------------------------------------------- 组:snapshot(矩阵)
|
|
307
|
+
kr_group_snapshot() {
|
|
308
|
+
section "snapshot · 宽度 × 主题 × 语言矩阵"
|
|
309
|
+
local b1="$tmp/s1.md" long="$tmp/s-long.md"
|
|
310
|
+
printf '快照回复一\n第二行\n' >"$b1"
|
|
311
|
+
{ local i; for i in $(seq 1 200); do printf '滚动行 %s\n' "$i"; done; printf 'END-MARKER-P234\n'; } >"$long"
|
|
312
|
+
fixture_up snapshot "dev2|快照标题|$b1" "verify|长文快照|$long"
|
|
313
|
+
# 60 条(多页夹具):第 2 页的 cursor 断言要真的有更旧的页
|
|
314
|
+
local i
|
|
315
|
+
for i in $(seq 1 58); do kr_cli "$ROOT" reply post --from dev2 --title "槽位 $i" --stdin <"$b1" >/dev/null; done
|
|
316
|
+
assert_eq "snapshot:夹具 store 有 60 个编号" "$(kr_cli "$ROOT" reply list --json | python3 -c 'import json,sys;print(json.load(sys.stdin)["total_slots"])')" "60"
|
|
317
|
+
local w t l f rc
|
|
318
|
+
for w in 160 120 99 59; do
|
|
319
|
+
for t in dark light; do
|
|
320
|
+
for l in zh en; do
|
|
321
|
+
f="$tmp/snap-$w-$t-$l.txt"
|
|
322
|
+
"${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$team_cli" --snapshot --page 5 \
|
|
323
|
+
--width "$w" --height 28 --theme "$t" --lang "$l" 2>/dev/null | sed -e 's/\x1b\[[0-9;]*m//g' >"$f"
|
|
324
|
+
rc=$?
|
|
325
|
+
if [ "$rc" != "0" ]; then bad "snapshot:${w}×${t}×${l} 退出码 $rc"; continue; fi
|
|
326
|
+
# 行不超宽 + 页脚是最后一行 + 五个页签都可点(身份可见)
|
|
327
|
+
local over over_rc
|
|
328
|
+
over="$(python3 - "$f" "$w" <<'PYW'
|
|
329
|
+
import sys, unicodedata
|
|
330
|
+
path, limit = sys.argv[1], int(sys.argv[2])
|
|
331
|
+
def dw(s):
|
|
332
|
+
n = 0
|
|
333
|
+
for ch in s:
|
|
334
|
+
if unicodedata.combining(ch):
|
|
335
|
+
continue
|
|
336
|
+
n += 2 if unicodedata.east_asian_width(ch) in ('W', 'F') else 1
|
|
337
|
+
return n
|
|
338
|
+
for i, line in enumerate(open(path, encoding='utf-8'), 1):
|
|
339
|
+
line = line.rstrip('\n')
|
|
340
|
+
if dw(line) > limit:
|
|
341
|
+
print(f"{i}: {dw(line)} 列")
|
|
342
|
+
break
|
|
343
|
+
PYW
|
|
344
|
+
)" ; over_rc=$?
|
|
345
|
+
if [ "$over_rc" != "0" ]; then
|
|
346
|
+
bad "snapshot:${w}×${t}×${l} 宽度检查器本身失败(rc=$over_rc,$over)"
|
|
347
|
+
elif [ -z "$over" ]; then ok "snapshot:${w}×${t}×${l} 没有行超过 ${w} 列(显示宽度)"
|
|
348
|
+
else bad "snapshot:${w}×${t}×${l} 有行超宽($over)"; fi
|
|
349
|
+
# 页签身份:59 列用短标签,但活动页标签仍在
|
|
350
|
+
if [ "$l" = "zh" ]; then assert_has "$f" "关键回复" "snapshot:${w}×${t}×${l} 活动页身份可见"; else assert_has "$f" "key replies" "snapshot:${w}×${t}×${l} 活动页身份可见"; fi
|
|
351
|
+
done
|
|
352
|
+
done
|
|
353
|
+
done
|
|
354
|
+
ev_save "$tmp/snap-59-dark-zh.txt" "snapshot-59-dark-zh.txt"
|
|
355
|
+
ev_save "$tmp/snap-160-light-en.txt" "snapshot-160-light-en.txt"
|
|
356
|
+
# 空 store / 坏 store / 长文视窗 三态
|
|
357
|
+
"${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$team_cli" --snapshot --page 5 --reply-before 10 --width 120 --height 24 --lang zh 2>/dev/null | sed -e 's/\x1b\[[0-9;]*m//g' >"$tmp/snap-cont.txt"
|
|
358
|
+
assert_has "$tmp/snap-cont.txt" "#1 " "snapshot:第二页 cursor 渲染出 #1(更旧页真的可达)"
|
|
359
|
+
ev_save "$tmp/snap-cont.txt" "snapshot-continuation.txt"
|
|
360
|
+
"${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$team_cli" --snapshot --page 5 --reply-no 2 --width 120 --height 24 --lang zh 2>/dev/null | sed -e 's/\x1b\[[0-9;]*m//g' >"$tmp/snap-view.txt"
|
|
361
|
+
assert_has "$tmp/snap-view.txt" "长文快照" "snapshot:长文视窗渲染标题"
|
|
362
|
+
mv "$state/key-replies" "$tmp/store-parked"
|
|
363
|
+
"${clean_env[@]}" node "$panel" --root "$ROOT" --team-cli "$team_cli" --snapshot --page 5 --width 99 --height 20 --lang zh 2>/dev/null | sed -e 's/\x1b\[[0-9;]*m//g' >"$tmp/snap-empty.txt"
|
|
364
|
+
ev_save "$tmp/snap-empty.txt" "snapshot-empty.txt"
|
|
365
|
+
mv "$tmp/store-parked" "$state/key-replies"
|
|
366
|
+
}
|
|
367
|
+
|