create-merlin-brain 3.8.2 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/bin/install.cjs +126 -21
  2. package/dist/server/api/client.d.ts.map +1 -1
  3. package/dist/server/api/client.js +11 -7
  4. package/dist/server/api/client.js.map +1 -1
  5. package/dist/server/cost/classifier.d.ts +22 -0
  6. package/dist/server/cost/classifier.d.ts.map +1 -0
  7. package/dist/server/cost/classifier.js +137 -0
  8. package/dist/server/cost/classifier.js.map +1 -0
  9. package/dist/server/cost/tracker.d.ts +34 -0
  10. package/dist/server/cost/tracker.d.ts.map +1 -0
  11. package/dist/server/cost/tracker.js +81 -0
  12. package/dist/server/cost/tracker.js.map +1 -0
  13. package/dist/server/lang/detector.d.ts +17 -0
  14. package/dist/server/lang/detector.d.ts.map +1 -0
  15. package/dist/server/lang/detector.js +144 -0
  16. package/dist/server/lang/detector.js.map +1 -0
  17. package/dist/server/lang/rules.d.ts +21 -0
  18. package/dist/server/lang/rules.d.ts.map +1 -0
  19. package/dist/server/lang/rules.js +70 -0
  20. package/dist/server/lang/rules.js.map +1 -0
  21. package/dist/server/server.d.ts.map +1 -1
  22. package/dist/server/server.js +74 -26
  23. package/dist/server/server.js.map +1 -1
  24. package/dist/server/tools/adaptive.d.ts.map +1 -1
  25. package/dist/server/tools/adaptive.js +2 -1
  26. package/dist/server/tools/adaptive.js.map +1 -1
  27. package/dist/server/tools/agents-index.d.ts.map +1 -1
  28. package/dist/server/tools/agents-index.js +6 -3
  29. package/dist/server/tools/agents-index.js.map +1 -1
  30. package/dist/server/tools/agents.d.ts.map +1 -1
  31. package/dist/server/tools/agents.js +10 -5
  32. package/dist/server/tools/agents.js.map +1 -1
  33. package/dist/server/tools/auto-teach.d.ts.map +1 -1
  34. package/dist/server/tools/auto-teach.js +2 -1
  35. package/dist/server/tools/auto-teach.js.map +1 -1
  36. package/dist/server/tools/behaviors.d.ts.map +1 -1
  37. package/dist/server/tools/behaviors.js +8 -4
  38. package/dist/server/tools/behaviors.js.map +1 -1
  39. package/dist/server/tools/config-sync.d.ts.map +1 -1
  40. package/dist/server/tools/config-sync.js +8 -4
  41. package/dist/server/tools/config-sync.js.map +1 -1
  42. package/dist/server/tools/context.d.ts.map +1 -1
  43. package/dist/server/tools/context.js +66 -7
  44. package/dist/server/tools/context.js.map +1 -1
  45. package/dist/server/tools/cost.d.ts +7 -0
  46. package/dist/server/tools/cost.d.ts.map +1 -0
  47. package/dist/server/tools/cost.js +53 -0
  48. package/dist/server/tools/cost.js.map +1 -0
  49. package/dist/server/tools/discoveries.d.ts.map +1 -1
  50. package/dist/server/tools/discoveries.js +8 -11
  51. package/dist/server/tools/discoveries.js.map +1 -1
  52. package/dist/server/tools/lite.d.ts.map +1 -1
  53. package/dist/server/tools/lite.js +8 -4
  54. package/dist/server/tools/lite.js.map +1 -1
  55. package/dist/server/tools/project.d.ts.map +1 -1
  56. package/dist/server/tools/project.js +14 -7
  57. package/dist/server/tools/project.js.map +1 -1
  58. package/dist/server/tools/route.d.ts.map +1 -1
  59. package/dist/server/tools/route.js +145 -31
  60. package/dist/server/tools/route.js.map +1 -1
  61. package/dist/server/tools/sights-index.d.ts.map +1 -1
  62. package/dist/server/tools/sights-index.js +4 -2
  63. package/dist/server/tools/sights-index.js.map +1 -1
  64. package/dist/server/tools/smart-route.d.ts +12 -0
  65. package/dist/server/tools/smart-route.d.ts.map +1 -0
  66. package/dist/server/tools/smart-route.js +156 -0
  67. package/dist/server/tools/smart-route.js.map +1 -0
  68. package/dist/server/tools/verification.d.ts.map +1 -1
  69. package/dist/server/tools/verification.js +2 -1
  70. package/dist/server/tools/verification.js.map +1 -1
  71. package/files/agents/code-organization-supervisor.md +1 -0
  72. package/files/agents/context-guardian.md +1 -0
  73. package/files/agents/docs-keeper.md +1 -0
  74. package/files/agents/dry-refactor.md +1 -0
  75. package/files/agents/elite-code-refactorer.md +1 -0
  76. package/files/agents/hardening-guard.md +1 -0
  77. package/files/agents/implementation-dev.md +1 -0
  78. package/files/agents/merlin-api-designer.md +1 -0
  79. package/files/agents/merlin-codebase-mapper.md +4 -0
  80. package/files/agents/merlin-debugger.md +1 -0
  81. package/files/agents/merlin-executor.md +1 -0
  82. package/files/agents/merlin-frontend.md +1 -0
  83. package/files/agents/merlin-integration-checker.md +1 -0
  84. package/files/agents/merlin-migrator.md +1 -0
  85. package/files/agents/merlin-milestone-auditor.md +1 -0
  86. package/files/agents/merlin-performance.md +1 -0
  87. package/files/agents/merlin-planner.md +1 -0
  88. package/files/agents/merlin-researcher.md +4 -0
  89. package/files/agents/merlin-reviewer.md +1 -0
  90. package/files/agents/merlin-security.md +1 -0
  91. package/files/agents/merlin-verifier.md +1 -0
  92. package/files/agents/merlin-work-verifier.md +1 -0
  93. package/files/agents/merlin.md +19 -3
  94. package/files/agents/ops-railway.md +1 -0
  95. package/files/agents/orchestrator-retrofit.md +1 -0
  96. package/files/agents/product-spec.md +1 -0
  97. package/files/agents/remotion.md +1 -0
  98. package/files/agents/system-architect.md +1 -0
  99. package/files/agents/tests-qa.md +1 -0
  100. package/files/commands/merlin/help.md +11 -0
  101. package/files/commands/merlin/loop-recipes.md +73 -0
  102. package/files/hooks/agent-sync.sh +3 -0
  103. package/files/hooks/check-file-size.sh +12 -0
  104. package/files/hooks/config-change.sh +43 -0
  105. package/files/hooks/instructions-loaded.sh +34 -0
  106. package/files/hooks/session-start.sh +52 -2
  107. package/files/hooks/worktree-create.sh +44 -0
  108. package/files/hooks/worktree-remove.sh +36 -0
  109. package/files/loop/lib/agents.sh +3 -0
  110. package/files/loop/lib/blend-handoff.sh +3 -0
  111. package/files/loop/lib/blend-learn.sh +3 -0
  112. package/files/loop/lib/blend-parallel.sh +3 -0
  113. package/files/loop/lib/blend-verify.sh +3 -0
  114. package/files/loop/lib/blend.sh +3 -0
  115. package/files/loop/lib/boot.sh +3 -0
  116. package/files/loop/lib/context.sh +3 -0
  117. package/files/loop/lib/discuss.sh +3 -0
  118. package/files/loop/lib/modes.sh +3 -0
  119. package/files/loop/lib/progress.sh +3 -0
  120. package/files/loop/lib/safety.sh +3 -0
  121. package/files/loop/lib/session-end.sh +3 -0
  122. package/files/loop/lib/sights.sh +3 -0
  123. package/files/loop/lib/state.sh +3 -0
  124. package/files/loop/lib/teams.sh +3 -0
  125. package/files/loop/lib/timeout.sh +3 -0
  126. package/files/loop/lib/tui.sh +3 -0
  127. package/files/loop/lib/workflow-gen.sh +3 -0
  128. package/files/loop/lib/workflow-run.sh +3 -0
  129. package/files/loop/lib/workflow.sh +3 -0
  130. package/files/loop/merlin-loop.sh +3 -0
  131. package/files/loop/merlin-session.sh +3 -0
  132. package/package.json +2 -1
  133. package/rules/go.md +38 -0
  134. package/rules/java.md +36 -0
  135. package/rules/python.md +38 -0
  136. package/rules/rust.md +34 -0
  137. package/rules/swift.md +35 -0
  138. package/rules/typescript.md +38 -0
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: merlin:loop-recipes
3
+ description: Show pre-built /loop patterns for common Merlin workflows
4
+ ---
5
+
6
+ <objective>
7
+ Display pre-built `/loop` recipes for common Merlin workflows.
8
+
9
+ Output ONLY the reference content below. Do NOT add:
10
+
11
+ - Project-specific analysis
12
+ - Git status or file context
13
+ - Next-step suggestions
14
+ - Any commentary beyond the reference
15
+ </objective>
16
+
17
+ <reference>
18
+ # Merlin Loop Recipes
19
+
20
+ Pre-built `/loop` patterns for common Merlin workflows. Copy and use directly.
21
+
22
+ ## Development Monitoring
23
+
24
+ - `/loop 5m /merlin:progress` — Check project progress every 5 minutes
25
+ - `/loop 2m check build status and report any failures` — CI monitoring
26
+ - `/loop 10m /merlin:standup` — Running standup summary
27
+ - `/loop 15m check if any new errors appeared in the logs` — Log monitoring
28
+
29
+ ## Code Quality
30
+
31
+ - `/loop 30m scan for files over 400 lines and list them` — File size monitoring
32
+ - `/loop 1h review recent changes for security issues` — Security patrol
33
+ - `/loop 4h check if documentation is up to date with recent code changes` — Doc freshness
34
+ - `/loop 2h scan for duplicate code or functions that do the same thing` — DRY check
35
+
36
+ ## Sights & Context
37
+
38
+ - `/loop 30m merlin_get_context("current work progress")` — Keep Sights context warm
39
+ - `/loop 1h merlin_lite_refresh()` — Refresh local Sights analysis
40
+ - `/loop 6h run /merlin:map-codebase to keep codebase index fresh` — Index freshness
41
+
42
+ ## Deployment
43
+
44
+ - `/loop 2m check Railway deployment status` — Deploy monitoring
45
+ - `/loop 5m check if PR checks have passed` — PR monitoring
46
+ - `/loop 10m check if the staging environment is healthy` — Staging health
47
+
48
+ ## Planning & Todos
49
+
50
+ - `/loop 1h /merlin:check-todos and summarize what's pending` — Todo awareness
51
+ - `/loop 24h /merlin:standup and create a brief daily summary` — Daily digest
52
+
53
+ ## Usage
54
+
55
+ Just copy any recipe above and paste it into Claude Code. Customize the interval and prompt as needed.
56
+
57
+ ```
58
+ /loop 5m /merlin:progress
59
+ ```
60
+
61
+ Native `/loop` features:
62
+ - Supports natural language intervals (e.g., "every 5 minutes", "5m", "2h")
63
+ - Default interval: 10 minutes
64
+ - Auto-expires after 3 days
65
+ - Session-scoped (lives in your active session)
66
+ - Can run any slash command or natural language prompt
67
+
68
+ ## Tips
69
+
70
+ - Combine with `/merlin:progress` for a live project dashboard
71
+ - Use shorter intervals (2-5m) during active deploys, longer (1h+) for background monitoring
72
+ - Chain recipes: let one loop inform what the next one checks
73
+ </reference>
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # Merlin Hook: Agent Sync (SessionStart, background)
3
3
  # Checks installed agents freshness and updates from cloud. Max once/hour.
4
+ #
5
+ # ASYNC: This hook should be registered as async (non-blocking)
6
+ # Claude Code supports async hooks — register this one as background
4
7
  set -euo pipefail
5
8
  trap 'echo "{}"; exit 0' ERR
6
9
 
@@ -4,9 +4,21 @@
4
4
  # Checks if the modified file exceeds the 400-line convention.
5
5
  # Exits with code 2 to inject feedback when file is too large.
6
6
  #
7
+ # Agent-type awareness: docs-keeper and merlin-verifier agents are exempt
8
+ # from the 400-line limit (they work with doc/verification files).
9
+ #
7
10
  set -euo pipefail
8
11
  trap 'echo "{}"; exit 0' ERR
9
12
 
13
+ # Check agent type — skip enforcement for non-implementation agents
14
+ AGENT_TYPE="${CLAUDE_AGENT_TYPE:-${CLAUDE_CODE_AGENT_TYPE:-main}}"
15
+ case "$AGENT_TYPE" in
16
+ docs-keeper|merlin-verifier)
17
+ echo '{}'
18
+ exit 0
19
+ ;;
20
+ esac
21
+
10
22
  # Read tool input from stdin (Claude Code pipes JSON)
11
23
  input=""
12
24
  if [ ! -t 0 ]; then
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Merlin Hook: ConfigChange
4
+ # Purpose: Validate Merlin MCP key still works after config change.
5
+ # Also logs config changes to Sights for enterprise audit trail.
6
+ #
7
+ # Always exits 0 — never blocks Claude Code.
8
+ #
9
+ set -euo pipefail
10
+ trap 'echo "{}"; exit 0' ERR
11
+
12
+ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+
14
+ # Source shared libs if available
15
+ [ -f "${HOOK_DIR}/lib/analytics.sh" ] && . "${HOOK_DIR}/lib/analytics.sh"
16
+
17
+ MERLIN_API_KEY="${MERLIN_API_KEY:-}"
18
+ AGENT_ID="${CLAUDE_AGENT_ID:-unknown}"
19
+ AGENT_TYPE="${CLAUDE_AGENT_TYPE:-main}"
20
+
21
+ # Log config change event if analytics available
22
+ if declare -f log_event >/dev/null 2>&1; then
23
+ log_event "config_change" "$(printf '{"agent_id":"%s","agent_type":"%s","has_key":"%s"}' "$AGENT_ID" "$AGENT_TYPE" "$([ -n "$MERLIN_API_KEY" ] && echo true || echo false)")"
24
+ fi
25
+
26
+ if [ -z "$MERLIN_API_KEY" ]; then
27
+ echo "Merlin: No API key configured after config change" >&2
28
+ echo '{}'
29
+ exit 0
30
+ fi
31
+
32
+ # Quick validation — check key format (valid prefixes: mrln_ or ccw_)
33
+ case "$MERLIN_API_KEY" in
34
+ mrln_*|ccw_*)
35
+ # Valid prefix — no-op
36
+ ;;
37
+ *)
38
+ echo "Merlin: API key has unexpected format after config change" >&2
39
+ ;;
40
+ esac
41
+
42
+ echo '{}'
43
+ exit 0
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Merlin Hook: InstructionsLoaded
4
+ # Purpose: Pre-warm Merlin Sights connection when CLAUDE.md loads.
5
+ # Fires BEFORE session-start, giving us a head start on context loading.
6
+ #
7
+ # Always exits 0 — never blocks Claude Code startup.
8
+ #
9
+ set -euo pipefail
10
+ trap 'echo "{}"; exit 0' ERR
11
+
12
+ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+
14
+ # Source shared libs if available
15
+ # shellcheck source=lib/analytics.sh
16
+ [ -f "${HOOK_DIR}/lib/analytics.sh" ] && . "${HOOK_DIR}/lib/analytics.sh"
17
+ # shellcheck source=lib/sights-check.sh
18
+ [ -f "${HOOK_DIR}/lib/sights-check.sh" ] && . "${HOOK_DIR}/lib/sights-check.sh"
19
+
20
+ # Log agent context if available
21
+ AGENT_ID="${CLAUDE_AGENT_ID:-unknown}"
22
+ AGENT_TYPE="${CLAUDE_AGENT_TYPE:-main}"
23
+
24
+ # Log the instructions-loaded event if analytics is available
25
+ if declare -f log_event >/dev/null 2>&1; then
26
+ log_event "instructions_loaded" "$(printf '{"agent_id":"%s","agent_type":"%s","cwd":"%s"}' "$AGENT_ID" "$AGENT_TYPE" "${PWD:-}")"
27
+ fi
28
+
29
+ # Signal that Merlin instructions were loaded
30
+ # The MCP server will handle actual Sights connection
31
+ echo "Merlin instructions loaded — Sights pre-warming (agent: ${AGENT_TYPE})" >&2
32
+
33
+ echo '{}'
34
+ exit 0
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env bash
2
2
  #
3
3
  # Merlin Hook: SessionStart (consolidated)
4
- # Does three things in a single hook (avoids 3x "success" messages):
4
+ # Does four things in a single hook (avoids multiple "success" messages):
5
5
  # 1. Analytics: initialize session, log start event
6
6
  # 2. Agent sync: refresh agent files from cloud (background, max once/hour)
7
+ # 2.5. Auto-update: check npm for new Merlin version (background, max once/24h)
7
8
  # 3. Context injection: output additionalContext for the session
8
9
  #
9
10
  # Always exits 0 — never blocks Claude Code startup.
@@ -75,9 +76,13 @@ _merlin_cleanup_stale &
75
76
  # shellcheck source=lib/sights-check.sh
76
77
  . "${HOOKS_DIR}/lib/sights-check.sh"
77
78
 
79
+ # Log agent context if available
80
+ AGENT_ID="${CLAUDE_AGENT_ID:-unknown}"
81
+ AGENT_TYPE="${CLAUDE_AGENT_TYPE:-main}"
82
+
78
83
  ensure_session_file
79
84
  cwd="${PWD:-$(pwd)}"
80
- log_event "session_start" "$(printf '{"cwd":"%s"}' "$cwd")"
85
+ log_event "session_start" "$(printf '{"cwd":"%s","agent_id":"%s","agent_type":"%s"}' "$cwd" "$AGENT_ID" "$AGENT_TYPE")"
81
86
 
82
87
  # Warm up Sights context in background
83
88
  if command -v merlin >/dev/null 2>&1; then
@@ -126,6 +131,51 @@ _merlin_sync_agents() {
126
131
  }
127
132
  _merlin_sync_agents &
128
133
 
134
+ # ── 2.5. Auto-update check (background, max once/24h) ─────────
135
+ # Proactively upgrades Merlin when a new version is published.
136
+ # Runs silently in background — never blocks session startup.
137
+ _merlin_auto_update() {
138
+ local merlin_dir="${HOME}/.claude/merlin"
139
+ local last_check="${merlin_dir}/.last-update-check"
140
+ local version_file="${merlin_dir}/VERSION"
141
+ local check_interval=86400 # 24 hours
142
+
143
+ [ -d "${merlin_dir}" ] || return 0
144
+
145
+ # Skip if checked within the last 24 hours
146
+ if [ -f "${last_check}" ]; then
147
+ local last
148
+ last=$(cat "${last_check}" 2>/dev/null || echo "0")
149
+ [ $(($(date +%s) - last)) -lt ${check_interval} ] && return 0
150
+ fi
151
+
152
+ # Record check time immediately (prevents parallel checks)
153
+ date +%s > "${last_check}"
154
+
155
+ # Read installed version
156
+ local installed="0.0.0"
157
+ [ -f "${version_file}" ] && installed=$(cat "${version_file}" 2>/dev/null || echo "0.0.0")
158
+
159
+ # Determine channel from version string
160
+ local channel="latest"
161
+ echo "${installed}" | grep -q "beta" && channel="beta"
162
+
163
+ # Check npm for latest version (5s timeout)
164
+ local available
165
+ available=$(npm view "create-merlin-brain@${channel}" version 2>/dev/null) || return 0
166
+ [ -z "${available}" ] && return 0
167
+
168
+ # Compare versions (simple: if they differ and available is newer)
169
+ [ "${installed}" = "${available}" ] && return 0
170
+
171
+ # Version differs — run the upgrade
172
+ echo "merlin: updating ${installed} → ${available} ..." >&2
173
+ if npx "create-merlin-brain@${channel}" --yes 2>/dev/null; then
174
+ echo "merlin: updated to v${available}. Restart Claude Code for full effect." >&2
175
+ fi
176
+ }
177
+ _merlin_auto_update &
178
+
129
179
  # ── 3. Context injection (the only stdout output) ──────────────
130
180
  # Output additionalContext JSON for Claude to see at session start.
131
181
  # Full boot instructions are in CLAUDE.md — this is a lightweight nudge.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Merlin Hook: WorktreeCreate
4
+ # Purpose: Propagate .merlin/ config into git worktrees so sub-agents
5
+ # spawned in worktrees have Sights access.
6
+ #
7
+ # Always exits 0 — never blocks Claude Code.
8
+ #
9
+ set -euo pipefail
10
+ trap 'echo "{}"; exit 0' ERR
11
+
12
+ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+
14
+ # Source shared libs if available
15
+ [ -f "${HOOK_DIR}/lib/analytics.sh" ] && . "${HOOK_DIR}/lib/analytics.sh"
16
+
17
+ WORKTREE_PATH="${CLAUDE_WORKTREE_PATH:-}"
18
+ AGENT_ID="${CLAUDE_AGENT_ID:-unknown}"
19
+ AGENT_TYPE="${CLAUDE_AGENT_TYPE:-main}"
20
+
21
+ if [ -z "$WORKTREE_PATH" ]; then
22
+ echo '{}'
23
+ exit 0
24
+ fi
25
+
26
+ # Copy Merlin config to worktree
27
+ if [ -d ".merlin" ]; then
28
+ cp -r .merlin "$WORKTREE_PATH/.merlin" 2>/dev/null || true
29
+ fi
30
+
31
+ # Copy project CLAUDE.md to worktree if not already present
32
+ if [ -f "CLAUDE.md" ] && [ ! -f "$WORKTREE_PATH/CLAUDE.md" ]; then
33
+ cp CLAUDE.md "$WORKTREE_PATH/CLAUDE.md" 2>/dev/null || true
34
+ fi
35
+
36
+ # Log event if analytics available
37
+ if declare -f log_event >/dev/null 2>&1; then
38
+ log_event "worktree_create" "$(printf '{"path":"%s","agent_id":"%s","agent_type":"%s"}' "$WORKTREE_PATH" "$AGENT_ID" "$AGENT_TYPE")"
39
+ fi
40
+
41
+ echo "Merlin: propagated config to worktree ${WORKTREE_PATH} (agent: ${AGENT_TYPE})" >&2
42
+
43
+ echo '{}'
44
+ exit 0
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Merlin Hook: WorktreeRemove
4
+ # Purpose: Cleanup Merlin state from removed worktrees.
5
+ #
6
+ # Always exits 0 — never blocks Claude Code.
7
+ #
8
+ set -euo pipefail
9
+ trap 'echo "{}"; exit 0' ERR
10
+
11
+ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+
13
+ # Source shared libs if available
14
+ [ -f "${HOOK_DIR}/lib/analytics.sh" ] && . "${HOOK_DIR}/lib/analytics.sh"
15
+
16
+ WORKTREE_PATH="${CLAUDE_WORKTREE_PATH:-}"
17
+ AGENT_ID="${CLAUDE_AGENT_ID:-unknown}"
18
+ AGENT_TYPE="${CLAUDE_AGENT_TYPE:-main}"
19
+
20
+ if [ -z "$WORKTREE_PATH" ]; then
21
+ echo '{}'
22
+ exit 0
23
+ fi
24
+
25
+ # Remove Merlin artifacts from worktree (if still present)
26
+ rm -rf "$WORKTREE_PATH/.merlin" 2>/dev/null || true
27
+
28
+ # Log event if analytics available
29
+ if declare -f log_event >/dev/null 2>&1; then
30
+ log_event "worktree_remove" "$(printf '{"path":"%s","agent_id":"%s","agent_type":"%s"}' "$WORKTREE_PATH" "$AGENT_ID" "$AGENT_TYPE")"
31
+ fi
32
+
33
+ echo "Merlin: cleaned up worktree ${WORKTREE_PATH} (agent: ${AGENT_TYPE})" >&2
34
+
35
+ echo '{}'
36
+ exit 0
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Agent Profiles & Routing
4
7
  # Task → Agent mapping based on keywords
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ BLEND ENGINE — Stage 3: Structured Handoffs ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ BLEND ENGINE — Stage 4: Blend Learning ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ BLEND ENGINE — Stage 2: Parallel Agent Execution ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ BLEND ENGINE — Stage 1: True Independent Verification ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ MERLIN BLEND ENGINE - Dynamic Agent Fusion ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Boot Sequence
4
7
  # The 5-phase Merlin Pro boot sequence that runs before every task
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Smart Context Management
4
7
  # Intelligent context loading and memory retrieval
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Discussion Mode
4
7
  # Spawns a fresh Claude session for conversation without losing loop state
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Mode Management
4
7
  # Handles automated, interactive, and hybrid loop modes
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Progress Tracking
4
7
  # Visual progress, time estimates, and reporting
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Safety Controls
4
7
  # Rate limiting, circuit breakers, and budget management
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Session End Protocol
4
7
  # Enforces commit + sync + checkpoint at every task end
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Sights Integration
4
7
  # Fetches recent changes, trajectory, and records commits
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - State Management
4
7
  # Local state + cloud sync to merlin.build
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Agent Teams Integration
4
7
  # Enables parallel specialist execution using Claude Code Agent Teams.
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Timeout Handling
4
7
  # Provides timeout with countdown for pause points, enabling AFK operation
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # Merlin Loop - Interactive TUI
4
7
  # Beautiful terminal interface for pause/continue control
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ MERLIN WORKFLOW ENGINE — Dynamic Workflow Generation ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ MERLIN WORKFLOW ENGINE — Run, Resume, Status, CLI ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ MERLIN WORKFLOW ENGINE - Core Engine ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ MERLIN LOOP - Autonomous AI Development Orchestrator ║
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env bash
2
+ # DEPRECATED: Use Claude Code's native /loop command instead.
3
+ # See /merlin:loop-recipes for pre-built patterns.
4
+ # This script is kept for backward compatibility only.
2
5
  #
3
6
  # ╔═══════════════════════════════════════════════════════════════════════════╗
4
7
  # ║ MERLIN SESSION - Interactive Deterministic Orchestrator ║
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-merlin-brain",
3
- "version": "3.8.2",
3
+ "version": "3.10.0",
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",
@@ -44,6 +44,7 @@
44
44
  "bin/",
45
45
  "dist/",
46
46
  "files/",
47
+ "rules/",
47
48
  "README.md"
48
49
  ],
49
50
  "dependencies": {
package/rules/go.md ADDED
@@ -0,0 +1,38 @@
1
+ # Go Coding Rules
2
+
3
+ ## Error Handling
4
+ - Handle every error explicitly — never discard with `_` unless truly safe (log a comment why)
5
+ - Return errors to the caller; only wrap with `fmt.Errorf("context: %w", err)` at boundaries
6
+ - Use `errors.Is` / `errors.As` for error inspection — never string comparison
7
+ - Sentinel errors as package-level `var ErrFoo = errors.New("...")` for exported error types
8
+
9
+ ## Function Design
10
+ - Accept interfaces, return structs — keeps callers flexible, keeps implementations concrete
11
+ - Context (`context.Context`) as the first parameter on every I/O and long-running function
12
+ - Short variable names in small scopes (`i`, `r`, `w`); descriptive names at package scope
13
+ - No named return values except for `(err error)` in defer-based cleanup
14
+
15
+ ## Testing
16
+ - Table-driven tests for all non-trivial functions:
17
+ ```go
18
+ tests := []struct{ name string; input X; want Y }{...}
19
+ for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {...}) }
20
+ ```
21
+ - Use `testify/assert` or standard `t.Errorf` — avoid panics in tests
22
+ - Test files in the same package (white-box) for internals, `_test` package for public API
23
+
24
+ ## Concurrency
25
+ - No global mutable state — pass dependencies explicitly or use struct fields
26
+ - `sync.Mutex` for shared state; channels for signalling and work queues
27
+ - Always check for goroutine leaks: every goroutine must have a clear exit path
28
+ - Use `errgroup` for structured goroutine coordination
29
+
30
+ ## Code Organisation
31
+ - One package per directory; package name matches directory name (no `util`, `common` packages)
32
+ - Interfaces defined in the consuming package, not the implementing one
33
+ - Constants grouped with `iota` enums; avoid magic numbers inline
34
+
35
+ ## Style
36
+ - `gofmt` always (enforced in CI)
37
+ - Comments on all exported identifiers — start with the identifier name
38
+ - Struct field tags are valid JSON-serializable when used with encoding/json
package/rules/java.md ADDED
@@ -0,0 +1,36 @@
1
+ # Java Coding Rules
2
+
3
+ ## Modern Java (16+)
4
+ - `record` for immutable data classes — eliminates boilerplate getters/equals/hashCode
5
+ - Sealed classes (`sealed interface`) for exhaustive type hierarchies
6
+ - Pattern matching (`instanceof Foo f`) over manual casts
7
+ - `switch` expressions with arrow syntax for concise pattern dispatch
8
+ - Text blocks for multi-line strings (SQL, JSON templates)
9
+
10
+ ## Collections & Streams
11
+ - Stream API for transforming collections — avoid imperative loops when streams are clearer
12
+ - `Collectors.toUnmodifiableList/Map()` for defensive copies
13
+ - Prefer `List.of()`, `Map.of()` for small literals (immutable)
14
+ - `Optional<T>` for nullable return values — never return `null` from public methods
15
+
16
+ ## Null Safety
17
+ - `Optional<T>` for methods that legitimately have no result
18
+ - `@Nullable` / `@NonNull` annotations on all public API parameters and returns
19
+ - Fail fast with `Objects.requireNonNull()` in constructors
20
+
21
+ ## Object Design
22
+ - Builder pattern for types with >3 constructor parameters (use Lombok `@Builder` or manual)
23
+ - Dependency injection via constructor — no field injection (`@Autowired` on fields)
24
+ - Interfaces for all service contracts; `Impl` suffix only for the concrete class
25
+ - Immutable by default: `final` fields, no setters on domain objects
26
+
27
+ ## Error Handling
28
+ - Checked exceptions for recoverable errors callers must handle
29
+ - Unchecked (`RuntimeException`) for programming errors and unrecoverable failures
30
+ - Never swallow exceptions with empty catch blocks
31
+ - Wrap and rethrow with context: `throw new ServiceException("failed to save user", cause)`
32
+
33
+ ## Testing
34
+ - JUnit 5 with `@DisplayName` for descriptive test names
35
+ - `@ParameterizedTest` with `@MethodSource` for table-driven tests
36
+ - Mockito for mocking dependencies; assert interactions with `verify()`