pi-mega-compact 0.4.5 → 0.4.6

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 (68) hide show
  1. package/dist/extensions/dashboard-server.js +450 -0
  2. package/dist/extensions/dashboard-server.test.js +111 -0
  3. package/dist/extensions/error-patterns.js +115 -0
  4. package/dist/extensions/mega-compact.js +782 -0
  5. package/dist/extensions/mega-compact.test.js +328 -0
  6. package/dist/extensions/openclaw-mega-compact.js +291 -0
  7. package/dist/src/adapt.js +106 -0
  8. package/dist/src/boundary.js +88 -0
  9. package/dist/src/boundary.test.js +53 -0
  10. package/dist/src/canary.js +118 -0
  11. package/dist/src/compact.js +250 -0
  12. package/dist/src/compact.test.js +78 -0
  13. package/dist/src/config/dedup.js +81 -0
  14. package/dist/src/config.js +12 -0
  15. package/dist/src/dedup/dedup.test.js +41 -0
  16. package/dist/src/dedup/digest.js +30 -0
  17. package/dist/src/dedup/l1-lsh.js +52 -0
  18. package/dist/src/dedup/l1-minhash.js +91 -0
  19. package/dist/src/dedup/l1-verify.js +54 -0
  20. package/dist/src/dedup/l1.test.js +50 -0
  21. package/dist/src/dedup/mmr.js +45 -0
  22. package/dist/src/dedup/normalize.js +39 -0
  23. package/dist/src/dedup/raptor/guardrails.js +83 -0
  24. package/dist/src/dedup/raptor/index.js +94 -0
  25. package/dist/src/dedup/raptor/kmeans.js +152 -0
  26. package/dist/src/dedup/raptor/raptor.test.js +205 -0
  27. package/dist/src/dedup/raptor/retrieval.js +81 -0
  28. package/dist/src/dedup/raptor/summarizer.js +85 -0
  29. package/dist/src/dedup/raptor/tree.js +177 -0
  30. package/dist/src/dedup/sprint12.test.js +219 -0
  31. package/dist/src/dedup/topk.js +60 -0
  32. package/dist/src/dedup-engine.test.js +447 -0
  33. package/dist/src/e2e.test.js +698 -0
  34. package/dist/src/embedder.js +102 -0
  35. package/dist/src/engine.js +137 -0
  36. package/dist/src/engine.test.js +111 -0
  37. package/dist/src/extractive.js +209 -0
  38. package/dist/src/extractive.test.js +130 -0
  39. package/dist/src/httpEmbedder.js +143 -0
  40. package/dist/src/log.js +47 -0
  41. package/dist/src/log.test.js +42 -0
  42. package/dist/src/minilm.js +92 -0
  43. package/dist/src/monitoring.js +131 -0
  44. package/dist/src/ratio.bench.test.js +897 -0
  45. package/dist/src/recall.integration.test.js +77 -0
  46. package/dist/src/recall.js +60 -0
  47. package/dist/src/recall.test.js +50 -0
  48. package/dist/src/sprint14.test.js +219 -0
  49. package/dist/src/store/backfill.js +189 -0
  50. package/dist/src/store/bloom.js +114 -0
  51. package/dist/src/store/compression.js +177 -0
  52. package/dist/src/store/compression.test.js +67 -0
  53. package/dist/src/store/integrity.js +44 -0
  54. package/dist/src/store/migrate.js +79 -0
  55. package/dist/src/store/migrate.test.js +139 -0
  56. package/dist/src/store/sprint10.test.js +186 -0
  57. package/dist/src/store/sqlite.js +574 -0
  58. package/dist/src/store.js +115 -0
  59. package/dist/src/store.test.js +142 -0
  60. package/dist/src/supersede.js +68 -0
  61. package/dist/src/supersede.test.js +36 -0
  62. package/dist/src/tokens.js +31 -0
  63. package/dist/src/types.js +8 -0
  64. package/dist/src/types.test.js +9 -0
  65. package/dist/src/vectorStore.js +465 -0
  66. package/dist/src/vectorStore.test.js +479 -0
  67. package/dist/src/wordpiece.js +129 -0
  68. package/package.json +4 -2
@@ -0,0 +1,115 @@
1
+ // Error pattern detection for broken environment setups
2
+ // Detects various states of incomplete or broken configurations
3
+ export function detectBrokenEnvironmentSetup(configPath, missingFileExists = false) {
4
+ // Pattern 1: Checks if required config files are missing
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const configDir = path.dirname(configPath);
8
+ const requiredFiles = [
9
+ 'config.json',
10
+ 'settings.json',
11
+ '.env',
12
+ 'package.json',
13
+ ];
14
+ const directoryExists = fs.existsSync(configDir);
15
+ const allFilesExist = requiredFiles.every(file => fs.existsSync(path.join(configDir, file)));
16
+ return directoryExists && !allFilesExist && !missingFileExists;
17
+ }
18
+ export function detectBrokenEnvironmentSetupWithLogging(configPath, missingFileExists = false) {
19
+ // Pattern 2: Similar to pattern 1 but with verbose logging for debugging
20
+ const fs = require('fs');
21
+ const path = require('path');
22
+ const configDir = path.dirname(configPath);
23
+ const requiredFiles = [
24
+ 'config.json',
25
+ 'settings.json',
26
+ '.env',
27
+ 'package.json',
28
+ ];
29
+ console.log(`[ERROR_PATTERN] Checking environment at: ${configDir}`);
30
+ const directoryExists = fs.existsSync(configDir);
31
+ console.log(`[ERROR_PATTERN] Directory exists: ${directoryExists}`);
32
+ const fileStatus = requiredFiles.map(file => ({
33
+ file,
34
+ exists: fs.existsSync(path.join(configDir, file)),
35
+ }));
36
+ console.log(`[ERROR_PATTERN] File status:`, fileStatus);
37
+ const allFilesExist = fileStatus.every(f => f.exists);
38
+ const result = directoryExists && !allFilesExist && !missingFileExists;
39
+ console.log(`[ERROR_PATTERN] Broken environment detected: ${result}`);
40
+ return result;
41
+ }
42
+ export function detectPartialEnvironmentSetup(configPath, incompleteFileExists = true) {
43
+ // Pattern 3: Detects a variant where only some files exist
44
+ // and a partial setup marker indicates the setup was interrupted
45
+ const fs = require('fs');
46
+ const path = require('path');
47
+ const configDir = path.dirname(configPath);
48
+ // Files that indicate a complete setup was attempted
49
+ const setupPhaseFiles = [
50
+ 'package.json', // Phase 1: Project initialization
51
+ 'tsconfig.json', // Phase 2: TypeScript configuration
52
+ '.gitignore', // Phase 3: Git setup
53
+ 'README.md', // Phase 4: Documentation
54
+ ];
55
+ // Marker file that indicates setup started but wasn't completed
56
+ const partialMarker = '.setup-in-progress';
57
+ const partialMarkerPath = path.join(configDir, partialMarker);
58
+ console.log(`[PARTIAL_SETUP] Checking for incomplete setup at: ${configDir}`);
59
+ const directoryExists = fs.existsSync(configDir);
60
+ if (!directoryExists) {
61
+ console.log(`[PARTIAL_SETUP] Directory does not exist`);
62
+ return false;
63
+ }
64
+ const partialMarkerExists = fs.existsSync(partialMarkerPath);
65
+ console.log(`[PARTIAL_SETUP] Partial marker exists: ${partialMarkerExists}`);
66
+ const fileCheckResults = setupPhaseFiles.map(file => ({
67
+ exists: fs.existsSync(path.join(configDir, file)),
68
+ path: file,
69
+ }));
70
+ const existingFiles = fileCheckResults.filter(f => f.exists);
71
+ const missingFiles = fileCheckResults.filter(f => !f.exists);
72
+ console.log(`[PARTIAL_SETUP] Existing files: ${existingFiles.map(f => f.path).join(', ')}`);
73
+ console.log(`[PARTIAL_SETUP] Missing files: ${missingFiles.map(f => f.path).join(', ')}`);
74
+ // Detect partial setup: some files exist but not all,
75
+ // and either the partial marker exists or incomplete file flag is set
76
+ const hasPartialState = existingFiles.length > 0 && existingFiles.length < setupPhaseFiles.length;
77
+ const isPartialSetup = hasPartialState && (partialMarkerExists || incompleteFileExists);
78
+ console.log(`[PARTIAL_SETUP] Partial state detected: ${hasPartialState}`);
79
+ console.log(`[PARTIAL_SETUP] Is partial setup: ${isPartialSetup}`);
80
+ return isPartialSetup;
81
+ }
82
+ // Helper function to get detailed partial setup information
83
+ export function getPartialSetupDetails(configPath) {
84
+ const fs = require('fs');
85
+ const path = require('path');
86
+ const configDir = path.dirname(configPath);
87
+ const setupPhaseFiles = ['package.json', 'tsconfig.json', '.gitignore', 'README.md'];
88
+ const partialMarker = '.setup-in-progress';
89
+ if (!fs.existsSync(configDir)) {
90
+ return null;
91
+ }
92
+ return {
93
+ directoryExists: true,
94
+ requiredFiles: setupPhaseFiles.map(file => ({
95
+ exists: fs.existsSync(path.join(configDir, file)),
96
+ path: path.join(configDir, file),
97
+ })),
98
+ partialMarkerExists: fs.existsSync(path.join(configDir, partialMarker)),
99
+ };
100
+ }
101
+ // Function to create a partial setup state for testing
102
+ export function createPartialSetupForTesting(testDir, filesToCreate) {
103
+ const fs = require('fs');
104
+ const path = require('path');
105
+ if (!fs.existsSync(testDir)) {
106
+ fs.mkdirSync(testDir, { recursive: true });
107
+ }
108
+ // Create the partial marker file
109
+ fs.writeFileSync(path.join(testDir, '.setup-in-progress'), 'Setup in progress...');
110
+ // Create only the specified files
111
+ filesToCreate.forEach(file => {
112
+ const filePath = path.join(testDir, file);
113
+ fs.writeFileSync(filePath, `// ${file} content`);
114
+ });
115
+ }