@benzotti/jedi 0.1.42 → 0.1.45

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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +1 -1
  3. package/framework/agents/jdi-architect.md +30 -1
  4. package/framework/agents/jdi-backend.md +27 -0
  5. package/framework/agents/jdi-devops.md +33 -1
  6. package/framework/agents/jdi-frontend.md +27 -0
  7. package/framework/agents/jdi-perf-analyst.md +116 -0
  8. package/framework/agents/jdi-planner.md +39 -10
  9. package/framework/agents/jdi-pr-feedback.md +1 -1
  10. package/framework/agents/jdi-pr-generator.md +20 -0
  11. package/framework/agents/jdi-producer.md +196 -0
  12. package/framework/agents/{jdi-executor.md → jdi-programmer.md} +17 -2
  13. package/framework/agents/jdi-qa-tester.md +113 -0
  14. package/framework/agents/jdi-quality.md +30 -1
  15. package/framework/agents/jdi-security.md +118 -0
  16. package/framework/agents/jdi-ux-designer.md +39 -1
  17. package/framework/commands/build.md +148 -0
  18. package/framework/commands/commit.md +59 -8
  19. package/framework/commands/create-plan.md +172 -19
  20. package/framework/commands/generate-pr.md +80 -8
  21. package/framework/commands/implement-plan.md +205 -25
  22. package/framework/commands/pr-feedback.md +64 -9
  23. package/framework/commands/pr-review.md +76 -17
  24. package/framework/commands/quick.md +115 -10
  25. package/framework/components/meta/AgentBase.md +13 -0
  26. package/framework/components/meta/AgentRouter.md +122 -34
  27. package/framework/components/meta/AgentTeamsOrchestration.md +28 -10
  28. package/framework/components/meta/ComplexityRouter.md +31 -11
  29. package/framework/components/meta/SilentDiscovery.md +79 -0
  30. package/framework/components/meta/StrictnessProtocol.md +60 -0
  31. package/framework/components/meta/TeamRouter.md +1 -1
  32. package/framework/components/planning/TaskBreakdown.md +13 -1
  33. package/framework/components/planning/WaveComputation.md +1 -1
  34. package/framework/config/jdi-config.yaml +4 -4
  35. package/framework/jedi.md +4 -4
  36. package/framework/teams/engineering.md +3 -3
  37. package/framework/templates/PLAN.md +24 -0
  38. package/framework/templates/SUMMARY.md +1 -1
  39. package/package.json +1 -1
@@ -1,33 +1,92 @@
1
1
  ---
2
2
  name: pr-review
3
- description: "JDI: Review pull request"
3
+ description: "JDI: Review pull request with learnings-aware analysis"
4
+ allowed-tools: Read, Bash, Task
5
+ argument-hint: "<pr-number-or-url> [--no-comments]"
6
+ context: |
7
+ !git branch --show-current 2>/dev/null
4
8
  ---
5
9
 
6
10
  # /jdi:pr-review
7
11
 
8
- Review a pull request with learnings-aware analysis.
12
+ Review a pull request against the team's learnings and coding standards.
13
+
14
+ **This skill follows `<JDI:StrictnessProtocol />`. Read that component before executing any step below.**
15
+
16
+ ---
9
17
 
10
18
  ## Flags
11
19
 
12
- - `--no-comments` — Do not post comments to GitHub. Write review to `.jdi/reviews/PR-{number}-review.md` instead.
20
+ - `--no-comments` — Do not post comments to GitHub. Write the review to `.jdi/reviews/PR-{number}-review.md` instead.
21
+
22
+ ---
23
+
24
+ ## Orchestration
25
+
26
+ ### 1. Parse PR Reference
27
+
28
+ Extract the PR number from `$ARGUMENTS`. Accept either a bare number (`123`) or a GitHub URL (`https://github.com/org/repo/pull/123`). If neither form is present, STOP:
29
+
30
+ > "I need a PR number or URL. Try `/jdi:pr-review 123` or `/jdi:pr-review https://github.com/org/repo/pull/123`."
31
+
32
+ ### 2. Parse Flags
33
+
34
+ Check for `--no-comments`. Map to the `post="false"` parameter for the `PRReview` component.
35
+
36
+ ### 3. Verify PR Exists
37
+
38
+ Run `gh pr view {number}` to confirm the PR is reachable. If `gh` errors, STOP and report the failure — do NOT fabricate a review.
39
+
40
+ ### 4. Delegate to Reviewer
13
41
 
14
- ## Delegation
42
+ Spawn the reviewer via Task tool. JDI specialists spawn as `general-purpose` with identity injected via prompt text:
15
43
 
16
- Parse flags from $ARGUMENTS. Map `--no-comments` to `post="false"`.
44
+ ```
45
+ Task(
46
+ subagent_type="general-purpose",
47
+ prompt="Read .jdi/framework/components/meta/AgentBase.md for the base protocol.
17
48
 
18
- Use Task tool with subagent_type="general-purpose" and prompt:
49
+ Read learnings before reviewing these represent the team's coding standards
50
+ and MUST be cross-referenced during review:
51
+ - Always: .jdi/framework/learnings/general.md
52
+ - PHP/Laravel PRs: also .jdi/framework/learnings/backend.md
53
+ - React/TypeScript PRs: also .jdi/framework/learnings/frontend.md
54
+ - Test changes: also .jdi/framework/learnings/testing.md
55
+ - CI/Docker changes: also .jdi/framework/learnings/devops.md
19
56
 
20
- Read ./.jdi/framework/components/meta/AgentBase.md for the base protocol.
57
+ Apply learnings as additional review criteria — flag violations and praise adherence.
21
58
 
22
- Read learnings before reviewing — these represent the team's coding standards and MUST be cross-referenced during review:
23
- - Always read: `.jdi/framework/learnings/general.md`
24
- - For PHP/Laravel PRs: also read `.jdi/framework/learnings/backend.md`
25
- - For React/TypeScript PRs: also read `.jdi/framework/learnings/frontend.md`
26
- - For test changes: also read `.jdi/framework/learnings/testing.md`
27
- - For CI/Docker changes: also read `.jdi/framework/learnings/devops.md`
28
- Apply learnings as additional review criteria — flag violations and praise adherence.
59
+ Read .jdi/framework/components/quality/PRReview.md for review instructions.
60
+ {If --no-comments: invoke as <JDI:PRReview post=\"false\" />}
29
61
 
30
- Read ./.jdi/framework/components/quality/PRReview.md for review instructions.
31
- {If --no-comments flag was present: Include `post="false"` parameter — invoke as `<JDI:PRReview post="false" />`}
62
+ Review PR: {pr-number}"
63
+ )
64
+ ```
65
+
66
+ ### 5. Present Result
67
+
68
+ After the reviewer returns, summarise: number of comments posted (or file path of the written review), severity breakdown, and any blocking issues.
69
+
70
+ Then **STOP**. Do NOT merge, approve, or take any follow-up action.
71
+
72
+ ---
73
+
74
+ ## Edge Cases
75
+
76
+ | Situation | Response |
77
+ |-----------|----------|
78
+ | No PR reference in arguments | STOP at step 1. Ask for a number or URL. |
79
+ | `gh pr view` fails (not logged in, wrong repo) | Report the error verbatim. Do NOT attempt a workaround. |
80
+ | PR is already merged | Note it in the summary and review anyway — learnings may still apply. |
81
+ | PR is a draft | Review as normal; flag that the PR is draft in the summary. |
82
+ | `.jdi/framework/learnings/` missing | Reviewer falls back to base review criteria. Record the missing learnings in the summary. |
83
+
84
+ ---
85
+
86
+ ## Collaborative Protocol
87
+
88
+ <JDI:StrictnessProtocol />
89
+
90
+ ---
32
91
 
33
- Review PR: $ARGUMENTS
92
+ **PR to review:** $ARGUMENTS
@@ -1,19 +1,124 @@
1
1
  ---
2
2
  name: quick
3
- description: "JDI: Quick focused change"
3
+ description: "JDI: Quick focused change (skips planner, relaxed standards)"
4
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit
5
+ argument-hint: "<task description> [--dry-run]"
6
+ context: |
7
+ !git status --short 2>/dev/null | head -20
4
8
  ---
5
9
 
6
10
  # /jdi:quick
7
11
 
8
- Execute a small, focused change directly without full orchestration.
12
+ Execute a small, focused change directly without full orchestration. For trivial or prototype work only — no planner, no agent spawn, no waves.
9
13
 
10
- **Flags:** `--dry-run` (preview without writing files)
14
+ **This skill follows `<JDI:StrictnessProtocol />`. Read that component before executing any step below.**
11
15
 
12
- ## Direct Execution
16
+ ---
17
+
18
+ ## Flags
19
+
20
+ - `--dry-run` — Preview the change without writing files. List intended edits and STOP.
21
+
22
+ ---
23
+
24
+ ## Scope Gate (read first)
25
+
26
+ `/jdi:quick` is for:
27
+
28
+ - Single-file edits, typo fixes, log lines, variable renames
29
+ - Prototype / exploration code where throwaway is acceptable
30
+ - Tasks under ~30 minutes with no architectural impact
31
+
32
+ `/jdi:quick` is NOT for:
33
+
34
+ - Production code requiring tests, review, or sign-off
35
+ - Multi-file refactors or anything touching contracts (API routes, DTOs, exported types, migrations)
36
+ - Work that spans tech stacks or layers
37
+
38
+ If the task doesn't fit, redirect to `/jdi:create-plan "<feature>"` before writing any code.
39
+
40
+ ---
41
+
42
+ ## Orchestration
43
+
44
+ The steps below are numbered and ordered. Do NOT skip, merge, or reorder them.
45
+
46
+ ### 1. Parse and Classify
47
+
48
+ Read `$ARGUMENTS`. If the task description suggests production-grade work (tests required, multi-file, architectural), STOP and redirect:
49
+
50
+ > "This looks bigger than `/jdi:quick` is meant for. Run `/jdi:create-plan "<feature>"` instead so we agree on scope before writing code."
51
+
52
+ **Wait for the user's answer. Do not proceed until they confirm `/jdi:quick` is still the right fit.**
53
+
54
+ ### 2. Detect Tech Stack
55
+
56
+ Read the target files (inferred from `$ARGUMENTS` or the user's follow-up). Identify the stack. Record in working memory.
57
+
58
+ ### 3. Dry Run Check
59
+
60
+ If `--dry-run` is present, list the files you would edit and the intended change per file. Then **STOP**. Do NOT write anything.
61
+
62
+ ### 4. Execute Change
63
+
64
+ Apply the edit directly via Edit tool. No agent spawn. No TaskCreate. Scope is intentionally narrow — one concern per invocation.
65
+
66
+ ### 5. Verification
67
+
68
+ Run only the quality gates that are cheap and relevant:
69
+
70
+ - Typecheck for TS changes (`tsc --noEmit` or project-equivalent)
71
+ - Lint for the touched file only (not the whole repo)
72
+ - Tests only if the user explicitly asked for them — `/jdi:quick` defaults to skipping
73
+
74
+ If a gate fails, STOP and report. Do NOT auto-fix beyond the scope the user requested.
75
+
76
+ ### 6. Report
77
+
78
+ Present a 3-line summary: files changed, gates run, next suggested action. End with:
79
+
80
+ > "Commit as `proto:` / `quick:` / leave uncommitted? Your call."
81
+
82
+ **Wait for the user's answer. Do NOT auto-commit.**
83
+
84
+ ---
85
+
86
+ ## Relaxed Standards Mode
87
+
88
+ - Prototype / throwaway code accepted
89
+ - Tests optional (default: skip)
90
+ - Commit message prefix: `proto:` or `quick:`
91
+ - Framed as exploration — NOT production
92
+ - `jdi-qa-tester` is NOT invoked in `/jdi:quick` mode. If regression checks matter, route through `/jdi:implement-plan` instead.
93
+
94
+ ---
95
+
96
+ ## Edge Cases
97
+
98
+ | Situation | Response |
99
+ |-----------|----------|
100
+ | Task description implies production work | Redirect to `/jdi:create-plan` at step 1. Do NOT proceed. |
101
+ | `.jdi/` directory doesn't exist | Proceed anyway — `/jdi:quick` does not require JDI scaffolding. Skip any state updates. |
102
+ | Typecheck or lint fails after edit | Report the failure. Do NOT auto-fix unrelated issues. |
103
+ | User asks for tests mid-task | Honour the request; run the test command once, report, then stop. |
104
+ | Target file doesn't exist | Ask the user: create it, or did they mean a different path? |
105
+
106
+ ---
107
+
108
+ ## HARD STOP
109
+
110
+ Once the edit is applied and gates have run, the skill is **DONE**.
111
+
112
+ - Do NOT auto-commit.
113
+ - Do NOT advance state.
114
+ - Do NOT invoke any other skill.
115
+
116
+ ---
117
+
118
+ ## Collaborative Protocol
119
+
120
+ <JDI:StrictnessProtocol />
121
+
122
+ ---
13
123
 
14
- 1. Parse task from $ARGUMENTS
15
- 2. Detect tech stack from target files
16
- 3. Execute changes directly (no agent spawn, no team, no waves)
17
- 4. Run verification gates
18
- 5. Commit with conventional format
19
- 6. Brief state update (if .jdi/ exists)
124
+ **Task:** $ARGUMENTS
@@ -11,6 +11,19 @@ Standards inherited by all JDI agents via `<JDI:AgentBase />`. Default loads Cor
11
11
  - Batch file reads: issue all Read calls in a single turn rather than sequentially.
12
12
  - Batch git operations: combine related commands into a single Bash call where possible.
13
13
 
14
+ ## Budget Discipline
15
+
16
+ You have a finite per-invocation budget (tokens, tool calls, wall time). Long runs can be terminated mid-task before you produce your final report. To survive:
17
+
18
+ 1. **Batch reads in parallel** — one turn with all Read calls, not sequential.
19
+ 2. **Cap exploration** — read only the files your spawn prompt names. If more are needed, report what you need and stop rather than wandering.
20
+ 3. **Write fixes before verifying** — Edit calls persist even if you are later truncated. Save the report for last.
21
+ 4. **Short reports (<400 words)** — terse file list + one sentence per change. Long formal reports are where truncation bites.
22
+ 5. **One concern per invocation** — address what was asked, do not expand scope.
23
+ 6. **Don't re-read files you just edited** — the harness tracks state.
24
+
25
+ If your work exceeds one invocation, complete what you can, return a progress report naming exactly what remains, and let the orchestrator re-spawn you.
26
+
14
27
  ## Component Resolution
15
28
 
16
29
  When a spec contains `<JDI:*>` tags:
@@ -22,26 +22,39 @@ into the plan and implement-plan must use them.
22
22
 
23
23
  ## 1. Agent Discovery (at plan time)
24
24
 
25
- The planner MUST perform discovery before task breakdown. Merge two roots (the
26
- project-local list overrides the user-global list on name collision):
25
+ The planner MUST perform discovery before task breakdown. JDI specialists live
26
+ in the framework itself, not in Claude Code's subagent registry — the
27
+ orchestrator reads their specs and injects identity via prompt text when
28
+ spawning (see `framework/jedi.md` Critical Constraints).
27
29
 
28
- 1. `.claude/agents/*.md` project-local specialists (highest priority)
29
- 2. `~/.claude/agents/*.md` — user-global specialists
30
+ Merge these roots in order (earlier roots override later ones on name
31
+ collision):
32
+
33
+ 1. `.jdi/framework/agents/jdi-*.md` — JDI specialists installed in the project
34
+ (primary source for any project using JDI). When working on the jedi repo
35
+ itself, fall back to `framework/agents/jdi-*.md` in the repo root.
36
+ 2. `.claude/agents/*.md` — project-local Claude Code subagents (user-added
37
+ specialists, takes precedence over user-global)
38
+ 3. `~/.claude/agents/*.md` — user-global Claude Code subagents
30
39
 
31
40
  For each `.md` file, read the YAML frontmatter and extract:
32
41
 
33
- - `name` — the subagent_type value passed to the Task tool
42
+ - `name` — identity used in the spawn prompt (JDI agents) or as the
43
+ `subagent_type` value (Claude Code registered subagents)
34
44
  - `description` — the one-line capability blurb used for routing decisions
35
45
  - `model` (optional) — preferred model if specified
36
46
  - `tools` (optional) — tool allowlist if the agent is tool-restricted
37
47
 
38
- Agents whose frontmatter is unreadable or missing `name` are skipped.
48
+ Record each entry with a `source:` field so `implement-plan` knows how to spawn
49
+ it: `jdi` for JDI framework specialists, `claude-code` for registered
50
+ subagents. Agents whose frontmatter is unreadable or missing `name` are skipped.
39
51
 
40
- Discovery command (reference — the planner may use `Glob` + `Read`):
52
+ Discovery commands (reference — the planner uses `Glob` + `Read`):
41
53
 
42
54
  ```bash
43
- ls ~/.claude/agents/ 2>/dev/null
55
+ ls .jdi/framework/agents/jdi-*.md 2>/dev/null || ls framework/agents/jdi-*.md 2>/dev/null
44
56
  ls .claude/agents/ 2>/dev/null
57
+ ls ~/.claude/agents/ 2>/dev/null
45
58
  ```
46
59
 
47
60
  The resulting catalogue MUST be written into the plan index frontmatter as
@@ -50,20 +63,24 @@ implement-plan pass can see exactly which agents were visible at plan time.
50
63
 
51
64
  ```yaml
52
65
  available_agents:
66
+ - name: jdi-backend
67
+ source: jdi
68
+ description: PHP/Laravel backend specialist — APIs, migrations, contracts
69
+ - name: jdi-frontend
70
+ source: jdi
71
+ description: TS/React frontend specialist — components, types, client code
72
+ - name: jdi-qa-tester
73
+ source: jdi
74
+ description: Post-task verification, a11y, contract checks
53
75
  - name: unity-specialist
54
- description: Authority on Unity-specific patterns, APIs, and optimisation
55
- - name: unity-ui-specialist
56
- description: Unity UI Toolkit / UGUI / runtime UI performance
57
- - name: gameplay-programmer
58
- description: Implements game mechanics, player systems, combat
59
- - name: qa-tester
60
- description: Writes test cases, bug reports, regression checklists
76
+ source: claude-code
77
+ description: Unity API patterns and optimisation (user-added)
61
78
  ```
62
79
 
63
- If discovery returns zero agents (or `.claude/agents/` doesn't exist on either
64
- root), the planner falls back to the legacy routing (tech-stack default:
65
- `jdi-backend` or `jdi-frontend`) and records `available_agents: []` so it is
66
- explicit rather than silent.
80
+ If discovery returns zero agents (no JDI install and no `.claude/agents/`),
81
+ the planner records `available_agents: []` and falls back to the legacy
82
+ tech-stack default (`jdi-backend` / `jdi-frontend` / `general-purpose`) so
83
+ the empty state is explicit rather than silent.
67
84
 
68
85
  ---
69
86
 
@@ -123,6 +140,29 @@ signal hierarchy (highest to lowest):
123
140
  | PHP backend | `jdi-backend` |
124
141
  | TypeScript / React frontend | `jdi-frontend` |
125
142
  | Full-stack | `jdi-backend` + `jdi-frontend` |
143
+ | Orchestration / sprint / risk / scope | `jdi-producer` |
144
+ | Performance profiling / budgets / regression | `jdi-perf-analyst` |
145
+ | Security review / vuln audit / secrets / privacy | `jdi-security` |
146
+ | Test case writing / regression checklist / post-task verify | `jdi-qa-tester` |
147
+
148
+ ### Jedi meta-framework routing
149
+
150
+ Use these pins when the work being done is on the Jedi framework itself
151
+ (editing files under `framework/`, writing plans about JDI, etc.).
152
+
153
+ | Signal | Preferred agent |
154
+ |--------|-----------------|
155
+ | Framework design | `jdi-architect` |
156
+ | Framework edits | `jdi-programmer` |
157
+ | Framework tests | `jdi-quality` |
158
+ | Plan creation | `jdi-planner` |
159
+ | Sprint / risk / scope | `jdi-producer` |
160
+ | Perf profiling | `jdi-perf-analyst` |
161
+ | Security audit | `jdi-security` |
162
+ | Post-task verify | `jdi-qa-tester` |
163
+
164
+ > **Note:** `jdi-qa-tester` is automatically invoked by `implement-plan` after
165
+ > every code-touching task — it does not need to be explicitly pinned per task.
126
166
 
127
167
  ---
128
168
 
@@ -155,44 +195,90 @@ this specialist. Reviewers can use it to challenge bad routings.
155
195
 
156
196
  ## 4. Execution (at implement-plan time)
157
197
 
158
- `implement-plan` MUST read the task's `agent:` field from each task file and
159
- pass it as `subagent_type` when spawning via the Task tool.
198
+ `implement-plan` MUST read the task's `agent:` field and the corresponding
199
+ `source:` from `available_agents`, then spawn via the Task tool using the
200
+ correct pattern for that source.
201
+
202
+ > **Non-negotiable platform constraint:** Claude Code's Task tool only accepts
203
+ > `subagent_type` values that are registered in its subagent list. JDI's
204
+ > specialists live in `framework/agents/` — NOT in `.claude/agents/` — so they
205
+ > are NOT registered subagent types. Passing `subagent_type="jdi-backend"`
206
+ > (or any other JDI agent name) errors with `classifyHandoffIfNeeded is not
207
+ > defined`. See `framework/jedi.md` Critical Constraints.
208
+ >
209
+ > The workaround: spawn `subagent_type="general-purpose"` and inject the JDI
210
+ > agent's identity via the prompt text. Registered Claude Code specialists
211
+ > (found under `.claude/agents/`) can still be spawned directly by name.
212
+
213
+ ### Source-aware spawn pattern
214
+
215
+ | `source` in catalogue | `subagent_type` | Identity mechanism |
216
+ |----------------------|-----------------|--------------------|
217
+ | `jdi` | `"general-purpose"` | Prompt text: `"You are {task.agent}. Read .jdi/framework/agents/{task.agent}.md for instructions."` |
218
+ | `claude-code` | `"{task.agent}"` | Native — Claude Code loads the agent spec from `.claude/agents/` |
160
219
 
161
220
  ### Single-agent mode
162
221
 
163
222
  ```
223
+ # source: jdi (JDI framework specialist)
224
+ Task(
225
+ subagent_type: "general-purpose",
226
+ name: "{plan.primary_agent}",
227
+ prompt: "You are {plan.primary_agent}. Read .jdi/framework/agents/{plan.primary_agent}.md
228
+ for your full role and instructions. Also read .jdi/framework/components/meta/AgentBase.md
229
+ for the JDI base protocol.
230
+
231
+ <standard single-agent spawn prompt from ComplexityRouter>"
232
+ )
233
+
234
+ # source: claude-code (user-added registered specialist)
164
235
  Task(
165
- subagent_type: "{plan.primary_agent}", # NOT "general-purpose"
236
+ subagent_type: "{plan.primary_agent}", # e.g. unity-specialist
166
237
  name: "{plan.primary_agent}",
167
238
  prompt: "<standard single-agent spawn prompt from ComplexityRouter>"
168
239
  )
169
240
  ```
170
241
 
171
242
  If `plan.primary_agent` is missing (legacy plan or empty `available_agents`),
172
- fall back to `general-purpose` with a `jdi-backend` / `jdi-frontend` spec load.
243
+ fall back to `subagent_type="general-purpose"` with a `jdi-backend` /
244
+ `jdi-frontend` spec load in the prompt.
173
245
 
174
246
  ### Agent-teams mode
175
247
 
176
- For each task, read its `agent:` frontmatter field and spawn ONE Task tool call
177
- per task with `subagent_type` set to that value:
248
+ For each task, read its `agent:` frontmatter field and the matching `source:`
249
+ from the plan's `available_agents` catalogue. Spawn ONE Task tool call per task
250
+ using the pattern that matches its source (see table above).
178
251
 
179
252
  ```
253
+ # JDI specialist (source: jdi)
254
+ Task(
255
+ subagent_type: "general-purpose",
256
+ name: "{task.agent}-{task_id}",
257
+ prompt: "You are {task.agent}. Read .jdi/framework/agents/{task.agent}.md for instructions.
258
+ <spawn prompt from AgentTeamsOrchestration with TASK_FILE: {task file}>"
259
+ )
260
+
261
+ # Claude Code registered specialist (source: claude-code)
180
262
  Task(
181
- subagent_type: "{task.agent}", # per-task specialist
263
+ subagent_type: "{task.agent}",
182
264
  name: "{task.agent}-{task_id}",
183
265
  prompt: "<spawn prompt from AgentTeamsOrchestration with TASK_FILE: {task file}>"
184
266
  )
185
267
  ```
186
268
 
187
269
  Tasks with no `agent:` field fall back to the tech-stack default
188
- (`jdi-backend` / `jdi-frontend` / `general-purpose`).
270
+ (`jdi-backend` / `jdi-frontend`) spawned via the `source: jdi` pattern.
189
271
 
190
272
  ### Mixed fallbacks
191
273
 
192
- - If the discovered specialist name does NOT match a valid subagent type in the
193
- current session (e.g. plan was created on a different machine), downgrade to
194
- `general-purpose` and log a warning in the implement-plan summary: `agent
195
- downgrade: {planned} → general-purpose (not installed)`.
274
+ - If a pinned `source: jdi` agent's spec file is not found at
275
+ `.jdi/framework/agents/{name}.md` (or `framework/agents/{name}.md` in the
276
+ self-hosting repo), downgrade to `general-purpose` with a `jdi-backend` /
277
+ `jdi-frontend` spec load. Record `agent_downgrade: {planned} → general-purpose
278
+ (spec not found)` in the summary.
279
+ - If a pinned `source: claude-code` agent is not registered in the current
280
+ session (e.g. plan was created on a different machine), downgrade the same
281
+ way. Record `agent_downgrade: {planned} → general-purpose (not installed)`.
196
282
  - Never silently change the pin; always surface downgrades in the summary.
197
283
 
198
284
  ---
@@ -209,9 +295,11 @@ The planner MUST NOT:
209
295
  The implement-plan pass MUST:
210
296
 
211
297
  1. Read `agent:` from every task file before spawning.
212
- 2. Surface any downgrade in the summary.
213
- 3. Prefer project-local `.claude/agents/` over `~/.claude/agents/` on name
214
- collision.
298
+ 2. Read the matching `source:` from the plan's `available_agents` catalogue to
299
+ pick the correct spawn pattern (see §4).
300
+ 3. Surface any downgrade in the summary.
301
+ 4. Prefer `.jdi/framework/agents/` (or `framework/agents/` in the jedi repo)
302
+ over `.claude/agents/` over `~/.claude/agents/` on name collision.
215
303
 
216
304
  ---
217
305
 
@@ -11,7 +11,11 @@ description: Agent Teams orchestration quick-reference
11
11
  1. **Pre-flight** — Read command spec, `<JDI:CodebaseContext />`, read state.yaml, set status to "executing". Read each task file's `agent:` frontmatter field so you know which specialist to spawn per task (see `.jdi/framework/components/meta/AgentRouter.md`).
12
12
  2. **Create Team** — `TeamCreate(team_name: "{team-name}")`
13
13
  3. **Create Tasks** — TaskCreate per work unit, set `addBlockedBy` dependencies
14
- 4. **Spawn Teammates** — Task tool with `subagent_type: "{task.agent}"` (the pin from the task file frontmatter — e.g. `unity-ui-specialist`, `gameplay-programmer`). Never hardcode `general-purpose` when a pin exists. Verify the pinned agent is installed before spawning; if not, downgrade to `general-purpose` and record `agent_downgrade:` in the summary. Include in prompt: agent spec path, team context, task assignments.
14
+ 4. **Spawn Teammates** — Task tool, one call per task. The spawn pattern depends on the `source:` field in `available_agents` (see `AgentRouter.md` §4):
15
+ - **`source: jdi`** (JDI framework specialists like `jdi-backend`, `jdi-frontend`, `jdi-qa-tester`) — `subagent_type: "general-purpose"` and inject identity via prompt text: `"You are {task.agent}. Read .jdi/framework/agents/{task.agent}.md for instructions."` This is the common case.
16
+ - **`source: claude-code`** (user-added registered subagents like `unity-ui-specialist`) — `subagent_type: "{task.agent}"` directly; Claude Code loads the spec natively.
17
+ - Verify the agent exists before spawning. For `jdi`, check `.jdi/framework/agents/{name}.md`. For `claude-code`, check `.claude/agents/{name}.md` or `~/.claude/agents/{name}.md`. Missing spec → downgrade to `general-purpose` and record `agent_downgrade:` in the summary.
18
+ - Include in prompt: agent spec path, team context, task assignments. **Scope tightly** — one task per spawn, exact file targets, capped exploration, short reports (<400 words). See `AgentBase.md` § Budget Discipline.
15
19
  5. **Coordinate** — Automatic message delivery for results, TaskList to monitor, SendMessage to guide/unblock
16
20
  6. **Cleanup** — shutdown_request to all → TeamDelete → set status "complete" → report (include which specialist ran which task and any downgrade events)
17
21
 
@@ -44,14 +48,15 @@ by `jdi-planner` via `AgentRouter` at plan time. The table below is the
44
48
 
45
49
  ---
46
50
 
47
- ## Specialist Spawn Prompt Template (~200 tokens)
51
+ ## Specialist Spawn Prompt Templates (~200 tokens)
52
+
53
+ ### `source: jdi` — JDI framework specialist (common case)
48
54
 
49
55
  ```
50
- You are {task.agent}. Your Claude Code agent definition has already been
51
- loaded from .claude/agents/{task.agent}.md (or ~/.claude/agents/{task.agent}.md)
52
- follow it. Also read .jdi/framework/components/meta/AgentBase.md for the
53
- JDI base protocol. If your Claude Code agent definition has requires_components
54
- in frontmatter, batch-read them before starting.
56
+ You are {task.agent}. Read .jdi/framework/agents/{task.agent}.md for your
57
+ full role and instructions. Also read .jdi/framework/components/meta/AgentBase.md
58
+ for the JDI base protocol. If your spec has requires_components in frontmatter,
59
+ batch-read them before starting.
55
60
 
56
61
  TEAM: {team-name}
57
62
  PLAN: {plan-path}
@@ -71,9 +76,22 @@ Report: files_modified, files_to_create, commits_pending.
71
76
  No git commit (use commits_pending).
72
77
  ```
73
78
 
74
- The `subagent_type` passed to the Task tool is the `agent:` pin from the task
75
- file frontmatter NOT `general-purpose`. See
76
- `.jdi/framework/components/meta/AgentRouter.md` for full rules.
79
+ Spawned via `Task(subagent_type="general-purpose", ...)` see
80
+ `.jdi/framework/jedi.md` Critical Constraints for why.
81
+
82
+ ### `source: claude-code` — registered Claude Code subagent
83
+
84
+ ```
85
+ Your agent definition has already been loaded by Claude Code from
86
+ .claude/agents/{task.agent}.md — follow it. Also read
87
+ .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
88
+
89
+ <same TEAM / PLAN / TASK_FILE / WORKING_DIR block + steps + report as above>
90
+ ```
91
+
92
+ Spawned via `Task(subagent_type="{task.agent}", ...)` — Claude Code validates
93
+ the subagent type against its registered list. See
94
+ `.jdi/framework/components/meta/AgentRouter.md` §4 for full rules.
77
95
 
78
96
  ---
79
97
 
@@ -40,21 +40,28 @@ reasoning: "{why this mode was chosen}"
40
40
  Spawn one specialist agent directly via Task tool. Follow cache-optimised load
41
41
  order (AgentBase first).
42
42
 
43
- **Pinning rule:** read `primary_agent` from the plan index frontmatter. If set
44
- and the agent is installed (verify against `.claude/agents/{name}.md` or
45
- `~/.claude/agents/{name}.md`), use it as the `subagent_type`. If unset or not
46
- installed, fall back to `general-purpose` and record a `agent_downgrade:` note
47
- in the summary. Never silently default to `general-purpose` when a pin exists.
48
- See `.jdi/framework/components/meta/AgentRouter.md`.
43
+ **Pinning rule:** read `primary_agent` from the plan index frontmatter and the
44
+ matching `source:` from `available_agents`. Verify the agent exists:
45
+
46
+ - `source: jdi` check `.jdi/framework/agents/{name}.md` (or
47
+ `framework/agents/{name}.md` in the self-hosting jedi repo)
48
+ - `source: claude-code` → check `.claude/agents/{name}.md` or
49
+ `~/.claude/agents/{name}.md`
50
+
51
+ If unset or not found, fall back to `general-purpose` and record an
52
+ `agent_downgrade:` note in the summary. Never silently default to
53
+ `general-purpose` when a pin exists.
54
+ See `.jdi/framework/components/meta/AgentRouter.md` §4 for full spawn rules.
55
+
56
+ ### JDI specialist (source: jdi — the common case)
49
57
 
50
58
  ```
51
59
  Task(
52
- subagent_type: "{plan.primary_agent}", # e.g. unity-specialist NOT hardcoded
60
+ subagent_type: "general-purpose", # MUST be general-purpose for JDI agents
53
61
  name: "{plan.primary_agent}",
54
- prompt: "You are {plan.primary_agent}. Your Claude Code agent definition has
55
- already been loaded from .claude/agents/{name}.md (or ~/.claude/agents/{name}.md)
56
- — follow it. Also read .jdi/framework/components/meta/AgentBase.md for the
57
- JDI base protocol.
62
+ prompt: "You are {plan.primary_agent}. Read .jdi/framework/agents/{plan.primary_agent}.md
63
+ for your full role and instructions. Also read
64
+ .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
58
65
 
59
66
  ## Project Context
60
67
  - Type: {project_type}
@@ -70,6 +77,19 @@ Report: files_modified, files_to_create, commits_pending."
70
77
  )
71
78
  ```
72
79
 
80
+ ### Claude Code registered specialist (source: claude-code)
81
+
82
+ ```
83
+ Task(
84
+ subagent_type: "{plan.primary_agent}", # e.g. unity-specialist
85
+ name: "{plan.primary_agent}",
86
+ prompt: "Your agent definition has already been loaded from .claude/agents/.
87
+ Also read .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
88
+
89
+ <same Project Context + Task sections as above>"
90
+ )
91
+ ```
92
+
73
93
  No TeamCreate, no TaskCreate, no cross-agent coordination.
74
94
 
75
95
  ### Legacy fallback (no pins)