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

@ai-rpg-engine/campaign-memory

v2.1.6

Published

Persistent NPC memory, relationship axes, and campaign journal for AI RPG Engine

Readme

@ai-rpg-engine/campaign-memory

npm License: MIT

AI RPG Engine 提供的持久 NPC 记忆、多维度关系和战役日志。

安装

npm install @ai-rpg-engine/campaign-memory

功能

NPC 会记住发生的事情。 不仅仅是“敌对:true”,他们会跟踪信任、恐惧、钦佩和熟悉度,这些指标会随着每次互动而变化。 记忆会随着时间的推移而逐渐淡化:鲜明 → 模糊 → 黯淡 → 被遗忘。 战役日志会记录重要的事件,并在不同的游戏会话中保持一致。

用法

战役日志

import { CampaignJournal } from '@ai-rpg-engine/campaign-memory';

const journal = new CampaignJournal();

// Record a significant event
const record = journal.record({
  tick: 42,
  category: 'kill',
  actorId: 'player',
  targetId: 'merchant_1',
  zoneId: 'market',
  description: 'Player killed the merchant during a robbery',
  significance: 0.9,
  witnesses: ['guard_1', 'bystander_2'],
  data: { weapon: 'dagger' },
});

// Query the journal
const playerActions = journal.query({ actorId: 'player', category: 'kill' });
const merchantHistory = journal.getInvolving('merchant_1');

NPC 记忆库

import { NpcMemoryBank, applyRelationshipEffect } from '@ai-rpg-engine/campaign-memory';

const guardMemory = new NpcMemoryBank('guard_1');

// Guard witnesses the player killing a merchant
guardMemory.remember(record, 0.9, -0.8);      // high salience, very negative
applyRelationshipEffect(guardMemory, record, 'witness');

// Check how the guard feels about the player
const rel = guardMemory.getRelationship('player');
// { trust: -0.15, fear: 0.25, admiration: -0.05, familiarity: 0 }

// Later, memories fade
guardMemory.consolidate(currentTick);
const memories = guardMemory.recall({ aboutEntity: 'player', minSalience: 0.5 });

关系维度

| 维度 | 范围 | 含义 | |------|-------|---------| | 信任 | -1 到 1 | 不信任 → 信任 | | 恐惧 | 0 到 1 | 无惧 → 极度恐惧 | | 钦佩 | -1 到 1 | 鄙视 → 钦佩 | | 熟悉度 | 0 到 1 | 陌生人 → 亲密 |

记录类别

action (行动) · combat (战斗) · kill (杀戮) · betrayal (背叛) · gift (礼物) · theft (盗窃) · debt (债务) · discovery (发现) · alliance (联盟) · insult (侮辱) · rescue (救援) · death (死亡)

每个类别都有默认的关系影响。 救援会增加信任 (+0.4) 和钦佩 (+0.3)。 背叛会破坏信任 (-0.5)。

记忆巩固

记忆会通过三个阶段随着时间而衰减:

  • 鲜明 (vivid) — 显著性高,最近形成的
  • 模糊 (faded) — 显著性低于衰减阈值
  • 黯淡 (dim) — 几乎被遗忘,即将被遗忘

可以为每个 NPC 或全局配置衰减率。

序列化

CampaignJournalNpcMemoryBank 都支持 serialize()deserialize() 方法,以便在不同的游戏会话中保持持久性。

AI RPG Engine 的一部分

此软件包是 AI RPG Engine 单一代码仓库的一部分。 它可以独立使用,也可以与引擎的认知和传闻系统集成。

许可证

MIT