create-merlin-brain 3.8.0-beta.1 → 3.8.0-beta.3

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.
@@ -305,6 +305,39 @@ Activated by: "get shit done", "Merlin mode", "move fast", "just build it", "shi
305
305
 
306
306
  ---
307
307
 
308
+ ## Proactive Workflow Suggestions
309
+
310
+ When a user's task matches a workflow pattern, **suggest it as option [1]** before routing manually.
311
+ Users don't need to know commands exist — Merlin surfaces them.
312
+
313
+ | User intent | Suggest |
314
+ |---|---|
315
+ | "build [feature]", "add [feature]" | `/merlin:workflow run feature-dev "..."` |
316
+ | "build the whole thing", "full product", "end to end" | `/merlin:workflow run product-dev "..."` |
317
+ | "fix [bug]", "broken", "not working", "crash" | `/merlin:workflow run bug-fix "..."` |
318
+ | "security", "audit", "vulnerabilities", "pen test" | `/merlin:workflow run security-audit` |
319
+ | "refactor", "cleanup", "tech debt", "organize" | `/merlin:workflow run refactor "..."` |
320
+ | "build UI", "frontend", "components", "design" | `/merlin:workflow run ui-build "..."` |
321
+ | "build API", "endpoints", "REST", "backend" | `/merlin:workflow run api-build "..."` |
322
+ | "idea", "from scratch", "spec first", "greenfield" | `/merlin:workflow run spec-to-code "..."` |
323
+ | Complex multi-step, migration, unusual pipeline | `/merlin:workflow create "..."` |
324
+
325
+ **Suggestion format:**
326
+ ```
327
+ 🔮 This looks like a great fit for an automated workflow:
328
+
329
+ [1] Run **feature-dev** workflow (automated 7-step pipeline)
330
+ [2] Route to specialist for quick manual work
331
+ [3] Plan as a phase first
332
+ ```
333
+
334
+ **When NOT to suggest workflows:**
335
+ - Task is trivially small (one file, few lines)
336
+ - User explicitly says "just do it" or "quick fix"
337
+ - Already inside a workflow run
338
+
339
+ ---
340
+
308
341
  ## Anti-Patterns (NEVER Do These)
309
342
 
310
343
  - **Never** run `claude --agent` via Bash — it FAILS inside Claude Code sessions. Use `Skill("merlin:route")` instead
@@ -306,6 +306,51 @@ See what's changed since your installed version.
306
306
 
307
307
  Usage: `/merlin:whats-new`
308
308
 
309
+ ## Automated Workflows
310
+
311
+ Workflows are named pipelines that chain specialist agents through a fixed sequence.
312
+ Each step spawns a fresh Claude process with 200K context.
313
+
314
+ **`/merlin:workflow list`** — See all available workflows
315
+ **`/merlin:workflow run <id> "<task>"`** — Execute a workflow
316
+ **`/merlin:workflow create "<goal>"`** — Generate a custom workflow from a goal description
317
+ **`/merlin:workflow status`** — Check current run progress
318
+ **`/merlin:workflow resume`** — Resume an interrupted workflow
319
+ **`/merlin:workflow skip`** — Skip current step and advance
320
+
321
+ ### Bundled Workflows
322
+
323
+ | Workflow | Steps | Description |
324
+ |----------|-------|-------------|
325
+ | `feature-dev` | 7 | Drop in a feature request. Get back a tested PR. |
326
+ | `bug-fix` | 6 | Report a bug. Get back a fix with regression test and PR. |
327
+ | `security-audit` | 6 | Run a full security sweep. Get fixes and a clean report. |
328
+ | `refactor` | 6 | Analyze, plan, refactor, verify, test, and PR. |
329
+ | `product-dev` | 7 | Describe a product idea. Get back a fully built, tested feature. |
330
+ | `ui-build` | 7 | Describe a UI. Get back designed, built, tested components. |
331
+ | `api-build` | 7 | Describe an API. Get back designed, validated, tested endpoints. |
332
+ | `spec-to-code` | 7 | Start from an idea. Get back specced, architected, tested code. |
333
+
334
+ ### Dynamic Workflow Creation
335
+
336
+ Don't see a workflow that fits? Generate one:
337
+ ```
338
+ /merlin:workflow create "Migrate from MongoDB to PostgreSQL with zero downtime"
339
+ ```
340
+
341
+ Merlin uses Claude to design a custom pipeline with the right specialist agents.
342
+
343
+ ### Terminal Usage
344
+
345
+ Workflows also run outside Claude Code via the loop:
346
+ ```bash
347
+ merlin-loop workflow list
348
+ merlin-loop workflow run feature-dev "Add OAuth login"
349
+ merlin-loop workflow create "Set up CI/CD pipeline"
350
+ merlin-loop workflow status
351
+ merlin-loop workflow resume
352
+ ```
353
+
309
354
  ## Files & Structure
310
355
 
311
356
  ```
@@ -1,23 +1,32 @@
1
1
  ---
2
2
  name: merlin:update
3
3
  description: Update Merlin to latest version with changelog display
4
+ argument-hint: "[--beta | --stable]"
4
5
  ---
5
6
 
6
7
  <objective>
7
8
  Check for Merlin updates, install if available, and display what changed.
8
9
 
9
- Provides a better update experience than raw `npx create-merlin-brain` by showing version diff and changelog entries.
10
+ Supports two channels:
11
+ - **stable** (default) — production-ready releases via `npx create-merlin-brain@latest`
12
+ - **beta** — cutting-edge features via `npx create-merlin-brain@beta`
13
+
14
+ Provides a better update experience than raw `npx` by showing version diff, channel info, and changelog.
10
15
  </objective>
11
16
 
12
17
  <process>
13
18
 
14
19
  <step name="get_installed_version">
15
- Read installed version:
20
+ Read installed version and detect current channel:
16
21
 
17
22
  ```bash
18
23
  cat ~/.claude/merlin/VERSION 2>/dev/null
19
24
  ```
20
25
 
26
+ **Detect channel from version string:**
27
+ - Contains `-beta` → user is on the **beta** channel
28
+ - No prerelease suffix → user is on the **stable** channel
29
+
21
30
  **If VERSION file missing:**
22
31
  ```
23
32
  ## Merlin Update
@@ -32,56 +41,78 @@ Running fresh install...
32
41
  Proceed to install step (treat as version 0.0.0 for comparison).
33
42
  </step>
34
43
 
35
- <step name="check_latest_version">
36
- Check npm for latest version:
44
+ <step name="check_available_versions">
45
+ Check npm for both channels:
37
46
 
38
47
  ```bash
39
- npm view create-merlin-brain version 2>/dev/null
48
+ npm view create-merlin-brain dist-tags --json 2>/dev/null
49
+ ```
50
+
51
+ This returns something like:
52
+ ```json
53
+ {"latest": "3.7.3", "beta": "3.8.0-beta.1"}
40
54
  ```
41
55
 
56
+ If `--beta` flag in $ARGUMENTS: target the beta channel.
57
+ If `--stable` flag in $ARGUMENTS: target the stable channel.
58
+ If no flag: target whichever channel the user is currently on (detected from VERSION).
59
+
42
60
  **If npm check fails:**
43
61
  ```
44
62
  Couldn't check for updates (offline or npm unavailable).
45
63
 
46
- To update manually: `npx create-merlin-brain@latest`
64
+ To update manually:
65
+ Stable: npx create-merlin-brain@latest
66
+ Beta: npx create-merlin-brain@beta
47
67
  ```
48
68
 
49
69
  STOP here if npm unavailable.
50
70
  </step>
51
71
 
52
- <step name="compare_versions">
53
- Compare installed vs latest:
72
+ <step name="display_status">
73
+ Show a clear version dashboard:
54
74
 
55
- **If installed == latest:**
56
75
  ```
57
- ## Merlin Update
76
+ ## Merlin Version Status
58
77
 
59
- **Installed:** X.Y.Z
60
- **Latest:** X.Y.Z
78
+ **Installed:** 3.8.0-beta.1 (beta channel)
61
79
 
62
- You're already on the latest version.
63
- ```
80
+ **Available:**
81
+ stable 3.7.3 ← production-ready
82
+ beta 3.8.0-beta.1 ← cutting-edge (you are here)
64
83
 
65
- STOP here if already up to date.
84
+ **Beta includes (not in stable):**
85
+ • Workflow Engine — predefined multi-agent pipelines
86
+ /merlin:workflow run feature-dev "Add OAuth login"
87
+ • 4 bundled workflows: feature-dev, bug-fix, security-audit, refactor
88
+ • CLI: merlin-loop workflow [list|run|status|resume|skip]
89
+ ```
66
90
 
67
- **If installed > latest:**
91
+ **If installed matches target channel's latest:**
68
92
  ```
69
- ## Merlin Update
93
+ You're on the latest [channel] version.
94
+ ```
95
+ STOP here if already up to date.
96
+ </step>
70
97
 
71
- **Installed:** X.Y.Z
72
- **Latest:** A.B.C
98
+ <step name="confirm_and_update">
99
+ If update available, ask user to confirm:
73
100
 
74
- You're ahead of the latest release (development version?).
75
101
  ```
102
+ Update available: X.Y.Z → A.B.C (channel)
76
103
 
77
- STOP here if ahead.
78
- </step>
79
-
80
- <step name="run_update">
81
- Run the update:
104
+ [1] Update now
105
+ [2] Switch to [other channel] instead
106
+ [3] Skip
107
+ ```
82
108
 
109
+ Run the update based on choice:
83
110
  ```bash
111
+ # For stable:
84
112
  npx create-merlin-brain@latest
113
+
114
+ # For beta:
115
+ npx create-merlin-brain@beta
85
116
  ```
86
117
 
87
118
  Capture output. If install fails, show error and STOP.
@@ -101,59 +132,43 @@ cat ~/.claude/merlin/CHANGELOG.md 2>/dev/null
101
132
  ```
102
133
  </step>
103
134
 
104
- <step name="extract_changes">
105
- From the changelog, extract entries between:
106
- - **From:** installed version (exclusive)
107
- - **To:** latest version (inclusive)
108
-
109
- Parse each `## [X.Y.Z]` section and collect all versions in the range.
110
- </step>
111
-
112
135
  <step name="display_result">
113
- Format beautiful output:
136
+ Format output:
114
137
 
115
138
  ```
116
- Merlin Updated: v1.5.10 -> v3.0.0
139
+ Merlin Updated: v3.7.3 v3.8.0-beta.1 (beta)
117
140
 
118
141
  What's New
119
142
  ------------------------------------------------------------
120
143
 
121
- ## [3.0.0] - 2026-02-07
122
-
123
- ### Changed
124
- - BREAKING: All agent routing now uses fresh process isolation
125
- - Every specialist gets fresh 200K context via `claude --agent -p`
126
- - Task() removed entirely — deterministic handoff protocol
127
- - Two modes: interactive (default) and automated
144
+ ## [3.8.0-beta.0] - 2026-02-21
128
145
 
129
- ## [2.x.x] - ...
130
-
131
- ### Fixed
132
- - ...
146
+ ### Added
147
+ - Workflow Engine — predefined multi-agent pipelines
148
+ - 4 bundled workflows: feature-dev, bug-fix, security-audit, refactor
149
+ - /merlin:workflow skill command
150
+ - merlin-loop workflow CLI integration
133
151
 
134
152
  ------------------------------------------------------------
135
153
 
136
154
  Restart Claude Code to pick up the new commands.
137
-
138
- [View full changelog](https://github.com/sandman66666/merlin/blob/main/CHANGELOG.md)
139
155
  ```
140
156
 
141
157
  **Key elements:**
142
- - Version transition header
158
+ - Version transition header with channel
143
159
  - All changelog entries in the range
144
160
  - **BREAKING:** changes surfaced prominently
145
- - Restart reminder (critical for picking up new commands)
146
- - Link to full changelog
161
+ - Restart reminder
147
162
  </step>
148
163
 
149
164
  </process>
150
165
 
151
166
  <success_criteria>
152
- - [ ] Installed version read correctly
153
- - [ ] Latest version checked via npm
154
- - [ ] Update skipped if already current
167
+ - [ ] Installed version and channel detected correctly
168
+ - [ ] Both stable and beta versions checked via npm
169
+ - [ ] Channel-aware update (beta stays on beta, stable stays on stable)
170
+ - [ ] User can switch channels with --beta / --stable flags
155
171
  - [ ] Update executed successfully
156
- - [ ] Changelog fetched (remote or local fallback)
157
- - [ ] Changes between versions displayed
172
+ - [ ] Changelog displayed
158
173
  - [ ] Restart reminder shown
159
174
  </success_criteria>
@@ -4,9 +4,10 @@ description: See what's new in Merlin since your installed version
4
4
  ---
5
5
 
6
6
  <objective>
7
- Display changes between installed version and latest available version.
7
+ Display your installed version, current channel (stable vs beta), what's available,
8
+ and what the beta channel offers over stable.
8
9
 
9
- Shows version comparison, changelog entries for missed versions, and update instructions.
10
+ Quick version check no installs, just info.
10
11
  </objective>
11
12
 
12
13
  <process>
@@ -18,6 +19,10 @@ Read installed version from VERSION file:
18
19
  cat ~/.claude/merlin/VERSION 2>/dev/null
19
20
  ```
20
21
 
22
+ **Detect channel from version string:**
23
+ - Contains `-beta` → **beta** channel
24
+ - No prerelease suffix → **stable** channel
25
+
21
26
  **If VERSION file missing:**
22
27
  ```
23
28
  ## Merlin What's New
@@ -27,98 +32,120 @@ cat ~/.claude/merlin/VERSION 2>/dev/null
27
32
  Your installation doesn't include version tracking.
28
33
 
29
34
  **To fix:** `npx create-merlin-brain@latest`
30
-
31
- This will reinstall with version tracking enabled.
32
35
  ```
33
36
 
34
37
  STOP here if no VERSION file.
35
38
  </step>
36
39
 
37
- <step name="fetch_remote_changelog">
38
- Fetch latest CHANGELOG.md from GitHub:
39
-
40
- Use WebFetch tool with:
41
- - URL: `https://raw.githubusercontent.com/sandman66666/merlin/main/CHANGELOG.md`
42
- - Prompt: "Extract all version entries with their dates and changes. Return in Keep-a-Changelog format."
40
+ <step name="check_available_versions">
41
+ Check npm for all dist-tags:
43
42
 
44
- **If fetch fails:**
45
- Fall back to local changelog:
46
43
  ```bash
47
- cat ~/.claude/merlin/CHANGELOG.md 2>/dev/null
44
+ npm view create-merlin-brain dist-tags --json 2>/dev/null
48
45
  ```
49
46
 
50
- Note to user: "Couldn't check for updates (offline or GitHub unavailable). Showing local changelog."
47
+ **If npm check fails:**
48
+ Show installed version only with offline note.
51
49
  </step>
52
50
 
53
- <step name="parse_versions">
54
- From the remote (or local) changelog:
51
+ <step name="display_dashboard">
52
+ Show a clear version dashboard:
55
53
 
56
- 1. **Extract latest version** - First `## [X.Y.Z]` line after `## [Unreleased]`
57
- 2. **Compare with installed** - From VERSION file
58
- 3. **Extract entries between** - All version sections from latest down to (but not including) installed
54
+ ```
55
+ ## Merlin Version Status
59
56
 
60
- **Version comparison:**
61
- - If installed == latest: "You're on the latest version"
62
- - If installed < latest: Show changes since installed version
63
- - If installed > latest: "You're ahead of latest release (development version?)"
64
- </step>
57
+ **Installed:** 3.8.0-beta.1
58
+ **Channel:** beta
65
59
 
66
- <step name="display_output">
67
- Format output clearly:
60
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
68
61
 
69
- **If up to date:**
62
+ **Available versions:**
63
+ stable 3.7.3 npx create-merlin-brain@latest
64
+ beta 3.8.0-beta.1 ← npx create-merlin-brain@beta
65
+
66
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
70
67
  ```
71
- ## Merlin What's New
72
68
 
73
- **Installed:** 1.4.26
74
- **Latest:** 1.4.26
69
+ Then show what's different between channels.
70
+ </step>
75
71
 
76
- You're on the latest version.
72
+ <step name="show_beta_features">
73
+ **Always show what beta has that stable doesn't:**
77
74
 
78
- [View full changelog](https://github.com/sandman66666/merlin/blob/main/CHANGELOG.md)
79
75
  ```
80
-
81
- **If updates available:**
76
+ ## What's in Beta (not in stable)
77
+
78
+ ### Workflow Engine (3.8.0-beta)
79
+ Predefined multi-agent pipelines that chain specialist agents automatically.
80
+
81
+ **4 bundled workflows:**
82
+ - `feature-dev` — 7-step pipeline: plan → setup → implement → verify → test → PR → review
83
+ - `bug-fix` — 6-step pipeline: triage → investigate → fix → regression-test → verify → PR
84
+ - `security-audit` — 6-step pipeline: scan → prioritize → fix → verify → test → PR
85
+ - `refactor` — 6-step pipeline: analyze → plan → refactor → verify → test → PR
86
+
87
+ **How to use:**
88
+ /merlin:workflow list — see available workflows
89
+ /merlin:workflow run feature-dev "Add X" — run a complete pipeline
90
+ /merlin:workflow status — check progress
91
+ /merlin:workflow resume — resume after interruption
92
+
93
+ **CLI (outside Claude Code):**
94
+ merlin-loop workflow list
95
+ merlin-loop workflow run feature-dev "Add OAuth login"
96
+
97
+ Each step spawns a fresh Claude process with 200K context.
98
+ Uses blend engine for optimal agent selection per step.
99
+ Structured handoffs pass context between steps automatically.
82
100
  ```
83
- ## Merlin What's New
84
-
85
- **Installed:** 1.4.23
86
- **Latest:** 1.4.26
87
-
88
- ---
101
+ </step>
89
102
 
90
- ### Changes since your version:
103
+ <step name="show_update_instructions">
104
+ Based on current state:
91
105
 
92
- ## [1.4.26] - 2026-01-20
106
+ **If on stable, beta available:**
107
+ ```
108
+ **Want to try beta?**
109
+ npx create-merlin-brain@beta
93
110
 
94
- ### Added
95
- - Feature X
96
- - Feature Y
111
+ **Stay on stable (just update):**
112
+ /merlin:update
113
+ ```
97
114
 
98
- ### Changed
99
- - **BREAKING:** Changed Z behavior
115
+ **If on beta, update available:**
116
+ ```
117
+ **Update beta:**
118
+ npx create-merlin-brain@beta
100
119
 
101
- ## [1.4.25] - 2026-01-18
120
+ **Switch to stable:**
121
+ npx create-merlin-brain@latest
122
+ ```
102
123
 
103
- ### Fixed
104
- - Bug in feature A
124
+ **If on latest of current channel:**
125
+ ```
126
+ You're on the latest [channel] version.
127
+ ```
128
+ </step>
105
129
 
106
- ---
130
+ <step name="fetch_changelog">
131
+ Optionally fetch remote changelog for detailed version history:
107
132
 
108
- [View full changelog](https://github.com/sandman66666/merlin/blob/main/CHANGELOG.md)
133
+ Use WebFetch tool with:
134
+ - URL: `https://raw.githubusercontent.com/sandman66666/merlin/main/CHANGELOG.md`
135
+ - Prompt: "Extract all version entries with their dates and changes. Return in Keep-a-Changelog format."
109
136
 
110
- **To update:** `npx create-merlin-brain@latest`
111
- ```
137
+ **If fetch fails:** Skip this step (dashboard is sufficient).
112
138
 
113
- **Breaking changes:** Surface prominently with **BREAKING:** prefix in the output.
139
+ Show entries between installed version and latest only if there are missed versions.
114
140
  </step>
115
141
 
116
142
  </process>
117
143
 
118
144
  <success_criteria>
119
145
  - [ ] Installed version read from VERSION file
120
- - [ ] Remote changelog fetched (or graceful fallback to local)
121
- - [ ] Version comparison displayed clearly
122
- - [ ] Changes since installed version shown (if any)
123
- - [ ] Update instructions provided when behind
146
+ - [ ] Channel correctly detected (stable vs beta)
147
+ - [ ] Both available versions shown (stable + beta)
148
+ - [ ] Beta features described clearly
149
+ - [ ] Install/switch instructions provided
150
+ - [ ] Works gracefully offline (shows installed info only)
124
151
  </success_criteria>
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: merlin:workflow
3
3
  description: Run predefined multi-agent workflows (feature-dev, bug-fix, security-audit, refactor)
4
- argument-hint: "[list | run <id> \"<task>\" | status | resume | skip]"
4
+ argument-hint: "[list | run <id> \"<task>\" | create \"<goal>\" | status | resume | skip]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Glob
@@ -38,7 +38,7 @@ between steps, and independent verification for high-stakes steps.
38
38
  ## Step 1: Parse Arguments
39
39
 
40
40
  Extract from $ARGUMENTS:
41
- - **subcommand**: First word (list, run, status, resume, skip)
41
+ - **subcommand**: First word (list, run, create, status, resume, skip)
42
42
  - **workflow-id**: Second word (only for `run`)
43
43
  - **task**: Everything after workflow-id (only for `run`)
44
44
 
@@ -48,11 +48,12 @@ Available workflow commands:
48
48
 
49
49
  /merlin:workflow list — See available workflows
50
50
  /merlin:workflow run feature-dev "Add X" — Run a workflow
51
+ /merlin:workflow create "Migrate to X" — Generate custom workflow from goal
51
52
  /merlin:workflow status — Check progress
52
53
  /merlin:workflow resume — Resume interrupted workflow
53
54
  /merlin:workflow skip — Skip current step
54
55
 
55
- Bundled workflows: feature-dev, bug-fix, security-audit, refactor
56
+ Bundled workflows: feature-dev, bug-fix, security-audit, refactor, product-dev, ui-build, api-build, spec-to-code
56
57
  ```
57
58
 
58
59
  ## Step 2: Route by Subcommand
@@ -210,6 +211,59 @@ Next steps:
210
211
  [3] Continue in current context
211
212
  ```
212
213
 
214
+ ### `create` — Generate Custom Workflow
215
+
216
+ **Required args:** goal description (what you want to achieve).
217
+
218
+ If missing:
219
+ ```
220
+ Usage: /merlin:workflow create "<goal description>"
221
+
222
+ Example: /merlin:workflow create "Migrate from MongoDB to PostgreSQL with zero downtime"
223
+ ```
224
+
225
+ #### Step 2a: Get Sights Context
226
+
227
+ ```
228
+ Call: merlin_get_context
229
+ Task: "{goal description}"
230
+ ```
231
+
232
+ #### Step 2b: Generate via merlin-loop
233
+
234
+ ```bash
235
+ LOOP_SCRIPT="${HOME}/.claude/loop/merlin-loop.sh"
236
+ bash "$LOOP_SCRIPT" workflow create "${GOAL}" 2>&1
237
+ ```
238
+
239
+ The workflow engine will:
240
+ 1. Use Claude to design a custom pipeline based on the goal
241
+ 2. Validate the generated JSON (correct schema, valid agent_hints)
242
+ 3. Save to `~/.claude/loop/workflows/<id>.json`
243
+ 4. Show a preview of the generated pipeline
244
+
245
+ #### Step 2c: Confirm and Run
246
+
247
+ Show the generated pipeline preview to the user:
248
+ ```
249
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
250
+ GENERATED WORKFLOW: [name]
251
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
252
+
253
+ Goal: [goal]
254
+ Steps: [N]
255
+ Pipeline: Step1 -> Step2 -> Step3 -> ...
256
+
257
+ [1] Run this workflow now
258
+ [2] Edit the workflow JSON first
259
+ [3] Save for later
260
+ ```
261
+
262
+ If user confirms, run it:
263
+ ```bash
264
+ bash "$LOOP_SCRIPT" workflow run "${WORKFLOW_ID}" "${GOAL}" 2>&1
265
+ ```
266
+
213
267
  ### `status` — Show Current Run
214
268
 
215
269
  Read the workflow run state:
@@ -35,6 +35,22 @@ You are not generic Claude. You are a **Merlin agent** — enhanced with codebas
35
35
  | plan, roadmap, phase, milestone | Use /merlin:plan-phase or /merlin:discuss-milestone |
36
36
  | map, analyze, understand codebase | Use /merlin:map-codebase |
37
37
 
38
+ **You suggest workflows.** When a user's task matches a workflow pattern, suggest it proactively:
39
+
40
+ | User says | Suggest workflow |
41
+ |---|---|
42
+ | "build [feature]", "add [feature]" | `feature-dev` |
43
+ | "build the whole thing", "full product" | `product-dev` |
44
+ | "fix [bug]", "broken", "not working" | `bug-fix` |
45
+ | "security", "audit", "vulnerabilities" | `security-audit` |
46
+ | "refactor", "cleanup", "tech debt" | `refactor` |
47
+ | "build UI", "frontend", "components" | `ui-build` |
48
+ | "build API", "endpoints", "REST" | `api-build` |
49
+ | "idea", "from scratch", "spec first" | `spec-to-code` |
50
+ | Complex multi-step or unusual task | `/merlin:workflow create "..."` |
51
+
52
+ Show as: `[1] Run **workflow-name** workflow (automated N-step pipeline)` — users don't need to know commands.
53
+
38
54
  **You maintain continuity.** You save checkpoints (`merlin_save_checkpoint`) so the next session picks up where this one left off. You commit work incrementally. You never let work disappear.
39
55
 
40
56
  **You verify before committing.** Call `merlin_run_verification` before every git commit. Build, types, lint must pass.
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # ╔═══════════════════════════════════════════════════════════════════════════╗
4
+ # ║ MERLIN WORKFLOW ENGINE — Dynamic Workflow Generation ║
5
+ # ║ Describe a goal, Merlin generates a custom pipeline ║
6
+ # ╚═══════════════════════════════════════════════════════════════════════════╝
7
+ #
8
+ # Uses Claude to generate a workflow JSON from a natural language goal.
9
+ # The generated workflow follows the same schema as bundled workflows
10
+ # and can be run, resumed, and managed identically.
11
+
12
+ # Colors (inherit from parent)
13
+ : "${RESET:=\033[0m}"
14
+ : "${BOLD:=\033[1m}"
15
+ : "${DIM:=\033[2m}"
16
+ : "${RED:=\033[31m}"
17
+ : "${GREEN:=\033[32m}"
18
+ : "${YELLOW:=\033[33m}"
19
+ : "${BLUE:=\033[34m}"
20
+ : "${MAGENTA:=\033[35m}"
21
+ : "${CYAN:=\033[36m}"
22
+
23
+ # Valid agent_hint values from the blend engine registry
24
+ VALID_AGENT_HINTS="impl security architect spec test debug refactor frontend api deploy docs perf migrate video secaudit codeorg review swift android uidesign uibuild anim"
25
+
26
+ # ═══════════════════════════════════════════════════════════════════════════════
27
+ # Generate a workflow from a goal description
28
+ # ═══════════════════════════════════════════════════════════════════════════════
29
+
30
+ workflow_generate() {
31
+ local goal="$1"
32
+
33
+ if [ -z "$goal" ]; then
34
+ echo -e "${RED}Usage: workflow create \"<goal description>\"${RESET}" >&2
35
+ echo -e "${DIM}Example: workflow create \"Migrate from MongoDB to PostgreSQL\"${RESET}" >&2
36
+ return 1
37
+ fi
38
+
39
+ echo -e "${MAGENTA}${BOLD} Generating workflow for:${RESET} ${goal}" >&2
40
+ echo -e "${DIM} Using Claude to design a custom pipeline...${RESET}" >&2
41
+ echo "" >&2
42
+
43
+ # Build the generation prompt
44
+ local prompt
45
+ prompt=$(cat <<'PROMPT_END'
46
+ You are a workflow designer for the Merlin AI development system. Generate a JSON workflow definition.
47
+
48
+ SCHEMA REQUIREMENTS:
49
+ - "id": kebab-case identifier (e.g., "mongo-to-postgres")
50
+ - "name": Human-readable name
51
+ - "description": One-line description
52
+ - "version": "1.0"
53
+ - "steps": Array of 5-8 step objects
54
+ - "on_failure": "pause"
55
+ - "on_complete": "notify"
56
+
57
+ STEP SCHEMA:
58
+ - "id": short kebab-case (e.g., "analyze", "implement")
59
+ - "label": Human-readable step name
60
+ - "agent_hint": One of: impl, security, architect, spec, test, debug, refactor, frontend, api, deploy, docs, perf, migrate, secaudit, uidesign, uibuild, anim
61
+ - "input_template": Detailed prompt with {{task}} and {{handoff}} placeholders. Use {{filename.md}} for output_file references.
62
+ - "expects": UPPER_CASE signal (e.g., "ANALYSIS_COMPLETE")
63
+ - "retry": 1-3 (more for complex steps)
64
+ - Optional: "output_file": "filename.md", "blend": true (for implementation steps), "independent": true (for verification), "action": "gh_pr_create" (for PR steps)
65
+
66
+ DESIGN PRINCIPLES:
67
+ - Start with analysis/planning, end with testing/PR
68
+ - Include an independent verification step
69
+ - Implementation steps should have blend: true and retry: 3
70
+ - Each step's input_template should be detailed enough for an AI agent to work autonomously
71
+ - Reference previous step outputs via {{filename.md}} when available
72
+
73
+ Output ONLY valid JSON. No markdown fences, no explanation.
74
+ PROMPT_END
75
+ )
76
+
77
+ prompt="${prompt}
78
+
79
+ GOAL: ${goal}
80
+
81
+ Generate the workflow JSON now:"
82
+
83
+ # Call Claude to generate
84
+ local raw_output
85
+ raw_output=$(echo "$prompt" | claude -p --output-format text 2>/dev/null)
86
+ local gen_exit=$?
87
+
88
+ if [ $gen_exit -ne 0 ] || [ -z "$raw_output" ]; then
89
+ echo -e "${RED}Failed to generate workflow. Claude returned an error.${RESET}" >&2
90
+ return 1
91
+ fi
92
+
93
+ # Extract JSON from output (handles possible markdown fences)
94
+ local json_output
95
+ json_output=$(echo "$raw_output" | python3 -c "
96
+ import sys, json, re
97
+
98
+ text = sys.stdin.read()
99
+
100
+ # Try to extract JSON from markdown code fences
101
+ match = re.search(r'\`\`\`(?:json)?\s*\n?(.*?)\n?\`\`\`', text, re.DOTALL)
102
+ if match:
103
+ text = match.group(1).strip()
104
+
105
+ # Try to find raw JSON object
106
+ if not text.startswith('{'):
107
+ match = re.search(r'(\{.*\})', text, re.DOTALL)
108
+ if match:
109
+ text = match.group(1)
110
+
111
+ # Validate it's valid JSON with required fields
112
+ try:
113
+ wf = json.loads(text)
114
+ assert 'id' in wf, 'Missing id'
115
+ assert 'steps' in wf, 'Missing steps'
116
+ assert len(wf['steps']) > 0, 'No steps'
117
+ print(json.dumps(wf, indent=2))
118
+ except Exception as e:
119
+ print(f'PARSE_ERROR: {e}', file=sys.stderr)
120
+ sys.exit(1)
121
+ " 2>/dev/null)
122
+
123
+ if [ $? -ne 0 ] || [ -z "$json_output" ]; then
124
+ echo -e "${RED}Failed to parse generated workflow JSON.${RESET}" >&2
125
+ echo -e "${DIM}Raw output saved to /tmp/merlin-workflow-gen-debug.txt${RESET}" >&2
126
+ echo "$raw_output" > /tmp/merlin-workflow-gen-debug.txt
127
+ return 1
128
+ fi
129
+
130
+ # Validate agent_hints
131
+ local invalid_hints
132
+ invalid_hints=$(echo "$json_output" | python3 -c "
133
+ import json, sys
134
+ valid = set('${VALID_AGENT_HINTS}'.split())
135
+ wf = json.load(sys.stdin)
136
+ invalid = []
137
+ for step in wf['steps']:
138
+ hint = step.get('agent_hint', '')
139
+ if hint and hint not in valid:
140
+ invalid.append(f\"{step['id']}: {hint}\")
141
+ if invalid:
142
+ print('\n'.join(invalid))
143
+ " 2>/dev/null)
144
+
145
+ if [ -n "$invalid_hints" ]; then
146
+ echo -e "${YELLOW}Warning: Some agent_hints are not in registry:${RESET}" >&2
147
+ echo -e "${DIM}${invalid_hints}${RESET}" >&2
148
+ echo -e "${YELLOW}Attempting to fix...${RESET}" >&2
149
+
150
+ # Auto-fix invalid hints to closest valid one (default: impl)
151
+ json_output=$(echo "$json_output" | python3 -c "
152
+ import json, sys
153
+ valid = set('${VALID_AGENT_HINTS}'.split())
154
+ wf = json.load(sys.stdin)
155
+ for step in wf['steps']:
156
+ if step.get('agent_hint', '') not in valid:
157
+ step['agent_hint'] = 'impl'
158
+ print(json.dumps(wf, indent=2))
159
+ " 2>/dev/null)
160
+ fi
161
+
162
+ # Ensure on_failure and on_complete exist
163
+ json_output=$(echo "$json_output" | python3 -c "
164
+ import json, sys
165
+ wf = json.load(sys.stdin)
166
+ wf.setdefault('on_failure', 'pause')
167
+ wf.setdefault('on_complete', 'notify')
168
+ wf.setdefault('version', '1.0')
169
+ print(json.dumps(wf, indent=2))
170
+ " 2>/dev/null)
171
+
172
+ # Save to workflow directory
173
+ local wf_id
174
+ wf_id=$(echo "$json_output" | python3 -c "import json,sys; print(json.load(sys.stdin)['id'])")
175
+
176
+ local save_dir="${WORKFLOW_DIR}"
177
+ mkdir -p "$save_dir"
178
+ local save_path="${save_dir}/${wf_id}.json"
179
+
180
+ echo "$json_output" > "$save_path"
181
+ echo -e "${GREEN}${BOLD} Workflow saved:${RESET} ${save_path}" >&2
182
+
183
+ # Show preview
184
+ workflow_show_preview "$json_output"
185
+
186
+ # Return the path for callers
187
+ echo "$save_path"
188
+ }
189
+
190
+ # ═══════════════════════════════════════════════════════════════════════════════
191
+ # Pretty-print a workflow for user confirmation
192
+ # ═══════════════════════════════════════════════════════════════════════════════
193
+
194
+ workflow_show_preview() {
195
+ local json_input="$1"
196
+
197
+ python3 -c "
198
+ import json, sys
199
+
200
+ wf = json.loads('''${json_input//\'/\\\'}''')
201
+
202
+ name = wf.get('name', wf['id'])
203
+ desc = wf.get('description', '')
204
+ steps = wf['steps']
205
+
206
+ print()
207
+ print(f' \033[35m\033[1m{name}\033[0m')
208
+ print(f' \033[2m{desc}\033[0m')
209
+ print(f' \033[36mSteps:\033[0m {len(steps)}')
210
+ print()
211
+
212
+ # Pipeline visualization
213
+ labels = [s.get('label', s['id']) for s in steps]
214
+ pipeline = ' \033[2m->\033[0m '.join(f'\033[1m{l}\033[0m' for l in labels)
215
+ print(f' Pipeline: {pipeline}')
216
+ print()
217
+
218
+ # Step detail table
219
+ print(f' \033[2m{\"Step\":<4} {\"Label\":<25} {\"Agent\":<12} {\"Signal\":<25}\033[0m')
220
+ print(f' \033[2m{\"─\"*4} {\"─\"*25} {\"─\"*12} {\"─\"*25}\033[0m')
221
+ for i, s in enumerate(steps, 1):
222
+ label = s.get('label', s['id'])[:25]
223
+ hint = s.get('agent_hint', '?')[:12]
224
+ expects = s.get('expects', '-')[:25]
225
+ print(f' {i:<4} {label:<25} {hint:<12} {expects:<25}')
226
+ print()
227
+ " 2>/dev/null >&2
228
+ }
@@ -342,6 +342,52 @@ workflow_dispatch() {
342
342
  status) workflow_status ;;
343
343
  resume) workflow_resume "$@" ;;
344
344
  skip) workflow_skip ;;
345
+ create)
346
+ local goal="$*"
347
+ if [ -z "$goal" ]; then
348
+ echo -e "${RED}Usage: merlin-loop workflow create \"<goal description>\"${RESET}" >&2
349
+ echo -e "${DIM}Example: merlin-loop workflow create \"Migrate from MongoDB to PostgreSQL\"${RESET}" >&2
350
+ return 1
351
+ fi
352
+ if ! type workflow_generate &>/dev/null; then
353
+ echo -e "${RED}Workflow generation not available. Check lib/workflow-gen.sh${RESET}" >&2
354
+ return 1
355
+ fi
356
+ local wf_path
357
+ wf_path=$(workflow_generate "$goal")
358
+ local gen_exit=$?
359
+ if [ $gen_exit -ne 0 ]; then
360
+ return 1
361
+ fi
362
+ # Interactive mode: ask to run
363
+ if [ -t 0 ] && [ -t 1 ]; then
364
+ echo ""
365
+ echo -e "${BOLD}Run this workflow now?${RESET}"
366
+ echo -e " [${BOLD}y${RESET}] Yes, run it"
367
+ echo -e " [${BOLD}n${RESET}] No, just save it"
368
+ echo -e " [${BOLD}e${RESET}] Edit the JSON first"
369
+ echo -ne " Choice: "
370
+ read -r choice
371
+ case "$choice" in
372
+ y|Y)
373
+ local wf_id
374
+ wf_id=$(python3 -c "import json; print(json.load(open('$wf_path'))['id'])")
375
+ workflow_run "$wf_id" "$goal"
376
+ ;;
377
+ e|E)
378
+ echo -e "${CYAN}Edit the workflow at: ${BOLD}${wf_path}${RESET}"
379
+ echo -e "${DIM}Then run: merlin-loop workflow run <id> \"${goal}\"${RESET}"
380
+ ;;
381
+ *)
382
+ echo -e "${GREEN}Saved to: ${wf_path}${RESET}"
383
+ echo -e "${DIM}Run later: merlin-loop workflow run <id> \"${goal}\"${RESET}"
384
+ ;;
385
+ esac
386
+ else
387
+ # Non-interactive: just save and print path
388
+ echo -e "${GREEN}Workflow saved: ${wf_path}${RESET}"
389
+ fi
390
+ ;;
345
391
  install)
346
392
  local source="${1:-}"
347
393
  if [ -z "$source" ]; then
@@ -352,7 +398,7 @@ workflow_dispatch() {
352
398
  ;;
353
399
  *)
354
400
  echo -e "${RED}Unknown workflow command: ${subcmd}${RESET}" >&2
355
- echo -e "Commands: list, run, status, resume, skip, install" >&2
401
+ echo -e "Commands: list, run, create, status, resume, skip, install" >&2
356
402
  return 1
357
403
  ;;
358
404
  esac
@@ -380,4 +380,5 @@ _workflow_run_action() {
380
380
  # ═══════════════════════════════════════════════════════════════════════════════
381
381
 
382
382
  _WORKFLOW_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
383
+ source "${_WORKFLOW_LIB_DIR}/workflow-gen.sh" 2>/dev/null || true
383
384
  source "${_WORKFLOW_LIB_DIR}/workflow-run.sh" 2>/dev/null || true
@@ -772,6 +772,7 @@ usage() {
772
772
  echo ""
773
773
  echo " workflow list List available workflows"
774
774
  echo " workflow run <id> \"<task>\" Run a named workflow"
775
+ echo " workflow create \"<goal>\" Generate custom workflow from goal"
775
776
  echo " workflow status Show workflow run progress"
776
777
  echo " workflow resume Resume interrupted workflow"
777
778
  echo " workflow skip Skip current step and advance"
@@ -803,6 +804,7 @@ usage() {
803
804
  echo ""
804
805
  echo " merlin-loop workflow list # See available workflows"
805
806
  echo " merlin-loop workflow run feature-dev \"Add OAuth\" # Run a workflow"
807
+ echo " merlin-loop workflow create \"Migrate to Postgres\" # Generate custom workflow"
806
808
  echo " merlin-loop workflow status # Check progress"
807
809
  echo " merlin-loop workflow resume # Resume after failure"
808
810
  }
@@ -0,0 +1,71 @@
1
+ {
2
+ "id": "api-build",
3
+ "name": "API Build",
4
+ "description": "Describe an API. Get back designed, validated, authenticated, tested endpoints with PR.",
5
+ "version": "1.0",
6
+ "steps": [
7
+ {
8
+ "id": "design",
9
+ "label": "API Design",
10
+ "agent_hint": "api",
11
+ "input_template": "Design the API for:\n\n{{task}}\n\nDefine:\n- Resource naming and URL structure (RESTful)\n- HTTP methods and status codes per endpoint\n- Request/response schemas with examples\n- Pagination, filtering, sorting patterns\n- Error response format\n- Versioning strategy\n\nFollow existing API patterns in the codebase.\n\nOutput DESIGN_COMPLETE when done.",
12
+ "expects": "DESIGN_COMPLETE",
13
+ "output_file": "api-design.md",
14
+ "retry": 1
15
+ },
16
+ {
17
+ "id": "endpoints",
18
+ "label": "Endpoint Implementation",
19
+ "agent_hint": "impl",
20
+ "input_template": "Implement the API endpoints from this design:\n\n{{api-design.md}}\n\nPrevious context:\n{{handoff}}\n\nRules:\n- Follow existing route/controller/service patterns\n- Keep handlers thin — business logic in services\n- Include proper status codes and error responses\n- Add request logging\n- Keep files under 400 lines\n\nOutput ENDPOINTS_COMPLETE when done.",
21
+ "expects": "ENDPOINTS_COMPLETE",
22
+ "retry": 2,
23
+ "blend": true
24
+ },
25
+ {
26
+ "id": "validation",
27
+ "label": "Input Validation",
28
+ "agent_hint": "security",
29
+ "input_template": "Add comprehensive input validation to all endpoints:\n\nContext:\n{{handoff}}\n\nFor every endpoint:\n- Validate request body schema\n- Validate query parameters and path params\n- Sanitize string inputs\n- Enforce type constraints\n- Add meaningful validation error messages\n- Reject unexpected fields\n\nOutput VALIDATION_COMPLETE when done.",
30
+ "expects": "VALIDATION_COMPLETE",
31
+ "retry": 2,
32
+ "blend": true
33
+ },
34
+ {
35
+ "id": "auth",
36
+ "label": "Authentication & Authorization",
37
+ "agent_hint": "security",
38
+ "input_template": "Add authentication and authorization to the API:\n\nContext:\n{{handoff}}\n\nEnsure:\n- All endpoints require proper authentication\n- Role-based access control where applicable\n- Rate limiting on sensitive endpoints\n- CORS configuration\n- Token validation and refresh handling\n\nFollow existing auth patterns in the codebase.\n\nOutput AUTH_COMPLETE when done.",
39
+ "expects": "AUTH_COMPLETE",
40
+ "retry": 2,
41
+ "blend": true
42
+ },
43
+ {
44
+ "id": "test",
45
+ "label": "API Testing",
46
+ "agent_hint": "test",
47
+ "input_template": "Write comprehensive API tests:\n\nContext:\n{{handoff}}\n\nAPI Design:\n{{api-design.md}}\n\n1. Happy path tests for every endpoint\n2. Validation error tests (bad inputs)\n3. Authentication tests (unauthorized, forbidden)\n4. Edge cases (empty results, pagination bounds)\n5. All tests must pass\n\nOutput TESTS_PASS when complete.",
48
+ "expects": "TESTS_PASS",
49
+ "retry": 2
50
+ },
51
+ {
52
+ "id": "docs",
53
+ "label": "API Documentation",
54
+ "agent_hint": "docs",
55
+ "input_template": "Create API documentation:\n\nContext:\n{{handoff}}\n\nAPI Design:\n{{api-design.md}}\n\nGenerate:\n- OpenAPI/Swagger spec (if applicable)\n- Endpoint reference with examples\n- Authentication guide\n- Error code reference\n- Quick start for API consumers\n\nOutput DOCS_COMPLETE when done.",
56
+ "expects": "DOCS_COMPLETE",
57
+ "retry": 1
58
+ },
59
+ {
60
+ "id": "pr",
61
+ "label": "Pull Request",
62
+ "agent_hint": "impl",
63
+ "input_template": "Create a PR for the API build.\n\nContext:\n{{handoff}}\n\nOriginal task: {{task}}\n\nPR should include:\n- Endpoint summary table\n- Breaking changes (if any)\n- Auth requirements\n- How to test with curl/Postman examples\n\nOutput PR_CREATED when done.",
64
+ "expects": "PR_CREATED",
65
+ "action": "gh_pr_create",
66
+ "retry": 1
67
+ }
68
+ ],
69
+ "on_failure": "pause",
70
+ "on_complete": "notify"
71
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "id": "product-dev",
3
+ "name": "Product Development",
4
+ "description": "Describe a product idea. Get back a fully built, tested, and documented feature.",
5
+ "version": "1.0",
6
+ "steps": [
7
+ {
8
+ "id": "spec",
9
+ "label": "Product Spec",
10
+ "agent_hint": "spec",
11
+ "input_template": "Create a lean product spec for:\n\n{{task}}\n\nInclude:\n- User stories with acceptance criteria\n- Core flows (happy path + error states)\n- Data model sketch\n- Out of scope (what NOT to build)\n- Success metrics\n\nKeep it lean — no fluff, just what an engineer needs to start building.\n\nOutput SPEC_COMPLETE when done.",
12
+ "expects": "SPEC_COMPLETE",
13
+ "output_file": "spec.md",
14
+ "retry": 2
15
+ },
16
+ {
17
+ "id": "architecture",
18
+ "label": "Architecture",
19
+ "agent_hint": "architect",
20
+ "input_template": "Design the architecture for this product spec:\n\n{{spec.md}}\n\nPrevious context:\n{{handoff}}\n\nDefine:\n- Service boundaries and data flow\n- Database schema / models\n- API endpoints\n- Key technical decisions with rationale\n- File structure plan\n\nKeep it simple. Prefer fewer services. No over-engineering.\n\nOutput ARCH_COMPLETE when done.",
21
+ "expects": "ARCH_COMPLETE",
22
+ "output_file": "architecture.md",
23
+ "retry": 1
24
+ },
25
+ {
26
+ "id": "implement",
27
+ "label": "Implementation",
28
+ "agent_hint": "impl",
29
+ "input_template": "Implement the product according to spec and architecture:\n\nSpec:\n{{spec.md}}\n\nArchitecture:\n{{architecture.md}}\n\nPrevious context:\n{{handoff}}\n\nRules:\n- Follow existing patterns in the codebase\n- Keep files under 400 lines\n- Commit after each logical change\n- Implement core flows first, then edge cases\n\nOutput IMPL_COMPLETE when done.",
30
+ "expects": "IMPL_COMPLETE",
31
+ "retry": 3,
32
+ "blend": true
33
+ },
34
+ {
35
+ "id": "harden",
36
+ "label": "Hardening",
37
+ "agent_hint": "security",
38
+ "input_template": "Harden the implementation for production:\n\nContext:\n{{handoff}}\n\nCheck and fix:\n- Input validation on all user inputs\n- Authentication and authorization checks\n- Error handling (no unhandled exceptions)\n- Rate limiting where appropriate\n- Secrets not hardcoded\n- SQL injection / XSS prevention\n\nOutput HARDENED when all critical paths are secured.",
39
+ "expects": "HARDENED",
40
+ "retry": 2,
41
+ "blend": true
42
+ },
43
+ {
44
+ "id": "test",
45
+ "label": "Testing",
46
+ "agent_hint": "test",
47
+ "input_template": "Write comprehensive tests for the implementation:\n\nContext:\n{{handoff}}\n\n1. Unit tests for core business logic\n2. Integration tests for API endpoints\n3. Edge case tests from the spec\n4. Ensure all tests pass\n\nOutput TESTS_PASS when all tests pass.",
48
+ "expects": "TESTS_PASS",
49
+ "retry": 2
50
+ },
51
+ {
52
+ "id": "docs",
53
+ "label": "Documentation",
54
+ "agent_hint": "docs",
55
+ "input_template": "Write documentation for the new feature:\n\nContext:\n{{handoff}}\n\nCreate:\n- API documentation (if endpoints added)\n- User-facing docs (if UI added)\n- Developer notes (key decisions, gotchas)\n- Update existing docs if needed\n\nKeep it concise. Engineers read docs, not novels.\n\nOutput DOCS_COMPLETE when done.",
56
+ "expects": "DOCS_COMPLETE",
57
+ "retry": 1
58
+ },
59
+ {
60
+ "id": "pr",
61
+ "label": "Pull Request",
62
+ "agent_hint": "impl",
63
+ "input_template": "Create a PR for the completed product feature.\n\nContext:\n{{handoff}}\n\nOriginal task: {{task}}\n\nWrite a clear PR title and description covering:\n- What was built and why\n- Key technical decisions\n- How to test it\n- Screenshots if UI changes\n\nOutput PR_CREATED when done.",
64
+ "expects": "PR_CREATED",
65
+ "action": "gh_pr_create",
66
+ "retry": 1
67
+ }
68
+ ],
69
+ "on_failure": "pause",
70
+ "on_complete": "notify"
71
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "id": "spec-to-code",
3
+ "name": "Spec to Code",
4
+ "description": "Start from an idea. Get back a specced, architected, planned, and tested implementation.",
5
+ "version": "1.0",
6
+ "steps": [
7
+ {
8
+ "id": "ideate",
9
+ "label": "Ideation",
10
+ "agent_hint": "spec",
11
+ "input_template": "Explore and expand this idea:\n\n{{task}}\n\nThink through:\n- What problem does this solve?\n- Who is the user?\n- What's the simplest version that delivers value?\n- What are the risks and unknowns?\n- What similar solutions exist?\n\nOutput a focused product brief.\n\nOutput IDEATION_COMPLETE when done.",
12
+ "expects": "IDEATION_COMPLETE",
13
+ "output_file": "brief.md",
14
+ "retry": 1
15
+ },
16
+ {
17
+ "id": "requirements",
18
+ "label": "Requirements",
19
+ "agent_hint": "spec",
20
+ "input_template": "Turn this product brief into concrete requirements:\n\n{{brief.md}}\n\nPrevious context:\n{{handoff}}\n\nCreate:\n- Functional requirements (what it MUST do)\n- Non-functional requirements (performance, security, scale)\n- Acceptance criteria for each requirement\n- Priority: P0 (must have) vs P1 (should have) vs P2 (nice to have)\n\nOutput REQUIREMENTS_COMPLETE when done.",
21
+ "expects": "REQUIREMENTS_COMPLETE",
22
+ "output_file": "requirements.md",
23
+ "retry": 1
24
+ },
25
+ {
26
+ "id": "architecture",
27
+ "label": "Architecture",
28
+ "agent_hint": "architect",
29
+ "input_template": "Design the technical architecture for these requirements:\n\n{{requirements.md}}\n\nPrevious context:\n{{handoff}}\n\nDefine:\n- System components and boundaries\n- Data models and relationships\n- API contracts\n- Infrastructure needs\n- Technical decisions with trade-off analysis\n\nOutput ARCH_COMPLETE when done.",
30
+ "expects": "ARCH_COMPLETE",
31
+ "output_file": "architecture.md",
32
+ "retry": 1
33
+ },
34
+ {
35
+ "id": "plan",
36
+ "label": "Implementation Plan",
37
+ "agent_hint": "spec",
38
+ "agent_override": "merlin-planner",
39
+ "input_template": "Create a detailed implementation plan:\n\nRequirements:\n{{requirements.md}}\n\nArchitecture:\n{{architecture.md}}\n\nPrevious context:\n{{handoff}}\n\nBreak into ordered tasks with:\n- File changes per task\n- Dependencies between tasks\n- Verification criteria\n- Estimated complexity\n\nOutput PLAN_COMPLETE when done.",
40
+ "expects": "PLAN_COMPLETE",
41
+ "output_file": "plan.md",
42
+ "retry": 1
43
+ },
44
+ {
45
+ "id": "implement",
46
+ "label": "Implementation",
47
+ "agent_hint": "impl",
48
+ "input_template": "Implement according to the plan:\n\n{{plan.md}}\n\nPrevious context:\n{{handoff}}\n\nFollow the task order. Commit after each logical unit.\nKeep files under 400 lines. Follow existing codebase patterns.\n\nOutput IMPL_COMPLETE when all plan tasks are done.",
49
+ "expects": "IMPL_COMPLETE",
50
+ "retry": 3,
51
+ "blend": true
52
+ },
53
+ {
54
+ "id": "verify",
55
+ "label": "Verification",
56
+ "agent_hint": "architect",
57
+ "agent_override": "merlin-verifier",
58
+ "input_template": "Verify the implementation against requirements.\n\nDo NOT read the original task. Evaluate cold:\n- Does the code match the requirements?\n- Are acceptance criteria met?\n- Any bugs, missing error handling, security issues?\n\nRequirements:\n{{requirements.md}}\n\nContext:\n{{handoff}}\n\nOutput VERIFIED when review passes.",
59
+ "expects": "VERIFIED",
60
+ "independent": true,
61
+ "retry": 1
62
+ },
63
+ {
64
+ "id": "test",
65
+ "label": "Testing",
66
+ "agent_hint": "test",
67
+ "input_template": "Write and run comprehensive tests:\n\nContext:\n{{handoff}}\n\nRequirements:\n{{requirements.md}}\n\n1. Unit tests for each P0 requirement\n2. Integration tests for core flows\n3. Edge case and error path tests\n4. All tests must pass\n\nOutput TESTS_PASS when complete.",
68
+ "expects": "TESTS_PASS",
69
+ "retry": 2
70
+ }
71
+ ],
72
+ "on_failure": "pause",
73
+ "on_complete": "notify"
74
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "id": "ui-build",
3
+ "name": "UI Build",
4
+ "description": "Describe a UI. Get back designed, built, styled, tested components with PR.",
5
+ "version": "1.0",
6
+ "steps": [
7
+ {
8
+ "id": "design-spec",
9
+ "label": "Design Spec",
10
+ "agent_hint": "uidesign",
11
+ "input_template": "Create a UI design spec for:\n\n{{task}}\n\nInclude:\n- Component hierarchy and layout structure\n- User interaction flows (clicks, forms, navigation)\n- Responsive breakpoints and behavior\n- Accessibility requirements (ARIA, keyboard nav, contrast)\n- Design tokens to use (colors, spacing, typography)\n- States: loading, empty, error, success\n\nOutput DESIGN_COMPLETE when done.",
12
+ "expects": "DESIGN_COMPLETE",
13
+ "output_file": "design-spec.md",
14
+ "retry": 1
15
+ },
16
+ {
17
+ "id": "components",
18
+ "label": "Component Build",
19
+ "agent_hint": "uibuild",
20
+ "input_template": "Build the UI components from this design spec:\n\n{{design-spec.md}}\n\nPrevious context:\n{{handoff}}\n\nRules:\n- Use existing component library patterns in the codebase\n- Keep components small and focused (one responsibility)\n- Props interfaces first, then implementation\n- Keep files under 400 lines — split into subcomponents\n\nOutput COMPONENTS_COMPLETE when done.",
21
+ "expects": "COMPONENTS_COMPLETE",
22
+ "retry": 2,
23
+ "blend": true
24
+ },
25
+ {
26
+ "id": "layout",
27
+ "label": "Layout & Routing",
28
+ "agent_hint": "frontend",
29
+ "input_template": "Wire up layout, routing, and page structure:\n\nContext:\n{{handoff}}\n\nConnect components into pages. Set up routing if needed. Handle layout responsiveness.\nFollow existing routing patterns in the codebase.\n\nOutput LAYOUT_COMPLETE when done.",
30
+ "expects": "LAYOUT_COMPLETE",
31
+ "retry": 2,
32
+ "blend": true
33
+ },
34
+ {
35
+ "id": "state",
36
+ "label": "State & Data",
37
+ "agent_hint": "frontend",
38
+ "input_template": "Wire up state management and data fetching:\n\nContext:\n{{handoff}}\n\nConnect to APIs, set up state management, handle loading/error states.\nFollow existing data fetching patterns (hooks, queries, etc).\n\nOutput STATE_COMPLETE when done.",
39
+ "expects": "STATE_COMPLETE",
40
+ "retry": 2,
41
+ "blend": true
42
+ },
43
+ {
44
+ "id": "styling",
45
+ "label": "Styling & Polish",
46
+ "agent_hint": "frontend",
47
+ "input_template": "Polish the UI styling and interactions:\n\nContext:\n{{handoff}}\n\nRefine:\n- Spacing, alignment, typography consistency\n- Hover/focus/active states\n- Transitions and micro-animations\n- Dark mode support (if applicable)\n- Mobile responsive behavior\n\nOutput STYLING_COMPLETE when done.",
48
+ "expects": "STYLING_COMPLETE",
49
+ "retry": 1,
50
+ "blend": true
51
+ },
52
+ {
53
+ "id": "test",
54
+ "label": "UI Testing",
55
+ "agent_hint": "test",
56
+ "input_template": "Write tests for the UI components:\n\nContext:\n{{handoff}}\n\n1. Component render tests (all states)\n2. Interaction tests (clicks, form submissions)\n3. Accessibility tests (axe-core, keyboard navigation)\n4. Responsive layout tests if applicable\n\nOutput TESTS_PASS when all tests pass.",
57
+ "expects": "TESTS_PASS",
58
+ "retry": 2
59
+ },
60
+ {
61
+ "id": "pr",
62
+ "label": "Pull Request",
63
+ "agent_hint": "impl",
64
+ "input_template": "Create a PR for the UI build.\n\nContext:\n{{handoff}}\n\nOriginal task: {{task}}\n\nPR should include:\n- Screenshots or description of visual changes\n- Component breakdown\n- Accessibility notes\n- How to test manually\n\nOutput PR_CREATED when done.",
65
+ "expects": "PR_CREATED",
66
+ "action": "gh_pr_create",
67
+ "retry": 1
68
+ }
69
+ ],
70
+ "on_failure": "pause",
71
+ "on_complete": "notify"
72
+ }
@@ -1 +1 @@
1
- 3.6.4
1
+ 3.8.0-beta.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-merlin-brain",
3
- "version": "3.8.0-beta.1",
3
+ "version": "3.8.0-beta.3",
4
4
  "description": "Merlin - The Ultimate AI Brain for Claude Code. One install: workflows, agents, loop, and Sights MCP server.",
5
5
  "type": "module",
6
6
  "main": "./dist/server/index.js",