A lightweight, extensible Python-first Code Agent framework for code generation, execution, and tooling with LLMs.
PyTo AI automates your Git workflow by using LLMs to generate commit messages and merge request descriptions. It integrates with GitLab via glab CLI and supports bilingual (Chinese/English) interfaces.
- AI-powered commit messages — Generates conventional commit messages from your staged diff
- AI-powered merge requests — Creates structured MR titles and descriptions with background, changes, and impact sections
- Branch sync analysis — Detects divergence from the target branch and recommends rebase strategies
- GitLab integration — Creates MRs and opens them in your browser via
glab - Bilingual support — Chinese (
zh) and English (en) prompts and UI - Fallback to manual input — If LLM generation fails, prompts for manual input
# Clone the repository
git clone https://github.com/JoshYuJump/pyto-ai.git
cd pyto-ai
# Install with uv
uv syncCreate ~/.pyto/settings.json (auto-created on first run with defaults):
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your-api-key-here",
"ANTHROPIC_BASE_URL": "https://api.anthropic.com"
},
"model": "claude-sonnet-4-20250514"
}PyTo Code uses the Anthropic API via Pydantic AI. You can point ANTHROPIC_BASE_URL to any Anthropic-compatible endpoint (e.g., Aliyun Dashscope, AWS Bedrock).
Create a pyto.toml in your project root:
[general]
language = "en" # "en" for English, "zh" for Chinese
[gitflow]
gitlab_host = "gitlab.example.com"
gitlab_port = "443"
repo_name = "group/project"
develop_branch = "main"For the submit command, install and authenticate glab:
glab auth loginStage changes, generate a commit message with AI, and push:
pyto commitSkip the confirmation prompt:
pyto commit --skip-reviewCommit, push, and create a GitLab merge request:
pyto submitSkip the confirmation prompt:
pyto submit --skip-reviewThe submit workflow will:
- Check for uncommitted changes
- Stage and commit with an AI-generated message
- Analyze branch divergence from the target branch
- Optionally sync/rebase with the target branch
- Push to remote
- Generate MR title and description with AI
- Create the MR and open it in your browser
pyto/
├── __init__.py # Package version
├── main.py # CLI entry point (argparse)
├── llm.py # LLM settings & Pydantic AI agent factory
└── commands/
├── __init__.py
├── commit.py # GitWorkflow — commit & push
└── submit.py # SubmitWorkflow — commit, push & MR
The framework uses Pydantic AI for structured LLM interactions. Each command creates a typed agent with a Pydantic output model (CommitMessage, MRContent) to ensure responses conform to the expected schema.
# Install dev dependencies
uv sync --group dev
# Run tests
uv run pytest
# Lint
uv run ruff check .