#!/bin/bash
# =============================================================================
# SentryAgent.ai — Start Virtual CTO Agent
# =============================================================================
# Launches a separate Claude Code instance as the Virtual CTO.
# The CTO will register on the central hub and await CEO instructions.
#
# Usage:
#   ./scripts/start-cto.sh
#
# The CTO agent runs in its own terminal session and communicates
# with the CEO via the central hub (#vpe-cto-approvals channel).
# =============================================================================

set -e

PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CTO_WORKSPACE="$PROJECT_ROOT/.cto-workspace"

echo "=============================================="
echo "  SentryAgent.ai — Starting Virtual CTO Agent"
echo "=============================================="
echo ""
echo "  Project:    $PROJECT_ROOT"
echo "  Workspace:  $CTO_WORKSPACE"
echo "  Hub Channel: #vpe-cto-approvals"
echo ""
echo "  The Virtual CTO will:"
echo "  1. Read PRD.md then README.md"
echo "  2. Register on central hub as VirtualCTO"
echo "  3. Report status to CEO"
echo "  4. Await CEO priorities"
echo ""
echo "=============================================="
echo ""

# Verify the CTO workspace exists
if [ ! -f "$CTO_WORKSPACE/CLAUDE.md" ]; then
  echo "ERROR: CTO workspace not found at $CTO_WORKSPACE/CLAUDE.md"
  echo "Please ensure the project is set up correctly."
  exit 1
fi

# Launch Claude Code in the CTO workspace with full autonomy
# --dangerously-skip-permissions bypasses all approval prompts — no Shift+Tab needed
cd "$CTO_WORKSPACE"
exec claude --dangerously-skip-permissions
