#!/bin/bash # AUTONOMOUS BUILDER - Binary/Minimal Output LEARNED_ZST=~/Library/Mobile\ Documents/com~apple~CloudDocs/AGI_Data/thataiguy/learned_items.json.zst OUT=~/Library/Mobile\ Documents/com~apple~CloudDocs/AGI_Data/generated LOG=~/.thataiguy/logs/builder.log mkdir -p "$OUT/bin" "$OUT/data" ~/.thataiguy/logs log() { echo "[$(date +%H:%M:%S)] $1" >> "$LOG"; echo "[BUILD] $1"; } # Read from compressed data get_topics() { zstd -d -c "$LEARNED_ZST" 2>/dev/null | jq -r '.[-100:] | .[].content' | \ grep -oE '\b[A-Za-z]{5,}\b' | tr '[:upper:]' '[:lower:]' | \ sort | uniq -c | sort -rn | head -15 | awk '$1>2{print $2}' } get_data() { zstd -d -c "$LEARNED_ZST" 2>/dev/null | jq -r --arg t "$1" \ '.[] | select(.content | ascii_downcase | contains($t)) | .content' | head -3 } # Create minimal binary script create_bin() { local t="$1" f="$OUT/bin/${1}" log "Creating binary: $t" # Minimal script - no comments, compressed printf '#!/bin/bash\nD=~/.thataiguy/learned_items.json.zst\nzstd -dc "$D" 2>/dev/null|jq -r ".[]|select(.content|test(\"%s\";\"i\"))|.content"|head -5\n' "$t" > "$f" chmod +x "$f" # Compress script itself zstd -f -q --rm "$f" -o "${f}.zst" 2>/dev/null log "Created: ${f}.zst ($(du -h "${f}.zst"|cut -f1))" } # Create compressed data insight create_data() { local t="$1" f="$OUT/data/${1}.zst" log "Creating data: $t" get_data "$t" | zstd -f -q -o "$f" log "Created: $f ($(du -h "$f"|cut -f1))" } # Run binary (decompress and execute) run_bin() { local f="$OUT/bin/${1}.zst" [ -f "$f" ] && zstd -d -c "$f" | bash } log "=== Binary Builder Starting ===" cycle=0 while true; do cycle=$((cycle + 1)) topic=$(get_topics | shuf 2>/dev/null | head -1 || get_topics | head -1) if [ -n "$topic" ]; then log "Cycle $cycle: $topic" [ $((cycle % 2)) -eq 0 ] && create_bin "$topic" || create_data "$topic" fi # Compress all generated periodically [ $((cycle % 10)) -eq 0 ] && { log "Compressing generated..." cd "$OUT" && tar -cf - . 2>/dev/null | zstd -f -q -o ~/Library/Mobile\ Documents/com~apple~CloudDocs/AGI_Data/generated.tar.zst } sleep 300 done