Skip to main content

Zenco

PyPI version Tests Code Quality License: MIT Python 3.9+

Zenco is an AI-powered code analysis and enhancement tool that supports multiple programming languages. It automatically generates docstrings, adds type hints, detects magic numbers, removes dead code, and provides intelligent refactoring suggestions using Large Language Models (LLMs).

This project was built on a foundation of solid Object-Oriented Programming principles and design patterns, including the Visitor, Strategy, Factory, and Adapter patterns.


Core Features

Multi-Language Support

  • Python, JavaScript, Java, Go, C++ - Full support across major programming languages
  • Tree-sitter powered - Fast, accurate parsing for all supported languages

AI-Powered Code Enhancement

  • Docstring Generation: Context-aware docstrings for functions and classes
  • Type Hint Addition: Intelligent type annotations for Python functions
  • Magic Number Detection: Identifies and replaces numeric literals with named constants
  • Dead Code Removal: Detects and removes unused imports, variables, and functions
  • Strict Mode: Advanced cleanup including unused local variables and private methods

Developer Experience

  • Multiple LLM Providers: Support for Groq, OpenAI, Anthropic, and Google Gemini
  • Colorful Terminal Output: Rich, beautiful command-line interface
  • Umbrella Commands: --refactor and --refactor-strict for comprehensive code improvement
  • Git Integration: Process only changed files with --diff
  • Safe Preview Mode: See changes before applying with dry-run by default

Installation

Install Zenco directly from PyPI:

pip install zenco

Quick Start

  1. Initialize your project:
zenco init

This interactive wizard helps you configure your preferred AI provider (Groq, OpenAI, Anthropic, or Gemini).

  1. Preview changes on a file:
zenco run myfile.py --refactor
  1. Apply comprehensive improvements:
zenco run . --refactor-strict --in-place

Configuration

Zenco uses a .env file for secrets and a pyproject.toml file for project-wide settings.

1. API Credentials (.env)

The zenco init command will create this for you. Example:

GROQ_API_KEY="gsk_YourActualGroqApiKeyHere"
GROQ_MODEL_NAME="llama3-8b-8192"
ZENCO_PROVIDER="groq"

Usage Examples

Basic Commands

# Get help
zenco --help
zenco run --help

# Preview changes (dry run)
zenco run myfile.py --docstrings
zenco run . --refactor

# Apply changes
zenco run myfile.py --docstrings --in-place
zenco run . --refactor-strict --in-place

Feature-Specific Usage

# Add type hints to Python files
zenco run . --add-type-hints --in-place

# Fix magic numbers across languages
zenco run . --fix-magic-numbers --in-place

# Remove dead code (safe mode)
zenco run . --dead-code --in-place

# Remove dead code (strict mode - includes locals)
zenco run . --dead-code --dead-code-strict --in-place

# Process only Git-changed files
zenco run . --diff --refactor --in-place

Umbrella Commands

# Safe refactor: docstrings + type hints + magic numbers + dead code
zenco run . --refactor --in-place

# Strict refactor: includes unused local variables and private methods
zenco run . --refactor-strict --in-place

JSON Output Mode

# Get structured JSON output for IDE/extension integration
zenco run myfile.py --docstrings --json

# JSON output includes: filepath, language, changes, stats, and error information
zenco run . --refactor --json --in-place

The --json flag outputs structured data suitable for programmatic consumption, including:

  • File processing results with success status
  • Original and modified content
  • Detailed change metadata (type, line number, description)
  • Statistics (docstrings added, type hints added, etc.)
  • Error information if processing fails

How It Works

Zenco uses a "Tree-sitter + AI" architecture for fast, accurate multi-language support:

  1. Tree-sitter Parsing: Fast, incremental parsing for Python, JavaScript, Java, Go, and C++
  2. Pattern Detection: Identifies missing docstrings, magic numbers, unused code, and type annotation opportunities
  3. AI Enhancement: Sends relevant code context to your chosen LLM for intelligent suggestions
  4. Safe Transformation: Applies changes using precise byte-level edits with the CodeTransformer
  5. Multi-Provider Support: Works with Groq, OpenAI, Anthropic, and Google Gemini APIs

🤝 Contributors

We thank all the people who contribute to Zenco! Your contributions make this project better.

🎉 How to Contribute

🏆 Notable Contributions

  • Initial Development: @paudelnirajan - Core architecture, multi-language support
  • Future contributors will be listed here as they join the project!

Made with ❤️ by the Zenco community

License

This project is licensed under the MIT License.

Metadata

Release files for zenco 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zenco 1.3.1
File Size Uploaded Provenance Actions
zenco-1.3.1.tar.gz 41.3 kB Without provenance Details for zenco-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zenco 1.3.1
File Interpreter ABI Platform Actions
zenco-1.3.1-py3-none-any.whl Python 3 none any Details for zenco-1.3.1-py3-none-any.whl

Total release size: 78.7 kB

Release files / zenco-1.3.1.tar.gz

Download URL zenco-1.3.1.tar.gz
Size 41.3 kB
Tags Source
SHA-256 checksum
How to use checksums
feae0189816445d2a8711150f1bac3a1c73a9b8b3135560d4b5efae116ba6e40
BLAKE2b-256 checksum
How to use checksums
7728cdd5ea485ffccb852d21745fea3865a4d67c95921eb92a872818aef2f6c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / zenco-1.3.1-py3-none-any.whl

Download URL zenco-1.3.1-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ff9b837b3a94159624bbca7c126e633839fcab36bf520e30c46786677037f9f
BLAKE2b-256 checksum
How to use checksums
e43d29966c7a17cf166d1730304317b9aeb084cfd1e2081d620187f9c775e5ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for zenco 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page