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,112 @@
1
+ #!/usr/bin/env bash
2
+ # M58/B2 · 双向机械守卫:正确性门禁里没有性能判定,性能套件里必须有判定标记。
3
+ #
4
+ # bash skills/teamsmith/tests/gate-guard.sh (纯逻辑:只 grep 三个文件,不起任何进程)
5
+ #
6
+ # 三条(任一不成立 → 打印 `bad: …` 并退出 1):
7
+ # ① `smoke.sh`(门禁本体)不得含性能判定标记,也不得点名测量夹具;
8
+ # ② `panel-knobs.sh`(时间无关的旋钮完整性助手)必须在,且走 premise-only、不驱赶测量夹具;
9
+ # ③ `perf.sh`(性能套件)必须带着那组命名单源标记 —— 「偷懒式搬迁」(从门禁删了但没落地)会被抓住。
10
+ #
11
+ # 判定标记是一个**封闭集合**(design D6):帧预算 / CPU 份额的单源常量名、旧判定的函数名与注入旋钮名
12
+ # (把 §27-d 原样塞回门禁就命中)、预算/份额的比较形态、以及测量夹具的点名。
13
+ #
14
+ # 注意:本文件**不是**被 grep 的对象(守卫自己要写这些字面量),被检查的只有上面三个文件。
15
+ # 守卫自己也不判时长、不读环境 —— 跑机核数/负载与它无关。
16
+ set -uo pipefail
17
+
18
+ here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19
+ smoke="$here/smoke.sh"
20
+ knobs="$here/panel-knobs.sh"
21
+ perf="$here/perf.sh"
22
+
23
+ FAILED=0
24
+ ok() { printf 'ok: %s\n' "$1"; }
25
+ bad() { printf 'bad: %s\n' "$1"; FAILED=$((FAILED + 1)); }
26
+
27
+ # 标记(封闭集合)
28
+ MARK_RE='PERF_FRAME_BUDGET_MS|PERF_CPU_MAX_PCT|PERF_ASSEMBLY_PREMISE_FACTOR|PERF_FIRST_FRAME_PREMISE_FACTOR|PERF_CPU_PREMISE_FACTOR|p27_assembly|TEAM_SMOKE_FRAME_DELAY_MS|TEAM_SMOKE_LOADAVG|TEAM_SMOKE_CORES'
29
+ # 时长/份额比较的形态(帧预算、秒数;把 [ "$med" -le 2000 ] 这类判定塞回来就命中)
30
+ MARK_CMP_RE='(-le|-lt|-ge|-gt)[[:space:]]+2000|(>=|<=|>|<)[[:space:]]*2000[^0-9]'
31
+ # 测量夹具的点名(门禁自己不许调用它们;面板夹具只在 premise-only 模式下经 panel-knobs.sh 被用到)
32
+ FIX_RE='panel-cpu\.sh|panel-cpu-premise\.sh|perf\.sh'
33
+
34
+ need_file() { [ -f "$1" ] || bad "缺文件 $1"; }
35
+
36
+ # ① 门禁本体
37
+ if [ -f "$smoke" ]; then
38
+ hits="$(grep -nE -- "$MARK_RE" "$smoke" || true)"
39
+ cmps="$(grep -nE -- "$MARK_CMP_RE" "$smoke" || true)"
40
+ fixes="$(grep -nE -- "$FIX_RE" "$smoke" || true)"
41
+ if [ -z "$hits$cmps$fixes" ]; then
42
+ ok "smoke.sh 里没有性能判定标记、时长/份额比较,也没有测量夹具的点名"
43
+ else
44
+ bad "smoke.sh 里出现了性能判定标记 / 比较 / 测量夹具点名($(printf '%s\n%s\n%s\n' "$hits" "$cmps" "$fixes" | grep -v '^$' | head -3 | tr '\n' ';'))"
45
+ fi
46
+ # 门禁还得真的调用守卫与旋钮助手(否则守卫被摘掉也没人知道)
47
+ for need in 'gate-guard\.sh' 'panel-knobs\.sh'; do
48
+ grep -qE -- "$need" "$smoke" || bad "smoke.sh 没有调用 $need(守卫/旋钮完整性被摘掉了)"
49
+ done
50
+ else
51
+ bad "缺 $smoke"
52
+ fi
53
+
54
+ # ② 旋钮完整性助手
55
+ if [ -f "$knobs" ]; then
56
+ if grep -qF 'TEAM_PANEL_CPU_PREMISE_ONLY=1' "$knobs"; then
57
+ ok "panel-knobs.sh 存在且走 panel-cpu.sh 的 premise-only 模式"
58
+ else
59
+ bad "panel-knobs.sh 丢了 premise-only 调用(TEAM_PANEL_CPU_PREMISE_ONLY=1)"
60
+ fi
61
+ grep -qE 'panel-cpu-premise\.sh' "$knobs" \
62
+ && bad "panel-knobs.sh 反过来驱赶测量夹具 panel-cpu-premise.sh(门禁又被测量绑上了)" \
63
+ || ok "panel-knobs.sh 不驱赶测量夹具"
64
+ else
65
+ bad "缺 $knobs(旋钮不得漏进真路径的检查没了)"
66
+ fi
67
+
68
+ # ③ 性能套件
69
+ if [ -f "$perf" ]; then
70
+ PERF_MARKERS_OK=1
71
+ for pair in 'PERF_FRAME_BUDGET_MS=2000' 'PERF_CPU_MAX_PCT=1' 'PERF_ASSEMBLY_PREMISE_FACTOR=0.75' \
72
+ 'PERF_FIRST_FRAME_PREMISE_FACTOR=0.25' 'PERF_CPU_PREMISE_FACTOR=0.25'; do
73
+ grep -qF -- "$pair" "$perf" || { bad "perf.sh 没有带着标记 $pair(判定被删掉了?)"; PERF_MARKERS_OK=0; }
74
+ done
75
+ # ok 只在**全部**标记都在时打印 —— 缺任何一个都只说 bad(PM 复验 F1:bad 与「带着标记」的 ok
76
+ # 并排是最伤信任的自相矛盾;判定 rc 一直是对的,错的是自述)。
77
+ [ "$PERF_MARKERS_OK" = "1" ] && ok "perf.sh 带着帧预算 / CPU 份额 / 前提系数的命名单源标记"
78
+ else
79
+ bad "缺 $perf"
80
+ fi
81
+
82
+ # ④ 计时记录不是判决(P70 / D33 的边界):门禁里唯一可以把「测到的时长」和阈值比的模块是
83
+ # lib/section-guard.sh(每段硬预算 = 存活检测)。标记是**比较形态**($elapsed / $SECONDS… 与
84
+ # -gt/-ge/-lt/-le 相邻),不是变量名本身 —— 别的模块打印时长、把时长当数据搬运都不算判定。
85
+ DUR_MOD="$here/lib/section-guard.sh"
86
+ DUR_CMP_RE='(\$elapsed|\$\{elapsed\}|\$duration|\$took|\$SECONDS)[^|;]*-(gt|ge|lt|le)([^0-9A-Za-z_]|$)'
87
+ DUR_HITS=""
88
+ for f in "$smoke" "$here"/lib/*.sh; do
89
+ [ -f "$f" ] || continue
90
+ [ "$f" = "$DUR_MOD" ] && continue
91
+ h="$(grep -nE -- "$DUR_CMP_RE" "$f" 2>/dev/null | head -3 || true)"
92
+ [ -n "$h" ] && DUR_HITS="$DUR_HITS$f: $h; "
93
+ done
94
+ if [ -z "$DUR_HITS" ]; then
95
+ ok "门禁的时长只被记录、不被判定(lib/section-guard.sh 之外没有时长阈值比较)"
96
+ else
97
+ bad "门禁里出现了时长阈值比较(计时记录成了判决):$DUR_HITS"
98
+ fi
99
+ if [ -f "$DUR_MOD" ]; then
100
+ grep -qE -- '-(ge|gt)[[:space:]]+"\$budget"' "$DUR_MOD" \
101
+ && ok "lib/section-guard.sh 是唯一做时长比较的模块(trip 比较在位)" \
102
+ || bad "lib/section-guard.sh 丢了 trip 比较(-ge \"\$budget\")—— 单源边界没了"
103
+ else
104
+ bad "缺 $DUR_MOD(每段硬预算的看门狗模块)"
105
+ fi
106
+
107
+ if [ "$FAILED" -eq 0 ]; then
108
+ printf '\ngate-guard: 四向都过(门禁无判定、旋钮助手在岗、性能套件带标记、时长比较只在段落守卫)\n'
109
+ exit 0
110
+ fi
111
+ printf '\ngate-guard: %d 条不成立\n' "$FAILED"
112
+ exit 1
@@ -0,0 +1,233 @@
1
+ #!/usr/bin/env bash
2
+ # teamsmith · 守卫状态矩阵(E3 §1.5 的 10 个实测状态)
3
+ #
4
+ # bash tests/guard-matrix.sh
5
+ #
6
+ # 为什么需要它:守卫是「光标锚定 + 只看光标行及以上」的启发式,它的边界不是靠理由,而是靠
7
+ # E3 在真实 Pi pane 上量出来的 10 个状态(E3 §1.1 的捕获形状 + §1.5 的矩阵)。这里把那 10 个状态
8
+ # 逐个喂给**生产代码**(lib/outbox.sh 的守卫函数),断言判定与真值一致 —— 唯一允许的分歧是
9
+ # 9b「纯空白草稿」:光标相对检测法的实测盲区,规格要求它被写下来而不是被修好(不许静默)。
10
+ #
11
+ # 怎么喂:PATH 里放一个假 tmux —— capture-pane 输出状态文本,display-message '#{cursor_y}'
12
+ # 输出状态的光标行。判断用的是真的 team_input_box_state(不是测试里抄一份)。
13
+ set -uo pipefail
14
+
15
+ SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
17
+ # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
18
+ . "$SELF_DIR/lib/tmp-root.sh"
19
+
20
+ [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
21
+ TMP="$(tmp_root_create guard-matrix)" || exit 3
22
+ trap 'tmp_root_reap_all' EXIT
23
+ SHIM="$TMP/bin"
24
+ mkdir -p "$SHIM"
25
+ : > "$TMP/capture"
26
+ : > "$TMP/cursor"
27
+
28
+ cat > "$SHIM/tmux" <<EOF
29
+ #!/usr/bin/env bash
30
+ # 假 tmux:只服务本矩阵。capture-pane 输出状态文本;cursor_y 输出状态光标行(tmux 是 0-based)
31
+ case "\$*" in
32
+ *cursor_y*) n="\$(cat "$TMP/cursor" 2>/dev/null)"; printf '%s\n' "\$(( \${n:-1} - 1 ))" ;;
33
+ *capture-pane*) cat "$TMP/capture" 2>/dev/null ;;
34
+ *) : ;;
35
+ esac
36
+ exit 0
37
+ EOF
38
+ chmod +x "$SHIM/tmux"
39
+
40
+ RULE="$(printf '%.0s─' $(seq 1 80))"
41
+ PASS=0; FAIL=0
42
+ ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
43
+ bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
44
+
45
+ # 写状态:第一个参数是光标所在的 1-based 屏幕行;后面的行从屏幕第 21 行开始铺
46
+ # (E3 的捕获就是从 row 21 起摘的:上面是对话,输入框在其下)
47
+ state() { # <cursor-row> <行...>
48
+ local cursor="$1"; shift
49
+ {
50
+ local i
51
+ for i in $(seq 1 20); do printf '\n'; done
52
+ for line in "$@"; do printf '%s\n' "$line"; done
53
+ } > "$TMP/capture"
54
+ printf '%s\n' "$cursor" > "$TMP/cursor"
55
+ }
56
+
57
+ verdict() {
58
+ PATH="$SHIM:$PATH" bash -c '. "'"$SKILL_DIR"'/scripts/lib/common.sh"; team_input_box_state "sess:win"' 2>/dev/null
59
+ }
60
+
61
+ check() { # <名字> <期望> <真值说明>
62
+ local got; got="$(verdict)"
63
+ if [ "$got" = "$2" ]; then ok "状态 $1 → $got"
64
+ else bad "状态 $1:期望 $2,实际 $got($3)"; fi
65
+ }
66
+
67
+ printf 'teamsmith guard matrix · skill=%s\n' "$SKILL_DIR"
68
+
69
+ # ---- 1. 空框(PM 的包自带提示行),光标在第一行内容行 --------------------------
70
+ # E3 §1.1(a):上边框 21、内容行 22-24、提示行 25、下边框 26、footer 27,cursor=0,22 → 行 23
71
+ state 23 "$RULE" "" "" "" " k3 Kimi Coding max" "$RULE" "footer"
72
+ check "1 空框(包提示行)" EMPTY "E3 §1.5 状态 1"
73
+
74
+ # ---- 2. 单行草稿(光标在草稿行)----------------------------------------------
75
+ # E3 §1.1(b):草稿在 23,blank 24,hint 25,下边框 26,cursor=24,22 → 行 23
76
+ state 23 "$RULE" "" "半截草稿 half a sentence" "" " k3 Kimi Coding max" "$RULE" "footer"
77
+ check "2 单行草稿" BUSY "E3 §1.5 状态 2"
78
+
79
+ # ---- 3. 草稿 + 尾随空格 ------------------------------------------------------
80
+ state 23 "$RULE" "" "draft with trailing spaces " "" " k3 Kimi Coding max" "$RULE" "footer"
81
+ check "3 草稿带尾随空格" BUSY "E3 §1.5 状态 3"
82
+
83
+ # ---- 4. 清空(C-u 之后)------------------------------------------------------
84
+ state 23 "$RULE" "" "" "" " k3 Kimi Coding max" "$RULE" "footer"
85
+ check "4 清空后" EMPTY "E3 §1.5 状态 4"
86
+
87
+ # ---- 5. 工作中(spinner 当上边框)+ 空框 -------------------------------------
88
+ # E3 §1.1(c):spinner 在 24,内容行 25-29,hint 30,下边框 31,footer 32,cursor=0,27 → 行 28
89
+ state 28 "" "" "" "── ⠇ Photosynthesizing… · 3s ────────────" "" "" "" "" "" " k3 Kimi Coding max" "$RULE" "footer"
90
+ check "5 工作中·空框" EMPTY "E3 §1.5 状态 5(spinner 上边框)"
91
+
92
+ # ---- 6. 工作中 + 草稿 --------------------------------------------------------
93
+ state 28 "" "" "" "── ⠇ Photosynthesizing… · 3s ────────────" "" "" "" "draft while working" "" " k3 Kimi Coding max" "$RULE" "footer"
94
+ check "6 工作中·有草稿" BUSY "E3 §1.5 状态 6"
95
+
96
+ # ---- 7. Steering 队列挂件可见 + 空框 ----------------------------------------
97
+ state 24 " Steering: beta line two" " ↳ Alt+Up to edit all queued messages" "$RULE" "" "" "" " k3 Kimi Coding max" "$RULE" "footer"
98
+ check "7 Steering 挂件·空框" EMPTY "E3 §1.5 状态 7"
99
+
100
+ # ---- 8. 三行草稿,光标在草稿后面的空行 ---------------------------------------
101
+ state 25 "$RULE" "线一" "线二" "线三" "" " k3 Kimi Coding max" "$RULE" "footer"
102
+ check "8 三行草稿·光标在尾随空行" BUSY "E3 §1.5 状态 8(整框扫描:光标上方内容行)"
103
+
104
+ # ---- 10. 光标停在空白行、草稿文字在光标**下方**(V7-F1 真实 Pi 复现形)----------
105
+ # 人的草稿以空行开头(leading newline),Up 键把光标移到那空行上:文字全在光标行下方。
106
+ # 光标相对判定(v2)在这里漏检、判 EMPTY → 消息打进草稿粘连 D20;整框扫描必须 BUSY。
107
+ state 23 "$RULE" "" "BODY-1" "BODY-2" " k3 Kimi Coding max" "$RULE" "footer"
108
+ check "10 草稿在光标行下方(V7-F1)" BUSY "V7-F1:leading-newline + Up × N 的真实形状"
109
+
110
+ # ---- 11. 草稿以空行开头、光标在首行空行(下方有文字,中间还隔空行)--------------
111
+ state 23 "$RULE" "" "BODY-1" "" " k3 Kimi Coding max" "$RULE" "footer"
112
+ check "11 空行开头草稿·光标在顶部" BUSY "V7-F1 变体:光标与文字之间再隔空行也是 BUSY"
113
+
114
+ # ---- 9a. 校准之后的空框 ------------------------------------------------------
115
+ # 与状态 1 同形:它的价值是防止以后加「基线」(v3)时把校准后的空框误判成 BUSY
116
+ state 23 "$RULE" "" "" "" " k3 Kimi Coding max" "$RULE" "footer"
117
+ check "9a 校准后空框" EMPTY "E3 §1.5 状态 9a"
118
+
119
+ # ---- 9b. 纯空白草稿:**已知盲区**(规格要求写下来,不是要求修好)--------------
120
+ # tmux capture-pane 会裁掉行尾空白,所以「三个空格」在捕获里就是空行 —— 这正是 E3 量到的洞
121
+ state 23 "$RULE" "" " " "" " k3 Kimi Coding max" "$RULE" "footer"
122
+ check "9b 纯空白草稿(已知盲区)" EMPTY "E3 §1.5 状态 9b:这个洞必须在 troubleshooting.md §3 里写明"
123
+
124
+ # ---- 12. 草稿里含一行框线(光标在它下方):V8-N1 的真实 Pi 形状 ----------------
125
+ # 人的草稿 = 「half a sentence」+ 一行 10 字 ─(粘贴 Markdown 分隔线/表格会产生);
126
+ # 旧判据把草稿自己的框线当成上边框,它上方的正文被排除 → 脏框判成空框(D20 重演)。
127
+ RULE10="$(printf '%.0s─' $(seq 1 10))"
128
+ state 24 "$RULE" "half a sentence" "$RULE10" "" " k3 Kimi Coding max" "$RULE" "footer"
129
+ check "12 草稿含框线行·光标在下方(V8-N1)" BUSY "V8-N1:短框线不许顶替真上边框"
130
+
131
+ # ---- 13. 同根镜像:光标在草稿框线的上方,文字在框线下方(V8-N1c)----------------
132
+ state 22 "$RULE" "" "$RULE10" "draft below the rule" " k3 Kimi Coding max" "$RULE" "footer"
133
+ check "13 框线在光标下方·文字更下(V8-N1c)" BUSY "V8-N1c:短框线不许顶替真下边框"
134
+
135
+ # ---- 14. 草稿最后一行是**等宽**框线(V9-A4,裁切型 TUI 可达)-----------------
136
+ # 粘贴的长分隔线被裁到 pane 宽 / Markdown 表格分隔行正好整除 → 整行 ─ 的宽度恰好等于
137
+ # 下边框。「最近者优先」会把它当上边框、正文被排除 → 脏框判空(D20 损害);
138
+ # 修:上边框取「最高的等宽候选」,草稿框线落在框**内**成为内容。
139
+ state 24 "$RULE" "a sentence in the draft" "$RULE" "" " k3 Kimi Coding max" "$RULE" "footer"
140
+ check "14 草稿含等宽框线·光标在下方(V9-A4)" BUSY "V9-A4:等宽框线也不许顶替真上边框"
141
+
142
+ # ---- 15. 草稿是粘贴的 Markdown 表格(两条等宽框线,光标在下方)(V9-A5)---------
143
+ state 26 "$RULE" "| col |" "$RULE" "| row 2 |" "$RULE" "" " k3 Kimi Coding max" "$RULE" "footer"
144
+ check "15 表格草稿·两条等宽框线(V9-A5)" BUSY "V9-A5:表格边框行落在框内成为内容"
145
+
146
+ # ---- 16. 工作中(spinner 顶边框)+ 草稿里有 spinner 形状的一行(V9-A8)-----------
147
+ # tier2「最近者优先」会把草稿自己的 ──…── 行当成上边框 → 上方正文被排除 → EMPTY。
148
+ SPIN="── ⠇ Photosynthesizing… · 3s ────────────"
149
+ state 28 "" "" "" "$SPIN" "" "" "── 我草稿里的分隔 ────────────" "" " k3 Kimi Coding max" "$RULE" "footer"
150
+ check "16 spinner 顶 + 草稿 spinner 形状行(V9-A8)" BUSY "V9-A8:tier2 同样取最高候选"
151
+
152
+ # ---- 17. 光标**坐在**草稿的等宽框线行上(V9-A10 的真实夹具形状)-----------------
153
+ # mytui/真实 TUI 里草稿末行是等宽框线时光标就停在那一行;若把光标行自己也当下边框候选,
154
+ # 它上方的正文会落进提示行槽位被排除 → 脏框判空(D20 损害)。下边框严格在光标下方找。
155
+ state 23 "$RULE" "a sentence in the draft" "$RULE" " k3 Kimi Coding max" "$RULE" "footer"
156
+ check "17 光标在草稿等宽框线行上(V9-A10)" BUSY "V9-A10:光标行自身是内容,不是下边框"
157
+
158
+ # ---- 附:非 Pi pane(找不到上下框线)→ UNKNOWN -------------------------------
159
+ state 3 "working…" "working…" "working…" "working…"
160
+ check "附·非 Pi pane(无框线)" UNKNOWN "E3 §1.5 的 matrix3:bash/vim 这类 pane → NONE"
161
+
162
+ printf '\n== holds_only 指纹判据(V8-N2/N4 + 既有形状) ==\n'
163
+
164
+ verdict_holds() { # <payload 原文>
165
+ PATH="$SHIM:$PATH" bash -c '. "'"$SKILL_DIR"'/scripts/lib/common.sh"
166
+ if team_box_holds_only "sess:win" "$1"; then printf "only-ours\n"; else printf "extra-text\n"; fi' _ "$1" 2>/dev/null
167
+ }
168
+ check_holds() { # <名字> <期望> <payload> <说明>
169
+ local got; got="$(verdict_holds "$3")"
170
+ if [ "$got" = "$2" ]; then ok "holds $1 → $got"
171
+ else bad "holds $1:期望 $2,实际 $got($4)"; fi
172
+ }
173
+
174
+ BIG14="$(seq -w 1 14 | sed 's/^/line-/')" # 14 行 payload(尾随换行被 $() 剥掉)
175
+
176
+ # H1(V8-N2):payload 原文里就有占位符字样,框里是它的**逐字**形态 → 我们的
177
+ state 23 "$RULE" "" "see [paste #1 +3 lines] and more text" "" " k3 Kimi Coding max" "$RULE" "footer"
178
+ check_holds "H1 payload 含占位符字样·逐字(V8-N2)" only-ours \
179
+ "see [paste #1 +3 lines] and more text" "剥除路径不许剥 payload 原文"
180
+
181
+ # H2(V8-N4):框里两个折叠占位符(人的粘贴 + 我们的粘贴)→ 不是「只有我们」
182
+ state 23 "$RULE" "" "[paste #1 +3 lines][paste #2 +14 lines]" "" " k3 Kimi Coding max" "$RULE" "footer"
183
+ check_holds "H2 双占位符(V8-N4)" extra-text "$BIG14" "多于一个占位符就必须判竞态"
184
+
185
+ # H3:框里只有一个占位符且 +K == payload 行数 → 我们的粘贴被折叠,放行
186
+ state 23 "$RULE" "" "[paste #1 +14 lines]" "" " k3 Kimi Coding max" "$RULE" "footer"
187
+ check_holds "H3 单占位符·K 匹配" only-ours "$BIG14" "Pi 折叠我们自己的粘贴的正常形态"
188
+
189
+ # H4:只有一个占位符但 +K 与 payload 行数对不上 → 那不是我们的粘贴
190
+ state 23 "$RULE" "" "[paste #1 +3 lines]" "" " k3 Kimi Coding max" "$RULE" "footer"
191
+ check_holds "H4 单占位符·K 不符" extra-text "$BIG14" "+K 必须与 payload 行数对齐"
192
+
193
+ # H5(V7-90.B 形状保持):占位符旁边有人的字 → 竞态
194
+ state 23 "$RULE" "" "HI-[paste #1 +15 lines]" "" " k3 Kimi Coding max" "$RULE" "footer"
195
+ check_holds "H5 占位符+人的字(V7 形状)" extra-text "$BIG14" "折叠框混入人字必须拦住"
196
+
197
+ # H6(V8-N6 边界,记录在案):可见区只是 payload 前缀 → 仍判 only-ours(截断/横滚窗口)
198
+ state 23 "$RULE" "" "V8PROBE-LONG" "" " k3 Kimi Coding max" "$RULE" "footer"
199
+ check_holds "H6 前缀窗口(V8-N6 边界)" only-ours "V8PROBE-LONG-MESSAGE" "为截断显示保留的接受窗口,后果写进 troubleshooting"
200
+
201
+ # H7:草稿行 + 占位符(K 碰巧对上)→ 竞态。占位符路径依赖框文本拼接后整串锚定
202
+ # (`^…$` 跨不过拼接出来的同行),这条 pin 住「占位符不独占全框就不算我们的」。
203
+ state 23 "$RULE" "" "draft line[paste #1 +14 lines]" "" " k3 Kimi Coding max" "$RULE" "footer"
204
+ check_holds "H7 占位符不独占全框(K 碰巧对上)" extra-text "$BIG14" "K 对上也不够:占位符必须独占全框"
205
+
206
+ # H8(V9-B1 的 holds_only 层):payload 正文含**半成品**占位符字样,框里是逐字形态 → 我们的
207
+ state 23 "$RULE" "" "the guard waits while the TUI draws [paste #1 +1 frames" "" " k3 Kimi Coding max" "$RULE" "footer"
208
+ check_holds "H8 payload 含半成品占位符字样·逐字(V9-B1)" only-ours \
209
+ "the guard waits while the TUI draws [paste #1 +1 frames" "半成品字样由逐字判据放行,不进中间帧/占位符路径"
210
+
211
+ # ---- H9–H12:中间帧判据的双向边界(V9-B1 子串变体 / B2 反向形状)-------------
212
+ # 子串匹配曾把 payload 自己的正文误判成「还在渲染」(V9-B1);反向的误伤是「payload 含完整
213
+ # 占位符字样被压住」(V9-B2)。两个方向都钉:
214
+ # H9 句子里嵌了半成品字样(不是整行)→ 不是中间帧(子串不触发)
215
+ # H10 句子里嵌了完整占位符字样 → 不是中间帧
216
+ # H11 整行就是半成品(真实的渲染中间帧)→ 是中间帧(等待渲染完成)
217
+ # H12 整行是完整占位符(折叠后的终态)→ 不是中间帧(走 holds_only 的 +K 路径)
218
+ check_mid() { # <名字> <期望 1/0> <文本> <说明>
219
+ local got=0
220
+ PATH="$SHIM:$PATH" bash -c '. "'"$SKILL_DIR"'/scripts/lib/common.sh"; team_box_mid_render "$1"' _ "$3" >/dev/null 2>&1 && got=1
221
+ if [ "$got" = "$2" ]; then ok "pin $1"
222
+ else bad "pin $1:期望 $2,实际 $got($4)"; fi
223
+ }
224
+ check_mid "H9 子串半成品字样不是中间帧(V9-B1)" 0 \
225
+ "the guard waits while the TUI draws [paste #1 +1 frames" "子串不触发中间帧"
226
+ check_mid "H10 子串完整占位符字样不是中间帧(V9-B2)" 0 \
227
+ "see [paste #1 +3 lines] and more text" "payload 自带占位符字样照常走投递"
228
+ check_mid "H11 整行半成品是中间帧(V8-N3)" 1 "[paste #1 +1" "真实的渲染中间帧要继续等"
229
+ check_mid "H12 整行完整占位符不是中间帧" 0 "[paste #1 +14 lines]" "折叠终态走 holds_only"
230
+
231
+ printf '\n== 结果 == ✓ %s ✗ %s\n' "$PASS" "$FAIL"
232
+ [ "$FAIL" -eq 0 ] || exit 1
233
+ printf 'guard matrix 全绿\n'