|
#!/bin/bash |
|
|
|
# ========================================== |
|
# RALPH WIGGUM LOOP (Pure Autonomy Mode) |
|
# "The Agent is the boss. The script is the memory." |
|
# ========================================== |
|
|
|
# --- CONFIGURATION --- |
|
TASK_FILE="PROMPT.md" |
|
MAX_ITERATIONS=15 |
|
ITERATION=0 |
|
|
|
# Logging Setup (Timestamped) |
|
# Creates a unique folder for this session: .auggie_wiggum/2026-01-09_14-30-00 |
|
CURRENT_DATE_AND_TIME=$(date +"%Y-%m-%d_%H-%M-%S") |
|
LOG_DIR="./.auggie_wiggum/$CURRENT_DATE_AND_TIME" |
|
|
|
mkdir -p "$LOG_DIR" |
|
|
|
# --- PRE-FLIGHT CHECKS --- |
|
if [ ! -f "$TASK_FILE" ]; then |
|
echo "β Error: $TASK_FILE not found." |
|
exit 1 |
|
fi |
|
|
|
echo "π Starting Auggie (Autonomous Mode)..." |
|
echo "π Session saved in: $LOG_DIR" |
|
echo "-----------------------------------" |
|
|
|
# --- THE LOOP --- |
|
while [ $ITERATION -lt $MAX_ITERATIONS ]; do |
|
echo "π Iteration $ITERATION" |
|
|
|
# 1. BUILD CONTEXT (MEMORY) |
|
# The script reads everything the agent "thought" and "did" in previous iterations. |
|
HISTORY_CONTEXT="" |
|
|
|
if [ $ITERATION -gt 0 ]; then |
|
echo " (Reading memory from previous iterations...)" |
|
for (( i=0; i<ITERATION; i++ )); do |
|
PREV_FILE="$LOG_DIR/iteration_$i.txt" |
|
if [ -f "$PREV_FILE" ]; then |
|
STEP_CONTENT=$(cat "$PREV_FILE") |
|
HISTORY_CONTEXT+=$'\n'"--- HISTORY (Iteration #$i) ---"$'\n'"$STEP_CONTENT"$'\n' |
|
fi |
|
done |
|
fi |
|
|
|
# 2. CONSTRUCT THE PROMPT |
|
# We instruct the agent to use its own tools to verify the work. |
|
FULL_PROMPT=" |
|
$(cat "$TASK_FILE") |
|
|
|
====== SHORT-TERM MEMORY (What you already tried) ====== |
|
$HISTORY_CONTEXT |
|
======================================================== |
|
|
|
LOOP INSTRUCTIONS: |
|
1. You are running in an autonomous loop. |
|
2. Analyze the history above. If you tried something and it failed, try a different approach. |
|
3. YOU are responsible for ensuring the code works. Run your own internal checks/tests if possible. |
|
4. If the task is 100% COMPLETE and TESTED, write exactly \"I'm done\" on the very last line. |
|
5. If not finished, briefly describe your progress and what you will do next. |
|
" |
|
|
|
# 3. RUN AUGGIE |
|
# --print: captures output to file | --quiet: suppresses system logs |
|
OUTPUT=$(auggie --print --quiet "$FULL_PROMPT") |
|
|
|
# 4. SAVE LOG (The "Memory") |
|
CURRENT_LOG_FILE="$LOG_DIR/iteration_$ITERATION.txt" |
|
echo "$OUTPUT" > "$CURRENT_LOG_FILE" |
|
echo "π Thought process saved: $CURRENT_LOG_FILE" |
|
|
|
# 5. CHECK IF AGENT DECIDED TO STOP |
|
# Looks for "I'm done" on the last line (case insensitive) |
|
LAST_LINE=$(echo "$OUTPUT" | tail -n 1 | xargs | tr '[:upper:]' '[:lower:]') |
|
|
|
if [[ "$LAST_LINE" == *"i'm done"* ]]; then |
|
echo "-----------------------------------" |
|
echo "β
Agent reported completion." |
|
echo "π Full history available at: $LOG_DIR" |
|
exit 0 |
|
fi |
|
|
|
((ITERATION++)) |
|
|
|
# Safety pause to avoid API rate limits |
|
sleep 2 |
|
done |
|
|
|
echo "π Max iterations reached without completion signal." |
|
exit 1 |