@gilbert_oliveira/commit-wizard 1.0.25 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,156 @@
1
+ import { encode, decode } from 'gpt-tokenizer';
2
+ import ora from 'ora';
3
+ import cliProgress from 'cli-progress';
4
+ /**
5
+ * Processador de diff para chunks e resumos
6
+ */
7
+ export class DiffProcessor {
8
+ constructor(aiService, maxTokens = 1000) {
9
+ this.aiService = aiService;
10
+ this.maxTokens = maxTokens;
11
+ }
12
+ /**
13
+ * Divide o diff em chunks menores baseado na contagem de tokens
14
+ */
15
+ chunkDiff(diff) {
16
+ const tokens = encode(diff);
17
+ if (tokens.length <= this.maxTokens) {
18
+ return [diff];
19
+ }
20
+ const chunks = [];
21
+ for (let i = 0; i < tokens.length; i += this.maxTokens) {
22
+ const chunkTokens = tokens.slice(i, i + this.maxTokens);
23
+ const chunkText = decode(chunkTokens);
24
+ chunks.push(chunkText);
25
+ }
26
+ return chunks;
27
+ }
28
+ /**
29
+ * Processa diff grande gerando resumos dos chunks
30
+ */
31
+ async processLargeDiff(diff) {
32
+ const chunks = this.chunkDiff(diff);
33
+ if (chunks.length === 1) {
34
+ return chunks[0];
35
+ }
36
+ const partialSummaries = [];
37
+ // Se há muitos chunks, usa progress bar
38
+ if (chunks.length > 3) {
39
+ console.log(`\n📊 Processando ${chunks.length} chunks do diff...\n`);
40
+ const progressBar = new cliProgress.SingleBar({
41
+ format: '🔄 Progresso |' + '{bar}' + '| {percentage}% | {value}/{total} chunks | ETA: {eta}s',
42
+ barCompleteChar: '█',
43
+ barIncompleteChar: '░',
44
+ hideCursor: true,
45
+ });
46
+ progressBar.start(chunks.length, 0);
47
+ try {
48
+ for (let i = 0; i < chunks.length; i++) {
49
+ const summary = await this.aiService.generateSummary(chunks[i]);
50
+ partialSummaries.push(summary);
51
+ progressBar.update(i + 1);
52
+ }
53
+ progressBar.stop();
54
+ console.log(`✅ ${chunks.length} chunks processados com sucesso.\n`);
55
+ }
56
+ catch (error) {
57
+ progressBar.stop();
58
+ console.log('❌ Erro ao processar chunks do diff.\n');
59
+ throw error;
60
+ }
61
+ }
62
+ else {
63
+ // Para poucos chunks, usa spinner simples
64
+ const spinner = ora(`Processando ${chunks.length} chunks...`).start();
65
+ try {
66
+ for (let i = 0; i < chunks.length; i++) {
67
+ spinner.text = `Processando chunk ${i + 1}/${chunks.length}...`;
68
+ const summary = await this.aiService.generateSummary(chunks[i]);
69
+ partialSummaries.push(summary);
70
+ }
71
+ spinner.succeed(`${chunks.length} chunks processados.`);
72
+ }
73
+ catch (error) {
74
+ spinner.fail('Erro ao processar chunks.');
75
+ throw error;
76
+ }
77
+ }
78
+ return partialSummaries.join('\n\n');
79
+ }
80
+ /**
81
+ * Analisa a complexidade do diff
82
+ */
83
+ analyzeDiffComplexity(diff) {
84
+ const tokens = encode(diff);
85
+ const lines = diff.split('\n');
86
+ const fileChanges = (diff.match(/^diff --git/gm) || []).length;
87
+ let complexity = 'simple';
88
+ if (tokens.length > 2000 || fileChanges > 10) {
89
+ complexity = 'complex';
90
+ }
91
+ else if (tokens.length > 500 || fileChanges > 3) {
92
+ complexity = 'moderate';
93
+ }
94
+ return {
95
+ tokenCount: tokens.length,
96
+ lineCount: lines.length,
97
+ fileCount: fileChanges,
98
+ complexity,
99
+ };
100
+ }
101
+ /**
102
+ * Extrai estatísticas do diff
103
+ */
104
+ extractDiffStats(diff) {
105
+ const lines = diff.split('\n');
106
+ let additions = 0;
107
+ let deletions = 0;
108
+ const files = [];
109
+ const types = new Set();
110
+ for (const line of lines) {
111
+ if (line.startsWith('+') && !line.startsWith('+++')) {
112
+ additions++;
113
+ }
114
+ else if (line.startsWith('-') && !line.startsWith('---')) {
115
+ deletions++;
116
+ }
117
+ else if (line.startsWith('diff --git')) {
118
+ const match = line.match(/b\/(.+)$/);
119
+ if (match) {
120
+ const file = match[1];
121
+ files.push(file);
122
+ const ext = file.split('.').pop()?.toLowerCase();
123
+ if (ext) {
124
+ types.add(ext);
125
+ }
126
+ }
127
+ }
128
+ }
129
+ return {
130
+ additions,
131
+ deletions,
132
+ files,
133
+ types: Array.from(types),
134
+ };
135
+ }
136
+ /**
137
+ * Verifica se o diff contém breaking changes
138
+ */
139
+ detectBreakingChanges(diff) {
140
+ const breakingPatterns = [
141
+ /class.*\{[\s\S]*?constructor.*\(/,
142
+ /interface.*\{[\s\S]*?\}/,
143
+ /export.*function.*\(/,
144
+ /export.*class/,
145
+ /export.*interface/,
146
+ /export.*type/,
147
+ /API/i,
148
+ /BREAKING/i,
149
+ /deprecated/i,
150
+ /remove.*function/i,
151
+ /delete.*method/i,
152
+ ];
153
+ return breakingPatterns.some(pattern => pattern.test(diff));
154
+ }
155
+ }
156
+ //# sourceMappingURL=diff-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-processor.js","sourceRoot":"","sources":["../src/diff-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,aAAa;IAIxB,YAAY,SAAoB,EAAE,YAAoB,IAAI;QACxD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,IAAY;QACpB,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAE5B,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC;QAED,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,IA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M,IAAI,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;gBACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACrC,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;oBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAEjB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAC;oBACjD,IAAI,GAAG,EAAE,CAAC;wBACR,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBACjB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,SAAS;YACT,SAAS;YACT,KAAK;YACL,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SACzB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,qBAAqB,CAAC,IAAY;QAChC,MAAM,gBAAgB,GAAG;YACvB,kCAAkC;YAClC,yBAAyB;YACzB,sBAAsB;YACtB,eAAe;YACf,mBAAmB;YACnB,cAAc;YACd,MAAM;YACN,WAAW;YACX,aAAa;YACb,mBAAmB;YACnB,iBAAiB;SAClB,CAAC;QAEF,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ export interface GitStatus {
2
+ hasStagedFiles: boolean;
3
+ stagedFiles: string[];
4
+ diff: string;
5
+ }
6
+ /**
7
+ * Utilitários para operações Git
8
+ */
9
+ export declare class GitUtils {
10
+ private excludePatterns;
11
+ constructor(excludePatterns?: string[]);
12
+ /**
13
+ * Verifica se o diretório atual é um repositório Git
14
+ */
15
+ isGitRepository(): boolean;
16
+ /**
17
+ * Constrói argumentos de exclusão para comandos git
18
+ */
19
+ private buildExcludeArgs;
20
+ /**
21
+ * Obtém status dos arquivos staged
22
+ */
23
+ getStagedStatus(): GitStatus;
24
+ /**
25
+ * Realiza commit com mensagem
26
+ */
27
+ commit(message: string, additionalArgs?: string[]): void;
28
+ /**
29
+ * Realiza commit usando arquivo temporário para a mensagem
30
+ */
31
+ commitWithFile(messageFile: string, additionalArgs?: string[]): void;
32
+ /**
33
+ * Obtém informações sobre o último commit
34
+ */
35
+ getLastCommitInfo(): {
36
+ hash: string;
37
+ message: string;
38
+ author: string;
39
+ date: string;
40
+ };
41
+ /**
42
+ * Verifica se há arquivos não commitados
43
+ */
44
+ hasUncommittedChanges(): boolean;
45
+ /**
46
+ * Lista branches disponíveis
47
+ */
48
+ getBranches(): {
49
+ current: string;
50
+ all: string[];
51
+ };
52
+ }
@@ -0,0 +1,156 @@
1
+ import { execSync } from 'child_process';
2
+ /**
3
+ * Utilitários para operações Git
4
+ */
5
+ export class GitUtils {
6
+ constructor(excludePatterns = []) {
7
+ this.excludePatterns = excludePatterns;
8
+ }
9
+ /**
10
+ * Verifica se o diretório atual é um repositório Git
11
+ */
12
+ isGitRepository() {
13
+ try {
14
+ execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
15
+ return true;
16
+ }
17
+ catch {
18
+ return false;
19
+ }
20
+ }
21
+ /**
22
+ * Constrói argumentos de exclusão para comandos git
23
+ */
24
+ buildExcludeArgs() {
25
+ if (this.excludePatterns.length === 0) {
26
+ return '';
27
+ }
28
+ return this.excludePatterns.map(pattern => `":(exclude)${pattern}"`).join(' ');
29
+ }
30
+ /**
31
+ * Obtém status dos arquivos staged
32
+ */
33
+ getStagedStatus() {
34
+ if (!this.isGitRepository()) {
35
+ throw new Error('Diretório atual não é um repositório Git');
36
+ }
37
+ const excludeArgs = this.buildExcludeArgs();
38
+ try {
39
+ // Verifica arquivos staged
40
+ const stagedFiles = execSync(`git diff --cached --name-only -- . ${excludeArgs}`, {
41
+ encoding: 'utf8',
42
+ })
43
+ .toString()
44
+ .trim();
45
+ if (!stagedFiles) {
46
+ return {
47
+ hasStagedFiles: false,
48
+ stagedFiles: [],
49
+ diff: '',
50
+ };
51
+ }
52
+ // Obtém o diff completo
53
+ const diff = execSync(`git diff --cached -- . ${excludeArgs}`, { encoding: 'utf8' });
54
+ return {
55
+ hasStagedFiles: true,
56
+ stagedFiles: stagedFiles.split('\n').filter(file => file.trim()),
57
+ diff,
58
+ };
59
+ }
60
+ catch (error) {
61
+ throw new Error(`Erro ao obter status Git: ${error}`);
62
+ }
63
+ }
64
+ /**
65
+ * Realiza commit com mensagem
66
+ */
67
+ commit(message, additionalArgs = []) {
68
+ if (!this.isGitRepository()) {
69
+ throw new Error('Diretório atual não é um repositório Git');
70
+ }
71
+ try {
72
+ const args = additionalArgs.length > 0 ? ` ${additionalArgs.join(' ')}` : '';
73
+ execSync(`git commit -m "${message.replace(/"/g, '\\"')}"${args}`, {
74
+ stdio: 'inherit',
75
+ });
76
+ }
77
+ catch (error) {
78
+ throw new Error(`Erro ao realizar commit: ${error}`);
79
+ }
80
+ }
81
+ /**
82
+ * Realiza commit usando arquivo temporário para a mensagem
83
+ */
84
+ commitWithFile(messageFile, additionalArgs = []) {
85
+ if (!this.isGitRepository()) {
86
+ throw new Error('Diretório atual não é um repositório Git');
87
+ }
88
+ try {
89
+ const args = additionalArgs.length > 0 ? ` ${additionalArgs.join(' ')}` : '';
90
+ execSync(`git commit -F "${messageFile}"${args}`, {
91
+ stdio: 'inherit',
92
+ });
93
+ }
94
+ catch (error) {
95
+ throw new Error(`Erro ao realizar commit: ${error}`);
96
+ }
97
+ }
98
+ /**
99
+ * Obtém informações sobre o último commit
100
+ */
101
+ getLastCommitInfo() {
102
+ if (!this.isGitRepository()) {
103
+ throw new Error('Diretório atual não é um repositório Git');
104
+ }
105
+ try {
106
+ const info = execSync('git log -1 --pretty=format:"%H|%s|%an|%ad" --date=short', {
107
+ encoding: 'utf8',
108
+ });
109
+ const [hash, message, author, date] = info.split('|');
110
+ return { hash, message, author, date };
111
+ }
112
+ catch (error) {
113
+ throw new Error(`Erro ao obter informações do último commit: ${error}`);
114
+ }
115
+ }
116
+ /**
117
+ * Verifica se há arquivos não commitados
118
+ */
119
+ hasUncommittedChanges() {
120
+ if (!this.isGitRepository()) {
121
+ return false;
122
+ }
123
+ try {
124
+ const status = execSync('git status --porcelain', { encoding: 'utf8' });
125
+ return status.trim().length > 0;
126
+ }
127
+ catch {
128
+ return false;
129
+ }
130
+ }
131
+ /**
132
+ * Lista branches disponíveis
133
+ */
134
+ getBranches() {
135
+ if (!this.isGitRepository()) {
136
+ throw new Error('Diretório atual não é um repositório Git');
137
+ }
138
+ try {
139
+ const branchOutput = execSync('git branch', { encoding: 'utf8' });
140
+ const branches = branchOutput
141
+ .split('\n')
142
+ .map(line => line.trim())
143
+ .filter(line => line);
144
+ const current = branches
145
+ .find(branch => branch.startsWith('*'))
146
+ ?.replace('*', '')
147
+ .trim() || '';
148
+ const all = branches.map(branch => branch.replace('*', '').trim());
149
+ return { current, all };
150
+ }
151
+ catch (error) {
152
+ throw new Error(`Erro ao obter branches: ${error}`);
153
+ }
154
+ }
155
+ }
156
+ //# sourceMappingURL=git-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-utils.js","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC;;GAEG;AACH,MAAM,OAAO,QAAQ;IAGnB,YAAY,kBAA4B,EAAE;QACxC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,eAAe;QACb,IAAI,CAAC;YACH,QAAQ,CAAC,qCAAqC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YACrE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IA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,IAAI,CAAC,IAAI,EAAE,CAAC;iBACxB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAExB,MAAM,OAAO,GACX,QAAQ;iBACL,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;gBACvC,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;iBACjB,IAAI,EAAE,IAAI,EAAE,CAAC;YAElB,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAEnE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,16 +1,2 @@
1
- #!/usr/bin/env ts-node
2
- /**
3
- * Realiza a chamada à API do OpenAI.
4
- * @param prompt Texto que será enviado como mensagem do usuário.
5
- * @param mode Define o contexto: 'commit' para gerar mensagem de commit ou outro valor para resumo.
6
- * @returns Resposta da API (string com a mensagem ou o resumo).
7
- */
8
- export declare function callOpenAI(prompt: string, mode?: string): Promise<string>;
9
- /**
10
- * Divide o diff em chunks menores com base na contagem de tokens.
11
- * Utiliza o gpt-tokenizer para garantir que cada chunk não exceda o limite de tokens.
12
- * @param diff O diff completo em formato de string.
13
- * @param maxTokens Quantidade máxima de tokens permitida para cada chunk (padrão: 1000 tokens).
14
- * @returns Array de strings, cada uma representando um chunk.
15
- */
16
- export declare function chunkDiff(diff: string, maxTokens?: number): string[];
1
+ #!/usr/bin/env node
2
+ export {};