Skip to content

Commit efdda7a

Browse files
Updated implement-extensions commands to uses Hypha when possible
1 parent 3d73756 commit efdda7a

3 files changed

Lines changed: 807 additions & 84 deletions

File tree

.claude/commands/implement-extensions-batch.md

Lines changed: 183 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,33 @@ prompt as follows BEFORE the `Agent(...)` call:
9191
The team template itself does NOT need to change. The single-file
9292
`/implement-extensions` command continues to use the unadapted prompts.
9393

94+
## Sub-agent spawn mode (applies to EVERY `Agent(...)` call below)
95+
96+
Every `Agent(...)` call in this command MUST pass `mode: "acceptEdits"`
97+
explicitly. Same rule as the single-file command — see the "Sub-agent spawn
98+
mode" section in `.claude/commands/implement-extensions.md` for the
99+
rationale. Applies to: legacy researcher (8a), Hypha researcher (8b),
100+
comparator (8.5), implementer (9), tester (9), regression-sweep tester (11),
101+
reviewer (12).
102+
103+
## Pre-flight: Hypha plugin detection (runs before step 1)
104+
105+
Identical semantics to the single-file command's Hypha pre-flight (see
106+
`.claude/commands/implement-extensions.md` → "Pre-flight: Hypha plugin
107+
detection"). Summary:
108+
109+
- Record `hypha_available: bool` at the very start of the invocation.
110+
- When `hypha_available == true`, both researchers run in parallel at Phase R
111+
(step 8), followed by the comparator (step 8.5), followed by the new
112+
Gate B-C (batch-scoped, one pick across all N files).
113+
- When `hypha_available == false`, surface a one-line install recommendation
114+
once and continue with the legacy-only flow — steps 8, 9, ..., 14 as
115+
written. Skip step 8b, step 8.5, and Gate B-C entirely.
116+
- On mid-run downgrade (Hypha errors between 8b and 8.5), stop dispatching
117+
Hypha work, skip 8.5 + Gate B-C, proceed with `active_notes_file` per
118+
file = its legacy `NOTES_FILE`. Surface the downgrade in step 14's final
119+
summary.
120+
94121
## Workflow
95122

96123
### 1. Parse `$ARGUMENTS` and validate the batch
@@ -125,7 +152,10 @@ step 2:
125152
| `TARGET_INTERFACE` | `I<Foo>` — find via Glob `SysML2.NET/Core/AutoGenPoco/**/I<Foo>.cs` |
126153
| `TARGET_METACLASS` | `<Foo>` |
127154
| `SUBJECT_PARAM_NAME` | lowercase first char of `<Foo>` + `<Foo>[1..]` + `Subject` |
128-
| `NOTES_FILE` | `.team-notes/<foo>-extensions-spec.md` (kebab-case) |
155+
| `NOTES_FILE` | `.team-notes/<foo>-extensions-spec.md` (kebab-case) — legacy researcher output |
156+
| `HYPHA_NOTES_FILE` | `.team-notes/<foo>-extensions-spec-hypha.md` — only when `hypha_available == true` |
157+
| `COMPARISON_FILE` | `.team-notes/<foo>-extensions-comparison.md` — only when `hypha_available == true` |
158+
| `ACTIVE_NOTES_FILE` | per-file, computed at Gate B-C (or defaulted to the legacy `NOTES_FILE` when Hypha is off). Substituted into implementer/tester/reviewer prompts. |
129159
| `TEAM_NAME` | `batch-extensions-impl` (one team name for the whole batch) |
130160
| `ISSUE_NUMBER` | from `gh issue list … --search "SysML2.NET/Extend/<Foo>Extensions.cs in:body"` |
131161

@@ -211,15 +241,20 @@ Idempotent — re-assigning is a no-op on `gh`. Report success/failure per issue
211241
on failure, log and continue (an unassignable issue is not a blocker for the
212242
implementation itself).
213243

214-
### 8. Phase R — Spawn the batch researcher (ONE agent)
244+
### 8. Phase R — Spawn the batch researcher(s)
245+
246+
Split into 8a + 8b based on `hypha_available` from the pre-flight.
247+
248+
#### 8a. Legacy batch researcher (ALWAYS run)
215249

216250
**One `Agent(...)` call** for the entire batch:
217251

218252
- `subagent_type: "general-purpose"`
219253
- `model: <researcher_model>` per the batch-wide step-5 grade.
220254
- Foreground.
221-
- Prompt: the v2 researcher prompt from `.claude/team-templates/extension-impl.md`,
222-
adapted per "Prompt adaptation rules" above:
255+
- Prompt: the v2 legacy researcher prompt from
256+
`.claude/team-templates/extension-impl.md`, adapted per "Prompt adaptation
257+
rules" above:
223258
- Allowed-write list: ALL N notes files
224259
(`.team-notes/<foo1>-extensions-spec.md`, …,
225260
`.team-notes/<fooN>-extensions-spec.md`).
@@ -228,9 +263,106 @@ implementation itself).
228263
- "When done" SendMessage payload: a per-file summary (file → derivation
229264
source → transitive stub-blocker flags), not a single blob.
230265

231-
After the agent returns, **read each notes file** yourself to verify coverage,
232-
spec-text-only flags, and stub-blocker flags. If a notes file is missing or
233-
empty, re-dispatch the researcher with a focused brief naming only that file.
266+
#### 8b. Hypha batch researcher (ONLY when `hypha_available == true`)
267+
268+
**Spawn 8a and 8b in the SAME orchestrator message** — one message, two
269+
`Agent(...)` calls, both foreground. They run in parallel with completely
270+
independent contexts.
271+
272+
- `subagent_type: "general-purpose"`
273+
- `model: <researcher_model>` — same tier as legacy.
274+
- Foreground.
275+
- Prompt: the v2 `hypha-researcher` prompt, adapted per "Prompt adaptation
276+
rules":
277+
- Allowed-write list: ALL N Hypha notes files
278+
(`.team-notes/<foo1>-extensions-spec-hypha.md`, …,
279+
`.team-notes/<fooN>-extensions-spec-hypha.md`).
280+
- "Methods to research" enumeration: same as legacy (identical union of
281+
all N method lists, grouped per file).
282+
- The forbidden-reads list is UNCHANGED from the single-file prompt —
283+
the batch still MUST NOT touch `Resources/*.uml` or
284+
`Resources/specification/*.pdf.txt` regardless of file count.
285+
- Same per-file summary payload shape as 8a, plus explicit flags on
286+
methods where Hypha returned "not found" or had to fall back to a
287+
spec citation.
288+
289+
#### 8c. Post-researcher coverage check
290+
291+
After BOTH agents return (or just 8a in a legacy-only run), read each notes
292+
file yourself to verify coverage. Re-dispatch the individual researcher whose
293+
file(s) are empty / missing sections. Do NOT proceed until all files
294+
(N legacy + N Hypha, or just N legacy) are complete.
295+
296+
If `hypha_available == false`, skip 8b + 8c-Hypha, skip step 8.5 + Gate B-C,
297+
and proceed directly to step 9 (Phase IT) with each file's `ACTIVE_NOTES_FILE`
298+
defaulted to its legacy `NOTES_FILE`.
299+
300+
### 8.5. Phase C — Spawn the batch comparator (ONLY when `hypha_available == true`)
301+
302+
**One `Agent(...)` call** for the whole batch:
303+
304+
- `subagent_type: "general-purpose"`
305+
- `model: <researcher_model>` — same tier as the researchers.
306+
- Foreground.
307+
- Prompt: the v2 `comparator` prompt, adapted per "Prompt adaptation rules":
308+
- Allowed-write list: ALL N comparison files
309+
(`.team-notes/<foo1>-extensions-comparison.md`, …,
310+
`.team-notes/<fooN>-extensions-comparison.md`).
311+
- Input pairs: for each of the N files, the pair
312+
(`.team-notes/<foo>-extensions-spec.md`,
313+
`.team-notes/<foo>-extensions-spec-hypha.md`).
314+
- "When done" SendMessage payload: per-file overall verdict + counts,
315+
followed by a top-level batch verdict roll-up (majority-verdict wins,
316+
with the count of files in each bucket surfaced).
317+
318+
After it returns, read each `COMPARISON_FILE` yourself to build the batch-wide
319+
inline preview for Gate B-C.
320+
321+
### 8.7. Gate B-C — Batch-Comparison gate (ONLY when `hypha_available == true`)
322+
323+
Before Phase IT, present the batch-wide comparison inline and ask for a
324+
**single batch-wide pick** (Hypha vs. legacy) that applies to ALL N files.
325+
This intentionally differs from the single-file Gate R-C: at N=6, per-file
326+
picking is unusable — the gate would become 6 sequential
327+
`AskUserQuestion` calls. A single batch-wide pick is the pragmatic tradeoff;
328+
the per-file comparison files remain on disk regardless so the user can
329+
audit each file's fit after the run.
330+
331+
1. **Render** an inline preview:
332+
- Batch-wide verdict roll-up (e.g. "Hypha stronger for 4/6 files, legacy
333+
stronger for 1/6, equivalent for 1/6").
334+
- Per-file table:
335+
336+
| File | Verdict | Counts (agree/disagree/legacy-only/hypha-only) | Top concern |
337+
|---|---|---|---|
338+
| `<Foo1>Extensions.cs` | hypha stronger | 6/1/0/0 ||
339+
| `<Foo2>Extensions.cs` | mixed | 3/2/1/0 | `ComputeX` — different OCL translation |
340+
|||||
341+
342+
- Paths to all N `COMPARISON_FILE`s so the user can dive in per file.
343+
- Cap at ~120 lines (higher than single-file since the table scales with N).
344+
345+
2. **Ask** via `AskUserQuestion` (single question, 3 options):
346+
- **Use Hypha notes across the batch** — every file's
347+
`ACTIVE_NOTES_FILE` = its `HYPHA_NOTES_FILE`.
348+
- **Use legacy notes across the batch** — every file's
349+
`ACTIVE_NOTES_FILE` = its `NOTES_FILE`.
350+
- **Abort — re-research with feedback** — free-form `Other` text is
351+
forwarded to the still-addressable researcher(s) via `SendMessage`;
352+
after they return, re-run 8.5 and this gate.
353+
354+
3. **On pick**, record the per-file `ACTIVE_NOTES_FILE` map on orchestrator
355+
state (the pick is batch-wide but the map is per-file so downstream can
356+
substitute the correct path per file). Proceed to Phase IT (step 9).
357+
358+
4. **On abort without re-research**, stop the orchestration. All
359+
`.team-notes/*.md` files remain for the user's reference. The branch
360+
created in step 6 stays; no Phase IT edits happen.
361+
362+
Rationale: Gate B-C is the batch analogue of the single-file Gate R-C, with
363+
a single-question shape because per-file picking at N=6 is impractical. The
364+
per-file `COMPARISON_FILE`s stay on disk regardless of the pick so a mixed
365+
verdict is still auditable file-by-file after the run.
234366

235367
### 9. Phase IT — Spawn the batch implementer + tester in parallel (TWO agents)
236368

@@ -245,14 +377,16 @@ to the N test fixtures (disjoint sets).
245377
- "Methods to implement" section: enumerate ALL methods across ALL N files,
246378
grouped under an `## File: <PRODUCTION_FILE>` heading per file. Order
247379
files by dependency tier (file A's stubs that file B depends on come first).
248-
- Reads ALL N notes files before starting.
380+
- Reads ALL N `ACTIVE_NOTES_FILE`s before starting (per-file, from the
381+
Gate B-C pick — either legacy or Hypha; in a legacy-only run, all
382+
files' `ACTIVE_NOTES_FILE` = their legacy `NOTES_FILE`).
249383
- **Tester prompt**: the v2 tester prompt, adapted similarly.
250384
- Allowed-write list: ALL N test fixtures.
251385
- "Methods to test" section: enumerate per file.
252386
- **Parallel-mode caveat still applies** — tester runs only `dotnet build` of
253387
the test project, NEVER `dotnet test` (production lacks the implementer's
254388
parallel-turn edits in the tester's disk view).
255-
- Reads ALL N notes files before starting.
389+
- Reads ALL N `ACTIVE_NOTES_FILE`s before starting.
256390

257391
### 10. Phase V — Orchestrator verification (sequential)
258392

@@ -305,8 +439,11 @@ Iterate until the full solution test run is 0 failures.
305439
per "Prompt adaptation rules":
306440

307441
- Read-only across the repo (unchanged from the template).
308-
- Files to review: ALL N notes files + ALL N production files + ALL N test
309-
fixtures + any sibling fixtures touched in Phase S.
442+
- Files to review: ALL N `ACTIVE_NOTES_FILE`s (per-file, from Gate B-C) +
443+
ALL N production files + ALL N test fixtures + any sibling fixtures
444+
touched in Phase S. The Hypha notes file / legacy notes file that was
445+
NOT picked at Gate B-C is not part of the reviewer's contract for that
446+
file, but is still preserved on disk for the A/B corpus.
310447
- "Output format" SendMessage payload: per-file `OK / NEEDS FIX` verdicts, then
311448
a batch-wide summary line. The orchestrator needs to know which files need
312449
re-dispatch and which are clean.
@@ -352,6 +489,19 @@ Print to the user:
352489
- Spec-text-only methods flagged separately (grounded in spec prose, not OCL).
353490
- Out-of-scope blockers surfaced.
354491

492+
- **Hypha comparison block** (ONLY when `hypha_available == true`):
493+
- Batch-wide verdict roll-up from the N `COMPARISON_FILE`s
494+
(e.g. "Hypha stronger for 4/6 files, legacy stronger for 1/6,
495+
equivalent for 1/6").
496+
- Which notes path drove implementation (batch-wide: Hypha or legacy,
497+
per Gate B-C).
498+
- Repo-relative paths to all N `.team-notes/<foo>-extensions-comparison.md`
499+
files for the user to inspect after the run — the A/B corpus lives on
500+
disk regardless of the Gate B-C pick.
501+
- If the run downgraded mid-flight (Hypha errored between 8b and 8.5),
502+
a short note saying "Hypha comparison unavailable for the batch —
503+
downgraded to legacy-only at step X" and skip the rest of the block.
504+
355505
- **Pre-filled commit message** (MANDATORY — append at the very end of the final-summary message in a fenced code block, ready to copy):
356506

357507
```
@@ -376,7 +526,9 @@ After the handoff line, the orchestrator stops. The run is complete. The user ma
376526
| Dirty working tree | Step 4 | Abort, ask user to commit/stash. |
377527
| Branch already exists | Step 6 | Abort; ask user to pick a different batch or delete the stale branch. |
378528
| `gh issue edit --add-assignee` fails for one issue | Step 7 | Log + continue (non-blocking; implementation still proceeds). |
379-
| Researcher's notes file missing/empty for one file | Step 8 | Re-dispatch THE researcher with a focused brief naming only that file. |
529+
| Researcher's notes file missing/empty for one file | Step 8a / 8b | Re-dispatch THE affected researcher (legacy or Hypha) with a focused brief naming only that file. |
530+
| Hypha plugin errors mid-run (between 8b and 8.5) | Step 8 / 8.5 | Skip step 8.5 + Gate B-C. Set every file's `ACTIVE_NOTES_FILE` = its legacy `NOTES_FILE`. Surface downgrade in step 14. |
531+
| Comparator's report missing/empty for one file | Step 8.5 | Re-dispatch THE comparator with a focused brief naming only that file's pair. |
380532
| Production build fails | Step 10.1 | Re-dispatch THE implementer with a focused brief naming the broken file(s) + compile errors. |
381533
| Targeted test fails | Step 10.2 | Attribute (OCL vs test bug), re-dispatch THE implementer or THE tester with a focused brief. |
382534
| Sibling test failure in regression sweep | Step 11 | Dispatch ONE regression-sweep tester with the full sibling list. |
@@ -390,7 +542,13 @@ After the handoff line, the orchestrator stops. The run is complete. The user ma
390542
## Parallelism caps (orchestrator self-enforced)
391543

392544
- N ≤ 6 files per batch (single-context working set limit for each agent).
393-
- Phase R: **1** agent.
545+
- Phase R:
546+
- Legacy-only run (`hypha_available == false`): **1** agent.
547+
- Hypha run (`hypha_available == true`): **2** agents in parallel
548+
(1 legacy researcher + 1 Hypha researcher). Same-message dual
549+
`Agent(...)` calls; disjoint output paths (legacy → `NOTES_FILE`,
550+
Hypha → `HYPHA_NOTES_FILE`).
551+
- Phase C (comparator, only in Hypha runs): **1** agent.
394552
- Phase IT: **2** agents in parallel (1 implementer + 1 tester).
395553
- Phase S regression-sweep tester: **1** agent.
396554
- Phase RV: **1** agent.
@@ -406,9 +564,18 @@ context per role.
406564
expansion, multi-file allowed-write list, per-file method grouping).
407565
Do not invent new role prompts from scratch.
408566
- All paths in agent prompts must be repo-relative with forward slashes.
409-
- Researcher is **mandatory** for the batch, even when one or more files have
410-
been seen before via `/implement-extensions`. The researcher is cheap and
411-
produces the contract the implementer/tester/reviewer read.
567+
- Legacy researcher is **mandatory** for the batch, even when one or more
568+
files have been seen before via `/implement-extensions`. It is cheap and
569+
produces the contract the implementer/tester/reviewer read (when Gate B-C
570+
picks legacy, or the run is legacy-only).
571+
- **Hypha researcher + comparator + Gate B-C run when `hypha_available == true`.**
572+
Both researchers spawn in the same orchestrator message (parallel,
573+
disjoint outputs), the comparator diffs their N pairs, and Gate B-C
574+
presents a single batch-wide pick to the user. Neither researcher may
575+
cross-contaminate: legacy MUST NOT use Hypha, Hypha MUST NOT read raw
576+
`Resources/*.uml` or `Resources/specification/*.pdf.txt`. See the
577+
pre-flight section at the top of this file and the template's "How Hypha
578+
comparison plugs in" section.
412579
- Reviewer is **mandatory** for the batch — cheap insurance against subtle OCL
413580
mistranslation.
414581
- The branch and the assignments persist even on partial failure. Be explicit

0 commit comments

Comments
 (0)