opencode-mad 0.4.0 → 1.0.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mad-workflow
3
- description: Multi-Agent Dev workflow for parallel development with git worktrees and subagents
3
+ description: Multi-Agent Dev workflow for parallel development with git worktrees and specialized agents
4
4
  license: MIT
5
5
  compatibility: opencode
6
6
  metadata:
@@ -10,16 +10,75 @@ metadata:
10
10
 
11
11
  # MAD Workflow
12
12
 
13
- MAD (Multi-Agent Dev) enables parallel software development by decomposing tasks into independent subtasks, each running in isolated git worktrees with dedicated subagents.
13
+ MAD (Multi-Agent Dev) enables parallel software development by decomposing tasks into independent subtasks, each running in isolated git worktrees with dedicated specialized agents.
14
+
15
+ ## Architecture Overview
16
+
17
+ ```
18
+ USER REQUEST
19
+ |
20
+ v
21
+ +-------------------+
22
+ | ORCHESTRATOR | <- Coordinator (never codes)
23
+ +-------------------+
24
+ |
25
+ +-------------------+-------------------+
26
+ | |
27
+ v v
28
+ +-------------+ +-------------+
29
+ | ANALYSTE | -- analysis report --> | ARCHITECTE |
30
+ +-------------+ +-------------+
31
+ |
32
+ v
33
+ Development Plan
34
+ |
35
+ +-------------------+-------------------+
36
+ | | |
37
+ v v v
38
+ +-----------+ +-----------+ +-----------+
39
+ | DEVELOPER | | DEVELOPER | | DEVELOPER |
40
+ | worktree1 | | worktree2 | | worktree3 |
41
+ +-----------+ +-----------+ +-----------+
42
+ | | |
43
+ +-------------------+-------------------+
44
+ |
45
+ +-----------------------------+-----------------------------+
46
+ | | |
47
+ v v v
48
+ +----------+ +----------+ +----------+
49
+ | TESTER | | REVIEWER | | SECURITY |
50
+ +----------+ +----------+ +----------+
51
+ | | |
52
+ +-----------------------------+-----------------------------+
53
+ |
54
+ v
55
+ +----------+
56
+ | MERGER | (if conflicts)
57
+ +----------+
58
+ |
59
+ v
60
+ +----------+
61
+ | FIXER | (if issues)
62
+ +----------+
63
+ ```
14
64
 
15
65
  ## Core Concepts
16
66
 
17
67
  ### Worktrees
18
68
  Git worktrees provide isolated working directories, each on its own branch. This allows multiple tasks to be developed simultaneously without conflicts.
19
69
 
20
- ### Subagents
21
- - **mad-developer**: Implements a single focused task in a worktree
22
- - **mad-fixer**: Resolves build errors, test failures, and conflicts
70
+ ### Specialized Agents
71
+
72
+ | Agent | Role | Responsibility |
73
+ |-------|------|----------------|
74
+ | **mad-analyste** | Analysis | Understands codebase, finds relevant code, identifies patterns |
75
+ | **mad-architecte** | Planning | Creates task breakdown, file ownership, API contracts |
76
+ | **mad-developer** | Implementation | Writes code in isolated worktrees |
77
+ | **mad-tester** | Testing | Runs tests, verifies functionality |
78
+ | **mad-reviewer** | Code Review | Checks quality, patterns, best practices |
79
+ | **mad-security** | Security | Audits for vulnerabilities, injection risks |
80
+ | **mad-fixer** | Bug Fixing | Fixes errors, test failures, review issues |
81
+ | **mad-merger** | Conflicts | Resolves git merge conflicts |
23
82
 
24
83
  ### Signal Files
25
84
  - `.agent-task`: Task description (created by orchestrator)
@@ -27,13 +86,53 @@ Git worktrees provide isolated working directories, each on its own branch. This
27
86
  - `.agent-blocked`: Block marker with reason
28
87
  - `.agent-error`: Error details from failed tests
29
88
 
30
- ## Workflow Steps
89
+ ## Workflow Phases
90
+
91
+ ### Phase 1: Analysis
92
+ The Orchestrator spawns an Analyste to understand the codebase:
93
+ - Project structure and technologies
94
+ - Relevant existing code
95
+ - Dependencies and patterns
96
+ - Potential impact areas
97
+
98
+ ### Phase 2: Planning
99
+ The Orchestrator spawns an Architecte to create the plan:
100
+ - Task breakdown with clear boundaries
101
+ - File ownership (CRITICAL: no overlaps!)
102
+ - API contracts between components
103
+ - Merge order recommendation
104
+
105
+ ### Phase 3: User Approval
106
+ The Orchestrator presents the plan and waits for "GO".
107
+
108
+ ### Phase 4: Development
109
+ The Orchestrator:
110
+ 1. Creates worktrees with `mad_worktree_create`
111
+ 2. Registers permissions with `mad_register_agent`
112
+ 3. Spawns Developers in parallel
113
+
114
+ ### Phase 5: Quality Assurance
115
+ The Orchestrator spawns in parallel:
116
+ - Testers (run tests)
117
+ - Reviewers (check code quality)
118
+ - Security (audit vulnerabilities)
119
+
120
+ ### Phase 6: Resolution
121
+ If issues found:
122
+ - Spawn Fixer for bugs/review issues
123
+ - Spawn Merger for conflicts
124
+
125
+ ### Phase 7: Finalization
126
+ - Merge all branches
127
+ - Run `mad_final_check`
128
+ - Push with `mad_push_and_watch`
129
+ - Cleanup worktrees
31
130
 
32
131
  ## CRITICAL: Parallel Execution is MANDATORY
33
132
 
34
- The entire purpose of MAD is to run tasks IN PARALLEL.
133
+ The entire purpose of MAD is to run tasks IN PARALLEL.
35
134
 
36
- ### WRONG - Sequential (defeats the purpose)
135
+ ### WRONG - Sequential (defeats the purpose)
37
136
  ```
38
137
  Message 1: mad_worktree_create(branch: "feat-a", ...)
39
138
  Message 2: mad_worktree_create(branch: "feat-b", ...)
@@ -41,7 +140,7 @@ Message 3: Task(subagent_type: "mad-developer", ...) for feat-a
41
140
  Message 4: Task(subagent_type: "mad-developer", ...) for feat-b
42
141
  ```
43
142
 
44
- ### CORRECT - Parallel (the whole point!)
143
+ ### CORRECT - Parallel (the whole point!)
45
144
  ```
46
145
  Single Message containing:
47
146
  mad_worktree_create(branch: "feat-a", ...)
@@ -50,112 +149,106 @@ Single Message containing:
50
149
 
51
150
  Single Message containing:
52
151
  Task(subagent_type: "mad-developer", ...) for feat-a
53
- Task(subagent_type: "mad-developer", ...) for feat-b
152
+ Task(subagent_type: "mad-developer", ...) for feat-b
54
153
  Task(subagent_type: "mad-developer", ...) for feat-c
55
154
  ```
56
155
 
57
156
  If you're not parallelizing, you're not using MAD correctly!
58
157
 
59
- ### 1. Decomposition
60
- Analyze the request and identify parallelizable components:
61
- - Different modules/features
62
- - Independent files
63
- - Separable concerns
158
+ ## File Ownership Rules
64
159
 
65
- ### 2. Worktree Creation
66
- For each subtask:
67
- ```
68
- mad_worktree_create(
69
- branch: "feat/feature-name",
70
- task: "Detailed task description"
71
- )
72
- ```
73
-
74
- ### 3. Parallel Execution
75
- Spawn subagents simultaneously:
76
- ```
77
- Task(subagent_type: "mad-developer", ...)
78
- Task(subagent_type: "mad-developer", ...)
79
- Task(subagent_type: "mad-developer", ...)
80
- ```
160
+ Each task MUST have exclusive ownership. Two agents must NEVER modify the same file.
81
161
 
82
- ### 4. Monitoring
83
- Check progress:
162
+ **Good:**
84
163
  ```
85
- mad_status()
164
+ Task 1: OWNS /backend/**
165
+ Task 2: OWNS /frontend/**
166
+ Task 3: OWNS /package.json, /README.md
86
167
  ```
87
168
 
88
- ### 5. Testing
89
- Verify each worktree:
169
+ **Bad:**
90
170
  ```
91
- mad_test(worktree: "feat-feature-name")
171
+ Task 1: "Create login page"
172
+ Task 2: "Create signup page"
173
+ # BAD! Both might create /frontend/index.html
92
174
  ```
93
175
 
94
- ### 6. Merging
95
- Merge completed work:
96
- ```
97
- mad_merge(worktree: "feat-feature-name")
98
- ```
99
-
100
- > **Note:** `mad_merge` automatically uses `--no-ff` to preserve history. If you ever need to merge manually, always use `git merge --no-ff`.
101
-
102
- ### 7. Cleanup
103
- Remove finished worktrees:
104
- ```
105
- mad_cleanup(worktree: "feat-feature-name")
106
- ```
107
-
108
- ### 8. Final Check
109
- Verify global project health:
110
- ```
111
- mad_final_check()
112
- ```
113
- This distinguishes session errors from pre-existing issues.
114
-
115
- ### 9. Push & CI Watch
116
- Push to remote and monitor CI:
117
- ```
118
- mad_push_and_watch()
119
- ```
120
- This will:
121
- - Push changes to the remote
122
- - Detect if GitHub Actions CI exists
123
- - Watch CI progress in real-time with `gh run watch`
124
- - Report success or failure with logs
125
-
126
- If CI fails, create a `fix-ci` worktree to fix the errors.
127
-
128
- ## Best Practices
129
-
130
- 1. **Keep subtasks focused** - Each should be completable in one session
131
- 2. **Name branches clearly** - `feat/`, `fix/`, `refactor/` prefixes
132
- 3. **Test before merge** - Always run mad_test first
133
- 4. **Handle blocks promptly** - Don't let blocked tasks linger
134
- 5. **Merge sequentially** - Avoid merge conflict cascades
135
- 6. **Always use `--no-ff` for merges** - Preserves feature history and enables easy reverts
136
-
137
176
  ## Available Tools
138
177
 
139
178
  | Tool | Purpose |
140
179
  |------|---------|
141
180
  | `mad_worktree_create` | Create isolated branch |
142
181
  | `mad_status` | Dashboard of all worktrees |
182
+ | `mad_visualize` | ASCII art visualization |
143
183
  | `mad_test` | Run tests on worktree |
144
184
  | `mad_merge` | Merge completed branch |
145
185
  | `mad_cleanup` | Remove worktree |
146
186
  | `mad_done` | Mark task complete |
147
187
  | `mad_blocked` | Mark task blocked |
148
188
  | `mad_read_task` | Read task description |
189
+ | `mad_register_agent` | Register agent permissions |
149
190
  | `mad_final_check` | Run global build/lint and categorize errors |
150
191
  | `mad_push_and_watch` | Push to remote and watch CI |
151
192
 
152
- ## Example
193
+ > **Note:** `mad_merge` automatically uses `--no-ff` to preserve history. If you ever need to merge manually, always use `git merge --no-ff`.
194
+
195
+ ## Example Session
153
196
 
154
197
  Request: "Add user authentication with login, signup, and password reset"
155
198
 
156
- 1. Create 3 worktrees: `feat/auth-login`, `feat/auth-signup`, `feat/auth-reset`
157
- 2. Spawn 3 developer subagents in parallel
158
- 3. Monitor until all complete
159
- 4. Test each, merge sequentially
160
- 5. Cleanup worktrees
161
- 6. Final integration test
199
+ ### 1. Analysis Phase
200
+ ```
201
+ Task(subagent_type: "mad-analyste", ...)
202
+ -> Returns: "Project uses Express + React, auth should go in /backend/auth/** and /frontend/auth/**"
203
+ ```
204
+
205
+ ### 2. Planning Phase
206
+ ```
207
+ Task(subagent_type: "mad-architecte", ...)
208
+ -> Returns plan with 3 tasks:
209
+ - feat-auth-backend: OWNS /backend/auth/**
210
+ - feat-auth-frontend: OWNS /frontend/auth/**
211
+ - feat-auth-config: OWNS /config/auth.js
212
+ ```
213
+
214
+ ### 3. Development Phase
215
+ ```
216
+ mad_worktree_create(branch: "feat-auth-backend", ...)
217
+ mad_worktree_create(branch: "feat-auth-frontend", ...)
218
+ mad_worktree_create(branch: "feat-auth-config", ...)
219
+
220
+ mad_register_agent(sessionID: "...", agentType: "developer", allowedPaths: ["/backend/auth/**"], ...)
221
+ Task(subagent_type: "mad-developer", ...) for backend
222
+ Task(subagent_type: "mad-developer", ...) for frontend
223
+ Task(subagent_type: "mad-developer", ...) for config
224
+ ```
225
+
226
+ ### 4. Quality Phase
227
+ ```
228
+ Task(subagent_type: "mad-tester", ...) for each worktree
229
+ Task(subagent_type: "mad-reviewer", ...) for each worktree
230
+ Task(subagent_type: "mad-security", ...) for each worktree
231
+ ```
232
+
233
+ ### 5. Finalization
234
+ ```
235
+ mad_merge(worktree: "feat-auth-config")
236
+ mad_merge(worktree: "feat-auth-backend")
237
+ mad_merge(worktree: "feat-auth-frontend")
238
+ mad_final_check()
239
+ mad_push_and_watch()
240
+ mad_cleanup(worktree: "feat-auth-backend")
241
+ mad_cleanup(worktree: "feat-auth-frontend")
242
+ mad_cleanup(worktree: "feat-auth-config")
243
+ ```
244
+
245
+ ## Best Practices
246
+
247
+ 1. **Delegate everything** - Orchestrator coordinates, never codes
248
+ 2. **Keep subtasks focused** - Each should be completable in one session
249
+ 3. **Name branches clearly** - `feat/`, `fix/`, `refactor/` prefixes
250
+ 4. **Test before merge** - Always run quality checks first
251
+ 5. **Handle blocks promptly** - Don't let blocked tasks linger
252
+ 6. **Merge sequentially** - Avoid merge conflict cascades
253
+ 7. **Always use `--no-ff` for merges** - Preserves feature history and enables easy reverts
254
+ 8. **Register permissions** - Use `mad_register_agent` before spawning developers