-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·387 lines (335 loc) · 12.4 KB
/
install.sh
File metadata and controls
executable file
·387 lines (335 loc) · 12.4 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
#!/usr/bin/env bash
# signet-first — full setup installer
#
# Platforms: Linux (tested), macOS (tested), Windows (not supported — use WSL)
#
# Installs from scratch:
# 1. Signet (AI memory system)
# 2. signet-first skill (Signet-first memory protocol)
#
# Signet's knowledge graph traversal + FTS5 keyword search handle all skill
# search patterns. No embedding provider is required.
#
# Usage (one-liner):
# curl -sL https://raw.githubusercontent.com/ostico/signet-first/master/install.sh | bash
#
# Options (environment variables):
# HARNESS=opencode|claude-code|codex|cursor|gemini|copilot Force harness (default: auto-detect)
# SKIP_SIGNET=1 Skip Signet install (already have it)
# SKILL_ONLY=1 Skip everything, just install the skill
#
# Examples:
# curl -sL .../install.sh | bash # Full install
# curl -sL .../install.sh | SKILL_ONLY=1 bash # Just the skill
# curl -sL .../install.sh | HARNESS=claude-code bash # Force Claude Code
set -uo pipefail
REPO="https://raw.githubusercontent.com/ostico/signet-first/master"
HARNESS="${HARNESS:-auto}"
SKIP_SIGNET="${SKIP_SIGNET:-0}"
SKILL_ONLY="${SKILL_ONLY:-0}"
if [ -t 1 ]; then
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; BOLD='\033[1m'; NC='\033[0m'
else
GREEN=''; YELLOW=''; RED=''; BOLD=''; NC=''
fi
ok() { echo -e " ${GREEN}✓${NC} $1"; }
warn() { echo -e " ${YELLOW}⚠${NC} $1"; }
fail() { echo -e " ${RED}✗${NC} $1"; }
step() { echo -e "\n${BOLD}[$1]${NC} $2"; }
# ─── Harness detection ────────────────────────────────────────────────────────
detect_harness() {
if [ "$HARNESS" != "auto" ]; then return; fi
if [ -d "$HOME/.config/opencode" ]; then
HARNESS="opencode"
elif [ -d "$HOME/.claude" ]; then
HARNESS="claude-code"
elif [ -d "$HOME/.agents/skills" ]; then
HARNESS="codex"
elif [ -d "$HOME/.cursor" ]; then
HARNESS="cursor"
elif [ -d "$HOME/.gemini" ]; then
HARNESS="gemini"
else
HARNESS="opencode"
warn "No harness directory found — defaulting to opencode"
fi
}
clone_dir() {
case "$HARNESS" in
opencode) echo "$HOME/.config/opencode/skills/signet-first" ;;
claude-code) echo "$HOME/.claude/skills/signet-first" ;;
codex) echo "$HOME/.codex/signet-first" ;;
cursor) echo "$HOME/.cursor/skills/signet-first" ;;
gemini) echo "$HOME/.gemini/signet-first" ;;
copilot) echo "$HOME/.copilot/skills/signet-first" ;;
*) echo "$HOME/.config/opencode/skills/signet-first" ;;
esac
}
discovery_dir() {
case "$HARNESS" in
codex) echo "$HOME/.agents/skills/signet-first" ;;
gemini) echo "$HOME/.gemini/extensions/signet-first" ;;
*) echo "" ;;
esac
}
# ─── Step 1: Node.js check ───────────────────────────────────────────────────
check_node() {
if [ "$SKILL_ONLY" = "1" ] || [ "$SKIP_SIGNET" = "1" ]; then return 0; fi
step "1/3" "Node.js"
if command -v node &> /dev/null; then
NODE_VER=$(node --version)
NODE_MAJOR=$(echo "$NODE_VER" | sed 's/v//' | cut -d. -f1)
if [ "$NODE_MAJOR" -ge 20 ]; then
ok "Node.js $NODE_VER"
return 0
else
fail "Node.js $NODE_VER too old (need v20+)"
fi
else
fail "Node.js not found"
fi
echo " Install Node.js 22:"
echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash"
echo " source ~/.\"\${SHELL##*/}rc\" && nvm install 22"
return 1
}
# ─── Step 2: Signet ──────────────────────────────────────────────────────────
install_signet() {
if [ "$SKILL_ONLY" = "1" ] || [ "$SKIP_SIGNET" = "1" ]; then return 0; fi
step "2/3" "Signet"
if command -v bun &> /dev/null; then
ok "Bun already installed ($(bun --version 2>/dev/null))"
else
echo " Installing Bun (Signet daemon runtime)..."
curl -fsSL https://bun.sh/install | bash > /dev/null 2>&1
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
if command -v bun &> /dev/null; then
ok "Bun installed ($(bun --version 2>/dev/null))"
else
warn "Bun installation failed — daemon won't start"
echo " Try manually: curl -fsSL https://bun.sh/install | bash"
fi
fi
if command -v signet &> /dev/null; then
ok "Signet already installed ($(signet --version 2>/dev/null || echo 'unknown'))"
else
echo " Installing signetai..."
npm install -g signetai 2>&1 | tail -3
if command -v signet &> /dev/null; then
ok "Signet installed ($(signet --version 2>/dev/null))"
else
fail "Signet installation failed"
echo " Try manually: npm install -g signetai"
return 1
fi
fi
if [ -f "$HOME/.agents/agent.yaml" ]; then
ok "Signet already configured (~/.agents/agent.yaml exists)"
else
echo " Running signet setup (non-interactive)..."
signet setup --non-interactive \
--name "Smart-Agent" \
--description "Personal AI assistant" \
--harness "$HARNESS" \
--deployment-type local \
--extraction-provider "$HARNESS" \
--embedding-provider none \
--skip-git \
2>&1 | tail -5
if [ -f "$HOME/.agents/agent.yaml" ]; then
ok "Signet configured"
else
warn "Setup may still be running — check with: signet status"
fi
fi
if signet status 2>&1 | grep -q "Daemon running"; then
ok "Signet daemon running"
else
echo " Starting Signet daemon..."
signet daemon start 2>&1 | tail -3
sleep 3
if signet status 2>&1 | grep -q "Daemon running"; then
ok "Signet daemon started"
else
warn "Daemon may need manual start: signet daemon start"
fi
fi
echo " Syncing harness plugins..."
signet sync > /dev/null 2>&1
ok "Harness plugins synced"
if [ "$HARNESS" = "opencode" ]; then
local CONFIG="$HOME/.config/opencode/opencode.json"
if [ -f "$CONFIG" ] && grep -q '"signet"' "$CONFIG"; then
ok "Signet MCP already in opencode.json"
else
warn "Add signet MCP to opencode.json manually:"
echo ' "mcp": { "signet": { "command": ["signet-mcp"], "enabled": true } }'
fi
fi
}
# ─── Step 3: signet-first skill ──────────────────────────────────────────────
install_skill() {
step "3/3" "signet-first skill + plugin"
local DIR
DIR=$(clone_dir)
if [ -d "$DIR/.git" ]; then
ok "signet-first already cloned at $DIR"
echo " Updating..."
git -C "$DIR" pull --ff-only 2>&1 | tail -3
elif command -v git &> /dev/null; then
echo " Cloning repository (includes hooks + plugin files)..."
git clone https://github.com/Ostico/signet-first.git "$DIR" 2>&1 | tail -3
else
echo " git not available — falling back to SKILL.md download"
mkdir -p "$DIR"
curl -sL "$REPO/SKILL.md" -o "$DIR/SKILL.md"
fi
if [ -f "$DIR/SKILL.md" ]; then
ok "signet-first installed at $DIR"
else
fail "Installation failed"
echo " Try manually: git clone https://github.com/Ostico/signet-first.git $DIR"
return 1
fi
# Create discovery symlink when clone path != discovery path
local DISC
DISC=$(discovery_dir)
if [ -n "$DISC" ] && [ "$DISC" != "$DIR" ]; then
local DISC_PARENT
DISC_PARENT=$(dirname "$DISC")
mkdir -p "$DISC_PARENT"
if [ -L "$DISC" ]; then
ok "Discovery symlink already exists ($DISC)"
elif [ -d "$DISC" ]; then
warn "Directory already exists at $DISC — skipping symlink"
else
ln -sf "$DIR" "$DISC"
ok "Symlinked $DIR → $DISC"
fi
fi
if [ "$HARNESS" = "opencode" ]; then
register_opencode_plugin
fi
if [ "$HARNESS" = "claude-code" ]; then
echo ""
warn "Claude Code requires manual plugin registration."
echo " Run these two commands in your Claude Code prompt:"
echo " /plugin marketplace add Ostico/signet-first"
echo " /plugin install signet-first@signet-first-dev"
echo " Then restart Claude Code."
fi
if [ "$HARNESS" = "cursor" ]; then
echo ""
warn "Cursor requires manual plugin installation."
echo " In Cursor, open Settings > Rules and verify the plugin is loaded."
echo " Or run in Cursor chat:"
echo " /plugin install $DIR"
fi
if [ "$HARNESS" = "copilot" ]; then
local COPILOT_PLUGIN_DIR="$HOME/.copilot/installed-plugins/_direct/signet-first"
if [ -d "$DIR" ] && [ ! -L "$COPILOT_PLUGIN_DIR" ]; then
mkdir -p "$HOME/.copilot/installed-plugins/_direct"
ln -sf "$DIR" "$COPILOT_PLUGIN_DIR"
ok "Copilot CLI plugin symlinked"
elif [ -L "$COPILOT_PLUGIN_DIR" ]; then
ok "Copilot CLI plugin symlink already exists"
fi
fi
}
register_opencode_plugin() {
local CONFIG="$HOME/.config/opencode/opencode.json"
local PLUGIN_ENTRY="signet-first@git+https://github.com/Ostico/signet-first.git"
if [ ! -f "$CONFIG" ]; then
warn "opencode.json not found — create it manually or restart OpenCode"
return
fi
if grep -q "signet-first" "$CONFIG" 2>/dev/null; then
ok "signet-first plugin already in opencode.json"
return
fi
if command -v jq &> /dev/null; then
local TMP="${CONFIG}.tmp"
if jq -e '.plugin' "$CONFIG" > /dev/null 2>&1; then
jq ".plugin += [\"$PLUGIN_ENTRY\"]" "$CONFIG" > "$TMP" && mv "$TMP" "$CONFIG"
else
jq ". + {\"plugin\": [\"$PLUGIN_ENTRY\"]}" "$CONFIG" > "$TMP" && mv "$TMP" "$CONFIG"
fi
ok "signet-first plugin added to opencode.json"
else
warn "jq not available — add this to opencode.json plugin array manually:"
echo " \"$PLUGIN_ENTRY\""
fi
}
# ─── Summary ─────────────────────────────────────────────────────────────────
summary() {
echo ""
echo -e "${BOLD}━━━ Done ━━━${NC}"
echo ""
local ALL_OK=true
if command -v signet &> /dev/null; then
if signet status 2>&1 | grep -q "Daemon running"; then
ok "Signet daemon running"
else
warn "Signet installed but daemon not running — run: signet daemon start"
ALL_OK=false
fi
else
warn "Signet not installed — run: npm install -g signetai && signet setup"
ALL_OK=false
fi
local DIR
DIR=$(clone_dir)
if [ -f "$DIR/SKILL.md" ]; then
ok "signet-first skill installed ($HARNESS)"
if [ -d "$DIR/.git" ]; then
ok "full repo cloned (hooks + plugin files included)"
else
warn "SKILL.md only — plugin auto-injection not available"
echo " For full plugin: git clone https://github.com/Ostico/signet-first.git $DIR"
fi
else
fail "Skill not found at $DIR/SKILL.md"
ALL_OK=false
fi
if [ "$HARNESS" = "opencode" ]; then
local CONFIG="$HOME/.config/opencode/opencode.json"
if [ -f "$CONFIG" ] && grep -q "signet-first" "$CONFIG"; then
ok "signet-first plugin registered in opencode.json"
else
warn "Plugin not registered — auto-injection won't work until added to opencode.json"
fi
fi
if [ "$HARNESS" = "claude-code" ]; then
warn "Register the plugin in Claude Code:"
echo " /plugin marketplace add Ostico/signet-first"
echo " /plugin install signet-first@signet-first-dev"
fi
if [ "$HARNESS" = "cursor" ]; then
warn "Verify the plugin in Cursor Settings > Rules."
fi
if [ "$HARNESS" = "gemini" ]; then
echo " Verify: gemini extensions list"
fi
if [ "$HARNESS" = "copilot" ]; then
echo " Verify: copilot plugin list"
fi
echo ""
if [ "$ALL_OK" = true ]; then
echo -e " ${GREEN}${BOLD}Restart your agent session to activate the skill.${NC}"
else
echo -e " ${YELLOW}Some components need attention — see warnings above.${NC}"
echo -e " Full setup guide: $REPO/SIGNET_SETUP.md"
fi
echo ""
}
# ─── Main ────────────────────────────────────────────────────────────────────
echo ""
echo -e "${BOLD}signet-first installer${NC}"
echo " https://github.com/ostico/signet-first"
echo ""
detect_harness
echo -e " Harness: ${BOLD}$HARNESS${NC}"
check_node && install_signet || true
install_skill || true
summary