Metadata-Version: 2.4
Name: acps-translation-forge
Version: 1.0.0
Summary: Protocol-native multi-agent contrastive translation studio for CATTI preparation, commercial contracts and business correspondence. A Literal Agent exposes grammatical and lexical transfer faults, a Native Agent rebuilds drafts into idiomatic target-language prose, and a Critique Agent annotates each rewrite with techniques like part-of-speech shift, amplification and omission. ACPs discovery, AIP v2 orchestration and typed products yield auditable, technique-level learning reports.
Author: ACPs Translation Forge Engineering
License-Expression: MIT
Project-URL: Homepage, https://pypi.org/project/acps-translation-forge/
Project-URL: Source, https://github.com/acps-labs/acps-translation-forge
Keywords: acps,acps-sdk,multi-agent,aip,translation,contrastive-translation,catti,business-english,contract-translation,education-technology
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: End Users/Desktop
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Education
Classifier: Topic :: Education :: Computer Aided Instruction (CAI)
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: acps-sdk==2.1.0
Requires-Dist: fastapi>=0.100.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: uvicorn>=0.27.0
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff>=0.6.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"

# ACPs Translation Forge

> Protocol-native multi-agent contrastive translation for people who need to
> *understand* a translation decision, not just receive a finished sentence.

**acps-translation-forge 1.0.0** is a professional contrastive translation
workbench built on **acps-sdk 2.1.0**. It is designed for CATTI translation
preparation, commercial contract and quotation drafting, and business-letter
practice where a learner must defend every word choice.

Instead of returning one opaque translation, three independent ACPs agents
collaborate through AIP v2 tasks:

1. **Literal Agent** produces a deliberate word-for-word gloss, preserving source
   word order and exposing grammar, collocation and register faults.
2. **Native Agent** consumes that validated literal product and rebuilds each
   segment with target-language constructions and business-letter conventions.
3. **Critique Agent** compares both versions, names the translation technique
   behind every rewrite (part-of-speech shift, amplification, omission,
   inversion, recast, register control), and turns the contrast into CATTI-style
   drills.

A Leader discovers each skill through ADP, dispatches tasks over JSON-RPC,
validates every structured product and returns one auditable report.

## Naming

`acps-translation-forge` combines three ideas:

- **ACPs** — the agent capability protocol stack the project is built on.
- **Translation** — the domain: Chinese-English business correspondence.
- **Forge** — a workshop where raw literal metal is hammered into native-quality
  prose. The name signals craft and an auditable production pipeline, not a
  one-shot toy translator.

The PyPI distribution uses hyphens (`acps-translation-forge`); the import package
uses underscores (`translation_forge`).

## Why three agents instead of one translator?

| Concern | Single black-box translator | Translation Forge mesh |
| --- | --- | --- |
| Diagnosis | only a final sentence | literal gloss with segment-level risk labels |
| Decision visibility | hidden | every rewrite linked to a named technique |
| Learning value | copy the answer | contrastive explanation plus drills |
| Register control | inconsistent | dedicated salutation/closing/signature handling |
| Auditability | one response | ACS capability, ADP discovery, AIP task id, state and latency per hop |
| Failure isolation | one prompt owns everything | typed request/product validation at every agent boundary |

The collaboration is real JSON-RPC between three independently hosted services:

```text
                         ┌──────────────────┐
User letter ─> Leader ──>│  Literal Agent   │
                         └────────┬─────────┘
                                  │ LiteralReport
                                  ▼
                         ┌──────────────────┐
                         │  Native Agent    │
                         └────────┬─────────┘
                                  │ NativeReport
                                  ▼
                         ┌──────────────────┐
                         │  Critique Agent  │
                         └────────┬─────────┘
                                  │ CritiqueReport
                                  ▼
                         TranslationReport
```

Each downstream agent consumes the previous agent's structured product. The
report is therefore built from three auditable hops, not three independent
opinions on the raw text.

## Real application scenarios

- **CATTI 笔译备考**：练完一段译文后，先看直译暴露了哪些“字面对应”的陷阱，
  再对照地道译文和技巧标签复盘，而不是只背参考译文。
- **商务合同/报价函翻译**：检查“收悉”“敬请查收”“给予百分之五折扣”等套语
  是否被逐字硬译，确保语域与术语一致。
- **日常商务信函练习**：用同一封函件练习正式函件、邮件简写两种文体，观察
  敬语层级如何变化。
- **翻译教学与教研**：报告中的每一组对照都有可审计的技巧标签，便于课堂讲评。

## Project layout

```text
acps-translation-forge/
├── pyproject.toml
├── README.md
├── run_demo.py
├── src/translation_forge/
│   ├── __init__.py
│   ├── __main__.py
│   ├── agents/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   ├── critique.py
│   │   ├── literal.py
│   │   └── native.py
│   ├── cli.py
│   ├── corpus.py
│   ├── critique_engine.py
│   ├── demo.py
│   ├── identity.py
│   ├── leader.py
│   ├── lexicon.py
│   ├── literal_engine.py
│   ├── mesh.py
│   ├── models.py
│   ├── native_engine.py
│   ├── py.typed
│   ├── registry.py
│   ├── report.py
│   ├── runtime.py
│   └── segmentation.py
└── tests/test_end_to_end.py
```

## Install

Python 3.10 or newer is required.

```bash
python -m venv .venv

# Windows PowerShell
.venv\Scripts\Activate.ps1
# macOS / Linux: source .venv/bin/activate

python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
```

The runtime dependency is pinned with `acps-sdk==2.1.0`; FastAPI, uvicorn,
Pydantic and HTTPX host the local AIP services and typed payloads.

## One-click demo

```bash
python run_demo.py
# equivalent after installation:
translation-forge demo
# or:
python -m translation_forge demo
```

The script starts all three agent services, submits the built-in Chinese business
letter, runs the full pipeline and prints the contrastive report. Stable content
includes:

```text
==============================================================================
ACPs Translation Forge v1.0.0 · 多智能体对比式翻译工坊
本次方向：中文 → 英文
==============================================================================
本地 AIP v2 网格已启动（每个 Specialist 独立 RPC 端点）：
  · Literal Agent    ... instance 000301
  · Native Agent     ... instance 000302
  · Critique Agent   ... instance 000303

## 2. Literal Agent · 直译底稿

Respected Mr. Smith:

Thank you on November 18, 2026 's incoming letter. Your esteemed company about
intelligent warehouse system procurement 's inquiry, our side already receive
and know and deeply interest. Through study, our side agree at contract total
amount on the basis give your side 5 percent 's discount. Along with the letter
attach revised quotation, please check and receive. If receive early reply,
extremely grateful.

## 3. Native Agent · 地道译文

Dear Mr. Smith,

Thank you for your letter dated November 18, 2026. We acknowledge receipt of
your inquiry regarding the procurement of an intelligent warehousing system and
are deeply interested in it. Upon review, we agree to offer you a 5% discount on
the total contract value. Please find the revised quotation enclosed for your
review. We would appreciate your prompt reply.

Yours sincerely,

Li Ming
Purchasing Manager
East China Intelligent Manufacturing Co., Ltd.

## 5. 评分与复盘

- 忠实度：95 / 100
- 流畅度：95 / 100
- 文体控制：95 / 100
```

The full report also contains a segment-by-segment contrast table with techniques
such as **词性转换**, **增译**, **省译**, **语序调整**, plus CATTI tips and drills.
Use `translation-forge demo --json` when another application needs the raw
`TranslationReport`.

The tool is bidirectional:

```bash
translation-forge demo --direction en-zh
```

## Translate your own letter

Inline text:

```bash
translation-forge translate \
  --direction zh-en \
  --title "Contract concession · draft 3" \
  --text "尊敬的史密斯先生：感谢您于2026年11月18日的来函。……"
```

UTF-8 file:

```bash
translation-forge translate \
  --direction zh-en \
  --file letter.txt \
  --genre business-letter \
  --title "Supplier concession letter"
```

The built-in engine is a deterministic construction-based baseline, not an LLM
call. It does not upload your letter or require an API key. Coverage is reported
honestly: sentences outside the bilingual construction bank are marked as
`待人工校订` rather than silently invented. The lexicon and construction bank are
in `lexicon.py` and `native_engine.py` and can be extended for new domains.

## Use it as a library

```python
import asyncio

from translation_forge import Direction, LocalAgentMesh, TranslationSession
from translation_forge.report import render_markdown


async def main() -> None:
    with LocalAgentMesh() as mesh:
        async with TranslationSession(mesh.registry) as session:
            report = await session.translate(
                "尊敬的史密斯先生：感谢您的来函。",
                direction=Direction.ZH_EN,
                title="Lesson 01",
            )
    print(render_markdown(report))


asyncio.run(main())
```

## Tests and static checks

```bash
pytest -q
ruff check .
```

The suite covers literal risk detection, native business-English rewriting,
technique attribution, the English-to-Chinese direction, exact SDK pinning and a
complete three-agent AIP RPC round trip.

## Build the wheel

```bash
python -m pip install --upgrade build twine
python -m build --wheel
python -m twine check dist/*
```

The resulting installable artifact is:

```text
dist/acps_translation_forge-1.0.0-py3-none-any.whl
```

To build both wheel and source distribution, run `python -m build` without
`--wheel`.

## Publish to TestPyPI and PyPI

Rehearse on TestPyPI first:

```bash
python -m twine upload --repository testpypi dist/*
```

Then publish the same validated artifacts to PyPI:

```bash
python -m twine upload dist/*
```

Use an API token when prompted: username `__token__`, password the full token
(including its `pypi-` prefix). A `.pypirc` file or the `TWINE_USERNAME` and
`TWINE_PASSWORD` environment variables can supply credentials without putting
them in shell history. PyPI versions are immutable: increment
`[project].version` and `PROJECT_VERSION` together before uploading a replacement.

## Honest scope

This project demonstrates protocol-native multi-agent collaboration with a
transparent, deterministic Chinese-English business-letter engine. It is not a
general-purpose neural machine translation system, and it does not claim
human-level literary translation. Its value is the **contrastive learning
loop**: literal diagnosis → native rewrite → technique-level critique, with every
hop discoverable, typed and auditable through ACPs.
