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
- ⚡ Agent CLI – run
nano-codeand start chatting immediately. - 🛠 Basic Tools – easily add new tools. Out-of-the-box you get:
list_dir,find_files,read_file,write_file,search_text…add_tasksfor quick TODO-list capture.
- 🧠 Session memory – every run stores context (working dir, conversation, cost tracking).
- 🔌 Pluggable LLM – ships with an OpenAI client but the design allows dropping in other providers.
🚀 Installation
We recommend the blazingly fast uv package manager, but classic pip works too.
# 1. Clone the repo (optional – the package can also live on PyPI later)
git clone https://github.com/gusye1234/nano-code.git
cd nano-code
# 2. Install (requires Python ≥ 3.11)
uv sync
# or for editable dev installs (includes test dependencies)
uv pip install -e '.[dev]'
# fallback (slower) – replace `uv pip` with classic pip if you don't have uv
Make sure you have an OpenAI-compatible API key in your environment:
export OPENAI_API_KEY="sk-..."
# Optional – point to an OpenAI-compatible endpoint
export LLM_BASE_URL="https://api.openai.com/v1"
⚙️ Configuration
nano-code supports configuration via environment variables and an optional config file. You must provide an OpenAI-compatible API key, and can customize the LLM endpoint or other defaults if desired.
Option 1: Environment variables (recommended for quickstart)
Option 2: config.json file
You can optionally create a config file at:
~/.nano_code/config.json
Where ~ is your home directory (e.g., /home/yourname/.nano_code/config.json on Linux/macOS, or C:\Users\yourname\.nano_code\config.json on Windows).
Example contents:
{
"llm_api_key": "sk-...",
"llm_base_url": "https://api.openai.com/v1",
"llm_main_model": "gpt-4.1"
}
- Any keys matching the Env class (see
nano_code/env.py) are supported. - File-based config takes effect if present, otherwise environment variables are used as fallback.
🏃♀️ Quickstart
uvx nano-code
🗂 Project structure
nano-code/
├── nano_code/ # Library package
│ ├── agent/ # Agent implementations (interactive / non-interactive)
│ ├── agent_tool/ # Tool registry & concrete tools
│ │ ├── os_tool/ # File-system helpers (list_dir, read_file, ...)
│ │ └── util_tool/ # Misc utilities (add_tasks)
│ ├── core/ # Session handling, cost tracking
│ ├── llm/ # LLM client abstraction & OpenAI driver
│ ├── utils/ # Shared helpers (logger, file paths)
│ ├── constants.py # Global paths & limits
│ ├── env.py # Runtime configuration loader
│ └── __main__.py # CLI entry-point (`python -m nano_code`)
├── tests/ # Pytest suite exercising tools & flows
├── pyproject.toml # Project metadata / dependencies
└── README.md # ← You are here
🤝 Contributing
Pull requests are welcome! The codebase is intentionally small – feel free to add new tools, improve docs or extend test coverage. For larger changes, please open an issue first to discuss what you would like to change.
# run the tests
pytest -q
📜 License
This project is licensed under the MIT License. See LICENSE for details.
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.4.tar.gz.
File metadata
- Download URL: nano_code-0.1.4.tar.gz
- Upload date:
- Size: 86.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9d92133d831078ca7122db28a3fe2ba638161cb5e3f5f97a78a38d8f6031a23
|
|
| MD5 |
0c09f2f96507dcb94d7da6648e1cb405
|
|
| BLAKE2b-256 |
d9c5d09a99337b0084e093ce1ccbccc9de27a3fcaaaebf81885524381324c7ae
|
File details
Details for the file nano_code-0.1.4-py3-none-any.whl.
File metadata
- Download URL: nano_code-0.1.4-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c6e77d3e2af3d69f8ad7dd22b08b3f643238fbdcfcd7edd5330da768dfbae94
|
|
| MD5 |
90e0a9cde6a21186c7a132ca3a1debed
|
|
| BLAKE2b-256 |
3e73105ffd93ffdeeed1cc396cb841c285b26428e3968aa3e07e26718a0dd808
|