@benzotti/jedi 0.1.0

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 (83) hide show
  1. package/README.md +615 -0
  2. package/dist/index.js +10514 -0
  3. package/framework/adapters/generic.yaml +23 -0
  4. package/framework/adapters/laravel.yaml +46 -0
  5. package/framework/adapters/nextjs.yaml +36 -0
  6. package/framework/adapters/node.yaml +29 -0
  7. package/framework/agents/jdi-architect.md +118 -0
  8. package/framework/agents/jdi-backend.md +52 -0
  9. package/framework/agents/jdi-codebase-mapper.md +59 -0
  10. package/framework/agents/jdi-committer.md +83 -0
  11. package/framework/agents/jdi-debugger.md +73 -0
  12. package/framework/agents/jdi-devops.md +46 -0
  13. package/framework/agents/jdi-executor.md +89 -0
  14. package/framework/agents/jdi-feedback-learner.md +92 -0
  15. package/framework/agents/jdi-frontend.md +51 -0
  16. package/framework/agents/jdi-head-engineering.md +30 -0
  17. package/framework/agents/jdi-phase-researcher.md +59 -0
  18. package/framework/agents/jdi-plan-checker.md +80 -0
  19. package/framework/agents/jdi-planner.md +140 -0
  20. package/framework/agents/jdi-pr-feedback.md +118 -0
  21. package/framework/agents/jdi-pr-generator.md +80 -0
  22. package/framework/agents/jdi-product-lead.md +44 -0
  23. package/framework/agents/jdi-quality.md +77 -0
  24. package/framework/agents/jdi-researcher.md +70 -0
  25. package/framework/agents/jdi-ux-designer.md +40 -0
  26. package/framework/agents/jdi-verifier.md +80 -0
  27. package/framework/commands/commit.md +20 -0
  28. package/framework/commands/create-plan.md +32 -0
  29. package/framework/commands/generate-pr.md +19 -0
  30. package/framework/commands/implement-plan.md +34 -0
  31. package/framework/commands/init.md +65 -0
  32. package/framework/commands/pr-feedback.md +20 -0
  33. package/framework/commands/pr-review.md +15 -0
  34. package/framework/commands/quick.md +17 -0
  35. package/framework/commands/status.md +13 -0
  36. package/framework/commands/worktree-remove.md +32 -0
  37. package/framework/commands/worktree.md +52 -0
  38. package/framework/components/execution/CodebaseContext.md +36 -0
  39. package/framework/components/execution/Commit.md +121 -0
  40. package/framework/components/execution/Verify.md +140 -0
  41. package/framework/components/execution/VerifyAdvanced.md +43 -0
  42. package/framework/components/meta/AgentBase.md +108 -0
  43. package/framework/components/meta/AgentTeamsOrchestration.md +71 -0
  44. package/framework/components/meta/ComplexityRouter.md +80 -0
  45. package/framework/components/meta/StateUpdate.md +191 -0
  46. package/framework/components/meta/TeamRouter.md +86 -0
  47. package/framework/components/planning/TaskBreakdown.md +83 -0
  48. package/framework/components/planning/WaveComputation.md +59 -0
  49. package/framework/components/quality/PRReview.md +196 -0
  50. package/framework/components/quality/PRReviewLocal.md +99 -0
  51. package/framework/config/jdi-config.yaml +159 -0
  52. package/framework/config/state.yaml +72 -0
  53. package/framework/config/variables.yaml +43 -0
  54. package/framework/hooks/checkpoint.md +196 -0
  55. package/framework/hooks/jdi-worktree-cleanup.md +123 -0
  56. package/framework/hooks/lint-fix-frontend.md +59 -0
  57. package/framework/hooks/on-pause.md +213 -0
  58. package/framework/hooks/pre-commit.md +143 -0
  59. package/framework/jedi.md +336 -0
  60. package/framework/learnings/backend.md +3 -0
  61. package/framework/learnings/devops.md +3 -0
  62. package/framework/learnings/frontend.md +3 -0
  63. package/framework/learnings/general.md +3 -0
  64. package/framework/learnings/testing.md +3 -0
  65. package/framework/rules/commit-rules.md +24 -0
  66. package/framework/rules/deviation-rules.md +221 -0
  67. package/framework/teams/devops.md +26 -0
  68. package/framework/teams/engineering.md +29 -0
  69. package/framework/teams/micro-management.md +26 -0
  70. package/framework/teams/product-research.md +29 -0
  71. package/framework/teams/quality-assurance.md +27 -0
  72. package/framework/templates/PLAN-TASK.md +28 -0
  73. package/framework/templates/PLAN.md +127 -0
  74. package/framework/templates/PROJECT.md +104 -0
  75. package/framework/templates/PROJECT.yaml +16 -0
  76. package/framework/templates/REQUIREMENTS.md +95 -0
  77. package/framework/templates/REQUIREMENTS.yaml +27 -0
  78. package/framework/templates/ROADMAP.md +116 -0
  79. package/framework/templates/ROADMAP.yaml +24 -0
  80. package/framework/templates/STATE.md +137 -0
  81. package/framework/templates/SUMMARY.md +201 -0
  82. package/framework/workflows/README.md +87 -0
  83. package/package.json +35 -0
@@ -0,0 +1,36 @@
1
+ # CodebaseContext Component
2
+
3
+ Cache-first codebase context loading. Reads existing analysis — never spawns mapper automatically.
4
+
5
+ ---
6
+
7
+ ## Cache-First Loading
8
+
9
+ 1. If `.jdi/codebase/SUMMARY.md` exists → **read it directly** (regardless of age)
10
+ 2. If `.jdi/codebase/CONVENTIONS.md` exists → read it when writing code
11
+ 3. If neither exists → **inform user** to run `/jdi:map-codebase` first, then proceed without codebase context
12
+
13
+ **Never spawn codebase mapper automatically.** The mapper is expensive (~30% of session budget). Only run it via explicit `/jdi:map-codebase` command.
14
+
15
+ **Skip entirely if:** `--skip-codebase` flag is present in command arguments.
16
+
17
+ ---
18
+
19
+ ## Context Files
20
+
21
+ | File | Purpose | When to Read |
22
+ |------|---------|--------------|
23
+ | `.jdi/codebase/SUMMARY.md` | Architecture overview, file locations, tech stack | Always (if exists) |
24
+ | `.jdi/codebase/CONVENTIONS.md` | Coding standards (mapper output only) | When writing code (if exists) |
25
+ | `.claude/rules/*.md` | Auto-loaded patterns (no explicit read needed) | Automatic |
26
+ | `.jdi/config/state.yaml` | Current phase, plan, position | Always |
27
+
28
+ ---
29
+
30
+ ## Usage in Commands
31
+
32
+ ```
33
+ <JDI:CodebaseContext />
34
+ ```
35
+
36
+ This component reads cached context files. If no codebase analysis exists, it proceeds without it — agents can still analyse relevant source files directly.
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: Commit
3
+ category: execution
4
+ description: Create atomic commits with proper formatting and state tracking
5
+ params:
6
+ - name: scope
7
+ type: string
8
+ required: false
9
+ default: "task"
10
+ options: ["task", "plan", "phase", "docs", "fix"]
11
+ description: What level of work is being committed
12
+ - name: type
13
+ type: string
14
+ required: false
15
+ default: null
16
+ options: ["feat", "fix", "refactor", "docs", "test", "chore", "perf", "style"]
17
+ description: Override commit type (auto-detected if not provided)
18
+ - name: files
19
+ type: array
20
+ required: false
21
+ default: null
22
+ description: Specific files to stage (auto-detected if not provided)
23
+ ---
24
+
25
+ # Commit
26
+
27
+ Create an atomic commit with proper formatting, staging, and state tracking.
28
+
29
+ ---
30
+
31
+ ## Default Behaviour
32
+
33
+ When invoked as `<JDI:Commit />`:
34
+
35
+ 1. **Check for changes** — `git status --porcelain`. If none, skip.
36
+
37
+ 2. **Identify modified files** — Parse git status, group by change type.
38
+
39
+ 3. **Determine commit type** — `feat` (new), `fix` (bug), `refactor` (cleanup), `docs` (documentation), `test` (tests). Override with `type` param.
40
+
41
+ 4. **Stage files individually**
42
+ ```bash
43
+ git add path/to/file1
44
+ git add path/to/file2
45
+ ```
46
+ **NEVER** use `git add .` or `git add -A`
47
+
48
+ **EXCLUDED DIRECTORIES** (never stage):
49
+ - `.worktrees/**` — Git worktrees
50
+ - `.jdi/**` — JDI runtime state
51
+
52
+ ```bash
53
+ if [[ "$file" == .worktrees/* ]] || [[ "$file" == .jdi/* ]]; then
54
+ echo "SKIP (excluded): $file"
55
+ continue
56
+ fi
57
+ ```
58
+
59
+ 5. **Create commit message** — Use <JDI:Commit:MessageFormat />
60
+
61
+ 6. **Execute commit**
62
+ ```bash
63
+ git commit -m "$(cat <<'EOF'
64
+ {message}
65
+ EOF
66
+ )"
67
+ ```
68
+
69
+ 7. **Record commit hash** — `git rev-parse --short HEAD`
70
+
71
+ 8. **Update state** — Add commit to `state.yaml` session_commits array.
72
+
73
+ ---
74
+
75
+ <section name="MessageFormat">
76
+
77
+ ## Message Format
78
+
79
+ ```
80
+ {type}({scope}): {description}
81
+
82
+ - {change 1}
83
+ - {change 2}
84
+ - {change 3}
85
+ ```
86
+
87
+ ### Type Selection
88
+
89
+ | Type | When to Use |
90
+ |------|-------------|
91
+ | `feat` | New feature, endpoint, component |
92
+ | `fix` | Bug fix, error correction |
93
+ | `test` | Test-only changes |
94
+ | `refactor` | Code cleanup, no behaviour change |
95
+ | `perf` | Performance improvement |
96
+ | `docs` | Documentation changes |
97
+ | `style` | Formatting, linting fixes |
98
+ | `chore` | Config, tooling, dependencies |
99
+
100
+ ### Rules
101
+ - **Scope**: In a plan: `{phase}-{plan}` (e.g., `01-02`). Standalone: feature name or file area.
102
+ - **Description**: Imperative mood, no capital start, no period, max 72 chars.
103
+ - **Body**: 3-5 bullet points of WHAT changed.
104
+
105
+ </section>
106
+
107
+ ---
108
+
109
+ ## Scope Reference
110
+
111
+ | Scope | Message Format |
112
+ |-------|----------------|
113
+ | `task` | `{type}({phase}-{plan}): task {N} - {desc}` |
114
+ | `plan` | `docs({phase}-{plan}): complete {plan-name}` |
115
+ | `phase` | `docs({phase}): complete {phase-name}` |
116
+ | `docs` | `docs: {description}` |
117
+ | `fix` | `fix: {description}` |
118
+
119
+ ## State Updates
120
+
121
+ After commit: append to `commits.session_commits` in state.yaml, update `last_commit_hash`. Append to `implementation.files_modified` in variables.yaml.
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: Verify
3
+ category: execution
4
+ description: Verify completion of tasks, plans, phases, or requirements
5
+ params:
6
+ - name: scope
7
+ type: string
8
+ required: false
9
+ options: ["task", "plan", "phase", "requirements"]
10
+ default: "task"
11
+ description: What level to verify
12
+ - name: strict
13
+ type: boolean
14
+ required: false
15
+ default: false
16
+ description: Fail on any unmet criteria (vs warn)
17
+ - name: include_tests
18
+ type: boolean
19
+ required: false
20
+ default: true
21
+ description: Run tests as part of verification
22
+ ---
23
+
24
+ # Verify
25
+
26
+ Verify completion of work at various levels of granularity.
27
+
28
+ ---
29
+
30
+ ## Default Behaviour
31
+
32
+ When invoked as `<JDI:Verify />`:
33
+
34
+ 1. **Determine scope** — Check current position from state.yaml, default to task-level
35
+ 2. **Load verification criteria** — task: PLAN.md verification section; plan: PLAN.md success_criteria; phase: ROADMAP.yaml must_haves
36
+ 3. **Execute verification** — Run each check, record pass/fail
37
+ 4. **Report results** — Output summary, update state
38
+
39
+ ---
40
+
41
+ <section name="Task">
42
+
43
+ ## Task Verification (`scope="task"`)
44
+
45
+ 1. **Load task verification criteria** from PLAN.md `**Verification:**` checklist
46
+ 2. **Execute each check**: file existence, code patterns, test gates (see TestRunner), manual inspection
47
+ 3. **Load done criteria** from `**Done when:**`
48
+ 4. **Report result**:
49
+ ```markdown
50
+ ## Task Verification: Task {N}
51
+ **Status:** PASS | FAIL
52
+
53
+ ### Verification Checks
54
+ - [x] {check 1} - PASS
55
+ - [ ] {check 2} - FAIL: {reason}
56
+
57
+ ### Done Criteria
58
+ - [x] {criterion} - Met
59
+
60
+ ### Issues
61
+ - {issue description if any}
62
+ ```
63
+
64
+ </section>
65
+
66
+ ---
67
+
68
+ <section name="Plan">
69
+
70
+ ## Plan Verification (`scope="plan"`)
71
+
72
+ 1. **Verify all tasks complete** — check status and commits
73
+ 2. **Load plan success criteria** from `<success_criteria>` block
74
+ 3. **Execute plan-level checks** — test suite, lint/type errors, integration points
75
+ 4. **Generate SUMMARY.md preview** — draft with deviations
76
+ 5. **Report result**:
77
+ ```markdown
78
+ ## Plan Verification: {phase}-{plan}
79
+ **Status:** PASS | FAIL
80
+
81
+ ### Task Completion
82
+ - [x] Task 1: {name} - {commit}
83
+
84
+ ### Success Criteria
85
+ - [x] {criterion 1} - Met
86
+ - [ ] {criterion 2} - NOT MET: {reason}
87
+
88
+ ### Tests
89
+ - Suite: {test suite} | Result: {pass/fail} | Coverage: {percentage}
90
+
91
+ ### Ready for SUMMARY.md: YES | NO
92
+ ```
93
+
94
+ </section>
95
+
96
+ ---
97
+
98
+ ## Advanced Verification (Phase & Requirements)
99
+
100
+ For `scope="phase"` or `scope="requirements"`, load `<JDI:VerifyAdvanced />`.
101
+
102
+ ---
103
+
104
+ <section name="TestRunner">
105
+
106
+ ## Test Execution (`include_tests="true"`)
107
+
108
+ 1. **Detect changed files**
109
+ ```bash
110
+ # Task-level
111
+ git diff --cached --name-only
112
+ git diff --name-only
113
+ # Plan-level
114
+ git diff master --name-only
115
+ ```
116
+
117
+ 2. **Backend test gate (MANDATORY if ANY `*.php` files changed)**
118
+ ```bash
119
+ composer test
120
+ ```
121
+ If fails: verification FAILS. Do not proceed. Fix tests first.
122
+
123
+ 3. **Frontend tests (if `*.ts`, `*.tsx`, `*.js`, `*.jsx` changed)**
124
+ ```bash
125
+ bun run test:vitest
126
+ ```
127
+
128
+ 4. **Parse results** — total, passed, failed, skipped, coverage
129
+
130
+ 5. **Report**: For each stack (Backend/Frontend), include: ran (yes/no), command, result, counts, and any failed test details.
131
+
132
+ </section>
133
+
134
+ ---
135
+
136
+ ## State Updates
137
+
138
+ After verification, set `position.status` to `verified` or `verification_failed`. If gaps found, add to `blockers` array with `type: verification_gap`.
139
+
140
+ Gap severity: Critical (goal blocked → closure plan), High (requirement unmet → targeted fix), Medium (partially met → note), Low (enhancement → document).
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: VerifyAdvanced
3
+ category: execution
4
+ description: Advanced verification for phase and requirements scope
5
+ ---
6
+
7
+ # VerifyAdvanced
8
+
9
+ Lazy-loaded verification for `scope="phase"` and `scope="requirements"`. See `<JDI:Verify />` for task and plan verification.
10
+
11
+ ---
12
+
13
+ <section name="Phase">
14
+
15
+ ## Phase Verification
16
+
17
+ When `scope="phase"`:
18
+
19
+ 1. **Verify all plans complete** — Check SUMMARY.md exists for each plan, verify success criteria met
20
+ 2. **Load phase must_haves from ROADMAP.yaml**
21
+ 3. **Verify against codebase (not claims)** — Actually check the codebase, run the functionality
22
+ 4. **Create VERIFICATION.md** with must-haves status table, plans completed, gaps found, human verification needed
23
+ 5. **Route by status:**
24
+ - `PASSED` → Continue to next phase
25
+ - `GAPS_FOUND` → Create gap closure plans
26
+ - `HUMAN_NEEDED` → Present checklist to user
27
+
28
+ </section>
29
+
30
+ ---
31
+
32
+ <section name="Requirements">
33
+
34
+ ## Requirements Verification
35
+
36
+ When `scope="requirements"`:
37
+
38
+ 1. **Load REQUIREMENTS.yaml** — Get all v1 requirements with REQ-IDs
39
+ 2. **For each requirement** — Find which phase/plan claimed to implement it, verify implementation exists, check acceptance criteria
40
+ 3. **Cross-reference evidence** — Link to test files, code implementing the requirement, note partial implementations
41
+ 4. **Generate report** with total/verified/failed/not-implemented counts, verification results table, failed requirements details, recommendations
42
+
43
+ </section>
@@ -0,0 +1,108 @@
1
+ # AgentBase Component
2
+
3
+ Standards inherited by all JDI agents via `<JDI:AgentBase />`. Default loads Core only.
4
+
5
+ ## Standards
6
+
7
+ - Use **Australian English** spelling in all outputs.
8
+ - Follow `CLAUDE.md` and `.claude/rules/` conventions.
9
+ - Read `.jdi/config/state.yaml` once at task start — update `position`, `progress`, `current_plan` fields via `<JDI:StateUpdate />`.
10
+ - Use the Read tool before editing any file.
11
+ - Batch file reads: issue all Read calls in a single turn rather than sequentially.
12
+ - Batch git operations: combine related commands into a single Bash call where possible.
13
+
14
+ ## Component Resolution
15
+
16
+ When a spec contains `<JDI:*>` tags:
17
+ 1. Read the file from `.jdi/framework/components/` (execution/, planning/, quality/, meta/).
18
+ 2. If a section is specified (`<JDI:X:Section />`), execute only that section.
19
+ 3. Apply tag parameters as constraints. Return to agent spec and continue.
20
+
21
+ If your spec has a `requires_components` frontmatter field, read ALL listed components before starting execution.
22
+
23
+ Do NOT skip `<JDI:*>` tags — they contain essential instructions.
24
+
25
+ ## Activation Protocol
26
+
27
+ On activation, announce and begin immediately:
28
+ ```
29
+ You are now active as {agent-name}. {Action verb} as requested.
30
+ ```
31
+
32
+ ## Structured Returns
33
+
34
+ Return a YAML block with `status`, agent-specific fields, and `next_action` after all work is complete.
35
+
36
+ ## Boundaries
37
+
38
+ - **Will Do**: Actions within agent responsibility. Prioritise these.
39
+ - **Will Not**: Actions outside scope. Delegate or escalate, never attempt.
40
+
41
+ ---
42
+
43
+ <section name="Sandbox">
44
+
45
+ ## Sandbox Awareness
46
+
47
+ You run in a sandboxed environment. Key constraints:
48
+
49
+ | Operation | Tool / Method | Persists? | Notes |
50
+ |-----------|--------------|-----------|-------|
51
+ | Edit existing files | Edit tool | **Yes** | Primary way to modify code |
52
+ | Delete files | Bash `rm` | **Yes** | Destructive — use with care |
53
+ | Create new files | Write tool / Bash `cat >` | **No** | Silently fails — report in `files_to_create` |
54
+ | Git commits | Bash `git commit` | **No** | Silently fails — report in `commits_pending` |
55
+ | Read files | Read tool | **Yes** | Works reliably |
56
+ | Run commands | Bash tool | **Yes** | Output is real; side-effects vary |
57
+
58
+ **Key Rules:**
59
+ 1. **NEVER attempt `git commit`** — it will appear to succeed but produces no real commit.
60
+ 2. **NEVER create new files** via Write tool or Bash redirection — they will not persist.
61
+ 3. **ALWAYS use the Edit tool** to modify existing files.
62
+ 4. **Report pending work** in structured returns using `files_to_create` and `commits_pending`.
63
+
64
+ ### Structured Returns for Sandbox-Limited Operations
65
+
66
+ ```yaml
67
+ files_to_create:
68
+ - path: "path/to/new/file.md"
69
+ content: |
70
+ Full file content here...
71
+ files_modified:
72
+ - path/to/edited/file1.ts
73
+ commits_pending:
74
+ - message: |
75
+ feat(01-01-T1): implement feature X
76
+ files:
77
+ - path/to/modified/file1.ts
78
+ ```
79
+
80
+ ### Orchestrator Post-Agent Handling
81
+
82
+ After a sandboxed agent completes, the orchestrator must:
83
+ 1. Create files from `files_to_create` using Write tool
84
+ 2. Execute commits from `commits_pending` via `git add` + `git commit`
85
+ 3. Record real commit hashes in `.jdi/config/state.yaml`
86
+
87
+ </section>
88
+
89
+ ---
90
+
91
+ <section name="TeamMode">
92
+
93
+ ## Communication (Team Mode)
94
+
95
+ When operating within an Agent Team (spawned by coordinator):
96
+
97
+ 1. **Claim tasks**: Call TaskList, find tasks assigned to you
98
+ 2. **Execute**: Read task description, implement using Edit tool
99
+ 3. **Report**: SendMessage to coordinator with structured return (include `files_modified`, `files_to_create`, `commits_pending`)
100
+ 4. **Complete**: TaskUpdate(status: "completed") AFTER sending results
101
+ 5. **Next**: Check TaskList for more assigned tasks. If none, go idle.
102
+
103
+ **Team Mode Rules:**
104
+ - NEVER write to state.yaml (coordinator handles this)
105
+ - ALWAYS SendMessage results to coordinator before TaskUpdate(completed)
106
+ - Use **SendMessage** to communicate — plain text is not visible to teammates.
107
+
108
+ </section>
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: AgentTeamsOrchestration
3
+ category: meta
4
+ description: Agent Teams orchestration quick-reference
5
+ ---
6
+
7
+ # AgentTeamsOrchestration
8
+
9
+ ## Core Pattern (6 Steps)
10
+
11
+ 1. **Pre-flight** — Read command spec, `<JDI:CodebaseContext />`, read state.yaml, set status to "executing"
12
+ 2. **Create Team** — `TeamCreate(team_name: "{team-name}")`
13
+ 3. **Create Tasks** — TaskCreate per work unit, set `addBlockedBy` dependencies
14
+ 4. **Spawn Teammates** — Task tool with `subagent_type: "general-purpose"`. Include in prompt: agent spec path, team context, task assignments
15
+ 5. **Coordinate** — Automatic message delivery for results, TaskList to monitor, SendMessage to guide/unblock
16
+ 6. **Cleanup** — shutdown_request to all → TeamDelete → set status "complete" → report
17
+
18
+ ---
19
+
20
+ ## Task Routing Table
21
+
22
+ | Task Stack | Agent(s) | Spawn Count |
23
+ |-----------|----------|-------------|
24
+ | PHP only | jdi-backend | 1 |
25
+ | TS/React only | jdi-frontend | 1 |
26
+ | Full-stack | jdi-backend + jdi-frontend | 2 |
27
+ | Config/docs | jdi-backend (default) | 1 |
28
+
29
+ ---
30
+
31
+ ## Specialist Spawn Prompt Template (~200 tokens)
32
+
33
+ ```
34
+ You are {agent-name}. Read .jdi/framework/agents/{spec}.md and .jdi/framework/components/meta/AgentBase.md.
35
+
36
+ TEAM: {team-name}
37
+ PLAN: {plan-path}
38
+ TASK_FILE: {task-file-path}
39
+ WORKING_DIR: {working-directory}
40
+
41
+ Read your TASK_FILE for task details (objective, files, steps, verification).
42
+ If TASK_FILE is not provided (legacy plan), claim tasks from TaskList and read task details from the PLAN file.
43
+
44
+ 1. Implement using Edit tool
45
+ 2. SendMessage to coordinator with structured return
46
+ 3. Mark task completed via TaskUpdate
47
+
48
+ Report: files_modified, files_to_create, commits_pending.
49
+ No git commit (use commits_pending).
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Deferred Operations Checklist
55
+
56
+ After all specialist tasks complete:
57
+
58
+ 1. **Collect** — Aggregate `files_modified`, `files_to_create`, `commits_pending` from all SendMessage results
59
+ 2. **Create files** — Write tool for each `files_to_create` entry
60
+ 3. **Execute commits** — `git add` + `git commit` for each `commits_pending` entry
61
+ 4. **Record hashes** — Store real commit hashes in state.yaml
62
+ 5. **Verify** — Confirm all `files_modified` are present in working tree
63
+
64
+ ---
65
+
66
+ ## Team Lifecycle
67
+
68
+ ```
69
+ TeamCreate → Spawn agents → Monitor (auto message delivery) →
70
+ Collect results → Deferred ops → shutdown_request → TeamDelete
71
+ ```
@@ -0,0 +1,80 @@
1
+ # ComplexityRouter Component
2
+
3
+ Evaluates plan complexity and returns the routing decision for implement-plan.
4
+
5
+ ---
6
+
7
+ ## Decision Matrix
8
+
9
+ Read the plan index file (frontmatter + task manifest table) and extract these signals:
10
+
11
+ | Signal | Simple | Complex |
12
+ |--------|--------|---------|
13
+ | Task count | ≤3 | >3 |
14
+ | Tech stacks | Single (PHP-only OR TS-only) | Mixed (PHP + TS/React) |
15
+ | Wave count | 1 (all tasks parallel or sequential) | >1 (multi-wave dependencies) |
16
+
17
+ **Routing rule:** If ANY signal is "Complex" → use Agent Teams mode. All signals must be "Simple" for single-agent mode.
18
+
19
+ **Override flags:**
20
+ - `--team` in command arguments → force Agent Teams mode
21
+ - `--single` in command arguments → force single-agent mode
22
+
23
+ ---
24
+
25
+ ## Output
26
+
27
+ After evaluation, set the routing decision:
28
+
29
+ ```yaml
30
+ mode: single-agent | agent-teams
31
+ primary_agent: jdi-backend | jdi-frontend # based on tech stack
32
+ secondary_agents: [] # only populated in agent-teams mode
33
+ reasoning: "{why this mode was chosen}"
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Single-Agent Mode
39
+
40
+ Spawn one specialist agent directly via Task tool. Follow cache-optimised load order (AgentBase first):
41
+
42
+ ```
43
+ Task(
44
+ subagent_type: "general-purpose",
45
+ name: "{primary_agent}",
46
+ prompt: "Read .jdi/framework/components/meta/AgentBase.md for the base protocol.
47
+ You are {primary_agent}. Read .jdi/framework/agents/{primary_agent}.md for your spec.
48
+ If your spec has requires_components in frontmatter, batch-read all listed components before starting.
49
+
50
+ ## Project Context
51
+ - Type: {project_type}
52
+ - Tech stack: {tech_stack}
53
+ - Quality gates: {quality_gates}
54
+ - Working directory: {cwd}
55
+
56
+ ## Task
57
+ Execute all tasks in the plan sequentially. PLAN: {plan-path}.
58
+ For split plans (task_files in frontmatter), read each task file one at a time from the file: field in state.yaml.
59
+ Report: files_modified, files_to_create, commits_pending."
60
+ )
61
+ ```
62
+
63
+ No TeamCreate, no TaskCreate, no cross-agent coordination.
64
+
65
+ ---
66
+
67
+ ## Agent Teams Mode
68
+
69
+ Follow full orchestration from `.jdi/framework/components/meta/AgentTeamsOrchestration.md`:
70
+ TeamCreate → TaskCreate per plan task → spawn specialists per tech-stack routing → wave-based coordination → collect deferred ops → shutdown → TeamDelete.
71
+
72
+ ---
73
+
74
+ ## Usage
75
+
76
+ ```
77
+ <JDI:ComplexityRouter />
78
+ ```
79
+
80
+ Referenced by implement-plan command stub. Evaluates at orchestration time, before any agents are spawned.