@dcode-dev/dcode
v1.1.12
Published
AI-Powered Coding Assistant built with Go - Terminal-based AI assistant for writing, editing, and understanding code
Maintainers
Readme
dcode
dcode is an AI-powered terminal coding agent built in Go with a full Bubbletea TUI. It supports 20+ AI providers, autonomous tool use, multi-step undo/redo, live thinking display, and a rich @ file-picker — all without leaving your terminal.
Features
- 20+ AI providers — Anthropic, OpenAI, Google Gemini, GitHub Copilot, Azure OpenAI, AWS Bedrock, Groq, OpenRouter, xAI, DeepSeek, Mistral, DeepInfra, Cerebras, Together AI, Cohere, Perplexity, GitLab, Cloudflare, Replicate, and any OpenAI-compatible endpoint
- Autonomous tool use — reads, writes, edits files; searches with glob/grep; executes shell commands; browses the web; calls MCP servers
- Rich TUI — Bubbletea interface with Glamour-rendered markdown, Chroma syntax highlighting, scrollable history, and a light-green blinking cursor
- Thinking display — live streaming of extended-thinking / reasoning with opencode-style spinner and topic extraction
- Multi-step undo/redo —
Ctrl+Z/Ctrl+Shift+Zbacked by git snapshots; also/undoand/redoslash commands - Copy code blocks —
Ctrl+Y+ digit copies the Nth code block from the last response;/copy Nalso works - @ file picker — type
@to attach any file (text, images, or directories); text files are injected as fenced code blocks, images as inline data - Session persistence — all conversations saved as JSON with import/export and share
- MCP support — connects to local and remote Model Context Protocol servers
- Git worktrees —
dcode worktree create <name>for isolated parallel sessions on separate branches - Non-interactive mode —
dcode run "prompt"for scripting and CI/CD pipelines - Shell completions — bash, zsh, fish, and PowerShell via
dcode completion
Installation
From a release (recommended)
Download the binary for your platform from the Releases page and put it on your PATH:
# Linux (x86_64)
curl -L https://github.com/Dhanuzh/dcode/releases/latest/download/dcode_linux_x86_64.tar.gz | tar xz
sudo mv dcode /usr/local/bin/
# macOS (Apple Silicon)
curl -L https://github.com/Dhanuzh/dcode/releases/latest/download/dcode_darwin_arm64.tar.gz | tar xz
sudo mv dcode /usr/local/bin/Via go install
go install github.com/Dhanuzh/dcode/cmd/dcode@latestBuild from source
git clone https://github.com/Dhanuzh/dcode.git
cd dcode
make build # builds ./dcode with version/commit ldflags
make install # copies to /usr/local/bin (requires sudo)Quick Start
# First run — dcode guides you through authentication
dcode
# Or authenticate explicitly
dcode auth login
# Non-interactive one-shot prompt
dcode run "explain the main function in cmd/dcode/main.go"
# Use a specific provider and model
dcode --provider openai --model gpt-4oAuthentication
dcode supports three credential sources, in priority order:
- Stored credentials (recommended) —
dcode auth loginsaves keys to~/.config/dcode/credentials.jsonwith0600permissions - Environment variables — e.g.
ANTHROPIC_API_KEY,OPENAI_API_KEY,GOOGLE_API_KEY - Config file —
~/.config/dcode/dcode.jsonor project-local.dcode/dcode.json
Provider-specific OAuth flows:
dcode auth anthropic # Anthropic OAuth PKCE flow (no API key needed)
dcode auth copilot # GitHub Copilot device-code OAuth
dcode auth openai # API key promptList configured providers:
dcode auth listConfiguration
Global config lives at ~/.config/dcode/dcode.json. Override per-project with .dcode/dcode.json in your repo root.
# View current resolved config
dcode config show
# Change settings
dcode config set provider anthropic
dcode config set model claude-sonnet-4-5
dcode config set theme dracula| Key | Default | Description |
|---|---|---|
| provider | anthropic | Default AI provider |
| model | (provider default) | Model ID |
| default_agent | coder | Agent to use (coder, planner, explorer) |
| max_tokens | 8192 | Max output tokens |
| streaming | true | Stream responses |
| theme | dark | TUI colour theme |
| snapshot | true | Enable git snapshots for undo |
TUI Key Bindings
| Key | Action |
|---|---|
| Enter | Send message |
| Ctrl+C | Cancel running request |
| Ctrl+Z | Undo last AI action |
| Ctrl+Shift+Z | Redo |
| Ctrl+Y + digit | Copy Nth code block |
| @ | Open file picker (attach file or image) |
| Ctrl+L | Clear screen |
| Ctrl+M | Toggle mouse mode |
| Tab | Cycle through sessions / autocomplete |
| ↑ / ↓ | Scroll history |
| /help | List slash commands |
| /undo, /redo | Undo / redo |
| /copy N | Copy Nth code block |
| /clear | Clear conversation |
| /model | Switch model interactively |
| /agent | Switch agent |
Available Commands
dcode # Start the TUI (default)
dcode run <prompt> # Non-interactive single prompt
dcode auth # Manage credentials
dcode config # View/edit configuration
dcode models # List all models by provider
dcode agent list # List available agents
dcode session list # List saved sessions
dcode session delete <id>
dcode export <session-id>
dcode import <file>
dcode share create <session-id>
dcode mcp list # List MCP servers
dcode mcp add # Add an MCP server
dcode worktree create <name>
dcode stats # Usage statistics
dcode debug config # Dump resolved config JSON
dcode version # Show version and commit
dcode upgrade # Self-update via go install
dcode completion bash # Shell completion scriptProject Structure
dcode/
├── cmd/dcode/ # CLI entry point (Cobra commands)
├── internal/
│ ├── agent/ # Agent definitions and system prompts
│ ├── config/ # Config loading, credentials, provider registry
│ ├── earlyinit/ # Lipgloss dark-background init (WSL2 fix)
│ ├── provider/ # AI provider implementations (20+)
│ ├── server/ # HTTP API server (headless mode)
│ ├── session/ # Session store, prompt engine, compaction
│ ├── share/ # Session sharing client
│ ├── tool/ # Tool registry and implementations
│ ├── tui/ # Bubbletea TUI model and components
│ └── worktree/ # Git worktree management
├── .github/workflows/ # CI + release (GoReleaser)
├── .goreleaser.yml # Cross-platform release config
├── Makefile # Build targets with ldflags
├── go.mod
└── LICENSEDevelopment
Prerequisites
- Go 1.24.2+
- golangci-lint (optional, for
make lint) - goreleaser (optional, for
make snapshot)
Common tasks
make build # build with version/commit injected
make test # go test -race ./...
make cover # test + HTML coverage report
make fmt # gofmt -w .
make lint # golangci-lint run
make cross # cross-compile Linux/macOS/Windows
make snapshot # local goreleaser snapshotAdding a new AI provider
Implement the Provider interface in internal/provider/:
type Provider interface {
Name() string
Models() []ModelInfo
CreateMessage(ctx context.Context, req *MessageRequest) (*MessageResponse, error)
StreamMessage(ctx context.Context, req *MessageRequest, cb func(*StreamChunk) error) error
}Register it in internal/provider/provider.go → CreateProvider.
Adding a new tool
Implement tool.Tool in internal/tool/ and register it in tool.GetRegistry().
License
MIT — see LICENSE.
