@benzotti/jdi 0.1.46 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12791,7 +12791,7 @@ var stateCommand = defineCommand({
12791
12791
  // package.json
12792
12792
  var package_default = {
12793
12793
  name: "@benzotti/jdi",
12794
- version: "0.1.46",
12794
+ version: "0.1.49",
12795
12795
  description: "JDI - Context-efficient AI development framework for Claude Code",
12796
12796
  type: "module",
12797
12797
  bin: {
@@ -22,7 +22,7 @@ Do not add unrelated extras (tooling, testing, linting, CI) unless the user expl
22
22
  2. **DO investigate the full scope of the request.** "Scope discipline" means no unrelated additions — it does NOT mean ignoring requirements that are clearly implied by the request. If the user asks for a UI view with specific columns, you must verify those columns exist in the backend response, and plan to add them if they don't.
23
23
  3. **When reference PRs/tickets are provided, analyse them thoroughly.** Read the actual diff, files changed, patterns used, columns/fields added, routes created, and data flow. The user provides reference PRs so you follow the same pattern — extract the full pattern, don't just skim.
24
24
  4. **When the user says "backend is already done", verify it.** Read the actual API endpoint, check what fields it returns, and confirm they match the frontend requirements. If there's a gap, include it in the plan.
25
- 5. **Do not make subjective decisions.** If something is ambiguous (e.g. folder structure, routing library, state management), list it as an open question and ask the user — do not guess.
25
+ 5. **Do not make subjective decisions.** If something is ambiguous (e.g. folder structure, routing library, state management), list it as an open question and ask the user — do not guess. If pre-answered questions cover a decision point, use the pre-answered value rather than listing it as open.
26
26
  6. **Suggest optional additions separately.** After presenting the plan, list 3-5 common additions the user might want. These are suggestions, NOT part of the plan.
27
27
  7. **Same request = same plan.** Two identical requests must produce structurally identical plans. Achieve this by following the templates exactly and not improvising.
28
28
 
@@ -33,11 +33,27 @@ Before planning, ALWAYS:
33
33
  2. Apply any team preferences found (e.g. "always use path aliases", "prefer Zustand over Redux")
34
34
  3. Learnings override your defaults — if the team has a preference, follow it
35
35
 
36
+ ## CRITICAL: Respect Pre-Answered Questions
37
+
38
+ When the spawn prompt includes a `PRE_ANSWERED_QUESTIONS` block:
39
+
40
+ 1. Parse each question-id and chosen answer
41
+ 2. Treat these as settled decisions — do NOT re-ask them
42
+ 3. Do NOT surface them as "Open Questions" in the plan
43
+ 4. Reference them in relevant task descriptions as
44
+ "Decision: {question} → {answer} (pre-plan gate)"
45
+ 5. Only surface NEW questions that genuinely emerged DURING
46
+ planning and could not have been anticipated from the
47
+ feature description alone
48
+
49
+ Pre-answered questions represent explicit user choices made via
50
+ interactive prompts. Overriding them silently is forbidden.
51
+
36
52
  ## CRITICAL: File Writing is Mandatory
37
53
 
38
54
  You MUST write files using Write/Edit tools. Returning plan content as text is NOT acceptable.
39
55
 
40
- **SANDBOX OVERRIDE:** Plan file creation is an EXCEPTION to AgentBase sandbox rules. You MUST use the Write tool to create plan files directly do NOT defer them to `files_to_create`. Plan files WILL persist when written via the Write tool. This override applies ONLY to `.jdi/plans/` and `.jdi/config/` files listed below.
56
+ You MUST use the Write tool to create plan files directly. You have full file permissions (`mode: "bypassPermissions"`).
41
57
 
42
58
  Required files (SPLIT FORMAT — one file per task):
43
59
  1. `.jdi/plans/{phase}-{plan}-{slug}.plan.md` (index file — manifest table only, NO inline task details)
@@ -73,7 +73,7 @@ For each task:
73
73
 
74
74
  ### Step 4: Plan Completion
75
75
  - Run plan-level verification
76
- - Generate SUMMARY.md (via `files_to_create`)
76
+ - Generate SUMMARY.md (via Write tool)
77
77
  - Update final state
78
78
 
79
79
  ---
@@ -91,10 +91,8 @@ one_liner: "{brief summary}"
91
91
  next_action: {what should happen next}
92
92
  files_modified:
93
93
  - path/to/edited/file1.ts
94
- files_to_create:
95
- - path: ".jdi/plans/{phase}-{plan}-{slug}.summary.md"
96
- content: |
97
- {full summary content}
94
+ files_created:
95
+ - .jdi/plans/{phase}-{plan}-{slug}.summary.md
98
96
  commits_pending:
99
97
  - message: "{conventional commit message}"
100
98
  files: [path/to/file1.ts]
@@ -55,6 +55,78 @@ Write to `.jdi/research/{topic}-research.md`.
55
55
 
56
56
  ---
57
57
 
58
+ ## Pre-Plan Discovery Mode
59
+
60
+ **Trigger:** Spawned by `create-plan` with mode flag `--pre-plan-discovery`.
61
+
62
+ This is a lightweight, fast mode — NOT a full research report. The goal is to identify decision points in the codebase that the user should resolve before planning begins.
63
+
64
+ ### Constraints
65
+
66
+ - **Budget:** Read at most 15 files
67
+ - **Output:** Under 400 words
68
+ - **No file writes** — do not create `.jdi/research/` files in this mode
69
+
70
+ ### Input
71
+
72
+ - Feature description
73
+ - `PRE_DISCOVERED_CONTEXT` (scaffolding already read by the orchestrator)
74
+
75
+ ### What to Look For
76
+
77
+ Scan the codebase for decision points relevant to the feature:
78
+
79
+ - **Competing patterns** — e.g. two state management approaches, two API styles, inconsistent naming conventions
80
+ - **Missing data/fields** — the feature implies data that doesn't exist yet in current schemas/models
81
+ - **Architectural choices** — where to put new code, which module to extend, whether to create a new module
82
+ - **Dependency/library choices** — feature needs a capability the project doesn't have yet
83
+ - **Existing conventions** — patterns that constrain the approach (established test patterns, folder structure, naming)
84
+
85
+ ### Output Format
86
+
87
+ Return a structured YAML `RESEARCH_QUESTIONS` block:
88
+
89
+ ```yaml
90
+ RESEARCH_DISCOVERY:
91
+ research_questions:
92
+ - id: RQ-01
93
+ question: "The codebase uses both X and Y for Z — which should this feature follow?"
94
+ header: "PATTERN"
95
+ options:
96
+ - label: "Use X"
97
+ description: "Consistent with src/foo/ — the newer pattern"
98
+ - label: "Use Y"
99
+ description: "Consistent with src/bar/ — the legacy pattern"
100
+ context: "Found X in src/foo/*.ts (3 files), Y in src/bar/*.ts (7 files)"
101
+ - id: RQ-02
102
+ question: "..."
103
+ header: "..."
104
+ options:
105
+ - label: "..."
106
+ description: "..."
107
+ context: "..."
108
+ research_context: "Brief summary of what was found for the planner"
109
+ ```
110
+
111
+ Each question must include:
112
+ - `id`: Sequential ID (`RQ-01`, `RQ-02`, ...)
113
+ - `question`: Clear, specific question text
114
+ - `header`: Category tag, max 12 chars (`PATTERN`, `STACK`, `DATA`, `APPROACH`, `BOUNDARY`)
115
+ - `options`: 2-4 options with `label` and `description` grounded in codebase findings
116
+ - `context`: Brief note on what evidence was found
117
+
118
+ ### If No Questions Found
119
+
120
+ Return an empty array with a brief context summary. This is a valid outcome for clear-cut features:
121
+
122
+ ```yaml
123
+ RESEARCH_DISCOVERY:
124
+ research_questions: []
125
+ research_context: "Scanned src/components/ and src/api/. Single pattern in use (React Query + Zustand). No competing approaches or ambiguous extension points found."
126
+ ```
127
+
128
+ ---
129
+
58
130
  ## Structured Returns
59
131
 
60
132
  ```yaml
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: build
3
3
  description: "JDI: Guided setup and state-aware entry point for new and returning users"
4
- allowed-tools: Read, Glob, Grep, Bash
4
+ allowed-tools: Read, Glob, Grep, Bash, AskUserQuestion
5
5
  argument-hint: "[no arguments]"
6
6
  context: |
7
7
  !cat .jdi/config/state.yaml 2>/dev/null | head -20
@@ -51,6 +51,19 @@ If NEITHER condition is true, the user is new — proceed to step 3.
51
51
 
52
52
  Present exactly these four options. Frame them for software projects — no game-specific language, no engine/prototype vocabulary.
53
53
 
54
+ **Preferred: AskUserQuestion.** Use AskUserQuestion with:
55
+ - **header:** `STAGE`
56
+ - **question:** `Which of these describes your situation best?`
57
+ - **options:**
58
+ 1. label: `No idea yet` — description: `I want to figure out what to build`
59
+ 2. label: `Vague idea` — description: `I know the problem but not the shape of the solution`
60
+ 3. label: `Clear concept` — description: `I know what I want to build and roughly how`
61
+ 4. label: `Existing work` — description: `There's already code or scaffolding I want to continue from`
62
+
63
+ The automatic "Other" option covers situations that don't fit. Route based on the selected option — same branch logic as step 4.
64
+
65
+ **Fallback (if AskUserQuestion is unavailable):** Present as plain markdown instead:
66
+
54
67
  > **Welcome to JDI.**
55
68
  >
56
69
  > Before I suggest anything, I'd like to understand where you are. Which of these describes your situation best?
@@ -98,7 +111,16 @@ Each branch below is its own script. Follow the one that matches the user's choi
98
111
 
99
112
  ### 5. Confirm Before Handing Off
100
113
 
101
- After presenting your recommendation, ask this exact question:
114
+ After presenting your recommendation, confirm with the user before proceeding.
115
+
116
+ **Preferred: AskUserQuestion.** Use AskUserQuestion with:
117
+ - **header:** `NEXT`
118
+ - **question:** `Ready to proceed?`
119
+ - **options:**
120
+ 1. label: `{recommended command}` — description: `Start with the recommended next step`
121
+ 2. label: `Something else` — description: `I want to do something different`
122
+
123
+ **Fallback (if AskUserQuestion is unavailable):** Ask as plain text instead:
102
124
 
103
125
  > "Would you like to start with **{recommended command}**, or something else?"
104
126
 
@@ -37,8 +37,9 @@ If there are unstaged changes but nothing is staged, ask the user:
37
37
  Spawn the committer via Task tool. JDI specialists spawn as `general-purpose` with identity injected via prompt text (see `framework/jdi.md` Critical Constraints):
38
38
 
39
39
  ```
40
- Task(
40
+ Agent(
41
41
  subagent_type="general-purpose",
42
+ mode="bypassPermissions",
42
43
  prompt="You are jdi-committer. Read .jdi/framework/agents/jdi-committer.md for
43
44
  your full role and instructions. Also read .jdi/framework/components/meta/AgentBase.md
44
45
  for the JDI base protocol. If your spec has requires_components in frontmatter,
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: create-plan
3
3
  description: "JDI: Create implementation plan"
4
- allowed-tools: Read, Glob, Grep, Bash, Write, Edit, Task
4
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit, Task, AskUserQuestion
5
5
  argument-hint: "<feature to plan> [--worktree | --worktree-lightweight | --status]"
6
6
  context: |
7
7
  !cat .jdi/config/state.yaml 2>/dev/null | head -25
@@ -12,7 +12,7 @@ context: |
12
12
 
13
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
14
 
15
- **This skill follows `<JDI:StrictnessProtocol />` and `<JDI:SilentDiscovery />`. Read those components before executing any step below.**
15
+ **This skill follows `<JDI:StrictnessProtocol />`, `<JDI:SilentDiscovery />`, and `<JDI:InteractiveGate />`. Read those components before executing any step below.**
16
16
 
17
17
  ---
18
18
 
@@ -89,14 +89,40 @@ If the feature description looks trivial (single file, <30 minutes, no architect
89
89
 
90
90
  **Wait for the user's answer. Do not proceed until they respond.** If they pick quick, STOP — do not spawn the planner.
91
91
 
92
+ ### 4a. Pre-Plan Research Spawn
93
+
94
+ Spawn `jdi-researcher` in `pre-plan-discovery` mode via `Agent(subagent_type="general-purpose", mode="bypassPermissions")`. The spawn prompt MUST include:
95
+
96
+ - The feature description (`$ARGUMENTS`)
97
+ - `PRE_DISCOVERED_CONTEXT` as a YAML block
98
+ - Mode: `--pre-plan-discovery`
99
+ - Spec path: `.jdi/framework/agents/jdi-researcher.md`
100
+ - Instruction: _"Scan the codebase for decision points relevant to this feature. Return RESEARCH_QUESTIONS YAML. Budget: <=15 file reads, <400 word report."_
101
+
102
+ Store the return as `RESEARCH_DISCOVERY`.
103
+
104
+ ### 4b. Pre-Planning Questions (Interactive Gate)
105
+
106
+ Execute `<JDI:InteractiveGate mode="pre-plan" />`:
107
+
108
+ 1. Collect surface-level ambiguity questions from the feature description
109
+ 2. Collect research-driven questions from `RESEARCH_DISCOVERY.research_questions`
110
+ 3. Merge, deduplicate, prioritise (research-driven first)
111
+ 4. If questions exist, present via `AskUserQuestion`. Wait for answers.
112
+ 5. If zero questions from both sources, skip silently.
113
+
114
+ Store answers as `PRE_ANSWERED_QUESTIONS`.
115
+
92
116
  ### 5. Spawn Planner
93
117
 
94
- Spawn `jdi-planner` via `Task(subagent_type="general-purpose")`. The spawn prompt MUST include:
118
+ Spawn `jdi-planner` via `Agent(subagent_type="general-purpose", mode="bypassPermissions")`. The spawn prompt MUST include:
95
119
 
96
120
  - The feature description (`$ARGUMENTS`)
97
121
  - `PRE_DISCOVERED_CONTEXT` as a YAML block — planner must NOT re-read scaffolding
98
122
  - `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."_
123
+ - `PRE_ANSWERED_QUESTIONS` YAML block (from step 4b, if any questions were asked)
124
+ - `RESEARCH_DISCOVERY.research_context` (so the planner doesn't re-scan what the researcher already found)
125
+ - Explicit instruction: _"Do NOT re-prompt the user for anything already in PRE_DISCOVERED_CONTEXT. These questions were already answered by the user — do NOT re-ask them. The research context below summarises what was found in the codebase — use it, don't re-scan. Only surface NEW questions that emerged during planning that could not have been anticipated."_
100
126
  - Spec path: `.jdi/framework/agents/jdi-planner.md`
101
127
 
102
128
  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.
@@ -114,7 +140,7 @@ If any check fails, STOP and report the gap to the user. Do not advance state on
114
140
 
115
141
  ### 7. Execute Deferred Ops
116
142
 
117
- If the planner returned `files_to_create` (scaffolding it could not write inside its sandbox), create those files now via the Write tool.
143
+ The planner creates files directly (it has `bypassPermissions`). If any `files_to_create` entries were returned, create them now via the Write tool as a fallback.
118
144
 
119
145
  ### 8. Update State
120
146
 
@@ -156,7 +182,9 @@ Pre-written responses for known deviations. When one applies, follow the scripte
156
182
  |-----------|----------|
157
183
  | 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
184
  | `.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. |
185
+ | Feature description is vague ("improve X") | Steps 4a + 4b handle this: the researcher discovers codebase decision points, and the InteractiveGate surfaces ambiguity questions via AskUserQuestion. Do not waste a planner invocation on an underspecified prompt. |
186
+ | Pre-plan researcher returns zero questions | Skip step 4b if surface-level analysis also yields zero questions. Proceed directly to step 5. This is expected for clear features. |
187
+ | Pre-plan researcher returns >4 questions | Batch into multiple AskUserQuestion calls (max 4 per call). Present highest-priority questions first. |
160
188
  | Worktree flag but worktree already exists | Ask the user: reuse the existing worktree, or pick a new name? Do not silently proceed. |
161
189
  | `--status` with no current plan | Output "No current plan — run `/jdi:create-plan \"<feature>\"` to create one" and STOP. |
162
190
  | Planner returns without writing any files | STOP, report the failure, do NOT advance state. Ask the user to re-invoke or debug. |
@@ -45,8 +45,9 @@ Run `gh pr list --head {current-branch}`. If a PR already exists for this branch
45
45
  Spawn the specialist via Task tool. JDI specialists spawn as `general-purpose` with identity injected via prompt text:
46
46
 
47
47
  ```
48
- Task(
48
+ Agent(
49
49
  subagent_type="general-purpose",
50
+ mode="bypassPermissions",
50
51
  prompt="You are jdi-pr-generator. Read .jdi/framework/agents/jdi-pr-generator.md
51
52
  for your full role and instructions. Also read
52
53
  .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: implement-plan
3
3
  description: "JDI: Execute implementation plan"
4
- allowed-tools: Read, Glob, Grep, Bash, Write, Edit, Task
4
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit, Task, AskUserQuestion
5
5
  argument-hint: "[--team | --single | --dry-run | --skip-qa]"
6
6
  context: |
7
7
  !cat .jdi/config/state.yaml 2>/dev/null | head -30
@@ -101,15 +101,17 @@ Run `bun run src/index.ts state executing` (in installed projects: `npx jdi stat
101
101
 
102
102
  ### 8. Spawn and Execute
103
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/jdi.md` Critical Constraints and `framework/components/meta/AgentRouter.md` §4.
104
+ **Platform constraints:**
105
+ - 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. Registered Claude Code subagents (`source: claude-code`) are spawned directly by name. See `framework/jdi.md` Critical Constraints.
106
+ - **All agents MUST be spawned with `mode: "bypassPermissions"`** — agents run in background and cannot prompt the user for Write/Edit approval. Without this mode, agents will be blocked on permission prompts and fail silently.
105
107
 
106
108
  **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
+ - `source: jdi` → `Agent(subagent_type="general-purpose", mode="bypassPermissions", prompt="You are {plan.primary_agent}. Read .jdi/framework/agents/{plan.primary_agent}.md... PLAN: {index-path}")`
110
+ - `source: claude-code` → `Agent(subagent_type="{plan.primary_agent}", mode="bypassPermissions", prompt="<standard spawn prompt> PLAN: {index-path}")`
109
111
 
110
112
  For split plans, the agent reads task files one at a time via the `file:` field in `state.yaml`.
111
113
 
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.
114
+ **Agent Teams mode:** Spawn ONE Agent call per task using the source-aware pattern above. Pass `TASK_FILE: {task-file-path}` so the agent loads only its assigned task. Every spawn MUST include `mode: "bypassPermissions"`.
113
115
 
114
116
  **Prompt scoping rules (non-negotiable):**
115
117
  - One task = one spawn. Never bundle multiple tasks into one prompt.
@@ -120,6 +122,27 @@ For split plans, the agent reads task files one at a time via the `file:` field
120
122
 
121
123
  **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
124
 
125
+ ### 8a. Blocker Resolution
126
+
127
+ When an agent returns `status: blocked`:
128
+
129
+ 1. Read the blocker context from the agent's structured return
130
+ (blocker_reason, blocker_context, suggested_options if any)
131
+ 2. Execute `<JDI:InteractiveGate mode="blocker-resolution" />`
132
+ 3. Present the blocker to the user via AskUserQuestion:
133
+ - header: "BLOCKED"
134
+ - question: "{task_name} is blocked: {blocker_reason}"
135
+ - options (pick 2-4 based on context):
136
+ a) Resolve with approach X (if agent suggested options)
137
+ b) Skip this task and continue
138
+ c) Modify the task scope
139
+ d) Halt the plan
140
+ 4. Route based on answer:
141
+ - Resolve: re-spawn the agent with the resolution context
142
+ - Skip: advance-task with skip status, continue to next
143
+ - Modify: enter inline edit of the task file, then re-spawn
144
+ - Halt: stop execution, enter review loop at step 14
145
+
123
146
  ### 9. Advance Task State
124
147
 
125
148
  After each task's programmer returns successfully, run:
@@ -141,7 +164,7 @@ After each task's programmer returns, invoke `jdi-qa-tester` in `post-task-verif
141
164
 
142
165
  ### 11. Execute Deferred Ops
143
166
 
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.
167
+ Agents create files directly (they have `bypassPermissions`), so `files_to_create` should be empty. If any agent does return `files_to_create` entries, create them via Write tool. Execute `commits_pending` via `git add` + `git commit`. Do NOT skip this step.
145
168
 
146
169
  ### 12. Run Verification Gates
147
170
 
@@ -185,7 +208,8 @@ Pre-written responses for known deviations. When one applies, follow the scripte
185
208
  | Plan status is not `approved` | STOP at step 2. Tell the user to approve the plan first. Do NOT force-advance. |
186
209
  | Pinned agent not installed | Downgrade to `general-purpose`, record the downgrade, continue. Surface in the final summary. |
187
210
  | 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. |
211
+ | Programmer returns with `status: blocked` | Enter step 8a (Blocker Resolution). Do NOT advance task state. Present the blocker interactively via AskUserQuestion and route based on user's choice. |
212
+ | Agent suggests resolution options in structured return | Include agent's suggestions as the first AskUserQuestion options in step 8a, before the default options (skip/modify/halt). |
189
213
  | QA verification S1 or S2 failure | HALT the plan immediately. Record the failure in state. Wait for user direction before continuing. |
190
214
  | Verification gate failure at step 12 | STOP before completing. Report the failure, enter review loop. Do NOT advance state to `complete`. |
191
215
  | `--dry-run` with no changes needed | Output "no-op: plan is already at target state" and STOP. |
@@ -32,8 +32,9 @@ Run `gh api repos/{owner}/{repo}/pulls/{number}/comments` (or equivalent) to con
32
32
  Spawn the specialist via Task tool. JDI specialists spawn as `general-purpose` with identity injected via prompt text:
33
33
 
34
34
  ```
35
- Task(
35
+ Agent(
36
36
  subagent_type="general-purpose",
37
+ mode="bypassPermissions",
37
38
  prompt="You are jdi-pr-feedback. Read .jdi/framework/agents/jdi-pr-feedback.md
38
39
  for your full role and instructions. Also read
39
40
  .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
@@ -42,8 +42,9 @@ Run `gh pr view {number}` to confirm the PR is reachable. If `gh` errors, STOP a
42
42
  Spawn the reviewer via Task tool. JDI specialists spawn as `general-purpose` with identity injected via prompt text:
43
43
 
44
44
  ```
45
- Task(
45
+ Agent(
46
46
  subagent_type="general-purpose",
47
+ mode="bypassPermissions",
47
48
  prompt="Read .jdi/framework/components/meta/AgentBase.md for the base protocol.
48
49
 
49
50
  Read learnings before reviewing — these represent the team's coding standards
@@ -55,47 +55,43 @@ Return a YAML block with `status`, agent-specific fields, and `next_action` afte
55
55
 
56
56
  <section name="Sandbox">
57
57
 
58
- ## Sandbox Awareness
58
+ ## File Operations
59
59
 
60
- You run in a sandboxed environment. Key constraints:
60
+ You are spawned with full file permissions (`mode: "bypassPermissions"`). All standard tools work:
61
61
 
62
- | Operation | Tool / Method | Persists? | Notes |
63
- |-----------|--------------|-----------|-------|
64
- | Edit existing files | Edit tool | **Yes** | Primary way to modify code |
65
- | Delete files | Bash `rm` | **Yes** | Destructive use with care |
66
- | Create new files | Write tool / Bash `cat >` | **No** | Silently fails report in `files_to_create` |
67
- | Git commits | Bash `git commit` | **No** | Silently fails — report in `commits_pending` |
68
- | Read files | Read tool | **Yes** | Works reliably |
69
- | Run commands | Bash tool | **Yes** | Output is real; side-effects vary |
62
+ | Operation | Tool / Method | Notes |
63
+ |-----------|--------------|-------|
64
+ | Edit existing files | Edit tool | Primary way to modify code |
65
+ | Create new files | Write tool | Workscreate files directly |
66
+ | Delete files | Bash `rm` | Destructiveuse with care |
67
+ | Read files | Read tool | Works reliably |
68
+ | Run commands | Bash tool | Output is real; side-effects vary |
70
69
 
71
70
  **Key Rules:**
72
- 1. **NEVER attempt `git commit`** — it will appear to succeed but produces no real commit.
73
- 2. **NEVER create new files** via Write tool or Bash redirection they will not persist.
74
- 3. **ALWAYS use the Edit tool** to modify existing files.
75
- 4. **Report pending work** in structured returns using `files_to_create` and `commits_pending`.
71
+ 1. **Use the Edit tool** to modify existing files (read first).
72
+ 2. **Use the Write tool** to create new files directlydo NOT defer to the orchestrator.
73
+ 3. **Do NOT run `git commit`** — the orchestrator handles commits after all tasks complete. Report commits needed in `commits_pending`.
76
74
 
77
- ### Structured Returns for Sandbox-Limited Operations
75
+ ### Structured Returns
78
76
 
79
77
  ```yaml
80
- files_to_create:
81
- - path: "path/to/new/file.md"
82
- content: |
83
- Full file content here...
84
78
  files_modified:
85
79
  - path/to/edited/file1.ts
80
+ files_created:
81
+ - path/to/new/file.md
86
82
  commits_pending:
87
83
  - message: |
88
84
  feat(01-01-T1): implement feature X
89
85
  files:
90
86
  - path/to/modified/file1.ts
87
+ - path/to/new/file.md
91
88
  ```
92
89
 
93
90
  ### Orchestrator Post-Agent Handling
94
91
 
95
- After a sandboxed agent completes, the orchestrator must:
96
- 1. Create files from `files_to_create` using Write tool
97
- 2. Execute commits from `commits_pending` via `git add` + `git commit`
98
- 3. Record real commit hashes in `.jdi/config/state.yaml`
92
+ After an agent completes, the orchestrator:
93
+ 1. Executes commits from `commits_pending` via `git add` + `git commit`
94
+ 2. Records real commit hashes in `.jdi/config/state.yaml`
99
95
 
100
96
  </section>
101
97
 
@@ -109,7 +105,7 @@ When operating within an Agent Team (spawned by coordinator):
109
105
 
110
106
  1. **Claim tasks**: Call TaskList, find tasks assigned to you
111
107
  2. **Execute**: Read task description, implement using Edit tool
112
- 3. **Report**: SendMessage to coordinator with structured return (include `files_modified`, `files_to_create`, `commits_pending`)
108
+ 3. **Report**: SendMessage to coordinator with structured return (include `files_modified`, `files_created`, `commits_pending`)
113
109
  4. **Complete**: TaskUpdate(status: "completed") AFTER sending results
114
110
  5. **Next**: Check TaskList for more assigned tasks. If none, go idle.
115
111
 
@@ -212,17 +212,20 @@ correct pattern for that source.
212
212
 
213
213
  ### Source-aware spawn pattern
214
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/` |
215
+ **All agents MUST be spawned with `mode: "bypassPermissions"`** so they can create and edit files without blocking on permission prompts. Agents run in background they cannot prompt the user for approval.
216
+
217
+ | `source` in catalogue | `subagent_type` | `mode` | Identity mechanism |
218
+ |----------------------|-----------------|--------|--------------------|
219
+ | `jdi` | `"general-purpose"` | `"bypassPermissions"` | Prompt text: `"You are {task.agent}. Read .jdi/framework/agents/{task.agent}.md for instructions."` |
220
+ | `claude-code` | `"{task.agent}"` | `"bypassPermissions"` | Native — Claude Code loads the agent spec from `.claude/agents/` |
219
221
 
220
222
  ### Single-agent mode
221
223
 
222
224
  ```
223
225
  # source: jdi (JDI framework specialist)
224
- Task(
226
+ Agent(
225
227
  subagent_type: "general-purpose",
228
+ mode: "bypassPermissions",
226
229
  name: "{plan.primary_agent}",
227
230
  prompt: "You are {plan.primary_agent}. Read .jdi/framework/agents/{plan.primary_agent}.md
228
231
  for your full role and instructions. Also read .jdi/framework/components/meta/AgentBase.md
@@ -232,8 +235,9 @@ Task(
232
235
  )
233
236
 
234
237
  # source: claude-code (user-added registered specialist)
235
- Task(
238
+ Agent(
236
239
  subagent_type: "{plan.primary_agent}", # e.g. unity-specialist
240
+ mode: "bypassPermissions",
237
241
  name: "{plan.primary_agent}",
238
242
  prompt: "<standard single-agent spawn prompt from ComplexityRouter>"
239
243
  )
@@ -246,21 +250,23 @@ fall back to `subagent_type="general-purpose"` with a `jdi-backend` /
246
250
  ### Agent-teams mode
247
251
 
248
252
  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
253
+ from the plan's `available_agents` catalogue. Spawn ONE Agent tool call per task
250
254
  using the pattern that matches its source (see table above).
251
255
 
252
256
  ```
253
257
  # JDI specialist (source: jdi)
254
- Task(
258
+ Agent(
255
259
  subagent_type: "general-purpose",
260
+ mode: "bypassPermissions",
256
261
  name: "{task.agent}-{task_id}",
257
262
  prompt: "You are {task.agent}. Read .jdi/framework/agents/{task.agent}.md for instructions.
258
263
  <spawn prompt from AgentTeamsOrchestration with TASK_FILE: {task file}>"
259
264
  )
260
265
 
261
266
  # Claude Code registered specialist (source: claude-code)
262
- Task(
267
+ Agent(
263
268
  subagent_type: "{task.agent}",
269
+ mode: "bypassPermissions",
264
270
  name: "{task.agent}-{task_id}",
265
271
  prompt: "<spawn prompt from AgentTeamsOrchestration with TASK_FILE: {task file}>"
266
272
  )
@@ -68,15 +68,15 @@ and the `agent_rationale` explaining why you were picked for this task).
68
68
  If TASK_FILE is not provided (legacy plan), claim tasks from TaskList and read
69
69
  task details from the PLAN file.
70
70
 
71
- 1. Implement using Edit tool
71
+ 1. Implement using Edit tool (existing files) and Write tool (new files)
72
72
  2. SendMessage to coordinator with structured return
73
73
  3. Mark task completed via TaskUpdate
74
74
 
75
- Report: files_modified, files_to_create, commits_pending.
75
+ Report: files_modified, files_created, commits_pending.
76
76
  No git commit (use commits_pending).
77
77
  ```
78
78
 
79
- Spawned via `Task(subagent_type="general-purpose", ...)` — see
79
+ Spawned via `Agent(subagent_type="general-purpose", mode="bypassPermissions", ...)` — see
80
80
  `.jdi/framework/jdi.md` Critical Constraints for why.
81
81
 
82
82
  ### `source: claude-code` — registered Claude Code subagent
@@ -89,21 +89,20 @@ Your agent definition has already been loaded by Claude Code from
89
89
  <same TEAM / PLAN / TASK_FILE / WORKING_DIR block + steps + report as above>
90
90
  ```
91
91
 
92
- Spawned via `Task(subagent_type="{task.agent}", ...)` — Claude Code validates
92
+ Spawned via `Agent(subagent_type="{task.agent}", mode="bypassPermissions", ...)` — Claude Code validates
93
93
  the subagent type against its registered list. See
94
94
  `.jdi/framework/components/meta/AgentRouter.md` §4 for full rules.
95
95
 
96
96
  ---
97
97
 
98
- ## Deferred Operations Checklist
98
+ ## Post-Agent Operations
99
99
 
100
100
  After all specialist tasks complete:
101
101
 
102
- 1. **Collect** — Aggregate `files_modified`, `files_to_create`, `commits_pending` from all SendMessage results
103
- 2. **Create files** — Write tool for each `files_to_create` entry
104
- 3. **Execute commits** — `git add` + `git commit` for each `commits_pending` entry
105
- 4. **Record hashes** — Store real commit hashes in state.yaml
106
- 5. **Verify** — Confirm all `files_modified` are present in working tree
102
+ 1. **Collect** — Aggregate `files_modified`, `files_created`, `commits_pending` from all SendMessage results
103
+ 2. **Execute commits** — `git add` + `git commit` for each `commits_pending` entry
104
+ 3. **Record hashes** — Store real commit hashes in state.yaml
105
+ 4. **Verify** — Confirm all `files_modified` and `files_created` are present in working tree
107
106
 
108
107
  ---
109
108
 
@@ -56,8 +56,9 @@ See `.jdi/framework/components/meta/AgentRouter.md` §4 for full spawn rules.
56
56
  ### JDI specialist (source: jdi — the common case)
57
57
 
58
58
  ```
59
- Task(
59
+ Agent(
60
60
  subagent_type: "general-purpose", # MUST be general-purpose for JDI agents
61
+ mode: "bypassPermissions", # REQUIRED: agents need file write permissions
61
62
  name: "{plan.primary_agent}",
62
63
  prompt: "You are {plan.primary_agent}. Read .jdi/framework/agents/{plan.primary_agent}.md
63
64
  for your full role and instructions. Also read
@@ -73,15 +74,16 @@ for your full role and instructions. Also read
73
74
  Execute all tasks in the plan sequentially. PLAN: {plan-path}.
74
75
  For split plans (task_files in frontmatter), read each task file one at a time
75
76
  from the file: field in state.yaml.
76
- Report: files_modified, files_to_create, commits_pending."
77
+ Report: files_modified, files_created, commits_pending."
77
78
  )
78
79
  ```
79
80
 
80
81
  ### Claude Code registered specialist (source: claude-code)
81
82
 
82
83
  ```
83
- Task(
84
+ Agent(
84
85
  subagent_type: "{plan.primary_agent}", # e.g. unity-specialist
86
+ mode: "bypassPermissions", # REQUIRED: agents need file write permissions
85
87
  name: "{plan.primary_agent}",
86
88
  prompt: "Your agent definition has already been loaded from .claude/agents/.
87
89
  Also read .jdi/framework/components/meta/AgentBase.md for the JDI base protocol.
@@ -0,0 +1,138 @@
1
+ # InteractiveGate Component
2
+
3
+ A reusable question gate that presents structured decisions to the user via `AskUserQuestion` before a phase transition. Questions are sourced from two channels: surface-level ambiguity detection and research-driven codebase analysis.
4
+
5
+ When a command references `<JDI:InteractiveGate mode="..." />`, execute the steps below. Do NOT skip the merge/dedup logic even if only one source produces questions.
6
+
7
+ ---
8
+
9
+ ## Modes
10
+
11
+ | Mode | When | Question Sources |
12
+ |------|------|-----------------|
13
+ | `pre-plan` | Before planner spawn in `create-plan` | Surface-level analysis of feature description + `RESEARCH_QUESTIONS` from pre-plan research spawn |
14
+ | `blocker-resolution` | During implementation when a task is blocked | Surface-level analysis of the blocker description + context from the blocking task |
15
+
16
+ ---
17
+
18
+ ## Question Sources
19
+
20
+ ### Surface-Level (Ambiguity Detection)
21
+
22
+ Analyse the feature description (or blocker description) for ambiguity signals:
23
+
24
+ - **Vague scope words** — "improve", "enhance", "refactor", "clean up", "optimise" without measurable targets
25
+ - **Missing tech stack specifics** — feature implies a technology choice but doesn't state one
26
+ - **Unclear boundaries** — "and more", "etc.", "various", "all the things"
27
+ - **Multiple possible approaches** — description could be solved in fundamentally different ways
28
+ - **Implicit assumptions** — feature assumes context the user hasn't stated
29
+
30
+ Generate questions only for genuine ambiguities. Do NOT manufacture questions for clear descriptions.
31
+
32
+ ### Research-Driven
33
+
34
+ Consume the `RESEARCH_QUESTIONS` YAML block produced by the pre-plan research spawn (or equivalent). These are decision points discovered by analysing the actual codebase:
35
+
36
+ - Competing patterns (e.g. two state management approaches in use)
37
+ - Missing data/fields the feature will need
38
+ - Architectural choices (where to place new code, which module to extend)
39
+ - Dependency/library choices
40
+ - Existing conventions that constrain the approach
41
+
42
+ Research-driven questions arrive pre-formatted with `id`, `question`, `header`, `options`, and `context`.
43
+
44
+ ---
45
+
46
+ ## Merge and Prioritise
47
+
48
+ 1. Collect surface-level questions (assign IDs `SQ-01`, `SQ-02`, ...)
49
+ 2. Collect research-driven questions (IDs `RQ-01`, `RQ-02`, ... from the researcher)
50
+ 3. Deduplicate: if a surface question covers the same decision as a research question, keep the research version (it has codebase-grounded options)
51
+ 4. Sort: research-driven questions first (higher signal), then surface-level
52
+ 5. Cap at a reasonable total — if more than 8 questions survive, drop the lowest-priority surface-level questions
53
+
54
+ ---
55
+
56
+ ## AskUserQuestion Format
57
+
58
+ Each question presented via `AskUserQuestion` must follow this structure:
59
+
60
+ - **`header`**: Short category tag — max 12 characters. Examples: `SCOPE`, `STACK`, `APPROACH`, `PATTERN`, `DATA`, `BOUNDARY`
61
+ - **`question`**: The actual question text. Clear, specific, and actionable.
62
+ - **`options`**: 2-4 options, each with:
63
+ - `label`: Short option name
64
+ - `description`: One-line explanation. For research-driven questions, ground this in what the researcher found in the codebase.
65
+ - **`multiSelect`**: Set to `true` only for non-mutually-exclusive choices. Default `false`.
66
+ - An automatic "Other" option is always available (built into the tool).
67
+
68
+ **Batching rule:** Maximum 4 questions per `AskUserQuestion` call (tool limit). If more than 4 questions survive merge, batch into multiple sequential calls. Present the highest-priority questions first.
69
+
70
+ ---
71
+
72
+ ## Output Format
73
+
74
+ Store all answers as `PRE_ANSWERED_QUESTIONS` in YAML:
75
+
76
+ ```yaml
77
+ PRE_ANSWERED_QUESTIONS:
78
+ - id: RQ-01
79
+ source: research
80
+ question: "The codebase uses both Redux and Zustand — which should this feature follow?"
81
+ chosen: "Use Zustand"
82
+ custom_text: null
83
+ - id: SQ-01
84
+ source: surface
85
+ question: "What does 'improve performance' mean concretely?"
86
+ chosen: "Reduce load time below 2s"
87
+ custom_text: "Specifically the dashboard page load"
88
+ ```
89
+
90
+ Fields:
91
+ - `id`: Question ID (`RQ-*` for research, `SQ-*` for surface)
92
+ - `source`: `research` or `surface`
93
+ - `question`: The question text (for downstream reference)
94
+ - `chosen`: The selected option label (or "Other" if custom)
95
+ - `custom_text`: User's free-text input if they chose "Other", otherwise `null`
96
+
97
+ ---
98
+
99
+ ## Skip Condition
100
+
101
+ If BOTH sources yield zero questions after analysis, skip the gate entirely. Do NOT present an empty AskUserQuestion call. Proceed directly to the next step in the parent workflow.
102
+
103
+ Log internally: `InteractiveGate: 0 questions from surface + 0 from research — skipping gate.`
104
+
105
+ ---
106
+
107
+ ## Fallback
108
+
109
+ If `AskUserQuestion` is not available (not in the skill's `allowed-tools` list), fall back to plain markdown:
110
+
111
+ ```
112
+ Before we proceed, I have a few questions:
113
+
114
+ 1. **[PATTERN]** The codebase uses both X and Y for Z — which should this feature follow?
115
+ - A) Use X — consistent with src/foo/ (newer pattern)
116
+ - B) Use Y — consistent with src/bar/ (legacy pattern)
117
+ - C) Other (please specify)
118
+
119
+ 2. **[SCOPE]** What does "improve" mean concretely?
120
+ - A) Reduce load time below 2s
121
+ - B) Reduce memory usage
122
+ - C) Other (please specify)
123
+
124
+ Please respond with your choices (e.g. "1A, 2B") or provide details.
125
+ ```
126
+
127
+ Parse the user's response and populate `PRE_ANSWERED_QUESTIONS` accordingly.
128
+
129
+ ---
130
+
131
+ ## Usage
132
+
133
+ ```
134
+ <JDI:InteractiveGate mode="pre-plan" />
135
+ <JDI:InteractiveGate mode="blocker-resolution" />
136
+ ```
137
+
138
+ Referenced within a skill's numbered workflow steps. Requires that question sources (surface analysis input and/or `RESEARCH_QUESTIONS` block) are available in the execution context before invocation.
package/framework/jdi.md CHANGED
@@ -35,22 +35,30 @@ model: opus
35
35
 
36
36
  ### Correct Pattern
37
37
 
38
- Agent identity is passed via the **prompt parameter**, NOT the `subagent_type` parameter:
38
+ Agent identity is passed via the **prompt parameter**, NOT the `subagent_type` parameter.
39
+ **Permission mode** MUST be `"bypassPermissions"` so agents can create and edit files without blocking on approval prompts.
39
40
 
40
41
  ```
41
- Task(
42
+ Agent(
42
43
  prompt="You are jdi-programmer. Read .jdi/framework/agents/jdi-programmer.md for instructions. Execute: {task}",
43
- subagent_type="general-purpose" ← MUST be "general-purpose"
44
+ subagent_type="general-purpose", ← MUST be "general-purpose"
45
+ mode="bypassPermissions" ← REQUIRED: agents need file write permissions
44
46
  )
45
47
  ```
46
48
 
47
- ### Incorrect Pattern (WILL FAIL)
49
+ ### Incorrect Patterns (WILL FAIL)
48
50
 
49
51
  ```
50
- Task(
52
+ Agent(
51
53
  prompt="Execute the plan...",
52
54
  subagent_type="jdi-programmer" ← WRONG: Causes classifyHandoffIfNeeded error
53
55
  )
56
+
57
+ Agent(
58
+ prompt="Execute the plan...",
59
+ subagent_type="general-purpose"
60
+ # mode omitted ← WRONG: Agent blocked on Write/Edit permissions
61
+ )
54
62
  ```
55
63
 
56
64
  ### Why This Matters
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benzotti/jdi",
3
- "version": "0.1.46",
3
+ "version": "0.1.49",
4
4
  "description": "JDI - Context-efficient AI development framework for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {