#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"

echo "Building Designeo bundle..."

# Swap manifest
cp "$PROJECT_DIR/manifest.json" "$PROJECT_DIR/manifest.json.bak"
cp "$SCRIPT_DIR/manifest.designeo.json" "$PROJECT_DIR/manifest.json"

# Build
mcpb pack "$PROJECT_DIR"

# Restore original manifest
mv "$PROJECT_DIR/manifest.json.bak" "$PROJECT_DIR/manifest.json"

# Move bundle to .private
mv "$PROJECT_DIR/better-confluence-mcp.mcpb" "$SCRIPT_DIR/better-confluence-mcp-designeo.mcpb"

echo "Done: .private/better-confluence-mcp-designeo.mcpb"
