feat(baoyu-translate): add three-mode translation skill with glossary support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jim Liu 宝玉
2026-03-05 19:32:27 -06:00
parent ce259e4547
commit 5b4ba3ac3f
13 changed files with 1119 additions and 3 deletions
@@ -0,0 +1,73 @@
# EXTEND.md Schema for baoyu-translate
## Format
EXTEND.md uses YAML format:
```yaml
# Default target language (ISO code or common name)
target_language: zh-CN
# Default translation mode
default_mode: normal # quick | normal | refined
# Target audience (affects annotation depth and register)
audience: general # general | technical | academic | business | or custom string
# Translation style preference
style: storytelling # storytelling | formal | technical | literal
# Word count threshold to trigger chunked translation
chunk_threshold: 4000
# Max words per chunk
chunk_max_words: 5000
# Custom glossary (merged with built-in glossary)
# CLI --glossary flag overrides these
glossary:
- from: "Reinforcement Learning"
to: "强化学习"
- from: "Transformer"
to: "Transformer"
note: "Keep English"
# Language-pair specific glossaries
glossaries:
en-zh:
- from: "AI Agent"
to: "AI 智能体"
ja-zh:
- from: "人工知能"
to: "人工智能"
```
## Fields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `target_language` | string | `zh-CN` | Default target language code |
| `default_mode` | string | `normal` | Default translation mode (`quick` / `normal` / `refined`) |
| `audience` | string | `general` | Target reader profile (`general` / `technical` / `academic` / `business` / custom) |
| `style` | string | `storytelling` | Translation style preference |
| `chunk_threshold` | number | `4000` | Word count threshold to trigger chunked translation |
| `chunk_max_words` | number | `5000` | Max words per chunk |
| `glossary` | array | `[]` | Universal glossary entries |
| `glossaries` | object | `{}` | Language-pair specific glossary entries |
## Glossary Entry
| Field | Required | Description |
|-------|----------|-------------|
| `from` | yes | Source term |
| `to` | yes | Target translation |
| `note` | no | Usage note (e.g., "Keep English", "Only in tech context") |
## Priority
1. CLI `--glossary` file entries
2. EXTEND.md `glossaries[pair]` entries
3. EXTEND.md `glossary` entries
4. Built-in glossary (e.g., `references/glossary-en-zh.md`)
Later entries override earlier ones for the same source term.
@@ -0,0 +1,157 @@
---
name: first-time-setup
description: First-time setup flow for baoyu-translate preferences
---
# First-Time Setup
## Overview
When no EXTEND.md is found, guide user through preference setup.
**BLOCKING OPERATION**: This setup MUST complete before ANY translation. Do NOT:
- Start translating content
- Ask about files or output paths
- Proceed to any workflow steps
ONLY ask the questions in this setup flow, save EXTEND.md, then continue.
## Setup Flow
```
No EXTEND.md found
|
v
+---------------------+
| AskUserQuestion |
| (all questions) |
+---------------------+
|
v
+---------------------+
| Create EXTEND.md |
+---------------------+
|
v
Continue translation
```
## Questions
**Language**: Use user's input language or saved language preference.
Use AskUserQuestion with ALL questions in ONE call:
### Question 1: Target Language
```yaml
header: "Target Language"
question: "Default target language?"
options:
- label: "简体中文 zh-CN (Recommended)"
description: "Translate to Simplified Chinese"
- label: "繁體中文 zh-TW"
description: "Translate to Traditional Chinese"
- label: "English en"
description: "Translate to English"
- label: "日本語 ja"
description: "Translate to Japanese"
```
Note: User may type a custom language code.
### Question 2: Translation Mode
```yaml
header: "Mode"
question: "Default translation mode?"
options:
- label: "Normal (Recommended)"
description: "Analyze content first, then translate"
- label: "Quick"
description: "Direct translation, no analysis"
- label: "Refined"
description: "Full workflow: analyze → translate → review → polish"
```
### Question 3: Target Audience
```yaml
header: "Audience"
question: "Default target audience?"
options:
- label: "General readers (Recommended)"
description: "Plain language, more translator's notes for jargon"
- label: "Technical"
description: "Developers/engineers, less annotation on tech terms"
- label: "Academic"
description: "Formal register, precise terminology"
- label: "Business"
description: "Business-friendly tone, explain tech concepts"
```
Note: User may type a custom audience description.
### Question 4: Translation Style
```yaml
header: "Style"
question: "Translation style?"
options:
- label: "Storytelling (Recommended)"
description: "Engaging, narrative-like flow"
- label: "Formal"
description: "Professional, structured"
- label: "Technical"
description: "Precise, documentation-style"
- label: "Literal"
description: "Close to original structure"
```
### Question 5: Save Location
```yaml
header: "Save"
question: "Where to save preferences?"
options:
- label: "User (Recommended)"
description: "$HOME/.baoyu-skills/ (all projects)"
- label: "Project"
description: ".baoyu-skills/ (this project only)"
```
## Save Locations
| Choice | Path | Scope |
|--------|------|-------|
| User | `$HOME/.baoyu-skills/baoyu-translate/EXTEND.md` | All projects |
| Project | `.baoyu-skills/baoyu-translate/EXTEND.md` | Current project |
## After Setup
1. Create directory if needed
2. Write EXTEND.md with selected values
3. Confirm: "Preferences saved to [path]"
4. Mention: "You can add custom glossary terms to EXTEND.md anytime. See the `glossary` section in the file for the format."
5. Continue with translation using saved preferences
## EXTEND.md Template
```yaml
target_language: [zh-CN/zh-TW/en/ja/...]
default_mode: [quick/normal/refined]
audience: [general/technical/academic/business/custom]
style: [storytelling/formal/technical/literal]
# Custom glossary (optional) — add your own term translations here
# glossary:
# - from: "Term"
# to: "翻译"
# - from: "Another Term"
# to: "另一个翻译"
# note: "Usage context"
```
## Modifying Preferences Later
Users can edit EXTEND.md directly or delete it to trigger setup again.