#!/bin/sh # Installs poping's Meta skills for Claude Code and points them at your poping wallet. # # curl -fsSL https://poping.art/skills/install.sh | sh -s -- pp_live_xxx [search] [imagine] # # With no skill names, both are installed. Each skill goes to ~/.claude/skills/ and its # command is linked onto PATH. The key is saved as POPING_API_KEY in ~/.claude/settings.json # ("env"), so every Claude Code session bills that key; calls are charged at the upstream # price plus our margin, the same as the rest of the API. set -e base=${POPING_BASE_URL:-https://poping.art} key="" names="" while [ $# -gt 0 ]; do case $1 in --base) base=$2; shift ;; --base=*) base=${1#--base=} ;; search|imagine) names="$names $1" ;; -*) echo "unknown option: $1" >&2; exit 2 ;; *) key=$1 ;; esac shift done base=$(printf %s "$base" | sed 's:/*$::; s:/v1$::') [ -n "$names" ] || names="search imagine" [ -n "$key" ] || key=${POPING_API_KEY:-} if [ -z "$key" ]; then echo "Pass your poping API key: curl -fsSL $base/skills/install.sh | sh -s -- " >&2 exit 2 fi # Both CLIs are TypeScript run by Node's own type stripping (22.18+). if ! command -v node >/dev/null 2>&1; then echo "Node.js 22.18 or newer is needed: https://nodejs.org" >&2 exit 1 fi if ! node -e 'const [a,b]=process.versions.node.split(".").map(Number);process.exit(a>22||(a===22&&b>=18)?0:1)'; then echo "Node.js $(node -v) is too old; 22.18 or newer is needed: https://nodejs.org" >&2 exit 1 fi skills="$HOME/.claude/skills" mkdir -p "$skills" # A PATH directory we can write to, so Claude Code's shell finds the commands. bindir="" for d in /opt/homebrew/bin /usr/local/bin "$HOME/.local/bin"; do case ":$PATH:" in *":$d:"*) [ -w "$d" ] && { bindir=$d; break; } ;; esac done if [ -z "$bindir" ]; then bindir="$HOME/.local/bin" mkdir -p "$bindir" echo "note: add $bindir to your PATH (the skills also run without it)." fi tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT for name in $names; do curl -fsSL "$base/skills/$name.tar.gz" -o "$tmp/$name.tar.gz" tar -xzf "$tmp/$name.tar.gz" -C "$tmp" rm -rf "$skills/$name" mv "$tmp/$name" "$skills/$name" case $name in search) bin="$skills/search/cli/bin/search" ;; imagine) bin="$skills/imagine/bin/imagine" ;; esac chmod +x "$bin" ln -sf "$bin" "$bindir/$name" echo "installed $name -> $skills/$name ($bindir/$name)" done # The key (and a non-default gateway) go into Claude Code's settings, kept alongside what is there. POPING_KEY=$key POPING_BASE=$base node -e ' const fs = require("fs"), path = require("path"); const file = path.join(process.env.HOME, ".claude", "settings.json"); let s = {}; try { s = JSON.parse(fs.readFileSync(file, "utf8")); } catch (e) { if (e.code !== "ENOENT") { console.error(`could not read ${file}: ${e.message}`); process.exit(1); } } s.env = { ...(s.env || {}), POPING_API_KEY: process.env.POPING_KEY }; if (process.env.POPING_BASE !== "https://poping.art") s.env.POPING_BASE_URL = process.env.POPING_BASE; else delete s.env.POPING_BASE_URL; fs.writeFileSync(file, JSON.stringify(s, null, 2) + "\n"); console.log(`saved POPING_API_KEY in ${file}`); ' echo "Done. Start a new Claude Code session and ask it to search or to draw something."