main
Kyle Bergstedt 0.1.1: CommonJS entry for Node 18 e3b5596
#!/usr/bin/env bash
# adom-forum installer — runs via `adom-wiki pkg install adom/adom-forum`.
#
# The tarball carries the CLI itself (one Node script, no build step) plus the
# skill. Installed by copying real files, no symlinks, so a later uninstall or
# upgrade of the package cannot leave a dangling link behind.
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
BIN_DIR="$HOME/.local/bin"
SKILLS_DIR="$HOME/.claude/skills"
mkdir -p "$BIN_DIR" "$SKILLS_DIR"

# Runs in the shared Linux runtime (Hydrogen web, macOS, and Windows all use
# it). Only Node 18+ is required; no host OS integration is used or assumed.
if ! command -v node >/dev/null 2>&1; then
  echo "[adom-forum] node is required (18 or newer) and was not found on PATH" >&2
  exit 1
fi
NODE_MAJOR="$(node -p 'process.versions.node.split(".")[0]')"
if [ "${NODE_MAJOR:-0}" -lt 18 ]; then
  echo "[adom-forum] node 18 or newer is required (found $(node --version))" >&2
  exit 1
fi

for name in adom-forum.cjs adom-forum; do
  tmp="$BIN_DIR/$name.tmp.$$"
  cp "$HERE/bin/$name" "$tmp"
  chmod +x "$tmp"
  rm -rf "$BIN_DIR/$name"
  mv -f "$tmp" "$BIN_DIR/$name"
  echo "   bin   → $BIN_DIR/$name"
done

# adom-wiki 1.0.81+ delivers skills/<name>/SKILL.md itself; older clients need this copy.
rm -rf "$SKILLS_DIR/adom-forum"
mkdir -p "$SKILLS_DIR/adom-forum"
cp "$HERE/skills/adom-forum/SKILL.md" "$SKILLS_DIR/adom-forum/SKILL.md"
echo "   skill → $SKILLS_DIR/adom-forum/SKILL.md"

case ":$PATH:" in
  *":$HOME/.local/bin:"*) ;;
  *) echo "[adom-forum] NOTE: $HOME/.local/bin is not on PATH — add it to your shell rc." ;;
esac

echo "✅ adom-forum $("$BIN_DIR/adom-forum" --version | awk '{print $NF}') installed. Try: adom-forum spaces"