复制安装命令
用 Codex 或 Claude 安装复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它先审查 Skill 页面再帮你安装。
复制前请先查看来源、License 和安全提示。
网文写作 skill 包,覆盖长篇与短篇网络小说的扫榜、拆文、写作、去AI味、封面图全流程。
用 Codex 或 Claude 安装复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它先审查 Skill 页面再帮你安装。
复制前请先查看来源、License 和安全提示。
来源文件:README.md
English | 中文
网文写作 skill 包,覆盖长篇与短篇网络小说的扫榜、拆文、写作、去AI味、封面图全流程。内置适配 Claude Code、OpenCode、ZCode、OpenClaw、Codex CLI、Reasonix;能读取项目文件的 Web AI / Agent 环境也可按通用 skills 路径使用。
套路 = 确定性的情绪满足
专业作者的方法论三步走:
围绕四条线展开:爆款逆向 · 剧情模块化重组 · 上下文状态分层管理 · 人机协同。
v0.7.6 起:重点在正文那一段。写正文的
narrative-writer有三条规则一直在空转——「写完必须立即统计字数」给的是一条 Bash 命令,可它的工具白名单里没有 Bash,同一句话又禁掉了模型估算,于是「字数达标是硬性要求」背后没有任何可执行判据;「返回前报出句长分布」同样只能编,而主会话正拿它做质量校验;「正文逐项展开细纲」是最高优先级的明令,放宽的那半边却只写在主 skill 里、从不进 spawn 提示词,子代理只看见限制,就按一个情节点一段平推成流水账。三条都已修好,实跑首次落盘即进验收区间(对照组不到下限的 73%)。新增细纲照搬检测:细纲把情节点写成成品散文句时正文只剩誊抄,配套的「复沓锚句」字段让必须逐字进正文的原话(誓言、系统面板、案卷原话)不被误判。另外 Claude Code 上用 Bash 重定向写正文也会被大纲/追踪守卫拦下,以及每次会话固定加载的文本再降两成(开书 −30%、回炉 −41%)。本版agents_version为 25,已部署项目需重新运行/story-setup并新开会话。v0.7.5 起:稳定版。补上 Claude Code 写正文守卫缺的追踪检查点门——另三端从 v0.7.3 起就有,主力端此前会静默写出若干章没有追踪的正文;长篇
story-long-write每次触发都整份进上下文的 SKILL.md 从 82 KB 降到 54 KB(开书三阶段抽成按需读的workflow-setup.md,日更不再为用不上的建纲步骤付费);清掉一批过度累加的限制指令,其中一条把正文里普通的「他说」判成了违规。本版agents_version为 24,已部署项目需重新运行/story-setup并新开会话。v0.7.4 起:全是修复。
story-import不再把用户自己的书登记成对标(此前会出现「对标目录内容跟自己设定完全相同」);story-setup 重部署不再把 Reasonix / generic 项目误判成 OpenClaw,多端部署也不再每次开会话误报参考包缺失;Stage 6 文风统计在 Windows 上不再必挂。spawn 的agents_version硬门禁改成提示——版本不匹配照常并行,只有 agent 文件缺失才降级 solo。本版agents_version为 23,已部署项目需重新运行/story-setup并新开会话。更早版本变更见 CHANGELOG.md。
flowchart LR
classDef entry fill:#f0f0f0,color:#333,stroke:#999,stroke-width:1px
classDef phase fill:#e8f4fd,color:#1a1a2e,stroke:#4a9be8,stroke-width:1px
classDef final fill:#fce4ec,color:#333,stroke:#e57373,stroke-width:1px
entry_l{{"长篇作者"}}:::entry
entry_s{{"短篇作者"}}:::entry
entry_r{{"已有方向"}}:::entry
entry_i{{"已有小说"}}:::entry
subgraph S0 [" 环境部署"]
setup["/story-setup"]:::phase
end
subgraph S1 [" 扫榜选材"]
direction TB
scan_l["长篇扫榜"]:::phase
scan_s["短篇扫榜"]:::phase
end
subgraph S2 [" 拆文学习"]
direction TB
analyze_l["长篇拆文"]:::phase
analyze_s["短篇拆文"]:::phase
import_l["已有小说导入"]:::phase
end
subgraph S3 [" 落笔创作"]
direction TB
write_l["长篇写作"]:::phase
write_s["短篇写作"]:::phase
end
subgraph S4 [" 精修定稿"]
deslop["去 AI 味"]:::final
end
entry_l --> setup
entry_s --> setup
setup --> scan_l
setup --> scan_s
scan_l --> analyze_l
scan_s --> analyze_s
analyze_l --> write_l
analyze_s --> write_s
entry_r -.->|跳过准备| write_l
entry_r -.->|跳过准备| write_s
entry_i -.->|推荐先部署| setup
setup -.->|逆向导入| import_l
import_l -.->|续写| write_l
write_l --> deslop
write_s --> deslop
方式一 直接告诉 Claude Code / OpenCode / ZCode / OpenClaw / Codex / Reasonix,或其他支持导入 GitHub 仓库/skill 的 Web AI / Agent 平台:
安装这个 skill https://github.com/zenstory-ai/oh-story-claudecode
升级时再说一次同一句话即可。
方式二 命令行:
npx skills add zenstory-ai/oh-story-claudecode -y -g
-g 全局安装,所有目录可用;去掉 -g 则只装到当前目录。更新时重新执行同一条命令即可。
Windows 上偶尔会看到 ENOENT ... mkdir 报错但末尾仍显示 Done!,这是有技能没装全。story-setup 的参考资料目录整个缺了一块时,跑 /story-setup 会提示参考资料包不完整;其它形式的残缺不一定有提示。无论有没有报错,重跑同一条安装命令即可修复。
Codex 用户: repo 内直接使用:Codex 会扫描 $REPO_ROOT/.agents/skills(指向 skills/ 的 symlink)发现 13 个 skill;用 $story、$story-setup 或 /skills 调用。Windows 上 git 需开 core.symlinks=true,否则 symlink 失效,改走下方 $story-setup 部署。
跑 $story-setup 部署到写作项目后,会写入 .codex/agents/*.toml、.codex/hooks.json、.codex/hooks/{story_codex_hook.py,run-story-hook.sh,run-story-hook.cmd} 和 .codex/skills/story-setup/references/agent-references/;请信任项目 .codex/ 配置层并在 /hooks review/trust hooks、新开 Codex 会话,让 custom agents 生效。
ZCode 用户: 在 Plugin Management 中把本仓库加入 marketplace,安装 oh-story 后可用 $story、$story-setup 或 / 面板调用 13 个 Skills/Commands。$story-setup 选择 target_cli=zcode 会部署 .zcode/skills/、.zcode/commands/、.zcode/hooks/story_zcode_hook.js,安全合并 .zcode/config.json 与根 AGENTS.md;Hook 依赖 PATH 中的 node。ZCode 3.3.4 不执行项目/plugin custom agents,也没有 PreCompact / SessionEnd,相关流程会明确降级 solo/direct,compact 后由 SessionStart 恢复上下文。
OpenCode 用户: 全局安装后 opencode 自动从 ~/.claude/skills/ 发现 skills;首次用自然语言触发 story-setup(如「用 story-setup 部署网文写作环境」),部署后退出重进 opencode -c 才能用 slash command。部分 hook 行为与 Claude Code 有差异(session-start / session-end / compact 等),详见 CONTRIBUTING.md 的 OpenCode 章节。
OpenClaw 用户: 当前支持 skills-only:OpenClaw 可从 workspace skills/、.agents/skills、~/.agents/skills、~/.openclaw/skills 等 skill root 发现本项目 13 个 skill;SKILL.md 已按 OpenClaw 要求使用单行 name / description 与单行 JSON metadata.openclaw。story-setup 选择 target_cli=openclaw 时会把 skills 复制到项目 skills/ 并写入 OpenClaw 版 AGENTS.md;agents/hooks 暂不部署,写正文前大纲守卫在 OpenClaw 下是 skill 内软约束。部署后如未显示新 skills,请新开 OpenClaw session 或等待 watcher 刷新。
Reasonix 用户: 当前支持 skills + 原生 plugin manifest:Reasonix 原生扫描项目 skill root(.agents/skills 等,指向 skills/ 的 symlink)发现 13 个 skill,用 reasonix doctor capabilities 校验;也可用根 reasonix-plugin.json 走 reasonix plugin install。story-setup 选择 target_cli=reasonix 时会把 skills 复制到项目 skills/ 并写入 Reasonix 版 AGENTS.md;hooks/custom agents 暂不部署,涉及专业 Agent 的 skill 走 solo/direct fallback。Windows 未启用 symlink 时改走原生 plugin。
Web AI / 通用 Agent 用户: 平台能读取 GitHub 仓库或项目文件时,可让 Agent 读取 skills/*/SKILL.md 与对应 references/;需要本地副本时,story-setup 可选 target_cli=generic,只写通用 AGENTS.md 和 skills/。无本项目 hooks/custom agents 的环境按 skill 内软约束或 solo/direct fallback 执行。
OpenClaw / Reasonix / 通用路径的目录残留要手动清: 这三条路径的 skill 副本在项目 skills/ 里,重跑 /story-setup 执行的就是项目里那份,自动清理到不了。项目里若出现 skills/story-setup/references/agent-references/agent-references/(可能嵌了多层)或 skills/story-setup/skills/,手动删掉。要让项目里的 skill 文本本身更新,还需要重新安装本项目后,用新包覆盖项目 skills/ 下这 13 个目录。
升级后如果项目里已经跑过 /story-setup,建议在项目根重跑一次 /story-setup,同步 hooks / agents / references。每版变更见 CHANGELOG.md 与 Releases。
多 agent 协作要先部署再新开会话: 7 个专业 agent(story-architect、narrative-writer、consistency-checker 等)由 /story-setup 写入项目 .claude/agents/,或由 $story-setup 写入 .codex/agents/*.toml。Claude Code / Codex 都在会话启动时更稳定地注册 custom agent;ZCode 3.3.4、OpenClaw Phase 1、Reasonix Phase 1 与 generic 路径默认走 skills + solo fallback。判断是否生效:新会话里跑 /story-review,报告头是 Effective Mode: full/lean 即注册成功,是 Fallback: ... -> solo 说明当前运行时未暴露该 agent。
导入续写顺序: 推荐先在写作项目根运行 /story-setup(部署 hooks/agents/AGENTS),新开/刷新会话后运行 /story-import 导入已有小说,再用 /story-long-write 日更 或 /story-long-write 写第N章 续写。也可以直接运行 /story-import;它会先检测是否已 setup,未部署时让你选择先去 setup 或继续串行导入。
| Skill | 触发 | 说明 |
|---|---|---|
story-setup | /story-setup $story-setup /准备写书 | 环境部署 · Claude/OpenCode/Codex/ZCode/OpenClaw/Reasonix + generic(已有配置安全合并) |
story | /story $story /story dashboard | 工具箱路由 · 模糊意图分发 + 本地拆文/项目 Dashboard |
story-long-write | /story-long-write /写长篇 | 长篇写作 · 大纲搭建、人物设定、正文输出 |
story-long-analyze | /story-long-analyze | 长篇拆文 · 黄金三章、爽点设计、节奏分析 |
story-long-scan | /story-long-scan | 长篇扫榜 · 起点/番茄/晋江市场趋势 |
story-short-write | /story-short-write | 短篇写作 · 情绪设计、反转构思、精修出稿 |
story-short-analyze | /story-short-analyze | 短篇拆文 · 故事核、结构分析、情感线、反转设计、写作手法、共鸣分析 |
story-short-scan | /story-short-scan | 短篇扫榜 · 知乎盐言/番茄短篇风口数据 |
story-deslop | /story-deslop /去AI味 | 去AI味 · 检测并清除 AI 写作痕迹 |
story-import | /story-import /导入小说 | 逆向导入 · 将已有小说反向解析为标准项目结构 |
story-review | /story-review /审查 | 多视角审查 · 4 Agent 多视角审稿 + 番茄/起点/知乎评分标准 |
story-cover | /story-cover /封面 | 封面生成 · 书名题材分析 + GPT-Image-2(Codex 内置用量 / API 回退) |
browser-cdp | /browser-cdp | 浏览器操控 · CDP 协议复用登录态抓取数据 |
story-deslop的本地检查是写作 lint:blocking 只限确定性句式/标点问题,其他提示按读感判断;朱雀等外部检测只作自测参考,不替代人工读感。
自然语言同样触发:
story-long-writestory-deslopstory-importstory dashboard(本机浏览拆文库与写作项目,可轻量编辑)story-explorer agent运行 /story dashboard(Codex 用 $story dashboard)打开本地写作工作台,浏览拆文库与
长/短篇项目文件树,并完成搜索、Markdown 预览、文本编辑、冲突保护保存和确认删除。
服务仅监听 127.0.0.1,小说内容不会上传。


使用 /story-long-analyze 深度模式分析《盘龙》前23章的完整输出:
demo/拆文库/盘龙/
├── 概要.md # 全书概要 + 章节索引
├── 拆文报告.md # 五维评分 + 爽点密度 + 可借鉴套路
├── 文风.md # 句长/标点/对话潜台词/情绪节奏 + 原文锚点
├── 章节/
│ ├── 第1章_深度拆解.md … 第3章_深度拆解.md # 黄金三章逐章深度分析
│ └── 第1章_摘要.md … 第23章_摘要.md # 每章一个摘要文件
├── 角色/
│ ├── 林雷.md # 主角完整档案
│ ├── 霍格.md # 核心配角
│ ├── 希尔曼.md # 核心配角
│ ├── 希里.md # 功能角色
│ ├── 德林柯沃特.md # 核心配角
│ ├── 沃顿.md # 功能角色
│ └── 角色关系.md # 关系网络
├── 剧情/
│ ├── 故事线.md # 框架识别 + 4剧情 + 2故事线
│ ├── 强者过境与魔法启蒙.md 等 # 五个分场景剧情单元
│ ├── 节奏.md # 节奏/关键信息递进/情绪触发爆发节律
│ └── 情绪模块.md # 读者需求/情绪引擎/可复用写作模块
└── 设定/
├── 世界观/
│ ├── 背景设定.md # 核心规则 + 特殊设定
│ ├── 力量体系.md # 战气 + 魔法 + 等级
│ ├── 地理.md # 安达卢西亚 + 玉兰大陆
│ └── 金手指.md # 盘龙戒指 + 德林柯沃特
└── 势力/
└── 巴鲁克家族.md # 龙血血脉家族档案
长篇拆文会额外生成 文风.md,并在 剧情/ 下产出 节奏.md(节奏/关键信息递进/情绪触发爆发节律)和 情绪模块.md(读者需求/情绪引擎/可复用写作模块);日更写作会通过 对标/{书名}/剧情/ 读取这些素材,避免文风、节奏和情绪模块偏离对标书。
使用 /story-short-analyze 拆解短篇《曾将爱意私藏》(约 8500 字,追妻火葬场 · 死遁)的完整输出:
demo/拆文库/曾将爱意私藏/
├── 原文/原文.txt # 原文备份
├── 拆文报告.md # 故事核 + 五维评分 + 爆点6维 + 认知反转 + 共鸣9层
├── 情节节点.md # 54 个情节节点(原文引用 + 情绪标记 −9~+9)
├── 写作手法.md # POV / 对话 / 信息差 / 物件钩子 等 11 项
└── _meta.json # 结构计数 structure_counts(Phase 7 门控依据)
短篇拆文产出 拆文报告 / 情节节点 / 写作手法,下游 /story-short-write 据此写同题材新短篇。
推荐先 /story-setup 部署写作项目,再使用 /story-import 把作者已发布的前 20 章(约 3.7 万字)逆向重建为可续写的写作工程,最后接 /story-long-write 日更 或 /story-long-write 写第21章 续写:
demo/长篇/让你管账号,你高燃混剪炸全网/
├── 正文/ 第001–020章(已发布原文)
├── 大纲/ 大纲.md · 卷纲_第1卷.md · 细纲_第001–020章.md(1 章 1 文件)
├── 设定/ 角色/{江晨·钟嘉嘉·周薄森·张耀祖·吴伟·李林}
│ 世界观/{背景设定·金手指} · 关系.md · 题材定位.md · 文风.md
└── 追踪/ _tracking-state.json · 上下文.md · 伏笔.md · 逐章记录/
角色状态/{角色名}.md · 时间线/{作者真相.md·读者已知.md}
逐章提取(事件 / 角色 / 设定 / 伏笔 / 时间线)反推为续写 bible,作者从第 21 章无缝接着写。
写作 skill 内部通过 7 个专业 Agent 协作,各司其职:
| Agent | 模型 | 职责 |
|---|---|---|
| story-architect | Opus | 故事架构 · 题材定位、大纲结构、钩子/反转设计、情绪弧线 |
| character-designer | Sonnet | 角色设计 · 角色档案、语言风格、动机链、对话创作 |
| narrative-writer | Sonnet | 叙事写手 · 正文写作、去AI味、格式合规 |
| consistency-checker | Haiku | 一致性检查 · 事实冲突扫描、伏笔追踪、S1-S4 分级报告 |
| story-researcher | Sonnet | 资料研究 · CDP 搜索+正文提取、多源交叉验证、结构化参考文件输出 |
| story-explorer | Haiku | 故事查询 · 角色/伏笔/设定/进度只读查询,日更上下文快速加载 |
| chapter-extractor | Haiku | 章节提取 · 摘要+情节点+角色提及,并行拆文核心单元 |
Agent 按需加载 references/ 中的写作理论(角色设计、对话技法、反转工具箱等 100+ 份方法论文件),不预占上下文。
/story-setup 为 Claude Code 部署 8 个自动化 hook:
| Hook | 触发时机 | 功能 |
|---|---|---|
| session-start.sh | 会话开始 | 显示分支、进度快照、拆文状态 |
| session-end.sh | 会话结束 | 记录会话日志到 追踪/session-log.txt |
| detect-story-gaps.sh | 会话开始 | 检测设定缺口、大纲缺失、伏笔断线 |
| pre-compact.sh | 上下文压缩前 | 保存进度快照路径和行数摘要 |
| post-compact.sh | 上下文压缩后 | 提示读取进度快照恢复上下文 |
| validate-story-commit.sh | git commit 时 | 检查硬编码属性、设定必填字段(仅警告,不阻断) |
| guard-outline-before-prose.sh | 写正文前(Write/Edit) | 缺对应细纲/小节大纲时阻止首次创建正文(阻断),强制先搭大纲 |
| check-prose-after-write.sh | 正文写入后(Write/Edit) | 轻量扫描截断、工程词、毒句式和字数欠账(提醒,不阻断) |
一部长篇动辄几十万字、几百章。设定冲突、伏笔断线、时间线对不上——写到最后全靠记忆硬撑,迟早翻车。
用文件系统把设定、大纲、正文、追踪拆开,每个维度独立维护。对话只负责创作,不负责记忆。
长篇:
{书名}/
├── 设定/
│ ├── 世界观/ # 背景、力量体系等,按主题拆文件
│ ├── 角色/ # 每个人物一个文件(江晨.md、钟嘉嘉.md)
│ ├── 势力/ # 每个势力/组织一个文件(火箭军文工团.md)
│ ├── 关系.md # 角色关系映射
│ └── 题材定位.md # 题材核心梗+对标分析
├── 大纲/
│ ├── 大纲.md # 全书卷级结构
│ ├── 卷纲_第一卷.md # 每卷一个:爽点节奏+情绪弧线+人物弧线+伏笔+反转
│ ├── 细纲_第001章.md # 每章一个:内容概括+多线情节+人物关系/出场顺序+钩子
│ └── ...
├── 正文/
│ ├── 第001章_章名.md
│ └── ...
├── 对标/ # 对标参考(结构化子目录从拆文库同步)
│ └── {对标书名}/
│ ├── 原文/ # 对标书原文章节
│ ├── 角色/ # 结构化角色卡(从 analyze 输出同步)
│ ├── 剧情/ # 结构化剧情线/节奏/情绪模块(从 analyze 输出同步)
│ ├── 设定/ # 结构化设定(从 analyze 输出同步)
│ ├── 文风.md # 日更前读取,用来贴近对标书文风
│ └── 拆文报告.md # analyze skill 输出的拆文报告
├── 追踪/ # 文件优先的连续性状态
│ ├── _tracking-state.json # 唯一结构化权威状态(不进正文 prompt)
│ ├── 上下文.md # 派生续写状态卡(固定 7 栏,≤12KB)
│ ├── 逐章记录/ # 每章未来相关连续性记录/修订覆盖层(≤3072 bytes)
│ ├── 角色状态/ # 派生核心角色快照(江晨.md、钟嘉嘉.md)
│ ├── 伏笔.md # 派生伏笔当前视图
│ └── 时间线/ # 派生作者真相.md + 读者已知.md
├── 参考资料/ # story-researcher 输出的研究资料
│ └── {topic}.md # 按研究主题拆分
短篇:
短篇/{标题}/
├── 正文.md # 完成稿
├── 小节大纲.md # 8 节结构 + 情绪曲线
└── 拆文库/ # 如有参考小说(analyze 输出)
└── {书名}/
├── 拆文报告.md
├── 情节节点.md
└── 写作手法.md
拆文库: 拆文 skill 默认输出到项目根目录 拆文库/{书名}/,产出结构化目录(角色/剧情/设定/章节),其中长篇剧情目录包含 节奏.md 和 情绪模块.md,是 analyze 的源数据(source of truth)。写作 skill 通过 对标/{书名}/剧情/ 等子目录消费这些资产(项目级引用视图),或自动回退读取 拆文库/。
.active-book: 项目根目录的文本文件,内容是当前活跃书目的相对路径(如 长篇/我的小说),hook 和写作 skill 据此定位当前项目。
各 skill 自带 references/ 知识库,按需加载,不占上下文。
| 主题 | 内容 | 所在 skill |
|---|---|---|
| 大纲排布 | 五步大纲法 · 故事结构分级 · 节点设计法 · 升级感设计 | long-write |
| 开头设计 | 开篇模式 · 前 500 字设计 · 黄金三章开头策略 | long-write / short-write |
| 人物设计 | 角色设定 · 人物提取 · 关系映射 · 动机链 · 群像 | long-write / short-write / short-analyze |
| 钩子技法 | 章尾钩子 13 式 · 章首钩子 7 式 · 段落级钩子 · 悬念编排 | long-write / short-write / short-analyze |
| 情绪设计 | 6 种弧形模板 · 期待感管理 · 题材赛道策略 | long-write / short-write |
| 题材框架 | 长篇八节点 · 短篇压缩三幕 · 8 大题材开头模板 | long-write / short-write / short-analyze |
| 对话技法 | 节奏 · 潜台词 · 信息控制 · 对话模式数据库 | long-write / short-write |
| 反转工具箱 | 类型 · 时机 · 误导底层路径 | long-write / short-write |
| 风格模块 | 对话 · 打斗 · 智斗 · 镜头式写作 · 装逼打脸 · 白描 | long-write |
| 高级技法 | 小纲四步法 · 高潮逆推 · 双线结构 · AB 交织法 | long-write |
| 去AI味 | 预防 · 三遍去AI法 · 改写范例库 · 禁用词表 | deslop / long-write / short-write |
| 质量检查 | 通用 · 长篇专项 · 短篇专项 · 毒点排查 | long-write / short-write / short-analyze |
| 写作公式 | 21 大题材写作公式 · 三翻四震 · 感情线四阶段 | short-write / short-analyze |
| 女频写作 | 女读者偏好 · 情感描写 · 感情线模式 · 对标拆书 | short-write |
| 拆文方法 | 黄金三章 · 情绪曲线 · 结构拆解 · 知乎风格分析 | long-analyze / short-analyze |
| 短篇方法论 | 故事核 · 情节节点 · 爆点分析 · 写作手法 · 节奏分析 · 共鸣分析 · 人物分类 · 平台适配 | short-analyze |
| 拆文实例 | 完整案例拆解 · 模板化输出 | short-analyze |
| 读者画像 | 9 维画像 · 目标读者分析 | long-scan |
| 市场数据 | 题材趋势 · 平台特性 · 采集格式 · 投稿指南 | long-scan / short-scan |
| 封面风格 | 10 大题材视觉风格 · 色彩构图 · 提示词模板 | story-cover |
| 多视角审稿 | 多视角审稿 · 评分标准 · 毒点排查 | story-review |
长篇 起点中文网 · 番茄小说 · 晋江文学城 · 七猫小说 · 刺猬猫
短篇 知乎盐言故事 · 番茄短篇 · 七猫短篇
真实产出样例见 demo/:短篇拆文《曾将爱意私藏》· 长篇拆文《盘龙》· 长篇续写工程《让你管账号,你高燃混剪炸全网》· 封面《剑道独尊》示例图。
这套 skill 现在能让我度过找工作的过渡期 :joy:,希望也能帮到有需要的朋友。
欢迎贡献新 skill、补充知识库、更新市场数据。详见 CONTRIBUTING.md。
name: story-setup
version: 1.2.7
description: "网文写作工具集基础设施部署。为 Claude Code / OpenCode / Codex / ZCode / OpenClaw / Reasonix 提供内置适配;Web AI / 通用 Agent 可走 skills + AGENTS.md 文件模式。触发方式:/story-setup、$story-setup、「准备写书」「帮我搭一下环境」「配置写作项目」。"
metadata: {"openclaw":{"source":"https://github.com/zenstory-ai/oh-story-claudecode"}}你是写作基础设施部署器。将网文写作工具集部署到用户项目目录:已适配的 CLI 走专用 hooks/agents/config;NarraFork、Web AI、自定义 Agent 等环境走通用文件模式。
执行铁律:不覆盖用户已有配置,合并而非替换。
先自检参考目录:以正在执行的本 SKILL.md 所在目录为准,列出与它同级的 references/ 下的子目录,核对下面 8 个名字是否都在且都非空——agent-references、templates、opencode、codex、zcode、openclaw、reasonix、generic;同级 scripts/merge-claude-settings.py、scripts/merge-codex-hooks.py 与 scripts/copy-path-safety.py 也必须存在(Claude/Codex hooks 合并和递归复制安全检查依赖它们)。有缺即 skill 包没装全,立即停止,不写任何部署文件,报告里区分「缺目录」「目录为空」和「缺脚本」,并给修复指令:「story-setup 参考资料包不完整,缺 {路径}。按你的安装方式重装 oh-story-claudecode(命令行装的重跑 npx skills add zenstory-ai/oh-story-claudecode -y -g,marketplace / Plugin Management 装的在面板里重装),再执行 /story-setup。」
判据是「有没有
SKILL.md」:只看正在执行的SKILL.md同级的references/。项目内.claude/skills/story-setup/、.codex/skills/story-setup/和 OpenCode 的skills/story-setup/只有references/agent-references/、不含SKILL.md,不会是执行目录,也不要拿它们核对。ZCode / OpenClaw / Reasonix / generic 的项目副本是整份 skill 拷贝、自带SKILL.md,8 个子目录本就齐全,照常核对即可。
.story-deployed)
agents_version 缺失、非整数或小于 25 → 标记为待更新,继续执行当前部署agents_version: 25 → 使用 AskUserQuestion 确认是否重新部署;提示里写明重新部署只用当前本地 skill 包刷新项目文件,要拿 skill 本身的新版本得先更新 oh-story-claudecode(npx skills add 或 marketplace),再回来重跑agents_version 大于 25 → 当前 story-setup 比项目部署旧;停止以避免降级覆盖,提示先更新 oh-story-claudecode,不写任何部署文件target_cli 字段。已部署项目以 sentinel 里的值为准:非空时(逗号分隔的多端组合原样保留)跳过下面第 5-12 步的环境探测与选择,直接按这些端重新部署。只有字段缺失或为空,才回落到探测。用户明确要求增删目标端时,用 AskUserQuestion 在现有值基础上改,改完的值写回 sentinel。追踪/ 子目录的目录,或用户自定义结构)
.claude/settings.local.json 是否存在
.active-book 文件是否存在
opencode.json 或 .opencode/ 是否存在
target_cli = opencode.codex/、.codex/config.toml、.codex/agents/、.codex/hooks.json、AGENTS.md 中的 Codex 段
target_cli = codex.zcode/、.zcode/config.json、zcode.json、.zcode/skills/、.zcode/commands/、AGENTS.md 中的 ZCode 段
target_cli = zcodeopenclaw.json、.openclaw/,或 AGENTS.md 中的 OpenClaw 段(标题行含 网文写作工具集(OpenClaw))
target_cli = openclaw.reasonix/、reasonix-plugin.json、REASONIX.md,或 AGENTS.md 中的 Reasonix 段(标题行含 网文写作工具集(Reasonix))
target_cli = reasonixAGENTS.md 中的通用段(标题行含 网文写作工具集(通用 Agent / Web AI))target_cli = generic第 8-10 步只认各端互斥的标记。
skills/*/SKILL.md的metadata.openclaw不作 OpenClaw 信号:13 个 skill 全都带这个字段,而 OpenClaw / Reasonix / generic 三条 skills-only 路径部署出的skills/长得一样,用它判定会把后两者一律误认成 OpenClaw。.agents/skills/同理由 Codex 与 Reasonix 共用,也不单独作准。三端真正的分辨点是各自AGENTS.md模板的标题行。
.claude/ 或 CLAUDE.md、OpenCode、Codex、ZCode、OpenClaw、Reasonix、generic 标记同时存在 → 使用 AskUserQuestion 让用户选择目标环境(选项:Claude Code / OpenCode / Codex / ZCode / OpenClaw / Reasonix / 通用 Web AI 或其他 Agent / 任意组合)target_cli = opencode,部署时创建 opencode.json 和 .opencode/target_cli = codex,部署时创建 .codex/target_cli = zcode,部署时创建 .zcode/、合并根 AGENTS.md,不创建项目 custom agentstarget_cli = openclaw,部署时复制 OpenClaw 兼容 skills 到项目 skills/target_cli = reasonix,部署时复制 skills 到项目 skills/、写入 Reasonix 版 AGENTS.md,不创建项目 custom agents/hookstarget_cli = generic,部署通用 AGENTS.md 与项目本地 skills/;不写平台专属 hooks/agentstarget_cli = claude-code,opencode,codex,zcode,openclaw,reasonix,generic 的子集(仅包含用户选择的端)使用 AskUserQuestion 确认部署位置后,依次执行。
整个 Phase 2 幂等:目录复制、文件写入和下表各合并算法重复执行结果一致。因环境原因(工具不可用、权限被拒、网络失败)中途失败时,直接从头重跑本 Phase,不需要先清理半成品;create only if absent 的用户状态文件(见下表 Owner class)不会被二次覆盖。
两列基准目录不同:Source path 相对正在执行的这份 skill 包,Target path 相对用户项目根。执行每一行(以及下面各端部署算法里的每个递归复制步骤)之前,先把通配符具体化为单个源/目标,再用本 SKILL.md 同级的 scripts/copy-path-safety.py 检查。该脚本按 Path.resolve / realpath 语义跟随已有 symlink,并在两侧都存在时用 samefile 核对文件系统对象;只转绝对路径或比较字符串不算检查完成。读取其 JSON:status: same 时 no-op,禁止复制;仅 copy_allowed: true 时可以复制;source_missing、unsafe_target_within_source 或 filesystem_identity_error 必须停止该步骤并报告。无法运行脚本时只能用当前环境的文件系统 API 做完全相同的 canonical realpath、same-object 与 target-descendant 检查;无法确认就停止,不得尝试复制。OpenClaw / Reasonix / generic 的项目副本是整份 skill 拷贝,重跑时执行的就是项目里那份;Reasonix / Codex 还可能经 .agents/skills → ../skills symlink 加载,路径文本不同也可能指向同一目录,照字面复制会把目录嵌进自身并撑满磁盘。
部署前清理自嵌套残留:{.claude,.codex,.zcode}/skills/story-setup/references/agent-references/ 与项目根 skills/story-setup/references/agent-references/ 里若多出 agent-references/ 层(可能嵌了多层),以及 skills/story-setup/skills/,整段删掉再部署,并在安装报告里列出删掉的路径。
| Source path | Target path | Owner class | Merge mode | Validation check |
|---|---|---|---|---|
skills/story-setup/references/templates/CLAUDE.md.tmpl | CLAUDE.md | user+managed | marker/section merge | contains story skill routing sections |
skills/story-setup/references/templates/hooks/ | .claude/hooks/ | story-setup managed | recursive replace | session-*.sh, detect-story-gaps.sh, validate-story-commit.sh, guard-outline-before-prose.sh, check-prose-after-write.sh, story_hook_core.js, story_hook_cli.js, lib/common.sh, lib/sentinel.sh exist;story_hook_core.js 与 OpenCode/ZCode 副本字节一致 |
skills/story-setup/references/templates/rules/*.md | .claude/rules/*.md | story-setup managed | replace | every rule contains paths frontmatter |
skills/story-setup/references/templates/agents/*.md | .claude/agents/*.md | story-setup managed | replace | 7 agent files exist |
skills/story-setup/references/agent-references/*.md | .claude/skills/story-setup/references/agent-references/*.md | story-setup managed | replace | every story-setup/references/agent-references/*.md reference resolves |
skills/story-setup/references/templates/settings-hooks.json | .claude/settings.local.json | user+managed | replace managed registrations by stable hook identity | hook JSON valid;旧 matcher 注册已迁移、当前模板命令各一份、用户 hook 保留 |
skills/story-setup/scripts/merge-claude-settings.py | 部署时执行,不复制到项目 | story-setup helper | execute | 替换已知 story hook 注册、保留用户 hooks/顶层字段,v24→v25 迁移与重复执行幂等 |
skills/story-setup/scripts/copy-path-safety.py | 每个递归复制步骤前执行,不复制到项目专用目录 | story-setup helper | execute | JSON 仅 copy_allowed: true 时允许复制;symlink 同对象 no-op;target 位于 source 内时停止 |
| generated sentinel | .story-deployed | story-setup managed | replace | contains agents_version, setup_skill_version, target_cli, resolver_strategy, references_dir |
skills/story-setup/references/opencode/AGENTS.md.tmpl | AGENTS.md | user+managed | marker/section merge | contains story skill routing sections |
skills/story-setup/references/opencode/agents/ | .opencode/agents/ | story-setup managed | replace | 7 agent files exist(replace 前按「配置 OpenCode Agent 模型」中的「保留已有模型配置」缓存现有 model:,避免覆盖用户已配模型) |
skills/story-setup/references/opencode/plugin.ts | .opencode/plugins/story-hooks.ts | story-setup managed | replace | TypeScript plugin file exists |
skills/story-setup/references/opencode/story_hook_core.js | .opencode/plugins/lib/story_hook_core.js | story-setup managed | replace | Node syntax valid;与 ZCode 副本字节一致;被 story-hooks.ts import |
skills/story-setup/references/opencode/commands/ | .opencode/commands/ | story-setup managed | replace | 13 command files exist |
skills/story-setup/references/opencode/opencode.json.patch | merge into opencode.json | user+managed | merge by plugin/permission key | plugin entry registered |
repository skills/story-setup/references/agent-references/ | skills/story-setup/references/agent-references/ | story-setup managed | replace | every reference resolves |
skills/story-setup/references/opencode/pre-commit.sh | .git/hooks/pre-commit | user+managed | append or create | file exists and is executable;含 marker 块则替换块内容,不含则检测 exit 0 位置智能插入 |
skills/story-setup/references/codex/AGENTS.md.tmpl | AGENTS.md | user+managed | marker/section merge | contains Codex story skill routing sections |
skills/story-setup/references/codex/agents/ | .codex/agents/ | story-setup managed | replace | 7 TOML agent files parse and contain name/description/developer_instructions |
skills/story-setup/references/codex/hooks/hooks.json | .codex/hooks.json | user+managed | replace managed registrations by stable hook identity | hook JSON valid; all stale direct/launcher registrations removed, current 6 registrations present exactly once |
skills/story-setup/references/codex/hooks/{story_codex_hook.py,run-story-hook.sh,run-story-hook.cmd} | .codex/hooks/ 同名文件 | story-setup managed | replace | Python/shell/cmd launcher 文件齐全 |
skills/story-setup/scripts/merge-codex-hooks.py | 部署时执行,不复制到项目 | story-setup helper | execute | 替换已知管理注册、保留用户 hooks 与未知顶层字段,结果幂等 |
skills/story-setup/references/agent-references/ | .codex/skills/story-setup/references/agent-references/ | story-setup managed | replace | every reference resolves |
skills/story-setup/references/zcode/AGENTS.md.tmpl | AGENTS.md | user+managed | marker/section merge | contains ZCode $story-* routing and solo fallback |
repository skills/{browser-cdp,story*}/ | .zcode/skills/{browser-cdp,story*}/ | story-setup managed for known skill names | replace known skill dirs only | 13 SKILL.md files exist and satisfy ZCode frontmatter limits |
skills/story-setup/references/zcode/commands/ | .zcode/commands/ | story-setup managed for known command names | replace known command files only | 13 commands have valid names/frontmatter |
skills/story-setup/references/zcode/hooks/story_zcode_hook.js | .zcode/hooks/story_zcode_hook.js | story-setup managed | replace | Node syntax valid; hook contract tests pass |
skills/story-setup/references/zcode/hooks/story_hook_core.js | .zcode/hooks/story_hook_core.js | story-setup managed | replace | Node syntax valid; hook contract tests pass |
skills/story-setup/references/zcode/config.json.patch | merge into .zcode/config.json | user+managed | merge by event+matcher+process args | JSON valid; 按「ZCode 部署算法」第 4 步 hooks 互斥分支校验——未装 oh-story 插件时 hooks.enabled=true、only supported events;已装插件时校验 .zcode/config.json 不含(或已移除)这批 oh-story hooks 注册 |
skills/story-setup/references/openclaw/AGENTS.md.tmpl | AGENTS.md | user+managed | marker/section merge | contains OpenClaw story skill routing sections |
skills/story-setup/references/generic/AGENTS.md.tmpl | AGENTS.md | user+managed | marker/section merge | contains generic story skill routing sections |
skills/story-setup/references/reasonix/AGENTS.md.tmpl | AGENTS.md | user+managed | marker/section merge | contains Reasonix story skill routing sections and solo/direct fallback |
repository skills/{browser-cdp,story*}/ | skills/{browser-cdp,story*}/ | story-setup managed for known skill names | replace known skill dirs only | 13 SKILL.md files exist; OpenClaw-compatible frontmatter |
repository skills/story-setup/references/agent-references/ | 随上一行整份 skill 拷贝落地,本行 no-op | story-setup managed | 不单独复制 | every reference resolves |
部署 opencode.json.patch 时按以下规则合并:
opencode.json(如存在),解析 JSONplugin 数组:将 ./.opencode/plugins/story-hooks.ts 加入数组,去重permission、model、provider 等),不覆盖opencode.jsonskills/story-setup/references/templates/CLAUDE.md.tmplCLAUDE.md(如已存在,按「CLAUDE.md 合并策略」处理)skills/story-setup/references/templates/hooks/ 复制到用户项目 .claude/hooks/lib/,其中:
lib/common.sh 提供 project_root、discover_active_book、discover_all_bookslib/sentinel.sh 提供 .story-deployed 字段读取.claude/hooks/*.sh 设置执行权限(chmod +x);lib/*.sh 由 hook source,不要求可执行位skills/story-setup/references/templates/rules/ 下所有 .md 文件.claude/rules/ 目录skills/story-setup/references/templates/agents/ 下所有 .md 文件.claude/agents/ 目录UPGRADING.md 的版本检测结果重新部署target_cli 含 opencode 时,覆盖 .opencode/agents/ 之前先执行下面「配置 OpenCode Agent 模型」的 Step 1 缓存现有 model:。那一步写在本节后面,但必须先跑——照顺序读到哪做到哪会先覆盖再缓存,用户已配的模型就没了。.opencode/agents/*.md 与 Codex 的 .codex/agents/*.toml 都由 references/opencode/agents/、references/codex/agents/ 下的预生成产物直接复制,这两个目录是部署的唯一来源。预生成产物由 oh-story-claudecode 仓库根的 scripts/sync-opencode.py 和 scripts/generate-codex-agents.py 维护;这两个脚本是仓库维护工具,不随 story-setup 下发,部署时不需要也无法调用。~/.zcode/agents/,plugin manifest 中的 agents 当前不执行。不要创建 .zcode/agents/ 或修改用户 home;相关 Skill 必须直接 solo/direct 并报告 fallback。story-setup/references/agent-references/*.md 这一本 skill 内复制路径;不要跨 skill 引用其他 skill 的 references。各 adapter 只使用当前规范前缀:Claude Code 为 .claude/skills/,OpenCode / OpenClaw / Reasonix / generic 为 skills/,Codex 为 .codex/skills/,ZCode 为 .zcode/skills/;不在运行时遍历历史备选路径。skills/story-setup/references/agent-references/ 下所有 .md 复制到项目内 .claude/skills/story-setup/references/agent-references/story-setup/references/agent-references/<file>.md,源包与目标包都必须存在 <file>.mdskills/story-setup/references/codex/agents/ 下所有 .toml 文件,复制到用户项目 .codex/agents/references/codex/agents/ 里的 TOML 由仓库根的 scripts/generate-codex-agents.py 从 Claude agent 模板确定性生成后提交入库,部署只做复制name、description、developer_instructionschapter-extractor、consistency-checker、story-explorer)必须保留 sandbox_mode = "read-only"unknown agent_type,调用方必须降级 solo/direct 并报告 fallback。skills/story-setup/references/agent-references/ 同步复制到 .codex/skills/story-setup/references/agent-references/,作为 Codex agent 的项目内参考资料主路径仅当
target_cli含opencode时执行。OpenCode 子代理不指定模型时继承主模型,导致低成本 Agent 也消耗主模型额度。此步骤自动检测用户模型并写入model:字段。
.opencode/agents/ 的 replace 之前执行)OpenCode agents 部署是 replace,会覆盖上次写入的 model:。所以在执行该 replace 之前先扫描现有 .opencode/agents/*.md,缓存每个 agent 的 model:(agent 名 → 模型 ID)。后续检测失败/超时、或用户跳过某一级时,用缓存值回填,避免把用户上次配好的低成本模型抹成主模型。若 replace 已先发生、缓存为空,则按全新部署处理,并在安装报告中提示"未能保留上次模型配置"。
优先执行 opencode models --verbose,它输出含 cost(input/output/cache 单价)、context、capabilities 的 metadata;不可用或解析失败时回退到 opencode models 纯文本(每行 provider/model)。两者都用 60000ms(60 秒)超时,因为首次运行需加载 models.dev 缓存。
model:、跳过自动配置,在安装报告中输出手动配置指南优先按成本分级(有 --verbose 时):按每模型实际 cost 从低到高分档——低端取最便宜/免费档、中端取中价档、高端取最贵或上下文/能力最强档。免费模型按真实 cost=0 归低端,不按名字里的营销词(如 nemotron-3-ultra-free 名含 ultra 但 cost=0,应归低端)。无 cost 数据的模型也据此进入候选,不被丢弃。
回退按关键词分级(无 --verbose 或无 cost 时):按模型 ID 中最后一个 / 之后的模型名按 -、.、_ 分割为段,逐段精确匹配关键词(不区分大小写)。例如 minimax-m3 拆为 [minimax, m3],不匹配 mini 也不匹配 max;claude-haiku-4.5 拆为 [claude, haiku, 4, 5],匹配 haiku。关键词分级是启发式,安装报告中标注 分级依据:关键词(heuristic)。
| 等级 | 匹配关键词 | 对应 Agent |
|---|---|---|
| 低端 | haiku, flash, mini, nano, lite | chapter-extractor, consistency-checker, story-explorer |
| 中端 | sonnet, plus | story-researcher, narrative-writer, character-designer |
| 高端 | opus, pro, ultra, max | story-architect |
按 低端 → 中端 → 高端 顺序,每级用 AskUserQuestion 让用户选择。
低端选项结构:
问题:"为低成本 Agent(chapter-extractor, consistency-checker, story-explorer)选择模型:"
选项:
- provider/model-id
- provider/model-id
- 自定义输入(手动输入完整模型 ID,ID 拼写错误要到运行时才会暴露)
- 跳过,使用主模型(成本可能较高)
中端选项结构:
问题:"为写作质量关键 Agent(narrative-writer, character-designer, story-researcher)选择模型:"
选项:
- provider/model-id
- provider/model-id
- 自定义输入(请勿使用低端模型,会影响正文质量;ID 拼写错误要到运行时才会暴露)
- 跳过,使用主模型(主模型质量通常足够)
高端选项结构:
问题:"为总指挥 Agent(story-architect)选择模型:"
选项:
- provider/model-id
- provider/model-id
- 自定义输入(手动输入完整模型 ID,ID 拼写错误要到运行时才会暴露)
- 跳过,使用主模型(成本可能较高)
规则:
自定义输入、保留现有模型(「保留已有模型配置」缓存到该 agent 的 model,无则不显示此项)、跳过,用主模型。候选为 0 时仍弹窗,并在问题说明里给出对应警告 + 列出未分级/未入档模型供参考——不再静默跳过交互(否则用户够不到自定义输入)。自定义输入:用户输入 provider/model-id 完整 ID;写入前校验为单行、无控制字符、匹配 ^[A-Za-z0-9._-]+/[A-Za-z0-9._:+-]+$,不符则提示重输或改选跳过。保留现有模型:写回「保留已有模型配置」缓存的该 agent model(重新部署时保住用户上次配置),不算"跳过"。跳过,用主模型:显式清除——不写该 agent 的 model:,agent 继承主模型。想保留上次配置请选 保留现有模型。对应用户选择的 agent 文件(.opencode/agents/*.md,由部署清单中 OpenCode agents 部署步骤在此步骤之前已部署),在 frontmatter 末尾、closing --- 之前,以零缩进的顶层字段插入 model:(不要插进 permission: 等多行 map 的缩进块内部)。值含 YAML 特殊字符时加引号,确保不破坏 frontmatter:
---
description: ...
mode: subagent
permission:
read: allow
edit: deny
steps: 12
model: provider/model-id
---
model: 字段(重新部署场景),替换该顶层 model: 的值,不新增重复键保留现有模型:写回「保留已有模型配置」缓存的该 agent model跳过,用主模型:不写入 model: 字段model:,避免 replace 抹掉用户上次配置for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done;无可用解释器时停止,不手写或简化合并。"$PYBIN" "{story-setup skill目录}/scripts/merge-claude-settings.py" --existing "{项目}/.claude/settings.local.json" --template "{story-setup skill目录}/references/templates/settings-hooks.json" --output "{项目}/.claude/settings.local.json"。Codex 项目 hooks 部署到 .codex/hooks.json;运行脚本部署到 .codex/hooks/story_codex_hook.py、run-story-hook.sh、run-story-hook.cmd。JSON 只负责定位项目根与传递 event,解释器探测由平台 launcher 统一处理。
references/codex/hooks/hooks.json 作为唯一当前模板,读取项目 .codex/hooks.json(不存在时视为空对象)。for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done;无可用解释器时停止,不手写或简化 JSON 合并。"$PYBIN" "{story-setup skill目录}/scripts/merge-codex-hooks.py" --existing "{项目}/.codex/hooks.json" --template "{story-setup skill目录}/references/codex/hooks/hooks.json" --output "{项目}/.codex/hooks.json"。该 helper 会识别旧直调 story_codex_hook.py、当前 run-story-hook.sh 和 run-story-hook.cmd 三类管理身份,先移除所有已知管理注册,再追加当前模板。command 字符串追加去重,否则 v17 直调命令会与 v18 launcher 双重注册。story_codex_hook.py 命令数为 0,当前模板 6 个注册各存在且仅存在一次,用户 hook 与未知顶层字段仍在。然后提示用户:项目 .codex/ 层需要被 Codex trust,非 managed command hooks 还需要在 /hooks 中 review/trust 后才会运行;Windows 下走 commandWindows,launcher 从当前目录向上定位项目 .codex/hooks/,与 POSIX 路径的嵌套目录行为一致。ZCode 首版部署 Skills、Commands、AGENTS.md 和支持事件内的 Hooks;不部署 .zcode/agents 或 .zcode/rules。
skills/ 下 13 个包含 SKILL.md 的目录到 .zcode/skills/{skill-name}/;仅替换这些已知目录,保留用户其他 Skills。references/zcode/commands/*.md 到 .zcode/commands/;仅替换 13 个同名命令,保留用户其他 Commands。references/zcode/hooks/story_zcode_hook.js 和 references/zcode/hooks/story_hook_core.js 到 .zcode/hooks/。references/zcode/config.json.patch 和现有 .zcode/config.json(如只有根 zcode.json,仍创建 .zcode/config.json 承载 oh-story 项目 Hooks,不改写根文件):
.zcode-plugin/plugin.json 的 hooks.json 已全局注册 SessionStart/PreToolUse/PostToolUse),则跳过下面把 config.json.patch 的 hooks 块合并进 .zcode/config.json——插件 manifest 已注册这批 hooks,再合并会让同一事件跑两遍(PreToolUse 拦两次、PostToolUse 注入两次)。只有未装插件(直接克隆 / 手动导入 references)时才合并 hooks。不确定时以「ZCode 是否已通过本插件注册这套 hooks」为准;skills/commands/hook 文件/AGENTS 与 config 的非 hook 字段两条路径都照常部署。hooks.enabled: true;用户已有更大的 timeoutMs 时保留,否则取模板值;对 hooks.events 的 SessionStart、PreToolUse、PostToolUse 按 event + matcher + process command + args 去重追加;不复制 ZCode 不支持的 PreCompact、PostCompact、SessionEnd、SubagentStop、Notification。references/zcode/AGENTS.md.tmpl 按「AGENTS.md 合并策略」写入根 AGENTS.md。.story-deployed 的 target_cli 写入 zcode 或多端组合,references_dir 写 .zcode/skills/story-setup/references/agent-references。node 命令运行项目 Hook。Plugin 安装不经过本算法:仓库根 .zcode-plugin/plugin.json 直接暴露同一组 Skills/Commands/Hooks。Plugin Skills 优先级低于 workspace .zcode/skills;两者同时存在时项目快照优先,升级项目快照需重新运行 $story-setup。Hooks 只能注册一份:插件 manifest 与 workspace .zcode/config.json 注册的是同一批事件,装了插件就不要再把 config.json.patch 的 hooks 合并进 .zcode/config.json(见上算法第 4 步的 hooks 互斥),否则 PreToolUse/PostToolUse 会双触发;插件在场时以插件 manifest 为 hooks 唯一注册源。
OpenClaw Phase 1 只部署 skills,不部署 OpenClaw agents/hooks/plugin。
skills/ 下所有包含 SKILL.md 的 story skill 目录(13 个:browser-cdp 与 story*)。skills/{skill-name}/,仅替换这些 story-setup 管理的已知 skill 目录;保留用户在 skills/ 下的其他目录。SKILL.md 必须满足 OpenClaw frontmatter 约束:name / description 是单行键值,metadata 是单行 JSON 对象且含 metadata.openclaw。skills/story-setup/references/openclaw/AGENTS.md.tmpl 到项目 AGENTS.md,按「AGENTS.md 合并策略」合并。.story-deployed 的 target_cli 写入 openclaw 或多端组合;references_dir 对 OpenClaw 写 skills/story-setup/references/agent-references。Reasonix(DeepSeek-Reasonix CLI)当前只部署 skills 与 AGENTS.md,不部署 Reasonix hooks/custom agents(hook I/O 契约与子代理行为缺少可校验的真实 CLI,留待后续阶段)。
skills/ 下所有包含 SKILL.md 的 story skill 目录(13 个:browser-cdp 与 story*)到目标项目 skills/{skill-name}/;仅替换这些 story-setup 管理的已知 skill 目录,保留用户其他目录。.agents/skills → ../skills 相对 symlink(与 Codex 共用的 skill root),使 Reasonix 原生扫描 .agents/skills 时发现这些 skill;若已是指向 skills/ 的 symlink 则保留,若被占用为普通目录则不覆盖并在安装报告提示。Windows 未启用 symlink 时跳过本步,改走根 reasonix-plugin.json 的 reasonix plugin install。skills/story-setup/references/reasonix/AGENTS.md.tmpl 到项目 AGENTS.md,按「AGENTS.md 合并策略」合并。.story-deployed 的 target_cli 写入 reasonix 或多端组合;references_dir 对 Reasonix 写 skills/story-setup/references/agent-references。通用路径面向 NarraFork、Web AI、自定义 Agent 等可读取项目文件的环境,只部署通用文件,不声明平台原生 hooks/agents 能力。
skills/ 下所有包含 SKILL.md 的 story skill 目录(13 个:browser-cdp 与 story*)到目标项目 skills/{skill-name}/;仅替换这些 story-setup 管理的已知 skill 目录,保留用户其他目录。skills/story-setup/references/generic/AGENTS.md.tmpl 到项目 AGENTS.md,按「AGENTS.md 合并策略」合并。.story-deployed 的 target_cli 写入 generic 或多端组合;references_dir 对 generic 写 skills/story-setup/references/agent-references。.story-deployed 文件(sentinel file)key: value 格式,hook 用 references/templates/hooks/lib/sentinel.sh 读取):
deployed_at: <date -u +"%Y-%m-%dT%H:%M:%SZ">
agents_version: 25
setup_skill_version: 1.2.7
target_cli: claude-code(或 opencode、codex、zcode、openclaw、reasonix、generic,或其任意组合)
resolver_strategy: project-local-skill-reference
references_dir: .claude/skills/story-setup/references/agent-references(Codex 写 .codex/skills/...;ZCode 写 .zcode/skills/...;OpenClaw / Reasonix / generic 写 skills/...;多端用逗号分隔)
.claude/.agents-pending-restart(空文件即可)。session-start.sh 在下一个会话启动时据此确认 agents 已随新会话注册,并自动删除该标记——用来向用户确认「重启已生效」。ZCode 不创建该标记,因为它不部署项目 agents。.story-deployed 已存在但 agents_version 缺失、非整数或小于 25,按本次流程更新 hooks/agents/rules/reference bundle(具体变更见 UPGRADING.md);大于 25 时已在 Phase 1 停止,不得降级覆盖.claude/settings.local.json 中的 hooks 字段是否正确.claude/hooks/ 下的脚本是否存在且有执行权限.claude/hooks/lib/common.sh 与 .claude/hooks/lib/sentinel.sh 是否存在.claude/rules/ 下的规则文件是否存在且包含 paths frontmatter.claude/agents/ 下的 7 个 agent 定义文件是否存在.claude/skills/story-setup/references/agent-references/ 下 reference 文件完整story-setup/references/agent-references/<file>.md 都能解析到 deployed bundle.story-deployed 是否存在且包含时间戳、agents_version: 25、setup_skill_version: 1.2.7、target_cli、resolver_strategy、references_dir.claude/agents/,但这些 custom agent 只在「会话启动」时才会被 Claude Code 注册成 subagent_type。请新开一个 Claude Code 会话再开始写作,否则当前会话里 story-review / story-long-write 等想 spawn story-architect、narrative-writer 等时会拿到「subagent_type 不可用」并降级 solo(单视角,失去多 agent 协作)。判断是否生效:新会话里跑 /story-review,报告头若是 Effective Mode: full/lean 即注册成功;若是 Fallback: ... -> solo 说明还在旧会话或未注册。/story-long-write 或 /story-short-writeAgent 模型配置:
story-architect → <高端模型>(provider/model-id)
narrative-writer → <中端模型>(provider/model-id)
character-designer → <中端模型>(provider/model-id)
story-researcher → <中端模型>(provider/model-id)
chapter-extractor → <低端模型>(provider/model-id)
consistency-checker → <低端模型>(provider/model-id)
story-explorer → <低端模型>(provider/model-id)
opencode models 不可用),输出手动配置指南:
无法自动检测模型列表。以下 Agent 未配置模型,将使用主模型,成本可能较高:
- chapter-extractor(建议使用低成本模型)
- consistency-checker(建议使用低成本模型)
- story-explorer(建议使用低成本模型)
手动配置方法:编辑 .opencode/agents/{agent名}.md,在 frontmatter 中添加:
model: provider/model-id
可用模型列表与成本可通过 opencode models --verbose 查看(输出含每模型 cost/context)。
模型库与定价见 OpenCode 官方模型源 https://models.dev/。
.opencode/agents/ 下的 7 个 agent 定义文件是否存在,且 frontmatter 包含 mode: subagent 和 permission 字段.opencode/plugins/story-hooks.ts 是否存在.opencode/plugins/lib/story_hook_core.js 存在且 node --check 通过(story-hooks.ts import 之,与 .zcode 副本字节一致的共享写正文守卫核;置于 lib/ 子目录以避开 OpenCode 单层 .opencode/plugins/*.js 插件自动发现).opencode/commands/ 下的 13 个 command 文件是否存在skills/story-setup/references/agent-references/ 下 reference 文件完整且数量与源目录一致opencode.json 的 plugin 数组是否包含 story-hooks 条目.git/hooks/pre-commit 是否存在且有执行权限(Windows 上跳过执行权限检查).opencode/agents/ 下 agent 文件 frontmatter 可被 YAML 解析、model:(如有配置)是合法顶层标量,而非仅 grep 到 model: 子串AGENTS.md 含 Codex story skill routing sections.codex/agents/ 下 7 个 .toml agent 定义文件存在并可解析.codex/hooks.json 存在且 JSON 有效,Unix command 仅通过 run-story-hook.sh 启动,Windows commandWindows 仅通过 run-story-hook.cmd 启动;不存在直调 story_codex_hook.py 的注册.codex/hooks/story_codex_hook.py、run-story-hook.sh、run-story-hook.cmd 存在,Python 语法有效,POSIX/Windows launcher 能从嵌套 cwd 定位项目根.codex/skills/story-setup/references/agent-references/ 下 reference 文件完整且数量与源目录一致.codex/ 配置层,并在 /hooks review/trust 非 managed hooks;部署后新开 Codex 会话让 custom agents 生效;若当前运行时仍返回 unknown agent_type,按各 skill 的 fallback 规则降级 solo/directAGENTS.md 含 ZCode $story-* 路由、大纲守卫和 solo/direct fallback.zcode/skills/ 下 13 个 Skills 与 .zcode/commands/ 下 13 个 Commands,验证 frontmatter 和命名.zcode/hooks/story_zcode_hook.js、.zcode/hooks/story_hook_core.js 存在且 node --check 通过.zcode/config.json JSON 有效,并按「ZCode 部署算法」第 4 步的 hooks 互斥分支校验:未装 oh-story 插件时,hooks.enabled=true、仅注册 ZCode 支持事件、所有 process args 指向项目 Hook;已装 oh-story 插件(.zcode-plugin/plugin.json 已全局注册这批 hooks)时,改为校验 .zcode/config.json 不含(或已移除)这批 oh-story hooks 注册——不得为了让校验通过而把 config.json.patch 的 hooks 块合并回去,否则同一事件双触发.zcode/skills/story-setup/references/agent-references/ 完整且所有 reference 路径可解析node;部署后新开 ZCode session 刷新 Skills/Commands/AGENTS.mdAGENTS.md 含 OpenClaw story skill routing sectionsskills/ 下 13 个 story skill 目录存在,且每个 SKILL.md 包含单行 name、单行 description、单行 JSON metadata.openclawskills/story-setup/references/agent-references/ 下 reference 文件完整且数量与源目录一致AGENTS.md 含通用 story skill routing sectionsskills/ 下 13 个 story skill 目录存在,且每个 SKILL.md 可读skills/story-setup/references/agent-references/ 下 reference 文件完整且数量与源目录一致AGENTS.md 含 Reasonix story skill routing sections 与 solo/direct fallback 说明skills/ 下 13 个 story skill 目录存在,且每个 SKILL.md 可读.agents/skills 为指向 skills/ 的 symlink(POSIX;使 Reasonix 原生扫描发现 skill);Windows 未建 symlink 时改为确认根 reasonix-plugin.json 可用于 reasonix plugin installskills/story-setup/references/agent-references/ 下 reference 文件完整且数量与源目录一致reasonix doctor capabilities 校验 skill 发现,部署后如未显示新 skills,新开 Reasonix session 或走根 reasonix-plugin.json 原生 plugin 安装| 占位符 | 替换规则 | 示例 |
|---|---|---|
{项目名} | 用户项目名称或目录名 | 《剑来》、《暗卫》 |
{书名} | 书名目录名(与目录一致) | 与 {项目名} 相同,或用户自定义 |
{目标平台} | 目标发布平台 | 起点、番茄、晋江、知乎盐言 |
{作者名} | 用户笔名或昵称 | 未指定时用「作者」 |
替换时去掉花括号。如果用户未指定项目名,用当前目录名。未指定的占位符保留原样不替换。
用户已有 CLAUDE.md 时,按 marker/section 合并:
## 标题切分为 section map用户已有 AGENTS.md 时,按 marker/section 合并:
## 标题切分为 section mapskills/story-setup/references/opencode/AGENTS.md.tmpl;Codex 使用 skills/story-setup/references/codex/AGENTS.md.tmpl;ZCode 使用 skills/story-setup/references/zcode/AGENTS.md.tmpl;OpenClaw 使用 skills/story-setup/references/openclaw/AGENTS.md.tmpl;Reasonix 使用 skills/story-setup/references/reasonix/AGENTS.md.tmpl;通用 Web AI / 其他 Agent 使用 skills/story-setup/references/generic/AGENTS.md.tmpl.story-deployed 不存在 → 全新安装,Phase 2 全部执行.story-deployed 存在且 agents_version: 25 → 提示已部署,AskUserQuestion 确认是否重新部署;提示里写明重新部署只用当前本地 skill 包刷新项目文件,skill 本身的更新走 npx skills add 或 marketplace.story-deployed 存在但 agents_version 缺失、非整数或小于 25 → 提示需要更新,重新执行 Phase 2 覆盖 agents/hooks/rules/reference bundle,CLAUDE.md / AGENTS.md / settings.local.json / .codex/hooks.json / .zcode/config.json 走合并策略.story-deployed 存在且 agents_version 大于 25 → 当前 skill 版本过旧,停止并提示先更新 oh-story-claudecode;不覆盖项目中的更新部署| 文件 | 用途 |
|---|---|
| references/templates/hooks/ | 8 个 hook 脚本模板 + story_hook_core.js(正文网/字数/大纲守卫/连续性/commit 侦测的共享实现,与 OpenCode/ZCode 同一份)+ story_hook_cli.js(bash hook 调核的 node 桥)+ lib/common.sh/lib/sentinel.sh(正文兜底 check-prose-after-write.sh 限 PostToolUse Write/Edit;cat>/tee 等 Bash 写正文由 Codex Stop 回合末 git 扫描兜,Claude/OpenCode 的 Bash 仅 pre-guard) |
| references/zcode/ | ZCode AGENTS、13 Commands、workspace config patch 与严格 JSON Hook runner |
流水线: 部署 位置: 初始化(最前置)
| 时机 | 跳转到 | 命令 |
|---|---|---|
| 部署完成,开始写作 | story-long-write / story-short-write | /story-long-write 或 /story-short-write |
| 导入已有小说做拆解 | story-import | /story-import |
| 需要浏览器登录态(扫榜/拆文取原文) | browser-cdp | /browser-cdp;generic 需平台允许本地脚本/浏览器控制 |
各端调用语法:Claude /名、Codex/ZCode $名、OpenClaw /skill 名、Reasonix / generic 直接点名 skill。
评论 (0)
暂无评论,成为第一个评论者吧!