Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

version rust deepseek license binary 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
/commit Git 提交 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
语言 Language Rust 2024 Edition
异步运行时 Async Tokio (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.