-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·218 lines (190 loc) · 8.19 KB
/
install.sh
File metadata and controls
executable file
·218 lines (190 loc) · 8.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env bash
#
# CodeView installer — sets up the skill for Claude Code and (optionally)
# puts the launcher on your PATH.
#
# Usage (from a clone of this repo):
# ./install.sh
#
# Or with options:
# ./install.sh --no-launcher # only install the skill, skip the launcher
# ./install.sh --dir=~/.claude # force a specific Claude Code install dir
# ./install.sh --help # show help
#
set -e
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_LAUNCHER=1
FORCE_CLAUDE_DIR=""
# ANSI colors (fall back to empty strings if stdout isn't a TTY)
if [[ -t 1 ]]; then
B=$'\033[1m'; DIM=$'\033[2m'; G=$'\033[32m'; Y=$'\033[33m'; R=$'\033[31m'; C=$'\033[36m'; N=$'\033[0m'
else
B=""; DIM=""; G=""; Y=""; R=""; C=""; N=""
fi
log() { echo -e " $*"; }
ok() { echo -e " ${G}✓${N} $*"; }
warn() { echo -e " ${Y}!${N} $*"; }
err() { echo -e " ${R}✗${N} $*" >&2; }
step() { echo; echo -e "${B}$*${N}"; }
usage() {
cat <<EOF
${B}CodeView installer${N}
Sets up the ${C}codeview${N} Claude Code skill so you can run ${C}/codeview${N}
in any project, and optionally puts the ${C}codeview${N} CLI launcher on your PATH.
${B}Usage${N}
./install.sh [options]
${B}Options${N}
--no-launcher Install the skill only; skip PATH setup for the launcher.
--dir=<path> Force a specific Claude Code install dir (e.g. ~/.claude).
By default the script detects ~/.claude
--help Show this help.
${B}What it does${N}
1. Detects your Claude Code skills directory.
2. Symlinks ${C}skill/codeview${N} from this repo into that directory.
3. Optionally symlinks ${C}bin/codeview${N} into /usr/local/bin (needs sudo)
or prints a shell alias you can paste into your .zshrc / .bashrc.
${B}After install${N}
• Restart Claude Code (the skill list is cached at session start).
• In any project: type ${C}/codeview${N} — writes .codeview/report.json.
• In your terminal: run ${C}codeview${N} — opens the dashboard.
EOF
}
for arg in "$@"; do
case "$arg" in
--no-launcher) INSTALL_LAUNCHER=0 ;;
--dir=*) FORCE_CLAUDE_DIR="${arg#--dir=}" ;;
--help|-h) usage; exit 0 ;;
*) err "Unknown option: $arg"; usage; exit 1 ;;
esac
done
# Expand ~/ manually
FORCE_CLAUDE_DIR="${FORCE_CLAUDE_DIR/#\~/$HOME}"
step "CodeView installer"
log "Repo: ${DIM}$REPO_DIR${N}"
# ─────────────────────────────────────────────────────────────────
# 1. Verify we're in a valid checkout
# ─────────────────────────────────────────────────────────────────
SKILL_SRC="$REPO_DIR/skill/codeview"
LAUNCHER_SRC="$REPO_DIR/bin/codeview"
if [[ ! -f "$SKILL_SRC/SKILL.md" ]]; then
err "Can't find $SKILL_SRC/SKILL.md"
err "Are you running this from inside a clone of the codeview repo?"
exit 1
fi
if [[ ! -f "$LAUNCHER_SRC" ]]; then
err "Can't find $LAUNCHER_SRC"
exit 1
fi
# ─────────────────────────────────────────────────────────────────
# 2. Detect Claude Code skills directory
# ─────────────────────────────────────────────────────────────────
step "Step 1 — Locating Claude Code"
CLAUDE_DIRS=()
if [[ -n "$FORCE_CLAUDE_DIR" ]]; then
CLAUDE_DIRS=("$FORCE_CLAUDE_DIR")
else
[[ -d "$HOME/.claude" ]] && CLAUDE_DIRS+=("$HOME/.claude")
fi
if [[ ${#CLAUDE_DIRS[@]} -eq 0 ]]; then
warn "No Claude Code directory found at ~/.claude"
warn "Creating ~/.claude (default stable install)"
mkdir -p "$HOME/.claude/skills"
CLAUDE_DIRS=("$HOME/.claude")
fi
for dir in "${CLAUDE_DIRS[@]}"; do
ok "Found Claude Code at ${C}$dir${N}"
done
# ─────────────────────────────────────────────────────────────────
# 3. Symlink the skill into every detected Claude Code install
# ─────────────────────────────────────────────────────────────────
step "Step 2 — Installing the skill"
for cdir in "${CLAUDE_DIRS[@]}"; do
skills_dir="$cdir/skills"
target="$skills_dir/codeview"
mkdir -p "$skills_dir"
if [[ -L "$target" ]]; then
current="$(readlink "$target")"
if [[ "$current" == "$SKILL_SRC" ]]; then
ok "${C}$target${N} — already linked correctly"
continue
else
warn "${C}$target${N} exists but points to ${DIM}$current${N}"
read -r -p " Replace it? [y/N] " ans
if [[ "$ans" =~ ^[Yy]$ ]]; then
rm "$target"
else
warn "Skipped ${C}$target${N}"
continue
fi
fi
elif [[ -e "$target" ]]; then
warn "${C}$target${N} exists and is not a symlink"
read -r -p " Back up and replace? [y/N] " ans
if [[ "$ans" =~ ^[Yy]$ ]]; then
mv "$target" "$target.bak.$(date +%s)"
else
warn "Skipped ${C}$target${N}"
continue
fi
fi
ln -s "$SKILL_SRC" "$target"
ok "Linked ${C}$target${N} → ${DIM}$SKILL_SRC${N}"
done
# ─────────────────────────────────────────────────────────────────
# 4. Optionally install the launcher on PATH
# ─────────────────────────────────────────────────────────────────
if [[ $INSTALL_LAUNCHER -eq 1 ]]; then
step "Step 3 — Installing the CLI launcher"
if command -v codeview >/dev/null 2>&1; then
existing="$(command -v codeview)"
if [[ "$(readlink "$existing" 2>/dev/null)" == "$LAUNCHER_SRC" ]]; then
ok "${C}codeview${N} already on PATH at ${C}$existing${N}"
else
warn "${C}codeview${N} is already on PATH at ${DIM}$existing${N}"
warn "(Not touching it. Use ${C}--no-launcher${N} next time to silence this.)"
fi
else
# Try /usr/local/bin (requires sudo on macOS)
default_bin="/usr/local/bin/codeview"
log ""
log "The launcher is at:"
log " ${DIM}$LAUNCHER_SRC${N}"
log ""
log "To make ${C}codeview${N} available in any terminal, either:"
log ""
log " ${B}Option A — system symlink (needs sudo):${N}"
log " ${C}sudo ln -s $LAUNCHER_SRC $default_bin${N}"
log ""
log " ${B}Option B — shell alias (no sudo):${N}"
log " add to your ~/.zshrc or ~/.bashrc:"
log " ${C}alias codeview='$LAUNCHER_SRC'${N}"
log ""
log " ${B}Option C — skip${N} and always type ${C}$LAUNCHER_SRC${N} directly."
log ""
read -r -p " Run Option A now (sudo symlink to $default_bin)? [y/N] " ans
if [[ "$ans" =~ ^[Yy]$ ]]; then
if sudo ln -s "$LAUNCHER_SRC" "$default_bin"; then
ok "Linked ${C}$default_bin${N} → ${DIM}$LAUNCHER_SRC${N}"
else
err "sudo symlink failed — use Option B or C instead"
fi
fi
fi
fi
# ─────────────────────────────────────────────────────────────────
# 5. Done
# ─────────────────────────────────────────────────────────────────
step "Done"
log ""
log "${G}CodeView is installed.${N}"
log ""
log "${B}Next steps:${N}"
log " 1. ${Y}Restart Claude Code${N} so it picks up the skill."
log " 2. Open a project and run: ${C}/codeview${N}"
log " (or say: \"use the codeview skill to scan this project\")"
log " 3. In your terminal: ${C}codeview${N}"
log " to open the dashboard."
log ""
log "Update later with: ${C}git -C $REPO_DIR pull${N}"
log "Uninstall with: ${C}./uninstall.sh${N}"
log ""