Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - 54cndr/DS-Code: AI编程助手 | AI coding agent · GitHub
Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - 54cndr/DS-Code: AI编程助手 | AI coding agent · GitHub
Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - 54cndr/DS-Code: AI编程助手 | AI coding agent · GitHub
Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - 54cndr/DS-Code: AI编程助手 | AI coding agent · GitHub
Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - 54cndr/DS-Code: AI编程助手 | AI coding agent · GitHub
Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - 54cndr/DS-Code: AI编程助手 | AI coding agent · GitHub
Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - 54cndr/DS-Code: AI编程助手 | AI coding agent · GitHub
Skip to content

Repository files navigation

DS-Code

一人即团队,终端即 IDE — AI 编程助手,在终端里完成从需求到部署的完整软件流程

One person, one team. Terminal is your IDE. — An AI-powered coding agent that takes you from idea to deployment, all inside the terminal.

versionrustdeepseeklicensebinary size


它是什么? What is it?

DS-Code 是一个专为 DeepSeek 大语言模型深度定制的终端编程助手(Terminal Code Agent)。它不是简单的 AI 聊天工具——它拥有完整的 Harness 执行内核:可以读写文件、执行 Shell 命令、管理 Git、搜索代码库、甚至并行派出子 Agent,像一个真正的程序员一样工作。

DS-Code is a TUI-based coding agent purpose-built for DeepSeek models. It has a full Harness execution kernel: it reads/writes files, runs shell commands, manages Git, searches your codebase, and can spawn parallel sub-agents. It works like a real programmer.

最大特色 The Biggest Feature:会自我成长的 Agent,像一个真正的程序员一样。
每次解决问题积累的经验自动保存到经验库,下次遇到类似问题直接调用——你用得越多,它越聪明。
A self-growing agent that learns from every interaction. Every bug fix, build trick, and project pattern is saved into an experience library. The more you use it, the smarter it gets.

它会自我成长:每次解决问题积累的经验会自动保存到经验库,下次遇到类似问题时直接调用——你用得越多,它越聪明。

It learns as you use it: every bug fix, build trick, and project pattern is saved into an experience library that grows with your project. The more you use it, the smarter it gets.


三种模式 Three Modes

模式 Mode图标权限适用场景
Plan 🟦蓝色只读 Read-only先看计划再决定 Execute after review
Agent 🟧珊瑚橙 Coral写操作需确认 Ask before write边看边做,逐步确认 Step-by-step with approval
Auto 🟪紫色自动批准 Auto-approve放手让它干 Full autonomy
Tab 键循环切换 | /mode 命令弹出菜单 | 启动参数 --plan / --auto

快速开始 Quick Start

1. 下载 / Download

Releases 下载单个可执行文件(4.6MB,零依赖),或者从源码编译:

From Releases download the single binary (4.6MB, zero dependencies), or build from source:

# 编译 Build
cargo build --release
# 产物在 target/release/ds-code (Linux/macOS) 或 ds-code.exe (Windows)

2. 配置 / Configure

# 设置 API Key(三选一)export DEEPSEEK_API_KEY="sk-your-key"# 环境变量 env var
ds-code --api-key "sk-your-key"# 命令行参数 CLI flag# 首次运行时会引导配置 ~/.ds-code/config.json Interactive setup on first run

3. 启动 / Launch

# 交互模式 Interactive TUI
ds-code
# 指定工作目录 + Agent 模式
ds-code -d /path/to/project --auto
# 单次提问 Non-interactive one-shot
ds-code -p "帮我写一个 HTTP 服务器 Help me write an HTTP server"# 继续上次会话 Resume last session
ds-code -c

核心能力 Core Capabilities

🛠️ 17 个内置工具 17 Built-in Tools

工具 Tool做什么
read_file / write_file / edit_file文件操作 File I/O(原子写入 + 5 级模糊匹配)
execute_shell运行命令 Run commands(智能超时 + 管道防死锁)
grep / list_files代码搜索 Code search & file listing
web_search / web_fetch联网搜索 Web search
spawn_agent / send_input / wait / close_agent并行子 Agent Parallel sub-agents
save_memory / search_experience / save_experience自成长记忆 Self-growing memory
debug_log调试日志 Debug logging

🧠 会学习的 Agent A Self-Growing Agent

  • MemoryEngine(记忆引擎):自动检测你的偏好和规则,下次自动遵守
  • ExperienceLibrary(经验库):每次修复 bug、解决编译错误后自动记录,积累技术经验
  • SmartWindow(智能窗口):长上下文自动裁剪,把宝贵的 token 用在刀刃上

🔒 安全执行 Security by Design

  • 三级权限级联:Plan(只读)→ Agent(需确认)→ Auto(自动批准)
  • 黑名单保护rm -rf /、fork bomb、mkfs 等危险命令所有模式拒绝
  • 15 个敏感路径写保护.git/.env.ssh/ 等自动拦截
  • 命令注入检测$()、反引号等 4 类注入模式检测

🌐 Windows 一等公民 Windows First-Class Citizen

  • PowerShell / cmd / Git Bash 方言自动检测
  • Git Bash 命令劫持防护(find%SystemRoot%\System32\find.exe
  • 管道死锁预防(独立读取线程排空管道)
  • 单 EXE,4.6MB,拷贝即用

🎨 终端原生 TUI Native Terminal UI

  • 流式打字机效果 Stream typewriter effect
  • ANSI scroll region 消息区独立滚动
  • Markdown 渲染 + 代码块高亮
  • @文件引用自动注入 @mention file injection
  • F2 Diff 预览 Diff preview
  • CJK 字符正确换行 Full-width character support

命令速查 Commands Cheatsheet

命令 Command说明
/mode切换模式 Switch mode
/save <摘要>保存会话 Save session
/sessions会话列表 List sessions
/resume <id>恢复会话 Resume session
/clear清空上下文 Clear context
/compact压缩上下文 Compact context
/diff查看 Git 变更 View git diff
/commitGit 提交 Git commit
/undo回滚变更 Rollback changes
/cost查看 Token 用量 Token usage
/memory管理记忆 Manage memory
/debug调试面板 Debug panel
/multi多 Agent 管理 Multi-agent mgmt
/image添加图片 Add image
/help帮助 Help

共 28 个内置命令,输入 / 自动补全提示。

28 built-in commands total. Type / for autocomplete suggestions.


项目结构 Project Structure

src/
├── main.rs # 入口 Entry point(CLI + TUI 事件循环)
├── agent_loop.rs # AI Agent 主循环 Main loop(~800 行)
├── multi_agent.rs # 多 Agent 并行系统 Multi-agent system(~840 行)
├── hooks.rs # Hook 事件系统 Hook event system
├── api/ # DeepSeek API 客户端(流式 SSE)
├── harness/ # 执行内核 Execution kernel
│ ├── executor.rs # 工具统一后端 Unified tool backend
│ ├── permission_engine.rs # 权限引擎 Permission engine
│ ├── rollback.rs # Git 回滚管理器 Rollback manager
│ └── danger_guard.rs # 黑名单保护 Blacklist guard
├── modes/ # 三种工作模式 Plan/Agent/Auto
├── ui/ # TUI 界面层(ratatui + crossterm)
├── context/ # 上下文管理 Context management
│ ├── smart_window.rs # 长上下文裁剪
│ ├── memory.rs # 记忆引擎
│ └── experience.rs # 经验库
├── commands/ # 28 个内置命令 Built-in commands
├── session/ # 会话持久化 Session persistence
├── config/ # 配置管理 Configuration
├── mcp/ # MCP 协议(Model Context Protocol)
└── observability/ # 可观测性 Observability
├── logger.rs # tracing 结构化日志
├── crash.rs # 崩溃报告 Crash report
├── metrics.rs # 性能指标 Metrics
└── session_log.rs # IO 记录 Session log

技术栈 Tech Stack

层 Layer技术 Technology
语言 LanguageRust 2024 Edition
异步运行时 AsyncTokio (multi-thread, 4 workers)
TUI 框架ratatui + crossterm
HTTP 客户端reqwest (rustls-tls)
Git 集成git2
CLI 解析Clap (derive)
日志tracing
编译优化LTO + opt-level=z + codegen-units=1 → 4.6MB 单文件

许可证 License

GPL v3


作者 Author

龙晓立 | Email: 54cndr@sohu.com


Built with ❤️ for developers who live in the terminal.