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,647 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Migration Validation Script
5
+ *
6
+ * Validates successful migration by checking:
7
+ * - File movement verification
8
+ * - Broken symlink detection
9
+ * - Git status validation
10
+ * - Build process test
11
+ * - Test suite execution
12
+ * - Docker build validation
13
+ * - Configuration file syntax
14
+ * - Path reference verification
15
+ *
16
+ * Usage:
17
+ * node scripts/migration/validate-migration.js [options]
18
+ *
19
+ * Options:
20
+ * --json Output results in JSON format
21
+ * --verbose Show detailed output
22
+ * --skip-build Skip build validation
23
+ * --skip-test Skip test suite validation
24
+ * --skip-docker Skip Docker build validation
25
+ */
26
+
27
+ import fs from 'fs/promises';
28
+ import path from 'path';
29
+ import { fileURLToPath } from 'url';
30
+ import { execSync } from 'child_process';
31
+
32
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
33
+ const projectRoot = path.resolve(__dirname, '../..');
34
+
35
+ // Parse command line arguments
36
+ const args = process.argv.slice(2);
37
+ const options = {
38
+ json: args.includes('--json'),
39
+ verbose: args.includes('--verbose'),
40
+ skipBuild: args.includes('--skip-build'),
41
+ skipTest: args.includes('--skip-test'),
42
+ skipDocker: args.includes('--skip-docker')
43
+ };
44
+
45
+ // Validation results
46
+ const results = {
47
+ timestamp: new Date().toISOString(),
48
+ overall: 'pending',
49
+ checks: {},
50
+ errors: [],
51
+ warnings: []
52
+ };
53
+
54
+ // Expected file structure after migration
55
+ const expectedFiles = [
56
+ '.claude-flow-novice/dist/src/cli/main.js',
57
+ '.claude-flow-novice/dist/src/index.js',
58
+ '.claude-flow-novice/dist/src/mcp/mcp-server-sdk.js',
59
+ '.claude-flow-novice/dist/src/core/index.js',
60
+ 'package.json',
61
+ 'Dockerfile',
62
+ '.dockerignore',
63
+ 'config/jest/jest.config.js',
64
+ 'config/linting/.eslintrc.json',
65
+ 'config/typescript/tsconfig.json'
66
+ ];
67
+
68
+ // Old paths that should not exist in code references
69
+ const deprecatedPaths = [
70
+ 'dist/src',
71
+ 'dist/mcp',
72
+ 'dist/cli',
73
+ './dist/',
74
+ '"dist/',
75
+ '\'dist/',
76
+ 'from "dist',
77
+ 'from \'dist',
78
+ 'require("dist',
79
+ 'require(\'dist'
80
+ ];
81
+
82
+ /**
83
+ * Log output based on format preference
84
+ */
85
+ function log(message, type = 'info') {
86
+ if (options.json) return; // Suppress console output in JSON mode
87
+
88
+ const icons = {
89
+ info: 'ā„¹ļø',
90
+ success: 'āœ…',
91
+ error: 'āŒ',
92
+ warning: 'āš ļø',
93
+ check: 'šŸ”'
94
+ };
95
+
96
+ console.log(`${icons[type] || ''} ${message}`);
97
+ }
98
+
99
+ /**
100
+ * Execute command with error handling
101
+ */
102
+ function execCommand(command, description, timeoutMs = 30000) {
103
+ try {
104
+ const output = execSync(command, {
105
+ cwd: projectRoot,
106
+ encoding: 'utf8',
107
+ stdio: options.verbose ? 'inherit' : 'pipe',
108
+ maxBuffer: 10 * 1024 * 1024, // 10MB buffer
109
+ timeout: timeoutMs
110
+ });
111
+ return { success: true, output };
112
+ } catch (error) {
113
+ return {
114
+ success: false,
115
+ error: error.message,
116
+ output: error.stdout || error.stderr || ''
117
+ };
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Check if file exists
123
+ */
124
+ async function fileExists(filePath) {
125
+ try {
126
+ await fs.access(path.join(projectRoot, filePath));
127
+ return true;
128
+ } catch {
129
+ return false;
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Validation: File Movement Verification
135
+ */
136
+ async function validateFileMovement() {
137
+ log('Checking file movement...', 'check');
138
+
139
+ const check = {
140
+ name: 'File Movement',
141
+ status: 'pass',
142
+ details: {
143
+ expected: expectedFiles.length,
144
+ found: 0,
145
+ missing: []
146
+ }
147
+ };
148
+
149
+ for (const file of expectedFiles) {
150
+ const exists = await fileExists(file);
151
+ if (exists) {
152
+ check.details.found++;
153
+ if (options.verbose) log(` āœ“ Found: ${file}`, 'info');
154
+ } else {
155
+ check.details.missing.push(file);
156
+ if (options.verbose) log(` āœ— Missing: ${file}`, 'warning');
157
+ }
158
+ }
159
+
160
+ if (check.details.missing.length > 0) {
161
+ check.status = 'fail';
162
+ results.errors.push(`Missing ${check.details.missing.length} expected files`);
163
+ } else {
164
+ log('All expected files found', 'success');
165
+ }
166
+
167
+ results.checks.fileMovement = check;
168
+ return check.status === 'pass';
169
+ }
170
+
171
+ /**
172
+ * Validation: Broken Symlink Detection
173
+ */
174
+ async function validateSymlinks() {
175
+ log('Checking for broken symlinks...', 'check');
176
+
177
+ const check = {
178
+ name: 'Symlink Validation',
179
+ status: 'pass',
180
+ details: {
181
+ brokenLinks: []
182
+ }
183
+ };
184
+
185
+ // Find broken symlinks only (more efficient - L flag finds broken links)
186
+ // Limit search depth to avoid long scans
187
+ const result = execCommand(
188
+ 'find . -maxdepth 5 -xtype l ! -path "./node_modules/*" ! -path "./.git/*" 2>/dev/null || true',
189
+ 'Finding broken symlinks',
190
+ 10000 // 10 second timeout
191
+ );
192
+
193
+ if (result.success && result.output && result.output.trim()) {
194
+ const symlinks = result.output.trim().split('\n').filter(Boolean);
195
+ check.details.brokenLinks = symlinks;
196
+
197
+ if (options.verbose) {
198
+ symlinks.forEach(link => log(` āœ— Broken symlink: ${link}`, 'warning'));
199
+ }
200
+ }
201
+
202
+ if (check.details.brokenLinks.length > 0) {
203
+ check.status = 'fail';
204
+ results.errors.push(`Found ${check.details.brokenLinks.length} broken symlinks`);
205
+ } else {
206
+ log('No broken symlinks found', 'success');
207
+ }
208
+
209
+ results.checks.symlinks = check;
210
+ return check.status === 'pass';
211
+ }
212
+
213
+ /**
214
+ * Validation: Git Status
215
+ */
216
+ async function validateGitStatus() {
217
+ log('Checking git status...', 'check');
218
+
219
+ const check = {
220
+ name: 'Git Status',
221
+ status: 'pass',
222
+ details: {
223
+ clean: false,
224
+ untracked: [],
225
+ modified: [],
226
+ deleted: []
227
+ }
228
+ };
229
+
230
+ const result = execCommand('git status --porcelain', 'Checking git status');
231
+
232
+ if (result.success) {
233
+ const status = result.output.trim();
234
+
235
+ if (status === '') {
236
+ check.details.clean = true;
237
+ log('Git working tree is clean', 'success');
238
+ } else {
239
+ const lines = status.split('\n');
240
+ for (const line of lines) {
241
+ const type = line.substring(0, 2).trim();
242
+ const file = line.substring(3);
243
+
244
+ if (type === '??') check.details.untracked.push(file);
245
+ else if (type === 'M' || type === 'MM') check.details.modified.push(file);
246
+ else if (type === 'D') check.details.deleted.push(file);
247
+ }
248
+
249
+ // Only warn if there are unexpected changes (deleted files might be expected)
250
+ if (check.details.modified.length > 0) {
251
+ results.warnings.push(`Git has ${check.details.modified.length} modified files`);
252
+ }
253
+
254
+ if (options.verbose) {
255
+ log(` Untracked: ${check.details.untracked.length}`, 'info');
256
+ log(` Modified: ${check.details.modified.length}`, 'info');
257
+ log(` Deleted: ${check.details.deleted.length}`, 'info');
258
+ }
259
+ }
260
+ } else {
261
+ check.status = 'skip';
262
+ results.warnings.push('Git status check skipped (not a git repository)');
263
+ }
264
+
265
+ results.checks.gitStatus = check;
266
+ return check.status !== 'fail';
267
+ }
268
+
269
+ /**
270
+ * Validation: Build Process
271
+ */
272
+ async function validateBuild() {
273
+ if (options.skipBuild) {
274
+ log('Skipping build validation', 'info');
275
+ results.checks.build = { name: 'Build Process', status: 'skip' };
276
+ return true;
277
+ }
278
+
279
+ log('Testing build process...', 'check');
280
+
281
+ const check = {
282
+ name: 'Build Process',
283
+ status: 'pass',
284
+ details: {
285
+ success: false,
286
+ duration: 0,
287
+ output: ''
288
+ }
289
+ };
290
+
291
+ const startTime = Date.now();
292
+ const result = execCommand('npm run build', 'Running npm build');
293
+ check.details.duration = Date.now() - startTime;
294
+
295
+ if (result.success) {
296
+ check.details.success = true;
297
+ log(`Build completed successfully in ${check.details.duration}ms`, 'success');
298
+ } else {
299
+ check.status = 'fail';
300
+ check.details.output = result.output;
301
+ results.errors.push('Build process failed');
302
+ log('Build process failed', 'error');
303
+ }
304
+
305
+ results.checks.build = check;
306
+ return check.status === 'pass';
307
+ }
308
+
309
+ /**
310
+ * Validation: Test Suite
311
+ */
312
+ async function validateTests() {
313
+ if (options.skipTest) {
314
+ log('Skipping test validation', 'info');
315
+ results.checks.tests = { name: 'Test Suite', status: 'skip' };
316
+ return true;
317
+ }
318
+
319
+ log('Running test suite...', 'check');
320
+
321
+ const check = {
322
+ name: 'Test Suite',
323
+ status: 'pass',
324
+ details: {
325
+ success: false,
326
+ duration: 0,
327
+ testCount: 0,
328
+ failures: 0
329
+ }
330
+ };
331
+
332
+ const startTime = Date.now();
333
+ const result = execCommand(
334
+ 'npm test -- --run --reporter=json 2>&1',
335
+ 'Running tests'
336
+ );
337
+ check.details.duration = Date.now() - startTime;
338
+
339
+ if (result.success) {
340
+ check.details.success = true;
341
+
342
+ // Try to parse test results
343
+ try {
344
+ const jsonMatch = result.output.match(/\{[\s\S]*"numTotalTests"[\s\S]*\}/);
345
+ if (jsonMatch) {
346
+ const testResults = JSON.parse(jsonMatch[0]);
347
+ check.details.testCount = testResults.numTotalTests || 0;
348
+ check.details.failures = testResults.numFailedTests || 0;
349
+ }
350
+ } catch {
351
+ // If parsing fails, just mark as success
352
+ }
353
+
354
+ log(`Tests passed in ${check.details.duration}ms`, 'success');
355
+ } else {
356
+ // Allow test failures as warning, not critical error
357
+ check.status = 'warning';
358
+ results.warnings.push('Some tests failed - review test output');
359
+ log('Test suite has failures', 'warning');
360
+ }
361
+
362
+ results.checks.tests = check;
363
+ return check.status !== 'fail';
364
+ }
365
+
366
+ /**
367
+ * Validation: Docker Build
368
+ */
369
+ async function validateDocker() {
370
+ if (options.skipDocker) {
371
+ log('Skipping Docker validation', 'info');
372
+ results.checks.docker = { name: 'Docker Build', status: 'skip' };
373
+ return true;
374
+ }
375
+
376
+ log('Testing Docker build...', 'check');
377
+
378
+ const check = {
379
+ name: 'Docker Build',
380
+ status: 'pass',
381
+ details: {
382
+ success: false,
383
+ duration: 0,
384
+ imageSize: 0
385
+ }
386
+ };
387
+
388
+ // First check if Docker is available
389
+ const dockerCheck = execCommand('docker --version', 'Checking Docker');
390
+ if (!dockerCheck.success) {
391
+ check.status = 'skip';
392
+ results.warnings.push('Docker not available - skipping Docker build validation');
393
+ results.checks.docker = check;
394
+ return true;
395
+ }
396
+
397
+ const startTime = Date.now();
398
+ const result = execCommand(
399
+ 'docker build . --no-cache -t claude-flow-novice:validation-test 2>&1',
400
+ 'Building Docker image'
401
+ );
402
+ check.details.duration = Date.now() - startTime;
403
+
404
+ if (result.success) {
405
+ check.details.success = true;
406
+
407
+ // Get image size
408
+ const sizeResult = execCommand(
409
+ 'docker images claude-flow-novice:validation-test --format "{{.Size}}"',
410
+ 'Getting image size'
411
+ );
412
+ if (sizeResult.success) {
413
+ check.details.imageSize = sizeResult.output.trim();
414
+ }
415
+
416
+ // Clean up test image
417
+ execCommand('docker rmi claude-flow-novice:validation-test', 'Cleaning up');
418
+
419
+ log(`Docker build successful (${check.details.imageSize})`, 'success');
420
+ } else {
421
+ check.status = 'fail';
422
+ results.errors.push('Docker build failed');
423
+ log('Docker build failed', 'error');
424
+ }
425
+
426
+ results.checks.docker = check;
427
+ return check.status === 'pass';
428
+ }
429
+
430
+ /**
431
+ * Validation: Configuration Files
432
+ */
433
+ async function validateConfigurations() {
434
+ log('Validating configuration files...', 'check');
435
+
436
+ const check = {
437
+ name: 'Configuration Validation',
438
+ status: 'pass',
439
+ details: {
440
+ validated: 0,
441
+ invalid: []
442
+ }
443
+ };
444
+
445
+ const configFiles = [
446
+ { path: 'package.json', type: 'json' },
447
+ { path: 'config/jest/jest.config.js', type: 'js' },
448
+ { path: '.dockerignore', type: 'text' },
449
+ { path: 'Dockerfile', type: 'text' }
450
+ ];
451
+
452
+ for (const config of configFiles) {
453
+ const filePath = path.join(projectRoot, config.path);
454
+
455
+ try {
456
+ const content = await fs.readFile(filePath, 'utf8');
457
+
458
+ if (config.type === 'json') {
459
+ JSON.parse(content); // Validate JSON syntax
460
+ }
461
+
462
+ check.details.validated++;
463
+ if (options.verbose) log(` āœ“ Valid: ${config.path}`, 'info');
464
+ } catch (error) {
465
+ check.details.invalid.push({
466
+ file: config.path,
467
+ error: error.message
468
+ });
469
+ if (options.verbose) log(` āœ— Invalid: ${config.path}`, 'warning');
470
+ }
471
+ }
472
+
473
+ if (check.details.invalid.length > 0) {
474
+ check.status = 'fail';
475
+ results.errors.push(`${check.details.invalid.length} configuration files have syntax errors`);
476
+ } else {
477
+ log('All configuration files valid', 'success');
478
+ }
479
+
480
+ results.checks.configurations = check;
481
+ return check.status === 'pass';
482
+ }
483
+
484
+ /**
485
+ * Validation: Path References
486
+ */
487
+ async function validatePathReferences() {
488
+ log('Checking for deprecated path references...', 'check');
489
+
490
+ const check = {
491
+ name: 'Path References',
492
+ status: 'pass',
493
+ details: {
494
+ scannedFiles: 0,
495
+ issues: []
496
+ }
497
+ };
498
+
499
+ // Search for old path references in source files
500
+ const searchDirs = ['src', 'config', 'scripts'];
501
+
502
+ // Combine patterns for a single grep operation (more efficient)
503
+ const combinedPattern = deprecatedPaths.map(p => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('\\|');
504
+ const result = execCommand(
505
+ `grep -r -E '${combinedPattern}' ${searchDirs.join(' ')} --include="*.js" --include="*.ts" --include="*.json" 2>/dev/null || true`,
506
+ 'Searching for deprecated paths',
507
+ 15000 // 15 second timeout
508
+ );
509
+
510
+ if (result.output && result.output.trim()) {
511
+ const matches = result.output.trim().split('\n');
512
+ const fileSet = new Set(matches.map(m => m.split(':')[0]));
513
+
514
+ check.details.issues.push({
515
+ pattern: 'deprecated-paths',
516
+ matches: matches.length,
517
+ files: Array.from(fileSet)
518
+ });
519
+ }
520
+
521
+ if (check.details.issues.length > 0) {
522
+ check.status = 'warning';
523
+ results.warnings.push(`Found ${check.details.issues.length} deprecated path references`);
524
+
525
+ if (options.verbose) {
526
+ for (const issue of check.details.issues) {
527
+ log(` Pattern "${issue.pattern}": ${issue.matches} matches`, 'warning');
528
+ }
529
+ }
530
+ } else {
531
+ log('No deprecated path references found', 'success');
532
+ }
533
+
534
+ results.checks.pathReferences = check;
535
+ return check.status !== 'fail';
536
+ }
537
+
538
+ /**
539
+ * Generate summary report
540
+ */
541
+ function generateSummary() {
542
+ const passed = Object.values(results.checks).filter(c => c.status === 'pass').length;
543
+ const failed = Object.values(results.checks).filter(c => c.status === 'fail').length;
544
+ const warnings = Object.values(results.checks).filter(c => c.status === 'warning').length;
545
+ const skipped = Object.values(results.checks).filter(c => c.status === 'skip').length;
546
+
547
+ results.summary = {
548
+ total: Object.keys(results.checks).length,
549
+ passed,
550
+ failed,
551
+ warnings,
552
+ skipped
553
+ };
554
+
555
+ if (failed > 0) {
556
+ results.overall = 'fail';
557
+ } else if (warnings > 0) {
558
+ results.overall = 'warning';
559
+ } else {
560
+ results.overall = 'pass';
561
+ }
562
+
563
+ return results.summary;
564
+ }
565
+
566
+ /**
567
+ * Output results
568
+ */
569
+ function outputResults() {
570
+ if (options.json) {
571
+ console.log(JSON.stringify(results, null, 2));
572
+ return;
573
+ }
574
+
575
+ const summary = results.summary;
576
+
577
+ console.log('\n' + '='.repeat(60));
578
+ console.log('šŸ“Š MIGRATION VALIDATION SUMMARY');
579
+ console.log('='.repeat(60));
580
+ console.log(`\nTimestamp: ${results.timestamp}`);
581
+ console.log(`Overall Status: ${results.overall.toUpperCase()}`);
582
+ console.log(`\nChecks: ${summary.total} total`);
583
+ console.log(` āœ… Passed: ${summary.passed}`);
584
+ console.log(` āŒ Failed: ${summary.failed}`);
585
+ console.log(` āš ļø Warnings: ${summary.warnings}`);
586
+ console.log(` ā­ļø Skipped: ${summary.skipped}`);
587
+
588
+ if (results.errors.length > 0) {
589
+ console.log('\nāŒ Errors:');
590
+ results.errors.forEach(err => console.log(` - ${err}`));
591
+ }
592
+
593
+ if (results.warnings.length > 0) {
594
+ console.log('\nāš ļø Warnings:');
595
+ results.warnings.forEach(warn => console.log(` - ${warn}`));
596
+ }
597
+
598
+ console.log('\n' + '='.repeat(60));
599
+
600
+ if (results.overall === 'pass') {
601
+ console.log('āœ… Migration validation PASSED');
602
+ } else if (results.overall === 'warning') {
603
+ console.log('āš ļø Migration validation PASSED with warnings');
604
+ } else {
605
+ console.log('āŒ Migration validation FAILED');
606
+ }
607
+ console.log('='.repeat(60) + '\n');
608
+ }
609
+
610
+ /**
611
+ * Main execution
612
+ */
613
+ async function main() {
614
+ try {
615
+ if (!options.json) {
616
+ console.log('šŸ” Migration Validation Script\n');
617
+ console.log(`Project: ${projectRoot}\n`);
618
+ }
619
+
620
+ // Run all validations
621
+ await validateFileMovement();
622
+ await validateSymlinks();
623
+ await validateGitStatus();
624
+ await validateConfigurations();
625
+ await validatePathReferences();
626
+ await validateBuild();
627
+ await validateTests();
628
+ await validateDocker();
629
+
630
+ // Generate and output summary
631
+ generateSummary();
632
+ outputResults();
633
+
634
+ // Exit with appropriate code
635
+ process.exit(results.overall === 'fail' ? 1 : 0);
636
+
637
+ } catch (error) {
638
+ console.error('āŒ Fatal error during validation:', error.message);
639
+ if (options.verbose) {
640
+ console.error(error.stack);
641
+ }
642
+ process.exit(1);
643
+ }
644
+ }
645
+
646
+ // Execute
647
+ main();
@@ -0,0 +1,65 @@
1
+ #!/bin/bash
2
+ # Monitor memory every 30 seconds, 20 iterations
3
+
4
+ LOG_FILE="memory-monitor-$(date +%Y%m%d-%H%M%S).log"
5
+ ITERATIONS=20
6
+ INTERVAL=30
7
+
8
+ echo "=== Memory Monitor Started ===" | tee "$LOG_FILE"
9
+ echo "Monitoring for $((ITERATIONS * INTERVAL)) seconds ($ITERATIONS checks)" | tee -a "$LOG_FILE"
10
+ echo "Timestamp: $(date)" | tee -a "$LOG_FILE"
11
+ echo "" | tee -a "$LOG_FILE"
12
+
13
+ for i in $(seq 1 $ITERATIONS); do
14
+ TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
15
+
16
+ # Total memory usage
17
+ TOTAL_MEM=$(ps aux | grep -E "(claude|node)" | grep -v grep | awk '{sum+=$6} END {printf "%.1f", sum/1024}')
18
+
19
+ # Node process count
20
+ NODE_COUNT=$(ps aux | grep node | grep -v grep | grep -v snapfuse | wc -l)
21
+
22
+ # Claude process count
23
+ CLAUDE_COUNT=$(ps aux | grep claude | grep -v grep | wc -l)
24
+
25
+ # Zombie processes
26
+ ZOMBIE_COUNT=$(ps aux | grep "<defunct>" | grep -v grep | wc -l)
27
+
28
+ # Find processes (memory bombs)
29
+ FIND_COUNT=$(ps aux | grep "find /mnt/c" | grep -v grep | wc -l)
30
+
31
+ # Hook processes
32
+ HOOK_COUNT=$(ps aux | grep "npx claude-flow-novice hooks" | grep -v grep | wc -l)
33
+
34
+ echo "[$i/$ITERATIONS] [$TIMESTAMP] MEM: ${TOTAL_MEM}MB | Node: $NODE_COUNT | Claude: $CLAUDE_COUNT | Zombies: $ZOMBIE_COUNT | Find: $FIND_COUNT | Hooks: $HOOK_COUNT" | tee -a "$LOG_FILE"
35
+
36
+ # Alerts
37
+ if (( $(echo "$TOTAL_MEM > 10000" | bc -l 2>/dev/null || echo 0) )); then
38
+ echo " āš ļø WARNING: Memory usage exceeds 10GB!" | tee -a "$LOG_FILE"
39
+ fi
40
+
41
+ if [ "$NODE_COUNT" -gt 20 ]; then
42
+ echo " āš ļø WARNING: $NODE_COUNT node processes (orphaned agents?)" | tee -a "$LOG_FILE"
43
+ fi
44
+
45
+ if [ "$FIND_COUNT" -gt 0 ]; then
46
+ echo " šŸ”“ CRITICAL: $FIND_COUNT find commands on /mnt/c (MEMORY BOMB!)" | tee -a "$LOG_FILE"
47
+ fi
48
+
49
+ if [ "$ZOMBIE_COUNT" -gt 0 ]; then
50
+ echo " šŸ’€ ZOMBIE: $ZOMBIE_COUNT zombie processes detected" | tee -a "$LOG_FILE"
51
+ fi
52
+
53
+ if [ "$HOOK_COUNT" -gt 5 ]; then
54
+ echo " šŸ” RECURSION: $HOOK_COUNT hook processes (possible recursion!)" | tee -a "$LOG_FILE"
55
+ fi
56
+
57
+ # Don't sleep on last iteration
58
+ if [ $i -lt $ITERATIONS ]; then
59
+ sleep $INTERVAL
60
+ fi
61
+ done
62
+
63
+ echo "" | tee -a "$LOG_FILE"
64
+ echo "=== Monitoring Complete ===" | tee -a "$LOG_FILE"
65
+ echo "Log saved to: $LOG_FILE" | tee -a "$LOG_FILE"