claude-flow-novice 2.2.4 → 2.2.5

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 (288) hide show
  1. package/package.json +9 -8
  2. package/scripts/.claude-flow/metrics/agent-metrics.json +1 -0
  3. package/scripts/.claude-flow/metrics/performance.json +9 -0
  4. package/scripts/.claude-flow/metrics/task-metrics.json +10 -0
  5. package/scripts/CLEANUP_OPTIMIZATION_REPORT.json +312 -0
  6. package/scripts/CLEANUP_PERFORMANCE_OPTIMIZATION.md +387 -0
  7. package/scripts/CLEANUP_QUICK_START.md +268 -0
  8. package/scripts/CLEANUP_TEST_RESULTS.md +205 -0
  9. package/scripts/README.md +339 -0
  10. package/scripts/ace-query.sh +384 -0
  11. package/scripts/agent-token-analysis.js +430 -0
  12. package/scripts/auto-setup.js +332 -0
  13. package/scripts/build/README.md +167 -0
  14. package/scripts/build/build-config.js +27 -0
  15. package/scripts/build/build-prompt-copier.sh +30 -0
  16. package/scripts/build/performance-monitor.js +869 -0
  17. package/scripts/build/prepare-publish.js +150 -0
  18. package/scripts/build/typescript-fixer.js +621 -0
  19. package/scripts/build/unified-builder.sh +428 -0
  20. package/scripts/build/update-bin-version.js +32 -0
  21. package/scripts/build/validate-agents.js +238 -0
  22. package/scripts/build-index.js +43 -0
  23. package/scripts/build-orchestrator.js +320 -0
  24. package/scripts/check-routing-stats.cjs +122 -0
  25. package/scripts/ci-validation.js +375 -0
  26. package/scripts/cleanup-blocking-coordination.sh +420 -0
  27. package/scripts/cleanup-idle-sessions.sh +59 -0
  28. package/scripts/collect-build-metrics.js +65 -0
  29. package/scripts/demo/README.md +79 -0
  30. package/scripts/demo/autoscaling-demo-simplified.js +963 -0
  31. package/scripts/demo/comprehensive-dashboard-test.js +693 -0
  32. package/scripts/demo/confidence-log.js +87 -0
  33. package/scripts/demo/confidence-report.js +82 -0
  34. package/scripts/demo/demo-multi-swarm-coordination.js +325 -0
  35. package/scripts/demo/demo-production-deployment.js +399 -0
  36. package/scripts/demo/demo-visualization-system.js +149 -0
  37. package/scripts/demo/performance-analysis.cjs +71 -0
  38. package/scripts/demo/performance-analysis.js +71 -0
  39. package/scripts/demo/test-autoscaling-demo.js +314 -0
  40. package/scripts/dependency-optimizer.js +349 -0
  41. package/scripts/dependency-security-assessment.js +331 -0
  42. package/scripts/deploy-sdk.sh +176 -0
  43. package/scripts/deployment-readiness-report.json +179 -0
  44. package/scripts/dev/README.md +264 -0
  45. package/scripts/dev/claude-flow-wrapper.sh +35 -0
  46. package/scripts/dev/claude-monitor.py +419 -0
  47. package/scripts/dev/claude-sparc.sh +562 -0
  48. package/scripts/dev/claude-wrapper.sh +17 -0
  49. package/scripts/dev/demo-phase3-compliance.js +172 -0
  50. package/scripts/dev/demo-task-system.ts +224 -0
  51. package/scripts/dev/deployment-validator.js +315 -0
  52. package/scripts/dev/spawn-claude-terminal.sh +32 -0
  53. package/scripts/dev/start-portal.sh +506 -0
  54. package/scripts/dev/start-web-ui.js +15 -0
  55. package/scripts/dev/stop-portal.sh +311 -0
  56. package/scripts/dev/validate-examples.ts +288 -0
  57. package/scripts/dev/validate-phase2.cjs +451 -0
  58. package/scripts/dev/validate-phase2.js +785 -0
  59. package/scripts/dev/validate-phase3.cjs +208 -0
  60. package/scripts/dev/validate-security-remediation.js +1 -0
  61. package/scripts/ecosystem.config.cjs +90 -0
  62. package/scripts/fix-js-extensions.js +167 -0
  63. package/scripts/generate-basic-types.js +73 -0
  64. package/scripts/generate-changelog.js +318 -0
  65. package/scripts/git-hooks/pre-commit.sh +143 -0
  66. package/scripts/health-checks.js +634 -0
  67. package/scripts/hook-wrapper.sh +54 -0
  68. package/scripts/install/README.md +375 -0
  69. package/scripts/install/REDIS_SETUP_VALIDATION.json +245 -0
  70. package/scripts/install/check-prerequisites.js +303 -0
  71. package/scripts/install/config-wizard.js +606 -0
  72. package/scripts/install/dependency-checker.js +385 -0
  73. package/scripts/install/health-check.js +765 -0
  74. package/scripts/install/install.js +256 -0
  75. package/scripts/install/installation-benchmark.js +461 -0
  76. package/scripts/install/quick-install.js +720 -0
  77. package/scripts/install/quick-start-wizard.js +295 -0
  78. package/scripts/install/redis-cli.js +289 -0
  79. package/scripts/install/redis-install-guides.md +407 -0
  80. package/scripts/install/redis-setup.js +559 -0
  81. package/scripts/install/redis-test.js +278 -0
  82. package/scripts/install/service-manager.js +672 -0
  83. package/scripts/install/setup.js +832 -0
  84. package/scripts/install/uninstall.js +526 -0
  85. package/scripts/install/update.js +461 -0
  86. package/scripts/install-pre-commit-hook.sh +127 -0
  87. package/scripts/legacy/README.md +272 -0
  88. package/scripts/legacy/batch-fix-ts.sh +54 -0
  89. package/scripts/legacy/build-migration.sh +105 -0
  90. package/scripts/legacy/build-monitor.js +209 -0
  91. package/scripts/legacy/build-with-filter.sh +84 -0
  92. package/scripts/legacy/build-workaround.sh +71 -0
  93. package/scripts/legacy/fix-ts-advanced.js +358 -0
  94. package/scripts/legacy/fix-ts-final.sh +50 -0
  95. package/scripts/legacy/fix-ts-targeted.sh +49 -0
  96. package/scripts/legacy/fix-typescript-errors.js +305 -0
  97. package/scripts/legacy/force-build.sh +63 -0
  98. package/scripts/legacy/optimize-performance.js +400 -0
  99. package/scripts/legacy/performance-monitor.js +263 -0
  100. package/scripts/legacy/performance-monitoring.js +532 -0
  101. package/scripts/legacy/performance-test-runner.js +645 -0
  102. package/scripts/legacy/quick-fix-ts.js +281 -0
  103. package/scripts/legacy/safe-build.sh +63 -0
  104. package/scripts/memory-monitor-coordinator.js +322 -0
  105. package/scripts/migrate-to-sdk.sh +520 -0
  106. package/scripts/migration/QUICK-START.md +189 -0
  107. package/scripts/migration/QUICK-START.md.backup-1760135091363 +189 -0
  108. package/scripts/migration/README.md +464 -0
  109. package/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md +500 -0
  110. package/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md.backup-1760135091348 +500 -0
  111. package/scripts/migration/UPDATE-PATHS-README.md +464 -0
  112. package/scripts/migration/UPDATE-PATHS-README.md.backup-1760135091337 +464 -0
  113. package/scripts/migration/example-patterns.json +19 -0
  114. package/scripts/migration/install-arm64.js +78 -0
  115. package/scripts/migration/install.js +83 -0
  116. package/scripts/migration/migrate-hooks.js +173 -0
  117. package/scripts/migration/migration-examples.ts +318 -0
  118. package/scripts/migration/reorganize-workspace.js +504 -0
  119. package/scripts/migration/test-update-paths.js +359 -0
  120. package/scripts/migration/update-paths.js +664 -0
  121. package/scripts/migration/validate-migration.js +647 -0
  122. package/scripts/monitor-loop.sh +65 -0
  123. package/scripts/monitor-memory.sh +47 -0
  124. package/scripts/monitor-migration.js +339 -0
  125. package/scripts/monitor.py +43 -0
  126. package/scripts/monitoring/README.md +178 -0
  127. package/scripts/monitoring/alert-monitor.sh +220 -0
  128. package/scripts/monitoring/analyze-resources.sh +199 -0
  129. package/scripts/monitoring/dashboards/rate-limiting-dashboard.json +211 -0
  130. package/scripts/monitoring/dynamic-monitor.sh +85 -0
  131. package/scripts/monitoring/launch-stability-test.sh +184 -0
  132. package/scripts/monitoring/monitor-test.sh +93 -0
  133. package/scripts/monitoring/pre-test-validation.sh +208 -0
  134. package/scripts/monitoring/quick-test-alerting.sh +118 -0
  135. package/scripts/monitoring/quick-test-rate-limiting.sh +206 -0
  136. package/scripts/monitoring/rate-limiting-monitor.sh +380 -0
  137. package/scripts/monitoring/resource-monitor.sh +126 -0
  138. package/scripts/monitoring/stability-monitor.js +429 -0
  139. package/scripts/monitoring/test-monitor-quick.sh +54 -0
  140. package/scripts/monitoring/view-alerts.sh +307 -0
  141. package/scripts/npm-metrics-collector.js +482 -0
  142. package/scripts/npm-package-validation.cjs +299 -0
  143. package/scripts/optimization/build-optimizer.js +438 -0
  144. package/scripts/optimization/config-validator.js +761 -0
  145. package/scripts/optimization/test-optimization.js +432 -0
  146. package/scripts/optimization/unified-activation.js +839 -0
  147. package/scripts/optimize-package-swarm.js +54 -0
  148. package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
  149. package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
  150. package/scripts/performance/test-enhanced-backend.sh +504 -0
  151. package/scripts/performance-monitor.js +644 -0
  152. package/scripts/performance-test-runner.js +698 -0
  153. package/scripts/post-deployment-monitoring.js +350 -0
  154. package/scripts/post-edit-pipeline.js +2091 -0
  155. package/scripts/post-install-claude-md.js +78 -0
  156. package/scripts/postinstall.js +79 -0
  157. package/scripts/pre-publish-validation.cjs +212 -0
  158. package/scripts/pre-publish-validation.js +429 -0
  159. package/scripts/redis-lua/cleanup-blocking-coordination.lua +198 -0
  160. package/scripts/release-announcement.js +425 -0
  161. package/scripts/release-notification.js +248 -0
  162. package/scripts/release-rollback.js +376 -0
  163. package/scripts/release-validation.js +460 -0
  164. package/scripts/rollback-sdk.sh +66 -0
  165. package/scripts/run-production-validation.ts +590 -0
  166. package/scripts/run-stability-validation.sh +687 -0
  167. package/scripts/security/README.md +339 -0
  168. package/scripts/security/deployment-validation.cjs +279 -0
  169. package/scripts/security/envelope-encryption-confidence-report.cjs +422 -0
  170. package/scripts/security/install-git-hooks.sh +132 -0
  171. package/scripts/security/install-git-secrets.sh +295 -0
  172. package/scripts/security/rotate-api-keys.js +469 -0
  173. package/scripts/security/ruv-swarm-safe.js +74 -0
  174. package/scripts/security/security-audit.cjs +538 -0
  175. package/scripts/security/setup-redis-auth.sh +397 -0
  176. package/scripts/security/validate-envelope-encryption.cjs +340 -0
  177. package/scripts/security-scan.js +492 -0
  178. package/scripts/src/web/frontend/.claude-flow/metrics/agent-metrics.json +1 -0
  179. package/scripts/src/web/frontend/.claude-flow/metrics/performance.json +9 -0
  180. package/scripts/src/web/frontend/.claude-flow/metrics/task-metrics.json +10 -0
  181. package/scripts/switch-api.sh +158 -0
  182. package/scripts/sync-agents.js +290 -0
  183. package/scripts/test/50-agent-test.js +625 -0
  184. package/scripts/test/NEW_STABILITY_TEST_GUIDE.md +407 -0
  185. package/scripts/test/README.md +236 -0
  186. package/scripts/test/STABILITY_TEST_EXAMPLE.md +347 -0
  187. package/scripts/test/STABILITY_TEST_README.md +480 -0
  188. package/scripts/test/agent-worker.js +309 -0
  189. package/scripts/test/ai-coordination-test.js +650 -0
  190. package/scripts/test/ai-mesh-coordination-test.js +416 -0
  191. package/scripts/test/check-links.ts +274 -0
  192. package/scripts/test/check-performance-regression.ts +168 -0
  193. package/scripts/test/cli-agent-coordination-test.js +313 -0
  194. package/scripts/test/coordinator-multilingual-test.js +396 -0
  195. package/scripts/test/coordinator-transparency-demo.js +585 -0
  196. package/scripts/test/coverage-report.ts +692 -0
  197. package/scripts/test/generate-swarm-tests.js +633 -0
  198. package/scripts/test/integration-test-validation.cjs +253 -0
  199. package/scripts/test/load-test-swarm.js +576 -0
  200. package/scripts/test/mesh-coordination-zero-overlap-test.js +740 -0
  201. package/scripts/test/multilingual-hello-world-test.js +390 -0
  202. package/scripts/test/quick-multilingual-demo.js +464 -0
  203. package/scripts/test/real-agent-test.js +312 -0
  204. package/scripts/test/run-phase3-compliance-tests.js +427 -0
  205. package/scripts/test/run-stability-test-examples.sh +292 -0
  206. package/scripts/test/stability-results/stability-metrics.jsonl +83 -0
  207. package/scripts/test/stability-results/stability-test-report.json +128 -0
  208. package/scripts/test/stability-results/stability-test.log +1827 -0
  209. package/scripts/test/stability-test-50-agents.js +734 -0
  210. package/scripts/test/test-batch-tasks.ts +29 -0
  211. package/scripts/test/test-byzantine-resolution.js +246 -0
  212. package/scripts/test/test-claude-spawn-options.sh +63 -0
  213. package/scripts/test/test-cli-wizard.js +331 -0
  214. package/scripts/test/test-comprehensive.js +401 -0
  215. package/scripts/test/test-coordination-features.ts +238 -0
  216. package/scripts/test/test-fallback-systems.js +276 -0
  217. package/scripts/test/test-init-command.ts +302 -0
  218. package/scripts/test/test-mcp.ts +251 -0
  219. package/scripts/test/test-runner.ts +568 -0
  220. package/scripts/test/test-swarm-integration.sh +92 -0
  221. package/scripts/test/test-swarm.ts +142 -0
  222. package/scripts/test/validation-summary.ts +408 -0
  223. package/scripts/test-cleanup-performance.sh +416 -0
  224. package/scripts/test-dashboard-auth.cjs +203 -0
  225. package/scripts/test-docker-deployment.sh +207 -0
  226. package/scripts/test-npm-package.cjs +167 -0
  227. package/scripts/test-provider-routing.cjs +226 -0
  228. package/scripts/test-routing-telemetry.cjs +147 -0
  229. package/scripts/test-runner.cjs +154 -0
  230. package/scripts/test-zai-10k.cjs +81 -0
  231. package/scripts/test-zai-api.cjs +191 -0
  232. package/scripts/test-zai-diagnostic.cjs +151 -0
  233. package/scripts/test-zai-final.cjs +128 -0
  234. package/scripts/test-zai-with-env.cjs +85 -0
  235. package/scripts/utils/README.md +261 -0
  236. package/scripts/utils/clean-build-artifacts.sh +94 -0
  237. package/scripts/utils/cleanup-root.sh +69 -0
  238. package/scripts/utils/fix-cliffy-imports.js +307 -0
  239. package/scripts/utils/fix-duplicate-imports.js +114 -0
  240. package/scripts/utils/fix-error-handling.cjs +70 -0
  241. package/scripts/utils/fix-import-paths.js +104 -0
  242. package/scripts/utils/fix-imports.js +116 -0
  243. package/scripts/utils/fix-shebang.js +78 -0
  244. package/scripts/utils/fix-test-modules.js +27 -0
  245. package/scripts/utils/fix-timezone-issue-246.js +200 -0
  246. package/scripts/utils/fix-ts-comprehensive.py +182 -0
  247. package/scripts/utils/fix-ts-targeted-batch.js +250 -0
  248. package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
  249. package/scripts/utils/simple-test-fixer.js +190 -0
  250. package/scripts/utils/validate-metrics-structure.cjs +144 -0
  251. package/scripts/validate-agent-hooks.js +506 -0
  252. package/scripts/validate-changelog.js +241 -0
  253. package/scripts/validate-coordination-cli.js +69 -0
  254. package/scripts/validate-coordination-toggle-integration.cjs +501 -0
  255. package/scripts/validate-docker-infrastructure.sh +502 -0
  256. package/scripts/validate-entry-points.js +300 -0
  257. package/scripts/validate-stage3-performance.ts +377 -0
  258. package/scripts/validate-template-bundling.js +180 -0
  259. package/scripts/validation/README.md +33 -0
  260. package/scripts/validation/acl-security-validation.cjs +214 -0
  261. package/scripts/validation/acl-security-validation.js +402 -0
  262. package/scripts/validation/byzantine-verification.js +407 -0
  263. package/scripts/validation/final-phase-2-consensus.cjs +219 -0
  264. package/scripts/validation/final-security-validation.js +791 -0
  265. package/scripts/validation/final-wasm-validation.cjs +840 -0
  266. package/scripts/validation/integration-test-analysis.js +105 -0
  267. package/scripts/validation/phase-0-comprehensive-validation.js +474 -0
  268. package/scripts/validation/phase-0-consensus-report.js +139 -0
  269. package/scripts/validation/phase-0-final-report.js +112 -0
  270. package/scripts/validation/phase-0-redis-consensus-report.js +129 -0
  271. package/scripts/validation/phase-0-validation-improved.js +490 -0
  272. package/scripts/validation/phase-0-validation-test.js +65 -0
  273. package/scripts/validation/phase-1-consensus-report.cjs +342 -0
  274. package/scripts/validation/phase-1-consensus-validation.cjs +551 -0
  275. package/scripts/validation/phase-1-consensus-validation.js +551 -0
  276. package/scripts/validation/phase-2-consensus-report.cjs +186 -0
  277. package/scripts/validation/phase-2-validation.cjs +171 -0
  278. package/scripts/validation/phase-2-validation.js +171 -0
  279. package/scripts/validation/phase-4-consensus-report.js +181 -0
  280. package/scripts/validation/phase-4-final-validation.js +351 -0
  281. package/scripts/validation/phase-5-consensus-report.cjs +113 -0
  282. package/scripts/validation/phase-5-consensus-report.js +113 -0
  283. package/scripts/validation/security-analysis.js +49 -0
  284. package/scripts/validation/security-validation.js +492 -0
  285. package/scripts/validation/simple-security-validation.js +464 -0
  286. package/scripts/verify-installation.js +112 -0
  287. package/scripts/verify-mcp-server.js +86 -0
  288. package/scripts/verify-sdk-phase1.cjs +293 -0
@@ -0,0 +1,401 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Comprehensive Test Runner for Claude Flow v2.0.0
5
+ */
6
+
7
+ import { spawn } from 'child_process';
8
+ import chalk from 'chalk';
9
+ import path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+ const projectRoot = path.join(__dirname, '..');
15
+
16
+ // Test configurations
17
+ const testSuites = [
18
+ {
19
+ name: 'Unit Tests',
20
+ command: 'npm',
21
+ args: ['run', 'test:unit'],
22
+ description: 'Run all unit tests for individual components',
23
+ timeout: 120000 // 2 minutes
24
+ },
25
+ {
26
+ name: 'Integration Tests',
27
+ command: 'npm',
28
+ args: ['run', 'test:integration'],
29
+ description: 'Run integration tests for system components',
30
+ timeout: 300000 // 5 minutes
31
+ },
32
+ {
33
+ name: 'End-to-End Tests',
34
+ command: 'npm',
35
+ args: ['run', 'test:e2e'],
36
+ description: 'Run end-to-end swarm coordination tests',
37
+ timeout: 600000 // 10 minutes
38
+ },
39
+ {
40
+ name: 'Performance Tests',
41
+ command: 'npm',
42
+ args: ['run', 'test:performance'],
43
+ description: 'Run performance benchmark tests',
44
+ timeout: 900000 // 15 minutes
45
+ },
46
+ {
47
+ name: 'CLI Tests',
48
+ command: 'npm',
49
+ args: ['run', 'test:cli'],
50
+ description: 'Run CLI command tests',
51
+ timeout: 180000 // 3 minutes
52
+ }
53
+ ];
54
+
55
+ // Load tests (optional)
56
+ const loadTests = [
57
+ {
58
+ name: 'Swarm Load Test',
59
+ command: 'node',
60
+ args: ['scripts/load-test-swarm.js'],
61
+ description: 'Test swarm coordination under heavy load',
62
+ timeout: 1200000 // 20 minutes
63
+ },
64
+ {
65
+ name: 'Memory Load Test',
66
+ command: 'node',
67
+ args: ['scripts/load-test-memory.js'],
68
+ description: 'Test memory management under high throughput',
69
+ timeout: 600000 // 10 minutes
70
+ }
71
+ ];
72
+
73
+ // Docker tests (optional)
74
+ const dockerTests = [
75
+ {
76
+ name: 'Docker Build Test',
77
+ command: 'docker',
78
+ args: ['build', '-t', 'claude-flow:test', '.'],
79
+ description: 'Test Docker image build',
80
+ timeout: 600000 // 10 minutes
81
+ },
82
+ {
83
+ name: 'Docker Container Test',
84
+ command: 'docker',
85
+ args: ['run', '--rm', 'claude-flow:test', 'claude-flow', '--version'],
86
+ description: 'Test Docker container execution',
87
+ timeout: 120000 // 2 minutes
88
+ }
89
+ ];
90
+
91
+ // NPX tests (optional)
92
+ const npxTests = [
93
+ {
94
+ name: 'NPX Installation Test',
95
+ command: 'npm',
96
+ args: ['pack'],
97
+ description: 'Test NPX package creation',
98
+ timeout: 180000 // 3 minutes
99
+ }
100
+ ];
101
+
102
+ class TestRunner {
103
+ constructor(options = {}) {
104
+ this.verbose = options.verbose || false;
105
+ this.includeLoad = options.load || false;
106
+ this.includeDocker = options.docker || false;
107
+ this.includeNpx = options.npx || false;
108
+ this.parallel = options.parallel || false;
109
+ this.results = new Map();
110
+ this.startTime = Date.now();
111
+ }
112
+
113
+ log(message, level = 'info') {
114
+ const timestamp = new Date().toISOString();
115
+ const prefix = `[${timestamp}]`;
116
+
117
+ switch (level) {
118
+ case 'success':
119
+ console.log(chalk.green(`${prefix} ✅ ${message}`));
120
+ break;
121
+ case 'error':
122
+ console.log(chalk.red(`${prefix} ❌ ${message}`));
123
+ break;
124
+ case 'warning':
125
+ console.log(chalk.yellow(`${prefix} ⚠️ ${message}`));
126
+ break;
127
+ case 'info':
128
+ default:
129
+ console.log(chalk.blue(`${prefix} ℹ️ ${message}`));
130
+ break;
131
+ }
132
+ }
133
+
134
+ async runTest(test) {
135
+ this.log(`Starting: ${test.name} - ${test.description}`);
136
+
137
+ const startTime = Date.now();
138
+
139
+ return new Promise((resolve) => {
140
+ const child = spawn(test.command, test.args, {
141
+ cwd: projectRoot,
142
+ stdio: this.verbose ? 'inherit' : 'pipe',
143
+ shell: process.platform === 'win32'
144
+ });
145
+
146
+ let stdout = '';
147
+ let stderr = '';
148
+
149
+ if (!this.verbose) {
150
+ child.stdout?.on('data', (data) => {
151
+ stdout += data.toString();
152
+ });
153
+
154
+ child.stderr?.on('data', (data) => {
155
+ stderr += data.toString();
156
+ });
157
+ }
158
+
159
+ // Set timeout
160
+ const timeoutId = setTimeout(() => {
161
+ child.kill('SIGTERM');
162
+ const result = {
163
+ name: test.name,
164
+ success: false,
165
+ error: 'Test timed out',
166
+ duration: Date.now() - startTime,
167
+ stdout: stdout,
168
+ stderr: stderr
169
+ };
170
+ this.results.set(test.name, result);
171
+ resolve(result);
172
+ }, test.timeout);
173
+
174
+ child.on('close', (code) => {
175
+ clearTimeout(timeoutId);
176
+ const duration = Date.now() - startTime;
177
+
178
+ const result = {
179
+ name: test.name,
180
+ success: code === 0,
181
+ exitCode: code,
182
+ duration: duration,
183
+ stdout: stdout,
184
+ stderr: stderr
185
+ };
186
+
187
+ if (code === 0) {
188
+ this.log(`Completed: ${test.name} (${duration}ms)`, 'success');
189
+ } else {
190
+ this.log(`Failed: ${test.name} (exit code: ${code})`, 'error');
191
+ if (!this.verbose && stderr) {
192
+ console.log(chalk.red('Error output:'));
193
+ console.log(stderr);
194
+ }
195
+ }
196
+
197
+ this.results.set(test.name, result);
198
+ resolve(result);
199
+ });
200
+
201
+ child.on('error', (error) => {
202
+ clearTimeout(timeoutId);
203
+ const result = {
204
+ name: test.name,
205
+ success: false,
206
+ error: error.message,
207
+ duration: Date.now() - startTime,
208
+ stdout: stdout,
209
+ stderr: stderr
210
+ };
211
+
212
+ this.log(`Error: ${test.name} - ${error.message}`, 'error');
213
+ this.results.set(test.name, result);
214
+ resolve(result);
215
+ });
216
+ });
217
+ }
218
+
219
+ async runTestSuite(tests, suiteName) {
220
+ this.log(`\n🏃‍♂️ Running ${suiteName} (${tests.length} tests)`);
221
+
222
+ if (this.parallel) {
223
+ const results = await Promise.all(tests.map(test => this.runTest(test)));
224
+ return results;
225
+ } else {
226
+ const results = [];
227
+ for (const test of tests) {
228
+ const result = await this.runTest(test);
229
+ results.push(result);
230
+
231
+ // Short delay between tests
232
+ await new Promise(resolve => setTimeout(resolve, 1000));
233
+ }
234
+ return results;
235
+ }
236
+ }
237
+
238
+ generateReport() {
239
+ const totalTime = Date.now() - this.startTime;
240
+ const results = Array.from(this.results.values());
241
+ const passed = results.filter(r => r.success).length;
242
+ const failed = results.filter(r => !r.success).length;
243
+ const total = results.length;
244
+
245
+ console.log('\n' + '='.repeat(80));
246
+ console.log(chalk.bold.blue('📊 CLAUDE FLOW v2.0.0 TEST REPORT'));
247
+ console.log('='.repeat(80));
248
+
249
+ console.log(`\n📈 Summary:`);
250
+ console.log(` Total Tests: ${total}`);
251
+ console.log(` Passed: ${chalk.green(passed)}`);
252
+ console.log(` Failed: ${chalk.red(failed)}`);
253
+ console.log(` Success Rate: ${chalk.cyan(((passed / total) * 100).toFixed(1))}%`);
254
+ console.log(` Total Time: ${chalk.yellow((totalTime / 1000).toFixed(2))}s`);
255
+
256
+ if (failed > 0) {
257
+ console.log(`\n❌ Failed Tests:`);
258
+ results.filter(r => !r.success).forEach(result => {
259
+ console.log(` • ${chalk.red(result.name)}: ${result.error || `Exit code ${result.exitCode}`}`);
260
+ });
261
+ }
262
+
263
+ console.log(`\n✅ Passed Tests:`);
264
+ results.filter(r => r.success).forEach(result => {
265
+ console.log(` • ${chalk.green(result.name)}: ${(result.duration / 1000).toFixed(2)}s`);
266
+ });
267
+
268
+ // Performance summary
269
+ const performanceResults = results.filter(r => r.name.includes('Performance'));
270
+ if (performanceResults.length > 0) {
271
+ console.log(`\n⚡ Performance Summary:`);
272
+ performanceResults.forEach(result => {
273
+ if (result.success) {
274
+ console.log(` • ${result.name}: ${chalk.green('PASSED')} (${(result.duration / 1000).toFixed(2)}s)`);
275
+ } else {
276
+ console.log(` • ${result.name}: ${chalk.red('FAILED')}`);
277
+ }
278
+ });
279
+ }
280
+
281
+ console.log('\n' + '='.repeat(80));
282
+
283
+ return {
284
+ total,
285
+ passed,
286
+ failed,
287
+ successRate: (passed / total) * 100,
288
+ totalTime,
289
+ results
290
+ };
291
+ }
292
+
293
+ async run() {
294
+ this.log('🚀 Starting Claude Flow v2.0.0 Comprehensive Test Suite');
295
+
296
+ try {
297
+ // Core test suites
298
+ await this.runTestSuite(testSuites, 'Core Test Suites');
299
+
300
+ // Optional test suites
301
+ if (this.includeLoad) {
302
+ await this.runTestSuite(loadTests, 'Load Tests');
303
+ }
304
+
305
+ if (this.includeDocker) {
306
+ await this.runTestSuite(dockerTests, 'Docker Tests');
307
+ }
308
+
309
+ if (this.includeNpx) {
310
+ await this.runTestSuite(npxTests, 'NPX Tests');
311
+ }
312
+
313
+ } catch (error) {
314
+ this.log(`Test runner error: ${error.message}`, 'error');
315
+ }
316
+
317
+ const report = this.generateReport();
318
+
319
+ // Exit with appropriate code
320
+ process.exit(report.failed > 0 ? 1 : 0);
321
+ }
322
+ }
323
+
324
+ // CLI handling
325
+ function parseArgs() {
326
+ const args = process.argv.slice(2);
327
+ const options = {
328
+ verbose: args.includes('--verbose') || args.includes('-v'),
329
+ load: args.includes('--load') || args.includes('-l'),
330
+ docker: args.includes('--docker') || args.includes('-d'),
331
+ npx: args.includes('--npx') || args.includes('-n'),
332
+ parallel: args.includes('--parallel') || args.includes('-p'),
333
+ help: args.includes('--help') || args.includes('-h')
334
+ };
335
+
336
+ return options;
337
+ }
338
+
339
+ function showHelp() {
340
+ console.log(`
341
+ ${chalk.bold.blue('Claude Flow v2.0.0 Comprehensive Test Runner')}
342
+
343
+ ${chalk.bold('Usage:')}
344
+ node scripts/test-comprehensive.js [options]
345
+
346
+ ${chalk.bold('Options:')}
347
+ -v, --verbose Show detailed test output
348
+ -l, --load Include load tests
349
+ -d, --docker Include Docker tests
350
+ -n, --npx Include NPX tests
351
+ -p, --parallel Run tests in parallel (faster but less stable)
352
+ -h, --help Show this help message
353
+
354
+ ${chalk.bold('Examples:')}
355
+ node scripts/test-comprehensive.js # Run core tests
356
+ node scripts/test-comprehensive.js --verbose # Run with detailed output
357
+ node scripts/test-comprehensive.js --load --docker # Include load and Docker tests
358
+ node scripts/test-comprehensive.js --parallel # Run tests in parallel
359
+
360
+ ${chalk.bold('Test Suites:')}
361
+ • Unit Tests - Individual component tests
362
+ • Integration Tests - System integration tests
363
+ • End-to-End Tests - Complete workflow tests
364
+ • Performance Tests - Benchmark and load tests
365
+ • CLI Tests - Command-line interface tests
366
+ • Load Tests - Heavy load and stress tests (optional)
367
+ • Docker Tests - Container and deployment tests (optional)
368
+ • NPX Tests - Package distribution tests (optional)
369
+ `);
370
+ }
371
+
372
+ // Main execution
373
+ async function main() {
374
+ const options = parseArgs();
375
+
376
+ if (options.help) {
377
+ showHelp();
378
+ process.exit(0);
379
+ }
380
+
381
+ const runner = new TestRunner(options);
382
+ await runner.run();
383
+ }
384
+
385
+ // Handle uncaught errors
386
+ process.on('uncaughtException', (error) => {
387
+ console.error(chalk.red('Uncaught Exception:'), error);
388
+ process.exit(1);
389
+ });
390
+
391
+ process.on('unhandledRejection', (reason, promise) => {
392
+ console.error(chalk.red('Unhandled Rejection at:'), promise, chalk.red('reason:'), reason);
393
+ process.exit(1);
394
+ });
395
+
396
+ // Run if called directly
397
+ if (import.meta.url === `file://${process.argv[1]}`) {
398
+ main();
399
+ }
400
+
401
+ export default TestRunner;
@@ -0,0 +1,238 @@
1
+ #!/usr/bin/env -S deno run --allow-all
2
+
3
+ /**
4
+ * Test script for advanced coordination features
5
+ * Demonstrates:
6
+ * - Resource management and deadlock detection
7
+ * - Task dependencies and scheduling
8
+ * - Work stealing and load balancing
9
+ * - Circuit breakers and fault tolerance
10
+ */
11
+
12
+ import { EventBus } from '../src/core/event-bus.ts';
13
+ import { Logger } from '../src/core/logger.js';
14
+ import { CoordinationManager } from '../src/coordination/manager.ts';
15
+ import { Task, SystemEvents } from '../src/utils/types.ts';
16
+ import { delay } from '../src/utils/helpers.ts';
17
+
18
+ async function testCoordinationFeatures() {
19
+ console.log('🔄 Testing Claude-Flow Coordination Features\n');
20
+
21
+ const eventBus = new EventBus();
22
+ const logger = new Logger({ level: 'info', format: 'json', destination: 'console' });
23
+
24
+ const config = {
25
+ maxRetries: 3,
26
+ retryDelay: 1000,
27
+ resourceTimeout: 5000,
28
+ deadlockDetection: true,
29
+ priorityLevels: 5,
30
+ };
31
+
32
+ const coordinator = new CoordinationManager(config, eventBus, logger);
33
+
34
+ try {
35
+ await coordinator.initialize();
36
+ console.log('✅ Coordination manager initialized\n');
37
+
38
+ // Test 1: Resource Management
39
+ console.log('📋 Test 1: Resource Management');
40
+ console.log('Testing resource acquisition and release...');
41
+
42
+ // Agent 1 acquires resource A
43
+ await coordinator.acquireResource('resource-A', 'agent-1');
44
+ console.log('✅ Agent 1 acquired resource A');
45
+
46
+ // Agent 2 tries to acquire resource A (should wait)
47
+ const acquire2Promise = coordinator.acquireResource('resource-A', 'agent-2');
48
+ console.log('⏳ Agent 2 waiting for resource A...');
49
+
50
+ // Release after delay
51
+ setTimeout(async () => {
52
+ await coordinator.releaseResource('resource-A', 'agent-1');
53
+ console.log('✅ Agent 1 released resource A');
54
+ }, 1000);
55
+
56
+ await acquire2Promise;
57
+ console.log('✅ Agent 2 acquired resource A\n');
58
+
59
+ // Test 2: Task Dependencies
60
+ console.log('📋 Test 2: Task Dependencies');
61
+
62
+ const parentTask: Task = {
63
+ id: 'parent-task',
64
+ type: 'process',
65
+ description: 'Parent task',
66
+ priority: 90,
67
+ dependencies: [],
68
+ status: 'pending',
69
+ input: {},
70
+ createdAt: new Date(),
71
+ };
72
+
73
+ const childTask: Task = {
74
+ id: 'child-task',
75
+ type: 'process',
76
+ description: 'Child task (depends on parent)',
77
+ priority: 80,
78
+ dependencies: ['parent-task'],
79
+ status: 'pending',
80
+ input: {},
81
+ createdAt: new Date(),
82
+ };
83
+
84
+ await coordinator.assignTask(parentTask, 'agent-1');
85
+ console.log('✅ Assigned parent task to agent-1');
86
+
87
+ try {
88
+ await coordinator.assignTask(childTask, 'agent-2');
89
+ } catch (error) {
90
+ console.log('✅ Child task correctly blocked by dependency');
91
+ }
92
+
93
+ // Complete parent task
94
+ eventBus.emit(SystemEvents.TASK_COMPLETED, {
95
+ taskId: 'parent-task',
96
+ result: { data: 'parent result' },
97
+ });
98
+
99
+ await delay(100);
100
+
101
+ // Now child should be assignable
102
+ await coordinator.assignTask(childTask, 'agent-2');
103
+ console.log('✅ Child task assigned after parent completion\n');
104
+
105
+ // Test 3: Deadlock Detection
106
+ console.log('📋 Test 3: Deadlock Detection');
107
+ console.log('Creating potential deadlock scenario...');
108
+
109
+ // Agent 3 holds B, wants A
110
+ await coordinator.acquireResource('resource-B', 'agent-3');
111
+ const agent3WantsA = coordinator.acquireResource('resource-A', 'agent-3')
112
+ .catch(() => console.log('✅ Deadlock detected and resolved'));
113
+
114
+ // Agent 2 holds A, wants B (creates cycle)
115
+ const agent2WantsB = coordinator.acquireResource('resource-B', 'agent-2')
116
+ .catch(() => console.log('✅ Agent 2 resource request failed'));
117
+
118
+ // Wait for deadlock detection
119
+ await delay(2000);
120
+
121
+ // Clean up resources
122
+ await coordinator.releaseResource('resource-A', 'agent-2');
123
+ await coordinator.releaseResource('resource-B', 'agent-3');
124
+ console.log('✅ Resources cleaned up\n');
125
+
126
+ // Test 4: Advanced Scheduling
127
+ console.log('📋 Test 4: Advanced Scheduling Features');
128
+ coordinator.enableAdvancedScheduling();
129
+ console.log('✅ Advanced scheduling enabled');
130
+
131
+ // Create tasks with different priorities
132
+ const highPriorityTask: Task = {
133
+ id: 'high-priority',
134
+ type: 'urgent',
135
+ description: 'High priority task',
136
+ priority: 100,
137
+ dependencies: [],
138
+ status: 'pending',
139
+ input: {},
140
+ createdAt: new Date(),
141
+ };
142
+
143
+ const lowPriorityTask: Task = {
144
+ id: 'low-priority',
145
+ type: 'batch',
146
+ description: 'Low priority task',
147
+ priority: 10,
148
+ dependencies: [],
149
+ status: 'pending',
150
+ input: {},
151
+ createdAt: new Date(),
152
+ };
153
+
154
+ await coordinator.assignTask(lowPriorityTask, 'agent-1');
155
+ await coordinator.assignTask(highPriorityTask, 'agent-1');
156
+ console.log('✅ Tasks assigned with priority scheduling\n');
157
+
158
+ // Test 5: Conflict Resolution
159
+ console.log('📋 Test 5: Conflict Resolution');
160
+
161
+ // Report a resource conflict
162
+ await coordinator.reportConflict('resource', 'shared-resource', ['agent-1', 'agent-2']);
163
+ console.log('✅ Resource conflict reported and auto-resolved');
164
+
165
+ // Report a task conflict
166
+ await coordinator.reportConflict('task', 'disputed-task', ['agent-1', 'agent-2']);
167
+ console.log('✅ Task conflict reported and auto-resolved\n');
168
+
169
+ // Test 6: Health and Metrics
170
+ console.log('📋 Test 6: Health Monitoring and Metrics');
171
+
172
+ const health = await coordinator.getHealthStatus();
173
+ console.log('🏥 Health Status:', health.healthy ? 'Healthy' : 'Unhealthy');
174
+
175
+ const metrics = await coordinator.getCoordinationMetrics();
176
+ console.log('📊 Coordination Metrics:');
177
+ console.log(` Tasks assigned: ${metrics.assigned || 0}`);
178
+ console.log(` Resources managed: ${metrics.resources || 0}`);
179
+ console.log(` Conflicts resolved: ${metrics.conflicts?.resolved || 0}`);
180
+ console.log(` Advanced scheduling: ${metrics.advancedScheduling ? 'Enabled' : 'Disabled'}`);
181
+
182
+ // Test 7: Message Routing
183
+ console.log('\n📋 Test 7: Inter-Agent Messaging');
184
+
185
+ // Set up message handler
186
+ let messagesReceived = 0;
187
+ eventBus.on('message:agent-2', (data: any) => {
188
+ messagesReceived++;
189
+ console.log(`✅ Agent 2 received message: ${data.message.content}`);
190
+ });
191
+
192
+ // Send messages
193
+ await coordinator.sendMessage('agent-1', 'agent-2', {
194
+ type: 'status',
195
+ content: 'Task completed'
196
+ });
197
+
198
+ await coordinator.sendMessage('agent-1', 'agent-2', {
199
+ type: 'data',
200
+ content: 'Results available'
201
+ });
202
+
203
+ await delay(100);
204
+ console.log(`✅ Sent and received ${messagesReceived} messages\n`);
205
+
206
+ // Perform maintenance
207
+ console.log('📋 Performing maintenance...');
208
+ await coordinator.performMaintenance();
209
+ console.log('✅ Maintenance completed');
210
+
211
+ // Shutdown
212
+ await coordinator.shutdown();
213
+ console.log('\n✅ Coordination manager shut down successfully');
214
+
215
+ // Summary
216
+ console.log('\n' + '='.repeat(50));
217
+ console.log('✅ ALL COORDINATION TESTS PASSED!');
218
+ console.log('='.repeat(50));
219
+ console.log('\nFeatures tested:');
220
+ console.log(' ✓ Resource management with mutual exclusion');
221
+ console.log(' ✓ Task dependencies and scheduling');
222
+ console.log(' ✓ Deadlock detection and prevention');
223
+ console.log(' ✓ Advanced scheduling with priorities');
224
+ console.log(' ✓ Conflict detection and resolution');
225
+ console.log(' ✓ Health monitoring and metrics');
226
+ console.log(' ✓ Inter-agent messaging');
227
+ console.log(' ✓ System maintenance');
228
+
229
+ } catch (error) {
230
+ console.error('❌ Test failed:', error);
231
+ throw error;
232
+ }
233
+ }
234
+
235
+ // Run the test
236
+ if (import.meta.main) {
237
+ testCoordinationFeatures().catch(console.error);
238
+ }