Initial commit: AI-driven visual novel scaffold

- Monorepo (pnpm workspace): apps/web + packages/{types,ai-client,engine}
- Next.js 16 web app with three-stage AI orchestration
- Three independently configurable providers: text LLM, image generator, vision model
- Warm minimalist editorial UI design
- One-click Vercel deploy ready

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-05-09 13:29:58 +08:00
commit cbd95bbea2
45 changed files with 1855 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import { chat } from "@dada/ai-client";
import type { ProviderConfig, Session, StoryFrame, UIElement } from "@dada/types";
import { parseJsonLoose } from "./jsonParser";
import { DIRECTOR_SYSTEM, buildDirectorUserMessage } from "./prompts";
type DirectorOutput = {
narration?: string;
speaker?: string;
line?: string;
scenePrompt: string;
uiElements: UIElement[];
};
export async function direct(
config: ProviderConfig,
session: Session,
): Promise<StoryFrame> {
const raw = await chat(
config,
[
{ role: "system", content: DIRECTOR_SYSTEM },
{ role: "user", content: buildDirectorUserMessage(session) },
],
{ temperature: 0.9, responseFormat: "json_object" },
);
const parsed = parseJsonLoose<DirectorOutput>(raw);
return {
id: `frame_${Date.now()}`,
narration: parsed.narration?.trim() || undefined,
speaker: parsed.speaker?.trim() || undefined,
line: parsed.line?.trim() || undefined,
scenePrompt: parsed.scenePrompt,
uiElements: parsed.uiElements ?? [],
};
}