create-merlin-brain 3.8.1 → 3.9.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 (134) 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 +69 -32
  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 +76 -13
  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/verification.d.ts.map +1 -1
  65. package/dist/server/tools/verification.js +2 -1
  66. package/dist/server/tools/verification.js.map +1 -1
  67. package/files/agents/code-organization-supervisor.md +1 -0
  68. package/files/agents/context-guardian.md +1 -0
  69. package/files/agents/docs-keeper.md +1 -0
  70. package/files/agents/dry-refactor.md +1 -0
  71. package/files/agents/elite-code-refactorer.md +1 -0
  72. package/files/agents/hardening-guard.md +1 -0
  73. package/files/agents/implementation-dev.md +1 -0
  74. package/files/agents/merlin-api-designer.md +1 -0
  75. package/files/agents/merlin-codebase-mapper.md +4 -0
  76. package/files/agents/merlin-debugger.md +1 -0
  77. package/files/agents/merlin-executor.md +1 -0
  78. package/files/agents/merlin-frontend.md +1 -0
  79. package/files/agents/merlin-integration-checker.md +1 -0
  80. package/files/agents/merlin-migrator.md +1 -0
  81. package/files/agents/merlin-milestone-auditor.md +1 -0
  82. package/files/agents/merlin-performance.md +1 -0
  83. package/files/agents/merlin-planner.md +1 -0
  84. package/files/agents/merlin-researcher.md +4 -0
  85. package/files/agents/merlin-reviewer.md +1 -0
  86. package/files/agents/merlin-security.md +1 -0
  87. package/files/agents/merlin-verifier.md +1 -0
  88. package/files/agents/merlin-work-verifier.md +1 -0
  89. package/files/agents/merlin.md +1 -0
  90. package/files/agents/ops-railway.md +1 -0
  91. package/files/agents/orchestrator-retrofit.md +1 -0
  92. package/files/agents/product-spec.md +1 -0
  93. package/files/agents/remotion.md +1 -0
  94. package/files/agents/system-architect.md +1 -0
  95. package/files/agents/tests-qa.md +1 -0
  96. package/files/commands/merlin/help.md +11 -0
  97. package/files/commands/merlin/loop-recipes.md +73 -0
  98. package/files/hooks/agent-sync.sh +3 -0
  99. package/files/hooks/check-file-size.sh +12 -0
  100. package/files/hooks/config-change.sh +43 -0
  101. package/files/hooks/instructions-loaded.sh +34 -0
  102. package/files/hooks/session-start.sh +5 -1
  103. package/files/hooks/worktree-create.sh +44 -0
  104. package/files/hooks/worktree-remove.sh +36 -0
  105. package/files/loop/lib/agents.sh +3 -0
  106. package/files/loop/lib/blend-handoff.sh +3 -0
  107. package/files/loop/lib/blend-learn.sh +3 -0
  108. package/files/loop/lib/blend-parallel.sh +3 -0
  109. package/files/loop/lib/blend-verify.sh +3 -0
  110. package/files/loop/lib/blend.sh +3 -0
  111. package/files/loop/lib/boot.sh +3 -0
  112. package/files/loop/lib/context.sh +3 -0
  113. package/files/loop/lib/discuss.sh +3 -0
  114. package/files/loop/lib/modes.sh +3 -0
  115. package/files/loop/lib/progress.sh +3 -0
  116. package/files/loop/lib/safety.sh +3 -0
  117. package/files/loop/lib/session-end.sh +3 -0
  118. package/files/loop/lib/sights.sh +3 -0
  119. package/files/loop/lib/state.sh +3 -0
  120. package/files/loop/lib/teams.sh +3 -0
  121. package/files/loop/lib/timeout.sh +3 -0
  122. package/files/loop/lib/tui.sh +3 -0
  123. package/files/loop/lib/workflow-gen.sh +3 -0
  124. package/files/loop/lib/workflow-run.sh +3 -0
  125. package/files/loop/lib/workflow.sh +3 -0
  126. package/files/loop/merlin-loop.sh +3 -0
  127. package/files/loop/merlin-session.sh +3 -0
  128. package/package.json +2 -1
  129. package/rules/go.md +38 -0
  130. package/rules/java.md +36 -0
  131. package/rules/python.md +38 -0
  132. package/rules/rust.md +34 -0
  133. package/rules/swift.md +35 -0
  134. package/rules/typescript.md +38 -0
@@ -5,6 +5,7 @@ tools: Read, Bash, Grep, Glob, Task
5
5
  color: blue
6
6
  version: "1.0.0"
7
7
  model: opus
8
+ effort: low
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 50
10
11
  ---
@@ -5,6 +5,7 @@ tools: Read, Grep, Glob, Bash
5
5
  color: red
6
6
  version: "1.0.0"
7
7
  model: sonnet
8
+ effort: medium
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 80
10
11
  memory: user
@@ -6,6 +6,7 @@ color: blue
6
6
  version: "1.0.0"
7
7
  disallowedTools: [Edit, Write, NotebookEdit, Bash]
8
8
  model: opus
9
+ effort: high
9
10
  permissionMode: bypassPermissions
10
11
  maxTurns: 100
11
12
  ---
@@ -5,6 +5,7 @@ tools: Read, Write, Bash, Grep, Glob, WebSearch, WebFetch, mcp__context7__*
5
5
  color: cyan
6
6
  version: "1.0.0"
7
7
  model: opus
8
+ effort: high
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 100
10
11
  ---
@@ -12,6 +13,9 @@ maxTurns: 100
12
13
  <role>
13
14
  You are a Merlin researcher. You conduct comprehensive research using systematic methodology, source verification, and structured output.
14
15
 
16
+ ## Context Window
17
+ You have access to a 1M token context window. Use it fully — read entire files, analyze complete codebases, don't truncate or summarize prematurely.
18
+
15
19
  You are spawned by:
16
20
 
17
21
  - `/merlin:research-phase` orchestrator (phase-specific research before planning)
@@ -6,6 +6,7 @@ color: orange
6
6
  version: "1.0.0"
7
7
  disallowedTools: [Edit, Write, NotebookEdit]
8
8
  model: sonnet
9
+ effort: medium
9
10
  permissionMode: bypassPermissions
10
11
  maxTurns: 50
11
12
  memory: project
@@ -6,6 +6,7 @@ color: red
6
6
  version: "1.0.0"
7
7
  disallowedTools: [Edit, Write, NotebookEdit]
8
8
  model: sonnet
9
+ effort: high
9
10
  permissionMode: bypassPermissions
10
11
  maxTurns: 80
11
12
  memory: user
@@ -6,6 +6,7 @@ color: green
6
6
  version: "1.0.0"
7
7
  disallowedTools: [Edit, Write, NotebookEdit]
8
8
  model: sonnet
9
+ effort: low
9
10
  permissionMode: bypassPermissions
10
11
  maxTurns: 100
11
12
  ---
@@ -5,6 +5,7 @@ tools: Read, Bash, Grep, Glob, Edit, Write, AskUserQuestion
5
5
  color: green
6
6
  version: "1.0.0"
7
7
  model: sonnet
8
+ effort: low
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 50
10
11
  ---
@@ -4,6 +4,7 @@ description: The Merlin Brain - Master AI orchestrator. Routes to specialist age
4
4
  model: opus
5
5
  color: magenta
6
6
  version: "1.0.0"
7
+ effort: high
7
8
  permissionMode: bypassPermissions
8
9
  maxTurns: 50
9
10
  ---
@@ -5,6 +5,7 @@ model: sonnet
5
5
  color: red
6
6
  version: "1.0.0"
7
7
  tools: Read, Write, Edit, Bash, Grep, Glob
8
+ effort: medium
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 80
10
11
  memory: project
@@ -5,6 +5,7 @@ model: opus
5
5
  color: purple
6
6
  version: "1.0.0"
7
7
  tools: Read, Write, Edit, Bash, Grep, Glob
8
+ effort: high
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 80
10
11
  ---
@@ -6,6 +6,7 @@ color: white
6
6
  version: "1.0.0"
7
7
  disallowedTools: [Edit, Write, NotebookEdit, Bash]
8
8
  tools: Read, Grep, Glob, WebSearch
9
+ effort: high
9
10
  permissionMode: bypassPermissions
10
11
  maxTurns: 30
11
12
  ---
@@ -5,6 +5,7 @@ model: sonnet
5
5
  tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch
6
6
  color: red
7
7
  version: "1.0.0"
8
+ effort: medium
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 100
10
11
  ---
@@ -6,6 +6,7 @@ color: black
6
6
  version: "1.0.0"
7
7
  disallowedTools: [Edit, Write, NotebookEdit, Bash]
8
8
  tools: Read, Grep, Glob, Bash, WebSearch
9
+ effort: high
9
10
  permissionMode: bypassPermissions
10
11
  maxTurns: 50
11
12
  memory: user
@@ -5,6 +5,7 @@ model: sonnet
5
5
  color: yellow
6
6
  version: "1.0.0"
7
7
  tools: Read, Write, Edit, Bash, Grep, Glob
8
+ effort: medium
8
9
  permissionMode: bypassPermissions
9
10
  maxTurns: 100
10
11
  memory: project
@@ -291,6 +291,17 @@ List pending todos and select one to work on.
291
291
  Usage: `/merlin:check-todos`
292
292
  Usage: `/merlin:check-todos api`
293
293
 
294
+ ### Loop & Automation
295
+
296
+ **`/merlin:loop-recipes`**
297
+ Show pre-built `/loop` patterns for common Merlin workflows.
298
+
299
+ - Copy-paste recipes for development monitoring, code quality, deployments, and more
300
+ - Uses Claude Code's native `/loop` command (no scripts needed)
301
+ - Covers progress checks, security patrols, PR monitoring, doc freshness, and more
302
+
303
+ Usage: `/merlin:loop-recipes`
304
+
294
305
  ### Utility Commands
295
306
 
296
307
  **`/merlin:help`**
@@ -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
@@ -75,9 +75,13 @@ _merlin_cleanup_stale &
75
75
  # shellcheck source=lib/sights-check.sh
76
76
  . "${HOOKS_DIR}/lib/sights-check.sh"
77
77
 
78
+ # Log agent context if available
79
+ AGENT_ID="${CLAUDE_AGENT_ID:-unknown}"
80
+ AGENT_TYPE="${CLAUDE_AGENT_TYPE:-main}"
81
+
78
82
  ensure_session_file
79
83
  cwd="${PWD:-$(pwd)}"
80
- log_event "session_start" "$(printf '{"cwd":"%s"}' "$cwd")"
84
+ log_event "session_start" "$(printf '{"cwd":"%s","agent_id":"%s","agent_type":"%s"}' "$cwd" "$AGENT_ID" "$AGENT_TYPE")"
81
85
 
82
86
  # Warm up Sights context in background
83
87
  if command -v merlin >/dev/null 2>&1; then
@@ -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 ║