lynkr 8.0.0 → 8.0.1

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 (102) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/api/openai-router.js +34 -2
  4. package/src/clients/standard-tools.js +23 -0
  5. package/src/config/index.js +20 -0
  6. package/src/orchestrator/index.js +2 -2
  7. package/src/server.js +2 -12
  8. package/src/tools/index.js +4 -0
  9. package/src/tools/lazy-loader.js +7 -0
  10. package/src/tools/tinyfish.js +358 -0
  11. package/src/tools/truncate.js +1 -0
  12. package/.github/FUNDING.yml +0 -15
  13. package/.github/workflows/README.md +0 -215
  14. package/.github/workflows/ci.yml +0 -69
  15. package/.github/workflows/index.yml +0 -62
  16. package/.github/workflows/web-tools-tests.yml +0 -56
  17. package/CITATIONS.bib +0 -6
  18. package/DEPLOYMENT.md +0 -1001
  19. package/LYNKR-TUI-PLAN.md +0 -984
  20. package/PERFORMANCE-REPORT.md +0 -866
  21. package/PLAN-per-client-model-routing.md +0 -252
  22. package/docs/42642f749da6234f41b6b425c3bb07c9.txt +0 -1
  23. package/docs/BingSiteAuth.xml +0 -4
  24. package/docs/docs-style.css +0 -478
  25. package/docs/docs.html +0 -198
  26. package/docs/google5be250e608e6da39.html +0 -1
  27. package/docs/index.html +0 -577
  28. package/docs/index.md +0 -584
  29. package/docs/robots.txt +0 -4
  30. package/docs/sitemap.xml +0 -44
  31. package/docs/style.css +0 -1223
  32. package/docs/toon-integration-spec.md +0 -130
  33. package/documentation/README.md +0 -101
  34. package/documentation/api.md +0 -806
  35. package/documentation/claude-code-cli.md +0 -679
  36. package/documentation/codex-cli.md +0 -397
  37. package/documentation/contributing.md +0 -571
  38. package/documentation/cursor-integration.md +0 -734
  39. package/documentation/docker.md +0 -874
  40. package/documentation/embeddings.md +0 -762
  41. package/documentation/faq.md +0 -713
  42. package/documentation/features.md +0 -403
  43. package/documentation/headroom.md +0 -519
  44. package/documentation/installation.md +0 -758
  45. package/documentation/memory-system.md +0 -476
  46. package/documentation/production.md +0 -636
  47. package/documentation/providers.md +0 -1009
  48. package/documentation/routing.md +0 -476
  49. package/documentation/testing.md +0 -629
  50. package/documentation/token-optimization.md +0 -325
  51. package/documentation/tools.md +0 -697
  52. package/documentation/troubleshooting.md +0 -969
  53. package/final-test.js +0 -33
  54. package/headroom-sidecar/config.py +0 -93
  55. package/headroom-sidecar/requirements.txt +0 -14
  56. package/headroom-sidecar/server.py +0 -451
  57. package/monitor-agents.sh +0 -31
  58. package/scripts/audit-log-reader.js +0 -399
  59. package/scripts/compact-dictionary.js +0 -204
  60. package/scripts/test-deduplication.js +0 -448
  61. package/src/db/database.sqlite +0 -0
  62. package/te +0 -11622
  63. package/test/README.md +0 -212
  64. package/test/azure-openai-config.test.js +0 -213
  65. package/test/azure-openai-error-resilience.test.js +0 -238
  66. package/test/azure-openai-format-conversion.test.js +0 -354
  67. package/test/azure-openai-integration.test.js +0 -287
  68. package/test/azure-openai-routing.test.js +0 -175
  69. package/test/azure-openai-streaming.test.js +0 -171
  70. package/test/bedrock-integration.test.js +0 -457
  71. package/test/comprehensive-test-suite.js +0 -928
  72. package/test/config-validation.test.js +0 -207
  73. package/test/cursor-integration.test.js +0 -484
  74. package/test/format-conversion.test.js +0 -578
  75. package/test/hybrid-routing-integration.test.js +0 -269
  76. package/test/hybrid-routing-performance.test.js +0 -428
  77. package/test/llamacpp-integration.test.js +0 -882
  78. package/test/lmstudio-integration.test.js +0 -347
  79. package/test/memory/extractor.test.js +0 -398
  80. package/test/memory/retriever.test.js +0 -613
  81. package/test/memory/retriever.test.js.bak +0 -585
  82. package/test/memory/search.test.js +0 -537
  83. package/test/memory/search.test.js.bak +0 -389
  84. package/test/memory/store.test.js +0 -344
  85. package/test/memory/store.test.js.bak +0 -312
  86. package/test/memory/surprise.test.js +0 -300
  87. package/test/memory-performance.test.js +0 -472
  88. package/test/openai-integration.test.js +0 -683
  89. package/test/openrouter-error-resilience.test.js +0 -418
  90. package/test/passthrough-mode.test.js +0 -385
  91. package/test/performance-benchmark.js +0 -351
  92. package/test/performance-tests.js +0 -528
  93. package/test/routing.test.js +0 -225
  94. package/test/toon-compression.test.js +0 -131
  95. package/test/web-tools.test.js +0 -329
  96. package/test-agents-simple.js +0 -43
  97. package/test-cli-connection.sh +0 -33
  98. package/test-learning-unit.js +0 -126
  99. package/test-learning.js +0 -112
  100. package/test-parallel-agents.sh +0 -124
  101. package/test-parallel-direct.js +0 -155
  102. package/test-subagents.sh +0 -117
@@ -1,528 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Comprehensive Performance Test Suite for Lynkr Optimizations
5
- * Tests all 10 implemented optimizations and measures improvements
6
- */
7
-
8
- const Database = require('better-sqlite3');
9
- const path = require('path');
10
- const fs = require('fs');
11
- const { performance } = require('perf_hooks');
12
-
13
- // Colors for terminal output
14
- const colors = {
15
- reset: '\x1b[0m',
16
- bright: '\x1b[1m',
17
- green: '\x1b[32m',
18
- yellow: '\x1b[33m',
19
- blue: '\x1b[34m',
20
- red: '\x1b[31m',
21
- cyan: '\x1b[36m',
22
- };
23
-
24
- function log(message, color = 'reset') {
25
- console.log(`${colors[color]}${message}${colors.reset}`);
26
- }
27
-
28
- function section(title) {
29
- console.log('\n' + '='.repeat(60));
30
- log(title, 'bright');
31
- console.log('='.repeat(60));
32
- }
33
-
34
- function benchmark(name, fn) {
35
- const start = performance.now();
36
- const result = fn();
37
- const duration = performance.now() - start;
38
- return { result, duration };
39
- }
40
-
41
- async function asyncBenchmark(name, fn) {
42
- const start = performance.now();
43
- const result = await fn();
44
- const duration = performance.now() - start;
45
- return { result, duration };
46
- }
47
-
48
- // Test results storage
49
- const results = {
50
- database: {},
51
- cache: {},
52
- regex: {},
53
- lazy: {},
54
- http: {},
55
- compression: {},
56
- };
57
-
58
- // =============================================================================
59
- // TEST 1: Database Indexes Performance
60
- // =============================================================================
61
- async function testDatabaseIndexes() {
62
- section('TEST 1: Database Indexes Performance');
63
-
64
- const dbPath = path.join(process.cwd(), 'data', 'sessions.db');
65
-
66
- if (!fs.existsSync(dbPath)) {
67
- log('⚠️ Database not found. Creating test database...', 'yellow');
68
- // Initialize database
69
- require('../src/db/index.js');
70
- }
71
-
72
- const db = new Database(dbPath);
73
-
74
- // Check if indexes exist
75
- log('\n📊 Checking Database Indexes...', 'cyan');
76
- const indexes = db.prepare("SELECT name FROM sqlite_master WHERE type='index'").all();
77
-
78
- const expectedIndexes = [
79
- 'idx_session_history_role',
80
- 'idx_sessions_created_at',
81
- 'idx_sessions_updated_at',
82
- 'idx_files_language',
83
- 'idx_files_mtime',
84
- 'idx_symbols_file_path',
85
- 'idx_symbols_name',
86
- 'idx_symbols_kind',
87
- ];
88
-
89
- const foundIndexes = indexes.map(i => i.name);
90
- let indexScore = 0;
91
-
92
- expectedIndexes.forEach(idx => {
93
- if (foundIndexes.includes(idx)) {
94
- log(`✅ ${idx}`, 'green');
95
- indexScore++;
96
- } else {
97
- log(`❌ ${idx} - MISSING`, 'red');
98
- }
99
- });
100
-
101
- results.database.indexesFound = indexScore;
102
- results.database.indexesExpected = expectedIndexes.length;
103
- results.database.indexScore = ((indexScore / expectedIndexes.length) * 100).toFixed(1);
104
-
105
- // Test query performance with EXPLAIN QUERY PLAN
106
- log('\n📊 Testing Query Performance...', 'cyan');
107
-
108
- const queries = [
109
- {
110
- name: 'Session history by role',
111
- query: "EXPLAIN QUERY PLAN SELECT * FROM session_history WHERE role = 'user' LIMIT 100",
112
- shouldUseIndex: 'idx_session_history_role'
113
- },
114
- {
115
- name: 'Recent sessions',
116
- query: 'EXPLAIN QUERY PLAN SELECT * FROM sessions ORDER BY updated_at DESC LIMIT 100',
117
- shouldUseIndex: 'idx_sessions_updated_at'
118
- },
119
- {
120
- name: 'Files by language',
121
- query: "EXPLAIN QUERY PLAN SELECT * FROM files WHERE language = 'javascript'",
122
- shouldUseIndex: 'idx_files_language'
123
- },
124
- {
125
- name: 'Symbol search',
126
- query: "EXPLAIN QUERY PLAN SELECT * FROM symbols WHERE name = 'test'",
127
- shouldUseIndex: 'idx_symbols_name'
128
- },
129
- ];
130
-
131
- let queryScore = 0;
132
- queries.forEach(({ name, query, shouldUseIndex }) => {
133
- try {
134
- const plan = db.prepare(query).all();
135
- const planText = plan.map(p => p.detail).join(' ');
136
- const usesIndex = planText.toLowerCase().includes('using index');
137
- const usesCorrectIndex = planText.includes(shouldUseIndex);
138
-
139
- if (usesCorrectIndex) {
140
- log(`✅ ${name} - Uses ${shouldUseIndex}`, 'green');
141
- queryScore++;
142
- } else if (usesIndex) {
143
- log(`⚠️ ${name} - Uses index but not optimal`, 'yellow');
144
- queryScore += 0.5;
145
- } else {
146
- log(`❌ ${name} - Full table scan`, 'red');
147
- }
148
- } catch (error) {
149
- log(`⚠️ ${name} - Table doesn't exist yet`, 'yellow');
150
- }
151
- });
152
-
153
- results.database.queryScore = ((queryScore / queries.length) * 100).toFixed(1);
154
-
155
- // Benchmark actual query speed
156
- log('\n📊 Benchmarking Query Speed...', 'cyan');
157
-
158
- try {
159
- const sessionCount = db.prepare('SELECT COUNT(*) as count FROM session_history').get();
160
-
161
- if (sessionCount && sessionCount.count > 0) {
162
- const { duration: withIndexDuration } = benchmark('Query with indexes', () => {
163
- return db.prepare("SELECT * FROM session_history WHERE role = 'user' LIMIT 100").all();
164
- });
165
-
166
- log(`⏱️ Query with indexes: ${withIndexDuration.toFixed(2)}ms`, 'cyan');
167
- results.database.queryTime = withIndexDuration.toFixed(2);
168
- } else {
169
- log('⚠️ No data in database for benchmarking', 'yellow');
170
- results.database.queryTime = 'N/A';
171
- }
172
- } catch (error) {
173
- log(`⚠️ Could not benchmark: ${error.message}`, 'yellow');
174
- results.database.queryTime = 'N/A';
175
- }
176
-
177
- db.close();
178
-
179
- log(`\n✅ Database Tests Complete: ${results.database.indexScore}% indexes, ${results.database.queryScore}% query optimization`, 'green');
180
- }
181
-
182
- // =============================================================================
183
- // TEST 2: Persistent Prompt Cache
184
- // =============================================================================
185
- async function testPromptCache() {
186
- section('TEST 2: Persistent Prompt Cache');
187
-
188
- log('\n📊 Testing Prompt Cache Implementation...', 'cyan');
189
-
190
- // Load the cache module
191
- const promptCache = require('../src/cache/prompt.js');
192
-
193
- // Test 1: Check if persistent storage is enabled
194
- const stats = promptCache.stats();
195
- log(`Cache enabled: ${stats.enabled ? '✅' : '❌'}`, stats.enabled ? 'green' : 'red');
196
- log(`Max entries: ${stats.maxEntries} (upgraded from 64)`, stats.maxEntries >= 1000 ? 'green' : 'yellow');
197
- log(`TTL: ${stats.ttlMs}ms`, 'cyan');
198
-
199
- results.cache.enabled = stats.enabled;
200
- results.cache.maxEntries = stats.maxEntries;
201
- results.cache.persistent = fs.existsSync(path.join(process.cwd(), 'data', 'prompt-cache.db'));
202
-
203
- if (results.cache.persistent) {
204
- log('✅ Persistent cache database found', 'green');
205
- } else {
206
- log('⚠️ Persistent cache database not created yet (will be created on first use)', 'yellow');
207
- }
208
-
209
- // Test 2: Benchmark cache performance
210
- if (stats.enabled) {
211
- log('\n📊 Benchmarking Cache Operations...', 'cyan');
212
-
213
- const testPayload = {
214
- model: 'test-model',
215
- messages: [{ role: 'user', content: 'test message' }],
216
- max_tokens: 100,
217
- };
218
-
219
- const testResponse = {
220
- ok: true,
221
- status: 200,
222
- json: {
223
- choices: [{
224
- message: { content: 'test response' },
225
- finish_reason: 'stop'
226
- }]
227
- }
228
- };
229
-
230
- // Benchmark write
231
- const { duration: writeDuration } = benchmark('Cache write', () => {
232
- return promptCache.storeResponse(testPayload, testResponse);
233
- });
234
-
235
- // Benchmark read
236
- const { duration: readDuration, result: cachedResult } = benchmark('Cache read', () => {
237
- return promptCache.fetch(testPayload);
238
- });
239
-
240
- log(`⏱️ Cache write: ${writeDuration.toFixed(3)}ms`, 'cyan');
241
- log(`⏱️ Cache read: ${readDuration.toFixed(3)}ms`, 'cyan');
242
- log(`${cachedResult ? '✅' : '❌'} Cache hit successful`, cachedResult ? 'green' : 'red');
243
-
244
- results.cache.writeTime = writeDuration.toFixed(3);
245
- results.cache.readTime = readDuration.toFixed(3);
246
- results.cache.speedup = readDuration < 1 ? `${(1 / readDuration).toFixed(1)}x faster than typical API call` : 'Instant';
247
- }
248
-
249
- log(`\n✅ Cache Tests Complete`, 'green');
250
- }
251
-
252
- // =============================================================================
253
- // TEST 3: Regex Pattern Caching
254
- // =============================================================================
255
- async function testRegexCaching() {
256
- section('TEST 3: Regex Pattern Caching');
257
-
258
- log('\n📊 Testing Regex Caching Implementation...', 'cyan');
259
-
260
- // Read indexer file to verify implementation
261
- const indexerCode = fs.readFileSync(path.join(__dirname, '..', 'src', 'indexer', 'index.js'), 'utf8');
262
-
263
- const hasRegexCache = indexerCode.includes('regexCache') && indexerCode.includes('getCachedRegex');
264
- const hasCacheLimit = indexerCode.includes('MAX_REGEX_CACHE_SIZE');
265
-
266
- log(`${hasRegexCache ? '✅' : '❌'} Regex cache implemented`, hasRegexCache ? 'green' : 'red');
267
- log(`${hasCacheLimit ? '✅' : '❌'} Cache size limit implemented`, hasCacheLimit ? 'green' : 'red');
268
-
269
- results.regex.implemented = hasRegexCache && hasCacheLimit;
270
-
271
- // Benchmark regex creation with and without cache
272
- log('\n📊 Benchmarking Regex Performance...', 'cyan');
273
-
274
- const testSymbols = ['testFunction', 'MyClass', 'handleClick', 'useState', 'getServerSideProps'];
275
-
276
- // Without cache (create new regex each time)
277
- const { duration: withoutCacheDuration } = benchmark('Without cache (100 iterations)', () => {
278
- for (let i = 0; i < 100; i++) {
279
- testSymbols.forEach(symbol => {
280
- const escaped = symbol.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
281
- new RegExp(`\\b${escaped}\\b`, "g");
282
- });
283
- }
284
- });
285
-
286
- // With cache simulation
287
- const cache = new Map();
288
- const { duration: withCacheDuration } = benchmark('With cache (100 iterations)', () => {
289
- for (let i = 0; i < 100; i++) {
290
- testSymbols.forEach(symbol => {
291
- if (!cache.has(symbol)) {
292
- const escaped = symbol.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
293
- cache.set(symbol, new RegExp(`\\b${escaped}\\b`, "g"));
294
- }
295
- cache.get(symbol);
296
- });
297
- }
298
- });
299
-
300
- const speedup = (withoutCacheDuration / withCacheDuration).toFixed(1);
301
-
302
- log(`⏱️ Without cache: ${withoutCacheDuration.toFixed(2)}ms`, 'cyan');
303
- log(`⏱️ With cache: ${withCacheDuration.toFixed(2)}ms`, 'cyan');
304
- log(`🚀 Speedup: ${speedup}x faster`, 'green');
305
-
306
- results.regex.speedup = speedup;
307
- results.regex.timeWithout = withoutCacheDuration.toFixed(2);
308
- results.regex.timeWith = withCacheDuration.toFixed(2);
309
-
310
- log(`\n✅ Regex Tests Complete: ${speedup}x faster`, 'green');
311
- }
312
-
313
- // =============================================================================
314
- // TEST 4: Lazy Loading Performance
315
- // =============================================================================
316
- async function testLazyLoading() {
317
- section('TEST 4: Lazy Loading Performance');
318
-
319
- log('\n📊 Testing Lazy Loading Implementation...', 'cyan');
320
-
321
- // Check parser.js for lazy loading
322
- const parserCode = fs.readFileSync(path.join(__dirname, '..', 'src', 'indexer', 'parser.js'), 'utf8');
323
-
324
- const hasLazyLoading = parserCode.includes('let Parser = null') &&
325
- parserCode.includes('getTreeSitterParser') &&
326
- parserCode.includes('getLanguageModule');
327
-
328
- log(`${hasLazyLoading ? '✅' : '❌'} Lazy loading implemented`, hasLazyLoading ? 'green' : 'red');
329
-
330
- results.lazy.implemented = hasLazyLoading;
331
-
332
- // Measure startup time improvement
333
- log('\n📊 Measuring Startup Performance...', 'cyan');
334
-
335
- // This is a simulation since we can't easily measure actual cold start
336
- log('⏱️ Estimated startup improvement: 2-4x faster', 'cyan');
337
- log('📦 Tree-sitter modules load on-demand only', 'cyan');
338
-
339
- results.lazy.benefit = 'Loads only when indexing is triggered';
340
-
341
- log(`\n✅ Lazy Loading Tests Complete`, 'green');
342
- }
343
-
344
- // =============================================================================
345
- // TEST 5: HTTP Connection Pooling
346
- // =============================================================================
347
- async function testHTTPPooling() {
348
- section('TEST 5: HTTP Connection Pooling');
349
-
350
- log('\n📊 Testing HTTP Pooling Implementation...', 'cyan');
351
-
352
- // Check databricks client for connection pooling
353
- const clientCode = fs.readFileSync(path.join(__dirname, '..', 'src', 'clients', 'databricks.js'), 'utf8');
354
-
355
- const hasPooling = clientCode.includes('httpAgent') &&
356
- clientCode.includes('httpsAgent') &&
357
- clientCode.includes('keepAlive: true');
358
-
359
- log(`${hasPooling ? '✅' : '❌'} HTTP connection pooling implemented`, hasPooling ? 'green' : 'red');
360
-
361
- if (hasPooling) {
362
- const hasMaxSockets = clientCode.includes('maxSockets');
363
- const hasKeepAlive = clientCode.includes('keepAliveMsecs');
364
-
365
- log(`${hasMaxSockets ? '✅' : '❌'} Connection pool size configured`, hasMaxSockets ? 'green' : 'red');
366
- log(`${hasKeepAlive ? '✅' : '❌'} Keep-alive configured`, hasKeepAlive ? 'green' : 'red');
367
- }
368
-
369
- results.http.implemented = hasPooling;
370
- results.http.benefit = 'Reuses TCP connections, 2x faster API calls';
371
-
372
- log(`\n✅ HTTP Pooling Tests Complete`, 'green');
373
- }
374
-
375
- // =============================================================================
376
- // TEST 6: Response Compression
377
- // =============================================================================
378
- async function testCompression() {
379
- section('TEST 6: Response Compression');
380
-
381
- log('\n📊 Testing Compression Implementation...', 'cyan');
382
-
383
- // Check server.js for compression middleware
384
- const serverCode = fs.readFileSync(path.join(__dirname, '..', 'src', 'server.js'), 'utf8');
385
-
386
- const hasCompression = serverCode.includes("require('compression')") ||
387
- serverCode.includes('require("compression")');
388
- const usesCompression = serverCode.includes('app.use(compression');
389
-
390
- log(`${hasCompression ? '✅' : '❌'} Compression module imported`, hasCompression ? 'green' : 'red');
391
- log(`${usesCompression ? '✅' : '❌'} Compression middleware enabled`, usesCompression ? 'green' : 'red');
392
-
393
- // Check package.json
394
- const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
395
- const compressionInstalled = packageJson.dependencies && packageJson.dependencies.compression;
396
-
397
- log(`${compressionInstalled ? '✅' : '❌'} Compression dependency installed`, compressionInstalled ? 'green' : 'red');
398
-
399
- results.compression.implemented = hasCompression && usesCompression && compressionInstalled;
400
- results.compression.benefit = '3x smaller response payloads (gzip)';
401
-
402
- log(`\n✅ Compression Tests Complete`, 'green');
403
- }
404
-
405
- // =============================================================================
406
- // FINAL REPORT
407
- // =============================================================================
408
- function printFinalReport() {
409
- section('📊 PERFORMANCE OPTIMIZATION SUMMARY');
410
-
411
- console.log('\n');
412
- console.log('┌─────────────────────────────────────────────────────────┐');
413
- console.log('│ OPTIMIZATION RESULTS │');
414
- console.log('├─────────────────────────────────────────────────────────┤');
415
-
416
- // Database
417
- log(`│ 1. Database Indexes ${results.database.indexScore}% Complete │`,
418
- results.database.indexScore >= 80 ? 'green' : 'yellow');
419
- log(`│ - Indexes found: ${results.database.indexesFound}/${results.database.indexesExpected} │`, 'cyan');
420
- log(`│ - Query optimization: ${results.database.queryScore}% │`, 'cyan');
421
- if (results.database.queryTime !== 'N/A') {
422
- log(`│ - Query time: ${results.database.queryTime}ms │`, 'cyan');
423
- }
424
-
425
- console.log('├─────────────────────────────────────────────────────────┤');
426
-
427
- // Cache
428
- log(`│ 2. Persistent Prompt Cache ${results.cache.enabled ? '✅ Active' : '❌ Inactive'} │`,
429
- results.cache.enabled ? 'green' : 'red');
430
- log(`│ - Max entries: ${results.cache.maxEntries} (was 64) │`, 'cyan');
431
- log(`│ - Persistent: ${results.cache.persistent ? 'Yes' : 'No'} │`, 'cyan');
432
- if (results.cache.writeTime) {
433
- log(`│ - Write: ${results.cache.writeTime}ms, Read: ${results.cache.readTime}ms │`, 'cyan');
434
- }
435
-
436
- console.log('├─────────────────────────────────────────────────────────┤');
437
-
438
- // Regex
439
- log(`│ 3. Regex Pattern Caching ${results.regex.implemented ? '✅ Implemented' : '❌ Missing'} │`,
440
- results.regex.implemented ? 'green' : 'red');
441
- if (results.regex.speedup) {
442
- log(`│ - Speedup: ${results.regex.speedup}x faster │`, 'green');
443
- }
444
-
445
- console.log('├─────────────────────────────────────────────────────────┤');
446
-
447
- // Lazy Loading
448
- log(`│ 4. Lazy Loading ${results.lazy.implemented ? '✅ Implemented' : '❌ Missing'} │`,
449
- results.lazy.implemented ? 'green' : 'red');
450
- log(`│ - Tree-sitter loads on-demand │`, 'cyan');
451
-
452
- console.log('├─────────────────────────────────────────────────────────┤');
453
-
454
- // HTTP Pooling
455
- log(`│ 5. HTTP Connection Pooling ${results.http.implemented ? '✅ Implemented' : '❌ Missing'} │`,
456
- results.http.implemented ? 'green' : 'red');
457
- log(`│ - Keep-alive connections enabled │`, 'cyan');
458
-
459
- console.log('├─────────────────────────────────────────────────────────┤');
460
-
461
- // Compression
462
- log(`│ 6. Response Compression ${results.compression.implemented ? '✅ Implemented' : '❌ Missing'} │`,
463
- results.compression.implemented ? 'green' : 'red');
464
- log(`│ - Gzip/deflate for responses > 1KB │`, 'cyan');
465
-
466
- console.log('└─────────────────────────────────────────────────────────┘');
467
-
468
- // Overall score
469
- const optimizations = [
470
- results.database.indexScore >= 80,
471
- results.cache.enabled,
472
- results.regex.implemented,
473
- results.lazy.implemented,
474
- results.http.implemented,
475
- results.compression.implemented,
476
- ];
477
-
478
- const successCount = optimizations.filter(Boolean).length;
479
- const successRate = ((successCount / optimizations.length) * 100).toFixed(0);
480
-
481
- console.log('\n');
482
- log(`🎯 Overall Success Rate: ${successRate}% (${successCount}/${optimizations.length} optimizations active)`,
483
- successRate >= 80 ? 'green' : successRate >= 60 ? 'yellow' : 'red');
484
-
485
- // Expected improvements
486
- console.log('\n📈 Expected Performance Improvements:');
487
- log(' • Database queries: 5-10x faster', 'green');
488
- log(' • Cache hits: Near-instant (vs 500ms+ API calls)', 'green');
489
- log(' • Symbol indexing: 5x faster regex operations', 'green');
490
- log(' • Server startup: 2-4x faster', 'green');
491
- log(' • API latency: 2x faster with connection pooling', 'green');
492
- log(' • Network transfer: 3x smaller payloads', 'green');
493
- log('\n 🚀 Combined: 5-10x overall performance improvement!', 'bright');
494
-
495
- console.log('\n');
496
- }
497
-
498
- // =============================================================================
499
- // RUN ALL TESTS
500
- // =============================================================================
501
- async function runAllTests() {
502
- log('\n🚀 Starting Lynkr Performance Test Suite\n', 'bright');
503
-
504
- try {
505
- await testDatabaseIndexes();
506
- await testPromptCache();
507
- await testRegexCaching();
508
- await testLazyLoading();
509
- await testHTTPPooling();
510
- await testCompression();
511
-
512
- printFinalReport();
513
-
514
- log('\n✅ All tests completed successfully!\n', 'green');
515
- process.exit(0);
516
- } catch (error) {
517
- log(`\n❌ Test suite failed: ${error.message}\n`, 'red');
518
- console.error(error);
519
- process.exit(1);
520
- }
521
- }
522
-
523
- // Run tests
524
- if (require.main === module) {
525
- runAllTests();
526
- }
527
-
528
- module.exports = { runAllTests };