lattice-code is a powerful command-line tool that leverages an AI agent for code generation and modification tasks directly in your local workspace. It can be run as an interactive TUI or in a headless mode for single-shot generation.
It is built on top of the Lattice Go Agent Framework.
- Interactive TUI: A terminal-based user interface for conversational code generation.
- Headless Mode: Run a single generation task from the command line and have the files written directly to your workspace.
- Workspace Awareness: The agent is provided with the file tree of your current project, allowing it to understand the context and make relevant changes.
- File Operations: The agent can create, modify, and delete files as needed to complete its task.
To build the lattice-code CLI from source:
# Clone the mcp repository
go install https://github.com/Protocol-Lattice/lattice-code-runner@latest
# Build mcp
git clone https://github.com/Protocol-Lattice/lattice-code.git
cd lattice-code
# Build mcp
chmod +x install.sh
./install.shThe agent requires API keys for the underlying LLM provider (e.g., Gemini). Ensure you have the necessary environment variables set.
export GEMINI_API_KEY="YOUR_API_KEY"To start the interactive terminal UI, simply run the command:
./lattice-codeThe headless package provides functionality to run a single generation turn.
// See src/headless.go for an example of how to run a single generation turn.
RunHeadless(ctx, agent, "./workspace", "My task is to create a new Go web server.")lattice-code works by:
- Collecting the file structure of your current workspace.
- Constructing a detailed prompt that includes your task and the file tree.
- Sending this context to a powerful AI agent.
- The agent responds with a plan and a series of markdown code blocks.
lattice-codeparses these blocks, extracts file paths from special// path: ...comments, and writes the content to your local file system.
