deepseekcode

module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: MIT

README

deepseekcode

Release Go Reference Go Report Card Go Version

English · 简体中文

deepseekcode is a terminal coding agent for DeepSeek models and OpenAI-compatible chat-completions endpoints. It ships as a single Go binary named dsc, with an interactive TUI, one-shot CLI mode, repository tools, SQLite-backed sessions, and a conservative permission model.

Why dsc (DeepSeek specialization)

Measured, not claimed. In a reproducible 12-turn session on deepseek-v4-flash, dsc holds a 94.7% prefix cache-hit rate vs 0% for a cache-naive agent — 4.5× cheaper, every figure read from DeepSeek's own prompt_cache_hit_tokens. Reproduce: make demo-cache (live) or make demo-cache-offline (no API key). Evidence: bench/.

  • Provable prefix-cache stability — a single canonical serializer feeds both the wire bytes and the cache fingerprint, so they cannot diverge by construction; dsc trace inspect shows prefixes==1 to prove a stable run (docs/prefix-cache.md).
  • Real, signal-driven Flash→Pro routing — opt-in via --auto-route (escalates on ambiguity / repeated repair), not just a prompt instruction; an always-on Duet pro-validator fires on destructive tool calls (docs/duet.md).
  • Real OS sandbox — sandbox-exec (macOS) / Landlock (Linux) with a real PTY, not just path containment (docs/SANDBOX.md).
  • Auto reasoning-effort — per-turn thinking on/off via multi-language keyword detection plus low/medium/high/max effort, dialed down automatically on simple tasks.

On tool-use (tau-bench-lite, 8 tasks) dsc is at parity on cost-per-solved (~$0.00038) with a strong DeepSeek-native flash baseline — reported honestly, with no capability claim on easy tasks (bench/taubench).

Features

  • Interactive Bubble Tea TUI and scriptable dsc -p "prompt" mode.
  • DeepSeek-first runtime with thinking, reasoning_effort control, long context, prefix-cache metrics, and deepseek-v4-flash / deepseek-v4-pro support.
  • OpenAI-compatible provider configuration for alternate chat-completions endpoints.
  • Repository tools for file reads/edits, patches, shell commands, git, grep, LSP queries, web fetch/search, and user questions.
  • Persistent project sessions with resume, branching, scrollback export, and /undo for recent edit steps.
  • Extensibility through custom slash commands, SKILL.md discovery, MCP tools, subagents, and isolated git worktrees.
  • Safety controls for read-only mode, ask-before-tool mode, auto-approve mode, secret path checks, bash allowlists, optional sandboxing, and Pro validation for destructive operations.

Installation

macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/amemiya02/deepseekcode/main/install.sh | sh

Homebrew:

brew install amemiya02/deepseekcode/deepseekcode

Scoop:

scoop bucket add deepseekcode https://github.com/amemiya02/deepseekcode-scoop
scoop install deepseekcode

Go:

go install github.com/amemiya02/deepseekcode/cmd/dsc@latest

From source:

git clone https://github.com/amemiya02/deepseekcode
cd deepseekcode
make build
./bin/dsc -version

Requirements:

  • Go version matching go.mod or newer when building from source.
  • DEEPSEEK_API_KEY, or another provider key configured in .deepseek/config.toml.
  • Git and language servers are optional, but enable richer repository context.

Quick Start

export DEEPSEEK_API_KEY=sk-...

dsc                              # open the TUI
dsc -p "summarize this repo"     # run one prompt and exit
dsc --read-only                  # inspect without write/edit/bash tools
dsc init                         # create starter project config
dsc doctor                       # check local setup

Session shortcuts:

dsc -c                 # continue the latest session in this project
dsc -r <session-id>    # resume a specific session
dsc -new               # force a new session

Configuration

Configuration is layered from built-in defaults, user config, project config, and CLI flags. Project config lives at ./.deepseek/config.toml; user config lives at ~/.deepseek/config.toml.

Minimal DeepSeek config:

[active]
provider = "deepseek"

[providers.deepseek]
type = "deepseek"
base_url = "https://api.deepseek.com"
env_var = "DEEPSEEK_API_KEY"
first_token_timeout_ms = 45000
chunk_stall_timeout_ms = 20000

[defaults]
model = "deepseek-v4-flash"
thinking = true

OpenAI-compatible endpoint:

[active]
provider = "openai"

[providers.openai]
type = "openai-compat"
base_url = "https://api.openai.com"
env_var = "OPENAI_API_KEY"
default_model = "gpt-4o"

See docs/config.md and docs/PROVIDERS.md for the full reference.

Environment Variables

Variable Default Description
DEEPSEEK_API_KEY (required) DeepSeek API key
DEEPSEEKCODE_BASE_URL https://api.deepseek.com API base URL; set to a mirror for China-mainland access
DEEPSEEKCODE_PROXY (none) Explicit HTTP/HTTPS proxy URL; overrides HTTPS_PROXY/HTTP_PROXY
DEEPSEEKCODE_LANG auto-detected UI locale override (zh-CN, en); falls back to LANG

Documentation

Development

make build       # build ./bin/dsc
make test        # go test ./...
make test-race   # go test -race ./...
make lint        # go vet ./...
make fmt         # gofmt -s -w .
make run         # build and launch the TUI

Before opening a pull request:

make fmt
make lint
make test

Contributing

Issues and pull requests are welcome. Keep README changes synchronized between README.md and README.zh-CN.md with matching ## structure. Document only features that are implemented and testable in this repository.

Star History

Star History Chart

License

MIT

Directories

Path Synopsis
bench
cmd/benchrunner command
benchrunner is a black-box benchmark harness that compares coding agents by running them against a set of tasks and collecting structured traces.
benchrunner is a black-box benchmark harness that compares coding agents by running them against a set of tasks and collecting structured traces.
cmd/cachedemo command
bench/cmd/cachedemo/main.go cachedemo runs a controlled A/B that proves deepseekcode keeps DeepSeek's prompt cache hot.
bench/cmd/cachedemo/main.go cachedemo runs a controlled A/B that proves deepseekcode keeps DeepSeek's prompt cache hot.
cmd/cacheprobe command
bench/cmd/cacheprobe/main.go cacheprobe sweeps a stable prefix across lengths and prints, for each, the prompt_cache_hit_tokens reported on a repeat request.
bench/cmd/cacheprobe/main.go cacheprobe sweeps a stable prefix across lengths and prints, for each, the prompt_cache_hit_tokens reported on a repeat request.
cmd/taubench command
Package taubench — the dsc arm.
Package taubench — the dsc arm.
cmd
dsc command
Command dsc is the deepseekcode CLI entrypoint.
Command dsc is the deepseekcode CLI entrypoint.
Command dsc-desktop is the Wails v3 desktop wrapper for DeepSeekCode.
Command dsc-desktop is the Wails v3 desktop wrapper for DeepSeekCode.
internal
acp
agent
compact.go owns session compaction: when the live message list grows past CompactionConfig.AutoCompactInputTokens the agent collapses the older portion into a synthetic summary message, preserving a configurable tail of recent turns.
compact.go owns session compaction: when the live message list grows past CompactionConfig.AutoCompactInputTokens the agent collapses the older portion into a synthetic summary message, preserving a configurable tail of recent turns.
cacheunit
internal/cacheunit/align.go Package cacheunit computes prefix padding so the Static Prefix ends on a DeepSeek cache-unit boundary.
internal/cacheunit/align.go Package cacheunit computes prefix padding so the Static Prefix ends on a DeepSeek cache-unit boundary.
config
Package config loads deepseekcode configuration from TOML with precedence: CLI flags > project ./.deepseek/config.toml > user ~/.deepseek/config.toml > built-in defaults.
Package config loads deepseekcode configuration from TOML with precedence: CLI flags > project ./.deepseek/config.toml > user ~/.deepseek/config.toml > built-in defaults.
doctor
Package doctor implements the `dsc doctor` health-check command.
Package doctor implements the `dsc doctor` health-check command.
gateway
Package gateway: Wave-5 add-to-chat endpoint.
Package gateway: Wave-5 add-to-chat endpoint.
gitctx
Package gitctx reads a cwd's git state for the prompt builder's dynamic context section.
Package gitctx reads a cwd's git state for the prompt builder's dynamic context section.
hooks
Package hooks provides an extensible hook system for deepseekcode.
Package hooks provides an extensible hook system for deepseekcode.
i18n
Package i18n provides a lightweight message catalog for deepseekcode.
Package i18n provides a lightweight message catalog for deepseekcode.
llm
Package llm is a hand-rolled DeepSeek API client.
Package llm is a hand-rolled DeepSeek API client.
llmtest
Package llmtest provides a deterministic, offline mock DeepSeek server for exercising the agent loop and the llm client end-to-end without a network connection or API credentials.
Package llmtest provides a deterministic, offline mock DeepSeek server for exercising the agent loop and the llm client end-to-end without a network connection or API credentials.
logging
Package logging provides structured logging for deepseekcode.
Package logging provides structured logging for deepseekcode.
lsp
Package lsp implements a lightweight LSP (Language Server Protocol) client.
Package lsp implements a lightweight LSP (Language Server Protocol) client.
mcp
Package mcp implements the Model Context Protocol (MCP) client for stdio transport.
Package mcp implements the Model Context Protocol (MCP) client for stdio transport.
memory
Package memory provides persistent, BM25-indexed long-term memory for the agent.
Package memory provides persistent, BM25-indexed long-term memory for the agent.
onboarding
Package onboarding provides helpers that detect whether the user needs first-run configuration before the agent can make API calls.
Package onboarding provides helpers that detect whether the user needs first-run configuration before the agent can make API calls.
permissions
Package permissions implements the tiered approval model described in docs/design.md §8.
Package permissions implements the tiered approval model described in docs/design.md §8.
prompt
Package prompt assembles the cache-stable system prompt for the agent.
Package prompt assembles the cache-stable system prompt for the agent.
repair
Package repair provides tool-call repair utilities for DeepSeek reliability.
Package repair provides tool-call repair utilities for DeepSeek reliability.
routing
internal/routing/clarify.go
internal/routing/clarify.go
session
Package session implements the SQLite-backed conversation store.
Package session implements the SQLite-backed conversation store.
skills
Package skills implements a cache-stable skill metadata index.
Package skills implements a cache-stable skill metadata index.
snapshots
Package snapshots implements pre-edit file rollback per docs/design.md §8.4.
Package snapshots implements pre-edit file rollback per docs/design.md §8.4.
tokenizer
Package tokenizer provides a pure-Go DeepSeek V4 BPE tokenizer for exact token counting.
Package tokenizer provides a pure-Go DeepSeek V4 BPE tokenizer for exact token counting.
tools
Package tools implements deepseekcode's built-in tool surface.
Package tools implements deepseekcode's built-in tool surface.
traceschema
Package traceschema is the single source of truth for an agent trace record — one JSONL line emitted by internal/agent, read by internal/traceinspect, and read by the benchmark harness (bench/cmd/benchrunner).
Package traceschema is the single source of truth for an agent trace record — one JSONL line emitted by internal/agent, read by internal/traceinspect, and read by the benchmark harness (bench/cmd/benchrunner).
tui
chrome.go renders the live activity band between the scrollback and the status line, and owns the redraw-ticker lifecycle that drives it.
chrome.go renders the live activity band between the scrollback and the status line, and owns the redraw-ticker lifecycle that drives it.
version
Package version exposes build-time identifiers stamped via -ldflags.
Package version exposes build-time identifiers stamped via -ldflags.
worktree
Package worktree provides git-worktree management via shell commands.
Package worktree provides git-worktree management via shell commands.
Package webapp embeds the compiled Svelte SPA for use by dsc serve --http and the Wails desktop wrapper.
Package webapp embeds the compiled Svelte SPA for use by dsc serve --http and the Wails desktop wrapper.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL