pycode-kg 0.17.1__tar.gz → 0.18.1__tar.gz

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-0.17.1 → pycode_kg-0.18.1}/PKG-INFO +89 -132
  2. pycode_kg-0.18.1/README.md +188 -0
  3. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/pyproject.toml +1 -1
  4. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/__init__.py +1 -1
  5. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/analysis/bridge.py +6 -2
  6. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/analysis/framework_detector.py +7 -1
  7. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_viz.py +2 -2
  8. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/layout3d.py +30 -14
  9. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/viz3d.py +140 -84
  10. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/viz3d_timeline.py +13 -13
  11. pycode_kg-0.17.1/README.md +0 -231
  12. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/LICENSE +0 -0
  13. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/.DS_Store +0 -0
  14. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/__main__.py +0 -0
  15. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/analysis/__init__.py +0 -0
  16. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/analysis/centrality.py +0 -0
  17. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/analysis/hybrid_rank.py +0 -0
  18. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/app.py +0 -0
  19. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/architecture.py +0 -0
  20. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/build_pycodekg_lancedb.py +0 -0
  21. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/build_pycodekg_sqlite.py +0 -0
  22. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/__init__.py +0 -0
  23. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_analyze.py +0 -0
  24. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_architecture.py +0 -0
  25. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_bridges.py +0 -0
  26. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_build.py +0 -0
  27. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_build_full.py +0 -0
  28. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_centrality.py +0 -0
  29. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_explain.py +0 -0
  30. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_framework_nodes.py +0 -0
  31. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_hooks.py +0 -0
  32. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_init.py +0 -0
  33. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_mcp.py +0 -0
  34. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_model.py +0 -0
  35. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_query.py +0 -0
  36. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/cmd_snapshot.py +0 -0
  37. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/main.py +0 -0
  38. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/cli/options.py +0 -0
  39. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/config.py +0 -0
  40. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/graph.py +0 -0
  41. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/index.py +0 -0
  42. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/kg.py +0 -0
  43. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/mcp/bridge_tools.py +0 -0
  44. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/mcp/framework_tools.py +0 -0
  45. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/mcp_server.py +0 -0
  46. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/module/__init__.py +0 -0
  47. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/module/base.py +0 -0
  48. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/module/extractor.py +0 -0
  49. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/module/types.py +0 -0
  50. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/pycodekg.py +0 -0
  51. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/pycodekg_query.py +0 -0
  52. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/pycodekg_snippet_packer.py +0 -0
  53. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/pycodekg_thorough_analysis.py +0 -0
  54. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/pycodekg_viz.py +0 -0
  55. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/pycodekg_viz3d.py +0 -0
  56. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/ranking/__init__.py +0 -0
  57. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/ranking/cli_rank.py +0 -0
  58. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/ranking/coderank.py +0 -0
  59. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/snapshots.py +0 -0
  60. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/sql/004_add_centrality_table.sql +0 -0
  61. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/store.py +0 -0
  62. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/utils.py +0 -0
  63. {pycode_kg-0.17.1 → pycode_kg-0.18.1}/src/pycode_kg/visitor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycode-kg
3
- Version: 0.17.1
3
+ Version: 0.18.1
4
4
  Summary: A tool to build a searchable knowledge graph from Python repositories
5
5
  License-Expression: Elastic-2.0
6
6
  License-File: LICENSE
@@ -72,22 +72,21 @@ Project-URL: Repository, https://github.com/Flux-Frontiers/pycode_kg
72
72
  Description-Content-Type: text/markdown
73
73
 
74
74
 
75
+ <p align="center">
76
+ <img src="assets/logos/pycodeKG.PNG" alt="PyCodeKG" width="200"/>
77
+ </p>
78
+
75
79
  [![Python](https://img.shields.io/badge/python-3.12%20%7C%203.13-blue.svg)](https://www.python.org/)
76
80
  [![License: Elastic-2.0](https://img.shields.io/badge/License-Elastic%202.0-blue.svg)](https://www.elastic.co/licensing/elastic-license)
77
- [![Version](https://img.shields.io/badge/version-0.16.0-blue.svg)](https://github.com/Flux-Frontiers/pycode_kg/releases)
81
+ [![Version](https://img.shields.io/badge/version-0.18.1-blue.svg)](https://github.com/Flux-Frontiers/pycode_kg/releases)
78
82
  [![CI](https://github.com/Flux-Frontiers/pycode_kg/actions/workflows/ci.yml/badge.svg)](https://github.com/Flux-Frontiers/pycode_kg/actions/workflows/ci.yml)
79
83
  [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
80
84
  [![DOI](https://zenodo.org/badge/1202379010.svg)](https://zenodo.org/badge/latestdoi/1202379010)
81
85
 
82
- <p align="center">
83
- <img src="assets/logo-md-256x256.png" alt="PyCodeKG logo" width="256"/>
84
- </p>
85
-
86
86
  **PyCodeKG** — A Deterministic Knowledge Graph for Python Codebases
87
87
  with Semantic Indexing and Source-Grounded Snippet Packing
88
88
 
89
89
  *Author: Eric G. Suchanek, PhD*
90
-
91
90
  *Flux-Frontiers, Liberty TWP, OH*
92
91
 
93
92
  [Technical Paper (PDF)](article/pycode_kg.pdf)
@@ -98,84 +97,35 @@ with Semantic Indexing and Source-Grounded Snippet Packing
98
97
 
99
98
  PyCodeKG constructs a **deterministic, explainable knowledge graph** from a Python codebase using static analysis. The graph captures structural relationships — definitions, calls, imports, and inheritance — directly from the Python AST, stores them in SQLite, and augments retrieval with vector embeddings via LanceDB.
100
99
 
101
- Structure is treated as **ground truth**; semantic search is strictly an acceleration layer. The result is a searchable, auditable representation of a codebase that supports precise navigation, contextual snippet extraction, and downstream reasoning without hallucination.
102
-
103
- ---
104
-
105
- ## What Agents Say
106
-
107
- *From independent assessments run against PyCodeKG's own codebase. See [assessments/](assessments/) for the full reports.*
108
-
109
- > "The workflow compression is real and substantial. Rather than reading files sequentially or running grep searches in the dark, an agent equipped with PyCodeKG can orient itself in seconds."
110
- > — Claude Sonnet 4.6
111
-
112
- > "Replaces hours of manual exploration with a single call. The most valuable tool in the suite."
113
- > — Claude Opus 4, on `analyze_repo()`
114
-
115
- > "It let me move from broad orientation to intent-driven discovery and then to structural validation without dropping down into manual grep or repeated file reads."
116
- > — GPT-5 (via Cline)
117
-
118
- > "Traditional file reading and grep-based exploration are slow, linear, and context-poor. PyCodeKG's semantic search, graph navigation, and architectural analysis provide a quantum leap in speed and depth of understanding."
119
- > — GPT-4.1
120
-
121
- > "`pack_snippets()` provided source excerpts around each hit, making the code instantly readable. Context lines and relevance metadata obviated manual file open."
122
- > — Raptor Mini
123
-
124
- > "Dramatically more effective than traditional grep/file-reading workflows. Unique value proposition: hybrid search combining natural-language intent with precise structural relationships."
125
- > — Claude Haiku 4.5
126
-
127
- ---
128
-
129
- ## Quick Start
100
+ **No inference required.** The CLI is fully useful as a standalone analysis tool — every result is derived from structure, not generated. When used with AI agents, PyCodeKG gives them structurally-grounded answers: precise callers, real call chains, exact line numbers. Hallucination-resistant by design.
130
101
 
131
- Run the one-line installer from within the repo you want to index:
132
-
133
- ```bash
134
- curl -fsSL https://raw.githubusercontent.com/Flux-Frontiers/pycode_kg/main/scripts/install-skill.sh | bash
135
- ```
136
-
137
- This sets up everything end-to-end:
138
-
139
- 1. Installs SKILL.md reference files for Claude Code, Kilo Code, and other agents
140
- 2. Installs Claude Code slash commands (`/pycodekg`, `/setup-mcp`)
141
- 3. Installs the `pycode-kg` package if not already present
142
- 4. Builds the SQLite knowledge graph and LanceDB semantic index
143
- 5. Writes MCP configuration for Claude Code, Kilo Code, GitHub Copilot, and Cline
144
-
145
- After the script completes, restart your AI agent to activate the MCP server.
146
-
147
- ```bash
148
- # Preview without making changes
149
- curl -fsSL .../install-skill.sh | bash -s -- --dry-run
150
-
151
- # Claude Code and GitHub Copilot only
152
- curl -fsSL .../install-skill.sh | bash -s -- --providers claude,copilot
153
- ```
102
+ Structure is treated as **ground truth**; semantic search is strictly an acceleration layer. The result is a searchable, auditable representation of a codebase that supports precise navigation, contextual snippet extraction, and downstream reasoning without hallucination.
154
103
 
155
- **Full installation options, manual setup, and MCP config:** [docs/INSTALLATION.md](docs/INSTALLATION.md)
104
+ PyCodeKG uses the same architecture as [DocKG](https://github.com/Flux-Frontiers/doc_kg) but targets Python source code rather than document corpora.
156
105
 
157
106
  ---
158
107
 
159
108
  ## Features
160
109
 
161
110
  - **Static analysis pipeline** — Three-pass AST extraction: structure, call graph, data-flow
162
- - **Deterministic knowledge graph** — SQLite-backed canonical store with provenance
111
+ - **Deterministic knowledge graph** — SQLite-backed canonical store with provenance-tracked edges
163
112
  - **Symbol resolution** — `RESOLVES_TO` edges bridge cross-module call sites via import aliases
164
- - **Hybrid query model** — Semantic seeding (LanceDB) + structural expansion (graph traversal)
113
+ - **Hybrid query model** — Semantic seeding (LanceDB embeddings) + structural expansion (graph traversal)
165
114
  - **Source-grounded snippet packing** — Definition and call-site snippets with line numbers
166
115
  - **Precise fan-in lookup** — Two-phase reverse traversal resolving cross-module caller chains
167
- - **MCP server** — Ten tools for AI agent integration
116
+ - **Temporal snapshots** — Save and diff graph metrics across commits and versions
117
+ - **MCP server** — Seventeen tools for AI agent integration
168
118
  - **Streamlit web app** — Interactive graph browser, hybrid query UI, snippet pack explorer
169
- - **3D visualizer** — PyVista/PyQt5 interactive graph explorer
119
+ - **3-D visualizer** — PyVista/PyQt5 interactive graph explorer with FunnelLayout and timeline view
170
120
  - **Zero-config MCP setup** — Single-line installer configures Claude Code, Kilo Code, GitHub Copilot, and Cline
171
121
 
172
122
  ---
173
123
 
174
- ## Usage
124
+ ## Quick Start
175
125
 
176
126
  ```bash
177
- # Build the knowledge graph
178
- pycodekg build --repo /path/to/your/repo
127
+ # Index your repo (SQLite + LanceDB in one step)
128
+ pycodekg build --repo /path/to/repo
179
129
 
180
130
  # Natural-language query
181
131
  pycodekg query "authentication flow"
@@ -184,92 +134,99 @@ pycodekg query "authentication flow"
184
134
  pycodekg pack "database connection setup" --format md --out context.md
185
135
 
186
136
  # Full architectural analysis
187
- pycodekg analyze /path/to/your/repo
137
+ pycodekg analyze /path/to/repo
138
+ ```
188
139
 
189
- # Launch the interactive web app
190
- pycodekg viz
140
+ ---
191
141
 
192
- # Start the MCP server
193
- pycodekg mcp --repo /path/to/your/repo
194
- ```
142
+ ## Installation
195
143
 
196
- ### MCP Tools (once the server is running)
144
+ **Requirements:** Python 3.12, < 3.14
197
145
 
198
- ```
199
- graph_stats() # node/edge counts by kind
200
- query_codebase("authentication flow") # hybrid semantic + structural search
201
- pack_snippets("database layer") # source-grounded snippets as Markdown
202
- get_node("fn:store:GraphStore.write") # fetch a single node by ID
203
- callers("fn:store:GraphStore.write") # precise fan-in lookup
204
- explain("fn:store:GraphStore.write") # natural-language explanation
205
- analyze_repo() # full architectural analysis as Markdown
206
- snapshot_list() # list saved snapshots with deltas
207
- snapshot_show("latest") # inspect the latest snapshot
208
- snapshot_diff("<key_a>", "<key_b>") # compare two snapshots
146
+ ```bash
147
+ # pip
148
+ pip install pycode-kg
149
+
150
+ # With Streamlit web visualizer
151
+ pip install 'pycode-kg[viz]'
152
+
153
+ # With 3-D visualizer (PyVista/PyQt5)
154
+ pip install 'pycode-kg[viz3d]'
155
+
156
+ # Poetry
157
+ poetry add pycode-kg
209
158
  ```
210
159
 
211
- ### Python API
160
+ > For the one-line skill installer (MCP config, Claude slash commands, git hooks) see [docs/INSTALLATION.md](docs/INSTALLATION.md).
212
161
 
213
- ```python
214
- from pycode_kg import PyCodeKG
162
+ ---
215
163
 
216
- kg = PyCodeKG(repo_root="/path/to/repo")
217
- kg.build(wipe=True)
164
+ ## Usage
218
165
 
219
- result = kg.query("database connection setup", k=8, hop=1)
220
- for node in result.nodes:
221
- print(node["id"], node["name"])
166
+ ### Build and query
222
167
 
223
- pack = kg.pack("authentication flow")
224
- pack.save("context.md")
168
+ ```bash
169
+ pycodekg build --repo . # full build (SQLite + LanceDB)
170
+ pycodekg build --repo . --include-dir src # index a specific subtree
171
+ pycodekg query "snapshot freshness comparison" # hybrid semantic + structural search
172
+ pycodekg pack "graph build pipeline" --format md # snippet pack for LLM context
225
173
  ```
226
174
 
227
- ---
175
+ ### Analyze codebase health
228
176
 
229
- ## Architecture
177
+ ```bash
178
+ pycodekg analyze . # full report + JSON snapshot
179
+ ```
230
180
 
231
- <p align="center">
232
- <img src="assets/codeKG_arch_square-web.jpg" alt="PyCodeKG architecture workflow" width="600"/>
233
- </p>
181
+ ### Snapshots
234
182
 
183
+ ```bash
184
+ pycodekg snapshot save 0.18.0 # capture current metrics
185
+ pycodekg snapshot list # list all snapshots
186
+ pycodekg snapshot diff <key_a> <key_b> # compare two versions
235
187
  ```
236
- Repository
237
-
238
- AST parsing — Pass 1: structure, Pass 2: calls, Pass 3: data-flow
239
-
240
- SQLite graph nodes + edges
241
-
242
- Symbol resolution RESOLVES_TO edges (sym: stubs → fn:/cls: defs)
243
-
244
- Vector indexing — LanceDB
245
-
246
- Hybrid query — semantic + graph
247
-
248
- Ranking + deduplication
249
-
250
- ├──▶ Streamlit web app
251
- └──▶ MCP server tools
188
+
189
+ ### Visualize
190
+
191
+ ```bash
192
+ pycodekg viz # Streamlit web app
193
+ pycodekg viz3d --layout funnel # 3-D PyVista explorer
194
+ pycodekg viz-timeline # metric history timeline
252
195
  ```
253
196
 
254
- The five design principles:
197
+ > Full flag reference: [docs/INSTALLATION.md](docs/INSTALLATION.md) · Query patterns: [docs/CHEATSHEET.md](docs/CHEATSHEET.md)
198
+
199
+ ---
200
+
201
+ ## MCP Integration
202
+
203
+ Start the MCP server, then wire it into your AI agent:
204
+
205
+ ```bash
206
+ pycodekg mcp --repo /path/to/repo
207
+ ```
255
208
 
256
- 1. **Structure is authoritative**The AST-derived graph is the source of truth.
257
- 2. **Semantics accelerate, never decide** — Embeddings seed and rank retrieval but never invent structure.
258
- 3. **Everything is traceable** — Nodes and edges map to concrete files and line numbers.
259
- 4. **Determinism over heuristics** — Identical input yields identical output.
260
- 5. **Composable artifacts** — SQLite for structure, LanceDB for vectors, Markdown/JSON for consumption.
209
+ PyCodeKG exposes seventeen tools covering hybrid search, snippet packing, caller tracing, architectural analysis, and temporal snapshots. Any MCP-compatible agentClaude Code, Claude Desktop, Cursor, Continue, GitHub Copilot — can consume them directly.
261
210
 
262
- **Full architecture documentation:** [docs/Architecture.md](docs/Architecture.md)
211
+ > Full provider setup, tool reference, and SSE transport: [docs/MCP.md](docs/MCP.md)
263
212
 
264
213
  ---
265
214
 
266
- ## Contribution Checklist
215
+ ## What Agents Say
216
+
217
+ *From independent assessments run against PyCodeKG's own codebase. See [assessments/](assessments/) for full reports.*
218
+
219
+ > "PyCodeKG compresses a multi-step workflow — semantic search, graph expansion, caller tracing, snippet retrieval, and architectural summarization — into a small set of tools that are fast to invoke and easy to chain. In practice, it let me move from broad orientation to intent-driven discovery and then to structural validation without dropping down into manual grep or repeated file reads."
220
+ > — GPT-5 (via Cline)
267
221
 
268
- When changing MCP tools in `src/pycode_kg/mcp_server.py` (signature, params, defaults, or behavior), update all three in the same commit:
222
+ > "What sets it apart from 'search the repo with embeddings' tools is the structural layer… Verdict: 4.5/5 recommend without reservation for any non-trivial Python codebase."
223
+ > — Claude Opus 4.7
269
224
 
270
- - Module docstring `Tools` list at the top of `src/pycode_kg/mcp_server.py`
271
- - `mcp = FastMCP(..., instructions=(...))` tool descriptions in `src/pycode_kg/mcp_server.py`
272
- - The runtime tool implementation and `:param:` docstrings
225
+ > "PyCodeKG is dramatically more effective than traditional grep/file-reading workflows. Unique value: hybrid search combining natural-language intent with precise structural relationships."
226
+ > Claude Haiku 4.5
227
+
228
+ > "`pack_snippets()` provided source excerpts around each hit, making the code instantly readable. Context lines and relevance metadata obviated manual file open."
229
+ > — Raptor Mini
273
230
 
274
231
  ---
275
232
 
@@ -281,7 +238,7 @@ If you use PyCodeKG in your research or project, please cite it:
281
238
 
282
239
  **APA**
283
240
 
284
- > Suchanek, E. G. (2026). *PyCodeKG: Semantic Knowledge Graph for Python Codebases* (Version 0.15.0) [Software]. Flux-Frontiers. https://doi.org/10.5281/zenodo.PLACEHOLDER
241
+ > Suchanek, E. G. (2026). *PyCodeKG: Semantic Knowledge Graph for Python Codebases* (Version 0.18.0) [Software]. Flux-Frontiers. https://doi.org/10.5281/zenodo.19834777
285
242
 
286
243
  **BibTeX**
287
244
 
@@ -289,11 +246,11 @@ If you use PyCodeKG in your research or project, please cite it:
289
246
  @software{suchanek_pycode_kg,
290
247
  author = {Suchanek, Eric G.},
291
248
  title = {{PyCodeKG}: Semantic Knowledge Graph for Python Codebases},
292
- version = {0.15.0},
249
+ version = {0.18.0},
293
250
  year = {2026},
294
251
  publisher = {Flux-Frontiers},
295
252
  url = {https://github.com/Flux-Frontiers/pycode_kg},
296
- doi = {10.5281/zenodo.PLACEHOLDER},
253
+ doi = {10.5281/zenodo.19834777},
297
254
  }
298
255
  ```
299
256
 
@@ -301,5 +258,5 @@ If you use PyCodeKG in your research or project, please cite it:
301
258
 
302
259
  ## License
303
260
 
304
- [Elastic License 2.0](https://www.elastic.co/licensing/elastic-license) — see [LICENSE](LICENSE).
261
+ [Elastic License 2.0](https://www.elastic.co/licensing/elastic-license) — free for non-commercial and internal use; commercial redistribution or hosting requires a license from Flux-Frontiers.
305
262
 
@@ -0,0 +1,188 @@
1
+
2
+ <p align="center">
3
+ <img src="assets/logos/pycodeKG.PNG" alt="PyCodeKG" width="200"/>
4
+ </p>
5
+
6
+ [![Python](https://img.shields.io/badge/python-3.12%20%7C%203.13-blue.svg)](https://www.python.org/)
7
+ [![License: Elastic-2.0](https://img.shields.io/badge/License-Elastic%202.0-blue.svg)](https://www.elastic.co/licensing/elastic-license)
8
+ [![Version](https://img.shields.io/badge/version-0.18.1-blue.svg)](https://github.com/Flux-Frontiers/pycode_kg/releases)
9
+ [![CI](https://github.com/Flux-Frontiers/pycode_kg/actions/workflows/ci.yml/badge.svg)](https://github.com/Flux-Frontiers/pycode_kg/actions/workflows/ci.yml)
10
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
11
+ [![DOI](https://zenodo.org/badge/1202379010.svg)](https://zenodo.org/badge/latestdoi/1202379010)
12
+
13
+ **PyCodeKG** — A Deterministic Knowledge Graph for Python Codebases
14
+ with Semantic Indexing and Source-Grounded Snippet Packing
15
+
16
+ *Author: Eric G. Suchanek, PhD*
17
+ *Flux-Frontiers, Liberty TWP, OH*
18
+
19
+ [Technical Paper (PDF)](article/pycode_kg.pdf)
20
+
21
+ ---
22
+
23
+ ## Overview
24
+
25
+ PyCodeKG constructs a **deterministic, explainable knowledge graph** from a Python codebase using static analysis. The graph captures structural relationships — definitions, calls, imports, and inheritance — directly from the Python AST, stores them in SQLite, and augments retrieval with vector embeddings via LanceDB.
26
+
27
+ **No inference required.** The CLI is fully useful as a standalone analysis tool — every result is derived from structure, not generated. When used with AI agents, PyCodeKG gives them structurally-grounded answers: precise callers, real call chains, exact line numbers. Hallucination-resistant by design.
28
+
29
+ Structure is treated as **ground truth**; semantic search is strictly an acceleration layer. The result is a searchable, auditable representation of a codebase that supports precise navigation, contextual snippet extraction, and downstream reasoning without hallucination.
30
+
31
+ PyCodeKG uses the same architecture as [DocKG](https://github.com/Flux-Frontiers/doc_kg) but targets Python source code rather than document corpora.
32
+
33
+ ---
34
+
35
+ ## Features
36
+
37
+ - **Static analysis pipeline** — Three-pass AST extraction: structure, call graph, data-flow
38
+ - **Deterministic knowledge graph** — SQLite-backed canonical store with provenance-tracked edges
39
+ - **Symbol resolution** — `RESOLVES_TO` edges bridge cross-module call sites via import aliases
40
+ - **Hybrid query model** — Semantic seeding (LanceDB embeddings) + structural expansion (graph traversal)
41
+ - **Source-grounded snippet packing** — Definition and call-site snippets with line numbers
42
+ - **Precise fan-in lookup** — Two-phase reverse traversal resolving cross-module caller chains
43
+ - **Temporal snapshots** — Save and diff graph metrics across commits and versions
44
+ - **MCP server** — Seventeen tools for AI agent integration
45
+ - **Streamlit web app** — Interactive graph browser, hybrid query UI, snippet pack explorer
46
+ - **3-D visualizer** — PyVista/PyQt5 interactive graph explorer with FunnelLayout and timeline view
47
+ - **Zero-config MCP setup** — Single-line installer configures Claude Code, Kilo Code, GitHub Copilot, and Cline
48
+
49
+ ---
50
+
51
+ ## Quick Start
52
+
53
+ ```bash
54
+ # Index your repo (SQLite + LanceDB in one step)
55
+ pycodekg build --repo /path/to/repo
56
+
57
+ # Natural-language query
58
+ pycodekg query "authentication flow"
59
+
60
+ # Source-grounded snippet pack — paste straight into an LLM prompt
61
+ pycodekg pack "database connection setup" --format md --out context.md
62
+
63
+ # Full architectural analysis
64
+ pycodekg analyze /path/to/repo
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Installation
70
+
71
+ **Requirements:** Python ≥ 3.12, < 3.14
72
+
73
+ ```bash
74
+ # pip
75
+ pip install pycode-kg
76
+
77
+ # With Streamlit web visualizer
78
+ pip install 'pycode-kg[viz]'
79
+
80
+ # With 3-D visualizer (PyVista/PyQt5)
81
+ pip install 'pycode-kg[viz3d]'
82
+
83
+ # Poetry
84
+ poetry add pycode-kg
85
+ ```
86
+
87
+ > For the one-line skill installer (MCP config, Claude slash commands, git hooks) see [docs/INSTALLATION.md](docs/INSTALLATION.md).
88
+
89
+ ---
90
+
91
+ ## Usage
92
+
93
+ ### Build and query
94
+
95
+ ```bash
96
+ pycodekg build --repo . # full build (SQLite + LanceDB)
97
+ pycodekg build --repo . --include-dir src # index a specific subtree
98
+ pycodekg query "snapshot freshness comparison" # hybrid semantic + structural search
99
+ pycodekg pack "graph build pipeline" --format md # snippet pack for LLM context
100
+ ```
101
+
102
+ ### Analyze codebase health
103
+
104
+ ```bash
105
+ pycodekg analyze . # full report + JSON snapshot
106
+ ```
107
+
108
+ ### Snapshots
109
+
110
+ ```bash
111
+ pycodekg snapshot save 0.18.0 # capture current metrics
112
+ pycodekg snapshot list # list all snapshots
113
+ pycodekg snapshot diff <key_a> <key_b> # compare two versions
114
+ ```
115
+
116
+ ### Visualize
117
+
118
+ ```bash
119
+ pycodekg viz # Streamlit web app
120
+ pycodekg viz3d --layout funnel # 3-D PyVista explorer
121
+ pycodekg viz-timeline # metric history timeline
122
+ ```
123
+
124
+ > Full flag reference: [docs/INSTALLATION.md](docs/INSTALLATION.md) · Query patterns: [docs/CHEATSHEET.md](docs/CHEATSHEET.md)
125
+
126
+ ---
127
+
128
+ ## MCP Integration
129
+
130
+ Start the MCP server, then wire it into your AI agent:
131
+
132
+ ```bash
133
+ pycodekg mcp --repo /path/to/repo
134
+ ```
135
+
136
+ PyCodeKG exposes seventeen tools covering hybrid search, snippet packing, caller tracing, architectural analysis, and temporal snapshots. Any MCP-compatible agent — Claude Code, Claude Desktop, Cursor, Continue, GitHub Copilot — can consume them directly.
137
+
138
+ > Full provider setup, tool reference, and SSE transport: [docs/MCP.md](docs/MCP.md)
139
+
140
+ ---
141
+
142
+ ## What Agents Say
143
+
144
+ *From independent assessments run against PyCodeKG's own codebase. See [assessments/](assessments/) for full reports.*
145
+
146
+ > "PyCodeKG compresses a multi-step workflow — semantic search, graph expansion, caller tracing, snippet retrieval, and architectural summarization — into a small set of tools that are fast to invoke and easy to chain. In practice, it let me move from broad orientation to intent-driven discovery and then to structural validation without dropping down into manual grep or repeated file reads."
147
+ > — GPT-5 (via Cline)
148
+
149
+ > "What sets it apart from 'search the repo with embeddings' tools is the structural layer… Verdict: 4.5/5 — recommend without reservation for any non-trivial Python codebase."
150
+ > — Claude Opus 4.7
151
+
152
+ > "PyCodeKG is dramatically more effective than traditional grep/file-reading workflows. Unique value: hybrid search combining natural-language intent with precise structural relationships."
153
+ > — Claude Haiku 4.5
154
+
155
+ > "`pack_snippets()` provided source excerpts around each hit, making the code instantly readable. Context lines and relevance metadata obviated manual file open."
156
+ > — Raptor Mini
157
+
158
+ ---
159
+
160
+ ## Citation
161
+
162
+ If you use PyCodeKG in your research or project, please cite it:
163
+
164
+ [![DOI](https://zenodo.org/badge/1202379010.svg)](https://zenodo.org/badge/latestdoi/1202379010)
165
+
166
+ **APA**
167
+
168
+ > Suchanek, E. G. (2026). *PyCodeKG: Semantic Knowledge Graph for Python Codebases* (Version 0.18.0) [Software]. Flux-Frontiers. https://doi.org/10.5281/zenodo.19834777
169
+
170
+ **BibTeX**
171
+
172
+ ```bibtex
173
+ @software{suchanek_pycode_kg,
174
+ author = {Suchanek, Eric G.},
175
+ title = {{PyCodeKG}: Semantic Knowledge Graph for Python Codebases},
176
+ version = {0.18.0},
177
+ year = {2026},
178
+ publisher = {Flux-Frontiers},
179
+ url = {https://github.com/Flux-Frontiers/pycode_kg},
180
+ doi = {10.5281/zenodo.19834777},
181
+ }
182
+ ```
183
+
184
+ ---
185
+
186
+ ## License
187
+
188
+ [Elastic License 2.0](https://www.elastic.co/licensing/elastic-license) — free for non-commercial and internal use; commercial redistribution or hosting requires a license from Flux-Frontiers.
@@ -66,7 +66,7 @@ ruff = ">=0.4.0"
66
66
  # ---------------------------------------------------------------------------
67
67
  [project]
68
68
  name = "pycode-kg"
69
- version = "0.17.1"
69
+ version = "0.18.1"
70
70
  description = "A tool to build a searchable knowledge graph from Python repositories"
71
71
  readme = "README.md"
72
72
  license = "Elastic-2.0"
@@ -32,7 +32,7 @@ KGModule SDK (build new domain KGs)::
32
32
  from pycode_kg import KGModule, KGExtractor, PyCodeKGExtractor, NodeSpec, EdgeSpec
33
33
  """
34
34
 
35
- __version__ = "0.17.1"
35
+ __version__ = "0.18.1"
36
36
  __author__ = "Eric G. Suchanek, PhD"
37
37
 
38
38
  # Low-level primitives (locked v0 contract)
@@ -5,6 +5,7 @@ For well-modularized codebases, identifies orchestrator and hub modules.
5
5
 
6
6
  Author: Eric G. Suchanek, PhD
7
7
  Last Revision: 2026-03-12 17:30:35
8
+ License: Elastic 2.0
8
9
  """
9
10
 
10
11
  import sqlite3
@@ -14,8 +15,11 @@ from pycode_kg.analysis.centrality import CentralityRecord, StructuralImportance
14
15
 
15
16
 
16
17
  def compute_bridge_centrality(
17
- kind="module", include_imports=True, top=25, db_path="pycodekg.sqlite"
18
- ):
18
+ kind: str = "module",
19
+ include_imports: bool = True,
20
+ top: int = 25,
21
+ db_path: str = "pycodekg.sqlite",
22
+ ) -> list[tuple[str, float]]:
19
23
  """
20
24
  Compute module connectivity: unique module interactions per module.
21
25
 
@@ -1,6 +1,10 @@
1
1
  """
2
2
  Framework Detector for PyCodeKG.
3
3
  Identifies repo-defining abstractions using centrality and cross-module signals.
4
+
5
+ Author: Eric G. Suchanek, PhD
6
+ Last Revision: 2026-03-12 17:30:35
7
+ License: Elastic 2.0
4
8
  """
5
9
 
6
10
  import sqlite3
@@ -33,7 +37,9 @@ _BOILERPLATE_NAMES: frozenset[str] = frozenset(
33
37
  )
34
38
 
35
39
 
36
- def detect_framework_nodes(limit=25, db_path="pycodekg.sqlite"):
40
+ def detect_framework_nodes(
41
+ limit: int = 25, db_path: str = "pycodekg.sqlite"
42
+ ) -> list[tuple[str, float, str]]:
37
43
  """
38
44
  Detect framework-like nodes using SIR and module connectivity.
39
45
 
@@ -88,13 +88,13 @@ def viz(db: str, port: str, no_browser: bool) -> None:
88
88
  )
89
89
  @click.option(
90
90
  "--layout",
91
- type=click.Choice(["allium", "cake"]),
91
+ type=click.Choice(["allium", "funnel"]),
92
92
  default="allium",
93
93
  show_default=True,
94
94
  help=(
95
95
  "3-D layout strategy. "
96
96
  "'allium' renders each module as a Giant Allium plant; "
97
- "'cake' stratifies nodes by kind across Z layers."
97
+ "'funnel' stratifies nodes by kind across Z layers."
98
98
  ),
99
99
  )
100
100
  @click.option(