@elsikora/commitizen-plugin-commitlint-ai 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Process.d.ts.map +1 -1
- package/dist/cjs/Process.js +12 -1
- package/dist/cjs/Process.js.map +1 -1
- package/dist/cjs/services/commitConfirmation.d.ts +3 -0
- package/dist/cjs/services/commitConfirmation.d.ts.map +1 -0
- package/dist/cjs/services/commitConfirmation.js +122 -0
- package/dist/cjs/services/commitConfirmation.js.map +1 -0
- package/dist/cjs/services/commitlintValidator.d.ts +6 -0
- package/dist/cjs/services/commitlintValidator.d.ts.map +1 -1
- package/dist/cjs/services/commitlintValidator.js +32 -31
- package/dist/cjs/services/commitlintValidator.js.map +1 -1
- package/dist/esm/Process.d.ts.map +1 -1
- package/dist/esm/Process.js +12 -1
- package/dist/esm/Process.js.map +1 -1
- package/dist/esm/services/commitConfirmation.d.ts +3 -0
- package/dist/esm/services/commitConfirmation.d.ts.map +1 -0
- package/dist/esm/services/commitConfirmation.js +120 -0
- package/dist/esm/services/commitConfirmation.js.map +1 -0
- package/dist/esm/services/commitlintValidator.d.ts +6 -0
- package/dist/esm/services/commitlintValidator.d.ts.map +1 -1
- package/dist/esm/services/commitlintValidator.js +32 -32
- package/dist/esm/services/commitlintValidator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../src/Process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAa1D,wBAA8B,OAAO,CACpC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE;IACT,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D,GACC,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../src/Process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAa1D,wBAA8B,OAAO,CACpC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE;IACT,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D,GACC,OAAO,CAAC,MAAM,CAAC,CAsMjB"}
|
package/dist/cjs/Process.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var chalk = require('chalk');
|
|
6
|
+
var commitConfirmation = require('./services/commitConfirmation.js');
|
|
6
7
|
var commitlintConfig = require('./services/commitlintConfig.js');
|
|
7
8
|
var commitlintValidator = require('./services/commitlintValidator.js');
|
|
8
9
|
var index = require('./services/llm/index.js');
|
|
@@ -53,8 +54,10 @@ async function Process(rules, prompts$1, inquirer) {
|
|
|
53
54
|
return validatedCommitMessage;
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
57
|
+
console.log(chalk.yellow("AI generated message rejected. Switching to commit edit mode."));
|
|
58
|
+
const confirmedCommitMessage = await commitConfirmation.commitConfirmation(promptContext, { ...commitConfig, scope: extractCommitScope(validatedCommitMessage) });
|
|
59
|
+
return confirmedCommitMessage;
|
|
56
60
|
// If user rejects the generated message, fall through to the manual entry option
|
|
57
|
-
console.log(chalk.yellow("AI-generated message rejected. Switching to manual commit entry."));
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
}
|
|
@@ -160,6 +163,14 @@ async function Process(rules, prompts$1, inquirer) {
|
|
|
160
163
|
}
|
|
161
164
|
return commitMessage;
|
|
162
165
|
}
|
|
166
|
+
function extractCommitScope(commitMessage) {
|
|
167
|
+
const scopeRegex = /^[^(\n]+(\([^)\n]+\))?:/;
|
|
168
|
+
const match = scopeRegex.exec(commitMessage);
|
|
169
|
+
if (match?.[1]) {
|
|
170
|
+
return match[1].slice(1, -1);
|
|
171
|
+
}
|
|
172
|
+
return "";
|
|
173
|
+
}
|
|
163
174
|
|
|
164
175
|
exports.default = Process;
|
|
165
176
|
//# sourceMappingURL=Process.js.map
|
package/dist/cjs/Process.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Process.js","sources":["../../../src/Process.ts"],"sourcesContent":[null],"names":["prompts","setPromptConfig","selectLLMProvider","extractLLMPromptContext","config","getLLMConfig","generateCommitMessage","validateAndFixCommitMessage"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Process.js","sources":["../../../src/Process.ts"],"sourcesContent":[null],"names":["prompts","setPromptConfig","selectLLMProvider","extractLLMPromptContext","config","getLLMConfig","generateCommitMessage","validateAndFixCommitMessage","commitConfirmation"],"mappings":";;;;;;;;;;;;AAce,eAAe,OAAO,CACpC,KAAqB,EACrBA,SAAyB,EACzB,QAEC,EAAA;IAGDC,uBAAe,CAACD,SAAO,CAAC;;AAGxB,IAAA,MAAME,uBAAiB,CAAC,QAAQ,CAAC;;IAGjC,MAAM,aAAa,GAAqBC,wCAAuB,CAAC,KAAK,EAAEH,SAAO,CAAC;;AAG/E,IAAA,MAAMI,QAAM,GAAmDC,mBAAY,EAAE;;IAG7E,IAAID,QAAM,IAAIA,QAAM,CAAC,IAAI,KAAK,QAAQ,EAAE;QACvC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;;SACtD;AACN,QAAA,IAAI;YACH,OA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;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitConfirmation.d.ts","sourceRoot":"","sources":["../../../src/services/commitConfirmation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AA+F5D,eAAO,MAAM,kBAAkB,GAAU,eAAe,gBAAgB,EAAE,cAAc,YAAY,KAAG,OAAO,CAAC,MAAM,CAsCpH,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chalk = require('chalk');
|
|
4
|
+
var inquirer = require('inquirer');
|
|
5
|
+
var commitlintValidator = require('./commitlintValidator.js');
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @elsikora/typescript/naming-convention */
|
|
8
|
+
/* eslint-disable @elsikora/typescript/typedef */
|
|
9
|
+
/* eslint-disable @elsikora/typescript/no-unsafe-assignment */
|
|
10
|
+
const switcher = async (typeOfChange, promptContext, commitConfig) => {
|
|
11
|
+
const newCommitConfig = { ...commitConfig };
|
|
12
|
+
if (typeOfChange === "changeType") {
|
|
13
|
+
const { type } = await inquirer.prompt([
|
|
14
|
+
{
|
|
15
|
+
choices: promptContext.typeEnum?.map((type) => {
|
|
16
|
+
const desc = promptContext.typeDescriptions?.[type]?.description ?? "";
|
|
17
|
+
const emoji = promptContext.typeDescriptions?.[type]?.emoji ?? "";
|
|
18
|
+
// Remove emoji from description if it already appears at the beginning
|
|
19
|
+
let cleanDesc = desc;
|
|
20
|
+
if (emoji && desc.startsWith(emoji)) {
|
|
21
|
+
cleanDesc = desc.slice(emoji.length).trim();
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
name: type + (emoji ? " " + emoji : "") + ": " + cleanDesc,
|
|
25
|
+
value: type,
|
|
26
|
+
};
|
|
27
|
+
}) ?? [],
|
|
28
|
+
message: promptContext.typeDescription ?? "Select the type of change that you're committing:",
|
|
29
|
+
name: "type",
|
|
30
|
+
type: "list",
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
newCommitConfig.type = type;
|
|
34
|
+
}
|
|
35
|
+
if (typeOfChange === "changeScope") {
|
|
36
|
+
const { scope } = await inquirer.prompt([
|
|
37
|
+
{
|
|
38
|
+
message: promptContext.scopeDescription ?? 'What is the scope of this change:\n - Use component, directory or area of codebase\n - Use comma-separated list for multiple areas\n - Type "global" for project-wide changes\n',
|
|
39
|
+
name: "scope",
|
|
40
|
+
type: "input",
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
newCommitConfig.scope = scope;
|
|
44
|
+
}
|
|
45
|
+
if (typeOfChange === "changeMessage") {
|
|
46
|
+
const { message } = await inquirer.prompt([
|
|
47
|
+
{
|
|
48
|
+
message: promptContext.subject.description ?? "Write a short, imperative mood description of the change:",
|
|
49
|
+
name: "message",
|
|
50
|
+
type: "input",
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
newCommitConfig.subject = message;
|
|
54
|
+
}
|
|
55
|
+
if (typeOfChange === "changeDescription") {
|
|
56
|
+
const { descr } = await inquirer.prompt([
|
|
57
|
+
{
|
|
58
|
+
message: promptContext.body?.description ?? "Provide a longer description of the change",
|
|
59
|
+
name: "descr",
|
|
60
|
+
type: "input",
|
|
61
|
+
},
|
|
62
|
+
]);
|
|
63
|
+
newCommitConfig.body = descr;
|
|
64
|
+
}
|
|
65
|
+
if (typeOfChange === "markBreaking") {
|
|
66
|
+
if (newCommitConfig.isBreaking) {
|
|
67
|
+
newCommitConfig.isBreaking = false;
|
|
68
|
+
newCommitConfig.breakingBody = "";
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const { brakingMsg } = await inquirer.prompt([
|
|
72
|
+
{
|
|
73
|
+
message: "Provide a longer description of the breaking change. (Press enter to skip)",
|
|
74
|
+
name: "brakingMsg",
|
|
75
|
+
type: "input",
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
newCommitConfig.isBreaking = true;
|
|
79
|
+
newCommitConfig.breakingBody = brakingMsg;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return newCommitConfig;
|
|
83
|
+
};
|
|
84
|
+
const commitConfirmation = async (promptContext, commitConfig) => {
|
|
85
|
+
const { editCommit } = await inquirer.prompt([
|
|
86
|
+
{
|
|
87
|
+
choices: [
|
|
88
|
+
{ name: "Edit commit type", value: "changeType" },
|
|
89
|
+
{ name: "Edit commit scope", value: "changeScope" },
|
|
90
|
+
{ name: "Edit commit message", value: "changeMessage" },
|
|
91
|
+
{ name: "Edit commit description", value: "changeDescription" },
|
|
92
|
+
{ name: commitConfig.isBreaking ? "Unmark as containing braking changes" : "Mark as containing braking changes", value: "markBreaking" },
|
|
93
|
+
],
|
|
94
|
+
message: "What do you want to do with the commit?",
|
|
95
|
+
name: "editCommit",
|
|
96
|
+
type: "list",
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
const newCommitConfig = await switcher(editCommit, promptContext, commitConfig);
|
|
100
|
+
const newMessage = commitlintValidator.constructCommitMessage(newCommitConfig);
|
|
101
|
+
console.log(chalk.green("Commit edited successfully"));
|
|
102
|
+
// Show the generated message to the user
|
|
103
|
+
console.log("\n" + chalk.yellow("Edited commit message:"));
|
|
104
|
+
console.log(chalk.white("-----------------------------------"));
|
|
105
|
+
console.log(chalk.white(newMessage));
|
|
106
|
+
console.log(chalk.white("-----------------------------------\n"));
|
|
107
|
+
const { isConfirmCommit } = await inquirer.prompt([
|
|
108
|
+
{
|
|
109
|
+
default: true,
|
|
110
|
+
message: "Are you sure you want to proceed with the commit above?",
|
|
111
|
+
name: "isConfirmCommit",
|
|
112
|
+
type: "confirm",
|
|
113
|
+
},
|
|
114
|
+
]);
|
|
115
|
+
if (isConfirmCommit)
|
|
116
|
+
return newMessage;
|
|
117
|
+
else
|
|
118
|
+
return commitConfirmation(promptContext, newCommitConfig);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
exports.commitConfirmation = commitConfirmation;
|
|
122
|
+
//# sourceMappingURL=commitConfirmation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitConfirmation.js","sources":["../../../../src/services/commitConfirmation.ts"],"sourcesContent":[null],"names":["constructCommitMessage"],"mappings":";;;;;;AAAA;AACA;AACA;AASA,MAAM,QAAQ,GAAG,OAAO,YAAoB,EAAE,aAA+B,EAAE,YAA0B,KAA2B;AACnI,IAAA,MAAM,eAAe,GAAiB,EAAE,GAAG,YAAY,EAAE;AAEzD,IAAA,IAAI,YAAY,KAAK,YAAY,EAAE;QAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;AACtC,YAAA;gBACC,OAAO,EACN,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAY,KAAI;AAC5C,oBAAA,MAAM,IAAI,GAAW,aAAa,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,WAAW,IAAI,EAAE;AAC9E,oBAAA,MAAM,KAAK,GAAW,aAAa,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE;;oBAEzE,IAAI,SAAS,GAAW,IAAI;oBAE5B,IAAI,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;AACpC,wBAAA,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE;;oBAG5C,OAAO;AACN,wBAAA,IAAI,EAAE,IAAI,IAAI,KAAK,GAAG,GAAG,GAAG,KAAK,GAAG,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS;AAC1D,wBAAA,KAAK,EAAE,IAAI;qBACX;iBACD,CAAC,IAAI,EAAE;AACT,gBAAA,OAAO,EAAE,aAAa,CAAC,eAAe,IAAI,mDAAmD;AAC7F,gBAAA,IAAI,EAAE,MAAM;AACZ,gBAAA,IAAI,EAAE,MAAM;AACZ,aAAA;AACD,SAAA,CAAC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AG,KAAK,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAEjE,MAAM,EAAE,eAAe,EAAE,GAAiC,MAAM,QAAQ,CAAC,MAAM,CAAC;AAC/E,QAAA;AACC,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,OAAO,EAAE,yDAAyD;AAClE,YAAA,IAAI,EAAE,iBAAiB;AACvB,YAAA,IAAI,EAAE,SAAS;AACf,SAAA;AACD,KAAA,CAAC;AAEF,IAAA,IAAI,eAAe;AAAE,QAAA,OAAO,UAAU;;AACjC,QAAA,OAAO,kBAAkB,CAAC,aAAa,EAAE,eAAe,CAAC;AAC/D;;;;"}
|
|
@@ -3,6 +3,12 @@ interface ValidationResult {
|
|
|
3
3
|
errors?: string;
|
|
4
4
|
isValid: boolean;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Constructs a commit message from a CommitConfig object
|
|
8
|
+
* @param commitConfig The commit configuration
|
|
9
|
+
* @returns The formatted commit message
|
|
10
|
+
*/
|
|
11
|
+
export declare function constructCommitMessage(commitConfig: CommitConfig): string;
|
|
6
12
|
/**
|
|
7
13
|
* Validates a commit message and retries with LLM if there are errors
|
|
8
14
|
* @param commitConfig The original commit configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitlintValidator.d.ts","sourceRoot":"","sources":["../../../src/services/commitlintValidator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commitlintValidator.d.ts","sourceRoot":"","sources":["../../../src/services/commitlintValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAY5D,UAAU,gBAAgB;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CA+BzE;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAqErI;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiB7F"}
|
|
@@ -6,6 +6,37 @@ var chalk = require('chalk');
|
|
|
6
6
|
var index = require('./llm/index.js');
|
|
7
7
|
|
|
8
8
|
const execAsync = node_util.promisify(node_child_process.exec);
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a commit message from a CommitConfig object
|
|
11
|
+
* @param commitConfig The commit configuration
|
|
12
|
+
* @returns The formatted commit message
|
|
13
|
+
*/
|
|
14
|
+
function constructCommitMessage(commitConfig) {
|
|
15
|
+
const type = commitConfig.type;
|
|
16
|
+
const scope = commitConfig.scope ? `(${commitConfig.scope})` : "";
|
|
17
|
+
const subject = commitConfig.subject;
|
|
18
|
+
const header = `${type}${scope}: ${subject}`;
|
|
19
|
+
// Body with optional breaking change
|
|
20
|
+
let body = "";
|
|
21
|
+
if (commitConfig.isBreaking) {
|
|
22
|
+
body = `BREAKING CHANGE: ${commitConfig.breakingBody || "This commit introduces breaking changes."}\n\n`;
|
|
23
|
+
}
|
|
24
|
+
if (commitConfig.body) {
|
|
25
|
+
body += commitConfig.body;
|
|
26
|
+
}
|
|
27
|
+
// Footer with issue references
|
|
28
|
+
let footer = "";
|
|
29
|
+
if (commitConfig.issues && commitConfig.issues.length > 0) {
|
|
30
|
+
footer = `Issues: ${commitConfig.issues.join(", ")}`;
|
|
31
|
+
}
|
|
32
|
+
if (commitConfig.references && commitConfig.references.length > 0) {
|
|
33
|
+
if (footer)
|
|
34
|
+
footer += "\n";
|
|
35
|
+
footer += `References: ${commitConfig.references.join(", ")}`;
|
|
36
|
+
}
|
|
37
|
+
// Combine all parts
|
|
38
|
+
return [header, body, footer].filter(Boolean).join("\n\n");
|
|
39
|
+
}
|
|
9
40
|
/**
|
|
10
41
|
* Validates a commit message and retries with LLM if there are errors
|
|
11
42
|
* @param commitConfig The original commit configuration
|
|
@@ -87,37 +118,6 @@ async function validateWithCommitlint(commitMessage) {
|
|
|
87
118
|
};
|
|
88
119
|
}
|
|
89
120
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Constructs a commit message from a CommitConfig object
|
|
92
|
-
* @param commitConfig The commit configuration
|
|
93
|
-
* @returns The formatted commit message
|
|
94
|
-
*/
|
|
95
|
-
function constructCommitMessage(commitConfig) {
|
|
96
|
-
const type = commitConfig.type;
|
|
97
|
-
const scope = commitConfig.scope ? `(${commitConfig.scope})` : "";
|
|
98
|
-
const subject = commitConfig.subject;
|
|
99
|
-
const header = `${type}${scope}: ${subject}`;
|
|
100
|
-
// Body with optional breaking change
|
|
101
|
-
let body = "";
|
|
102
|
-
if (commitConfig.isBreaking) {
|
|
103
|
-
body = `BREAKING CHANGE: ${commitConfig.breakingBody ?? "This commit introduces breaking changes."}\n\n`;
|
|
104
|
-
}
|
|
105
|
-
if (commitConfig.body) {
|
|
106
|
-
body += commitConfig.body;
|
|
107
|
-
}
|
|
108
|
-
// Footer with issue references
|
|
109
|
-
let footer = "";
|
|
110
|
-
if (commitConfig.issues && commitConfig.issues.length > 0) {
|
|
111
|
-
footer = `Issues: ${commitConfig.issues.join(", ")}`;
|
|
112
|
-
}
|
|
113
|
-
if (commitConfig.references && commitConfig.references.length > 0) {
|
|
114
|
-
if (footer)
|
|
115
|
-
footer += "\n";
|
|
116
|
-
footer += `References: ${commitConfig.references.join(", ")}`;
|
|
117
|
-
}
|
|
118
|
-
// Combine all parts
|
|
119
|
-
return [header, body, footer].filter(Boolean).join("\n\n");
|
|
120
|
-
}
|
|
121
121
|
/**
|
|
122
122
|
* Sends a commit message to the LLM for correction with provided errors
|
|
123
123
|
* @param commitConfig The original commit configuration
|
|
@@ -140,6 +140,7 @@ async function fixCommitMessageWithLLM(commitConfig, errors, promptContext, prev
|
|
|
140
140
|
return await index.generateCommitMessage(enhancedContext);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
exports.constructCommitMessage = constructCommitMessage;
|
|
143
144
|
exports.validateAndFixCommitMessage = validateAndFixCommitMessage;
|
|
144
145
|
exports.validateWithCommitlint = validateWithCommitlint;
|
|
145
146
|
//# sourceMappingURL=commitlintValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitlintValidator.js","sources":["../../../../src/services/commitlintValidator.ts"],"sourcesContent":[null],"names":["promisify","exec","generateCommitMessage"],"mappings":";;;;;;;AAWA,MAAM,SAAS,GAAiCA,mBAAS,CAACC,uBAAI,CAAC;AAQ/D;;;;;AAKG;AACI,eAAe,2BAA2B,CAAC,YAA0B,EAAE,aAA+B,EAAA;;AAE5G,IAAA,MAAM,aAAa,GAAW,sBAAsB,CAAC,YAAY,CAAC;;AAGlE,IAAA,MAAM,UAAU,GAAqB,MAAM,sBAAsB,CAAC,aAAa,CAAC;;AAGhF,IAAA,IAAI,UAAU,CAAC,OAAO,EAAE;AACvB,QAAA,OAAO,aAAa;;;IAIrB,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,MAAM,EAAE;QAC7C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,wDAAwD,CAAC,CAAC;QACnF,MAAM,WAAW,GAAW,CAAC;QAC7B,IAAI,aAAa,GAAiB,YAAY;QAC9C,MAAM,SAAS,GAAkB,EAAE;;;AAInC,QAAA,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,OAAO,EAAE,EAAE;;AAEv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AAM,CAAC,0CAA0C,CAAC,CAAC;QAErE,OAAO,IAAI,CAAC;;;AAIb,IAAA,OAAO,aAAa;AACrB;AAEA;;;;AAIG;AACI,eAAe,sBAAsB,CAAC,aAAqB,EAAA;AACjE,IAAA,IAAI;;AAEH,QAAA,MAAM,GAAG,GAAW,CAAS,MAAA,EAAA,aAAa,oBAAoB;;AAE9D,QAAA,MAAM,SAAS,CAAC,GAAG,CAAC;AAEpB,QAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;;IACvB,OAAO,KAAK,EAAE;;QAEf,MAAM,UAAU,GAA2D,KAA+D;QAE1I,OAAO;YACN,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,OAAO;AACpE,YAAA,OAAO,EAAE,KAAK;SACd;;AAEH;AAEA
|
|
1
|
+
{"version":3,"file":"commitlintValidator.js","sources":["../../../../src/services/commitlintValidator.ts"],"sourcesContent":[null],"names":["promisify","exec","generateCommitMessage"],"mappings":";;;;;;;AAWA,MAAM,SAAS,GAAiCA,mBAAS,CAACC,uBAAI,CAAC;AAQ/D;;;;AAIG;AACG,SAAU,sBAAsB,CAAC,YAA0B,EAAA;AAChE,IAAA,MAAM,IAAI,GAAW,YAAY,CAAC,IAAI;AACtC,IAAA,MAAM,KAAK,GAAW,YAAY,CAAC,KAAK,GAAG,CAAI,CAAA,EAAA,YAAY,CAAC,KAAK,CAAA,CAAA,CAAG,GAAG,EAAE;AACzE,IAAA,MAAM,OAAO,GAAW,YAAY,CAAC,OAAO;IAC5C,MAAM,MAAM,GAAW,CAAG,EAAA,IAAI,GAAG,KAAK,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE;;IAGpD,IAAI,IAAI,GAAW,EAAE;AAErB,IAAA,IAAI,YAAY,CAAC,UAAU,EAAE;QAC5B,IAAI,GAAG,oBAAoB,YAAY,CAAC,YAAY,IAAI,0CAA0C,MAAM;;AAGzG,IAAA,IAAI,YAAY,CAAC,IA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AC,CAAC;;AAG9H,IAAA,OAAO,MAAMC,2BAAqB,CAAC,eAAe,CAAC;AACpD;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../src/Process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAa1D,wBAA8B,OAAO,CACpC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE;IACT,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D,GACC,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../src/Process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAa1D,wBAA8B,OAAO,CACpC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE;IACT,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D,GACC,OAAO,CAAC,MAAM,CAAC,CAsMjB"}
|
package/dist/esm/Process.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
+
import { commitConfirmation } from './services/commitConfirmation.js';
|
|
2
3
|
import { extractLLMPromptContext } from './services/commitlintConfig.js';
|
|
3
4
|
import { validateAndFixCommitMessage } from './services/commitlintValidator.js';
|
|
4
5
|
import { selectLLMProvider, generateCommitMessage } from './services/llm/index.js';
|
|
@@ -49,8 +50,10 @@ async function Process(rules, prompts, inquirer) {
|
|
|
49
50
|
return validatedCommitMessage;
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
53
|
+
console.log(chalk.yellow("AI generated message rejected. Switching to commit edit mode."));
|
|
54
|
+
const confirmedCommitMessage = await commitConfirmation(promptContext, { ...commitConfig, scope: extractCommitScope(validatedCommitMessage) });
|
|
55
|
+
return confirmedCommitMessage;
|
|
52
56
|
// If user rejects the generated message, fall through to the manual entry option
|
|
53
|
-
console.log(chalk.yellow("AI-generated message rejected. Switching to manual commit entry."));
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -156,6 +159,14 @@ async function Process(rules, prompts, inquirer) {
|
|
|
156
159
|
}
|
|
157
160
|
return commitMessage;
|
|
158
161
|
}
|
|
162
|
+
function extractCommitScope(commitMessage) {
|
|
163
|
+
const scopeRegex = /^[^(\n]+(\([^)\n]+\))?:/;
|
|
164
|
+
const match = scopeRegex.exec(commitMessage);
|
|
165
|
+
if (match?.[1]) {
|
|
166
|
+
return match[1].slice(1, -1);
|
|
167
|
+
}
|
|
168
|
+
return "";
|
|
169
|
+
}
|
|
159
170
|
|
|
160
171
|
export { Process as default };
|
|
161
172
|
//# sourceMappingURL=Process.js.map
|
package/dist/esm/Process.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Process.js","sources":["../../../src/Process.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Process.js","sources":["../../../src/Process.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AAce,eAAe,OAAO,CACpC,KAAqB,EACrB,OAAyB,EACzB,QAEC,EAAA;IAGD,eAAe,CAAC,OAAO,CAAC;;AAGxB,IAAA,MAAM,iBAAiB,CAAC,QAAQ,CAAC;;IAGjC,MAAM,aAAa,GAAqB,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC;;AAG/E,IAA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AU,CAAC,IAAI,CAAC,aAAa,CAAC;AAEpE,IAAA,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;AACf,QAAA,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;;AAG7B,IAAA,OAAO,EAAE;AACV;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitConfirmation.d.ts","sourceRoot":"","sources":["../../../src/services/commitConfirmation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AA+F5D,eAAO,MAAM,kBAAkB,GAAU,eAAe,gBAAgB,EAAE,cAAc,YAAY,KAAG,OAAO,CAAC,MAAM,CAsCpH,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import { constructCommitMessage } from './commitlintValidator.js';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable @elsikora/typescript/naming-convention */
|
|
6
|
+
/* eslint-disable @elsikora/typescript/typedef */
|
|
7
|
+
/* eslint-disable @elsikora/typescript/no-unsafe-assignment */
|
|
8
|
+
const switcher = async (typeOfChange, promptContext, commitConfig) => {
|
|
9
|
+
const newCommitConfig = { ...commitConfig };
|
|
10
|
+
if (typeOfChange === "changeType") {
|
|
11
|
+
const { type } = await inquirer.prompt([
|
|
12
|
+
{
|
|
13
|
+
choices: promptContext.typeEnum?.map((type) => {
|
|
14
|
+
const desc = promptContext.typeDescriptions?.[type]?.description ?? "";
|
|
15
|
+
const emoji = promptContext.typeDescriptions?.[type]?.emoji ?? "";
|
|
16
|
+
// Remove emoji from description if it already appears at the beginning
|
|
17
|
+
let cleanDesc = desc;
|
|
18
|
+
if (emoji && desc.startsWith(emoji)) {
|
|
19
|
+
cleanDesc = desc.slice(emoji.length).trim();
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
name: type + (emoji ? " " + emoji : "") + ": " + cleanDesc,
|
|
23
|
+
value: type,
|
|
24
|
+
};
|
|
25
|
+
}) ?? [],
|
|
26
|
+
message: promptContext.typeDescription ?? "Select the type of change that you're committing:",
|
|
27
|
+
name: "type",
|
|
28
|
+
type: "list",
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
newCommitConfig.type = type;
|
|
32
|
+
}
|
|
33
|
+
if (typeOfChange === "changeScope") {
|
|
34
|
+
const { scope } = await inquirer.prompt([
|
|
35
|
+
{
|
|
36
|
+
message: promptContext.scopeDescription ?? 'What is the scope of this change:\n - Use component, directory or area of codebase\n - Use comma-separated list for multiple areas\n - Type "global" for project-wide changes\n',
|
|
37
|
+
name: "scope",
|
|
38
|
+
type: "input",
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
newCommitConfig.scope = scope;
|
|
42
|
+
}
|
|
43
|
+
if (typeOfChange === "changeMessage") {
|
|
44
|
+
const { message } = await inquirer.prompt([
|
|
45
|
+
{
|
|
46
|
+
message: promptContext.subject.description ?? "Write a short, imperative mood description of the change:",
|
|
47
|
+
name: "message",
|
|
48
|
+
type: "input",
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
newCommitConfig.subject = message;
|
|
52
|
+
}
|
|
53
|
+
if (typeOfChange === "changeDescription") {
|
|
54
|
+
const { descr } = await inquirer.prompt([
|
|
55
|
+
{
|
|
56
|
+
message: promptContext.body?.description ?? "Provide a longer description of the change",
|
|
57
|
+
name: "descr",
|
|
58
|
+
type: "input",
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
newCommitConfig.body = descr;
|
|
62
|
+
}
|
|
63
|
+
if (typeOfChange === "markBreaking") {
|
|
64
|
+
if (newCommitConfig.isBreaking) {
|
|
65
|
+
newCommitConfig.isBreaking = false;
|
|
66
|
+
newCommitConfig.breakingBody = "";
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const { brakingMsg } = await inquirer.prompt([
|
|
70
|
+
{
|
|
71
|
+
message: "Provide a longer description of the breaking change. (Press enter to skip)",
|
|
72
|
+
name: "brakingMsg",
|
|
73
|
+
type: "input",
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
newCommitConfig.isBreaking = true;
|
|
77
|
+
newCommitConfig.breakingBody = brakingMsg;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return newCommitConfig;
|
|
81
|
+
};
|
|
82
|
+
const commitConfirmation = async (promptContext, commitConfig) => {
|
|
83
|
+
const { editCommit } = await inquirer.prompt([
|
|
84
|
+
{
|
|
85
|
+
choices: [
|
|
86
|
+
{ name: "Edit commit type", value: "changeType" },
|
|
87
|
+
{ name: "Edit commit scope", value: "changeScope" },
|
|
88
|
+
{ name: "Edit commit message", value: "changeMessage" },
|
|
89
|
+
{ name: "Edit commit description", value: "changeDescription" },
|
|
90
|
+
{ name: commitConfig.isBreaking ? "Unmark as containing braking changes" : "Mark as containing braking changes", value: "markBreaking" },
|
|
91
|
+
],
|
|
92
|
+
message: "What do you want to do with the commit?",
|
|
93
|
+
name: "editCommit",
|
|
94
|
+
type: "list",
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
const newCommitConfig = await switcher(editCommit, promptContext, commitConfig);
|
|
98
|
+
const newMessage = constructCommitMessage(newCommitConfig);
|
|
99
|
+
console.log(chalk.green("Commit edited successfully"));
|
|
100
|
+
// Show the generated message to the user
|
|
101
|
+
console.log("\n" + chalk.yellow("Edited commit message:"));
|
|
102
|
+
console.log(chalk.white("-----------------------------------"));
|
|
103
|
+
console.log(chalk.white(newMessage));
|
|
104
|
+
console.log(chalk.white("-----------------------------------\n"));
|
|
105
|
+
const { isConfirmCommit } = await inquirer.prompt([
|
|
106
|
+
{
|
|
107
|
+
default: true,
|
|
108
|
+
message: "Are you sure you want to proceed with the commit above?",
|
|
109
|
+
name: "isConfirmCommit",
|
|
110
|
+
type: "confirm",
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
if (isConfirmCommit)
|
|
114
|
+
return newMessage;
|
|
115
|
+
else
|
|
116
|
+
return commitConfirmation(promptContext, newCommitConfig);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { commitConfirmation };
|
|
120
|
+
//# sourceMappingURL=commitConfirmation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitConfirmation.js","sources":["../../../../src/services/commitConfirmation.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;AACA;AACA;AASA,MAAM,QAAQ,GAAG,OAAO,YAAoB,EAAE,aAA+B,EAAE,YAA0B,KAA2B;AACnI,IAAA,MAAM,eAAe,GAAiB,EAAE,GAAG,YAAY,EAAE;AAEzD,IAAA,IAAI,YAAY,KAAK,YAAY,EAAE;QAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;AACtC,YAAA;gBACC,OAAO,EACN,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAY,KAAI;AAC5C,oBAAA,MAAM,IAAI,GAAW,aAAa,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,WAAW,IAAI,EAAE;AAC9E,oBAAA,MAAM,KAAK,GAAW,aAAa,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE;;oBAEzE,IAAI,SAAS,GAAW,IAAI;oBAE5B,IAAI,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;AACpC,wBAAA,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE;;oBAG5C,OAAO;AACN,wBAAA,IAAI,EAAE,IAAI,IAAI,KAAK,GAAG,GAAG,GAAG,KAAK,GAAG,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS;AAC1D,wBAAA,KAAK,EAAE,IAAI;qBACX;iBACD,CAAC,IAAI,EAAE;AACT,gBAAA,O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AAe,CAAC;IAE1D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;;AAGtD,IAAA,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAEjE,MAAM,EAAE,eAAe,EAAE,GAAiC,MAAM,QAAQ,CAAC,MAAM,CAAC;AAC/E,QAAA;AACC,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,OAAO,EAAE,yDAAyD;AAClE,YAAA,IAAI,EAAE,iBAAiB;AACvB,YAAA,IAAI,EAAE,SAAS;AACf,SAAA;AACD,KAAA,CAAC;AAEF,IAAA,IAAI,eAAe;AAAE,QAAA,OAAO,UAAU;;AACjC,QAAA,OAAO,kBAAkB,CAAC,aAAa,EAAE,eAAe,CAAC;AAC/D;;;;"}
|
|
@@ -3,6 +3,12 @@ interface ValidationResult {
|
|
|
3
3
|
errors?: string;
|
|
4
4
|
isValid: boolean;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Constructs a commit message from a CommitConfig object
|
|
8
|
+
* @param commitConfig The commit configuration
|
|
9
|
+
* @returns The formatted commit message
|
|
10
|
+
*/
|
|
11
|
+
export declare function constructCommitMessage(commitConfig: CommitConfig): string;
|
|
6
12
|
/**
|
|
7
13
|
* Validates a commit message and retries with LLM if there are errors
|
|
8
14
|
* @param commitConfig The original commit configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitlintValidator.d.ts","sourceRoot":"","sources":["../../../src/services/commitlintValidator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commitlintValidator.d.ts","sourceRoot":"","sources":["../../../src/services/commitlintValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAY5D,UAAU,gBAAgB;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CA+BzE;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAqErI;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiB7F"}
|
|
@@ -4,6 +4,37 @@ import chalk from 'chalk';
|
|
|
4
4
|
import { generateCommitMessage } from './llm/index.js';
|
|
5
5
|
|
|
6
6
|
const execAsync = promisify(exec);
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a commit message from a CommitConfig object
|
|
9
|
+
* @param commitConfig The commit configuration
|
|
10
|
+
* @returns The formatted commit message
|
|
11
|
+
*/
|
|
12
|
+
function constructCommitMessage(commitConfig) {
|
|
13
|
+
const type = commitConfig.type;
|
|
14
|
+
const scope = commitConfig.scope ? `(${commitConfig.scope})` : "";
|
|
15
|
+
const subject = commitConfig.subject;
|
|
16
|
+
const header = `${type}${scope}: ${subject}`;
|
|
17
|
+
// Body with optional breaking change
|
|
18
|
+
let body = "";
|
|
19
|
+
if (commitConfig.isBreaking) {
|
|
20
|
+
body = `BREAKING CHANGE: ${commitConfig.breakingBody || "This commit introduces breaking changes."}\n\n`;
|
|
21
|
+
}
|
|
22
|
+
if (commitConfig.body) {
|
|
23
|
+
body += commitConfig.body;
|
|
24
|
+
}
|
|
25
|
+
// Footer with issue references
|
|
26
|
+
let footer = "";
|
|
27
|
+
if (commitConfig.issues && commitConfig.issues.length > 0) {
|
|
28
|
+
footer = `Issues: ${commitConfig.issues.join(", ")}`;
|
|
29
|
+
}
|
|
30
|
+
if (commitConfig.references && commitConfig.references.length > 0) {
|
|
31
|
+
if (footer)
|
|
32
|
+
footer += "\n";
|
|
33
|
+
footer += `References: ${commitConfig.references.join(", ")}`;
|
|
34
|
+
}
|
|
35
|
+
// Combine all parts
|
|
36
|
+
return [header, body, footer].filter(Boolean).join("\n\n");
|
|
37
|
+
}
|
|
7
38
|
/**
|
|
8
39
|
* Validates a commit message and retries with LLM if there are errors
|
|
9
40
|
* @param commitConfig The original commit configuration
|
|
@@ -85,37 +116,6 @@ async function validateWithCommitlint(commitMessage) {
|
|
|
85
116
|
};
|
|
86
117
|
}
|
|
87
118
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Constructs a commit message from a CommitConfig object
|
|
90
|
-
* @param commitConfig The commit configuration
|
|
91
|
-
* @returns The formatted commit message
|
|
92
|
-
*/
|
|
93
|
-
function constructCommitMessage(commitConfig) {
|
|
94
|
-
const type = commitConfig.type;
|
|
95
|
-
const scope = commitConfig.scope ? `(${commitConfig.scope})` : "";
|
|
96
|
-
const subject = commitConfig.subject;
|
|
97
|
-
const header = `${type}${scope}: ${subject}`;
|
|
98
|
-
// Body with optional breaking change
|
|
99
|
-
let body = "";
|
|
100
|
-
if (commitConfig.isBreaking) {
|
|
101
|
-
body = `BREAKING CHANGE: ${commitConfig.breakingBody ?? "This commit introduces breaking changes."}\n\n`;
|
|
102
|
-
}
|
|
103
|
-
if (commitConfig.body) {
|
|
104
|
-
body += commitConfig.body;
|
|
105
|
-
}
|
|
106
|
-
// Footer with issue references
|
|
107
|
-
let footer = "";
|
|
108
|
-
if (commitConfig.issues && commitConfig.issues.length > 0) {
|
|
109
|
-
footer = `Issues: ${commitConfig.issues.join(", ")}`;
|
|
110
|
-
}
|
|
111
|
-
if (commitConfig.references && commitConfig.references.length > 0) {
|
|
112
|
-
if (footer)
|
|
113
|
-
footer += "\n";
|
|
114
|
-
footer += `References: ${commitConfig.references.join(", ")}`;
|
|
115
|
-
}
|
|
116
|
-
// Combine all parts
|
|
117
|
-
return [header, body, footer].filter(Boolean).join("\n\n");
|
|
118
|
-
}
|
|
119
119
|
/**
|
|
120
120
|
* Sends a commit message to the LLM for correction with provided errors
|
|
121
121
|
* @param commitConfig The original commit configuration
|
|
@@ -138,5 +138,5 @@ async function fixCommitMessageWithLLM(commitConfig, errors, promptContext, prev
|
|
|
138
138
|
return await generateCommitMessage(enhancedContext);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
export { validateAndFixCommitMessage, validateWithCommitlint };
|
|
141
|
+
export { constructCommitMessage, validateAndFixCommitMessage, validateWithCommitlint };
|
|
142
142
|
//# sourceMappingURL=commitlintValidator.js.map
|