aicommit-joy 0.1.1__tar.gz

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.
@@ -0,0 +1,35 @@
1
+ # 環境變數
2
+ .env
3
+
4
+ # Python 構建產物
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+
12
+ # 虛擬環境
13
+ .venv/
14
+ venv/
15
+ ENV/
16
+ env/
17
+
18
+ # IDE 設定
19
+ .vscode/
20
+ .idea/
21
+ *.swp
22
+ *.swo
23
+ *~
24
+
25
+ # OS 相關
26
+ .DS_Store
27
+ Thumbs.db
28
+
29
+ # PyPI 發布相關
30
+ *.whl
31
+ *.tar.gz
32
+
33
+ # UV 鎖定檔案(可選,看團隊需求)
34
+ # uv.lock
35
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joy
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.
@@ -0,0 +1,290 @@
1
+ Metadata-Version: 2.4
2
+ Name: aicommit-joy
3
+ Version: 0.1.1
4
+ Summary: AI-powered Git commit message generator using Conventional Commits
5
+ Author: Joy
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: ai,aicommit,aicommit-cli,aicommitcli,autocommit,automate,automation,cli,commit,commits,conventional-commits,gemini,git,smartcommit
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Software Development :: Version Control :: Git
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: google-genai>=0.2.2
22
+ Requires-Dist: python-dotenv>=1.0.0
23
+ Description-Content-Type: text/markdown
24
+
25
+ # aicommit 🤖
26
+
27
+ 使用 AI 自動生成符合 Conventional Commits 規範的 Git commit 訊息。
28
+ 使用 Gemini 2.5 Flash-Lite
29
+ 這是速度最快的 Flash 模型,經過最佳化調整,成本效益最高,輸送量也最大。
30
+
31
+ ## ✨ 功能特色
32
+
33
+ - 🤖 **AI 智能生成**:使用 Google Gemini AI 分析程式碼變更,自動生成專業的 commit 訊息
34
+ - ✏️ **手動編輯**:可以編輯 AI 生成的訊息,保留個人風格
35
+ - ✅ **格式驗證**:自動檢查 commit 訊息是否符合 Conventional Commits 規範
36
+ - 🎯 **繁體中文支援**:生成的訊息使用繁體中文描述
37
+ - 🚀 **全域命令**:安裝後可在任何 Git 專案中直接使用
38
+
39
+ ## 📋 安裝需求
40
+
41
+ - Python 3.10+
42
+ - Google Gemini API 金鑰
43
+ - Git
44
+
45
+ ## 🚀 快速開始
46
+
47
+ ### 1. 安裝 aicommit
48
+
49
+ ```bash
50
+ # 使用 pip 安裝
51
+ pip install aicommit-joy
52
+
53
+ # 或使用 pipx(推薦,避免依賴衝突)
54
+ pipx install aicommit-joy
55
+
56
+ # 或使用 uv(最快速)
57
+ uv tool install aicommit-joy
58
+ ```
59
+
60
+ > 💡 **提示**:
61
+ >
62
+ > - 使用 **pipx** 請先執行 `pip install pipx`,參考 [pipx 官方文檔](https://github.com/pypa/pipx)
63
+ > - 使用 **uv** 請先安裝 uv,參考 [uv 官方文檔](https://docs.astral.sh/uv/)
64
+
65
+ ### 2. 設定 API 金鑰
66
+
67
+ 在您的專案目錄建立 `.env` 檔案:
68
+
69
+ ```bash
70
+ echo "GEMINI_API_KEY=your_gemini_api_key_here" > .env
71
+ ```
72
+
73
+ > **如何取得 API 金鑰?**
74
+ > 前往 [Google AI Studio](https://aistudio.google.com/apikey) 免費取得您的 Gemini API 金鑰
75
+
76
+ ### 3. 開始使用
77
+
78
+ ```bash
79
+ # 在任何 Git 專案中
80
+ cd /path/to/your/project
81
+
82
+ # 暫存變更
83
+ git add .
84
+
85
+ # 執行 aicommit
86
+ aicommit
87
+ ```
88
+
89
+ 就這麼簡單!✨
90
+
91
+ ## 📖 使用範例
92
+
93
+ ```bash
94
+ $ cd /path/to/your/project
95
+ $ git add .
96
+ $ aicommit
97
+
98
+ 🤖 AI 正在分析程式碼變更,請稍候...
99
+
100
+ ------------------------------------
101
+ 📝 建議訊息: feat: 新增使用者登入功能
102
+ ------------------------------------
103
+
104
+ 請選擇操作 (y=使用/e=編輯/n=取消): e
105
+
106
+ 請輸入新的 commit 訊息(按 Enter 確認):
107
+ feat: 新增使用者登入功能
108
+ > feat: 新增使用者登入與註冊功能
109
+
110
+ ✅ 訊息格式正確!
111
+ 📝 更新後的訊息: feat: 新增使用者登入與註冊功能
112
+
113
+ 是否提交此訊息? (y/n): y
114
+ ✅ 提交成功!可以使用 git push 上傳
115
+ ```
116
+
117
+ ## 🎯 操作選項
118
+
119
+ 執行 `aicommit` 後,您有三個選項:
120
+
121
+ - **`y`** - 直接使用 AI 生成的訊息提交
122
+ - **`e`** - 編輯訊息後再提交
123
+ - **`n`** - 取消提交
124
+
125
+ ## 📝 Conventional Commits 規範
126
+
127
+ aicommit 遵循 [Conventional Commits](https://www.conventionalcommits.org/) 規範。
128
+
129
+ ### 允許的 Commit Types
130
+
131
+ | Type | 說明 | 範例 |
132
+ | ---------- | -------------------------- | ---------------------------------- |
133
+ | `feat` | 新增功能 | `feat: 新增使用者登入功能` |
134
+ | `fix` | 修復 bug | `fix: 修復登入頁面顯示錯誤` |
135
+ | `docs` | 文件修改 | `docs: 更新 API 文件` |
136
+ | `style` | 格式修改(不影響程式邏輯) | `style: 調整程式碼縮排` |
137
+ | `refactor` | 程式碼重構 | `refactor: 重構資料處理邏輯` |
138
+ | `perf` | 效能優化 | `perf: 優化資料庫查詢效能` |
139
+ | `test` | 測試相關 | `test: 新增登入功能測試` |
140
+ | `build` | 建置系統修改 | `build: 更新依賴套件版本` |
141
+ | `ci` | CI 設定修改 | `ci: 新增 GitHub Actions 工作流程` |
142
+ | `chore` | 雜項修改 | `chore: 更新 .gitignore` |
143
+ | `revert` | 恢復先前提交 | `revert: 恢復登入功能變更` |
144
+
145
+ ### 格式範例
146
+
147
+ ```
148
+ <type>: <subject>
149
+ ```
150
+
151
+ **正確範例**:
152
+
153
+ - ✅ `feat: 新增使用者登入功能`
154
+ - ✅ `fix: 修復登入頁面顯示錯誤`
155
+ - ✅ `docs: 更新 README 安裝說明`
156
+
157
+ **錯誤範例**:
158
+
159
+ - ❌ `feature: 新增功能` (type 錯誤,應為 `feat`)
160
+ - ❌ `feat 新增功能` (缺少冒號)
161
+ - ❌ `feat:` (subject 為空)
162
+
163
+ ## �️ 進階使用
164
+
165
+ ### 查看版本
166
+
167
+ ```bash
168
+ aicommit --version
169
+ ```
170
+
171
+ ### 查看幫助
172
+
173
+ ```bash
174
+ aicommit --help
175
+ ```
176
+
177
+ ### 更新 aicommit
178
+
179
+ ```bash
180
+ # 使用 pip
181
+ pip install --upgrade aicommit-joy
182
+
183
+ # 或使用 pipx
184
+ pipx upgrade aicommit-joy
185
+
186
+ # 或使用 uv
187
+ uv tool upgrade aicommit-joy
188
+ ```
189
+
190
+ ### 卸載 aicommit
191
+
192
+ ```bash
193
+ # 使用 pip
194
+ pip uninstall aicommit-joy
195
+
196
+ # 或使用 pipx
197
+ pipx uninstall aicommit-joy
198
+
199
+ # 或使用 uv
200
+ uv tool uninstall aicommit-joy
201
+ ```
202
+
203
+ ## 🔧 問題排除
204
+
205
+ ### ❌ 找不到 GEMINI_API_KEY
206
+
207
+ ```
208
+ ❌ Error: 找不到 GEMINI_API_KEY
209
+ 請在當前目錄建立 .env 檔案,內容:GEMINI_API_KEY=你的金鑰
210
+ ```
211
+
212
+ **解決方案**:
213
+
214
+ 1. 確認您的專案目錄中有 `.env` 檔案
215
+ 2. 檢查 `.env` 內容格式正確:`GEMINI_API_KEY=your_key_here`
216
+ 3. API 金鑰沒有多餘的引號或空格
217
+
218
+ ### ❌ 沒有偵測到暫存的變更
219
+
220
+ ```
221
+ ⚠️ 沒有偵測到暫存的變更(Staged Changes),如有變更請先執行 git add
222
+ ```
223
+
224
+ **解決方案**:先使用 `git add` 暫存您要提交的變更
225
+
226
+ ```bash
227
+ git add . # 暫存所有變更
228
+ git add file1.py file2.py # 暫存特定檔案
229
+ ```
230
+
231
+ ### ❌ AI 生成失敗
232
+
233
+ ```
234
+ ❌ AI 生成失敗: ...
235
+ ```
236
+
237
+ **可能原因**:
238
+
239
+ - 網路連線問題
240
+ - API 金鑰無效或過期
241
+ - API 配額已用完
242
+ - 變更內容過大
243
+
244
+ **解決方案**:
245
+
246
+ 1. 檢查網路連線
247
+ 2. 確認 API 金鑰有效
248
+ 3. 查看 [Google AI Studio](https://aistudio.google.com/) 配額使用狀況
249
+
250
+ ## 👨‍💻 開發者指南
251
+
252
+ ### 專案結構
253
+
254
+ ```
255
+ aicommit-cli/
256
+ ├── aicommit_cli/ # 主要套件
257
+ │ ├── __init__.py # 套件初始化
258
+ │ ├── core.py # 核心功能(Git、AI、驗證)
259
+ │ └── cli.py # CLI 入口點
260
+ ├── install.sh # 自動安裝腳本
261
+ ├── pyproject.toml # 專案配置
262
+ ├── LICENSE # MIT 授權
263
+ └── README.md # 專案說明
264
+ ```
265
+
266
+ ### 執行測試
267
+
268
+ ```bash
269
+ # 建立測試專案
270
+ cd /tmp
271
+ mkdir test-repo
272
+ cd test-repo
273
+ git init
274
+
275
+ # 建立測試檔案
276
+ echo "# Test" > README.md
277
+ git add README.md
278
+
279
+ # 測試 aicommit
280
+ aicommit
281
+ ```
282
+
283
+ ## 🙏 致謝
284
+
285
+ - [Google Gemini](https://ai.google.dev/) - 提供強大的 AI 能力
286
+ - [Conventional Commits](https://www.conventionalcommits.org/) - 提供 commit 訊息規範
287
+
288
+ ---
289
+
290
+ **享受使用 aicommit 的樂趣!** 🚀
@@ -0,0 +1,139 @@
1
+ # 發布 aicommit-cli 到 PyPI
2
+
3
+ 本文檔說明如何發布 aicommit-cli (套件名稱: `aicommit-cli`) 到 PyPI。
4
+
5
+ ## 前置準備
6
+
7
+ 1. **PyPI 帳號**: https://pypi.org/account/register/
8
+ 2. **API Token**: https://pypi.org/manage/account/token/
9
+ - 建立一個新的 API token
10
+ - 範圍可設為「整個帳號」或「特定專案」
11
+ - 保存好 token(格式:`pypi-...`)
12
+
13
+ ## 發布流程
14
+
15
+ ### 1. 更新版本號
16
+
17
+ 編輯 `pyproject.toml`,更新版本號:
18
+
19
+ ```toml
20
+ version = "0.1.1" # 例如從 0.1.0 升級到 0.1.1
21
+ ```
22
+
23
+ ### 2. 構建套件
24
+
25
+ 使用 `uv` 構建發行套件:
26
+
27
+ ```bash
28
+ uv build
29
+ ```
30
+
31
+ 這會在 `dist/` 目錄生成兩個文件:
32
+
33
+ - `aicommit-cli-x.x.x.tar.gz` (源碼發行版)
34
+ - `aicommit-cli-x.x.x-py3-none-any.whl` (wheel 套件)
35
+
36
+ ### 3. 檢查套件 (可選但推薦)
37
+
38
+ ```bash
39
+ uv tool run twine check dist/*
40
+ ```
41
+
42
+ ### 4. 上傳到 PyPI
43
+
44
+ 使用 API token 上傳:
45
+
46
+ ```bash
47
+ uv tool run twine upload dist/* -u __token__ -p pypi-YOUR_API_TOKEN_HERE
48
+ ```
49
+
50
+ 或者使用互動式輸入(系統會提示輸入用戶名和密碼):
51
+
52
+ ```bash
53
+ uv tool run twine upload dist/*
54
+ # Username: __token__
55
+ # Password: pypi-YOUR_API_TOKEN_HERE
56
+ ```
57
+
58
+ ### 5. 驗證發布
59
+
60
+ 訪問 PyPI 頁面確認:
61
+
62
+ - https://pypi.org/project/aicommit-cli/
63
+
64
+ 測試安裝:
65
+
66
+ ```bash
67
+ pip install aicommit-cli
68
+ aicommit-cli --version
69
+ ```
70
+
71
+ ## 測試發布 (推薦首次使用)
72
+
73
+ 在首次發布前,建議先上傳到 TestPyPI 測試:
74
+
75
+ ### 1. 註冊 TestPyPI 帳號
76
+
77
+ https://test.pypi.org/account/register/
78
+
79
+ ### 2. 建立 TestPyPI API Token
80
+
81
+ https://test.pypi.org/manage/account/token/
82
+
83
+ ### 3. 上傳到 TestPyPI
84
+
85
+ ```bash
86
+ uv tool run twine upload --repository testpypi dist/* -u __token__ -p YOUR_TESTPYPI_TOKEN
87
+ ```
88
+
89
+ ### 4. 從 TestPyPI 安裝測試
90
+
91
+ ```bash
92
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple aicommit-cli
93
+ ```
94
+
95
+ 注意:需要 `--extra-index-url` 因為依賴套件(如 `google-genai`)在正式 PyPI。
96
+
97
+ ## 清理構建產物
98
+
99
+ 發布後可以清理:
100
+
101
+ ```bash
102
+ rm -rf dist/ build/ *.egg-info
103
+ ```
104
+
105
+ ## 版本號規範
106
+
107
+ 遵循 [Semantic Versioning](https://semver.org/):
108
+
109
+ - **MAJOR.MINOR.PATCH** (例如 1.2.3)
110
+ - **MAJOR**: 不兼容的 API 變更
111
+ - **MINOR**: 向後兼容的功能新增
112
+ - **PATCH**: 向後兼容的錯誤修復
113
+
114
+ 範例:
115
+
116
+ - `0.1.0` → `0.1.1`: 錯誤修復
117
+ - `0.1.1` → `0.2.0`: 新增功能
118
+ - `0.2.0` → `1.0.0`: 重大變更或穩定版本
119
+
120
+ ## 常見問題
121
+
122
+ ### 上傳失敗:檔案已存在
123
+
124
+ PyPI 不允許覆蓋已上傳的版本。需要:
125
+
126
+ 1. 更新版本號
127
+ 2. 重新構建
128
+ 3. 再次上傳
129
+
130
+ ### Token 認證失敗
131
+
132
+ 確認:
133
+
134
+ - Username 必須是 `__token__`(兩個底線)
135
+ - Password 是完整的 token(包含 `pypi-` 前綴)
136
+
137
+ ### 依賴套件安裝失敗
138
+
139
+ 確保 `pyproject.toml` 中的依賴版本正確且可用。