astos 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
astos/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ """ASTOS — Abstract Syntax Tree Observer Service."""
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["__version__"]
astos/cli.py ADDED
@@ -0,0 +1,65 @@
1
+ """CLI do ASTOS: `astos` e `astos -a/--all`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import time
7
+ import webbrowser
8
+ from pathlib import Path
9
+
10
+ import click
11
+
12
+ from .generator import generate
13
+ from .parser import scan_repository
14
+
15
+
16
+ @click.command(context_settings={"help_option_names": ["-h", "--help"]})
17
+ @click.option("-a", "--all", "full", is_flag=True,
18
+ help="Força varredura completa do zero (ignora cache incremental).")
19
+ @click.option("--no-open", is_flag=True, default=False,
20
+ help="Gera os arquivos sem abrir o navegador.")
21
+ @click.option("--path", "root", default=".", type=click.Path(exists=True, file_okay=False),
22
+ help="Raiz do repositório a analisar (padrão: diretório atual).")
23
+ def main(full: bool, no_open: bool, root: str) -> None:
24
+ """ASTOS — Abstract Syntax Tree Observer Service (3D offline)."""
25
+ repo = Path(root).resolve()
26
+ astos_dir = repo / ".astos"
27
+ index = astos_dir / "index.html"
28
+ cache = astos_dir / "graph.json"
29
+
30
+ existed = astos_dir.exists()
31
+ astos_dir.mkdir(parents=True, exist_ok=True)
32
+
33
+ if full and cache.exists():
34
+ cache.unlink()
35
+ click.echo("ASTOS :: flag -a/--all detectada — cache descartado, varredura completa do zero.")
36
+
37
+ if not existed:
38
+ click.echo(f"ASTOS :: inicializando observer em {repo}")
39
+ else:
40
+ click.echo("ASTOS :: .astos/ encontrada — atualizando dados incrementalmente...")
41
+
42
+ t0 = time.time()
43
+ graph = scan_repository(repo)
44
+ graph["meta"]["generated_in_s"] = round(time.time() - t0, 2)
45
+ graph["meta"]["full_rescan"] = bool(full) or not existed
46
+
47
+ cache.write_text(json.dumps(graph, ensure_ascii=False, indent=1), encoding="utf-8")
48
+ generate(index, graph)
49
+
50
+ click.echo(
51
+ f"ASTOS :: {len(graph['nodes'])} nós · {len(graph['links'])} arestas "
52
+ f"-> {index} (100% offline, 3D imersivo)"
53
+ )
54
+ if not no_open:
55
+ try:
56
+ webbrowser.open(index.as_uri())
57
+ click.echo("ASTOS :: interface aberta no navegador padrão.")
58
+ except Exception as exc: # noqa: BLE001
59
+ click.echo(f"ASTOS :: não foi possível abrir o navegador: {exc}")
60
+ click.echo(f"ASTOS :: abra manualmente: {index}")
61
+ click.echo("ASTOS :: dica: 'astos -a' força rescan completo · [⛶ FULLSCREEN] + ESC no HUD.")
62
+
63
+
64
+ if __name__ == "__main__":
65
+ main()