@tellandshow/profile-core
v0.0.2
Published
Per-kid profile state — XP ledger + levels + feature unlocks. Pure data, append-only event log, storage-agnostic. Consumed by the Discovery engine to gate progressive uncovering of features (style cycler, side quests, AI personality swaps, etc) until they
Downloads
342
Maintainers
Readme
@tellandshow/profile-core
Per-kid profile state — XP ledger + levels + feature unlocks. Pure data; no React, no I/O beyond a swappable StorageAdapter.
What's here
ProfileCore— append-only event log; emits aProfileSnapshotafter each change.- Levels — triangular curve, Level N reached at
25 * N * (N - 1)XP. - Unlocks — feature-id → conditions;
isUnlocked('side-quests-panel')returns true once conditions are met. XP_AMOUNTS— central tuning table for how much XP each event gives.
Why
The Discovery engine (M4.20) needs to ask "is this feature unlocked yet?" before showing it. Profile-core is the source of truth for that answer.
Usage
import { ProfileCore, XP_AMOUNTS } from '@tellandshow/profile-core';
const profile = new ProfileCore({ storage: localStorage });
profile.addEvent({ type: 'wizard-complete', xp: XP_AMOUNTS['wizard-complete'] });
profile.addEvent({ type: 'project-shipped', xp: XP_AMOUNTS['project-shipped'] });
profile.getLevel(); // → 2
profile.isUnlocked('side-quests-panel'); // → true
profile.snapshot(); // → { xp, level, progress, unlocked, … }Testing
Pass the createMemoryStorage() adapter:
import { ProfileCore, createMemoryStorage } from '@tellandshow/profile-core';
const profile = new ProfileCore({ storage: createMemoryStorage() });License
MIT.
