Skip to main content

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-code and 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_tasks for 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

nano_code-0.1.2.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nano_code-0.1.2-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file nano_code-0.1.2.tar.gz.

File metadata

  • Download URL: nano_code-0.1.2.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for nano_code-0.1.2.tar.gz
Algorithm Hash digest
SHA256 45d4907b8df598a36ca1b21130de2860d8c6d647c38a14a7ebbb976b1e92bdef
MD5 ffd8bfa1e89ae21d662e73221047ac2d
BLAKE2b-256 e8cf9c9b95d92df30cba1c982a6c22c0ab94d8ac4c1f81f43c58788d6455e6c3

See more details on using hashes here.

File details

Details for the file nano_code-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: nano_code-0.1.2-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

Hashes for nano_code-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2bf6953d4e481dca96a76197f6e5e968db1af79de8944418c0b39568078c0d50
MD5 b52fd45aa69d4182e7ecfcb5c6d0be28
BLAKE2b-256 559e08dcdfc149b19afe3fd23db2745e0b0cb39cbf7d151eeb4719684fe987a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page