gitpt 1.6.1 → 1.7.2
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/README.md +34 -167
- package/dist/commands/commit/commitFlags.js +7 -0
- package/dist/commands/commit/context/buildPrompt.js +13 -10
- package/dist/commands/commit/context/summaryPrompt.js +5 -2
- package/dist/commands/commit/context/systemPrompt.js +4 -1
- package/dist/commands/commit/context/userPrompt.js +4 -1
- package/dist/commands/commit/generateCommitMessage.js +14 -17
- package/dist/commands/commit/index.js +186 -179
- package/dist/commands/commit/summarizeDiff.js +183 -162
- package/dist/commands/config.js +24 -9
- package/dist/commands/hook/index.js +68 -0
- package/dist/commands/middleware/capabilitiesMiddleware/ghCapability.js +20 -20
- package/dist/commands/middleware/capabilitiesMiddleware/gitCapability.js +13 -10
- package/dist/commands/middleware/capabilitiesMiddleware/index.js +12 -11
- package/dist/commands/middleware/hasStagedChangesMiddleware.js +9 -6
- package/dist/commands/middleware/setupMiddleware/defaultModels.js +14 -10
- package/dist/commands/middleware/setupMiddleware/index.js +65 -71
- package/dist/commands/model.js +7 -4
- package/dist/commands/passthroughArgs.js +11 -0
- package/dist/commands/pr/context/systemPrompt.js +4 -1
- package/dist/commands/pr/context/userPrompt.js +4 -1
- package/dist/commands/pr/generatePRDetails.js +24 -23
- package/dist/commands/pr/getPRContext.js +37 -62
- package/dist/commands/pr/index.js +57 -62
- package/dist/commands/reset.js +23 -23
- package/dist/commands/review/index.js +31 -0
- package/dist/commands/setup.js +38 -13
- package/dist/config.js +63 -60
- package/dist/index.js +30 -67
- package/dist/llm/budget.js +10 -0
- package/dist/llm/index.js +12 -7
- package/dist/llm/providers/anthropic/index.js +30 -30
- package/dist/llm/providers/apiKey.js +36 -35
- package/dist/llm/providers/apple/client.js +73 -83
- package/dist/llm/providers/apple/index.js +64 -72
- package/dist/llm/providers/apple/models.js +27 -19
- package/dist/llm/providers/base.js +36 -36
- package/dist/llm/providers/local/index.js +79 -91
- package/dist/llm/providers/openai/index.js +19 -16
- package/dist/llm/providers/openaiCompatible.js +59 -62
- package/dist/llm/providers/openrouter/index.js +18 -15
- package/dist/llm/registry.js +30 -34
- package/dist/llm/setup/getAvailableModels.js +15 -9
- package/dist/llm/setup/selectModel.js +36 -44
- package/dist/llm/tokenCount.js +4 -3
- package/dist/package.js +67 -0
- package/dist/services/gh/createPullRequest.js +38 -58
- package/dist/services/gh/index.js +6 -3
- package/dist/services/gh/isAvailable.js +10 -8
- package/dist/services/git/executeGitAdd.js +11 -12
- package/dist/services/git/executeGitCommit.js +10 -11
- package/dist/services/git/getAmendChanges.js +23 -0
- package/dist/services/git/getChangedFiles.js +28 -61
- package/dist/services/git/getCommitsSinceBaseBranch.js +28 -56
- package/dist/services/git/getCurrentBranch.js +10 -8
- package/dist/services/git/getDefaultBranch.js +35 -60
- package/dist/services/git/getStagedChanges.js +10 -8
- package/dist/services/git/getStagedFiles.js +10 -9
- package/dist/services/git/hasStagedChanges.js +9 -8
- package/dist/services/git/index.js +17 -12
- package/dist/services/git/isAvailable.js +10 -8
- package/dist/services/git/isGitRepository.js +10 -8
- package/dist/utils/commitlint.js +97 -135
- package/dist/utils/formatBaseURL.js +7 -6
- package/dist/utils/maskApiKey.js +6 -7
- package/package.json +14 -4
- package/dist/commands/commit/context/buildPrompt.d.ts +0 -4
- package/dist/commands/commit/context/summaryPrompt.d.ts +0 -2
- package/dist/commands/commit/context/systemPrompt.d.ts +0 -1
- package/dist/commands/commit/context/userPrompt.d.ts +0 -1
- package/dist/commands/commit/generateCommitMessage.d.ts +0 -1
- package/dist/commands/commit/index.d.ts +0 -7
- package/dist/commands/commit/summarizeDiff.d.ts +0 -1
- package/dist/commands/config.d.ts +0 -1
- package/dist/commands/middleware/capabilitiesMiddleware/ghCapability.d.ts +0 -1
- package/dist/commands/middleware/capabilitiesMiddleware/gitCapability.d.ts +0 -1
- package/dist/commands/middleware/capabilitiesMiddleware/index.d.ts +0 -3
- package/dist/commands/middleware/hasStagedChangesMiddleware.d.ts +0 -1
- package/dist/commands/middleware/setupMiddleware/defaultModels.d.ts +0 -8
- package/dist/commands/middleware/setupMiddleware/index.d.ts +0 -4
- package/dist/commands/model.d.ts +0 -1
- package/dist/commands/pr/context/systemPrompt.d.ts +0 -1
- package/dist/commands/pr/context/userPrompt.d.ts +0 -1
- package/dist/commands/pr/generatePRDetails.d.ts +0 -4
- package/dist/commands/pr/getPRContext.d.ts +0 -1
- package/dist/commands/pr/index.d.ts +0 -10
- package/dist/commands/reset.d.ts +0 -3
- package/dist/commands/setup.d.ts +0 -3
- package/dist/config.d.ts +0 -14
- package/dist/index.d.ts +0 -2
- package/dist/llm/client.d.ts +0 -24
- package/dist/llm/client.js +0 -1
- package/dist/llm/index.d.ts +0 -6
- package/dist/llm/providers/anthropic/index.d.ts +0 -9
- package/dist/llm/providers/apiKey.d.ts +0 -3
- package/dist/llm/providers/apple/client.d.ts +0 -3
- package/dist/llm/providers/apple/index.d.ts +0 -13
- package/dist/llm/providers/apple/models.d.ts +0 -14
- package/dist/llm/providers/base.d.ts +0 -30
- package/dist/llm/providers/local/index.d.ts +0 -11
- package/dist/llm/providers/openai/index.d.ts +0 -10
- package/dist/llm/providers/openaiCompatible.d.ts +0 -15
- package/dist/llm/providers/openrouter/index.d.ts +0 -9
- package/dist/llm/registry.d.ts +0 -8
- package/dist/llm/setup/getAvailableModels.d.ts +0 -5
- package/dist/llm/setup/selectModel.d.ts +0 -5
- package/dist/llm/setup/types.d.ts +0 -13
- package/dist/llm/setup/types.js +0 -1
- package/dist/llm/tokenCount.d.ts +0 -3
- package/dist/services/gh/createPullRequest.d.ts +0 -1
- package/dist/services/gh/index.d.ts +0 -4
- package/dist/services/gh/isAvailable.d.ts +0 -1
- package/dist/services/git/executeGitAdd.d.ts +0 -1
- package/dist/services/git/executeGitCommit.d.ts +0 -1
- package/dist/services/git/getChangedFiles.d.ts +0 -1
- package/dist/services/git/getCommitsSinceBaseBranch.d.ts +0 -1
- package/dist/services/git/getCurrentBranch.d.ts +0 -1
- package/dist/services/git/getDefaultBranch.d.ts +0 -1
- package/dist/services/git/getStagedChanges.d.ts +0 -1
- package/dist/services/git/getStagedFiles.d.ts +0 -1
- package/dist/services/git/hasStagedChanges.d.ts +0 -1
- package/dist/services/git/index.d.ts +0 -13
- package/dist/services/git/isAvailable.d.ts +0 -1
- package/dist/services/git/isGitRepository.d.ts +0 -1
- package/dist/utils/commitlint.d.ts +0 -25
- package/dist/utils/formatBaseURL.d.ts +0 -1
- package/dist/utils/maskApiKey.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,208 +1,75 @@
|
|
|
1
1
|
# GitPT
|
|
2
2
|
|
|
3
|
-
Git Prompt Tool is a
|
|
3
|
+
GitPT (Git Prompt Tool) is a git command alias that writes your commit messages with an LLM, built for on-device models. Use it anywhere you use git: every command it doesn't change passes straight through, so you can replace git with it and lose nothing. The one command that changes is `commit`, which writes the message for you.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Big remote models already write commits fine. The harder case is the small local model on your machine (Apple's Foundation Models, Ollama, LM Studio), which holds only a few thousand tokens. A real diff is much larger, so GitPT summarizes it file by file until it fits the model's context window, then writes the message from that summary. Remote APIs (OpenAI, Anthropic, OpenRouter) work too.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Generate commit messages with AI based on your code changes
|
|
7
|
+

|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
- Create pull requests with AI-generated titles and descriptions
|
|
9
|
+
<sub>The diff is summarized to fit the model's context window before the message is written.</sub>
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
- Compatible with all regular git options (flags, arguments, etc.)
|
|
15
|
-
- Edit suggested messages before committing
|
|
16
|
-
- Works with various AI models via OpenRouter
|
|
17
|
-
- Support for local LLMs with OpenAI-compatible API
|
|
18
|
-
- Support for Apple Foundation Models on-device (macOS 27+, no API key required)
|
|
19
|
-
- [Commitlint](https://commitlint.js.org/) support - read directly from your repository
|
|
11
|
+
> **New: Apple Foundation Models.** On macOS 27 and later, GitPT runs on Apple's built-in on-device model. No API key, no signup, nothing leaves your Mac. Run `gitpt setup` and choose Apple Foundation Models.
|
|
20
12
|
|
|
21
|
-
##
|
|
13
|
+
## Install
|
|
22
14
|
|
|
23
15
|
```bash
|
|
24
|
-
# Install globally
|
|
25
16
|
npm install -g gitpt
|
|
26
|
-
|
|
27
|
-
# Or use npx
|
|
28
|
-
npx gitpt
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Set up
|
|
32
|
-
|
|
33
|
-
To configure GitPT with your OpenRouter API key and select a model:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
gitpt setup
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
This will guide you through:
|
|
40
|
-
1. Entering your OpenRouter API key
|
|
41
|
-
2. Selecting an AI model from popular options or specifying a custom one
|
|
42
|
-
|
|
43
|
-
_It's recommended using small models, such as `openai/gpt-4.1-mini` as your model choice. Mainly due to its large context window, fast response times & cost-effective pricing._
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
You'll need an [OpenRouter](https://openrouter.ai/) account to get an API key.
|
|
47
|
-
|
|
48
|
-
## Usage
|
|
49
|
-
|
|
50
|
-
### Using GitPT as a Complete Git Replacement
|
|
51
|
-
|
|
52
|
-
GitPT can be used as a direct replacement for git - any git command can be run through GitPT:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# Standard git commands work exactly the same
|
|
56
|
-
gitpt status
|
|
57
|
-
gitpt log
|
|
58
|
-
gitpt branch
|
|
59
|
-
gitpt checkout -b new-feature
|
|
60
|
-
gitpt push origin main
|
|
61
|
-
|
|
62
|
-
# GitPT passes all arguments and options to git
|
|
63
|
-
gitpt log --oneline --graph
|
|
64
|
-
gitpt merge --no-ff feature-branch
|
|
65
17
|
```
|
|
66
18
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Add files to the staging area just like you would with git:
|
|
19
|
+
## Setup
|
|
70
20
|
|
|
71
21
|
```bash
|
|
72
|
-
#
|
|
73
|
-
gitpt add .
|
|
22
|
+
gitpt setup # pick a model
|
|
74
23
|
```
|
|
75
24
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Generate an AI-powered commit message based on your staged changes:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
gitpt commit
|
|
82
|
-
|
|
83
|
-
# Or supply -m argument, if you want to avoid gitpt generating the message
|
|
84
|
-
gitpt commit -m "feat: file hash validation"
|
|
85
|
-
|
|
86
|
-
# Pass any other git commit options
|
|
87
|
-
gitpt commit --amend
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
The tool will:
|
|
91
|
-
1. Analyze your staged changes
|
|
92
|
-
2. Generate a commit message using the configured AI model
|
|
93
|
-
3. Validate against commitlint rules (if configured)
|
|
94
|
-
4. Regenerate the message if it fails validation
|
|
95
|
-
5. Show you the suggested message
|
|
96
|
-
6. Let you edit the message before committing
|
|
97
|
-
7. Create the commit with your approved message
|
|
98
|
-
|
|
99
|
-
### Changing Models
|
|
100
|
-
|
|
101
|
-
You can change the AI model at any time:
|
|
25
|
+
Optional: alias git so GitPT runs everywhere you already type git.
|
|
102
26
|
|
|
103
27
|
```bash
|
|
104
|
-
|
|
105
|
-
gitpt model
|
|
28
|
+
alias git=gitpt
|
|
106
29
|
```
|
|
107
30
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
#### Using a Local LLM
|
|
111
|
-
|
|
112
|
-
GitPT works with any local LLM that provides an OpenAI-compatible API endpoint, such as:
|
|
113
|
-
- [Ollama](https://ollama.ai/)
|
|
114
|
-
- [LM Studio](https://lmstudio.ai/)
|
|
115
|
-
- [LocalAI](https://localai.io/)
|
|
116
|
-
- Custom setups with tools like llama.cpp
|
|
117
|
-
|
|
118
|
-
#### Using Apple Foundation Models
|
|
119
|
-
|
|
120
|
-
On macOS 27 and later, GitPT can use Apple's on-device Foundation Models through the built-in `fm` CLI — no API key or network connection required. Select **Apple Foundation Models** when running `gitpt setup` or `gitpt model`.
|
|
121
|
-
|
|
122
|
-
> Note: the on-device model has a small context window (~4096 tokens), so very large diffs may not fit.
|
|
123
|
-
|
|
124
|
-
## GitHub Usage
|
|
31
|
+
## Use
|
|
125
32
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
### Creating Pull Requests
|
|
129
|
-
|
|
130
|
-
Generate AI-powered pull request titles and descriptions based on your changes:
|
|
33
|
+
With plain git, you write the message yourself:
|
|
131
34
|
|
|
132
35
|
```bash
|
|
133
|
-
|
|
36
|
+
git add .
|
|
37
|
+
git commit -m "fix: handle empty staged diff" # you write the message
|
|
134
38
|
```
|
|
135
39
|
|
|
136
|
-
|
|
137
|
-
1. Analyze the commits and files changed since branching from the base branch
|
|
138
|
-
2. Generate a suitable PR title and detailed description
|
|
139
|
-
3. Show you the suggested content
|
|
140
|
-
4. Let you edit the title and description before submission
|
|
141
|
-
5. Create the pull request with your approved content
|
|
142
|
-
|
|
143
|
-
#### Pull Request Options
|
|
40
|
+
With GitPT, you don't:
|
|
144
41
|
|
|
145
42
|
```bash
|
|
146
|
-
|
|
147
|
-
gitpt
|
|
148
|
-
|
|
149
|
-
# Specify a custom base branch
|
|
150
|
-
gitpt pr create --base develop
|
|
151
|
-
|
|
152
|
-
# Skip editing the PR details
|
|
153
|
-
gitpt pr create --no-edit
|
|
154
|
-
|
|
155
|
-
# Provide your own title instead of generating one
|
|
156
|
-
gitpt pr create --title "Your PR title here"
|
|
43
|
+
gitpt add .
|
|
44
|
+
gitpt commit # GitPT writes it from the diff
|
|
157
45
|
```
|
|
158
46
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
GitPT leverages AI to enhance your Git workflow while acting as a complete git wrapper:
|
|
162
|
-
|
|
163
|
-
- **Command Handling:** GitPT intelligently routes commands - enhanced commands (commit, pr) use AI capabilities while all other git commands are passed directly to git.
|
|
164
|
-
|
|
165
|
-
- **For commits:** Sends a diff of your staged changes to the AI, which generates a contextual commit message following best practices.
|
|
166
|
-
|
|
167
|
-
- **Commitlint Integration:** Automatically detects commitlint configuration files and validates generated commit messages against your project's commit conventions. If validation fails, it regenerates a compliant message.
|
|
168
|
-
|
|
169
|
-
- **For pull requests:** Analyzes the commits and file changes between your branch and the base branch, then generates a suitable title and detailed description for your PR.
|
|
170
|
-
|
|
171
|
-
- **For other git commands:** Passes them through directly to git with all arguments and options preserved, ensuring complete compatibility with your existing git workflow.
|
|
47
|
+
`gitpt commit` reads your staged diff, writes the message, and opens it in your editor. Save and close to commit.
|
|
172
48
|
|
|
173
|
-
|
|
49
|
+
### Through plain `git commit`
|
|
174
50
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
# Clone the repository
|
|
179
|
-
git clone https://github.com/bartaxyz/GitPT.git
|
|
180
|
-
cd GitPT
|
|
181
|
-
|
|
182
|
-
# Install dependencies
|
|
183
|
-
npm install
|
|
184
|
-
|
|
185
|
-
# Build the project
|
|
186
|
-
npm run build
|
|
187
|
-
|
|
188
|
-
# Link for local development
|
|
189
|
-
npm link
|
|
190
|
-
```
|
|
51
|
+
Prefer typing `git commit`? Two ways:
|
|
191
52
|
|
|
192
|
-
|
|
53
|
+
- **Shell alias** — add `alias git=gitpt` to your shell rc, then `git commit` runs GitPT.
|
|
54
|
+
- **Git hook** — run `gitpt hook install` once. A normal `git commit` (without `-m`) then opens your editor prefilled with an AI-generated message. It steps aside for `-m`, merges, squashes, and amends, and never blocks a commit if generation fails. Remove it with `gitpt hook uninstall`.
|
|
193
55
|
|
|
194
|
-
|
|
56
|
+
## Commands
|
|
195
57
|
|
|
196
|
-
-
|
|
58
|
+
- `gitpt commit`: write a commit message from staged changes. Respects `-m` and your commitlint rules.
|
|
59
|
+
- `gitpt model`: pick or switch the model. Each provider keeps its own key.
|
|
60
|
+
- `gitpt setup` / `gitpt config` / `gitpt reset`: configure, show, or clear settings.
|
|
61
|
+
- `gitpt pr create`: draft a pull request title and description with the `gh` CLI (experimental).
|
|
62
|
+
- `gitpt hook install` / `gitpt hook uninstall`: use GitPT through a plain `git commit` via a `prepare-commit-msg` hook.
|
|
197
63
|
|
|
198
|
-
|
|
64
|
+
## Models
|
|
199
65
|
|
|
200
|
-
- **
|
|
66
|
+
- **On-device**: Apple's Foundation Models on macOS 27 or later (no API key), or any OpenAI-compatible local server such as Ollama or LM Studio.
|
|
67
|
+
- **Remote**: OpenAI, Anthropic, OpenRouter. Bring an API key.
|
|
201
68
|
|
|
202
|
-
|
|
69
|
+
## Requests and bugs
|
|
203
70
|
|
|
204
|
-
|
|
71
|
+
Want a feature or hit a bug? [Open an issue](https://github.com/bartaxyz/GitPT/issues).
|
|
205
72
|
|
|
206
73
|
## License
|
|
207
74
|
|
|
208
|
-
MIT
|
|
75
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/commands/commit/commitFlags.ts
|
|
2
|
+
var hasFlag = (args, flag) => args.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
|
|
3
|
+
var isAmend = (args) => hasFlag(args, "--amend");
|
|
4
|
+
var isAllowEmpty = (args) => hasFlag(args, "--allow-empty");
|
|
5
|
+
var skipsStagedGuard = (args) => isAmend(args) || isAllowEmpty(args);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isAmend, skipsStagedGuard };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { getCommitlintRules, hasCommitlintConfig
|
|
1
|
+
import { getCommitlintRules, hasCommitlintConfig } from "../../../utils/commitlint.js";
|
|
2
2
|
import { systemPrompt } from "./systemPrompt.js";
|
|
3
3
|
import { userPrompt } from "./userPrompt.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
//#region src/commands/commit/context/buildPrompt.ts
|
|
5
|
+
var buildCommitPrompt = (diff, validationErrors) => {
|
|
6
|
+
return {
|
|
7
|
+
system: [
|
|
8
|
+
systemPrompt,
|
|
9
|
+
hasCommitlintConfig() ? getCommitlintRules() : "",
|
|
10
|
+
validationErrors ? `\n\nYOUR PREVIOUS MESSAGE FAILED VALIDATION WITH THESE ERRORS:\n${validationErrors}\n\nFIX THESE ISSUES IN YOUR NEW MESSAGE.` : ""
|
|
11
|
+
].join("\n\n"),
|
|
12
|
+
user: userPrompt(diff)
|
|
13
|
+
};
|
|
13
14
|
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { buildCommitPrompt };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/commands/commit/context/summaryPrompt.ts
|
|
2
|
+
var summarySystemPrompt = `
|
|
2
3
|
You are condensing a fragment of a git diff so a commit message can be written afterwards.
|
|
3
4
|
|
|
4
5
|
Output exactly one line per changed file, in this format:
|
|
@@ -10,8 +11,10 @@ Rules:
|
|
|
10
11
|
- Describe the functional change (what was added, removed, refactored, or fixed), not file mechanics.
|
|
11
12
|
- Output ONLY these lines. No preamble, no commentary, no code fences, no headings, no blank lines.
|
|
12
13
|
`;
|
|
13
|
-
|
|
14
|
+
var summaryUserPrompt = (diffChunk) => `
|
|
14
15
|
Summarize the changes in this git diff fragment:
|
|
15
16
|
|
|
16
17
|
${diffChunk}
|
|
17
18
|
`;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { summarySystemPrompt, summaryUserPrompt };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/commands/commit/context/systemPrompt.ts
|
|
2
|
+
var systemPrompt = `
|
|
2
3
|
You are a helpful assistant that generates concise, informative Git commit messages.
|
|
3
4
|
|
|
4
5
|
Follow these strict rules:
|
|
@@ -36,3 +37,5 @@ Examples of Bad Commit Messages:
|
|
|
36
37
|
This implements the login page... ❌ (contains multiple lines)
|
|
37
38
|
- "fix: update styling" ❌ (includes quotes)
|
|
38
39
|
`;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { systemPrompt };
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { getConfig } from "../../config.js";
|
|
2
2
|
import { getProvider } from "../../llm/registry.js";
|
|
3
3
|
import { buildCommitPrompt } from "./context/buildPrompt.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
if (!message) {
|
|
18
|
-
throw new Error("No message returned from LLM");
|
|
19
|
-
}
|
|
20
|
-
return message;
|
|
4
|
+
//#region src/commands/commit/generateCommitMessage.ts
|
|
5
|
+
var generateCommitMessage = async (diff, validationErrors) => {
|
|
6
|
+
if (!getConfig().model) throw new Error("GitPT is not configured properly. Please run \"gitpt setup\" first.");
|
|
7
|
+
const { system, user } = buildCommitPrompt(diff, validationErrors);
|
|
8
|
+
const provider = getProvider();
|
|
9
|
+
const message = await provider.complete({
|
|
10
|
+
system,
|
|
11
|
+
user,
|
|
12
|
+
maxTokens: provider.maxOutputTokens
|
|
13
|
+
});
|
|
14
|
+
if (!message) throw new Error("No message returned from LLM");
|
|
15
|
+
return message;
|
|
21
16
|
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { generateCommitMessage };
|