Navegador

navegador / hooks / bootstrap.sh
Blame History Raw 117 lines
1
#!/usr/bin/env bash
2
# navegador bootstrap — install, initialise, and ingest a project
3
#
4
# Usage:
5
# curl -fsSL https://raw.githubusercontent.com/ConflictHQ/navegador/main/hooks/bootstrap.sh | bash
6
# # or locally:
7
# bash hooks/bootstrap.sh [--repo owner/repo] [--wiki] [--agent claude|gemini|openai]
8
9
set -euo pipefail
10
11
NAV_DB="${NAVEGADOR_DB:-.navegador/graph.db}"
12
REPO_PATH="${REPO_PATH:-.}"
13
GITHUB_REPO="${GITHUB_REPO:-}"
14
INSTALL_AGENT="${INSTALL_AGENT:-}"
15
INGEST_WIKI=false
16
17
# ── Parse args ────────────────────────────────────────────────────────────────
18
while [[ $# -gt 0 ]]; do
19
case $1 in
20
--repo) GITHUB_REPO="$2"; shift 2 ;;
21
--wiki) INGEST_WIKI=true; shift ;;
22
--agent) INSTALL_AGENT="$2"; shift 2 ;;
23
--db) NAV_DB="$2"; shift 2 ;;
24
*) echo "Unknown option: $1"; exit 1 ;;
25
esac
26
done
27
28
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
29
echo " Navegador bootstrap"
30
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
31
32
# ── Install ───────────────────────────────────────────────────────────────────
33
if ! command -v navegador &>/dev/null; then
34
echo "→ Installing navegador..."
35
pip install "navegador[sqlite]" --quiet
36
else
37
echo "→ navegador $(navegador --version 2>&1 | head -1) already installed"
38
fi
39
40
# ── Initialise DB directory ───────────────────────────────────────────────────
41
mkdir -p "$(dirname "$NAV_DB")"
42
echo "→ Graph DB: $NAV_DB"
43
44
# ── Ingest code ───────────────────────────────────────────────────────────────
45
echo "→ Ingesting code from $REPO_PATH ..."
46
navegador --db "$NAV_DB" ingest "$REPO_PATH" --json | \
47
python3 -c "import json,sys; d=json.load(sys.stdin); print(f\" files={d['files']} functions={d['functions']} classes={d['classes']} edges={d['edges']}\")"
48
49
# ── Ingest wiki ───────────────────────────────────────────────────────────────
50
if [[ "$INGEST_WIKI" == "true" && -n "$GITHUB_REPO" ]]; then
51
echo "→ Ingesting GitHub wiki for $GITHUB_REPO ..."
52
navegador --db "$NAV_DB" wiki ingest --repo "$GITHUB_REPO" ${GITHUB_TOKEN:+--token "$GITHUB_TOKEN"} || true
53
fi
54
55
# ── Install agent hook ────────────────────────────────────────────────────────
56
HOOK_SRC_BASE="https://raw.githubusercontent.com/ConflictHQ/navegador/main/hooks"
57
58
install_claude_hook() {
59
mkdir -p .claude/hooks
60
curl -fsSL "$HOOK_SRC_BASE/claude-hook.py" -o .claude/hooks/navegador.py
61
chmod +x .claude/hooks/navegador.py
62
63
SETTINGS=".claude/settings.json"
64
if [[ ! -f "$SETTINGS" ]]; then
65
cat > "$SETTINGS" <<'JSON'
66
{
67
"hooks": {
68
"PostToolUse": [
69
{
70
"matcher": "Edit|Write",
71
"hooks": [{ "type": "command", "command": "python3 .claude/hooks/navegador.py" }]
72
}
73
]
74
}
75
}
76
JSON
77
echo " Created $SETTINGS"
78
else
79
echo " $SETTINGS exists — add the hook manually (see .claude/hooks/navegador.py)"
80
fi
81
}
82
83
install_gemini_hook() {
84
mkdir -p .gemini/hooks
85
curl -fsSL "$HOOK_SRC_BASE/gemini-hook.py" -o .gemini/hooks/navegador.py
86
chmod +x .gemini/hooks/navegador.py
87
echo " Add to GEMINI.md: python3 .gemini/hooks/navegador.py <tool> <file>"
88
}
89
90
install_openai_hook() {
91
curl -fsSL "$HOOK_SRC_BASE/openai-hook.py" -o navegador-openai.py
92
chmod +x navegador-openai.py
93
echo " Register tool schemas from hooks/openai-tools.json with your assistant"
94
}
95
96
case "$INSTALL_AGENT" in
97
claude) echo "→ Installing Claude Code hook..."; install_claude_hook ;;
98
gemini) echo "→ Installing Gemini CLI hook..."; install_gemini_hook ;;
99
openai) echo "→ Installing OpenAI hook..."; install_openai_hook ;;
100
"") ;;
101
*) echo "Unknown agent: $INSTALL_AGENT (use claude|gemini|openai)" ;;
102
esac
103
104
# ── Stats ─────────────────────────────────────────────────────────────────────
105
echo ""
106
echo "→ Graph stats:"
107
navegador --db "$NAV_DB" stats 2>/dev/null || true
108
109
echo ""
110
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
111
echo " Done. Quick start:"
112
echo " navegador search \"your query\""
113
echo " navegador explain MyClass"
114
echo " navegador stats"
115
echo " navegador add concept \"Payment\" --domain billing"
116
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
117

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button