mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the container entrypoint, so the misspelling does not degrade a feature -- it runs migrate --check against a database whose history this tree does not share and the container never starts. Both replacements are measured against the shipped tree rather than chosen: every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL -> INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12 determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_ tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of the bad rule and cannot collide with an upstream name. The rule is fixed for the next convergence, and the tree it already produced is repaired in the same commit -- the codemod is idempotent against its own output, so it cannot undo this itself.
48 lines
1.8 KiB
Bash
Executable File
48 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/../services/mcp"
|
|
|
|
RUNTIME="${MCP_RUNTIME:-hono}"
|
|
|
|
pnpm install --frozen-lockfile
|
|
|
|
# `.env` is the canonical local-dev env (see .env.example) - make sure it
|
|
# exists, otherwise OAuth metadata advertises cloud (`oauth.hanzo.ai`)
|
|
# and MCP clients try to auth against production instead of local Django.
|
|
if [ ! -f .env ]; then
|
|
cp .env.example .env
|
|
if [ -f .dev.vars ]; then
|
|
echo "NOTE: .dev.vars is no longer read - created .env from .env.example." >&2
|
|
echo "Move any custom values from .dev.vars into .env, then delete .dev.vars." >&2
|
|
fi
|
|
fi
|
|
|
|
# SITE_URL on devboxes points at the public per-workspace subdomain; rewrite
|
|
# the three Insights-pointing keys so MCP's OAuth metadata advertises a host
|
|
# browsers can actually reach. Runs every start (not just first creation) so
|
|
# .env stays in sync when the workspace subdomain changes.
|
|
loopback_re='^https?://(localhost|127\.0\.0\.1)([:/]|$)'
|
|
if [ -n "${SITE_URL:-}" ] && ! [[ "${SITE_URL}" =~ $loopback_re ]]; then
|
|
tmp=$(mktemp)
|
|
grep -Ev '^(INSIGHTS_API_BASE_URL|INSIGHTS_MCP_APPS_ANALYTICS_BASE_URL|INSIGHTS_ANALYTICS_HOST)=' .env > "$tmp" || true
|
|
mv "$tmp" .env
|
|
# Leading \n guards against the prior file missing a trailing newline.
|
|
printf '\n%s\n%s\n%s\n' \
|
|
"INSIGHTS_API_BASE_URL=${SITE_URL}" \
|
|
"INSIGHTS_MCP_APPS_ANALYTICS_BASE_URL=${SITE_URL}" \
|
|
"INSIGHTS_ANALYTICS_HOST=${SITE_URL}" \
|
|
>> .env
|
|
fi
|
|
|
|
if [ "$RUNTIME" = "hono" ]; then
|
|
export REDIS_URL="${REDIS_URL:-redis://localhost:6379}"
|
|
export PORT="${PORT:-8787}"
|
|
exec pnpm run dev
|
|
else
|
|
# Edge-proxy worker only (wrangler dev) - the MCP protocol itself is
|
|
# served by the Hono runtime. Wrangler reads `.env` when `.dev.vars`
|
|
# is absent.
|
|
exec pnpm run dev:proxy
|
|
fi
|