writer-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWriter Agent
Writer Agent
Transform documents and URLs into styled article series.
将文档和网址转换为风格统一的系列文章。
Quick Reference
快速参考
| Reference | Purpose | Load at Step | DP | T1 | T2 | T3 |
|---|---|---|---|---|---|---|
| directory-structure.md | Output folder layout | Step 1 | ✓ | ✓ | ✓ | ✓ |
| decision-trees.md | Workflow decision guides | On confusion only | ✓ | ✓ | ✓ | ✓ |
| retry-workflow.md | Error recovery procedures | On error only | - | ✓ | ✓ | ✓ |
| large-doc-processing.md | Handling documents >50K words | Step 3 (if >20K) | - | - | ✓ | ✓ |
| article-writer-prompt.md | Subagent prompt templates | Step 4 | - | ✓ | ✓ | ✓ |
| context-extractor-prompt.md | Context extraction template | Step 3 (Tier 2) | - | - | ✓ | - |
| context-optimization.md | Context optimization anti-patterns | Step 3.1 | - | ✓ | ✓ | ✓ |
| detail-levels.md | Output detail level options | Step 2.5 | ✓ | ✓ | ✓ | ✓ |
DP = Direct Path | T1-T3 = Tier 1-3 | ✓ = Load | - = Skip
Dimension files (loaded at Step 2): , , , ,
voices/{voice}.mdstructures/{structure}.mdidentities/{identity}.mdaudiences/{audience}.mdemotional_maps/{emotion}.md| 参考文档 | 用途 | 加载步骤 | DP | T1 | T2 | T3 |
|---|---|---|---|---|---|---|
| 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}.mdstructures/{structure}.mdidentities/{identity}.mdaudiences/{audience}.mdemotional_maps/{emotion}.mdWorkflow 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 6Standard (Tier 1-2, 20K-100K words):
Input → Convert → Style/Structure → Analyze → Extract → Write → Synthesize → Verify
1 1 2 3 3 4 5 6Fast 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 6Step 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-convertGlob("**/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, luôn dùng đường dẫn tuyệt đối từ Glob..claude/skills/writer-agent/...
必须在所有其他步骤之前执行。该Skill可安装在不同位置。
步骤1:使用Glob查找:
wa-convertGlob("**/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
重要提示:禁止硬编码路径,始终使用Glob获取的绝对路径。.claude/skills/writer-agent/...
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 Type | Detection | Action |
|---|---|---|
| File (PDF/DOCX/EPUB/etc) | Path + extension | |
| URL (web page) | | |
| YouTube URL | | |
| Plain text / .txt / .md | No complex extension | Rewrite → |
检测输入类型并转换为markdown格式。
输出语言:始终为越南语,无论源语言是什么。
| 输入类型 | 检测方式 | 处理操作 |
|---|---|---|
| 文件(PDF/DOCX/EPUB等) | 路径+扩展名 | |
| 网址(网页) | 包含 | |
| YouTube网址 | 包含 | |
| 纯文本/.txt/.md | 无复杂扩展名 | 重写后执行 |
File/URL Conversion
文件/网址转换
bash
{SCRIPTS_DIR}/wa-convert [/path/to/file.pdf or url]Output:
docs/generated/{slug}-{timestamp}/input-handling/content.mdbash
{SCRIPTS_DIR}/wa-convert [/path/to/file.pdf 或 url]输出路径:
docs/generated/{slug}-{timestamp}/input-handling/content.mdPlain Text Processing
纯文本处理
- Read content (if file)
- Rewrite to structured markdown (add headings, preserve content)
- Propose title
- Execute:
bash
echo "{rewritten_content}" | {SCRIPTS_DIR}/wa-paste-text - --title "{title}"- 读取内容(若为文件)
- 重写为结构化markdown(添加标题,保留内容)
- 建议标题
- 执行命令:
bash
echo "{rewritten_content}" | {SCRIPTS_DIR}/wa-paste-text - --title "{title}"Error Handling
错误处理
| Error | Action |
|---|---|
| File not found | Ask for correct path |
| Unsupported format | Try Docling, confirm with user |
| URL fetch failed | Report and stop |
| Empty content | Warn, confirm before continue |
| Encrypted PDF | Ask 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).
| Voice | File | Mô tả |
|---|---|---|
| Teacher | | "Chúng ta" đồng hành, teaching, ấm áp |
| Personal | | "Tôi" personal journey, vulnerable |
| Objective | | Neutral, data-driven, formal |
| Guide | | Đồng hành mindful, Đông-Tây |
| Investigator | | Tìm hiểu, đặt câu hỏi, challenge |
| Dialogue | | Thầy-trò đối thoại, Zen |
| Storyteller | | Kể chuyện ngôi thứ nhất, chánh niệm |
| Custom | User tạo mới | Theo |
Voice files:
voices/{voice}.mdXem để so sánh tất cả dimensions.
references/_dimension-comparison.mdCustom voice: Nếu user muốn tạo voice riêng, copy → , điền theo template. Tương tự cho custom structure: → .
templates/_voice-template.mdvoices/{custom-name}.mdstructures/_structure-template.mdstructures/{custom-name}.md询问用户确认语气(文风、语调、人设)。
| 语气 | 文件 | 描述 |
|---|---|---|
| Teacher | | 采用“我们”的口吻,陪伴式教学,语气亲切温暖 |
| Personal | | 采用“我”的口吻,讲述个人经历,风格真诚 |
| Objective | | 中立客观,基于数据,正式严谨 |
| Guide | | 陪伴引导,融合东西方理念 |
| Investigator | | 探索式,善于提问,挑战固有认知 |
| Dialogue | | 师徒对话式,带有禅意 |
| Storyteller | | 第一人称叙事,注重正念 |
| 自定义 | 用户自行创建 | 参考 |
语气文件路径:
voices/{voice}.md可查看了解所有维度的对比信息。
references/_dimension-comparison.md自定义语气:若用户想要创建自定义语气,复制到,并按模板填写内容。自定义结构同理:复制到。
templates/_voice-template.mdvoices/{custom-name}.mdstructures/_structure-template.mdstructures/{custom-name}.mdStep 2b: Select Structure
步骤2b:选择结构(Structure)
Hỏi user để confirm structure (tổ chức bài viết).
Mỗi voice có trong frontmatter. Suggest default, user có thể override.
default_structure| Structure | File | Organization | Default cho |
|---|---|---|---|
| BLUF-Evidence | | Executive Summary → Evidence → Action | Objective |
| Building Blocks | | Hook → Intuition → Concept → Example → Apply | Teacher |
| Five Layers | | Surface → Structure → Tension → Connection → Synth | Investigator |
| Spiral Return | | Moment → Spiral deeper → Open ending | Personal |
| Master-Student | | Experience → Dialogue → Silence | Dialogue |
| Story Arc | | Scene → Encounter → Deepening → Transformation | Storyteller |
| Depth-Practice | | Present moment → Layers → Practice invitation | Guide |
Structure files:
structures/{structure}.mdXem để so sánh và mix-match.
references/_dimension-comparison.md询问用户确认文章结构。
每种语气在其前置元数据中都有默认结构映射,系统会建议默认选项,用户可确认或选择其他结构。
| 结构 | 文件 | 组织方式 | 默认适配语气 |
|---|---|---|---|
| BLUF-Evidence | | 执行摘要→证据→行动方案 | Objective |
| Building Blocks | | 钩子引入→直觉引导→概念讲解→示例→实践应用 | Teacher |
| Five Layers | | 表层→结构→张力→关联→综合 | Investigator |
| Spiral Return | | 瞬间切入→螺旋式深入→开放式结尾 | Personal |
| Master-Student | | 经验分享→对话交流→留白思考 | Dialogue |
| Story Arc | | 场景铺垫→冲突相遇→深度挖掘→转变升华 | Storyteller |
| Depth-Practice | | 当下时刻→分层解析→实践邀请 | Guide |
结构文件路径:
structures/{structure}.md可查看了解结构对比和组合指南。
references/_dimension-comparison.mdStep 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.
| Identity | File | Mô tả | Default cho |
|---|---|---|---|
| Tech Builder | | Practitioner, pragmatic builder | Teacher |
| Contemplative Thinker | | Hành giả, tìm ý nghĩa | Personal, Guide, Dialogue, Storyteller |
| Knowledge Curator | | Cross-domain connector | Objective, Investigator |
| Custom | User tạo mới | Theo | - |
Identity files:
identities/{identity}.md询问用户选择作者身份,系统会根据所选语气建议默认选项,用户可确认或选择其他身份。
| 身份 | 文件 | 描述 | 默认适配语气 |
|---|---|---|---|
| Tech Builder | | 实践者,务实的构建者 | Teacher |
| Contemplative Thinker | | 修行者,追寻意义 | Personal、Guide、Dialogue、Storyteller |
| Knowledge Curator | | 跨领域知识连接者 | Objective、Investigator |
| 自定义 | 用户自行创建 | 参考 | - |
身份文件路径:
identities/{identity}.mdStep 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.
| Audience | File | Mô tả | Default cho |
|---|---|---|---|
| Busy Professionals | | Bận, cần actionable | Objective |
| Curious Beginners | | Mới, cần clarity | Teacher, Guide |
| Deep Seekers | | Muốn chiều sâu | Personal, Investigator, Dialogue, Storyteller |
| Custom | User tạo mới | Theo | - |
Audience files:
audiences/{audience}.md询问用户文章的目标受众,系统会根据所选语气建议默认选项,用户可确认或选择其他受众。
| 受众 | 文件 | 描述 | 默认适配语气 |
|---|---|---|---|
| Busy Professionals | | 时间紧张,需要可落地内容 | Objective |
| Curious Beginners | | 新手,需要清晰易懂的内容 | Teacher、Guide |
| Deep Seekers | | 追求深度内容 | Personal、Investigator、Dialogue、Storyteller |
| 自定义 | 用户自行创建 | 参考 | - |
受众文件路径:
audiences/{audience}.mdStep 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.
| Emotion | File | Mô tả | Default cho |
|---|---|---|---|
| Empower & Challenge | | Growth qua discomfort | Teacher, Objective |
| Reflect & Discover | | Stillness, wonder | Personal, Guide, Dialogue, Storyteller |
| Provoke & Transform | | Challenge assumptions | Investigator |
| Custom | User tạo mới | Theo | - |
Emotion files:
emotional_maps/{emotion}.mdFlow: 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 | | 在不适中获得成长 | Teacher、Objective |
| Reflect & Discover | | 沉静、充满好奇 | Personal、Guide、Dialogue、Storyteller |
| Provoke & Transform | | 挑战固有认知 | Investigator |
| 自定义 | 用户自行创建 | 参考 | - |
情感文件路径:
emotional_maps/{emotion}.md流程:选择语气→系统为所有维度建议默认选项→用户逐一确认或选择其他选项
Default Mapping Table
默认映射表
📖 See:for full default mapping table, compatibility matrix, and mixing guidelines.references/_dimension-comparison.md
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 ở , 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.
_dimension-comparison.mdConflict 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.
| Level | Ratio | Description |
|---|---|---|
| Concise | 15-25% | Tóm lược, giữ ý chính |
| Standard | 30-40% | Cân bằng (Recommended) |
| Comprehensive | 50-65% | Chi tiết, giữ nhiều ví dụ |
| Faithful | 75-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_targetWord count để định hướng, không bắt buộc đạt chính xác
字数仅用于方向指引,无需严格达标
undefinedundefinedUnderstanding Detail Level Parameters
理解细节级别参数
Two complementary concepts:
- : Controls total article length relative to source
**target_ratio**
- Standard level: 30-40% (midpoint 35%)
- This ratio applies to the entire article wordcount
- : Controls retention of examples within kept content
**example_percentage**
- Standard level: 60% of examples
- This percentage applies only to example sections
See detail-levels.md for worked examples and full specification.
两个互补概念:
- :控制输出总字数与源文档的比例
**target_ratio**
- 标准版:30-40%(中间值35%)
- 该比例适用于整个系列文章的总字数
- :控制保留示例内容的比例
**example_percentage**
- 标准版:保留60%的示例
- 该比例仅适用于示例章节
查看detail-levels.md获取示例和完整说明。
Step 2.6: Tier Reference Table
步骤2.6:层级参考表
Canonical tier definitions (referenced throughout documentation):
| Tier | Word Count | Strategy | Context Approach | Glossary | max_concurrent |
|---|---|---|---|---|---|
| Direct Path | <20K OR (<50K AND ≤3 articles) | Main agent writes all | N/A (no subagents) | Inline (~200 words) | N/A |
| Tier 1 | 20K-50K (fails Direct Path) | Subagents read source directly | No context files | Inline (~200 words) | 3 |
| Tier 2 | 50K-100K | Smart compression | Context extractors | Separate file (~600 words) | 3 |
| Tier 3 | >=100K | Fast Path, minimal overhead | No context files | Inline (~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 Pathcondition is further limited by language: EN ~44K, VI ~32K, mixed ~38K words. These limits are pre-computed in<50K. If capacity exceeded, fallback to Tier 1.structure.json → direct_path.capacity_ok
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字) | 无 |
| 层级1 | 2万-5万字(不符合直接路径条件) | 轻量级子Agent,按行范围读取源文档 | 无上下文文件 | 嵌入式(约200字) | 3 |
| 层级2 | 5万-10万字 | 智能压缩 | 上下文提取器 | 独立文件(约600字) | 3 |
| 层级3 | ≥10万字 | 快速路径,最小化处理开销 | 无上下文文件 | 嵌入式(约300字) | 2 |
优先级规则:
- 首先检查直接路径条件,该条件优先于层级边界
- 2万-5万字且生成文章数≤3篇的文档使用直接路径(而非层级1)
- 仅不符合直接路径条件的文档才会进入层级选择
注意:直接路径的条件会因语言不同有所调整:英文约4.4万字,越南语约3.2万字,混合语言约3.8万字。这些限制已预计算在<5万字中。若超出容量,则 fallback 到层级1。structure.json → direct_path.capacity_ok
核心差异:
- 直接路径:主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 → use field (computed by v1.2+):
structure.jsondirect_pathwa-convertstructure.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:fields in structure.json (since v1.2) includedirect_path,eligible,capacity_ok, andcapacity_limit. These are pre-computed based on word count, estimated article count, and detected language. Main agent does NOT need to recalculate these values.warning
Examples:
| Document | Words | Articles | Path | Reason |
|---|---|---|---|---|
| Blog post | 15K | 5 | Direct | <20K words (first condition) ✓ |
| Tutorial | 45K | 3 | Direct | <50K AND ≤3 articles (second condition) ✓ |
| Long guide | 48K | 3 | Direct → Tier 1 | Exceeds max_words for mixed (38K) ⚠️ |
| Paper | 45K | 4 | Standard | Fails both conditions (4 > 3) → use subagents |
| Book chapter | 67K | 8 | Standard | Tier 2: smart compression |
| Full book | 142K | 12 | Fast | Tier 3: reference-based |
Note: Direct Path capacity limit depends on language: EN ~44K, VI ~32K, mixed ~38K words. Usefield for accurate limit.structure.json → language
读取 → 使用字段(由 v1.2+版本计算):
structure.jsondirect_pathwa-convertstructure.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中的字段(v1.2版本起)包含direct_path、eligible、capacity_ok和capacity_limit。这些值已根据字数、预估文章数和检测到的语言预计算完成,主Agent无需重新计算。warning
示例:
| 文档类型 | 字数 | 生成文章数 | 处理路径 | 原因 |
|---|---|---|---|---|
| 博客文章 | 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 exists):
structure.json- ONLY read for outline, stats, tier recommendation
structure.json - DO NOT read - it wastes context budget
content.md - Skip manual scanning (outline already in JSON)
Fallback (if missing):
structure.json⚠️ WARNING: Fallback mode loses 51% context optimization. Re-run to generate if possible.
wa-convertstructure.jsonManual scan using efficient commands:
bash
undefined📖 必读:context-optimization.md 解释了会浪费50%以上上下文预算的反模式,开始前请先阅读。
快速路径(若存在):
structure.json- 仅读取获取大纲、统计数据和层级建议
structure.json - 禁止读取- 这会浪费上下文预算
content.md - 跳过手动扫描(大纲已在JSON中)
回退方案(若缺失):
structure.json⚠️ 警告:回退模式会损失51%的上下文优化效果。若可能,请重新运行生成。
wa-convertstructure.json使用高效命令进行手动扫描:
bash
undefinedExtract 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:
| Action | Detail |
|---|---|
| SKIP | |
| CREATE | Minimal |
| EMBED | Key terms (~300 words) + dependencies inline in subagent prompts |
| SPAWN | Subagents immediately after |
Context savings: ~40% reduction in main agent context.
See large-doc-processing.md for format, subagent prompt template, and workflow details.
_plan.md对于超大型文档,最小化分析开销:
| 操作 | 详情 |
|---|---|
| 跳过 | |
| 创建 | 极简版 |
| 嵌入 | 关键术语(约300字)+ 依赖关系,直接嵌入子Agent提示 |
| 启动子Agent | 生成 |
上下文节省:主Agent上下文减少约40%。
查看large-doc-processing.md获取格式、子Agent提示模板和工作流细节。
_plan.md3.2 Content Inventory
3.2 内容清单
Use outline directly. Section IDs, line ranges, word counts, and critical markers are all available in .
structure.jsonstructure.json直接使用中的大纲。章节ID、行范围、字数和关键标记均已在中提供。
structure.jsonstructure.json3.3 Article Plan (analysis/_plan.md
)
analysis/_plan.md3.3 文章规划(analysis/_plan.md
)
analysis/_plan.mdCheck user request first:
python
undefined首先检查用户需求:
python
undefinedPriority: 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 cho mỗi article (, , , , ). Embed vào subagent prompt. Subagent ưu tiên structure file (primary), content-type hint (secondary).
content_typetutorialconceptualnarrativeanalysismixedCONTENT_TYPE: {type}Series Context (QUAN TRỌNG - tạo cùng lúc với plan):
Khi tạo , đồng thời xác định:
_plan.mdmarkdown
undefinedif 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字(参考值,无需严格达标)
- 若用户指定了文章数量,则严格遵循,不再自动拆分
内容类型检测:生成规划时,为每篇文章确定(教程、概念讲解、叙事、分析、混合类型)。将嵌入子Agent提示中。子Agent优先使用结构文件,其次参考内容类型提示。
content_typeCONTENT_TYPE: {type}系列上下文(重要 - 与规划同时生成):
生成时,同时确定:
_plan.mdmarkdown
undefinedSeries 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:
- User-specified count: Nếu user yêu cầu số bài cụ thể → tuân theo, KHÔNG auto-split
- Auto-split: Chỉ áp dụng khi user KHÔNG yêu cầu số bài cụ thể
Key constants:
- (~15 min reading time)
MAX_OUTPUT_WORDS = 3000 - (~13 min reading time)
TARGET_PART_WORDS = 2000 - 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_WORDSAlgorithm: 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.mdPart naming: → ,
02-core.md02-core-part1.md02-core-part2.mdContext 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之前。检查每篇规划中的文章。
优先级规则:
- 用户指定数量:若用户指定了文章数量,则严格遵循,禁止自动拆分
- 自动拆分:仅当用户未指定文章数量时适用
关键常量:
- (约15分钟阅读时长)
MAX_OUTPUT_WORDS = 3000 - (约13分钟阅读时长)
TARGET_PART_WORDS = 2000 - 最小拆分单元 = 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.md02-core-part1.md02-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 . Chi tiết: context-optimization.md#glossary-extraction-algorithm.
_glossary.mdArticle dependencies: Embed 1-2 sentences in prompt, not separate file.
⚠️ 时机:在步骤3.1-3.3之后,步骤3.5之前执行。
策略:层级1/3 → 嵌入式术语表(约200-300字),直接嵌入提示中。层级2 → 生成初始术语表 → 上下文提取器生成。详情:context-optimization.md#glossary-extraction-algorithm。
_glossary.md文章依赖关系:将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.md3.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 , KHÔNG cần user confirmation
_plan.md- 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
undefinedMain 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:
- CONTEXT RULES - Đã embed trong prompt template, cấm subagent glob/read files thừa
- 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的内容:
- 上下文规则 - 已嵌入提示模板,禁止子Agent额外读取文件
- run_in_background: true - 用于并行撰写文章(≥3篇)。主Agent不会将完整对话记录加入上下文,仅在需要时检查输出文件。
python
undefinedParallel 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
undefinedundefined4.0c State Tracking (Recommended)
4.0c 状态跟踪(推荐)
For resume and retry support, create/update . Required if retry-workflow is needed (see retry-workflow.md):
analysis/_state.jsonjson
{
"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.
为支持恢复和重试,创建/更新。若需要重试工作流(查看retry-workflow.md),则必须使用该文件:
analysis/_state.jsonjson
{
"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 in main context:
00-overview.md- 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 , save vào
_plan.mdarticles/XX-{slug}.md - Mỗi article MUST end with "## Các bài viết trong series"
- Coverage tracking: main agent tự tạo sau khi viết xong tất cả
_coverage.md
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.mdarticles/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个部分
- Spawn 02-core-part1.md
- Wait for completion → extract context bridge
- Spawn 02-core-part2.md (with context from part1)
- Wait → extract context bridge
- Spawn 02-core-part3.md (with context from part2)
- 启动02-core-part1.md的子Agent
- 等待完成 → 提取上下文衔接内容
- 启动02-core-part2.md的子Agent(带入第一部分的上下文)
- 等待完成 → 提取上下文衔接内容
- 启动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} --stdinValidates all required template variables are present. Exit code 0 = PASS, 1 = missing variables.
Continuous Batching (preferred over static batching):
- Tier 1-2: (smaller chunks ~3.5K words)
max_concurrent = 3 - Tier 3: (larger chunks ~10K words)
max_concurrent = 2 - 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:(较小内容块~3500字)
max_concurrent = 3 - 层级3:(较大内容块~10000字)
max_concurrent = 2 - 动态调整:大内容块(>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: → SoT. → SoT. → SoT. Otherwise → standard write.
h3_count >= 5h3 == 0 AND h2 >= 5h3 + h2 >= 5Workflow: 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)。
快速判断: → 使用SoT模式。 → 使用SoT模式。 → 使用SoT模式。否则 → 标准撰写。
h3_count >=5h3 ==0 且 h2 >=5h3 + h2 >=5工作流:阶段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 () → Main agent enriches to 4-column () → Aggregate into . See §5.2 for aggregation.
Section | StatusSection | Assigned To | Used In | Status_coverage.mdIMPORTANT: 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 (4-column format, see Step 5.2).
_coverage.md重要提示:通过/失败仅依据章节覆盖率,与字数无关。字数仅作统计用。
子Agent返回格式(查看article-writer-prompt.md):
markdown
完成: {filename} | {N} 字
关键要点: 当有明确目标且每日行动时,活力会迸发
覆盖率:
| 章节 | 状态 |
|---------|--------|
| S01 | ✅ 引用 |
| S02 ⭐ | ✅ 忠实重写 |
结果: 通过
系列文章列表: 已添加
验证: "Vita Nova" (L21)通过/失败标准:
- 通过:所有分配的章节均已覆盖 或 因合理理由跳过(冗余、偏离主题、用户指令)
- 失败:存在未覆盖的章节 或 无合理理由跳过(无理由,或仅说明“太长”/“已覆盖”但无参考)
- 字数:仅作统计,不影响通过/失败判断
主Agent添加“分配文章”和“使用位置”列 → 汇总到(4列格式,查看步骤5.2)。
_coverage.md4.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 with actual content for placeholder sections.
00-overview.mdKHÔNG đọc lại articles. Dùng dữ liệu đã có:
python
undefined用实际内容更新中的占位符章节。
00-overview.md禁止重新读取文章。使用已有的数据:
python
undefinedNguồ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:
```markdownkey_takeaways = [] # 来自每个子Agent返回格式中的关键要点
series_list = [] # 来自步骤3的_plan.md(已包含标题+描述)
core_message = "" # 来自_plan.md的系列上下文
**多部分文章**:将同一文章各部分的关键要点合并为1个要点。例如:第02篇文章有3个部分 → 选择最具代表性的要点或合并为1句话。
**关键要点**(从各子Agent的关键要点组合):
```markdownĐiểm chính
关键要点
- [Concept từ article 1 KEY_TAKEAWAY]: [Expand từ takeaway]
- [Concept từ article 2 KEY_TAKEAWAY]: [Expand từ takeaway]
- [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篇文章关键要点的概念]: [扩展要点内容]
- [来自第2篇文章关键要点的概念]: [扩展要点内容]
- [来自第3篇文章关键要点的概念]: [扩展要点内容]
**系列文章列表**(从_plan.md组合):
```markdownCác bài viết trong series
系列文章列表
- Tổng quan - Brief description (đang xem)
- Article 1 Title - Brief description
- 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篇文章标题 - 简要描述
**最终概述目标字数**:400-600字(概述特殊,使用字数目标而非章节覆盖率)
**关键要点质量不佳的回退方案**:若关键要点过于通用或为空,使用文章标题+plan.md中的描述替代。禁止为改进要点而读取文章文件。5.2 Coverage Aggregation
5.2 覆盖率汇总
Collect subagent coverage tables → aggregate into
analysis/_coverage.mdProcess: Subagent returns 2-column () → Main agent enriches to 4-column () → Concatenate into → Add summary stats.
Section | StatusSection | Assigned To | Used In | Status_coverage.mdCoverage file format:
markdown
undefined收集子Agent返回的覆盖率表格 → 汇总到
analysis/_coverage.md流程:子Agent返回2列格式()→ 主Agent扩展为4列()→ 连接到 → 添加统计摘要。
章节 | 状态章节 | 分配文章 | 使用位置 | 状态_coverage.md覆盖率文件格式:
markdown
undefinedSection Coverage Matrix
章节覆盖率矩阵
| Section | Assigned To | Used In | Status |
|---|---|---|---|
| S01 | 01-article.md | 01-article.md | ✅ summarized |
| S02 ⭐ | 01-article.md | 01-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| 章节 | 分配文章 | 使用位置 | 状态 |
|---|---|---|---|
| S01 | 01-article.md | 01-article.md | ✅ 摘要 |
| S02 ⭐ | 01-article.md | 01-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.mdStep 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 supplementaryQUAN 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~600 words)
00-overview.md -
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返回)
-
概述已更新关键要点和系列文章列表(读取约600字)
00-overview.md -
所有系列文章列表: 已添加(来自返回内容,若未添加则补充)
-
系列列表中的所有链接已验证(在概述文件中)
-
已生成_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 . Khi cần cài thêm thư viện, PHẢI activate venv trước:
{SCRIPTS_DIR}/.venvbash
undefined该Skill使用位于的虚拟环境。需要安装新库时,必须先激活虚拟环境:
{SCRIPTS_DIR}/.venvbash
undefined1. 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>