mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
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.
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
"""Shared path constants, structure loader, and helpers used by lint + maturity."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
# product/ -> insightscli_commands/ -> insightscli-commands/ -> tools/ -> repo root
|
|
REPO_ROOT = Path(__file__).parent.parent.parent.parent.parent
|
|
STRUCTURE_FILE = Path(__file__).parent.parent / "product_structure.yaml"
|
|
PRODUCTS_DIR = REPO_ROOT / "products"
|
|
TACH_TOML = REPO_ROOT / "tach.toml"
|
|
FRONTEND_PACKAGE_JSON = REPO_ROOT / "frontend" / "package.json"
|
|
DJANGO_SETTINGS = REPO_ROOT / "insights" / "settings" / "web.py"
|
|
DB_ROUTING_YAML = PRODUCTS_DIR / "db_routing.yaml"
|
|
|
|
|
|
def load_structure() -> dict:
|
|
return yaml.safe_load(STRUCTURE_FILE.read_text())
|
|
|
|
|
|
def get_tach_block(module_path: str) -> str:
|
|
"""Extract the tach.toml block for a given module path."""
|
|
if not TACH_TOML.exists():
|
|
return ""
|
|
content = TACH_TOML.read_text()
|
|
marker = f'path = "{module_path}"'
|
|
idx = content.find(marker)
|
|
if idx == -1:
|
|
return ""
|
|
block_start = content.rfind("[[modules]]", 0, idx)
|
|
if block_start == -1:
|
|
block_start = idx
|
|
next_block = content.find("[[modules]]", idx + len(marker))
|
|
if next_block == -1:
|
|
return content[block_start:]
|
|
return content[block_start:next_block]
|
|
|
|
|
|
def find_views_path(backend_dir: Path) -> tuple[Path | None, bool]:
|
|
"""Find the views file/dir and whether it's at the correct location.
|
|
|
|
Returns (path, is_correct_location). Path is None if no views found.
|
|
"""
|
|
pres_views = backend_dir / "presentation" / "views.py"
|
|
if pres_views.exists():
|
|
return pres_views, True
|
|
|
|
from .ast_helpers import count_viewset_files
|
|
|
|
# `insightscli product:isolate:move` relocates multi-viewset products into a
|
|
# `presentation/views/` package (one module per resource) rather than a single
|
|
# `presentation/views.py`. Both satisfy the tach `presentation\.views.*` interface,
|
|
# so treat the package form as a correct location too.
|
|
pres_views_pkg = backend_dir / "presentation" / "views"
|
|
if pres_views_pkg.is_dir() and count_viewset_files(pres_views_pkg) > 0:
|
|
return pres_views_pkg, True
|
|
|
|
api_dir = backend_dir / "api"
|
|
if api_dir.is_dir() and count_viewset_files(api_dir) > 0:
|
|
return api_dir, False
|
|
|
|
for candidate in (
|
|
backend_dir / "api" / "views.py",
|
|
backend_dir / "api.py",
|
|
backend_dir / "views.py",
|
|
):
|
|
if candidate.exists():
|
|
return candidate, False
|
|
|
|
return None, False
|