-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
116 lines (104 loc) · 3.73 KB
/
Copy pathinstall.sh
File metadata and controls
116 lines (104 loc) · 3.73 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
#!/usr/bin/env bash
# =============================================================================
# install.sh — cross-tool installer for the java-development skill
#
# Detects which AI coding tools are installed (Claude Code, Codex, OpenCode,
# ZCode) and installs the skill into each tool's discovery directory.
#
# Usage:
# ./install.sh # install everywhere it can
# ./install.sh --force # overwrite existing installs in detected tools
# ./install.sh --all # install to every supported tool directory
# ./install.sh --uninstall # remove from all tools
#
# Works on macOS, Linux, and Windows (Git Bash / WSL).
# =============================================================================
set -euo pipefail
SKILL_NAME="java-development"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
SKILL_SRC="${SCRIPT_DIR}" # the repo root IS the skill folder
FORCE=0
INSTALL_ALL=0
UNINSTALL=0
for arg in "$@"; do
case "$arg" in
--force|-f) FORCE=1 ;;
--all|-a) INSTALL_ALL=1 ;;
--uninstall|-u) UNINSTALL=1 ;;
--help|-h)
echo "Usage: ./install.sh [--force] [--all] [--uninstall]"
echo " --force overwrite an existing install"
echo " --all create every supported tool directory"
echo " --uninstall remove the skill from all detected tools"
exit 0 ;;
*) echo "Unknown arg: $arg"; exit 1 ;;
esac
done
# --- target directories per tool (in $HOME) ----------------------------------
# Each tool discovers skills in its own folder. We install into whichever exist.
declare -a TARGETS=(
"$HOME/.claude/skills" # Claude Code
"$HOME/.codex/skills" # OpenAI Codex CLI
"$HOME/.config/opencode/skills" # OpenCode global config
"$HOME/.opencode/skills" # OpenCode legacy/fallback path
"$HOME/.zcode/skills" # ZCode
"$HOME/.agents/skills" # generic cross-tool location
)
DEST_FOUND=0
for dir in "${TARGETS[@]}"; do
# Install only if the tool's parent config dir exists, unless --all was used.
parent="$(dirname "$dir")"
if [ "$INSTALL_ALL" -eq 0 ] && [ ! -d "$parent" ]; then
continue
fi
tool="$(basename "$parent" | sed 's/^\.//')" # .claude -> claude
target="$dir/$SKILL_NAME"
if [ "$UNINSTALL" -eq 1 ]; then
if [ -e "$target" ] || [ -L "$target" ]; then
rm -rf "$target"
echo "✓ uninstalled from $tool ($dir)"
fi
continue
fi
mkdir -p "$dir"
DEST_FOUND=1
# Prefer a symlink so `git pull` updates propagate automatically.
# Fall back to copy if symlink fails (e.g. no privilege on Windows).
if [ -e "$target" ] || [ -L "$target" ]; then
if [ "$FORCE" -eq 0 ]; then
echo "• $tool: already installed at $target (use --force to overwrite)"
continue
fi
rm -rf "$target"
fi
if ln -s "$SKILL_SRC" "$target" 2>/dev/null; then
echo "✓ $tool: linked → $target"
else
mkdir -p "$target"
(
cd "$SKILL_SRC"
tar --exclude=.git --exclude=__pycache__ --exclude='*.pyc' -cf - .
) | (
cd "$target"
tar -xf -
)
echo "✓ $tool: copied → $target (symlink unavailable)"
fi
done
if [ "$UNINSTALL" -eq 1 ]; then
echo ""
echo "Done. Skill removed from all detected tools."
exit 0
fi
if [ "$DEST_FOUND" -eq 0 ]; then
echo "⚠ No AI tool config directories found in $HOME."
echo " Install at least one of: Claude Code, Codex, OpenCode, ZCode,"
echo " then re-run this script. Or use --all to install to all paths."
exit 1
fi
echo ""
echo "Done. The '$SKILL_NAME' skill is now active in the tools above."
echo "Restart any running tool sessions to pick it up."
echo ""
echo "To verify: open the tool and ask a Java/Spring Boot question; the"
echo "skill should trigger automatically (see SKILL.md description keywords)."