@m3hti/commit-genie 1.2.4 → 1.2.5

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 (101) hide show
  1. package/package.json +1 -1
  2. package/dist/commands/config.d.ts +0 -3
  3. package/dist/commands/config.d.ts.map +0 -1
  4. package/dist/commands/config.js +0 -31
  5. package/dist/commands/config.js.map +0 -1
  6. package/dist/commands/generate.d.ts +0 -12
  7. package/dist/commands/generate.d.ts.map +0 -1
  8. package/dist/commands/generate.js +0 -550
  9. package/dist/commands/generate.js.map +0 -1
  10. package/dist/commands/generate.test.d.ts +0 -2
  11. package/dist/commands/generate.test.d.ts.map +0 -1
  12. package/dist/commands/generate.test.js +0 -168
  13. package/dist/commands/generate.test.js.map +0 -1
  14. package/dist/commands/hook.d.ts +0 -4
  15. package/dist/commands/hook.d.ts.map +0 -1
  16. package/dist/commands/hook.js +0 -62
  17. package/dist/commands/hook.js.map +0 -1
  18. package/dist/commands/stats.d.ts +0 -6
  19. package/dist/commands/stats.d.ts.map +0 -1
  20. package/dist/commands/stats.js +0 -39
  21. package/dist/commands/stats.js.map +0 -1
  22. package/dist/data/wordlist.d.ts +0 -11
  23. package/dist/data/wordlist.d.ts.map +0 -1
  24. package/dist/data/wordlist.js +0 -170
  25. package/dist/data/wordlist.js.map +0 -1
  26. package/dist/index.d.ts +0 -3
  27. package/dist/index.d.ts.map +0 -1
  28. package/dist/index.js +0 -82
  29. package/dist/index.js.map +0 -1
  30. package/dist/services/aiService.d.ts +0 -42
  31. package/dist/services/aiService.d.ts.map +0 -1
  32. package/dist/services/aiService.js +0 -224
  33. package/dist/services/aiService.js.map +0 -1
  34. package/dist/services/analyzerService.d.ts +0 -129
  35. package/dist/services/analyzerService.d.ts.map +0 -1
  36. package/dist/services/analyzerService.js +0 -1656
  37. package/dist/services/analyzerService.js.map +0 -1
  38. package/dist/services/analyzerService.test.d.ts +0 -2
  39. package/dist/services/analyzerService.test.d.ts.map +0 -1
  40. package/dist/services/analyzerService.test.js +0 -514
  41. package/dist/services/analyzerService.test.js.map +0 -1
  42. package/dist/services/configService.d.ts +0 -25
  43. package/dist/services/configService.d.ts.map +0 -1
  44. package/dist/services/configService.js +0 -228
  45. package/dist/services/configService.js.map +0 -1
  46. package/dist/services/configService.test.d.ts +0 -2
  47. package/dist/services/configService.test.d.ts.map +0 -1
  48. package/dist/services/configService.test.js +0 -165
  49. package/dist/services/configService.test.js.map +0 -1
  50. package/dist/services/gitService.d.ts +0 -64
  51. package/dist/services/gitService.d.ts.map +0 -1
  52. package/dist/services/gitService.js +0 -303
  53. package/dist/services/gitService.js.map +0 -1
  54. package/dist/services/gitService.test.d.ts +0 -2
  55. package/dist/services/gitService.test.d.ts.map +0 -1
  56. package/dist/services/gitService.test.js +0 -140
  57. package/dist/services/gitService.test.js.map +0 -1
  58. package/dist/services/historyService.d.ts +0 -39
  59. package/dist/services/historyService.d.ts.map +0 -1
  60. package/dist/services/historyService.js +0 -195
  61. package/dist/services/historyService.js.map +0 -1
  62. package/dist/services/historyService.test.d.ts +0 -2
  63. package/dist/services/historyService.test.d.ts.map +0 -1
  64. package/dist/services/historyService.test.js +0 -157
  65. package/dist/services/historyService.test.js.map +0 -1
  66. package/dist/services/hookService.d.ts +0 -29
  67. package/dist/services/hookService.d.ts.map +0 -1
  68. package/dist/services/hookService.js +0 -164
  69. package/dist/services/hookService.js.map +0 -1
  70. package/dist/services/lintService.d.ts +0 -32
  71. package/dist/services/lintService.d.ts.map +0 -1
  72. package/dist/services/lintService.js +0 -191
  73. package/dist/services/lintService.js.map +0 -1
  74. package/dist/services/spellService.d.ts +0 -42
  75. package/dist/services/spellService.d.ts.map +0 -1
  76. package/dist/services/spellService.js +0 -175
  77. package/dist/services/spellService.js.map +0 -1
  78. package/dist/services/splitService.d.ts +0 -32
  79. package/dist/services/splitService.d.ts.map +0 -1
  80. package/dist/services/splitService.js +0 -184
  81. package/dist/services/splitService.js.map +0 -1
  82. package/dist/services/statsService.d.ts +0 -28
  83. package/dist/services/statsService.d.ts.map +0 -1
  84. package/dist/services/statsService.js +0 -204
  85. package/dist/services/statsService.js.map +0 -1
  86. package/dist/types/index.d.ts +0 -222
  87. package/dist/types/index.d.ts.map +0 -1
  88. package/dist/types/index.js +0 -3
  89. package/dist/types/index.js.map +0 -1
  90. package/dist/utils/filePatterns.d.ts +0 -5
  91. package/dist/utils/filePatterns.d.ts.map +0 -1
  92. package/dist/utils/filePatterns.js +0 -77
  93. package/dist/utils/filePatterns.js.map +0 -1
  94. package/dist/utils/filePatterns.test.d.ts +0 -2
  95. package/dist/utils/filePatterns.test.d.ts.map +0 -1
  96. package/dist/utils/filePatterns.test.js +0 -51
  97. package/dist/utils/filePatterns.test.js.map +0 -1
  98. package/dist/utils/prompt.d.ts +0 -4
  99. package/dist/utils/prompt.d.ts.map +0 -1
  100. package/dist/utils/prompt.js +0 -60
  101. package/dist/utils/prompt.js.map +0 -1
package/dist/index.js DELETED
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const commander_1 = require("commander");
5
- const generate_1 = require("./commands/generate");
6
- const hook_1 = require("./commands/hook");
7
- const config_1 = require("./commands/config");
8
- const stats_1 = require("./commands/stats");
9
- const { version } = require('../package.json');
10
- const program = new commander_1.Command();
11
- program
12
- .name('commit-genie')
13
- .description('Generate intelligent Git commit messages based on your code changes')
14
- .version(version);
15
- program
16
- .command('generate')
17
- .alias('gen')
18
- .description('Analyze staged changes and suggest a commit message')
19
- .option('-c, --commit', 'Automatically commit with the generated message')
20
- .option('-d, --dry-run', 'Preview commit without executing (shows what would be committed)')
21
- .option('-a, --amend', 'Amend the last commit message instead of creating a new one')
22
- .option('--ai', 'Use AI to generate enhanced commit descriptions (requires API key in config)')
23
- .option('--no-interactive', 'Disable interactive mode (just show the message)')
24
- .option('--no-lint', 'Skip commit message linting')
25
- .option('-m, --message-only', 'Output only the commit message (for scripts/hooks)')
26
- .option('-s, --single', 'Show only one suggestion (skip multiple options)')
27
- .action((options) => (0, generate_1.generateCommand)(options));
28
- // Hook commands
29
- const hookCommand = program
30
- .command('hook')
31
- .description('Manage git hooks');
32
- hookCommand
33
- .command('install')
34
- .description('Install the prepare-commit-msg hook')
35
- .action(hook_1.hookInstallCommand);
36
- hookCommand
37
- .command('uninstall')
38
- .description('Uninstall the prepare-commit-msg hook')
39
- .action(hook_1.hookUninstallCommand);
40
- hookCommand
41
- .command('status')
42
- .description('Check if the hook is installed')
43
- .action(hook_1.hookStatusCommand);
44
- // Config commands
45
- const configCommand = program
46
- .command('config')
47
- .description('Manage configuration');
48
- configCommand
49
- .command('init')
50
- .description('Create a default config file')
51
- .action(config_1.configInitCommand);
52
- configCommand
53
- .command('show')
54
- .description('Show current configuration')
55
- .action(config_1.configShowCommand);
56
- // Stats command
57
- program
58
- .command('stats')
59
- .description('Show commit statistics for the repository')
60
- .option('-n, --count <number>', 'Number of commits to analyze', '100')
61
- .option('--json', 'Output as JSON')
62
- .action((options) => {
63
- (0, stats_1.statsCommand)({
64
- count: parseInt(options.count, 10),
65
- json: options.json,
66
- });
67
- });
68
- // Default action (if no command specified, run generate)
69
- program
70
- .option('-c, --commit', 'Automatically commit with the generated message')
71
- .option('-d, --dry-run', 'Preview commit without executing (shows what would be committed)')
72
- .option('-a, --amend', 'Amend the last commit message instead of creating a new one')
73
- .option('--ai', 'Use AI to generate enhanced commit descriptions (requires API key in config)')
74
- .option('--no-interactive', 'Disable interactive mode (just show the message)')
75
- .option('--no-lint', 'Skip commit message linting')
76
- .option('-m, --message-only', 'Output only the commit message (for scripts/hooks)')
77
- .option('-s, --single', 'Show only one suggestion (skip multiple options)')
78
- .action((options) => {
79
- (0, generate_1.generateCommand)(options);
80
- });
81
- program.parse(process.argv);
82
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA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E,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;IAClB,IAAA,0BAAe,EAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,42 +0,0 @@
1
- import { ChangeAnalysis, CommitType } from '../types';
2
- interface AIResponse {
3
- description: string;
4
- type?: CommitType;
5
- scope?: string;
6
- }
7
- export declare class AIService {
8
- /**
9
- * Check if AI is enabled and configured
10
- */
11
- static isEnabled(): boolean;
12
- /**
13
- * Generate an AI-enhanced description for the commit
14
- */
15
- static generateDescription(analysis: ChangeAnalysis, diff: string): Promise<AIResponse | null>;
16
- /**
17
- * Build the prompt for the AI
18
- */
19
- private static buildPrompt;
20
- /**
21
- * Call OpenAI API
22
- */
23
- private static callOpenAI;
24
- /**
25
- * Call Anthropic API
26
- */
27
- private static callAnthropic;
28
- /**
29
- * Call Google AI Studio (Gemini) API
30
- */
31
- private static callGoogle;
32
- /**
33
- * Call OpenRouter API (OpenAI-compatible)
34
- */
35
- private static callOpenRouter;
36
- /**
37
- * Get default model for provider
38
- */
39
- private static getDefaultModel;
40
- }
41
- export {};
42
- //# sourceMappingURL=aiService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aiService.d.ts","sourceRoot":"","sources":["../../src/services/aiService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtD,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,SAAS;IACpB;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,OAAO;IAK3B;;OAEG;WACU,mBAAmB,CAC9B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmC7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAgC1B;;OAEG;mBACkB,UAAU;IAkC/B;;OAEG;mBACkB,aAAa;IAkClC;;OAEG;mBACkB,UAAU;IA2C/B;;OAEG;mBACkB,cAAc;IAoCnC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;CAc/B"}
@@ -1,224 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AIService = void 0;
4
- const configService_1 = require("./configService");
5
- class AIService {
6
- /**
7
- * Check if AI is enabled and configured
8
- */
9
- static isEnabled() {
10
- const config = configService_1.ConfigService.getConfig();
11
- return config.ai?.enabled === true && !!config.ai?.apiKey;
12
- }
13
- /**
14
- * Generate an AI-enhanced description for the commit
15
- */
16
- static async generateDescription(analysis, diff) {
17
- const config = configService_1.ConfigService.getConfig();
18
- const aiConfig = config.ai;
19
- if (!aiConfig?.enabled || !aiConfig?.apiKey) {
20
- return null;
21
- }
22
- const provider = aiConfig.provider || 'openai';
23
- const model = aiConfig.model || this.getDefaultModel(provider);
24
- // Truncate diff to avoid token limits
25
- const truncatedDiff = diff.length > 3000 ? diff.substring(0, 3000) + '\n...(truncated)' : diff;
26
- const prompt = this.buildPrompt(analysis, truncatedDiff);
27
- try {
28
- if (provider === 'openai') {
29
- return await this.callOpenAI(aiConfig.apiKey, model, prompt);
30
- }
31
- else if (provider === 'anthropic') {
32
- return await this.callAnthropic(aiConfig.apiKey, model, prompt);
33
- }
34
- else if (provider === 'google') {
35
- return await this.callGoogle(aiConfig.apiKey, model, prompt);
36
- }
37
- else if (provider === 'openrouter') {
38
- return await this.callOpenRouter(aiConfig.apiKey, model, prompt);
39
- }
40
- }
41
- catch (error) {
42
- const errorMsg = error instanceof Error ? error.message : 'Unknown error';
43
- console.error(`\n⚠ AI Error: ${errorMsg}`);
44
- throw error; // Re-throw so caller can handle it
45
- }
46
- return null;
47
- }
48
- /**
49
- * Build the prompt for the AI
50
- */
51
- static buildPrompt(analysis, diff) {
52
- const filesChanged = [
53
- ...analysis.fileChanges.added.map(f => `+ ${f} (added)`),
54
- ...analysis.fileChanges.modified.map(f => `~ ${f} (modified)`),
55
- ...analysis.fileChanges.deleted.map(f => `- ${f} (deleted)`),
56
- ...analysis.fileChanges.renamed.map(f => `→ ${f} (renamed)`),
57
- ].join('\n');
58
- return `You are a helpful assistant that generates concise, professional git commit messages following the Conventional Commits specification.
59
-
60
- Given the following git diff and file changes, generate a commit message description (NOT the full message, just the description after the type: prefix).
61
-
62
- FILE CHANGES:
63
- ${filesChanged}
64
-
65
- DETECTED COMMIT TYPE: ${analysis.commitType}
66
- ${analysis.scope ? `DETECTED SCOPE: ${analysis.scope}` : ''}
67
- ${analysis.isBreakingChange ? 'THIS IS A BREAKING CHANGE' : ''}
68
-
69
- GIT DIFF:
70
- ${diff}
71
-
72
- RULES:
73
- 1. Write a clear, concise description (max 50 characters ideal, 72 max)
74
- 2. Use lowercase and imperative mood (e.g., "add", "fix", "update", not "added", "fixes", "updated")
75
- 3. Don't end with a period
76
- 4. Focus on WHAT changed and WHY, not HOW
77
- 5. Be specific but brief
78
-
79
- Respond with ONLY the description text, nothing else. No quotes, no type prefix, just the description.`;
80
- }
81
- /**
82
- * Call OpenAI API
83
- */
84
- static async callOpenAI(apiKey, model, prompt) {
85
- const response = await fetch('https://api.openai.com/v1/chat/completions', {
86
- method: 'POST',
87
- headers: {
88
- 'Content-Type': 'application/json',
89
- 'Authorization': `Bearer ${apiKey}`,
90
- },
91
- body: JSON.stringify({
92
- model,
93
- messages: [
94
- { role: 'user', content: prompt }
95
- ],
96
- max_tokens: 100,
97
- temperature: 0.3,
98
- }),
99
- });
100
- if (!response.ok) {
101
- const errorText = await response.text();
102
- throw new Error(`OpenAI API error: ${response.status} - ${errorText}`);
103
- }
104
- const data = await response.json();
105
- const content = data.choices?.[0]?.message?.content?.trim();
106
- if (content) {
107
- return { description: content.toLowerCase() };
108
- }
109
- return null;
110
- }
111
- /**
112
- * Call Anthropic API
113
- */
114
- static async callAnthropic(apiKey, model, prompt) {
115
- const response = await fetch('https://api.anthropic.com/v1/messages', {
116
- method: 'POST',
117
- headers: {
118
- 'Content-Type': 'application/json',
119
- 'x-api-key': apiKey,
120
- 'anthropic-version': '2023-06-01',
121
- },
122
- body: JSON.stringify({
123
- model,
124
- max_tokens: 100,
125
- messages: [
126
- { role: 'user', content: prompt }
127
- ],
128
- }),
129
- });
130
- if (!response.ok) {
131
- const errorText = await response.text();
132
- throw new Error(`Anthropic API error: ${response.status} - ${errorText}`);
133
- }
134
- const data = await response.json();
135
- const content = data.content?.find(c => c.type === 'text')?.text?.trim();
136
- if (content) {
137
- return { description: content.toLowerCase() };
138
- }
139
- return null;
140
- }
141
- /**
142
- * Call Google AI Studio (Gemini) API
143
- */
144
- static async callGoogle(apiKey, model, prompt) {
145
- const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${apiKey}`, {
146
- method: 'POST',
147
- headers: {
148
- 'Content-Type': 'application/json',
149
- },
150
- body: JSON.stringify({
151
- contents: [
152
- {
153
- parts: [{ text: prompt }],
154
- },
155
- ],
156
- generationConfig: {
157
- maxOutputTokens: 100,
158
- temperature: 0.3,
159
- },
160
- }),
161
- });
162
- if (!response.ok) {
163
- const errorText = await response.text();
164
- throw new Error(`Google AI API error: ${response.status} - ${errorText}`);
165
- }
166
- const data = await response.json();
167
- const content = data.candidates?.[0]?.content?.parts?.[0]?.text?.trim();
168
- if (content) {
169
- return { description: content.toLowerCase() };
170
- }
171
- return null;
172
- }
173
- /**
174
- * Call OpenRouter API (OpenAI-compatible)
175
- */
176
- static async callOpenRouter(apiKey, model, prompt) {
177
- const response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
178
- method: 'POST',
179
- headers: {
180
- 'Content-Type': 'application/json',
181
- 'Authorization': `Bearer ${apiKey}`,
182
- 'HTTP-Referer': 'https://github.com/AhmedMohamedAbdelaty/CommitGenie',
183
- 'X-Title': 'CommitGenie',
184
- },
185
- body: JSON.stringify({
186
- model,
187
- messages: [
188
- { role: 'user', content: prompt }
189
- ],
190
- max_tokens: 100,
191
- temperature: 0.3,
192
- }),
193
- });
194
- if (!response.ok) {
195
- const errorText = await response.text();
196
- throw new Error(`OpenRouter API error: ${response.status} - ${errorText}`);
197
- }
198
- const data = await response.json();
199
- const content = data.choices?.[0]?.message?.content?.trim();
200
- if (content) {
201
- return { description: content.toLowerCase() };
202
- }
203
- return null;
204
- }
205
- /**
206
- * Get default model for provider
207
- */
208
- static getDefaultModel(provider) {
209
- switch (provider) {
210
- case 'openai':
211
- return 'gpt-4o-mini';
212
- case 'anthropic':
213
- return 'claude-3-haiku-20240307';
214
- case 'google':
215
- return 'gemini-1.5-flash';
216
- case 'openrouter':
217
- return 'openai/gpt-3.5-turbo';
218
- default:
219
- return 'gpt-4o-mini';
220
- }
221
- }
222
- }
223
- exports.AIService = AIService;
224
- //# sourceMappingURL=aiService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"aiService.js","sourceRoot":"","sources":["../../src/services/aiService.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAShD,MAAa,SAAS;IACpB;;OAEG;IACH,MAAM,CAAC,SAAS;QACd,MAAM,MAAM,GAAG,6BAAa,CAAC,SAAS,EAAE,CAAC;QACzC,OAAO,MAAM,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAC9B,QAAwB,EACxB,IAAY;QAEZ,MAAM,MAAM,GAAG,6BAAa,CAAC,SAAS,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;QAE3B,IAAI,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,M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C,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC5D,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QAChD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,eAAe,CAAC,QAAgB;QAC7C,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,QAAQ;gBACX,OAAO,aAAa,CAAC;YACvB,KAAK,WAAW;gBACd,OAAO,yBAAyB,CAAC;YACnC,KAAK,QAAQ;gBACX,OAAO,kBAAkB,CAAC;YAC5B,KAAK,YAAY;gBACf,OAAO,sBAAsB,CAAC;YAChC;gBACE,OAAO,aAAa,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AArQD,8BAqQC"}
@@ -1,129 +0,0 @@
1
- import { ChangeAnalysis, CommitMessage, MessageSuggestion } from '../types';
2
- export declare class AnalyzerService {
3
- /**
4
- * Analyze staged changes and return structured analysis
5
- */
6
- static analyzeChanges(): ChangeAnalysis;
7
- /**
8
- * Detect breaking changes from diff content and file changes
9
- */
10
- private static detectBreakingChanges;
11
- /**
12
- * Determine the commit type based on analysis
13
- */
14
- private static determineCommitType;
15
- /**
16
- * Check if diff contains actual logic changes (not just formatting)
17
- */
18
- private static hasLogicChanges;
19
- /**
20
- * Check if the changes are ONLY non-style JavaScript changes
21
- * (console.log, debug statements, test prints, comments, etc.)
22
- * Returns true if JS files have changes but NO actual styling changes
23
- */
24
- private static hasOnlyNonStyleJsChanges;
25
- /**
26
- * Check if the diff contains only comment changes (documentation)
27
- * Returns true if ALL changes are comments (no code changes)
28
- */
29
- private static isCommentOnlyChange;
30
- /**
31
- * Perform semantic analysis on the diff to understand the nature of changes
32
- * This provides intent-based understanding rather than line-count metrics
33
- */
34
- private static analyzeSemanticChanges;
35
- /**
36
- * Detect which roles are affected by the changes and calculate semantic significance
37
- * Significance is NOT based on line count - it's based on the semantic weight of patterns
38
- */
39
- private static detectRoleChanges;
40
- /**
41
- * Determine if a pattern represents a high-value semantic change
42
- */
43
- private static isHighValuePattern;
44
- /**
45
- * Detect the intent for changes in a specific role
46
- */
47
- private static detectRoleIntent;
48
- /**
49
- * Determine the primary role from all detected role changes
50
- */
51
- private static determinePrimaryRole;
52
- /**
53
- * Determine the overall intent of the changes
54
- */
55
- private static determineIntent;
56
- /**
57
- * Extract affected element names (components, functions, etc.) from the diff
58
- */
59
- private static extractAffectedElements;
60
- /**
61
- * Detect function/class/type renames by comparing removed and added names
62
- * Returns an array of { oldName, newName } objects
63
- */
64
- private static detectRenames;
65
- /**
66
- * Extract affected elements for a specific role
67
- */
68
- private static extractElementsForRole;
69
- /**
70
- * Generate a human-readable summary for a role change
71
- */
72
- private static generateRoleSummary;
73
- /**
74
- * Generate the WHY description for the commit
75
- */
76
- private static generateIntentDescription;
77
- /**
78
- * Generate the WHAT changed description
79
- */
80
- private static generateWhatChanged;
81
- /**
82
- * Generate a descriptive commit message
83
- * Uses semantic analysis when available for intent-based descriptions
84
- */
85
- private static generateDescription;
86
- /**
87
- * Generate description based on semantic analysis
88
- * Creates intent-based messages like "update UserProfile validation logic"
89
- */
90
- private static generateSemanticDescription;
91
- /**
92
- * Determine scope from file paths
93
- */
94
- private static determineScope;
95
- /**
96
- * Extract file name from path
97
- */
98
- private static getFileName;
99
- /**
100
- * Generate commit body for larger changes
101
- * Includes semantic role context when available
102
- */
103
- private static generateBody;
104
- /**
105
- * Apply a template to build the commit message subject line
106
- */
107
- private static applyTemplate;
108
- /**
109
- * Build full commit message string
110
- */
111
- private static buildFullMessage;
112
- /**
113
- * Generate the final commit message
114
- */
115
- static generateCommitMessage(): CommitMessage;
116
- /**
117
- * Generate multiple message suggestions
118
- */
119
- static generateMultipleSuggestions(): MessageSuggestion[];
120
- /**
121
- * Generate suggestions with optional AI enhancement
122
- */
123
- static generateSuggestionsWithAI(useAI?: boolean): Promise<MessageSuggestion[]>;
124
- /**
125
- * Generate an alternative description style
126
- */
127
- private static generateAlternativeDescription;
128
- }
129
- //# sourceMappingURL=analyzerService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyzerService.d.ts","sourceRoot":"","sources":["../../src/services/analyzerService.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,EAEd,aAAa,EAGb,iBAAiB,EAKlB,MAAM,UAAU,CAAC;AA+NlB,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,cAAc;IA0GvC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAuEpC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAsRlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IA4B9B;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAkEvC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IA+ClC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAgCrC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA8ChC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAkBjC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAkD/B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IA6BnC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAsD9B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAkDtC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IA0C5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IA8CrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAUlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA2BxC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAkClC;;;OAG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