A Python Implementation of Gemini Code
Project description
nano-code ๐งฌ๐
nano-code is a tiny, batteries-included code-assistant framework written in Python 3.11+. Inspired by Googleโs Gemini Code demo, 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
- โก Single-file CLI โ run
nano-codeand start chatting immediately. - ๐ Agent Tools API โ 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.
- ๐งช Pytest suite โ examples for how to test agents & tools.
๐ 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"
๐โโ๏ธ Quickstart
uvx nano-code
Behind the scenes the agent converts your plain-English requests into JSON arguments for the tools defined in nano_code/agent_tool. Every tool returns two flavours of output: one optimised for the LLMโs next prompt (for_llm) and one for the human terminal (for_human).
๐ 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.3.tar.gz.
File metadata
- Download URL: nano_code-0.1.3.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be7ed6dac02b487b8cb02a631b6e4a58bbbb990a055c376b77a4ec69104bf6e7
|
|
| MD5 |
a3e4982638f5a4ef5b400718965ff1c1
|
|
| BLAKE2b-256 |
66ceffa1e53f4aa2eb3f3cce666f63a9e0ac377ca5bf263de4f94c74323f8d1a
|
File details
Details for the file nano_code-0.1.3-py3-none-any.whl.
File metadata
- Download URL: nano_code-0.1.3-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cd7e9e4d77d6453bc9a3c18f2aedb0406fbe6938a2704462fad4f2c44fac974
|
|
| MD5 |
9f2464eb107ae480d9e2ece2279c2c9b
|
|
| BLAKE2b-256 |
b6075cbe7e728a602bec82b20a21378e2b05495e729c45105abfd1c56e7a488f
|