@devness/coverit 0.1.0

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 (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -0
  3. package/dist/agents/orchestrator.d.ts +21 -0
  4. package/dist/agents/orchestrator.d.ts.map +1 -0
  5. package/dist/agents/orchestrator.js +235 -0
  6. package/dist/agents/orchestrator.js.map +1 -0
  7. package/dist/agents/reporter.d.ts +13 -0
  8. package/dist/agents/reporter.d.ts.map +1 -0
  9. package/dist/agents/reporter.js +323 -0
  10. package/dist/agents/reporter.js.map +1 -0
  11. package/dist/ai/anthropic-provider.d.ts +19 -0
  12. package/dist/ai/anthropic-provider.d.ts.map +1 -0
  13. package/dist/ai/anthropic-provider.js +83 -0
  14. package/dist/ai/anthropic-provider.js.map +1 -0
  15. package/dist/ai/claude-cli-provider.d.ts +22 -0
  16. package/dist/ai/claude-cli-provider.d.ts.map +1 -0
  17. package/dist/ai/claude-cli-provider.js +197 -0
  18. package/dist/ai/claude-cli-provider.js.map +1 -0
  19. package/dist/ai/index.d.ts +15 -0
  20. package/dist/ai/index.d.ts.map +1 -0
  21. package/dist/ai/index.js +16 -0
  22. package/dist/ai/index.js.map +1 -0
  23. package/dist/ai/ollama-provider.d.ts +17 -0
  24. package/dist/ai/ollama-provider.d.ts.map +1 -0
  25. package/dist/ai/ollama-provider.js +88 -0
  26. package/dist/ai/ollama-provider.js.map +1 -0
  27. package/dist/ai/openai-provider.d.ts +20 -0
  28. package/dist/ai/openai-provider.d.ts.map +1 -0
  29. package/dist/ai/openai-provider.js +74 -0
  30. package/dist/ai/openai-provider.js.map +1 -0
  31. package/dist/ai/prompts.d.ts +36 -0
  32. package/dist/ai/prompts.d.ts.map +1 -0
  33. package/dist/ai/prompts.js +259 -0
  34. package/dist/ai/prompts.js.map +1 -0
  35. package/dist/ai/provider-factory.d.ts +26 -0
  36. package/dist/ai/provider-factory.d.ts.map +1 -0
  37. package/dist/ai/provider-factory.js +111 -0
  38. package/dist/ai/provider-factory.js.map +1 -0
  39. package/dist/ai/types.d.ts +37 -0
  40. package/dist/ai/types.d.ts.map +1 -0
  41. package/dist/ai/types.js +10 -0
  42. package/dist/ai/types.js.map +1 -0
  43. package/dist/analysis/code-scanner.d.ts +9 -0
  44. package/dist/analysis/code-scanner.d.ts.map +1 -0
  45. package/dist/analysis/code-scanner.js +409 -0
  46. package/dist/analysis/code-scanner.js.map +1 -0
  47. package/dist/analysis/dependency-graph.d.ts +9 -0
  48. package/dist/analysis/dependency-graph.d.ts.map +1 -0
  49. package/dist/analysis/dependency-graph.js +149 -0
  50. package/dist/analysis/dependency-graph.js.map +1 -0
  51. package/dist/analysis/diff-analyzer.d.ts +9 -0
  52. package/dist/analysis/diff-analyzer.d.ts.map +1 -0
  53. package/dist/analysis/diff-analyzer.js +232 -0
  54. package/dist/analysis/diff-analyzer.js.map +1 -0
  55. package/dist/analysis/index.d.ts +5 -0
  56. package/dist/analysis/index.d.ts.map +1 -0
  57. package/dist/analysis/index.js +5 -0
  58. package/dist/analysis/index.js.map +1 -0
  59. package/dist/analysis/strategy-planner.d.ts +11 -0
  60. package/dist/analysis/strategy-planner.d.ts.map +1 -0
  61. package/dist/analysis/strategy-planner.js +384 -0
  62. package/dist/analysis/strategy-planner.js.map +1 -0
  63. package/dist/cli/index.d.ts +9 -0
  64. package/dist/cli/index.d.ts.map +1 -0
  65. package/dist/cli/index.js +288 -0
  66. package/dist/cli/index.js.map +1 -0
  67. package/dist/executors/base-executor.d.ts +35 -0
  68. package/dist/executors/base-executor.d.ts.map +1 -0
  69. package/dist/executors/base-executor.js +138 -0
  70. package/dist/executors/base-executor.js.map +1 -0
  71. package/dist/executors/browser-runner.d.ts +24 -0
  72. package/dist/executors/browser-runner.d.ts.map +1 -0
  73. package/dist/executors/browser-runner.js +194 -0
  74. package/dist/executors/browser-runner.js.map +1 -0
  75. package/dist/executors/cloud-runner.d.ts +41 -0
  76. package/dist/executors/cloud-runner.d.ts.map +1 -0
  77. package/dist/executors/cloud-runner.js +153 -0
  78. package/dist/executors/cloud-runner.js.map +1 -0
  79. package/dist/executors/index.d.ts +12 -0
  80. package/dist/executors/index.d.ts.map +1 -0
  81. package/dist/executors/index.js +28 -0
  82. package/dist/executors/index.js.map +1 -0
  83. package/dist/executors/local-runner.d.ts +40 -0
  84. package/dist/executors/local-runner.d.ts.map +1 -0
  85. package/dist/executors/local-runner.js +395 -0
  86. package/dist/executors/local-runner.js.map +1 -0
  87. package/dist/executors/reporter.d.ts +6 -0
  88. package/dist/executors/reporter.d.ts.map +1 -0
  89. package/dist/executors/reporter.js +6 -0
  90. package/dist/executors/reporter.js.map +1 -0
  91. package/dist/executors/simulator-runner.d.ts +30 -0
  92. package/dist/executors/simulator-runner.d.ts.map +1 -0
  93. package/dist/executors/simulator-runner.js +339 -0
  94. package/dist/executors/simulator-runner.js.map +1 -0
  95. package/dist/generators/api-test.d.ts +22 -0
  96. package/dist/generators/api-test.d.ts.map +1 -0
  97. package/dist/generators/api-test.js +235 -0
  98. package/dist/generators/api-test.js.map +1 -0
  99. package/dist/generators/base-generator.d.ts +79 -0
  100. package/dist/generators/base-generator.d.ts.map +1 -0
  101. package/dist/generators/base-generator.js +234 -0
  102. package/dist/generators/base-generator.js.map +1 -0
  103. package/dist/generators/desktop-test.d.ts +22 -0
  104. package/dist/generators/desktop-test.d.ts.map +1 -0
  105. package/dist/generators/desktop-test.js +290 -0
  106. package/dist/generators/desktop-test.js.map +1 -0
  107. package/dist/generators/e2e-browser.d.ts +19 -0
  108. package/dist/generators/e2e-browser.d.ts.map +1 -0
  109. package/dist/generators/e2e-browser.js +233 -0
  110. package/dist/generators/e2e-browser.js.map +1 -0
  111. package/dist/generators/index.d.ts +21 -0
  112. package/dist/generators/index.d.ts.map +1 -0
  113. package/dist/generators/index.js +66 -0
  114. package/dist/generators/index.js.map +1 -0
  115. package/dist/generators/mobile-test.d.ts +22 -0
  116. package/dist/generators/mobile-test.d.ts.map +1 -0
  117. package/dist/generators/mobile-test.js +286 -0
  118. package/dist/generators/mobile-test.js.map +1 -0
  119. package/dist/generators/unit-test.d.ts +23 -0
  120. package/dist/generators/unit-test.d.ts.map +1 -0
  121. package/dist/generators/unit-test.js +282 -0
  122. package/dist/generators/unit-test.js.map +1 -0
  123. package/dist/index.d.ts +12 -0
  124. package/dist/index.d.ts.map +1 -0
  125. package/dist/index.js +13 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/mcp/server.d.ts +8 -0
  128. package/dist/mcp/server.d.ts.map +1 -0
  129. package/dist/mcp/server.js +217 -0
  130. package/dist/mcp/server.js.map +1 -0
  131. package/dist/types/index.d.ts +295 -0
  132. package/dist/types/index.d.ts.map +1 -0
  133. package/dist/types/index.js +8 -0
  134. package/dist/types/index.js.map +1 -0
  135. package/dist/utils/framework-detector.d.ts +28 -0
  136. package/dist/utils/framework-detector.d.ts.map +1 -0
  137. package/dist/utils/framework-detector.js +184 -0
  138. package/dist/utils/framework-detector.js.map +1 -0
  139. package/dist/utils/git.d.ts +33 -0
  140. package/dist/utils/git.d.ts.map +1 -0
  141. package/dist/utils/git.js +82 -0
  142. package/dist/utils/git.js.map +1 -0
  143. package/dist/utils/logger.d.ts +17 -0
  144. package/dist/utils/logger.d.ts.map +1 -0
  145. package/dist/utils/logger.js +47 -0
  146. package/dist/utils/logger.js.map +1 -0
  147. package/package.json +86 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 coverit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,169 @@
1
+ # coverit
2
+
3
+ **Your code, covered. One command.**
4
+
5
+ <!-- badges -->
6
+ ![Version](https://img.shields.io/npm/v/coverit)
7
+ ![License](https://img.shields.io/npm/l/coverit)
8
+ ![Build](https://img.shields.io/github/actions/workflow/status/nicepkg/coverit/ci.yml)
9
+
10
+ ## What is coverit?
11
+
12
+ coverit is an AI-powered test generation and execution platform. It analyzes your code changes, determines what tests are needed, generates them, runs them, and reports the results. One command: `coverit run`.
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ # Install
18
+ bun add -g coverit
19
+
20
+ # Run in your project
21
+ coverit run
22
+
23
+ # Or scan first (dry run)
24
+ coverit scan
25
+ ```
26
+
27
+ ## Features
28
+
29
+ - **Smart diff analysis** -- parses git diffs to identify exactly what changed: new endpoints, modified functions, added components.
30
+ - **Automatic test strategy** -- decides which test types to generate (unit, API, E2E, mobile, desktop) based on file types and framework detection.
31
+ - **Multi-framework support** -- generates tests for Vitest, Jest, Playwright, Detox, and more, using the correct idioms for each.
32
+ - **Framework detection** -- identifies Hono, Express, NestJS, React, Expo, Tauri, and other frameworks from your project config.
33
+ - **Parallel execution** -- organizes tests into execution phases and runs independent plans concurrently.
34
+ - **Coverage tracking** -- collects line, branch, function, and statement coverage from test runners.
35
+ - **MCP integration** -- use coverit directly inside Claude Code as a set of MCP tools.
36
+ - **Local + Cloud** -- execute tests locally or in cloud sandboxes (E2B, Docker, Hetzner).
37
+
38
+ ## How It Works
39
+
40
+ ```
41
+ git diff → analyze → strategize → generate → execute → report
42
+ ```
43
+
44
+ | Step | What happens |
45
+ |------|-------------|
46
+ | **Diff** | Parses git changes to identify modified files, hunks, and line ranges. |
47
+ | **Analyze** | Scans source code to extract functions, classes, endpoints, components, and dependencies. |
48
+ | **Strategize** | Builds a `TestStrategy` with prioritized `TestPlan` items and phased execution order. |
49
+ | **Generate** | Produces test files using framework-specific generators (unit, API, E2E, mobile, desktop). |
50
+ | **Execute** | Runs generated tests via local runners, browsers, simulators, or cloud sandboxes. |
51
+ | **Report** | Aggregates results into a `CoveritReport` with pass/fail counts, coverage, and failure details. |
52
+
53
+ ## CLI Reference
54
+
55
+ | Command | Description |
56
+ |---------|-------------|
57
+ | `coverit scan [path]` | Analyze changes and display the test strategy without generating or running tests. |
58
+ | `coverit generate [path]` | Generate test files based on the analysis, but do not execute them. |
59
+ | `coverit run [path]` | Full pipeline: analyze, generate, execute, and report. |
60
+ | `coverit report` | Display the results of the last run. |
61
+
62
+ ## CLI Options
63
+
64
+ | Option | Description |
65
+ |--------|-------------|
66
+ | `--type <type>` | Restrict to a specific test type: `unit`, `api`, `e2e-browser`, `e2e-mobile`, `e2e-desktop`. |
67
+ | `--env <env>` | Execution environment: `local`, `cloud-sandbox`, `browser`, `mobile-simulator`, `desktop-app`. |
68
+ | `--coverage` | Collect coverage data during execution. |
69
+ | `--dry-run` | Show what would happen without writing files or running tests. |
70
+ | `--verbose` | Enable debug-level logging (`COVERIT_DEBUG=1`). |
71
+
72
+ ## MCP Integration
73
+
74
+ Add coverit as an MCP server in your Claude Code config:
75
+
76
+ ```json
77
+ {
78
+ "mcpServers": {
79
+ "coverit": {
80
+ "command": "bunx",
81
+ "args": ["coverit", "mcp"]
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ ### MCP Tools
88
+
89
+ | Tool | Description |
90
+ |------|-------------|
91
+ | `coverit_analyze` | Analyze code changes and return the test strategy. |
92
+ | `coverit_generate` | Generate test files from a strategy. |
93
+ | `coverit_run` | Execute generated tests and return results. |
94
+ | `coverit_full` | Full pipeline: analyze, generate, execute, report. |
95
+
96
+ ## Supported Frameworks
97
+
98
+ | Category | Frameworks |
99
+ |----------|-----------|
100
+ | API | Hono, Express, NestJS, Fastify |
101
+ | Frontend | React, Next.js |
102
+ | Mobile | React Native, Expo |
103
+ | Desktop | Tauri, Electron |
104
+ | Test Runners | Vitest, Jest, Playwright, Detox, Pytest |
105
+ | Package Managers | Bun, pnpm, npm, yarn |
106
+
107
+ ## Architecture
108
+
109
+ ```
110
+ ┌──────────────┐
111
+ │ CLI / MCP │ ← Entry points
112
+ └──────┬───────┘
113
+
114
+
115
+ ┌──────────────┐
116
+ │ Orchestrator │ ← Coordinates pipeline
117
+ └──────┬───────┘
118
+
119
+ ├──────────────┬──────────────┐
120
+ ▼ ▼ ▼
121
+ ┌────────────┐ ┌───────────┐ ┌────────────┐
122
+ │ Analysis │ │ Generators │ │ Executors │
123
+ │ Engine │ │ │ │ │
124
+ │ - Diff │ │ - Unit │ │ - Local │
125
+ │ - Scanner │ │ - API │ │ - Cloud │
126
+ │ - Deps │ │ - E2E │ │ - Browser │
127
+ │ - Strategy │ │ - Mobile │ │ - Simulator │
128
+ └────────────┘ │ - Desktop │ └──────┬──────┘
129
+ └───────────┘ │
130
+
131
+ ┌────────────┐
132
+ │ Reporter │
133
+ └────────────┘
134
+ ```
135
+
136
+ See [docs/architecture.md](docs/architecture.md) for a detailed breakdown.
137
+
138
+ ## Configuration
139
+
140
+ Create a `coverit.config.ts` in your project root:
141
+
142
+ ```ts
143
+ import { defineConfig } from "coverit";
144
+
145
+ export default defineConfig({
146
+ projectRoot: ".",
147
+ testTypes: ["unit", "api", "e2e-browser"],
148
+ environment: "local",
149
+ coverageThreshold: 80,
150
+ });
151
+ ```
152
+
153
+ See [docs/configuration.md](docs/configuration.md) for all options.
154
+
155
+ ## Roadmap
156
+
157
+ - Cloud execution (E2B, Docker)
158
+ - AI-powered test refinement on failure
159
+ - PR comment integration (GitHub Actions)
160
+ - VS Code extension
161
+ - Coverage trend tracking across runs
162
+
163
+ ## Contributing
164
+
165
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
166
+
167
+ ## License
168
+
169
+ [MIT](LICENSE)
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Coverit — Orchestrator
3
+ *
4
+ * Central pipeline engine that coordinates the full test lifecycle:
5
+ * analyze → plan → generate → execute → report.
6
+ *
7
+ * Each plan is executed independently — a failure in one plan does not
8
+ * block others. Errors are captured per-plan and included in the final report.
9
+ */
10
+ import type { CoveritConfig, CoveritEventHandler, CoveritReport } from "../types/index.js";
11
+ /**
12
+ * Runs the full coverit pipeline for a given configuration.
13
+ *
14
+ * Pipeline phases:
15
+ * 1. Analysis — diff, scan, dependency graph, strategy planning
16
+ * 2. Generation — create test files per plan (parallelized by phase)
17
+ * 3. Execution — run generated tests per plan
18
+ * 4. Reporting — aggregate results and persist
19
+ */
20
+ export declare function orchestrate(config: CoveritConfig, onEvent?: CoveritEventHandler): Promise<CoveritReport>;
21
+ //# sourceMappingURL=orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/agents/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,aAAa,EAEb,mBAAmB,EACnB,aAAa,EAOd,MAAM,mBAAmB,CAAC;AAqD3B;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,CAAC,CAqHxB"}
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Coverit — Orchestrator
3
+ *
4
+ * Central pipeline engine that coordinates the full test lifecycle:
5
+ * analyze → plan → generate → execute → report.
6
+ *
7
+ * Each plan is executed independently — a failure in one plan does not
8
+ * block others. Errors are captured per-plan and included in the final report.
9
+ */
10
+ import { mkdir, writeFile, readdir } from "node:fs/promises";
11
+ import { join } from "node:path";
12
+ import { createAIProvider, detectBestProvider } from "../ai/provider-factory.js";
13
+ import { analyzeDiff } from "../analysis/diff-analyzer.js";
14
+ import { scanCode } from "../analysis/code-scanner.js";
15
+ import { buildDependencyGraph } from "../analysis/dependency-graph.js";
16
+ import { planStrategy } from "../analysis/strategy-planner.js";
17
+ import { createGenerator } from "../generators/index.js";
18
+ import { createExecutor } from "../executors/index.js";
19
+ import { generateReport } from "../agents/reporter.js";
20
+ import { detectProjectInfo } from "../utils/framework-detector.js";
21
+ import { logger } from "../utils/logger.js";
22
+ const COVERIT_DIR = ".coverit";
23
+ const GENERATED_DIR = "generated";
24
+ const REPORT_FILE = "last-report.json";
25
+ function emit(handler, event) {
26
+ if (handler) {
27
+ try {
28
+ handler(event);
29
+ }
30
+ catch (err) {
31
+ logger.warn("Event handler threw:", err);
32
+ }
33
+ }
34
+ }
35
+ async function ensureDir(dirPath) {
36
+ await mkdir(dirPath, { recursive: true });
37
+ }
38
+ async function findExistingTests(projectRoot) {
39
+ const testDirs = ["__tests__", "tests", "test"];
40
+ const found = [];
41
+ for (const dir of testDirs) {
42
+ try {
43
+ const entries = await readdir(join(projectRoot, dir), {
44
+ recursive: true,
45
+ });
46
+ for (const entry of entries) {
47
+ if (typeof entry === "string" && /\.(test|spec)\.[jt]sx?$/.test(entry)) {
48
+ found.push(join(dir, entry));
49
+ }
50
+ }
51
+ }
52
+ catch {
53
+ // Directory doesn't exist — skip
54
+ }
55
+ }
56
+ return found;
57
+ }
58
+ /**
59
+ * Runs the full coverit pipeline for a given configuration.
60
+ *
61
+ * Pipeline phases:
62
+ * 1. Analysis — diff, scan, dependency graph, strategy planning
63
+ * 2. Generation — create test files per plan (parallelized by phase)
64
+ * 3. Execution — run generated tests per plan
65
+ * 4. Reporting — aggregate results and persist
66
+ */
67
+ export async function orchestrate(config, onEvent) {
68
+ const coveritDir = join(config.projectRoot, COVERIT_DIR);
69
+ const generatedDir = join(coveritDir, GENERATED_DIR);
70
+ await ensureDir(generatedDir);
71
+ // ── AI provider initialization ──────────────────────────────
72
+ // Attempt to stand up an LLM provider for intelligent test generation.
73
+ // Template-based generation is the automatic fallback when unavailable.
74
+ let aiProvider = null;
75
+ try {
76
+ if (config.ai?.provider) {
77
+ aiProvider = await createAIProvider(config.ai);
78
+ }
79
+ else {
80
+ aiProvider = await detectBestProvider();
81
+ }
82
+ logger.info(`Using AI provider: ${aiProvider.name}`);
83
+ }
84
+ catch {
85
+ logger.warn("No AI provider available — falling back to template-based generation");
86
+ }
87
+ // ── Phase 1: Analysis ──────────────────────────────────────
88
+ const projectInfo = await detectProjectInfo(config.projectRoot);
89
+ const baseBranch = config.targetPaths?.[0]; // TODO: proper baseBranch from config or git detection
90
+ const diffResult = await analyzeDiff(config.projectRoot, baseBranch);
91
+ emit(onEvent, { type: "analysis:start", data: { files: diffResult.files.length } });
92
+ const scanResults = [];
93
+ for (const changedFile of diffResult.files) {
94
+ const scanResult = await scanCode(join(config.projectRoot, changedFile.path), config.projectRoot);
95
+ scanResults.push(scanResult);
96
+ }
97
+ const depGraph = await buildDependencyGraph(config.projectRoot);
98
+ const strategy = await planStrategy(diffResult, scanResults, depGraph, config.projectRoot);
99
+ emit(onEvent, { type: "analysis:complete", data: { strategy } });
100
+ // ── Phase 2 & 3: Generation + Execution per phase ──────────
101
+ const existingTests = await findExistingTests(config.projectRoot);
102
+ const allResults = [];
103
+ for (const phase of strategy.executionOrder) {
104
+ // Plans within a phase can run in parallel
105
+ const phaseResults = await Promise.all(phase.plans.map(async (planId) => {
106
+ const plan = strategy.plans.find((p) => p.id === planId);
107
+ if (!plan) {
108
+ logger.warn(`Plan ${planId} referenced in phase but not found`);
109
+ return null;
110
+ }
111
+ try {
112
+ return await executePlan(plan, {
113
+ config,
114
+ projectInfo,
115
+ strategy,
116
+ scanResults,
117
+ existingTests,
118
+ generatedDir,
119
+ phase,
120
+ onEvent,
121
+ aiProvider,
122
+ });
123
+ }
124
+ catch (err) {
125
+ const message = err instanceof Error ? err.message : String(err);
126
+ logger.error(`Plan ${plan.id} failed:`, message);
127
+ emit(onEvent, {
128
+ type: "error",
129
+ data: { message, plan },
130
+ });
131
+ // Return a failure result so the pipeline continues
132
+ return {
133
+ planId: plan.id,
134
+ status: "error",
135
+ totalTests: 0,
136
+ passed: 0,
137
+ failed: 0,
138
+ skipped: 0,
139
+ duration: 0,
140
+ coverage: null,
141
+ failures: [],
142
+ output: `Plan execution error: ${message}`,
143
+ };
144
+ }
145
+ }));
146
+ for (const result of phaseResults) {
147
+ if (result)
148
+ allResults.push(result);
149
+ }
150
+ }
151
+ // ── Phase 4: Reporting ─────────────────────────────────────
152
+ const report = generateReport(projectInfo, strategy, allResults);
153
+ emit(onEvent, { type: "report:complete", data: { report } });
154
+ // Persist report for `coverit report` command
155
+ await writeFile(join(coveritDir, REPORT_FILE), JSON.stringify(report, null, 2), "utf-8");
156
+ return report;
157
+ }
158
+ async function executePlan(plan, ctx) {
159
+ const { config, projectInfo, scanResults, existingTests, generatedDir, phase, onEvent, aiProvider, } = ctx;
160
+ // ── Generate ───────────────────────────────────────────────
161
+ emit(onEvent, { type: "generation:start", data: { plan } });
162
+ const generatorCtx = {
163
+ plan,
164
+ project: projectInfo,
165
+ scanResults,
166
+ existingTests,
167
+ };
168
+ const generator = createGenerator(plan.type, projectInfo, aiProvider);
169
+ const genResult = await generator.generate(generatorCtx);
170
+ emit(onEvent, { type: "generation:complete", data: { result: genResult } });
171
+ // Write generated test files to .coverit/generated/
172
+ for (const test of genResult.tests) {
173
+ const outPath = join(generatedDir, test.filePath);
174
+ await ensureDir(join(outPath, ".."));
175
+ await writeFile(outPath, test.content, "utf-8");
176
+ }
177
+ if (config.generateOnly || config.skipExecution) {
178
+ return {
179
+ planId: plan.id,
180
+ status: "skipped",
181
+ totalTests: genResult.tests.reduce((sum, t) => sum + t.testCount, 0),
182
+ passed: 0,
183
+ failed: 0,
184
+ skipped: genResult.tests.reduce((sum, t) => sum + t.testCount, 0),
185
+ duration: 0,
186
+ coverage: null,
187
+ failures: [],
188
+ output: "Execution skipped (generate-only mode)",
189
+ };
190
+ }
191
+ // ── Execute ────────────────────────────────────────────────
192
+ emit(onEvent, {
193
+ type: "execution:start",
194
+ data: { plan, environment: phase.environment },
195
+ });
196
+ const executor = createExecutor(phase.environment);
197
+ // Execute each generated test and merge results
198
+ const mergedResult = {
199
+ planId: plan.id,
200
+ status: "passed",
201
+ totalTests: 0,
202
+ passed: 0,
203
+ failed: 0,
204
+ skipped: 0,
205
+ duration: 0,
206
+ coverage: null,
207
+ failures: [],
208
+ output: "",
209
+ };
210
+ for (const test of genResult.tests) {
211
+ const execResult = await executor.execute(test, {
212
+ environment: phase.environment,
213
+ timeout: 60_000,
214
+ retries: 0,
215
+ parallel: false,
216
+ collectCoverage: config.coverageThreshold !== undefined,
217
+ cloudConfig: config.cloudConfig,
218
+ });
219
+ mergedResult.totalTests += execResult.totalTests;
220
+ mergedResult.passed += execResult.passed;
221
+ mergedResult.failed += execResult.failed;
222
+ mergedResult.skipped += execResult.skipped;
223
+ mergedResult.duration += execResult.duration;
224
+ mergedResult.failures.push(...execResult.failures);
225
+ mergedResult.output += execResult.output + "\n";
226
+ if (execResult.coverage)
227
+ mergedResult.coverage = execResult.coverage;
228
+ if (execResult.status !== "passed")
229
+ mergedResult.status = execResult.status;
230
+ }
231
+ const execResult = mergedResult;
232
+ emit(onEvent, { type: "execution:complete", data: { result: execResult } });
233
+ return execResult;
234
+ }
235
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/agents/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC7D,O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AAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC9E,CAAC;IAED,MAAM,UAAU,GAAG,YAAY,CAAC;IAEhC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IAE5E,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Reporter — Aggregates execution results into a structured report with
3
+ * terminal and markdown output formatters.
4
+ *
5
+ * The terminal formatter produces a polished, color-coded summary using
6
+ * chalk. The markdown formatter produces a file-friendly version suitable
7
+ * for CI artifacts or PR comments.
8
+ */
9
+ import type { ProjectInfo, TestStrategy, ExecutionResult, CoveritReport } from "../types/index.js";
10
+ export declare function generateReport(project: ProjectInfo, strategy: TestStrategy, results: ExecutionResult[]): CoveritReport;
11
+ export declare function formatTerminalReport(report: CoveritReport): string;
12
+ export declare function formatMarkdownReport(report: CoveritReport): string;
13
+ //# sourceMappingURL=reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../src/agents/reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EAMd,MAAM,mBAAmB,CAAC;AAI3B,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,eAAe,EAAE,GACzB,aAAa,CAaf;AA+GD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAiKlE;AAID,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CA+GlE"}