name: webnovel-write description: 产出可发布章节,完整执行上下文、起草、审查、润色、数据回写与备份。
正文/第{NNNN}章-{title_safe}.md,无标题时回退 正文/第{NNNN}章.md。--fast 与 --minimal 只允许裁剪可选环节。chapter_status 判断chapter_reviewed)当多个指令来源冲突时,按以下顺序裁决:
chapter_status / blocking 硬门槛在进入 Step 0.5 之前,先判断:
preflight 失败或项目根不合法 → 阻断,先修环境blocking=true → 进入"修复 → 重审"循环,不得进入 Step 4/5anti_ai_force_check=fail → 回到 Step 4 修复,不得进入 Step 5/webnovel-write:Step 0.5 → Step 1 → Step 2 → Step 3 → Step 4 → Step 5 → Step 6/webnovel-write --fast:Step 0.5 → Step 1 → Step 2 → Step 3(轻量) → Step 4 → Step 5 → Step 6/webnovel-write --minimal:Step 0.5 → 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 2 | always | 核心约束 | ${SKILL_ROOT}/../../references/shared/core-constraints.md |
| Step 2 | always | Anti-AI 预防 | ${SKILL_ROOT}/references/anti-ai-guide.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、${CLAUDE_PLUGIN_ROOT}/scripts/extract_chapter_context.py规范化变量: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 0.5 之前,必须先生成并刷新本章的写前合同(类比网文作者开写前先过一遍大纲、设定、禁区):
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${WORKSPACE_ROOT}" \
story-system "{chapter_goal}" --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,本章审查合同(必须覆盖节点、本章禁区)阻断规则:
目的:在不阻断流程的前提下,对章纲中的结构化节点做轻量一致性提醒。
规则:
CBN/CEN 时执行。CBN 中地点是否与 protagonist_state.location 明显冲突CBN/CEN 中主角境界或能力要求是否与 protagonist_state.power 明显冲突context-agent,不得阻断流程。警告示例:
[NODE_WARNING] CBN 地点与当前状态不一致: 章纲=迦南学院入口, 实际=乌坦城[NODE_WARNING] CBN 强度要求与当前境界不一致: 章纲=斗师级压制, 实际=斗者三星使用 Task 调用 context-agent,输入:
chapterproject_rootstorage_path=.webnovel/state_file=.webnovel/state.jsonNODE_WARNING,一并传入硬要求:
执行前必须加载:
cat "${SKILL_ROOT}/../../references/shared/core-constraints.md"
cat "${SKILL_ROOT}/references/anti-ai-guide.md"
硬要求:
[TODO]、[待补充] 等占位符。CBN -> CPNs -> CEN 展开,不得跳过必须节点。状态推进:
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" state set-chapter-status --chapter {chapter_num} --status chapter_drafted
使用 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"
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" index save-review-metrics \
--data "@${PROJECT_ROOT}/.webnovel/tmp/review_metrics.json"
阻断规则:
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 终检状态推进(--minimal 除外):
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" state set-chapter-status --chapter {chapter_num} --status chapter_reviewed
核心原则: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 投影完成(长期记忆事实)投影层定位(Phase 5 明确):
.webnovel/state.json / index.db / summaries / memory_scratchpad 只是 commit 的"查询视图"| 失败场景 | 补跑策略 | 禁止操作 |
|---|---|---|
| commit 文件未生成 | 只重跑 Step 5.2 | ❌ 不回退 Step 1-4 |
projection_status.state=failed |
只修复 state projection 后补提 commit | ❌ 不重新提取事实 |
| 向量索引失败 | 只补跑 extraction 子步骤 | ❌ 不重新审查 |
TOTAL > 30000ms |
输出最慢 2-3 个环节与原因 | ❌ 不静默跳过性能问题 |
状态推进:
python -X utf8 "${SCRIPTS_DIR}/webnovel.py" --project-root "${PROJECT_ROOT}" state set-chapter-status --chapter {chapter_num} --status chapter_committed
git add .
git -c i18n.commitEncoding=UTF-8 commit -m "第{chapter_num}章: {title}"
规则:
未满足以下条件前,不得结束流程:
chapter_status 已推进到 chapter_drafted(Step 2 完成)。--minimal 除外)。blocking=true 的 issue,流程必须停在 Step 3。anti_ai_force_check=pass(--minimal 除外),chapter_status 已推进到 chapter_reviewed。CHAPTER_COMMIT,并确认 state/index/summary/memory projection 已完成或显式跳过,chapter_status 已推进到 chapter_committed。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(--minimal 模式下至少为 chapter_drafted)。CHAPTER_COMMIT 已写入 .story-system/commits/,且投影链路完成。触发条件:
恢复规则: