weavatrix 0.3.13 → 1.0.0

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 (303) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +231 -199
  3. package/bin/native/darwin-arm64/weavatrix +0 -0
  4. package/bin/native/darwin-x64/weavatrix +0 -0
  5. package/bin/native/linux-arm64/weavatrix +0 -0
  6. package/bin/native/linux-x64/weavatrix +0 -0
  7. package/bin/native/win32-arm64/weavatrix.exe +0 -0
  8. package/bin/native/win32-x64/weavatrix.exe +0 -0
  9. package/bin/resolve-binary.mjs +73 -0
  10. package/bin/run-native.mjs +26 -0
  11. package/bin/weavatrix-mcp.mjs +7 -6
  12. package/bin/weavatrix.mjs +5 -0
  13. package/package.json +8 -65
  14. package/skill/SKILL.md +62 -374
  15. package/skill/agents/openai.yaml +4 -0
  16. package/skill/references/tool-routing.md +45 -0
  17. package/SECURITY.md +0 -101
  18. package/docs/adr/0001-v0.3-offline-online-split.md +0 -60
  19. package/docs/agent-task-benchmark.md +0 -58
  20. package/docs/releases/v0.2.19.md +0 -33
  21. package/docs/releases/v0.3.0.md +0 -43
  22. package/docs/releases/v0.3.1.md +0 -30
  23. package/docs/releases/v0.3.10.md +0 -76
  24. package/docs/releases/v0.3.11.md +0 -55
  25. package/docs/releases/v0.3.12.md +0 -44
  26. package/docs/releases/v0.3.13.md +0 -34
  27. package/docs/releases/v0.3.2.md +0 -15
  28. package/docs/releases/v0.3.3.md +0 -25
  29. package/docs/releases/v0.3.4.md +0 -40
  30. package/docs/releases/v0.3.5.md +0 -50
  31. package/docs/releases/v0.3.6.md +0 -44
  32. package/docs/releases/v0.3.7.md +0 -37
  33. package/docs/releases/v0.3.8.md +0 -21
  34. package/docs/releases/v0.3.9.md +0 -36
  35. package/scripts/run-agent-task-benchmark.mjs +0 -118
  36. package/src/analysis/allowed-test-runner.js +0 -70
  37. package/src/analysis/architecture/contract-graph.js +0 -119
  38. package/src/analysis/architecture/contract-schema.js +0 -110
  39. package/src/analysis/architecture/contract-storage.js +0 -35
  40. package/src/analysis/architecture/contract-verification.js +0 -168
  41. package/src/analysis/architecture-contract.js +0 -16
  42. package/src/analysis/audit-debt.js +0 -94
  43. package/src/analysis/audit-extensions.js +0 -60
  44. package/src/analysis/cargo-dependency-evidence.js +0 -108
  45. package/src/analysis/cargo-manifests.js +0 -81
  46. package/src/analysis/change-classification/diff-parser.js +0 -103
  47. package/src/analysis/change-classification/options.js +0 -40
  48. package/src/analysis/change-classification/symbol-classifier.js +0 -177
  49. package/src/analysis/change-classification.js +0 -188
  50. package/src/analysis/coverage-reports.js +0 -235
  51. package/src/analysis/cycle-route.js +0 -14
  52. package/src/analysis/data-flow-evidence.js +0 -114
  53. package/src/analysis/dead-check.js +0 -300
  54. package/src/analysis/dead-code-review/candidates.js +0 -194
  55. package/src/analysis/dead-code-review/policy.js +0 -23
  56. package/src/analysis/dead-code-review.js +0 -119
  57. package/src/analysis/dep-check-ecosystems.js +0 -205
  58. package/src/analysis/dep-check.js +0 -290
  59. package/src/analysis/dep-rules.js +0 -10
  60. package/src/analysis/dependency/conventions.js +0 -16
  61. package/src/analysis/dependency/scoped-dependencies.js +0 -51
  62. package/src/analysis/dependency/source-references.js +0 -21
  63. package/src/analysis/duplicate-groups.js +0 -104
  64. package/src/analysis/duplicates-worker.js +0 -11
  65. package/src/analysis/duplicates.compute.js +0 -269
  66. package/src/analysis/duplicates.js +0 -15
  67. package/src/analysis/duplicates.run.js +0 -52
  68. package/src/analysis/duplicates.tokenize.js +0 -199
  69. package/src/analysis/endpoints/common.js +0 -62
  70. package/src/analysis/endpoints/extract.js +0 -107
  71. package/src/analysis/endpoints/inventory.js +0 -84
  72. package/src/analysis/endpoints/mounts.js +0 -129
  73. package/src/analysis/endpoints-java.js +0 -260
  74. package/src/analysis/endpoints-rust.js +0 -124
  75. package/src/analysis/endpoints.js +0 -3
  76. package/src/analysis/findings.js +0 -70
  77. package/src/analysis/git-history/analytics.js +0 -177
  78. package/src/analysis/git-history/collector.js +0 -67
  79. package/src/analysis/git-history/options.js +0 -66
  80. package/src/analysis/git-history.js +0 -143
  81. package/src/analysis/git-ref-graph.js +0 -76
  82. package/src/analysis/go-dependency-evidence.js +0 -62
  83. package/src/analysis/graph-analysis.aggregate.js +0 -295
  84. package/src/analysis/graph-analysis.edges.js +0 -24
  85. package/src/analysis/graph-analysis.js +0 -7
  86. package/src/analysis/graph-analysis.refs.js +0 -154
  87. package/src/analysis/graph-analysis.summaries.js +0 -65
  88. package/src/analysis/health-capabilities.js +0 -83
  89. package/src/analysis/hot-path-review.js +0 -266
  90. package/src/analysis/http-contract-wrappers.js +0 -241
  91. package/src/analysis/http-contracts/analysis.js +0 -179
  92. package/src/analysis/http-contracts/client-call-detection.js +0 -82
  93. package/src/analysis/http-contracts/client-call-parser.js +0 -273
  94. package/src/analysis/http-contracts/graph-context.js +0 -143
  95. package/src/analysis/http-contracts/matching.js +0 -61
  96. package/src/analysis/http-contracts/shared.js +0 -85
  97. package/src/analysis/http-contracts.js +0 -6
  98. package/src/analysis/internal-audit/dependency-health.js +0 -113
  99. package/src/analysis/internal-audit/python-manifests.js +0 -78
  100. package/src/analysis/internal-audit/repo-files.js +0 -50
  101. package/src/analysis/internal-audit/supply-chain.js +0 -149
  102. package/src/analysis/internal-audit.collect.js +0 -213
  103. package/src/analysis/internal-audit.js +0 -9
  104. package/src/analysis/internal-audit.reach.js +0 -173
  105. package/src/analysis/internal-audit.run.js +0 -256
  106. package/src/analysis/java-source.js +0 -36
  107. package/src/analysis/jvm-artifact-index.js +0 -87
  108. package/src/analysis/jvm-dependency-evidence.js +0 -138
  109. package/src/analysis/jvm-manifests.js +0 -114
  110. package/src/analysis/manifests.js +0 -123
  111. package/src/analysis/package-reachability.js +0 -39
  112. package/src/analysis/source-complexity.ast.js +0 -97
  113. package/src/analysis/source-complexity.constants.js +0 -55
  114. package/src/analysis/source-complexity.js +0 -14
  115. package/src/analysis/source-complexity.report.js +0 -81
  116. package/src/analysis/source-complexity.walk.js +0 -228
  117. package/src/analysis/source-correctness/retry-patterns.js +0 -93
  118. package/src/analysis/source-correctness.js +0 -222
  119. package/src/analysis/static-test-reachability.js +0 -150
  120. package/src/analysis/structure/dependency-graph.js +0 -151
  121. package/src/analysis/structure/findings.js +0 -162
  122. package/src/analysis/task-retrieval.js +0 -107
  123. package/src/analysis/transport-contracts.js +0 -224
  124. package/src/analysis/transport-runtime-evidence.js +0 -155
  125. package/src/analysis-kit.mjs +0 -17
  126. package/src/bounds.js +0 -4
  127. package/src/build-graph.js +0 -209
  128. package/src/child-env.js +0 -7
  129. package/src/config.js +0 -5
  130. package/src/extension/local-services.mjs +0 -75
  131. package/src/git-exec.js +0 -67
  132. package/src/graph/build-worker.js +0 -49
  133. package/src/graph/builder/go-receiver-resolution.js +0 -112
  134. package/src/graph/builder/js/dynamic-import.js +0 -26
  135. package/src/graph/builder/js/queries.js +0 -48
  136. package/src/graph/builder/lang-csharp.js +0 -40
  137. package/src/graph/builder/lang-css.js +0 -29
  138. package/src/graph/builder/lang-go.js +0 -140
  139. package/src/graph/builder/lang-html.js +0 -29
  140. package/src/graph/builder/lang-java-calls.js +0 -142
  141. package/src/graph/builder/lang-java.js +0 -215
  142. package/src/graph/builder/lang-js.js +0 -291
  143. package/src/graph/builder/lang-python.js +0 -235
  144. package/src/graph/builder/lang-rust-calls.js +0 -63
  145. package/src/graph/builder/lang-rust.js +0 -299
  146. package/src/graph/builder/lang-solidity.js +0 -126
  147. package/src/graph/builder/lang-sql.js +0 -263
  148. package/src/graph/builder/pass2-resolution.js +0 -81
  149. package/src/graph/builder/spec-pkg.js +0 -87
  150. package/src/graph/community.js +0 -27
  151. package/src/graph/edge-provenance.js +0 -31
  152. package/src/graph/file-lock.js +0 -69
  153. package/src/graph/freshness-probe.js +0 -142
  154. package/src/graph/graph-filter.js +0 -63
  155. package/src/graph/incremental-refresh.js +0 -235
  156. package/src/graph/internal-builder.barrels.js +0 -235
  157. package/src/graph/internal-builder.build.js +0 -300
  158. package/src/graph/internal-builder.java.js +0 -33
  159. package/src/graph/internal-builder.js +0 -12
  160. package/src/graph/internal-builder.langs.js +0 -157
  161. package/src/graph/internal-builder.pass2.js +0 -163
  162. package/src/graph/internal-builder.resolvers.js +0 -286
  163. package/src/graph/layout.js +0 -51
  164. package/src/graph/node-id.js +0 -7
  165. package/src/graph/parser-artifact-boundary.js +0 -55
  166. package/src/graph/relations.js +0 -4
  167. package/src/graph/repo-registry.js +0 -124
  168. package/src/graph/resolvers/rust.js +0 -117
  169. package/src/infra/infra-items.js +0 -255
  170. package/src/infra/infra-registry.js +0 -184
  171. package/src/infra/infra.detect.js +0 -119
  172. package/src/infra/infra.js +0 -38
  173. package/src/infra/infra.match.js +0 -102
  174. package/src/infra/infra.scan.js +0 -93
  175. package/src/mcp/actions/graph-lifecycle.mjs +0 -148
  176. package/src/mcp/architecture-bootstrap.mjs +0 -168
  177. package/src/mcp/architecture-starter.mjs +0 -234
  178. package/src/mcp/catalog.mjs +0 -233
  179. package/src/mcp/company-contract-page.mjs +0 -142
  180. package/src/mcp/company-contract-reconcile.mjs +0 -87
  181. package/src/mcp/company-contract-verdict.mjs +0 -42
  182. package/src/mcp/evidence/bun-lock-graph.mjs +0 -209
  183. package/src/mcp/evidence/duplicate-member-order.mjs +0 -8
  184. package/src/mcp/evidence/package-graph-common.mjs +0 -115
  185. package/src/mcp/evidence/package-lock-graph.mjs +0 -92
  186. package/src/mcp/evidence-snapshot.architecture.mjs +0 -80
  187. package/src/mcp/evidence-snapshot.common.mjs +0 -158
  188. package/src/mcp/evidence-snapshot.duplicates.mjs +0 -213
  189. package/src/mcp/evidence-snapshot.health.mjs +0 -102
  190. package/src/mcp/evidence-snapshot.inventory.mjs +0 -148
  191. package/src/mcp/evidence-snapshot.mjs +0 -50
  192. package/src/mcp/evidence-snapshot.package-graph.mjs +0 -34
  193. package/src/mcp/evidence-snapshot.structure.mjs +0 -84
  194. package/src/mcp/extension-api.mjs +0 -77
  195. package/src/mcp/git-output.mjs +0 -7
  196. package/src/mcp/graph/context-core.mjs +0 -111
  197. package/src/mcp/graph/context-seeds.mjs +0 -207
  198. package/src/mcp/graph/context-state.mjs +0 -85
  199. package/src/mcp/graph/reverse-reach.mjs +0 -42
  200. package/src/mcp/graph/tools-core.mjs +0 -143
  201. package/src/mcp/graph/tools-query.mjs +0 -276
  202. package/src/mcp/graph-context.mjs +0 -5
  203. package/src/mcp/graph-diff.mjs +0 -218
  204. package/src/mcp/health/audit-format.mjs +0 -199
  205. package/src/mcp/health/audit.mjs +0 -174
  206. package/src/mcp/health/dead-code.mjs +0 -110
  207. package/src/mcp/health/duplicates.mjs +0 -85
  208. package/src/mcp/health/endpoints.mjs +0 -71
  209. package/src/mcp/health/structure.mjs +0 -219
  210. package/src/mcp/runtime-version.mjs +0 -31
  211. package/src/mcp/server/auto-refresh.mjs +0 -66
  212. package/src/mcp/server/runtime-config.mjs +0 -43
  213. package/src/mcp/server/shutdown.mjs +0 -40
  214. package/src/mcp/staleness-notice.mjs +0 -20
  215. package/src/mcp/sync/evidence-architecture.mjs +0 -54
  216. package/src/mcp/sync/evidence-common.mjs +0 -88
  217. package/src/mcp/sync/evidence-duplicates.mjs +0 -97
  218. package/src/mcp/sync/evidence-health.mjs +0 -56
  219. package/src/mcp/sync/evidence-packages.mjs +0 -95
  220. package/src/mcp/sync/payload-common.mjs +0 -97
  221. package/src/mcp/sync/payload-v2.mjs +0 -54
  222. package/src/mcp/sync/payload-v3.mjs +0 -79
  223. package/src/mcp/sync-evidence.mjs +0 -23
  224. package/src/mcp/sync-payload.mjs +0 -70
  225. package/src/mcp/tool-result.mjs +0 -54
  226. package/src/mcp/tools-actions.mjs +0 -11
  227. package/src/mcp/tools-architecture.mjs +0 -177
  228. package/src/mcp/tools-company.mjs +0 -251
  229. package/src/mcp/tools-context.mjs +0 -222
  230. package/src/mcp/tools-endpoints.mjs +0 -207
  231. package/src/mcp/tools-graph-hubs.mjs +0 -78
  232. package/src/mcp/tools-graph.mjs +0 -17
  233. package/src/mcp/tools-health.mjs +0 -24
  234. package/src/mcp/tools-history.mjs +0 -28
  235. package/src/mcp/tools-impact-change.mjs +0 -220
  236. package/src/mcp/tools-impact-precision.mjs +0 -89
  237. package/src/mcp/tools-impact.mjs +0 -169
  238. package/src/mcp/tools-source.mjs +0 -238
  239. package/src/mcp/tools-verified-change.mjs +0 -200
  240. package/src/mcp-rg.mjs +0 -50
  241. package/src/mcp-runtime.mjs +0 -2
  242. package/src/mcp-server.mjs +0 -298
  243. package/src/mcp-source-tools.mjs +0 -163
  244. package/src/path-classification.js +0 -220
  245. package/src/path-ignore.js +0 -69
  246. package/src/precision/lsp-client/constants.js +0 -12
  247. package/src/precision/lsp-client/environment.js +0 -20
  248. package/src/precision/lsp-client/errors.js +0 -15
  249. package/src/precision/lsp-client/lifecycle.js +0 -114
  250. package/src/precision/lsp-client/message-parser.js +0 -81
  251. package/src/precision/lsp-client/protocol.js +0 -212
  252. package/src/precision/lsp-client/registry.js +0 -59
  253. package/src/precision/lsp-client/repo-uri.js +0 -60
  254. package/src/precision/lsp-client/stdio-client.js +0 -140
  255. package/src/precision/lsp-client.js +0 -10
  256. package/src/precision/lsp-overlay/budget-policy.js +0 -78
  257. package/src/precision/lsp-overlay/build.js +0 -261
  258. package/src/precision/lsp-overlay/contract.js +0 -61
  259. package/src/precision/lsp-overlay/reference-results.js +0 -108
  260. package/src/precision/lsp-overlay/semantic-inputs.js +0 -62
  261. package/src/precision/lsp-overlay/source-session.js +0 -142
  262. package/src/precision/lsp-overlay/store.js +0 -150
  263. package/src/precision/lsp-overlay/target-index.js +0 -152
  264. package/src/precision/lsp-overlay/target-query.js +0 -55
  265. package/src/precision/lsp-overlay.js +0 -11
  266. package/src/precision/symbol-query.js +0 -224
  267. package/src/precision/typescript-lsp-provider.js +0 -12
  268. package/src/precision/typescript-provider/client.js +0 -89
  269. package/src/precision/typescript-provider/discovery.js +0 -124
  270. package/src/precision/typescript-provider/isolated-runtime.js +0 -39
  271. package/src/precision/typescript-provider/project-host.js +0 -254
  272. package/src/precision/typescript-provider/project-safety.js +0 -166
  273. package/src/precision/typescript-provider/reference-usage.js +0 -53
  274. package/src/process.js +0 -95
  275. package/src/repo-path.js +0 -53
  276. package/src/scan/discover.inventory.js +0 -78
  277. package/src/scan/discover.js +0 -5
  278. package/src/scan/discover.list.js +0 -79
  279. package/src/scan/discover.stack.js +0 -227
  280. package/src/scan/search.core.js +0 -24
  281. package/src/scan/search.git.js +0 -102
  282. package/src/scan/search.js +0 -9
  283. package/src/scan/search.node.js +0 -83
  284. package/src/scan/search.preview.js +0 -49
  285. package/src/scan/search.rg.js +0 -145
  286. package/src/security/advisory-store.js +0 -172
  287. package/src/security/installed-jvm-rust.js +0 -46
  288. package/src/security/installed.js +0 -280
  289. package/src/security/malware-file-heuristics.js +0 -121
  290. package/src/security/malware-heuristics.exclusions.js +0 -134
  291. package/src/security/malware-heuristics.js +0 -15
  292. package/src/security/malware-heuristics.roots.js +0 -145
  293. package/src/security/malware-heuristics.scan.js +0 -89
  294. package/src/security/malware-heuristics.sweep.js +0 -122
  295. package/src/security/malware-scoring.js +0 -105
  296. package/src/security/match.js +0 -85
  297. package/src/security/registry-sig.classify.js +0 -137
  298. package/src/security/registry-sig.js +0 -18
  299. package/src/security/registry-sig.rules.js +0 -192
  300. package/src/security/rust-advisory-report.js +0 -60
  301. package/src/security/typosquat.js +0 -81
  302. package/src/util.js +0 -40
  303. package/src/version.js +0 -7
package/LICENSE CHANGED
@@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
package/README.md CHANGED
@@ -1,233 +1,265 @@
1
1
  # Weavatrix
2
2
 
3
- **Local repository intelligence for AI coding agents — understand an application fast, then change it with evidence.**
3
+ [![CI](https://github.com/sergii-ziborov/weavatrix/actions/workflows/ci.yml/badge.svg)](https://github.com/sergii-ziborov/weavatrix/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/weavatrix.svg)](https://www.npmjs.com/package/weavatrix)
5
+ [![crates.io](https://img.shields.io/crates/v/weavatrix-rust.svg)](https://crates.io/crates/weavatrix-rust)
6
+ [![docs.rs](https://docs.rs/weavatrix-rust/badge.svg)](https://docs.rs/weavatrix-rust)
7
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sergii-ziborov/weavatrix/blob/main/LICENSE)
8
+
9
+ **Give your coding agent the map of the repository before it starts guessing.**
10
+
11
+ Weavatrix is a native Rust repository-intelligence engine and MCP server for
12
+ Codex, Claude Code, and other coding agents. It turns source, Git history,
13
+ coverage, endpoints, infrastructure, clones, search, vectors, semantic links,
14
+ and temporal memory into one always-fresh evidence graph.
15
+
16
+ Ask what breaks, where an API is used, why a cycle exists, which code is truly
17
+ dead, or whether a change preserved the architecture. Weavatrix answers from
18
+ bounded graph evidence with file, line, extractor, confidence, and revision
19
+ provenance—not from a wider grep and not from a fabricated certainty score.
20
+
21
+ | Release proof | Result |
22
+ | --- | ---: |
23
+ | Read-only MCP tools | **39** |
24
+ | Installed-package cold speed vs `weavatrix-js` | **30.34x** |
25
+ | Warm tool-call speed vs `weavatrix-js` | **156.10x** |
26
+ | Shared JS call targets missing or wrong | **0 / 0** |
27
+ | Shared imports, methods, and re-exports covered | **100%** |
28
+ | Rust line coverage release gate | **87.18%** |
29
+ | Runtime downloads, install scripts, external executables | **0** |
30
+
31
+ ## Install in 30 seconds
4
32
 
5
- Weavatrix builds a reusable living graph of any local repository — files, symbols, imports, calls,
6
- inheritance, Health findings, clone families and Git-history coupling — and gives Claude Code, Codex
7
- or any MCP client a bounded map for fast understanding and low repeated context. The same graph then
8
- answers change impact, Health, dead-code review, duplicates, history and intended-architecture
9
- questions. **34 network-free tools. No repository data leaves your machine.**
10
-
11
- - Website: [weavatrix.com](https://weavatrix.com)
12
- - Source: [github.com/sergii-ziborov/weavatrix](https://github.com/sergii-ziborov/weavatrix)
13
- - npm: [`weavatrix`](https://www.npmjs.com/package/weavatrix) — `npx -y weavatrix <repoRoot>`
14
-
15
- This package is the complete offline engine under the MIT license: it reads and analyzes your code,
16
- initiates no outbound HTTP, and never edits your source. It is the read-only base of a layered stack —
17
- add [`weavatrix-refactor`](https://github.com/sergii-ziborov/weavatrix-refactor) (Apache-2.0) to apply
18
- hash-verified, reversible edits, or [`weavatrix-online`](https://github.com/sergii-ziborov/weavatrix-online)
19
- for authorized Cloud or self-hosted sync. Each is an optional superset that depends on this core through
20
- a supported extension API; the offline/online split is documented in
21
- [docs/adr/0001-v0.3-offline-online-split.md](docs/adr/0001-v0.3-offline-online-split.md).
22
-
23
- ## Install
33
+ ```sh
34
+ npx -y weavatrix mcp .
35
+ ```
24
36
 
25
- Requires Node ≥ 18.
37
+ Or install the Rust binary directly:
26
38
 
27
39
  ```sh
28
- # Claude Code
29
- claude mcp add -s user weavatrix -- npx -y weavatrix <repoRoot>
30
-
31
- # Codex CLI
32
- codex mcp add weavatrix -- npx -y weavatrix <repoRoot>
40
+ cargo install weavatrix-rust
41
+ weavatrix mcp . --profile=all
33
42
  ```
34
43
 
44
+ ### Codex
45
+
35
46
  ```toml
36
- # or in ~/.codex/config.toml
47
+ # ~/.codex/config.toml
37
48
  [mcp_servers.weavatrix]
38
49
  command = "npx"
39
- args = ["-y", "weavatrix", "C:/path/to/repo"]
40
- startup_timeout_sec = 20
41
- tool_timeout_sec = 60
50
+ args = ["-y", "weavatrix", "mcp", "."]
42
51
  ```
43
52
 
44
- Or run from a clone:
53
+ ### Claude Code
45
54
 
46
55
  ```sh
47
- git clone https://github.com/sergii-ziborov/weavatrix
48
- cd weavatrix && npm install
49
- claude mcp add -s user weavatrix -- node <path-to>/weavatrix/bin/weavatrix-mcp.mjs <repoRoot>
56
+ claude mcp add weavatrix -- npx -y weavatrix mcp .
50
57
  ```
51
58
 
52
- `<repoRoot>` is the repository to start with. Graphs are derived data and never live in your repo:
53
- they are stored in the per-user registry at `~/.weavatrix/graphs/<repository-storage-key>/graph.json`
54
- (with a stable `.repository-id` beside them). No graph yet? Ask the agent to call `rebuild_graph`, or
55
- just use a tool — graph and Health reads auto-reconcile the working graph before answering.
59
+ The npm package contains prebuilt binaries for Windows x64/arm64, macOS
60
+ x64/arm64, and glibc-based Linux x64/arm64. It has no install script and does
61
+ not download a binary after installation.
62
+
63
+ ## What your agent can ask
64
+
65
+ ```text
66
+ What breaks if I change src/auth/middleware.ts?
67
+ Trace POST /api/orders through the backend and its clients.
68
+ Which production symbols are dead, and what evidence says so?
69
+ Show duplicate implementations but suppress router boilerplate.
70
+ Which service violates the intended architecture, and why?
71
+ Find every HTTP, GraphQL, gRPC, Kafka, RabbitMQ, NATS, JMS,
72
+ SQS or SNS contract affected by this branch.
73
+ Build the smallest context bundle needed to edit this symbol safely.
74
+ Suggest internal links between these pages without mixing inferred SEO
75
+ relationships into the deterministic code graph.
76
+ ```
56
77
 
57
- An agent skill with recipes ships in [skill/SKILL.md](skill/SKILL.md) — install it as
58
- `~/.claude/skills/weavatrix/SKILL.md` (Claude Code) or `~/.codex/skills/weavatrix/SKILL.md` (Codex).
78
+ Weavatrix builds the graph once and projects the same revision into small,
79
+ task-specific answers. A health result, endpoint trace, blast radius, clone
80
+ family, architecture violation, and context bundle therefore agree about
81
+ repository identity and evidence.
59
82
 
60
- ## Configure
83
+ ## The 39-tool surface
61
84
 
62
- **Security profile** — pass a profile as the final positional argument (omitted = `offline`):
85
+ | Workflow | Tools |
86
+ | --- | --- |
87
+ | Graph orientation | `graph_stats`, `get_node`, `get_neighbors`, `query_graph`, `god_nodes`, `shortest_path`, `get_community`, `list_communities`, `module_map` |
88
+ | Change impact and proof | `get_dependents`, `change_impact`, `verified_change`, `prepare_change`, `graph_diff` |
89
+ | Exact source context | `search_code`, `read_source`, `inspect_symbol`, `context_bundle` |
90
+ | Health and quality | `find_duplicates`, `find_dead_code`, `run_audit`, `coverage_map`, `hot_path_review` |
91
+ | APIs and transports | `list_endpoints`, `trace_endpoint`, `trace_api_contract` |
92
+ | Architecture | `get_architecture_contract`, `verify_architecture`, `explain_architecture_violation`, `propose_architecture_exception` |
93
+ | Git and repositories | `git_history`, `cross_repo_git`, `open_repo`, `list_known_repos`, `rebuild_graph` |
94
+ | Native Rust extensions | `vector_search`, `semantic_link`, `seo_link_suggestions`, `memory_context` |
63
95
 
64
- | Profile | Local repository switching | Cross-repo graph reads | Network requests | Tools |
65
- |---|---:|---:|---:|---:|
66
- | `offline` (default) | Yes, only via `open_repo` | Yes, only via `trace_api_contract` | None | 34 |
67
- | `pinned` | No | No | None | 31 |
96
+ Three profiles expose bounded views of the same read-only engine:
68
97
 
69
98
  ```sh
70
- # hard-pin one repository and expose no cross-repo tools:
71
- claude mcp add -s user weavatrix -- npx -y weavatrix <repoRoot> pinned
99
+ weavatrix mcp . --profile=all # all 39 tools
100
+ weavatrix mcp . --profile=code # code and architecture
101
+ weavatrix mcp . --profile=seo # content and semantic linking
72
102
  ```
73
103
 
74
- Advanced registrations may pass an exact comma-separated capability set instead:
75
- `graph,search,source,health,build,retarget,crossrepo`. A custom list must include `crossrepo` to
76
- expose `trace_api_contract`. Legacy `online`/`osv`/`hosted`/`full` names fail loudly and point to
77
- `weavatrix-online`.
78
-
79
- **Semantic precision** — a bounded, read-only TypeScript/JavaScript language-server overlay is on by
80
- default for new graphs and upgrades confirmed references to `EXACT_LSP`. Turn it off for parser-only
81
- operation with `WEAVATRIX_PRECISION=off` (env), `precision:"off"` on `rebuild_graph`/`open_repo`, or
82
- the MCPB installer's precision choice. Java and Rust have no bundled language server; their edges stay
83
- parser-derived.
84
-
85
- The startup prewarm queries 32 ranked symbols (never more than 64) by default. For a deliberate
86
- high-budget pass, set `WEAVATRIX_PRECISION_MAX_SYMBOLS` above 64 or `WEAVATRIX_PRECISION_PREWARM=full`
87
- to cover every eligible target up to a 10,000-symbol ceiling; `WEAVATRIX_PRECISION_MAX_REFERENCES`,
88
- `WEAVATRIX_PRECISION_MAX_LINKS` and `WEAVATRIX_PRECISION_TIMEOUT_MS` tune the budgets. Repositories
89
- that exceed a hard ceiling stay honestly `PARTIAL`.
90
-
91
- **Repository config files** (all optional, repository-root):
92
-
93
- - `.weavatrixignore` — analysis-only exclusions that should stay tracked in Git (`*`, `**`, `?`,
94
- root-anchored `/patterns`, directory suffixes, ordered `!` re-includes).
95
- - `.weavatrix.json` — cross-repository HTTP client/wrapper contracts (`httpContracts`) and
96
- `classify.product` overrides.
97
- - `.weavatrix-deps.json` — `entrypoints`, `nonRuntimeRoots`, and Python `managedDependencies` /
98
- `ignoreDependencies` for conventions that cannot be inferred safely.
99
-
100
- **Test execution** — `verified_change` is read-only by default. Running an existing package
101
- test/check/verify script requires both `run_tests:true` and `WEAVATRIX_ALLOW_TEST_RUNS=1`; arbitrary
102
- commands are always rejected.
103
-
104
- After an upgrade, reconnect the MCP server or start a new agent task before checking the tool list —
105
- many clients snapshot `tools/list` for the lifetime of a connection. `graph_stats` reports the running
106
- version, enabled capabilities and registered-tool count so a cached process is distinguishable from
107
- the installed package.
108
-
109
- ## Tools
110
-
111
- The 34 methods project the same reusable graph into the smallest view a task needs.
112
-
113
- - **graph** — `graph_stats`, `get_node`, `get_neighbors`, `query_graph`, `god_nodes`, `shortest_path`,
114
- `get_community`, `list_communities`, `module_map`, `get_dependents`, `change_impact`,
115
- `verified_change`, `git_history`, `graph_diff`, `get_architecture_contract`, `prepare_change`.
116
- Runtime, TypeScript type-only and language compile-only edges are reported separately; every edge
117
- carries versioned provenance (`EXTRACTED` / `RESOLVED` / `INFERRED`, upgraded to `EXACT_LSP` only by
118
- the bundled TS/JS overlay, `CONFLICT` when evidence disagrees).
119
- - **search / source** — `search_code` (ripgrep-backed with a pure-Node fallback and
120
- repository-relative path globs), `read_source`, `context_bundle`, `inspect_symbol`,
121
- `list_endpoints` (Express/Fastify/Nest/Flask/FastAPI/Go mux/Rust axum & actix-web/Spring),
122
- `trace_endpoint`.
123
- - **health** — `find_dead_code`, `run_audit` (capability matrix + unused files/exports/dependencies,
124
- missing/duplicate deps, offline OSV vulnerabilities, typosquats, lockfile drift; `base_ref` +
125
- `debt: new|existing|all` for review-scoped results), `find_duplicates` (MOSS winnowing, catches
126
- renamed clones), `coverage_map`, `hot_path_review`, `verify_architecture`,
127
- `explain_architecture_violation`, `propose_architecture_exception`.
128
- - **build** — `rebuild_graph` (reports the structural delta, keeps the prior state as `graph.prev.json`).
129
- - **retarget** *(in `offline`, absent from `pinned`)* — `open_repo`, `list_known_repos`.
130
- - **crossrepo** *(in `offline`, absent from `pinned`)* — `trace_api_contract` (joins routes to client
131
- call-sites across registered local graphs; reads no source). Results are compact and paginated by
132
- default (`page_size`, opaque `cursor`, and bounded `per_item_limit` samples); `response_detail="full"`
133
- is an explicit opt-in and remains paginated.
134
-
135
- Every finding is review evidence, never an auto-delete verdict: `find_dead_code` /
136
- `run_audit category=unused` always return `REVIEW_REQUIRED` with `autoDelete:false`. Typecheck, tests
137
- and runtime checks remain the release authority.
138
-
139
- ## Always-fresh graph
140
-
141
- There is no watcher daemon to run and no manual refresh step: every graph/health call reconciles the
142
- graph before answering. A Git-token freshness probe (HEAD + dirty/untracked content, debounced 2 s)
143
- decides whether anything changed; when it did, a bounded incremental refresh reparses only the changed
144
- files plus their reverse importers (≤ 24 changed / ≤ 80 reparsed JS/TS files) and merges the scoped
145
- result into the previous graph under a file lock. Config/lockfile edits, export-surface changes,
146
- barrel files and non-JS/TS languages fall back to a full rebuild — correctness always wins over speed.
147
- Each refreshed answer carries a structured `refresh` record (`none` / `incremental` / `full`, changed
148
- file count), so an agent can tell exactly which repository state it is reasoning about. The same
149
- guarantees hold across concurrent MCP clients sharing one canonical graph.
150
-
151
- ## Benchmarks
152
-
153
- Two gates ship in the repository:
154
-
155
- - `npm run benchmark` — a reproducible golden suite for TypeScript, JavaScript, Python, Go, Java and
156
- Rust, plus cross-repository HTTP matching, framework conventions and the MCP graph lifecycle.
157
- - `npm run benchmark:real` — compares revision-pinned local snapshots against the checked-in 0.2.1
158
- relation baseline; it fails on unexplained signal loss (`MISSING`/`STALE`/`UNBASELINED` stay
159
- incomplete, not green).
160
-
161
- Representative local regression run (Windows x64, Node 24.15.0):
162
-
163
- | Gate | Result | Selected evidence |
164
- |---|---:|---|
165
- | Six language fixtures | 6/6 PASS | exact symbols/edges and complete edge provenance |
166
- | Cross-repo fixture | PASS, ~432 ms cold | endpoint match, typed wrapper, external use |
167
- | Lifecycle | PASS | `full → incremental → none → reconnect/none` |
168
- | Total fixture cold build | ~1.31 s | all six language graphs |
169
- | Real-repository baseline | 6/6 PASS | TS, JS, Python, Go, Java and Rust snapshots |
170
-
171
- Real snapshots ranged from 473 nodes / 1,165 edges in 0.22 s (Go) to 8,192 nodes / 21,814 edges in
172
- 9.44 s (TypeScript). These are regression measurements on one machine, not competitor benchmarks. See
173
- [benchmark/cases.mjs](benchmark/cases.mjs) and [docs/benchmarking.md](docs/benchmarking.md).
174
-
175
- ## Security model
176
-
177
- Socket capability alerts describe the expected powers of a local code-analysis tool; they are not
178
- vulnerability findings. Where each comes from and how it is bounded:
179
-
180
- | Capability alert | Why it exists | Activation and boundary |
181
- |---|---|---|
182
- | Network access | None in the MIT core | `offline`/`pinned` expose only local tools; online integration is a separate package |
183
- | Shell access | Local `git` (staleness/impact), `rg` (search), the bundled tsserver for JS/TS semantics, Windows child-tree termination, optional `verified_change` test scripts | The semantic provider never runs repository code; test execution needs `run_tests:true` + `WEAVATRIX_ALLOW_TEST_RUNS=1` and rejects arbitrary commands |
184
- | Debug / dynamic loading | Cache-busted `import()` hot-reloads watched MCP tool modules; `createRequire` loads package metadata and parser deps | Loads files from the installed package only; no `eval` |
185
- | Environment access | Reads local `WEAVATRIX_*` settings; children inherit a credential-stripped env | Connector secrets are removed; tsserver receives only allowlisted OS/temp/locale values |
186
- | Filesystem access | Reads the active repository, graph, lockfiles and coverage; writes derived graphs and caches | Realpath containment blocks traversal and symlink escapes; `pinned` removes `open_repo` |
187
- | URL strings | Advisory findings may contain fixed OSV documentation links | The core has no outbound request implementation |
188
-
189
- `read_source` accepts repo-relative regular files only, caps a read at 2 MB, and refuses lexical or
190
- realpath escapes. Report suspected vulnerabilities privately as described in [SECURITY.md](SECURITY.md).
191
-
192
- ## Languages
193
-
194
- JavaScript · TypeScript · TSX · Python · Go · Java · C# · Rust · Solidity · HTML · CSS — parsed with
195
- [web-tree-sitter](https://github.com/tree-sitter/tree-sitter) WASM grammars; no Python install and no
196
- native compilation.
197
-
198
- SQL is indexed without a grammar: `.sql` files contribute tables, views, columns, functions, indexes
199
- and triggers as first-class graph symbols, and SQL found in string literals of any other language
200
- links the enclosing function to the table it queries. That makes schema objects visible to
201
- `change_impact`/`get_dependents` (who touches this table?) and lets the dead-code check flag columns
202
- no statement references — conservatively: verdicts require literal-SQL evidence in the repo, and
203
- `SELECT *`-consumed tables never have their columns judged by name (ORM-generated SQL stays invisible
204
- and is therefore never judged either).
205
-
206
- Test surfaces are classified per file (path conventions plus `.weavatrix.json` overrides) and, for
207
- Rust, per symbol: `#[cfg(test)]` modules and `#[test]`/`#[bench]` items inside production `.rs` files
208
- carry a node-level `test_surface` flag, so dead-code, query, hot-path and hub tools treat them as
209
- tests rather than production code.
210
-
211
- ## Development
104
+ Optional Cargo features remove capabilities from `tools/list`; disabled
105
+ features are never advertised as unavailable stubs.
106
+
107
+ ## More than a code graph
108
+
109
+ ### Languages and repository surfaces
110
+
111
+ - Rust AST extraction plus JavaScript, TypeScript, Python, Go, Java, C#, C,
112
+ C++, Bash, SQL, Solidity, Swift, HTML, CSS-family, Terraform, XML,
113
+ Markdown-family, GraphQL, Protobuf, YAML, and Kubernetes structures;
114
+ - HTTP routes, GraphQL operations, gRPC services and streaming modes;
115
+ - Kafka, RabbitMQ/AMQP, JMS, NATS, SQS, SNS, and MongoDB evidence;
116
+ - package manifests, lockfiles, JSON configuration, architecture contracts,
117
+ and measured coverage artifacts.
118
+
119
+ ### Lossless parsing
120
+
121
+ The first-party
122
+ [`weavatrix-parse`](https://github.com/sergii-ziborov/weavatrix-parse)
123
+ tokenizer preserves every input byte. Structural extraction is fast, but the
124
+ original source remains recoverable for diagnostics, exact spans, future
125
+ compiler work, and source-to-source transformations.
126
+
127
+ The parser is not a regex fallback hidden behind a Rust binary. Its release
128
+ suite checks byte-for-byte round trips, exact facts, GraphQL/Protobuf fixtures,
129
+ and import agreement against tree-sitter on real repositories.
130
+
131
+ ### Direct Git and local-only operation
132
+
133
+ Weavatrix reads Git objects through
134
+ [`weavatrix-git`](https://github.com/sergii-ziborov/weavatrix-git); it does not
135
+ spawn `git`. Search does not spawn `rg`. The MCP server does not launch Node,
136
+ Python, a language server, or code from the analyzed repository.
137
+
138
+ Production code has no network or source-write path. Derived in-memory state
139
+ can refresh after files change, but Weavatrix does not edit application source
140
+ or create commits.
141
+
142
+ ### Evidence instead of overclaiming
143
+
144
+ Every relationship records its extractor, evidence class, confidence, and
145
+ optional source span. Static reachability is never reported as measured test
146
+ coverage. Dynamic or ambiguous JavaScript and Python behavior remains bounded
147
+ evidence for the agent instead of being silently connected to a same-named
148
+ symbol.
149
+
150
+ ## Speed measured at the package boundary
151
+
152
+ The release benchmark does not compare a Rust library function with a full
153
+ JavaScript process. It packs and installs both npm packages into isolated
154
+ roots, starts fresh MCP processes with empty caches, validates package and
155
+ protocol identity, calls the same tools, and checks clean shutdown.
156
+
157
+ On 2026-07-29, `weavatrix` 1.0.0 with Rust engine 1.0.1 was compared with
158
+ `weavatrix-js` 0.3.15 using three paired fresh processes per tool and five warm
159
+ calls per process:
160
+
161
+ | Tool | Rust cold median | JavaScript cold median | Speedup |
162
+ | --- | ---: | ---: | ---: |
163
+ | `graph_stats` | 249.87 ms | 7,561.94 ms | **30.73x** |
164
+ | `list_endpoints` | 321.07 ms | 7,400.17 ms | **26.15x** |
165
+ | `find_dead_code` | 310.45 ms | 9,298.27 ms | **31.81x** |
166
+ | `run_audit` | 378.47 ms | 11,583.83 ms | **35.62x** |
167
+
168
+ The median of all 12 paired cold ratios is **30.34x**. Warm-call medians are
169
+ 3.17 ms for Rust and 494.83 ms for JavaScript, a **156.10x** speedup. Every
170
+ selected tool was faster; the gate requires at least 24x cold overall, at
171
+ least 30x warm, valid MCP responses, matching package identity, and no leaked
172
+ child process.
173
+
174
+ Raw report:
175
+ [`npm-mcp-boundary-mcport-0.3.0-vs-js-0.3.15.json`](https://github.com/sergii-ziborov/weavatrix-rust/blob/main/benchmark-results/npm-mcp-boundary-mcport-0.3.0-vs-js-0.3.15.json)
176
+ (SHA-256
177
+ `8224CACEA4F10B6B09BB525FCC1E4FFA0A7AF1292CD1C4EC63515A2CF99D7F5A`).
178
+
179
+ The full methodology, historical same-revision repository measurements,
180
+ component competitors, limitations, and reproduction commands are in the
181
+ [benchmark report](https://github.com/sergii-ziborov/weavatrix-rust/blob/main/docs/benchmarks.md).
182
+
183
+ ## Quality measured against the JavaScript engine
184
+
185
+ Both engines analyzed an immutable 502-file `weavatrix-js` 0.3.14 checkout.
186
+ Paths, symbols, and relation identities were normalized before comparison.
187
+
188
+ | Relation | Rust | JavaScript | JavaScript evidence covered |
189
+ | --- | ---: | ---: | ---: |
190
+ | imports | 2,320 | 1,126 | **100%** |
191
+ | methods | 63 | 4 | **100%** |
192
+ | re-exports | 80 | 75 | **100%** |
193
+ | calls | 3,403 | 2,323 | **100% of targets** |
194
+
195
+ For calls, 2,024 edges matched exactly. The remaining 299 reached the same
196
+ source-line target while Rust also attached the containing symbol as owner.
197
+ There were **zero missing targets and zero wrong targets**. Rust-only edges are
198
+ retained as evidence, not automatically declared correct merely because there
199
+ are more of them.
200
+
201
+ Raw parity reports:
202
+
203
+ - [`graph-parity-rust-1.0.0-vs-js-0.3.14.json`](https://github.com/sergii-ziborov/weavatrix-rust/blob/main/benchmark-results/graph-parity-rust-1.0.0-vs-js-0.3.14.json)
204
+ - [`call-audit-rust-1.0.0-vs-js-0.3.14.json`](https://github.com/sergii-ziborov/weavatrix-rust/blob/main/benchmark-results/call-audit-rust-1.0.0-vs-js-0.3.14.json)
205
+
206
+ The release also dogfoods all 39 tools against Weavatrix itself. The verified
207
+ self-run returned `PASS` with zero health findings, zero clone families, zero
208
+ dead-code candidates after correct `#[cfg(test)]` inheritance, and no
209
+ architecture cycles or dependency findings.
210
+
211
+ ## Library and standalone CLI
212
+
213
+ The MCP transport is optional. A minimal build keeps the Rust library and
214
+ standalone `analyze`, `list-tools`, and `tool` commands without `mcport`:
215
+
216
+ ```toml
217
+ [dependencies]
218
+ weavatrix-rust = { version = "1", default-features = false }
219
+ ```
212
220
 
213
221
  ```sh
214
- npm install
215
- npm test # unit/integration tests plus the quick golden benchmark
216
- npm run benchmark # full TS/JS/Python/Go/Java/Rust + MCP lifecycle gate
217
- npm run benchmark:real # locally available real repos vs source-free 0.2.1 baselines
222
+ cargo build --no-default-features
223
+ weavatrix analyze . --pretty
224
+ weavatrix list-tools
225
+ weavatrix tool graph_stats .
218
226
  ```
219
227
 
220
- Maintained JavaScript/TypeScript under `src`, `bin`, `scripts`, `test` has a hard 300-line physical
221
- ceiling enforced by the release suite; larger concerns split into owner-focused modules behind slim
222
- facades. The weavatrix.com landing site lives in its own repository (`weavatrix-site`).
228
+ Enable `mcp` only when embedding the stdio server. The default full build also
229
+ connects the first-party scan, graph, Git, search, clone, vector, semantic, and
230
+ memory crates.
231
+
232
+ ## Safety and package integrity
233
+
234
+ - read-only repository analysis;
235
+ - no install scripts or runtime downloads;
236
+ - no application-source writes or commit creation;
237
+ - no execution of analyzed repository code;
238
+ - bounded MCP results with pagination for large neighborhoods and communities;
239
+ - source-free, credential-free evidence by default;
240
+ - npm provenance and immutable GitHub release assets;
241
+ - forbidden unsafe Rust in the engine.
242
+
243
+ ## Why the JavaScript version moved
244
+
245
+ The canonical npm package moved to the native Rust engine after the Rust
246
+ implementation covered the complete shared tool contract, found all measured
247
+ JavaScript relation targets, added five native workflows, removed external
248
+ runtime executables, preserved lossless parser input, and passed the installed
249
+ package speed gate.
250
+
251
+ The maintained JavaScript line remains available as
252
+ [`weavatrix-js`](https://github.com/sergii-ziborov/weavatrix-js) for extensions
253
+ and compatibility. `weavatrix@0.3.14` is the last JavaScript release under the
254
+ canonical package name.
223
255
 
224
- ## Release history
256
+ Build lineage:
225
257
 
226
- Per-version patch notes live in [docs/releases/](docs/releases/) — start with the newest entry there.
227
- The release process and gates are in [scripts/verify-release.mjs](scripts/verify-release.mjs).
258
+ - [`weavatrix`](https://github.com/sergii-ziborov/weavatrix) — canonical npm package;
259
+ - [`weavatrix-rust`](https://github.com/sergii-ziborov/weavatrix-rust) — native engine and crates.io source;
260
+ - [`weavatrix-parse`](https://github.com/sergii-ziborov/weavatrix-parse) — lossless parser;
261
+ - [`mcport`](https://github.com/sergii-ziborov/mcport) — dependency-light MCP stdio runtime.
228
262
 
229
263
  ## License
230
264
 
231
- The Weavatrix source in this repository is [MIT licensed](LICENSE) © 2026 Sergii Ziborov.
232
- Third-party dependencies retain their own licenses. See the public
233
- [license page](https://weavatrix.com/license) for the same notice.
265
+ MIT. Third-party crates retain their own licenses.
Binary file
Binary file
Binary file
@@ -0,0 +1,73 @@
1
+ // Resolves the platform-specific Weavatrix binary bundled in the universal npm
2
+ // package. Separate platform packages remain a development/test fallback.
3
+ // Pure Node: built-ins only, no install scripts and no network access.
4
+ import { existsSync } from 'node:fs'
5
+ import { createRequire } from 'node:module'
6
+ import { dirname, join } from 'node:path'
7
+ import { fileURLToPath } from 'node:url'
8
+
9
+ const PLATFORM_PACKAGES = {
10
+ 'win32 x64': ['@weavatrix/cli-win32-x64', 'weavatrix.exe'],
11
+ 'win32 arm64': ['@weavatrix/cli-win32-arm64', 'weavatrix.exe'],
12
+ 'darwin x64': ['@weavatrix/cli-darwin-x64', 'weavatrix'],
13
+ 'darwin arm64': ['@weavatrix/cli-darwin-arm64', 'weavatrix'],
14
+ 'linux x64': ['@weavatrix/cli-linux-x64', 'weavatrix'],
15
+ 'linux arm64': ['@weavatrix/cli-linux-arm64', 'weavatrix'],
16
+ }
17
+
18
+ const BUNDLED_BINARIES = {
19
+ 'win32 x64': ['win32-x64', 'weavatrix.exe'],
20
+ 'win32 arm64': ['win32-arm64', 'weavatrix.exe'],
21
+ 'darwin x64': ['darwin-x64', 'weavatrix'],
22
+ 'darwin arm64': ['darwin-arm64', 'weavatrix'],
23
+ 'linux x64': ['linux-x64', 'weavatrix'],
24
+ 'linux arm64': ['linux-arm64', 'weavatrix'],
25
+ }
26
+
27
+ export function resolveBinary() {
28
+ const key = `${process.platform} ${process.arch}`
29
+ const entry = PLATFORM_PACKAGES[key]
30
+ if (!entry) {
31
+ fail(`Unsupported platform: ${key}.`,
32
+ 'Prebuilt binaries cover win32/darwin/linux on x64 and arm64.',
33
+ 'On other platforms install from source: cargo install weavatrix-rust')
34
+ }
35
+ const bundled = locateBundled(key)
36
+ if (bundled) return bundled
37
+ const [packageName, binaryName] = entry
38
+ const binary = locate(packageName, binaryName)
39
+ if (binary) return binary
40
+ fail(`The bundled native executable for ${key} is missing.`,
41
+ 'The installed package is incomplete; reinstall weavatrix,',
42
+ 'or: cargo install weavatrix-rust')
43
+ return null
44
+ }
45
+
46
+ function locateBundled(key) {
47
+ const [directory, binaryName] = BUNDLED_BINARIES[key]
48
+ const binary = join(dirname(fileURLToPath(import.meta.url)), 'native', directory, binaryName)
49
+ return existsSync(binary) ? binary : null
50
+ }
51
+
52
+ // Registry installs resolve from this file's own location. The extra bases
53
+ // keep symlinked installs working (npm file:/link: put the real files outside
54
+ // the consumer's node_modules, and ESM canonicalizes import.meta.url).
55
+ function locate(packageName, binaryName) {
56
+ const bases = [import.meta.url, process.argv[1], join(process.cwd(), 'package.json')]
57
+ for (const base of bases) {
58
+ if (!base) continue
59
+ try {
60
+ const packageJson = createRequire(base).resolve(`${packageName}/package.json`)
61
+ const binary = packageJson.slice(0, -'package.json'.length) + binaryName
62
+ if (existsSync(binary)) return binary
63
+ } catch (error) {
64
+ if (error?.code !== 'MODULE_NOT_FOUND') throw error
65
+ }
66
+ }
67
+ return null
68
+ }
69
+
70
+ function fail(...lines) {
71
+ for (const line of lines) console.error(`weavatrix: ${line}`)
72
+ process.exit(1)
73
+ }
@@ -0,0 +1,26 @@
1
+ import { spawn } from 'node:child_process'
2
+ import { resolveBinary } from './resolve-binary.mjs'
3
+
4
+ export function runNative(command, label) {
5
+ const binary = resolveBinary()
6
+ const args = command ? [command, ...process.argv.slice(2)] : process.argv.slice(2)
7
+ // Node 22.15+ can replace the launcher process on POSIX. This preserves
8
+ // the stdio file descriptors while removing an otherwise idle wrapper
9
+ // process from every MCP request and from its measured memory footprint.
10
+ // Older Node releases and Windows retain the compatible spawn path.
11
+ if (['darwin', 'linux'].includes(process.platform) && typeof process.execve === 'function') {
12
+ process.execve(binary, [binary, ...args], process.env)
13
+ }
14
+ const child = spawn(binary, args, { stdio: 'inherit', windowsHide: true })
15
+ child.on('error', (error) => {
16
+ console.error(`${label}: failed to start native binary: ${error.message}`)
17
+ process.exit(1)
18
+ })
19
+ child.on('exit', (code, signal) => {
20
+ if (signal) process.kill(process.pid, signal)
21
+ process.exit(code ?? 1)
22
+ })
23
+ for (const signal of ['SIGINT', 'SIGTERM']) {
24
+ process.on(signal, () => child.kill(signal))
25
+ }
26
+ }
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
- // Weavatrix MCP stdio entry — thin launcher so npm/npx get a shebang'd bin
3
- // while the server itself stays a plain module. Positional args pass through:
4
- // weavatrix-mcp <repoRoot> [caps] — graph path derived automatically
5
- // weavatrix-mcp <graph.json> <repoRoot> [caps] — explicit graph file
6
- const {startMcpServer} = await import('../src/mcp-server.mjs')
7
- await startMcpServer()
2
+ // MCP stdio entry - drop-in compatible with the JavaScript weavatrix-mcp bin:
3
+ // weavatrix-mcp <repoRoot> [--profile=all|code|seo]
4
+ // Spawns the native Rust server with stdio inherited; this wrapper adds no
5
+ // buffering, no framing, and no event-loop work between client and server.
6
+ import { runNative } from './run-native.mjs'
7
+
8
+ runNative('mcp', 'weavatrix-mcp')
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // Full Weavatrix CLI: forwards arguments verbatim to the native binary.
3
+ import { runNative } from './run-native.mjs'
4
+
5
+ runNative(null, 'weavatrix')