ai-fob 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,394 @@
1
+ ---
2
+ description: Orchestrate a full multi-phase feature build by launching Claude Code teammates through inter-agent-team
3
+ argument-hint: "<path to HL plan spec> [start phase] [end phase]"
4
+ ---
5
+
6
+ # Build Feature — Inter-Agent Team Claude Code Runner
7
+
8
+ Orchestrate a full multi-phase feature build by launching one Claude Code teammate per phase through the `inter_agent_team` tool.
9
+
10
+ This workflow exists to avoid headless Claude Code execution (`claude -p`) while still automating phase sequencing. Each phase runs in a live Claude Code session launched with the existing Claude Code command:
11
+
12
+ ```txt
13
+ /build-phase-V2 <HL_PLAN_PATH> <PHASE_NUMBER>
14
+ ```
15
+
16
+ The Pi agent is the supervisor/orchestrator. Claude Code performs the phase build. Pi watches durable filesystem artifacts (`phase_completion_report.md` and `specs/STATE.md`) to decide when a phase has completed and whether to continue.
17
+
18
+ ## Required skills/tools
19
+
20
+ Before reading or interpreting `specs/STATE.md`, load and follow the `FOB-state-context` skill.
21
+
22
+ Use the `inter_agent_team` tool to create, show, attach only if explicitly requested, and close Claude Code teammates.
23
+
24
+ Do not use headless Claude Code (`claude -p`) in this workflow.
25
+
26
+ ## Arguments
27
+
28
+ Raw arguments: `$ARGUMENTS`
29
+
30
+ Parse into:
31
+
32
+ - `HL_PLAN_PATH`: first argument, required
33
+ - `START_PHASE`: second argument, optional, default: first incomplete phase or `1`
34
+ - `END_PHASE`: third argument, optional, default: total phases from plan frontmatter
35
+
36
+ If `HL_PLAN_PATH` is missing, stop with:
37
+
38
+ ```txt
39
+ Usage: /build-feature-interagent <path to HL plan spec> [start phase] [end phase]
40
+ ```
41
+
42
+ ## Derived variables
43
+
44
+ Compute in Step 0:
45
+
46
+ - `PROJECT_ROOT`: nearest ancestor containing `.pi/` or `.claude/`, preferably git root when available
47
+ - `HL_PLAN_PATH_ABS`: absolute path to high-level plan markdown file
48
+ - `HL_PLAN_PATH_REL`: project-root-relative path to high-level plan markdown file
49
+ - `SPEC_DIR`: parent directory of `HL_PLAN_PATH_ABS`
50
+ - `SPEC_DIR_REL`: project-root-relative path to `SPEC_DIR`
51
+ - `TASK_NAME`: `task:` from HL plan YAML frontmatter
52
+ - `TOTAL_PHASES`: `phases:` from HL plan YAML frontmatter
53
+ - `FEATURE_SLUG`: basename of `SPEC_DIR`
54
+ - `TEAM_NAME`: `build-feature-{FEATURE_SLUG}`
55
+ - `WORKFLOW_STATE_DIR`: `{PROJECT_ROOT}/.pi/inter-agent-team/workflows/build-feature`
56
+ - `WORKFLOW_STATE_FILE`: `{WORKFLOW_STATE_DIR}/{FEATURE_SLUG}.json`
57
+ - `STATE_MD`: nearest `specs/STATE.md` according to `FOB-state-context`; usually `{PROJECT_ROOT}/specs/STATE.md`
58
+ - `LEARNINGS_FILE`: `{SPEC_DIR}/build-feature-interagent-learnings.md`
59
+
60
+ ## Workflow state file
61
+
62
+ Maintain a resumable orchestration state file at `WORKFLOW_STATE_FILE`.
63
+
64
+ Shape:
65
+
66
+ ```json
67
+ {
68
+ "workflow": "build-feature-interagent",
69
+ "status": "running",
70
+ "planPath": "specs/example/example_V1.md",
71
+ "featureSlug": "example",
72
+ "teamName": "build-feature-example",
73
+ "createdAt": "ISO timestamp",
74
+ "updatedAt": "ISO timestamp",
75
+ "startPhase": 1,
76
+ "endPhase": 3,
77
+ "currentPhase": 1,
78
+ "phases": [
79
+ {
80
+ "phase": 1,
81
+ "status": "completed | running | blocked | failed | interrupted | skipped",
82
+ "agentName": "phase-1-builder",
83
+ "launchPrompt": "/build-phase-V2 specs/example/example_V1.md 1",
84
+ "startedAt": "ISO timestamp",
85
+ "completedAt": "ISO timestamp",
86
+ "completionReport": "specs/example/phase1_name/phase_completion_report.md",
87
+ "result": "complete | blocked | failed | unknown",
88
+ "validationResult": "pass | pass-with-followups | blocked | fail | unknown",
89
+ "stateHashBefore": "sha256",
90
+ "stateHashAfter": "sha256"
91
+ }
92
+ ]
93
+ }
94
+ ```
95
+
96
+ Read and update this file using safe read-modify-write behavior. Create parent directories if needed.
97
+
98
+ ## Completion signals
99
+
100
+ A phase is complete when the build-phase-V2 Claude teammate has produced durable completion evidence.
101
+
102
+ Use layered detection:
103
+
104
+ 1. Primary signal: a matching phase completion report exists and was created or modified after the phase launch:
105
+
106
+ ```txt
107
+ {SPEC_DIR}/phase{N}_*/phase_completion_report.md
108
+ ```
109
+
110
+ 2. Secondary signal: `STATE_MD` changed after launch, or the matching phase in `STATE_MD` is marked complete.
111
+
112
+ 3. Classification signal: the phase report YAML frontmatter contains:
113
+
114
+ ```yaml
115
+ type: phase-report
116
+ status: complete | blocked | failed
117
+ validation-result: pass | pass-with-followups | blocked | fail
118
+ ```
119
+
120
+ Proceed automatically only when:
121
+
122
+ ```txt
123
+ status: complete
124
+ ```
125
+
126
+ Treat `validation-result: pass-with-followups` as complete and continue, while recording follow-ups in the learnings file.
127
+
128
+ Stop automatically when:
129
+
130
+ ```txt
131
+ status: blocked
132
+ status: failed
133
+ validation-result: blocked
134
+ validation-result: fail
135
+ ```
136
+
137
+ If report parsing is ambiguous, stop and summarize the uncertainty. Do not launch the next phase on ambiguous evidence.
138
+
139
+ ## Polling defaults
140
+
141
+ Default poll interval:
142
+
143
+ ```txt
144
+ 60 seconds
145
+ ```
146
+
147
+ Maximum no-evidence wait before surfacing a stall warning:
148
+
149
+ ```txt
150
+ 30 minutes
151
+ ```
152
+
153
+ Do not kill a running Claude Code teammate solely because polling has not observed progress. Surface the stall and continue polling unless the user instructs otherwise.
154
+
155
+ ## Step 0: Parse, validate, and resume-detect
156
+
157
+ 1. Parse arguments.
158
+ 2. Resolve `PROJECT_ROOT`:
159
+ - prefer `git rev-parse --show-toplevel`
160
+ - otherwise walk upward from `HL_PLAN_PATH` until finding `.pi/` or `.claude/`
161
+ 3. Resolve `HL_PLAN_PATH_ABS` and `HL_PLAN_PATH_REL`.
162
+ 4. Verify `HL_PLAN_PATH_ABS` exists and is a Markdown file.
163
+ 5. Read the HL plan.
164
+ 6. Parse YAML frontmatter:
165
+ - `task:` → `TASK_NAME`; required
166
+ - `phases:` → `TOTAL_PHASES`; required positive integer
167
+ 7. Validate `START_PHASE` and `END_PHASE` if provided.
168
+ 8. Load `FOB-state-context` before reading `STATE_MD`.
169
+ 9. Locate/read `STATE_MD`.
170
+ 10. Create/read `WORKFLOW_STATE_FILE`.
171
+ 11. Reconcile prior state with filesystem:
172
+ - For each phase `1..TOTAL_PHASES`, look for `phase{N}_*/phase_completion_report.md`.
173
+ - If valid report exists with `status: complete`, mark phase completed in workflow state.
174
+ - If report exists with `status: blocked` or `status: failed`, mark phase blocked/failed and stop unless user explicitly asks to resume past it.
175
+ - If workflow state says `running` but there is no live teammate/session visible through `inter_agent_team list`, mark it `interrupted`.
176
+ 12. Determine the next phase:
177
+ - If `START_PHASE` was provided, use it.
178
+ - Otherwise use the first phase in the requested range that is not completed.
179
+ 13. If all phases in range are already complete, write final summary and stop.
180
+
181
+ ## Step 1: Initialize learnings and pre-flight log
182
+
183
+ Create or append to `LEARNINGS_FILE`.
184
+
185
+ Initial section:
186
+
187
+ ```markdown
188
+ # Build Feature Inter-Agent Learnings: {TASK_NAME}
189
+
190
+ Spec: {HL_PLAN_PATH_REL}
191
+ Project Root: {PROJECT_ROOT}
192
+ Total Phases: {TOTAL_PHASES}
193
+ Requested Range: {START_PHASE}-{END_PHASE}
194
+ Started/Resumed: {ISO timestamp}
195
+ Workflow State: {WORKFLOW_STATE_FILE}
196
+
197
+ ---
198
+ ```
199
+
200
+ Append a pre-flight section:
201
+
202
+ ```markdown
203
+ ## Pre-Flight Checks
204
+ Timestamp: {ISO timestamp}
205
+
206
+ - Git status: {clean | N uncommitted changes | unavailable}
207
+ - STATE.md: {STATE_MD path, task found/not found, completed phases if detected}
208
+ - Existing workflow state: {new | resumed}
209
+ - Existing reports: {phase report summary}
210
+ - Team strategy: one team per feature, one Claude Code teammate per phase
211
+ - Claude launch mode: claude --dangerously-skip-permissions "{launch prompt}"
212
+ ```
213
+
214
+ ## Step 2: Ensure feature team exists
215
+
216
+ Use a single active team for the feature:
217
+
218
+ ```txt
219
+ TEAM_NAME = build-feature-{FEATURE_SLUG}
220
+ ```
221
+
222
+ Before creating a new team:
223
+
224
+ 1. Call `inter_agent_team list`.
225
+ 2. If an active team with `TEAM_NAME` exists, reuse it.
226
+ 3. Otherwise create the team when launching the first phase.
227
+
228
+ Important: the current `inter_agent_team create` action creates team and teammates together. If no active team exists, create the feature team with the first phase teammate. If a team exists and adding new teammates is not supported yet, create a new phase-specific team named:
229
+
230
+ ```txt
231
+ build-feature-{FEATURE_SLUG}-phase-{N}
232
+ ```
233
+
234
+ Record the actual team name/id in `WORKFLOW_STATE_FILE`.
235
+
236
+ ## Step 3: Launch and supervise phases sequentially
237
+
238
+ For each phase `N` from current phase through `END_PHASE`:
239
+
240
+ ### 3.1 Baseline before launch
241
+
242
+ Record:
243
+
244
+ - current timestamp `PHASE_STARTED_AT`
245
+ - `STATE_MD` hash before launch, if file exists
246
+ - any existing matching `phase{N}_*/phase_completion_report.md` path and hash/mtime
247
+ - current workflow state
248
+
249
+ If a valid completion report already exists and phase is marked complete, skip to the next phase.
250
+
251
+ ### 3.2 Launch Claude Code teammate
252
+
253
+ Construct:
254
+
255
+ ```txt
256
+ AGENT_NAME = phase-{N}-builder
257
+ LAUNCH_PROMPT = /build-phase-V2 {HL_PLAN_PATH_REL} {N}
258
+ ```
259
+
260
+ Call `inter_agent_team create` with a Claude Code teammate:
261
+
262
+ ```ts
263
+ inter_agent_team({
264
+ action: "create",
265
+ name: "build-feature-{FEATURE_SLUG}-phase-{N}",
266
+ task: "Run Claude Code build phase {N} for {HL_PLAN_PATH_REL} and write the standard phase completion report.",
267
+ agents: [{
268
+ name: "phase-{N}-builder",
269
+ role: "Claude Code build-phase-V2 runner for phase {N}",
270
+ runtime: "claude-code",
271
+ runtimeArgs: ["--dangerously-skip-permissions"],
272
+ launchPrompt: "/build-phase-V2 {HL_PLAN_PATH_REL} {N}"
273
+ }]
274
+ })
275
+ ```
276
+
277
+ Record team id/name, agent id/name, launch prompt, state hash before launch, and timestamp in `WORKFLOW_STATE_FILE`.
278
+
279
+ Do not attach unless the user explicitly asks.
280
+
281
+ ### 3.3 Poll for completion
282
+
283
+ Loop:
284
+
285
+ 1. Sleep 60 seconds:
286
+
287
+ ```bash
288
+ sleep 60
289
+ ```
290
+
291
+ 2. Search for phase report:
292
+
293
+ ```bash
294
+ find "{SPEC_DIR}" -maxdepth 2 -type f -path "*/phase{N}_*/phase_completion_report.md" -print 2>/dev/null
295
+ find "{SPEC_DIR}" -maxdepth 2 -type f -path "*/phase_completion_report.md" -print 2>/dev/null | grep "/phase{N}_" || true
296
+ ```
297
+
298
+ 3. Check report mtime/hash against baseline. Prefer reports modified after `PHASE_STARTED_AT`.
299
+ 4. Read candidate report if found.
300
+ 5. Parse YAML frontmatter from the report.
301
+ 6. Check `STATE_MD` hash and phase marker.
302
+ 7. Optionally call `inter_agent_team show` for passive inspection if no file progress is observed for multiple polls. Do not attach automatically.
303
+ 8. Update `WORKFLOW_STATE_FILE` with last poll timestamp and observed evidence.
304
+
305
+ ### 3.4 Completion decision
306
+
307
+ If report frontmatter is valid:
308
+
309
+ - `status: complete`:
310
+ 1. Mark phase completed in workflow state.
311
+ 2. Record `completionReport`, `validationResult`, and `stateHashAfter`.
312
+ 3. Append phase summary to `LEARNINGS_FILE`.
313
+ 4. Close the phase teammate/team with `inter_agent_team close_team` for the phase team.
314
+ 5. Continue to phase `N+1`.
315
+
316
+ - `status: blocked`:
317
+ 1. Mark phase blocked in workflow state.
318
+ 2. Append blocked summary to `LEARNINGS_FILE`.
319
+ 3. Close or leave teammate based on user preference; default close after report exists.
320
+ 4. Stop the workflow. Do not launch next phase.
321
+
322
+ - `status: failed` or `status: fail`:
323
+ 1. Mark phase failed in workflow state.
324
+ 2. Append failure summary to `LEARNINGS_FILE`.
325
+ 3. Close or leave teammate based on user preference; default close after report exists.
326
+ 4. Stop the workflow. Do not launch next phase.
327
+
328
+ If report exists but frontmatter is invalid or missing required fields, stop and surface the issue.
329
+
330
+ If `STATE_MD` changed but no report exists, keep polling. `STATE.md` alone is not enough to proceed.
331
+
332
+ ### 3.5 Stall warning
333
+
334
+ If no report and no `STATE_MD` hash change have been observed for 30 minutes:
335
+
336
+ 1. Call `inter_agent_team show` for passive output inspection.
337
+ 2. Append a stall warning to `LEARNINGS_FILE`.
338
+ 3. Present options to the user:
339
+ - continue polling
340
+ - attach to teammate
341
+ - stop and leave teammate running
342
+ - close teammate and mark phase interrupted
343
+
344
+ Default if no instruction is available: continue polling.
345
+
346
+ ## Step 4: Resume behavior after interruption
347
+
348
+ When this prompt is run again for the same plan:
349
+
350
+ 1. Load `WORKFLOW_STATE_FILE`.
351
+ 2. Call `inter_agent_team list` to see live/active teams.
352
+ 3. Reconcile state with filesystem reports.
353
+ 4. For any phase marked `running`:
354
+ - If its completion report now exists and is valid, mark it complete/blocked/failed according to report.
355
+ - If there is no live teammate and no report, mark it `interrupted`.
356
+ - If there is a live teammate, continue polling that phase instead of launching a duplicate.
357
+ 5. Continue from the first incomplete/interrupted phase in range.
358
+ 6. If relaunching an interrupted phase, rely on `/build-phase-V2`'s own resume detection from `STATE.md` and phase artifacts.
359
+
360
+ Do not duplicate-run a phase if a live teammate for that phase is already active.
361
+
362
+ ## Step 5: Final report
363
+
364
+ When all requested phases complete, close/archive any phase teams created by this workflow that are still active and write:
365
+
366
+ ```markdown
367
+ ## Final Feature Summary
368
+ Completed: {ISO timestamp}
369
+ Status: completed | partial | blocked | failed | interrupted
370
+ Phases requested: {START_PHASE}-{END_PHASE}
371
+ Phases completed: {list}
372
+ Phases stopped: {list or none}
373
+ Reports:
374
+ - Phase N: {report path} ({status}, validation-result: {validationResult})
375
+ ```
376
+
377
+ Also print a concise final response to the user with:
378
+
379
+ - overall status
380
+ - completed phases
381
+ - stopped/blocked phase if any
382
+ - key report paths
383
+ - workflow state file path
384
+ - learnings file path
385
+
386
+ ## Safety and constraints
387
+
388
+ - Do not run `claude -p`.
389
+ - Do not launch phases in parallel unless the user explicitly requests parallel phase execution.
390
+ - Do not attach automatically.
391
+ - Do not proceed past blocked/failed/ambiguous reports without explicit user instruction.
392
+ - Close phase teams after a report is produced and classified, unless the user asks to keep them open.
393
+ - Treat `pass-with-followups` as complete but record follow-ups.
394
+ - Preserve `/build-phase-V2` as the source of truth for actual phase implementation, validation, reporting, and `STATE.md` updates.
package/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.1",
2
+ "version": "1.11.2",
3
3
  "presets": {
4
4
  "coding": {
5
5
  "description": "Research-driven coding workflow",
@@ -101,7 +101,8 @@
101
101
  "prompts": [
102
102
  "explore-codebase",
103
103
  "build-phase",
104
- "build-feature"
104
+ "build-feature",
105
+ "build-feature-interagent"
105
106
  ],
106
107
  "extensions": [
107
108
  "pinned-response",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-fob",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Deploy research-driven AI coding assistant assets (skills, agents, commands) into your projects",
5
5
  "bin": {
6
6
  "ai-fob": "bin/install.js"