Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/complete-agi-core / orchestrator/ingest-old-ai.sh |
| Date | Not specified in source |
| Repository | Janady13/complete-agi-core |
| Revision | 33aa84f2aa61cedbe010240ada7f4efbdfe795a7 |
| Branch | claude/improve-math-logic-ehIW1 |
| Path or archive member | orchestrator/ingest-old-ai.sh |
| Original SHA-256 | b85575f7f391a69cb1d7ff8d2f462b73f220e56e4a9fdd9329cd7a246c960424 |
| Git blob SHA | 1cc0e921e8aec23aa0b5262c994184667080b234 |
| Reading-copy SHA-256 | abf8003776f4d4312489698d1e8a75f752560b849ab5a9e83029e3741573dd60 |
Recovered source transcript
Download complete source text ↓176 lines · 5.9 KB
Credential-bearing and unrelated personal details were removed from this reading copy. The source identity and original checksum remain recorded.
#!/bin/bash
# INGEST OLD AI ARCHIVE - Teach both AGIs historical AI knowledge
export PATH="/opt/homebrew/bin:$PATH"
SOURCE_DIR="/Users/josephanady/Desktop/old ai/extracted/old ai"
MB1_LEARNED="$HOME/.agi_core/learned_items.json"
MB2_HOST="192.168.4.62"
MB2_USER="beandaddy"
MB2_PASS="Tcb_2032?"
LOG="$HOME/.agi_core/logs/old-ai-ingest.log"
mkdir -p "$HOME/.agi_core/logs"
log() { echo "[$(date +%H:%M:%S)] $1" | tee -a "$LOG"; }
# Add item to MB1 learned_items.json
add_to_mb1() {
local content="$1"
local importance="${2:-0.85}"
local timestamp=$(date +%s)
# Escape for JSON
content=$(echo "$content" | jq -Rs '.')
# Create temp file with new item
local temp=$(mktemp)
jq --argjson content "$content" \
--argjson imp "$importance" \
--argjson ts "$timestamp" \
'. + [{content: $content, importance: $imp, timestamp: $ts, relevance: 0.5}]' \
"$MB1_LEARNED" > "$temp" && mv "$temp" "$MB1_LEARNED"
}
# Process a single file
process_file() {
local file="$1"
local type="$2"
local basename=$(basename "$file")
# Skip if too large (>100KB for text)
local size=$(stat -f%z "$file" 2>/dev/null || echo 0)
[[ $size -gt 102400 ]] && return
# Skip empty files
[[ $size -eq 0 ]] && return
# Extract meaningful name from mangled filename
local clean_name=$(echo "$basename" | sed 's/~__/\//g' | sed 's/__/\//g' | sed 's/\.json$//' | sed 's/\.py$//' | sed 's/\.sql$//' | sed 's/\.swift$//' | sed 's/\.cpp$//' | sed 's/\.cs$//' | sed 's/\.sh$//' | sed 's/\.yaml$//' | sed 's/\.md$//')
local content=""
local importance=0.85
case "$type" in
json)
# Extract key structure and values from JSON
content=$(cat "$file" | jq -c '.' 2>/dev/null | head -c 2000)
[[ -z "$content" ]] && return
content="[legacy:config] $clean_name: $content"
importance=0.88
;;
sql)
# Extract CREATE TABLE and key SQL structures
content=$(grep -E "^(CREATE|ALTER|INSERT|--.*[A-Z])" "$file" 2>/dev/null | head -30 | tr '\n' ' ')
[[ -z "$content" ]] && return
content="[legacy:schema] $clean_name: $content"
importance=0.90
;;
swift|py|cpp|cs|c)
# Extract class/function definitions and comments
content=$(grep -E "^(class |func |def |public |private |void |int |struct |//|#.*[A-Z]|import |using )" "$file" 2>/dev/null | head -30 | tr '\n' ' ')
[[ -z "$content" ]] && return
content="[legacy:code:$type] $clean_name: $content"
importance=0.87
;;
sh)
# Extract script purpose and key commands
content=$(grep -E "^(#|export |function |[A-Z_]+=)" "$file" 2>/dev/null | head -20 | tr '\n' ' ')
[[ -z "$content" ]] && return
content="[legacy:script] $clean_name: $content"
importance=0.86
;;
yaml)
# Extract YAML structure
content=$(cat "$file" | head -40 | tr '\n' ' ')
content="[legacy:config:yaml] $clean_name: $content"
importance=0.85
;;
md)
# Extract markdown content
content=$(cat "$file" | head -50 | tr '\n' ' ')
content="[legacy:docs] $clean_name: $content"
importance=0.84
;;
esac
# Add to MB1 if we have content
if [[ -n "$content" && ${#content} -gt 50 ]]; then
add_to_mb1 "$content" "$importance"
echo "$content" # Return for MB2 batch
return 0
fi
return 1
}
# Main ingestion
log "=== OLD AI ARCHIVE INGESTION STARTING ==="
log "Source: $SOURCE_DIR"
TOTAL=0
SUCCESS=0
# Create batch file for MB2
MB2_BATCH=$(mktemp)
# Process each type
for ext in json sql swift py cpp cs c sh yaml md; do
count=0
log "Processing .$ext files..."
while IFS= read -r -d '' file; do
((TOTAL++))
result=$(process_file "$file" "$ext")
if [[ $? -eq 0 && -n "$result" ]]; then
((SUCCESS++))
((count++))
echo "$result" >> "$MB2_BATCH"
fi
done < <(find "$SOURCE_DIR" -name "*.$ext" -type f -print0 2>/dev/null)
log " Processed $count $ext files"
done
log "=== MB1 INGESTION COMPLETE ==="
log "Total files: $TOTAL, Successfully ingested: $SUCCESS"
# Compress updated learned_items for iCloud
log "Compressing for iCloud..."
zstd -f "$MB1_LEARNED" -o "$HOME/Library/Mobile Documents/com~apple~CloudDocs/AGI_Data/agi_core/learned_items.json.zst" 2>/dev/null
# Send to MB2
log "=== SENDING TO MB2 ==="
BATCH_COUNT=$(wc -l < "$MB2_BATCH" | tr -d ' ')
log "Sending $BATCH_COUNT items to MB2..."
# Create remote ingestion script
sshpass -p [credential removed] ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 "$MB2_USER@$MB2_HOST" 'cat > /tmp/ingest_batch.sh' << 'REMOTE_SCRIPT'
#!/bin/bash
export PATH="/opt/homebrew/bin:$PATH"
LEARNED="$HOME/.seferim/data/learned_items.json"
mkdir -p "$HOME/.seferim/data"
[[ ! -f "$LEARNED" ]] && echo "[]" > "$LEARNED"
while IFS= read -r line; do
[[ -z "$line" ]] && continue
content=$(echo "$line" | jq -Rs '.')
timestamp=$(date +%s)
temp=$(mktemp)
jq --argjson c "$content" --argjson t "$timestamp" \
'. + [{content: $c, importance: 0.85, timestamp: $t, relevance: 0.5}]' \
"$LEARNED" > "$temp" && mv "$temp" "$LEARNED"
done
echo "MB2 ingestion complete"
REMOTE_SCRIPT
# Send the batch data
sshpass -p [credential removed] ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 "$MB2_USER@$MB2_HOST" 'cat > /tmp/ingest_data.txt' < "$MB2_BATCH"
# Execute ingestion on MB2
sshpass -p [credential removed] ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 "$MB2_USER@$MB2_HOST" 'chmod +x /tmp/ingest_batch.sh && cat /tmp/ingest_data.txt | /tmp/ingest_batch.sh'
rm -f "$MB2_BATCH"
log "=== INGESTION COMPLETE ==="
log "MB1: $SUCCESS items added to learned_items.json"
log "MB2: $BATCH_COUNT items sent for ingestion"