Skip to main content

AI-powered code analysis and enhancement tool with multi-language support for docstrings, type hints, magic numbers, and dead code detection.

Project description

Zenco

PyPI version License: MIT

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"
AUTODOC_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

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

License

This project is licensed under the MIT License.

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

zenco-1.0.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

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

zenco-1.0.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file zenco-1.0.0.tar.gz.

File metadata

  • Download URL: zenco-1.0.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for zenco-1.0.0.tar.gz
Algorithm Hash digest
SHA256 454b1740d61d607aeebcd7bedd66ca43de1bd9858bcd4082af580810172e861c
MD5 350971feb9d3d4a0c6a079fc55437352
BLAKE2b-256 e50de8e8e5ab8ee9b93ba0af1271fef99b41ecaeb589193a766586d800141949

See more details on using hashes here.

File details

Details for the file zenco-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: zenco-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for zenco-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 892b4b792d912406501e9d20a7dbe3a2e514ac7ad7db352ef56c440537cc0f01
MD5 285eea12f1f4b513e23d481622db544e
BLAKE2b-256 7d25f142e017595b7b1a3b73cbf4b700732de7420f3d94843f2cfa237a914041

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