refactor: 重组专员 spec 目录结构为按步骤分目录

- 扁平 config/ → 按步骤编号目录(00-global, 01-task_configuration, 02-topic_recommendation...)
- 每个步骤内聚包含 meta.json、prompt.md、validator.json、fallback.json、rule.json
- workflow.json 只保留编排(步骤 key + 顺序),步骤配置由各自目录提供
- 全局配置隔离在 00-global/(domains.json, policy.json)
- 统一文件命名:meta.json, prompt.md, validator.json, fallback.json, rule.json, form.json
- 新增 SKILL.md 作为技能描述入口
- 新增 remaining_steps.json 作为快速参考
This commit is contained in:
eaiadmin
2026-09-24 23:34:04 +08:00
parent 011f722999
commit d1a737d448
53 changed files with 647 additions and 445 deletions
@@ -1,5 +1,5 @@
{
"description": "业务域配置。每个业务域有对应的标签和默认配置。",
"description": "业务域配置。每个业务域有对应的图片标签、热点源和默认关键词。",
"version": "1.0.0",
"domains": {
"AI": {
@@ -39,4 +39,4 @@
"default_keywords": []
}
}
}
}
@@ -0,0 +1,17 @@
{
"description": "步骤 0:任务配置表单定义。",
"version": "1.0.0",
"step_key": "task_configuration",
"fields": [
{ "key": "business_domain", "label": "业务域", "type": "select", "required": true, "options": ["AI", "医疗", "保险", "HR", "法务", "通用"] },
{ "key": "keyword", "label": "关键词", "type": "text", "required": true },
{ "key": "audience", "label": "目标受众", "type": "text", "default": "公众号读者", "required": false },
{ "key": "goal", "label": "写作目标", "type": "text", "required": false },
{ "key": "tone", "label": "语调风格", "type": "select", "default": "专业但好懂", "options": ["专业但好懂", "轻松有趣", "严肃权威", "故事叙述", "数据驱动"] },
{ "key": "requirements", "label": "特殊要求", "type": "textarea", "required": false },
{ "key": "outline_style", "label": "提纲风格", "type": "select", "default": "问题拆解型", "options": ["问题拆解型", "对比分析型", "案例驱动型", "步骤教程型"] },
{ "key": "outline_words", "label": "提纲字数", "type": "number", "default": 800, "min": 300, "max": 2000, "required": false },
{ "key": "content_target_words", "label": "正文目标字数", "type": "number", "default": 1400, "min": 500, "max": 5000, "required": false },
{ "key": "max_content_images", "label": "最大配图数(可选,0 表示无上限)", "type": "number", "default": 0, "min": 0, "max": 20, "required": false }
]
}
@@ -0,0 +1,8 @@
{
"description": "步骤 1:选题推荐。",
"version": "1.0.0",
"step_key": "topic_recommendation",
"prompt_file": "prompt.md",
"has_validator": false,
"has_fallback": false
}
@@ -0,0 +1,15 @@
# Role
你是 `topic_recommendation` 步骤的执行者,负责为公众号文章推荐选题。
# Goal
基于业务域、关键词、受众和目标,生成 3 个高传播潜力的选题建议。
# 输出要求
- 每个选题包含:标题、推荐理由、热度评估(高/中/低)
- 标题要吸引点击,理由要说明为什么这个选题适合该业务域
- 输出为 JSON 数组
# 约束
- 选题必须与业务域和关键词相关
- 避免过于技术化或过于泛泛的内容
- 标题长度控制在 20 字以内
@@ -0,0 +1,6 @@
{
"description": "标题降级资产。当 LLM 生成失败时使用默认模板。",
"version": "1.0.0",
"step_key": "title_generation",
"fallback_template": "围绕{{keyword}},本文为你解读{style}。点击查看更多。"
}
@@ -0,0 +1,8 @@
{
"description": "步骤 2:标题生成。",
"version": "1.0.0",
"step_key": "title_generation",
"prompt_file": "prompt.md",
"has_validator": false,
"has_fallback": true
}
@@ -0,0 +1,15 @@
# Role
你是 `title_generation` 步骤的执行者,负责为公众号文章生成标题。
# Goal
基于选定的选题,生成 3 个风格不同的标题建议。
# 输出要求
- 偏点击型:吸引点击,适合新媒体
- 偏稳重:专业权威,适合行业媒体
- 偏平衡:兼顾点击与专业性
# 约束
- 标题长度 15-30 字
- 避免标题党
- 每个标题要有独特角度
@@ -0,0 +1,8 @@
{
"description": "步骤 3:提纲生成。",
"version": "1.0.0",
"step_key": "outline_generation",
"prompt_file": "prompt.md",
"has_validator": true,
"has_fallback": false
}
@@ -0,0 +1,19 @@
# Role
你是 `outline_generation` 步骤的执行者,负责为公众号文章生成提纲。
# Goal
基于选定标题,生成结构清晰的 Markdown 提纲。
# 输出要求
- 至少 3 个小节(## 标题)
- 每个小节至少 2 个要点
- 提纲总字数约 {{outline_words}} 字
# 提纲风格
- 风格:{{outline_style}}
- 受众:{{audience}}
# 约束
- 使用 Markdown 二级标题(##)标记小节
- 避免空泛标题,每个小节要有具体内容
- 提纲之间要有逻辑递进关系
@@ -0,0 +1,18 @@
{
"description": "提纲验证规则。",
"version": "1.0.0",
"step_key": "outline_generation",
"checks": [
"minimum_sections",
"bullet_count_per_section",
"word_count_budget",
"no_generic_titles"
],
"minimum_sections": 3,
"minimum_bullets_per_section": 2,
"word_budget": {
"target": 800,
"tolerance": 0.15
},
"generic_ban_patterns": ["^先用.+切入", "^明确本文主线", "^本文主要讲述"]
}
@@ -0,0 +1,8 @@
{
"description": "步骤 4:正文创作。",
"version": "1.0.0",
"step_key": "content_creation",
"prompt_file": "prompt.md",
"has_validator": true,
"has_fallback": false
}
@@ -0,0 +1,25 @@
# Role
你是 `content_creation` 步骤的执行者,负责为公众号文章生成正文。
# Goal
基于选定提纲,生成完整的公众号文章正文。
# 输入
- 标题:{{selected_title}}
- 提纲:{{outline}}
- 业务域:{{business_domain}}
- 目标受众:{{audience}}
- 语调风格:{{tone}}
- 正文目标字数:{{content_target_words}}
# 输出要求
- 使用 Markdown 格式
- 每个小节用 `##` 标题
- 正文要有实质性内容,避免空话
- 总字数接近 {{content_target_words}}
# 约束
- 内容必须与提纲一致
- 语调要与 {{tone}} 匹配
- 避免使用模板化语言
- 每个小节要有具体的论据或案例支撑
@@ -0,0 +1,15 @@
{
"description": "正文验证规则。",
"version": "1.0.0",
"step_key": "content_creation",
"checks": [
"minimum_word_count",
"section_structure",
"no_empty_sections"
],
"minimum_word_count": 800,
"section_structure": {
"require_h2_headers": true,
"min_sections": 3
}
}
@@ -0,0 +1,8 @@
{
"description": "步骤 5:配图提示词。",
"version": "1.0.0",
"step_key": "image_prompt_generation",
"prompt_file": "prompt.md",
"has_validator": true,
"has_rule": true
}
@@ -1,5 +1,5 @@
# Role
你是 `image_prompt_generate` 步骤的执行者,负责为公众号文章生成配图提示词。
你是 `image_prompt_generation` 步骤的执行者,负责为公众号文章生成配图提示词。
# Goal
基于正文内容,按字数分布规则生成配图提示词,并将提示词以括号标记格式嵌入正文。
@@ -21,7 +21,7 @@
}
},
"prompt_template": {
"description": "配图提示词模板。{index} 为序号(从 1 开始),{section_title} 为小节标题,{section_summary} 为段落摘要(截断至 120 字)。",
"description": "配图提示词模板。{index} 为序号(从 1 开始),{section_summary} 为段落摘要(截断至 120 字)。",
"format": "chinese",
"min_chars": 40,
"max_chars": 70,
@@ -31,24 +31,5 @@
"description": "配图提示词在正文中的嵌入格式。",
"cover": "[TITLE_PIC: {prompt}, size: {size}]",
"content": "[section_{{index:02d}}: {prompt}, size: {size}]"
},
"validation": {
"checks": [
"section_mapping_completeness",
"required_visual_elements",
"prompt_length",
"no_forbidden_elements"
],
"required_elements": {
"subject": true,
"scene": true,
"lighting": true
},
"forbidden_elements": [
"text_overlay",
"collage_style"
],
"retry_max": 2,
"retry_feedback_template": "配图提示词校验失败:{failed_checks}。请重新生成全部提示词并修复问题,保持段落映射不变。"
}
}
}
@@ -1,7 +1,7 @@
{
"description": "配图提示词验证规则。",
"version": "1.0.0",
"step_id": "image_prompt_generation",
"step_key": "image_prompt_generation",
"checks": [
"section_mapping_completeness",
"required_visual_elements",
@@ -10,7 +10,6 @@
"bracket_format_valid"
],
"section_mapping": {
"description": "配图提示词与正文段落的映射必须完整。",
"cover_required": true,
"content_images_required": true
},
@@ -24,9 +23,9 @@
"count_mode": "chinese_characters"
},
"bracket_format": {
"cover_pattern": "^\\[TITLE_PIC: .* size: landscape_16_9\\]$",
"content_pattern": "^\\[section_\\d{2}: .* size: landscape_4_3\\]$"
"cover_pattern": "^\\\\[TITLE_PIC: .* size: landscape_16_9\\\\]$",
"content_pattern": "^\\\\[section_\\\\d{2}: .* size: landscape_4_3\\\\]$"
},
"retry_feedback_template": "配图提示词校验失败:{failed_checks}。请重新生成全部提示词并修复问题。",
"retry_max": 2
}
}
@@ -0,0 +1,10 @@
# Role
你是 `image_generation` 步骤的执行者,负责为公众号文章生成配图。
# Goal
基于配图提示词,调用外部图片生成 API 生成配图。
# 输出要求
- 封面图:16:9 横图
- 段落配图:4:3 横图
- 每个配图返回 URL 和元数据
@@ -0,0 +1,10 @@
# Role
你是 `preview_export` 步骤的执行者,负责生成预览稿。
# Goal
基于正文和图片,生成预览 MD、预览 HTML 和分页 MD 内容。
# 输出要求
- 预览 MD:Markdown 格式
- 预览 HTML:HTML 格式
- 分页 MD:带图片尺寸标注的分页 Markdown
@@ -0,0 +1,10 @@
# Role
你是 `page_markdown` 步骤的执行者,负责生成分页 Markdown。
# Goal
基于预览稿,生成适合公众号排版的分页 Markdown 文件。
# 输出要求
- 每页内容以 `<!-- PAGE N: 标题 -->` 分隔
- 分页之间用 `---` 分隔
- 图片使用 Markdown 格式引用,包含 alt 文字
@@ -0,0 +1,93 @@
# 公众号创作专员 - 规范定义
> 这是 pj0235 的第一个"配置驱动"专员样板。参考 pj0012 的 JSON 配置体系设计。
## 目录结构
```
spec/
├── SKILL.md # 技能描述(全局,不嵌入)
├── workflow.json # 工作流编排(步骤 key + 顺序 + 前置依赖)
├── remaining_steps.json # 快速参考(步骤 → 文件映射)
│
├── 00-global/ # 全局配置(跨步骤共享)
│ ├── domains.json # 业务域配置
│ └── policy.json # 重试/降级策略
│
├── 01-task_configuration/ # 步骤 0:任务配置
│ └── form.json # 表单字段定义
│
├── 02-topic_recommendation/ # 步骤 1:选题推荐
│ ├── meta.json # 步骤元信息
│ └── prompt.md # 提示词模板
│
├── 03-title_generation/ # 步骤 2:标题生成
│ ├── meta.json
│ ├── prompt.md
│ └── fallback.json # 降级资产
│
├── 04-outline_generation/ # 步骤 3:提纲生成
│ ├── meta.json
│ ├── prompt.md
│ └── validator.json # 验证规则
│
├── 05-content_creation/ # 步骤 4:正文创作
│ ├── meta.json
│ ├── prompt.md
│ └── validator.json
│
├── 06-image_prompt_generation/ # 步骤 5:配图提示词
│ ├── meta.json
│ ├── prompt.md
│ ├── rule.json # 配图规则(分布、模板、格式)
│ └── validator.json
│
├── 07-image_generation/ # 步骤 6:图片生成
│ └── prompt.md
│
├── 08-preview_export/ # 步骤 7:预览导出
│ └── prompt.md
│
└── 09-page_markdown/ # 步骤 8:分页 Markdown
└── prompt.md
```
## 设计原则
1. **每个步骤一个目录**:配置完全内聚,新增/修改步骤只动一个目录
2. **编号前缀**:文件名按数字排序即执行顺序
3. **统一命名**:`meta.json`、`prompt.md`、`validator.json`、`fallback.json`、`rule.json`
4. **全局配置隔离**:`00-global/` 放跨步骤共享的配置
5. **workflow.json 只保留编排**:步骤配置由各自目录提供
## 文件说明
| 文件 | 说明 | 是否必需 |
|------|------|---------|
| `meta.json` | 步骤元信息(step_key、版本号、依赖文件列表) | 是 |
| `prompt.md` | LLM 提示词模板(YAML 变量注入) | 是 |
| `validator.json` | 验证规则(检查清单、质量规则) | 否 |
| `fallback.json` | 降级资产(LLM 失败时的回退内容) | 否 |
| `rule.json` | 业务规则(仅用于配图提示词这类规则密集型步骤) | 否 |
| `form.json` | 表单字段定义(仅用于任务配置步骤) | 否 |
## 配图规则(核心示例)
配图提示词规则在 `06-image_prompt_generation/rule.json` 中定义,包括:
- 分布规则:封面图 + 每 500 字 1 张
- 提示词模板:中文模板 + 最小/最大字数
- 括号标记格式:`[TITLE_PIC: 提示词, size: landscape_16_9]`
- 验证规则:主体/场景/光线必填,文字覆盖/拼贴禁用
## 使用方式
Go 代码通过 `embed.FS` 嵌入所有 JSON/Markdown 文件,运行时:
1. 读取 JSON 配置 → 获取业务规则
2. 读取 prompt 模板 → 注入运行时参数 → 组装最终 prompt
3. 读取验证器 → 执行验证逻辑
4. 读取策略 → 控制重试/降级循环
## 如何参考
完整的学习分析见:`../../../../reference/pj0012-wechat-image-spec.md`
@@ -13,19 +13,19 @@
- 关键词驱动的通用文章生成
- 多业务域(AI/医疗/保险/HR/法务/通用)适配
## 工作流步骤
## 工作流
| 序号 | Step Key | 标签 | 前置条件 | 输出 |
|------|----------|------|----------|------|
| 0 | task_configuration | 任务配置 | — | 业务域、关键词、受众、语调等表单参数 |
| 1 | topic_recommendation | 选题推荐 | 配置完成 | 3 个选题建议(标题 + 理由 + 热度) |
| 2 | title_generation | 标题生成 | 有选题 | 3 个标题建议(偏点击/偏稳重/偏平衡) |
| 3 | outline_generation | 提纲生成 | 有标题 | Markdown 提纲结构 |
| 4 | content_creation | 正文创作 | 有提纲 | Markdown 正文(含 ## 小节标题) |
| 5 | image_prompt_generation | 配图提示词 | 有正文 | 配图提示词 + 带标记正文 |
| 6 | image_generation | 图片生成 | 有配图提示词 | 封面图 + 段落图 |
| 7 | preview_export | 预览导出 | 有正文 + 图片 | 预览 MD + 预览 HTML |
| 8 | page_markdown | 分页 Markdown | 有预览稿 | 分页 MD(含图片尺寸标注) |
| 编号 | Step Key | 标签 | 前置条件 |
|------|----------|------|----------|
| 0 | task_configuration | 任务配置 | — |
| 1 | topic_recommendation | 选题推荐 | 配置完成 |
| 2 | title_generation | 标题生成 | 有选题 |
| 3 | outline_generation | 提纲生成 | 有标题 |
| 4 | content_creation | 正文创作 | 有提纲 |
| 5 | image_prompt_generation | 配图提示词 | 有正文 |
| 6 | image_generation | 图片生成 | 有配图提示词 |
| 7 | preview_export | 预览导出 | 有正文 + 图片 |
| 8 | page_markdown | 分页 Markdown | 有预览稿 |
## 配图规则
@@ -34,7 +34,6 @@
2. 从正文开头累计字数,每 500 字生成 1 张配图
3. 每张配图放在其所属小节(##)的**开始处**
4. 如果某节很长(>500 字),则该节内按 500 字间隔插入多张
5. 如果某节不足 500 字,与下节合并累计,但不跨节重复
### 提示词模板
```
@@ -47,16 +46,12 @@
[section_01: 提示词, size: landscape_4_3]
```
## 业务域
AI、医疗、保险、HR、法务、通用
## 重试策略
- 热点抓取:最多 1 次重试
- 选题推荐:最多 1 次重试
- 标题/提纲/正文/配图:最多 2 次重试
- 预览/分页:0 次重试
- 图片生成/预览/分页:0 次重试
## 验证规则
- 提纲:至少 3 个小节,每小节至少 2 个要点
- 正文:至少 800 字,每个小节有实质性内容
- 配图提示词:段落数 = 提示词数,每个提示词 40-70 字,必须包含主体/场景/光线
- 配图提示词:段落数 = 提示词数,每个提示词 40-70 字
@@ -1,157 +0,0 @@
{
"description": "公众号创作工作流步骤定义。步骤按顺序执行,前一步骤完成方可进入下一步骤。",
"version": "1.0.0",
"steps": [
{
"key": "task_configuration",
"label": "任务配置",
"type": "form",
"order": 0,
"is_entry_point": true,
"description": "配置业务域、关键词、受众、语调等参数。"
},
{
"key": "topic_recommendation",
"label": "选题推荐",
"type": "ai",
"order": 1,
"preconditions": ["task_configuration"],
"description": "基于业务域和关键词生成 3 个选题建议。"
},
{
"key": "title_generation",
"label": "标题生成",
"type": "ai",
"order": 2,
"preconditions": ["topic_recommendation"],
"description": "基于选定选题生成 3 个标题建议(偏点击/偏稳重/偏平衡)。"
},
{
"key": "outline_generation",
"label": "提纲生成",
"type": "ai",
"order": 3,
"preconditions": ["title_generation"],
"description": "基于选定标题生成 Markdown 提纲结构。"
},
{
"key": "content_creation",
"label": "正文创作",
"type": "ai",
"order": 4,
"preconditions": ["outline_generation"],
"description": "基于选定提纲和配置参数生成正文。"
},
{
"key": "image_prompt_generation",
"label": "配图提示词",
"type": "ai",
"order": 5,
"preconditions": ["content_creation"],
"description": "基于正文按字数分布生成配图提示词,并嵌入带标记正文。"
},
{
"key": "image_generation",
"label": "图片生成",
"type": "external",
"order": 6,
"preconditions": ["image_prompt_generation"],
"description": "基于配图提示词调用外部图片生成 API。"
},
{
"key": "preview_export",
"label": "预览导出",
"type": "render",
"order": 7,
"preconditions": ["content_creation", "image_generation"],
"description": "生成预览 MD、预览 HTML 和分页 MD。"
},
{
"key": "page_markdown",
"label": "分页 Markdown",
"type": "render",
"order": 8,
"preconditions": ["preview_export"],
"description": "生成带图片尺寸标注的分页 Markdown。"
}
],
"forms": {
"task_configuration": {
"fields": [
{
"key": "business_domain",
"label": "业务域",
"type": "select",
"required": true,
"options": ["AI", "医疗", "保险", "HR", "法务", "通用"]
},
{
"key": "keyword",
"label": "关键词",
"type": "text",
"required": true
},
{
"key": "audience",
"label": "目标受众",
"type": "text",
"default": "公众号读者",
"required": false
},
{
"key": "goal",
"label": "写作目标",
"type": "text",
"required": false
},
{
"key": "tone",
"label": "语调风格",
"type": "select",
"default": "专业但好懂",
"options": ["专业但好懂", "轻松有趣", "严肃权威", "故事叙述", "数据驱动"]
},
{
"key": "requirements",
"label": "特殊要求",
"type": "textarea",
"required": false
},
{
"key": "outline_style",
"label": "提纲风格",
"type": "select",
"default": "问题拆解型",
"options": ["问题拆解型", "对比分析型", "案例驱动型", "步骤教程型"]
},
{
"key": "outline_words",
"label": "提纲字数",
"type": "number",
"default": 800,
"min": 300,
"max": 2000,
"required": false
},
{
"key": "content_target_words",
"label": "正文目标字数",
"type": "number",
"default": 1400,
"min": 500,
"max": 5000,
"required": false
},
{
"key": "max_content_images",
"label": "最大配图数(可选,0 表示无上限)",
"type": "number",
"default": 0,
"min": 0,
"max": 20,
"required": false
}
]
}
}
}
@@ -0,0 +1,5 @@
[
{"step_key": "image_generation", "prompt_file": "prompt.md"},
{"step_key": "preview_export", "prompt_file": "prompt.md"},
{"step_key": "page_markdown", "prompt_file": "prompt.md"}
]
@@ -0,0 +1,15 @@
{
"description": "工作流编排。按编号顺序执行,每步的 prompt/validator/fallback 在各自步骤目录中。",
"version": "1.0.0",
"steps": [
{ "key": "task_configuration", "label": "任务配置", "type": "form", "order": 0, "is_entry_point": true },
{ "key": "topic_recommendation", "label": "选题推荐", "type": "ai", "order": 1, "preconditions": ["task_configuration"] },
{ "key": "title_generation", "label": "标题生成", "type": "ai", "order": 2, "preconditions": ["topic_recommendation"] },
{ "key": "outline_generation", "label": "提纲生成", "type": "ai", "order": 3, "preconditions": ["title_generation"] },
{ "key": "content_creation", "label": "正文创作", "type": "ai", "order": 4, "preconditions": ["outline_generation"] },
{ "key": "image_prompt_generation", "label": "配图提示词", "type": "ai", "order": 5, "preconditions": ["content_creation"] },
{ "key": "image_generation", "label": "图片生成", "type": "external", "order": 6, "preconditions": ["image_prompt_generation"] },
{ "key": "preview_export", "label": "预览导出", "type": "render", "order": 7, "preconditions": ["content_creation", "image_generation"] },
{ "key": "page_markdown", "label": "分页 Markdown", "type": "render", "order": 8, "preconditions": ["preview_export"] }
]
}
@@ -7,7 +7,7 @@ import (
"strings"
)
//go:embed spec/config/*.json spec/config/validators/*.json spec/config/prompts/*.md
//go:embed spec/*.json spec/*/*.json spec/*/*.md
var specConfigFS embed.FS
// imagePromptConfig 从 JSON 配置文件读取的配图提示词规则。
@@ -81,7 +81,7 @@ func init() {
// loadWeixinPublicAccountImagePromptConfig 从嵌入的 spec 目录加载 JSON 配置。
func loadWeixinPublicAccountImagePromptConfig() *imagePromptConfig {
data, err := specConfigFS.ReadFile("spec/config/image_prompt.json")
data, err := specConfigFS.ReadFile("spec/06-image_prompt_generation/rule.json")
if err != nil {
// 如果 spec 目录不存在或配置缺失,回退到内联默认配置
return defaultImagePromptConfig()
@@ -1,5 +1,5 @@
{
"description": "业务域配置。每个业务域有对应的标签和默认配置。",
"description": "业务域配置。每个业务域有对应的图片标签、热点源和默认关键词。",
"version": "1.0.0",
"domains": {
"AI": {
@@ -39,4 +39,4 @@
"default_keywords": []
}
}
}
}
@@ -0,0 +1,17 @@
{
"description": "步骤 0:任务配置表单定义。",
"version": "1.0.0",
"step_key": "task_configuration",
"fields": [
{ "key": "business_domain", "label": "业务域", "type": "select", "required": true, "options": ["AI", "医疗", "保险", "HR", "法务", "通用"] },
{ "key": "keyword", "label": "关键词", "type": "text", "required": true },
{ "key": "audience", "label": "目标受众", "type": "text", "default": "公众号读者", "required": false },
{ "key": "goal", "label": "写作目标", "type": "text", "required": false },
{ "key": "tone", "label": "语调风格", "type": "select", "default": "专业但好懂", "options": ["专业但好懂", "轻松有趣", "严肃权威", "故事叙述", "数据驱动"] },
{ "key": "requirements", "label": "特殊要求", "type": "textarea", "required": false },
{ "key": "outline_style", "label": "提纲风格", "type": "select", "default": "问题拆解型", "options": ["问题拆解型", "对比分析型", "案例驱动型", "步骤教程型"] },
{ "key": "outline_words", "label": "提纲字数", "type": "number", "default": 800, "min": 300, "max": 2000, "required": false },
{ "key": "content_target_words", "label": "正文目标字数", "type": "number", "default": 1400, "min": 500, "max": 5000, "required": false },
{ "key": "max_content_images", "label": "最大配图数(可选,0 表示无上限)", "type": "number", "default": 0, "min": 0, "max": 20, "required": false }
]
}
@@ -0,0 +1,8 @@
{
"description": "步骤 1:选题推荐。",
"version": "1.0.0",
"step_key": "topic_recommendation",
"prompt_file": "prompt.md",
"has_validator": false,
"has_fallback": false
}
@@ -0,0 +1,15 @@
# Role
你是 `topic_recommendation` 步骤的执行者,负责为公众号文章推荐选题。
# Goal
基于业务域、关键词、受众和目标,生成 3 个高传播潜力的选题建议。
# 输出要求
- 每个选题包含:标题、推荐理由、热度评估(高/中/低)
- 标题要吸引点击,理由要说明为什么这个选题适合该业务域
- 输出为 JSON 数组
# 约束
- 选题必须与业务域和关键词相关
- 避免过于技术化或过于泛泛的内容
- 标题长度控制在 20 字以内
@@ -0,0 +1,6 @@
{
"description": "标题降级资产。当 LLM 生成失败时使用默认模板。",
"version": "1.0.0",
"step_key": "title_generation",
"fallback_template": "围绕{{keyword}},本文为你解读{style}。点击查看更多。"
}
@@ -0,0 +1,8 @@
{
"description": "步骤 2:标题生成。",
"version": "1.0.0",
"step_key": "title_generation",
"prompt_file": "prompt.md",
"has_validator": false,
"has_fallback": true
}
@@ -0,0 +1,15 @@
# Role
你是 `title_generation` 步骤的执行者,负责为公众号文章生成标题。
# Goal
基于选定的选题,生成 3 个风格不同的标题建议。
# 输出要求
- 偏点击型:吸引点击,适合新媒体
- 偏稳重:专业权威,适合行业媒体
- 偏平衡:兼顾点击与专业性
# 约束
- 标题长度 15-30 字
- 避免标题党
- 每个标题要有独特角度
@@ -0,0 +1,8 @@
{
"description": "步骤 3:提纲生成。",
"version": "1.0.0",
"step_key": "outline_generation",
"prompt_file": "prompt.md",
"has_validator": true,
"has_fallback": false
}
@@ -0,0 +1,19 @@
# Role
你是 `outline_generation` 步骤的执行者,负责为公众号文章生成提纲。
# Goal
基于选定标题,生成结构清晰的 Markdown 提纲。
# 输出要求
- 至少 3 个小节(## 标题)
- 每个小节至少 2 个要点
- 提纲总字数约 {{outline_words}} 字
# 提纲风格
- 风格:{{outline_style}}
- 受众:{{audience}}
# 约束
- 使用 Markdown 二级标题(##)标记小节
- 避免空泛标题,每个小节要有具体内容
- 提纲之间要有逻辑递进关系
@@ -0,0 +1,18 @@
{
"description": "提纲验证规则。",
"version": "1.0.0",
"step_key": "outline_generation",
"checks": [
"minimum_sections",
"bullet_count_per_section",
"word_count_budget",
"no_generic_titles"
],
"minimum_sections": 3,
"minimum_bullets_per_section": 2,
"word_budget": {
"target": 800,
"tolerance": 0.15
},
"generic_ban_patterns": ["^先用.+切入", "^明确本文主线", "^本文主要讲述"]
}
@@ -0,0 +1,8 @@
{
"description": "步骤 4:正文创作。",
"version": "1.0.0",
"step_key": "content_creation",
"prompt_file": "prompt.md",
"has_validator": true,
"has_fallback": false
}
@@ -0,0 +1,25 @@
# Role
你是 `content_creation` 步骤的执行者,负责为公众号文章生成正文。
# Goal
基于选定提纲,生成完整的公众号文章正文。
# 输入
- 标题:{{selected_title}}
- 提纲:{{outline}}
- 业务域:{{business_domain}}
- 目标受众:{{audience}}
- 语调风格:{{tone}}
- 正文目标字数:{{content_target_words}}
# 输出要求
- 使用 Markdown 格式
- 每个小节用 `##` 标题
- 正文要有实质性内容,避免空话
- 总字数接近 {{content_target_words}}
# 约束
- 内容必须与提纲一致
- 语调要与 {{tone}} 匹配
- 避免使用模板化语言
- 每个小节要有具体的论据或案例支撑
@@ -0,0 +1,15 @@
{
"description": "正文验证规则。",
"version": "1.0.0",
"step_key": "content_creation",
"checks": [
"minimum_word_count",
"section_structure",
"no_empty_sections"
],
"minimum_word_count": 800,
"section_structure": {
"require_h2_headers": true,
"min_sections": 3
}
}
@@ -0,0 +1,8 @@
{
"description": "步骤 5:配图提示词。",
"version": "1.0.0",
"step_key": "image_prompt_generation",
"prompt_file": "prompt.md",
"has_validator": true,
"has_rule": true
}
@@ -1,5 +1,5 @@
# Role
你是 `image_prompt_generate` 步骤的执行者,负责为公众号文章生成配图提示词。
你是 `image_prompt_generation` 步骤的执行者,负责为公众号文章生成配图提示词。
# Goal
基于正文内容,按字数分布规则生成配图提示词,并将提示词以括号标记格式嵌入正文。
@@ -21,7 +21,7 @@
}
},
"prompt_template": {
"description": "配图提示词模板。{index} 为序号(从 1 开始),{section_title} 为小节标题,{section_summary} 为段落摘要(截断至 120 字)。",
"description": "配图提示词模板。{index} 为序号(从 1 开始),{section_summary} 为段落摘要(截断至 120 字)。",
"format": "chinese",
"min_chars": 40,
"max_chars": 70,
@@ -31,24 +31,5 @@
"description": "配图提示词在正文中的嵌入格式。",
"cover": "[TITLE_PIC: {prompt}, size: {size}]",
"content": "[section_{{index:02d}}: {prompt}, size: {size}]"
},
"validation": {
"checks": [
"section_mapping_completeness",
"required_visual_elements",
"prompt_length",
"no_forbidden_elements"
],
"required_elements": {
"subject": true,
"scene": true,
"lighting": true
},
"forbidden_elements": [
"text_overlay",
"collage_style"
],
"retry_max": 2,
"retry_feedback_template": "配图提示词校验失败:{failed_checks}。请重新生成全部提示词并修复问题,保持段落映射不变。"
}
}
}
@@ -1,7 +1,7 @@
{
"description": "配图提示词验证规则。",
"version": "1.0.0",
"step_id": "image_prompt_generation",
"step_key": "image_prompt_generation",
"checks": [
"section_mapping_completeness",
"required_visual_elements",
@@ -10,7 +10,6 @@
"bracket_format_valid"
],
"section_mapping": {
"description": "配图提示词与正文段落的映射必须完整。",
"cover_required": true,
"content_images_required": true
},
@@ -24,9 +23,9 @@
"count_mode": "chinese_characters"
},
"bracket_format": {
"cover_pattern": "^\\[TITLE_PIC: .* size: landscape_16_9\\]$",
"content_pattern": "^\\[section_\\d{2}: .* size: landscape_4_3\\]$"
"cover_pattern": "^\\\\[TITLE_PIC: .* size: landscape_16_9\\\\]$",
"content_pattern": "^\\\\[section_\\\\d{2}: .* size: landscape_4_3\\\\]$"
},
"retry_feedback_template": "配图提示词校验失败:{failed_checks}。请重新生成全部提示词并修复问题。",
"retry_max": 2
}
}
@@ -0,0 +1,10 @@
# Role
你是 `image_generation` 步骤的执行者,负责为公众号文章生成配图。
# Goal
基于配图提示词,调用外部图片生成 API 生成配图。
# 输出要求
- 封面图:16:9 横图
- 段落配图:4:3 横图
- 每个配图返回 URL 和元数据
@@ -0,0 +1,10 @@
# Role
你是 `preview_export` 步骤的执行者,负责生成预览稿。
# Goal
基于正文和图片,生成预览 MD、预览 HTML 和分页 MD 内容。
# 输出要求
- 预览 MD:Markdown 格式
- 预览 HTML:HTML 格式
- 分页 MD:带图片尺寸标注的分页 Markdown
@@ -0,0 +1,10 @@
# Role
你是 `page_markdown` 步骤的执行者,负责生成分页 Markdown。
# Goal
基于预览稿,生成适合公众号排版的分页 Markdown 文件。
# 输出要求
- 每页内容以 `<!-- PAGE N: 标题 -->` 分隔
- 分页之间用 `---` 分隔
- 图片使用 Markdown 格式引用,包含 alt 文字
@@ -6,55 +6,88 @@
```
spec/
├── config/
│ ├── skill.md # 技能描述 + 执行策略(人可读 + LLM 可读)
│ ├── workflow.json # 工作流步骤定义(步骤 key、标签、前置条件、表单)
│ ├── image_prompt.json # 配图提示词规则(分布、模板、验证)
│ ├── domains.json # 业务域配置
│ └── policy.json # 重试和降级策略
├── config/prompts/
│ └── image_prompt_generate.prompt.md # 配图提示词生成 prompt 模板
├── config/validators/
│ └── image_prompt.json # 配图提示词验证规则
└── README.md
├── SKILL.md # 技能描述(全局,不嵌入)
├── workflow.json # 工作流编排(步骤 key + 顺序 + 前置依赖)
├── remaining_steps.json # 快速参考(步骤 → 文件映射)
│
├── 00-global/ # 全局配置(跨步骤共享)
│ ├── domains.json # 业务域配置
│ └── policy.json # 重试/降级策略
│
├── 01-task_configuration/ # 步骤 0:任务配置
│ └── form.json # 表单字段定义
│
├── 02-topic_recommendation/ # 步骤 1:选题推荐
│ ├── meta.json # 步骤元信息
│ └── prompt.md # 提示词模板
│
├── 03-title_generation/ # 步骤 2:标题生成
│ ├── meta.json
│ ├── prompt.md
│ └── fallback.json # 降级资产
│
├── 04-outline_generation/ # 步骤 3:提纲生成
│ ├── meta.json
│ ├── prompt.md
│ └── validator.json # 验证规则
│
├── 05-content_creation/ # 步骤 4:正文创作
│ ├── meta.json
│ ├── prompt.md
│ └── validator.json
│
├── 06-image_prompt_generation/ # 步骤 5:配图提示词
│ ├── meta.json
│ ├── prompt.md
│ ├── rule.json # 配图规则(分布、模板、格式)
│ └── validator.json
│
├── 07-image_generation/ # 步骤 6:图片生成
│ └── prompt.md
│
├── 08-preview_export/ # 步骤 7:预览导出
│ └── prompt.md
│
└── 09-page_markdown/ # 步骤 8:分页 Markdown
└── prompt.md
```
## 设计原则
1. **三层分离**:
- `skill.md` — 技能描述层(人可读 + LLM 可读)
- `*.json` — 数据配置层(机器可读,热更新)
- `*.prompt.md` — 提示词模板层(YAML 变量注入)
1. **每个步骤一个目录**:配置完全内聚,新增/修改步骤只动一个目录
2. **编号前缀**:文件名按数字排序即执行顺序
3. **统一命名**:`meta.json`、`prompt.md`、`validator.json`、`fallback.json`、`rule.json`
4. **全局配置隔离**:`00-global/` 放跨步骤共享的配置
5. **workflow.json 只保留编排**:步骤配置由各自目录提供
2. **代码是运行时适配器**:
- 按路径读取 JSON/文本
- 将运行时参数注入模板
- 执行验证器逻辑
- 控制重试/降级循环
- 调用 LLM
## 文件说明
3. **不硬编码业务内容**:
- 业务规则变更通过修改 JSON/Markdown 实现
- 代码层只做通用适配
| 文件 | 说明 | 是否必需 |
|------|------|---------|
| `meta.json` | 步骤元信息(step_key、版本号、依赖文件列表) | 是 |
| `prompt.md` | LLM 提示词模板(YAML 变量注入) | 是 |
| `validator.json` | 验证规则(检查清单、质量规则) | 否 |
| `fallback.json` | 降级资产(LLM 失败时的回退内容) | 否 |
| `rule.json` | 业务规则(仅用于配图提示词这类规则密集型步骤) | 否 |
| `form.json` | 表单字段定义(仅用于任务配置步骤) | 否 |
## 配图规则(核心示例)
配图提示词规则完全外置在 `image_prompt.json` 中,包括:
配图提示词规则在 `06-image_prompt_generation/rule.json` 中定义,包括:
- 分布规则:封面图 + 每 500 字 1 张
- 提示词模板:中文模板 + 最小/最大字数
- 括号标记格式:`[TITLE_PIC: 提示词, size: landscape_16_9]`
- 验证规则:主体/场景/光线必填,文字覆盖/拼贴禁用
- 重试策略:最多 2 次
## 如何参考
完整的学习分析见:`../../../../reference/pj0012-wechat-image-spec.md`
## 使用方式
Go 代码通过 `embed.FS` 嵌入这些文件,运行时:
Go 代码通过 `embed.FS` 嵌入所有 JSON/Markdown 文件,运行时:
1. 读取 JSON 配置 → 获取业务规则
2. 读取 prompt 模板 → 注入运行时参数 → 组装最终 prompt
3. 读取验证器 → 执行验证逻辑
4. 读取策略 → 控制重试/降级循环
## 如何参考
完整的学习分析见:`../../../../reference/pj0012-wechat-image-spec.md`
@@ -13,19 +13,19 @@
- 关键词驱动的通用文章生成
- 多业务域(AI/医疗/保险/HR/法务/通用)适配
## 工作流步骤
## 工作流
| 序号 | Step Key | 标签 | 前置条件 | 输出 |
|------|----------|------|----------|------|
| 0 | task_configuration | 任务配置 | — | 业务域、关键词、受众、语调等表单参数 |
| 1 | topic_recommendation | 选题推荐 | 配置完成 | 3 个选题建议(标题 + 理由 + 热度) |
| 2 | title_generation | 标题生成 | 有选题 | 3 个标题建议(偏点击/偏稳重/偏平衡) |
| 3 | outline_generation | 提纲生成 | 有标题 | Markdown 提纲结构 |
| 4 | content_creation | 正文创作 | 有提纲 | Markdown 正文(含 ## 小节标题) |
| 5 | image_prompt_generation | 配图提示词 | 有正文 | 配图提示词 + 带标记正文 |
| 6 | image_generation | 图片生成 | 有配图提示词 | 封面图 + 段落图 |
| 7 | preview_export | 预览导出 | 有正文 + 图片 | 预览 MD + 预览 HTML |
| 8 | page_markdown | 分页 Markdown | 有预览稿 | 分页 MD(含图片尺寸标注) |
| 编号 | Step Key | 标签 | 前置条件 |
|------|----------|------|----------|
| 0 | task_configuration | 任务配置 | — |
| 1 | topic_recommendation | 选题推荐 | 配置完成 |
| 2 | title_generation | 标题生成 | 有选题 |
| 3 | outline_generation | 提纲生成 | 有标题 |
| 4 | content_creation | 正文创作 | 有提纲 |
| 5 | image_prompt_generation | 配图提示词 | 有正文 |
| 6 | image_generation | 图片生成 | 有配图提示词 |
| 7 | preview_export | 预览导出 | 有正文 + 图片 |
| 8 | page_markdown | 分页 Markdown | 有预览稿 |
## 配图规则
@@ -34,7 +34,6 @@
2. 从正文开头累计字数,每 500 字生成 1 张配图
3. 每张配图放在其所属小节(##)的**开始处**
4. 如果某节很长(>500 字),则该节内按 500 字间隔插入多张
5. 如果某节不足 500 字,与下节合并累计,但不跨节重复
### 提示词模板
```
@@ -47,16 +46,12 @@
[section_01: 提示词, size: landscape_4_3]
```
## 业务域
AI、医疗、保险、HR、法务、通用
## 重试策略
- 热点抓取:最多 1 次重试
- 选题推荐:最多 1 次重试
- 标题/提纲/正文/配图:最多 2 次重试
- 预览/分页:0 次重试
- 图片生成/预览/分页:0 次重试
## 验证规则
- 提纲:至少 3 个小节,每小节至少 2 个要点
- 正文:至少 800 字,每个小节有实质性内容
- 配图提示词:段落数 = 提示词数,每个提示词 40-70 字,必须包含主体/场景/光线
- 配图提示词:段落数 = 提示词数,每个提示词 40-70 字
@@ -1,157 +0,0 @@
{
"description": "公众号创作工作流步骤定义。步骤按顺序执行,前一步骤完成方可进入下一步骤。",
"version": "1.0.0",
"steps": [
{
"key": "task_configuration",
"label": "任务配置",
"type": "form",
"order": 0,
"is_entry_point": true,
"description": "配置业务域、关键词、受众、语调等参数。"
},
{
"key": "topic_recommendation",
"label": "选题推荐",
"type": "ai",
"order": 1,
"preconditions": ["task_configuration"],
"description": "基于业务域和关键词生成 3 个选题建议。"
},
{
"key": "title_generation",
"label": "标题生成",
"type": "ai",
"order": 2,
"preconditions": ["topic_recommendation"],
"description": "基于选定选题生成 3 个标题建议(偏点击/偏稳重/偏平衡)。"
},
{
"key": "outline_generation",
"label": "提纲生成",
"type": "ai",
"order": 3,
"preconditions": ["title_generation"],
"description": "基于选定标题生成 Markdown 提纲结构。"
},
{
"key": "content_creation",
"label": "正文创作",
"type": "ai",
"order": 4,
"preconditions": ["outline_generation"],
"description": "基于选定提纲和配置参数生成正文。"
},
{
"key": "image_prompt_generation",
"label": "配图提示词",
"type": "ai",
"order": 5,
"preconditions": ["content_creation"],
"description": "基于正文按字数分布生成配图提示词,并嵌入带标记正文。"
},
{
"key": "image_generation",
"label": "图片生成",
"type": "external",
"order": 6,
"preconditions": ["image_prompt_generation"],
"description": "基于配图提示词调用外部图片生成 API。"
},
{
"key": "preview_export",
"label": "预览导出",
"type": "render",
"order": 7,
"preconditions": ["content_creation", "image_generation"],
"description": "生成预览 MD、预览 HTML 和分页 MD。"
},
{
"key": "page_markdown",
"label": "分页 Markdown",
"type": "render",
"order": 8,
"preconditions": ["preview_export"],
"description": "生成带图片尺寸标注的分页 Markdown。"
}
],
"forms": {
"task_configuration": {
"fields": [
{
"key": "business_domain",
"label": "业务域",
"type": "select",
"required": true,
"options": ["AI", "医疗", "保险", "HR", "法务", "通用"]
},
{
"key": "keyword",
"label": "关键词",
"type": "text",
"required": true
},
{
"key": "audience",
"label": "目标受众",
"type": "text",
"default": "公众号读者",
"required": false
},
{
"key": "goal",
"label": "写作目标",
"type": "text",
"required": false
},
{
"key": "tone",
"label": "语调风格",
"type": "select",
"default": "专业但好懂",
"options": ["专业但好懂", "轻松有趣", "严肃权威", "故事叙述", "数据驱动"]
},
{
"key": "requirements",
"label": "特殊要求",
"type": "textarea",
"required": false
},
{
"key": "outline_style",
"label": "提纲风格",
"type": "select",
"default": "问题拆解型",
"options": ["问题拆解型", "对比分析型", "案例驱动型", "步骤教程型"]
},
{
"key": "outline_words",
"label": "提纲字数",
"type": "number",
"default": 800,
"min": 300,
"max": 2000,
"required": false
},
{
"key": "content_target_words",
"label": "正文目标字数",
"type": "number",
"default": 1400,
"min": 500,
"max": 5000,
"required": false
},
{
"key": "max_content_images",
"label": "最大配图数(可选,0 表示无上限)",
"type": "number",
"default": 0,
"min": 0,
"max": 20,
"required": false
}
]
}
}
}
@@ -0,0 +1,5 @@
[
{"step_key": "image_generation", "prompt_file": "prompt.md"},
{"step_key": "preview_export", "prompt_file": "prompt.md"},
{"step_key": "page_markdown", "prompt_file": "prompt.md"}
]
@@ -0,0 +1,15 @@
{
"description": "工作流编排。按编号顺序执行,每步的 prompt/validator/fallback 在各自步骤目录中。",
"version": "1.0.0",
"steps": [
{ "key": "task_configuration", "label": "任务配置", "type": "form", "order": 0, "is_entry_point": true },
{ "key": "topic_recommendation", "label": "选题推荐", "type": "ai", "order": 1, "preconditions": ["task_configuration"] },
{ "key": "title_generation", "label": "标题生成", "type": "ai", "order": 2, "preconditions": ["topic_recommendation"] },
{ "key": "outline_generation", "label": "提纲生成", "type": "ai", "order": 3, "preconditions": ["title_generation"] },
{ "key": "content_creation", "label": "正文创作", "type": "ai", "order": 4, "preconditions": ["outline_generation"] },
{ "key": "image_prompt_generation", "label": "配图提示词", "type": "ai", "order": 5, "preconditions": ["content_creation"] },
{ "key": "image_generation", "label": "图片生成", "type": "external", "order": 6, "preconditions": ["image_prompt_generation"] },
{ "key": "preview_export", "label": "预览导出", "type": "render", "order": 7, "preconditions": ["content_creation", "image_generation"] },
{ "key": "page_markdown", "label": "分页 Markdown", "type": "render", "order": 8, "preconditions": ["preview_export"] }
]
}