ruvector 0.2.28 → 0.2.29

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 +9570 -9479
  4. package/bin/mcp-server.js +3854 -3854
  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,176 +1,176 @@
1
- /**
2
- * npm-fetch.js - Fetch package info and files from the npm registry.
3
- *
4
- * Uses the built-in Node 18+ fetch API. Retrieves package metadata from
5
- * registry.npmjs.org and file contents from unpkg.com / jsdelivr.
6
- */
7
-
8
- 'use strict';
9
-
10
- const REGISTRY_BASE = 'https://registry.npmjs.org';
11
- const JSDELIVR_BASE = 'https://data.jsdelivr.com/v1/package/npm';
12
- const UNPKG_BASE = 'https://unpkg.com';
13
-
14
- /**
15
- * Fetch package metadata from the npm registry.
16
- * @param {string} packageName - npm package name (e.g. 'express', '@anthropic-ai/claude-code')
17
- * @returns {Promise<{name: string, description: string, versions: string[], latest: string, distTags: object, packageJson: object}>}
18
- */
19
- async function fetchPackageInfo(packageName) {
20
- const url = `${REGISTRY_BASE}/${encodeURIComponent(packageName).replace('%40', '@')}`;
21
- const resp = await fetch(url, {
22
- headers: { Accept: 'application/json' },
23
- });
24
-
25
- if (!resp.ok) {
26
- throw new Error(`Package "${packageName}" not found (HTTP ${resp.status})`);
27
- }
28
-
29
- const data = await resp.json();
30
- const versions = Object.keys(data.versions || {}).reverse();
31
- const distTags = data['dist-tags'] || {};
32
- const latest = distTags.latest || versions[0] || '';
33
-
34
- return {
35
- name: data.name,
36
- description: data.description || '',
37
- versions,
38
- latest,
39
- distTags,
40
- packageJson: data.versions?.[latest] || {},
41
- };
42
- }
43
-
44
- /**
45
- * Fetch the file list for a specific package version via jsDelivr.
46
- * @param {string} packageName
47
- * @param {string} version
48
- * @returns {Promise<Array<{name: string, hash: string, size: number}>>}
49
- */
50
- async function fetchPackageFileList(packageName, version) {
51
- const encodedName = encodeURIComponent(packageName).replace('%40', '@');
52
- const url = `${JSDELIVR_BASE}/${encodedName}@${version}/flat`;
53
- const resp = await fetch(url);
54
- if (!resp.ok) {
55
- throw new Error(`Could not list files for ${packageName}@${version}`);
56
- }
57
- const data = await resp.json();
58
- return (data.files || []);
59
- }
60
-
61
- /**
62
- * Fetch the content of a single file from unpkg.
63
- * @param {string} packageName
64
- * @param {string} version
65
- * @param {string} filePath - e.g. '/dist/index.js'
66
- * @returns {Promise<string>}
67
- */
68
- async function fetchFileContent(packageName, version, filePath) {
69
- const cleanPath = filePath.startsWith('/') ? filePath.slice(1) : filePath;
70
- const url = `${UNPKG_BASE}/${packageName}@${version}/${cleanPath}`;
71
- const resp = await fetch(url, { redirect: 'follow' });
72
- if (!resp.ok) {
73
- throw new Error(`Could not fetch ${cleanPath} from ${packageName}@${version} (HTTP ${resp.status})`);
74
- }
75
- return resp.text();
76
- }
77
-
78
- /**
79
- * Find the main JS bundle file from a file list.
80
- * Checks common locations and falls back to the largest .js file.
81
- * @param {Array<{name: string, size: number}>} files
82
- * @param {object} [packageJson] - optional package.json to check main/module/browser fields
83
- * @returns {string|null}
84
- */
85
- function findMainBundle(files, packageJson) {
86
- // Check package.json fields first
87
- if (packageJson) {
88
- const fields = ['browser', 'module', 'main'];
89
- for (const field of fields) {
90
- if (typeof packageJson[field] === 'string') {
91
- const normalized = packageJson[field].startsWith('/')
92
- ? packageJson[field]
93
- : '/' + packageJson[field];
94
- if (files.some((f) => f.name === normalized)) {
95
- return normalized;
96
- }
97
- }
98
- }
99
- }
100
-
101
- // Well-known candidate paths
102
- const candidates = [
103
- '/dist/cli.js',
104
- '/dist/index.js',
105
- '/dist/main.js',
106
- '/dist/bundle.js',
107
- '/lib/index.js',
108
- '/lib/cli.js',
109
- '/index.js',
110
- '/cli.js',
111
- ];
112
-
113
- for (const candidate of candidates) {
114
- if (files.some((f) => f.name === candidate)) {
115
- return candidate;
116
- }
117
- }
118
-
119
- // Fallback: largest JS file (prefer non-minified)
120
- const jsFiles = files
121
- .filter((f) => f.name.endsWith('.js') && !f.name.endsWith('.min.js'))
122
- .sort((a, b) => b.size - a.size);
123
-
124
- return jsFiles.length > 0 ? jsFiles[0].name : null;
125
- }
126
-
127
- /**
128
- * Parse a target string into its components.
129
- * Handles: 'express', 'express@4.18.2', '@scope/pkg@1.0.0',
130
- * './local.js', 'https://...'.
131
- * @param {string} target
132
- * @returns {{type: 'npm'|'file'|'url', name?: string, version?: string, path?: string, url?: string}}
133
- */
134
- function parseTarget(target) {
135
- if (target.startsWith('http://') || target.startsWith('https://')) {
136
- return { type: 'url', url: target };
137
- }
138
-
139
- if (target.startsWith('.') || target.startsWith('/')) {
140
- return { type: 'file', path: target };
141
- }
142
-
143
- // npm package: @scope/name@version or name@version
144
- let name = target;
145
- let version = undefined;
146
- if (target.startsWith('@')) {
147
- // scoped: @scope/name@version
148
- const afterScope = target.indexOf('/', 1);
149
- if (afterScope > 0) {
150
- const atIdx = target.indexOf('@', afterScope + 1);
151
- if (atIdx > 0) {
152
- name = target.slice(0, atIdx);
153
- version = target.slice(atIdx + 1);
154
- }
155
- }
156
- } else {
157
- const atIdx = target.indexOf('@');
158
- if (atIdx > 0) {
159
- name = target.slice(0, atIdx);
160
- version = target.slice(atIdx + 1);
161
- }
162
- }
163
-
164
- return { type: 'npm', name, version };
165
- }
166
-
167
- module.exports = {
168
- fetchPackageInfo,
169
- fetchPackageFileList,
170
- fetchFileContent,
171
- findMainBundle,
172
- parseTarget,
173
- REGISTRY_BASE,
174
- UNPKG_BASE,
175
- JSDELIVR_BASE,
176
- };
1
+ /**
2
+ * npm-fetch.js - Fetch package info and files from the npm registry.
3
+ *
4
+ * Uses the built-in Node 18+ fetch API. Retrieves package metadata from
5
+ * registry.npmjs.org and file contents from unpkg.com / jsdelivr.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ const REGISTRY_BASE = 'https://registry.npmjs.org';
11
+ const JSDELIVR_BASE = 'https://data.jsdelivr.com/v1/package/npm';
12
+ const UNPKG_BASE = 'https://unpkg.com';
13
+
14
+ /**
15
+ * Fetch package metadata from the npm registry.
16
+ * @param {string} packageName - npm package name (e.g. 'express', '@anthropic-ai/claude-code')
17
+ * @returns {Promise<{name: string, description: string, versions: string[], latest: string, distTags: object, packageJson: object}>}
18
+ */
19
+ async function fetchPackageInfo(packageName) {
20
+ const url = `${REGISTRY_BASE}/${encodeURIComponent(packageName).replace('%40', '@')}`;
21
+ const resp = await fetch(url, {
22
+ headers: { Accept: 'application/json' },
23
+ });
24
+
25
+ if (!resp.ok) {
26
+ throw new Error(`Package "${packageName}" not found (HTTP ${resp.status})`);
27
+ }
28
+
29
+ const data = await resp.json();
30
+ const versions = Object.keys(data.versions || {}).reverse();
31
+ const distTags = data['dist-tags'] || {};
32
+ const latest = distTags.latest || versions[0] || '';
33
+
34
+ return {
35
+ name: data.name,
36
+ description: data.description || '',
37
+ versions,
38
+ latest,
39
+ distTags,
40
+ packageJson: data.versions?.[latest] || {},
41
+ };
42
+ }
43
+
44
+ /**
45
+ * Fetch the file list for a specific package version via jsDelivr.
46
+ * @param {string} packageName
47
+ * @param {string} version
48
+ * @returns {Promise<Array<{name: string, hash: string, size: number}>>}
49
+ */
50
+ async function fetchPackageFileList(packageName, version) {
51
+ const encodedName = encodeURIComponent(packageName).replace('%40', '@');
52
+ const url = `${JSDELIVR_BASE}/${encodedName}@${version}/flat`;
53
+ const resp = await fetch(url);
54
+ if (!resp.ok) {
55
+ throw new Error(`Could not list files for ${packageName}@${version}`);
56
+ }
57
+ const data = await resp.json();
58
+ return (data.files || []);
59
+ }
60
+
61
+ /**
62
+ * Fetch the content of a single file from unpkg.
63
+ * @param {string} packageName
64
+ * @param {string} version
65
+ * @param {string} filePath - e.g. '/dist/index.js'
66
+ * @returns {Promise<string>}
67
+ */
68
+ async function fetchFileContent(packageName, version, filePath) {
69
+ const cleanPath = filePath.startsWith('/') ? filePath.slice(1) : filePath;
70
+ const url = `${UNPKG_BASE}/${packageName}@${version}/${cleanPath}`;
71
+ const resp = await fetch(url, { redirect: 'follow' });
72
+ if (!resp.ok) {
73
+ throw new Error(`Could not fetch ${cleanPath} from ${packageName}@${version} (HTTP ${resp.status})`);
74
+ }
75
+ return resp.text();
76
+ }
77
+
78
+ /**
79
+ * Find the main JS bundle file from a file list.
80
+ * Checks common locations and falls back to the largest .js file.
81
+ * @param {Array<{name: string, size: number}>} files
82
+ * @param {object} [packageJson] - optional package.json to check main/module/browser fields
83
+ * @returns {string|null}
84
+ */
85
+ function findMainBundle(files, packageJson) {
86
+ // Check package.json fields first
87
+ if (packageJson) {
88
+ const fields = ['browser', 'module', 'main'];
89
+ for (const field of fields) {
90
+ if (typeof packageJson[field] === 'string') {
91
+ const normalized = packageJson[field].startsWith('/')
92
+ ? packageJson[field]
93
+ : '/' + packageJson[field];
94
+ if (files.some((f) => f.name === normalized)) {
95
+ return normalized;
96
+ }
97
+ }
98
+ }
99
+ }
100
+
101
+ // Well-known candidate paths
102
+ const candidates = [
103
+ '/dist/cli.js',
104
+ '/dist/index.js',
105
+ '/dist/main.js',
106
+ '/dist/bundle.js',
107
+ '/lib/index.js',
108
+ '/lib/cli.js',
109
+ '/index.js',
110
+ '/cli.js',
111
+ ];
112
+
113
+ for (const candidate of candidates) {
114
+ if (files.some((f) => f.name === candidate)) {
115
+ return candidate;
116
+ }
117
+ }
118
+
119
+ // Fallback: largest JS file (prefer non-minified)
120
+ const jsFiles = files
121
+ .filter((f) => f.name.endsWith('.js') && !f.name.endsWith('.min.js'))
122
+ .sort((a, b) => b.size - a.size);
123
+
124
+ return jsFiles.length > 0 ? jsFiles[0].name : null;
125
+ }
126
+
127
+ /**
128
+ * Parse a target string into its components.
129
+ * Handles: 'express', 'express@4.18.2', '@scope/pkg@1.0.0',
130
+ * './local.js', 'https://...'.
131
+ * @param {string} target
132
+ * @returns {{type: 'npm'|'file'|'url', name?: string, version?: string, path?: string, url?: string}}
133
+ */
134
+ function parseTarget(target) {
135
+ if (target.startsWith('http://') || target.startsWith('https://')) {
136
+ return { type: 'url', url: target };
137
+ }
138
+
139
+ if (target.startsWith('.') || target.startsWith('/')) {
140
+ return { type: 'file', path: target };
141
+ }
142
+
143
+ // npm package: @scope/name@version or name@version
144
+ let name = target;
145
+ let version = undefined;
146
+ if (target.startsWith('@')) {
147
+ // scoped: @scope/name@version
148
+ const afterScope = target.indexOf('/', 1);
149
+ if (afterScope > 0) {
150
+ const atIdx = target.indexOf('@', afterScope + 1);
151
+ if (atIdx > 0) {
152
+ name = target.slice(0, atIdx);
153
+ version = target.slice(atIdx + 1);
154
+ }
155
+ }
156
+ } else {
157
+ const atIdx = target.indexOf('@');
158
+ if (atIdx > 0) {
159
+ name = target.slice(0, atIdx);
160
+ version = target.slice(atIdx + 1);
161
+ }
162
+ }
163
+
164
+ return { type: 'npm', name, version };
165
+ }
166
+
167
+ module.exports = {
168
+ fetchPackageInfo,
169
+ fetchPackageFileList,
170
+ fetchFileContent,
171
+ findMainBundle,
172
+ parseTarget,
173
+ REGISTRY_BASE,
174
+ UNPKG_BASE,
175
+ JSDELIVR_BASE,
176
+ };