tscode-kg 0.2.0__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 (36) hide show
  1. tscode_kg-0.2.0/LICENSE +24 -0
  2. tscode_kg-0.2.0/PKG-INFO +196 -0
  3. tscode_kg-0.2.0/README.md +144 -0
  4. tscode_kg-0.2.0/pyproject.toml +162 -0
  5. tscode_kg-0.2.0/src/tscode_kg/__init__.py +42 -0
  6. tscode_kg-0.2.0/src/tscode_kg/__main__.py +6 -0
  7. tscode_kg-0.2.0/src/tscode_kg/analysis.py +1829 -0
  8. tscode_kg-0.2.0/src/tscode_kg/app.py +1355 -0
  9. tscode_kg-0.2.0/src/tscode_kg/bridge.py +114 -0
  10. tscode_kg-0.2.0/src/tscode_kg/centrality.py +434 -0
  11. tscode_kg-0.2.0/src/tscode_kg/cli/__init__.py +1 -0
  12. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_analyze.py +69 -0
  13. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_bridges.py +38 -0
  14. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_build.py +86 -0
  15. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_centrality.py +124 -0
  16. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_explain.py +58 -0
  17. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_framework_nodes.py +43 -0
  18. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_hooks.py +125 -0
  19. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_init.py +234 -0
  20. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_mcp.py +35 -0
  21. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_model.py +52 -0
  22. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_query.py +75 -0
  23. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_snapshot.py +431 -0
  24. tscode_kg-0.2.0/src/tscode_kg/cli/cmd_viz.py +175 -0
  25. tscode_kg-0.2.0/src/tscode_kg/cli/main.py +56 -0
  26. tscode_kg-0.2.0/src/tscode_kg/coderank.py +564 -0
  27. tscode_kg-0.2.0/src/tscode_kg/config.py +36 -0
  28. tscode_kg-0.2.0/src/tscode_kg/explain.py +270 -0
  29. tscode_kg-0.2.0/src/tscode_kg/extractor.py +827 -0
  30. tscode_kg-0.2.0/src/tscode_kg/framework_detector.py +106 -0
  31. tscode_kg-0.2.0/src/tscode_kg/kg.py +193 -0
  32. tscode_kg-0.2.0/src/tscode_kg/layout3d.py +492 -0
  33. tscode_kg-0.2.0/src/tscode_kg/mcp_server.py +1412 -0
  34. tscode_kg-0.2.0/src/tscode_kg/snapshots.py +64 -0
  35. tscode_kg-0.2.0/src/tscode_kg/viz3d.py +1457 -0
  36. tscode_kg-0.2.0/src/tscode_kg/viz3d_timeline.py +369 -0
@@ -0,0 +1,24 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2026, Flux-Frontiers
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: tscode-kg
3
+ Version: 0.2.0
4
+ Summary: Knowledge graph for TypeScript/JavaScript codebases — AST extraction, hybrid semantic+structural search
5
+ License-Expression: Elastic-2.0
6
+ License-File: LICENSE
7
+ Keywords: knowledge-graph,typescript,javascript,ast,sqlite-vec,sqlite,semantic-search
8
+ Author: Eric G. Suchanek, PhD
9
+ Author-email: suchanek@mac.com
10
+ Requires-Python: >=3.12,<3.14
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Provides-Extra: dev
19
+ Provides-Extra: kgdeps
20
+ Provides-Extra: viz
21
+ Provides-Extra: viz3d
22
+ Requires-Dist: PyQt5 (>=5.15.11,<5.16) ; extra == "viz3d"
23
+ Requires-Dist: click (>=8.1.0,<9)
24
+ Requires-Dist: detect-secrets (>=1.5.0) ; extra == "dev"
25
+ Requires-Dist: doc-kg (>=0.18.1) ; extra == "kgdeps"
26
+ Requires-Dist: kgmodule-utils[semantic,sqlite-vec] (>=0.8.0)
27
+ Requires-Dist: markdown (>=3.10,<3.11) ; extra == "viz3d"
28
+ Requires-Dist: mcp (>=1.0.0,<2)
29
+ Requires-Dist: networkx (>=3.0)
30
+ Requires-Dist: param (>=2.4,<2.5) ; extra == "viz3d"
31
+ Requires-Dist: plotly (>=6.8.0,<6.9) ; extra == "viz"
32
+ Requires-Dist: pre-commit (>=4.5.1) ; extra == "dev"
33
+ Requires-Dist: pycode-kg (>=0.20.0,<0.21) ; extra == "dev"
34
+ Requires-Dist: pycode-kg (>=0.20.0,<0.21) ; extra == "kgdeps"
35
+ Requires-Dist: pylint (>=4.0.5) ; extra == "dev"
36
+ Requires-Dist: pytest (>=8.0.0) ; extra == "dev"
37
+ Requires-Dist: pytest-cov (>=5.0.0) ; extra == "dev"
38
+ Requires-Dist: pyvis (>=0.3.2,<0.4) ; extra == "viz"
39
+ Requires-Dist: pyvista (>=0.48.4,<0.49) ; extra == "viz3d"
40
+ Requires-Dist: pyvistaqt (>=0.12,<0.13) ; extra == "viz3d"
41
+ Requires-Dist: rich (>=14.3.3,<15)
42
+ Requires-Dist: ruff (>=0.4.0) ; extra == "dev"
43
+ Requires-Dist: streamlit (>=1.59.0,<1.60) ; extra == "viz"
44
+ Requires-Dist: trame-vtk (>=2.11.8,<2.12) ; extra == "viz3d"
45
+ Requires-Dist: tree-sitter (>=0.25.0)
46
+ Requires-Dist: tree-sitter-typescript (>=0.23.2)
47
+ Requires-Dist: ty (>=0.0.41) ; extra == "dev"
48
+ Project-URL: Homepage, https://github.com/Flux-Frontiers/tscode_kg
49
+ Project-URL: Repository, https://github.com/Flux-Frontiers/tscode_kg
50
+ Description-Content-Type: text/markdown
51
+
52
+ # TypeScriptKG
53
+
54
+ Knowledge graph for TypeScript and JavaScript codebases — deterministic AST extraction, hybrid semantic + structural search.
55
+
56
+ ## Overview
57
+
58
+ TypeScriptKG builds a queryable knowledge graph from TypeScript/JavaScript source code using:
59
+
60
+ - **tree-sitter** for deterministic, parser-level AST extraction (no LLM inference during indexing)
61
+ - **SQLite** for the structural graph (nodes, edges, provenance)
62
+ - **sqlite-vec** for the semantic vector index (embeddings via `BAAI/bge-small-en-v1.5`)
63
+ - **Hybrid retrieval**: semantic seed → graph hop expansion → lexical re-ranking
64
+
65
+ ## Node types
66
+
67
+ | Kind | Description |
68
+ |------|-------------|
69
+ | `module` | Every indexed `.ts`/`.tsx`/`.js`/`.jsx` file |
70
+ | `class` | Class declaration |
71
+ | `interface` | TypeScript interface |
72
+ | `type_alias` | TypeScript type alias |
73
+ | `enum` | TypeScript enum |
74
+ | `namespace` | TypeScript namespace / module declaration |
75
+ | `function` | Module-level function (declaration or `const` arrow) |
76
+ | `method` | Method or accessor within a class |
77
+ | `symbol` | Unresolved external import stub |
78
+
79
+ ## Edge types
80
+
81
+ | Relation | Description |
82
+ |----------|-------------|
83
+ | `CONTAINS` | module → class/function/interface… |
84
+ | `IMPORTS` | module → module |
85
+ | `CALLS` | function/method → function |
86
+ | `INHERITS` | class extends class |
87
+ | `IMPLEMENTS` | class implements interface |
88
+ | `EXTENDS` | interface extends interface |
89
+
90
+ ## Quick start
91
+
92
+ ```bash
93
+ pip install tscode-kg
94
+
95
+ # First-time setup (downloads model, builds graph, installs hooks, snapshots)
96
+ tscodekg init --repo /path/to/ts-repo
97
+
98
+ # Build the KG for a TypeScript repo
99
+ tscodekg build --repo /path/to/ts-repo
100
+
101
+ # Query
102
+ tscodekg query "authentication middleware"
103
+ tscodekg pack "error handling utilities" --hop 2
104
+
105
+ # Thorough architectural analysis (fan-in/out, CodeRank, SIR centrality, JSDoc coverage)
106
+ tscodekg analyze /path/to/ts-repo --report analysis.md
107
+
108
+ # Structural rankings and node explanations
109
+ tscodekg centrality --top 20
110
+ tscodekg bridges --top 20
111
+ tscodekg framework-nodes --top 20
112
+ tscodekg explain "fn:src/utils/helpers.ts:formatDate"
113
+
114
+ # Temporal metric snapshots
115
+ tscodekg snapshot save --repo /path/to/ts-repo
116
+ tscodekg snapshot list
117
+
118
+ # Interactive visualizers (install extras: tscode-kg[viz] / tscode-kg[viz3d])
119
+ tscodekg viz --port 8500
120
+ tscodekg viz3d --layout allium
121
+ tscodekg viz-timeline --type 2d
122
+
123
+ # Install the pre-commit snapshot hook
124
+ tscodekg install-hooks --repo /path/to/ts-repo
125
+
126
+ # MCP server (Claude Desktop, Cursor, etc.)
127
+ tscodekg mcp --repo /path/to/ts-repo
128
+ ```
129
+
130
+ Each subcommand is also available as a dedicated script alias — `tscodekg-init`,
131
+ `tscodekg-build`, `tscodekg-query`, `tscodekg-pack`, `tscodekg-analyze`,
132
+ `tscodekg-centrality`, `tscodekg-viz`, `tscodekg-viz3d`, `tscodekg-viz-timeline`,
133
+ `tscodekg-install-hooks`, `tscodekg-download-model`, `tscodekg-mcp` — both forms
134
+ are equivalent.
135
+
136
+ ## MCP tools
137
+
138
+ The MCP server exposes the full PyCodeKG toolkit, applied to TypeScript/JavaScript
139
+ codebases: `graph_stats`, `query_codebase`, `pack_snippets`, `callers`, `get_node`,
140
+ `list_nodes`, `find_node`, `centrality`, `bridge_centrality`, `framework_nodes`,
141
+ `find_definition_at`, `analyze_repo`, `explain`, `rank_nodes`, `query_ranked`,
142
+ `explain_rank`, `snapshot_list`, `snapshot_show`, and `snapshot_diff`.
143
+
144
+ See `docs/MCP.md` for setup and `docs/CHEATSHEET.md` for a query cookbook.
145
+ Repo-local Claude Code skills live in `skills/`.
146
+
147
+ ## Snapshots & git hook
148
+
149
+ `tscodekg snapshot save` captures graph metrics (nodes, edges, JSDoc coverage,
150
+ issues, hotspots) keyed by git tree hash into `.tscodekg/snapshots/`, with
151
+ deltas computed against the previous and baseline snapshots.
152
+ `tscodekg install-hooks` installs a pre-commit hook that rebuilds the index,
153
+ captures a snapshot, stages the snapshot directory, and then runs the
154
+ pre-commit framework checks — so every commit records the state of the
155
+ knowledge graph. Skip it for one commit with `TSCODEKG_SKIP_SNAPSHOT=1`.
156
+
157
+ ## Python API
158
+
159
+ ```python
160
+ from tscode_kg import TypeScriptKG
161
+
162
+ kg = TypeScriptKG(repo_root="/path/to/ts-repo")
163
+ stats = kg.build(wipe=True)
164
+
165
+ result = kg.query("authentication middleware", k=8)
166
+ result.print_summary()
167
+
168
+ pack = kg.pack("error handling", k=8, hop=1)
169
+ pack.save("context.md")
170
+ ```
171
+
172
+ ## Architecture
173
+
174
+ TypeScriptKG is a domain implementation of the `KGModule` base class from `kgmodule-utils`.
175
+ Only the TypeScript/JS-specific extraction layer is implemented here — all generic
176
+ infrastructure (SQLite, sqlite-vec, hybrid query, snippet packing) is inherited from
177
+ `KGModule`.
178
+
179
+ ## Configuration
180
+
181
+ In your project's `pyproject.toml`:
182
+
183
+ ```toml
184
+ [tool.tscodekg]
185
+ include = ["src"] # top-level dirs to index (empty = all)
186
+ exclude = ["__tests__"] # extra dirs to skip
187
+ ```
188
+
189
+ ## Author
190
+
191
+ Eric G. Suchanek, PhD — Flux Frontiers
192
+
193
+ ## License
194
+
195
+ Elastic-2.0
196
+
@@ -0,0 +1,144 @@
1
+ # TypeScriptKG
2
+
3
+ Knowledge graph for TypeScript and JavaScript codebases — deterministic AST extraction, hybrid semantic + structural search.
4
+
5
+ ## Overview
6
+
7
+ TypeScriptKG builds a queryable knowledge graph from TypeScript/JavaScript source code using:
8
+
9
+ - **tree-sitter** for deterministic, parser-level AST extraction (no LLM inference during indexing)
10
+ - **SQLite** for the structural graph (nodes, edges, provenance)
11
+ - **sqlite-vec** for the semantic vector index (embeddings via `BAAI/bge-small-en-v1.5`)
12
+ - **Hybrid retrieval**: semantic seed → graph hop expansion → lexical re-ranking
13
+
14
+ ## Node types
15
+
16
+ | Kind | Description |
17
+ |------|-------------|
18
+ | `module` | Every indexed `.ts`/`.tsx`/`.js`/`.jsx` file |
19
+ | `class` | Class declaration |
20
+ | `interface` | TypeScript interface |
21
+ | `type_alias` | TypeScript type alias |
22
+ | `enum` | TypeScript enum |
23
+ | `namespace` | TypeScript namespace / module declaration |
24
+ | `function` | Module-level function (declaration or `const` arrow) |
25
+ | `method` | Method or accessor within a class |
26
+ | `symbol` | Unresolved external import stub |
27
+
28
+ ## Edge types
29
+
30
+ | Relation | Description |
31
+ |----------|-------------|
32
+ | `CONTAINS` | module → class/function/interface… |
33
+ | `IMPORTS` | module → module |
34
+ | `CALLS` | function/method → function |
35
+ | `INHERITS` | class extends class |
36
+ | `IMPLEMENTS` | class implements interface |
37
+ | `EXTENDS` | interface extends interface |
38
+
39
+ ## Quick start
40
+
41
+ ```bash
42
+ pip install tscode-kg
43
+
44
+ # First-time setup (downloads model, builds graph, installs hooks, snapshots)
45
+ tscodekg init --repo /path/to/ts-repo
46
+
47
+ # Build the KG for a TypeScript repo
48
+ tscodekg build --repo /path/to/ts-repo
49
+
50
+ # Query
51
+ tscodekg query "authentication middleware"
52
+ tscodekg pack "error handling utilities" --hop 2
53
+
54
+ # Thorough architectural analysis (fan-in/out, CodeRank, SIR centrality, JSDoc coverage)
55
+ tscodekg analyze /path/to/ts-repo --report analysis.md
56
+
57
+ # Structural rankings and node explanations
58
+ tscodekg centrality --top 20
59
+ tscodekg bridges --top 20
60
+ tscodekg framework-nodes --top 20
61
+ tscodekg explain "fn:src/utils/helpers.ts:formatDate"
62
+
63
+ # Temporal metric snapshots
64
+ tscodekg snapshot save --repo /path/to/ts-repo
65
+ tscodekg snapshot list
66
+
67
+ # Interactive visualizers (install extras: tscode-kg[viz] / tscode-kg[viz3d])
68
+ tscodekg viz --port 8500
69
+ tscodekg viz3d --layout allium
70
+ tscodekg viz-timeline --type 2d
71
+
72
+ # Install the pre-commit snapshot hook
73
+ tscodekg install-hooks --repo /path/to/ts-repo
74
+
75
+ # MCP server (Claude Desktop, Cursor, etc.)
76
+ tscodekg mcp --repo /path/to/ts-repo
77
+ ```
78
+
79
+ Each subcommand is also available as a dedicated script alias — `tscodekg-init`,
80
+ `tscodekg-build`, `tscodekg-query`, `tscodekg-pack`, `tscodekg-analyze`,
81
+ `tscodekg-centrality`, `tscodekg-viz`, `tscodekg-viz3d`, `tscodekg-viz-timeline`,
82
+ `tscodekg-install-hooks`, `tscodekg-download-model`, `tscodekg-mcp` — both forms
83
+ are equivalent.
84
+
85
+ ## MCP tools
86
+
87
+ The MCP server exposes the full PyCodeKG toolkit, applied to TypeScript/JavaScript
88
+ codebases: `graph_stats`, `query_codebase`, `pack_snippets`, `callers`, `get_node`,
89
+ `list_nodes`, `find_node`, `centrality`, `bridge_centrality`, `framework_nodes`,
90
+ `find_definition_at`, `analyze_repo`, `explain`, `rank_nodes`, `query_ranked`,
91
+ `explain_rank`, `snapshot_list`, `snapshot_show`, and `snapshot_diff`.
92
+
93
+ See `docs/MCP.md` for setup and `docs/CHEATSHEET.md` for a query cookbook.
94
+ Repo-local Claude Code skills live in `skills/`.
95
+
96
+ ## Snapshots & git hook
97
+
98
+ `tscodekg snapshot save` captures graph metrics (nodes, edges, JSDoc coverage,
99
+ issues, hotspots) keyed by git tree hash into `.tscodekg/snapshots/`, with
100
+ deltas computed against the previous and baseline snapshots.
101
+ `tscodekg install-hooks` installs a pre-commit hook that rebuilds the index,
102
+ captures a snapshot, stages the snapshot directory, and then runs the
103
+ pre-commit framework checks — so every commit records the state of the
104
+ knowledge graph. Skip it for one commit with `TSCODEKG_SKIP_SNAPSHOT=1`.
105
+
106
+ ## Python API
107
+
108
+ ```python
109
+ from tscode_kg import TypeScriptKG
110
+
111
+ kg = TypeScriptKG(repo_root="/path/to/ts-repo")
112
+ stats = kg.build(wipe=True)
113
+
114
+ result = kg.query("authentication middleware", k=8)
115
+ result.print_summary()
116
+
117
+ pack = kg.pack("error handling", k=8, hop=1)
118
+ pack.save("context.md")
119
+ ```
120
+
121
+ ## Architecture
122
+
123
+ TypeScriptKG is a domain implementation of the `KGModule` base class from `kgmodule-utils`.
124
+ Only the TypeScript/JS-specific extraction layer is implemented here — all generic
125
+ infrastructure (SQLite, sqlite-vec, hybrid query, snippet packing) is inherited from
126
+ `KGModule`.
127
+
128
+ ## Configuration
129
+
130
+ In your project's `pyproject.toml`:
131
+
132
+ ```toml
133
+ [tool.tscodekg]
134
+ include = ["src"] # top-level dirs to index (empty = all)
135
+ exclude = ["__tests__"] # extra dirs to skip
136
+ ```
137
+
138
+ ## Author
139
+
140
+ Eric G. Suchanek, PhD — Flux Frontiers
141
+
142
+ ## License
143
+
144
+ Elastic-2.0
@@ -0,0 +1,162 @@
1
+ # pyproject.toml — TypeScriptKG package configuration (PEP 621)
2
+ #
3
+ # Author: Eric G. Suchanek, PhD
4
+ #
5
+ # Build system : Poetry 2.x with PEP 621 [project] table
6
+ #
7
+ # Quick install (pip)
8
+ # -------------------
9
+ # pip install -e ".[dev]" core + dev tools
10
+ # pip install -e "." core runtime only
11
+ #
12
+ # First-time setup
13
+ # ----------------
14
+ # python -m venv .venv
15
+ # source .venv/bin/activate
16
+ # pip install -e ".[dev]"
17
+ #
18
+ # Build KG indices
19
+ # ----------------
20
+ # tscodekg build --repo .
21
+
22
+ [build-system]
23
+ requires = ["poetry-core>=2.0.0"]
24
+ build-backend = "poetry.core.masonry.api"
25
+
26
+ [tool.poetry]
27
+ packages = [{ include = "tscode_kg", from = "src" }]
28
+
29
+ [project]
30
+ name = "tscode-kg"
31
+ version = "0.2.0"
32
+ description = "Knowledge graph for TypeScript/JavaScript codebases — AST extraction, hybrid semantic+structural search"
33
+ readme = "README.md"
34
+ license = "Elastic-2.0"
35
+ authors = [
36
+ { name = "Eric G. Suchanek, PhD", email = "suchanek@mac.com" }
37
+ ]
38
+ keywords = ["knowledge-graph", "typescript", "javascript", "ast", "sqlite-vec", "sqlite", "semantic-search"]
39
+ classifiers = [
40
+ "Development Status :: 3 - Alpha",
41
+ "Intended Audience :: Developers",
42
+ "Topic :: Software Development :: Libraries :: Python Modules",
43
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
44
+ "Programming Language :: Python :: 3",
45
+ "Programming Language :: Python :: 3.12",
46
+ "Programming Language :: Python :: 3.13",
47
+ ]
48
+ requires-python = ">=3.12,<3.14"
49
+ dependencies = [
50
+ # Core: tree-sitter AST extraction + CLI skeleton. kgmodule-utils supplies
51
+ # the NodeSpec/EdgeSpec/KGExtractor types the extractor is built on;
52
+ # click drives the tscodekg command group (subcommands lazily import the
53
+ # heavier build/query/mcp pieces below).
54
+ "tree-sitter>=0.25.0",
55
+ "tree-sitter-typescript>=0.23.2",
56
+ "rich>=14.3.3,<15",
57
+ "kgmodule-utils[semantic,sqlite-vec]>=0.8.0",
58
+ "click>=8.1.0,<9",
59
+ # Upper-bounded: mcp 2.0 removed the bundled `mcp.server.fastmcp` module
60
+ # (FastMCP was split out into the standalone `fastmcp` package) and rebuilt
61
+ # mcp.server around new submodules. src/tscode_kg/mcp_server.py imports
62
+ # FastMCP from mcp, so an unbounded floor lets a clean install pull 2.x and
63
+ # break `tscodekg-mcp` at import time. Lift this only alongside a port to
64
+ # the standalone fastmcp package.
65
+ "mcp>=1.0.0,<2",
66
+ "networkx>=3.0",
67
+ ]
68
+
69
+ [project.optional-dependencies]
70
+ # Cross-KG: PyCodeKG (Python codebases) and DocKG (docs) available from within tscode_kg
71
+ kgdeps = [
72
+ "pycode-kg>=0.20.0,<0.21",
73
+ "doc-kg>=0.18.1",
74
+ ]
75
+ # Streamlit graph explorer + plotly timeline.
76
+ # Version brackets follow pycode_kg's proven lockfile versions.
77
+ viz = [
78
+ "plotly>=6.8.0,<6.9",
79
+ "pyvis>=0.3.2,<0.4",
80
+ "streamlit>=1.59.0,<1.60",
81
+ ]
82
+ # PyVista/PyQt5 3-D visualizer.
83
+ # NOTE: deliberately plain `pyvista`, not `pyvista[jupyter]` — the jupyter
84
+ # extra's trame/jupyter subtree sends Poetry's resolver into runaway
85
+ # marker-split re-solving (hours, not minutes). The Qt interactor does not
86
+ # need it; for in-notebook rendering or HTML export install
87
+ # `pip install "pyvista[jupyter]"` manually.
88
+ viz3d = [
89
+ "markdown>=3.10,<3.11",
90
+ "param>=2.4,<2.5",
91
+ "PyQt5>=5.15.11,<5.16",
92
+ "pyvista>=0.48.4,<0.49",
93
+ "pyvistaqt>=0.12,<0.13",
94
+ "trame-vtk>=2.11.8,<2.12",
95
+ ]
96
+ dev = [
97
+ "detect-secrets>=1.5.0",
98
+ # This repo is Python — pycodekg indexes it and runs in the pre-commit hook.
99
+ "pycode-kg>=0.20.0,<0.21",
100
+ "ty>=0.0.41",
101
+ "pre-commit>=4.5.1",
102
+ "pylint>=4.0.5",
103
+ "pytest>=8.0.0",
104
+ "pytest-cov>=5.0.0",
105
+ "ruff>=0.4.0",
106
+ ]
107
+
108
+ [project.urls]
109
+ Homepage = "https://github.com/Flux-Frontiers/tscode_kg"
110
+ Repository = "https://github.com/Flux-Frontiers/tscode_kg"
111
+
112
+ [project.scripts]
113
+ tscodekg = "tscode_kg.cli.main:cli"
114
+ tscodekg-analyze = "tscode_kg.cli.cmd_analyze:analyze"
115
+ tscodekg-build = "tscode_kg.cli.cmd_build:build"
116
+ tscodekg-centrality = "tscode_kg.cli.cmd_centrality:centrality"
117
+ tscodekg-download-model = "tscode_kg.cli.cmd_model:download_model"
118
+ tscodekg-init = "tscode_kg.cli.cmd_init:init"
119
+ tscodekg-install-hooks = "tscode_kg.cli.cmd_hooks:install_hooks"
120
+ tscodekg-query = "tscode_kg.cli.cmd_query:query"
121
+ tscodekg-pack = "tscode_kg.cli.cmd_query:pack"
122
+ tscodekg-viz = "tscode_kg.cli.cmd_viz:viz"
123
+ tscodekg-viz3d = "tscode_kg.cli.cmd_viz:viz3d"
124
+ tscodekg-viz-timeline = "tscode_kg.cli.cmd_viz:viz_timeline"
125
+ tscodekg-mcp = "tscode_kg.mcp_server:main"
126
+
127
+ [tool.ruff]
128
+ line-length = 100
129
+ target-version = "py312"
130
+
131
+ [tool.ruff.lint]
132
+ select = ["E", "F", "W", "I", "UP"]
133
+ ignore = ["E501"]
134
+
135
+ [tool.ty.environment]
136
+ python-version = "3.12"
137
+ root = ["src"]
138
+
139
+ [tool.ty.rules]
140
+ # Be lenient about third-party stubs (mirrors mypy's ignore_missing_imports).
141
+ unresolved-import = "ignore"
142
+ # viz3d.py carries `# ty: ignore` suppressions for param/PyQt5/pyvista false
143
+ # positives. Those libraries live in the optional viz/viz3d extras, so in the
144
+ # lean CI install the imports are Unknown, the errors don't fire, and the
145
+ # ignores look "unused". Don't fail the build on that — the suppressions are
146
+ # still honored locally where the extras (and the errors) are present.
147
+ unused-ignore-comment = "ignore"
148
+
149
+ [tool.pytest.ini_options]
150
+ testpaths = ["tests"]
151
+ addopts = "-v --tb=short"
152
+ markers = [
153
+ "slow: marks tests as slow",
154
+ "integration: marks tests that require real model/sqlite-vec",
155
+ ]
156
+
157
+ [tool.tscodekg]
158
+ include = ["src"]
159
+
160
+ # This repo is Python — PyCodeKG (not TypeScriptKG) indexes it on commit.
161
+ [tool.pycodekg]
162
+ include = ["src"]
@@ -0,0 +1,42 @@
1
+ """
2
+ tscode_kg: Knowledge graph for TypeScript/JavaScript codebases.
3
+
4
+ Pure tree-sitter AST extraction → SQLite (authoritative) → sqlite-vec (semantic index).
5
+
6
+ Primary entry point::
7
+
8
+ from tscode_kg import TypeScriptKG
9
+
10
+ kg = TypeScriptKG(repo_root="/path/to/ts-repo")
11
+ stats = kg.build(wipe=True)
12
+ result = kg.query("authentication middleware")
13
+ pack = kg.pack("error handling utilities")
14
+ pack.save("context.md")
15
+
16
+ KGExtractor SDK::
17
+
18
+ from tscode_kg import TSCodeExtractor
19
+ """
20
+
21
+ __version__ = "0.2.0"
22
+ __author__ = "Eric G. Suchanek, PhD"
23
+
24
+ from tscode_kg.extractor import TSCodeExtractor
25
+
26
+ __all__ = [
27
+ "TSCodeExtractor",
28
+ ]
29
+
30
+ try:
31
+ from tscode_kg.analysis import TSCodeKGAnalyzer
32
+ from tscode_kg.kg import BuildStats, QueryResult, SnippetPack, TypeScriptKG
33
+
34
+ __all__ += [
35
+ "TypeScriptKG",
36
+ "TSCodeKGAnalyzer",
37
+ "BuildStats",
38
+ "QueryResult",
39
+ "SnippetPack",
40
+ ]
41
+ except ImportError:
42
+ pass # kgmodule-utils[semantic] not installed; extractor still works standalone
@@ -0,0 +1,6 @@
1
+ """Allow ``python -m tscode_kg`` to invoke the CLI."""
2
+
3
+ from tscode_kg.cli.main import cli
4
+
5
+ if __name__ == "__main__":
6
+ cli()