[PR #4811] [MERGED] feat(server): CLI parity for lorebook entry keyword/selective fields #6504

Closed
opened 2026-10-23 04:11:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4811
Author: @kolacheee
Created: 8/9/2026
Status: ✅ Merged
Merged: 8/9/2026
Merged by: @kolacheee

Base: staging ← Head: feat/4798-cli-lorebook-parity


📝 Commits (2)

  • c3ae8db feat(server): CLI parity for lorebook entry keyword/selective fields
  • b2a7c94 fix(server): list the new lorebook entry flags in mari lorebooks --help

📊 Changes

2 files changed (+128 additions, -49 deletions)

View changed files

📝 packages/server/src/services/mari-db/mari-db.service.ts (+71 -49)
📝 scripts/regressions/open-issues.regression.ts (+57 -0)

📄 Description

Linked issue

Closes #4798

Why this change

The mari CLI's lorebooks add-entry / update-entry handlers silently hardcoded the advanced lorebook entry fields (selective, selectiveLogic, matchWholeWords, caseSensitive, useRegex) and offered no flags for them — so a lorebook entry authored or edited via the CLI could not be made Selective, whole-word, case-sensitive, or regex-matched, and could not carry secondary keys. That left the CLI behind the app_data entry-write path, which was brought to parity in #4796. This gap was surfaced by the adversarial review of #4796.

What changed

  • Expose --selective, --selective-logic, --match-whole-words, --case-sensitive, --use-regex, and --secondary-keys on mari lorebooks add-entry, and the paired presence flags (--selective/--no-selective, --match-whole-words/--no-match-whole-words, --case-sensitive/--no-case-sensitive, --use-regex/--no-use-regex) plus --selective-logic and --secondary-keys on update-entry. --selective-logic is validated against the stored enum (and/and_all/or/not/not_all) on both subcommands.
  • Refactor add-entry to build its row via buildLorebookEntryCreateRow (the shared app_data builder) instead of a duplicated inline row shape, then apply the CLI-only folderId — so the CLI and app_data entry shapes cannot drift apart again.
  • Register the new bare boolean flags in BOOLEAN_FLAGS and update the add-entry / update-entry usage strings.
  • Extend the open-issues regression with CLI add-entry / update-entry coverage: field round-trip through both, and invalid --selective-logic rejection on both subcommands.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated (run locally, green — boxes left unticked for the human to confirm):

  • pnpm check (tsc + eslint + client build) passes.
  • open-issues regression passes, including the new CLI add-entry / update-entry assertions (fields round-trip through the real executeCli path; invalid --selective-logic is rejected on both subcommands).

Still worth a manual pass (NOT yet done):

  • Run mari lorebooks add-entry <lorebook-id> --name X --keys foo --selective --selective-logic and_all --match-whole-words --use-regex --apply, then read the entry back (mari lorebooks entries / the editor) and confirm the fields persisted.
  • mari lorebooks update-entry <entry-id> --no-match-whole-words --selective-logic not --apply and confirm the patch applied.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

No docs/ files change in this PR, so no docs-i18n mirroring is required. No version bump.

Summary by CodeRabbit

  • New Features

    • Added CLI support for configuring lorebook entry secondary keys, selective matching, selective logic, whole-word matching, case sensitivity, and regular expressions.
    • Added support for changing or clearing these matching options when updating entries.
  • Bug Fixes

    • Improved validation and normalization of selective logic values.
    • Added clearer errors for invalid selective logic settings.
  • Tests

    • Added regression coverage for creating, updating, clearing, and validating lorebook entry matching options.

🔄 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/4811 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/9/2026 **Status:** ✅ Merged **Merged:** 8/9/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/4798-cli-lorebook-parity` --- ### 📝 Commits (2) - [`c3ae8db`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c3ae8dbe785805c2bda2ad448bc26ce57460277c) feat(server): CLI parity for lorebook entry keyword/selective fields - [`b2a7c94`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b2a7c948f7db8177df52bce30a8d86bfffa145fa) fix(server): list the new lorebook entry flags in `mari lorebooks --help` ### 📊 Changes **2 files changed** (+128 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+71 -49) 📝 `scripts/regressions/open-issues.regression.ts` (+57 -0) </details> ### 📄 Description ## Linked issue Closes #4798 ## Why this change The `mari` CLI's `lorebooks add-entry` / `update-entry` handlers silently hardcoded the advanced lorebook entry fields (`selective`, `selectiveLogic`, `matchWholeWords`, `caseSensitive`, `useRegex`) and offered no flags for them — so a lorebook entry authored or edited via the CLI could not be made Selective, whole-word, case-sensitive, or regex-matched, and could not carry secondary keys. That left the CLI behind the `app_data` entry-write path, which was brought to parity in #4796. This gap was surfaced by the adversarial review of #4796. ## What changed - Expose `--selective`, `--selective-logic`, `--match-whole-words`, `--case-sensitive`, `--use-regex`, and `--secondary-keys` on `mari lorebooks add-entry`, and the paired presence flags (`--selective`/`--no-selective`, `--match-whole-words`/`--no-match-whole-words`, `--case-sensitive`/`--no-case-sensitive`, `--use-regex`/`--no-use-regex`) plus `--selective-logic` and `--secondary-keys` on `update-entry`. `--selective-logic` is validated against the stored enum (`and`/`and_all`/`or`/`not`/`not_all`) on both subcommands. - Refactor `add-entry` to build its row via `buildLorebookEntryCreateRow` (the shared `app_data` builder) instead of a duplicated inline row shape, then apply the CLI-only `folderId` — so the CLI and `app_data` entry shapes cannot drift apart again. - Register the new bare boolean flags in `BOOLEAN_FLAGS` and update the `add-entry` / `update-entry` usage strings. - Extend the open-issues regression with CLI `add-entry` / `update-entry` coverage: field round-trip through both, and invalid `--selective-logic` rejection on both subcommands. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated (run locally, green — boxes left unticked for the human to confirm): - `pnpm check` (tsc + eslint + client build) passes. - `open-issues` regression passes, including the new CLI `add-entry` / `update-entry` assertions (fields round-trip through the real `executeCli` path; invalid `--selective-logic` is rejected on both subcommands). Still worth a manual pass (NOT yet done): - Run `mari lorebooks add-entry <lorebook-id> --name X --keys foo --selective --selective-logic and_all --match-whole-words --use-regex --apply`, then read the entry back (`mari lorebooks entries` / the editor) and confirm the fields persisted. - `mari lorebooks update-entry <entry-id> --no-match-whole-words --selective-logic not --apply` and confirm the patch applied. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) No `docs/` files change in this PR, so no `docs-i18n` mirroring is required. No version bump. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added CLI support for configuring lorebook entry secondary keys, selective matching, selective logic, whole-word matching, case sensitivity, and regular expressions. * Added support for changing or clearing these matching options when updating entries. * **Bug Fixes** * Improved validation and normalization of selective logic values. * Added clearer errors for invalid selective logic settings. * **Tests** * Added regression coverage for creating, updating, clearing, and validating lorebook entry matching options. <!-- 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-23 04:11:03 +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#6504
No description provided.