teamsmith 0.0.0-stage → 0.1.2
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/LICENSE +21 -0
- package/README.md +158 -2
- package/bin/team.mjs +59 -0
- package/install.sh +94 -0
- package/package.json +37 -4
- package/skills/teamsmith/CHANGELOG.md +763 -0
- package/skills/teamsmith/SKILL.md +312 -0
- package/skills/teamsmith/extension/team-bg.ts +435 -0
- package/skills/teamsmith/extension/team-inbox-watch.ts +1412 -0
- package/skills/teamsmith/extension/team-notify.ts +663 -0
- package/skills/teamsmith/references/agent-adapters.md +643 -0
- package/skills/teamsmith/references/config.md +477 -0
- package/skills/teamsmith/references/meeting.md +124 -0
- package/skills/teamsmith/references/memory.md +133 -0
- package/skills/teamsmith/references/migration.md +227 -0
- package/skills/teamsmith/references/openspec.md +222 -0
- package/skills/teamsmith/references/philosophy.md +95 -0
- package/skills/teamsmith/references/protocol.md +712 -0
- package/skills/teamsmith/references/troubleshooting.md +1384 -0
- package/skills/teamsmith/references/workflows.md +448 -0
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +1709 -0
- package/skills/teamsmith/scripts/lib/cmd-bg.sh +284 -0
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +311 -0
- package/skills/teamsmith/scripts/lib/cmd-config.sh +1156 -0
- package/skills/teamsmith/scripts/lib/cmd-death.sh +562 -0
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +149 -0
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +124 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +212 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +904 -0
- package/skills/teamsmith/scripts/lib/cmd-outbox.sh +196 -0
- package/skills/teamsmith/scripts/lib/cmd-project.sh +642 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +1393 -0
- package/skills/teamsmith/scripts/lib/cmd-status.sh +1399 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +191 -0
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +1681 -0
- package/skills/teamsmith/scripts/lib/common.sh +4964 -0
- package/skills/teamsmith/scripts/lib/draft-entry.sh +51 -0
- package/skills/teamsmith/scripts/lib/outbox.sh +2042 -0
- package/skills/teamsmith/scripts/lib/tmux-argv.sh +165 -0
- package/skills/teamsmith/scripts/monitor.mjs +616 -0
- package/skills/teamsmith/scripts/panel/README.md +192 -0
- package/skills/teamsmith/scripts/panel/build.sh +47 -0
- package/skills/teamsmith/scripts/panel/bun.lock +109 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +68 -0
- package/skills/teamsmith/scripts/panel/package.json +24 -0
- package/skills/teamsmith/scripts/panel/panel.js +388 -0
- package/skills/teamsmith/scripts/panel/src/App.tsx +2150 -0
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/compose.ts +691 -0
- package/skills/teamsmith/scripts/panel/src/data.ts +555 -0
- package/skills/teamsmith/scripts/panel/src/format.ts +50 -0
- package/skills/teamsmith/scripts/panel/src/layout.ts +2562 -0
- package/skills/teamsmith/scripts/panel/src/main.tsx +894 -0
- package/skills/teamsmith/scripts/panel/src/markdown.ts +340 -0
- package/skills/teamsmith/scripts/panel/src/sanitize.ts +42 -0
- package/skills/teamsmith/scripts/panel/src/settings.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +416 -0
- package/skills/teamsmith/scripts/panel/src/strings/index.ts +65 -0
- package/skills/teamsmith/scripts/panel/src/strings/types.ts +9 -0
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +414 -0
- package/skills/teamsmith/scripts/panel/src/theme.ts +116 -0
- package/skills/teamsmith/scripts/panel/src/types.ts +652 -0
- package/skills/teamsmith/scripts/panel/src/width.ts +105 -0
- package/skills/teamsmith/scripts/panel/tsconfig.json +16 -0
- package/skills/teamsmith/scripts/shim/signal-gate +156 -0
- package/skills/teamsmith/scripts/shim/tmux +403 -0
- package/skills/teamsmith/scripts/team +143 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +147 -0
- package/skills/teamsmith/templates/BOARD.md.tmpl +18 -0
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +22 -0
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +25 -0
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +84 -0
- package/skills/teamsmith/templates/ROADMAP.md.tmpl +29 -0
- package/skills/teamsmith/templates/config.sh.tmpl +106 -0
- package/skills/teamsmith/templates/memory-seed.md.tmpl +46 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +110 -0
- package/skills/teamsmith/templates/report.md.tmpl +36 -0
- package/skills/teamsmith/templates/task.md.tmpl +65 -0
- package/skills/teamsmith/templates/threads-README.md +17 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +682 -0
- package/skills/teamsmith/tests/bg-ledger.sh +307 -0
- package/skills/teamsmith/tests/checkout-shape-probe.sh +800 -0
- package/skills/teamsmith/tests/config-cli.sh +1562 -0
- package/skills/teamsmith/tests/container-tmux.sh +493 -0
- package/skills/teamsmith/tests/coverage-inventory.sh +173 -0
- package/skills/teamsmith/tests/death-cause.sh +564 -0
- package/skills/teamsmith/tests/delivery-truth.sh +1231 -0
- package/skills/teamsmith/tests/fake-tui.py +450 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +60 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +139 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/mock-server.py +29 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/observe.ts +20 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +79 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +175 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +229 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/README.md +22 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.seen +8 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.wake +9 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/pm-nudges.wake +3 -0
- package/skills/teamsmith/tests/fixtures/signal-lint-cases.txt +40 -0
- package/skills/teamsmith/tests/flip-glue.sh +162 -0
- package/skills/teamsmith/tests/flip-m12-26c.sh +129 -0
- package/skills/teamsmith/tests/flip-m12.sh +185 -0
- package/skills/teamsmith/tests/flip-m16.sh +166 -0
- package/skills/teamsmith/tests/flip-m17.sh +204 -0
- package/skills/teamsmith/tests/flip-m33.sh +284 -0
- package/skills/teamsmith/tests/flip-m34.sh +96 -0
- package/skills/teamsmith/tests/flip-m37.sh +185 -0
- package/skills/teamsmith/tests/flip-m4.3.sh +375 -0
- package/skills/teamsmith/tests/flip-m43.sh +128 -0
- package/skills/teamsmith/tests/flip-m44.sh +262 -0
- package/skills/teamsmith/tests/flip-m45.sh +244 -0
- package/skills/teamsmith/tests/flip-m46.sh +238 -0
- package/skills/teamsmith/tests/flip-m48.sh +304 -0
- package/skills/teamsmith/tests/flip-m6.2.sh +205 -0
- package/skills/teamsmith/tests/flip-m6.3.sh +283 -0
- package/skills/teamsmith/tests/flip-m6.4.sh +267 -0
- package/skills/teamsmith/tests/flip-m6.5.sh +113 -0
- package/skills/teamsmith/tests/flip-m7.1.sh +135 -0
- package/skills/teamsmith/tests/flip-m7.2.sh +321 -0
- package/skills/teamsmith/tests/flip-p144.sh +112 -0
- package/skills/teamsmith/tests/flip-p156.sh +133 -0
- package/skills/teamsmith/tests/flip-p158.sh +301 -0
- package/skills/teamsmith/tests/flip-p160.sh +182 -0
- package/skills/teamsmith/tests/flip-p171.sh +249 -0
- package/skills/teamsmith/tests/flip-p18.1.sh +95 -0
- package/skills/teamsmith/tests/flip-p20.sh +286 -0
- package/skills/teamsmith/tests/flip-p201.sh +249 -0
- package/skills/teamsmith/tests/flip-p210.sh +239 -0
- package/skills/teamsmith/tests/flip-p211.sh +152 -0
- package/skills/teamsmith/tests/flip-p217.sh +288 -0
- package/skills/teamsmith/tests/flip-p22.sh +123 -0
- package/skills/teamsmith/tests/flip-p23.sh +239 -0
- package/skills/teamsmith/tests/flip-p25.sh +165 -0
- package/skills/teamsmith/tests/flip-p71.sh +184 -0
- package/skills/teamsmith/tests/flip-p72.sh +202 -0
- package/skills/teamsmith/tests/frames/README.md +176 -0
- package/skills/teamsmith/tests/frames/p78-conversation-rule-below-box.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-cursor-mid-draft.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor-line.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-blank-region.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-only.txt +5 -0
- package/skills/teamsmith/tests/frames/p78-spinner-row-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-wider-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p86-f1-mixed-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-narrower-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-spinner-top-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/pi-0.85.1-update-banner.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-draft-half-sentence.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-empty-box.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-one-line-draft.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-project-trust-prompt.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-empty-editor.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-human-draft.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-1.0.0-git-error-in-box.txt +32 -0
- package/skills/teamsmith/tests/gate-guard.sh +112 -0
- package/skills/teamsmith/tests/guard-matrix.sh +233 -0
- package/skills/teamsmith/tests/install-shape.sh +731 -0
- package/skills/teamsmith/tests/ledger-ban.sh +612 -0
- package/skills/teamsmith/tests/lib/box-judge.sh +68 -0
- package/skills/teamsmith/tests/lib/checkout-shape.sh +129 -0
- package/skills/teamsmith/tests/lib/loop-scan.awk +114 -0
- package/skills/teamsmith/tests/lib/pty-wait.sh +676 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +855 -0
- package/skills/teamsmith/tests/lib/shell-lex.pl +261 -0
- package/skills/teamsmith/tests/lib/tmp-root.sh +528 -0
- package/skills/teamsmith/tests/lib/tmux-cap.sh +35 -0
- package/skills/teamsmith/tests/lib/tmux-iso-call-probe.sh +81 -0
- package/skills/teamsmith/tests/lib/tmux-iso-probe.sh +46 -0
- package/skills/teamsmith/tests/lib/tmux-iso.sh +381 -0
- package/skills/teamsmith/tests/load-experiment.sh +290 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +84 -0
- package/skills/teamsmith/tests/panel-b2-slow-stub.sh +19 -0
- package/skills/teamsmith/tests/panel-b2.sh +1183 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +240 -0
- package/skills/teamsmith/tests/panel-b3-pty-tmux-mouse.py +138 -0
- package/skills/teamsmith/tests/panel-b3-stub.sh +279 -0
- package/skills/teamsmith/tests/panel-b3.sh +1301 -0
- package/skills/teamsmith/tests/panel-choices.sh +572 -0
- package/skills/teamsmith/tests/panel-clipboard-model.ts +187 -0
- package/skills/teamsmith/tests/panel-compose-model.ts +290 -0
- package/skills/teamsmith/tests/panel-contrast.mjs +81 -0
- package/skills/teamsmith/tests/panel-cpu-premise.sh +173 -0
- package/skills/teamsmith/tests/panel-cpu.sh +391 -0
- package/skills/teamsmith/tests/panel-flip-m54.sh +207 -0
- package/skills/teamsmith/tests/panel-flip-p123.sh +278 -0
- package/skills/teamsmith/tests/panel-flip-p125.sh +318 -0
- package/skills/teamsmith/tests/panel-flip-p128.sh +259 -0
- package/skills/teamsmith/tests/panel-keyprobe-pty.py +99 -0
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +41 -0
- package/skills/teamsmith/tests/panel-keyprobe.sh +82 -0
- package/skills/teamsmith/tests/panel-keyprobe.tsx +116 -0
- package/skills/teamsmith/tests/panel-knobs.sh +83 -0
- package/skills/teamsmith/tests/panel-p21.sh +2181 -0
- package/skills/teamsmith/tests/panel-snapshots.sh +802 -0
- package/skills/teamsmith/tests/panel-strings.mjs +195 -0
- package/skills/teamsmith/tests/perf.sh +740 -0
- package/skills/teamsmith/tests/pm-box-real.sh +350 -0
- package/skills/teamsmith/tests/pulse-nudge-key.sh +563 -0
- package/skills/teamsmith/tests/routes.sh +1652 -0
- package/skills/teamsmith/tests/section-budgets.tsv +150 -0
- package/skills/teamsmith/tests/section-guard.sh +231 -0
- package/skills/teamsmith/tests/section-needs-audit.sh +94 -0
- package/skills/teamsmith/tests/section-paths.tsv +142 -0
- package/skills/teamsmith/tests/section-select.sh +655 -0
- package/skills/teamsmith/tests/signal-gate.sh +366 -0
- package/skills/teamsmith/tests/signal-lint-legacy.txt +14 -0
- package/skills/teamsmith/tests/signal-lint.pl +416 -0
- package/skills/teamsmith/tests/skill-load.mjs +65 -0
- package/skills/teamsmith/tests/smoke.sh +19711 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +32 -0
- package/skills/teamsmith/tests/spec-ledger-refs.tsv +78 -0
- package/skills/teamsmith/tests/spec-refs.sh +826 -0
- package/skills/teamsmith/tests/task-header-model.sh +267 -0
- package/skills/teamsmith/tests/team-bg-flip.sh +239 -0
- package/skills/teamsmith/tests/team-bg-harness.mjs +392 -0
- package/skills/teamsmith/tests/team-bg-stop.sh +434 -0
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +191 -0
- package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +1559 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +1190 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +31 -0
- package/skills/teamsmith/tests/tmux-lint.pl +604 -0
- package/skills/teamsmith-init/SKILL.md +100 -0
- package/skills/teamsmith-init/references/bootstrap.md +74 -0
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +46 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# P23/B1 · 任务书头部字段的严格读取层(change-centric-discipline tasks.md 1.1)
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/task-header-model.sh
|
|
5
|
+
#
|
|
6
|
+
# 夹具自带一个最小 scratch 项目(git init + team init + openspec/specs),在同一进程里直接驱动
|
|
7
|
+
# `team_brief_field_raw` / `team_task_change_value` / `team_task_deltas` / `team_task_anchor`。
|
|
8
|
+
# 每条断言自带名字:失败时点名是哪一条(而不是让 PM 去猜哪个值读错了)。
|
|
9
|
+
# 退出码:0 = 全绿;1 = 有失败;3 = 环境/前置不满足。纯逻辑,不建 tmux、不起进程,FAST 模式照跑。
|
|
10
|
+
set -uo pipefail
|
|
11
|
+
|
|
12
|
+
SKILL_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
13
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
14
|
+
. "$SKILL_DIR/tests/lib/tmp-root.sh"
|
|
15
|
+
TEAM="bash $SKILL_DIR/scripts/team"
|
|
16
|
+
|
|
17
|
+
# 身份隔离(与 smoke.sh 同一套):绝不继承调用者的团队身份
|
|
18
|
+
unset TEAM_ROOT TEAM_MAIN_ROOT TEAM_ROOT_SOURCE TEAM_ROOT_WAS TEAM_PROJECT TEAM_SESSION \
|
|
19
|
+
TEAM_SESSION_FROM TEAM_PM_WINDOW TEAM_AGENTS TEAM_DOCS_DIR TEAM_WORKTREES_DIR TEAM_GATES \
|
|
20
|
+
TEAM_VCS TEAM_CONFIG_FILE TEAM_ALLOW_FOREIGN_SESSION TEAM_ALLOW_DESTRUCTIVE_TMUX \
|
|
21
|
+
TEAM_TMUX_CALLS_LOG TEAM_TMUX_REAL 2>/dev/null || true
|
|
22
|
+
unset TMUX TMUX_PANE 2>/dev/null || true
|
|
23
|
+
|
|
24
|
+
PASS=0
|
|
25
|
+
FAIL=0
|
|
26
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
|
|
27
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
28
|
+
|
|
29
|
+
TMP="$(tmp_root_create task-header-model)" || exit 3
|
|
30
|
+
cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; tmp_root_reap_all; return 0; }
|
|
31
|
+
trap cleanup EXIT
|
|
32
|
+
|
|
33
|
+
P="$TMP/proj"
|
|
34
|
+
mkdir -p "$P"
|
|
35
|
+
( cd "$P" && git init -q -b main && git config user.email thm@test && git config user.name thm \
|
|
36
|
+
&& git commit -q --allow-empty -m "chore: init" ) || { printf '前置失败:git init\n' >&2; exit 3; }
|
|
37
|
+
( cd "$P" && $TEAM init --session thm --agents "dev verify" --vcs local --gates true --docs docs/team ) >"$TMP/init.log" 2>&1 \
|
|
38
|
+
|| { printf '前置失败:team init\n' >&2; tail -5 "$TMP/init.log" >&2; exit 3; }
|
|
39
|
+
mkdir -p "$P/openspec/specs/panel" "$P/openspec/specs/dispatch"
|
|
40
|
+
cat > "$P/openspec/specs/panel/spec.md" <<'EOF'
|
|
41
|
+
# panel Specification
|
|
42
|
+
|
|
43
|
+
## Requirements
|
|
44
|
+
|
|
45
|
+
### Requirement: The board page is a kanban over the board's states
|
|
46
|
+
|
|
47
|
+
text
|
|
48
|
+
EOF
|
|
49
|
+
cat > "$P/openspec/specs/dispatch/spec.md" <<'EOF'
|
|
50
|
+
### Requirement: A brief is self-contained and names its evidence
|
|
51
|
+
EOF
|
|
52
|
+
|
|
53
|
+
cd "$P" || exit 3
|
|
54
|
+
# shellcheck source=lib/common.sh
|
|
55
|
+
. "$SKILL_DIR/scripts/lib/common.sh"
|
|
56
|
+
for f in "$SKILL_DIR"/scripts/lib/cmd-*.sh; do
|
|
57
|
+
# shellcheck disable=SC1090
|
|
58
|
+
. "$f" 2>/dev/null || true
|
|
59
|
+
done
|
|
60
|
+
team_load_config >/dev/null 2>&1 || { printf '前置失败:team_load_config\n' >&2; exit 3; }
|
|
61
|
+
|
|
62
|
+
BRIEF="$TMP/brief.md"
|
|
63
|
+
mkbrief() { # stdin → $BRIEF(头部片段;调用方给完整任务书)
|
|
64
|
+
cat > "$BRIEF"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
check_val() { # <名字> <函数> <brief 文件> <期望 stdout 精确值>
|
|
68
|
+
local name="$1" fn="$2" f="$3" want="$4" got rc
|
|
69
|
+
got="$("$fn" "$f" 2>&1)"; rc=$?
|
|
70
|
+
if [ "$rc" -eq 0 ] && [ "$got" = "$want" ]; then ok "$name"
|
|
71
|
+
else bad "$name(期望 rc=0 输出 [${want//$'\n'/|}], 实际 rc=$rc 输出 [${got//$'\n'/|}])"; fi
|
|
72
|
+
}
|
|
73
|
+
check_refuse() { # <名字> <函数> <brief 文件> <必须出现的片段...>
|
|
74
|
+
local name="$1" fn="$2" f="$3"; shift 3
|
|
75
|
+
local got rc frag miss=""
|
|
76
|
+
got="$("$fn" "$f" 2>&1)"; rc=$?
|
|
77
|
+
for frag in "$@"; do case "$got" in *"$frag"*) ;; *) miss="$miss [$frag]" ;; esac; done
|
|
78
|
+
if [ "$rc" -ne 0 ] && [ -z "$miss" ]; then ok "$name"
|
|
79
|
+
else bad "$name(rc=$rc 应有非 0${miss:+;缺片段$miss};输出 [${got//$'\n'/|}])"; fi
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
printf '\033[1m== task-header-model · 1.1 严格头部读取 ==\033[0m\n'
|
|
83
|
+
|
|
84
|
+
# —— team_brief_field_raw:全部匹配行;` #` 才是注释,`#` 紧贴值是值本身 ——
|
|
85
|
+
mkbrief <<'EOF'
|
|
86
|
+
```
|
|
87
|
+
task: X1
|
|
88
|
+
change: alpha # 注释要被剥掉
|
|
89
|
+
specs: panel#The board page is a kanban over the board's states
|
|
90
|
+
```
|
|
91
|
+
EOF
|
|
92
|
+
raw_change="$(team_brief_field_raw "$BRIEF" change)"
|
|
93
|
+
if [ "$raw_change" = "alpha" ]; then ok "raw:change 行剥掉 \` #\` 注释"; else bad "raw:change 注释没剥掉([$raw_change])"; fi
|
|
94
|
+
raw_specs="$(team_brief_field_raw "$BRIEF" specs)"
|
|
95
|
+
if [ "$raw_specs" = "panel#The board page is a kanban over the board's states" ]; then
|
|
96
|
+
ok "raw:specs 里的 \`#\` 紧贴值 → 不当注释"
|
|
97
|
+
else bad "raw:specs 的 \`#\` 被当成了注释([$raw_specs])"; fi
|
|
98
|
+
|
|
99
|
+
# —— team_task_change_value ——
|
|
100
|
+
mkbrief <<'EOF'
|
|
101
|
+
```
|
|
102
|
+
task: X1
|
|
103
|
+
agent: dev
|
|
104
|
+
```
|
|
105
|
+
EOF
|
|
106
|
+
check_val "change:行缺失 ≡ \`-\`" team_task_change_value "$BRIEF" "-"
|
|
107
|
+
mkbrief <<'EOF'
|
|
108
|
+
```
|
|
109
|
+
change: -
|
|
110
|
+
```
|
|
111
|
+
EOF
|
|
112
|
+
check_val "change:\`-\`" team_task_change_value "$BRIEF" "-"
|
|
113
|
+
mkbrief <<'EOF'
|
|
114
|
+
```
|
|
115
|
+
change: Alpha_1.x
|
|
116
|
+
```
|
|
117
|
+
EOF
|
|
118
|
+
check_val "change:单 token(含 . _ -)" team_task_change_value "$BRIEF" "Alpha_1.x"
|
|
119
|
+
mkbrief <<'EOF'
|
|
120
|
+
```
|
|
121
|
+
change: alpha, beta
|
|
122
|
+
```
|
|
123
|
+
EOF
|
|
124
|
+
check_refuse "change:逗号列表被拒并点名那一行" team_task_change_value "$BRIEF" "change: 的值是 \`alpha, beta\`" "只接受一个 change id"
|
|
125
|
+
mkbrief <<'EOF'
|
|
126
|
+
```
|
|
127
|
+
change: alpha beta
|
|
128
|
+
```
|
|
129
|
+
EOF
|
|
130
|
+
check_refuse "change:两个词被拒" team_task_change_value "$BRIEF" "alpha beta"
|
|
131
|
+
mkbrief <<'EOF'
|
|
132
|
+
```
|
|
133
|
+
change: alpha
|
|
134
|
+
change: beta
|
|
135
|
+
```
|
|
136
|
+
EOF
|
|
137
|
+
check_refuse "change:两行都点名" team_task_change_value "$BRIEF" "change: 有 2 行" "alpha" "beta"
|
|
138
|
+
mkbrief <<'EOF'
|
|
139
|
+
```
|
|
140
|
+
change: .alpha
|
|
141
|
+
```
|
|
142
|
+
EOF
|
|
143
|
+
check_refuse "change:首字符不是字母数字被拒" team_task_change_value "$BRIEF" ".alpha"
|
|
144
|
+
mkbrief <<'EOF'
|
|
145
|
+
```
|
|
146
|
+
change: alpha#x
|
|
147
|
+
```
|
|
148
|
+
EOF
|
|
149
|
+
check_refuse "change:带 # 的值被拒" team_task_change_value "$BRIEF" "alpha#x"
|
|
150
|
+
mkbrief <<'EOF'
|
|
151
|
+
```
|
|
152
|
+
change: alpha # 合法注释
|
|
153
|
+
```
|
|
154
|
+
EOF
|
|
155
|
+
check_val "change:注释后的单 token 合法" team_task_change_value "$BRIEF" "alpha"
|
|
156
|
+
|
|
157
|
+
# —— team_task_deltas ——
|
|
158
|
+
mkbrief <<'EOF'
|
|
159
|
+
```
|
|
160
|
+
change: alpha
|
|
161
|
+
```
|
|
162
|
+
EOF
|
|
163
|
+
check_val "deltas:行缺失 → \`*\`(unknown)" team_task_deltas "$BRIEF" "*"
|
|
164
|
+
mkbrief <<'EOF'
|
|
165
|
+
```
|
|
166
|
+
deltas: -
|
|
167
|
+
```
|
|
168
|
+
EOF
|
|
169
|
+
check_val "deltas:\`-\` → 空集" team_task_deltas "$BRIEF" ""
|
|
170
|
+
mkbrief <<'EOF'
|
|
171
|
+
```
|
|
172
|
+
deltas: panel, memory-and-deps
|
|
173
|
+
```
|
|
174
|
+
EOF
|
|
175
|
+
check_val "deltas:逗号列表 → 每行一个" team_task_deltas "$BRIEF" $'panel\nmemory-and-deps'
|
|
176
|
+
mkbrief <<'EOF'
|
|
177
|
+
```
|
|
178
|
+
deltas: panel,
|
|
179
|
+
```
|
|
180
|
+
EOF
|
|
181
|
+
check_refuse "deltas:空项被拒(不静默当空集)" team_task_deltas "$BRIEF" "deltas: 的值是 \`panel,\`"
|
|
182
|
+
mkbrief <<'EOF'
|
|
183
|
+
```
|
|
184
|
+
deltas: panel;bogus
|
|
185
|
+
```
|
|
186
|
+
EOF
|
|
187
|
+
check_refuse "deltas:坏 token 被拒" team_task_deltas "$BRIEF" "panel;bogus"
|
|
188
|
+
|
|
189
|
+
# —— team_task_anchor ——
|
|
190
|
+
mkbrief <<'EOF'
|
|
191
|
+
```
|
|
192
|
+
change: -
|
|
193
|
+
specs: -
|
|
194
|
+
```
|
|
195
|
+
EOF
|
|
196
|
+
check_refuse "anchor:两种形式都没有 → 拒绝并列两式" team_task_anchor "$BRIEF" \
|
|
197
|
+
"specs: <capability>#<requirement>" "anchor: none (infra) — <非空理由>" "openspec/specs/"
|
|
198
|
+
mkbrief <<'EOF'
|
|
199
|
+
```
|
|
200
|
+
change: -
|
|
201
|
+
specs: panel#The board page is a kanban over the board's states
|
|
202
|
+
```
|
|
203
|
+
EOF
|
|
204
|
+
check_val "anchor:specs 解析到 capability#requirement" team_task_anchor "$BRIEF" \
|
|
205
|
+
$'specs\tpanel#The board page is a kanban over the board\'s states'
|
|
206
|
+
mkbrief <<'EOF'
|
|
207
|
+
```
|
|
208
|
+
change: -
|
|
209
|
+
specs: panel
|
|
210
|
+
```
|
|
211
|
+
EOF
|
|
212
|
+
check_val "anchor:只给 capability 也算解析" team_task_anchor "$BRIEF" $'specs\tpanel'
|
|
213
|
+
mkbrief <<'EOF'
|
|
214
|
+
```
|
|
215
|
+
change: -
|
|
216
|
+
specs: no-such-capability#x
|
|
217
|
+
```
|
|
218
|
+
EOF
|
|
219
|
+
check_refuse "anchor:capability 不存在 → 点名查找路径" team_task_anchor "$BRIEF" \
|
|
220
|
+
"openspec/specs/no-such-capability/spec.md"
|
|
221
|
+
mkbrief <<'EOF'
|
|
222
|
+
```
|
|
223
|
+
change: -
|
|
224
|
+
specs: panel#Not A Requirement
|
|
225
|
+
```
|
|
226
|
+
EOF
|
|
227
|
+
check_refuse "anchor:requirement 不存在 → 拒绝" team_task_anchor "$BRIEF" "### Requirement: Not A Requirement"
|
|
228
|
+
mkbrief <<'EOF'
|
|
229
|
+
```
|
|
230
|
+
change: -
|
|
231
|
+
anchor: none (infra) — CI runner environment and test portability
|
|
232
|
+
```
|
|
233
|
+
EOF
|
|
234
|
+
check_val "anchor:infra 形式(带理由)" team_task_anchor "$BRIEF" $'infra\tCI runner environment and test portability'
|
|
235
|
+
mkbrief <<'EOF'
|
|
236
|
+
```
|
|
237
|
+
change: -
|
|
238
|
+
anchor: none (infra) --
|
|
239
|
+
```
|
|
240
|
+
EOF
|
|
241
|
+
check_refuse "anchor:none (infra) 缺理由 → 拒绝" team_task_anchor "$BRIEF" "少了理由"
|
|
242
|
+
mkbrief <<'EOF'
|
|
243
|
+
```
|
|
244
|
+
change: -
|
|
245
|
+
anchor: none (infra) 没有分隔符的理由
|
|
246
|
+
```
|
|
247
|
+
EOF
|
|
248
|
+
check_refuse "anchor:缺 — 分隔符 → 拒绝" team_task_anchor "$BRIEF" "少了 \`—\` 分隔符"
|
|
249
|
+
mkbrief <<'EOF'
|
|
250
|
+
```
|
|
251
|
+
change: -
|
|
252
|
+
anchor: -
|
|
253
|
+
```
|
|
254
|
+
EOF
|
|
255
|
+
check_refuse "anchor:\`anchor: -\` 不是可识别的锚" team_task_anchor "$BRIEF" "不是可识别的锚"
|
|
256
|
+
mkbrief <<'EOF'
|
|
257
|
+
```
|
|
258
|
+
change: -
|
|
259
|
+
specs: dispatch#A brief is self-contained and names its evidence
|
|
260
|
+
```
|
|
261
|
+
EOF
|
|
262
|
+
check_val "anchor:另一个 capability 的 requirement 也解析" team_task_anchor "$BRIEF" \
|
|
263
|
+
$'specs\tdispatch#A brief is self-contained and names its evidence'
|
|
264
|
+
|
|
265
|
+
printf '\n== 结果 == ✓ %d ✗ %d\n' "$PASS" "$FAIL"
|
|
266
|
+
[ "$FAIL" -eq 0 ] || exit 1
|
|
267
|
+
exit 0
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# M27 · team-bg 后台车道的翻转复现(红 → 绿)
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/team-bg-flip.sh [--keep]
|
|
5
|
+
# TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/team-bg-flip.sh # 默认 merge-base HEAD main
|
|
6
|
+
#
|
|
7
|
+
# 红(两种,都要有):
|
|
8
|
+
# ① 修复前的树(BASE = merge-base HEAD main)按它自己缺什么形状来判:
|
|
9
|
+
# · 没有 team-bg.ts → 车道根本不存在,夹具必须报 import 失败;
|
|
10
|
+
# · 有 M30 之前的老版(--git-common-dir)→ S11(worktree 会话的产物写进共享根)红;
|
|
11
|
+
# · 有 M30 但缺 P33(结果里没有 `cmd:` 行)→ S12 的显示用例红;
|
|
12
|
+
# · BASE 已经含 P33(没有修复前可对照)→ 可见跳过,并提示用 TEAM_FLIP_BASE 指到修复前的 revision。
|
|
13
|
+
# ② 定点破坏(每个只改一行):收割静默 / 合并窗口 / 唤醒投递方式 / 账本格式 / 日志上限 / 根解析 /
|
|
14
|
+
# P33 显示(cmd 行 / 单行化 / 码点切 / 收割回执)—— 每个都必须让夹具里**对应用例**变红。
|
|
15
|
+
# 破坏没生效(sed 没匹配上)= 假红,直接判失败。
|
|
16
|
+
# 绿:当前树的真扩展跑同一套夹具,全绿(TEAM-BG-HARNESS OK)。
|
|
17
|
+
#
|
|
18
|
+
# 只写 /tmp 下的临时目录;不碰调用者所在的仓库/session/tmux(夹具自己清空 TEAM_* 身份并断言
|
|
19
|
+
# 产物落在临时仓库里,另有一条反向守卫对比真实仓库 state/ 的前后快照)。
|
|
20
|
+
set -uo pipefail
|
|
21
|
+
|
|
22
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
|
+
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
24
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
25
|
+
. "$SELF_DIR/lib/tmp-root.sh"
|
|
26
|
+
SKILL_EXT="$SKILL_DIR/extension/team-bg.ts"
|
|
27
|
+
REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
|
|
28
|
+
[ -n "$REPO_ROOT" ] || { printf 'team-bg-flip: 找不到 git 仓库(需要它取修复前的树)\n' >&2; exit 2; }
|
|
29
|
+
|
|
30
|
+
# 能直接跑 .ts 的运行时(与 smoke 的选择顺序一致;没有就响亮退出,不静默跳过)
|
|
31
|
+
RUNNER=""
|
|
32
|
+
if command -v node >/dev/null 2>&1 && node -e 'process.exit(process.features.typescript?0:1)' >/dev/null 2>&1; then
|
|
33
|
+
RUNNER="node"
|
|
34
|
+
elif command -v bun >/dev/null 2>&1 && bun -e '1' >/dev/null 2>&1; then
|
|
35
|
+
RUNNER="bun"
|
|
36
|
+
elif [ -x "$HOME/.bun/bin/bun" ] && "$HOME/.bun/bin/bun" -e '1' >/dev/null 2>&1; then
|
|
37
|
+
RUNNER="$HOME/.bun/bin/bun"
|
|
38
|
+
elif command -v tsx >/dev/null 2>&1; then
|
|
39
|
+
RUNNER="tsx"
|
|
40
|
+
fi
|
|
41
|
+
[ -n "$RUNNER" ] || { printf 'team-bg-flip: 没有能跑 .ts 的运行时(node 开启类型剥离 / bun / tsx)\n' >&2; exit 2; }
|
|
42
|
+
|
|
43
|
+
BASE="${TEAM_FLIP_BASE:-}"
|
|
44
|
+
if [ -z "$BASE" ]; then
|
|
45
|
+
BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
|
|
46
|
+
fi
|
|
47
|
+
[ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" rev-parse --verify -q HEAD^ 2>/dev/null || true)"
|
|
48
|
+
[ -n "$BASE" ] || { printf 'team-bg-flip: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
|
|
49
|
+
|
|
50
|
+
KEEP=0
|
|
51
|
+
[ "${1:-}" = "--keep" ] && KEEP=1
|
|
52
|
+
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
53
|
+
TMP="$(tmp_root_create flip-m27)" || exit 3
|
|
54
|
+
cleanup() { [ "$KEEP" = "1" ] || tmp_root_reap_all; }
|
|
55
|
+
trap cleanup EXIT
|
|
56
|
+
|
|
57
|
+
FAIL=0
|
|
58
|
+
RED1=ran # ran / skipped:红①是否真的跑出对照(BASE 已含修复时可见跳过)
|
|
59
|
+
MUTATIONS=0 # 实际执行过的定点破坏条数(红②的自我描述不再手写数字)
|
|
60
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
|
|
61
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
62
|
+
hdr() { printf '\n== %s ==\n' "$1"; }
|
|
63
|
+
|
|
64
|
+
HARNESS="$SKILL_DIR/tests/team-bg-harness.mjs"
|
|
65
|
+
[ -f "$HARNESS" ] || { printf 'team-bg-flip: 缺夹具 %s\n' "$HARNESS" >&2; exit 2; }
|
|
66
|
+
run_harness() { # <ext.ts> <tag> → 0/1(stdout 落 $TMP/<tag>.log)
|
|
67
|
+
local ext="$1" tag="$2"
|
|
68
|
+
$RUNNER "$HARNESS" "$ext" >"$TMP/$tag.log" 2>&1
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
printf '修复前 revision: %s(%s)\n修复后 skill: %s\n运行时: %s\n' \
|
|
72
|
+
"$BASE" "$(git -C "$REPO_ROOT" log -1 --format=%s "$BASE")" "$SKILL_DIR" "$RUNNER"
|
|
73
|
+
|
|
74
|
+
# ── ① 修复前的树:按 BASE 缺什么形状判红 ───────────────────────────────────────
|
|
75
|
+
hdr "红①:修复前的树里的 team-bg(M30 之前 / P33 之前 / 根本没有这个扩展)"
|
|
76
|
+
mkdir -p "$TMP/red/ext"
|
|
77
|
+
git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith/extension 2>/dev/null | tar -x -C "$TMP/red"
|
|
78
|
+
RED_EXT="$TMP/red/skills/teamsmith/extension/team-bg.ts"
|
|
79
|
+
if [ -f "$RED_EXT" ] && grep -qF 'displayCmd(' "$RED_EXT"; then
|
|
80
|
+
# merge-base 已经落在修复之后的树上(例如 main 已合 P33、分支从那里切):没有「修复前」可对照。
|
|
81
|
+
# 不静默放水:点名说明,并提醒用 TEAM_FLIP_BASE 指到修复前的 revision;守卫仍由红②的定点破坏承担。
|
|
82
|
+
RED1=skipped
|
|
83
|
+
printf ' (跳过红①:%s 已经含 P33 的 displayCmd —— 没有修复前的树可对照;要跑翻转请用 TEAM_FLIP_BASE=<修复前 sha>)\n' "$BASE"
|
|
84
|
+
elif [ -f "$RED_EXT" ]; then
|
|
85
|
+
if grep -qF "'--show-toplevel'" "$RED_EXT"; then
|
|
86
|
+
# M27/M30 都在、只缺 P33:修复前的树里结果文本没有 `cmd:` 行 → 夹具应当红在 S12 的显示用例。
|
|
87
|
+
ok "前提成立:$BASE 里有 M30 之后的 team-bg.ts(P33 之前:结果里还不点命令)"
|
|
88
|
+
if run_harness "$RED_EXT" red-base; then
|
|
89
|
+
bad "修复前:夹具竟然全绿(结果里的 cmd 行没有被守门)"
|
|
90
|
+
elif grep -qF "TEAM-BG-CASE FAIL S12 short command is named in the result text" "$TMP/red-base.log"; then
|
|
91
|
+
ok "修复前:结果里没有命令 → S12 的显示用例红 —— 缺失被夹具复现"
|
|
92
|
+
else
|
|
93
|
+
bad "修复前:红了,但不是 P33 的显示用例:$(grep -m1 'TEAM-BG-CASE FAIL' "$TMP/red-base.log" | sed 's/^TEAM-BG-CASE FAIL //')"
|
|
94
|
+
fi
|
|
95
|
+
else
|
|
96
|
+
# main 已经合了 M27 → 修复前的树里是**旧版 team-bg**(缺 M30 的根解析修正):夹具应当**跑起来**
|
|
97
|
+
# 并红在 S11(worktree 会话的产物被写进共享根)——这一条红就是泄漏本身。
|
|
98
|
+
ok "前提成立:$BASE 里有 M30 之前的 team-bg.ts(旧根解析)"
|
|
99
|
+
if run_harness "$RED_EXT" red-base; then
|
|
100
|
+
bad "修复前:夹具竟然全绿(根解析泄漏没有被抓到)"
|
|
101
|
+
elif grep -qF "TEAM-BG-CASE FAIL S11 a worktree session writes its job log inside the worktree" "$TMP/red-base.log"; then
|
|
102
|
+
ok "修复前:旧根解析(--git-common-dir)让 S11 红 —— 泄漏被夹具复现"
|
|
103
|
+
else
|
|
104
|
+
bad "修复前:红了,但不是 S11(M30 的泄漏形状):$(grep -m1 'TEAM-BG-CASE FAIL' "$TMP/red-base.log" | sed 's/^TEAM-BG-CASE FAIL //')"
|
|
105
|
+
fi
|
|
106
|
+
fi
|
|
107
|
+
else
|
|
108
|
+
ok "前提成立:$BASE 的 extension/ 里只有 team-notify.ts(M27 之前的树)"
|
|
109
|
+
if run_harness "$RED_EXT" red-base; then
|
|
110
|
+
bad "修复前:夹具竟然全绿(缺失的扩展被当成了通过)"
|
|
111
|
+
else
|
|
112
|
+
ok "修复前:夹具非 0 退出($(grep -m1 'TEAM-BG-CASE FAIL' "$TMP/red-base.log" | sed 's/^TEAM-BG-CASE FAIL //'))"
|
|
113
|
+
fi
|
|
114
|
+
if grep -q 'TEAM-BG-CASE PASS' "$TMP/red-base.log"; then
|
|
115
|
+
bad "修复前:夹具居然跑出了通过用例(import 都失败了不该有)"
|
|
116
|
+
else
|
|
117
|
+
ok "修复前:一个用例都没有通过(import 阶段就红)"
|
|
118
|
+
fi
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
# ── ② 定点破坏:每一行都必须让对应用例变红 ───────────────────────────────────
|
|
122
|
+
hdr "红②:定点破坏(每个只改一行,各自必须红在对应用例)"
|
|
123
|
+
mutate_expect_red() { # <tag> <sed 表达式> <必须出现的 FAIL 用例名>
|
|
124
|
+
local tag="$1" expr="$2" want="$3" dir
|
|
125
|
+
MUTATIONS=$((MUTATIONS + 1))
|
|
126
|
+
dir="$TMP/mut-$tag"
|
|
127
|
+
mkdir -p "$dir"
|
|
128
|
+
cp "$SKILL_EXT" "$dir/team-bg.ts"
|
|
129
|
+
sed -i "$expr" "$dir/team-bg.ts"
|
|
130
|
+
if cmp -s "$SKILL_EXT" "$dir/team-bg.ts"; then
|
|
131
|
+
bad "$tag:定点破坏没生效(sed 表达式没匹配到)——不许把假红当证据"
|
|
132
|
+
return
|
|
133
|
+
fi
|
|
134
|
+
if run_harness "$dir/team-bg.ts" "$tag"; then
|
|
135
|
+
bad "$tag:破坏后夹具仍然全绿(这条性质没有被守门)"
|
|
136
|
+
elif grep -qF "TEAM-BG-CASE FAIL $want" "$TMP/$tag.log"; then
|
|
137
|
+
ok "$tag:红在「$want」"
|
|
138
|
+
else
|
|
139
|
+
bad "$tag:红了,但不是那条用例(期望 $want):$(grep -m1 'TEAM-BG-CASE FAIL' "$TMP/$tag.log" | sed 's/^TEAM-BG-CASE FAIL //')"
|
|
140
|
+
fi
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# 收割静默:完成筛选条件里去掉「未收割」这一条 → 已经收割过的作业仍会被唤醒
|
|
144
|
+
mutate_expect_red harvest-silent \
|
|
145
|
+
's/\.filter(j => j\.done && !j\.harvested && !j\.notified)/.filter(j => j.done \&\& !j.notified)/' \
|
|
146
|
+
"S2 harvested job never wakes the agent"
|
|
147
|
+
# 合并窗口:250ms → 0 → 同一拍完成的作业各发一条(#689 的过量唤醒)
|
|
148
|
+
mutate_expect_red merge-window \
|
|
149
|
+
's/const MERGE_WINDOW_MS = 250/const MERGE_WINDOW_MS = 0/' \
|
|
150
|
+
"S3 two jobs finishing together produce exactly one message"
|
|
151
|
+
# 唤醒投递方式:followUp+triggerTurn → nextTurn(排队不唤醒)
|
|
152
|
+
mutate_expect_red wake-mode \
|
|
153
|
+
"s/{ triggerTurn: true, deliverAs: 'followUp' }/{ deliverAs: 'nextTurn' }/" \
|
|
154
|
+
"S1 wake is a followUp with triggerTurn"
|
|
155
|
+
# 账本格式:settled-with-unharvested → 别的名字(PM 复验/digest 的读法失效)
|
|
156
|
+
mutate_expect_red ledger-format \
|
|
157
|
+
's/settled-with-unharvested=\${open\.length}/settle-unharvested=\${open.length}/' \
|
|
158
|
+
"S5 settled lines report the unharvested count"
|
|
159
|
+
# 日志上限:无视 TEAM_BG_LOG_MAX_BYTES(回到固定 512KB)→ 夹具的小上限不再生效
|
|
160
|
+
mutate_expect_red log-cap \
|
|
161
|
+
's/return Number\.isFinite(n) && n >= 256 ? n : DEFAULT_MAX_BYTES/return DEFAULT_MAX_BYTES/' \
|
|
162
|
+
"S6 log stays under the cap"
|
|
163
|
+
# 根解析(M30):worktree 会话的产物必须落在**自己的 worktree** —— 退回 git-common-dir 就是泄漏本身
|
|
164
|
+
mutate_expect_red worktree-root \
|
|
165
|
+
"s/'--show-toplevel'/'--git-common-dir'/" \
|
|
166
|
+
"S11 a worktree session writes its job log inside the worktree"
|
|
167
|
+
# P33-①:结果文本里去掉 `cmd:` 行 → 用户又看不到自己跑的是什么(短命令那条必须红)
|
|
168
|
+
mutate_expect_red cmd-line-drop \
|
|
169
|
+
's|\\n cmd: \${displayCmd(command)}||' \
|
|
170
|
+
"S12 short command is named in the result text"
|
|
171
|
+
# P33-②:文本直接用原命令(跳过单行化/缩略)→ 多行命令的换行跟着进结果(那条必须红)
|
|
172
|
+
mutate_expect_red cmd-raw-passthrough \
|
|
173
|
+
's|\${displayCmd(command)}|\${command}|' \
|
|
174
|
+
"S12 multiline command is single-lined in the result text"
|
|
175
|
+
# P33-③:按 UTF-16 单元切(one.split(""))而不是按码点 → 代理对会被劈成半个(长命令那条必须红)
|
|
176
|
+
mutate_expect_red cmd-unit-slice \
|
|
177
|
+
's|Array\.from(one)|one.split("")|' \
|
|
178
|
+
"S12 long command is truncated at the 100th code point + ellipsis"
|
|
179
|
+
# P33-④:收割回执里去掉 `cmd:` 行(sed 无 g 只换第一处 = still running 形状)→ 该形状的用例必须红
|
|
180
|
+
mutate_expect_red cmd-wait-drop \
|
|
181
|
+
's|\\n cmd: \${displayCmd(job\.command)}||' \
|
|
182
|
+
"S12 the harvest receipt (still running) names the command too"
|
|
183
|
+
|
|
184
|
+
# ── ③ 绿:当前树的真扩展 ─────────────────────────────────────────────────────
|
|
185
|
+
hdr "绿:当前树的真扩展(同一套夹具)"
|
|
186
|
+
if run_harness "$SKILL_EXT" green; then
|
|
187
|
+
ok "绿:夹具全绿($(grep -c 'TEAM-BG-CASE PASS' "$TMP/green.log") 条用例,$(grep -m1 'TEAM-BG-HARNESS' "$TMP/green.log"))"
|
|
188
|
+
else
|
|
189
|
+
bad "绿:当前树的扩展没过夹具"; grep 'TEAM-BG-CASE FAIL' "$TMP/green.log" | sed 's/^/ /'
|
|
190
|
+
fi
|
|
191
|
+
if grep -q 'TEAM-BG-CASE FAIL' "$TMP/green.log"; then
|
|
192
|
+
bad "绿:输出里还有 FAIL 用例"
|
|
193
|
+
else
|
|
194
|
+
ok "绿:没有 FAIL 用例"
|
|
195
|
+
fi
|
|
196
|
+
if grep -q 'reverse guard: the real repo state/ is untouched' "$TMP/green.log"; then
|
|
197
|
+
ok "反向守卫:夹具确认真实仓库 state/ 未被触碰"
|
|
198
|
+
else
|
|
199
|
+
bad "反向守卫:夹具没有跑到真实仓库 state/ 的快照对比"
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
# ── ④ 真 pi 的加载链(零模型调用):两个 -e 并列 + 坏扩展对照 ──────────────
|
|
203
|
+
hdr "真 pi 加载链:notify + bg 两个 -e(零模型调用),坏扩展必须让 pi 失败"
|
|
204
|
+
PI_BIN=""
|
|
205
|
+
if command -v pi >/dev/null 2>&1; then PI_BIN="$(command -v pi)"
|
|
206
|
+
elif [ -x "$HOME/.bun/bin/pi" ]; then PI_BIN="$HOME/.bun/bin/pi"; fi
|
|
207
|
+
if [ -z "$PI_BIN" ]; then
|
|
208
|
+
printf ' (跳过:PATH 里没有 pi 可执行文件 —— 这条是集成证据,不是门禁)\n'
|
|
209
|
+
else
|
|
210
|
+
PI_TIMEOUT="${TEAM_BG_PI_TIMEOUT:-30}"
|
|
211
|
+
# 正:两个真扩展都加载,pi 正常跑完(stdin EOF 就退出;rc=0 且没有 Failed to load)
|
|
212
|
+
( sleep 2 ) | timeout "$PI_TIMEOUT" "$PI_BIN" --mode rpc --no-session \
|
|
213
|
+
-e "$SKILL_DIR/extension/team-notify.ts" -e "$SKILL_EXT" >"$TMP/rpc-green.log" 2>&1
|
|
214
|
+
if [ "$?" -eq 0 ] && ! grep -qi 'failed to load' "$TMP/rpc-green.log"; then
|
|
215
|
+
ok "真 pi 接受两个 -e(notify + bg)且无加载错误"
|
|
216
|
+
else
|
|
217
|
+
bad "真 pi 加载两个扩展失败:$(grep -i 'failed to load' "$TMP/rpc-green.log" | head -1)"
|
|
218
|
+
fi
|
|
219
|
+
# 反:故意抛错的扩展必须让 pi 非 0 退出(证明上面那条不是「pi 根本不看 -e」)
|
|
220
|
+
printf 'export default function () { throw new Error("team-bg-flip-broken-probe") }\n' > "$TMP/broken-ext.ts"
|
|
221
|
+
( sleep 2 ) | timeout "$PI_TIMEOUT" "$PI_BIN" --mode rpc --no-session -e "$TMP/broken-ext.ts" >"$TMP/rpc-broken.log" 2>&1
|
|
222
|
+
if [ "$?" -ne 0 ] && grep -q 'team-bg-flip-broken-probe' "$TMP/rpc-broken.log"; then
|
|
223
|
+
ok "坏扩展对照:pi 拒绝加载(rc≠0 且报出被抛的错误)"
|
|
224
|
+
else
|
|
225
|
+
bad "坏扩展对照没红:pi 对加载失败的扩展无反应(上面那条正例就没有证据力)"
|
|
226
|
+
fi
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
printf '\n'
|
|
230
|
+
if [ "$FAIL" -eq 0 ]; then
|
|
231
|
+
if [ "$RED1" = "skipped" ]; then
|
|
232
|
+
printf '\033[32mteam-bg-flip:绿 + 红②×%d 全绿;红① 可见跳过(%s 已含修复,没有修复前的树可对照)\033[0m\n' "$MUTATIONS" "$BASE"
|
|
233
|
+
else
|
|
234
|
+
printf '\033[32mteam-bg-flip:翻转已复现(红① + 红②×%d → 绿)\033[0m\n' "$MUTATIONS"
|
|
235
|
+
fi
|
|
236
|
+
exit 0
|
|
237
|
+
fi
|
|
238
|
+
printf '\033[31mteam-bg-flip:没有观察到预期的翻转(%d 条失败)\033[0m\n' "$FAIL"
|
|
239
|
+
exit 1
|