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.
Files changed (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +158 -2
  3. package/bin/team.mjs +59 -0
  4. package/install.sh +94 -0
  5. package/package.json +37 -4
  6. package/skills/teamsmith/CHANGELOG.md +763 -0
  7. package/skills/teamsmith/SKILL.md +312 -0
  8. package/skills/teamsmith/extension/team-bg.ts +435 -0
  9. package/skills/teamsmith/extension/team-inbox-watch.ts +1412 -0
  10. package/skills/teamsmith/extension/team-notify.ts +663 -0
  11. package/skills/teamsmith/references/agent-adapters.md +643 -0
  12. package/skills/teamsmith/references/config.md +477 -0
  13. package/skills/teamsmith/references/meeting.md +124 -0
  14. package/skills/teamsmith/references/memory.md +133 -0
  15. package/skills/teamsmith/references/migration.md +227 -0
  16. package/skills/teamsmith/references/openspec.md +222 -0
  17. package/skills/teamsmith/references/philosophy.md +95 -0
  18. package/skills/teamsmith/references/protocol.md +712 -0
  19. package/skills/teamsmith/references/troubleshooting.md +1384 -0
  20. package/skills/teamsmith/references/workflows.md +448 -0
  21. package/skills/teamsmith/scripts/lib/cmd-agents.sh +1709 -0
  22. package/skills/teamsmith/scripts/lib/cmd-bg.sh +284 -0
  23. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +311 -0
  24. package/skills/teamsmith/scripts/lib/cmd-config.sh +1156 -0
  25. package/skills/teamsmith/scripts/lib/cmd-death.sh +562 -0
  26. package/skills/teamsmith/scripts/lib/cmd-docs.sh +149 -0
  27. package/skills/teamsmith/scripts/lib/cmd-draft.sh +124 -0
  28. package/skills/teamsmith/scripts/lib/cmd-init.sh +212 -0
  29. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +904 -0
  30. package/skills/teamsmith/scripts/lib/cmd-outbox.sh +196 -0
  31. package/skills/teamsmith/scripts/lib/cmd-project.sh +642 -0
  32. package/skills/teamsmith/scripts/lib/cmd-review.sh +1393 -0
  33. package/skills/teamsmith/scripts/lib/cmd-status.sh +1399 -0
  34. package/skills/teamsmith/scripts/lib/cmd-update.sh +191 -0
  35. package/skills/teamsmith/scripts/lib/cmd-watch.sh +1681 -0
  36. package/skills/teamsmith/scripts/lib/common.sh +4964 -0
  37. package/skills/teamsmith/scripts/lib/draft-entry.sh +51 -0
  38. package/skills/teamsmith/scripts/lib/outbox.sh +2042 -0
  39. package/skills/teamsmith/scripts/lib/tmux-argv.sh +165 -0
  40. package/skills/teamsmith/scripts/monitor.mjs +616 -0
  41. package/skills/teamsmith/scripts/panel/README.md +192 -0
  42. package/skills/teamsmith/scripts/panel/build.sh +47 -0
  43. package/skills/teamsmith/scripts/panel/bun.lock +109 -0
  44. package/skills/teamsmith/scripts/panel/draft-send.sh +68 -0
  45. package/skills/teamsmith/scripts/panel/package.json +24 -0
  46. package/skills/teamsmith/scripts/panel/panel.js +388 -0
  47. package/skills/teamsmith/scripts/panel/src/App.tsx +2150 -0
  48. package/skills/teamsmith/scripts/panel/src/clipboard.ts +154 -0
  49. package/skills/teamsmith/scripts/panel/src/compose.ts +691 -0
  50. package/skills/teamsmith/scripts/panel/src/data.ts +555 -0
  51. package/skills/teamsmith/scripts/panel/src/format.ts +50 -0
  52. package/skills/teamsmith/scripts/panel/src/layout.ts +2562 -0
  53. package/skills/teamsmith/scripts/panel/src/main.tsx +894 -0
  54. package/skills/teamsmith/scripts/panel/src/markdown.ts +340 -0
  55. package/skills/teamsmith/scripts/panel/src/sanitize.ts +42 -0
  56. package/skills/teamsmith/scripts/panel/src/settings.ts +154 -0
  57. package/skills/teamsmith/scripts/panel/src/strings/en.ts +416 -0
  58. package/skills/teamsmith/scripts/panel/src/strings/index.ts +65 -0
  59. package/skills/teamsmith/scripts/panel/src/strings/types.ts +9 -0
  60. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +414 -0
  61. package/skills/teamsmith/scripts/panel/src/theme.ts +116 -0
  62. package/skills/teamsmith/scripts/panel/src/types.ts +652 -0
  63. package/skills/teamsmith/scripts/panel/src/width.ts +105 -0
  64. package/skills/teamsmith/scripts/panel/tsconfig.json +16 -0
  65. package/skills/teamsmith/scripts/shim/signal-gate +156 -0
  66. package/skills/teamsmith/scripts/shim/tmux +403 -0
  67. package/skills/teamsmith/scripts/team +143 -0
  68. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +147 -0
  69. package/skills/teamsmith/templates/BOARD.md.tmpl +18 -0
  70. package/skills/teamsmith/templates/DECISIONS.md.tmpl +22 -0
  71. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +25 -0
  72. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +84 -0
  73. package/skills/teamsmith/templates/ROADMAP.md.tmpl +29 -0
  74. package/skills/teamsmith/templates/config.sh.tmpl +106 -0
  75. package/skills/teamsmith/templates/memory-seed.md.tmpl +46 -0
  76. package/skills/teamsmith/templates/pm-prompt.md.tmpl +110 -0
  77. package/skills/teamsmith/templates/report.md.tmpl +36 -0
  78. package/skills/teamsmith/templates/task.md.tmpl +65 -0
  79. package/skills/teamsmith/templates/threads-README.md +17 -0
  80. package/skills/teamsmith/tests/bg-ledger-harness.mjs +682 -0
  81. package/skills/teamsmith/tests/bg-ledger.sh +307 -0
  82. package/skills/teamsmith/tests/checkout-shape-probe.sh +800 -0
  83. package/skills/teamsmith/tests/config-cli.sh +1562 -0
  84. package/skills/teamsmith/tests/container-tmux.sh +493 -0
  85. package/skills/teamsmith/tests/coverage-inventory.sh +173 -0
  86. package/skills/teamsmith/tests/death-cause.sh +564 -0
  87. package/skills/teamsmith/tests/delivery-truth.sh +1231 -0
  88. package/skills/teamsmith/tests/fake-tui.py +450 -0
  89. package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +60 -0
  90. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +139 -0
  91. package/skills/teamsmith/tests/fixtures/delivery-truth-real/mock-server.py +29 -0
  92. package/skills/teamsmith/tests/fixtures/delivery-truth-real/observe.ts +20 -0
  93. package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +79 -0
  94. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +175 -0
  95. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +229 -0
  96. package/skills/teamsmith/tests/fixtures/p71-incident/README.md +22 -0
  97. package/skills/teamsmith/tests/fixtures/p71-incident/dev2.seen +8 -0
  98. package/skills/teamsmith/tests/fixtures/p71-incident/dev2.wake +9 -0
  99. package/skills/teamsmith/tests/fixtures/p71-incident/pm-nudges.wake +3 -0
  100. package/skills/teamsmith/tests/fixtures/signal-lint-cases.txt +40 -0
  101. package/skills/teamsmith/tests/flip-glue.sh +162 -0
  102. package/skills/teamsmith/tests/flip-m12-26c.sh +129 -0
  103. package/skills/teamsmith/tests/flip-m12.sh +185 -0
  104. package/skills/teamsmith/tests/flip-m16.sh +166 -0
  105. package/skills/teamsmith/tests/flip-m17.sh +204 -0
  106. package/skills/teamsmith/tests/flip-m33.sh +284 -0
  107. package/skills/teamsmith/tests/flip-m34.sh +96 -0
  108. package/skills/teamsmith/tests/flip-m37.sh +185 -0
  109. package/skills/teamsmith/tests/flip-m4.3.sh +375 -0
  110. package/skills/teamsmith/tests/flip-m43.sh +128 -0
  111. package/skills/teamsmith/tests/flip-m44.sh +262 -0
  112. package/skills/teamsmith/tests/flip-m45.sh +244 -0
  113. package/skills/teamsmith/tests/flip-m46.sh +238 -0
  114. package/skills/teamsmith/tests/flip-m48.sh +304 -0
  115. package/skills/teamsmith/tests/flip-m6.2.sh +205 -0
  116. package/skills/teamsmith/tests/flip-m6.3.sh +283 -0
  117. package/skills/teamsmith/tests/flip-m6.4.sh +267 -0
  118. package/skills/teamsmith/tests/flip-m6.5.sh +113 -0
  119. package/skills/teamsmith/tests/flip-m7.1.sh +135 -0
  120. package/skills/teamsmith/tests/flip-m7.2.sh +321 -0
  121. package/skills/teamsmith/tests/flip-p144.sh +112 -0
  122. package/skills/teamsmith/tests/flip-p156.sh +133 -0
  123. package/skills/teamsmith/tests/flip-p158.sh +301 -0
  124. package/skills/teamsmith/tests/flip-p160.sh +182 -0
  125. package/skills/teamsmith/tests/flip-p171.sh +249 -0
  126. package/skills/teamsmith/tests/flip-p18.1.sh +95 -0
  127. package/skills/teamsmith/tests/flip-p20.sh +286 -0
  128. package/skills/teamsmith/tests/flip-p201.sh +249 -0
  129. package/skills/teamsmith/tests/flip-p210.sh +239 -0
  130. package/skills/teamsmith/tests/flip-p211.sh +152 -0
  131. package/skills/teamsmith/tests/flip-p217.sh +288 -0
  132. package/skills/teamsmith/tests/flip-p22.sh +123 -0
  133. package/skills/teamsmith/tests/flip-p23.sh +239 -0
  134. package/skills/teamsmith/tests/flip-p25.sh +165 -0
  135. package/skills/teamsmith/tests/flip-p71.sh +184 -0
  136. package/skills/teamsmith/tests/flip-p72.sh +202 -0
  137. package/skills/teamsmith/tests/frames/README.md +176 -0
  138. package/skills/teamsmith/tests/frames/p78-conversation-rule-below-box.txt +6 -0
  139. package/skills/teamsmith/tests/frames/p78-cursor-mid-draft.txt +6 -0
  140. package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor-line.txt +6 -0
  141. package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor.txt +6 -0
  142. package/skills/teamsmith/tests/frames/p78-draft-rule-blank-region.txt +6 -0
  143. package/skills/teamsmith/tests/frames/p78-draft-rule-only.txt +5 -0
  144. package/skills/teamsmith/tests/frames/p78-spinner-row-below-cursor.txt +6 -0
  145. package/skills/teamsmith/tests/frames/p78-wider-rule-below-cursor.txt +6 -0
  146. package/skills/teamsmith/tests/frames/p86-f1-mixed-width-disjoint-box.txt +8 -0
  147. package/skills/teamsmith/tests/frames/p86-f1-narrower-width-disjoint-box.txt +8 -0
  148. package/skills/teamsmith/tests/frames/p86-f1-spinner-top-disjoint-box.txt +8 -0
  149. package/skills/teamsmith/tests/frames/pi-0.85.1-update-banner.txt +30 -0
  150. package/skills/teamsmith/tests/frames/pi-0.87.0-draft-half-sentence.txt +30 -0
  151. package/skills/teamsmith/tests/frames/pi-0.87.0-empty-box.txt +30 -0
  152. package/skills/teamsmith/tests/frames/pi-0.87.0-one-line-draft.txt +30 -0
  153. package/skills/teamsmith/tests/frames/pi-0.87.0-project-trust-prompt.txt +30 -0
  154. package/skills/teamsmith/tests/frames/pi-0.99.2-empty-editor.txt +32 -0
  155. package/skills/teamsmith/tests/frames/pi-0.99.2-human-draft.txt +32 -0
  156. package/skills/teamsmith/tests/frames/pi-1.0.0-git-error-in-box.txt +32 -0
  157. package/skills/teamsmith/tests/gate-guard.sh +112 -0
  158. package/skills/teamsmith/tests/guard-matrix.sh +233 -0
  159. package/skills/teamsmith/tests/install-shape.sh +731 -0
  160. package/skills/teamsmith/tests/ledger-ban.sh +612 -0
  161. package/skills/teamsmith/tests/lib/box-judge.sh +68 -0
  162. package/skills/teamsmith/tests/lib/checkout-shape.sh +129 -0
  163. package/skills/teamsmith/tests/lib/loop-scan.awk +114 -0
  164. package/skills/teamsmith/tests/lib/pty-wait.sh +676 -0
  165. package/skills/teamsmith/tests/lib/section-guard.sh +855 -0
  166. package/skills/teamsmith/tests/lib/shell-lex.pl +261 -0
  167. package/skills/teamsmith/tests/lib/tmp-root.sh +528 -0
  168. package/skills/teamsmith/tests/lib/tmux-cap.sh +35 -0
  169. package/skills/teamsmith/tests/lib/tmux-iso-call-probe.sh +81 -0
  170. package/skills/teamsmith/tests/lib/tmux-iso-probe.sh +46 -0
  171. package/skills/teamsmith/tests/lib/tmux-iso.sh +381 -0
  172. package/skills/teamsmith/tests/load-experiment.sh +290 -0
  173. package/skills/teamsmith/tests/loop-inventory.tsv +84 -0
  174. package/skills/teamsmith/tests/panel-b2-slow-stub.sh +19 -0
  175. package/skills/teamsmith/tests/panel-b2.sh +1183 -0
  176. package/skills/teamsmith/tests/panel-b3-pty-mouse.py +240 -0
  177. package/skills/teamsmith/tests/panel-b3-pty-tmux-mouse.py +138 -0
  178. package/skills/teamsmith/tests/panel-b3-stub.sh +279 -0
  179. package/skills/teamsmith/tests/panel-b3.sh +1301 -0
  180. package/skills/teamsmith/tests/panel-choices.sh +572 -0
  181. package/skills/teamsmith/tests/panel-clipboard-model.ts +187 -0
  182. package/skills/teamsmith/tests/panel-compose-model.ts +290 -0
  183. package/skills/teamsmith/tests/panel-contrast.mjs +81 -0
  184. package/skills/teamsmith/tests/panel-cpu-premise.sh +173 -0
  185. package/skills/teamsmith/tests/panel-cpu.sh +391 -0
  186. package/skills/teamsmith/tests/panel-flip-m54.sh +207 -0
  187. package/skills/teamsmith/tests/panel-flip-p123.sh +278 -0
  188. package/skills/teamsmith/tests/panel-flip-p125.sh +318 -0
  189. package/skills/teamsmith/tests/panel-flip-p128.sh +259 -0
  190. package/skills/teamsmith/tests/panel-keyprobe-pty.py +99 -0
  191. package/skills/teamsmith/tests/panel-keyprobe-stub.sh +41 -0
  192. package/skills/teamsmith/tests/panel-keyprobe.sh +82 -0
  193. package/skills/teamsmith/tests/panel-keyprobe.tsx +116 -0
  194. package/skills/teamsmith/tests/panel-knobs.sh +83 -0
  195. package/skills/teamsmith/tests/panel-p21.sh +2181 -0
  196. package/skills/teamsmith/tests/panel-snapshots.sh +802 -0
  197. package/skills/teamsmith/tests/panel-strings.mjs +195 -0
  198. package/skills/teamsmith/tests/perf.sh +740 -0
  199. package/skills/teamsmith/tests/pm-box-real.sh +350 -0
  200. package/skills/teamsmith/tests/pulse-nudge-key.sh +563 -0
  201. package/skills/teamsmith/tests/routes.sh +1652 -0
  202. package/skills/teamsmith/tests/section-budgets.tsv +150 -0
  203. package/skills/teamsmith/tests/section-guard.sh +231 -0
  204. package/skills/teamsmith/tests/section-needs-audit.sh +94 -0
  205. package/skills/teamsmith/tests/section-paths.tsv +142 -0
  206. package/skills/teamsmith/tests/section-select.sh +655 -0
  207. package/skills/teamsmith/tests/signal-gate.sh +366 -0
  208. package/skills/teamsmith/tests/signal-lint-legacy.txt +14 -0
  209. package/skills/teamsmith/tests/signal-lint.pl +416 -0
  210. package/skills/teamsmith/tests/skill-load.mjs +65 -0
  211. package/skills/teamsmith/tests/smoke.sh +19711 -0
  212. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +32 -0
  213. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +32 -0
  214. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +32 -0
  215. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +32 -0
  216. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +32 -0
  217. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +32 -0
  218. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +32 -0
  219. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +32 -0
  220. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +32 -0
  221. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +32 -0
  222. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +32 -0
  223. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +32 -0
  224. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +32 -0
  225. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +32 -0
  226. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +32 -0
  227. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +32 -0
  228. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +32 -0
  229. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +32 -0
  230. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +32 -0
  231. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +32 -0
  232. package/skills/teamsmith/tests/spec-ledger-refs.tsv +78 -0
  233. package/skills/teamsmith/tests/spec-refs.sh +826 -0
  234. package/skills/teamsmith/tests/task-header-model.sh +267 -0
  235. package/skills/teamsmith/tests/team-bg-flip.sh +239 -0
  236. package/skills/teamsmith/tests/team-bg-harness.mjs +392 -0
  237. package/skills/teamsmith/tests/team-bg-stop.sh +434 -0
  238. package/skills/teamsmith/tests/team-inbox-watch-flip.sh +191 -0
  239. package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +1559 -0
  240. package/skills/teamsmith/tests/tmp-hygiene.sh +1190 -0
  241. package/skills/teamsmith/tests/tmux-lint-legacy.txt +31 -0
  242. package/skills/teamsmith/tests/tmux-lint.pl +604 -0
  243. package/skills/teamsmith-init/SKILL.md +100 -0
  244. package/skills/teamsmith-init/references/bootstrap.md +74 -0
  245. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +46 -0
@@ -0,0 +1,267 @@
1
+ #!/usr/bin/env bash
2
+ # M6.4 · 独立验证包:V4.0 F4/F6/F19/F21/F23 的 red → green 复现
3
+ #
4
+ # bash skills/teamsmith/tests/flip-m6.4.sh # 红树 = 与保护分支的分叉点,绿树 = 本 worktree
5
+ # TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-m6.4.sh
6
+ #
7
+ # 为什么需要:M6.4 修的是「信号与承诺的诚实」——每一条都是「旧版真的会发错信号」。
8
+ # 这个包**不复用 smoke 的夹具**:自己建仓库/自带 upstream 的 worktree/会议目录,对同一份现场
9
+ # 分别跑「修复前」和「修复后」两棵 skill 树,断言旧版会红、新版会绿:
10
+ #
11
+ # F4 已 push(@{upstream}..HEAD=0)但领先 main 的分支:旧版 digest 喊「收尾:提交并 push」,新版不喊
12
+ # F6 id 带 '-' 的任务(API-2):旧版把 reports/API-2-dev.md 当 id=API → 「忽略的非任务报告」,新版待复验
13
+ # F19 会议 TTL:旧版 --ttl 0 接受、TTL_HOURS=abc 的历史会议永生,新版拒绝/按默认值判定过期
14
+ # F21 落后会话的 version --check:旧版退出码 141(SIGPIPE),新版 0
15
+ # F23 team reload:旧版承诺「watchdog 看到 marker 会重启 PM 会话」,新版删掉承诺、只说实的
16
+ #
17
+ # 只写 /tmp 下的临时目录,不碰调用者所在的任何仓库/session。
18
+ set -uo pipefail
19
+
20
+ SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
+ SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
22
+ # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
23
+ . "$SELF_DIR/lib/tmp-root.sh"
24
+ REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
25
+ [ -n "$REPO_ROOT" ] || { printf 'flip-m6.4: 找不到 git 仓库(需要 git archive 取修复前的树)\n' >&2; exit 2; }
26
+
27
+ BASE="${TEAM_FLIP_BASE:-}"
28
+ if [ -z "$BASE" ]; then
29
+ BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
30
+ fi
31
+ [ -n "$BASE" ] || { printf 'flip-m6.4: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
32
+
33
+ [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
34
+ TMP="$(tmp_root_create flip-m6.4)" || exit 3
35
+ cleanup() { tmp_root_reap_all; }
36
+ trap cleanup EXIT
37
+
38
+ # ---- 红树(修复前) / 绿树(修复后) -----------------------------------------
39
+ mkdir -p "$TMP/red"
40
+ git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red" || exit 2
41
+ RED_SKILL="$TMP/red/skills/teamsmith"
42
+ GREEN_SKILL="$SKILL_DIR"
43
+ # 守卫:传进来的 base 必须真的还是「修复前」,否则这个包会报出一个假的「翻转」
44
+ for probe in 'team_git_upstream_ahead:scripts/lib/cmd-status.sh' \
45
+ 'team_report_task_id:scripts/lib/common.sh' \
46
+ 'team_meeting_ttl_hours:scripts/lib/cmd-meeting.sh' \
47
+ '没有任何组件会因为 marker 重启会话:scripts/lib/cmd-update.sh'; do
48
+ f="${probe#*:}"; needle="${probe%%:*}"
49
+ if grep -qF "$needle" "$RED_SKILL/$f" 2>/dev/null; then
50
+ printf 'flip-m6.4: $BASE 已经包含 M6.4 的修复(%s 里已有 %s)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' "$f" "$needle" >&2
51
+ exit 2
52
+ fi
53
+ done
54
+
55
+ # ---- 夹具仓库(同一个现场,两棵树各跑一遍) ----------------------------------
56
+ REPO="$TMP/repo"; mkdir -p "$REPO"
57
+ export TEAM_MEETINGS_DIR="$TMP/meetings"
58
+ (
59
+ cd "$REPO" || exit 1
60
+ git init -q -b main .
61
+ git config user.email flip@teamsmith
62
+ git config user.name flip
63
+ echo "# flip fixture" > README.md
64
+ git add -A && git commit -qm "chore: init"
65
+ bash "$GREEN_SKILL/scripts/team" init --session flip-m64 --agents dev --vcs local --gates true --docs docs/team >/dev/null 2>&1
66
+ mkdir -p docs/team/reports
67
+ ) || { printf 'flip-m6.4: 夹具仓库初始化失败\n' >&2; exit 2; }
68
+
69
+ FAIL=0
70
+ ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
71
+ bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL+1)); }
72
+
73
+ team() { # <skill-dir> <log> <args...>(不覆盖名册)
74
+ local sk="$1" log="$2"; shift 2
75
+ ( cd "$REPO" && bash "$sk/scripts/team" "$@" ) >"$log" 2>&1
76
+ TEAM_RC=$?
77
+ }
78
+ team_agents() { # <名册> <skill-dir> <log> <args...>(临时覆盖名册:环境变量优先于 config)
79
+ local agents="$1" sk="$2" log="$3"; shift 3
80
+ ( cd "$REPO" && TEAM_AGENTS="$agents" bash "$sk/scripts/team" "$@" ) >"$log" 2>&1
81
+ TEAM_RC=$?
82
+ }
83
+ tailof() { grep -F -- "$2" "$1" | head -3; }
84
+
85
+ printf '修复前 revision: %s(%s)\n修复后 skill: %s\n夹具仓库: %s\n' \
86
+ "$BASE" "$(git -C "$REPO_ROOT" log -1 --format=%s "$BASE")" "$GREEN_SKILL" "$REPO"
87
+
88
+ # ---------------------------------------------------------------- F4
89
+ printf '\n=== F4 · push 状态必须相对 @{upstream} ===\n'
90
+ F4WT="$REPO/.worktrees/f4"
91
+ git -C "$REPO" init -q --bare "$TMP/origin.git"
92
+ git -C "$REPO" worktree add -q -b task/F4 "$F4WT" main >/dev/null 2>&1 || true
93
+ printf 'one\n' > "$F4WT/f4.txt"
94
+ git -C "$F4WT" add -A >/dev/null 2>&1 && git -C "$F4WT" commit -qm "feat: demo" >/dev/null 2>&1
95
+ git -C "$REPO" remote add origin "$TMP/origin.git" >/dev/null 2>&1 || true
96
+ git -C "$F4WT" push -q -u origin task/F4 >/dev/null 2>&1
97
+ printf '现场:@{upstream}..HEAD=%s(真的没东西可 push) main..HEAD=%s(旧版拿这个当下面的「未 push」)\n' \
98
+ "$(git -C "$F4WT" rev-list --count '@{upstream}..HEAD')" "$(git -C "$F4WT" rev-list --count main..HEAD)"
99
+
100
+ team_agents f4 "$RED_SKILL" "$TMP/f4-red.log" digest
101
+ team_agents f4 "$GREEN_SKILL" "$TMP/f4-green.log" digest
102
+ printf '[红] digest §[4] 相关行:\n'; tailof "$TMP/f4-red.log" "收尾:提交并 push" | sed 's/^/ /'
103
+ printf '[绿] digest §[4] 相关行:\n'; tailof "$TMP/f4-green.log" "未 push" | sed 's/^/ /'
104
+ if grep -qF '收尾:提交并 push' "$TMP/f4-red.log"; then
105
+ ok "修复前:已 push 的分支被喊「收尾:提交并 push」(这就是 F4 的假信号)"
106
+ else bad "修复前:夹具没造出假信号(旧版竟然没喊 push)"; fi
107
+ if grep -qF '收尾:提交并 push' "$TMP/f4-green.log"; then
108
+ bad "修复后:已 push 的分支仍然被喊 push"
109
+ else ok "修复后:@{upstream}..HEAD=0 → 不再被当成未收尾"; fi
110
+ if grep -qF '领先 1' "$TMP/f4-red.log" && ! grep -qF '领先 1' "$TMP/f4-green.log"; then
111
+ ok "修复后:相对 main 的领先数不再冒充「未 push」(绿树 §[4] 里没有它)"
112
+ else bad "修复后:关于「领先 main」的表达没有变(红有/绿无 这个差分不成立)"; fi
113
+
114
+ # ---------------------------------------------------------------- F6
115
+ printf '\n=== F6 · id 带 "-" 的任务报告(API-2) ===\n'
116
+ team "$GREEN_SKILL" "$TMP/f6-task.log" task API-2 --title "api-2 endpoint" --agent dev
117
+ printf '%s\n' '# API-2 · api-2 endpoint' '' 'agent: dev status: DONE' > "$REPO/docs/team/reports/API-2-dev.md"
118
+ team "$RED_SKILL" "$TMP/f6-red.log" digest
119
+ team "$GREEN_SKILL" "$TMP/f6-green.log" digest
120
+ printf '[红] 忽略清单/待复验:\n'; { tailof "$TMP/f6-red.log" "忽略的非任务报告" | sed 's/^/ /'; tailof "$TMP/f6-red.log" "review API" | sed 's/^/ /'; }
121
+ printf '[绿] 忽略清单/待复验:\n'; { tailof "$TMP/f6-green.log" "忽略的非任务报告" | sed 's/^/ /'; tailof "$TMP/f6-green.log" "review API" | sed 's/^/ /'; }
122
+ if grep -qF '忽略的非任务报告:API-2-dev.md' "$TMP/f6-red.log" && ! grep -qF 'review API-2' "$TMP/f6-red.log"; then
123
+ ok "修复前:正式任务 API-2 的报告落进「忽略的非任务报告」,也不在待复验里(F6)"
124
+ else bad "修复前:夹具没造出误判(旧版没有把 API-2-dev.md 忽略)"; fi
125
+ if grep -qF 'review API-2' "$TMP/f6-green.log" && ! grep -qF '忽略的非任务报告:API-2-dev.md' "$TMP/f6-green.log"; then
126
+ ok "修复后:API-2 的报告进入待复验,且带完整 id"
127
+ else bad "修复后:API-2 的报告仍然被判成非任务报告"; fi
128
+
129
+ # ---------------------------------------------------------------- F19
130
+ printf '\n=== F19 · 会议 TTL 不能是垃圾值/永生 ===\n'
131
+ team "$RED_SKILL" "$TMP/f19-red.log" meeting open ttl-zero --with other --topic "ttl 0" --ttl 0 --yes
132
+ RED_TTL_RC="$TEAM_RC"
133
+ team "$GREEN_SKILL" "$TMP/f19-green.log" meeting open ttl-zero --with other --topic "ttl 0" --ttl 0 --yes
134
+ GREEN_TTL_RC="$TEAM_RC"
135
+ printf '[红] rc=%s 登记值:%s\n' "$RED_TTL_RC" "$(grep -s '^TTL_HOURS=' "$TMP/meetings/ttl-zero/state.env" 2>/dev/null || echo '(没有 state.env)')"
136
+ printf '[绿] rc=%s %s\n' "$GREEN_TTL_RC" "$(grep -sF '正整数小时' "$TMP/f19-green.log" | head -1)"
137
+ if [ "$RED_TTL_RC" = "0" ]; then ok "修复前:--ttl 0 被接受(会议成了永生)"
138
+ else bad "修复前:夹具没造出「永生」格(--ttl 0 竟然被拒)"; fi
139
+ if [ "$GREEN_TTL_RC" != "0" ]; then ok "修复后:--ttl 0 非 0 退出(被拒绝)"
140
+ else bad "修复后:--ttl 0 仍然被接受"; fi
141
+
142
+ # 历史遗留的非法登记值:旧版永生,新版按默认值判定过期
143
+ team "$GREEN_SKILL" "$TMP/f19-legacy-open.log" meeting open ttl-legacy --with other --topic "legacy" --yes
144
+ sed -i 's/^TTL_HOURS=.*/TTL_HOURS=abc/' "$TMP/meetings/ttl-legacy/state.env"
145
+ sed -i 's/^OPENED_EPOCH=.*/OPENED_EPOCH=1000/' "$TMP/meetings/ttl-legacy/state.env"
146
+ team "$RED_SKILL" "$TMP/f19-legacy-red.log" meeting read ttl-legacy --peek
147
+ team "$GREEN_SKILL" "$TMP/f19-legacy-green.log" meeting read ttl-legacy --peek
148
+ team "$RED_SKILL" "$TMP/f19-say-red.log" meeting say ttl-legacy --intent info "54 年后还能说吗"
149
+ RED_SAY_RC="$TEAM_RC"
150
+ team "$GREEN_SKILL" "$TMP/f19-say-green.log" meeting say ttl-legacy --intent info "54 年后还能说吗"
151
+ GREEN_SAY_RC="$TEAM_RC"
152
+ printf '[红] read:%s | say rc=%s\n' "$(grep -sF 'TTL' "$TMP/f19-legacy-red.log" | head -1 | sed 's/^[[:space:]]*//')" "$RED_SAY_RC"
153
+ printf '[绿] read:%s | say rc=%s\n' "$(grep -sF 'TTL' "$TMP/f19-legacy-green.log" | head -1 | sed 's/^[[:space:]]*//')" "$GREEN_SAY_RC"
154
+ if [ "$RED_SAY_RC" = "0" ]; then ok "修复前:TTL_HOURS=abc 的老会议 54 年后仍然能发言(F19 的永生)"
155
+ else bad "修复前:夹具没造出永生(旧版竟然拒绝了 say)"; fi
156
+ if [ "$GREEN_SAY_RC" != "0" ]; then ok "修复后:非法 TTL 按默认值判过期(say 被拒)"
157
+ else bad "修复后:非法 TTL 的老会议仍然能发言"; fi
158
+ if grep -qF 'TTL abch' "$TMP/f19-legacy-red.log"; then ok "修复前:read 把登记值原样印成 \"TTL abch\""
159
+ else bad "修复前:read 没有印出 \"TTL abch\"(夹具或文案变了)"; fi
160
+ if grep -qF 'TTL 72h' "$TMP/f19-legacy-green.log"; then ok "修复后:read 印有效 TTL(TTL 72h)"
161
+ else bad "修复后:read 没有印有效 TTL"; fi
162
+
163
+ # ---------------------------------------------------------------- F21
164
+ printf '\n=== F21 · 落后会话的 version --check 退出码 ===\n'
165
+ team "$RED_SKILL" "$TMP/f21-mark-red.log" mark-loaded --version 0.0.1
166
+ team "$RED_SKILL" "$TMP/f21-red.log" version --check
167
+ RED_V_RC="$TEAM_RC"
168
+ team "$GREEN_SKILL" "$TMP/f21-mark-green.log" mark-loaded --version 0.0.1
169
+ team "$GREEN_SKILL" "$TMP/f21-green.log" version --check
170
+ GREEN_V_RC="$TEAM_RC"
171
+ printf '[红] rc=%s %s\n' "$RED_V_RC" "$(grep -sF '本会话是旧的' "$TMP/f21-red.log" | head -1 | sed 's/^[[:space:]]*//')"
172
+ printf '[绿] rc=%s %s\n' "$GREEN_V_RC" "$(grep -sF '本会话是旧的' "$TMP/f21-green.log" | head -1 | sed 's/^[[:space:]]*//')"
173
+ if [ "$RED_V_RC" = "141" ]; then ok "修复前:退出码 141(SIGPIPE,head 提前退出 + pipefail)"
174
+ else bad "修复前:退出码是 $RED_V_RC(没复现 141)"; fi
175
+ if grep -qF '本会话是旧的' "$TMP/f21-red.log"; then ok "修复前:文案本身是对的(所以调用方会把 141 当崩溃)"
176
+ else bad "修复前:连「本会话是旧的」都没打印(夹具不对)"; fi
177
+ if [ "$GREEN_V_RC" = "0" ]; then ok "修复后:退出码 0(stale 不再是崩溃)"
178
+ else bad "修复后:退出码是 $GREEN_V_RC"; fi
179
+ if grep -qF '本会话是旧的' "$TMP/f21-green.log" && grep -qF '最新变更' "$TMP/f21-green.log"; then
180
+ ok "修复后:既报「旧的」也仍然打印 CHANGELOG 摘要"
181
+ else bad "修复后:CHANGELOG 摘要被吃掉了"; fi
182
+ team "$GREEN_SKILL" "$TMP/f21-restore.log" mark-loaded >/dev/null 2>&1
183
+
184
+ # ---------------------------------------------------------------- F23
185
+ printf '\n=== F23 · team reload 的承诺 ===\n'
186
+ team "$RED_SKILL" "$TMP/f23-red.log" reload
187
+ team "$GREEN_SKILL" "$TMP/f23-green.log" reload
188
+ printf '[红] %s\n' "$(grep -sF 'watchdog' "$TMP/f23-red.log" | head -1 | sed 's/^[[:space:]]*//')"
189
+ printf '[绿] %s\n' "$(grep -sF 'marker' "$TMP/f23-green.log" | head -1 | sed 's/^[[:space:]]*//')"
190
+ if grep -qF 'watchdog' "$TMP/f23-red.log" && grep -qF '重启 PM 会话' "$TMP/f23-red.log"; then
191
+ ok "修复前:promises the watchdog will restart the PM session when it sees the marker"
192
+ else bad "修复前:没有那句假承诺(文案变了?)"; fi
193
+ if ! grep -qF '重启 PM 会话' "$TMP/f23-green.log" && grep -qF '没有任何组件会因为 marker 重启会话' "$TMP/f23-green.log"; then
194
+ ok "修复后:删掉承诺,只说 marker 的真实作用(含「没有任何组件重启会话」)"
195
+ else bad "修复后:承诺还在或没有说清实际行为"; fi
196
+ GREEN_READERS="$(grep -rl 'reload-requested' "$GREEN_SKILL/scripts" 2>/dev/null | grep -v 'cmd-update.sh' || true)"
197
+ if [ -z "$GREEN_READERS" ]; then ok "修复后:scripts/ 里除 cmd-update.sh 外确实没有组件读 marker"
198
+ else bad "还有组件读 marker:$GREEN_READERS"; fi
199
+ if grep -qF 'rmSync(marker, { force: true })' "$GREEN_SKILL/extension/team-notify.ts" 2>/dev/null; then
200
+ ok "修复后:扩展侧只在 /reload 后清掉 marker(与文案一致)"
201
+ else bad "扩展侧不再清理 marker(文案就又不准了)"; fi
202
+ team "$GREEN_SKILL" "$TMP/f23-done.log" reload --done >/dev/null 2>&1
203
+
204
+ # ---------------------------------------------------------------- 变异自检:把实现改坏 → 守卫必须红
205
+ # 上面的红树是「整个修复前版本」;这里再单独把每一处修复改坏(其余都是修好的代码),
206
+ # 确认守卫断言真的是针对这几行实现,而不是靠整个版本差异。
207
+ printf '\n=== 变异自检(破坏实现 → 守卫断言必须变红) ===\n'
208
+ MUT="$TMP/mutant"
209
+ rm -rf "$MUT"; cp -r "$GREEN_SKILL" "$MUT"
210
+ mutate() { # <文件> <原文字面量> <替换>(整行子串替换,避免 sed 的转义地狱)
211
+ local f="$1" old="$2" new="$3"
212
+ awk -v old="$old" -v new="$new" '{ p=index($0, old); if (p>0) { $0 = substr($0,1,p-1) new substr($0,p+length(old)) }; print }' "$f" > "$f.mut" && mv "$f.mut" "$f"
213
+ }
214
+ mutate "$MUT/scripts/lib/cmd-status.sh" '"$(team_git_upstream_ahead "$wt")"' '"$ahead"'
215
+ mutate "$MUT/scripts/lib/common.sh" 'id="$(team_report_task_id "$glob")"' 'id="${base%%-*}"'
216
+ mutate "$MUT/scripts/lib/cmd-status.sh" 'id="$(team_report_task_id "$glob")"' 'id="${base%%-*}"'
217
+ mutate "$MUT/scripts/lib/cmd-meeting.sh" '[ "$ttl" -gt 0 ] 2>/dev/null || team_usage_die' '[ "$ttl" -gt 0 ] 2>/dev/null || team_warn'
218
+ f21_old="$(grep -F 'BEGIN{n=0} /^## /' "$MUT/scripts/lib/cmd-update.sh" | head -1)"
219
+ [ -n "$f21_old" ] && mutate "$MUT/scripts/lib/cmd-update.sh" "$f21_old" ' sed -n '\''/^## /,$p'\'' "$(team_skill_changelog)" | head -14 | sed '\''s/^/ /'\'''
220
+ mutate "$MUT/scripts/lib/cmd-update.sh" 'marker(.pi/team/state/reload-requested)仅用于记账' '若你有 watchdog:它看到 marker 后会重启 PM 会话(pi -c 保留历史。marker 记账'
221
+ MUTATIONS="$(diff -rq "$GREEN_SKILL/scripts" "$MUT/scripts" 2>/dev/null | wc -l | tr -d ' ')"
222
+ printf '已注入变异:%s 个文件不同(期望 4:cmd-status/cmd-meeting/cmd-update/common)\n' "$MUTATIONS"
223
+
224
+ # 边界:变异树必须只作用在夹具仓库上(第一次写这个包时就踩过:CLI 用调用者的 cwd,
225
+ # 结果把真实项目当成了受测对象)。每条命令都在夹具仓库里跑,并且先证明 paths 认的是夹具。
226
+ mut() { # <log> <env 名册或 -> <args...>:在夹具仓库里跑变异树
227
+ local log="$1" agents="$2"; shift 2
228
+ ( cd "$REPO" && [ "$agents" = "-" ] && bash "$MUT/scripts/team" "$@" || TEAM_AGENTS="$agents" bash "$MUT/scripts/team" "$@" ) >"$log" 2>&1
229
+ MUT_RC=$?
230
+ }
231
+ MUT_ROOT="$( cd "$REPO" && bash "$MUT/scripts/team" paths 2>/dev/null | sed -n 's/.*"main_root": "\([^"]*\)".*/\1/p' )"
232
+ if [ "$MUT_ROOT" = "$REPO" ]; then ok "变异自检在夹具仓库里跑(main_root=$REPO)"
233
+ else bad "变异自检没有认到夹具仓库(main_root=$MUT_ROOT)——拒绝继续"; printf '\n'; exit 2; fi
234
+
235
+ # 守卫 1(F4):改了 push 状态的口径 → digest 必须重新喊 push
236
+ mut "$TMP/mut-f4.log" f4 digest
237
+ if grep -qF '收尾:提交并 push' "$TMP/mut-f4.log"; then ok "变异 F4:把 upstream 量法改回保护分支 → 守卫(不许喊 push)变红"
238
+ else bad "变异 F4:改回旧口径后 digest 竟然仍然不喊 push(守卫没在防这条实现)"; fi
239
+ # 守卫 2(F6):两个调用点(common/report 扫描 + cmd-status 待复验覆盖)都得改回「第一个 '-'」
240
+ mut "$TMP/mut-f6.log" - digest
241
+ if grep -qF '忽略的非任务报告:API-2-dev.md' "$TMP/mut-f6.log" && ! grep -qF 'review API-2' "$TMP/mut-f6.log"; then
242
+ ok "变异 F6:改回首个 '-' 切 id → 守卫(API-2 必须在待复验)变红"
243
+ else bad "变异 F6:改回旧解析后 API-2 仍然在待复验(守卫没在防这条实现)"; fi
244
+ # 守卫 3(F19):去掉「必须正数」这一半 → --ttl 0 必须又能被接受
245
+ mut "$TMP/mut-f19.log" - meeting open mut-ttl --with other --topic "mutant" --ttl 0 --yes
246
+ if [ "$MUT_RC" = "0" ]; then ok "变异 F19:去掉正数校验 → 守卫(--ttl 0 必须被拒)变红"
247
+ else bad "变异 F19:去掉校验后 --ttl 0 仍然被拒(守卫没在防这条实现)"; fi
248
+ # 守卫 4(F21):改回 sed|head 管道 → 退出码必须又变 141
249
+ mut "$TMP/mut-f21-mark.log" - mark-loaded --version 0.0.1
250
+ mut "$TMP/mut-f21.log" - version --check
251
+ if [ "$MUT_RC" = "141" ]; then ok "变异 F21:改回 sed|head 管道 → 守卫(退出码必须 0)变红"
252
+ else bad "变异 F21:改回管道后退出码是 $MUT_RC(守卫没在防这条实现)"; fi
253
+ ( cd "$REPO" && bash "$GREEN_SKILL/scripts/team" mark-loaded ) >/dev/null 2>&1
254
+ # 守卫 5(F23):把假承诺放回去 → 守卫(不许出现「重启 PM 会话」)必须变红
255
+ mut "$TMP/mut-f23.log" - reload
256
+ if grep -qF '重启 PM 会话' "$TMP/mut-f23.log"; then ok "变异 F23:把假承诺放回文案 → 守卫(不许承诺重启)变红"
257
+ else bad "变异 F23:放回假承诺后守卫没抓到(守卫没在防这条文案)"; fi
258
+ mut "$TMP/mut-f23-done.log" - reload --done
259
+
260
+ # ---------------------------------------------------------------- 汇总
261
+ printf '\n'
262
+ if [ "$FAIL" -eq 0 ]; then
263
+ printf '\033[32mflip-m6.4:五个 finding 的翻转全部复现(红 → 绿)\033[0m\n'
264
+ exit 0
265
+ fi
266
+ printf '\033[31mflip-m6.4:有 %d 条翻转断言失败(见上)\033[0m\n' "$FAIL"
267
+ exit 1
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env bash
2
+ # M6.5 · 独立验证包:假 PM 存活(`team up` 谎报)的 red → green 复现
3
+ #
4
+ # bash skills/teamsmith/tests/flip-m6.5.sh # 红树 = HEAD 的父提交(TEAM_FLIP_BASE 可覆盖),绿树 = 本 worktree
5
+ # TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-m6.5.sh
6
+ #
7
+ # 为什么需要:M6.5 的失效格是「cwd 在项目内 + 前台不是 shell」——空 session 刚建好时那个进程名在本环境是
8
+ # `tmux`,于是老规则判 `running:tmux`,`team up` 打印「PM 在运行」却不启动任何东西。这里把这一格**确定性地**
9
+ # 造出来(窗口里跑 `tmux wait-for`,cwd 用夹具仓库),对「修复前 / 修复后」两份 skill 跑同一条命令:
10
+ #
11
+ # 红:up **不**启动假 agent,且 argv 日志为空(旧输出含「PM 在运行(tmux)」)
12
+ # 绿:up 真的启动假 agent,argv 日志里出现 `-c` 与 `@pm-prompt.md`
13
+ #
14
+ # 只写 /tmp 下的临时目录,只动自己起的 tmux session(结束时清理);不碰调用者所在的任何仓库/session。
15
+ set -uo pipefail
16
+
17
+ SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18
+ SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
19
+ # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
20
+ . "$SELF_DIR/lib/tmp-root.sh"
21
+ # P162:破坏性调用(kill-server/kill-session/kill-window)动手前先证明私有 socket 生效
22
+ . "$SELF_DIR/lib/tmux-iso.sh"
23
+ REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
24
+ [ -n "$REPO_ROOT" ] || { printf 'flip-m6.5: 找不到 git 仓库(本脚本需要 git archive 取修复前的树)\n' >&2; exit 2; }
25
+ command -v tmux >/dev/null 2>&1 || { printf 'flip-m6.5: 需要 tmux(本复现是 tmux 现场的)\n' >&2; exit 2; }
26
+
27
+ BASE="${TEAM_FLIP_BASE:-}"
28
+ if [ -z "$BASE" ]; then
29
+ # 默认:与保护分支的分叉点(M6.5 的修复提交都在它之后)
30
+ BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
31
+ fi
32
+ [ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" rev-parse --verify -q HEAD^ 2>/dev/null || true)"
33
+ [ -n "$BASE" ] || { printf 'flip-m6.5: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
34
+
35
+ [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
36
+ TMP="$(tmp_root_create flip-m6.5)" || exit 3
37
+ SESS="teamsmith-flip-m65-$$"
38
+
39
+ # M28:夹具自己的 tmux 调用要有隔离证据(裸 tmux 按 $TMUX 打到调用者 server —— M23 事故形状)。
40
+ # unset TMUX + 私有 TMUX_TMPDIR;工具在私有 server 的窗口里跑,继承同一套环境。口径见 tests/tmux-lint.pl。
41
+ unset TMUX TMUX_PANE 2>/dev/null || true
42
+ TMUX_TMPDIR="$TMP/tmux"; mkdir -p "$TMUX_TMPDIR"; export TMUX_TMPDIR
43
+ cleanup() { # P162:收尾先证明私有 socket 生效(不成立就拒绝;cleanup 里不许 exit)
44
+ tmux_iso_guard_soft "flip-m6.5" "收尾:私有 session" --tmpdir "${TMUX_TMPDIR:-}" --own-root "$TMP" \
45
+ && tmux kill-session -t "$SESS" 2>/dev/null || true
46
+ tmp_root_reap_all
47
+ }
48
+ trap cleanup EXIT
49
+
50
+ # ---- 夹具:临时仓库 + teamsmith init + 记录 argv 的假 agent --------------------
51
+ mkdir -p "$TMP/red-skill" "$TMP/fake-bin" "$TMP/repo"
52
+ git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red-skill" || exit 2
53
+ RED_SKILL="$TMP/red-skill/skills/teamsmith"
54
+ # 守卫:传进来的 base 必须真的还是「修复前」(否则这个包会报一个假的「翻转」)
55
+ if grep -q 'team_pm_pid_live' "$RED_SKILL/scripts/lib/common.sh" 2>/dev/null; then
56
+ printf 'flip-m6.5: $BASE 已经包含 M6.5 的修复(不是修复前的树)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' >&2
57
+ exit 2
58
+ fi
59
+ cat > "$TMP/fake-bin/pi-log" <<EOF
60
+ #!/usr/bin/env bash
61
+ printf '%s\n' "\$@" >> "$TMP/pm-args.log"
62
+ sleep 600
63
+ EOF
64
+ chmod +x "$TMP/fake-bin/pi-log"
65
+
66
+ cd "$TMP/repo" || exit 2
67
+ git init -q .; git config user.email t@t; git config user.name t
68
+ echo hi > README.md; git add -A; git commit -qm init >/dev/null; git branch -m main
69
+ bash "$SKILL_DIR/scripts/team" init --yes >/dev/null 2>&1
70
+ sed -i "s|^TEAM_PI_BIN=.*|TEAM_PI_BIN=\"$TMP/fake-bin/pi-log\"|" .pi/team/config.sh
71
+
72
+ # ---- 造「cwd 在项目内 + 前台不是 shell(tmux)」这一格,然后跑某一版 skill 的 up ----
73
+ false_liveness_scene() {
74
+ # P162:重建现场前先证明私有 socket 生效(不成立 → 硬停)
75
+ tmux_iso_require "flip-m6.5" "重建现场:收掉旧 session" --tmpdir "${TMUX_TMPDIR:-}" --own-root "$TMP"
76
+ tmux kill-session -t "$SESS" 2>/dev/null || true
77
+ tmux new-session -d -s "$SESS" -n pm -c "$TMP/repo" 2>/dev/null || true
78
+ tmux respawn-pane -k -t "$SESS:pm" "cd $TMP/repo && exec tmux wait-for flip-m65-never" >/dev/null 2>&1 || true
79
+ sleep 1
80
+ }
81
+ run_up() { # <skill-dir> <tag>
82
+ false_liveness_scene
83
+ rm -f "$TMP/pm-args.log"
84
+ TEAM_SESSION="$SESS" TEAM_ROOT="$TMP/repo" TEAM_PI_BIN="$TMP/fake-bin/pi-log" \
85
+ bash "$1/scripts/team" up > "$TMP/up-$2.log" 2>&1
86
+ printf '\n=== [%s] 现场:%s ===\n' "$2" "$(tmux display-message -p -t "$SESS:pm" 'pane_pid=#{pane_pid} cmd=#{pane_current_command}' 2>/dev/null || echo '?')"
87
+ printf '=== [%s] team up 输出 ===\n' "$2"; cat "$TMP/up-$2.log"
88
+ printf '=== [%s] 假 agent argv 日志 ===\n' "$2"
89
+ if [ -s "$TMP/pm-args.log" ]; then cat "$TMP/pm-args.log"; else printf '(空:没有任何 agent 被启动)\n'; fi
90
+ }
91
+
92
+ printf '修复前 revision: %s(%s)\n修复后 skill: %s\n' "$BASE" "$(git -C "$REPO_ROOT" log -1 --format=%s "$BASE")" "$SKILL_DIR"
93
+ run_up "$RED_SKILL" red
94
+ RED_UP="$TMP/up-red.log"; RED_ARGS="$TMP/pm-args.log"; cp -f "$RED_ARGS" "$TMP/red-args.snapshot" 2>/dev/null || :
95
+ run_up "$SKILL_DIR" green
96
+
97
+ # ---- 断言 ----------------------------------------------------------------
98
+ FAIL=0
99
+ ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
100
+ bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL+1)); }
101
+ printf '\n== 翻转断言 ==\n'
102
+ if grep -qF 'PM 已启动' "$RED_UP"; then bad "修复前:up 竟然启动了 PM(夹具没造出假存活格)"
103
+ else ok "修复前:up 没有启动 PM(旧输出:$(grep -F 'PM 在运行' "$RED_UP" | head -1 | sed 's/^[[:space:]]*//' || echo '—'))"; fi
104
+ if [ -s "$TMP/red-args.snapshot" ]; then bad "修复前:假 agent 被启动了(argv 日志非空)"; else ok "修复前:假 agent 从未被调用(argv 日志为空)"; fi
105
+ if grep -qF 'PM 已启动' "$TMP/up-green.log"; then ok "修复后:up 真的启动了 PM"; else bad "修复后:up 没有启动 PM"; fi
106
+ if [ -s "$RED_ARGS" ] && grep -qF -- '-c' "$RED_ARGS" && grep -qF 'pm-prompt.md' "$RED_ARGS"; then
107
+ ok "修复后:假 agent argv 里有 -c 与 @pm-prompt.md"
108
+ else bad "修复后:argv 日志缺 -c / pm-prompt.md"; fi
109
+
110
+ printf '\n'
111
+ [ "$FAIL" -eq 0 ] && { printf '\033[32mflip-m6.5:翻转已复现(红 → 绿)\033[0m\n'; exit 0; }
112
+ printf '\033[31mflip-m6.5:没有观察到预期的翻转(%d 条失败)\033[0m\n' "$FAIL"
113
+ exit 1
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env bash
2
+ # M7.1 · 独立验证包:一个用旧版本/旧名建起来的项目「没有任何入口知道要改什么」→ doctor 一行指引(red → green)
3
+ #
4
+ # bash skills/teamsmith/tests/flip-m7.1.sh # 红树 = 与保护分支的分叉点(TEAM_FLIP_BASE 可覆盖),绿树 = 本 worktree
5
+ # TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-m7.1.sh
6
+ #
7
+ # 为什么需要:M7.1 之前 references/migration.md 不存在,doctor 也不会指向任何迁移说明 —— 迁移知识散在
8
+ # CHANGELOG/DECISIONS/复验记录里,工具里没有入口。这里用两棵 skill 树(修复前 / 修复后)跑**同一套夹具**:
9
+ #
10
+ # 红:migration.md 文件不存在;doctor 输出里没有任何迁移指引(旧项目只能靠人记得)
11
+ # 绿:doctor 打出**一行**指引,指向**这棵绿树**里的 migration.md;按配方跑一次 init 之后指引消失
12
+ #
13
+ # 只写 /tmp 下的临时目录;不建 tmux、不起 agent 进程(纯逻辑,几秒跑完)。不碰调用者的任何仓库/session。
14
+ set -uo pipefail
15
+
16
+ SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+ SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
18
+ # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
19
+ . "$SELF_DIR/lib/tmp-root.sh"
20
+ REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
21
+ [ -n "$REPO_ROOT" ] || { printf 'flip-m7.1: 找不到 git 仓库(本脚本需要 git archive 取修复前的树)\n' >&2; exit 2; }
22
+
23
+ BASE="${TEAM_FLIP_BASE:-}"
24
+ [ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
25
+ [ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" rev-parse --verify -q HEAD^ 2>/dev/null || true)"
26
+ [ -n "$BASE" ] || { printf 'flip-m7.1: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
27
+
28
+ [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
29
+ TMP="$(tmp_root_create flip-m7.1)" || exit 3
30
+ cleanup() { tmp_root_reap_all; }
31
+ trap cleanup EXIT
32
+
33
+ # ---- 夹具材料:假依赖(v1.19.0 起 doctor 缺 magic-context/OpenSpec 会失败,与本次翻转无关) ----
34
+ mkdir -p "$TMP/red-skill" "$TMP/deps/npm/node_modules/@cortexkit/pi-magic-context" "$TMP/deps/spec" "$TMP/fake-bin"
35
+ git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red-skill" || exit 2
36
+ RED_SKILL="$TMP/red-skill/skills/teamsmith"
37
+ printf '{"packages":["npm:@cortexkit/pi-magic-context"]}\n' > "$TMP/deps/settings.json"
38
+ printf '{"name":"@cortexkit/pi-magic-context","version":"9.9.9"}\n' \
39
+ > "$TMP/deps/npm/node_modules/@cortexkit/pi-magic-context/package.json"
40
+ cat > "$TMP/fake-bin/openspec" <<'EOF'
41
+ #!/usr/bin/env bash
42
+ [ "${1:-}" = "--version" ] && printf 'openspec 9.9.9 (flip-fake)\n'
43
+ exit 0
44
+ EOF
45
+ cat > "$TMP/fake-bin/pi" <<'EOF'
46
+ #!/usr/bin/env bash
47
+ case "${1:-}" in
48
+ --version|-v) printf 'pi 0.0.0 (flip-fake)\n' ;;
49
+ --help|-h) printf 'usage: pi [--session-id <id>]\n' ;;
50
+ esac
51
+ exit 0
52
+ EOF
53
+ chmod +x "$TMP/fake-bin/openspec" "$TMP/fake-bin/pi"
54
+
55
+ # ---- 守卫:传进来的 base 必须真的还是「修复前」(否则这个包会报一个假的「翻转」) ----
56
+ if [ -e "$RED_SKILL/references/migration.md" ]; then
57
+ printf 'flip-m7.1: $BASE 已经带着 references/migration.md(不是修复前的树)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' >&2
58
+ exit 2
59
+ fi
60
+ if grep -q 'team_migration_reasons' "$RED_SKILL/scripts/lib/cmd-project.sh" 2>/dev/null; then
61
+ printf 'flip-m7.1: $BASE 已经带着 doctor 指引(不是修复前的树)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' >&2
62
+ exit 2
63
+ fi
64
+
65
+ # ---- 同一个夹具:init 一个新项目,再把 AGENTS.md 标记改回旧名(模拟"当年用 pi-team 建的项目") ----
66
+ fixture() { # <标签> <skill 树> → 回显夹具目录
67
+ local tag="$1" skill="$2" d
68
+ d="$TMP/fixture-$tag"
69
+ mkdir -p "$d"
70
+ ( cd "$d" && git init -q -b main && git config user.email flip@teamsmith && git config user.name flip \
71
+ && git commit -q --allow-empty -m init )
72
+ ( cd "$d" && bash "$skill/scripts/team" init --session "flip-m71-$tag" --agents dev --vcs local \
73
+ --gates true --docs docs/team ) >"$TMP/init-$tag.log" 2>&1
74
+ {
75
+ printf 'TEAM_PI_SETTINGS_FILE="%s"\n' "$TMP/deps/settings.json"
76
+ printf 'TEAM_OPENSPEC_BIN="%s"\n' "$TMP/fake-bin/openspec"
77
+ printf 'TEAM_SPEC_DIR="%s"\n' "$TMP/deps/spec"
78
+ } >> "$d/.pi/team/config.sh"
79
+ sed -i 's|<!-- teamsmith:begin -->|<!-- pi-team:begin -->|; s|<!-- teamsmith:end -->|<!-- pi-team:end -->|' "$d/AGENTS.md"
80
+ printf '%s' "$d"
81
+ }
82
+ doctor_run() { # <skill 树> <夹具目录> <输出文件>
83
+ ( cd "$2" && PATH="$TMP/fake-bin:$PATH" bash "$1/scripts/team" doctor ) >"$3" 2>&1
84
+ }
85
+ init_run() { # <skill 树> <夹具目录> <标签>
86
+ ( cd "$2" && bash "$1/scripts/team" init --session "flip-m71-$3" --agents dev --vcs local \
87
+ --gates true --docs docs/team ) >/dev/null 2>&1
88
+ }
89
+
90
+ printf '修复前 revision: %s(%s)\n修复后 skill: %s\n' \
91
+ "$BASE" "$(git -C "$REPO_ROOT" log -1 --format=%s "$BASE")" "$SKILL_DIR"
92
+ RED_FIX="$(fixture red "$RED_SKILL")"
93
+ GREEN_FIX="$(fixture green "$SKILL_DIR")"
94
+ doctor_run "$RED_SKILL" "$RED_FIX" "$TMP/doctor-red.log"
95
+ doctor_run "$SKILL_DIR" "$GREEN_FIX" "$TMP/doctor-green.log"
96
+ init_run "$SKILL_DIR" "$GREEN_FIX" green
97
+ doctor_run "$SKILL_DIR" "$GREEN_FIX" "$TMP/doctor-green-after-init.log"
98
+ init_run "$RED_SKILL" "$RED_FIX" red
99
+ doctor_run "$RED_SKILL" "$RED_FIX" "$TMP/doctor-red-after-init.log"
100
+
101
+ # ---- 断言 ----------------------------------------------------------------
102
+ FAIL=0
103
+ ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
104
+ bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL+1)); }
105
+ printf '\n== 现场 ==\n'
106
+ printf '修复前 doctor 输出的最后一行:%s\n' "$(tail -1 "$TMP/doctor-red.log" | sed 's/^[[:space:]]*//')"
107
+ printf '修复后 doctor 的迁移指引行: %s\n' \
108
+ "$(grep 'migration.md' "$TMP/doctor-green.log" | tail -1 | sed 's/^[[:space:]]*//')"
109
+ printf '修复后 init 一次之后: %s\n' "$(tail -1 "$TMP/doctor-green-after-init.log" | sed 's/^[[:space:]]*//')"
110
+
111
+ printf '\n== 翻转断言 ==\n'
112
+ if grep -q 'migration.md' "$TMP/doctor-red.log"; then bad "修复前:doctor 竟然已经有迁移指引(夹具/基线不对)"
113
+ else ok "修复前:doctor 没有任何迁移指引(旧项目在工具里没有入口)"; fi
114
+ if [ -e "$RED_SKILL/references/migration.md" ]; then bad "修复前:migration.md 竟然存在"
115
+ else ok "修复前:references/migration.md 不存在(没有这份文档)"; fi
116
+ if grep -qF "$SKILL_DIR/references/migration.md" "$TMP/doctor-green.log"; then
117
+ ok "修复后:doctor 打出指引,且指向这棵绿树里的 migration.md"
118
+ else bad "修复后:doctor 没有指向本树 migration.md 的指引"; fi
119
+ if [ "$(grep -c 'migration.md' "$TMP/doctor-green.log")" = "1" ]; then
120
+ ok "修复后:指引只打一行(不是刷屏)"
121
+ else bad "修复后:指引打了 $(grep -c 'migration.md' "$TMP/doctor-green.log") 次"; fi
122
+ if grep -qF '<!-- teamsmith:begin -->' "$GREEN_FIX/AGENTS.md" && ! grep -qF '<!-- pi-team:begin -->' "$GREEN_FIX/AGENTS.md"; then
123
+ ok "修复后:按配方跑一次 init,旧标记被就地改写成 teamsmith(单块)"
124
+ else bad "修复后:init 之后 AGENTS.md 里还有旧标记(或新标记缺失)"; fi
125
+ if grep -q 'migration.md' "$TMP/doctor-green-after-init.log"; then
126
+ bad "修复后:标记迁移完指引还赖着不走"
127
+ else ok "修复后:标记迁移完指引消失(不再需要迁移)"; fi
128
+ if grep -q 'migration.md' "$TMP/doctor-red-after-init.log"; then
129
+ bad "修复前:跑完 init 竟然出现了修复后才有的指引"
130
+ else ok "修复前:即使跑完 init 也没有任何指引(修复确实在绿树里)"; fi
131
+
132
+ printf '\n'
133
+ [ "$FAIL" -eq 0 ] && { printf '\033[32mflip-m7.1:翻转已复现(红 → 绿)\033[0m\n'; exit 0; }
134
+ printf '\033[31mflip-m7.1:没有观察到预期的翻转(%d 条失败)\033[0m\n' "$FAIL"
135
+ exit 1