feat: complete ONI Agent project with full Mod API, Python toolchain, and development guide

- Implement all Mod API endpoints (buildings, research, geysers, alerts, critters, deconstruct, prioritize, research, schedule, wardrobe)
- Enhance Python tools with comprehensive CLI, analysis (O2/food/power/temp/water), and 7 blueprints (SPOM, toilet, ranch, farm, cooling, bedroom)
- Add utility scripts: auto_repair, auto_analyze, watch mode, setup
- Write Agent-Mod integration constraints and development guide
- Create skills directory with ONI agent skill definition
This commit is contained in:
root
2026-05-22 08:44:56 +08:00
commit 0e17e8a6ac
14 changed files with 1579 additions and 0 deletions

30
scripts/auto_analyze.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# ONI Agent - Quick analysis report
# Runs health check, then pulls full game state and analyzes it.
set -euo pipefail
SCRIPT_DIR="$(dirname "$0")"
TOOLS_DIR="$SCRIPT_DIR/../tools"
echo "========================================"
echo " ONI Agent - Quick Analysis"
echo "========================================"
# Step 1: Health check
echo "[1/3] Checking Mod connection..."
python3 "$TOOLS_DIR/oni_api.py" health 2>/dev/null || {
echo "[!] Game not connected. Run auto_repair.sh first."
exit 1
}
# Step 2: Full status dump
echo "[2/3] Fetching game state..."
python3 "$TOOLS_DIR/oni_api.py" status
# Step 3: Analysis report
echo ""
echo "[3/3] Running analysis..."
python3 "$TOOLS_DIR/oni_analyzer.py"
echo ""
echo "Done."

28
scripts/auto_repair.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# ONI Agent - Auto Repair Script
# Detects game connection issues and attempts to restart the Mod bridge.
set -euo pipefail
CONFIG_PATH="$(dirname "$0")/../config.json"
HOST=$(python3 -c "import json; print(json.load(open('$CONFIG_PATH'))['modHost'])")
PORT=$(python3 -c "import json; print(json.load(open('$CONFIG_PATH'))['modPort'])")
TIMEOUT=$(python3 -c "import json; print(json.load(open('$CONFIG_PATH'))['timeout'])")
check_health() {
curl -sf --max-time "$TIMEOUT" "http://$HOST:$PORT/health" > /dev/null 2>&1
}
echo "[ONI Agent] Checking Mod connection..."
if check_health; then
echo "[OK] Mod is running on $HOST:$PORT"
exit 0
else
echo "[!] Cannot reach Mod at $HOST:$PORT"
echo " Make sure Oxygen Not Included is running with the ONI Agent Bridge mod enabled."
echo " Steps:"
echo " 1. Launch Oxygen Not Included"
echo " 2. Enable 'ONI Agent Bridge' mod in the Mod menu"
echo " 3. Load a save or start a new game"
echo " 4. Run this script again"
exit 1
fi

28
scripts/setup.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# ONI Agent - Project Setup Script
# Ensures Python dependencies and directory structure.
set -euo pipefail
echo "[ONI Agent] Setting up project..."
# Verify Python3
if ! command -v python3 &> /dev/null; then
echo "[!] Python3 is required but not found."
exit 1
fi
echo "[OK] Python3 found: $(python3 --version)"
# Verify Python tools are syntactically valid
TOOLS_DIR="$(dirname "$0")/../tools"
for f in "$TOOLS_DIR"/*.py; do
python3 -m py_compile "$f" 2>/dev/null && echo "[OK] $f" || echo "[!] Syntax error in $f"
done
echo ""
echo "[OK] Setup complete."
echo ""
echo "Next steps:"
echo " 1. Launch Oxygen Not Included with the ONI Agent Bridge mod"
echo " 2. Run: python3 tools/oni_api.py health"
echo " 3. Run: python3 tools/oni_api.py status"
echo " 4. Run: python3 tools/oni_analyzer.py"

26
scripts/watch.sh Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# ONI Agent - Watch Mode
# Continuously polls game state and runs analysis on a timer.
set -euo pipefail
SCRIPT_DIR="$(dirname "$0")"
TOOLS_DIR="$SCRIPT_DIR/../tools"
INTERVAL=${1:-60}
if ! [[ "$INTERVAL" =~ ^[0-9]+$ ]] || [ "$INTERVAL" -lt 10 ]; then
echo "Usage: watch.sh [interval_seconds] (minimum 10)"
exit 1
fi
echo "[ONI Agent] Watch mode started (interval: ${INTERVAL}s)"
echo "Press Ctrl+C to stop."
echo ""
while true; do
clear 2>/dev/null || true
output=$(python3 "$TOOLS_DIR/oni_analyzer.py" 2>&1)
echo "$output"
echo ""
echo "[Next update in ${INTERVAL}s...]"
sleep "$INTERVAL"
done