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.3.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.3-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

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

Hashes for nano_code-0.1.3.tar.gz
Algorithm Hash digest
SHA256 be7ed6dac02b487b8cb02a631b6e4a58bbbb990a055c376b77a4ec69104bf6e7
MD5 a3e4982638f5a4ef5b400718965ff1c1
BLAKE2b-256 66ceffa1e53f4aa2eb3f3cce666f63a9e0ac377ca5bf263de4f94c74323f8d1a

See more details on using hashes here.

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

Hashes for nano_code-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4cd7e9e4d77d6453bc9a3c18f2aedb0406fbe6938a2704462fad4f2c44fac974
MD5 9f2464eb107ae480d9e2ece2279c2c9b
BLAKE2b-256 b6075cbe7e728a602bec82b20a21378e2b05495e729c45105abfd1c56e7a488f

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