2025-10-11 12:29:03 -03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2025-11-11 09:42:52 -03:00
|
|
|
set -e # Exit on error
|
|
|
|
|
|
2025-10-11 12:29:03 -03:00
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
2025-10-13 17:43:03 -03:00
|
|
|
PROJECT_ROOT="$SCRIPT_DIR"
|
2025-10-18 22:25:59 -03:00
|
|
|
OUTPUT_FILE="/tmp/prompt.out"
|
2025-10-19 11:08:23 -03:00
|
|
|
|
2025-11-11 09:42:52 -03:00
|
|
|
# Check required commands
|
|
|
|
|
command -v cargo >/dev/null 2>&1 || { echo "cargo is required but not installed" >&2; exit 1; }
|
|
|
|
|
command -v xclip >/dev/null 2>&1 || { echo "xclip is required but not installed" >&2; exit 1; }
|
|
|
|
|
|
2025-10-13 17:43:03 -03:00
|
|
|
echo "Please, fix this consolidated LLM Context" > "$OUTPUT_FILE"
|
2025-10-11 12:29:03 -03:00
|
|
|
|
|
|
|
|
prompts=(
|
2025-10-19 11:08:23 -03:00
|
|
|
"./prompts/dev/platform/fix-errors.md"
|
2025-10-18 22:25:59 -03:00
|
|
|
"./prompts/dev/platform/shared.md"
|
2025-10-13 17:43:03 -03:00
|
|
|
"./Cargo.toml"
|
2025-10-11 12:29:03 -03:00
|
|
|
)
|
|
|
|
|
|
2025-11-11 09:42:52 -03:00
|
|
|
# Validate files exist
|
|
|
|
|
for file in "${prompts[@]}"; do
|
|
|
|
|
if [ ! -f "$file" ]; then
|
|
|
|
|
echo "Required file not found: $file" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2025-10-11 12:29:03 -03:00
|
|
|
for file in "${prompts[@]}"; do
|
|
|
|
|
cat "$file" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
dirs=(
|
2025-10-28 12:44:28 -03:00
|
|
|
# "auth"
|
2025-10-28 14:20:55 -03:00
|
|
|
# "automation"
|
|
|
|
|
#"basic"
|
2025-10-28 12:44:28 -03:00
|
|
|
# "bot"
|
|
|
|
|
"bootstrap"
|
|
|
|
|
# "package_manager"
|
|
|
|
|
# "channels"
|
|
|
|
|
# "config"
|
|
|
|
|
# "context"
|
|
|
|
|
# "email"
|
|
|
|
|
# "file"
|
|
|
|
|
# "llm"
|
|
|
|
|
"drive_monitor"
|
|
|
|
|
# "llm_legacy"
|
|
|
|
|
# "org"
|
|
|
|
|
# "session"
|
|
|
|
|
"file"
|
|
|
|
|
"kb"
|
2025-10-19 19:28:08 -03:00
|
|
|
"shared"
|
2025-10-28 14:20:55 -03:00
|
|
|
#"tests"
|
2025-10-28 12:44:28 -03:00
|
|
|
# "tools"
|
|
|
|
|
# "web_automation"
|
|
|
|
|
# "whatsapp"
|
2025-10-11 12:29:03 -03:00
|
|
|
)
|
|
|
|
|
for dir in "${dirs[@]}"; do
|
2025-11-11 09:42:52 -03:00
|
|
|
if [ -d "$PROJECT_ROOT/src/$dir" ]; then
|
|
|
|
|
find "$PROJECT_ROOT/src/$dir" -name "*.rs" | while read -r file; do
|
|
|
|
|
if [ -f "$file" ]; then
|
|
|
|
|
echo "$file" >> "$OUTPUT_FILE"
|
|
|
|
|
cat "$file" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
2025-10-11 12:29:03 -03:00
|
|
|
done
|
|
|
|
|
|
2025-10-11 13:29:38 -03:00
|
|
|
# Also append the specific files you mentioned
|
2025-10-13 09:36:06 -03:00
|
|
|
echo "$PROJECT_ROOT/src/main.rs" >> "$OUTPUT_FILE"
|
2025-10-11 12:29:03 -03:00
|
|
|
cat "$PROJECT_ROOT/src/main.rs" >> "$OUTPUT_FILE"
|
2025-10-13 09:36:06 -03:00
|
|
|
|
2025-10-28 14:20:55 -03:00
|
|
|
echo "$PROJECT_ROOT/src/basic/keywords/get.rs" >> "$OUTPUT_FILE"
|
|
|
|
|
cat "$PROJECT_ROOT/src/basic/keywords/get.rs" >> "$OUTPUT_FILE"
|
2025-10-11 12:29:03 -03:00
|
|
|
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
2025-10-20 09:42:07 -03:00
|
|
|
echo "Compiling..."
|
2025-10-13 17:43:03 -03:00
|
|
|
cargo build --message-format=short 2>&1 | grep -E 'error' >> "$OUTPUT_FILE"
|
2025-10-18 22:25:59 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate and display token count (approximation: words * 1.3)
|
2025-11-11 09:42:52 -03:00
|
|
|
WORD_COUNT=$(wc -w < "$OUTPUT_FILE") || { echo "Error counting words" >&2; exit 1; }
|
|
|
|
|
TOKEN_COUNT=$(echo "$WORD_COUNT * 1.3 / 1" | bc) || { echo "Error calculating tokens" >&2; exit 1; }
|
|
|
|
|
FILE_SIZE=$(wc -c < "$OUTPUT_FILE") || { echo "Error getting file size" >&2; exit 1; }
|
2025-10-18 22:25:59 -03:00
|
|
|
|
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
|
echo "Approximate token count: $TOKEN_COUNT"
|
|
|
|
|
echo "Context size: $FILE_SIZE bytes"
|
|
|
|
|
|
2025-11-11 09:42:52 -03:00
|
|
|
if ! cat "$OUTPUT_FILE" | xclip -selection clipboard; then
|
|
|
|
|
echo "Error copying to clipboard" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-18 22:25:59 -03:00
|
|
|
echo "Content copied to clipboard (xclip)"
|
|
|
|
|
rm -f "$OUTPUT_FILE"
|