lea_code 0.0.9
lea_code: ^0.0.9 copied to clipboard
lea_code is a Dart command-line coding assistant powered by Genkit.
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
- Three-stage agent workflow with separate analysis, execution, and verification passes
- Provider selection for Google or OpenAI-compatible backends
- Model selection via a command-line flag
- Optional custom system prompt
- Configurable max tool-calling turns per response
- Automatic verification retries for failed execution attempts
- Conversation reset with
/new - Runtime-managed tools for:
- reading numbered file content from absolute paths
- writing and editing workspace files with read-before-write safety checks
- running shell commands in the workspace with approval prompts for risky commands
- searching code with
rgand file name matching withfind - asking the user multiple-choice questions during a session
- creating and updating in-session tasks
- listing and reading MCP resources when an MCP adapter is configured
- sleeping / waiting and running PowerShell commands when needed
- Inline tool status messages while the assistant works
Requirements #
- Dart SDK
^3.11.4 - API access:
- Google: a Google AI key
- OpenAI: an OpenAI-compatible key (optionally with a custom base URL)
rg(ripgrep) available on your system for thegreptool- PowerShell is optional and only needed for the
powershelltool
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-5.4 \
--system_prompt "You are a careful coding assistant."
OpenAI example:
lea \
--provider openai \
--model gpt-5.4 \
--api_key "$OPENAI_API_KEY"
OpenAI-compatible base URL example:
lea \
--provider openai \
--model gpt-5.4 \
--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 ofgoogleoropenai. Defaults togoogle.-m,--model: Model name to use. Defaults togemini-flash-lite-latest.-k,--api_key: API key to use (provider-dependent).-b,--base_url: Base URL to use (primarily foropenai).-s,--system_prompt: Optional system prompt passed as output instructions.-t,--max_turns: Maximum number of turns the model can use in a conversation step. Defaults to100.-h,--help: Show help.-v,--version: Show version.
Interactive Commands #
/new: clear the current conversation history/exit: quit the program
Built-in Tools #
The assistant exposes its tools through stage-specific agents built on BaseAgent:
AnalysisAgent: read-oriented planning before any edits are madeExecuteAgent: full tool access for making the requested changesVerifyAgent: read-oriented validation and final response generation
The full tool set includes fourteen tools:
powershell: runs a PowerShell command when PowerShell is availableglob: finds files by wildcard pattern usingfindgrep: searches file contents withrgsleep: waits for a requested durationbash: runs a shell command in the workspace, with approval checks for risky commandsread: reads a text file from an absolute path and returns numbered linesedit: edits an existing file using exact string replacementswrite: writes a file inside the workspaceask_user_question: asks the user one to three multiple-choice questionstask_create: creates a task in the current sessiontask_update: updates an existing session tasktask_list: lists session taskslist_mcp_resources: lists resources from the configured MCP backendread_mcp_resource: reads a specific MCP resource
Tool usage is surfaced in the terminal as status messages like [bash] ... and [bash] completed.
The runtime tracks files that have been read so edit and write can reject stale overwrites, keeps commands inside the workspace, and can pause for explicit approval before mutating or networked shell commands. These tools operate on the local machine, so use this project only in directories and environments you trust.
Each request now flows through three model stages. The analysis stage inspects the request and prepares a plan without modifying files, the execution stage applies changes, and the verification stage checks whether the request is fully satisfied. When verification fails, Lea Code can retry execution with verifier feedback for up to three attempts before returning the final response.
Project Structure #
bin/lea_code.dart: CLI entrypoint and REPL looplib/lea_code.dart: top-level application flow, staged agent orchestration, approval prompts, and question handlinglib/agents/base_agent.dart: shared Genkit wrapper and reusable tool-set mixinslib/agents/analysis_agent.dart: read-only planning agentlib/agents/execute_agent.dart: execution agent with editing toolslib/agents/verify_agent.dart: read-only verification agentlib/agents/general_agent.dart: compatibility export for agent classeslib/tools/: tool definitions exposed to the modellib/tools/runtime/: shared runtime for file tracking, task state, and approvalslib/tools/models/: runtime model classes shared across toolslib/tools/utils/: command safety and JSON schema helper utilities
Notes #
- API keys are passed via
--api_key(provider-dependent). You can still source them from environment variables in your shell (e.g.--api_key "$OPENAI_API_KEY"). - Tool output is returned directly to the model, including shell stderr when present.
- The installed executable is
lea. read,write, andeditexpect absolute file paths.grepusesrg, andglobusesfind.editand overwritingwriteoperations require the file to be read first in the current session.bashsupports optionalworkdirandtimeout_msinputs and prompts for approval when a command looks mutating, networked, or otherwise non-read-only.- MCP resource tools return an error unless an MCP adapter is configured for the session.