Skip to content
NerfEkoPublic

About

a fun interactive feature rich llm agent TUI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

evilcode

License Go Built with Charm Ollama Linux

A note before you use it: evilcode was built with AI. I have extensively cross-verified it against other open-source coding agents wherever the features overlap, but it is still an active personal project and should be treated that way. Pull requests and feature requests are welcome.

evilcode is the coding agent I wanted to use every day: a keyboard-driven terminal app that hands a model real tools (files, shell, git, LSP, MCP, memory) and gets out of the way while it works.

It runs entirely on your machine. There's no account, no telemetry and no hosted workspace. A small daemon owns your sessions, so you can close the terminal mid-task, come back later from another window (or your phone), and pick up where things left off.

evilcode auditing a real codebase for panic-shaped bugs

Install

Linux only. The quick way grabs the latest release build:

curl -fsSL https://evileko.dev/evilcode | sh

That puts evilcode in ~/.local/bin, along with a shorter ec alias, and tells you if that directory isn't on your PATH. Run it again later and it offers to update, reinstall, remove, or reset your config instead of blindly overwriting anything. Updating from inside is one command:

evilcode update

To build it yourself you need Go 1.26 or newer:

git clone https://git.evileko.dev/evileko/evilcode
cd evilcode
go build -o evilcode ./cmd/evilcode
ln -sf "$PWD/evilcode" ~/.local/bin/evilcode
ln -sf "$PWD/evilcode" ~/.local/bin/ec

Shell completions:

evilcode completions zsh  > ~/.zfunc/_evilcode
evilcode completions bash > /etc/bash_completion.d/evilcode
evilcode completions fish > ~/.config/fish/completions/evilcode.fish

A few optional tools light up extra features when they're installed: rg for the grep tool, gopls for LSP, mmdc for Mermaid diagrams, img2sixel for images in terminals without Kitty graphics, and tmux for the probe rig.

Getting started

Type evilcode (or ec) and start talking. The daemon starts on its own the first time you need it.

evilcode                              # open the TUI
evilcode -m glm-5.2@ollama-cloud      # open it with a specific model
evilcode run "fix the parser"         # hand off a prompt and get your shell back
evilcode run --wait "explain this"    # hand off a prompt and stream the answer
evilcode attach -l                    # list sessions
evilcode attach [session]             # jump back into one
evilcode resume --from claude <id>    # import a Claude Code (or Codex) session

A few things about how it behaves:

  • Sessions start with your first prompt. Opening evilcode and quitting leaves nothing behind.
  • Windows are just views. Closing a terminal doesn't stop the agent. Another window can attach to the same session, and a session nobody is watching stays loaded for ten minutes after its last activity before it's quietly put away. Its history stays on disk for /resume.
  • Quitting is tidy. Ctrl+C twice (or /quit) also stops the daemon if nothing else is using it: no other sessions, no running turn, no other windows.
  • run doesn't need you around. evilcode run submits the prompt to the daemon and exits, and the work carries on without your shell. Add --wait to stream the reply, or --local for an old-style in-process one-shot.

If you ever want to manage the daemon by hand:

evilcode serve            # run it in the foreground
evilcode serve -status    # what's it doing?
evilcode serve -stop      # stop it cleanly

Models

Out of the box evilcode looks for credentials and picks something sensible:

You have Default model
OLLAMA_API_KEY deepseek-v4.1-flash@ollama-cloud
OPENCODE_API_KEY or an OpenCode login glm-5.3-flash@opencode-go
neither deepseek-v4.1-flash:cloud@ollama-local through your local Ollama

It also speaks to OpenAI-compatible APIs, DeepSeek directly, and Codex (if the Codex CLI is installed and logged in, evilcode finds its account automatically). There's a deterministic mock provider too, which is what the tests use.

Inside the app, /model switches models, /reasoning (or Alt+R) changes reasoning effort where the model supports it, and /refresh-model-list re-fetches each provider's catalog when something new comes out. The catalog is otherwise cached for the session.

Logging in

/login walks you through it, or name the provider directly with /login <provider>. Keys are saved to your own user-only config file.

For OpenCode Go you have two options. You can paste a key from opencode.ai/auth, or run /login opencode-go oauth to sign in through your browser with a device code, the way opencode's own client does now. The OAuth login refreshes itself and writes rotated tokens back to your config. Whichever credential you set last is the one that's used, except that OPENCODE_API_KEY in the environment always wins. /login status opencode-go tells you which one is active.

A small gateway detail: the muse-spark, grok and gpt-5.6 models on OpenCode Go only work over its /responses endpoint, so evilcode sends them there automatically. Their reasoning summaries can occasionally come back empty from the gateway. The model is still thinking; there's just nothing to show.

Optional services

  • /connect brave turns on the web_search tool using a Brave Search key (or set BRAVE_SEARCH_API_KEY / BRAVE_API_KEY).
  • /connect ollama-usage powers the Ollama Cloud usage widget. Ollama has no usage API, so the widget reads your ollama.com settings page with your browser session cookie. Paste the __Secure-session cookie value (DevTools → Network → any ollama.com request → Cookies), or set OLLAMA_SESSION_COOKIE. That cookie is a live login, so treat it like a password. If Ollama changes the page, the widget says so instead of guessing.

What's in the box

The terminal UI

It's built on the Charm libraries and designed for a real terminal:

  • Streaming Markdown with syntax highlighting. Click a shell code block to copy a clean version of the command.
  • Diffs inline, pinned (/diff), or as change gutters on the whole file.
  • A live split view. Ctrl+L opens a side pane that follows whatever the agent is touching: bash output streams in like a real terminal, file edits assemble against the file on disk, and anything else gets a preview. Ctrl+Q closes it, and the mouse wheel scrolls whichever side you're pointing at.
  • Model and reasoning pickers, Ctrl+R history search, themes (/theme), and images via Kitty graphics or sixel.
  • A start page that lists your sessions with a live preview, so you're not guessing which one was which.

/help lists every command and /keys shows the full keymap.

Tools

The model gets read, write, edit, multiedit, glob, grep, bash, background tasks (bg), ask for questions back to you, a todo list, git helpers, LSP, MCP servers, and web_search if you've connected Brave.

  • grep can show the whole function, method or type around each match.
  • edit supports hash-anchored changes, so an edit against stale content is refused rather than applied somewhere it doesn't belong.
  • Long-running shell commands can move into the daemon's background task manager and keep going after you disconnect. Manage them with bg status, bg output, bg wait and bg cancel.
  • Skills are picked up from .evilcode/skills and .agents/skills in your repo, then ~/.config/evilcode/skills, ~/.agents/skills and ~/.claude/skills.

Sessions

Every message is written to disk as it arrives. You can /resume, /fork, /rename, drop a /checkpoint, or /rewind to an earlier point. A resumed session comes back in its original directory with its last model. If the daemon goes down in the middle of a turn, that session is marked as crashed rather than looking finished.

You can also bring in history from elsewhere: evilcode resume --from claude imports a Claude Code session, and --from codex imports a Codex one.

Long conversations

When the context gets close to full (the window minus the larger of 15% or 16,384 tokens), evilcode compacts it. It asks the session's model for a summary first, then falls back through your other configured models if needed. The summary follows a fixed shape (goal, progress, decisions, next steps) and gets checked. One that drops your goal or answers a question that was still open is thrown out and redone. The file paths in it come from the actual tool calls, not the model's memory. If a provider rejects a request for being too long, evilcode compacts and tries again.

Two lighter tools help too. Between turns, older reads of a file you've since re-read are blanked out, which keeps growth slow. /shake trims big tool results and code blocks without calling a model and keeps the originals recoverable. And when you'd rather start clean, /handoff writes a handoff document and continues in a fresh session, leaving the original untouched.

[compaction]
strategy = "context-full"   # context-full | shake | off
reserve_tokens = 16384
keep_recent_tokens = 20000
prune_reads = true

Memory

Memory is optional. When it's on, relevant facts from past work can be recalled into a turn, and a short summary is saved when a session is closed. It falls back to plain text matching if the embedding model isn't available. Toggle it with /memory.

Workers and overnight runs

A session can hand work off to headless workers with the spawn_worker tool or /summon. By default spawn_worker returns right away with the worker's name, and the result (checked against a JSON Schema if you give one) shows up later as a message. Pass wait: true to block until it's done instead. Workers send heartbeats, so one that's gone quiet shows up as stale instead of leaving everyone waiting, and they share file and todo state so a small swarm can coordinate. Include the word "orchestrate" in a prompt (or run /orchestrate on) and the session switches into a fan-out mode built for exactly that.

Sessions can also talk to each other. broadcast and peers reach the sessions working in the same directory plus the caller's own spawner and workers. send_message can reach any session by name.

/overnight works through your todo list with no window attached. It stops when it runs out of turns, tokens or time, or stops making progress, and leaves you a short report.

The web UI

The daemon can also serve a browser version of the whole thing: the session list, live chat, questions, interrupts, model switching, commands, and spawning workers. It works well on a phone, and you can add it to your home screen as an app.

evilcode serve -web       # listens on 127.0.0.1:7749

Set [webui] enabled = true to have it start with the daemon every time. It's off by default and only listens on localhost.

Access is protected by a token. The first time it starts, evilcode prints a one-time link containing the token. Open it and the token is swapped for a cookie. After that, requests use the cookie or an Authorization: Bearer header. The token itself lives next to the socket at <socket>.web-token, which is $XDG_RUNTIME_DIR/evilcode.sock.web-token by default.

Using it from your phone

The simplest path is Tailscale. Inside evilcode, run /tailscale. It starts the web listener if needed, sets up tailscale serve, and shows a QR code for your https://<node>.<tailnet>.ts.net address with the token already included. Point your phone camera at it and you're in.

The manual version, if you'd rather:

evilcode serve -web -idle 0      # -idle 0 keeps the daemon up while you're away
tailscale serve --bg 7749        # HTTPS on your tailnet → 127.0.0.1:7749
tailscale serve status           # shows the https://<node>.<tailnet>.ts.net address

Then open https://<node>.<tailnet>.ts.net/?token=<token> on the other device. For this proxied setup, set [webui] trust_forwarded_headers = true so the proxied address is accepted. Leave it off for anything direct clients can reach, since those headers are otherwise easy to fake. When you're done, tailscale serve reset removes the proxy (only if you have no other Serve routes on that node).

A few safety notes:

  • Don't use tailscale funnel, and don't bind evilcode to a LAN or tailnet IP. Keep it on localhost and let Tailscale do the exposing.
  • [webui] require_auth = false turns the token off entirely. Only do that when your network (for example, Tailscale ACLs) is the whole security boundary.
  • Treat the token like a password. Keep it out of shell history, issues and logs.

Configuration

Everything lives in ~/.config/evilcode/config.toml, or wherever EVILCODE_CONFIG points. You don't need one to start. If the file has mistakes, evilcode lists every problem at once so you can fix it in one pass.

default_model = "deepseek-v4.1-flash@ollama-cloud"

[[provider]]
name = "ollama-cloud"
kind = "ollama"
base_url = "https://ollama.com"
api_key_env = "OLLAMA_API_KEY"

[[model]]
name = "glm-5.2:cloud"
context_window = 262144

[display]
theme = "catppuccin-frappe"  # catppuccin-frappe | dracula | nosferatu | gloom | daywalker
inline_diffs = true
centered = false

[features]
memory = true
advisor = false
max_steps = 0            # 0 means no limit on tool rounds

A repository can carry its own defaults in .evilcode.toml at its root. Models and roles can be set there, but credentials can't.

Keys

Key What it does
Enter send (queues it if a turn is already running)
Shift+Enter, Alt+Enter, trailing \ new line
Esc close an overlay, interrupt the turn, then clear the input
Ctrl+C detach; twice to quit (and stop the daemon if nothing else is live)
Ctrl+R search prompt history
Ctrl+L / Ctrl+Q open / close the live split view
Ctrl+G toggle a scroll bookmark
Ctrl+P toggle auto-poke
Ctrl+Up pull back queued messages
Alt+R / Alt+T cycle reasoning effort / thinking display
PgUp, PgDn scroll a page
↑, ↓ on empty input scroll a line

If your terminal can't tell Shift+Enter from Enter, run /terminal-setup. /keys shows everything else.

Your data

evilcode has no telemetry and no account. What it keeps is stored under ~/.local/share/evilcode/:

  • sessions/*.jsonl: your conversations and tool history
  • prompt-history.jsonl: prompts you've typed
  • memory.jsonl: long-term memory, if you use it
  • session blobs and overnight reports

These are basically private work logs. They can hold prompts, code, command output, and anything the model looked at, so treat them that way.

Contributing

evilcode started as a tool for one person, so it has opinions and a few seams that are tighter than they should be. That's exactly why outside eyes help. Bug reports, feature requests, docs fixes and pull requests are all welcome. If you change behavior, please add a focused test where it makes sense, and run these first:

go test ./...
go test -race ./...
go vet ./...

For UI changes there's a probe rig that drives a real binary in a headless tmux pane and captures frames as text and PNGs (see docs/probe.md):

go build -o evilcode ./cmd/evilcode
go test -tags probe ./probe/...
probe/probe.sh boot
probe/probe.sh keys "/help" Enter
probe/probe.sh png help
probe/probe.sh kill

Where things live:

cmd/evilcode        the executable and updater
internal/agent      the model loop, events and hooks
internal/tui        the terminal UI
internal/attachcmd  the socket client behind attached windows
internal/tuicmd     the default TUI entrypoint
internal/runcmd     headless runs, local and through the daemon
internal/servecmd   the daemon entrypoint
internal/daemon     the server: sessions, reconnects, workers, web UI
internal/provider   Ollama, OpenAI-compatible, DeepSeek, OpenCode Go, Codex, mock
internal/tools      the built-in tools
internal/wiring     shared setup for providers, tools and sessions
internal/memory     long-term memory

evilcode is licensed under GPL-3.0. If you try it and something feels rough, or you have an idea that would make it better, I'd love to hear about it.

About

a fun interactive feature rich llm agent TUI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages