@blackbelt-technology/pi-dashboard-agent-teams-plugin 0.0.0-stage → 0.12.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 +541 -2
- package/examples/judo-modules.helpers.md +78 -0
- package/examples/judo-modules.md +17 -0
- package/package.json +201 -4
- package/prompts/openspec-group-member.md +13 -0
- package/prompts/teammate-member-commit.md +60 -0
- package/prompts/teammate.md +61 -0
- package/src/bridge/command.ts +187 -0
- package/src/bridge/context.ts +67 -0
- package/src/bridge/guard.ts +183 -0
- package/src/bridge/index.ts +514 -0
- package/src/bridge/inproc-capabilities.ts +137 -0
- package/src/bridge/inproc-child.ts +193 -0
- package/src/bridge/inproc-command.ts +233 -0
- package/src/bridge/inproc-host.ts +831 -0
- package/src/bridge/inproc-outbox.ts +158 -0
- package/src/bridge/inproc-spawn-checks.ts +133 -0
- package/src/bridge/inproc-text.ts +39 -0
- package/src/bridge/lane.ts +133 -0
- package/src/bridge/openspec-guard.ts +129 -0
- package/src/bridge/plan-mode.ts +152 -0
- package/src/bridge/shell-guard.ts +137 -0
- package/src/bridge/tools.ts +211 -0
- package/src/client/ApprovalCard.tsx +211 -0
- package/src/client/LiveRegion.tsx +42 -0
- package/src/client/MailEntryCard.tsx +173 -0
- package/src/client/MembersGrid.tsx +219 -0
- package/src/client/MessageLog.tsx +217 -0
- package/src/client/PlaybookCard.tsx +54 -0
- package/src/client/StartTeamDialog.tsx +196 -0
- package/src/client/StartTeamFolderAction.tsx +48 -0
- package/src/client/StartTeamParts.tsx +165 -0
- package/src/client/TaskBoard.tsx +255 -0
- package/src/client/TeamBadge.tsx +39 -0
- package/src/client/TeamHeader.tsx +145 -0
- package/src/client/TeamTabs.tsx +71 -0
- package/src/client/TeamToolRenderers.tsx +310 -0
- package/src/client/TeamView.tsx +200 -0
- package/src/client/announcements.ts +104 -0
- package/src/client/approval-i18n.ts +96 -0
- package/src/client/approval-parse.ts +93 -0
- package/src/client/format-cwd.ts +23 -0
- package/src/client/index.tsx +12 -0
- package/src/client/inproc-i18n.ts +68 -0
- package/src/client/inproc-view.ts +26 -0
- package/src/client/lazy-i18n.ts +42 -0
- package/src/client/mail-i18n.ts +98 -0
- package/src/client/mail-parse.ts +75 -0
- package/src/client/pill.tsx +11 -0
- package/src/client/recipes.ts +22 -0
- package/src/client/routes.ts +18 -0
- package/src/client/start-api.ts +110 -0
- package/src/client/start-i18n.ts +150 -0
- package/src/client/status-map.ts +80 -0
- package/src/client/team-controls.ts +106 -0
- package/src/client/team-refs.ts +39 -0
- package/src/client/team-view-i18n.ts +441 -0
- package/src/client/teams-feeder.tsx +91 -0
- package/src/client/teams-hooks.ts +25 -0
- package/src/client/teams-store.ts +615 -0
- package/src/client/tool-details.ts +100 -0
- package/src/client/tool-families.ts +34 -0
- package/src/client/tool-i18n.ts +165 -0
- package/src/client/view-kit.tsx +46 -0
- package/src/configSchema.json +241 -0
- package/src/i18n.ts +27 -0
- package/src/server/access.ts +57 -0
- package/src/server/agent-prompts.ts +84 -0
- package/src/server/agents.ts +132 -0
- package/src/server/args.ts +43 -0
- package/src/server/config.ts +242 -0
- package/src/server/dispatch.ts +75 -0
- package/src/server/driver-inproc.ts +627 -0
- package/src/server/driver.ts +234 -0
- package/src/server/epoch.ts +14 -0
- package/src/server/extension-points.ts +382 -0
- package/src/server/hook-engine.ts +201 -0
- package/src/server/hook-hash.ts +20 -0
- package/src/server/hook-limiter.ts +110 -0
- package/src/server/hook-payload.ts +74 -0
- package/src/server/hook-run.ts +201 -0
- package/src/server/hook-trust.ts +248 -0
- package/src/server/hooks.ts +171 -0
- package/src/server/index.ts +64 -0
- package/src/server/inproc-lead.ts +130 -0
- package/src/server/inproc-lifecycle.ts +267 -0
- package/src/server/inproc-mail.ts +58 -0
- package/src/server/lane.ts +147 -0
- package/src/server/mail-limits.ts +87 -0
- package/src/server/mail.ts +238 -0
- package/src/server/messaging.ts +165 -0
- package/src/server/modes-inproc.ts +383 -0
- package/src/server/modes.ts +48 -0
- package/src/server/notices.ts +100 -0
- package/src/server/op-util.ts +24 -0
- package/src/server/openspec/apply-briefing.ts +41 -0
- package/src/server/openspec/apply.ts +72 -0
- package/src/server/openspec/batch-lock.ts +79 -0
- package/src/server/openspec/briefing.ts +56 -0
- package/src/server/openspec/bundled.ts +77 -0
- package/src/server/openspec/config.ts +133 -0
- package/src/server/openspec/gate.ts +247 -0
- package/src/server/openspec/git.ts +45 -0
- package/src/server/openspec/group-api.ts +8 -0
- package/src/server/openspec/groups.ts +108 -0
- package/src/server/openspec/hints.ts +326 -0
- package/src/server/openspec/index.ts +251 -0
- package/src/server/openspec/inject.ts +98 -0
- package/src/server/openspec/inputs.ts +98 -0
- package/src/server/openspec/launcher.ts +488 -0
- package/src/server/openspec/lock.ts +382 -0
- package/src/server/openspec/log.ts +81 -0
- package/src/server/openspec/names.ts +22 -0
- package/src/server/openspec/profiles.ts +359 -0
- package/src/server/openspec/relaunch-route.ts +35 -0
- package/src/server/openspec/seed-apply.ts +200 -0
- package/src/server/openspec/seed-core.ts +268 -0
- package/src/server/openspec/seed-group.ts +216 -0
- package/src/server/openspec/sidecar.ts +349 -0
- package/src/server/openspec/slices.ts +16 -0
- package/src/server/openspec/sync.ts +303 -0
- package/src/server/openspec/tasks-source.ts +109 -0
- package/src/server/openspec/worktree.ts +205 -0
- package/src/server/ops.ts +1433 -0
- package/src/server/persistence.ts +502 -0
- package/src/server/plan-policy.ts +99 -0
- package/src/server/plan-store.ts +72 -0
- package/src/server/plans.ts +177 -0
- package/src/server/proxy-identity.ts +90 -0
- package/src/server/routes.ts +247 -0
- package/src/server/runtime.ts +289 -0
- package/src/server/shutdown.ts +189 -0
- package/src/server/snapshot.ts +118 -0
- package/src/server/spawn-precedence.ts +101 -0
- package/src/server/spawn-resolve.ts +83 -0
- package/src/server/spawn.ts +345 -0
- package/src/server/start-lead.ts +119 -0
- package/src/server/start-phase.ts +142 -0
- package/src/server/start-prepare.ts +133 -0
- package/src/server/start-profiles.ts +38 -0
- package/src/server/start.ts +124 -0
- package/src/server/store.ts +506 -0
- package/src/server/tasks.ts +447 -0
- package/src/server/telemetry.ts +62 -0
- package/src/server/template-fs.ts +98 -0
- package/src/server/template-parse.ts +272 -0
- package/src/server/template-render.ts +148 -0
- package/src/server/template-yaml.ts +81 -0
- package/src/server/templates-hooks.ts +158 -0
- package/src/server/templates-routes.ts +136 -0
- package/src/server/templates.ts +315 -0
- package/src/server/types.ts +52 -0
- package/src/server/ui-bridge.ts +218 -0
- package/src/server/ui-counters.ts +45 -0
- package/src/server/user-actions.ts +138 -0
- package/src/shared/approval-mail.ts +30 -0
- package/src/shared/clock.ts +21 -0
- package/src/shared/constants.ts +74 -0
- package/src/shared/index.ts +20 -0
- package/src/shared/inproc-protocol.ts +179 -0
- package/src/shared/mail-format.ts +193 -0
- package/src/shared/openspec-profile.ts +25 -0
- package/src/shared/owner-key.ts +40 -0
- package/src/shared/plan-mode.ts +62 -0
- package/src/shared/plugin-id.ts +15 -0
- package/src/shared/policy.ts +107 -0
- package/src/shared/protocol.ts +520 -0
- package/src/shared/snapshot.ts +149 -0
- package/src/shared/subagents-contract.ts +249 -0
- package/src/shared/text.ts +109 -0
- package/src/shared/types.ts +262 -0
- package/src/shared/ui-protocol.ts +57 -0
- package/templates/openspec-apply.md +40 -0
- package/templates/openspec-group.md +33 -0
package/README.md
CHANGED
|
@@ -1,3 +1,542 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @blackbelt-technology/pi-dashboard-agent-teams-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Agent teams core for pi-dashboard (plugin id `agent-teams`). A lead session
|
|
4
|
+
spawns visible teammate sessions and coordinates them through a shared task list
|
|
5
|
+
and a mailbox; every host call goes through `ServerPluginContext`. On top of the
|
|
6
|
+
core: **team templates** (start a whole team from a markdown file), **hooks**
|
|
7
|
+
(quality gates on idle / task events) and **plan approval** (a member plans
|
|
8
|
+
read-only until the lead or the user approves).
|
|
9
|
+
|
|
10
|
+
Not to be confused with `packages/team-plugin` (the personas/conversations
|
|
11
|
+
plugin) — unrelated.
|
|
12
|
+
|
|
13
|
+
| Entry | Path |
|
|
14
|
+
|-------|------|
|
|
15
|
+
| Server | `src/server/index.ts` — store, lane handlers, REST routes, dispatcher, member driver, templates / hooks / plan approval |
|
|
16
|
+
| Bridge | `src/bridge/index.ts` — team tools, teammate-scope guard, plan-mode narrowing, `/agent-team` command (pi extension) |
|
|
17
|
+
| Client | `src/client/index.tsx` — i18n catalog; claims the entry renderers (mail, approval, playbook, team tools) and the `sidebar-folder-section` Start team action |
|
|
18
|
+
| Config | `src/configSchema.json` — limits, rates, timeouts, TTLs, `autoDispatch`, `extraCwdRoots`, template / hook / plan settings |
|
|
19
|
+
|
|
20
|
+
Manifest `emits`: `agent-teams:mail`, `agent-teams:team_closed` (the manifest
|
|
21
|
+
contract test fails when the server emits a type not listed there).
|
|
22
|
+
|
|
23
|
+
Specs: `openspec/changes/add-agent-teams-core/`, `openspec/changes/add-agent-teams-templates-hooks/`.
|
|
24
|
+
|
|
25
|
+
## Tests
|
|
26
|
+
|
|
27
|
+
- `npx vitest run packages/agent-teams-plugin/src` (via `HOME=$(mktemp -d) …`, see `npm run test:parallel`) — unit + faux-pi-rpc harness.
|
|
28
|
+
- `src/__tests__/harness/` — injected clock, fake host `ctx`, faux `pi --mode rpc` driver.
|
|
29
|
+
- Browser E2E: `tests/e2e/agent-teams-*.spec.ts` (command, Start team dialog, approval card); VM smoke: `qa/tests/70-agent-teams-templates.sh`.
|
|
30
|
+
|
|
31
|
+
## Team templates
|
|
32
|
+
|
|
33
|
+
A template is a markdown file: YAML frontmatter describes the team, the body is
|
|
34
|
+
the **lead playbook** (delivered to the lead as one mail). Start one with
|
|
35
|
+
`/agent-team start <template> <goal>` or the dashboard's **Start team** dialog.
|
|
36
|
+
|
|
37
|
+
### Sources
|
|
38
|
+
|
|
39
|
+
| Source | Path | Trust |
|
|
40
|
+
|--------|------|-------|
|
|
41
|
+
| `project` | `<cwd>/.pi/teams/<name>.md` | read only when `host.isProjectTrusted(cwd)` is true; otherwise listed by file name with `trusted:false`, never parsed, not startable (`project_untrusted`) |
|
|
42
|
+
| `user` | `<piAgentDir>/teams/<name>.md` | always trusted |
|
|
43
|
+
| `bundled` | registered in code by later changes (`registerBundledTemplate`) | trusted; no hook prompt |
|
|
44
|
+
|
|
45
|
+
A trusted `project` template shadows a `user` / `bundled` one of the same name;
|
|
46
|
+
an untrusted project file never shadows anything. The file name stem must equal
|
|
47
|
+
the frontmatter `name` (`^[a-z][a-z0-9-]{0,39}$`). Files must be regular files
|
|
48
|
+
whose realpath stays inside the source directory (`outside_source_dir`) and at
|
|
49
|
+
most `maxTemplateBytes` (default 65536, `template_too_large`). A listing holds
|
|
50
|
+
at most 200 templates. Invalid templates are listed with stable error codes and
|
|
51
|
+
cannot be started; unknown keys are ignored with a warning.
|
|
52
|
+
|
|
53
|
+
The frontmatter is parsed strictly: one YAML mapping, unique keys, **no anchors,
|
|
54
|
+
aliases, merge keys or custom tags** (`frontmatter_invalid`).
|
|
55
|
+
|
|
56
|
+
### Frontmatter fields
|
|
57
|
+
|
|
58
|
+
| Field | Type | Meaning |
|
|
59
|
+
|-------|------|---------|
|
|
60
|
+
| `name` | string, required | equals the file stem |
|
|
61
|
+
| `description` | string | one line shown in listings and the dialog |
|
|
62
|
+
| `mode` | string | member runtime mode; omit to use the runtime default. A mode that is not registered → `mode_unavailable` |
|
|
63
|
+
| `lead.model` | string | model for a **dashboard-started** lead; ignored (with a notice) by the `/agent-team` command, the session keeps its model |
|
|
64
|
+
| `maxTeammates` | integer ≥ 1 | cap on roster **plus** lead-spawned members; the configured maximum stays the upper bound (`roster_exceeds_max`) |
|
|
65
|
+
| `autoDispatch` | boolean | per-team override of the dispatcher; `false` = members claim tasks with `TaskUpdate` only |
|
|
66
|
+
| `notify.coalesceMs` | integer 0–10000 | per-team lead-notice flush window (`notify_out_of_range`). Errors, shutdown rejections, plan requests, member deaths, spawn failures and direct messages always wake the lead |
|
|
67
|
+
| `spawn` | `eager` (default) \| `lead` | `eager`: server spawns every member after the lead binds; `lead`: none, the playbook lists the roster for the lead to spawn with `TeammateSpawn` |
|
|
68
|
+
| `requirePlanApproval` | `false` \| `true` \| `"user"` | team-wide **floor** for plan approval (see [Plan approval](#plan-approval)) |
|
|
69
|
+
| `defaultModel` | string | model for members that name none |
|
|
70
|
+
| `defaultTools` / `defaultSkills` | string[] | team default tool / skill lists; also a **ceiling** for lead-supplied lists |
|
|
71
|
+
| `members[]` | list | the roster (below) |
|
|
72
|
+
| `hooks` | mapping | event → up to 3 `{command, timeoutMs?}` (see [Hooks](#hooks)) |
|
|
73
|
+
|
|
74
|
+
Member fields: `name` (required; core member-name rules, `lead` is reserved),
|
|
75
|
+
`agent` (a teammate type, see below), `role`, `model`, `count` (integer ≥ 1;
|
|
76
|
+
expands to `<name>` for 1, `<name>-1…-n` for n > 1; every expanded name must be
|
|
77
|
+
valid and unique), `tools`, `skills`, `cwd` (still confined to the lead cwd and
|
|
78
|
+
`extraCwdRoots`), `requirePlanApproval`, `prompt` (extra system-prompt text).
|
|
79
|
+
|
|
80
|
+
### Variables and the playbook
|
|
81
|
+
|
|
82
|
+
The body and each member `prompt` get exactly `{{goal}}` and `{{cwd}}`, once, by
|
|
83
|
+
plain replacement (no recursion; an unknown `{{x}}` stays literal and warns). The
|
|
84
|
+
goal is required, at most 4000 characters, control characters and newlines
|
|
85
|
+
collapse to one space. The rendered playbook (body + goal + roster summary) must
|
|
86
|
+
fit one core mail (`maxMessageChars` − 500, 120 lines) — otherwise
|
|
87
|
+
`playbook_too_long`; it is never truncated.
|
|
88
|
+
|
|
89
|
+
A template describes how to **start** a team only. At start the server snapshots
|
|
90
|
+
it on the team (name, source, hash, hooks, defaults, roster, goal, playbook); later
|
|
91
|
+
edits or deletion of the file never change a running team. A server restart
|
|
92
|
+
between start and lead bind keeps the roster, and eager spawning reconciles
|
|
93
|
+
idempotently (only missing members, playbook never re-sent).
|
|
94
|
+
|
|
95
|
+
### Teammate types (`.pi/agents`)
|
|
96
|
+
|
|
97
|
+
A member (or a `TeammateSpawn {agent}` call) may name an agent definition
|
|
98
|
+
(`^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$`), resolved against the team lead cwd:
|
|
99
|
+
`<leadCwd>/.pi/agents/<agent>.md` (only when the project is trusted), then
|
|
100
|
+
`<piAgentDir>/agents/<agent>.md`; regular files up to 64 KiB. Errors:
|
|
101
|
+
`agent_not_found`, `agent_untrusted`, `agent_invalid`.
|
|
102
|
+
|
|
103
|
+
Mapping: `description` → default role (else the agent name); `model` → spawn
|
|
104
|
+
model; `thinking` → thinking level (unknown level ignored with a warning);
|
|
105
|
+
`tools` → tool allowlist (**must be a YAML array**, a comma string fails
|
|
106
|
+
`agent_invalid`); `prompt` or the markdown body → a prompt file appended after
|
|
107
|
+
the protocol prompt (agent file first, then the member `prompt`). `inherit_context`
|
|
108
|
+
is ignored: a teammate never receives the lead's history. The team tools
|
|
109
|
+
(`TaskList`, `SendMessage`, `PlanSubmit`, …) are always appended to the list.
|
|
110
|
+
|
|
111
|
+
Precedence per field — first defined wins: spawn argument → template member →
|
|
112
|
+
agent definition → team default (`model`, `tools`, `skills`). A template-declared
|
|
113
|
+
`tools` / `skills` list is a **ceiling**: a lead-supplied list is intersected with
|
|
114
|
+
it and anything outside fails `tools_outside_template` / `skills_outside_template`.
|
|
115
|
+
`requirePlanApproval` is a **floor**: a spawn argument may only strengthen it
|
|
116
|
+
(`false` < `true` < `"user"`). The model is neither floor nor ceiling.
|
|
117
|
+
|
|
118
|
+
### `/agent-team` command
|
|
119
|
+
|
|
120
|
+
Registered by the bridge in every pi session:
|
|
121
|
+
|
|
122
|
+
- `/agent-team start <template> <goal…>` — the calling session becomes the lead
|
|
123
|
+
(its own cwd; a payload cwd is ignored), the lead tools are registered as after
|
|
124
|
+
`TeamCreate`, the playbook arrives as an `agent-teams-playbook` message and the
|
|
125
|
+
lead's turn starts. Errors (`already_in_team`, `lead_confined`,
|
|
126
|
+
`project_untrusted`, `template_invalid`, `playbook_too_long`, …) are shown in
|
|
127
|
+
the session UI. Project hooks that are not yet confirmed open one confirm dialog
|
|
128
|
+
listing the exact commands.
|
|
129
|
+
- `/agent-team templates` — lists this folder's templates with source, validity,
|
|
130
|
+
trust state and whether they run hooks.
|
|
131
|
+
|
|
132
|
+
Argument completion offers the subcommands and cached template names. Starting a
|
|
133
|
+
team is not an agent tool: a teammate calling `team.start` gets
|
|
134
|
+
`nested_team_forbidden`, and no tool accepts `trustHooks`.
|
|
135
|
+
|
|
136
|
+
### Start team dialog (dashboard)
|
|
137
|
+
|
|
138
|
+
The plugin claims the `sidebar-folder-section` slot: each workspace folder gets a
|
|
139
|
+
**Start team** action. The dialog lists the folder's templates (source, validity,
|
|
140
|
+
trust; untrusted project templates are disabled with a prompt to trust the
|
|
141
|
+
project), takes a goal and calls `POST …/teams/start` with the folder cwd. The
|
|
142
|
+
server creates the team (`starting`, `owner` = the request principal), spawns a
|
|
143
|
+
new lead session with the template `lead.model`, and on bind delivers the
|
|
144
|
+
playbook and starts the eager roster. If the lead never binds within
|
|
145
|
+
`spawnTimeoutMs` the team closes with `lead_spawn_failed` (also across a server
|
|
146
|
+
restart). When the answer is `hooks_untrusted {hash, commands}` the dialog shows
|
|
147
|
+
the commands and retries with `trustHooks` = that hash only after confirmation.
|
|
148
|
+
|
|
149
|
+
## Hooks
|
|
150
|
+
|
|
151
|
+
A template may declare shell hooks, run by the **server** (never the agent) as
|
|
152
|
+
`bash -c <command>` in the team lead cwd, sequentially, up to 3 per event
|
|
153
|
+
(`too_many_hooks`), `command` ≤ 2000 characters (`hook_command_too_long`),
|
|
154
|
+
`timeoutMs` an integer ≥ 1.
|
|
155
|
+
|
|
156
|
+
| Event | Fires | On exit 2 |
|
|
157
|
+
|-------|-------|-----------|
|
|
158
|
+
| `TaskCreated` | before `TaskCreate` commits | the call fails `hook_blocked` with the feedback; no task |
|
|
159
|
+
| `TaskCompleted` | before `TaskUpdate → completed` commits | task stays `in_progress`; the call fails `hook_blocked` |
|
|
160
|
+
| `TeammateIdle` | when a member reports idle | member is not marked idle, the lead is not notified, a waking `hook_feedback` mail carries the stderr to the member |
|
|
161
|
+
|
|
162
|
+
Unknown event keys are ignored with a warning. Claims and trusted server callers
|
|
163
|
+
(`skipGates`) run no hooks. `TeammateIdle` skips `shutdown_pending` members,
|
|
164
|
+
idles that carry an error or abort, and members with a pending plan.
|
|
165
|
+
|
|
166
|
+
**Contract**
|
|
167
|
+
|
|
168
|
+
- **Exit code**: `0` allow · `2` block, stderr (control characters stripped, ≤ 2000
|
|
169
|
+
chars; empty → `hook blocked (no output)`) is the feedback · anything else, a
|
|
170
|
+
timeout, an output overflow or a spawn error → **allow** (fail-open), logged and
|
|
171
|
+
counted. The first command that exits 2 ends the sequence. Spawn error and
|
|
172
|
+
first timeout per team notify the lead once; three consecutive non-blocking
|
|
173
|
+
errors for one event give a non-waking notice.
|
|
174
|
+
- **stdin**: one JSON object built only from server-held state, e.g.
|
|
175
|
+
`{hook_event_name, team:{id,name}, cwd, member, memberCwd, task:{id,title,description,status,owner,blockedBy,result}, idle:{settleId,finalText,error}}`
|
|
176
|
+
(`task` for task events, `idle` for `TeammateIdle`; `finalText` is cut to 4000 chars).
|
|
177
|
+
- **Environment** (allowlist, never the server env): `PATH`, `HOME`, `USER`,
|
|
178
|
+
`LANG`, `LC_*`, `TMPDIR`, `SHELL`, `AGENT_TEAMS_EVENT`, `AGENT_TEAMS_TEAM_ID`,
|
|
179
|
+
`AGENT_TEAMS_MEMBER`, `AGENT_TEAMS_TASK_ID`. Task text is on stdin only.
|
|
180
|
+
- **Budget**: all commands of one event share **one deadline = the core
|
|
181
|
+
`opGateBudgetMs` (12 s total, queue wait included)**; each command's `timeoutMs`
|
|
182
|
+
(default `hookTimeoutMs` = 10 s) is capped by the remaining budget. At most 2
|
|
183
|
+
hooks per team and 4 server-wide run at once; stdout and stderr are capped at
|
|
184
|
+
64 KiB each. A timed-out hook's whole process tree is killed (also on shutdown).
|
|
185
|
+
A task hook that cannot start before the deadline fails with `hook_blocked` /
|
|
186
|
+
`hook_busy` (retry works); a second completion of a task whose hook is running
|
|
187
|
+
fails `hook_pending`; an idle hook that cannot start lets the idle through.
|
|
188
|
+
- **Long gates**: the gate answers inside the 15 s lane timeout, so a gate that
|
|
189
|
+
needs more than ~10 s (a full test suite) must not be a blocking hook. Make it
|
|
190
|
+
a **quick check** (lint one file, grep the diff, `git diff --quiet`), or use an
|
|
191
|
+
**async pattern**: the hook only records a request, and a later task (a CI
|
|
192
|
+
step, a reviewer member) does the slow work.
|
|
193
|
+
- **Retries**: after `hookMaxRetries` (default 3) consecutive `TeammateIdle`
|
|
194
|
+
blocks for one member the idle is accepted and the lead is told; any accepted
|
|
195
|
+
idle resets the counter. `0` means idle hooks never block.
|
|
196
|
+
|
|
197
|
+
**Trust (TOFU).** User-source (and bundled) hooks are trusted. Project-source
|
|
198
|
+
hooks run only when the project is trusted **and** a confirmation exists for
|
|
199
|
+
`realpath(cwd)` + the SHA-256 of the canonical hook set (event names, command
|
|
200
|
+
text and order, effective `timeoutMs`; comments, whitespace and key order are
|
|
201
|
+
ignored). Otherwise `team.start` answers `hooks_untrusted` with the hash and the
|
|
202
|
+
exact commands and starts nothing; retry with `trustHooks` = the shown hash
|
|
203
|
+
(`hash_mismatch` if the file changed meanwhile). Confirmations live in
|
|
204
|
+
`<dataDir>/hook-trust.json`. The hooks are **frozen** onto the team at start:
|
|
205
|
+
nothing (tool, route, revoked trust) changes a running team's hooks; revocation
|
|
206
|
+
only gates later starts. A trusted project hook runs with your privileges, like
|
|
207
|
+
any project extension — review it before confirming.
|
|
208
|
+
|
|
209
|
+
## Plan approval
|
|
210
|
+
|
|
211
|
+
`requirePlanApproval` (template, member, or spawn argument): `false` (default),
|
|
212
|
+
`true` (the lead or the user decides), `"user"` (only the user decides).
|
|
213
|
+
|
|
214
|
+
```mermaid
|
|
215
|
+
stateDiagram-v2
|
|
216
|
+
[*] --> planning: spawn (true or "user")
|
|
217
|
+
planning --> pending: PlanSubmit
|
|
218
|
+
pending --> pending: PlanSubmit (old plan superseded)
|
|
219
|
+
pending --> approved: PlanDecision / user approves
|
|
220
|
+
pending --> planning: rejected (feedback delivered)
|
|
221
|
+
approved --> [*]
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
1. A plan-mode member is spawned with an explicit tool list (including the plan
|
|
225
|
+
tools), `PI_EXT_AGENT_TEAMS_PLAN_MODE=1` and a **dispatch hold**; the server
|
|
226
|
+
records `planApproval:"planning"`. Its bridge narrows the active tools to
|
|
227
|
+
`planModeTools` + the team tools + `PlanSubmit` and blocks every other tool
|
|
228
|
+
call (`bash`, `edit`, `write`, …) until approval. A `planning` member may still
|
|
229
|
+
claim a task explicitly; it is excluded from auto-claim.
|
|
230
|
+
2. The member calls `PlanSubmit {plan}` (≤ `planMaxChars`, ≤ 120 lines, else
|
|
231
|
+
`message_too_long`; empty → `invalid_args`; outside plan mode →
|
|
232
|
+
`plan_not_required`). The server stores plan `p<N>` (per team, 20 max, oldest
|
|
233
|
+
decided one dropped, pending never), sets `pending`, and wakes the lead with a
|
|
234
|
+
`plan_request` mail (customType `agent-teams-approval`). A new submission marks
|
|
235
|
+
the old pending plan `superseded`. A pending member triggers no idle hook and
|
|
236
|
+
no idle notice.
|
|
237
|
+
3. The **lead** calls `PlanDecision {member, planId, approve, feedback?}`, or the
|
|
238
|
+
**user** presses Approve / Reject on the card in the lead's chat (or posts to
|
|
239
|
+
`plan-decision`). `decidedBy` is recorded by the server from the verified
|
|
240
|
+
caller, never from message text. Stale decisions fail `already_decided`,
|
|
241
|
+
unknown ones `unknown_plan`; `feedback` has the plan bound.
|
|
242
|
+
4. Approval sets `approved`, clears the hold and wakes the member with a
|
|
243
|
+
`plan_decision` mail; the bridge re-syncs through `hello` and restores the
|
|
244
|
+
**server-provided** tool list plus the team tools. Rejection keeps the member
|
|
245
|
+
read-only (`planning`) and delivers the feedback. If the bridge cannot narrow
|
|
246
|
+
tools or `PlanSubmit` is missing, the `tool_call` block still refuses non-plan
|
|
247
|
+
tools and the member is marked `degraded:"plan_tools_unavailable"` (lead notified).
|
|
248
|
+
|
|
249
|
+
Limits of `"user"`: with `requirePlanApproval:"user"` the lead's `PlanDecision`
|
|
250
|
+
fails `user_decision_required`, but the mode is **advisory, not a security
|
|
251
|
+
boundary** — when identity is not enforced, any local-token REST caller can post
|
|
252
|
+
the user decision. Plan-mode narrowing is in-session extension logic (it stops
|
|
253
|
+
the model, not a malicious extension). Because the member gets an explicit tool
|
|
254
|
+
list, non-default extension/MCP tools are only available after approval if named
|
|
255
|
+
in `tools`.
|
|
256
|
+
|
|
257
|
+
Plans, holds and member states persist across a server restart. A pending plan
|
|
258
|
+
becomes `cancelled` when its member's session ends or does not re-register within
|
|
259
|
+
`spawnTimeoutMs` of the restart.
|
|
260
|
+
|
|
261
|
+
**Rollback.** Reverting this change leaves stored fields inert and teams run as
|
|
262
|
+
plain core teams (no hooks, no plan gate). A member still awaiting approval keeps
|
|
263
|
+
the read-only scope until its session ends — it was spawned with the narrowed
|
|
264
|
+
tool list, and nothing after the revert can approve it. Delete
|
|
265
|
+
`<dataDir>/hook-trust.json` and `<dataDir>/prompts/` if desired.
|
|
266
|
+
|
|
267
|
+
## Configuration keys
|
|
268
|
+
|
|
269
|
+
Added by this change (`src/configSchema.json`; invalid values fall back to the
|
|
270
|
+
default with a startup warning):
|
|
271
|
+
|
|
272
|
+
| Key | Default | Meaning |
|
|
273
|
+
|-----|---------|---------|
|
|
274
|
+
| `maxTemplateBytes` | 65536 | max template file size (`template_too_large`) |
|
|
275
|
+
| `hookTimeoutMs` | 10000 | default per-command hook timeout, capped by the remaining `opGateBudgetMs` |
|
|
276
|
+
| `hookMaxRetries` | 3 | consecutive idle-hook blocks before the idle is accepted (`0` = never block) |
|
|
277
|
+
| `planMaxChars` | 6000 | max plan / decision feedback characters; effective `min(planMaxChars, maxMessageChars − 500)` and 120 lines |
|
|
278
|
+
| `planModeTools` | `[read, grep, find, ls]` | tools kept while a plan awaits approval; `bash`, `edit`, `write` and unknown names are dropped with a warning |
|
|
279
|
+
|
|
280
|
+
The hook budget itself is the core `opGateBudgetMs` (default 12000, max 14000).
|
|
281
|
+
|
|
282
|
+
## In-process teammates (mode `in-process`)
|
|
283
|
+
|
|
284
|
+
`teammateMode` (`session` default, or `in-process`; `TeamCreate {mode}` and a template `mode` win over it)
|
|
285
|
+
runs teammates as background children of the lead through the external
|
|
286
|
+
`@blackbelt-technology/pi-dashboard-subagents` extension instead of one dashboard session each.
|
|
287
|
+
|
|
288
|
+
**Requirement: this mode needs `pi-dashboard-subagents` 0.9.0 or newer (API `apiVersion` 1) that
|
|
289
|
+
answers `subagents:capabilities`; 0.8.1 and older do not.** Until it is installed, `TeamCreate {mode:"in-process"}` fails with `mode_unavailable`
|
|
290
|
+
(`subagents_extension_missing` / `subagents_extension_outdated`) and session mode is unaffected. The plugin
|
|
291
|
+
does not list the package in its manifest `requires`; the gate is the runtime capability handshake
|
|
292
|
+
(`src/shared/subagents-contract.ts`). Update the package from the Packages tab.
|
|
293
|
+
|
|
294
|
+
| Key | Default | Meaning |
|
|
295
|
+
|-----|---------|---------|
|
|
296
|
+
| `teammateMode` | unset (`session`) | default mode when `TeamCreate` and the template give none (`session` \| `in-process`) |
|
|
297
|
+
| `inProcessIdleTtlSec` | absent | free an idle child after N seconds (integer ≥ 1); absent keeps idle children until stopped |
|
|
298
|
+
| `inProcessLeanChildren` | `false` | children load no discovered extensions (cheaper, isolated from foreign extensions) |
|
|
299
|
+
| `inProcessCmdTimeoutMs` | 10000 | command ack deadline to the lead bridge (integer 1000–120000; out of range is rejected at settings write, never clamped) |
|
|
300
|
+
| `inProcessQueueTimeoutMs` | absent | opt-in: fail a teammate queued longer than this for a subagents slot (`spawn_timeout`) |
|
|
301
|
+
|
|
302
|
+
Parity gaps versus session mode: no direct user chat with a teammate (read-only subagent view), no resume,
|
|
303
|
+
members do not survive a lead `/reload`, no MCP in children, and parallelism is bounded by the subagents
|
|
304
|
+
`maxConcurrent` setting (shared with the lead's own `Agent` calls).
|
|
305
|
+
Skills: the child guard layers (prompt filter, `/skill:` refusal, `SKILL.md` read guard) apply to every grant, so an empty
|
|
306
|
+
grant hides all skills; a non-empty `skills` grant needs the subagents feature `loader_skills` (otherwise the spawn fails
|
|
307
|
+
with `skills_unavailable_in_process`), and without any grant a child sees no project or user skills. A member `cwd` outside
|
|
308
|
+
the lead's git repository needs the feature `cwd_scope` (otherwise `cwd_outside_scope`).
|
|
309
|
+
|
|
310
|
+
## REST routes
|
|
311
|
+
|
|
312
|
+
All under `/api/plugins/agent-teams/`; tiers live in `packages/shared/src/route-tiers.ts`.
|
|
313
|
+
`cwd` is required (`cwd_required`) and admitted by the host route-cwd admission.
|
|
314
|
+
Failures are `{ok:false, error, message?, details?}`.
|
|
315
|
+
|
|
316
|
+
| Route | Tier | Body / query |
|
|
317
|
+
|-------|------|--------------|
|
|
318
|
+
| `GET templates?cwd=` | observe | the folder's template listing (`{templates, warnings?}`) |
|
|
319
|
+
| `POST teams/start` | operate | `{template, goal, cwd, trustHooks?}` → starts a team with a new lead session; `hooks_untrusted` carries `details {hash, commands}` |
|
|
320
|
+
| `POST hook-trust` | operate | `{cwd, hash}` — record a confirmation; only for the hash the server currently computes for a trusted project template of that cwd (`hash_mismatch`) |
|
|
321
|
+
| `DELETE hook-trust?cwd=&hash=` | operate | revoke one confirmation; no `hash` removes every confirmation for the cwd |
|
|
322
|
+
| `GET teams/:id/plans` | observe | the team's plan requests (core visibility rule; foreign team → the unknown-team 404) |
|
|
323
|
+
| `POST teams/:id/members/:name/plan-decision` | operate | `{planId, approve, feedback?}` — the user's decision (team-control rule) |
|
|
324
|
+
| `POST openspec-relaunch` | operate | `{teamId, change}` — clear a `launch_failed` / lost launch of an `openspec-group` team and re-evaluate its launcher (`not_relaunchable` for any other state; see "OpenSpec templates") |
|
|
325
|
+
|
|
326
|
+
## Example templates
|
|
327
|
+
|
|
328
|
+
### `.pi/teams/review-pr.md` — eager roster with hooks
|
|
329
|
+
|
|
330
|
+
A project template (hooks ⇒ the first start asks for a hash-bound confirmation).
|
|
331
|
+
Hooks are quick checks that read the event JSON from stdin.
|
|
332
|
+
|
|
333
|
+
```markdown
|
|
334
|
+
---
|
|
335
|
+
name: review-pr
|
|
336
|
+
description: Review a pull request with two reviewers, gated by quick checks
|
|
337
|
+
maxTeammates: 4
|
|
338
|
+
spawn: eager
|
|
339
|
+
notify:
|
|
340
|
+
coalesceMs: 2000
|
|
341
|
+
defaultModel: "@fast"
|
|
342
|
+
defaultTools: [read, grep, find, ls, bash]
|
|
343
|
+
members:
|
|
344
|
+
- name: reviewer
|
|
345
|
+
count: 2
|
|
346
|
+
role: Reads the diff and reports defects with file and line
|
|
347
|
+
prompt: |
|
|
348
|
+
Review only what the goal names in {{cwd}}. Report findings as
|
|
349
|
+
TaskUpdate results: one defect per line, "path:line - problem".
|
|
350
|
+
- name: summarizer
|
|
351
|
+
role: Merges the reviewers' findings into SUMMARY.md
|
|
352
|
+
tools: [read, grep, find, ls, write]
|
|
353
|
+
hooks:
|
|
354
|
+
TaskCreated:
|
|
355
|
+
- command: |-
|
|
356
|
+
jq -e '.task.title | test("^[A-Za-z]+-?[0-9]*: ")' >/dev/null ||
|
|
357
|
+
{ echo "Start the task title with a topic and a colon, e.g. 'auth: check token expiry'" >&2; exit 2; }
|
|
358
|
+
timeoutMs: 3000
|
|
359
|
+
TaskCompleted:
|
|
360
|
+
- command: |-
|
|
361
|
+
jq -e '(.task.result // "") | length > 0' >/dev/null ||
|
|
362
|
+
{ echo "Complete the task with a result: what you checked and what you found" >&2; exit 2; }
|
|
363
|
+
timeoutMs: 3000
|
|
364
|
+
TeammateIdle:
|
|
365
|
+
- command: |-
|
|
366
|
+
p=$(cat)
|
|
367
|
+
[ "$(echo "$p" | jq -r .member)" != "summarizer" ] ||
|
|
368
|
+
[ -f "$(echo "$p" | jq -r .memberCwd)/SUMMARY.md" ] ||
|
|
369
|
+
{ echo "Write SUMMARY.md before going idle" >&2; exit 2; }
|
|
370
|
+
timeoutMs: 3000
|
|
371
|
+
---
|
|
372
|
+
You lead a pull-request review for: {{goal}}
|
|
373
|
+
|
|
374
|
+
Working directory: {{cwd}}
|
|
375
|
+
|
|
376
|
+
1. Create one task per area of the change (prefix every title with a topic and a colon).
|
|
377
|
+
2. The two reviewers claim tasks and report defects in the task result.
|
|
378
|
+
3. When all review tasks are completed, ask the summarizer to produce SUMMARY.md
|
|
379
|
+
and give the user a short verdict.
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Stdin can be read once, so a hook that needs several fields reads it into a
|
|
383
|
+
variable first (`p=$(cat)`, as the idle hook does). Keep every hook a quick check
|
|
384
|
+
(see **Long gates**).
|
|
385
|
+
|
|
386
|
+
### `.pi/teams/refactor-module.md` — plan approval with agent members
|
|
387
|
+
|
|
388
|
+
Members are teammate types from `.pi/agents` (`Explore`, `Audit`); the implementer
|
|
389
|
+
plans first and needs the **user's** approval.
|
|
390
|
+
|
|
391
|
+
```markdown
|
|
392
|
+
---
|
|
393
|
+
name: refactor-module
|
|
394
|
+
description: Refactor a module — an implementer plans first, an auditor reviews the result
|
|
395
|
+
maxTeammates: 3
|
|
396
|
+
spawn: eager
|
|
397
|
+
requirePlanApproval: false
|
|
398
|
+
defaultTools: [read, grep, find, ls, edit, write, bash]
|
|
399
|
+
members:
|
|
400
|
+
- name: scout
|
|
401
|
+
agent: Explore
|
|
402
|
+
role: Maps the module and its callers before any change
|
|
403
|
+
tools: [read, grep, find, ls]
|
|
404
|
+
- name: implementer
|
|
405
|
+
role: Implements the refactor after its plan is approved
|
|
406
|
+
requirePlanApproval: user
|
|
407
|
+
prompt: |
|
|
408
|
+
Goal: {{goal}}
|
|
409
|
+
Explore first, then submit your plan with PlanSubmit (steps, files touched,
|
|
410
|
+
tests to run). Do not change files until the plan is approved.
|
|
411
|
+
- name: auditor
|
|
412
|
+
agent: Audit
|
|
413
|
+
role: Reviews the finished change for defects and regressions
|
|
414
|
+
tools: [read, grep, find, ls]
|
|
415
|
+
---
|
|
416
|
+
You lead a refactor of: {{goal}}
|
|
417
|
+
|
|
418
|
+
Working directory: {{cwd}}
|
|
419
|
+
|
|
420
|
+
1. Ask `scout` for a map of the module and its callers; create tasks from it.
|
|
421
|
+
2. `implementer` plans first; its plan reaches you as a plan request. Only the
|
|
422
|
+
user can approve it (`requirePlanApproval: user`), so tell the user to review
|
|
423
|
+
the card instead of calling `PlanDecision` yourself.
|
|
424
|
+
3. After approval the implementer works the tasks; then ask `auditor` to review.
|
|
425
|
+
4. Report the outcome to the user.
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
`Explore` and `Audit` resolve from `<cwd>/.pi/agents/` (trusted project) or
|
|
429
|
+
`<piAgentDir>/agents/`; a missing one fails that member's spawn with
|
|
430
|
+
`agent_not_found` and only that member is marked `failed`.
|
|
431
|
+
|
|
432
|
+
## OpenSpec templates (`openspec-group`, `openspec-apply`)
|
|
433
|
+
|
|
434
|
+
Two templates ship inside the package (`templates/`, source `bundled`: listed after `project` and `user`,
|
|
435
|
+
shadowable by a trusted project or a user file of the same name, trusted, no hook confirmation, always
|
|
436
|
+
`mode: session`). A **profile** (server-side seeding, launcher, lock, guards) is bound to the template **name**
|
|
437
|
+
and only when the resolved source is `bundled`: a shadowing file of the same name runs as a plain template, and no
|
|
438
|
+
frontmatter key selects a profile. Both need a trusted project (`project_untrusted` otherwise), are started like
|
|
439
|
+
any template (`/agent-team start <template> <goal>` or the Start team dialog) and are checked by a **preflight**
|
|
440
|
+
that creates nothing when it refuses. The goal is a name of at most 64 characters (`^[a-z0-9][a-z0-9-]{0,63}$`).
|
|
441
|
+
`examples/` is documentation only: nothing under it is ever scanned, listed or started.
|
|
442
|
+
|
|
443
|
+
| Template | Goal | What the server does |
|
|
444
|
+
|----------|------|----------------------|
|
|
445
|
+
| `openspec-group` | an OpenSpec group id or name (`groups.json`) | one task per change (blocked by in-group `dependencies.yaml` edges), then one teammate per change, started lazily in the saved order, at most `openspecGroupParallel` at a time, each in its own git worktree `<repo>/.worktrees/os-<change>` on branch `os/<change>`; the teammate ships its change there with the ship skill and may commit, push and merge in its own worktree only |
|
|
446
|
+
| `openspec-apply` | one change name | tasks from the change's `tasks.md` (one per checkbox, or one per section for a wide change) plus a final `Review` task owned by a read-only `reviewer` that uses the `review-code` skill; two implementers share the lead's cwd; the lead is the only committer |
|
|
447
|
+
|
|
448
|
+
The lead commits nothing in a group (the teammates do) and never spawns teammates by hand. In an apply team the
|
|
449
|
+
teammates never commit; the lead commits once after `Review` is completed and the checkboxes are synced. Task and
|
|
450
|
+
change text is **data**, never instructions: every briefing says so, and the server notices carry codes and ids,
|
|
451
|
+
never task text.
|
|
452
|
+
|
|
453
|
+
### Group: worktrees, completion, relaunch
|
|
454
|
+
|
|
455
|
+
- Preflight codes, first failing wins: `invalid_args`, `project_untrusted`, `profile_unavailable`,
|
|
456
|
+
`invalid_config`, then `group_unknown` / `group_ambiguous` / `group_empty` / `groups_invalid` / `change_unknown` /
|
|
457
|
+
`tasks_unreadable`, `lead_not_repo_root` (the lead must run in the repository root), `batch_runner_active` (a live
|
|
458
|
+
ship-batch lock), `ship_skill_missing` / `review_skill_missing`, `base_not_found`, `too_many_tasks`,
|
|
459
|
+
`nothing_to_do`, `change_in_use` (another active team, or a start that has not bound yet, already drives the
|
|
460
|
+
change).
|
|
461
|
+
- A task is completed only by its teammate and only when the change is shipped: the server verifies that the
|
|
462
|
+
change was archived and merged (`not_shipped` otherwise; with the worktree gone it fetches `origin/<merge base>`
|
|
463
|
+
within `openspecFetchTimeoutMs`).
|
|
464
|
+
- A failed launch (`launch_failed <code>`) or a lost member wakes the lead with the code and the relaunch route;
|
|
465
|
+
nothing is relaunched automatically. The owner relaunches with
|
|
466
|
+
`POST /api/plugins/agent-teams/openspec-relaunch` (`{teamId, change}`, tier `operate`; `not_relaunchable` for any
|
|
467
|
+
other state) or deletes the team. There is no abandon route in v1.
|
|
468
|
+
- When the task is completed the slot is free at once and the member is asked to shut down; a rejection or
|
|
469
|
+
silence only notifies the lead.
|
|
470
|
+
|
|
471
|
+
### Apply: `tasks.md` hints and checkbox sync
|
|
472
|
+
|
|
473
|
+
The checkbox list always comes from the dashboard's own tasks route; the plugin only reads `tasks.md` a second
|
|
474
|
+
time for dependency hints, which are plain HTML comments the dashboard and the OpenSpec CLI ignore and the plugin
|
|
475
|
+
never rewrites:
|
|
476
|
+
|
|
477
|
+
```markdown
|
|
478
|
+
## 2. Engine
|
|
479
|
+
- [ ] 2.1 Parse the input
|
|
480
|
+
- [ ] 2.2 Build the plan <!-- after: 2.1 -->
|
|
481
|
+
- [ ] 2.3 Wire the CLI
|
|
482
|
+
<!-- after: 2.1, §1 -->
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
| Rule | Behaviour |
|
|
486
|
+
|------|-----------|
|
|
487
|
+
| Grammar | `<!-- after: <entry>[, <entry>…] -->`; an entry is a checkbox id (`2.1`) or a section number (`§2`); a bare number is a checkbox id first, then a section; the keyword is case-insensitive and whitespace-tolerant; at most 64 entries (the rest is dropped and reported) |
|
|
488
|
+
| Placement | trailing on a checkbox line, or on its own line directly below a checkbox (that box) or a `##` heading (every box of the section; a box-level hint wins); hints inside fenced code or on indented sub-bullets are ignored; the first hint of a box wins, a second is reported |
|
|
489
|
+
| Direction | every edge must point backward in the file; forward, self, duplicate and cyclic entries and unknown ids are dropped and listed once in the start notice |
|
|
490
|
+
| Default | without a hint a section waits for the previous non-empty section (a barrier); ticked boxes count as satisfied |
|
|
491
|
+
|
|
492
|
+
The runtime is the **sole writer** of checkboxes: when a task completes it ticks the matching box (matched by id
|
|
493
|
+
and text hash) through the dashboard route, serially per change, with a bounded retry; a failure is a lead notice
|
|
494
|
+
and the box stays as it is. Teammates of an apply team may not `write`/`edit` `openspec/changes/*/tasks.md` or
|
|
495
|
+
`…/specs/**`. **Limitations (advisory, stated honestly in every briefing):** that guard covers the `write` and
|
|
496
|
+
`edit` tools only, `bash` is not covered, so the sole-writer rule for a shell is a request backed by the lead's
|
|
497
|
+
diff review, not a sandbox. If the dashboard refuses the in-process toggle (`401`/`403`) the sync is not retried
|
|
498
|
+
and the lead gets a `sync_forbidden` notice naming the task ids: tick those boxes by hand. A team closed while a
|
|
499
|
+
sync is pending waits up to 5 s for it, then keeps `synced:false` and tells the lead.
|
|
500
|
+
|
|
501
|
+
### The `harness` resource lock
|
|
502
|
+
|
|
503
|
+
Group teammates share one docker test harness; `ResourceLock {action: acquire | release | status, name}` (teammate
|
|
504
|
+
tool, group teams only, resource `harness`) is a small server-owned mutex. `acquire` answers `granted:true`, or
|
|
505
|
+
`granted:false` with the holder and queue position and the teammate **ends its turn** (no polling): the oldest
|
|
506
|
+
waiter is handed the lock synchronously when it is released and woken by a `lock_grant` mail. The lock is released on
|
|
507
|
+
`release`, when its holder settles idle, goes away or fails, on team close, and after `openspecLockTtlMs`
|
|
508
|
+
(default 30 min; the lead is told). A teammate must **not end its turn while holding** it. The lock is advisory: it
|
|
509
|
+
does not stop a direct harness start, and the harness start script's own memory guard stays the hard backstop.
|
|
510
|
+
|
|
511
|
+
### Seams, host services and configuration
|
|
512
|
+
|
|
513
|
+
The profiles use only core registries (start profiles, spawn contributors, op gates, dispatch eligibility,
|
|
514
|
+
server mail and lead notices, the per-member committer) and refuse to start (`profile_unavailable`) when one is
|
|
515
|
+
missing. To reach the dashboard's own REST routes (git worktrees for the group, the tasks list and toggle for
|
|
516
|
+
apply) the plugin goes through a **host-provided loopback service**, never through a credential of its own; when
|
|
517
|
+
the host denies or does not provide it, the sync reports `sync_forbidden` and a worktree step fails the launch
|
|
518
|
+
with a typed `launch_failed` code. State lives in a sidecar per team (`<dataDir>/openspec/<teamId>.json`),
|
|
519
|
+
pruned with closed teams; if it is lost the launcher, sync and lock stay off for that team and the lead is told.
|
|
520
|
+
|
|
521
|
+
| Key | Default | Meaning |
|
|
522
|
+
|-----|---------|---------|
|
|
523
|
+
| `openspecGroupParallel` | 2 | changes shipped at the same time (clamped into `1..maxTeammates`) |
|
|
524
|
+
| `openspecShipSkill` | `ship-it` | skill a group teammate loads first |
|
|
525
|
+
| `openspecReviewSkill` | `review-code` | skill of the apply reviewer |
|
|
526
|
+
| `openspecWorktreeBase` | `develop` | branch a new change worktree forks from |
|
|
527
|
+
| `openspecMergeBase` | `develop` | branch the ship skill merges into (the completion gate looks for the archive there) |
|
|
528
|
+
| `openspecLockTtlMs` | 1800000 | lock time limit (clamped into 60000..86400000) |
|
|
529
|
+
| `openspecFetchTimeoutMs` | 8000 | bound of the gate's `git fetch` (max 10000) |
|
|
530
|
+
|
|
531
|
+
Invalid values fall back to the default (integers only) with a warning; names and refs are validated before use
|
|
532
|
+
(`invalid_config`).
|
|
533
|
+
|
|
534
|
+
### Example: `examples/judo-modules.md`
|
|
535
|
+
|
|
536
|
+
A judo-ng-style per-module template (one teammate per Maven module in rank order, a fast `TaskCompleted` hook that
|
|
537
|
+
checks a verification stamp) with its two helper script sketches in `examples/judo-modules.helpers.md`. It is
|
|
538
|
+
documentation: copy it into a project's `.pi/teams/` to use it.
|
|
539
|
+
|
|
540
|
+
## Teammate limits (advisory with `bash`)
|
|
541
|
+
|
|
542
|
+
A teammate runs behind a guard (tool allowlist, skill allowlist, sleep-poll and git-write guards, spawn-time `PI_EXT_AGENT_TEAMS_*` policy). The tool and skill allowlists are **advisory while the teammate has the `bash` tool**: a shell can still read files or run commands outside them (`bash -c "git commit"`, `$(…)` indirection and scripts are not chased). For a stricter limit give the teammate a `tools` list without `bash`. `blockSleepPolling` and `blockGitWrite` (both default true) are plugin settings.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# judo-modules: the two helper script sketches (documentation only)
|
|
2
|
+
|
|
3
|
+
Documentation for `judo-modules.md`, a judo-ng-style per-module team template (one teammate per Maven
|
|
4
|
+
module, in rank order). **Documentation only:** the plugin never scans, lists or starts anything under
|
|
5
|
+
`examples/` (`GET …/templates` does not show `judo-modules`), and it does not execute, install or reference the
|
|
6
|
+
scripts below. The template uses only the template features of the templates-hooks change (`spawn: lead`,
|
|
7
|
+
`autoDispatch: false`, a `TaskCompleted` hook) and no code of this plugin.
|
|
8
|
+
|
|
9
|
+
## Use it
|
|
10
|
+
|
|
11
|
+
1. Copy `judo-modules.md` to `<project>/.pi/teams/judo-modules.md` of a trusted project. The first start asks
|
|
12
|
+
you to confirm its hook (see the README "Hooks" section).
|
|
13
|
+
2. Copy the two scripts below into the consuming repository as `scripts/verify-module.sh` and
|
|
14
|
+
`scripts/team-verify-stamp.sh`, adapt the build command and the module layout, and make them executable.
|
|
15
|
+
|
|
16
|
+
## How it works
|
|
17
|
+
|
|
18
|
+
- Rank -> `blockedBy` is done by the lead from the playbook (the module rank is the roster order).
|
|
19
|
+
- A `TaskCompleted` hook may run only for the shared op-gate budget (12 s by default), so it cannot run
|
|
20
|
+
`mvn verify`. The pattern is a verification **stamp**: the teammate runs `scripts/verify-module.sh <module>`
|
|
21
|
+
in its own turn; the script runs the build and writes `<module>/target/.team-verify` with the hash of the
|
|
22
|
+
module tree. The hook only compares that stamp with the current tree hash and exits 2 ("run
|
|
23
|
+
scripts/verify-module.sh") when the stamp is missing or stale; the teammate verifies and completes again.
|
|
24
|
+
- Teammates run in the lead's cwd (one shared checkout) and never commit; the lead is the only committer.
|
|
25
|
+
|
|
26
|
+
## `scripts/verify-module.sh` (run by the teammate, in its own turn)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
#!/usr/bin/env bash
|
|
30
|
+
# Usage: scripts/verify-module.sh <module>
|
|
31
|
+
# Runs the module build and, only when it passes, records the tree hash it verified.
|
|
32
|
+
set -euo pipefail
|
|
33
|
+
module="${1:?usage: verify-module.sh <module>}"
|
|
34
|
+
root="$(git rev-parse --show-toplevel)"
|
|
35
|
+
dir="$root/$module"
|
|
36
|
+
[[ "$module" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || { echo "not a module name: $module" >&2; exit 64; }
|
|
37
|
+
[ -d "$dir" ] || { echo "no such module: $module" >&2; exit 64; }
|
|
38
|
+
|
|
39
|
+
# The same hash the hook computes: tracked + untracked-but-not-ignored files of the module.
|
|
40
|
+
tree_hash() {
|
|
41
|
+
(cd "$dir" && git ls-files -co --exclude-standard -z | sort -z | xargs -0 shasum -a 256 | shasum -a 256 | cut -d' ' -f1)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
before="$(tree_hash)"
|
|
45
|
+
(cd "$root" && mvn -q -pl "$module" -am verify)
|
|
46
|
+
after="$(tree_hash)"
|
|
47
|
+
# A file that changed while the build ran invalidates the verification.
|
|
48
|
+
[ "$before" = "$after" ] || { echo "module changed during verification; run again" >&2; exit 1; }
|
|
49
|
+
|
|
50
|
+
mkdir -p "$dir/target"
|
|
51
|
+
printf '%s\n' "$after" > "$dir/target/.team-verify"
|
|
52
|
+
echo "verified $module ($after)"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## `scripts/team-verify-stamp.sh` (the `TaskCompleted` hook; fast, no build)
|
|
56
|
+
|
|
57
|
+
The hook receives the event JSON on stdin. Exit 0 allows the completion; exit 2 blocks it and stderr is
|
|
58
|
+
returned to the teammate as feedback.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
#!/usr/bin/env bash
|
|
62
|
+
# Allows a task completion only when the module's verification stamp matches the current tree.
|
|
63
|
+
set -uo pipefail
|
|
64
|
+
event="$(cat)"
|
|
65
|
+
module="$(printf '%s' "$event" | jq -r '.task.title // empty')" # the task is titled `<module>`
|
|
66
|
+
[[ "$module" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || exit 0 # not a module task: nothing to check
|
|
67
|
+
root="$(git rev-parse --show-toplevel)"
|
|
68
|
+
dir="$root/$module"
|
|
69
|
+
[ -d "$dir" ] || exit 0
|
|
70
|
+
|
|
71
|
+
stamp="$dir/target/.team-verify"
|
|
72
|
+
current="$(cd "$dir" && git ls-files -co --exclude-standard -z | sort -z | xargs -0 shasum -a 256 | shasum -a 256 | cut -d' ' -f1)"
|
|
73
|
+
if [ ! -f "$stamp" ] || [ "$(cat "$stamp")" != "$current" ]; then
|
|
74
|
+
echo "module $module is not verified for its current files: run scripts/verify-module.sh $module, then complete the task again" >&2
|
|
75
|
+
exit 2
|
|
76
|
+
fi
|
|
77
|
+
exit 0
|
|
78
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: judo-modules
|
|
3
|
+
description: One teammate per Maven module, in rank order
|
|
4
|
+
mode: session
|
|
5
|
+
maxTeammates: 4
|
|
6
|
+
autoDispatch: false
|
|
7
|
+
spawn: lead
|
|
8
|
+
hooks:
|
|
9
|
+
TaskCompleted: [{ command: "bash scripts/team-verify-stamp.sh", timeoutMs: 8000 }]
|
|
10
|
+
members:
|
|
11
|
+
- { name: core, prompt: "Module judo-core. Run scripts/verify-module.sh judo-core before completing." }
|
|
12
|
+
- { name: engine, prompt: "Module judo-engine. Needs core." }
|
|
13
|
+
- { name: ui, prompt: "Module judo-ui. Needs engine." }
|
|
14
|
+
---
|
|
15
|
+
You lead modules of {{goal}} in {{cwd}}. For each module in rank order create one task titled `<module>`
|
|
16
|
+
(blockedBy the tasks of lower rank), assign it to the matching member (`TaskUpdate owner`), and spawn the members
|
|
17
|
+
with TeammateSpawn (they run in {{cwd}}). You commit; teammates do not.
|