#!/bin/bash

# Auto-Build Environment Setup
# Generated by Planner Agent
# Task: Fix README inaccuracies and add missing setup documentation

set -e

echo "========================================"
echo "Documentation Update Task - Init"
echo "========================================"

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

echo ""
echo -e "${GREEN}Task Type:${NC} Documentation update (no services to start)"
echo -e "${GREEN}Workflow:${NC} simple"
echo ""

# ============================================
# VERIFY PROJECT SETUP
# ============================================

echo "Verifying project setup..."

# Check if pnpm is available
if ! command -v pnpm &> /dev/null; then
    echo -e "${YELLOW}Warning: pnpm not found. Install with: npm install -g pnpm${NC}"
else
    echo -e "${GREEN}✓ pnpm found${NC}"
fi

# Check if node_modules exists (via symlink or local)
if [ -d "node_modules" ] || [ -L "node_modules" ]; then
    echo -e "${GREEN}✓ node_modules present${NC}"
else
    echo -e "${YELLOW}Warning: node_modules not found. Run: pnpm install${NC}"
fi

# Check if key files exist
echo ""
echo "Checking key files..."
[ -f "README.md" ] && echo -e "${GREEN}✓ README.md${NC}" || echo -e "${RED}✗ README.md${NC}"
[ -f "package.json" ] && echo -e "${GREEN}✓ package.json${NC}" || echo -e "${RED}✗ package.json${NC}"
[ -f "Dockerfile" ] && echo -e "${GREEN}✓ Dockerfile${NC}" || echo -e "${RED}✗ Dockerfile${NC}"
[ -f "docker-compose.yml" ] && echo -e "${GREEN}✓ docker-compose.yml${NC}" || echo -e "${RED}✗ docker-compose.yml${NC}"
[ -f ".env.local" ] && echo -e "${GREEN}✓ .env.local${NC}" || echo -e "${YELLOW}○ .env.local (optional)${NC}"

echo ""
echo "========================================"
echo "Environment Ready for Documentation Updates"
echo "========================================"
echo ""
echo -e "${GREEN}Next Steps:${NC}"
echo "  1. Review implementation_plan.json"
echo "  2. Run coder agent to execute subtasks"
echo "  3. Review updated README.md"
echo ""
echo -e "${YELLOW}Note: This is a documentation-only task${NC}"
echo -e "${YELLOW}No services need to be running${NC}"
echo ""
