feat(completion): 基于 DeepSeek FIM 实现行内代码补全 - #223
Open
liuwanwan1 wants to merge 1 commit into
Open
Conversation
Implement inline (ghost text) code completion using the DeepSeek FIM endpoint (https://api-docs.deepseek.com/guides/fim_completion), closing the feature requested in Vizards#83. - Add non-streaming fimCompletion() to DeepSeekClient (/beta/completions on the official endpoint, /completions for compatible providers) - Add DeepSeekInlineCompletionProvider with debounce, cancellation, prefix-continuation caching, and prefix/suffix context window - Register the provider for all files; errors are logged, never shown as popups since completion fires on typing pauses - New settings: completion.enabled (default on), completion.modelId (default deepseek-v4-pro), completion.maxTokens (128), completion.debounceDelay (300ms), with en/zh-cn descriptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
Close #83
背景与思路
Issue #83 希望本扩展支持代码补全。两条可行路线:
因此本 PR 选择路线 2:基于 VS Code 稳定的
InlineCompletionItemProviderAPI(无需 proposed API)+ DeepSeek FIM 接口实现行内补全(幽灵文本,Tab 接受)。实现方案
src/client/core.tsfimCompletion()方法:官方端点请求/beta/completions,自定义 baseUrl 的兼容服务请求/completions;复用现有错误归一化层与AbortController取消机制src/types.tsDeepSeekFimRequest/DeepSeekFimResponse类型src/completion/provider.ts(新增)DeepSeekInlineCompletionProvider:截取光标前 8000 字符为prompt、后 2000 字符为suffix;300ms 防抖 + 取消;前缀延续缓存(用户接受部分建议后继续打字时直接复用剩余建议,不再发起请求)src/runtime/completion.ts(新增)、src/runtime/lifecycle.tssrc/config.ts、package.json、package.nls*.json新增配置项
deepseek-copilot.completion.enabled:是否启用补全,默认 开启,读取于每次请求,开关即时生效无需重启;deepseek-copilot.completion.modelId:FIM 请求模型,默认deepseek-v4-pro(官方 FIM 文档示例所用模型);deepseek-copilot.completion.maxTokens:单次补全最大 token 数,默认 128(FIM 接口上限 4K);deepseek-copilot.completion.debounceDelay:输入停顿后触发请求的延迟,默认 300ms。关键取舍
DeepSeek: 显示日志可查),不打扰用户;maxTokens默认较小;deepseek-v4-pro,flash 是否支持 FIM 未经证实,故默认保守,用户可自行切换。验证
npm run compile、npm run lint通过;npm run format:check全仓库(含未改动的 main)在 Windows 本地均报存量格式问题(疑似 CRLF 检出导致,上游 main 的 CI 为 success),本 PR 新增代码不在其列;后续可拓展(本 PR 不含)