@m3hti/commit-genie 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/analyzerService.d.ts +0 -141
- package/dist/services/analyzerService.d.ts.map +1 -1
- package/dist/services/analyzerService.js +23 -1880
- package/dist/services/analyzerService.js.map +1 -1
- package/dist/services/analyzerService.test.js +97 -0
- package/dist/services/analyzerService.test.js.map +1 -1
- package/dist/services/breakingChangeDetector.d.ts +9 -0
- package/dist/services/breakingChangeDetector.d.ts.map +1 -0
- package/dist/services/breakingChangeDetector.js +76 -0
- package/dist/services/breakingChangeDetector.js.map +1 -0
- package/dist/services/commitTypeDetector.d.ts +32 -0
- package/dist/services/commitTypeDetector.d.ts.map +1 -0
- package/dist/services/commitTypeDetector.js +490 -0
- package/dist/services/commitTypeDetector.js.map +1 -0
- package/dist/services/descriptionGenerator.d.ts +58 -0
- package/dist/services/descriptionGenerator.d.ts.map +1 -0
- package/dist/services/descriptionGenerator.js +569 -0
- package/dist/services/descriptionGenerator.js.map +1 -0
- package/dist/services/fileContentAnalyzer.d.ts +10 -0
- package/dist/services/fileContentAnalyzer.d.ts.map +1 -0
- package/dist/services/fileContentAnalyzer.js +170 -0
- package/dist/services/fileContentAnalyzer.js.map +1 -0
- package/dist/services/fileContentAnalyzer.test.d.ts +2 -0
- package/dist/services/fileContentAnalyzer.test.d.ts.map +1 -0
- package/dist/services/fileContentAnalyzer.test.js +118 -0
- package/dist/services/fileContentAnalyzer.test.js.map +1 -0
- package/dist/services/gitService.test.js +242 -24
- package/dist/services/gitService.test.js.map +1 -1
- package/dist/services/hookService.test.d.ts +2 -0
- package/dist/services/hookService.test.d.ts.map +1 -0
- package/dist/services/hookService.test.js +182 -0
- package/dist/services/hookService.test.js.map +1 -0
- package/dist/services/lintService.test.d.ts +2 -0
- package/dist/services/lintService.test.d.ts.map +1 -0
- package/dist/services/lintService.test.js +288 -0
- package/dist/services/lintService.test.js.map +1 -0
- package/dist/services/messageBuilder.d.ts +16 -0
- package/dist/services/messageBuilder.d.ts.map +1 -0
- package/dist/services/messageBuilder.js +135 -0
- package/dist/services/messageBuilder.js.map +1 -0
- package/dist/services/scopeDetector.d.ts +6 -0
- package/dist/services/scopeDetector.d.ts.map +1 -0
- package/dist/services/scopeDetector.js +51 -0
- package/dist/services/scopeDetector.js.map +1 -0
- package/dist/services/semanticAnalyzer.d.ts +25 -0
- package/dist/services/semanticAnalyzer.d.ts.map +1 -0
- package/dist/services/semanticAnalyzer.js +713 -0
- package/dist/services/semanticAnalyzer.js.map +1 -0
- package/dist/services/splitService.test.d.ts +2 -0
- package/dist/services/splitService.test.d.ts.map +1 -0
- package/dist/services/splitService.test.js +190 -0
- package/dist/services/splitService.test.js.map +1 -0
- package/dist/services/statsService.test.d.ts +2 -0
- package/dist/services/statsService.test.d.ts.map +1 -0
- package/dist/services/statsService.test.js +211 -0
- package/dist/services/statsService.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COMMIT_EMOJIS = void 0;
|
|
4
|
+
exports.generateBody = generateBody;
|
|
5
|
+
exports.applyTemplate = applyTemplate;
|
|
6
|
+
exports.buildFullMessage = buildFullMessage;
|
|
7
|
+
const configService_1 = require("./configService");
|
|
8
|
+
exports.COMMIT_EMOJIS = {
|
|
9
|
+
feat: '\u2728',
|
|
10
|
+
fix: '\ud83d\udc1b',
|
|
11
|
+
docs: '\ud83d\udcda',
|
|
12
|
+
style: '\ud83d\udc84',
|
|
13
|
+
refactor: '\u267b\ufe0f',
|
|
14
|
+
test: '\ud83e\uddea',
|
|
15
|
+
chore: '\ud83d\udd27',
|
|
16
|
+
perf: '\u26a1',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Generate commit body for larger changes
|
|
20
|
+
* Includes semantic role context when available
|
|
21
|
+
*/
|
|
22
|
+
function generateBody(analysis) {
|
|
23
|
+
const lines = [];
|
|
24
|
+
const semantic = analysis.semanticAnalysis;
|
|
25
|
+
// Include semantic context (WHY the change was made) for multi-role changes
|
|
26
|
+
if (semantic && semantic.hasMultipleRoles) {
|
|
27
|
+
lines.push('Changes:');
|
|
28
|
+
for (const roleChange of semantic.roleChanges.filter(r => r.significance > 15).slice(0, 4)) {
|
|
29
|
+
const elements = roleChange.affectedElements.length > 0
|
|
30
|
+
? ` (${roleChange.affectedElements.slice(0, 2).join(', ')})`
|
|
31
|
+
: '';
|
|
32
|
+
lines.push(`- ${roleChange.summary}${elements}`);
|
|
33
|
+
}
|
|
34
|
+
lines.push('');
|
|
35
|
+
}
|
|
36
|
+
// Only add file details for truly large changes
|
|
37
|
+
if (!analysis.isLargeChange && lines.length === 0) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
// Add file change details for large changes
|
|
41
|
+
if (analysis.isLargeChange) {
|
|
42
|
+
if (lines.length > 0) {
|
|
43
|
+
lines.push('Files:');
|
|
44
|
+
}
|
|
45
|
+
if (analysis.fileChanges.added.length > 0) {
|
|
46
|
+
lines.push(`- Add ${analysis.fileChanges.added.join(', ')}`);
|
|
47
|
+
}
|
|
48
|
+
if (analysis.fileChanges.modified.length > 0) {
|
|
49
|
+
const files = analysis.fileChanges.modified.slice(0, 5);
|
|
50
|
+
const suffix = analysis.fileChanges.modified.length > 5
|
|
51
|
+
? ` and ${analysis.fileChanges.modified.length - 5} more`
|
|
52
|
+
: '';
|
|
53
|
+
lines.push(`- Update ${files.join(', ')}${suffix}`);
|
|
54
|
+
}
|
|
55
|
+
if (analysis.fileChanges.deleted.length > 0) {
|
|
56
|
+
lines.push(`- Remove ${analysis.fileChanges.deleted.join(', ')}`);
|
|
57
|
+
}
|
|
58
|
+
if (analysis.fileChanges.renamed.length > 0) {
|
|
59
|
+
lines.push(`- Rename ${analysis.fileChanges.renamed.join(', ')}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return lines.length > 0 ? lines.join('\n') : undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Apply a template to build the commit message subject line
|
|
66
|
+
*/
|
|
67
|
+
function applyTemplate(template, type, scope, description, includeEmoji, isBreaking) {
|
|
68
|
+
const emoji = includeEmoji ? exports.COMMIT_EMOJIS[type] : '';
|
|
69
|
+
const breakingIndicator = isBreaking ? '!' : '';
|
|
70
|
+
let result = template
|
|
71
|
+
.replace('{emoji}', emoji)
|
|
72
|
+
.replace('{type}', type + breakingIndicator)
|
|
73
|
+
.replace('{description}', description);
|
|
74
|
+
// Handle scope - if no scope, use noScope template or remove scope placeholder
|
|
75
|
+
if (scope) {
|
|
76
|
+
result = result.replace('{scope}', scope);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Remove scope and parentheses if no scope
|
|
80
|
+
result = result.replace('({scope})', '').replace('{scope}', '');
|
|
81
|
+
}
|
|
82
|
+
// Clean up extra spaces
|
|
83
|
+
result = result.replace(/\s+/g, ' ').trim();
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Build full commit message string
|
|
88
|
+
*/
|
|
89
|
+
function buildFullMessage(type, scope, description, body, includeEmoji, ticketInfo, isBreaking, breakingReasons) {
|
|
90
|
+
const config = configService_1.ConfigService.getConfig();
|
|
91
|
+
const includeBreakingFooter = config.breakingChangeDetection?.includeFooter !== false;
|
|
92
|
+
const templates = config.templates;
|
|
93
|
+
let full = '';
|
|
94
|
+
// Use template if available
|
|
95
|
+
if (templates) {
|
|
96
|
+
const template = scope
|
|
97
|
+
? (templates.default || '{emoji} {type}({scope}): {description}')
|
|
98
|
+
: (templates.noScope || '{emoji} {type}: {description}');
|
|
99
|
+
full = applyTemplate(template, type, scope, description, includeEmoji, isBreaking);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// Fallback to original logic
|
|
103
|
+
if (includeEmoji) {
|
|
104
|
+
full += `${exports.COMMIT_EMOJIS[type]} `;
|
|
105
|
+
}
|
|
106
|
+
full += type;
|
|
107
|
+
if (scope) {
|
|
108
|
+
full += `(${scope})`;
|
|
109
|
+
}
|
|
110
|
+
// Add breaking change indicator
|
|
111
|
+
if (isBreaking) {
|
|
112
|
+
full += '!';
|
|
113
|
+
}
|
|
114
|
+
full += `: ${description}`;
|
|
115
|
+
}
|
|
116
|
+
if (body) {
|
|
117
|
+
full += `\n\n${body}`;
|
|
118
|
+
}
|
|
119
|
+
// Add BREAKING CHANGE footer if enabled and breaking
|
|
120
|
+
if (isBreaking && includeBreakingFooter && breakingReasons && breakingReasons.length > 0) {
|
|
121
|
+
full += '\n\nBREAKING CHANGE: ' + breakingReasons[0];
|
|
122
|
+
if (breakingReasons.length > 1) {
|
|
123
|
+
for (let i = 1; i < breakingReasons.length; i++) {
|
|
124
|
+
full += `\n- ${breakingReasons[i]}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Add ticket reference as footer
|
|
129
|
+
if (ticketInfo) {
|
|
130
|
+
const prefix = ticketInfo.prefix || 'Refs:';
|
|
131
|
+
full += `\n\n${prefix} ${ticketInfo.id}`;
|
|
132
|
+
}
|
|
133
|
+
return full;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=messageBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageBuilder.js","sourceRoot":"","sources":["../../src/services/messageBuilder.ts"],"names":[],"mappings":";;;AAuBA,oCAiDC;AAKD,sCA4BC;AAKD,4CAgEC;AA9KD,mDAAgD;AAOnC,QAAA,aAAa,GAA+B;IACvD,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,cAAc;IACnB,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,cAAc;IACrB,QAAQ,EAAE,cAAc;IACxB,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,QAAQ;CACf,CAAC;AAGF;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AM,MAAM,GAAG,UAAU,CAAC,MAAM,IAAI,OAAO,CAAC;QAC5C,IAAI,IAAI,OAAO,MAAM,IAAI,UAAU,CAAC,EAAE,EAAE,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeDetector.d.ts","sourceRoot":"","sources":["../../src/services/scopeDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,SAAS,CA+C5E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.determineScope = determineScope;
|
|
4
|
+
const configService_1 = require("./configService");
|
|
5
|
+
/**
|
|
6
|
+
* Determine scope from file paths
|
|
7
|
+
*/
|
|
8
|
+
function determineScope(stagedFiles) {
|
|
9
|
+
if (stagedFiles.length === 0)
|
|
10
|
+
return undefined;
|
|
11
|
+
const config = configService_1.ConfigService.getConfig();
|
|
12
|
+
const paths = stagedFiles.map((f) => f.path);
|
|
13
|
+
// Check config-based scope mappings first
|
|
14
|
+
if (config.scopes && config.scopes.length > 0) {
|
|
15
|
+
for (const mapping of config.scopes) {
|
|
16
|
+
const matchingFiles = paths.filter((p) => p.includes(mapping.pattern));
|
|
17
|
+
if (matchingFiles.length === paths.length) {
|
|
18
|
+
return mapping.scope;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// If most files match a pattern, use that scope
|
|
22
|
+
for (const mapping of config.scopes) {
|
|
23
|
+
const matchingFiles = paths.filter((p) => p.includes(mapping.pattern));
|
|
24
|
+
if (matchingFiles.length > paths.length / 2) {
|
|
25
|
+
return mapping.scope;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Fallback to default heuristic
|
|
30
|
+
const firstPath = paths[0];
|
|
31
|
+
const parts = firstPath.split('/');
|
|
32
|
+
if (parts.length > 1) {
|
|
33
|
+
const potentialScope = parts[0];
|
|
34
|
+
// Common scope names to look for
|
|
35
|
+
const validScopes = [
|
|
36
|
+
'api',
|
|
37
|
+
'ui',
|
|
38
|
+
'auth',
|
|
39
|
+
'db',
|
|
40
|
+
'core',
|
|
41
|
+
'utils',
|
|
42
|
+
'components',
|
|
43
|
+
'services',
|
|
44
|
+
];
|
|
45
|
+
if (validScopes.includes(potentialScope.toLowerCase())) {
|
|
46
|
+
return potentialScope;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=scopeDetector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeDetector.js","sourceRoot":"","sources":["../../src/services/scopeDetector.ts"],"names":[],"mappings":";;AAMA,wCA+CC;AApDD,mDAAgD;AAEhD;;GAEG;AACH,SAAgB,cAAc,CAAC,WAAyB;IACtD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAE/C,MAAM,MAAM,GAAG,6BAAa,CAAC,SAAS,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE7C,0CAA0C;IAC1C,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACpC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACvE,IAAI,aAAa,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC1C,OAAO,OAAO,CAAC,KAAK,CAAC;YACvB,CAAC;QACH,CAAC;QACD,gDAAgD;QAChD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACpC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACvE,IAAI,aAAa,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5C,OAAO,OAAO,CAAC,KAAK,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAED,gCAAgC;IAChC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEhC,iCAAiC;QACjC,MAAM,WAAW,GAAG;YAClB,KAAK;YACL,IAAI;YACJ,MAAM;YACN,IAAI;YACJ,MAAM;YACN,OAAO;YACP,YAAY;YACZ,UAAU;SACX,CAAC;QAEF,IAAI,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;YACvD,OAAO,cAAc,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChangeRole, FileChange, SemanticAnalysis, SemanticIntent } from '../types';
|
|
2
|
+
export declare const ROLE_DESCRIPTIONS: Record<ChangeRole, string>;
|
|
3
|
+
export declare const INTENT_VERBS: Record<SemanticIntent, {
|
|
4
|
+
past: string;
|
|
5
|
+
present: string;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Perform semantic analysis on the diff to understand the nature of changes
|
|
9
|
+
* This provides intent-based understanding rather than line-count metrics
|
|
10
|
+
*/
|
|
11
|
+
export declare function analyzeSemanticChanges(diff: string, stagedFiles: FileChange[]): SemanticAnalysis;
|
|
12
|
+
/**
|
|
13
|
+
* Extract affected element names (components, functions, etc.) from the diff
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractAffectedElements(diff: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Extract function/class/method names from git diff by analyzing both hunk headers
|
|
18
|
+
* and the actual context lines around changes.
|
|
19
|
+
*
|
|
20
|
+
* This method prioritizes function declarations found in context lines near the
|
|
21
|
+
* actual changes, which is more accurate than just using hunk headers (which may
|
|
22
|
+
* show preceding functions instead of the one being modified).
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractHunkContext(diff: string): string[];
|
|
25
|
+
//# sourceMappingURL=semanticAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticAnalyzer.d.ts","sourceRoot":"","sources":["../../src/services/semanticAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAEV,gBAAgB,EAChB,cAAc,EACf,MAAM,UAAU,CAAC;AAoKlB,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CASxD,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAQlF,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,UAAU,EAAE,GACxB,gBAAgB,CA6BlB;AAuND;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAqE9D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiDzD"}
|