@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
@@ -0,0 +1,459 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ function mcpCommand() {
4
+ return { command: "mapx", args: [] };
5
+ }
6
+ function mcpArgs(projectDir) {
7
+ return ["serve", "--dir", projectDir];
8
+ }
9
+ const MCP_CONFIGS = [
10
+ {
11
+ name: "opencode",
12
+ filename: "opencode.json",
13
+ detect: (dir) => {
14
+ return existsSync(join(dir, "opencode.json")) || existsSync(join(dir, "opencode.jsonc"));
15
+ },
16
+ generate: (projectDir) => {
17
+ const cmd = mcpCommand();
18
+ return JSON.stringify({
19
+ "$schema": "https://opencode.ai/config.json",
20
+ mcp: {
21
+ mapx: {
22
+ type: "local",
23
+ command: [cmd.command, ...mcpArgs(projectDir)],
24
+ enabled: true
25
+ }
26
+ }
27
+ }, null, 2);
28
+ }
29
+ },
30
+ {
31
+ name: "gemini-cli",
32
+ filename: ".gemini/settings.json",
33
+ detect: (dir) => {
34
+ return existsSync(join(dir, ".gemini"));
35
+ },
36
+ generate: (projectDir) => {
37
+ const cmd = mcpCommand();
38
+ return JSON.stringify({
39
+ mcpServers: {
40
+ mapx: {
41
+ command: cmd.command,
42
+ args: mcpArgs(projectDir)
43
+ }
44
+ }
45
+ }, null, 2);
46
+ }
47
+ },
48
+ {
49
+ name: "cursor-mcp",
50
+ filename: ".cursor/mcp.json",
51
+ detect: (dir) => {
52
+ return existsSync(join(dir, ".cursor"));
53
+ },
54
+ generate: (projectDir) => {
55
+ const cmd = mcpCommand();
56
+ return JSON.stringify({
57
+ mcpServers: {
58
+ mapx: {
59
+ command: cmd.command,
60
+ args: mcpArgs(projectDir)
61
+ }
62
+ }
63
+ }, null, 2);
64
+ }
65
+ },
66
+ {
67
+ name: "vscode-mcp",
68
+ filename: ".vscode/mcp.json",
69
+ detect: (dir) => {
70
+ return existsSync(join(dir, ".vscode"));
71
+ },
72
+ generate: (projectDir) => {
73
+ const cmd = mcpCommand();
74
+ return JSON.stringify({
75
+ servers: {
76
+ mapx: {
77
+ command: cmd.command,
78
+ args: mcpArgs(projectDir)
79
+ }
80
+ }
81
+ }, null, 2);
82
+ }
83
+ },
84
+ {
85
+ name: "antigravity",
86
+ filename: ".agents/mcp.json",
87
+ detect: (dir) => {
88
+ return existsSync(join(dir, ".agents"));
89
+ },
90
+ generate: (projectDir) => {
91
+ const cmd = mcpCommand();
92
+ return JSON.stringify({
93
+ servers: {
94
+ mapx: {
95
+ command: cmd.command,
96
+ args: mcpArgs(projectDir)
97
+ }
98
+ }
99
+ }, null, 2);
100
+ }
101
+ }
102
+ ];
103
+ const TEMPLATES = {
104
+ generic: {
105
+ filename: "AGENTS.md",
106
+ isAppend: false,
107
+ content: `# MapxGraph - LLM Integration Guide
108
+
109
+ This project uses **MapxGraph** \u2014 a local code graph memory system that provides persistent, structured understanding of the codebase across LLM sessions.
110
+
111
+ ## What MapxGraph Does
112
+
113
+ MapxGraph scans source files across **22 languages**, extracts symbols (classes, functions, methods, interfaces, traits, enums, structs, modules, constants, properties, namespaces) and dependencies (imports, requires, extends, implements, calls, instantiation), builds a weighted graph with PageRank importance scoring, and persists everything to \`.mapx/\`.
114
+
115
+ This means you (the LLM) can quickly understand the codebase structure without reading every file.
116
+
117
+ ## Commands
118
+
119
+ All commands accept a target directory. Three ways to specify:
120
+
121
+ \`\`\`bash
122
+ # 1. Positional path argument
123
+ mapx scan /path/to/project
124
+
125
+ # 2. --dir / -d flag
126
+ mapx scan --dir /path/to/project
127
+ mapx query "MyClass" -d /path/to/project
128
+
129
+ # 3. Global flag (works with any subcommand)
130
+ mapx -d /path/to/project scan
131
+ \`\`\`
132
+
133
+ ### Available Commands
134
+
135
+ - \`mapx init [path]\` - First-time setup (auto-adds .mapx/ to .gitignore)
136
+ - \`mapx uninit [path]\` - Remove .mapx/ and reverse integration changes
137
+ - \`mapx scan [path]\` - Full scan
138
+ - \`mapx update [path]\` (alias: \`sync\`) - Incremental update (fast)
139
+ - \`mapx status [path]\` - Check what changed since last scan
140
+ - \`mapx export [--dir path]\` - Export compact graph summary
141
+ - \`mapx export --format=<fmt>\` - Export as \`llm\`, \`json\`, \`dot\`, \`svg\`, or \`toon\`
142
+ - \`mapx export --cluster <mode> --depth <n>\` - Cluster-aware DOT/SVG export
143
+ - \`mapx query <symbol> [--dir path]\` - Search for symbols
144
+ - \`mapx search <term> [--dir path] [--kind kind] [--file prefix] [--exact] [--limit limit]\` - Advanced search for symbols
145
+ - \`mapx deps <file> [--dir path]\` - Show dependencies for a file
146
+ - \`mapx summary [path]\` - Project summary
147
+ - \`mapx clusters [--dir path]\` - List detected clusters/modules
148
+ - \`mapx trace <symbol> [--dir path]\` - Trace data flow
149
+ - \`mapx callers <symbol> [--dir path] [--depth depth]\` - Trace callers of a symbol
150
+ - \`mapx callees <symbol> [--dir path] [--depth depth]\` - Trace callees of a symbol
151
+ - \`mapx impact <symbol> [--dir path] [--depth depth]\` - Perform change impact analysis
152
+ - \`mapx node <symbol> [--dir path] [--source]\` - Inspect a symbol node and optionally view its source code
153
+ - \`mapx files [--dir path] [--path prefix] [--lang language] [--sort sort] [--limit limit]\` - List and filter files
154
+ - \`mapx lang list\` - List supported languages and status
155
+ - \`mapx lang install <lang>\` - Install dynamic language support
156
+ - \`mapx lang uninstall <lang>\` - Uninstall dynamic language support
157
+ - \`mapx serve --dir /path\` - Start stdio MCP server
158
+ - \`mapx serve --sse --port <port>\` - Start SSE (HTTP) MCP server
159
+ - \`mapx ui [--port <port>]\` - Open web dashboard for interactive visualization
160
+ - \`mapx workspaces list\` - List registered repositories
161
+ - \`mapx workspaces add <path>\` - Register a new repository
162
+ - \`mapx workspaces discover\` - Discover unregistered submodules, peers, VS Code folders
163
+ - \`mapx workspaces sync\` - Auto-register discovered repositories
164
+
165
+ ## MCP Tools
166
+
167
+ When running as an MCP server, MapxGraph exposes these tools:
168
+ - \`mapx_scan\` - Scan the code graph (full scan)
169
+ - \`mapx_sync\` - Sync changed files to update the graph (incremental scan)
170
+ - \`mapx_query\` - Search symbols by name pattern
171
+ - \`mapx_search\` - Filtered semantic and regex-like symbol search
172
+ - \`mapx_node\` - Deep inspection of a specific symbol and its source code
173
+ - \`mapx_files\` - List and filter files by path, language, and size or line counts
174
+ - \`mapx_dependencies\` - Get deps and reverse-deps for a file
175
+ - \`mapx_callers\` - Direct and nested callers of a symbol
176
+ - \`mapx_callees\` - Direct and nested callees of a symbol
177
+ - \`mapx_trace\` - Trace data flow paths from a starting symbol or file
178
+ - \`mapx_sources\` - Find entry points (sources) in the codebase
179
+ - \`mapx_sinks\` - Find terminal consumers (sinks) in the codebase
180
+ - \`mapx_impact\` - Multi-depth blast radius and change risk analysis for a symbol
181
+ - \`mapx_clusters\` - List code clusters/modules
182
+ - \`mapx_status\` - Check scan status, languages breakdown, top PageRank files/symbols, and index recommendations
183
+ - \`mapx_export\` - Export compact graph summary (formats: llm, json, dot, svg, toon)
184
+ - \`mapx_context\` - Intelligent, token-budgeted workspace context builder
185
+ - \`mapx_workspaces\` - Retrieve workspace configuration and repositories (list/discover)
186
+ - \`mapx_lang_list\` - List supported languages and status
187
+ - \`mapx_lang_install\` - Install dynamic language support
188
+ - \`mapx_lang_uninstall\` - Uninstall dynamic language support
189
+
190
+ ## When to Use
191
+
192
+ 1. **Start of session**: Run \`mapx export\` to get a compact overview.
193
+ 2. **Need to find something**: Run \`mapx query <term>\` or \`mapx search\` instead of grepping.
194
+ 3. **Need to understand a file**: Run \`mapx deps <file>\` to see relationships.
195
+ 4. **Files changed**: Run \`mapx sync\` (or \`mapx update\`) to incrementally update the graph.
196
+ 5. **Major changes**: Run \`mapx scan\` for a full re-scan.
197
+ 6. **Need a visual overview**: Run \`mapx export --format=svg -o graph.svg\`.
198
+ 7. **Trace data flow / call chains**: Run \`mapx trace <symbol>\`, \`mapx callers\`, or \`mapx callees\`.
199
+ 8. **Planning a modification**: Run \`mapx impact\` to determine the blast radius.
200
+ 9. **Building custom prompts / context**: Run \`mapx context\` to generate optimal context within a token budget.`
201
+ },
202
+ claude: {
203
+ filename: "CLAUDE.md",
204
+ isAppend: false,
205
+ content: `# MapxGraph - Claude Integration Guide
206
+
207
+ This project is configured with **MapxGraph** for codebase navigation and graph query support across **22 languages**.
208
+
209
+ ## Claude Desktop Configuration
210
+
211
+ Add the following to your Claude Desktop configuration file (\`~/.config/Claude/claude_desktop_config.json\` or \`~/Library/Application Support/Claude/claude_desktop_config.json\`):
212
+
213
+ \`\`\`json
214
+ {
215
+ "mcpServers": {
216
+ "mapx-{{PROJECT_NAME}}": {
217
+ "command": "npx",
218
+ "args": [
219
+ "-y",
220
+ "mapx",
221
+ "serve",
222
+ "--dir",
223
+ "{{PROJECT_DIR}}"
224
+ ]
225
+ }
226
+ }
227
+ }
228
+ \`\`\`
229
+
230
+ ## MCP Tools Available (25 total)
231
+
232
+ **Graph Building:** \`mapx_scan\`, \`mapx_sync\`
233
+ **Symbol Discovery:** \`mapx_query\`, \`mapx_search\`, \`mapx_node\`, \`mapx_files\`
234
+ **Dependencies & Flow:** \`mapx_dependencies\`, \`mapx_callers\`, \`mapx_callees\`, \`mapx_trace\`, \`mapx_sources\`, \`mapx_sinks\`
235
+ **Analysis:** \`mapx_impact\`, \`mapx_clusters\`, \`mapx_status\`
236
+ **Export:** \`mapx_export\` (llm/json/dot/svg/toon), \`mapx_context\`
237
+ **Workspaces:** \`mapx_workspaces\` (list/discover)
238
+ **Languages:** \`mapx_lang_list\`, \`mapx_lang_install\`, \`mapx_lang_uninstall\`
239
+
240
+ ## Workflows
241
+
242
+ 1. Run \`mapx_export\` at the start of your session to gain context.
243
+ 2. Use \`mapx_query\` or \`mapx_search\` to find symbols.
244
+ 3. Use \`mapx_callers\` / \`mapx_callees\` to trace call chains.
245
+ 4. Run \`mapx_impact\` before making changes to understand blast radius.
246
+ 5. If files are modified, call \`mapx_sync\` to update the graph.
247
+ 6. Call \`mapx_trace\` to trace data flow paths.`
248
+ },
249
+ cursor: {
250
+ filename: ".cursor/rules/mapx.mdc",
251
+ isAppend: false,
252
+ content: `---
253
+ description: Rules for using MapxGraph for codebase understanding, symbol search, and data-flow tracing across 22 languages
254
+ globs: ["**/*"]
255
+ alwaysApply: false
256
+ ---
257
+ # Cursor Rules for MapxGraph
258
+
259
+ Use MapxGraph commands or MCP tools to understand code structure.
260
+
261
+ ## Available MCP Tools (25 total)
262
+
263
+ **Graph:** \`mapx_scan\`, \`mapx_sync\`
264
+ **Search:** \`mapx_query\`, \`mapx_search\`, \`mapx_node\`, \`mapx_files\`
265
+ **Deps:** \`mapx_dependencies\`, \`mapx_callers\`, \`mapx_callees\`, \`mapx_trace\`, \`mapx_sources\`, \`mapx_sinks\`
266
+ **Analysis:** \`mapx_impact\`, \`mapx_clusters\`, \`mapx_status\`
267
+ **Export:** \`mapx_export\` (llm/json/dot/svg/toon), \`mapx_context\`
268
+ **Workspaces:** \`mapx_workspaces\`
269
+ **Languages:** \`mapx_lang_list\`, \`mapx_lang_install\`, \`mapx_lang_uninstall\`
270
+
271
+ ## Workflow
272
+
273
+ 1. Always use \`mapx_export\` on startup rather than reading directories.
274
+ 2. Use \`mapx_search --kind class\` to find specific symbol types.
275
+ 3. Run \`mapx_impact\` before refactoring to assess blast radius.
276
+ 4. Run \`mapx_sync\` (or \`mapx_scan\`) after file changes.
277
+ 5. Query via \`mapx_query\` to navigate symbols.`
278
+ },
279
+ copilot: {
280
+ filename: ".github/copilot-instructions.md",
281
+ isAppend: true,
282
+ content: `## MapxGraph Integration
283
+
284
+ This project uses MapxGraph (22 languages, 25 MCP tools). You can run the following CLI commands to understand the codebase:
285
+ - \`mapx export\` - Graph overview (LLM summary, or --format=json/dot/svg/toon)
286
+ - \`mapx query <term>\` - Search symbols
287
+ - \`mapx search <term> --kind class\` - Advanced filtered search
288
+ - \`mapx deps <file>\` - View file dependencies
289
+ - \`mapx callers <symbol>\` - Trace callers
290
+ - \`mapx callees <symbol>\` - Trace callees
291
+ - \`mapx impact <symbol>\` - Change impact analysis
292
+ - \`mapx clusters\` - View logical modules
293
+ - \`mapx trace <symbol>\` - Trace data-flow paths
294
+ - \`mapx node <symbol> --source\` - Inspect symbol source code`
295
+ },
296
+ windsurf: {
297
+ filename: ".windsurf/rules/mapx.md",
298
+ isAppend: false,
299
+ content: `---
300
+ trigger: model_decided
301
+ ---
302
+ # MapxGraph Rules for Windsurf
303
+
304
+ This project utilizes MapxGraph to maintain local code indexes across **22 languages** with **25 MCP tools**.
305
+
306
+ Use the MapxGraph MCP tools or CLI commands to navigate:
307
+ - \`mapx_export\` / \`mapx export\` on startup.
308
+ - \`mapx_query\` / \`mapx query\` to locate definitions.
309
+ - \`mapx_search\` / \`mapx search\` for advanced filtered search.
310
+ - \`mapx_callers\` / \`mapx callers\` to trace call chains.
311
+ - \`mapx_impact\` / \`mapx impact\` before refactoring.
312
+ - \`mapx_trace\` / \`mapx trace\` to analyze data flow.
313
+ - \`mapx_sync\` / \`mapx sync\` after edits.`
314
+ },
315
+ cline: {
316
+ filename: ".clinerules",
317
+ isAppend: true,
318
+ content: `## MapxGraph Rules for Cline
319
+
320
+ This project is indexed by MapxGraph (22 languages, 25 MCP tools).
321
+ Auto-start the MCP server with the configured directory \`{{PROJECT_DIR}}\`.
322
+ Available tools:
323
+ - \`mapx_export\` - Call this first to get the summary.
324
+ - \`mapx_query\` / \`mapx_search\` - Find files or symbols.
325
+ - \`mapx_callers\` / \`mapx_callees\` - Trace call chains.
326
+ - \`mapx_impact\` - Assess blast radius before changes.
327
+ - \`mapx_trace\` - Trace data-flow callers and callees.
328
+ - \`mapx_context\` - Generate token-budgeted context.`
329
+ },
330
+ aider: {
331
+ filename: "AIDER.md",
332
+ isAppend: false,
333
+ content: `# MapxGraph Aider Integration
334
+
335
+ Use MapxGraph commands in this repository to analyze code across **22 languages**.
336
+
337
+ ## Key CLI Commands
338
+
339
+ - \`mapx export\`: Compact summary of the graph structure.
340
+ - \`mapx export --format=svg -o graph.svg\`: Visual graph export.
341
+ - \`mapx query <symbol>\`: Find locations and definitions.
342
+ - \`mapx search <term> --kind class\`: Advanced filtered search.
343
+ - \`mapx deps <file>\`: Show dependencies.
344
+ - \`mapx callers <symbol>\`: Show who calls a symbol.
345
+ - \`mapx callees <symbol>\`: Show what a symbol calls.
346
+ - \`mapx impact <symbol>\`: Change impact analysis.
347
+ - \`mapx trace <symbol>\`: Show data-flow traversal.
348
+ - \`mapx node <symbol> --source\`: View symbol source code.
349
+ - \`mapx sync\` (or \`mapx update\`): Run after edits.`
350
+ },
351
+ gemini: {
352
+ filename: "GEMINI.md",
353
+ isAppend: false,
354
+ content: `# MapxGraph Gemini Integration
355
+
356
+ Utilize MapxGraph to obtain codebase context for Gemini across **22 languages**.
357
+
358
+ ## CLI Commands
359
+
360
+ - Run \`mapx export\` to summarize the project (supports --format=llm/json/dot/svg/toon).
361
+ - Run \`mapx query <symbol>\` to locate symbols.
362
+ - Run \`mapx search <term>\` for advanced filtered search.
363
+ - Run \`mapx callers <symbol>\` / \`mapx callees <symbol>\` to trace call chains.
364
+ - Run \`mapx impact <symbol>\` to assess change blast radius.
365
+ - Run \`mapx trace <symbol>\` to analyze data flow.
366
+ - Run \`mapx node <symbol> --source\` to inspect a symbol's source code.
367
+ - Run \`mapx sync\` after file edits to update the graph.`
368
+ },
369
+ continue: {
370
+ filename: ".continue/mapx.yaml",
371
+ isAppend: false,
372
+ content: `# Continue configuration for MapxGraph (22 languages, 25 MCP tools)
373
+ contextProviders:
374
+ - name: cmd
375
+ args:
376
+ name: mapx-export
377
+ cmd: mapx export --tokens=4000
378
+ - name: cmd
379
+ args:
380
+ name: mapx-status
381
+ cmd: mapx status
382
+ `
383
+ },
384
+ zed: {
385
+ filename: ".zed/mapx-instructions.md",
386
+ isAppend: false,
387
+ content: `# Zed Assistant MapxGraph Instructions
388
+
389
+ This project uses MapxGraph (22 languages, 25 MCP tools).
390
+
391
+ ## Key Commands
392
+ - Run \`mapx export\` to retrieve a token-budgeted codebase summary.
393
+ - Run \`mapx query <symbol>\` to find definitions.
394
+ - Run \`mapx search <term>\` for advanced filtered search.
395
+ - Run \`mapx callers <symbol>\` / \`mapx callees <symbol>\` to trace call chains.
396
+ - Run \`mapx impact <symbol>\` to assess change risk before refactoring.
397
+ - Run \`mapx trace <symbol>\` to trace data flow.
398
+ - Run \`mapx sync\` after file edits to update the graph.`
399
+ },
400
+ antigravity: {
401
+ filename: ".agents/rules/mapx.md",
402
+ isAppend: false,
403
+ content: `# MapxGraph Initialization Rule
404
+
405
+ ## Context
406
+
407
+ Triggered when a new task is received, before any planning, reasoning, or execution steps begin.
408
+ This project is indexed by **MapxGraph** \u2014 a local code graph memory system (22 languages, 25 MCP tools) that provides persistent, structured understanding of the codebase.
409
+
410
+ ## Requirements
411
+
412
+ You must execute the following MCP tools immediately upon receiving a user prompt:
413
+
414
+ 1. Call \`mapx_sync\` to incrementally re-index any files changed since the last scan.
415
+ 2. Call \`mapx_export\` (with \`tokens: 8192\`) to retrieve a compact, PageRank-ranked codebase skeleton.
416
+
417
+ ## Constraints
418
+
419
+ * **Do not** generate a task plan or response text until both MCP tool responses are received.
420
+ * If either MCP call fails, report the initialization error to the user before proceeding.
421
+ * After receiving the export, use it as your primary codebase context \u2014 avoid reading entire files unless specifically needed.
422
+
423
+ ## Pre-Modification Workflow
424
+
425
+ Before editing any symbol (class, function, method, interface):
426
+
427
+ 1. Call \`mapx_impact\` on the target symbol to assess blast radius and risk score.
428
+ 2. Call \`mapx_callers\` to identify all upstream dependents.
429
+ 3. If impacted files > 3, call \`mapx_context\` with the affected symbols as seeds to build a token-budgeted context window.
430
+
431
+ ## Post-Modification Workflow
432
+
433
+ After completing file writes:
434
+
435
+ 1. Call \`mapx_sync\` to re-index modified files.
436
+ 2. Verify the updated graph reflects your changes before reporting completion.
437
+
438
+ ## Available MCP Tools
439
+
440
+ **Graph Building:** \`mapx_scan\`, \`mapx_sync\`
441
+ **Symbol Discovery:** \`mapx_query\`, \`mapx_search\`, \`mapx_node\`, \`mapx_files\`
442
+ **Dependencies & Flow:** \`mapx_dependencies\`, \`mapx_callers\`, \`mapx_callees\`, \`mapx_trace\`, \`mapx_sources\`, \`mapx_sinks\`
443
+ **Analysis:** \`mapx_impact\`, \`mapx_clusters\`, \`mapx_status\`
444
+ **Export:** \`mapx_export\` (llm/json/dot/svg/toon), \`mapx_context\`
445
+ **Workspaces:** \`mapx_workspaces\` (list/discover)
446
+ **Languages:** \`mapx_lang_list\`, \`mapx_lang_install\`, \`mapx_lang_uninstall\`
447
+
448
+ ## Key Principles
449
+
450
+ * **Pre-Planning Trigger**: Always sync and export before planning. Never act on stale graph data.
451
+ * **Strict Ordering**: Initialization \u2192 Impact Analysis \u2192 Planning \u2192 Execution \u2192 Re-sync.
452
+ * **Fail-Safe**: Prevent the agent from acting on unverified workspace data.
453
+ * **Token Efficiency**: Use \`mapx_export\` and \`mapx_context\` instead of reading raw source files \u2014 reduces token usage by up to 87%.`
454
+ }
455
+ };
456
+ export {
457
+ MCP_CONFIGS,
458
+ TEMPLATES
459
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { Command } from 'commander';
2
+ import { Store } from './core/store.js';
3
+ import { MapxGraph } from './core/graph.js';
4
+ import { Config } from './core/config.js';
5
+ import './core/store-interface.js';
6
+ import './types.js';
7
+ import './languages/registry.js';
8
+
9
+ declare function buildCLI(): Command;
10
+ declare function loadContext(dir: string): Promise<{
11
+ config: Config;
12
+ store: Store;
13
+ graph: MapxGraph;
14
+ }>;
15
+
16
+ export { buildCLI, loadContext };