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

@kar-mi/spirit-vale-tools-sqlite

v0.2.3

Published

Disposable SQLite read-model infrastructure for Spirit Vale session logs.

Readme

@kar-mi/spirit-vale-tools-sqlite

Disposable SQLite read-model infrastructure for Spirit Vale session logs.

Internal package. This package is published only because the domain packages depend on it at runtime; it is installed automatically alongside them and is not a supported public API.

Install

bun add @kar-mi/spirit-vale-tools-sqlite

What it is

JSON Lines session logs stay the canonical record. This package maintains a cache derived from them, by default at <logDirectory>/cache/read-model.sqlite. The cache is never migrated: anything unusable is deleted and rebuilt from the logs. Nothing here writes to, renames, or deletes a log file.

Usage

A domain package owns its own tables and importer; this package owns the database, its metadata, and how far each log has been indexed.

import { openReadModel } from "@kar-mi/spirit-vale-tools-sqlite";

const model = await openReadModel({
  logDirectory,
  domains: [{
    name: "example",
    version: 1,
    createSchema: (db) => db.exec("create table if not exists example_rows (sequence integer primary key)"),
    dropSchema: (db) => db.exec("drop table if exists example_rows"),
  }],
  onRebuild: (event) => console.error(`read model rebuilt: ${event.reason}`),
});

await model.indexStream({
  sessionId,
  stream: "combat",
  domain: "example",
  sourcePath,
  apply(records, db) {
    for (const record of records) {
      db.query("insert or replace into example_rows (sequence) values ($sequence)").run({ sequence: record.sequence });
    }
  },
  clear(scope, db) {
    db.query("delete from example_rows").run();
  },
});

model.close();

indexStream reads only what the log has gained since the recorded byte offset, so it is cheap to call repeatedly and resumes across process restarts.

Guarantees

  • Rows and indexing progress commit in the same transaction, so an interrupted pass resumes exactly rather than double-counting.
  • Each transaction covers at most batchBytes of source (1 MiB by default) and always ends on a record boundary.
  • A truncated, replaced, or rewound log rebuilds that stream; a corrupt database or a changed infrastructure schema rebuilds the whole file; a changed domain version rebuilds only that domain.
  • Use model.bigintStatement(...) for 64-bit values such as reward coins. A plain read rounds anything past Number.MAX_SAFE_INTEGER.
  • Prefer model.statement(...) / model.bigintStatement(...) for your own reads. They reuse one prepared statement for the model's lifetime and provide the per-statement bigint mode. Direct database.query() / database.prepare() access remains available for advanced cases; model.close() force-finalizes every outstanding statement.

See the package guide for registry setup and usage.