From d664f5ce5b906a5418da19dbbc22cea07648c092 Mon Sep 17 00:00:00 2001 From: Michael Krause Date: Mon, 9 Feb 2026 10:05:09 -0600 Subject: [PATCH] Add Firefrost Automation System Initial automation framework: - executor.sh: Runs queued tasks and commits results - automation-daemon.sh: Watches Git for new tasks every 10s - queue/: Tasks from Claude (*.sh files) - results/: Execution results committed back - logs/: Execution logs and completed tasks System enables Claude to commit operations to Git, TX1 pulls and executes automatically, then commits results back. Reduces manual copy/paste from Michael to ONE command at session start. Built for marathon sessions and medical accessibility needs. Phase 1 complete - ready for testing --- automation/README.md | 7 ++++ automation/automation-daemon.sh | 36 ++++++++++++++++++ automation/executor.sh | 65 +++++++++++++++++++++++++++++++++ automation/logs/.gitkeep | 2 + automation/queue/.gitkeep | 3 ++ automation/results/.gitkeep | 3 ++ 6 files changed, 116 insertions(+) create mode 100644 automation/README.md create mode 100755 automation/automation-daemon.sh create mode 100755 automation/executor.sh create mode 100644 automation/logs/.gitkeep create mode 100644 automation/queue/.gitkeep create mode 100644 automation/results/.gitkeep diff --git a/automation/README.md b/automation/README.md new file mode 100644 index 0000000..a065c39 --- /dev/null +++ b/automation/README.md @@ -0,0 +1,7 @@ +# Firefrost Automation System + +This directory contains the Git-based automation system for TX1. + +- queue/ - Commands from Claude to be executed +- results/ - Execution results committed back +- logs/ - Execution logs and history diff --git a/automation/automation-daemon.sh b/automation/automation-daemon.sh new file mode 100755 index 0000000..09e0bf1 --- /dev/null +++ b/automation/automation-daemon.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Firefrost Automation Daemon +# Watches for new tasks in Git and executes them + +REPO_DIR="/root/firefrost-work/firefrost-operations-manual" +LOG_DIR="$REPO_DIR/automation/logs" +EXECUTOR="$REPO_DIR/automation/executor.sh" +CHECK_INTERVAL=10 # Check every 10 seconds + +# Function to log with timestamp +log() { + echo "[$(date '+%Y-%m-%d %H:%M:%S')] DAEMON: $1" | tee -a "$LOG_DIR/daemon.log" +} + +log "==========================================" +log "Firefrost Automation Daemon Starting" +log "Check Interval: ${CHECK_INTERVAL}s" +log "==========================================" + +cd "$REPO_DIR" + +while true; do + # Pull latest from Git (quietly) + git pull origin master &>/dev/null + + # Check if there are tasks in queue + TASK_COUNT=$(find automation/queue -name "*.sh" -type f 2>/dev/null | wc -l) + + if [ "$TASK_COUNT" -gt 0 ]; then + log "Found $TASK_COUNT task(s) in queue - executing..." + bash "$EXECUTOR" + fi + + # Wait before next check + sleep "$CHECK_INTERVAL" +done diff --git a/automation/executor.sh b/automation/executor.sh new file mode 100755 index 0000000..5622dbe --- /dev/null +++ b/automation/executor.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# Firefrost Automation Executor +# Runs queued commands and commits results back to Git + +set -e # Exit on error + +QUEUE_DIR="/root/firefrost-work/firefrost-operations-manual/automation/queue" +RESULTS_DIR="/root/firefrost-work/firefrost-operations-manual/automation/results" +LOG_DIR="/root/firefrost-work/firefrost-operations-manual/automation/logs" +REPO_DIR="/root/firefrost-work/firefrost-operations-manual" + +# Function to log with timestamp +log() { + echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_DIR/executor.log" +} + +# Change to repo directory +cd "$REPO_DIR" + +# Pull latest from Git +log "Pulling latest from Git..." +git pull origin master || log "WARNING: Git pull failed, continuing with local" + +# Check for queued tasks +TASKS=$(find "$QUEUE_DIR" -name "*.sh" -type f | sort) + +if [ -z "$TASKS" ]; then + log "No tasks in queue" + exit 0 +fi + +# Process each task +for TASK in $TASKS; do + TASK_NAME=$(basename "$TASK") + RESULT_FILE="$RESULTS_DIR/${TASK_NAME%.sh}_result.txt" + + log "==========================================" + log "Executing task: $TASK_NAME" + log "==========================================" + + # Execute task and capture output + { + echo "Task: $TASK_NAME" + echo "Started: $(date)" + echo "==========================================" + bash "$TASK" 2>&1 + EXIT_CODE=$? + echo "==========================================" + echo "Finished: $(date)" + echo "Exit Code: $EXIT_CODE" + } > "$RESULT_FILE" + + # Move task to completed (remove from queue) + mv "$TASK" "$LOG_DIR/${TASK_NAME%.sh}_completed_$(date +%Y%m%d_%H%M%S).sh" + + log "Task $TASK_NAME completed (exit code: $EXIT_CODE)" +done + +# Commit results back to Git +log "Committing results to Git..." +git add automation/results/*.txt automation/logs/*.sh 2>/dev/null || true +git commit -m "Automation: Task execution results $(date '+%Y-%m-%d %H:%M:%S')" || log "Nothing to commit" +git push origin master || log "WARNING: Git push failed" + +log "Executor run complete" diff --git a/automation/logs/.gitkeep b/automation/logs/.gitkeep new file mode 100644 index 0000000..30abab8 --- /dev/null +++ b/automation/logs/.gitkeep @@ -0,0 +1,2 @@ +# Logs Directory +Execution logs and completed tasks diff --git a/automation/queue/.gitkeep b/automation/queue/.gitkeep new file mode 100644 index 0000000..e4e907a --- /dev/null +++ b/automation/queue/.gitkeep @@ -0,0 +1,3 @@ +# Queue Directory +Tasks from Claude will appear here as .sh files + diff --git a/automation/results/.gitkeep b/automation/results/.gitkeep new file mode 100644 index 0000000..9d0374e --- /dev/null +++ b/automation/results/.gitkeep @@ -0,0 +1,3 @@ +# Results Directory +Execution results will be committed here +