#!/bin/bash
# Check for available updates — report only, don't install

set -e

echo "=== Claude Code ==="
CURRENT=$(claude --version 2>/dev/null | head -1 || echo "not installed")
LATEST=$(npm show @anthropic-ai/claude-code version 2>/dev/null || echo "unknown")

CURRENT_VER=$(echo "$CURRENT" | sed 's/ (Claude Code)//')
if [ "$CURRENT_VER" = "$LATEST" ] || [ "$LATEST" = "unknown" ]; then
    echo "✅ Up to date: $CURRENT"
else
    echo "⬆️  Update available: $CURRENT_VER → $LATEST"
    echo "   Run: npm update -g @anthropic-ai/claude-code"
fi

echo ""
echo "=== OpenClaw ==="
OC_CURRENT=$(openclaw --version 2>/dev/null | head -1 || echo "not installed")
OC_LATEST=$(npm show openclaw version 2>/dev/null || echo "unknown")

OC_CURRENT_VER=$(echo "$OC_CURRENT" | grep -oP '[\d.]+' | head -1 || echo "$OC_CURRENT")
if [ "$OC_CURRENT_VER" = "$OC_LATEST" ] || [ "$OC_LATEST" = "unknown" ]; then
    echo "✅ Up to date: $OC_CURRENT"
else
    echo "⬆️  Update available: $OC_CURRENT_VER → $OC_LATEST"
    echo "   Run: npm update -g openclaw"
fi


# inou is fully server-based; no local MCP bundle to check
