#!/bin/sh # Nomos Turnkey Substrate Installer # https://sophialabs.ca # Machine-Enforced Reality for Coding Agents set -e # ============================================================================== # Terminal Aesthetics & Formatting (POSIX Compliant) # Uses printf command substitution to guarantee escape code evaluation on all shells. # ============================================================================== RESET="$(printf '\033[0m')" BOLD="$(printf '\033[1m')" CYAN="$(printf '\033[38;2;56;189;248m')" GREEN="$(printf '\033[38;2;52;211;153m')" YELLOW="$(printf '\033[38;2;251;191;36m')" RED="$(printf '\033[38;2;239;68;68m')" echo "" echo "${CYAN}${BOLD} ▲ NOMOS — Deterministic Engineering Substrate${RESET}" echo "${CYAN} https://sophialabs.ca | Machine-Enforced Reality for Coding Agents${RESET}" echo "" # ============================================================================== # Phase 1: Operating System & Hardware Architecture Identification # Matches host environment to pre-compiled static Go binary releases. # ============================================================================== OS="$(uname -s | tr '[:upper:]' '[:lower:]')" ARCH="$(uname -m)" case "$ARCH" in x86_64|amd64) ARCH="amd64" ;; arm64|aarch64) ARCH="arm64" ;; *) echo "${RED}❌ Unsupported architecture: $ARCH${RESET}" exit 1 ;; esac case "$OS" in linux) OS="linux" ;; darwin) OS="darwin" ;; *) echo "${RED}❌ Unsupported operating system: $OS${RESET}" exit 1 ;; esac echo "${BOLD}🔍 Detected platform:${RESET} ${OS}_${ARCH}" # ============================================================================== # Phase 2: Directory Scaffolding & Path Resolution # Nomos standardizes on ~/.nomos/bin for isolated user-level binary execution. # ============================================================================== INSTALL_DIR="$HOME/.nomos/bin" mkdir -p "$INSTALL_DIR" BINARY_PATH="$INSTALL_DIR/nomos" TMP_BIN="$INSTALL_DIR/nomos.tmp.$$" # ============================================================================== # Phase 3: Existing Installation Audit # Alerts user if upgrading an existing local binary in ~/.nomos/bin. # ============================================================================== if [ -f "$BINARY_PATH" ]; then echo "${YELLOW}âš ī¸ Existing nomos binary detected at $BINARY_PATH. Upgrading...${RESET}" fi # ============================================================================== # Phase 4: CDN Asset Retrieval # Directly streams static, symbol-stripped binaries from SophiaLabs. # Falls back to local Go toolchain if CDN asset is temporarily unreachable. # ============================================================================== DOWNLOAD_URL="https://sophialabs.ca/bin/nomos_${OS}_${ARCH}" echo "âŦ‡ī¸ Downloading pre-compiled Nomos Go binary (${OS}_${ARCH})..." if curl -fL --progress-bar -o "$TMP_BIN" "$DOWNLOAD_URL" 2>/dev/null || curl -fsSL -o "$TMP_BIN" "$DOWNLOAD_URL"; then chmod +x "$TMP_BIN" mv "$TMP_BIN" "$BINARY_PATH" echo "${GREEN}✓ Downloaded Nomos binary from sophialabs.ca${RESET}" elif command -v go >/dev/null 2>&1; then echo "${YELLOW}â„šī¸ CDN asset unavailable. Compiling from Go source via toolchain...${RESET}" GOBIN="$INSTALL_DIR" go install github.com/mgantlett/nomos-os/src/nomos@latest echo "${GREEN}✓ Compiled and installed via go toolchain.${RESET}" else rm -f "$TMP_BIN" echo "${RED}❌ Installation failed. Could not fetch binary from ${DOWNLOAD_URL}.${RESET}" echo " Please check network connectivity or visit https://sophialabs.ca/docs/nomos" exit 1 fi # ============================================================================== # Phase 5: Post-Installation Smoke Test # Confirms execution permissions and kernel ABI compatibility on the local host. # ============================================================================== if ! "$BINARY_PATH" --help >/dev/null 2>&1; then echo "${RED}❌ Installed binary failed smoke test execution on this host.${RESET}" exit 1 fi # ============================================================================== # Phase 6: Shell Configuration & PATH Synchronization # Identifies the active shell runtime and safely registers ~/.nomos/bin in PATH. # ============================================================================== SHELL_NAME="$(basename "${SHELL:-sh}")" RC_FILE="" case "$SHELL_NAME" in zsh) RC_FILE="$HOME/.zshrc" ;; bash) RC_FILE="$HOME/.bashrc" ;; *) RC_FILE="$HOME/.profile" ;; esac if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then echo "" echo "âš™ī¸ Configuring PATH in $RC_FILE..." if [ -f "$RC_FILE" ]; then if ! grep -q '\.nomos/bin' "$RC_FILE"; then printf '\n# Nomos Substrate\nexport PATH="%s:$PATH"\n' "$INSTALL_DIR" >> "$RC_FILE" echo "${GREEN}✓ Added $INSTALL_DIR to $RC_FILE${RESET}" fi else printf '# Nomos Substrate\nexport PATH="%s:$PATH"\n' "$INSTALL_DIR" >> "$RC_FILE" echo "${GREEN}✓ Created $RC_FILE and configured PATH${RESET}" fi export PATH="$INSTALL_DIR:$PATH" fi # ============================================================================== # Summary & Agent Onboarding Directives # Guides human developer to launch their AI agent and execute /nomos-handshake. # ============================================================================== echo "" echo "${GREEN}${BOLD}🎉 Nomos Substrate installed successfully!${RESET}" echo "" echo " Location : ${BINARY_PATH}" echo " Protocol : Unified v1.4" echo "" echo "${CYAN}${BOLD}🚀 Next Steps:${RESET}" echo " 1. Reload your shell: ${BOLD}source $RC_FILE${RESET} (or open a new terminal tab)" echo " 2. Go to any existing git repository: ${BOLD}cd your-project${RESET}" echo " 3. Open your AI coding agent (Cursor, Claude Code, Antigravity) and type:" echo " ${CYAN}${BOLD}/nomos-handshake${RESET}" echo "" echo " 💡 To uninstall anytime: ${BOLD}curl -fsSL https://sophialabs.ca/uninstall | sh${RESET}" echo ""