被多个 Skill 或看板消费的连接、模型、嵌入、Claude 运行时与声音账入口 各只保留一份实现;Skill 只留 CLI/落库,看板只读 muse-db,门禁锁死跨域注入。 Co-authored-by: Cursor <cursoragent@cursor.com>
114 lines
5.9 KiB
Python
114 lines
5.9 KiB
Python
#!/usr/bin/env python3
|
||
"""真写一章 · 阶段一:建立作品 + 第 1 章 + 设定/大纲/细纲(规划落库)。
|
||
|
||
新建一部科幻机甲小说《深渊机神》(宇宙/星空/机甲/人类/异族/战斗/舰队/巨舰/天才/
|
||
生物机甲/微恐/克苏鲁/黑暗/养成/收集/生存/升级/机战),创建第 1 章,
|
||
并把设定包/大纲/章级细纲经 persist_planning 落库(shadow→confirmed)。
|
||
"""
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||
PLANNING_SCRIPTS = SCRIPT_DIR.parents[1] / ".claude" / "skills" / "plan-story" / "scripts"
|
||
if str(PLANNING_SCRIPTS) not in sys.path:
|
||
sys.path.insert(0, str(PLANNING_SCRIPTS))
|
||
|
||
from muse_db import connect # noqa: E402
|
||
from persist_planning import write_section, confirm_section # noqa: E402
|
||
|
||
WORK_TITLE = "深渊机神"
|
||
GENRE = "科幻·机甲·克苏鲁"
|
||
CHAPTER1_TITLE = "渊临"
|
||
|
||
# 设定包(作品核心)
|
||
SETTING_PAYLOAD = {
|
||
"title": WORK_TITLE,
|
||
"genre": GENRE,
|
||
"logline": "人类舰队深入深渊星域,天才机师驾驶生物机甲对抗克苏鲁式异族,在黑暗宇宙中生存、收集、升级。",
|
||
"core_premise": "深渊星域浮现克苏鲁式异族,人类以生物机甲对抗。主角是天才机师,从底层养成机甲、收集异种核心、在黑暗森林般的星域生存升级。",
|
||
"world": "人类文明扩张至深渊星域,遭遇沉睡的克苏鲁式异族。生物机甲以异种核心为源,机师与机甲精神链接。宇宙是黑暗森林,舰队巨舰是人类的移动堡垒。",
|
||
"power_system": "生物机甲以异种核心驱动,机师精神链接深度决定机甲出力。代价:链接过深会被异族精神污染(微恐/克苏鲁)。升级=融合更强异种核心。",
|
||
"style": "冷峻、克制、微恐。战斗场面宏大(舰队/巨舰/机甲),心理描写细腻(克苏鲁式精神压迫)。句式偏短,节奏紧。",
|
||
"themes": ["生存", "升级", "收集", "养成", "黑暗森林", "克苏鲁", "机甲", "舰队"],
|
||
}
|
||
|
||
# 大纲(总纲)
|
||
OUTLINE_PAYLOAD = {
|
||
"title": WORK_TITLE,
|
||
"overall_arc": "主角从底层机师成长为驾驶神级生物机甲的存在,对抗深渊克苏鲁异族,揭开宇宙黑暗森林的真相。",
|
||
"volume_1": "第一卷·渊临:主角初遇深渊异族,觉醒生物机甲,在舰队中生存立足。",
|
||
"volume_1_chapters": "第1章 渊临(开篇:深渊异族初现,主角觉醒)→ 后续章节展开舰队生存与机甲养成。",
|
||
}
|
||
|
||
# 第 1 章细纲
|
||
FINE_OUTLINE_PAYLOAD = {
|
||
"targetChapter": 1,
|
||
"targetChars": 4000,
|
||
"chapterGoal": "开篇:深渊星域异族初现,主角(天才机师)在危机中觉醒生物机甲,建立微恐/克苏鲁基调与生存压力。",
|
||
"hardConstraints": [
|
||
"主角是天才机师,初次驾驶生物机甲。",
|
||
"深渊异族(克苏鲁式)首次出现,营造微恐/精神压迫。",
|
||
"建立黑暗森林/舰队/巨舰的世界观基调。",
|
||
"章末钩子:主角觉醒生物机甲的代价(精神污染的预兆)。",
|
||
],
|
||
"keyEvents": [
|
||
"主角所在的舰队侦察船在深渊星域遭遇异常信号。",
|
||
"克苏鲁式异族生物现身,舰队遭受精神压迫(微恐)。",
|
||
"主角在危机中被迫启动未完成的生物机甲。",
|
||
"主角与生物机甲精神链接,击退异族,但出现精神污染预兆。",
|
||
],
|
||
"adjustableBeats": [
|
||
"开场节奏(侦察船日常 → 异常信号 → 异族现身)可调整。",
|
||
"精神压迫的描写强度可调整(微恐基调)。",
|
||
],
|
||
"declaredNewFacts": [
|
||
"主角:天才机师,名字待定(建议:林深)。",
|
||
"生物机甲:以异种核心驱动,精神链接。",
|
||
"深渊异族:克苏鲁式,精神污染。",
|
||
],
|
||
"mustAppearEntities": ["主角(林深)", "生物机甲", "深渊异族", "侦察船"],
|
||
"chapterEndHook": "主角击退异族后,发现精神链接留下污染预兆——机甲的核心在低语。",
|
||
"sourceRef": {"sourceId": "outline:volume_1", "sourceVersion": "v1"},
|
||
}
|
||
|
||
|
||
def main():
|
||
with connect() as conn:
|
||
# 1) 建作品
|
||
work_id = conn.execute(
|
||
"INSERT INTO muse_content_work(owner_user_id, title, description, genre, status, "
|
||
"summary, word_count, chapter_count, revision, creator, updater) "
|
||
"VALUES (1,%s,%s,%s,'writing',%s,0,0,1,'setup','setup') RETURNING id",
|
||
(WORK_TITLE, SETTING_PAYLOAD["logline"], GENRE, SETTING_PAYLOAD["core_premise"])).fetchone()[0]
|
||
print(f"建作品: id={work_id} 《{WORK_TITLE}》")
|
||
|
||
# 2) 建第 1 章
|
||
chapter_id = conn.execute(
|
||
"INSERT INTO muse_content_chapter(work_id, title, order_no, status, revision, creator, updater) "
|
||
"VALUES (%s,%s,1,'draft',1,'setup','setup') RETURNING id",
|
||
(work_id, CHAPTER1_TITLE)).fetchone()[0]
|
||
print(f"建第 1 章: id={chapter_id} 《{CHAPTER1_TITLE}》")
|
||
conn.commit()
|
||
|
||
# 3) 设定/大纲(书级,shadow→confirmed)
|
||
setting = write_section(work_id, section_type="setting", schema_type="novel_work", payload=SETTING_PAYLOAD)
|
||
confirm_section(setting["id"])
|
||
print(f"设定包: section id={setting['id']} → confirmed")
|
||
outline = write_section(work_id, section_type="outline", schema_type="outline", payload=OUTLINE_PAYLOAD)
|
||
confirm_section(outline["id"])
|
||
print(f"大纲: section id={outline['id']} → confirmed")
|
||
|
||
# 4) 章级细纲(章级,shadow→confirmed)
|
||
fine = write_section(work_id, section_type="fine_outline", schema_type="outline",
|
||
target_chapter=1, payload=FINE_OUTLINE_PAYLOAD)
|
||
confirm_section(fine["id"])
|
||
print(f"第1章细纲: section id={fine['id']} → confirmed")
|
||
|
||
print(f"\n阶段一完成: work_id={work_id}, chapter_id={chapter_id}")
|
||
print(f"WORK_ID={work_id}")
|
||
print(f"CHAPTER_ID={chapter_id}")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|