[PR #227] [MERGED] feat(lorebooks): add description field to lorebook entries (Part of Knowledge-Router Agent PRs) #4516

Closed
opened 2026-10-22 04:08:20 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/227
Author: @cha1latte
Created: 4/25/2026
Status: ✅ Merged
Merged: 4/28/2026
Merged by: @SpicyMarinara

Base: main ← Head: feat/lorebook-entry-description


📝 Commits (2)

  • 4be14e7 feat(lorebooks): add description field to lorebook entries
  • ce3be2b fix(lorebooks): align CREATE TABLE with description column and update test fixture

📊 Changes

7 files changed (+31 additions, -0 deletions)

View changed files

📝 packages/client/src/components/lorebooks/LorebookEditor.tsx (+16 -0)
📝 packages/server/src/db/migrate.ts (+6 -0)
📝 packages/server/src/db/schema/lorebooks.ts (+2 -0)
📝 packages/server/src/services/storage/lorebooks.storage.ts (+2 -0)
📝 packages/server/test/lorebook-processing.test.ts (+1 -0)
📝 packages/shared/src/schemas/lorebook.schema.ts (+2 -0)
📝 packages/shared/src/types/lorebook.ts (+2 -0)

📄 Description

Part 1 of #226 — schema groundwork for the upcoming knowledge-router agent.

Summary

Adds a description column to lorebook_entries and a textarea for it in the entry editor. The field is short AI-facing summary text (one or two sentences) that the future knowledge-router agent will use to decide which entries are relevant to the current scene — without paying the cost of summarizing every entry's full content.

This PR is schema-only. No agent yet, no behavior change for existing flows. The field defaults to empty and is invisible to all current code paths.

Why

The existing knowledge-retrieval agent summarizes every enabled entry from the configured source lorebooks before generation. For large lorebooks (One Piece, Wheel of Time, etc.) this gets chunked and adds significant latency and token cost — and for constant: true entries, it duplicates work the standard activation pipeline already does. The knowledge-router agent (coming in the next PR) will instead read short descriptions and pick entry IDs to inject verbatim. This PR gives users a place to write those descriptions.

See issue #226 for the full design and the maintainer's Discord invitation.

Changes

File Change
packages/server/src/db/schema/lorebooks.ts New description column on lorebookEntries, defaults to ""
packages/server/src/db/migrate.ts Idempotent ALTER TABLE migration entry
packages/shared/src/schemas/lorebook.schema.ts description field on create + update Zod schemas
packages/shared/src/types/lorebook.ts description: string on LorebookEntry
packages/server/src/services/storage/lorebooks.storage.ts Wired through createEntry / updateEntry
packages/client/src/components/lorebooks/LorebookEditor.tsx Description textarea below Name in the entry editor

Known limitations

  • Existing entries have empty descriptions. That's intentional — the knowledge-router agent will fall back to entry name + first 1-2 keys when description is empty, so old lorebooks still work, just less precisely. A future "lorebook description backfill" agent could auto-populate them; out of scope here.
  • No UI surface yet showing descriptions in lists or coverage. That's part of the agent's settings panel in the third PR in this set.
image

Summary by CodeRabbit

  • New Features
    • Users can add and edit a new description field for lorebook entries via the editor; descriptions are saved with entries.
    • Descriptions are now used to improve entry relevance and selection, enhancing how related content is surfaced.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/227 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 4/25/2026 **Status:** ✅ Merged **Merged:** 4/28/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `feat/lorebook-entry-description` --- ### 📝 Commits (2) - [`4be14e7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4be14e77976b2d9e366a00ed80c6ac1b60994db8) feat(lorebooks): add description field to lorebook entries - [`ce3be2b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ce3be2ba040146634cdab7e7207d718bf35a2ea1) fix(lorebooks): align CREATE TABLE with description column and update test fixture ### 📊 Changes **7 files changed** (+31 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/lorebooks/LorebookEditor.tsx` (+16 -0) 📝 `packages/server/src/db/migrate.ts` (+6 -0) 📝 `packages/server/src/db/schema/lorebooks.ts` (+2 -0) 📝 `packages/server/src/services/storage/lorebooks.storage.ts` (+2 -0) 📝 `packages/server/test/lorebook-processing.test.ts` (+1 -0) 📝 `packages/shared/src/schemas/lorebook.schema.ts` (+2 -0) 📝 `packages/shared/src/types/lorebook.ts` (+2 -0) </details> ### 📄 Description Part 1 of #226 — schema groundwork for the upcoming `knowledge-router` agent. ## Summary Adds a `description` column to `lorebook_entries` and a textarea for it in the entry editor. The field is short AI-facing summary text (one or two sentences) that the future `knowledge-router` agent will use to decide which entries are relevant to the current scene — without paying the cost of summarizing every entry's full content. This PR is **schema-only**. No agent yet, no behavior change for existing flows. The field defaults to empty and is invisible to all current code paths. ## Why The existing `knowledge-retrieval` agent summarizes every enabled entry from the configured source lorebooks before generation. For large lorebooks (One Piece, Wheel of Time, etc.) this gets chunked and adds significant latency and token cost — and for `constant: true` entries, it duplicates work the standard activation pipeline already does. The `knowledge-router` agent (coming in the next PR) will instead read short descriptions and pick entry IDs to inject verbatim. This PR gives users a place to write those descriptions. See [issue #226](https://github.com/Pasta-Devs/Marinara-Engine/issues/226) for the full design and the maintainer's Discord invitation. ## Changes | File | Change | |---|---| | `packages/server/src/db/schema/lorebooks.ts` | New `description` column on `lorebookEntries`, defaults to `""` | | `packages/server/src/db/migrate.ts` | Idempotent `ALTER TABLE` migration entry | | `packages/shared/src/schemas/lorebook.schema.ts` | `description` field on create + update Zod schemas | | `packages/shared/src/types/lorebook.ts` | `description: string` on `LorebookEntry` | | `packages/server/src/services/storage/lorebooks.storage.ts` | Wired through `createEntry` / `updateEntry` | | `packages/client/src/components/lorebooks/LorebookEditor.tsx` | Description textarea below Name in the entry editor | ## Known limitations - **Existing entries have empty descriptions.** That's intentional — the `knowledge-router` agent will fall back to entry name + first 1-2 keys when description is empty, so old lorebooks still work, just less precisely. A future "lorebook description backfill" agent could auto-populate them; out of scope here. - **No UI surface yet showing descriptions in lists or coverage.** That's part of the agent's settings panel in the third PR in this set. <img width="990" height="347" alt="image" src="https://github.com/user-attachments/assets/5efa4b43-85f2-4115-ae05-69b0eac32dd7" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Users can add and edit a new description field for lorebook entries via the editor; descriptions are saved with entries. * Descriptions are now used to improve entry relevance and selection, enhancing how related content is surfaced. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:08:20 +07:00
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#4516
No description provided.