[GH-ISSUE #6328] [Feature]: Make name aliases readable wherever character names are resolved #3532

Closed
opened 2026-10-21 06:04:01 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @ylli-selmani on GitHub (Sep 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6328

Originally assigned to: @SpicyMarinara on GitHub.

Disclaimer: I had Mari write this up, but the idea is simply to read character cards' extension.NameAliases, which are already exported, just not... read on the server side.

What problem does this solve?

Ever since a previous PR of mine (which i like a lot. colored named are awesome), characters can have name aliases (extensions.nameAliases, editable in the appearance/colors tab). They already travel with the card on export and import, and on the client they already have one consumer: inline name coloring.

Nothing else can see them. Anything that needs to take a loose name string and work out which character card it refers to can only match the card's exact name. In practice, models and users write nicknames, shorthand, or a different spelling ("Logan" for "Wolverine"), that match fails, and the consumer falls back to a bare, unreliable string. Aliases are exactly the human-maintained vocabulary that would fix this, and they are already sitting in the card, unread.

Proposed solution

Make aliases available wherever character names are already resolved on the server side, so a consumer can match an incoming name string against a card's name and its aliases and get back a stable character id.

Today the existing id to name resolver (resolveCharacterNameMap) reads a card's name and nothing else. Rather than change its return shape (other callers want a plain name), add a sibling resolver beside it that returns the card's name together with its nameAliases, keyed by the same character id, and let the existing function become a thin projection of it. One card parser, no second source of truth, and every existing call site keeps working byte for byte.

Rules that should match the existing name behavior:

  • Only cards added to the chat are eligible (present in the chat's character list, whether enabled or disabled).
  • The link between a card, its name, and its aliases is the map key: all three come off the same getCharacterById(id) row, so an alias cannot drift to a different id and there is no separate alias table to keep in sync.
  • Alias matching is a fallback tier, tried after the exact name has been tried. Not a replacement, and not a reordering.
  • Blank or non-string alias entries are ignored rather than stored.
  • If two cards share an alias, first match wins is acceptable.

Alternatives considered

  • Keep aliases client-only: leaves any server-side or agent-side consumer unable to resolve nicknames, and duplicates matching logic per consumer.
  • Ask models to spell names exactly: the misspelling is the failure mode, so this does not fix it. Users maintain aliases precisely because the spelling varies.

Additional context

  • Purely additive: no new storage, no new card field, no UI change. Aliases are already authored, already persisted, and already imported/exported with the card. This is only about giving them a read path outside the client.

  • Other possible uses beyond mine: scanning recent messages for names or nicknames and resolving them to character ids (for trackers, presence detection, or speaker attribution), and generally letting any feature key off "who is this text about" without hard-coding spellings.

    • On the top of my head: The Character Tracker Agent currently copies character id's from < characters > and then uses them in their output for presentCharacters. But if someone's card is currently not active, but in the chat and in the STORY, the agent doesn't have an ID to copy, and maybe they don't even use their actual Card Name, but some nickname. So, they'd simply write nothing or the actual name again in the ID field, and I've noticed in actual gameplay, that they don't update the ID even if the correct one is in their context later. So, with this you could do the same thing I want to do for my item dossier. Compare the name against character cards, look for a match and pull the ID for avatars etc, and use name Aliases as a fallback to fetching said Id's. Reduces small model failure points or something like that.
  • One future feature of mine (an persistent item dossier to give items actual json entries WITH owners and fetched ownerIDs (either character card id or persona ID), still in development) would use this as its nickname tier, but that is my own work and not part of this request. I am asking only for the read path, not for anyone to build something on top of it.


Sketch of the shape (names are illustrative, maintainers may restructure):

    // The single card parser: one place knows the card's shape.
    export interface CharacterIdentity {
      name: string;
      nameAliases: string[];
    }

    function readCharacterIdentity(data: unknown): CharacterIdentity | null {
      try {
        const parsed = typeof data === "string" ? JSON.parse(data) : data;
        if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;

        const name = (parsed as { name?: unknown }).name;
        if (typeof name !== "string" || !name.trim()) return null;

        // Aliases live on extensions.nameAliases, filtered to non-empty strings.
        const extensions = (parsed as { extensions?: unknown }).extensions;
        const rawAliases =
          extensions && typeof extensions === "object" && !Array.isArray(extensions)
            ? (extensions as { nameAliases?: unknown }).nameAliases
            : undefined;
        const nameAliases = Array.isArray(rawAliases)
          ? rawAliases
              .filter((alias): alias is string => typeof alias === "string" && !!alias.trim())
              .map((alias) => alias.trim())
          : [];

        return { name: name.trim(), nameAliases };
      } catch {
        return null;
      }
    }

    /**
     * Map character ids to name plus aliases. Pure: the caller supplies the lookup.
     * Ids whose card is gone, unreadable, or nameless are absent, matching the
     * existing name resolver.
     */
    export async function resolveCharacterIdentityMap(
      characterIds: string[],
      getCharacterById: (id: string) => Promise<{ data?: unknown } | null | undefined>,
    ): Promise<Map<string, CharacterIdentity>> {
      const entries = await Promise.all(
        characterIds.map(async (id) => {
          const row = await getCharacterById(id);
          const identity = readCharacterIdentity(row?.data);
          return identity ? ([id, identity] as const) : null;
        }),
      );

      return new Map(entries.filter((entry): entry is readonly [string, CharacterIdentity] => !!entry));
    }

    /** Existing callers keep the plain id to name shape. */
    export async function resolveCharacterNameMap(
      characterIds: string[],
      getCharacterById: (id: string) => Promise<{ data?: unknown } | null | undefined>,
    ): Promise<Map<string, string>> {
      const identities = await resolveCharacterIdentityMap(characterIds, getCharacterById);
      return new Map([...identities].map(([id, identity]) => [id, identity.name]));
    }

A consumer then matches in tiers, which is where the alias fallback actually lives:

    const identities = await resolveCharacterIdentityMap(chatCharacterIds, getCharacterById);

    // 1. exact name match (trimmed, case-insensitive)
    // 2. alias match (trimmed, case-insensitive), first match wins on collisions

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @ylli-selmani on GitHub (Sep 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6328 Originally assigned to: @SpicyMarinara on GitHub. Disclaimer: I had Mari write this up, but the idea is simply to read character cards' extension.NameAliases, which are already exported, just not... read on the server side. ## What problem does this solve? Ever since a previous PR of mine (which i like a lot. colored named are awesome), characters can have **name aliases** (`extensions.nameAliases`, editable in the appearance/colors tab). They already travel with the card on export and import, and on the client they already have one consumer: inline name coloring. Nothing else can see them. Anything that needs to take a loose name string and work out *which character card it refers to* can only match the card's exact `name`. In practice, models and users write nicknames, shorthand, or a different spelling ("Logan" for "Wolverine"), that match fails, and the consumer falls back to a bare, unreliable string. Aliases are exactly the human-maintained vocabulary that would fix this, and they are already sitting in the card, unread. ## Proposed solution Make aliases available wherever character names are already resolved on the server side, so a consumer can match an incoming name string against a card's name **and** its aliases and get back a stable character id. Today the existing id to name resolver (`resolveCharacterNameMap`) reads a card's `name` and nothing else. Rather than change its return shape (other callers want a plain name), add a sibling resolver beside it that returns the card's `name` together with its `nameAliases`, keyed by the same character id, and let the existing function become a thin projection of it. One card parser, no second source of truth, and every existing call site keeps working byte for byte. Rules that should match the existing name behavior: - Only cards **added to the chat** are eligible (present in the chat's character list, whether enabled or disabled). - The link between a card, its name, and its aliases is the map key: all three come off the same `getCharacterById(id)` row, so an alias cannot drift to a different id and there is no separate alias table to keep in sync. - Alias matching is a **fallback tier**, tried after the exact name has been tried. Not a replacement, and not a reordering. - Blank or non-string alias entries are ignored rather than stored. - If two cards share an alias, first match wins is acceptable. ## Alternatives considered - **Keep aliases client-only**: leaves any server-side or agent-side consumer unable to resolve nicknames, and duplicates matching logic per consumer. - **Ask models to spell names exactly**: the misspelling is the failure mode, so this does not fix it. Users maintain aliases precisely because the spelling varies. ## Additional context * Purely additive: no new storage, no new card field, no UI change. Aliases are already authored, already persisted, and already imported/exported with the card. This is only about giving them a read path outside the client. * Other possible uses beyond mine: scanning recent messages for names or nicknames and resolving them to character ids (for trackers, presence detection, or speaker attribution), and generally letting any feature key off "who is this text about" without hard-coding spellings. - On the top of my head: The Character Tracker Agent currently copies character id's from < characters > and then uses them in their output for presentCharacters. But if someone's card is currently not active, but in the chat and in the STORY, the agent doesn't have an ID to copy, and maybe they don't even use their actual Card Name, but some nickname. So, they'd simply write nothing or the actual name again in the ID field, and I've noticed in actual gameplay, that they don't update the ID even if the correct one is in their context later. So, with this you could do the same thing I want to do for my item dossier. Compare the name against character cards, look for a match and pull the ID for avatars etc, and use name Aliases as a fallback to fetching said Id's. Reduces small model failure points or something like that. * One future feature of mine (an persistent item dossier to give items actual json entries WITH owners and fetched ownerIDs (either character card id or persona ID), still in development) would use this as its nickname tier, but that is my own work and not part of this request. I am asking only for the read path, not for anyone to build something on top of it. --- Sketch of the shape (names are illustrative, maintainers may restructure): ``` // The single card parser: one place knows the card's shape. export interface CharacterIdentity { name: string; nameAliases: string[]; } function readCharacterIdentity(data: unknown): CharacterIdentity | null { try { const parsed = typeof data === "string" ? JSON.parse(data) : data; if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null; const name = (parsed as { name?: unknown }).name; if (typeof name !== "string" || !name.trim()) return null; // Aliases live on extensions.nameAliases, filtered to non-empty strings. const extensions = (parsed as { extensions?: unknown }).extensions; const rawAliases = extensions && typeof extensions === "object" && !Array.isArray(extensions) ? (extensions as { nameAliases?: unknown }).nameAliases : undefined; const nameAliases = Array.isArray(rawAliases) ? rawAliases .filter((alias): alias is string => typeof alias === "string" && !!alias.trim()) .map((alias) => alias.trim()) : []; return { name: name.trim(), nameAliases }; } catch { return null; } } /** * Map character ids to name plus aliases. Pure: the caller supplies the lookup. * Ids whose card is gone, unreadable, or nameless are absent, matching the * existing name resolver. */ export async function resolveCharacterIdentityMap( characterIds: string[], getCharacterById: (id: string) => Promise<{ data?: unknown } | null | undefined>, ): Promise<Map<string, CharacterIdentity>> { const entries = await Promise.all( characterIds.map(async (id) => { const row = await getCharacterById(id); const identity = readCharacterIdentity(row?.data); return identity ? ([id, identity] as const) : null; }), ); return new Map(entries.filter((entry): entry is readonly [string, CharacterIdentity] => !!entry)); } /** Existing callers keep the plain id to name shape. */ export async function resolveCharacterNameMap( characterIds: string[], getCharacterById: (id: string) => Promise<{ data?: unknown } | null | undefined>, ): Promise<Map<string, string>> { const identities = await resolveCharacterIdentityMap(characterIds, getCharacterById); return new Map([...identities].map(([id, identity]) => [id, identity.name])); } ``` A consumer then matches in tiers, which is where the alias fallback actually lives: ``` const identities = await resolveCharacterIdentityMap(chatCharacterIds, getCharacterById); // 1. exact name match (trimmed, case-insensitive) // 2. alias match (trimmed, case-insensitive), first match wins on collisions ``` ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 18, 2026):

@SpicyMarinara is handling this in the current issue sweep: #6335. Implementation and regression proof are in progress.

<!-- gh-comment-id:5734517055 --> @SpicyMarinara commented on GitHub (Sep 18, 2026): @SpicyMarinara is handling this in the current issue sweep: #6335. Implementation and regression proof are in progress.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 18, 2026):

Resolved in #6335, merged into staging.

Added a reusable character identity resolver that reads canonical names and sanitized aliases from the same card data. The existing name-only resolver uses that parser too. It reads the caller's supplied chat members, including disabled members, without scanning unrelated characters.

Regression proof covers imported JSON and object cards, malformed aliases, chat scope and name-only compatibility. This supplies the requested read path; it does not add downstream alias-matching behavior.

<!-- gh-comment-id:5735396674 --> @SpicyMarinara commented on GitHub (Sep 18, 2026): Resolved in #6335, merged into `staging`. Added a reusable character identity resolver that reads canonical names and sanitized aliases from the same card data. The existing name-only resolver uses that parser too. It reads the caller's supplied chat members, including disabled members, without scanning unrelated characters. Regression proof covers imported JSON and object cards, malformed aliases, chat scope and name-only compatibility. This supplies the requested read path; it does not add downstream alias-matching behavior.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3532
No description provided.