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,240 @@
1
+ #!/usr/bin/env python3
2
+ """Direct pty mouse driver for the pulse console (pulse-console B3, tasks.md 6.3).
3
+
4
+ The headless sibling of `panel-b3-pty-tmux-mouse.py`: the panel itself runs on the pty (no tmux in
5
+ the middle) and the click bytes are written straight to the master. It asserts the two properties
6
+ that do not need tmux's hit testing:
7
+
8
+ * with the mouse preference on, the console emits the SGR enable sequence (`ESC[?1006h`);
9
+ * a click on the page tabs switches the page (the page file changes) — the same effect the
10
+ keyboard's `2` has.
11
+
12
+ python3 panel-b3-pty-mouse.py --js node --panel panel.js --root DIR --state-dir DIR
13
+ --team-cli STUB --out raw.bin [--click-col 12 --click-row 2] [--keys "hi"] [--expect-draft hi]
14
+
15
+ Exit: 0 assertions held, 2 the console never rendered, 3 usage/env failure.
16
+ """
17
+
18
+ import argparse
19
+ import fcntl
20
+ import os
21
+ import pty
22
+ import select
23
+ import struct
24
+ import subprocess
25
+ import sys
26
+ import termios
27
+ import time
28
+
29
+
30
+ def drain(fd, seconds, deadline=None):
31
+ end = time.time() + seconds
32
+ buf = b""
33
+ while time.time() < end:
34
+ r, _, _ = select.select([fd], [], [], 0.05)
35
+ if r:
36
+ try:
37
+ chunk = os.read(fd, 65536)
38
+ except OSError:
39
+ break
40
+ if not chunk:
41
+ break
42
+ buf += chunk
43
+ if deadline is not None and time.time() > deadline:
44
+ break
45
+ return buf
46
+
47
+
48
+ def main():
49
+ ap = argparse.ArgumentParser()
50
+ ap.add_argument("--js", required=True)
51
+ ap.add_argument("--panel", required=True)
52
+ ap.add_argument("--root", required=True)
53
+ ap.add_argument("--state-dir", required=True)
54
+ ap.add_argument("--team-cli", required=True)
55
+ ap.add_argument("--out", required=True)
56
+ ap.add_argument("--click-col", type=int, default=12)
57
+ ap.add_argument("--click-row", type=int, default=2)
58
+ ap.add_argument("--click2-col", type=int, default=0, help="a second click after --send")
59
+ ap.add_argument("--click2-row", type=int, default=0)
60
+ ap.add_argument("--keys", default="")
61
+ ap.add_argument("--expect-draft", default="")
62
+ ap.add_argument("--expect-enable", choices=["yes", "no"], default="yes")
63
+ ap.add_argument("--expect-page", default="")
64
+ ap.add_argument("--toggle-mouse-off", action="store_true",
65
+ help="open the overlay, move to the mouse row and toggle it off before clicking")
66
+ ap.add_argument("--no-click", action="store_true", help="inject only the wheel (if any), no press/release")
67
+ ap.add_argument("--wheel", choices=["down", "up", "none"], default="none")
68
+ ap.add_argument("--wheel-clicks", type=int, default=0)
69
+ ap.add_argument("--out2", default="", help="the bytes written after the wheel injection")
70
+ ap.add_argument("--send", default="", help="comma-separated key sequence before the dump (enter,esc,q,tab,up,down,left,right, or raw text)")
71
+ ap.add_argument("--send2", default="", help="second key sequence; its bytes go to --out2 after --send")
72
+ ap.add_argument("--cols", type=int, default=100)
73
+ ap.add_argument("--rows", type=int, default=30)
74
+ ap.add_argument("--wait", type=float, default=25.0)
75
+ args = ap.parse_args()
76
+
77
+ named = {
78
+ "enter": b"\r",
79
+ "esc": b"\x1b",
80
+ "tab": b"\t",
81
+ "up": b"\x1b[A",
82
+ "down": b"\x1b[B",
83
+ "right": b"\x1b[C",
84
+ "left": b"\x1b[D",
85
+ }
86
+
87
+ def send_sequence(sequence, deadline):
88
+ for token in sequence.split(","):
89
+ if not token:
90
+ continue
91
+ os.write(master, named.get(token, token.encode()))
92
+ time.sleep(0.35)
93
+ return drain(master, 1.0, deadline)
94
+
95
+ master, slave = pty.openpty()
96
+ fcntl.ioctl(slave, termios.TIOCSWINSZ, struct.pack("HHHH", args.rows, args.cols, 0, 0))
97
+ env = dict(
98
+ os.environ,
99
+ TERM="xterm-256color",
100
+ TEAM_MONITOR_UI="tui",
101
+ )
102
+ proc = subprocess.Popen(
103
+ [
104
+ args.js,
105
+ args.panel,
106
+ "--root",
107
+ args.root,
108
+ "--state-dir",
109
+ args.state_dir,
110
+ "--team-cli",
111
+ args.team_cli,
112
+ "--no-pulse",
113
+ "--interval",
114
+ "2",
115
+ ],
116
+ stdin=slave,
117
+ stdout=slave,
118
+ stderr=slave,
119
+ env=env,
120
+ close_fds=True,
121
+ )
122
+ os.close(slave)
123
+
124
+ deadline = time.time() + args.wait
125
+ boot = b""
126
+ while time.time() < deadline and b"teamsmith pulse" not in boot:
127
+ boot += drain(master, 0.3, deadline)
128
+ if b"teamsmith pulse" not in boot:
129
+ proc.kill()
130
+ os.close(master)
131
+ print("panel-b3-pty-mouse: the console never rendered", file=sys.stderr)
132
+ return 2
133
+
134
+ out = boot + drain(master, 0.5, deadline)
135
+
136
+ toggled = b""
137
+ if args.toggle_mouse_off:
138
+ # `,` opens the overlay on the language row; three Downs reach the mouse row; Enter toggles.
139
+ for key in [b",", b"\x1b[B", b"\x1b[B", b"\x1b[B", b"\r"]:
140
+ os.write(master, key)
141
+ time.sleep(0.3)
142
+ toggled = drain(master, 1.0, deadline)
143
+ out += toggled
144
+ if b"\x1b[?1006l" not in toggled:
145
+ print("panel-b3-pty-mouse: toggling the mouse off emitted no disable sequence", file=sys.stderr)
146
+ proc.terminate()
147
+ os.close(master)
148
+ return 1
149
+ if toggled.rfind(b"\x1b[?1006h") > toggled.rfind(b"\x1b[?1006l"):
150
+ print("panel-b3-pty-mouse: an enable sequence arrived after the disable", file=sys.stderr)
151
+ proc.terminate()
152
+ os.close(master)
153
+ return 1
154
+ # Close the overlay so the tab click lands on the frame again.
155
+ os.write(master, b"\x1b")
156
+ time.sleep(0.3)
157
+ out += drain(master, 0.5, deadline)
158
+
159
+ if not args.no_click:
160
+ os.write(master, f"\x1b[<0;{args.click_col};{args.click_row}M".encode())
161
+ time.sleep(0.3)
162
+ os.write(master, f"\x1b[<0;{args.click_col};{args.click_row}m".encode())
163
+ out += drain(master, 1.0, deadline)
164
+
165
+ # Everything after `--send` is the "after" segment: the wheel, the second click and `--send2`.
166
+ # `--out2` gets exactly that segment, which is how a test sees a state change without scraping
167
+ # the whole stream (the existing wheel fixtures rely on the same shape).
168
+ after = b""
169
+
170
+ if args.send:
171
+ after += send_sequence(args.send, deadline)
172
+
173
+ if args.wheel != "none" and args.wheel_clicks > 0:
174
+ button = 65 if args.wheel == "down" else 64
175
+ for _ in range(args.wheel_clicks):
176
+ os.write(master, f"\x1b[<{button};{args.click_col};{args.click_row}M".encode())
177
+ time.sleep(0.35)
178
+ after += drain(master, 1.2, deadline)
179
+
180
+ if args.keys:
181
+ for ch in args.keys:
182
+ os.write(master, ch.encode())
183
+ time.sleep(0.12)
184
+ out += drain(master, 1.0, deadline)
185
+
186
+ if args.click2_col > 0:
187
+ os.write(master, f"\x1b[<0;{args.click2_col};{args.click2_row}M".encode())
188
+ time.sleep(0.3)
189
+ os.write(master, f"\x1b[<0;{args.click2_col};{args.click2_row}m".encode())
190
+ after += drain(master, 1.0, deadline)
191
+
192
+ if args.send2:
193
+ after += send_sequence(args.send2, deadline)
194
+
195
+ out += after
196
+ if args.out2:
197
+ with open(args.out2, "wb") as dump2:
198
+ dump2.write(after)
199
+
200
+ with open(args.out, "wb") as dump:
201
+ dump.write(out)
202
+
203
+ proc.terminate()
204
+ try:
205
+ proc.wait(timeout=3)
206
+ except subprocess.TimeoutExpired:
207
+ proc.kill()
208
+ os.close(master)
209
+
210
+ enabled = b"\x1b[?1006h" in out
211
+ ok = True
212
+ if args.expect_enable == "yes" and not enabled:
213
+ print("panel-b3-pty-mouse: the console never sent the SGR enable sequence", file=sys.stderr)
214
+ ok = False
215
+ if args.expect_enable == "no" and enabled:
216
+ print("panel-b3-pty-mouse: mouse is off but the enable sequence was sent", file=sys.stderr)
217
+ ok = False
218
+ if args.expect_page:
219
+ try:
220
+ with open(os.path.join(args.state_dir, "panel-page")) as fh:
221
+ page = fh.read().strip()
222
+ except OSError:
223
+ page = ""
224
+ if page != args.expect_page:
225
+ print(f"panel-b3-pty-mouse: panel-page is {page!r}, expected {args.expect_page!r}", file=sys.stderr)
226
+ ok = False
227
+ if args.expect_draft:
228
+ try:
229
+ with open(os.path.join(args.state_dir, "draft.md")) as fh:
230
+ draft = fh.read()
231
+ except OSError:
232
+ draft = ""
233
+ if draft != args.expect_draft:
234
+ print(f"panel-b3-pty-mouse: draft is {draft!r}, expected {args.expect_draft!r}", file=sys.stderr)
235
+ ok = False
236
+ return 0 if ok else 1
237
+
238
+
239
+ if __name__ == "__main__":
240
+ sys.exit(main())
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env python3
2
+ """Full-chain mouse driver for the pulse console (pulse-console B3, tasks.md 6.3).
3
+
4
+ `tmux send-keys` cannot inject an `0x1b` byte (tmux's key layer eats it — E6's methodology note),
5
+ so the only honest way to test SGR mouse is a real-terminal pty: a python pty plays the user's
6
+ terminal, a tmux CLIENT is attached on it, and the click bytes are written to the pty master. tmux
7
+ hit-tests them and forwards SGR to the pane application, exactly as a real click would.
8
+
9
+ The script locates the click target itself from `tmux capture-pane`: it finds the row holding the
10
+ key-band hint text and the hint's column, so the click lands on the rendered target rather than on
11
+ hard-coded coordinates.
12
+
13
+ python3 panel-b3-pty-tmux-mouse.py --sock S --session S --out raw.bin \
14
+ [--pane SESSION:WINDOW] [--hint "m 写信"] [--offset 0] [--wheel down|up|none] [--rows N] [--cols N]
15
+
16
+ Exit: 0 the click was injected, 2 the hint row was never rendered (setup failure), 3 no tmux.
17
+ """
18
+
19
+ import argparse
20
+ import fcntl
21
+ import os
22
+ import pty
23
+ import select
24
+ import struct
25
+ import subprocess
26
+ import sys
27
+ import termios
28
+ import time
29
+
30
+
31
+ def tmux(sock, *args):
32
+ return subprocess.run(["tmux", "-L", sock, *args], capture_output=True, text=True).stdout
33
+
34
+
35
+ def drain(fd, seconds):
36
+ end = time.time() + seconds
37
+ buf = b""
38
+ while time.time() < end:
39
+ r, _, _ = select.select([fd], [], [], 0.05)
40
+ if r:
41
+ try:
42
+ chunk = os.read(fd, 65536)
43
+ except OSError:
44
+ break
45
+ if not chunk:
46
+ break
47
+ buf += chunk
48
+ # keep reading until the window is quiet for a moment
49
+ if buf:
50
+ end = min(end, time.time() + 0.15)
51
+ return buf
52
+
53
+
54
+ def find_hint(pane_text, hint):
55
+ for i, line in enumerate(pane_text.splitlines()):
56
+ col = line.find(hint)
57
+ if col >= 0:
58
+ return i + 1, col + 1 # 1-based row and column
59
+ return None, None
60
+
61
+
62
+ def main():
63
+ ap = argparse.ArgumentParser()
64
+ ap.add_argument("--sock", required=True)
65
+ ap.add_argument("--session", required=True)
66
+ ap.add_argument("--pane", default="")
67
+ ap.add_argument("--hint", default="m ")
68
+ ap.add_argument("--offset", type=int, default=0)
69
+ ap.add_argument("--wheel", choices=["down", "up", "none"], default="none")
70
+ ap.add_argument("--clicks", type=int, default=1)
71
+ ap.add_argument("--no-click", action="store_true", help="inject only the wheel (if any), no press/release")
72
+ ap.add_argument("--rows", type=int, default=32)
73
+ ap.add_argument("--cols", type=int, default=120)
74
+ ap.add_argument("--wait", type=float, default=25.0)
75
+ ap.add_argument("--out", required=True)
76
+ ap.add_argument("--no-client", action="store_true", help="inject on the server's own tty (not used)")
77
+ args = ap.parse_args()
78
+
79
+ target = args.pane or f"{args.session}:"
80
+ deadline = time.time() + args.wait
81
+ row = col = None
82
+ while time.time() < deadline:
83
+ text = tmux(args.sock, "capture-pane", "-p", "-t", target)
84
+ row, col = find_hint(text, args.hint)
85
+ if row is not None:
86
+ break
87
+ time.sleep(0.3)
88
+ if row is None:
89
+ print(f"panel-b3-pty-tmux-mouse: hint {args.hint!r} never rendered in {target}", file=sys.stderr)
90
+ return 2
91
+
92
+ x = col + args.offset
93
+ y = row
94
+
95
+ master, slave = pty.openpty()
96
+ # The client's terminal is ONE row taller than the pane: tmux draws its status line on the
97
+ # client's last row, so a pane of N rows maps to client rows 1..N only when the client has N+1
98
+ # rows. Without the extra row a click on the pane's last row (the key band once the footer is
99
+ # pinned there, P18/B1) lands on the status line and never reaches the pane.
100
+ fcntl.ioctl(slave, termios.TIOCSWINSZ, struct.pack("HHHH", args.rows + 1, args.cols, 0, 0))
101
+ env = dict(os.environ, TERM="xterm-256color")
102
+ client = subprocess.Popen(
103
+ ["tmux", "-L", args.sock, "attach", "-t", target],
104
+ stdin=slave,
105
+ stdout=slave,
106
+ stderr=slave,
107
+ env=env,
108
+ close_fds=True,
109
+ )
110
+ os.close(slave)
111
+ boot = drain(master, 2.0)
112
+ with open(args.out, "wb") as dump:
113
+ dump.write(boot)
114
+
115
+ for seq in [] if args.no_click else [f"\x1b[<0;{x};{y}M", f"\x1b[<0;{x};{y}m"]:
116
+ os.write(master, seq.encode())
117
+ time.sleep(0.35)
118
+ drain(master, 0.2)
119
+ if args.wheel != "none":
120
+ button = 65 if args.wheel == "down" else 64
121
+ for _ in range(args.clicks):
122
+ os.write(master, f"\x1b[<{button};{x};{y}M".encode())
123
+ time.sleep(0.35)
124
+ drain(master, 0.2)
125
+ drain(master, 0.4)
126
+
127
+ client.terminate()
128
+ try:
129
+ client.wait(timeout=3)
130
+ except subprocess.TimeoutExpired:
131
+ client.kill()
132
+ os.close(master)
133
+ print(f"clicked ({x},{y}) on {target}")
134
+ return 0
135
+
136
+
137
+ if __name__ == "__main__":
138
+ sys.exit(main())
@@ -0,0 +1,279 @@
1
+ #!/usr/bin/env bash
2
+ # A deterministic `team __panel-data` stand-in for the console-surface fixtures (pulse-console B3).
3
+ #
4
+ # bash panel-b3-stub.sh --root DIR __panel-data --block <name> [--events N] [--no-activity]
5
+ #
6
+ # Every block is fixed data with fixed ages, so the snapshot suite can pin widths × themes byte for
7
+ # byte. `--block nope` exits 2 (the closed set), and `--block health` can be made to fail with
8
+ # B3_STUB_FAIL=health for the degraded-rendering checks.
9
+ #
10
+ # Two deterministic size knobs (used by the bounded-frame flip, which needs an overview whose
11
+ # natural content is ~30 rows): B3_STUB_AGENTS=N widens the agent table, B3_STUB_RECENT=N lengthens
12
+ # the recent-events block (pass the matching `--events N` to the panel). Both default to the
13
+ # original fixture, so the pinned snapshots are untouched.
14
+ set -uo pipefail
15
+
16
+ block=""
17
+ prev=""
18
+ detail_id=""
19
+ detail_file=""
20
+ for a in "$@"; do
21
+ [ "$prev" = "--block" ] && block="$a"
22
+ [ "$prev" = "--id" ] && detail_id="$a"
23
+ [ "$prev" = "--file" ] && detail_file="$a"
24
+ prev="$a"
25
+ done
26
+
27
+ if [ -n "${B3_STUB_FAIL:-}" ] && [ "$block" = "${B3_STUB_FAIL}" ]; then
28
+ printf 'stub: degrading %s on purpose\n' "$block" >&2
29
+ exit 1
30
+ fi
31
+
32
+ # P18/B3: append every block name this stub is asked for, so a test can prove which children a
33
+ # frame really spawned (the detail reader must be absent while the view is closed).
34
+ if [ -n "${B3_STUB_SPAWN_LOG:-}" ]; then
35
+ printf '%s\n' "$block" >> "$B3_STUB_SPAWN_LOG" 2>/dev/null || true
36
+ fi
37
+
38
+ json_str() { printf '"%s"' "$(printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g')"; }
39
+ # Multiline-safe variant: the whole text is slurped first, then escaped (backslash, quote, CR,
40
+ # tab, newline — in that order, so an escape added by one step is never re-escaped by the next).
41
+ json_str_ml() {
42
+ printf '"%s"' "$(printf '%s' "$1" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/\r//g' -e 's/\t/\\t/g' -e 's/\n/\\n/g')"
43
+ }
44
+ agents_json() {
45
+ if [ "${B3_STUB_AGENTS:-2}" != "2" ]; then
46
+ # N deterministic agent rows (the tall-overview fixture); row 1 is the base fixture's running
47
+ # dev, the rest are idle fixture agents.
48
+ local n="${B3_STUB_AGENTS}" i
49
+ printf '[\n'
50
+ printf ' {"name": "dev", "state": "running", "task": "P14", "branch": "task/P14-apply-pulse-console-b3", "dirty": true, "ahead": 3, "upstream_ahead": "", "model": "deepseek/deepseek-flash", "session_tokens": 41000, "session_window": 272000, "session_text": "41k/272k"}'
51
+ for ((i = 2; i <= n; i++)); do
52
+ printf ',\n {"name": "dev%s", "state": "absent", "task": "", "branch": "-", "dirty": false, "ahead": null, "upstream_ahead": "", "model": "-", "session_tokens": 0, "session_window": 0, "session_text": "-"}' "$i"
53
+ done
54
+ printf '\n]\n'
55
+ return 0
56
+ fi
57
+ cat <<'JSON'
58
+ [
59
+ {"name": "dev", "state": "running", "task": "P14", "branch": "task/P14-apply-pulse-console-b3", "dirty": true,
60
+ "ahead": 3, "upstream_ahead": "", "model": "deepseek/deepseek-flash", "session_tokens": 41000,
61
+ "session_window": 272000, "session_text": "41k/272k"},
62
+ {"name": "verify", "state": "absent", "task": "", "branch": "-", "dirty": false,
63
+ "ahead": null, "upstream_ahead": "", "model": "-", "session_tokens": 0,
64
+ "session_window": 0, "session_text": "-"}
65
+ ]
66
+ JSON
67
+ }
68
+
69
+ recent_json() { # B3_STUB_RECENT lines, deterministic timestamps; unset = the original fixture
70
+ if [ -z "${B3_STUB_RECENT:-}" ]; then
71
+ printf '%s\n' '["10:00:01 夹具动作一", "10:00:02 夹具动作二", "10:00:03 夹具动作三"]'
72
+ return 0
73
+ fi
74
+ local n="${B3_STUB_RECENT}" i out=""
75
+ for ((i = 1; i <= n; i++)); do
76
+ # Row 1 is 10:00:01 — the base fixture's first timestamp, so the default output is unchanged.
77
+ printf -v t '%02d:%02d:%02d' 10 $((i / 60)) $((i % 60))
78
+ out="$out${out:+, }\"$t 夹具动作$i\""
79
+ done
80
+ printf '[%s]\n' "$out"
81
+ }
82
+
83
+ board_json() {
84
+ # B3_STUB_BOARD_FILE=<path>: serve that file verbatim — the board-page fixtures rewrite it between
85
+ # refreshes to prove the focus survives a reorder and falls back when the entry leaves the board.
86
+ if [ -n "${B3_STUB_BOARD_FILE:-}" ] && [ -r "${B3_STUB_BOARD_FILE}" ]; then
87
+ cat "${B3_STUB_BOARD_FILE}"
88
+ return 0
89
+ fi
90
+ if [ -z "${B3_STUB_DONE:-}" ]; then
91
+ cat <<'JSON'
92
+ {"rows": [
93
+ {"id": "P14", "title": "控制台表面:三页/设置/鼠标/i18n/响应式", "agent": "dev", "branch": "task/P14", "deps": "-", "state": "wip", "phase": "apply"},
94
+ {"id": "V14", "title": "独立复验:控制台表面", "agent": "verify", "branch": "-", "deps": "P14", "state": "todo", "phase": "verify"},
95
+ {"id": "P13", "title": "消息入口与三个动作", "agent": "dev", "branch": "task/P13", "deps": "P12", "state": "done"},
96
+ {"id": "P12", "title": "异步数据层", "agent": "dev", "branch": "task/P12", "deps": "-", "state": "done"},
97
+ {"id": "P11", "title": "提案", "agent": "dev2", "branch": "task/P11", "deps": "-", "state": "done"},
98
+ {"id": "P10", "title": "Ink 面板重写", "agent": "dev", "branch": "task/P10", "deps": "-", "state": "done"},
99
+ {"id": "P9", "title": "提案", "agent": "dev2", "branch": "task/P9", "deps": "-", "state": "done"},
100
+ {"id": "P8", "title": "pulse 改名", "agent": "dev2", "branch": "task/P8", "deps": "-", "state": "done"},
101
+ {"id": "P7", "title": "提案", "agent": "dev2", "branch": "task/P7", "deps": "-", "state": "done"},
102
+ {"id": "P6", "title": "延后投递", "agent": "dev", "branch": "task/P6", "deps": "-", "state": "done"},
103
+ {"id": "V21", "title": "阻塞夹具", "agent": "verify", "branch": "-", "deps": "-", "state": "blocked"}
104
+ ],
105
+ "counts": {"todo": 1, "wip": 1, "review": 0, "done": 7, "blocked": 1, "dropped": 0},
106
+ "total": 11,
107
+ "deliveries": [
108
+ {"id": "P13", "agent": "dev", "at": "2026-09-16T09:30:00Z"},
109
+ {"id": "P12", "agent": "dev", "at": "2026-09-16T08:00:00Z"},
110
+ {"id": "V13", "agent": "verify", "at": "2026-09-15T09:00:00Z"}
111
+ ]}
112
+ JSON
113
+ return 0
114
+ fi
115
+ # B3_STUB_DONE=N: the same head plus N generated `done` rows (newest first) and a dropped pair —
116
+ # the fixture the folded-history growth and the kanban's long-lane scroll are checked against.
117
+ local n="${B3_STUB_DONE}" i
118
+ printf '{"rows": [\n'
119
+ printf ' {"id": "P14", "title": "控制台表面", "agent": "dev", "branch": "task/P14", "deps": "-", "state": "wip", "phase": "apply"},\n'
120
+ printf ' {"id": "V14", "title": "独立复验", "agent": "verify", "branch": "-", "deps": "P14", "state": "todo", "phase": "verify"},\n'
121
+ for ((i = 1; i <= n; i++)); do
122
+ printf ' {"id": "D%02d", "title": "历史条目 %02d", "agent": "dev2", "branch": "task/D%02d", "deps": "-", "state": "done"},\n' "$i" "$i" "$i"
123
+ done
124
+ printf ' {"id": "X1", "title": "被放弃的条目", "agent": "dev2", "branch": "-", "deps": "-", "state": "dropped"},\n'
125
+ printf ' {"id": "V21", "title": "阻塞夹具", "agent": "verify", "branch": "-", "deps": "-", "state": "blocked"}\n'
126
+ printf '],\n "counts": {"todo": 1, "wip": 1, "review": 0, "done": %s, "blocked": 1, "dropped": 1},\n "total": %s,\n "deliveries": [\n {"id": "P14", "agent": "dev", "at": "2026-09-16T09:30:00Z"}\n ]}\n' "$n" "$((n + 4))"
127
+ }
128
+
129
+ changes_json() { cat <<'JSON'
130
+ {"available": true, "source": "openspec", "count": 2, "changes": [
131
+ {"id": "pulse-console", "done": 8, "total": 28, "age": "44m ago", "phase": "apply"},
132
+ {"id": "rename-watchdog", "done": 12, "total": 12, "age": "2d ago", "phase": "verify"}
133
+ ]}
134
+ JSON
135
+ }
136
+
137
+ specs_json() { cat <<'JSON'
138
+ {"available": true, "count": 12, "requirements": 45, "specs": [
139
+ {"name": "panel", "requirements": 12},
140
+ {"name": "watchdog", "requirements": 10},
141
+ {"name": "delivery-guard", "requirements": 9},
142
+ {"name": "dispatch", "requirements": 7}
143
+ ]}
144
+ JSON
145
+ }
146
+
147
+ decisions_json() { cat <<'JSON'
148
+ {"count": 40, "recent": ["D40 · 2026-09-16 · 决定 — 控制台分三批", "D39 · 2026-09-16 · 决定 — i18n 进 B3", "D38 · 2026-09-15 · 决定 — q 收起不清巡检"]}
149
+ JSON
150
+ }
151
+
152
+ outbox_list_json() { cat <<'JSON'
153
+ {"queued": 2, "held": 1, "entries": [
154
+ {"name": "1758000000000-001-pm.msg", "state": "queued", "age_s": 42, "target": "this-project:pm", "kind": "notify", "from": "dev", "reason": "", "text": "第一行\n第二行"},
155
+ {"name": "1758000001000-002-pm.msg", "state": "queued", "age_s": 7, "target": "this-project:pm", "kind": "say", "from": "verify", "reason": "", "text": "排队中的第二条"},
156
+ {"name": "1757990000000-003-pm.msg", "state": "held", "age_s": 3600, "target": "this-project:pm", "kind": "notify", "from": "dev", "reason": "draft-raced", "text": "被扣住的副本"}
157
+ ]}
158
+ JSON
159
+ }
160
+
161
+ inbox_json() { cat <<'JSON'
162
+ {"agents": [
163
+ {"agent": "dev", "inbox_new": 1, "inbox_lines": 12, "inbox_age_s": 120, "inbox_tail": "一行简报", "thread_lines": 8, "thread_age_s": 300, "thread_tail": "一条线索"},
164
+ {"agent": "verify", "inbox_new": 0, "inbox_lines": 3, "inbox_age_s": 900, "inbox_tail": "", "thread_lines": 2, "thread_age_s": 1200, "thread_tail": ""}
165
+ ]}
166
+ JSON
167
+ }
168
+
169
+ patrol_json() { cat <<'JSON'
170
+ {"count": 5, "lines": ["10:00:00Z 容量 RAM 4040MB", "10:15:00Z 待办 3:叫醒 PM", "10:30:00Z 无待办:不叫醒 PM", "10:45:00Z 待办 1:叫醒 PM", "11:00:00Z 无待办:不叫醒 PM"]}
171
+ JSON
172
+ }
173
+
174
+ # ---- the detail reader's stand-in (P18/B3): per-id discovered files, four per entry.
175
+ detail_brief() { # <id>
176
+ printf '# %s · fixture brief\n\n' "$1"
177
+ cat <<'MD'
178
+ A paragraph with **bold**, `code` and a [link](https://example.invalid/x).
179
+
180
+ - first bullet
181
+ - second bullet with enough words to wrap inside a narrow pane
182
+
183
+ > a quoted line
184
+
185
+ ```sh
186
+ echo "verbatim fence body"
187
+ ```
188
+
189
+ | id | state | note |
190
+ |:---|:------:|-----:|
191
+ | P1 | wip | short |
192
+ | P22 | done | a longer note |
193
+
194
+ ---
195
+
196
+ closing paragraph
197
+ MD
198
+ }
199
+
200
+ # The report grows with B3_STUB_DETAIL_LONG (default 40) so the detail window has rows to scroll.
201
+ detail_report() { # <id>
202
+ local i n="${B3_STUB_DETAIL_LONG:-40}"
203
+ printf '# %s · fixture report\n\n' "$1"
204
+ for ((i = 1; i <= n; i++)); do printf 'report line %02d with a few words to read\n' "$i"; done
205
+ }
206
+
207
+ # detail_json <id> <file>: every entry except the empty `Z9` has the four discovered files
208
+ # (brief/report/review/review:done), so the focused board card always opens something. `--file` must
209
+ # be one of that entry's discovered paths (anything else exits non-zero, exactly like the real
210
+ # reader). B3_STUB_DETAIL_FILE=<json> serves a whole block verbatim (the hostile/truncated fixtures).
211
+ detail_json() {
212
+ if [ -n "${B3_STUB_DETAIL_FILE:-}" ] && [ -r "${B3_STUB_DETAIL_FILE}" ]; then
213
+ cat "${B3_STUB_DETAIL_FILE}"
214
+ return 0
215
+ fi
216
+ local id="${1:-}" want="${2:-}"
217
+ if [ -z "$id" ] || [ "$id" = "Z9" ]; then
218
+ printf '{"id": %s, "count": 0, "file": "", "text": "", "truncated": false, "files": []}\n' "$(json_str "$id")"
219
+ return 0
220
+ fi
221
+ local p_brief="docs/team/tasks/$id-a.md" p_report="docs/team/reports/$id-dev.md" \
222
+ p_review="docs/team/reviews/$id.md" p_done="docs/team/reviews/$id-done.md"
223
+ local files
224
+ files="$(printf '[{"tab": "brief", "name": "%s-a.md", "path": "%s", "size": 420, "truncated": false}, {"tab": "report:dev", "name": "%s-dev.md", "path": "%s", "size": 1400, "truncated": false}, {"tab": "review", "name": "%s.md", "path": "%s", "size": 90, "truncated": false}, {"tab": "review:done", "name": "%s-done.md", "path": "%s", "size": 120, "truncated": false}]' \
225
+ "$id" "$p_brief" "$id" "$p_report" "$id" "$p_review" "$id" "$p_done")"
226
+ local file="$p_brief" text
227
+ text="$(detail_brief "$id")"
228
+ case "$want" in
229
+ ''|"$p_brief") ;;
230
+ "$p_report") file="$want"; text="$(detail_report "$id")" ;;
231
+ "$p_review") file="$want"; text="# $id · fixture review
232
+
233
+ the independent check found nothing" ;;
234
+ "$p_done") file="$want"; text="# $id · fixture review (done)
235
+
236
+ closed" ;;
237
+ *) printf 'panel-b3-stub: --file not in the discovered set: %s\n' "$want" >&2; return 1 ;;
238
+ esac
239
+ printf '{"id": %s, "count": 4, "file": %s, "text": %s, "truncated": false, "files": %s}\n' \
240
+ "$(json_str "$id")" "$(json_str "$file")" "$(json_str_ml "$text")" "$files"
241
+ }
242
+
243
+ case "$block" in
244
+ frame)
245
+ printf '%s\n' '{"project": "fixture", "timestamp": "2026-09-16T10:00:00Z", "interval": 900, "standby": {"on": false, "reason": ""}, "activity_source": ""}'
246
+ ;;
247
+ pm)
248
+ printf '%s\n' '{"state": "running", "detail": "", "evidence": "pid 12345"}'
249
+ ;;
250
+ pending)
251
+ printf '%s\n' '{"inbox": 1, "reports": 2, "todo": 1, "wip": 1, "review": 0, "blocked": 1, "stopped": 0, "total": 6, "text": "未读 1 · 待复验 2 · blocked 1"}'
252
+ ;;
253
+ outbox)
254
+ printf '%s\n' '{"queued": 2, "held": 1, "oldest_age_s": 42, "forced": 0}'
255
+ ;;
256
+ capacity)
257
+ printf '%s\n' '{"ram_avail_mb": 4040, "swap_free_mb": 31306, "agents": 5, "spark": [4000, 4010, 4020, 4030, 4040]}'
258
+ ;;
259
+ agents) agents_json ;;
260
+ recent) recent_json ;;
261
+ activity)
262
+ printf '%s\n' '[]'
263
+ ;;
264
+ board) board_json ;;
265
+ changes) changes_json ;;
266
+ specs) specs_json ;;
267
+ decisions) decisions_json ;;
268
+ outbox_list) outbox_list_json ;;
269
+ inbox) inbox_json ;;
270
+ patrol) patrol_json ;;
271
+ detail) detail_json "$detail_id" "$detail_file" ;;
272
+ health)
273
+ printf '%s\n' '{"version": "1.38.0", "doc_version": "1.38.0", "doctor": "ok", "gates": "—"}'
274
+ ;;
275
+ *)
276
+ printf 'panel-b3-stub: unknown block %s\n' "${block:-<none>}" >&2
277
+ exit 2
278
+ ;;
279
+ esac