Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
114 lines (105 loc) · 3.8 KB
/
Copy pathinstall.sh
File metadata and controls
114 lines (105 loc) · 3.8 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
#!/bin/bash
# install.sh - put housebroken where the current user's agent can reach it.
#
# Two destinations and nothing else: the gate scripts, the `housebroken`
# dispatcher and a VERSION file go into $HOUSEBROKEN_HOME/bin, and the skill
# directory goes into $HOME/.claude/skills/housebroken, which is where Claude
# Code looks for a user skill. No profile is edited, no PATH is changed, no
# state is written anywhere else; when the bin directory is not on PATH the
# one line to add is printed for the operator to add by hand.
#
# Other agent hosts (Codex, Cursor, Copilot) are not wired up yet.
# skills/housebroken/SKILL.md is the source of truth for every future adapter:
# an adapter converts that file, it does not restate its rules.
#
# Usage:
# bash install.sh # install
# bash install.sh --dry-run # print what it would do, change nothing
# bash install.sh --uninstall # remove exactly what install put there
# bash install.sh --help
#
# Environment:
# HOUSEBROKEN_HOME install root, default $HOME/.housebroken. The scripts and
# the dispatcher go in its bin/ subdirectory.
# HOME the user home; $HOME/.claude/skills is the skill root.
#
# Assumes bash and a writable HOME. Works from any working directory: the repo
# root is resolved from this file's own location.
set -u
usage() {
sed -n '2,/^set -u$/p' "$0" | sed 's/^# \{0,1\}//; /^set -u$/d'
}
mode=install
case "${1:-}" in
--help|-h) usage; exit 0 ;;
--dry-run|-n) mode=dry ;;
--uninstall) mode=uninstall ;;
"") ;;
*) echo "install.sh: unknown argument: $1" >&2; usage >&2; exit 2 ;;
esac
repo=$(cd "$(dirname "$0")" && pwd)
HOUSEBROKEN_HOME="${HOUSEBROKEN_HOME:-$HOME/.housebroken}"
bindir="$HOUSEBROKEN_HOME/bin"
skilldir="$HOME/.claude/skills/housebroken"
for need in "$repo/scripts" "$repo/bin/housebroken" "$repo/skills/housebroken" "$repo/pyproject.toml"; do
if [ ! -e "$need" ]; then
echo "install.sh: missing from the repository: $need" >&2
exit 1
fi
done
version=$(sed -n 's/^version = "\(.*\)"/\1/p' "$repo/pyproject.toml" | head -1)
[ -n "$version" ] || { echo "install.sh: no version = \"...\" line in $repo/pyproject.toml" >&2; exit 1; }
if [ "$mode" = uninstall ]; then
for f in "$repo"/scripts/*.sh; do
target="$bindir/$(basename "$f")"
[ -e "$target" ] && rm -f "$target" && echo "removed $target"
done
for target in "$bindir/housebroken" "$bindir/VERSION"; do
if [ -e "$target" ]; then
rm -f "$target"
echo "removed $target"
fi
done
if [ -d "$skilldir" ]; then
rm -rf "$skilldir"
echo "removed $skilldir"
fi
rmdir "$bindir" 2>/dev/null && echo "removed $bindir"
rmdir "$HOUSEBROKEN_HOME" 2>/dev/null && echo "removed $HOUSEBROKEN_HOME"
echo "uninstalled housebroken"
exit 0
fi
if [ "$mode" = dry ]; then
echo "would create $bindir"
for f in "$repo"/scripts/*.sh; do
echo "would copy $(basename "$f") to $bindir"
done
echo "would copy housebroken to $bindir"
echo "would write VERSION (housebroken $version) to $bindir"
echo "would create $skilldir"
echo "would copy the skill from $repo/skills/housebroken to $skilldir"
exit 0
fi
mkdir -p "$bindir"
for f in "$repo"/scripts/*.sh; do
cp "$f" "$bindir/"
chmod +x "$bindir/$(basename "$f")" 2>/dev/null || true
echo "installed $bindir/$(basename "$f")"
done
cp "$repo/bin/housebroken" "$bindir/housebroken"
chmod +x "$bindir/housebroken" 2>/dev/null || true
echo "installed $bindir/housebroken"
echo "housebroken $version" > "$bindir/VERSION"
echo "installed $bindir/VERSION"
rm -rf "$skilldir"
mkdir -p "$skilldir"
cp -R "$repo/skills/housebroken/." "$skilldir/"
echo "installed $skilldir"
case ":${PATH:-}:" in
*":$bindir:"*) ;;
*)
echo
echo "$bindir is not on PATH. Add this line to your shell profile:"
echo " export PATH=\"$bindir:\$PATH\""
;;
esac