#!/bin/bash # Source common utilities SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/ai-common" show_usage() { echo "Usage: ai-tr TRANSFORMATION [FILE...]" echo "Transform text format or style while preserving semantic meaning." echo "" echo "Arguments:" echo " TRANSFORMATION Description of the desired transformation" echo "" echo "Options:" echo " -h Show this help message" } TRANSFORMATION="" FILES=() while getopts "h" opt; do case $opt in h) handle_help show_usage ;; \?) handle_invalid_option "$OPTARG" ;; esac done shift $((OPTIND-1)) # Check dependencies check_dependencies require_argument "Transformation description" "$1" show_usage TRANSFORMATION="$1" shift FILES=("$@") # Validate files exist before processing if [ ${#FILES[@]} -gt 0 ]; then validate_files "${FILES[@]}" fi # Get input with validation if ! INPUT=$(get_input "${FILES[@]}"); then exit $EXIT_NO_MATCH fi PROMPT="You are a semantic text transformation tool. Apply the following transformation: $TRANSFORMATION CRITICAL REQUIREMENTS: 1. Preserve ALL semantic meaning and factual content 2. Keep the same essential information - do not add, remove, or change facts 3. Only change style, tone, format, or wording as requested 4. Maintain the original structure (same number of distinct points/items) 5. Output ONLY the transformed text - no explanations or commentary Transform each line/paragraph separately to maintain structure. Text to transform: $INPUT" # Call Claude with error handling RESULT=$(call_claude "$PROMPT") EXIT_CODE=$? if [ $EXIT_CODE -eq 0 ]; then echo "$RESULT" exit $EXIT_SUCCESS else exit $EXIT_CODE fi