create-merlin-brain 3.10.0 → 3.12.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.
- package/bin/install.cjs +146 -22
- package/bin/runtime-adapters.cjs +396 -0
- package/dist/server/cost/tracker.d.ts +38 -2
- package/dist/server/cost/tracker.d.ts.map +1 -1
- package/dist/server/cost/tracker.js +87 -15
- package/dist/server/cost/tracker.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +74 -30
- package/dist/server/server.js.map +1 -1
- package/dist/server/tools/adaptive.js +1 -1
- package/dist/server/tools/adaptive.js.map +1 -1
- package/dist/server/tools/agents-index.js +3 -3
- package/dist/server/tools/agents-index.js.map +1 -1
- package/dist/server/tools/agents.js +5 -5
- package/dist/server/tools/agents.js.map +1 -1
- package/dist/server/tools/behaviors.js +4 -4
- package/dist/server/tools/behaviors.js.map +1 -1
- package/dist/server/tools/context.js +7 -7
- package/dist/server/tools/context.js.map +1 -1
- package/dist/server/tools/cost.d.ts +3 -1
- package/dist/server/tools/cost.d.ts.map +1 -1
- package/dist/server/tools/cost.js +66 -13
- package/dist/server/tools/cost.js.map +1 -1
- package/dist/server/tools/discoveries.js +6 -6
- package/dist/server/tools/discoveries.js.map +1 -1
- package/dist/server/tools/index.d.ts +4 -0
- package/dist/server/tools/index.d.ts.map +1 -1
- package/dist/server/tools/index.js +4 -0
- package/dist/server/tools/index.js.map +1 -1
- package/dist/server/tools/learning.d.ts +12 -0
- package/dist/server/tools/learning.d.ts.map +1 -0
- package/dist/server/tools/learning.js +269 -0
- package/dist/server/tools/learning.js.map +1 -0
- package/dist/server/tools/project.js +7 -7
- package/dist/server/tools/project.js.map +1 -1
- package/dist/server/tools/promote.d.ts +11 -0
- package/dist/server/tools/promote.d.ts.map +1 -0
- package/dist/server/tools/promote.js +315 -0
- package/dist/server/tools/promote.js.map +1 -0
- package/dist/server/tools/route.d.ts.map +1 -1
- package/dist/server/tools/route.js +65 -24
- package/dist/server/tools/route.js.map +1 -1
- package/dist/server/tools/session-restore.d.ts +18 -0
- package/dist/server/tools/session-restore.d.ts.map +1 -0
- package/dist/server/tools/session-restore.js +154 -0
- package/dist/server/tools/session-restore.js.map +1 -0
- package/dist/server/tools/session-search.d.ts +16 -0
- package/dist/server/tools/session-search.d.ts.map +1 -0
- package/dist/server/tools/session-search.js +240 -0
- package/dist/server/tools/session-search.js.map +1 -0
- package/dist/server/tools/sights-index.js +2 -2
- package/dist/server/tools/sights-index.js.map +1 -1
- package/dist/server/tools/smart-route.d.ts.map +1 -1
- package/dist/server/tools/smart-route.js +4 -5
- package/dist/server/tools/smart-route.js.map +1 -1
- package/dist/server/tools/verification.js +1 -1
- package/dist/server/tools/verification.js.map +1 -1
- package/files/agents/code-organization-supervisor.md +9 -0
- package/files/agents/context-guardian.md +9 -0
- package/files/agents/docs-keeper.md +11 -1
- package/files/agents/dry-refactor.md +12 -1
- package/files/agents/elite-code-refactorer.md +10 -0
- package/files/agents/hardening-guard.md +13 -1
- package/files/agents/implementation-dev.md +12 -1
- package/files/agents/merlin-access-control-reviewer.md +248 -0
- package/files/agents/merlin-api-designer.md +9 -0
- package/files/agents/merlin-codebase-mapper.md +9 -1
- package/files/agents/merlin-debugger.md +10 -0
- package/files/agents/merlin-dependency-auditor.md +216 -0
- package/files/agents/merlin-executor.md +12 -1
- package/files/agents/merlin-frontend.md +9 -0
- package/files/agents/merlin-input-validator.md +247 -0
- package/files/agents/merlin-integration-checker.md +9 -1
- package/files/agents/merlin-migrator.md +9 -0
- package/files/agents/merlin-milestone-auditor.md +8 -0
- package/files/agents/merlin-performance.md +8 -0
- package/files/agents/merlin-planner.md +10 -0
- package/files/agents/merlin-researcher.md +10 -0
- package/files/agents/merlin-reviewer.md +42 -7
- package/files/agents/merlin-sast-reviewer.md +182 -0
- package/files/agents/merlin-secret-scanner.md +203 -0
- package/files/agents/merlin-security.md +9 -0
- package/files/agents/merlin-verifier.md +9 -0
- package/files/agents/merlin-work-verifier.md +9 -0
- package/files/agents/merlin.md +10 -0
- package/files/agents/ops-railway.md +11 -1
- package/files/agents/orchestrator-retrofit.md +9 -1
- package/files/agents/product-spec.md +11 -1
- package/files/agents/remotion.md +8 -0
- package/files/agents/system-architect.md +11 -1
- package/files/agents/tests-qa.md +12 -1
- package/files/commands/merlin/course-correct.md +219 -0
- package/files/commands/merlin/debug.md +2 -2
- package/files/commands/merlin/execute-phase.md +96 -199
- package/files/commands/merlin/execute-plan.md +118 -182
- package/files/commands/merlin/health.md +385 -0
- package/files/commands/merlin/loop-recipes.md +93 -36
- package/files/commands/merlin/map-codebase.md +4 -4
- package/files/commands/merlin/next.md +240 -0
- package/files/commands/merlin/optimize-prompts.md +158 -0
- package/files/commands/merlin/plan-phase.md +1 -1
- package/files/commands/merlin/profiles.md +215 -0
- package/files/commands/merlin/promote.md +176 -0
- package/files/commands/merlin/quick.md +229 -0
- package/files/commands/merlin/readiness-gate.md +208 -0
- package/files/commands/merlin/research-phase.md +2 -2
- package/files/commands/merlin/research-project.md +4 -4
- package/files/commands/merlin/resume-work.md +27 -1
- package/files/commands/merlin/route.md +43 -1
- package/files/commands/merlin/sandbox.md +359 -0
- package/files/commands/merlin/usage.md +55 -0
- package/files/commands/merlin/verify-work.md +1 -1
- package/files/docker/Dockerfile.merlin +20 -0
- package/files/docker/docker-compose.merlin.yml +23 -0
- package/files/hook-templates/auto-commit.sh +64 -0
- package/files/hook-templates/auto-format.sh +95 -0
- package/files/hook-templates/auto-test.sh +117 -0
- package/files/hook-templates/branch-protection.sh +72 -0
- package/files/hook-templates/changelog-reminder.sh +76 -0
- package/files/hook-templates/complexity-check.sh +112 -0
- package/files/hook-templates/import-audit.sh +83 -0
- package/files/hook-templates/license-header.sh +84 -0
- package/files/hook-templates/pr-description.sh +100 -0
- package/files/hook-templates/todo-tracker.sh +80 -0
- package/files/hooks/check-file-size.sh +17 -4
- package/files/hooks/config-change.sh +44 -16
- package/files/hooks/instructions-loaded.sh +22 -5
- package/files/hooks/notify-desktop.sh +157 -0
- package/files/hooks/notify-webhook.sh +141 -0
- package/files/hooks/pre-edit-sights-check.sh +76 -9
- package/files/hooks/security-scanner.sh +153 -0
- package/files/hooks/session-end-memory-sync.sh +97 -0
- package/files/hooks/session-end.sh +274 -1
- package/files/hooks/session-start.sh +19 -6
- package/files/hooks/smart-approve.sh +270 -0
- package/files/hooks/teammate-idle-verify.sh +87 -12
- package/files/hooks/worktree-create.sh +20 -3
- package/files/hooks/worktree-remove.sh +21 -3
- package/files/merlin/references/plan-format.md +37 -9
- package/files/merlin/sandbox.json +9 -0
- package/files/merlin/security.json +11 -0
- package/files/merlin/templates/ci/docs-update.yml +81 -0
- package/files/merlin/templates/ci/pr-review.yml +50 -0
- package/files/merlin/templates/ci/security-audit.yml +74 -0
- package/files/merlin/templates/config.json +9 -1
- package/files/rules/api-rules.md +30 -0
- package/files/rules/frontend-rules.md +25 -0
- package/files/rules/hooks-rules.md +36 -0
- package/files/rules/mcp-rules.md +30 -0
- package/files/rules/worker-rules.md +29 -0
- package/package.json +1 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: merlin:promote
|
|
3
|
+
description: Promote a high-confidence learned behavior into a permanent reusable skill or agent
|
|
4
|
+
argument-hint: "[behavior-id or keyword]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- mcp__merlin__merlin_get_behaviors
|
|
7
|
+
- mcp__merlin__merlin_list_promotion_candidates
|
|
8
|
+
- mcp__merlin__merlin_promote_behavior
|
|
9
|
+
- AskUserQuestion
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<objective>
|
|
13
|
+
Turn proven learned behaviors into first-class, permanent skills.
|
|
14
|
+
|
|
15
|
+
Behaviors with confidence >= 0.85 have been validated enough to be formalized. This command
|
|
16
|
+
walks you through selecting candidates, reviewing auto-generated skill drafts, editing them,
|
|
17
|
+
and saving them to the project's Sights catalog — where they become discoverable by all agents.
|
|
18
|
+
</objective>
|
|
19
|
+
|
|
20
|
+
<process>
|
|
21
|
+
|
|
22
|
+
## Step 1: Parse Arguments
|
|
23
|
+
|
|
24
|
+
Extract from $ARGUMENTS (optional):
|
|
25
|
+
- **behavior-id**: A specific behavior UUID to promote directly
|
|
26
|
+
- **keyword**: A word/phrase to filter candidates by pattern text
|
|
27
|
+
|
|
28
|
+
If no argument is given, proceed to list all candidates.
|
|
29
|
+
|
|
30
|
+
## Step 2: Load Promotion Candidates
|
|
31
|
+
|
|
32
|
+
Call `merlin_list_promotion_candidates` with no filters.
|
|
33
|
+
|
|
34
|
+
If the result says there are no candidates yet:
|
|
35
|
+
```
|
|
36
|
+
No behaviors are ready for promotion yet.
|
|
37
|
+
Confidence >= 0.85 is required. Keep applying behaviors — each successful
|
|
38
|
+
application adds +0.05 confidence.
|
|
39
|
+
|
|
40
|
+
Use /merlin:check-behaviors to see current confidence levels.
|
|
41
|
+
```
|
|
42
|
+
Then stop.
|
|
43
|
+
|
|
44
|
+
## Step 3: Display Candidates
|
|
45
|
+
|
|
46
|
+
Present the candidates in a numbered list:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Promotion Candidates ({N} behaviors ready)
|
|
50
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
51
|
+
|
|
52
|
+
[1] {pattern}
|
|
53
|
+
Action: {action}
|
|
54
|
+
Confidence: {confidence} | Applied: {timesApplied}x
|
|
55
|
+
ID: {id}
|
|
56
|
+
|
|
57
|
+
[2] ...
|
|
58
|
+
|
|
59
|
+
[A] Promote ALL candidates
|
|
60
|
+
[Q] Quit
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Step 4: Ask User to Select
|
|
64
|
+
|
|
65
|
+
Ask the user which behavior(s) to promote. Accept:
|
|
66
|
+
- A single number (promote that one)
|
|
67
|
+
- Multiple numbers comma-separated ("1,3")
|
|
68
|
+
- "A" to promote all
|
|
69
|
+
- "Q" to quit
|
|
70
|
+
|
|
71
|
+
If $ARGUMENTS had a valid behavior-id or keyword, auto-select matching candidates
|
|
72
|
+
and skip the question (just confirm: "Found behavior matching '{keyword}' — promoting it.").
|
|
73
|
+
|
|
74
|
+
## Step 5: Generate Skill Draft(s)
|
|
75
|
+
|
|
76
|
+
For the selected behaviors, call:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
merlin_promote_behavior(
|
|
80
|
+
behaviorId: "{id}", // or omit and use patternKeyword if multi-select
|
|
81
|
+
repoUrl: optional
|
|
82
|
+
)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If multiple behaviors selected, call once with no behaviorId to get all clustered:
|
|
86
|
+
```
|
|
87
|
+
merlin_promote_behavior() // clusters ALL candidates automatically
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Step 6: Present Draft for Review
|
|
91
|
+
|
|
92
|
+
Show each draft inside a code block. Then ask:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Review the skill draft above.
|
|
96
|
+
|
|
97
|
+
[A] Approve and save as-is
|
|
98
|
+
[E] Edit then save (paste your edited version)
|
|
99
|
+
[S] Skip this skill
|
|
100
|
+
[Q] Quit without saving
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
If the user chooses **E**:
|
|
104
|
+
- Ask them to paste their edited SKILL.md content
|
|
105
|
+
- Use their version as the skillDraft
|
|
106
|
+
|
|
107
|
+
## Step 7: Save Approved Draft
|
|
108
|
+
|
|
109
|
+
When user approves (A or E):
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
merlin_promote_behavior(
|
|
113
|
+
approved: true,
|
|
114
|
+
skillDraft: "{draft content}",
|
|
115
|
+
repoUrl: optional
|
|
116
|
+
)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Show the confirmation message returned by the tool.
|
|
120
|
+
|
|
121
|
+
## Step 8: Handle Multiple Drafts
|
|
122
|
+
|
|
123
|
+
If there were multiple skill drafts, loop through each (Step 6-7) before finishing.
|
|
124
|
+
|
|
125
|
+
## Step 9: Summary
|
|
126
|
+
|
|
127
|
+
After all drafts are handled:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
Promotion complete
|
|
131
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
132
|
+
|
|
133
|
+
Saved: {N} skill(s)
|
|
134
|
+
Skipped: {M} skill(s)
|
|
135
|
+
|
|
136
|
+
Saved skills are now in the Sights index and discoverable by:
|
|
137
|
+
merlin_get_context("skill: {name}")
|
|
138
|
+
|
|
139
|
+
Next: Reference these skills in agent prompts or route tasks to them
|
|
140
|
+
via /merlin:route.
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
</process>
|
|
144
|
+
|
|
145
|
+
<behavior_clustering>
|
|
146
|
+
|
|
147
|
+
When multiple behaviors share overlapping trigger keywords (Jaccard similarity >= 0.3),
|
|
148
|
+
the promotion tool automatically clusters them into a single skill with multiple actions.
|
|
149
|
+
This keeps the agent catalog focused rather than fragmenting related patterns.
|
|
150
|
+
|
|
151
|
+
Example: "always run tests after editing src/" and "always run lint on TypeScript files"
|
|
152
|
+
would cluster into a "QualityGates" skill with two actions.
|
|
153
|
+
|
|
154
|
+
The draft shows which behaviors were merged and preserves their individual trigger conditions.
|
|
155
|
+
|
|
156
|
+
</behavior_clustering>
|
|
157
|
+
|
|
158
|
+
<error_handling>
|
|
159
|
+
|
|
160
|
+
| Condition | Action |
|
|
161
|
+
|-----------|--------|
|
|
162
|
+
| No candidates yet | Explain threshold, show path to get there |
|
|
163
|
+
| Behavior ID not found | Show available IDs, ask user to re-select |
|
|
164
|
+
| API unavailable | Inform user, suggest trying again later |
|
|
165
|
+
| User skips all drafts | Exit cleanly with "Nothing saved" message |
|
|
166
|
+
| Draft edit is empty | Ask again, do not save empty skill |
|
|
167
|
+
|
|
168
|
+
</error_handling>
|
|
169
|
+
|
|
170
|
+
<design_notes>
|
|
171
|
+
- This command is a guided UX wrapper around merlin_promote_behavior and merlin_list_promotion_candidates
|
|
172
|
+
- The tools do the heavy lifting (clustering, draft generation, saving)
|
|
173
|
+
- Always show the draft BEFORE saving — never auto-save without user review
|
|
174
|
+
- Skill drafts are saved to the Sights catalog as discoveries, not as local files
|
|
175
|
+
- Skills are retrievable with merlin_get_context("skill: {name}")
|
|
176
|
+
</design_notes>
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: merlin:quick
|
|
3
|
+
description: Run an ad-hoc task with Merlin guarantees but no ceremony — no plan files, no phase tracking
|
|
4
|
+
argument-hint: "\"task description\""
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Glob
|
|
8
|
+
- Grep
|
|
9
|
+
- Bash
|
|
10
|
+
- Write
|
|
11
|
+
- AskUserQuestion
|
|
12
|
+
- mcp__merlin__merlin_get_context
|
|
13
|
+
- mcp__merlin__merlin_search
|
|
14
|
+
- mcp__merlin__merlin_find_files
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<objective>
|
|
18
|
+
Handle ad-hoc tasks fast — no PLAN.md, no STATE.md updates, no phase ceremony.
|
|
19
|
+
|
|
20
|
+
Skips: research agents, discussion phase, plan-checking, post-execution verification.
|
|
21
|
+
Provides: Sights context injection, specialist routing, fresh 200K process, git diff review.
|
|
22
|
+
|
|
23
|
+
Perfect for: bug fixes, small features, one-off tasks, config changes, experiments.
|
|
24
|
+
Use the full workflow (`/merlin:plan-phase` + `/merlin:execute-plan`) for anything that touches core architecture or spans multiple files significantly.
|
|
25
|
+
|
|
26
|
+
Estimated 40-50% token reduction vs full workflow.
|
|
27
|
+
</objective>
|
|
28
|
+
|
|
29
|
+
<context>
|
|
30
|
+
User's task: $ARGUMENTS
|
|
31
|
+
</context>
|
|
32
|
+
|
|
33
|
+
<process>
|
|
34
|
+
|
|
35
|
+
## Step 1: Parse Task
|
|
36
|
+
|
|
37
|
+
Extract task description from $ARGUMENTS (the quoted string).
|
|
38
|
+
|
|
39
|
+
If no arguments provided:
|
|
40
|
+
```
|
|
41
|
+
Usage: /merlin:quick "task description"
|
|
42
|
+
|
|
43
|
+
Examples:
|
|
44
|
+
/merlin:quick "add dark mode toggle to settings page"
|
|
45
|
+
/merlin:quick "fix the 404 on /api/users when id is missing"
|
|
46
|
+
/merlin:quick "write tests for the auth middleware"
|
|
47
|
+
/merlin:quick "update README with new env vars"
|
|
48
|
+
```
|
|
49
|
+
Exit.
|
|
50
|
+
|
|
51
|
+
## Step 2: Get Sights Context
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Call: merlin_get_context
|
|
55
|
+
Task: "{task-description}"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Store as SIGHTS_CONTEXT. If unavailable, use Glob, Grep, and Read to discover relevant files manually.
|
|
59
|
+
|
|
60
|
+
## Step 3: Determine Best Agent
|
|
61
|
+
|
|
62
|
+
Route based on task description keywords:
|
|
63
|
+
|
|
64
|
+
| Task type | Agent |
|
|
65
|
+
|-----------|-------|
|
|
66
|
+
| Code, feature, fix, refactor, implement, add, change, update (code) | `implementation-dev` |
|
|
67
|
+
| Test, spec, coverage, unit, integration, e2e | `tests-qa` |
|
|
68
|
+
| Docs, README, comment, document, explain | `docs-keeper` |
|
|
69
|
+
| Debug, error, crash, broken, failing, investigate | `merlin-debugger` |
|
|
70
|
+
| API design, endpoint, schema, contract | `merlin-api-designer` |
|
|
71
|
+
| Performance, slow, optimize, bottleneck | `merlin-performance` |
|
|
72
|
+
| Frontend, UI, component, styling, CSS | `merlin-frontend` |
|
|
73
|
+
| Migration, schema change, data | `merlin-migrator` |
|
|
74
|
+
| Security, vulnerability, auth, permissions | `merlin-security` |
|
|
75
|
+
|
|
76
|
+
If unclear, default to `implementation-dev`.
|
|
77
|
+
|
|
78
|
+
State the chosen agent and why, one line.
|
|
79
|
+
|
|
80
|
+
## Step 4: Clarify If Needed
|
|
81
|
+
|
|
82
|
+
If the task is ambiguous in a way that would cause the agent to make wrong assumptions, ask ONE focused question using AskUserQuestion.
|
|
83
|
+
|
|
84
|
+
Examples of good clarifying questions:
|
|
85
|
+
- "Should this update the existing endpoint or create a new one?"
|
|
86
|
+
- "Is this for the frontend or backend auth layer?"
|
|
87
|
+
|
|
88
|
+
If the task is clear, skip this step and note: "Task is clear — spawning {agent} directly."
|
|
89
|
+
|
|
90
|
+
## Step 5: Spawn Fresh Agent
|
|
91
|
+
|
|
92
|
+
Write a handoff file and spawn the specialist in a fresh 200K context.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
HANDOFF_DIR="/tmp/merlin-quick-$$"
|
|
96
|
+
mkdir -p "$HANDOFF_DIR"
|
|
97
|
+
HANDOFF_FILE="$HANDOFF_DIR/handoff.md"
|
|
98
|
+
RESULT_FILE="$HANDOFF_DIR/result.md"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Write handoff content:
|
|
102
|
+
|
|
103
|
+
```markdown
|
|
104
|
+
# Quick Task Handoff
|
|
105
|
+
|
|
106
|
+
## Your Task
|
|
107
|
+
{task-description}
|
|
108
|
+
|
|
109
|
+
## Mode
|
|
110
|
+
automated — make reasonable assumptions. Do NOT output CHECKPOINT_NEEDED.
|
|
111
|
+
State any assumptions you made at the end.
|
|
112
|
+
|
|
113
|
+
## Merlin Sights Context
|
|
114
|
+
{SIGHTS_CONTEXT}
|
|
115
|
+
|
|
116
|
+
## Constraints
|
|
117
|
+
- This is a quick task — scope to what's described, no more
|
|
118
|
+
- Prefer targeted changes over broad refactors
|
|
119
|
+
- If you discover something bigger that needs attention, note it in Decisions but do NOT fix it
|
|
120
|
+
- Commit your changes when done with a clear conventional commit message
|
|
121
|
+
|
|
122
|
+
## Result Protocol
|
|
123
|
+
When done, output this exact block at the END of your response:
|
|
124
|
+
|
|
125
|
+
---QUICK_RESULT---
|
|
126
|
+
Status: completed | error
|
|
127
|
+
Summary: <2-3 sentence summary of what you did>
|
|
128
|
+
Files-Changed: <comma-separated list of files modified>
|
|
129
|
+
Decisions: <key decisions and assumptions, one per line>
|
|
130
|
+
Follow-Up: <anything bigger discovered that needs attention, one per line>
|
|
131
|
+
---END_QUICK_RESULT---
|
|
132
|
+
|
|
133
|
+
Also write a detailed result to: {RESULT_FILE}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Spawn:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
unset CLAUDECODE && cat "$HANDOFF_FILE" | claude \
|
|
140
|
+
--agent {agent-name} \
|
|
141
|
+
-p \
|
|
142
|
+
--permission-mode acceptEdits \
|
|
143
|
+
--output-format text \
|
|
144
|
+
2>&1
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Use Bash tool with `timeout: 600000` (10 minutes max).
|
|
148
|
+
|
|
149
|
+
## Step 6: Review Changes
|
|
150
|
+
|
|
151
|
+
After the agent completes:
|
|
152
|
+
|
|
153
|
+
1. Parse the `---QUICK_RESULT---` block from output.
|
|
154
|
+
2. Run a quick git diff review:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
git diff --stat HEAD 2>/dev/null
|
|
158
|
+
git diff HEAD 2>/dev/null | head -100
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
3. Check exit code — non-zero means error; show output and offer retry.
|
|
162
|
+
|
|
163
|
+
4. Clean up:
|
|
164
|
+
```bash
|
|
165
|
+
rm -rf "$HANDOFF_DIR"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Step 7: Present Result
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
════════════════════════════════════════
|
|
172
|
+
Quick Task — {agent-name} completed
|
|
173
|
+
════════════════════════════════════════
|
|
174
|
+
|
|
175
|
+
{summary from result}
|
|
176
|
+
|
|
177
|
+
Files changed:
|
|
178
|
+
{files-changed list}
|
|
179
|
+
|
|
180
|
+
Decisions / Assumptions:
|
|
181
|
+
{decisions from result}
|
|
182
|
+
|
|
183
|
+
{If follow-up items exist:}
|
|
184
|
+
Noticed (not fixed):
|
|
185
|
+
{follow-up items — these may warrant a full workflow}
|
|
186
|
+
|
|
187
|
+
────────────────────────────────────────
|
|
188
|
+
Looks good? Run: git add -p && git commit
|
|
189
|
+
Or discard: git checkout .
|
|
190
|
+
────────────────────────────────────────
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
If any follow-up items were surfaced, suggest:
|
|
194
|
+
```
|
|
195
|
+
For larger work found above, consider:
|
|
196
|
+
/merlin:plan-phase — full workflow with planning + execution
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
</process>
|
|
200
|
+
|
|
201
|
+
<agent_selection_notes>
|
|
202
|
+
- `implementation-dev` handles the vast majority of quick code tasks
|
|
203
|
+
- Only switch to a specialist if the task is clearly domain-specific
|
|
204
|
+
- When in doubt, `implementation-dev` is the right default — it knows to call other agents if needed
|
|
205
|
+
- Never spawn `merlin-planner`, `system-architect`, or `product-spec` for quick tasks — those are for full workflow phases
|
|
206
|
+
</agent_selection_notes>
|
|
207
|
+
|
|
208
|
+
<error_handling>
|
|
209
|
+
|
|
210
|
+
| Condition | Action |
|
|
211
|
+
|-----------|--------|
|
|
212
|
+
| No arguments | Show usage examples, exit |
|
|
213
|
+
| Sights unavailable | Proceed with manual discovery via Glob/Grep |
|
|
214
|
+
| Agent not found | Default to `implementation-dev` |
|
|
215
|
+
| Spawn fails (exit != 0) | Show error output, offer retry or `/merlin:debug` |
|
|
216
|
+
| Spawn times out (>10 min) | Warn: task too large for quick mode, suggest full workflow |
|
|
217
|
+
| No result block in output | Treat full output as summary, still run git diff review |
|
|
218
|
+
| Nothing changed in git | Note: agent may have analyzed only — confirm with user |
|
|
219
|
+
|
|
220
|
+
</error_handling>
|
|
221
|
+
|
|
222
|
+
<design_notes>
|
|
223
|
+
- NEVER use Task() — it shares parent context, not true isolation
|
|
224
|
+
- ALWAYS use `claude --agent <name> -p` via Bash — true fresh process
|
|
225
|
+
- No PLAN.md written — that's the whole point of quick mode
|
|
226
|
+
- No STATE.md update — quick tasks are ephemeral by design
|
|
227
|
+
- The git diff IS the verification — no formal verify-work agent
|
|
228
|
+
- For anything that feels like it needs a plan, redirect to the full workflow
|
|
229
|
+
</design_notes>
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: merlin:readiness-gate
|
|
3
|
+
description: Validate planning completeness before implementation begins
|
|
4
|
+
argument-hint: "<phase-number>"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Bash
|
|
8
|
+
- Grep
|
|
9
|
+
- Glob
|
|
10
|
+
- mcp__merlin__merlin_get_context
|
|
11
|
+
- mcp__merlin__merlin_get_project_status
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<objective>
|
|
15
|
+
Validate that planning artifacts are complete and coherent before any implementation begins.
|
|
16
|
+
|
|
17
|
+
Prevents the #1 failure mode: starting to code with incomplete, ambiguous, or uncovered specs.
|
|
18
|
+
|
|
19
|
+
Runs 6 checks and returns a READY / NEEDS WORK / NOT READY verdict with specific issues to fix.
|
|
20
|
+
</objective>
|
|
21
|
+
|
|
22
|
+
<process>
|
|
23
|
+
|
|
24
|
+
## Step 1: Parse Arguments
|
|
25
|
+
|
|
26
|
+
Extract from $ARGUMENTS:
|
|
27
|
+
- **phase**: Phase number (e.g., "4", "2.1") — or "current" to auto-detect from STATE.md
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# If "current" or empty, read current phase from STATE
|
|
31
|
+
head -30 .planning/STATE.md 2>/dev/null
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Resolve phase name from ROADMAP.md:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
grep -A 5 "Phase ${PHASE_NUM}" .planning/ROADMAP.md 2>/dev/null | head -6
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Step 2: Document Discovery
|
|
41
|
+
|
|
42
|
+
Check that required planning documents exist. Record each as present (✅) or missing (❌).
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
ls .planning/PROJECT.md 2>/dev/null
|
|
46
|
+
ls .planning/ROADMAP.md 2>/dev/null
|
|
47
|
+
ls .planning/REQUIREMENTS.md 2>/dev/null
|
|
48
|
+
ls .planning/phases/${PHASE_DIR}/*-PLAN.md 2>/dev/null
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Track:
|
|
52
|
+
- `doc_project`: present or missing
|
|
53
|
+
- `doc_roadmap`: present or missing
|
|
54
|
+
- `doc_requirements`: present or missing
|
|
55
|
+
- `plan_count`: number of PLAN.md files found for the phase
|
|
56
|
+
|
|
57
|
+
If `doc_project`, `doc_roadmap`, and `doc_requirements` are all missing: emit **NOT READY** immediately — planning has not started. Skip remaining steps.
|
|
58
|
+
|
|
59
|
+
## Step 3: Requirements Analysis
|
|
60
|
+
|
|
61
|
+
Read `.planning/REQUIREMENTS.md`. For each requirement, check:
|
|
62
|
+
|
|
63
|
+
1. Has at least one explicit acceptance criterion (a testable condition — not a vague goal)
|
|
64
|
+
2. Does not contain ambiguous modal verbs: "should", "might", "could", "may"
|
|
65
|
+
3. Is expressed as a testable condition (something that can pass or fail a test)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
grep -n "should\|might\|could\| may " .planning/REQUIREMENTS.md 2>/dev/null
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Track:
|
|
72
|
+
- `req_total`: total requirements found
|
|
73
|
+
- `req_testable`: requirements that meet all three conditions
|
|
74
|
+
- `req_ambiguous`: list of requirement IDs / lines with vague language
|
|
75
|
+
|
|
76
|
+
Result label: `{req_testable}/{req_total} requirements are testable`
|
|
77
|
+
|
|
78
|
+
## Step 4: Plan Coverage
|
|
79
|
+
|
|
80
|
+
Cross-reference PLAN.md task descriptions against requirement IDs in REQUIREMENTS.md.
|
|
81
|
+
|
|
82
|
+
For each requirement ID (e.g., R-4.1, R-4.2), check whether at least one PLAN.md file references or addresses it — either by ID or by matching keyword.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# List requirement IDs
|
|
86
|
+
grep -E "^R-[0-9]" .planning/REQUIREMENTS.md 2>/dev/null
|
|
87
|
+
|
|
88
|
+
# Check plan files for coverage
|
|
89
|
+
grep -l "${REQ_ID}" .planning/phases/${PHASE_DIR}/*-PLAN.md 2>/dev/null
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Track:
|
|
93
|
+
- `covered_reqs`: requirements mentioned in at least one plan
|
|
94
|
+
- `uncovered_reqs`: requirements with no matching plan task (list them)
|
|
95
|
+
|
|
96
|
+
Result label: flag each uncovered requirement by ID.
|
|
97
|
+
|
|
98
|
+
## Step 5: Dependency Check
|
|
99
|
+
|
|
100
|
+
Verify upstream phases are complete and external dependencies are documented.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Check that all prior phases have SUMMARY.md
|
|
104
|
+
for prev_phase in all phases numbered below current; do
|
|
105
|
+
ls .planning/phases/${prev_phase_dir}/*-SUMMARY.md 2>/dev/null
|
|
106
|
+
done
|
|
107
|
+
|
|
108
|
+
# Check STATE.md for documented external dependencies
|
|
109
|
+
grep -i "depend\|external\|blocker\|prerequisite" .planning/STATE.md 2>/dev/null
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Track:
|
|
113
|
+
- `prior_phases_complete`: all prior phases have at least one SUMMARY.md (true/false)
|
|
114
|
+
- `missing_summaries`: list of prior phase directories with no SUMMARY.md
|
|
115
|
+
- `external_deps_noted`: whether dependencies section exists in STATE.md
|
|
116
|
+
|
|
117
|
+
## Step 6: Plan Quality
|
|
118
|
+
|
|
119
|
+
For each PLAN.md in the phase, check:
|
|
120
|
+
|
|
121
|
+
1. Has a non-empty `<objective>` section
|
|
122
|
+
2. Has at least one explicit success criterion
|
|
123
|
+
3. References specific file paths (not just vague descriptions like "update the code")
|
|
124
|
+
4. Scope is reasonable — fewer than 15 distinct tasks in one plan
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Read each PLAN.md for the phase
|
|
128
|
+
for plan in .planning/phases/${PHASE_DIR}/*-PLAN.md; do
|
|
129
|
+
grep -c "<objective>" "$plan" 2>/dev/null
|
|
130
|
+
grep -i "success.criteria\|acceptance\|done when" "$plan" 2>/dev/null
|
|
131
|
+
grep -E "\.(ts|js|py|go|md|json|yaml|sh)" "$plan" 2>/dev/null | wc -l
|
|
132
|
+
done
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Track per plan:
|
|
136
|
+
- `has_objective`: true/false
|
|
137
|
+
- `has_success_criteria`: true/false
|
|
138
|
+
- `has_file_refs`: true/false
|
|
139
|
+
- `quality_issues`: list of specific deficiencies per plan name
|
|
140
|
+
|
|
141
|
+
## Step 7: Final Assessment
|
|
142
|
+
|
|
143
|
+
Compute verdict:
|
|
144
|
+
|
|
145
|
+
| Condition | Verdict |
|
|
146
|
+
|-----------|---------|
|
|
147
|
+
| Any required doc missing | NOT READY |
|
|
148
|
+
| Prior phases incomplete | NOT READY |
|
|
149
|
+
| req_testable < 50% of req_total | NOT READY |
|
|
150
|
+
| 1–2 uncovered requirements OR plan quality issues | NEEDS WORK |
|
|
151
|
+
| All checks pass | READY |
|
|
152
|
+
|
|
153
|
+
Collect all issues into a numbered list.
|
|
154
|
+
|
|
155
|
+
Present the full report:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
🔮 **Readiness Gate** · Phase {N}: {Phase Name}
|
|
159
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
160
|
+
|
|
161
|
+
{icon} Document Discovery — {summary}
|
|
162
|
+
{icon} Requirements Analysis — {req_testable}/{req_total} requirements are testable
|
|
163
|
+
{icon} Plan Coverage — {covered}/{total} requirements addressed
|
|
164
|
+
{icon} Dependency Check — {prior phases summary}
|
|
165
|
+
{icon} Plan Quality — {plan_count} plans, {quality_summary}
|
|
166
|
+
{icon} Final Assessment — {READY | NEEDS WORK | NOT READY}
|
|
167
|
+
|
|
168
|
+
### Issues to Address:
|
|
169
|
+
{numbered list of specific issues — omit if READY}
|
|
170
|
+
|
|
171
|
+
### Verdict: {icon} {READY | NEEDS WORK | NOT READY}
|
|
172
|
+
{one-line action — e.g., "Fix 2 issues before executing." or "You're clear to start."}
|
|
173
|
+
|
|
174
|
+
[1] Fix issues and re-check
|
|
175
|
+
[2] Execute anyway (not recommended — only shown for NEEDS WORK)
|
|
176
|
+
[3] See per-plan detail
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Icons: ✅ pass · ⚠️ warn · ❌ fail
|
|
180
|
+
|
|
181
|
+
For READY: do not show options [1] and [2]. Offer only:
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
[1] Execute phase: /merlin:execute-phase {N}
|
|
185
|
+
[2] See per-plan detail
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
</process>
|
|
189
|
+
|
|
190
|
+
<critical_rules>
|
|
191
|
+
|
|
192
|
+
**READ, DO NOT MODIFY.** This command never writes or edits planning files. It reports only.
|
|
193
|
+
|
|
194
|
+
**BE SPECIFIC.** Every issue in the Issues list must name the exact file, requirement ID, or plan that needs attention.
|
|
195
|
+
|
|
196
|
+
**FAIL FAST.** If all required docs are missing, emit NOT READY after Step 2 and stop.
|
|
197
|
+
|
|
198
|
+
**DO NOT BLOCK UNCONDITIONALLY.** NEEDS WORK means improvable — still offer an override path. Only NOT READY hard-stops execution.
|
|
199
|
+
|
|
200
|
+
</critical_rules>
|
|
201
|
+
|
|
202
|
+
<success_criteria>
|
|
203
|
+
- [ ] Phase resolved from args or STATE.md
|
|
204
|
+
- [ ] All 6 checks executed and reported
|
|
205
|
+
- [ ] Specific issues listed by file/ID (no vague feedback)
|
|
206
|
+
- [ ] Correct verdict emitted (READY / NEEDS WORK / NOT READY)
|
|
207
|
+
- [ ] Next steps offered based on verdict
|
|
208
|
+
</success_criteria>
|
|
@@ -117,7 +117,7 @@ Write to: .planning/phases/{phase}-{slug}/{phase}-RESEARCH.md
|
|
|
117
117
|
|
|
118
118
|
```
|
|
119
119
|
## Spawn fresh researcher process via Bash:
|
|
120
|
-
cat "$HANDOFF_DIR/handoff.md" | claude \
|
|
120
|
+
unset CLAUDECODE && cat "$HANDOFF_DIR/handoff.md" | claude \
|
|
121
121
|
--agent merlin-researcher \
|
|
122
122
|
-p \
|
|
123
123
|
--permission-mode acceptEdits \
|
|
@@ -152,7 +152,7 @@ Research file: @.planning/phases/{phase}-{slug}/{phase}-RESEARCH.md
|
|
|
152
152
|
|
|
153
153
|
```
|
|
154
154
|
## Spawn fresh continuation process via Bash:
|
|
155
|
-
cat "$HANDOFF_DIR/continuation.md" | claude \
|
|
155
|
+
unset CLAUDECODE && cat "$HANDOFF_DIR/continuation.md" | claude \
|
|
156
156
|
--agent merlin-researcher \
|
|
157
157
|
-p \
|
|
158
158
|
--permission-mode acceptEdits \
|
|
@@ -71,7 +71,7 @@ Spawn all 4 in parallel with rich context:
|
|
|
71
71
|
|
|
72
72
|
```
|
|
73
73
|
## Spawn fresh researcher via Bash:
|
|
74
|
-
## Write the following to a handoff file, then: cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
74
|
+
## Write the following to a handoff file, then: unset CLAUDECODE && cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
75
75
|
## Handoff content:
|
|
76
76
|
# "
|
|
77
77
|
<research_type>
|
|
@@ -113,7 +113,7 @@ Use template: ~/.claude/merlin/templates/research-project/STACK.md
|
|
|
113
113
|
## End of Stack research handoff
|
|
114
114
|
|
|
115
115
|
## Spawn fresh researcher via Bash:
|
|
116
|
-
## Write the following to a handoff file, then: cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
116
|
+
## Write the following to a handoff file, then: unset CLAUDECODE && cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
117
117
|
## Handoff content:
|
|
118
118
|
# "
|
|
119
119
|
<research_type>
|
|
@@ -155,7 +155,7 @@ Use template: ~/.claude/merlin/templates/research-project/FEATURES.md
|
|
|
155
155
|
## End of Features research handoff
|
|
156
156
|
|
|
157
157
|
## Spawn fresh researcher via Bash:
|
|
158
|
-
## Write the following to a handoff file, then: cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
158
|
+
## Write the following to a handoff file, then: unset CLAUDECODE && cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
159
159
|
## Handoff content:
|
|
160
160
|
# "
|
|
161
161
|
<research_type>
|
|
@@ -197,7 +197,7 @@ Use template: ~/.claude/merlin/templates/research-project/ARCHITECTURE.md
|
|
|
197
197
|
## End of Architecture research handoff
|
|
198
198
|
|
|
199
199
|
## Spawn fresh researcher via Bash:
|
|
200
|
-
## Write the following to a handoff file, then: cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
200
|
+
## Write the following to a handoff file, then: unset CLAUDECODE && cat handoff.md | claude --agent merlin-researcher -p --permission-mode acceptEdits --output-format text
|
|
201
201
|
## Handoff content:
|
|
202
202
|
# "
|
|
203
203
|
<research_type>
|