codmap 0.0.3__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.
- codmap-0.0.3/LICENSE +21 -0
- codmap-0.0.3/PKG-INFO +245 -0
- codmap-0.0.3/README.md +209 -0
- codmap-0.0.3/codemap/__init__.py +10 -0
- codmap-0.0.3/codemap/apidiff.py +208 -0
- codmap-0.0.3/codemap/arch.py +190 -0
- codmap-0.0.3/codemap/cli.py +718 -0
- codmap-0.0.3/codemap/diagnostics.py +256 -0
- codmap-0.0.3/codemap/extract/__init__.py +10 -0
- codmap-0.0.3/codemap/extract/attrflow.py +230 -0
- codmap-0.0.3/codemap/extract/behavior.py +771 -0
- codmap-0.0.3/codemap/extract/dataflow.py +97 -0
- codmap-0.0.3/codemap/extract/dispatch.py +248 -0
- codmap-0.0.3/codemap/extract/griffe_extractor.py +496 -0
- codmap-0.0.3/codemap/extract/gsource.py +83 -0
- codmap-0.0.3/codemap/extract/roots.py +427 -0
- codmap-0.0.3/codemap/freshness.py +94 -0
- codmap-0.0.3/codemap/incremental.py +195 -0
- codmap-0.0.3/codemap/integrations/__init__.py +51 -0
- codmap-0.0.3/codemap/integrations/base.py +196 -0
- codmap-0.0.3/codemap/integrations/cocoindex.py +78 -0
- codmap-0.0.3/codemap/integrations/gate.py +58 -0
- codmap-0.0.3/codemap/integrations/gitnexus.py +93 -0
- codmap-0.0.3/codemap/integrations/registry.py +69 -0
- codmap-0.0.3/codemap/integrations/transport.py +46 -0
- codmap-0.0.3/codemap/model.py +178 -0
- codmap-0.0.3/codemap/provenance.py +248 -0
- codmap-0.0.3/codemap/query.py +1164 -0
- codmap-0.0.3/codemap/scope.py +212 -0
- codmap-0.0.3/codemap/serve/__init__.py +26 -0
- codmap-0.0.3/codemap/serve/_scip_pb2.py +100 -0
- codmap-0.0.3/codemap/serve/api_surface.py +60 -0
- codmap-0.0.3/codemap/serve/apidiff.py +83 -0
- codmap-0.0.3/codemap/serve/architecture.py +101 -0
- codmap-0.0.3/codemap/serve/audit.py +176 -0
- codmap-0.0.3/codemap/serve/check.py +80 -0
- codmap-0.0.3/codemap/serve/ctags.py +203 -0
- codmap-0.0.3/codemap/serve/impact.py +84 -0
- codmap-0.0.3/codemap/serve/livingdocs.py +174 -0
- codmap-0.0.3/codemap/serve/mcp_server.py +278 -0
- codmap-0.0.3/codemap/serve/mermaid.py +120 -0
- codmap-0.0.3/codemap/serve/pack.py +93 -0
- codmap-0.0.3/codemap/serve/rag.py +142 -0
- codmap-0.0.3/codemap/serve/review.py +197 -0
- codmap-0.0.3/codemap/serve/scip.py +183 -0
- codmap-0.0.3/codemap/serve/semantic.py +71 -0
- codmap-0.0.3/codemap/serve/server.py +43 -0
- codmap-0.0.3/codemap/serve/session.py +482 -0
- codmap-0.0.3/codemap/serve/subsystems.py +85 -0
- codmap-0.0.3/codemap/serve/vault.py +156 -0
- codmap-0.0.3/codemap/store.py +28 -0
- codmap-0.0.3/codemap/tomlio.py +59 -0
- codmap-0.0.3/codmap.egg-info/PKG-INFO +245 -0
- codmap-0.0.3/codmap.egg-info/SOURCES.txt +103 -0
- codmap-0.0.3/codmap.egg-info/dependency_links.txt +1 -0
- codmap-0.0.3/codmap.egg-info/entry_points.txt +2 -0
- codmap-0.0.3/codmap.egg-info/requires.txt +9 -0
- codmap-0.0.3/codmap.egg-info/top_level.txt +1 -0
- codmap-0.0.3/pyproject.toml +75 -0
- codmap-0.0.3/setup.cfg +4 -0
- codmap-0.0.3/tests/test_epistemic.py +70 -0
- codmap-0.0.3/tests/test_gitnexus_router.py +128 -0
- codmap-0.0.3/tests/test_impact_depth.py +122 -0
- codmap-0.0.3/tests/test_integrations.py +198 -0
- codmap-0.0.3/tests/test_issue3_serve_freshness.py +89 -0
- codmap-0.0.3/tests/test_livingdocs.py +104 -0
- codmap-0.0.3/tests/test_m0_api_surface.py +91 -0
- codmap-0.0.3/tests/test_m11_argcontract.py +54 -0
- codmap-0.0.3/tests/test_m12_dataflow.py +75 -0
- codmap-0.0.3/tests/test_m15_review.py +123 -0
- codmap-0.0.3/tests/test_m16_architecture.py +96 -0
- codmap-0.0.3/tests/test_m17_mcp.py +119 -0
- codmap-0.0.3/tests/test_m18_freshness.py +86 -0
- codmap-0.0.3/tests/test_m1_5_semantics.py +114 -0
- codmap-0.0.3/tests/test_m1_query.py +82 -0
- codmap-0.0.3/tests/test_m2_views.py +101 -0
- codmap-0.0.3/tests/test_m3_serve.py +180 -0
- codmap-0.0.3/tests/test_m4_behavior.py +115 -0
- codmap-0.0.3/tests/test_m5_deep.py +56 -0
- codmap-0.0.3/tests/test_m6_repo_scope.py +177 -0
- codmap-0.0.3/tests/test_m7_dispatch.py +89 -0
- codmap-0.0.3/tests/test_m9_family.py +76 -0
- codmap-0.0.3/tests/test_r1c13_callgraph_accuracy.py +72 -0
- codmap-0.0.3/tests/test_r1c13_grep_vs_graph.py +69 -0
- codmap-0.0.3/tests/test_r1c16_semantic.py +216 -0
- codmap-0.0.3/tests/test_r1c20_attribute_edges.py +148 -0
- codmap-0.0.3/tests/test_r1c21_flat_layout.py +319 -0
- codmap-0.0.3/tests/test_r1c22_source_visible_refs.py +197 -0
- codmap-0.0.3/tests/test_r1c23_hard_python.py +277 -0
- codmap-0.0.3/tests/test_r1c24_test_mapping.py +173 -0
- codmap-0.0.3/tests/test_r1c25_provenance.py +268 -0
- codmap-0.0.3/tests/test_r1c26_deep_union.py +134 -0
- codmap-0.0.3/tests/test_r1c27_config_honesty.py +207 -0
- codmap-0.0.3/tests/test_r1c2_ctags.py +171 -0
- codmap-0.0.3/tests/test_r1c3_arch_contract.py +186 -0
- codmap-0.0.3/tests/test_r1c3_dogfood.py +25 -0
- codmap-0.0.3/tests/test_r1c4_complexity.py +150 -0
- codmap-0.0.3/tests/test_r1c5_apidiff.py +168 -0
- codmap-0.0.3/tests/test_r1c6_pack.py +120 -0
- codmap-0.0.3/tests/test_r1c7_edge_vocab.py +52 -0
- codmap-0.0.3/tests/test_r1c8_deadcode.py +121 -0
- codmap-0.0.3/tests/test_r1c9_incremental.py +209 -0
- codmap-0.0.3/tests/test_scip_export.py +156 -0
- codmap-0.0.3/tests/test_scope.py +139 -0
- codmap-0.0.3/tests/test_subsystems.py +134 -0
codmap-0.0.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kogriv
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
codmap-0.0.3/PKG-INFO
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codmap
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Static analyzer that turns a package's source into a queryable code graph.
|
|
5
|
+
Author-email: kogriv <kogriv@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/kogriv/codemap
|
|
8
|
+
Project-URL: Source, https://github.com/kogriv/codemap
|
|
9
|
+
Project-URL: Issues, https://github.com/kogriv/codemap/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/kogriv/codemap/blob/main/CHANGELOG.md
|
|
11
|
+
Project-URL: Documentation, https://github.com/kogriv/codemap/tree/main/docs
|
|
12
|
+
Keywords: static-analysis,code-graph,call-graph,dependency-graph,code-intelligence,ast,griffe,mcp,rag,scip
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: griffe>=2.0
|
|
29
|
+
Requires-Dist: networkx>=3.0
|
|
30
|
+
Requires-Dist: jedi>=0.19
|
|
31
|
+
Provides-Extra: mcp
|
|
32
|
+
Requires-Dist: mcp>=2.0; extra == "mcp"
|
|
33
|
+
Provides-Extra: scip
|
|
34
|
+
Requires-Dist: protobuf>=5.26; extra == "scip"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# codemap
|
|
38
|
+
|
|
39
|
+
**A static analyzer that turns a Python package's source into a queryable code graph.**
|
|
40
|
+
It reads source only — no runtime import — so it works on any package and stays decoupled from
|
|
41
|
+
the code it analyzes. One canonical, deterministic graph store → many renders: API surface,
|
|
42
|
+
dependency/architecture audit, RAG chunks, an Obsidian vault, mermaid diagrams, change-set review,
|
|
43
|
+
and a **SCIP index** for interop with Sourcegraph / Glean and other precise-code-intelligence tools.
|
|
44
|
+
|
|
45
|
+
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
46
|
+
|
|
47
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.12, **530 tests with no failures on
|
|
48
|
+
Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
|
|
49
|
+
wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 31 ops (28 exposed
|
|
50
|
+
as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
|
|
51
|
+
v1 boundaries), **[BACKLOG.md](BACKLOG.md)** (roadmap), and **[research/](research/)** (tool landscape).
|
|
52
|
+
|
|
53
|
+
## Why it exists
|
|
54
|
+
|
|
55
|
+
Docs describe code and CLIs call code; without a parsed map of the code both are done blind. codemap
|
|
56
|
+
builds that map as **facts**: modules, classes, functions, the public API surface, import/inherit/
|
|
57
|
+
export edges, best-effort call edges, registry-family `implements` links, string-key column dataflow,
|
|
58
|
+
and per-call argument contracts — then answers questions over it.
|
|
59
|
+
|
|
60
|
+
Design principles: **source-only** (static `ast`/`griffe`, never imports the target), **deterministic**
|
|
61
|
+
(canonical sorted JSON, no timestamps — diffable), **CLI-AI-first** (JSON by default, stable exit
|
|
62
|
+
codes), **honest** (approximations are labeled, not hidden).
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
**Python 3.11+** — the range is measured on 3.11–3.14 in CI, not assumed ([docs/ci.md](docs/ci.md)).
|
|
67
|
+
|
|
68
|
+
> **The distribution is `codmap`; everything else is `codemap`.** `codemap` was already taken on
|
|
69
|
+
> PyPI, so you install `codmap` — and then the command, the import and this repository are all
|
|
70
|
+
> spelled `codemap`, as they always were.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install codmap # then: codemap build ./yourpkg
|
|
74
|
+
|
|
75
|
+
# optional: MCP server (`codemap serve --mcp`)
|
|
76
|
+
pip install 'codmap[mcp]'
|
|
77
|
+
|
|
78
|
+
# optional: SCIP export (`codemap export scip`)
|
|
79
|
+
pip install 'codmap[scip]'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Until the first release lands on PyPI, install straight from the repository instead:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install git+https://github.com/kogriv/codemap
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Working on codemap itself, from a clone:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
uv venv && uv pip install -e '.[mcp,scip]' # or: pip install -e '.[mcp,scip]'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Dependencies: `griffe` (structure), `networkx` (query backend), `jedi` (deep call resolution).
|
|
95
|
+
Optional extras: `mcp` (Model Context Protocol server), `scip` (protobuf, for SCIP export).
|
|
96
|
+
|
|
97
|
+
## Quickstart
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# build the canonical graph of a package
|
|
101
|
+
codemap build ./yourpkg -o graph.json
|
|
102
|
+
|
|
103
|
+
# repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact
|
|
104
|
+
codemap build ./yourpkg --deep --mode full --consumer ./tests --docs ./docs -o graph.json
|
|
105
|
+
|
|
106
|
+
# ask about a symbol (JSON by default; --format text for humans)
|
|
107
|
+
codemap query analyze_zones --graph graph.json
|
|
108
|
+
|
|
109
|
+
# reports over the graph
|
|
110
|
+
codemap report architecture --graph graph.json # layers, coupling, god-objects, cycles
|
|
111
|
+
codemap report dependencies --graph graph.json
|
|
112
|
+
codemap report dead-code --graph graph.json
|
|
113
|
+
codemap report impact --symbol MyClass --graph graph.json
|
|
114
|
+
|
|
115
|
+
# change-set review straight from a diff → risk-sorted dossier
|
|
116
|
+
git diff | codemap review - --graph graph.json
|
|
117
|
+
|
|
118
|
+
# exports (see docs/export.md)
|
|
119
|
+
codemap export rag --graph graph.json -o chunks.jsonl
|
|
120
|
+
codemap export mermaid --graph graph.json --mkind class
|
|
121
|
+
codemap export vault --graph graph.json -o vault/
|
|
122
|
+
codemap export scip --graph graph.json -o index.scip # SCIP index (needs [scip] extra)
|
|
123
|
+
codemap export ctags --graph graph.json -o tags # universal-ctags tags file
|
|
124
|
+
|
|
125
|
+
# semantic (concept) search via an opt-in adapter → codemap symbols (needs the tool + opt-in)
|
|
126
|
+
codemap semantic "detect swing pivots" --build ./pkg --root pkg
|
|
127
|
+
|
|
128
|
+
# token-budgeted context pack — most relevant graph slice under N tokens (ranked; --seed to focus)
|
|
129
|
+
codemap pack --graph graph.json --budget 2000 --seed analyze_zones
|
|
130
|
+
|
|
131
|
+
# warm resident process — JSON requests over stdin/stdout (29 ops)
|
|
132
|
+
codemap serve --graph graph.json --source-root .
|
|
133
|
+
|
|
134
|
+
# …or expose the same surface as MCP tools for an AI-agent host (needs [mcp] extra)
|
|
135
|
+
codemap serve --graph graph.json --source-root . --mcp
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## What it answers
|
|
139
|
+
|
|
140
|
+
- **Structure & API** — public surface, signatures, docstrings, deprecation.
|
|
141
|
+
- **Dependencies & architecture** — import cycles, layers + direction/violations, coupling
|
|
142
|
+
(Ca/Ce/instability), god-objects & call-hubs, per-function complexity (cyclomatic / MI)
|
|
143
|
+
blended with structural coupling.
|
|
144
|
+
- **Impact / blast radius** — who uses X, across the whole repo (core + tests + docs).
|
|
145
|
+
- **Change review** — a diff → the symbols it touches, their callers, signature-change surface,
|
|
146
|
+
touched columns, cross-root consumers, risk rank.
|
|
147
|
+
- **Dispatch seams** — registry/factory families and the Protocol each impl satisfies.
|
|
148
|
+
- **Dataflow** — producers/consumers of a string-keyed DataFrame column.
|
|
149
|
+
- **Semantic search** (opt-in) — a concept query routed to an external adapter, with each fuzzy hit
|
|
150
|
+
resolved to the exact codemap symbol at its location (`codemap semantic`). See [docs/integrations.md](docs/integrations.md).
|
|
151
|
+
- **Context pack** — the most relevant slice of the graph under a token budget, ranked by importance or
|
|
152
|
+
by relevance to seed symbols (`codemap pack --budget N [--seed X]`). See [docs/pack.md](docs/pack.md).
|
|
153
|
+
- **Interop** — export the graph as a [SCIP](https://scip-code.org/) index (definitions + symbol
|
|
154
|
+
info + inherits/implements relationships) so Sourcegraph, Glean and other SCIP consumers can drive
|
|
155
|
+
go-to-definition, symbol search and type hierarchy over it. See [docs/export.md](docs/export.md).
|
|
156
|
+
|
|
157
|
+
## How it compares
|
|
158
|
+
|
|
159
|
+
codemap is **the precise structural leg for index-free AI agents** — it complements embeddings-RAG and
|
|
160
|
+
Repomix-style packing rather than competing with them. Its bet is to be the best *deterministic, diffable,
|
|
161
|
+
provenance-aware* graph in that slot, and to interoperate outward (SCIP, ctags) instead of locking the graph
|
|
162
|
+
away.
|
|
163
|
+
|
|
164
|
+
> **A code graph an agent can trust: source-only, deterministic, diffable — no index to go stale, no LSP to provision.**
|
|
165
|
+
|
|
166
|
+
The [research track](research/) measures this against the field hands-on, on a shared benchmark scope. The
|
|
167
|
+
[positioning doc](research/positioning.md) is the publication layer — the narrative and the numbers behind the
|
|
168
|
+
claims above; [comparison.md](research/comparison.md) is the coverage matrix that backs them.
|
|
169
|
+
|
|
170
|
+
Honesty is part of the bet: the call graph is a **measured lower bound**, not a guess. [docs/accuracy.md](docs/accuracy.md)
|
|
171
|
+
reports it — 100% precision / 100% decidable-recall on a hand-labeled suite, an openly-stated ~60% recall
|
|
172
|
+
against *all* true edges (the price of Python's dynamism), and a grep-vs-graph proof that the graph is ~2×
|
|
173
|
+
cheaper than grep for impact on unique names, tens of × on polymorphic ones, and no cheaper for locating a
|
|
174
|
+
symbol.
|
|
175
|
+
|
|
176
|
+
## Dogfooding
|
|
177
|
+
|
|
178
|
+
codemap is validated end-to-end against a real external package. Place a target repo as a sibling and
|
|
179
|
+
run the full flow against its package — e.g. `codemap build ../bquant/bquant` (point at the package
|
|
180
|
+
directory that holds `__init__.py`, not the repo root) — treating codemap purely as a third-party tool.
|
|
181
|
+
The `gaps/` directory records those dogfood runs: each is a pre-registered set of hypotheses, a run on
|
|
182
|
+
the live graph, findings, and the milestone that closed them.
|
|
183
|
+
|
|
184
|
+
## Documentation
|
|
185
|
+
|
|
186
|
+
- **[DESIGN.md](DESIGN.md)** — product design, the query catalog, v1 boundaries.
|
|
187
|
+
- **[docs/export.md](docs/export.md)** — export recipes: RAG, mermaid, Obsidian vault, SCIP + ctags interop.
|
|
188
|
+
- **[docs/accuracy.md](docs/accuracy.md)** — measured call-graph accuracy, the honest static ceiling, and
|
|
189
|
+
the grep-vs-graph value proof (both harnesses guarded in CI).
|
|
190
|
+
- **[docs/architecture-contracts.md](docs/architecture-contracts.md)** — declare the intended architecture
|
|
191
|
+
in `codemap.toml` and enforce it with `codemap check` (CI gate; codemap dogfoods its own).
|
|
192
|
+
- **[docs/api-diff.md](docs/api-diff.md)** — `codemap diff` two snapshots for added/removed/changed symbols
|
|
193
|
+
and API breaking-change detection (release gate + `review --base`).
|
|
194
|
+
- **[docs/integrations.md](docs/integrations.md)** — the opt-in router/adapter layer over external tools
|
|
195
|
+
(`codemap route` / `codemap semantic`); license policy; adding an integration.
|
|
196
|
+
- **[docs/dead-code.md](docs/dead-code.md)** — graded dead-code candidates (high/medium/low + provenance
|
|
197
|
+
reason) with a `[dead_code]` whitelist and `--min-confidence` filter.
|
|
198
|
+
- **[docs/pack.md](docs/pack.md)** — `codemap pack`: PageRank ranking + token-budgeted context slice for
|
|
199
|
+
AI agents (global importance or seed-focused relevance).
|
|
200
|
+
- **[docs/attribute-edges.md](docs/attribute-edges.md)** — `accesses` edges: who reads/writes a class field,
|
|
201
|
+
honest field-level `impact` (`accessors`; `unknown` vs `none`).
|
|
202
|
+
- **[docs/incremental.md](docs/incremental.md)** — `codemap build --incremental`: recompute only changed
|
|
203
|
+
modules (~12× faster on `--deep`), byte-identical on the fast tier.
|
|
204
|
+
- **[docs/test-mapping.md](docs/test-mapping.md)** — `codemap tests <symbol>`: which tests exercise a
|
|
205
|
+
symbol, as runnable pytest node ids, with the measured distance cutoff and an `unknown` that never
|
|
206
|
+
pretends to be "untested".
|
|
207
|
+
- **[docs/hard-python.md](docs/hard-python.md)** — what the extractor does with metaclasses, dynamic
|
|
208
|
+
classes, star imports, quoted annotations, `.pyi` stubs and symlinked trees; and the conditions where it
|
|
209
|
+
warns instead of answering.
|
|
210
|
+
- **[docs/provenance.md](docs/provenance.md)** — the `provenance` block: which tool, which tier, which
|
|
211
|
+
input tree built a graph; what stays in the sidecar; the schema-mismatch warning and `diff`'s
|
|
212
|
+
comparability check.
|
|
213
|
+
- **[docs/flat-layout.md](docs/flat-layout.md)** — flat module directories (sibling imports, no
|
|
214
|
+
`__init__.py`): labelled `resolution="flat"` edges, and the empty-import-graph warning that stops a
|
|
215
|
+
vacuous graph from reading as a clean one.
|
|
216
|
+
- **[research/blog/](research/blog/)** — **the build-story series**: field notes on building
|
|
217
|
+
codemap and measuring it against rival tools (EN + RU). See the section below.
|
|
218
|
+
- **[BACKLOG.md](BACKLOG.md)** — milestones M0–M18, the research track (R1), and deferred work.
|
|
219
|
+
- **[gaps/](gaps/)** — dogfood runs, coverage analysis, the living [axis register](gaps/dogfood_axes.md).
|
|
220
|
+
- **[research/](research/)** — survey of adjacent code-analysis tools and how codemap relates to each
|
|
221
|
+
(integrate / wrap / learn); source of the R1 capability roadmap. See
|
|
222
|
+
**[research/positioning.md](research/positioning.md)** for the publication-layer narrative and
|
|
223
|
+
**[research/comparison.md](research/comparison.md)** for the hands-on coverage matrix.
|
|
224
|
+
|
|
225
|
+
## Writing — the build-story series
|
|
226
|
+
|
|
227
|
+
Field notes on building codemap, and on measuring it honestly against the nearest rival
|
|
228
|
+
tools. Published here in the repo; every post exists in English and Russian.
|
|
229
|
+
**Index: [research/blog/](research/blog/README.md).**
|
|
230
|
+
|
|
231
|
+
| # | Post | |
|
|
232
|
+
|---|------|---|
|
|
233
|
+
| 0 | **A code graph an agent can trust** — what codemap is, the bet it makes, and the honest limits. | [EN](research/blog/00-a-code-graph-an-agent-can-trust.md) · [RU](research/blog/00-a-code-graph-an-agent-can-trust.ru.md) |
|
|
234
|
+
| 1 | **The competitor wasn't broken. We were.** — I nearly published that a rival's impact analysis was broken. The bug was my `PATH`. | [EN](research/blog/01-the-competitor-wasnt-broken.md) · [RU](research/blog/01-the-competitor-wasnt-broken.ru.md) |
|
|
235
|
+
| 2 | **The one that does more — and why that's fine.** — a 1.7 GB hybrid rival that proved the thesis instead of threatening it. | [EN](research/blog/02-the-one-that-does-more.md) · [RU](research/blog/02-the-one-that-does-more.ru.md) |
|
|
236
|
+
| 3 | **The competitor that does *less* — and that's why I take it.** — the emptiest coverage row was the most useful find. For its license, not its features. | [EN](research/blog/03-the-one-that-does-less.md) · [RU](research/blog/03-the-one-that-does-less.ru.md) |
|
|
237
|
+
| 4 | **My determinism test went red. The tool was fine.** — the input was moving under it, and the artifact could not say so. How the graph learned to name what built it. | [EN](research/blog/04-the-determinism-test-that-was-right.md) · [RU](research/blog/04-the-determinism-test-that-was-right.ru.md) |
|
|
238
|
+
|
|
239
|
+
New here? Read **1 → 0 → 2 → 3 → 4**. Every number in every post reproduces from a
|
|
240
|
+
[tool card](research/tools/) or the [comparison hub](research/comparison.md) — measurements,
|
|
241
|
+
not verdict.
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
[MIT](LICENSE).
|
codmap-0.0.3/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# codemap
|
|
2
|
+
|
|
3
|
+
**A static analyzer that turns a Python package's source into a queryable code graph.**
|
|
4
|
+
It reads source only — no runtime import — so it works on any package and stays decoupled from
|
|
5
|
+
the code it analyzes. One canonical, deterministic graph store → many renders: API surface,
|
|
6
|
+
dependency/architecture audit, RAG chunks, an Obsidian vault, mermaid diagrams, change-set review,
|
|
7
|
+
and a **SCIP index** for interop with Sourcegraph / Glean and other precise-code-intelligence tools.
|
|
8
|
+
|
|
9
|
+
[](https://github.com/kogriv/codemap/actions/workflows/ci.yml)
|
|
10
|
+
|
|
11
|
+
**Status:** 🟢 M0–M20 implemented + research track (R1/R2) — schema 0.12, **530 tests with no failures on
|
|
12
|
+
Python 3.11–3.14** ([in CI](docs/ci.md): the full suite including the dogfood pass, a determinism check, a
|
|
13
|
+
wheel smoke test, and ctags/SCIP interop against the real CLIs), warm serve surface with 31 ops (28 exposed
|
|
14
|
+
as MCP tools), and SCIP export. See **[DESIGN.md](DESIGN.md)** (product design &
|
|
15
|
+
v1 boundaries), **[BACKLOG.md](BACKLOG.md)** (roadmap), and **[research/](research/)** (tool landscape).
|
|
16
|
+
|
|
17
|
+
## Why it exists
|
|
18
|
+
|
|
19
|
+
Docs describe code and CLIs call code; without a parsed map of the code both are done blind. codemap
|
|
20
|
+
builds that map as **facts**: modules, classes, functions, the public API surface, import/inherit/
|
|
21
|
+
export edges, best-effort call edges, registry-family `implements` links, string-key column dataflow,
|
|
22
|
+
and per-call argument contracts — then answers questions over it.
|
|
23
|
+
|
|
24
|
+
Design principles: **source-only** (static `ast`/`griffe`, never imports the target), **deterministic**
|
|
25
|
+
(canonical sorted JSON, no timestamps — diffable), **CLI-AI-first** (JSON by default, stable exit
|
|
26
|
+
codes), **honest** (approximations are labeled, not hidden).
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
**Python 3.11+** — the range is measured on 3.11–3.14 in CI, not assumed ([docs/ci.md](docs/ci.md)).
|
|
31
|
+
|
|
32
|
+
> **The distribution is `codmap`; everything else is `codemap`.** `codemap` was already taken on
|
|
33
|
+
> PyPI, so you install `codmap` — and then the command, the import and this repository are all
|
|
34
|
+
> spelled `codemap`, as they always were.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install codmap # then: codemap build ./yourpkg
|
|
38
|
+
|
|
39
|
+
# optional: MCP server (`codemap serve --mcp`)
|
|
40
|
+
pip install 'codmap[mcp]'
|
|
41
|
+
|
|
42
|
+
# optional: SCIP export (`codemap export scip`)
|
|
43
|
+
pip install 'codmap[scip]'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Until the first release lands on PyPI, install straight from the repository instead:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install git+https://github.com/kogriv/codemap
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Working on codemap itself, from a clone:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv venv && uv pip install -e '.[mcp,scip]' # or: pip install -e '.[mcp,scip]'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Dependencies: `griffe` (structure), `networkx` (query backend), `jedi` (deep call resolution).
|
|
59
|
+
Optional extras: `mcp` (Model Context Protocol server), `scip` (protobuf, for SCIP export).
|
|
60
|
+
|
|
61
|
+
## Quickstart
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# build the canonical graph of a package
|
|
65
|
+
codemap build ./yourpkg -o graph.json
|
|
66
|
+
|
|
67
|
+
# repo-scoped: add consumers (tests/examples) + docs for blast-radius/impact
|
|
68
|
+
codemap build ./yourpkg --deep --mode full --consumer ./tests --docs ./docs -o graph.json
|
|
69
|
+
|
|
70
|
+
# ask about a symbol (JSON by default; --format text for humans)
|
|
71
|
+
codemap query analyze_zones --graph graph.json
|
|
72
|
+
|
|
73
|
+
# reports over the graph
|
|
74
|
+
codemap report architecture --graph graph.json # layers, coupling, god-objects, cycles
|
|
75
|
+
codemap report dependencies --graph graph.json
|
|
76
|
+
codemap report dead-code --graph graph.json
|
|
77
|
+
codemap report impact --symbol MyClass --graph graph.json
|
|
78
|
+
|
|
79
|
+
# change-set review straight from a diff → risk-sorted dossier
|
|
80
|
+
git diff | codemap review - --graph graph.json
|
|
81
|
+
|
|
82
|
+
# exports (see docs/export.md)
|
|
83
|
+
codemap export rag --graph graph.json -o chunks.jsonl
|
|
84
|
+
codemap export mermaid --graph graph.json --mkind class
|
|
85
|
+
codemap export vault --graph graph.json -o vault/
|
|
86
|
+
codemap export scip --graph graph.json -o index.scip # SCIP index (needs [scip] extra)
|
|
87
|
+
codemap export ctags --graph graph.json -o tags # universal-ctags tags file
|
|
88
|
+
|
|
89
|
+
# semantic (concept) search via an opt-in adapter → codemap symbols (needs the tool + opt-in)
|
|
90
|
+
codemap semantic "detect swing pivots" --build ./pkg --root pkg
|
|
91
|
+
|
|
92
|
+
# token-budgeted context pack — most relevant graph slice under N tokens (ranked; --seed to focus)
|
|
93
|
+
codemap pack --graph graph.json --budget 2000 --seed analyze_zones
|
|
94
|
+
|
|
95
|
+
# warm resident process — JSON requests over stdin/stdout (29 ops)
|
|
96
|
+
codemap serve --graph graph.json --source-root .
|
|
97
|
+
|
|
98
|
+
# …or expose the same surface as MCP tools for an AI-agent host (needs [mcp] extra)
|
|
99
|
+
codemap serve --graph graph.json --source-root . --mcp
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## What it answers
|
|
103
|
+
|
|
104
|
+
- **Structure & API** — public surface, signatures, docstrings, deprecation.
|
|
105
|
+
- **Dependencies & architecture** — import cycles, layers + direction/violations, coupling
|
|
106
|
+
(Ca/Ce/instability), god-objects & call-hubs, per-function complexity (cyclomatic / MI)
|
|
107
|
+
blended with structural coupling.
|
|
108
|
+
- **Impact / blast radius** — who uses X, across the whole repo (core + tests + docs).
|
|
109
|
+
- **Change review** — a diff → the symbols it touches, their callers, signature-change surface,
|
|
110
|
+
touched columns, cross-root consumers, risk rank.
|
|
111
|
+
- **Dispatch seams** — registry/factory families and the Protocol each impl satisfies.
|
|
112
|
+
- **Dataflow** — producers/consumers of a string-keyed DataFrame column.
|
|
113
|
+
- **Semantic search** (opt-in) — a concept query routed to an external adapter, with each fuzzy hit
|
|
114
|
+
resolved to the exact codemap symbol at its location (`codemap semantic`). See [docs/integrations.md](docs/integrations.md).
|
|
115
|
+
- **Context pack** — the most relevant slice of the graph under a token budget, ranked by importance or
|
|
116
|
+
by relevance to seed symbols (`codemap pack --budget N [--seed X]`). See [docs/pack.md](docs/pack.md).
|
|
117
|
+
- **Interop** — export the graph as a [SCIP](https://scip-code.org/) index (definitions + symbol
|
|
118
|
+
info + inherits/implements relationships) so Sourcegraph, Glean and other SCIP consumers can drive
|
|
119
|
+
go-to-definition, symbol search and type hierarchy over it. See [docs/export.md](docs/export.md).
|
|
120
|
+
|
|
121
|
+
## How it compares
|
|
122
|
+
|
|
123
|
+
codemap is **the precise structural leg for index-free AI agents** — it complements embeddings-RAG and
|
|
124
|
+
Repomix-style packing rather than competing with them. Its bet is to be the best *deterministic, diffable,
|
|
125
|
+
provenance-aware* graph in that slot, and to interoperate outward (SCIP, ctags) instead of locking the graph
|
|
126
|
+
away.
|
|
127
|
+
|
|
128
|
+
> **A code graph an agent can trust: source-only, deterministic, diffable — no index to go stale, no LSP to provision.**
|
|
129
|
+
|
|
130
|
+
The [research track](research/) measures this against the field hands-on, on a shared benchmark scope. The
|
|
131
|
+
[positioning doc](research/positioning.md) is the publication layer — the narrative and the numbers behind the
|
|
132
|
+
claims above; [comparison.md](research/comparison.md) is the coverage matrix that backs them.
|
|
133
|
+
|
|
134
|
+
Honesty is part of the bet: the call graph is a **measured lower bound**, not a guess. [docs/accuracy.md](docs/accuracy.md)
|
|
135
|
+
reports it — 100% precision / 100% decidable-recall on a hand-labeled suite, an openly-stated ~60% recall
|
|
136
|
+
against *all* true edges (the price of Python's dynamism), and a grep-vs-graph proof that the graph is ~2×
|
|
137
|
+
cheaper than grep for impact on unique names, tens of × on polymorphic ones, and no cheaper for locating a
|
|
138
|
+
symbol.
|
|
139
|
+
|
|
140
|
+
## Dogfooding
|
|
141
|
+
|
|
142
|
+
codemap is validated end-to-end against a real external package. Place a target repo as a sibling and
|
|
143
|
+
run the full flow against its package — e.g. `codemap build ../bquant/bquant` (point at the package
|
|
144
|
+
directory that holds `__init__.py`, not the repo root) — treating codemap purely as a third-party tool.
|
|
145
|
+
The `gaps/` directory records those dogfood runs: each is a pre-registered set of hypotheses, a run on
|
|
146
|
+
the live graph, findings, and the milestone that closed them.
|
|
147
|
+
|
|
148
|
+
## Documentation
|
|
149
|
+
|
|
150
|
+
- **[DESIGN.md](DESIGN.md)** — product design, the query catalog, v1 boundaries.
|
|
151
|
+
- **[docs/export.md](docs/export.md)** — export recipes: RAG, mermaid, Obsidian vault, SCIP + ctags interop.
|
|
152
|
+
- **[docs/accuracy.md](docs/accuracy.md)** — measured call-graph accuracy, the honest static ceiling, and
|
|
153
|
+
the grep-vs-graph value proof (both harnesses guarded in CI).
|
|
154
|
+
- **[docs/architecture-contracts.md](docs/architecture-contracts.md)** — declare the intended architecture
|
|
155
|
+
in `codemap.toml` and enforce it with `codemap check` (CI gate; codemap dogfoods its own).
|
|
156
|
+
- **[docs/api-diff.md](docs/api-diff.md)** — `codemap diff` two snapshots for added/removed/changed symbols
|
|
157
|
+
and API breaking-change detection (release gate + `review --base`).
|
|
158
|
+
- **[docs/integrations.md](docs/integrations.md)** — the opt-in router/adapter layer over external tools
|
|
159
|
+
(`codemap route` / `codemap semantic`); license policy; adding an integration.
|
|
160
|
+
- **[docs/dead-code.md](docs/dead-code.md)** — graded dead-code candidates (high/medium/low + provenance
|
|
161
|
+
reason) with a `[dead_code]` whitelist and `--min-confidence` filter.
|
|
162
|
+
- **[docs/pack.md](docs/pack.md)** — `codemap pack`: PageRank ranking + token-budgeted context slice for
|
|
163
|
+
AI agents (global importance or seed-focused relevance).
|
|
164
|
+
- **[docs/attribute-edges.md](docs/attribute-edges.md)** — `accesses` edges: who reads/writes a class field,
|
|
165
|
+
honest field-level `impact` (`accessors`; `unknown` vs `none`).
|
|
166
|
+
- **[docs/incremental.md](docs/incremental.md)** — `codemap build --incremental`: recompute only changed
|
|
167
|
+
modules (~12× faster on `--deep`), byte-identical on the fast tier.
|
|
168
|
+
- **[docs/test-mapping.md](docs/test-mapping.md)** — `codemap tests <symbol>`: which tests exercise a
|
|
169
|
+
symbol, as runnable pytest node ids, with the measured distance cutoff and an `unknown` that never
|
|
170
|
+
pretends to be "untested".
|
|
171
|
+
- **[docs/hard-python.md](docs/hard-python.md)** — what the extractor does with metaclasses, dynamic
|
|
172
|
+
classes, star imports, quoted annotations, `.pyi` stubs and symlinked trees; and the conditions where it
|
|
173
|
+
warns instead of answering.
|
|
174
|
+
- **[docs/provenance.md](docs/provenance.md)** — the `provenance` block: which tool, which tier, which
|
|
175
|
+
input tree built a graph; what stays in the sidecar; the schema-mismatch warning and `diff`'s
|
|
176
|
+
comparability check.
|
|
177
|
+
- **[docs/flat-layout.md](docs/flat-layout.md)** — flat module directories (sibling imports, no
|
|
178
|
+
`__init__.py`): labelled `resolution="flat"` edges, and the empty-import-graph warning that stops a
|
|
179
|
+
vacuous graph from reading as a clean one.
|
|
180
|
+
- **[research/blog/](research/blog/)** — **the build-story series**: field notes on building
|
|
181
|
+
codemap and measuring it against rival tools (EN + RU). See the section below.
|
|
182
|
+
- **[BACKLOG.md](BACKLOG.md)** — milestones M0–M18, the research track (R1), and deferred work.
|
|
183
|
+
- **[gaps/](gaps/)** — dogfood runs, coverage analysis, the living [axis register](gaps/dogfood_axes.md).
|
|
184
|
+
- **[research/](research/)** — survey of adjacent code-analysis tools and how codemap relates to each
|
|
185
|
+
(integrate / wrap / learn); source of the R1 capability roadmap. See
|
|
186
|
+
**[research/positioning.md](research/positioning.md)** for the publication-layer narrative and
|
|
187
|
+
**[research/comparison.md](research/comparison.md)** for the hands-on coverage matrix.
|
|
188
|
+
|
|
189
|
+
## Writing — the build-story series
|
|
190
|
+
|
|
191
|
+
Field notes on building codemap, and on measuring it honestly against the nearest rival
|
|
192
|
+
tools. Published here in the repo; every post exists in English and Russian.
|
|
193
|
+
**Index: [research/blog/](research/blog/README.md).**
|
|
194
|
+
|
|
195
|
+
| # | Post | |
|
|
196
|
+
|---|------|---|
|
|
197
|
+
| 0 | **A code graph an agent can trust** — what codemap is, the bet it makes, and the honest limits. | [EN](research/blog/00-a-code-graph-an-agent-can-trust.md) · [RU](research/blog/00-a-code-graph-an-agent-can-trust.ru.md) |
|
|
198
|
+
| 1 | **The competitor wasn't broken. We were.** — I nearly published that a rival's impact analysis was broken. The bug was my `PATH`. | [EN](research/blog/01-the-competitor-wasnt-broken.md) · [RU](research/blog/01-the-competitor-wasnt-broken.ru.md) |
|
|
199
|
+
| 2 | **The one that does more — and why that's fine.** — a 1.7 GB hybrid rival that proved the thesis instead of threatening it. | [EN](research/blog/02-the-one-that-does-more.md) · [RU](research/blog/02-the-one-that-does-more.ru.md) |
|
|
200
|
+
| 3 | **The competitor that does *less* — and that's why I take it.** — the emptiest coverage row was the most useful find. For its license, not its features. | [EN](research/blog/03-the-one-that-does-less.md) · [RU](research/blog/03-the-one-that-does-less.ru.md) |
|
|
201
|
+
| 4 | **My determinism test went red. The tool was fine.** — the input was moving under it, and the artifact could not say so. How the graph learned to name what built it. | [EN](research/blog/04-the-determinism-test-that-was-right.md) · [RU](research/blog/04-the-determinism-test-that-was-right.ru.md) |
|
|
202
|
+
|
|
203
|
+
New here? Read **1 → 0 → 2 → 3 → 4**. Every number in every post reproduces from a
|
|
204
|
+
[tool card](research/tools/) or the [comparison hub](research/comparison.md) — measurements,
|
|
205
|
+
not verdict.
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
[MIT](LICENSE).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""codemap — static code-graph builder.
|
|
2
|
+
|
|
3
|
+
Pipeline: Extract (griffe) -> Build (neutral model) -> Store (JSON) -> Serve (reports).
|
|
4
|
+
See DESIGN.md.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from codemap.model import Edge, Graph, Node
|
|
8
|
+
|
|
9
|
+
__all__ = ["Graph", "Node", "Edge"]
|
|
10
|
+
__version__ = "0.0.2"
|