1010# 4. Wires Claude Code (hooks + MCP + router) if available
1111# 5. Runs `dhee onboard` — provider picker, API key paste,
1212# and optional git repo linking
13+ # 6. Shows `dhee ui` so the developer can inspect the local brain
1314#
1415# Non-interactive: pass DHEE_PROVIDER=openai DHEE_API_KEY=sk-... to skip
15- # the prompts entirely (CI-friendly).
16+ # the prompts entirely (CI-friendly). Set DHEE_INIT_REPO=/path/to/repo to
17+ # wire a git repo non-interactively after install. Set
18+ # DHEE_INIT_SKIP_INGEST=1 for CI smoke tests that should link the repo without
19+ # calling an embedding provider.
1620#
1721# Requires: Python 3.9+ (Claude Code CLI optional)
1822set -e
@@ -21,7 +25,9 @@ DHEE_HOME="$HOME/.dhee"
2125VENV_DIR=" $DHEE_HOME /.venv"
2226BIN_DIR=" $HOME /.local/bin"
2327MIN_PYTHON=" 3.9"
24- PACKAGE=" dhee>=6.1.0"
28+ DEFAULT_PACKAGE=" dhee>=6.2.0"
29+ PACKAGE=" ${DHEE_INSTALL_PACKAGE:- $DEFAULT_PACKAGE } "
30+ FALLBACK_PACKAGE=" ${DHEE_FALLBACK_PACKAGE:- git+https:// github.com/ Sankhya-AI/ Dhee.git@ main} "
2531
2632# --- Colors ---
2733if [ -t 1 ]; then
@@ -35,6 +41,19 @@ warn() { printf "${YELLOW}!${RESET} %s\n" "$1"; }
3541error () { printf " ${RED} x${RESET} %s\n" " $1 " >&2 ; exit 1; }
3642done_ () { printf " ${GREEN} ✓${RESET} %s\n" " $1 " ; }
3743
44+ pip_install_package () {
45+ " $VENV_DIR /bin/pip" install --upgrade --force-reinstall --no-cache-dir " $1 " -q
46+ }
47+
48+ verify_handoff_bus () {
49+ " $VENV_DIR /bin/python" - << 'PY ' >/dev/null 2>&1
50+ from dhee.core.kernel import _get_bus
51+
52+ bus = _get_bus()
53+ bus.close()
54+ PY
55+ }
56+
3857# --- OS check ---
3958OS=" $( uname -s) "
4059case " $OS " in
7392
7493# --- Install package ---
7594" $VENV_DIR /bin/pip" install --upgrade pip -q 2> /dev/null
76- " $VENV_DIR /bin/pip" install --upgrade --no-cache-dir " $PACKAGE " -q
77- done_ " Installed dhee"
95+ if pip_install_package " $PACKAGE " ; then
96+ done_ " Installed dhee"
97+ else
98+ if [ -n " ${DHEE_INSTALL_PACKAGE:- } " ]; then
99+ error " Could not install Dhee from DHEE_INSTALL_PACKAGE=$DHEE_INSTALL_PACKAGE "
100+ fi
101+ warn " PyPI install failed — trying the current GitHub release path"
102+ command -v git > /dev/null 2>&1 || error " Git is required for the fallback installer. Install git, then rerun the command."
103+ pip_install_package " $FALLBACK_PACKAGE " || error " Could not install Dhee from PyPI or GitHub fallback"
104+ done_ " Installed dhee from GitHub fallback"
105+ fi
78106
79107# --- Verify bundled handoff bus ---
80- if " $VENV_DIR /bin/python" - << 'PY ' >/dev/null 2>&1
81- from dhee.core.kernel import _get_bus
82-
83- bus = _get_bus()
84- bus.close()
85- PY
86- then
108+ if verify_handoff_bus; then
87109 done_ " Cross-agent handoff bus ready"
88110else
89- error " Dhee installed, but the bundled handoff bus failed to import. Please rerun the installer or report this build."
111+ if [ -n " ${DHEE_INSTALL_PACKAGE:- } " ]; then
112+ error " Dhee installed, but the bundled handoff bus failed to import from DHEE_INSTALL_PACKAGE=$DHEE_INSTALL_PACKAGE "
113+ fi
114+ warn " PyPI package failed handoff-bus verification — repairing from GitHub"
115+ command -v git > /dev/null 2>&1 || error " Git is required for the repair installer. Install git, then rerun the command."
116+ pip_install_package " $FALLBACK_PACKAGE " || error " Dhee installed, but GitHub repair failed. Please report this installer output."
117+ verify_handoff_bus || error " Dhee installed, but the bundled handoff bus still failed to import after repair."
118+ done_ " Cross-agent handoff bus ready"
90119fi
91120
92121# --- Symlink binaries ---
@@ -170,9 +199,23 @@ else
170199 fi
171200fi
172201
202+ if [ -n " ${DHEE_INIT_REPO:- } " ]; then
203+ info " Wiring git repo: ${DHEE_INIT_REPO} "
204+ INIT_FLAGS=" "
205+ [ " ${DHEE_INIT_SKIP_INGEST:- } " = " 1" ] && INIT_FLAGS=" $INIT_FLAGS --skip-ingest"
206+ [ " ${DHEE_INIT_SKIP_FIRST_LIGHT:- } " = " 1" ] && INIT_FLAGS=" $INIT_FLAGS --skip-first-light"
207+ # shellcheck disable=SC2086 # intentional flag splitting for the small managed flag set above.
208+ if " $VENV_DIR /bin/dhee" init " $DHEE_INIT_REPO " $INIT_FLAGS > /dev/null 2>&1 ; then
209+ done_ " Repo wired into Dhee"
210+ else
211+ warn " Repo wire-up failed — run 'cd ${DHEE_INIT_REPO} && dhee init' manually for details"
212+ fi
213+ fi
214+
173215# --- Done ---
174216printf " \n${BOLD}${GREEN} Dhee is ready.${RESET} \n"
175217printf " Wire up a repo: ${BOLD} cd /path/to/repo && dhee init${RESET} \n"
218+ printf " Open the UI: ${BOLD} dhee ui${RESET} ${DIM} (local command center, folders canvas, firewall)${RESET} \n"
176219printf " Update later: ${BOLD} dhee update${RESET} \n\n"
177220printf " ${DIM} Status: dhee status (savings + brain health)${RESET} \n"
178221printf " ${DIM} Recall: dhee recall \" <query>\" (your personal cross-repo brain)${RESET} \n"
0 commit comments