refactor: opencode

This commit is contained in:
Apunkt 2026-05-12 16:45:15 +02:00
parent 09c5b30f15
commit 91d67b2e12
No known key found for this signature in database
12 changed files with 1843 additions and 77 deletions

View file

@ -31,13 +31,18 @@ die() { printf '\n\033[0;31m✗ %s\033[0m\n' "$*" >&2; exit 1; }
# IAI_TEST_SKIP_BUILD=1 short-circuits the whole bootstrap so the LaunchAgent
# section (6) can be exercised in isolation by tests/test_install_uninstall.py
# (Plan 07.1-03 Task 3) without spending ~30s on venv + npm.
#
# VENV_BASE: all venvs live in ~/.venv/<project-name> for central backup.
# ---------------------------------------------------------------------------
VENV_BASE="${HOME}/.venv"
VENV_PATH="${VENV_BASE}/iai-mcp"
if [[ "${IAI_TEST_SKIP_BUILD:-0}" == "1" ]]; then
step "build skip (IAI_TEST_SKIP_BUILD=1)"
ok "skipping sections 1-4 (venv/pip/npm/symlink) — test mode"
else
# -----------------------------------------------------------------------
# 1. venv
# 1. venv (central location: ~/.venv/iai-mcp)
# -----------------------------------------------------------------------
step "python venv"
# iai-mcp requires Python 3.11 or 3.12 (torch + lancedb on 3.13/3.14
@ -60,19 +65,19 @@ else
fi
[ -n "$PY" ] || die "Python 3.11 or 3.12 not found. macOS: brew install python@3.12 | Linux: apt install python3.12 (or use pyenv)"
ok "using $PY ($($PY --version))"
if [ ! -d .venv ]; then
"$PY" -m venv .venv
ok ".venv created"
if [ ! -d "${VENV_PATH}" ]; then
"$PY" -m venv "${VENV_PATH}"
ok "venv created at ${VENV_PATH}"
else
ok ".venv already exists"
ok "venv already exists at ${VENV_PATH}"
fi
# -----------------------------------------------------------------------
# 2. editable install
# -----------------------------------------------------------------------
step "editable install (pip -e .)"
.venv/bin/pip install --quiet --upgrade pip
.venv/bin/pip install --quiet -e .
"${VENV_PATH}"/bin/pip install --quiet --upgrade pip
"${VENV_PATH}"/bin/pip install --quiet -e .
ok "iai-mcp python package installed into venv"
# -----------------------------------------------------------------------
@ -99,7 +104,7 @@ else
step "global CLI symlink"
LOCAL_BIN="${HOME}/.local/bin"
LINK_PATH="${LOCAL_BIN}/iai-mcp"
TARGET="${REPO_ROOT}/.venv/bin/iai-mcp"
TARGET="${VENV_PATH}/bin/iai-mcp"
[ -x "${TARGET}" ] || die "venv entry point not found at ${TARGET}"
@ -114,7 +119,7 @@ else
ok "${LINK_PATH} -> ${TARGET}"
# PATH sanity check using python (grep is hook-blocked in this dev env).
PATH_HAS_LOCAL_BIN="$(.venv/bin/python - <<PY
PATH_HAS_LOCAL_BIN="$("${VENV_PATH}"/bin/python - <<PY
import os
print("1" if "${LOCAL_BIN}" in os.environ.get("PATH", "").split(":") else "0")
PY
@ -163,7 +168,7 @@ if [[ "$(uname)" != "Darwin" ]]; then
elif [[ "${DRY_RUN:-0}" == "1" ]]; then
ok "DRY_RUN=1 — skipping launchctl calls (test mode)"
else
PYTHON_PATH="${REPO_ROOT}/.venv/bin/python"
PYTHON_PATH="${VENV_PATH}/bin/python"
if [ ! -x "${PYTHON_PATH}" ]; then
warn "venv python not found at ${PYTHON_PATH} — falling back to $(command -v python3)"
PYTHON_PATH="$(command -v python3)"