@bugchud/core
v0.2.1
Published
Schema-first TypeScript framework for the BUGCHUD! tabletop RPG: foundation types, content definitions, runtime state, simulator contracts, computed views, and the transcribed ruleset data.
Maintainers
Readme
@bugchud/core
@bugchud/core is the shared schema, content catalog, runtime model layer, and validation surface for Bugchud applications.
It gives downstream apps two things at once:
- Plain JSON-friendly schemas for authored rulesets and live runtime state.
- Ergonomic runtime classes for creating, editing, validating, and serializing that state safely.
Live runtime state now includes both aggregate injury tracking and explicit anatomy data, so applications can store wound totals alongside limb-by-limb status such as impaired, lost, prosthetic, or mutation-added body parts.
Install
npm install @bugchud/coreThe package is ESM-only and targets Node 18.17+ plus modern TypeScript/bundler setups.
Quick Example
import { BugchudCore } from "@bugchud/core";
import { importedRuleset } from "@bugchud/core/data";
const core = new BugchudCore({ ruleset: importedRuleset });
const character = core.createCharacter({
name: "Marta Rust",
currentFate: 1,
});
character.addDream(importedRuleset.progression.dreamRefs[0]);
character.setWounds(2);
character.patchBodyPart("leftArm", {
status: "lost",
notes: ["Crushed in a scrap-hauler accident."],
});
const npc = core.createNpc({
name: "Roadfang",
allegiance: "Raiders",
});
const characterIssues = character.getIssues();
const combatDraft = character.getCombatProfileDraft();
const payload = character.toJSON();Package Map
Applications will usually interact with these surfaces:
@bugchud/coreThe app-facing runtime layer:BugchudCore, model classes, wrappers, factories, serialization, and validation exports.@bugchud/core/foundationPrimitive building blocks such as branded ids, typed refs, constants, dice/effect types, and helper builders.@bugchud/core/contentImmutable authored ruleset definitions likeBugchudRuleset,RaceDefinition,WeaponDefinition, andCreatureDefinition.@bugchud/core/statePlain serializable runtime snapshots likeCharacterState,CreatureState,EncounterState, andCampaignState.@bugchud/core/contractsSimulator-facing interfaces for actions, events, and resolution contracts. Important for engine work, but not a finished rules engine by itself.@bugchud/core/viewsComputed projections likeComputedCombatProfileand draft calculators that turn state plus ruleset into UI/combat-facing read models.@bugchud/core/validationStructured validation result types and helpers for rulesets and runtime snapshots.@bugchud/core/characterCharacter-specific initializer and factory surface.@bugchud/core/npcCreature/NPC-specific initializer and factory surface.@bugchud/core/dataThe imported canonical ruleset and transcribed BUGCHUD content. Heavy by design and intended as read-only source data.
Core Idea
The library is intentionally layered:
contentdescribes what may exist in the ruleset.statedescribes what currently exists in a running game or editor.- model classes like
CharacterModelandNpcModelprovide an ergonomic editing API over plain state. viewsderive read models from state plus ruleset.validationand snapshot serialization protect persistence and transport boundaries.
The important design rule is that classes are for application ergonomics, but plain snapshots remain the persistence boundary.
That means explicit body-part changes belong in plain BodyState too, not only in model helpers. If a character loses an arm, gains a prosthetic tail, or carries a long-term torso injury, those facts should survive serialization as regular runtime state.
Documentation
- Documentation Index
- Getting Started
- Using The Library In An Application
- Runtime API Guide
- Character And NPC Workflows
- Imported Data Guide
- Schema Reference Overview
- Generated API Reference
To sync the packaged docs onto a local machine, run:
npx --yes --package @bugchud/core finalchud-docsThat command copies the published docs/ tree into ./finalchud-docs, compares each file with a SHA-256 hash on reruns, and only overwrites files whose contents changed. Pass a custom destination as a positional argument or with --dir.
Development
npm run verify
npm run docs:checkdocs:check regenerates docs/api/, validates internal markdown links, and verifies that key public symbols appear in the generated reference.
Versioning
The package is still pre-1.0. Pin versions precisely if a downstream application needs a stable integration surface.
