lea_code

lea_code is a Dart command-line coding assistant powered by Genkit. It runs as an interactive terminal chat and gives the model a set of local workspace tools so it can inspect files, edit code, run commands, ask for approval, and manage lightweight session state while working in your project.

Features

  • Interactive CLI chat loop with streamed responses
  • A single agent loop, modeled on Claude Code, that keeps the whole conversation (tool calls included) across requests
  • A built-in system prompt focused on code quality: read before editing, follow project conventions, keep diffs minimal, and verify with the project's own checks
  • Session context in the system prompt: working directory, platform, date, model, and a git status snapshot
  • Project instructions loaded from LEA.md, CLAUDE.md, or AGENTS.md in the workspace and its parent directories, plus ~/.lea/LEA.md
  • Provider selection for Google, Anthropic, or OpenAI-compatible backends
  • Optional custom system prompt, appended after the built-in one
  • A terminal UI modeled on Claude Code: a bordered input box with history and slash-command completion, a spinner while the agent works, Markdown-styled responses, ⏺ Tool(argument) blocks with short result summaries, a checkbox task list, and arrow-key menus for approvals and questions
  • Esc or Ctrl-C interrupts the running request

Requirements

  • Dart SDK ^3.11.4
  • git (optional) for the session git snapshot
  • API access:
    • Google: a Google AI key
    • OpenAI: an OpenAI-compatible key (optionally with a custom base URL)
    • Anthropic: an Anthropic API key (--api_key, or the ANTHROPIC_API_KEY environment variable)
  • rg (ripgrep) available on your system for the grep and glob tools
  • PowerShell is only used on Windows, by the powershell tool

Install

dart pub global activate lea_code

Run

lea

You can also choose a provider, model, and provide a system prompt:

lea \
  --provider openai \
  --model gpt-6-luna \
  --system_prompt "You are a careful coding assistant."

OpenAI example:

lea \
  --provider openai \
  --model gpt-6-luna \
  --api_key "$OPENAI_API_KEY"

Anthropic example:

lea \
  --provider anthropic \
  --model claude-sonnet-5-5 \
  --api_key "$ANTHROPIC_API_KEY"

OpenAI-compatible base URL example:

lea \
  --provider openai \
  --model gpt-6-luna \
  --base_url "http://localhost:11434/v1" \
  --api_key "your-key-if-needed"

You can also control how many model turns are allowed while using tools:

lea --max_turns 100

CLI Options

  • -p, --provider: Provider to use. One of google, openai, or anthropic. Defaults to google.
  • -m, --model: Model name to use. Defaults to gemini-flash-lite-latest for google, gpt-6-luna for openai, and claude-sonnet-5-5 for anthropic.
  • -k, --api_key: API key to use (provider-dependent).
  • -b, --base_url: Base URL to use (for openai and anthropic).
  • -s, --system_prompt: Extra instructions appended to the built-in system prompt.
  • -t, --max_turns: Maximum number of model turns per request. Defaults to 100.
  • -h, --help: Show help.
  • -v, --version: Show version.

Interactive Commands

Type / in the input box to see and complete these:

  • /clear: clear the conversation and the screen
  • /new: clear the conversation, keeping the screen
  • /tasks: show the session task list
  • /model: show the current model
  • /help: show commands and shortcuts
  • /exit (or /quit): quit the program

Keyboard Shortcuts

  • Enter: send the message. \ then Enter, Alt+Enter, or Shift+Enter (in terminals that report it) inserts a newline
  • ↑ / ↓: move through earlier messages
  • Esc: interrupt the running request; press it twice to clear the input
  • Ctrl-C: interrupt the running request, or clear the input; press it twice on an empty input to exit
  • Ctrl-D on an empty input: exit
  • Ctrl-L: clear the screen
  • Ctrl-A / Ctrl-E, Ctrl-W, Ctrl-U, Ctrl-K, Alt+←/→: line editing
  • ? on an empty input: show shortcuts

Pastes longer than a few lines are shown as [Pasted text #1 +42 lines] and sent in full. Color is turned off when NO_COLOR is set, and the plain line-based interface is used when input or output is not a terminal.

Project Instructions

At startup Lea Code looks for instruction files and adds them to the system prompt, in this order:

  1. ~/.lea/LEA.md (your personal instructions for every project)
  2. LEA.md, CLAUDE.md, and AGENTS.md in each directory from the filesystem root down to the workspace

Later files are more specific, and project instructions take precedence over the built-in guidance. Use them for build and test commands, code style, and anything the agent should always know about the project.

Built-in Tools

  • read: reads a text file with cat -n style line numbers (2000 lines by default, offset/limit for more)
  • edit: replaces an exact string in a file. The match must be unique unless replace_all is set, and the file must have been read and left unchanged since
  • write: creates a file, or overwrites one that was read first
  • glob: finds files by glob pattern (**/*.dart), newest first, respecting .gitignore
  • grep: searches file contents with ripgrep, with file filters, context lines, and output modes
  • bash: runs a shell command in the workspace, asking for approval unless every part of the command is recognized as read-only
  • ask_user_question: asks the user one to three multiple-choice questions
  • task_create, task_update, task_list: a session task list the agent uses to plan and track multi-step work
  • sleep: waits for something external, such as a server starting
  • powershell (Windows only): runs a PowerShell command after approval
  • list_mcp_resources, read_mcp_resource: only available when an MCP adapter is configured

Tool activity is shown in the terminal as lines such as [bash] Run unit tests: dart test. Failed tool calls are shown and returned to the model as Error: ... so it can recover.

edit and write keep paths inside the workspace (after resolving ..). These tools run on your machine, so use Lea Code only in directories and environments you trust.

Project Structure

  • bin/lea_code.dart: CLI entrypoint and argument parsing
  • lib/lea_code.dart: the terminal app: REPL loop, streaming output, approvals, and questions
  • lib/agent/coding_agent.dart: the agent loop and conversation history
  • lib/prompts/system_prompt.dart: the system prompt
  • lib/prompts/session_context.dart: environment, git snapshot, and instruction file discovery
  • lib/tools/: tool definitions, with tool_registry.dart choosing which tools are exposed
  • lib/tools/runtime/: shared runtime for path resolution, file tracking, tasks, and approvals
  • lib/tools/utils/: the shared tool helper and command safety rules