Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AIScientists Dev WorldSeed chronicle parser

From Leeroopedia
Knowledge Sources
Domains Frontend, Parsing
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete parser for narrator chapter data from stream records, serving as the single source of truth for ChronicleBar and ChronicleSheet, provided by the WorldSeed frontend.

Description

The chronicle module exports `extractChapters(records)` which scans stream records for narrator highlight actions (`kind: 'action'`, `agent_id: 'narrator'`, `highlight: true`), extracting title, tldr, body paragraphs (split on double-newline), and asides with paired whisper options. `extractLatestChapter(records, maxTick?)` returns the most recent chapter at or before a tick boundary. The `parseAsidesAndWhispers` helper splits aside blocks (filtering arrow-prefixed lines) and pairs them with whisper lines positionally. The module also exports `Whisper`, `Aside`, and `Chapter` interfaces.

Usage

Import this parser from ChronicleBar (for the latest chapter strip) and ChronicleSheet (for the full chapter list) to render narrator-generated chronicle content.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: frontend/src/lib/chronicle.ts

Signature

export interface Chapter {
  num: number; tick: number; title: string; tldr: string;
  paragraphs: string[]; asides: Aside[];
}

export function extractChapters(records: any[]): Chapter[];
export function extractLatestChapter(records: any[], maxTick?: number): Chapter | null;

Import

import { extractChapters, extractLatestChapter, type Chapter } from '@/lib/chronicle';

I/O Contract

Inputs

Name Type Required Description
records any[] Yes │ Stream records array
maxTick number No │ Upper tick bound for latest chapter

Outputs

Name Type Description
extractChapters returns Chapter[] │ All narrator chapters in tick order
extractLatestChapter returns null │ Latest chapter at or before maxTick

Usage Examples

import { extractChapters, extractLatestChapter } from '@/lib/chronicle';

// Get all chapters for the full chronicle sheet
const chapters = extractChapters(streamRecords);
// chapters = [{ num: 1, tick: 5, title: "Arrival", paragraphs: [...], ... }]

// Get the latest chapter for the bar display
const latest = extractLatestChapter(streamRecords, currentTick);

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment