@entro314labs/ai-changelog-generator 3.1.1 → 3.2.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +412 -875
  2. package/README.md +8 -3
  3. package/ai-changelog-mcp.sh +0 -0
  4. package/ai-changelog.sh +0 -0
  5. package/bin/ai-changelog-dxt.js +9 -9
  6. package/bin/ai-changelog-mcp.js +19 -17
  7. package/bin/ai-changelog.js +6 -6
  8. package/package.json +80 -48
  9. package/src/ai-changelog-generator.js +91 -81
  10. package/src/application/orchestrators/changelog.orchestrator.js +791 -516
  11. package/src/application/services/application.service.js +137 -128
  12. package/src/cli.js +76 -57
  13. package/src/domains/ai/ai-analysis.service.js +289 -209
  14. package/src/domains/analysis/analysis.engine.js +328 -192
  15. package/src/domains/changelog/changelog.service.js +1174 -783
  16. package/src/domains/changelog/workspace-changelog.service.js +487 -249
  17. package/src/domains/git/git-repository.analyzer.js +348 -258
  18. package/src/domains/git/git.service.js +132 -112
  19. package/src/infrastructure/cli/cli.controller.js +390 -274
  20. package/src/infrastructure/config/configuration.manager.js +220 -190
  21. package/src/infrastructure/interactive/interactive-staging.service.js +154 -135
  22. package/src/infrastructure/interactive/interactive-workflow.service.js +200 -159
  23. package/src/infrastructure/mcp/mcp-server.service.js +208 -207
  24. package/src/infrastructure/metrics/metrics.collector.js +140 -123
  25. package/src/infrastructure/providers/core/base-provider.js +87 -40
  26. package/src/infrastructure/providers/implementations/anthropic.js +101 -99
  27. package/src/infrastructure/providers/implementations/azure.js +124 -101
  28. package/src/infrastructure/providers/implementations/bedrock.js +136 -126
  29. package/src/infrastructure/providers/implementations/dummy.js +23 -23
  30. package/src/infrastructure/providers/implementations/google.js +123 -114
  31. package/src/infrastructure/providers/implementations/huggingface.js +94 -87
  32. package/src/infrastructure/providers/implementations/lmstudio.js +75 -60
  33. package/src/infrastructure/providers/implementations/mock.js +69 -73
  34. package/src/infrastructure/providers/implementations/ollama.js +89 -66
  35. package/src/infrastructure/providers/implementations/openai.js +88 -89
  36. package/src/infrastructure/providers/implementations/vertex.js +227 -197
  37. package/src/infrastructure/providers/provider-management.service.js +245 -207
  38. package/src/infrastructure/providers/provider-manager.service.js +145 -125
  39. package/src/infrastructure/providers/utils/base-provider-helpers.js +308 -302
  40. package/src/infrastructure/providers/utils/model-config.js +220 -195
  41. package/src/infrastructure/providers/utils/provider-utils.js +105 -100
  42. package/src/infrastructure/validation/commit-message-validation.service.js +259 -161
  43. package/src/shared/constants/colors.js +453 -180
  44. package/src/shared/utils/cli-demo.js +285 -0
  45. package/src/shared/utils/cli-entry-utils.js +257 -249
  46. package/src/shared/utils/cli-ui.js +447 -0
  47. package/src/shared/utils/diff-processor.js +513 -0
  48. package/src/shared/utils/error-classes.js +125 -156
  49. package/src/shared/utils/json-utils.js +93 -89
  50. package/src/shared/utils/utils.js +1117 -945
  51. package/types/index.d.ts +353 -344
@@ -1,201 +1,205 @@
1
- import { ChangelogOrchestrator } from '../orchestrators/changelog.orchestrator.js';
2
- import { ConfigurationManager } from '../../infrastructure/config/configuration.manager.js';
3
- import colors from '../../shared/constants/colors.js';
1
+ import process from 'node:process'
2
+
3
+ import { ConfigurationManager } from '../../infrastructure/config/configuration.manager.js'
4
+ import colors from '../../shared/constants/colors.js'
5
+ import { ChangelogOrchestrator } from '../orchestrators/changelog.orchestrator.js'
4
6
 
5
7
  export class ApplicationService {
6
8
  constructor(options = {}) {
7
- this.options = options;
8
- this.configManager = new ConfigurationManager();
9
- this.orchestrator = new ChangelogOrchestrator(this.configManager, options);
10
- this.initialized = false;
11
-
9
+ this.options = options
10
+ this.configManager = new ConfigurationManager()
11
+ this.orchestrator = new ChangelogOrchestrator(this.configManager, options)
12
+ this.initialized = false
13
+
12
14
  // Apply options
13
15
  if (options.noColor || process.env.NO_COLOR) {
14
- colors.disable();
16
+ colors.disable()
15
17
  }
16
-
18
+
17
19
  // Wait for orchestrator to initialize
18
- this.initializeAsync();
20
+ this.initializeAsync()
19
21
  }
20
-
22
+
21
23
  async initializeAsync() {
22
24
  try {
23
25
  // Wait for orchestrator services to be ready
24
- await this.orchestrator.ensureInitialized();
25
- this.initialized = true;
26
+ await this.orchestrator.ensureInitialized()
27
+ this.initialized = true
26
28
  } catch (error) {
27
- console.error(colors.errorMessage('Application service initialization failed:'), error.message);
29
+ console.error(
30
+ colors.errorMessage('Application service initialization failed:'),
31
+ error.message
32
+ )
28
33
  }
29
34
  }
30
-
35
+
31
36
  async ensureInitialized() {
32
37
  if (!this.initialized) {
33
- await this.initializeAsync();
38
+ await this.initializeAsync()
34
39
  }
35
40
  }
36
41
 
37
42
  async generateChangelog(options = {}) {
38
43
  try {
39
- const { version, since } = options;
40
- return await this.orchestrator.generateChangelog(version, since);
44
+ const { version, since } = options
45
+ return await this.orchestrator.generateChangelog(version, since)
41
46
  } catch (error) {
42
- console.error(colors.errorMessage('Application service error:'), error.message);
43
- throw error;
47
+ console.error(colors.errorMessage('Application service error:'), error.message)
48
+ throw error
44
49
  }
45
50
  }
46
51
 
47
52
  async analyzeRepository(options = {}) {
48
53
  try {
49
- return await this.orchestrator.analyzeRepository(options);
54
+ return await this.orchestrator.analyzeRepository(options)
50
55
  } catch (error) {
51
- console.error(colors.errorMessage('Repository analysis error:'), error.message);
52
- throw error;
56
+ console.error(colors.errorMessage('Repository analysis error:'), error.message)
57
+ throw error
53
58
  }
54
59
  }
55
60
 
56
61
  async analyzeCurrentChanges() {
57
62
  try {
58
- await this.ensureInitialized();
59
- return await this.orchestrator.analyzeRepository({ type: 'changes' });
63
+ await this.ensureInitialized()
64
+ return await this.orchestrator.analyzeRepository({ type: 'changes' })
60
65
  } catch (error) {
61
- console.error(colors.errorMessage('Changes analysis error:'), error.message);
62
- throw error;
66
+ console.error(colors.errorMessage('Changes analysis error:'), error.message)
67
+ throw error
63
68
  }
64
69
  }
65
70
 
66
71
  async analyzeRecentCommits(limit = 10) {
67
72
  try {
68
- return await this.orchestrator.analyzeRepository({
69
- type: 'commits',
70
- limit
71
- });
73
+ return await this.orchestrator.analyzeRepository({
74
+ type: 'commits',
75
+ limit,
76
+ })
72
77
  } catch (error) {
73
- console.error(colors.errorMessage('Commits analysis error:'), error.message);
74
- throw error;
78
+ console.error(colors.errorMessage('Commits analysis error:'), error.message)
79
+ throw error
75
80
  }
76
81
  }
77
82
 
78
83
  async assessHealth(options = {}) {
79
84
  try {
80
- return await this.orchestrator.analyzeRepository({
85
+ return await this.orchestrator.analyzeRepository({
81
86
  type: 'health',
82
- ...options
83
- });
87
+ ...options,
88
+ })
84
89
  } catch (error) {
85
- console.error(colors.errorMessage('Health assessment error:'), error.message);
86
- throw error;
90
+ console.error(colors.errorMessage('Health assessment error:'), error.message)
91
+ throw error
87
92
  }
88
93
  }
89
94
 
90
95
  async generateChangelogFromChanges(version) {
91
96
  try {
92
- return await this.orchestrator.generateChangelogFromChanges(version);
97
+ return await this.orchestrator.generateChangelogFromChanges(version)
93
98
  } catch (error) {
94
- console.error(colors.errorMessage('Working directory changelog error:'), error.message);
95
- throw error;
99
+ console.error(colors.errorMessage('Working directory changelog error:'), error.message)
100
+ throw error
96
101
  }
97
102
  }
98
103
 
99
104
  async runInteractive() {
100
105
  try {
101
- return await this.orchestrator.runInteractive();
106
+ return await this.orchestrator.runInteractive()
102
107
  } catch (error) {
103
- console.error(colors.errorMessage('Interactive mode error:'), error.message);
104
- throw error;
108
+ console.error(colors.errorMessage('Interactive mode error:'), error.message)
109
+ throw error
105
110
  }
106
111
  }
107
112
 
108
113
  // Configuration delegation
109
114
  setAnalysisMode(mode) {
110
- this.orchestrator.setAnalysisMode(mode);
115
+ this.orchestrator.setAnalysisMode(mode)
111
116
  }
112
117
 
113
118
  setModelOverride(model) {
114
- this.orchestrator.setModelOverride(model);
119
+ this.orchestrator.setModelOverride(model)
115
120
  }
116
121
 
117
122
  // Metrics delegation
118
123
  getMetrics() {
119
- return this.orchestrator.getMetrics();
124
+ return this.orchestrator.getMetrics()
120
125
  }
121
126
 
122
127
  resetMetrics() {
123
- this.orchestrator.resetMetrics();
128
+ this.orchestrator.resetMetrics()
124
129
  }
125
130
 
126
131
  // Provider management
127
132
  async listProviders() {
128
133
  try {
129
- return await this.orchestrator.providerManager.listProviders();
134
+ return await this.orchestrator.providerManager.listProviders()
130
135
  } catch (error) {
131
- console.error(colors.errorMessage('Provider listing error:'), error.message);
132
- throw error;
136
+ console.error(colors.errorMessage('Provider listing error:'), error.message)
137
+ throw error
133
138
  }
134
139
  }
135
140
 
136
- async switchProvider(providerName) {
141
+ switchProvider(providerName) {
137
142
  try {
138
- const result = this.orchestrator.providerManager.switchProvider(providerName);
143
+ const result = this.orchestrator.providerManager.switchProvider(providerName)
139
144
  if (result.success) {
140
145
  // Reinitialize services with new provider
141
- this.orchestrator.initializeServices();
142
- console.log(colors.successMessage(`✅ Switched to provider: ${providerName}`));
146
+ this.orchestrator.initializeServices()
147
+ console.log(colors.successMessage(`✅ Switched to provider: ${providerName}`))
143
148
  }
144
- return result;
149
+ return result
145
150
  } catch (error) {
146
- console.error(colors.errorMessage('Provider switch error:'), error.message);
147
- return { success: false, error: error.message };
151
+ console.error(colors.errorMessage('Provider switch error:'), error.message)
152
+ return { success: false, error: error.message }
148
153
  }
149
154
  }
150
155
 
151
156
  // Validation methods
152
- async validateConfiguration() {
157
+ validateConfiguration() {
153
158
  try {
154
159
  // Basic validation
155
- const config = this.configManager.getAll();
156
- const issues = [];
157
-
158
- if (!config.GIT_PATH && !process.cwd()) {
159
- issues.push('No git path configured');
160
+ const config = this.configManager.getAll()
161
+ const issues = []
162
+
163
+ if (!(config.GIT_PATH || process.cwd())) {
164
+ issues.push('No git path configured')
160
165
  }
161
-
166
+
162
167
  // Validate AI provider if available
163
168
  if (this.orchestrator.aiProvider) {
164
- const isAvailable = this.orchestrator.aiProvider.isAvailable();
169
+ const isAvailable = this.orchestrator.aiProvider.isAvailable()
165
170
  if (!isAvailable) {
166
- issues.push('AI provider not properly configured');
171
+ issues.push('AI provider not properly configured')
167
172
  }
168
173
  }
169
-
174
+
170
175
  return {
171
176
  valid: issues.length === 0,
172
177
  issues,
173
- recommendations: this.generateRecommendations(issues)
174
- };
175
-
178
+ recommendations: this.generateRecommendations(issues),
179
+ }
176
180
  } catch (error) {
177
- console.error(colors.errorMessage('Configuration validation error:'), error.message);
181
+ console.error(colors.errorMessage('Configuration validation error:'), error.message)
178
182
  return {
179
183
  valid: false,
180
184
  issues: [error.message],
181
- recommendations: []
182
- };
185
+ recommendations: [],
186
+ }
183
187
  }
184
188
  }
185
189
 
186
190
  generateRecommendations(issues) {
187
- const recommendations = [];
188
-
189
- issues.forEach(issue => {
191
+ const recommendations = []
192
+
193
+ issues.forEach((issue) => {
190
194
  if (issue.includes('git path')) {
191
- recommendations.push('Set GIT_PATH environment variable or run from git repository');
195
+ recommendations.push('Set GIT_PATH environment variable or run from git repository')
192
196
  }
193
197
  if (issue.includes('AI provider')) {
194
- recommendations.push('Configure AI provider credentials in .env.local file');
198
+ recommendations.push('Configure AI provider credentials in .env.local file')
195
199
  }
196
- });
197
-
198
- return recommendations;
200
+ })
201
+
202
+ return recommendations
199
203
  }
200
204
 
201
205
  // Health check
@@ -204,111 +208,116 @@ export class ApplicationService {
204
208
  const health = {
205
209
  status: 'healthy',
206
210
  checks: {},
207
- timestamp: new Date().toISOString()
208
- };
209
-
211
+ timestamp: new Date().toISOString(),
212
+ }
213
+
210
214
  // Git check
211
215
  try {
212
216
  health.checks.git = {
213
217
  status: this.orchestrator.gitManager.isGitRepo ? 'ok' : 'error',
214
- message: this.orchestrator.gitManager.isGitRepo ? 'Git repository detected' : 'Not a git repository'
215
- };
218
+ message: this.orchestrator.gitManager.isGitRepo
219
+ ? 'Git repository detected'
220
+ : 'Not a git repository',
221
+ }
216
222
  } catch (error) {
217
- health.checks.git = { status: 'error', message: error.message };
223
+ health.checks.git = { status: 'error', message: error.message }
218
224
  }
219
-
225
+
220
226
  // AI provider check
221
227
  try {
222
228
  health.checks.ai = {
223
229
  status: this.orchestrator.aiProvider?.isAvailable() ? 'ok' : 'warning',
224
- message: this.orchestrator.aiProvider?.isAvailable() ? 'AI provider available' : 'AI provider not configured'
225
- };
230
+ message: this.orchestrator.aiProvider?.isAvailable()
231
+ ? 'AI provider available'
232
+ : 'AI provider not configured',
233
+ }
226
234
  } catch (error) {
227
- health.checks.ai = { status: 'error', message: error.message };
235
+ health.checks.ai = { status: 'error', message: error.message }
228
236
  }
229
-
237
+
230
238
  // Configuration check
231
239
  try {
232
- const configValidation = await this.validateConfiguration();
240
+ const configValidation = await this.validateConfiguration()
233
241
  health.checks.config = {
234
242
  status: configValidation.valid ? 'ok' : 'warning',
235
- message: configValidation.valid ? 'Configuration valid' : `${configValidation.issues.length} issues found`
236
- };
243
+ message: configValidation.valid
244
+ ? 'Configuration valid'
245
+ : `${configValidation.issues.length} issues found`,
246
+ }
237
247
  } catch (error) {
238
- health.checks.config = { status: 'error', message: error.message };
248
+ health.checks.config = { status: 'error', message: error.message }
239
249
  }
240
-
250
+
241
251
  // Overall status
242
- const hasErrors = Object.values(health.checks).some(check => check.status === 'error');
243
- const hasWarnings = Object.values(health.checks).some(check => check.status === 'warning');
244
-
252
+ const hasErrors = Object.values(health.checks).some((check) => check.status === 'error')
253
+ const hasWarnings = Object.values(health.checks).some((check) => check.status === 'warning')
254
+
245
255
  if (hasErrors) {
246
- health.status = 'unhealthy';
256
+ health.status = 'unhealthy'
247
257
  } else if (hasWarnings) {
248
- health.status = 'degraded';
258
+ health.status = 'degraded'
249
259
  }
250
-
251
- return health;
252
-
260
+
261
+ return health
253
262
  } catch (error) {
254
263
  return {
255
264
  status: 'unhealthy',
256
265
  error: error.message,
257
- timestamp: new Date().toISOString()
258
- };
266
+ timestamp: new Date().toISOString(),
267
+ }
259
268
  }
260
269
  }
261
270
 
262
271
  // Commit message generation
263
272
  async generateCommitMessage() {
264
273
  try {
265
- await this.ensureInitialized();
266
- return await this.orchestrator.interactiveService.generateCommitSuggestion();
274
+ await this.ensureInitialized()
275
+ return await this.orchestrator.interactiveService.generateCommitSuggestion()
267
276
  } catch (error) {
268
- console.error(colors.errorMessage('Commit message generation error:'), error.message);
269
- throw error;
277
+ console.error(colors.errorMessage('Commit message generation error:'), error.message)
278
+ throw error
270
279
  }
271
280
  }
272
281
 
273
282
  // Provider validation methods
274
283
  async validateProvider(providerName) {
275
284
  try {
276
- return await this.orchestrator.providerManager.testProvider(providerName);
285
+ return await this.orchestrator.providerManager.testProvider(providerName)
277
286
  } catch (error) {
278
- console.error(colors.errorMessage('Provider validation error:'), error.message);
279
- throw error;
287
+ console.error(colors.errorMessage('Provider validation error:'), error.message)
288
+ throw error
280
289
  }
281
290
  }
282
291
 
283
292
  async validateAllProviders() {
284
293
  try {
285
- return await this.orchestrator.providerManager.validateAll();
294
+ return await this.orchestrator.providerManager.validateAll()
286
295
  } catch (error) {
287
- console.error(colors.errorMessage('All providers validation error:'), error.message);
288
- throw error;
296
+ console.error(colors.errorMessage('All providers validation error:'), error.message)
297
+ throw error
289
298
  }
290
299
  }
291
300
 
292
301
  // Additional helper methods
293
302
  async generateChangelogFromCommits(commitHashes) {
294
303
  try {
295
- return await this.orchestrator.interactiveService.generateChangelogForCommits(commitHashes);
304
+ return await this.orchestrator.interactiveService.generateChangelogForCommits(commitHashes)
296
305
  } catch (error) {
297
- console.error(colors.errorMessage('Changelog from commits error:'), error.message);
298
- throw error;
306
+ console.error(colors.errorMessage('Changelog from commits error:'), error.message)
307
+ throw error
299
308
  }
300
309
  }
301
310
 
302
311
  // Interactive commit workflow
303
312
  async executeCommitWorkflow(options = {}) {
304
313
  try {
305
- await this.ensureInitialized();
306
-
314
+ await this.ensureInitialized()
315
+
307
316
  // Delegate to orchestrator for the commit workflow
308
- return await this.orchestrator.executeCommitWorkflow(options);
317
+ return await this.orchestrator.executeCommitWorkflow(options)
309
318
  } catch (error) {
310
- console.error(colors.errorMessage('Commit workflow error:'), error.message);
311
- throw error;
319
+ console.error(colors.errorMessage('Commit workflow error:'), error.message)
320
+ throw error
312
321
  }
313
322
  }
314
- }
323
+ }