YooooEX's 101 - 编译 Sweep AI IDEA 插件实现代码补全

TL;DR专用 (点击了解更多详细信息) 前言 专注 IDEA 系列的插件 Sweep AI 倒了, 虽然推荐了替代 FireBender , 但为了补全给9$一个月还是感觉贵, 于是就有了这个记录. 官方在 Github 和 huggingface 上放出了对应的插件仓库和模型, 想着跑一下, 要...
YooooEX's 101 - 编译 Sweep AI IDEA 插件实现代码补全
YooooEX's 101 - 编译 Sweep AI IDEA 插件实现代码补全
(点击了解更多详细信息)

前言

discord

专注 IDEA 系列的插件 Sweep AI 倒了, 虽然推荐了替代FireBender, 但为了补全给9$一个月还是感觉贵, 于是就有了这个记录.

官方在 Githubhuggingface 上放出了对应的插件仓库和模型, 想着跑一下, 要是效果可以就能放到token上了买号.

准备施法材料

你需要的材料有:

  • IntelliJ IDEA: 用的 2025.3.4

  • 一个能装载模型的环境: 云端或自己电脑跑

    环境配置如下

    spec

  • 插件仓库: sweepai/jetbrains_plugin

  • 模型: huggingface(用的是sweep-next-edit-1.5B.q8_0,用sweep-next-edit-v2-7B撑不住这么多并发)

编译 IDEA 插件

确认编译环境是否符合要求

plugin-dev-req

把仓库拉下来, 使用 IDEA 打开

调整 gradle 依赖

build.gradle.kts

...
// 插件id, 改id要动逻辑, 懒得动
val pluginId = "dev.sweep.assistant"
// 插件名称
val pluginName = "Sweep AI customization by yooooex"
// 版本号
version = "1.29.3-yooooex"
...
intellijPlatform {
    ...
    pluginVerification {
        // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#target-platforms
        // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-types.html#IntelliJPlatformType
        ides {
            select {
                types.set(listOf(IntelliJPlatformType.WebStorm))
                channels.set(listOf(ProductRelease.Channel.RELEASE))
                // 最低/最高版本支持
                sinceBuild.set("242")
                untilBuild.set("243.*")
            }
            ...
            select {
                types.set(
                    listOf(
                        IntelliJPlatformType.IntellijIdeaUltimate,
                        IntelliJPlatformType.IntellijIdeaCommunity,
                        IntelliJPlatformType.GoLand,
                        IntelliJPlatformType.PyCharmCommunity,
                        IntelliJPlatformType.PyCharmProfessional,
                        IntelliJPlatformType.CLion,
                        IntelliJPlatformType.Rider,
                        IntelliJPlatformType.AndroidStudio,
                        IntelliJPlatformType.RustRover,
                        IntelliJPlatformType.RubyMine,
                        IntelliJPlatformType.PhpStorm,
                    ),
                )
                channels.set(listOf(ProductRelease.Channel.RELEASE))
                // 最低/最高版本支持
                sinceBuild.set("241")
                untilBuild.set("253.*")
            }
        }
    }
}
...
dependencies {
    ...
    intellijPlatform {
        // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html#target-platforms
        // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-types.html#IntelliJPlatformType
        // 使用你的idea版本
        intellijIdeaUltimate("2025.3.4")
    }
    ...
}

编译

调整完配置, 运行 gradle :buildPlugin 编译插件, 产出物位于 build/distributions 下.

部署服务

模型

使用你喜欢的软件跑模型, 这里使用的是LM Studio.

lmstudio

并发要弄高点, 因为 Next Edit 预测的原因, 编辑文件后的光标移动也会触发请求.

转发服务

在对应的地方部署服务

# uvx sweep-autocomplete --help     
# usage: sweep-autocomplete [-h] [--host HOST] [--port PORT]

# Sweep Autocomplete Server

# options:
#   -h, --help   show this help message and exit
#   --host HOST  Bind host (default: 0.0.0.0)
#   --port PORT  Bind port (default: 8081)
uvx sweep-autocomplete --port 8081

sweep-autocomplete 提供以下环境变量配置:

  • NEXT_EDIT_AUTOCOMPLETE_ENDPOINT: 远端地址(/v1/completions), 填写地址即可, 无需补充路径
  • MODEL_REPO: 远端模型repo(huggingface), 默认为 sweepai/sweep-next-edit-0.5B
  • MODEL_FILENAME: 远端模型文件名称, 默认为 sweep-next-edit-0.5b.q8_0.gguf

若在本地部署, 根据环境选择合适的模型即可(MODEL_REPO/MODEL_FILENAME).

转发到其他服务时设置 NEXT_EDIT_AUTOCOMPLETE_ENDPOINT .

在设置了 NEXT_EDIT_AUTOCOMPLETE_ENDPOINT 后, 将忽略本地LLM逻辑(MODEL_REPO/MODEL_FILENAME无效)

插件配置

安装

打开要安装插件的 IDE, 在设置中找到插件页, 点击齿轮图标选择 Install Plugin from Disk 安装.

设置

打开插件设置, 插件设置 Account

根据 转发服务 部署的方式, 选择要填写的数据

  • 远端部署: Sweep API URL 填写 URL
  • 本地模式: 勾选 Enable Local Autocomplete Server

完结

没了, 就是这样, 开始用吧. 有用请给我赞求求了 :tieba_087:

CC BY-NC-SA 4.0 license

1 个帖子 - 1 位参与者

阅读完整话题

来源: linux.do查看原文