@mgamil/mapx 0.2.4

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 (203) hide show
  1. package/LICENSE +194 -0
  2. package/README.md +488 -0
  3. package/VERSION +1 -0
  4. package/dist/agents/generator.d.ts +74 -0
  5. package/dist/agents/generator.js +375 -0
  6. package/dist/agents/templates.d.ts +29 -0
  7. package/dist/agents/templates.js +459 -0
  8. package/dist/cli.d.ts +16 -0
  9. package/dist/cli.js +1835 -0
  10. package/dist/core/cluster-engine.d.ts +32 -0
  11. package/dist/core/cluster-engine.js +314 -0
  12. package/dist/core/config.d.ts +29 -0
  13. package/dist/core/config.js +178 -0
  14. package/dist/core/context-builder.d.ts +61 -0
  15. package/dist/core/context-builder.js +252 -0
  16. package/dist/core/flow-tracer.d.ts +63 -0
  17. package/dist/core/flow-tracer.js +366 -0
  18. package/dist/core/git-tracker.d.ts +20 -0
  19. package/dist/core/git-tracker.js +159 -0
  20. package/dist/core/graph.d.ts +42 -0
  21. package/dist/core/graph.js +186 -0
  22. package/dist/core/metrics.d.ts +24 -0
  23. package/dist/core/metrics.js +87 -0
  24. package/dist/core/scanner.d.ts +53 -0
  25. package/dist/core/scanner.js +949 -0
  26. package/dist/core/store-bun.d.ts +13 -0
  27. package/dist/core/store-bun.js +34 -0
  28. package/dist/core/store-interface.d.ts +15 -0
  29. package/dist/core/store-interface.js +7 -0
  30. package/dist/core/store-node.d.ts +13 -0
  31. package/dist/core/store-node.js +35 -0
  32. package/dist/core/store.d.ts +132 -0
  33. package/dist/core/store.js +614 -0
  34. package/dist/core/workspace-manager.d.ts +9 -0
  35. package/dist/core/workspace-manager.js +64 -0
  36. package/dist/exporters/dot-exporter.d.ts +16 -0
  37. package/dist/exporters/dot-exporter.js +179 -0
  38. package/dist/exporters/graph-exporter.d.ts +14 -0
  39. package/dist/exporters/graph-exporter.js +85 -0
  40. package/dist/exporters/index.d.ts +9 -0
  41. package/dist/exporters/index.js +12 -0
  42. package/dist/exporters/llm-exporter.d.ts +18 -0
  43. package/dist/exporters/llm-exporter.js +224 -0
  44. package/dist/exporters/svg-exporter.d.ts +19 -0
  45. package/dist/exporters/svg-exporter.js +319 -0
  46. package/dist/exporters/toon-exporter.d.ts +16 -0
  47. package/dist/exporters/toon-exporter.js +246 -0
  48. package/dist/frameworks/detectors/aspnet.d.ts +11 -0
  49. package/dist/frameworks/detectors/aspnet.js +52 -0
  50. package/dist/frameworks/detectors/django.d.ts +14 -0
  51. package/dist/frameworks/detectors/django.js +135 -0
  52. package/dist/frameworks/detectors/drupal.d.ts +13 -0
  53. package/dist/frameworks/detectors/drupal.js +94 -0
  54. package/dist/frameworks/detectors/express.d.ts +12 -0
  55. package/dist/frameworks/detectors/express.js +234 -0
  56. package/dist/frameworks/detectors/fastapi.d.ts +12 -0
  57. package/dist/frameworks/detectors/fastapi.js +203 -0
  58. package/dist/frameworks/detectors/flask.d.ts +12 -0
  59. package/dist/frameworks/detectors/flask.js +244 -0
  60. package/dist/frameworks/detectors/go.d.ts +11 -0
  61. package/dist/frameworks/detectors/go.js +75 -0
  62. package/dist/frameworks/detectors/laravel.d.ts +11 -0
  63. package/dist/frameworks/detectors/laravel.js +462 -0
  64. package/dist/frameworks/detectors/nestjs.d.ts +12 -0
  65. package/dist/frameworks/detectors/nestjs.js +155 -0
  66. package/dist/frameworks/detectors/nextjs.d.ts +11 -0
  67. package/dist/frameworks/detectors/nextjs.js +118 -0
  68. package/dist/frameworks/detectors/rails.d.ts +12 -0
  69. package/dist/frameworks/detectors/rails.js +76 -0
  70. package/dist/frameworks/detectors/react-router.d.ts +11 -0
  71. package/dist/frameworks/detectors/react-router.js +115 -0
  72. package/dist/frameworks/detectors/rust.d.ts +11 -0
  73. package/dist/frameworks/detectors/rust.js +59 -0
  74. package/dist/frameworks/detectors/spring.d.ts +11 -0
  75. package/dist/frameworks/detectors/spring.js +56 -0
  76. package/dist/frameworks/detectors/sveltekit.d.ts +11 -0
  77. package/dist/frameworks/detectors/sveltekit.js +154 -0
  78. package/dist/frameworks/detectors/symfony.d.ts +13 -0
  79. package/dist/frameworks/detectors/symfony.js +175 -0
  80. package/dist/frameworks/detectors/tanstack-router.d.ts +12 -0
  81. package/dist/frameworks/detectors/tanstack-router.js +80 -0
  82. package/dist/frameworks/detectors/vapor.d.ts +11 -0
  83. package/dist/frameworks/detectors/vapor.js +52 -0
  84. package/dist/frameworks/detectors/vue-router.d.ts +12 -0
  85. package/dist/frameworks/detectors/vue-router.js +237 -0
  86. package/dist/frameworks/detectors/wordpress.d.ts +13 -0
  87. package/dist/frameworks/detectors/wordpress.js +141 -0
  88. package/dist/frameworks/detectors/yii.d.ts +11 -0
  89. package/dist/frameworks/detectors/yii.js +131 -0
  90. package/dist/frameworks/framework-registry.d.ts +13 -0
  91. package/dist/frameworks/framework-registry.js +77 -0
  92. package/dist/frameworks/route-registry.d.ts +26 -0
  93. package/dist/frameworks/route-registry.js +102 -0
  94. package/dist/index.d.ts +19 -0
  95. package/dist/index.js +30 -0
  96. package/dist/languages/index.d.ts +2 -0
  97. package/dist/languages/index.js +7 -0
  98. package/dist/languages/installer.d.ts +13 -0
  99. package/dist/languages/installer.js +103 -0
  100. package/dist/languages/registry.d.ts +19 -0
  101. package/dist/languages/registry.js +427 -0
  102. package/dist/main.d.ts +2 -0
  103. package/dist/main.js +20 -0
  104. package/dist/mcp.d.ts +11 -0
  105. package/dist/mcp.js +1699 -0
  106. package/dist/parsers/common-methods.d.ts +3 -0
  107. package/dist/parsers/common-methods.js +33 -0
  108. package/dist/parsers/fallback-parser.d.ts +10 -0
  109. package/dist/parsers/fallback-parser.js +18 -0
  110. package/dist/parsers/generic-wasm-parser.d.ts +23 -0
  111. package/dist/parsers/generic-wasm-parser.js +168 -0
  112. package/dist/parsers/ignored-symbols.d.ts +26 -0
  113. package/dist/parsers/ignored-symbols.js +77 -0
  114. package/dist/parsers/index.d.ts +9 -0
  115. package/dist/parsers/index.js +13 -0
  116. package/dist/parsers/languages/javascript.d.ts +11 -0
  117. package/dist/parsers/languages/javascript.js +28 -0
  118. package/dist/parsers/languages/php.d.ts +15 -0
  119. package/dist/parsers/languages/php.js +648 -0
  120. package/dist/parsers/languages/typescript.d.ts +10 -0
  121. package/dist/parsers/languages/typescript.js +9 -0
  122. package/dist/parsers/languages/vue.d.ts +13 -0
  123. package/dist/parsers/languages/vue.js +63 -0
  124. package/dist/parsers/parse-worker.d.ts +2 -0
  125. package/dist/parsers/parse-worker.js +185 -0
  126. package/dist/parsers/parser-interface.d.ts +9 -0
  127. package/dist/parsers/parser-interface.js +0 -0
  128. package/dist/parsers/parser-registry.d.ts +8 -0
  129. package/dist/parsers/parser-registry.js +52 -0
  130. package/dist/parsers/wasm-parser.d.ts +16 -0
  131. package/dist/parsers/wasm-parser.js +110 -0
  132. package/dist/types.d.ts +172 -0
  133. package/dist/types.js +0 -0
  134. package/dist/ui/index.html +270 -0
  135. package/dist/ui/main.js +581 -0
  136. package/dist/ui/main.js.map +7 -0
  137. package/dist/ui/styles.css +573 -0
  138. package/dist/ui-events.d.ts +36 -0
  139. package/dist/ui-events.js +61 -0
  140. package/dist/ui-server.d.ts +12 -0
  141. package/dist/ui-server.js +504 -0
  142. package/package.json +179 -0
  143. package/queries/bash/references.scm +22 -0
  144. package/queries/bash/symbols.scm +15 -0
  145. package/queries/c/references.scm +14 -0
  146. package/queries/c/symbols.scm +30 -0
  147. package/queries/c-sharp/references.scm +26 -0
  148. package/queries/c-sharp/symbols.scm +57 -0
  149. package/queries/cpp/references.scm +21 -0
  150. package/queries/cpp/symbols.scm +44 -0
  151. package/queries/dart/references.scm +33 -0
  152. package/queries/dart/symbols.scm +38 -0
  153. package/queries/elixir/references.scm +45 -0
  154. package/queries/elixir/symbols.scm +41 -0
  155. package/queries/go/references.scm +22 -0
  156. package/queries/go/symbols.scm +53 -0
  157. package/queries/java/references.scm +32 -0
  158. package/queries/java/symbols.scm +41 -0
  159. package/queries/javascript/references.scm +14 -0
  160. package/queries/javascript/symbols.scm +23 -0
  161. package/queries/kotlin/references.scm +31 -0
  162. package/queries/kotlin/symbols.scm +24 -0
  163. package/queries/lua/references.scm +19 -0
  164. package/queries/lua/symbols.scm +29 -0
  165. package/queries/pascal/references.scm +29 -0
  166. package/queries/pascal/symbols.scm +45 -0
  167. package/queries/php/references.scm +109 -0
  168. package/queries/php/symbols.scm +33 -0
  169. package/queries/python/references.scm +50 -0
  170. package/queries/python/symbols.scm +21 -0
  171. package/queries/ruby/references.scm +48 -0
  172. package/queries/ruby/symbols.scm +24 -0
  173. package/queries/rust/references.scm +31 -0
  174. package/queries/rust/symbols.scm +35 -0
  175. package/queries/scala/references.scm +30 -0
  176. package/queries/scala/symbols.scm +35 -0
  177. package/queries/svelte/references.scm +20 -0
  178. package/queries/svelte/symbols.scm +30 -0
  179. package/queries/swift/references.scm +22 -0
  180. package/queries/swift/symbols.scm +37 -0
  181. package/queries/typescript/references.scm +25 -0
  182. package/queries/typescript/symbols.scm +35 -0
  183. package/queries/vue/references.scm +20 -0
  184. package/queries/vue/symbols.scm +28 -0
  185. package/queries/zig/references.scm +20 -0
  186. package/queries/zig/symbols.scm +22 -0
  187. package/wasm/tree-sitter-c.wasm +0 -0
  188. package/wasm/tree-sitter-c_sharp.wasm +0 -0
  189. package/wasm/tree-sitter-cpp.wasm +0 -0
  190. package/wasm/tree-sitter-dart.wasm +0 -0
  191. package/wasm/tree-sitter-go.wasm +0 -0
  192. package/wasm/tree-sitter-java.wasm +0 -0
  193. package/wasm/tree-sitter-javascript.wasm +0 -0
  194. package/wasm/tree-sitter-kotlin.wasm +0 -0
  195. package/wasm/tree-sitter-php.wasm +0 -0
  196. package/wasm/tree-sitter-python.wasm +0 -0
  197. package/wasm/tree-sitter-ruby.wasm +0 -0
  198. package/wasm/tree-sitter-rust.wasm +0 -0
  199. package/wasm/tree-sitter-scala.wasm +0 -0
  200. package/wasm/tree-sitter-swift.wasm +0 -0
  201. package/wasm/tree-sitter-tsx.wasm +0 -0
  202. package/wasm/tree-sitter-typescript.wasm +0 -0
  203. package/wasm/tree-sitter-vue.wasm +0 -0
package/LICENSE ADDED
@@ -0,0 +1,194 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and incorporated
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any Contribution
81
+ embodied within the Work constitutes direct or contributory patent
82
+ infringement, then any patent licenses granted to You under this License
83
+ for that Work shall terminate as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or Derivative
91
+ Works a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, You must include a readable copy of the
104
+ attribution notices contained within such NOTICE file, in
105
+ at least one of the following places: within a NOTICE text
106
+ file distributed as part of the Derivative Works; within
107
+ the Source form or documentation, if provided along with the
108
+ Derivative Works; or, within a display generated by the
109
+ Derivative Works, if and wherever such third-party notices
110
+ normally appear. The contents of the NOTICE file are for
111
+ informational purposes only and do not modify the License.
112
+ You may add Your own attribution notices within Derivative
113
+ Works that You distribute, alongside or as an addendum to
114
+ the NOTICE text from the Work, provided that such additional
115
+ attribution notices cannot be construed as modifying the
116
+ License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, reproduce, modify,
120
+ and distribute Your modifications as part of a Derivative Work,
121
+ under the terms and conditions of this License; provided, however,
122
+ that such additional grant of rights does not reduce or restrict
123
+ the rights granted to You herein by this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any warranties or conditions
143
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
144
+ PARTICULAR PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or reproducing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (including but not limited to damages for loss of goodwill,
156
+ work stoppage, computer failure or malfunction, or all other
157
+ commercial damages or losses), even if such Contributor has been
158
+ advised of the possibility of such damages.
159
+
160
+ 9. Accepting Warranty or Liability. While redistributing the Work or
161
+ Derivative Works thereof, You may choose to offer, and charge a fee
162
+ for, acceptance of support, warranty, indemnity, or other liability
163
+ obligations and/or rights consistent with this License. However, in
164
+ accepting such obligations, You may offer such obligations only on
165
+ Your own behalf and on Your sole responsibility, not on behalf of
166
+ any other Contributor, and only if You agree to indemnify, defend,
167
+ and hold each Contributor harmless for any liability incurred by, or
168
+ claims asserted against, such Contributor by reason of your accepting
169
+ any such warranty or additional liability.
170
+
171
+ END OF TERMS AND CONDITIONS
172
+
173
+ APPENDIX: How to apply the Apache License to your work.
174
+
175
+ To apply the Apache License to your work, attach the following
176
+ boilerplate notice, with the fields enclosed by brackets "[]"
177
+ replaced with your own identifying information. (Don't include
178
+ the brackets!) The text should be enclosed in the appropriate
179
+ comment syntax for the file format in question. It should also be
180
+ included in any file distribution as the source form of the work.
181
+
182
+ Copyright 2026 Mohamed Gamil
183
+
184
+ Licensed under the Apache License, Version 2.0 (the "License");
185
+ you may not use this file except in compliance with the License.
186
+ You may obtain a copy of the License at
187
+
188
+ http://www.apache.org/licenses/LICENSE-2.0
189
+
190
+ Unless required by applicable law or agreed to in writing, software
191
+ distributed under the License is distributed on an "AS IS" BASIS,
192
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193
+ See the License for the specific language governing permissions and
194
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,488 @@
1
+ # MapX
2
+
3
+ **Local code graph memory for LLMs.** Scan your codebase once — instantly query symbols, trace dependencies, analyze impact, and generate structured summaries without re-reading files.
4
+
5
+ MapX uses [tree-sitter](https://tree-sitter.github.io/) to parse source files across **22 languages**, builds a PageRank-weighted dependency graph, and persists everything to a local SQLite database. Works as a standalone CLI or as an [MCP server](https://modelcontextprotocol.io/) with **25 tools** for Claude Desktop, Cursor, VS Code, and any other MCP-compatible client.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - **22 languages** — 8 built-in (PHP, JS, TS, Python, Go, Rust, Java, C#), 7 bundled (Ruby, C, C++, Swift, Kotlin, Scala, Vue), 7 installable (Svelte, Lua, Elixir, Zig, Bash, Pascal, Dart)
12
+ - **Deep symbol extraction** — classes, methods, functions, interfaces, traits, enums, structs, modules, constants, properties, namespaces — with full import/inheritance/instantiation reference tracking
13
+ - **Incremental scans** — git-aware change detection; only re-parses files that changed
14
+ - **Fast** — parallelised file reads, bounded WASM concurrency, batched SQLite writes
15
+ - **Resumable** — scan progress is checkpointed; `Ctrl+C` and re-run picks up where it left off
16
+ - **25 MCP tools** — scan, query, search, trace, callers, callees, impact, export, context, workspaces, and more
17
+ - **Data flow tracing** — trace call chains, find sources/sinks, analyze change impact with blast radius scoring
18
+ - **Multi-repo workspaces** — register multiple repos, discover submodules, track cross-repo dependencies
19
+ - **Multiple export formats** — LLM summary (token-budgeted), JSON, GraphViz DOT, SVG, TOON
20
+ - **Framework detection** — 21 frameworks recognized (Laravel, Express, Next.js, Django, Flask, FastAPI, Spring, Rails, and more)
21
+ - **Web dashboard** — built-in `mapx ui` for interactive graph visualization
22
+ - **Zero cloud** — everything stays on disk in `.mapx/` inside your project
23
+ - **87% LLM cost reduction** — drops context token consumption by 87% vs baseline workspace reads by feeding exact signatures and transitive impact summaries
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ### Pre-built binary (recommended)
30
+
31
+ Download the latest release for your platform from the [Releases](../../releases) page and place it on your `PATH`:
32
+
33
+ ```bash
34
+ # Linux x86_64
35
+ curl -fsSL https://github.com/MohamedGamil/mapx/releases/latest/download/mapx-linux-x64-installer.sh | sh
36
+
37
+ # macOS Apple Silicon
38
+ curl -fsSL https://github.com/MohamedGamil/mapx/releases/latest/download/mapx-darwin-arm64-installer.sh | sh
39
+ ```
40
+
41
+ Or extract the archive manually:
42
+
43
+ ```bash
44
+ tar xzf mapx-<version>-linux-x64.tar.gz
45
+ cd mapx-<version>
46
+ ./install.sh --local # installs to ~/.local/bin (no sudo)
47
+ ./install.sh --system # installs to /usr/local/bin (needs sudo)
48
+ ```
49
+
50
+ ### From npm
51
+
52
+ ```bash
53
+ npm install -g mapx
54
+ ```
55
+
56
+ ### From source
57
+
58
+ Requires [Node.js](https://nodejs.org/) ≥ 20 or [Bun](https://bun.sh/).
59
+
60
+ ```bash
61
+ git clone https://github.com/MohamedGamil/mapx.git
62
+ cd mapx
63
+ npm install
64
+ npx tsx src/main.ts --help
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Quick Start
70
+
71
+ ```bash
72
+ # 1. Initialize mapx in your project (auto-adds .mapx/ to .gitignore)
73
+ cd /path/to/your/project
74
+ mapx init
75
+
76
+ # 2. Scan all source files
77
+ mapx scan
78
+
79
+ # 3. View a token-efficient summary (great for pasting into an LLM)
80
+ mapx export
81
+
82
+ # 4. Search for a symbol
83
+ mapx query UserService
84
+
85
+ # 5. Show a file's dependencies
86
+ mapx deps src/app.ts
87
+
88
+ # 6. Trace who calls a function
89
+ mapx callers handleRequest
90
+
91
+ # 7. Assess change impact before refactoring
92
+ mapx impact UserService
93
+
94
+ # 8. Check what changed since the last scan
95
+ mapx status
96
+ ```
97
+
98
+ All commands accept a target directory via a positional argument, `--dir`, or `-d`:
99
+
100
+ ```bash
101
+ mapx scan /path/to/project
102
+ mapx query "MyClass" --dir /path/to/project
103
+ mapx -d /path/to/project export
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Commands
109
+
110
+ | Command | Description |
111
+ |---------|-------------|
112
+ | `mapx init [path]` | Initialise mapx; create `.mapx/`, `AGENTS.md`, auto-detect agent tools, generate MCP configs |
113
+ | `mapx uninit [path]` | Remove mapx; delete `.mapx/`, reverse LLM integration changes, clean MCP configs |
114
+ | `mapx scan [path]` | Full scan — builds the graph from scratch (supports `--force` to bypass cache) |
115
+ | `mapx update [path]` | Incremental scan — only re-parses changed files |
116
+ | `mapx status [path]` | Show graph metrics, language breakdown, PageRank rankings, git changes |
117
+ | `mapx query <term>` | Search symbols by name (partial match) |
118
+ | `mapx search <term>` | Advanced symbol search with `--kind`, `--file`, `--exact`, `--limit` filters |
119
+ | `mapx deps <file>` | Show dependencies and reverse-dependencies |
120
+ | `mapx trace <symbol>` | Trace data flow paths from a symbol |
121
+ | `mapx callers <symbol>` | Show direct and nested callers |
122
+ | `mapx callees <symbol>` | Show direct and nested callees |
123
+ | `mapx impact <symbol>` | Change impact analysis — blast radius and risk scoring |
124
+ | `mapx node <symbol>` | Inspect a symbol with metadata and optional `--source` |
125
+ | `mapx files` | List and filter files with `--path`, `--lang`, `--sort`, `--limit` |
126
+ | `mapx clusters` | List detected code clusters/modules |
127
+ | `mapx export` | Export graph (default: LLM summary, 8K tokens) |
128
+ | `mapx export --format=json` | Full graph as JSON |
129
+ | `mapx export --format=dot` | GraphViz DOT (with `--cluster` and `--depth`) |
130
+ | `mapx export --format=svg` | SVG visualisation |
131
+ | `mapx export --format=toon` | TOON compact format (with `--delimiter`, `--key-folding`) |
132
+ | `mapx export -o out.txt` | Write export to a file |
133
+ | `mapx summary [path]` | One-line project summary |
134
+ | `mapx lang list` | List supported languages and status |
135
+ | `mapx lang install <name>` | Install an installable-tier language |
136
+ | `mapx lang uninstall <name>` | Uninstall a language |
137
+ | `mapx ui` | Open the web dashboard for interactive visualization |
138
+ | `mapx workspaces list` | List registered repositories |
139
+ | `mapx workspaces add <path>` | Register a new repository |
140
+ | `mapx workspaces discover` | Discover unregistered submodules, peers, VS Code folders |
141
+ | `mapx workspaces sync` | Auto-register discovered repositories |
142
+ | `mapx agents mcp` | Auto-detect agent tools and generate MCP config files |
143
+ | `mapx serve --dir <path>` | Start MCP server (stdio) |
144
+ | `mapx serve --sse --port 3456` | Start MCP server (SSE/HTTP) |
145
+
146
+ See [docs/cli-reference.md](docs/cli-reference.md) for full details on all flags.
147
+
148
+ ---
149
+
150
+ ## Token Consumption Benchmarks
151
+
152
+ MapX significantly reduces LLM context window usage when performing agentic coding tasks. The built-in benchmark suite simulates typical AI workflows (understanding structure, tracing dependencies, multi-file edits) to compare baseline file reads versus MapX MCP tool calls.
153
+
154
+ **Average Savings: 87% reduction in token usage.**
155
+
156
+ | Scenario | Baseline (No MapX) | With MapX | Savings | Cost (Sonnet 3.5) |
157
+ |----------|-------------------|-----------|---------|-------------------|
158
+ | Understand structure | 28.4K tokens (15 tool calls) | 600 tokens (1 tool call) | **98%** | $0.0852 → $0.0018 |
159
+ | Multi-file edit | 40.4K tokens (25 tool calls) | 7.2K tokens (9 tool calls) | **82%** | $0.1213 → $0.0215 |
160
+ | Full session (15 tasks) | 194.4K tokens (123 calls) | 29.8K tokens (43 calls) | **85%** | $0.5832 → $0.0894 |
161
+
162
+ Run the benchmark on your own codebase:
163
+ ```bash
164
+ make bench DIR=/path/to/project
165
+ ```
166
+ See [docs/benchmarking.md](docs/benchmarking.md) for full scenario breakdowns and methodology.
167
+
168
+ ---
169
+
170
+ ## MCP Integration
171
+
172
+ Start the MCP server and paste the printed configuration into your tool:
173
+
174
+ ```bash
175
+ mapx serve --dir /path/to/your/project
176
+ ```
177
+
178
+ You can optionally append the `--debug` flag to log all incoming MCP tool calls, parameters, execution durations, and success/error status to `stderr` (allowing stdout to remain clean for transport protocols):
179
+
180
+ ```bash
181
+ mapx serve --dir /path/to/your/project --debug
182
+ ```
183
+
184
+ On startup mapx prints ready-to-copy configuration for Claude Desktop, Cursor, and VS Code.
185
+
186
+ ### Claude Desktop (`claude_desktop_config.json`)
187
+
188
+ ```json
189
+ {
190
+ "mcpServers": {
191
+ "mapx": {
192
+ "command": "mapx",
193
+ "args": ["serve", "--dir", "/path/to/your/project"]
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
199
+ ### Cursor / VS Code (`.cursor/mcp.json`)
200
+
201
+ ```json
202
+ {
203
+ "mcpServers": {
204
+ "mapx": {
205
+ "command": "mapx",
206
+ "args": ["serve", "--dir", "/path/to/your/project"]
207
+ }
208
+ }
209
+ }
210
+ ```
211
+
212
+ ### Available MCP tools (25 total)
213
+
214
+ | Category | Tools |
215
+ |----------|-------|
216
+ | **Graph Building** | `mapx_scan`, `mapx_sync` |
217
+ | **Symbol Discovery** | `mapx_query`, `mapx_search`, `mapx_node`, `mapx_files` |
218
+ | **Dependencies & Flow** | `mapx_dependencies`, `mapx_callers`, `mapx_callees`, `mapx_trace`, `mapx_sources`, `mapx_sinks` |
219
+ | **Analysis** | `mapx_impact`, `mapx_clusters`, `mapx_status` |
220
+ | **Export** | `mapx_export`, `mapx_context` |
221
+ | **Workspaces** | `mapx_workspaces` |
222
+ | **Language Management** | `mapx_lang_list`, `mapx_lang_install`, `mapx_lang_uninstall` |
223
+
224
+ See [docs/mcp-integration.md](docs/mcp-integration.md) for full tool parameters and client setup.
225
+
226
+ ---
227
+
228
+ ## Programmatic Usage
229
+
230
+ MapX can be imported programmatically as an ESM library in Node.js or TypeScript projects to execute scans, load code graphs, or build token-optimized LLM context:
231
+
232
+ ```typescript
233
+ import { Config, Store, Scanner, MapxGraph, ContextBuilder } from '@mgamil/mapx';
234
+
235
+ const dir = '/path/to/project';
236
+ const config = await Config.load(dir);
237
+ const store = new Store(`${dir}/.mapx/mapx.db`);
238
+
239
+ // 1. Run incremental scan
240
+ const scanner = new Scanner(dir, store);
241
+ await scanner.scanIncremental();
242
+
243
+ // 2. Query code metrics
244
+ console.log(`Scanned ${store.getFileCount()} files and ${store.getSymbolCount()} symbols.`);
245
+
246
+ // 3. Close database connection
247
+ store.close();
248
+ ```
249
+
250
+ See [docs/getting-started.md](docs/getting-started.md#programmatic-usage) for a detailed programmatic API example.
251
+
252
+ ---
253
+
254
+ ## Supported Languages
255
+
256
+ ### Built-in (Tier 1) — Always available
257
+
258
+ | Language | Extensions | Key Symbols |
259
+ |----------|-----------|-------------|
260
+ | PHP | `.php`, `.phtml` | classes, methods, functions, interfaces, traits, enums, constants, properties, namespaces |
261
+ | JavaScript | `.js`, `.mjs`, `.cjs` | classes, methods, functions, interfaces, enums, properties |
262
+ | TypeScript | `.ts`, `.cts`, `.mts` | classes, methods, functions, interfaces, enums, properties, namespaces |
263
+ | Python | `.py` | classes, functions, constants |
264
+ | Go | `.go` | structs, interfaces, functions, methods, constants, packages |
265
+ | Rust | `.rs` | structs, traits, enums, functions, impl blocks, constants, modules, macros |
266
+ | Java | `.java` | classes, interfaces, enums, methods, fields, constants, packages |
267
+ | C# | `.cs` | classes, interfaces, enums, structs, methods, properties, namespaces, records |
268
+
269
+ ### Bundled (Tier 2) — Ships with the tool
270
+
271
+ | Language | Extensions | Key Symbols |
272
+ |----------|-----------|-------------|
273
+ | Ruby | `.rb` | classes, modules, methods, constants, properties |
274
+ | C | `.c`, `.h` | structs, functions, enums, typedefs, macros |
275
+ | C++ | `.cpp`, `.hpp`, `.cc` | classes, structs, functions, namespaces, enums, templates |
276
+ | Swift | `.swift` | classes, structs, protocols, enums, functions, properties |
277
+ | Kotlin | `.kt`, `.kts` | classes, objects, functions, interfaces, properties |
278
+ | Scala | `.scala`, `.sc` | classes, objects, traits, functions, vals |
279
+ | Vue | `.vue` | functions, classes, methods, properties (supports `@/` alias resolution) |
280
+
281
+ ### Installable (Tier 3) — `mapx lang install <name>`
282
+
283
+ | Language | Extensions | Key Symbols |
284
+ |----------|-----------|-------------|
285
+ | Svelte | `.svelte` | functions, classes, methods, props, constants |
286
+ | Lua | `.lua` | functions, methods, variables |
287
+ | Elixir | `.ex`, `.exs` | modules, functions, macros, structs, protocols |
288
+ | Zig | `.zig` | functions, structs, constants, tests |
289
+ | Bash | `.sh`, `.bash` | functions, variables, aliases |
290
+ | Pascal | `.pas`, `.pp` | classes, records, interfaces, methods, functions, constants, units |
291
+ | Dart | `.dart` | classes, functions, enums, mixins, extensions |
292
+
293
+ All languages track **imports**, **inheritance/implementation**, **instantiation**, and **calls** where applicable. See [docs/adding-languages.md](docs/adding-languages.md) to add your own.
294
+
295
+ ---
296
+
297
+ ## Agentic Integration
298
+
299
+ `mapx init` creates (or updates) an `AGENTS.md` file in your project root. This file documents the mapx CLI and MCP tools so LLM coding agents can discover and use them automatically.
300
+
301
+ During initialization, mapx also **auto-detects installed agent tools** and generates MCP server config files:
302
+
303
+ | Agent Tool | Config File | Auto-Detection |
304
+ |------------|-------------|----------------|
305
+ | opencode | `opencode.json` | `opencode.json` or `opencode.jsonc` exists |
306
+ | Gemini CLI | `.gemini/settings.json` | `.gemini/` directory exists |
307
+ | Cursor | `.cursor/mcp.json` | `.cursor/` directory exists |
308
+ | VS Code | `.vscode/mcp.json` | `.vscode/` directory exists |
309
+ | Antigravity | `.agents/mcp.json` | `.agents/` directory exists |
310
+
311
+ This means running `mapx init` in a project that uses Cursor and Gemini CLI will auto-register mapx as an MCP server in both tools — no manual config editing needed.
312
+
313
+ You can also run `mapx agents mcp --detect` to see which tools are available, or `mapx agents mcp --all` to generate configs for all supported tools.
314
+
315
+ The AGENTS.md content is wrapped in markers and can safely coexist with existing AGENTS.md content:
316
+
317
+ ```markdown
318
+ <!-- mapx -->
319
+ ...mapx documentation for LLMs...
320
+ <!-- /mapx -->
321
+ ```
322
+
323
+ ---
324
+
325
+ ## Storage
326
+
327
+ mapx stores everything locally inside your project:
328
+
329
+ ```
330
+ .mapx/
331
+ ├── config.json # Repo configuration and language settings
332
+ ├── mapx.db # SQLite database — symbols, edges, scan cache
333
+ └── scan.lock # Present only while a scan is running
334
+ ```
335
+
336
+ `.mapx/` is automatically added to `.gitignore` during `mapx init`.
337
+
338
+ ---
339
+
340
+ ## Architecture
341
+
342
+ <!-- ![Architecture Diagram](./docs/images/01-arch.png) -->
343
+
344
+ ```mermaid
345
+ graph TD
346
+ classDef interface fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
347
+ classDef core fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
348
+ classDef storage fill:#fff3e0,stroke:#e65100,stroke-width:2px;
349
+ classDef engine fill:#f3e5f5,stroke:#4a148c,stroke-width:2px;
350
+
351
+ CLI["CLI Interface<br>(cli.ts)"]:::interface
352
+ MCP["MCP Server<br>(mcp.ts)"]:::interface
353
+ UI["Web Dashboard<br>(ui-server.ts)"]:::interface
354
+
355
+ Scanner["Scanner<br>(scanner.ts)"]:::core
356
+ GitTracker["Git Tracker<br>(git-tracker.ts)"]:::core
357
+ Workspace["Workspace Manager<br>(workspace-manager.ts)"]:::core
358
+
359
+ Registry["Language Registry<br>(registry.ts)"]:::core
360
+ Parsers["Parsers<br>(parsers/)"]:::core
361
+
362
+ Store["Store Interface<br>(store.ts)"]:::storage
363
+ SQLite[("SQLite DB<br>(mapx.db)")]:::storage
364
+ Graphology["In-Memory Graph<br>(graphology)"]:::storage
365
+
366
+ Exporters["Exporters<br>(exporters/)"]:::engine
367
+ FlowTracer["Flow Tracer<br>(flow-tracer.ts)"]:::engine
368
+ Context["Context Builder<br>(context-builder.ts)"]:::engine
369
+
370
+ CLI --> Scanner
371
+ MCP --> Scanner
372
+ UI --> Store
373
+
374
+ Scanner --> GitTracker
375
+ Scanner --> Registry
376
+ Registry --> Parsers
377
+
378
+ Scanner --> Store
379
+ Workspace --> Store
380
+
381
+ Store --> SQLite
382
+ Store --> Graphology
383
+
384
+ Store --> Exporters
385
+ Store --> FlowTracer
386
+ Store --> Context
387
+
388
+ FlowTracer --> CLI
389
+ FlowTracer --> MCP
390
+ Context --> MCP
391
+ Exporters --> CLI
392
+ Exporters --> MCP
393
+ ```
394
+
395
+ See [docs/architecture.md](docs/architecture.md) for a detailed breakdown of each component.
396
+
397
+ ---
398
+
399
+ ## Documentation
400
+
401
+ | Doc | Description |
402
+ |-----|-------------|
403
+ | [Getting Started](docs/getting-started.md) | Installation, quick start, supported languages |
404
+ | [CLI Reference](docs/cli-reference.md) | All 31 commands and their flags |
405
+ | [MCP Integration](docs/mcp-integration.md) | MCP server setup and all 25 tools |
406
+ | [Configuration](docs/configuration.md) | Config file, workspace setup, settings |
407
+ | [Benchmarking](docs/benchmarking.md) | Token cost analysis vs baseline LLM usage |
408
+ | [Adding Languages](docs/adding-languages.md) | Extend mapx with new tree-sitter grammars |
409
+ | [Framework Integration](docs/framework-integration.md) | Heuristics and routing/hook extraction for 21 frameworks |
410
+ | [Agent Best Practices](docs/agent-best-practices.md) | Prompting guidelines and tool selection cheat sheet for LLM agents |
411
+ | [Architecture](docs/architecture.md) | Internals and component overview |
412
+
413
+ ---
414
+
415
+ ## Development
416
+
417
+ ### npm script shortcuts
418
+
419
+ All CLI commands are available as npm scripts for development:
420
+
421
+ ```bash
422
+ npm run scan # Full scan
423
+ npm run update # Incremental scan
424
+ npm run status # Show status
425
+ npm run export # LLM summary
426
+ npm run export:svg # SVG export
427
+ npm run query -- UserService # Symbol search
428
+ npm run search -- User --kind class # Advanced search
429
+ npm run callers -- handleRequest # Trace callers
430
+ npm run impact -- UserService # Change impact
431
+ npm run ui # Web dashboard
432
+ npm run serve # MCP server (stdio)
433
+ npm run serve:sse # MCP server (SSE)
434
+ ```
435
+
436
+ ### Makefile shortcuts
437
+
438
+ ```bash
439
+ make help # Show all targets
440
+ make scan DIR=/path # Full scan
441
+ make search q=User k=class # Advanced search
442
+ make callers s=handleRequest # Trace callers
443
+ make impact s=UserService d=3 # Impact with depth
444
+ make node s=UserService src=1 # Inspect with source
445
+ make export-toon DIR=/path # TOON export
446
+ make serve-sse PORT=3456 # SSE server
447
+ make ui PORT=8080 # Web dashboard
448
+ ```
449
+
450
+ ### Building binaries
451
+
452
+ Requires [Bun](https://bun.sh/) for binary compilation.
453
+
454
+ ```bash
455
+ # Build for all platforms
456
+ make build-all
457
+
458
+ # Build for a single platform
459
+ make build-linux
460
+ make build-mac-arm
461
+ make build-win
462
+
463
+ # Package into distributable archives + self-extracting installers
464
+ make package-all
465
+
466
+ # Install locally (no sudo)
467
+ make install-local
468
+ ```
469
+
470
+ ---
471
+
472
+ ## Publishing to npm
473
+
474
+ To publish new releases of the npm package:
475
+
476
+ 1. Create a tag matching the version in `package.json` and push it:
477
+ ```bash
478
+ git tag v0.1.7
479
+ git push origin v0.1.7
480
+ ```
481
+ 2. The GitHub Actions publish workflow will automatically run, verify version synchronization, build WASM grammars, compile the TypeScript code using `tsup`, and publish to the npm registry with provenance.
482
+ 3. **Important**: The workflow requires a repository secret named `NPM_TOKEN`. This token must be generated on `npmjs.com` as an **Automation** access token.
483
+
484
+ ---
485
+
486
+ ## License
487
+
488
+ Apache 2.0 — see [LICENSE](LICENSE).
package/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.4