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,238 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# M46 · 翻转包:投递通道降级可见 + 慢路径自愈的 red → green 证据
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/flip-m46.sh
|
|
5
|
+
# TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-m46.sh # 覆盖「修复前」的 revision
|
|
6
|
+
#
|
|
7
|
+
# 事故(2026-09-20,用户报「other_project 又没自动发消息」):PM 进程加载的是 M40 之前的
|
|
8
|
+
# team-inbox-watch.ts,按继承的 TEAM_* 解到 this-project,用 this-project 的会话名算出期望 target
|
|
9
|
+
# 与真实会话不符 → 每 2s 一次 `skip setup`,而痕迹全写进**别人的** state;投递静默退回输入框
|
|
10
|
+
# 粘贴路径 → 一次 draft-raced-left + 两条消息滞留。M46 修的是「降级没被看见 + 慢路径残留/
|
|
11
|
+
# 死目标没人管」,本包用四组翻转证明测试真的咬在实现上:
|
|
12
|
+
#
|
|
13
|
+
# ① 修复前($BASE)扩展:harness 的 M46-S14/S15/S16 必须 FAIL(复现:跳过无痕、state 无锚)
|
|
14
|
+
# ② 本树扩展:harness 全绿
|
|
15
|
+
# ③ 变异扩展(writeSkipRecord 变空操作):M46-S14 必须红
|
|
16
|
+
# ④ 变异 bash 三处(告警行恒假 / target_gone 恒假 / residue sweep 空操作):同一夹具上
|
|
17
|
+
# 三条断言各自变红 —— 去掉实现 → 断言红(不是「实现怎么改都绿」)
|
|
18
|
+
#
|
|
19
|
+
# 退出码:0 = 预期全部成立;1 = 有翻转不成立;2 = 环境/前置不满足(不算绿也不算红)。
|
|
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
|
+
REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
|
|
27
|
+
[ -n "$REPO_ROOT" ] || { printf 'flip-m46: 找不到 git 仓库(需要 git archive 取修复前的树)\n' >&2; exit 2; }
|
|
28
|
+
|
|
29
|
+
TS_RUNNER=""
|
|
30
|
+
if command -v node >/dev/null 2>&1 && node -e 'process.exit(process.features.typescript?0:1)' >/dev/null 2>&1; then
|
|
31
|
+
TS_RUNNER="node"
|
|
32
|
+
elif command -v bun >/dev/null 2>&1 && bun -e '1' >/dev/null 2>&1; then
|
|
33
|
+
TS_RUNNER="bun"
|
|
34
|
+
elif [ -x "$HOME/.bun/bin/bun" ] && "$HOME/.bun/bin/bun" -e '1' >/dev/null 2>&1; then
|
|
35
|
+
TS_RUNNER="$HOME/.bun/bin/bun"
|
|
36
|
+
fi
|
|
37
|
+
[ -n "$TS_RUNNER" ] || { printf 'flip-m46: 需要 node(类型剥离)或 bun 来跑 TS 扩展\n' >&2; exit 2; }
|
|
38
|
+
|
|
39
|
+
BASE="${TEAM_FLIP_BASE:-}"
|
|
40
|
+
if [ -z "$BASE" ]; then
|
|
41
|
+
BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
|
|
42
|
+
fi
|
|
43
|
+
[ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" rev-parse --verify -q HEAD^ 2>/dev/null || true)"
|
|
44
|
+
[ -n "$BASE" ] || { printf 'flip-m46: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
|
|
45
|
+
|
|
46
|
+
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
47
|
+
TMP="$(tmp_root_create flip-m46)" || exit 3
|
|
48
|
+
cleanup() {
|
|
49
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0 # 管道/命令替换的子 shell 不要重复清场
|
|
50
|
+
tmp_root_reap_all
|
|
51
|
+
}
|
|
52
|
+
trap cleanup EXIT
|
|
53
|
+
|
|
54
|
+
# 子串判定:用 case(不起管道)——`printf ... | grep -q` 在 `set -o pipefail` 下会被 grep 的提前退出
|
|
55
|
+
# 变成 SIGPIPE(141)而假红;日志越大越容易命中(P28 把 harness 日志从 ~14KB 撑到 ~17KB 时实测)。
|
|
56
|
+
has() { case "$2" in *"$1"*) return 0 ;; *) return 1 ;; esac; }
|
|
57
|
+
|
|
58
|
+
fail() { printf '\033[31m✗\033[0m %s\n' "$*"; }
|
|
59
|
+
pass() { printf '\033[32m✓\033[0m %s\n' "$*"; }
|
|
60
|
+
|
|
61
|
+
# ---- 树:红(修复前)/ 绿(本 worktree)/ 变异(绿 + 单点破坏)-------------------------------
|
|
62
|
+
mkdir -p "$TMP/red"
|
|
63
|
+
git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red" || exit 2
|
|
64
|
+
RED_EXT="$TMP/red/skills/teamsmith/extension/team-inbox-watch.ts"
|
|
65
|
+
GREEN="$SKILL_DIR"
|
|
66
|
+
GREEN_EXT="$SKILL_DIR/extension/team-inbox-watch.ts"
|
|
67
|
+
HARNESS="$SKILL_DIR/tests/team-inbox-watch-harness.mjs"
|
|
68
|
+
|
|
69
|
+
# 前置守卫:红树必须真的还没有 M46(否则报的是假翻转),绿树必须真的带着修复
|
|
70
|
+
if grep -q 'writeSkipRecord' "$RED_EXT" 2>/dev/null; then
|
|
71
|
+
printf 'flip-m46: $BASE 已经包含 M46 的修复(不是修复前的树)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' >&2
|
|
72
|
+
exit 2
|
|
73
|
+
fi
|
|
74
|
+
grep -q 'writeSkipRecord' "$GREEN_EXT" || { printf 'flip-m46: 本树扩展找不到 writeSkipRecord(修复不在?)\n' >&2; exit 2; }
|
|
75
|
+
|
|
76
|
+
# ③ 变异扩展:writeSkipRecord 变空操作(跳过不再留痕)
|
|
77
|
+
MUT_EXT_DIR="$TMP/mut-ext"
|
|
78
|
+
cp -a "$SKILL_DIR" "$MUT_EXT_DIR"
|
|
79
|
+
python3 - "$MUT_EXT_DIR/extension/team-inbox-watch.ts" <<'PY' || exit 2
|
|
80
|
+
import sys
|
|
81
|
+
p = sys.argv[1]
|
|
82
|
+
s = open(p).read()
|
|
83
|
+
old = "}): void {\n const dir = watchDir(root)"
|
|
84
|
+
new = "}): void {\n if (info.reason) return\n const dir = watchDir(root)"
|
|
85
|
+
if s.count(old) != 1:
|
|
86
|
+
sys.exit("flip-m46: writeSkipRecord 的函数体形状变了(找不到注入点)")
|
|
87
|
+
open(p, 'w').write(s.replace(old, new, 1))
|
|
88
|
+
PY
|
|
89
|
+
|
|
90
|
+
# ④ 变异 bash:三处单点破坏,各拷一份完整 skill 树
|
|
91
|
+
mk_bash_mut() { # <名字> <python 变异脚本> → 目录
|
|
92
|
+
local name="$1" patch="$2" dir
|
|
93
|
+
dir="$TMP/mut-$name"
|
|
94
|
+
cp -a "$SKILL_DIR" "$dir"
|
|
95
|
+
python3 "$patch" || exit 2
|
|
96
|
+
}
|
|
97
|
+
cat > "$TMP/patch-warn.py" <<PY
|
|
98
|
+
import sys
|
|
99
|
+
p = "$TMP/mut-warn/scripts/lib/outbox.sh"
|
|
100
|
+
s = open(p).read()
|
|
101
|
+
old = "team_inbox_watch_degraded_line() { #"
|
|
102
|
+
if s.count(old) != 1: sys.exit("flip-m46: 告警行函数形状变了")
|
|
103
|
+
open(p, 'w').write(s.replace(old, "team_inbox_watch_degraded_line() { return 1; #", 1))
|
|
104
|
+
PY
|
|
105
|
+
cat > "$TMP/patch-gone.py" <<PY
|
|
106
|
+
import sys
|
|
107
|
+
p = "$TMP/mut-gone/scripts/lib/outbox.sh"
|
|
108
|
+
s = open(p).read()
|
|
109
|
+
old = "team_outbox_target_gone() {\n"
|
|
110
|
+
if s.count(old) != 1: sys.exit("flip-m46: target_gone 函数形状变了")
|
|
111
|
+
open(p, 'w').write(s.replace(old, "team_outbox_target_gone() {\n return 1\n", 1))
|
|
112
|
+
PY
|
|
113
|
+
cat > "$TMP/patch-sweep.py" <<PY
|
|
114
|
+
import sys
|
|
115
|
+
p = "$TMP/mut-sweep/scripts/lib/outbox.sh"
|
|
116
|
+
s = open(p).read()
|
|
117
|
+
old = "team_outbox_sweep_residue() {\n"
|
|
118
|
+
if s.count(old) != 1: sys.exit("flip-m46: sweep 函数形状变了")
|
|
119
|
+
open(p, 'w').write(s.replace(old, "team_outbox_sweep_residue() {\n return 0\n", 1))
|
|
120
|
+
PY
|
|
121
|
+
mk_bash_mut warn "$TMP/patch-warn.py"
|
|
122
|
+
mk_bash_mut gone "$TMP/patch-gone.py"
|
|
123
|
+
mk_bash_mut sweep "$TMP/patch-sweep.py"
|
|
124
|
+
|
|
125
|
+
# ---- 聚焦夹具:一个临时项目 = 活 skip 痕迹 + 死目标 held + 框内残留 held + 框外残留 held -----
|
|
126
|
+
# 为什么要自己的夹具:烟雾全跑太慢,而这三条断言要能各自对上一处实现。
|
|
127
|
+
M46FIX="$TMP/fixture"; mkdir -p "$M46FIX"
|
|
128
|
+
FIX_ROOT="$M46FIX/proj"
|
|
129
|
+
mkdir -p "$FIX_ROOT/.pi/team/state/outbox/held" "$FIX_ROOT/.pi/team/state/inbox-watch" "$FIX_ROOT/docs/team/inbox"
|
|
130
|
+
( cd "$FIX_ROOT" && git init -q -b main . ) >/dev/null 2>&1
|
|
131
|
+
printf 'TEAM_PROJECT="m46-flip"\nTEAM_SESSION="live-sess"\nTEAM_PM_WINDOW="pm"\nTEAM_DOCS_DIR="docs/team"\nTEAM_VCS="local"\n' > "$FIX_ROOT/.pi/team/config.sh"
|
|
132
|
+
printf 'version=1\ntarget=other-project:pm\nkey=other-project_pm-00000000\nsession=other-project\nwindow=pm\nexpect=live-sess\ninbox=pm\nreason=session-mismatch\ndetail=session other-project != live-sess\npid=%s\ncwd=%s\nheartbeat=%s\n' \
|
|
133
|
+
"$$" "$FIX_ROOT" "$(date +%s)" > "$FIX_ROOT/.pi/team/state/inbox-watch/other-project_pm-00000000.skip"
|
|
134
|
+
printf 'kind: say\ntarget: old-session:pi\nfrom: pm\ncreated: x\ndedup: -\n---\nM46-FLIP-DEAD\n' > "$FIX_ROOT/.pi/team/state/outbox/held/1700000000000-0001-old-session:pi.msg"
|
|
135
|
+
printf 'kind: say\ntarget: live-sess:pm\nfrom: pm\ncreated: x\ndedup: -\n---\nM46-FLIP-STUCK\n' > "$FIX_ROOT/.pi/team/state/outbox/held/1700000000001-0002-live-sess:pm.msg"
|
|
136
|
+
printf 'kind: say\ntarget: live-sess:pm\nfrom: pm\ncreated: x\ndedup: -\n---\nM46-FLIP-BOXCLEAR\n' > "$FIX_ROOT/.pi/team/state/outbox/held/1700000000002-0003-live-sess:pm.msg"
|
|
137
|
+
{
|
|
138
|
+
printf '2026-09-20T02:00:00Z name=1700000000000-0001-old-session:pi.msg reason=expired-nopane held-since=x attempts=1 target=old-session:pi\n'
|
|
139
|
+
printf '2026-09-20T02:01:00Z name=1700000000001-0002-live-sess:pm.msg reason=draft-raced-left held-since=x attempts=1 target=live-sess:pm\n'
|
|
140
|
+
printf '2026-09-20T02:02:00Z name=1700000000002-0003-live-sess:pm.msg reason=draft-raced-left held-since=x attempts=1 target=live-sess:pm\n'
|
|
141
|
+
} > "$FIX_ROOT/.pi/team/state/outbox/HOLDING.log"
|
|
142
|
+
|
|
143
|
+
# 假 tmux:live-sess 在;box 里只有 M46-FLIP-STUCK(另一条残留的 payload 已经不在框里)
|
|
144
|
+
SHIM="$M46FIX/shim"; mkdir -p "$SHIM"
|
|
145
|
+
cat > "$SHIM/tmux" <<'SHIMEOF'
|
|
146
|
+
#!/usr/bin/env bash
|
|
147
|
+
case "$*" in
|
|
148
|
+
*has-session*) [ "${3:-}" = "live-sess" ] && exit 0 || exit 1 ;;
|
|
149
|
+
esac
|
|
150
|
+
case "$*" in
|
|
151
|
+
*pane_id*) case " $* " in *" live-sess:"*) printf '%%1\n'; exit 0 ;; esac; exit 1 ;;
|
|
152
|
+
*cursor_y*) printf '2\n'; exit 0 ;;
|
|
153
|
+
*pane_current_command*) printf 'pi\n'; exit 0 ;;
|
|
154
|
+
*bracket_paste_flag*) printf '1\n'; exit 0 ;;
|
|
155
|
+
*list-windows*) printf 'pm\n'; exit 0 ;;
|
|
156
|
+
*capture-pane*) printf 'transcript\n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\nM46-FLIP-STUCK\n\n\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n'; exit 0 ;;
|
|
157
|
+
esac
|
|
158
|
+
exit 1
|
|
159
|
+
SHIMEOF
|
|
160
|
+
chmod +x "$SHIM/tmux"
|
|
161
|
+
|
|
162
|
+
flip_cli() { # <skill 目录> <参数…> → stdout+stderr(身份隔离;fixture 的 shim 在 PATH 最前)
|
|
163
|
+
local skill="$1"; shift
|
|
164
|
+
( cd "$FIX_ROOT" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION \
|
|
165
|
+
-u TEAM_STATE_DIR -u TMUX -u TMUX_PANE -u TEAM_INBOX_WATCH_TARGET \
|
|
166
|
+
PATH="$SHIM:$PATH" bash "$skill/scripts/team" "$@" 2>&1 ) || true
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
RC=0
|
|
170
|
+
|
|
171
|
+
# ---- ① 红树:harness 的 M46 三条必须 FAIL ----
|
|
172
|
+
run_harness() { "$TS_RUNNER" "$HARNESS" "$1" 2>&1; }
|
|
173
|
+
RED_LOG="$(run_harness "$RED_EXT")"; RED_RC=$?
|
|
174
|
+
if [ "$RED_RC" -ne 0 ] \
|
|
175
|
+
&& has 'TEAM-IW-CASE FAIL M46-S14' "$RED_LOG" \
|
|
176
|
+
&& has 'TEAM-IW-CASE FAIL M46-S15' "$RED_LOG" && has 'TEAM-IW-CASE FAIL M46-S16' "$RED_LOG"; then
|
|
177
|
+
pass "红树($BASE)复现成功:M46-S14/S15/S16 全红(修复前:跳过无痕、继承的 state 无锚定)"
|
|
178
|
+
else
|
|
179
|
+
fail "红树没有复现(rc=$RED_RC;预期 M46-S14/S15/S16 全 FAIL)"
|
|
180
|
+
printf '%s\n' "$RED_LOG" | grep 'TEAM-IW-CASE' | tail -8 | sed 's/^/ /'
|
|
181
|
+
RC=1
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
# ---- ② 本树:harness 必须全绿 ----
|
|
185
|
+
GREEN_LOG="$(run_harness "$GREEN_EXT")"; GREEN_RC=$?
|
|
186
|
+
GREEN_N="$(printf '%s\n' "$GREEN_LOG" | grep -c 'TEAM-IW-CASE PASS')"
|
|
187
|
+
if [ "$GREEN_RC" -eq 0 ] && has 'TEAM-IW-HARNESS OK' "$GREEN_LOG"; then
|
|
188
|
+
pass "本树:harness 全绿($GREEN_N 条用例,含 M46-S14/S15/S16)"
|
|
189
|
+
else
|
|
190
|
+
fail "本树不是全绿(rc=$GREEN_RC)"
|
|
191
|
+
printf '%s\n' "$GREEN_LOG" | grep 'TEAM-IW-CASE FAIL' | sed 's/^/ /'
|
|
192
|
+
RC=1
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
# ---- ③ 变异扩展:writeSkipRecord 空操作 → S14 必须红 ----
|
|
196
|
+
MUT_LOG="$(run_harness "$MUT_EXT_DIR/extension/team-inbox-watch.ts")"; MUT_RC=$?
|
|
197
|
+
if [ "$MUT_RC" -ne 0 ] && has 'TEAM-IW-CASE FAIL M46-S14' "$MUT_LOG"; then
|
|
198
|
+
pass "变异扩展(writeSkipRecord 空操作):M46-S14 红 —— 守卫测试咬在留痕实现上"
|
|
199
|
+
else
|
|
200
|
+
fail "变异扩展没有红(rc=$MUT_RC;预期 M46-S14 FAIL)"
|
|
201
|
+
printf '%s\n' "$MUT_LOG" | grep 'TEAM-IW-CASE' | tail -6 | sed 's/^/ /'
|
|
202
|
+
RC=1
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
# ---- ④ 变异 bash:三处单点破坏 → 同夹具上的三条断言各自变红 ----
|
|
206
|
+
GREEN_STATUS="$(flip_cli "$GREEN" status)"
|
|
207
|
+
MUT_STATUS="$(flip_cli "$TMP/mut-warn" status)"
|
|
208
|
+
if has '投递通道降级' "$GREEN_STATUS" && ! has '投递通道降级' "$MUT_STATUS"; then
|
|
209
|
+
pass "bash 变异①(告警行恒假):绿树 status 报降级 / 变异树不报 —— 这条断言真的钉在告警实现上"
|
|
210
|
+
else
|
|
211
|
+
fail "bash 变异① 翻转不成立(绿树:$(printf '%s' "$GREEN_STATUS" | grep -c '投递通道降级') 条降级;变异树:$(printf '%s' "$MUT_STATUS" | grep -c '投递通道降级') 条)"
|
|
212
|
+
RC=1
|
|
213
|
+
fi
|
|
214
|
+
GREEN_LIST="$(flip_cli "$GREEN" outbox list)"
|
|
215
|
+
MUT_LIST="$(flip_cli "$TMP/mut-gone" outbox list)"
|
|
216
|
+
if has 'target=gone' "$GREEN_LIST" && ! has 'target=gone' "$MUT_LIST"; then
|
|
217
|
+
pass "bash 变异②(target_gone 恒假):绿树 list 标 target=gone / 变异树不标 —— 断言钉在死目标判定上"
|
|
218
|
+
else
|
|
219
|
+
fail "bash 变异② 翻转不成立(绿树:$(printf '%s' "$GREEN_LIST" | grep -c 'target=gone');变异树:$(printf '%s' "$MUT_LIST" | grep -c 'target=gone'))"
|
|
220
|
+
RC=1
|
|
221
|
+
fi
|
|
222
|
+
# 残留巡检:先绿树 flush → 记账本;变异树用自己的夹具副本(HOLDING.log 也拷一份)
|
|
223
|
+
cp -a "$FIX_ROOT" "$TMP/fixture-mut"
|
|
224
|
+
( cd "$TMP/fixture-mut" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION \
|
|
225
|
+
-u TEAM_STATE_DIR -u TMUX -u TMUX_PANE -u TEAM_INBOX_WATCH_TARGET \
|
|
226
|
+
PATH="$SHIM:$PATH" bash "$TMP/mut-sweep/scripts/team" outbox flush ) >/dev/null 2>&1 || true
|
|
227
|
+
flip_cli "$GREEN" outbox flush >/dev/null
|
|
228
|
+
GREEN_SWEEP="$(grep -c 'residue-clear entry=1700000000002-0003' "$FIX_ROOT/.pi/team/state/outbox/HOLDING.log" || true)"
|
|
229
|
+
MUT_SWEEP="$(grep -c 'residue-clear entry=1700000000002-0003' "$TMP/fixture-mut/.pi/team/state/outbox/HOLDING.log" || true)"
|
|
230
|
+
if [ "$GREEN_SWEEP" -ge 1 ] && [ "$MUT_SWEEP" -eq 0 ]; then
|
|
231
|
+
pass "bash 变异③(residue sweep 空操作):绿树记 residue-clear / 变异树不记 —— 断言钉在巡检实现上"
|
|
232
|
+
else
|
|
233
|
+
fail "bash 变异③ 翻转不成立(绿树=$GREEN_SWEEP,变异树=$MUT_SWEEP)"
|
|
234
|
+
RC=1
|
|
235
|
+
fi
|
|
236
|
+
|
|
237
|
+
printf 'exit=%s\n' "$RC"
|
|
238
|
+
exit "$RC"
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# M48 flips: the duplicate-id work is pinned to the thing that changed, in both halves.
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/flip-m48.sh focus # 控制台:焦点按行身份(翻转 = 改回按 ID 比较)
|
|
5
|
+
# bash skills/teamsmith/tests/flip-m48.sh add # CLI:board add 拒绝重复(翻转 = 去掉检查)
|
|
6
|
+
# bash skills/teamsmith/tests/flip-m48.sh assign # CLI:assign 原地改 agent(翻转 = 改回「再 add 一行」)
|
|
7
|
+
# bash skills/teamsmith/tests/flip-m48.sh # 三个都跑
|
|
8
|
+
# bash skills/teamsmith/tests/flip-m48.sh --keep # 保留临时目录(排查)
|
|
9
|
+
#
|
|
10
|
+
# focus:`src` 的临时副本打补丁(焦点匹配与 ↑/↓ 走路改回裸 ID 比较)→ bun 重建翻转 bundle →
|
|
11
|
+
# `tests/panel-b3.sh board` 跑两遍(翻转 bundle 应红在 M48 的重复断言上,提交的 bundle 应绿)。
|
|
12
|
+
# 真源码一个字节都不动。
|
|
13
|
+
# add:skill 树的临时副本去掉 `team_board_add` 的重复检查 → 用 smoke 的**前导 + §0/§2/§4/§4b/§4c**
|
|
14
|
+
# 拼出的聚焦探针(判据就是门禁里的那一份,不是抄的第二份)跑两遍:副本应红在 §4c 的
|
|
15
|
+
# 「重复 ID 被拒 / 文件未变」上,真树应绿。
|
|
16
|
+
# assign:skill 临时副本把 `team_board_assign` 的写口换成「再 add 一行」(即重复 ID 进来的老路)→
|
|
17
|
+
# 同一探针:副本应红在「assign 后行数不变 / T1.1 仍是两行」上,真树应绿。
|
|
18
|
+
#
|
|
19
|
+
# 退出码:0 = 翻转都成立;1 = 有预期不成立;2 = 环境/前置不满足。
|
|
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
|
+
TREE="$(cd -P "$SKILL_DIR/../.." && pwd)"
|
|
27
|
+
SMOKE="$SKILL_DIR/tests/smoke.sh"
|
|
28
|
+
PANEL_DIR="$SKILL_DIR/scripts/panel"
|
|
29
|
+
PIN="$PANEL_DIR/panel.js"
|
|
30
|
+
|
|
31
|
+
mode=""
|
|
32
|
+
case "${1:-}" in
|
|
33
|
+
"") mode=all ;;
|
|
34
|
+
focus|add|assign) mode="$1" ;;
|
|
35
|
+
--keep) KEEP=1; mode="${2:-all}" ;;
|
|
36
|
+
-h|--help) sed -n '2,20p' "$0"; exit 0 ;;
|
|
37
|
+
*) printf 'flip-m48: 未知参数 %s(focus|add|assign|all|--keep)\n' "$1" >&2; exit 2 ;;
|
|
38
|
+
esac
|
|
39
|
+
case "$mode" in all|focus|add|assign) ;; *) printf 'flip-m48: 未知模式 %s\n' "$mode" >&2; exit 2 ;; esac
|
|
40
|
+
KEEP="${KEEP:-0}"
|
|
41
|
+
|
|
42
|
+
die2() { printf 'flip-m48: %s\n' "$*" >&2; exit 2; }
|
|
43
|
+
pass() { printf ' \033[32m✓\033[0m %s\n' "$*"; }
|
|
44
|
+
fail() { printf ' \033[31m✗\033[0m %s\n' "$*"; RC=1; }
|
|
45
|
+
plain() { sed 's/\x1b\[[0-9;]*m//g' "$1"; }
|
|
46
|
+
|
|
47
|
+
command -v git >/dev/null 2>&1 || die2 "需要 git"
|
|
48
|
+
command -v python3 >/dev/null 2>&1 || die2 "需要 python3(打补丁)"
|
|
49
|
+
[ -s "$SMOKE" ] || die2 "找不到 $SMOKE"
|
|
50
|
+
[ -s "$PIN" ] || die2 "找不到 bundle($PIN)"
|
|
51
|
+
|
|
52
|
+
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
53
|
+
TMP="$(tmp_root_create flip-m48)" || exit 3
|
|
54
|
+
cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; [ "$KEEP" = "1" ] || tmp_root_reap_all; return 0; }
|
|
55
|
+
trap cleanup EXIT
|
|
56
|
+
RC=0
|
|
57
|
+
|
|
58
|
+
printf '\033[1m== flip-m48 · 看板重复 ID(%s)==\033[0m\n' "$mode"
|
|
59
|
+
|
|
60
|
+
# ---------------------------------------------------------------- focus(控制台)
|
|
61
|
+
flip_focus() {
|
|
62
|
+
local bun js ink_pin react_pin
|
|
63
|
+
bun="${M48_FLIP_BUN:-}"
|
|
64
|
+
[ -n "$bun" ] || bun="$(command -v bun 2>/dev/null || true)"
|
|
65
|
+
[ -n "$bun" ] || bun="$HOME/.bun/bin/bun"
|
|
66
|
+
js="$(command -v node || command -v bun || true)"
|
|
67
|
+
[ -x "$bun" ] || { printf ' 跳过 focus:需要 bun 重建翻转 bundle(%s)\n' "$bun" >&2; return 2; }
|
|
68
|
+
[ -n "$js" ] || { printf ' 跳过 focus:本机没有 node/bun\n' >&2; return 2; }
|
|
69
|
+
command -v tmux >/dev/null 2>&1 || { printf ' 跳过 focus:panel-b3 需要 tmux\n' >&2; return 2; }
|
|
70
|
+
ink_pin="$(sed -n 's/.*"ink": *"\([^"]*\)".*/\1/p' "$PANEL_DIR/package.json")"
|
|
71
|
+
react_pin="$(sed -n 's/.*"react": *"\([^"]*\)".*/\1/p' "$PANEL_DIR/package.json")"
|
|
72
|
+
|
|
73
|
+
local src="$TMP/focus-src" out="$TMP/focus-panel.js"
|
|
74
|
+
mkdir -p "$src"
|
|
75
|
+
cp -r "$PANEL_DIR/src/." "$src/"
|
|
76
|
+
ln -sfn "$PANEL_DIR/node_modules" "$src/node_modules"
|
|
77
|
+
python3 - "$src" <<'PY' || return 2
|
|
78
|
+
import sys
|
|
79
|
+
|
|
80
|
+
d = sys.argv[1]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def edit(name, old, new):
|
|
84
|
+
path = f'{d}/{name}'
|
|
85
|
+
s = open(path, encoding='utf-8').read()
|
|
86
|
+
if s.count(old) != 1:
|
|
87
|
+
sys.exit(f'flip-m48: pattern not unique ({s.count(old)}): {old[:70]!r}')
|
|
88
|
+
open(path, 'w', encoding='utf-8').write(s.replace(old, new))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# The App's kanban walk goes back to the id lookup: `findIndex` by id always answers with the first
|
|
92
|
+
# of two rows sharing an id, and the same-id early return then freezes the cursor on it.
|
|
93
|
+
edit('App.tsx', """ const row = focusRow(rows, current)
|
|
94
|
+
if (!row) return
|
|
95
|
+
const inLane = rows.filter((r) => r.state === current.lane)
|
|
96
|
+
const idx = inLane.indexOf(row)
|
|
97
|
+
const next = idx < 0 ? undefined : inLane[idx + cardDelta]
|
|
98
|
+
if (!next || next === row) return""", """ const inLane = rows.filter((r) => r.state === current.lane) // FLIP m48: id lookup
|
|
99
|
+
const idx = inLane.findIndex((r) => r.id === current.id) // FLIP m48
|
|
100
|
+
const next = inLane[Math.max(0, Math.min(inLane.length - 1, idx + cardDelta))] // FLIP m48
|
|
101
|
+
if (!next || next.id === current.id) return // FLIP m48: the freeze""")
|
|
102
|
+
# The card highlight goes back to comparing ids: both duplicates light up at once.
|
|
103
|
+
edit('layout.ts', """ for (let i = win.start; i < win.end; i++) {
|
|
104
|
+
const card = cards[i]
|
|
105
|
+
const focused = card === target""", """ for (let i = win.start; i < win.end; i++) {
|
|
106
|
+
const card = cards[i]
|
|
107
|
+
const focused = card.id === (target?.id ?? '') // FLIP m48: id match lights both rows""")
|
|
108
|
+
edit('layout.ts', """ for (const card of cards) {
|
|
109
|
+
const focused = card === target""", """ for (const card of cards) {
|
|
110
|
+
const focused = card.id === (target?.id ?? '') // FLIP m48: id match lights both rows""")
|
|
111
|
+
PY
|
|
112
|
+
( cd "$PANEL_DIR" && "$bun" build "$src/main.tsx" --target=node --format=esm --minify \
|
|
113
|
+
--define "__PIN_INK__=\"$ink_pin\"" --define "__PIN_REACT__=\"$react_pin\"" \
|
|
114
|
+
--outfile "$out" ) >"$TMP/focus-build.log" 2>&1 || {
|
|
115
|
+
printf ' ✗ focus:翻转 bundle 构建失败\n' >&2; tail -5 "$TMP/focus-build.log" >&2; return 2
|
|
116
|
+
}
|
|
117
|
+
grep -q 'FLIP m48' "$src/App.tsx" "$src/layout.ts" || { printf ' ✗ focus:补丁没写进去\n' >&2; return 2; }
|
|
118
|
+
|
|
119
|
+
local flipped_log="$TMP/focus-flipped.log" now_log="$TMP/focus-now.log" rc rc2
|
|
120
|
+
TEAM_B3_PANEL="$out" bash "$SKILL_DIR/tests/panel-b3.sh" board >"$flipped_log" 2>&1; rc=$?
|
|
121
|
+
TEAM_B3_PANEL="$PIN" bash "$SKILL_DIR/tests/panel-b3.sh" board >"$now_log" 2>&1; rc2=$?
|
|
122
|
+
printf ' 翻转 bundle 的 board 场景:rc=%s(✗ %s 条)|提交 bundle:rc=%s(✗ %s 条)\n' \
|
|
123
|
+
"$rc" "$(plain "$flipped_log" | grep -ac '^ .*✗' || true)" "$rc2" "$(plain "$now_log" | grep -ac '^ .*✗' || true)"
|
|
124
|
+
|
|
125
|
+
local want_flipped="" l
|
|
126
|
+
for l in '✗ M48 重复 ID:↓ 走到同 ID 的第二行(不卡死)' '✗ M48 重复 ID:焦点光标恰好一个(不是两行都亮)'; do
|
|
127
|
+
{ plain "$flipped_log" || true; } | grep -qF -- "$l" || want_flipped="$want_flipped
|
|
128
|
+
$l"
|
|
129
|
+
done
|
|
130
|
+
if [ -n "$want_flipped" ]; then
|
|
131
|
+
fail "focus:翻转 bundle 没有红在预期断言上:$want_flipped"
|
|
132
|
+
plain "$flipped_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
|
|
133
|
+
else
|
|
134
|
+
pass "focus:翻转(改回按 ID 比较)→ 重复 ID 的行走/单光标断言变红"
|
|
135
|
+
fi
|
|
136
|
+
if [ "$rc2" -eq 0 ] && ! { plain "$now_log" || true; } | grep -q '^ .*✗'; then
|
|
137
|
+
pass "focus:提交的 bundle 在同一场景全绿(同一夹具、同一判据红→绿)"
|
|
138
|
+
else
|
|
139
|
+
fail "focus:提交的 bundle 在 board 场景有失败项(rc=$rc2)"
|
|
140
|
+
plain "$now_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
|
|
141
|
+
fi
|
|
142
|
+
return 0
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
# ---------------------------------------------------------------- add(CLI 守卫)
|
|
146
|
+
extract_section() { # <file> <name> → 打印该 section 的整块
|
|
147
|
+
local f="$1" name="$2" start end
|
|
148
|
+
start="$(grep -n -F "section \"$name\"" "$f" | head -1 | cut -d: -f1)"
|
|
149
|
+
[ -n "$start" ] || return 1
|
|
150
|
+
end="$(awk -v s="$start" 'NR>s && /^section "/ { print NR; exit }' "$f")"
|
|
151
|
+
if [ -n "$end" ]; then sed -n "${start},$((end-1))p" "$f"; else sed -n "${start},\$p" "$f"; fi
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
build_probe() { # <out> <skill-dir>:smoke 前导 + §0/§2/§4/§4b/§4c(判据就是门禁里那一份)
|
|
155
|
+
local out="$1" sk="$2"
|
|
156
|
+
{
|
|
157
|
+
awk '/^# -+ 0\. 仓库/{exit} {print}' "$SMOKE"
|
|
158
|
+
extract_section "$SMOKE" "0 · 临时仓库"
|
|
159
|
+
extract_section "$SMOKE" "2 · init"
|
|
160
|
+
extract_section "$SMOKE" "4 · task + board"
|
|
161
|
+
extract_section "$SMOKE" "4b · 状态诚实:未知 id 不假装写入 + done 要证据(M6.1 F29/F1)"
|
|
162
|
+
extract_section "$SMOKE" "4c · 看板重复 ID(M48):add 拒绝 / --allow-dup / 三处可见"
|
|
163
|
+
cat <<'EOS'
|
|
164
|
+
section "PROBE-M48-END"
|
|
165
|
+
printf '\n== 结果 == ok %d bad %d\n' "$PASS" "$FAIL"
|
|
166
|
+
printf 'PROBE-M48-END\n'
|
|
167
|
+
[ "$FAIL" -eq 0 ] && exit 0
|
|
168
|
+
exit 1
|
|
169
|
+
EOS
|
|
170
|
+
} | sed "s|^SKILL_DIR=.*|SKILL_DIR=\"$sk\"|" > "$out"
|
|
171
|
+
grep -q '^section "4c ' "$out" || die2 "$SMOKE 里没有 §4c(M48 的守卫不在?)"
|
|
172
|
+
grep -q '^section "PROBE-M48-END"' "$out" || die2 "探针结尾没写进去"
|
|
173
|
+
bash -n "$out" || die2 "探针语法不对(截取写坏了):$out"
|
|
174
|
+
return 0
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
run_probe() { # <probe> <log>
|
|
178
|
+
local probe="$1" log="$2"
|
|
179
|
+
TEAM_SMOKE_NO_LOCK=1 bash "$probe" > "$log" 2>&1
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
flip_add() {
|
|
183
|
+
local copy="$TMP/add-tree"
|
|
184
|
+
mkdir -p "$copy/skills"
|
|
185
|
+
# 两个 skill 都要(SKILL_INIT_DIR 是兄弟目录);node_modules 不需要,跳过。
|
|
186
|
+
( cd "$TREE" && tar --exclude='*/node_modules' -cf - skills ) | ( cd "$copy" && tar -xf - ) || return 2
|
|
187
|
+
[ -d "$copy/skills/teamsmith-init" ] || { printf ' ✗ add:skill 副本不完整\n' >&2; return 2; }
|
|
188
|
+
python3 - "$copy/skills/teamsmith/scripts/lib/common.sh" <<'PY' || return 2
|
|
189
|
+
import sys
|
|
190
|
+
|
|
191
|
+
path = sys.argv[1]
|
|
192
|
+
s = open(path, encoding='utf-8').read()
|
|
193
|
+
old = """ if team_board_has "$1"; then
|
|
194
|
+
if [ "$allow_dup" != "1" ]; then"""
|
|
195
|
+
new = """ if false; then # FLIP m48: the duplicate check removed
|
|
196
|
+
if [ "$allow_dup" != "1" ]; then"""
|
|
197
|
+
if s.count(old) != 1:
|
|
198
|
+
sys.exit(f'flip-m48: pattern not unique ({s.count(old)})')
|
|
199
|
+
open(path, 'w', encoding='utf-8').write(s.replace(old, new))
|
|
200
|
+
PY
|
|
201
|
+
grep -q 'FLIP m48: the duplicate check removed' "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ add:补丁没写进去\n' >&2; return 2; }
|
|
202
|
+
bash -n "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ add:补丁把脚本改坏了\n' >&2; return 2; }
|
|
203
|
+
|
|
204
|
+
local mutated_log="$TMP/add-flipped.log" real_log="$TMP/add-now.log"
|
|
205
|
+
build_probe "$TMP/probe-mutated.sh" "$copy/skills/teamsmith" || return 2
|
|
206
|
+
build_probe "$TMP/probe-real.sh" "$SKILL_DIR" || return 2
|
|
207
|
+
run_probe "$TMP/probe-mutated.sh" "$mutated_log"; local mrc=$?
|
|
208
|
+
run_probe "$TMP/probe-real.sh" "$real_log"; local rrc=$?
|
|
209
|
+
grep -q '^PROBE-M48-END$' "$mutated_log" || { printf ' ✗ add:翻转侧探针没跑完(%s)\n' "$(tail -1 "$mutated_log")" >&2; return 2; }
|
|
210
|
+
grep -q '^PROBE-M48-END$' "$real_log" || { printf ' ✗ add:真树侧探针没跑完(%s)\n' "$(tail -1 "$real_log")" >&2; return 2; }
|
|
211
|
+
printf ' 翻转 skill 的 §4c:rc=%s(✗ %s 条)|真树 §4c:rc=%s(✗ %s 条)\n' \
|
|
212
|
+
"$mrc" "$(plain "$mutated_log" | grep -ac '^ .*✗' || true)" "$rrc" "$(plain "$real_log" | grep -ac '^ .*✗' || true)"
|
|
213
|
+
|
|
214
|
+
if [ "$mrc" -ne 0 ] && { plain "$mutated_log" || true; } | grep -qF '✗ M48:重复 ID 的 board add 应当被拒'; then
|
|
215
|
+
pass "add:去掉检查 → §4c 的「重复 ID 应当被拒」变红(守卫测试真的咬在检查上)"
|
|
216
|
+
plain "$mutated_log" | grep -aF 'M48:' | grep -aF '✗' | sed 's/^/ /' | head -5
|
|
217
|
+
else
|
|
218
|
+
fail "add:去掉检查后 §4c 没有红在预期断言上(rc=$mrc)"
|
|
219
|
+
plain "$mutated_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -8
|
|
220
|
+
fi
|
|
221
|
+
if [ "$rrc" -eq 0 ] && ! { plain "$real_log" || true; } | grep -q '^ .*✗'; then
|
|
222
|
+
pass "add:真树(带检查)在同一探针上全绿"
|
|
223
|
+
else
|
|
224
|
+
fail "add:真树在 §4c 探针上有失败项(rc=$rrc)"
|
|
225
|
+
plain "$real_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -8
|
|
226
|
+
fi
|
|
227
|
+
return 0
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
# ---------------------------------------------------------------- assign(原地指派的正门)
|
|
231
|
+
flip_assign() {
|
|
232
|
+
local copy="$TMP/assign-tree"
|
|
233
|
+
mkdir -p "$copy/skills"
|
|
234
|
+
( cd "$TREE" && tar --exclude='*/node_modules' -cf - skills ) | ( cd "$copy" && tar -xf - ) || return 2
|
|
235
|
+
[ -d "$copy/skills/teamsmith-init" ] || { printf ' ✗ assign:skill 副本不完整\n' >&2; return 2; }
|
|
236
|
+
# 老路:指派 = 再写一行(重复 ID 就是这么进来的)。真源码一个字节不动。
|
|
237
|
+
python3 - "$copy/skills/teamsmith/scripts/lib/common.sh" <<'PY' || return 2
|
|
238
|
+
import sys
|
|
239
|
+
|
|
240
|
+
path = sys.argv[1]
|
|
241
|
+
s = open(path, encoding='utf-8').read()
|
|
242
|
+
old = """ team_board_write_col "$id" agent "$ag" || return 1
|
|
243
|
+
return 0
|
|
244
|
+
}"""
|
|
245
|
+
new = """ team_board_add "$id" "指派 $ag" "$ag" "-" "-" 1 || return 1 # FLIP m48: assign by adding a row
|
|
246
|
+
return 0
|
|
247
|
+
}"""
|
|
248
|
+
if s.count(old) != 1:
|
|
249
|
+
sys.exit(f'flip-m48: pattern not unique ({s.count(old)})')
|
|
250
|
+
open(path, 'w', encoding='utf-8').write(s.replace(old, new))
|
|
251
|
+
PY
|
|
252
|
+
grep -q 'FLIP m48: assign by adding a row' "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ assign:补丁没写进去\n' >&2; return 2; }
|
|
253
|
+
bash -n "$copy/skills/teamsmith/scripts/lib/common.sh" || { printf ' ✗ assign:补丁把脚本改坏了\n' >&2; return 2; }
|
|
254
|
+
|
|
255
|
+
local mutated_log="$TMP/assign-flipped.log" real_log="$TMP/assign-now.log"
|
|
256
|
+
build_probe "$TMP/probe-assign-mutated.sh" "$copy/skills/teamsmith" || return 2
|
|
257
|
+
build_probe "$TMP/probe-assign-real.sh" "$SKILL_DIR" || return 2
|
|
258
|
+
run_probe "$TMP/probe-assign-mutated.sh" "$mutated_log"; local mrc=$?
|
|
259
|
+
run_probe "$TMP/probe-assign-real.sh" "$real_log"; local rrc=$?
|
|
260
|
+
grep -q '^PROBE-M48-END$' "$mutated_log" || { printf ' ✗ assign:翻转侧探针没跑完(%s)\n' "$(tail -1 "$mutated_log")" >&2; return 2; }
|
|
261
|
+
grep -q '^PROBE-M48-END$' "$real_log" || { printf ' ✗ assign:真树侧探针没跑完(%s)\n' "$(tail -1 "$real_log")" >&2; return 2; }
|
|
262
|
+
printf ' 翻转 skill 的 §4c:rc=%s(✗ %s 条)|真树 §4c:rc=%s(✗ %s 条)\n' \
|
|
263
|
+
"$mrc" "$(plain "$mutated_log" | grep -ac '^ .*✗' || true)" "$rrc" "$(plain "$real_log" | grep -ac '^ .*✗' || true)"
|
|
264
|
+
|
|
265
|
+
local want="" l
|
|
266
|
+
for l in '✗ M48:assign 后行数不变(不是又加一行)' '✗ M48:assign 后 T1.1 仍是两行(没有顺手改历史数据)'; do
|
|
267
|
+
{ plain "$mutated_log" || true; } | grep -qF -- "$l" || want="$want
|
|
268
|
+
$l"
|
|
269
|
+
done
|
|
270
|
+
if [ -n "$want" ]; then
|
|
271
|
+
fail "assign:翻转(指派改成再写一行)没有红在预期断言上:$want"
|
|
272
|
+
plain "$mutated_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
|
|
273
|
+
else
|
|
274
|
+
pass "assign:翻转(指派 = 再写一行)→ 行数/去重断言变红(守卫真的咬在「原地改」上)"
|
|
275
|
+
fi
|
|
276
|
+
if [ "$rrc" -eq 0 ] && ! { plain "$real_log" || true; } | grep -q '^ .*✗'; then
|
|
277
|
+
pass "assign:真树(原地改 agent)在同一探针上全绿"
|
|
278
|
+
else
|
|
279
|
+
fail "assign:真树在 §4c 探针上有失败项(rc=$rrc)"
|
|
280
|
+
plain "$real_log" | grep -aE '^ .*✗' | sed 's/^/ /' | head -10
|
|
281
|
+
fi
|
|
282
|
+
return 0
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
case "$mode" in
|
|
286
|
+
focus) flip_focus || RC=1 ;;
|
|
287
|
+
add) flip_add || RC=1 ;;
|
|
288
|
+
assign) flip_assign || RC=1 ;;
|
|
289
|
+
all)
|
|
290
|
+
flip_focus || RC=1
|
|
291
|
+
printf '\n'
|
|
292
|
+
flip_add || RC=1
|
|
293
|
+
printf '\n'
|
|
294
|
+
flip_assign || RC=1
|
|
295
|
+
;;
|
|
296
|
+
esac
|
|
297
|
+
|
|
298
|
+
printf '\n'
|
|
299
|
+
if [ "$RC" -eq 0 ]; then
|
|
300
|
+
printf '\033[32mflip-m48 全部成立\033[0m\n'
|
|
301
|
+
else
|
|
302
|
+
printf '\033[31mflip-m48 有翻转不成立\033[0m\n'
|
|
303
|
+
fi
|
|
304
|
+
exit "$RC"
|