Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/complete-agi-core / seferim/seferim-learner.sh |
| Date | Not specified in source |
| Repository | Janady13/complete-agi-core |
| Revision | 223c58f8857eb60c4d020e6d6feacdbfb482d71d |
| Branch | main |
| Path or archive member | seferim/seferim-learner.sh |
| Original SHA-256 | 823b8af54b1521c77ccf2ff92311e7df1e7c50dfba1133bd251e8d8422f18833 |
| Git blob SHA | 1c0fad4c4bd8086b29196f69004686bbf35c78ee |
| Reading-copy SHA-256 | 823b8af54b1521c77ccf2ff92311e7df1e7c50dfba1133bd251e8d8422f18833 |
Every recorded occurrence
These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/complete-agi-core / seferim/seferim-learner.sh | main | 223c58f8857eb60c4d020e6d6feacdbfb482d71d | Open original |
| Janady13/complete-agi-core / seferim/seferim-learner.sh | claude/improve-math-logic-ehIW1 | 33aa84f2aa61cedbe010240ada7f4efbdfe795a7 | Open original |
Recovered source transcript
Download complete source text ↓249 lines · 9.3 KB
#!/bin/bash
# =============================================================================
# SEFERIM LEARNER v4 - Simple HTTP APIs (no jq, no Python dependencies)
# Uses curl + sed for parsing
# =============================================================================
set +e
LOG=~/.seferim/logs/learner.log
LEARNED_DIR=~/.seferim/learned
ICLOUD_LEARNED=~/Library/Mobile\ Documents/com~apple~CloudDocs/AGI_Data/learned/macbook2
mkdir -p "$LEARNED_DIR" "$ICLOUD_LEARNED" ~/.seferim/logs
UA="SEFERIM-AGI/2.0"
FAMILIES="epona athena aurora selene mnemosyne logos yad hermes prometheus"
get_family_topics() {
case "$1" in
epona) echo "science history biology physics chemistry astronomy" ;;
athena) echo "strategy planning military chess war business" ;;
aurora) echo "art music painting sculpture creativity poetry" ;;
selene) echo "consciousness mind brain thought awareness" ;;
mnemosyne) echo "memory learning knowledge cognition" ;;
logos) echo "mathematics logic proof theorem algebra geometry" ;;
yad) echo "programming algorithm software code computer" ;;
hermes) echo "communication network internet protocol" ;;
prometheus) echo "innovation technology invention startup" ;;
*) echo "knowledge science fact" ;;
esac
}
# =============================================================================
# SIMPLE API FUNCTIONS (curl + sed parsing)
# =============================================================================
# Quotable - returns quotes (HTTP works!)
fetch_quote() {
local raw=$(curl -s --max-time 8 "http://api.quotable.io/random" 2>/dev/null)
if [ -n "$raw" ]; then
# Extract content and author using sed
local content=$(echo "$raw" | sed 's/.*"content":"\([^"]*\)".*/\1/')
local author=$(echo "$raw" | sed 's/.*"author":"\([^"]*\)".*/\1/')
echo "Quote: $content - $author"
fi
}
# Numbers API - math facts (HTTP)
fetch_number_fact() {
local num=$((RANDOM % 1000))
curl -s --max-time 5 "http://numbersapi.com/$num/math" 2>/dev/null
}
# Date facts (HTTP)
fetch_date_fact() {
local month=$(( (RANDOM % 12) + 1 ))
local day=$(( (RANDOM % 28) + 1 ))
curl -s --max-time 5 "http://numbersapi.com/$month/$day/date" 2>/dev/null
}
# HackerNews (HTTPS but usually works)
fetch_hackernews() {
local idx=$((RANDOM % 30))
local ids=$(curl -sk --max-time 5 "https://hacker-news.firebaseio.com/v0/topstories.json" 2>/dev/null)
if [ -n "$ids" ]; then
# Extract ID at position using sed
local story_id=$(echo "$ids" | sed 's/\[//' | sed 's/\]//' | cut -d',' -f$((idx + 1)) | tr -d ' ')
if [ -n "$story_id" ]; then
local story=$(curl -sk --max-time 5 "https://hacker-news.firebaseio.com/v0/item/$story_id.json" 2>/dev/null)
if [ -n "$story" ]; then
local title=$(echo "$story" | sed 's/.*"title":"\([^"]*\)".*/\1/')
local score=$(echo "$story" | sed 's/.*"score":\([0-9]*\).*/\1/')
echo "HackerNews: $title. Score: $score"
fi
fi
fi
}
# Wikipedia (HTTPS - may need -k flag)
fetch_wikipedia() {
local topic="$1"
local encoded=$(echo "$topic" | sed 's/ /%20/g')
local raw=$(curl -sk --max-time 10 \
"https://en.wikipedia.org/w/api.php?action=query&titles=$encoded&prop=extracts&exintro=1&explaintext=1&format=json" \
-H "User-Agent: $UA" 2>/dev/null)
if [ -n "$raw" ]; then
# Extract between "extract":" and the next "}
local extract=$(echo "$raw" | sed 's/.*"extract":"//' | sed 's/"},.*//' | head -c 800)
if [ -n "$extract" ] && [ "$extract" != "$raw" ]; then
echo "$extract"
fi
fi
}
# DuckDuckGo (HTTPS)
fetch_duckduckgo() {
local query="$1"
local encoded=$(echo "$query" | sed 's/ /+/g')
local raw=$(curl -sk --max-time 8 \
"https://api.duckduckgo.com/?q=$encoded&format=json&no_html=1" \
-H "User-Agent: $UA" 2>/dev/null)
if [ -n "$raw" ]; then
# Try AbstractText first
local abstract=$(echo "$raw" | sed 's/.*"AbstractText":"//' | sed 's/",.*//' | head -c 600)
if [ -n "$abstract" ] && [ ${#abstract} -gt 20 ] && [ "$abstract" != "$raw" ]; then
echo "$abstract"
fi
fi
}
# Cat facts (HTTP - fun fallback)
fetch_cat_fact() {
local raw=$(curl -sk --max-time 5 "https://catfact.ninja/fact" 2>/dev/null)
if [ -n "$raw" ]; then
local fact=$(echo "$raw" | sed 's/.*"fact":"//' | sed 's/".*//')
echo "Cat Fact: $fact"
fi
}
# =============================================================================
# SMART FETCH
# =============================================================================
smart_fetch() {
local topic="$1"
local family="$2"
local content=""
local source=""
case "$family" in
aurora|creativity)
content=$(fetch_quote)
source="quotable"
;;
logos|mathematics)
content=$(fetch_number_fact)
source="numbersapi"
[ -z "$content" ] && { content=$(fetch_date_fact); source="numbersapi"; }
;;
hermes|prometheus)
content=$(fetch_hackernews)
source="hackernews"
;;
*)
# Try Wikipedia first
content=$(fetch_wikipedia "$topic")
source="wikipedia"
# Fallback to DuckDuckGo
[ -z "$content" ] || [ ${#content} -lt 30 ] && { content=$(fetch_duckduckgo "$topic"); source="duckduckgo"; }
# Fallback to quote
[ -z "$content" ] || [ ${#content} -lt 30 ] && { content=$(fetch_quote); source="quotable"; }
# Fallback to number fact
[ -z "$content" ] || [ ${#content} -lt 30 ] && { content=$(fetch_number_fact); source="numbersapi"; }
;;
esac
# Ultimate fallback
[ -z "$content" ] || [ ${#content} -lt 15 ] && { content=$(fetch_cat_fact); source="catfact"; }
echo "$content|$source"
}
# =============================================================================
# LEARN
# =============================================================================
learn_topic() {
local topic="$1"
local family="$2"
local importance="${3:-0.75}"
echo "[$(date +%H:%M:%S)] Fetching: $topic for $family" >> "$LOG"
local result=$(smart_fetch "$topic" "$family")
local content=$(echo "$result" | rev | cut -d'|' -f2- | rev) # Everything before last |
local source=$(echo "$result" | rev | cut -d'|' -f1 | rev) # Last field
if [ -n "$content" ] && [ ${#content} -gt 15 ]; then
local ts=$(date +%s)
local day=$(date +%Y%m%d)
local safe_content=$(echo "$content" | head -c 700 | tr '\n' ' ' | sed 's/"/\\"/g' | sed "s/'/\\'/g")
local entry="{\"timestamp\":$ts,\"source\":\"macbook2\",\"api\":\"$source\",\"topic\":\"$topic\",\"family\":\"$family\",\"content\":\"$safe_content\",\"importance\":$importance}"
echo "$entry" >> "$LEARNED_DIR/$day.jsonl"
echo "$entry" >> "$ICLOUD_LEARNED/$day.jsonl"
echo "[$(date +%H:%M:%S)] LEARNED [$family] $topic from $source (${#content} chars)" >> "$LOG"
return 0
else
echo "[$(date +%H:%M:%S)] FAILED: $topic (content too short: ${#content})" >> "$LOG"
return 1
fi
}
get_random_family() {
local arr=($FAMILIES)
local idx=$((RANDOM % ${#arr[@]}))
echo "${arr[$idx]}"
}
get_random_topic() {
local topics=$(get_family_topics "$1")
local arr=($topics)
local idx=$((RANDOM % ${#arr[@]}))
echo "${arr[$idx]}"
}
# =============================================================================
# MAIN
# =============================================================================
echo "=============================================" >> "$LOG"
echo "[$(date)] SEFERIM Learner v4 (Simple HTTP)" >> "$LOG"
echo " - No jq/Python dependencies" >> "$LOG"
echo " - HTTP-first APIs" >> "$LOG"
echo "=============================================" >> "$LOG"
cycle=0
while true; do
cycle=$((cycle + 1))
FAMILY=$(get_random_family)
TOPIC=$(get_random_topic "$FAMILY")
echo "" >> "$LOG"
echo "[$(date +%H:%M:%S)] === Cycle $cycle ===" >> "$LOG"
echo "[$(date +%H:%M:%S)] Family: $FAMILY, Topic: $TOPIC" >> "$LOG"
learn_topic "$TOPIC" "$FAMILY" 0.75
# Curiosity every 4 cycles
if [ $((cycle % 4)) -eq 0 ]; then
echo "[$(date +%H:%M:%S)] CURIOSITY: HackerNews" >> "$LOG"
hn=$(fetch_hackernews)
if [ -n "$hn" ] && [ ${#hn} -gt 20 ]; then
ts=$(date +%s)
day=$(date +%Y%m%d)
safe=$(echo "$hn" | head -c 500 | tr '\n' ' ' | sed 's/"/\\"/g')
echo "{\"timestamp\":$ts,\"source\":\"macbook2\",\"api\":\"hackernews\",\"topic\":\"tech-news\",\"family\":\"hermes\",\"content\":\"$safe\",\"importance\":0.65}" >> "$LEARNED_DIR/$day.jsonl"
echo "{\"timestamp\":$ts,\"source\":\"macbook2\",\"api\":\"hackernews\",\"topic\":\"tech-news\",\"family\":\"hermes\",\"content\":\"$safe\",\"importance\":0.65}" >> "$ICLOUD_LEARNED/$day.jsonl"
echo "[$(date +%H:%M:%S)] CURIOSITY learned!" >> "$LOG"
fi
fi
# Status every 8
if [ $((cycle % 8)) -eq 0 ]; then
total=$(cat "$LEARNED_DIR"/*.jsonl 2>/dev/null | wc -l | tr -d ' ')
echo "[$(date +%H:%M:%S)] STATUS: $total total items" >> "$LOG"
fi
sleep 35
done