"""Transport for the `wiki` domain — args in, delegate, format out. Two verbs, deliberately not four. `wiki_sync` also holds `generate_wiki()` (systems.db → system pages) and `import_from_wiki()` (pages → systems.db), and neither is exposed: re-rendering today would delete ~10,700 lines of the committed pages (see wiki_sync's docstring, T-1290). A verb is a promise that running it is safe, and that one would not be. They come back when the renderer reproduces the committed pages byte-for-byte. """ from __future__ import annotations from pathlib import Path import typer from tooling.core import cli, console from tooling.core.command import command app = cli.domain("wiki", "The wiki seed — fill rates and the GTTR hook.") @app.callback() def _domain() -> None: """Keeps `wiki` a group (Typer collapses a single-command app).""" @app.command("stats") @command def stats() -> None: """Fill rates of the structured star-system columns in systems.db.""" from tooling.domains.wiki import wiki_sync wiki_sync.stats() @app.command("gttr-hook") @command def gttr_hook( db: Path = typer.Option(None, "--db", help="systems.db to write (default: server/data/systems.db)."), system: str = typer.Option(None, "--system", help="Only this system_id, e.g. 'GJ 71'."), max_words: int = typer.Option(45, "--max-words", help="Soft cap on hook length."), dry_run: bool = typer.Option(False, "--dry-run", help="Extract, write nothing."), verbose: bool = typer.Option(False, "--verbose", help="Print every extracted hook."), ) -> None: """Extract each system's GTTR opening line into star_systems.gttr_hook. Reads wiki/star-systems//gttr.md, takes the first **NAME** paragraph, collapses and caps it. Re-run after editing any gttr.md. """ from tooling.domains.wiki import gttr_hook as service counts = service.run( db or service.DB_PATH, system=system, max_words=max_words, dry_run=dry_run, verbose=verbose, ) written = "extracted, nothing written (dry run)" if dry_run else "written" console.verdict( f"gttr-hook: {counts['updated']} {written}, " f"{counts['missing']} missing gttr.md, {counts['unmatched']} unmatched" )