@elsikora/commitizen-plugin-commitlint-ai 1.0.0-dev.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/LICENSE +21 -0
- package/README.md +150 -0
- package/dist/cjs/ManualProcess.d.ts +6 -0
- package/dist/cjs/ManualProcess.d.ts.map +1 -0
- package/dist/cjs/ManualProcess.js +111 -0
- package/dist/cjs/ManualProcess.js.map +1 -0
- package/dist/cjs/Process.d.ts +6 -0
- package/dist/cjs/Process.d.ts.map +1 -0
- package/dist/cjs/Process.js +165 -0
- package/dist/cjs/Process.js.map +1 -0
- package/dist/cjs/Question.d.ts +46 -0
- package/dist/cjs/Question.d.ts.map +1 -0
- package/dist/cjs/SectionBody.d.ts +4 -0
- package/dist/cjs/SectionBody.d.ts.map +1 -0
- package/dist/cjs/SectionFooter.d.ts +13 -0
- package/dist/cjs/SectionFooter.d.ts.map +1 -0
- package/dist/cjs/SectionHeader.d.ts +15 -0
- package/dist/cjs/SectionHeader.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +14 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +70 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/services/commitlintConfig.d.ts +4 -0
- package/dist/cjs/services/commitlintConfig.d.ts.map +1 -0
- package/dist/cjs/services/commitlintConfig.js +198 -0
- package/dist/cjs/services/commitlintConfig.js.map +1 -0
- package/dist/cjs/services/commitlintValidator.d.ts +20 -0
- package/dist/cjs/services/commitlintValidator.d.ts.map +1 -0
- package/dist/cjs/services/commitlintValidator.js +145 -0
- package/dist/cjs/services/commitlintValidator.js.map +1 -0
- package/dist/cjs/services/getRuleQuestionConfig.d.ts +4 -0
- package/dist/cjs/services/getRuleQuestionConfig.d.ts.map +1 -0
- package/dist/cjs/services/llm/anthropic.d.ts +3 -0
- package/dist/cjs/services/llm/anthropic.d.ts.map +1 -0
- package/dist/cjs/services/llm/anthropic.js +118 -0
- package/dist/cjs/services/llm/anthropic.js.map +1 -0
- package/dist/cjs/services/llm/config.d.ts +5 -0
- package/dist/cjs/services/llm/config.d.ts.map +1 -0
- package/dist/cjs/services/llm/config.js +181 -0
- package/dist/cjs/services/llm/config.js.map +1 -0
- package/dist/cjs/services/llm/index.d.ts +6 -0
- package/dist/cjs/services/llm/index.d.ts.map +1 -0
- package/dist/cjs/services/llm/index.js +398 -0
- package/dist/cjs/services/llm/index.js.map +1 -0
- package/dist/cjs/services/llm/models.d.ts +34 -0
- package/dist/cjs/services/llm/models.d.ts.map +1 -0
- package/dist/cjs/services/llm/models.js +65 -0
- package/dist/cjs/services/llm/models.js.map +1 -0
- package/dist/cjs/services/llm/openai.d.ts +3 -0
- package/dist/cjs/services/llm/openai.d.ts.map +1 -0
- package/dist/cjs/services/llm/openai.js +111 -0
- package/dist/cjs/services/llm/openai.js.map +1 -0
- package/dist/cjs/services/llm/types.d.ts +71 -0
- package/dist/cjs/services/llm/types.d.ts.map +1 -0
- package/dist/cjs/store/defaultPromptConfigs.d.ts +33 -0
- package/dist/cjs/store/defaultPromptConfigs.d.ts.map +1 -0
- package/dist/cjs/store/defaultPromptConfigs.js +39 -0
- package/dist/cjs/store/defaultPromptConfigs.js.map +1 -0
- package/dist/cjs/store/prompts.d.ts +6 -0
- package/dist/cjs/store/prompts.d.ts.map +1 -0
- package/dist/cjs/store/prompts.js +40 -0
- package/dist/cjs/store/prompts.js.map +1 -0
- package/dist/cjs/store/rules.d.ts +7 -0
- package/dist/cjs/store/rules.d.ts.map +1 -0
- package/dist/cjs/types.d.ts +3 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/utils/case-function.d.ts +9 -0
- package/dist/cjs/utils/case-function.d.ts.map +1 -0
- package/dist/cjs/utils/full-stop-function.d.ts +9 -0
- package/dist/cjs/utils/full-stop-function.d.ts.map +1 -0
- package/dist/cjs/utils/leading-blank-function.d.ts +8 -0
- package/dist/cjs/utils/leading-blank-function.d.ts.map +1 -0
- package/dist/cjs/utils/rules.d.ts +26 -0
- package/dist/cjs/utils/rules.d.ts.map +1 -0
- package/dist/esm/ManualProcess.d.ts +6 -0
- package/dist/esm/ManualProcess.d.ts.map +1 -0
- package/dist/esm/ManualProcess.js +107 -0
- package/dist/esm/ManualProcess.js.map +1 -0
- package/dist/esm/Process.d.ts +6 -0
- package/dist/esm/Process.d.ts.map +1 -0
- package/dist/esm/Process.js +161 -0
- package/dist/esm/Process.js.map +1 -0
- package/dist/esm/Question.d.ts +46 -0
- package/dist/esm/Question.d.ts.map +1 -0
- package/dist/esm/SectionBody.d.ts +4 -0
- package/dist/esm/SectionBody.d.ts.map +1 -0
- package/dist/esm/SectionFooter.d.ts +13 -0
- package/dist/esm/SectionFooter.d.ts.map +1 -0
- package/dist/esm/SectionHeader.d.ts +15 -0
- package/dist/esm/SectionHeader.d.ts.map +1 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +67 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/services/commitlintConfig.d.ts +4 -0
- package/dist/esm/services/commitlintConfig.d.ts.map +1 -0
- package/dist/esm/services/commitlintConfig.js +196 -0
- package/dist/esm/services/commitlintConfig.js.map +1 -0
- package/dist/esm/services/commitlintValidator.d.ts +20 -0
- package/dist/esm/services/commitlintValidator.d.ts.map +1 -0
- package/dist/esm/services/commitlintValidator.js +142 -0
- package/dist/esm/services/commitlintValidator.js.map +1 -0
- package/dist/esm/services/getRuleQuestionConfig.d.ts +4 -0
- package/dist/esm/services/getRuleQuestionConfig.d.ts.map +1 -0
- package/dist/esm/services/llm/anthropic.d.ts +3 -0
- package/dist/esm/services/llm/anthropic.d.ts.map +1 -0
- package/dist/esm/services/llm/anthropic.js +116 -0
- package/dist/esm/services/llm/anthropic.js.map +1 -0
- package/dist/esm/services/llm/config.d.ts +5 -0
- package/dist/esm/services/llm/config.d.ts.map +1 -0
- package/dist/esm/services/llm/config.js +178 -0
- package/dist/esm/services/llm/config.js.map +1 -0
- package/dist/esm/services/llm/index.d.ts +6 -0
- package/dist/esm/services/llm/index.d.ts.map +1 -0
- package/dist/esm/services/llm/index.js +393 -0
- package/dist/esm/services/llm/index.js.map +1 -0
- package/dist/esm/services/llm/models.d.ts +34 -0
- package/dist/esm/services/llm/models.d.ts.map +1 -0
- package/dist/esm/services/llm/models.js +60 -0
- package/dist/esm/services/llm/models.js.map +1 -0
- package/dist/esm/services/llm/openai.d.ts +3 -0
- package/dist/esm/services/llm/openai.d.ts.map +1 -0
- package/dist/esm/services/llm/openai.js +109 -0
- package/dist/esm/services/llm/openai.js.map +1 -0
- package/dist/esm/services/llm/types.d.ts +71 -0
- package/dist/esm/services/llm/types.d.ts.map +1 -0
- package/dist/esm/store/defaultPromptConfigs.d.ts +33 -0
- package/dist/esm/store/defaultPromptConfigs.d.ts.map +1 -0
- package/dist/esm/store/defaultPromptConfigs.js +35 -0
- package/dist/esm/store/defaultPromptConfigs.js.map +1 -0
- package/dist/esm/store/prompts.d.ts +6 -0
- package/dist/esm/store/prompts.d.ts.map +1 -0
- package/dist/esm/store/prompts.js +38 -0
- package/dist/esm/store/prompts.js.map +1 -0
- package/dist/esm/store/rules.d.ts +7 -0
- package/dist/esm/store/rules.d.ts.map +1 -0
- package/dist/esm/types.d.ts +3 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/utils/case-function.d.ts +9 -0
- package/dist/esm/utils/case-function.d.ts.map +1 -0
- package/dist/esm/utils/full-stop-function.d.ts +9 -0
- package/dist/esm/utils/full-stop-function.d.ts.map +1 -0
- package/dist/esm/utils/leading-blank-function.d.ts +8 -0
- package/dist/esm/utils/leading-blank-function.d.ts.map +1 -0
- package/dist/esm/utils/rules.d.ts +26 -0
- package/dist/esm/utils/rules.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.cjs +6 -0
- package/package.json +101 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ElsiKora
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://6jft62zmy9nx2oea.public.blob.vercel-storage.com/commitizen-plugin-commitlint-ai-NDrywOvLY7r3a2w5qeC1bzTAaBoAtI.png" width="500" alt="project-logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Commitizen Plugin Commitlint AI 🤖</h1>
|
|
6
|
+
<p align="center"><em>AI-powered Commitizen adapter that generates conventional commits with Commitlint integration</em></p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a aria-label="ElsiKora logo" href="https://elsikora.com">
|
|
10
|
+
<img src="https://img.shields.io/badge/MADE%20BY%20ElsiKora-333333.svg?style=for-the-badge" alt="ElsiKora">
|
|
11
|
+
</a> <img src="https://img.shields.io/badge/version-blue.svg?style=for-the-badge&logo=npm&logoColor=white" alt="version"> <img src="https://img.shields.io/badge/typescript-blue.svg?style=for-the-badge&logo=typescript&logoColor=white" alt="typescript"> <img src="https://img.shields.io/badge/license-green.svg?style=for-the-badge&logo=license&logoColor=white" alt="license"> <img src="https://img.shields.io/badge/commitizen-green.svg?style=for-the-badge&logo=commitizen&logoColor=white" alt="commitizen"> <img src="https://img.shields.io/badge/commitlint-red.svg?style=for-the-badge&logo=commitlint&logoColor=white" alt="commitlint">
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
## 📚 Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Description](#-description)
|
|
17
|
+
- [Features](#-features)
|
|
18
|
+
- [Installation](#-installation)
|
|
19
|
+
- [Usage](#-usage)
|
|
20
|
+
- [Roadmap](#-roadmap)
|
|
21
|
+
- [FAQ](#-faq)
|
|
22
|
+
- [License](#-license)
|
|
23
|
+
|
|
24
|
+
## 📖 Description
|
|
25
|
+
|
|
26
|
+
This plugin enhances your Git workflow by combining the power of AI with conventional commit standards. It intelligently analyzes your code changes and generates meaningful commit messages that follow your project's commitlint rules. Whether you're working solo or in a team, this tool helps maintain consistent, high-quality commit history while reducing the cognitive load of writing commit messages.
|
|
27
|
+
|
|
28
|
+
## 🚀 Features
|
|
29
|
+
|
|
30
|
+
- ✨ **AI-powered commit message generation using OpenAI or Anthropic models**
|
|
31
|
+
- ✨ **Full integration with Commitlint rules and configuration**
|
|
32
|
+
- ✨ **Support for both manual and automatic commit modes**
|
|
33
|
+
- ✨ **Smart scope detection based on changed files**
|
|
34
|
+
- ✨ **Breaking change detection and documentation**
|
|
35
|
+
- ✨ **Customizable commit message format**
|
|
36
|
+
- ✨ **Interactive commit message confirmation**
|
|
37
|
+
- ✨ **Supports multiple AI models including GPT-4, Claude 3, and more**
|
|
38
|
+
- ✨ **Environment variable support for API keys**
|
|
39
|
+
- ✨ **Fallback to manual mode if AI generation fails**
|
|
40
|
+
|
|
41
|
+
## 🛠 Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Using npm
|
|
45
|
+
npm install --save-dev @elsikora/commitizen-plugin-commitlint-ai
|
|
46
|
+
|
|
47
|
+
# Using yarn
|
|
48
|
+
yarn add -D @elsikora/commitizen-plugin-commitlint-ai
|
|
49
|
+
|
|
50
|
+
# Using pnpm
|
|
51
|
+
pnpm add -D @elsikora/commitizen-plugin-commitlint-ai
|
|
52
|
+
|
|
53
|
+
# Configure commitizen to use the adapter
|
|
54
|
+
npx commitizen init @elsikora/commitizen-plugin-commitlint-ai --save-dev --save-exact
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 💡 Usage
|
|
58
|
+
|
|
59
|
+
### Basic Usage
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Commit changes using the AI-powered adapter
|
|
63
|
+
git add .
|
|
64
|
+
git cz
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Configuration
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
// commitlint.config.js
|
|
71
|
+
module export default {
|
|
72
|
+
extends: ['@commitlint/config-conventional'],
|
|
73
|
+
rules: {
|
|
74
|
+
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor']],
|
|
75
|
+
'scope-case': [2, 'always', 'lower-case']
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Environment Variables
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# .env
|
|
84
|
+
OPENAI_API_KEY=your-api-key
|
|
85
|
+
# or
|
|
86
|
+
ANTHROPIC_API_KEY=your-api-key
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Manual Mode
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Create .elsikora/manual file to enable manual mode
|
|
93
|
+
mkdir -p .elsikora
|
|
94
|
+
touch .elsikora/manual
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Advanced Usage with TypeScript
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { getLLMConfig, setLLMConfig } from "@elsikora/commitizen-plugin-commitlint-ai";
|
|
101
|
+
|
|
102
|
+
// Configure AI provider
|
|
103
|
+
setLLMConfig({
|
|
104
|
+
provider: "openai",
|
|
105
|
+
model: "gpt-4",
|
|
106
|
+
mode: "auto",
|
|
107
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Custom Prompt Configuration
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
// .elsikora/commitlint-ai.config.js
|
|
115
|
+
export default {
|
|
116
|
+
provider: "anthropic",
|
|
117
|
+
model: "claude-3-opus-20240229",
|
|
118
|
+
mode: "auto",
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 🛣 Roadmap
|
|
123
|
+
|
|
124
|
+
| Task / Feature | Status |
|
|
125
|
+
| ---------------------------------------------------------------------------- | -------------- |
|
|
126
|
+
| Future development plans include: | 🚧 In Progress |
|
|
127
|
+
| - Support for more AI providers | 🚧 In Progress |
|
|
128
|
+
| - Enhanced diff analysis for better commit suggestions | 🚧 In Progress |
|
|
129
|
+
| - Custom prompt templates | 🚧 In Progress |
|
|
130
|
+
| - Integration with more Git hosting platforms | 🚧 In Progress |
|
|
131
|
+
| - Performance optimizations for large codebases | 🚧 In Progress |
|
|
132
|
+
| - Multi-language support for commit messages | 🚧 In Progress |
|
|
133
|
+
| - Team collaboration features | 🚧 In Progress |
|
|
134
|
+
| (done) AI-powered commit message generation using OpenAI or Anthropic models | 🚧 In Progress |
|
|
135
|
+
| (done) Full integration with Commitlint rules and configuration | 🚧 In Progress |
|
|
136
|
+
| (done) Support for both manual and automatic commit modes | 🚧 In Progress |
|
|
137
|
+
|
|
138
|
+
## ❓ FAQ
|
|
139
|
+
|
|
140
|
+
**Q: How does the AI generate commit messages?** A: The plugin analyzes your git diff and changed files, then uses AI to understand the changes and generate appropriate conventional commit messages that comply with your commitlint rules.
|
|
141
|
+
|
|
142
|
+
**Q: What happens if the AI service is unavailable?** A: The plugin automatically falls back to manual mode, allowing you to enter commit messages traditionally.
|
|
143
|
+
|
|
144
|
+
**Q: Can I use custom commit message formats?** A: Yes, the plugin respects your commitlint configuration and generates messages accordingly.
|
|
145
|
+
|
|
146
|
+
**Q: Is my code sent to the AI service?** A: Only the git diff and file names are sent to generate accurate commit messages. No full source code is transmitted.
|
|
147
|
+
|
|
148
|
+
## 🔒 License
|
|
149
|
+
|
|
150
|
+
This project is licensed under **MIT License**.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { QualifiedRules, UserPromptConfig } from "@commitlint/types";
|
|
2
|
+
import type { Answers, DistinctQuestion } from "inquirer";
|
|
3
|
+
export default function ManualProcess(rules: QualifiedRules, prompts: UserPromptConfig, inquirer: {
|
|
4
|
+
prompt(questions: Array<DistinctQuestion>): Promise<Answers>;
|
|
5
|
+
}): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=ManualProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManualProcess.d.ts","sourceRoot":"","sources":["../../src/ManualProcess.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;AAU1D,wBAA8B,aAAa,CAC1C,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,CA4IjB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var commitlintConfig = require('./services/commitlintConfig.js');
|
|
7
|
+
var prompts = require('./store/prompts.js');
|
|
8
|
+
|
|
9
|
+
async function ManualProcess(rules, prompts$1, inquirer) {
|
|
10
|
+
prompts.setPromptConfig(prompts$1);
|
|
11
|
+
// Extract context from commitlint config
|
|
12
|
+
const promptContext = commitlintConfig.extractLLMPromptContext(rules, prompts$1);
|
|
13
|
+
// Message removed as it's now handled in the index.ts file
|
|
14
|
+
// Manual entry prompts
|
|
15
|
+
const commitQuestions = [
|
|
16
|
+
{
|
|
17
|
+
choices: promptContext.typeEnum?.map((type) => {
|
|
18
|
+
const desc = promptContext.typeDescriptions?.[type]?.description ?? "";
|
|
19
|
+
const emoji = promptContext.typeDescriptions?.[type]?.emoji ?? "";
|
|
20
|
+
// Remove emoji from description if it already appears at the beginning
|
|
21
|
+
let cleanDesc = desc;
|
|
22
|
+
if (emoji && desc.startsWith(emoji)) {
|
|
23
|
+
cleanDesc = desc.slice(emoji.length).trim();
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
// eslint-disable-next-line @elsikora-sonar/no-nested-template-literals
|
|
27
|
+
name: `${type}${emoji ? ` ${emoji}` : ""}: ${cleanDesc}`,
|
|
28
|
+
value: type,
|
|
29
|
+
};
|
|
30
|
+
}) ?? [],
|
|
31
|
+
message: promptContext.typeDescription ?? "Select the type of change that you're committing:",
|
|
32
|
+
name: "type",
|
|
33
|
+
type: "list",
|
|
34
|
+
},
|
|
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 - Press enter to skip if scope is not applicable',
|
|
37
|
+
name: "scope",
|
|
38
|
+
type: "input",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
message: promptContext.subject.description ?? "Write a short, imperative mood description of the change:",
|
|
42
|
+
name: "subject",
|
|
43
|
+
type: "input",
|
|
44
|
+
// eslint-disable-next-line @elsikora-typescript/explicit-function-return-type
|
|
45
|
+
validate: (input) => {
|
|
46
|
+
if (!input)
|
|
47
|
+
return "Subject is required";
|
|
48
|
+
return true;
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
message: promptContext.body?.description ?? "Provide a longer description of the change: (press enter to skip)",
|
|
53
|
+
name: "body",
|
|
54
|
+
type: "input",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
// eslint-disable-next-line @elsikora-typescript/naming-convention
|
|
58
|
+
default: false,
|
|
59
|
+
message: "Are there any breaking changes?",
|
|
60
|
+
name: "isBreaking",
|
|
61
|
+
type: "confirm",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
message: "Describe the breaking changes:",
|
|
65
|
+
name: "breakingBody",
|
|
66
|
+
type: "input",
|
|
67
|
+
// eslint-disable-next-line @elsikora-typescript/no-unsafe-return
|
|
68
|
+
when: (answers) => answers.isBreaking,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
// First get all commit details
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
const answers = await inquirer.prompt(commitQuestions);
|
|
74
|
+
// Construct message from manual answers
|
|
75
|
+
// eslint-disable-next-line @elsikora-typescript/restrict-template-expressions,@elsikora-sonar/no-nested-template-literals
|
|
76
|
+
const header = `${answers.type}${answers.scope ? `(${answers.scope})` : ""}: ${answers.subject}`;
|
|
77
|
+
let body = "";
|
|
78
|
+
if (answers.isBreaking) {
|
|
79
|
+
// eslint-disable-next-line @elsikora-typescript/restrict-template-expressions
|
|
80
|
+
body = `BREAKING CHANGE: ${answers.breakingBody || "This commit introduces breaking changes."}\n\n`;
|
|
81
|
+
}
|
|
82
|
+
if (answers.body) {
|
|
83
|
+
// eslint-disable-next-line @elsikora-typescript/restrict-plus-operands
|
|
84
|
+
body += answers.body;
|
|
85
|
+
}
|
|
86
|
+
const commitMessage = [header, body].filter(Boolean).join("\n\n");
|
|
87
|
+
// Display the commit message to the user
|
|
88
|
+
console.log("\n" + chalk.yellow("Your commit message:"));
|
|
89
|
+
console.log(chalk.white("-----------------------------------"));
|
|
90
|
+
console.log(chalk.white(commitMessage));
|
|
91
|
+
console.log(chalk.white("-----------------------------------\n"));
|
|
92
|
+
// Now ask for confirmation
|
|
93
|
+
const { confirmCommit } = await inquirer.prompt([
|
|
94
|
+
{
|
|
95
|
+
// eslint-disable-next-line @elsikora-typescript/naming-convention
|
|
96
|
+
default: true,
|
|
97
|
+
message: "Are you sure you want to proceed with the commit above?",
|
|
98
|
+
name: "confirmCommit",
|
|
99
|
+
type: "confirm",
|
|
100
|
+
},
|
|
101
|
+
]);
|
|
102
|
+
// Check confirmation
|
|
103
|
+
if (!confirmCommit) {
|
|
104
|
+
console.log(chalk.yellow("Commit canceled."));
|
|
105
|
+
throw new Error("User canceled the commit");
|
|
106
|
+
}
|
|
107
|
+
return commitMessage;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
exports.default = ManualProcess;
|
|
111
|
+
//# sourceMappingURL=ManualProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManualProcess.js","sources":["../../../src/ManualProcess.ts"],"sourcesContent":[null],"names":["prompts","setPromptConfig","extractLLMPromptContext"],"mappings":";;;;;;;;AAWe,eAAe,aAAa,CAC1C,KAAqB,EACrBA,SAAyB,EACzB,QAEC,EAAA;IAGDC,uBAAe,CAACD,SAAO,CAAC;;IAGxB,MAAM,aAAa,GAAqBE,wCAAuB,CAAC,KAAK,EAAEF,SAAO,CAAC;;;AAK/E,IAAA,MAAM,eAAe,GAsBjB;AACH,QAAA;YACC,OAAO,EACN,aAAa,C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AAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;;IAGjE,MAAM,EAAE,aAAa,EAAE,GAAY,MAAM,QAAQ,CAAC,MAAM,CAAC;AACxD,QAAA;;AAEC,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,OAAO,EAAE,yDAAyD;AAClE,YAAA,IAAI,EAAE,eAAe;AACrB,YAAA,IAAI,EAAE,SAAS;AACf,SAAA;AACD,KAAA,CAAC;;IAGF,IAAI,CAAC,aAAa,EAAE;QACnB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE7C,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;;AAG5C,IAAA,OAAO,aAAa;AACrB;;;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { QualifiedRules, UserPromptConfig } from "@commitlint/types";
|
|
2
|
+
import type { Answers, DistinctQuestion } from "inquirer";
|
|
3
|
+
export default function Process(rules: QualifiedRules, prompts: UserPromptConfig, inquirer: {
|
|
4
|
+
prompt(questions: Array<DistinctQuestion>): Promise<Answers>;
|
|
5
|
+
}): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=Process.d.ts.map
|
|
@@ -0,0 +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,CAmMjB"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var commitlintConfig = require('./services/commitlintConfig.js');
|
|
7
|
+
var commitlintValidator = require('./services/commitlintValidator.js');
|
|
8
|
+
var index = require('./services/llm/index.js');
|
|
9
|
+
var prompts = require('./store/prompts.js');
|
|
10
|
+
var config = require('./services/llm/config.js');
|
|
11
|
+
|
|
12
|
+
async function Process(rules, prompts$1, inquirer) {
|
|
13
|
+
prompts.setPromptConfig(prompts$1);
|
|
14
|
+
// First, ask for LLM provider and API key
|
|
15
|
+
await index.selectLLMProvider(inquirer);
|
|
16
|
+
// Extract context from commitlint config
|
|
17
|
+
const promptContext = commitlintConfig.extractLLMPromptContext(rules, prompts$1);
|
|
18
|
+
// Check if manual mode is enabled in config
|
|
19
|
+
const config$1 = config.getLLMConfig();
|
|
20
|
+
// If manual mode is enabled, skip AI generation and go straight to manual entry
|
|
21
|
+
if (config$1 && config$1.mode === "manual") {
|
|
22
|
+
console.log(chalk.blue("Using manual commit entry mode..."));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
try {
|
|
26
|
+
console.log(chalk.blue("Generating commit message with AI..."));
|
|
27
|
+
// Generate commit message using LLM
|
|
28
|
+
const commitConfig = await index.generateCommitMessage(promptContext);
|
|
29
|
+
// Validate the commit message with commitlint and fix if needed
|
|
30
|
+
const validatedCommitMessage = await commitlintValidator.validateAndFixCommitMessage(commitConfig, promptContext);
|
|
31
|
+
// If validation returned null, it means we should switch to manual mode
|
|
32
|
+
if (validatedCommitMessage === null) {
|
|
33
|
+
console.log(chalk.yellow("Switching to manual commit entry after failed validation attempts."));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log(chalk.green("AI generated commit message successfully!"));
|
|
37
|
+
// Show the generated message to the user
|
|
38
|
+
console.log("\n" + chalk.yellow("Generated commit message:"));
|
|
39
|
+
console.log(chalk.white("-----------------------------------"));
|
|
40
|
+
console.log(chalk.white(validatedCommitMessage));
|
|
41
|
+
console.log(chalk.white("-----------------------------------\n"));
|
|
42
|
+
// Ask for confirmation
|
|
43
|
+
const { confirmCommit } = await inquirer.prompt([
|
|
44
|
+
{
|
|
45
|
+
// eslint-disable-next-line @elsikora-typescript/naming-convention
|
|
46
|
+
default: true,
|
|
47
|
+
message: "Do you want to proceed with this commit message?",
|
|
48
|
+
name: "confirmCommit",
|
|
49
|
+
type: "confirm",
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
if (confirmCommit) {
|
|
53
|
+
return validatedCommitMessage;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// 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
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// Only show error for AI mode errors, not when manual mode is intentionally used
|
|
63
|
+
if (config$1?.mode !== "manual") {
|
|
64
|
+
console.error(chalk.red("Error generating commit with AI:"), error);
|
|
65
|
+
console.log(chalk.yellow("Falling back to manual commit entry..."));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Fallback to regular prompts if LLM fails or in manual mode
|
|
70
|
+
const commitQuestions = [
|
|
71
|
+
{
|
|
72
|
+
choices: promptContext.typeEnum?.map((type) => {
|
|
73
|
+
const desc = promptContext.typeDescriptions?.[type]?.description ?? "";
|
|
74
|
+
const emoji = promptContext.typeDescriptions?.[type]?.emoji ?? "";
|
|
75
|
+
// Remove emoji from description if it already appears at the beginning
|
|
76
|
+
let cleanDesc = desc;
|
|
77
|
+
if (emoji && desc.startsWith(emoji)) {
|
|
78
|
+
cleanDesc = desc.slice(emoji.length).trim();
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
name: type + (emoji ? " " + emoji : "") + ": " + cleanDesc,
|
|
82
|
+
value: type,
|
|
83
|
+
};
|
|
84
|
+
}) ?? [],
|
|
85
|
+
message: promptContext.typeDescription ?? "Select the type of change that you're committing:",
|
|
86
|
+
name: "type",
|
|
87
|
+
type: "list",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
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 - Press enter to skip if scope is not applicable',
|
|
91
|
+
name: "scope",
|
|
92
|
+
type: "input",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
message: promptContext.subject.description ?? "Write a short, imperative mood description of the change:",
|
|
96
|
+
name: "subject",
|
|
97
|
+
type: "input",
|
|
98
|
+
// eslint-disable-next-line @elsikora-sonar/function-return-type
|
|
99
|
+
validate: (input) => {
|
|
100
|
+
if (!input)
|
|
101
|
+
return "Subject is required";
|
|
102
|
+
return true;
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
message: promptContext.body?.description ?? "Provide a longer description of the change: (press enter to skip)",
|
|
107
|
+
name: "body",
|
|
108
|
+
type: "input",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
// eslint-disable-next-line @elsikora-typescript/naming-convention
|
|
112
|
+
default: false,
|
|
113
|
+
message: "Are there any breaking changes?",
|
|
114
|
+
name: "isBreaking",
|
|
115
|
+
type: "confirm",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
message: "Describe the breaking changes:",
|
|
119
|
+
name: "breakingBody",
|
|
120
|
+
type: "input",
|
|
121
|
+
// eslint-disable-next-line @elsikora-typescript/no-unsafe-return
|
|
122
|
+
when: (answers) => answers.isBreaking,
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
// First get all commit details
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
const answers = await inquirer.prompt(commitQuestions);
|
|
128
|
+
// Construct message from manual answers
|
|
129
|
+
// eslint-disable-next-line @elsikora-typescript/no-unsafe-argument,@elsikora-typescript/restrict-plus-operands
|
|
130
|
+
const header = "".concat(answers.type, answers.scope ? "(" + answers.scope + ")" : "", ": ", answers.subject);
|
|
131
|
+
let body = "";
|
|
132
|
+
if (answers.isBreaking) {
|
|
133
|
+
// eslint-disable-next-line @elsikora-typescript/restrict-template-expressions
|
|
134
|
+
body = `BREAKING CHANGE: ${answers.breakingBody || "This commit introduces breaking changes."}\n\n`;
|
|
135
|
+
}
|
|
136
|
+
if (answers.body) {
|
|
137
|
+
// eslint-disable-next-line @elsikora-typescript/restrict-plus-operands
|
|
138
|
+
body += answers.body;
|
|
139
|
+
}
|
|
140
|
+
const commitMessage = [header, body].filter(Boolean).join("\n\n");
|
|
141
|
+
// Display the commit message to the user
|
|
142
|
+
console.log("\n" + chalk.yellow("Your commit message:"));
|
|
143
|
+
console.log(chalk.white("-----------------------------------"));
|
|
144
|
+
console.log(chalk.white(commitMessage));
|
|
145
|
+
console.log(chalk.white("-----------------------------------\n"));
|
|
146
|
+
// Now ask for confirmation
|
|
147
|
+
const { confirmCommit } = await inquirer.prompt([
|
|
148
|
+
{
|
|
149
|
+
// eslint-disable-next-line @elsikora-typescript/naming-convention
|
|
150
|
+
default: true,
|
|
151
|
+
message: "Are you sure you want to proceed with the commit above?",
|
|
152
|
+
name: "confirmCommit",
|
|
153
|
+
type: "confirm",
|
|
154
|
+
},
|
|
155
|
+
]);
|
|
156
|
+
// Check confirmation
|
|
157
|
+
if (!confirmCommit) {
|
|
158
|
+
console.log(chalk.yellow("Commit canceled."));
|
|
159
|
+
throw new Error("User canceled the commit");
|
|
160
|
+
}
|
|
161
|
+
return commitMessage;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
exports.default = Process;
|
|
165
|
+
//# sourceMappingURL=Process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Process.js","sources":["../../../src/Process.ts"],"sourcesContent":[null],"names":["prompts","setPromptConfig","selectLLMProvider","extractLLMPromptContext","config","getLLMConfig","generateCommitMessage","validateAndFixCommitMessage"],"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,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;;AAG/D,YAAA,MAAM,YAAY,GAAiB,MAAME,2BAAqB,CAAC,aAAa,CAAC;;YAG7E,MAAM,sBAAsB,GAAkB,MAAMC,+CAA2B,CAAC,YAAY,EAAE,aAAa,CAAC;;AAG5G,YAAA,IAAI,sBAAsB,KAAK,IAAI,EAAE;gBACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,oEAAoE,CAAC,CAAC;;iBACzF;gBACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;;AAGrE,gBAAA,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC;gBAC7D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;gBAC/D,O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E;QACnB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE7C,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;;AAG5C,IAAA,OAAO,aAAa;AACrB;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { PromptMessages, PromptName } from "@commitlint/types";
|
|
2
|
+
import type { Answers, ChoiceCollection, DistinctQuestion } from "inquirer";
|
|
3
|
+
import type { CaseFunction as CaseFunction } from "./utils/case-function.js";
|
|
4
|
+
import type { FullStopFunction as FullStopFunction } from "./utils/full-stop-function.js";
|
|
5
|
+
export type QuestionConfig = {
|
|
6
|
+
caseFn?: CaseFunction;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
enumList?: ChoiceCollection<{
|
|
9
|
+
name: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}> | null;
|
|
12
|
+
fullStopFn?: FullStopFunction;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
messages: PromptMessages;
|
|
15
|
+
minLength?: number;
|
|
16
|
+
multipleSelectDefaultDelimiter?: string;
|
|
17
|
+
multipleValueDelimiters?: RegExp;
|
|
18
|
+
skip?: boolean;
|
|
19
|
+
title: string;
|
|
20
|
+
when?: DistinctQuestion["when"];
|
|
21
|
+
};
|
|
22
|
+
export default class Question {
|
|
23
|
+
get maxLength(): number;
|
|
24
|
+
set maxLength(maxLength: number);
|
|
25
|
+
get minLength(): number;
|
|
26
|
+
set minLength(minLength: number);
|
|
27
|
+
get question(): Readonly<DistinctQuestion>;
|
|
28
|
+
private _maxLength;
|
|
29
|
+
private _minLength;
|
|
30
|
+
private readonly _question;
|
|
31
|
+
private readonly caseFn;
|
|
32
|
+
private readonly fullStopFn;
|
|
33
|
+
private readonly messages;
|
|
34
|
+
private readonly multipleSelectDefaultDelimiter?;
|
|
35
|
+
private readonly multipleValueDelimiters?;
|
|
36
|
+
private readonly skip;
|
|
37
|
+
private readonly title;
|
|
38
|
+
constructor(name: PromptName, { caseFn, defaultValue, enumList, fullStopFn, maxLength, messages, minLength, multipleSelectDefaultDelimiter, multipleValueDelimiters, skip, title, when }: QuestionConfig);
|
|
39
|
+
getMessage(key: string): string;
|
|
40
|
+
protected beforeQuestionStart(_answers: Answers): void;
|
|
41
|
+
protected decorateMessage(_answers: Answers): string;
|
|
42
|
+
protected filter(input: Array<string> | string): string;
|
|
43
|
+
protected transformer(input: string, _answers: Answers): string;
|
|
44
|
+
protected validate(input: string): boolean | string;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=Question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Question.d.ts","sourceRoot":"","sources":["../../src/Question.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAO1F,MAAM,MAAM,cAAc,GAAG;IAC5B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;QAC3B,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACd,CAAC,GAAG,IAAI,CAAC;IACV,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,IAAI,CA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,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM;IAoBvD,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM;IAa/D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM;CA4BnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionBody.d.ts","sourceRoot":"","sources":["../../src/SectionBody.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAa1D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAuB7D;AAED,wBAAgB,YAAY,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAKtD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PromptName } from "@commitlint/types";
|
|
2
|
+
import type { Answers, DistinctQuestion } from "inquirer";
|
|
3
|
+
import type { QuestionConfig } from "./Question.js";
|
|
4
|
+
import Question from "./Question.js";
|
|
5
|
+
export declare class FooterQuestion extends Question {
|
|
6
|
+
footerMaxLength: number;
|
|
7
|
+
footerMinLength: number;
|
|
8
|
+
constructor(name: PromptName, questionConfig: QuestionConfig, footerMaxLength?: number, footerMinLength?: number);
|
|
9
|
+
beforeQuestionStart(answers: Answers): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function combineCommitMessage(answers: Answers): string;
|
|
12
|
+
export declare function getQuestions(): Array<DistinctQuestion>;
|
|
13
|
+
//# sourceMappingURL=SectionFooter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionFooter.d.ts","sourceRoot":"","sources":["../../src/SectionFooter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAKpD,OAAO,QAAQ,MAAM,eAAe,CAAC;AAOrC,qBAAa,cAAe,SAAQ,QAAQ;IAC3C,eAAe,EAAE,MAAM,CAAC;IAExB,eAAe,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM;IAMhH,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAK3C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAiD7D;AAED,wBAAgB,YAAY,IAAI,KAAK,CAAC,gBAAgB,CAAC,CA+FtD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PromptName, RuleField } from "@commitlint/types";
|
|
2
|
+
import type { Answers, DistinctQuestion } from "inquirer";
|
|
3
|
+
import type { QuestionConfig } from "./Question.js";
|
|
4
|
+
import Question from "./Question.js";
|
|
5
|
+
import getRuleQuestionConfig from "./services/getRuleQuestionConfig.js";
|
|
6
|
+
export declare class HeaderQuestion extends Question {
|
|
7
|
+
headerMaxLength: number;
|
|
8
|
+
headerMinLength: number;
|
|
9
|
+
constructor(name: PromptName, questionConfig: QuestionConfig, headerMaxLength?: number, headerMinLength?: number);
|
|
10
|
+
beforeQuestionStart(answers: Answers): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function combineCommitMessage(answers: Answers): string;
|
|
13
|
+
export declare function getQuestionConfig(name: RuleField): ReturnType<typeof getRuleQuestionConfig>;
|
|
14
|
+
export declare function getQuestions(): Array<DistinctQuestion>;
|
|
15
|
+
//# sourceMappingURL=SectionHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionHeader.d.ts","sourceRoot":"","sources":["../../src/SectionHeader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,qBAAqB,MAAM,qCAAqC,CAAC;AAGxE,qBAAa,cAAe,SAAQ,QAAQ;IAC3C,eAAe,EAAE,MAAM,CAAC;IAExB,eAAe,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM;IAMhH,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAK3C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAO7D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAY3F;AAED,wBAAgB,YAAY,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAqBtD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Answers, DistinctQuestion } from "inquirer";
|
|
2
|
+
export { getLLMConfig, setLLMConfig } from "./services/llm/index.js";
|
|
3
|
+
export type { CommitMode, LLMConfig, LLMConfigStorage, LLMModel, LLMProvider } from "./services/llm/types.js";
|
|
4
|
+
type Commit = (message: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Entry point for commitizen
|
|
7
|
+
* @param inquirerIns instance passed by commitizen, unused
|
|
8
|
+
* @param commit callback to execute with complete commit message
|
|
9
|
+
* @return {void}
|
|
10
|
+
*/
|
|
11
|
+
export declare function prompter(inquirerIns: {
|
|
12
|
+
prompt(questions: Array<DistinctQuestion>): Promise<Answers>;
|
|
13
|
+
}, commit: Commit): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAW1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAU9G,KAAK,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAkCxC;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC7B,WAAW,EAAE;IACZ,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D,EACD,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|