pi-mega-compact 0.4.5 → 0.4.7
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.
- package/dist/extensions/dashboard-server.js +450 -0
- package/dist/extensions/dashboard-server.test.js +111 -0
- package/dist/extensions/error-patterns.js +115 -0
- package/dist/extensions/mega-compact.js +821 -0
- package/dist/extensions/mega-compact.test.js +328 -0
- package/dist/extensions/openclaw-mega-compact.js +291 -0
- package/dist/src/adapt.js +106 -0
- package/dist/src/boundary.js +88 -0
- package/dist/src/boundary.test.js +53 -0
- package/dist/src/canary.js +118 -0
- package/dist/src/compact.js +250 -0
- package/dist/src/compact.test.js +78 -0
- package/dist/src/config/dedup.js +81 -0
- package/dist/src/config.js +12 -0
- package/dist/src/dedup/dedup.test.js +41 -0
- package/dist/src/dedup/digest.js +30 -0
- package/dist/src/dedup/l1-lsh.js +52 -0
- package/dist/src/dedup/l1-minhash.js +91 -0
- package/dist/src/dedup/l1-verify.js +54 -0
- package/dist/src/dedup/l1.test.js +50 -0
- package/dist/src/dedup/mmr.js +45 -0
- package/dist/src/dedup/normalize.js +39 -0
- package/dist/src/dedup/raptor/guardrails.js +83 -0
- package/dist/src/dedup/raptor/index.js +94 -0
- package/dist/src/dedup/raptor/kmeans.js +152 -0
- package/dist/src/dedup/raptor/raptor.test.js +205 -0
- package/dist/src/dedup/raptor/retrieval.js +81 -0
- package/dist/src/dedup/raptor/summarizer.js +85 -0
- package/dist/src/dedup/raptor/tree.js +177 -0
- package/dist/src/dedup/sprint12.test.js +219 -0
- package/dist/src/dedup/topk.js +60 -0
- package/dist/src/dedup-engine.test.js +447 -0
- package/dist/src/e2e.test.js +698 -0
- package/dist/src/embedder.js +102 -0
- package/dist/src/engine.js +139 -0
- package/dist/src/engine.test.js +111 -0
- package/dist/src/extractive.js +209 -0
- package/dist/src/extractive.test.js +130 -0
- package/dist/src/httpEmbedder.js +143 -0
- package/dist/src/log.js +47 -0
- package/dist/src/log.test.js +42 -0
- package/dist/src/minilm.js +92 -0
- package/dist/src/monitoring.js +131 -0
- package/dist/src/ratio.bench.test.js +897 -0
- package/dist/src/recall.integration.test.js +77 -0
- package/dist/src/recall.js +60 -0
- package/dist/src/recall.test.js +50 -0
- package/dist/src/sprint14.test.js +219 -0
- package/dist/src/store/backfill.js +189 -0
- package/dist/src/store/bloom.js +114 -0
- package/dist/src/store/compression.js +177 -0
- package/dist/src/store/compression.test.js +67 -0
- package/dist/src/store/integrity.js +44 -0
- package/dist/src/store/migrate.js +79 -0
- package/dist/src/store/migrate.test.js +139 -0
- package/dist/src/store/sprint10.test.js +186 -0
- package/dist/src/store/sqlite.js +574 -0
- package/dist/src/store.js +115 -0
- package/dist/src/store.test.js +142 -0
- package/dist/src/supersede.js +68 -0
- package/dist/src/supersede.test.js +36 -0
- package/dist/src/tokens.js +31 -0
- package/dist/src/types.js +8 -0
- package/dist/src/types.test.js +9 -0
- package/dist/src/vectorStore.js +465 -0
- package/dist/src/vectorStore.test.js +479 -0
- package/dist/src/wordpiece.js +129 -0
- package/extensions/mega-compact.ts +47 -11
- package/package.json +4 -2
- package/src/engine.ts +5 -0
|
@@ -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
|
+
}
|