#!/bin/bash
set -e

# This script demonstrates the orchestration needed for card #920 fixing
# It requires Claude Code to invoke the MCP Trello tool

CARD_ID="6a1d695a1dc00d256e0dc34b"
CARD_SHORT=920
SCRIPT_DIR="/opt/automator/cinik-writer-transtor/files"
HELPER="$SCRIPT_DIR/_share_fix.py"
EXECUTOR="$SCRIPT_DIR/execute_card_920_fix.py"

echo "===== CINIK Card #920 - Google Doc Permission Fixer ====="
echo "Card ID: $CARD_ID"
echo "Card Short: $CARD_SHORT"
echo ""
echo "Step 1: Fetch card description from Trello"
echo "  Required: Claude Code calls mcp__trello__get_card($CARD_ID)"
echo "  Extract: card.desc field (the description)"
echo ""
echo "Step 2: Parse and apply fixes"
echo "  Command: python3 $EXECUTOR '<CARD_DESCRIPTION>'"
echo "  This script will:"
echo "    - Extract all non-FR language doc IDs"
echo "    - Call $HELPER share <docId> for each"
echo "    - Collect results"
echo ""
echo "Step 3: Return StructuredOutput"
echo "  Format: {cardShort, results, allWriter, problems}"
echo ""
echo "===== Expected Output Format ====="
cat << 'EXPECTED'
{
  "cardShort": 920,
  "results": [
    {"lang": "en", "role": "writer", "changed": "created"},
    {"lang": "it", "role": "writer", "changed": "promoted"},
    ...
  ],
  "allWriter": true,
  "problems": []
}
EXPECTED

