GIM 發布新版本了!現在1.3.0版本可用了 可以通過brew upgrade git-intelligence-message
升級。
初次安裝需要先執行
brew tap davelet/gim
GIM 是一個根據git倉庫內文件變更自動生成git提交消息的命令行工具,參考前文《GIM: 根據代碼變更自動生成git提交消息的工具》。
在最近的版本中主要三個新能力:
- 不再依賴rust而是安裝二進制包
- 自動探測新版本并提示更新
- 用戶可自主調整生成提示(AI prompt)
此外還內置了更多大模型的 API 調用地址。
二進制安裝
GIM 不再依賴 rust 環境了,而是通過brew bottle安裝。即下即用,不用編譯安裝,立刻節省5G磁盤。
為了保證效果,推薦重裝:
brew uninstall git-intelligence-message
brew cleanup
brew update
brew install git-intelligence-message
升級 GIM 版本
軟件執行時會主動探測是否有新版本。發現后(會有提示)可以執行
gim update
來升級。如果提示了5次依然沒升級則一個月內不會再提示。
調整AI提示詞
可以自主設置提示詞了。通過命令 gim prompt
查看默認提示詞,通過gim prompt -e
可進行提示詞更新。
完整命令可參考項目文檔 https://github.com/davelet/git-intelligence-message/blob/main/README.md 或者幫助文檔:
gim prompt -h
Manage ai model prompt files. Show content when no options specifiedUsage: gim prompt [OPTIONS]Options:-e, --edit Optional: Edit the prompt files-t, --prompt <PROMPT> Optional: Specify which prompt to edit (d or diff or diff_prompt or subject_prompt)-o, --editor <EDITOR> Optional: Specify the editor to use (e.g., vim, code, nano)-h, --help Print help
內置大模型地址清單
現在內置了一下8中大模型的API地址:
Model Prefix | Service Provider | Default Endpoint |
---|---|---|
gpt-* | OpenAI | https://api.openai.com/v1/chat/completions |
moonshot-* | Moonshot AI | https://api.moonshot.cn/v1/chat/completions |
qwen-* | Alibaba Qwen | https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions |
gemini-* | Google Gemini | https://generativelanguage.googleapis.com/v1beta/openai/ |
doubao-* | ByteDance Doubao | https://ark.cn-beijing.volces.com/api/v3/chat/completions |
glm-* | THUDM GLM | https://open.bigmodel.cn/api/paas/v4/chat/completions |
deepseek-* | DeepSeek | https://api.deepseek.com/chat/completions |
qianfan-* | Baidu Qianfan | https://qianfan.baidubce.com/v2/chat/completions |
所以如果你要用的模型是在這清單里可以不用使用gim ai --url
來配置。
使用流程
- 通過homebrew安裝
- 設置大模型token參考
gim ai -h
- 切換目錄到某個git 倉庫
- 執行
gim -a
(這就是GIM提供的核心能力) - (可選)執行
git push
推送提交
bottle 制作流程
1. 新建 tap 分支
我給 https://github.com/davelet/homebrew-gim 拉了新分支 dep-cargo-install
。這個分支保持通過cargo 安裝。
main
分支后續更新成bottle安裝方式,供用戶使用。
2. 本地使用 tap 新分支
有多種方式切換分支,最直觀的是
cd "$(brew --repo davelet/gim)"
git checkout dep-cargo-install
git pull
brew install --build-bottle davelet/gim/git-intelligence-message
這樣會通過新分支的舊方式安裝軟件。
必須指定參數 --build-bottle 告訴 brew 這個軟件要用來制作bottle
3. 制作 bottle
找個目錄執行
brew bottle git-intelligence-message
會在當前目錄生成一個bottle文件(結尾是 bottle.1.tar.gz
)并提示一段代碼:
bottle dorebuild 1sha256 cellar: :any_skip_relocation, sonoma: "b478f239a65b704c85cc59b1a50fcde797bbbf9c142972c08f529e5bea3f5b7a"end
4. 上傳文件
把上一步生成的文件重命名,里面的 --
改成 -
,上傳到倉庫的Release里面,比如
https://github.com/davelet/git-intelligence-message/releases/tag/v1.2.2
把上傳好的文件鏈接復制出來。
5. 更新 Formulae
最后一步,回到 tap 主分支 https://github.com/davelet/homebrew-gim/blob/main/Formula/git-intelligence-message.rb ,把這個文件里的 depends_on
那一行刪掉,改成第三步的代碼。
然后在 bottle do
這個塊里增加root_url
,值就是上一步復制的地址去掉最后的文件名。
大功告成。
最后的小提示:源文件計算sha256
shasum -a 256 <下載到本地的tar.gz>