agentsclimarketplace

Story setup

Skill wyouwd1/oh-story-opencode/skills/story-setup

网文写作工具集基础设施部署。将 hooks/rules/agents/CLAUDE.md 等基础设施部署到用户项目目录。 触发方式:/story-setup、「准备写书」「帮我搭一下环境」「配置写作项目」From its SKILL.md

Install
npx -y skills add wyouwd1/oh-story-opencode --skill story-setup

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 8 stars8 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

13.4 KB, as published. Nobody here has run it

story-setup:网文写作工具集基础设施部署

你是写作基础设施部署器。将网文写作工具集的全套基础设施(hooks、rules、agents、CLAUDE.md)部署到用户项目目录。

执行铁律:不覆盖用户已有配置,合并而非替换。


Phase 1:检测项目状态

  1. 检查当前目录是否已部署过(存在 .story-deployed)
    • 如果已存在 → 使用 AskUserQuestion 确认是否重新部署
  2. 检测运行环境:检查 opencode.json 是否存在 → OpenCode 环境;检查 .claude/settings.local.json 是否存在 → Claude Code 环境。两者可共存。
  3. 检查是否有书名目录(包含 追踪/ 子目录的目录,或用户自定义结构)
    • 有 → 识别为长篇项目,显示当前项目信息
    • 无 → 识别为新项目或短篇项目
  4. 检查 .active-book 文件是否存在
    • 存在 → 显示当前活跃书目
    • 不存在 → 跳过

Phase 2:部署基础设施

使用 AskUserQuestion 确认部署位置后,依次执行。

2.0 部署清单(机械可检查)

Source pathTarget pathOwner classMerge modeValidation check
skills/story-setup/references/templates/CLAUDE.md.tmplCLAUDE.mduser+managedmarker/section mergecontains story skill routing sections
skills/story-setup/references/templates/hooks/.claude/hooks/story-setup managedrecursive replacesession-*.sh, detect-story-gaps.sh, validate-story-commit.sh, lib/common.sh, lib/sentinel.sh exist
skills/story-setup/references/templates/rules/*.md.claude/rules/*.mdstory-setup managedreplaceevery rule contains paths frontmatter
skills/story-setup/references/templates/agents/*.md.claude/agents/*.mdstory-setup managedreplace7 agent files exist
skills/story-setup/references/agent-references/*.md.claude/skills/story-setup/references/agent-references/*.mdstory-setup managedreplaceevery story-setup/references/agent-references/*.md reference resolves
skills/story-setup/references/templates/settings-hooks.json.claude/settings.local.jsonuser+managedmerge by hook commandhook JSON valid and registered commands deduped
skills/story-setup/references/templates/上下文.md.tmpl{书名}/追踪/上下文.mduser statecreate only if absentnever overwrite existing writing context
generated sentinel.story-deployedstory-setup managedreplacecontains agents_version, setup_skill_version, target_cli, resolver_strategy, references_dir

2.1 部署 CLAUDE.md

  • 读取 skills/story-setup/references/templates/CLAUDE.md.tmpl
  • 替换占位符(见下方「模板占位符」段)
  • 写入项目根目录 CLAUDE.md(如已存在,按「CLAUDE.md 合并策略」处理)

2.2 部署 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,不要求可执行位

2.3 部署 Rules

  • 读取 skills/story-setup/references/templates/rules/ 下所有 .md 文件
  • 复制到用户项目的 .claude/rules/ 目录

2.4 部署 Agents

  • 读取 skills/story-setup/references/templates/agents/ 下所有 .md 文件
  • 复制到用户项目的 .claude/agents/ 目录
  • Agent 文件属于 story-setup 管理文件,可安全覆盖;版本升级时按 UPGRADING.md 的版本检测结果重新部署

2.4.1 Agent 兼容性处理

  • Agent frontmatter 以 Claude Code 为主;OpenClaw/qclaw 等只要支持 AgentSkills,未知字段(如 memory、skills、disallowedTools)应被忽略。若目标工具报 frontmatter 错误,保留 name、description、tools 三项,删除不支持字段后再部署。
  • 部署到项目后,agent 内引用的参考资料必须走 story-setup/references/agent-references/*.md 这一本 skill 内复制路径;不要跨 skill 引用其他 skill 的 references。若全局安装路径不同,优先用项目内 .claude/skills/ 或 skills/ 作为规范路径前缀,其次用工具的 skill 搜索能力,不要假定固定绝对路径。

2.4.2 部署 Agent References

  • 将 skills/story-setup/references/agent-references/ 下所有 .md 复制到项目内 .claude/skills/story-setup/references/agent-references/
  • 如目标项目已经使用项目本地 skills/ 目录,也可以同步复制到 skills/story-setup/references/agent-references/ 作为 fallback,但不得只复制 fallback 而遗漏 .claude/skills/ 主路径
  • 校验:凡 agent 或 reference 中出现 story-setup/references/agent-references/<file>.md,源包与目标包都必须存在 <file>.md

2.5 部署 Session State 模板

  • 读取 skills/story-setup/references/templates/上下文.md.tmpl
  • 仅当已识别为长篇书目且 {书名}/追踪/ 已存在时,创建缺失的 {书名}/追踪/上下文.md
  • 如果目标文件已存在,不覆盖;短篇项目不得因此创建 追踪/ 目录

2.6 合并 Hooks 注册到 settings.local.json

兼容性说明:settings-hooks.json 中 PreToolUse 的 if 字段使用 Claude Code hook 条件语法,需要运行环境支持 hook-level if。若目标工具不支持该字段,hook 脚本本身仍会自检并 advisory-only 退出;部署时可删除该 if 字段并保留 matcher + command。

  • 读取 skills/story-setup/references/templates/settings-hooks.json
  • 读取用户项目的 .claude/settings.local.json(如存在)
  • 合并 hooks 配置(按「settings-hooks.json 合并算法」处理)
  • 写入 .claude/settings.local.json

2.7 创建部署标记

  • 创建 .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: 10
    setup_skill_version: 1.1.1
    target_cli: claude-code+opencode
    resolver_strategy: project-local-skill-reference
    references_dir: skills/story-setup/references/agent-references
    
  • 此文件供 session-start.sh 和写作 skill 检测部署状态,避免重复提示
  • 如果 .story-deployed 已存在但无 agents_version 或版本 < 10,提示用户重新运行 story-setup 以更新 hooks/agents/rules/reference bundle(具体变更见 UPGRADING.md)

Phase 2A:OpenCode 适配部署

当检测到 opencode.json 存在时,额外执行以下部署步骤。

2A.0 OpenCode 部署清单

Source pathTarget pathMerge mode
skills/story-setup/references/templates/agents/*.md.opencode/agents/*.mdreplace
skills/story-setup/references/agent-references/*.mdskills/story-setup/references/agent-references/*.mdreplace
(内联)opencode.jsonmerge (add skills.paths, plugin entry)
(内联)AGENTS.md (if absent)create from template

2A.1 部署 Agent 到 .opencode/agents/

  • 将 agent 模板复制到 .opencode/agents/(与 .claude/agents/ 并行部署)
  • OpenCode agent frontmatter 转换:
    • 保留字段:name(必须),description,model
    • 添加字段:mode: subagent, permission(按 tools 映射)
    • 去掉不兼容字段:tools, memory, skills, disallowedTools, maxTurns
    • model 转换:opus→anthropic/claude-opus-4-5, sonnet→anthropic/claude-sonnet-4-6, haiku→anthropic/claude-haiku-4-5(注意:此映射需随 Anthropic 模型版本更新而维护)
    • tools 映射为 permission(Read→read: allow, Write→write: allow, disallowedTools→deny)
  • 如 .opencode/agents/ 已存在 agent 文件,按 .story-deployed 的 agents_version 决定是否覆盖

2A.2 部署/合并 opencode.json

  • 读取现有 opencode.json(如存在),保留用户自定义字段
  • 确保包含:"$schema": "https://opencode.ai/config.json"
  • 合并 skills.paths(确保包含 "skills")
  • 合并 instructions(确保包含 "AGENTS.md")
  • 如果 .opencode/plugin/story-hooks.ts 存在,添加到 plugin 数组

2A.3 部署 AGENTS.md

  • 仅当项目无 AGENTS.md 时创建,包含 Skill 路由表、文件结构、协作规则
  • 如已有 CLAUDE.md 且无 AGENTS.md,从 CLAUDE.md 模板生成 OpenCode 兼容版

2A.4 创建 .story-deployed

  • target_cli 字段更新为 "opencode" 或 "claude-code+opencode"(根据检测结果)
  • 其他字段不变

Phase 3:验证安装

  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: 10、setup_skill_version: 1.1.1、target_cli、resolver_strategy、references_dir
  6. 输出安装报告:
    • 列出所有已部署的文件
    • 列出需要注意的事项(如已有配置已合并)
    • 提示用户可以开始使用 /story-long-write 或 /story-short-write

模板占位符

占位符替换规则示例
{项目名}用户项目名称或目录名《剑来》、《暗卫》
{书名}书名目录名(与目录一致)与 {项目名} 相同,或用户自定义
{目标平台}目标发布平台起点、番茄、晋江、知乎盐言
{作者名}用户笔名或昵称未指定时用「作者」

替换时去掉花括号。如果用户未指定项目名,用当前目录名。未指定的占位符保留原样不替换。

CLAUDE.md 合并策略

用户已有 CLAUDE.md 时,按 marker/section 合并:

  1. 优先识别 story-setup 管理块标记(如果旧项目已有标记,只替换标记内内容)
  2. 无标记时,读取用户现有 CLAUDE.md,按 ## 标题切分为 section map
  3. 读取模板 CLAUDE.md.tmpl,同样切分
  4. 模板中的标准 section(Skill 路由表、文件结构、协作规则、Context Recovery、语言)覆盖用户同名 section
  5. 用户独有的 section(自定义内容)保留不动
  6. 未知冲突用 AskUserQuestion 让用户选择保留哪个版本

settings-hooks.json 合并算法

hooks 注册合并按 command 字段去重:

  1. 读取用户现有 .claude/settings.local.json(如存在),提取 hooks 部分
  2. 读取 settings-hooks.json 模板,提取要注册的 hooks
  3. 对每个 hook event(SessionStart、PreToolUse 等):
    • 用户已有的 hook command → 保留,不重复添加
    • 模板中的新 hook command → append 到对应 event 的 hooks 数组
    • 用户独有的其他配置(permissions、env 等)→ 完整保留
  4. 写入合并后的完整 settings.local.json

重新部署

  • .story-deployed 不存在 → 全新安装,Phase 2 全部执行
  • .story-deployed 存在且 agents_version: 10 → 提示已部署,AskUserQuestion 确认是否重新部署
  • .story-deployed 存在但 agents_version < 10 → 提示需要更新,重新执行 Phase 2 覆盖 agents/hooks/rules/reference bundle,CLAUDE.md 和 settings.local.json 走合并策略

参考资料

文件用途
references/templates/CLAUDE.md.tmpl项目根 CLAUDE.md 模板
references/templates/hooks/6 个 hook 脚本模板 + lib/common.sh/lib/sentinel.sh
references/templates/rules/4 条 path-scoped 规则模板
references/templates/agents/7 个 agent 定义模板(story-architect, character-designer, narrative-writer, consistency-checker, story-researcher, story-explorer, chapter-extractor)
references/agent-references/Agent 模板自带的参考资料副本;部署到 skills/story-setup/references/agent-references/,避免跨 skill references
references/templates/settings-hooks.jsonhooks 注册 JSON 片段(Claude Code 专用)
references/templates/上下文.md.tmpl写作上下文模板

流程衔接

流水线: 部署 位置: 初始化(最前置)

时机跳转到命令
部署完成,开始写作story-long-write / story-short-write/story-long-write 或 /story-short-write
导入已有小说做拆解story-import/story-import
需要浏览器登录态(扫榜/拆文取原文)browser-cdp/browser-cdp

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.