#!/bin/bash # Install/upgrade the inkreach-teable CLI + agent skill from this standalone repo. # Run from this skill's directory (or anywhere; paths resolve from this file). # What it does: # 1. Builds the CLI (this repo's root IS the package). # 2. Links the `inkreach-teable` command globally. # 3. Installs the skill to ~/.zcode/skills/inkreach-teable (user scope — # available in every ZCode workspace, shadows same-named workspace skills). # Re-run this script after pulling changes to refresh both the command and the skill. set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Resolve the repo root: skill lives at /.agents/skills/inkreach-teable/scripts/ REPO_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)" SKILL_DIR="$REPO_ROOT/.agents/skills/inkreach-teable" echo "=== inkreach-teable CLI installation ===" # Check Node.js if ! command -v node &> /dev/null; then echo "ERROR: Node.js is not installed. Install Node.js >= 18 first." exit 1 fi NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1) if [ "$NODE_VERSION" -lt 18 ]; then echo "ERROR: Node.js >= 18 required, found v$(node -v)" exit 1 fi echo "✓ Node.js $(node -v)" # Check repo layout if [ ! -f "$REPO_ROOT/package.json" ] || [ ! -d "$REPO_ROOT/src" ]; then echo "ERROR: CLI source not found at $REPO_ROOT" echo " Ensure the inkreach-teable-cli repo is checked out at $REPO_ROOT" exit 1 fi # Build echo "Building CLI from $REPO_ROOT ..." cd "$REPO_ROOT" if command -v pnpm &> /dev/null; then pnpm install --prefer-offline 2>/dev/null || true pnpm build else echo "ERROR: pnpm not found. Install pnpm first: npm i -g pnpm" exit 1 fi # Link globally. Prefer pnpm; fall back to npm link; finally create a wrapper. echo "Linking 'inkreach-teable' command globally ..." LINKED=0 if command -v pnpm &> /dev/null && pnpm link --global 2>/dev/null; then LINKED=1 elif command -v npm &> /dev/null && npm link 2>/dev/null; then LINKED=1 fi # Ensure a usable wrapper exists on PATH even if global bin isn't configured. mkdir -p "$HOME/.local/bin" cat > "$HOME/.local/bin/inkreach-teable" < /dev/null; then echo "✓ inkreach-teable CLI installed ($(inkreach-teable --version 2>/dev/null || echo 'unknown'))" echo "" echo "Next: configure endpoint + token:" echo " inkreach-teable auth login --endpoint http://localhost:3000 --token " echo "Or create a PAT first:" echo " inkreach-teable auth token create --name my-cli" else echo "⚠ 'inkreach-teable' not on PATH. Add pnpm/npm global bin to your PATH, or run directly:" echo " node $REPO_ROOT/dist/bin.js " fi