roleplay-memory

Officialneta-search/roleplay-memory
Installation
npx -y @neta-art/neta-search-cli@latest skills add neta-search/roleplay-memory
Summary

Give a roleplay you already play a lasting memory, so a character or a whole story remembers what happened.

  • For a companion chat, the character keeps their own journal and reflections about you, and remembers what you talked about.
  • For a story or adventure, the world keeps a narrator's chronicle and a running record of what has happened, with no character needed.
  • You get two cards on your board: a memory status card and a journal card (a world chronicle card for stories).
  • After each chat the memory updates by itself, and it only starts once you have said yes for that roleplay.
  • If you play as yourself, you can also get a card of your own that keeps what you say about yourself.
SKILL.md
# Roleplay Memory · entry

This skill does one thing: **install long-term memory on a roleplay that already exists, after the user said yes.** It never builds a roleplay.

Memory comes in two kinds, and you pick which by reading the roleplay and its chat yourself — never by asking:

- **Character memory** (companion roleplays): one character's own first-person journal and reflections on themselves and the user.
- **World memory** (story / adventure roleplays): one per world, owned by no character and needing no character card — a narrator's objective chronicle and a story state of what happened.

The flow says how to judge, and when a character the user names needs a card made first.

On top of either kind, when the user plays the roleplay **as themselves** (`optional_characters` holds `null`), the install also gives them a **card of their own** (`--player-profile`; again judged, never asked): one character atom per world, the roleplay's "as yourself" entry pointed at it, the user's own identity linked to it, and its own background lane keeping on it what the player says about themselves.

## What this skill delivers

- Memory installed (for the character, or the world memory), written into the one roleplay they agreed to: the memory directory, the scripts and internal skills in the world, the world-level gate, and the user's yes recorded for that roleplay.
- **Two memory cards published into the current world** — "\<name\> · Memory status" and "\<name\> · Memory journal" (「记忆状态」「记忆观察」 in `zh`; for the world memory "\<world name\> · Memory status" and "\<world name\> · World chronicle", 「记忆状态」「世界编年」) — handed to the user as two interaction-components Work cards (ids from `webworks.cards`). The install is not done until both are published and handed over.
- With `--player-profile`: the player's own card, handed over as a material card after the two memory cards, plus one line telling the user they now enter as that card and what gets kept on it.
- **No yes, no install.** A request like "a character who remembers me" while a roleplay is being built is the reason to *offer* memory, not the yes itself. Until the user agrees in this conversation, do not run `instantiate.mjs`, `install-memory-hook.mjs`, `install-memory-cron.mjs` or `install-memory-webworks.mjs`, and do not edit, re-register or republish memory pages already in the world (`works/webs/memory-*` — older installs may use `works/web/` — and their `meta.json`), even when memory looks half-installed or its cards look stale or missing.

## 1. Pick the language

Use the language you are actually speaking with the user right now, normalized to a code (`zh-CN` → `zh`, `en_US` → `en`). Do not pick from `language` in `world/WORLD.md` — it may lag behind the conversation.

| Case | Flow to read | `--language` |
| --- | --- | --- |
| `flows/<lang>.md` exists in this skill directory (`zh`, `en`) | that one | that code |
| no flow for that language | `flows/en.md` | the user's code |

When you fell back to `en` and the user is not speaking English, read every "in English" there as "in the user's language". The scripts handle languages without a pack; what is missing is only the prompt. The memory cards' titles, UI and covers come in `zh` or `en` only, any other language gets the English ones, so refer to them by the names shown on the board.

Reply to the user in that language for the whole run.

## 2. Read the flow and follow it

```
<this skill dir>/flows/<lang>.md
```

It covers: which roleplay and which kind of memory (read with `node <this skill dir>/inspect-roleplay.mjs`, read-only), the version check, the install order, the checks, what to tell the user, handing over the two cards, and a character with memory appearing in another roleplay. `INSTALL.md` in this directory is the technical manual behind it. Wherever the flow or INSTALL.md says `<this package dir>`, use this skill's directory; scripts that say `scripts/…` run from the world root after the install put them there.

## Check the world's memory version first

Before installing — and whenever the user asks about memory in a world that already has some — run `node <this skill dir>/instantiate.mjs --check-world --target <world root>` (read-only).

- `none` / `v2`: carry on.
- `v1` or `mixed`: this world's memory system is the older version. Do not install, do not copy files, do not run any memory script. Tell the user once, in their language and in world terms: the memory here is the older version; upgrading lets new characters get memory and keeps every memory already written. Ask whether to upgrade, then end the turn. On yes: `node <this skill dir>/instantiate.mjs --upgrade --target <world root>` and relay its result; on no: leave memory as it is — the existing roleplays still work. Do not raise it again in the same conversation.
- `instantiate.mjs` refuses on its own with `needs-upgrade` in a `v1` / `mixed` world; treat that the same way.

If the world already carries the V2 workflow (another character has memory, `scripts/` sits at the world root), those files stay as they are: `instantiate.mjs` only adds what is missing and lists what it left alone under `keptExisting`. Do not copy or edit template files over them by hand. `--upgrade` (V1 → V2; on a V2 world it only refreshes scripts and skills) runs only after the user said yes to upgrading.

Memory in V2 is per character and world-wide: what happens to the character in any roleplay is remembered, but memory is written only into roleplays the user agreed to — the one of this install, plus any they later say yes to.

The world memory follows the same rule: one per world, it reads every roleplay except companion ones, and is written only into the roleplays the user turned it on in.

## Out of scope

- Building or rewriting a roleplay. No roleplay yet → companion-onboarding first.
- Building or rewriting a character — with one exception: the user names a character to remember them and that character has no card. Then make a text card (`neta atom add --no-cover`, only what the story has shown about them), and if that is refused for a missing `visualStyle`, set one that fits the world first. Nothing else.
- Making a player's own card other than through `--player-profile`, or pointing a roleplay's entry at it by hand. `--player-profile` is the one place this skill changes a roleplay itself (only `optional_characters` null → the card, and the card added to `atomIds`; `character_context`, premise and everything else stay).
- Changing world settings: the `world/WORLD.md` frontmatter (visual style, language, cover, anything else), by `neta config set` or by hand — except the `visualStyle` the card above needs.
- Deleting any file that was in the world before this run, or editing files the run did not create — characters' cards, roleplays, other skills, `.neta/` — apart from what `--player-profile` does above (and the profile lane later writing only the marked region of the player's card, which may be the phone's existing "My identity" card).
- Writing memory into a roleplay the user did not agree to (`memory-works.mjs set … --confirmed` only after their explicit yes), installing V2 memory into a V1 / mixed world, or upgrading a world without the user's yes.
- Changing the internal skills installed into the world (`memory-keeper`, `memory-weaver`, `memory-chronicler`, `memory-importer`, `memory-mechanic`, `player-profile-keeper`): they run the memory once it is installed.