Files
infiplot-web/lib/engine/prompts/segments/writer/cot.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

45 lines
2.3 KiB
TypeScript

import type { PromptSegment } from "../../types";
export const WRITER_COT: PromptSegment = {
id: "writer-cot",
name: "思维链",
type: "cot-instruction",
agent: "writer",
zone: "stable",
order: 105,
enabled: true,
editable: true,
category: "思维链",
content: `═══════════════════════════════════════════════════════════════════
创作前规划(在 <plan> 的 sceneSummary 中体现你的思考结果)
═══════════════════════════════════════════════════════════════════
在输出 <plan> 之前,请在脑中完成以下思考(不需要输出思考过程,直接体现在产出质量中):
**Phase 1: 信息梳理**
- 分析当前情境:时间、地点、氛围、在场角色、关系与张力
- 梳理叙事线索:角色当前目标、隐藏动机、未解决冲突、时间线内关键事件
- 梳理本段所需的故事设定:世界观细节、特殊规则、已埋伏笔、待处理的叙事元素
- 区分知识层级:故事中的公共知识、特定角色掌握的私有知识、不应透露给读者的创作者情报
- **若这是故事开局**(尚无故事档案):先在脑中搭好整部故事的脊梁(主线钩子、题材基调、第二人称主角卡、核心配角),它将写入 <plan> 的 storyBible,为后续每一幕定调
**Phase 2: 前文优化**
- 分析前文是否有情节/文风/角色刻画/段落结构/篇幅的不足
- 本轮创作中有针对性地调整和改善
**Phase 3: 挑战与对策**
- 预判潜在的逻辑不一致、角色连贯性问题、节奏困难
- 为每个挑战准备创作策略
**Phase 4: 定稿方向**
- 基于已有线索构想多个可能的叙事方向(转折 / 高潮 / 悬念 / 日常)
- 选定一条最贴合故事走向和玩家期待的路径
- 确定本段的语言风格、叙事节奏和情绪基调
**Phase 5: 对白打磨**
- 确保对白反映角色性格、背景和当前情绪
- 通过用词和说话习惯突出角色独特魅力
**Phase 6: 构建开场**
- 综合以上阶段,设计一个自然承接上文、引人入胜的开场`,
};