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.
- package/package.json +9 -8
- package/scripts/.claude-flow/metrics/agent-metrics.json +1 -0
- package/scripts/.claude-flow/metrics/performance.json +9 -0
- package/scripts/.claude-flow/metrics/task-metrics.json +10 -0
- package/scripts/CLEANUP_OPTIMIZATION_REPORT.json +312 -0
- package/scripts/CLEANUP_PERFORMANCE_OPTIMIZATION.md +387 -0
- package/scripts/CLEANUP_QUICK_START.md +268 -0
- package/scripts/CLEANUP_TEST_RESULTS.md +205 -0
- package/scripts/README.md +339 -0
- package/scripts/ace-query.sh +384 -0
- package/scripts/agent-token-analysis.js +430 -0
- package/scripts/auto-setup.js +332 -0
- package/scripts/build/README.md +167 -0
- package/scripts/build/build-config.js +27 -0
- package/scripts/build/build-prompt-copier.sh +30 -0
- package/scripts/build/performance-monitor.js +869 -0
- package/scripts/build/prepare-publish.js +150 -0
- package/scripts/build/typescript-fixer.js +621 -0
- package/scripts/build/unified-builder.sh +428 -0
- package/scripts/build/update-bin-version.js +32 -0
- package/scripts/build/validate-agents.js +238 -0
- package/scripts/build-index.js +43 -0
- package/scripts/build-orchestrator.js +320 -0
- package/scripts/check-routing-stats.cjs +122 -0
- package/scripts/ci-validation.js +375 -0
- package/scripts/cleanup-blocking-coordination.sh +420 -0
- package/scripts/cleanup-idle-sessions.sh +59 -0
- package/scripts/collect-build-metrics.js +65 -0
- package/scripts/demo/README.md +79 -0
- package/scripts/demo/autoscaling-demo-simplified.js +963 -0
- package/scripts/demo/comprehensive-dashboard-test.js +693 -0
- package/scripts/demo/confidence-log.js +87 -0
- package/scripts/demo/confidence-report.js +82 -0
- package/scripts/demo/demo-multi-swarm-coordination.js +325 -0
- package/scripts/demo/demo-production-deployment.js +399 -0
- package/scripts/demo/demo-visualization-system.js +149 -0
- package/scripts/demo/performance-analysis.cjs +71 -0
- package/scripts/demo/performance-analysis.js +71 -0
- package/scripts/demo/test-autoscaling-demo.js +314 -0
- package/scripts/dependency-optimizer.js +349 -0
- package/scripts/dependency-security-assessment.js +331 -0
- package/scripts/deploy-sdk.sh +176 -0
- package/scripts/deployment-readiness-report.json +179 -0
- package/scripts/dev/README.md +264 -0
- package/scripts/dev/claude-flow-wrapper.sh +35 -0
- package/scripts/dev/claude-monitor.py +419 -0
- package/scripts/dev/claude-sparc.sh +562 -0
- package/scripts/dev/claude-wrapper.sh +17 -0
- package/scripts/dev/demo-phase3-compliance.js +172 -0
- package/scripts/dev/demo-task-system.ts +224 -0
- package/scripts/dev/deployment-validator.js +315 -0
- package/scripts/dev/spawn-claude-terminal.sh +32 -0
- package/scripts/dev/start-portal.sh +506 -0
- package/scripts/dev/start-web-ui.js +15 -0
- package/scripts/dev/stop-portal.sh +311 -0
- package/scripts/dev/validate-examples.ts +288 -0
- package/scripts/dev/validate-phase2.cjs +451 -0
- package/scripts/dev/validate-phase2.js +785 -0
- package/scripts/dev/validate-phase3.cjs +208 -0
- package/scripts/dev/validate-security-remediation.js +1 -0
- package/scripts/ecosystem.config.cjs +90 -0
- package/scripts/fix-js-extensions.js +167 -0
- package/scripts/generate-basic-types.js +73 -0
- package/scripts/generate-changelog.js +318 -0
- package/scripts/git-hooks/pre-commit.sh +143 -0
- package/scripts/health-checks.js +634 -0
- package/scripts/hook-wrapper.sh +54 -0
- package/scripts/install/README.md +375 -0
- package/scripts/install/REDIS_SETUP_VALIDATION.json +245 -0
- package/scripts/install/check-prerequisites.js +303 -0
- package/scripts/install/config-wizard.js +606 -0
- package/scripts/install/dependency-checker.js +385 -0
- package/scripts/install/health-check.js +765 -0
- package/scripts/install/install.js +256 -0
- package/scripts/install/installation-benchmark.js +461 -0
- package/scripts/install/quick-install.js +720 -0
- package/scripts/install/quick-start-wizard.js +295 -0
- package/scripts/install/redis-cli.js +289 -0
- package/scripts/install/redis-install-guides.md +407 -0
- package/scripts/install/redis-setup.js +559 -0
- package/scripts/install/redis-test.js +278 -0
- package/scripts/install/service-manager.js +672 -0
- package/scripts/install/setup.js +832 -0
- package/scripts/install/uninstall.js +526 -0
- package/scripts/install/update.js +461 -0
- package/scripts/install-pre-commit-hook.sh +127 -0
- package/scripts/legacy/README.md +272 -0
- package/scripts/legacy/batch-fix-ts.sh +54 -0
- package/scripts/legacy/build-migration.sh +105 -0
- package/scripts/legacy/build-monitor.js +209 -0
- package/scripts/legacy/build-with-filter.sh +84 -0
- package/scripts/legacy/build-workaround.sh +71 -0
- package/scripts/legacy/fix-ts-advanced.js +358 -0
- package/scripts/legacy/fix-ts-final.sh +50 -0
- package/scripts/legacy/fix-ts-targeted.sh +49 -0
- package/scripts/legacy/fix-typescript-errors.js +305 -0
- package/scripts/legacy/force-build.sh +63 -0
- package/scripts/legacy/optimize-performance.js +400 -0
- package/scripts/legacy/performance-monitor.js +263 -0
- package/scripts/legacy/performance-monitoring.js +532 -0
- package/scripts/legacy/performance-test-runner.js +645 -0
- package/scripts/legacy/quick-fix-ts.js +281 -0
- package/scripts/legacy/safe-build.sh +63 -0
- package/scripts/memory-monitor-coordinator.js +322 -0
- package/scripts/migrate-to-sdk.sh +520 -0
- package/scripts/migration/QUICK-START.md +189 -0
- package/scripts/migration/QUICK-START.md.backup-1760135091363 +189 -0
- package/scripts/migration/README.md +464 -0
- package/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md +500 -0
- package/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md.backup-1760135091348 +500 -0
- package/scripts/migration/UPDATE-PATHS-README.md +464 -0
- package/scripts/migration/UPDATE-PATHS-README.md.backup-1760135091337 +464 -0
- package/scripts/migration/example-patterns.json +19 -0
- package/scripts/migration/install-arm64.js +78 -0
- package/scripts/migration/install.js +83 -0
- package/scripts/migration/migrate-hooks.js +173 -0
- package/scripts/migration/migration-examples.ts +318 -0
- package/scripts/migration/reorganize-workspace.js +504 -0
- package/scripts/migration/test-update-paths.js +359 -0
- package/scripts/migration/update-paths.js +664 -0
- package/scripts/migration/validate-migration.js +647 -0
- package/scripts/monitor-loop.sh +65 -0
- package/scripts/monitor-memory.sh +47 -0
- package/scripts/monitor-migration.js +339 -0
- package/scripts/monitor.py +43 -0
- package/scripts/monitoring/README.md +178 -0
- package/scripts/monitoring/alert-monitor.sh +220 -0
- package/scripts/monitoring/analyze-resources.sh +199 -0
- package/scripts/monitoring/dashboards/rate-limiting-dashboard.json +211 -0
- package/scripts/monitoring/dynamic-monitor.sh +85 -0
- package/scripts/monitoring/launch-stability-test.sh +184 -0
- package/scripts/monitoring/monitor-test.sh +93 -0
- package/scripts/monitoring/pre-test-validation.sh +208 -0
- package/scripts/monitoring/quick-test-alerting.sh +118 -0
- package/scripts/monitoring/quick-test-rate-limiting.sh +206 -0
- package/scripts/monitoring/rate-limiting-monitor.sh +380 -0
- package/scripts/monitoring/resource-monitor.sh +126 -0
- package/scripts/monitoring/stability-monitor.js +429 -0
- package/scripts/monitoring/test-monitor-quick.sh +54 -0
- package/scripts/monitoring/view-alerts.sh +307 -0
- package/scripts/npm-metrics-collector.js +482 -0
- package/scripts/npm-package-validation.cjs +299 -0
- package/scripts/optimization/build-optimizer.js +438 -0
- package/scripts/optimization/config-validator.js +761 -0
- package/scripts/optimization/test-optimization.js +432 -0
- package/scripts/optimization/unified-activation.js +839 -0
- package/scripts/optimize-package-swarm.js +54 -0
- package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
- package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
- package/scripts/performance/test-enhanced-backend.sh +504 -0
- package/scripts/performance-monitor.js +644 -0
- package/scripts/performance-test-runner.js +698 -0
- package/scripts/post-deployment-monitoring.js +350 -0
- package/scripts/post-edit-pipeline.js +2091 -0
- package/scripts/post-install-claude-md.js +78 -0
- package/scripts/postinstall.js +79 -0
- package/scripts/pre-publish-validation.cjs +212 -0
- package/scripts/pre-publish-validation.js +429 -0
- package/scripts/redis-lua/cleanup-blocking-coordination.lua +198 -0
- package/scripts/release-announcement.js +425 -0
- package/scripts/release-notification.js +248 -0
- package/scripts/release-rollback.js +376 -0
- package/scripts/release-validation.js +460 -0
- package/scripts/rollback-sdk.sh +66 -0
- package/scripts/run-production-validation.ts +590 -0
- package/scripts/run-stability-validation.sh +687 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/deployment-validation.cjs +279 -0
- package/scripts/security/envelope-encryption-confidence-report.cjs +422 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/install-git-secrets.sh +295 -0
- package/scripts/security/rotate-api-keys.js +469 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/security/security-audit.cjs +538 -0
- package/scripts/security/setup-redis-auth.sh +397 -0
- package/scripts/security/validate-envelope-encryption.cjs +340 -0
- package/scripts/security-scan.js +492 -0
- package/scripts/src/web/frontend/.claude-flow/metrics/agent-metrics.json +1 -0
- package/scripts/src/web/frontend/.claude-flow/metrics/performance.json +9 -0
- package/scripts/src/web/frontend/.claude-flow/metrics/task-metrics.json +10 -0
- package/scripts/switch-api.sh +158 -0
- package/scripts/sync-agents.js +290 -0
- package/scripts/test/50-agent-test.js +625 -0
- package/scripts/test/NEW_STABILITY_TEST_GUIDE.md +407 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/STABILITY_TEST_EXAMPLE.md +347 -0
- package/scripts/test/STABILITY_TEST_README.md +480 -0
- package/scripts/test/agent-worker.js +309 -0
- package/scripts/test/ai-coordination-test.js +650 -0
- package/scripts/test/ai-mesh-coordination-test.js +416 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -0
- package/scripts/test/cli-agent-coordination-test.js +313 -0
- package/scripts/test/coordinator-multilingual-test.js +396 -0
- package/scripts/test/coordinator-transparency-demo.js +585 -0
- package/scripts/test/coverage-report.ts +692 -0
- package/scripts/test/generate-swarm-tests.js +633 -0
- package/scripts/test/integration-test-validation.cjs +253 -0
- package/scripts/test/load-test-swarm.js +576 -0
- package/scripts/test/mesh-coordination-zero-overlap-test.js +740 -0
- package/scripts/test/multilingual-hello-world-test.js +390 -0
- package/scripts/test/quick-multilingual-demo.js +464 -0
- package/scripts/test/real-agent-test.js +312 -0
- package/scripts/test/run-phase3-compliance-tests.js +427 -0
- package/scripts/test/run-stability-test-examples.sh +292 -0
- package/scripts/test/stability-results/stability-metrics.jsonl +83 -0
- package/scripts/test/stability-results/stability-test-report.json +128 -0
- package/scripts/test/stability-results/stability-test.log +1827 -0
- package/scripts/test/stability-test-50-agents.js +734 -0
- package/scripts/test/test-batch-tasks.ts +29 -0
- package/scripts/test/test-byzantine-resolution.js +246 -0
- package/scripts/test/test-claude-spawn-options.sh +63 -0
- package/scripts/test/test-cli-wizard.js +331 -0
- package/scripts/test/test-comprehensive.js +401 -0
- package/scripts/test/test-coordination-features.ts +238 -0
- package/scripts/test/test-fallback-systems.js +276 -0
- package/scripts/test/test-init-command.ts +302 -0
- package/scripts/test/test-mcp.ts +251 -0
- package/scripts/test/test-runner.ts +568 -0
- package/scripts/test/test-swarm-integration.sh +92 -0
- package/scripts/test/test-swarm.ts +142 -0
- package/scripts/test/validation-summary.ts +408 -0
- package/scripts/test-cleanup-performance.sh +416 -0
- package/scripts/test-dashboard-auth.cjs +203 -0
- package/scripts/test-docker-deployment.sh +207 -0
- package/scripts/test-npm-package.cjs +167 -0
- package/scripts/test-provider-routing.cjs +226 -0
- package/scripts/test-routing-telemetry.cjs +147 -0
- package/scripts/test-runner.cjs +154 -0
- package/scripts/test-zai-10k.cjs +81 -0
- package/scripts/test-zai-api.cjs +191 -0
- package/scripts/test-zai-diagnostic.cjs +151 -0
- package/scripts/test-zai-final.cjs +128 -0
- package/scripts/test-zai-with-env.cjs +85 -0
- package/scripts/utils/README.md +261 -0
- package/scripts/utils/clean-build-artifacts.sh +94 -0
- package/scripts/utils/cleanup-root.sh +69 -0
- package/scripts/utils/fix-cliffy-imports.js +307 -0
- package/scripts/utils/fix-duplicate-imports.js +114 -0
- package/scripts/utils/fix-error-handling.cjs +70 -0
- package/scripts/utils/fix-import-paths.js +104 -0
- package/scripts/utils/fix-imports.js +116 -0
- package/scripts/utils/fix-shebang.js +78 -0
- package/scripts/utils/fix-test-modules.js +27 -0
- package/scripts/utils/fix-timezone-issue-246.js +200 -0
- package/scripts/utils/fix-ts-comprehensive.py +182 -0
- package/scripts/utils/fix-ts-targeted-batch.js +250 -0
- package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
- package/scripts/utils/simple-test-fixer.js +190 -0
- package/scripts/utils/validate-metrics-structure.cjs +144 -0
- package/scripts/validate-agent-hooks.js +506 -0
- package/scripts/validate-changelog.js +241 -0
- package/scripts/validate-coordination-cli.js +69 -0
- package/scripts/validate-coordination-toggle-integration.cjs +501 -0
- package/scripts/validate-docker-infrastructure.sh +502 -0
- package/scripts/validate-entry-points.js +300 -0
- package/scripts/validate-stage3-performance.ts +377 -0
- package/scripts/validate-template-bundling.js +180 -0
- package/scripts/validation/README.md +33 -0
- package/scripts/validation/acl-security-validation.cjs +214 -0
- package/scripts/validation/acl-security-validation.js +402 -0
- package/scripts/validation/byzantine-verification.js +407 -0
- package/scripts/validation/final-phase-2-consensus.cjs +219 -0
- package/scripts/validation/final-security-validation.js +791 -0
- package/scripts/validation/final-wasm-validation.cjs +840 -0
- package/scripts/validation/integration-test-analysis.js +105 -0
- package/scripts/validation/phase-0-comprehensive-validation.js +474 -0
- package/scripts/validation/phase-0-consensus-report.js +139 -0
- package/scripts/validation/phase-0-final-report.js +112 -0
- package/scripts/validation/phase-0-redis-consensus-report.js +129 -0
- package/scripts/validation/phase-0-validation-improved.js +490 -0
- package/scripts/validation/phase-0-validation-test.js +65 -0
- package/scripts/validation/phase-1-consensus-report.cjs +342 -0
- package/scripts/validation/phase-1-consensus-validation.cjs +551 -0
- package/scripts/validation/phase-1-consensus-validation.js +551 -0
- package/scripts/validation/phase-2-consensus-report.cjs +186 -0
- package/scripts/validation/phase-2-validation.cjs +171 -0
- package/scripts/validation/phase-2-validation.js +171 -0
- package/scripts/validation/phase-4-consensus-report.js +181 -0
- package/scripts/validation/phase-4-final-validation.js +351 -0
- package/scripts/validation/phase-5-consensus-report.cjs +113 -0
- package/scripts/validation/phase-5-consensus-report.js +113 -0
- package/scripts/validation/security-analysis.js +49 -0
- package/scripts/validation/security-validation.js +492 -0
- package/scripts/validation/simple-security-validation.js +464 -0
- package/scripts/verify-installation.js +112 -0
- package/scripts/verify-mcp-server.js +86 -0
- package/scripts/verify-sdk-phase1.cjs +293 -0
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claude Flow Novice - Health Check Script
|
|
5
|
+
*
|
|
6
|
+
* Comprehensive system health verification
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { execSync, spawn } from 'child_process';
|
|
10
|
+
import { existsSync, readFileSync, accessSync, constants } from 'fs';
|
|
11
|
+
import { join, dirname } from 'path';
|
|
12
|
+
import { homedir, platform, totalmem, freemem, cpus } from 'os';
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
import ora from 'ora';
|
|
15
|
+
import boxen from 'boxen';
|
|
16
|
+
|
|
17
|
+
class HealthChecker {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.platform = platform();
|
|
20
|
+
this.homeDir = homedir();
|
|
21
|
+
this.configDir = join(this.homeDir, '.claude-flow-novice', 'config');
|
|
22
|
+
this.results = {
|
|
23
|
+
overall: 'unknown',
|
|
24
|
+
categories: {
|
|
25
|
+
system: { status: 'unknown', checks: [] },
|
|
26
|
+
dependencies: { status: 'unknown', checks: [] },
|
|
27
|
+
configuration: { status: 'unknown', checks: [] },
|
|
28
|
+
services: { status: 'unknown', checks: [] },
|
|
29
|
+
network: { status: 'unknown', checks: [] }
|
|
30
|
+
},
|
|
31
|
+
warnings: [],
|
|
32
|
+
errors: [],
|
|
33
|
+
recommendations: []
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async check() {
|
|
38
|
+
console.log(chalk.blue.bold('š„ Claude Flow Novice Health Check\n'));
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
await this.checkSystemHealth();
|
|
42
|
+
await this.checkDependencies();
|
|
43
|
+
await this.checkConfiguration();
|
|
44
|
+
await this.checkServices();
|
|
45
|
+
await this.checkNetwork();
|
|
46
|
+
|
|
47
|
+
this.calculateOverallStatus();
|
|
48
|
+
this.displayResults();
|
|
49
|
+
|
|
50
|
+
return this.results;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(chalk.red('ā Health check failed:'), error.message);
|
|
53
|
+
this.results.errors.push(error.message);
|
|
54
|
+
this.results.overall = 'error';
|
|
55
|
+
return this.results;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async checkSystemHealth() {
|
|
60
|
+
const spinner = ora('Checking system health...').start();
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const checks = [];
|
|
64
|
+
|
|
65
|
+
// CPU Check
|
|
66
|
+
const cpuInfo = cpus();
|
|
67
|
+
const cpuCores = cpuInfo.length;
|
|
68
|
+
const cpuModel = cpuInfo[0].model;
|
|
69
|
+
checks.push({
|
|
70
|
+
name: 'CPU',
|
|
71
|
+
status: 'pass',
|
|
72
|
+
message: `${cpuCores} cores - ${cpuModel}`,
|
|
73
|
+
details: { cores: cpuCores, model: cpuModel }
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Memory Check
|
|
77
|
+
const totalMem = totalmem();
|
|
78
|
+
const freeMem = freemem();
|
|
79
|
+
const usedMem = totalMem - freeMem;
|
|
80
|
+
const memUsagePercent = (usedMem / totalMem) * 100;
|
|
81
|
+
|
|
82
|
+
let memStatus = 'pass';
|
|
83
|
+
if (memUsagePercent > 90) memStatus = 'fail';
|
|
84
|
+
else if (memUsagePercent > 75) memStatus = 'warn';
|
|
85
|
+
|
|
86
|
+
checks.push({
|
|
87
|
+
name: 'Memory',
|
|
88
|
+
status: memStatus,
|
|
89
|
+
message: `${Math.round(memUsagePercent)}% used (${Math.round(freeMem / 1024 / 1024)}MB free)`,
|
|
90
|
+
details: {
|
|
91
|
+
total: Math.round(totalMem / 1024 / 1024),
|
|
92
|
+
free: Math.round(freeMem / 1024 / 1024),
|
|
93
|
+
usage: Math.round(memUsagePercent)
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Disk Space Check
|
|
98
|
+
const diskInfo = await this.getDiskInfo();
|
|
99
|
+
const diskUsagePercent = ((diskInfo.used / diskInfo.total) * 100);
|
|
100
|
+
|
|
101
|
+
let diskStatus = 'pass';
|
|
102
|
+
if (diskUsagePercent > 95) diskStatus = 'fail';
|
|
103
|
+
else if (diskUsagePercent > 85) diskStatus = 'warn';
|
|
104
|
+
|
|
105
|
+
checks.push({
|
|
106
|
+
name: 'Disk Space',
|
|
107
|
+
status: diskStatus,
|
|
108
|
+
message: `${Math.round(diskUsagePercent)}% used (${Math.round(diskInfo.free / 1024 / 1024)}MB free)`,
|
|
109
|
+
details: diskInfo
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Node.js Version Check
|
|
113
|
+
const nodeVersion = process.version;
|
|
114
|
+
const nodeMajor = parseInt(nodeVersion.slice(1).split('.')[0]);
|
|
115
|
+
let nodeStatus = nodeMajor >= 20 ? 'pass' : 'fail';
|
|
116
|
+
checks.push({
|
|
117
|
+
name: 'Node.js Version',
|
|
118
|
+
status: nodeStatus,
|
|
119
|
+
message: nodeVersion,
|
|
120
|
+
details: { version: nodeVersion, major: nodeMajor }
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
this.results.categories.system.checks = checks;
|
|
124
|
+
this.results.categories.system.status = this.calculateCategoryStatus(checks);
|
|
125
|
+
|
|
126
|
+
spinner.succeed('System health check completed');
|
|
127
|
+
} catch (error) {
|
|
128
|
+
spinner.fail('System health check failed');
|
|
129
|
+
this.results.categories.system.status = 'error';
|
|
130
|
+
this.results.categories.system.checks.push({
|
|
131
|
+
name: 'System Check',
|
|
132
|
+
status: 'error',
|
|
133
|
+
message: error.message
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async getDiskInfo() {
|
|
139
|
+
try {
|
|
140
|
+
let output;
|
|
141
|
+
if (this.platform === 'win32') {
|
|
142
|
+
output = execSync('wmic logicaldisk get size,freespace,caption', { encoding: 'utf8' });
|
|
143
|
+
const lines = output.split('\n').filter(line => line.trim());
|
|
144
|
+
const data = lines[1].split(/\s+/);
|
|
145
|
+
return {
|
|
146
|
+
total: parseInt(data[1]) || 0,
|
|
147
|
+
free: parseInt(data[2]) || 0,
|
|
148
|
+
used: (parseInt(data[1]) || 0) - (parseInt(data[2]) || 0)
|
|
149
|
+
};
|
|
150
|
+
} else {
|
|
151
|
+
output = execSync('df -h ~', { encoding: 'utf8' });
|
|
152
|
+
const lines = output.split('\n');
|
|
153
|
+
const data = lines[1].split(/\s+/);
|
|
154
|
+
return {
|
|
155
|
+
total: this.parseDiskSpace(data[1]),
|
|
156
|
+
used: this.parseDiskSpace(data[2]),
|
|
157
|
+
free: this.parseDiskSpace(data[3])
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return { total: 0, used: 0, free: 0 };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
parseDiskSpace(spaceStr) {
|
|
166
|
+
const units = { K: 1024, M: 1024 * 1024, G: 1024 * 1024 * 1024, T: 1024 * 1024 * 1024 * 1024 };
|
|
167
|
+
const match = spaceStr.match(/^(\d+\.?\d*)(K|M|G|T)?$/);
|
|
168
|
+
if (!match) return 0;
|
|
169
|
+
|
|
170
|
+
const [, value, unit] = match;
|
|
171
|
+
const multiplier = units[unit] || 1;
|
|
172
|
+
return parseFloat(value) * multiplier;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async checkDependencies() {
|
|
176
|
+
const spinner = ora('Checking dependencies...').start();
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
const checks = [];
|
|
180
|
+
const dependencies = [
|
|
181
|
+
{ name: 'npm', command: 'npm --version', minVersion: '9.0.0' },
|
|
182
|
+
{ name: 'redis-cli', command: 'redis-cli --version', optional: true },
|
|
183
|
+
{ name: 'git', command: 'git --version', optional: true },
|
|
184
|
+
{ name: 'docker', command: 'docker --version', optional: true }
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
for (const dep of dependencies) {
|
|
188
|
+
try {
|
|
189
|
+
const output = execSync(dep.command, { encoding: 'utf8' }).trim();
|
|
190
|
+
const version = output.split(' ').pop();
|
|
191
|
+
|
|
192
|
+
let status = 'pass';
|
|
193
|
+
if (dep.minVersion && this.compareVersions(version, dep.minVersion) < 0) {
|
|
194
|
+
status = 'fail';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
checks.push({
|
|
198
|
+
name: dep.name,
|
|
199
|
+
status,
|
|
200
|
+
message: version,
|
|
201
|
+
details: { version, optional: dep.optional || false }
|
|
202
|
+
});
|
|
203
|
+
} catch (error) {
|
|
204
|
+
if (dep.optional) {
|
|
205
|
+
checks.push({
|
|
206
|
+
name: dep.name,
|
|
207
|
+
status: 'warn',
|
|
208
|
+
message: 'Not installed',
|
|
209
|
+
details: { optional: true }
|
|
210
|
+
});
|
|
211
|
+
} else {
|
|
212
|
+
checks.push({
|
|
213
|
+
name: dep.name,
|
|
214
|
+
status: 'fail',
|
|
215
|
+
message: 'Not installed',
|
|
216
|
+
details: { optional: false }
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Check claude-flow-novice installation
|
|
223
|
+
try {
|
|
224
|
+
const output = execSync('claude-flow-novice --version', { encoding: 'utf8' }).trim();
|
|
225
|
+
checks.push({
|
|
226
|
+
name: 'claude-flow-novice',
|
|
227
|
+
status: 'pass',
|
|
228
|
+
message: output,
|
|
229
|
+
details: { version: output }
|
|
230
|
+
});
|
|
231
|
+
} catch (error) {
|
|
232
|
+
checks.push({
|
|
233
|
+
name: 'claude-flow-novice',
|
|
234
|
+
status: 'fail',
|
|
235
|
+
message: 'Not installed or not in PATH',
|
|
236
|
+
details: {}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
this.results.categories.dependencies.checks = checks;
|
|
241
|
+
this.results.categories.dependencies.status = this.calculateCategoryStatus(checks);
|
|
242
|
+
|
|
243
|
+
spinner.succeed('Dependency check completed');
|
|
244
|
+
} catch (error) {
|
|
245
|
+
spinner.fail('Dependency check failed');
|
|
246
|
+
this.results.categories.dependencies.status = 'error';
|
|
247
|
+
this.results.categories.dependencies.checks.push({
|
|
248
|
+
name: 'Dependency Check',
|
|
249
|
+
status: 'error',
|
|
250
|
+
message: error.message
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async checkConfiguration() {
|
|
256
|
+
const spinner = ora('Checking configuration...').start();
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
const checks = [];
|
|
260
|
+
|
|
261
|
+
// Check config directory exists
|
|
262
|
+
const configDirExists = existsSync(this.configDir);
|
|
263
|
+
checks.push({
|
|
264
|
+
name: 'Configuration Directory',
|
|
265
|
+
status: configDirExists ? 'pass' : 'fail',
|
|
266
|
+
message: configDirExists ? 'Exists' : 'Not found',
|
|
267
|
+
details: { path: this.configDir }
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
if (configDirExists) {
|
|
271
|
+
// Check required config files
|
|
272
|
+
const configFiles = [
|
|
273
|
+
'config.json',
|
|
274
|
+
'redis.json',
|
|
275
|
+
'services.json',
|
|
276
|
+
'.env'
|
|
277
|
+
];
|
|
278
|
+
|
|
279
|
+
for (const file of configFiles) {
|
|
280
|
+
const filePath = join(this.configDir, file);
|
|
281
|
+
const exists = existsSync(filePath);
|
|
282
|
+
|
|
283
|
+
checks.push({
|
|
284
|
+
name: `Config File: ${file}`,
|
|
285
|
+
status: exists ? 'pass' : 'warn',
|
|
286
|
+
message: exists ? 'Exists' : 'Not found',
|
|
287
|
+
details: { path: filePath }
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
if (exists && file.endsWith('.json')) {
|
|
291
|
+
try {
|
|
292
|
+
JSON.parse(readFileSync(filePath, 'utf8'));
|
|
293
|
+
} catch (error) {
|
|
294
|
+
checks.push({
|
|
295
|
+
name: `Config Validity: ${file}`,
|
|
296
|
+
status: 'fail',
|
|
297
|
+
message: 'Invalid JSON',
|
|
298
|
+
details: { error: error.message }
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Check file permissions
|
|
306
|
+
try {
|
|
307
|
+
const testPath = join(this.configDir, '.health-check');
|
|
308
|
+
require('fs').writeFileSync(testPath, 'test');
|
|
309
|
+
require('fs').unlinkSync(testPath);
|
|
310
|
+
|
|
311
|
+
checks.push({
|
|
312
|
+
name: 'File Permissions',
|
|
313
|
+
status: 'pass',
|
|
314
|
+
message: 'Read/Write access confirmed',
|
|
315
|
+
details: {}
|
|
316
|
+
});
|
|
317
|
+
} catch (error) {
|
|
318
|
+
checks.push({
|
|
319
|
+
name: 'File Permissions',
|
|
320
|
+
status: 'fail',
|
|
321
|
+
message: 'No write access',
|
|
322
|
+
details: { error: error.message }
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
this.results.categories.configuration.checks = checks;
|
|
327
|
+
this.results.categories.configuration.status = this.calculateCategoryStatus(checks);
|
|
328
|
+
|
|
329
|
+
spinner.succeed('Configuration check completed');
|
|
330
|
+
} catch (error) {
|
|
331
|
+
spinner.fail('Configuration check failed');
|
|
332
|
+
this.results.categories.configuration.status = 'error';
|
|
333
|
+
this.results.categories.configuration.checks.push({
|
|
334
|
+
name: 'Configuration Check',
|
|
335
|
+
status: 'error',
|
|
336
|
+
message: error.message
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async checkServices() {
|
|
342
|
+
const spinner = ora('Checking services...').start();
|
|
343
|
+
|
|
344
|
+
try {
|
|
345
|
+
const checks = [];
|
|
346
|
+
|
|
347
|
+
// Check Redis
|
|
348
|
+
try {
|
|
349
|
+
const redisInfo = await this.getRedisServiceInfo();
|
|
350
|
+
checks.push({
|
|
351
|
+
name: 'Redis Service',
|
|
352
|
+
status: 'pass',
|
|
353
|
+
message: `Running (PID: ${redisInfo.pid})`,
|
|
354
|
+
details: redisInfo
|
|
355
|
+
});
|
|
356
|
+
} catch (error) {
|
|
357
|
+
checks.push({
|
|
358
|
+
name: 'Redis Service',
|
|
359
|
+
status: 'fail',
|
|
360
|
+
message: 'Not running or not accessible',
|
|
361
|
+
details: { error: error.message }
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Check Dashboard
|
|
366
|
+
try {
|
|
367
|
+
const dashboardInfo = await this.getDashboardServiceInfo();
|
|
368
|
+
if (dashboardInfo.running) {
|
|
369
|
+
checks.push({
|
|
370
|
+
name: 'Dashboard Service',
|
|
371
|
+
status: 'pass',
|
|
372
|
+
message: `Running on port ${dashboardInfo.port}`,
|
|
373
|
+
details: dashboardInfo
|
|
374
|
+
});
|
|
375
|
+
} else {
|
|
376
|
+
checks.push({
|
|
377
|
+
name: 'Dashboard Service',
|
|
378
|
+
status: 'warn',
|
|
379
|
+
message: 'Not running',
|
|
380
|
+
details: dashboardInfo
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
} catch (error) {
|
|
384
|
+
checks.push({
|
|
385
|
+
name: 'Dashboard Service',
|
|
386
|
+
status: 'warn',
|
|
387
|
+
message: 'Not configured',
|
|
388
|
+
details: {}
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Check Monitoring
|
|
393
|
+
try {
|
|
394
|
+
const monitoringInfo = await this.getMonitoringServiceInfo();
|
|
395
|
+
if (monitoringInfo.running) {
|
|
396
|
+
checks.push({
|
|
397
|
+
name: 'Monitoring Service',
|
|
398
|
+
status: 'pass',
|
|
399
|
+
message: `Running (PID: ${monitoringInfo.pid})`,
|
|
400
|
+
details: monitoringInfo
|
|
401
|
+
});
|
|
402
|
+
} else {
|
|
403
|
+
checks.push({
|
|
404
|
+
name: 'Monitoring Service',
|
|
405
|
+
status: 'warn',
|
|
406
|
+
message: 'Not running',
|
|
407
|
+
details: monitoringInfo
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
} catch (error) {
|
|
411
|
+
checks.push({
|
|
412
|
+
name: 'Monitoring Service',
|
|
413
|
+
status: 'warn',
|
|
414
|
+
message: 'Not configured',
|
|
415
|
+
details: {}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
this.results.categories.services.checks = checks;
|
|
420
|
+
this.results.categories.services.status = this.calculateCategoryStatus(checks);
|
|
421
|
+
|
|
422
|
+
spinner.succeed('Service check completed');
|
|
423
|
+
} catch (error) {
|
|
424
|
+
spinner.fail('Service check failed');
|
|
425
|
+
this.results.categories.services.status = 'error';
|
|
426
|
+
this.results.categories.services.checks.push({
|
|
427
|
+
name: 'Service Check',
|
|
428
|
+
status: 'error',
|
|
429
|
+
message: error.message
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
async getRedisServiceInfo() {
|
|
435
|
+
const info = execSync('redis-cli info server', { encoding: 'utf8' });
|
|
436
|
+
const lines = info.split('\r\n');
|
|
437
|
+
const result = {};
|
|
438
|
+
|
|
439
|
+
lines.forEach(line => {
|
|
440
|
+
if (line.includes(':')) {
|
|
441
|
+
const [key, value] = line.split(':');
|
|
442
|
+
result[key] = value;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
return {
|
|
447
|
+
pid: parseInt(result.process_id),
|
|
448
|
+
uptime: parseInt(result.uptime_in_seconds),
|
|
449
|
+
version: result.redis_version,
|
|
450
|
+
connected_clients: parseInt(result.connected_clients)
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async getDashboardServiceInfo() {
|
|
455
|
+
const configPath = join(this.configDir, 'services.json');
|
|
456
|
+
if (!existsSync(configPath)) {
|
|
457
|
+
return { running: false };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const services = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
461
|
+
const dashboardConfig = services.services?.dashboard;
|
|
462
|
+
|
|
463
|
+
if (!dashboardConfig?.enabled) {
|
|
464
|
+
return { running: false, disabled: true };
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
try {
|
|
468
|
+
const port = dashboardConfig.port || 3000;
|
|
469
|
+
const response = await fetch(`http://localhost:${port}/health`, { timeout: 5000 });
|
|
470
|
+
|
|
471
|
+
return {
|
|
472
|
+
running: response.ok,
|
|
473
|
+
port,
|
|
474
|
+
status: response.status
|
|
475
|
+
};
|
|
476
|
+
} catch (error) {
|
|
477
|
+
return { running: false, port: dashboardConfig.port || 3000 };
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
async getMonitoringServiceInfo() {
|
|
482
|
+
try {
|
|
483
|
+
const output = execSync('ps aux | grep claude-flow-monitor | grep -v grep', { encoding: 'utf8' });
|
|
484
|
+
if (output.trim()) {
|
|
485
|
+
const parts = output.trim().split(/\s+/);
|
|
486
|
+
return {
|
|
487
|
+
running: true,
|
|
488
|
+
pid: parseInt(parts[1]),
|
|
489
|
+
command: parts.slice(10).join(' ')
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
} catch (error) {
|
|
493
|
+
// Process not found
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return { running: false };
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
async checkNetwork() {
|
|
500
|
+
const spinner = ora('Checking network connectivity...').start();
|
|
501
|
+
|
|
502
|
+
try {
|
|
503
|
+
const checks = [];
|
|
504
|
+
|
|
505
|
+
// Check internet connectivity
|
|
506
|
+
try {
|
|
507
|
+
const response = await fetch('https://api.github.com', { timeout: 5000 });
|
|
508
|
+
checks.push({
|
|
509
|
+
name: 'Internet Connectivity',
|
|
510
|
+
status: response.ok ? 'pass' : 'warn',
|
|
511
|
+
message: response.ok ? 'Connected' : 'Limited connectivity',
|
|
512
|
+
details: { status: response.status }
|
|
513
|
+
});
|
|
514
|
+
} catch (error) {
|
|
515
|
+
checks.push({
|
|
516
|
+
name: 'Internet Connectivity',
|
|
517
|
+
status: 'warn',
|
|
518
|
+
message: 'No internet connection',
|
|
519
|
+
details: { error: error.message }
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Check npm registry
|
|
524
|
+
try {
|
|
525
|
+
execSync('npm ping', { stdio: 'ignore', timeout: 10000 });
|
|
526
|
+
checks.push({
|
|
527
|
+
name: 'NPM Registry',
|
|
528
|
+
status: 'pass',
|
|
529
|
+
message: 'Accessible',
|
|
530
|
+
details: {}
|
|
531
|
+
});
|
|
532
|
+
} catch (error) {
|
|
533
|
+
checks.push({
|
|
534
|
+
name: 'NPM Registry',
|
|
535
|
+
status: 'fail',
|
|
536
|
+
message: 'Not accessible',
|
|
537
|
+
details: { error: error.message }
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// Check port availability
|
|
542
|
+
const ports = [3000, 6379, 8080];
|
|
543
|
+
for (const port of ports) {
|
|
544
|
+
try {
|
|
545
|
+
const output = execSync(`netstat -an | grep :${port}`, { stdio: 'ignore' });
|
|
546
|
+
checks.push({
|
|
547
|
+
name: `Port ${port}`,
|
|
548
|
+
status: 'pass',
|
|
549
|
+
message: 'Available',
|
|
550
|
+
details: { port, inUse: true }
|
|
551
|
+
});
|
|
552
|
+
} catch (error) {
|
|
553
|
+
checks.push({
|
|
554
|
+
name: `Port ${port}`,
|
|
555
|
+
status: 'pass',
|
|
556
|
+
message: 'Available',
|
|
557
|
+
details: { port, inUse: false }
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
this.results.categories.network.checks = checks;
|
|
563
|
+
this.results.categories.network.status = this.calculateCategoryStatus(checks);
|
|
564
|
+
|
|
565
|
+
spinner.succeed('Network check completed');
|
|
566
|
+
} catch (error) {
|
|
567
|
+
spinner.fail('Network check failed');
|
|
568
|
+
this.results.categories.network.status = 'error';
|
|
569
|
+
this.results.categories.network.checks.push({
|
|
570
|
+
name: 'Network Check',
|
|
571
|
+
status: 'error',
|
|
572
|
+
message: error.message
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
calculateCategoryStatus(checks) {
|
|
578
|
+
const hasFailures = checks.some(check => check.status === 'fail' || check.status === 'error');
|
|
579
|
+
const hasWarnings = checks.some(check => check.status === 'warn');
|
|
580
|
+
|
|
581
|
+
if (hasFailures) return 'fail';
|
|
582
|
+
if (hasWarnings) return 'warn';
|
|
583
|
+
return 'pass';
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
calculateOverallStatus() {
|
|
587
|
+
const categories = Object.values(this.results.categories);
|
|
588
|
+
const hasFailures = categories.some(cat => cat.status === 'fail' || cat.status === 'error');
|
|
589
|
+
const hasWarnings = categories.some(cat => cat.status === 'warn');
|
|
590
|
+
|
|
591
|
+
if (hasFailures) this.results.overall = 'fail';
|
|
592
|
+
else if (hasWarnings) this.results.overall = 'warn';
|
|
593
|
+
else this.results.overall = 'pass';
|
|
594
|
+
|
|
595
|
+
// Collect warnings and errors
|
|
596
|
+
categories.forEach(category => {
|
|
597
|
+
category.checks.forEach(check => {
|
|
598
|
+
if (check.status === 'fail' || check.status === 'error') {
|
|
599
|
+
this.results.errors.push(`${check.name}: ${check.message}`);
|
|
600
|
+
} else if (check.status === 'warn') {
|
|
601
|
+
this.results.warnings.push(`${check.name}: ${check.message}`);
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// Generate recommendations
|
|
607
|
+
this.generateRecommendations();
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
generateRecommendations() {
|
|
611
|
+
const recommendations = [];
|
|
612
|
+
|
|
613
|
+
// System recommendations
|
|
614
|
+
const systemChecks = this.results.categories.system.checks;
|
|
615
|
+
const memoryCheck = systemChecks.find(check => check.name === 'Memory');
|
|
616
|
+
if (memoryCheck && memoryCheck.details.usage > 75) {
|
|
617
|
+
recommendations.push('Consider closing unused applications to free up memory');
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
const diskCheck = systemChecks.find(check => check.name === 'Disk Space');
|
|
621
|
+
if (diskCheck && diskCheck.details.free < 1024) { // Less than 1GB
|
|
622
|
+
recommendations.push('Free up disk space for optimal performance');
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// Dependency recommendations
|
|
626
|
+
const depChecks = this.results.categories.dependencies.checks;
|
|
627
|
+
const redisCheck = depChecks.find(check => check.name === 'redis-cli');
|
|
628
|
+
if (redisCheck && redisCheck.status === 'warn') {
|
|
629
|
+
recommendations.push('Install Redis for full functionality');
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// Service recommendations
|
|
633
|
+
const serviceChecks = this.results.categories.services.checks;
|
|
634
|
+
const dashboardCheck = serviceChecks.find(check => check.name === 'Dashboard Service');
|
|
635
|
+
if (dashboardCheck && dashboardCheck.status === 'warn') {
|
|
636
|
+
recommendations.push('Start the dashboard service for web interface');
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
this.results.recommendations = recommendations;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
displayResults() {
|
|
643
|
+
console.log('\n' + chalk.blue.bold('š Health Check Results\n'));
|
|
644
|
+
|
|
645
|
+
// Overall status
|
|
646
|
+
const statusColors = {
|
|
647
|
+
pass: chalk.green,
|
|
648
|
+
warn: chalk.yellow,
|
|
649
|
+
fail: chalk.red,
|
|
650
|
+
error: chalk.red
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
const statusIcons = {
|
|
654
|
+
pass: 'ā
',
|
|
655
|
+
warn: 'ā ļø',
|
|
656
|
+
fail: 'ā',
|
|
657
|
+
error: 'š„'
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
const overallColor = statusColors[this.results.overall];
|
|
661
|
+
const overallIcon = statusIcons[this.results.overall];
|
|
662
|
+
|
|
663
|
+
console.log(overallColor.bold(`${overallIcon} Overall Status: ${this.results.overall.toUpperCase()}\n`));
|
|
664
|
+
|
|
665
|
+
// Category results
|
|
666
|
+
for (const [categoryName, category] of Object.entries(this.results.categories)) {
|
|
667
|
+
const categoryColor = statusColors[category.status];
|
|
668
|
+
const categoryIcon = statusIcons[category.status];
|
|
669
|
+
|
|
670
|
+
console.log(categoryColor.bold(`${categoryIcon} ${categoryName.charAt(0).toUpperCase() + categoryName.slice(1)}:`));
|
|
671
|
+
|
|
672
|
+
category.checks.forEach(check => {
|
|
673
|
+
const checkColor = statusColors[check.status];
|
|
674
|
+
const checkIcon = statusIcons[check.status];
|
|
675
|
+
console.log(` ${checkColor} ${checkIcon} ${check.name}: ${check.message}`);
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
console.log();
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// Warnings
|
|
682
|
+
if (this.results.warnings.length > 0) {
|
|
683
|
+
console.log(chalk.yellow.bold('ā ļø Warnings:'));
|
|
684
|
+
this.results.warnings.forEach(warning => {
|
|
685
|
+
console.log(chalk.yellow(` ⢠${warning}`));
|
|
686
|
+
});
|
|
687
|
+
console.log();
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// Errors
|
|
691
|
+
if (this.results.errors.length > 0) {
|
|
692
|
+
console.log(chalk.red.bold('ā Errors:'));
|
|
693
|
+
this.results.errors.forEach(error => {
|
|
694
|
+
console.log(chalk.red(` ⢠${error}`));
|
|
695
|
+
});
|
|
696
|
+
console.log();
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// Recommendations
|
|
700
|
+
if (this.results.recommendations.length > 0) {
|
|
701
|
+
console.log(chalk.cyan.bold('š” Recommendations:'));
|
|
702
|
+
this.results.recommendations.forEach(rec => {
|
|
703
|
+
console.log(chalk.cyan(` ⢠${rec}`));
|
|
704
|
+
});
|
|
705
|
+
console.log();
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// Summary
|
|
709
|
+
const summary = this.results.overall === 'pass'
|
|
710
|
+
? chalk.green.bold('š All systems are healthy!')
|
|
711
|
+
: this.results.overall === 'warn'
|
|
712
|
+
? chalk.yellow.bold('ā ļø Some issues detected - review recommendations')
|
|
713
|
+
: chalk.red.bold('ā Critical issues found - immediate attention required');
|
|
714
|
+
|
|
715
|
+
console.log(boxen(summary, {
|
|
716
|
+
padding: 1,
|
|
717
|
+
margin: 1,
|
|
718
|
+
borderStyle: 'round',
|
|
719
|
+
borderColor: this.results.overall === 'pass' ? 'green' : this.results.overall === 'warn' ? 'yellow' : 'red'
|
|
720
|
+
}));
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
compareVersions(version1, version2) {
|
|
724
|
+
const v1parts = version1.split('.').map(Number);
|
|
725
|
+
const v2parts = version2.split('.').map(Number);
|
|
726
|
+
const maxLength = Math.max(v1parts.length, v2parts.length);
|
|
727
|
+
|
|
728
|
+
for (let i = 0; i < maxLength; i++) {
|
|
729
|
+
const v1part = v1parts[i] || 0;
|
|
730
|
+
const v2part = v2parts[i] || 0;
|
|
731
|
+
|
|
732
|
+
if (v1part > v2part) return 1;
|
|
733
|
+
if (v1part < v2part) return -1;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
return 0;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// CLI Interface with options
|
|
741
|
+
async function main() {
|
|
742
|
+
const options = {
|
|
743
|
+
verbose: process.argv.includes('--verbose'),
|
|
744
|
+
json: process.argv.includes('--json'),
|
|
745
|
+
quiet: process.argv.includes('--quiet')
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
const checker = new HealthChecker();
|
|
749
|
+
const results = await checker.check();
|
|
750
|
+
|
|
751
|
+
if (options.json) {
|
|
752
|
+
console.log(JSON.stringify(results, null, 2));
|
|
753
|
+
} else if (options.verbose) {
|
|
754
|
+
console.log(chalk.blue('\nš Detailed health report generated.'));
|
|
755
|
+
console.log(chalk.gray(`Check completed at: ${new Date().toISOString()}\n`));
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
process.exit(results.overall === 'pass' ? 0 : 1);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
762
|
+
main();
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export default HealthChecker;
|