[GH-ISSUE #4798] [Feature]: CLI parity — expose selective/matchWholeWords/etc. on mari lorebooks add-entry/update-entry #2644

Closed
opened 2026-10-21 05:52:05 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Aug 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4798

Originally assigned to: @kolacheee on GitHub.

What problem does this solve?

#4791 / #4796 exposed the advanced lorebook entry fields (selective, selectiveLogic, matchWholeWords, caseSensitive, useRegex) to Professor Mari's app_data lorebook.create / addEntry / updateEntry actions, which had previously been silently hardcoded. The mari CLI is a separate code path that PR #4796 did not touch, so it still cannot set these fields:

  • mari lorebooks add-entry (the executeCli add-entry handler in packages/server/src/services/mari-db/mari-db.service.ts) builds its entry row inline and hardcodes selective: "false", selectiveLogic: "and", matchWholeWords: "false", caseSensitive: "false", useRegex: "false" (and secondaryKeys: []), with no flags to override them.
  • mari lorebooks update-entry supports only --name / --content / --keys / --description / --tag / --outlet-name / --enable / --disable / --constant / --no-constant / --order / --folder-id. It has no --selective, --selective-logic, --match-whole-words, --case-sensitive, --use-regex, or --secondary-keys (and also no --position / --depth / --role / --group, which the app_data updateEntry path does accept).

So a lorebook entry authored or edited via the CLI cannot be made Selective, whole-word, case-sensitive, or regex-matched, cannot carry secondary keys, and cannot be grouped/placed — an inconsistency with the app_data surface that now supports all of these.

Severity: low / non-blocking. It is mitigated because Professor Mari is directed to use app_data (not the CLI) for lorebook-entry writes, so the realistic exposure is small. This is a consistency/completeness gap for CLI users and any future CLI-driven automation. It was surfaced during the adversarial review of #4796.

Proposed solution

Bring the CLI lorebooks add-entry / update-entry handlers to parity with the app_data entry-write surface:

  • add-entry: read --selective, --selective-logic, --match-whole-words, --case-sensitive, --use-regex, --secondary-keys (and consider --position / --depth / --role / --group) instead of hardcoding, validating --selective-logic against the enum (and / and_all / or / not / not_all) the same way normalizeSelectiveLogic now does for the app_data path.
  • update-entry: add the same flags to the field/flag handling.
  • Ideally refactor the CLI entry-row build to reuse buildLorebookEntryCreateRow (which, after #4796, already reads all these fields from its data argument) rather than duplicating the row shape inline — so the two paths cannot silently drift apart again.
  • Update the add-entry / update-entry usage strings and add a regression covering the new flags.

Alternatives considered

  • Leave the CLI as-is — acceptable short-term (Mari is routed to app_data), but the divergence will keep surprising CLI users and is exactly the kind of duplicated-row-shape that re-drifts.

Additional context

  • Counterpart PR that fixed the app_data path: #4796 (issue #4791). This issue is the CLI half, deliberately scoped out of that PR.
  • Location: the executeCli lorebooks add-entry / update-entry cases in packages/server/src/services/mari-db/mari-db.service.ts (the inline entryRow build with the hardcoded selective/selectiveLogic/matchWholeWords/caseSensitive/useRegex, and the entryFieldMap + flag handling in update-entry).
  • Refactor hint: buildLorebookEntryCreateRow already reads all these fields, so CLI add-entry could delegate to it and drop the duplicated inline row.

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 @kolacheee on GitHub (Aug 9, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4798 Originally assigned to: @kolacheee on GitHub. ## What problem does this solve? #4791 / #4796 exposed the advanced lorebook entry fields (`selective`, `selectiveLogic`, `matchWholeWords`, `caseSensitive`, `useRegex`) to Professor Mari's `app_data` `lorebook.create` / `addEntry` / `updateEntry` actions, which had previously been silently hardcoded. The **`mari` CLI** is a *separate* code path that PR #4796 did not touch, so it still cannot set these fields: - **`mari lorebooks add-entry`** (the `executeCli` `add-entry` handler in `packages/server/src/services/mari-db/mari-db.service.ts`) builds its entry row inline and hardcodes `selective: "false"`, `selectiveLogic: "and"`, `matchWholeWords: "false"`, `caseSensitive: "false"`, `useRegex: "false"` (and `secondaryKeys: []`), with no flags to override them. - **`mari lorebooks update-entry`** supports only `--name` / `--content` / `--keys` / `--description` / `--tag` / `--outlet-name` / `--enable` / `--disable` / `--constant` / `--no-constant` / `--order` / `--folder-id`. It has no `--selective`, `--selective-logic`, `--match-whole-words`, `--case-sensitive`, `--use-regex`, or `--secondary-keys` (and also no `--position` / `--depth` / `--role` / `--group`, which the `app_data` `updateEntry` path *does* accept). So a lorebook entry authored or edited via the CLI cannot be made Selective, whole-word, case-sensitive, or regex-matched, cannot carry secondary keys, and cannot be grouped/placed — an inconsistency with the `app_data` surface that now supports all of these. **Severity: low / non-blocking.** It is mitigated because Professor Mari is directed to use `app_data` (not the CLI) for lorebook-entry writes, so the realistic exposure is small. This is a consistency/completeness gap for CLI users and any future CLI-driven automation. It was surfaced during the adversarial review of #4796. ## Proposed solution Bring the CLI `lorebooks add-entry` / `update-entry` handlers to parity with the `app_data` entry-write surface: - `add-entry`: read `--selective`, `--selective-logic`, `--match-whole-words`, `--case-sensitive`, `--use-regex`, `--secondary-keys` (and consider `--position` / `--depth` / `--role` / `--group`) instead of hardcoding, validating `--selective-logic` against the enum (`and` / `and_all` / `or` / `not` / `not_all`) the same way `normalizeSelectiveLogic` now does for the `app_data` path. - `update-entry`: add the same flags to the field/flag handling. - Ideally **refactor the CLI entry-row build to reuse `buildLorebookEntryCreateRow`** (which, after #4796, already reads all these fields from its `data` argument) rather than duplicating the row shape inline — so the two paths cannot silently drift apart again. - Update the `add-entry` / `update-entry` usage strings and add a regression covering the new flags. ## Alternatives considered - Leave the CLI as-is — acceptable short-term (Mari is routed to `app_data`), but the divergence will keep surprising CLI users and is exactly the kind of duplicated-row-shape that re-drifts. ## Additional context - Counterpart PR that fixed the `app_data` path: #4796 (issue #4791). This issue is the CLI half, deliberately scoped out of that PR. - Location: the `executeCli` lorebooks `add-entry` / `update-entry` cases in `packages/server/src/services/mari-db/mari-db.service.ts` (the inline `entryRow` build with the hardcoded `selective`/`selectiveLogic`/`matchWholeWords`/`caseSensitive`/`useRegex`, and the `entryFieldMap` + flag handling in `update-entry`). - Refactor hint: `buildLorebookEntryCreateRow` already reads all these fields, so CLI `add-entry` could delegate to it and drop the duplicated inline row. ## 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.
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#2644
No description provided.