cast-code 1.0.8 → 1.0.9

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.
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "CommitGeneratorService", {
9
9
  }
10
10
  });
11
11
  const _common = require("@nestjs/common");
12
+ const _fs = require("fs");
12
13
  const _child_process = require("child_process");
13
14
  const _messages = require("@langchain/core/messages");
14
15
  const _multillmservice = require("../../../common/services/multi-llm.service");
@@ -22,19 +23,82 @@ function _ts_decorate(decorators, target, key, desc) {
22
23
  function _ts_metadata(k, v) {
23
24
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
24
25
  }
26
+ const COMMIT_TYPES = [
27
+ 'feat',
28
+ 'fix',
29
+ 'docs',
30
+ 'style',
31
+ 'refactor',
32
+ 'perf',
33
+ 'test',
34
+ 'build',
35
+ 'ci',
36
+ 'chore'
37
+ ];
38
+ const COMMIT_TYPE_SET = new Set(COMMIT_TYPES);
39
+ const COMMIT_TYPE_ALIASES = {
40
+ feature: 'feat',
41
+ features: 'feat',
42
+ bug: 'fix',
43
+ bugfix: 'fix',
44
+ documentation: 'docs',
45
+ docs: 'docs',
46
+ test: 'test',
47
+ tests: 'test',
48
+ testing: 'test',
49
+ performance: 'perf',
50
+ optimize: 'perf',
51
+ optimization: 'perf',
52
+ dependency: 'build',
53
+ dependencies: 'build',
54
+ maintenance: 'chore',
55
+ housekeeping: 'chore',
56
+ cleanup: 'chore',
57
+ remove: 'refactor'
58
+ };
59
+ const LEADING_VERB_TRANSLATIONS = {
60
+ add: 'adiciona',
61
+ adds: 'adiciona',
62
+ update: 'atualiza',
63
+ updates: 'atualiza',
64
+ upgrade: 'atualiza',
65
+ upgrades: 'atualiza',
66
+ fix: 'corrige',
67
+ fixes: 'corrige',
68
+ remove: 'remove',
69
+ removes: 'remove',
70
+ refactor: 'refatora',
71
+ refactors: 'refatora',
72
+ improve: 'melhora',
73
+ improves: 'melhora',
74
+ create: 'cria',
75
+ creates: 'cria',
76
+ implement: 'implementa',
77
+ implements: 'implementa',
78
+ rename: 'renomeia',
79
+ renames: 'renomeia'
80
+ };
25
81
  let CommitGeneratorService = class CommitGeneratorService {
26
82
  getDiffInfo() {
27
83
  try {
28
84
  const cwd = process.cwd();
29
- const staged = (0, _child_process.execSync)('git diff --cached', {
85
+ const staged = (0, _child_process.execSync)('git diff --cached --unified=1 --no-ext-diff', {
86
+ cwd,
87
+ encoding: 'utf-8'
88
+ });
89
+ const unstaged = (0, _child_process.execSync)('git diff --unified=1 --no-ext-diff', {
30
90
  cwd,
31
91
  encoding: 'utf-8'
32
92
  });
33
- const unstaged = (0, _child_process.execSync)('git diff', {
93
+ const stagedStats = (0, _child_process.execSync)('git diff --cached --stat', {
34
94
  cwd,
35
95
  encoding: 'utf-8'
36
96
  });
37
- const stats = (0, _child_process.execSync)('git diff --stat', {
97
+ const unstagedStats = (0, _child_process.execSync)('git diff --stat', {
98
+ cwd,
99
+ encoding: 'utf-8'
100
+ });
101
+ const statusShort = (0, _child_process.execSync)('git status --short', {
38
102
  cwd,
39
103
  encoding: 'utf-8'
40
104
  });
@@ -49,7 +113,7 @@ let CommitGeneratorService = class CommitGeneratorService {
49
113
  stagedFiles: this.extractFiles(staged),
50
114
  unstagedFiles: this.extractFiles(unstaged),
51
115
  untrackedFiles,
52
- stats
116
+ stats: this.buildStatsSummary(stagedStats, unstagedStats, statusShort, untrackedFiles)
53
117
  };
54
118
  } catch {
55
119
  return null;
@@ -83,7 +147,7 @@ let CommitGeneratorService = class CommitGeneratorService {
83
147
  new _messages.HumanMessage(prompt)
84
148
  ]);
85
149
  const message = this.extractContent(response.content);
86
- return this.cleanCommitMessage(message);
150
+ return this.normalizeCommitMessage(message, 'chore', scope);
87
151
  }
88
152
  async splitCommits() {
89
153
  const diffInfo = this.getDiffInfo();
@@ -103,16 +167,16 @@ let CommitGeneratorService = class CommitGeneratorService {
103
167
  const splitContent = this.extractContent(splitResponse.content);
104
168
  const commitGroups = this.parseCommitGroups(splitContent);
105
169
  if (!commitGroups?.length) return null;
106
- const validGroups = commitGroups.filter((group)=>Array.isArray(group.files) && group.files.length > 0);
107
- if (validGroups.length === 0) return null;
108
- for (const group of validGroups){
170
+ const normalizedGroups = this.normalizeCommitGroups(commitGroups, allFiles);
171
+ if (normalizedGroups.length === 0) return null;
172
+ for (const group of normalizedGroups){
109
173
  if (!group.scope) {
110
174
  group.scope = this.monorepoDetector.determineScope(group.files, monorepoInfo);
111
175
  }
112
176
  }
113
177
  const splitCommits = [];
114
- for (const group of validGroups){
115
- const message = await this.generateMessageForGroup(group, diffInfo);
178
+ for (const group of normalizedGroups){
179
+ const message = await this.generateMessageForGroup(group);
116
180
  splitCommits.push({
117
181
  ...group,
118
182
  message
@@ -179,9 +243,9 @@ let CommitGeneratorService = class CommitGeneratorService {
179
243
  (0, _child_process.execSync)('git reset', {
180
244
  cwd
181
245
  });
182
- for (const file of commit.files){
246
+ for (const file of this.normalizeFiles(commit.files)){
183
247
  try {
184
- (0, _child_process.execSync)(`git add "${file}"`, {
248
+ (0, _child_process.execSync)(`git add -- ${this.escapeShellArg(file)}`, {
185
249
  cwd
186
250
  });
187
251
  } catch {}
@@ -213,13 +277,25 @@ let CommitGeneratorService = class CommitGeneratorService {
213
277
  }
214
278
  async refineCommitMessage(currentMessage, userSuggestion, diffInfo) {
215
279
  const llm = this.multiLlmService.createModel('cheap');
216
- const prompt = `Current commit message: ${currentMessage}\n\nUser suggestion: ${userSuggestion}\n\nDiff:\n${diffInfo.staged.slice(0, 3000)}`;
280
+ const context = this.buildDiffContext(diffInfo, {
281
+ maxLength: 6000,
282
+ maxCharsPerFile: 1200,
283
+ maxUntrackedFiles: 3,
284
+ maxUntrackedLines: 40
285
+ });
286
+ const currentMetadata = this.extractTypeAndScope(currentMessage);
287
+ const prompt = `Mensagem atual: ${currentMessage}
288
+
289
+ Sugestão do usuário: ${userSuggestion}
290
+
291
+ Contexto do diff:
292
+ ${context}`;
217
293
  const response = await llm.invoke([
218
294
  new _messages.SystemMessage(this.getRefineSystemPrompt()),
219
295
  new _messages.HumanMessage(prompt)
220
296
  ]);
221
297
  const message = this.extractContent(response.content);
222
- return this.cleanCommitMessage(message);
298
+ return this.normalizeCommitMessage(message, currentMetadata.type ?? 'chore', currentMetadata.scope, 'atualiza código', currentMetadata.breaking ?? false);
223
299
  }
224
300
  extractFiles(diff) {
225
301
  const files = new Set();
@@ -244,61 +320,76 @@ let CommitGeneratorService = class CommitGeneratorService {
244
320
  }
245
321
  return String(content);
246
322
  }
247
- cleanCommitMessage(message) {
248
- const lines = message.trim().split('\n').map((l)=>l.trim()).filter((l)=>l.length > 0);
249
- const firstCommitLine = lines.find((l)=>l.includes(':')) || lines[0] || '';
250
- return firstCommitLine.replace(/^["']|["']$/g, '').trim();
251
- }
252
323
  buildCommitPrompt(diffInfo, scope) {
253
- const scopeHint = scope ? `\n\nThis is a monorepo. The changes are primarily in the "${scope}" module.` : '';
254
- let fullDiff = '';
255
- if (diffInfo.staged) {
256
- fullDiff += `=== Staged changes ===\n${diffInfo.staged}\n\n`;
257
- }
258
- if (diffInfo.unstaged) {
259
- fullDiff += `=== Unstaged changes ===\n${diffInfo.unstaged}\n\n`;
260
- }
261
- const untrackedHint = diffInfo.untrackedFiles.length > 0 ? `\nNew untracked files (will also be committed): ${diffInfo.untrackedFiles.join(', ')}\n` : '';
262
- const maxLength = 10000;
263
- if (fullDiff.length > maxLength) {
264
- fullDiff = fullDiff.slice(0, maxLength) + '\n\n... (truncated)';
265
- }
266
- return `Generate a single conventional commit message for ALL of the following changes.${scopeHint}\n\nFiles changed:\n${diffInfo.stats}${untrackedHint}\n\n${fullDiff}`;
324
+ const scopeHint = scope ? `Escopo provável do monorepo: "${scope}".` : 'Escopo do monorepo não identificado automaticamente.';
325
+ const fullDiff = this.buildDiffContext(diffInfo, {
326
+ maxLength: 12000,
327
+ maxCharsPerFile: 1800,
328
+ maxUntrackedFiles: 4,
329
+ maxUntrackedLines: 60
330
+ });
331
+ return `Analise TODO o contexto de mudanças e gere UMA mensagem de commit no padrão Conventional Commits.
332
+
333
+ ${scopeHint}
334
+
335
+ Regras obrigatórias:
336
+ - Formato: "type(scope): descrição", "type: descrição" ou com breaking "type(scope)!: descrição"
337
+ - Tipos permitidos: ${COMMIT_TYPES.join(', ')}
338
+ - Descrição em português (pt-BR), objetiva, no imperativo e sem ponto final
339
+ - Máximo de 72 caracteres no assunto completo
340
+ - A mensagem deve refletir a intenção principal do conjunto total de mudanças
341
+ - Se for breaking change, inclua "!" após o type/scope
342
+ - Considere staged, unstaged e arquivos novos
343
+
344
+ Contexto do diff:
345
+ ${fullDiff}`;
267
346
  }
268
347
  buildSplitPrompt(diffInfo, files) {
269
- let fullDiff = '';
270
- if (diffInfo.staged) {
271
- fullDiff += `=== Staged changes ===\n${diffInfo.staged}\n\n`;
272
- }
273
- if (diffInfo.unstaged) {
274
- fullDiff += `=== Unstaged changes ===\n${diffInfo.unstaged}\n\n`;
275
- }
276
- const allFiles = [
348
+ const allFiles = this.normalizeFiles([
277
349
  ...files,
278
- ...diffInfo.untrackedFiles.filter((f)=>!files.includes(f))
279
- ];
280
- const untrackedHint = diffInfo.untrackedFiles.length > 0 ? `\nNew untracked files (must be included in commits): ${diffInfo.untrackedFiles.join(', ')}\n` : '';
281
- const maxLength = 8000;
282
- if (fullDiff.length > maxLength) {
283
- fullDiff = fullDiff.slice(0, maxLength) + '\n\n... (truncated)';
284
- }
285
- return `Analyze all the files below and group them into logical commits. Include ALL files in the result.\n\nFiles: ${allFiles.join(', ')}${untrackedHint}\n\nStats:\n${diffInfo.stats}\n\n${fullDiff}`;
350
+ ...diffInfo.untrackedFiles
351
+ ]);
352
+ const fullDiff = this.buildDiffContext(diffInfo, {
353
+ maxLength: 15000,
354
+ maxCharsPerFile: 1600,
355
+ maxUntrackedFiles: 6,
356
+ maxUntrackedLines: 80
357
+ });
358
+ return `Analise o diff completo e divida em commits lógicos no padrão Conventional Commits.
359
+
360
+ Regras obrigatórias:
361
+ - Cada arquivo da lista deve aparecer exatamente uma vez no resultado
362
+ - Inclua TODOS os arquivos listados
363
+ - Separe mudanças por coesão funcional (feature, fix, docs, refactor etc.)
364
+ - Evite misturar objetivos diferentes no mesmo commit
365
+ - Tipos permitidos: ${COMMIT_TYPES.join(', ')}
366
+ - Descrição em português (pt-BR), no imperativo e sem ponto final
367
+
368
+ Arquivos esperados:
369
+ ${allFiles.join(', ') || '(nenhum arquivo detectado)'}
370
+
371
+ Contexto do diff:
372
+ ${fullDiff}`;
286
373
  }
287
- async generateMessageForGroup(group, diffInfo) {
374
+ async generateMessageForGroup(group) {
288
375
  const llm = this.multiLlmService.createModel('cheap');
289
376
  const scopePart = group.scope ? `(${group.scope})` : '';
290
- const prompt = `Generate a conventional commit message (max 72 chars) for:\n\nType: ${group.type}${scopePart}\nFiles: ${group.files.join(', ')}\nDescription: ${group.description}\n\nIMPORTANT: Return ONLY the commit message in format: "type(scope): description" or "type: description"\nThe message MUST be in English.`;
377
+ const prompt = `Gere uma mensagem Conventional Commit (máximo 72 caracteres) para este grupo:
378
+
379
+ Tipo: ${group.type}${scopePart}
380
+ Arquivos: ${group.files.join(', ')}
381
+ Resumo: ${group.description}
382
+
383
+ Retorne APENAS uma linha no formato:
384
+ "type(scope): descrição", "type: descrição" ou "type(scope)!: descrição"
385
+
386
+ Descrição obrigatoriamente em português (pt-BR).`;
291
387
  const response = await llm.invoke([
292
388
  new _messages.SystemMessage(this.getCommitSystemPrompt()),
293
389
  new _messages.HumanMessage(prompt)
294
390
  ]);
295
- let message = this.extractContent(response.content);
296
- message = this.cleanCommitMessage(message);
297
- if (!message.includes(':')) {
298
- const scope = group.scope ? `(${group.scope})` : '';
299
- message = `${group.type}${scope}: ${message}`;
300
- }
301
- return message;
391
+ const message = this.extractContent(response.content);
392
+ return this.normalizeCommitMessage(message, group.type, group.scope, group.description);
302
393
  }
303
394
  parseCommitGroups(content) {
304
395
  const jsonMatch = content.match(/```json\s*([\s\S]*?)\s*```/);
@@ -319,88 +410,315 @@ let CommitGeneratorService = class CommitGeneratorService {
319
410
  return null;
320
411
  }
321
412
  getCommitSystemPrompt() {
322
- return `You are a Git commit message expert. Generate concise commit messages following Conventional Commits.
323
-
324
- **Available types:**
325
- - feat: new feature
326
- - fix: bug fix
327
- - docs: documentation
328
- - style: formatting (no logic change)
329
- - refactor: refactoring (no functionality change)
330
- - perf: performance improvement
331
- - test: tests
332
- - build: build/dependencies
333
- - ci: continuous integration
334
- - chore: general tasks
335
- - cleanup: code cleanup
336
- - remove: code removal
413
+ return `Você é especialista em mensagens de commit no padrão Conventional Commits.
337
414
 
338
- **Format:**
339
- - With scope: <type>(<scope>): <description>
340
- - Without scope: <type>: <description>
415
+ Tipos permitidos:
416
+ ${COMMIT_TYPES.join(', ')}
341
417
 
342
- **Rules:**
343
- - Maximum 72 characters for the subject line
344
- - Description in English
345
- - No period at the end
346
- - Use imperative mood ("add" not "added")
347
- - Be specific but concise
418
+ Formato obrigatório:
419
+ - Com escopo: <type>(<scope>): <descrição>
420
+ - Sem escopo: <type>: <descrição>
421
+ - Breaking change no assunto: <type>(<scope>)!: <descrição> (ou <type>!: <descrição>)
348
422
 
349
- If this is a monorepo and you can identify the module, include the scope.
423
+ Regras:
424
+ - Assunto completo com no máximo 72 caracteres
425
+ - Descrição em português (pt-BR)
426
+ - Verbo no imperativo
427
+ - Sem ponto final
428
+ - Seja específico e evite mensagens genéricas
429
+ - Use escopo quando ele estiver claro
430
+ - Tipos feat e fix devem ser usados de forma semântica (feature e correção)
350
431
 
351
- Return ONLY the commit message, nothing else.`;
432
+ Retorne SOMENTE a linha do commit, sem explicações.`;
352
433
  }
353
434
  getSplitSystemPrompt() {
354
- return `You are a Git commit organization expert. Analyze the changes and divide them into logical commits.
435
+ return `Você é especialista em organizar diffs em commits lógicos.
355
436
 
356
- **YOUR TASK:**
357
- Group changes into logical commits based on:
358
- 1. **Functional cohesion**: Changes that make sense together
359
- 2. **Change type**: features, fixes, docs, refactorings separated
360
- 3. **Related files**: Files that work together
437
+ Tarefa:
438
+ - Agrupar mudanças por coesão funcional
439
+ - Separar corretamente feature, fix, docs, refactor etc.
440
+ - Garantir que todos os arquivos apareçam exatamente uma vez
361
441
 
362
- **RETURN FORMAT (JSON):**
363
- Return ONLY valid JSON in this format:
442
+ Formato de resposta:
443
+ Retorne SOMENTE JSON válido:
364
444
  \`\`\`json
365
445
  {
366
446
  "commits": [
367
447
  {
368
448
  "type": "feat",
369
- "files": ["src/auth.ts", "src/models/user.ts"],
370
- "description": "add user authentication"
449
+ "files": ["src/chatbot/service.ts"],
450
+ "description": "adiciona service de chatbot"
371
451
  },
372
452
  {
373
453
  "type": "docs",
374
454
  "files": ["README.md"],
375
- "description": "update documentation"
455
+ "description": "atualiza documentação de uso"
376
456
  }
377
457
  ]
378
458
  }
379
459
  \`\`\`
380
460
 
381
- **AVAILABLE TYPES:**
382
- feat, fix, docs, style, refactor, perf, test, build, ci, chore
461
+ Regras:
462
+ - Tipos permitidos: ${COMMIT_TYPES.join(', ')}
463
+ - Cada commit com propósito claro
464
+ - Descrição em português (pt-BR), no imperativo, sem ponto final
465
+ - Máximo recomendado de 5 arquivos por commit
466
+ - Pode retornar 1 commit apenas se o diff for pequeno e coeso
383
467
 
384
- **RULES:**
385
- - Each commit should have a clear purpose
386
- - Group functionally related files
387
- - Separate features from fixes from documentation
388
- - Maximum 5 files per commit (ideally fewer)
389
- - If diff is small (<3 files), can be 1 commit only
390
- - Description must ALWAYS be in English
391
- - Include ALL files in the result
392
-
393
- **IMPORTANT:** Return ONLY the JSON, no additional text.`;
468
+ Retorne SOMENTE o JSON, sem texto adicional.`;
394
469
  }
395
470
  getRefineSystemPrompt() {
396
- return `You are refining a commit message based on user feedback.
471
+ return `Você está refinando uma mensagem de commit a partir do feedback do usuário.
472
+
473
+ Instruções:
474
+ - Respeite Conventional Commits
475
+ - Mantenha no máximo 72 caracteres
476
+ - Mensagem em português (pt-BR), no imperativo e sem ponto final
477
+ - Incorpore a sugestão do usuário sem perder precisão técnica
397
478
 
398
- **Instructions:**
399
- - Keep the message concise (max 72 characters)
400
- - Follow Conventional Commits format
401
- - Incorporate the user's suggestion
402
- - Return ONLY the new commit message, without explanations
403
- - Message MUST be in English`;
479
+ Retorne SOMENTE a nova linha de commit.`;
480
+ }
481
+ normalizeCommitGroups(commitGroups, files) {
482
+ const expectedFiles = new Set(this.normalizeFiles(files));
483
+ const usedFiles = new Set();
484
+ const normalizedGroups = [];
485
+ for (const group of commitGroups){
486
+ const filesFromGroup = this.normalizeFiles(Array.isArray(group.files) ? group.files : []).filter((file)=>expectedFiles.has(file)).filter((file)=>{
487
+ if (usedFiles.has(file)) {
488
+ return false;
489
+ }
490
+ usedFiles.add(file);
491
+ return true;
492
+ });
493
+ if (filesFromGroup.length === 0) continue;
494
+ normalizedGroups.push({
495
+ type: this.normalizeCommitType(group.type, this.inferTypeFromFiles(filesFromGroup)),
496
+ files: filesFromGroup,
497
+ description: this.normalizeDescription(group.description, 'organiza mudanças relacionadas'),
498
+ scope: this.normalizeScope(group.scope)
499
+ });
500
+ }
501
+ const missingFiles = this.normalizeFiles(files).filter((file)=>!usedFiles.has(file));
502
+ if (missingFiles.length > 0) {
503
+ normalizedGroups.push({
504
+ type: this.inferTypeFromFiles(missingFiles),
505
+ files: missingFiles,
506
+ description: 'organiza arquivos restantes do diff'
507
+ });
508
+ }
509
+ return normalizedGroups;
510
+ }
511
+ normalizeCommitMessage(rawMessage, fallbackType, fallbackScope, fallbackDescription = 'atualiza código', fallbackBreaking = false) {
512
+ const candidateLine = this.extractCandidateCommitLine(rawMessage);
513
+ const match = candidateLine.match(/^([a-zA-Z-]+)(?:\(([^)]+)\))?(!)?:\s*(.+)$/);
514
+ const type = this.normalizeCommitType(match?.[1], fallbackType);
515
+ const scope = this.normalizeScope(match?.[2] ?? fallbackScope);
516
+ const breaking = Boolean(match?.[3]) || fallbackBreaking;
517
+ const rawDescription = match?.[4] ?? candidateLine;
518
+ const description = this.normalizeDescription(rawDescription, fallbackDescription);
519
+ const breakingFlag = breaking ? '!' : '';
520
+ const prefix = scope ? `${type}(${scope})${breakingFlag}: ` : `${type}${breakingFlag}: `;
521
+ const maxDescriptionLength = Math.max(12, 72 - prefix.length);
522
+ const truncatedDescription = this.truncateText(description, maxDescriptionLength);
523
+ return `${prefix}${truncatedDescription}`;
524
+ }
525
+ extractTypeAndScope(message) {
526
+ const candidateLine = this.extractCandidateCommitLine(message);
527
+ const match = candidateLine.match(/^([a-zA-Z-]+)(?:\(([^)]+)\))?(!)?:\s*.+$/);
528
+ if (!match) return {};
529
+ return {
530
+ type: this.normalizeCommitType(match[1], 'chore'),
531
+ scope: this.normalizeScope(match[2]),
532
+ breaking: Boolean(match[3])
533
+ };
534
+ }
535
+ extractCandidateCommitLine(rawMessage) {
536
+ const withoutCodeBlock = rawMessage.replace(/```(?:[\w-]+)?/g, '');
537
+ const lines = withoutCodeBlock.split('\n').map((line)=>line.trim()).filter((line)=>line.length > 0).map((line)=>line.replace(/^[-*]\s+/, ''));
538
+ if (lines.length === 0) return '';
539
+ const conventionalLine = lines.find((line)=>/^[a-zA-Z-]+(?:\([^)]+\))?!?:\s+/.test(line));
540
+ if (conventionalLine) {
541
+ return conventionalLine.replace(/^["'`]|["'`]$/g, '').trim();
542
+ }
543
+ const prefixedLine = lines.find((line)=>/^commit\s*:/i.test(line));
544
+ if (prefixedLine) {
545
+ return prefixedLine.replace(/^commit\s*:/i, '').replace(/^["'`]|["'`]$/g, '').trim();
546
+ }
547
+ return lines[0].replace(/^["'`]|["'`]$/g, '').trim();
548
+ }
549
+ normalizeCommitType(type, fallbackType) {
550
+ const normalized = (type || '').toLowerCase().trim().replace(/[^a-z]/g, '');
551
+ if (!normalized) return fallbackType;
552
+ if (COMMIT_TYPE_SET.has(normalized)) return normalized;
553
+ if (COMMIT_TYPE_ALIASES[normalized]) return COMMIT_TYPE_ALIASES[normalized];
554
+ return fallbackType;
555
+ }
556
+ normalizeScope(scope) {
557
+ if (!scope) return undefined;
558
+ const normalized = scope.trim().replace(/^["'`]|["'`]$/g, '').toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9/_-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
559
+ return normalized || undefined;
560
+ }
561
+ normalizeDescription(description, fallback) {
562
+ let normalized = description.replace(/^["'`]|["'`]$/g, '').replace(/^([a-zA-Z-]+)(?:\([^)]+\))?!?:\s*/, '').replace(/\s+/g, ' ').trim();
563
+ normalized = normalized.replace(/[.;:!?]+$/, '').trim();
564
+ if (!normalized) normalized = fallback;
565
+ normalized = this.translateLeadingVerb(normalized);
566
+ if (/^[A-ZÀ-Ý]/.test(normalized)) {
567
+ normalized = normalized.charAt(0).toLowerCase() + normalized.slice(1);
568
+ }
569
+ return normalized;
570
+ }
571
+ translateLeadingVerb(description) {
572
+ const match = description.match(/^([a-zA-Z]+)(\b.*)$/);
573
+ if (!match) return description;
574
+ const translated = LEADING_VERB_TRANSLATIONS[match[1].toLowerCase()];
575
+ if (!translated) return description;
576
+ return `${translated}${match[2]}`;
577
+ }
578
+ truncateText(text, maxLength) {
579
+ if (text.length <= maxLength) return text;
580
+ const truncated = text.slice(0, maxLength).trimEnd();
581
+ const lastSpace = truncated.lastIndexOf(' ');
582
+ if (lastSpace > maxLength * 0.6) {
583
+ return truncated.slice(0, lastSpace).trimEnd();
584
+ }
585
+ return truncated;
586
+ }
587
+ normalizeFiles(files) {
588
+ const unique = new Set();
589
+ for (const file of files){
590
+ if (typeof file !== 'string') continue;
591
+ const normalized = file.trim().replace(/^["']|["']$/g, '');
592
+ if (!normalized) continue;
593
+ unique.add(normalized);
594
+ }
595
+ return Array.from(unique);
596
+ }
597
+ buildStatsSummary(stagedStats, unstagedStats, statusShort, untrackedFiles) {
598
+ const sections = [];
599
+ if (statusShort.trim()) {
600
+ sections.push(`Git status (--short):\n${statusShort.trim()}`);
601
+ }
602
+ if (stagedStats.trim()) {
603
+ sections.push(`Diff staged (--cached --stat):\n${stagedStats.trim()}`);
604
+ }
605
+ if (unstagedStats.trim()) {
606
+ sections.push(`Diff unstaged (--stat):\n${unstagedStats.trim()}`);
607
+ }
608
+ if (untrackedFiles.length > 0) {
609
+ sections.push(`Arquivos novos (${untrackedFiles.length}): ${untrackedFiles.join(', ')}`);
610
+ }
611
+ return sections.join('\n\n');
612
+ }
613
+ buildDiffContext(diffInfo, options) {
614
+ const sections = [];
615
+ if (diffInfo.stats.trim()) {
616
+ sections.push(`Resumo:\n${diffInfo.stats.trim()}`);
617
+ }
618
+ sections.push(this.buildFilesSummary(diffInfo));
619
+ const stagedByFile = this.limitDiffByFile(diffInfo.staged, options.maxCharsPerFile);
620
+ if (stagedByFile) {
621
+ sections.push(`=== STAGED ===\n${stagedByFile}`);
622
+ }
623
+ const unstagedByFile = this.limitDiffByFile(diffInfo.unstaged, options.maxCharsPerFile);
624
+ if (unstagedByFile) {
625
+ sections.push(`=== UNSTAGED ===\n${unstagedByFile}`);
626
+ }
627
+ const untrackedPreview = this.buildUntrackedPreview(diffInfo.untrackedFiles, options.maxUntrackedFiles, options.maxUntrackedLines);
628
+ if (untrackedPreview) {
629
+ sections.push(`=== PREVIEW ARQUIVOS NOVOS ===\n${untrackedPreview}`);
630
+ }
631
+ let combined = sections.filter(Boolean).join('\n\n');
632
+ if (combined.length > options.maxLength) {
633
+ combined = `${combined.slice(0, options.maxLength).trimEnd()}\n\n... (contexto truncado)`;
634
+ }
635
+ return combined;
636
+ }
637
+ buildFilesSummary(diffInfo) {
638
+ const lines = [];
639
+ const stagedFiles = this.normalizeFiles(diffInfo.stagedFiles);
640
+ const unstagedFiles = this.normalizeFiles(diffInfo.unstagedFiles);
641
+ const untrackedFiles = this.normalizeFiles(diffInfo.untrackedFiles);
642
+ if (stagedFiles.length > 0) {
643
+ lines.push(`Staged (${stagedFiles.length}): ${this.summarizeFileList(stagedFiles)}`);
644
+ }
645
+ if (unstagedFiles.length > 0) {
646
+ lines.push(`Unstaged (${unstagedFiles.length}): ${this.summarizeFileList(unstagedFiles)}`);
647
+ }
648
+ if (untrackedFiles.length > 0) {
649
+ lines.push(`Novos (${untrackedFiles.length}): ${this.summarizeFileList(untrackedFiles)}`);
650
+ }
651
+ if (lines.length === 0) {
652
+ return 'Arquivos afetados: nenhum arquivo identificado';
653
+ }
654
+ return `Arquivos afetados:\n${lines.join('\n')}`;
655
+ }
656
+ summarizeFileList(files, limit = 20) {
657
+ if (files.length <= limit) {
658
+ return files.join(', ');
659
+ }
660
+ const remaining = files.length - limit;
661
+ return `${files.slice(0, limit).join(', ')}, ... (+${remaining})`;
662
+ }
663
+ limitDiffByFile(diff, maxCharsPerFile) {
664
+ if (!diff.trim()) return '';
665
+ const sections = this.splitDiffByFile(diff);
666
+ if (sections.length === 0) return '';
667
+ const limitedSections = sections.map((section)=>{
668
+ if (section.length <= maxCharsPerFile) return section.trimEnd();
669
+ return `${section.slice(0, maxCharsPerFile).trimEnd()}\n... (diff deste arquivo truncado)`;
670
+ });
671
+ return limitedSections.join('\n\n');
672
+ }
673
+ splitDiffByFile(diff) {
674
+ const rawSections = diff.split(/^diff --git /m).map((section)=>section.trim()).filter((section)=>section.length > 0);
675
+ return rawSections.map((section)=>`diff --git ${section}`);
676
+ }
677
+ buildUntrackedPreview(files, maxFiles, maxLines) {
678
+ const selectedFiles = this.normalizeFiles(files).slice(0, maxFiles);
679
+ const sections = [];
680
+ for (const file of selectedFiles){
681
+ const preview = this.readTextFilePreview(file, maxLines);
682
+ if (!preview) continue;
683
+ sections.push(`--- ${file} ---\n${preview}`);
684
+ }
685
+ if (files.length > maxFiles) {
686
+ sections.push(`... ${files.length - maxFiles} arquivo(s) novo(s) omitido(s)`);
687
+ }
688
+ return sections.join('\n\n');
689
+ }
690
+ readTextFilePreview(file, maxLines) {
691
+ try {
692
+ const content = (0, _fs.readFileSync)(file, 'utf-8');
693
+ if (content.includes('\u0000')) {
694
+ return '[arquivo binário omitido]';
695
+ }
696
+ if (!content.length) {
697
+ return '[arquivo vazio]';
698
+ }
699
+ const lines = content.split('\n');
700
+ const preview = lines.slice(0, maxLines).join('\n');
701
+ const clippedPreview = preview.length > 2500 ? `${preview.slice(0, 2500)}\n...` : preview;
702
+ if (lines.length > maxLines && !clippedPreview.endsWith('\n...')) {
703
+ return `${clippedPreview}\n...`;
704
+ }
705
+ return clippedPreview;
706
+ } catch {
707
+ return '';
708
+ }
709
+ }
710
+ inferTypeFromFiles(files) {
711
+ if (files.length === 0) return 'chore';
712
+ const onlyDocs = files.every((file)=>/^docs\//i.test(file) || /(^|\/)README\.md$/i.test(file) || /(^|\/)CHANGELOG\.md$/i.test(file) || /\.(md|mdx|txt)$/i.test(file));
713
+ if (onlyDocs) return 'docs';
714
+ const onlyTests = files.every((file)=>/(^|\/)__tests__\//.test(file) || /\.(spec|test)\.[cm]?[jt]sx?$/.test(file));
715
+ if (onlyTests) return 'test';
716
+ const onlyInfra = files.every((file)=>/(^|\/)package(-lock)?\.json$/.test(file) || /(^|\/)(pnpm-lock\.yaml|yarn\.lock)$/i.test(file) || /(^|\/)Dockerfile/i.test(file) || /(^|\/)docker-compose\.ya?ml$/i.test(file) || /(^|\/)\.github\/workflows\//.test(file));
717
+ if (onlyInfra) return 'build';
718
+ return 'chore';
719
+ }
720
+ escapeShellArg(value) {
721
+ return `'${value.replace(/'/g, '\'\\\'\'')}'`;
404
722
  }
405
723
  constructor(multiLlmService, monorepoDetector){
406
724
  this.multiLlmService = multiLlmService;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/git/services/commit-generator.service.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { execSync } from 'child_process';\nimport { HumanMessage, SystemMessage } from '@langchain/core/messages';\nimport { MultiLlmService } from '../../../common/services/multi-llm.service';\nimport { MonorepoDetectorService } from './monorepo-detector.service';\nimport { GitDiffInfo, SplitCommit, CommitGroup, MonorepoInfo } from '../types/git.types';\n\n@Injectable()\nexport class CommitGeneratorService {\n constructor(\n private readonly multiLlmService: MultiLlmService,\n private readonly monorepoDetector: MonorepoDetectorService,\n ) {}\n\n getDiffInfo(): GitDiffInfo | null {\n try {\n const cwd = process.cwd();\n const staged = execSync('git diff --cached', { cwd, encoding: 'utf-8' });\n const unstaged = execSync('git diff', { cwd, encoding: 'utf-8' });\n const stats = execSync('git diff --stat', { cwd, encoding: 'utf-8' });\n const untrackedRaw = execSync('git ls-files --others --exclude-standard', { cwd, encoding: 'utf-8' });\n const untrackedFiles = untrackedRaw.trim() ? untrackedRaw.trim().split('\\n').filter(f => f.trim()) : [];\n\n return {\n staged,\n unstaged,\n stagedFiles: this.extractFiles(staged),\n unstagedFiles: this.extractFiles(unstaged),\n untrackedFiles,\n stats,\n };\n } catch {\n return null;\n }\n }\n\n hasChanges(): boolean {\n try {\n const output = execSync('git status --porcelain', { cwd: process.cwd(), encoding: 'utf-8' });\n return output.trim().length > 0;\n } catch {\n return false;\n }\n }\n\n async generateCommitMessage(): Promise<string | null> {\n const diffInfo = this.getDiffInfo();\n if (!diffInfo) return null;\n\n const monorepoInfo = this.monorepoDetector.detectMonorepo(process.cwd());\n const allFiles = [...diffInfo.stagedFiles, ...diffInfo.unstagedFiles, ...diffInfo.untrackedFiles];\n const scope = this.monorepoDetector.determineScope(allFiles, monorepoInfo);\n\n const llm = this.multiLlmService.createModel('cheap');\n const prompt = this.buildCommitPrompt(diffInfo, scope);\n\n const response = await llm.invoke([\n new SystemMessage(this.getCommitSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const message = this.extractContent(response.content);\n return this.cleanCommitMessage(message);\n }\n\n async splitCommits(): Promise<SplitCommit[] | null> {\n const diffInfo = this.getDiffInfo();\n if (!diffInfo) return null;\n\n const monorepoInfo = this.monorepoDetector.detectMonorepo(process.cwd());\n const allFiles = [...diffInfo.stagedFiles, ...diffInfo.unstagedFiles, ...diffInfo.untrackedFiles];\n\n const llm = this.multiLlmService.createModel('cheap');\n const splitPrompt = this.buildSplitPrompt(diffInfo, allFiles);\n\n const splitResponse = await llm.invoke([\n new SystemMessage(this.getSplitSystemPrompt()),\n new HumanMessage(splitPrompt),\n ]);\n\n const splitContent = this.extractContent(splitResponse.content);\n const commitGroups = this.parseCommitGroups(splitContent);\n\n if (!commitGroups?.length) return null;\n\n const validGroups = commitGroups.filter((group) => Array.isArray(group.files) && group.files.length > 0);\n if (validGroups.length === 0) return null;\n\n for (const group of validGroups) {\n if (!group.scope) {\n group.scope = this.monorepoDetector.determineScope(group.files, monorepoInfo);\n }\n }\n\n const splitCommits: SplitCommit[] = [];\n for (const group of validGroups) {\n const message = await this.generateMessageForGroup(group, diffInfo);\n splitCommits.push({ ...group, message });\n }\n\n return splitCommits;\n }\n\n executeCommit(message: string, autoStage = true): boolean {\n try {\n const cwd = process.cwd();\n if (autoStage) {\n execSync('git add -A', { cwd });\n }\n execSync('git commit -F -', { cwd, input: `${message}\\n`, encoding: 'utf-8' });\n return true;\n } catch {\n return false;\n }\n }\n\n executePush(): { success: boolean; error?: string } {\n try {\n const cwd = process.cwd();\n const branch = execSync('git branch --show-current', { cwd, encoding: 'utf-8' }).trim();\n execSync(`git push origin ${branch}`, { cwd, encoding: 'utf-8' });\n return { success: true };\n } catch (error: any) {\n const message = error.message || 'Push failed';\n if (message.includes('rejected') || message.includes('diverged')) {\n return { success: false, error: 'Push rejected. Run \"git pull --rebase\" first.' };\n }\n return { success: false, error: message };\n }\n }\n\n executeSplitCommits(commits: SplitCommit[]): { success: boolean; committed: number; error?: string; originalHead?: string } {\n const cwd = process.cwd();\n let committedCount = 0;\n let originalHead: string | undefined;\n\n try {\n originalHead = execSync('git rev-parse HEAD', { cwd, encoding: 'utf-8' }).trim();\n\n for (const commit of commits) {\n execSync('git reset', { cwd });\n\n for (const file of commit.files) {\n try {\n execSync(`git add \"${file}\"`, { cwd });\n } catch {}\n }\n\n const staged = execSync('git diff --cached --name-only', { cwd, encoding: 'utf-8' });\n if (!staged.trim()) continue;\n\n execSync('git commit -F -', { cwd, input: `${commit.message}\\n`, encoding: 'utf-8' });\n committedCount++;\n }\n\n return { success: true, committed: committedCount };\n } catch (error: any) {\n return {\n success: false,\n committed: committedCount,\n error: error.message || 'Failed to execute commits',\n originalHead\n };\n }\n }\n\n async refineCommitMessage(\n currentMessage: string,\n userSuggestion: string,\n diffInfo: GitDiffInfo,\n ): Promise<string> {\n const llm = this.multiLlmService.createModel('cheap');\n\n const prompt = `Current commit message: ${currentMessage}\\n\\nUser suggestion: ${userSuggestion}\\n\\nDiff:\\n${diffInfo.staged.slice(0, 3000)}`;\n\n const response = await llm.invoke([\n new SystemMessage(this.getRefineSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const message = this.extractContent(response.content);\n return this.cleanCommitMessage(message);\n }\n\n private extractFiles(diff: string): string[] {\n const files = new Set<string>();\n const lines = diff.split('\\n');\n\n for (const line of lines) {\n if (line.startsWith('diff --git')) {\n const match = line.match(/diff --git a\\/(.+?) b\\/(.+?)$/);\n if (match) {\n files.add(match[2]);\n }\n }\n }\n\n return Array.from(files);\n }\n\n private extractContent(content: unknown): string {\n if (typeof content === 'string') return content;\n if (Array.isArray(content) && content.length > 0) {\n const first = content[0];\n if (typeof first === 'object' && first !== null && 'text' in first) {\n return String(first.text);\n }\n }\n return String(content);\n }\n\n private cleanCommitMessage(message: string): string {\n const lines = message.trim().split('\\n').map(l => l.trim()).filter(l => l.length > 0);\n const firstCommitLine = lines.find(l => l.includes(':')) || lines[0] || '';\n return firstCommitLine.replace(/^[\"']|[\"']$/g, '').trim();\n }\n\n private buildCommitPrompt(diffInfo: GitDiffInfo, scope?: string): string {\n const scopeHint = scope ? `\\n\\nThis is a monorepo. The changes are primarily in the \"${scope}\" module.` : '';\n\n let fullDiff = '';\n if (diffInfo.staged) {\n fullDiff += `=== Staged changes ===\\n${diffInfo.staged}\\n\\n`;\n }\n if (diffInfo.unstaged) {\n fullDiff += `=== Unstaged changes ===\\n${diffInfo.unstaged}\\n\\n`;\n }\n\n const untrackedHint = diffInfo.untrackedFiles.length > 0\n ? `\\nNew untracked files (will also be committed): ${diffInfo.untrackedFiles.join(', ')}\\n`\n : '';\n\n const maxLength = 10000;\n if (fullDiff.length > maxLength) {\n fullDiff = fullDiff.slice(0, maxLength) + '\\n\\n... (truncated)';\n }\n\n return `Generate a single conventional commit message for ALL of the following changes.${scopeHint}\\n\\nFiles changed:\\n${diffInfo.stats}${untrackedHint}\\n\\n${fullDiff}`;\n }\n\n private buildSplitPrompt(diffInfo: GitDiffInfo, files: string[]): string {\n let fullDiff = '';\n if (diffInfo.staged) {\n fullDiff += `=== Staged changes ===\\n${diffInfo.staged}\\n\\n`;\n }\n if (diffInfo.unstaged) {\n fullDiff += `=== Unstaged changes ===\\n${diffInfo.unstaged}\\n\\n`;\n }\n\n const allFiles = [...files, ...diffInfo.untrackedFiles.filter(f => !files.includes(f))];\n const untrackedHint = diffInfo.untrackedFiles.length > 0\n ? `\\nNew untracked files (must be included in commits): ${diffInfo.untrackedFiles.join(', ')}\\n`\n : '';\n\n const maxLength = 8000;\n if (fullDiff.length > maxLength) {\n fullDiff = fullDiff.slice(0, maxLength) + '\\n\\n... (truncated)';\n }\n\n return `Analyze all the files below and group them into logical commits. Include ALL files in the result.\\n\\nFiles: ${allFiles.join(', ')}${untrackedHint}\\n\\nStats:\\n${diffInfo.stats}\\n\\n${fullDiff}`;\n }\n\n private async generateMessageForGroup(group: CommitGroup, diffInfo: GitDiffInfo): Promise<string> {\n const llm = this.multiLlmService.createModel('cheap');\n\n const scopePart = group.scope ? `(${group.scope})` : '';\n\n const prompt = `Generate a conventional commit message (max 72 chars) for:\\n\\nType: ${group.type}${scopePart}\\nFiles: ${group.files.join(', ')}\\nDescription: ${group.description}\\n\\nIMPORTANT: Return ONLY the commit message in format: \"type(scope): description\" or \"type: description\"\\nThe message MUST be in English.`;\n\n const response = await llm.invoke([\n new SystemMessage(this.getCommitSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n let message = this.extractContent(response.content);\n message = this.cleanCommitMessage(message);\n\n if (!message.includes(':')) {\n const scope = group.scope ? `(${group.scope})` : '';\n message = `${group.type}${scope}: ${message}`;\n }\n\n return message;\n }\n\n private parseCommitGroups(content: string): CommitGroup[] | null {\n const jsonMatch = content.match(/```json\\s*([\\s\\S]*?)\\s*```/);\n if (jsonMatch) {\n try {\n const parsed = JSON.parse(jsonMatch[1]);\n if (parsed.commits && Array.isArray(parsed.commits)) {\n return parsed.commits;\n }\n } catch {}\n }\n\n try {\n const parsed = JSON.parse(content);\n if (parsed.commits && Array.isArray(parsed.commits)) {\n return parsed.commits;\n }\n } catch {}\n\n return null;\n }\n\n private getCommitSystemPrompt(): string {\n return `You are a Git commit message expert. Generate concise commit messages following Conventional Commits.\n\n**Available types:**\n- feat: new feature\n- fix: bug fix\n- docs: documentation\n- style: formatting (no logic change)\n- refactor: refactoring (no functionality change)\n- perf: performance improvement\n- test: tests\n- build: build/dependencies\n- ci: continuous integration\n- chore: general tasks\n- cleanup: code cleanup\n- remove: code removal\n\n**Format:**\n- With scope: <type>(<scope>): <description>\n- Without scope: <type>: <description>\n\n**Rules:**\n- Maximum 72 characters for the subject line\n- Description in English\n- No period at the end\n- Use imperative mood (\"add\" not \"added\")\n- Be specific but concise\n\nIf this is a monorepo and you can identify the module, include the scope.\n\nReturn ONLY the commit message, nothing else.`;\n }\n\n private getSplitSystemPrompt(): string {\n return `You are a Git commit organization expert. Analyze the changes and divide them into logical commits.\n\n**YOUR TASK:**\nGroup changes into logical commits based on:\n1. **Functional cohesion**: Changes that make sense together\n2. **Change type**: features, fixes, docs, refactorings separated\n3. **Related files**: Files that work together\n\n**RETURN FORMAT (JSON):**\nReturn ONLY valid JSON in this format:\n\\`\\`\\`json\n{\n \"commits\": [\n {\n \"type\": \"feat\",\n \"files\": [\"src/auth.ts\", \"src/models/user.ts\"],\n \"description\": \"add user authentication\"\n },\n {\n \"type\": \"docs\",\n \"files\": [\"README.md\"],\n \"description\": \"update documentation\"\n }\n ]\n}\n\\`\\`\\`\n\n**AVAILABLE TYPES:**\nfeat, fix, docs, style, refactor, perf, test, build, ci, chore\n\n**RULES:**\n- Each commit should have a clear purpose\n- Group functionally related files\n- Separate features from fixes from documentation\n- Maximum 5 files per commit (ideally fewer)\n- If diff is small (<3 files), can be 1 commit only\n- Description must ALWAYS be in English\n- Include ALL files in the result\n\n**IMPORTANT:** Return ONLY the JSON, no additional text.`;\n }\n\n private getRefineSystemPrompt(): string {\n return `You are refining a commit message based on user feedback.\n\n**Instructions:**\n- Keep the message concise (max 72 characters)\n- Follow Conventional Commits format\n- Incorporate the user's suggestion\n- Return ONLY the new commit message, without explanations\n- Message MUST be in English`;\n }\n}\n"],"names":["CommitGeneratorService","getDiffInfo","cwd","process","staged","execSync","encoding","unstaged","stats","untrackedRaw","untrackedFiles","trim","split","filter","f","stagedFiles","extractFiles","unstagedFiles","hasChanges","output","length","generateCommitMessage","diffInfo","monorepoInfo","monorepoDetector","detectMonorepo","allFiles","scope","determineScope","llm","multiLlmService","createModel","prompt","buildCommitPrompt","response","invoke","SystemMessage","getCommitSystemPrompt","HumanMessage","message","extractContent","content","cleanCommitMessage","splitCommits","splitPrompt","buildSplitPrompt","splitResponse","getSplitSystemPrompt","splitContent","commitGroups","parseCommitGroups","validGroups","group","Array","isArray","files","generateMessageForGroup","push","executeCommit","autoStage","input","executePush","branch","success","error","includes","executeSplitCommits","commits","committedCount","originalHead","commit","file","committed","refineCommitMessage","currentMessage","userSuggestion","slice","getRefineSystemPrompt","diff","Set","lines","line","startsWith","match","add","from","first","String","text","map","l","firstCommitLine","find","replace","scopeHint","fullDiff","untrackedHint","join","maxLength","scopePart","type","description","jsonMatch","parsed","JSON","parse"],"mappings":";;;;+BAQaA;;;eAAAA;;;wBARc;+BACF;0BACmB;iCACZ;yCACQ;;;;;;;;;;AAIjC,IAAA,AAAMA,yBAAN,MAAMA;IAMXC,cAAkC;QAChC,IAAI;YACF,MAAMC,MAAMC,QAAQD,GAAG;YACvB,MAAME,SAASC,IAAAA,uBAAQ,EAAC,qBAAqB;gBAAEH;gBAAKI,UAAU;YAAQ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,IAAI8D,OAAOpC,OAAO,IAAId,MAAMC,OAAO,CAACiD,OAAOpC,OAAO,GAAG;gBACnD,OAAOoC,OAAOpC,OAAO;YACvB;QACF,EAAE,OAAM,CAAC;QAET,OAAO;IACT;IAEQ9B,wBAAgC;QACtC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CA6BiC,CAAC;IAC5C;IAEQU,uBAA+B;QACrC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDAuC4C,CAAC;IACvD;IAEQ8B,wBAAgC;QACtC,OAAO,CAAC;;;;;;;4BAOgB,CAAC;IAC3B;IA9XA,YACE,AAAiB/C,eAAgC,EACjD,AAAiBN,gBAAyC,CAC1D;aAFiBM,kBAAAA;aACAN,mBAAAA;IAChB;AA4XL"}
1
+ {"version":3,"sources":["../../../../src/modules/git/services/commit-generator.service.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { readFileSync } from 'fs';\nimport { execSync } from 'child_process';\nimport { HumanMessage, SystemMessage } from '@langchain/core/messages';\nimport { MultiLlmService } from '../../../common/services/multi-llm.service';\nimport { MonorepoDetectorService } from './monorepo-detector.service';\nimport { GitDiffInfo, SplitCommit, CommitGroup, ConventionalCommitType } from '../types/git.types';\n\nconst COMMIT_TYPES: ConventionalCommitType[] = [\n 'feat',\n 'fix',\n 'docs',\n 'style',\n 'refactor',\n 'perf',\n 'test',\n 'build',\n 'ci',\n 'chore',\n];\n\nconst COMMIT_TYPE_SET = new Set<string>(COMMIT_TYPES);\n\nconst COMMIT_TYPE_ALIASES: Record<string, ConventionalCommitType> = {\n feature: 'feat',\n features: 'feat',\n bug: 'fix',\n bugfix: 'fix',\n documentation: 'docs',\n docs: 'docs',\n test: 'test',\n tests: 'test',\n testing: 'test',\n performance: 'perf',\n optimize: 'perf',\n optimization: 'perf',\n dependency: 'build',\n dependencies: 'build',\n maintenance: 'chore',\n housekeeping: 'chore',\n cleanup: 'chore',\n remove: 'refactor',\n};\n\nconst LEADING_VERB_TRANSLATIONS: Record<string, string> = {\n add: 'adiciona',\n adds: 'adiciona',\n update: 'atualiza',\n updates: 'atualiza',\n upgrade: 'atualiza',\n upgrades: 'atualiza',\n fix: 'corrige',\n fixes: 'corrige',\n remove: 'remove',\n removes: 'remove',\n refactor: 'refatora',\n refactors: 'refatora',\n improve: 'melhora',\n improves: 'melhora',\n create: 'cria',\n creates: 'cria',\n implement: 'implementa',\n implements: 'implementa',\n rename: 'renomeia',\n renames: 'renomeia',\n};\n\n@Injectable()\nexport class CommitGeneratorService {\n constructor(\n private readonly multiLlmService: MultiLlmService,\n private readonly monorepoDetector: MonorepoDetectorService,\n ) {}\n\n getDiffInfo(): GitDiffInfo | null {\n try {\n const cwd = process.cwd();\n const staged = execSync('git diff --cached --unified=1 --no-ext-diff', { cwd, encoding: 'utf-8' });\n const unstaged = execSync('git diff --unified=1 --no-ext-diff', { cwd, encoding: 'utf-8' });\n const stagedStats = execSync('git diff --cached --stat', { cwd, encoding: 'utf-8' });\n const unstagedStats = execSync('git diff --stat', { cwd, encoding: 'utf-8' });\n const statusShort = execSync('git status --short', { cwd, encoding: 'utf-8' });\n const untrackedRaw = execSync('git ls-files --others --exclude-standard', { cwd, encoding: 'utf-8' });\n const untrackedFiles = untrackedRaw.trim() ? untrackedRaw.trim().split('\\n').filter(f => f.trim()) : [];\n\n return {\n staged,\n unstaged,\n stagedFiles: this.extractFiles(staged),\n unstagedFiles: this.extractFiles(unstaged),\n untrackedFiles,\n stats: this.buildStatsSummary(stagedStats, unstagedStats, statusShort, untrackedFiles),\n };\n } catch {\n return null;\n }\n }\n\n hasChanges(): boolean {\n try {\n const output = execSync('git status --porcelain', { cwd: process.cwd(), encoding: 'utf-8' });\n return output.trim().length > 0;\n } catch {\n return false;\n }\n }\n\n async generateCommitMessage(): Promise<string | null> {\n const diffInfo = this.getDiffInfo();\n if (!diffInfo) return null;\n\n const monorepoInfo = this.monorepoDetector.detectMonorepo(process.cwd());\n const allFiles = [...diffInfo.stagedFiles, ...diffInfo.unstagedFiles, ...diffInfo.untrackedFiles];\n const scope = this.monorepoDetector.determineScope(allFiles, monorepoInfo);\n\n const llm = this.multiLlmService.createModel('cheap');\n const prompt = this.buildCommitPrompt(diffInfo, scope);\n\n const response = await llm.invoke([\n new SystemMessage(this.getCommitSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const message = this.extractContent(response.content);\n return this.normalizeCommitMessage(message, 'chore', scope);\n }\n\n async splitCommits(): Promise<SplitCommit[] | null> {\n const diffInfo = this.getDiffInfo();\n if (!diffInfo) return null;\n\n const monorepoInfo = this.monorepoDetector.detectMonorepo(process.cwd());\n const allFiles = [...diffInfo.stagedFiles, ...diffInfo.unstagedFiles, ...diffInfo.untrackedFiles];\n\n const llm = this.multiLlmService.createModel('cheap');\n const splitPrompt = this.buildSplitPrompt(diffInfo, allFiles);\n\n const splitResponse = await llm.invoke([\n new SystemMessage(this.getSplitSystemPrompt()),\n new HumanMessage(splitPrompt),\n ]);\n\n const splitContent = this.extractContent(splitResponse.content);\n const commitGroups = this.parseCommitGroups(splitContent);\n if (!commitGroups?.length) return null;\n\n const normalizedGroups = this.normalizeCommitGroups(commitGroups, allFiles);\n if (normalizedGroups.length === 0) return null;\n\n for (const group of normalizedGroups) {\n if (!group.scope) {\n group.scope = this.monorepoDetector.determineScope(group.files, monorepoInfo);\n }\n }\n\n const splitCommits: SplitCommit[] = [];\n for (const group of normalizedGroups) {\n const message = await this.generateMessageForGroup(group);\n splitCommits.push({ ...group, message });\n }\n\n return splitCommits;\n }\n\n executeCommit(message: string, autoStage = true): boolean {\n try {\n const cwd = process.cwd();\n if (autoStage) {\n execSync('git add -A', { cwd });\n }\n execSync('git commit -F -', { cwd, input: `${message}\\n`, encoding: 'utf-8' });\n return true;\n } catch {\n return false;\n }\n }\n\n executePush(): { success: boolean; error?: string } {\n try {\n const cwd = process.cwd();\n const branch = execSync('git branch --show-current', { cwd, encoding: 'utf-8' }).trim();\n execSync(`git push origin ${branch}`, { cwd, encoding: 'utf-8' });\n return { success: true };\n } catch (error: any) {\n const message = error.message || 'Push failed';\n if (message.includes('rejected') || message.includes('diverged')) {\n return { success: false, error: 'Push rejected. Run \"git pull --rebase\" first.' };\n }\n return { success: false, error: message };\n }\n }\n\n executeSplitCommits(commits: SplitCommit[]): { success: boolean; committed: number; error?: string; originalHead?: string } {\n const cwd = process.cwd();\n let committedCount = 0;\n let originalHead: string | undefined;\n\n try {\n originalHead = execSync('git rev-parse HEAD', { cwd, encoding: 'utf-8' }).trim();\n\n for (const commit of commits) {\n execSync('git reset', { cwd });\n\n for (const file of this.normalizeFiles(commit.files)) {\n try {\n execSync(`git add -- ${this.escapeShellArg(file)}`, { cwd });\n } catch {}\n }\n\n const staged = execSync('git diff --cached --name-only', { cwd, encoding: 'utf-8' });\n if (!staged.trim()) continue;\n\n execSync('git commit -F -', { cwd, input: `${commit.message}\\n`, encoding: 'utf-8' });\n committedCount++;\n }\n\n return { success: true, committed: committedCount };\n } catch (error: any) {\n return {\n success: false,\n committed: committedCount,\n error: error.message || 'Failed to execute commits',\n originalHead\n };\n }\n }\n\n async refineCommitMessage(\n currentMessage: string,\n userSuggestion: string,\n diffInfo: GitDiffInfo,\n ): Promise<string> {\n const llm = this.multiLlmService.createModel('cheap');\n const context = this.buildDiffContext(diffInfo, {\n maxLength: 6000,\n maxCharsPerFile: 1200,\n maxUntrackedFiles: 3,\n maxUntrackedLines: 40,\n });\n const currentMetadata = this.extractTypeAndScope(currentMessage);\n\n const prompt = `Mensagem atual: ${currentMessage}\n\nSugestão do usuário: ${userSuggestion}\n\nContexto do diff:\n${context}`;\n\n const response = await llm.invoke([\n new SystemMessage(this.getRefineSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const message = this.extractContent(response.content);\n return this.normalizeCommitMessage(\n message,\n currentMetadata.type ?? 'chore',\n currentMetadata.scope,\n 'atualiza código',\n currentMetadata.breaking ?? false,\n );\n }\n\n private extractFiles(diff: string): string[] {\n const files = new Set<string>();\n const lines = diff.split('\\n');\n\n for (const line of lines) {\n if (line.startsWith('diff --git')) {\n const match = line.match(/diff --git a\\/(.+?) b\\/(.+?)$/);\n if (match) {\n files.add(match[2]);\n }\n }\n }\n\n return Array.from(files);\n }\n\n private extractContent(content: unknown): string {\n if (typeof content === 'string') return content;\n if (Array.isArray(content) && content.length > 0) {\n const first = content[0];\n if (typeof first === 'object' && first !== null && 'text' in first) {\n return String(first.text);\n }\n }\n return String(content);\n }\n\n private buildCommitPrompt(diffInfo: GitDiffInfo, scope?: string): string {\n const scopeHint = scope\n ? `Escopo provável do monorepo: \"${scope}\".`\n : 'Escopo do monorepo não identificado automaticamente.';\n const fullDiff = this.buildDiffContext(diffInfo, {\n maxLength: 12000,\n maxCharsPerFile: 1800,\n maxUntrackedFiles: 4,\n maxUntrackedLines: 60,\n });\n\n return `Analise TODO o contexto de mudanças e gere UMA mensagem de commit no padrão Conventional Commits.\n\n${scopeHint}\n\nRegras obrigatórias:\n- Formato: \"type(scope): descrição\", \"type: descrição\" ou com breaking \"type(scope)!: descrição\"\n- Tipos permitidos: ${COMMIT_TYPES.join(', ')}\n- Descrição em português (pt-BR), objetiva, no imperativo e sem ponto final\n- Máximo de 72 caracteres no assunto completo\n- A mensagem deve refletir a intenção principal do conjunto total de mudanças\n- Se for breaking change, inclua \"!\" após o type/scope\n- Considere staged, unstaged e arquivos novos\n\nContexto do diff:\n${fullDiff}`;\n }\n\n private buildSplitPrompt(diffInfo: GitDiffInfo, files: string[]): string {\n const allFiles = this.normalizeFiles([...files, ...diffInfo.untrackedFiles]);\n const fullDiff = this.buildDiffContext(diffInfo, {\n maxLength: 15000,\n maxCharsPerFile: 1600,\n maxUntrackedFiles: 6,\n maxUntrackedLines: 80,\n });\n\n return `Analise o diff completo e divida em commits lógicos no padrão Conventional Commits.\n\nRegras obrigatórias:\n- Cada arquivo da lista deve aparecer exatamente uma vez no resultado\n- Inclua TODOS os arquivos listados\n- Separe mudanças por coesão funcional (feature, fix, docs, refactor etc.)\n- Evite misturar objetivos diferentes no mesmo commit\n- Tipos permitidos: ${COMMIT_TYPES.join(', ')}\n- Descrição em português (pt-BR), no imperativo e sem ponto final\n\nArquivos esperados:\n${allFiles.join(', ') || '(nenhum arquivo detectado)'}\n\nContexto do diff:\n${fullDiff}`;\n }\n\n private async generateMessageForGroup(group: CommitGroup): Promise<string> {\n const llm = this.multiLlmService.createModel('cheap');\n const scopePart = group.scope ? `(${group.scope})` : '';\n const prompt = `Gere uma mensagem Conventional Commit (máximo 72 caracteres) para este grupo:\n\nTipo: ${group.type}${scopePart}\nArquivos: ${group.files.join(', ')}\nResumo: ${group.description}\n\nRetorne APENAS uma linha no formato:\n\"type(scope): descrição\", \"type: descrição\" ou \"type(scope)!: descrição\"\n\nDescrição obrigatoriamente em português (pt-BR).`;\n\n const response = await llm.invoke([\n new SystemMessage(this.getCommitSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const message = this.extractContent(response.content);\n return this.normalizeCommitMessage(message, group.type, group.scope, group.description);\n }\n\n private parseCommitGroups(content: string): CommitGroup[] | null {\n const jsonMatch = content.match(/```json\\s*([\\s\\S]*?)\\s*```/);\n if (jsonMatch) {\n try {\n const parsed = JSON.parse(jsonMatch[1]);\n if (parsed.commits && Array.isArray(parsed.commits)) {\n return parsed.commits;\n }\n } catch {}\n }\n\n try {\n const parsed = JSON.parse(content);\n if (parsed.commits && Array.isArray(parsed.commits)) {\n return parsed.commits;\n }\n } catch {}\n\n return null;\n }\n\n private getCommitSystemPrompt(): string {\n return `Você é especialista em mensagens de commit no padrão Conventional Commits.\n\nTipos permitidos:\n${COMMIT_TYPES.join(', ')}\n\nFormato obrigatório:\n- Com escopo: <type>(<scope>): <descrição>\n- Sem escopo: <type>: <descrição>\n- Breaking change no assunto: <type>(<scope>)!: <descrição> (ou <type>!: <descrição>)\n\nRegras:\n- Assunto completo com no máximo 72 caracteres\n- Descrição em português (pt-BR)\n- Verbo no imperativo\n- Sem ponto final\n- Seja específico e evite mensagens genéricas\n- Use escopo quando ele estiver claro\n- Tipos feat e fix devem ser usados de forma semântica (feature e correção)\n\nRetorne SOMENTE a linha do commit, sem explicações.`;\n }\n\n private getSplitSystemPrompt(): string {\n return `Você é especialista em organizar diffs em commits lógicos.\n\nTarefa:\n- Agrupar mudanças por coesão funcional\n- Separar corretamente feature, fix, docs, refactor etc.\n- Garantir que todos os arquivos apareçam exatamente uma vez\n\nFormato de resposta:\nRetorne SOMENTE JSON válido:\n\\`\\`\\`json\n{\n \"commits\": [\n {\n \"type\": \"feat\",\n \"files\": [\"src/chatbot/service.ts\"],\n \"description\": \"adiciona service de chatbot\"\n },\n {\n \"type\": \"docs\",\n \"files\": [\"README.md\"],\n \"description\": \"atualiza documentação de uso\"\n }\n ]\n}\n\\`\\`\\`\n\nRegras:\n- Tipos permitidos: ${COMMIT_TYPES.join(', ')}\n- Cada commit com propósito claro\n- Descrição em português (pt-BR), no imperativo, sem ponto final\n- Máximo recomendado de 5 arquivos por commit\n- Pode retornar 1 commit apenas se o diff for pequeno e coeso\n\nRetorne SOMENTE o JSON, sem texto adicional.`;\n }\n\n private getRefineSystemPrompt(): string {\n return `Você está refinando uma mensagem de commit a partir do feedback do usuário.\n\nInstruções:\n- Respeite Conventional Commits\n- Mantenha no máximo 72 caracteres\n- Mensagem em português (pt-BR), no imperativo e sem ponto final\n- Incorpore a sugestão do usuário sem perder precisão técnica\n\nRetorne SOMENTE a nova linha de commit.`;\n }\n\n private normalizeCommitGroups(commitGroups: CommitGroup[], files: string[]): CommitGroup[] {\n const expectedFiles = new Set(this.normalizeFiles(files));\n const usedFiles = new Set<string>();\n const normalizedGroups: CommitGroup[] = [];\n\n for (const group of commitGroups) {\n const filesFromGroup = this.normalizeFiles(Array.isArray(group.files) ? group.files : [])\n .filter((file) => expectedFiles.has(file))\n .filter((file) => {\n if (usedFiles.has(file)) {\n return false;\n }\n usedFiles.add(file);\n return true;\n });\n\n if (filesFromGroup.length === 0) continue;\n\n normalizedGroups.push({\n type: this.normalizeCommitType(group.type, this.inferTypeFromFiles(filesFromGroup)),\n files: filesFromGroup,\n description: this.normalizeDescription(group.description, 'organiza mudanças relacionadas'),\n scope: this.normalizeScope(group.scope),\n });\n }\n\n const missingFiles = this.normalizeFiles(files).filter((file) => !usedFiles.has(file));\n if (missingFiles.length > 0) {\n normalizedGroups.push({\n type: this.inferTypeFromFiles(missingFiles),\n files: missingFiles,\n description: 'organiza arquivos restantes do diff',\n });\n }\n\n return normalizedGroups;\n }\n\n private normalizeCommitMessage(\n rawMessage: string,\n fallbackType: ConventionalCommitType,\n fallbackScope?: string,\n fallbackDescription = 'atualiza código',\n fallbackBreaking = false,\n ): string {\n const candidateLine = this.extractCandidateCommitLine(rawMessage);\n const match = candidateLine.match(/^([a-zA-Z-]+)(?:\\(([^)]+)\\))?(!)?:\\s*(.+)$/);\n\n const type = this.normalizeCommitType(match?.[1], fallbackType);\n const scope = this.normalizeScope(match?.[2] ?? fallbackScope);\n const breaking = Boolean(match?.[3]) || fallbackBreaking;\n const rawDescription = match?.[4] ?? candidateLine;\n const description = this.normalizeDescription(rawDescription, fallbackDescription);\n\n const breakingFlag = breaking ? '!' : '';\n const prefix = scope\n ? `${type}(${scope})${breakingFlag}: `\n : `${type}${breakingFlag}: `;\n const maxDescriptionLength = Math.max(12, 72 - prefix.length);\n const truncatedDescription = this.truncateText(description, maxDescriptionLength);\n\n return `${prefix}${truncatedDescription}`;\n }\n\n private extractTypeAndScope(message: string): {\n type?: ConventionalCommitType;\n scope?: string;\n breaking?: boolean;\n } {\n const candidateLine = this.extractCandidateCommitLine(message);\n const match = candidateLine.match(/^([a-zA-Z-]+)(?:\\(([^)]+)\\))?(!)?:\\s*.+$/);\n if (!match) return {};\n\n return {\n type: this.normalizeCommitType(match[1], 'chore'),\n scope: this.normalizeScope(match[2]),\n breaking: Boolean(match[3]),\n };\n }\n\n private extractCandidateCommitLine(rawMessage: string): string {\n const withoutCodeBlock = rawMessage.replace(/```(?:[\\w-]+)?/g, '');\n const lines = withoutCodeBlock\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .map((line) => line.replace(/^[-*]\\s+/, ''));\n\n if (lines.length === 0) return '';\n\n const conventionalLine = lines.find((line) => /^[a-zA-Z-]+(?:\\([^)]+\\))?!?:\\s+/.test(line));\n if (conventionalLine) {\n return conventionalLine.replace(/^[\"'`]|[\"'`]$/g, '').trim();\n }\n\n const prefixedLine = lines.find((line) => /^commit\\s*:/i.test(line));\n if (prefixedLine) {\n return prefixedLine.replace(/^commit\\s*:/i, '').replace(/^[\"'`]|[\"'`]$/g, '').trim();\n }\n\n return lines[0].replace(/^[\"'`]|[\"'`]$/g, '').trim();\n }\n\n private normalizeCommitType(\n type: string | undefined,\n fallbackType: ConventionalCommitType,\n ): ConventionalCommitType {\n const normalized = (type || '')\n .toLowerCase()\n .trim()\n .replace(/[^a-z]/g, '');\n\n if (!normalized) return fallbackType;\n if (COMMIT_TYPE_SET.has(normalized)) return normalized as ConventionalCommitType;\n if (COMMIT_TYPE_ALIASES[normalized]) return COMMIT_TYPE_ALIASES[normalized];\n\n return fallbackType;\n }\n\n private normalizeScope(scope?: string): string | undefined {\n if (!scope) return undefined;\n\n const normalized = scope\n .trim()\n .replace(/^[\"'`]|[\"'`]$/g, '')\n .toLowerCase()\n .replace(/\\s+/g, '-')\n .replace(/[^a-z0-9/_-]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n\n return normalized || undefined;\n }\n\n private normalizeDescription(description: string, fallback: string): string {\n let normalized = description\n .replace(/^[\"'`]|[\"'`]$/g, '')\n .replace(/^([a-zA-Z-]+)(?:\\([^)]+\\))?!?:\\s*/, '')\n .replace(/\\s+/g, ' ')\n .trim();\n\n normalized = normalized.replace(/[.;:!?]+$/, '').trim();\n if (!normalized) normalized = fallback;\n\n normalized = this.translateLeadingVerb(normalized);\n\n if (/^[A-ZÀ-Ý]/.test(normalized)) {\n normalized = normalized.charAt(0).toLowerCase() + normalized.slice(1);\n }\n\n return normalized;\n }\n\n private translateLeadingVerb(description: string): string {\n const match = description.match(/^([a-zA-Z]+)(\\b.*)$/);\n if (!match) return description;\n\n const translated = LEADING_VERB_TRANSLATIONS[match[1].toLowerCase()];\n if (!translated) return description;\n\n return `${translated}${match[2]}`;\n }\n\n private truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n\n const truncated = text.slice(0, maxLength).trimEnd();\n const lastSpace = truncated.lastIndexOf(' ');\n if (lastSpace > maxLength * 0.6) {\n return truncated.slice(0, lastSpace).trimEnd();\n }\n\n return truncated;\n }\n\n private normalizeFiles(files: string[]): string[] {\n const unique = new Set<string>();\n\n for (const file of files) {\n if (typeof file !== 'string') continue;\n const normalized = file.trim().replace(/^[\"']|[\"']$/g, '');\n if (!normalized) continue;\n unique.add(normalized);\n }\n\n return Array.from(unique);\n }\n\n private buildStatsSummary(\n stagedStats: string,\n unstagedStats: string,\n statusShort: string,\n untrackedFiles: string[],\n ): string {\n const sections: string[] = [];\n\n if (statusShort.trim()) {\n sections.push(`Git status (--short):\\n${statusShort.trim()}`);\n }\n if (stagedStats.trim()) {\n sections.push(`Diff staged (--cached --stat):\\n${stagedStats.trim()}`);\n }\n if (unstagedStats.trim()) {\n sections.push(`Diff unstaged (--stat):\\n${unstagedStats.trim()}`);\n }\n if (untrackedFiles.length > 0) {\n sections.push(`Arquivos novos (${untrackedFiles.length}): ${untrackedFiles.join(', ')}`);\n }\n\n return sections.join('\\n\\n');\n }\n\n private buildDiffContext(\n diffInfo: GitDiffInfo,\n options: {\n maxLength: number;\n maxCharsPerFile: number;\n maxUntrackedFiles: number;\n maxUntrackedLines: number;\n },\n ): string {\n const sections: string[] = [];\n\n if (diffInfo.stats.trim()) {\n sections.push(`Resumo:\\n${diffInfo.stats.trim()}`);\n }\n\n sections.push(this.buildFilesSummary(diffInfo));\n\n const stagedByFile = this.limitDiffByFile(diffInfo.staged, options.maxCharsPerFile);\n if (stagedByFile) {\n sections.push(`=== STAGED ===\\n${stagedByFile}`);\n }\n\n const unstagedByFile = this.limitDiffByFile(diffInfo.unstaged, options.maxCharsPerFile);\n if (unstagedByFile) {\n sections.push(`=== UNSTAGED ===\\n${unstagedByFile}`);\n }\n\n const untrackedPreview = this.buildUntrackedPreview(\n diffInfo.untrackedFiles,\n options.maxUntrackedFiles,\n options.maxUntrackedLines,\n );\n if (untrackedPreview) {\n sections.push(`=== PREVIEW ARQUIVOS NOVOS ===\\n${untrackedPreview}`);\n }\n\n let combined = sections.filter(Boolean).join('\\n\\n');\n if (combined.length > options.maxLength) {\n combined = `${combined.slice(0, options.maxLength).trimEnd()}\\n\\n... (contexto truncado)`;\n }\n\n return combined;\n }\n\n private buildFilesSummary(diffInfo: GitDiffInfo): string {\n const lines: string[] = [];\n\n const stagedFiles = this.normalizeFiles(diffInfo.stagedFiles);\n const unstagedFiles = this.normalizeFiles(diffInfo.unstagedFiles);\n const untrackedFiles = this.normalizeFiles(diffInfo.untrackedFiles);\n\n if (stagedFiles.length > 0) {\n lines.push(`Staged (${stagedFiles.length}): ${this.summarizeFileList(stagedFiles)}`);\n }\n if (unstagedFiles.length > 0) {\n lines.push(`Unstaged (${unstagedFiles.length}): ${this.summarizeFileList(unstagedFiles)}`);\n }\n if (untrackedFiles.length > 0) {\n lines.push(`Novos (${untrackedFiles.length}): ${this.summarizeFileList(untrackedFiles)}`);\n }\n\n if (lines.length === 0) {\n return 'Arquivos afetados: nenhum arquivo identificado';\n }\n\n return `Arquivos afetados:\\n${lines.join('\\n')}`;\n }\n\n private summarizeFileList(files: string[], limit = 20): string {\n if (files.length <= limit) {\n return files.join(', ');\n }\n\n const remaining = files.length - limit;\n return `${files.slice(0, limit).join(', ')}, ... (+${remaining})`;\n }\n\n private limitDiffByFile(diff: string, maxCharsPerFile: number): string {\n if (!diff.trim()) return '';\n\n const sections = this.splitDiffByFile(diff);\n if (sections.length === 0) return '';\n\n const limitedSections = sections.map((section) => {\n if (section.length <= maxCharsPerFile) return section.trimEnd();\n return `${section.slice(0, maxCharsPerFile).trimEnd()}\\n... (diff deste arquivo truncado)`;\n });\n\n return limitedSections.join('\\n\\n');\n }\n\n private splitDiffByFile(diff: string): string[] {\n const rawSections = diff\n .split(/^diff --git /m)\n .map((section) => section.trim())\n .filter((section) => section.length > 0);\n\n return rawSections.map((section) => `diff --git ${section}`);\n }\n\n private buildUntrackedPreview(files: string[], maxFiles: number, maxLines: number): string {\n const selectedFiles = this.normalizeFiles(files).slice(0, maxFiles);\n const sections: string[] = [];\n\n for (const file of selectedFiles) {\n const preview = this.readTextFilePreview(file, maxLines);\n if (!preview) continue;\n sections.push(`--- ${file} ---\\n${preview}`);\n }\n\n if (files.length > maxFiles) {\n sections.push(`... ${files.length - maxFiles} arquivo(s) novo(s) omitido(s)`);\n }\n\n return sections.join('\\n\\n');\n }\n\n private readTextFilePreview(file: string, maxLines: number): string {\n try {\n const content = readFileSync(file, 'utf-8');\n if (content.includes('\\u0000')) {\n return '[arquivo binário omitido]';\n }\n\n if (!content.length) {\n return '[arquivo vazio]';\n }\n\n const lines = content.split('\\n');\n const preview = lines.slice(0, maxLines).join('\\n');\n const clippedPreview = preview.length > 2500 ? `${preview.slice(0, 2500)}\\n...` : preview;\n\n if (lines.length > maxLines && !clippedPreview.endsWith('\\n...')) {\n return `${clippedPreview}\\n...`;\n }\n\n return clippedPreview;\n } catch {\n return '';\n }\n }\n\n private inferTypeFromFiles(files: string[]): ConventionalCommitType {\n if (files.length === 0) return 'chore';\n\n const onlyDocs = files.every((file) =>\n /^docs\\//i.test(file)\n || /(^|\\/)README\\.md$/i.test(file)\n || /(^|\\/)CHANGELOG\\.md$/i.test(file)\n || /\\.(md|mdx|txt)$/i.test(file),\n );\n if (onlyDocs) return 'docs';\n\n const onlyTests = files.every((file) =>\n /(^|\\/)__tests__\\//.test(file)\n || /\\.(spec|test)\\.[cm]?[jt]sx?$/.test(file),\n );\n if (onlyTests) return 'test';\n\n const onlyInfra = files.every((file) =>\n /(^|\\/)package(-lock)?\\.json$/.test(file)\n || /(^|\\/)(pnpm-lock\\.yaml|yarn\\.lock)$/i.test(file)\n || /(^|\\/)Dockerfile/i.test(file)\n || /(^|\\/)docker-compose\\.ya?ml$/i.test(file)\n || /(^|\\/)\\.github\\/workflows\\//.test(file),\n );\n if (onlyInfra) return 'build';\n\n return 'chore';\n }\n\n private escapeShellArg(value: string): string {\n return `'${value.replace(/'/g, '\\'\\\\\\'\\'')}'`;\n }\n}\n"],"names":["CommitGeneratorService","COMMIT_TYPES","COMMIT_TYPE_SET","Set","COMMIT_TYPE_ALIASES","feature","features","bug","bugfix","documentation","docs","test","tests","testing","performance","optimize","optimization","dependency","dependencies","maintenance","housekeeping","cleanup","remove","LEADING_VERB_TRANSLATIONS","add","adds","update","updates","upgrade","upgrades","fix","fixes","removes","refactor","refactors","improve","improves","create","creates","implement","implements","rename","renames","getDiffInfo","cwd","process","staged","execSync","encoding","unstaged","stagedStats","unstagedStats","statusShort","untrackedRaw","untrackedFiles","trim","split","filter","f","stagedFiles","extractFiles","unstagedFiles","stats","buildStatsSummary","hasChanges","output","length","generateCommitMessage","diffInfo","monorepoInfo","monorepoDetector","detectMonorepo","allFiles","scope","determineScope","llm","multiLlmService","createModel","prompt","buildCommitPrompt","response","invoke","SystemMessage","getCommitSystemPrompt","HumanMessage","message","extractContent","content","normalizeCommitMessage","splitCommits","splitPrompt","buildSplitPrompt","splitResponse","getSplitSystemPrompt","splitContent","commitGroups","parseCommitGroups","normalizedGroups","normalizeCommitGroups","group","files","generateMessageForGroup","push","executeCommit","autoStage","input","executePush","branch","success","error","includes","executeSplitCommits","commits","committedCount","originalHead","commit","file","normalizeFiles","escapeShellArg","committed","refineCommitMessage","currentMessage","userSuggestion","context","buildDiffContext","maxLength","maxCharsPerFile","maxUntrackedFiles","maxUntrackedLines","currentMetadata","extractTypeAndScope","getRefineSystemPrompt","type","breaking","diff","lines","line","startsWith","match","Array","from","isArray","first","String","text","scopeHint","fullDiff","join","scopePart","description","jsonMatch","parsed","JSON","parse","expectedFiles","usedFiles","filesFromGroup","has","normalizeCommitType","inferTypeFromFiles","normalizeDescription","normalizeScope","missingFiles","rawMessage","fallbackType","fallbackScope","fallbackDescription","fallbackBreaking","candidateLine","extractCandidateCommitLine","Boolean","rawDescription","breakingFlag","prefix","maxDescriptionLength","Math","max","truncatedDescription","truncateText","withoutCodeBlock","replace","map","conventionalLine","find","prefixedLine","normalized","toLowerCase","undefined","fallback","translateLeadingVerb","charAt","slice","translated","truncated","trimEnd","lastSpace","lastIndexOf","unique","sections","options","buildFilesSummary","stagedByFile","limitDiffByFile","unstagedByFile","untrackedPreview","buildUntrackedPreview","combined","summarizeFileList","limit","remaining","splitDiffByFile","limitedSections","section","rawSections","maxFiles","maxLines","selectedFiles","preview","readTextFilePreview","readFileSync","clippedPreview","endsWith","onlyDocs","every","onlyTests","onlyInfra","value"],"mappings":";;;;+BAoEaA;;;eAAAA;;;wBApEc;oBACE;+BACJ;0BACmB;iCACZ;yCACQ;;;;;;;;;;AAGxC,MAAMC,eAAyC;IAC7C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,kBAAkB,IAAIC,IAAYF;AAExC,MAAMG,sBAA8D;IAClEC,SAAS;IACTC,UAAU;IACVC,KAAK;IACLC,QAAQ;IACRC,eAAe;IACfC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPC,SAAS;IACTC,aAAa;IACbC,UAAU;IACVC,cAAc;IACdC,YAAY;IACZC,cAAc;IACdC,aAAa;IACbC,cAAc;IACdC,SAAS;IACTC,QAAQ;AACV;AAEA,MAAMC,4BAAoD;IACxDC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC,SAAS;IACTC,SAAS;IACTC,UAAU;IACVC,KAAK;IACLC,OAAO;IACPT,QAAQ;IACRU,SAAS;IACTC,UAAU;IACVC,WAAW;IACXC,SAAS;IACTC,UAAU;IACVC,QAAQ;IACRC,SAAS;IACTC,WAAW;IACXC,YAAY;IACZC,QAA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oBAAoBzG,IAAI,CAACyG,SACtB,+BAA+BzG,IAAI,CAACyG;QAEzC,IAAI4G,WAAW,OAAO;QAEtB,MAAMC,YAAY7H,MAAM2H,KAAK,CAAC,CAAC3G,OAC7B,+BAA+BzG,IAAI,CAACyG,SACjC,uCAAuCzG,IAAI,CAACyG,SAC5C,oBAAoBzG,IAAI,CAACyG,SACzB,gCAAgCzG,IAAI,CAACyG,SACrC,8BAA8BzG,IAAI,CAACyG;QAExC,IAAI6G,WAAW,OAAO;QAEtB,OAAO;IACT;IAEQ3G,eAAe4G,KAAa,EAAU;QAC5C,OAAO,CAAC,CAAC,EAAEA,MAAM9C,OAAO,CAAC,MAAM,YAAY,CAAC,CAAC;IAC/C;IAxwBA,YACE,AAAiBxG,eAAgC,EACjD,AAAiBN,gBAAyC,CAC1D;aAFiBM,kBAAAA;aACAN,mBAAAA;IAChB;AAswBL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cast-code",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Multi-agent CLI system powered by DeepAgents",
5
5
  "main": "dist/main.js",
6
6
  "bin": {