lea_code 0.0.7
lea_code: ^0.0.7 copied to clipboard
A command-line coding assistant powered by Genkit and Google Gemini.
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
- 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
- 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 now registers fourteen tools through GeneralAgent:
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.
Project Structure #
bin/lea_code.dart: CLI entrypoint and REPL looplib/lea_code.dart: top-level application flow, approval prompts, and question handlinglib/agents/general_agent.dart: Genkit setup and tool registrationlib/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.