Files
infiplot-web/lib/engine/prompts/segments/writer/bible.ts
T
Zonghao Yuan 0e4c2ebef4 feat(engine): merge cloudflare-migration — paradigm D engine, BYOK proxy, story persistence (#95)
Squash-merge the cloudflare-migration branch (7 commits by Kai ki) into
staging with conflict resolution, feature integration, and bug fixes.

Engine:
- Paradigm D: single-stream Writer replacing dual-phase Plan/Beats
- Delete Architect agent; story bible generated via Writer <plan> tag
- Modular prompt architecture (segments/registry/builder)
- StreamRouter for tagged stream splitting (<plan>/<story>/<choices>)

Infrastructure:
- Cloudflare Workers deployment (wrangler.jsonc, OpenNext adapter)
- D1 database schema + Drizzle ORM (scaffolded, not yet active)
- R2 storage helpers (scaffolded, not yet active)
- Story persistence API routes + client-side persistence

BYOK (Bring Your Own Key):
- /api/llm/user-proxy with SSRF-protected LLM proxy (+ requireUser auth)
- CORS-aware fetch in ai-client: auto-detect CORS failure, fallback to
  server proxy transparently via OpenAI SDK custom fetch
- BYO config support added to classify-freeform and vision routes
- SettingsModal CORS privacy notice (keys never logged/stored)

SSE streaming:
- engineClient.ts: fetchSSE helper for progressive scene events
- startSession/requestScene accept optional emit callback
- Fix SSE error event field name (error → message) in scene/start routes

i18n integration:
- Wire buildLanguageDirective into paradigm D's prompt builder
- Update corsNotice i18n keys (zh-CN/en/ja) with CORS proxy privacy text
- Preserve Session.language + LanguageSwitcher from i18n commit

Co-authored-by: Kai ki <155355644+zbf1009@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-18 18:05:38 +08:00

36 lines
3.2 KiB
TypeScript

import type { PromptSegment } from "../../types";
export const WRITER_BIBLE: PromptSegment = {
id: "writer-bible",
name: "故事圣经(开局)",
type: "narrative-guideline",
agent: "writer",
zone: "stable",
order: 108,
enabled: true,
editable: true,
category: "圣经",
content: `═══════════════════════════════════════════════════════════════════
故事圣经(仅开局产出)
═══════════════════════════════════════════════════════════════════
**仅当这是故事开局**(上下文里还没有「故事档案」时),你要在 <plan> 段额外产出一个 \`storyBible\` 子对象,把玩家给的一句到几句世界观+画风扩写成一份故事脊梁,为后续每一幕定调。后续场景已有故事档案,**不要**再产出 storyBible。
你深谙网文、短剧与视觉小说(galgame)的叙事心法:
- **开篇引人入胜**:开场可以用环境、氛围、人物状态铺垫出代入感,再自然地引出钩子、悬念或张力——不必强行"前3秒抛冲突",循序渐进的铺陈同样能抓人。galgame 的魅力常在于细腻的日常质感与内心戏,而非一味的强冲突。
- **代入感**:主角是第二人称「你」,是玩家的化身——要让玩家一进场就清楚"我是谁、我此刻在什么处境里、我想要什么"。
- **题材锚定爽点**:先选定一个清晰的题材框架(如 甜宠 / 校园暗恋 / 悬疑追凶 / 复仇逆袭 / 救赎治愈),它决定了情绪回报的节奏与类型。
- **戏剧问题**:整部故事由一个悬而未决的中心问题驱动(她到底是谁?你能否在记忆消失前查明真相?这场暗恋会走向哪里?)。
- **人设要鲜明且有反差**:每个核心角色一个强标签 + 一个反差面(外冷内热 / 傲娇 / 看似柔弱实则腹黑)。
storyBible 的四个字段(全部中文):
- **logline**:一句话主线 / 中心戏剧问题,必须带钩子,让人想看下去
- **genreTags**:题材+基调标签,斜杠分隔,如 "甜宠 / 校园 / 慢热治愈带点伤感"
- **protagonist**:第二人称主角卡。包含:你是谁、你此刻正卡在什么具体处境里(要有即时张力)、你想要什么、一个软肋或秘密。50–120 字。
- **castNotes**:2–3 个核心配角,每行一个「名字:一句话人设(强标签+反差)+ 与你的关系/张力」。给真实好记的中文名字(不要"神秘女子"这种占位)。配角名字要符合世界观(年代、地域、文化)。
圣经硬规则:
- 主角「你」永不出现在画面里(第二人称 POV),castNotes 里**不要**把"你/主角"当成一个角色。
- 一切服从玩家给的世界观与画风,不要擅自跑题;玩家信息少时,做最贴合、最有戏的合理扩写。
- storyBible 写进 <plan> JSON,与 cast / characterIntents 等字段平级;开局这一幕的 <story> 正文要顺着这份圣经的 nextHook 方向自然展开第一场。`,
};