npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

narrarium

v0.1.21

Published

Core schemas, repo scaffolding, search, validation, and export helpers for Narrarium book repositories.

Readme

narrarium

Core Narrarium helpers for local-first book repositories.

Includes

  • repository scaffolding and managed book structure
  • markdown frontmatter schemas and rich canon templates
  • canon search, related-link discovery, and validation
  • draft promotion, plot sync, and resume or evaluation helpers
  • manual story-state sync helpers built from chapter resume deltas
  • doctorBook() checks for broken references, spoiler thresholds, asset metadata, and stale maintenance files
  • EPUB export helpers with opening matter, scene navigation, and optional canon index generation

Install

npm install narrarium

What it does

  • scaffold the canonical book repository structure
  • validate markdown frontmatter and file placement
  • create rich canon files for characters, locations, factions, items, secrets, and timeline events
  • create and update chapters, scenes, chapter drafts, and paragraph drafts
  • answer natural-language canon questions with queryCanon()
  • propose targeted scene revisions with reviseParagraph() without writing files yet
  • propose chapter-level editorial plans with reviseChapter() without mutating files
  • sync plot.md, chapter resumes, and total resume files
  • sync state/current.md, state/status.md, and state/chapters/ from state_changes
  • export the book to EPUB
  • diagnose repository drift with doctorBook()

Quick example

import {
  initializeBookRepo,
  createCharacterProfile,
  createChapter,
  createParagraph,
  doctorBook,
} from "narrarium";

await initializeBookRepo("my-book", {
  title: "My Book",
  author: "Author Name",
  language: "en",
});

await createCharacterProfile("my-book", {
  name: "Lyra Vale",
  roleTier: "main",
  speakingStyle: "Measured and observant.",
  backgroundSummary: "Raised in covert trade circles.",
  functionInBook: "Primary viewpoint anchor.",
});

await createChapter("my-book", {
  number: 1,
  title: "The Arrival",
});

await createParagraph("my-book", {
  chapter: "chapter:001-the-arrival",
  number: 1,
  title: "At The Gate",
});

const report = await doctorBook("my-book");
console.log(report.ok, report.issues);

Hidden canon and assets

  • use known_from and reveal_in to mark when canon is safe for public reader views
  • use secret_refs and private_notes for author-facing hidden canon
  • store asset metadata in markdown beside images and prefer alt_text plus caption so web and EPUB output stay accessible

Remote book manager foundations

narrarium now also exports the first SDK foundations for remote book access:

  • BookManager as the high-level entry point
  • LocalStorageBookProfileStore and InMemoryBookProfileStore for connection profiles
  • NarrariumBookWorkspace for in-memory edits before commit and push
  • NarrariumRemoteProvider so GitHub and Azure DevOps adapters can plug into the same flow
  • GitHubRemoteProvider with real GitHub snapshot loading plus direct commit/push scaffolding
  • AzureDevOpsRemoteProvider with matching Azure DevOps snapshot loading and direct push support
  • high-level workspace helpers like upsertCharacter, updateChapter, and updateParagraph

Quick example:

import {
  AzureDevOpsRemoteProvider,
  BookManager,
  GitHubRemoteProvider,
  LocalStorageBookProfileStore,
} from "narrarium";

const manager = new BookManager({
  profileStore: new LocalStorageBookProfileStore(),
  providers: [new GitHubRemoteProvider()],
});

const profile = await manager.createGitHubProfile({
  name: "Primary Book",
  owner: "your-org",
  repository: "your-book",
  branch: "main",
  token: "github-token",
});

const snapshot = await manager.loadBook(profile);
const workspace = manager.beginWorkspace(snapshot);

workspace.updateChapter("chapter:001-the-arrival", {
  frontmatter: { title: "The Arrival Revised" },
});
workspace.updateParagraph("paragraph:001-the-arrival:001-at-the-gate", {
  body: "# Scene\n\nThe harbor measures every returning face.",
});

GitHubRemoteProvider can now resolve the branch head, read the Narrarium markdown tree, build a typed snapshot, and push workspace changes back with GitHub commits. AzureDevOpsRemoteProvider now supports the same load and direct push flow through the Azure DevOps Git REST API.

For Azure DevOps, register new AzureDevOpsRemoteProvider() and create a profile with organization, project, repository, branch, and PAT token.

Story state and continuity

Narrarium keeps structured continuity separate from the narrative summaries:

  • resumes/chapters/*.md stays readable and can include a state_changes frontmatter block
  • state/current.md stores the latest consolidated continuity snapshot
  • state/chapters/*.md stores the snapshot after each chapter
  • state/status.md tracks whether story state is stale and why

Story mutations mark the state as stale, but they do not auto-sync the snapshots. That is deliberate: you decide when a rewrite is stable enough to refresh continuity state.

Typical flow:

import {
  syncAllResumes,
  syncStoryState,
  updateParagraph,
} from "narrarium";

await updateParagraph("my-book", {
  chapter: "chapter:001-the-arrival",
  paragraph: "001-at-the-gate",
  body: "# Scene\n\nThe harbor watches before it welcomes.",
});

await syncAllResumes("my-book");
await syncStoryState("my-book");

You can also query the repository semantically:

import { queryCanon } from "narrarium";

const result = await queryCanon("my-book", "What does Lyra know after chapter 4?");
console.log(result.answer);
console.log(result.sources);

Typical queryCanon() prompts:

  • Where is Lyra right now?
  • What does Lyra know after chapter 4?
  • What is Lyra's relationship with Taren?
  • What condition is Lyra in?
  • What open loops are still active?
  • How does Lyra's relationship with Taren change between chapter 3 and chapter 8?
  • How does Lyra's condition change between chapter 3 and chapter 8?
  • What open loops change between chapter 3 and chapter 8?
  • Who knows this secret?
  • When does the brass key first appear?

For exact control, queryCanon() also accepts fromChapter, toChapter, and throughChapter options.

See docs/query-canon.md for a fuller guide with use cases, scope rules, output fields, and limitations.

You can also run proposal-only editorial passes on a final paragraph:

import { reviseParagraph } from "narrarium";

const revision = await reviseParagraph("my-book", {
  chapter: "chapter:001-the-arrival",
  paragraph: "001-at-the-gate",
  mode: "tension",
  intensity: "medium",
});

console.log(revision.proposedBody);
console.log(revision.editorialNotes);
console.log(revision.suggestedStateChanges);

See docs/revise-paragraph.md for the modes, continuity behavior, and manual apply workflow.

For broader chapter-level passes:

import { reviseChapter } from "narrarium";

const revision = await reviseChapter("my-book", {
  chapter: "chapter:001-the-arrival",
  mode: "pacing",
  intensity: "medium",
});

console.log(revision.chapterDiagnosis);
console.log(revision.revisionPlan);
console.log(revision.proposedParagraphs);

See docs/revise-chapter.md for the chapter workflow and output model.

Narrarium also supports explicit chapter-level style overrides with a global book fallback. See docs/style-profiles.md.

Recommended state_changes keys inside chapter resumes:

  • locations
  • knowledge_gain and knowledge_loss
  • inventory_add and inventory_remove
  • relationship_updates
  • conditions
  • wounds
  • open_loops_add and open_loops_resolved

See the root README.md and docs/repository-spec.md for the full repo model.