#!/bin/bash

# Claude Code Implementation Script
# Use this to implement the workflow schedule module using Claude Code

echo "╔══════════════════════════════════════════════════════════════════╗"
echo "║                                                                  ║"
echo "║       Claude Code - Workflow Schedule Implementation            ║"
echo "║                                                                  ║"
echo "╚══════════════════════════════════════════════════════════════════╝"
echo ""

PROJECT_PATH="/Users/debrajdas/WORKSPACE/001_RZ/PROJECTS/ETHER/250218_nodejs_core"

echo "🎯 Target Project: $PROJECT_PATH"
echo ""

# Check if Claude Code is installed
if ! command -v claude-code &> /dev/null; then
    echo "❌ Claude Code is not installed"
    echo ""
    echo "Install it with:"
    echo "  npm install -g @anthropic-ai/claude-code"
    echo ""
    echo "Or visit: https://docs.claude.com/claude-code"
    exit 1
fi

echo "✅ Claude Code is installed"
echo ""

# Check if project exists
if [ ! -d "$PROJECT_PATH" ]; then
    echo "❌ Project not found at: $PROJECT_PATH"
    exit 1
fi

echo "✅ Project found"
echo ""

cd "$PROJECT_PATH"

echo "🚀 Starting Claude Code..."
echo ""
echo "📋 Prompt loaded from: CLAUDE_CODE_PROMPT.md"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Run Claude Code with the prompt
claude-code --prompt "$(cat "$SCRIPT_DIR/CLAUDE_CODE_PROMPT.md")"

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "✅ Claude Code session complete!"
echo ""
echo "📋 Next Steps:"
echo "   1. Review the generated files"
echo "   2. Install dependencies: npm install @nestjs/bull bull ioredis cron-parser moment-timezone"
echo "   3. Setup Redis: docker run -d -p 6379:6379 --name redis redis:alpine"
echo "   4. Update .env with Redis configuration"
echo "   5. Run migrations: npm run migration:run"
echo "   6. Start app: npm run start:dev"
echo ""
