teamsmith 0.2.0 → 0.3.0

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 (117) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +28 -0
  4. package/skills/teamsmith/SKILL.md +14 -7
  5. package/skills/teamsmith/extension/team-notify.ts +37 -6
  6. package/skills/teamsmith/extension/team.ts +438 -0
  7. package/skills/teamsmith/references/config.md +39 -6
  8. package/skills/teamsmith/references/migration.md +197 -47
  9. package/skills/teamsmith/references/protocol.md +176 -19
  10. package/skills/teamsmith/references/troubleshooting.md +124 -7
  11. package/skills/teamsmith/references/workflows.md +36 -2
  12. package/skills/teamsmith/scripts/lib/cmd-agents.sh +318 -23
  13. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +2 -2
  14. package/skills/teamsmith/scripts/lib/cmd-config.sh +349 -67
  15. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  16. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  17. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  18. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  19. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  20. package/skills/teamsmith/scripts/lib/cmd-project.sh +30 -103
  21. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  22. package/skills/teamsmith/scripts/lib/cmd-reply.sh +3 -3
  23. package/skills/teamsmith/scripts/lib/cmd-review.sh +175 -30
  24. package/skills/teamsmith/scripts/lib/cmd-status.sh +226 -17
  25. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  26. package/skills/teamsmith/scripts/lib/cmd-watch.sh +564 -46
  27. package/skills/teamsmith/scripts/lib/common.sh +773 -48
  28. package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
  29. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  30. package/skills/teamsmith/scripts/panel/panel.js +207 -207
  31. package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
  32. package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
  33. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  34. package/skills/teamsmith/scripts/panel/src/data.ts +11 -3
  35. package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
  36. package/skills/teamsmith/scripts/panel/src/main.tsx +33 -8
  37. package/skills/teamsmith/scripts/panel/src/strings/en.ts +39 -29
  38. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +41 -31
  39. package/skills/teamsmith/scripts/panel/src/types.ts +28 -3
  40. package/skills/teamsmith/scripts/replies.mjs +4 -1
  41. package/skills/teamsmith/scripts/shim/tmux +18 -0
  42. package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
  43. package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
  44. package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
  45. package/skills/teamsmith/scripts/team +19 -6
  46. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +8 -1
  47. package/skills/teamsmith/templates/config.sh.tmpl +20 -1
  48. package/skills/teamsmith/templates/pm-prompt.md.tmpl +21 -0
  49. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  50. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  51. package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
  52. package/skills/teamsmith/tests/config-cli.sh +160 -14
  53. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  54. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  55. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  56. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  57. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  58. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  59. package/skills/teamsmith/tests/flip-m37.sh +4 -1
  60. package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
  61. package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
  62. package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
  63. package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
  64. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  65. package/skills/teamsmith/tests/flip-p210.sh +4 -1
  66. package/skills/teamsmith/tests/flip-p217.sh +4 -1
  67. package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
  68. package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
  69. package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
  70. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  71. package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
  72. package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
  73. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  74. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  75. package/skills/teamsmith/tests/install-shape.sh +279 -20
  76. package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
  77. package/skills/teamsmith/tests/key-replies-ui.sh +0 -7
  78. package/skills/teamsmith/tests/key-replies.sh +240 -1
  79. package/skills/teamsmith/tests/ledger-ban.sh +5 -4
  80. package/skills/teamsmith/tests/ledger-claim.sh +2 -1
  81. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  82. package/skills/teamsmith/tests/lib/model-policy.sh +4 -0
  83. package/skills/teamsmith/tests/lib/model-routing-flips.py +51 -0
  84. package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
  85. package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
  86. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  87. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  88. package/skills/teamsmith/tests/lib/tmux-iso.sh +31 -13
  89. package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
  90. package/skills/teamsmith/tests/panel-b2.sh +106 -3
  91. package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
  92. package/skills/teamsmith/tests/panel-b3.sh +175 -19
  93. package/skills/teamsmith/tests/panel-choices.sh +11 -6
  94. package/skills/teamsmith/tests/panel-cpu.sh +2 -1
  95. package/skills/teamsmith/tests/panel-knobs.sh +7 -1
  96. package/skills/teamsmith/tests/panel-p21.sh +156 -73
  97. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  98. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  99. package/skills/teamsmith/tests/perf.sh +121 -30
  100. package/skills/teamsmith/tests/routes.sh +327 -93
  101. package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
  102. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  103. package/skills/teamsmith/tests/section-budgets.tsv +20 -10
  104. package/skills/teamsmith/tests/section-guard.sh +6 -1
  105. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  106. package/skills/teamsmith/tests/section-paths.tsv +19 -13
  107. package/skills/teamsmith/tests/section-select.sh +8 -1
  108. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  109. package/skills/teamsmith/tests/slash-team.sh +617 -0
  110. package/skills/teamsmith/tests/smoke.sh +2972 -440
  111. package/skills/teamsmith/tests/task-model-routing.sh +507 -10
  112. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  113. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  114. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  115. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  116. package/skills/teamsmith-init/SKILL.md +12 -12
  117. package/skills/teamsmith-init/references/bootstrap.md +3 -3
@@ -40,10 +40,11 @@ literals or simple `$VAR`.
40
40
  | `TEAM_SESSION` | `$TEAM_PROJECT` | tmux session (shared by the PM and every agent) |
41
41
  | `TEAM_PM_WINDOW` | `pm` | the window the PM session lives in; notifications are typed there |
42
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_TASK_MODELS` | empty (required) | the project's task-category → model map: `routine=provider/light analysis=provider/strong verify=provider/strong`. A **new** dispatch selects the model of the brief's `category:` from it; a complete same-task recovery keeps the model/SID it was already assigned, even after the category leaves the map. One category: `team config set-task-model <category> <model>`; the whole map: `team config set TEAM_TASK_MODELS '<map>' --yes`; breaking migration: `team config upgrade-models` |
43
+ | `TEAM_TASK_MODELS` | empty (required) | the project's task-category → model map: `routine=provider/light analysis=provider/strong verify=provider/strong`. A **new** dispatch selects the model of the brief's `category:` from it; a complete same-task recovery keeps the model/SID it was already assigned, even after the category leaves the map. One category: `team config set-task-model <category> <model>`; the whole map: `team config set TEAM_TASK_MODELS '<map>' --yes`; breaking migration: the next `team up` (startup transaction) or `team config upgrade-models` |
44
44
  | `TEAM_PM_MODEL` | empty (required) | the **independent PM model** — never a fallback to a task model or a worker default. `team up` guards it (a running PM with a different model needs an explicit `--fresh-pm`) |
45
+ | `TEAM_CONFIG_VERSION` | the current shape (written by the tool) | the configuration **shape number** (`refuse` class — the console never writes it). A project without the key is classified by its keys; a number higher than this tool's newest known shape is refused instead of migrated. `init`/`bootstrap` write the current number and the startup transaction writes it when it migrates an old shape |
45
46
 
46
- Categories are the project's own vocabulary (`[a-z][a-z0-9-]*`, unique): routine/analysis/verify are the initial example, not an engine list, and `phase:`/seat never selects a model automatically. The initial suggestion is `routine=opencode-go/deepseek-v4.1-flash`, `analysis`/`verify=openai-codex/gpt-6.1-sol:high`, independent PM the same strong model — examples, not defaults or a provider-availability claim. The retired keys TEAM_AGENT_MODELS / TEAM_DEFAULT_MODEL are no longer read: a project that still carries them is refused by the loader and by init/bootstrap, and migrates through the explicit `team config upgrade-models --task-models '<map>' --pm-model '<model>'` transaction (preview first, then `--yes`) — never through `team init --force`, bootstrap or an inference.
47
+ Categories are the project's own vocabulary (`[a-z][a-z0-9-]*`, unique): routine/analysis/verify are the initial example, not an engine list, and `phase:`/seat never selects a model automatically. The initial suggestion is `routine=opencode-go/deepseek-v4.1-flash`, `analysis`/`verify=openai-codex/gpt-6.1-sol:high`, independent PM the same strong model — examples, not defaults or a provider-availability claim. The retired keys TEAM_AGENT_MODELS / TEAM_DEFAULT_MODEL are no longer read: a project that still carries them is refused by the loader and by init/bootstrap, and migrates on the next `team up` (the startup transaction derives the pairs from the old keys, prints them before → after, backs the file up and writes through the same checked writer) or through the explicit `team config upgrade-models --task-models '<map>' --pm-model '<model>'` transaction (preview first, then `--yes`) — never through `team init --force`, bootstrap or an inference. The refusal advice carries one paste-ready `team config upgrade-models …` command derived from that project's own configuration, or names the obstacle when the derivation is not unambiguous.
47
48
  | `TEAM_MODEL_LIMITS` | `kimi-coding/k3=2` | concurrency limits, `provider/model=N` space separated; `0` = unlimited |
48
49
  | `TEAM_EXTRA_PI_ARGS` | empty | extra arguments passed to pi (space separated, values with spaces are unsupported) |
49
50
 
@@ -56,6 +57,7 @@ Categories are the project's own vocabulary (`[a-z][a-z0-9-]*`, unique): routine
56
57
  | `TEAM_INSTALL_CMD` | empty | install command run after creating a worktree (e.g. `pnpm install --frozen-lockfile`) |
57
58
  | `TEAM_DOCS_DIR` | `docs/team` | directory for briefs/reports/reviews/threads/inbox |
58
59
  | `TEAM_WORKTREES_DIR` | `.worktrees` | long-lived worktree directory (also how "this is an agent session" is recognised) |
60
+ | `TEAM_TMP_ROOT` | empty (resolved) | temp root for fixtures and gates. Resolution happens in exactly one place (`team_tmp_root`): a non-empty `TMPDIR` in the environment wins, then this key, then the platform default `/var/tmp/teamsmith-<project-ns>` — a filesystem, not the memory-backed `/tmp` (fixture writes must not compete with the OOM killer). The two-step order is printed, not guessed: `team status`, the dispatch capacity line and `tmp-hygiene --status` all name the value and its `source=tmpdir|config|default`, and a `TMPDIR` that overrides this key is reported as such. An explicit value that is relative, missing, not a directory or not writable blocks dispatch with the path and a remedy — it is never replaced by another root. Only the default leg is created (0700, first write); explicit roots are never created for you. Rollback to the old behaviour: `TEAM_TMP_ROOT="/tmp"` |
59
61
  | `TEAM_PROTECTED_BRANCH` | `main` | the branch only the PM may advance |
60
62
  | `TEAM_REMOTE` | `origin` | remote name (present even in local mode, used when pushing branches) |
61
63
  | `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) |
@@ -64,6 +66,7 @@ Categories are the project's own vocabulary (`[a-z][a-z0-9-]*`, unique): routine
64
66
  | `TEAM_DISPATCH_VERIFY_SEC` | `8` | how long a dispatch waits for the pane's launch proof before it kills the window and retries |
65
67
  | `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
68
  | `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) |
69
+ | `TEAM_UPDATE_CHECK` | `1` | `0` = `team up` makes no npm version lookup at all (no query, no cache read or write). `1` = at most one bounded (≤2 s) lookup per 24 h, cached in `<state>/update-check.env`; every outcome except "local is older than the published version" prints nothing and never changes `team up`'s exit code. The tool never installs itself |
67
70
 
68
71
  ### agent adapter (the internal seam (frozen); leave all four empty for the built-in Pi behaviour)
69
72
 
@@ -149,7 +152,7 @@ empty panel reported as success.
149
152
  |---|---|---|
150
153
  | `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) |
151
154
  | `TEAM_MIN_TOTAL_MB` | `512` | the absolute RAM+swap floor |
152
- | `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 |
155
+ | `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 **resolved** temp root — `TMPDIR` → `TEAM_TMP_ROOT` → `/var/tmp/teamsmith-<ns>`, named with its `source=` — **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 |
153
156
  | `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 |
154
157
  | `TEAM_WARN_AVAIL_MB` | `2048` | below this much available RAM: warn only (slowness is acceptable), never refuse |
155
158
  | `TEAM_AGENT_MEM_MB` | `6144` | empirical footprint of one agent, used by `team ps` for its "how many more fit" estimate |
@@ -157,9 +160,34 @@ empty panel reported as success.
157
160
  | `TEAM_NOTIFY_DEDUP_SEC` | `20` | deduplication window (seconds); `0` = no deduplication |
158
161
  | `TEAM_INBOX_MAX_CHARS` | `150` | truncation length of the agent's last message inside a briefing |
159
162
  | `TEAM_NOTIFY_LOG` | `/tmp/<project>-teamsmith-notify.log` | extension debug log (look here when notifications misbehave) |
163
+ | `TEAM_NOTIFY_DETAIL_MAX` | `2048` | events a turn-end notification's detail file (`state/notify.log`) may hold before it is rotated to `state/notify.log.1` (one generation kept; a rotation is named in the extension log) |
160
164
  | `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` |
161
165
  | `TEAM_OUTBOX_MAX` | `200` | delivery guard: maximum active queue entries; beyond it the oldest entry is escalated to `held/` |
162
166
 
167
+ ### Orphan seat processes (`seat-visibility`)
168
+
169
+ A seat's liveness is judged **by its window**: a process whose tmux window is gone is invisible to `team status`
170
+ and `team resume` while still holding memory (one host had seven such processes summing to ~4 GB). `team ps`,
171
+ `team status` and `team up` therefore append a **host-side census** read from `/proc` — a process is a seat when
172
+ its own environment carries teamsmith's identity (`TEAM_MAIN_ROOT`/`TEAM_ROOT`) and its command line names the
173
+ project's configured agent or PM executable. A seat is an orphan exactly when it has **no live pane**, judged on
174
+ the tmux server the process itself names; when that server cannot be queried the process is left **unjudged** and
175
+ is never called an orphan. Only this project's orphans are named (each with a copy-pasteable `team reap <pid>
176
+ --yes`); another project's orphans and identity-less processes are reported as a count and a **floor** (`≥`) only,
177
+ because the reading is meant to be copied into the ledger. The census writes nothing and signals nothing.
178
+
179
+ | Key | Default | Purpose |
180
+ |---|---|---|
181
+ | `TEAM_ORPHAN_WARN_MB` | `1024` | when the host-wide orphan total is at or above this many MB, `team digest`'s capacity line carries one hint (total, this project's share, the cleanup command). `0` = never hint (needs `--allow-danger`). It never changes the exit code |
182
+ | `TEAM_ORPHAN_SCAN` | `1` | whether the host-side census runs at all. `0` = read no process's environment: `team ps`, `team status` and `team up` print one named skip line instead of the reading, `team digest` adds no hint, and `team reap --orphans` refuses (exit 2) — cleanup then needs an explicit pid (`team reap <pid> --yes`). It exists for hosts where reading another process's environment is refused; the reading — and the cleanup plan it feeds — needs the default `1` |
183
+ | `TEAM_ORPHAN_PROC_ROOT` | `/proc` | fixture-only: the proc root the census reads, so the unreadable / vanished / empty-environment / missing-field edges can be built deterministically. Not writable from the console |
184
+
185
+ Cleanup is never automatic: `team reap --orphans` prints the plan and signals nothing, and `team reap --orphans
186
+ --yes` (or `team reap <pid> --yes`) re-verifies every target immediately before signalling it — still this
187
+ project's seat, still without a live pane, and the same process start time the plan recorded — then sends
188
+ `SIGTERM`, waits a bounded 5 s and only then `SIGKILL`. Every signal appends one line to `state/reap.log`.
189
+ `--yes` is the only authorization: no configuration key, environment variable or inherited value turns it on.
190
+
163
191
  ### Deferred delivery (`delivery-guard`)
164
192
 
165
193
  Automatic senders never type into an input box that already holds a draft: the message is queued in
@@ -313,7 +341,7 @@ see it.
313
341
  | `TEAM_MIN_FREE_SWAP_MB` | temporarily override the disk swap floor |
314
342
  | `TEAM_MEMINFO_FILE` | point at another meminfo file (for containers/tests without `/proc/meminfo`) |
315
343
  | `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 |
316
- | `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` |
344
+ | `TMPDIR` | the **first** source of the temp root (`team_tmp_root`): a non-empty value wins over `TEAM_TMP_ROOT` and the disk default `/var/tmp/teamsmith-<ns>`; `TMPDIR=D bash tests/config-cli.sh` is the shape of the temp-root flip, the override is printed as `source=tmpdir`, and no fixture template may hardcode `/tmp` |
317
345
 
318
346
  Environment-only temp-root knobs are deliberately **not** part of the config surface (no schema row, not writable into
319
347
  `.pi/team/config.sh`): they live in `references/protocol.md` §9b-2 and `references/troubleshooting.md` §25 —
@@ -389,7 +417,8 @@ under its domain with the committed console bundle, and no group list exists any
389
417
  never reaches a running process (the measured `TEAM_MONITOR_ACTIVITY` case).
390
418
  * A `'` inside the value is written `'\''`. A line break or a `#` is refused (the notify extension's flat reader
391
419
  cuts at ` #`). On the eight keys that reader parses — `TEAM_SESSION`, `TEAM_PM_WINDOW`, `TEAM_WORKTREES_DIR`,
392
- `TEAM_DOCS_DIR`, `TEAM_NOTIFY_TMUX`, `TEAM_NOTIFY_DEDUP_SEC`, `TEAM_INBOX_MAX_CHARS`, `TEAM_NOTIFY_LOG` — a `'`
420
+ `TEAM_DOCS_DIR`, `TEAM_NOTIFY_TMUX`, `TEAM_NOTIFY_DEDUP_SEC`, `TEAM_INBOX_MAX_CHARS`, `TEAM_NOTIFY_LOG`,
421
+ `TEAM_NOTIFY_DETAIL_MAX` — a `'`
393
422
  is refused too (that reader has no escape).
394
423
  * Every byte the write does not change survives: comments, blank lines, the order of the keys and the changed
395
424
  line's own inline comment. A key the file lacks is appended on a line of its own (a missing final newline is
@@ -432,7 +461,11 @@ model. `team config upgrade-models --task-models '<map>' --pm-model '<model>'` i
432
461
  transaction: it previews with `--dry-run`, writes only with `--yes`, replaces the four model keys (the two retired
433
462
  worker keys are removed, the two new keys upserted) and keeps every other byte; its relevant-line grammar
434
463
  (top-level unique literal assignments, optional inline comments) refuses export/duplicate/multiline/dynamic shapes
435
- with the file and line named, and the repair is a hand-normalized literal line. The retired `set-agent-model`
464
+ with the file and line named, and the repair is a hand-normalized literal line. The startup path calls the same
465
+ transaction (`team up`, actor `up-migration`): it derives the pairs from the old keys with the same table the
466
+ refusals use, writes `TEAM_CONFIG_VERSION`, prints every pair before → after with the backup path and the restore
467
+ command, and re-enters itself so later steps read the new bytes; `team up --print` writes nothing and `team up
468
+ --no-migrate` refuses instead of writing. The retired `set-agent-model`
436
469
  route exits 5 pointing at these; `team add-agent --model` is retired too (a seat is a name in the roster, not a
437
470
  model identity).
438
471
 
@@ -136,14 +136,18 @@ one-line reaction.
136
136
  | reports that are not committed yet no longer point at a review, and a squash-merged branch reports "already merged (squash, same content) — no push needed" | v1.22.0 | read the wording before acting: both lines exist to stop a PM from reviewing or pushing something that is already done |
137
137
  | the PM's own CLI is configurable (`TEAM_PM_CMD` / `TEAM_PM_BIN` / `TEAM_PM_RESUME_ARGS`) | M8.1 | nothing to do — all three keys are empty by default and the built-in Pi command is byte-for-byte unchanged. They belong to the internal seam (frozen): reserved for a possible future non-Pi adapter, no compatibility promise — the PM side runs Pi (`references/agent-adapters.md` §2) |
138
138
  | the console brings three state files and one changed default: `TEAM_MONITOR_REFRESH` drops `5` → `3` | v1.38.0 (pulse-console B3) | the TUI keeps its own preferences in `state/panel.conf` (`lang`, `page`, `activity`, `mouse`, `density` and an optional `theme`), remembers the last page in `state/panel-page`, and holds the PM's compose draft in `state/draft.md`. All three are runtime state: deleting them is safe and `--print`/`--json` never read them. Set `TEAM_MONITOR_REFRESH=5` to keep the old cadence (`references/config.md` lists the key) |
139
+ | the fixtures' and gates' temp root defaults to **disk** instead of the memory-backed `/tmp`: `/var/tmp/teamsmith-<ns>`, resolved by `team_tmp_root` (`TMPDIR` → `TEAM_TMP_ROOT` → default) and printed as `source=tmpdir|config|default` | v0.3.0 (tmp-root-on-disk) | nothing to migrate — the first write creates the new root (0700) and old `/tmp` residue stays where it is; `tmp-hygiene.sh --status` names the resolved root, its `source=` and the old root's leftovers, and `TMPDIR=/tmp bash skills/teamsmith/tests/tmp-hygiene.sh --sweep --dry-run` selects the old base explicitly. An explicit root (`TMPDIR` / `TEAM_TMP_ROOT`) must already exist and be writable — it is never created for you. Rollback: `TEAM_TMP_ROOT=/tmp` |
139
140
 
140
141
  ## 5b. The breaking model-policy upgrade (task categories)
141
142
 
142
- This is the one upgrade that needs an explicit transaction instead of a re-render. The retired keys
143
+ This is the one upgrade a re-render cannot do: it needs the four-key migration transaction. The retired keys
143
144
  TEAM_AGENT_MODELS and TEAM_DEFAULT_MODEL are no longer read (an old seat model is **not** reinterpreted as a task
144
145
  model): a project that still carries them is refused by `team dispatch`/`team up` and by `team init`/
145
- `team bootstrap` — before any install, ledger, worktree or pulse work — and the repair is the dedicated
146
- four-key transaction:
146
+ `team bootstrap` — before any install, ledger, worktree or pulse work. Two routes apply the same transaction: the
147
+ **startup transaction** (the next `team up` derives the pairs from the old keys, prints every pair before → after
148
+ with the backup path and the restore command, writes through the checked writer and re-enters itself) or the
149
+ **explicit transaction**. The full sequence — upgrading the tool itself, backing up the configuration and rolling
150
+ back — is §6.
147
151
 
148
152
  ```bash
149
153
  team config upgrade-models --task-models 'routine=<model> analysis=<model> verify=<model>' --pm-model '<model>' # preview: prints the diff, writes nothing
@@ -153,8 +157,19 @@ team config upgrade-models --task-models '…' --pm-model '<model>' --yes
153
157
  It rewrites only those keys through the checked writer (temp file → `bash -n` → fingerprint CAS → atomic rename →
154
158
  one audit line), turns a removed line's inline comment into a standalone one and leaves every other byte alone.
155
159
  Shapes it cannot locate unambiguously (export/multiline/variable expansion/duplicate keys) are refused with the
156
- file and line plus the manual-normalization route. `team init --force`, `bootstrap` and inference are **not**
157
- migration routes; a fresh project passes `--task-models`/`--pm-model` to `init`/`bootstrap` instead.
160
+ file and line plus the manual-normalization route. `team up --print` writes nothing (it prints the same
161
+ prediction, with the backup path it would use) and `team up --no-migrate` refuses instead of writing, naming the
162
+ manual command. `team init --force`, `bootstrap` and inference are **not** migration routes; a fresh project
163
+ passes `--task-models`/`--pm-model` to `init`/`bootstrap` instead. For the step-by-step upgrade of an existing
164
+ project, including the npm install, the configuration backup and the rollback, see §6.
165
+
166
+ **How the shape is detected.** Detection is a version table with **one row per migration** — the shape it matches
167
+ (`from`), the shape it produces (`to`), the transform it applies and the tool version that introduced it — applied
168
+ in order and idempotently; adding a migration is one table row plus one transform plus one fixture group. A
169
+ project's shape number is `TEAM_CONFIG_VERSION` (written by `init`/`bootstrap` and by every migration; a `refuse`
170
+ key — the console never writes it); a configuration **without** that key is classified by its keys (a retired key
171
+ ⇒ the pre-policy shape, otherwise the current one). A shape number **higher** than this tool's newest known one is
172
+ **refused** rather than migrated with an older row, and so is a shape the table has no row for.
158
173
 
159
174
  After the policy is in place: a **new** dispatch takes the brief's `category:` model (routine for bounded ordinary
160
175
  implementation, analysis for complex planning/judgment, verify for independent adversarial review — or the
@@ -173,55 +188,187 @@ promise is made for unknown consumers.
173
188
 
174
189
  ## 6. Upgrade recipe
175
190
 
176
- Replace `<skill checkout>` with the git checkout the installed skill points at (`team paths` prints it).
191
+ This moves a project set up with teamsmith 0.1.x onto 0.2.0 or later. §1 still holds — `docs/team/**`,
192
+ `.pi/team/state/**` and your own files keep their format, so there is no data conversion. What does move is the
193
+ **tool installation** (step 1), this project's **model policy** (step 2), the PM's **launch identity** (step 3),
194
+ the **sessions** (step 4), and the way you **prove** (step 5) and **roll back** (step 6) the result.
195
+
196
+ Run every command from the project's main checkout, and replace `<v>` with the version you are moving to (for
197
+ example `0.2.0`).
198
+
199
+ ### Step 1 — upgrade the tool itself (npm, not a checkout)
200
+
201
+ Since 0.2.0 the installed skill is a copy of the npm package `teamsmith`: `~/.agents/skills/teamsmith` is a
202
+ symlink into `$(npm root -g)/teamsmith/skills/teamsmith`. There is no checkout to `git pull`; the upgrade is the
203
+ package plus the installer that refreshes the shared links:
204
+
205
+ ```bash
206
+ npm i -g teamsmith@<v> --registry https://registry.npmjs.org
207
+ bash "$(npm root -g)/teamsmith/install.sh" # idempotent: refresh the shared skill links
208
+ team version # the version the CLI reports now
209
+ readlink -f ~/.agents/skills/teamsmith # must resolve under $(npm root -g)/teamsmith/skills/teamsmith
210
+ ```
211
+
212
+ `install.sh` is safe to re-run and installs the canonical directories only. If `readlink -f` still points at an
213
+ old checkout, this machine has a second skill source — fix that link (or re-run `install.sh` into the target you
214
+ want) before going on, or later reads will mix two versions.
215
+
216
+ ### Step 2 — per project: back up the configuration, then let the first `team up` migrate it
217
+
218
+ **Back up the configuration first.** The migration keeps its own backup, but this one is yours:
219
+
220
+ ```bash
221
+ cp .pi/team/config.sh ".pi/team/config.sh.pre-upgrade-$(date -u +%Y%m%dT%H%M%SZ)"
222
+ ```
223
+
224
+ Look before you write:
177
225
 
178
226
  ```bash
179
- # 1) get the new skill (a copy install updates by re-running ./install.sh instead)
180
- git -C <skill checkout> pull --ff-only # refuses when the checkout has diverged (local commits) — deliberate
181
-
182
- # 2) is this session still the old version?
183
- team version --check
184
- # expect two version numbers (loaded vs disk) and a hint to run /reload;
185
- # identical versions print "consistent" instead. Exit code stays 0 either way.
186
-
187
- # 3) environment self-check — fix every ✗ before going on
188
- team doctor
189
-
190
- # 4) re-render this project's contracts (idempotent: config is kept, the AGENTS.md
191
- # section is refreshed in place, and a legacy marker is rewritten to the new one).
192
- # A config still carrying the retired model keys is REFUSED here — run the explicit
193
- # migration first: team config upgrade-models --task-models '…' --pm-model '…' [--yes]
194
- team init
195
-
196
- # 5) the spec layer, only when openspec/ is missing
197
- openspec init --tools none
198
-
199
- # 6) put the spec gate into TEAM_GATES in .pi/team/config.sh
200
- # TEAM_GATES="openspec validate --all --strict && <old gates>"
201
-
202
- # 7) rebuild the pulse window and look at it (renamed from `watchdog` in v1.36.0 — §2b:
203
- # the old commands/window/variables still work; a running `watchdog` window is adopted
204
- # and `team pulse restart` swaps it for a `pulse` one)
205
- team pulse up
206
- team pulse status
207
-
208
- # 8) prove the tooling end to end in a throwaway repository (never touches this project)
209
- bash skills/teamsmith/tests/smoke.sh # full suite (tens of seconds idle, minutes on a loaded box)
210
- TEAM_SMOKE_FAST=1 bash skills/teamsmith/tests/smoke.sh # logic-only subset; each skipped section prints SKIP
227
+ team up --print
211
228
  ```
212
229
 
213
- Expected output, in order:
230
+ On a 0.1.x-shaped configuration this writes nothing and prints, in order: the migration row it matched (which
231
+ migration, from which shape to which), a **per-key before → after table**, the backup path it would use, the `cp`
232
+ command that restores it, and why the keys move. `team up --no-migrate` is the same promise from the other side:
233
+ it refuses, writes nothing, and prints the manual transaction in whichever of the two command forms below fits
234
+ your configuration — the derived command when the derivation is unambiguous, the placeholder route when it is not.
214
235
 
215
- | Step | What you should see |
236
+ Then run the real thing:
237
+
238
+ ```bash
239
+ team up
240
+ ```
241
+
242
+ `team up` now begins with a **startup transaction**. It prints the same before → after table, writes a backup
243
+ under `.pi/team/state/config-backups/config.sh.pre-<shape>-<timestamp>`, rewrites only the model keys through the
244
+ checked writer (temp file → `bash -n` → fingerprint compare-and-swap → atomic rename → one audit line in
245
+ `.pi/team/state/config.log`), prints the restore command, and re-enters itself to read the new configuration and
246
+ start the PM.
247
+
248
+ In 0.1.x terms the transaction does this:
249
+
250
+ | 0.1.x key | becomes |
216
251
  |---|---|
217
- | `version --check` | the disk version, the `SKILL.md` version and the loaded version, then either a "consistent" line or the "this session is old" line with the `/reload` hint |
218
- | `/reload` in Pi | the skill list is rebuilt; the extension sends a follow-up that makes the PM read `SKILL.md` again (text already in the conversation history does **not** change by itself) |
219
- | `doctor` | every line prefixed with a check mark; each `✗` line carries its own fix (`pi install …`, `openspec init --tools none`, `TEAM_*_BIN`, …); the summary line counts failures and warnings |
220
- | `init` | a write/refresh line per generated file — the `AGENTS.md` protocol section appears exactly once (check with `grep -c '<!-- teamsmith:begin -->' AGENTS.md`) |
221
- | `smoke` | an all-green summary (or the failure count), and in fast mode a line listing the skipped process sections |
252
+ | `TEAM_AGENT_MODELS='dev=<model> verify=<model>'` | one `TEAM_TASK_MODELS` pair per seat, with the seat name as the category |
253
+ | `TEAM_DEFAULT_MODEL='<model>'` | a `default=<model>` pair in `TEAM_TASK_MODELS` |
254
+ | `TEAM_PM_MODEL='<model>'` | the same value, re-written through the checked writer so the write is audited |
255
+ | — | `TEAM_CONFIG_VERSION='2'`, the shape number every later migration is measured against |
256
+
257
+ If it **refuses**, it names the obstacle and prints the manual transaction in one of **two command forms**. Which
258
+ one you get is a fact about *your* configuration, not a style: the tool never prints a command it cannot support.
259
+
260
+ - **A shape it can derive from** — every retired key is a top-level single-line literal, every value is a valid
261
+ `provider/model`, and no two seat names normalize onto one category. The command is **derived from your own
262
+ configuration**, with the map and the PM model already filled in
263
+ (`--task-models 'dev=vendor/light verify=vendor/strong:high default=vendor/base' --pm-model 'vendor/pm:high'`).
264
+ `team up --no-migrate` on such a configuration prints this form.
265
+ - **A shape the derivation stops on** — a value built by variable expansion or written as a multi-line literal, a
266
+ seat name that normalizes onto the fallback `default` (the fallback name collides), or a value that is not a
267
+ valid model. Here it prints the **placeholder route** instead: the command arrives with an *unfilled*
268
+ `--task-models` and `--pm-model`, each holding a bracketed placeholder written in the CLI's own language, and
269
+ *you* write the map. The refusal line above it names what stopped the derivation (for that first shape, the
270
+ file and line that is not a plain literal). A derivation that resolved some pairs before stopping still prints
271
+ them, with the bracketed placeholder standing in for the offending one — a partly filled map therefore means
272
+ "fix that one pair", not "start from scratch".
273
+
274
+ The same conditional holds wherever a refusal offers the manual transaction (a refused `team config set` or
275
+ `team dispatch` prints these two forms under its two routes). The two are distinguishable at a glance: in a
276
+ **derived** command every `--task-models` value was read from *your* file, while a **placeholder-route** command
277
+ leaves a bracketed placeholder somewhere among its arguments.
278
+
279
+ The manual route is the same transaction, run by hand:
280
+
281
+ ```bash
282
+ team config upgrade-models --task-models '<the map it printed>' --pm-model '<the model it printed>' --dry-run
283
+ team config upgrade-models --task-models '…' --pm-model '…' --yes
284
+ ```
285
+
286
+ `--dry-run` prints the diff and writes nothing; `--yes` is the one write. `team init --force`, `team bootstrap`
287
+ and inference are **not** migration routes (§5b). Confirm the new shape before going on:
288
+
289
+ ```bash
290
+ team config list # exit code 0, and no `migration_required` line at the end
291
+ ```
292
+
293
+ ### Step 3 — the PM launch identity (`state/pm-launch.env`)
294
+
295
+ `.pi/team/state/pm-launch.env` is a flat record of the identity the PM was last started with: the project and
296
+ window, the resolved model, the resume key (which Pi session it continues), the launch mode (`fresh` or
297
+ `continued`) and a nonce. It is what lets a later `team up` prove it is resuming the *same* conversation on the
298
+ *same* model, and it is deliberately not project data (§1).
299
+
300
+ A project upgraded from 0.1.x has no such record — the file did not exist then. The first `team up` after the
301
+ migration handles that for you: a missing record is read as "no claim about the past", this launch is
302
+ **registered**, and the run prints one line saying so. That line carries `model=<model>`, `resume_key=<key>` and
303
+ `mode=continued`, and reminds you that changing the PM model requires `--fresh-pm`.
304
+
305
+ Two exits exist, and they differ in what they keep:
306
+
307
+ - **Let it register (the default).** The PM continues the conversation `team_pm_continuity` resolves — `pi -c`, the
308
+ previous session for this directory, unless `TEAM_PM_SESSION_ID` or `TEAM_PM_RESUME_ARGS` say otherwise — and the
309
+ record is written from the successful launch.
310
+ - **`team up --fresh-pm`.** This one launch starts a **new** conversation: the resume arguments are dropped, the
311
+ old Pi session file is left untouched in the history, and the record is written with `mode=fresh`. Disk is the
312
+ handover — `docs/team/**` and `team digest` carry the work.
313
+
314
+ When a record **exists and disagrees** with what the configuration resolves now, `team up` refuses instead of
315
+ guessing. The refusal names `PM launch identity changed` plus the field that moved (`model`, `resume_key` or the
316
+ window), and prints two exits:
317
+
318
+ - **`team up --fresh-pm`** — start a new conversation. The Pi history is not touched.
319
+ - **`team up --adopt-pm-identity --yes`** — declare that this continued run really is the recorded identity: it
320
+ writes the record plus one audit line, and is refused while the PM is running.
321
+
322
+ **Why a changed model cannot continue the old conversation.** One conversation is pinned to one model: Pi's
323
+ session history is bound to the provider/model that produced it, so resuming that session under a different model
324
+ is not the same conversation. `--fresh-pm` is therefore the only honest way to change the PM's model;
325
+ `--adopt-pm-identity --yes` exists for the case where the *record* is stale but the resolved identity really is
326
+ what you are resuming. `team up --print` predicts all of this without writing: it prints the registration line it
327
+ would write, or the two exits when it would refuse.
328
+
329
+ ### Step 4 — sessions: bring the PM and the seats back up
330
+
331
+ ```bash
332
+ team up # the PM window in the project's own tmux session
333
+ team up --agents # also resume the seats that have unfinished tasks
334
+ team resume --dry-run # what --agents would do, without doing it
335
+ ```
336
+
337
+ Text already read into a running session does not change under it: restart each project's own agent sessions (or
338
+ `/reload` the PM in Pi) so they read the new `SKILL.md` and `references/**`. `team up` starts the PM and nothing
339
+ else; the patrol window is created by `team pulse up`, and `team pulse status` shows its state.
340
+
341
+ ### Step 5 — prove it
342
+
343
+ ```bash
344
+ team doctor # fix every ✗ before going on; each line carries its own fix
345
+ bash skills/teamsmith/tests/tmp-hygiene.sh --status # the resolved temp root, its `source=` and any old /tmp residue
346
+ team config list # the new keys, exit code 0
347
+ team dispatch --print <agent> <ID> <brief> # the brief's `category:` line resolves to the mapped model
348
+ ```
349
+
350
+ The status line also settles the one on-disk change since 0.3.0: fixture roots resolve to `/var/tmp/teamsmith-<ns>`
351
+ on disk unless `TMPDIR` or `TEAM_TMP_ROOT` says otherwise, the line prints which of the three won, and the old `/tmp`
352
+ roots are **not** migrated (`TMPDIR=/tmp bash skills/teamsmith/tests/tmp-hygiene.sh --sweep --dry-run` shows them).
353
+ `TEAM_TMP_ROOT=/tmp` is the rollback to the old behaviour.
354
+
355
+ The `dispatch --print` line is the one that proves the policy is live: it must print
356
+ `category=<the brief's category> model=<the mapped model>`. A brief with no `category:` line is refused.
357
+
358
+ ### Step 6 — roll back
359
+
360
+ ```bash
361
+ cp "<the backup path the migration printed>" .pi/team/config.sh # the configuration, byte for byte
362
+ ```
363
+
364
+ Restoring the backup puts the old shape back (and `team config list` says `migration_required` again), which is
365
+ what you want if the new policy is wrong. `--fresh-pm` needs no rollback: it never touched the Pi session
366
+ history, so the old conversation is still there to `team up` into after you restore the configuration. Nothing
367
+ else moved — `docs/team/**` and the rest of `.pi/team/state/**` were never rewritten. §7 covers pinning an older
368
+ tool version, which is the other half of a rollback.
222
369
 
223
- Do the upgrade **before** dispatching new work, and note the version in `DECISIONS.md`: a worker dispatched after the
224
- upgrade gets the new prompt template, one dispatched before does not.
370
+ Do the upgrade **before** dispatching new work, and note the version in `DECISIONS.md`: a worker dispatched after
371
+ the upgrade gets the new prompt template, one dispatched before does not.
225
372
 
226
373
  ## 7. Rolling back
227
374
 
@@ -244,6 +391,9 @@ team mark-loaded # re-record what this session sho
244
391
  git again. Pin at v1.11.0 or later unless that is exactly what you want.
245
392
  - Rollback and re-upgrade can be repeated freely; the only state the skill keeps about versions is
246
393
  `.pi/team/state/pm-loaded.env`.
394
+ - Since 0.3.0 the fixture/gate temp root lives on disk (`/var/tmp/teamsmith-<ns>`). Pinning an older tool sends it
395
+ back to `/tmp` on its own; with the new tool, `TEAM_TMP_ROOT=/tmp` restores the old behaviour. Nothing under
396
+ `/var/tmp/teamsmith-<ns>` is project data — those roots are disposable and the sweep reclaims them.
247
397
 
248
398
  ## 8. What is deliberately not supported
249
399