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.
- package/README.md +16 -8
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +55 -0
- package/skills/teamsmith/SKILL.md +18 -7
- package/skills/teamsmith/extension/team-bg.ts +47 -11
- package/skills/teamsmith/extension/team-notify.ts +143 -4
- package/skills/teamsmith/references/agent-adapters.md +7 -7
- package/skills/teamsmith/references/config.md +29 -15
- package/skills/teamsmith/references/migration.md +38 -2
- package/skills/teamsmith/references/openspec.md +23 -9
- package/skills/teamsmith/references/protocol.md +81 -13
- package/skills/teamsmith/references/workflows.md +31 -19
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
- package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
- package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
- package/skills/teamsmith/scripts/lib/cmd-project.sh +134 -17
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
- package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
- package/skills/teamsmith/scripts/lib/common.sh +797 -71
- package/skills/teamsmith/scripts/monitor.mjs +34 -3
- package/skills/teamsmith/scripts/panel/README.md +22 -11
- package/skills/teamsmith/scripts/panel/panel.js +217 -215
- package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
- package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
- package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
- package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
- package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
- package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
- package/skills/teamsmith/scripts/replies.mjs +893 -0
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
- package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
- package/skills/teamsmith/templates/config.sh.tmpl +10 -5
- package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -1
- package/skills/teamsmith/templates/report.md.tmpl +12 -0
- package/skills/teamsmith/templates/task.md.tmpl +4 -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 +287 -58
- package/skills/teamsmith/tests/config-cli.sh +162 -288
- package/skills/teamsmith/tests/death-cause.sh +5 -2
- package/skills/teamsmith/tests/install-shape.sh +4 -2
- package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
- package/skills/teamsmith/tests/key-replies.sh +1075 -0
- package/skills/teamsmith/tests/ledger-ban.sh +5 -5
- package/skills/teamsmith/tests/ledger-claim.sh +247 -0
- package/skills/teamsmith/tests/lib/checkout-shape.sh +66 -14
- package/skills/teamsmith/tests/lib/model-policy.sh +26 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +136 -0
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
- package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +372 -0
- package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
- package/skills/teamsmith/tests/panel-b2.sh +1 -1
- package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
- package/skills/teamsmith/tests/panel-b3.sh +14 -10
- package/skills/teamsmith/tests/panel-choices.sh +74 -61
- package/skills/teamsmith/tests/panel-cpu.sh +1 -1
- package/skills/teamsmith/tests/panel-p21.sh +311 -190
- package/skills/teamsmith/tests/perf.sh +1 -1
- package/skills/teamsmith/tests/pm-box-real.sh +1 -1
- package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
- package/skills/teamsmith/tests/routes.sh +43 -22
- package/skills/teamsmith/tests/section-budgets.tsv +9 -5
- package/skills/teamsmith/tests/section-paths.tsv +26 -16
- package/skills/teamsmith/tests/section-select.sh +99 -16
- package/skills/teamsmith/tests/smoke.sh +930 -216
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
- package/skills/teamsmith/tests/task-header-model.sh +2 -1
- package/skills/teamsmith/tests/task-model-routing.sh +1014 -0
- package/skills/teamsmith-init/SKILL.md +38 -38
- package/skills/teamsmith-init/references/bootstrap.md +6 -4
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
package/README.md
CHANGED
|
@@ -56,14 +56,14 @@ than replaced (`--force` replaces only an entry recognised as this skill).
|
|
|
56
56
|
### As a Pi package (no global CLI)
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
pi install git:git@github.com:Track07-cda/teamsmith@v0.
|
|
60
|
-
pi install -l git:git@github.com:Track07-cda/teamsmith@v0.
|
|
59
|
+
pi install git:git@github.com:Track07-cda/teamsmith@v0.2.0 # user level: every project
|
|
60
|
+
pi install -l git:git@github.com:Track07-cda/teamsmith@v0.2.0 # project level: recorded in .pi/settings.json
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
- **Pin a released tag**: `@v<version>`, the version `team version` prints. Latest tag:
|
|
64
64
|
`git tag --sort=-v:refname | head -1`.
|
|
65
|
-
- The `git@github.com:` form (or `ssh://git@github.com/Track07-cda/teamsmith@v0.
|
|
66
|
-
whether or not you have a token; the shorthand `git:github.com/Track07-cda/teamsmith@v0.
|
|
65
|
+
- The `git@github.com:` form (or `ssh://git@github.com/Track07-cda/teamsmith@v0.2.0`) uses your SSH key and works
|
|
66
|
+
whether or not you have a token; the shorthand `git:github.com/Track07-cda/teamsmith@v0.2.0` takes the HTTPS
|
|
67
67
|
route, so it works anonymously on the public repository and asks for credentials if your access is private.
|
|
68
68
|
- The clone lands in `~/.pi/agent/git/<host>/<path>` (user level) or `.pi/git/<host>/<path>` (project level); the
|
|
69
69
|
skill directory — the `<skill>` used in every command below — is `<clone>/skills/teamsmith`.
|
|
@@ -116,16 +116,24 @@ No forge dependency: the PM uses `git`/`gh`/`glab` directly, and cross-project c
|
|
|
116
116
|
## Quickstart (in a project repo)
|
|
117
117
|
|
|
118
118
|
1. **Bring the project up** — ask your agent to run the `teamsmith-init` skill. It settles the questions with you
|
|
119
|
-
(session and roster,
|
|
119
|
+
(session and roster, the task-category model map and the independent PM model, gates, VCS mode, patrol rhythm),
|
|
120
|
+
shows the plan, then writes it:
|
|
120
121
|
|
|
121
122
|
```bash
|
|
122
123
|
bash <skill>/scripts/team bootstrap --print # the plan; writes nothing
|
|
123
|
-
bash <skill>/scripts/team bootstrap
|
|
124
|
+
bash <skill>/scripts/team bootstrap --agents "dev verify" \
|
|
125
|
+
--task-models 'routine=vendor/light analysis=vendor/strong verify=vendor/strong' --pm-model 'vendor/strong:high'
|
|
124
126
|
bash <skill>/scripts/team doctor # self-check: git/tmux/agent CLI/dependencies/gates/capacity
|
|
125
|
-
openspec init --tools pi # required dependency: spec root + the
|
|
127
|
+
openspec init --tools pi # required dependency: spec root + the generated phase commands
|
|
128
|
+
# (a pin without a `verify` workflow — 1.8.0 has only `core` —
|
|
129
|
+
# does not generate `opsx-verify`; see references/openspec.md §6)
|
|
126
130
|
```
|
|
127
131
|
|
|
128
|
-
|
|
132
|
+
A fresh project must pass `--task-models` and `--pm-model` (there is no default model to guess); a project whose
|
|
133
|
+
config already carries a valid policy may re-enter without them, and a config still on the retired worker keys is
|
|
134
|
+
refused before any side effect and migrates through `team config upgrade-models` (see
|
|
135
|
+
`skills/teamsmith/references/migration.md` §5b). `bootstrap` is idempotent and prints the `git worktree add`
|
|
136
|
+
command for each agent (git stays with the PM).
|
|
129
137
|
|
|
130
138
|
2. **Dispatch the first task**:
|
|
131
139
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamsmith",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Turn one agent session into a project owner: self-contained task briefs dispatched to worker agents in their own git worktrees, independent verification on a separate checkout, and an auditable ledger (BOARD / reviews / threads / DECISIONS). Runs on Pi today.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -5,6 +5,61 @@
|
|
|
5
5
|
> `SKILL.md`/`references/**`/`templates/**`/`extension/**` 在 Pi 里输入 `/reload`(或 `/pi-team-reload`)即生效;
|
|
6
6
|
> 判断自己是不是旧的:`team mark-loaded`(开局记一次)→ `team version --check`。
|
|
7
7
|
|
|
8
|
+
## v0.2.0 · 2026-10-14
|
|
9
|
+
|
|
10
|
+
功能版:**按任务类别分配模型**(含破坏式配置迁移)、**Pulse 关键回复页**,以及长作业车道的提示词侧。
|
|
11
|
+
|
|
12
|
+
### ⚠️ 破坏性变化:项目的模型配置换形状
|
|
13
|
+
|
|
14
|
+
旧的 `TEAM_AGENT_MODELS`(按席位)与 `TEAM_DEFAULT_MODEL` **不再被接受**:旧项目在任何写入之前就被拒绝,
|
|
15
|
+
并指向升级命令。新形状是「**任务类别 → 模型**的映射 + PM 自己的模型」:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
team config upgrade-models --task-models 'code=provider/model verify=… analysis=…' --pm-model 'provider/model'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
语义上也变了:**一个任务固定一个模型与会话**——续跑复用该任务记录里的模型与会话(不再回落到席位配置),
|
|
22
|
+
**换模型必须新会话**(因为闭源模型的推理状态不能跨模型接续;这条是 Pi 的边界,Teamsmith 只约束自己的调用)。
|
|
23
|
+
|
|
24
|
+
- **任务类别模型路由**(task-model-routing):派单按任务书的 `category:` 解析模型(`--model` 仍可显式覆盖);
|
|
25
|
+
类别词汇是**项目数据**(`routine/analysis/verify` 只是示例,不是引擎的固定集合,映射为空才非法);
|
|
26
|
+
派单预览与 `team ps` 显示类别、最终模型与来源;面板新增类别编辑与「策略 vs 实际」分离的读面。
|
|
27
|
+
- **Pulse 关键回复页**(pulse-key-replies):`team reply post` 显式发布一份要保留的正文(只从 stdin 读),
|
|
28
|
+
固定槽位索引 + 不可变原文 + 文件锁;面板第五页按时间列出并能看全文——**PM 的关键答复不再被聊天流埋掉**。
|
|
29
|
+
- **长作业车道:工人提示词侧**(long-job-suspend B 刀):开场简报把「挂起等作业」写成**第三种合法回合结束
|
|
30
|
+
状态**(交付 / 硬阻塞 / 挂起),并要求点名在等哪个作业;「必须回合结束前收割」的旧措辞清零。
|
|
31
|
+
配套:`state/bg.log` 的 `start`/`wait` 记录让「起了就等」可数,收件箱标签把挂起与中断分开(A 刀在 0.1.2)。
|
|
32
|
+
|
|
33
|
+
### 门禁与工具面
|
|
34
|
+
|
|
35
|
+
- **路由前门进闸门**(P238):13 组路由测试以前只能手工跑,现在 `§61`(FAST 12 组 / live 13 组)承接;
|
|
36
|
+
`§61b` 是 22 臂变异自检(live 专跑、FAST 里可见跳过);**每一组单独可跑**(此前 `pm` 组单独跑会因缺前置
|
|
37
|
+
连锁红 29 条);选段归属不再把新测试文件归到无关段。
|
|
38
|
+
- **账本禁令对报告类改动开火**(P239):账本文本的任何改动都会选中 `§60`,归属于承载检查的那一段;
|
|
39
|
+
扫描面从「只读 `.md`」扩到 `docs/team` 下**每个会被提交的文件**(`ledger/*.tsv` 从前是盲区,植入泄漏会假绿)。
|
|
40
|
+
- **归档前置判据认 squash 合并**(P244):`team change status` 的「分支是否已并入」改用内容等价判定
|
|
41
|
+
(`-z` 逐字节读路径,非 ASCII / 含引号 / 含反斜杠的路径名不再造成**假阳**)。
|
|
42
|
+
- **发布检查跟上改写后的形状**(P247):取「HEAD 可达的最新 tag」并提示不在历史里的旧 tag
|
|
43
|
+
(本仓那 29 个已删);`team init` 路线按新配置合同传参。
|
|
44
|
+
- **临时根与容量**(P141/P144):派单前的容量地板增加磁盘/inode 两腿;陈旧夹具根的清扫有安全下限。
|
|
45
|
+
- 本版另修了预算表两行的 band 规则、以及 PM 记错合并选段的流程问题(见 `docs/team/DECISIONS.md`)。
|
|
46
|
+
|
|
47
|
+
## v0.1.2 · 2026-10-13
|
|
48
|
+
|
|
49
|
+
补丁版:把「长作业车道」的工具侧修复和发布机器一起发出去。
|
|
50
|
+
|
|
51
|
+
- **长作业车道:起完就结束回合**(long-job-suspend A 刀 + P236 返工):工具说明不再要求「回合结束前
|
|
52
|
+
必须收割」——完成叫醒会把结果带回来,原地等只限「作业很短」或「结果卡住下一步且确实没别的可做」。
|
|
53
|
+
后台作业的 `start`/`wait` 两类记录写进 `state/bg.log`,`waited_s` 只量本次调用等待的时间。
|
|
54
|
+
- **挂起与中断分得开**:回合结束且确实在等自己的作业时,收件箱标 `[auto·suspended]` 并带 `awaiting=<id>`;
|
|
55
|
+
判据按 `.job` 记录的 `cwd` 归属到本会话自己的工作树(缺字段/相对路径/解析失败一律不判挂起)。
|
|
56
|
+
修前形状:只要项目里任何一个席位在做长作业,其他席位每次结束回合都会被误标(真实运行中出现四次)。
|
|
57
|
+
- **发布机器进仓并跟上改写后的形状**(P229/P233):`docs/team/tools/release-check.sh` 与
|
|
58
|
+
`publish-public.sh` 从仓外搬回仓库跟踪(此前被 ignore,坏了两周无人知),检查对象改为
|
|
59
|
+
「本仓即公开仓」:六处版本落点、最新 tag 必须等于版本且 HEAD 就在 tag 上、公开面泄漏扫描(产品面
|
|
60
|
+
查全部形状、账本面查凭据形状)、公开面不变量、三条安装路线;`--self-test` 跑真检查对四棵变异树。
|
|
61
|
+
发布清单 `docs/team/RELEASE-PUBLIC.md` 按新模型重写。
|
|
62
|
+
|
|
8
63
|
## v0.1.1 · 2026-10-04
|
|
9
64
|
|
|
10
65
|
首个发布(v0.1.0)之后当天合并的修复 —— 其中两条直接影响使用者:
|
|
@@ -3,7 +3,7 @@ name: teamsmith
|
|
|
3
3
|
description: teamsmith gives one agent real ownership of a project — it plans, writes self-contained task briefs, dispatches worker agents into their own tmux windows and git worktrees, verifies their work on an independent checkout, merges, and keeps an auditable ledger (BOARD/reviews/threads/DECISIONS). A pulse window (the periodic patrol) wakes the owner only when there is pending work, and the owner can deliberately stand down. Works with Pi; the launch/notify seam is an internal seam (frozen) reserved for a possible future non-Pi adapter, with no compatibility promise. Use when the user wants an agent to own a project end to end, dispatch tasks to worker agents, run agents in parallel in tmux with git worktree isolation, act as a PM/orchestrator over other agents, review an agent's work independently, run the patrol (`pulse`) as a tmux window, wake the PM only when there is pending work, or resume and coordinate a multi-agent project. To start a new project, use the teamsmith-init skill.
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
|
-
version: "0.
|
|
6
|
+
version: "0.2.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# teamsmith · one agent that actually owns the project
|
|
@@ -48,20 +48,21 @@ everything below is the daily loop, which starts once the project is up.
|
|
|
48
48
|
|
|
49
49
|
| Goal | Command |
|
|
50
50
|
|---|---|
|
|
51
|
-
| Init / self-check | `team init [--session s] [--agents "a b"] [--vcs local\|remote] [--copy\|--no-skills]` (installs both skills into the project's `.pi/skills
|
|
51
|
+
| Init / self-check | `team init [--session s] [--agents "a b"] [--vcs local\|remote] --task-models '<category=provider/model …>' --pm-model '<provider/model>' [--copy\|--no-skills]` (fresh projects must pass both model inputs; installs both skills into the project's `.pi/skills/`), `team doctor` (reports that install, warns on drift) |
|
|
52
52
|
| Observe | `team roster` (windows/branch/dirty/ahead), `team status [ID]`, `team ps` (capacity + model limits + PM/pulse liveness), `team digest` (PM's pending work) |
|
|
53
53
|
| Inbox | `team inbox [agent] [--ack] [--all]` |
|
|
54
|
+
| Key replies | `team reply post --from <seat> --title "<short>" --stdin` (publish the body you are about to send; a saved receipt means project-local durable publication only — never user delivery, approval, read status or a refreshed console), `team reply list [--before <no>] [--json]`, `team reply show <no> [--json\|--raw]` (readers are observation-only: no mkdir, no writes, no lock; `--raw` exports the original bytes and refuses a TTY). The console's page 5 shows the latest reply plus the numbered history. See `references/protocol.md` §4b |
|
|
54
55
|
| Document contracts | `team task <ID> --title ... --agent a`, `team board add\|assign\|set\|ls`, `team change status <id> [--json]` (readiness view: tasks/evidence, declared vs touched delta files, blockers; exit 0 iff every mapped task is finished), `team thread <a> "..." --from pm --re <ID>`, `team report <ID> <a>` |
|
|
55
|
-
| Dispatch | `team add-agent <a> [--register] [--
|
|
56
|
+
| Dispatch | `team add-agent <a> [--register] [--create] [--no-install] [--print]`, `team dispatch <a> <ID> <taskfile> [--model m] [--branch <name>] [--fresh] [--allow-overflow] [--force] [--print]` (a new dispatch selects the brief's `category:` model from `TEAM_TASK_MODELS` unless `--model` overrides; same-task recovery keeps the committed model/SID; all pre-launch guards are judged in **one pass**: one refusal lists every blocker, each with a paste-able `修法:<command>` or `改行:<exact line>` and a final count line; `--force` overrides only the guards that carry an override, printed as a warning and logged after a real launch) |
|
|
56
57
|
| Collaborate | `team say <a> "<one-line message>" [--no-verify]` (verifies delivery; falls back to the inbox when the agent is not running), `team notify <a> "<one line>" [--from <sender>]` (agent → PM; the sender comes from the runtime directory — an unresolved sender is refused, never recorded as `pm`) |
|
|
57
58
|
| Draft / deferred delivery | `team draft [pm]` opens an editor window on `state/draft-pm.md` (nothing automated ever types into it; save+quit enqueues through the guarded path and prints the ack there), `team draft send [<file>] [--now]` (headless form), `team outbox [list]` (what is waiting, with `held` reasons), `team outbox flush [--now]`, `team outbox drop <n\|all>`. Every automated sender refuses to type into an input box that already holds a draft: the message is queued in `state/outbox/` and reported as `queued`; a `geometry-untrusted` read (the supported Pi layout cannot be established) or three trusted-empty drains with no progress (`queue-stalled`) hold the entry durably with its reason and **exit non-zero**, never promising an automatic delivery. `--now` is the audited override that types anyway (`state/outbox/forced.log`). See `references/troubleshooting.md` §3 |
|
|
58
59
|
| Long gate (background job) | **tool calls in the session** (not `team` subcommands): `team_bg_run` starts a detached job (id + pid at once, `state/bg/<id>.log`), `team_bg_wait <id>` harvests it (exit code + log tail inline). One merged wake-up per finished batch, silence once harvested, one `settled-with-unharvested=<n>` line per turn end in `state/bg.log`. Injected on both built-in Pi paths; a custom template opts in with `{bg_ext}`. The lane's records are readable and stoppable from the CLI: `team bg list` (one row per record, signals nothing), `team bg stop <id>` (signals only the recorded job — the `(pid, start-time)` pair is the identity, a reused pid is refused). Inside a window `pkill`/`killall` are the signal gate and refuse every name/pattern selection with exit 64. See `references/workflows.md` §E2 |
|
|
59
60
|
| Verify | `team review <ID> --dir <PM-prepared independent checkout> [--no-gates] [--strong] [--allow-unresolved-branch]` → `reviews/<ID>.md` (runs gates + writes evidence; refuses a dirty or `.gitignore`d checkout / an unresolvable `--branch` unless the matching `TEAM_REVIEW_ALLOW_*` override is used and recorded; `--strong` structurally checks flip evidence + a path to an independent package) |
|
|
60
61
|
| Wrap up | `team close <ID> [--keep-window]` (BOARD/state/window only, never git), `team teardown --agent a [--purge] [--register]` (explicit cleanup; `--register` removes the seat from the roster through the audited writer first) |
|
|
61
|
-
| Bootstrap | `team bootstrap [--agents "dev verify"] [--print]` (recommended), `team init`, `team doctor` |
|
|
62
|
+
| Bootstrap | `team bootstrap [--agents "dev verify"] --task-models '<map>' --pm-model '<model>' [--print]` (recommended; both model inputs are required on a fresh project, a valid policy is kept on re-entry, a legacy config is refused before any side effect and points at `team config upgrade-models`), `team init`, `team doctor` |
|
|
62
63
|
| Patrol (pulse) | `team pulse up\|down\|restart\|status\|logs` (a `pulse` window in the same session runs the monitor + periodic patrol; single backend). Renamed from `watchdog` in v1.36.0: `team watchdog …`, `watchdog-status`, `install-watchdog`, `uninstall-watchdog` still work as aliases until v2.0.0 (they print a one-line deprecation notice first). `team watch [--once]` (foreground patrol) |
|
|
63
64
|
| Monitor | `team monitor [--once] [--activity]` (**serves the current tmux session only**: who is running / tasks / pending / capacity; `--activity` adds per-agent activity streams, off by default), `team panel` reuses it. The TUI's own preferences live in `state/panel.conf` (language, page, activity, mouse, density, theme) — runtime state, not project config, and `--print`/`--json` never read it |
|
|
64
|
-
| Project settings | `team config list [--json]` / `team config set <KEY> <VALUE> [--dry-run] [--fingerprint <sha256>] [--actor <name>] [--allow-danger]` / `team config log [N]` / `team config set-
|
|
65
|
+
| Project settings | `team config list [--json]` / `team config set <KEY> <VALUE> [--dry-run] [--fingerprint <sha256>] [--actor <name>] [--allow-danger]` / `team config log [N]` / `team config set-task-model <category> <model>` / `team config upgrade-models --task-models '<map>' --pm-model '<model>' [--dry-run\|--yes]`: the only writer of `.pi/team/config.sh` (comment/order preserving, single-quote form, value validation, danger list, sha256 CAS, one audit line per attempt in `state/config.log`). Model policy is the task-category map plus the independent PM model; the retired seat front doors (`set-agent-model`, `add-agent --model`) refuse and point here. The console's project-settings view (settings overlay → `项目设置`) lists every key with its effect class (`apply`/`restart`/`refuse`) and edits through this command; see `references/config.md` §5 |
|
|
65
66
|
| PM/agent lifecycle | `team up [--agents]` (recover the PM), `team resume` (PM's tool: continue stopped agents), `team standby on\|off` (PM deliberately stands down) |
|
|
66
67
|
| Cross-project meetings | `team meeting open/say/read/list/inbox/propose/agree/close` (PM-to-PM peer exchange: interface work, advice, problem reports; **not a command channel** — consensus needs both sides) |
|
|
67
68
|
| Updates | `team mark-loaded` (record the version at session start), `team version --check` (should I reload?), `team changelog [--since X]`, `team reload` |
|
|
@@ -95,8 +96,12 @@ when they conflict, the creed wins and the process gets fixed.
|
|
|
95
96
|
|
|
96
97
|
1. **Model the work**: `team doctor`, `init` if needed; break the user's request into milestones in `ROADMAP.md`
|
|
97
98
|
and write each task as a **self-contained brief** (context / deliverables / boundaries / copy-pasteable
|
|
98
|
-
acceptance commands / report requirements) —
|
|
99
|
-
|
|
99
|
+
acceptance commands / report requirements) — a routine category usually runs a fast model that will not fix
|
|
100
|
+
vague requests, so the brief carries the whole context.
|
|
101
|
+
2. **Dispatch**: `team dispatch <a> <ID> <taskfile>`. Check `team ps` (memory / model concurrency) first. The
|
|
102
|
+
brief's `category:` picks the model from `TEAM_TASK_MODELS` (routine for bounded work, analysis for complex
|
|
103
|
+
planning/judgment, verify for independent adversarial review — the project may use other category names);
|
|
104
|
+
record the rationale in the brief prose when the choice is not obvious.
|
|
100
105
|
One long-lived worktree per agent; dispatching again to the same agent resumes its session, use `--fresh` for a
|
|
101
106
|
new one. The brief's `change:`/`specs:`/`anchor:`/`deltas:` lines are checked **before the window opens**: one
|
|
102
107
|
change id per task (no override), a change-less brief must declare a resolvable anchor, two unfinished tasks of
|
|
@@ -241,6 +246,12 @@ about them). They stay writable so the seam can be maintained and diagnosed; to
|
|
|
241
246
|
## Non-negotiable rules (verified during review)
|
|
242
247
|
- **Never claim something passed without having run it.** Reports must include commands and output tails; the PM
|
|
243
248
|
re-runs independently.
|
|
249
|
+
- **Publish the body before you answer.** Before sending a substantive answer, publish that same body with
|
|
250
|
+
`team reply post --from <seat> --title "<short>" --stdin`, then send the answer normally — saved, input error,
|
|
251
|
+
storage error, busy or unconfirmed never changes what you send (the failure notice goes to stderr, never into the
|
|
252
|
+
answer). A saved receipt means project-local durable publication only: not user delivery, not approval, not read
|
|
253
|
+
status, not a refreshed console, and it creates no pending work, no outbox/inbox entry and no wake-up. See
|
|
254
|
+
`references/protocol.md` §4b.
|
|
244
255
|
- Agents only touch directories they own (`OWNERSHIP.md`); cross-directory needs → write `BLOCKED:` in the report.
|
|
245
256
|
- Agents must not push the protected branch, force-push, merge PR/MRs, or rebase/delete other people's branches.
|
|
246
257
|
- Tokens live in project token files (`TEAM_TOKEN_FILE` / `TEAM_GITLAB_TOKEN_FILE`, gitignored) and are injected by
|
|
@@ -24,6 +24,7 @@ import { dirname, join, resolve } from 'node:path'
|
|
|
24
24
|
|
|
25
25
|
type Job = {
|
|
26
26
|
id: string
|
|
27
|
+
root: string // 起作业时解析到的车道根 —— 账本/记录/wait 行都落它下面(会话中途换 cwd 也不漂)
|
|
27
28
|
pid: number
|
|
28
29
|
command: string
|
|
29
30
|
cwd: string
|
|
@@ -45,6 +46,20 @@ const TRUNC_MARK = '[team-bg] truncated: output exceeded the log cap, earlier ou
|
|
|
45
46
|
const CMD_DISPLAY_MAX = 100 // 结果文本里命令的码点上限(超出 → 前 100 码点 + …)
|
|
46
47
|
const CMD_ELLIPSIS = '…'
|
|
47
48
|
|
|
49
|
+
/**
|
|
50
|
+
* 车道口径(design 决策 1,单一来源)——两个工具的 description / snippet / guidelines / 起作业回执
|
|
51
|
+
* 都从这里取材,门禁(tests/bg-ledger.sh)逐字钉住:
|
|
52
|
+
* ① 起完**默认结束回合**;
|
|
53
|
+
* ② 作业完成时的**叫醒是正常收割点**(多条合并成一条,不是损失);
|
|
54
|
+
* ③ **原地等是有界例外**:预算(约 2 分钟)+ 结果卡住下一步 + 没有别的任务可推进,三条**同时**成立。
|
|
55
|
+
* 任何面都不得再出现「回合结束前必须收割」的措辞,也不得把叫醒写成惩罚/损失。
|
|
56
|
+
*/
|
|
57
|
+
const INLINE_WAIT_BUDGET = '~2 minutes'
|
|
58
|
+
const SUSPEND_DEFAULT =
|
|
59
|
+
'End your turn after starting; the completion wake-up (several completions merge into one message) is the normal harvest point.'
|
|
60
|
+
const INLINE_WAIT_EXCEPTION =
|
|
61
|
+
`Wait inline only in the bounded exception: all three must hold -- the job should finish within the inline-wait budget (${INLINE_WAIT_BUDGET}), its result blocks your immediate next step, and no other task work can advance meanwhile.`
|
|
62
|
+
|
|
48
63
|
/**
|
|
49
64
|
* 定位**本会话自己的根**:team-bg 的产物(作业日志、账本、合并窗口)都是会话本地的,
|
|
50
65
|
* 必须落在会话自己的工作树里 —— worktree 会话 = 它的 worktree,主工作树会话 = 主工作树。
|
|
@@ -258,12 +273,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
258
273
|
label: 'Team background job',
|
|
259
274
|
description:
|
|
260
275
|
'Start a long command (a gate, a build) as a detached background job and return immediately with a job id. ' +
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
promptSnippet:
|
|
276
|
+
`Output goes to state/bg/<id>.log (bounded). ${SUSPEND_DEFAULT} Then run team_bg_wait <id> there to harvest it. ` +
|
|
277
|
+
INLINE_WAIT_EXCEPTION,
|
|
278
|
+
promptSnippet:
|
|
279
|
+
'team_bg_run: start a long command in the background and end your turn ' +
|
|
280
|
+
'(returns a job id immediately; the completion wake-up is the normal harvest point)',
|
|
264
281
|
promptGuidelines: [
|
|
265
|
-
|
|
266
|
-
'(a turn must not end with unharvested background jobs).',
|
|
282
|
+
`Use team_bg_run for long gates or builds. ${SUSPEND_DEFAULT} ${INLINE_WAIT_EXCEPTION}`,
|
|
267
283
|
],
|
|
268
284
|
parameters: {
|
|
269
285
|
type: 'object',
|
|
@@ -295,11 +311,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
295
311
|
closeSync(fd)
|
|
296
312
|
}
|
|
297
313
|
const job: Job = {
|
|
298
|
-
id, pid: child.pid ?? 0, command, cwd, log, startedAt: Date.now(),
|
|
314
|
+
id, root, pid: child.pid ?? 0, command, cwd, log, startedAt: Date.now(),
|
|
299
315
|
done: false, exitCode: null, harvested: false, notified: false, waiters: [],
|
|
300
316
|
}
|
|
301
317
|
jobs.set(id, job)
|
|
302
|
-
if (job.pid > 0)
|
|
318
|
+
if (job.pid > 0) {
|
|
319
|
+
writeJobRecord(root, job)
|
|
320
|
+
// 起作业的账本行:与 .job 记录同一点位、返回 job id **之前**写(design 决策 6)。
|
|
321
|
+
// 「起了就等」与「挂起后被叫醒再收」从此只凭 state/bg.log 就能分开数。
|
|
322
|
+
appendLedger(root, `start id=${id} pid=${job.pid}`)
|
|
323
|
+
}
|
|
303
324
|
child.on('exit', (code: number | null) => finishJob(root, job, code))
|
|
304
325
|
child.on('error', (error: Error) => {
|
|
305
326
|
appendLedger(root, `spawn-error id=${id} ${String(error?.message ?? error)}`)
|
|
@@ -310,7 +331,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
310
331
|
trimTimer = setInterval(() => { for (const j of jobs.values()) if (!j.done) trimLog(j.log) }, TRIM_EVERY_MS)
|
|
311
332
|
}
|
|
312
333
|
return {
|
|
313
|
-
content: [{ type: 'text', text: `job ${id} started (pid ${job.pid}); log: ${log}\n cmd: ${displayCmd(command)}\
|
|
334
|
+
content: [{ type: 'text', text: `job ${id} started (pid ${job.pid}); log: ${log}\n cmd: ${displayCmd(command)}\n${SUSPEND_DEFAULT} Harvest job ${id} with team_bg_wait when that wake-up arrives (the result comes back inline). ${INLINE_WAIT_EXCEPTION}` }],
|
|
314
335
|
details: { id, pid: job.pid, log, cwd, cmd: command },
|
|
315
336
|
}
|
|
316
337
|
},
|
|
@@ -319,8 +340,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
319
340
|
pi.registerTool({
|
|
320
341
|
name: 'team_bg_wait',
|
|
321
342
|
label: 'Team background job wait',
|
|
322
|
-
description:
|
|
323
|
-
|
|
343
|
+
description:
|
|
344
|
+
'Wait for a job started by team_bg_run, harvest it and return its exit code plus the log tail inline. ' +
|
|
345
|
+
`${SUSPEND_DEFAULT} ${INLINE_WAIT_EXCEPTION}`,
|
|
346
|
+
promptSnippet:
|
|
347
|
+
'team_bg_wait: harvest a team_bg_run job (waits if it is still running; the completion wake-up is the normal harvest point)',
|
|
324
348
|
parameters: {
|
|
325
349
|
type: 'object',
|
|
326
350
|
properties: {
|
|
@@ -330,7 +354,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
330
354
|
required: ['id'],
|
|
331
355
|
additionalProperties: false,
|
|
332
356
|
} as any,
|
|
333
|
-
async execute(_toolCallId: string, params: any, signal: any) {
|
|
357
|
+
async execute(_toolCallId: string, params: any, signal: any, _onUpdate: any, ctx: any) {
|
|
334
358
|
const job = jobs.get(String(params?.id ?? ''))
|
|
335
359
|
if (!job) {
|
|
336
360
|
const known = [...jobs.keys()].join(', ') || '(none)'
|
|
@@ -340,23 +364,35 @@ export default function (pi: ExtensionAPI) {
|
|
|
340
364
|
? Math.max(0, Number(params.timeout_ms))
|
|
341
365
|
: DEFAULT_WAIT_MS
|
|
342
366
|
let running = false
|
|
367
|
+
let interrupted = false
|
|
368
|
+
let waitedMs = 0
|
|
343
369
|
if (!job.done && timeout > 0) {
|
|
344
370
|
job.harvested = true // 收割意图先落地:保证完成时静默(#689 第 1 条)
|
|
371
|
+
const waitingSince = Date.now()
|
|
345
372
|
const exited = await waitForExit(job, timeout, signal)
|
|
373
|
+
waitedMs = Date.now() - waitingSince // 只量**本次调用**自己等的时间,不是作业年龄
|
|
346
374
|
if (!exited && !job.done) {
|
|
347
375
|
job.harvested = false // 没收成 → 撤销意图,完成时照常唤醒
|
|
348
376
|
running = true
|
|
377
|
+
interrupted = signal?.aborted === true // 超时 vs 被中止:账本分开记(design 决策 6)
|
|
349
378
|
}
|
|
350
379
|
} else if (!job.done) {
|
|
351
380
|
running = true
|
|
381
|
+
interrupted = signal?.aborted === true
|
|
352
382
|
}
|
|
383
|
+
const waitedS = (waitedMs / 1000).toFixed(1)
|
|
384
|
+
const root = job.root || findRoot(String(ctx?.cwd ?? process.cwd()))
|
|
353
385
|
if (running) {
|
|
386
|
+
// 每次 team_bg_wait 返回一行(超时 = running;信号中止 = interrupted);既有的
|
|
387
|
+
// wake / settled-with-unharvested / spawn-error / stop 行形状一字不动。
|
|
388
|
+
appendLedger(root, `wait id=${job.id} outcome=${interrupted ? 'interrupted' : 'running'} waited_s=${waitedS}`)
|
|
354
389
|
return {
|
|
355
390
|
content: [{ type: 'text', text: `job ${job.id} is still running (pid ${job.pid}); log: ${job.log}\n cmd: ${displayCmd(job.command)}` }],
|
|
356
391
|
details: { id: job.id, running: true, log: job.log, cmd: job.command },
|
|
357
392
|
}
|
|
358
393
|
}
|
|
359
394
|
job.harvested = true
|
|
395
|
+
appendLedger(root, `wait id=${job.id} outcome=harvested waited_s=${waitedS}`)
|
|
360
396
|
const { text, truncated } = tailOf(job.log, TAIL_BYTES)
|
|
361
397
|
const secs = ((Date.now() - job.startedAt) / 1000).toFixed(1)
|
|
362
398
|
const body = truncated ? `${TRUNC_MARK}\n${text}` : text
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent'
|
|
21
21
|
import { execFileSync } from 'node:child_process'
|
|
22
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
22
|
+
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
|
23
23
|
import { dirname, join, resolve } from 'node:path'
|
|
24
24
|
import { fileURLToPath } from 'node:url'
|
|
25
25
|
|
|
@@ -132,6 +132,126 @@ function findRoot(cwd: string): string {
|
|
|
132
132
|
return derived || envRoot
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/** 后台车道自己写记录的 state 目录(team-bg 的 findRoot + stateDir 两条规则的复刻)——挂起判定
|
|
136
|
+
* **只**读这里。为什么不拿 notify 自己的 root 顶替(design 决策 4):本仓 worker worktree 不带 config,
|
|
137
|
+
* 两侧今天巧合都落主工作树;而 worktree 自带 config 的形状(S11 夹具)下车道落 worktree 侧,
|
|
138
|
+
* notify 的 git-common-dir 就会读错目录。规则:显式 TEAM_STATE_DIR 优先;否则「cwd 的 worktree 带
|
|
139
|
+
* config → 它自己;TEAM_ROOT(带 config);最近的带 config 的祖先;git 主工作树(最后的兜底)」。
|
|
140
|
+
* 任何一步推不出来 → 空串(调用方 fail-closed:不挂起)。 */
|
|
141
|
+
function laneStateDir(cwd: string): string {
|
|
142
|
+
const envDir = process.env.TEAM_STATE_DIR
|
|
143
|
+
if (envDir) return resolve(envDir)
|
|
144
|
+
let root = ''
|
|
145
|
+
const top = run('git', ['-C', cwd, 'rev-parse', '--path-format=absolute', '--show-toplevel'])
|
|
146
|
+
if (top && existsSync(join(top, '.pi/team/config.sh'))) root = resolve(top)
|
|
147
|
+
const envRoot = process.env.TEAM_ROOT ? resolve(process.env.TEAM_ROOT) : ''
|
|
148
|
+
if (!root && envRoot && existsSync(join(envRoot, '.pi/team/config.sh'))) root = envRoot
|
|
149
|
+
if (!root) {
|
|
150
|
+
let dir = resolve(cwd)
|
|
151
|
+
for (;;) {
|
|
152
|
+
if (existsSync(join(dir, '.pi/team/config.sh'))) { root = dir; break }
|
|
153
|
+
const parent = dirname(dir)
|
|
154
|
+
if (parent === dir) break
|
|
155
|
+
dir = parent
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (!root) {
|
|
159
|
+
const common = run('git', ['-C', cwd, 'rev-parse', '--path-format=absolute', '--git-common-dir'])
|
|
160
|
+
if (common) {
|
|
161
|
+
const main = dirname(common)
|
|
162
|
+
if (existsSync(join(main, '.pi/team/config.sh'))) root = main
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return root ? join(root, '.pi/team/state') : ''
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** notify 自己的落点(它的项目根 + .pi/team/state)。**不许**拿它当车道的目录;只用来在两侧分歧时
|
|
169
|
+
* 记一行日志点名(否则这种错位会静默地读到错目录)。 */
|
|
170
|
+
function notifyStateDir(root: string): string {
|
|
171
|
+
return root ? join(root, '.pi/team/state') : ''
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** /proc/<pid>/stat 的启动时间指纹(第 22 字段)。comm 字段带空格/括号 → 按**最后一个** `)` 切开再数。
|
|
175
|
+
* 进程不在 / 读不到 → 空串(调用方据此判「不算在跑」)。 */
|
|
176
|
+
function procStartTime(pid: number): string {
|
|
177
|
+
try {
|
|
178
|
+
const stat = readFileSync(`/proc/${pid}/stat`, 'utf8')
|
|
179
|
+
const rest = stat.slice(stat.lastIndexOf(')') + 1).trim().split(/\s+/)
|
|
180
|
+
return rest[19] ?? ''
|
|
181
|
+
} catch {
|
|
182
|
+
return ''
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** 真实路径(软链与尾斜杠都归一):只接受绝对路径 —— 相对路径在记录里没有对象可解析,属畸形;
|
|
187
|
+
* 解析失败(路径已不存在 / 无权限)返回空串。调用方拿空串一律 fail-closed(不判挂起,绝不猜)。 */
|
|
188
|
+
function realPathOf(p: string): string {
|
|
189
|
+
if (!p || p[0] !== '/') return ''
|
|
190
|
+
try {
|
|
191
|
+
return realpathSync(p)
|
|
192
|
+
} catch {
|
|
193
|
+
return ''
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** P236 · 本会话的归属路径集合(真实路径):会话自己的 cwd 与它所在的工作树。任一路径解析失败就不
|
|
198
|
+
* 放进去 —— 集合为空 = 一条作业都不认(fail-closed 的极端形状,好过认错别人的作业)。 */
|
|
199
|
+
function ownedSessionPaths(cwd: string, worktree: string): Set<string> {
|
|
200
|
+
const owned = new Set<string>()
|
|
201
|
+
for (const p of [cwd, worktree]) {
|
|
202
|
+
const real = realPathOf(resolve(p))
|
|
203
|
+
if (real) owned.add(real)
|
|
204
|
+
}
|
|
205
|
+
return owned
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** P236 · 归属判据:作业记录里的 `cwd`(作业启动时的工作目录,也就是拥有它的那个席位的工作树)
|
|
209
|
+
* 解析到本会话自己的工作树/cwd(真实路径相等)才算「我的作业」。缺 `cwd`、相对路径、解析失败、
|
|
210
|
+
* 或指向别人的工作树 → 都不算(fail-closed)。 */
|
|
211
|
+
function isOwnedCwd(jobCwd: string, owned: Set<string>): boolean {
|
|
212
|
+
const real = realPathOf(jobCwd)
|
|
213
|
+
return real !== '' && owned.has(real)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** 在跑作业集合:读车道目录下的 `bg/*.job`,逐条做 (pid, start-time) 活体验证(与 `team bg list`
|
|
217
|
+
* 同一条身份规则),再按 `cwd` 只留**本会话自己的**作业(P236 归属范围 —— 同一车道目录里的记录
|
|
218
|
+
* 可能属于别的席位,把别人的长作业算成自己挂起会污染 `awaiting=`)。任何一条失败都**跳过**
|
|
219
|
+
* (目录/记录读不了、软链-FIFO 记录、pid 非正整数、start 缺失、/proc 读不到、指纹不符、cwd 缺失
|
|
220
|
+
* 或不属于本会话)—— fail-closed:判定的不确定方向永远是「不挂起」,绝不假造挂起(design 决策 4)。 */
|
|
221
|
+
function runningLaneJobs(laneDir: string, owned: Set<string>): string[] {
|
|
222
|
+
if (!laneDir || owned.size === 0) return []
|
|
223
|
+
let names: string[]
|
|
224
|
+
try {
|
|
225
|
+
names = readdirSync(join(laneDir, 'bg'))
|
|
226
|
+
} catch {
|
|
227
|
+
return [] // 车道还没起过作业(目录不存在)/ 读不了:没有在跑作业
|
|
228
|
+
}
|
|
229
|
+
const ids: string[] = []
|
|
230
|
+
for (const name of names.sort()) {
|
|
231
|
+
if (!name.endsWith('.job')) continue
|
|
232
|
+
const id = name.slice(0, -'.job'.length)
|
|
233
|
+
if (!/^[A-Za-z0-9._-]+$/.test(id)) continue // 平坦 id(读侧边界与 team bg 同规则)
|
|
234
|
+
try {
|
|
235
|
+
const file = join(laneDir, 'bg', name)
|
|
236
|
+
if (!lstatSync(file).isFile()) continue // 软链 / FIFO / 目录:记录畸形
|
|
237
|
+
const fields: Record<string, string> = {}
|
|
238
|
+
for (const line of readFileSync(file, 'utf8').split(/\r?\n/)) {
|
|
239
|
+
const i = line.indexOf('=')
|
|
240
|
+
if (i > 0) fields[line.slice(0, i).trim()] = line.slice(i + 1).trim()
|
|
241
|
+
}
|
|
242
|
+
const pid = Number(fields.pid ?? '')
|
|
243
|
+
const start = fields.start ?? ''
|
|
244
|
+
if (!Number.isInteger(pid) || pid <= 0 || !start) continue
|
|
245
|
+
if (procStartTime(pid) !== start) continue // 死进程 / pid 复用 / /proc 读不到:都不算在跑
|
|
246
|
+
if (!isOwnedCwd(fields.cwd ?? '', owned)) continue // P236:别人的作业不算自己挂起
|
|
247
|
+
ids.push(id)
|
|
248
|
+
} catch {
|
|
249
|
+
continue // 读不了:不算在跑
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return ids
|
|
253
|
+
}
|
|
254
|
+
|
|
135
255
|
function readCfg(root: string): Cfg {
|
|
136
256
|
const file = process.env.TEAM_CONFIG_FILE || join(root, '.pi/team/config.sh')
|
|
137
257
|
const cfg: Cfg = { ...DEFAULTS }
|
|
@@ -330,8 +450,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
330
450
|
const tip = proven ? run('git', ['-C', cwd, 'rev-parse', 'HEAD']).slice(0, TIP_WIDTH) : ''
|
|
331
451
|
const revStamp = tip ? ` · task=${id} tip=${tip}` : ''
|
|
332
452
|
const dirty = run('git', ['-C', cwd, 'status', '--porcelain']).split('\n').filter(Boolean).length
|
|
333
|
-
// 未提交 = 没交付干净:让 PM 一眼看出来(CEP 实测:这种状态和"干净交付"在通知里长得一样)
|
|
334
|
-
const dirtyFlag = dirty > 0 ? `⚠ 未提交 ${dirty} 个文件 · ` : ''
|
|
335
453
|
const upstream = run('git', ['-C', cwd, 'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}'])
|
|
336
454
|
const unpushed = upstream
|
|
337
455
|
? run('git', ['-C', cwd, 'rev-list', '--count', '@{upstream}..HEAD']) || '?'
|
|
@@ -355,11 +473,28 @@ export default function (pi: ExtensionAPI) {
|
|
|
355
473
|
/* 通知绝不能打断会话 */
|
|
356
474
|
}
|
|
357
475
|
|
|
476
|
+
// 挂起判定(design 决策 4 + P236 归属范围):在跑集合从**车道自己写记录的目录**读(laneStateDir),
|
|
477
|
+
// 逐条 (pid, start-time) 验活、再按 cwd 只留**本会话自己的**作业;判定失败一律退回非挂起形状
|
|
478
|
+
// (fail-closed)——既不假造挂起,也不拿 notify 自己的 root 顶替车道目录(两侧分歧时它只负责把
|
|
479
|
+
// 这件事记进日志)。
|
|
480
|
+
// P236(缺陷现场):同一车道目录里的记录可能属于**别的席位** —— 只看「项目里有活作业」会把别人的
|
|
481
|
+
// 长作业算成自己挂起。归属判据 = 作业的 cwd 与本会话自己的工作树/cwd 解析到同一个真实路径。
|
|
482
|
+
const laneDir = laneStateDir(cwd)
|
|
483
|
+
const ownDir = notifyStateDir(root)
|
|
484
|
+
if (laneDir && ownDir && laneDir !== ownDir) {
|
|
485
|
+
log(`suspend check reads the lane's directory ${laneDir} (notify's own root would be ${ownDir})`, cfg)
|
|
486
|
+
}
|
|
487
|
+
const owned = ownedSessionPaths(cwd, join(wtPrefix, agent))
|
|
488
|
+
const running = runningLaneJobs(laneDir, owned)
|
|
489
|
+
const awaiting = running.length > 0 ? `awaiting=${running.join(',')}` : ''
|
|
490
|
+
const suspended = completed && running.length > 0
|
|
491
|
+
|
|
358
492
|
const summary = [
|
|
359
493
|
`agent:${agent}`,
|
|
360
494
|
id,
|
|
361
495
|
`branch=${branch || '-'}`,
|
|
362
496
|
`uncommitted=${dirty}`,
|
|
497
|
+
...(awaiting ? [awaiting] : []),
|
|
363
498
|
`unpushed=${unpushed}${upstream ? '' : '(no-upstream)'}`,
|
|
364
499
|
].join(' · ')
|
|
365
500
|
// 未完成的回合 + 本轮内有过生命周期事件 = 内部重启/压缩的产物,不是交付:不发简报、不敲门。
|
|
@@ -371,8 +506,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
371
506
|
}
|
|
372
507
|
lifecycleDuringTurn = ''
|
|
373
508
|
|
|
509
|
+
// 未提交 = 没交付干净:让 PM 一眼看出来(CEP 实测:这种状态和"干净交付"在通知里长得一样)。
|
|
510
|
+
// 挂起不是交付主张:省略 ⚠ 前缀(事实留在 uncommitted=<n> 字段里),否则告警框只会误导。
|
|
511
|
+
const dirtyFlag = dirty > 0 && !suspended ? `⚠ 未提交 ${dirty} 个文件 · ` : ''
|
|
512
|
+
|
|
374
513
|
count++
|
|
375
|
-
const tag = completed ? '[auto]' : '[auto·interrupted]'
|
|
514
|
+
const tag = completed ? (suspended ? '[auto·suspended]' : '[auto]') : '[auto·interrupted]'
|
|
376
515
|
// 去重键:整条末消息的「长度+指纹」+ 修订标识(新 tip = 新修订,不该被去重吞掉)。
|
|
377
516
|
// 老键(last[0:60])会把三条开头相同、后半不同的简报当成同一条吞掉(M6.3 F17)。
|
|
378
517
|
const key = `${agent}|${tag}|${summary}|${revStamp}|${last.length}:${fingerprint(last)}`
|
|
@@ -59,7 +59,7 @@ malformed one such as `{ cwd }` all fail loudly, and the error names `TEAM_PM_CM
|
|
|
59
59
|
|
|
60
60
|
- `{cwd}` — the project's **main worktree** (the PM's working directory)
|
|
61
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` (
|
|
62
|
+
- `{model}` — the model-name part of the independent `TEAM_PM_MODEL` (required; the PM has no worker fallback)
|
|
63
63
|
- `{provider}` — the provider part
|
|
64
64
|
- `{prompt_file}` — path of `state/pm-prompt.md`, the PM briefing (`team up --print` prints the same text)
|
|
65
65
|
- `{prompt}` — `"$0"`: the briefing as a single argv token handed over by the window harness (keep the quotes)
|
|
@@ -171,10 +171,10 @@ Rules:
|
|
|
171
171
|
- The template's first word must be a **bare executable name** (no quotes): `TEAM_AGENT_BIN`, `team doctor` and the
|
|
172
172
|
window-readiness wait resolve it with `command -v`, which cannot see `"my agent"`. If your CLI really has a space
|
|
173
173
|
in its name, set `TEAM_AGENT_BIN` to its absolute path.
|
|
174
|
-
- `{model}`/`{provider}` come from
|
|
175
|
-
`
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
- `{model}`/`{provider}` come from the dispatch's **selected launch identity** — the brief's task category
|
|
175
|
+
resolved through `TEAM_TASK_MODELS`, or an explicit `team dispatch --model` override — not from the CLI and not
|
|
176
|
+
from a per-seat key. Set the category mapping so `{model}` matches what the CLI really uses; that also keeps
|
|
177
|
+
`TEAM_MODEL_LIMITS` (model concurrency) meaningful.
|
|
178
178
|
- The rendered command is executed by `bash -lc` in the window; the usual quoting rules of your shell
|
|
179
179
|
apply, and nothing is `eval`-ed twice.
|
|
180
180
|
- **The first word is resolved, not guessed** (the same rule as the PM side, §2): the window shell is
|
|
@@ -566,7 +566,7 @@ TEAM_AGENT_CMD='codex exec -C {cwd} -m {model} -s workspace-write "$(cat {prompt
|
|
|
566
566
|
TEAM_AGENT_BIN="$HOME/.bun/bin/codex"
|
|
567
567
|
TEAM_AGENT_NOTIFY_CMD='bash {skill_dir}/scripts/team notify pm --from {agent} --from-file {summary_file}'
|
|
568
568
|
TEAM_AGENT_LOG_GLOB='~/.codex/sessions/**/*.jsonl'
|
|
569
|
-
|
|
569
|
+
TEAM_TASK_MODELS="routine=openai/gpt-5.6-terra analysis=openai/gpt-5.6-terra" # {model} → the category's model (here gpt-5.6-terra)
|
|
570
570
|
```
|
|
571
571
|
|
|
572
572
|
Notes:
|
|
@@ -592,7 +592,7 @@ TEAM_AGENT_CMD='opencode run --model {provider}/{model} --dir {cwd} "$(cat {prom
|
|
|
592
592
|
TEAM_AGENT_BIN="$HOME/.opencode/bin/opencode"
|
|
593
593
|
TEAM_AGENT_NOTIFY_CMD='bash {skill_dir}/scripts/team notify pm --from {agent} --from-file {summary_file}'
|
|
594
594
|
TEAM_AGENT_LOG_GLOB='~/.local/share/opencode/log/*.log'
|
|
595
|
-
|
|
595
|
+
TEAM_TASK_MODELS="routine=google/gemini-3-flash-preview"
|
|
596
596
|
```
|
|
597
597
|
|
|
598
598
|
**Verified end-to-end on this machine** (no Pi involved): `team dispatch` started opencode in the agent
|