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,41 @@
1
+ #!/usr/bin/env bash
2
+ # A deliberately slow `team __panel-data` stand-in for the keystroke fixture (tasks.md 1.4).
3
+ #
4
+ # The probe calls the tree's own data layer with `--team-cli` pointing here, so the refresh is a
5
+ # controlled five seconds instead of a busy repository. Both request shapes are served: the full
6
+ # object (pre-change data layer) and one block per call (post-change data layer).
7
+ set -euo pipefail
8
+
9
+ sleep "${KEYPROBE_STUB_SLEEP:-5}"
10
+
11
+ block=""
12
+ prev=""
13
+ for a in "$@"; do
14
+ [ "$prev" = "--block" ] && block="$a"
15
+ prev="$a"
16
+ done
17
+
18
+ emit_full() {
19
+ cat <<'JSON'
20
+ {"panel": {"project": "keyprobe", "timestamp": "2026-01-01T00:00:00Z", "interval": 900,
21
+ "standby": {"on": false, "reason": ""},
22
+ "pm": {"state": "absent", "detail": "", "evidence": ""},
23
+ "pending": {"inbox": 0, "reports": 0, "todo": 0, "wip": 0, "review": 0, "blocked": 0, "stopped": 0, "total": 0, "text": ""},
24
+ "outbox": {"queued": 0, "held": 0, "oldest_age_s": null, "forced": 0},
25
+ "capacity": {"ram_avail_mb": 4000, "swap_free_mb": 1024, "agents": 2, "spark": [4000, 4010]},
26
+ "agents": [], "recent": [], "activity_source": ""}, "activity": []}
27
+ JSON
28
+ }
29
+
30
+ case "$block" in
31
+ "") emit_full ;;
32
+ frame) printf '%s\n' '{"project": "keyprobe", "timestamp": "2026-01-01T00:00:00Z", "interval": 900, "standby": {"on": false, "reason": ""}, "activity_source": ""}' ;;
33
+ pm) printf '%s\n' '{"state": "absent", "detail": "", "evidence": ""}' ;;
34
+ pending) printf '%s\n' '{"inbox": 0, "reports": 0, "todo": 0, "wip": 0, "review": 0, "blocked": 0, "stopped": 0, "total": 0, "text": ""}' ;;
35
+ outbox) printf '%s\n' '{"queued": 0, "held": 0, "oldest_age_s": null, "forced": 0}' ;;
36
+ capacity) printf '%s\n' '{"ram_avail_mb": 4000, "swap_free_mb": 1024, "agents": 2, "spark": [4000, 4010]}' ;;
37
+ agents) printf '%s\n' '[]' ;;
38
+ recent) printf '%s\n' '[]' ;;
39
+ activity) printf '%s\n' '[]' ;;
40
+ *) printf 'keyprobe-stub: unknown block %s\n' "$block" >&2; exit 2 ;;
41
+ esac
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env bash
2
+ # Keystroke flip fixture (pulse-console B1, tasks.md 1.4).
3
+ #
4
+ # bash skills/teamsmith/tests/panel-keyprobe.sh [tree]
5
+ #
6
+ # `tree` defaults to the repository this script lives in. The probe is built **from that tree**, so
7
+ # running the same fixture against the pre-change revision and the branch is the flip: the stub
8
+ # reader sleeps five seconds, the pty types `m`+`hello`+Enter during the refresh, and the fixture
9
+ # passes only when the compose line opened and the draft is exactly `hello`.
10
+ #
11
+ # Exit: 0 green, 2 the draft never arrived / was distorted (the red case), 3 setup failure.
12
+ set -uo pipefail
13
+
14
+ here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
+ # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
16
+ . "$here/lib/tmp-root.sh"
17
+ tree="${1:-$(cd -P "$here/../../.." && pwd)}"
18
+ tmp="$(tmp_root_create panel-keyprobe)" || exit 3
19
+ log="$tmp/keyprobe.log"
20
+ out="$tmp/probe.out"
21
+ rc=3
22
+ cleanup() { tmp_root_reap_all; }
23
+ trap cleanup EXIT
24
+
25
+ bun_bin="${BUN:-}"
26
+ if [ -z "$bun_bin" ] && command -v bun >/dev/null 2>&1; then bun_bin="$(command -v bun)"; fi
27
+ [ -n "$bun_bin" ] || bun_bin="$HOME/.bun/bin/bun"
28
+ js="${TEAM_JS_BIN:-}"
29
+ if [ -z "$js" ] && command -v node >/dev/null 2>&1; then js="$(command -v node)"; fi
30
+ [ -n "$js" ] || js="$(command -v bun || echo '')"
31
+
32
+ if [ ! -x "$bun_bin" ]; then
33
+ printf 'panel-keyprobe: bun is required to build the probe (looked at %s)\n' "$bun_bin" >&2
34
+ exit 3
35
+ fi
36
+ if [ -z "$js" ]; then
37
+ printf 'panel-keyprobe: no node/bun runtime to run the probe\n' >&2
38
+ exit 3
39
+ fi
40
+ if [ ! -f "$tree/skills/teamsmith/tests/panel-keyprobe.tsx" ]; then
41
+ printf 'panel-keyprobe: %s does not carry the fixture\n' "$tree" >&2
42
+ exit 3
43
+ fi
44
+
45
+ stub="$tmp/keyprobe-stub.sh"
46
+ cp "$tree/skills/teamsmith/tests/panel-keyprobe-stub.sh" "$stub"
47
+ chmod +x "$stub"
48
+
49
+ # The probe is built from the tree under test: its `src/data.ts` is what the fixture exercises.
50
+ if ! "$bun_bin" build "$tree/skills/teamsmith/tests/panel-keyprobe.tsx" --target=node --format=esm \
51
+ --outfile "$tmp/keyprobe.js" >"$tmp/build.log" 2>&1; then
52
+ printf 'panel-keyprobe: cannot build the probe from %s\n' "$tree" >&2
53
+ tail -5 "$tmp/build.log" >&2
54
+ exit 3
55
+ fi
56
+
57
+ mkdir -p "$tmp/root"
58
+ printf '%s\n' "tree: $tree" >"$out"
59
+ set +e
60
+ python3 "$tree/skills/teamsmith/tests/panel-keyprobe-pty.py" --log "$log" --timeout 20 -- \
61
+ "$js" "$tmp/keyprobe.js" --root "$tmp/root" --team-cli "$stub" --log "$log" --timeout 15000 \
62
+ >>"$out" 2>&1
63
+ probe_rc=$?
64
+ set -e
65
+ printf 'probe rc: %s\n' "$probe_rc" >>"$out"
66
+
67
+ printf '== keyprobe.out ==\n'
68
+ cat "$out"
69
+ printf '== keyprobe.log ==\n'
70
+ cat "$log" 2>/dev/null || printf '(no log)\n'
71
+
72
+ if grep -q '^SUBMITTED draft=hello$' "$log" 2>/dev/null; then
73
+ printf 'panel-keyprobe: OK — compose opened and the draft is exactly hello\n'
74
+ rc=0
75
+ elif [ "$probe_rc" = "2" ]; then
76
+ printf 'panel-keyprobe: RED — the keystrokes never opened compose / became the draft hello\n' >&2
77
+ rc=2
78
+ else
79
+ printf 'panel-keyprobe: FAIL — probe rc=%s\n' "$probe_rc" >&2
80
+ rc=2
81
+ fi
82
+ exit "$rc"
@@ -0,0 +1,116 @@
1
+ // Keystroke probe (tasks.md 1.4): the tree's own panel data layer plus a minimal compose line,
2
+ // typed into over a pty while a five-second reader refresh is in flight.
3
+ //
4
+ // Why a probe and not the shipped console: in batch B1 the console has no compose line yet
5
+ // (batch B2 owns it), so "the draft holds exactly `hello`" needs an input line; the property under
6
+ // test is the data layer's, and this probe drives the tree's real `loadPanelData` exactly the way
7
+ // `src/main.tsx` does and reports every input event it sees.
8
+ //
9
+ // The input model matches Ink's `useInput` on the pinned version (E6 §2.3): one read from the
10
+ // terminal is one input event, and an event that is exactly `m` opens the compose line. Escape
11
+ // prefixes are tolerated the way Ink strips them.
12
+ //
13
+ // Usage: bun build panel-keyprobe.tsx --target=node --format=esm --outfile keyprobe.js
14
+ // node keyprobe.js --root DIR --team-cli STUB --log FILE [--timeout MS]
15
+ //
16
+ // Log lines (one JSON object each, plus the two plain markers):
17
+ // {"kind":"start"|"assembly"|"input"|"submit"|"timeout", ...}
18
+ // SUBMITTED draft=<draft> — printed when the compose line submits
19
+ // Exit: 0 = submitted, 2 = timed out, 3 = assembly failed before any input.
20
+
21
+ import { appendFileSync, writeFileSync } from 'node:fs'
22
+ import { loadPanelData } from '../scripts/panel/src/data.js'
23
+
24
+ function argOf(name: string): string | undefined {
25
+ const i = process.argv.indexOf(`--${name}`)
26
+ if (i === -1) return undefined
27
+ const v = process.argv[i + 1]
28
+ return v && !v.startsWith('--') ? v : undefined
29
+ }
30
+
31
+ const root = argOf('root') || process.cwd()
32
+ const teamCli = argOf('team-cli')
33
+ const logFile = argOf('log') || `${root}/.pi/team/state/keyprobe.log`
34
+ const timeoutMs = Number(argOf('timeout') ?? 15000) || 15000
35
+
36
+ writeFileSync(logFile, '')
37
+ const log = (obj: Record<string, unknown>): void => appendFileSync(logFile, `${JSON.stringify(obj)}\n`)
38
+ const logLine = (line: string): void => appendFileSync(logFile, `${line}\n`)
39
+ const now = (): number => Date.now()
40
+
41
+ // ---- the input line (the console's `m` / typing / Enter, batch B2's shape) --------------------
42
+ let composing = false
43
+ let draft = ''
44
+ let submitted = false
45
+
46
+ function handleEvent(input: string): void {
47
+ log({ kind: 'input', t: now(), input, composing, draft })
48
+ if (!composing) {
49
+ if (input === 'm') {
50
+ composing = true
51
+ log({ kind: 'compose-open', t: now() })
52
+ }
53
+ return
54
+ }
55
+ for (const ch of input) {
56
+ if (ch === '\r' || ch === '\n') {
57
+ submitted = true
58
+ log({ kind: 'submit', t: now(), draft })
59
+ logLine(`SUBMITTED draft=${draft}`)
60
+ finish(0)
61
+ return
62
+ }
63
+ if (ch === '\x7f' || ch === '\b') {
64
+ draft = [...draft].slice(0, -1).join('')
65
+ continue
66
+ }
67
+ if (ch < ' ' && ch !== '\t') continue
68
+ draft += ch
69
+ }
70
+ }
71
+
72
+ let done = false
73
+ function finish(code: number): void {
74
+ if (done) return
75
+ done = true
76
+ try {
77
+ process.stdin.setRawMode?.(false)
78
+ } catch {
79
+ /* the pty may already be gone */
80
+ }
81
+ process.exit(code)
82
+ }
83
+
84
+ // ---- the data layer (the thing under test) ----------------------------------------------------
85
+ const startedAt = now()
86
+ log({ kind: 'start', t: startedAt, root, teamCli })
87
+
88
+ // Ink enables raw mode before effects run, which is why the terminal is raw while the first
89
+ // refresh is still in flight on the blocking revision.
90
+ try {
91
+ process.stdin.setRawMode?.(true)
92
+ } catch {
93
+ /* not a tty: the driver always gives us one */
94
+ }
95
+ process.stdin.resume()
96
+ process.stdin.on('data', (chunk: Buffer) => {
97
+ // One read = one input event (Ink's useInput contract); strip a leading escape prefix like Ink.
98
+ let input = chunk.toString('utf8')
99
+ if (input.startsWith('\x1b')) input = input.slice(1)
100
+ handleEvent(input)
101
+ })
102
+
103
+ // `await` works on both revisions: before the change `loadPanelData` returns a value synchronously
104
+ // (and blocks the loop doing it), after it returns a promise and never blocks.
105
+ void (async () => {
106
+ const res = await loadPanelData({ root, teamCli, activity: false, events: 4 })
107
+ log({ kind: 'assembly', t: now(), ms: now() - startedAt, ok: res.ok, error: res.error ?? '' })
108
+ if (!res.ok && !submitted) finish(3)
109
+ })()
110
+
111
+ setTimeout(() => {
112
+ if (submitted) return
113
+ log({ kind: 'timeout', t: now(), composing, draft })
114
+ logLine('TIMEOUT')
115
+ finish(2)
116
+ }, timeoutMs)
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env bash
2
+ # M58/B2 · 旋钮完整性(时间无关)—— 正确性门禁每轮跑的 d-realpath 承诺。
3
+ #
4
+ # bash skills/teamsmith/tests/panel-knobs.sh (FAST 安全:不起 tmux / node / 任何测量)
5
+ #
6
+ # 背景:`panel#Frame assembly is asynchronous…` 的「夹具旋钮不得漏进真路径」以前由面板测量夹具的
7
+ # d-realpath 用例带着一次真测量来证;M58 把测量搬进性能套件后,正确性门禁
8
+ # 只留**时间无关**的这一半:
9
+ # ① 三个 TEAM_PANEL_CPU_* 旋钮在夹具开关关着时必须被忽略并打印;
10
+ # ② premise 行只反映真读数(不许出现注入的 9999 / 1 核);
11
+ # ③ 不判任何时长(输出里没有 median / budget / pane CPU 判定行)。
12
+ # 实现走 panel-cpu.sh 的 premise-only 模式(TEAM_PANEL_CPU_PREMISE_ONLY=1):那条路径在起 tmux/node
13
+ # 之前就退出,所以门禁不再点名任何测量夹具(守卫见 tests/gate-guard.sh)。
14
+ #
15
+ # 退出码:0 全绿;1 有失败项。输出:ok/bad + `== 结果 ==` 一行。
16
+ set -uo pipefail
17
+
18
+ here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19
+ tree="${TEAM_PANEL_CPU_TREE:-$(cd -P "$here/../../.." && pwd)}"
20
+ cpu="$here/panel-cpu.sh"
21
+ PASS=0; FAIL=0
22
+ ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
23
+ bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
24
+ result_line() { printf '\n== 结果 == ✓ %d ✗ %d\n' "$PASS" "$FAIL"; }
25
+
26
+ if [ ! -f "$cpu" ]; then
27
+ bad "缺 $cpu(premise-only 模式的宿主)"
28
+ result_line; exit 1
29
+ fi
30
+ real_load="$(cut -d' ' -f1 /proc/loadavg 2>/dev/null || printf '?')"
31
+ real_cores="$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || printf 0)"
32
+ case "$real_cores" in ''|*[!0-9]*) real_cores=0 ;; esac
33
+
34
+ out="$(mktemp "${TMPDIR:-/tmp}/panel-knobs.XXXXXX")"
35
+ trap 'rm -f "$out"' EXIT
36
+ # 夹具开关**显式清掉**(继承来的 TEAM_SMOKE_FIXTURE=1 会让注入被采信,那样这条检查就假绿);
37
+ # 三个旋钮全部注入,正是 d-realpath 的形状。
38
+ (
39
+ cd "$tree" && env -u TEAM_SMOKE_FIXTURE -u TEAM_SMOKE_LOADAVG -u TEAM_SMOKE_CORES \
40
+ -u TEAM_SMOKE_FRAME_DELAY_MS -u TMUX -u TMUX_PANE -u TMUX_TMPDIR \
41
+ TEAM_PANEL_CPU_LOADAVG=9999 TEAM_PANEL_CPU_CORES=1 TEAM_PANEL_CPU_FRAME_DELAY_MS=99999 \
42
+ TEAM_PANEL_CPU_PREMISE_ONLY=1 \
43
+ timeout 30 bash "$cpu"
44
+ ) >"$out" 2>&1
45
+ rc=$?
46
+ if [ "$rc" = 0 ]; then
47
+ ok "premise-only 模式退出 0(它不判时长)"
48
+ else
49
+ bad "premise-only 模式退出 $rc(期望 0)"; sed -n '1,6p' "$out" | sed 's/^/ /'
50
+ fi
51
+ for kv in 'TEAM_PANEL_CPU_LOADAVG=9999' 'TEAM_PANEL_CPU_CORES=1' 'TEAM_PANEL_CPU_FRAME_DELAY_MS=99999'; do
52
+ if grep -qF "忽略 $kv" "$out"; then ok "注入的旋钮被忽略并打印:$kv"
53
+ else bad "没有看到「忽略 $kv」行"; fi
54
+ done
55
+ if grep -qE 'load premise: loadavg [0-9.]+ (<=|>) [0-9.]+ \(0\.25 x [0-9]+ cores\)' "$out"; then
56
+ ok "premise 行在,且是 0.25 × 核格式"
57
+ else
58
+ bad "缺 premise 行(或格式不是 0.25 × 核)"; sed -n '/load premise/p' "$out" | sed 's/^/ /'
59
+ fi
60
+ if [ "$real_cores" -gt 0 ] && grep -qF "(0.25 x ${real_cores} cores)" "$out"; then
61
+ ok "premise 行用的是真核数(${real_cores})"
62
+ else
63
+ bad "premise 行没有用真核数(期望 0.25 x ${real_cores} cores)"
64
+ fi
65
+ if grep -qF "loadavg ${real_load}" "$out"; then
66
+ ok "premise 行用的是真 loadavg(${real_load})"
67
+ else
68
+ bad "premise 行的 loadavg 不是真读数(期望 ${real_load})"; sed -n '/load premise/p' "$out" | sed 's/^/ /'
69
+ fi
70
+ if [ "$real_cores" != "1" ] && grep -qE 'loadavg 9999|\(0\.25 x 1 cores\)' "$out"; then
71
+ bad "premise 行里出现了注入值(旋钮漏进了真路径!)"
72
+ else
73
+ ok "premise 行里没有注入值(没有 9999 / 1 核)"
74
+ fi
75
+ if grep -qE 'median [0-9]|budget 2000ms|pane CPU' "$out"; then
76
+ bad "premise-only 模式判了时长(输出里出现 median/budget/pane CPU)"
77
+ else
78
+ ok "没有判任何时长(输出里没有 median/budget 判定行)"
79
+ fi
80
+
81
+ result_line
82
+ [ "$FAIL" -eq 0 ] && { printf '\033[32mpanel-knobs 全绿\033[0m\n'; exit 0; }
83
+ printf '\033[31mpanel-knobs 有失败项\033[0m\n'; exit 1