@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.
- package/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/agents/orchestrator.d.ts +21 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +235 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/reporter.d.ts +13 -0
- package/dist/agents/reporter.d.ts.map +1 -0
- package/dist/agents/reporter.js +323 -0
- package/dist/agents/reporter.js.map +1 -0
- package/dist/ai/anthropic-provider.d.ts +19 -0
- package/dist/ai/anthropic-provider.d.ts.map +1 -0
- package/dist/ai/anthropic-provider.js +83 -0
- package/dist/ai/anthropic-provider.js.map +1 -0
- package/dist/ai/claude-cli-provider.d.ts +22 -0
- package/dist/ai/claude-cli-provider.d.ts.map +1 -0
- package/dist/ai/claude-cli-provider.js +197 -0
- package/dist/ai/claude-cli-provider.js.map +1 -0
- package/dist/ai/index.d.ts +15 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +16 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/ollama-provider.d.ts +17 -0
- package/dist/ai/ollama-provider.d.ts.map +1 -0
- package/dist/ai/ollama-provider.js +88 -0
- package/dist/ai/ollama-provider.js.map +1 -0
- package/dist/ai/openai-provider.d.ts +20 -0
- package/dist/ai/openai-provider.d.ts.map +1 -0
- package/dist/ai/openai-provider.js +74 -0
- package/dist/ai/openai-provider.js.map +1 -0
- package/dist/ai/prompts.d.ts +36 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/prompts.js +259 -0
- package/dist/ai/prompts.js.map +1 -0
- package/dist/ai/provider-factory.d.ts +26 -0
- package/dist/ai/provider-factory.d.ts.map +1 -0
- package/dist/ai/provider-factory.js +111 -0
- package/dist/ai/provider-factory.js.map +1 -0
- package/dist/ai/types.d.ts +37 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +10 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/analysis/code-scanner.d.ts +9 -0
- package/dist/analysis/code-scanner.d.ts.map +1 -0
- package/dist/analysis/code-scanner.js +409 -0
- package/dist/analysis/code-scanner.js.map +1 -0
- package/dist/analysis/dependency-graph.d.ts +9 -0
- package/dist/analysis/dependency-graph.d.ts.map +1 -0
- package/dist/analysis/dependency-graph.js +149 -0
- package/dist/analysis/dependency-graph.js.map +1 -0
- package/dist/analysis/diff-analyzer.d.ts +9 -0
- package/dist/analysis/diff-analyzer.d.ts.map +1 -0
- package/dist/analysis/diff-analyzer.js +232 -0
- package/dist/analysis/diff-analyzer.js.map +1 -0
- package/dist/analysis/index.d.ts +5 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +5 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/strategy-planner.d.ts +11 -0
- package/dist/analysis/strategy-planner.d.ts.map +1 -0
- package/dist/analysis/strategy-planner.js +384 -0
- package/dist/analysis/strategy-planner.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +288 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/executors/base-executor.d.ts +35 -0
- package/dist/executors/base-executor.d.ts.map +1 -0
- package/dist/executors/base-executor.js +138 -0
- package/dist/executors/base-executor.js.map +1 -0
- package/dist/executors/browser-runner.d.ts +24 -0
- package/dist/executors/browser-runner.d.ts.map +1 -0
- package/dist/executors/browser-runner.js +194 -0
- package/dist/executors/browser-runner.js.map +1 -0
- package/dist/executors/cloud-runner.d.ts +41 -0
- package/dist/executors/cloud-runner.d.ts.map +1 -0
- package/dist/executors/cloud-runner.js +153 -0
- package/dist/executors/cloud-runner.js.map +1 -0
- package/dist/executors/index.d.ts +12 -0
- package/dist/executors/index.d.ts.map +1 -0
- package/dist/executors/index.js +28 -0
- package/dist/executors/index.js.map +1 -0
- package/dist/executors/local-runner.d.ts +40 -0
- package/dist/executors/local-runner.d.ts.map +1 -0
- package/dist/executors/local-runner.js +395 -0
- package/dist/executors/local-runner.js.map +1 -0
- package/dist/executors/reporter.d.ts +6 -0
- package/dist/executors/reporter.d.ts.map +1 -0
- package/dist/executors/reporter.js +6 -0
- package/dist/executors/reporter.js.map +1 -0
- package/dist/executors/simulator-runner.d.ts +30 -0
- package/dist/executors/simulator-runner.d.ts.map +1 -0
- package/dist/executors/simulator-runner.js +339 -0
- package/dist/executors/simulator-runner.js.map +1 -0
- package/dist/generators/api-test.d.ts +22 -0
- package/dist/generators/api-test.d.ts.map +1 -0
- package/dist/generators/api-test.js +235 -0
- package/dist/generators/api-test.js.map +1 -0
- package/dist/generators/base-generator.d.ts +79 -0
- package/dist/generators/base-generator.d.ts.map +1 -0
- package/dist/generators/base-generator.js +234 -0
- package/dist/generators/base-generator.js.map +1 -0
- package/dist/generators/desktop-test.d.ts +22 -0
- package/dist/generators/desktop-test.d.ts.map +1 -0
- package/dist/generators/desktop-test.js +290 -0
- package/dist/generators/desktop-test.js.map +1 -0
- package/dist/generators/e2e-browser.d.ts +19 -0
- package/dist/generators/e2e-browser.d.ts.map +1 -0
- package/dist/generators/e2e-browser.js +233 -0
- package/dist/generators/e2e-browser.js.map +1 -0
- package/dist/generators/index.d.ts +21 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +66 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/mobile-test.d.ts +22 -0
- package/dist/generators/mobile-test.d.ts.map +1 -0
- package/dist/generators/mobile-test.js +286 -0
- package/dist/generators/mobile-test.js.map +1 -0
- package/dist/generators/unit-test.d.ts +23 -0
- package/dist/generators/unit-test.d.ts.map +1 -0
- package/dist/generators/unit-test.js +282 -0
- package/dist/generators/unit-test.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +8 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +217 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/types/index.d.ts +295 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/framework-detector.d.ts +28 -0
- package/dist/utils/framework-detector.d.ts.map +1 -0
- package/dist/utils/framework-detector.js +184 -0
- package/dist/utils/framework-detector.js.map +1 -0
- package/dist/utils/git.d.ts +33 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +82 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/logger.d.ts +17 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +47 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Templates for AI-Powered Test Generation
|
|
3
|
+
*
|
|
4
|
+
* These prompts combine AST analysis context with structured LLM
|
|
5
|
+
* instructions to produce high-quality, runnable test files.
|
|
6
|
+
* Each prompt is designed to be provider-agnostic — they work
|
|
7
|
+
* identically whether sent to Claude, GPT, or a local model.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Build the message array for generating tests from source code
|
|
11
|
+
* and AST analysis results. The system message establishes the
|
|
12
|
+
* persona and hard constraints; the user message provides all
|
|
13
|
+
* the context needed to write tests.
|
|
14
|
+
*/
|
|
15
|
+
export function buildTestGenerationPrompt(params) {
|
|
16
|
+
const { sourceCode, scanResult, testType, framework, existingTests, projectContext, } = params;
|
|
17
|
+
const systemPrompt = buildSystemPrompt(framework);
|
|
18
|
+
const userPrompt = buildUserPrompt(sourceCode, scanResult, testType, framework, existingTests, projectContext);
|
|
19
|
+
return [
|
|
20
|
+
{ role: "system", content: systemPrompt },
|
|
21
|
+
{ role: "user", content: userPrompt },
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
function buildSystemPrompt(framework) {
|
|
25
|
+
return `You are an expert test engineer specializing in writing thorough, maintainable test suites.
|
|
26
|
+
|
|
27
|
+
FRAMEWORK: ${framework}
|
|
28
|
+
|
|
29
|
+
HARD RULES — follow these exactly:
|
|
30
|
+
1. Output ONLY the complete test file content. No markdown fences, no explanations, no commentary.
|
|
31
|
+
2. Write meaningful assertions that verify behavior. Never write trivial assertions like \`toBeDefined()\` or \`toBeTruthy()\` as the sole check for a test case.
|
|
32
|
+
3. Do NOT mock standard library modules (node:crypto, node:fs, node:path, etc.) unless you are specifically testing an error path that requires it.
|
|
33
|
+
4. Test behavior and public contracts, not implementation details. If a refactor would break the test but not the behavior, the test is wrong.
|
|
34
|
+
5. Each test case must have a clear, descriptive name that explains what behavior it verifies.
|
|
35
|
+
6. Group related tests using \`describe\` blocks that mirror the module's structure.
|
|
36
|
+
7. Include setup/teardown where needed, but keep tests isolated from each other.
|
|
37
|
+
8. Use realistic test data, not meaningless strings like "foo" and "bar".
|
|
38
|
+
9. Prefer \`toEqual\` for deep equality, \`toBe\` for primitives and references, \`toThrow\` for errors.
|
|
39
|
+
10. Handle async code correctly — always await promises and use proper async test patterns.`;
|
|
40
|
+
}
|
|
41
|
+
function buildUserPrompt(sourceCode, scanResult, testType, framework, existingTests, projectContext) {
|
|
42
|
+
const sections = [];
|
|
43
|
+
// Project context (optional)
|
|
44
|
+
if (projectContext) {
|
|
45
|
+
sections.push(`## Project Context\n${projectContext}`);
|
|
46
|
+
}
|
|
47
|
+
// Source code
|
|
48
|
+
sections.push(`## Source Code (${scanResult.file})\n\`\`\`${scanResult.language}\n${sourceCode}\n\`\`\``);
|
|
49
|
+
// AST analysis — give the LLM structured insight into the code
|
|
50
|
+
sections.push(`## Code Analysis (AST Scan Result)\n\`\`\`json\n${JSON.stringify(formatScanResult(scanResult), null, 2)}\n\`\`\``);
|
|
51
|
+
// Test type instructions
|
|
52
|
+
sections.push(`## Test Type: ${testType}\n${getTestTypeInstructions(testType, framework)}`);
|
|
53
|
+
// Existing tests to avoid duplication
|
|
54
|
+
if (existingTests && existingTests.length > 0) {
|
|
55
|
+
sections.push(`## Existing Test Files (do NOT duplicate these)\nThe following test files already exist for this module. Do not re-test anything they already cover.\n\n${existingTests.map((t) => `- ${t}`).join("\n")}`);
|
|
56
|
+
}
|
|
57
|
+
// Import guidance based on framework
|
|
58
|
+
sections.push(`## Import Instructions\n${getImportInstructions(framework, scanResult)}`);
|
|
59
|
+
return sections.join("\n\n");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Format the scan result for prompt inclusion — strip noise and
|
|
63
|
+
* keep only the fields the LLM needs to reason about test targets.
|
|
64
|
+
*/
|
|
65
|
+
function formatScanResult(scanResult) {
|
|
66
|
+
return {
|
|
67
|
+
file: scanResult.file,
|
|
68
|
+
language: scanResult.language,
|
|
69
|
+
fileType: scanResult.fileType,
|
|
70
|
+
exports: scanResult.exports.map((e) => ({
|
|
71
|
+
name: e.name,
|
|
72
|
+
kind: e.kind,
|
|
73
|
+
isDefault: e.isDefault,
|
|
74
|
+
})),
|
|
75
|
+
functions: scanResult.functions.map((f) => ({
|
|
76
|
+
name: f.name,
|
|
77
|
+
params: f.params.map((p) => ({
|
|
78
|
+
name: p.name,
|
|
79
|
+
type: p.type,
|
|
80
|
+
isOptional: p.isOptional,
|
|
81
|
+
})),
|
|
82
|
+
returnType: f.returnType,
|
|
83
|
+
isAsync: f.isAsync,
|
|
84
|
+
isExported: f.isExported,
|
|
85
|
+
complexity: f.complexity,
|
|
86
|
+
})),
|
|
87
|
+
classes: scanResult.classes.map((c) => ({
|
|
88
|
+
name: c.name,
|
|
89
|
+
methods: c.methods.map((m) => ({
|
|
90
|
+
name: m.name,
|
|
91
|
+
params: m.params.length,
|
|
92
|
+
isAsync: m.isAsync,
|
|
93
|
+
})),
|
|
94
|
+
isExported: c.isExported,
|
|
95
|
+
})),
|
|
96
|
+
endpoints: scanResult.endpoints.map((e) => ({
|
|
97
|
+
method: e.method,
|
|
98
|
+
path: e.path,
|
|
99
|
+
handler: e.handler,
|
|
100
|
+
middleware: e.middleware,
|
|
101
|
+
})),
|
|
102
|
+
components: scanResult.components.map((c) => ({
|
|
103
|
+
name: c.name,
|
|
104
|
+
props: c.props.map((p) => ({
|
|
105
|
+
name: p.name,
|
|
106
|
+
type: p.type,
|
|
107
|
+
isOptional: p.isOptional,
|
|
108
|
+
})),
|
|
109
|
+
hooks: c.hooks,
|
|
110
|
+
isPage: c.isPage,
|
|
111
|
+
})),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function getTestTypeInstructions(testType, framework) {
|
|
115
|
+
switch (testType) {
|
|
116
|
+
case "unit":
|
|
117
|
+
return `Write unit tests for each exported function and class.
|
|
118
|
+
|
|
119
|
+
For each function/method, cover:
|
|
120
|
+
- Happy path with typical inputs
|
|
121
|
+
- Edge cases (empty strings, zero, null/undefined where applicable, boundary values)
|
|
122
|
+
- Error cases (invalid input, thrown exceptions)
|
|
123
|
+
- Return value correctness
|
|
124
|
+
|
|
125
|
+
For classes, test:
|
|
126
|
+
- Construction with valid and invalid arguments
|
|
127
|
+
- Each public method independently
|
|
128
|
+
- State transitions and side effects`;
|
|
129
|
+
case "integration":
|
|
130
|
+
return `Write integration tests that verify how multiple modules work together.
|
|
131
|
+
|
|
132
|
+
Focus on:
|
|
133
|
+
- Data flow between functions/services
|
|
134
|
+
- Database or external service interactions (mock at the boundary)
|
|
135
|
+
- Error propagation across module boundaries
|
|
136
|
+
- Real-world usage scenarios that exercise multiple code paths`;
|
|
137
|
+
case "api":
|
|
138
|
+
return `Write API endpoint tests for each route.
|
|
139
|
+
|
|
140
|
+
For each endpoint, test:
|
|
141
|
+
- Successful request with valid payload (2xx response)
|
|
142
|
+
- Validation failures with invalid/missing fields (4xx response)
|
|
143
|
+
- Authentication/authorization errors if middleware is present
|
|
144
|
+
- Correct response shape and status codes
|
|
145
|
+
- Edge cases in request parameters
|
|
146
|
+
|
|
147
|
+
Use ${framework === "vitest" || framework === "jest" ? "supertest or the framework's test client" : "the appropriate HTTP test client"} to make requests.`;
|
|
148
|
+
case "e2e-browser":
|
|
149
|
+
return `Write end-to-end browser tests using ${framework === "playwright" ? "Playwright" : framework === "cypress" ? "Cypress" : "the browser test framework"}.
|
|
150
|
+
|
|
151
|
+
Test complete user flows:
|
|
152
|
+
- Page navigation and URL verification
|
|
153
|
+
- Form filling, submission, and validation feedback
|
|
154
|
+
- Button clicks, modal interactions, and dynamic content
|
|
155
|
+
- Loading states and error states
|
|
156
|
+
- Responsive behavior if applicable
|
|
157
|
+
|
|
158
|
+
Use realistic user actions — click, type, navigate — not internal API calls.`;
|
|
159
|
+
case "e2e-mobile":
|
|
160
|
+
return `Write mobile end-to-end tests.
|
|
161
|
+
|
|
162
|
+
Test:
|
|
163
|
+
- Screen rendering and layout
|
|
164
|
+
- Navigation between screens (stack, tab, drawer)
|
|
165
|
+
- Touch gestures (tap, swipe, long press)
|
|
166
|
+
- Form inputs and keyboard interactions
|
|
167
|
+
- Platform-specific behavior where relevant`;
|
|
168
|
+
case "e2e-desktop":
|
|
169
|
+
return `Write desktop application end-to-end tests.
|
|
170
|
+
|
|
171
|
+
Test:
|
|
172
|
+
- Window creation and management
|
|
173
|
+
- Tauri commands and IPC communication
|
|
174
|
+
- Menu interactions and keyboard shortcuts
|
|
175
|
+
- File system operations through the app
|
|
176
|
+
- Native dialog interactions
|
|
177
|
+
- Window state (minimize, maximize, close)`;
|
|
178
|
+
case "snapshot":
|
|
179
|
+
return `Write snapshot tests for the component/module output.
|
|
180
|
+
|
|
181
|
+
- Capture rendered output or serialized state
|
|
182
|
+
- Cover different prop/input combinations
|
|
183
|
+
- Include edge cases that affect rendering
|
|
184
|
+
- Each snapshot should have a descriptive test name`;
|
|
185
|
+
case "performance":
|
|
186
|
+
return `Write performance benchmark tests.
|
|
187
|
+
|
|
188
|
+
- Measure execution time for key operations
|
|
189
|
+
- Set reasonable performance budgets
|
|
190
|
+
- Test with realistic data sizes
|
|
191
|
+
- Compare against baseline expectations
|
|
192
|
+
- Use ${framework}'s timing utilities or performance.now()`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function getImportInstructions(framework, scanResult) {
|
|
196
|
+
const sourceFile = scanResult.file;
|
|
197
|
+
// Compute a relative import path assuming the test file is co-located
|
|
198
|
+
// or in a __tests__ directory adjacent to the source
|
|
199
|
+
const importPath = `./${sourceFile.split("/").pop()?.replace(/\.(ts|tsx|js|jsx)$/, "")}`;
|
|
200
|
+
const lines = [];
|
|
201
|
+
switch (framework) {
|
|
202
|
+
case "vitest":
|
|
203
|
+
lines.push(`Import test utilities from "vitest": { describe, it, expect, vi, beforeEach, afterEach }`, `Import the module under test from "${importPath}" using relative path.`);
|
|
204
|
+
break;
|
|
205
|
+
case "jest":
|
|
206
|
+
lines.push(`Use global Jest functions: describe, it, expect, jest, beforeEach, afterEach`, `Import the module under test from "${importPath}" using relative path.`);
|
|
207
|
+
break;
|
|
208
|
+
case "playwright":
|
|
209
|
+
lines.push(`Import from "@playwright/test": { test, expect }`, `Use test.describe for grouping, test() for individual tests.`);
|
|
210
|
+
break;
|
|
211
|
+
case "cypress":
|
|
212
|
+
lines.push(`Use global Cypress functions: describe, it, cy`, `Use cy.visit(), cy.get(), cy.contains() for interactions.`);
|
|
213
|
+
break;
|
|
214
|
+
default:
|
|
215
|
+
lines.push(`Import the module under test from "${importPath}".`, `Use the standard testing imports for ${framework}.`);
|
|
216
|
+
}
|
|
217
|
+
return lines.join("\n");
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Build the message array for refining tests that failed.
|
|
221
|
+
* This is used in the feedback loop: generate -> run -> failures -> refine -> run again.
|
|
222
|
+
*/
|
|
223
|
+
export function buildTestRefinementPrompt(params) {
|
|
224
|
+
const { testCode, failures, sourceCode } = params;
|
|
225
|
+
const systemPrompt = `You are an expert test engineer fixing failing tests.
|
|
226
|
+
|
|
227
|
+
HARD RULES:
|
|
228
|
+
1. Output ONLY the complete, corrected test file. No markdown fences, no explanations.
|
|
229
|
+
2. Fix the failing tests based on the error messages and stack traces provided.
|
|
230
|
+
3. Do NOT remove tests that fail — fix them so they pass against the actual source code behavior.
|
|
231
|
+
4. If a test assumption was wrong (the code behaves differently than expected), update the test to match the actual behavior.
|
|
232
|
+
5. If a test was testing the right thing but had an implementation error (wrong import, typo, incorrect assertion syntax), fix the implementation error.
|
|
233
|
+
6. Preserve all passing tests exactly as they are.
|
|
234
|
+
7. Do NOT add new tests — only fix the failing ones.`;
|
|
235
|
+
const failureDetails = failures
|
|
236
|
+
.map((f, i) => {
|
|
237
|
+
const parts = [`### Failure ${i + 1}: ${f.testName}`, `Message: ${f.message}`];
|
|
238
|
+
if (f.expected)
|
|
239
|
+
parts.push(`Expected: ${f.expected}`);
|
|
240
|
+
if (f.actual)
|
|
241
|
+
parts.push(`Actual: ${f.actual}`);
|
|
242
|
+
if (f.stack)
|
|
243
|
+
parts.push(`Stack:\n${f.stack}`);
|
|
244
|
+
return parts.join("\n");
|
|
245
|
+
})
|
|
246
|
+
.join("\n\n");
|
|
247
|
+
const userPrompt = `## Failing Test File\n\`\`\`\n${testCode}\n\`\`\`
|
|
248
|
+
|
|
249
|
+
## Test Failures\n${failureDetails}
|
|
250
|
+
|
|
251
|
+
## Original Source Code Being Tested\n\`\`\`\n${sourceCode}\n\`\`\`
|
|
252
|
+
|
|
253
|
+
Fix the failing tests so they pass against the source code above. Output the complete corrected test file.`;
|
|
254
|
+
return [
|
|
255
|
+
{ role: "system", content: systemPrompt },
|
|
256
|
+
{ role: "user", content: userPrompt },
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/ai/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAA4B;IAE5B,MAAM,EACJ,UAAU,EACV,UAAU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AAc;;gDAEc,UAAU;;2GAEiD,CAAC;IAE1G,OAAO;QACL,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;QACzC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Provider Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates the appropriate AI provider based on explicit config or
|
|
5
|
+
* auto-detection. Detection order reflects cost/convenience tradeoffs:
|
|
6
|
+
*
|
|
7
|
+
* 1. Claude CLI -- free if user has Pro/Max subscription
|
|
8
|
+
* 2. Anthropic -- best quality, requires API key
|
|
9
|
+
* 3. OpenAI -- widely available, requires API key
|
|
10
|
+
* 4. Ollama -- free & local, but quality varies by model
|
|
11
|
+
*
|
|
12
|
+
* The COVERIT_AI_PROVIDER env var can override auto-detection.
|
|
13
|
+
*/
|
|
14
|
+
import type { AIProvider, AIProviderConfig } from "./types.js";
|
|
15
|
+
/**
|
|
16
|
+
* Create a provider from an explicit configuration.
|
|
17
|
+
* Throws if the specified provider is not available.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createAIProvider(config?: AIProviderConfig): Promise<AIProvider>;
|
|
20
|
+
/**
|
|
21
|
+
* Auto-detect the best available AI provider by probing each one
|
|
22
|
+
* in priority order. Prefers providers that are free or already
|
|
23
|
+
* configured.
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectBestProvider(): Promise<AIProvider>;
|
|
26
|
+
//# sourceMappingURL=provider-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-factory.d.ts","sourceRoot":"","sources":["../../src/ai/provider-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAM/E;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,CAAC,CAgBrB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,UAAU,CAAC,CA6C9D"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Provider Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates the appropriate AI provider based on explicit config or
|
|
5
|
+
* auto-detection. Detection order reflects cost/convenience tradeoffs:
|
|
6
|
+
*
|
|
7
|
+
* 1. Claude CLI -- free if user has Pro/Max subscription
|
|
8
|
+
* 2. Anthropic -- best quality, requires API key
|
|
9
|
+
* 3. OpenAI -- widely available, requires API key
|
|
10
|
+
* 4. Ollama -- free & local, but quality varies by model
|
|
11
|
+
*
|
|
12
|
+
* The COVERIT_AI_PROVIDER env var can override auto-detection.
|
|
13
|
+
*/
|
|
14
|
+
import { ClaudeCliProvider } from "./claude-cli-provider.js";
|
|
15
|
+
import { AnthropicProvider } from "./anthropic-provider.js";
|
|
16
|
+
import { OpenAIProvider } from "./openai-provider.js";
|
|
17
|
+
import { OllamaProvider } from "./ollama-provider.js";
|
|
18
|
+
/**
|
|
19
|
+
* Create a provider from an explicit configuration.
|
|
20
|
+
* Throws if the specified provider is not available.
|
|
21
|
+
*/
|
|
22
|
+
export async function createAIProvider(config) {
|
|
23
|
+
// If no config, fall through to auto-detection
|
|
24
|
+
if (!config) {
|
|
25
|
+
return detectBestProvider();
|
|
26
|
+
}
|
|
27
|
+
const provider = buildProvider(config.provider, config);
|
|
28
|
+
const available = await provider.isAvailable();
|
|
29
|
+
if (!available) {
|
|
30
|
+
throw new Error(`AI provider "${config.provider}" is not available. ${getProviderHint(config.provider)}`);
|
|
31
|
+
}
|
|
32
|
+
return provider;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Auto-detect the best available AI provider by probing each one
|
|
36
|
+
* in priority order. Prefers providers that are free or already
|
|
37
|
+
* configured.
|
|
38
|
+
*/
|
|
39
|
+
export async function detectBestProvider() {
|
|
40
|
+
// Allow env var to force a specific provider
|
|
41
|
+
const envProvider = process.env["COVERIT_AI_PROVIDER"];
|
|
42
|
+
if (envProvider) {
|
|
43
|
+
const provider = buildProvider(envProvider);
|
|
44
|
+
const available = await provider.isAvailable();
|
|
45
|
+
if (available)
|
|
46
|
+
return provider;
|
|
47
|
+
throw new Error(`COVERIT_AI_PROVIDER is set to "${envProvider}" but it is not available. ${getProviderHint(envProvider)}`);
|
|
48
|
+
}
|
|
49
|
+
// Probe providers in priority order
|
|
50
|
+
const candidates = [
|
|
51
|
+
new ClaudeCliProvider(),
|
|
52
|
+
new AnthropicProvider(),
|
|
53
|
+
new OpenAIProvider(),
|
|
54
|
+
new OllamaProvider(),
|
|
55
|
+
];
|
|
56
|
+
for (const candidate of candidates) {
|
|
57
|
+
const available = await candidate.isAvailable();
|
|
58
|
+
if (available)
|
|
59
|
+
return candidate;
|
|
60
|
+
}
|
|
61
|
+
throw new Error([
|
|
62
|
+
"No AI provider available. Configure one of the following:",
|
|
63
|
+
"",
|
|
64
|
+
" 1. Install Claude Code CLI (uses your Pro/Max subscription):",
|
|
65
|
+
" https://docs.anthropic.com/en/docs/claude-code",
|
|
66
|
+
"",
|
|
67
|
+
" 2. Set ANTHROPIC_API_KEY for Anthropic API access",
|
|
68
|
+
"",
|
|
69
|
+
" 3. Set OPENAI_API_KEY for OpenAI API access",
|
|
70
|
+
"",
|
|
71
|
+
" 4. Run Ollama locally: https://ollama.com",
|
|
72
|
+
"",
|
|
73
|
+
"Or set COVERIT_AI_PROVIDER to force a specific provider.",
|
|
74
|
+
].join("\n"));
|
|
75
|
+
}
|
|
76
|
+
/** Instantiate a provider by type without checking availability */
|
|
77
|
+
function buildProvider(type, config) {
|
|
78
|
+
switch (type) {
|
|
79
|
+
case "claude-cli":
|
|
80
|
+
return new ClaudeCliProvider(config);
|
|
81
|
+
case "anthropic":
|
|
82
|
+
return new AnthropicProvider(config);
|
|
83
|
+
case "openai":
|
|
84
|
+
return new OpenAIProvider(config);
|
|
85
|
+
case "ollama":
|
|
86
|
+
return new OllamaProvider(config);
|
|
87
|
+
case "openai-compatible":
|
|
88
|
+
return new OpenAIProvider({ ...config, provider: "openai-compatible" });
|
|
89
|
+
default: {
|
|
90
|
+
const _exhaustive = type;
|
|
91
|
+
throw new Error(`Unknown AI provider type: ${_exhaustive}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Return a setup hint for a specific provider */
|
|
96
|
+
function getProviderHint(type) {
|
|
97
|
+
switch (type) {
|
|
98
|
+
case "claude-cli":
|
|
99
|
+
return "Install Claude Code: https://docs.anthropic.com/en/docs/claude-code";
|
|
100
|
+
case "anthropic":
|
|
101
|
+
return "Set the ANTHROPIC_API_KEY environment variable.";
|
|
102
|
+
case "openai":
|
|
103
|
+
case "openai-compatible":
|
|
104
|
+
return "Set the OPENAI_API_KEY environment variable.";
|
|
105
|
+
case "ollama":
|
|
106
|
+
return "Start Ollama: ollama serve";
|
|
107
|
+
default:
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=provider-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-factory.js","sourceRoot":"","sources":["../../src/ai/provider-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAyB;IAEzB,+CAA+C;IAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,kBAA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
+
* When running as an MCP server inside Claude Code, Claude IS the AI
|
|
6
|
+
* and none of these providers are used. This layer exists solely for
|
|
7
|
+
* standalone CLI usage where we need to call an LLM directly.
|
|
8
|
+
*/
|
|
9
|
+
export type AIProviderType = "claude-cli" | "anthropic" | "openai" | "ollama" | "openai-compatible";
|
|
10
|
+
export interface AIProviderConfig {
|
|
11
|
+
provider: AIProviderType;
|
|
12
|
+
model?: string;
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
/** Base URL override for ollama or openai-compatible endpoints */
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
maxTokens?: number;
|
|
17
|
+
temperature?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface AIMessage {
|
|
20
|
+
role: "system" | "user" | "assistant";
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AIResponse {
|
|
24
|
+
content: string;
|
|
25
|
+
model: string;
|
|
26
|
+
tokensUsed?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface AIGenerateOptions {
|
|
29
|
+
maxTokens?: number;
|
|
30
|
+
temperature?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface AIProvider {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
generate(messages: AIMessage[], options?: AIGenerateOptions): Promise<AIResponse>;
|
|
35
|
+
isAvailable(): Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,QAAQ,GACR,mBAAmB,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CACN,QAAQ,EAAE,SAAS,EAAE,EACrB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC"}
|
package/dist/ai/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Provider Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for all AI providers used in CLI mode.
|
|
5
|
+
* When running as an MCP server inside Claude Code, Claude IS the AI
|
|
6
|
+
* and none of these providers are used. This layer exists solely for
|
|
7
|
+
* standalone CLI usage where we need to call an LLM directly.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CodeScanResult } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Perform AST-level code analysis on a TypeScript/JavaScript file.
|
|
4
|
+
*
|
|
5
|
+
* @param filePath - Absolute path to the source file
|
|
6
|
+
* @param projectRoot - Absolute path to the project root (for relative path computation)
|
|
7
|
+
*/
|
|
8
|
+
export declare function scanCode(filePath: string, projectRoot: string): Promise<CodeScanResult>;
|
|
9
|
+
//# sourceMappingURL=code-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-scanner.d.ts","sourceRoot":"","sources":["../../src/analysis/code-scanner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAWf,MAAM,mBAAmB,CAAC;AAmb3B;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC,CA2BzB"}
|