qkpr 0.0.11

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.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 KazooTTT <work@kazoottt.top>
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,278 @@
1
+ # qkpr
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![License][license-src]][license-href]
6
+
7
+ Create a Pull Request with interactive branch selection
8
+ ## Usage Demo
9
+
10
+ quick create pr with interactive branch selection
11
+
12
+ ![](docs/images/demo.gif)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ # Using npm
18
+ npm install -g qkpr
19
+
20
+ # Using pnpm
21
+ pnpm add -g qkpr
22
+
23
+ # Using yarn
24
+ yarn global add qkpr
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Interactive Menu
30
+
31
+ Navigate to your git repository and run:
32
+
33
+ ```bash
34
+ qkpr
35
+ ```
36
+
37
+ The CLI will show an interactive menu where you can choose from all available features:
38
+
39
+ - 🔧 Create Pull Request
40
+ - 🤖 Generate Commit Message
41
+ - 🌿 Generate Branch Name
42
+ - ⚙️ Configure API Key
43
+ - 🔧 Configure Model
44
+
45
+ ### Create Pull Request
46
+
47
+ You can directly access the PR creation feature:
48
+
49
+ ```bash
50
+ qkpr pr
51
+ ```
52
+
53
+ The CLI will interactively guide you through creating a pull request:
54
+
55
+ 1. **Repository Detection**: Automatically detects the current Git repository
56
+ 2. **Branch Selection**: Interactively select the target branch with search functionality
57
+ 3. **PR Generation**: Generates a standardized PR description with commit summaries
58
+ 4. **Clipboard Integration**: Copies the PR description to your clipboard
59
+ 5. **Browser Launch**: Opens the PR page in your default browser
60
+ 6. **Merge Branch**: Optionally creates a suggested merge branch for conflict resolution
61
+
62
+ ### AI-Powered Commit Message Generation
63
+
64
+ Generate commit messages automatically using AI:
65
+
66
+ ```bash
67
+ qkpr commit
68
+ ```
69
+
70
+ Features:
71
+
72
+ - 🤖 **AI-Powered**: Uses Google Gemini 2.0 Flash to analyze your changes
73
+ - 📝 **Angular Convention**: Follows Angular commit message standards
74
+ - 🌿 **Branch Name Suggestion**: Suggests appropriate branch names based on changes
75
+ - 🎯 **Smart Analysis**: Analyzes staged changes (git diff --cached)
76
+ - ✅ **Interactive**: Choose to commit, copy, or regenerate
77
+
78
+ #### First Time Setup
79
+
80
+ 1. Get your Gemini API Key from [Google AI Studio](https://aistudio.google.com/apikey)
81
+ 2. Configure your API key (choose one method):
82
+
83
+ - **Method 1**: Using config command
84
+
85
+ ```bash
86
+ qkpr config
87
+ ```
88
+
89
+ - **Method 2**: Using environment variable
90
+
91
+ ```bash
92
+ export QUICK_PR_GEMINI_API_KEY=your_api_key_here
93
+ # or use the legacy variable name
94
+ export GEMINI_API_KEY=your_api_key_here
95
+ ```
96
+
97
+ Or the tool will prompt you to enter it on first use.
98
+
99
+ #### Model Configuration
100
+
101
+ By default, the tool uses `gemini-2.0-flash`. You can configure a different model:
102
+
103
+ ```bash
104
+ qkpr config:model
105
+ ```
106
+
107
+ The tool will:
108
+
109
+ 1. **Dynamically fetch** all available models from Google's API (if API key is configured)
110
+ 2. Display a list of models to choose from
111
+ 3. Allow custom model name input
112
+
113
+ Common Gemini models include (updated 2025.11.17, fetched from Google API):
114
+
115
+ **Common Gemini Models:**
116
+
117
+ - `gemini-2.5-pro`
118
+ - `gemini-2.5-flash`
119
+ - `gemini-2.0-flash` (default)
120
+ - `gemini-2.0-flash-exp`
121
+ - `gemini-flash-latest`
122
+
123
+ You can also set the model via environment variable:
124
+
125
+ ```bash
126
+ export QUICK_PR_GEMINI_MODEL=gemini-2.5-pro
127
+ # or use the legacy variable name
128
+ export GEMINI_MODEL=gemini-2.5-pro
129
+ ```
130
+
131
+ #### Workflow Example
132
+
133
+ ```bash
134
+ # Stage your changes
135
+ git add .
136
+
137
+ # Generate commit message
138
+ qkpr commit
139
+
140
+ # The tool will:
141
+ # 1. Analyze your staged changes
142
+ # 2. Generate a commit message following Angular conventions
143
+ # 3. Suggest a branch name
144
+ # 4. Ask if you want to commit, copy to clipboard, or regenerate
145
+ ```
146
+
147
+ ## Features
148
+
149
+ ### Pull Request Creation
150
+
151
+ - 🔧 **Interactive Branch Selection**: Choose target branch with search functionality
152
+ - 📌 **Protected Branches**: Highlights and pins important branches (main, master, etc.)
153
+ - 🗂️ **Smart Categorization**: Groups branches by prefix (feat/, fix/, merge/, etc.)
154
+ - ⏰ **Time Display**: Shows last commit time for each branch
155
+ - 📋 **Auto-Generated PR Description**: Includes commit summaries and formatted content
156
+ - 📋 **Clipboard Integration**: Automatically copies PR description to clipboard
157
+ - 🌐 **Browser Integration**: Opens PR comparison page automatically
158
+ - 🔄 **Merge Branch Suggestion**: Offers to create a merge resolution branch
159
+ - 🏷️ **Multi-Platform Support**: Compatible with GitHub, GitLab, and Gitee
160
+
161
+ ### AI Commit Messages
162
+
163
+ - 🤖 **Gemini AI**: Powered by Google Gemini 2.0 Flash
164
+ - 📝 **Angular Convention**: Follows industry-standard commit message format
165
+ - 🌿 **Branch Naming**: Suggests semantic branch names
166
+ - 🔍 **Smart Analysis**: Analyzes git diff to understand changes
167
+ - 💾 **Secure Storage**: API key stored locally in `~/.qkpr/config.json`
168
+
169
+ ### Other Features
170
+
171
+ - 🔄 **Auto Update Check**: Notifies when new version is available
172
+ - ⚙️ **Easy Configuration**: Simple setup for API keys
173
+ - 🎨 **Beautiful UI**: Colorful and intuitive terminal interface
174
+
175
+ ## Available Commands
176
+
177
+ ### Interactive Menu (Default)
178
+
179
+ ```bash
180
+ qkpr
181
+ ```
182
+
183
+ Shows an interactive menu to choose from all available features
184
+
185
+ ### Create PR
186
+
187
+ ```bash
188
+ qkpr pr
189
+ ```
190
+
191
+ Directly create a pull request with interactive branch selection
192
+
193
+ ### Generate Commit Message
194
+
195
+ ```bash
196
+ qkpr commit
197
+ ```
198
+
199
+ Directly generate commit message using AI (requires Gemini API key)
200
+
201
+ ### Generate Branch Name
202
+
203
+ ```bash
204
+ qkpr branch
205
+ ```
206
+
207
+ Directly generate a semantic branch name based on your staged changes using AI (requires Gemini API key)
208
+
209
+ ### Configuration
210
+
211
+ ```bash
212
+ qkpr config
213
+ ```
214
+
215
+ Configure Gemini API key for AI features
216
+
217
+ ```bash
218
+ qkpr config:model
219
+ ```
220
+
221
+ Configure Gemini model for AI commit message generation
222
+
223
+ ### Version
224
+
225
+ ```bash
226
+ qkpr --version
227
+ # or
228
+ qkpr -v
229
+ ```
230
+
231
+ ### Help
232
+
233
+ ```bash
234
+ qkpr --help
235
+ # or
236
+ qkpr -h
237
+ ```
238
+
239
+ ## Requirements
240
+
241
+ - `git` version 2.0+
242
+ - Node.js version 18+
243
+ - Gemini API key (for AI commit feature) - Get it from [Google AI Studio](https://aistudio.google.com/apikey)
244
+
245
+ ## License
246
+
247
+ [MIT](./LICENSE) License © [KazooTTT](https://github.com/kazoottt)
248
+
249
+ ## Contributing
250
+
251
+ Contributions, issues, and feature requests are welcome!
252
+
253
+ ## Note for Developers
254
+
255
+ This project uses pnpm workspaces and tsdown for building. For development:
256
+
257
+ ```bash
258
+ # Install dependencies
259
+ pnpm install
260
+
261
+ # Build the project
262
+ pnpm run build
263
+
264
+ # Run tests
265
+ pnpm run test
266
+
267
+ # Lint
268
+ pnpm run lint
269
+ ```
270
+
271
+ <!-- Badges -->
272
+
273
+ [npm-version-src]: https://img.shields.io/npm/v/qkpr?style=flat&colorA=080f12&colorB=1fa669
274
+ [npm-version-href]: https://npmjs.com/package/qkpr
275
+ [npm-downloads-src]: https://img.shields.io/npm/dm/qkpr?style=flat&colorA=080f12&colorB=1fa669
276
+ [npm-downloads-href]: https://npmjs.com/package/qkpr
277
+ [license-src]: https://img.shields.io/github/license/kazoottt/qkpr.svg?style=flat&colorA=080f12&colorB=1fa669
278
+ [license-href]: https://github.com/kazoottt/qkpr/blob/main/LICENSE.md
@@ -0,0 +1,278 @@
1
+ # qkpr
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![License][license-src]][license-href]
6
+
7
+ 通过交互式分支选择创建 Pull Request 的 CLI 工具
8
+ ## 功能演示
9
+
10
+ 快速创建带有交互式分支选择的 PR
11
+
12
+ ![](docs/images/demo.gif)
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ # 使用 npm
18
+ npm install -g qkpr
19
+
20
+ # 使用 pnpm
21
+ pnpm add -g qkpr
22
+
23
+ # 使用 yarn
24
+ yarn global add qkpr
25
+ ```
26
+
27
+ ## 使用方法
28
+
29
+ ### 交互式菜单
30
+
31
+ 导航到你的 Git 仓库并运行:
32
+
33
+ ```bash
34
+ qkpr
35
+ ```
36
+
37
+ CLI 将显示一个交互式菜单,你可以从中选择所有可用的功能:
38
+
39
+ - 🔧 创建 Pull Request
40
+ - 🤖 生成提交消息
41
+ - 🌿 生成分支名称
42
+ - ⚙️ 配置 API 密钥
43
+ - 🔧 配置模型
44
+
45
+ ### 创建 Pull Request
46
+
47
+ 你可以直接访问 PR 创建功能:
48
+
49
+ ```bash
50
+ qkpr pr
51
+ ```
52
+
53
+ CLI 将通过交互方式指导你创建 Pull Request:
54
+
55
+ 1. **仓库检测**:自动检测当前 Git 仓库
56
+ 2. **分支选择**:通过搜索功能交互式选择目标分支
57
+ 3. **PR 生成**:生成包含提交摘要的标准化 PR 描述
58
+ 4. **剪贴板集成**:将 PR 描述复制到你的剪贴板
59
+ 5. **浏览器启动**:在你的默认浏览器中打开 PR 页面
60
+ 6. **合并分支**:可选地创建建议的合并分支用于冲突解决
61
+
62
+ ### AI 驱动的提交消息生成
63
+
64
+ 使用 AI 自动生成提交消息:
65
+
66
+ ```bash
67
+ qkpr commit
68
+ ```
69
+
70
+ 功能特性:
71
+
72
+ - 🤖 **AI 驱动**:使用 Google Gemini 2.0 Flash 分析你的变更
73
+ - 📝 **Angular 约定**:遵循 Angular 提交消息标准
74
+ - 🌿 **分支名称建议**:基于变更建议适当的分支名称
75
+ - 🎯 **智能分析**:分析暂存的变更(`git diff --cached`)
76
+ - ✅ **交互式**:选择提交、复制或重新生成
77
+
78
+ #### 首次设置
79
+
80
+ 1. 从 [Google AI Studio](https://aistudio.google.com/apikey) 获取你的 Gemini API 密钥
81
+ 2. 配置你的 API 密钥(选择一种方法):
82
+
83
+ - **方法 1**:使用配置命令
84
+
85
+ ```bash
86
+ qkpr config
87
+ ```
88
+
89
+ - **方法 2**:使用环境变量
90
+
91
+ ```bash
92
+ export QUICK_PR_GEMINI_API_KEY=your_api_key_here
93
+ # 或者使用旧版变量名
94
+ export GEMINI_API_KEY=your_api_key_here
95
+ ```
96
+
97
+ 或者工具会在首次使用时提示你输入。
98
+
99
+ #### 模型配置
100
+
101
+ 默认情况下,工具使用 `gemini-2.0-flash`。你可以配置不同的模型:
102
+
103
+ ```bash
104
+ qkpr config:model
105
+ ```
106
+
107
+ 工具将:
108
+
109
+ 1. **动态获取** Google API 中所有可用模型(如果已配置 API 密钥)
110
+ 2. 显示模型列表供选择
111
+ 3. 允许自定义模型名称输入
112
+
113
+ 常见的 Gemini 模型包括(更新于 2025.11.17,从 Google API 获取):
114
+
115
+ **常见 Gemini 模型:**
116
+
117
+ - `gemini-2.5-pro`
118
+ - `gemini-2.5-flash`
119
+ - `gemini-2.0-flash`(默认)
120
+ - `gemini-2.0-flash-exp`
121
+ - `gemini-flash-latest`
122
+
123
+ 你也可以通过环境变量设置模型:
124
+
125
+ ```bash
126
+ export QUICK_PR_GEMINI_MODEL=gemini-2.5-pro
127
+ # 或者使用旧版变量名
128
+ export GEMINI_MODEL=gemini-2.5-pro
129
+ ```
130
+
131
+ #### 工作流示例
132
+
133
+ ```bash
134
+ # 暂存你的变更
135
+ git add .
136
+
137
+ # 生成提交消息
138
+ qkpr commit
139
+
140
+ # 工具将:
141
+ # 1. 分析你的暂存变更
142
+ # 2. 生成遵循 Angular 约定的提交消息
143
+ # 3. 建议分支名称
144
+ # 4. 询问你是否要提交、复制到剪贴板或重新生成
145
+ ```
146
+
147
+ ## 功能特性
148
+
149
+ ### Pull Request 创建
150
+
151
+ - 🔧 **交互式分支选择**:通过搜索功能选择目标分支
152
+ - 📌 **受保护分支**:高亮和固定重要分支(main、master 等)
153
+ - 🗂️ **智能分类**:按前缀分组分支(feat/、fix/、merge/ 等)
154
+ - ⏰ **时间显示**:显示每个分支的最后提交时间
155
+ - 📋 **自动生成的 PR 描述**:包含提交摘要和格式化内容
156
+ - 📋 **剪贴板集成**:自动将 PR 描述复制到剪贴板
157
+ - 🌐 **浏览器集成**:自动打开 PR 比较页面
158
+ - 🔄 **合并分支建议**:提供创建合并解决分支的选项
159
+ - 🏷️ **多平台支持**:兼容 GitHub、GitLab 和 Gitee
160
+
161
+ ### AI 提交消息
162
+
163
+ - 🤖 **Gemini AI**:由 Google Gemini 2.0 Flash 驱动
164
+ - 📝 **Angular 约定**:遵循行业标准的提交消息格式
165
+ - 🌿 **分支命名**:建议语义化分支名称
166
+ - 🔍 **智能分析**:分析 git diff 以了解变更
167
+ - 💾 **安全存储**:API 密钥本地存储在 `~/.qkpr/config.json`
168
+
169
+ ### 其他功能
170
+
171
+ - 🔄 **自动更新检查**:新版本可用时通知
172
+ - ⚙️ **简单配置**:API 密钥的简单设置
173
+ - 🎨 **美观界面**:彩色直观的终端界面
174
+
175
+ ## 可用命令
176
+
177
+ ### 交互式菜单(默认)
178
+
179
+ ```bash
180
+ qkpr
181
+ ```
182
+
183
+ 显示交互式菜单以选择所有可用功能
184
+
185
+ ### 创建 PR
186
+
187
+ ```bash
188
+ qkpr pr
189
+ ```
190
+
191
+ 通过交互式分支选择直接创建 Pull Request
192
+
193
+ ### 生成提交消息
194
+
195
+ ```bash
196
+ qkpr commit
197
+ ```
198
+
199
+ 使用 AI 直接生成提交消息(需要 Gemini API 密钥)
200
+
201
+ ### 生成分支名称
202
+
203
+ ```bash
204
+ qkpr branch
205
+ ```
206
+
207
+ 使用 AI 基于你的暂存变更直接生成语义化分支名称(需要 Gemini API 密钥)
208
+
209
+ ### 配置
210
+
211
+ ```bash
212
+ qkpr config
213
+ ```
214
+
215
+ 为 AI 功能配置 Gemini API 密钥
216
+
217
+ ```bash
218
+ qkpr config:model
219
+ ```
220
+
221
+ 配置用于 AI 提交消息生成的 Gemini 模型
222
+
223
+ ### 版本
224
+
225
+ ```bash
226
+ qkpr --version
227
+ # 或者
228
+ qkpr -v
229
+ ```
230
+
231
+ ### 帮助
232
+
233
+ ```bash
234
+ qkpr --help
235
+ # 或者
236
+ qkpr -h
237
+ ```
238
+
239
+ ## 系统要求
240
+
241
+ - `git` 版本 2.0+
242
+ - Node.js 版本 18+
243
+ - Gemini API 密钥(用于 AI 提交功能)- 从 [Google AI Studio](https://aistudio.google.com/apikey) 获取
244
+
245
+ ## 许可证
246
+
247
+ [MIT](./LICENSE) 许可证 © [KazooTTT](https://github.com/kazoottt)
248
+
249
+ ## 贡献
250
+
251
+ 欢迎贡献、问题反馈和功能请求!
252
+
253
+ ## 开发者注意事项
254
+
255
+ 此项目使用 pnpm 工作区和 tsdown 进行构建。开发环境:
256
+
257
+ ```bash
258
+ # 安装依赖
259
+ pnpm install
260
+
261
+ # 构建项目
262
+ pnpm run build
263
+
264
+ # 运行测试
265
+ pnpm run test
266
+
267
+ # 代码检查
268
+ pnpm run lint
269
+ ```
270
+
271
+ <!-- Badges -->
272
+
273
+ [npm-version-src]: https://img.shields.io/npm/v/qkpr?style=flat&colorA=080f12&colorB=1fa669
274
+ [npm-version-href]: https://npmjs.com/package/qkpr
275
+ [npm-downloads-src]: https://img.shields.io/npm/dm/qkpr?style=flat&colorA=080f12&colorB=1fa669
276
+ [npm-downloads-href]: https://npmjs.com/package/qkpr
277
+ [license-src]: https://img.shields.io/github/license/kazoottt/qkpr.svg?style=flat&colorA=080f12&colorB=1fa669
278
+ [license-href]: https://github.com/kazoottt/qkpr/blob/main/LICENSE.md
@@ -0,0 +1 @@
1
+ export { };