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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nano_code-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e5c1ab29df0bc9b2dbfb5eacaa7338955a206e97317bf29506c72134f21fd6f5
MD5 5e1baf52fc340488d4273ceee8d40f5e
BLAKE2b-256 0fa685698dc72fae05a80441bcd75cb600c9f953fd89d9c5ec99a61874f4fd75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nano_code-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65f00b5968fd5de9f89056f30e85dd6a7e730df488b5c3192b160ec41e5964a0
MD5 b51149af9aefac326d0ec9b42b3eac62
BLAKE2b-256 1ebdeeea635d05cd4e7259ed710adc08c5c98fecfe0340d818b4c123cdc58b10

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