|
1 | | -"""graphify CLI - `graphify install` sets up the Claude Code skill.""" |
| 1 | +"""graphify CLI - `graphify install` sets up the Claude Code skill.""" |
2 | 2 | from __future__ import annotations |
3 | 3 | import json |
4 | 4 | import platform |
@@ -378,89 +378,8 @@ def main() -> None: |
378 | 378 | print("Run 'graphify --help' for usage.", file=sys.stderr) |
379 | 379 | sys.exit(1) |
380 | 380 |
|
381 | | - |
382 | | -def _run_rootly_viz_command(args: list[str]) -> None: |
383 | | - """Re-apply Rootly coloring + filters to an existing graph.json. |
384 | | -
|
385 | | - Usage: graphify rootly viz [--graph <path>] [--output <path>] |
386 | | -
|
387 | | - Defaults: |
388 | | - --graph graphify-rootly-data/graphify-out/graph.json |
389 | | - --output graphify-rootly-data/graphify-out/graph.html |
390 | | - """ |
391 | | - graph_path: Path | None = None |
392 | | - output_path: Path | None = None |
393 | | - |
394 | | - i = 0 |
395 | | - while i < len(args): |
396 | | - arg = args[i] |
397 | | - if arg in ("--graph",) and i + 1 < len(args): |
398 | | - graph_path = Path(args[i + 1]) |
399 | | - i += 2 |
400 | | - elif arg.startswith("--graph="): |
401 | | - graph_path = Path(arg.split("=", 1)[1]) |
402 | | - i += 1 |
403 | | - elif arg in ("--output",) and i + 1 < len(args): |
404 | | - output_path = Path(args[i + 1]) |
405 | | - i += 2 |
406 | | - elif arg.startswith("--output="): |
407 | | - output_path = Path(arg.split("=", 1)[1]) |
408 | | - i += 1 |
409 | | - elif arg in ("-h", "--help"): |
410 | | - print("Usage: graphify rootly viz [--graph <path>] [--output <path>]") |
411 | | - print() |
412 | | - print("Re-applies Rootly color coding and filters to an existing graph.json.") |
413 | | - print("Use this after running semantic extraction (e.g. via /graphify) to") |
414 | | - print("restore the Rootly-specific visualization with severity colors,") |
415 | | - print("team/service layers, and alert filtering.") |
416 | | - print() |
417 | | - print("Options:") |
418 | | - print(" --graph <path> path to graph.json (default: graphify-rootly-data/graphify-out/graph.json)") |
419 | | - print(" --output <path> path to write graph.html (default: same dir as graph.json)") |
420 | | - return |
421 | | - else: |
422 | | - print(f"error: unknown flag '{arg}'. Run 'graphify rootly viz --help'.", file=sys.stderr) |
423 | | - sys.exit(1) |
424 | | - |
425 | | - # Defaults |
426 | | - if graph_path is None: |
427 | | - graph_path = Path("graphify-rootly-data") / "graphify-out" / "graph.json" |
428 | | - if not graph_path.exists(): |
429 | | - print(f"error: graph.json not found at {graph_path}", file=sys.stderr) |
430 | | - print(" Run 'graphify rootly' first to generate it.", file=sys.stderr) |
431 | | - sys.exit(1) |
432 | | - |
433 | | - if output_path is None: |
434 | | - output_path = graph_path.parent / "graph.html" |
435 | | - |
436 | | - print(f" Loading graph from {graph_path}...") |
437 | | - from networkx.readwrite import json_graph as nx_json_graph |
438 | | - from graphify.cluster import cluster |
439 | | - from graphify.export import to_html |
440 | | - |
441 | | - # graph.json is written by to_json() using node_link_data (edges key = "links"), |
442 | | - # so we must load it with node_link_graph — not build_from_json which expects |
443 | | - # an extraction dict with an "edges" key and would silently drop all edges. |
444 | | - graph_data = json.loads(graph_path.read_text(encoding="utf-8")) |
445 | | - G = nx_json_graph.node_link_graph(graph_data, edges="links") |
446 | | - communities = cluster(G) |
447 | | - |
448 | | - print(f" Applying Rootly visualization...") |
449 | | - try: |
450 | | - to_html(G, communities, str(output_path), rootly=True) |
451 | | - print(f" Done -> {output_path.resolve()}") |
452 | | - except ValueError as exc: |
453 | | - print(f" error: {exc}", file=sys.stderr) |
454 | | - sys.exit(1) |
455 | | - |
456 | | - |
457 | 381 | def _run_rootly_command(args: list[str]) -> None: |
458 | 382 | """Parse flags for `graphify rootly` and delegate to rootly_flow.""" |
459 | | - # Subcommand dispatch |
460 | | - if args and args[0] == "viz": |
461 | | - _run_rootly_viz_command(args[1:]) |
462 | | - return |
463 | | - |
464 | 383 | api_key_override: str | None = None |
465 | 384 | days_override: int | None = None |
466 | 385 | mode_override: str | None = None |
@@ -519,10 +438,7 @@ def _run_rootly_command(args: list[str]) -> None: |
519 | 438 | data_override = arg.split("=", 1)[1] |
520 | 439 | i += 1 |
521 | 440 | elif arg in ("-h", "--help"): |
522 | | - print("Usage: graphify rootly [subcommand] [options]") |
523 | | - print() |
524 | | - print("Subcommands:") |
525 | | - print(" viz re-apply Rootly coloring to an existing graph.json") |
| 441 | + print("Usage: graphify rootly [options]") |
526 | 442 | print() |
527 | 443 | print("Options (fetch + build):") |
528 | 444 | print(" --days 7|30|90 date range (skips the TUI prompt)") |
@@ -551,3 +467,4 @@ def _run_rootly_command(args: list[str]) -> None: |
551 | 467 |
|
552 | 468 | if __name__ == "__main__": |
553 | 469 | main() |
| 470 | + |
0 commit comments