#!/bin/bash
# Emite el modo de desarrollo activo (Framework o Solution) como additionalContext
# para el hook SessionStart, de modo que Claude aplique el mindset correcto.

MODE_FILE="${CLAUDE_PROJECT_DIR:-.}/.catalyst-dev-mode"
if [ -f "$MODE_FILE" ]; then
  MODE=$(tr -d '[:space:]' < "$MODE_FILE")
else
  MODE="Solution"
fi

MODE_LC=$(echo "$MODE" | tr '[:upper:]' '[:lower:]')

if [ "$MODE_LC" = "framework" ]; then
  read -r -d '' CONTEXT <<'EOF'
Current development mode: **Framework**

Mindset: "Who else might need this?" — generalize, extract, document.

Rules for this mode:
- Plan and prepare code for future uses even if not needed right now (unless cost is high).
- Extract composables, shared components, and utilities to @aurora/.
- Create and update skills to document patterns.
- Write code that is easy for AI to read, understand, and reuse.
- Prioritize clarity and reusability over speed.
- It IS valid here to propose lifting a pattern into `aurora-catalyst-cli` or the generator. If the request would be better solved by a generator change, say so.

Switch mode with `/catalyst-dev-mode solution` if the task is a concrete requirement to deliver fast.
EOF
else
  read -r -d '' CONTEXT <<'EOF'
Current development mode: **Solution**

Mindset: "What's the shortest path?" — consume, don't build.

Rules for this mode:
- Use existing tools, composables, and components from @aurora/.
- Stay within the established architecture. Only add new architecture if imperatively required.
- Optimize for delivering the requirement, not for future flexibility.
- Follow the patterns documented in skills — don't invent new ones.

Hard prohibitions in Solution mode (do NOT relax these unless the user switches to Framework):
- Do NOT propose changes to `aurora-catalyst-cli` or to the generation contract. A request in Solution mode is by definition a customization; assume the CLI does not cover it.
- Do NOT treat `@aurora-catalyst-generated` headers as a blocker. Edit those files directly. Regeneration policy is the user's concern, not yours.
- If you think "this should live in the CLI" → keep it to yourself. Suggesting it here just delays the user's task.

Switch mode with `/catalyst-dev-mode framework` if the task requires building reusable abstractions or generator changes.
EOF
fi

jq -nc --arg ctx "$CONTEXT" '{hookSpecificOutput: {hookEventName: "SessionStart", additionalContext: $ctx}}'
