teamsmith 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +158 -2
- package/bin/team.mjs +59 -0
- package/install.sh +94 -0
- package/package.json +37 -4
- package/skills/teamsmith/CHANGELOG.md +763 -0
- package/skills/teamsmith/SKILL.md +312 -0
- package/skills/teamsmith/extension/team-bg.ts +435 -0
- package/skills/teamsmith/extension/team-inbox-watch.ts +1412 -0
- package/skills/teamsmith/extension/team-notify.ts +663 -0
- package/skills/teamsmith/references/agent-adapters.md +643 -0
- package/skills/teamsmith/references/config.md +477 -0
- package/skills/teamsmith/references/meeting.md +124 -0
- package/skills/teamsmith/references/memory.md +133 -0
- package/skills/teamsmith/references/migration.md +227 -0
- package/skills/teamsmith/references/openspec.md +222 -0
- package/skills/teamsmith/references/philosophy.md +95 -0
- package/skills/teamsmith/references/protocol.md +712 -0
- package/skills/teamsmith/references/troubleshooting.md +1384 -0
- package/skills/teamsmith/references/workflows.md +448 -0
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +1709 -0
- package/skills/teamsmith/scripts/lib/cmd-bg.sh +284 -0
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +311 -0
- package/skills/teamsmith/scripts/lib/cmd-config.sh +1156 -0
- package/skills/teamsmith/scripts/lib/cmd-death.sh +562 -0
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +149 -0
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +124 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +212 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +904 -0
- package/skills/teamsmith/scripts/lib/cmd-outbox.sh +196 -0
- package/skills/teamsmith/scripts/lib/cmd-project.sh +642 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +1393 -0
- package/skills/teamsmith/scripts/lib/cmd-status.sh +1399 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +191 -0
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +1681 -0
- package/skills/teamsmith/scripts/lib/common.sh +4964 -0
- package/skills/teamsmith/scripts/lib/draft-entry.sh +51 -0
- package/skills/teamsmith/scripts/lib/outbox.sh +2042 -0
- package/skills/teamsmith/scripts/lib/tmux-argv.sh +165 -0
- package/skills/teamsmith/scripts/monitor.mjs +616 -0
- package/skills/teamsmith/scripts/panel/README.md +192 -0
- package/skills/teamsmith/scripts/panel/build.sh +47 -0
- package/skills/teamsmith/scripts/panel/bun.lock +109 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +68 -0
- package/skills/teamsmith/scripts/panel/package.json +24 -0
- package/skills/teamsmith/scripts/panel/panel.js +388 -0
- package/skills/teamsmith/scripts/panel/src/App.tsx +2150 -0
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/compose.ts +691 -0
- package/skills/teamsmith/scripts/panel/src/data.ts +555 -0
- package/skills/teamsmith/scripts/panel/src/format.ts +50 -0
- package/skills/teamsmith/scripts/panel/src/layout.ts +2562 -0
- package/skills/teamsmith/scripts/panel/src/main.tsx +894 -0
- package/skills/teamsmith/scripts/panel/src/markdown.ts +340 -0
- package/skills/teamsmith/scripts/panel/src/sanitize.ts +42 -0
- package/skills/teamsmith/scripts/panel/src/settings.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +416 -0
- package/skills/teamsmith/scripts/panel/src/strings/index.ts +65 -0
- package/skills/teamsmith/scripts/panel/src/strings/types.ts +9 -0
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +414 -0
- package/skills/teamsmith/scripts/panel/src/theme.ts +116 -0
- package/skills/teamsmith/scripts/panel/src/types.ts +652 -0
- package/skills/teamsmith/scripts/panel/src/width.ts +105 -0
- package/skills/teamsmith/scripts/panel/tsconfig.json +16 -0
- package/skills/teamsmith/scripts/shim/signal-gate +156 -0
- package/skills/teamsmith/scripts/shim/tmux +403 -0
- package/skills/teamsmith/scripts/team +143 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +147 -0
- package/skills/teamsmith/templates/BOARD.md.tmpl +18 -0
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +22 -0
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +25 -0
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +84 -0
- package/skills/teamsmith/templates/ROADMAP.md.tmpl +29 -0
- package/skills/teamsmith/templates/config.sh.tmpl +106 -0
- package/skills/teamsmith/templates/memory-seed.md.tmpl +46 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +110 -0
- package/skills/teamsmith/templates/report.md.tmpl +36 -0
- package/skills/teamsmith/templates/task.md.tmpl +65 -0
- package/skills/teamsmith/templates/threads-README.md +17 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +682 -0
- package/skills/teamsmith/tests/bg-ledger.sh +307 -0
- package/skills/teamsmith/tests/checkout-shape-probe.sh +800 -0
- package/skills/teamsmith/tests/config-cli.sh +1562 -0
- package/skills/teamsmith/tests/container-tmux.sh +493 -0
- package/skills/teamsmith/tests/coverage-inventory.sh +173 -0
- package/skills/teamsmith/tests/death-cause.sh +564 -0
- package/skills/teamsmith/tests/delivery-truth.sh +1231 -0
- package/skills/teamsmith/tests/fake-tui.py +450 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +60 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +139 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/mock-server.py +29 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/observe.ts +20 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +79 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +175 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +229 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/README.md +22 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.seen +8 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.wake +9 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/pm-nudges.wake +3 -0
- package/skills/teamsmith/tests/fixtures/signal-lint-cases.txt +40 -0
- package/skills/teamsmith/tests/flip-glue.sh +162 -0
- package/skills/teamsmith/tests/flip-m12-26c.sh +129 -0
- package/skills/teamsmith/tests/flip-m12.sh +185 -0
- package/skills/teamsmith/tests/flip-m16.sh +166 -0
- package/skills/teamsmith/tests/flip-m17.sh +204 -0
- package/skills/teamsmith/tests/flip-m33.sh +284 -0
- package/skills/teamsmith/tests/flip-m34.sh +96 -0
- package/skills/teamsmith/tests/flip-m37.sh +185 -0
- package/skills/teamsmith/tests/flip-m4.3.sh +375 -0
- package/skills/teamsmith/tests/flip-m43.sh +128 -0
- package/skills/teamsmith/tests/flip-m44.sh +262 -0
- package/skills/teamsmith/tests/flip-m45.sh +244 -0
- package/skills/teamsmith/tests/flip-m46.sh +238 -0
- package/skills/teamsmith/tests/flip-m48.sh +304 -0
- package/skills/teamsmith/tests/flip-m6.2.sh +205 -0
- package/skills/teamsmith/tests/flip-m6.3.sh +283 -0
- package/skills/teamsmith/tests/flip-m6.4.sh +267 -0
- package/skills/teamsmith/tests/flip-m6.5.sh +113 -0
- package/skills/teamsmith/tests/flip-m7.1.sh +135 -0
- package/skills/teamsmith/tests/flip-m7.2.sh +321 -0
- package/skills/teamsmith/tests/flip-p144.sh +112 -0
- package/skills/teamsmith/tests/flip-p156.sh +133 -0
- package/skills/teamsmith/tests/flip-p158.sh +301 -0
- package/skills/teamsmith/tests/flip-p160.sh +182 -0
- package/skills/teamsmith/tests/flip-p171.sh +249 -0
- package/skills/teamsmith/tests/flip-p18.1.sh +95 -0
- package/skills/teamsmith/tests/flip-p20.sh +286 -0
- package/skills/teamsmith/tests/flip-p201.sh +249 -0
- package/skills/teamsmith/tests/flip-p210.sh +239 -0
- package/skills/teamsmith/tests/flip-p211.sh +152 -0
- package/skills/teamsmith/tests/flip-p217.sh +288 -0
- package/skills/teamsmith/tests/flip-p22.sh +123 -0
- package/skills/teamsmith/tests/flip-p23.sh +239 -0
- package/skills/teamsmith/tests/flip-p25.sh +165 -0
- package/skills/teamsmith/tests/flip-p71.sh +184 -0
- package/skills/teamsmith/tests/flip-p72.sh +202 -0
- package/skills/teamsmith/tests/frames/README.md +176 -0
- package/skills/teamsmith/tests/frames/p78-conversation-rule-below-box.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-cursor-mid-draft.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor-line.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-blank-region.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-only.txt +5 -0
- package/skills/teamsmith/tests/frames/p78-spinner-row-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-wider-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p86-f1-mixed-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-narrower-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-spinner-top-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/pi-0.85.1-update-banner.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-draft-half-sentence.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-empty-box.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-one-line-draft.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-project-trust-prompt.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-empty-editor.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-human-draft.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-1.0.0-git-error-in-box.txt +32 -0
- package/skills/teamsmith/tests/gate-guard.sh +112 -0
- package/skills/teamsmith/tests/guard-matrix.sh +233 -0
- package/skills/teamsmith/tests/install-shape.sh +731 -0
- package/skills/teamsmith/tests/ledger-ban.sh +612 -0
- package/skills/teamsmith/tests/lib/box-judge.sh +68 -0
- package/skills/teamsmith/tests/lib/checkout-shape.sh +129 -0
- package/skills/teamsmith/tests/lib/loop-scan.awk +114 -0
- package/skills/teamsmith/tests/lib/pty-wait.sh +676 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +855 -0
- package/skills/teamsmith/tests/lib/shell-lex.pl +261 -0
- package/skills/teamsmith/tests/lib/tmp-root.sh +528 -0
- package/skills/teamsmith/tests/lib/tmux-cap.sh +35 -0
- package/skills/teamsmith/tests/lib/tmux-iso-call-probe.sh +81 -0
- package/skills/teamsmith/tests/lib/tmux-iso-probe.sh +46 -0
- package/skills/teamsmith/tests/lib/tmux-iso.sh +381 -0
- package/skills/teamsmith/tests/load-experiment.sh +290 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +84 -0
- package/skills/teamsmith/tests/panel-b2-slow-stub.sh +19 -0
- package/skills/teamsmith/tests/panel-b2.sh +1183 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +240 -0
- package/skills/teamsmith/tests/panel-b3-pty-tmux-mouse.py +138 -0
- package/skills/teamsmith/tests/panel-b3-stub.sh +279 -0
- package/skills/teamsmith/tests/panel-b3.sh +1301 -0
- package/skills/teamsmith/tests/panel-choices.sh +572 -0
- package/skills/teamsmith/tests/panel-clipboard-model.ts +187 -0
- package/skills/teamsmith/tests/panel-compose-model.ts +290 -0
- package/skills/teamsmith/tests/panel-contrast.mjs +81 -0
- package/skills/teamsmith/tests/panel-cpu-premise.sh +173 -0
- package/skills/teamsmith/tests/panel-cpu.sh +391 -0
- package/skills/teamsmith/tests/panel-flip-m54.sh +207 -0
- package/skills/teamsmith/tests/panel-flip-p123.sh +278 -0
- package/skills/teamsmith/tests/panel-flip-p125.sh +318 -0
- package/skills/teamsmith/tests/panel-flip-p128.sh +259 -0
- package/skills/teamsmith/tests/panel-keyprobe-pty.py +99 -0
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +41 -0
- package/skills/teamsmith/tests/panel-keyprobe.sh +82 -0
- package/skills/teamsmith/tests/panel-keyprobe.tsx +116 -0
- package/skills/teamsmith/tests/panel-knobs.sh +83 -0
- package/skills/teamsmith/tests/panel-p21.sh +2181 -0
- package/skills/teamsmith/tests/panel-snapshots.sh +802 -0
- package/skills/teamsmith/tests/panel-strings.mjs +195 -0
- package/skills/teamsmith/tests/perf.sh +740 -0
- package/skills/teamsmith/tests/pm-box-real.sh +350 -0
- package/skills/teamsmith/tests/pulse-nudge-key.sh +563 -0
- package/skills/teamsmith/tests/routes.sh +1652 -0
- package/skills/teamsmith/tests/section-budgets.tsv +150 -0
- package/skills/teamsmith/tests/section-guard.sh +231 -0
- package/skills/teamsmith/tests/section-needs-audit.sh +94 -0
- package/skills/teamsmith/tests/section-paths.tsv +142 -0
- package/skills/teamsmith/tests/section-select.sh +655 -0
- package/skills/teamsmith/tests/signal-gate.sh +366 -0
- package/skills/teamsmith/tests/signal-lint-legacy.txt +14 -0
- package/skills/teamsmith/tests/signal-lint.pl +416 -0
- package/skills/teamsmith/tests/skill-load.mjs +65 -0
- package/skills/teamsmith/tests/smoke.sh +19711 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +32 -0
- package/skills/teamsmith/tests/spec-ledger-refs.tsv +78 -0
- package/skills/teamsmith/tests/spec-refs.sh +826 -0
- package/skills/teamsmith/tests/task-header-model.sh +267 -0
- package/skills/teamsmith/tests/team-bg-flip.sh +239 -0
- package/skills/teamsmith/tests/team-bg-harness.mjs +392 -0
- package/skills/teamsmith/tests/team-bg-stop.sh +434 -0
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +191 -0
- package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +1559 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +1190 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +31 -0
- package/skills/teamsmith/tests/tmux-lint.pl +604 -0
- package/skills/teamsmith-init/SKILL.md +100 -0
- package/skills/teamsmith-init/references/bootstrap.md +74 -0
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +46 -0
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
# Agent adapters · the launch and notify seam (internal, frozen)
|
|
2
|
+
|
|
3
|
+
teamsmith promises exactly one harness: **Pi**, at the version floor `README.md` states and `team doctor`
|
|
4
|
+
enforces. The launch and notify seam documented here is an **internal seam (frozen)**: the built-in Pi paths are
|
|
5
|
+
rendered by the same engine, the seam is reserved for a possible future non-Pi adapter, and teamsmith makes
|
|
6
|
+
**no compatibility promise** about it — it is not a public extension point, and the new-project questionnaire
|
|
7
|
+
never asks about it. It stays writable and diagnosable so a maintainer can work on it; the worked non-Pi
|
|
8
|
+
examples below are **seam documentation, not a support offer**.
|
|
9
|
+
|
|
10
|
+
Mechanically, the workflow does not depend on Pi: the PM owns *windows,
|
|
11
|
+
worktrees, task briefs, reports, gates and the inbox contract*, and "how do I start this agent CLI"
|
|
12
|
+
is pluggable — on the **worker side** (four keys) and on the **PM side** (three keys, §2). **All of them
|
|
13
|
+
empty by default, which keeps the Pi behaviour byte-for-byte identical.**
|
|
14
|
+
|
|
15
|
+
| Key | Meaning | Empty (default) |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `TEAM_AGENT_CMD` | launch template for the agent CLI | built-in Pi command: `TEAM_PI_BIN --provider P --model M -e <notify ext> -e <bg ext> -e <inbox-watch ext> --skill <skill dir> --session-id <sid>` |
|
|
18
|
+
| `TEAM_AGENT_NOTIFY_CMD` | how a worker tells the PM its turn ended | the Pi notify extension (`extension/team-notify.ts` → `inbox/<agent>.md` + knock on the PM window) |
|
|
19
|
+
| `TEAM_AGENT_LOG_GLOB` | optional log/session files for `team monitor --activity` | Pi session discovery (`~/.pi/agent/sessions/**`) |
|
|
20
|
+
| `TEAM_AGENT_BIN` | binary used for the window-readiness wait and existence checks | first word of `TEAM_AGENT_CMD`, else `TEAM_PI_BIN` |
|
|
21
|
+
|
|
22
|
+
`team doctor` and `team paths` always print the resolved adapter: `built-in (Pi) → <path>` or
|
|
23
|
+
`custom: <cmd> → <path>`. `doctor` fails only when a **configured** adapter cannot be resolved; on
|
|
24
|
+
the built-in path a missing `pi` still fails exactly as before.
|
|
25
|
+
|
|
26
|
+
## 1. The contract
|
|
27
|
+
|
|
28
|
+
teamsmith owns (identical for every adapter):
|
|
29
|
+
|
|
30
|
+
- the tmux window (`<session>:<agent>`), `cd <worktree>`, a short wait until `TEAM_AGENT_BIN` is
|
|
31
|
+
executable (the window shell's PATH is not ready at `new-window` time), the small banner, and
|
|
32
|
+
`exec bash` once the CLI exits (so the window stays usable for `team say`);
|
|
33
|
+
- the prompt: teamsmith composes it, writes it to
|
|
34
|
+
`$TEAM_MAIN_ROOT/.pi/team/state/prompt-<agent>-<ID>.md`, and passes the same text as the harness'
|
|
35
|
+
`argv[0]` — this is why the window command line stays short no matter how big the prompt is;
|
|
36
|
+
- the task/report/board/thread/inbox contract and every `team …` subcommand the worker is told to call;
|
|
37
|
+
- liveness: "is this agent running" is answered from the pane's foreground process group, not from a
|
|
38
|
+
Pi-specific hook, so it works for any CLI (see `references/troubleshooting.md`).
|
|
39
|
+
|
|
40
|
+
The adapter owns: how to start its CLI, how that CLI is told which model/prompt/session to use, and how
|
|
41
|
+
the worker notifies the PM at turn end. The **team background lane is teamsmith's own** (§3a): the built-in Pi
|
|
42
|
+
paths load it with `-e`, a custom Pi-shaped template opts in with `{bg_ext}`, and a CLI without a Pi extension API
|
|
43
|
+
simply does not have those two tools.
|
|
44
|
+
|
|
45
|
+
## 2. The PM side: `TEAM_PM_CMD`
|
|
46
|
+
|
|
47
|
+
The PM side is the same internal seam (frozen). Workers describe their CLI with `TEAM_AGENT_CMD`; the PM
|
|
48
|
+
describes its own with `TEAM_PM_CMD`, and an empty value means "the built-in Pi command", unchanged.
|
|
49
|
+
|
|
50
|
+
| Key | Meaning | Empty (default) |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `TEAM_PM_CMD` | launch template for the PM | built-in Pi command: `TEAM_PI_BIN --provider P --model M -e <bg ext> -e <inbox-watch ext> --skill <skill dir> -c @<state>/pm-prompt.md` |
|
|
53
|
+
| `TEAM_PM_BIN` | binary used for the start-time existence check and for the liveness **identity** check | first word of `TEAM_PM_CMD`, else `TEAM_PI_BIN` |
|
|
54
|
+
| `TEAM_PM_RESUME_ARGS` | arguments that continue the PM's previous session | on the Pi path the historical `-c` / `--session-id <id>`; on a custom CLI: **nothing — the restart does not continue the history** |
|
|
55
|
+
|
|
56
|
+
<!-- pm-side:begin -->
|
|
57
|
+
PM placeholders — same engine, same rules as §3 (a blank or multi-line template, an unknown token and a
|
|
58
|
+
malformed one such as `{ cwd }` all fail loudly, and the error names `TEAM_PM_CMD`):
|
|
59
|
+
|
|
60
|
+
- `{cwd}` — the project's **main worktree** (the PM's working directory)
|
|
61
|
+
- `{session_id}` — `TEAM_PM_SESSION_ID`, empty by default (only meaningful if your CLI has its own session ids)
|
|
62
|
+
- `{model}` — the model-name part of `TEAM_PM_MODEL` (default `TEAM_DEFAULT_MODEL`)
|
|
63
|
+
- `{provider}` — the provider part
|
|
64
|
+
- `{prompt_file}` — path of `state/pm-prompt.md`, the PM briefing (`team up --print` prints the same text)
|
|
65
|
+
- `{prompt}` — `"$0"`: the briefing as a single argv token handed over by the window harness (keep the quotes)
|
|
66
|
+
- `{skill_dir}` — the teamsmith skill directory
|
|
67
|
+
- `{bg_ext}` — path of the team background-job extension (`extension/team-bg.ts`): the PM's lane for long gates
|
|
68
|
+
(`team_bg_run` / `team_bg_wait`, see §3a). The built-in Pi command already passes it; a custom Pi-shaped PM
|
|
69
|
+
template adds `-e {bg_ext}` to get the same tools.
|
|
70
|
+
- `{extra_args}` — `TEAM_PM_EXTRA_PI_ARGS`, the PM's own key, **not** the worker's `TEAM_EXTRA_PI_ARGS`
|
|
71
|
+
- `{resume_args}` — `TEAM_PM_RESUME_ARGS` (PM-only; a **worker** template that uses it still fails as unknown)
|
|
72
|
+
<!-- pm-side:end -->
|
|
73
|
+
|
|
74
|
+
The worker placeholders `{notify_ext}` and `{summary}` are not part of the PM set, and asserting them in a PM
|
|
75
|
+
template is rejected too. (The placeholder table in §3 is the worker list; this section is the PM list — the smoke
|
|
76
|
+
suite keeps both in sync with the engine.)
|
|
77
|
+
|
|
78
|
+
Launch contract, identical to the worker side: teamsmith writes the briefing to `state/pm-prompt.md`,
|
|
79
|
+
`cd`s to the main worktree, records the pid that is about to become the agent in `state/pm.pid.spawn` and
|
|
80
|
+
only then `exec`s the template. The briefing itself never lands on the command line: the window harness
|
|
81
|
+
passes it as `argv[0]`, which is what `{prompt}` reads — use `{prompt_file}` when your CLI can read a file.
|
|
82
|
+
|
|
83
|
+
Two details of that harness matter when you write a template or debug one:
|
|
84
|
+
|
|
85
|
+
- **The first word is resolved, not guessed.** The window command runs under `bash -lc`, whose `PATH` comes from
|
|
86
|
+
`/etc/profile` and `~/.bash_profile` — typically *without* the directories your interactive shell adds
|
|
87
|
+
(`~/.bun/bin`, version-manager shims). teamsmith therefore resolves the template's bare first word on the
|
|
88
|
+
**caller's** `PATH` and renders the absolute path into the command, so `TEAM_PM_CMD='codex exec {prompt}'` works
|
|
89
|
+
even where `bash -lc 'command -v codex'` fails. A first word that already contains `/`, quotes, `$` or `{` is
|
|
90
|
+
left exactly as written (that is more than a bare executable name, so it is your command to own).
|
|
91
|
+
- **A failed start leaves evidence and does not take the window with it.** The CLI runs inside a subshell, so when
|
|
92
|
+
it exits the window returns to a prompt instead of vanishing; the launcher then writes
|
|
93
|
+
`state/pm-launch-failed.log` with the CLI's exit code, the rendered command, the resolved executable and the
|
|
94
|
+
window's last non-blank output (the raw capture lives next to it as `state/pm-launch-tail.txt`). `team up` exits
|
|
95
|
+
non-zero in that case — a failed start is never reported as success. The next `team up` or pulse tick treats
|
|
96
|
+
the idle prompt as "no PM" and replaces it.
|
|
97
|
+
|
|
98
|
+
### What the PM does **not** get
|
|
99
|
+
|
|
100
|
+
- **No turn-end notification, and no auto-nudge event.** `TEAM_AGENT_NOTIFY_CMD` and the Pi notify extension
|
|
101
|
+
are *worker* features: a worker tells the PM when its turn ended. For the PM that direction is inverted — the
|
|
102
|
+
PM is the recipient. A non-Pi PM is started/restarted by `team up` and by the pulse's pending-work check
|
|
103
|
+
(`watch --once`: unread inbox, reports to verify, blocked or stopped agents) and reads `team inbox` itself.
|
|
104
|
+
The PM **does** get the team background lane (`team-bg.ts`), because that is not notification: it is the PM's
|
|
105
|
+
own long-gate tool (§3a).
|
|
106
|
+
- **No guaranteed session continuity.** With `TEAM_PM_RESUME_ARGS` empty, a restart begins a *fresh* session,
|
|
107
|
+
and the tool says so in plain words instead of implying a continuation. The handoff is the durable record —
|
|
108
|
+
`docs/team/**` (BOARD, DECISIONS, threads, reports) plus `team inbox` — and the briefing itself tells the new
|
|
109
|
+
PM to start with `team digest`. If your CLI supports continuing (`--continue`, `resume --last`,
|
|
110
|
+
`--session <id>`, …), put those arguments in `TEAM_PM_RESUME_ARGS` **and** reference `{resume_args}` in
|
|
111
|
+
`TEAM_PM_CMD`; `team up` then reports how the session is continued instead of warning. Putting arguments in
|
|
112
|
+
the key without the placeholder is detected and reported as "the arguments are configured but not used".
|
|
113
|
+
- **No model/CLI compatibility guarantee.** `{model}` comes from teamsmith's registry; a CLI that does not know
|
|
114
|
+
that model fails inside the CLI, exactly like a worker adapter would.
|
|
115
|
+
|
|
116
|
+
### Liveness identity and the wrapper caveat
|
|
117
|
+
|
|
118
|
+
`state/pm.pid` (the pid teamsmith spawned, or the pid the pane's foreground process had when it was recognised)
|
|
119
|
+
plus a cwd inside the project is the strongest evidence; the fallback is "the foreground process in the PM window
|
|
120
|
+
is `TEAM_PM_BIN`". Either way the check resolves **the PM's** executable (`TEAM_PM_BIN` > first word of
|
|
121
|
+
`TEAM_PM_CMD` > `TEAM_PI_BIN`) — it does not require the name `pi`, and a PM whose CLI is not Pi counts.
|
|
122
|
+
|
|
123
|
+
- **Wrapper scripts**: if `TEAM_PM_BIN` is a wrapper that `exec`s the real CLI, the process image changes name the
|
|
124
|
+
moment it `exec`s, so argv-based recognition stops matching. The *spawn* proof (`proof=spawn`, the pid written to
|
|
125
|
+
`state/pm.pid.spawn` before `exec`) keeps the PM "running" — this is the same mechanism that covers a wrapped
|
|
126
|
+
`pi` (M6.3 F30).
|
|
127
|
+
- Do **not** wrap the PM with something that starts the CLI as a *child* (`sh -c 'codex …'` without `exec`, a
|
|
128
|
+
supervisor, a shell function): the recorded pid is then the wrapper, and liveness is lost as soon as it exits.
|
|
129
|
+
`exec` (or `TEAM_PM_BIN` pointing straight at the CLI) is what the contract expects.
|
|
130
|
+
- `team doctor`'s worker-adapter check proves the **worker** CLI; it says nothing about the PM CLI. The PM CLI is
|
|
131
|
+
checked at start time (`team up`, the pulse): a missing or unresolvable executable fails before anything is
|
|
132
|
+
respawned, naming `TEAM_PM_BIN` and the template's first word.
|
|
133
|
+
|
|
134
|
+
**Verified on this machine** (2026-09-16): `codex` as the PM CLI in a scratch project — `team up` started it,
|
|
135
|
+
the briefing was delivered (its first action was `team digest`), it drove `team board ls` / `team dispatch --print`
|
|
136
|
+
from that session, a killed window was restarted by `team up` (with the explicit "history is not continued"
|
|
137
|
+
notice), and `team watch --once` (with pending work) restarted it the same way. The evidence is in the M8.1
|
|
138
|
+
delivery report; the smoke suite repeats the same four scenarios against a fake non-Pi PM (`tests/smoke.sh`, §6i).
|
|
139
|
+
|
|
140
|
+
## 3. Launch: `TEAM_AGENT_CMD`
|
|
141
|
+
|
|
142
|
+
One shell command line, run in the worktree. Placeholders (values are `%q`-quoted by teamsmith):
|
|
143
|
+
|
|
144
|
+
| Placeholder | Expands to |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `{cwd}` | the agent's worktree (absolute) |
|
|
147
|
+
| `{session_id}` | teamsmith's session id `<TEAM_SESSION>-<agent>` (`--fresh` appends a timestamp) |
|
|
148
|
+
| `{model}` | the **model-name** part of the agent's model (`provider/model` → `model`) |
|
|
149
|
+
| `{provider}` | the provider part |
|
|
150
|
+
| `{prompt_file}` | path of the prompt file — the most portable way to pass the prompt (`"$(cat {prompt_file})"`, or the CLI's own file/stdin flag) |
|
|
151
|
+
| `{prompt}` | `"$0"`: the prompt as passed by the harness — keep the quotes, the value is inserted verbatim |
|
|
152
|
+
| `{skill_dir}` | teamsmith skill directory (for `bash {skill_dir}/scripts/team …`) |
|
|
153
|
+
| `{notify_ext}` | path of the Pi notify extension (only useful for Pi-compatible CLIs) |
|
|
154
|
+
| `{bg_ext}` | path of the team background-job extension (`extension/team-bg.ts`, §3a; only useful for Pi-compatible CLIs) |
|
|
155
|
+
| `{extra_args}` | `TEAM_EXTRA_PI_ARGS`, inserted verbatim |
|
|
156
|
+
|
|
157
|
+
Rules:
|
|
158
|
+
|
|
159
|
+
- **Any brace-delimited token that is not exactly a supported placeholder aborts the dispatch** and prints the
|
|
160
|
+
supported list plus the config key. That covers plain typos *and* near-misses that used to slip through
|
|
161
|
+
silently: whitespace inside the braces, a trailing space, doubled braces, stray quotes. JSON bodies
|
|
162
|
+
(`-d '{"a":1}'`), awk programs (`'{print $1}'`), shell variables (`${HOME}`) and brace expansion (`{a,b}`) are
|
|
163
|
+
not placeholders and stay untouched. `team dispatch … --print` renders the command for inspection, and the
|
|
164
|
+
smoke suite asserts a rendered command contains no leftover `{`.
|
|
165
|
+
- An adapter template must be **non-blank** and **single-line**: a whitespace-only `TEAM_AGENT_CMD` is rejected
|
|
166
|
+
instead of silently rendering `cd <worktree> &&` (a window that never starts an agent), and a newline is rejected
|
|
167
|
+
because the second line would be executed as its own command by the window shell.
|
|
168
|
+
- `{prompt}` and `{extra_args}` are inserted **verbatim** — you own the quoting for those. Everything else is quoted
|
|
169
|
+
for you. Expansion is a **single left-to-right pass**, so a value that happens to contain `{cwd}` (e.g. inside
|
|
170
|
+
`TEAM_EXTRA_PI_ARGS`) is never expanded a second time.
|
|
171
|
+
- The template's first word must be a **bare executable name** (no quotes): `TEAM_AGENT_BIN`, `team doctor` and the
|
|
172
|
+
window-readiness wait resolve it with `command -v`, which cannot see `"my agent"`. If your CLI really has a space
|
|
173
|
+
in its name, set `TEAM_AGENT_BIN` to its absolute path.
|
|
174
|
+
- `{model}`/`{provider}` come from teamsmith's model registry (`TEAM_DEFAULT_MODEL`,
|
|
175
|
+
`TEAM_AGENT_MODELS`), not from the CLI. For a custom CLI either hardcode the model in the template or
|
|
176
|
+
set `TEAM_AGENT_MODELS="dev=<provider>/<model>"` so `{model}` matches what the CLI really uses — that
|
|
177
|
+
also keeps `TEAM_MODEL_LIMITS` (model concurrency) meaningful.
|
|
178
|
+
- The rendered command is executed by `bash -lc` in the window; the usual quoting rules of your shell
|
|
179
|
+
apply, and nothing is `eval`-ed twice.
|
|
180
|
+
- **The first word is resolved, not guessed** (the same rule as the PM side, §2): the window shell is
|
|
181
|
+
`bash -lc`, whose `PATH` typically lacks the directories your interactive shell adds, so a bare first word is
|
|
182
|
+
resolved on the **caller's** `PATH` and the absolute path is rendered into the command. `TEAM_AGENT_CMD='codex …'`
|
|
183
|
+
therefore works even where `bash -lc 'command -v codex'` fails. A first word that already contains `/`, quotes,
|
|
184
|
+
`$` or `{` is left exactly as written, and when `TEAM_AGENT_BIN` explicitly names a **different** binary the
|
|
185
|
+
template is not touched.
|
|
186
|
+
- **"The harness started" is not "the agent started".** The window harness records the agent's exit code
|
|
187
|
+
(`state/dispatch-<agent>.exit`, same nonce as the spawn proof), and a worker CLI that exits non-zero within
|
|
188
|
+
`TEAM_DISPATCH_ALIVE_SEC` (default 1s) makes the dispatch **fail**: it prints `exit=<code>` and writes
|
|
189
|
+
`state/dispatch-<agent>-launch-failed.log` (rendered command, resolved binary, exit code, window tail). An
|
|
190
|
+
adapter that exits 0 is reported as finished — normal for script-style CLIs — and one that keeps running as
|
|
191
|
+
still running. The built-in Pi path keeps its old contract (a short-lived `TEAM_PI_BIN` is allowed), so an
|
|
192
|
+
immediately exiting `pi` is still a success with a warning.
|
|
193
|
+
|
|
194
|
+
### 3a. The team's own background lane (built-in Pi: `{bg_ext}`)
|
|
195
|
+
|
|
196
|
+
A gate or a build that takes tens of minutes must not sit inside a turn. The team ships its own lane — no
|
|
197
|
+
third-party package, no extra window, nothing loaded into the user's own Pi sessions:
|
|
198
|
+
|
|
199
|
+
| Tool | What it does |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `team_bg_run` | starts the command as a **detached** `bash -c` job, returns a job id + pid at once; combined stdout/stderr goes to `state/bg/<id>.log` — in **the session's own root** (see below) — (bounded: past `TEAM_BG_LOG_MAX_BYTES`, default 512 KB, the head is dropped and the tail is kept behind a truncation marker) |
|
|
202
|
+
| `team_bg_wait <id>` | waits for the job (or returns at once with `timeout_ms`), **harvests** it and returns exit code + log tail inline |
|
|
203
|
+
|
|
204
|
+
Both results name the **command** next to the job id (` cmd: …`, single-lined and truncated past 100 code
|
|
205
|
+
points with `…`, cut on **code-point** boundaries so CJK characters and surrogate pairs never split), so a
|
|
206
|
+
session running several jobs can tell which is which; `details.cmd` carries the command verbatim (P33).
|
|
207
|
+
|
|
208
|
+
Both teamsmith launch paths load it: the built-in Pi worker command and the built-in Pi PM command pass
|
|
209
|
+
`-e <skill>/extension/team-bg.ts`. A custom template gets the same tools with `-e {bg_ext}`. A CLI that has no
|
|
210
|
+
Pi extension API simply does not have these tools — nothing else changes.
|
|
211
|
+
|
|
212
|
+
**Where those files live (M30): the session's own root.** The job logs and the ledger are session-local
|
|
213
|
+
artifacts, so `state/bg/<id>.log` and `state/bg.log` are resolved against **the session's own worktree**
|
|
214
|
+
(`git rev-parse --show-toplevel` of the session's cwd): a dispatched worker's long-gate logs stay inside
|
|
215
|
+
`<worktree>/.pi/team/state/`, the PM's stay in the main worktree. They never land in the shared ledger
|
|
216
|
+
location — that is where the *interface* state lives (the outbox and the inbox-watch registry/spool, which
|
|
217
|
+
senders and sessions must agree on). The old `--git-common-dir` resolution wrote a worktree session's logs
|
|
218
|
+
into the main worktree's state; the M30 incident is what that costs: gate stdout (it contains every smoke
|
|
219
|
+
fixture's name) then tripped the isolation assertion of the *next* gate in that project. An explicit
|
|
220
|
+
`TEAM_STATE_DIR` still wins over all of this.
|
|
221
|
+
|
|
222
|
+
The rules (from oh-my-pi issue #689, measured in the E8 probes):
|
|
223
|
+
|
|
224
|
+
1. **Harvest before the turn ends.** An unharvested job that finishes while the agent is idle wakes it **once**,
|
|
225
|
+
with one merged `followUp` message for every job that finished in the same window. That costs a turn; a
|
|
226
|
+
harvested job never wakes anyone (its result was already returned inline).
|
|
227
|
+
2. **Several jobs, one message.** Completion notices are merged, and never delivered while the agent is running
|
|
228
|
+
tools (they wait for the next settle).
|
|
229
|
+
3. **The ledger is `state/bg.log`.** Every turn end appends one line —
|
|
230
|
+
`<ISO timestamp> settled-with-unharvested=<n>[ jobs=<id>:<running|exit<code>>,…]`, and every delivery appends
|
|
231
|
+
`<ISO timestamp> wake count=<n> ids=<id>,…`. So “this turn ended with unharvested jobs” is a fact on disk
|
|
232
|
+
that the PM (or a verifier) can read after the fact.
|
|
233
|
+
4. **A session restart does not kill jobs.** The job table is session-scoped and cleared on `session_start` /
|
|
234
|
+
`session_shutdown`; the processes are detached, the logs and the ledger stay in `state/`. After a restart the
|
|
235
|
+
results are still readable, but the ids are gone and nobody will be woken — treat `state/bg.log` as the record.
|
|
236
|
+
|
|
237
|
+
What the lane is **not**: it does not watch the user's sessions, it does not subscribe to any package's event
|
|
238
|
+
bus, and it only knows the jobs it started itself. It is injected through the same `-e` channel as the notify
|
|
239
|
+
extension, which is exactly the boundary: user sessions do not get it.
|
|
240
|
+
|
|
241
|
+
## 4. Notify: `TEAM_AGENT_NOTIFY_CMD`
|
|
242
|
+
|
|
243
|
+
**A worker's summary text is data, never code.** The worker writes its one-line summary into a file and runs a
|
|
244
|
+
fixed command; nothing the worker types is ever interpolated into a shell line.
|
|
245
|
+
|
|
246
|
+
Placeholders: `{summary_file}`, `{summary}`, `{agent}`, `{cwd}`, `{session_id}`, `{model}`, `{provider}`, `{skill_dir}`.
|
|
247
|
+
|
|
248
|
+
- `{summary_file}` — the path teamsmith reserves for the summary (`<state>/summary-<agent>-<ID>.md`, `%q`-quoted).
|
|
249
|
+
Use it with a CLI that reads a file: `… notify pm --from {agent} --from-file {summary_file}`.
|
|
250
|
+
- `{summary}` — **kept for compatibility, but never interpolated as text**: for a worker's command it expands to
|
|
251
|
+
a quoted read of the same summary file (`"$(cat '…')"`, and inside `'{summary}'` the single-quote-safe form), so
|
|
252
|
+
existing templates keep working without turning a worker's summary into shell code. Tooling that calls the
|
|
253
|
+
helper with an explicit summary string (the old five-argument call) gets it back `%q`-quoted as a single word —
|
|
254
|
+
still never evaluated.
|
|
255
|
+
- `{agent}` `{cwd}` `{session_id}` `{model}` `{provider}` `{skill_dir}` — the same values as in the launch
|
|
256
|
+
template, `%q`-quoted.
|
|
257
|
+
|
|
258
|
+
The two supported ways to receive the summary:
|
|
259
|
+
|
|
260
|
+
```sh
|
|
261
|
+
# recommended: the CLI reads the file itself (no file read in the shell at all), and the sender is stated
|
|
262
|
+
# explicitly so a runtime directory that names no seat can never be mis-attributed
|
|
263
|
+
TEAM_AGENT_NOTIFY_CMD='bash {skill_dir}/scripts/team notify pm --from {agent} --from-file {summary_file}'
|
|
264
|
+
# also fine: teamsmith renders a quoted file read, the command shape stays yours
|
|
265
|
+
TEAM_AGENT_NOTIFY_CMD='bash {skill_dir}/scripts/team notify pm --from {agent} --from-file {summary_file}'
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The rendered prompt section contains only teamsmith-owned paths plus that command, and instructs the worker:
|
|
269
|
+
write your one-line summary into the file, then run **exactly this command, with no substitutions, no extra
|
|
270
|
+
arguments and no quotes**.
|
|
271
|
+
|
|
272
|
+
`team notify <agent> --from-file <path>` normalises the file to a single line (CR removed, newlines → spaces,
|
|
273
|
+
trailing blanks stripped) so the inbox keeps one entry per line, and preserves every other byte — quotes,
|
|
274
|
+
`$`, backticks and `{agent}`-looking text arrive verbatim. A missing or empty summary file is a real failure
|
|
275
|
+
(non-zero exit, nothing appended), so a hop-through-empty-file is never silently reported as “notified”.
|
|
276
|
+
|
|
277
|
+
**The sender is not the recipient.** `team notify` attributes the message to the sender it resolves from the
|
|
278
|
+
caller's runtime context: an explicit `--from <name>` claim wins (recorded verbatim; a disagreement with the
|
|
279
|
+
runtime directory is named on stderr), otherwise the runtime directory — the project's main worktree resolves to
|
|
280
|
+
`pm`, and a worktree under the main worktree's worktrees directory resolves to its own directory name, also when
|
|
281
|
+
the command runs in one of its subdirectories.
|
|
282
|
+
|
|
283
|
+
The main worktree is the PM's **only when nothing says otherwise**. Because the ledger records the **author**, a
|
|
284
|
+
call from the main worktree that carries a seat clue is **refused** instead of being recorded as `pm` (P201): it
|
|
285
|
+
exits non-zero, writes nothing (no inbox line, no knock) and names both the directory's `pm` and the clue, plus
|
|
286
|
+
the two ways out — state the sender with `--from <your name>`, or run the command from your own worktree. A
|
|
287
|
+
clue is a name from this project's roster (`TEAM_AGENTS`); anything else is not a clue. The clue list:
|
|
288
|
+
|
|
289
|
+
1. the window name of the caller's **own pane** — read with
|
|
290
|
+
`tmux display-message -p -t "$TMUX_PANE" '#{window_name}'`, and only when that pane's session is this
|
|
291
|
+
project's `TEAM_SESSION`. Asking without `-t` answers the attached client's current window instead (measured
|
|
292
|
+
on tmux 3.7c: from a `dev2` pane that returns `pm`), which is an echo, not evidence; a window in another
|
|
293
|
+
session is not this project's seat window either.
|
|
294
|
+
2. an inherited `TEAM_AGENT`.
|
|
295
|
+
|
|
296
|
+
Clues never *become* the sender — the window name is mutable UI state and an inherited value can be stale, so a
|
|
297
|
+
clue only vetoes the directory's `pm` claim. On a worktree the runtime directory wins outright, and a
|
|
298
|
+
disagreeing `TEAM_AGENT` is named on stderr. If neither names a sender the call **refuses** (non-zero, no inbox
|
|
299
|
+
line, no knock) and names `--from`; a worker's notification is never recorded as `pm`. The same name appears on
|
|
300
|
+
the durable inbox line, in the knock text and in the queued entry's `from:` field.
|
|
301
|
+
|
|
302
|
+
Dispatch **warns but never blocks** when `TEAM_AGENT_NOTIFY_CMD` looks unusable (unknown placeholder, newline,
|
|
303
|
+
whitespace-only, unexecutable first word) — that is the M3.0 contract. When that happens the prompt section is
|
|
304
|
+
replaced by “the notify configuration is unusable; put your summary in the report instead”, so a worker never gets
|
|
305
|
+
a half command to copy. If your CLI is the built-in Pi (empty `TEAM_AGENT_CMD`), the section says so: Pi's notify
|
|
306
|
+
extension already reports the turn end, and the extra command is only run if the PM asked for it.
|
|
307
|
+
|
|
308
|
+
### What counts as “the same briefing” (built-in Pi extension)
|
|
309
|
+
|
|
310
|
+
`extension/team-notify.ts` suppresses an **identical** briefing inside `TEAM_NOTIFY_DEDUP_SEC` (default 20s; `0`
|
|
311
|
+
disables it). The dedup key covers the agent, the summary line, and the length plus a fingerprint of the **whole**
|
|
312
|
+
last assistant message — not the first 60 characters of it, so two different briefings that only share an opening
|
|
313
|
+
are both delivered. Content changes (branch, uncommitted, unpushed) are part of the summary, so a changed state
|
|
314
|
+
re-sends; only a byte-identical repeat inside the window is dropped.
|
|
315
|
+
|
|
316
|
+
## 4a. Delivery to a live session: inbox watch (Pi) vs pasting (everything else)
|
|
317
|
+
|
|
318
|
+
Automated messages (turn-end briefings, `team say`, drafts, pulse wake lines) reach a window in one of two
|
|
319
|
+
ways, and **the channel is chosen by the target, not by the sender**:
|
|
320
|
+
|
|
321
|
+
| Target | Channel |
|
|
322
|
+
|---|---|
|
|
323
|
+
| a Pi session that loaded `extension/team-inbox-watch.ts` (both built-in launch paths pass it with `-e`; a custom Pi-shaped template can add `-e {skill_dir}/extension/team-inbox-watch.ts`) | **inbox watch**: a durable inbox line plus one pointer line in `state/inbox-watch/<key>.wake`; the session's own extension calls `pi.sendMessage({customType:'team-inbox'}, {triggerTurn:true, deliverAs:'followUp'})`. **The input box is never read and never typed into.** |
|
|
324
|
+
| everything else — a custom adapter, a Pi session without the extension, a dead or foreign registration — and the explicit escape hatch (`--now`) | **paste path**: the delivery guard reads the box, defers while it holds a draft, types, verifies the submission in the conversation above the box, and retracts or leaves residue honestly (`references/troubleshooting.md` §3) |
|
|
325
|
+
|
|
326
|
+
Readiness is proven by the session itself: the extension writes `state/inbox-watch/<key>.reg`
|
|
327
|
+
(`target=<session>:<window>`, `inbox=<name>`, `pid`, `cwd`, `started`, `heartbeat`), and a sender routes to the
|
|
328
|
+
watch channel only when a registration matches that exact target, its pid is alive and its `cwd` is inside
|
|
329
|
+
this project — a fresh `heartbeat` is only the fallback when `cwd` is absent (bounded by
|
|
330
|
+
`TEAM_INBOX_WATCH_STALE`, default 300 s), because a heartbeat is not an identity. Deleting the registry on
|
|
331
|
+
`session_shutdown` is part of the contract: a stale file would make senders believe somebody is listening.
|
|
332
|
+
Messaging a session that was started without the extension (or whose registration is gone) simply stays on the
|
|
333
|
+
paste path.
|
|
334
|
+
|
|
335
|
+
What the session receives is a **pointer**: `[teamsmith] inbox wake: N new team message(s)`, one line per
|
|
336
|
+
message (`[kind] from <who> → <inbox>.md :: <truncated preview>`) and where to read the full text. Bursts merge
|
|
337
|
+
into one message, previews are truncated (`TEAM_INBOX_WATCH_PREVIEW`, default 160 chars), and the spool itself
|
|
338
|
+
is bounded (`TEAM_INBOX_WATCH_MAX_BYTES`, default 128 KiB: head dropped, tail kept). A session restart
|
|
339
|
+
re-baselines the spool, so lines written before it started never wake anybody — the pulse's pending check is
|
|
340
|
+
the fallback and its semantics are unchanged.
|
|
341
|
+
|
|
342
|
+
The durable-inbox contract lives in the outbox entry header (it decides who writes the line):
|
|
343
|
+
|
|
344
|
+
| Header | Meaning |
|
|
345
|
+
|---|---|
|
|
346
|
+
| `inbox: <name>` | the channel writes the line when it delivers (the paste path writes it only if the entry ends up held) |
|
|
347
|
+
| `inbox: <name>` + `inbox-written: 1` | the sender already wrote it (`--inbox-written`) — the channel must not write a second line |
|
|
348
|
+
| `inbox: -` + `inbox-written: 1` | no inbox line on purpose: the wake itself is the message and the sender's own log is the record (pulse wake lines) |
|
|
349
|
+
|
|
350
|
+
Knocks (`team notify`, the notify extension) are wakes, not messages: on a watcher-registered PM they take the
|
|
351
|
+
watch channel **without** tmux or PM-liveness heuristics — the registration (`pid` + `cwd`) is the liveness
|
|
352
|
+
evidence — and they never add an inbox line beyond the one their sender already wrote.
|
|
353
|
+
|
|
354
|
+
The session-side ledger is `state/inbox-watch.log` (`started` / `wake n=… kinds=…` / `stopped` lines); the
|
|
355
|
+
sender side records `watch` as the outcome in `state/outbox/delivered.log`.
|
|
356
|
+
|
|
357
|
+
### 4a.2 When the watch channel is absent: the skip record (M46)
|
|
358
|
+
|
|
359
|
+
An absent registration is only *evidence of absence*; the **reason** is written by the session that could not
|
|
360
|
+
register. On every skip path the extension writes `state/inbox-watch/<key>.skip` (same `KEY=VALUE` shape as
|
|
361
|
+
`.reg`: `target`, `session`, `window`, `expect`, `reason`, `detail`, `pid`, `cwd`, `ts`, `heartbeat`) and the
|
|
362
|
+
`skip setup: …` ledger line stays as it was. `reason` is a small closed vocabulary today —
|
|
363
|
+
`session-mismatch` (the session resolved from tmux, or from `TEAM_INBOX_WATCH_TARGET`, is not the project's
|
|
364
|
+
`TEAM_SESSION`; `expect` carries the configured name) and `no-tmux-target` (no `TMUX_PANE` and no override,
|
|
365
|
+
ledger only). A record is **believed only while it is live**: the writing pid must be alive and `cwd` inside
|
|
366
|
+
this project (cwd absent → `heartbeat` within `TEAM_INBOX_WATCH_STALE`), the same identity rule the registry
|
|
367
|
+
uses. A successful registration deletes the records for its target, so the trace cannot outlive the problem.
|
|
368
|
+
|
|
369
|
+
Consumers: `team doctor` prints one `投递通道 inbox-watch` line (`pass` when a live registration exists for the
|
|
370
|
+
PM target, a warning naming the reason otherwise), `team status` and `team digest` print the same warning as
|
|
371
|
+
`投递通道降级: …`, and the panel's `panel.pm.delivery_warning` carries the short reason for the status band.
|
|
372
|
+
The match for a `session-mismatch` record also accepts the **same window name** rather than the exact target,
|
|
373
|
+
because the expected target (`TEAM_SESSION` + `TEAM_PM_WINDOW`) is precisely what is wrong in that shape. The
|
|
374
|
+
state directory these records live in is anchored to the project derived from the process's cwd (the git main
|
|
375
|
+
worktree): an inherited `TEAM_STATE_DIR` that points at **another teamsmith project's** state is refused with
|
|
376
|
+
a `TEAM_IDENTITY_CONFLICT inherited TEAM_STATE_DIR=…` ledger line, so a session can never treat another
|
|
377
|
+
project's state as its home.
|
|
378
|
+
|
|
379
|
+
The paste-path fallback is not a dead end while the channel is missing. Every drain first runs a **read-only**
|
|
380
|
+
residue sweep over terminal holds (`draft-raced*`, `unconfirmed`): if the target's box is gone or no longer
|
|
381
|
+
holds the payload, `outbox/HOLDING.log` gains a `residue-clear entry=… why=box-clear|target-gone` line and the
|
|
382
|
+
status line stops reporting a residue that no longer exists. No keys are ever sent for a terminal entry (the
|
|
383
|
+
specification's "a draft-raced entry is never pasted again" also covers later drains). Held entries whose
|
|
384
|
+
target window no longer exists are marked `target=gone` by `team outbox list`, counted in the status queue
|
|
385
|
+
line, and cleaned only by the explicit `team outbox drop gone` (which names every file it drops).
|
|
386
|
+
|
|
387
|
+
### 4a.1 Delivery semantics: the journal / offset / rescan / caps (M43, P81)
|
|
388
|
+
|
|
389
|
+
The watcher tracks the spool with an **in-memory byte offset** into `state/inbox-watch/<key>.wake`. The only
|
|
390
|
+
in-repo writer appends (`>>`), so a healthy offset never exceeds the file size. The offset is an audit
|
|
391
|
+
position, not the delivery contract — the **delivery journal** is (§4a.1c). These rules hold:
|
|
392
|
+
|
|
393
|
+
1. **A shrink is always external, and it is always recorded.** If the spool's size falls below the offset (or
|
|
394
|
+
the file vanishes while being tracked), something outside the repo truncated/rewrote/replaced it (the
|
|
395
|
+
2026-09-19 incident: an external actor rewrote the PM's spool in place twice within 6 s; the old code
|
|
396
|
+
silently reset `offset = 0` and re-read the whole file — 42 lines were delivered twice and `total` was
|
|
397
|
+
inflated by 84). Now the watcher writes a `spool shrink: size fell below offset=… → bounded rescan from 0`
|
|
398
|
+
ledger line instead of a silent reset.
|
|
399
|
+
2. **No delivery is ever enqueued twice.** Before a wake is sent, the watcher appends the line's identity and
|
|
400
|
+
wake material as a `read` record and then an `intent` record to `state/inbox-watch/<key>.deliver`; after
|
|
401
|
+
the session API returns it appends `sent` (or `failed`). Lines that come back via a rewrite (or overlap
|
|
402
|
+
after a shrink) are skipped and recorded as `replay suppressed n=<n> reason=<normal|rescan>` ledger lines.
|
|
403
|
+
3. **Replays are bounded and explained.** A shrink triggers a *rescan*: the file is re-read from 0, but
|
|
404
|
+
lines with a journal record are dropped and genuinely-new lines are capped to the **most recent**
|
|
405
|
+
`TEAM_INBOX_WATCH_REPLAY_MAX` (default 20); anything older is skipped and the wake text says so
|
|
406
|
+
(`(spool rescan after external shrink: delivered the last K unseen line(s); skipped D already-delivered +
|
|
407
|
+
M older …)`). If everything was already delivered there is **no wake at all** — the ledger's
|
|
408
|
+
`rescan lines=… dup=… skipped=… deliver=0` line is the audit trail.
|
|
409
|
+
|
|
410
|
+
Counter semantics: the ledger's `total=` (and the wake text's `N`) count **real deliveries only** — rescan /
|
|
411
|
+
replay skips never inflate it, and a rescan wake carries a `rescan[dup=D skipped=M]` annotation. The other
|
|
412
|
+
caps are unchanged: previews truncate at `TEAM_INBOX_WATCH_PREVIEW` (160 chars), a wake lists at most 5 lines,
|
|
413
|
+
and the spool's own ceiling is `TEAM_INBOX_WATCH_MAX_BYTES` (128 KiB, head dropped tail kept, offset snapped
|
|
414
|
+
to the new size so the kept tail is not re-announced).
|
|
415
|
+
|
|
416
|
+
Every `wake` ledger line names the wake's `seq=` and the identities it carries; the recovery and suppression
|
|
417
|
+
paths each have their own counter: `replay suppressed n= reason=<normal|rescan>`, `inflight assumed n=`,
|
|
418
|
+
`recovery n=` (on the recovery wake), `unprovable n=`, `deliver blocked`, `torn tail`,
|
|
419
|
+
`baseline swallowed n=`, `retry stale=<n>`. Counters never move `total=`.
|
|
420
|
+
|
|
421
|
+
### 4a.1c The delivery journal: at-most-once, fail-closed, three restart states (P81)
|
|
422
|
+
|
|
423
|
+
The wake is a doorbell; the durable inbox line is the message. `state/inbox-watch/<key>.deliver` is an
|
|
424
|
+
append-only journal and is the **only** durable authority for what may still be woken about — process memory
|
|
425
|
+
is never trusted across a restart. One record per line, ISO-stamped, values escaped so the fields are
|
|
426
|
+
space-separated and reversible:
|
|
427
|
+
|
|
428
|
+
```
|
|
429
|
+
start baseline=<n> size=<n> head=<stamp>
|
|
430
|
+
read seq=<n> off=<n> size=<n> head=<stamp> id=<identity> src=<ms> kind=<k> from=<f> durable=<d> preview=<p>
|
|
431
|
+
intent seq=<n>
|
|
432
|
+
sent seq=<n> (a .seen import writes sent with a negative seq and imported=1)
|
|
433
|
+
failed seq=<n> reason=<why>
|
|
434
|
+
floor id=<oldest retained identity> ts=<floor source time> evicted=<n> kept=<n>
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
- **The order is the contract**: `read` → `intent` → send → `sent`/`failed`. A wake is sent only after its
|
|
438
|
+
`intent` is on disk. If the journal cannot be written the watcher sends **nothing** (not even the one wake
|
|
439
|
+
it was about to send), records `deliver blocked`, and leaves the lines unseen so a later tick can pick
|
|
440
|
+
them up: losing a doorbell is allowed, losing the journal is not.
|
|
441
|
+
- **A line's identity** is the sender's `id=` field (the sixth spool field, the outbox entry name that also
|
|
442
|
+
appears in `state/outbox/delivered.log`) when present, and `sha1:<hex>` of the whole line otherwise. The
|
|
443
|
+
wake text prints exactly this string, so a recipient can resolve an identity against the journal and the
|
|
444
|
+
sender's own log; two byte-identical payloads are distinguishable by identity and source time.
|
|
445
|
+
- **After a restart the state is judged from the journal**, in exactly three states: `read` without `intent`
|
|
446
|
+
(the send never started) → the line is woken about **once** by the recovery pass and the ledger records
|
|
447
|
+
`recovery`; `intent` without `sent`/`failed` → the outcome is unknown, the line is **never** woken again and
|
|
448
|
+
the ledger records `inflight assumed n=` once; `sent` → never again. `failed` means the message never
|
|
449
|
+
entered the session: the line may be retried **at most once per tick** and never after
|
|
450
|
+
`TEAM_INBOX_WATCH_STALE_SEC` (`retry stale=<n>`).
|
|
451
|
+
- **A torn or unparsable trailing record is an unknown outcome, never a licence to re-send**: it reads as the
|
|
452
|
+
`inflight` state (ledger `torn tail`), so a crash while appending the `intent` cannot turn into a duplicate.
|
|
453
|
+
- **Fail-safe past the eviction floor**: past `TEAM_INBOX_WATCH_JOURNAL_MAX` (default 1024) records the
|
|
454
|
+
journal is compacted to just under the bound, keeping whole `read…intent…sent` groups and writing a `floor`
|
|
455
|
+
record (its `ts` is the oldest retained source timestamp). An identity the journal no longer covers and
|
|
456
|
+
whose source time is older than that floor can no longer be proven undelivered → it is counted `unprovable`
|
|
457
|
+
and **never** woken (fail-safe, not fail-open).
|
|
458
|
+
- **One-way `.seen` migration**: on the first start of a target the previous code's `<key>.seen` is imported
|
|
459
|
+
once, additively, as already-delivered identities; from then on deleting, emptying or corrupting
|
|
460
|
+
`<key>.seen` changes no delivery decision (the journal is the memory).
|
|
461
|
+
- **Freshness applies to every path**, including recovery and retry: a line older than
|
|
462
|
+
`TEAM_INBOX_WATCH_STALE_SEC` is counted (`stale=`) and never woken, on the startup baseline, the ordinary
|
|
463
|
+
read, the rescan and the journal's recovery. Its readable copy is the durable inbox line.
|
|
464
|
+
- **Startup accounting**: `started … baseline=<spool size>` still names the current spool end (the baseline
|
|
465
|
+
doctrine is unchanged), and `baseline swallowed n=<n>` counts the complete lines present at startup that no
|
|
466
|
+
journal record covers, so the doctrine's cost is visible instead of silent.
|
|
467
|
+
- **Knobs** (environment-only; no `team config` schema row): `TEAM_INBOX_WATCH_JOURNAL_MAX` (default `1024`) is
|
|
468
|
+
the journal record bound, and `TEAM_INBOX_WATCH_ABORT_AFTER=read|intent` is a **fixture-only** switch
|
|
469
|
+
(`TEAM_SMOKE_FIXTURE=1`) that makes the watcher SIGKILL itself at that write-ahead step for the
|
|
470
|
+
crash-restart fixtures — without the fixture flag it is inert and the ledger records it as ignored.
|
|
471
|
+
|
|
472
|
+
### 4a.1b What a *correct* offset means (P28) — the rule the 2026-09-19 loop violated
|
|
473
|
+
|
|
474
|
+
The shrink/replay rules above only hold if the offset is computed honestly. Three invariants, all of them
|
|
475
|
+
enforced in code and covered by the harness:
|
|
476
|
+
|
|
477
|
+
1. **The offset advances by the bytes actually read** (`readSync`'s return value), and each line is decoded
|
|
478
|
+
**on its own**. The old code derived the offset as `Buffer.byteLength(decoded.slice(...))` — a
|
|
479
|
+
decode→re-encode round trip. One invalid byte (written by the producer, see 2) became U+FFFD (3 bytes), so
|
|
480
|
+
the offset advanced **past** the file size (`19635 > 19634`). That is what made the shrink rule fire on a
|
|
481
|
+
healthy spool, and because the state never converged it re-fired every few seconds, re-delivering old lines.
|
|
482
|
+
A read that starts mid-line must not deliver a fragment either.
|
|
483
|
+
2. **The producer cannot write half a character**: previews are cut with `head -c 700` and passed through
|
|
484
|
+
`iconv -c` so an incomplete multibyte tail is dropped rather than written. (`cut -c1-700` under `LC_ALL=C`
|
|
485
|
+
is byte-wise and was the original source of the invalid line.)
|
|
486
|
+
3. **A shrink needs evidence, and recovery must converge**: the watcher keeps the pair `(size, head
|
|
487
|
+
fingerprint)` (FNV-1a over the first bytes). A size below the offset with an **unchanged head** is repaired
|
|
488
|
+
by backing the offset off by one byte (a lost tail byte, not a rewrite); a **changed head** means an
|
|
489
|
+
external rewrite → exactly one bounded rescan. The same `(size, head)` pair is never rescanned twice, so a
|
|
490
|
+
non-converging case cannot turn into a wake loop.
|
|
491
|
+
|
|
492
|
+
**Only fresh lines wake — on every path.** A line older than `TEAM_INBOX_WATCH_STALE_SEC` (default `900`) is
|
|
493
|
+
classified `stale`: it is still written to the durable inbox file, but it does not wake a session
|
|
494
|
+
(`classify stale=<n> unparsable=<n> inbox=…`; a recovered line that has gone stale is counted `stale=1` and
|
|
495
|
+
not `recovery=`, per `references/troubleshooting.md` §20). A line whose timestamp cannot be parsed is
|
|
496
|
+
delivered (never silently dropped). The ledger separates traffic from recovery: `total=` counts **real
|
|
497
|
+
deliveries only**, while `rescan lines=… dup=… skipped=… deliver=0 stale=… unparsable=…` records recovery and
|
|
498
|
+
the journal counters (`replay suppressed` / `inflight assumed` / `recovery` / `unprovable` / `deliver blocked`
|
|
499
|
+
/ `torn tail` / `baseline swallowed`) name the rest. **A repeated `spool shrink` line with `deliver=0` is a
|
|
500
|
+
defect signal, not noise** — it means the offset is not converging (see `references/troubleshooting.md` §20).
|
|
501
|
+
|
|
502
|
+
## 5. Logs / activity: `TEAM_AGENT_LOG_GLOB`
|
|
503
|
+
|
|
504
|
+
`team monitor --activity` renders Pi session JSONL by default. With `TEAM_AGENT_LOG_GLOB` set, the
|
|
505
|
+
**tail of the newest matching file** is rendered as that agent's activity instead (`{agent}` in the
|
|
506
|
+
pattern → the agent name). Globbing is dependency-free: `*`, `?`, `**`, a leading `~`, and absolute or
|
|
507
|
+
project-relative paths; multiple matches are ordered by mtime.
|
|
508
|
+
|
|
509
|
+
Verified examples (this machine, 2026-09-14):
|
|
510
|
+
|
|
511
|
+
```sh
|
|
512
|
+
TEAM_AGENT_LOG_GLOB='~/.codex/sessions/**/*.jsonl' # codex rollout files
|
|
513
|
+
TEAM_AGENT_LOG_GLOB='~/.local/share/opencode/log/*.log' # opencode rolling log
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Degradation is explicit: if nothing matches, or there are no Pi sessions and no glob, the block stays
|
|
517
|
+
`⚫ no session` and says why; the team status panel above it is untouched. `--json` tags every block with
|
|
518
|
+
`"source": "pi" | "log" | "none"`.
|
|
519
|
+
|
|
520
|
+
### Bounded reads and display safety (F2/F3, M3.3)
|
|
521
|
+
|
|
522
|
+
Activity streams are **untrusted input** (another process writes those files), so the monitor treats them
|
|
523
|
+
as data, not as text for your terminal:
|
|
524
|
+
|
|
525
|
+
- **Only the tail is read, never the whole file.** A log tail is at most
|
|
526
|
+
`--log-tail-bytes` / `TEAM_AGENT_LOG_TAIL_BYTES` bytes — default **64 KiB (65536)**, hard cap **1 MiB
|
|
527
|
+
(1048576)**; a larger value is clamped, a non-numeric/zero value falls back to the default with a
|
|
528
|
+
warning on stderr. Files smaller than the window are read whole (byte-for-byte the old behaviour). A Pi
|
|
529
|
+
session file is read as *head window (`64 KiB`, for the `session` header) + tail window* — the middle is
|
|
530
|
+
skipped. Measured with a 256 MiB log: **~573 MB → 60 MB peak RSS**, and under
|
|
531
|
+
`--max-old-space-size=64` it used to abort with exit 134 and now exits 0.
|
|
532
|
+
- `count` in the `log` block means "lines inside the read window" (for `pi` blocks: events inside the
|
|
533
|
+
windows), and every block carries the bounds it used, so a truncated view is visible instead of
|
|
534
|
+
implied. `--json` adds `tail_limit`, `tail_bytes`, `file_bytes`, `truncated`, `available`, `reason` and
|
|
535
|
+
`sessionPath` (existing fields keep their meaning; nothing is removed).
|
|
536
|
+
- **Control sequences are stripped before rendering** — in the text panel, in live mode and in `--json`
|
|
537
|
+
alike: `OSC` (`ESC ]`, e.g. window title, `OSC 52` clipboard writes), `CSI` (`ESC [`, clear/colour),
|
|
538
|
+
C1 CSI, bare `ESC`, `BEL`, `BS`, `CR`, other C0/C1 controls (except `\n`/`\t`) and bidi control
|
|
539
|
+
characters. Displayed text must not be able to touch the PM's terminal or lie about it.
|
|
540
|
+
- **Unreadable files degrade instead of crashing or silently blanking**: permissions (`EACCES`), FIFOs,
|
|
541
|
+
devices/sockets, a file deleted between glob and read (`ENOENT`), a symlink pointing at a directory, or
|
|
542
|
+
content with NUL bytes (binary) render as `log unreadable` / `session unreadable` + a human-readable `reason`, with
|
|
543
|
+
`"available": false`. FIFOs and devices are never `open`ed for reading (the old whole-file read could
|
|
544
|
+
block forever and freeze the pulse window). A glob that matches nothing, or one that matches a plain
|
|
545
|
+
directory, still degrades to `⚫ no session` exactly as before.
|
|
546
|
+
|
|
547
|
+
How to change the window:
|
|
548
|
+
|
|
549
|
+
```sh
|
|
550
|
+
# one-off / shell only
|
|
551
|
+
TEAM_AGENT_LOG_TAIL_BYTES=262144 team monitor --activity
|
|
552
|
+
node scripts/monitor.mjs --root . --log-glob '…' --log-tail-bytes 262144 # direct call
|
|
553
|
+
|
|
554
|
+
# .pi/team/config.sh — note the export: `team monitor` forwards only TEAM_AGENT_LOG_GLOB explicitly,
|
|
555
|
+
# so a plain assignment stays a shell variable and never reaches monitor.mjs
|
|
556
|
+
export TEAM_AGENT_LOG_TAIL_BYTES=262144
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
The flag wins over the environment variable; the cap wins over both.
|
|
560
|
+
|
|
561
|
+
## 6. Worked example: codex
|
|
562
|
+
|
|
563
|
+
```sh
|
|
564
|
+
# .pi/team/config.sh
|
|
565
|
+
TEAM_AGENT_CMD='codex exec -C {cwd} -m {model} -s workspace-write "$(cat {prompt_file})"'
|
|
566
|
+
TEAM_AGENT_BIN="$HOME/.bun/bin/codex"
|
|
567
|
+
TEAM_AGENT_NOTIFY_CMD='bash {skill_dir}/scripts/team notify pm --from {agent} --from-file {summary_file}'
|
|
568
|
+
TEAM_AGENT_LOG_GLOB='~/.codex/sessions/**/*.jsonl'
|
|
569
|
+
TEAM_AGENT_MODELS="dev=openai/gpt-5.6-terra" # {model} → gpt-5.6-terra (the model name codex itself knows)
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Notes:
|
|
573
|
+
|
|
574
|
+
- `codex exec` is codex's non-interactive mode; `-s workspace-write` (or
|
|
575
|
+
`--dangerously-bypass-approvals-and-sandbox` inside a disposable container) is what lets the worker
|
|
576
|
+
write; `--json` / `-o <file>` give machine-readable output.
|
|
577
|
+
- **Verified on this machine** (2026-09-14, `codex-cli 0.146.1`, `~/.bun/bin/codex`): the dispatch
|
|
578
|
+
window ran codex, which created and committed `greeting-codex.txt` and wrote its report; its notify
|
|
579
|
+
call landed in `docs/team/inbox/pm.md`. (The first run notified the *prompt-file path* instead of a
|
|
580
|
+
summary — that was a teamsmith bug in how the prompt rendered the notify example; since M3.2 the prompt
|
|
581
|
+
never contains worker text at all, the summary goes through `--from-file`.)
|
|
582
|
+
- codex keeps its own sessions under `~/.codex/sessions/**`; teamsmith's `{session_id}` is *not* a codex
|
|
583
|
+
session id. `team resume` means "dispatch the same task again in the same worktree/window"; resuming a
|
|
584
|
+
codex conversation is a codex concern (`codex exec resume …`) and can be added to the template.
|
|
585
|
+
- codex is not on the PATH in this environment (`~/.bun/bin/codex`); pinning `TEAM_AGENT_BIN` to the
|
|
586
|
+
absolute path is exactly what that key is for.
|
|
587
|
+
|
|
588
|
+
## 7. Worked example: opencode
|
|
589
|
+
|
|
590
|
+
```sh
|
|
591
|
+
TEAM_AGENT_CMD='opencode run --model {provider}/{model} --dir {cwd} "$(cat {prompt_file})"'
|
|
592
|
+
TEAM_AGENT_BIN="$HOME/.opencode/bin/opencode"
|
|
593
|
+
TEAM_AGENT_NOTIFY_CMD='bash {skill_dir}/scripts/team notify pm --from {agent} --from-file {summary_file}'
|
|
594
|
+
TEAM_AGENT_LOG_GLOB='~/.local/share/opencode/log/*.log'
|
|
595
|
+
TEAM_AGENT_MODELS="dev=google/gemini-3-flash-preview"
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
**Verified end-to-end on this machine** (no Pi involved): `team dispatch` started opencode in the agent
|
|
599
|
+
window, opencode read the task brief, created and committed the file, wrote
|
|
600
|
+
`docs/team/reports/T1.1-dev.md`, and ran the notify command — the PM inbox received the line. The M3.0
|
|
601
|
+
report keeps the window command, the agent's output tail, the produced report and the inbox line.
|
|
602
|
+
|
|
603
|
+
`opencode run` starts a fresh session per call; use `--continue` / `--session <id>` if you want it to
|
|
604
|
+
continue (opencode's session ids are its own — see the note under codex).
|
|
605
|
+
|
|
606
|
+
## 8. Verifying a new adapter (checklist)
|
|
607
|
+
|
|
608
|
+
1. `team doctor` → the `agent adapter` line resolves the binary; `team paths` shows `agent_adapter`.
|
|
609
|
+
2. `team dispatch <agent> <ID> <task> --print` → read the rendered command: no leftover `{`, and the
|
|
610
|
+
`prompt file` path it prints exists.
|
|
611
|
+
3. Run that command by hand inside the worktree (auth, flags, cwd) before trusting tmux to do it.
|
|
612
|
+
4. Real dispatch, then check: the window shows the CLI; the worker's writes land in the worktree; the
|
|
613
|
+
worker writes its summary file and the notify command lands in `docs/team/inbox/pm.md` (or the PM
|
|
614
|
+
window) with the summary byte-exact (`TEAM_AGENT_NOTIFY_CMD` with `{summary_file}`).
|
|
615
|
+
5. `team monitor --once --activity` → the agent's block shows its Pi session or the configured log tail.
|
|
616
|
+
6. Only then rely on it — gates, reports and `team review` work the same for every adapter.
|
|
617
|
+
|
|
618
|
+
## 9. Intentionally unsupported
|
|
619
|
+
|
|
620
|
+
- **Emulating an agent's internal turn events.** teamsmith does not parse a vendor's private protocol to
|
|
621
|
+
guess "the agent finished thinking". Turn-end notification is the adapter's job
|
|
622
|
+
(`TEAM_AGENT_NOTIFY_CMD`), plus the PM side (`team say`, `inbox`, `roster`).
|
|
623
|
+
- **A notifying PM.** The PM's own CLI is configurable (`TEAM_PM_CMD`, §2), but the notification direction is not
|
|
624
|
+
symmetric: teamsmith has no "the PM's CLI finished a turn" event. A non-Pi PM is woken by the pulse's
|
|
625
|
+
pending-work check (or by a human running `team up`) and reads `team inbox`; it never pushes a turn-end event of
|
|
626
|
+
its own. The built-in Pi PM receives notifications through the inbox-watch channel (§4a); a non-Pi PM (or a Pi
|
|
627
|
+
PM started without the watcher) is still nudged by typing into its window when it is alive (`team notify pm`,
|
|
628
|
+
the pulse nudge) — that path works for a non-Pi PM too, because it only checks that the pane is busy, not which
|
|
629
|
+
CLI runs.
|
|
630
|
+
- **Interpolating worker text into a shell line.** A summary is data: it arrives through a file
|
|
631
|
+
(`{summary_file}` / `team notify --from-file`). `{summary}` is rendered as a quoted file read for
|
|
632
|
+
compatibility, but nothing a worker writes is ever re-interpreted by a shell — there is no supported way
|
|
633
|
+
to make a summary part of a command's text.
|
|
634
|
+
- **Multiplexing per-agent streams out of one shared log.** `{agent}` is a filename placeholder, not a
|
|
635
|
+
stream splitter; point the glob at per-agent files (or accept one shared tail).
|
|
636
|
+
- **Replacing the PM's own CLI by *guessing* it.** The PM side is part of the same internal seam (frozen) (§2), but
|
|
637
|
+
teamsmith will not infer a
|
|
638
|
+
launch command for you: without `TEAM_PM_CMD` it uses the built-in Pi command, and a custom CLI needs an explicit
|
|
639
|
+
template (otherwise the same `pi` command is attempted and fails inside `pi`).
|
|
640
|
+
- **CLIs that cannot accept a prompt non-interactively** (prompt only via a human TUI). Use
|
|
641
|
+
`{prompt_file}` if the CLI can read a file or stdin; otherwise the agent cannot be dispatched by
|
|
642
|
+
teamsmith.
|
|
643
|
+
- **New runtime dependencies.** Everything here is bash plus the CLI you install yourself.
|