diff --git a/SETUP_GUIDE.md b/SETUP_GUIDE.md index 99946461..cb0332a4 100644 --- a/SETUP_GUIDE.md +++ b/SETUP_GUIDE.md @@ -6,74 +6,74 @@ Officer is a self-hosted AI intranet for teams. This guide covers fresh installa ## Architecture -Officer uses **system-wide Node.js** to ensure all users have consistent access to tools: +Officer uses **system-wide Node.js v22** to ensure all users have consistent access: ``` -System Node.js (v22, system-wide) +System Node.js v22 (/usr/bin/node) ↓ -npm global packages → /usr/local/lib/node_modules/ - ├── pi (coding agent) - ├── claude (Claude Code) - └── (available to all users) + All users automatically get: + ├── node, npm, bun + ├── pi, claude (coding agents) + ├── go, rustc (compilers) + └── All tools and services -Systemd Services - ├── officer-pty-sidecar (terminal backend) +Systemd Services (use system Node) + ├── officer-pty-sidecar + ├── officer (main server) └── (other services) ``` -This is **not** an nvm-based setup. Each user doesn't install their own Node version. Instead: -- One system Node.js for everyone -- All npm packages installed system-wide -- Simple, predictable, production-friendly +**Benefits:** +- One Node version for everyone (no conflicts) +- New users automatically get same setup +- Services use consistent environment +- Simple to maintain and troubleshoot +- Automatic installation (setup.sh handles it) --- ## Installation Steps -### 1. Install Node.js 22 (System-Wide) - -**On fresh Ubuntu/Debian:** - -```bash -# Add NodeSource repository for Node 22 LTS -curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - - -# Install Node.js and npm -sudo apt-get install -y nodejs - -# Verify for all users -node --version -npm --version - -# Both should work regardless of which user runs it -``` - -**Already have an older Node version?** - -```bash -# upgrade it -curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - -sudo apt-get install -y nodejs - -# verify -node --version # Should be v22.x.x -``` - -**Coming from nvm?** - -```bash -# If you installed via nvm before, remove it -# Then install system Node as above -# nvm is NOT needed for Officer production setup -``` - -### 2. Run Setup Script +### Quick Start (One Command) ```bash cd /path/to/officer/monorepo bash scripts/setup.sh ``` +That's it! The script will: +- Install Node.js 22 automatically (if not found) +- Install all dependencies +- Setup all services +- Verify everything works + +### What Happens Automatically + +The setup script automatically: +1. Checks if Node 22 is installed +2. If not, sets up NodeSource repository and installs it +3. Installs all system packages, tools, and npm globals +4. Creates systemd services +5. Verifies everything works + +**No manual Node installation needed!** + +### Coming from nvm? + +```bash +# If you previously installed via nvm, you can remove it +# (optional, won't interfere) +rm -rf ~/.nvm + +# Or keep it for local dev, but system Node will take precedence for services +``` + +The system Node (installed by setup.sh) will be used by: +- All users +- All systemd services +- All npm global packages +- Officer server itself + This will: - Install all system dependencies (git, build tools, ffmpeg, etc.) - Install Bun, Go, Rust @@ -85,27 +85,27 @@ This will: **Note:** Setup script uses `sudo` for system-level installations. You'll be prompted for your password. -### 3. Verify Installation +### Verify Installation + +After setup.sh completes, verify as any user: ```bash -# Everyone can use these (all users) -which node # /usr/bin/node -which pi # /usr/bin/pi -which claude # /usr/bin/claude -which bun # /home/user/.bun/bin/bun (or /usr/local/bin/bun) +node --version # v22.x.x +which pi # /usr/bin/pi +which claude # /usr/bin/claude +which bun # /usr/local/bin/bun -# Test that pi works -pi --version +# Test Pi works pi --list-models -# Test that Officer can start +# Test Officer can start bun dev -# In another terminal +# In another terminal, test API curl http://localhost:5000/api/pi/models ``` -### 4. Start Officer +### Start Officer **Development:** ```bash @@ -171,26 +171,18 @@ The `officer-pty-sidecar` systemd service will still use `/usr/bin/node` (system ### "node: command not found" -**For a single user:** -```bash -# User's shell doesn't have node in PATH -# Make sure system Node is installed: -sudo apt-get install -y nodejs -node --version -``` +This shouldn't happen if setup.sh ran successfully. But if it does: -**For systemd service:** ```bash -# Service can't find node -sudo systemctl status officer-pty-sidecar -journalctl -u officer-pty-sidecar +# Run setup script again — it will install Node if missing +bash scripts/setup.sh -# Fix: Install system Node +# Or manually install: curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - sudo apt-get install -y nodejs -# Restart service -sudo systemctl restart officer-pty-sidecar +# Verify +node --version # Should be v22.x.x ``` ### "pi: command not found" @@ -271,12 +263,17 @@ sudo systemctl restart officer-pty-sidecar --- -## Next Steps +## Quick Start -1. Install Node.js: `curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs` -2. Run setup: `bash scripts/setup.sh` -3. Start Officer: `bun dev` (or PM2/systemd in production) -4. Open browser: `http://localhost:5000` (or your configured port) +```bash +cd /path/to/officer/monorepo +bash scripts/setup.sh +bun dev +``` + +Open browser: `http://localhost:5000` (or your configured port) + +That's it! Everything is installed automatically. --- diff --git a/scripts/setup.sh b/scripts/setup.sh index 4d5fc60b..3aafeabf 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -268,9 +268,10 @@ if has node; then if [ "$NODE_MAJOR" = "22" ]; then skip "node v$NODE_VER (system-wide)" else - warn "Node $NODE_VER found but v22 is required — upgrading via NodeSource..." + warn "Node $NODE_VER found but v22 is required — upgrading..." case $PM in apt) + echo " Setting up NodeSource repository..." curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - sudo apt-get install -y nodejs if has node && [ "$(node -v | cut -d. -f1 | tr -d 'v')" = "22" ]; then @@ -279,26 +280,40 @@ if has node; then fail "Node.js upgrade failed" fi ;; - *) - warn "Manual upgrade needed for $PM: install Node.js 22 from official sources" + pacman) + install_pkg nodejs npm + if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi + ;; + brew) + install_pkg node + if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi ;; esac fi else - warn "Node.js not found — installing v22 via NodeSource..." + echo " Node.js not found — installing v22..." case $PM in apt) + echo " Setting up NodeSource repository (this may take a moment)..." curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - + echo " Installing nodejs from apt..." sudo apt-get install -y nodejs - if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi + if has node; then + ok "node v$(node -v) installed from NodeSource" + else + fail "Node.js install failed" + exit 1 + fi ;; pacman) + echo " Installing nodejs from pacman..." install_pkg nodejs npm - if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi + if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; exit 1; fi ;; brew) + echo " Installing node from brew..." install_pkg node - if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; fi + if has node; then ok "node v$(node -v) installed"; else fail "node install failed"; exit 1; fi ;; esac fi