mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The rename runs on the way in and nothing checked it afterwards, so paths and content drifted apart in three places, and each one broke something quietly. The script language had three names at once. Files on disk carried `.iql`/`.iqle`, the source matchers said `.script`, and the bytecode matchers said `.hoge`, so the test harness globbed zero files and the STL compiler regenerated an empty table. It is `script` now, in one place: `.script` source, `.scriptc` bytecode, `bin/script` to run one and `bin/scriptc` to compile one. 190 TypeScript specifiers named files that had been renamed away, which is the whole CDP consumer graph -- the event worker, not the web boot. `--check` only ever read Python imports; it reads both module systems now, and repoints both. `-hog-` became `-mascot-` in paths while content said `script`, so the code review product's skill directories stopped matching the prefix that discovers them and it ran with no perspectives at all. PATH_REGEX is CONTENT_REGEX -- the same list, not a copy -- so a rule can no longer land in one and miss the other, and the four disagreeing `hog` path rules collapse into the one word rule content already had. `HOGLI_*` becomes `INSIGHTSCLI_*` at every reader and writer, with no alias: an env var read under two names is two names. The seven casings of `hogql` and five of `hogvm` collapse into one rule per prefix casing, which leaves the suffix alone because `QL` is SQL's and `VM` is a virtual machine's. `--check` now refuses every retired spelling, in content and in paths, and draws the line the rules draw: `insights_hogfunction` is a Postgres table so it is left alone, and a migration filename is its identity in `django_migrations` so it is frozen rather than failed. Third-party names we cannot rename are reported as pending, never exempted.
49 lines
1.8 KiB
Bash
Executable File
49 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Wrapper that ensures venv is active before running insightscli.
|
|
# Needed for git hooks / lint-staged which may run outside an activated shell.
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
PYTHON_CMD="python"
|
|
|
|
if [ -z "${VIRTUAL_ENV:-}" ]; then
|
|
# Only local venvs are considered here. Standalone insightscli must never adopt
|
|
# the main clone's venv: commands like `uv sync --active` would rewrite it
|
|
# against this worktree. Hooks that need borrowing export VIRTUAL_ENV via
|
|
# bin/helpers/worktree-borrow.sh before insightscli runs.
|
|
FOUND_VENV=""
|
|
if [ -f "$REPO_ROOT/bin/helpers/worktree-borrow.sh" ]; then
|
|
source "$REPO_ROOT/bin/helpers/worktree-borrow.sh"
|
|
FOUND_VENV="$(insights_find_venv "$REPO_ROOT")"
|
|
fi
|
|
|
|
if [ -n "$FOUND_VENV" ]; then
|
|
source "$FOUND_VENV/bin/activate"
|
|
PYTHON_CMD="$FOUND_VENV/bin/python"
|
|
fi
|
|
else
|
|
PYTHON_CMD="$VIRTUAL_ENV/bin/python"
|
|
fi
|
|
|
|
# Migration aid: after the common/insightscli/ -> tools/insightscli/ + tools/insightscli-commands/
|
|
# restructure, users with stale venvs see `ModuleNotFoundError: insightscli`. Catch it
|
|
# early and point at `uv sync`. Safe to delete once everyone has re-activated.
|
|
INSIGHTSCLI_IMPORT_ERR="$("$PYTHON_CMD" -c "import insightscli" 2>&1)" || true
|
|
if [[ -n "$INSIGHTSCLI_IMPORT_ERR" && "$INSIGHTSCLI_IMPORT_ERR" == *"No module named 'insightscli'"* ]]; then
|
|
cat >&2 <<'EOF'
|
|
error: the `insightscli` package is not importable from your active venv.
|
|
|
|
It recently moved to tools/insightscli/ (framework) + tools/insightscli-commands/ (commands).
|
|
Your venv has stale paths — re-sync it:
|
|
|
|
flox activate # recommended (flox auto-runs uv sync)
|
|
uv sync --active # or sync directly
|
|
|
|
Then rerun your insightscli command.
|
|
EOF
|
|
exit 127
|
|
fi
|
|
|
|
exec "$PYTHON_CMD" -m insightscli "$@"
|