4.1 KiB
4.1 KiB
Setup & Onboarding (setup.org)
- Overview: The Zero-to-One Experience
- 1. The Unified Entrypoint (opencortex.sh)
- 2. The Baremetal Path (onboard-baremetal.sh)
Overview: The Zero-to-One Experience
The Setup & Onboarding process ensures that users can boot the opencortex Lisp Machine with zero friction.
1. The Unified Entrypoint (opencortex.sh)
set -e
PORT=9105
HOST=${1:-localhost}
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NC='\033[0m'
command_exists() { command -v "$1" >/dev/null 2>&1; }
# --- Bootstrap Mode ---
bootstrap_opencortex() {
echo -e "${BLUE}=== OpenCortex: Zero-to-One Bootstrapper ===${NC}"
if [ -d ".git" ]; then return; fi
TARGET_DIR="opencortex"
if [ ! -d "$TARGET_DIR" ]; then
echo -e "${BLUE}Cloning repository into $TARGET_DIR...${NC}"
git clone http://10.10.10.201:3001/amr/opencortex.git "$TARGET_DIR"
fi
cd "$TARGET_DIR"
git submodule update --init --recursive
echo -e "${GREEN}✓ Repository prepared.${NC}"
./scripts/onboard-baremetal.sh
echo -e "${GREEN}✓ Setup phase complete.${NC}"
exit 0
}
if [ ! -d ".git" ]; then bootstrap_opencortex; fi
# 1. Try to drop straight into the CLI chat
if command_exists socat && socat - TCP:$HOST:$PORT,connect-timeout=1 2>/dev/null; then
echo -e "${BLUE}Connected to autonomous brain at $HOST:$PORT...${NC}"
socat READLINE,history=$HOME/.org_agent_history TCP:$HOST:$PORT
exit 0
fi
# 2. Launch
if [ -f "opencortex.asd" ]; then echo -e "${YELLOW}Brain is offline. Starting it now...${NC}"; $0 --boot > brain.log 2>&1 & sleep 10; exec $0 "$@"; fi
done < .env
fi
echo -e "${BLUE}Starting OpenCortex Brain...${NC}"
sbcl --non-interactive \
--eval "(load \"~/quicklisp/setup.lisp\")" \
--eval "(push \"$(pwd)/\" asdf:*central-registry*)" \
--eval "(ql:quickload :opencortex)" \
--eval "(opencortex:main)"
fi
2. The Baremetal Path (onboard-baremetal.sh)
# OpenCortex Final-Mile Installer
RED='\033[0;31m'; GREEN='\033[0;32m'; BLUE='\033[0;34m'; YELLOW='\033[0;33m'; NC='\033[0m'
echo -e "${BLUE}=== OpenCortex: Baremetal Power-User Setup ===${NC}"
prompt_user() {
local prompt="$1"
local default="$2"
local var_name="$3"
local result=""
echo -n -e "${YELLOW}$prompt (default: $default): ${NC}" >&2
if read -t 5 result; then :; else result="$default"; echo -e "${BLUE} [Auto-Selected: $default]${NC}" >&2 fi
val=${result:-$default}
eval "$var_name=\"$val\""
}
if ! command -v sbcl >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y sbcl emacs git curl socat || true
fi
if [ ! -d "$HOME/quicklisp" ]; then
curl -O https://beta.quicklisp.org/quicklisp.lisp
sbcl --non-interactive --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --eval "(ql-util:without-prompting (ql:add-to-init-file))"
rm quicklisp.lisp
fi
echo -e "${BLUE}Tangling source files...${NC}"
mkdir -p src
for f in literate/*.org; do
emacs --batch --eval "(require 'org)" --eval "(org-babel-tangle-file \"$f\")" >/dev/null 2>&1
done
if [ ! -f .env ]; then cp .env.example .env; fi
prompt_user "What is your name?" "User" "USER_NAME"
prompt_user "What shall we name your Assistant?" "OpenCortex" "AGENT_NAME"
prompt_user "Select provider (1:Gemini, 2:OpenRouter)" "1" "LLM_CHOICE"
sed -i "s/MEMEX_USER=.*/MEMEX_USER=\"$USER_NAME\"/g" .env
sed -i "s/MEMEX_ASSISTANT=.*/MEMEX_ASSISTANT=\"$AGENT_NAME\"/g" .env
ROOT_DIR=$(pwd)
sed -i "s|MEMEX_DIR=.*|MEMEX_DIR=\"$(dirname $ROOT_DIR)\"|g" .env
sed -i "s|SKILLS_DIR=.*|SKILLS_DIR=\"$ROOT_DIR/skills\"|g" .env
mkdir -p "$HOME/.local/bin"
ln -sf "$ROOT_DIR/opencortex.sh" "$HOME/.local/bin/opencortex"
echo -e "${GREEN}✓ Installed 'opencortex' command to ~/.local/bin${NC}"
echo -e "\n${GREEN}==============================================${NC}"
echo -e "${GREEN} OpenCortex Installation Complete! ${NC}"
echo -e "${GREEN}==============================================${NC}"
echo -e "To start: opencortex"