Files
claude/lib/detect-plugins.sh
T
bchanot 381ed9fa5d chore(code-clean): lint directives, guarded cd, hook regex split, helper extractions
A1 drop unused `import gzip`; B1/B2 file-level shellcheck directives
placed before `set -u`; B3 `cd "$REPO" || exit 1`; B4 hook regex split
into `pattern+=` lines (sha256 of $pattern unchanged); B11
`_build_parser`/`_dispatch` pulled out of google_seo `_cli`; B20
detect-plugins header names update-all.sh; C2 prune-memory deterministic
suite wired into SUITES (literal path); C3 `_refuse_outside_allowlist`
moved up in deploy-commit.

No behavior change except B3 (a failed cd now exits 1) and C2 (one more
suite). B5/B7/B9/B18/B19 land in the refactor commit.
2026-10-12 22:51:28 +02:00

91 lines
2.9 KiB
Bash

#!/usr/bin/env bash
# ============================================================
# lib/detect-plugins.sh — Single source of truth for plugin detection
# Sourced by: session-start.sh, doctor.sh, install-plugins.sh, update-all.sh
#
# Each function returns 0 (detected) or 1 (not detected).
# No output — callers handle messaging.
# ============================================================
# --- Always-on plugins ---
detect_rtk() {
command -v rtk &>/dev/null && return 0
# PATH heal: hook/session PATH may lack the cargo bin dir (LRN-036 class)
[ -x "$HOME/.cargo/bin/rtk" ] || [ -x "$HOME/.local/bin/rtk" ]
}
detect_superpowers() {
# superpowers = 7 vendored skills since 2026-09-28; the plugin is gone.
# One file test on the linked vendored skill: proves vendored AND
# linked in one shot — no plugin cache glob, no `claude plugin list`.
[ -f "$HOME/.claude/skills/brainstorming/SKILL.md" ]
}
# --- Toggle plugins ---
detect_gstack() {
# gstack is exposed via per-skill symlinks (browse, canary, qa, …);
# the legacy top-level symlink was removed to avoid duplicate entries.
# Detect by checking any of its individual skills.
[ -L "$HOME/.claude/skills/browse" ] || [ -L "$HOME/.claude/skills/qa" ]
}
detect_gsd() {
# GSD v2 (gsd-pi) is a standalone CLI, not a Claude Code plugin.
# Detection: check for 'gsd' binary in PATH.
command -v gsd &>/dev/null
}
detect_plugin_dev() {
# plugin-dev replaces the old "skill-creator" reference
local cache_dir="$HOME/.claude/plugins/cache"
[ -d "$cache_dir" ] && compgen -G "$cache_dir"/*plugin-dev* &>/dev/null
}
detect_uiux_pro_max() {
local cache_dir="$HOME/.claude/plugins/cache"
[ -d "$cache_dir" ] && compgen -G "$cache_dir"/*ui-ux-pro-max* &>/dev/null
}
detect_context7() {
# Context7 CLI (ctx7) — installed globally via npm
command -v ctx7 &>/dev/null
}
detect_graphifyy() {
# Graphifyy — codebase knowledge graph, installed via pipx
command -v graphify &>/dev/null
}
# --- Plan detection ---
detect_plan() {
# Detect Claude plan: max, pro, or free.
# Checks ~/.claude.json for model access hints.
# Returns plan name on stdout, always exits 0.
local claude_json="$HOME/.claude.json"
if [ -f "$claude_json" ]; then
# Max plan: has opus model access or max flag
if grep -q '"planType".*"max"' "$claude_json" 2>/dev/null; then
echo "max"; return 0
fi
# Check cached features for max indicators
if grep -q '"tengu_cobalt_compass": true' "$claude_json" 2>/dev/null \
&& grep -q '"tengu_harbor": true' "$claude_json" 2>/dev/null; then
echo "max"; return 0
fi
fi
# Fallback: check if claude CLI reports plan
local plan
plan=$(claude config get planType 2>/dev/null || true)
case "$plan" in
max|Max|MAX) echo "max" ;;
pro|Pro|PRO) echo "pro" ;;
free|Free|FREE) echo "free" ;;
*) echo "pro" ;; # default assumption
esac
}