- install.sh: no longer exits early when ~/.automaton exists. Skips the clone but runs all setup (VRAM detection, guards, self-improvement loop, virtualenv). Both curl|bash and git-clone + ./install.sh now work correctly. - onboard-project.sh: new script that bootstraps automaton in a project — creates .automaton/ skeleton, detects models, writes config.md, inits git, installs hooks, adds .gitignore entries. - README.md: fix install flow docs (curl|bash + clone-then-run), add onboard-project.sh as Option A for project setup
119 lines
4.7 KiB
Bash
Executable File
119 lines
4.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
FRAMEWORK_DIR="$HOME/.automaton"
|
|
|
|
GIT_URL="${1:-}"
|
|
|
|
if [ ! -d "$FRAMEWORK_DIR" ]; then
|
|
# Fresh install — need a Git URL to clone
|
|
if [ -z "$GIT_URL" ]; then
|
|
echo "ERROR: Git URL required for fresh install."
|
|
echo ""
|
|
echo "Usage:"
|
|
echo " curl -fsSL https://raw.githubusercontent.com/<user>/automaton/main/scripts/install.sh | bash -s -- <git-url>"
|
|
echo ""
|
|
echo " --- or ---"
|
|
echo ""
|
|
echo " git clone <git-url> ~/.automaton"
|
|
echo " bash ~/.automaton/scripts/install.sh"
|
|
echo ""
|
|
echo "The framework is cloned to ~/.automaton. Choose your URL carefully"
|
|
echo "as it cannot be changed later without reinstalling."
|
|
exit 1
|
|
fi
|
|
echo "Cloning automaton from $GIT_URL to $FRAMEWORK_DIR..."
|
|
git clone "$GIT_URL" "$FRAMEWORK_DIR"
|
|
echo ""
|
|
else
|
|
echo "automaton already installed at $FRAMEWORK_DIR — running setup steps..."
|
|
if [ -n "$GIT_URL" ]; then
|
|
echo "Note: Git URL argument ignored because ~/.automaton already exists."
|
|
echo "To update, run: cd ~/.automaton && ./update.sh"
|
|
fi
|
|
echo ""
|
|
fi
|
|
|
|
# --- Everything below is idempotent and runs on both fresh and existing installs ---
|
|
|
|
echo "=== VRAM / Context Detection ==="
|
|
echo "Detecting your system's VRAM to recommend task decomposition settings..."
|
|
echo ""
|
|
|
|
# Run VRAM detection script if it exists
|
|
if [ -f "$FRAMEWORK_DIR/scripts/vram_detect.py" ]; then
|
|
# Run in project-dir context so it can read framework overhead
|
|
detection_output=$(cd "$FRAMEWORK_DIR" && python3 "$FRAMEWORK_DIR/scripts/vram_detect.py" 2>&1 || true)
|
|
|
|
# Extract JSON output (the block after "=== JSON Output ===")
|
|
json_output=$(echo "$detection_output" | sed -n '/=== JSON Output ===/,$p' | tail -n +2)
|
|
|
|
if [ -n "$json_output" ]; then
|
|
echo "$detection_output"
|
|
|
|
# Extract key values from JSON using Python
|
|
recommended_k=$(echo "$json_output" | python3 -c 'import json,sys; print(json.load(sys.stdin)["recommended_k"])' 2>/dev/null || echo "?")
|
|
max_peak_kb=$(echo "$json_output" | python3 -c 'import json,sys; print(json.load(sys.stdin)["max_peak_context_kb"])' 2>/dev/null || echo "?")
|
|
headroom=$(echo "$json_output" | python3 -c 'import json,sys; print(json.load(sys.stdin)["headroom"])' 2>/dev/null || echo "?")
|
|
|
|
echo ""
|
|
echo "=== Recommended VRAM Configuration ==="
|
|
echo "For low-VRAM systems (8GB, 16GB VRAM), add this to ~/.automaton/config.md:"
|
|
echo ""
|
|
echo "## VRAM Configuration"
|
|
echo "- **Auto-detect**: Yes # Let the agent detect automatically"
|
|
echo "- **Target context**: ${recommended_k}k tokens # Override auto-detect if needed"
|
|
echo "- **Headroom**: ${headroom}%"
|
|
echo "- **Max peak context per sub-task**: $((max_peak_kb / 1000))k tokens"
|
|
echo ""
|
|
echo "This ensures tasks are decomposed into sub-tasks that fit within your"
|
|
echo "available VRAM. For more information, see the README."
|
|
else
|
|
echo "Could not detect VRAM. You can manually set your VRAM configuration in ~/.automaton/config.md."
|
|
echo "See the README for details."
|
|
fi
|
|
else
|
|
echo "VRAM detection script not found. You can manually set your VRAM configuration in ~/.automaton/config.md."
|
|
echo "See the README for details."
|
|
fi
|
|
|
|
echo ""
|
|
echo "Installation complete."
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Onboard a project: bash ~/.automaton/scripts/onboard-project.sh /path/to/project"
|
|
echo " 2. Or tell your agent: 'Onboard this project into automaton'"
|
|
echo ""
|
|
|
|
# Register pre-edit guards for detected harnesses
|
|
bash "$FRAMEWORK_DIR/scripts/register-guards.sh"
|
|
|
|
# Bootstrap self-improvement loop (default-on, D21)
|
|
python3 "$FRAMEWORK_DIR/scripts/status.py" --create-loop self-improvement \
|
|
--from-template self-improvement --project "$FRAMEWORK_DIR" || true
|
|
python3 "$FRAMEWORK_DIR/scripts/status.py" --install-schedule self-improvement \
|
|
--interval 3600 --project "$FRAMEWORK_DIR" || true
|
|
|
|
echo ""
|
|
echo "=== Self-Improvement Loop ==="
|
|
echo "A self-improvement loop has been created and scheduled (runs every 3600s)."
|
|
echo "It will tick against status.py --audit on this framework's own repo."
|
|
echo "To disable: python3 ~/.automaton/scripts/status.py --pause-loop self-improvement --project ~/.automaton/"
|
|
echo ""
|
|
|
|
# Verify framework is working
|
|
python3 "$FRAMEWORK_DIR/scripts/status.py" --version || echo "WARNING: status.py --version failed"
|
|
|
|
# --- Python deps (idempotent, in framework dir) ---
|
|
if [ ! -d "$FRAMEWORK_DIR/.venv" ]; then
|
|
python3 -m venv "$FRAMEWORK_DIR/.venv"
|
|
fi
|
|
if [ -f "$FRAMEWORK_DIR/.venv/bin/python3" ]; then
|
|
VENV_PY="$FRAMEWORK_DIR/.venv/bin/python3"
|
|
elif [ -f "$FRAMEWORK_DIR/.venv/Scripts/python.exe" ]; then
|
|
VENV_PY="$FRAMEWORK_DIR/.venv/Scripts/python.exe"
|
|
else
|
|
VENV_PY="python3"
|
|
fi
|
|
"$VENV_PY" -m pip install --quiet --upgrade pip
|
|
"$VENV_PY" -m pip install --quiet -r "$FRAMEWORK_DIR/requirements.txt" |