name: webnovel-write description: 产出可发布章节,完整执行上下文、起草、审查、润色、数据回写与备份。
正文/第{NNNN}章-{title_safe}.md,无标题时回退 正文/第{NNNN}章.md。--fast 与 --minimal 只允许裁剪可选环节。chapter_status 判断rejected 或 projection 未完成)当多个指令来源冲突时,按以下顺序裁决:
chapter_status / blocking 硬门槛在进入 Step 1 之前,先判断:
preflight 失败或项目根不合法 → 阻断,先修环境blocking=true → 进入"修复 → 重审"循环,不得进入 Step 4/5anti_ai_force_check=fail → 回到 Step 4 修复,不得进入 Step 5/webnovel-write:Step 1 → Step 2 → Step 3 → Step 4 → Step 5 → Step 6/webnovel-write --fast:Step 1 → Step 2 → Step 3(轻量) → Step 4 → Step 5 → Step 6/webnovel-write --minimal:Step 1 → Step 2 → Step 4(仅排版) → Step 5 → Step 6最小产物:
index.db.review_metrics 新记录(--minimal 除外).webnovel/summaries/ch{NNNN}.md.webnovel/state.json 的进度与 chapter_meta.webnovel/memory_scratchpad.json 的长期记忆事实加载等级:
路径说明:../../references/ 指共享 references;references/ 指 skill 私有 skills/webnovel-write/references/。
| Step | Trigger | Reference | 实际路径 |
|---|---|---|---|
| Step 1 | always | 追读力分类 | ${SKILL_ROOT}/../../references/reading-power-taxonomy.md |
| Step 1 | always | 题材配置 | ${SKILL_ROOT}/../../references/genre-profiles.md |
| Step 1 | always | 风格差异化 | ${SKILL_ROOT}/references/style-variants.md |
| Step 3 | always | 审查 schema | ${SKILL_ROOT}/../../references/review-schema.md(reviewer 内部使用) |
| Step 4 | always | 润色指南 | ${SKILL_ROOT}/references/polish-guide.md |
| Step 4 | always | 排版规则 | ${SKILL_ROOT}/references/writing/typesetting.md |
| Step 4 | always | 风格适配 | ${SKILL_ROOT}/references/style-adapter.md |
reference_search.py)| Step | Trigger | 检索命令 |
|---|---|---|
| Step 2 | 本章有新角色首次出场 | python -X utf8 "${SCRIPTS_DIR}/reference_search.py" --skill write --table 命名规则 --query "角色命名" --genre {题材} |
| Step 2 | 本章有战斗/对峙场景 | ... --skill write --table 场景写法 --query "战斗描写" --genre {题材} |
| Step 2 | 本章有多角色对话 | ... --skill write --table 写作技法 --query "对话声线 口吻区分" |
| Step 2 | 本章有情感/心理描写 | ... --skill write --table 写作技法 --query "情感描写 心理" |
| Step 2 | 本章涉及高频桥段 | ... --skill write --table 场景写法 --query "{桥段类型}" |
Read/Grep:读取大纲、状态、正文与参考资料。Bash:运行 webnovel.py 与相关脚本。Task:调用 context-agent、reviewer 与 data-agent。必须完成:
.webnovel/state.json大纲/总纲.md规范化变量:WORKSPACE_ROOT、PROJECT_ROOT、SKILL_ROOT、SCRIPTS_DIR、chapter_num、chapter_padded
export WORKSPACE_ROOT="${CLAUDE_PROJECT_DIR:-$PWD}"
export SCRIPTS_DIR="${CLAUDE_PLUGIN_ROOT:?CLAUDE_PLUGIN_ROOT is required}/scripts"
export SKILL_ROOT="${CLAUDE_PLUGIN_ROOT:?CLAUDE_PLUGIN_ROOT is required}/skills/webnovel-write"
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${WORKSPACE_ROOT}" preflight
export PROJECT_ROOT="$(python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${WORKSPACE_ROOT}" where)"
硬门槛:
preflight 必须成功。在进入 Step 1 之前,必须先生成并刷新本章的写前合同(类比网文作者开写前先过一遍大纲、设定、禁区):
genre 参数规范:
--genre 必须从 state.json 的 project.genre 读取(唯一真源),不得手动填写若章纲无明确目标,fallback 到 "{题材} 第{chapter_num}章"
# 从 state.json 读取题材(唯一真源)
GENRE="$(python -X utf8 -c "import json,sys; s=json.load(open('${PROJECT_ROOT}/.webnovel/state.json',encoding='utf-8')); print(s.get('project',{}).get('genre',''))")"
# query 填章纲目标(用于 CSV 检索),genre 固定从 state.json 读取
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${WORKSPACE_ROOT}" \
story-system "{章纲目标,如:韩立进入坊市试探消息}" --genre "${GENRE}" --chapter {chapter_num} --persist --emit-runtime-contracts --format both
合同树必备文件(写前真源,缺一不可):
.story-system/MASTER_SETTING.json - MASTER_SETTING,全书主设定合同(题材、调性、核心禁忌).story-system/volumes/volume_{volume_num}.json - VOLUME_BRIEF,本卷节奏合同(卷级目标、爽点密度).story-system/reviews/chapter_{chapter_num}.review.json - REVIEW_CONTRACT,本章审查合同(必须覆盖节点、本章禁区)chapter_brief 定位说明:
.story-system/chapters/chapter_{chapter_num}.json 的 chapter_focus 是 CSV 检索派生的参考,不是本章实际目标大纲/第X卷-详细大纲.md 中的章纲原文为最高权重(仅次于用户意见)chapter_{chapter_num}.json 的核心价值是 reasoning 字段中的裁决元数据(风格优先级、节奏策略、反模式)阻断规则:
使用 Task 调用 context-agent,输入:
chapterproject_rootstorage_path=.webnovel/state_file=.webnovel/state.json硬要求:
context-agent 必须先完成 research,再输出最终的写作任务书。硬要求:
core-constraints.md。anti-ai-guide.md。[TODO]、[待补充] 等占位符。CBN -> CPNs -> CEN 展开,不得跳过必须节点。使用 Task 调用 reviewer agent,输入:
chapterchapter_file(正文文件路径)project_rootscripts_dirreviewer 输出为结构化问题清单 JSON(参见 review-schema.md),保存到中间产物路径。
Step 3 中间产物约定:
${PROJECT_ROOT}/.webnovel/tmp/review_results.json${PROJECT_ROOT}/.webnovel/tmp/review_metrics.json标准文件流:
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" review-pipeline \
--chapter {chapter_num} \
--review-results "${PROJECT_ROOT}/.webnovel/tmp/review_results.json" \
--metrics-out "${PROJECT_ROOT}/.webnovel/tmp/review_metrics.json" \
--report-file "审查报告/第{chapter_num}章审查报告.md" \
--save-metrics
阻断规则:
blocking=true 的 issue,不得进入 Step 4/5。模式规则:
--fast:轻量审查(reviewer 仅检查 setting/timeline/continuity 三个维度)--minimal:跳过 Step 3执行前必须加载:
cat "${SKILL_ROOT}/references/polish-guide.md"
cat "${SKILL_ROOT}/references/writing/typesetting.md"
cat "${SKILL_ROOT}/references/style-adapter.md"
执行顺序:
风格适配硬要求:
Anti-AI 硬要求:
anti_ai_force_check=pass/failfail 时不得进入 Step 5模式规则:
--minimal:仅排版,跳过问题修复、风格适配和 Anti-AI 终检核心原则:Data Agent 不是写后真理源,它只负责提取事实并生成 commit artifacts。 真正的写后事实入口是 accepted
CHAPTER_COMMIT,类比网文作者写完一章后的"定稿提交"。
使用 Task 调用 data-agent,产出四份中间文件(commit 前置材料):
| 文件 | 职责 | 来源 |
|---|---|---|
review_results.json |
审查问题清单 | Step 3 reviewer + review-pipeline |
fulfillment_result.json |
大纲履约情况(覆盖了哪些节点、漏了哪些) | plot_structure 对比 |
disambiguation_result.json |
实体消歧状态(pending / warnings) | 角色/势力/地点消歧 |
extraction_result.json |
章节事实提取(事件、状态变化、实体变化、摘要) | 正文语义提取 |
Data Agent 新角色定位(Phase 5 降级后):
state.json / index.db / summaries / memory_scratchpad(这些是投影层,由 commit 驱动)主命令(类比作者点击"发布章节"按钮):
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" chapter-commit \
--chapter {chapter_num} \
--review-result "${PROJECT_ROOT}/.webnovel/tmp/review_results.json" \
--fulfillment-result "${PROJECT_ROOT}/.webnovel/tmp/fulfillment_result.json" \
--disambiguation-result "${PROJECT_ROOT}/.webnovel/tmp/disambiguation_result.json" \
--extraction-result "${PROJECT_ROOT}/.webnovel/tmp/extraction_result.json"
提交判定规则(自动判断 accepted / rejected):
review_results.blocking_count > 0 → rejected(有阻断问题,不能发布)fulfillment_result.missed_nodes 非空 → rejected(大纲节点没写完)disambiguation_result.pending 非空 → rejected(角色消歧未完成)成功标准(accepted commit 才会触发投影):
.story-system/commits/chapter_{chapter_num}.commit.json 已生成(写后真源)projection_status 五项全部为 done 或 skipped:
state → .webnovel/state.json 投影完成(主角境界、当前位置等)index → index.db 投影完成(角色出场、势力关系等)summary → summaries/ch{chapter_padded}.md 投影完成(章节摘要)memory → memory_scratchpad.json 投影完成(长期记忆事实)vector → 向量索引投影完成(事件/实体语义检索)投影层定位(Phase 5 明确):
.webnovel/state.json / index.db / summaries / memory_scratchpad 只是 commit 的"查询视图"chapter_status 推进:
state_projection_writer 自动推进到 chapter_committedstate_projection_writer 自动推进到 chapter_rejectedset-chapter-status| 失败场景 | 补跑策略 | 禁止操作 |
|---|---|---|
| commit 文件未生成 | 只重跑 Step 5.2 | ❌ 不回退 Step 1-4 |
projection_status.state=failed |
只修复 state projection 后补提 commit | ❌ 不重新提取事实 |
projection_status.vector=failed |
只补跑 vector projection | ❌ 不重新提取事实 |
TOTAL > 30000ms |
输出最慢 2-3 个环节与原因 | ❌ 不静默跳过性能问题 |
git add .
git -c i18n.commitEncoding=UTF-8 commit -m "第{chapter_num}章: {title}"
规则:
未满足以下条件前,不得结束流程:
--minimal 除外)。blocking=true 的 issue,流程必须停在 Step 3。anti_ai_force_check=pass(--minimal 除外)。CHAPTER_COMMIT,projection_status 五项全部为 done 或 skipped。chapter_status 为 chapter_committed(由 projection writer 自动推进,不手动写入)。python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" state get-chapter-status --chapter {chapter_num}
test -f "${PROJECT_ROOT}/正文/第${chapter_padded}章.md"
test -f "${PROJECT_ROOT}/.story-system/commits/chapter_${chapter_num}.commit.json"
test -f "${PROJECT_ROOT}/.webnovel/summaries/ch${chapter_padded}.md"
test -f "${PROJECT_ROOT}/.webnovel/memory_scratchpad.json"
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" index get-recent-review-metrics --limit 1
tail -n 1 "${PROJECT_ROOT}/.webnovel/observability/data_agent_timing.jsonl" || true
成功标准:
chapter_status 为 chapter_committed(由 projection writer 自动推进)。CHAPTER_COMMIT 已写入 .story-system/commits/,且投影链路完成。触发条件:
恢复规则: