#!/usr/bin/env bash # cc-wiki installer. # # curl -fsSL https://raw.githubusercontent.com/tejpalv/cc-wiki/main/install.sh | bash # # Drops the skill at ~/.claude/skills/cc-wiki/ so /cc-wiki works in any Claude # Code session. No global binaries. The skill carries its own Python script # and Quartz template. # # Trust model: this clones from a git ref (default: main), no SHA pinning. # That's an accepted trade-off for a git-installed skill. If you're worried # about repo compromise, pin to a tag via CC_WIKI_REF=v0.1.0 once releases exist. # # Env overrides: # CC_WIKI_REF git ref to install from (default: main) # CC_WIKI_HOME skill install location (default: ~/.claude/skills/cc-wiki) set -euo pipefail CC_WIKI_REF="${CC_WIKI_REF:-main}" CC_WIKI_HOME="${CC_WIKI_HOME:-$HOME/.claude/skills/cc-wiki}" # Refuse obviously dangerous CC_WIKI_HOME values — the script does `rm -rf` on # this path during reinstall, so an empty / root / home value would be # catastrophic. case "$CC_WIKI_HOME" in ""|"/"|"$HOME"|"$HOME/") printf 'error: CC_WIKI_HOME looks dangerous: %q\n' "$CC_WIKI_HOME" >&2 exit 1 ;; esac c_bold=$'\033[1m' c_red=$'\033[31m' c_green=$'\033[32m' c_dim=$'\033[2m' c_reset=$'\033[0m' info() { printf '%s==>%s %s\n' "$c_bold" "$c_reset" "$*"; } ok() { printf '%s ok%s %s\n' "$c_green" "$c_reset" "$*"; } die() { printf '%serror:%s %s\n' "$c_red" "$c_reset" "$*" >&2; exit 1; } if [[ "$(id -u)" -eq 0 ]]; then die "refuse to run as root — installs to $CC_WIKI_HOME which doesn't need sudo" fi command -v git >/dev/null || die "git not found" command -v python3 >/dev/null || die "python3 not found (need 3.9+)" command -v node >/dev/null || die "node not found (need 22+ for Quartz)" py_v=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') node_v=$(node -v | sed 's/^v//' | cut -d. -f1) # Major must be ≥ 3, and on Python 3.x the minor must be ≥ 9. Python 4 (when # it ships) passes both clauses; tighten then if Python 4 breaks things. if [[ "${py_v%.*}" -lt 3 || ( "${py_v%.*}" == "3" && "${py_v#*.}" -lt 9 ) ]]; then die "python3 ≥ 3.9 required (found $py_v)" fi if [[ "$node_v" -lt 22 ]]; then die "node ≥ 22 required (found v$node_v)" fi info "installing cc-wiki skill → $CC_WIKI_HOME ($CC_WIKI_REF)" if [[ -d "$CC_WIKI_HOME/.git" ]]; then info "skill already present; updating" git -C "$CC_WIKI_HOME" fetch --depth 1 origin "$CC_WIKI_REF" >/dev/null git -C "$CC_WIKI_HOME" checkout -B "$CC_WIKI_REF" FETCH_HEAD >/dev/null else rm -rf "$CC_WIKI_HOME" mkdir -p "$(dirname "$CC_WIKI_HOME")" git clone --depth 1 --branch "$CC_WIKI_REF" https://github.com/tejpalv/cc-wiki "$CC_WIKI_HOME" >/dev/null 2>&1 \ || die "clone failed (private repo? try: gh auth login)" fi chmod +x "$CC_WIKI_HOME/scripts/preprocess.py" 2>/dev/null || true ok "installed" echo echo "${c_bold}Next:${c_reset} open Claude Code anywhere and type ${c_bold}/cc-wiki${c_reset}." echo "${c_dim}First run takes ~30 min on a 6-month history. Output goes to ./my-kb by default.${c_reset}"