pycode-kg 0.16.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.
Files changed (63) hide show
  1. pycode_kg/.DS_Store +0 -0
  2. pycode_kg/__init__.py +91 -0
  3. pycode_kg/__main__.py +11 -0
  4. pycode_kg/analysis/__init__.py +15 -0
  5. pycode_kg/analysis/bridge.py +108 -0
  6. pycode_kg/analysis/centrality.py +412 -0
  7. pycode_kg/analysis/framework_detector.py +103 -0
  8. pycode_kg/analysis/hybrid_rank.py +53 -0
  9. pycode_kg/app.py +1335 -0
  10. pycode_kg/architecture.py +624 -0
  11. pycode_kg/build_pycodekg_lancedb.py +15 -0
  12. pycode_kg/build_pycodekg_sqlite.py +15 -0
  13. pycode_kg/cli/__init__.py +29 -0
  14. pycode_kg/cli/cmd_analyze.py +96 -0
  15. pycode_kg/cli/cmd_architecture.py +150 -0
  16. pycode_kg/cli/cmd_bridges.py +26 -0
  17. pycode_kg/cli/cmd_build.py +154 -0
  18. pycode_kg/cli/cmd_build_full.py +242 -0
  19. pycode_kg/cli/cmd_centrality.py +131 -0
  20. pycode_kg/cli/cmd_explain.py +180 -0
  21. pycode_kg/cli/cmd_framework_nodes.py +18 -0
  22. pycode_kg/cli/cmd_hooks.py +137 -0
  23. pycode_kg/cli/cmd_init.py +312 -0
  24. pycode_kg/cli/cmd_mcp.py +71 -0
  25. pycode_kg/cli/cmd_model.py +53 -0
  26. pycode_kg/cli/cmd_query.py +211 -0
  27. pycode_kg/cli/cmd_snapshot.py +421 -0
  28. pycode_kg/cli/cmd_viz.py +180 -0
  29. pycode_kg/cli/main.py +23 -0
  30. pycode_kg/cli/options.py +63 -0
  31. pycode_kg/config.py +78 -0
  32. pycode_kg/graph.py +125 -0
  33. pycode_kg/index.py +542 -0
  34. pycode_kg/kg.py +220 -0
  35. pycode_kg/layout3d.py +470 -0
  36. pycode_kg/mcp/bridge_tools.py +19 -0
  37. pycode_kg/mcp/framework_tools.py +18 -0
  38. pycode_kg/mcp_server.py +1965 -0
  39. pycode_kg/module/__init__.py +83 -0
  40. pycode_kg/module/base.py +720 -0
  41. pycode_kg/module/extractor.py +276 -0
  42. pycode_kg/module/types.py +532 -0
  43. pycode_kg/pycodekg.py +543 -0
  44. pycode_kg/pycodekg_query.py +1 -0
  45. pycode_kg/pycodekg_snippet_packer.py +1 -0
  46. pycode_kg/pycodekg_thorough_analysis.py +2751 -0
  47. pycode_kg/pycodekg_viz.py +1 -0
  48. pycode_kg/pycodekg_viz3d.py +1 -0
  49. pycode_kg/ranking/__init__.py +1 -0
  50. pycode_kg/ranking/cli_rank.py +92 -0
  51. pycode_kg/ranking/coderank.py +555 -0
  52. pycode_kg/snapshots.py +612 -0
  53. pycode_kg/sql/004_add_centrality_table.sql +12 -0
  54. pycode_kg/store.py +766 -0
  55. pycode_kg/utils.py +39 -0
  56. pycode_kg/visitor.py +413 -0
  57. pycode_kg/viz3d.py +1353 -0
  58. pycode_kg/viz3d_timeline.py +364 -0
  59. pycode_kg-0.16.0.dist-info/METADATA +305 -0
  60. pycode_kg-0.16.0.dist-info/RECORD +63 -0
  61. pycode_kg-0.16.0.dist-info/WHEEL +4 -0
  62. pycode_kg-0.16.0.dist-info/entry_points.txt +19 -0
  63. pycode_kg-0.16.0.dist-info/licenses/LICENSE +94 -0
@@ -0,0 +1,83 @@
1
+ """
2
+ pycode_kg.module — KGModule SDK for building production-grade knowledge graph modules.
3
+
4
+ This subpackage provides the abstract base class and supporting types that
5
+ enable any knowledge domain (Python code, TypeScript, genomics, legal text, …)
6
+ to be expressed as a full-featured knowledge graph with:
7
+
8
+ - SQLite graph storage (:class:`~pycode_kg.store.GraphStore`)
9
+ - LanceDB vector index (:class:`~pycode_kg.index.SemanticIndex`)
10
+ - Hybrid semantic + structural query (:meth:`~KGModule.query`)
11
+ - Source-grounded snippet packing (:meth:`~KGModule.pack`)
12
+ - Snapshot management (:class:`~pycode_kg.snapshots.SnapshotManager`)
13
+
14
+ Usage — building a new domain KG::
15
+
16
+ from pycode_kg.module import KGModule, KGExtractor, NodeSpec, EdgeSpec
17
+
18
+ class MyExtractor(KGExtractor):
19
+ def node_kinds(self): return ["entity", "relation"]
20
+ def edge_kinds(self): return ["LINKED_TO"]
21
+ def extract(self):
22
+ for item in parse_my_domain(self.repo_path):
23
+ yield NodeSpec(node_id=item.id, kind="entity", ...)
24
+
25
+ class MyKG(KGModule):
26
+ def make_extractor(self): return MyExtractor(self.repo_root)
27
+ def kind(self): return "meta"
28
+ def analyze(self): return "# My KG Analysis\\n..."
29
+
30
+ kg = MyKG("/path/to/data")
31
+ kg.build(wipe=True)
32
+ result = kg.query("some concept")
33
+
34
+ The existing Python-backed :class:`~pycode_kg.kg.PyCodeKG` is a concrete
35
+ implementation of :class:`KGModule` using :class:`PyCodeKGExtractor`.
36
+ """
37
+
38
+ from pycode_kg.module.base import KGModule
39
+ from pycode_kg.module.extractor import EdgeSpec, KGExtractor, NodeSpec, PyCodeKGExtractor
40
+ from pycode_kg.module.types import (
41
+ BuildStats,
42
+ QueryResult,
43
+ Snippet,
44
+ SnippetPack,
45
+ compute_span,
46
+ docstring_signal,
47
+ lexical_overlap_score,
48
+ make_module_summary,
49
+ make_snippet,
50
+ normalize_query_text,
51
+ query_tokens,
52
+ read_lines,
53
+ safe_join,
54
+ semantic_score_from_distance,
55
+ spans_overlap,
56
+ )
57
+
58
+ __all__ = [
59
+ # Core abstractions
60
+ "KGModule",
61
+ "KGExtractor",
62
+ "PyCodeKGExtractor",
63
+ # Intermediate spec types
64
+ "NodeSpec",
65
+ "EdgeSpec",
66
+ # Result types
67
+ "BuildStats",
68
+ "QueryResult",
69
+ "Snippet",
70
+ "SnippetPack",
71
+ # Utilities (exported for subclass use)
72
+ "semantic_score_from_distance",
73
+ "query_tokens",
74
+ "normalize_query_text",
75
+ "docstring_signal",
76
+ "lexical_overlap_score",
77
+ "safe_join",
78
+ "read_lines",
79
+ "compute_span",
80
+ "make_snippet",
81
+ "make_module_summary",
82
+ "spans_overlap",
83
+ ]