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
This commit is contained in:
7
automation/README.md
Normal file
7
automation/README.md
Normal file
@@ -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
|
||||
36
automation/automation-daemon.sh
Executable file
36
automation/automation-daemon.sh
Executable file
@@ -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
|
||||
65
automation/executor.sh
Executable file
65
automation/executor.sh
Executable file
@@ -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"
|
||||
2
automation/logs/.gitkeep
Normal file
2
automation/logs/.gitkeep
Normal file
@@ -0,0 +1,2 @@
|
||||
# Logs Directory
|
||||
Execution logs and completed tasks
|
||||
3
automation/queue/.gitkeep
Normal file
3
automation/queue/.gitkeep
Normal file
@@ -0,0 +1,3 @@
|
||||
# Queue Directory
|
||||
Tasks from Claude will appear here as .sh files
|
||||
|
||||
3
automation/results/.gitkeep
Normal file
3
automation/results/.gitkeep
Normal file
@@ -0,0 +1,3 @@
|
||||
# Results Directory
|
||||
Execution results will be committed here
|
||||
|
||||
Reference in New Issue
Block a user