From ec4c87c86e6b42d8c8148980b0e8607ba6d0a88b Mon Sep 17 00:00:00 2001 From: cinos Date: Sun, 17 May 2026 19:32:55 +0900 Subject: [PATCH] fix(export): accept edges-only graph JSON for wiki export (#909) Co-authored-by: Hermes Agent --- graphify/__main__.py | 2 ++ tests/test_cli_export.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/graphify/__main__.py b/graphify/__main__.py index c98277e..4fff852 100644 --- a/graphify/__main__.py +++ b/graphify/__main__.py @@ -2218,6 +2218,8 @@ def main() -> None: from graphify.build import build_from_json as _bfj _raw = json.loads(graph_path.read_text(encoding="utf-8")) + if "links" not in _raw and "edges" in _raw: + _raw = dict(_raw, links=_raw["edges"]) try: G = _jg.node_link_graph(_raw, edges="links") except TypeError: diff --git a/tests/test_cli_export.py b/tests/test_cli_export.py index 3125ab8..07412f1 100644 --- a/tests/test_cli_export.py +++ b/tests/test_cli_export.py @@ -115,6 +115,19 @@ def test_export_wiki_creates_articles(tmp_path): assert (wiki / "index.md").exists() +def test_export_wiki_accepts_edges_only_graph_json(tmp_path): + out = _make_graph(tmp_path) + graph_path = out / "graph.json" + data = json.loads(graph_path.read_text()) + data["edges"] = data.pop("links") + graph_path.write_text(json.dumps(data)) + + r = _run(["export", "wiki"], tmp_path) + + assert r.returncode == 0, r.stderr + assert (out / "wiki" / "index.md").exists() + + # ── graphify export graphml ────────────────────────────────────────────────── def test_export_graphml_creates_file(tmp_path):