story-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesestory-setup:网文写作工具集基础设施部署
story-setup: Infrastructure Deployment for Online Novel Writing Toolset
你是写作基础设施部署器。将网文写作工具集的全套基础设施(hooks、rules、agents、CLAUDE.md)部署到用户项目目录。
执行铁律:不覆盖用户已有配置,合并而非替换。
You are a writing infrastructure deployer. Deploy the complete infrastructure of the online novel writing toolset (hooks, rules, agents, CLAUDE.md) to the user's project directory.
Iron Rule of Execution: Do not overwrite existing user configurations; merge instead of replace.
Phase 1:检测项目状态
Phase 1: Detect Project Status
- 检查当前目录是否已部署过(存在 )
.story-deployed- 如果已存在 → 使用 AskUserQuestion 确认是否重新部署
- 检查是否有书名目录(包含 子目录的目录,或用户自定义结构)
追踪/- 有 → 识别为长篇项目,显示当前项目信息
- 无 → 识别为新项目或短篇项目
- 检查 是否存在
.claude/settings.local.json- 存在 → 读取现有配置,后续合并
- 不存在 → 后续创建新文件
- 检查 文件是否存在
.active-book- 存在 → 显示当前活跃书目
- 不存在 → 跳过
- Check if the current directory has been deployed (exists)
.story-deployed- If exists → Use AskUserQuestion to confirm whether to redeploy
- Check if there is a book title directory (a directory containing the subdirectory, or a user-defined structure)
追踪/- If exists → Identify as a long-form project and display current project information
- If not exists → Identify as a new project or short-form project
- Check if exists
.claude/settings.local.json- If exists → Read existing configuration for subsequent merging
- If not exists → Create a new file later
- Check if file exists
.active-book- If exists → Display current active book title
- If not exists → Skip
Phase 2:部署基础设施
Phase 2: Deploy Infrastructure
使用 AskUserQuestion 确认部署位置后,依次执行:
After confirming the deployment location via AskUserQuestion, execute the following steps in order:
2.1 部署 CLAUDE.md
2.1 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 the project root directory (if already exists, handle according to "CLAUDE.md Merging Strategy")
CLAUDE.md
2.2 部署 Hooks
2.2 Deploy Hooks
- 读取 下所有
skills/story-setup/references/templates/hooks/文件.sh - 复制到用户项目的 目录
.claude/hooks/ - 确保脚本有执行权限(chmod +x)
- Read all files under
.shskills/story-setup/references/templates/hooks/ - Copy to the user's project directory
.claude/hooks/ - Ensure scripts have execution permissions (chmod +x)
2.3 部署 Rules
2.3 Deploy Rules
- 读取 下所有
skills/story-setup/references/templates/rules/文件.md - 复制到用户项目的 目录
.claude/rules/
- Read all files under
.mdskills/story-setup/references/templates/rules/ - Copy to the user's project directory
.claude/rules/
2.4 部署 Agents
2.4 Deploy Agents
- 读取 下所有
skills/story-setup/references/templates/agents/文件.md - 复制到用户项目的 目录
.claude/agents/
- Read all files under
.mdskills/story-setup/references/templates/agents/ - Copy to the user's project directory
.claude/agents/
2.5 部署 Session State 模板
2.5 Deploy Session State Template
- 读取
skills/story-setup/references/templates/上下文.md.tmpl - 如有书名目录,复制到 下
{书名}/追踪/
- Read
skills/story-setup/references/templates/上下文.md.tmpl - If there is a book title directory, copy it to
{Book Title}/追踪/
2.6 合并 Hooks 注册到 settings.local.json
2.6 Merge Hooks Registration to settings.local.json
- 读取
skills/story-setup/references/templates/settings-hooks.json - 读取用户项目的 (如存在)
.claude/settings.local.json - 合并 hooks 配置(按「settings-hooks.json 合并算法」处理)
- 写入
.claude/settings.local.json
- Read
skills/story-setup/references/templates/settings-hooks.json - Read the user's project (if exists)
.claude/settings.local.json - Merge hooks configuration (handle according to "settings-hooks.json Merging Algorithm")
- Write to
.claude/settings.local.json
2.7 创建部署标记
2.7 Create Deployment Marker
- 创建 文件(sentinel file)
.story-deployed - 写入两行:第一行 ,第二行
deployed_at: <date -u +"%Y-%m-%dT%H:%M:%SZ">agents_version: 2 - 此文件供 session-start.sh 和写作 skill 检测部署状态,避免重复提示
- 如果 已存在但无
.story-deployed或版本为 1,提示用户重新运行 story-setup 以更新 Agentagents_version
- Create file (sentinel file)
.story-deployed - Write two lines: First line , second line
deployed_at: <date -u +"%Y-%m-%dT%H:%M:%SZ">agents_version: 2 - This file is used by session-start.sh and writing skills to detect deployment status and avoid repeated prompts
- If exists but has no
.story-deployedor version is 1, prompt the user to re-run story-setup to update Agentagents_version
Phase 3:验证安装
Phase 3: Verify Installation
- 验证 hooks 注册:
- 检查 中的 hooks 字段是否正确
.claude/settings.local.json - 检查 下的脚本是否存在且有执行权限
.claude/hooks/
- 检查
- 验证 rules 路径:
- 检查 下的规则文件是否存在且包含
.claude/rules/frontmatterpaths
- 检查
- 验证 agents:
- 检查 下的 agent 定义文件是否存在
.claude/agents/
- 检查
- 验证部署标记:
- 检查 是否存在且包含时间戳
.story-deployed
- 检查
- 输出安装报告:
- 列出所有已部署的文件
- 列出需要注意的事项(如已有配置已合并)
- 提示用户可以开始使用 或
/story-long-write/story-short-write
- Verify hooks registration:
- Check if the hooks field in is correct
.claude/settings.local.json - Check if scripts under exist and have execution permissions
.claude/hooks/
- Check if the hooks field in
- Verify rules path:
- Check if rule files under exist and contain
.claude/rules/frontmatterpaths
- Check if rule files under
- Verify agents:
- Check if agent definition files under exist
.claude/agents/
- Check if agent definition files under
- Verify deployment marker:
- Check if exists and contains a timestamp
.story-deployed
- Check if
- Output installation report:
- List all deployed files
- List notes (e.g., existing configurations have been merged)
- Prompt the user to start using or
/story-long-write/story-short-write
模板占位符
Template Placeholders
| 占位符 | 替换规则 | 示例 |
|---|---|---|
| 用户项目名称或目录名 | 《剑来》、《暗卫》 |
| 书名目录名(与目录一致) | 与 |
替换时去掉花括号。如果用户未指定项目名,用当前目录名。
| Placeholder | Replacement Rule | Example |
|---|---|---|
| User's project name or directory name | Sword Comes, Dark Guard |
| Book title directory name (consistent with the directory) | Same as |
Remove curly braces when replacing. If the user does not specify a project name, use the current directory name.
CLAUDE.md 合并策略
CLAUDE.md Merging Strategy
用户已有 CLAUDE.md 时,按 section 合并:
- 读取用户现有 CLAUDE.md,按 标题切分为 section map
## - 读取模板 CLAUDE.md.tmpl,同样切分
- 模板中的标准 section(Skill 路由表、文件结构、协作规则、Context Recovery、语言)覆盖用户同名 section
- 用户独有的 section(自定义内容)保留不动
- 未知冲突用 AskUserQuestion 让用户选择保留哪个版本
When the user already has CLAUDE.md, merge by section:
- Read the user's existing CLAUDE.md and split into a section map by headings
## - Read the template CLAUDE.md.tmpl and split it the same way
- Standard sections in the template (Skill Routing Table, File Structure, Collaboration Rules, Context Recovery, Language) overwrite the user's sections with the same name
- Unique sections of the user (custom content) remain unchanged
- For unknown conflicts, use AskUserQuestion to let the user choose which version to keep
settings-hooks.json 合并算法
settings-hooks.json Merging Algorithm
hooks 注册合并按 command 字段去重:
- 读取用户现有 (如存在),提取 hooks 部分
.claude/settings.local.json - 读取 模板,提取要注册的 hooks
settings-hooks.json - 对每个 hook event(SessionStart、PreToolUse 等):
- 用户已有的 hook command → 保留,不重复添加
- 模板中的新 hook command → append 到对应 event 的 hooks 数组
- 用户独有的其他配置(permissions、env 等)→ 完整保留
- 写入合并后的完整 settings.local.json
Merge hooks registration by deduplicating based on the command field:
- Read the user's existing (if exists) and extract the hooks part
.claude/settings.local.json - Read the template and extract the hooks to be registered
settings-hooks.json - For each hook event (SessionStart, PreToolUse, etc.):
- Existing hook commands from the user → Keep, do not add duplicates
- New hook commands from the template → Append to the hooks array of the corresponding event
- Other unique configurations from the user (permissions, env, etc.) → Fully retain
- Write the merged complete settings.local.json
重新部署
Redeployment
- 不存在 → 全新安装,Phase 2 全部执行
.story-deployed - 存在且
.story-deployed→ 提示已部署,AskUserQuestion 确认是否重新部署agents_version: 2 - 存在但无
.story-deployed或版本 < 2 → 提示需要更新,重新执行 Phase 2 覆盖 agents/hooks/rules,CLAUDE.md 和 settings.local.json 走合并策略agents_version
- does not exist → Fresh installation, execute all steps in Phase 2
.story-deployed - exists and
.story-deployed→ Prompt that deployment is already done, use AskUserQuestion to confirm whether to redeployagents_version: 2 - exists but has no
.story-deployedor version < 2 → Prompt that an update is needed, re-execute Phase 2 to overwrite agents/hooks/rules, and use merging strategy for CLAUDE.md and settings.local.jsonagents_version
参考资料
Reference Materials
| 文件 | 用途 |
|---|---|
| references/templates/CLAUDE.md.tmpl | 项目根 CLAUDE.md 模板 |
| references/templates/hooks/ | 5 个 hook 脚本模板 |
| references/templates/rules/ | 4 条 path-scoped 规则模板 |
| references/templates/agents/ | 4 个 agent 定义模板 |
| references/templates/settings-hooks.json | hooks 注册 JSON 片段 |
| references/templates/上下文.md.tmpl | 写作上下文模板 |
| File | Purpose |
|---|---|
| references/templates/CLAUDE.md.tmpl | Template for project root CLAUDE.md |
| references/templates/hooks/ | 5 hook script templates |
| references/templates/rules/ | 4 path-scoped rule templates |
| references/templates/agents/ | 4 agent definition templates |
| references/templates/settings-hooks.json | Hooks registration JSON snippet |
| references/templates/上下文.md.tmpl | Writing context template |