ruvector 0.2.22 → 0.2.23

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 (108) hide show
  1. package/README.md +2 -2
  2. package/package.json +9 -5
  3. package/dist/analysis/complexity.d.ts +0 -52
  4. package/dist/analysis/complexity.d.ts.map +0 -1
  5. package/dist/analysis/complexity.js +0 -146
  6. package/dist/analysis/index.d.ts +0 -15
  7. package/dist/analysis/index.d.ts.map +0 -1
  8. package/dist/analysis/index.js +0 -38
  9. package/dist/analysis/patterns.d.ts +0 -71
  10. package/dist/analysis/patterns.d.ts.map +0 -1
  11. package/dist/analysis/patterns.js +0 -243
  12. package/dist/analysis/security.d.ts +0 -51
  13. package/dist/analysis/security.d.ts.map +0 -1
  14. package/dist/analysis/security.js +0 -139
  15. package/dist/core/adaptive-embedder.d.ts +0 -156
  16. package/dist/core/adaptive-embedder.d.ts.map +0 -1
  17. package/dist/core/adaptive-embedder.js +0 -838
  18. package/dist/core/agentdb-fast.d.ts +0 -149
  19. package/dist/core/agentdb-fast.d.ts.map +0 -1
  20. package/dist/core/agentdb-fast.js +0 -301
  21. package/dist/core/ast-parser.d.ts +0 -108
  22. package/dist/core/ast-parser.d.ts.map +0 -1
  23. package/dist/core/ast-parser.js +0 -602
  24. package/dist/core/attention-fallbacks.d.ts +0 -321
  25. package/dist/core/attention-fallbacks.d.ts.map +0 -1
  26. package/dist/core/attention-fallbacks.js +0 -552
  27. package/dist/core/cluster-wrapper.d.ts +0 -148
  28. package/dist/core/cluster-wrapper.d.ts.map +0 -1
  29. package/dist/core/cluster-wrapper.js +0 -271
  30. package/dist/core/coverage-router.d.ts +0 -88
  31. package/dist/core/coverage-router.d.ts.map +0 -1
  32. package/dist/core/coverage-router.js +0 -315
  33. package/dist/core/diff-embeddings.d.ts +0 -93
  34. package/dist/core/diff-embeddings.d.ts.map +0 -1
  35. package/dist/core/diff-embeddings.js +0 -334
  36. package/dist/core/gnn-wrapper.d.ts +0 -143
  37. package/dist/core/gnn-wrapper.d.ts.map +0 -1
  38. package/dist/core/gnn-wrapper.js +0 -213
  39. package/dist/core/graph-algorithms.d.ts +0 -83
  40. package/dist/core/graph-algorithms.d.ts.map +0 -1
  41. package/dist/core/graph-algorithms.js +0 -514
  42. package/dist/core/graph-wrapper.d.ts +0 -147
  43. package/dist/core/graph-wrapper.d.ts.map +0 -1
  44. package/dist/core/graph-wrapper.js +0 -299
  45. package/dist/core/index.d.ts +0 -48
  46. package/dist/core/index.d.ts.map +0 -1
  47. package/dist/core/index.js +0 -89
  48. package/dist/core/intelligence-engine.d.ts +0 -258
  49. package/dist/core/intelligence-engine.d.ts.map +0 -1
  50. package/dist/core/intelligence-engine.js +0 -1030
  51. package/dist/core/learning-engine.d.ts +0 -160
  52. package/dist/core/learning-engine.d.ts.map +0 -1
  53. package/dist/core/learning-engine.js +0 -589
  54. package/dist/core/neural-embeddings.d.ts +0 -393
  55. package/dist/core/neural-embeddings.d.ts.map +0 -1
  56. package/dist/core/neural-embeddings.js +0 -1091
  57. package/dist/core/neural-perf.d.ts +0 -331
  58. package/dist/core/neural-perf.d.ts.map +0 -1
  59. package/dist/core/neural-perf.js +0 -704
  60. package/dist/core/onnx/pkg/package.json +0 -3
  61. package/dist/core/onnx-embedder.d.ts +0 -105
  62. package/dist/core/onnx-embedder.d.ts.map +0 -1
  63. package/dist/core/onnx-embedder.js +0 -410
  64. package/dist/core/onnx-optimized.d.ts +0 -109
  65. package/dist/core/onnx-optimized.d.ts.map +0 -1
  66. package/dist/core/onnx-optimized.js +0 -419
  67. package/dist/core/parallel-intelligence.d.ts +0 -109
  68. package/dist/core/parallel-intelligence.d.ts.map +0 -1
  69. package/dist/core/parallel-intelligence.js +0 -340
  70. package/dist/core/parallel-workers.d.ts +0 -177
  71. package/dist/core/parallel-workers.d.ts.map +0 -1
  72. package/dist/core/parallel-workers.js +0 -671
  73. package/dist/core/router-wrapper.d.ts +0 -75
  74. package/dist/core/router-wrapper.d.ts.map +0 -1
  75. package/dist/core/router-wrapper.js +0 -243
  76. package/dist/core/rvf-wrapper.d.ts +0 -86
  77. package/dist/core/rvf-wrapper.d.ts.map +0 -1
  78. package/dist/core/rvf-wrapper.js +0 -102
  79. package/dist/core/sona-wrapper.d.ts +0 -226
  80. package/dist/core/sona-wrapper.d.ts.map +0 -1
  81. package/dist/core/sona-wrapper.js +0 -282
  82. package/dist/core/tensor-compress.d.ts +0 -134
  83. package/dist/core/tensor-compress.d.ts.map +0 -1
  84. package/dist/core/tensor-compress.js +0 -432
  85. package/dist/index.d.ts +0 -105
  86. package/dist/index.d.ts.map +0 -1
  87. package/dist/index.js +0 -221
  88. package/dist/services/embedding-service.d.ts +0 -136
  89. package/dist/services/embedding-service.d.ts.map +0 -1
  90. package/dist/services/embedding-service.js +0 -294
  91. package/dist/services/index.d.ts +0 -6
  92. package/dist/services/index.d.ts.map +0 -1
  93. package/dist/services/index.js +0 -26
  94. package/dist/types.d.ts +0 -145
  95. package/dist/types.d.ts.map +0 -1
  96. package/dist/types.js +0 -2
  97. package/dist/workers/benchmark.d.ts +0 -44
  98. package/dist/workers/benchmark.d.ts.map +0 -1
  99. package/dist/workers/benchmark.js +0 -230
  100. package/dist/workers/index.d.ts +0 -10
  101. package/dist/workers/index.d.ts.map +0 -1
  102. package/dist/workers/index.js +0 -25
  103. package/dist/workers/native-worker.d.ts +0 -76
  104. package/dist/workers/native-worker.d.ts.map +0 -1
  105. package/dist/workers/native-worker.js +0 -490
  106. package/dist/workers/types.d.ts +0 -69
  107. package/dist/workers/types.d.ts.map +0 -1
  108. package/dist/workers/types.js +0 -7
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  **The fastest vector database for Node.js—built in Rust, runs everywhere**
12
12
 
13
- Ruvector is a self-learning vector database with **enterprise-grade semantic search**, hybrid retrieval (sparse + dense), Graph RAG, FlashAttention-3, and billion-scale DiskANN — all in a single npm package. Unlike cloud-only solutions or Python-first databases, Ruvector is designed for JavaScript/TypeScript developers who need **blazing-fast vector search** without external services.
13
+ Ruvector is a self-learning vector database with **enterprise-grade semantic search**, hybrid retrieval (sparse + dense), Graph RAG, FlashAttention-3, and DiskANN — all in a single npm package. Unlike cloud-only solutions or Python-first databases, Ruvector is designed for JavaScript/TypeScript developers who need **blazing-fast vector search** without external services.
14
14
 
15
15
  > 🚀 **Sub-millisecond queries** • 🎯 **52,000+ inserts/sec** • 💾 **~50 bytes per vector** • 🌍 **Runs anywhere** • 🧠 **859 tests passing**
16
16
 
@@ -40,7 +40,7 @@ npx ruvector hooks init --pretrain --build-agents quality
40
40
  - **FlashAttention-3** — IO-aware tiled attention, O(N) memory instead of O(N^2)
41
41
  - **Graph RAG** — Knowledge graph + community detection for multi-hop queries (30-60% improvement)
42
42
  - **Hybrid Search** — Sparse + dense vectors with RRF fusion (20-49% better retrieval)
43
- - **DiskANN / Vamana** — Billion-scale SSD-backed ANN with <10ms latency
43
+ - **DiskANN / Vamana** — SSD-friendly ANN graph with PQ compression for large-scale search
44
44
  - **ColBERT Multi-Vector** — Per-token late interaction retrieval (MaxSim)
45
45
  - **Matryoshka Embeddings** — Adaptive-dimension search with funnel/cascade modes
46
46
  - **MLA** — Multi-Head Latent Attention with ~93% KV-cache compression (DeepSeek-V2/V3)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ruvector",
3
- "version": "0.2.22",
4
- "description": "Self-learning vector database for Node.js hybrid search, Graph RAG, FlashAttention-3, DiskANN, 50+ attention mechanisms",
3
+ "version": "0.2.23",
4
+ "description": "Self-learning vector database for Node.js \u2014 hybrid search, Graph RAG, FlashAttention-3, HNSW, 50+ attention mechanisms",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "bin": {
@@ -47,7 +47,7 @@
47
47
  "mcp",
48
48
  "edge-computing",
49
49
  "graph-rag",
50
- "diskann",
50
+ "hnsw",
51
51
  "hybrid-search",
52
52
  "colbert",
53
53
  "turboquant",
@@ -97,7 +97,8 @@
97
97
  "peerDependencies": {
98
98
  "@ruvector/pi-brain": ">=0.1.0",
99
99
  "@ruvector/router": ">=0.1.0",
100
- "@ruvector/ruvllm": ">=2.0.0"
100
+ "@ruvector/ruvllm": ">=2.0.0",
101
+ "@ruvector/diskann": ">=0.1.0"
101
102
  },
102
103
  "peerDependenciesMeta": {
103
104
  "@ruvector/pi-brain": {
@@ -108,9 +109,12 @@
108
109
  },
109
110
  "@ruvector/router": {
110
111
  "optional": true
112
+ },
113
+ "@ruvector/diskann": {
114
+ "optional": true
111
115
  }
112
116
  },
113
117
  "engines": {
114
118
  "node": ">=18.0.0"
115
119
  }
116
- }
120
+ }
@@ -1,52 +0,0 @@
1
- /**
2
- * Complexity Analysis Module - Consolidated code complexity metrics
3
- *
4
- * Single source of truth for cyclomatic complexity and code metrics.
5
- * Used by native-worker.ts and parallel-workers.ts
6
- */
7
- export interface ComplexityResult {
8
- file: string;
9
- lines: number;
10
- nonEmptyLines: number;
11
- cyclomaticComplexity: number;
12
- functions: number;
13
- avgFunctionSize: number;
14
- maxFunctionComplexity?: number;
15
- }
16
- export interface ComplexityThresholds {
17
- complexity: number;
18
- functions: number;
19
- lines: number;
20
- avgSize: number;
21
- }
22
- export declare const DEFAULT_THRESHOLDS: ComplexityThresholds;
23
- /**
24
- * Analyze complexity of a single file
25
- */
26
- export declare function analyzeFile(filePath: string, content?: string): ComplexityResult;
27
- /**
28
- * Analyze complexity of multiple files
29
- */
30
- export declare function analyzeFiles(files: string[], maxFiles?: number): ComplexityResult[];
31
- /**
32
- * Check if complexity exceeds thresholds
33
- */
34
- export declare function exceedsThresholds(result: ComplexityResult, thresholds?: ComplexityThresholds): boolean;
35
- /**
36
- * Get complexity rating
37
- */
38
- export declare function getComplexityRating(complexity: number): 'low' | 'medium' | 'high' | 'critical';
39
- /**
40
- * Filter files exceeding thresholds
41
- */
42
- export declare function filterComplex(results: ComplexityResult[], thresholds?: ComplexityThresholds): ComplexityResult[];
43
- declare const _default: {
44
- DEFAULT_THRESHOLDS: ComplexityThresholds;
45
- analyzeFile: typeof analyzeFile;
46
- analyzeFiles: typeof analyzeFiles;
47
- exceedsThresholds: typeof exceedsThresholds;
48
- getComplexityRating: typeof getComplexityRating;
49
- filterComplex: typeof filterComplex;
50
- };
51
- export default _default;
52
- //# sourceMappingURL=complexity.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"complexity.d.ts","sourceRoot":"","sources":["../../src/analysis/complexity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,oBAKhC,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAsDhF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY,GAAG,gBAAgB,EAAE,CAExF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,EACxB,UAAU,GAAE,oBAAyC,GACpD,OAAO,CAOT;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAK9F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,gBAAgB,EAAE,EAC3B,UAAU,GAAE,oBAAyC,GACpD,gBAAgB,EAAE,CAEpB;;;;;;;;;AAED,wBAOE"}
@@ -1,146 +0,0 @@
1
- "use strict";
2
- /**
3
- * Complexity Analysis Module - Consolidated code complexity metrics
4
- *
5
- * Single source of truth for cyclomatic complexity and code metrics.
6
- * Used by native-worker.ts and parallel-workers.ts
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.DEFAULT_THRESHOLDS = void 0;
43
- exports.analyzeFile = analyzeFile;
44
- exports.analyzeFiles = analyzeFiles;
45
- exports.exceedsThresholds = exceedsThresholds;
46
- exports.getComplexityRating = getComplexityRating;
47
- exports.filterComplex = filterComplex;
48
- const fs = __importStar(require("fs"));
49
- exports.DEFAULT_THRESHOLDS = {
50
- complexity: 10,
51
- functions: 30,
52
- lines: 500,
53
- avgSize: 50,
54
- };
55
- /**
56
- * Analyze complexity of a single file
57
- */
58
- function analyzeFile(filePath, content) {
59
- try {
60
- const fileContent = content ?? (fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf-8') : '');
61
- if (!fileContent) {
62
- return { file: filePath, lines: 0, nonEmptyLines: 0, cyclomaticComplexity: 1, functions: 0, avgFunctionSize: 0 };
63
- }
64
- const lines = fileContent.split('\n');
65
- const nonEmptyLines = lines.filter(l => l.trim().length > 0).length;
66
- // Count branching statements for cyclomatic complexity
67
- const branches = (fileContent.match(/\bif\b/g)?.length || 0) +
68
- (fileContent.match(/\belse\b/g)?.length || 0) +
69
- (fileContent.match(/\bfor\b/g)?.length || 0) +
70
- (fileContent.match(/\bwhile\b/g)?.length || 0) +
71
- (fileContent.match(/\bswitch\b/g)?.length || 0) +
72
- (fileContent.match(/\bcase\b/g)?.length || 0) +
73
- (fileContent.match(/\bcatch\b/g)?.length || 0) +
74
- (fileContent.match(/\?\?/g)?.length || 0) +
75
- (fileContent.match(/&&/g)?.length || 0) +
76
- (fileContent.match(/\|\|/g)?.length || 0) +
77
- (fileContent.match(/\?[^:]/g)?.length || 0); // Ternary
78
- const cyclomaticComplexity = branches + 1;
79
- // Count functions
80
- const functionPatterns = [
81
- /function\s+\w+/g,
82
- /\w+\s*=\s*(?:async\s*)?\(/g,
83
- /\w+\s*:\s*(?:async\s*)?\(/g,
84
- /(?:async\s+)?(?:public|private|protected)?\s+\w+\s*\([^)]*\)\s*[:{]/g,
85
- ];
86
- let functions = 0;
87
- for (const pattern of functionPatterns) {
88
- functions += (fileContent.match(pattern) || []).length;
89
- }
90
- // Deduplicate by rough estimate
91
- functions = Math.ceil(functions / 2);
92
- const avgFunctionSize = functions > 0 ? Math.round(nonEmptyLines / functions) : nonEmptyLines;
93
- return {
94
- file: filePath,
95
- lines: lines.length,
96
- nonEmptyLines,
97
- cyclomaticComplexity,
98
- functions,
99
- avgFunctionSize,
100
- };
101
- }
102
- catch {
103
- return { file: filePath, lines: 0, nonEmptyLines: 0, cyclomaticComplexity: 1, functions: 0, avgFunctionSize: 0 };
104
- }
105
- }
106
- /**
107
- * Analyze complexity of multiple files
108
- */
109
- function analyzeFiles(files, maxFiles = 100) {
110
- return files.slice(0, maxFiles).map(f => analyzeFile(f));
111
- }
112
- /**
113
- * Check if complexity exceeds thresholds
114
- */
115
- function exceedsThresholds(result, thresholds = exports.DEFAULT_THRESHOLDS) {
116
- return (result.cyclomaticComplexity > thresholds.complexity ||
117
- result.functions > thresholds.functions ||
118
- result.lines > thresholds.lines ||
119
- result.avgFunctionSize > thresholds.avgSize);
120
- }
121
- /**
122
- * Get complexity rating
123
- */
124
- function getComplexityRating(complexity) {
125
- if (complexity <= 5)
126
- return 'low';
127
- if (complexity <= 10)
128
- return 'medium';
129
- if (complexity <= 20)
130
- return 'high';
131
- return 'critical';
132
- }
133
- /**
134
- * Filter files exceeding thresholds
135
- */
136
- function filterComplex(results, thresholds = exports.DEFAULT_THRESHOLDS) {
137
- return results.filter(r => exceedsThresholds(r, thresholds));
138
- }
139
- exports.default = {
140
- DEFAULT_THRESHOLDS: exports.DEFAULT_THRESHOLDS,
141
- analyzeFile,
142
- analyzeFiles,
143
- exceedsThresholds,
144
- getComplexityRating,
145
- filterComplex,
146
- };
@@ -1,15 +0,0 @@
1
- /**
2
- * Analysis Module - Consolidated code analysis utilities
3
- *
4
- * Single source of truth for:
5
- * - Security scanning
6
- * - Complexity analysis
7
- * - Pattern extraction
8
- */
9
- export * from './security';
10
- export * from './complexity';
11
- export * from './patterns';
12
- export { default as security } from './security';
13
- export { default as complexity } from './complexity';
14
- export { default as patterns } from './patterns';
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analysis/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- /**
3
- * Analysis Module - Consolidated code analysis utilities
4
- *
5
- * Single source of truth for:
6
- * - Security scanning
7
- * - Complexity analysis
8
- * - Pattern extraction
9
- */
10
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- var desc = Object.getOwnPropertyDescriptor(m, k);
13
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
- desc = { enumerable: true, get: function() { return m[k]; } };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }) : (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- o[k2] = m[k];
20
- }));
21
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
- };
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.patterns = exports.complexity = exports.security = void 0;
29
- __exportStar(require("./security"), exports);
30
- __exportStar(require("./complexity"), exports);
31
- __exportStar(require("./patterns"), exports);
32
- // Re-export defaults for convenience
33
- var security_1 = require("./security");
34
- Object.defineProperty(exports, "security", { enumerable: true, get: function () { return __importDefault(security_1).default; } });
35
- var complexity_1 = require("./complexity");
36
- Object.defineProperty(exports, "complexity", { enumerable: true, get: function () { return __importDefault(complexity_1).default; } });
37
- var patterns_1 = require("./patterns");
38
- Object.defineProperty(exports, "patterns", { enumerable: true, get: function () { return __importDefault(patterns_1).default; } });
@@ -1,71 +0,0 @@
1
- /**
2
- * Pattern Extraction Module - Consolidated code pattern detection
3
- *
4
- * Single source of truth for extracting functions, imports, exports, etc.
5
- * Used by native-worker.ts and parallel-workers.ts
6
- */
7
- export interface PatternMatch {
8
- type: 'function' | 'class' | 'import' | 'export' | 'todo' | 'variable' | 'type';
9
- match: string;
10
- file: string;
11
- line?: number;
12
- }
13
- export interface FilePatterns {
14
- file: string;
15
- language: string;
16
- functions: string[];
17
- classes: string[];
18
- imports: string[];
19
- exports: string[];
20
- todos: string[];
21
- variables: string[];
22
- }
23
- /**
24
- * Detect language from file extension
25
- */
26
- export declare function detectLanguage(file: string): string;
27
- /**
28
- * Extract function names from content
29
- */
30
- export declare function extractFunctions(content: string): string[];
31
- /**
32
- * Extract class names from content
33
- */
34
- export declare function extractClasses(content: string): string[];
35
- /**
36
- * Extract import statements from content
37
- */
38
- export declare function extractImports(content: string): string[];
39
- /**
40
- * Extract export statements from content
41
- */
42
- export declare function extractExports(content: string): string[];
43
- /**
44
- * Extract TODO/FIXME comments from content
45
- */
46
- export declare function extractTodos(content: string): string[];
47
- /**
48
- * Extract all patterns from a file
49
- */
50
- export declare function extractAllPatterns(filePath: string, content?: string): FilePatterns;
51
- /**
52
- * Extract patterns from multiple files
53
- */
54
- export declare function extractFromFiles(files: string[], maxFiles?: number): FilePatterns[];
55
- /**
56
- * Convert FilePatterns to PatternMatch array (for native-worker compatibility)
57
- */
58
- export declare function toPatternMatches(patterns: FilePatterns): PatternMatch[];
59
- declare const _default: {
60
- detectLanguage: typeof detectLanguage;
61
- extractFunctions: typeof extractFunctions;
62
- extractClasses: typeof extractClasses;
63
- extractImports: typeof extractImports;
64
- extractExports: typeof extractExports;
65
- extractTodos: typeof extractTodos;
66
- extractAllPatterns: typeof extractAllPatterns;
67
- extractFromFiles: typeof extractFromFiles;
68
- toPatternMatches: typeof toPatternMatches;
69
- };
70
- export default _default;
71
- //# sourceMappingURL=patterns.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../src/analysis/patterns.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUnD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CA2B1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBxD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAUtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CA0BnF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY,GAAG,YAAY,EAAE,CAExF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAoBvE;;;;;;;;;;;;AAED,wBAUE"}
@@ -1,243 +0,0 @@
1
- "use strict";
2
- /**
3
- * Pattern Extraction Module - Consolidated code pattern detection
4
- *
5
- * Single source of truth for extracting functions, imports, exports, etc.
6
- * Used by native-worker.ts and parallel-workers.ts
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.detectLanguage = detectLanguage;
43
- exports.extractFunctions = extractFunctions;
44
- exports.extractClasses = extractClasses;
45
- exports.extractImports = extractImports;
46
- exports.extractExports = extractExports;
47
- exports.extractTodos = extractTodos;
48
- exports.extractAllPatterns = extractAllPatterns;
49
- exports.extractFromFiles = extractFromFiles;
50
- exports.toPatternMatches = toPatternMatches;
51
- const fs = __importStar(require("fs"));
52
- /**
53
- * Detect language from file extension
54
- */
55
- function detectLanguage(file) {
56
- const ext = file.split('.').pop()?.toLowerCase() || '';
57
- const langMap = {
58
- ts: 'typescript', tsx: 'typescript', js: 'javascript', jsx: 'javascript',
59
- rs: 'rust', py: 'python', go: 'go', java: 'java', rb: 'ruby',
60
- cpp: 'cpp', c: 'c', h: 'c', hpp: 'cpp', cs: 'csharp',
61
- md: 'markdown', json: 'json', yaml: 'yaml', yml: 'yaml',
62
- sql: 'sql', sh: 'shell', bash: 'shell', zsh: 'shell',
63
- };
64
- return langMap[ext] || ext || 'unknown';
65
- }
66
- /**
67
- * Extract function names from content
68
- */
69
- function extractFunctions(content) {
70
- const patterns = [
71
- /function\s+(\w+)/g,
72
- /const\s+(\w+)\s*=\s*(?:async\s*)?\([^)]*\)\s*=>/g,
73
- /let\s+(\w+)\s*=\s*(?:async\s*)?\([^)]*\)\s*=>/g,
74
- /(?:async\s+)?(?:public|private|protected)?\s+(\w+)\s*\([^)]*\)\s*[:{]/g,
75
- /(\w+)\s*:\s*(?:async\s*)?\([^)]*\)\s*=>/g,
76
- /def\s+(\w+)\s*\(/g, // Python
77
- /fn\s+(\w+)\s*[<(]/g, // Rust
78
- /func\s+(\w+)\s*\(/g, // Go
79
- ];
80
- const funcs = new Set();
81
- const reserved = new Set(['if', 'for', 'while', 'switch', 'catch', 'try', 'else', 'return', 'new', 'class', 'function', 'async', 'await']);
82
- for (const pattern of patterns) {
83
- const regex = new RegExp(pattern.source, pattern.flags);
84
- let match;
85
- while ((match = regex.exec(content)) !== null) {
86
- const name = match[1];
87
- if (name && !reserved.has(name) && name.length > 1) {
88
- funcs.add(name);
89
- }
90
- }
91
- }
92
- return Array.from(funcs);
93
- }
94
- /**
95
- * Extract class names from content
96
- */
97
- function extractClasses(content) {
98
- const patterns = [
99
- /class\s+(\w+)/g,
100
- /interface\s+(\w+)/g,
101
- /type\s+(\w+)\s*=/g,
102
- /enum\s+(\w+)/g,
103
- /struct\s+(\w+)/g,
104
- ];
105
- const classes = new Set();
106
- for (const pattern of patterns) {
107
- const regex = new RegExp(pattern.source, pattern.flags);
108
- let match;
109
- while ((match = regex.exec(content)) !== null) {
110
- if (match[1])
111
- classes.add(match[1]);
112
- }
113
- }
114
- return Array.from(classes);
115
- }
116
- /**
117
- * Extract import statements from content
118
- */
119
- function extractImports(content) {
120
- const patterns = [
121
- /import\s+.*?from\s+['"]([^'"]+)['"]/g,
122
- /import\s+['"]([^'"]+)['"]/g,
123
- /require\s*\(['"]([^'"]+)['"]\)/g,
124
- /from\s+(\w+)\s+import/g, // Python
125
- /use\s+(\w+(?:::\w+)*)/g, // Rust
126
- ];
127
- const imports = [];
128
- for (const pattern of patterns) {
129
- const regex = new RegExp(pattern.source, pattern.flags);
130
- let match;
131
- while ((match = regex.exec(content)) !== null) {
132
- if (match[1])
133
- imports.push(match[1]);
134
- }
135
- }
136
- return [...new Set(imports)];
137
- }
138
- /**
139
- * Extract export statements from content
140
- */
141
- function extractExports(content) {
142
- const patterns = [
143
- /export\s+(?:default\s+)?(?:class|function|const|let|var|interface|type|enum)\s+(\w+)/g,
144
- /export\s*\{\s*([^}]+)\s*\}/g,
145
- /module\.exports\s*=\s*(\w+)/g,
146
- /exports\.(\w+)\s*=/g,
147
- /pub\s+(?:fn|struct|enum|type)\s+(\w+)/g, // Rust
148
- ];
149
- const exports = [];
150
- for (const pattern of patterns) {
151
- const regex = new RegExp(pattern.source, pattern.flags);
152
- let match;
153
- while ((match = regex.exec(content)) !== null) {
154
- if (match[1]) {
155
- // Handle grouped exports: export { a, b, c }
156
- const names = match[1].split(',').map(s => s.trim().split(/\s+as\s+/)[0].trim());
157
- exports.push(...names.filter(n => n && /^\w+$/.test(n)));
158
- }
159
- }
160
- }
161
- return [...new Set(exports)];
162
- }
163
- /**
164
- * Extract TODO/FIXME comments from content
165
- */
166
- function extractTodos(content) {
167
- const pattern = /\/\/\s*(TODO|FIXME|HACK|XXX|BUG|NOTE):\s*(.+)/gi;
168
- const todos = [];
169
- let match;
170
- while ((match = pattern.exec(content)) !== null) {
171
- todos.push(`${match[1]}: ${match[2].trim()}`);
172
- }
173
- return todos;
174
- }
175
- /**
176
- * Extract all patterns from a file
177
- */
178
- function extractAllPatterns(filePath, content) {
179
- try {
180
- const fileContent = content ?? (fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf-8') : '');
181
- return {
182
- file: filePath,
183
- language: detectLanguage(filePath),
184
- functions: extractFunctions(fileContent),
185
- classes: extractClasses(fileContent),
186
- imports: extractImports(fileContent),
187
- exports: extractExports(fileContent),
188
- todos: extractTodos(fileContent),
189
- variables: [], // Could add variable extraction if needed
190
- };
191
- }
192
- catch {
193
- return {
194
- file: filePath,
195
- language: detectLanguage(filePath),
196
- functions: [],
197
- classes: [],
198
- imports: [],
199
- exports: [],
200
- todos: [],
201
- variables: [],
202
- };
203
- }
204
- }
205
- /**
206
- * Extract patterns from multiple files
207
- */
208
- function extractFromFiles(files, maxFiles = 100) {
209
- return files.slice(0, maxFiles).map(f => extractAllPatterns(f));
210
- }
211
- /**
212
- * Convert FilePatterns to PatternMatch array (for native-worker compatibility)
213
- */
214
- function toPatternMatches(patterns) {
215
- const matches = [];
216
- for (const func of patterns.functions) {
217
- matches.push({ type: 'function', match: func, file: patterns.file });
218
- }
219
- for (const cls of patterns.classes) {
220
- matches.push({ type: 'class', match: cls, file: patterns.file });
221
- }
222
- for (const imp of patterns.imports) {
223
- matches.push({ type: 'import', match: imp, file: patterns.file });
224
- }
225
- for (const exp of patterns.exports) {
226
- matches.push({ type: 'export', match: exp, file: patterns.file });
227
- }
228
- for (const todo of patterns.todos) {
229
- matches.push({ type: 'todo', match: todo, file: patterns.file });
230
- }
231
- return matches;
232
- }
233
- exports.default = {
234
- detectLanguage,
235
- extractFunctions,
236
- extractClasses,
237
- extractImports,
238
- extractExports,
239
- extractTodos,
240
- extractAllPatterns,
241
- extractFromFiles,
242
- toPatternMatches,
243
- };