teamsmith 0.1.1 → 0.2.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 (104) hide show
  1. package/README.md +16 -8
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +55 -0
  4. package/skills/teamsmith/SKILL.md +18 -7
  5. package/skills/teamsmith/extension/team-bg.ts +47 -11
  6. package/skills/teamsmith/extension/team-notify.ts +143 -4
  7. package/skills/teamsmith/references/agent-adapters.md +7 -7
  8. package/skills/teamsmith/references/config.md +29 -15
  9. package/skills/teamsmith/references/migration.md +38 -2
  10. package/skills/teamsmith/references/openspec.md +23 -9
  11. package/skills/teamsmith/references/protocol.md +81 -13
  12. package/skills/teamsmith/references/workflows.md +31 -19
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
  16. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  17. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  18. package/skills/teamsmith/scripts/lib/cmd-project.sh +134 -17
  19. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  20. package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
  21. package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
  22. package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
  23. package/skills/teamsmith/scripts/lib/common.sh +797 -71
  24. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  25. package/skills/teamsmith/scripts/panel/README.md +22 -11
  26. package/skills/teamsmith/scripts/panel/panel.js +217 -215
  27. package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
  28. package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
  29. package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
  30. package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
  31. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  32. package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
  33. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
  34. package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
  35. package/skills/teamsmith/scripts/replies.mjs +893 -0
  36. package/skills/teamsmith/scripts/team +1 -0
  37. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
  38. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  39. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  40. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  41. package/skills/teamsmith/templates/config.sh.tmpl +10 -5
  42. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  43. package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -1
  44. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  45. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  46. package/skills/teamsmith/tests/bg-ledger-harness.mjs +682 -0
  47. package/skills/teamsmith/tests/bg-ledger.sh +307 -0
  48. package/skills/teamsmith/tests/checkout-shape-probe.sh +287 -58
  49. package/skills/teamsmith/tests/config-cli.sh +162 -288
  50. package/skills/teamsmith/tests/death-cause.sh +5 -2
  51. package/skills/teamsmith/tests/install-shape.sh +4 -2
  52. package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
  53. package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
  54. package/skills/teamsmith/tests/key-replies.sh +1075 -0
  55. package/skills/teamsmith/tests/ledger-ban.sh +5 -5
  56. package/skills/teamsmith/tests/ledger-claim.sh +247 -0
  57. package/skills/teamsmith/tests/lib/checkout-shape.sh +66 -14
  58. package/skills/teamsmith/tests/lib/model-policy.sh +26 -0
  59. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  60. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  61. package/skills/teamsmith/tests/lib/model-routing-flips.py +136 -0
  62. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  63. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  64. package/skills/teamsmith/tests/lib/reply-fixture.sh +372 -0
  65. package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
  66. package/skills/teamsmith/tests/panel-b2.sh +1 -1
  67. package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
  68. package/skills/teamsmith/tests/panel-b3.sh +14 -10
  69. package/skills/teamsmith/tests/panel-choices.sh +74 -61
  70. package/skills/teamsmith/tests/panel-cpu.sh +1 -1
  71. package/skills/teamsmith/tests/panel-p21.sh +311 -190
  72. package/skills/teamsmith/tests/perf.sh +1 -1
  73. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  74. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  75. package/skills/teamsmith/tests/routes.sh +43 -22
  76. package/skills/teamsmith/tests/section-budgets.tsv +9 -5
  77. package/skills/teamsmith/tests/section-paths.tsv +26 -16
  78. package/skills/teamsmith/tests/section-select.sh +99 -16
  79. package/skills/teamsmith/tests/smoke.sh +930 -216
  80. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  81. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  82. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  83. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  84. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  85. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  86. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  87. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  88. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  89. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  90. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  91. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  92. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  93. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  94. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  95. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  96. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  97. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  98. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  99. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  100. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  101. package/skills/teamsmith/tests/task-model-routing.sh +1014 -0
  102. package/skills/teamsmith-init/SKILL.md +38 -38
  103. package/skills/teamsmith-init/references/bootstrap.md +6 -4
  104. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -40,10 +40,10 @@ 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_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`) |
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` |
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
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. |
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
47
  | `TEAM_MODEL_LIMITS` | `kimi-coding/k3=2` | concurrency limits, `provider/model=N` space separated; `0` = unlimited |
48
48
  | `TEAM_EXTRA_PI_ARGS` | empty | extra arguments passed to pi (space separated, values with spaces are unsupported) |
49
49
 
@@ -135,7 +135,6 @@ long-running TUI keep today's tick semantics (one patrol tick per `TEAM_PULSE_IN
135
135
  `--no-watchdog`, keeps the panel and stops the ticks). A missing runtime is a loud failure in every mode, never an
136
136
  empty panel reported as success.
137
137
 
138
- | `TEAM_PM_MODEL` | empty | the PM's own model; empty = `TEAM_DEFAULT_MODEL` |
139
138
  | `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
139
  | `TEAM_PM_EXTRA_PI_ARGS` | empty | extra pi arguments for the PM (`{extra_args}` in a `TEAM_PM_CMD` template) |
141
140
  | `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 |
@@ -340,7 +339,7 @@ second source of truth: the value lives in the contract, the class table lives i
340
339
  | class | meaning | examples |
341
340
  |---|---|---|
342
341
  | `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_*`) |
342
+ | `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`), the PM's model (`TEAM_PM_MODEL` — a running PM keeps it until an explicit `--fresh-pm` restart), a live session (`TEAM_INBOX_WATCH_*`) |
344
343
  | `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
344
 
346
345
  A key the schema does not know is listed read-only ("not a known project setting", pointing at this file) and is
@@ -366,7 +365,7 @@ The vocabulary is exactly these twelve tokens; the visible heading is the table
366
365
  | `branch` | branch semantics and forge | `TEAM_BRANCH_MODE`, `TEAM_GITLAB_HOST` |
367
366
  | `policy` | permission and dependency policy | `TEAM_ALLOW_FOREIGN_IDENTITY`, `TEAM_REQUIRE_JS` |
368
367
  | `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` |
368
+ | `task-model` | task category policy and the independent PM model | `TEAM_TASK_MODELS`, `TEAM_PM_MODEL` |
370
369
  | `workflow` | workflow and gates | `TEAM_GATES`, `TEAM_REVIEW_TIMEOUT` |
371
370
  | `delivery` | capacity and delivery notices | `TEAM_MIN_AVAIL_MB`, `TEAM_TMP_MIN_FREE_MB`, `TEAM_DEFER_TTL` |
372
371
  | `panel` | pulse and console | `TEAM_PULSE_INTERVAL`, `TEAM_MONITOR_REFRESH` |
@@ -413,17 +412,33 @@ name. Danger never makes an invalid value legal.
413
412
  ```sh
414
413
  team config list --json
415
414
  team config set TEAM_PULSE_NUDGE_GAP 1200 --dry-run
416
- team config set-agent-model dev deepseek/deepseek-flash --dry-run
415
+ team config set-task-model routine deepseek/deepseek-flash --dry-run
416
+ team config set TEAM_PM_MODEL deepseek/deepseek-flash --dry-run
417
+ team config upgrade-models --task-models 'routine=deepseek/deepseek-flash analysis=xai/grok-4.6' --pm-model deepseek/deepseek-flash --dry-run
417
418
  team config log 5
418
419
  ```
419
420
 
420
421
  `0` written/valid · `3` fingerprint conflict (nothing written) · `4` invalid value · `5` key not editable ·
421
422
  `6` write error (file unchanged) · `7` dangerous (a `--dry-run` reports it too). `team config set … --fingerprint
422
423
  <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.
424
+ caller's explicit "use the file as it is now".
425
+
426
+ **The three model front doors.** `team config set-task-model <category> <model>` upserts exactly one category in
427
+ TEAM_TASK_MODELS (through the same checked writer, so category values are validated and the rest of the map is
428
+ preserved byte for byte); a new category is legal, an empty map is not, and removing a category is done by setting
429
+ the whole map (`team config set TEAM_TASK_MODELS '<remaining map>' --yes`) — which limits future selection but does
430
+ not invalidate a complete same-task assignment. `team config set TEAM_PM_MODEL <model>` writes the independent PM
431
+ model. `team config upgrade-models --task-models '<map>' --pm-model '<model>'` is the one **breaking migration**
432
+ transaction: it previews with `--dry-run`, writes only with `--yes`, replaces the four model keys (the two retired
433
+ worker keys are removed, the two new keys upserted) and keeps every other byte; its relevant-line grammar
434
+ (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`
436
+ route exits 5 pointing at these; `team add-agent --model` is retired too (a seat is a name in the roster, not a
437
+ model identity).
438
+
439
+ `team task --category` is only the **brief generator**: it writes the brief's `category:` header and nothing else —
440
+ it never selects or overrides a dispatch's model, and `team task` takes no model flag. The header is read by
441
+ `team dispatch` (which resolves it through the map), and only `team dispatch --model` overrides one launch.
427
442
 
428
443
  **The roster's two authorized entries.** `TEAM_AGENTS` keeps class `refuse` — `team config set TEAM_AGENTS …`
429
444
  still exits 5 and points at these entries instead. `team add-agent <a> --register` and `team teardown --agent <a>
@@ -433,10 +448,9 @@ still exits 5 and points at these entries instead. `team add-agent <a> --registe
433
448
  semantics (documented here, not printed in `team help`); a stale fingerprint exits 3 with one `result=conflict`
434
449
  line and nothing written. `--register` on a seat already in the roster is a visible no-op (exit 0, no write, no
435
450
  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`
451
+ `team add-agent <a>` for a seat outside the roster exits 5 naming both routes (hand-edit `.pi/team/config.sh`, or
452
+ add `--register`) and touches nothing else; the retired `--model` flag is refused with a pointer at the task-
453
+ category writers. Every attempt that passes argument parsing appends one line to `<state>/config.log`
440
454
  (`<UTC ISO-8601> result=<ok|refused|invalid|conflict|danger-refused|write-error> actor=… key=… old='…' new='…'`,
441
455
  plus `expected=`/`actual=` on a conflict); `team config log [N]` and `list --json`'s audit tail read at most the
442
456
  file's last 16 KiB and print at most N lines (default 10).
@@ -14,7 +14,7 @@ session) and for anyone deciding whether upgrading is safe.
14
14
  | Surface | Why it does not move |
15
15
  |---|---|
16
16
  | the `team` CLI | sub-commands are only ever **removed**, never renamed in place; everything that still exists keeps its name and flags |
17
- | `.pi/team/config.sh` | sourced by bash, flat `TEAM_*` keys; new keys ship with a default, so a config written years ago keeps working |
17
+ | `.pi/team/config.sh` | sourced by bash, flat `TEAM_*` keys; new keys ship with a default, so a config written years ago keeps working (the one exception is the breaking model-policy upgrade — §5b) |
18
18
  | `TEAM_*` environment variables | override the config file (env beats config) and are read that way in every version |
19
19
  | the `docs/team/**` layout | `tasks/ reports/ reviews/ threads/ inbox/` plus `BOARD.md ROADMAP.md OWNERSHIP.md DECISIONS.md PROTOCOL.md` |
20
20
  | `docs/team/BOARD.md` columns | `ID · task · agent · branch · deps · status`, with the status vocabulary `todo/wip/review/done/blocked/dropped` |
@@ -137,6 +137,40 @@ one-line reaction.
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
139
 
140
+ ## 5b. The breaking model-policy upgrade (task categories)
141
+
142
+ This is the one upgrade that needs an explicit transaction instead of a re-render. The retired keys
143
+ TEAM_AGENT_MODELS and TEAM_DEFAULT_MODEL are no longer read (an old seat model is **not** reinterpreted as a task
144
+ 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:
147
+
148
+ ```bash
149
+ team config upgrade-models --task-models 'routine=<model> analysis=<model> verify=<model>' --pm-model '<model>' # preview: prints the diff, writes nothing
150
+ team config upgrade-models --task-models '…' --pm-model '<model>' --yes # the one write
151
+ ```
152
+
153
+ It rewrites only those keys through the checked writer (temp file → `bash -n` → fingerprint CAS → atomic rename →
154
+ one audit line), turns a removed line's inline comment into a standalone one and leaves every other byte alone.
155
+ 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.
158
+
159
+ After the policy is in place: a **new** dispatch takes the brief's `category:` model (routine for bounded ordinary
160
+ implementation, analysis for complex planning/judgment, verify for independent adversarial review — or the
161
+ project's own names), while a running/completed assignment keeps its recorded model/SID and is never rewritten by
162
+ the upgrade; a brief must carry a `category:` header before it can be dispatched again; the PM's own model is
163
+ `TEAM_PM_MODEL`, and a running PM on a different model is continued only with `team up --fresh-pm`.
164
+
165
+ The operations around a source upgrade are **separate recorded gates**, each previewed and authorized per command:
166
+ private source verification; landing validated source on a shared/protected tree; writing this project's
167
+ configuration (and the first fresh launch that reads it); and adopting a changed shared skill source. A shared
168
+ skill link (e.g. `~/.agents/skills/teamsmith` → this checkout's `skills/teamsmith`) reads its target's **current**
169
+ bytes, so changing that target affects later reads in other projects even without an installer; before landing,
170
+ either isolate the known shared consumers to preserved stable source and verify the isolation, or obtain explicit
171
+ approval of the identified shared impact. No partial slice should land on a shared main, and no zero-impact
172
+ promise is made for unknown consumers.
173
+
140
174
  ## 6. Upgrade recipe
141
175
 
142
176
  Replace `<skill checkout>` with the git checkout the installed skill points at (`team paths` prints it).
@@ -154,7 +188,9 @@ team version --check
154
188
  team doctor
155
189
 
156
190
  # 4) re-render this project's contracts (idempotent: config is kept, the AGENTS.md
157
- # section is refreshed in place, and a legacy marker is rewritten to the new one)
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]
158
194
  team init
159
195
 
160
196
  # 5) the spec layer, only when openspec/ is missing
@@ -14,7 +14,8 @@ CLI reference, `validate` output). Those live where they are generated and maint
14
14
  ## 0. Where the authoritative OpenSpec documentation is
15
15
 
16
16
  - **The phase commands themselves** — `.pi/prompts/opsx-*.md` and `.pi/skills/openspec-*/SKILL.md`, generated for
17
- this project's agent tool (`openspec init --tools pi`). That is what an agent actually follows. They describe the
17
+ this project's agent tool (`openspec init --tools pi`; §6 states exactly which of the five phases the installed
18
+ OpenSpec actually generates). That is what an agent actually follows. They describe the
18
19
  *mechanics* of a phase (how to explore, how to write the artifacts); **who may invoke a phase, and behind which
19
20
  gate, is teamsmith's rule, not theirs** — see §1, §2 and §4.
20
21
  - **The artifact instructions** — `openspec instructions <artifact>` (proposal / specs / design / tasks / apply /
@@ -184,14 +185,27 @@ tip.
184
185
 
185
186
  ## 6. Preconditions
186
187
 
187
- - The phase commands must be generated for the agents' tool: `openspec init --tools pi` writes
188
- `.pi/prompts/opsx-*.md` and `.pi/skills/openspec-*/SKILL.md` (use the tool's own id for a non-Pi CLI). Once a
189
- project has them, `openspec update` refreshes them; it finds the configured tools from the generated files and
190
- answers "No configured tools found" when there are none. Commit the generated files with the project.
191
- - Without them, a phase cannot be invoked **as a command**: an agent can still do the same steps by hand from
192
- OpenSpec's own docs, but then the PM cannot check that the phase really ran its workflow, the planning-only
193
- boundary of propose is only a convention, and the numbered phases in a brief point at nothing. Prefer generating
194
- and committing them.
188
+ - Generate what the installed OpenSpec can generate: `openspec init --tools pi` writes the command and skill files
189
+ for the workflows of the active profile (use the tool's own id for a non-Pi CLI). With the version this project
190
+ pins — **1.8.0, whose only profile is `core`** (`openspec config list` prints
191
+ `workflows: propose, explore, apply, update, sync, archive (from core profile)`) — that is
192
+ `opsx-{explore,propose,apply,archive}` plus the helper commands `opsx-update`/`opsx-sync`, and the matching
193
+ skills `openspec-{explore,propose,apply-change,archive-change}` plus `openspec-sync-specs`/`openspec-update-change`.
194
+ **It does not generate the verify pair** (`opsx-verify.md`,
195
+ `openspec-verify-change/SKILL.md`): 1.8.0 has no `verify` workflow, and the `expanded` profile this guide used to
196
+ name does not exist (`openspec config profile expanded` → `Error: Unknown profile preset "expanded". Available
197
+ presets: core`). Once a project has generated files, `openspec update` refreshes them; it finds the configured
198
+ tools from those files and answers "No configured tools found" when there are none.
199
+ - **A phase whose command is missing is not a phase that did not run.** The verify phase is owned by this guide, not
200
+ by a generated file: run it from §1 and §5 — a different agent than the implementer, the change + the landed code
201
+ + the report as its hand-in, `docs/team/reviews/<ID>.md` as its hand-out. If you want a command for it, write the
202
+ prompt yourself and say it is yours; do not record a hand-written prompt as generated. What teamsmith gates on is
203
+ the **artifact** (the review record); the command file is only checked where the checkout carries one (a checkout
204
+ without the machine-generated surface gets a named skip, never a red — P222).
205
+ - Whether the generated files are committed follows the project's own ignore rules. This repository ignores `.pi/**`
206
+ (`.gitignore`): the files are per-machine, every clone and every CI checkout starts without them, and the gate
207
+ reports the `.pi/prompts` / `.pi/skills` checks as named skips there. A project that does commit them gets those
208
+ checks on every checkout, which is strictly more coverage.
195
209
  - Resolve the CLI and the spec root: `team paths` (and `team doctor`) print `TEAM_OPENSPEC_BIN` / `TEAM_SPEC_DIR`;
196
210
  with `TEAM_REQUIRE_OPENSPEC=1` (the default) a missing CLI or spec directory fails the doctor. The gate needs the
197
211
  CLI on `PATH` (or an absolute path in `TEAM_OPENSPEC_BIN`).
@@ -84,6 +84,16 @@ Guards and limitations:
84
84
  earlier than the automatic one. The **recipient** names the durable inbox file (`docs/team/inbox/<agent>.md`);
85
85
  the PM is still the **knock destination** — the queue entry's declaration and the wake pointer both name that
86
86
  same recipient file, and a durable append that fails exits non-zero without a wake.
87
+ - **The turn-end notice separates three endings**, the same three turn-end states the worker prompt names: a
88
+ **completed** turn with no job of that session still running is `[auto]`; the same turn with live jobs is
89
+ `[auto·suspended]`, carrying `awaiting=<id>[,<id>…]`; an **unfinished** turn stays `[auto·interrupted]` (with
90
+ `awaiting=` too when its jobs are alive). A suspension omits the `⚠ 未提交` prefix — it is not a delivery claim —
91
+ while `uncommitted=<n>` stays. The three states are **delivered**, **hard-blocked** and
92
+ **suspended on background jobs**, and the lane rule is the suspend default: `team_bg_run` starts a long job and
93
+ the turn ends; the completion wake-up is the normal harvest point; in-turn waiting is the bounded exception,
94
+ only inside the inline-wait budget (about 2 minutes), when the result blocks the next step and nothing else can
95
+ advance. A seat that suspended and then died needs no new patrol clause: an unfinished task with no live window
96
+ is already pending work (§8).
87
97
  - The **other** injected extension is `extension/team-bg.ts` (M27) — not notification, but the team's own
88
98
  background lane: `team_bg_run` starts a detached job (bounded `state/bg/<id>.log`), `team_bg_wait <id>` harvests
89
99
  it, a harvested job stays silent, several finishing jobs arrive as one message, and every turn end appends
@@ -119,10 +129,44 @@ Guards and limitations:
119
129
  call appends one line to `state/signal-calls.log` (`TEAM_SIGNAL_CALLS_LOG`), and a refusal is also copied byte
120
130
  for byte into `<log>.forensics` so it outlives the call log's rotation.
121
131
 
132
+ ## 4b. Key replies: publish the body before you answer
133
+
134
+ The wake-up loop carries a *pointer* (`inbox/<agent>.md` plus a knock), and the report carries the *process*. Neither
135
+ carries the **body** of a substantive answer, and both are transient or post-hoc: the inbox is gitignored, and a report
136
+ is written after the work. When an answer itself is the durable artefact — a decision, a trade-off, a root cause, a
137
+ finding someone will quote weeks later — publish that body explicitly before you send it:
138
+
139
+ ```
140
+ team reply post --from <seat> --title "<short single line>" --stdin <<'EOF'
141
+ … the exact body you are about to send …
142
+ EOF
143
+ ```
144
+
145
+ Then send the answer normally. Publication **never gates the answer**: the same body goes out whether the post
146
+ reported `saved` (0), an input error (2), storage unavailable (4), a busy writer (5, the lock wait is bounded) or
147
+ `unconfirmed` (6, the entry is visible but its durability could not be confirmed — never re-post it automatically).
148
+ Failures are diagnostics on stderr; they must not be concatenated into the answer, and they must not stop it.
149
+
150
+ What a receipt does and does not mean:
151
+ - **A saved receipt is project-local durable publication only.** It is not user delivery, not approval, not read
152
+ status, and not a refreshed console. Nothing else changes state: publishing creates no pending work, no BOARD row,
153
+ no outbox/inbox entry, no patrol wake-up, and no confirmation/reminder/approval lifecycle.
154
+ - **No new configuration key.** The capability is part of the tool, not a project setting.
155
+ - **Storage is project state, outside the published tree**: `<main_root>/.pi/team/state/key-replies/` holds a
156
+ fixed-size commit index plus the immutable originals (`team paths` resolves the root; the store never lands in
157
+ `docs/team/` or in a checkout). `list` / `show` / the console's summary are **observation-only**: they never
158
+ create, repair or lock anything, and a missing store stays missing.
159
+ - **Read it back with the tool, not by hand**: `team reply list [--before <no>] [--json]` pages the numbered slots
160
+ (newest first), `team reply show <no>` prints safe display text, `team reply show <no> --raw` exports the original
161
+ bytes to a non-TTY stdout, and the console's page 5 renders the latest reply plus the numbered history. Flags and
162
+ exit codes are in `team reply --help`.
163
+ - **The honest limit**: the fixtures can only prove that both exits carry the same body for a *fixture* agent. No tool
164
+ can verify that a real agent follows this guidance — so it is written here as a rule, not enforced by the store.
165
+
122
166
  ## 5. Task briefs: written for "a weak model without context"
123
167
 
124
- The default development model is a cheap, fast one (e.g. `deepseek/deepseek-flash`). It **will not correct an
125
- ambiguous requirement on its own**, so a brief has to be self-contained:
168
+ The `routine` category usually runs a cheap, fast model (e.g. `opencode-go/deepseek-v4.1-flash`). It **will not
169
+ correct an ambiguous requirement on its own**, so a brief has to be self-contained:
126
170
 
127
171
  - Background: why this is being done, where the relevant docs are (do not paste large chunks of code).
128
172
  - Deliverables: file paths plus key signatures/behaviour, item by item.
@@ -180,14 +224,30 @@ exactly how a printed fix turned into `✗ dispatch: 未知参数 --force(…
180
224
  with no override still refuses. A printed route is a promise, not decoration: `tests/routes.sh` applies every
181
225
  `修法:`/`改行:` family in a fixture and reddens when a route stops clearing its blocker or is no longer honored.
182
226
 
183
- ## 6. Model strategy: cheap models do the work, a different family does the adversarial verification
227
+ ## 6. Model strategy: task categories; different families for verification
228
+
229
+ The contract maps **task categories** to models (`TEAM_TASK_MODELS`) and names one independent `TEAM_PM_MODEL`.
230
+ The brief's `category:` selects a new dispatch's model, `team dispatch --model` overrides one launch, and a
231
+ complete same-task recovery keeps the model/SID it was committed to (even if the category later leaves the map).
232
+ The engine never derives a model from a phase or a seat: "verify" is a project category name, not an automatic
233
+ phase→model mapping, so a project with other names says which one means independent review.
234
+
235
+ | Use | Category | Selection principle |
236
+ |---|---|---|
237
+ | Implementation/tests/docs | `routine` | a cheap model without concurrency limits; a good brief is enough |
238
+ | Complex planning / important architecture judgment | `analysis` | a strong model, with the reasoning recorded on disk (decision log/design), not only in a session |
239
+ | Independent verification/adversarial analysis | `verify` | switch model families (to avoid the same blind spots); a strong author model never waives independent review |
240
+ | Heavy concurrent work | any | the subscription token/quota is shared → cap concurrency with `TEAM_MODEL_LIMITS` and queue the rest; `team ps` shows occupancy |
241
+
242
+ Changing the policy changes **future** selections only. Redefining or dropping a category does not invalidate a
243
+ committed assignment: recovery uses the recorded model/SID, while a **new** task citing a dropped category is
244
+ refused. A running PM keeps its model until an explicit `team up --fresh-pm`, and a fresh takeover continues from
245
+ the files on disk (brief, report, thread, `state/`), never by replaying a conversation.
184
246
 
185
- | Use | Selection principle |
186
- |---|---|
187
- | Implementation/tests/docs | a cheap model without concurrency limits; a good brief is enough |
188
- | Independent verification/adversarial analysis | switch model families (to avoid the same blind spots), e.g. the grok family |
189
- | Heavy review/hard problems | subscription quota is tight → cap concurrency with `TEAM_MODEL_LIMITS`, run one at a time |
190
- | Long-context hard problems | slow and concurrency-limited; only when the PM explicitly asks |
247
+ Private source verification, protected-branch source landing, this project's configuration/fresh launch and shared
248
+ skill-source adoption are **four separate recorded gates**; each is previewed and authorized per operation. A
249
+ shared skill link reads its target's current bytes, so changing that target can affect other projects without an
250
+ installer.
191
251
 
192
252
  `team dispatch` checks `TEAM_MODEL_LIMITS` and capacity before dispatching: the rules (from two OOM incidents on CEP,
193
253
  one of which hit RAM and zram bottom at the same time):
@@ -456,7 +516,7 @@ unresolved `merge --squash` is caught by the next gate instead of reaching `main
456
516
  A trap: an add/add conflict is often git's rename detection pairing two different paths (e.g. `reviews/<ID>.md` and
457
517
  `reports/<ID>-<agent>.md`). Retry with `git -c merge.renames=false merge --squash <branch>` and it goes away.
458
518
 
459
- ## 8f. Template rendering and dispatch traps (measured on erp)
519
+ ## 8f. Template rendering and dispatch traps (measured on an external project)
460
520
 
461
521
  - **Rendering must not go through sed**: `&` inside the replacement string means "the matched text", so
462
522
  `TEAM_GATES="pnpm test && pnpm lint"` was written out as `pnpm test {{GATES}}{{GATES}} pnpm lint`. `team_render` now
@@ -465,7 +525,7 @@ A trap: an add/add conflict is often git's rename detection pairing two differen
465
525
  `init` also escapes gate values containing `$ \` \ "` before writing them into the config, so sourcing it back
466
526
  yields the same value as the input (and is never executed).
467
527
  - **Dispatch writes absolute paths**: the window shell's PATH/rc may not be ready yet, so exec'ing `pi` directly ends
468
- in `command not found` (reproduced twice on erp). Dispatch now resolves pi's absolute path first, writes it into the
528
+ in `command not found` (reproduced twice on an external project). Dispatch now resolves pi's absolute path first, writes it into the
469
529
  window command, and checks that it exists before dispatching (a missing binary fails immediately instead of being
470
530
  discovered inside the window).
471
531
  - **GitLab API headers and bodies must match**: if `--data-urlencode` is the form body, then
@@ -628,7 +688,10 @@ turns into a red a fixture cannot explain.
628
688
  Since 2026-10-04 the readable ledger — board, decisions, roadmap, ownership, briefs, the text of reports and
629
689
  verification records, threads — is committed to the repository (D94). A brief or a report is therefore public the
630
690
  moment it is written, and the one mechanical redaction pass that produced the first batch has no net behind it.
631
- So the ban is a check in the gate: suite section `60` runs `tests/ledger-ban.sh`, which scans `docs/team/**/*.md`
691
+ So the ban is a check in the gate: suite section `60` runs `tests/ledger-ban.sh`, which scans every file under
692
+ `docs/team` that would be committed (`git ls-files -c -o --exclude-standard`; P231 widened this from `**/*.md`,
693
+ because the `.tsv` ledgers — precisely where branch and project names get written — were a blind spot: a planted
694
+ leak there came back green)
632
695
  and fails, naming file and line, on
633
696
 
634
697
  - a home directory (`/home/<name>…` or `/Users/<name>…`; the ellipsis placeholders `/home/.../` and `/home/…/` pass);
@@ -656,7 +719,12 @@ itself failed. Falsifiability lives in the fixture self-test (`bash tests/ledger
656
719
  path and a planted forbidden name must come back red with file:line, a missing list must show the visible skip, a
657
720
  shadow scanner whose hit counter is broken must make the two red cases fail, and a second shadow whose masking is
658
721
  turned off must make the “no raw text in the output” cases fail — a mixed line, twenty-five occurrences on one line,
659
- a placeholder standing before the hit (the offset must survive the blanking), and an over-long line.
722
+ a placeholder standing before the hit (the offset must survive the blanking), and an over-long line. P231 extends
723
+ both ends: the face itself is pinned by the ownership fixture (`tests/ledger-claim.sh`) — a planted name in a
724
+ `docs/team/ledger/*.tsv` must come back red naming that file and line, while a copy of the scanner whose face is
725
+ narrowed back to `*.md` must return `hits=0` on the same tree (the false green, reproduced) — and the header rules
726
+ (`# ledger-scan:` must be a single line and must point at the section that carries this check) are refused at load
727
+ time instead of at check time.
660
728
 
661
729
  ## 9c. Strong verification (adversarial package + finding flips, for milestones)
662
730
 
@@ -34,9 +34,10 @@ verified one by one, archived only after the last one landed.
34
34
  ## A. Assembling a team in a new project
35
35
 
36
36
  New-project setup lives in the **`teamsmith-init`** skill: it carries the ordered question checklist (dependencies,
37
- session/roster/models, gates, VCS mode, install command, the project's ROADMAP/OWNERSHIP/AGENTS.md red lines), the
38
- `team bootstrap` command and the handoff back here. Read `skills/teamsmith-init/SKILL.md` before running anything;
39
- the command's own behaviour is in
37
+ session/roster and the task-category map + independent PM model, gates, VCS mode, install command, the project's
38
+ ROADMAP/OWNERSHIP/AGENTS.md red lines), the `team bootstrap` command (fresh projects must pass
39
+ `--task-models` and `--pm-model`; a legacy config is refused and migrates through `team config upgrade-models`) and
40
+ the handoff back here. Read `skills/teamsmith-init/SKILL.md` before running anything; the command's own behaviour is in
40
41
  [../../teamsmith-init/references/bootstrap.md](../../teamsmith-init/references/bootstrap.md).
41
42
 
42
43
  ## B. Dispatching the first task
@@ -56,18 +57,22 @@ bash <skill>/scripts/team dispatch dev T1.1 docs/team/tasks/T1.1-*.md
56
57
  bash <skill>/scripts/team dispatch dev T1.1 docs/team/tasks/T1.1-*.md --print # just want to see the prompt
57
58
  ```
58
59
 
59
- Dispatch does this: guards (memory, model concurrency, **session size vs the model window**) → builds the prompt
60
- (scope, red lines, delivery process) → starts an interactive pi in `<session>:dev` (`--session-id <session>-dev`,
61
- `-e` loading the notify extension, `--skill` loading this skill) → **waits for launch proof**: the pane harness
62
- writes a per-attempt nonce right before it execs the agent, and only that proof is reported as success (the line
63
- says the launch was verified). No proof → the window is killed, one retry is made, and the command reports a clear
64
- failure ("the dispatch was sent but the launch could not be confirmed") with what to check. A dispatch never claims
65
- success for a command that never ran.
66
-
67
- Resuming: dispatch the same agent for the same task and the session is reused; `--fresh` starts a new one
68
- (`<session>-<agent>-<timestamp>`; the old history stays in its own file). Use `--fresh` when the task is new and the
69
- session carries a long history from an earlier task, when you switch model family/provider, or when the session is
70
- wedged (the `Context full` / connection-error loop — troubleshooting §4a).
60
+ Dispatch does this: guards (memory, model concurrency, **session size vs the model window**) → resolves the launch
61
+ identity (a **new** task takes the brief's `category:` model from `TEAM_TASK_MODELS`, or `--model` as a one-launch
62
+ override, and gets a fresh SID; a complete same-task recovery keeps the recorded model/SID/category even after the
63
+ category leaves the map) → builds the prompt (scope, red lines, delivery process) → starts an interactive pi in
64
+ `<session>:dev` (`--session-id <session>-dev`, `-e` loading the notify extension, `--skill` loading this skill) →
65
+ **waits for launch proof**: the pane harness writes a per-attempt nonce right before it execs the agent, and only
66
+ that proof is reported as success (the line says the launch was verified). The complete assignment is published
67
+ atomically only after the proof; previews and refusals never write one. No proof → the window is killed, the old
68
+ record stays, and the command reports a clear failure ("the dispatch was sent but the launch could not be
69
+ confirmed") with what to check. A dispatch never claims success for a command that never ran.
70
+
71
+ Resuming: dispatch the same agent for the same task and the recorded session is reused; `--fresh` starts a new one
72
+ (keeping the recorded model/category, only the SID changes) and is required when the model would change (thinking
73
+ suffix included). Use `--fresh` when the task is new and the session carries a long history from an earlier task,
74
+ when you switch model family/provider, or when the session is wedged (the `Context full` / connection-error loop —
75
+ troubleshooting §4a).
71
76
 
72
77
  **One agent, one unfinished task.** Before launching, dispatch also reads what that agent is already carrying: the
73
78
  recorded task (`state/<agent>.env`), its board row and the worktree's checked-out branch. If another task is still
@@ -179,10 +184,17 @@ team_bg_wait review-T1.1
179
184
 
180
185
  The four rules that make it safe (they are the extension's code, not a convention):
181
186
 
182
- 1. **Harvest before the turn ends.** An unharvested job wakes you **once** when it finishes; a harvested job stays
183
- silent (its result came back inline). Several jobs finishing together arrive as **one** message, and never while
184
- you are running tools.
185
- 2. **The ledger is on disk**: every turn end appends
187
+ 1. **End the turn after starting; the completion wake-up is the normal harvest point.** The tool returns at once,
188
+ so the turn is free: end it, and when the job finishes and you are idle you are woken once (several jobs
189
+ finishing together arrive as one message) to run `team_bg_wait <id>`; a harvested job stays silent (its result
190
+ came back inline). In-turn waiting is the bounded exception: use it only when all three hold -- the job is
191
+ expected to finish within the inline-wait budget (about 2 minutes), its result blocks your immediate next step,
192
+ and no other task work can advance meanwhile. A turn that ends with this session's jobs still running is
193
+ **suspended on background jobs** -- a third legal ending beside **delivered** and **hard-blocked**, not a
194
+ delivery and not a blockage, and its last line names every awaited job id.
195
+ 2. **The ledger is on disk**: `team_bg_run` appends `<ISO timestamp> start id=<id> pid=<pid>` before it returns the
196
+ id, and every `team_bg_wait` appends `<ISO timestamp> wait id=<id> outcome=<harvested|running|interrupted>
197
+ waited_s=<s>` (the seconds that call itself waited). Every turn end appends
186
198
  `<ISO timestamp> settled-with-unharvested=<n> jobs=<id>:<running|exit<code>>,…` to
187
199
  `<root>/.pi/team/state/bg.log` — a review or a digest can read “this turn ended with unharvested work”
188
200
  afterwards. Deliveries append `wake count=<n> ids=…`.