基于 DeepSeek 模型的 VS Code 智能编码助手 —— AI-powered VS Code extension for intelligent code assistance
集成 AI 对话、内联代码补全、代码审查、工具调用、Token 统计等全方位开发辅助能力
AI chat, inline completions, code review, tool system, token stats & more
📋 目录 Table of Contents
✨ 功能特性 Features
🤖 AI 对话 AI Chat
| 功能 Feature |
说明 Description |
| DeepSeek 模型接入 DeepSeek Models |
支持 deepseek-chat(通用对话与代码)和 deepseek-reasoner(推理增强)模型 / deepseek-chat (general/code) and deepseek-reasoner (enhanced reasoning) |
| 流式输出 Streaming Output |
SSE 逐字实时响应,可随时中止生成(Stop 按钮 / Esc 键)/ Real-time SSE responses, abort anytime |
| 推理链渲染 Reasoning Chain |
deepseek-reasoner 的思维链内容可折叠展示 / Collapsible reasoning chain display |
| 上下文管理 Context Management |
滑动窗口裁剪 + 自动摘要压缩,支持 1M token 上下文窗口 / Sliding window trim + auto-summarization, 1M token window |
| 对话历史持久化 History Persistence |
自动保存到磁盘,支持多会话管理(新建/切换/重命名/删除/搜索)/ Auto-saved, multi-session management |
| 消息编辑 Message Editing |
支持编辑历史用户消息或 AI 回复,编辑后可重新生成 / Edit past messages; re-trigger AI after editing |
| 重新生成 Regenerate |
一键重新生成 AI 回复 / One-click regenerate AI responses |
| @ 引用上下文 @ Context References |
输入 @file:、@folder:、@symbol: 引用工作区文件 / Type @file:, @folder:, @symbol: to reference workspace files |
| 文件上传 File Upload |
支持拖拽或选择器上传代码、文本、图片等文件 / Drag-and-drop or picker upload for code, text, images |
| 斜杠命令 Slash Commands |
内置 /fix、/explain、/optimize、/test、/comment、/clear、/help 等快捷命令 / Built-in quick commands |
在编辑器中选中代码后右键 → DeepSeek AI 子菜单 —— Select code → Right click → DeepSeek AI submenu
| 操作 Action |
说明 Description |
| 💡 解释代码 Explain Code |
用自然语言解释选中代码的功能和逻辑 / Explain selected code in natural language |
| ⚡ 优化代码 Optimize Code |
对代码进行性能和可读性优化建议 / Suggest performance & readability improvements |
| 📝 生成注释 Add Comments |
自动生成注释和文档 / Auto-generate comments and documentation |
| 🐛 修复问题 Fix Issues |
分析代码中的潜在 Bug 并给出修复方案 / Analyze code for bugs and suggest fixes |
| 🧪 生成测试 Generate Tests |
基于选中函数/类自动生成单元测试 / Generate unit tests for selected function/class |
⌨️ 内联代码补全 Inline Completions
- 幽灵文本(Ghost Text):输入代码时自动显示灰色补全建议 / Auto-display gray completion suggestions as you type
- Tab 接受,Esc 忽略 / Tab to accept, Esc to dismiss
- 自动触发:输入过程防抖(默认 200ms)、换行后预测下一行 / Debounced auto-trigger (200ms), predicts after newline
- 手动触发:快捷键
Alt+\ 随时触发 / Manual trigger with Alt+\
- 智能去重:自动跳过光标后已有的代码 / Skips code already present after cursor
- 支持所有编程语言 / All languages supported
- 配置项:启用/禁用、最大行数、延迟时间、快捷键 / Configurable: enable/disable, max lines, delay, shortcut
注册了 28 个工具,支持文件读写、Shell 执行、Git 操作、网络搜索、任务管理、REPL 等能力
28 registered tools for file ops, shell, Git, web search, tasks, REPL, and more
| 类别 Category |
工具 Tools |
权限 Permission |
| 文件 Files |
read_file, list_dir, glob_workspace, grep_workspace, write_file, edit_file |
readonly / workspace-write |
| Git |
git_log, git_diff, git_status, git_show, git_blame |
readonly |
| Shell |
bash, powershell |
danger |
| 网络 Web |
web_search, web_fetch |
danger |
| 任务 Tasks |
task_create, task_get, task_list, task_stop, task_update, task_output |
mixed |
| REPL |
repl, repl_session_list |
danger |
| 其他 Other |
structured_output, ask_user_question, notebook_edit, pdf_extract, sleep, config 等 |
mixed |
权限与安全 Permissions & Security
- 五级权限 5 levels:
readonly → workspace-write → danger → prompt → allow
- 三种模式 3 modes: default(弹窗确认 / confirm dialog)、auto(启发式判断 / heuristic)、bypass(跳过 / skip)
- 危险命令防护:内置危险命令黑名单(
rm -rf /、sudo、curl | bash 等),自动检测并拦截 / Built-in dangerous command blacklist
- 路径逃逸检测:写文件时验证路径在工作区内 / Validates file paths are within workspace
- Trust Mode:支持自定义信任规则,会话级临时信任 / Custom trust rules, session-level temporary trust
- 审计日志:记录所有权限决策,最多 100 条 / Records all permission decisions (max 100)
📊 Token 消耗统计 Token Usage Stats
- 每日/每月统计 Daily/monthly stats: 按时间维度查看 Token 用量 / Token usage by time dimension
- 操作类型归因 Operation attribution: 区分 chat、explain、optimize、fix、test 等操作 / Breakdown by operation type
- 会话归因 Session attribution: 查看每个会话的消耗详情 / Per-session consumption details
- 每日趋势图 Daily trend chart: 柱状图展示近 7/30 天趋势 / Bar chart showing 7/30 day trends
- 余额查询 Balance inquiry: 调用 DeepSeek API 查询账户余额 / Check balance via DeepSeek API
- 价格计算 Cost calculation: 自动按官方定价换算预估费用 / Auto-calculated estimated fees
- 告警机制 Alerts: 日/月用量阈值告警 / Daily/monthly threshold warnings
- 状态栏显示 Status bar: 实时显示今日 Token 用量(自动格式化 k/M)/ Real-time today's token usage (auto-formatted)
- 三档定价 3-tier pricing: 缓存命中 / 缓存未命中 / 输出,分别计价 / Cache hit / miss / output, priced separately
⚙️ 设置面板 Settings Panel
独立的设置 Webview 面板,分为多个区段 —— Standalone settings Webview panel with multiple sections
| 区段 Section |
配置项 Settings |
| 🔑 API 配置 API Config |
API Key、API Endpoint |
| 🤖 模型配置 Model Config |
模型选择、Temperature、Top P、Max Tokens / Model selection, Temperature, Top P, Max Tokens |
| ✏️ 内联补全 Inline Completion |
启用/禁用、最大行数、延迟、快捷键 / Enable/disable, max lines, delay, shortcut |
| 📂 上下文与 RAG Context & RAG |
自动文件数、RAG 开关 / Auto file count, RAG toggle |
| 🌐 输出语言 Output Language |
7 种语言选择 / 7 language options |
| 📎 文件上传 File Upload |
大小限制 / Size limit |
| 🔔 Token 告警 Token Alerts |
日/月告警阈值 / Daily/monthly warning thresholds |
| 🔒 隐私与安全 Privacy & Security |
隐私模式、数据脱敏 / Privacy mode, data sanitization |
| 🐛 调试与日志 Debug & Logging |
调试开关、日志级别 / Debug toggle, log level |
| 💾 外部存储 External Storage |
存储后端、Gist Token、自动同步 / Storage backend, Gist Token, auto sync |
支持 测试 API 连接 和 在线获取模型列表 —— Supports API connection test and online model list fetching
🚀 快速开始 Quick Start
安装 Installation
从 VS Code 扩展市场搜索 DeepSeek AI Coder 并安装,或从 VSIX 文件手动安装。
Search DeepSeek AI Coder in VS Code marketplace or install from VSIX file.
- 点击 VS Code 右侧活动栏的 DeepSeek 图标 / Click the DeepSeek icon in VS Code's right activity bar
- 点击聊天面板标题栏的 ⚙️ 齿轮按钮打开设置 / Click the ⚙️ gear button in the chat panel
- 在 API 配置 中输入你的 DeepSeek API Key / Enter your DeepSeek API Key under API Config
- 点击「测试连接」验证是否配置成功 / Click "Test Connection" to verify
- 选择你需要的模型(
deepseek-chat 或 deepseek-reasoner) / Select your model
💡 你也可以通过 VS Code 设置直接配置:Ctrl+, → 搜索 deepseek-ai-coder.apiKey
You can also configure via VS Code settings: Ctrl+, → search deepseek-ai-coder.apiKey
开始使用 Start Using
配置完成后,点击状态栏右下角的 🤖 DeepSeek 按钮,或按 Shift+Alt+I 打开聊天面板,即可开始与 AI 对话。
Click the 🤖 DeepSeek button in the status bar, or press Shift+Alt+I to open the chat panel and start chatting.
🖥️ 界面预览 UI Preview
┌─────────────────────────────────────────────────────────────┐
│ 次要侧边栏 (右侧) Secondary Sidebar (Right) │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ 🤖 DeepSeek AI Coder 🗑️ ⚙️ │ │
│ ├──────────────────────────────────────────────────────┤ │
│ │ ┌──────────────────────────────────────────────────┐│ │
│ │ │ 💬 Chat 📊 Token Stats ││ │
│ │ └──────────────────────────────────────────────────┘│ │
│ │ │ │
│ │ 快捷命令 Quick cmds: /fix /explain /optimize /test │ │
│ │ │ │
│ │ ┌──────────────────────────────────────────────┐ │ │
│ │ │ 👤 你 You 昨天 Yesterday │ │ │
│ │ │ 帮我解释这段 React 代码的工作原理 │ │ │
│ │ └──────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ ┌──────────────────────────────────────────────┐ │ │
│ │ │ 🤖 DeepSeek 00:02.3s │ │ │
│ │ │ 这是一段 React 函数组件代码... │ │ │
│ │ │ │ │ │
│ │ │ 📥 In: 342 📤 Out: 1,256 💰 ¥0.0032 │ │ │
│ │ │ 🎯 Cache: 120 (saved 51%) │ │ │
│ │ └──────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ Context: 📄 src/App.tsx 📄 src/utils/ ✕ │ │
│ │ │ │
│ │ ┌──────────────────────────────────────────────┐ │ │
│ │ │ / Type msg, @ ref file, ↑↓ history... │ │ │
│ │ └──────────────────────────────────────────────┘ │ │
│ │ 📎 🎤 ➡️ │ │
│ ├──────────────────────────────────────────────────────┤ │
│ │ Context: 12.4k / 128k tokens ████████░░░░ 12% │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
💬 使用指南 Usage Guide
1. 💬 AI 对话 AI Chat
打开聊天面板后,你可以 —— Once the chat panel is open, you can:
- 自由对话 Free chat: 直接输入问题,AI 会结合上下文回答 / Simply type your question; AI responds with context awareness
- 斜杠命令 Slash commands: 输入
/ 快速触发常用操作 / Type / for quick actions
/fix 帮我修复这个 bug fix this bug
/explain 解释这段代码 explain this code
/optimize 优化这个函数 optimize this function
/test 生成测试用例 generate test cases
- 引用文件 File references: 输入
@ 搜索并引用工作区文件 / Type @ to reference workspace files
@file:src/utils/helpers.ts
@folder:src/components/
@symbol:UserService
- 上传文件 File upload: 拖拽文件到输入框,或点击 📎 按钮选择文件 / Drag files or click 📎 to upload
- 编辑消息 Edit messages: 鼠标悬停在历史消息上,点击 ✏️ 按钮编辑 / Hover over a message and click ✏️
- 重新生成 Regenerate: 点击 AI 回复下方的 🔄 按钮重新生成 / Click 🔄 below AI responses
- 管理会话 Session management: 左侧会话栏可新建、切换、重命名、删除、搜索对话 / Create, switch, rename, delete, search sessions
- 在编辑器中选中一段代码 / Select code in the editor
- 右键 → DeepSeek AI → 选择操作 / Right-click → DeepSeek AI → Choose an action
- 聊天面板自动打开,AI 开始处理 / Chat panel opens, AI starts processing
- 查看结果,可继续追问或调整 / View results; continue asking or refine
示例 Example:
// 选中年函数,右键 → DeepSeek AI → 💡 解释代码
// Select the function, right-click → DeepSeek AI → 💡 Explain Code
function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
AI 会解释这是斐波那契数列的递归实现,并指出性能问题。
AI will explain this is a recursive Fibonacci implementation and point out performance issues.
3. ⌨️ 内联代码补全 Inline Completion
直接在编辑器中输入代码,AI 会自动以灰色幽灵文本显示补全建议:
Type code in the editor; AI shows gray ghost text suggestions:
// 输入 Type:
function greet(name) {
// 自动出现灰色补全 Auto ghost text:
// return `Hello, ${name}!`;
}
// Tab 接受 accept, Esc 忽略 dismiss
- 自动触发 Auto-trigger: 输入过程中自动显示(默认延迟 200ms)/ Shows during typing (default 200ms debounce)
- 手动触发 Manual trigger: 按
Alt+\ 强制触发 / Press Alt+\ anytime
- 设置 Settings: 可在设置面板中调整最大行数、延迟时间、快捷键等 / Adjust max lines, delay, shortcut in settings
在对话中,AI 可以自动使用工具完成复杂任务:
During conversations, AI can automatically use tools to complete complex tasks:
文件操作 File ops:
用户 User: 读取 src/config.ts 文件并解释配置项
AI: 调用 read_file 工具读取文件,然后分析内容 / calls read_file, then analyzes
Git 操作 Git ops:
用户 User: 查看最近的 5 次提交记录
AI: 调用 git_log 工具获取提交历史 / calls git_log to get history
Shell 命令 Shell commands:
用户 User: 帮我找出项目中最大的 10 个文件
AI: 调用 bash 工具执行查找命令 / calls bash to execute search
网络搜索 Web search:
用户 User: 搜索 React 19 的新特性
AI: 调用 web_search 工具获取最新信息 / calls web_search for latest info
⚠️ 工具执行需要你的授权确认(默认模式),所有文件写入和命令执行都有安全审计。
Tool execution requires your authorization (default mode); all file writes and commands are audited.
5. 📊 Token 消耗统计 Token Stats
在右侧侧边栏切换到 Token Stats 标签页 —— Switch to the Token Stats tab in the right sidebar:
- 概览卡片 Overview cards: 今日请求数、输入/输出 Token、缓存命中率、预估费用 / Today's requests, I/O tokens, cache hit rate, estimated cost
- 每日趋势 Daily trend: 柱状图展示 7/30 天用量趋势 / Bar chart showing 7/30 day usage trends
- 操作归因 Operation attribution: 按操作类型查看消耗分布 / Breakdown by operation type
- 会话归因 Session attribution: 查看每个会话的 Token 消耗详情 / Per-session token details
- 余额查询 Balance: 点击「查询余额」查看账户余额 / Click "Check Balance" to view balance
状态栏也实时显示今日 Token 用量,鼠标悬停可查看详细信息。
The status bar also shows today's token usage in real-time; hover for details.
6. ⚙️ 设置面板 Settings
点击聊天面板标题栏的 ⚙️ 齿轮按钮,或执行命令 DeepSeek AI 设置:
Click the ⚙️ gear icon in the chat panel, or run command DeepSeek AI 设置:
- 配置 API Key 和 Endpoint / Configure API Key & Endpoint
- 切换模型和调整参数 / Switch models & adjust parameters
- 设置内联补全行为 / Set inline completion behavior
- 选择输出语言 / Choose output language
- 配置隐私与安全策略 / Configure privacy & security
- 管理 Token 告警阈值 / Manage token alert thresholds
- 测试 API 连接 / Test API connection
- 获取可用模型列表 / Fetch available model list
🌐 多语言支持 Multi-language Support
支持 7 种语言的 UI 和 AI 输出。在设置中选择语言后,AI 回复将使用对应语言,UI 界面也会同步切换。
Supports 7 languages for UI and AI output. Select a language in settings — AI replies and UI will switch accordingly.
| 语言 Language |
代码 Code |
| 🇨🇳 简体中文 Chinese (Simplified) |
zh-CN |
| 🇬🇧 English |
en |
| 🇯🇵 日本語 Japanese |
ja |
| 🇰🇷 한국어 Korean |
ko |
| 🇫🇷 Français French |
fr |
| 🇩🇪 Deutsch German |
de |
| 🇪🇸 Español Spanish |
es |
⌨️ 快捷键 Keyboard Shortcuts
| 快捷键 Shortcut |
功能 Function |
Shift+Alt+I |
打开 DeepSeek Chat 侧边栏 / Open DeepSeek Chat sidebar |
Alt+\ |
手动触发内联代码补全 / Manually trigger inline completion |
Esc |
取消内联补全 / 中止 AI 生成 / Cancel inline completion / Abort AI generation |
⚙️ 配置项 Configuration
所有配置项在 VS Code settings.json 中以 deepseek-ai-coder.* 前缀访问。
All settings are accessible in VS Code settings.json with the deepseek-ai-coder.* prefix.
| 配置项 Key |
类型 Type |
默认值 Default |
说明 Description |
apiKey |
string |
"" |
DeepSeek API Key |
apiEndpoint |
string |
"https://api.deepseek.com" |
API 请求地址 API endpoint URL |
model |
enum |
"deepseek-chat" |
模型选择 Model selection |
temperature |
number |
0.7 |
采样温度 (0~2) Sampling temperature |
maxTokens |
number |
4096 |
最大输出 Token 数 (1~65536) Max output tokens |
topP |
number |
1 |
核采样参数 (0.01~1) Top-P sampling |
language |
enum |
"zh-CN" |
输出语言 Output language |
inlineCompletions.enabled |
boolean |
true |
启用内联补全 Enable inline completions |
inlineCompletions.maxLines |
number |
5 |
内联补全最大行数 (1~20) Max inline completion lines |
inlineCompletions.delay |
number |
200 |
触发防抖延迟 (ms) Trigger debounce delay |
inlineCompletions.shortcut |
string |
"alt+\\" |
手动触发快捷键 Manual trigger shortcut |
context.maxAutoFiles |
number |
3 |
自动上下文文件数上限 Max auto-context files |
rag.enabled |
boolean |
true |
启用代码库语义搜索 Enable RAG semantic search |
rag.indexOnStartup |
boolean |
true |
启动时自动索引 Auto-index on startup |
upload.maxSizeMB |
number |
10 |
上传文件大小上限 (MB) Max upload file size |
tokenUsage.warnDaily |
number |
0 |
日 Token 警告阈值 (0=不启用) Daily token warning threshold |
tokenUsage.warnMonthly |
number |
0 |
月 Token 警告阈值 (0=不启用) Monthly token warning threshold |
privacyMode |
boolean |
false |
隐私模式(不发送代码) Privacy mode (don't send code) |
sanitize.enabled |
boolean |
false |
启用数据脱敏 Enable data sanitization |
debug.enabled |
boolean |
false |
启用调试模式 Enable debug mode |
debug.logLevel |
enum |
"info" |
日志级别 Log level |
permissionMode |
enum |
"default" |
权限模式 Permission mode (default / auto / bypass) |
toolPermissions |
object |
{} |
工具权限配置 Tool permission overrides |
trustMode.rules |
array |
[] |
信任命令规则 Trust mode rules |
storage.backend |
enum |
"local" |
存储后端 Storage backend (local / gist) |
storage.gistToken |
string |
"" |
GitHub Gist Token |
storage.autoSync |
boolean |
false |
自动同步 Auto sync |
📦 技术栈 Tech Stack
| 技术 Technology |
用途 Purpose |
| TypeScript 6.0 |
开发语言,strict 模式 / Development language, strict mode |
| VS Code API |
扩展开发(Webview、InlineCompletion、命令系统等)/ Extension development |
| DeepSeek API |
AI 对话、代码补全 / AI chat, code completion |
| esbuild |
构建打包 / Build bundler |
| marked |
Markdown 渲染(唯一运行时依赖)/ Markdown rendering (only runtime dependency) |
📄 License
本项目基于 This project is licensed under the GNU Affero General Public License v3.0 开源。
版权所有 © 2026 邓阳勇 Copyright © 2026 邓阳勇