A Python Implementation of Gemini Code
Project description
nano-code is a tiny, batteries-included code-assistant written in Python. Inspired by Googleโs Gemini Code, it lets you spin up an interactive CLI agent powered by OpenAI (or any compatible) LLM and a growing toolbox of actions such as reading files, listing directories, searching text and more.
The project aims to be small enough to grok in one sitting yet powerful enough to be genuinely useful when navigating or refactoring real-world codebases.
โจ Features
| Feature | Description |
|---|---|
| โก Instant CLI | Run nano-code and start chatting immediately |
| ๐ Rich Toolset | Built-in tools for filesystem operations and more |
| ๐ง Smart Memory | Persistent session context with cost tracking |
| ๐ Pluggable LLMs | OpenAI-compatible with easy provider switching |
| ๐ฆ Zero Config | Works out of the box with sensible defaults |
Built-in Tools
- File Operations:
list_dir,find_files,read_file,write_file,edit_file,mv_file_or_dir - Search & Analysis:
search_textwith regex support - Task Management:
add_tasksfor quick TODO capture - Easy Extensibility: Simple plugin system for custom tools
๐ Installation
Quick Start (Recommended)
# Install and run with uv (fastest)
uvx nano-code@latest
Development Setup
# Clone the repo
git clone https://github.com/gusye1234/nano-code.git
cd nano-code
# Install with uv (recommended)
uv sync
# Or install in development mode
uv pip install -e '.[dev]'
# Or use pip
pip install -e '.[dev]'
Requirements
- Python โฅ 3.11
- OpenAI-compatible API key
Environment Setup
# Required: Set your OpenAI API key
export OPENAI_API_KEY="sk-..."
# Optional: Custom endpoint (for OpenAI-compatible APIs)
export LLM_BASE_URL="https://api.openai.com/v1"
# Optional: Default model override
export LLM_MAIN_MODEL="gpt-4.1"
โ๏ธ Configuration
Configure nano-code using either environment variables or a config file. Environment variables take precedence over config files.
Method 1: Environment Variables (Recommended)
export OPENAI_API_KEY="sk-..." # Required
export LLM_BASE_URL="https://api.openai.com/v1" # Optional
export LLM_MAIN_MODEL="gpt-4.1" # Optional
Method 2: Config File
Create ~/.nano_code/config.json:
{
"llm_api_key": "sk-...",
"llm_base_url": "https://api.openai.com/v1",
"llm_main_model": "gpt-4.1"
}
Config file locations:
- Linux/macOS:
~/.nano_code/config.json - Windows:
%USERPROFILE%\.nano_code\config.json
See nano_code/env.py for all supported configuration options.
๐โโ๏ธ Quickstart
One-liner (Recommended)
uvx nano-code
From source
# After installing from source
python -m nano_code
# OR
nano-code
First Run
- Run
nano-codein your project directory - The agent will start with your current directory as the working context
- Start chatting! Try:
- "List all Python files in this project"
- "Find TODO comments in the codebase"
- "Read the main README file"
๐ Project Structure
nano-code/
โโโ nano_code/ # Core library package
โ โโโ agent/ # Agent implementations
โ โโโ agent_tool/ # Tool system
โ โ โโโ os_tool/ # Filesystem operations
โ โ โโโ util_tool/ # Utility functions
โ โโโ core/ # Session & memory management
โ โโโ llm/ # LLM integrations
โ โโโ utils/ # Shared utilities
โ โโโ constants.py # Configuration constants
โ โโโ env.py # Environment configuration
โ โโโ __main__.py # CLI entry point
โโโ tests/ # Comprehensive test suite
โโโ pyproject.toml # Project configuration
โโโ README.md # Documentation
Key Components
- Session System: Maintains context across interactions
- Tool Registry: Pluggable architecture for custom tools
- LLM Abstraction: Provider-agnostic LLM interface
- Cost Tracking: Real-time usage and cost monitoring
๐ค Contributing
We welcome contributions! The codebase is intentionally small and designed for easy extension.
Getting Started
# Clone and setup
git clone https://github.com/gusye1234/nano-code.git
cd nano-code
uv sync
# Run tests
pytest -q
# Run tests with coverage
pytest --cov=nano_code tests/
Contribution Guidelines
- Add new tools: Easy plugin system for custom functionality
- Improve documentation: Help make the project more accessible
- Extend test coverage: Ensure reliability for all features
- Report bugs: Create issues for any problems you encounter
For significant changes, please open an issue first to discuss your approach.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ท๏ธ Disclaimer
Any git commit that starts with nc: is written by nano-code itself.
Built with โค๏ธ by the nano-code community
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nano_code-0.1.5.tar.gz.
File metadata
- Download URL: nano_code-0.1.5.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
807e96e609bd5236b4bd3873b5d30a7401f33e1e34e5364330d2299132b762c6
|
|
| MD5 |
46c3a40af27d5c32dfc326e738e3a155
|
|
| BLAKE2b-256 |
05383ca014d8a3c0308afb80d6baf37522e1c76ce014e43b77e2865545a6f6d1
|
File details
Details for the file nano_code-0.1.5-py3-none-any.whl.
File metadata
- Download URL: nano_code-0.1.5-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aae12f8293538dd9e00bdf3190b02390c6382845beab37b0681bcd32fb21386
|
|
| MD5 |
cab59ad4ff5c8938463425e3dadc497b
|
|
| BLAKE2b-256 |
ae1c4d9d8a3955a8243b02a2956c9c77a88ef02c715e10a3decb5252b08c3dad
|