End-to-end pipeline for adding new chapters to the '人选天选论 — A Philosophy of Choice and Cost' book. Use this skill when the user wants to update the book, add a new chapter, process chapter images, run the book pipeline, do OCR transcription for the book, proofread book chapters, translate book chapters, generate the bilingual edition, or anything related to the 人选天选论 digitization workflow. Also trigger when the user mentions 'update book', 'new chapter', 'process chapter', 'book pipeline', 'book OCR', or refers to the a-philosophy-of-choice-and-cost project.
Automates the full 6-phase pipeline for adding new chapters to the book project at ~/Desktop/a-philosophy-of-choice-and-cost/.
/update-book <chapter_number> [image_source_path]
chapter_number (required): The chapter number, e.g. 3, 04, 5. Normalize to zero-padded two-digit format internally (e.g. 03, 04).image_source_path (optional): Directory containing the source images. Defaults to ~/Desktop/a-philosophy-of-choice-and-cost/images/.Examples:
/update-book 4 — process chapter 4 from images already in images//update-book 5 ~/Downloads/ch5_photos/ — copy images from a custom source directory first~/Desktop/a-philosophy-of-choice-and-cost/
├── images/ # Working directory for current chapter images (gitignored)
│ └── processed/chXX/ # Completed images moved here after pipeline
├── zh/src/ # Chinese source markdown
│ ├── SUMMARY.md
│ ├── preface.md
│ ├── aside.md
│ ├── ch01.md, ch02.md, ...
├── en/src/ # English translation markdown
│ ├── SUMMARY.md
│ ├── ch01.md, ch02.md, ...
├── bilingual/src/ # Bilingual CN/EN edition
│ ├── SUMMARY.md
│ ├── ch01.md, ch02.md, ...
└── WORKFLOW.md # Canonical reference
Every translation agent and reviewer MUST use these exact terms. No synonyms, no variations.
| Chinese | English | Notes |
|---|---|---|
| 人选 | Human Choice | Core concept — the choice a person makes |
| 天选 | Heaven's Selection | Core concept — the outcome one cannot control |
| 祸 | Cost | Not "disaster" or "misfortune" |
| 福 | Fortune | Not "blessing" or "happiness" |
| 天权 | Celestial Balance | Not "heavenly power" |
| 天机 | Celestial Insight | Not "heavenly secret" |
| 贪婪 | Greed | |
| 恐惧 | Fear | |
| 自治 | Self-rationalization | NOT "self-governance" or "autonomy" |
| 道痕 | Dao Marks | Not "path marks" in this translation context |
| 两忘 | Double Forgetting | |
| 破画原理 | The Painting Principle | |
| 《剑来》 | "Sword Come" | Novel title — do not translate as other novels |
When encountering terms not in this glossary, preserve the original Chinese in parentheses after the English translation on first occurrence.
Run each phase sequentially. Do not skip phases. Report progress to the user after each phase completes.
Goal: Get properly named images into images/ sorted by page order.
Set variables:
PROJECT=~/Desktop/a-philosophy-of-choice-and-cost
CH=XX (zero-padded chapter number)
If a custom image_source_path was provided:
$PROJECT/images/chXX_NN.jpg (e.g. ch04_01.jpg, ch04_02.jpg, ...) sorted by original filename or creation dateIf images are already in $PROJECT/images/:
chXX_* patternVerify: display the sorted file list and total count. Ask the user to confirm before proceeding.
Checkpoint: "Found N images for chapter XX. Proceeding to OCR."
Goal: Produce zh/src/chXX.md from the page images.
$PROJECT/images/Each OCR agent:
# headings, > blockquotes, **bold**, --- page breaks between pages# 第X章 · [chapter title]> blank lines between each line. Otherwise markdown merges them into one paragraph. Example:
> Line one.
>
> Line two.
<div class="epigraph"> for chapter opening pages (see WORKFLOW.md Formatting Standards)<div class="chapter-footer"> for chapter-end attribution$PROJECT/zh/src/chXX.mdCommon OCR pitfalls to watch for:
Checkpoint: "OCR complete. zh/src/chXX.md created (N lines). Starting proofreading."
Goal: Ensure the Chinese transcription is character-perfect against the original images.
Launch 3 parallel Opus agents. Each independently compares zh/src/chXX.md against ALL original images for this chapter.
Each agent produces an error report:
PASS — no errors found
OR
FAIL — errors found:
Line: [line number]
Image: [filename]
Wrong: [current text]
Correct: [text from image]
zh/src/chXX.md, then re-launch all 3 agentsReport after each round:
Proofreading Round N:
Agent 1: PASS/FAIL (X errors)
Agent 2: PASS/FAIL (X errors)
Agent 3: PASS/FAIL (X errors)
Status: [continuing / complete]
Checkpoint: "Proofreading complete after N rounds. All 3 agents PASS. Starting layout polish."
Goal: Make the markdown well-formatted for comfortable reading — especially on mobile. No need to match the original images exactly.
Launch 1 agent to review zh/src/chXX.md and apply these formatting rules:
Multi-line blockquotes: Every > line in a multi-line group MUST have a > blank line between them. No exceptions.
Chapter epigraph (if the chapter has an opening poem/title page): Wrap in HTML structure:
<div class="epigraph">
<div class="book-title">人 选 天 选 论</div>
<div class="book-author">姜 蓝 著</div>
<hr>
<div class="verse">
verse line 1
verse line 2
</div>
</div>
Chapter footer (last line, author attribution): Wrap in:
<div class="chapter-footer">— 姜蓝《人选天选论》· 第X章 标题 —</div>
Short poetic/rhythmic sentences that clearly form a list or verse (e.g., "有的人找运气 / 有的人找形势 / ..."): Must be in a blockquote with > blank lines between each line. Do NOT merge into one paragraph.
No unnecessary formatting: Don't add HTML classes to normal body paragraphs. CSS handles indent and spacing automatically.
No unreasonable line breaks: Only split into separate lines when the text is clearly:
Normal prose paragraphs must NEVER be split into multiple lines. If a sentence is long, leave it as one paragraph.
Punctuation cleanup:
Verify --- placement: Page break separators should only be between major sections or natural pauses. NEVER place --- in the middle of a sentence or paragraph. If OCR inserted --- at a page boundary that splits a sentence, remove the --- and merge the text back into one paragraph.
Cross-page sentence merging: OCR agents split text by image/page boundaries. If a sentence starts on one page and continues on the next, the text MUST be merged into one paragraph. Look for paragraphs ending without punctuation or the next paragraph starting with a comma/period.
The agent reads the file, applies fixes, and writes it back. Then display a summary of changes made.
Checkpoint: "Layout polish complete. N formatting fixes applied. Starting translation."
Goal: Produce en/src/chXX.md — a faithful, natural English translation.
Launch a translation agent (or multiple for long chapters) that receives:
zh/src/chXX.md--- page breaksSave output to $PROJECT/en/src/chXX.md
Launch 3 parallel Opus review agents. Each reviews the full translation checking for:
Known pitfalls:
Loop rules: Same as proofreading — 3 agents, all must PASS, minimum 2 rounds, safety limit of 5 rounds.
Report format: Same as proofreading rounds.
Checkpoint: "Translation complete and reviewed. en/src/chXX.md created. Starting bilingual edition."
Goal: Produce bilingual/src/chXX.md — paragraph-by-paragraph CN/EN comparison.
zh/src/chXX.md and en/src/chXX.md# Chapter Title EN | 第X章 · 中文标题
> Chinese paragraph text here.
English translation paragraph here.
---
> Next Chinese paragraph.
Next English paragraph.
---
Rules:
> )--- separator between each CN/EN pair# EN Title | 中文标题 format)$PROJECT/bilingual/src/chXX.mdCheckpoint: "Bilingual edition created. Starting final updates."
Goal: Update metadata, archive images, commit, and push.
Determine the chapter title from the Chinese source (the # 第X章 · ... heading) and the English translation.
Append to each SUMMARY.md:
zh/src/SUMMARY.md — add:
- [第X章 · {中文标题}](chXX.md)
en/src/SUMMARY.md — add:
- [Chapter X: {English Title}](chXX.md)
bilingual/src/SUMMARY.md — add:
- [Chapter X: {English Title} | 第X章 · {中文标题}](chXX.md)
Follow the exact pattern of existing entries. Read each SUMMARY.md first to match the style.
mkdir -p $PROJECT/images/processed/chXX/
mv $PROJECT/images/chXX_* $PROJECT/images/processed/chXX/
cd $PROJECT
git add zh/src/chXX.md en/src/chXX.md bilingual/src/chXX.md
git add zh/src/SUMMARY.md en/src/SUMMARY.md bilingual/src/SUMMARY.md
git commit -m "Add Chapter XX: {English Title} ({中文标题})
- Chinese source: zh/src/chXX.md
- English translation: en/src/chXX.md
- Bilingual edition: bilingual/src/chXX.md
- Proofreading: N rounds, all 3 agents PASS
- Translation review: N rounds, all 3 agents PASS"
git push
Checkpoint: "Chapter XX pipeline complete. All 3 editions updated. Pushed to GitHub — auto-deploy will publish to Pages."
zh/src/, warn the user and ask whether to overwrite or skip OCR.git push fails, report the error and let the user resolve it.If the user says "resume chapter X" or "continue from phase N":
zh/src/chXX.md, en/src/chXX.md, bilingual/src/chXX.md)