teamsmith 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +69 -0
- package/skills/teamsmith/SKILL.md +20 -13
- package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
- 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 +201 -30
- package/skills/teamsmith/references/troubleshooting.md +130 -10
- 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 +182 -32
- package/skills/teamsmith/scripts/lib/cmd-status.sh +234 -21
- 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 +1004 -245
- package/skills/teamsmith/scripts/lib/gate-lock.sh +582 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +211 -211
- package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +12 -5
- package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
- package/skills/teamsmith/scripts/panel/src/data.ts +51 -5
- package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
- package/skills/teamsmith/scripts/panel/src/main.tsx +37 -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/killall +10 -0
- package/skills/teamsmith/scripts/shim/pgrep +10 -0
- package/skills/teamsmith/scripts/shim/pidof +10 -0
- package/skills/teamsmith/scripts/shim/pkill +10 -0
- package/skills/teamsmith/scripts/shim/signal-gate +108 -31
- 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/README.md +31 -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 +83 -54
- package/skills/teamsmith/tests/config-cli.sh +184 -32
- 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-p158.sh +2 -1
- package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
- package/skills/teamsmith/tests/flip-p310-lock.sh +210 -0
- package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
- package/skills/teamsmith/tests/gate-guard.sh +52 -79
- package/skills/teamsmith/tests/help-surface.sh +1664 -0
- package/skills/teamsmith/tests/install-shape.sh +359 -22
- package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
- package/skills/teamsmith/tests/key-replies-ui.sh +2 -8
- package/skills/teamsmith/tests/key-replies.sh +281 -28
- 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/pty-wait.sh +21 -111
- package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
- package/skills/teamsmith/tests/lib/section-guard.sh +316 -164
- 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 +83 -77
- package/skills/teamsmith/tests/panel-b2.sh +430 -352
- package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
- package/skills/teamsmith/tests/panel-b3.sh +314 -62
- package/skills/teamsmith/tests/panel-choices.sh +11 -6
- package/skills/teamsmith/tests/panel-cpu.sh +43 -130
- package/skills/teamsmith/tests/panel-p21.sh +251 -265
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +187 -396
- package/skills/teamsmith/tests/routes.sh +440 -117
- package/skills/teamsmith/tests/seat-interrupt.sh +1012 -0
- package/skills/teamsmith/tests/seat-visibility.sh +675 -0
- package/skills/teamsmith/tests/section-guard.sh +13 -102
- package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
- package/skills/teamsmith/tests/section-paths.tsv +32 -18
- package/skills/teamsmith/tests/section-select.sh +371 -19
- package/skills/teamsmith/tests/signal-gate.sh +249 -27
- package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
- package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
- package/skills/teamsmith/tests/slash-team.sh +617 -0
- package/skills/teamsmith/tests/slice-coverage.sh +206 -0
- package/skills/teamsmith/tests/smoke.sh +3595 -788
- package/skills/teamsmith/tests/task-model-routing.sh +530 -15
- package/skills/teamsmith/tests/team-bg-stop.sh +18 -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/tests/workflow-entry.sh +207 -0
- package/skills/teamsmith-init/SKILL.md +12 -12
- package/skills/teamsmith-init/references/bootstrap.md +3 -3
- package/skills/teamsmith/tests/flip-glue.sh +0 -162
- package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
- package/skills/teamsmith/tests/flip-m12.sh +0 -185
- package/skills/teamsmith/tests/flip-m16.sh +0 -166
- package/skills/teamsmith/tests/flip-m17.sh +0 -204
- package/skills/teamsmith/tests/flip-m34.sh +0 -96
- package/skills/teamsmith/tests/flip-m37.sh +0 -185
- package/skills/teamsmith/tests/flip-m4.3.sh +0 -375
- package/skills/teamsmith/tests/flip-m43.sh +0 -128
- package/skills/teamsmith/tests/flip-m45.sh +0 -244
- package/skills/teamsmith/tests/flip-m46.sh +0 -238
- package/skills/teamsmith/tests/flip-m48.sh +0 -304
- package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
- package/skills/teamsmith/tests/flip-m6.3.sh +0 -283
- package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
- package/skills/teamsmith/tests/flip-m6.5.sh +0 -113
- package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
- package/skills/teamsmith/tests/flip-m7.2.sh +0 -321
- package/skills/teamsmith/tests/flip-p144.sh +0 -112
- package/skills/teamsmith/tests/flip-p156.sh +0 -133
- package/skills/teamsmith/tests/flip-p160.sh +0 -182
- package/skills/teamsmith/tests/flip-p171.sh +0 -249
- package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
- package/skills/teamsmith/tests/flip-p20.sh +0 -286
- package/skills/teamsmith/tests/flip-p201.sh +0 -249
- package/skills/teamsmith/tests/flip-p210.sh +0 -239
- package/skills/teamsmith/tests/flip-p211.sh +0 -152
- package/skills/teamsmith/tests/flip-p217.sh +0 -288
- package/skills/teamsmith/tests/flip-p22.sh +0 -123
- package/skills/teamsmith/tests/flip-p23.sh +0 -239
- package/skills/teamsmith/tests/flip-p25.sh +0 -165
- package/skills/teamsmith/tests/flip-p71.sh +0 -184
- package/skills/teamsmith/tests/flip-p72.sh +0 -202
- package/skills/teamsmith/tests/load-experiment.sh +0 -290
- package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
- package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
- package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
- package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
- package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
- package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
- package/skills/teamsmith/tests/panel-knobs.sh +0 -83
- package/skills/teamsmith/tests/section-budgets.tsv +0 -154
- package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# workflow-entry.sh · CI 入口(`.github/workflows/gates.yml`)的可执行检查(P326)
|
|
3
|
+
#
|
|
4
|
+
# 为什么有这个文件:`gates.yml` 那条路径原先**没有任何段读它、也没有任何行声明它** —— 改一次 CI 入口
|
|
5
|
+
# 就是 `decision=FULL`(整套,含 §61b 的 4946 s),而它恰恰是本 change 自己改的文件。这个脚本把
|
|
6
|
+
# 2026-10-20 C4 里**已经真跑过**的那次宿主侧检查固化成可重跑的入口:它执行的是工作流**自己的**
|
|
7
|
+
# `run:` 块(不是对 YAML 的再解释),只把两个 GitHub 表达式换成环境值、把 `docker` 换成记录 argv 的桩。
|
|
8
|
+
#
|
|
9
|
+
# 只验三件已经成立过的行为(不建解析框架、不建矩阵):
|
|
10
|
+
# ① 有效基点 + 特殊文件名(换行 / 空格 / 引号+反斜杠)→ 路径逐字节到达容器的套件参数,
|
|
11
|
+
# 且容器命令里带 `--floor --paths "$@"`;
|
|
12
|
+
# ② 基点不可解析(空 / 全零 / 不在仓里)→ 一条 `::warning::` + 退回**全套**(命令里没有 `--floor`);
|
|
13
|
+
# ③ 底层执行失败(docker rc≠0)→ 这一步照旧非 0(失败不被 `|| true` 之类吞掉)。
|
|
14
|
+
#
|
|
15
|
+
# 用法:
|
|
16
|
+
# bash skills/teamsmith/tests/workflow-entry.sh [--tree <仓库根>]
|
|
17
|
+
# 退出码:
|
|
18
|
+
# 0 = 三条行为都成立;1 = 有不成立项(逐条 ✗ 并点名);2 = 缺前提(打印 SKIP(条件不满足)——
|
|
19
|
+
# **跳过不是通过**):检出里没有 `.github/workflows/gates.yml`(产品面检出不含 CI 源码)或宿主没有 git。
|
|
20
|
+
# 不写工作树:全部落在 $TMPDIR 下的私有根里,退出时删掉自己的根(失败可 TEAM_TMP_KEEP=1 保留现场)。
|
|
21
|
+
set -uo pipefail
|
|
22
|
+
|
|
23
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
24
|
+
ROOT_ARG=""
|
|
25
|
+
while [ $# -gt 0 ]; do
|
|
26
|
+
case "$1" in
|
|
27
|
+
--tree) shift; [ $# -gt 0 ] || { printf 'workflow-entry: --tree 需要一条路径\n' >&2; exit 2; }; ROOT_ARG="$1"; shift ;;
|
|
28
|
+
-h|--help) sed -n '2,25p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
29
|
+
*) printf 'workflow-entry: 未知参数 %s\n' "$1" >&2; exit 2 ;;
|
|
30
|
+
esac
|
|
31
|
+
done
|
|
32
|
+
|
|
33
|
+
c_ok=0; c_bad=0; c_skip=0
|
|
34
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$*"; c_ok=$((c_ok + 1)); }
|
|
35
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$*"; c_bad=$((c_bad + 1)); }
|
|
36
|
+
skip() { printf ' \033[33mSKIP(条件不满足)\033[0m %s(跳过不是通过)\n' "$*"; c_skip=$((c_skip + 1)); }
|
|
37
|
+
summary() { # 收口:0 全绿 / 1 有红 / 2 只有跳过(没结论,不算通过)
|
|
38
|
+
printf '== workflow-entry == ok %s bad %s skip %s\n' "$c_ok" "$c_bad" "$c_skip"
|
|
39
|
+
[ "$c_bad" -eq 0 ] || return 1
|
|
40
|
+
[ "$c_skip" -eq 0 ] || [ "$c_ok" -gt 0 ] || return 2
|
|
41
|
+
return 0
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if [ -n "$ROOT_ARG" ]; then TREE="$(cd "$ROOT_ARG" 2>/dev/null && pwd)" || { skip "workflow-entry:--tree $ROOT_ARG 不存在"; summary; exit $?; }
|
|
45
|
+
else TREE="$(cd -P "$SELF_DIR/../../.." && pwd)"; fi
|
|
46
|
+
WF="$TREE/.github/workflows/gates.yml"
|
|
47
|
+
if ! command -v git >/dev/null 2>&1; then skip "workflow-entry:宿主没有 git(这条检查要建一个临时仓库)"; summary; exit $?; fi
|
|
48
|
+
if [ ! -f "$WF" ]; then
|
|
49
|
+
skip "workflow-entry:检出里没有 .github/workflows/gates.yml(产品面检出不含 CI 源码,$TREE)"
|
|
50
|
+
summary; exit $?
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
TMP="$(mktemp -d "${TMPDIR:-/var/tmp}/teamsmith-wfentry.XXXXXX")" || { skip "workflow-entry:建不了临时根"; summary; exit $?; }
|
|
54
|
+
cleanup() {
|
|
55
|
+
if [ "${TEAM_TMP_KEEP:-0}" = "1" ]; then
|
|
56
|
+
printf 'workflow-entry:保留现场 %s(TEAM_TMP_KEEP=1)\n' "$TMP"
|
|
57
|
+
return 0
|
|
58
|
+
fi
|
|
59
|
+
# 删不掉要出声:无名吞掉会让下一次运行踩着一个半截根继续(而且没人知道)。
|
|
60
|
+
if ! rm -rf "$TMP"; then
|
|
61
|
+
printf 'workflow-entry:⚠ 临时根删不掉,请手动清理:%s\n' "$TMP" >&2
|
|
62
|
+
fi
|
|
63
|
+
}
|
|
64
|
+
trap cleanup EXIT
|
|
65
|
+
|
|
66
|
+
# ── 从工作流里取出这一步的 `run:` 块原文(缩进 10 空格 → 去掉 10 空格)──────────────────────────────
|
|
67
|
+
# 只按行首缩进与步骤头切一次:不做 YAML 解析,也不跨步骤猜结构。
|
|
68
|
+
BLOCK="$TMP/run-block.sh"
|
|
69
|
+
awk '
|
|
70
|
+
/^ - name: Gates \(pinned container\)/ { inside = 1; next }
|
|
71
|
+
inside && /^ run: \|$/ { body = 1; next }
|
|
72
|
+
body && /^ - name:/ { exit }
|
|
73
|
+
body { sub(/^ /, ""); print }
|
|
74
|
+
' "$WF" > "$BLOCK"
|
|
75
|
+
if [ ! -s "$BLOCK" ]; then
|
|
76
|
+
bad "workflow-entry:工作流里找不到「Gates (pinned container)」这一步的 run 块(入场形状变了?)"
|
|
77
|
+
summary; exit $?
|
|
78
|
+
fi
|
|
79
|
+
if ! grep -qF 'smoke.sh' "$BLOCK"; then
|
|
80
|
+
bad "workflow-entry:取出的 run 块里没有调用 smoke.sh(切错步骤了?)"
|
|
81
|
+
summary; exit $?
|
|
82
|
+
fi
|
|
83
|
+
# 两个 GitHub 表达式换成环境值:这是**唯一**的改写(真实取值只可能来自 runner)。
|
|
84
|
+
sed -i 's|BASE="\${{ github.event.before }}"|BASE="${GH_BEFORE:-}"|; s|TIP="\${{ github.sha }}"|TIP="${GH_TIP:-}"|' "$BLOCK"
|
|
85
|
+
if grep -qF '${{' "$BLOCK"; then
|
|
86
|
+
bad "workflow-entry:run 块里还有没被替换的 \${{ … }} 表达式(这一层不认识它)"
|
|
87
|
+
summary; exit $?
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# ── docker 桩:只记录 argv(NUL 分隔,逐字节),按 STUB_RC 返回 ─────────────────────────────────
|
|
91
|
+
STUB="$TMP/bin"; mkdir -p "$STUB"
|
|
92
|
+
cat > "$STUB/docker" <<'EOS'
|
|
93
|
+
#!/usr/bin/env bash
|
|
94
|
+
[ "${1:-}" = "rm" ] && exit 0
|
|
95
|
+
: > "$DOCKER_ARGV"
|
|
96
|
+
for a in "$@"; do printf '%s\0' "$a" >> "$DOCKER_ARGV"; done
|
|
97
|
+
printf 'STUB docker %s args\n' "$#"
|
|
98
|
+
exit "${STUB_RC:-0}"
|
|
99
|
+
EOS
|
|
100
|
+
chmod +x "$STUB/docker"
|
|
101
|
+
|
|
102
|
+
run_block() { # <argv 日志> <stub rc> <before> <sha> → 跑一次工作流的 run 块
|
|
103
|
+
local log="$1" rc="$2" before="$3" sha="$4"
|
|
104
|
+
( cd "$REPO" && PATH="$STUB:$PATH" DOCKER_ARGV="$log" STUB_RC="$rc" \
|
|
105
|
+
GH_BEFORE="$before" GH_TIP="$sha" TEAM_CI_TMP_ROOT="$TMP/ci-tmp" \
|
|
106
|
+
bash "$BLOCK" )
|
|
107
|
+
}
|
|
108
|
+
argv_field() { # <argv 日志> <下标> → 第 N 个参数(NUL 分隔,逐字节)
|
|
109
|
+
local log="$1" want="$2" i=0 a
|
|
110
|
+
while IFS= read -r -d '' a; do
|
|
111
|
+
[ "$i" = "$want" ] && { printf '%s' "$a"; return 0; }
|
|
112
|
+
i=$((i + 1))
|
|
113
|
+
done < "$log"
|
|
114
|
+
return 1
|
|
115
|
+
}
|
|
116
|
+
argv_index_of() { # <argv 日志> <精确值> → 下标(用于找 `_` 这类固定占位符)
|
|
117
|
+
local log="$1" want="$2" i=0 a
|
|
118
|
+
while IFS= read -r -d '' a; do
|
|
119
|
+
[ "$a" = "$want" ] && { printf '%s' "$i"; return 0; }
|
|
120
|
+
i=$((i + 1))
|
|
121
|
+
done < "$log"
|
|
122
|
+
return 1
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# ── ① 有效基点 + 特殊文件名:路径逐字节到达容器的套件参数 ───────────────────────────────────────
|
|
126
|
+
REPO="$TMP/repo"; mkdir -p "$REPO/skills/teamsmith/tests"
|
|
127
|
+
cp "$WF" "$REPO/gates.yml" # 只为让临时仓库里有一个受版本控制的文件
|
|
128
|
+
git -C "$REPO" init -q -b main
|
|
129
|
+
git -C "$REPO" -c user.email=wfentry@example.invalid -c user.name=wfentry add -A
|
|
130
|
+
git -C "$REPO" -c user.email=wfentry@example.invalid -c user.name=wfentry commit -qm base
|
|
131
|
+
B1="$(git -C "$REPO" rev-parse HEAD)"
|
|
132
|
+
ODD1="$REPO/odd line"$'\n'"break.sh"
|
|
133
|
+
ODD2="$REPO/odd space name.sh"
|
|
134
|
+
ODD3="$REPO/odd quote\"and\\backslash.sh"
|
|
135
|
+
: > "$ODD1"; : > "$ODD2"; : > "$ODD3"
|
|
136
|
+
git -C "$REPO" -c user.email=wfentry@example.invalid -c user.name=wfentry add -A
|
|
137
|
+
git -C "$REPO" -c user.email=wfentry@example.invalid -c user.name=wfentry commit -qm odd
|
|
138
|
+
T1="$(git -C "$REPO" rev-parse HEAD)"
|
|
139
|
+
|
|
140
|
+
run_block "$TMP/argv-valid.bin" 0 "$B1" "$T1" > "$TMP/valid.out" 2>&1
|
|
141
|
+
RC1=$?
|
|
142
|
+
if [ "$RC1" -ne 0 ]; then
|
|
143
|
+
bad "workflow-entry ①:有效基点时这一步退非 0(rc=$RC1)"
|
|
144
|
+
sed 's/^/ /' "$TMP/valid.out" | head -5
|
|
145
|
+
else
|
|
146
|
+
ok "workflow-entry ①:有效基点时这一步退出 0"
|
|
147
|
+
fi
|
|
148
|
+
CMD="$(argv_field "$TMP/argv-valid.bin" "$(( $(argv_index_of "$TMP/argv-valid.bin" teamsmith-gates:ci) + 3 ))")"
|
|
149
|
+
case "$CMD" in
|
|
150
|
+
*'smoke.sh --floor'*'--paths "$@"'*) ok 'workflow-entry ①:容器命令带 `--floor` 与 `--paths "$@"`(不是全套、也不会丢路径)' ;;
|
|
151
|
+
*) bad "workflow-entry ①:容器命令不是 --floor --paths 形状(实际:${CMD:0:160})" ;;
|
|
152
|
+
esac
|
|
153
|
+
US="$(argv_index_of "$TMP/argv-valid.bin" _)"
|
|
154
|
+
if [ -z "$US" ]; then
|
|
155
|
+
bad 'workflow-entry ①:容器命令里没有 `_`(bash -c 的 $0 占位)—— 路径不是作为参数交进去的'
|
|
156
|
+
else
|
|
157
|
+
n=0; : > "$TMP/got.raw"
|
|
158
|
+
i=$((US + 1))
|
|
159
|
+
# argv_field 在下标越界时只 return 1、不打印(这里的 stderr 是空的);循环条件就是它的退出码。
|
|
160
|
+
while a="$(argv_field "$TMP/argv-valid.bin" "$i" 2>/dev/null)" && [ -n "$a" ]; do
|
|
161
|
+
printf '%s\0' "$a" >> "$TMP/got.raw"; n=$((n + 1)); i=$((i + 1))
|
|
162
|
+
done
|
|
163
|
+
# 期望集合 = git 眼里的这三个路径(逐字节),排序后逐字节比对:顺序无所谓,字节必须一样。
|
|
164
|
+
: > "$TMP/want.raw"
|
|
165
|
+
while IFS= read -r -d '' p; do printf '%s\0' "$p" >> "$TMP/want.raw"; done \
|
|
166
|
+
< <(git -C "$REPO" diff --name-only -z "$B1" "$T1")
|
|
167
|
+
sort -z "$TMP/got.raw" > "$TMP/got.sorted" 2>/dev/null
|
|
168
|
+
sort -z "$TMP/want.raw" > "$TMP/want.sorted" 2>/dev/null
|
|
169
|
+
if [ "$n" = "3" ] && cmp -s "$TMP/got.sorted" "$TMP/want.sorted"; then
|
|
170
|
+
ok "workflow-entry ①:3 条特殊文件名(换行 / 空格 / 引号+反斜杠)逐字节到达容器参数(cmp 一致)"
|
|
171
|
+
else
|
|
172
|
+
bad "workflow-entry ①:特殊文件名没有逐字节到达(收到 $n 条,cmp 不一致)"
|
|
173
|
+
printf ' 收到:\n'; tr '\0' '\n' < "$TMP/got.raw" | sed 's/^/ |/'
|
|
174
|
+
printf ' 期望:\n'; tr '\0' '\n' < "$TMP/want.raw" | sed 's/^/ |/'
|
|
175
|
+
fi
|
|
176
|
+
fi
|
|
177
|
+
|
|
178
|
+
# ── ② 基点不可解析 → 一条 warning + 退回全套(命令里没有 --floor)────────────────────────────────
|
|
179
|
+
for badbase in "" "0000000000000000000000000000000000000000" "no-such-sha-$$"; do
|
|
180
|
+
tag="${badbase:-空}"
|
|
181
|
+
run_block "$TMP/argv-bad.bin" 0 "$badbase" "$T1" > "$TMP/bad.out" 2>&1
|
|
182
|
+
RC2=$?
|
|
183
|
+
CMD2="$(argv_field "$TMP/argv-bad.bin" "$(( $(argv_index_of "$TMP/argv-bad.bin" teamsmith-gates:ci 2>/dev/null || printf 0) + 3 ))")"
|
|
184
|
+
# 「退回全套」要**正向确认**:命令里必须真的以完整入口跑起来(`bash skills/teamsmith/tests/smoke.sh --keep`
|
|
185
|
+
# + 前面的 openspec 校验),不能只看「缺了 --floor」—— 命令为空时那个条件也成立。
|
|
186
|
+
case "$CMD2" in
|
|
187
|
+
*'openspec validate --all --strict'*'bash skills/teamsmith/tests/smoke.sh --keep '*) _runs_full=1 ;;
|
|
188
|
+
*) _runs_full=0 ;;
|
|
189
|
+
esac
|
|
190
|
+
if [ "$RC2" -eq 0 ] && grep -qF '::warning::changed-path base is unresolvable' "$TMP/bad.out" \
|
|
191
|
+
&& [ "$_runs_full" = 1 ] && ! printf '%s' "$CMD2" | grep -qF -- '--floor'; then
|
|
192
|
+
ok "workflow-entry ②:基点不可解析($tag)→ ::warning:: + 正向确认执行完整入口(openspec 校验 + smoke.sh --keep,且没有 --floor)"
|
|
193
|
+
else
|
|
194
|
+
bad "workflow-entry ②:基点不可解析($tag)没有正向确认退回完整入口(rc=$RC2,入口在=$_runs_full,命令:${CMD2:0:120})"
|
|
195
|
+
fi
|
|
196
|
+
done
|
|
197
|
+
|
|
198
|
+
# ── ③ 底层执行失败 → 这一步照旧非 0(失败不被吞)────────────────────────────────────────────────
|
|
199
|
+
run_block "$TMP/argv-fail.bin" 5 "$B1" "$T1" > "$TMP/fail.out" 2>&1
|
|
200
|
+
RC3=$?
|
|
201
|
+
if [ "$RC3" -ne 0 ]; then
|
|
202
|
+
ok "workflow-entry ③:容器执行失败(stub rc=5)→ 这一步非 0(rc=$RC3),失败没被吞"
|
|
203
|
+
else
|
|
204
|
+
bad "workflow-entry ③:容器执行失败后这一步仍退 0(失败被吞了)"
|
|
205
|
+
fi
|
|
206
|
+
|
|
207
|
+
summary
|
|
@@ -3,7 +3,7 @@ name: teamsmith-init
|
|
|
3
3
|
description: teamsmith-init is the new-project entry point of the teamsmith toolkit — organize multiple agents into a team, set up an agent collaboration protocol, and bootstrap this skill into a new project. It walks the questions to settle with the user first (dependencies, session and roster, the task-category mapping and the independent PM model, gates, VCS mode, install command, and the project's ROADMAP/OWNERSHIP/AGENTS.md red lines), then runs the one command that writes `.pi/team/config.sh` + the `docs/team/` skeleton + the `AGENTS.md` protocol section and starts the pulse, and finally hands day-to-day operation to the `teamsmith` skill. Use when the user wants to bootstrap teamsmith into a new repository, set up a brand-new team, organize multiple agents into a team, or set up an agent collaboration protocol where none exists yet.
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
|
-
version: "0.
|
|
6
|
+
version: "0.3.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# teamsmith-init · bring a new project to "ready to dispatch"
|
|
@@ -14,17 +14,15 @@ with the user, run one command, then hand day-to-day operation to the **`teamsmi
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npm install -g teamsmith # the `team` CLI (one npm bin entry; it checks bash >= 5 and prints the fix)
|
|
17
|
-
team init # in this project: config + docs skeleton + the skills
|
|
17
|
+
team init # in this project: config + docs skeleton + the skills and the /team extension
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
`team init` installs both skills into the project's **`.pi/skills/`** (Pi's project-level search path)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
is not your route: `pi install …` at a released tag (no global CLI) and `./install.sh` from a checkout (writes
|
|
27
|
-
into `~/.agents/skills`). Everything after setup (dispatch, the pulse, review, merge) belongs to the daily skill.
|
|
20
|
+
`team init` installs both skills into the project's **`.pi/skills/`** (Pi's project-level search path) and the
|
|
21
|
+
`/team` extension into **`.pi/extensions/`**; the default is a symlink to the package, `--copy` copies, `--no-skills`
|
|
22
|
+
skips both. Because both are project resources Pi asks about, the **first interactive `pi` run shows a
|
|
23
|
+
project-trust prompt** — one line names the answers: `pi --approve`, `/trust` in Pi, `team init --no-skills`.
|
|
24
|
+
Alternatives to npm: `pi install …` at a released tag, `./install.sh` from a checkout. Everything after setup
|
|
25
|
+
(dispatch, the pulse, review, merge) belongs to the daily skill.
|
|
28
26
|
|
|
29
27
|
## 1. Settle these with the user, in this order
|
|
30
28
|
|
|
@@ -68,8 +66,10 @@ into `~/.agents/skills`). Everything after setup (dispatch, the pulse, review, m
|
|
|
68
66
|
|
|
69
67
|
Fresh projects must pass both model inputs (`--task-models`, `--pm-model`); a valid v2 policy is kept on
|
|
70
68
|
re-entry. A **legacy** config (retired TEAM_AGENT_MODELS / TEAM_DEFAULT_MODEL) is refused before any
|
|
71
|
-
install/ledger/worktree/pulse work and migrates
|
|
72
|
-
|
|
69
|
+
install/ledger/worktree/pulse work and migrates on the next `team up` (the startup transaction derives the
|
|
70
|
+
category pairs from the old keys, prints them, backs the file up and re-enters itself) or through the explicit
|
|
71
|
+
`team config upgrade-models --task-models '<map>' --pm-model '<model>'` transaction; `bootstrap`, `init --force`
|
|
72
|
+
and inference are not migration routes.
|
|
73
73
|
|
|
74
74
|
`bootstrap` is idempotent (a rerun fills in what is missing and leaves the rest alone, including the project's
|
|
75
75
|
`.pi/skills/` install — that is the upgrade route for a project set up before this skill version) and it
|
|
@@ -23,12 +23,12 @@ Or hand the contents of `templates/bootstrap-prompt.md.tmpl` (placeholders subst
|
|
|
23
23
|
|---|---|---|
|
|
24
24
|
| Detect tmux | adopts the `session:window` the PM itself runs in and writes it into the config (no manual fill-in) | recomputed every run |
|
|
25
25
|
| Write config | `.pi/team/config.sh` (identity/roster/**task-category model map + independent PM model**/gates/install command/forge/guards/pulse) | if it exists it is kept; only missing entries are filled in |
|
|
26
|
-
| Model policy | fresh runs must pass `--task-models` and `--pm-model` (there is no default model); a valid v2 policy is kept on re-entry; a config still carrying the retired worker keys is refused **before** any install/ledger/worktree/pulse step and migrates
|
|
26
|
+
| Model policy | fresh runs must pass `--task-models` and `--pm-model` (there is no default model); a valid v2 policy is kept on re-entry; a config still carrying the retired worker keys is refused **before** any install/ledger/worktree/pulse step and migrates on the next `team up` (the startup transaction) or through the explicit `team config upgrade-models` transaction | ✔ |
|
|
27
27
|
| Required dependencies | checks magic-context (Pi package `@cortexkit/pi-magic-context`) and OpenSpec (CLI resolvable + the spec dir); a missing one prints its exact fix/downgrade command, and does not block the setup | ✔ |
|
|
28
28
|
| Docs skeleton | `docs/team/{ROADMAP,BOARD,OWNERSHIP,DECISIONS,PROTOCOL}.md`, `tasks/`, `reports/`, `reviews/`, `threads/`, `inbox/` | skipped when present |
|
|
29
29
|
| Team protocol | injects the `<!-- teamsmith:begin --> … end -->` section into `AGENTS.md` (**refreshes** it instead of appending twice) | ✔ |
|
|
30
|
-
| `.gitignore` | `.pi/team/state/`, `docs/team/inbox/`, `docs/team/reviews/*.log`, `.worktrees/`, `.pi/skills/` | ✔ |
|
|
31
|
-
| Project skills | installs the running skills (`teamsmith`, and `teamsmith-init` when present) into the project's `.pi/skills/` — link by default, `--copy` for an ephemeral source; one line per
|
|
30
|
+
| `.gitignore` | `.pi/team/state/`, `docs/team/inbox/`, `docs/team/reviews/*.log`, `.worktrees/`, `.pi/skills/`, `.pi/extensions/` | ✔ |
|
|
31
|
+
| Project skills and the `/team` extension | installs the running skills (`teamsmith`, and `teamsmith-init` when present) into the project's `.pi/skills/` and the running CLI's own `extension/team.ts` into `.pi/extensions/team.ts` — link by default, `--copy` for an ephemeral source; one line per entry; because `.pi/skills/` and `.pi/extensions/` are resources Pi asks about, the step also prints one line naming the project-trust prompt the first interactive `pi` run will show and its answers (`pi --approve` for a single run, `/trust` in Pi to save, `team init --no-skills` to skip both); a conflict is announced with its routes and never replaced silently, and an unmarked regular file is never deleted even with `--force` | a rerun `skip`s what is already right, and says the trust line again; this runs even when the config already exists (the upgrade path) |
|
|
32
32
|
| Agent worktrees | one long-lived `.worktrees/<agent>` per roster member (branch `agent/<agent>`), installing dependencies when `TEAM_INSTALL_CMD` is set | skipped when present |
|
|
33
33
|
| Pulse | `team pulse up`: a `pulse` window in the same session runs the monitor (patrolling every 15 minutes by default) | skipped when already running |
|
|
34
34
|
| Checklist | prints "what next" (ROADMAP/OWNERSHIP → first task → dispatch → digest) | — |
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# teamsmith · 翻转夹具(delivery-guard 的 red → green 证据;P6 任务 0.1)
|
|
3
|
-
#
|
|
4
|
-
# bash tests/flip-glue.sh # 用本树的 skill(有守卫 → 必须绿)
|
|
5
|
-
# bash tests/flip-glue.sh --skill <另一棵树>/skills/teamsmith # 指定别的树(pre-change → 必须红)
|
|
6
|
-
# bash tests/flip-glue.sh --keep # 保留临时目录排查
|
|
7
|
-
#
|
|
8
|
-
# 场景(D20,E3 §1.1(e) 的实测复现):
|
|
9
|
-
# 假 TUI 的输入框里已经有人写了半句草稿,然后一条自动化消息(watchdog/notify 那一类)投递一次。
|
|
10
|
-
# pre-change(没有守卫):`send-keys -l` + Enter 把草稿和消息拼成**一条提交**,草稿离开输入框 → 红。
|
|
11
|
-
# 带守卫:一个键都不写,消息进 state/outbox/,草稿原样留在输入框里 → 绿。
|
|
12
|
-
#
|
|
13
|
-
# 退出码:0 = 绿(守卫生效)|1 = 红(复现了粘连)|2 = 环境缺依赖(不算绿,也不假装红)。
|
|
14
|
-
#
|
|
15
|
-
# 隔离(M7.2 教训):全部在临时仓库 + 临时 tmux session 里跑,继承的 TEAM_* 一律清掉,
|
|
16
|
-
# 写任何东西之前先断言 `team paths` 指向临时根;调用方项目的 inbox/state 前后哈希必须一致。
|
|
17
|
-
set -uo pipefail
|
|
18
|
-
|
|
19
|
-
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
20
|
-
FIXTURE_TUI="$SELF_DIR/fake-tui.py"
|
|
21
|
-
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
22
|
-
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
23
|
-
. "$SELF_DIR/lib/tmp-root.sh"
|
|
24
|
-
# P162:破坏性调用(kill-server/kill-session/kill-window)动手前先证明私有 socket 生效
|
|
25
|
-
. "$SELF_DIR/lib/tmux-iso.sh"
|
|
26
|
-
KEEP=0
|
|
27
|
-
while [ $# -gt 0 ]; do
|
|
28
|
-
case "$1" in
|
|
29
|
-
--skill) SKILL_DIR="${2:?--skill 需要目录}"; shift 2 ;;
|
|
30
|
-
--skill=*) SKILL_DIR="${1#*=}"; shift ;;
|
|
31
|
-
--keep) KEEP=1; shift ;;
|
|
32
|
-
-h|--help) sed -n '2,20p' "$0"; exit 0 ;;
|
|
33
|
-
*) printf 'flip-glue: 未知参数 %s\n' "$1" >&2; exit 2 ;;
|
|
34
|
-
esac
|
|
35
|
-
done
|
|
36
|
-
TEAM_CLI="$SKILL_DIR/scripts/team"
|
|
37
|
-
[ -f "$TEAM_CLI" ] || { printf 'flip-glue: 找不到 %s\n' "$TEAM_CLI" >&2; exit 2; }
|
|
38
|
-
command -v tmux >/dev/null 2>&1 || { printf 'flip-glue: 需要 tmux\n' >&2; exit 2; }
|
|
39
|
-
command -v python3 >/dev/null 2>&1 || { printf 'flip-glue: 需要 python3(夹具 TUI)\n' >&2; exit 2; }
|
|
40
|
-
|
|
41
|
-
DRAFT='半截草稿 half a sentence'
|
|
42
|
-
NOTICE='[watchdog] 待办:验 V9.9'
|
|
43
|
-
|
|
44
|
-
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
45
|
-
SB="$(tmp_root_create flip-glue)" || exit 3
|
|
46
|
-
REPO="$SB/repo"
|
|
47
|
-
SESSION="teamsmith-flip-$$"
|
|
48
|
-
SUBMIT_LOG="$SB/submit.log"
|
|
49
|
-
: > "$SUBMIT_LOG"
|
|
50
|
-
|
|
51
|
-
# M28:本夹具自己的 tmux 流量也必须有隔离证据 —— 顶层 unset TMUX + 私有 TMUX_TMPDIR。
|
|
52
|
-
# 不隔离的话,下面每一发裸 `tmux` 都会按 `$TMUX` 打到调用者的 server(M23 事故形状);
|
|
53
|
-
# 判定口径见 tests/tmux-lint.pl(口径 A–D),门禁会扫这一条。
|
|
54
|
-
unset TMUX TMUX_PANE 2>/dev/null || true
|
|
55
|
-
TMUX_TMPDIR="$SB/tmux"; mkdir -p "$TMUX_TMPDIR"; export TMUX_TMPDIR
|
|
56
|
-
|
|
57
|
-
# 调用方项目(真仓库)的收件箱/状态指纹:夹具绝不允许碰它们
|
|
58
|
-
REAL_MAIN="$(git -C "$PWD" rev-parse --path-format=absolute --git-common-dir 2>/dev/null | xargs -r dirname || true)"
|
|
59
|
-
real_fp() { # <根> → 目录指纹(不存在也算一个值)
|
|
60
|
-
local r="$1" out=""
|
|
61
|
-
[ -n "$r" ] || { printf 'none'; return 0; }
|
|
62
|
-
for d in "$r/docs/team/inbox" "$r/.pi/team/state"; do
|
|
63
|
-
if [ -d "$d" ]; then
|
|
64
|
-
out="$out$(cd "$d" && find . -type f 2>/dev/null | sort | while IFS= read -r f; do printf '%s ' "$f"; md5sum "$f" 2>/dev/null | cut -d' ' -f1; done | md5sum)"
|
|
65
|
-
else
|
|
66
|
-
out="$out missing"
|
|
67
|
-
fi
|
|
68
|
-
done
|
|
69
|
-
printf '%s' "$out" | md5sum | cut -d' ' -f1
|
|
70
|
-
}
|
|
71
|
-
REAL_BEFORE="$(real_fp "$REAL_MAIN")"
|
|
72
|
-
|
|
73
|
-
cleanup() {
|
|
74
|
-
# P162:收尾先证明私有 socket 生效(不成立就拒绝;cleanup 里不许 exit)
|
|
75
|
-
tmux_iso_guard_soft "flip-glue" "收尾:私有 session" --tmpdir "${TMUX_TMPDIR:-}" --own-root "$SB" \
|
|
76
|
-
&& tmux kill-session -t "$SESSION" 2>/dev/null || true
|
|
77
|
-
if [ "$KEEP" = "1" ]; then printf '保留临时目录:%s\n' "$SB"
|
|
78
|
-
else tmp_root_reap_all; fi
|
|
79
|
-
}
|
|
80
|
-
trap cleanup EXIT
|
|
81
|
-
|
|
82
|
-
fail() { printf '\033[31m✗\033[0m %s\n' "$*"; }
|
|
83
|
-
pass() { printf '\033[32m✓\033[0m %s\n' "$*"; }
|
|
84
|
-
|
|
85
|
-
mkdir -p "$REPO"
|
|
86
|
-
( cd "$REPO" && git init -q -b main && git config user.email flip@teamsmith && git config user.name flip \
|
|
87
|
-
&& echo hi > README.md && git add -A && git commit -qm init ) >/dev/null 2>&1 || { fail "临时仓库初始化失败"; exit 2; }
|
|
88
|
-
|
|
89
|
-
# 清掉继承的团队身份:夹具只服务自己的临时仓库
|
|
90
|
-
TEAMENV=(env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_ROOT_SOURCE -u TEAM_ROOT_WAS -u TEAM_PROJECT
|
|
91
|
-
-u TEAM_SESSION -u TEAM_SESSION_FROM -u TEAM_PM_WINDOW -u TEAM_AGENTS -u TEAM_DOCS_DIR
|
|
92
|
-
-u TEAM_WORKTREES_DIR -u TEAM_GATES -u TEAM_VCS -u TEAM_CONFIG_FILE -u TEAM_STATE_DIR
|
|
93
|
-
-u TEAM_ALLOW_FOREIGN_SESSION -u TEAM_DEFER_TTL -u TEAM_OUTBOX_MAX)
|
|
94
|
-
|
|
95
|
-
( cd "$REPO" && "${TEAMENV[@]}" bash "$TEAM_CLI" init --session "$SESSION" --agents "dev" --vcs local \
|
|
96
|
-
--gates "true" --docs docs/team ) >"$SB/init.log" 2>&1 \
|
|
97
|
-
|| { fail "team init 失败($SB/init.log)"; cat "$SB/init.log"; exit 2; }
|
|
98
|
-
|
|
99
|
-
# 写任何东西之前:team paths 必须指向临时根(否则夹具会污染真项目)
|
|
100
|
-
PATHS="$( cd "$REPO" && "${TEAMENV[@]}" bash "$TEAM_CLI" paths 2>/dev/null )"
|
|
101
|
-
case "$PATHS" in
|
|
102
|
-
*"\"main_root\": \"$REPO\""*) pass "隔离:team paths 指向临时根($REPO)" ;;
|
|
103
|
-
*) fail "隔离失败:team paths 不是临时根 —— $PATHS"; exit 2 ;;
|
|
104
|
-
esac
|
|
105
|
-
|
|
106
|
-
# 夹具 pane:输入框里已经有草稿
|
|
107
|
-
tmux_iso_require "flip-glue" "重建私有 session 前收掉旧的" --tmpdir "${TMUX_TMPDIR:-}" --own-root "$SB"
|
|
108
|
-
tmux kill-session -t "$SESSION" 2>/dev/null || true
|
|
109
|
-
tmux new-session -d -s "$SESSION" -n pm -x 100 -y 24 -c "$REPO" || { fail "建 tmux session 失败"; exit 2; }
|
|
110
|
-
tmux new-window -d -t "$SESSION" -n dev -c "$REPO" \
|
|
111
|
-
"FAKE_TUI_DRAFT='$DRAFT' FAKE_TUI_COLS=100 FAKE_TUI_SUBMIT_LOG='$SUBMIT_LOG' python3 '$FIXTURE_TUI'" \
|
|
112
|
-
|| { fail "建夹具 pane 失败"; exit 2; }
|
|
113
|
-
sleep 1
|
|
114
|
-
|
|
115
|
-
# 投递一条自动化消息(走 say:pre-change 与 branch 的实现差异就在这里)
|
|
116
|
-
( cd "$REPO" && "${TEAMENV[@]}" bash "$TEAM_CLI" say dev "$NOTICE" ) >"$SB/say.log" 2>&1 || true
|
|
117
|
-
sleep 0.5
|
|
118
|
-
|
|
119
|
-
SUBMITS="$(cat "$SUBMIT_LOG" 2>/dev/null || true)"
|
|
120
|
-
GLUED=""
|
|
121
|
-
while IFS= read -r line; do
|
|
122
|
-
case "$line" in
|
|
123
|
-
SUBMIT:*) GLUED="${line#SUBMIT:}" ;;
|
|
124
|
-
esac
|
|
125
|
-
done <<< "$SUBMITS"
|
|
126
|
-
|
|
127
|
-
QUEUE_N=0
|
|
128
|
-
for f in "$REPO/.pi/team/state/outbox"/*.msg; do [ -f "$f" ] && QUEUE_N=$((QUEUE_N + 1)); done
|
|
129
|
-
PANE_NOW="$(tmux capture-pane -p -t "$SESSION:dev" 2>/dev/null || true)"
|
|
130
|
-
REAL_AFTER="$(real_fp "$REAL_MAIN")"
|
|
131
|
-
|
|
132
|
-
printf '\n—— 夹具现场 ——\n'
|
|
133
|
-
printf 'say 输出:%s\n' "$(tr '\n' ' ' < "$SB/say.log")"
|
|
134
|
-
printf '提交记录:%s\n' "${SUBMITS:-(无提交)}"
|
|
135
|
-
printf '队列条目:%s\n' "$QUEUE_N"
|
|
136
|
-
printf '输入框草稿:%s\n' "$(printf '%s' "$PANE_NOW" | grep -cF "$DRAFT")"
|
|
137
|
-
|
|
138
|
-
RC=0
|
|
139
|
-
case "$SUBMITS" in
|
|
140
|
-
*"$DRAFT"*)
|
|
141
|
-
fail "RED:草稿被粘走并提交了 —— $(printf '%s' "$SUBMITS" | tr '\n' ' ')"
|
|
142
|
-
RC=1 ;;
|
|
143
|
-
esac
|
|
144
|
-
if [ -n "$SUBMITS" ] && [ "$GLUED" != "$NOTICE" ]; then
|
|
145
|
-
fail "RED:出现了非预期提交 —— SUBMIT:$GLUED"
|
|
146
|
-
RC=1
|
|
147
|
-
fi
|
|
148
|
-
case "$PANE_NOW" in
|
|
149
|
-
*"$DRAFT"*) : ;;
|
|
150
|
-
*) fail "RED:输入框里的草稿不在了"; RC=1 ;;
|
|
151
|
-
esac
|
|
152
|
-
if [ "$QUEUE_N" -ne 1 ]; then
|
|
153
|
-
fail "RED:state/outbox/ 应当恰好 1 条,实际 $QUEUE_N(pre-change 树没有队列,这是预期的红)"
|
|
154
|
-
RC=1
|
|
155
|
-
fi
|
|
156
|
-
if [ "$REAL_BEFORE" != "$REAL_AFTER" ]; then
|
|
157
|
-
fail "隔离失败:调用方项目($REAL_MAIN)的 inbox/state 被改了"
|
|
158
|
-
RC=1
|
|
159
|
-
fi
|
|
160
|
-
if [ "$RC" = "0" ]; then pass "GREEN:草稿原样留在输入框;state/outbox/ 1 条(payload = 通知);真项目未被写入"; fi
|
|
161
|
-
printf 'exit=%s\n' "$RC"
|
|
162
|
-
exit "$RC"
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# M12 追加 · 26-c 容量行自抖的翻转夹具(红 → 绿)
|
|
3
|
-
#
|
|
4
|
-
# bash skills/teamsmith/tests/flip-m12-26c.sh # 放大注入下:旧 26-c 红 / 新 26-c 绿
|
|
5
|
-
# bash skills/teamsmith/tests/flip-m12-26c.sh --measure 12 # 只测:当前树 26-c 连跑 N 次报失败率(不放大)
|
|
6
|
-
# bash skills/teamsmith/tests/flip-m12-26c.sh --probe base # 只跑一面(base 或 current),自然条件
|
|
7
|
-
# TEAM_FLIP_BASE=<sha> bash …/flip-m12-26c.sh # 自选基线(默认 merge-base HEAD main)
|
|
8
|
-
#
|
|
9
|
-
# 为什么需要:26-c 的两条断言把两次**实时执行**逐字对比(`--print` vs 重定向 `--once`;`--print` vs
|
|
10
|
-
# `UI=text --once`),而容量数据源默认是 /proc/meminfo 与 /proc/swaps —— 数值每秒都在动
|
|
11
|
-
# (实测 MemAvailable ±100MB/s;面板的 `可再加 N 个` = (avail + disk_free − 512) / 6144,在边界
|
|
12
|
-
# 附近两次采样就能差 1)。旧 26-c 因此偶发红,且报错把原因说成「没走纯文本路径(ESC=0)」——
|
|
13
|
-
# ESC 是 0,误导来源就在这里。
|
|
14
|
-
#
|
|
15
|
-
# 翻转手法:探针 = smoke 的前导 + 26 段到 26-c(单跑 ~4.3s)。「放大注入」= TEAM_AGENT_MEM_MB=1:
|
|
16
|
-
# 分母从 6144MB 变 1MB,把「每秒 ±MB 的漂移」放大成「可再加 必差 1」,于是
|
|
17
|
-
# 旧 26-c(读实时值)→ 两次采样必不同 → 红;
|
|
18
|
-
# 新 26-c(p10cap 钉住 meminfo+swaps 夹具)→ 两次都读夹具 → 绿。
|
|
19
|
-
# 注入不碰被测对象(产品代码与断言都不变),只是让时间窗口里的漂移可见。
|
|
20
|
-
#
|
|
21
|
-
# 边界:只读 git(`git show BASE:…smoke.sh`),只写 /tmp 下的临时目录;截出来的 smoke 段在 EXIT 时
|
|
22
|
-
# 自己收干净,不碰调用者所在的仓库/session。
|
|
23
|
-
set -uo pipefail
|
|
24
|
-
|
|
25
|
-
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
26
|
-
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
27
|
-
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
28
|
-
. "$SELF_DIR/lib/tmp-root.sh"
|
|
29
|
-
REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
|
|
30
|
-
[ -n "$REPO_ROOT" ] || { printf 'flip-m12-26c: 找不到 git 仓库\n' >&2; exit 2; }
|
|
31
|
-
command -v python3 >/dev/null 2>&1 || { printf 'flip-m12-26c: 需要 python3(截取探针)\n' >&2; exit 2; }
|
|
32
|
-
|
|
33
|
-
MODE="flip"; MEASURE_N=0; PROBE_WHICH=""
|
|
34
|
-
case "${1:-}" in
|
|
35
|
-
--measure) MODE="measure"; MEASURE_N="${2:-0}" ;;
|
|
36
|
-
--probe) MODE="probe"; PROBE_WHICH="${2:-}"
|
|
37
|
-
case "$PROBE_WHICH" in base|current) ;; *) printf 'flip-m12-26c --probe <base|current>\n' >&2; exit 2 ;; esac ;;
|
|
38
|
-
""|-h|--help)
|
|
39
|
-
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then sed -n '2,22p' "$0"; exit 0; fi ;;
|
|
40
|
-
*) printf 'flip-m12-26c: 未知参数 %s\n' "$1" >&2; exit 2 ;;
|
|
41
|
-
esac
|
|
42
|
-
|
|
43
|
-
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
44
|
-
TMP="$(tmp_root_create flip-m12-26c)" || exit 3
|
|
45
|
-
trap 'tmp_root_reap_all' EXIT
|
|
46
|
-
|
|
47
|
-
CUR_SMOKE="$SKILL_DIR/tests/smoke.sh"
|
|
48
|
-
[ -f "$CUR_SMOKE" ] || { printf 'flip-m12-26c: 找不到 %s\n' "$CUR_SMOKE" >&2; exit 2; }
|
|
49
|
-
BASE="${TEAM_FLIP_BASE:-}"
|
|
50
|
-
[ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
|
|
51
|
-
[ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" rev-parse --verify -q HEAD^ 2>/dev/null || true)"
|
|
52
|
-
[ -n "$BASE" ] || { printf 'flip-m12-26c: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
|
|
53
|
-
BASE_SMOKE="$TMP/smoke-base.sh"
|
|
54
|
-
git -C "$REPO_ROOT" show "$BASE:skills/teamsmith/tests/smoke.sh" > "$BASE_SMOKE" 2>/dev/null \
|
|
55
|
-
|| { printf 'flip-m12-26c: %s 里没有 smoke.sh\n' "$BASE" >&2; exit 2; }
|
|
56
|
-
if grep -q '^p10cap=(' "$BASE_SMOKE"; then
|
|
57
|
-
printf 'flip-m12-26c: BASE(%s)已经含 26-c 的夹具钉(不是修复前的树)——用 TEAM_FLIP_BASE=<修复前的 sha>\n' "$BASE" >&2
|
|
58
|
-
exit 2
|
|
59
|
-
fi
|
|
60
|
-
grep -q '^p10cap=(' "$CUR_SMOKE" || { printf 'flip-m12-26c: 当前树没含 26-c 的夹具钉\n' >&2; exit 2; }
|
|
61
|
-
|
|
62
|
-
# 探针 = 前导(helpers/夹具函数)+ 26 段到 26-c 之前;SKILL_DIR 指向当前树(产品代码)
|
|
63
|
-
build_probe() { # <src-smoke> <out>
|
|
64
|
-
local src="$1" out="$2"
|
|
65
|
-
{
|
|
66
|
-
awk '/^# -+ 0\. 仓库/{exit} {print}' "$src"
|
|
67
|
-
printf '\n# —— 26-c 聚焦探针 ——\n'
|
|
68
|
-
awk '/^section "26 · 面板(pulse-tui-panel/{f=1} /^# -+ 26-d\. --json/{exit} f{print}' "$src"
|
|
69
|
-
} | sed "s|^SKILL_DIR=.*|SKILL_DIR=\"$SKILL_DIR\"|" > "$out"
|
|
70
|
-
cat >> "$out" <<'EOS'
|
|
71
|
-
section "15 · 完成(26-c 聚焦探针)"
|
|
72
|
-
printf '\n== 结果 == ✓ %d ✗ %d\n' "$PASS" "$FAIL"
|
|
73
|
-
[ "$FAIL" -eq 0 ] && exit 0
|
|
74
|
-
exit 1
|
|
75
|
-
EOS
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
probe_run() { # <src-smoke> <tag> <amp:1|0> <log> → 退出码
|
|
79
|
-
local src="$1" tag="$2" amp="$3" log="$4" p
|
|
80
|
-
p="$TMP/probe-$tag.sh"
|
|
81
|
-
build_probe "$src" "$p"
|
|
82
|
-
if [ "$amp" = "1" ]; then
|
|
83
|
-
TEAM_AGENT_MEM_MB=1 bash "$p" > "$log" 2>&1 # 放大:分母 6144MB → 1MB
|
|
84
|
-
else
|
|
85
|
-
bash "$p" > "$log" 2>&1
|
|
86
|
-
fi
|
|
87
|
-
return $?
|
|
88
|
-
}
|
|
89
|
-
reds() { grep -a '✗' "$1" 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep -v '== 结果 =='; }
|
|
90
|
-
result_line() { grep -a '== 结果 ==' "$1" 2>/dev/null | tail -1 | sed 's/\x1b\[[0-9;]*m//g'; }
|
|
91
|
-
|
|
92
|
-
if [ "$MODE" = "measure" ]; then
|
|
93
|
-
[ "$MEASURE_N" -gt 0 ] || { printf 'flip-m12-26c --measure <次数>\n' >&2; exit 2; }
|
|
94
|
-
printf 'M12-26c 测量:当前树 26-c(聚焦探针、不放大)连跑 %s 次\n' "$MEASURE_N"
|
|
95
|
-
n=0; bad=0
|
|
96
|
-
while [ "$n" -lt "$MEASURE_N" ]; do
|
|
97
|
-
n=$((n + 1))
|
|
98
|
-
if probe_run "$CUR_SMOKE" "m$n" 0 "$TMP/measure-$n.log"; then
|
|
99
|
-
printf ' run %-3s 绿 %s\n' "$n" "$(result_line "$TMP/measure-$n.log")"
|
|
100
|
-
else
|
|
101
|
-
bad=$((bad + 1)); printf ' run %-3s 红 %s\n' "$n" "$(result_line "$TMP/measure-$n.log")"
|
|
102
|
-
reds "$TMP/measure-$n.log" | sed 's/^/ /'
|
|
103
|
-
fi
|
|
104
|
-
done
|
|
105
|
-
printf '失败率:%s/%s\n' "$bad" "$n"
|
|
106
|
-
[ "$bad" -eq 0 ] || exit 1
|
|
107
|
-
exit 0
|
|
108
|
-
fi
|
|
109
|
-
|
|
110
|
-
if [ "$MODE" = "probe" ]; then
|
|
111
|
-
src="$BASE_SMOKE"; [ "$PROBE_WHICH" = "current" ] && src="$CUR_SMOKE"
|
|
112
|
-
probe_run "$src" "$PROBE_WHICH" 0 "$TMP/probe-$PROBE_WHICH.log"; rc=$?
|
|
113
|
-
printf '%s:rc=%s %s\n' "$PROBE_WHICH" "$rc" "$(result_line "$TMP/probe-$PROBE_WHICH.log")"
|
|
114
|
-
reds "$TMP/probe-$PROBE_WHICH.log" | sed 's/^/ /'
|
|
115
|
-
exit 0 # 诊断模式:红也当输出(自然条件下旧 26-c 本来就偶尔红)
|
|
116
|
-
fi
|
|
117
|
-
|
|
118
|
-
printf 'M12-26c 翻转:同一放大注入(TEAM_AGENT_MEM_MB=1)下,旧 26-c 必须红、新 26-c 必须绿\n'
|
|
119
|
-
printf ' BASE=%s\n 当前=%s\n' "$BASE" "$CUR_SMOKE"
|
|
120
|
-
FAILED=0
|
|
121
|
-
probe_run "$BASE_SMOKE" base 1 "$TMP/base.log"; brc=$?
|
|
122
|
-
probe_run "$CUR_SMOKE" cur 1 "$TMP/cur.log"; crc=$?
|
|
123
|
-
printf '旧 26-c(BASE,实时读数):rc=%s %s\n' "$brc" "$(result_line "$TMP/base.log")"
|
|
124
|
-
reds "$TMP/base.log" | sed 's/^/ /'
|
|
125
|
-
printf '新 26-c(当前,夹具钉住):rc=%s %s\n' "$crc" "$(result_line "$TMP/cur.log")"
|
|
126
|
-
reds "$TMP/cur.log" | sed 's/^/ /'
|
|
127
|
-
[ "$brc" -ne 0 ] || { printf '✗ 翻转不成立:放大注入没能让旧 26-c 红\n'; FAILED=1; }
|
|
128
|
-
[ "$crc" -eq 0 ] || { printf '✗ 修复不成立:同一个注入让新 26-c 红了\n'; FAILED=1; }
|
|
129
|
-
[ "$FAILED" -eq 0 ] && printf '翻转成立:旧 26-c 红、新 26-c 绿\n' || exit 1
|