cadr-cli 1.10.0 → 2.0.1
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/dist/adr/adr.d.ts +17 -0
- package/dist/adr/adr.d.ts.map +1 -0
- package/dist/{adr.js → adr/adr.js} +4 -44
- package/dist/adr/adr.js.map +1 -0
- package/dist/adr/adr.test.d.ts +5 -0
- package/dist/{adr.test.d.ts.map → adr/adr.test.d.ts.map} +1 -1
- package/dist/{adr.test.js → adr/adr.test.js} +0 -14
- package/dist/adr/adr.test.js.map +1 -0
- package/dist/adr/index.d.ts +2 -0
- package/dist/adr/index.d.ts.map +1 -0
- package/dist/adr/index.js +18 -0
- package/dist/adr/index.js.map +1 -0
- package/dist/analysis/analysis.orchestrator.d.ts +14 -0
- package/dist/analysis/analysis.orchestrator.d.ts.map +1 -0
- package/dist/analysis/analysis.orchestrator.js +175 -0
- package/dist/analysis/analysis.orchestrator.js.map +1 -0
- package/dist/analysis/strategies/git-strategy.d.ts +22 -0
- package/dist/analysis/strategies/git-strategy.d.ts.map +1 -0
- package/dist/analysis/strategies/git-strategy.js +114 -0
- package/dist/analysis/strategies/git-strategy.js.map +1 -0
- package/dist/commands/analyze.js +3 -3
- package/dist/commands/analyze.js.map +1 -1
- package/dist/commands/status.d.ts +11 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +69 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/status.test.d.ts +2 -0
- package/dist/commands/status.test.d.ts.map +1 -0
- package/dist/commands/status.test.js +83 -0
- package/dist/commands/status.test.js.map +1 -0
- package/dist/git/git.errors.d.ts +6 -0
- package/dist/git/git.errors.d.ts.map +1 -0
- package/dist/git/git.errors.js +15 -0
- package/dist/git/git.errors.js.map +1 -0
- package/dist/git/git.operations.d.ts +12 -0
- package/dist/git/git.operations.d.ts.map +1 -0
- package/dist/git/git.operations.js +64 -0
- package/dist/git/git.operations.js.map +1 -0
- package/dist/git/index.d.ts +4 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +19 -0
- package/dist/git/index.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/index.d.ts +3 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +19 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm.d.ts +35 -0
- package/dist/llm/llm.d.ts.map +1 -0
- package/dist/{llm.js → llm/llm.js} +16 -58
- package/dist/llm/llm.js.map +1 -0
- package/dist/{prompts.d.ts → llm/prompts.d.ts} +1 -38
- package/dist/llm/prompts.d.ts.map +1 -0
- package/dist/{prompts.js → llm/prompts.js} +9 -54
- package/dist/llm/prompts.js.map +1 -0
- package/dist/llm/response-parser.d.ts +9 -0
- package/dist/llm/response-parser.d.ts.map +1 -0
- package/dist/llm/response-parser.js +67 -0
- package/dist/llm/response-parser.js.map +1 -0
- package/dist/presenters/console-presenter.d.ts +35 -0
- package/dist/presenters/console-presenter.d.ts.map +1 -0
- package/dist/presenters/console-presenter.js +114 -0
- package/dist/presenters/console-presenter.js.map +1 -0
- package/package.json +1 -1
- package/src/{adr.test.ts → adr/adr.test.ts} +10 -23
- package/src/{adr.ts → adr/adr.ts} +7 -48
- package/src/adr/index.ts +1 -0
- package/src/analysis/analysis.orchestrator.ts +175 -0
- package/src/analysis/strategies/git-strategy.ts +106 -0
- package/src/commands/analyze.ts +8 -9
- package/src/commands/status.test.ts +64 -0
- package/src/commands/status.ts +71 -0
- package/src/git/git.errors.ts +10 -0
- package/src/git/git.operations.ts +85 -0
- package/src/git/index.ts +3 -0
- package/src/index.ts +6 -0
- package/src/llm/index.ts +2 -0
- package/src/{llm.ts → llm/llm.ts} +46 -107
- package/src/{prompts.ts → llm/prompts.ts} +30 -72
- package/src/llm/response-parser.ts +90 -0
- package/src/presenters/console-presenter.ts +152 -0
- package/dist/adr.d.ts +0 -50
- package/dist/adr.d.ts.map +0 -1
- package/dist/adr.js.map +0 -1
- package/dist/adr.test.d.ts +0 -8
- package/dist/adr.test.js.map +0 -1
- package/dist/analysis.d.ts +0 -24
- package/dist/analysis.d.ts.map +0 -1
- package/dist/analysis.js +0 -281
- package/dist/analysis.js.map +0 -1
- package/dist/analysis.test.d.ts +0 -8
- package/dist/analysis.test.d.ts.map +0 -1
- package/dist/analysis.test.js +0 -351
- package/dist/analysis.test.js.map +0 -1
- package/dist/git.d.ts +0 -54
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js +0 -204
- package/dist/git.js.map +0 -1
- package/dist/llm.d.ts +0 -73
- package/dist/llm.d.ts.map +0 -1
- package/dist/llm.js.map +0 -1
- package/dist/llm.test.d.ts +0 -2
- package/dist/llm.test.d.ts.map +0 -1
- package/dist/llm.test.js +0 -592
- package/dist/llm.test.js.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/prompts.test.d.ts +0 -2
- package/dist/prompts.test.d.ts.map +0 -1
- package/dist/prompts.test.js +0 -427
- package/dist/prompts.test.js.map +0 -1
- package/src/analysis.test.ts +0 -396
- package/src/analysis.ts +0 -262
- package/src/git.ts +0 -300
- package/src/llm.test.ts +0 -701
- package/src/prompts.test.ts +0 -515
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* LLM Client Module
|
|
4
|
-
*
|
|
5
|
-
* Provider-based wrapper for analyzing code changes.
|
|
6
|
-
* Implements fail-open error handling per constitution requirements.
|
|
7
|
-
*/
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.analyzeChanges = analyzeChanges;
|
|
10
4
|
exports.generateADRContent = generateADRContent;
|
|
11
|
-
const providers_1 = require("
|
|
12
|
-
const logger_1 = require("
|
|
13
|
-
/**
|
|
14
|
-
* Rough token estimation (1 token ≈ 4 characters for English text)
|
|
15
|
-
* This is a conservative estimate
|
|
16
|
-
*/
|
|
5
|
+
const providers_1 = require("../providers");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
17
7
|
function estimateTokens(text) {
|
|
18
8
|
return Math.ceil(text.length / 4);
|
|
19
9
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Analyze staged changes using OpenAI LLM
|
|
22
|
-
*
|
|
23
|
-
* @param config - Analysis configuration with API settings
|
|
24
|
-
* @param request - Analysis request with code changes
|
|
25
|
-
* @returns Promise resolving to analysis response with result or error
|
|
26
|
-
*/
|
|
27
10
|
async function analyzeChanges(config, request) {
|
|
28
11
|
try {
|
|
29
|
-
// Check if API key is available
|
|
30
12
|
const apiKey = process.env[config.api_key_env];
|
|
31
13
|
if (!apiKey) {
|
|
32
14
|
logger_1.loggerInstance.warn('API key not found in environment', {
|
|
@@ -34,10 +16,9 @@ async function analyzeChanges(config, request) {
|
|
|
34
16
|
});
|
|
35
17
|
return {
|
|
36
18
|
result: null,
|
|
37
|
-
error: `API key not found: ${config.api_key_env} environment variable is not set
|
|
19
|
+
error: `API key not found: ${config.api_key_env} environment variable is not set`,
|
|
38
20
|
};
|
|
39
21
|
}
|
|
40
|
-
// Estimate tokens for logging and validation
|
|
41
22
|
const estimatedTokens = estimateTokens(request.analysis_prompt);
|
|
42
23
|
logger_1.loggerInstance.info('Sending analysis request to LLM', {
|
|
43
24
|
provider: config.provider,
|
|
@@ -45,7 +26,6 @@ async function analyzeChanges(config, request) {
|
|
|
45
26
|
file_count: request.file_paths.length,
|
|
46
27
|
estimated_tokens: estimatedTokens,
|
|
47
28
|
});
|
|
48
|
-
// Warn if token estimate is high (most models have 8k-32k limits)
|
|
49
29
|
if (estimatedTokens > 7000) {
|
|
50
30
|
logger_1.loggerInstance.warn('High token count detected', {
|
|
51
31
|
estimated_tokens: estimatedTokens,
|
|
@@ -63,20 +43,16 @@ async function analyzeChanges(config, request) {
|
|
|
63
43
|
logger_1.loggerInstance.warn('No response content from LLM', { provider: config.provider });
|
|
64
44
|
return {
|
|
65
45
|
result: null,
|
|
66
|
-
error: 'No response content from LLM'
|
|
46
|
+
error: 'No response content from LLM',
|
|
67
47
|
};
|
|
68
48
|
}
|
|
69
|
-
// Parse JSON response - handle markdown-wrapped JSON
|
|
70
49
|
let parsedResponse;
|
|
71
50
|
try {
|
|
72
|
-
// Try to extract JSON from markdown code blocks if present
|
|
73
51
|
let jsonContent = responseContent.trim();
|
|
74
|
-
// Remove markdown code block if present: ```json ... ``` or ``` ... ```
|
|
75
52
|
const codeBlockMatch = jsonContent.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
|
|
76
53
|
if (codeBlockMatch) {
|
|
77
54
|
jsonContent = codeBlockMatch[1].trim();
|
|
78
55
|
}
|
|
79
|
-
// Try to find JSON object if there's surrounding text
|
|
80
56
|
const jsonMatch = jsonContent.match(/\{[\s\S]*\}/);
|
|
81
57
|
if (jsonMatch) {
|
|
82
58
|
jsonContent = jsonMatch[0];
|
|
@@ -90,10 +66,9 @@ async function analyzeChanges(config, request) {
|
|
|
90
66
|
});
|
|
91
67
|
return {
|
|
92
68
|
result: null,
|
|
93
|
-
error: `Failed to parse LLM response as JSON. Response was:\n${responseContent.substring(0, 200)}
|
|
69
|
+
error: `Failed to parse LLM response as JSON. Response was:\n${responseContent.substring(0, 200)}...`,
|
|
94
70
|
};
|
|
95
71
|
}
|
|
96
|
-
// Validate response format
|
|
97
72
|
if (typeof parsedResponse.is_significant !== 'boolean' ||
|
|
98
73
|
typeof parsedResponse.reason !== 'string') {
|
|
99
74
|
logger_1.loggerInstance.warn('Invalid response format from LLM', {
|
|
@@ -101,26 +76,23 @@ async function analyzeChanges(config, request) {
|
|
|
101
76
|
});
|
|
102
77
|
return {
|
|
103
78
|
result: null,
|
|
104
|
-
error: `Invalid response format from LLM. Expected {is_significant: boolean, reason: string}, got: ${JSON.stringify(parsedResponse).substring(0, 150)}
|
|
79
|
+
error: `Invalid response format from LLM. Expected {is_significant: boolean, reason: string}, got: ${JSON.stringify(parsedResponse).substring(0, 150)}...`,
|
|
105
80
|
};
|
|
106
81
|
}
|
|
107
|
-
// Reason is required when is_significant is true, but can be empty when false
|
|
108
82
|
if (parsedResponse.is_significant && !parsedResponse.reason) {
|
|
109
83
|
logger_1.loggerInstance.warn('Missing reason for significant change', {
|
|
110
84
|
response: parsedResponse,
|
|
111
85
|
});
|
|
112
86
|
return {
|
|
113
87
|
result: null,
|
|
114
|
-
error: 'LLM indicated significant change but provided no reason'
|
|
88
|
+
error: 'LLM indicated significant change but provided no reason',
|
|
115
89
|
};
|
|
116
90
|
}
|
|
117
|
-
// Build result with timestamp
|
|
118
91
|
const result = {
|
|
119
92
|
is_significant: parsedResponse.is_significant,
|
|
120
93
|
reason: parsedResponse.reason,
|
|
121
94
|
timestamp: new Date().toISOString(),
|
|
122
95
|
};
|
|
123
|
-
// Include confidence if provided
|
|
124
96
|
if (typeof parsedResponse.confidence === 'number' &&
|
|
125
97
|
parsedResponse.confidence >= 0 &&
|
|
126
98
|
parsedResponse.confidence <= 1) {
|
|
@@ -133,21 +105,19 @@ async function analyzeChanges(config, request) {
|
|
|
133
105
|
return { result, error: undefined };
|
|
134
106
|
}
|
|
135
107
|
catch (error) {
|
|
136
|
-
// Fail-open: log error and return descriptive error message
|
|
137
108
|
const errorObj = error;
|
|
138
109
|
let errorMessage;
|
|
139
|
-
// Check for specific error types and provide helpful messages
|
|
140
110
|
if (errorObj.status === 401) {
|
|
141
111
|
errorMessage = 'Invalid API key - please check your API key configuration';
|
|
142
112
|
logger_1.loggerInstance.warn('LLM API authentication failed', { error: errorObj });
|
|
143
113
|
}
|
|
144
114
|
else if (errorObj.status === 400 && errorObj.message?.includes('maximum context length')) {
|
|
145
|
-
// Extract token counts from error message if available
|
|
146
115
|
const tokenMatch = errorObj.message.match(/(\d+)\s+tokens/g);
|
|
147
|
-
errorMessage =
|
|
148
|
-
'
|
|
149
|
-
|
|
150
|
-
|
|
116
|
+
errorMessage =
|
|
117
|
+
'Diff too large for model context window. Try:\n' +
|
|
118
|
+
' • Stage fewer files at once\n' +
|
|
119
|
+
' • Use a model with larger context window in cadr.yaml\n' +
|
|
120
|
+
' • Add ignore patterns to filter large files';
|
|
151
121
|
logger_1.loggerInstance.warn('LLM context length exceeded', {
|
|
152
122
|
error: errorObj,
|
|
153
123
|
tokens: tokenMatch,
|
|
@@ -172,16 +142,8 @@ async function analyzeChanges(config, request) {
|
|
|
172
142
|
return { result: null, error: errorMessage };
|
|
173
143
|
}
|
|
174
144
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Generate ADR content using LLM
|
|
177
|
-
*
|
|
178
|
-
* @param config - Analysis configuration with API settings
|
|
179
|
-
* @param request - Generation request with code changes
|
|
180
|
-
* @returns Promise resolving to generation response with result or error
|
|
181
|
-
*/
|
|
182
145
|
async function generateADRContent(config, request) {
|
|
183
146
|
try {
|
|
184
|
-
// Check if API key is available
|
|
185
147
|
const apiKey = process.env[config.api_key_env];
|
|
186
148
|
if (!apiKey) {
|
|
187
149
|
logger_1.loggerInstance.warn('API key not found in environment for generation', {
|
|
@@ -189,7 +151,7 @@ async function generateADRContent(config, request) {
|
|
|
189
151
|
});
|
|
190
152
|
return {
|
|
191
153
|
result: null,
|
|
192
|
-
error: `API key not found: ${config.api_key_env} environment variable is not set
|
|
154
|
+
error: `API key not found: ${config.api_key_env} environment variable is not set`,
|
|
193
155
|
};
|
|
194
156
|
}
|
|
195
157
|
logger_1.loggerInstance.info('Sending generation request to LLM', {
|
|
@@ -200,26 +162,23 @@ async function generateADRContent(config, request) {
|
|
|
200
162
|
const provider = (0, providers_1.getProvider)(config.provider);
|
|
201
163
|
const responseContent = await provider.analyze(request.generation_prompt, {
|
|
202
164
|
apiKey,
|
|
203
|
-
model: config.analysis_model,
|
|
165
|
+
model: config.analysis_model,
|
|
204
166
|
timeoutMs: config.timeout_seconds * 1000,
|
|
205
167
|
});
|
|
206
168
|
if (!responseContent) {
|
|
207
169
|
logger_1.loggerInstance.warn('No response content from LLM for generation', {
|
|
208
|
-
provider: config.provider
|
|
170
|
+
provider: config.provider,
|
|
209
171
|
});
|
|
210
172
|
return {
|
|
211
173
|
result: null,
|
|
212
|
-
error: 'No response content from LLM'
|
|
174
|
+
error: 'No response content from LLM',
|
|
213
175
|
};
|
|
214
176
|
}
|
|
215
|
-
// Clean up the response - remove markdown code fences if LLM added them
|
|
216
177
|
let cleanedContent = responseContent.trim();
|
|
217
|
-
// Remove markdown code block if present
|
|
218
178
|
const codeBlockMatch = cleanedContent.match(/```(?:markdown|md)?\s*\n?([\s\S]*?)\n?```/);
|
|
219
179
|
if (codeBlockMatch) {
|
|
220
180
|
cleanedContent = codeBlockMatch[1].trim();
|
|
221
181
|
}
|
|
222
|
-
// Extract title from first line (should be # Title)
|
|
223
182
|
const titleMatch = cleanedContent.match(/^#\s+(.+)$/m);
|
|
224
183
|
const title = titleMatch ? titleMatch[1].trim() : 'Untitled Decision';
|
|
225
184
|
const result = {
|
|
@@ -234,7 +193,6 @@ async function generateADRContent(config, request) {
|
|
|
234
193
|
return { result, error: undefined };
|
|
235
194
|
}
|
|
236
195
|
catch (error) {
|
|
237
|
-
// Fail-open: log error and return descriptive error message
|
|
238
196
|
const errorObj = error;
|
|
239
197
|
let errorMessage;
|
|
240
198
|
if (errorObj.status === 401) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/llm/llm.ts"],"names":[],"mappings":";;AA6CA,wCAuJC;AAED,gDAoFC;AA1RD,4CAA2C;AAE3C,sCAAqD;AAuCrD,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,MAAsB,EACtB,OAAwB;IAExB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,u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AQ,EAAE,CAAC,CAAC;QACpF,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAClF,YAAY,GAAG,oBAAoB,MAAM,CAAC,eAAe,IAAI,CAAC;YAC9D,uBAAM,CAAC,IAAI,CAAC,2CAA2C,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,cAAc,QAAQ,CAAC,OAAO,IAAI,wBAAwB,EAAE,CAAC;YAC5E,uBAAM,CAAC,IAAI,CAAC,0CAA0C,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -1,49 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prompts Module
|
|
3
|
-
*
|
|
4
|
-
* Contains versioned prompt templates for LLM analysis and ADR generation.
|
|
5
|
-
* Follows the constitution requirement for versioned prompts.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Version 1 of the analysis prompt template.
|
|
9
|
-
*
|
|
10
|
-
* This prompt is designed to analyze code changes for architectural significance.
|
|
11
|
-
* It uses specific criteria for determining significance and enforces strict JSON output.
|
|
12
|
-
*/
|
|
13
1
|
export declare const ANALYSIS_PROMPT_V1 = "\nYou are an expert principal engineer and software architect acting as a meticulous code reviewer. Your sole task is to determine if the provided git diff represents an architecturally significant change that warrants an Architectural Decision Record (ADR).\n\nGiven the following staged changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nA change is considered architecturally significant if it:\n- Introduces a new external dependency, library, or service.\n- Adds, removes, or modifies infrastructure components (e.g., databases, caches, queues, Docker services).\n- Changes a public API contract, a data schema, or a critical data model.\n- Alters authentication, authorization, or other core security patterns.\n- Modifies cross-cutting concerns like logging, observability, or CI/CD pipelines.\n\nRespond ONLY with a single, minified JSON object with no preamble, no markdown, and no additional text. The JSON object must adhere to the following schema:\n{\"is_significant\": boolean, \"reason\": string}\n\nThe \"reason\" should be a concise, one-sentence explanation for your decision, suitable for showing to a developer. If the change is not significant, the reason should be an empty string.\n";
|
|
14
|
-
|
|
15
|
-
* Formats a prompt template by replacing placeholders with actual data.
|
|
16
|
-
*
|
|
17
|
-
* @param template - The prompt template with placeholders
|
|
18
|
-
* @param data - Object containing file_paths and diff_content
|
|
19
|
-
* @returns Formatted prompt with placeholders replaced
|
|
20
|
-
*/
|
|
2
|
+
export declare const GENERATION_PROMPT_V1 = "\nYou are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.\n\nGiven the following code changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nGenerate an ADR that follows this EXACT structure:\n\n# [Short title of solved problem and solution]\n\n* Status: [proposed | rejected | accepted | deprecated | superseded by [ADR-0005](0005-example.md)]\n* Date: {current_date}\n\n## Context and Problem Statement\n\n[Describe the context and problem statement in 2-3 sentences. What is the issue that we're addressing?]\n\n## Decision Drivers\n\n* [decision driver 1, e.g., a force, constraint, requirement]\n* [decision driver 2]\n* [etc.]\n\n## Considered Options\n\n* [option 1]\n* [option 2]\n* [option 3]\n\n## Decision Outcome\n\nChosen option: \"[option 1]\", because [justification. e.g., only option which meets KO criterion decision driver | which resolves force 1 | etc.].\n\n### Consequences\n\n* Good, because [positive consequence 1]\n* Good, because [positive consequence 2]\n* Bad, because [negative consequence 1]\n* Bad, because [negative consequence 2]\n\n## More Information\n\n[Any additional context, links to related discussions, or implementation notes]\n\nIMPORTANT INSTRUCTIONS:\n1. Use the EXACT markdown structure shown above\n2. Set Status to \"accepted\" (since this change is being committed)\n3. The title should be concise, action-oriented, and describe the decision made\n4. Keep Context and Problem Statement brief but clear (2-4 sentences)\n5. List at least 2-3 decision drivers that influenced this choice\n6. Include at least 2 considered options (including the chosen one)\n7. Be specific about consequences - list both benefits and drawbacks\n8. In \"More Information\", mention any technical details, related files, or future considerations\n\nRespond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.\n";
|
|
21
3
|
export declare function formatPrompt(template: string, data: {
|
|
22
4
|
file_paths: string[];
|
|
23
5
|
diff_content: string;
|
|
24
6
|
}): string;
|
|
25
|
-
/**
|
|
26
|
-
* Version 1 of the generation prompt template.
|
|
27
|
-
*
|
|
28
|
-
* This prompt generates ADRs following the MADR (Markdown Architectural Decision Records) format.
|
|
29
|
-
* MADR is a lean template for documenting architectural decisions in a structured way.
|
|
30
|
-
*/
|
|
31
|
-
export declare const GENERATION_PROMPT_V1 = "\nYou are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.\n\nGiven the following code changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nGenerate an ADR that follows this EXACT structure:\n\n# [Short title of solved problem and solution]\n\n* Status: [proposed | rejected | accepted | deprecated | superseded by [ADR-0005](0005-example.md)]\n* Date: {current_date}\n\n## Context and Problem Statement\n\n[Describe the context and problem statement in 2-3 sentences. What is the issue that we're addressing?]\n\n## Decision Drivers\n\n* [decision driver 1, e.g., a force, constraint, requirement]\n* [decision driver 2]\n* [etc.]\n\n## Considered Options\n\n* [option 1]\n* [option 2]\n* [option 3]\n\n## Decision Outcome\n\nChosen option: \"[option 1]\", because [justification. e.g., only option which meets KO criterion decision driver | which resolves force 1 | etc.].\n\n### Consequences\n\n* Good, because [positive consequence 1]\n* Good, because [positive consequence 2]\n* Bad, because [negative consequence 1]\n* Bad, because [negative consequence 2]\n\n## More Information\n\n[Any additional context, links to related discussions, or implementation notes]\n\nIMPORTANT INSTRUCTIONS:\n1. Use the EXACT markdown structure shown above\n2. Set Status to \"accepted\" (since this change is being committed)\n3. The title should be concise, action-oriented, and describe the decision made\n4. Keep Context and Problem Statement brief but clear (2-4 sentences)\n5. List at least 2-3 decision drivers that influenced this choice\n6. Include at least 2 considered options (including the chosen one)\n7. Be specific about consequences - list both benefits and drawbacks\n8. In \"More Information\", mention any technical details, related files, or future considerations\n\nRespond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.\n";
|
|
32
|
-
/**
|
|
33
|
-
* Formats the generation prompt with actual diff data
|
|
34
|
-
*
|
|
35
|
-
* @param data - Object containing file_paths and diff_content
|
|
36
|
-
* @returns Formatted generation prompt
|
|
37
|
-
*/
|
|
38
7
|
export declare function formatGenerationPrompt(data: {
|
|
39
8
|
file_paths: string[];
|
|
40
9
|
diff_content: string;
|
|
41
10
|
}): string;
|
|
42
|
-
/**
|
|
43
|
-
* Prompt user for ADR generation confirmation
|
|
44
|
-
*
|
|
45
|
-
* @param reason - The reason why this change is architecturally significant
|
|
46
|
-
* @returns Promise<boolean> - true if user wants to generate, false otherwise
|
|
47
|
-
*/
|
|
48
11
|
export declare function promptForGeneration(reason: string): Promise<boolean>;
|
|
49
12
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/llm/prompts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,ksCAoB9B,CAAC;AAEF,eAAO,MAAM,oBAAoB,ihEA0DhC,CAAC;AAEF,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACnD,MAAM,CAMR;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAQT;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuB1E"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Prompts Module
|
|
4
|
-
*
|
|
5
|
-
* Contains versioned prompt templates for LLM analysis and ADR generation.
|
|
6
|
-
* Follows the constitution requirement for versioned prompts.
|
|
7
|
-
*/
|
|
8
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
3
|
if (k2 === undefined) k2 = k;
|
|
10
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -44,12 +38,6 @@ exports.formatPrompt = formatPrompt;
|
|
|
44
38
|
exports.formatGenerationPrompt = formatGenerationPrompt;
|
|
45
39
|
exports.promptForGeneration = promptForGeneration;
|
|
46
40
|
const readline = __importStar(require("readline"));
|
|
47
|
-
/**
|
|
48
|
-
* Version 1 of the analysis prompt template.
|
|
49
|
-
*
|
|
50
|
-
* This prompt is designed to analyze code changes for architectural significance.
|
|
51
|
-
* It uses specific criteria for determining significance and enforces strict JSON output.
|
|
52
|
-
*/
|
|
53
41
|
exports.ANALYSIS_PROMPT_V1 = `
|
|
54
42
|
You are an expert principal engineer and software architect acting as a meticulous code reviewer. Your sole task is to determine if the provided git diff represents an architecturally significant change that warrants an Architectural Decision Record (ADR).
|
|
55
43
|
|
|
@@ -71,29 +59,6 @@ Respond ONLY with a single, minified JSON object with no preamble, no markdown,
|
|
|
71
59
|
|
|
72
60
|
The "reason" should be a concise, one-sentence explanation for your decision, suitable for showing to a developer. If the change is not significant, the reason should be an empty string.
|
|
73
61
|
`;
|
|
74
|
-
/**
|
|
75
|
-
* Formats a prompt template by replacing placeholders with actual data.
|
|
76
|
-
*
|
|
77
|
-
* @param template - The prompt template with placeholders
|
|
78
|
-
* @param data - Object containing file_paths and diff_content
|
|
79
|
-
* @returns Formatted prompt with placeholders replaced
|
|
80
|
-
*/
|
|
81
|
-
function formatPrompt(template, data) {
|
|
82
|
-
// Format file paths as a readable list
|
|
83
|
-
const formattedFilePaths = data.file_paths.length > 0
|
|
84
|
-
? data.file_paths.join('\n')
|
|
85
|
-
: 'No files';
|
|
86
|
-
// Replace placeholders with actual data
|
|
87
|
-
return template
|
|
88
|
-
.replace('{file_paths}', formattedFilePaths)
|
|
89
|
-
.replace('{diff_content}', data.diff_content);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Version 1 of the generation prompt template.
|
|
93
|
-
*
|
|
94
|
-
* This prompt generates ADRs following the MADR (Markdown Architectural Decision Records) format.
|
|
95
|
-
* MADR is a lean template for documenting architectural decisions in a structured way.
|
|
96
|
-
*/
|
|
97
62
|
exports.GENERATION_PROMPT_V1 = `
|
|
98
63
|
You are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.
|
|
99
64
|
|
|
@@ -153,40 +118,30 @@ IMPORTANT INSTRUCTIONS:
|
|
|
153
118
|
|
|
154
119
|
Respond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.
|
|
155
120
|
`;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
121
|
+
function formatPrompt(template, data) {
|
|
122
|
+
const formattedFilePaths = data.file_paths.length > 0 ? data.file_paths.join('\n') : 'No files';
|
|
123
|
+
return template
|
|
124
|
+
.replace('{file_paths}', formattedFilePaths)
|
|
125
|
+
.replace('{diff_content}', data.diff_content);
|
|
126
|
+
}
|
|
162
127
|
function formatGenerationPrompt(data) {
|
|
163
|
-
const formattedFilePaths = data.file_paths.length > 0
|
|
164
|
-
? data.file_paths.join('\n')
|
|
165
|
-
: 'No files';
|
|
128
|
+
const formattedFilePaths = data.file_paths.length > 0 ? data.file_paths.join('\n') : 'No files';
|
|
166
129
|
const currentDate = new Date().toISOString().split('T')[0];
|
|
167
|
-
return exports.GENERATION_PROMPT_V1
|
|
168
|
-
.replace('{file_paths}', formattedFilePaths)
|
|
130
|
+
return exports.GENERATION_PROMPT_V1.replace('{file_paths}', formattedFilePaths)
|
|
169
131
|
.replace('{diff_content}', data.diff_content)
|
|
170
132
|
.replace('{current_date}', currentDate);
|
|
171
133
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Prompt user for ADR generation confirmation
|
|
174
|
-
*
|
|
175
|
-
* @param reason - The reason why this change is architecturally significant
|
|
176
|
-
* @returns Promise<boolean> - true if user wants to generate, false otherwise
|
|
177
|
-
*/
|
|
178
134
|
async function promptForGeneration(reason) {
|
|
179
135
|
return new Promise((resolve) => {
|
|
180
136
|
const rl = readline.createInterface({
|
|
181
137
|
input: process.stdin,
|
|
182
138
|
output: process.stdout,
|
|
183
139
|
});
|
|
184
|
-
|
|
140
|
+
/* eslint-disable-next-line no-console */
|
|
185
141
|
console.log(`\n💭 ${reason}\n`);
|
|
186
142
|
rl.question('📝 Would you like to generate an ADR for this change? (Press ENTER or type "yes" to confirm, "no" to skip): ', (answer) => {
|
|
187
143
|
rl.close();
|
|
188
144
|
const normalized = answer.trim().toLowerCase();
|
|
189
|
-
// Accept: empty (ENTER), "y", "yes"
|
|
190
145
|
const confirmed = normalized === '' || normalized === 'y' || normalized === 'yes';
|
|
191
146
|
resolve(confirmed);
|
|
192
147
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/llm/prompts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,oCASC;AAED,wDAWC;AAED,kDAuBC;AAnID,mDAAqC;AAExB,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;CAoBjC,CAAC;AAEW,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DnC,CAAC;AAEF,SAAgB,YAAY,CAC1B,QAAgB,EAChB,IAAoD;IAEpD,MAAM,kBAAkB,GAAG,IA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I,EAAE,CAAC,WAAW,EAAE,CAAC;YAE/C,MAAM,SAAS,GAAG,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,KAAK,CAAC;YAElF,OAAO,CAAC,SAAS,CAAC,CAAC;QACrB,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ParsedAnalysisResponse {
|
|
2
|
+
is_significant: boolean;
|
|
3
|
+
reason: string;
|
|
4
|
+
confidence?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseAnalysisResponse(responseContent: string): ParsedAnalysisResponse;
|
|
7
|
+
export declare function extractTitleFromMarkdown(content: string): string;
|
|
8
|
+
export declare function parseLLMResponse<T>(responseContent: string, validator: (parsed: unknown) => T): T;
|
|
9
|
+
//# sourceMappingURL=response-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-parser.d.ts","sourceRoot":"","sources":["../../src/llm/response-parser.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,GAAG,sBAAsB,CA0CrF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUhE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAyBjG"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAnalysisResponse = parseAnalysisResponse;
|
|
4
|
+
exports.extractTitleFromMarkdown = extractTitleFromMarkdown;
|
|
5
|
+
exports.parseLLMResponse = parseLLMResponse;
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
function parseAnalysisResponse(responseContent) {
|
|
8
|
+
let jsonContent = responseContent.trim();
|
|
9
|
+
const codeBlockMatch = jsonContent.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
|
|
10
|
+
if (codeBlockMatch) {
|
|
11
|
+
jsonContent = codeBlockMatch[1].trim();
|
|
12
|
+
}
|
|
13
|
+
const jsonMatch = jsonContent.match(/\{[\s\S]*\}/);
|
|
14
|
+
if (jsonMatch) {
|
|
15
|
+
jsonContent = jsonMatch[0];
|
|
16
|
+
}
|
|
17
|
+
const parsedResponse = JSON.parse(jsonContent);
|
|
18
|
+
if (typeof parsedResponse.is_significant !== 'boolean' ||
|
|
19
|
+
typeof parsedResponse.reason !== 'string') {
|
|
20
|
+
throw new Error(`Invalid response format. Expected {is_significant: boolean, reason: string}, got: ${JSON.stringify(parsedResponse).substring(0, 150)}...`);
|
|
21
|
+
}
|
|
22
|
+
if (parsedResponse.is_significant && !parsedResponse.reason) {
|
|
23
|
+
throw new Error('LLM indicated significant change but provided no reason');
|
|
24
|
+
}
|
|
25
|
+
const result = {
|
|
26
|
+
is_significant: parsedResponse.is_significant,
|
|
27
|
+
reason: parsedResponse.reason,
|
|
28
|
+
};
|
|
29
|
+
if (typeof parsedResponse.confidence === 'number' &&
|
|
30
|
+
parsedResponse.confidence >= 0 &&
|
|
31
|
+
parsedResponse.confidence <= 1) {
|
|
32
|
+
result.confidence = parsedResponse.confidence;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
function extractTitleFromMarkdown(content) {
|
|
37
|
+
let cleanedContent = content.trim();
|
|
38
|
+
const codeBlockMatch = cleanedContent.match(/```(?:markdown|md)?\s*\n?([\s\S]*?)\n?```/);
|
|
39
|
+
if (codeBlockMatch) {
|
|
40
|
+
cleanedContent = codeBlockMatch[1].trim();
|
|
41
|
+
}
|
|
42
|
+
const titleMatch = cleanedContent.match(/^#\s+(.+)$/m);
|
|
43
|
+
return titleMatch ? titleMatch[1].trim() : 'Untitled Decision';
|
|
44
|
+
}
|
|
45
|
+
function parseLLMResponse(responseContent, validator) {
|
|
46
|
+
try {
|
|
47
|
+
let jsonContent = responseContent.trim();
|
|
48
|
+
const codeBlockMatch = jsonContent.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
|
|
49
|
+
if (codeBlockMatch) {
|
|
50
|
+
jsonContent = codeBlockMatch[1].trim();
|
|
51
|
+
}
|
|
52
|
+
const jsonMatch = jsonContent.match(/\{[\s\S]*\}/);
|
|
53
|
+
if (jsonMatch) {
|
|
54
|
+
jsonContent = jsonMatch[0];
|
|
55
|
+
}
|
|
56
|
+
const parsed = JSON.parse(jsonContent);
|
|
57
|
+
return validator(parsed);
|
|
58
|
+
}
|
|
59
|
+
catch (parseError) {
|
|
60
|
+
logger_1.loggerInstance.warn('Failed to parse LLM response as JSON', {
|
|
61
|
+
error: parseError,
|
|
62
|
+
response: responseContent,
|
|
63
|
+
});
|
|
64
|
+
throw new Error(`Failed to parse LLM response as JSON. Response was:\n${responseContent.substring(0, 200)}...`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=response-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-parser.js","sourceRoot":"","sources":["../../src/llm/response-parser.ts"],"names":[],"mappings":";;AAQA,sDA0CC;AAED,4DAUC;AAED,4CAyBC;AAzFD,sCAAqD;AAQrD,SAAgB,qBAAqB,CAAC,eAAuB;IAC3D,IAAI,WAAW,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;IAEzC,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC/E,IAAI,cAAc,EAAE,CAAC;QACnB,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACzC,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M,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACvD,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC;AACjE,CAAC;AAED,SAAgB,gBAAgB,CAAI,eAAuB,EAAE,SAAiC;IAC5F,IAAI,CAAC;QACH,IAAI,WAAW,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;QAEzC,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC/E,IAAI,cAAc,EAAE,CAAC;YACnB,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,CAAC;QAED,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACnD,IAAI,SAAS,EAAE,CAAC;YACd,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACvC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,UAAU,EAAE,CAAC;QACpB,uBAAM,CAAC,IAAI,CAAC,sCAAsC,EAAE;YAClD,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,eAAe;SAC1B,CAAC,CAAC;QACH,MAAM,IAAI,KAAK,CACb,wDAAwD,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface AnalysisSummary {
|
|
2
|
+
fileCount: number;
|
|
3
|
+
mode: string;
|
|
4
|
+
isSignificant: boolean;
|
|
5
|
+
reason: string;
|
|
6
|
+
confidence?: number;
|
|
7
|
+
filePath?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface DiffOptions {
|
|
11
|
+
mode: 'staged' | 'all' | 'branch-diff';
|
|
12
|
+
base?: string;
|
|
13
|
+
head?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class ConsolePresenter {
|
|
16
|
+
showConfigError(): void;
|
|
17
|
+
showGitError(message: string): void;
|
|
18
|
+
showReadFilesError(): void;
|
|
19
|
+
showNoChanges(options: DiffOptions): void;
|
|
20
|
+
showAnalyzingFiles(files: string[], options: DiffOptions): void;
|
|
21
|
+
showNoDiffContent(): void;
|
|
22
|
+
showSendingToLLM(options: DiffOptions, provider: string, model: string): void;
|
|
23
|
+
showAnalysisFailed(error?: string): void;
|
|
24
|
+
showAnalysisComplete(): void;
|
|
25
|
+
showSignificantResult(summary: AnalysisSummary): void;
|
|
26
|
+
showNotSignificantResult(summary: AnalysisSummary): void;
|
|
27
|
+
showGeneratingADR(): void;
|
|
28
|
+
showGenerationFailed(error?: string): void;
|
|
29
|
+
showADRSuccess(filePath: string): void;
|
|
30
|
+
showADRSaveError(error?: string): void;
|
|
31
|
+
showSkippingGeneration(): void;
|
|
32
|
+
showUnexpectedError(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const presenter: ConsolePresenter;
|
|
35
|
+
//# sourceMappingURL=console-presenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-presenter.d.ts","sourceRoot":"","sources":["../../src/presenters/console-presenter.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,aAAa,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,gBAAgB;IAC3B,eAAe,IAAI,IAAI;IAMvB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAInC,kBAAkB,IAAI,IAAI;IAI1B,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAwBzC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAoB/D,iBAAiB,IAAI,IAAI;IAIzB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAY7E,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAKxC,oBAAoB,IAAI,IAAI;IAI5B,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAQrD,wBAAwB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IASxD,iBAAiB,IAAI,IAAI;IAIzB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAK1C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQtC,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAKtC,sBAAsB,IAAI,IAAI;IAK9B,mBAAmB,IAAI,IAAI;CAI5B;AAED,eAAO,MAAM,SAAS,kBAAyB,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.presenter = exports.ConsolePresenter = void 0;
|
|
4
|
+
class ConsolePresenter {
|
|
5
|
+
showConfigError() {
|
|
6
|
+
console.error('\n❌ Configuration Error');
|
|
7
|
+
console.error('Configuration file not found or invalid.');
|
|
8
|
+
console.error('\n💡 Run `cadr init` to create a configuration file.\n');
|
|
9
|
+
}
|
|
10
|
+
showGitError(message) {
|
|
11
|
+
console.error(`\n❌ Git Error: ${message}\n`);
|
|
12
|
+
}
|
|
13
|
+
showReadFilesError() {
|
|
14
|
+
console.error('\n❌ Failed to read changed files\n');
|
|
15
|
+
}
|
|
16
|
+
showNoChanges(options) {
|
|
17
|
+
const modeText = options.mode === 'staged'
|
|
18
|
+
? 'staged'
|
|
19
|
+
: options.mode === 'branch-diff'
|
|
20
|
+
? `between ${options.base || 'origin/main'} and ${options.head || 'HEAD'}`
|
|
21
|
+
: 'uncommitted';
|
|
22
|
+
console.log(`\nℹ️ No changes to analyze ${options.mode === 'branch-diff' ? modeText : `(${modeText})`}`);
|
|
23
|
+
if (options.mode === 'staged') {
|
|
24
|
+
console.log('💡 Stage some files first:');
|
|
25
|
+
console.log(' git add <files>');
|
|
26
|
+
console.log(' cadr analyze --staged\n');
|
|
27
|
+
}
|
|
28
|
+
else if (options.mode === 'branch-diff') {
|
|
29
|
+
console.log('💡 No changes found between specified git references.\n');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.log('💡 Make some changes first, then run:');
|
|
33
|
+
console.log(' cadr analyze\n');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
showAnalyzingFiles(files, options) {
|
|
37
|
+
const modeText = options.mode === 'staged'
|
|
38
|
+
? 'staged'
|
|
39
|
+
: options.mode === 'branch-diff'
|
|
40
|
+
? `between ${options.base || 'origin/main'} and ${options.head || 'HEAD'}`
|
|
41
|
+
: 'uncommitted';
|
|
42
|
+
const fileCountText = options.mode === 'branch-diff'
|
|
43
|
+
? `${files.length} file${files.length === 1 ? '' : 's'} changed ${modeText}`
|
|
44
|
+
: `${files.length} ${modeText} file${files.length === 1 ? '' : 's'}`;
|
|
45
|
+
console.log(`\n📝 Analyzing ${fileCountText}:`);
|
|
46
|
+
files.forEach((file) => {
|
|
47
|
+
console.log(` • ${file}`);
|
|
48
|
+
});
|
|
49
|
+
console.log('');
|
|
50
|
+
}
|
|
51
|
+
showNoDiffContent() {
|
|
52
|
+
console.log('\nℹ️ No diff content found\n');
|
|
53
|
+
}
|
|
54
|
+
showSendingToLLM(options, provider, model) {
|
|
55
|
+
const analysisText = options.mode === 'staged'
|
|
56
|
+
? 'staged changes'
|
|
57
|
+
: options.mode === 'branch-diff'
|
|
58
|
+
? 'changes'
|
|
59
|
+
: 'uncommitted changes';
|
|
60
|
+
console.log(`🔍 Analyzing ${analysisText} for architectural significance...\n`);
|
|
61
|
+
console.log(`🤖 Sending to ${provider} ${model}...\n`);
|
|
62
|
+
}
|
|
63
|
+
showAnalysisFailed(error) {
|
|
64
|
+
console.error('\n❌ Analysis failed');
|
|
65
|
+
console.error(`\n${error || 'Unknown error occurred'}\n`);
|
|
66
|
+
}
|
|
67
|
+
showAnalysisComplete() {
|
|
68
|
+
console.log('✅ Analysis Complete\n');
|
|
69
|
+
}
|
|
70
|
+
showSignificantResult(summary) {
|
|
71
|
+
console.log('📊 Result: ✨ ARCHITECTURALLY SIGNIFICANT');
|
|
72
|
+
console.log(`💭 Reasoning: ${summary.reason}\n`);
|
|
73
|
+
if (summary.confidence) {
|
|
74
|
+
console.log(`🎯 Confidence: ${(summary.confidence * 100).toFixed(0)}%\n`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
showNotSignificantResult(summary) {
|
|
78
|
+
console.log('📊 Result: ℹ️ NOT ARCHITECTURALLY SIGNIFICANT');
|
|
79
|
+
console.log(`💭 Reasoning: ${summary.reason}\n`);
|
|
80
|
+
if (summary.confidence) {
|
|
81
|
+
console.log(`🎯 Confidence: ${(summary.confidence * 100).toFixed(0)}%\n`);
|
|
82
|
+
}
|
|
83
|
+
console.log('✅ No ADR needed for these changes.\n');
|
|
84
|
+
}
|
|
85
|
+
showGeneratingADR() {
|
|
86
|
+
console.log('\n🧠 Generating ADR draft...\n');
|
|
87
|
+
}
|
|
88
|
+
showGenerationFailed(error) {
|
|
89
|
+
console.error('\n❌ ADR generation failed');
|
|
90
|
+
console.error(`\n${error || 'Unknown error occurred'}\n`);
|
|
91
|
+
}
|
|
92
|
+
showADRSuccess(filePath) {
|
|
93
|
+
console.log('✅ Success! Draft ADR created\n');
|
|
94
|
+
console.log(`📄 File: ${filePath}\n`);
|
|
95
|
+
console.log('💡 Next steps:');
|
|
96
|
+
console.log(' 1. Review and refine the generated ADR');
|
|
97
|
+
console.log(' 2. Commit it alongside your code changes\n');
|
|
98
|
+
}
|
|
99
|
+
showADRSaveError(error) {
|
|
100
|
+
console.error('\n❌ Failed to save ADR');
|
|
101
|
+
console.error(`\n${error || 'Unknown error occurred'}\n`);
|
|
102
|
+
}
|
|
103
|
+
showSkippingGeneration() {
|
|
104
|
+
console.log('\n📋 Skipping ADR generation');
|
|
105
|
+
console.log('🎯 Recommendation: Consider documenting this decision manually.\n');
|
|
106
|
+
}
|
|
107
|
+
showUnexpectedError() {
|
|
108
|
+
console.error('\n❌ An unexpected error occurred');
|
|
109
|
+
console.error('Please check the logs for more details.\n');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.ConsolePresenter = ConsolePresenter;
|
|
113
|
+
exports.presenter = new ConsolePresenter();
|
|
114
|
+
//# sourceMappingURL=console-presenter.js.map
|