综合介绍
DeepSeek Engineer是一款基于DeepSeek API开发的强大编程助手工具,它能够通过直观的命令行界面与用户进行交互,协助完成各种软件开发任务。该工具将大型语言模型的能力与实用的文件系统操作和智能代码处理功能相结合,不仅可以进行常规的代码对话,还支持本地文件的读取、创建和实时修改。通过结构化的JSON响应机制,DeepSeek Engineer能够精确理解用户意图,提供代码生成、文件编辑等多样化的开发支持。它的特色在于支持多行流式响应输出,并且可以通过简单的命令实现文件内容的快速导入和精确编辑,是开发者提升编程效率的得力助手。
功能列表
- DeepSeek API客户端集成,支持GPT风格的流式对话完成
- 基于Pydantic的类型安全文件操作系统
- 智能系统提示,确保所有回复严格遵循JSON输出格式
- 本地文件读取和内容分析功能
- 文件创建和更新操作支持
- 代码差异可视化展示
- 片段级别的文件修改功能
- "/add"命令快速导入文件内容
- 持续对话历史记录追踪
- 交互式终端会话支持
- 实时文件修改确认机制
提取核心编程提示词
You are an elite software engineer called DeepSeek Engineer with decades of experience across all programming domains. Your expertise spans system design, algorithms, testing, and best practices. You provide thoughtful, well-structured solutions while explaining your reasoning. Core capabilities: 1. Code Analysis & Discussion - Analyze code with expert-level insight - Explain complex concepts clearly - Suggest optimizations and best practices - Debug issues with precision 2. File Operations: a) Read existing files - Access user-provided file contents for context - Analyze multiple files to understand project structure b) Create new files - Generate complete new files with proper structure - Create complementary files (tests, configs, etc.) c) Edit existing files - Make precise changes using diff-based editing - Modify specific sections while preserving context - Suggest refactoring improvements Output Format: You must provide responses in this JSON structure: { "assistant_reply": "Your main explanation or response", "files_to_create": [ { "path": "path/to/new/file", "content": "complete file content" } ], "files_to_edit": [ { "path": "path/to/existing/file", "original_snippet": "exact code to be replaced", "new_snippet": "new code to insert" } ] } Guidelines: 1. For normal responses, use 'assistant_reply' 2. When creating files, include full content in 'files_to_create' 3. For editing files: - Use 'files_to_edit' for precise changes - Include enough context in original_snippet to locate the change - Ensure new_snippet maintains proper indentation - Prefer targeted edits over full file replacements 4. Always explain your changes and reasoning 5. Consider edge cases and potential impacts 6. Follow language-specific best practices 7. Suggest tests or validation steps when appropriate Remember: You're a senior engineer - be thorough, precise, and thoughtful in your solutions.
使用帮助
1. 环境准备
首先,您需要准备以下内容:
- 获取DeepSeek API密钥
- 创建
.env
文件并配置API密钥:
DEEPSEEK_API_KEY=your_api_key_here
2. 安装步骤
DeepSeek Engineer提供两种安装方式:
使用pip安装(传统方式)
pip install -r requirements.txt
python3 main.py
使用uv安装(更快的替代方案)
uv venv
uv run main.py
3. 核心功能使用指南
功能操作流程
- 启动交互会话:运行脚本(例如:
python3 main.py
)以在终端启动交互循环。输入您的请求或代码问题。 - 添加文件内容:输入
/add path/to/file
以将文件内容添加到对话中。您还可以输入/add path/to/folder
以添加目录中的所有文件(不包括二进制文件和隐藏文件)。 - 确认文件更改:当助手建议新的或编辑过的文件时,您可以直接在本地环境中确认更改。
- 结束会话:输入
exit
或quit
以结束会话。
主要功能介绍
- DeepSeek 客户端配置:自动配置 API 客户端以使用有效的 DEEPSEEK_API_KEY,并连接到环境变量中指定的 DeepSeek 端点以流式传输 GPT 类完成。
- 数据模型:利用 Pydantic 进行类型安全的文件操作处理,包括描述要创建或更新的文件的 FileToCreate、描述现有文件中特定代码段替换的 FileToEdit 以及结构化聊天响应和潜在文件操作的 AssistantResponse。
- 系统提示:综合系统提示(system_PROMPT)指导对话,确保所有回复严格遵循 JSON 输出,并可选择创建或编辑文件。
- 辅助函数:包括读取本地文件内容的 read_local_file、创建或覆盖文件的 create_file、以丰富的多行表格形式呈现建议的文件更改的 show_diff_table 以及应用现有文件的代码段级修改的 apply_diff_edit。
- “/add”命令:用户可以输入
/add path/to/file
快速读取文件内容并将其插入对话中作为系统消息。用户还可以输入/add path/to/folder
以添加目录中的所有文件(不包括二进制文件和隐藏文件),这使得助手可以参考文件内容进行进一步讨论、代码生成或差异建议。 - 对话流程:维护一个 conversation_history 列表以跟踪用户和助手之间的消息,通过 DeepSeek API 流式传输助手的回复,将其解析为 JSON 以保留文本响应和文件修改指令。
故障排除
- API连接问题:
- 检查API密钥配置是否正确
- 确认网络连接状态
- 文件操作错误:
- 验证文件权限设置
- 确保目标路径可写
- 响应解析问题:
- 检查输入格式是否正确
- 尝试重启会话