deepseekcode

module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT

README

deepseekcode

CI Go Reference Go Report Card Baseline

English · 简体中文

deepseekcode is a terminal-native coding agent for DeepSeek models and OpenAI-compatible chat-completions endpoints. It ships as a single Go binary named dsc, with a Bubble Tea TUI, one-shot CLI mode, structured tools, SQLite-backed sessions, cache-aware request serialization, and a permission model designed for day-to-day repository work.

Current documented baseline: v0.2.0.

Why deepseekcode

DeepSeek exposes reasoning, prefix-cache metrics, long context, and cost characteristics that are worth treating as first-class UX. This project builds around those primitives instead of hiding them behind a generic chat wrapper.

  • It keeps reasoning visible with collapsible thinking blocks and a fullscreen /tape timeline.
  • It keeps costs visible with cache-hit and usage reporting in the TUI and CLI step output.
  • It keeps edits reviewable with structured file tools, pre-edit snapshots, /undo, and typed git helpers.
  • It keeps dangerous actions explicit with tiered permissions, secret path checks, bash allowlists, and the Pro validator hook.

Features

  • TUI and one-shot mode: run dsc for the interactive terminal UI, or dsc -p "prompt" for scriptable stdout output.
  • DeepSeek-first runtime: defaults to deepseek-v4-flash, supports deepseek-v4-pro, DeepSeek thinking options, prefix-cache metrics, and JSON-mode validation.
  • OpenAI-compatible providers: configure alternate chat-completions endpoints in .deepseek/config.toml.
  • Reasoning Tape: view model reasoning, tool calls, and repair events in the chat stream or the /tape fullscreen view.
  • Two-Model Duet: uses the Pro-capable provider path as a validator for destructive tool calls instead of invoking it on every turn.
  • Tool-rich agent loop: file edits, patch application, bash, git, web fetch/search, LSP queries, subagents, worktrees, tasks, and user questions are exposed through function calling.
  • Sessions and resume: stores sessions in pure-Go SQLite and supports -c, -r, and the /sessions picker.
  • Custom commands and skills: loads .deepseek/command/*.md slash commands and discovers SKILL.md files from project and home directories.
  • MCP integration: configured MCP servers are connected at startup and their tools are bridged into the agent registry.
  • Optional sandboxing: when enabled in config, bash tools use the platform sandbox implementation available on the host.

Install

macOS / Linux (one-liner)
curl -fsSL https://raw.githubusercontent.com/amemiya02/deepseekcode/main/install.sh | sh

Installs dsc to ~/.local/bin. Override with PREFIX=/usr/local sh or pin a version with DSC_VERSION=v0.3.0 sh.

macOS (Homebrew)
brew install amemiya02/deepseekcode/deepseekcode
Windows (Scoop)
scoop bucket add deepseekcode https://github.com/amemiya02/deepseekcode-scoop
scoop install deepseekcode
Go
go install github.com/amemiya02/deepseekcode/cmd/dsc@latest
Build from source
git clone https://github.com/amemiya02/deepseekcode
cd deepseekcode
make build
./bin/dsc -version

Prerequisites:

  • Go version matching go.mod or newer.
  • A DeepSeek API key, or another configured provider key.
  • Git is optional, but enables git-aware prompt context and git tools.
  • Language servers are optional; dsc connects to detected servers when they are present.

Quick Start

export DEEPSEEK_API_KEY=sk-...

dsc
dsc -p "summarize this repository"
dsc --read-only -p "explain the architecture"
dsc init
dsc doctor

Useful session flags:

dsc -c                 # continue the most recent 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-local config, and CLI flags. Project-local configuration lives at ./.deepseek/config.toml; user-wide configuration lives at ~/.deepseek/config.toml.

Minimal DeepSeek configuration:

[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 endpoints use the same provider mechanism:

[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 field reference.

CLI Reference

Top-level commands:

dsc                  # launch the TUI
dsc init             # create DEEPSEEK.md and .deepseek/config.toml
dsc doctor           # check config, provider, terminal, SQLite, git, MCP, LSP, and updates
dsc upgrade          # check the latest GitHub release and print an upgrade command
dsc agent list       # list project agents
dsc agent show NAME  # print an agent definition
dsc agent new NAME   # scaffold .deepseek/agent/NAME.md
dsc agent validate   # validate project agent definitions
dsc trace inspect TRACE.jsonl

Main flags:

-version          print build version
-p "prompt"      run one model turn and exit
-model ID        override the main-loop model
-read-only       block write, edit, and bash tools
-ask-all         ask before every tool call
-yolo            auto-approve all tool calls
-no-duet         disable the Pro validator hook
-debug           write structured logs under .deepseek/log/
-trace-jsonl P   write benchmark/diagnostic trace events to a JSONL file

TUI Commands

Keys:

Enter       send prompt
Shift+Enter insert newline
Ctrl+C      cancel current run, or quit when idle
Ctrl+D      quit
Ctrl+R      toggle the most recent thinking block
Ctrl+T      toggle all thinking blocks
PgUp/PgDn   scroll

Slash commands:

/help       show keymap and commands
/clear      clear scrollback
/quit       exit
/models     list or switch the main-loop model
/tape       open the reasoning tape
/sessions   list this project's sessions
/export     open full scrollback in $PAGER
/undo       restore the previous edit step
/compact    force message compaction

Custom slash commands are loaded from .deepseek/command/*.md in the project and home directories. Discovered skills are also promoted to slash commands unless a user command with the same name exists.

Built-in Tooling

dsc exposes tools through model function calling. The active set may also include MCP tools from configured servers.

Core repository tools:

  • read_file, write_file, edit_file, apply_patch
  • glob, grep, ls
  • bash, bash_pty, background_bash
  • git_diff, git_show, git_blame, git_log
  • todo_write, task_status, question

Context and extension tools:

  • lsp for language-server-backed symbol queries when a server is detected.
  • skill_read for loading discovered SKILL.md bodies on demand.
  • web_fetch and web_search when web tooling is enabled in config.
  • task for subagent dispatch and worktree for isolated git worktree management.

See docs/tools.md for tool parameters and safety notes.

Safety Model

The permission policy is intentionally conservative:

  • Read-only tools are allowed by default.
  • File writes are allowed inside the current working directory unless the target path looks secret-like or unsafe.
  • Bash is controlled by allowlist patterns and permission prompts.
  • --read-only, --ask-all, and --yolo override the default policy.
  • Destructive operations can be checked by the Duet validator hook.
  • Mutating file tools snapshot affected paths before execution; /undo restores the last edit step.
  • Optional sandboxing can be enabled for bash execution where the host platform supports it.

See docs/permissions.md and docs/SANDBOX.md.

Project Files

Development

Common commands:

make build
make test
make test-race
make lint
make fmt
make tidy
make run

Run a focused test:

go test ./internal/llm/ -run TestThinkingSerializesAsStruct -v

Before opening a pull request, run:

make fmt
make lint
make test

Versioning

Use v0.2.0 as the current public baseline for this repository. The codebase includes the terminal agent surface plus implemented provider configuration, web tools, MCP bridging, LSP integration, subagent dispatch, worktree support, sandbox wiring, and diagnostic commands.

Release builds are stamped by make build through git describe, so a tagged build such as v0.2.0 will appear in dsc -version.

Contributing

Issues and pull requests are welcome. Keep changes grounded in the current CLI, TUI, config, and tool behavior; avoid documenting a feature until it is implemented and testable in this repository.

For README changes, update both README.md and README.zh-CN.md with matching ## structure.

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
dsc command
Command dsc is the deepseekcode CLI entrypoint.
Command dsc is the deepseekcode CLI entrypoint.
internal
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.
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.
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.
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.
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.
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.
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.

Jump to

Keyboard shortcuts

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