Local MVP for a shared-world, multi-character interrogation sim.
- Install dependencies:
npm install
- Create a local
.env(copy from.env.example) and setOPENAI_API_KEY. - Start the server:
npm run dev
- Open
http://localhost:3000.
- State is stored in-memory per session.
- Character responses use the OpenAI API when
OPENAI_API_KEYis set. - Agent prompt templates live in
agents/. - Language toggle (English/Greek) is available in the UI.
- Model mode toggle (auto/routine/critical) is available in the UI.
- LLM judge endpoint:
POST /api/story-judge- Accepts
novel(orstory_text) plus optionalcast_list,timeline_notes,clue_list,solution_reveal. - Returns structured scores + a full markdown critique report.
- Accepts
- Feedback loop endpoint:
POST /api/story-loop- Runs judge -> pass/fail gate -> minimal patch -> re-judge (up to
max_rounds). - If gate passes, runs constructor next and (by default) writes a backlog entry to
server/story_backlog/. - Returns each round’s judge report, patch summary, final verdict, constructor status, and backlog metadata.
- Runs judge -> pass/fail gate -> minimal patch -> re-judge (up to
- Unified endpoint:
POST /api/storylab- Same inputs as above.
- Set
judge_only: truefor judge-only mode; default runs loop mode. - Use
persist_backlog: falseto skip backlog write.
Quality gate (pass criteria):
- total score >= 80/100
- internal consistency >= 18/25
- means/opportunity/motive integrity >= 14/20
- clue fairness >= 14/20
- critical contradictions <= 0
- major contradictions <= 2
CLI:
- Judge only (text report):
npm run story:judge -- <caseId> --file <story.txt> - Judge only (JSON):
npm run story:judge -- <caseId> --file <story.txt> --json - Feedback loop JSON:
npm run story:loop -- <caseId> --file <story.txt>- Reads from stdin when no
--fileis provided, so copy/paste works directly. - Add
--no-backlogto skip backlog persistence.
- Reads from stdin when no
- Batch judge+fix all library stories:
npm run story:all -- --max-rounds 3 --write-casepacks - Legacy storylab review:
npm run storylab:review -- <caseId> <novel-file-path>
- API routes are in
api/and are compatible with Vercel Serverless Functions. - Deploy the repo and set environment variables in Vercel:
OPENAI_API_KEY- Optional:
OPENAI_MODEL_ROUTINE,OPENAI_MODEL_CRITICAL,OPENAI_MODEL_NARRATOR,OPENAI_MODEL_CHECKER,OPENAI_MODEL_STORY_JUDGE,OPENAI_MODEL_STORY_FIXER,OPENAI_MODEL_STORYLAB,OPENAI_MAX_OUTPUT_TOKENS,OPENAI_TEMPERATURE
- Note: in-memory sessions are ephemeral on serverless; persistence needs a DB/KV for production.