VSCode 插件
AI-commit 插件
Github 地址 ,根据提交内容,使用 AI 自动给出 commit 信息
先 clone 下来,初始化
npm init
修改依赖,在 package.json 中 dependencies,
"undici": "^5.28.4",
"@google/generative-ai": "^0.24.0",
以及在 configuration.properties 中,添加一个代理选项
"ai-commit.GEMINI_PROXY_URL": {
"type": "string",
"default": "",
"description": "Gemini API 代理 URL (例如: http://127.0.0.1:7897),留空则不使用代理"
}
在 config.ts 中,export enum ConfigKeys 添加配置
GEMINI_PROXY_URL = 'GEMINI_PROXY_URL',
在 gemini-utils.ts 中,修改
// 导入
import { setGlobalDispatcher, ProxyAgent } from 'undici';
// 函数 getGeminiConfig 中
const proxyUrl = configManager.getConfig<string>(ConfigKeys.GEMINI_PROXY_URL);
// 设置代理
if (proxyUrl) {
const dispatcher = new ProxyAgent({ uri: new URL(proxyUrl).toString() });
setGlobalDispatcher(dispatcher);
}
本地打包使用 vsce 工具
// 全局下载安装
npm i vsce -g
// npm install --save-dev vsce // 或者将 vsce 工具添加到项目的开发依赖中
运行以下命令来构建 VSCode 扩展:
npx vsce package
这将在项目根目录下生成一个名为 xxx.vsix 的 VSIX 文件。即可导入 VSCode 或者 Cursor
最后重启 IDE
references
最后编辑于:2025 年 03 月 15 日 23:30