fix: Absolute path for ASDF registry in script
This commit is contained in:
@@ -25,6 +25,7 @@ command_exists() { command -v "$1" >/dev/null 2>&1; }
|
|||||||
bootstrap_opencortex() {
|
bootstrap_opencortex() {
|
||||||
echo -e "${BLUE}=== OpenCortex: Zero-to-One Bootstrapper ===${NC}"
|
echo -e "${BLUE}=== OpenCortex: Zero-to-One Bootstrapper ===${NC}"
|
||||||
if [ -d ".git" ]; then return; fi
|
if [ -d ".git" ]; then return; fi
|
||||||
|
|
||||||
TARGET_DIR="opencortex"
|
TARGET_DIR="opencortex"
|
||||||
if [ ! -d "$TARGET_DIR" ]; then
|
if [ ! -d "$TARGET_DIR" ]; then
|
||||||
echo -e "${BLUE}Cloning repository into $TARGET_DIR...${NC}"
|
echo -e "${BLUE}Cloning repository into $TARGET_DIR...${NC}"
|
||||||
@@ -38,25 +39,52 @@ bootstrap_opencortex() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -d ".git" ]; then bootstrap_opencortex; fi
|
if [ ! -d ".git" ] && [[ ! "$(pwd)" =~ "opencortex" ]]; then
|
||||||
|
bootstrap_opencortex
|
||||||
|
fi
|
||||||
|
|
||||||
# 1. Try to drop straight into the CLI chat
|
# --- Helper: Load Env ---
|
||||||
|
load_env() {
|
||||||
|
if [ -f .env ]; then
|
||||||
|
while IFS='=' read -r key value || [ -n "$key" ]; do
|
||||||
|
# Remove whitespace and quotes
|
||||||
|
key=$(echo "$key" | xargs)
|
||||||
|
value=$(echo "$value" | xargs | sed 's/^"//;s/"$//')
|
||||||
|
if [[ "$key" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then
|
||||||
|
export "$key=$value"
|
||||||
|
fi
|
||||||
|
done < .env
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Force Boot ---
|
||||||
|
if [[ "$1" == "--boot" ]]; then
|
||||||
|
load_env
|
||||||
|
echo -e "${BLUE}Starting OpenCortex Brain...${NC}"
|
||||||
|
# Use absolute path to the directory containing this script for ASDF
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
exec sbcl --non-interactive \
|
||||||
|
--eval "(load \"~/quicklisp/setup.lisp\")" \
|
||||||
|
--eval "(push \"$SCRIPT_DIR/\" asdf:*central-registry*)" \
|
||||||
|
--eval "(ql:quickload :opencortex)" \
|
||||||
|
--eval "(opencortex:main)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Client Mode ---
|
||||||
if command_exists socat && socat - TCP:$HOST:$PORT,connect-timeout=1 2>/dev/null; then
|
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}"
|
echo -e "${BLUE}Connected to autonomous brain at $HOST:$PORT...${NC}"
|
||||||
socat READLINE,history=$HOME/.org_agent_history TCP:$HOST:$PORT
|
socat READLINE,history=$HOME/.org_agent_history TCP:$HOST:$PORT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Launch
|
# --- Auto-Boot Logic ---
|
||||||
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
|
if [ -f "opencortex.asd" ] || [ -f "$(dirname "$0")/opencortex.asd" ]; then
|
||||||
done < .env
|
echo -e "${YELLOW}Brain is offline. Starting it now...${NC}"
|
||||||
fi
|
# Use the absolute path to ourselves to ensure the right script boots
|
||||||
echo -e "${BLUE}Starting OpenCortex Brain...${NC}"
|
SELF="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")"
|
||||||
sbcl --non-interactive \
|
"$SELF" --boot > brain.log 2>&1 &
|
||||||
--eval "(load \"~/quicklisp/setup.lisp\")" \
|
sleep 10
|
||||||
--eval "(push \"$(pwd)/\" asdf:*central-registry*)" \
|
exec "$SELF" "$@"
|
||||||
--eval "(ql:quickload :opencortex)" \
|
|
||||||
--eval "(opencortex:main)"
|
|
||||||
fi
|
fi
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@@ -72,27 +100,33 @@ prompt_user() {
|
|||||||
local var_name="$3"
|
local var_name="$3"
|
||||||
local result=""
|
local result=""
|
||||||
echo -n -e "${YELLOW}$prompt (default: $default): ${NC}" >&2
|
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
|
if read -t 5 result; then :; else result="$default"; echo -e "${BLUE} [Auto-Selected: $default]${NC}" >&2; fi
|
||||||
val=${result:-$default}
|
val=${result:-$default}
|
||||||
eval "$var_name=\"$val\""
|
eval "$var_name=\"$val\""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 1. Dependencies
|
||||||
if ! command -v sbcl >/dev/null 2>&1; then
|
if ! command -v sbcl >/dev/null 2>&1; then
|
||||||
|
echo -e "${BLUE}Installing dependencies...${NC}"
|
||||||
sudo apt-get update && sudo apt-get install -y sbcl emacs git curl socat || true
|
sudo apt-get update && sudo apt-get install -y sbcl emacs git curl socat || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 2. Quicklisp
|
||||||
if [ ! -d "$HOME/quicklisp" ]; then
|
if [ ! -d "$HOME/quicklisp" ]; then
|
||||||
curl -O https://beta.quicklisp.org/quicklisp.lisp
|
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))"
|
sbcl --non-interactive --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --eval "(ql-util:without-prompting (ql:add-to-init-file))"
|
||||||
rm quicklisp.lisp
|
rm quicklisp.lisp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 3. Tangling
|
||||||
echo -e "${BLUE}Tangling source files...${NC}"
|
echo -e "${BLUE}Tangling source files...${NC}"
|
||||||
mkdir -p src
|
mkdir -p src
|
||||||
for f in literate/*.org; do
|
for f in literate/*.org; do
|
||||||
|
echo " - Tangling $f"
|
||||||
emacs --batch --eval "(require 'org)" --eval "(org-babel-tangle-file \"$f\")" >/dev/null 2>&1
|
emacs --batch --eval "(require 'org)" --eval "(org-babel-tangle-file \"$f\")" >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# 4. Config
|
||||||
if [ ! -f .env ]; then cp .env.example .env; fi
|
if [ ! -f .env ]; then cp .env.example .env; fi
|
||||||
prompt_user "What is your name?" "User" "USER_NAME"
|
prompt_user "What is your name?" "User" "USER_NAME"
|
||||||
prompt_user "What shall we name your Assistant?" "OpenCortex" "AGENT_NAME"
|
prompt_user "What shall we name your Assistant?" "OpenCortex" "AGENT_NAME"
|
||||||
@@ -101,16 +135,17 @@ 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_USER=.*/MEMEX_USER=\"$USER_NAME\"/g" .env
|
||||||
sed -i "s/MEMEX_ASSISTANT=.*/MEMEX_ASSISTANT=\"$AGENT_NAME\"/g" .env
|
sed -i "s/MEMEX_ASSISTANT=.*/MEMEX_ASSISTANT=\"$AGENT_NAME\"/g" .env
|
||||||
|
|
||||||
ROOT_DIR=$(pwd)
|
# 5. Path Alignment
|
||||||
sed -i "s|MEMEX_DIR=.*|MEMEX_DIR=\"$(dirname $ROOT_DIR)\"|g" .env
|
INSTALL_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
sed -i "s|SKILLS_DIR=.*|SKILLS_DIR=\"$ROOT_DIR/skills\"|g" .env
|
sed -i "s|MEMEX_DIR=.*|MEMEX_DIR=\"$(dirname "$INSTALL_DIR")\"|g" .env
|
||||||
|
sed -i "s|SKILLS_DIR=.*|SKILLS_DIR=\"$INSTALL_DIR/skills\"|g" .env
|
||||||
|
|
||||||
mkdir -p "$HOME/.local/bin"
|
mkdir -p "$HOME/.local/bin"
|
||||||
ln -sf "$ROOT_DIR/opencortex.sh" "$HOME/.local/bin/opencortex"
|
ln -sf "$INSTALL_DIR/opencortex.sh" "$HOME/.local/bin/opencortex"
|
||||||
echo -e "${GREEN}✓ Installed 'opencortex' command to ~/.local/bin${NC}"
|
echo -e "${GREEN}✓ Installed 'opencortex' command to ~/.local/bin${NC}"
|
||||||
|
|
||||||
echo -e "\n${GREEN}==============================================${NC}"
|
echo -e "\n${GREEN}==============================================${NC}"
|
||||||
echo -e "${GREEN} OpenCortex Installation Complete! ${NC}"
|
echo -e " OpenCortex Installation Complete! "
|
||||||
echo -e "${GREEN}==============================================${NC}"
|
echo -e "==============================================${NC}"
|
||||||
echo -e "To start: opencortex"
|
echo -e "To start: opencortex"
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ command_exists() { command -v "$1" >/dev/null 2>&1; }
|
|||||||
bootstrap_opencortex() {
|
bootstrap_opencortex() {
|
||||||
echo -e "${BLUE}=== OpenCortex: Zero-to-One Bootstrapper ===${NC}"
|
echo -e "${BLUE}=== OpenCortex: Zero-to-One Bootstrapper ===${NC}"
|
||||||
if [ -d ".git" ]; then return; fi
|
if [ -d ".git" ]; then return; fi
|
||||||
|
|
||||||
TARGET_DIR="opencortex"
|
TARGET_DIR="opencortex"
|
||||||
if [ ! -d "$TARGET_DIR" ]; then
|
if [ ! -d "$TARGET_DIR" ]; then
|
||||||
echo -e "${BLUE}Cloning repository into $TARGET_DIR...${NC}"
|
echo -e "${BLUE}Cloning repository into $TARGET_DIR...${NC}"
|
||||||
@@ -29,23 +30,50 @@ bootstrap_opencortex() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -d ".git" ]; then bootstrap_opencortex; fi
|
if [ ! -d ".git" ] && [[ ! "$(pwd)" =~ "opencortex" ]]; then
|
||||||
|
bootstrap_opencortex
|
||||||
|
fi
|
||||||
|
|
||||||
# 1. Try to drop straight into the CLI chat
|
# --- Helper: Load Env ---
|
||||||
|
load_env() {
|
||||||
|
if [ -f .env ]; then
|
||||||
|
while IFS='=' read -r key value || [ -n "$key" ]; do
|
||||||
|
# Remove whitespace and quotes
|
||||||
|
key=$(echo "$key" | xargs)
|
||||||
|
value=$(echo "$value" | xargs | sed 's/^"//;s/"$//')
|
||||||
|
if [[ "$key" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then
|
||||||
|
export "$key=$value"
|
||||||
|
fi
|
||||||
|
done < .env
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Force Boot ---
|
||||||
|
if [[ "$1" == "--boot" ]]; then
|
||||||
|
load_env
|
||||||
|
echo -e "${BLUE}Starting OpenCortex Brain...${NC}"
|
||||||
|
# Use absolute path to the directory containing this script for ASDF
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
exec sbcl --non-interactive \
|
||||||
|
--eval "(load \"~/quicklisp/setup.lisp\")" \
|
||||||
|
--eval "(push \"$SCRIPT_DIR/\" asdf:*central-registry*)" \
|
||||||
|
--eval "(ql:quickload :opencortex)" \
|
||||||
|
--eval "(opencortex:main)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Client Mode ---
|
||||||
if command_exists socat && socat - TCP:$HOST:$PORT,connect-timeout=1 2>/dev/null; then
|
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}"
|
echo -e "${BLUE}Connected to autonomous brain at $HOST:$PORT...${NC}"
|
||||||
socat READLINE,history=$HOME/.org_agent_history TCP:$HOST:$PORT
|
socat READLINE,history=$HOME/.org_agent_history TCP:$HOST:$PORT
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Launch
|
# --- Auto-Boot Logic ---
|
||||||
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
|
if [ -f "opencortex.asd" ] || [ -f "$(dirname "$0")/opencortex.asd" ]; then
|
||||||
done < .env
|
echo -e "${YELLOW}Brain is offline. Starting it now...${NC}"
|
||||||
fi
|
# Use the absolute path to ourselves to ensure the right script boots
|
||||||
echo -e "${BLUE}Starting OpenCortex Brain...${NC}"
|
SELF="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")"
|
||||||
sbcl --non-interactive \
|
"$SELF" --boot > brain.log 2>&1 &
|
||||||
--eval "(load \"~/quicklisp/setup.lisp\")" \
|
sleep 10
|
||||||
--eval "(push \"$(pwd)/\" asdf:*central-registry*)" \
|
exec "$SELF" "$@"
|
||||||
--eval "(ql:quickload :opencortex)" \
|
|
||||||
--eval "(opencortex:main)"
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -9,27 +9,33 @@ prompt_user() {
|
|||||||
local var_name="$3"
|
local var_name="$3"
|
||||||
local result=""
|
local result=""
|
||||||
echo -n -e "${YELLOW}$prompt (default: $default): ${NC}" >&2
|
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
|
if read -t 5 result; then :; else result="$default"; echo -e "${BLUE} [Auto-Selected: $default]${NC}" >&2; fi
|
||||||
val=${result:-$default}
|
val=${result:-$default}
|
||||||
eval "$var_name=\"$val\""
|
eval "$var_name=\"$val\""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 1. Dependencies
|
||||||
if ! command -v sbcl >/dev/null 2>&1; then
|
if ! command -v sbcl >/dev/null 2>&1; then
|
||||||
|
echo -e "${BLUE}Installing dependencies...${NC}"
|
||||||
sudo apt-get update && sudo apt-get install -y sbcl emacs git curl socat || true
|
sudo apt-get update && sudo apt-get install -y sbcl emacs git curl socat || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 2. Quicklisp
|
||||||
if [ ! -d "$HOME/quicklisp" ]; then
|
if [ ! -d "$HOME/quicklisp" ]; then
|
||||||
curl -O https://beta.quicklisp.org/quicklisp.lisp
|
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))"
|
sbcl --non-interactive --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --eval "(ql-util:without-prompting (ql:add-to-init-file))"
|
||||||
rm quicklisp.lisp
|
rm quicklisp.lisp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 3. Tangling
|
||||||
echo -e "${BLUE}Tangling source files...${NC}"
|
echo -e "${BLUE}Tangling source files...${NC}"
|
||||||
mkdir -p src
|
mkdir -p src
|
||||||
for f in literate/*.org; do
|
for f in literate/*.org; do
|
||||||
|
echo " - Tangling $f"
|
||||||
emacs --batch --eval "(require 'org)" --eval "(org-babel-tangle-file \"$f\")" >/dev/null 2>&1
|
emacs --batch --eval "(require 'org)" --eval "(org-babel-tangle-file \"$f\")" >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# 4. Config
|
||||||
if [ ! -f .env ]; then cp .env.example .env; fi
|
if [ ! -f .env ]; then cp .env.example .env; fi
|
||||||
prompt_user "What is your name?" "User" "USER_NAME"
|
prompt_user "What is your name?" "User" "USER_NAME"
|
||||||
prompt_user "What shall we name your Assistant?" "OpenCortex" "AGENT_NAME"
|
prompt_user "What shall we name your Assistant?" "OpenCortex" "AGENT_NAME"
|
||||||
@@ -38,15 +44,16 @@ 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_USER=.*/MEMEX_USER=\"$USER_NAME\"/g" .env
|
||||||
sed -i "s/MEMEX_ASSISTANT=.*/MEMEX_ASSISTANT=\"$AGENT_NAME\"/g" .env
|
sed -i "s/MEMEX_ASSISTANT=.*/MEMEX_ASSISTANT=\"$AGENT_NAME\"/g" .env
|
||||||
|
|
||||||
ROOT_DIR=$(pwd)
|
# 5. Path Alignment
|
||||||
sed -i "s|MEMEX_DIR=.*|MEMEX_DIR=\"$(dirname $ROOT_DIR)\"|g" .env
|
INSTALL_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
sed -i "s|SKILLS_DIR=.*|SKILLS_DIR=\"$ROOT_DIR/skills\"|g" .env
|
sed -i "s|MEMEX_DIR=.*|MEMEX_DIR=\"$(dirname "$INSTALL_DIR")\"|g" .env
|
||||||
|
sed -i "s|SKILLS_DIR=.*|SKILLS_DIR=\"$INSTALL_DIR/skills\"|g" .env
|
||||||
|
|
||||||
mkdir -p "$HOME/.local/bin"
|
mkdir -p "$HOME/.local/bin"
|
||||||
ln -sf "$ROOT_DIR/opencortex.sh" "$HOME/.local/bin/opencortex"
|
ln -sf "$INSTALL_DIR/opencortex.sh" "$HOME/.local/bin/opencortex"
|
||||||
echo -e "${GREEN}✓ Installed 'opencortex' command to ~/.local/bin${NC}"
|
echo -e "${GREEN}✓ Installed 'opencortex' command to ~/.local/bin${NC}"
|
||||||
|
|
||||||
echo -e "\n${GREEN}==============================================${NC}"
|
echo -e "\n${GREEN}==============================================${NC}"
|
||||||
echo -e "${GREEN} OpenCortex Installation Complete! ${NC}"
|
echo -e " OpenCortex Installation Complete! "
|
||||||
echo -e "${GREEN}==============================================${NC}"
|
echo -e "==============================================${NC}"
|
||||||
echo -e "To start: opencortex"
|
echo -e "To start: opencortex"
|
||||||
|
|||||||
Reference in New Issue
Block a user