claude-flow 2.7.33 → 2.7.35

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 (99) hide show
  1. package/.claude/settings.local.json +9 -2
  2. package/.claude/skills/agentic-jujutsu/SKILL.md +1 -1
  3. package/CHANGELOG.md +140 -0
  4. package/bin/claude-flow +1 -1
  5. package/dist/src/cli/commands/mcp.js +61 -7
  6. package/dist/src/cli/commands/mcp.js.map +1 -1
  7. package/dist/src/cli/init/index.js +55 -33
  8. package/dist/src/cli/init/index.js.map +1 -1
  9. package/dist/src/cli/simple-cli.js +182 -172
  10. package/dist/src/cli/simple-cli.js.map +1 -1
  11. package/dist/src/cli/simple-commands/init/agent-copier.js +9 -3
  12. package/dist/src/cli/simple-commands/init/agent-copier.js.map +1 -1
  13. package/dist/src/core/DatabaseManager.js +39 -9
  14. package/dist/src/core/DatabaseManager.js.map +1 -1
  15. package/dist/src/mcp/async/job-manager-mcp25.js +240 -0
  16. package/dist/src/mcp/async/job-manager-mcp25.js.map +1 -0
  17. package/dist/src/mcp/index.js +8 -0
  18. package/dist/src/mcp/index.js.map +1 -1
  19. package/dist/src/mcp/protocol/version-negotiation.js +182 -0
  20. package/dist/src/mcp/protocol/version-negotiation.js.map +1 -0
  21. package/dist/src/mcp/registry/mcp-registry-client-2025.js +210 -0
  22. package/dist/src/mcp/registry/mcp-registry-client-2025.js.map +1 -0
  23. package/dist/src/mcp/server-factory.js +189 -0
  24. package/dist/src/mcp/server-factory.js.map +1 -0
  25. package/dist/src/mcp/server-mcp-2025.js +283 -0
  26. package/dist/src/mcp/server-mcp-2025.js.map +1 -0
  27. package/dist/src/mcp/tool-registry-progressive.js +319 -0
  28. package/dist/src/mcp/tool-registry-progressive.js.map +1 -0
  29. package/dist/src/mcp/tools/_template.js +62 -0
  30. package/dist/src/mcp/tools/_template.js.map +1 -0
  31. package/dist/src/mcp/tools/loader.js +228 -0
  32. package/dist/src/mcp/tools/loader.js.map +1 -0
  33. package/dist/src/mcp/tools/system/search.js +224 -0
  34. package/dist/src/mcp/tools/system/search.js.map +1 -0
  35. package/dist/src/mcp/tools/system/status.js +168 -0
  36. package/dist/src/mcp/tools/system/status.js.map +1 -0
  37. package/dist/src/mcp/validation/schema-validator-2025.js +198 -0
  38. package/dist/src/mcp/validation/schema-validator-2025.js.map +1 -0
  39. package/dist/src/utils/error-recovery.js +215 -0
  40. package/dist/src/utils/error-recovery.js.map +1 -0
  41. package/dist/src/utils/metrics-reader.js +10 -0
  42. package/dist/src/utils/metrics-reader.js.map +1 -1
  43. package/docs/.claude-flow/metrics/performance.json +3 -3
  44. package/docs/.claude-flow/metrics/task-metrics.json +3 -3
  45. package/docs/.github-release-issue-v2.7.33.md +488 -0
  46. package/docs/AGENTDB_BRANCH_MERGE_VERIFICATION.md +436 -0
  47. package/docs/AUTOMATIC_ERROR_RECOVERY_v2.7.35.md +321 -0
  48. package/docs/BRANCH_REVIEW_SUMMARY.md +439 -0
  49. package/docs/CONFIRMATION_AUTOMATIC_ERROR_RECOVERY.md +384 -0
  50. package/docs/DEEP_CODE_REVIEW_v2.7.33.md +1159 -0
  51. package/docs/DOCKER_TEST_RESULTS_v2.7.35.md +305 -0
  52. package/docs/MCP_2025_FEATURE_CONFIRMATION.md +698 -0
  53. package/docs/NPM_PUBLISH_GUIDE_v2.7.33.md +628 -0
  54. package/docs/REGRESSION_TEST_REPORT_v2.7.33.md +397 -0
  55. package/docs/RELEASE_NOTES_v2.7.33.md +618 -0
  56. package/docs/RELEASE_READINESS_SUMMARY.md +377 -0
  57. package/docs/RELEASE_SUMMARY_v2.7.33.md +456 -0
  58. package/docs/agentic-flow-agentdb-mcp-integration.md +1198 -0
  59. package/docs/features/automatic-error-recovery.md +333 -0
  60. package/docs/github-issues/README.md +88 -0
  61. package/docs/github-issues/wsl-enotempty-automatic-recovery.md +470 -0
  62. package/docs/mcp-2025-implementation-summary.md +459 -0
  63. package/docs/mcp-spec-2025-implementation-plan.md +1330 -0
  64. package/docs/phase-1-2-implementation-summary.md +676 -0
  65. package/docs/regression-analysis-phase-1-2.md +555 -0
  66. package/docs/troubleshooting/wsl-better-sqlite3-error.md +239 -0
  67. package/package.json +5 -2
  68. package/scripts/create-github-issue.sh +64 -0
  69. package/scripts/test-docker-wsl.sh +198 -0
  70. package/src/cli/commands/mcp.ts +86 -9
  71. package/src/cli/init/index.ts +72 -42
  72. package/src/cli/simple-commands/init/agent-copier.js +10 -5
  73. package/src/core/DatabaseManager.ts +55 -9
  74. package/src/mcp/async/job-manager-mcp25.ts +456 -0
  75. package/src/mcp/index.ts +60 -0
  76. package/src/mcp/protocol/version-negotiation.ts +329 -0
  77. package/src/mcp/registry/mcp-registry-client-2025.ts +334 -0
  78. package/src/mcp/server-factory.ts +426 -0
  79. package/src/mcp/server-mcp-2025.ts +507 -0
  80. package/src/mcp/tool-registry-progressive.ts +539 -0
  81. package/src/mcp/tools/_template.ts +174 -0
  82. package/src/mcp/tools/loader.ts +362 -0
  83. package/src/mcp/tools/system/search.ts +276 -0
  84. package/src/mcp/tools/system/status.ts +206 -0
  85. package/src/mcp/validation/schema-validator-2025.ts +294 -0
  86. package/src/utils/error-recovery.ts +325 -0
  87. package/docs/AGENTDB_V1.6.1_DEEP_REVIEW.md +0 -386
  88. package/docs/AGENT_FOLDER_STRUCTURE_FIX.md +0 -192
  89. package/docs/RECENT_RELEASES_SUMMARY.md +0 -375
  90. package/docs/V2.7.31_RELEASE_NOTES.md +0 -375
  91. /package/.claude/agents/analysis/{analyze-code-quality.md → code-review/analyze-code-quality.md} +0 -0
  92. /package/.claude/agents/architecture/{arch-system-design.md → system-design/arch-system-design.md} +0 -0
  93. /package/.claude/agents/data/{data-ml-model.md → ml/data-ml-model.md} +0 -0
  94. /package/.claude/agents/development/{dev-backend-api.md → backend/dev-backend-api.md} +0 -0
  95. /package/.claude/agents/devops/{ops-cicd-github.md → ci-cd/ops-cicd-github.md} +0 -0
  96. /package/.claude/agents/documentation/{docs-api-openapi.md → api-docs/docs-api-openapi.md} +0 -0
  97. /package/.claude/agents/specialized/{spec-mobile-react-native.md → mobile/spec-mobile-react-native.md} +0 -0
  98. /package/.claude/agents/testing/{tdd-london-swarm.md → unit/tdd-london-swarm.md} +0 -0
  99. /package/.claude/agents/testing/{production-validator.md → validation/production-validator.md} +0 -0
@@ -0,0 +1,321 @@
1
+ # Automatic Error Recovery Implementation - v2.7.35
2
+
3
+ ## Summary
4
+
5
+ Implemented comprehensive automatic error recovery system for `claude-flow init` that handles the WSL better-sqlite3 ENOTEMPTY error **without manual intervention**.
6
+
7
+ ## Changes Made
8
+
9
+ ### 1. New Error Recovery Utility (`src/utils/error-recovery.ts`)
10
+
11
+ **Features:**
12
+ - ✅ Automatic ENOTEMPTY npm cache error detection
13
+ - ✅ WSL environment detection and optimization
14
+ - ✅ Automatic npm/npx cache cleanup
15
+ - ✅ Retry logic with exponential backoff (1s, 2s, 4s, 8s, 16s)
16
+ - ✅ Permission fixes for WSL environments
17
+ - ✅ better-sqlite3 verification and reinstallation
18
+
19
+ **Key Functions:**
20
+ ```typescript
21
+ - isNpmCacheError(error): boolean
22
+ - isWSL(): boolean
23
+ - cleanNpmCache(): Promise<RecoveryResult>
24
+ - retryWithRecovery<T>(fn, options): Promise<T>
25
+ - recoverWSLErrors(): Promise<RecoveryResult>
26
+ - recoverInitErrors(error): Promise<RecoveryResult>
27
+ ```
28
+
29
+ ### 2. Enhanced DatabaseManager (`src/core/DatabaseManager.ts`)
30
+
31
+ **Improvements:**
32
+ - Added `initializeSQLiteWithRecovery()` method
33
+ - Automatic fallback from SQLite to JSON on errors
34
+ - Retry counter (max 3 attempts per provider)
35
+ - Enhanced error logging with recovery suggestions
36
+
37
+ **Flow:**
38
+ ```
39
+ Try SQLite → Error? → Warn + Fallback to JSON
40
+ Initialize → Error? → Retry with JSON (3x max)
41
+ ```
42
+
43
+ ### 3. Updated Init Command (`src/cli/init/index.ts`)
44
+
45
+ **Enhanced with:**
46
+ - Wrapped entire initialization in `retryWithRecovery()`
47
+ - Proactive WSL detection and optimization
48
+ - Automatic cache cleanup on npm errors
49
+ - Extended retry count with `--force` flag (5 attempts vs 3)
50
+ - Comprehensive error recovery logging
51
+
52
+ **User Experience:**
53
+ ```bash
54
+ npx claude-flow@alpha init --force
55
+
56
+ 🔍 WSL environment detected
57
+ ✅ WSL environment optimized
58
+
59
+ ⚠️ Detected npm cache error (attempt 1/5)
60
+ 🧹 Cleaning npm cache...
61
+ ✅ Cache cleaned, retrying...
62
+
63
+ 🔄 Retry attempt 1 after error recovery...
64
+ 🎉 Project initialized successfully!
65
+ ```
66
+
67
+ ### 4. Test Coverage (`tests/unit/utils/error-recovery.test.ts`)
68
+
69
+ **Tests:**
70
+ - ✅ ENOTEMPTY error detection
71
+ - ✅ better-sqlite3 error detection
72
+ - ✅ WSL environment detection
73
+ - ✅ Retry logic with success
74
+ - ✅ Max retry handling
75
+ - ✅ onRetry callback execution
76
+ - ✅ Cache cleanup functionality
77
+ - ✅ Init error recovery
78
+
79
+ ### 5. Documentation
80
+
81
+ **Created/Updated:**
82
+ - ✅ `docs/features/automatic-error-recovery.md` - Comprehensive guide
83
+ - ✅ `docs/troubleshooting/wsl-better-sqlite3-error.md` - Updated with auto-recovery info
84
+ - ✅ `docs/AUTOMATIC_ERROR_RECOVERY_v2.7.35.md` - This document
85
+
86
+ ## How It Works
87
+
88
+ ### Before (Manual Fix Required)
89
+
90
+ ```bash
91
+ $ npx claude-flow@alpha init --force
92
+ [Error: ENOTEMPTY: directory not empty, rmdir '/home/user/.npm/_npx/xxx/node_modules/better-sqlite3']
93
+
94
+ # User had to manually:
95
+ $ npm cache clean --force
96
+ $ rm -rf ~/.npm/_npx
97
+ $ npx claude-flow@alpha init --force # Try again
98
+ ```
99
+
100
+ ### After (Automatic Recovery)
101
+
102
+ ```bash
103
+ $ npx claude-flow@alpha init --force
104
+
105
+ 🔍 WSL environment detected
106
+ ✅ WSL environment optimized
107
+
108
+ 📁 Phase 1: Creating directory structure...
109
+ ⚠️ Detected npm cache error (attempt 1/5)
110
+ 🧹 Cleaning npm cache...
111
+ ✅ npm cache cleaned
112
+ 🗑️ Removing npx cache: /home/user/.npm/_npx
113
+ ✅ npx cache removed
114
+ ✅ Cache cleaned, retrying...
115
+
116
+ 🔄 Retry attempt 1 after error recovery...
117
+ 📁 Phase 1: Creating directory structure...
118
+ 🎉 Project initialized successfully!
119
+
120
+ # No manual intervention needed!
121
+ ```
122
+
123
+ ## Recovery Strategies
124
+
125
+ ### 1. npm Cache Errors
126
+
127
+ ```typescript
128
+ if (isNpmCacheError(error)) {
129
+ 1. Run `npm cache clean --force`
130
+ 2. Remove `~/.npm/_npx` directory
131
+ 3. Fix permissions (WSL: `chmod -R 755 ~/.npm`)
132
+ 4. Retry with exponential backoff
133
+ }
134
+ ```
135
+
136
+ ### 2. WSL Environment
137
+
138
+ ```typescript
139
+ if (isWSL()) {
140
+ 1. Detect running from `/mnt/c/` (Windows mount) → Warn user
141
+ 2. Check for build tools (gcc, python3) → Suggest install
142
+ 3. Apply permission fixes
143
+ 4. Clean cache with WSL-specific handling
144
+ }
145
+ ```
146
+
147
+ ### 3. Database Initialization
148
+
149
+ ```typescript
150
+ if (sqliteInitFails) {
151
+ 1. Try SQLite with recovery
152
+ 2. On error → Warn user
153
+ 3. Fallback to JSON provider
154
+ 4. Retry initialization (3x max)
155
+ 5. Success → Continue with JSON storage
156
+ }
157
+ ```
158
+
159
+ ### 4. better-sqlite3 Issues
160
+
161
+ ```typescript
162
+ if (!better-sqlite3Available) {
163
+ 1. Attempt reinstall with retry
164
+ 2. Clean cache before each retry
165
+ 3. Verify installation after each attempt
166
+ 4. Max 3 retries with exponential backoff
167
+ 5. Fallback to JSON if all fail
168
+ }
169
+ ```
170
+
171
+ ## Configuration
172
+
173
+ ### Retry Options
174
+
175
+ ```typescript
176
+ interface RetryOptions {
177
+ maxRetries?: number; // 3 (normal) or 5 (--force)
178
+ delay?: number; // 1000ms initial delay
179
+ onRetry?: (attempt, error) => void;
180
+ cleanupFn?: () => Promise<void>;
181
+ }
182
+ ```
183
+
184
+ ### Recovery Result
185
+
186
+ ```typescript
187
+ interface RecoveryResult {
188
+ success: boolean; // Recovery succeeded?
189
+ action: string; // Action taken
190
+ message: string; // User-friendly message
191
+ recovered: boolean; // Was recovery needed?
192
+ }
193
+ ```
194
+
195
+ ## Testing Checklist
196
+
197
+ - [ ] Test on Ubuntu WSL2
198
+ - [ ] Test on Debian WSL2
199
+ - [ ] Test with ENOTEMPTY error simulation
200
+ - [ ] Test with missing better-sqlite3
201
+ - [ ] Test from `/mnt/c/` (Windows filesystem)
202
+ - [ ] Test from `~/` (WSL filesystem)
203
+ - [ ] Test with `--force` flag
204
+ - [ ] Test without `--force` flag
205
+ - [ ] Test cache cleanup functionality
206
+ - [ ] Test SQLite → JSON fallback
207
+ - [ ] Test max retry exhaustion
208
+ - [ ] Test successful recovery after 1 retry
209
+ - [ ] Test successful recovery after multiple retries
210
+
211
+ ## Docker Testing
212
+
213
+ ### Dockerfile for Testing
214
+
215
+ ```dockerfile
216
+ FROM ubuntu:22.04
217
+
218
+ # Install Node.js and build tools
219
+ RUN apt-get update && apt-get install -y \
220
+ curl \
221
+ build-essential \
222
+ python3 \
223
+ git
224
+
225
+ # Install Node.js 20
226
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
227
+ apt-get install -y nodejs
228
+
229
+ # Create test user
230
+ RUN useradd -m -s /bin/bash testuser
231
+ USER testuser
232
+ WORKDIR /home/testuser
233
+
234
+ # Test command
235
+ CMD npx claude-flow@alpha init --force
236
+ ```
237
+
238
+ ### Test Commands
239
+
240
+ ```bash
241
+ # Build test image
242
+ docker build -t claude-flow-test -f Dockerfile.test .
243
+
244
+ # Run test
245
+ docker run -it claude-flow-test
246
+
247
+ # Test with volume mount
248
+ docker run -it -v $(pwd):/workspace -w /workspace claude-flow-test
249
+
250
+ # Simulate WSL environment
251
+ docker run -it -e SIMULATE_WSL=1 claude-flow-test
252
+ ```
253
+
254
+ ## Rollout Plan
255
+
256
+ ### Phase 1: Internal Testing
257
+ - [ ] Unit tests pass
258
+ - [ ] Integration tests pass
259
+ - [ ] Docker tests pass
260
+ - [ ] WSL manual testing
261
+
262
+ ### Phase 2: Beta Release
263
+ - [ ] Release as v2.7.35-beta.1
264
+ - [ ] Gather feedback from WSL users
265
+ - [ ] Monitor error rates
266
+ - [ ] Collect recovery metrics
267
+
268
+ ### Phase 3: Production Release
269
+ - [ ] Release as v2.7.35
270
+ - [ ] Update documentation
271
+ - [ ] Announce on GitHub
272
+ - [ ] Close related issues
273
+
274
+ ## Metrics to Track
275
+
276
+ ```typescript
277
+ // Recovery success rate
278
+ const recoveryMetrics = {
279
+ totalErrors: 0,
280
+ recoveredErrors: 0,
281
+ successRate: 0,
282
+ avgRetries: 0,
283
+ cacheCleanups: 0,
284
+ wslOptimizations: 0,
285
+ sqliteToJsonFallbacks: 0
286
+ };
287
+ ```
288
+
289
+ ## Known Limitations
290
+
291
+ 1. **Cannot fix all errors**: Some errors (disk full, permissions) may not be recoverable
292
+ 2. **Requires network**: npm cache operations need internet access
293
+ 3. **WSL1 limitations**: WSL1 has more filesystem issues than WSL2
294
+ 4. **Build tools**: better-sqlite3 requires gcc/python3 (auto-detects and warns)
295
+
296
+ ## Future Enhancements
297
+
298
+ 1. **Telemetry**: Track recovery success rates
299
+ 2. **Smart caching**: Detect when cache cleanup is needed proactively
300
+ 3. **Pre-flight checks**: Verify environment before initialization
301
+ 4. **Better diagnostics**: Detailed error reports for unrecoverable issues
302
+ 5. **Parallel recovery**: Try multiple recovery strategies simultaneously
303
+
304
+ ## Related Issues
305
+
306
+ Closes:
307
+ - Issue #XXX: WSL better-sqlite3 ENOTEMPTY error
308
+ - Issue #XXX: npm cache corruption during init
309
+ - Issue #XXX: Improve error handling for initialization
310
+
311
+ ## References
312
+
313
+ - [better-sqlite3 Documentation](https://github.com/WiseLibs/better-sqlite3)
314
+ - [npm cache Documentation](https://docs.npmjs.com/cli/v9/commands/npm-cache)
315
+ - [WSL Issues Tracker](https://github.com/microsoft/WSL/issues)
316
+ - [Node.js Error Codes](https://nodejs.org/api/errors.html)
317
+
318
+ ---
319
+
320
+ **Status**: ✅ Implementation Complete - Ready for Testing
321
+ **Next**: Docker validation and beta release