agentleFS
Microsoft AzureKnown publisherAzure/co-op-translator/AGENTS.md

co-op-translator

AGENTS.md658 starsChanged 3 months agoMITView on GitHub

Co‑op Translator is a Python command‑line tool and GitHub Actions workflow that translates Markdown files, Jupyter notebooks, and image text into multiple languages. It organizes outputs under language‑specific folders and keeps translations synchronized with source content. The project is structured as a Poetry‑managed library with CLI entry points. Notes: - Default entrypoint is translate. Override with --entrypoint migrate-links for link migration. - Ensure GHCR package visibility is Public for anonymous pulls. Create a .env file at the repository root and…

  • Reads credentials
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

22 rules. About 1 is common, 12 are distinctive, and 9 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Default entrypoint is translate.

    line 76
  2. Distinctive:

    Ensure GHCR package visibility is Public for anonymous pulls.

    line 77
  3. Very specific:

    Create a .env file at the repository root and provide credentials/endpoints for your chosen language model and (optionally) vision service.

    line 88
  4. Common:

    Run tests from the repository root.

    line 160
  5. Very specific:

    Keep API keys and endpoints in .env or your CI secrets store.

    line 227
  6. Distinctive:

    Run affected notebooks completely

    line 236
  7. Distinctive:

    Verify all cells execute without errors

    line 237
  8. Distinctive:

    Check that outputs are appropriate

    line 238
  9. Distinctive:

    Update README.md if adding new concepts

    line 241
  10. Distinctive:

    Add comments in notebooks for complex code

    line 242
  11. Distinctive:

    Ensure markdown cells explain the purpose

    line 243
  12. Very specific:

    Avoid committing .env files (use .env.example)

    line 246
  13. Very specific:

    Don't commit venv/ or __pycache__/ directories

    line 247
  14. Distinctive:

    Keep notebook outputs when they demonstrate concepts

    line 248
  15. Very specific:

    Remove temporary files and backup notebooks (*-backup.ipynb)

    line 249
  16. Distinctive:

    Follow the style and formatting guidelines

    line 252
  17. Very specific:

    Run poetry run black . and poetry run ruff check .

    line 253
  18. Distinctive:

    Add or update tests when changing behavior

    line 256
  19. Distinctive:

    Keep CLI help consistent with changes

    line 257
  20. Distinctive:

    Use clear, concise titles.

    line 282
  21. Very specific:

    Prefer Poetry for reproducible environments.

    line 294
  22. Very specific:

    When invoking CLIs in CI, provide required secrets via environment variables or .env injection.

    line 295

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Project Overview

Co‑op Translator is a Python command‑line tool and GitHub Actions workflow that translates Markdown files, Jupyter notebooks, and image text into multiple languages. It organizes outputs under language‑specific folders and keeps translations synchronized with source content. The project is structured as a Poetry‑managed library with CLI entry points.

Architecture overview

  • CLI entry points (translate, migrate-links, evaluate) invoke a unified CLI that dispatches to translation, link migration, and evaluation flows.
  • Configuration loader reads .env and auto‑detects the LLM provider (Azure OpenAI or OpenAI) and, if requested, the vision provider (Azure AI Service) for image text extraction.
  • Translation core handles Markdown and notebooks; the vision pipeline extracts text from images when -img is used.
  • Outputs are organized into translations/<lang>/ for text and translated_images/ for images, preserving original structure.

Key technologies and frameworks

  • Python 3.11–3.14, Poetry for packaging
  • CLI: click
  • LLM/AI SDKs: Azure OpenAI, OpenAI, Semantic Kernel, Microsoft Agent Framework
  • Vision: Azure AI Service (Computer Vision)
  • HTTP and data: httpx, pydantic
  • Imaging: pillow, opencv-python, matplotlib
  • Tooling: pytest, black, ruff

Setup Commands

Prerequisites

  • Python 3.11–3.14
  • Azure subscription (optional, for Azure AI services)
  • Internet access for LLM/Vision APIs (e.g., Azure OpenAI/OpenAI, Azure AI Vision)

Option A: Poetry (recommended)

# From repository root
pip install poetry
poetry install

# Run any command via Poetry
poetry run translate --help

Option B: pip/venv

# Create & activate virtual environment
python -m venv .venv
# Windows
.venv\\Scripts\\activate
# Linux/macOS
# source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# (Optional) Editable install for local development
pip install -e .

End User Usage

Docker (published image)

# Pull public image from GHCR
docker pull ghcr.io/azure/co-op-translator:latest

# Run with current folder mounted and .env provided (Bash/Zsh)
docker run --rm -it --env-file .env -v "${PWD}:/work" ghcr.io/azure/co-op-translator:latest -l "fr es" -md

# PowerShell
docker run --rm -it --env-file .env -v ${PWD}:/work ghcr.io/azure/co-op-translator:latest -l "fr es" -md

Notes:

  • Default entrypoint is translate. Override with --entrypoint migrate-links for link migration.
  • Ensure GHCR package visibility is Public for anonymous pulls.

CLI (pip)

pip install co-op-translator
translate -l "fr es" -md

Environment configuration

Create a .env file at the repository root and provide credentials/endpoints for your chosen language model and (optionally) vision service. For provider-specific setup, see docs/azure-ai-setup.md.

Required Environment Variables

At least one LLM provider must be configured. For image translation, Azure AI Service must also be configured.

  • Azure OpenAI (text translation):
    • AZURE_OPENAI_API_KEY
    • AZURE_OPENAI_ENDPOINT
    • AZURE_OPENAI_MODEL_NAME
    • AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
    • AZURE_OPENAI_API_VERSION
  • OpenAI (text translation alternative):
    • OPENAI_API_KEY
    • OPENAI_ORG_ID (optional)
    • OPENAI_CHAT_MODEL_ID (required when using OpenAI provider)
    • OPENAI_BASE_URL (optional; defaults to https://api.openai.com/v1)
  • Azure AI Service for image text extraction (required when using -img):
    • AZURE_AI_SERVICE_API_KEY (preferred) or legacy AZURE_SUBSCRIPTION_KEY
    • AZURE_AI_SERVICE_ENDPOINT

Example .env snippet:

# Azure AI Service (for image translation)
AZURE_AI_SERVICE_API_KEY="..."
AZURE_AI_SERVICE_ENDPOINT="https://<your-ai-service>.cognitiveservices.azure.com/"

# Azure OpenAI (primary option)
AZURE_OPENAI_API_KEY="..."
AZURE_OPENAI_ENDPOINT="https://<your-azure-openai>.openai.azure.com/"
AZURE_OPENAI_MODEL_NAME="gpt-4o"
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME="<your-deployment>"
AZURE_OPENAI_API_VERSION="2024-12-01-preview"

# OpenAI (alternative option)
OPENAI_API_KEY="..."
OPENAI_ORG_ID="..."            # optional
OPENAI_CHAT_MODEL_ID="gpt-4o"   # required when using OpenAI
OPENAI_BASE_URL="https://api.openai.com/v1" # optional

Notes:

  • The tool auto-detects the available LLM provider; configure either Azure OpenAI or OpenAI.
  • Image translation requires both AZURE_AI_SERVICE_API_KEY and AZURE_AI_SERVICE_ENDPOINT.
  • The CLI will raise a clear error if required variables are missing.

Development Workflow

  • Source code lives under src/co_op_translator; tests under tests/.
  • Primary CLIs (installed via entry points):
# Translate content to one or more languages (space‑separated codes)
translate -l "fr es de"

# Restrict by content type
translate -l "ja" -md            # only Markdown
translate -l "ko" -nb            # only notebooks
translate -l "zh" -md -img       # Markdown + images

# Update links in previously translated notebooks/Markdown
migrate-links -l "all" -y

See additional usage docs in docs/.

Testing Instructions

Run tests from the repository root. Some tests may require API credentials; skip those when needed.

# Run full test suite
pytest

# Skip tests that require live API keys
pytest -m "not api_key_required"

# Run a subset
pytest tests/co_op_translator -k "name_substring"

Optional coverage (requires coverage):

coverage run -m pytest -m "not api_key_required"
coverage html  # outputs to ./htmlcov

Code Style Guidelines

  • Formatter: Black (configured in pyproject.toml, line length 88)
  • Linter: Ruff (configured in pyproject.toml, line length 120)
  • Type checks: mypy (configuration present; enable if installed)

Commands:

# Via Poetry
poetry run black .
poetry run ruff check .
poetry run ruff check . --fix   # safe auto‑fixes

# Or with global tools
black .
ruff check .

Organize Python sources under src/, tests under tests/, and prefer explicit imports within the package namespace (co_op_translator.*).

Build and Deployment

Build artifacts are published to dist/.

# Build (Poetry)
poetry build

# Local install of the built wheel
pip install dist/*.whl

Automation via GitHub Actions is supported; see:

  • docs/github-actions.md

Container Image (GHCR)

  • Official image: ghcr.io/azure/co-op-translator:<tag>
  • Tags: latest (on main), semantic tags like vX.Y.Z, and a sha tag
  • Multi-arch: linux/amd64, linux/arm64 supported via Buildx
  • Dockerfile pattern: build dependency wheels in builder (with build-essential and python3-dev) and install from local wheelhouse in runtime (pip install --no-index --find-links=/wheels)
  • Workflow: .github/workflows/docker-publish.yml builds and pushes to GHCR

Security Considerations

  • Keep API keys and endpoints in .env or your CI secrets store; never commit secrets.
  • For image translation, Azure AI Vision keys/endpoints are required; otherwise omit -img.
  • Validate provider quotas/rate limits when running large translation batches.

Pull Request Guidelines

Before Submitting

  1. Test your changes:
    • Run affected notebooks completely
    • Verify all cells execute without errors
    • Check that outputs are appropriate
  2. Documentation updates:
    • Update README.md if adding new concepts
    • Add comments in notebooks for complex code
    • Ensure markdown cells explain the purpose
  3. File changes:
    • Avoid committing .env files (use .env.example)
    • Don't commit venv/ or __pycache__/ directories
    • Keep notebook outputs when they demonstrate concepts
    • Remove temporary files and backup notebooks (*-backup.ipynb)
  4. Style and formatting:
    • Follow the style and formatting guidelines
    • Run poetry run black . and poetry run ruff check . to check for style and formatting issues
  5. Add/update tests and CLI help:
    • Add or update tests when changing behavior
    • Keep CLI help consistent with changes

Commit message and merge strategy

We use Squash and Merge as the default. The final squash commit message should follow:

<type>: <description> (#<PR number>)

Allowed types:

  • Docs — documentation updates
  • Build — build system, dependencies, configuration/CI
  • Core — core functionality and features (e.g., src/co_op_translator/core)

Examples:

  • Docs: Update installation instructions for clarity (#50)
  • Core: Improve handling of image translation (#60)

Notes:

  • PR titles are often auto-prefixed based on labels; verify the generated prefix is correct.

PR Title Format

Use clear, concise titles. Prefer the same structure as the final squash commit:

  • Docs: Update installation instructions for clarity
  • Core: Improve handling of image translation

Debugging and Troubleshooting

  • Common issues and fixes: docs/troubleshooting.md
  • Supported languages and notes (including fonts/known issues): docs/supported-languages.md
  • For link issues in notebooks, re‑run: migrate-links -l "all" -y

Notes for Agents

  • Prefer Poetry for reproducible environments; otherwise use requirements.txt.
  • When invoking CLIs in CI, provide required secrets via environment variables or .env injection.
  • For monorepo consumers, this repo acts as a standalone package; no sub‑package coordination is required.
  • Multi-arch guidance: keep linux/arm64 when ARM users (Apple Silicon/ARM servers) are a target; otherwise linux/amd64 only is acceptable for simplicity.
  • Point users to Docker Quick Start in README.md when they prefer container usage; include Bash and PowerShell variants due to quoting differences.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.