claude-flow 2.7.34 → 2.7.36

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 (134) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/bin/claude-flow +1 -1
  3. package/dist/src/__tests__/benchmarks/performance.bench.js +0 -19
  4. package/dist/src/__tests__/benchmarks/performance.bench.js.map +1 -1
  5. package/dist/src/__tests__/hook-matchers.test.js.map +1 -1
  6. package/dist/src/agents/agent-registry.js.map +1 -1
  7. package/dist/src/api/auth-service.js.map +1 -1
  8. package/dist/src/api/claude-client-enhanced.js +4 -2
  9. package/dist/src/api/claude-client-enhanced.js.map +1 -1
  10. package/dist/src/api/claude-client.js +4 -2
  11. package/dist/src/api/claude-client.js.map +1 -1
  12. package/dist/src/api/database-service.js.map +1 -1
  13. package/dist/src/api/swarm-api.js +1 -1
  14. package/dist/src/api/swarm-api.js.map +1 -1
  15. package/dist/src/cli/commands/hive-mind/wizard.js +1 -1
  16. package/dist/src/cli/commands/hive-mind/wizard.js.map +1 -1
  17. package/dist/src/cli/help-formatter.js +0 -5
  18. package/dist/src/cli/init/index.js +55 -33
  19. package/dist/src/cli/init/index.js.map +1 -1
  20. package/dist/src/cli/simple-commands/init/skills-copier.js +1 -1
  21. package/dist/src/cli/simple-commands/init/skills-copier.js.map +1 -1
  22. package/dist/src/cli/simple-orchestrator.js +1 -1
  23. package/dist/src/cli/simple-orchestrator.js.map +1 -1
  24. package/dist/src/coordination/conflict-resolution.js +1 -1
  25. package/dist/src/coordination/conflict-resolution.js.map +1 -1
  26. package/dist/src/coordination/load-balancer.js +1 -1
  27. package/dist/src/coordination/load-balancer.js.map +1 -1
  28. package/dist/src/core/DatabaseManager.js +39 -9
  29. package/dist/src/core/DatabaseManager.js.map +1 -1
  30. package/dist/src/core/config.js +1 -1
  31. package/dist/src/core/config.js.map +1 -1
  32. package/dist/src/enterprise/audit-manager.js +1 -1
  33. package/dist/src/enterprise/audit-manager.js.map +1 -1
  34. package/dist/src/providers/openai-provider.js +2 -2
  35. package/dist/src/providers/openai-provider.js.map +1 -1
  36. package/dist/src/sdk/checkpoint-manager.js +1 -1
  37. package/dist/src/sdk/checkpoint-manager.js.map +1 -1
  38. package/dist/src/services/agentic-flow-hooks/workflow-hooks.js +1 -1
  39. package/dist/src/services/agentic-flow-hooks/workflow-hooks.js.map +1 -1
  40. package/dist/src/swarm/coordinator.js +1 -1
  41. package/dist/src/swarm/coordinator.js.map +1 -1
  42. package/dist/src/utils/error-recovery.js +215 -0
  43. package/dist/src/utils/error-recovery.js.map +1 -0
  44. package/dist/src/utils/key-redactor.js.map +1 -1
  45. package/dist/src/utils/metrics-reader.js +10 -0
  46. package/dist/src/verification/rollback.js +2 -2
  47. package/dist/src/verification/rollback.js.map +1 -1
  48. package/dist/src/verification/tests/mocks/false-reporting-scenarios.test.js +4 -2
  49. package/dist/src/verification/tests/mocks/false-reporting-scenarios.test.js.map +1 -1
  50. package/docs/.claude-flow/metrics/performance.json +3 -3
  51. package/docs/.claude-flow/metrics/task-metrics.json +3 -3
  52. package/docs/architecture/README.md +555 -0
  53. package/docs/architecture/github-workflows-optimization-strategy.md +1079 -0
  54. package/docs/architecture/workflow-architecture-diagram.md +615 -0
  55. package/docs/architecture/workflow-optimization-implementation-guide.md +593 -0
  56. package/docs/features/AUTOMATIC_ERROR_RECOVERY_v2.7.35.md +321 -0
  57. package/docs/features/automatic-error-recovery.md +333 -0
  58. package/docs/fixes/WORKFLOW_FIXES.md +292 -0
  59. package/docs/fixes/WORKFLOW_FIXES_FINAL_STATUS.md +291 -0
  60. package/docs/fixes/github-workflow-fixes-pr888.md +279 -0
  61. package/docs/fixes/workflow-fixes-action-plan.md +388 -0
  62. package/docs/github-issues/README.md +88 -0
  63. package/docs/github-issues/wsl-enotempty-automatic-recovery.md +470 -0
  64. package/docs/github-workflow-fixes.md +219 -0
  65. package/docs/reviews/github-workflows-analysis-report.md +820 -0
  66. package/docs/reviews/pr-888-review-report.md +560 -0
  67. package/docs/testing/CONFIRMATION_AUTOMATIC_ERROR_RECOVERY.md +384 -0
  68. package/docs/testing/DOCKER_TEST_RESULTS_v2.7.35.md +305 -0
  69. package/docs/troubleshooting/wsl-better-sqlite3-error.md +239 -0
  70. package/docs/validation/workflow-fix-verification.md +206 -0
  71. package/package.json +7 -7
  72. package/scripts/create-github-issue.sh +64 -0
  73. package/scripts/test-docker-wsl.sh +198 -0
  74. package/src/__tests__/benchmarks/performance.bench.ts +2 -25
  75. package/src/__tests__/hook-matchers.test.ts +2 -0
  76. package/src/agents/agent-registry.ts +1 -1
  77. package/src/api/auth-service.ts +1 -1
  78. package/src/api/claude-client-enhanced.ts +2 -1
  79. package/src/api/claude-client.ts +2 -2
  80. package/src/api/database-service.ts +1 -2
  81. package/src/api/swarm-api.ts +2 -2
  82. package/src/cli/commands/hive-mind/wizard.ts +1 -1
  83. package/src/cli/init/index.ts +72 -42
  84. package/src/cli/simple-commands/init/skills-copier.js +1 -1
  85. package/src/cli/simple-orchestrator.ts +1 -1
  86. package/src/coordination/conflict-resolution.ts +1 -1
  87. package/src/coordination/load-balancer.ts +1 -1
  88. package/src/core/DatabaseManager.ts +55 -9
  89. package/src/core/config.ts +1 -1
  90. package/src/enterprise/audit-manager.ts +1 -1
  91. package/src/providers/openai-provider.ts +2 -2
  92. package/src/sdk/checkpoint-manager.ts +1 -1
  93. package/src/services/agentic-flow-hooks/workflow-hooks.ts +1 -1
  94. package/src/swarm/coordinator.ts +1 -1
  95. package/src/utils/error-recovery.ts +325 -0
  96. package/src/verification/rollback.ts +2 -2
  97. package/src/verification/tests/mocks/false-reporting-scenarios.test.ts +6 -3
  98. /package/docs/{BUG_REPORT_MEMORY_STATS.md → bug-reports/BUG_REPORT_MEMORY_STATS.md} +0 -0
  99. /package/docs/{MCP_2025_FEATURE_CONFIRMATION.md → features/MCP_2025_FEATURE_CONFIRMATION.md} +0 -0
  100. /package/docs/{OPTIONAL_LOCAL_EMBEDDINGS.md → features/OPTIONAL_LOCAL_EMBEDDINGS.md} +0 -0
  101. /package/docs/{mcp-2025-implementation-summary.md → features/mcp-2025-implementation-summary.md} +0 -0
  102. /package/docs/{mcp-spec-2025-implementation-plan.md → features/mcp-spec-2025-implementation-plan.md} +0 -0
  103. /package/docs/{AGENTIC_FLOW_ENABLED_LOG_FIX.md → fixes/AGENTIC_FLOW_ENABLED_LOG_FIX.md} +0 -0
  104. /package/docs/{MEMORY_COMMAND_FIX.md → fixes/MEMORY_COMMAND_FIX.md} +0 -0
  105. /package/docs/{NPX_MEMORY_FIX_v2.7.19.md → fixes/NPX_MEMORY_FIX_v2.7.19.md} +0 -0
  106. /package/docs/{REMOTE_INSTALL_FIX.md → fixes/REMOTE_INSTALL_FIX.md} +0 -0
  107. /package/docs/{SQLITE_FIX_COMPLETE_v2.7.21.md → fixes/SQLITE_FIX_COMPLETE_v2.7.21.md} +0 -0
  108. /package/docs/{NPM_PUBLISH_GUIDE_v2.7.33.md → guides/NPM_PUBLISH_GUIDE_v2.7.33.md} +0 -0
  109. /package/docs/{SWARM_INITIALIZATION_GUIDE.md → guides/SWARM_INITIALIZATION_GUIDE.md} +0 -0
  110. /package/docs/{AGENTDB_BRANCH_MERGE_VERIFICATION.md → integration/AGENTDB_BRANCH_MERGE_VERIFICATION.md} +0 -0
  111. /package/docs/{INTEGRATION_STATUS_FINAL.md → integration/INTEGRATION_STATUS_FINAL.md} +0 -0
  112. /package/docs/{agentic-flow-agentdb-mcp-integration.md → integration/agentic-flow-agentdb-mcp-integration.md} +0 -0
  113. /package/docs/{phase-1-2-implementation-summary.md → integration/phase-1-2-implementation-summary.md} +0 -0
  114. /package/docs/{.github-release-issue-v2.7.33.md → releases/.github-release-issue-v2.7.33.md} +0 -0
  115. /package/docs/{RELEASE_NOTES_v2.7.15.md → releases/RELEASE_NOTES_v2.7.15.md} +0 -0
  116. /package/docs/{RELEASE_NOTES_v2.7.33.md → releases/RELEASE_NOTES_v2.7.33.md} +0 -0
  117. /package/docs/{RELEASE_READINESS_SUMMARY.md → releases/RELEASE_READINESS_SUMMARY.md} +0 -0
  118. /package/docs/{RELEASE_SUMMARY_v2.7.33.md → releases/RELEASE_SUMMARY_v2.7.33.md} +0 -0
  119. /package/docs/{V2.7.14_RELEASE_NOTES.md → releases/V2.7.14_RELEASE_NOTES.md} +0 -0
  120. /package/docs/{V2.7.25_RELEASE_NOTES.md → releases/V2.7.25_RELEASE_NOTES.md} +0 -0
  121. /package/docs/{V2.7.26_RELEASE_SUMMARY.md → releases/V2.7.26_RELEASE_SUMMARY.md} +0 -0
  122. /package/docs/{V2.7.27_RELEASE_NOTES.md → releases/V2.7.27_RELEASE_NOTES.md} +0 -0
  123. /package/docs/{V2.7.28_RELEASE_NOTES.md → releases/V2.7.28_RELEASE_NOTES.md} +0 -0
  124. /package/docs/{AGENTIC_FLOW_INTEGRATION_REVIEW.md → reviews/AGENTIC_FLOW_INTEGRATION_REVIEW.md} +0 -0
  125. /package/docs/{BRANCH_REVIEW_SUMMARY.md → reviews/BRANCH_REVIEW_SUMMARY.md} +0 -0
  126. /package/docs/{DEEP_CODE_REVIEW_v2.7.33.md → reviews/DEEP_CODE_REVIEW_v2.7.33.md} +0 -0
  127. /package/docs/{LATEST_LIBRARIES_REVIEW.md → reviews/LATEST_LIBRARIES_REVIEW.md} +0 -0
  128. /package/docs/{REGRESSION_TEST_REPORT_v2.7.33.md → testing/REGRESSION_TEST_REPORT_v2.7.33.md} +0 -0
  129. /package/docs/{V2.7.27_TEST_REPORT.md → testing/V2.7.27_TEST_REPORT.md} +0 -0
  130. /package/docs/{regression-analysis-phase-1-2.md → testing/regression-analysis-phase-1-2.md} +0 -0
  131. /package/docs/{TRANSFORMER_INITIALIZATION_ISSUE.md → troubleshooting/TRANSFORMER_INITIALIZATION_ISSUE.md} +0 -0
  132. /package/docs/{FIX_VERIFICATION_MEMORY_STATS.md → validation/FIX_VERIFICATION_MEMORY_STATS.md} +0 -0
  133. /package/docs/{TOOL_VALIDATION_REPORT.md → validation/TOOL_VALIDATION_REPORT.md} +0 -0
  134. /package/docs/{VALIDATION_REPORT_v2.7.1.md → validation/VALIDATION_REPORT_v2.7.1.md} +0 -0
@@ -593,7 +593,7 @@ function applyStepOptimizations(
593
593
  state: any,
594
594
  optimizations: any[]
595
595
  ): any {
596
- let optimizedState = { ...state };
596
+ const optimizedState = { ...state };
597
597
 
598
598
  for (const opt of optimizations) {
599
599
  switch (opt.type) {
@@ -1064,7 +1064,7 @@ export class SwarmCoordinator extends EventEmitter implements SwarmEventEmitter
1064
1064
  private calculateCapabilityMatch(agent: AgentState, task: TaskDefinition): number {
1065
1065
  const requiredCapabilities = task.requirements.capabilities;
1066
1066
  let matches = 0;
1067
- let total = requiredCapabilities.length;
1067
+ const total = requiredCapabilities.length;
1068
1068
 
1069
1069
  for (const capability of requiredCapabilities) {
1070
1070
  if (this.agentHasCapability(agent, capability)) {
@@ -0,0 +1,325 @@
1
+ /**
2
+ * Error Recovery Utilities
3
+ * Automatic error detection and recovery for common installation issues
4
+ */
5
+
6
+ import { execSync } from 'child_process';
7
+ import * as fs from 'fs-extra';
8
+ import * as path from 'path';
9
+ import * as os from 'os';
10
+
11
+ export interface RecoveryResult {
12
+ success: boolean;
13
+ action: string;
14
+ message: string;
15
+ recovered: boolean;
16
+ }
17
+
18
+ export interface RetryOptions {
19
+ maxRetries?: number;
20
+ delay?: number;
21
+ onRetry?: (attempt: number, error: Error) => void;
22
+ cleanupFn?: () => Promise<void>;
23
+ }
24
+
25
+ /**
26
+ * Detect if an error is the ENOTEMPTY npm cache error
27
+ */
28
+ export function isNpmCacheError(error: any): boolean {
29
+ const errorStr = error?.message || String(error);
30
+ return (
31
+ errorStr.includes('ENOTEMPTY') &&
32
+ (errorStr.includes('npm') || errorStr.includes('npx') || errorStr.includes('_npx'))
33
+ ) || errorStr.includes('better-sqlite3');
34
+ }
35
+
36
+ /**
37
+ * Detect if running on WSL (Windows Subsystem for Linux)
38
+ */
39
+ export function isWSL(): boolean {
40
+ if (process.platform !== 'linux') {
41
+ return false;
42
+ }
43
+
44
+ try {
45
+ const release = fs.readFileSync('/proc/version', 'utf8').toLowerCase();
46
+ return release.includes('microsoft') || release.includes('wsl');
47
+ } catch {
48
+ return false;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Clean npm and npx cache directories
54
+ */
55
+ export async function cleanNpmCache(): Promise<RecoveryResult> {
56
+ const homeDir = os.homedir();
57
+ const npxCacheDir = path.join(homeDir, '.npm', '_npx');
58
+
59
+ try {
60
+ console.log('🧹 Cleaning npm cache...');
61
+
62
+ // Clean npm cache
63
+ try {
64
+ execSync('npm cache clean --force', { stdio: 'pipe' });
65
+ console.log('✅ npm cache cleaned');
66
+ } catch (error) {
67
+ console.warn('⚠️ npm cache clean failed, continuing...');
68
+ }
69
+
70
+ // Remove npx cache directory
71
+ if (await fs.pathExists(npxCacheDir)) {
72
+ console.log(`🗑️ Removing npx cache: ${npxCacheDir}`);
73
+ await fs.remove(npxCacheDir);
74
+ console.log('✅ npx cache removed');
75
+ }
76
+
77
+ // Fix permissions on WSL
78
+ if (isWSL()) {
79
+ const npmDir = path.join(homeDir, '.npm');
80
+ if (await fs.pathExists(npmDir)) {
81
+ try {
82
+ execSync(`chmod -R 755 "${npmDir}"`, { stdio: 'pipe' });
83
+ console.log('✅ npm directory permissions fixed');
84
+ } catch (error) {
85
+ console.warn('⚠️ Permission fix failed, continuing...');
86
+ }
87
+ }
88
+ }
89
+
90
+ return {
91
+ success: true,
92
+ action: 'cache-cleanup',
93
+ message: 'npm/npx cache cleaned successfully',
94
+ recovered: true
95
+ };
96
+ } catch (error) {
97
+ return {
98
+ success: false,
99
+ action: 'cache-cleanup',
100
+ message: `Failed to clean cache: ${error instanceof Error ? error.message : String(error)}`,
101
+ recovered: false
102
+ };
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Automatic retry with exponential backoff and error recovery
108
+ */
109
+ export async function retryWithRecovery<T>(
110
+ fn: () => Promise<T>,
111
+ options: RetryOptions = {}
112
+ ): Promise<T> {
113
+ const {
114
+ maxRetries = 3,
115
+ delay = 1000,
116
+ onRetry,
117
+ cleanupFn
118
+ } = options;
119
+
120
+ let lastError: Error | undefined;
121
+
122
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
123
+ try {
124
+ return await fn();
125
+ } catch (error) {
126
+ lastError = error as Error;
127
+
128
+ // Check if it's a recoverable error
129
+ if (isNpmCacheError(error)) {
130
+ console.log(`\n⚠️ Detected npm cache error (attempt ${attempt}/${maxRetries})`);
131
+
132
+ // Attempt automatic recovery
133
+ const recovery = await cleanNpmCache();
134
+ if (recovery.success) {
135
+ console.log('✅ Cache cleaned, retrying...\n');
136
+
137
+ // Run custom cleanup if provided
138
+ if (cleanupFn) {
139
+ await cleanupFn();
140
+ }
141
+
142
+ // Exponential backoff
143
+ const backoffDelay = delay * Math.pow(2, attempt - 1);
144
+ await new Promise(resolve => setTimeout(resolve, backoffDelay));
145
+
146
+ continue; // Retry
147
+ } else {
148
+ console.error('❌ Cache cleanup failed:', recovery.message);
149
+ }
150
+ }
151
+
152
+ // Call retry callback
153
+ if (onRetry && attempt < maxRetries) {
154
+ onRetry(attempt, lastError);
155
+ await new Promise(resolve => setTimeout(resolve, delay));
156
+ continue;
157
+ }
158
+
159
+ // Last attempt failed
160
+ if (attempt === maxRetries) {
161
+ break;
162
+ }
163
+ }
164
+ }
165
+
166
+ // All retries exhausted
167
+ throw new Error(
168
+ `Operation failed after ${maxRetries} attempts. ` +
169
+ `Last error: ${lastError?.message || 'Unknown error'}`
170
+ );
171
+ }
172
+
173
+ /**
174
+ * WSL-specific error recovery
175
+ */
176
+ export async function recoverWSLErrors(): Promise<RecoveryResult> {
177
+ if (!isWSL()) {
178
+ return {
179
+ success: true,
180
+ action: 'wsl-check',
181
+ message: 'Not running on WSL, no recovery needed',
182
+ recovered: false
183
+ };
184
+ }
185
+
186
+ console.log('🔍 Detected WSL environment, applying fixes...');
187
+
188
+ try {
189
+ const homeDir = os.homedir();
190
+
191
+ // Check if running from Windows mount
192
+ const cwd = process.cwd();
193
+ if (cwd.startsWith('/mnt/')) {
194
+ console.warn('⚠️ WARNING: Running from Windows filesystem (/mnt/)');
195
+ console.warn(' For best results, run from WSL filesystem (e.g., ~/projects/)');
196
+ }
197
+
198
+ // Ensure build tools are available
199
+ try {
200
+ execSync('which gcc', { stdio: 'pipe' });
201
+ } catch {
202
+ console.warn('⚠️ build-essential not found. Install with:');
203
+ console.warn(' sudo apt-get update && sudo apt-get install -y build-essential python3');
204
+ }
205
+
206
+ // Clean cache with WSL-specific handling
207
+ return await cleanNpmCache();
208
+ } catch (error) {
209
+ return {
210
+ success: false,
211
+ action: 'wsl-recovery',
212
+ message: `WSL recovery failed: ${error instanceof Error ? error.message : String(error)}`,
213
+ recovered: false
214
+ };
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Verify better-sqlite3 installation
220
+ */
221
+ export async function verifyBetterSqlite3(): Promise<boolean> {
222
+ try {
223
+ require.resolve('better-sqlite3');
224
+ return true;
225
+ } catch {
226
+ return false;
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Install better-sqlite3 with retry and error recovery
232
+ */
233
+ export async function installBetterSqlite3WithRecovery(): Promise<RecoveryResult> {
234
+ console.log('📦 Installing better-sqlite3...');
235
+
236
+ return retryWithRecovery(
237
+ async () => {
238
+ execSync('npm install better-sqlite3 --no-save', {
239
+ stdio: 'inherit',
240
+ cwd: process.cwd()
241
+ });
242
+
243
+ // Verify installation
244
+ if (await verifyBetterSqlite3()) {
245
+ return {
246
+ success: true,
247
+ action: 'install-sqlite',
248
+ message: 'better-sqlite3 installed successfully',
249
+ recovered: true
250
+ };
251
+ } else {
252
+ throw new Error('Installation completed but module not found');
253
+ }
254
+ },
255
+ {
256
+ maxRetries: 3,
257
+ delay: 2000,
258
+ onRetry: (attempt, error) => {
259
+ console.log(`⚠️ Install attempt ${attempt} failed: ${error.message}`);
260
+ console.log('🔄 Cleaning cache and retrying...');
261
+ }
262
+ }
263
+ );
264
+ }
265
+
266
+ /**
267
+ * Comprehensive error recovery for initialization
268
+ */
269
+ export async function recoverInitErrors(error: any): Promise<RecoveryResult> {
270
+ console.log('\n🚨 Error detected during initialization');
271
+ console.log(` Error: ${error?.message || String(error)}\n`);
272
+
273
+ // WSL-specific recovery
274
+ if (isWSL()) {
275
+ console.log('🔧 Applying WSL-specific fixes...');
276
+ const wslRecovery = await recoverWSLErrors();
277
+ if (!wslRecovery.success) {
278
+ return wslRecovery;
279
+ }
280
+ }
281
+
282
+ // npm cache error recovery
283
+ if (isNpmCacheError(error)) {
284
+ console.log('🔧 Detected npm cache error, attempting recovery...');
285
+ const cacheRecovery = await cleanNpmCache();
286
+ if (!cacheRecovery.success) {
287
+ return cacheRecovery;
288
+ }
289
+
290
+ // Try to reinstall better-sqlite3
291
+ if (!await verifyBetterSqlite3()) {
292
+ console.log('🔧 better-sqlite3 missing, attempting reinstall...');
293
+ return await installBetterSqlite3WithRecovery();
294
+ }
295
+
296
+ return {
297
+ success: true,
298
+ action: 'error-recovery',
299
+ message: 'Cache cleaned and dependencies verified',
300
+ recovered: true
301
+ };
302
+ }
303
+
304
+ // Generic error handling
305
+ return {
306
+ success: false,
307
+ action: 'error-recovery',
308
+ message: `Unable to automatically recover from error: ${error?.message || String(error)}`,
309
+ recovered: false
310
+ };
311
+ }
312
+
313
+ /**
314
+ * Export utility functions
315
+ */
316
+ export const errorRecovery = {
317
+ isNpmCacheError,
318
+ isWSL,
319
+ cleanNpmCache,
320
+ retryWithRecovery,
321
+ recoverWSLErrors,
322
+ verifyBetterSqlite3,
323
+ installBetterSqlite3WithRecovery,
324
+ recoverInitErrors
325
+ };
@@ -445,7 +445,7 @@ export class StateManager extends EventEmitter {
445
445
  const filename = `${snapshot.id}.snapshot.json`;
446
446
  const filepath = join(this.snapshotDir, filename);
447
447
 
448
- let content = JSON.stringify(snapshot, null, 2);
448
+ const content = JSON.stringify(snapshot, null, 2);
449
449
 
450
450
  if (this.compressionEnabled) {
451
451
  const compressed = await gzipAsync(Buffer.from(content, 'utf-8'));
@@ -1298,7 +1298,7 @@ export class RollbackHistory extends EventEmitter {
1298
1298
  const filename = `${entry.id}.history.json`;
1299
1299
  const filepath = join(this.historyDir, filename);
1300
1300
 
1301
- let content = JSON.stringify(entry, null, 2);
1301
+ const content = JSON.stringify(entry, null, 2);
1302
1302
 
1303
1303
  if (this.compressionEnabled) {
1304
1304
  const compressed = await gzipAsync(Buffer.from(content, 'utf-8'));
@@ -16,7 +16,10 @@ import * as path from 'path';
16
16
  import * as os from 'os';
17
17
 
18
18
  // Import verification components
19
- import TruthScoreCalculator from '../../../../.claude/helpers/truth-score.js';
19
+ // Dynamic import for CommonJS module
20
+ import { createRequire } from 'module';
21
+ const require = createRequire(import.meta.url);
22
+ const TruthScoreCalc = require('../../../../.claude/helpers/truth-score.js');
20
23
 
21
24
  interface MockAgent {
22
25
  id: string;
@@ -86,9 +89,9 @@ describe('False Reporting Detection Scenarios', () => {
86
89
 
87
90
  beforeEach(async () => {
88
91
  tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'false-reporting-test-'));
89
-
92
+
90
93
  // Setup truth score calculator
91
- truthCalculator = new TruthScoreCalculator();
94
+ truthCalculator = new TruthScoreCalc();
92
95
  truthCalculator.configPath = path.join(tempDir, 'verification.json');
93
96
  truthCalculator.memoryPath = path.join(tempDir, 'truth-scores');
94
97
  await truthCalculator.init();