writer-agent

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Writer Agent

Writer Agent

Transform documents and URLs into styled article series.
将文档和网址转换为风格统一的系列文章。

Quick Reference

快速参考

ReferencePurposeLoad at StepDPT1T2T3
directory-structure.mdOutput folder layoutStep 1
decision-trees.mdWorkflow decision guidesOn confusion only
retry-workflow.mdError recovery proceduresOn error only-
large-doc-processing.mdHandling documents >50K wordsStep 3 (if >20K)--
article-writer-prompt.mdSubagent prompt templatesStep 4-
context-extractor-prompt.mdContext extraction templateStep 3 (Tier 2)---
context-optimization.mdContext optimization anti-patternsStep 3.1-
detail-levels.mdOutput detail level optionsStep 2.5
DP = Direct Path | T1-T3 = Tier 1-3 | = Load | - = Skip
Dimension files (loaded at Step 2):
voices/{voice}.md
,
structures/{structure}.md
,
identities/{identity}.md
,
audiences/{audience}.md
,
emotional_maps/{emotion}.md
参考文档用途加载步骤DPT1T2T3
directory-structure.md输出文件夹布局说明步骤1
decision-trees.md工作流决策指南仅在有疑问时加载
retry-workflow.md错误恢复流程仅在出错时加载-
large-doc-processing.md处理超过5万字的文档指南步骤3(若文档超过2万字)--
article-writer-prompt.md子Agent提示模板步骤4-
context-extractor-prompt.md上下文提取模板步骤3(Tier 2)---
context-optimization.md上下文优化反模式说明步骤3.1-
detail-levels.md输出细节级别选项说明步骤2.5
DP = 直接路径 | T1-T3 = 层级1-3 | = 需要加载 | - = 跳过
维度文件(步骤2加载):
voices/{voice}.md
structures/{structure}.md
identities/{identity}.md
audiences/{audience}.md
emotional_maps/{emotion}.md

Workflow Overview

工作流概述

Direct Path (<20K words OR <50K words with <=3 articles):
Main agent writes all articles directly without subagents.
Input → Convert → Style/Structure → Plan → Write(main) → Synthesize → Verify
  1        1           2               3        4            5           6
Standard (Tier 1-2, 20K-100K words):
Input → Convert → Style/Structure → Analyze → Extract → Write → Synthesize → Verify
  1        1           2               3         3         4        5           6
Fast Path (Tier 3, >=100K words):
Input → Convert → Style/Structure → Plan → Write(parallel) → Synthesize → Verify
  1        1           2              3          4              5           6
直接路径(文档<2万字 或 <5万字且生成文章数≤3篇):
主Agent直接撰写所有文章,无需子Agent参与。
输入 → 转换 → 风格/结构设定 → 规划 → 撰写(主Agent) → 合成 → 验证
  1        1           2               3        4            5           6
标准路径(层级1-2,文档2万-10万字):
输入 → 转换 → 风格/结构设定 → 分析 → 提取 → 撰写 → 合成 → 验证
  1        1           2               3         3         4        5           6
快速路径(层级3,文档≥10万字):
输入 → 转换 → 风格/结构设定 → 规划 → 并行撰写 → 合成 → 验证
  1        1           2              3          4              5           6

Step 0: Resolve Skill Paths (BẮT BUỘC)

步骤0:解析Skill路径(必须)

PHẢI thực hiện TRƯỚC mọi bước khác. Skill có thể được cài ở nhiều vị trí khác nhau.
Bước 1: Dùng Glob tìm
wa-convert
:
Glob("**/writer-agent/scripts/wa-convert")
Bước 2: Từ kết quả, xác định 4 đường dẫn:
SCRIPTS_DIR = directory chứa wa-convert  (ví dụ: /Users/x/.claude/skills/writer-agent/scripts)
SKILL_DIR   = parent của SCRIPTS_DIR     (ví dụ: /Users/x/.claude/skills/writer-agent)
VOICES_DIR  = SKILL_DIR/voices           (ví dụ: /Users/x/.claude/skills/writer-agent/voices)
STRUCTURES_DIR = SKILL_DIR/structures    (ví dụ: /Users/x/.claude/skills/writer-agent/structures)
IDENTITIES_DIR = SKILL_DIR/identities    (ví dụ: /Users/x/.claude/skills/writer-agent/identities)
AUDIENCES_DIR  = SKILL_DIR/audiences     (ví dụ: /Users/x/.claude/skills/writer-agent/audiences)
EMOTIONS_DIR   = SKILL_DIR/emotional_maps (ví dụ: /Users/x/.claude/skills/writer-agent/emotional_maps)
Bước 3: Ghi nhớ các đường dẫn này. Tất cả commands trong các bước sau PHẢI dùng đường dẫn đã resolve, KHÔNG dùng relative path.
Ví dụ: Nếu Glob trả về
/Users/x/.claude/skills/writer-agent/scripts/wa-convert
:
  • Gọi convert:
    /Users/x/.claude/skills/writer-agent/scripts/wa-convert file.pdf
  • Đọc voice:
    /Users/x/.claude/skills/writer-agent/voices/teacher.md
  • Đọc structure:
    /Users/x/.claude/skills/writer-agent/structures/building-blocks.md
  • Đọc identity:
    /Users/x/.claude/skills/writer-agent/identities/tech-builder.md
QUAN TRỌNG: KHÔNG BAO GIỜ hardcode
.claude/skills/writer-agent/...
, luôn dùng đường dẫn tuyệt đối từ Glob.
必须在所有其他步骤之前执行。该Skill可安装在不同位置。
步骤1:使用Glob查找
wa-convert
Glob("**/writer-agent/scripts/wa-convert")
步骤2:根据查找结果,确定4个路径:
SCRIPTS_DIR = 包含wa-convert的目录 (示例:/Users/x/.claude/skills/writer-agent/scripts)
SKILL_DIR   = SCRIPTS_DIR的父目录     (示例:/Users/x/.claude/skills/writer-agent)
VOICES_DIR  = SKILL_DIR/voices           (示例:/Users/x/.claude/skills/writer-agent/voices)
STRUCTURES_DIR = SKILL_DIR/structures    (示例:/Users/x/.claude/skills/writer-agent/structures)
IDENTITIES_DIR = SKILL_DIR/identities    (示例:/Users/x/.claude/skills/writer-agent/identities)
AUDIENCES_DIR  = SKILL_DIR/audiences     (示例:/Users/x/.claude/skills/writer-agent/audiences)
EMOTIONS_DIR   = SKILL_DIR/emotional_maps (示例:/Users/x/.claude/skills/writer-agent/emotional_maps)
步骤3:记录这些路径。后续所有命令必须使用解析后的绝对路径,禁止使用相对路径。
示例:若Glob返回
/Users/x/.claude/skills/writer-agent/scripts/wa-convert
  • 调用转换命令:
    /Users/x/.claude/skills/writer-agent/scripts/wa-convert file.pdf
  • 读取voice文件:
    /Users/x/.claude/skills/writer-agent/voices/teacher.md
  • 读取structure文件:
    /Users/x/.claude/skills/writer-agent/structures/building-blocks.md
  • 读取identity文件:
    /Users/x/.claude/skills/writer-agent/identities/tech-builder.md
重要提示:禁止硬编码
.claude/skills/writer-agent/...
路径,始终使用Glob获取的绝对路径。

Step 1: Input Handling

步骤1:输入处理

Detect input type and convert to markdown.
Output language: Luôn là tiếng Việt, bất kể source language.
Input TypeDetectionAction
File (PDF/DOCX/EPUB/etc)Path + extension
wa-convert {path}
URL (web page)
http://
or
https://
wa-convert {url}
YouTube URL
youtube.com
or
youtu.be
wa-convert {url}
Plain text / .txt / .mdNo complex extensionRewrite →
wa-paste-text
检测输入类型并转换为markdown格式。
输出语言:始终为越南语,无论源语言是什么。
输入类型检测方式处理操作
文件(PDF/DOCX/EPUB等)路径+扩展名
wa-convert {path}
网址(网页)包含
http://
https://
wa-convert {url}
YouTube网址包含
youtube.com
youtu.be
wa-convert {url}
纯文本/.txt/.md无复杂扩展名重写后执行
wa-paste-text

File/URL Conversion

文件/网址转换

bash
{SCRIPTS_DIR}/wa-convert [/path/to/file.pdf or url]
Output:
docs/generated/{slug}-{timestamp}/input-handling/content.md
bash
{SCRIPTS_DIR}/wa-convert [/path/to/file.pdf 或 url]
输出路径
docs/generated/{slug}-{timestamp}/input-handling/content.md

Plain Text Processing

纯文本处理

  1. Read content (if file)
  2. Rewrite to structured markdown (add headings, preserve content)
  3. Propose title
  4. Execute:
bash
echo "{rewritten_content}" | {SCRIPTS_DIR}/wa-paste-text - --title "{title}"
  1. 读取内容(若为文件)
  2. 重写为结构化markdown(添加标题,保留内容)
  3. 建议标题
  4. 执行命令:
bash
echo "{rewritten_content}" | {SCRIPTS_DIR}/wa-paste-text - --title "{title}"

Error Handling

错误处理

ErrorAction
File not foundAsk for correct path
Unsupported formatTry Docling, confirm with user
URL fetch failedReport and stop
Empty contentWarn, confirm before continue
Encrypted PDFAsk for decrypted version
错误类型处理操作
文件未找到请求用户提供正确路径
不支持的格式尝试使用Docling转换,与用户确认
网址获取失败报错并终止流程
内容为空发出警告,确认后再继续
加密PDF请求用户提供解密版本

Step 2: Select Writing Dimensions (5 Dimensions)

步骤2:选择撰写维度(5个维度)

Hệ thống 5 chiều độc lập. User chọn từng chiều, mix-match tự do.
Flow: Voice → Structure → Identity → Audience → Emotion (tất cả bắt buộc)
Mỗi chiều có default mapping dựa trên voice. Hệ thống suggest defaults, user PHẢI confirm hoặc chọn khác cho mỗi chiều.
Skip dimension: Nếu user nói "không biết" hoặc skip → dùng default mapping → ghi nhận → tiếp tục. Không hỏi lại.
5个独立的维度系统,用户可自由组合选择。
流程顺序:Voice(语气)→ Structure(结构)→ Identity(身份)→ Audience(受众)→ Emotion(情感)(所有维度均为必填)
每个维度会根据所选语气提供默认映射,系统会给出默认建议,用户必须确认或选择其他选项。
跳过维度:若用户表示“不知道”或跳过,则使用默认映射并记录,继续流程,无需再次询问。

Step 2a: Select Voice

步骤2a:选择语气(Voice)

Hỏi user để confirm voice (giọng văn, tone, persona).
VoiceFileMô tả
Teacher
teacher.md
"Chúng ta" đồng hành, teaching, ấm áp
Personal
personal.md
"Tôi" personal journey, vulnerable
Objective
objective.md
Neutral, data-driven, formal
Guide
guide.md
Đồng hành mindful, Đông-Tây
Investigator
investigator.md
Tìm hiểu, đặt câu hỏi, challenge
Dialogue
dialogue.md
Thầy-trò đối thoại, Zen
Storyteller
storyteller.md
Kể chuyện ngôi thứ nhất, chánh niệm
CustomUser tạo mớiTheo
templates/_voice-template.md
Voice files:
voices/{voice}.md
Xem
references/_dimension-comparison.md
để so sánh tất cả dimensions.
Custom voice: Nếu user muốn tạo voice riêng, copy
templates/_voice-template.md
voices/{custom-name}.md
, điền theo template. Tương tự cho custom structure:
structures/_structure-template.md
structures/{custom-name}.md
.
询问用户确认语气(文风、语调、人设)。
语气文件描述
Teacher
teacher.md
采用“我们”的口吻,陪伴式教学,语气亲切温暖
Personal
personal.md
采用“我”的口吻,讲述个人经历,风格真诚
Objective
objective.md
中立客观,基于数据,正式严谨
Guide
guide.md
陪伴引导,融合东西方理念
Investigator
investigator.md
探索式,善于提问,挑战固有认知
Dialogue
dialogue.md
师徒对话式,带有禅意
Storyteller
storyteller.md
第一人称叙事,注重正念
自定义用户自行创建参考
templates/_voice-template.md
模板
语气文件路径:
voices/{voice}.md
可查看
references/_dimension-comparison.md
了解所有维度的对比信息。
自定义语气:若用户想要创建自定义语气,复制
templates/_voice-template.md
voices/{custom-name}.md
,并按模板填写内容。自定义结构同理:复制
structures/_structure-template.md
structures/{custom-name}.md

Step 2b: Select Structure

步骤2b:选择结构(Structure)

Hỏi user để confirm structure (tổ chức bài viết).
Mỗi voice có
default_structure
trong frontmatter. Suggest default, user có thể override.
StructureFileOrganizationDefault cho
BLUF-Evidence
bluf-evidence.md
Executive Summary → Evidence → ActionObjective
Building Blocks
building-blocks.md
Hook → Intuition → Concept → Example → ApplyTeacher
Five Layers
five-layers.md
Surface → Structure → Tension → Connection → SynthInvestigator
Spiral Return
spiral-return.md
Moment → Spiral deeper → Open endingPersonal
Master-Student
master-student.md
Experience → Dialogue → SilenceDialogue
Story Arc
story-arc.md
Scene → Encounter → Deepening → TransformationStoryteller
Depth-Practice
depth-practice.md
Present moment → Layers → Practice invitationGuide
Structure files:
structures/{structure}.md
Xem
references/_dimension-comparison.md
để so sánh và mix-match.
询问用户确认文章结构。
每种语气在其前置元数据中都有默认结构映射,系统会建议默认选项,用户可确认或选择其他结构。
结构文件组织方式默认适配语气
BLUF-Evidence
bluf-evidence.md
执行摘要→证据→行动方案Objective
Building Blocks
building-blocks.md
钩子引入→直觉引导→概念讲解→示例→实践应用Teacher
Five Layers
five-layers.md
表层→结构→张力→关联→综合Investigator
Spiral Return
spiral-return.md
瞬间切入→螺旋式深入→开放式结尾Personal
Master-Student
master-student.md
经验分享→对话交流→留白思考Dialogue
Story Arc
story-arc.md
场景铺垫→冲突相遇→深度挖掘→转变升华Storyteller
Depth-Practice
depth-practice.md
当下时刻→分层解析→实践邀请Guide
结构文件路径:
structures/{structure}.md
可查看
references/_dimension-comparison.md
了解结构对比和组合指南。

Step 2c: Select Writer Identity

步骤2c:选择作者身份(Identity)

Hỏi user chọn writer identity. Suggest default dựa trên voice, user confirm hoặc chọn khác.
IdentityFileMô tảDefault cho
Tech Builder
tech-builder.md
Practitioner, pragmatic builderTeacher
Contemplative Thinker
contemplative-thinker.md
Hành giả, tìm ý nghĩaPersonal, Guide, Dialogue, Storyteller
Knowledge Curator
knowledge-curator.md
Cross-domain connectorObjective, Investigator
CustomUser tạo mớiTheo
templates/_identity-template.md
-
Identity files:
identities/{identity}.md
询问用户选择作者身份,系统会根据所选语气建议默认选项,用户可确认或选择其他身份。
身份文件描述默认适配语气
Tech Builder
tech-builder.md
实践者,务实的构建者Teacher
Contemplative Thinker
contemplative-thinker.md
修行者,追寻意义Personal、Guide、Dialogue、Storyteller
Knowledge Curator
knowledge-curator.md
跨领域知识连接者Objective、Investigator
自定义用户自行创建参考
templates/_identity-template.md
模板
-
身份文件路径:
identities/{identity}.md

Step 2d: Select Audience Profile

步骤2d:选择受众画像(Audience)

Hỏi user viết cho ai. Suggest default dựa trên voice, user confirm hoặc chọn khác.
AudienceFileMô tảDefault cho
Busy Professionals
busy-professionals.md
Bận, cần actionableObjective
Curious Beginners
curious-beginners.md
Mới, cần clarityTeacher, Guide
Deep Seekers
deep-seekers.md
Muốn chiều sâuPersonal, Investigator, Dialogue, Storyteller
CustomUser tạo mớiTheo
templates/_audience-template.md
-
Audience files:
audiences/{audience}.md
询问用户文章的目标受众,系统会根据所选语气建议默认选项,用户可确认或选择其他受众。
受众文件描述默认适配语气
Busy Professionals
busy-professionals.md
时间紧张,需要可落地内容Objective
Curious Beginners
curious-beginners.md
新手,需要清晰易懂的内容Teacher、Guide
Deep Seekers
deep-seekers.md
追求深度内容Personal、Investigator、Dialogue、Storyteller
自定义用户自行创建参考
templates/_audience-template.md
模板
-
受众文件路径:
audiences/{audience}.md

Step 2e: Select Emotional Map

步骤2e:选择情感映射(Emotion)

Hỏi user muốn người đọc cảm thấy gì. Suggest default dựa trên voice, user confirm hoặc chọn khác.
EmotionFileMô tảDefault cho
Empower & Challenge
empower-challenge.md
Growth qua discomfortTeacher, Objective
Reflect & Discover
reflect-discover.md
Stillness, wonderPersonal, Guide, Dialogue, Storyteller
Provoke & Transform
provoke-transform.md
Challenge assumptionsInvestigator
CustomUser tạo mớiTheo
templates/_emotion-template.md
-
Emotion files:
emotional_maps/{emotion}.md
Flow: Chọn voice → Hệ thống suggest defaults cho tất cả → User confirm hoặc chọn khác từng cái
询问用户希望读者产生的情感,系统会根据所选语气建议默认选项,用户可确认或选择其他情感。
情感文件描述默认适配语气
Empower & Challenge
empower-challenge.md
在不适中获得成长Teacher、Objective
Reflect & Discover
reflect-discover.md
沉静、充满好奇Personal、Guide、Dialogue、Storyteller
Provoke & Transform
provoke-transform.md
挑战固有认知Investigator
自定义用户自行创建参考
templates/_emotion-template.md
模板
-
情感文件路径:
emotional_maps/{emotion}.md
流程:选择语气→系统为所有维度建议默认选项→用户逐一确认或选择其他选项

Default Mapping Table

默认映射表

📖 See:
references/_dimension-comparison.md
for full default mapping table, compatibility matrix, and mixing guidelines.
Mỗi dimension table ở trên đã ghi "Default cho" column. Dùng bảng so sánh chi tiết khi cần xác nhận compatibility.
Low Compatibility Warning: Khi user chọn combo có compatibility ★ (thấp) theo bảng ở
_dimension-comparison.md
, thông báo user: "Combination này ít phổ biến, có thể tạo tension trong giọng văn. Bạn muốn tiếp tục hay chọn khác?". Nếu user confirm → proceed.
Conflict Resolution: Khi dimensions tạo tension (vd: Provoke & Transform + Teacher voice), Voice luôn quyết định HOW (giọng văn, tone, persona). Profile (Identity/Audience/Emotion) bổ sung WHAT (authority, đối tượng, cảm xúc). Nếu conflict: Voice wins về style/tone, Profile wins về content framing.
📖 参考
references/_dimension-comparison.md
包含完整的默认映射表、兼容性矩阵和组合指南。
上述每个维度表都包含“默认适配语气”列,如需确认兼容性,可查看详细对比表。
低兼容性警告:当用户选择的组合在
_dimension-comparison.md
中兼容性为★(低)时,需告知用户:“该组合较为少见,可能导致文风冲突。是否继续或更换其他组合?”。若用户确认,则继续流程。
冲突解决:当各维度产生冲突时(例如:Provoke & Transform情感 + Teacher语气),语气(Voice)始终决定表达方式(文风、语调、人设),而身份/受众/情感维度补充内容框架(权威性、目标对象、情感导向)。若发生冲突,语气在风格/语调上优先,其他维度在内容框架上优先。

Step 2.5: Select Detail Level

步骤2.5:选择细节级别

Hỏi user để confirm output detail level.
LevelRatioDescription
Concise15-25%Tóm lược, giữ ý chính
Standard30-40%Cân bằng (Recommended)
Comprehensive50-65%Chi tiết, giữ nhiều ví dụ
Faithful75-90%Gần như đầy đủ, viết lại theo style
Default: Standard (if user skips or unclear)
询问用户确认输出内容的细节级别。
级别比例描述
简洁版15-25%仅保留核心内容的摘要
标准版30-40%平衡型(推荐)
详细版50-65%内容详尽,保留大量示例
忠实版75-90%几乎完整保留原文,仅调整风格
默认选项:标准版(若用户跳过或未明确说明)

Calculate Target Words (Tham khảo)

计算目标字数(参考)

LƯU Ý: Target words chỉ mang tính tham khảo. PASS/FAIL dựa trên section coverage, không phải word count.
target_ratio = midpoint of selected level
total_target = source_words × target_ratio

Per article (reference only):
article_target = (article_source_words / source_words) × total_target
注意:目标字数仅作参考,流程的通过/失败依据章节覆盖率判断,而非字数。
target_ratio = 所选级别的中间值
total_target = 源文档字数 × target_ratio

单篇文章目标字数(仅参考):
article_target = (单篇源文档字数 / 总源文档字数) × total_target

Word count để định hướng, không bắt buộc đạt chính xác

字数仅用于方向指引,无需严格达标

undefined
undefined

Understanding Detail Level Parameters

理解细节级别参数

Two complementary concepts:
  1. **target_ratio**
    : Controls total article length relative to source
  • Standard level: 30-40% (midpoint 35%)
  • This ratio applies to the entire article wordcount
  1. **example_percentage**
    : Controls retention of examples within kept content
  • Standard level: 60% of examples
  • This percentage applies only to example sections
See detail-levels.md for worked examples and full specification.
两个互补概念
  1. **target_ratio**
    :控制输出总字数与源文档的比例
  • 标准版:30-40%(中间值35%)
  • 该比例适用于整个系列文章的总字数
  1. **example_percentage**
    :控制保留示例内容的比例
  • 标准版:保留60%的示例
  • 该比例仅适用于示例章节
查看detail-levels.md获取示例和完整说明。

Step 2.6: Tier Reference Table

步骤2.6:层级参考表

Canonical tier definitions (referenced throughout documentation):
TierWord CountStrategyContext ApproachGlossarymax_concurrent
Direct Path<20K OR (<50K AND ≤3 articles)Main agent writes allN/A (no subagents)Inline (~200 words)N/A
Tier 120K-50K (fails Direct Path)Subagents read source directlyNo context filesInline (~200 words)3
Tier 250K-100KSmart compressionContext extractorsSeparate file (~600 words)3
Tier 3>=100KFast Path, minimal overheadNo context filesInline (~300 words)2
Priority rules:
  • Direct Path conditions are checked FIRST and override tier boundaries
  • Documents 20K-50K with ≤3 articles use Direct Path (not Tier 1)
  • Only documents failing Direct Path conditions fall through to tier selection
Note: Direct Path
<50K
condition is further limited by language: EN ~44K, VI ~32K, mixed ~38K words. These limits are pre-computed in
structure.json → direct_path.capacity_ok
. If capacity exceeded, fallback to Tier 1.
Key differences:
  • Direct Path: Main agent handles everything (no subagents)
  • Tier 1: Lightweight subagents, read source via line ranges
  • Tier 2: Context extraction for compression (only tier with separate glossary file)
  • Tier 3: Like Tier 1 but larger chunks, more selective glossary, lower concurrency
标准层级定义(全文档通用):
层级文档字数范围策略上下文处理方式术语表格式最大并发数
直接路径<2万字 或 (<5万字且生成文章数≤3篇)主Agent全权处理无需上下文提取嵌入式(约200字)
层级12万-5万字(不符合直接路径条件)轻量级子Agent,按行范围读取源文档无上下文文件嵌入式(约200字)3
层级25万-10万字智能压缩上下文提取器独立文件(约600字)3
层级3≥10万字快速路径,最小化处理开销无上下文文件嵌入式(约300字)2
优先级规则
  • 首先检查直接路径条件,该条件优先于层级边界
  • 2万-5万字且生成文章数≤3篇的文档使用直接路径(而非层级1)
  • 仅不符合直接路径条件的文档才会进入层级选择
注意:直接路径的
<5万字
条件会因语言不同有所调整:英文约4.4万字,越南语约3.2万字,混合语言约3.8万字。这些限制已预计算在
structure.json → direct_path.capacity_ok
中。若超出容量,则 fallback 到层级1。
核心差异
  • 直接路径:主Agent处理所有事务(无子Agent)
  • 层级1:轻量级子Agent,通过行范围读取源文档
  • 层级2:通过上下文提取实现压缩(唯一使用独立术语表文件的层级)
  • 层级3:类似层级1,但处理更大的内容块,术语表更精简,并发数更低

Step 3: Analyze

步骤3:分析

Goal: Create analysis artifacts for article generation.
目标:生成用于文章创作的分析产物。

3.0 Processing Path Selection

3.0 处理路径选择

Read
structure.json
→ use
direct_path
field (computed by
wa-convert
v1.2+):
structure.json → direct_path.eligible?
├─ YES AND direct_path.capacity_ok?
│   └─ DIRECT PATH
│       └─ Skip context extraction
│       └─ Main agent writes ALL articles
│       └─ ~30% faster for small documents
├─ YES BUT NOT direct_path.capacity_ok?
│   └─ WARN: direct_path.warning
│   └─ RECOMMEND: Use Tier 1 with subagents instead
├─ NO AND tier_recommendation.tier <= 2?
│   └─ STANDARD PATH (3.1-3.5)
└─ NO AND tier_recommendation.tier == 3?
    └─ FAST PATH (Tier 3)
Note:
direct_path
fields in structure.json (since v1.2) include
eligible
,
capacity_ok
,
capacity_limit
, and
warning
. These are pre-computed based on word count, estimated article count, and detected language. Main agent does NOT need to recalculate these values.
Examples:
DocumentWordsArticlesPathReason
Blog post15K5Direct<20K words (first condition) ✓
Tutorial45K3Direct<50K AND ≤3 articles (second condition) ✓
Long guide48K3Direct → Tier 1Exceeds max_words for mixed (38K) ⚠️
Paper45K4StandardFails both conditions (4 > 3) → use subagents
Book chapter67K8StandardTier 2: smart compression
Full book142K12FastTier 3: reference-based
Note: Direct Path capacity limit depends on language: EN ~44K, VI ~32K, mixed ~38K words. Use
structure.json → language
field for accurate limit.
读取
structure.json
→ 使用
direct_path
字段(由
wa-convert
v1.2+版本计算):
structure.json → direct_path.eligible?
├─ 是 且 direct_path.capacity_ok?
│   └─ 直接路径
│       └─ 跳过上下文提取
│       └─ 主Agent撰写所有文章
│       └─ 小文档处理速度提升约30%
├─ 是 但 direct_path.capacity_ok?为否
│   └─ 警告:direct_path.warning
│   └─ 建议:改用带子女Agent的层级1
├─ 否 且 tier_recommendation.tier ≤2?
│   └─ 标准路径(步骤3.1-3.5)
└─ 否 且 tier_recommendation.tier ==3?
    └─ 快速路径(层级3)
注意:structure.json中的
direct_path
字段(v1.2版本起)包含
eligible
capacity_ok
capacity_limit
warning
。这些值已根据字数、预估文章数和检测到的语言预计算完成,主Agent无需重新计算。
示例
文档类型字数生成文章数处理路径原因
博客文章1.5万5直接路径字数<2万(满足第一个条件) ✓
教程4.5万3直接路径字数<5万且生成文章数≤3篇(满足第二个条件) ✓
长篇指南4.8万3直接路径→层级1超出混合语言的字数限制(3.8万) ⚠️
学术论文4.5万4标准路径不符合直接路径的两个条件(生成文章数>3) → 使用子Agent
书籍章节6.7万8标准路径层级2:智能压缩
完整书籍14.2万12快速路径层级3:基于参考的处理
注意:直接路径的容量限制因语言而异:英文约4.4万字,越南语约3.2万字,混合语言约3.8万字。使用
structure.json → language
字段获取准确限制。

3.1 Structure Scan

3.1 结构扫描

📖 READ FIRST: context-optimization.md explains anti-patterns that waste 50%+ context budget. Review before proceeding.
Quick path (if
structure.json
exists):
  • ONLY read
    structure.json
    for outline, stats, tier recommendation
  • DO NOT read
    content.md
    - it wastes context budget
  • Skip manual scanning (outline already in JSON)
Fallback (if
structure.json
missing):
⚠️ WARNING: Fallback mode loses 51% context optimization. Re-run
wa-convert
to generate
structure.json
if possible.
Manual scan using efficient commands:
bash
undefined
📖 必读context-optimization.md 解释了会浪费50%以上上下文预算的反模式,开始前请先阅读。
快速路径(若
structure.json
存在):
  • 读取
    structure.json
    获取大纲、统计数据和层级建议
  • 禁止读取
    content.md
    - 这会浪费上下文预算
  • 跳过手动扫描(大纲已在JSON中)
回退方案(若
structure.json
缺失):
⚠️ 警告:回退模式会损失51%的上下文优化效果。若可能,请重新运行
wa-convert
生成
structure.json
使用高效命令进行手动扫描:
bash
undefined

Extract heading structure without reading full file

提取标题结构,无需读取完整文件

grep -n "^#" docs/generated/{slug}/input-handling/content.md | head -100
grep -n "^#" docs/generated/{slug}/input-handling/content.md | head -100

Or use line-based sampling (first 100 lines for overview)

或基于行的抽样(读取前100行获取概览)

Read(file_path, offset=1, limit=100) # Only to extract headings

⚠️ **CRITICAL**: Do NOT read full `content.md` during structure scan! For all tiers, subagents will read source content directly when writing articles. Reading it now wastes 90%+ context budget. See [context-optimization.md](references/context-optimization.md) for budget examples and common mistakes.
Read(file_path, offset=1, limit=100) # 仅用于提取标题

⚠️ **关键提示**:结构扫描期间禁止读取完整的`content.md`!对于所有层级,子Agent在撰写文章时会直接读取源内容。此时读取会浪费90%以上的上下文预算。查看[context-optimization.md](references/context-optimization.md)获取预算示例和常见错误。

3.1.1 Tier 3 Fast Path (>=100K words)

3.1.1 层级3快速路径(文档≥10万字)

For very large documents, minimize analysis overhead:
ActionDetail
SKIP
_glossary.md
, context files
CREATEMinimal
_plan.md
(section-to-article mapping + line ranges)
EMBEDKey terms (~300 words) + dependencies inline in subagent prompts
SPAWNSubagents immediately after
_plan.md
(continuous batching)
Context savings: ~40% reduction in main agent context.
See large-doc-processing.md for
_plan.md
format, subagent prompt template, and workflow details.
对于超大型文档,最小化分析开销:
操作详情
跳过
_glossary.md
、上下文文件
创建极简版
_plan.md
(章节-文章映射+行范围)
嵌入关键术语(约300字)+ 依赖关系,直接嵌入子Agent提示
启动子Agent生成
_plan.md
后立即启动子Agent(持续批量处理)
上下文节省:主Agent上下文减少约40%。
查看large-doc-processing.md获取
_plan.md
格式、子Agent提示模板和工作流细节。

3.2 Content Inventory

3.2 内容清单

Use
structure.json
outline directly. Section IDs, line ranges, word counts, and critical markers are all available in
structure.json
.
直接使用
structure.json
中的大纲。章节ID、行范围、字数和关键标记均已在
structure.json
中提供。

3.3 Article Plan (
analysis/_plan.md
)

3.3 文章规划(
analysis/_plan.md

Check user request first:
python
undefined
首先检查用户需求
python
undefined

Priority: User request > Auto-split

优先级:用户需求 > 自动拆分

if user_specified_article_count: # User yêu cầu số bài cụ thể (ví dụ: "chia thành 5 bài") target_articles = user_specified_count skip_auto_split = True # Phân bổ sections đều cho các bài, không chia nhỏ thêm else: # Auto mode: chia thành 3-7 bài, mỗi bài ~10 phút đọc target_articles = calculate_optimal_articles(total_words, detail_ratio) skip_auto_split = False

Group sections into articles (default 3-7, or user-specified count):

```markdown
| #   | Slug  | Title         | Sections      | Est. Words | Reading Time |
| --- | ----- | ------------- | ------------- | ---------- | ------------ |
| 1   | intro | Introduction  | S01, S02      | 2000       | ~13 min      |
| 2   | core  | Core Concepts | S03, S04, S05 | 2500       | ~13-15 min   |
Rules:
  • All sections must be mapped. Coverage check at end.
  • Target reading time phụ thuộc detail level: Concise ~5min, Standard ~10min, Comprehensive ~13min, Faithful ~15min
  • Target words/bài: 2000-3000 từ (tham khảo, không bắt buộc)
  • Nếu user chỉ định số bài → tuân theo, không auto-split thêm
Content-Type Detection: Khi tạo plan, xác định
content_type
cho mỗi article (
tutorial
,
conceptual
,
narrative
,
analysis
,
mixed
). Embed
CONTENT_TYPE: {type}
vào subagent prompt. Subagent ưu tiên structure file (primary), content-type hint (secondary).
Series Context (QUAN TRỌNG - tạo cùng lúc với plan):
Khi tạo
_plan.md
, đồng thời xác định:
markdown
undefined
if user_specified_article_count: # 用户指定了生成文章的数量(例如:“分成5篇文章”) target_articles = user_specified_count skip_auto_split = True # 将章节平均分配给各文章,不再进一步拆分 else: # 自动模式:拆分为3-7篇文章,每篇约10分钟阅读时长 target_articles = calculate_optimal_articles(total_words, detail_ratio) skip_auto_split = False

将章节分组到各文章中(默认3-7篇,或用户指定数量):

```markdown
| #   | 别名  | 标题         | 包含章节      | 预估字数 | 阅读时长 |
| --- | ----- | ------------- | ------------- | ---------- | ------------ |
| 1   | intro | 引言  | S01、S02      | 2000       | ~13分钟      |
| 2   | core  | 核心概念 | S03、S04、S05 | 2500       | ~13-15分钟   |
规则
  • 所有章节必须被覆盖,最后检查覆盖率
  • 目标阅读时长取决于细节级别:简洁版5分钟,标准版10分钟,详细版13分钟,忠实版15分钟
  • 单篇文章目标字数:2000-3000字(参考值,无需严格达标)
  • 若用户指定了文章数量,则严格遵循,不再自动拆分
内容类型检测:生成规划时,为每篇文章确定
content_type
(教程、概念讲解、叙事、分析、混合类型)。将
CONTENT_TYPE: {type}
嵌入子Agent提示中。子Agent优先使用结构文件,其次参考内容类型提示。
系列上下文(重要 - 与规划同时生成)
生成
_plan.md
时,同时确定:
markdown
undefined

Series Context

系列上下文

Core message: "{1-2 câu thông điệp cốt lõi}"
| # | Title | Role | Reader Enters | Reader Exits | Bridge to Next | | 1 | Intro | foundation | Chưa biết X | Hiểu X cơ bản | "Nhưng X trong thực tế...?" | | 2 | Core | development | Hiểu X cơ bản | Nắm vững Y | "Y mở ra câu hỏi về Z..." | | 3 | Adv | climax | Nắm vững Y | Kết nối Y với Z | N/A (last) |

**Cách tạo Reader Enters/Exits/Bridge:**

- `Reader Enters`: Kiến thức người đọc có khi bắt đầu bài (từ bài trước hoặc kiến thức nền)
- `Reader Exits`: Kiến thức người đọc đạt được sau bài (dẫn tới bài sau)
- `Bridge to Next`: 1 câu gợi tò mò kết nối bài này với bài tiếp (KHÔNG dùng "Trong phần tiếp theo...")

Thông tin này sẽ được embed vào `SERIES_CONTEXT` block trong mỗi subagent prompt (xem [article-writer-prompt.md](references/article-writer-prompt.md#series-context-block)).
核心信息: "{1-2句核心观点}"
| # | 标题 | 作用 | 读者初始状态 | 读者结束状态 | 与下一篇的衔接 | | 1 | 引言 | 基础铺垫 | 不了解X | 理解X的基本概念 | “但X在实际应用中是怎样的?” | | 2 | 核心 | 深入讲解 | 理解X的基本概念 | 掌握Y | “Y引出了关于Z的问题...” | | 3 | 进阶 | 高潮部分 | 掌握Y | 将Y与Z关联 | 无(最后一篇) |

**如何生成读者初始/结束状态及衔接语**:

- `读者初始状态`:读者开始阅读本文时的知识水平(来自上一篇文章或基础知识)
- `读者结束状态`:读者读完本文后应达到的知识水平(为下一篇文章做铺垫)
- `与下一篇的衔接`:1句引发好奇心的衔接语(禁止使用“在下一部分中...”)

这些信息将嵌入到每个子Agent提示的`SERIES_CONTEXT`块中(查看[article-writer-prompt.md](references/article-writer-prompt.md#series-context-block))。

3.3.1 Article Splitting (Auto)

3.3.1 文章拆分(自动)

Trigger: After Step 3.3, before Step 3.4. Check each planned article.
Priority rules:
  1. User-specified count: Nếu user yêu cầu số bài cụ thể → tuân theo, KHÔNG auto-split
  2. Auto-split: Chỉ áp dụng khi user KHÔNG yêu cầu số bài cụ thể
Key constants:
  • MAX_OUTPUT_WORDS = 3000
    (~15 min reading time)
  • TARGET_PART_WORDS = 2000
    (~13 min reading time)
  • Atomic unit = H2 block (H2 + H3 children). NEVER split within paragraph, H3, or critical section.
When to split:
estimated_output = source_words × detail_ratio > MAX_OUTPUT_WORDS
Algorithm: Greedy grouping of H2 blocks, no minimum. See large-doc-processing.md#article-splitting-strategy for full algorithm and validation matrix.
Validate after split:
bash
{SCRIPTS_DIR}/wa-validate-split docs/generated/{book}/analysis/_plan.md
Part naming:
02-core.md
02-core-part1.md
,
02-core-part2.md
Context bridging: For Part N > 1, provide prev part topics, last paragraph, key concepts. See article-writer-prompt.md#multi-part-article-template.
触发时机:步骤3.3之后,步骤3.4之前。检查每篇规划中的文章。
优先级规则
  1. 用户指定数量:若用户指定了文章数量,则严格遵循,禁止自动拆分
  2. 自动拆分:仅当用户未指定文章数量时适用
关键常量
  • MAX_OUTPUT_WORDS = 3000
    (约15分钟阅读时长)
  • TARGET_PART_WORDS = 2000
    (约13分钟阅读时长)
  • 最小拆分单元 = H2区块(H2标题 + 下属H3内容)。禁止在段落、H3或关键章节内拆分。
拆分条件
estimated_output = 源文档字数 × 细节比例 > MAX_OUTPUT_WORDS
算法:贪心算法分组H2区块,无最小数量限制。查看large-doc-processing.md#article-splitting-strategy获取完整算法和验证矩阵。
拆分后验证
bash
{SCRIPTS_DIR}/wa-validate-split docs/generated/{book}/analysis/_plan.md
拆分后命名
02-core.md
02-core-part1.md
02-core-part2.md
上下文衔接:对于第N部分(N>1),提供前一部分的主题、最后一段和关键概念。查看article-writer-prompt.md#multi-part-article-template

3.4 Shared Context (Inline Glossary)

3.4 共享上下文(嵌入式术语表)

⚠️ TIMING: Execute AFTER Steps 3.1-3.3, BEFORE Step 3.5.
Strategy: Tier 1/3 → inline glossary (~200-300 words) embed trong prompt. Tier 2 → seed glossary → context extractors produce
_glossary.md
. Chi tiết: context-optimization.md#glossary-extraction-algorithm.
Article dependencies: Embed 1-2 sentences in prompt, not separate file.
⚠️ 时机:在步骤3.1-3.3之后,步骤3.5之前执行。
策略:层级1/3 → 嵌入式术语表(约200-300字),直接嵌入提示中。层级2 → 生成初始术语表 → 上下文提取器生成
_glossary.md
。详情:context-optimization.md#glossary-extraction-algorithm
文章依赖关系:将1-2句话嵌入提示中,无需独立文件。

3.5 Context Files

3.5 上下文文件

Skip for:
  • Tier 1 (<50K words): Subagents read source directly via line ranges
  • Tier 3 (>=100K words): Subagents read source directly via line ranges
  • Direct Path (<20K words): Main agent writes directly
Decision (see decision-trees.md#3 for full tree):
  • Tier 1/3 or <20K words: Skip context files (subagents read source directly via line ranges)
  • Tier 2 (50K-100K): Spawn context extractor subagents (batch: min(3, article_count))
  • Template:
    templates/_context-file-template.md
Each context file:
analysis/XX-{slug}-context.md
跳过场景
  • 层级1(文档<5万字):子Agent通过行范围直接读取源文档
  • 层级3(文档≥10万字):子Agent通过行范围直接读取源文档
  • 直接路径(文档<2万字):主Agent直接撰写
决策逻辑(查看decision-trees.md#3获取完整决策树):
  • 层级1/3 或 文档<2万字:跳过上下文文件(子Agent通过行范围直接读取源文档)
  • 层级2(5万-10万字):启动上下文提取子Agent(批量处理:最小(3, 文章数量))
  • 模板:
    templates/_context-file-template.md
每个上下文文件路径:
analysis/XX-{slug}-context.md

3.6 Quality Gate: Analysis Complete

3.6 质量检查:分析完成

Before proceeding to Step 4, verify:
  • All sections have IDs (from structure.json)
  • Critical sections marked (* auto-detected in structure.json)
    • Guideline: Thường <=30% sections là critical
    • If >30%: Tự động ghi nhận trong
      _plan.md
      , KHÔNG cần user confirmation
      • Document: "High critical ratio: {ratio}% - technical content"
      • Tiếp tục workflow bình thường
    • If >50%: Tự động chuyển sang Tier 3 strategy (read source directly)
      • KHÔNG cần STOP hoặc ask user
      • Tier 3 xử lý được high critical ratio vì đọc source trực tiếp
      • Ghi log: "Auto-escalated to Tier 3 due to high critical ratio"
    • Rationale: Tự động xử lý thay vì blocking workflow để hỏi user
  • Article plan covers 100% sections
  • For Tier 3: _plan.md created with line ranges
进入步骤4之前,验证以下内容:
  • 所有章节均有ID(来自structure.json)
  • 关键章节已标记(* 由structure.json自动检测)
    • 指南:通常≤30%的章节为关键章节
    • 若超过30%:在
      _plan.md
      中自动记录,无需用户确认
      • 记录内容:“关键章节比例高:{ratio}% - 技术类内容”
      • 继续正常工作流
    • 若超过50%:自动切换到层级3策略(直接读取源文档)
      • 无需停止或询问用户
      • 层级3可处理高比例关键章节,因为直接读取源文档
      • 记录日志:“因关键章节比例过高,自动升级到层级3”
    • 理由:自动处理而非阻塞工作流询问用户
  • 文章规划覆盖100%章节
  • 对于层级3:已创建带行范围的_plan.md

Step 4: Write Articles

步骤4:撰写文章

4.0a Pre-read Voice & Structure (BẮT BUỘC)

4.0a 预读语气与结构文件(必须)

PHẢI thực hiện TRƯỚC khi spawn subagents. Main agent đọc sẵn voice và structure files, embed nội dung vào subagent prompt. Subagent KHÔNG tự đọc các file này.
python
undefined
必须在启动子Agent之前执行。主Agent预先读取语气和结构文件,将内容嵌入子Agent提示中。子Agent不会自行读取这些文件。
python
undefined

Main agent đọc 1 lần, dùng cho tất cả subagents

主Agent读取一次,所有子Agent共用

voice_content = Read(f"{VOICES_DIR}/{voice}.md") structure_content = Read(f"{STRUCTURES_DIR}/{structure}.md")
voice_content = Read(f"{VOICES_DIR}/{voice}.md") structure_content = Read(f"{STRUCTURES_DIR}/{structure}.md")

Embed vào prompt thay vì truyền file path

正确做法:将内容嵌入提示

ĐÚNG: VOICE:\n{voice_content}

正确示例: VOICE:\n{voice_content}

SAI: STYLE: {VOICES_DIR}/{voice}.md (subagent phải tự đọc → lãng phí context)

错误示例: STYLE: {VOICES_DIR}/{voice}.md (子Agent需自行读取 → 浪费上下文)


**Lý do**: Mỗi file read trong subagent tạo ~4-6 JSON messages trong conversation transcript. Với 2 file reads (voice + structure), mỗi subagent tiết kiệm ~8-12 messages + ~300 lines content trong transcript trả về cho main agent.

**理由**:子Agent每读取一个文件,会在对话记录中产生约4-6条JSON消息。若读取2个文件(语气+结构),每个子Agent可节省约8-12条消息 + 约300行返回内容给主Agent。

4.0b Subagent Context Budget Rules

4.0b 子Agent上下文预算规则

Giảm output trả về main agent:
  1. CONTEXT RULES - Đã embed trong prompt template, cấm subagent glob/read files thừa
  2. run_in_background: true - Dùng cho parallel article writing (≥3 articles). Main agent không nhận full transcript vào context, chỉ check output file khi cần.
python
undefined
减少返回给主Agent的内容
  1. 上下文规则 - 已嵌入提示模板,禁止子Agent额外读取文件
  2. run_in_background: true - 用于并行撰写文章(≥3篇)。主Agent不会将完整对话记录加入上下文,仅在需要时检查输出文件。
python
undefined

Parallel writing với run_in_background

并行撰写,使用run_in_background

tasks = [] for article in articles: task = Task( subagent_type="general-purpose", description=f"Write: {article.title}",
    run_in_background=True,  # QUAN TRỌNG: tránh prompt too long
    prompt=compose_prompt(article, voice_content, structure_content)
)
tasks.append(task)
tasks = [] for article in articles: task = Task( subagent_type="general-purpose", description=f"撰写: {article.title}",
    run_in_background=True,  # 适用于≥3篇文章
    prompt=compose_prompt(article, voice_content, structure_content)
)
tasks.append(task)

Check completion bằng Read tool trên output file

通过Read工具检查输出文件完成情况

KHÔNG dùng TaskOutput với block=true cho nhiều tasks

禁止对多个任务使用TaskOutput并设置block=true

undefined
undefined

4.0c State Tracking (Recommended)

4.0c 状态跟踪(推荐)

For resume and retry support, create/update
analysis/_state.json
. Required if retry-workflow is needed (see retry-workflow.md):
json
{
  "status": "in_progress",
  "current_step": 4,
  "completed_articles": ["00-overview.md"],
  "pending_articles": ["01-intro.md", "02-core.md"]
}
See retry-workflow.md for details.
For selective re-runs (style change or single article rewrite), see retry-workflow.md#selective-re-run.
为支持恢复和重试,创建/更新
analysis/_state.json
。若需要重试工作流(查看retry-workflow.md),则必须使用该文件:
json
{
  "status": "in_progress",
  "current_step": 4,
  "completed_articles": ["00-overview.md"],
  "pending_articles": ["01-intro.md", "02-core.md"]
}
查看retry-workflow.md获取详情。
对于选择性重跑(修改风格或重写单篇文章),查看retry-workflow.md#selective-re-run

4.1 Overview Article (Phase 1)

4.1 概述文章(第一阶段)

Write
00-overview.md
in main context:
  • Requires full series knowledge
  • Template:
    templates/_overview-template.md
  • Target: 300-400 words (initial)
  • Include placeholders for Key Takeaways and Article Index
Phase 1 content:
  • Surprising insight + Micro-story + Core questions + Why It Matters
  • Placeholder sections for Điểm chính and Mục lục
在主上下文中撰写
00-overview.md
  • 需要掌握整个系列的知识
  • 模板:
    templates/_overview-template.md
  • 目标字数:300-400字(初始版)
  • 包含“关键要点”和“系列文章索引”的占位符
第一阶段内容
  • 令人惊讶的见解 + 微型故事 + 核心问题 + 重要性
  • “关键要点”和“目录”的占位符章节

4.2 Content Articles

4.2 内容文章

Direct Path (<20K words): Main agent writes all articles directly.
Direct Path guidelines — main agent follows cùng shared rules như subagent:
  • Đọc voice file + structure file
  • Đọc source content.md trực tiếp (full hoặc theo line ranges từ structure.json)
  • Apply tất cả shared rules: LANGUAGE, FORMATTING, REWRITE RULE, ANTI-AI WRITING
  • KHÔNG cần return format (vì không có subagent)
  • Viết từng article theo
    _plan.md
    , save vào
    articles/XX-{slug}.md
  • Mỗi article MUST end with "## Các bài viết trong series"
  • Coverage tracking: main agent tự tạo
    _coverage.md
    sau khi viết xong tất cả
Standard/Fast Path: Spawn subagents for articles 01+:
Task tool:
- subagent_type: "general-purpose"
- description: "Write: {title}"
- run_in_background: true  # Dùng cho ≥3 articles
- prompt: [Use references/article-writer-prompt.md]
直接路径(文档<2万字):主Agent直接撰写所有文章。
直接路径指南 — 主Agent遵循与子Agent相同的共享规则:
  • 读取语气文件 + 结构文件
  • 直接读取源文档content.md(完整内容或来自structure.json的行范围)
  • 应用所有共享规则:语言、格式、重写规则、反AI写作
  • 无需返回格式(因为没有子Agent)
  • 按照
    _plan.md
    撰写每篇文章,保存到
    articles/XX-{slug}.md
  • 每篇文章末尾必须添加“## 系列文章列表”
  • 覆盖率跟踪:主Agent在完成所有文章后自动创建
    _coverage.md
标准/快速路径:为第01篇及以后的文章启动子Agent:
Task工具:
- subagent_type: "general-purpose"
- description: "撰写: {title}"
- run_in_background: true  # 适用于≥3篇文章
- prompt: [使用references/article-writer-prompt.md]

QUAN TRỌNG: Dùng {voiceContent} và {structureContent} đã pre-read ở Step 4.0a

重要提示: 使用步骤4.0a中预读的{voiceContent}和{structureContent}

KHÔNG truyền file paths cho subagent tự đọc

禁止传递文件路径让子Agent自行读取


**Multi-Part Articles** (from Step 3.3.1):

For split articles, spawn each part sequentially within the article:

**多部分文章**(来自步骤3.3.1):

对于拆分后的文章,在同一文章内按顺序启动各部分的子Agent:

Article 2 was split into 3 parts

第2篇文章拆分为3个部分

  1. Spawn 02-core-part1.md
  2. Wait for completion → extract context bridge
  3. Spawn 02-core-part2.md (with context from part1)
  4. Wait → extract context bridge
  5. Spawn 02-core-part3.md (with context from part2)
  1. 启动02-core-part1.md的子Agent
  2. 等待完成 → 提取上下文衔接内容
  3. 启动02-core-part2.md的子Agent(带入第一部分的上下文)
  4. 等待完成 → 提取上下文衔接内容
  5. 启动02-core-part3.md的子Agent(带入第二部分的上下文)

Other articles can run in parallel

其他文章可并行处理

e.g., 01-intro.md and 03-advanced.md can run while part2 waits

例如:01-intro.md和03-advanced.md可在等待第二部分时并行运行


**Context bridge extraction:**

> See [large-doc-processing.md §Context Bridge](references/large-doc-processing.md#context-bridge) for the `extract_context_bridge()` function used between multi-part articles.

**Prompt validation (optional, for debugging):**

```bash
echo "{prompt_text}" | {SCRIPTS_DIR}/wa-validate-prompt --tier {1|2|3} --stdin
Validates all required template variables are present. Exit code 0 = PASS, 1 = missing variables.
Continuous Batching (preferred over static batching):
  • Tier 1-2:
    max_concurrent = 3
    (smaller chunks ~3.5K words)
  • Tier 3:
    max_concurrent = 2
    (larger chunks ~10K words)
  • Dynamic adjustment: large chunks (>8K) → reduce to 2, all small (<2K) → increase to 5
  • On any completion → spawn next immediately (no batch waiting)
  • Benefits: 25-35% faster than static batching
See large-doc-processing.md#continuous-batching-vs-static for full algorithm.
Progress Reporting:
After each article completes, update TaskUpdate:
  • Format:
    "Writing articles: {completed}/{total} completed"
  • Example:
    "Writing articles: 3/7 completed"
  • Do NOT include time estimates

**上下文衔接内容提取**:

> 查看[large-doc-processing.md §Context Bridge](references/large-doc-processing.md#context-bridge)获取多部分文章之间使用的`extract_context_bridge()`函数。

**提示验证(可选,用于调试)**:

```bash
echo "{prompt_text}" | {SCRIPTS_DIR}/wa-validate-prompt --tier {1|2|3} --stdin
验证所有必填模板变量是否存在。退出码0=通过,1=缺失变量。
持续批量处理(优于静态批量处理):
  • 层级1-2:
    max_concurrent = 3
    (较小内容块~3500字)
  • 层级3:
    max_concurrent = 2
    (较大内容块~10000字)
  • 动态调整:大内容块(>8000字)→ 并发数减为2,所有小内容块(<2000字)→ 并发数增至5
  • 任何文章完成后 → 立即启动下一个(无需等待批量完成)
  • 优势:比静态批量处理快25-35%
查看large-doc-processing.md#continuous-batching-vs-static获取完整算法。
进度报告
每完成一篇文章,更新TaskUpdate:
  • 格式:
    "文章撰写进度: {已完成数}/{总数} 篇完成"
  • 示例:
    "文章撰写进度: 3/7 篇完成"
  • 禁止包含时间预估

4.3 SoT Pattern (Long Articles)

4.3 SoT模式(长文章)

When to use Skeleton-of-Thought: estimated output >2000 words AND >=5 subsections (H3 preferred, fallback to H2).
Quick decision:
h3_count >= 5
→ SoT.
h3 == 0 AND h2 >= 5
→ SoT.
h3 + h2 >= 5
→ SoT. Otherwise → standard write.
Workflow: Phase 1 (skeleton) → Phase 2 (expand ALL sections parallel) → Phase 3 (merge + transitions)
Benefits: 45-50% faster for long articles. See article-writer-prompt.md#sot-pattern for template.
Limitations: Priority 3 (paragraph breaks) not implemented. Ambiguous structure → default to standard write.
适用场景:预估输出字数>2000字 且 包含≥5个小节(优先H3,无H3则 fallback 到H2)。
快速判断
h3_count >=5
→ 使用SoT模式。
h3 ==0 且 h2 >=5
→ 使用SoT模式。
h3 + h2 >=5
→ 使用SoT模式。否则 → 标准撰写。
工作流:阶段1(框架)→ 阶段2(并行扩展所有小节)→ 阶段3(合并+过渡)
优势:长文章撰写速度提升45-50%。查看article-writer-prompt.md#sot-pattern获取模板。
限制:优先级3(段落换行)未实现。结构模糊的文章默认使用标准撰写模式。

4.4 Coverage Tracking

4.4 覆盖率跟踪

Coverage Format Pipeline: Subagent returns 2-column (
Section | Status
) → Main agent enriches to 4-column (
Section | Assigned To | Used In | Status
) → Aggregate into
_coverage.md
. See §5.2 for aggregation.
IMPORTANT: PASS/FAIL chỉ dựa trên section coverage, không phải word count. Word count chỉ mang tính thống kê.
Subagent return format (see article-writer-prompt.md):
markdown
DONE: {filename} | {N} words
KEY_TAKEAWAY: Sinh lực bùng lên khi có mục đích rõ ràng và hành động mỗi ngày
COVERAGE:
| Section | Status |
|---------|--------|
| S01 | ✅ quoted |
| S02 ⭐ | ✅ faithful |
RESULT: PASS
SERIES_LIST: YES
VERIFY: "Vita Nova" (L21)
Tiêu chí PASS/FAIL:
  • PASS: Tất cả assigned sections được covered HOẶC skipped với lý do hợp lệ (redundant, off-topic, user instruction)
  • FAIL: Có section bị missing hoặc skipped không hợp lệ (không có lý do, hoặc "too long" / "already covered" thiếu reference)
  • Word count: Chỉ thống kê, KHÔNG ảnh hưởng PASS/FAIL
Main agent enriches with "Assigned To" and "Used In" columns → aggregates into
_coverage.md
(4-column format, see Step 5.2).
覆盖率格式流程:子Agent返回2列格式(
章节 | 状态
)→ 主Agent扩展为4列(
章节 | 分配文章 | 使用位置 | 状态
)→ 汇总到
_coverage.md
。查看§5.2获取汇总方式。
重要提示:通过/失败仅依据章节覆盖率,与字数无关。字数仅作统计用。
子Agent返回格式(查看article-writer-prompt.md):
markdown
完成: {filename} | {N} 字
关键要点: 当有明确目标且每日行动时,活力会迸发
覆盖率:
| 章节 | 状态 |
|---------|--------|
| S01 | ✅ 引用 |
| S02 ⭐ | ✅ 忠实重写 |
结果: 通过
系列文章列表: 已添加
验证: "Vita Nova" (L21)
通过/失败标准
  • 通过:所有分配的章节均已覆盖 或 因合理理由跳过(冗余、偏离主题、用户指令)
  • 失败:存在未覆盖的章节 或 无合理理由跳过(无理由,或仅说明“太长”/“已覆盖”但无参考)
  • 字数:仅作统计,不影响通过/失败判断
主Agent添加“分配文章”和“使用位置”列 → 汇总到
_coverage.md
(4列格式,查看步骤5.2)。

4.5 Critical Sections

4.5 关键章节

⭐ sections MUST be faithfully rewritten (không tóm tắt, không bỏ ý):
  • Giữ 100% ý nghĩa và thông tin gốc, KHÔNG được tóm tắt hay lược bỏ
  • PHẢI viết lại bằng tiếng Việt theo voice đã chọn
  • KHÔNG copy nguyên văn từ source
  • If unable to include fully → flag for review
⭐标记的章节必须忠实重写(不得摘要、不得遗漏内容):
  • 100%保留原文含义和信息,不得摘要或省略
  • 必须按照所选语气翻译成越南语
  • 不得直接复制原文
  • 若无法完整包含 → 标记为需要审核

4.6 Quality Gate: Articles Complete

4.6 质量检查:文章完成

Before proceeding to Step 5, verify từ subagent returns (KHÔNG cần đọc article files):
  • All articles written (check pending list vs DONE returns)
  • All RESULT: PASS (coverage đầy đủ)
  • All SERIES_LIST: YES
  • KEY_TAKEAWAY collected từ mỗi subagent (dùng cho Step 5.1)
  • VERIFY quotes provided (spot-check source fidelity)
进入步骤5之前,根据子Agent返回内容验证(无需读取文章文件):
  • 所有文章已完成(对比待处理列表和完成返回)
  • 所有结果: 通过(覆盖率完整)
  • 所有系列文章列表: 已添加
  • 已收集每个子Agent返回的关键要点(用于步骤5.1)
  • 已提供验证引用(抽查原文准确性)

Step 5: Synthesize

步骤5:合成

5.1 Update Overview (Phase 2)

5.1 更新概述(第二阶段)

Update
00-overview.md
with actual content for placeholder sections.
KHÔNG đọc lại articles. Dùng dữ liệu đã có:
python
undefined
用实际内容更新
00-overview.md
中的占位符章节。
禁止重新读取文章。使用已有的数据:
python
undefined

Nguồn dữ liệu cho overview (KHÔNG cần đọc article files):

概述的数据源(无需读取文章文件):

key_takeaways = [] # Từ KEY_TAKEAWAY trong return format của mỗi subagent series_list = [] # Từ _plan.md (đã có titles + descriptions từ Step 3) core_message = "" # Từ _plan.md Series Context

**Multi-part articles**: Gom KEY_TAKEAWAYs của các parts thành 1 takeaway cho bài đó. Ví dụ: article 02 có 3 parts → chọn takeaway đại diện nhất hoặc tổng hợp thành 1 câu.

**Điểm chính** (Key Takeaways) - compose từ KEY_TAKEAWAYs:

```markdown
key_takeaways = [] # 来自每个子Agent返回格式中的关键要点 series_list = [] # 来自步骤3的_plan.md(已包含标题+描述) core_message = "" # 来自_plan.md的系列上下文

**多部分文章**:将同一文章各部分的关键要点合并为1个要点。例如:第02篇文章有3个部分 → 选择最具代表性的要点或合并为1句话。

**关键要点**(从各子Agent的关键要点组合):

```markdown

Điểm chính

关键要点

  1. [Concept từ article 1 KEY_TAKEAWAY]: [Expand từ takeaway]
  2. [Concept từ article 2 KEY_TAKEAWAY]: [Expand từ takeaway]
  3. [Concept từ article 3 KEY_TAKEAWAY]: [Expand từ takeaway]

**Các bài viết trong series** (Series List) - compose từ `_plan.md`:

```markdown
  1. [来自第1篇文章关键要点的概念]: [扩展要点内容]
  2. [来自第2篇文章关键要点的概念]: [扩展要点内容]
  3. [来自第3篇文章关键要点的概念]: [扩展要点内容]

**系列文章列表**(从_plan.md组合):

```markdown

Các bài viết trong series

系列文章列表

  1. Tổng quan - Brief description (đang xem)
  2. Article 1 Title - Brief description
  3. Article 2 Title - Brief description

**Final overview target**: 400-600 words (overview đặc biệt, dùng word target thay vì section coverage)

**Fallback nếu KEY_TAKEAWAY kém**: Nếu takeaway quá generic hoặc trống, dùng article title + plan description từ `_plan.md` thay thế. KHÔNG đọc article file chỉ để cải thiện takeaway.
  1. 总览 - 简要描述 (当前查看)
  2. 第1篇文章标题 - 简要描述
  3. 第2篇文章标题 - 简要描述

**最终概述目标字数**:400-600字(概述特殊,使用字数目标而非章节覆盖率)

**关键要点质量不佳的回退方案**:若关键要点过于通用或为空,使用文章标题+plan.md中的描述替代。禁止为改进要点而读取文章文件。

5.2 Coverage Aggregation

5.2 覆盖率汇总

Collect subagent coverage tables → aggregate into
analysis/_coverage.md
Process: Subagent returns 2-column (
Section | Status
) → Main agent enriches to 4-column (
Section | Assigned To | Used In | Status
) → Concatenate into
_coverage.md
→ Add summary stats.
Coverage file format:
markdown
undefined
收集子Agent返回的覆盖率表格 → 汇总到
analysis/_coverage.md
流程:子Agent返回2列格式(
章节 | 状态
)→ 主Agent扩展为4列(
章节 | 分配文章 | 使用位置 | 状态
)→ 连接到
_coverage.md
→ 添加统计摘要。
覆盖率文件格式
markdown
undefined

Section Coverage Matrix

章节覆盖率矩阵

SectionAssigned ToUsed InStatus
S0101-article.md01-article.md✅ summarized
S02 ⭐01-article.md01-article.md✅ faithful
  • Total: {N} | Used: {N} | Missing: {N}

**Edge cases** (reassignment, shared sections, skipped): See [large-doc-processing.md#coverage-tracking](references/large-doc-processing.md#coverage-tracking).

Run validation:

```bash
{SCRIPTS_DIR}/wa-validate docs/generated/{book}/analysis/_coverage.md
章节分配文章使用位置状态
S0101-article.md01-article.md✅ 摘要
S02 ⭐01-article.md01-article.md✅ 忠实重写
  • 总章节数: {N} | 已使用: {N} | 缺失: {N}

**边缘情况**(重新分配、共享章节、跳过):查看[large-doc-processing.md#coverage-tracking](references/large-doc-processing.md#coverage-tracking)。

运行验证:

```bash
{SCRIPTS_DIR}/wa-validate docs/generated/{book}/analysis/_coverage.md

Step 6: Verify

步骤6:验证

6.1 Coverage Check

6.1 覆盖率检查

Soft target: Coverage nên đạt >=95% (không bắt buộc retry)
Coverage results:
├─ >= 95% → PASS (tiếp tục)
├─ 90-94% → WARNING (ghi nhận, không retry tự động)
│   └─ Chỉ retry nếu user yêu cầu
├─ < 90% → ASK USER
│   └─ Option 1: Accept as-is
│   └─ Option 2: Retry specific articles
│   └─ Option 3: Create supplementary
QUAN TRỌNG: Không tự động retry để đạt coverage target. Việc retry tốn token và thời gian, thường không cải thiện đáng kể.
软目标:覆盖率应≥95%(无需强制重试)
覆盖率结果:
├─ ≥95% → 通过(继续流程)
├─ 90-94% → 警告(记录,不自动重试)
│   └─ 仅在用户要求时重试
├─ <90% → 询问用户
│   └─ 选项1:接受当前结果
│   └─ 选项2:重试指定文章
│   └─ 选项3:创建补充内容
重要提示:禁止自动重试以达到覆盖率目标。重试会消耗token和时间,通常不会显著提升质量。

6.2 Quality Checklist

6.2 质量检查清单

Verify từ subagent returns + overview file (KHÔNG cần đọc article files):
  • All RESULT: PASS (từ subagent returns)
  • Overview updated with Key Takeaways and Series List (đọc
    00-overview.md
    ~600 words)
  • All SERIES_LIST: YES (từ returns, append nếu NO)
  • All links in series lists verified (trong overview file)
  • _coverage.md reported (>=95% target, >=90% acceptable)
  • Critical ⭐ sections: VERIFY quotes match source (spot-check từ returns)
  • Warnings logged for any skipped sections
  • Anti-AI writing rules passed (xem article-writer-prompt.md#anti-ai-writing)
根据子Agent返回内容+概述文件验证(无需读取文章文件):
  • 所有结果: 通过(来自子Agent返回)
  • 概述已更新关键要点和系列文章列表(读取
    00-overview.md
    约600字)
  • 所有系列文章列表: 已添加(来自返回内容,若未添加则补充)
  • 系列列表中的所有链接已验证(在概述文件中)
  • 已生成_coverage.md报告(目标≥95%,≥90%可接受)
  • 关键⭐章节:验证引用与原文匹配(从返回内容中抽查)
  • 已记录所有跳过章节的警告
  • 已通过反AI写作规则检查(查看article-writer-prompt.md#anti-ai-writing

6.3 Error Recovery (User-Driven)

6.3 错误恢复(用户驱动)

Policy: Không tự động retry. Mọi lỗi đều report cho user và chờ quyết định. See retry-workflow.md.
策略:禁止自动重试。所有错误均需报告给用户并等待决策。查看retry-workflow.md

Content Guidelines

内容指南

Key rules: Source fidelity (rewrite, don't copy), ⭐ critical sections = faithful rewrite 100%, Anti-AI writing (no em dash, no AI vocabulary), NO tables/diagrams in output, MỖI article PHẢI có "## Các bài viết trong series" ở cuối. Full details: article-writer-prompt.md.
核心规则:忠实于原文(重写,不复制),⭐关键章节=100%忠实重写,反AI写作(禁止使用破折号、AI常用词汇),输出中禁止包含表格/图表,每篇文章末尾必须添加“## 系列文章列表”。完整详情:article-writer-prompt.md

Cài đặt thư viện mới

安装新库

Skill sử dụng virtual environment tại
{SCRIPTS_DIR}/.venv
. Khi cần cài thêm thư viện, PHẢI activate venv trước:
bash
undefined
该Skill使用位于
{SCRIPTS_DIR}/.venv
的虚拟环境。需要安装新库时,必须先激活虚拟环境
bash
undefined

1. Activate venv (dùng SCRIPTS_DIR từ Step 0)

1. 激活虚拟环境(使用步骤0中获取的SCRIPTS_DIR)

source {SCRIPTS_DIR}/.venv/bin/activate
source {SCRIPTS_DIR}/.venv/bin/activate

2. Cài package

2. 安装包

uv pip install <package>
uv pip install <package>

3. Cập nhật requirements.txt

3. 更新requirements.txt

uv pip freeze > {SCRIPTS_DIR}/requirements.txt

**KHÔNG dùng:**

- `uv pip install <package>` khi chưa activate venv → lỗi "No virtual environment found"
- `uv pip install <package> --system` → lỗi "externally managed" (Python Homebrew)
- `uv add <package>` → cần pyproject.toml, skill dùng requirements.txt

<br>
uv pip freeze > {SCRIPTS_DIR}/requirements.txt

**禁止使用**:

- 未激活虚拟环境时执行`uv pip install <package>` → 报错“No virtual environment found”
- `uv pip install <package> --system` → 报错“externally managed”(Homebrew安装的Python)
- `uv add <package>` → 需要pyproject.toml,该Skill使用requirements.txt

<br>