mid coding commit

This commit is contained in:
zazawowow
2026-01-24 22:59:20 +00:00
parent 64cc3bc7fb
commit 731cd67cfb
2228 changed files with 135554 additions and 18 deletions

89
scripts/dev-container.sh Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/bash
# Development Container Environment Setup
# Checks container runtime availability and provides helper commands
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "🐳 Archipelago Development Container Environment"
echo ""
# Check for Podman
PODMAN_AVAILABLE=false
if command -v podman >/dev/null 2>&1; then
PODMAN_VERSION=$(podman --version)
echo "✅ Podman found: $PODMAN_VERSION"
if podman info >/dev/null 2>&1; then
PODMAN_AVAILABLE=true
echo " Podman daemon is running"
else
echo " ⚠️ Podman daemon not running"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo " Start with: podman machine start"
fi
fi
else
echo "❌ Podman not found"
fi
# Check for Docker
DOCKER_AVAILABLE=false
if command -v docker >/dev/null 2>&1; then
DOCKER_VERSION=$(docker --version)
echo "✅ Docker found: $DOCKER_VERSION"
if docker info >/dev/null 2>&1; then
DOCKER_AVAILABLE=true
echo " Docker daemon is running"
else
echo " ⚠️ Docker daemon not running"
echo " Start Docker Desktop or: sudo systemctl start docker"
fi
else
echo "❌ Docker not found"
fi
echo ""
# Determine runtime
RUNTIME="auto"
if [ "$PODMAN_AVAILABLE" = true ]; then
RUNTIME="podman"
echo "🎯 Using Podman (preferred)"
elif [ "$DOCKER_AVAILABLE" = true ]; then
RUNTIME="docker"
echo "🎯 Using Docker (fallback)"
else
echo "❌ No container runtime available!"
echo " Install Podman: https://podman.io/getting-started/installation"
echo " Or install Docker: https://docs.docker.com/get-docker/"
exit 1
fi
echo ""
echo "📋 Helper Commands:"
echo ""
echo "List containers:"
echo " $RUNTIME ps -a"
echo ""
echo "View container logs:"
echo " $RUNTIME logs <container-name>"
echo ""
echo "Stop all archipelago containers:"
echo " $RUNTIME ps -a --filter 'name=archipelago-' --format '{{.Names}}' | xargs -r $RUNTIME stop"
echo ""
echo "Remove all archipelago containers:"
echo " $RUNTIME ps -a --filter 'name=archipelago-' --format '{{.Names}}' | xargs -r $RUNTIME rm -f"
echo ""
echo "Clean up dev data:"
echo " rm -rf /tmp/archipelago-dev"
echo ""
echo "Start backend with containers:"
echo " cd $PROJECT_ROOT/core"
echo " ARCHIPELAGO_DEV_MODE=true \\"
echo " ARCHIPELAGO_CONTAINER_RUNTIME=$RUNTIME \\"
echo " ARCHIPELAGO_PORT_OFFSET=10000 \\"
echo " ARCHIPELAGO_BITCOIN_SIMULATION=mock \\"
echo " cargo run --bin archipelago"
echo ""

94
scripts/dev-setup.sh Executable file
View File

@@ -0,0 +1,94 @@
#!/bin/bash
# Development environment setup script
# Installs dependencies and sets up development environment
set -e
echo "🚀 Setting up Archipelago development environment..."
# Check prerequisites
echo "📋 Checking prerequisites..."
command -v rustc >/dev/null 2>&1 || { echo "❌ Rust is required. Install from https://rustup.rs/"; exit 1; }
command -v node >/dev/null 2>&1 || { echo "❌ Node.js is required. Install from https://nodejs.org/"; exit 1; }
command -v cargo >/dev/null 2>&1 || { echo "❌ Cargo is required. Install Rust toolchain."; exit 1; }
echo "✅ Prerequisites check passed"
# Get project root (assumes script is in scripts/)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "📁 Project root: $PROJECT_ROOT"
# Check if we're in the right directory structure
if [ ! -d "$PROJECT_ROOT/core" ] && [ ! -d "$PROJECT_ROOT/neode-ui" ]; then
echo "⚠️ Warning: This script expects to be run from the Archipelago workspace."
echo " If you're working with Code/Archipelago, you may need to adjust paths."
read -p "Continue anyway? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Setup frontend
if [ -d "$PROJECT_ROOT/neode-ui" ]; then
echo "📦 Setting up frontend..."
cd "$PROJECT_ROOT/neode-ui"
if [ ! -d "node_modules" ]; then
npm install
else
echo " node_modules already exists, skipping install"
fi
else
echo "⚠️ neode-ui directory not found, skipping frontend setup"
fi
# Setup backend
if [ -d "$PROJECT_ROOT/core" ]; then
echo "🔧 Setting up backend..."
cd "$PROJECT_ROOT/core"
# Check if Cargo.toml exists
if [ -f "Cargo.toml" ]; then
echo " Fetching Rust dependencies..."
cargo fetch
else
echo "⚠️ Cargo.toml not found in core/, skipping backend setup"
fi
else
echo "⚠️ core directory not found, skipping backend setup"
fi
# Check for Podman (optional)
if command -v podman >/dev/null 2>&1; then
echo "✅ Podman found: $(podman --version)"
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! podman machine list | grep -q "running"; then
echo "⚠️ Podman machine not running. Start with: podman machine start"
fi
fi
else
echo "⚠️ Podman not found (optional, needed for container features)"
echo " Install: https://podman.io/getting-started/installation"
fi
# Check for PostgreSQL (optional)
if command -v psql >/dev/null 2>&1; then
echo "✅ PostgreSQL found: $(psql --version)"
else
echo "⚠️ PostgreSQL not found (optional, needed for backend database)"
echo " Install: https://www.postgresql.org/download/"
echo " Or use Docker: docker run -d --name postgres -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres:15"
fi
echo ""
echo "✅ Development environment setup complete!"
echo ""
echo "Next steps:"
echo " 1. Start backend: cd core && cargo run --bin startbox"
echo " 2. Start frontend: cd neode-ui && npm run dev"
echo ""
echo "Or use the mock backend for UI-only development:"
echo " cd neode-ui && npm run dev:mock"

210
scripts/dev-start.sh Executable file
View File

@@ -0,0 +1,210 @@
#!/bin/bash
# Archipelago Development Server Starter
# Pure Archipelago implementation - NO StartOS
set +e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "🚀 Archipelago Development Server Starter"
echo ""
# Use the workspace directory
FRONTEND_DIR="$PROJECT_ROOT/neode-ui"
BACKEND_DIR="$PROJECT_ROOT/core"
# Verify the frontend directory exists
if [ ! -d "$FRONTEND_DIR" ]; then
echo "❌ Frontend directory not found: $FRONTEND_DIR"
exit 1
fi
echo "Choose a development mode:"
echo " 1) Mock backend (UI development only - fastest)"
echo " 2) Full stack (Archipelago backend + frontend)"
echo " 3) Setup mode (first-time user setup flow - mock)"
echo " 4) Onboarding mode (onboarding flow - mock)"
echo " 5) Existing user (login with password - mock)"
echo " 6) Show manual instructions"
echo ""
read -p "Enter choice [1-6]: " choice
case $choice in
1)
echo ""
echo "🎨 Starting frontend with mock backend..."
cd "$FRONTEND_DIR"
# Kill any existing processes
echo " 🧹 Cleaning up ports 5959 and 8100..."
lsof -ti:5959 | xargs kill -9 2>/dev/null || true
lsof -ti:8100 | xargs kill -9 2>/dev/null || true
sleep 1
# Check dependencies
if [ ! -d "node_modules" ]; then
echo "⚠️ Installing dependencies..."
npm install
fi
echo " Running: npm run dev:mock"
echo " (Press Ctrl+C to stop)"
echo ""
npm run dev:mock
;;
2)
echo ""
echo "🔧 Starting FULL STACK (Archipelago backend + frontend)..."
# Kill ports
echo " 🧹 Cleaning up ports 5959 and 8100..."
lsof -ti:5959 | xargs kill -9 2>/dev/null || true
lsof -ti:8100 | xargs kill -9 2>/dev/null || true
sleep 1
# Check if backend can build
echo " 🔨 Checking backend build..."
if [ ! -d "$BACKEND_DIR" ]; then
echo "❌ Backend directory not found: $BACKEND_DIR"
exit 1
fi
cd "$BACKEND_DIR"
if ! cargo check --bin archipelago > /tmp/archipelago-backend-check.log 2>&1; then
echo "❌ Backend build check failed. See /tmp/archipelago-backend-check.log for details."
echo " Falling back to mock backend for UI development."
cd "$FRONTEND_DIR"
if [ ! -d "node_modules" ]; then
npm install
fi
npm run dev:mock
exit 0
fi
echo " 🚀 Starting Archipelago backend..."
cargo run --bin archipelago > /tmp/archipelago-backend.log 2>&1 &
BACKEND_PID=$!
echo " Backend PID: $BACKEND_PID"
echo " Logs: tail -f /tmp/archipelago-backend.log"
# Wait for backend to start listening on port 5959
echo " ⏳ Waiting for backend to start on port 5959..."
timeout=60
count=0
while ! lsof -ti:5959 > /dev/null 2>&1 && [ $count -lt $timeout ]; do
sleep 1
count=$((count + 1))
done
if ! lsof -ti:5959 > /dev/null 2>&1; then
echo "❌ Backend did not start on port 5959 within $timeout seconds."
echo " Killing backend process $BACKEND_PID."
kill $BACKEND_PID 2>/dev/null || true
echo " Falling back to mock backend for UI development."
cd "$FRONTEND_DIR"
if [ ! -d "node_modules" ]; then
npm install
fi
npm run dev:mock
exit 0
fi
echo " ✅ Backend is listening on port 5959"
# Start frontend
echo " 🎨 Starting frontend..."
cd "$FRONTEND_DIR"
if [ ! -d "node_modules" ]; then
echo " Installing frontend dependencies..."
npm install
fi
# Trap to kill backend on exit
trap "kill $BACKEND_PID 2>/dev/null" EXIT
echo " (Press Ctrl+C to stop both servers)"
echo ""
npm run dev
;;
3)
echo ""
echo "🔧 Starting in SETUP mode (mock backend)..."
cd "$FRONTEND_DIR"
# Kill ports
lsof -ti:5959 | xargs kill -9 2>/dev/null || true
lsof -ti:8100 | xargs kill -9 2>/dev/null || true
sleep 1
if [ ! -d "node_modules" ]; then
npm install
fi
echo " Starting setup flow..."
VITE_DEV_MODE=setup npm run dev:mock
;;
4)
echo ""
echo "📚 Starting in ONBOARDING mode (mock backend)..."
cd "$FRONTEND_DIR"
# Kill ports
lsof -ti:5959 | xargs kill -9 2>/dev/null || true
lsof -ti:8100 | xargs kill -9 2>/dev/null || true
sleep 1
if [ ! -d "node_modules" ]; then
npm install
fi
echo " Starting onboarding flow..."
VITE_DEV_MODE=onboarding npm run dev:mock
;;
5)
echo ""
echo "👤 Starting as EXISTING USER (mock backend)..."
cd "$FRONTEND_DIR"
# Kill ports
lsof -ti:5959 | xargs kill -9 2>/dev/null || true
lsof -ti:8100 | xargs kill -9 2>/dev/null || true
sleep 1
if [ ! -d "node_modules" ]; then
npm install
fi
echo " Starting with login screen..."
VITE_DEV_MODE=existing npm run dev:mock
;;
6)
echo ""
echo "📋 Manual Instructions:"
echo ""
echo "For UI development (mock backend):"
echo " cd $FRONTEND_DIR"
echo " npm run dev:mock"
echo ""
echo "For full stack (Archipelago backend + frontend):"
echo " Terminal 1 (Backend):"
echo " cd $BACKEND_DIR"
echo " cargo run --bin archipelago"
echo ""
echo " Terminal 2 (Frontend):"
echo " cd $FRONTEND_DIR"
echo " npm run dev"
echo ""
echo "Then open: http://localhost:8100"
echo ""
echo "Mock backend dev modes:"
echo " VITE_DEV_MODE=setup - First-time setup flow"
echo " VITE_DEV_MODE=onboarding - Onboarding flow"
echo " VITE_DEV_MODE=existing - Login screen"
;;
*)
echo "Invalid choice"
exit 1
;;
esac

38
scripts/dev.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Quick dev script - just starts the mock backend for UI development
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
FRONTEND_DIR="$PROJECT_ROOT/neode-ui"
if [ ! -d "$FRONTEND_DIR" ]; then
echo "❌ Frontend directory not found: $FRONTEND_DIR"
exit 1
fi
echo "📁 Using: $FRONTEND_DIR"
cd "$FRONTEND_DIR"
# Kill any existing processes on ports 5959 and 8100
echo "🧹 Cleaning up ports 5959 and 8100..."
lsof -ti:5959 | xargs kill -9 2>/dev/null || true
lsof -ti:8100 | xargs kill -9 2>/dev/null || true
sleep 1
# Check if node_modules exists
if [ ! -d "node_modules" ]; then
echo "⚠️ Installing dependencies..."
npm install
fi
# Check if mock-backend.js exists
if [ ! -f "mock-backend.js" ]; then
echo "❌ mock-backend.js not found in $FRONTEND_DIR"
echo " Make sure you're using the correct project directory"
exit 1
fi
echo "🚀 Starting frontend with mock backend..."
echo " (Press Ctrl+C to stop)"
echo ""
npm run dev:mock

68
scripts/prepackage-test.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
# Test prepackaged containers (k484, atob)
# Builds containers and tests installation flow
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "📦 Testing Prepackaged Containers"
echo ""
# Determine container runtime
RUNTIME="auto"
if command -v podman >/dev/null 2>&1 && podman info >/dev/null 2>&1; then
RUNTIME="podman"
elif command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
RUNTIME="docker"
else
echo "❌ No container runtime available!"
exit 1
fi
echo "🐳 Using runtime: $RUNTIME"
echo ""
# Function to build and test a container
test_container() {
local APP_ID="$1"
local PACKAGE_DIR="$2"
if [ ! -d "$PACKAGE_DIR" ]; then
echo "⚠️ Skipping $APP_ID: package directory not found: $PACKAGE_DIR"
return
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Testing: $APP_ID"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
"$SCRIPT_DIR/test-container.sh" "$APP_ID" "$PACKAGE_DIR"
echo ""
sleep 2
}
# Test k484
if [ -d "$PROJECT_ROOT/../k484-package" ] || [ -d "$HOME/k484-package" ]; then
K484_DIR="$PROJECT_ROOT/../k484-package"
if [ ! -d "$K484_DIR" ]; then
K484_DIR="$HOME/k484-package"
fi
test_container "k484" "$K484_DIR"
fi
# Test atob
if [ -d "$PROJECT_ROOT/../atob-package" ] || [ -d "$HOME/atob-package" ]; then
ATOB_DIR="$PROJECT_ROOT/../atob-package"
if [ ! -d "$ATOB_DIR" ]; then
ATOB_DIR="$HOME/atob-package"
fi
test_container "atob" "$ATOB_DIR"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ All container tests complete!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

159
scripts/test-container.sh Executable file
View File

@@ -0,0 +1,159 @@
#!/bin/bash
# Test a prepackaged container
# Usage: ./test-container.sh <app-id> <package-dir>
set -e
if [ $# -lt 2 ]; then
echo "Usage: $0 <app-id> <package-dir>"
echo ""
echo "Example:"
echo " $0 k484 ./k484-package"
exit 1
fi
APP_ID="$1"
PACKAGE_DIR="$2"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "🧪 Testing container: $APP_ID"
echo "📦 Package directory: $PACKAGE_DIR"
echo ""
# Check if package directory exists
if [ ! -d "$PACKAGE_DIR" ]; then
echo "❌ Package directory not found: $PACKAGE_DIR"
exit 1
fi
# Determine container runtime
RUNTIME="auto"
if command -v podman >/dev/null 2>&1 && podman info >/dev/null 2>&1; then
RUNTIME="podman"
elif command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
RUNTIME="docker"
else
echo "❌ No container runtime available!"
exit 1
fi
echo "🐳 Using runtime: $RUNTIME"
echo ""
# Check for Dockerfile
if [ ! -f "$PACKAGE_DIR/Dockerfile" ]; then
echo "❌ Dockerfile not found in $PACKAGE_DIR"
exit 1
fi
# Build container image
IMAGE_NAME="${APP_ID}:dev"
echo "🔨 Building container image: $IMAGE_NAME"
$RUNTIME build -t "$IMAGE_NAME" "$PACKAGE_DIR" || {
echo "❌ Failed to build container image"
exit 1
}
echo "✅ Image built successfully"
echo ""
# Create test manifest
MANIFEST_DIR="$PROJECT_ROOT/apps/$APP_ID"
mkdir -p "$MANIFEST_DIR"
MANIFEST_FILE="$MANIFEST_DIR/manifest.yml"
cat > "$MANIFEST_FILE" <<EOF
app:
id: $APP_ID
name: $(echo "$APP_ID" | tr '[:lower:]' '[:upper:]')
version: dev
description: Development test container for $APP_ID
container:
image: $IMAGE_NAME
pull_policy: never # Use local image
resources:
cpu_limit: 1
memory_limit: 512Mi
ports:
- host: 8080
container: 8080
protocol: tcp
volumes:
- type: bind
source: /tmp/archipelago-dev/$APP_ID
target: /data
options: [rw]
EOF
echo "📝 Created test manifest: $MANIFEST_FILE"
echo ""
# Check if backend is running
BACKEND_URL="${BACKEND_URL:-http://localhost:5959}"
if ! curl -s "$BACKEND_URL/health" >/dev/null 2>&1; then
echo "⚠️ Backend not running at $BACKEND_URL"
echo " Start backend first:"
echo " cd $PROJECT_ROOT/core"
echo " ARCHIPELAGO_DEV_MODE=true cargo run --bin archipelago"
echo ""
echo " Or install via RPC manually:"
echo " curl -X POST $BACKEND_URL/rpc/v1 \\"
echo " -H 'Content-Type: application/json' \\"
echo " -d '{\"method\":\"container-install\",\"params\":{\"manifest_path\":\"$MANIFEST_FILE\"}}'"
exit 0
fi
# Install via RPC
echo "📥 Installing container via RPC..."
RESPONSE=$(curl -s -X POST "$BACKEND_URL/rpc/v1" \
-H "Content-Type: application/json" \
-d "{\"method\":\"container-install\",\"params\":{\"manifest_path\":\"$MANIFEST_FILE\"}}")
if echo "$RESPONSE" | grep -q '"error"'; then
echo "❌ Installation failed:"
echo "$RESPONSE" | jq '.' 2>/dev/null || echo "$RESPONSE"
exit 1
fi
CONTAINER_NAME=$(echo "$RESPONSE" | jq -r '.result' 2>/dev/null || echo "")
echo "✅ Container installed: $CONTAINER_NAME"
echo ""
# Start container
echo "🚀 Starting container..."
curl -s -X POST "$BACKEND_URL/rpc/v1" \
-H "Content-Type: application/json" \
-d "{\"method\":\"container-start\",\"params\":{\"app_id\":\"$APP_ID\"}}" >/dev/null
sleep 2
# Check status
echo "📊 Container status:"
STATUS=$(curl -s -X POST "$BACKEND_URL/rpc/v1" \
-H "Content-Type: application/json" \
-d "{\"method\":\"container-status\",\"params\":{\"app_id\":\"$APP_ID\"}}")
echo "$STATUS" | jq '.' 2>/dev/null || echo "$STATUS"
echo ""
# Get logs
echo "📋 Container logs (last 20 lines):"
LOGS=$(curl -s -X POST "$BACKEND_URL/rpc/v1" \
-H "Content-Type: application/json" \
-d "{\"method\":\"container-logs\",\"params\":{\"app_id\":\"$APP_ID\",\"lines\":20}}")
echo "$LOGS" | jq -r '.[]' 2>/dev/null || echo "$LOGS"
echo ""
echo "✅ Test complete!"
echo ""
echo "To clean up:"
echo " curl -X POST $BACKEND_URL/rpc/v1 \\"
echo " -H 'Content-Type: application/json' \\"
echo " -d '{\"method\":\"container-remove\",\"params\":{\"app_id\":\"$APP_ID\"}}'"
echo " $RUNTIME rmi $IMAGE_NAME"