#!/bin/sh # Plainsend CLI installer, served at https://plainsend.app/install: # # curl -fsSL https://plainsend.app/install | sh # # Checks for Node.js 22 or later, installs @plainsend/cli from npm (globally), then prints the next steps. # It changes nothing else on your computer. Set PLAINSEND_NPM to use another npm (for example "pnpm" or "bun"). set -eu say() { printf '%s\n' "$*"; } fail() { printf 'plainsend install: %s\n' "$*" >&2; exit 1; } command -v node >/dev/null 2>&1 || fail "Node.js 22 or later is needed. Install it from https://nodejs.org (or with nvm, fnm or Homebrew), then run this again." major=$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0) [ "$major" -ge 22 ] 2>/dev/null || fail "Node.js 22 or later is needed; this is $(node -v). Upgrade it, then run this again." npm_cmd=${PLAINSEND_NPM:-npm} command -v "$npm_cmd" >/dev/null 2>&1 || fail "$npm_cmd was not found. It comes with Node.js; check your PATH." # Until the package is published, say how to get going without it (npm answers 404 for an unknown package). if [ "$npm_cmd" = npm ] && ! npm view @plainsend/cli version >/dev/null 2>&1; then say "The Plainsend CLI is not on npm yet. Until it is, connect your agent to the MCP server (it signs in through" say "the browser):" say "" say " claude mcp add --transport http plainsend https://api.plainsend.app/mcp" say "" say "Docs: https://plainsend.app/docs For agents: https://plainsend.app/llms.txt" exit 0 fi say "Installing the Plainsend CLI with $npm_cmd..." case "$npm_cmd" in pnpm) pnpm add -g @plainsend/cli ;; bun) bun add -g @plainsend/cli ;; *) "$npm_cmd" install -g @plainsend/cli || fail "the install failed. If it was a permissions error, set an npm prefix you own (npm config set prefix ~/.npm-global, add ~/.npm-global/bin to PATH) and run this again." ;; esac command -v plainsend >/dev/null 2>&1 || fail "installed, but 'plainsend' is not on your PATH. Add $("$npm_cmd" prefix -g 2>/dev/null || echo 'your npm prefix')/bin to PATH." say "" say "Installed: $(plainsend help | head -n 1)" say "" say "Next:" say " plainsend login sign in through your browser" say " plainsend init in your project folder: config, agent instructions, a test email to you" say " claude mcp add --transport http plainsend https://api.plainsend.app/mcp" say " connect Claude Code (it signs in through the browser too)"