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,477 @@
1
+ # Configuration and on-disk layout
2
+
3
+ ## 1. Config discovery order
4
+
5
+ The `team` CLI:
6
+
7
+ 1. `--config <file>` / the environment variable `TEAM_CONFIG_FILE`
8
+ 2. `.pi/team/config.sh` under `--root <dir>` / `TEAM_ROOT`
9
+ 3. Walk up from the current directory looking for `.pi/team/config.sh`
10
+
11
+ **Identity comes from the directory, not from the environment.** The project root is the git worktree the command
12
+ runs in (`--root <dir>` when given: that directory's worktree), the main worktree is its git common dir, and the
13
+ project name/session come from *that* project's config. Inherited `TEAM_ROOT` / `TEAM_MAIN_ROOT` / `TEAM_PROJECT` /
14
+ `TEAM_SESSION` values are never allowed to win silently: when they name **another project**, commands that change
15
+ shared state or start long-lived processes refuse to run, and read-only forms (`paths`, `--print`, `--dry-run`,
16
+ `status`, …) resolve by the directory and print the mismatch (`TEAM_ALLOW_FOREIGN_IDENTITY=1` runs anyway and
17
+ records that in `state/watchdog.log`). Sibling worktrees of the **same** project (an agent worktree with the PM's
18
+ `TEAM_ROOT` in the environment) are not a mismatch. Windows the CLI starts (PM, pulse, worker, draft) are stamped
19
+ with the *destination* directory's identity, so a long-lived process always belongs to the directory it was started
20
+ in — see [troubleshooting.md](troubleshooting.md) §18.
21
+
22
+ The notify extension (inside the agent process, **it never sources the config and never runs project code**):
23
+ walks up the same way and only parses the few flat `KEY=VALUE` entries it needs; when it finds none it falls back to
24
+ the git main worktree. `$VAR` / `${VAR}` inside values are expanded from `process.env`.
25
+
26
+ ## 2. Config keys (`.pi/team/config.sh`)
27
+
28
+ > Keys are added over time and always ship with a default, so an older config file keeps working. What changed
29
+ > between versions, and what a project set up earlier has to do about it: [migration.md](migration.md).
30
+
31
+ The config file is sourced by bash, so `$HOME` and conditional logic are allowed; but the notify extension can only
32
+ read **flat single-line assignments**, so the keys it cares about (session/pm-window/worktrees/docs/notify) should stay
33
+ literals or simple `$VAR`.
34
+
35
+ ### Identity / roster
36
+
37
+ | Key | Default | Purpose |
38
+ |---|---|---|
39
+ | `TEAM_PROJECT` | the main worktree's directory name | display name |
40
+ | `TEAM_SESSION` | `$TEAM_PROJECT` | tmux session (shared by the PM and every agent) |
41
+ | `TEAM_PM_WINDOW` | `pm` | the window the PM session lives in; notifications are typed there |
42
+ | `TEAM_AGENTS` | empty (`init` sets `dev verify`) | roster, space separated; grows only through `team add-agent <a> --register` and shrinks only through `team teardown --agent <a> --register` (both audited; a bare `team add-agent <a>` refuses a seat the roster does not carry and names both routes) |
43
+ | `TEAM_AGENT_MODELS` | empty | per-agent model override: `dev=deepseek/deepseek-flash verify=xai/grok-4.6` |
44
+ | `TEAM_DEFAULT_MODEL` | `deepseek/deepseek-flash` | default model (`provider/model`) |
45
+
46
+ Dispatch model resolution order: `--model` > `TEAM_AGENT_MODELS` (per-agent) > `TEAM_DEFAULT_MODEL`. The roster's recorded `model` is display-only ("what ran last time"); `team roster` and `team ps` tag it with its source label (current config / explicit `--model` / stale record whose config changed since — the CLI prints these labels in Chinese). It never feeds resolution, so editing the config takes effect on the very next dispatch. |
47
+ | `TEAM_MODEL_LIMITS` | `kimi-coding/k3=2` | concurrency limits, `provider/model=N` space separated; `0` = unlimited |
48
+ | `TEAM_EXTRA_PI_ARGS` | empty | extra arguments passed to pi (space separated, values with spaces are unsupported) |
49
+
50
+ ### Workflow
51
+
52
+ | Key | Default | Purpose |
53
+ |---|---|---|
54
+ | `TEAM_GATES` | auto-detected by `init` | verification gate command (e.g. `pnpm verify`) |
55
+ | `TEAM_PI_BIN` | `pi` | pi executable (give an absolute path when it is not on PATH; often used in self-tests) |
56
+ | `TEAM_INSTALL_CMD` | empty | install command run after creating a worktree (e.g. `pnpm install --frozen-lockfile`) |
57
+ | `TEAM_DOCS_DIR` | `docs/team` | directory for briefs/reports/reviews/threads/inbox |
58
+ | `TEAM_WORKTREES_DIR` | `.worktrees` | long-lived worktree directory (also how "this is an agent session" is recognised) |
59
+ | `TEAM_PROTECTED_BRANCH` | `main` | the branch only the PM may advance |
60
+ | `TEAM_REMOTE` | `origin` | remote name (present even in local mode, used when pushing branches) |
61
+ | `TEAM_PI_AGENT_DIR` | the directory of `TEAM_PI_SETTINGS_FILE` | where Pi keeps `sessions/` and its model catalog — the only place the session-size guard and the model windows are read from (read-only: `stat` of the session file, the catalog files) |
62
+ | `TEAM_MODEL_WINDOWS` | empty | explicit context windows, `provider/model=272000` space separated (also accepts a bare model name); wins over Pi's catalog and covers providers Pi does not know |
63
+ | `TEAM_SESSION_WARN_TOKENS` | `200000` | conservative threshold used when the selected model's window cannot be resolved (the message says so instead of guessing) |
64
+ | `TEAM_DISPATCH_VERIFY_SEC` | `8` | how long a dispatch waits for the pane's launch proof before it kills the window and retries |
65
+ | `TEAM_DISPATCH_ALIVE_SEC` | `1` | after the launch proof, how long to observe whether the agent is still in the window (built-in Pi only; `0` = skip the observation). A subsequent exit is reported as a warning, never as a failed dispatch |
66
+ | `TEAM_SQUASH_LOOKBACK` | `200` | how many commits on the protected branch are scanned when deciding "this branch was already squash-merged" (one tree comparison per agent row; a heuristic, see workflows.md) |
67
+
68
+ ### agent adapter (the internal seam (frozen); leave all four empty for the built-in Pi behaviour)
69
+
70
+ The four keys are an **internal seam (frozen)**: the built-in Pi paths are rendered by the same engine, the seam
71
+ is reserved for a possible future non-Pi adapter, and teamsmith makes **no compatibility promise** about it — it is
72
+ not a public extension point, and the new-project questionnaire never asks about it. The keys stay writable and
73
+ validated so the seam can be maintained; the contract, the placeholder semantics and the worked codex/opencode
74
+ examples (seam documentation, not a support offer) are in [agent-adapters.md](agent-adapters.md).
75
+
76
+ | Key | Default | Purpose |
77
+ |---|---|---|
78
+ | `TEAM_AGENT_CMD` | empty | launch template for the agent CLI; empty = the built-in Pi command. Placeholders: `{cwd}` `{session_id}` `{model}` `{provider}` `{prompt_file}` `{prompt}` `{skill_dir}` `{notify_ext}` `{extra_args}`; an unknown **or malformed** placeholder (`{ cwd }`/`{{cwd}}`…) makes `dispatch` fail with the supported list; a whitespace-only or multi-line template is refused as well (the first word must be a bare executable name) |
79
+ | `TEAM_AGENT_NOTIFY_CMD` | empty | template for the worker's end-of-turn notification to the PM (`{summary_file}` `{summary}` `{agent}` `{cwd}` `{session_id}` `{model}` `{provider}` `{skill_dir}`); empty = the Pi notify extension. **The summary is data**: the worker writes it into `{summary_file}` and then runs the rendered fixed command unchanged (recommended: `… notify pm --from {agent} --from-file {summary_file}` — the sender is stated explicitly, because a runtime directory that names no seat is refused, never recorded as `pm`; so is a call from the main worktree that carries a roster seat clue — see `agent-adapters.md` §4); `{summary}` is kept for compatibility only and renders as "a read of that file", never as interpolated text. An unusable template only warns, and the prompt section is replaced by "put it in the report" |
80
+ | `TEAM_AGENT_LOG_GLOB` | empty | activity source for `team monitor --activity`: the **tail** of the newest matching file (`*` `?` `**`, a leading `~`, `{agent}` = agent name); empty = Pi session files; when nothing matches it degrades to "no session" and says why |
81
+ | `TEAM_AGENT_LOG_TAIL_BYTES` | empty (=64KiB) | how many bytes of the log tail to read at most (a positive integer, hard cap 1MiB; above the cap it is clamped, a bad value falls back to the default and warns on stderr). **Note**: `team monitor` only forwards `TEAM_AGENT_LOG_GLOB` explicitly to monitor.mjs, so to use this key you must write `export TEAM_AGENT_LOG_TAIL_BYTES=…` in `.pi/team/config.sh` (or export it in the shell / pass `--log-tail-bytes` to monitor.mjs) — a plain assignment never reaches the child process |
82
+ | `TEAM_AGENT_BIN` | empty | executable used for the window PATH readiness wait / existence checks / `doctor`; empty = the first word of `TEAM_AGENT_CMD`, otherwise `TEAM_PI_BIN` |
83
+
84
+ > The internal seam (frozen) in full — the contract (what teamsmith owns vs. what the adapter owns), the placeholder
85
+ > semantics, the worked codex and opencode examples, a verification checklist and the intentionally unsupported list:
86
+ > see [agent-adapters.md](agent-adapters.md).
87
+
88
+ ### forge
89
+
90
+ | Key | Default | Purpose |
91
+ |---|---|---|
92
+ | `TEAM_VCS` | auto-detected | `local` / `github` / `gitlab` |
93
+ | `TEAM_TOKEN_FILE` | `.gh-pat` | github: PAT file (at the main worktree root, chmod 600, gitignored) |
94
+ | `TEAM_GITLAB_HOST` | empty | gitlab: `https://gitlab.example.com[:port]` |
95
+ | `TEAM_GITLAB_PROJECT` | empty | gitlab: `group/sub/project` (the script URL-encodes it) |
96
+ | `TEAM_GITLAB_TOKEN_FILE` | `$HOME/.gitlab-pa-token` | gitlab: PAT file |
97
+ | `TEAM_CONFIRM_WRITES` | `1` | `1` = write operations require `--yes` (**keep it**) |
98
+
99
+ | Guard | Default | Purpose |
100
+ |---|---|---|
101
+ | the pulse only "counts pending work + wakes the PM" (it only wakes when there is work); starting, stopping and resuming agents is the PM's job (`team resume`) |
102
+ | `TEAM_REQUIRE_MAGIC_CONTEXT` | `1` | `1` = magic-context (PM memory) is a hard dependency: `team doctor` fails without it, `dispatch` warns (never blocks). `0` downgrades it to a warning |
103
+ | `TEAM_PI_SETTINGS_FILE` | `~/.pi/agent/settings.json` | where Pi extensions (magic-context) are detected, and where the package is resolved from (`<settings dir>/npm/node_modules/…`); overridable for tests/multi-user setups |
104
+ | `TEAM_REQUIRE_OPENSPEC` | `1` | `1` = OpenSpec (the spec layer) is a hard dependency: `doctor` fails when the CLI or the spec dir is missing, `dispatch` warns. `0` downgrades it to a warning |
105
+ | `TEAM_OPENSPEC_BIN` | `openspec` | the OpenSpec CLI to resolve (an absolute path is allowed, same pattern as `TEAM_PI_BIN`) |
106
+ | `TEAM_SPEC_DIR` | `openspec` | the project's OpenSpec root; a relative path is resolved against the main worktree |
107
+ The patrol keys were renamed `TEAM_WATCH_*` → `TEAM_PULSE_*` in v1.36.0. During the alias period (until v2.0.0)
108
+ the effective value of each is `TEAM_PULSE_<NAME>` > `TEAM_WATCH_<NAME>` > the default, and `team pulse status` /
109
+ `team doctor` name every legacy variable still in effect.
110
+
111
+ | `TEAM_PULSE_INTERVAL` | `900` | patrol period (seconds): 15 minutes by default, 300~3600 recommended. This is the beat of "look for work on a timer", not a heartbeat |
112
+ | `TEAM_PULSE_NUDGE_GAP` | `900` | the shortest interval before the same batch of pending work is reminded again (seconds) |
113
+ | `TEAM_PULSE_REBUILD_TMUX` | `0` | `0` = leave tmux alone (a missing session/window is only reported); `1` = allow rebuilding the session/PM window (self-recovery after a reboot) |
114
+ | `TEAM_PULSE_MAX_RESTARTS` | `5` | maximum automatic PM starts per hour (guards against a crash loop). Counted from `state/pm-restarts.log` (real restarts) **and** `state/pm-start-attempts.log` (every attempt), so a start loop that never confirms is bounded too |
115
+ | `TEAM_PULSE_WINDOW` | `pulse` | window name for the tmux backend. Alias period: a still-running legacy `watchdog` window is recognized as the backend; `team pulse restart` swaps it for the resolved name |
116
+ | `TEAM_MONITOR_REFRESH` | `3` | the console's data-refresh cadence (seconds): each cadence rebuilds the cached blocks once — it is a redraw period, not a polling loop, and the effective value is visible as `panel.refresh_s` in `--json`. **The default changed from `5` to `3` with the console (pulse-console B3)** — the 3-second cadence plus the <1%-of-one-core red line is the performance contract. `--print`/`--json` never tick |
117
+ | `TEAM_MONITOR_ACTIVITY` | `1` | `1` = the activity column is part of the layout (only windows running in this session, read as a bounded tail); `0` = the pre-v1.38.0 layout without it. **The default changed from `0` to `1` in v1.38.0** — this is the one default the panel rewrite moved. `--activity` / `--no-activity` still override the key in both directions |
118
+ | `TEAM_MONITOR_EVENTS` | `4` | how many recent session events the activity column starts with per agent |
119
+ | `TEAM_MONITOR_UI` | `auto` | which renderer to use: `auto` = the TUI when stdout is a terminal and plain text otherwise; `tui` forces the TUI renderer even when stdout is redirected; `text` forces the plain-text frame (no escape sequences, no screen clear) |
120
+ | `TEAM_JS_BIN` | empty | absolute path to the JavaScript runtime the panel bundle runs on; empty = `node` > `bun` > `tsx` on `PATH`. The runtime is resolved in one place and reported by `team paths` (`js_runner`) |
121
+ | `TEAM_REQUIRE_JS` | `1` | `1` = a JS runtime is a hard dependency like magic-context and OpenSpec: `team doctor` fails when none of `node`/`bun`/`tsx` resolves or the version is below the panel bundle's floor (`node` 20 or `bun` 1.3). `0` downgrades that **doctor row only** to a warning — the panel itself still needs a runtime, and `team monitor` fails loudly in every mode without one |
122
+
123
+ `team monitor` itself has four output modes and two geometry overrides:
124
+
125
+ ```
126
+ team monitor # TUI in a terminal; plain text when stdout is not a TTY
127
+ team monitor --once # one frame through the same renderer selection, plus the due tick
128
+ team monitor --print # exactly one plain-text frame: 0 escape bytes, no state writes, no tick
129
+ team monitor --json # one JSON object {"panel": …, "activity": …}: same guarantees as --print
130
+ team monitor --width N --height N # override the geometry (the layout/degradation contract is checkable headlessly)
131
+ ```
132
+
133
+ `--print` and `--json` are the observers: they never tick and never write into `TEAM_STATE_DIR`. `--once` and the
134
+ long-running TUI keep today's tick semantics (one patrol tick per `TEAM_PULSE_INTERVAL`; `--no-pulse`, alias
135
+ `--no-watchdog`, keeps the panel and stops the ticks). A missing runtime is a loud failure in every mode, never an
136
+ empty panel reported as success.
137
+
138
+ | `TEAM_PM_MODEL` | empty | the PM's own model; empty = `TEAM_DEFAULT_MODEL` |
139
+ | `TEAM_PM_SESSION_ID` | empty | empty = `pi -c` (continue the previous session in this directory, keeping the PM's history). Explicit session id for a CLI whose session concept you control (`{session_id}` in `TEAM_PM_CMD`); on the built-in Pi path it still becomes `--session-id <id>` |
140
+ | `TEAM_PM_EXTRA_PI_ARGS` | empty | extra pi arguments for the PM (`{extra_args}` in a `TEAM_PM_CMD` template) |
141
+ | `TEAM_PM_CMD` | empty | **launch template for the PM's own CLI** (the PM side of the adapter, M8.1). Placeholders: `{cwd}` `{session_id}` `{model}` `{provider}` `{prompt_file}` `{prompt}` `{skill_dir}` `{extra_args}` `{resume_args}`. Empty = the built-in Pi command, byte-for-byte the pre-M8.1 behaviour; the rules (unknown/malformed placeholder, blank or multi-line template) are shared with `TEAM_AGENT_CMD` and fail loudly. See [agent-adapters.md](agent-adapters.md) §2. A start that fails leaves a diagnosis (window output, the rendered command, the CLI's exit code) in `state/pm-launch-failed.log`, and `team up` exits non-zero |
142
+ | `TEAM_PM_BIN` | empty | executable used for the PM's start-time existence check and its liveness identity check; empty = the first word of `TEAM_PM_CMD`, else `TEAM_PI_BIN`. The name does not have to be `pi` (a wrapper that `exec`s the real CLI is covered by the spawn proof). A **bare** first word is resolved on the *caller's* `PATH` and the rendered command uses the absolute path it resolved to — the window runs under `bash -lc`, whose `PATH` does not have your interactive rc-file additions |
143
+ | `TEAM_PM_RESUME_ARGS` | empty | arguments that continue the PM's previous session when `team up`/the pulse restarts it (`{resume_args}`). Built-in Pi path: empty = the historical `-c`; a value replaces it. Custom CLI: empty = **no continuity** (the restart starts fresh, and `team up` says so and points at `docs/team/**` + `team inbox`); a value is only used if the template contains `{resume_args}` |
144
+ | `TEAM_PM_START_WAIT` | `6` | seconds to wait for the PM to come up after starting it — the pid is recorded in `state/pm.pid` only once the configured agent binary is really running in that window. The start-in-flight marker `state/pm.pid.starting` stays fresh for this value **+ 5s**, and while it is fresh no tick starts a second PM over the one that is coming up |
145
+ | `TEAM_REPLACE_FOREIGN_PM` | `0` | `1` = allow `team up` to overwrite a process in the PM window whose cwd is **outside** this project (a non-PM process with an in-project cwd is always replaceable — it is reported as `unknown:<cmd>`) |
146
+
147
+ ### Guards (capacity)
148
+
149
+ | Key | Default | Purpose |
150
+ |---|---|---|
151
+ | `TEAM_MIN_FREE_SWAP_MB` | `1024` | **floor**: below this much free swap the dispatch is refused (a full swap gets processes killed by the OOM killer) |
152
+ | `TEAM_MIN_TOTAL_MB` | `512` | the absolute RAM+swap floor |
153
+ | `TEAM_TMP_MIN_FREE_MB` | `1024` | **floor**: below this much free space the dispatch is refused — judged on the filesystems a worker writes to (the temp root `${TMPDIR:-/tmp}` **and** the worktree filesystem). Derivation: one gate round's root measured 95 MB / 11,797 files, a killed `config-cli` root 99 MB / 10,954 files, so 1 GiB leaves ~10 gate rounds of headroom |
154
+ | `TEAM_TMP_MIN_FREE_INODES` | `100000` | **floor**: the same filesystems' free inodes (judged only where the filesystem reports an inode table). Derivation: the same 10,954-file roots → ~9 roots of headroom; the tmpfs died with 4,645 of 3,811,434 inodes free |
155
+ | `TEAM_WARN_AVAIL_MB` | `2048` | below this much available RAM: warn only (slowness is acceptable), never refuse |
156
+ | `TEAM_AGENT_MEM_MB` | `6144` | empirical footprint of one agent, used by `team ps` for its "how many more fit" estimate |
157
+ | `TEAM_NOTIFY_TMUX` | `1` | `0` = write the inbox only, never type into the PM window |
158
+ | `TEAM_NOTIFY_DEDUP_SEC` | `20` | deduplication window (seconds); `0` = no deduplication |
159
+ | `TEAM_INBOX_MAX_CHARS` | `150` | truncation length of the agent's last message inside a briefing |
160
+ | `TEAM_NOTIFY_LOG` | `/tmp/<project>-teamsmith-notify.log` | extension debug log (look here when notifications misbehave) |
161
+ | `TEAM_DEFER_TTL` | `300` | delivery guard: seconds a queued message may wait before it is moved to `state/outbox/held/` (holding never types anything; the payload is already in the recipient's inbox). A backstop, not the first symptom: an untrusted geometry holds immediately and three trusted-empty drains with no progress hold as `queue-stalled` |
162
+ | `TEAM_OUTBOX_MAX` | `200` | delivery guard: maximum active queue entries; beyond it the oldest entry is escalated to `held/` |
163
+
164
+ ### Deferred delivery (`delivery-guard`)
165
+
166
+ Automatic senders never type into an input box that already holds a draft: the message is queued in
167
+ `state/outbox/` (one immutable file per message) and delivered when the box is free. A message deferred behind a
168
+ **trusted** non-empty box is reported as `queued` (exit 0). Two outcomes are instead `held` with a machine reason
169
+ and a non-zero exit: `geometry-untrusted` (the supported Pi layout cannot be established — no key is sent and no
170
+ draft is asserted) and `queue-stalled` (three consecutive eligible drains read a trusted empty box but made no
171
+ progress; observations are recorded per entry in `state/outbox/diagnostics/`). Both keep the immutable entry and
172
+ its durable inbox copy; `team outbox list` names the reason and the recovery command, and the obstacles are also
173
+ counted on the `team status` / `team digest` outbox line and in the panel. The escape hatches are explicit:
174
+ `team say <agent> "…" --now` and `team outbox flush --now` type immediately **even into a non-empty box** and append
175
+ one audit line to `state/outbox/forced.log`; `team outbox drop <n|all>` discards entries; `team draft pm`
176
+ (`state/draft-pm.md`) is the human entry point. See `references/troubleshooting.md` §3 for the detector's known edges.
177
+
178
+ ### Branch model (D1)
179
+
180
+ | Key | Default | Purpose |
181
+ |---|---|---|
182
+ | `TEAM_VCS` | `local` | `local`\|`github`\|`gitlab`\|`other` (`other` = the project's own forge, see the next two lines) |
183
+
184
+ > The branch-model keys below are only a **naming convention** (the skill never creates or switches branches;
185
+ > `dispatch` merely uses them to print hints).
186
+
187
+ | `TEAM_BRANCH_MODE` | `task` | `task` = one branch per task (`task/<ID>-<slug>`; the unit of verification/merge/rollback is the task) | `agent` = one long-lived branch per agent |
188
+ | `TEAM_TASK_BRANCH_PREFIX` | `task` | task branch prefix |
189
+ | `TEAM_TASK_BRANCH_RESET` | `1` | `close` prints the exact `git -C <worktree> switch --detach <protected>` command for a worktree still sitting on that task's branch (the CLI never runs git); `0` = say nothing about the reset |
190
+ | `TEAM_AGENT_BRANCH_PREFIX` | `agent` | prefix used in `agent` mode |
191
+
192
+ ## 3. On-disk layout inside a project
193
+
194
+ ```
195
+ <project root>/
196
+ ├── .pi/team/
197
+ │ ├── config.sh # configuration (committed, shared by the team)
198
+ │ ├── forbidden-names.txt # ledger-ban list: other-project names that may not appear in the committed
199
+ │ │ # ledger, one per line (gitignored; this repository's PM maintains it by hand —
200
+ │ │ # the gate reads it, `init` does not create it; see protocol.md §9b-3)
201
+ │ └── state/ # runtime state (gitignored): <agent>.env (the durable record),
202
+ │ # pm.pid (pid of the PM this tool started: the liveness proof),
203
+ │ # notify-dedup, prompt-<agent>-<ID>.md (the prompt of this dispatch;
204
+ │ # {prompt_file} points at it), patrol (watchdog.*)/capacity logs,
205
+ │ # draft.md (the console's compose draft),
206
+ │ # panel.conf (the console's preferences) and
207
+ │ # panel-page (the page it last showed)
208
+ ├── AGENTS.md # carries the <!-- teamsmith:begin --> protocol section (written/refreshed by init)
209
+ ├── .worktrees/
210
+ │ ├── <agent>/ # each agent's long-lived worktree (branch agent/<name>)
211
+ │ └── review-<ID>/ # detached worktree for PM verification (safe to delete at any time)
212
+ └── <docs>/ # docs/team by default
213
+ ├── PROTOCOL.md # protocol summary (for humans and agents)
214
+ ├── BOARD.md # task board (the status column is maintained by team board / task / merge / close)
215
+ ├── ROADMAP.md # milestones and exit criteria
216
+ ├── OWNERSHIP.md # directory ownership + roster
217
+ ├── DECISIONS.md # decision log (reasons/impact)
218
+ ├── tasks/<ID>-<slug>.md
219
+ ├── reports/<ID>-<agent>.md
220
+ ├── reviews/<ID>.md + <ID>-verify.log # verification records (the log is gitignored)
221
+ ├── reviews/<ID>-done.md # append-only audit of every `done` transition
222
+ │ # (which evidence was checked / why it was forced)
223
+ ├── threads/<agent>.md # append-only message thread
224
+ └── inbox/<agent>.md # automatic briefings (gitignored)
225
+ ```
226
+
227
+ `.gitignore` entries appended by `init`:
228
+
229
+ ```
230
+ .pi/team/state/
231
+ <docs>/inbox/
232
+ <docs>/reviews/*.log
233
+ .worktrees/
234
+ ```
235
+
236
+ ### What is durable in `state/` and what is derived (read-only commands never mutate the record)
237
+
238
+ `state/<agent>.env` is the **durable record** of an agent: `task`, `taskfile`, `branch`, `worktree`, `model`,
239
+ `window`, `started`, `inbox_lines`. Only the commands that really change the team write it (`dispatch`, `resume`,
240
+ `add-agent`, `close`, `teardown`, `inbox --ack`).
241
+
242
+ Liveness is **not** stored for agents: whether an agent is running — and therefore which model-concurrency slot it
243
+ holds — is derived from tmux (`has-window`) at query time. A crashed window therefore frees its slot while the record
244
+ stays, and the read-only commands (`roster`, `status`, `ps`, `digest`, `inbox`, `paths`, `pulse status`) write
245
+ nothing at all. This is a tested invariant (smoke: state hash before/after), not a convention: an earlier version
246
+ had the model counter call `team_state_clear` for dead windows, so a single `team ps` deleted a crashed agent's
247
+ `task`/`branch` — after which `digest` reported "nothing to do" and `team resume` had nothing to resume.
248
+
249
+ The PM is the one exception, and only because a guess about it was proven to lie (M6.5): the start path
250
+ (`team up` / the pulse) records the pid of the agent process it launched in `state/pm.pid`, and liveness means
251
+ "that pid is alive **and** its cwd is inside this project". The file is written by the start path only
252
+ (`team_pm_start`); the read-only commands read it and never remove a stale entry (a dead pid simply fails the
253
+ check). Without it, a freshly created, still-empty pane was reported as `running:tmux`.
254
+
255
+ `state/draft.md` is the console's compose draft (pulse-console B2): written only by the panel process while a
256
+ human types in the input line, restored by the next `m`, and cleared once a send lands (delivered, queued or
257
+ held). A missing file means an empty draft — the next compose starts blank. `--print`/`--json` never read it,
258
+ and no command other than `team monitor`'s TUI writes it.
259
+
260
+ `state/panel.conf` and `state/panel-page` are the console's runtime preferences (pulse-console B3). The
261
+ overlay (`,`) edits exactly five: `lang` (`zh`/`en`), `page` (the default page, 1–4), `activity` (the activity
262
+ column for TUI sessions), `mouse` and `density` (`comfortable`/`compact`); a sixth key, `theme`
263
+ (`dark`/`light`/`auto`), pins the palette and is not an overlay item. The file is read **by the TUI only**:
264
+ `--print`/`--json` never look at it, so the machine exits stay byte-stable under any preference. A missing,
265
+ unreadable or corrupt file falls back to the defaults (zh, page 1, activity and mouse on, comfortable,
266
+ auto), and unknown keys are ignored. `panel-page` is one number in `1`–`4` — the page the human last showed,
267
+ restored on the next start (the `page` preference is the fallback when it is absent, and a value outside
268
+ `1`–`4` falls back to it too, never an error). Neither file is the project
269
+ contract — `.pi/team/config.sh` keeps that role, and nothing moves between the two.
270
+
271
+ ### The console's data blocks (`team __panel-data`)
272
+
273
+ The console reads every screen from one internal, read-only command: `team __panel-data --block <name>`
274
+ (one child process per block, each with its own timeout; a failed block renders as `—` and never takes the
275
+ others down). The block names are a closed set — `frame`, `pm`, `pending`, `outbox`, `capacity`, `agents`,
276
+ `recent`, `activity`, `board`, `changes`, `specs`, `decisions`, `outbox_list`, `inbox`, `patrol`, `health`
277
+ and `detail` — and `--events <n>` sizes the activity tail. `--print`/`--json` assemble the machine blocks only
278
+ (the console-only readers, including `detail` and `settings`, are never spawned there).
279
+
280
+ `--block detail --id <ID> [--file <path>]` is the read-only markdown detail view's reader (P18/B3). It
281
+ discovers, by entry id with the literal boundary `-`/`.` after the id (`P1` never matches `P17`):
282
+ `docs/team/tasks/<ID>-*.md` (tab `brief`), `docs/team/reports/<ID>-*.md` — files only, a report package
283
+ directory does not match — (tab `report:<agent>`) and `docs/team/reviews/<ID>.md` plus
284
+ `docs/team/reviews/<ID>-*.md` (tabs `review` / `review:<suffix>`), and returns that list plus the text of the
285
+ first file. `--file` serves one of those discovered paths only: anything else (a path outside the set, a
286
+ `..` traversal, another entry's file) exits non-zero and prints no content, so the console is never an
287
+ arbitrary file reader. Text is capped at 128 KiB (`TEAM_PANEL_DETAIL_CAP` overrides the cap) with a
288
+ `truncated` marker per file, and the block is requested only while the detail view is open: a parked
289
+ console spawns no `detail` child at all.
290
+
291
+ `--block settings` is the project-settings view's reader (P22/B2): its payload is exactly `team config list
292
+ --json` (the contract's schema, its effect classes, each key's functional `group`, the per-seat models and the
293
+ audit tail). Like `detail` it is
294
+ requested only while the view is open — a parked console spawns no `settings` child and `--print`/`--json` never
295
+ see it.
296
+
297
+ ## 4. Environment variables (usable without writing them into the config)
298
+
299
+ | Variable | Purpose |
300
+ |---|---|
301
+ | `TEAM_ROOT` | explicitly name the project root (locates the project; the **identity** itself still comes from the runtime directory — an inherited value naming another project is reported and refused, §1) |
302
+ | `TEAM_ALLOW_FOREIGN_IDENTITY` | `1` = run anyway when the inherited identity names another project; the run is recorded in `state/watchdog.log` |
303
+ | `TEAM_CONFIG_FILE` | explicitly name the config file (same as `team --config`) |
304
+ | `TEAM_MIN_AVAIL_MB` | `1024` | **hard line**: the `MemAvailable` floor (the CEP machine sets 4096, the lesson of two OOMs) |
305
+ | `TEAM_MIN_FREE_SWAP_MB` | `1024` | **hard line**: the free **disk swap** floor (**zram excluded**) |
306
+ | `TEAM_ZRAM_WARN_PCT` | `85` | above this zram usage, warn only |
307
+ | `TEAM_MERGE_PREFER_THEIRS` | empty | paths that default to the branch side on a `merge` conflict (comma separated, e.g. `pnpm-lock.yaml`) |
308
+ | `TEAM_REVIEW_TIMEOUT` | `1800` | hard timeout for the gates `team review` runs (seconds); a verdict of `TIMEOUT` needs **both** the `timeout` wrapper's exit code (124/137) **and** an elapsed time within `TEAM_REVIEW_TIMEOUT_GRACE` of the deadline — a gate that exits 124 by itself, or one killed by a signal, is recorded as `FAIL` (with the signal named), never as a timeout; log text never decides |
309
+ | `TEAM_REVIEW_TIMEOUT_GRACE` | `2` | slack (seconds) around `TEAM_REVIEW_TIMEOUT` when deciding whether the wrapper really hit the deadline |
310
+ | `TEAM_REVIEW_ALLOW_DIRTY` | `0` | `1` = review a checkout with uncommitted changes anyway (the only override that works); the verification record then states `checkout dirty: N files (override …)` + the file list |
311
+ | `TEAM_REVIEW_ALLOW_IGNORED` | `0` | `1` = review a checkout that contains `.gitignore`d artefacts (invisible to `git status --porcelain`, yet readable by the gates); the record lists them |
312
+ | `TEAM_REVIEW_ALLOW_UNRESOLVED_BRANCH` | `0` | `1` = stamp a review for a `--branch`/revision that does not resolve in the main worktree (deleted branch, external commit); the record says `branch-unresolved (override)` |
313
+ | `TEAM_REVIEW_ANY_DIR` | `0` | `1` = skip the “checkout HEAD == branch tip” guard when deliberately reviewing a historical revision (pair it with `--branch <sha>`) |
314
+ | `TEAM_MIN_FREE_SWAP_MB` | temporarily override the disk swap floor |
315
+ | `TEAM_MEMINFO_FILE` | point at another meminfo file (for containers/tests without `/proc/meminfo`) |
316
+ | `TEAM_DISK_STATS_FILE` | the disk-reading fixture (`TEAM_MEMINFO_FILE`'s sibling): rows `path<TAB>total_kb<TAB>avail_kb<TAB>itotal<TAB>ifree`, longest matching path prefix wins; a path with no row reads as unreadable — tests only |
317
+ | `TMPDIR` | the temp root every fixture's root resolves to (`${TMPDIR:-/tmp}`); `TMPDIR=D bash tests/config-cli.sh` is the shape of the temp-root flip, and no fixture template may hardcode `/tmp` |
318
+
319
+ Environment-only temp-root knobs are deliberately **not** part of the config surface (no schema row, not writable into
320
+ `.pi/team/config.sh`): they live in `references/protocol.md` §9b-2 and `references/troubleshooting.md` §25 —
321
+ TEAM_TMP_KEEP (1 = keep the fixture's temp root and print its path) and TEAM_TMP_SWEEP_AGE (minutes, default 30).
322
+ `TEAM_TMP_MIN_FREE_MB` and `TEAM_TMP_MIN_FREE_INODES` **left** that list (P144): they are the dispatch floor's
323
+ thresholds now, so they are schema rows (class `apply`, group `delivery`) whose `0` goes through
324
+ `team config set … --allow-danger` and the audit line — see the Guards (capacity) table above and §5.
325
+ | `TEAM_MODEL_LIMITS` | temporarily loosen/tighten concurrency (`""` means unlimited) |
326
+ | `TEAM_ASSUME_YES` | `1` = skip `--yes` (only recommended inside automation scripts) |
327
+ | `TEAM_BOARD_DONE_FORCE` | `1` = PM override for the `done` gate: write `done` even though neither a usable review record nor a merged branch exists (`close --status done` has the `--force` flag for the same thing) |
328
+ | `TEAM_BOARD_DONE_REASON` | the reason recorded in `<docs>/reviews/<ID>-done.md` when `TEAM_BOARD_DONE_FORCE=1`; required, otherwise the override is refused |
329
+ | `NO_COLOR` | turn colours off |
330
+
331
+ ## 5. `team config` — the contract's read/write surface
332
+
333
+ `team config` and the roster's two authorized entries (`team add-agent … --register`, `team teardown … --register`) are the only commands that write `.pi/team/config.sh` (`team init` / `team bootstrap` write through
334
+ the same bottom-level function). It exists so a setting can change without hand-editing the file and without a
335
+ second source of truth: the value lives in the contract, the class table lives in the command
336
+ (`scripts/lib/cmd-config.sh`), the console's labels live in its string tables.
337
+
338
+ ### Effect classes (who reads the value, and when)
339
+
340
+ | class | meaning | examples |
341
+ |---|---|---|
342
+ | `apply` | the next process that reads the contract sees the new value | `TEAM_GATES`, the capacity floors, the review escape hatches, the patrol policy |
343
+ | `restart` | a running process holds the value it started with; the receipt names the target and the command | the pulse (`TEAM_PULSE_INTERVAL`, `TEAM_MONITOR_REFRESH`), a seat's model (`TEAM_AGENT_MODELS`, `TEAM_PM_MODEL` — a running seat keeps its model until its next `dispatch`/`resume`), a live session (`TEAM_INBOX_WATCH_*`) |
344
+ | `refuse` | not the console's to change: the project's identity, the roster, the ledger's layout, the branch/forge definitions, the authority guards, the dependency policy and the machine paths Pi's own state is read from — the console may not widen its own authority and may not move the ledger it is reading | `TEAM_PROJECT`, `TEAM_AGENTS` (route: `team add-agent <a> --register` / `team teardown --agent <a> --register`), `TEAM_STATE_DIR`, `TEAM_PROTECTED_BRANCH`, `TEAM_ALLOW_FOREIGN_IDENTITY` … |
345
+
346
+ A key the schema does not know is listed read-only ("not a known project setting", pointing at this file) and is
347
+ never written.
348
+
349
+ ### The schema's tenth column (`group`) — the functional domain
350
+
351
+ Every schema row carries a **tenth** `|`-separated field, the key's functional domain: a closed ASCII token
352
+ matching `^[a-z][a-z0-9-]*$`. It is the row's own data (like `class`, `kind`, `default` and `suggest`) — **not**
353
+ parsed from the `# ---- … ----` section comments, which stay documentation: a comment must never be able to move
354
+ a row between headings. The fields are positional, so the ninth column (`suggest`) is written empty for a row
355
+ that has no suggestions when the group follows; a row whose tenth field is missing or malformed is a schema
356
+ defect, and `tests/config-cli.sh`'s `groups` section names the key and fails — the read never invents a default
357
+ group or hides the row (the console shows such a row under its visible ungrouped fallback heading,
358
+ `settingsGroupUngrouped` in the string tables).
359
+
360
+ The vocabulary is exactly these twelve tokens; the visible heading is the table entry `group_<token>` in
361
+ **both** languages (the zh and en tables are the only place a heading's words live):
362
+
363
+ | token | domain | example keys |
364
+ |---|---|---|
365
+ | `identity` | identity and ledger layout | `TEAM_PROJECT`, `TEAM_DOCS_DIR` |
366
+ | `branch` | branch semantics and forge | `TEAM_BRANCH_MODE`, `TEAM_GITLAB_HOST` |
367
+ | `policy` | permission and dependency policy | `TEAM_ALLOW_FOREIGN_IDENTITY`, `TEAM_REQUIRE_JS` |
368
+ | `roster` | roster, model resolution and adapters | `TEAM_AGENT_CMD`, `TEAM_AGENT_BIN`, `TEAM_MODEL_LIMITS` |
369
+ | `seat-model` | per-seat models | `TEAM_DEFAULT_MODEL`, `TEAM_AGENT_MODELS`, `TEAM_PM_MODEL` |
370
+ | `workflow` | workflow and gates | `TEAM_GATES`, `TEAM_REVIEW_TIMEOUT` |
371
+ | `delivery` | capacity and delivery notices | `TEAM_MIN_AVAIL_MB`, `TEAM_TMP_MIN_FREE_MB`, `TEAM_DEFER_TTL` |
372
+ | `panel` | pulse and console | `TEAM_PULSE_INTERVAL`, `TEAM_MONITOR_REFRESH` |
373
+ | `patrol` | patrol policy | `TEAM_PULSE_NUDGE_GAP`, `TEAM_PULSE_MAX_RESTARTS` |
374
+ | `pm-lifecycle` | PM lifecycle | `TEAM_PM_CMD`, `TEAM_PM_RESUME_ARGS` |
375
+ | `session` | live sessions | the `TEAM_INBOX_WATCH_*` family |
376
+ | `meeting` | cross-project meetings | `TEAM_MEETING_TTL_HOURS`, `TEAM_MEETING_KNOCK` |
377
+
378
+ The token is the **only** declaration of the vocabulary: `team config list --json` reports each key record's
379
+ `group` verbatim (empty string for a key the file carries and the schema does not know), the console looks its
380
+ heading up by the token (`group_<token>`, falling back to the raw token when the table has none), and
381
+ `tests/panel-strings.mjs` asserts the two sets equal **in both directions** — a token no row uses has no label
382
+ (stale label) and a row's token without a label is a missing label. A key added to the schema therefore lands
383
+ under its domain with the committed console bundle, and no group list exists anywhere else.
384
+
385
+ ### The written form
386
+
387
+ * `KEY='value'` — a sourced value is data: no expansion, no command substitution, no globbing. Values a child
388
+ process reads from the **environment** are written `export KEY='value'` (`form=export`: `TEAM_MONITOR_ACTIVITY`,
389
+ `TEAM_AGENT_LOG_TAIL_BYTES`, the `TEAM_INBOX_WATCH_*` family, `TEAM_BG_LOG_MAX_BYTES`); a plain assignment
390
+ never reaches a running process (the measured `TEAM_MONITOR_ACTIVITY` case).
391
+ * A `'` inside the value is written `'\''`. A line break or a `#` is refused (the notify extension's flat reader
392
+ cuts at ` #`). On the eight keys that reader parses — `TEAM_SESSION`, `TEAM_PM_WINDOW`, `TEAM_WORKTREES_DIR`,
393
+ `TEAM_DOCS_DIR`, `TEAM_NOTIFY_TMUX`, `TEAM_NOTIFY_DEDUP_SEC`, `TEAM_INBOX_MAX_CHARS`, `TEAM_NOTIFY_LOG` — a `'`
394
+ is refused too (that reader has no escape).
395
+ * Every byte the write does not change survives: comments, blank lines, the order of the keys and the changed
396
+ line's own inline comment. A key the file lacks is appended on a line of its own (a missing final newline is
397
+ added first). The write is atomic: a temp file in the contract's directory → `bash -n` → a mode-preserving
398
+ `mv`; any failure leaves the original bytes and removes the temp file.
399
+
400
+ ### The danger list
401
+
402
+ A **valid** value that disables a shipped guard or makes a shipped loop spin needs the explicit
403
+ `--allow-danger`: the capacity floors at `0` (`TEAM_MIN_FREE_SWAP_MB`, `TEAM_MIN_TOTAL_MB`, `TEAM_MIN_AVAIL_MB`,
404
+ `TEAM_WARN_AVAIL_MB`, `TEAM_TMP_MIN_FREE_MB`, `TEAM_TMP_MIN_FREE_INODES`), `TEAM_PULSE_INTERVAL` below 60, `TEAM_REVIEW_TIMEOUT` below 60,
405
+ `TEAM_PULSE_MAX_RESTARTS=0`, `TEAM_DEFER_TTL=0`, `TEAM_OUTBOX_MAX=0`, `TEAM_SQUASH_LOOKBACK=0`, the
406
+ `TEAM_REVIEW_ALLOW_*` / `TEAM_REVIEW_ANY_DIR` overrides at `1`, `TEAM_BOARD_DONE_FORCE=1`, a non-empty
407
+ `TEAM_MEETING_ALLOW_USER_ID`, and a `TEAM_PULSE_WINDOW` change while a pulse backend still runs under the old
408
+ name. Danger never makes an invalid value legal.
409
+
410
+ ### The commands and their exit codes
411
+
412
+ <!-- config-examples · tests/config-cli.sh executes exactly these lines -->
413
+ ```sh
414
+ team config list --json
415
+ team config set TEAM_PULSE_NUDGE_GAP 1200 --dry-run
416
+ team config set-agent-model dev deepseek/deepseek-flash --dry-run
417
+ team config log 5
418
+ ```
419
+
420
+ `0` written/valid · `3` fingerprint conflict (nothing written) · `4` invalid value · `5` key not editable ·
421
+ `6` write error (file unchanged) · `7` dangerous (a `--dry-run` reports it too). `team config set … --fingerprint
422
+ <sha256>` is a compare-and-swap: any byte change since the read refuses it, and a write without the flag is the
423
+ caller's explicit "use the file as it is now". `team config set-agent-model <seat> <model|->` writes the pair
424
+ list (`TEAM_AGENT_MODELS`, or `TEAM_PM_MODEL` for the `pm` seat) itself — the caller never composes it — and `-`
425
+ removes the seat's override, leaving `TEAM_DEFAULT_MODEL` in force. `--actor <name>` labels the audit line (the
426
+ console passes `panel`); `--dry-run` performs every check and writes neither the contract nor an audit line.
427
+
428
+ **The roster's two authorized entries.** `TEAM_AGENTS` keeps class `refuse` — `team config set TEAM_AGENTS …`
429
+ still exits 5 and points at these entries instead. `team add-agent <a> --register` and `team teardown --agent <a>
430
+ --register` are the one read-modify-write of the roster: the value rule (each token
431
+ `[A-Za-z0-9][A-Za-z0-9._-]*`, unique, never `pm`), the same sha256 fingerprint CAS and exactly one
432
+ `result=ok actor=cli` audit line per written value. Both accept `--fingerprint <sha256>` with `team config set`'s
433
+ semantics (documented here, not printed in `team help`); a stale fingerprint exits 3 with one `result=conflict`
434
+ line and nothing written. `--register` on a seat already in the roster is a visible no-op (exit 0, no write, no
435
+ audit line); `team teardown --agent <a>` without the flag leaves the roster byte-identical (today's default).
436
+ `team add-agent <a>` for a seat outside the roster, or `team add-agent <a> --model m` without `--register`,
437
+ exits 5 naming both routes (hand-edit `.pi/team/config.sh`, or add `--register`) and touches nothing else;
438
+ `--register --model <provider/model>|-` writes the roster first and then the seat's model through the same
439
+ pairlist serializer as `set-agent-model` (`-` removes the override). Every attempt that passes argument parsing appends one line to `<state>/config.log`
440
+ (`<UTC ISO-8601> result=<ok|refused|invalid|conflict|danger-refused|write-error> actor=… key=… old='…' new='…'`,
441
+ plus `expected=`/`actual=` on a conflict); `team config log [N]` and `list --json`'s audit tail read at most the
442
+ file's last 16 KiB and print at most N lines (default 10).
443
+
444
+ ### Keys the class table above does not describe
445
+
446
+ | Key | Class | Default | Meaning |
447
+ |---|---|---|---|
448
+ | `TEAM_MEETINGS_DIR` | refuse | `~/.pi/team/meetings` | the cross-project meeting store (the ledger's layout) |
449
+ | `TEAM_MEETING_TTL_HOURS` | apply | `72` | meeting TTL (hours) |
450
+ | `TEAM_MEETING_MAX_TURNS` | apply | `20` | turns per side |
451
+ | `TEAM_MEETING_KNOCK` | apply | `0` | 1 = allow knocking on the other PM's window |
452
+ | `TEAM_MEETING_ALLOW_USER_ID` | apply | empty | non-empty = who may knock (widens permission, hence the danger flag) |
453
+ | `TEAM_ALLOW_FOREIGN_SESSION` | refuse | `0` | run anyway on a foreign tmux session (with `--yes`) |
454
+ | `TEAM_GUARD_FOREIGN_TARGET` | refuse | `1` | only type into windows of this session |
455
+ | `TEAM_ALLOW_DESTRUCTIVE_TMUX` | refuse | `0` | **retired (M67)**: it grants nothing — the gate decides by the object a call targets, and the only in-band escape is the argv token `--teamsmith-allow-destructive`. The key stays as a non-writable tombstone so old configs keep loading; `team doctor` names the residue when a running server still carries it |
456
+ | `TEAM_SMOKE_FAST` | refuse | `0` | skip the real-process smoke sections |
457
+ | `TEAM_PULSE_PENDING_BOARD` | apply | `0` | 1 = board todo/wip count as a wake-up signal |
458
+ | `TEAM_INBOX_WATCH_MAX_BYTES` | restart · export | `131072` | spool cap (bytes) |
459
+ | `TEAM_INBOX_WATCH_PREVIEW` | restart · export | `160` | wake-up message preview length |
460
+ | `TEAM_INBOX_WATCH_REPLAY_MAX` | restart · export | `20` | lines replayed after a shrink |
461
+ | `TEAM_INBOX_WATCH_SEEN_MAX` | restart · export | `512` | dedup memory |
462
+ | `TEAM_INBOX_WATCH_STALE` | restart · export | `300` | heartbeat staleness bound (seconds) |
463
+ | `TEAM_INBOX_WATCH_STALE_SEC` | restart · export | `900` | **spool line age** above which a line never wakes (it still lands in the durable inbox) — P28 |
464
+ | `TEAM_INBOX_WATCH_FORCE_FAIL` | refuse | empty | force the registration failure path (e.g. `ENOSPC`) and mark the record `forced=1` — never set it outside tests (M53) |
465
+ | `TEAM_IW_REQUIRE_WATCH` | refuse | empty | `1` = the inbox-watch gate treats an unavailable watcher premise as a **red** instead of a visible SKIP (strict mode) — M53 |
466
+ | `TEAM_INBOX_WATCH_POLL_MS` | restart · export | `5000` | `fs.watch` fallback poll (ms) |
467
+ | `TEAM_INBOX_WATCH_HEARTBEAT_MS` | restart · export | `5000` | registry heartbeat (ms) |
468
+ | `TEAM_INBOX_WATCH_TARGET` | restart · export | empty | explicit knock target |
469
+ | `TEAM_BG_LOG_MAX_BYTES` | restart · export | `524288` | background job log cap (bytes) |
470
+ | `TEAM_SIGNAL_CALLS_LOG` | refuse | empty | P159 signal gate: one line per intercepted `pkill`/`killall` call; a refusal is copied byte for byte into `<log>.forensics` before the main line is written, so it outlives the log's rotation. The window prefix pins it to `state/signal-calls.log`; fixtures may point it elsewhere |
471
+ | `TEAM_SIGNAL_REAL` | refuse | empty | P159 signal gate: the real executable the read-only pass-through forms (`--help`/`-h`/`-V`/`--version`) go to; fixtures pin their argv-recording stub here. A refusal resolves nothing, so the gate still refuses when this is unset or unresolvable |
472
+ | `TEAM_BG_STOP_GRACE` | refuse | `5` | P159 `team bg stop`: seconds to wait after the group `TERM` before escalating to `KILL` (`0` = escalate at once, no wait). A job that ignores `TERM` is reachable only through the escalation, so this is the knob that decides how long it lingers |
473
+
474
+ The tmux family's own two launch seams (its call log and its real-binary pin, TEAM_TMUX_CALLS_LOG /
475
+ TEAM_TMUX_REAL — deliberately written without the backticks the completeness walk scans) predate this rule and stay
476
+ **environment-only**: the launch prefix writes them and nothing validates them, so they are deliberately not schema
477
+ rows. The signal family above is registered (all three keys are `refuse` rows: `team config set` writes none of them).
@@ -0,0 +1,124 @@
1
+ # Cross-project meetings (meeting mode)
2
+
3
+ This is the mechanism for **normal conversation** between two projects (how an interface fits, advice, problem
4
+ reports); it is not a chat room and certainly not a command channel.
5
+
6
+ ## Boundaries (they apply to every meeting)
7
+
8
+ | Allowed | Not allowed |
9
+ |---|---|
10
+ | Discussing interfaces/contracts/fields/ordering/error codes | Telling the other side's PM or agents what to do |
11
+ | Advice + its basis (measurements/docs/trade-offs) | Making a decision on the other side's behalf |
12
+ | Reporting problems with a reproduction | Impersonating a human to issue instructions |
13
+ | Asking for information, scheduling a joint test window | Changing the other side's repository/state, merging its PRs for it |
14
+ | Each side claiming its own half | Pushing a "joint decision" as a fait accompli |
15
+
16
+ - **A meeting only produces "consensus + each side's own todos"**, never a command aimed at the other side; landing the
17
+ work always happens inside each side's own project.
18
+ - `intent` is limited to `info | question | report | proposal | request` —— **there is no `command` in the mechanism**.
19
+ - Consensus requires both sides to `agree` separately; every entry in `AGREEMENTS` records "our side lands / their side lands".
20
+ - **Workers do not attend**: cross-project traffic goes through the PM only. A worker that needs outside help writes
21
+ `BLOCKED:` in its report.
22
+ - **The user** is the only one who can give instructions across projects (`team meeting say --as-user` from a human
23
+ terminal; an agent process is refused).
24
+
25
+ ## Shared area (outside both projects)
26
+
27
+ ```
28
+ <meetings>/<slug>/ # default ~/.pi/team/meetings/<slug>/
29
+ ├── agenda.md # topics + boundaries + closure record
30
+ ├── state.env # participants / peer session / TTL / MAX_TURNS / status
31
+ ├── transcript/0001_<project>_<intent>.md # append-only turns (the only truth; written before any knock)
32
+ ├── agreements/A1.md # consensus entries (proposal + agreed-by of each side)
33
+ ├── read/<project>.seq # each side's read position (inbox counts unread from it)
34
+ └── knocks.log # knock record (one line per turn whose notice was really delivered)
35
+ ```
36
+
37
+ ## Commands
38
+
39
+ ```bash
40
+ team meeting open <slug> --with <project>[:<session>] --topic "order API integration" --ttl 72 --yes # --ttl = positive integer hours
41
+ team meeting say <slug> --intent proposal "POST /orders should take an idempotency_key (UUID, required)" [--knock]
42
+ team meeting read <slug> [--since N] [--peek] # marks what it reads by default
43
+ team meeting inbox # which meetings are waiting for my reply
44
+ team meeting list [--all]
45
+ team meeting propose <slug> "interface contract v1: fields/error codes/timeouts" --sides "ours:… / theirs:…"
46
+ team meeting agree <slug> A1 [--note "our side lands: T4.2"] # must be the other side confirming (never your own proposal)
47
+ team meeting close <slug> [--summary "conclusions and leftovers"] # read-only afterwards (the transcript freezes)
48
+ ```
49
+
50
+ The session in `--with <project>:<session>` is what **knocking** uses (to tell the other PM there is a meeting message);
51
+ a meeting can be opened without knowing it, only knocking is unavailable then (the message still lands in the shared
52
+ area, where the other side's patrol of `meeting inbox` finds it).
53
+
54
+ ## Workflow example
55
+
56
+ ```bash
57
+ # project A (initiates)
58
+ team meeting open order-api --with <peer>:<peer> --topic "order API integration" --yes
59
+ team meeting say order-api --intent proposal "POST /orders should take an idempotency_key; a repeat returns the same order number"
60
+ # → to nudge the other PM immediately (their project must allow knocking): add --knock
61
+ # (and both sides need TEAM_MEETING_KNOCK=1)
62
+
63
+ # project B (responds)
64
+ team meeting inbox # → order-api (1 new turn)
65
+ team meeting read order-api
66
+ team meeting say order-api --intent question "how long is the repeat window? is 10 minutes enough?"
67
+ team meeting say order-api --intent request "your call: 10 minutes / 24 hours" # asks for their decision, but does **not** decide for them
68
+
69
+ # forming consensus
70
+ team meeting propose order-api "window 24h; a repeat returns the same order_id" --sides "ours:api side / theirs:order side"
71
+ # the other side confirms
72
+ team meeting agree order-api A1 --note "order side lands: T5.1"
73
+ team meeting close order-api --summary "contract settled; leftover: idempotency-key format for batch submission"
74
+ ```
75
+
76
+ ## Knocking (off by default)
77
+
78
+ - `say` only **writes to disk** by default: the other PM sees it on its next `team meeting inbox` patrol.
79
+ - For something urgent, `--knock` sends one line (`[meeting:<slug>] … has a new turn`) to the other PM's window.
80
+ Preconditions: ① the global switch `TEAM_MEETING_KNOCK=1`; ② the peer session was registered at `open` time;
81
+ ③ Pi is actually running in that window.
82
+ - Knocking is the **only** allowed cross-session action, and it only announces "there is a message" — it never decides
83
+ anything for the other side.
84
+
85
+ ## When knocking fails
86
+
87
+ ```bash
88
+ team meeting peer <slug> <project>:<session> # register/update the peer session afterwards (works even if open did not have it)
89
+ team meeting knock <slug> # knock again for the last turn after registering
90
+ ```
91
+
92
+ `knock` reports five things in order: ① the `TEAM_MEETING_KNOCK` switch ② whether the peer session is registered
93
+ ③ whether that session exists in tmux ④ whether Pi is really running in the peer PM's window ⑤ whether the boundary
94
+ guard lets it through. **A failed knock does not affect the message** — it is already in the shared area.
95
+
96
+ A busy peer box does not lose the knock either: the command reports `queued` and the single-line notice waits in the
97
+ sender's `state/outbox/`. The `knocks.log` line names `[meeting:<slug>#<N>]` **when that notice is really delivered**
98
+ — immediately, or by `team outbox flush` once the box is free (the same single writer records both ways, so a queued
99
+ knock is never counted twice and a notice that is still waiting writes nothing). The receiver's staleness check
100
+ (`read/<project>.seq >= N`, only the shared area) therefore sees the same ledger entry either way.
101
+
102
+ ## Guards (at the code level)
103
+
104
+ | Guard | Behaviour |
105
+ |---|---|
106
+ | Cross-session typing refused by default | an unregistered cross-session `send-keys` is always refused; only "knocking for a registered meeting" passes (`TEAM_GUARD_FOREIGN_TARGET=1`) |
107
+ | Write first, knock second | a message can only be knocked for after it is in the transcript; a failed knock loses nothing |
108
+ | Identity cannot be forged | every turn carries `from: <project>/pm@<session>`; the receiver always treats it as a peer statement |
109
+ | Impersonating a human refused | `--as-user` needs a human terminal + `TEAM_MEETING_ALLOW_USER_ID=1`; an agent process is refused |
110
+ | Giving orders refused | anything outside the `intent` whitelist is refused; a body carrying an order marker (`[order]`/`[command]`, or the Chinese equivalents) is refused too |
111
+ | Rate limit | `MAX_TURNS` per side (default 20, taken from the meeting record; a stricter env `TEAM_MEETING_MAX_TURNS` wins) |
112
+ | Expiry | after `TTL_HOURS` the meeting is read-only; it needs `close` or `open --force` to continue. `--ttl` must be a **positive integer number of hours** (`0`, negative values and non-numeric input are refused at open time, so a meeting can never be opened as "never expires"); `--ttl` above 8760 (one year) is clamped to 8760 with a warning, and a stored `TTL_HOURS` that is missing or not a positive integer falls back to the documented default instead of granting immortality |
113
+ | Zero writes to others | the meeting path only writes the shared area; it has no write permission in the peer's repository |
114
+
115
+ ## Configuration
116
+
117
+ | Key | Default | Meaning |
118
+ |---|---|---|
119
+ | `TEAM_MEETINGS_DIR` | `~/.pi/team/meetings` | shared-area location (outside both projects, never inside one of the repositories) |
120
+ | `TEAM_MEETING_TTL_HOURS` | `72` | meeting lifetime in hours; read-only afterwards. Must be a positive integer — anything else falls back to `72` |
121
+ | `TEAM_MEETING_MAX_TURNS` | `20` | per-side turn budget (a hard limit; wins when it is stricter than the meeting record) |
122
+ | `TEAM_MEETING_KNOCK` | `0` | `1` = allow `--knock` to nudge the peer PM's window |
123
+ | `TEAM_MEETING_ALLOW_USER_ID` | empty | `1` = allow a human terminal to use `--as-user` (cross-project instructions come from the user only) |
124
+ | `TEAM_GUARD_FOREIGN_TARGET` | `1` | the global cross-session typing guard (a meeting knock is the only exception) |