Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

98 lines
3.6 KiB
Python

"""Unified build command with smart change detection."""
from __future__ import annotations
import subprocess
from collections.abc import Iterable
import click
from insightscli.manifest import REPO_ROOT
from insightscli_commands.change_detection import changed_files, matches_globs
# command -> file globs that should trigger it
TRIGGERS: dict[str, tuple[str, ...]] = {
"build:schema": (
"frontend/src/queries/schema/*",
"insights/schema_migrations/*",
),
# Python-only globs on the api/presentation trees: OpenAPI is generated from
# code, so metadata files that live alongside it (owners.yaml) must not
# trigger a regen.
"build:openapi": (
"insights/api/*.py",
"insights/scopes.py",
"ee/api/*.py",
"products/*/backend/api/*.py",
"products/*/backend/presentation/*.py",
"products/*/backend/widget_specs/*.py",
"products/*/mcp/*.yaml",
"products/*/mcp/prompts/*",
"services/mcp/definitions/*",
"services/mcp/schema/tool-definitions.json",
"services/mcp/src/templates/sections/*",
# The generator formats its output, so lint/format scope decides the bytes
# that land in the generated trees — a config-only edit silently invalidates them.
".oxfmtrc.json",
".oxlintrc.json",
),
"build:grammar": ("insights/insightsql/grammar/*",),
"build:taxonomy-json": ("insights/taxonomy/*",),
"build:products": ("products/*/frontend/*",),
"build:skills": ("products/*/skills/*",),
"build:schema-mcp": ("services/mcp/src/*",),
}
def _match_commands(changed: Iterable[str]) -> list[str]:
"""Return build commands whose trigger globs match any changed file."""
return [cmd for cmd, globs in TRIGGERS.items() if any(matches_globs(p, globs) for p in changed)]
@click.command(name="build", help="Run code generation pipelines (smart change detection by default)")
@click.option("--force", is_flag=True, help="Rebuild all pipelines unconditionally")
@click.option("--dry-run", is_flag=True, help="Show what would be rebuilt without running")
@click.option("--list", "list_all", is_flag=True, help="List all available pipelines")
def build(force: bool, dry_run: bool, list_all: bool) -> None:
"""Unified build command with smart change detection."""
if list_all:
click.echo("Available build pipelines:\n")
for cmd, globs in TRIGGERS.items():
click.echo(f" {cmd}")
for glob in globs:
click.echo(f" {glob}")
return
if force:
commands = list(TRIGGERS)
else:
changed = changed_files()
if not changed:
click.echo("Nothing to rebuild -- no changes detected.")
return
commands = _match_commands(changed)
if not commands:
click.echo(f"Nothing to rebuild -- {len(changed)} changed file(s) don't match any build trigger.")
return
if dry_run:
click.echo(f"Would build {len(commands)} pipeline(s):")
for cmd in commands:
click.echo(f" {cmd}")
return
bin_insightscli = str(REPO_ROOT / "bin" / "insightscli")
failed: list[str] = []
for cmd in commands:
click.secho(f"--- {cmd} ---", fg="blue", bold=True)
result = subprocess.run([bin_insightscli, cmd], cwd=REPO_ROOT)
if result.returncode != 0:
failed.append(cmd)
click.echo()
if failed:
click.secho(f"Build completed with failures: {', '.join(failed)}", fg="red")
raise SystemExit(1)
else:
click.secho("All pipelines completed successfully.", fg="green")