teamsmith 0.2.0 → 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 +4 -4
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +28 -0
- package/skills/teamsmith/SKILL.md +14 -7
- package/skills/teamsmith/extension/team-notify.ts +37 -6
- package/skills/teamsmith/extension/team.ts +438 -0
- package/skills/teamsmith/references/config.md +39 -6
- package/skills/teamsmith/references/migration.md +197 -47
- package/skills/teamsmith/references/protocol.md +176 -19
- package/skills/teamsmith/references/troubleshooting.md +124 -7
- package/skills/teamsmith/references/workflows.md +36 -2
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +318 -23
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +2 -2
- package/skills/teamsmith/scripts/lib/cmd-config.sh +349 -67
- 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 +30 -103
- package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +3 -3
- package/skills/teamsmith/scripts/lib/cmd-review.sh +175 -30
- package/skills/teamsmith/scripts/lib/cmd-status.sh +226 -17
- package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +564 -46
- package/skills/teamsmith/scripts/lib/common.sh +773 -48
- package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +207 -207
- package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
- 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 +11 -3
- package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
- package/skills/teamsmith/scripts/panel/src/main.tsx +33 -8
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +39 -29
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +41 -31
- package/skills/teamsmith/scripts/panel/src/types.ts +28 -3
- package/skills/teamsmith/scripts/replies.mjs +4 -1
- 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 +19 -6
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +8 -1
- package/skills/teamsmith/templates/config.sh.tmpl +20 -1
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +21 -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 +160 -14
- 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 +279 -20
- package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
- package/skills/teamsmith/tests/key-replies-ui.sh +0 -7
- package/skills/teamsmith/tests/key-replies.sh +240 -1
- package/skills/teamsmith/tests/ledger-ban.sh +5 -4
- package/skills/teamsmith/tests/ledger-claim.sh +2 -1
- package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +4 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +51 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
- 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 +31 -13
- package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
- package/skills/teamsmith/tests/panel-b2.sh +106 -3
- package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
- package/skills/teamsmith/tests/panel-b3.sh +175 -19
- package/skills/teamsmith/tests/panel-choices.sh +11 -6
- package/skills/teamsmith/tests/panel-cpu.sh +2 -1
- package/skills/teamsmith/tests/panel-knobs.sh +7 -1
- package/skills/teamsmith/tests/panel-p21.sh +156 -73
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +121 -30
- package/skills/teamsmith/tests/routes.sh +327 -93
- 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 +20 -10
- 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 +19 -13
- package/skills/teamsmith/tests/section-select.sh +8 -1
- 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 +2972 -440
- package/skills/teamsmith/tests/task-model-routing.sh +507 -10
- 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 +12 -12
- package/skills/teamsmith-init/references/bootstrap.md +3 -3
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# slash-team-e2e.sh — `/team` 的**端到端层**(change: slash-team · 实现:P270)
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/slash-team-e2e.sh [--flip] [--keep]
|
|
5
|
+
#
|
|
6
|
+
# 真 pi(`--mode rpc --no-session --approve`)+ 夹具项目里的记录桩:
|
|
7
|
+
# - `PI_CODING_AGENT_DIR` 指向夹具自己的空目录(无凭据、无模型、不读 $HOME 的 pi 配置、不写 trust store)
|
|
8
|
+
# - 项目本地装扩展(`.pi/extensions/team.ts`,Pi 自动发现)+ `team` 桩(`.pi/skills/teamsmith/scripts/team`)
|
|
9
|
+
# - stdin 发 `/team …`,判 JSONL:`disposition:"handled"`、`message_start` 的 content/display、
|
|
10
|
+
# `extension_ui_request` 的 notifyType、桩记下的 argv/cwd/env。
|
|
11
|
+
#
|
|
12
|
+
# 判据(spec extension-slash 的场景):
|
|
13
|
+
# 短成功 → 只有 info 通知;多行成功 → 进正文;桩退出 3 → error 通知点名 3 + 正文带两路流;
|
|
14
|
+
# 表外命令 → 拒绝且桩日志里没有它;`TEAM_ASSUME_YES=1` 的会话 → 子进程环境里没有它、argv 里没有注入的 --yes。
|
|
15
|
+
#
|
|
16
|
+
# `--flip`:把扩展的正文落点改成 notify(scratch 副本装进第二个夹具)——「多行成功进正文」必须变红。
|
|
17
|
+
#
|
|
18
|
+
# 退出码:0 全绿 / 前置不满足时可见 SKIP 也 0;1 有失败;2 用法错误;3 setup 失败。
|
|
19
|
+
set -uo pipefail
|
|
20
|
+
|
|
21
|
+
here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
tree="$(cd -P "$here/../../.." && pwd)"
|
|
23
|
+
. "$here/lib/tmp-root.sh"
|
|
24
|
+
|
|
25
|
+
# 原始 argv 先存档:守卫的 re-exec 必须拿到**没被 shift 消耗过**的那份 ——
|
|
26
|
+
# 直接传 "$@" 会把 `--flip` 丢掉(脚本照样绿、翻转臂静默少跑两条)。
|
|
27
|
+
ORIG_ARGS=("$@")
|
|
28
|
+
FLIP=0
|
|
29
|
+
KEEP=0
|
|
30
|
+
argc=$#
|
|
31
|
+
while [ $# -gt 0 ]; do
|
|
32
|
+
case "$1" in
|
|
33
|
+
--flip) FLIP=1; shift ;;
|
|
34
|
+
--keep) KEEP=1; export TEAM_TMP_KEEP=1; shift ;;
|
|
35
|
+
-h|--help) sed -n '2,20p' "$0"; exit 0 ;;
|
|
36
|
+
*) printf 'slash-team-e2e: 未知参数 %s(用法见 --help)\n' "$1" >&2; exit 2 ;;
|
|
37
|
+
esac
|
|
38
|
+
# 每个分支都必须 shift:`--keep` 曾经漏了 shift,脚本于是永不退出、零输出地空转
|
|
39
|
+
# (PM 2026-10-16 收掉过一个挂了 1h35m 的 --keep 进程)。这条守卫把同一类缺陷变成
|
|
40
|
+
# 立刻可见的 rc=2,而不是一个静默的死循环。
|
|
41
|
+
[ "$#" -lt "$argc" ] || { printf '%s: 参数循环没有前进(分支缺 shift?):%s\n' "slash-team-e2e" "$1" >&2; exit 2; }
|
|
42
|
+
argc=$#
|
|
43
|
+
done
|
|
44
|
+
|
|
45
|
+
# 兜底超时(本轮修掉的缺陷,见报告的 finding):真 pi 的 RPC 路径会等 stdin / 模型响应,子进程一旦卡在
|
|
46
|
+
# read 上,脚本原先可以无限等下去 —— PM 2026-10-16 收掉过一个挂了 1h35m 的 `--keep` 进程(pid 324481)。
|
|
47
|
+
# 现在无论谁怎么调(含 --keep、含被接到管道上),整个脚本都在这里被掐掉:先 TERM,10s 后 KILL。
|
|
48
|
+
# 调用方不必记得加 timeout;要换上限就给 TEAM_SLASH_E2E_GUARD(秒)。
|
|
49
|
+
e2e_guard() {
|
|
50
|
+
local sec="${TEAM_SLASH_E2E_GUARD:-300}"
|
|
51
|
+
if [ -z "${TEAM_SLASH_E2E_GUARDED:-}" ]; then
|
|
52
|
+
printf 'slash-team-e2e: 兜底超时 %ss(TEAM_SLASH_E2E_GUARD 可改);超时先 TERM 再 KILL\n' "$sec"
|
|
53
|
+
TEAM_SLASH_E2E_GUARDED=1 exec timeout --kill-after=10 "$sec" bash "$0" "$@"
|
|
54
|
+
fi
|
|
55
|
+
}
|
|
56
|
+
e2e_guard "${ORIG_ARGS[@]}"
|
|
57
|
+
|
|
58
|
+
ext="$tree/skills/teamsmith/extension/team.ts"
|
|
59
|
+
[ -f "$ext" ] || { printf 'slash-team-e2e: 没有扩展源 %s\n' "$ext" >&2; exit 3; }
|
|
60
|
+
|
|
61
|
+
PI_BIN="${TEAM_SLASH_PI:-}"
|
|
62
|
+
if [ -z "$PI_BIN" ]; then
|
|
63
|
+
# 裸名字不可靠(登录 shell 的 PATH 与交互 shell 不同,且门禁会把假 pi 放在 PATH 最前)——
|
|
64
|
+
# 先试真实安装路径,再退回 PATH 上的名字。
|
|
65
|
+
for cand in "$HOME/.bun/bin/pi" "$(command -v pi 2>/dev/null || true)"; do
|
|
66
|
+
[ -n "$cand" ] && [ -x "$cand" ] && { PI_BIN="$cand"; break; }
|
|
67
|
+
done
|
|
68
|
+
fi
|
|
69
|
+
if [ -z "$PI_BIN" ]; then
|
|
70
|
+
printf '\033[33mSKIP(前置不成立:本机没有 pi)\033[0m 端到端层跑不了(纯逻辑层仍可跑:tests/slash-team.sh)\n'
|
|
71
|
+
exit 0
|
|
72
|
+
fi
|
|
73
|
+
# 门禁的假 pi 不是真 pi(它只会回显参数):显式 SKIP,不把「桩没反应」当成产品失败。
|
|
74
|
+
if "$PI_BIN" --version 2>&1 | grep -q 'smoke-fake'; then
|
|
75
|
+
printf '\033[33mSKIP(前置不成立:%s 是门禁的假 pi,不是真 pi)\033[0m 端到端层跑不了;用 TEAM_SLASH_PI 指一个真 pi\n' "$PI_BIN"
|
|
76
|
+
exit 0
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
tmp="$(tmp_root_create slash-team-e2e)" || exit 3
|
|
80
|
+
cleanup() {
|
|
81
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0
|
|
82
|
+
if [ "$KEEP" = "1" ]; then printf '\n保留夹具目录:%s\n' "$tmp"
|
|
83
|
+
else tmp_root_reap_all; fi
|
|
84
|
+
}
|
|
85
|
+
trap cleanup EXIT
|
|
86
|
+
|
|
87
|
+
PASS=0; FAIL=0
|
|
88
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
|
|
89
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
90
|
+
assert_eq() { [ "$2" = "$3" ] && ok "$1" || bad "$1(期望 [$3],实际 [$2])"; }
|
|
91
|
+
assert_has() { printf '%s' "$1" | grep -qF -- "$2" && ok "$3" || bad "$3(在 [$1] 里找不到 [$2])"; }
|
|
92
|
+
assert_not() { printf '%s' "$1" | grep -qF -- "$2" && bad "$3(不该出现 [$2])" || ok "$3"; }
|
|
93
|
+
|
|
94
|
+
# ---------------------------------------------------------------- 夹具
|
|
95
|
+
fixture() { # <dir> <扩展源>:项目本地装扩展 + 记录 argv/cwd/env 的 team 桩
|
|
96
|
+
local d="$1" src="$2"
|
|
97
|
+
mkdir -p "$d/.pi/team" "$d/.pi/extensions" "$d/.pi/skills/teamsmith/scripts" "$d/agentdir" "$d/home" "$d/sessions"
|
|
98
|
+
printf 'TEAM_SESSION=e2e\n' > "$d/.pi/team/config.sh"
|
|
99
|
+
cp "$src" "$d/.pi/extensions/team.ts"
|
|
100
|
+
cat > "$d/.pi/skills/teamsmith/scripts/team" <<'STUB'
|
|
101
|
+
#!/usr/bin/env bash
|
|
102
|
+
# 记录桩:每次调用追加一个 BEGIN…END 块(argv 逐 token / cwd / 三个被剥离变量的实际值)。
|
|
103
|
+
{
|
|
104
|
+
printf 'BEGIN\n'
|
|
105
|
+
for a in "$@"; do printf 'ARG\t%s\n' "$a"; done
|
|
106
|
+
printf 'CWD\t%s\n' "$PWD"
|
|
107
|
+
printf 'ASSUME\t%s\n' "${TEAM_ASSUME_YES-unset}"
|
|
108
|
+
printf 'UPGRADE\t%s\n' "${TEAM_UPGRADE_CONFIRMED-unset}"
|
|
109
|
+
printf 'FOREIGN\t%s\n' "${TEAM_ALLOW_FOREIGN_SESSION-unset}"
|
|
110
|
+
printf 'END\n'
|
|
111
|
+
} >> "${REC_LOG:?REC_LOG 没给}"
|
|
112
|
+
case "${1:-}" in
|
|
113
|
+
version) printf '0.1.0-stub\n' ;;
|
|
114
|
+
doctor) printf 'out line\n'; printf 'boom\n' >&2; exit 3 ;;
|
|
115
|
+
ps) printf 'a\nb\n' ;;
|
|
116
|
+
*) printf 'x\ny\n' ;;
|
|
117
|
+
esac
|
|
118
|
+
exit 0
|
|
119
|
+
STUB
|
|
120
|
+
chmod +x "$d/.pi/skills/teamsmith/scripts/team"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
prompts_for() { # <文件>
|
|
124
|
+
cat > "$1" <<'P'
|
|
125
|
+
{"id":"1","type":"prompt","message":"/team version"}
|
|
126
|
+
{"id":"2","type":"prompt","message":"/team ps"}
|
|
127
|
+
{"id":"3","type":"prompt","message":"/team doctor"}
|
|
128
|
+
{"id":"4","type":"prompt","message":"/team dispatch dev P1 docs/team/tasks/P1.md"}
|
|
129
|
+
{"id":"5","type":"prompt","message":"/team meeting say alpha --intent proposal \"two words\""}
|
|
130
|
+
{"id":"6","type":"prompt","message":"/team config upgrade-models --task-models routine=vendor/light --pm-model vendor/strong"}
|
|
131
|
+
{"id":"7","type":"prompt","message":"/team config upgrade-models --task-models routine=vendor/light --pm-model vendor/strong --yes"}
|
|
132
|
+
P
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
run_pi() { # <proj> <prompts> <out> <err> <rec-log>
|
|
136
|
+
# 写完 prompt 后**不马上关 stdin**(立刻 EOF 会让 pi 只处理第一条就退出),而是等回执数到齐
|
|
137
|
+
# 再关;关闭 = pi 收尾退出。写端有界(250×0.2s),不让夹具挂住。
|
|
138
|
+
local proj="$1" prompts="$2" out="$3" err="$4" rec="$5"
|
|
139
|
+
local want i; want="$(grep -c . "$prompts")"
|
|
140
|
+
: > "$out"; : > "$err"
|
|
141
|
+
{
|
|
142
|
+
cat "$prompts"
|
|
143
|
+
for i in $(seq 1 150); do
|
|
144
|
+
[ "$(grep -c '"type":"response"' "$out" 2>/dev/null || true)" -ge "$want" ] && break
|
|
145
|
+
sleep 0.2
|
|
146
|
+
done
|
|
147
|
+
} | ( cd "$proj" && exec env HOME="$proj/home" PI_CODING_AGENT_DIR="$proj/agentdir" TEAM_ASSUME_YES=1 REC_LOG="$rec" \
|
|
148
|
+
timeout --kill-after=5 120 "$PI_BIN" --mode rpc --no-session --approve --session-dir "$proj/sessions" ) > "$out" 2> "$err"
|
|
149
|
+
return $?
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
# 桩日志里含 <pattern>(且不含 <exclude>,给了的话)的那个 BEGIN…END 块(找不到 → 空)
|
|
153
|
+
rec_block() { # <log> <pattern> [exclude]
|
|
154
|
+
awk -v pat="$2" -v exc="${3:-}" '
|
|
155
|
+
/^BEGIN$/ { buf = ""; keep = 0; seen_exc = 0; inblk = 1; next }
|
|
156
|
+
/^END$/ { if (inblk && keep && !seen_exc) { printf "%s", buf }; inblk = 0; next }
|
|
157
|
+
inblk {
|
|
158
|
+
buf = buf $0 "\n"
|
|
159
|
+
if (index($0, pat) > 0) keep = 1
|
|
160
|
+
if (exc != "" && index($0, exc) > 0) seen_exc = 1
|
|
161
|
+
}
|
|
162
|
+
' "$1"
|
|
163
|
+
}
|
|
164
|
+
rec_arg_line() { # <block> <n>(第 n 个 ARG 行,1 起)
|
|
165
|
+
printf '%s\n' "$1" | awk -F'\t' -v n="$2" '$1 == "ARG" { c++; if (c == n) { print $2; exit } }'
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# ---------------------------------------------------------------- 绿侧
|
|
169
|
+
proj="$tmp/proj"
|
|
170
|
+
fixture "$proj" "$ext"
|
|
171
|
+
prompts_for "$tmp/prompts.jsonl"
|
|
172
|
+
rec="$tmp/rec.log"; : > "$rec"
|
|
173
|
+
run_pi "$proj" "$tmp/prompts.jsonl" "$tmp/out.jsonl" "$tmp/err.log" "$rec"
|
|
174
|
+
rc=$?
|
|
175
|
+
out="$(cat "$tmp/out.jsonl" 2>/dev/null)"
|
|
176
|
+
|
|
177
|
+
printf '\n\033[1m== e2e · 真 pi RPC ==\033[0m\n'
|
|
178
|
+
assert_eq "pi RPC 退出码 0(夹具封闭、无模型)" "$rc" "0"
|
|
179
|
+
assert_eq "七条 prompt 都得到成功回执" \
|
|
180
|
+
"$(printf '%s\n' "$out" | grep -c '"type":"response","command":"prompt","success":true')" "7"
|
|
181
|
+
assert_eq "桩被调用了 6 次(表外那条不落桩)" "$(grep -c '^BEGIN$' "$rec" || true)" "6"
|
|
182
|
+
|
|
183
|
+
# ① 短成功 ⇒ 只有 info 通知,不进正文
|
|
184
|
+
notify_version="$(printf '%s\n' "$out" | grep '"type":"extension_ui_request"' | grep -F '0.1.0-stub')"
|
|
185
|
+
assert_has "$notify_version" '"notifyType":"info"' "短成功是 info 通知"
|
|
186
|
+
assert_has "$notify_version" '"message":"0.1.0-stub"' "通知内容就是那一行"
|
|
187
|
+
assert_not "$out" '$ team version' "短成功没有加正文条目"
|
|
188
|
+
|
|
189
|
+
# ② 多行成功 ⇒ 进正文(display:true),命令行 + 退出码 + 输出
|
|
190
|
+
msg_ps="$(printf '%s\n' "$out" | grep '"type":"message_start"' | grep -F 'teamsmith-team' | grep -F '$ team ps')"
|
|
191
|
+
assert_has "$msg_ps" '"display":true' "多行成功的正文 display 打开"
|
|
192
|
+
assert_has "$msg_ps" 'exit 0' "正文写明退出码 0"
|
|
193
|
+
assert_has "$msg_ps" '--- stdout ---' "正文带 stdout 段"
|
|
194
|
+
assert_has "$msg_ps" 'a\nb' "正文带输出"
|
|
195
|
+
|
|
196
|
+
# ③ 桩退出 3 ⇒ error 通知点名 3 + 正文带两路流
|
|
197
|
+
notify_doctor="$(printf '%s\n' "$out" | grep '"type":"extension_ui_request"' | grep -F 'boom' || printf '%s\n' "$out" | grep '"type":"extension_ui_request"' | grep -F 'exit 3' || printf '%s\n' "$out" | grep '"type":"extension_ui_request"' | grep -F '3')"
|
|
198
|
+
assert_has "$notify_doctor" '"notifyType":"error"' "失败是 error 通知"
|
|
199
|
+
assert_has "$notify_doctor" '3' "失败通知点名退出码 3"
|
|
200
|
+
msg_doctor="$(printf '%s\n' "$out" | grep '"type":"message_start"' | grep -F 'teamsmith-team' | grep -F '$ team doctor')"
|
|
201
|
+
assert_has "$msg_doctor" 'exit 3' "失败正文写明退出码 3"
|
|
202
|
+
assert_has "$msg_doctor" '--- stderr ---' "失败正文带 stderr 段"
|
|
203
|
+
assert_has "$msg_doctor" 'boom' "失败正文带 stderr 内容"
|
|
204
|
+
|
|
205
|
+
# ④ 表外命令 ⇒ 拒绝进正文、零子进程
|
|
206
|
+
msg_dispatch="$(printf '%s\n' "$out" | grep '"type":"message_start"' | grep -F 'teamsmith-team' | grep -F 'dispatch')"
|
|
207
|
+
assert_has "$msg_dispatch" 'dispatch' "拒绝文案点名 dispatch"
|
|
208
|
+
assert_has "$msg_dispatch" 'PM' "拒绝文案说明这是 PM / 席位的命令"
|
|
209
|
+
assert_has "$msg_dispatch" '终端' "拒绝文案给出去终端跑的出路"
|
|
210
|
+
assert_eq "表外命令一个子进程都没起(桩日志里没有它)" "$(printf '%s' "$(rec_block "$rec" 'ARG dispatch')" | wc -l | tr -d ' ')" "0"
|
|
211
|
+
|
|
212
|
+
# ⑤ 用户 token 逐字(双引号里的空格是一个 token)
|
|
213
|
+
blk_say="$(rec_block "$rec" 'ARG meeting')"
|
|
214
|
+
assert_eq "meeting say 的 argv 逐字(含 \"two words\")" \
|
|
215
|
+
"$(printf '%s\n' "$blk_say" | awk -F'\t' '$1 == "ARG" { printf "%s|", $2 }')" \
|
|
216
|
+
"meeting|say|alpha|--intent|proposal|two words|"
|
|
217
|
+
|
|
218
|
+
# ⑥ 环境剥离 + 不注入 --yes + cwd = 项目根
|
|
219
|
+
blk_cfg="$(rec_block "$rec" 'ARG config' '--yes')"
|
|
220
|
+
assert_has "$blk_cfg" "ASSUME unset" "会话里的 TEAM_ASSUME_YES 没进子进程"
|
|
221
|
+
assert_has "$blk_cfg" "UPGRADE unset" "TEAM_UPGRADE_CONFIRMED 没进子进程"
|
|
222
|
+
assert_has "$blk_cfg" "FOREIGN unset" "TEAM_ALLOW_FOREIGN_SESSION 没进子进程"
|
|
223
|
+
assert_not "$blk_cfg" "ARG --yes" "没有注入的 --yes"
|
|
224
|
+
assert_eq "升级命令的 argv 逐字" \
|
|
225
|
+
"$(printf '%s\n' "$blk_cfg" | awk -F'\t' '$1 == "ARG" { printf "%s|", $2 }')" \
|
|
226
|
+
"config|upgrade-models|--task-models|routine=vendor/light|--pm-model|vendor/strong|"
|
|
227
|
+
assert_eq "每次调用的 cwd 都是项目根" "$(grep -c "CWD $proj\$" "$rec" || true)" "6"
|
|
228
|
+
# ⑤b 用户自己敲的 --yes 原样过去(前门不自己加,也不自己删)
|
|
229
|
+
blk_yes="$(rec_block "$rec" 'ARG --yes')"
|
|
230
|
+
assert_eq "用户自己的 --yes 逐字过去" \
|
|
231
|
+
"$(printf '%s\n' "$blk_yes" | awk -F'\t' '$1 == "ARG" { printf "%s|", $2 }')" \
|
|
232
|
+
"config|upgrade-models|--task-models|routine=vendor/light|--pm-model|vendor/strong|--yes|"
|
|
233
|
+
|
|
234
|
+
# ⑤c 真 CLI 的那半边(spec 场景点名):会话里没有 --yes 时,升级命令必须由 CLI 自己的守卫决定
|
|
235
|
+
# —— 跑的是本树真 `team`(软链进夹具),断言「dry-run 字样出现在正文」+「config.sh 字节没动」。
|
|
236
|
+
printf '\n\033[1m== e2e · 真 CLI(前门不替 CLI 做决定)\033[0m\n'
|
|
237
|
+
rproj="$tmp/realcli"
|
|
238
|
+
mkdir -p "$rproj/.pi/team" "$rproj/.pi/extensions" "$rproj/.pi/skills" "$rproj/agentdir" "$rproj/home" "$rproj/sessions" "$rproj/docs/team"
|
|
239
|
+
cp "$ext" "$rproj/.pi/extensions/team.ts"
|
|
240
|
+
# 整棵 skill 软链(与真 `team init` 同形):CLI 按 $0 的目录找 lib/,只软链 team 脚本本身会找不到 common.sh。
|
|
241
|
+
ln -s "$tree/skills/teamsmith" "$rproj/.pi/skills/teamsmith"
|
|
242
|
+
cat > "$rproj/.pi/team/config.sh" <<'RCFG'
|
|
243
|
+
TEAM_SESSION=e2e
|
|
244
|
+
TEAM_AGENTS="dev"
|
|
245
|
+
TEAM_DOCS_DIR=docs/team
|
|
246
|
+
TEAM_DEFAULT_MODEL=vendor/old
|
|
247
|
+
TEAM_AGENT_MODELS="dev=vendor/old"
|
|
248
|
+
RCFG
|
|
249
|
+
( cd "$rproj" && git init -q -b main && git -c user.email=e2e@teamsmith -c user.name=e2e add -A && git -c user.email=e2e@teamsmith -c user.name=e2e commit -q -m init ) >/dev/null 2>&1
|
|
250
|
+
rc_before="$(sha256sum "$rproj/.pi/team/config.sh" | cut -d' ' -f1)"
|
|
251
|
+
printf '{"id":"1","type":"prompt","message":"/team config upgrade-models --task-models routine=vendor/light --pm-model vendor/strong"}\n' > "$tmp/realcli-prompts.jsonl"
|
|
252
|
+
# 会话环境里不带 TEAM_*(真 CLI 按目录认项目);不清干净会先撞身份冲突,测不到 dry-run。
|
|
253
|
+
# 会话环境:只剥掉 TEAM_*/TMUX*(真 CLI 按目录认项目);不能用 `env -i` —— 本机 pi 是过 distrobox
|
|
254
|
+
# 回家的 shim,清空环境会 rc=127(“distrobox: not found”)。清干净的会话里 CLI 才不会先撞身份冲突。
|
|
255
|
+
strip=()
|
|
256
|
+
while IFS= read -r v; do strip+=(-u "$v"); done < <(env | sed -n 's/^\(TEAM_[A-Za-z0-9_]*\)=.*/\1/p' | sort -u)
|
|
257
|
+
strip+=(-u TMUX -u TMUX_PANE)
|
|
258
|
+
{
|
|
259
|
+
cat "$tmp/realcli-prompts.jsonl"
|
|
260
|
+
for i in $(seq 1 150); do
|
|
261
|
+
[ "$(grep -c '"type":"response"' "$tmp/realcli-out.jsonl" 2>/dev/null || true)" -ge 1 ] && break
|
|
262
|
+
sleep 0.2
|
|
263
|
+
done
|
|
264
|
+
} | ( cd "$rproj" && exec env "${strip[@]}" HOME="$rproj/home" PI_CODING_AGENT_DIR="$rproj/agentdir" \
|
|
265
|
+
timeout --kill-after=5 120 "$PI_BIN" --mode rpc --no-session --approve --session-dir "$rproj/sessions" ) \
|
|
266
|
+
> "$tmp/realcli-out.jsonl" 2> "$tmp/realcli-err.log"
|
|
267
|
+
rout="$(cat "$tmp/realcli-out.jsonl" 2>/dev/null)"
|
|
268
|
+
rc_after="$(sha256sum "$rproj/.pi/team/config.sh" | cut -d' ' -f1)"
|
|
269
|
+
assert_eq "真 CLI:config.sh 字节没动(前门没替人授权)" "$rc_after" "$rc_before"
|
|
270
|
+
msg_real="$(printf '%s\n' "$rout" | grep '"type":"message_start"' | grep -F 'teamsmith-team' | grep -F '$ team config upgrade-models')"
|
|
271
|
+
assert_has "$msg_real" 'dry-run' "真 CLI:正文里是 CLI 自己的 dry-run 判定(说明真跑到了)"
|
|
272
|
+
assert_has "$msg_real" 'exit 0' "真 CLI:正文写明退出码"
|
|
273
|
+
assert_has "$msg_real" 'TEAM_DEFAULT_MODEL' "真 CLI:正文点名要退役的键"
|
|
274
|
+
assert_not "$msg_real" '身份冲突' "真 CLI:没有先撞身份冲突(测的是产品判定)"
|
|
275
|
+
|
|
276
|
+
# ---------------------------------------------------------------- 翻转:正文落点改成 notify
|
|
277
|
+
if [ "$FLIP" = "1" ]; then
|
|
278
|
+
FLIP_PASS_BEFORE="$PASS"
|
|
279
|
+
printf '\n\033[1m== e2e · flip(正文落点改成 notify)\033[0m\n'
|
|
280
|
+
fproj="$tmp/flip"
|
|
281
|
+
fdir="$tmp/flip-src"; mkdir -p "$fdir"
|
|
282
|
+
fext="$fdir/team.ts"
|
|
283
|
+
python3 - "$ext" "$fext" <<'PY'
|
|
284
|
+
import sys
|
|
285
|
+
src, dst = sys.argv[1], sys.argv[2]
|
|
286
|
+
s = open(src, encoding='utf-8').read()
|
|
287
|
+
old = (" const content = formatEntry(m.tokens, res)\n"
|
|
288
|
+
" deps.sendMessage({ customType: CUSTOM_TYPE, content, display: true })")
|
|
289
|
+
new = (" const content = formatEntry(m.tokens, res)\n"
|
|
290
|
+
" deps.notify(content, 'info')")
|
|
291
|
+
if old not in s:
|
|
292
|
+
print('没找到正文落点(夹具没生效)', file=sys.stderr)
|
|
293
|
+
sys.exit(3)
|
|
294
|
+
open(dst, 'w', encoding='utf-8').write(s.replace(old, new, 1))
|
|
295
|
+
PY
|
|
296
|
+
if [ ! -s "$fext" ]; then
|
|
297
|
+
bad "flip:变异没落地(夹具没生效)"
|
|
298
|
+
else
|
|
299
|
+
fixture "$fproj" "$fext"
|
|
300
|
+
printf '{"id":"1","type":"prompt","message":"/team ps"}\n' > "$tmp/flip-prompts.jsonl"
|
|
301
|
+
frec="$tmp/flip-rec.log"; : > "$frec"
|
|
302
|
+
run_pi "$fproj" "$tmp/flip-prompts.jsonl" "$tmp/flip-out.jsonl" "$tmp/flip-err.log" "$frec"
|
|
303
|
+
fout="$(cat "$tmp/flip-out.jsonl" 2>/dev/null)"
|
|
304
|
+
if printf '%s\n' "$fout" | grep -q '"type":"message_start"'; then
|
|
305
|
+
bad "flip:正文落点改成 notify 之后仍然进了正文(判据没钉住)"
|
|
306
|
+
else
|
|
307
|
+
ok "flip:正文落点改成 notify ⇒ 多行结果不再进正文(判据会红)"
|
|
308
|
+
fi
|
|
309
|
+
if printf '%s\n' "$fout" | grep '"type":"extension_ui_request"' | grep -qF '$ team ps'; then
|
|
310
|
+
ok "flip:结果改走通知(现场证据)"
|
|
311
|
+
else
|
|
312
|
+
bad "flip:结果既没进正文也没进通知"
|
|
313
|
+
fi
|
|
314
|
+
fi
|
|
315
|
+
fi
|
|
316
|
+
|
|
317
|
+
if [ "$FLIP" = "1" ] && [ "$PASS" -le "${FLIP_PASS_BEFORE:-0}" ]; then
|
|
318
|
+
bad "flip:--flip 一轮没有多出任何断言(翻转臂没跑 —— argv 丢了或块没进)"
|
|
319
|
+
fi
|
|
320
|
+
|
|
321
|
+
printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d\n' "$PASS" "$FAIL"
|
|
322
|
+
[ "$FAIL" -eq 0 ] && exit 0
|
|
323
|
+
exit 1
|