story-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

story-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

先自检参考目录:以正在执行的本
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 个子目录本就齐全,照常核对即可。
  1. 检查当前目录是否已部署过(存在
    .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。
  2. 检查是否有书名目录(包含
    追踪/
    子目录的目录,或用户自定义结构)
    • 有 → 识别为长篇项目,显示当前项目信息
    • 无 → 识别为新项目或短篇项目
  3. 检查
    .claude/settings.local.json
    是否存在
    • 存在 → 读取现有配置,后续合并
    • 不存在 → 后续创建新文件
  4. 检查
    .active-book
    文件是否存在
    • 存在 → 显示当前活跃书目
    • 不存在 → 跳过
  5. 检查
    opencode.json
    .opencode/
    是否存在
    • 存在 → 识别为 opencode 项目,
      target_cli = opencode
    • 不存在 → 跳过
  6. 检查
    .codex/
    .codex/config.toml
    .codex/agents/
    .codex/hooks.json
    AGENTS.md
    中的 Codex 段
    • 存在 → 识别为 Codex 项目,
      target_cli = codex
    • 不存在 → 跳过
  7. 检查
    .zcode/
    .zcode/config.json
    zcode.json
    .zcode/skills/
    .zcode/commands/
    AGENTS.md
    中的 ZCode 段
    • 存在 → 识别为 ZCode 项目,
      target_cli = zcode
    • 不存在 → 跳过
  8. 检查
    openclaw.json
    .openclaw/
    ,或
    AGENTS.md
    中的 OpenClaw 段(标题行含
    网文写作工具集(OpenClaw)
    • 存在 → 识别为 OpenClaw 项目,
      target_cli = openclaw
    • 不存在 → 跳过
  9. 检查
    .reasonix/
    reasonix-plugin.json
    REASONIX.md
    ,或
    AGENTS.md
    中的 Reasonix 段(标题行含
    网文写作工具集(Reasonix)
    • 存在 → 识别为 Reasonix 项目,
      target_cli = reasonix
    • 不存在 → 跳过
  10. 检查
    AGENTS.md
    中的通用段(标题行含
    网文写作工具集(通用 Agent / Web AI)
  • 存在 → 识别为通用 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
模板的标题行。
  1. .claude/
    CLAUDE.md
    、OpenCode、Codex、ZCode、OpenClaw、Reasonix、generic 标记同时存在 → 使用 AskUserQuestion 让用户选择目标环境(选项:Claude Code / OpenCode / Codex / ZCode / OpenClaw / Reasonix / 通用 Web AI 或其他 Agent / 任意组合)
  2. 如七类标记都不存在(全新项目)→ 使用 AskUserQuestion 让用户选择目标环境
  • 用户选择 opencode →
    target_cli = opencode
    ,部署时创建
    opencode.json
    .opencode/
  • 用户选择 claude-code → 按现有逻辑处理
  • 用户选择 codex →
    target_cli = codex
    ,部署时创建
    .codex/
  • 用户选择 zcode →
    target_cli = zcode
    ,部署时创建
    .zcode/
    、合并根
    AGENTS.md
    ,不创建项目 custom agents
  • 用户选择 openclaw →
    target_cli = openclaw
    ,部署时复制 OpenClaw 兼容 skills 到项目
    skills/
  • 用户选择 reasonix →
    target_cli = reasonix
    ,部署时复制 skills 到项目
    skills/
    、写入 Reasonix 版
    AGENTS.md
    ,不创建项目 custom agents/hooks
  • 用户选择通用 Web AI / 其他 Agent →
    target_cli = generic
    ,部署通用
    AGENTS.md
    与项目本地
    skills/
    ;不写平台专属 hooks/agents
  • 用户选择多端 →
    target_cli = claude-code,opencode,codex,zcode,openclaw,reasonix,generic
    的子集(仅包含用户选择的端)
First self-check reference directory: Based on the directory where this executing
SKILL.md
is located, list the subdirectories under the sibling
references/
, and verify that all 8 names below exist and are non-empty
agent-references
,
templates
,
opencode
,
codex
,
zcode
,
openclaw
,
reasonix
,
generic
; the sibling
scripts/merge-claude-settings.py
,
scripts/merge-codex-hooks.py
and
scripts/copy-path-safety.py
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
npx skills add zenstory-ai/oh-story-claudecode -y -g
again if installed via command line, reinstall via the panel if installed via marketplace / Plugin Management), then execute /story-setup."
The criterion is "whether
SKILL.md
exists": Only check the
references/
at the same level as the executing
SKILL.md
. The project's
.claude/skills/story-setup/
,
.codex/skills/story-setup/
and OpenCode's
skills/story-setup/
only have
references/agent-references/
and do not contain
SKILL.md
, 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 own
SKILL.md
, and the 8 subdirectories are complete, so verify as usual.
  1. Check if the current directory has been deployed (
    .story-deployed
    exists)
    • agents_version
      is missing, non-integer or less than
      25
      → Mark as pending update, continue with current deployment
    • agents_version: 25
      → 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
      npx skills add
      or marketplace), then run /story-setup again
    • agents_version
      is greater than
      25
      → 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 files
    • At the same time, read the
      target_cli
      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.
  2. Check if there is a book title directory (a directory containing a
    追踪/
    subdirectory, 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
  3. Check if
    .claude/settings.local.json
    exists
    • Exists → Read existing configuration, merge later
    • Does not exist → Create a new file later
  4. Check if
    .active-book
    file exists
    • Exists → Display current active book title
    • Does not exist → Skip
  5. Check if
    opencode.json
    or
    .opencode/
    exists
    • Exists → Identify as an opencode project,
      target_cli = opencode
    • Does not exist → Skip
  6. Check
    .codex/
    ,
    .codex/config.toml
    ,
    .codex/agents/
    ,
    .codex/hooks.json
    , Codex section in
    AGENTS.md
    • Exists → Identify as a Codex project,
      target_cli = codex
    • Does not exist → Skip
  7. Check
    .zcode/
    ,
    .zcode/config.json
    ,
    zcode.json
    ,
    .zcode/skills/
    ,
    .zcode/commands/
    , ZCode section in
    AGENTS.md
    • Exists → Identify as a ZCode project,
      target_cli = zcode
    • Does not exist → Skip
  8. Check
    openclaw.json
    ,
    .openclaw/
    , or OpenClaw section in
    AGENTS.md
    (title line contains "网文写作工具集(OpenClaw)")
    • Exists → Identify as an OpenClaw project,
      target_cli = openclaw
    • Does not exist → Skip
  9. Check
    .reasonix/
    ,
    reasonix-plugin.json
    ,
    REASONIX.md
    , or Reasonix section in
    AGENTS.md
    (title line contains "网文写作工具集(Reasonix)")
    • Exists → Identify as a Reasonix project,
      target_cli = reasonix
    • Does not exist → Skip
  10. Check the general section in
    AGENTS.md
    (title line contains "网文写作工具集(通用 Agent / Web AI)")
    • 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.
    metadata.openclaw
    in
    skills/*/SKILL.md
    is not used as an OpenClaw signal: All 13 skills have this field, and the
    skills/
    deployed 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.
    .agents/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.md
    templates.
  11. If
    .claude/
    or
    CLAUDE.md
    , 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)
  12. 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 →
      target_cli = opencode
      , create
      opencode.json
      and
      .opencode/
      during deployment
    • User selects claude-code → Process according to existing logic
    • User selects codex →
      target_cli = codex
      , create
      .codex/
      during deployment
    • User selects zcode →
      target_cli = zcode
      , merge root
      AGENTS.md
      during deployment, do not create project custom agents
    • User selects openclaw →
      target_cli = openclaw
      , copy OpenClaw-compatible skills to project
      skills/
      during deployment
    • User selects reasonix →
      target_cli = reasonix
      , copy skills to project
      skills/
      and write Reasonix version
      AGENTS.md
      during deployment, do not create project custom agents/hooks
    • User selects General Web AI / other Agent →
      target_cli = generic
      , deploy general
      AGENTS.md
      and project local
      skills/
      ; do not write platform-specific hooks/agents
    • User selects multiple ends →
      target_cli = subset of claude-code,opencode,codex,zcode,openclaw,reasonix,generic
      (only includes the ends selected by the user)

Phase 2:部署基础设施

Phase 2: Deploy Infrastructure

使用 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/
,整段删掉再部署,并在安装报告里列出删掉的路径。
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
create only if absent
(see Owner class in the table below) will not be overwritten for the second time.
The two columns have different base directories:
Source path
is relative to the executing skill package,
Target path
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
scripts/copy-path-safety.py
at the same level as this
SKILL.md
to check. This script follows existing symlinks according to
Path.resolve
/
realpath
semantics, and uses
samefile
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
status: same
, no-op, copying is prohibited; only when
copy_allowed: true
can copying be performed; if
source_missing
,
unsafe_target_within_source
or
filesystem_identity_error
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
.agents/skills → ../skills
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.
Clean up self-nested residues before deployment: If there is an extra
agent-references/
layer (possibly multiple nested layers) in
{.claude,.codex,.zcode}/skills/story-setup/references/agent-references/
and the project root
skills/story-setup/references/agent-references/
, as well as
skills/story-setup/skills/
, delete the entire segment before deployment, and list the deleted paths in the installation report.

Step 1:部署清单(机械可检查)

Step 1: Deployment Checklist (Mechanically Verifiable)

Source pathTarget pathOwner classMerge modeValidation check
skills/story-setup/references/templates/CLAUDE.md.tmpl
CLAUDE.md
user+managedmarker/section mergecontains story skill routing sections
skills/story-setup/references/templates/hooks/
.claude/hooks/
story-setup managedrecursive 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 managedreplaceevery rule contains
paths
frontmatter
skills/story-setup/references/templates/agents/*.md
.claude/agents/*.md
story-setup managedreplace7 agent files exist
skills/story-setup/references/agent-references/*.md
.claude/skills/story-setup/references/agent-references/*.md
story-setup managedreplaceevery
story-setup/references/agent-references/*.md
reference resolves
skills/story-setup/references/templates/settings-hooks.json
.claude/settings.local.json
user+managedreplace managed registrations by stable hook identityhook JSON valid;旧 matcher 注册已迁移、当前模板命令各一份、用户 hook 保留
skills/story-setup/scripts/merge-claude-settings.py
部署时执行,不复制到项目story-setup helperexecute替换已知 story hook 注册、保留用户 hooks/顶层字段,v24→v25 迁移与重复执行幂等
skills/story-setup/scripts/copy-path-safety.py
每个递归复制步骤前执行,不复制到项目专用目录story-setup helperexecuteJSON 仅
copy_allowed: true
时允许复制;symlink 同对象 no-op;target 位于 source 内时停止
generated sentinel
.story-deployed
story-setup managedreplacecontains
agents_version
,
setup_skill_version
,
target_cli
,
resolver_strategy
,
references_dir
skills/story-setup/references/opencode/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains story skill routing sections
skills/story-setup/references/opencode/agents/
.opencode/agents/
story-setup managedreplace7 agent files exist(replace 前按「配置 OpenCode Agent 模型」中的「保留已有模型配置」缓存现有
model:
,避免覆盖用户已配模型)
skills/story-setup/references/opencode/plugin.ts
.opencode/plugins/story-hooks.ts
story-setup managedreplaceTypeScript plugin file exists
skills/story-setup/references/opencode/story_hook_core.js
.opencode/plugins/lib/story_hook_core.js
story-setup managedreplaceNode syntax valid;与 ZCode 副本字节一致;被 story-hooks.ts import
skills/story-setup/references/opencode/commands/
.opencode/commands/
story-setup managedreplace13 command files exist
skills/story-setup/references/opencode/opencode.json.patch
merge into
opencode.json
user+managedmerge by plugin/permission keyplugin entry registered
repository
skills/story-setup/references/agent-references/
skills/story-setup/references/agent-references/
story-setup managedreplaceevery reference resolves
skills/story-setup/references/opencode/pre-commit.sh
.git/hooks/pre-commit
user+managedappend or createfile exists and is executable;含 marker 块则替换块内容,不含则检测 exit 0 位置智能插入
skills/story-setup/references/codex/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains Codex story skill routing sections
skills/story-setup/references/codex/agents/
.codex/agents/
story-setup managedreplace7 TOML agent files parse and contain
name
/
description
/
developer_instructions
skills/story-setup/references/codex/hooks/hooks.json
.codex/hooks.json
user+managedreplace managed registrations by stable hook identityhook 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 managedreplacePython/shell/cmd launcher 文件齐全
skills/story-setup/scripts/merge-codex-hooks.py
部署时执行,不复制到项目story-setup helperexecute替换已知管理注册、保留用户 hooks 与未知顶层字段,结果幂等
skills/story-setup/references/agent-references/
.codex/skills/story-setup/references/agent-references/
story-setup managedreplaceevery reference resolves
skills/story-setup/references/zcode/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains ZCode
$story-*
routing and solo fallback
repository
skills/{browser-cdp,story*}/
.zcode/skills/{browser-cdp,story*}/
story-setup managed for known skill namesreplace known skill dirs only13
SKILL.md
files exist and satisfy ZCode frontmatter limits
skills/story-setup/references/zcode/commands/
.zcode/commands/
story-setup managed for known command namesreplace known command files only13 commands have valid names/frontmatter
skills/story-setup/references/zcode/hooks/story_zcode_hook.js
.zcode/hooks/story_zcode_hook.js
story-setup managedreplaceNode syntax valid; hook contract tests pass
skills/story-setup/references/zcode/hooks/story_hook_core.js
.zcode/hooks/story_hook_core.js
story-setup managedreplaceNode syntax valid; hook contract tests pass
skills/story-setup/references/zcode/config.json.patch
merge into
.zcode/config.json
user+managedmerge by event+matcher+process argsJSON 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+managedmarker/section mergecontains OpenClaw story skill routing sections
skills/story-setup/references/generic/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains generic story skill routing sections
skills/story-setup/references/reasonix/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains Reasonix story skill routing sections and solo/direct fallback
repository
skills/{browser-cdp,story*}/
skills/{browser-cdp,story*}/
story-setup managed for known skill namesreplace known skill dirs only13
SKILL.md
files exist; OpenClaw-compatible frontmatter
repository
skills/story-setup/references/agent-references/
随上一行整份 skill 拷贝落地,本行 no-opstory-setup managed不单独复制every reference resolves
Source pathTarget pathOwner classMerge modeValidation check
skills/story-setup/references/templates/CLAUDE.md.tmpl
CLAUDE.md
user+managedmarker/section mergecontains story skill routing sections
skills/story-setup/references/templates/hooks/
.claude/hooks/
story-setup managedrecursive 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
has identical bytes with OpenCode/ZCode copies
skills/story-setup/references/templates/rules/*.md
.claude/rules/*.md
story-setup managedreplaceevery rule contains
paths
frontmatter
skills/story-setup/references/templates/agents/*.md
.claude/agents/*.md
story-setup managedreplace7 agent files exist
skills/story-setup/references/agent-references/*.md
.claude/skills/story-setup/references/agent-references/*.md
story-setup managedreplaceevery
story-setup/references/agent-references/*.md
reference resolves
skills/story-setup/references/templates/settings-hooks.json
.claude/settings.local.json
user+managedreplace managed registrations by stable hook identityhook JSON valid;old matcher registrations have been migrated, each current template command exists once, user hooks are retained
skills/story-setup/scripts/merge-claude-settings.py
Executed during deployment, not copied to projectstory-setup helperexecutereplaces known story hook registrations, retains user hooks/top-level fields, v24→v25 migration and repeated execution are idempotent
skills/story-setup/scripts/copy-path-safety.py
Executed before each recursive copy step, not copied to project-specific directorystory-setup helperexecuteJSON allows copying only when
copy_allowed: true
; symlink to same object is no-op; stop when target is within source
generated sentinel
.story-deployed
story-setup managedreplacecontains
agents_version
,
setup_skill_version
,
target_cli
,
resolver_strategy
,
references_dir
skills/story-setup/references/opencode/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains story skill routing sections
skills/story-setup/references/opencode/agents/
.opencode/agents/
story-setup managedreplace7 agent files exist (before replace, cache existing
model:
according to "Retain existing model configuration" in "Configure OpenCode Agent Model" to avoid overwriting user-configured models)
skills/story-setup/references/opencode/plugin.ts
.opencode/plugins/story-hooks.ts
story-setup managedreplaceTypeScript plugin file exists
skills/story-setup/references/opencode/story_hook_core.js
.opencode/plugins/lib/story_hook_core.js
story-setup managedreplaceNode syntax valid;has identical bytes with ZCode copies;imported by story-hooks.ts
skills/story-setup/references/opencode/commands/
.opencode/commands/
story-setup managedreplace13 command files exist
skills/story-setup/references/opencode/opencode.json.patch
merge into
opencode.json
user+managedmerge by plugin/permission keyplugin entry registered
repository
skills/story-setup/references/agent-references/
skills/story-setup/references/agent-references/
story-setup managedreplaceevery reference resolves
skills/story-setup/references/opencode/pre-commit.sh
.git/hooks/pre-commit
user+managedappend or createfile exists and is executable;if marker block exists, replace block content, if not, intelligently insert by detecting exit 0 position
skills/story-setup/references/codex/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains Codex story skill routing sections
skills/story-setup/references/codex/agents/
.codex/agents/
story-setup managedreplace7 TOML agent files parse and contain
name
/
description
/
developer_instructions
skills/story-setup/references/codex/hooks/hooks.json
.codex/hooks.json
user+managedreplace managed registrations by stable hook identityhook 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}
Same-named files in
.codex/hooks/
story-setup managedreplacePython/shell/cmd launcher files are complete
skills/story-setup/scripts/merge-codex-hooks.py
Executed during deployment, not copied to projectstory-setup helperexecutereplaces known managed registrations, retains user hooks and unknown top-level fields, results are idempotent
skills/story-setup/references/agent-references/
.codex/skills/story-setup/references/agent-references/
story-setup managedreplaceevery reference resolves
skills/story-setup/references/zcode/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains ZCode
$story-*
routing and solo fallback
repository
skills/{browser-cdp,story*}/
.zcode/skills/{browser-cdp,story*}/
story-setup managed for known skill namesreplace known skill dirs only13
SKILL.md
files exist and satisfy ZCode frontmatter limits
skills/story-setup/references/zcode/commands/
.zcode/commands/
story-setup managed for known command namesreplace known command files only13 commands have valid names/frontmatter
skills/story-setup/references/zcode/hooks/story_zcode_hook.js
.zcode/hooks/story_zcode_hook.js
story-setup managedreplaceNode syntax valid; hook contract tests pass
skills/story-setup/references/zcode/hooks/story_hook_core.js
.zcode/hooks/story_hook_core.js
story-setup managedreplaceNode syntax valid; hook contract tests pass
skills/story-setup/references/zcode/config.json.patch
merge into
.zcode/config.json
user+managedmerge by event+matcher+process argsJSON valid; verify according to hooks mutually exclusive branch in "ZCode Deployment Algorithm" Step 4 — when oh-story plugin is not installed,
hooks.enabled=true
、only supported events; when plugin is installed, verify that
.zcode/config.json
does not contain (or has removed) these oh-story hook registrations
skills/story-setup/references/openclaw/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains OpenClaw story skill routing sections
skills/story-setup/references/generic/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains generic story skill routing sections
skills/story-setup/references/reasonix/AGENTS.md.tmpl
AGENTS.md
user+managedmarker/section mergecontains Reasonix story skill routing sections and solo/direct fallback
repository
skills/{browser-cdp,story*}/
skills/{browser-cdp,story*}/
story-setup managed for known skill namesreplace known skill dirs only13
SKILL.md
files exist; OpenClaw-compatible frontmatter
repository
skills/story-setup/references/agent-references/
Landed with the full skill copy in the previous line, no-op for this linestory-setup managedNo separate copyevery reference resolves

opencode.json 合并算法

opencode.json Merge Algorithm

部署
opencode.json.patch
时按以下规则合并:
  1. 读取现有
    opencode.json
    (如存在),解析 JSON
  2. 合并
    plugin
    数组:将
    ./.opencode/plugins/story-hooks.ts
    加入数组,去重
  3. 保留用户已有的其他配置字段(
    permission
    model
    provider
    等),不覆盖
  4. 写入合并后的
    opencode.json
When deploying
opencode.json.patch
, merge according to the following rules:
  1. Read the existing
    opencode.json
    (if exists), parse JSON
  2. Merge the
    plugin
    array: Add
    ./.opencode/plugins/story-hooks.ts
    to the array and deduplicate
  3. Retain other existing configuration fields of the user (such as
    permission
    ,
    model
    ,
    provider
    ), do not overwrite
  4. 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
    CLAUDE.md
    (if it already exists, process according to "CLAUDE.md Merge Strategy")

Step 3:部署 Hooks

Step 3: Deploy Hooks

  • 递归复制完整目录树:将
    skills/story-setup/references/templates/hooks/
    复制到用户项目
    .claude/hooks/
  • 必须保留子目录
    lib/
    ,其中:
    • lib/common.sh
      提供
      project_root
      discover_active_book
      discover_all_books
    • lib/sentinel.sh
      提供
      .story-deployed
      字段读取
  • 只需对
    .claude/hooks/*.sh
    设置执行权限(
    chmod +x
    );
    lib/*.sh
    由 hook
    source
    ,不要求可执行位
  • Recursively copy the complete directory tree: Copy
    skills/story-setup/references/templates/hooks/
    to the user's project
    .claude/hooks/
  • Must retain the subdirectory
    lib/
    , where:
    • lib/common.sh
      provides
      project_root
      ,
      discover_active_book
      ,
      discover_all_books
    • lib/sentinel.sh
      provides
      .story-deployed
      field reading
  • Only need to set execution permissions (
    chmod +x
    ) for
    .claude/hooks/*.sh
    ;
    lib/*.sh
    is sourced by hooks, no need for executable bits

Step 4:部署 Rules

Step 4: Deploy Rules

  • 读取
    skills/story-setup/references/templates/rules/
    下所有
    .md
    文件
  • 复制到用户项目的
    .claude/rules/
    目录
  • Read all
    .md
    files under
    skills/story-setup/references/templates/rules/
  • Copy to the
    .claude/rules/
    directory of the user's project

Step 5:部署 Agents

Step 5: Deploy Agents

  • 读取
    skills/story-setup/references/templates/agents/
    下所有
    .md
    文件
  • 复制到用户项目的
    .claude/agents/
    目录
  • Agent 文件属于 story-setup 管理文件,可安全覆盖;版本升级时按
    UPGRADING.md
    的版本检测结果重新部署
  • target_cli
    含 opencode 时,覆盖
    .opencode/agents/
    之前先执行下面「配置 OpenCode Agent 模型」的 Step 1 缓存现有
    model:
    。那一步写在本节后面,但必须先跑——照顺序读到哪做到哪会先覆盖再缓存,用户已配的模型就没了。
  • 部署后必须新开会话:agent 只在会话启动时注册;原因与必须输出的报告文案见「验证安装」中的「输出安装报告」。
  • Read all
    .md
    files under
    skills/story-setup/references/templates/agents/
  • Copy to the
    .claude/agents/
    directory of the user's project
  • Agent files are managed by story-setup and can be safely overwritten; redeploy according to the version detection results in
    UPGRADING.md
    during version upgrade
  • When
    target_cli
    contains opencode, execute Step 1 of "Configure OpenCode Agent Model" to cache existing
    model:
    before overwriting
    .opencode/agents/
    . 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.
  • 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 的
    .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 3.3.4 不部署项目 agents:其自定义子智能体只支持用户级
    ~/.zcode/agents/
    ,plugin manifest 中的
    agents
    当前不执行。不要创建
    .zcode/agents/
    或修改用户 home;相关 Skill 必须直接 solo/direct 并报告 fallback。
  • OpenClaw Phase 1 不部署 agents:OpenClaw 只部署 skills,agent 协作相关 skill 必须按既有 fallback 规则降级 solo/direct,不要把 Claude/OpenCode agent frontmatter 直接复制成 OpenClaw agent。
  • 部署到项目后,agent 内引用的参考资料必须走
    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/
    ;不在运行时遍历历史备选路径。
  • Agent frontmatter is mainly based on Claude Code; OpenCode's
    .opencode/agents/*.md
    and Codex's
    .codex/agents/*.toml
    are directly copied from pre-generated products under
    references/opencode/agents/
    and
    references/codex/agents/
    , which are the only sources for deployment. The pre-generated products are maintained by
    scripts/sync-opencode.py
    and
    scripts/generate-codex-agents.py
    at 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.
  • ZCode 3.3.4 does not deploy project agents: Its custom sub-agents only support user-level
    ~/.zcode/agents/
    , and the
    agents
    in the plugin manifest is not currently executed. Do not create
    .zcode/agents/
    or modify the user's home; related Skills must directly use solo/direct and report fallback.
  • 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
    story-setup/references/agent-references/*.md
    ; do not reference references from other skills across skills. Each adapter only uses the current specification prefix: Claude Code uses
    .claude/skills/
    , OpenCode / OpenClaw / Reasonix / generic use
    skills/
    , Codex uses
    .codex/skills/
    , ZCode uses
    .zcode/skills/
    ; does not traverse historical alternative paths at runtime.

部署 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
    .md
    files under
    skills/story-setup/references/agent-references/
    to
    .claude/skills/story-setup/references/agent-references/
    in the project
  • Verification: For every occurrence of
    story-setup/references/agent-references/<file>.md
    in agents or references,
    <file>.md
    must exist in both the source package and the target package

部署 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 管理文件,可安全覆盖;
    references/codex/agents/
    里的 TOML 由仓库根的
    scripts/generate-codex-agents.py
    从 Claude agent 模板确定性生成后提交入库,部署只做复制
  • 校验每个 TOML 都能解析,且包含 Codex 必需字段:
    name
    description
    developer_instructions
  • 只读职责 agent(
    chapter-extractor
    consistency-checker
    story-explorer
    )必须保留
    sandbox_mode = "read-only"
  • 部署后必须 trust + 新开 Codex 会话(报告文案与 fallback 规则见「验证 Codex 部署」);若运行时返回
    unknown agent_type
    ,调用方必须降级 solo/direct 并报告 fallback。
  • skills/story-setup/references/agent-references/
    同步复制到
    .codex/skills/story-setup/references/agent-references/
    ,作为 Codex agent 的项目内参考资料主路径
  • Read all
    .toml
    files under
    skills/story-setup/references/codex/agents/
    , copy to the user's project
    .codex/agents/
  • Agent files are managed by story-setup and can be safely overwritten; the TOML in
    references/codex/agents/
    is deterministically generated from Claude agent templates by
    scripts/generate-codex-agents.py
    at the root of the repository and committed to the repository, deployment only does copying
  • Verify that each TOML can be parsed and contains Codex required fields:
    name
    ,
    description
    ,
    developer_instructions
  • Read-only responsibility agents (
    chapter-extractor
    ,
    consistency-checker
    ,
    story-explorer
    ) must retain
    sandbox_mode = "read-only"
  • Must trust + start a new Codex session after deployment (report copy and fallback rules are in "Verify Codex Deployment"); if
    unknown agent_type
    is returned at runtime, the caller must downgrade to solo/direct and report fallback.
  • Synchronously copy
    skills/story-setup/references/agent-references/
    to
    .codex/skills/story-setup/references/agent-references/
    as the main path for intra-project reference materials of Codex agents

配置 OpenCode Agent 模型

Configure OpenCode Agent Model

仅当
target_cli
opencode
时执行。OpenCode 子代理不指定模型时继承主模型,导致低成本 Agent 也消耗主模型额度。此步骤自动检测用户模型并写入
model:
字段。
Only execute when
target_cli
contains
opencode
. 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 the
model:
field.
Step 1:保留已有模型配置(必须在
.opencode/agents/
的 replace 之前执行)
Step 1: Retain Existing Model Configuration (must be executed before replacing
.opencode/agents/
)
OpenCode agents 部署是
replace
,会覆盖上次写入的
model:
。所以在执行该 replace 之前先扫描现有
.opencode/agents/*.md
,缓存每个 agent 的
model:
(agent 名 → 模型 ID)。后续检测失败/超时、或用户跳过某一级时,用缓存值回填,避免把用户上次配好的低成本模型抹成主模型。若 replace 已先发生、缓存为空,则按全新部署处理,并在安装报告中提示"未能保留上次模型配置"。
OpenCode agent deployment uses
replace
, which will overwrite the previously written
model:
. Therefore, before executing this replace, first scan the existing
.opencode/agents/*.md
and cache the
model:
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.
Step 2:获取模型列表
Step 2: Get Model List
优先执行
opencode models --verbose
,它输出含 cost(input/output/cache 单价)、context、capabilities 的 metadata;不可用或解析失败时回退到
opencode models
纯文本(每行
provider/model
)。两者都用 60000ms(60 秒)超时,因为首次运行需加载 models.dev 缓存。
  • 成功 → 进入「模型分级」
  • 超时 → 重试一次(缓存可能未预热);仍然超时则按「保留已有模型配置」缓存回填已有
    model:
    、跳过自动配置,在安装报告中输出手动配置指南
  • 失败(命令不存在、输出为空等)→ 同上:回填「保留已有模型配置」缓存、跳过自动配置、输出手动配置指南
优先执行
opencode models --verbose
,它输出含 cost(input/output/cache 单价)、context、capabilities 的 metadata;不可用或解析失败时回退到
opencode models
纯文本(每行
provider/model
)。两者都用 60000ms(60 秒)超时,因为首次运行需加载 models.dev 缓存。
  • Success → Enter "Model Classification"
  • Timeout → Retry once (cache may not be preheated); if still timeout, fill in the existing
    model:
    with the cache from "Retain Existing Model Configuration", skip automatic configuration, and output manual configuration guide in the installation report
  • 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
优先按成本分级(有
--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
  • 一个模型可能匹配多个等级的关键词,取最高等级
  • 关键词回退下未匹配任何关键词的模型仍列入候选附加建议(按成本分级则一律纳入),并在安装报告列出,提示"可通过自定义输入使用"
  • 同一等级内,如果包含多个模型供应商,优先列出知名供应商(anthropic、openai、google、deepseek)的模型
Prioritize classification by cost (when
--verbose
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.,
nemotron-3-ultra-free
contains
ultra
in the name but cost=0, should be classified as low-end). Models without cost data are also included in candidates and not discarded.
Fallback to classification by keywords (when no
--verbose
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,
minimax-m3
is split into
[minimax, m3]
, does not match
mini
or
max
;
claude-haiku-4.5
is split into
[claude, haiku, 4, 5]
, matches
haiku
. Keyword classification is heuristic, mark "Classification basis: keywords (heuristic)" in the installation report.
GradeMatching KeywordsCorresponding Agents
Low-end
haiku
,
flash
,
mini
,
nano
,
lite
chapter-extractor, consistency-checker, story-explorer
Mid-end
sonnet
,
plus
story-researcher, narrative-writer, character-designer
High-end
opus
,
pro
,
ultra
,
max
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 时仍弹窗,并在问题说明里给出对应警告 + 列出未分级/未入档模型供参考——不再静默跳过交互(否则用户够不到自定义输入)。
  • 自定义输入
    :用户输入
    provider/model-id
    完整 ID;写入前校验为单行、无控制字符、匹配
    ^[A-Za-z0-9._-]+/[A-Za-z0-9._:+-]+$
    ,不符则提示重输或改选跳过。
  • 保留现有模型
    :写回「保留已有模型配置」缓存的该 agent model(重新部署时保住用户上次配置),不算"跳过"。
  • 跳过,用主模型
    :显式清除——不写该 agent 的
    model:
    ,agent 继承主模型。想保留上次配置请选
    保留现有模型
  • 各级候选为 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
    ,
    Retain existing model
    (the model of this agent cached in "Retain Existing Model Configuration", do not display this item if none),
    Skip, use main 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).
  • Custom input
    : User enters full
    provider/model-id
    ; verify it is a single line, no control characters, matches
    ^[A-Za-z0-9._-]+/[A-Za-z0-9._:+-]+$
    before writing, if not, prompt to re-enter or choose to skip.
  • Retain existing model
    : 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".
  • Skip, use main model
    : Explicitly clear — do not write the
    model:
    field for this agent, the agent inherits the main model. To retain previous configuration, select
    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/*.md
,由部署清单中 OpenCode agents 部署步骤在此步骤之前已部署),在 frontmatter 末尾、closing
---
之前,以零缩进的顶层字段插入
model:
(不要插进
permission:
等多行 map 的缩进块内部)。值含 YAML 特殊字符时加引号,确保不破坏 frontmatter:
yaml
---
description: ...
mode: subagent
permission:
  read: allow
  edit: deny
steps: 12
model: provider/model-id
---
  • 如果 agent 文件已有
    model:
    字段(重新部署场景),替换该顶层
    model:
    的值,不新增重复键
  • 保留现有模型
    :写回「保留已有模型配置」缓存的该 agent model
  • 跳过,用主模型
    :不写入
    model:
    字段
  • 检测失败/超时、没走到本步骤的等级:用「保留已有模型配置」缓存回填
    model:
    ,避免 replace 抹掉用户上次配置
For the agent files corresponding to the user's selection (
.opencode/agents/*.md
, which have been deployed by the OpenCode agents deployment step in the deployment checklist before this step), insert
model:
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
permission:
). Add quotes if the value contains YAML special characters to ensure the frontmatter is not damaged:
yaml
---
description: ...
mode: subagent
permission:
  read: allow
  edit: deny
steps: 12
model: provider/model-id
---
  • If the agent file already has a
    model:
    field (redeployment scenario), replace the value of this top-level
    model:
    , do not add duplicate keys
  • Retain existing model
    : Write back the model of this agent cached in "Retain Existing Model Configuration"
  • Skip, use main model
    : Do not write the
    model:
    field
  • For levels that failed/timeout and did not reach this step: Fill in
    model:
    with the cache from "Retain Existing Model Configuration", avoiding overwriting the user's previous configuration due to replace

Step 6:合并 Hooks 注册到 settings.local.json

Step 6: Merge Hook Registrations to settings.local.json

  1. 按现有跨平台规则探测 Python:
    for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done
    ;无可用解释器时停止,不手写或简化合并。
  2. 调用
    "$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"
  3. helper 会移除所有已知 story-setup hook 的历史注册,再追加当前模板;因此 matcher/timeout/if 能随版本升级,同时混在旧 block 中的用户 hook 与未知顶层字段原样保留。写后解析 JSON,验证模板命令各一份、用户配置仍在,再复跑 helper 比较文件字节确认幂等。
  1. Detect Python according to existing cross-platform rules:
    for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done
    ; stop if no available interpreter, do not manually write or simplify merging.
  2. 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"
    .
  3. 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 部署到
.codex/hooks.json
;运行脚本部署到
.codex/hooks/story_codex_hook.py
run-story-hook.sh
run-story-hook.cmd
。JSON 只负责定位项目根与传递 event,解释器探测由平台 launcher 统一处理。
  1. 定位当前 story-setup skill 目录,读取
    references/codex/hooks/hooks.json
    作为唯一当前模板,读取项目
    .codex/hooks.json
    (不存在时视为空对象)。
  2. 按现有跨平台规则探测可用 Python:
    for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done
    ;无可用解释器时停止,不手写或简化 JSON 合并。
  3. 调用
    "$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
    三类管理身份,先移除所有已知管理注册,再追加当前模板。
  4. 保留用户已有的非 story-setup hooks、matcher 块与未知顶层字段。重复执行必须幂等;禁止再按原始
    command
    字符串追加去重,否则 v17 直调命令会与 v18 launcher 双重注册。
  5. 写入后解析 JSON 验证:旧直调
    story_codex_hook.py
    命令数为 0,当前模板 6 个注册各存在且仅存在一次,用户 hook 与未知顶层字段仍在。然后提示用户:项目
    .codex/
    层需要被 Codex trust,非 managed command hooks 还需要在
    /hooks
    中 review/trust 后才会运行;Windows 下走
    commandWindows
    ,launcher 从当前目录向上定位项目
    .codex/hooks/
    ,与 POSIX 路径的嵌套目录行为一致。
Codex project hooks are deployed to
.codex/hooks.json
; run scripts to deploy to
.codex/hooks/story_codex_hook.py
,
run-story-hook.sh
,
run-story-hook.cmd
. JSON is only responsible for locating the project root and passing events, interpreter detection is uniformly handled by the platform launcher.
  1. Locate the current story-setup skill directory, read
    references/codex/hooks/hooks.json
    as the only current template, read the project's
    .codex/hooks.json
    (treat as empty object if it does not exist).
  2. Detect available Python according to existing cross-platform rules:
    for PYBIN in python3 python py; do "$PYBIN" -c "" 2>/dev/null && break; done
    ; stop if no available interpreter, do not manually write or simplify JSON merging.
  3. 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"
    . This helper will identify three types of managed identities: old direct call
    story_codex_hook.py
    , current
    run-story-hook.sh
    and
    run-story-hook.cmd
    , first remove all known managed registrations, then append the current template.
  4. Retain non-story-setup hooks, matcher blocks and unknown top-level fields already present in the user's configuration. Repeated execution must be idempotent;禁止再按原始
    command
    字符串追加去重,否则 v17 直调命令会与 v18 launcher 双重注册。
  5. Parse JSON after writing to verify: The number of old direct call
    story_codex_hook.py
    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
    .codex/
    layer needs to be trusted by Codex, non-managed command hooks also need to be reviewed/trusted in
    /hooks
    before running; on Windows, use
    commandWindows
    , the launcher locates the project's
    .codex/hooks/
    from the current directory upwards, consistent with the nested directory behavior of POSIX paths.

ZCode 部署算法(target_cli 含 zcode 时)

ZCode Deployment Algorithm (when target_cli contains zcode)

ZCode 首版部署 Skills、Commands、AGENTS.md 和支持事件内的 Hooks;不部署
.zcode/agents
.zcode/rules
  1. 复制仓库当前
    skills/
    下 13 个包含
    SKILL.md
    的目录到
    .zcode/skills/{skill-name}/
    ;仅替换这些已知目录,保留用户其他 Skills。
  2. 复制
    references/zcode/commands/*.md
    .zcode/commands/
    ;仅替换 13 个同名命令,保留用户其他 Commands。
  3. 复制
    references/zcode/hooks/story_zcode_hook.js
    references/zcode/hooks/story_hook_core.js
    .zcode/hooks/
  4. 读取
    references/zcode/config.json.patch
    和现有
    .zcode/config.json
    (如只有根
    zcode.json
    ,仍创建
    .zcode/config.json
    承载 oh-story 项目 Hooks,不改写根文件):
    • 保留用户所有未知字段、MCP、plugins、skills/commands disable overrides;
    • hooks 互斥(避免双触发):若本项目经已安装的 oh-story 插件运行(marketplace 安装,仓库根
      .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(仅未装插件时):设置
      hooks.enabled: true
      ;用户已有更大的
      timeoutMs
      时保留,否则取模板值;对
      hooks.events
      的 SessionStart、PreToolUse、PostToolUse 按
      event + matcher + process command + args
      去重追加;不复制 ZCode 不支持的 PreCompact、PostCompact、SessionEnd、SubagentStop、Notification。
  5. references/zcode/AGENTS.md.tmpl
    按「AGENTS.md 合并策略」写入根
    AGENTS.md
  6. .story-deployed
    target_cli
    写入
    zcode
    或多端组合,
    references_dir
    .zcode/skills/story-setup/references/agent-references
  7. 安装报告明确说明:ZCode 3.3.4 的项目/plugin custom agents 不执行,所有专业角色走 solo/direct;系统需要可用的
    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 唯一注册源。
The first version of ZCode deploys Skills, Commands, AGENTS.md and Hooks within supported events; does not deploy
.zcode/agents
or
.zcode/rules
.
  1. Copy the 13 directories containing
    SKILL.md
    under the current repository's
    skills/
    to
    .zcode/skills/{skill-name}/
    ; only replace these known directories, retain other Skills of the user.
  2. Copy
    references/zcode/commands/*.md
    to
    .zcode/commands/
    ; only replace 13 commands with the same name, retain other Commands of the user.
  3. Copy
    references/zcode/hooks/story_zcode_hook.js
    and
    references/zcode/hooks/story_hook_core.js
    to
    .zcode/hooks/
    .
  4. Read
    references/zcode/config.json.patch
    and the existing
    .zcode/config.json
    (if only the root
    zcode.json
    exists, still create
    .zcode/config.json
    to carry oh-story project Hooks, do not modify the root file):
    • 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,
      hooks.json
      in
      .zcode-plugin/plugin.json
      at the repository root has globally registered SessionStart/PreToolUse/PostToolUse), then skip merging the
      hooks
      block of
      config.json.patch
      into
      .zcode/config.json
      below — 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.
    • Merge hooks (only when plugin is not installed): Set
      hooks.enabled: true
      ; retain if the user already has a larger
      timeoutMs
      , otherwise take the template value; deduplicate and append SessionStart, PreToolUse, PostToolUse in
      hooks.events
      by
      event + matcher + process command + args
      ; do not copy PreCompact, PostCompact, SessionEnd, SubagentStop, Notification which are not supported by ZCode.
  5. Write the root
    AGENTS.md
    according to "AGENTS.md Merge Strategy" using
    references/zcode/AGENTS.md.tmpl
    .
  6. Write
    zcode
    or multi-end combination to
    target_cli
    in
    .story-deployed
    , write
    .zcode/skills/story-setup/references/agent-references
    to
    references_dir
    .
  7. 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
    node
    command to run project Hooks.
Plugin installation does not go through this algorithm:
.zcode-plugin/plugin.json
at the repository root directly exposes the same set of Skills/Commands/Hooks. Plugin Skills have lower priority than workspace
.zcode/skills
; if both exist, the project snapshot takes precedence, and upgrading the project snapshot requires re-running
$story-setup
.Only one set of Hooks can be registered: The plugin manifest and workspace
.zcode/config.json
register the same set of events, do not merge the hooks of
config.json.patch
into
.zcode/config.json
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.

OpenClaw skills-only 部署算法(target_cli 含 openclaw 时)

OpenClaw skills-only Deployment Algorithm (when target_cli contains openclaw)

OpenClaw Phase 1 只部署 skills,不部署 OpenClaw agents/hooks/plugin。
  1. 读取仓库当前
    skills/
    下所有包含
    SKILL.md
    的 story skill 目录(13 个:
    browser-cdp
    story*
    )。
  2. 写入目标项目
    skills/{skill-name}/
    ,仅替换这些 story-setup 管理的已知 skill 目录;保留用户在
    skills/
    下的其他目录。
  3. 每个
    SKILL.md
    必须满足 OpenClaw frontmatter 约束:
    name
    /
    description
    是单行键值,
    metadata
    是单行 JSON 对象且含
    metadata.openclaw
  4. 复制
    skills/story-setup/references/openclaw/AGENTS.md.tmpl
    到项目
    AGENTS.md
    ,按「AGENTS.md 合并策略」合并。
  5. .story-deployed
    target_cli
    写入
    openclaw
    或多端组合;
    references_dir
    对 OpenClaw 写
    skills/story-setup/references/agent-references
  6. 安装报告提示项见 Phase 3 第 10 步。
OpenClaw Phase 1 only deploys skills, does not deploy OpenClaw agents/hooks/plugin.
  1. Read all story skill directories containing
    SKILL.md
    under the current repository's
    skills/
    (13:
    browser-cdp
    and
    story*
    ).
  2. Write to the target project's
    skills/{skill-name}/
    , only replace these story-setup managed known skill directories; retain other directories of the user under
    skills/
    .
  3. Each
    SKILL.md
    must meet OpenClaw frontmatter constraints:
    name
    /
    description
    are single-line key-value pairs,
    metadata
    is a single-line JSON object and contains
    metadata.openclaw
    .
  4. Copy
    skills/story-setup/references/openclaw/AGENTS.md.tmpl
    to the project's
    AGENTS.md
    , merge according to "AGENTS.md Merge Strategy".
  5. Write
    openclaw
    or multi-end combination to
    target_cli
    in
    .story-deployed
    ; write
    skills/story-setup/references/agent-references
    to
    references_dir
    for OpenClaw.
  6. 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 与
AGENTS.md
,不部署 Reasonix hooks/custom agents(hook I/O 契约与子代理行为缺少可校验的真实 CLI,留待后续阶段)。
  1. 读取仓库当前
    skills/
    下所有包含
    SKILL.md
    的 story skill 目录(13 个:
    browser-cdp
    story*
    )到目标项目
    skills/{skill-name}/
    ;仅替换这些 story-setup 管理的已知 skill 目录,保留用户其他目录。
  2. 在项目根创建
    .agents/skills → ../skills
    相对 symlink(与 Codex 共用的 skill root),使 Reasonix 原生扫描
    .agents/skills
    时发现这些 skill;若已是指向
    skills/
    的 symlink 则保留,若被占用为普通目录则不覆盖并在安装报告提示。Windows 未启用 symlink 时跳过本步,改走根
    reasonix-plugin.json
    reasonix plugin install
  3. 复制
    skills/story-setup/references/reasonix/AGENTS.md.tmpl
    到项目
    AGENTS.md
    ,按「AGENTS.md 合并策略」合并。
  4. .story-deployed
    target_cli
    写入
    reasonix
    或多端组合;
    references_dir
    对 Reasonix 写
    skills/story-setup/references/agent-references
  5. 安装报告提示项见 Phase 3 第 12 步。
Reasonix (DeepSeek-Reasonix CLI) currently only deploys skills and
AGENTS.md
, 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).
  1. Read all story skill directories containing
    SKILL.md
    under the current repository's
    skills/
    (13:
    browser-cdp
    and
    story*
    ) to the target project's
    skills/{skill-name}/
    ; only replace these story-setup managed known skill directories, retain other directories of the user.
  2. Create a relative symlink
    .agents/skills → ../skills
    in the project root (shared with Codex's skill root), so that Reasonix can discover these skills when natively scanning
    .agents/skills
    ; if it is already a symlink pointing to
    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 root
    reasonix-plugin.json
    for
    reasonix plugin install
    .
  3. Copy
    skills/story-setup/references/reasonix/AGENTS.md.tmpl
    to the project's
    AGENTS.md
    , merge according to "AGENTS.md Merge Strategy".
  4. Write
    reasonix
    or multi-end combination to
    target_cli
    in
    .story-deployed
    ; write
    skills/story-setup/references/agent-references
    to
    references_dir
    for Reasonix.
  5. 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 能力。
  1. 复制仓库当前
    skills/
    下所有包含
    SKILL.md
    的 story skill 目录(13 个:
    browser-cdp
    story*
    )到目标项目
    skills/{skill-name}/
    ;仅替换这些 story-setup 管理的已知 skill 目录,保留用户其他目录。
  2. 复制
    skills/story-setup/references/generic/AGENTS.md.tmpl
    到项目
    AGENTS.md
    ,按「AGENTS.md 合并策略」合并。
  3. .story-deployed
    target_cli
    写入
    generic
    或多端组合;
    references_dir
    对 generic 写
    skills/story-setup/references/agent-references
  4. 安装报告提示项见 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.
  1. Copy all story skill directories containing
    SKILL.md
    under the current repository's
    skills/
    (13:
    browser-cdp
    and
    story*
    ) to the target project's
    skills/{skill-name}/
    ; only replace these story-setup managed known skill directories, retain other directories of the user.
  2. Copy
    skills/story-setup/references/generic/AGENTS.md.tmpl
    to the project's
    AGENTS.md
    , merge according to "AGENTS.md Merge Strategy".
  3. Write
    generic
    or multi-end combination to
    target_cli
    in
    .story-deployed
    ; write
    skills/story-setup/references/agent-references
    to
    references_dir
    for generic.
  4. Prompt items in the installation report are in Step 11 of Phase 3.

Step 7:创建部署标记

Step 7: Create Deployment Marker

  • 创建
    .story-deployed
    文件(sentinel file)
  • 写入以下字段(YAML
    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/...;多端用逗号分隔)
  • 此文件供 session-start.sh 和写作 skill 检测部署状态,避免重复提示
  • target_cli 含 claude-code 时,同时创建一次性标记文件
    .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 停止,不得降级覆盖
  • Create
    .story-deployed
    file (sentinel file)
  • Write the following fields (YAML
    key: value
    format, read by
    references/templates/hooks/lib/sentinel.sh
    in hooks):
    deployed_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
    .claude/.agents-pending-restart
    (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.
  • If
    .story-deployed
    exists but
    agents_version
    is missing, non-integer or less than
    25
    , update hooks/agents/rules/reference bundle according to this process (specific changes see
    UPGRADING.md
    ); if greater than
    25
    , stop in Phase 1 and do not downgrade overwrite

Phase 3:验证安装

Phase 3: Verify Installation

  1. 验证 hooks 注册:
    • 检查
      .claude/settings.local.json
      中的 hooks 字段是否正确
    • 检查
      .claude/hooks/
      下的脚本是否存在且有执行权限
    • 检查
      .claude/hooks/lib/common.sh
      .claude/hooks/lib/sentinel.sh
      是否存在
  2. 验证 rules 路径:
    • 检查
      .claude/rules/
      下的规则文件是否存在且包含
      paths
      frontmatter
  3. 验证 agents:
    • 检查
      .claude/agents/
      下的 7 个 agent 定义文件是否存在
  4. 验证 agent reference bundle:
    • 检查
      .claude/skills/story-setup/references/agent-references/
      下 reference 文件完整
    • 检查所有
      story-setup/references/agent-references/<file>.md
      都能解析到 deployed bundle
  5. 验证部署标记:
    • 检查
      .story-deployed
      是否存在且包含时间戳、
      agents_version: 25
      setup_skill_version: 1.2.7
      target_cli
      resolver_strategy
      references_dir
  6. 输出安装报告:
    • 列出所有已部署的文件
    • 列出需要注意的事项(如已有配置已合并)
    • ⚠️ 重启提示(必须醒目输出):本次部署写入了
      .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-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/。
  7. 验证 opencode 部署(仅当 target_cli 含 opencode 时):
    • 检查
      .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:
      子串
  8. 验证 Codex 部署(仅当 target_cli 含 codex 时):
    • 检查
      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 需要 trust 项目
      .codex/
      配置层,并在
      /hooks
      review/trust 非 managed hooks;部署后新开 Codex 会话让 custom agents 生效;若当前运行时仍返回
      unknown agent_type
      ,按各 skill 的 fallback 规则降级 solo/direct
  9. 验证 ZCode 部署(仅当 target_cli 含 zcode 时):
    • 检查根
      AGENTS.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 路径可解析
    • 用 fixture 调用 SessionStart、PreToolUse deny/allow、PostToolUse,确认无发现时 stdout 为空、有输出时符合 ZCode 严格 JSON
    • 安装报告必须提示:ZCode 3.3.4 不执行项目/plugin custom agents,full/lean 多 Agent 请求会稳定降级 solo/direct;Hook 依赖 PATH 中的
      node
      ;部署后新开 ZCode session 刷新 Skills/Commands/AGENTS.md
  10. 验证 OpenClaw 部署(仅当 target_cli 含 openclaw 时):
    • 检查
      AGENTS.md
      含 OpenClaw story skill routing sections
    • 检查
      skills/
      下 13 个 story skill 目录存在,且每个
      SKILL.md
      包含单行
      name
      、单行
      description
      、单行 JSON
      metadata.openclaw
    • 检查
      skills/story-setup/references/agent-references/
      下 reference 文件完整且数量与源目录一致
    • 安装报告必须提示:OpenClaw Phase 1 是 skills-only;未部署 OpenClaw agents/hooks,运行时硬拦截不可用,写正文前大纲守卫、commit 提醒、session/compact 自动注入只作为 skill 内软约束;OpenClaw 在 session 启动时 snapshot eligible skills,部署后如命令/skills 未出现,需新开 OpenClaw session 或等待 skills watcher 刷新
  11. 验证通用 Web AI / 其他 Agent 部署(仅当 target_cli 含 generic 时):
    • 检查
      AGENTS.md
      含通用 story skill routing sections
    • 检查
      skills/
      下 13 个 story skill 目录存在,且每个
      SKILL.md
      可读
    • 检查
      skills/story-setup/references/agent-references/
      下 reference 文件完整且数量与源目录一致
    • 安装报告必须提示:generic 不部署平台专属 hooks/custom agents;大纲守卫、commit 提醒、session/compact 注入等硬拦截与多 agent 协作都按 skill 内软约束或 solo/direct fallback 执行
  12. 验证 Reasonix 部署(仅当 target_cli 含 reasonix 时):
    • 检查
      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 install
    • 检查
      skills/story-setup/references/agent-references/
      下 reference 文件完整且数量与源目录一致
    • 安装报告必须提示:Reasonix 当前是 skills-only;未部署 Reasonix hooks/custom agents,写正文前大纲守卫、commit 提醒、session/compact 自动注入只作为 skill 内软约束,涉及专业 Agent 的 Skill 走 solo/direct fallback;可用
      reasonix doctor capabilities
      校验 skill 发现,部署后如未显示新 skills,新开 Reasonix session 或走根
      reasonix-plugin.json
      原生 plugin 安装

  1. Verify hook registration:
    • Check if the hooks field in
      .claude/settings.local.json
      is correct
    • Check if the scripts under
      .claude/hooks/
      exist and have execution permissions
    • Check if
      .claude/hooks/lib/common.sh
      and
      .claude/hooks/lib/sentinel.sh
      exist
  2. Verify rules path:
    • Check if the rule files under
      .claude/rules/
      exist and contain
      paths
      frontmatter
  3. Verify agents:
    • Check if the 7 agent definition files under
      .claude/agents/
      exist
  4. Verify agent reference bundle:
    • Check if the reference files under
      .claude/skills/story-setup/references/agent-references/
      are complete
    • Check that all
      story-setup/references/agent-references/<file>.md
      can resolve to the deployed bundle
  5. Verify deployment marker:
    • Check if
      .story-deployed
      exists and contains timestamp,
      agents_version: 25
      ,
      setup_skill_version: 1.2.7
      ,
      target_cli
      ,
      resolver_strategy
      ,
      references_dir
  6. 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
      .claude/agents/
      , but these custom agents are only registered as
      subagent_type
      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 spawn
      story-architect
      ,
      narrative-writer
      etc. 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: Run
      /story-review
      in the new session, if the report header is
      Effective Mode: full/lean
      , registration is successful; if it is
      Fallback: ... -> solo
      , it means you are still in the old session or not registered.
    • You can use
      /story-long-write
      or
      /story-short-write
      after restart
    • 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 (
      opencode models
      is unavailable), output manual configuration guide:
      Unable 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/.
  7. Verify opencode deployment (only when target_cli contains opencode):
    • Check if the 7 agent definition files under
      .opencode/agents/
      exist, and the frontmatter contains
      mode: subagent
      and
      permission
      fields
    • Check if
      .opencode/plugins/story-hooks.ts
      exists
    • Check if
      .opencode/plugins/lib/story_hook_core.js
      exists and passes
      node --check
      (imported by story-hooks.ts, shared prose guard core with identical bytes to
      .zcode
      copy; placed in
      lib/
      subdirectory to avoid OpenCode's automatic discovery of single-layer
      .opencode/plugins/*.js
      plugins)
    • Check if the 13 command files under
      .opencode/commands/
      exist
    • Check if the reference files under
      skills/story-setup/references/agent-references/
      are complete and the quantity is the same as the source directory
    • Check if the
      plugin
      array in
      opencode.json
      contains the story-hooks entry
    • Check if
      .git/hooks/pre-commit
      exists and has execution permissions (skip execution permission check on Windows)
    • Check if the frontmatter of agent files under
      .opencode/agents/
      can be parsed by YAML, and
      model:
      (if configured) is a valid top-level scalar, not just grep for
      model:
      substring
  8. Verify Codex deployment (only when target_cli contains codex):
    • Check if
      AGENTS.md
      contains Codex story skill routing sections
    • Check if 7
      .toml
      agent definition files under
      .codex/agents/
      exist and can be parsed
    • Check if
      .codex/hooks.json
      exists and is JSON valid, Unix
      command
      is only started via
      run-story-hook.sh
      , Windows
      commandWindows
      is only started via
      run-story-hook.cmd
      ; no registration of direct call
      story_codex_hook.py
      exists
    • Check if
      .codex/hooks/story_codex_hook.py
      ,
      run-story-hook.sh
      ,
      run-story-hook.cmd
      exist, Python syntax is valid, POSIX/Windows launcher can locate project root from nested cwd
    • Check if the reference files under
      .codex/skills/story-setup/references/agent-references/
      are complete and the quantity is the same as the source directory
    • The installation report must prompt: Codex needs to trust the project's
      .codex/
      configuration layer, and review/trust non-managed hooks in
      /hooks
      ; start a new Codex session after deployment to make custom agents take effect; if the current runtime still returns
      unknown agent_type
      , downgrade to solo/direct according to the fallback rules of each skill
  9. Verify ZCode deployment (only when target_cli contains zcode):
    • Check if the root
      AGENTS.md
      contains ZCode
      $story-*
      routing, outline guard and solo/direct fallback
    • Check 13 Skills under
      .zcode/skills/
      and 13 Commands under
      .zcode/commands/
      , verify frontmatter and naming
    • Check if
      .zcode/hooks/story_zcode_hook.js
      ,
      .zcode/hooks/story_hook_core.js
      exist and pass
      node --check
    • Check if
      .zcode/config.json
      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,
      hooks.enabled=true
      , only register ZCode supported events, all
      process
      args point to project Hook; when oh-story plugin is installed (
      .zcode-plugin/plugin.json
      has globally registered these hooks), instead verify that
      .zcode/config.json
      does not contain (or has removed) these oh-story hook registrations —do not merge the hooks block of
      config.json.patch
      back to make verification pass, otherwise the same event will be triggered twice
    • Check if
      .zcode/skills/story-setup/references/agent-references/
      is complete and all reference paths can be resolved
    • 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
      node
      in PATH; start a new ZCode session after deployment to refresh Skills/Commands/AGENTS.md
  10. Verify OpenClaw deployment (only when target_cli contains openclaw):
    • Check if
      AGENTS.md
      contains OpenClaw story skill routing sections
    • Check if 13 story skill directories under
      skills/
      exist, and each
      SKILL.md
      contains single-line
      name
      , single-line
      description
      , single-line JSON
      metadata.openclaw
    • Check if the reference files under
      skills/story-setup/references/agent-references/
      are complete and the quantity is the same as the source directory
    • 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
  11. Verify General Web AI / Other Agent deployment (only when target_cli contains generic):
    • Check if
      AGENTS.md
      contains general story skill routing sections
    • Check if 13 story skill directories under
      skills/
      exist, and each
      SKILL.md
      is readable
    • Check if the reference files under
      skills/story-setup/references/agent-references/
      are complete and the quantity is the same as the source directory
    • 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
  12. Verify Reasonix deployment (only when target_cli contains reasonix):
    • Check if
      AGENTS.md
      contains Reasonix story skill routing sections and solo/direct fallback instructions
    • Check if 13 story skill directories under
      skills/
      exist, and each
      SKILL.md
      is readable
    • Check if the project's
      .agents/skills
      is a symlink pointing to
      skills/
      (POSIX; allows Reasonix native scanning to discover skills); when symlink is not created on Windows, instead confirm that the root
      reasonix-plugin.json
      can be used for
      reasonix plugin install
    • Check if the reference files under
      skills/story-setup/references/agent-references/
      are complete and the quantity is the same as the source directory
    • 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
      reasonix doctor capabilities
      to verify skill discovery, if new skills do not appear after deployment, start a new Reasonix session or use root
      reasonix-plugin.json
      for native plugin installation

模板占位符

Template Placeholders

占位符替换规则示例
{项目名}
用户项目名称或目录名《剑来》、《暗卫》
{书名}
书名目录名(与目录一致)
{项目名}
相同,或用户自定义
{目标平台}
目标发布平台起点、番茄、晋江、知乎盐言
{作者名}
用户笔名或昵称未指定时用「作者」
替换时去掉花括号。如果用户未指定项目名,用当前目录名。未指定的占位符保留原样不替换。
PlaceholderReplacement RuleExample
{项目名}
User project name or directory name《Sword Comes》, 《Dark Guard》
{书名}
Book title directory name (consistent with directory)Same as
{项目名}
, or user-defined
{目标平台}
Target publishing platformQidian, Tomato, Jinjiang, Zhihu Yanyan
{作者名}
User pen name or nicknameUse "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 合并:
  1. 优先识别 story-setup 管理块标记(如果旧项目已有标记,只替换标记内内容)
  2. 无标记时,读取用户现有 CLAUDE.md,按
    ##
    标题切分为 section map
  3. 读取模板 CLAUDE.md.tmpl,同样切分
  4. 模板中的标准 section(Skill 路由表、文件结构、协作规则、Compact 后恢复上下文)覆盖用户同名 section
  5. 用户独有的 section(自定义内容)保留不动
  6. 未知冲突用 AskUserQuestion 让用户选择保留哪个版本
When the user already has CLAUDE.md, merge by marker/section:
  1. Prioritize identifying story-setup managed block markers (if the old project already has markers, only replace the content within the markers)
  2. If no markers exist, read the user's existing CLAUDE.md and split into section map by
    ##
    titles
  3. Read the template CLAUDE.md.tmpl and split in the same way
  4. 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
  5. User's unique sections (custom content) retained unchanged
  6. 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 合并:
  1. 优先识别 story-setup 管理块标记(如果旧项目已有标记,只替换标记内内容)
  2. 无标记时,读取用户现有 AGENTS.md,按
    ##
    标题切分为 section map
  3. OpenCode 使用
    skills/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
  4. 模板中的标准 section(Skill 路由表、文件结构、协作规则、Compact 后恢复上下文)覆盖同名 section;用户独有 section 保留
  5. 多端同时部署时,Codex/OpenCode/ZCode/OpenClaw/Reasonix/generic 共同可用的通用段落只保留一份;工具特有说明以小节区分,避免互相覆盖
When the user already has AGENTS.md, merge by marker/section:
  1. Prioritize identifying story-setup managed block markers (if the old project already has markers, only replace the content within the markers)
  2. If no markers exist, read the user's existing AGENTS.md and split into section map by
    ##
    titles
  3. OpenCode uses
    skills/story-setup/references/opencode/AGENTS.md.tmpl
    ; Codex uses
    skills/story-setup/references/codex/AGENTS.md.tmpl
    ; ZCode uses
    skills/story-setup/references/zcode/AGENTS.md.tmpl
    ; OpenClaw uses
    skills/story-setup/references/openclaw/AGENTS.md.tmpl
    ; Reasonix uses
    skills/story-setup/references/reasonix/AGENTS.md.tmpl
    ; General Web AI / Other Agents use
    skills/story-setup/references/generic/AGENTS.md.tmpl
  4. 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
  5. 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

  • .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;不覆盖项目中的更新部署

  • .story-deployed
    does not exist → New installation, execute all of Phase 2
  • .story-deployed
    exists and
    agents_version: 25
    → 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 via
    npx skills add
    or marketplace
  • .story-deployed
    exists but
    agents_version
    is missing, non-integer or less than
    25
    → 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 strategy
  • .story-deployed
    exists and
    agents_version
    is greater than
    25
    → Current skill version is too old, stop and prompt to update oh-story-claudecode first; do not overwrite updated deployment in the project

参考资料

Reference Materials

文件用途
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

FilePurpose
references/templates/hooks/8 hook script templates +
story_hook_core.js
(shared implementation of prose web/word count/outline guard/consistency/commit detection, same copy as OpenCode/ZCode) +
story_hook_cli.js
(node bridge for bash hook calling core) +
lib/common.sh
/
lib/sentinel.sh
(prose fallback
check-prose-after-write.sh
is limited to PostToolUse Write/Edit; Bash writing prose such as
cat>
/
tee
is covered by git scanning at the end of Codex Stop round, Bash of Claude/OpenCode only uses pre-guard)
references/zcode/ZCode AGENTS, 13 Commands, workspace config patch and strict JSON Hook runner

流程衔接

Process Connection

流水线: 部署 位置: 初始化(最前置)
时机跳转到命令
部署完成,开始写作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。
Pipeline: Deployment Position: Initialization (most front-end)
TimingJump toCommand
Deployment completed, start writingstory-long-write / story-short-write
/story-long-write
or
/story-short-write
Import existing novel for disassemblystory-import
/story-import
Need browser login state (rank scanning/extract original text from novel)browser-cdp
/browser-cdp
; generic requires platform to allow local scripts/browser control
Calling syntax for each end: Claude
/name
, Codex/ZCode
$name
, OpenClaw
/skill name
, Reasonix / generic directly name the skill.