Backup before continuing from Codex 5.2 session - User storage, compaction suggestions, streaming improvements
This commit is contained in:
209
Launch-Unix.sh
209
Launch-Unix.sh
@@ -1,133 +1,170 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo ""
|
||||
echo " ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗"
|
||||
echo " ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║"
|
||||
echo " ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║"
|
||||
echo " ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║"
|
||||
echo " ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║"
|
||||
echo " ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝"
|
||||
echo ""
|
||||
echo " LAUNCHER - Linux/macOS"
|
||||
echo " ═════════════════════════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
# NomadArch Launcher for macOS and Linux
|
||||
# Version: 0.4.0
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
ERRORS=0
|
||||
WARNINGS=0
|
||||
AUTO_FIXED=0
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "[STEP 1/5] Checking Dependencies..."
|
||||
echo ""
|
||||
echo "NomadArch Launcher (macOS/Linux)"
|
||||
echo "Version: 0.4.0"
|
||||
echo ""
|
||||
|
||||
echo "[PREFLIGHT 1/7] Checking Dependencies..."
|
||||
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo "[ERROR] Node.js not found!"
|
||||
echo ""
|
||||
echo "Please install Node.js first: https://nodejs.org/"
|
||||
echo "Then run: ./Install-Linux.sh (or ./Install-Mac.sh on macOS)"
|
||||
echo ""
|
||||
echo -e "${YELLOW}[WARN]${NC} Node.js not found. Running installer..."
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
bash "$SCRIPT_DIR/Install-Mac.sh"
|
||||
else
|
||||
bash "$SCRIPT_DIR/Install-Linux.sh"
|
||||
fi
|
||||
echo -e "${BLUE}[INFO]${NC} If Node.js was installed, open a new terminal and run Launch-Unix.sh again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NODE_VERSION=$(node --version)
|
||||
echo "[OK] Node.js: $NODE_VERSION"
|
||||
echo -e "${GREEN}[OK]${NC} Node.js: $NODE_VERSION"
|
||||
|
||||
if ! command -v npm &> /dev/null; then
|
||||
echo "[ERROR] npm not found!"
|
||||
echo ""
|
||||
echo -e "${RED}[ERROR]${NC} npm not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NPM_VERSION=$(npm --version)
|
||||
echo "[OK] npm: $NPM_VERSION"
|
||||
echo -e "${GREEN}[OK]${NC} npm: $NPM_VERSION"
|
||||
|
||||
echo ""
|
||||
echo "[STEP 2/5] Checking for OpenCode CLI..."
|
||||
echo ""
|
||||
echo "[PREFLIGHT 2/7] Checking for OpenCode CLI..."
|
||||
|
||||
if command -v opencode &> /dev/null; then
|
||||
echo "[OK] OpenCode is available in PATH"
|
||||
elif [ -f "bin/opencode" ]; then
|
||||
echo "[OK] OpenCode binary found in bin/ folder"
|
||||
echo -e "${GREEN}[OK]${NC} OpenCode CLI available in PATH"
|
||||
elif [[ -f "$SCRIPT_DIR/bin/opencode" ]]; then
|
||||
echo -e "${GREEN}[OK]${NC} OpenCode binary found in bin/"
|
||||
else
|
||||
echo "[WARN] OpenCode CLI not found"
|
||||
echo "[INFO] Run ./Install-Linux.sh (or ./Install-Mac.sh on macOS) to install OpenCode"
|
||||
WARNINGS=$((WARNINGS + 1))
|
||||
echo -e "${YELLOW}[WARN]${NC} OpenCode CLI not found"
|
||||
echo "[INFO] Run Install-*.sh to set up OpenCode"
|
||||
((WARNINGS++))
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[STEP 3/5] Checking for Existing Build..."
|
||||
echo ""
|
||||
echo "[PREFLIGHT 3/7] Checking Dependencies..."
|
||||
|
||||
if [ -d "packages/ui/dist" ]; then
|
||||
echo "[OK] UI build found"
|
||||
else
|
||||
echo "[WARN] No UI build found. Building now..."
|
||||
echo ""
|
||||
cd packages/ui
|
||||
npm run build
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[ERROR] UI build failed!"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
else
|
||||
echo "[OK] UI build completed"
|
||||
if [[ ! -d "node_modules" ]]; then
|
||||
echo -e "${YELLOW}[INFO]${NC} Dependencies not installed. Installing now..."
|
||||
if ! npm install; then
|
||||
echo -e "${RED}[ERROR]${NC} Dependency installation failed!"
|
||||
exit 1
|
||||
fi
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[STEP 4/5] Checking Port Availability..."
|
||||
echo ""
|
||||
|
||||
SERVER_PORT=3001
|
||||
UI_PORT=3000
|
||||
|
||||
if lsof -Pi :$SERVER_PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
|
||||
echo "[WARN] Port $SERVER_PORT is already in use"
|
||||
echo "[INFO] Another NomadArch instance or app may be running"
|
||||
echo "[INFO] To find the process: lsof -i :$SERVER_PORT"
|
||||
echo "[INFO] To kill it: kill -9 \$(lsof -t -i:$SERVER_PORT)"
|
||||
WARNINGS=$((WARNINGS + 1))
|
||||
echo -e "${GREEN}[OK]${NC} Dependencies installed (auto-fix)"
|
||||
((AUTO_FIXED++))
|
||||
else
|
||||
echo "[OK] Port $SERVER_PORT is available"
|
||||
echo -e "${GREEN}[OK]${NC} Dependencies found"
|
||||
fi
|
||||
|
||||
if lsof -Pi :$UI_PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
|
||||
echo "[WARN] Port $UI_PORT is already in use"
|
||||
echo "[INFO] To find the process: lsof -i :$UI_PORT"
|
||||
echo "[INFO] To kill it: kill -9 \$(lsof -t -i:$UI_PORT)"
|
||||
WARNINGS=$((WARNINGS + 1))
|
||||
echo ""
|
||||
echo "[PREFLIGHT 4/7] Finding Available Port..."
|
||||
|
||||
DEFAULT_SERVER_PORT=3001
|
||||
DEFAULT_UI_PORT=3000
|
||||
SERVER_PORT=$DEFAULT_SERVER_PORT
|
||||
UI_PORT=$DEFAULT_UI_PORT
|
||||
|
||||
for port in {3001..3050}; do
|
||||
if ! lsof -i :$port -sTCP:LISTEN -t > /dev/null 2>&1; then
|
||||
SERVER_PORT=$port
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} Server port: $SERVER_PORT"
|
||||
|
||||
echo ""
|
||||
echo "[PREFLIGHT 5/7] Final Checks..."
|
||||
|
||||
if [[ ! -d "packages/ui/dist" ]]; then
|
||||
echo -e "${YELLOW}[WARN]${NC} UI build directory not found"
|
||||
echo -e "${YELLOW}[INFO]${NC} Running UI build..."
|
||||
pushd packages/ui >/dev/null
|
||||
if ! npm run build; then
|
||||
echo -e "${RED}[ERROR]${NC} UI build failed!"
|
||||
popd >/dev/null
|
||||
((ERRORS++))
|
||||
else
|
||||
popd >/dev/null
|
||||
echo -e "${GREEN}[OK]${NC} UI build completed (auto-fix)"
|
||||
((AUTO_FIXED++))
|
||||
fi
|
||||
else
|
||||
echo "[OK] Port $UI_PORT is available"
|
||||
echo -e "${GREEN}[OK]${NC} UI build directory exists"
|
||||
fi
|
||||
|
||||
if [[ ! -f "packages/electron-app/dist/main/main.js" ]]; then
|
||||
echo -e "${YELLOW}[WARN]${NC} Electron build incomplete"
|
||||
echo -e "${YELLOW}[INFO]${NC} Running full build..."
|
||||
if ! npm run build; then
|
||||
echo -e "${RED}[ERROR]${NC} Full build failed!"
|
||||
((ERRORS++))
|
||||
else
|
||||
echo -e "${GREEN}[OK]${NC} Full build completed (auto-fix)"
|
||||
((AUTO_FIXED++))
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}[OK]${NC} Electron build exists"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[STEP 5/5] Starting NomadArch..."
|
||||
echo "[PREFLIGHT 6/7] Launch Summary"
|
||||
|
||||
echo -e "${BLUE}[STATUS]${NC}"
|
||||
echo ""
|
||||
echo " Node.js: $NODE_VERSION"
|
||||
echo " npm: $NPM_VERSION"
|
||||
echo " Auto-fixes applied: $AUTO_FIXED"
|
||||
echo " Warnings: $WARNINGS"
|
||||
echo " Errors: $ERRORS"
|
||||
echo " Server Port: $SERVER_PORT"
|
||||
echo ""
|
||||
|
||||
if [ $ERRORS -gt 0 ]; then
|
||||
echo "[ERROR] Cannot start due to errors!"
|
||||
echo ""
|
||||
if [[ $ERRORS -gt 0 ]]; then
|
||||
echo -e "${RED}[RESULT]${NC} Cannot start due to errors!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Starting NomadArch..."
|
||||
echo "[INFO] Server will run on http://localhost:$SERVER_PORT"
|
||||
echo "[INFO] Press Ctrl+C to stop"
|
||||
echo -e "${GREEN}[INFO]${NC} Starting NomadArch..."
|
||||
echo -e "${GREEN}[INFO]${NC} Server will run on http://localhost:$SERVER_PORT"
|
||||
echo -e "${YELLOW}[INFO]${NC} Press Ctrl+C to stop"
|
||||
echo ""
|
||||
|
||||
SERVER_URL="http://localhost:$SERVER_PORT"
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
open "$SERVER_URL" 2>/dev/null || true
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
xdg-open "$SERVER_URL" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
export CLI_PORT=$SERVER_PORT
|
||||
npm run dev:electron
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "[ERROR] NomadArch exited with an error!"
|
||||
echo ""
|
||||
echo "Common solutions:"
|
||||
echo " 1. Check that all dependencies are installed: npm install"
|
||||
echo " 2. Check that the UI is built: cd packages/ui && npm run build"
|
||||
echo " 3. Check for port conflicts (see warnings above)"
|
||||
echo " 4. Check the error message above for details"
|
||||
echo ""
|
||||
echo "To reinstall everything: ./Install-Linux.sh (or ./Install-Mac.sh on macOS)"
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
echo ""
|
||||
echo -e "${RED}[ERROR]${NC} NomadArch exited with an error!"
|
||||
fi
|
||||
|
||||
exit $EXIT_CODE
|
||||
|
||||
Reference in New Issue
Block a user