ruvector 0.2.28 → 0.2.30

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 (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +2270 -2270
  3. package/bin/cli.js +9598 -9479
  4. package/bin/mcp-server.js +1 -1
  5. package/dist/core/intelligence-engine.d.ts +13 -0
  6. package/dist/core/intelligence-engine.d.ts.map +1 -1
  7. package/dist/core/intelligence-engine.js +38 -0
  8. package/dist/core/onnx/bundled-parallel.mjs +164 -164
  9. package/dist/core/onnx/embed-worker.mjs +67 -67
  10. package/dist/core/onnx/loader.js +434 -434
  11. package/dist/core/onnx/package.json +3 -3
  12. package/dist/core/onnx/pkg/LICENSE +21 -21
  13. package/dist/core/onnx/pkg/loader.js +348 -348
  14. package/dist/core/onnx/pkg/package.json +3 -3
  15. package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.d.ts +112 -112
  16. package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.js +5 -5
  17. package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.js +638 -638
  18. package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts +29 -29
  19. package/dist/core/parallel-workers.js +439 -439
  20. package/dist/workers/benchmark.js +15 -15
  21. package/package.json +122 -122
  22. package/src/decompiler/api-prober.js +302 -302
  23. package/src/decompiler/index.js +463 -463
  24. package/src/decompiler/metrics.js +86 -86
  25. package/src/decompiler/model-decompiler.js +423 -423
  26. package/src/decompiler/module-splitter.js +498 -498
  27. package/src/decompiler/module-tree.js +142 -142
  28. package/src/decompiler/name-predictor.js +400 -400
  29. package/src/decompiler/npm-fetch.js +176 -176
  30. package/src/decompiler/reconstructor.js +499 -499
  31. package/src/decompiler/reference-tracker.js +285 -285
  32. package/src/decompiler/statement-parser.js +285 -285
  33. package/src/decompiler/style-improver.js +438 -438
  34. package/src/decompiler/subcategories.js +339 -339
  35. package/src/decompiler/validator.js +379 -379
  36. package/src/decompiler/witness.js +140 -140
  37. package/wasm/package.json +26 -26
  38. package/wasm/ruvector_decompiler_wasm.d.ts +27 -27
  39. package/wasm/ruvector_decompiler_wasm.js +220 -220
  40. package/wasm/ruvector_decompiler_wasm_bg.wasm.d.ts +16 -16
  41. package/dist/core/onnx/pkg/ruvector.db +0 -0
@@ -1,140 +1,140 @@
1
- /**
2
- * witness.js - SHA-256 witness chain generation and verification.
3
- *
4
- * A witness chain is a Merkle-like structure that cryptographically proves
5
- * the decompiled output derives from a specific input bundle.
6
- *
7
- * Chain structure:
8
- * root = H(source_hash || module_hashes[0] || ... || module_hashes[n])
9
- *
10
- * Each entry records:
11
- * { hash, label, parent }
12
- * so the chain can be verified without re-running the decompiler.
13
- */
14
-
15
- 'use strict';
16
-
17
- const crypto = require('crypto');
18
-
19
- /**
20
- * Compute SHA-256 hash of a string or buffer.
21
- * @param {string|Buffer} data
22
- * @returns {string} hex-encoded hash
23
- */
24
- function sha256(data) {
25
- return crypto.createHash('sha256').update(data).digest('hex');
26
- }
27
-
28
- /**
29
- * Build a witness chain from source and decompiled modules.
30
- *
31
- * @param {string} source - original bundle source code
32
- * @param {Array<{name: string, content: string}>} modules - decompiled modules
33
- * @returns {{
34
- * source_hash: string,
35
- * module_hashes: Array<{name: string, hash: string}>,
36
- * root: string,
37
- * chain: Array<{hash: string, label: string, parent: string|null}>,
38
- * created: string,
39
- * algorithm: string
40
- * }}
41
- */
42
- function buildWitnessChain(source, modules) {
43
- const sourceHash = sha256(source);
44
- const chain = [];
45
- const moduleHashes = [];
46
-
47
- // Root node: the source hash
48
- chain.push({
49
- hash: sourceHash,
50
- label: 'source',
51
- parent: null,
52
- });
53
-
54
- // One node per decompiled module
55
- for (const mod of modules) {
56
- const modHash = sha256(mod.content);
57
- moduleHashes.push({ name: mod.name, hash: modHash });
58
-
59
- chain.push({
60
- hash: modHash,
61
- label: `module:${mod.name}`,
62
- parent: sourceHash,
63
- });
64
- }
65
-
66
- // Compute Merkle root: H(source_hash || mod_hash_0 || ... || mod_hash_n)
67
- const allHashes = sourceHash + moduleHashes.map((m) => m.hash).join('');
68
- const root = sha256(allHashes);
69
-
70
- chain.push({
71
- hash: root,
72
- label: 'root',
73
- parent: sourceHash,
74
- });
75
-
76
- return {
77
- source_hash: sourceHash,
78
- module_hashes: moduleHashes,
79
- root,
80
- chain,
81
- created: new Date().toISOString(),
82
- algorithm: 'sha256',
83
- };
84
- }
85
-
86
- /**
87
- * Verify a witness chain against a source file.
88
- *
89
- * @param {object} witness - the witness object (from buildWitnessChain)
90
- * @param {string} [sourceContent] - original source to verify against (optional)
91
- * @returns {{valid: boolean, chain_length: number, root: string, errors: string[]}}
92
- */
93
- function verifyWitnessChain(witness, sourceContent) {
94
- const errors = [];
95
-
96
- if (!witness || !witness.chain || !witness.root) {
97
- return { valid: false, chain_length: 0, root: '', errors: ['Missing witness data'] };
98
- }
99
-
100
- // Verify source hash if content provided
101
- if (sourceContent) {
102
- const actualSourceHash = sha256(sourceContent);
103
- if (actualSourceHash !== witness.source_hash) {
104
- errors.push(
105
- `Source hash mismatch: expected ${witness.source_hash}, got ${actualSourceHash}`,
106
- );
107
- }
108
- }
109
-
110
- // Verify chain integrity: each node's parent must exist in the chain
111
- const hashSet = new Set(witness.chain.map((n) => n.hash));
112
- for (const node of witness.chain) {
113
- if (node.parent && !hashSet.has(node.parent)) {
114
- errors.push(`Broken chain: node ${node.label} references missing parent ${node.parent}`);
115
- }
116
- }
117
-
118
- // Recompute root from module hashes
119
- if (witness.module_hashes && witness.source_hash) {
120
- const allHashes =
121
- witness.source_hash + witness.module_hashes.map((m) => m.hash).join('');
122
- const expectedRoot = sha256(allHashes);
123
- if (expectedRoot !== witness.root) {
124
- errors.push(`Root mismatch: expected ${expectedRoot}, got ${witness.root}`);
125
- }
126
- }
127
-
128
- return {
129
- valid: errors.length === 0,
130
- chain_length: witness.chain.length,
131
- root: witness.root,
132
- errors,
133
- };
134
- }
135
-
136
- module.exports = {
137
- sha256,
138
- buildWitnessChain,
139
- verifyWitnessChain,
140
- };
1
+ /**
2
+ * witness.js - SHA-256 witness chain generation and verification.
3
+ *
4
+ * A witness chain is a Merkle-like structure that cryptographically proves
5
+ * the decompiled output derives from a specific input bundle.
6
+ *
7
+ * Chain structure:
8
+ * root = H(source_hash || module_hashes[0] || ... || module_hashes[n])
9
+ *
10
+ * Each entry records:
11
+ * { hash, label, parent }
12
+ * so the chain can be verified without re-running the decompiler.
13
+ */
14
+
15
+ 'use strict';
16
+
17
+ const crypto = require('crypto');
18
+
19
+ /**
20
+ * Compute SHA-256 hash of a string or buffer.
21
+ * @param {string|Buffer} data
22
+ * @returns {string} hex-encoded hash
23
+ */
24
+ function sha256(data) {
25
+ return crypto.createHash('sha256').update(data).digest('hex');
26
+ }
27
+
28
+ /**
29
+ * Build a witness chain from source and decompiled modules.
30
+ *
31
+ * @param {string} source - original bundle source code
32
+ * @param {Array<{name: string, content: string}>} modules - decompiled modules
33
+ * @returns {{
34
+ * source_hash: string,
35
+ * module_hashes: Array<{name: string, hash: string}>,
36
+ * root: string,
37
+ * chain: Array<{hash: string, label: string, parent: string|null}>,
38
+ * created: string,
39
+ * algorithm: string
40
+ * }}
41
+ */
42
+ function buildWitnessChain(source, modules) {
43
+ const sourceHash = sha256(source);
44
+ const chain = [];
45
+ const moduleHashes = [];
46
+
47
+ // Root node: the source hash
48
+ chain.push({
49
+ hash: sourceHash,
50
+ label: 'source',
51
+ parent: null,
52
+ });
53
+
54
+ // One node per decompiled module
55
+ for (const mod of modules) {
56
+ const modHash = sha256(mod.content);
57
+ moduleHashes.push({ name: mod.name, hash: modHash });
58
+
59
+ chain.push({
60
+ hash: modHash,
61
+ label: `module:${mod.name}`,
62
+ parent: sourceHash,
63
+ });
64
+ }
65
+
66
+ // Compute Merkle root: H(source_hash || mod_hash_0 || ... || mod_hash_n)
67
+ const allHashes = sourceHash + moduleHashes.map((m) => m.hash).join('');
68
+ const root = sha256(allHashes);
69
+
70
+ chain.push({
71
+ hash: root,
72
+ label: 'root',
73
+ parent: sourceHash,
74
+ });
75
+
76
+ return {
77
+ source_hash: sourceHash,
78
+ module_hashes: moduleHashes,
79
+ root,
80
+ chain,
81
+ created: new Date().toISOString(),
82
+ algorithm: 'sha256',
83
+ };
84
+ }
85
+
86
+ /**
87
+ * Verify a witness chain against a source file.
88
+ *
89
+ * @param {object} witness - the witness object (from buildWitnessChain)
90
+ * @param {string} [sourceContent] - original source to verify against (optional)
91
+ * @returns {{valid: boolean, chain_length: number, root: string, errors: string[]}}
92
+ */
93
+ function verifyWitnessChain(witness, sourceContent) {
94
+ const errors = [];
95
+
96
+ if (!witness || !witness.chain || !witness.root) {
97
+ return { valid: false, chain_length: 0, root: '', errors: ['Missing witness data'] };
98
+ }
99
+
100
+ // Verify source hash if content provided
101
+ if (sourceContent) {
102
+ const actualSourceHash = sha256(sourceContent);
103
+ if (actualSourceHash !== witness.source_hash) {
104
+ errors.push(
105
+ `Source hash mismatch: expected ${witness.source_hash}, got ${actualSourceHash}`,
106
+ );
107
+ }
108
+ }
109
+
110
+ // Verify chain integrity: each node's parent must exist in the chain
111
+ const hashSet = new Set(witness.chain.map((n) => n.hash));
112
+ for (const node of witness.chain) {
113
+ if (node.parent && !hashSet.has(node.parent)) {
114
+ errors.push(`Broken chain: node ${node.label} references missing parent ${node.parent}`);
115
+ }
116
+ }
117
+
118
+ // Recompute root from module hashes
119
+ if (witness.module_hashes && witness.source_hash) {
120
+ const allHashes =
121
+ witness.source_hash + witness.module_hashes.map((m) => m.hash).join('');
122
+ const expectedRoot = sha256(allHashes);
123
+ if (expectedRoot !== witness.root) {
124
+ errors.push(`Root mismatch: expected ${expectedRoot}, got ${witness.root}`);
125
+ }
126
+ }
127
+
128
+ return {
129
+ valid: errors.length === 0,
130
+ chain_length: witness.chain.length,
131
+ root: witness.root,
132
+ errors,
133
+ };
134
+ }
135
+
136
+ module.exports = {
137
+ sha256,
138
+ buildWitnessChain,
139
+ verifyWitnessChain,
140
+ };
package/wasm/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "ruvector-decompiler-wasm",
3
- "collaborators": [
4
- "Ruvector Team"
5
- ],
6
- "description": "WASM bindings for the RuVector JavaScript bundle decompiler (Louvain pipeline)",
7
- "version": "2.1.0",
8
- "license": "MIT",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/ruvnet/ruvector"
12
- },
13
- "files": [
14
- "ruvector_decompiler_wasm_bg.wasm",
15
- "ruvector_decompiler_wasm.js",
16
- "ruvector_decompiler_wasm.d.ts"
17
- ],
18
- "main": "ruvector_decompiler_wasm.js",
19
- "types": "ruvector_decompiler_wasm.d.ts",
20
- "keywords": [
21
- "decompiler",
22
- "javascript",
23
- "wasm",
24
- "mincut",
25
- "louvain"
26
- ]
1
+ {
2
+ "name": "ruvector-decompiler-wasm",
3
+ "collaborators": [
4
+ "Ruvector Team"
5
+ ],
6
+ "description": "WASM bindings for the RuVector JavaScript bundle decompiler (Louvain pipeline)",
7
+ "version": "2.1.0",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/ruvnet/ruvector"
12
+ },
13
+ "files": [
14
+ "ruvector_decompiler_wasm_bg.wasm",
15
+ "ruvector_decompiler_wasm.js",
16
+ "ruvector_decompiler_wasm.d.ts"
17
+ ],
18
+ "main": "ruvector_decompiler_wasm.js",
19
+ "types": "ruvector_decompiler_wasm.d.ts",
20
+ "keywords": [
21
+ "decompiler",
22
+ "javascript",
23
+ "wasm",
24
+ "mincut",
25
+ "louvain"
26
+ ]
27
27
  }
@@ -1,27 +1,27 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /**
5
- * Decompile a minified JavaScript bundle using the full Louvain pipeline.
6
- *
7
- * # Arguments
8
- *
9
- * * `source` - The minified JavaScript source code.
10
- * * `config_json` - JSON string of `DecompileConfig` fields. Pass `"{}"` for defaults.
11
- *
12
- * # Returns
13
- *
14
- * A JSON string containing the `DecompileResult` (modules, witness, inferred names, etc.)
15
- * or a JSON object with an `"error"` field on failure.
16
- */
17
- export function decompile(source: string, config_json: string): string;
18
-
19
- /**
20
- * Initialize the WASM module (sets up panic hook for better error messages).
21
- */
22
- export function init(): void;
23
-
24
- /**
25
- * Return the version of the decompiler WASM module.
26
- */
27
- export function version(): string;
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Decompile a minified JavaScript bundle using the full Louvain pipeline.
6
+ *
7
+ * # Arguments
8
+ *
9
+ * * `source` - The minified JavaScript source code.
10
+ * * `config_json` - JSON string of `DecompileConfig` fields. Pass `"{}"` for defaults.
11
+ *
12
+ * # Returns
13
+ *
14
+ * A JSON string containing the `DecompileResult` (modules, witness, inferred names, etc.)
15
+ * or a JSON object with an `"error"` field on failure.
16
+ */
17
+ export function decompile(source: string, config_json: string): string;
18
+
19
+ /**
20
+ * Initialize the WASM module (sets up panic hook for better error messages).
21
+ */
22
+ export function init(): void;
23
+
24
+ /**
25
+ * Return the version of the decompiler WASM module.
26
+ */
27
+ export function version(): string;