@gilbert_oliveira/commit-wizard 1.2.2 → 2.0.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/.commit-wizardrc +17 -0
- package/LICENSE +3 -3
- package/README.md +374 -211
- package/bin/commit-wizard.ts +51 -0
- package/dist/commit-wizard.js +195 -0
- package/package.json +71 -64
- package/src/config/index.ts +237 -0
- package/src/core/cache.ts +210 -0
- package/src/core/index.ts +381 -0
- package/src/core/openai.ts +336 -0
- package/src/core/smart-split.ts +698 -0
- package/src/git/index.ts +177 -0
- package/src/ui/index.ts +204 -0
- package/src/ui/smart-split.ts +141 -0
- package/src/utils/args.ts +56 -0
- package/src/utils/polyfill.ts +82 -0
- package/dist/ai-service.d.ts +0 -44
- package/dist/ai-service.js +0 -287
- package/dist/ai-service.js.map +0 -1
- package/dist/commit-splitter.d.ts +0 -48
- package/dist/commit-splitter.js +0 -227
- package/dist/commit-splitter.js.map +0 -1
- package/dist/config.d.ts +0 -22
- package/dist/config.js +0 -84
- package/dist/config.js.map +0 -1
- package/dist/diff-processor.d.ts +0 -39
- package/dist/diff-processor.js +0 -156
- package/dist/diff-processor.js.map +0 -1
- package/dist/git-utils.d.ts +0 -72
- package/dist/git-utils.js +0 -373
- package/dist/git-utils.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -486
- package/dist/index.js.map +0 -1
package/dist/ai-service.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serviço para interação com APIs de IA
|
|
3
|
-
*/
|
|
4
|
-
export class AIService {
|
|
5
|
-
constructor(config) {
|
|
6
|
-
this.config = config;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Gera prompt do sistema baseado no modo e linguagem
|
|
10
|
-
*/
|
|
11
|
-
getSystemPrompt(mode) {
|
|
12
|
-
const isPortuguese = this.config.language === 'pt';
|
|
13
|
-
if (mode === 'commit') {
|
|
14
|
-
return isPortuguese
|
|
15
|
-
? 'Você é um assistente que gera mensagens de commit seguindo a convenção do Conventional Commits. Use linguagem imperativa em português.'
|
|
16
|
-
: 'You are an assistant that generates commit messages following the Conventional Commits convention. Use imperative language in English.';
|
|
17
|
-
}
|
|
18
|
-
return isPortuguese
|
|
19
|
-
? 'Você é um assistente que resume alterações de código de forma breve, usando linguagem imperativa em português.'
|
|
20
|
-
: 'You are an assistant that summarizes code changes briefly, using imperative language in English.';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Gera prompt para mensagem de commit
|
|
24
|
-
*/
|
|
25
|
-
getCommitPrompt() {
|
|
26
|
-
const isPortuguese = this.config.language === 'pt';
|
|
27
|
-
if (isPortuguese) {
|
|
28
|
-
return `
|
|
29
|
-
Por favor, escreva APENAS a mensagem de commit para este diff usando a convenção de Conventional Commits.
|
|
30
|
-
|
|
31
|
-
IMPORTANTE: Retorne SOMENTE a mensagem de commit, sem explicações, sem blocos de código, sem tabelas, sem dados extras.
|
|
32
|
-
|
|
33
|
-
A mensagem deve começar com um tipo de commit, como:
|
|
34
|
-
feat: para novas funcionalidades
|
|
35
|
-
fix: para correções de bugs
|
|
36
|
-
chore: para alterações que não afetam a funcionalidade
|
|
37
|
-
docs: para mudanças na documentação
|
|
38
|
-
style: para alterações no estilo do código (formatação)
|
|
39
|
-
refactor: para alterações no código que não alteram a funcionalidade
|
|
40
|
-
perf: para melhorias de desempenho
|
|
41
|
-
test: para alterações nos testes
|
|
42
|
-
ci: para mudanças no pipeline de integração contínua
|
|
43
|
-
|
|
44
|
-
${this.config.includeEmoji ? 'Inclua emojis apropriados no início da mensagem.' : 'Não inclua emojis na mensagem.'}
|
|
45
|
-
|
|
46
|
-
Para breaking changes, use "!" após o tipo: feat!(auth): reestruturar fluxo de login
|
|
47
|
-
|
|
48
|
-
Use sempre linguagem imperativa, como:
|
|
49
|
-
- "adiciona recurso"
|
|
50
|
-
- "corrige bug"
|
|
51
|
-
- "remove arquivo"
|
|
52
|
-
|
|
53
|
-
Mantenha a mensagem concisa mas informativa.
|
|
54
|
-
|
|
55
|
-
RETORNE APENAS A MENSAGEM DE COMMIT, NADA MAIS.
|
|
56
|
-
`;
|
|
57
|
-
}
|
|
58
|
-
return `
|
|
59
|
-
Please write ONLY the commit message for this diff using the Conventional Commits convention.
|
|
60
|
-
|
|
61
|
-
IMPORTANT: Return ONLY the commit message, no explanations, no code blocks, no tables, no extra data.
|
|
62
|
-
|
|
63
|
-
The message should start with a commit type, such as:
|
|
64
|
-
feat: for new features
|
|
65
|
-
fix: for bug fixes
|
|
66
|
-
chore: for changes that don't affect functionality
|
|
67
|
-
docs: for documentation changes
|
|
68
|
-
style: for code style changes (formatting)
|
|
69
|
-
refactor: for code changes that don't alter functionality
|
|
70
|
-
perf: for performance improvements
|
|
71
|
-
test: for test changes
|
|
72
|
-
ci: for CI pipeline changes
|
|
73
|
-
|
|
74
|
-
${this.config.includeEmoji ? 'Include appropriate emojis at the beginning of the message.' : 'Do not include emojis in the message.'}
|
|
75
|
-
|
|
76
|
-
For breaking changes, use "!" after the type: feat!(auth): restructure login flow
|
|
77
|
-
|
|
78
|
-
Always use imperative language, such as:
|
|
79
|
-
- "add feature"
|
|
80
|
-
- "fix bug"
|
|
81
|
-
- "remove file"
|
|
82
|
-
|
|
83
|
-
Keep the message concise but informative.
|
|
84
|
-
|
|
85
|
-
RETURN ONLY THE COMMIT MESSAGE, NOTHING ELSE.
|
|
86
|
-
`;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Realiza chamada para a API da OpenAI
|
|
90
|
-
*/
|
|
91
|
-
async callOpenAI(prompt, mode = 'commit') {
|
|
92
|
-
if (!this.config.apiKey) {
|
|
93
|
-
throw new Error('API key da OpenAI não configurada');
|
|
94
|
-
}
|
|
95
|
-
const url = 'https://api.openai.com/v1/chat/completions';
|
|
96
|
-
const systemPrompt = this.getSystemPrompt(mode);
|
|
97
|
-
const fullPrompt = mode === 'commit' ? `${this.getCommitPrompt()}\n\nDiff:\n\n${prompt}` : prompt;
|
|
98
|
-
const body = {
|
|
99
|
-
model: this.config.model,
|
|
100
|
-
messages: [
|
|
101
|
-
{ role: 'system', content: systemPrompt },
|
|
102
|
-
{ role: 'user', content: fullPrompt },
|
|
103
|
-
],
|
|
104
|
-
temperature: this.config.temperature,
|
|
105
|
-
max_tokens: 500, // Limite para mensagens de commit
|
|
106
|
-
};
|
|
107
|
-
try {
|
|
108
|
-
// Timeout de 30 segundos para evitar travamentos
|
|
109
|
-
const controller = new AbortController();
|
|
110
|
-
const timeoutId = globalThis.setTimeout(() => controller.abort(), 30000);
|
|
111
|
-
const response = await globalThis.fetch(url, {
|
|
112
|
-
method: 'POST',
|
|
113
|
-
headers: {
|
|
114
|
-
'Content-Type': 'application/json',
|
|
115
|
-
Authorization: `Bearer ${this.config.apiKey}`,
|
|
116
|
-
},
|
|
117
|
-
body: JSON.stringify(body),
|
|
118
|
-
signal: controller.signal,
|
|
119
|
-
});
|
|
120
|
-
globalThis.clearTimeout(timeoutId);
|
|
121
|
-
if (!response.ok) {
|
|
122
|
-
const errorData = await response.json().catch(() => ({}));
|
|
123
|
-
throw new Error(`Erro na API OpenAI (${response.status}): ${errorData.error?.message || response.statusText}`);
|
|
124
|
-
}
|
|
125
|
-
const data = await response.json();
|
|
126
|
-
// Limpa e valida a resposta
|
|
127
|
-
const rawContent = data.choices[0].message.content;
|
|
128
|
-
const cleanContent = this.cleanApiResponse(rawContent);
|
|
129
|
-
return {
|
|
130
|
-
content: cleanContent,
|
|
131
|
-
usage: data.usage
|
|
132
|
-
? {
|
|
133
|
-
promptTokens: data.usage.prompt_tokens,
|
|
134
|
-
completionTokens: data.usage.completion_tokens,
|
|
135
|
-
totalTokens: data.usage.total_tokens,
|
|
136
|
-
}
|
|
137
|
-
: undefined,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
if (error instanceof Error) {
|
|
142
|
-
if (error.name === 'AbortError') {
|
|
143
|
-
throw new Error('Timeout: A requisição demorou mais de 30 segundos. Tente reduzir o tamanho do diff ou verificar sua conexão.');
|
|
144
|
-
}
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
throw new Error(`Erro desconhecido ao chamar API: ${error}`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Limpa a resposta da API removendo conteúdo inválido
|
|
152
|
-
*/
|
|
153
|
-
cleanApiResponse(content) {
|
|
154
|
-
if (!content) {
|
|
155
|
-
throw new Error('Resposta da API está vazia');
|
|
156
|
-
}
|
|
157
|
-
// Remove blocos de código markdown
|
|
158
|
-
let cleaned = content.replace(/```[\s\S]*?```/g, '');
|
|
159
|
-
// Remove backticks isolados
|
|
160
|
-
cleaned = cleaned.replace(/```/g, '');
|
|
161
|
-
// Divide em linhas para limpeza linha por linha
|
|
162
|
-
const lines = cleaned.split('\n');
|
|
163
|
-
const cleanLines = lines.filter(line => {
|
|
164
|
-
const trimmed = line.trim();
|
|
165
|
-
// Remove linhas vazias
|
|
166
|
-
if (!trimmed)
|
|
167
|
-
return false;
|
|
168
|
-
// Remove apenas linhas que são claramente comandos shell ou funções isoladas (mais específico)
|
|
169
|
-
// Não remove se faz parte de uma mensagem de commit válida
|
|
170
|
-
if ((trimmed === 'cleanDiffOutput' ||
|
|
171
|
-
trimmed === 'cleanCommitMessage' ||
|
|
172
|
-
trimmed === 'cleanApiResponse' ||
|
|
173
|
-
trimmed === 'AIService' ||
|
|
174
|
-
trimmed === 'execSync' ||
|
|
175
|
-
trimmed === 'GitUtils') &&
|
|
176
|
-
!trimmed.match(/^(feat|fix|docs|style|refactor|test|chore|perf|ci|build)/)) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
// Remove linhas que contêm tabelas de cobertura (mais rigoroso)
|
|
180
|
-
if (trimmed.includes('|') &&
|
|
181
|
-
(trimmed.includes('%') || trimmed.includes('Stmts') || trimmed.includes('Branch')))
|
|
182
|
-
return false;
|
|
183
|
-
if (trimmed.match(/^[-|]+$/))
|
|
184
|
-
return false;
|
|
185
|
-
if (trimmed.includes('File') && trimmed.includes('Stmts'))
|
|
186
|
-
return false;
|
|
187
|
-
if (trimmed.includes('All files') && trimmed.includes('|'))
|
|
188
|
-
return false;
|
|
189
|
-
if (trimmed.includes('Uncovered Line'))
|
|
190
|
-
return false;
|
|
191
|
-
// Remove linhas com apenas caracteres especiais/separadores
|
|
192
|
-
if (trimmed.match(/^[\s\-|%]+$/))
|
|
193
|
-
return false;
|
|
194
|
-
// Remove linhas que parecem output de ferramentas de cobertura
|
|
195
|
-
if (trimmed.includes('coverage') && trimmed.includes('|'))
|
|
196
|
-
return false;
|
|
197
|
-
if (trimmed.includes('----') && trimmed.includes('|'))
|
|
198
|
-
return false;
|
|
199
|
-
// Remove linhas que contêm nomes de arquivos com estatísticas (padrão específico)
|
|
200
|
-
if (trimmed.match(/\.(ts|js|tsx|jsx)\s*\|\s*\d+\.\d+\s*\|\s*\d+\.\d+/))
|
|
201
|
-
return false;
|
|
202
|
-
// Remove linhas que contêm "src" ou diretórios com estatísticas
|
|
203
|
-
if (trimmed.match(/^\s*(src|tests?|lib|dist)\s*\|\s*\d+\.\d+/))
|
|
204
|
-
return false;
|
|
205
|
-
// Remove linhas com números que parecem estatísticas de cobertura
|
|
206
|
-
if (trimmed.match(/\|\s*\d+\.\d+\s*\|\s*\d+\.\d+\s*\|\s*\d+\.\d+\s*\|\s*\d+\.\d+\s*\|/))
|
|
207
|
-
return false;
|
|
208
|
-
// Remove linhas que contêm caracteres potencialmente perigosos para shell
|
|
209
|
-
// MAS apenas se não forem parte de uma mensagem de commit válida
|
|
210
|
-
if (trimmed.match(/[;|&$`]/) &&
|
|
211
|
-
!trimmed.match(/^(feat|fix|docs|style|refactor|test|chore|perf|ci|build)[:(]/) &&
|
|
212
|
-
!trimmed.includes('test') && // Preserva mensagens sobre testes
|
|
213
|
-
!trimmed.includes('adiciona') && // Preserva mensagens normais
|
|
214
|
-
!trimmed.includes('atualiza') &&
|
|
215
|
-
!trimmed.includes('melhora')) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
// Remove linhas que parecem ser nomes de métodos ou classes TypeScript isoladas
|
|
219
|
-
// MAS preserva se fazem parte de uma mensagem de commit
|
|
220
|
-
if (trimmed.match(/^(private|public|protected|static|class|interface|function|export|import)/) &&
|
|
221
|
-
!trimmed.match(/^(feat|fix|docs|style|refactor|test|chore|perf|ci|build)/)) {
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
return true;
|
|
225
|
-
});
|
|
226
|
-
// Reconstrói o conteúdo
|
|
227
|
-
let result = cleanLines.join('\n').trim();
|
|
228
|
-
// Remove múltiplas linhas vazias
|
|
229
|
-
result = result.replace(/\n\s*\n\s*\n/g, '\n\n');
|
|
230
|
-
// Remove linhas vazias no início e fim
|
|
231
|
-
result = result.replace(/^\s*\n+/, '').replace(/\n+\s*$/, '');
|
|
232
|
-
// Sanitiza caracteres especiais que podem causar problemas (mais conservador)
|
|
233
|
-
result = result.replace(/[`\\]/g, '\\$&');
|
|
234
|
-
// Valida se o resultado é uma mensagem de commit válida
|
|
235
|
-
this.validateCommitMessage(result);
|
|
236
|
-
return result;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Valida se a mensagem de commit é válida
|
|
240
|
-
*/
|
|
241
|
-
validateCommitMessage(message) {
|
|
242
|
-
if (!message || message.trim().length === 0) {
|
|
243
|
-
throw new Error('Mensagem de commit vazia após limpeza');
|
|
244
|
-
}
|
|
245
|
-
// Verifica se a mensagem tem pelo menos um tipo de commit válido
|
|
246
|
-
const validTypes = [
|
|
247
|
-
'feat',
|
|
248
|
-
'fix',
|
|
249
|
-
'docs',
|
|
250
|
-
'style',
|
|
251
|
-
'refactor',
|
|
252
|
-
'test',
|
|
253
|
-
'chore',
|
|
254
|
-
'perf',
|
|
255
|
-
'ci',
|
|
256
|
-
'build',
|
|
257
|
-
];
|
|
258
|
-
const hasValidType = validTypes.some(type => message.toLowerCase().includes(`${type}:`) || message.toLowerCase().includes(`${type}(`));
|
|
259
|
-
if (!hasValidType) {
|
|
260
|
-
console.warn('⚠️ Mensagem de commit não segue padrão Conventional Commits');
|
|
261
|
-
}
|
|
262
|
-
// Verifica se contém apenas caracteres válidos para commit
|
|
263
|
-
const invalidChars = /[^\w\s\-_.:()[\]{}!@#$%^&*+=~`|\\;'",<>/?áéíóúâêîôûàèìòùãõç]/g;
|
|
264
|
-
if (invalidChars.test(message)) {
|
|
265
|
-
console.warn('⚠️ Mensagem contém caracteres especiais que podem causar problemas');
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Gera resumo de um chunk de diff
|
|
270
|
-
*/
|
|
271
|
-
async generateSummary(chunk) {
|
|
272
|
-
const isPortuguese = this.config.language === 'pt';
|
|
273
|
-
const summaryPrefix = isPortuguese
|
|
274
|
-
? 'A partir do diff abaixo, extraia um resumo breve das alterações (use linguagem imperativa):'
|
|
275
|
-
: 'From the diff below, extract a brief summary of the changes (use imperative language):';
|
|
276
|
-
const prompt = `${summaryPrefix}\n\n${chunk}`;
|
|
277
|
-
const response = await this.callOpenAI(prompt, 'summary');
|
|
278
|
-
return response.content;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Gera mensagem de commit baseada no diff ou resumo
|
|
282
|
-
*/
|
|
283
|
-
async generateCommitMessage(diffOrSummary) {
|
|
284
|
-
return this.callOpenAI(diffOrSummary, 'commit');
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
//# sourceMappingURL=ai-service.js.map
|
package/dist/ai-service.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai-service.js","sourceRoot":"","sources":["../src/ai-service.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,OAAO,SAAS;IAGpB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED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AC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,KAAa;QACjC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC;QACnD,MAAM,aAAa,GAAG,YAAY;YAChC,CAAC,CAAC,6FAA6F;YAC/F,CAAC,CAAC,wFAAwF,CAAC;QAE7F,MAAM,MAAM,GAAG,GAAG,aAAa,OAAO,KAAK,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,qBAAqB,CAAC,aAAqB;QAC/C,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { GitUtils } from './git-utils.js';
|
|
2
|
-
import { Config } from './config.js';
|
|
3
|
-
export interface CommitGroup {
|
|
4
|
-
id: string;
|
|
5
|
-
type: 'feat' | 'fix' | 'docs' | 'style' | 'refactor' | 'test' | 'chore' | 'ci';
|
|
6
|
-
emoji: string;
|
|
7
|
-
description: string;
|
|
8
|
-
files: string[];
|
|
9
|
-
diff: string;
|
|
10
|
-
priority: number;
|
|
11
|
-
}
|
|
12
|
-
export interface SplitCommitResult {
|
|
13
|
-
groups: CommitGroup[];
|
|
14
|
-
totalFiles: number;
|
|
15
|
-
suggestedOrder: string[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Serviço para dividir commits grandes em commits menores e organizados
|
|
19
|
-
*/
|
|
20
|
-
export declare class CommitSplitter {
|
|
21
|
-
private gitUtils;
|
|
22
|
-
private config;
|
|
23
|
-
constructor(gitUtils: GitUtils, config: Config);
|
|
24
|
-
/**
|
|
25
|
-
* Analisa um arquivo e determina seu contexto/tipo
|
|
26
|
-
*/
|
|
27
|
-
private analyzeFileContext;
|
|
28
|
-
/**
|
|
29
|
-
* Obtém emoji e prioridade para cada tipo de commit
|
|
30
|
-
*/
|
|
31
|
-
private getCommitTypeInfo;
|
|
32
|
-
/**
|
|
33
|
-
* Agrupa arquivos relacionados por similaridade de caminho
|
|
34
|
-
*/
|
|
35
|
-
private groupRelatedFiles;
|
|
36
|
-
/**
|
|
37
|
-
* Divide o diff atual em grupos de commits organizados
|
|
38
|
-
*/
|
|
39
|
-
analyzeAndSplit(): Promise<SplitCommitResult>;
|
|
40
|
-
/**
|
|
41
|
-
* Gera descrição inteligente para um grupo de arquivos
|
|
42
|
-
*/
|
|
43
|
-
private generateGroupDescription;
|
|
44
|
-
/**
|
|
45
|
-
* Encontra diretório comum de uma lista de arquivos
|
|
46
|
-
*/
|
|
47
|
-
private findCommonDirectory;
|
|
48
|
-
}
|
package/dist/commit-splitter.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
/**
|
|
3
|
-
* Serviço para dividir commits grandes em commits menores e organizados
|
|
4
|
-
*/
|
|
5
|
-
export class CommitSplitter {
|
|
6
|
-
constructor(gitUtils, config) {
|
|
7
|
-
this.gitUtils = gitUtils;
|
|
8
|
-
this.config = config;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Analisa um arquivo e determina seu contexto/tipo
|
|
12
|
-
*/
|
|
13
|
-
analyzeFileContext(filePath, diff) {
|
|
14
|
-
const fileName = filePath.toLowerCase();
|
|
15
|
-
const diffContent = diff.toLowerCase();
|
|
16
|
-
// Testes
|
|
17
|
-
if (fileName.includes('test') || fileName.includes('spec') || fileName.includes('__tests__')) {
|
|
18
|
-
return 'test';
|
|
19
|
-
}
|
|
20
|
-
// Documentação
|
|
21
|
-
if (fileName.includes('readme') ||
|
|
22
|
-
fileName.includes('.md') ||
|
|
23
|
-
fileName.includes('docs/') ||
|
|
24
|
-
fileName.includes('changelog')) {
|
|
25
|
-
return 'docs';
|
|
26
|
-
}
|
|
27
|
-
// CI/CD
|
|
28
|
-
if (fileName.includes('.github/') ||
|
|
29
|
-
fileName.includes('ci.yml') ||
|
|
30
|
-
fileName.includes('workflow') ||
|
|
31
|
-
fileName.includes('pipeline')) {
|
|
32
|
-
return 'ci';
|
|
33
|
-
}
|
|
34
|
-
// Configuração/Build
|
|
35
|
-
if (fileName.includes('package.json') ||
|
|
36
|
-
fileName.includes('tsconfig') ||
|
|
37
|
-
fileName.includes('eslint') ||
|
|
38
|
-
fileName.includes('.config') ||
|
|
39
|
-
fileName.includes('jest.config') ||
|
|
40
|
-
fileName.includes('.gitignore')) {
|
|
41
|
-
return 'chore';
|
|
42
|
-
}
|
|
43
|
-
// Estilos (CSS, formatação)
|
|
44
|
-
if (fileName.includes('.css') ||
|
|
45
|
-
fileName.includes('.scss') ||
|
|
46
|
-
fileName.includes('style') ||
|
|
47
|
-
diffContent.includes('prettier') ||
|
|
48
|
-
diffContent.includes('format')) {
|
|
49
|
-
return 'style';
|
|
50
|
-
}
|
|
51
|
-
// Análise do conteúdo do diff
|
|
52
|
-
if (diffContent.includes('fix') ||
|
|
53
|
-
diffContent.includes('bug') ||
|
|
54
|
-
diffContent.includes('error') ||
|
|
55
|
-
diffContent.includes('throw') ||
|
|
56
|
-
diffContent.includes('catch')) {
|
|
57
|
-
return 'fix';
|
|
58
|
-
}
|
|
59
|
-
if (diffContent.includes('refactor') ||
|
|
60
|
-
diffContent.includes('rename') ||
|
|
61
|
-
diffContent.includes('move') ||
|
|
62
|
-
diffContent.includes('extract') ||
|
|
63
|
-
diffContent.includes('reorganiz')) {
|
|
64
|
-
return 'refactor';
|
|
65
|
-
}
|
|
66
|
-
// Por padrão, considera como nova funcionalidade
|
|
67
|
-
return 'feat';
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Obtém emoji e prioridade para cada tipo de commit
|
|
71
|
-
*/
|
|
72
|
-
getCommitTypeInfo(type) {
|
|
73
|
-
const typeMap = {
|
|
74
|
-
fix: { emoji: '🐛', priority: 1 },
|
|
75
|
-
test: { emoji: '🧪', priority: 2 },
|
|
76
|
-
docs: { emoji: '📚', priority: 3 },
|
|
77
|
-
chore: { emoji: '🔧', priority: 4 },
|
|
78
|
-
style: { emoji: '💄', priority: 5 },
|
|
79
|
-
refactor: { emoji: '♻️', priority: 6 },
|
|
80
|
-
feat: { emoji: '✨', priority: 7 },
|
|
81
|
-
ci: { emoji: '🔄', priority: 8 },
|
|
82
|
-
};
|
|
83
|
-
return typeMap[type];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Agrupa arquivos relacionados por similaridade de caminho
|
|
87
|
-
*/
|
|
88
|
-
groupRelatedFiles(files) {
|
|
89
|
-
const groups = [];
|
|
90
|
-
const processed = new Set();
|
|
91
|
-
for (const file of files) {
|
|
92
|
-
if (processed.has(file))
|
|
93
|
-
continue;
|
|
94
|
-
const group = [file];
|
|
95
|
-
processed.add(file);
|
|
96
|
-
const fileDir = file.split('/').slice(0, -1).join('/');
|
|
97
|
-
const fileName = file.split('/').pop()?.split('.')[0] || '';
|
|
98
|
-
// Procura arquivos relacionados
|
|
99
|
-
for (const otherFile of files) {
|
|
100
|
-
if (processed.has(otherFile) || otherFile === file)
|
|
101
|
-
continue;
|
|
102
|
-
const otherDir = otherFile.split('/').slice(0, -1).join('/');
|
|
103
|
-
const otherName = otherFile.split('/').pop()?.split('.')[0] || '';
|
|
104
|
-
// Mesmo diretório ou nomes similares
|
|
105
|
-
if (fileDir === otherDir ||
|
|
106
|
-
fileName === otherName ||
|
|
107
|
-
otherName.includes(fileName) ||
|
|
108
|
-
fileName.includes(otherName)) {
|
|
109
|
-
group.push(otherFile);
|
|
110
|
-
processed.add(otherFile);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
groups.push(group);
|
|
114
|
-
}
|
|
115
|
-
return groups;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Divide o diff atual em grupos de commits organizados
|
|
119
|
-
*/
|
|
120
|
-
async analyzeAndSplit() {
|
|
121
|
-
console.log(chalk.blue('\n🔍 Analisando mudanças para dividir em commits...'));
|
|
122
|
-
const changedFiles = this.gitUtils.getChangedFiles();
|
|
123
|
-
if (changedFiles.length === 0) {
|
|
124
|
-
throw new Error('Nenhuma mudança detectada para commit');
|
|
125
|
-
}
|
|
126
|
-
console.log(chalk.gray(`📁 Arquivos alterados: ${changedFiles.length}`));
|
|
127
|
-
// Agrupa arquivos por contexto
|
|
128
|
-
const contextGroups = new Map();
|
|
129
|
-
for (const file of changedFiles) {
|
|
130
|
-
const fileDiff = this.gitUtils.getFileDiff(file);
|
|
131
|
-
const context = this.analyzeFileContext(file, fileDiff);
|
|
132
|
-
const key = context;
|
|
133
|
-
if (!contextGroups.has(key)) {
|
|
134
|
-
contextGroups.set(key, { files: [], type: context });
|
|
135
|
-
}
|
|
136
|
-
contextGroups.get(key).files.push(file);
|
|
137
|
-
}
|
|
138
|
-
// Cria grupos de commit
|
|
139
|
-
const commitGroups = [];
|
|
140
|
-
let groupId = 1;
|
|
141
|
-
for (const [, group] of contextGroups) {
|
|
142
|
-
const { emoji, priority } = this.getCommitTypeInfo(group.type);
|
|
143
|
-
// Subdivide grupos grandes por arquivos relacionados
|
|
144
|
-
const relatedGroups = this.groupRelatedFiles(group.files);
|
|
145
|
-
for (const relatedFiles of relatedGroups) {
|
|
146
|
-
const groupDiff = relatedFiles.map(file => this.gitUtils.getFileDiff(file)).join('\n\n');
|
|
147
|
-
commitGroups.push({
|
|
148
|
-
id: `group-${groupId++}`,
|
|
149
|
-
type: group.type,
|
|
150
|
-
emoji,
|
|
151
|
-
description: await this.generateGroupDescription(relatedFiles, group.type),
|
|
152
|
-
files: relatedFiles,
|
|
153
|
-
diff: groupDiff,
|
|
154
|
-
priority,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// Ordena por prioridade e complexidade
|
|
159
|
-
commitGroups.sort((a, b) => {
|
|
160
|
-
if (a.priority !== b.priority)
|
|
161
|
-
return a.priority - b.priority;
|
|
162
|
-
return a.files.length - b.files.length;
|
|
163
|
-
});
|
|
164
|
-
const suggestedOrder = commitGroups.map(g => g.id);
|
|
165
|
-
return {
|
|
166
|
-
groups: commitGroups,
|
|
167
|
-
totalFiles: changedFiles.length,
|
|
168
|
-
suggestedOrder,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Gera descrição inteligente para um grupo de arquivos
|
|
173
|
-
*/
|
|
174
|
-
async generateGroupDescription(files, type) {
|
|
175
|
-
const isPortuguese = this.config.language === 'pt';
|
|
176
|
-
// Descrições padrão por tipo
|
|
177
|
-
const defaultDescriptions = {
|
|
178
|
-
feat: isPortuguese ? 'adiciona nova funcionalidade' : 'add new feature',
|
|
179
|
-
fix: isPortuguese ? 'corrige bug' : 'fix bug',
|
|
180
|
-
docs: isPortuguese ? 'atualiza documentação' : 'update documentation',
|
|
181
|
-
style: isPortuguese ? 'melhora formatação do código' : 'improve code formatting',
|
|
182
|
-
refactor: isPortuguese ? 'refatora código' : 'refactor code',
|
|
183
|
-
test: isPortuguese ? 'adiciona/atualiza testes' : 'add/update tests',
|
|
184
|
-
chore: isPortuguese ? 'atualiza configurações' : 'update configuration',
|
|
185
|
-
ci: isPortuguese ? 'atualiza CI/CD' : 'update CI/CD',
|
|
186
|
-
};
|
|
187
|
-
// Se apenas um arquivo, usa nome específico
|
|
188
|
-
if (files.length === 1) {
|
|
189
|
-
const fileName = files[0].split('/').pop() || '';
|
|
190
|
-
return isPortuguese
|
|
191
|
-
? `${defaultDescriptions[type]} em ${fileName}`
|
|
192
|
-
: `${defaultDescriptions[type]} in ${fileName}`;
|
|
193
|
-
}
|
|
194
|
-
// Se múltiplos arquivos do mesmo diretório
|
|
195
|
-
const commonDir = this.findCommonDirectory(files);
|
|
196
|
-
if (commonDir) {
|
|
197
|
-
return isPortuguese
|
|
198
|
-
? `${defaultDescriptions[type]} em ${commonDir}`
|
|
199
|
-
: `${defaultDescriptions[type]} in ${commonDir}`;
|
|
200
|
-
}
|
|
201
|
-
// Descrição genérica
|
|
202
|
-
return defaultDescriptions[type];
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Encontra diretório comum de uma lista de arquivos
|
|
206
|
-
*/
|
|
207
|
-
findCommonDirectory(files) {
|
|
208
|
-
if (files.length === 0)
|
|
209
|
-
return null;
|
|
210
|
-
const dirs = files.map(f => f.split('/').slice(0, -1));
|
|
211
|
-
if (dirs.length === 1)
|
|
212
|
-
return dirs[0].join('/');
|
|
213
|
-
const commonParts = [];
|
|
214
|
-
const minLength = Math.min(...dirs.map(d => d.length));
|
|
215
|
-
for (let i = 0; i < minLength; i++) {
|
|
216
|
-
const part = dirs[0][i];
|
|
217
|
-
if (dirs.every(d => d[i] === part)) {
|
|
218
|
-
commonParts.push(part);
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return commonParts.length > 0 ? commonParts.join('/') : null;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
//# sourceMappingURL=commit-splitter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commit-splitter.js","sourceRoot":"","sources":["../src/commit-splitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B;;GAEG;AACH,MAAM,OAAO,cAAc;IAIzB,YAAY,QAAkB,EAAE,MAAc;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,QAAgB,EAAE,IAAY;QACvD,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEvC,SAAS;QACT,IAAI,QAAQ,CAAC,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,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;gBACnC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/D,CAAC;CACF"}
|
package/dist/config.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface Config {
|
|
2
|
-
apiKey?: string;
|
|
3
|
-
model: string;
|
|
4
|
-
temperature: number;
|
|
5
|
-
maxTokens: number;
|
|
6
|
-
language: 'pt' | 'en';
|
|
7
|
-
autoCommit: boolean;
|
|
8
|
-
excludePatterns: string[];
|
|
9
|
-
includeEmoji: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Carrega a configuração mesclando defaults com arquivo de config
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadConfig(): Config;
|
|
15
|
-
/**
|
|
16
|
-
* Salva a configuração no arquivo local ou global
|
|
17
|
-
*/
|
|
18
|
-
export declare function saveConfig(config: Partial<Config>, global?: boolean): void;
|
|
19
|
-
/**
|
|
20
|
-
* Cria um arquivo de configuração exemplo
|
|
21
|
-
*/
|
|
22
|
-
export declare function createConfigExample(): void;
|