@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,39 +1,192 @@
1
1
  ---
2
2
  name: create-plan
3
3
  description: "JDI: Create implementation plan"
4
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit, Task
5
+ argument-hint: "<feature to plan> [--worktree | --worktree-lightweight | --status]"
6
+ context: |
7
+ !cat .jdi/config/state.yaml 2>/dev/null | head -25
8
+ !ls .jdi/plans/*.plan.md 2>/dev/null | tail -5
4
9
  ---
5
10
 
6
11
  # /jdi:create-plan
7
12
 
8
- Create an implementation plan using a single planner agent (includes research).
13
+ Create an implementation plan using a single planner agent (includes research). Deterministic workflow — every invocation follows the same numbered steps, in order, without skipping.
14
+
15
+ **This skill follows `<JDI:StrictnessProtocol />` and `<JDI:SilentDiscovery />`. Read those components before executing any step below.**
16
+
17
+ ---
9
18
 
10
19
  ## Flags
11
20
 
12
21
  - `--worktree` — Create git worktree with full environment before planning (follow `.claude/commands/jdi/worktree.md` steps)
13
22
  - `--worktree-lightweight` — Same but skip databases/web server (deps + migrate only)
23
+ - `--status` — Status mode: generate a plan progress report using `state.yaml` + the current plan. Does NOT spawn the planner. See Status Mode section below.
14
24
 
15
25
  > **Do NOT use the built-in `EnterWorktree` tool.** Always follow `/jdi:worktree` Direct Execution steps.
16
26
 
17
- ## Orchestration
18
-
19
- 1. **Worktree** (if flagged): derive name from task, follow worktree.md steps, `cd` into `.worktrees/<name>`
20
- 2. Read codebase context (`.jdi/codebase/SUMMARY.md` if exists)
21
- 3. Read scaffolding (.jdi/PROJECT.yaml, REQUIREMENTS.yaml, ROADMAP.yaml) create from templates if missing
22
- 4. **Agent Discovery (MANDATORY)** — before spawning the planner, enumerate available Claude Code agents by listing `.claude/agents/` (project-local) and `~/.claude/agents/` (user-global). Read each `.md` file's frontmatter for `name` and `description`. Pass the resulting catalogue into the planner's spawn prompt as `AVAILABLE_AGENTS` so it can pin specialists per task. If neither directory exists, pass an empty list. See `.jdi/framework/components/meta/AgentRouter.md` for the full routing rules.
23
- 5. Quick Mode Detection — suggest /jdi:quick for trivial tasks
24
- 6. Spawn `jdi-planner` agent (subagent_type="general-purpose") — creates split plan files (index .plan.md + per-task .T{n}.md files). The planner MUST write these files directly via Write tool (sandbox override for plan files). The planner MUST write the `available_agents` catalogue into the plan index frontmatter and pin an `agent:` field in every task file via AgentRouter.
25
- 7. Collect and execute deferred ops — if the agent returned `files_to_create`, create them now using Write tool. Verify split plan files exist: index `.plan.md` + individual `.T{n}.md` task files. Verify each task file's frontmatter contains an `agent:` field (unless `available_agents` is empty).
26
- 8. **Update state via CLI** — do NOT manually edit state.yaml. Run:
27
- ```bash
28
- npx jdi state plan-ready --plan-path ".jdi/plans/{plan-file}" --plan-name "{plan name}"
29
- ```
30
- 9. **Present summary** (name, objective, task table including the assigned `agent:` per task, files) then ask: _"Provide feedback to refine, or say **approved** to finalise."_
31
- 10. **Review loop**: Feedback → revise plan in-place, increment revision, re-present summary. Repeat until approved. Approval → run `npx jdi state approved`, then **STOP**.
27
+ ---
28
+
29
+ ## Status Mode (`--status`)
30
+
31
+ When `--status` is passed, run this workflow instead of the planning workflow. All other flags are ignored.
32
+
33
+ ### 1. Read State
34
+
35
+ Read `.jdi/config/state.yaml` and the current plan file (index + every task file listed in `task_files:`).
36
+
37
+ ### 2. Generate Tables
38
+
39
+ Produce four tables — **Completed**, **In Progress**, **Blocked**, **Not Started** — listing each task with its `agent:` pin, `priority:` band, and any notes pulled from state.
40
+
41
+ ### 3. Output and Stop
42
+
43
+ Print the report to stdout. Then **STOP**. Do NOT spawn the planner. Do NOT write any files. Do NOT advance state. The user may run `/jdi:create-plan "<feature>"` (without `--status`) when they want to plan new work.
44
+
45
+ ---
46
+
47
+ ## Orchestration (Planning Mode)
48
+
49
+ The steps below are numbered and ordered. Do NOT skip, merge, or reorder them. Each step ends with a clear state transition — if you cannot produce that transition, STOP and ask.
50
+
51
+ ### 1. Worktree Setup (if flagged)
52
+
53
+ If `--worktree` or `--worktree-lightweight` is present, derive a branch name from the task description, follow the Direct Execution steps in `framework/commands/worktree.md`, and `cd` into `.worktrees/<name>`. Confirm the working directory changed before proceeding.
54
+
55
+ If no worktree flag is present, skip this step entirely — do not mention it to the user.
56
+
57
+ ### 2. Silent Discovery
58
+
59
+ Execute `<JDI:SilentDiscovery />` now. Read the scaffolding files listed in that component and store the result internally as `PRE_DISCOVERED_CONTEXT`. Do NOT print the discovery output to the user.
60
+
61
+ **Additional reads for this skill:**
62
+ - `.jdi/REQUIREMENTS.yaml` → `risks:` block (for the planner's Risks section)
63
+ - Prior plan's `SUMMARY.md` if it exists (for carryover candidates)
64
+ - `.jdi/codebase/SUMMARY.md` if it exists (for codebase context)
65
+
66
+ Append these to `PRE_DISCOVERED_CONTEXT`.
67
+
68
+ **If scaffolding files are missing:** record `missing: true` for each in `PRE_DISCOVERED_CONTEXT`. Do not error. The planner will create missing files from templates in step 5.
69
+
70
+ ### 3. Agent Discovery
71
+
72
+ Enumerate available agents in this order (earlier roots override later ones on name collision). For each discovered `.md` file, read the frontmatter `name:` and `description:` and record a `source:` field so `implement-plan` picks the correct spawn pattern.
73
+
74
+ 1. **JDI framework specialists (primary — `source: jdi`)** — list `.jdi/framework/agents/jdi-*.md` (installed projects). If that directory does not exist, fall back to `framework/agents/jdi-*.md` (self-hosting jedi repo).
75
+ 2. **Project-local Claude Code subagents (`source: claude-code`)** — list `.claude/agents/*.md`.
76
+ 3. **User-global Claude Code subagents (`source: claude-code`)** — list `~/.claude/agents/*.md`.
77
+
78
+ Store the merged catalogue as `AVAILABLE_AGENTS`. If none of the roots exist, set `AVAILABLE_AGENTS = []`. Do NOT fail.
79
+
80
+ > **Why source matters:** JDI specialists (`jdi-backend`, `jdi-frontend`, etc.) are NOT registered Claude Code subagents — they live in `framework/agents/`. `implement-plan` must spawn them via `subagent_type="general-purpose"` with identity injected via prompt text. Registered Claude Code subagents (`source: claude-code`) can be spawned by name directly. See `framework/jedi.md` Critical Constraints and `framework/components/meta/AgentRouter.md` §4.
81
+
82
+ See `framework/components/meta/AgentRouter.md` §1 for the full discovery + routing rules the planner will apply.
83
+
84
+ ### 4. Quick Mode Detection
85
+
86
+ If the feature description looks trivial (single file, <30 minutes, no architectural impact — e.g. "rename var X", "add a log line"), recommend `/jdi:quick "<description>"` instead. Present this as a suggestion, not a redirect:
87
+
88
+ > "This looks small enough for `/jdi:quick`, which skips the planner entirely. Want to use that instead, or stick with `/jdi:create-plan`?"
89
+
90
+ **Wait for the user's answer. Do not proceed until they respond.** If they pick quick, STOP — do not spawn the planner.
91
+
92
+ ### 5. Spawn Planner
93
+
94
+ Spawn `jdi-planner` via `Task(subagent_type="general-purpose")`. The spawn prompt MUST include:
95
+
96
+ - The feature description (`$ARGUMENTS`)
97
+ - `PRE_DISCOVERED_CONTEXT` as a YAML block — planner must NOT re-read scaffolding
98
+ - `AVAILABLE_AGENTS` catalogue — planner pins specialists via AgentRouter
99
+ - Explicit instruction: _"Do NOT re-prompt the user for anything already in PRE_DISCOVERED_CONTEXT. Surface open questions ONLY for facts you cannot infer."_
100
+ - Spec path: `.jdi/framework/agents/jdi-planner.md`
101
+
102
+ The planner creates split plan files (index `.plan.md` + per-task `.T{n}.md` files) directly via Write tool (sandbox override for plan files). It writes `available_agents:` into the index frontmatter and pins an `agent:` field in every task file.
103
+
104
+ ### 6. Verify Planner Output
105
+
106
+ After the planner returns, confirm:
107
+
108
+ - Index file `.jdi/plans/{plan-id}.plan.md` exists
109
+ - Every entry in `task_files:` exists on disk
110
+ - Every task file's frontmatter contains an `agent:` field (unless `AVAILABLE_AGENTS` was empty)
111
+ - The index frontmatter contains `available_agents:` matching what you passed in
112
+
113
+ If any check fails, STOP and report the gap to the user. Do not advance state on incomplete output.
114
+
115
+ ### 7. Execute Deferred Ops
116
+
117
+ If the planner returned `files_to_create` (scaffolding it could not write inside its sandbox), create those files now via the Write tool.
118
+
119
+ ### 8. Update State
120
+
121
+ Run the state CLI — do NOT manually edit `state.yaml`:
122
+
123
+ ```bash
124
+ bun run src/index.ts state plan-ready --plan-path ".jdi/plans/{plan-file}" --plan-name "{plan name}"
125
+ ```
126
+
127
+ (In installed projects: `npx jdi state plan-ready ...`)
128
+
129
+ ### 9. Present Summary
130
+
131
+ Present the plan summary to the user:
132
+
133
+ - Plan name, objective, and sprint goal
134
+ - Task manifest table: `ID | Task | Agent | Priority | Requires`
135
+ - Any open questions the planner surfaced
136
+ - File list (index + task files)
137
+
138
+ End with the exact prompt: _"Provide feedback to refine, or say **approved** to finalise."_
139
+
140
+ **Wait for the user's answer. Do not advance state. Do not invoke any other skill. Do not begin implementation.**
141
+
142
+ ### 10. Review Loop
143
+
144
+ - **Feedback:** apply the requested changes in place (edit existing plan files, increment revision counter in frontmatter), re-present the summary, and ask the same question again.
145
+ - **Approval** (user says "approved", "lgtm", "looks good", or equivalent): run `bun run src/index.ts state approved`, output the completion message, and STOP.
146
+
147
+ **Never loop back to step 5.** Feedback refines; it does not restart.
148
+
149
+ ---
150
+
151
+ ## Edge Cases
152
+
153
+ Pre-written responses for known deviations. When one applies, follow the scripted response rather than improvising.
154
+
155
+ | Situation | Response |
156
+ |-----------|----------|
157
+ | Scaffolding files missing (`.jdi/PROJECT.yaml` etc.) | Planner creates them from `framework/templates/` in step 5. Do NOT ask the user for values the template's defaults cover. |
158
+ | `.claude/agents/` empty on both levels | Set `AVAILABLE_AGENTS = []`, note in summary, and proceed. The planner falls back to tech-stack defaults. |
159
+ | Feature description is vague ("improve X") | Ask 2-3 targeted follow-ups BEFORE spawning the planner. Do not waste a planner invocation on an underspecified prompt. |
160
+ | Worktree flag but worktree already exists | Ask the user: reuse the existing worktree, or pick a new name? Do not silently proceed. |
161
+ | `--status` with no current plan | Output "No current plan — run `/jdi:create-plan \"<feature>\"` to create one" and STOP. |
162
+ | Planner returns without writing any files | STOP, report the failure, do NOT advance state. Ask the user to re-invoke or debug. |
163
+ | User asks to implement during review loop | Remind them of the gate: "Planning and implementation are separate phases. Say `approved` to lock in the plan, then run `/jdi:implement-plan`." Do NOT auto-advance. |
164
+
165
+ ---
32
166
 
33
167
  ## HARD STOP — Planning Gate
34
168
 
35
- After the user approves the plan, your work is **DONE**. Output: _"Plan approved and locked in. Let me know when you want to implement."_ Then **STOP completely**. Do NOT invoke `/jdi:implement-plan`, do NOT spawn implementation agents, do NOT begin writing source code. Planning and implementation are separate human-gated phases.
169
+ After the user approves the plan, your work is **DONE**.
170
+
171
+ Output exactly: _"Plan approved and locked in. Let me know when you want to implement."_
172
+
173
+ Then STOP completely.
174
+
175
+ - Do NOT invoke `/jdi:implement-plan`.
176
+ - Do NOT spawn implementation agents.
177
+ - Do NOT begin writing source code.
178
+ - Do NOT suggest implementation commands beyond the one-line completion message.
179
+
180
+ Planning and implementation are separate human-gated phases. This gate exists because past sessions have drifted into implementation immediately after approval, producing work the user did not sanction.
181
+
182
+ ---
183
+
184
+ ## Collaborative Protocol
185
+
186
+ <JDI:StrictnessProtocol />
187
+
188
+ ---
36
189
 
37
- Agent base (read FIRST for cache): .jdi/framework/components/meta/AgentBase.md | Agent spec: .jdi/framework/agents/jdi-planner.md | Agent routing: .jdi/framework/components/meta/AgentRouter.md
190
+ **References:** Agent base (read FIRST for cache): `.jdi/framework/components/meta/AgentBase.md` | Agent spec: `.jdi/framework/agents/jdi-planner.md` | Agent routing: `.jdi/framework/components/meta/AgentRouter.md`
38
191
 
39
- Feature to plan: $ARGUMENTS
192
+ **Feature to plan:** $ARGUMENTS
@@ -1,19 +1,91 @@
1
1
  ---
2
2
  name: generate-pr
3
- description: "JDI: Generate pull request"
3
+ description: "JDI: Generate comprehensive PR description and create the pull request"
4
+ allowed-tools: Read, Bash, Task
5
+ argument-hint: "[optional context hint]"
6
+ context: |
7
+ !git branch --show-current 2>/dev/null
8
+ !git log --oneline main..HEAD 2>/dev/null | head -15
4
9
  ---
5
10
 
6
11
  # /jdi:generate-pr
7
12
 
8
- Generate a comprehensive PR description and create the pull request.
13
+ Generate a PR description from the current branch's commits and create the pull request via the `jdi-pr-generator` specialist.
9
14
 
10
- ## Delegation
15
+ **This skill follows `<JDI:StrictnessProtocol />`. Read that component before executing any step below.**
11
16
 
12
- **Agent:** jdi-pr-generator
17
+ ---
18
+
19
+ ## Orchestration
20
+
21
+ ### 1. Branch Pre-flight
22
+
23
+ Run these checks in parallel:
24
+
25
+ - `git branch --show-current` — confirm we're not on `main`/`master`
26
+ - `git log --oneline main..HEAD` — confirm there are commits to include
27
+ - `git status --short` — confirm working tree is clean
28
+
29
+ If any check fails, STOP and report:
30
+
31
+ | Failure | Message |
32
+ |---------|---------|
33
+ | On `main`/`master` | "You're on the base branch. Switch to a feature branch first." |
34
+ | Zero commits ahead of base | "No commits to include in a PR. Make commits first." |
35
+ | Dirty working tree | "Working tree has uncommitted changes. Commit or stash before generating a PR." |
36
+
37
+ ### 2. Existing PR Check
38
+
39
+ Run `gh pr list --head {current-branch}`. If a PR already exists for this branch, STOP:
40
+
41
+ > "PR #{existing} already exists for this branch. Use `/jdi:pr-feedback` to address comments, or update the existing PR directly."
42
+
43
+ ### 3. Delegate to jdi-pr-generator
44
+
45
+ Spawn the specialist via Task tool. JDI specialists spawn as `general-purpose` with identity injected via prompt text:
46
+
47
+ ```
48
+ Task(
49
+ subagent_type="general-purpose",
50
+ prompt="You are jdi-pr-generator. Read .jdi/framework/agents/jdi-pr-generator.md
51
+ for your full role and instructions. Also read
52
+ .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
53
+
54
+ Generate PR for current branch. Context hint: $ARGUMENTS"
55
+ )
56
+ ```
13
57
 
14
- Use Task tool with subagent_type="general-purpose" and prompt:
58
+ ### 4. Confirm Before Creating
15
59
 
16
- Read ./.jdi/framework/components/meta/AgentBase.md for the base protocol.
17
- You are jdi-pr-generator. Read ./.jdi/framework/agents/jdi-pr-generator.md for instructions.
60
+ The generator returns a draft title and body. Present both to the user and ask:
61
+
62
+ > "Create the PR with this title and body, or revise first?"
63
+
64
+ **Wait for the user's answer. Do NOT auto-run `gh pr create`.** Creating a PR is visible to collaborators — it requires explicit approval.
65
+
66
+ ### 5. Create PR
67
+
68
+ On approval, run `gh pr create` with the confirmed title and body. Report the PR URL. Then **STOP**.
69
+
70
+ ---
71
+
72
+ ## Edge Cases
73
+
74
+ | Situation | Response |
75
+ |-----------|----------|
76
+ | On `main`/`master` | STOP at step 1. Refuse to generate. |
77
+ | No commits ahead of base | STOP at step 1. Nothing to PR. |
78
+ | Dirty working tree | STOP at step 1. Ask the user to commit or stash. |
79
+ | Existing PR for branch | STOP at step 2. Redirect to `/jdi:pr-feedback`. |
80
+ | `gh` not authenticated | Report the error verbatim. Do NOT attempt to create the PR via other means. |
81
+ | User wants to target a non-default base | Pass the base to `gh pr create --base {branch}` at step 5, after explicit confirmation. |
82
+
83
+ ---
84
+
85
+ ## Collaborative Protocol
86
+
87
+ <JDI:StrictnessProtocol />
88
+
89
+ ---
18
90
 
19
- Generate PR for current branch: $ARGUMENTS
91
+ **Context:** $ARGUMENTS
@@ -1,38 +1,218 @@
1
1
  ---
2
2
  name: implement-plan
3
3
  description: "JDI: Execute implementation plan"
4
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit, Task
5
+ argument-hint: "[--team | --single | --dry-run | --skip-qa]"
6
+ context: |
7
+ !cat .jdi/config/state.yaml 2>/dev/null | head -30
4
8
  ---
5
9
 
6
10
  # /jdi:implement-plan
7
11
 
8
- Execute a PLAN.md with complexity-based routing.
12
+ Execute an approved plan with complexity-based routing. Deterministic workflow — every invocation follows the same numbered steps, in order, without skipping.
9
13
 
10
- **Flags:** `--team` (force Agent Teams) | `--single` (force single agent) | `--dry-run` (preview without writing)
14
+ **This skill follows `<JDI:StrictnessProtocol />` and `<JDI:SilentDiscovery />`. Read those components before executing any step below.**
15
+
16
+ ---
17
+
18
+ ## Flags
19
+
20
+ - `--team` — Force Agent Teams mode regardless of complexity signals
21
+ - `--single` — Force single-agent mode regardless of complexity signals
22
+ - `--dry-run` — Preview without writing: list files that would change and agents that would be spawned, then STOP
23
+ - `--skip-qa` — Skip the post-task `jdi-qa-tester` verification pass
11
24
 
12
25
  > **Do NOT use the built-in `EnterWorktree` tool.** If `state.yaml` has `worktree.active: true`, just `cd` into `worktree.path`.
13
26
 
27
+ ---
28
+
14
29
  ## Orchestration
15
30
 
16
- 1. Read codebase context (`.jdi/codebase/SUMMARY.md` if exists)
17
- 2. Read plan index file and state.yaml — parse frontmatter for tasks, deps, waves, tech_stack, `available_agents`, and `primary_agent`
18
- 3. **Read learnings:** Always read `.jdi/framework/learnings/general.md`. Then read domain-specific learnings based on tech_stack from plan frontmatter: PHP → `backend.md`, TS/React → `frontend.md`. Follow any conventions found — learnings override defaults.
19
- 4. **Format detection:** If frontmatter contains `task_files:`, this is a split plan — task details are in separate files. If absent, legacy monolithic plan — all tasks inline.
20
- 5. **Read per-task agents (MANDATORY for split plans)** — for every task file listed in `task_files`, read its frontmatter and record the `agent:` field. This is the `subagent_type` you will pass to the Task tool when spawning. Missing `agent:` → fall back to `primary_agent` → fall back to tech-stack default (`jdi-backend` / `jdi-frontend` / `general-purpose`). NEVER default everything to `general-purpose` silently. See `.jdi/framework/components/meta/AgentRouter.md`.
21
- 6. **Agent existence check** — for each pinned agent, confirm it is actually installed (`.claude/agents/{name}.md` project-local, or `~/.claude/agents/{name}.md` user-global). If it is NOT installed, downgrade to `general-purpose` and record a `agent_downgrade:` entry to surface in the summary. Never silently change the pin.
22
- 7. **Complexity routing** (`<JDI:ComplexityRouter />`): Simple (≤3 tasks, single stack/wave) → single agent. Complex → Agent Teams swarm. Override: `--team` / `--single`
23
- 8. **Tech routing (fallback only when no pins exist)**: PHP → jdi-backend | TS/React → jdi-frontend | Full-stack → both. Pins ALWAYS override this fallback.
24
- 9. Execute:
25
- - **Single agent:** Spawn with `subagent_type: {plan.primary_agent}` (NOT `general-purpose`). Pass `PLAN: {index-path}`. For split plans, the agent reads task files one at a time via `file:` field in state.yaml.
26
- - **Agent Teams:** For split plans, spawn ONE Task tool call per task with `subagent_type: {task.agent}` (the pin from the task file frontmatter), passing `TASK_FILE: {task-file-path}` so it loads only its assigned task. For legacy plans, pass `PLAN: {plan-path}` and use `primary_agent`.
27
- 10. Collect and execute deferred ops (files, commits)
28
- 11. Run verification (tests, lint, typecheck)
29
- 12. **Update state via CLI** — do NOT manually edit state.yaml. Run `npx jdi state executing` before execution and `npx jdi state complete` after. Use `npx jdi state advance-task {task-id}` after each task completes.
30
- 13. **Present summary** (tasks completed, files changed, verification results, **which specialist ran which task**, any `agent_downgrade` events, deviations) then ask: _"Provide feedback to adjust, or say **approved** to finalise."_
31
- 14. **Review loop**: Feedback apply code changes, run tests, increment revision, re-present. Approval → suggest commit/PR. Natural conversation no separate command needed.
32
-
33
- Agent base (read FIRST for cache): .jdi/framework/components/meta/AgentBase.md | Agent specs: .jdi/framework/agents/jdi-backend.md, .jdi/framework/agents/jdi-frontend.md
34
- Orchestration: .jdi/framework/components/meta/AgentTeamsOrchestration.md | Routing: .jdi/framework/components/meta/ComplexityRouter.md | Agent routing: .jdi/framework/components/meta/AgentRouter.md
35
-
36
- When spawning agents, detect project type and include a `## Project Context` block (type, tech stack, quality gates, working directory) in the spawn prompt. This saves agents 2-3 discovery tool calls.
37
-
38
- Plan to execute: $ARGUMENTS
31
+ The steps below are numbered and ordered. Do NOT skip, merge, or reorder them. Each step ends with a clear state transition — if you cannot produce that transition, STOP and ask.
32
+
33
+ ### 1. Silent Discovery
34
+
35
+ Execute `<JDI:SilentDiscovery />` now. Read the scaffolding files listed in that component and store the result internally as `DISCOVERED_STATE`. Do NOT print the discovery output to the user.
36
+
37
+ **Additional reads for this skill:**
38
+ - `.jdi/codebase/SUMMARY.md` if it exists
39
+ - `.jdi/framework/learnings/general.md` (always)
40
+ - Domain-specific learnings based on `DISCOVERED_STATE.tech_stack`: PHP `backend.md`, TS/React `frontend.md`, testing `testing.md`, devops `devops.md`
41
+
42
+ Learnings override defaults. Record which learnings files were found in `DISCOVERED_STATE.learnings_loaded`.
43
+
44
+ ### 2. Load Plan
45
+
46
+ Read the plan index file (path from `$ARGUMENTS` or from `DISCOVERED_STATE.current_plan.path`). Parse the frontmatter for:
47
+
48
+ - `tasks:` or `task_files:` (legacy monolithic vs split plan)
49
+ - `deps:` and `waves:`
50
+ - `tech_stack:`
51
+ - `available_agents:` catalogue
52
+ - `primary_agent:` pin
53
+
54
+ **Format detection:** if frontmatter contains `task_files:`, this is a split plan — read each task file's frontmatter in a single batch. If absent, this is a legacy monolithic plan — all tasks are inline in the index.
55
+
56
+ **Plan status gate:** if the plan's status in `state.yaml` is not `approved`, STOP and tell the user: "Plan is in status `{status}` — run `/jdi:create-plan` (or the review loop) to reach `approved` before implementing."
57
+
58
+ ### 3. Resolve Per-Task Agents
59
+
60
+ For every task file listed in `task_files:`, record the `agent:` field from its frontmatter. This is the `subagent_type` you will pass to the Task tool when spawning.
61
+
62
+ **Resolution order:**
63
+ 1. Task-level `agent:` pin from the task file frontmatter
64
+ 2. Plan-level `primary_agent:` from the index frontmatter
65
+ 3. Tech-stack default: PHP → `jdi-backend`, TS/React → `jdi-frontend`, otherwise → `general-purpose`
66
+
67
+ **NEVER default everything to `general-purpose` silently.** See `framework/components/meta/AgentRouter.md`.
68
+
69
+ ### 4. Agent Existence Check
70
+
71
+ For each pinned agent, read the matching `source:` from the plan's `available_agents` catalogue and confirm the spec exists:
72
+
73
+ - **`source: jdi`** — check `.jdi/framework/agents/{name}.md` (installed projects) or `framework/agents/{name}.md` (self-hosting jedi repo)
74
+ - **`source: claude-code`** — check `.claude/agents/{name}.md` (project-local) or `~/.claude/agents/{name}.md` (user-global)
75
+
76
+ If the spec is NOT found, downgrade to `general-purpose` (with a `jdi-backend` / `jdi-frontend` spec load in the prompt) and record an `agent_downgrade:` entry listing the original pin, the downgrade target, and the reason. This entry MUST appear in the final summary — never silently change a pin.
77
+
78
+ ### 5. Complexity Routing
79
+
80
+ Apply `<JDI:ComplexityRouter />`:
81
+ - **Simple** (≤3 tasks, single stack/wave) → single-agent mode
82
+ - **Complex** (>3 tasks OR multi-stack OR multi-wave) → Agent Teams swarm
83
+
84
+ **Override flags:** `--team` forces Agent Teams mode; `--single` forces single-agent mode. Overrides win over complexity signals.
85
+
86
+ Record the routing decision and reasoning in `DISCOVERED_STATE.routing`.
87
+
88
+ ### 6. Dry Run Check
89
+
90
+ If `--dry-run` is present, output:
91
+ - The resolved agent per task
92
+ - Any `agent_downgrade:` entries
93
+ - The routing decision
94
+ - The list of files each task claims to touch (from task spec)
95
+
96
+ Then **STOP**. Do NOT spawn agents, do NOT advance state, do NOT edit files.
97
+
98
+ ### 7. Advance State to Executing
99
+
100
+ Run `bun run src/index.ts state executing` (in installed projects: `npx jdi state executing`). Do NOT manually edit `state.yaml`.
101
+
102
+ ### 8. Spawn and Execute
103
+
104
+ **Platform constraint:** JDI specialists (`source: jdi`) are NOT registered Claude Code subagents and MUST be spawned via `subagent_type="general-purpose"` with identity injected via prompt text (`"You are {agent}. Read .jdi/framework/agents/{agent}.md..."`). Registered Claude Code subagents (`source: claude-code`) are spawned directly by name. See `framework/jedi.md` Critical Constraints and `framework/components/meta/AgentRouter.md` §4.
105
+
106
+ **Single-agent mode:**
107
+ - `source: jdi` → `Task(subagent_type="general-purpose", prompt="You are {plan.primary_agent}. Read .jdi/framework/agents/{plan.primary_agent}.md... PLAN: {index-path}")`
108
+ - `source: claude-code` → `Task(subagent_type="{plan.primary_agent}", prompt="<standard spawn prompt> PLAN: {index-path}")`
109
+
110
+ For split plans, the agent reads task files one at a time via the `file:` field in `state.yaml`.
111
+
112
+ **Agent Teams mode:** Spawn ONE Task call per task using the source-aware pattern above. Pass `TASK_FILE: {task-file-path}` so the agent loads only its assigned task.
113
+
114
+ **Prompt scoping rules (non-negotiable):**
115
+ - One task = one spawn. Never bundle multiple tasks into one prompt.
116
+ - Give exact file paths. Cap exploration explicitly: "read only your TASK_FILE and the files it names."
117
+ - Request short reports (<400 words). Agents can be truncated mid-task; scoped prompts survive the budget ceiling.
118
+ - Include a `## Project Context` block in every spawn prompt: type, tech stack, quality gates, working directory. Saves 2-3 discovery tool calls per spawn.
119
+ - For split plans, the agent reads the `TASK_FILE` itself — do not inline task content into the prompt.
120
+
121
+ **Wave-based execution:** honour `waves:` from the plan frontmatter. Spawn all tasks in wave N in parallel; wait for all returns before starting wave N+1.
122
+
123
+ ### 9. Advance Task State
124
+
125
+ After each task's programmer returns successfully, run:
126
+
127
+ ```bash
128
+ bun run src/index.ts state advance-task {task-id}
129
+ ```
130
+
131
+ Do NOT advance state for tasks that failed or were skipped. Do NOT batch advance calls — advance per task, in order.
132
+
133
+ ### 10. Post-Task Verify (jdi-qa-tester)
134
+
135
+ After each task's programmer returns, invoke `jdi-qa-tester` in `post-task-verify` mode with the task's `done_when` criteria and `files_modified` list. If verification fails with **S1** or **S2** severity, **halt the plan** and escalate to the user. Otherwise record the verification result in the task summary and proceed to commit.
136
+
137
+ - **a11y-check trigger:** if `files_modified` includes UI files (components, views, templates, CSS affecting render), additionally invoke `jdi-qa-tester` in `a11y-check` mode and record the result in the same task summary.
138
+ - **contract-check trigger:** if `files_modified` includes contract-bearing files — API routes, Controllers/Actions, DTOs, FormRequests, OpenAPI specs, exported TypeScript types, `packages/*/src/index.ts`, DB migrations, generated client code — additionally invoke `jdi-qa-tester` in `contract-check` mode. Treat any contract failure as at least **S2** and halt the plan.
139
+ - **Skip rules:** Skipped entirely if `--skip-qa` is passed. Also skipped automatically if `files_modified` contains ONLY `.md`, `.yaml`, or `.yml` files (documentation/config doesn't get regression-tested). The programmer's structured return field `qa_verification_needed: false` is also honoured.
140
+ - **Contract-check exception to the skip rule:** if any file in `files_modified` is a contract-bearing YAML/JSON spec (OpenAPI / Swagger — e.g. `openapi.yaml`, `swagger.json`, `api/*.yaml`, `**/openapi*.{yml,yaml,json}`; GraphQL SDL — `**/*.graphql`, `**/schema.gql`; JSON Schema — `**/schemas/**/*.json`), still invoke `contract-check` even when the doc-only skip rule would otherwise apply. `post-task-verify` and `a11y-check` remain skipped in this case — only `contract-check` runs.
141
+
142
+ ### 11. Execute Deferred Ops
143
+
144
+ Collect `files_to_create` returns from every agent and execute them via Write tool. Apply any pending commit operations. Do NOT skip this step — sandbox-returned artefacts are real work.
145
+
146
+ ### 12. Run Verification Gates
147
+
148
+ Execute the project's quality gates in order: tests, lint, typecheck (exact commands come from `DISCOVERED_STATE.quality_gates`). Record pass/fail per gate.
149
+
150
+ If any gate fails, STOP — do not advance state to `complete`. Report the failure and enter the review loop at step 14.
151
+
152
+ ### 13. Advance State to Complete
153
+
154
+ Run `bun run src/index.ts state complete`. Do NOT manually edit `state.yaml`.
155
+
156
+ ### 14. Present Summary
157
+
158
+ Present the implementation summary to the user:
159
+
160
+ - Tasks completed (with per-task agent and verification result)
161
+ - Files changed (grouped by task)
162
+ - Quality gate results
163
+ - Any `agent_downgrade:` events
164
+ - Deviations from the spec
165
+
166
+ End with the exact prompt: _"Provide feedback to adjust, or say **approved** to finalise."_
167
+
168
+ **Wait for the user's answer. Do NOT suggest commits or PRs yet.**
169
+
170
+ ### 15. Review Loop
171
+
172
+ - **Feedback:** apply the requested code changes, re-run verification gates, increment the revision counter, and re-present the summary.
173
+ - **Approval:** suggest a conventional commit or PR generation as the next step. Do NOT auto-run either — the user decides.
174
+
175
+ **Never loop back to step 8.** Feedback refines existing tasks; it does not re-spawn agents for tasks that already completed.
176
+
177
+ ---
178
+
179
+ ## Edge Cases
180
+
181
+ Pre-written responses for known deviations. When one applies, follow the scripted response rather than improvising.
182
+
183
+ | Situation | Response |
184
+ |-----------|----------|
185
+ | Plan status is not `approved` | STOP at step 2. Tell the user to approve the plan first. Do NOT force-advance. |
186
+ | Pinned agent not installed | Downgrade to `general-purpose`, record the downgrade, continue. Surface in the final summary. |
187
+ | Task file missing (listed in `task_files:` but not on disk) | STOP. Report the missing file. Do NOT advance state. |
188
+ | Programmer returns with `status: blocked` | HALT the plan. Do NOT advance task state. Surface the blocker to the user and wait. |
189
+ | QA verification S1 or S2 failure | HALT the plan immediately. Record the failure in state. Wait for user direction before continuing. |
190
+ | Verification gate failure at step 12 | STOP before completing. Report the failure, enter review loop. Do NOT advance state to `complete`. |
191
+ | `--dry-run` with no changes needed | Output "no-op: plan is already at target state" and STOP. |
192
+ | Worktree active but path missing | Ask the user: recreate the worktree, or proceed in current directory? Do NOT silently proceed. |
193
+ | Wave has zero tasks ready | Skip the empty wave, log it, continue to the next wave. |
194
+ | User asks to skip verification during review | Remind them of `--skip-qa` flag semantics. Do NOT skip silently. |
195
+
196
+ ---
197
+
198
+ ## HARD STOP — Verification Gate
199
+
200
+ Before presenting the summary (step 14), all three must be true:
201
+
202
+ 1. Every task has either `advance-task` applied OR a documented failure in the summary
203
+ 2. Every QA verification trigger that fired has a recorded result
204
+ 3. Every quality gate has passed OR been explicitly flagged as failing in the summary
205
+
206
+ If ANY of these is not true, STOP. Do not present a summary that implies success when work remains. Silent gaps are the failure mode this gate exists to prevent.
207
+
208
+ ---
209
+
210
+ ## Collaborative Protocol
211
+
212
+ <JDI:StrictnessProtocol />
213
+
214
+ ---
215
+
216
+ **References:** Agent base (read FIRST for cache): `.jdi/framework/components/meta/AgentBase.md` | Agent specs: `.jdi/framework/agents/jdi-backend.md`, `.jdi/framework/agents/jdi-frontend.md` | Orchestration: `.jdi/framework/components/meta/AgentTeamsOrchestration.md` | Routing: `.jdi/framework/components/meta/ComplexityRouter.md`, `.jdi/framework/components/meta/AgentRouter.md`
217
+
218
+ **Plan to execute:** $ARGUMENTS
@@ -1,20 +1,75 @@
1
1
  ---
2
2
  name: pr-feedback
3
- description: "JDI: Address PR feedback"
3
+ description: "JDI: Address PR review comments systematically"
4
+ allowed-tools: Read, Bash, Task
5
+ argument-hint: "<pr-number-or-url>"
6
+ context: |
7
+ !git branch --show-current 2>/dev/null
4
8
  ---
5
9
 
6
10
  # /jdi:pr-feedback
7
11
 
8
- Address PR review comments systematically.
12
+ Address review comments on a pull request via the `jdi-pr-feedback` specialist.
9
13
 
10
- ## Delegation
14
+ **This skill follows `<JDI:StrictnessProtocol />`. Read that component before executing any step below.**
11
15
 
12
- **Agent:** jdi-pr-feedback
16
+ ---
17
+
18
+ ## Orchestration
19
+
20
+ ### 1. Parse PR Reference
21
+
22
+ Extract the PR number from `$ARGUMENTS`. Accept a bare number or a full GitHub URL. If neither is present, STOP and ask for one.
23
+
24
+ ### 2. Fetch Unresolved Comments
25
+
26
+ Run `gh api repos/{owner}/{repo}/pulls/{number}/comments` (or equivalent) to confirm there are unresolved comments. If there are none, STOP:
27
+
28
+ > "PR #{number} has no unresolved review comments. Nothing to address."
29
+
30
+ ### 3. Delegate to jdi-pr-feedback
31
+
32
+ Spawn the specialist via Task tool. JDI specialists spawn as `general-purpose` with identity injected via prompt text:
33
+
34
+ ```
35
+ Task(
36
+ subagent_type="general-purpose",
37
+ prompt="You are jdi-pr-feedback. Read .jdi/framework/agents/jdi-pr-feedback.md
38
+ for your full role and instructions. Also read
39
+ .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
40
+ If your spec has requires_components in frontmatter, batch-read all listed
41
+ components before starting.
42
+
43
+ Address feedback for PR: {pr-number}"
44
+ )
45
+ ```
46
+
47
+ ### 4. Present Result
13
48
 
14
- Use Task tool with subagent_type="general-purpose" and prompt:
49
+ After the specialist returns, summarise: comments addressed, files touched, commits made. End with:
15
50
 
16
- Read ./.jdi/framework/components/meta/AgentBase.md for the base protocol.
17
- You are jdi-pr-feedback. Read ./.jdi/framework/agents/jdi-pr-feedback.md for instructions.
18
- If your spec has requires_components in frontmatter, batch-read all listed components before starting.
51
+ > "Feedback applied. Review the diff, then run `/jdi:commit` or push when ready."
52
+
53
+ **Wait for the user's response. Do NOT auto-push.**
54
+
55
+ ---
56
+
57
+ ## Edge Cases
58
+
59
+ | Situation | Response |
60
+ |-----------|----------|
61
+ | No PR reference | STOP at step 1. Ask for a number or URL. |
62
+ | No unresolved comments | STOP at step 2. Nothing to do. |
63
+ | Specialist cannot address a specific comment | Surface the blocker; the user decides whether to override or defer. |
64
+ | Working tree dirty before start | Ask whether to stash, commit, or abort. Do NOT silently mix unrelated changes. |
65
+ | PR is closed or merged | STOP and report — feedback on closed PRs is not actionable via this skill. |
66
+
67
+ ---
68
+
69
+ ## Collaborative Protocol
70
+
71
+ <JDI:StrictnessProtocol />
72
+
73
+ ---
19
74
 
20
- Address feedback for PR: $ARGUMENTS
75
+ **PR to address:** $ARGUMENTS