#!/bin/bash # SuperMemory - Add Memory Script # Usage: add-memory.sh "content" "description (optional)" set -e CONTENT="$1" DESCRIPTION="$2" if [ -z "$CONTENT" ]; then echo "Error: No content provided" echo "Usage: add-memory.sh \"content\" \"description (optional)\"" exit 1 fi API_KEY="${SUPERMEMORY_API_KEY}" if [ -z "$API_KEY" ]; then echo "Error: SUPERMEMORY_API_KEY environment variable not set" echo "Please set it with: export SUPERMEMORY_API_KEY=\"your-api-key\"" exit 1 fi # Sanitize description: replace spaces with hyphens, keep only alphanumeric, hyphens, underscores SANITIZED_DESC=$(echo "${DESCRIPTION:-clawdbot}" | tr -cd '[:alnum:]-_' | tr '[:upper:]' '[:lower:]') # SuperMemory API endpoint (using the direct API) API_URL="https://api.supermemory.ai/v3/documents" # Prepare the request DATA=$(cat <