-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·148 lines (132 loc) · 3 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·148 lines (132 loc) · 3 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
#!/bin/bash
set -euo pipefail
SELFOS_DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET="all"
REGISTER_HOOK="ask"
usage() {
cat <<'EOF'
Usage: ./setup.sh [--target claude|codex|all] [--hook|--no-hook]
Registers selfOS skills as global symlinks.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--target)
TARGET="${2:-}"
shift 2
;;
--target=*)
TARGET="${1#*=}"
shift
;;
--hook)
REGISTER_HOOK="yes"
shift
;;
--no-hook)
REGISTER_HOOK="no"
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
case "$TARGET" in
claude|codex|all) ;;
*)
echo "Invalid target: $TARGET" >&2
usage >&2
exit 1
;;
esac
SKILLS=(
wiki
interview
thought
digest
todo
wiki-help
academic-writing
paper-plot
transcribe
de-ai
)
echo "selfOS Setup"
echo "============"
echo ""
install_links() {
local source_root="$1"
local dest_root="$2"
local entry_file="$3"
local label="$4"
mkdir -p "$dest_root"
echo "Registering $label skill symlinks..."
for skill in "${SKILLS[@]}"; do
local target="$source_root/$skill"
local link="$dest_root/$skill"
if [ ! -f "$target/$entry_file" ]; then
echo " skip $skill (missing $entry_file)"
continue
fi
if [ -L "$link" ]; then
local current
current="$(readlink "$link")"
if [ "$current" = "$target" ]; then
echo " ok $skill"
else
ln -sfn "$target" "$link"
echo " -> $skill"
fi
elif [ -e "$link" ]; then
echo " skip $skill (real file/dir exists at $link)"
else
ln -s "$target" "$link"
echo " + $skill"
fi
done
}
if [ "$TARGET" = "claude" ] || [ "$TARGET" = "all" ]; then
install_links "$SELFOS_DIR/.claude/skills" "$HOME/.claude/skills" "skill.md" "Claude"
echo ""
fi
if [ "$TARGET" = "codex" ] || [ "$TARGET" = "all" ]; then
install_links "$SELFOS_DIR/.agents/skills" "$HOME/.agents/skills" "SKILL.md" "Codex"
echo ""
fi
if [ "$TARGET" = "claude" ] || [ "$TARGET" = "all" ]; then
if [ "$REGISTER_HOOK" = "ask" ]; then
echo "Auto-Capture hook registers a Stop hook that silently captures"
echo "personal context from Claude Code sessions into your wiki."
echo ""
read -r -p "Register Auto-Capture hook? (y/n) " REPLY
if [[ $REPLY =~ ^[Yy]$ ]]; then
REGISTER_HOOK="yes"
else
REGISTER_HOOK="no"
fi
fi
if [ "$REGISTER_HOOK" = "yes" ]; then
echo ""
echo "Add this to ~/.claude/settings.json under \"Stop\" hooks:"
echo ""
echo " {"
echo " \"hooks\": [{"
echo " \"command\": \"bash $SELFOS_DIR/hooks/auto-capture.sh\","
echo " \"type\": \"command\""
echo " }],"
echo " \"matcher\": \"\""
echo " }"
echo ""
fi
fi
echo "Done."
if [ "$TARGET" = "codex" ] || [ "$TARGET" = "all" ]; then
echo "Codex users: restart the Codex session if newly installed skills do not appear immediately."
fi