create-merlin-brain 3.5.13 → 3.6.1

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.
@@ -40,6 +40,7 @@ source "$SCRIPT_DIR/lib/context.sh"
40
40
  source "$SCRIPT_DIR/lib/modes.sh"
41
41
  source "$SCRIPT_DIR/lib/sights.sh" 2>/dev/null || true # Sights integration
42
42
  source "$SCRIPT_DIR/lib/agents.sh" 2>/dev/null || true # Agent profiles and routing
43
+ source "$SCRIPT_DIR/lib/blend.sh" 2>/dev/null || true # Dynamic agent blending engine
43
44
  source "$SCRIPT_DIR/lib/teams.sh" 2>/dev/null || true # Agent Teams integration
44
45
  source "$SCRIPT_DIR/lib/boot.sh" 2>/dev/null || true # Boot sequence
45
46
  source "$SCRIPT_DIR/lib/session-end.sh" 2>/dev/null || true # Session end protocol
@@ -402,23 +403,40 @@ run_iteration() {
402
403
  local output
403
404
  local exit_code=0
404
405
 
405
- # Route to the specialist agent selected by boot sequence
406
+ # ═══════════════════════════════════════════════════════════════════════════
407
+ # BLEND ENGINE: Create a custom specialist for this task
408
+ # Instead of routing to a single static agent, blend multiple agents
409
+ # into a custom-optimized specialist for every iteration.
410
+ # Fallback: use boot-selected agent if blend engine not available.
411
+ # ═══════════════════════════════════════════════════════════════════════════
406
412
  local agent_cli_name="merlin"
407
- if [ -n "${BOOT_SELECTED_AGENT:-}" ] && type get_agent_cli_name &> /dev/null; then
413
+ local agent_display_name="merlin"
414
+
415
+ if type blend_for_task &>/dev/null; then
416
+ # Blend engine available — create custom specialist
417
+ mkdir -p "$LOOP_DIR/blends"
418
+ local blend_path
419
+ blend_path=$(blend_for_task "$current_task_desc" "$LOOP_DIR/blends")
420
+ agent_cli_name="$blend_path"
421
+ agent_display_name=$(blend_summary "$current_task_desc" 2>/dev/null || echo "Blended Specialist")
422
+
423
+ if type blend_show_decision &>/dev/null; then
424
+ blend_show_decision "$current_task_desc"
425
+ fi
426
+ elif [ -n "${BOOT_SELECTED_AGENT:-}" ] && type get_agent_cli_name &> /dev/null; then
427
+ # Fallback: static agent routing (pre-blend behavior)
408
428
  agent_cli_name=$(get_agent_cli_name "$BOOT_SELECTED_AGENT")
409
- fi
410
-
411
- local agent_display_name="$agent_cli_name"
412
- if type get_agent_display_name &> /dev/null && [ -n "${BOOT_SELECTED_AGENT:-}" ]; then
413
- agent_display_name=$(get_agent_display_name "$BOOT_SELECTED_AGENT")
429
+ if type get_agent_display_name &> /dev/null; then
430
+ agent_display_name=$(get_agent_display_name "$BOOT_SELECTED_AGENT")
431
+ fi
414
432
  fi
415
433
 
416
434
  echo -e "${BLUE}Spawning Claude as ${BOLD}${agent_display_name}${RESET}${BLUE}...${RESET}"
417
- echo -e "${BLUE}Agent: --agent ${agent_cli_name} | Task list: ${TASK_LIST_ID}${RESET}"
435
+ echo -e "${BLUE}Agent: --agent $(basename "$agent_cli_name" .md) | Task list: ${TASK_LIST_ID}${RESET}"
418
436
 
419
437
  # Capture output and exit code
420
438
  # CLAUDE_CODE_TASK_LIST_ID enables cross-session task coordination
421
- # --agent routes to the specialist selected by boot sequence
439
+ # --agent routes to the blended specialist (or fallback agent)
422
440
  set +e
423
441
  output=$(CLAUDE_CODE_TASK_LIST_ID="$TASK_LIST_ID" claude --agent "$agent_cli_name" --output-format stream-json 2>&1 <<< "$full_prompt")
424
442
  exit_code=$?