story-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesestory-setup:网文写作工具集基础设施部署
story-setup: Infrastructure Deployment for Web Novel Writing Toolset
你是写作基础设施部署器。将网文写作工具集部署到用户项目目录:已适配的 CLI 走专用 hooks/agents/config;NarraFork、Web AI、自定义 Agent 等环境走通用文件模式。
执行铁律:不覆盖用户已有配置,合并而非替换。
You are the writing infrastructure deployer. Deploy the web novel writing toolset to the user's project directory: Adapted CLIs use dedicated hooks/agents/config; environments like NarraFork, Web AI, and custom Agents use the general file mode.
Iron Rule of Execution: Do not overwrite existing user configurations, merge instead of replacing.
Phase 1:检测项目状态
Phase 1: Detect Project Status
先自检参考目录:以正在执行的本 所在目录为准,列出与它同级的 下的子目录,核对下面 8 个名字是否都在且都非空——、、、、、、、;同级 、 与 也必须存在(Claude/Codex hooks 合并和递归复制安全检查依赖它们)。有缺即 skill 包没装全,立即停止,不写任何部署文件,报告里区分「缺目录」「目录为空」和「缺脚本」,并给修复指令:「story-setup 参考资料包不完整,缺 {路径}。按你的安装方式重装 oh-story-claudecode(命令行装的重跑 ,marketplace / Plugin Management 装的在面板里重装),再执行 /story-setup。」
SKILL.mdreferences/agent-referencestemplatesopencodecodexzcodeopenclawreasonixgenericscripts/merge-claude-settings.pyscripts/merge-codex-hooks.pyscripts/copy-path-safety.pynpx skills add zenstory-ai/oh-story-claudecode -y -g判据是「有没有」:只看正在执行的SKILL.md同级的SKILL.md。项目内references/、.claude/skills/story-setup/和 OpenCode 的.codex/skills/story-setup/只有skills/story-setup/、不含references/agent-references/,不会是执行目录,也不要拿它们核对。ZCode / OpenClaw / Reasonix / generic 的项目副本是整份 skill 拷贝、自带SKILL.md,8 个子目录本就齐全,照常核对即可。SKILL.md
- 检查当前目录是否已部署过(存在 )
.story-deployed- 缺失、非整数或小于
agents_version→ 标记为待更新,继续执行当前部署25 - → 使用 AskUserQuestion 确认是否重新部署;提示里写明重新部署只用当前本地 skill 包刷新项目文件,要拿 skill 本身的新版本得先更新 oh-story-claudecode(
agents_version: 25或 marketplace),再回来重跑npx skills add - 大于
agents_version→ 当前 story-setup 比项目部署旧;停止以避免降级覆盖,提示先更新 oh-story-claudecode,不写任何部署文件25 - 同时读 字段。已部署项目以 sentinel 里的值为准:非空时(逗号分隔的多端组合原样保留)跳过下面第 5-12 步的环境探测与选择,直接按这些端重新部署。只有字段缺失或为空,才回落到探测。用户明确要求增删目标端时,用 AskUserQuestion 在现有值基础上改,改完的值写回 sentinel。
target_cli
- 检查是否有书名目录(包含 子目录的目录,或用户自定义结构)
追踪/- 有 → 识别为长篇项目,显示当前项目信息
- 无 → 识别为新项目或短篇项目
- 检查 是否存在
.claude/settings.local.json- 存在 → 读取现有配置,后续合并
- 不存在 → 后续创建新文件
- 检查 文件是否存在
.active-book- 存在 → 显示当前活跃书目
- 不存在 → 跳过
- 检查 或
opencode.json是否存在.opencode/- 存在 → 识别为 opencode 项目,
target_cli = opencode - 不存在 → 跳过
- 存在 → 识别为 opencode 项目,
- 检查 、
.codex/、.codex/config.toml、.codex/agents/、.codex/hooks.json中的 Codex 段AGENTS.md- 存在 → 识别为 Codex 项目,
target_cli = codex - 不存在 → 跳过
- 存在 → 识别为 Codex 项目,
- 检查 、
.zcode/、.zcode/config.json、zcode.json、.zcode/skills/、.zcode/commands/中的 ZCode 段AGENTS.md- 存在 → 识别为 ZCode 项目,
target_cli = zcode - 不存在 → 跳过
- 存在 → 识别为 ZCode 项目,
- 检查 、
openclaw.json,或.openclaw/中的 OpenClaw 段(标题行含AGENTS.md)网文写作工具集(OpenClaw)- 存在 → 识别为 OpenClaw 项目,
target_cli = openclaw - 不存在 → 跳过
- 存在 → 识别为 OpenClaw 项目,
- 检查 、
.reasonix/、reasonix-plugin.json,或REASONIX.md中的 Reasonix 段(标题行含AGENTS.md)网文写作工具集(Reasonix)- 存在 → 识别为 Reasonix 项目,
target_cli = reasonix - 不存在 → 跳过
- 存在 → 识别为 Reasonix 项目,
- 检查 中的通用段(标题行含
AGENTS.md)网文写作工具集(通用 Agent / Web AI)
- 存在 → 识别为通用 Web AI 项目,
target_cli = generic - 不存在 → 跳过
第 8-10 步只认各端互斥的标记。的skills/*/SKILL.md不作 OpenClaw 信号:13 个 skill 全都带这个字段,而 OpenClaw / Reasonix / generic 三条 skills-only 路径部署出的metadata.openclaw长得一样,用它判定会把后两者一律误认成 OpenClaw。skills/同理由 Codex 与 Reasonix 共用,也不单独作准。三端真正的分辨点是各自.agents/skills/模板的标题行。AGENTS.md
- 如 或
.claude/、OpenCode、Codex、ZCode、OpenClaw、Reasonix、generic 标记同时存在 → 使用 AskUserQuestion 让用户选择目标环境(选项:Claude Code / OpenCode / Codex / ZCode / OpenClaw / Reasonix / 通用 Web AI 或其他 Agent / 任意组合)CLAUDE.md - 如七类标记都不存在(全新项目)→ 使用 AskUserQuestion 让用户选择目标环境
- 用户选择 opencode → ,部署时创建
target_cli = opencode和opencode.json.opencode/ - 用户选择 claude-code → 按现有逻辑处理
- 用户选择 codex → ,部署时创建
target_cli = codex.codex/ - 用户选择 zcode → ,部署时创建
target_cli = zcode、合并根.zcode/,不创建项目 custom agentsAGENTS.md - 用户选择 openclaw → ,部署时复制 OpenClaw 兼容 skills 到项目
target_cli = openclawskills/ - 用户选择 reasonix → ,部署时复制 skills 到项目
target_cli = reasonix、写入 Reasonix 版skills/,不创建项目 custom agents/hooksAGENTS.md - 用户选择通用 Web AI / 其他 Agent → ,部署通用
target_cli = generic与项目本地AGENTS.md;不写平台专属 hooks/agentsskills/ - 用户选择多端 → 的子集(仅包含用户选择的端)
target_cli = claude-code,opencode,codex,zcode,openclaw,reasonix,generic
First self-check reference directory: Based on the directory where this executing is located, list the subdirectories under the sibling , and verify that all 8 names below exist and are non-empty — , , , , , , , ; the sibling , and must also exist (they are dependencies for merging Claude/Codex hooks and recursive copy safety checks). If any are missing, the skill package is not fully installed, stop immediately without writing any deployment files, distinguish between "missing directory", "empty directory" and "missing script" in the report, and provide repair instructions: "The story-setup reference package is incomplete, missing {path}. Reinstall oh-story-claudecode according to your installation method (run again if installed via command line, reinstall via the panel if installed via marketplace / Plugin Management), then execute /story-setup."
SKILL.mdreferences/agent-referencestemplatesopencodecodexzcodeopenclawreasonixgenericscripts/merge-claude-settings.pyscripts/merge-codex-hooks.pyscripts/copy-path-safety.pynpx skills add zenstory-ai/oh-story-claudecode -y -gThe criterion is "whetherexists": Only check theSKILL.mdat the same level as the executingreferences/. The project'sSKILL.md,.claude/skills/story-setup/and OpenCode's.codex/skills/story-setup/only haveskills/story-setup/and do not containreferences/agent-references/, so they will not be the execution directory, and do not use them for verification. The project copies of ZCode / OpenClaw / Reasonix / generic are full skill copies with their ownSKILL.md, and the 8 subdirectories are complete, so verify as usual.SKILL.md
-
Check if the current directory has been deployed (exists)
.story-deployed- is missing, non-integer or less than
agents_version→ Mark as pending update, continue with current deployment25 - → Use AskUserQuestion to confirm whether to redeploy; clearly state in the prompt that redeployment only refreshes project files using the current local skill package, to get a new version of the skill itself, you need to update oh-story-claudecode first (via
agents_version: 25or marketplace), then run /story-setup againnpx skills add - is greater than
agents_version→ The current story-setup is older than the project deployment; stop to avoid downgrade overwriting, prompt to update oh-story-claudecode first, do not write any deployment files25 - At the same time, read the field. For deployed projects, follow the value in the sentinel: When non-empty (multi-end combination separated by commas is retained as-is), skip steps 5-12 below for environment detection and selection, and redeploy directly according to these ends. Only when the field is missing or empty, fall back to detection. When the user explicitly requests to add or remove target ends, use AskUserQuestion to modify based on the existing value, and write the modified value back to the sentinel.
target_cli
-
Check if there is a book title directory (a directory containing asubdirectory, or a user-defined structure)
追踪/- Exists → Identify as a long-form project, display current project information
- Does not exist → Identify as a new project or short-form project
-
Check ifexists
.claude/settings.local.json- Exists → Read existing configuration, merge later
- Does not exist → Create a new file later
-
Check iffile exists
.active-book- Exists → Display current active book title
- Does not exist → Skip
-
Check ifor
opencode.jsonexists.opencode/- Exists → Identify as an opencode project,
target_cli = opencode - Does not exist → Skip
- Exists → Identify as an opencode project,
-
Check,
.codex/,.codex/config.toml,.codex/agents/, Codex section in.codex/hooks.jsonAGENTS.md- Exists → Identify as a Codex project,
target_cli = codex - Does not exist → Skip
- Exists → Identify as a Codex project,
-
Check,
.zcode/,.zcode/config.json,zcode.json,.zcode/skills/, ZCode section in.zcode/commands/AGENTS.md- Exists → Identify as a ZCode project,
target_cli = zcode - Does not exist → Skip
- Exists → Identify as a ZCode project,
-
Check,
openclaw.json, or OpenClaw section in.openclaw/(title line contains "网文写作工具集(OpenClaw)")AGENTS.md- Exists → Identify as an OpenClaw project,
target_cli = openclaw - Does not exist → Skip
- Exists → Identify as an OpenClaw project,
-
Check,
.reasonix/,reasonix-plugin.json, or Reasonix section inREASONIX.md(title line contains "网文写作工具集(Reasonix)")AGENTS.md- Exists → Identify as a Reasonix project,
target_cli = reasonix - Does not exist → Skip
- Exists → Identify as a Reasonix project,
-
Check the general section in(title line contains "网文写作工具集(通用 Agent / Web AI)")
AGENTS.md- Exists → Identify as a general Web AI project,
target_cli = generic - Does not exist → Skip
Steps 8-10 only recognize mutually exclusive markers for each end.inmetadata.openclawis not used as an OpenClaw signal: All 13 skills have this field, and theskills/*/SKILL.mddeployed by the three skills-only paths of OpenClaw / Reasonix / generic look the same, so using it to judge will misidentify the latter two as OpenClaw.skills/is also shared by Codex and Reasonix, so it is not used alone. The real distinguishing point for the three ends is the title line of their respective.agents/skills/templates.AGENTS.md - Exists → Identify as a general Web AI project,
-
Ifor
.claude/, OpenCode, Codex, ZCode, OpenClaw, Reasonix, and generic markers exist at the same time → Use AskUserQuestion to let the user select the target environment (options: Claude Code / OpenCode / Codex / ZCode / OpenClaw / Reasonix / General Web AI or other Agent / Any combination)CLAUDE.md -
If none of the seven types of markers exist (brand new project) → Use AskUserQuestion to let the user select the target environment
- User selects opencode → , create
target_cli = opencodeandopencode.jsonduring deployment.opencode/ - User selects claude-code → Process according to existing logic
- User selects codex → , create
target_cli = codexduring deployment.codex/ - User selects zcode → , merge root
target_cli = zcodeduring deployment, do not create project custom agentsAGENTS.md - User selects openclaw → , copy OpenClaw-compatible skills to project
target_cli = openclawduring deploymentskills/ - User selects reasonix → , copy skills to project
target_cli = reasonixand write Reasonix versionskills/during deployment, do not create project custom agents/hooksAGENTS.md - User selects General Web AI / other Agent → , deploy general
target_cli = genericand project localAGENTS.md; do not write platform-specific hooks/agentsskills/ - User selects multiple ends → (only includes the ends selected by the user)
target_cli = subset of claude-code,opencode,codex,zcode,openclaw,reasonix,generic
- User selects opencode →
Phase 2:部署基础设施
Phase 2: Deploy Infrastructure
使用 AskUserQuestion 确认部署位置后,依次执行。
整个 Phase 2 幂等:目录复制、文件写入和下表各合并算法重复执行结果一致。因环境原因(工具不可用、权限被拒、网络失败)中途失败时,直接从头重跑本 Phase,不需要先清理半成品; 的用户状态文件(见下表 Owner class)不会被二次覆盖。
create only if absent两列基准目录不同: 相对正在执行的这份 skill 包, 相对用户项目根。执行每一行(以及下面各端部署算法里的每个递归复制步骤)之前,先把通配符具体化为单个源/目标,再用本 同级的 检查。该脚本按 / 语义跟随已有 symlink,并在两侧都存在时用 核对文件系统对象;只转绝对路径或比较字符串不算检查完成。读取其 JSON: 时 no-op,禁止复制;仅 时可以复制;、 或 必须停止该步骤并报告。无法运行脚本时只能用当前环境的文件系统 API 做完全相同的 canonical realpath、same-object 与 target-descendant 检查;无法确认就停止,不得尝试复制。OpenClaw / Reasonix / generic 的项目副本是整份 skill 拷贝,重跑时执行的就是项目里那份;Reasonix / Codex 还可能经 symlink 加载,路径文本不同也可能指向同一目录,照字面复制会把目录嵌进自身并撑满磁盘。
Source pathTarget pathSKILL.mdscripts/copy-path-safety.pyPath.resolverealpathsamefilestatus: samecopy_allowed: truesource_missingunsafe_target_within_sourcefilesystem_identity_error.agents/skills → ../skills部署前清理自嵌套残留: 与项目根 里若多出 层(可能嵌了多层),以及 ,整段删掉再部署,并在安装报告里列出删掉的路径。
{.claude,.codex,.zcode}/skills/story-setup/references/agent-references/skills/story-setup/references/agent-references/agent-references/skills/story-setup/skills/Use AskUserQuestion to confirm the deployment location, then execute in sequence.
The entire Phase 2 is idempotent: The results of directory copying, file writing, and each merge algorithm in the table below are consistent when executed repeatedly. If it fails halfway due to environmental reasons (unavailable tools, permission denied, network failure), restart this Phase directly from the beginning without cleaning up semi-finished products first; user status files marked as (see Owner class in the table below) will not be overwritten for the second time.
create only if absentThe two columns have different base directories: is relative to the executing skill package, is relative to the user's project root. Before executing each line (and each recursive copy step in the deployment algorithms of each end below), first convert wildcards into specific source/target paths, then use at the same level as this to check. This script follows existing symlinks according to / semantics, and uses to verify filesystem objects when both sides exist; just converting to absolute paths or comparing strings does not count as completing the check. Read its JSON: When , no-op, copying is prohibited; only when can copying be performed; if , or occurs, this step must be stopped and reported. If the script cannot be run, only use the filesystem API of the current environment to perform the same canonical realpath, same-object and target-descendant checks; if it cannot be confirmed, stop and do not attempt to copy. The project copies of OpenClaw / Reasonix / generic are full skill copies, and the one executed during rerunning is the one in the project; Reasonix / Codex may also be loaded via symlink, and different path texts may point to the same directory, so copying literally will embed the directory into itself and fill up the disk.
Source pathTarget pathscripts/copy-path-safety.pySKILL.mdPath.resolverealpathsamefilestatus: samecopy_allowed: truesource_missingunsafe_target_within_sourcefilesystem_identity_error.agents/skills → ../skillsClean up self-nested residues before deployment: If there is an extra layer (possibly multiple nested layers) in and the project root , as well as , delete the entire segment before deployment, and list the deleted paths in the installation report.
agent-references/{.claude,.codex,.zcode}/skills/story-setup/references/agent-references/skills/story-setup/references/agent-references/skills/story-setup/skills/Step 1:部署清单(机械可检查)
Step 1: Deployment Checklist (Mechanically Verifiable)
| Source path | Target path | Owner class | Merge mode | Validation check |
|---|---|---|---|---|
| | user+managed | marker/section merge | contains story skill routing sections |
| | story-setup managed | recursive replace | |
| | story-setup managed | replace | every rule contains |
| | story-setup managed | replace | 7 agent files exist |
| | story-setup managed | replace | every |
| | user+managed | replace managed registrations by stable hook identity | hook JSON valid;旧 matcher 注册已迁移、当前模板命令各一份、用户 hook 保留 |
| 部署时执行,不复制到项目 | story-setup helper | execute | 替换已知 story hook 注册、保留用户 hooks/顶层字段,v24→v25 迁移与重复执行幂等 |
| 每个递归复制步骤前执行,不复制到项目专用目录 | story-setup helper | execute | JSON 仅 |
| generated sentinel | | story-setup managed | replace | contains |
| | user+managed | marker/section merge | contains story skill routing sections |
| | story-setup managed | replace | 7 agent files exist(replace 前按「配置 OpenCode Agent 模型」中的「保留已有模型配置」缓存现有 |
| | story-setup managed | replace | TypeScript plugin file exists |
| | story-setup managed | replace | Node syntax valid;与 ZCode 副本字节一致;被 story-hooks.ts import |
| | story-setup managed | replace | 13 command files exist |
| merge into | user+managed | merge by plugin/permission key | plugin entry registered |
repository | | story-setup managed | replace | every reference resolves |
| | user+managed | append or create | file exists and is executable;含 marker 块则替换块内容,不含则检测 exit 0 位置智能插入 |
| | user+managed | marker/section merge | contains Codex story skill routing sections |
| | story-setup managed | replace | 7 TOML agent files parse and contain |
| | user+managed | replace managed registrations by stable hook identity | hook JSON valid; all stale direct/launcher registrations removed, current 6 registrations present exactly once |
| | story-setup managed | replace | Python/shell/cmd launcher 文件齐全 |
| 部署时执行,不复制到项目 | story-setup helper | execute | 替换已知管理注册、保留用户 hooks 与未知顶层字段,结果幂等 |
| | story-setup managed | replace | every reference resolves |
| | user+managed | marker/section merge | contains ZCode |
repository | | story-setup managed for known skill names | replace known skill dirs only | 13 |
| | story-setup managed for known command names | replace known command files only | 13 commands have valid names/frontmatter |
| | story-setup managed | replace | Node syntax valid; hook contract tests pass |
| | story-setup managed | replace | Node syntax valid; hook contract tests pass |
| merge into | user+managed | merge by event+matcher+process args | JSON valid; 按「ZCode 部署算法」第 4 步 hooks 互斥分支校验——未装 oh-story 插件时 |
| | user+managed | marker/section merge | contains OpenClaw story skill routing sections |
| | user+managed | marker/section merge | contains generic story skill routing sections |
| | user+managed | marker/section merge | contains Reasonix story skill routing sections and solo/direct fallback |
repository | | story-setup managed for known skill names | replace known skill dirs only | 13 |
repository | 随上一行整份 skill 拷贝落地,本行 no-op | story-setup managed | 不单独复制 | every reference resolves |
| Source path | Target path | Owner class | Merge mode | Validation check |
|---|---|---|---|---|
| | user+managed | marker/section merge | contains story skill routing sections |
| | story-setup managed | recursive replace | |
| | story-setup managed | replace | every rule contains |
| | story-setup managed | replace | 7 agent files exist |
| | story-setup managed | replace | every |
| | user+managed | replace managed registrations by stable hook identity | hook JSON valid;old matcher registrations have been migrated, each current template command exists once, user hooks are retained |
| Executed during deployment, not copied to project | story-setup helper | execute | replaces known story hook registrations, retains user hooks/top-level fields, v24→v25 migration and repeated execution are idempotent |
| Executed before each recursive copy step, not copied to project-specific directory | story-setup helper | execute | JSON allows copying only when |
| generated sentinel | | story-setup managed | replace | contains |
| | user+managed | marker/section merge | contains story skill routing sections |
| | story-setup managed | replace | 7 agent files exist (before replace, cache existing |
| | story-setup managed | replace | TypeScript plugin file exists |
| | story-setup managed | replace | Node syntax valid;has identical bytes with ZCode copies;imported by story-hooks.ts |
| | story-setup managed | replace | 13 command files exist |
| merge into | user+managed | merge by plugin/permission key | plugin entry registered |
repository | | story-setup managed | replace | every reference resolves |
| | user+managed | append or create | file exists and is executable;if marker block exists, replace block content, if not, intelligently insert by detecting exit 0 position |
| | user+managed | marker/section merge | contains Codex story skill routing sections |
| | story-setup managed | replace | 7 TOML agent files parse and contain |
| | user+managed | replace managed registrations by stable hook identity | hook JSON valid; all stale direct/launcher registrations removed, current 6 registrations present exactly once |
| Same-named files in | story-setup managed | replace | Python/shell/cmd launcher files are complete |
| Executed during deployment, not copied to project | story-setup helper | execute | replaces known managed registrations, retains user hooks and unknown top-level fields, results are idempotent |
| | story-setup managed | replace | every reference resolves |
| | user+managed | marker/section merge | contains ZCode |
repository | | story-setup managed for known skill names | replace known skill dirs only | 13 |
| | story-setup managed for known command names | replace known command files only | 13 commands have valid names/frontmatter |
| | story-setup managed | replace | Node syntax valid; hook contract tests pass |
| | story-setup managed | replace | Node syntax valid; hook contract tests pass |
| merge into | user+managed | merge by event+matcher+process args | JSON valid; verify according to hooks mutually exclusive branch in "ZCode Deployment Algorithm" Step 4 — when oh-story plugin is not installed, |
| | user+managed | marker/section merge | contains OpenClaw story skill routing sections |
| | user+managed | marker/section merge | contains generic story skill routing sections |
| | user+managed | marker/section merge | contains Reasonix story skill routing sections and solo/direct fallback |
repository | | story-setup managed for known skill names | replace known skill dirs only | 13 |
repository | Landed with the full skill copy in the previous line, no-op for this line | story-setup managed | No separate copy | every reference resolves |
opencode.json 合并算法
opencode.json Merge Algorithm
部署 时按以下规则合并:
opencode.json.patch- 读取现有 (如存在),解析 JSON
opencode.json - 合并 数组:将
plugin加入数组,去重./.opencode/plugins/story-hooks.ts - 保留用户已有的其他配置字段(、
permission、model等),不覆盖provider - 写入合并后的
opencode.json
When deploying , merge according to the following rules:
opencode.json.patch- Read the existing (if exists), parse JSON
opencode.json - Merge the array: Add
pluginto the array and deduplicate./.opencode/plugins/story-hooks.ts - Retain other existing configuration fields of the user (such as ,
permission,model), do not overwriteprovider - Write the merged
opencode.json
Step 2:部署 CLAUDE.md
Step 2: Deploy CLAUDE.md
- 读取
skills/story-setup/references/templates/CLAUDE.md.tmpl - 替换占位符(见下方「模板占位符」段)
- 写入项目根目录 (如已存在,按「CLAUDE.md 合并策略」处理)
CLAUDE.md
- Read
skills/story-setup/references/templates/CLAUDE.md.tmpl - Replace placeholders (see "Template Placeholders" section below)
- Write to project root directory (if it already exists, process according to "CLAUDE.md Merge Strategy")
CLAUDE.md
Step 3:部署 Hooks
Step 3: Deploy Hooks
- 递归复制完整目录树:将 复制到用户项目
skills/story-setup/references/templates/hooks/.claude/hooks/ - 必须保留子目录 ,其中:
lib/- 提供
lib/common.sh、project_root、discover_active_bookdiscover_all_books - 提供
lib/sentinel.sh字段读取.story-deployed
- 只需对 设置执行权限(
.claude/hooks/*.sh);chmod +x由 hooklib/*.sh,不要求可执行位source
- Recursively copy the complete directory tree: Copy to the user's project
skills/story-setup/references/templates/hooks/.claude/hooks/ - Must retain the subdirectory , where:
lib/- provides
lib/common.sh,project_root,discover_active_bookdiscover_all_books - provides
lib/sentinel.shfield reading.story-deployed
- Only need to set execution permissions () for
chmod +x;.claude/hooks/*.shis sourced by hooks, no need for executable bitslib/*.sh
Step 4:部署 Rules
Step 4: Deploy Rules
- 读取 下所有
skills/story-setup/references/templates/rules/文件.md - 复制到用户项目的 目录
.claude/rules/
- Read all files under
.mdskills/story-setup/references/templates/rules/ - Copy to the directory of the user's project
.claude/rules/
Step 5:部署 Agents
Step 5: Deploy Agents
- 读取 下所有
skills/story-setup/references/templates/agents/文件.md - 复制到用户项目的 目录
.claude/agents/ - Agent 文件属于 story-setup 管理文件,可安全覆盖;版本升级时按 的版本检测结果重新部署
UPGRADING.md - 含 opencode 时,覆盖
target_cli之前先执行下面「配置 OpenCode Agent 模型」的 Step 1 缓存现有.opencode/agents/。那一步写在本节后面,但必须先跑——照顺序读到哪做到哪会先覆盖再缓存,用户已配的模型就没了。model: - 部署后必须新开会话:agent 只在会话启动时注册;原因与必须输出的报告文案见「验证安装」中的「输出安装报告」。
- Read all files under
.mdskills/story-setup/references/templates/agents/ - Copy to the directory of the user's project
.claude/agents/ - Agent files are managed by story-setup and can be safely overwritten; redeploy according to the version detection results in during version upgrade
UPGRADING.md - When contains opencode, execute Step 1 of "Configure OpenCode Agent Model" to cache existing
target_clibefore overwritingmodel:. This step is written later in this section, but must be run first — if you follow the order and overwrite first then cache, the user's configured model will be lost..opencode/agents/ - Must start a new session after deployment: Agents are only registered when the session starts; the reason and the report copy that must be output are in "Output Installation Report" in "Verify Installation".
Agent 兼容性处理
Agent Compatibility Handling
- Agent frontmatter 以 Claude Code 为主;OpenCode 的 与 Codex 的
.opencode/agents/*.md都由.codex/agents/*.toml、references/opencode/agents/下的预生成产物直接复制,这两个目录是部署的唯一来源。预生成产物由 oh-story-claudecode 仓库根的references/codex/agents/和scripts/sync-opencode.py维护;这两个脚本是仓库维护工具,不随 story-setup 下发,部署时不需要也无法调用。scripts/generate-codex-agents.py - ZCode 3.3.4 不部署项目 agents:其自定义子智能体只支持用户级 ,plugin manifest 中的
~/.zcode/agents/当前不执行。不要创建agents或修改用户 home;相关 Skill 必须直接 solo/direct 并报告 fallback。.zcode/agents/ - OpenClaw Phase 1 不部署 agents:OpenClaw 只部署 skills,agent 协作相关 skill 必须按既有 fallback 规则降级 solo/direct,不要把 Claude/OpenCode agent frontmatter 直接复制成 OpenClaw agent。
- 部署到项目后,agent 内引用的参考资料必须走 这一本 skill 内复制路径;不要跨 skill 引用其他 skill 的 references。各 adapter 只使用当前规范前缀:Claude Code 为
story-setup/references/agent-references/*.md,OpenCode / OpenClaw / Reasonix / generic 为.claude/skills/,Codex 为skills/,ZCode 为.codex/skills/;不在运行时遍历历史备选路径。.zcode/skills/
- Agent frontmatter is mainly based on Claude Code; OpenCode's and Codex's
.opencode/agents/*.mdare directly copied from pre-generated products under.codex/agents/*.tomlandreferences/opencode/agents/, which are the only sources for deployment. The pre-generated products are maintained byreferences/codex/agents/andscripts/sync-opencode.pyat the root of the oh-story-claudecode repository; these two scripts are repository maintenance tools, not distributed with story-setup, and do not need to be called during deployment.scripts/generate-codex-agents.py - ZCode 3.3.4 does not deploy project agents: Its custom sub-agents only support user-level , and the
~/.zcode/agents/in the plugin manifest is not currently executed. Do not createagentsor modify the user's home; related Skills must directly use solo/direct and report fallback..zcode/agents/ - OpenClaw Phase 1 does not deploy agents: OpenClaw only deploys skills, and skills related to agent collaboration must be downgraded to solo/direct according to existing fallback rules, do not directly copy Claude/OpenCode agent frontmatter as OpenClaw agents.
- After deployment to the project, the reference materials referenced in the agent must use the intra-skill copy path ; do not reference references from other skills across skills. Each adapter only uses the current specification prefix: Claude Code uses
story-setup/references/agent-references/*.md, OpenCode / OpenClaw / Reasonix / generic use.claude/skills/, Codex usesskills/, ZCode uses.codex/skills/; does not traverse historical alternative paths at runtime..zcode/skills/
部署 Agent References
Deploy Agent References
- 将 下所有
skills/story-setup/references/agent-references/复制到项目内.md.claude/skills/story-setup/references/agent-references/ - 校验:凡 agent 或 reference 中出现 ,源包与目标包都必须存在
story-setup/references/agent-references/<file>.md<file>.md
- Copy all files under
.mdtoskills/story-setup/references/agent-references/in the project.claude/skills/story-setup/references/agent-references/ - Verification: For every occurrence of in agents or references,
story-setup/references/agent-references/<file>.mdmust exist in both the source package and the target package<file>.md
部署 Codex Agents(target_cli 含 codex 时)
Deploy Codex Agents (when target_cli contains codex)
- 读取 下所有
skills/story-setup/references/codex/agents/文件,复制到用户项目.toml.codex/agents/ - Agent 文件属于 story-setup 管理文件,可安全覆盖;里的 TOML 由仓库根的
references/codex/agents/从 Claude agent 模板确定性生成后提交入库,部署只做复制scripts/generate-codex-agents.py - 校验每个 TOML 都能解析,且包含 Codex 必需字段:、
name、descriptiondeveloper_instructions - 只读职责 agent(、
chapter-extractor、consistency-checker)必须保留story-explorersandbox_mode = "read-only" - 部署后必须 trust + 新开 Codex 会话(报告文案与 fallback 规则见「验证 Codex 部署」);若运行时返回 ,调用方必须降级 solo/direct 并报告 fallback。
unknown agent_type - 将 同步复制到
skills/story-setup/references/agent-references/,作为 Codex agent 的项目内参考资料主路径.codex/skills/story-setup/references/agent-references/
- Read all files under
.toml, copy to the user's projectskills/story-setup/references/codex/agents/.codex/agents/ - Agent files are managed by story-setup and can be safely overwritten; the TOML in is deterministically generated from Claude agent templates by
references/codex/agents/at the root of the repository and committed to the repository, deployment only does copyingscripts/generate-codex-agents.py - Verify that each TOML can be parsed and contains Codex required fields: ,
name,descriptiondeveloper_instructions - Read-only responsibility agents (,
chapter-extractor,consistency-checker) must retainstory-explorersandbox_mode = "read-only" - Must trust + start a new Codex session after deployment (report copy and fallback rules are in "Verify Codex Deployment"); if is returned at runtime, the caller must downgrade to solo/direct and report fallback.
unknown agent_type - Synchronously copy to
skills/story-setup/references/agent-references/as the main path for intra-project reference materials of Codex agents.codex/skills/story-setup/references/agent-references/
配置 OpenCode Agent 模型
Configure OpenCode Agent Model
仅当含target_cli时执行。OpenCode 子代理不指定模型时继承主模型,导致低成本 Agent 也消耗主模型额度。此步骤自动检测用户模型并写入opencode字段。model:
Only execute whencontainstarget_cli. When OpenCode sub-agents do not specify a model, they inherit the main model, resulting in low-cost Agents also consuming main model quotas. This step automatically detects the user's model and writes theopencodefield.model:
Step 1:保留已有模型配置(必须在 .opencode/agents/
的 replace 之前执行)
.opencode/agents/Step 1: Retain Existing Model Configuration (must be executed before replacing .opencode/agents/
)
.opencode/agents/OpenCode agents 部署是 ,会覆盖上次写入的 。所以在执行该 replace 之前先扫描现有 ,缓存每个 agent 的 (agent 名 → 模型 ID)。后续检测失败/超时、或用户跳过某一级时,用缓存值回填,避免把用户上次配好的低成本模型抹成主模型。若 replace 已先发生、缓存为空,则按全新部署处理,并在安装报告中提示"未能保留上次模型配置"。
replacemodel:.opencode/agents/*.mdmodel:OpenCode agent deployment uses , which will overwrite the previously written . Therefore, before executing this replace, first scan the existing and cache the of each agent (agent name → model ID). If detection fails/timeout later, or the user skips a certain level, use the cached value to fill in, avoiding overwriting the user's previously configured low-cost model with the main model. If replace has already occurred and the cache is empty, process it as a new deployment, and prompt "Failed to retain previous model configuration" in the installation report.
replacemodel:.opencode/agents/*.mdmodel:Step 2:获取模型列表
Step 2: Get Model List
优先执行 ,它输出含 cost(input/output/cache 单价)、context、capabilities 的 metadata;不可用或解析失败时回退到 纯文本(每行 )。两者都用 60000ms(60 秒)超时,因为首次运行需加载 models.dev 缓存。
opencode models --verboseopencode modelsprovider/model- 成功 → 进入「模型分级」
- 超时 → 重试一次(缓存可能未预热);仍然超时则按「保留已有模型配置」缓存回填已有 、跳过自动配置,在安装报告中输出手动配置指南
model: - 失败(命令不存在、输出为空等)→ 同上:回填「保留已有模型配置」缓存、跳过自动配置、输出手动配置指南
优先执行 ,它输出含 cost(input/output/cache 单价)、context、capabilities 的 metadata;不可用或解析失败时回退到 纯文本(每行 )。两者都用 60000ms(60 秒)超时,因为首次运行需加载 models.dev 缓存。
opencode models --verboseopencode modelsprovider/model- Success → Enter "Model Classification"
- Timeout → Retry once (cache may not be preheated); if still timeout, fill in the existing with the cache from "Retain Existing Model Configuration", skip automatic configuration, and output manual configuration guide in the installation report
model: - Failure (command does not exist, output is empty, etc.) → Same as above: Fill in the cache from "Retain Existing Model Configuration", skip automatic configuration, output manual configuration guide
Step 3:模型分级
Step 3: Model Classification
优先按成本分级(有 时):按每模型实际 cost 从低到高分档——低端取最便宜/免费档、中端取中价档、高端取最贵或上下文/能力最强档。免费模型按真实 cost=0 归低端,不按名字里的营销词(如 名含 但 cost=0,应归低端)。无 cost 数据的模型也据此进入候选,不被丢弃。
--verbosenemotron-3-ultra-freeultra回退按关键词分级(无 或无 cost 时):按模型 ID 中最后一个 之后的模型名按 、、 分割为段,逐段精确匹配关键词(不区分大小写)。例如 拆为 ,不匹配 也不匹配 ; 拆为 ,匹配 。关键词分级是启发式,安装报告中标注 。
--verbose/-._minimax-m3[minimax, m3]minimaxclaude-haiku-4.5[claude, haiku, 4, 5]haiku分级依据:关键词(heuristic)| 等级 | 匹配关键词 | 对应 Agent |
|---|---|---|
| 低端 | | chapter-extractor, consistency-checker, story-explorer |
| 中端 | | story-researcher, narrative-writer, character-designer |
| 高端 | | story-architect |
- 一个模型可能匹配多个等级的关键词,取最高等级
- 关键词回退下未匹配任何关键词的模型仍列入候选附加建议(按成本分级则一律纳入),并在安装报告列出,提示"可通过自定义输入使用"
- 同一等级内,如果包含多个模型供应商,优先列出知名供应商(anthropic、openai、google、deepseek)的模型
Prioritize classification by cost (when is available): Grade each model from lowest to highest cost — low-end takes the cheapest/free tier, mid-end takes the mid-priced tier, high-end takes the most expensive or the one with the strongest context/capabilities. Free models are classified as low-end with real cost=0, do not rely on marketing words in the name (e.g., contains in the name but cost=0, should be classified as low-end). Models without cost data are also included in candidates and not discarded.
--verbosenemotron-3-ultra-freeultraFallback to classification by keywords (when no or no cost): Split the model name after the last in the model ID into segments by , , , and match keywords exactly segment by segment (case-insensitive). For example, is split into , does not match or ; is split into , matches . Keyword classification is heuristic, mark "Classification basis: keywords (heuristic)" in the installation report.
--verbose/-._minimax-m3[minimax, m3]minimaxclaude-haiku-4.5[claude, haiku, 4, 5]haiku| Grade | Matching Keywords | Corresponding Agents |
|---|---|---|
| Low-end | | chapter-extractor, consistency-checker, story-explorer |
| Mid-end | | story-researcher, narrative-writer, character-designer |
| High-end | | story-architect |
- A model may match keywords of multiple grades, take the highest grade
- Models that do not match any keywords in keyword fallback are still included in candidate additional suggestions (all are included in cost classification), and listed in the installation report, prompting "Can be used via custom input"
- Within the same grade, if multiple model providers are included, prioritize models from well-known providers (anthropic, openai, google, deepseek)
Step 4:逐级交互选择
Step 4: Step-by-Step Interactive Selection
按 低端 → 中端 → 高端 顺序,每级用 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 拼写错误要到运行时才会暴露)
- 跳过,使用主模型(成本可能较高)规则:
- 候选最多显示 5 个,超过则截断并提示"更多模型请使用自定义输入"。每一级无论候选数是否为 0 都用 AskUserQuestion 弹出,选项至少含:候选模型(如有)、、
自定义输入(「保留已有模型配置」缓存到该 agent 的 model,无则不显示此项)、保留现有模型。候选为 0 时仍弹窗,并在问题说明里给出对应警告 + 列出未分级/未入档模型供参考——不再静默跳过交互(否则用户够不到自定义输入)。跳过,用主模型 - :用户输入
自定义输入完整 ID;写入前校验为单行、无控制字符、匹配provider/model-id,不符则提示重输或改选跳过。^[A-Za-z0-9._-]+/[A-Za-z0-9._:+-]+$ - :写回「保留已有模型配置」缓存的该 agent model(重新部署时保住用户上次配置),不算"跳过"。
保留现有模型 - :显式清除——不写该 agent 的
跳过,用主模型,agent 继承主模型。想保留上次配置请选model:。保留现有模型 - 各级候选为 0 时在问题说明里给出提示:
- 低端:"未检测到低成本模型,这 3 个 agent 将使用主模型,成本可能较高"
- 中端:"未检测到匹配的中端模型。narrative-writer、character-designer、story-researcher 将使用主模型。如主模型质量足够此配置合理;如需降本,请用自定义输入指定不低于主模型质量的中端模型,或从下方未分级模型里选。"
- 高端:"未检测到高端模型,story-architect 将使用主模型"
In the order of low-end → mid-end → high-end, use AskUserQuestion to let the user select at each level.
Low-end option structure:
Question: "Select model for low-cost Agents (chapter-extractor, consistency-checker, story-explorer):"
Options:
- provider/model-id
- provider/model-id
- Custom input (manually enter full model ID, ID spelling errors will only be exposed at runtime)
- Skip, use main model (cost may be higher)Mid-end option structure:
Question: "Select model for writing quality-critical Agents (narrative-writer, character-designer, story-researcher):"
Options:
- provider/model-id
- provider/model-id
- Custom input (do not use low-end models, which will affect text quality; ID spelling errors will only be exposed at runtime)
- Skip, use main model (main model quality is usually sufficient)High-end option structure:
Question: "Select model for command Agent (story-architect):"
Options:
- provider/model-id
- provider/model-id
- Custom input (manually enter full model ID, ID spelling errors will only be exposed at runtime)
- Skip, use main model (cost may be higher)Rules:
- Display up to 5 candidates, truncate if more than 5 and prompt "For more models, use custom input". Pop up AskUserQuestion at each level regardless of whether the number of candidates is 0, options must include: candidate models (if any), ,
Custom input(the model of this agent cached in "Retain Existing Model Configuration", do not display this item if none),Retain existing model. When candidates are 0, still pop up the window, and give a corresponding warning in the question description + list unclassified/ungraded models for reference — do not silently skip interaction (otherwise the user cannot access custom input).Skip, use main model - : User enters full
Custom input; verify it is a single line, no control characters, matchesprovider/model-idbefore writing, if not, prompt to re-enter or choose to skip.^[A-Za-z0-9._-]+/[A-Za-z0-9._:+-]+$ - : Write back the model of this agent cached in "Retain Existing Model Configuration" (preserve the user's previous configuration during redeployment), not counted as "skip".
Retain existing model - : Explicitly clear — do not write the
Skip, use main modelfield for this agent, the agent inherits the main model. To retain previous configuration, selectmodel:.Retain existing model - When candidates are 0 at each level, give prompts in the question description:
- Low-end: "No low-cost models detected, these 3 agents will use the main model, cost may be higher"
- Mid-end: "No matching mid-end models detected. narrative-writer, character-designer, story-researcher will use the main model. This configuration is reasonable if the main model quality is sufficient; if cost reduction is needed, specify a mid-end model not lower than the main model quality via custom input, or select from the ungraded models below."
- High-end: "No high-end models detected, story-architect will use the main model"
Step 5:写入 model 字段
Step 5: Write model Field
对应用户选择的 agent 文件(,由部署清单中 OpenCode agents 部署步骤在此步骤之前已部署),在 frontmatter 末尾、closing 之前,以零缩进的顶层字段插入 (不要插进 等多行 map 的缩进块内部)。值含 YAML 特殊字符时加引号,确保不破坏 frontmatter:
.opencode/agents/*.md---model:permission:yaml
---
description: ...
mode: subagent
permission:
read: allow
edit: deny
steps: 12
model: provider/model-id
---- 如果 agent 文件已有 字段(重新部署场景),替换该顶层
model:的值,不新增重复键model: - :写回「保留已有模型配置」缓存的该 agent model
保留现有模型 - :不写入
跳过,用主模型字段model: - 检测失败/超时、没走到本步骤的等级:用「保留已有模型配置」缓存回填 ,避免 replace 抹掉用户上次配置
model:
For the agent files corresponding to the user's selection (, which have been deployed by the OpenCode agents deployment step in the deployment checklist before this step), insert as a top-level field with zero indentation at the end of the frontmatter, before the closing (do not insert into the indentation block of multi-line maps such as ). Add quotes if the value contains YAML special characters to ensure the frontmatter is not damaged:
.opencode/agents/*.mdmodel:---permission:yaml
---
description: ...
mode: subagent
permission:
read: allow
edit: deny
steps: 12
model: provider/model-id
---- If the agent file already has a field (redeployment scenario), replace the value of this top-level
model:, do not add duplicate keysmodel: - : Write back the model of this agent cached in "Retain Existing Model Configuration"
Retain existing model - : Do not write the
Skip, use main modelfieldmodel: - For levels that failed/timeout and did not reach this step: Fill in with the cache from "Retain Existing Model Configuration", avoiding overwriting the user's previous configuration due to replace
model:
Step 6:合并 Hooks 注册到 settings.local.json
Step 6: Merge Hook Registrations to settings.local.json
- 按现有跨平台规则探测 Python:;无可用解释器时停止,不手写或简化合并。
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" - helper 会移除所有已知 story-setup hook 的历史注册,再追加当前模板;因此 matcher/timeout/if 能随版本升级,同时混在旧 block 中的用户 hook 与未知顶层字段原样保留。写后解析 JSON,验证模板命令各一份、用户配置仍在,再复跑 helper 比较文件字节确认幂等。
- Detect Python according to existing cross-platform rules: ; stop if no available interpreter, do not manually write or simplify merging.
for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done - Call .
"$PYBIN" "{story-setup skill directory}/scripts/merge-claude-settings.py" --existing "{project}/.claude/settings.local.json" --template "{story-setup skill directory}/references/templates/settings-hooks.json" --output "{project}/.claude/settings.local.json" - The helper will remove all historical registrations of known story-setup hooks, then append the current template; therefore, matcher/timeout/if can be upgraded with the version, while user hooks and unknown top-level fields mixed in the old block are retained as-is. Parse JSON after writing, verify that each template command exists once, user configuration is still present, then re-run the helper to compare file bytes to confirm idempotency.
Codex hooks.json 合并算法(target_cli 含 codex 时)
Codex hooks.json Merge Algorithm (when target_cli contains codex)
Codex 项目 hooks 部署到 ;运行脚本部署到 、、。JSON 只负责定位项目根与传递 event,解释器探测由平台 launcher 统一处理。
.codex/hooks.json.codex/hooks/story_codex_hook.pyrun-story-hook.shrun-story-hook.cmd- 定位当前 story-setup skill 目录,读取 作为唯一当前模板,读取项目
references/codex/hooks/hooks.json(不存在时视为空对象)。.codex/hooks.json - 按现有跨平台规则探测可用 Python:;无可用解释器时停止,不手写或简化 JSON 合并。
for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done - 调用 。该 helper 会识别旧直调
"$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"、当前story_codex_hook.py和run-story-hook.sh三类管理身份,先移除所有已知管理注册,再追加当前模板。run-story-hook.cmd - 保留用户已有的非 story-setup hooks、matcher 块与未知顶层字段。重复执行必须幂等;禁止再按原始 字符串追加去重,否则 v17 直调命令会与 v18 launcher 双重注册。
command - 写入后解析 JSON 验证:旧直调 命令数为 0,当前模板 6 个注册各存在且仅存在一次,用户 hook 与未知顶层字段仍在。然后提示用户:项目
story_codex_hook.py层需要被 Codex trust,非 managed command hooks 还需要在.codex/中 review/trust 后才会运行;Windows 下走/hooks,launcher 从当前目录向上定位项目commandWindows,与 POSIX 路径的嵌套目录行为一致。.codex/hooks/
Codex project hooks are deployed to ; run scripts to deploy to , , . JSON is only responsible for locating the project root and passing events, interpreter detection is uniformly handled by the platform launcher.
.codex/hooks.json.codex/hooks/story_codex_hook.pyrun-story-hook.shrun-story-hook.cmd- Locate the current story-setup skill directory, read as the only current template, read the project's
references/codex/hooks/hooks.json(treat as empty object if it does not exist)..codex/hooks.json - Detect available Python according to existing cross-platform rules: ; stop if no available interpreter, do not manually write or simplify JSON merging.
for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done - Call . This helper will identify three types of managed identities: old direct call
"$PYBIN" "{story-setup skill directory}/scripts/merge-codex-hooks.py" --existing "{project}/.codex/hooks.json" --template "{story-setup skill directory}/references/codex/hooks/hooks.json" --output "{project}/.codex/hooks.json", currentstory_codex_hook.pyandrun-story-hook.sh, first remove all known managed registrations, then append the current template.run-story-hook.cmd - Retain non-story-setup hooks, matcher blocks and unknown top-level fields already present in the user's configuration. Repeated execution must be idempotent;禁止再按原始 字符串追加去重,否则 v17 直调命令会与 v18 launcher 双重注册。
command - Parse JSON after writing to verify: The number of old direct call commands is 0, each of the 6 current template registrations exists exactly once, user hooks and unknown top-level fields are still present. Then prompt the user: The project's
story_codex_hook.pylayer needs to be trusted by Codex, non-managed command hooks also need to be reviewed/trusted in.codex/before running; on Windows, use/hooks, the launcher locates the project'scommandWindowsfrom the current directory upwards, consistent with the nested directory behavior of POSIX paths..codex/hooks/
ZCode 部署算法(target_cli 含 zcode 时)
ZCode Deployment Algorithm (when target_cli contains zcode)
ZCode 首版部署 Skills、Commands、AGENTS.md 和支持事件内的 Hooks;不部署 或 。
.zcode/agents.zcode/rules- 复制仓库当前 下 13 个包含
skills/的目录到SKILL.md;仅替换这些已知目录,保留用户其他 Skills。.zcode/skills/{skill-name}/ - 复制 到
references/zcode/commands/*.md;仅替换 13 个同名命令,保留用户其他 Commands。.zcode/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承载 oh-story 项目 Hooks,不改写根文件):.zcode/config.json- 保留用户所有未知字段、MCP、plugins、skills/commands disable overrides;
- hooks 互斥(避免双触发):若本项目经已安装的 oh-story 插件运行(marketplace 安装,仓库根 的
.zcode-plugin/plugin.json已全局注册 SessionStart/PreToolUse/PostToolUse),则跳过下面把hooks.json的config.json.patch块合并进hooks——插件 manifest 已注册这批 hooks,再合并会让同一事件跑两遍(PreToolUse 拦两次、PostToolUse 注入两次)。只有未装插件(直接克隆 / 手动导入 references)时才合并 hooks。不确定时以「ZCode 是否已通过本插件注册这套 hooks」为准;skills/commands/hook 文件/AGENTS 与 config 的非 hook 字段两条路径都照常部署。.zcode/config.json - 合并 hooks(仅未装插件时):设置 ;用户已有更大的
hooks.enabled: true时保留,否则取模板值;对timeoutMs的 SessionStart、PreToolUse、PostToolUse 按hooks.events去重追加;不复制 ZCode 不支持的 PreCompact、PostCompact、SessionEnd、SubagentStop、Notification。event + matcher + process command + args
- 将 按「AGENTS.md 合并策略」写入根
references/zcode/AGENTS.md.tmpl。AGENTS.md - 的
.story-deployed写入target_cli或多端组合,zcode写references_dir。.zcode/skills/story-setup/references/agent-references - 安装报告明确说明:ZCode 3.3.4 的项目/plugin custom agents 不执行,所有专业角色走 solo/direct;系统需要可用的 命令运行项目 Hook。
node
Plugin 安装不经过本算法:仓库根 直接暴露同一组 Skills/Commands/Hooks。Plugin Skills 优先级低于 workspace ;两者同时存在时项目快照优先,升级项目快照需重新运行 。Hooks 只能注册一份:插件 manifest 与 workspace 注册的是同一批事件,装了插件就不要再把 的 hooks 合并进 (见上算法第 4 步的 hooks 互斥),否则 PreToolUse/PostToolUse 会双触发;插件在场时以插件 manifest 为 hooks 唯一注册源。
.zcode-plugin/plugin.json.zcode/skills$story-setup.zcode/config.jsonconfig.json.patch.zcode/config.jsonThe first version of ZCode deploys Skills, Commands, AGENTS.md and Hooks within supported events; does not deploy or .
.zcode/agents.zcode/rules- Copy the 13 directories containing under the current repository's
SKILL.mdtoskills/; only replace these known directories, retain other Skills of the user..zcode/skills/{skill-name}/ - Copy to
references/zcode/commands/*.md; only replace 13 commands with the same name, retain other Commands of the user..zcode/commands/ - Copy and
references/zcode/hooks/story_zcode_hook.jstoreferences/zcode/hooks/story_hook_core.js..zcode/hooks/ - Read and the existing
references/zcode/config.json.patch(if only the root.zcode/config.jsonexists, still createzcode.jsonto carry oh-story project Hooks, do not modify the root file):.zcode/config.json- Retain all unknown fields, MCP, plugins, skills/commands disable overrides of the user;
- Hooks mutual exclusion (avoid double triggering): If this project runs via the installed oh-story plugin (marketplace installation, in
hooks.jsonat the repository root has globally registered SessionStart/PreToolUse/PostToolUse), then skip merging the.zcode-plugin/plugin.jsonblock ofhooksintoconfig.json.patchbelow — the plugin manifest has already registered these hooks, merging again will cause the same event to run twice (PreToolUse intercepted twice, PostToolUse injected twice). Only merge hooks when the plugin is not installed (directly cloned / manually imported references). When uncertain, take "Whether ZCode has registered this set of hooks via this plugin" as the criterion; non-hook fields of skills/commands/hook files/AGENTS and config are deployed as usual via both paths..zcode/config.json - Merge hooks (only when plugin is not installed): Set ; retain if the user already has a larger
hooks.enabled: true, otherwise take the template value; deduplicate and append SessionStart, PreToolUse, PostToolUse intimeoutMsbyhooks.events; do not copy PreCompact, PostCompact, SessionEnd, SubagentStop, Notification which are not supported by ZCode.event + matcher + process command + args
- Write the root according to "AGENTS.md Merge Strategy" using
AGENTS.md.references/zcode/AGENTS.md.tmpl - Write or multi-end combination to
zcodeintarget_cli, write.story-deployedto.zcode/skills/story-setup/references/agent-references.references_dir - The installation report must clearly state: ZCode 3.3.4 does not execute project/plugin custom agents, full/lean multi-Agent requests will be stably downgraded to solo/direct; the system requires an available command to run project Hooks.
node
Plugin installation does not go through this algorithm: at the repository root directly exposes the same set of Skills/Commands/Hooks. Plugin Skills have lower priority than workspace ; if both exist, the project snapshot takes precedence, and upgrading the project snapshot requires re-running .Only one set of Hooks can be registered: The plugin manifest and workspace register the same set of events, do not merge the hooks of into when the plugin is installed (see hooks mutual exclusion in Step 4 of the above algorithm), otherwise PreToolUse/PostToolUse will be triggered twice; when the plugin is present, the plugin manifest is the only registration source for hooks.
.zcode-plugin/plugin.json.zcode/skills$story-setup.zcode/config.jsonconfig.json.patch.zcode/config.jsonOpenClaw skills-only 部署算法(target_cli 含 openclaw 时)
OpenClaw skills-only Deployment Algorithm (when target_cli contains openclaw)
OpenClaw Phase 1 只部署 skills,不部署 OpenClaw agents/hooks/plugin。
- 读取仓库当前 下所有包含
skills/的 story skill 目录(13 个:SKILL.md与browser-cdp)。story* - 写入目标项目 ,仅替换这些 story-setup 管理的已知 skill 目录;保留用户在
skills/{skill-name}/下的其他目录。skills/ - 每个 必须满足 OpenClaw frontmatter 约束:
SKILL.md/name是单行键值,description是单行 JSON 对象且含metadata。metadata.openclaw - 复制 到项目
skills/story-setup/references/openclaw/AGENTS.md.tmpl,按「AGENTS.md 合并策略」合并。AGENTS.md - 的
.story-deployed写入target_cli或多端组合;openclaw对 OpenClaw 写references_dir。skills/story-setup/references/agent-references - 安装报告提示项见 Phase 3 第 10 步。
OpenClaw Phase 1 only deploys skills, does not deploy OpenClaw agents/hooks/plugin.
- Read all story skill directories containing under the current repository's
SKILL.md(13:skills/andbrowser-cdp).story* - Write to the target project's , only replace these story-setup managed known skill directories; retain other directories of the user under
skills/{skill-name}/.skills/ - Each must meet OpenClaw frontmatter constraints:
SKILL.md/nameare single-line key-value pairs,descriptionis a single-line JSON object and containsmetadata.metadata.openclaw - Copy to the project's
skills/story-setup/references/openclaw/AGENTS.md.tmpl, merge according to "AGENTS.md Merge Strategy".AGENTS.md - Write or multi-end combination to
openclawintarget_cli; write.story-deployedtoskills/story-setup/references/agent-referencesfor OpenClaw.references_dir - Prompt items in the installation report are in Step 10 of Phase 3.
Reasonix skills-only 部署算法(target_cli 含 reasonix 时)
Reasonix skills-only Deployment Algorithm (when target_cli contains reasonix)
Reasonix(DeepSeek-Reasonix CLI)当前只部署 skills 与 ,不部署 Reasonix hooks/custom agents(hook I/O 契约与子代理行为缺少可校验的真实 CLI,留待后续阶段)。
AGENTS.md- 读取仓库当前 下所有包含
skills/的 story skill 目录(13 个:SKILL.md与browser-cdp)到目标项目story*;仅替换这些 story-setup 管理的已知 skill 目录,保留用户其他目录。skills/{skill-name}/ - 在项目根创建 相对 symlink(与 Codex 共用的 skill root),使 Reasonix 原生扫描
.agents/skills → ../skills时发现这些 skill;若已是指向.agents/skills的 symlink 则保留,若被占用为普通目录则不覆盖并在安装报告提示。Windows 未启用 symlink 时跳过本步,改走根skills/的reasonix-plugin.json。reasonix plugin install - 复制 到项目
skills/story-setup/references/reasonix/AGENTS.md.tmpl,按「AGENTS.md 合并策略」合并。AGENTS.md - 的
.story-deployed写入target_cli或多端组合;reasonix对 Reasonix 写references_dir。skills/story-setup/references/agent-references - 安装报告提示项见 Phase 3 第 12 步。
Reasonix (DeepSeek-Reasonix CLI) currently only deploys skills and , does not deploy Reasonix hooks/custom agents (hook I/O contract and sub-agent behavior lack verifiable real CLI, to be added in subsequent phases).
AGENTS.md- Read all story skill directories containing under the current repository's
SKILL.md(13:skills/andbrowser-cdp) to the target project'sstory*; only replace these story-setup managed known skill directories, retain other directories of the user.skills/{skill-name}/ - Create a relative symlink in the project root (shared with Codex's skill root), so that Reasonix can discover these skills when natively scanning
.agents/skills → ../skills; if it is already a symlink pointing to.agents/skills, retain it, if it is occupied as a normal directory, do not overwrite and prompt in the installation report. Skip this step when symlink is not enabled on Windows, instead use the rootskills/forreasonix-plugin.json.reasonix plugin install - Copy to the project's
skills/story-setup/references/reasonix/AGENTS.md.tmpl, merge according to "AGENTS.md Merge Strategy".AGENTS.md - Write or multi-end combination to
reasonixintarget_cli; write.story-deployedtoskills/story-setup/references/agent-referencesfor Reasonix.references_dir - Prompt items in the installation report are in Step 12 of Phase 3.
通用 Web AI / 其他 Agent 部署算法(target_cli 含 generic 时)
General Web AI / Other Agent Deployment Algorithm (when target_cli contains generic)
通用路径面向 NarraFork、Web AI、自定义 Agent 等可读取项目文件的环境,只部署通用文件,不声明平台原生 hooks/agents 能力。
- 复制仓库当前 下所有包含
skills/的 story skill 目录(13 个:SKILL.md与browser-cdp)到目标项目story*;仅替换这些 story-setup 管理的已知 skill 目录,保留用户其他目录。skills/{skill-name}/ - 复制 到项目
skills/story-setup/references/generic/AGENTS.md.tmpl,按「AGENTS.md 合并策略」合并。AGENTS.md - 的
.story-deployed写入target_cli或多端组合;generic对 generic 写references_dir。skills/story-setup/references/agent-references - 安装报告提示项见 Phase 3 第 11 步。
The general path is for environments that can read project files such as NarraFork, Web AI, custom Agents, only deploys general files, does not declare platform-native hooks/agents capabilities.
- Copy all story skill directories containing under the current repository's
SKILL.md(13:skills/andbrowser-cdp) to the target project'sstory*; only replace these story-setup managed known skill directories, retain other directories of the user.skills/{skill-name}/ - Copy to the project's
skills/story-setup/references/generic/AGENTS.md.tmpl, merge according to "AGENTS.md Merge Strategy".AGENTS.md - Write or multi-end combination to
genericintarget_cli; write.story-deployedtoskills/story-setup/references/agent-referencesfor generic.references_dir - Prompt items in the installation report are in Step 11 of Phase 3.
Step 7:创建部署标记
Step 7: Create Deployment Marker
- 创建 文件(sentinel file)
.story-deployed - 写入以下字段(YAML 格式,hook 用
key: value读取):references/templates/hooks/lib/sentinel.shdeployed_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/...;多端用逗号分隔) - 此文件供 session-start.sh 和写作 skill 检测部署状态,避免重复提示
- target_cli 含 claude-code 时,同时创建一次性标记文件 (空文件即可)。session-start.sh 在下一个会话启动时据此确认 agents 已随新会话注册,并自动删除该标记——用来向用户确认「重启已生效」。ZCode 不创建该标记,因为它不部署项目 agents。
.claude/.agents-pending-restart - 如果 已存在但
.story-deployed缺失、非整数或小于agents_version,按本次流程更新 hooks/agents/rules/reference bundle(具体变更见25);大于UPGRADING.md时已在 Phase 1 停止,不得降级覆盖25
- Create file (sentinel file)
.story-deployed - Write the following fields (YAML format, read by
key: valuein hooks):references/templates/hooks/lib/sentinel.shdeployed_at: <date -u +"%Y-%m-%dT%H:%M:%SZ"> agents_version: 25 setup_skill_version: 1.2.7 target_cli: claude-code (or opencode, codex, zcode, openclaw, reasonix, generic, or any combination thereof) resolver_strategy: project-local-skill-reference references_dir: .claude/skills/story-setup/references/agent-references (Codex writes .codex/skills/...; ZCode writes .zcode/skills/...; OpenClaw / Reasonix / generic write skills/...; multi-end uses comma separation) - This file is used by session-start.sh and writing skills to detect deployment status and avoid repeated prompts
- When target_cli contains claude-code, also create a one-time marker file (empty file is sufficient). session-start.sh will confirm that agents have been registered with the new session when the next session starts, and automatically delete this marker — used to confirm "restart has taken effect" to the user. ZCode does not create this marker because it does not deploy project agents.
.claude/.agents-pending-restart - If exists but
.story-deployedis missing, non-integer or less thanagents_version, update hooks/agents/rules/reference bundle according to this process (specific changes see25); if greater thanUPGRADING.md, stop in Phase 1 and do not downgrade overwrite25
Phase 3:验证安装
Phase 3: Verify Installation
- 验证 hooks 注册:
- 检查 中的 hooks 字段是否正确
.claude/settings.local.json - 检查 下的脚本是否存在且有执行权限
.claude/hooks/ - 检查 与
.claude/hooks/lib/common.sh是否存在.claude/hooks/lib/sentinel.sh
- 检查
- 验证 rules 路径:
- 检查 下的规则文件是否存在且包含
.claude/rules/frontmatterpaths
- 检查
- 验证 agents:
- 检查 下的 7 个 agent 定义文件是否存在
.claude/agents/
- 检查
- 验证 agent reference bundle:
- 检查 下 reference 文件完整
.claude/skills/story-setup/references/agent-references/ - 检查所有 都能解析到 deployed bundle
story-setup/references/agent-references/<file>.md
- 检查
- 验证部署标记:
- 检查 是否存在且包含时间戳、
.story-deployed、agents_version: 25、setup_skill_version: 1.2.7、target_cli、resolver_strategyreferences_dir
- 检查
- 输出安装报告:
- 列出所有已部署的文件
- 列出需要注意的事项(如已有配置已合并)
- ⚠️ 重启提示(必须醒目输出):本次部署写入了 ,但这些 custom agent 只在「会话启动」时才会被 Claude Code 注册成
.claude/agents/。请新开一个 Claude Code 会话再开始写作,否则当前会话里 story-review / story-long-write 等想 spawnsubagent_type、story-architect等时会拿到「subagent_type 不可用」并降级 solo(单视角,失去多 agent 协作)。判断是否生效:新会话里跑narrative-writer,报告头若是/story-review即注册成功;若是Effective Mode: full/lean说明还在旧会话或未注册。Fallback: ... -> solo - 重启后即可使用 或
/story-long-write/story-short-write - 如果执行了「配置 OpenCode Agent 模型」,输出 Agent 模型配置摘要:
Agent 模型配置: 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 部署(仅当 target_cli 含 opencode 时):
- 检查 下的 7 个 agent 定义文件是否存在,且 frontmatter 包含
.opencode/agents/和mode: subagent字段permission - 检查 是否存在
.opencode/plugins/story-hooks.ts - 检查 存在且
.opencode/plugins/lib/story_hook_core.js通过(story-hooks.ts import 之,与node --check副本字节一致的共享写正文守卫核;置于.zcode子目录以避开 OpenCode 单层lib/插件自动发现).opencode/plugins/*.js - 检查 下的 13 个 command 文件是否存在
.opencode/commands/ - 检查 下 reference 文件完整且数量与源目录一致
skills/story-setup/references/agent-references/ - 检查 的
opencode.json数组是否包含 story-hooks 条目plugin - 检查 是否存在且有执行权限(Windows 上跳过执行权限检查)
.git/hooks/pre-commit - 检查 下 agent 文件 frontmatter 可被 YAML 解析、
.opencode/agents/(如有配置)是合法顶层标量,而非仅 grep 到model:子串model:
- 检查
- 验证 Codex 部署(仅当 target_cli 含 codex 时):
- 检查 含 Codex story skill routing sections
AGENTS.md - 检查 下 7 个
.codex/agents/agent 定义文件存在并可解析.toml - 检查 存在且 JSON 有效,Unix
.codex/hooks.json仅通过command启动,Windowsrun-story-hook.sh仅通过commandWindows启动;不存在直调run-story-hook.cmd的注册story_codex_hook.py - 检查 、
.codex/hooks/story_codex_hook.py、run-story-hook.sh存在,Python 语法有效,POSIX/Windows launcher 能从嵌套 cwd 定位项目根run-story-hook.cmd - 检查 下 reference 文件完整且数量与源目录一致
.codex/skills/story-setup/references/agent-references/ - 安装报告必须提示:Codex 需要 trust 项目 配置层,并在
.codex/review/trust 非 managed hooks;部署后新开 Codex 会话让 custom agents 生效;若当前运行时仍返回/hooks,按各 skill 的 fallback 规则降级 solo/directunknown agent_type
- 检查
- 验证 ZCode 部署(仅当 target_cli 含 zcode 时):
- 检查根 含 ZCode
AGENTS.md路由、大纲守卫和 solo/direct fallback$story-* - 检查 下 13 个 Skills 与
.zcode/skills/下 13 个 Commands,验证 frontmatter 和命名.zcode/commands/ - 检查 、
.zcode/hooks/story_zcode_hook.js存在且.zcode/hooks/story_hook_core.js通过node --check - 检查 JSON 有效,并按「ZCode 部署算法」第 4 步的 hooks 互斥分支校验:未装 oh-story 插件时,
.zcode/config.json、仅注册 ZCode 支持事件、所有hooks.enabled=trueargs 指向项目 Hook;已装 oh-story 插件(process已全局注册这批 hooks)时,改为校验.zcode-plugin/plugin.json不含(或已移除)这批 oh-story hooks 注册——不得为了让校验通过而把.zcode/config.json的 hooks 块合并回去,否则同一事件双触发config.json.patch - 检查 完整且所有 reference 路径可解析
.zcode/skills/story-setup/references/agent-references/ - 用 fixture 调用 SessionStart、PreToolUse deny/allow、PostToolUse,确认无发现时 stdout 为空、有输出时符合 ZCode 严格 JSON
- 安装报告必须提示:ZCode 3.3.4 不执行项目/plugin custom agents,full/lean 多 Agent 请求会稳定降级 solo/direct;Hook 依赖 PATH 中的 ;部署后新开 ZCode session 刷新 Skills/Commands/AGENTS.md
node
- 检查根
- 验证 OpenClaw 部署(仅当 target_cli 含 openclaw 时):
- 检查 含 OpenClaw story skill routing sections
AGENTS.md - 检查 下 13 个 story skill 目录存在,且每个
skills/包含单行SKILL.md、单行name、单行 JSONdescriptionmetadata.openclaw - 检查 下 reference 文件完整且数量与源目录一致
skills/story-setup/references/agent-references/ - 安装报告必须提示:OpenClaw Phase 1 是 skills-only;未部署 OpenClaw agents/hooks,运行时硬拦截不可用,写正文前大纲守卫、commit 提醒、session/compact 自动注入只作为 skill 内软约束;OpenClaw 在 session 启动时 snapshot eligible skills,部署后如命令/skills 未出现,需新开 OpenClaw session 或等待 skills watcher 刷新
- 检查
- 验证通用 Web AI / 其他 Agent 部署(仅当 target_cli 含 generic 时):
- 检查 含通用 story skill routing sections
AGENTS.md - 检查 下 13 个 story skill 目录存在,且每个
skills/可读SKILL.md - 检查 下 reference 文件完整且数量与源目录一致
skills/story-setup/references/agent-references/ - 安装报告必须提示:generic 不部署平台专属 hooks/custom agents;大纲守卫、commit 提醒、session/compact 注入等硬拦截与多 agent 协作都按 skill 内软约束或 solo/direct fallback 执行
- 检查
- 验证 Reasonix 部署(仅当 target_cli 含 reasonix 时):
- 检查 含 Reasonix story skill routing sections 与 solo/direct fallback 说明
AGENTS.md - 检查 下 13 个 story skill 目录存在,且每个
skills/可读SKILL.md - 检查项目 为指向
.agents/skills的 symlink(POSIX;使 Reasonix 原生扫描发现 skill);Windows 未建 symlink 时改为确认根skills/可用于reasonix-plugin.jsonreasonix plugin install - 检查 下 reference 文件完整且数量与源目录一致
skills/story-setup/references/agent-references/ - 安装报告必须提示:Reasonix 当前是 skills-only;未部署 Reasonix hooks/custom agents,写正文前大纲守卫、commit 提醒、session/compact 自动注入只作为 skill 内软约束,涉及专业 Agent 的 Skill 走 solo/direct fallback;可用 校验 skill 发现,部署后如未显示新 skills,新开 Reasonix session 或走根
reasonix doctor capabilities原生 plugin 安装reasonix-plugin.json
- 检查
- Verify hook registration:
- Check if the hooks field in is correct
.claude/settings.local.json - Check if the scripts under exist and have execution permissions
.claude/hooks/ - Check if and
.claude/hooks/lib/common.shexist.claude/hooks/lib/sentinel.sh
- Check if the hooks field in
- Verify rules path:
- Check if the rule files under exist and contain
.claude/rules/frontmatterpaths
- Check if the rule files under
- Verify agents:
- Check if the 7 agent definition files under exist
.claude/agents/
- Check if the 7 agent definition files under
- Verify agent reference bundle:
- Check if the reference files under are complete
.claude/skills/story-setup/references/agent-references/ - Check that all can resolve to the deployed bundle
story-setup/references/agent-references/<file>.md
- Check if the reference files under
- Verify deployment marker:
- Check if exists and contains timestamp,
.story-deployed,agents_version: 25,setup_skill_version: 1.2.7,target_cli,resolver_strategyreferences_dir
- Check if
- Output installation report:
- List all deployed files
- List matters needing attention (such as existing configurations have been merged)
- ⚠️ Restart Prompt (must be output prominently): This deployment wrote to , but these custom agents are only registered as
.claude/agents/by Claude Code when the "session starts".Please start a new Claude Code session before writing, otherwise when story-review / story-long-write etc. try to spawnsubagent_type,story-architectetc. in the current session, they will get "subagent_type unavailable" and downgrade to solo (single perspective, losing multi-agent collaboration). To judge whether it takes effect: Runnarrative-writerin the new session, if the report header is/story-review, registration is successful; if it isEffective Mode: full/lean, it means you are still in the old session or not registered.Fallback: ... -> solo - You can use or
/story-long-writeafter restart/story-short-write - If "Configure OpenCode Agent Model" was executed, output Agent model configuration summary:
Agent Model Configuration: story-architect → <high-end model> (provider/model-id) narrative-writer → <mid-end model> (provider/model-id) character-designer → <mid-end model> (provider/model-id) story-researcher → <mid-end model> (provider/model-id) chapter-extractor → <low-end model> (provider/model-id) consistency-checker → <low-end model> (provider/model-id) story-explorer → <low-end model> (provider/model-id) - If automatic detection fails (is unavailable), output manual configuration guide:
opencode modelsUnable to automatically detect model list. The following Agents are not configured with models and will use the main model, cost may be higher: - chapter-extractor (recommended to use low-cost model) - consistency-checker (recommended to use low-cost model) - story-explorer (recommended to use low-cost model) Manual configuration method: Edit .opencode/agents/{agent-name}.md, add to frontmatter: model: provider/model-id Available model list and cost can be viewed via opencode models --verbose (output includes cost/context per model). Model library and pricing see OpenCode official model source https://models.dev/.
- Verify opencode deployment (only when target_cli contains opencode):
- Check if the 7 agent definition files under exist, and the frontmatter contains
.opencode/agents/andmode: subagentfieldspermission - Check if exists
.opencode/plugins/story-hooks.ts - Check if exists and passes
.opencode/plugins/lib/story_hook_core.js(imported by story-hooks.ts, shared prose guard core with identical bytes tonode --checkcopy; placed in.zcodesubdirectory to avoid OpenCode's automatic discovery of single-layerlib/plugins).opencode/plugins/*.js - Check if the 13 command files under exist
.opencode/commands/ - Check if the reference files under are complete and the quantity is the same as the source directory
skills/story-setup/references/agent-references/ - Check if the array in
plugincontains the story-hooks entryopencode.json - Check if exists and has execution permissions (skip execution permission check on Windows)
.git/hooks/pre-commit - Check if the frontmatter of agent files under can be parsed by YAML, and
.opencode/agents/(if configured) is a valid top-level scalar, not just grep formodel:substringmodel:
- Check if the 7 agent definition files under
- Verify Codex deployment (only when target_cli contains codex):
- Check if contains Codex story skill routing sections
AGENTS.md - Check if 7 agent definition files under
.tomlexist and can be parsed.codex/agents/ - Check if exists and is JSON valid, Unix
.codex/hooks.jsonis only started viacommand, Windowsrun-story-hook.shis only started viacommandWindows; no registration of direct callrun-story-hook.cmdexistsstory_codex_hook.py - Check if ,
.codex/hooks/story_codex_hook.py,run-story-hook.shexist, Python syntax is valid, POSIX/Windows launcher can locate project root from nested cwdrun-story-hook.cmd - Check if the reference files under are complete and the quantity is the same as the source directory
.codex/skills/story-setup/references/agent-references/ - The installation report must prompt: Codex needs to trust the project's configuration layer, and review/trust non-managed hooks in
.codex/; start a new Codex session after deployment to make custom agents take effect; if the current runtime still returns/hooks, downgrade to solo/direct according to the fallback rules of each skillunknown agent_type
- Check if
- Verify ZCode deployment (only when target_cli contains zcode):
- Check if the root contains ZCode
AGENTS.mdrouting, outline guard and solo/direct fallback$story-* - Check 13 Skills under and 13 Commands under
.zcode/skills/, verify frontmatter and naming.zcode/commands/ - Check if ,
.zcode/hooks/story_zcode_hook.jsexist and pass.zcode/hooks/story_hook_core.jsnode --check - Check if is JSON valid, and verify according to hooks mutual exclusion branch in Step 4 of "ZCode Deployment Algorithm": When oh-story plugin is not installed,
.zcode/config.json, only register ZCode supported events, allhooks.enabled=trueargs point to project Hook; when oh-story plugin is installed (processhas globally registered these hooks), instead verify that.zcode-plugin/plugin.jsondoes not contain (or has removed) these oh-story hook registrations —do not merge the hooks block of.zcode/config.jsonback to make verification pass, otherwise the same event will be triggered twiceconfig.json.patch - Check if is complete and all reference paths can be resolved
.zcode/skills/story-setup/references/agent-references/ - Call SessionStart, PreToolUse deny/allow, PostToolUse with fixture, confirm stdout is empty when no discovery, and conforms to ZCode strict JSON when there is output
- The installation report must prompt: ZCode 3.3.4 does not execute project/plugin custom agents, full/lean multi-Agent requests will be stably downgraded to solo/direct; Hook depends on in PATH; start a new ZCode session after deployment to refresh Skills/Commands/AGENTS.md
node
- Check if the root
- Verify OpenClaw deployment (only when target_cli contains openclaw):
- Check if contains OpenClaw story skill routing sections
AGENTS.md - Check if 13 story skill directories under exist, and each
skills/contains single-lineSKILL.md, single-linename, single-line JSONdescriptionmetadata.openclaw - Check if the reference files under are complete and the quantity is the same as the source directory
skills/story-setup/references/agent-references/ - The installation report must prompt: OpenClaw Phase 1 is skills-only; OpenClaw agents/hooks are not deployed, runtime hard interception is unavailable, outline guard before writing prose, commit reminder, session/compact automatic injection only serve as soft constraints within skills; OpenClaw snapshots eligible skills when the session starts, if commands/skills do not appear after deployment, start a new OpenClaw session or wait for skills watcher to refresh
- Check if
- Verify General Web AI / Other Agent deployment (only when target_cli contains generic):
- Check if contains general story skill routing sections
AGENTS.md - Check if 13 story skill directories under exist, and each
skills/is readableSKILL.md - Check if the reference files under are complete and the quantity is the same as the source directory
skills/story-setup/references/agent-references/ - The installation report must prompt: generic does not deploy platform-specific hooks/custom agents; hard interception such as outline guard, commit reminder, session/compact injection and multi-agent collaboration are executed according to soft constraints within skills or solo/direct fallback
- Check if
- Verify Reasonix deployment (only when target_cli contains reasonix):
- Check if contains Reasonix story skill routing sections and solo/direct fallback instructions
AGENTS.md - Check if 13 story skill directories under exist, and each
skills/is readableSKILL.md - Check if the project's is a symlink pointing to
.agents/skills(POSIX; allows Reasonix native scanning to discover skills); when symlink is not created on Windows, instead confirm that the rootskills/can be used forreasonix-plugin.jsonreasonix plugin install - Check if the reference files under are complete and the quantity is the same as the source directory
skills/story-setup/references/agent-references/ - The installation report must prompt: Reasonix is currently skills-only; Reasonix hooks/custom agents are not deployed, outline guard before writing prose, commit reminder, session/compact automatic injection only serve as soft constraints within skills, Skills involving professional Agents use solo/direct fallback; use to verify skill discovery, if new skills do not appear after deployment, start a new Reasonix session or use root
reasonix doctor capabilitiesfor native plugin installationreasonix-plugin.json
- Check if
模板占位符
Template Placeholders
| 占位符 | 替换规则 | 示例 |
|---|---|---|
| 用户项目名称或目录名 | 《剑来》、《暗卫》 |
| 书名目录名(与目录一致) | 与 |
| 目标发布平台 | 起点、番茄、晋江、知乎盐言 |
| 用户笔名或昵称 | 未指定时用「作者」 |
替换时去掉花括号。如果用户未指定项目名,用当前目录名。未指定的占位符保留原样不替换。
| Placeholder | Replacement Rule | Example |
|---|---|---|
| User project name or directory name | 《Sword Comes》, 《Dark Guard》 |
| Book title directory name (consistent with directory) | Same as |
| Target publishing platform | Qidian, Tomato, Jinjiang, Zhihu Yanyan |
| User pen name or nickname | Use "Author" if not specified |
Remove curly braces when replacing. If the user does not specify a project name, use the current directory name. Unspecified placeholders are retained as-is.
CLAUDE.md 合并策略
CLAUDE.md Merge Strategy
用户已有 CLAUDE.md 时,按 marker/section 合并:
- 优先识别 story-setup 管理块标记(如果旧项目已有标记,只替换标记内内容)
- 无标记时,读取用户现有 CLAUDE.md,按 标题切分为 section map
## - 读取模板 CLAUDE.md.tmpl,同样切分
- 模板中的标准 section(Skill 路由表、文件结构、协作规则、Compact 后恢复上下文)覆盖用户同名 section
- 用户独有的 section(自定义内容)保留不动
- 未知冲突用 AskUserQuestion 让用户选择保留哪个版本
When the user already has CLAUDE.md, merge by marker/section:
- Prioritize identifying story-setup managed block markers (if the old project already has markers, only replace the content within the markers)
- If no markers exist, read the user's existing CLAUDE.md and split into section map by titles
## - Read the template CLAUDE.md.tmpl and split in the same way
- Standard sections in the template (Skill routing table, file structure, collaboration rules, restore context after Compact) override the user's sections with the same name
- User's unique sections (custom content) retained unchanged
- For unknown conflicts, use AskUserQuestion to let the user choose which version to retain
AGENTS.md 合并策略(OpenCode / Codex / ZCode / OpenClaw / Reasonix / generic)
AGENTS.md Merge Strategy (OpenCode / Codex / ZCode / OpenClaw / Reasonix / generic)
用户已有 AGENTS.md 时,按 marker/section 合并:
- 优先识别 story-setup 管理块标记(如果旧项目已有标记,只替换标记内内容)
- 无标记时,读取用户现有 AGENTS.md,按 标题切分为 section map
## - OpenCode 使用 ;Codex 使用
skills/story-setup/references/opencode/AGENTS.md.tmpl;ZCode 使用skills/story-setup/references/codex/AGENTS.md.tmpl;OpenClaw 使用skills/story-setup/references/zcode/AGENTS.md.tmpl;Reasonix 使用skills/story-setup/references/openclaw/AGENTS.md.tmpl;通用 Web AI / 其他 Agent 使用skills/story-setup/references/reasonix/AGENTS.md.tmplskills/story-setup/references/generic/AGENTS.md.tmpl - 模板中的标准 section(Skill 路由表、文件结构、协作规则、Compact 后恢复上下文)覆盖同名 section;用户独有 section 保留
- 多端同时部署时,Codex/OpenCode/ZCode/OpenClaw/Reasonix/generic 共同可用的通用段落只保留一份;工具特有说明以小节区分,避免互相覆盖
When the user already has AGENTS.md, merge by marker/section:
- Prioritize identifying story-setup managed block markers (if the old project already has markers, only replace the content within the markers)
- If no markers exist, read the user's existing AGENTS.md and split into section map by titles
## - OpenCode uses ; Codex uses
skills/story-setup/references/opencode/AGENTS.md.tmpl; ZCode usesskills/story-setup/references/codex/AGENTS.md.tmpl; OpenClaw usesskills/story-setup/references/zcode/AGENTS.md.tmpl; Reasonix usesskills/story-setup/references/openclaw/AGENTS.md.tmpl; General Web AI / Other Agents useskills/story-setup/references/reasonix/AGENTS.md.tmplskills/story-setup/references/generic/AGENTS.md.tmpl - Standard sections in the template (Skill routing table, file structure, collaboration rules, restore context after Compact) override sections with the same name; user's unique sections are retained
- When deploying to multiple ends, retain only one copy of general paragraphs common to Codex/OpenCode/ZCode/OpenClaw/Reasonix/generic; tool-specific instructions are distinguished by subsections to avoid overwriting each other
重新部署
Redeployment
- 不存在 → 全新安装,Phase 2 全部执行
.story-deployed - 存在且
.story-deployed→ 提示已部署,AskUserQuestion 确认是否重新部署;提示里写明重新部署只用当前本地 skill 包刷新项目文件,skill 本身的更新走agents_version: 25或 marketplacenpx skills add - 存在但
.story-deployed缺失、非整数或小于agents_version→ 提示需要更新,重新执行 Phase 2 覆盖 agents/hooks/rules/reference bundle,CLAUDE.md / AGENTS.md / settings.local.json / .codex/hooks.json / .zcode/config.json 走合并策略25 - 存在且
.story-deployed大于agents_version→ 当前 skill 版本过旧,停止并提示先更新 oh-story-claudecode;不覆盖项目中的更新部署25
- does not exist → New installation, execute all of Phase 2
.story-deployed - exists and
.story-deployed→ Prompt that it has been deployed, use AskUserQuestion to confirm whether to redeploy; clearly state in the prompt that redeployment only refreshes project files using the current local skill package, skill updates are done viaagents_version: 25or marketplacenpx skills add - exists but
.story-deployedis missing, non-integer or less thanagents_version→ Prompt that update is needed, re-execute Phase 2 to overwrite agents/hooks/rules/reference bundle, CLAUDE.md / AGENTS.md / settings.local.json / .codex/hooks.json / .zcode/config.json follow merge strategy25 - exists and
.story-deployedis greater thanagents_version→ Current skill version is too old, stop and prompt to update oh-story-claudecode first; do not overwrite updated deployment in the project25
参考资料
Reference Materials
| 文件 | 用途 |
|---|---|
| references/templates/hooks/ | 8 个 hook 脚本模板 + |
| references/zcode/ | ZCode AGENTS、13 Commands、workspace config patch 与严格 JSON Hook runner |
| File | Purpose |
|---|---|
| references/templates/hooks/ | 8 hook script templates + |
| references/zcode/ | ZCode AGENTS, 13 Commands, workspace config patch and strict JSON Hook runner |
流程衔接
Process Connection
流水线: 部署
位置: 初始化(最前置)
| 时机 | 跳转到 | 命令 |
|---|---|---|
| 部署完成,开始写作 | story-long-write / story-short-write | |
| 导入已有小说做拆解 | story-import | |
| 需要浏览器登录态(扫榜/拆文取原文) | browser-cdp | |
各端调用语法:Claude 、Codex/ZCode 、OpenClaw 、Reasonix / generic 直接点名 skill。
/名$名/skill 名Pipeline: Deployment
Position: Initialization (most front-end)
| Timing | Jump to | Command |
|---|---|---|
| Deployment completed, start writing | story-long-write / story-short-write | |
| Import existing novel for disassembly | story-import | |
| Need browser login state (rank scanning/extract original text from novel) | browser-cdp | |
Calling syntax for each end: Claude , Codex/ZCode , OpenClaw , Reasonix / generic directly name the skill.
/name$name/skill name