claude-flow-novice 1.3.0 ā 1.3.2
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/.claude-flow-novice/preferences/generation.json +147 -0
- package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
- package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
- package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
- package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
- package/.claude-flow-novice/preferences/project-local.json +91 -0
- package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
- package/.claude-flow-novice/preferences/team-shared.json +195 -0
- package/.claude-flow-novice/preferences/user-global.json +247 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
- package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
- package/CLAUDE.md +81 -0
- package/README-NPM.md +0 -0
- package/package.json +11 -7
- 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/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/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/migration/README.md +434 -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/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/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-test-runner.js +698 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -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/run-phase3-compliance-tests.js +427 -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/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/verify-mcp-server.js +86 -0
- package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
- package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
- package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
- package/src/cli/simple-commands/__tests__/task.test.js +8 -0
- package/src/cli/simple-commands/agent.js +216 -0
- package/src/cli/simple-commands/analysis.js +570 -0
- package/src/cli/simple-commands/automation-executor.js +1603 -0
- package/src/cli/simple-commands/automation.js +627 -0
- package/src/cli/simple-commands/batch-manager.js +338 -0
- package/src/cli/simple-commands/claude-telemetry.js +311 -0
- package/src/cli/simple-commands/claude-track.js +102 -0
- package/src/cli/simple-commands/concurrent-display.js +348 -0
- package/src/cli/simple-commands/config.js +319 -0
- package/src/cli/simple-commands/coordination.js +307 -0
- package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
- package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
- package/src/cli/simple-commands/fix-hook-variables.js +363 -0
- package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
- package/src/cli/simple-commands/github/github-api.js +624 -0
- package/src/cli/simple-commands/github/init.js +543 -0
- package/src/cli/simple-commands/github.js +377 -0
- package/src/cli/simple-commands/goal.js +145 -0
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
- package/src/cli/simple-commands/hive-mind/communication.js +740 -0
- package/src/cli/simple-commands/hive-mind/core.js +1031 -0
- package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
- package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
- package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
- package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
- package/src/cli/simple-commands/hive-mind/queen.js +809 -0
- package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
- package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
- package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
- package/src/cli/simple-commands/hive-mind.js +3112 -0
- package/src/cli/simple-commands/hive.js +140 -0
- package/src/cli/simple-commands/hook-safety.js +671 -0
- package/src/cli/simple-commands/hooks.js +1268 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
- package/src/cli/simple-commands/init/README.md +106 -0
- package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
- package/src/cli/simple-commands/init/agent-copier.js +347 -0
- package/src/cli/simple-commands/init/batch-init.js +663 -0
- package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
- package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
- package/src/cli/simple-commands/init/help.js +110 -0
- package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
- package/src/cli/simple-commands/init/index.js +1953 -0
- package/src/cli/simple-commands/init/performance-monitor.js +344 -0
- package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
- package/src/cli/simple-commands/init/rollback/index.js +399 -0
- package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
- package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
- package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
- package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
- package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
- package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
- package/src/cli/simple-commands/init/sparc-structure.js +68 -0
- package/src/cli/simple-commands/init/template-copier.js +640 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
- package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
- package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
- package/src/cli/simple-commands/init/validation/index.js +388 -0
- package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
- package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
- package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
- package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
- package/src/cli/simple-commands/init.js +4 -0
- package/src/cli/simple-commands/mcp-health.js +163 -0
- package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
- package/src/cli/simple-commands/mcp.js +420 -0
- package/src/cli/simple-commands/memory-consolidation.js +631 -0
- package/src/cli/simple-commands/memory.js +345 -0
- package/src/cli/simple-commands/migrate-hooks.js +63 -0
- package/src/cli/simple-commands/monitor.js +417 -0
- package/src/cli/simple-commands/neural.js +148 -0
- package/src/cli/simple-commands/pair-autofix-only.js +755 -0
- package/src/cli/simple-commands/pair-basic.js +751 -0
- package/src/cli/simple-commands/pair-old.js +623 -0
- package/src/cli/simple-commands/pair-working.js +849 -0
- package/src/cli/simple-commands/pair.js +849 -0
- package/src/cli/simple-commands/performance-hooks.js +149 -0
- package/src/cli/simple-commands/performance-metrics.js +601 -0
- package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
- package/src/cli/simple-commands/process-ui.js +274 -0
- package/src/cli/simple-commands/realtime-update-system.js +659 -0
- package/src/cli/simple-commands/sparc/architecture.js +1750 -0
- package/src/cli/simple-commands/sparc/commands.js +575 -0
- package/src/cli/simple-commands/sparc/completion.js +1831 -0
- package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
- package/src/cli/simple-commands/sparc/index.js +321 -0
- package/src/cli/simple-commands/sparc/phase-base.js +430 -0
- package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
- package/src/cli/simple-commands/sparc/refinement.js +1856 -0
- package/src/cli/simple-commands/sparc/specification.js +736 -0
- package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
- package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
- package/src/cli/simple-commands/sparc-modes/code.js +148 -0
- package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
- package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
- package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
- package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
- package/src/cli/simple-commands/sparc-modes/index.js +201 -0
- package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
- package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
- package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
- package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
- package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
- package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
- package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
- package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
- package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
- package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
- package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
- package/src/cli/simple-commands/sparc.js +530 -0
- package/src/cli/simple-commands/start-ui.js +147 -0
- package/src/cli/simple-commands/start-wrapper.js +285 -0
- package/src/cli/simple-commands/start.js +2 -0
- package/src/cli/simple-commands/status.js +303 -0
- package/src/cli/simple-commands/stream-chain-clean.js +221 -0
- package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
- package/src/cli/simple-commands/stream-chain-real.js +408 -0
- package/src/cli/simple-commands/stream-chain-working.js +323 -0
- package/src/cli/simple-commands/stream-chain.js +491 -0
- package/src/cli/simple-commands/stream-processor.js +340 -0
- package/src/cli/simple-commands/swarm-executor.js +253 -0
- package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
- package/src/cli/simple-commands/swarm-ui.js +741 -0
- package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
- package/src/cli/simple-commands/swarm.js +2277 -0
- package/src/cli/simple-commands/task.js +228 -0
- package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
- package/src/cli/simple-commands/timestamp-fix.js +104 -0
- package/src/cli/simple-commands/token-tracker.js +372 -0
- package/src/cli/simple-commands/tool-execution-framework.js +555 -0
- package/src/cli/simple-commands/train-and-stream.js +354 -0
- package/src/cli/simple-commands/training-pipeline.js +874 -0
- package/src/cli/simple-commands/training.js +288 -0
- package/src/cli/simple-commands/verification-hooks.js +336 -0
- package/src/cli/simple-commands/verification-integration.js +464 -0
- package/src/cli/simple-commands/verification-training-integration.js +646 -0
- package/src/cli/simple-commands/verification.js +551 -0
- package/src/cli/simple-commands/web-server.js +929 -0
- package/src/cli/simple-commands/webui-validator.js +136 -0
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -0
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
#!/usr/bin/env -S deno run --allow-all
|
|
2
|
+
/**
|
|
3
|
+
* Advanced coverage analysis and reporting
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { parseArgs } from "https://deno.land/std@0.220.0/cli/parse_args.ts";
|
|
7
|
+
import { exists } from "https://deno.land/std@0.220.0/fs/exists.ts";
|
|
8
|
+
import { ensureDir } from "https://deno.land/std@0.220.0/fs/ensure_dir.ts";
|
|
9
|
+
import { walk } from "https://deno.land/std@0.220.0/fs/walk.ts";
|
|
10
|
+
|
|
11
|
+
interface CoverageData {
|
|
12
|
+
url: string;
|
|
13
|
+
ranges: Array<{
|
|
14
|
+
start: { line: number; col: number };
|
|
15
|
+
end: { line: number; col: number };
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface FileCoverage {
|
|
20
|
+
path: string;
|
|
21
|
+
totalLines: number;
|
|
22
|
+
coveredLines: number;
|
|
23
|
+
uncoveredLines: number[];
|
|
24
|
+
coverage: number;
|
|
25
|
+
functions: FunctionCoverage[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface FunctionCoverage {
|
|
29
|
+
name: string;
|
|
30
|
+
line: number;
|
|
31
|
+
covered: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface CoverageReport {
|
|
35
|
+
timestamp: string;
|
|
36
|
+
summary: {
|
|
37
|
+
totalFiles: number;
|
|
38
|
+
totalLines: number;
|
|
39
|
+
coveredLines: number;
|
|
40
|
+
coverage: number;
|
|
41
|
+
thresholds: {
|
|
42
|
+
statements: number;
|
|
43
|
+
branches: number;
|
|
44
|
+
functions: number;
|
|
45
|
+
lines: number;
|
|
46
|
+
};
|
|
47
|
+
passed: boolean;
|
|
48
|
+
};
|
|
49
|
+
files: FileCoverage[];
|
|
50
|
+
uncoveredFiles: string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class CoverageAnalyzer {
|
|
54
|
+
private sourceDir: string;
|
|
55
|
+
private coverageDir: string;
|
|
56
|
+
private outputDir: string;
|
|
57
|
+
private thresholds: {
|
|
58
|
+
statements: number;
|
|
59
|
+
branches: number;
|
|
60
|
+
functions: number;
|
|
61
|
+
lines: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
constructor(options: {
|
|
65
|
+
sourceDir: string;
|
|
66
|
+
coverageDir: string;
|
|
67
|
+
outputDir: string;
|
|
68
|
+
thresholds: {
|
|
69
|
+
statements: number;
|
|
70
|
+
branches: number;
|
|
71
|
+
functions: number;
|
|
72
|
+
lines: number;
|
|
73
|
+
};
|
|
74
|
+
}) {
|
|
75
|
+
this.sourceDir = options.sourceDir;
|
|
76
|
+
this.coverageDir = options.coverageDir;
|
|
77
|
+
this.outputDir = options.outputDir;
|
|
78
|
+
this.thresholds = options.thresholds;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async generateReport(): Promise<CoverageReport> {
|
|
82
|
+
console.log("š Analyzing coverage data...");
|
|
83
|
+
|
|
84
|
+
await ensureDir(this.outputDir);
|
|
85
|
+
|
|
86
|
+
// Load coverage data
|
|
87
|
+
const coverageData = await this.loadCoverageData();
|
|
88
|
+
|
|
89
|
+
// Get all source files
|
|
90
|
+
const sourceFiles = await this.getSourceFiles();
|
|
91
|
+
|
|
92
|
+
// Analyze each file
|
|
93
|
+
const fileAnalysis = await this.analyzeFiles(sourceFiles, coverageData);
|
|
94
|
+
|
|
95
|
+
// Find uncovered files
|
|
96
|
+
const coveredFiles = new Set(coverageData.map(d => this.normalizePath(d.url)));
|
|
97
|
+
const uncoveredFiles = sourceFiles.filter(file => !coveredFiles.has(file));
|
|
98
|
+
|
|
99
|
+
// Calculate summary
|
|
100
|
+
const summary = this.calculateSummary(fileAnalysis, uncoveredFiles.length);
|
|
101
|
+
|
|
102
|
+
const report: CoverageReport = {
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
summary,
|
|
105
|
+
files: fileAnalysis,
|
|
106
|
+
uncoveredFiles,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Generate various report formats
|
|
110
|
+
await this.generateHTMLReport(report);
|
|
111
|
+
await this.generateJSONReport(report);
|
|
112
|
+
await this.generateTextReport(report);
|
|
113
|
+
await this.generateBadges(report);
|
|
114
|
+
|
|
115
|
+
return report;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private async loadCoverageData(): Promise<CoverageData[]> {
|
|
119
|
+
const coverageFiles: CoverageData[] = [];
|
|
120
|
+
|
|
121
|
+
if (!await exists(this.coverageDir)) {
|
|
122
|
+
throw new Error(`Coverage directory not found: ${this.coverageDir}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for await (const entry of walk(this.coverageDir, {
|
|
126
|
+
exts: [".json"],
|
|
127
|
+
includeDirs: false
|
|
128
|
+
})) {
|
|
129
|
+
const content = await Deno.readTextFile(entry.path);
|
|
130
|
+
const data = JSON.parse(content);
|
|
131
|
+
|
|
132
|
+
if (data.url && data.ranges) {
|
|
133
|
+
coverageFiles.push(data);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return coverageFiles;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private async getSourceFiles(): Promise<string[]> {
|
|
141
|
+
const files: string[] = [];
|
|
142
|
+
|
|
143
|
+
for await (const entry of walk(this.sourceDir, {
|
|
144
|
+
exts: [".ts"],
|
|
145
|
+
includeDirs: false,
|
|
146
|
+
skip: [/\.test\.ts$/, /test\.ts$/, /tests?\//]
|
|
147
|
+
})) {
|
|
148
|
+
// Normalize path
|
|
149
|
+
const relativePath = entry.path.replace(Deno.cwd() + "/", "");
|
|
150
|
+
files.push(relativePath);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return files;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private normalizePath(url: string): string {
|
|
157
|
+
// Convert file:// URLs to relative paths
|
|
158
|
+
if (url.startsWith("file://")) {
|
|
159
|
+
url = url.replace("file://", "");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Remove leading slash and make relative to cwd
|
|
163
|
+
const cwd = Deno.cwd();
|
|
164
|
+
if (url.startsWith(cwd)) {
|
|
165
|
+
url = url.replace(cwd + "/", "");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return url;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private async analyzeFiles(sourceFiles: string[], coverageData: CoverageData[]): Promise<FileCoverage[]> {
|
|
172
|
+
const analysis: FileCoverage[] = [];
|
|
173
|
+
|
|
174
|
+
for (const file of sourceFiles) {
|
|
175
|
+
const coverage = coverageData.find(d => this.normalizePath(d.url) === file);
|
|
176
|
+
const fileAnalysis = await this.analyzeFile(file, coverage);
|
|
177
|
+
analysis.push(fileAnalysis);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return analysis;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private async analyzeFile(filePath: string, coverage?: CoverageData): Promise<FileCoverage> {
|
|
184
|
+
const content = await Deno.readTextFile(filePath);
|
|
185
|
+
const lines = content.split('\n');
|
|
186
|
+
const totalLines = lines.filter(line => line.trim() && !line.trim().startsWith('//')).length;
|
|
187
|
+
|
|
188
|
+
if (!coverage) {
|
|
189
|
+
return {
|
|
190
|
+
path: filePath,
|
|
191
|
+
totalLines,
|
|
192
|
+
coveredLines: 0,
|
|
193
|
+
uncoveredLines: Array.from({ length: totalLines }, (_, i) => i + 1),
|
|
194
|
+
coverage: 0,
|
|
195
|
+
functions: this.extractFunctions(content, false),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Analyze covered lines
|
|
200
|
+
const coveredLines = new Set<number>();
|
|
201
|
+
|
|
202
|
+
for (const range of coverage.ranges) {
|
|
203
|
+
for (let line = range.start.line; line <= range.end.line; line++) {
|
|
204
|
+
coveredLines.add(line);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const uncoveredLines: number[] = [];
|
|
209
|
+
for (let i = 1; i <= lines.length; i++) {
|
|
210
|
+
const line = lines[i - 1].trim();
|
|
211
|
+
if (line && !line.startsWith('//') && !coveredLines.has(i)) {
|
|
212
|
+
uncoveredLines.push(i);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const coveragePercent = totalLines > 0 ? ((totalLines - uncoveredLines.length) / totalLines) * 100 : 100;
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
path: filePath,
|
|
220
|
+
totalLines,
|
|
221
|
+
coveredLines: totalLines - uncoveredLines.length,
|
|
222
|
+
uncoveredLines,
|
|
223
|
+
coverage: coveragePercent,
|
|
224
|
+
functions: this.extractFunctions(content, true, coveredLines),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private extractFunctions(content: string, checkCoverage: boolean, coveredLines?: Set<number>): FunctionCoverage[] {
|
|
229
|
+
const functions: FunctionCoverage[] = [];
|
|
230
|
+
const lines = content.split('\n');
|
|
231
|
+
|
|
232
|
+
// Simple regex patterns for TypeScript functions
|
|
233
|
+
const patterns = [
|
|
234
|
+
/^\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)/,
|
|
235
|
+
/^\s*(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s+)?\(/,
|
|
236
|
+
/^\s*(?:public|private|protected)?\s*(?:async\s+)?(\w+)\s*\(/,
|
|
237
|
+
/^\s*(\w+)\s*:\s*\([^)]*\)\s*=>/,
|
|
238
|
+
];
|
|
239
|
+
|
|
240
|
+
for (let i = 0; i < lines.length; i++) {
|
|
241
|
+
const line = lines[i];
|
|
242
|
+
|
|
243
|
+
for (const pattern of patterns) {
|
|
244
|
+
const match = line.match(pattern);
|
|
245
|
+
if (match) {
|
|
246
|
+
const functionName = match[1];
|
|
247
|
+
const lineNumber = i + 1;
|
|
248
|
+
const covered = checkCoverage ? (coveredLines?.has(lineNumber) ?? false) : false;
|
|
249
|
+
|
|
250
|
+
functions.push({
|
|
251
|
+
name: functionName,
|
|
252
|
+
line: lineNumber,
|
|
253
|
+
covered,
|
|
254
|
+
});
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return functions;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
private calculateSummary(files: FileCoverage[], uncoveredFileCount: number): CoverageReport['summary'] {
|
|
264
|
+
const totalFiles = files.length + uncoveredFileCount;
|
|
265
|
+
const totalLines = files.reduce((sum, file) => sum + file.totalLines, 0);
|
|
266
|
+
const coveredLines = files.reduce((sum, file) => sum + file.coveredLines, 0);
|
|
267
|
+
const coverage = totalLines > 0 ? (coveredLines / totalLines) * 100 : 100;
|
|
268
|
+
|
|
269
|
+
const passed = coverage >= this.thresholds.lines;
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
totalFiles,
|
|
273
|
+
totalLines,
|
|
274
|
+
coveredLines,
|
|
275
|
+
coverage,
|
|
276
|
+
thresholds: this.thresholds,
|
|
277
|
+
passed,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private async generateHTMLReport(report: CoverageReport): Promise<void> {
|
|
282
|
+
const fileRows = report.files
|
|
283
|
+
.sort((a, b) => a.coverage - b.coverage)
|
|
284
|
+
.map(file => {
|
|
285
|
+
const coverageClass = file.coverage >= 80 ? 'high' : file.coverage >= 60 ? 'medium' : 'low';
|
|
286
|
+
const coverageBar = `<div class="coverage-bar"><div class="coverage-fill ${coverageClass}" style="width: ${file.coverage}%"></div></div>`;
|
|
287
|
+
|
|
288
|
+
return `
|
|
289
|
+
<tr class="${coverageClass}">
|
|
290
|
+
<td><a href="#file-${file.path.replace(/[^a-zA-Z0-9]/g, '-')}">${file.path}</a></td>
|
|
291
|
+
<td>${file.coverage.toFixed(2)}%</td>
|
|
292
|
+
<td>${coverageBar}</td>
|
|
293
|
+
<td>${file.coveredLines}/${file.totalLines}</td>
|
|
294
|
+
<td>${file.uncoveredLines.length}</td>
|
|
295
|
+
<td>${file.functions.filter(f => f.covered).length}/${file.functions.length}</td>
|
|
296
|
+
</tr>`;
|
|
297
|
+
}).join('');
|
|
298
|
+
|
|
299
|
+
const uncoveredRows = report.uncoveredFiles.map(file => `
|
|
300
|
+
<tr class="uncovered">
|
|
301
|
+
<td>${file}</td>
|
|
302
|
+
<td>0%</td>
|
|
303
|
+
<td><div class="coverage-bar"><div class="coverage-fill low" style="width: 0%"></div></div></td>
|
|
304
|
+
<td>0/0</td>
|
|
305
|
+
<td>-</td>
|
|
306
|
+
<td>0/0</td>
|
|
307
|
+
</tr>
|
|
308
|
+
`).join('');
|
|
309
|
+
|
|
310
|
+
const fileDetails = report.files.map(file => {
|
|
311
|
+
const uncoveredLinesStr = file.uncoveredLines.length > 0
|
|
312
|
+
? file.uncoveredLines.slice(0, 20).join(', ') + (file.uncoveredLines.length > 20 ? '...' : '')
|
|
313
|
+
: 'All lines covered';
|
|
314
|
+
|
|
315
|
+
const functionRows = file.functions.map(func => `
|
|
316
|
+
<tr class="${func.covered ? 'covered' : 'uncovered'}">
|
|
317
|
+
<td>${func.name}</td>
|
|
318
|
+
<td>${func.line}</td>
|
|
319
|
+
<td>${func.covered ? 'ā
' : 'ā'}</td>
|
|
320
|
+
</tr>
|
|
321
|
+
`).join('');
|
|
322
|
+
|
|
323
|
+
return `
|
|
324
|
+
<div class="file-detail" id="file-${file.path.replace(/[^a-zA-Z0-9]/g, '-')}">
|
|
325
|
+
<h3>š ${file.path}</h3>
|
|
326
|
+
<div class="file-summary">
|
|
327
|
+
<div class="metric">
|
|
328
|
+
<span class="label">Coverage:</span>
|
|
329
|
+
<span class="value ${file.coverage >= 80 ? 'high' : file.coverage >= 60 ? 'medium' : 'low'}">${file.coverage.toFixed(2)}%</span>
|
|
330
|
+
</div>
|
|
331
|
+
<div class="metric">
|
|
332
|
+
<span class="label">Lines:</span>
|
|
333
|
+
<span class="value">${file.coveredLines}/${file.totalLines}</span>
|
|
334
|
+
</div>
|
|
335
|
+
<div class="metric">
|
|
336
|
+
<span class="label">Functions:</span>
|
|
337
|
+
<span class="value">${file.functions.filter(f => f.covered).length}/${file.functions.length}</span>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
|
|
341
|
+
${file.uncoveredLines.length > 0 ? `
|
|
342
|
+
<div class="uncovered-lines">
|
|
343
|
+
<h4>Uncovered Lines:</h4>
|
|
344
|
+
<p>${uncoveredLinesStr}</p>
|
|
345
|
+
</div>
|
|
346
|
+
` : ''}
|
|
347
|
+
|
|
348
|
+
${file.functions.length > 0 ? `
|
|
349
|
+
<div class="functions">
|
|
350
|
+
<h4>Functions:</h4>
|
|
351
|
+
<table>
|
|
352
|
+
<thead>
|
|
353
|
+
<tr>
|
|
354
|
+
<th>Function</th>
|
|
355
|
+
<th>Line</th>
|
|
356
|
+
<th>Covered</th>
|
|
357
|
+
</tr>
|
|
358
|
+
</thead>
|
|
359
|
+
<tbody>
|
|
360
|
+
${functionRows}
|
|
361
|
+
</tbody>
|
|
362
|
+
</table>
|
|
363
|
+
</div>
|
|
364
|
+
` : ''}
|
|
365
|
+
</div>`;
|
|
366
|
+
}).join('');
|
|
367
|
+
|
|
368
|
+
const html = `<!DOCTYPE html>
|
|
369
|
+
<html>
|
|
370
|
+
<head>
|
|
371
|
+
<title>Claude-Flow Coverage Report</title>
|
|
372
|
+
<style>
|
|
373
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; padding: 20px; background: #f8f9fa; }
|
|
374
|
+
.header { background: white; padding: 30px; border-radius: 8px; margin-bottom: 30px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
|
375
|
+
.header h1 { margin: 0; color: #2c3e50; }
|
|
376
|
+
.header .timestamp { color: #7f8c8d; margin-top: 5px; }
|
|
377
|
+
|
|
378
|
+
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
|
|
379
|
+
.summary-card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); text-align: center; }
|
|
380
|
+
.summary-card h3 { margin: 0 0 10px 0; color: #2c3e50; font-size: 14px; text-transform: uppercase; }
|
|
381
|
+
.summary-card .value { font-size: 32px; font-weight: bold; margin: 10px 0; }
|
|
382
|
+
.summary-card .value.high { color: #27ae60; }
|
|
383
|
+
.summary-card .value.medium { color: #f39c12; }
|
|
384
|
+
.summary-card .value.low { color: #e74c3c; }
|
|
385
|
+
.summary-card .threshold { font-size: 12px; color: #7f8c8d; }
|
|
386
|
+
|
|
387
|
+
.coverage-status { padding: 15px; border-radius: 8px; margin-bottom: 30px; text-align: center; font-weight: bold; }
|
|
388
|
+
.coverage-status.passed { background: #d4edda; color: #155724; }
|
|
389
|
+
.coverage-status.failed { background: #f8d7da; color: #721c24; }
|
|
390
|
+
|
|
391
|
+
.files-table { background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 30px; }
|
|
392
|
+
.files-table h2 { margin: 0; padding: 20px; background: #2c3e50; color: white; }
|
|
393
|
+
table { width: 100%; border-collapse: collapse; }
|
|
394
|
+
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ecf0f1; }
|
|
395
|
+
th { background: #f8f9fa; font-weight: 600; }
|
|
396
|
+
|
|
397
|
+
.coverage-bar { width: 100px; height: 20px; background: #ecf0f1; border-radius: 10px; overflow: hidden; }
|
|
398
|
+
.coverage-fill { height: 100%; transition: width 0.3s ease; }
|
|
399
|
+
.coverage-fill.high { background: linear-gradient(90deg, #27ae60, #2ecc71); }
|
|
400
|
+
.coverage-fill.medium { background: linear-gradient(90deg, #f39c12, #e67e22); }
|
|
401
|
+
.coverage-fill.low { background: linear-gradient(90deg, #e74c3c, #c0392b); }
|
|
402
|
+
|
|
403
|
+
.high { background-color: rgba(39, 174, 96, 0.1); }
|
|
404
|
+
.medium { background-color: rgba(243, 156, 18, 0.1); }
|
|
405
|
+
.low { background-color: rgba(231, 76, 60, 0.1); }
|
|
406
|
+
.uncovered { background-color: rgba(231, 76, 60, 0.2); }
|
|
407
|
+
|
|
408
|
+
.file-detail { background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
|
409
|
+
.file-detail h3 { margin: 0 0 15px 0; color: #2c3e50; }
|
|
410
|
+
.file-summary { display: flex; gap: 20px; margin-bottom: 20px; }
|
|
411
|
+
.metric { display: flex; flex-direction: column; }
|
|
412
|
+
.metric .label { font-size: 12px; color: #7f8c8d; text-transform: uppercase; }
|
|
413
|
+
.metric .value { font-size: 18px; font-weight: bold; margin-top: 5px; }
|
|
414
|
+
|
|
415
|
+
.uncovered-lines { margin: 15px 0; }
|
|
416
|
+
.uncovered-lines h4 { margin: 0 0 10px 0; color: #e74c3c; }
|
|
417
|
+
.functions { margin: 15px 0; }
|
|
418
|
+
.functions h4 { margin: 0 0 10px 0; color: #2c3e50; }
|
|
419
|
+
.functions table { margin-top: 10px; }
|
|
420
|
+
.covered { background-color: rgba(39, 174, 96, 0.1); }
|
|
421
|
+
|
|
422
|
+
.footer { text-align: center; margin-top: 40px; color: #7f8c8d; }
|
|
423
|
+
</style>
|
|
424
|
+
</head>
|
|
425
|
+
<body>
|
|
426
|
+
<div class="header">
|
|
427
|
+
<h1>š Claude-Flow Coverage Report</h1>
|
|
428
|
+
<div class="timestamp">Generated: ${report.timestamp}</div>
|
|
429
|
+
</div>
|
|
430
|
+
|
|
431
|
+
<div class="coverage-status ${report.summary.passed ? 'passed' : 'failed'}">
|
|
432
|
+
${report.summary.passed ? 'ā
Coverage thresholds passed' : 'ā Coverage thresholds not met'}
|
|
433
|
+
</div>
|
|
434
|
+
|
|
435
|
+
<div class="summary">
|
|
436
|
+
<div class="summary-card">
|
|
437
|
+
<h3>Overall Coverage</h3>
|
|
438
|
+
<div class="value ${report.summary.coverage >= 80 ? 'high' : report.summary.coverage >= 60 ? 'medium' : 'low'}">${report.summary.coverage.toFixed(2)}%</div>
|
|
439
|
+
<div class="threshold">Threshold: ${this.thresholds.lines}%</div>
|
|
440
|
+
</div>
|
|
441
|
+
<div class="summary-card">
|
|
442
|
+
<h3>Total Files</h3>
|
|
443
|
+
<div class="value">${report.summary.totalFiles}</div>
|
|
444
|
+
</div>
|
|
445
|
+
<div class="summary-card">
|
|
446
|
+
<h3>Covered Lines</h3>
|
|
447
|
+
<div class="value">${report.summary.coveredLines}</div>
|
|
448
|
+
<div class="threshold">of ${report.summary.totalLines}</div>
|
|
449
|
+
</div>
|
|
450
|
+
<div class="summary-card">
|
|
451
|
+
<h3>Uncovered Files</h3>
|
|
452
|
+
<div class="value ${report.uncoveredFiles.length === 0 ? 'high' : 'low'}">${report.uncoveredFiles.length}</div>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
|
|
456
|
+
<div class="files-table">
|
|
457
|
+
<h2>š File Coverage</h2>
|
|
458
|
+
<table>
|
|
459
|
+
<thead>
|
|
460
|
+
<tr>
|
|
461
|
+
<th>File</th>
|
|
462
|
+
<th>Coverage</th>
|
|
463
|
+
<th>Progress</th>
|
|
464
|
+
<th>Lines</th>
|
|
465
|
+
<th>Uncovered</th>
|
|
466
|
+
<th>Functions</th>
|
|
467
|
+
</tr>
|
|
468
|
+
</thead>
|
|
469
|
+
<tbody>
|
|
470
|
+
${fileRows}
|
|
471
|
+
${uncoveredRows}
|
|
472
|
+
</tbody>
|
|
473
|
+
</table>
|
|
474
|
+
</div>
|
|
475
|
+
|
|
476
|
+
<div class="file-details">
|
|
477
|
+
<h2>š File Details</h2>
|
|
478
|
+
${fileDetails}
|
|
479
|
+
</div>
|
|
480
|
+
|
|
481
|
+
<div class="footer">
|
|
482
|
+
<p>Claude-Flow Coverage Report - Advanced AI Agent Orchestration System</p>
|
|
483
|
+
</div>
|
|
484
|
+
</body>
|
|
485
|
+
</html>`;
|
|
486
|
+
|
|
487
|
+
await Deno.writeTextFile(`${this.outputDir}/coverage-detailed.html`, html);
|
|
488
|
+
console.log(" ā
Detailed HTML coverage report generated");
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
private async generateJSONReport(report: CoverageReport): Promise<void> {
|
|
492
|
+
await Deno.writeTextFile(
|
|
493
|
+
`${this.outputDir}/coverage-report.json`,
|
|
494
|
+
JSON.stringify(report, null, 2)
|
|
495
|
+
);
|
|
496
|
+
console.log(" ā
JSON coverage report generated");
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
private async generateTextReport(report: CoverageReport): Promise<void> {
|
|
500
|
+
const lines: string[] = [];
|
|
501
|
+
|
|
502
|
+
lines.push("š CLAUDE-FLOW COVERAGE REPORT");
|
|
503
|
+
lines.push("=".repeat(50));
|
|
504
|
+
lines.push(`Generated: ${report.timestamp}`);
|
|
505
|
+
lines.push("");
|
|
506
|
+
|
|
507
|
+
lines.push("š SUMMARY");
|
|
508
|
+
lines.push("-".repeat(20));
|
|
509
|
+
lines.push(`Overall Coverage: ${report.summary.coverage.toFixed(2)}%`);
|
|
510
|
+
lines.push(`Total Files: ${report.summary.totalFiles}`);
|
|
511
|
+
lines.push(`Covered Lines: ${report.summary.coveredLines}/${report.summary.totalLines}`);
|
|
512
|
+
lines.push(`Uncovered Files: ${report.uncoveredFiles.length}`);
|
|
513
|
+
lines.push("");
|
|
514
|
+
|
|
515
|
+
lines.push("šÆ THRESHOLDS");
|
|
516
|
+
lines.push("-".repeat(20));
|
|
517
|
+
lines.push(`Lines: ${report.summary.coverage.toFixed(2)}% (threshold: ${report.summary.thresholds.lines}%)`);
|
|
518
|
+
lines.push(`Status: ${report.summary.passed ? 'ā
PASSED' : 'ā FAILED'}`);
|
|
519
|
+
lines.push("");
|
|
520
|
+
|
|
521
|
+
if (report.files.length > 0) {
|
|
522
|
+
lines.push("š FILES BY COVERAGE");
|
|
523
|
+
lines.push("-".repeat(20));
|
|
524
|
+
|
|
525
|
+
const sortedFiles = [...report.files].sort((a, b) => a.coverage - b.coverage);
|
|
526
|
+
|
|
527
|
+
for (const file of sortedFiles) {
|
|
528
|
+
const status = file.coverage >= 80 ? 'ā
' : file.coverage >= 60 ? 'ā ļø' : 'ā';
|
|
529
|
+
lines.push(`${status} ${file.path}: ${file.coverage.toFixed(2)}% (${file.coveredLines}/${file.totalLines} lines)`);
|
|
530
|
+
|
|
531
|
+
if (file.uncoveredLines.length > 0 && file.uncoveredLines.length <= 10) {
|
|
532
|
+
lines.push(` Uncovered lines: ${file.uncoveredLines.join(', ')}`);
|
|
533
|
+
} else if (file.uncoveredLines.length > 10) {
|
|
534
|
+
lines.push(` Uncovered lines: ${file.uncoveredLines.slice(0, 10).join(', ')}... (+${file.uncoveredLines.length - 10} more)`);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
lines.push("");
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (report.uncoveredFiles.length > 0) {
|
|
541
|
+
lines.push("š« UNCOVERED FILES");
|
|
542
|
+
lines.push("-".repeat(20));
|
|
543
|
+
for (const file of report.uncoveredFiles) {
|
|
544
|
+
lines.push(`ā ${file}`);
|
|
545
|
+
}
|
|
546
|
+
lines.push("");
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
lines.push("š” RECOMMENDATIONS");
|
|
550
|
+
lines.push("-".repeat(20));
|
|
551
|
+
|
|
552
|
+
const lowCoverageFiles = report.files.filter(f => f.coverage < 60);
|
|
553
|
+
if (lowCoverageFiles.length > 0) {
|
|
554
|
+
lines.push("⢠Focus on improving coverage for these files:");
|
|
555
|
+
for (const file of lowCoverageFiles.slice(0, 5)) {
|
|
556
|
+
lines.push(` - ${file.path} (${file.coverage.toFixed(2)}%)`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
if (report.uncoveredFiles.length > 0) {
|
|
561
|
+
lines.push("⢠Add tests for uncovered files:");
|
|
562
|
+
for (const file of report.uncoveredFiles.slice(0, 5)) {
|
|
563
|
+
lines.push(` - ${file}`);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (report.summary.coverage >= 90) {
|
|
568
|
+
lines.push("⢠Excellent coverage! Consider adding edge case tests.");
|
|
569
|
+
} else if (report.summary.coverage >= 80) {
|
|
570
|
+
lines.push("⢠Good coverage! Focus on critical paths and error handling.");
|
|
571
|
+
} else {
|
|
572
|
+
lines.push("⢠Coverage needs improvement. Add tests for core functionality first.");
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
await Deno.writeTextFile(`${this.outputDir}/coverage-report.txt`, lines.join('\n'));
|
|
576
|
+
console.log(" ā
Text coverage report generated");
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
private async generateBadges(report: CoverageReport): Promise<void> {
|
|
580
|
+
const coverage = report.summary.coverage;
|
|
581
|
+
const color = coverage >= 90 ? 'brightgreen' :
|
|
582
|
+
coverage >= 80 ? 'green' :
|
|
583
|
+
coverage >= 70 ? 'yellow' :
|
|
584
|
+
coverage >= 60 ? 'orange' : 'red';
|
|
585
|
+
|
|
586
|
+
const badgeUrl = `https://img.shields.io/badge/coverage-${coverage.toFixed(1)}%25-${color}`;
|
|
587
|
+
|
|
588
|
+
const badgeMarkdown = ``;
|
|
589
|
+
const badgeHTML = `<img src="${badgeUrl}" alt="Coverage ${coverage.toFixed(1)}%">`;
|
|
590
|
+
|
|
591
|
+
const badges = {
|
|
592
|
+
url: badgeUrl,
|
|
593
|
+
markdown: badgeMarkdown,
|
|
594
|
+
html: badgeHTML,
|
|
595
|
+
coverage: coverage.toFixed(1),
|
|
596
|
+
color,
|
|
597
|
+
status: report.summary.passed ? 'passed' : 'failed',
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
await Deno.writeTextFile(
|
|
601
|
+
`${this.outputDir}/coverage-badges.json`,
|
|
602
|
+
JSON.stringify(badges, null, 2)
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
console.log(" ā
Coverage badges generated");
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
async function main(): Promise<void> {
|
|
610
|
+
const args = parseArgs(Deno.args, {
|
|
611
|
+
string: ["source-dir", "coverage-dir", "output-dir"],
|
|
612
|
+
boolean: ["help"],
|
|
613
|
+
default: {
|
|
614
|
+
"source-dir": "./src",
|
|
615
|
+
"coverage-dir": "./tests/results/coverage",
|
|
616
|
+
"output-dir": "./tests/results",
|
|
617
|
+
},
|
|
618
|
+
alias: {
|
|
619
|
+
h: "help",
|
|
620
|
+
s: "source-dir",
|
|
621
|
+
c: "coverage-dir",
|
|
622
|
+
o: "output-dir",
|
|
623
|
+
},
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
if (args.help) {
|
|
627
|
+
console.log(`
|
|
628
|
+
š Claude-Flow Coverage Analysis Tool
|
|
629
|
+
|
|
630
|
+
USAGE:
|
|
631
|
+
coverage-report.ts [OPTIONS]
|
|
632
|
+
|
|
633
|
+
OPTIONS:
|
|
634
|
+
--source-dir, -s Source code directory (default: ./src)
|
|
635
|
+
--coverage-dir, -c Coverage data directory (default: ./tests/results/coverage)
|
|
636
|
+
--output-dir, -o Output directory for reports (default: ./tests/results)
|
|
637
|
+
--help, -h Show this help
|
|
638
|
+
|
|
639
|
+
EXAMPLES:
|
|
640
|
+
# Generate coverage report with defaults
|
|
641
|
+
./scripts/coverage-report.ts
|
|
642
|
+
|
|
643
|
+
# Custom directories
|
|
644
|
+
./scripts/coverage-report.ts --source-dir ./lib --coverage-dir ./coverage --output-dir ./reports
|
|
645
|
+
`);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
const thresholds = {
|
|
650
|
+
statements: 80,
|
|
651
|
+
branches: 75,
|
|
652
|
+
functions: 80,
|
|
653
|
+
lines: 80,
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
const analyzer = new CoverageAnalyzer({
|
|
657
|
+
sourceDir: args["source-dir"],
|
|
658
|
+
coverageDir: args["coverage-dir"],
|
|
659
|
+
outputDir: args["output-dir"],
|
|
660
|
+
thresholds,
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
try {
|
|
664
|
+
const report = await analyzer.generateReport();
|
|
665
|
+
|
|
666
|
+
console.log("\nš COVERAGE SUMMARY");
|
|
667
|
+
console.log("=".repeat(40));
|
|
668
|
+
console.log(`Overall Coverage: ${report.summary.coverage.toFixed(2)}%`);
|
|
669
|
+
console.log(`Total Files: ${report.summary.totalFiles}`);
|
|
670
|
+
console.log(`Covered Lines: ${report.summary.coveredLines}/${report.summary.totalLines}`);
|
|
671
|
+
console.log(`Uncovered Files: ${report.uncoveredFiles.length}`);
|
|
672
|
+
|
|
673
|
+
const status = report.summary.passed ? "ā
PASSED" : "ā FAILED";
|
|
674
|
+
console.log(`Status: ${status}`);
|
|
675
|
+
|
|
676
|
+
console.log(`\nš Reports generated in: ${args["output-dir"]}`);
|
|
677
|
+
console.log(` - Detailed HTML: coverage-detailed.html`);
|
|
678
|
+
console.log(` - JSON Data: coverage-report.json`);
|
|
679
|
+
console.log(` - Text Summary: coverage-report.txt`);
|
|
680
|
+
console.log(` - Badges: coverage-badges.json`);
|
|
681
|
+
|
|
682
|
+
Deno.exit(report.summary.passed ? 0 : 1);
|
|
683
|
+
|
|
684
|
+
} catch (error) {
|
|
685
|
+
console.error("ā Coverage analysis failed:", error.message);
|
|
686
|
+
Deno.exit(1);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (import.meta.main) {
|
|
691
|
+
main();
|
|
692
|
+
}
|