From 39a97678bb140216018422219f434cb81e2a9c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Liu=20=E5=AE=9D=E7=8E=89?= Date: Wed, 25 Mar 2026 20:09:30 -0500 Subject: [PATCH] feat(baoyu-translate): enrich translation prompt with full analysis context Restructure 02-prompt.md template to better leverage analysis results: - Add source voice assessment alongside target style preset - Extract figurative language mapping into dedicated structured table - Include reasoning in comprehension challenges for annotation depth - Add translation challenges section for structural/creative issues - Provide chunk position context in subagent spawn prompts --- skills/baoyu-translate/SKILL.md | 8 ++-- .../references/refined-workflow.md | 11 +++++- .../references/subagent-prompt-template.md | 37 ++++++++++++++++--- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/skills/baoyu-translate/SKILL.md b/skills/baoyu-translate/SKILL.md index feaa4f6..db366a4 100644 --- a/skills/baoyu-translate/SKILL.md +++ b/skills/baoyu-translate/SKILL.md @@ -1,7 +1,7 @@ --- name: baoyu-translate description: Translates articles and documents between languages with three modes - quick (direct), normal (analyze then translate), and refined (analyze, translate, review, polish). Supports custom glossaries and terminology consistency via EXTEND.md. Use when user asks to "translate", "翻译", "精翻", "translate article", "translate to Chinese/English", "改成中文", "改成英文", "convert to Chinese", "localize", "本地化", or needs any document translation. Also triggers for "refined translation", "精细翻译", "proofread translation", "快速翻译", "快翻", "这篇文章翻译一下", or when a URL or file is provided with translation intent. -version: 1.56.1 +version: 1.57.0 metadata: openclaw: homepage: https://github.com/JimLiu/baoyu-skills#baoyu-translate @@ -189,12 +189,12 @@ Before translating chunks: - Splits at markdown block boundaries to preserve structure - If a single block exceeds the threshold, falls back to line splitting, then word splitting 4. **Assemble translation prompt**: - - Main agent reads `01-analysis.md` (if exists) and assembles shared context using Part 1 of [references/subagent-prompt-template.md](references/subagent-prompt-template.md) — inlining the resolved style preset (from `--style` flag, EXTEND.md `style` setting, or default `storytelling`), content background, merged glossary, and comprehension challenges + - Main agent reads `01-analysis.md` (if exists) and assembles shared context using Part 1 of [references/subagent-prompt-template.md](references/subagent-prompt-template.md) — inlining: target style + source voice assessment, content background, merged glossary, figurative language mapping (structured table), comprehension challenges (with reasoning), and translation challenges (structural/creative) - Save as `02-prompt.md` in the output directory (shared context only, no task instructions) 5. **Draft translation via subagents** (if Agent tool available): - Spawn one subagent **per chunk**, all in parallel (Part 2 of the template) - - Each subagent reads `02-prompt.md` for shared context, translates its chunk, saves to `chunks/chunk-NN-draft.md` - - Terminology consistency is guaranteed by the shared `02-prompt.md` (glossary + comprehension challenges from analysis) + - Each subagent reads `02-prompt.md` for shared context, receives chunk position info (chunk N of M + brief context of where it sits in the argument), translates its chunk, saves to `chunks/chunk-NN-draft.md` + - Consistency is guaranteed by the shared `02-prompt.md` (glossary, figurative language mapping, comprehension challenges, source voice, and translation challenges from analysis) - If no chunks (content under threshold): spawn one subagent for the entire source file - If Agent tool is unavailable, translate chunks sequentially inline using `02-prompt.md` 6. **Merge**: Once all subagents complete, combine translated chunks in order. If `chunks/frontmatter.md` exists, prepend it. Save as `03-draft.md` (refined) or `translation.md` (normal) diff --git a/skills/baoyu-translate/references/refined-workflow.md b/skills/baoyu-translate/references/refined-workflow.md index d8e7f7c..950fbd6 100644 --- a/skills/baoyu-translate/references/refined-workflow.md +++ b/skills/baoyu-translate/references/refined-workflow.md @@ -121,9 +121,16 @@ Implicit assumptions: [unstated premises] ## Step 2: Assemble Translation Prompt -Main agent reads `01-analysis.md` and assembles a complete translation prompt using [references/subagent-prompt-template.md](subagent-prompt-template.md). Inline the resolved style preset (from `--style` flag, EXTEND.md `style` setting, or default `storytelling`), content background, merged glossary, and comprehension challenges into the prompt. Save to `02-prompt.md`. +Main agent reads `01-analysis.md` and assembles a complete translation prompt using [references/subagent-prompt-template.md](subagent-prompt-template.md). Inline the following from analysis into the prompt: -This prompt is used by the subagent (chunked) or by the main agent itself (non-chunked). +- **Target style + Source voice**: Resolved style preset (from `--style` flag, EXTEND.md `style` setting, or default `storytelling`) AND the source voice assessment from analysis §1.5 (formal/conversational, humor, register, sentence rhythm) +- **Content background**: Quick summary, core argument, author background, writing context, purpose, implicit assumptions (from §1.1–1.3) +- **Glossary**: Merged glossary with analysis-extracted terms (from §1.4) +- **Figurative Language Mapping**: Structured table from analysis §1.7 — each metaphor/idiom with intended meaning, approach (interpret/substitute/retain), and suggested rendering +- **Comprehension Challenges**: Each challenge with reasoning (why it confuses readers) and proposed note (from §1.6) +- **Translation Challenges**: Structural and creative challenges from analysis §1.8 — specific passages with suggested approaches + +Save to `02-prompt.md`. This prompt is used by the subagent (chunked) or by the main agent itself (non-chunked). ## Step 3: Initial Draft diff --git a/skills/baoyu-translate/references/subagent-prompt-template.md b/skills/baoyu-translate/references/subagent-prompt-template.md index e112613..b969816 100644 --- a/skills/baoyu-translate/references/subagent-prompt-template.md +++ b/skills/baoyu-translate/references/subagent-prompt-template.md @@ -21,13 +21,15 @@ You are a professional translator. Your task is to translate markdown content fr ## Translation Style -{style description — e.g., "storytelling: engaging narrative flow, smooth transitions, vivid phrasing" or custom style from user} +**Target style**: {style description — e.g., "storytelling: engaging narrative flow, smooth transitions, vivid phrasing" or custom style from user} -Apply this style consistently: it determines the voice, tone, and sentence-level choices throughout the translation. Style is independent of audience — a technical audience can still get a storytelling-style translation, or a general audience can get a formal one. +**Source voice** (from analysis, if exists): {Describe the original author's voice — e.g., "Self-deprecating, conversational tone with frequent tech-industry humor. Sarcasm used to critique trends. Short punchy sentences alternate with longer analytical passages." Include: formal/conversational, humor type, cultural register, sentence rhythm, any distinctive patterns.} + +Apply the target style consistently while respecting the source voice. The translator should understand what the original sounds like in order to produce a translation that captures the same feel in the target style. Style is independent of audience — a technical audience can still get a storytelling-style translation, or a general audience can get a formal one. ## Content Background -{Inlined from 01-analysis.md if analysis exists: quick summary, core argument, author background, writing context, tone assessment, figurative language & metaphor mapping.} +{Inlined from 01-analysis.md if analysis exists: quick summary, core argument, author background, writing context, purpose, implicit assumptions.} ## Glossary @@ -35,23 +37,43 @@ Apply these term translations consistently throughout. First occurrence of each {Merged glossary — combine built-in glossary + EXTEND.md glossary + terms extracted in analysis. One per line: English → Translation} +## Figurative Language Mapping + +{Inlined from 01-analysis.md section 1.7 if analysis exists. Structured table — one row per metaphor, idiom, or figurative expression identified in the source:} + +| Original Expression | Intended Meaning | Approach | Suggested Rendering | +|--------------------|--------------------|----------|---------------------| +| {source metaphor} | {what the author actually means} | {Interpret / Substitute / Retain} | {target-language rendering or guidance} | + +Also note any emotional connotations (words carrying subjective feeling beyond dictionary meaning) and implied meanings (sentences where surface meaning is simpler than the author's full intent) identified in the analysis — preserve these in translation. + ## Comprehension Challenges The following terms or references may confuse target readers. Add translator's notes in parentheses where they appear: `译文(English original,通俗解释)` -{Inlined from 01-analysis.md comprehension challenges section if analysis exists. Each entry: term → explanation to use as note.} +{Inlined from 01-analysis.md comprehension challenges section if analysis exists. Each entry includes the reasoning so the translator can calibrate annotation depth:} + +- **{term/passage}**: {why this may confuse target readers} → Note: {concise explanation to use as translator's note} + +## Translation Challenges + +{Inlined from 01-analysis.md section 1.8 if analysis exists. Specific passages requiring structural or creative adaptation:} + +- {location/passage}: {what makes it challenging — e.g., 60-word participial chain, wordplay, pun, author's signature humor} → {suggested approach — e.g., break into 2-3 shorter sentences, adapt the joke for target culture, preserve the ambiguity} + +If this section is empty, omit it. ## Translation Principles - **Accuracy first**: Facts, data, and logic must match the original exactly - **Meaning over words**: Translate what the author means, not just what the words say. When a literal translation sounds unnatural or fails to convey the intended effect, restructure freely to express the same meaning in idiomatic {target_lang} -- **Figurative language**: Interpret metaphors, idioms, and figurative expressions by their intended meaning. When a source-language image does not carry the same connotation in {target_lang}, replace it with a natural expression that conveys the same idea and emotional effect. Refer to the Figurative Language section in Content Background (if provided) for pre-analyzed metaphor mappings +- **Figurative language**: Interpret metaphors, idioms, and figurative expressions by their intended meaning. When a source-language image does not carry the same connotation in {target_lang}, replace it with a natural expression that conveys the same idea and emotional effect. Follow the Figurative Language Mapping table above for pre-analyzed decisions - **Emotional fidelity**: Preserve the emotional connotations of word choices, not just their dictionary meanings - **Natural flow**: Use idiomatic {target_lang} word order and sentence patterns; break or restructure sentences freely when the source structure doesn't work naturally - **Terminology**: Use glossary translations consistently; annotate with original term in parentheses on first occurrence - **Preserve format**: Keep all markdown formatting (headings, bold, italic, images, links, code blocks) - **Respect original**: Maintain original meaning and intent; do not add, remove, or editorialize — but sentence structure and imagery may be adapted freely to serve the meaning -- **Translator's notes**: For terms or cultural references listed in Comprehension Challenges above, add a concise explanatory note in parentheses. Only annotate where genuinely needed for the target audience. +- **Translator's notes**: For terms or cultural references listed in Comprehension Challenges above, add a concise explanatory note in parentheses. Use the provided reasoning to judge annotation depth — explain more for genuinely obscure references, less for terms that are merely unfamiliar. Only annotate where genuinely needed for the target audience. ``` --- @@ -63,6 +85,9 @@ The following terms or references may confuse target readers. Add translator's n ``` Read the translation instructions from: {output_dir}/02-prompt.md +You are translating chunk {NN} of {total_chunks}. +Context: {brief description of what this chunk covers and where it sits in the overall argument — e.g., "This chunk covers the author's critique of current approaches, following the introduction of the problem and leading into the proposed solution."} + Translate this chunk: 1. Read `{output_dir}/chunks/chunk-{NN}.md` 2. Translate following the instructions in 02-prompt.md