AI-powered code translator using Claude Sonnet 4.5's extended thinking
Project description
🌍 Polyglot - AI Code Translator
An AI-powered CLI tool that translates code between programming languages using Claude Sonnet 4.5's extended thinking capabilities.
Features
- 🧠 Extended Thinking - See the AI's reasoning process as it translates
- 🎨 Idiomatic Translation - Not just syntax conversion, but proper language idioms
- ⚡ Smart Optimization - Optimizes for target language best practices
- 📊 Side-by-side Comparison - Visual diff of source and target
- 🎯 12+ Languages - Python, Rust, Go, TypeScript, Java, C++, and more
Installation
Option 1: Install from PyPI (Recommended)
pip install polyglot-cli
# Set your API key
export ANTHROPIC_API_KEY='your-key-here'
Option 2: Install from source
git clone https://github.com/samar/polyglot-cli.git
cd polyglot-cli
pip install -e .
# Set your API key
export ANTHROPIC_API_KEY='your-key-here'
Option 3: Use pipx (Isolated installation)
pipx install polyglot-cli
export ANTHROPIC_API_KEY='your-key-here'
Usage
Translate a file
polyglot translate python rust --file example.py
Translate from stdin
echo 'def hello(): print("hi")' | polyglot translate python go
Save output
polyglot translate python rust --file example.py --output example.rs
Hide AI reasoning
polyglot translate python rust --file example.py --no-thinking
List supported languages
polyglot languages
Examples
Python → Rust
polyglot translate python rust --file example.py
The AI will:
- Show its thinking process (how it approaches the translation)
- Convert Python's dynamic types to Rust's static types
- Replace Python's dict cache with Rust's HashMap
- Use idiomatic Rust patterns
- Show side-by-side comparison
JavaScript → Go
polyglot translate javascript go --file api.js
Converts async/await to Go's goroutines and channels!
Why Polyglot?
This showcases Claude Sonnet 4.5's extended thinking - you can literally see the AI reasoning through:
- Type system differences
- Memory management patterns
- Idiomatic conventions
- Performance trade-offs
It's not just translating syntax, it's understanding and adapting code philosophy between languages!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polyglot_cli-0.1.0.tar.gz.
File metadata
- Download URL: polyglot_cli-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f889dad85ea80c647aab5cffe21963bb906212f98e40c2727c8532d2f8e7ec7
|
|
| MD5 |
cad90fabe7260005140f5e90826e9ddc
|
|
| BLAKE2b-256 |
e488985d1ee2b34cde2195118c2df50bbaa00bf68782d9fb799c1848b15333a3
|
File details
Details for the file polyglot_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: polyglot_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c4dae974da6e9cff70b06bbd4f0b0f1f01d09283563622b5c83757f73d9513f
|
|
| MD5 |
7e2015c1a8abce8aade5c8461d936a08
|
|
| BLAKE2b-256 |
53f359077528ca99c8293ceab7c1e4b79db3dc3b2d241cc6e02042d8a9e0596a
|