[PR #7376] [CLOSED] feat(mari): built-in skill library, on-demand skill tool, pacing rules #7708

Closed
opened 2026-10-24 04:06:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7376
Author: @ATreemanDork
Created: 10/9/2026
Status: ❌ Closed

Base: staging ← Head: feat/mari-skills-pacing


📝 Commits (8)

  • 74882da refactor(mari): move workspace tool definitions into a tool registry
  • 025a5e3 feat(mari): built-in skill library, on-demand skill tool, pacing rules
  • 837c9d7 feat(mari): direct the model to load matching skills before acting
  • da0d759 feat(mari): show a skill-active chip when the skill tool loads a skill
  • 5ca52fa fix(mari): let the skill tool pass workspace command validation
  • 8f8aafa fix(mari): self-correct misrouted skill fetches
  • c920e5d fix(mari): steer skill fetches away from app_data in the prompt
  • 4bc144f fix(mari): stop parrotting the catchphrase in workspace replies

📊 Changes

13 files changed (+2249 additions, -478 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/chat/HomeProfessorMariChat.tsx (+43 -5)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+12 -0)
➕ packages/server/src/services/professor-mari/builtin-skills.ts (+524 -0)
➕ packages/server/src/services/professor-mari/tool-registry.ts (+1317 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+122 -451)
📝 packages/server/src/services/professor-mari/workspace-skills.service.ts (+114 -6)
📝 packages/shared/src/types/professor-mari-workspace.ts (+4 -1)
➕ scripts/regressions/mari-skill-tool.regression.ts (+73 -0)
📝 scripts/regressions/open-issues.regression.ts (+7 -1)
📝 scripts/regressions/professor-mari-preset-variables.regression.ts (+23 -11)
📝 scripts/regressions/professor-mari/shell-sandbox.regression.ts (+7 -3)

📄 Description

Closes #7375

Stacked PR: This branch is based on #7366 (tool-registry refactor) and includes its commit 74882da1c. GitHub shows "includes #7366"; it will be rebased onto staging once #7366 lands.

Why this change

Professor Mari's Home workspace prompt currently carries verbose how-to guidance — command-family reference, guided sequences, lorebook/preset authoring guides — inline on every turn, and the model has no structured way to be handed task-specific instructions. Long inline guides get compressed poorly by models and bloat the always-in-context prompt.

This PR ships a built-in skill library with on-demand retrieval:

  • 16 built-in skill documents (builtin-skills.ts) covering Mari's task catalog (docs, files, commands, deps, chats, characters, lorebooks, presets, themes).
  • Compact always-in-context index: a <skill_library> block (~19 lines) with one line per skill; full docs are fetched only when needed.
  • New skill tool (16th, kind meta, non-mutating, idempotent): Mari calls skill with an id from the index to load the full instructions.
  • Live-test routing fixes (found in a Docker build while trying the feature): (a) the skill tool case was missing from the workspace-command validation gate, so every skill call failed with "Unsupported workspace command: skill" before reaching the dispatcher; (b) models keep trying to reach the skill library through app_data ({"action": "skill"}) — the structured app-data runtime now answers with a self-correcting error pointing at the skill tool and the in-context <skill_library> index, and the app_data tool description now states that skills are not app_data actions (that description is where the model forms the "skills are app data" belief); (c) a commandSkill() miss now points at the in-context skill index, so a guessed id (models do invent ids like scenario-build) is self-correcting instead of a bare dead end. All pinned by a new regression lane.
  • Skill-fetch directive: the <skill_library> index now tells the model to load the skill(s) matching a task before acting and follow their Workflow. Multi-tool tasks (e.g. create a character and a lorebook) are thus driven by the matching skill's tool-recipe instead of being improvised from the pacing block. (Server-side auto-activation - task→skill routing - is the documented upgrade path if this soft directive proves unreliable.)
  • Skill-active chip (client, moved in from the would-be PR 3): when the skill tool loads a skill, the chat timeline now shows a dedicated Mari skill / Skill active chip naming the skill and tagging it · Built-in / · Custom (parses the skill tool's <skill id name builtin> output wrapper; degrades to a humanized id with no tag while the call is still running). Reuses the existing skill tone; no new localization keys.
  • User-editable built-ins: the existing Skills panel now lists the 16 built-ins with a "Built-in" badge. Editing one materializes it into the user's skills storage; a "Restore Default" button (enabled once edited) removes the local copy and the shipped text returns. User-authored skills are untouched — payloads stay byte-identical (builtin flag only appears on built-ins).
  • Leaner system prompt: the multi-line Command-families block is replaced by a compact <tool_inventory> derived from the tool registry; MARI_GUIDED_SEQUENCES and the lorebook/preset authoring guides are replaced by a short <pacing> block (their content now lives in the task skills). All behavioral rules (read-back, apply:false semantics, decision authoring, MAX_COMMAND_ROUNDS = 12) are unchanged.

What changed

  • packages/server/src/services/professor-mari/builtin-skills.ts (new): 16 built-in skill documents, fixed BUILTIN_SKILL_TIMESTAMP, BUILTIN_SKILLS/BUILTIN_SKILL_MAP/BUILTIN_SKILL_IDS exports, getBuiltinSkill(), renderSkillLibraryIndex().
  • tool-registry.ts: skill tool entry (16th); count comment updated. Derived exports (WORKSPACE_TOOL_NAMES, etc.) pick it up automatically. The app_data description now states that skills are not app_data actions (the index is already in context, and the skill tool loads one by id) — that description is where the model forms the "skills are app data" belief.
  • workspace-agent.service.ts: renderToolInventory() replaces the Command-families block in the system prompt; <pacing> block replaces ${MARI_GUIDED_SEQUENCES} and the lorebook/preset authoring guides in the protocol prompt (behavioral rules kept); buildSkillsPrompt() now emits the two-layer <skill_library> index + <user_skills>; new case "skill" dispatch via commandSkill() (service-first, then shipped constant; <skill id name builtin> XML output); workspaceCommandValidationIssue() gains a case "skill" so skill calls clear the validation gate (they previously failed with "Unsupported workspace command: skill" before reaching the dispatcher); a commandSkill() miss ("Skill "X" not found.") now points at the in-context skill index so a guessed id is self-correcting.
  • packages/server/src/services/mari-db/mari-db.service.ts: executeAction returns a self-correcting error for skill* app_data actions (models sometimes route a skill fetch here instead of the skill tool), pointing at the tool and the in-context <skill_library> index instead of the generic unsupported-action dead end.
  • scripts/regressions/mari-skill-tool.regression.ts (new): pins the skill-tool validation gate (valid id dispatches to the wrapper, missing id rejects, unknown id reaches commandSkill with a self-correcting miss) and the app_data skill routing (runtime: skill and skill.get actions get the self-correcting error, not the generic dead end).
  • workspace-skills.service.ts: list() merges the built-in library (materialized file wins; shipped constant synthesized with pinned timestamps); new getById(); update() materializes a built-in on first edit; delete() of an unedited built-in is a no-op (Restore Default = remove the override); builtin flag only on built-ins.
  • packages/shared/.../professor-mari-workspace.ts: "skill" in the tool-name union; builtin?: boolean on the skill summary.
  • Client HomeProfessorMariChat.tsx: "Built-in" badge next to built-in names; delete button becomes "Restore Default" with RotateCcw for built-ins (enabled only once the built-in has been edited). 2 new en.json keys. Plus the active-skill timeline chip (getSkillToolPresentation + a skill branch in inferToolPresentation).
  • professor-mari-preset-variables.regression.ts: check 1 now pins the {{variableName}} guidance in the create-preset/edit-preset skill docs; check 2 (protocol prompt preset.create example) unchanged.
  • CHANGELOG.md: [Unreleased] entry.

Validation

  • pnpm check passes locally (TypeScript + ESLint + format + localization + build)
  • 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

Additional automated validation run locally:

  • pnpm regression:prompt: 1/1 passed
  • pnpm regression:node (full suite): 544/545 passed. The one failure, log-worker-ready, is an unrelated log-worker harness flake ("unsettled top-level await" on becomesReady, no reference to mari/skills/registry in the test); it passes when re-run standalone.
  • Targeted regression lanes: professor-mari 9/9, professor-mari-preset-variables 1/1, mari-package-service 1/1, mari/decision-authoring 1/1, mari-skill-tool 1/1, open-issues 1/1, capability-tool-runtime 1/1, game-mode-dice-tool 1/1, multiplayer-generation-policy 1/1 — all passed; full mari filter re-run 32/32 after the app_data routing change
  • pnpm version:check: version files in sync for 2.5.0
  • Temporary prompt-shape + skills-lifecycle sanity script (removed after run): 16-tool registry shape, system-prompt <tool_inventory> (16 lines incl. skill), protocol-prompt <pacing> + |skill schema union, and the built-in lifecycle (fresh list = 16 pinned built-ins → edit materializes file → updatedAt > createdAt → delete restores shipped text → unedited delete is a no-op → user-skill payloads carry no builtin key) — all passed

Manual verification notes

  • Manually verify in Home → Professor Mari → Skills panel: the 16 built-ins show a "Built-in" badge; editing one and saving persists it and enables the "Restore Default" button; clicking it removes the local copy and the shipped text returns; a user-created skill still shows the plain delete button.
  • Manually verify in a Mari chat: a multi-step task (e.g. "create a lorebook with 3 entries") runs at a 1–3 commands-per-response pace and verifies each step; the model can fetch skill content by id (ask it to load create-lorebook).

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)

UI evidence (if applicable)

UI change is the Skills panel badge + Restore Default button (screenshot to be added after manual browser verification).


🔄 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/7376 **Author:** [@ATreemanDork](https://github.com/ATreemanDork) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `feat/mari-skills-pacing` --- ### 📝 Commits (8) - [`74882da`](https://github.com/Pasta-Devs/Marinara-Engine/commit/74882da1ca9d8453d03518ac14cdf1e719098158) refactor(mari): move workspace tool definitions into a tool registry - [`025a5e3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/025a5e36dca43b0cf86e094d80b198e2fb2e4068) feat(mari): built-in skill library, on-demand skill tool, pacing rules - [`837c9d7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/837c9d7da047b108cdcf0fc4d6c112bb3e20efd3) feat(mari): direct the model to load matching skills before acting - [`da0d759`](https://github.com/Pasta-Devs/Marinara-Engine/commit/da0d75937cb91a05bb46ac79c2a94f4264fde933) feat(mari): show a skill-active chip when the skill tool loads a skill - [`5ca52fa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5ca52fa0730b6a60ec3a3df8910a49b1119a5e27) fix(mari): let the skill tool pass workspace command validation - [`8f8aafa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f8aafab4323f65e34a97c31a69206734feafbcd) fix(mari): self-correct misrouted skill fetches - [`c920e5d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c920e5d42f52c7d5ca0663c78dc5949d657bcfee) fix(mari): steer skill fetches away from app_data in the prompt - [`4bc144f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4bc144f33638f5e4d3102f93465c6b31f3e6ebb2) fix(mari): stop parrotting the catchphrase in workspace replies ### 📊 Changes **13 files changed** (+2249 additions, -478 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/chat/HomeProfessorMariChat.tsx` (+43 -5) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+12 -0) ➕ `packages/server/src/services/professor-mari/builtin-skills.ts` (+524 -0) ➕ `packages/server/src/services/professor-mari/tool-registry.ts` (+1317 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+122 -451) 📝 `packages/server/src/services/professor-mari/workspace-skills.service.ts` (+114 -6) 📝 `packages/shared/src/types/professor-mari-workspace.ts` (+4 -1) ➕ `scripts/regressions/mari-skill-tool.regression.ts` (+73 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+7 -1) 📝 `scripts/regressions/professor-mari-preset-variables.regression.ts` (+23 -11) 📝 `scripts/regressions/professor-mari/shell-sandbox.regression.ts` (+7 -3) </details> ### 📄 Description Closes #7375 **Stacked PR:** This branch is based on #7366 (tool-registry refactor) and includes its commit `74882da1c`. GitHub shows "includes #7366"; it will be rebased onto `staging` once #7366 lands. ## Why this change Professor Mari's Home workspace prompt currently carries verbose how-to guidance — command-family reference, guided sequences, lorebook/preset authoring guides — inline on every turn, and the model has no structured way to be handed task-specific instructions. Long inline guides get compressed poorly by models and bloat the always-in-context prompt. This PR ships a built-in skill library with on-demand retrieval: - **16 built-in skill documents** (`builtin-skills.ts`) covering Mari's task catalog (docs, files, commands, deps, chats, characters, lorebooks, presets, themes). - **Compact always-in-context index**: a `<skill_library>` block (~19 lines) with one line per skill; full docs are fetched only when needed. - **New `skill` tool** (16th, kind `meta`, non-mutating, idempotent): Mari calls `skill` with an id from the index to load the full instructions. - **Live-test routing fixes** (found in a Docker build while trying the feature): (a) the `skill` tool case was missing from the workspace-command validation gate, so every skill call failed with "Unsupported workspace command: skill" before reaching the dispatcher; (b) models keep trying to reach the skill library through `app_data` (`{"action": "skill"}`) — the structured app-data runtime now answers with a self-correcting error pointing at the `skill` tool and the in-context `<skill_library>` index, and the `app_data` tool description now states that skills are not app_data actions (that description is where the model forms the "skills are app data" belief); (c) a `commandSkill()` miss now points at the in-context skill index, so a guessed id (models do invent ids like `scenario-build`) is self-correcting instead of a bare dead end. All pinned by a new regression lane. - **Skill-fetch directive**: the `<skill_library>` index now tells the model to load the skill(s) matching a task *before* acting and follow their `Workflow`. Multi-tool tasks (e.g. create a character *and* a lorebook) are thus driven by the matching skill's tool-recipe instead of being improvised from the pacing block. (Server-side auto-activation - task→skill routing - is the documented upgrade path if this soft directive proves unreliable.) - **Skill-active chip** (client, moved in from the would-be PR 3): when the `skill` tool loads a skill, the chat timeline now shows a dedicated `Mari skill` / `Skill active` chip naming the skill and tagging it `· Built-in` / `· Custom` (parses the skill tool's `<skill id name builtin>` output wrapper; degrades to a humanized id with no tag while the call is still running). Reuses the existing `skill` tone; no new localization keys. - **User-editable built-ins**: the existing Skills panel now lists the 16 built-ins with a "Built-in" badge. Editing one materializes it into the user's skills storage; a "Restore Default" button (enabled once edited) removes the local copy and the shipped text returns. User-authored skills are untouched — payloads stay byte-identical (`builtin` flag only appears on built-ins). - **Leaner system prompt**: the multi-line Command-families block is replaced by a compact `<tool_inventory>` derived from the tool registry; `MARI_GUIDED_SEQUENCES` and the lorebook/preset authoring guides are replaced by a short `<pacing>` block (their content now lives in the task skills). All behavioral rules (read-back, `apply:false` semantics, decision authoring, `MAX_COMMAND_ROUNDS = 12`) are unchanged. ## What changed - `packages/server/src/services/professor-mari/builtin-skills.ts` (new): 16 built-in skill documents, fixed `BUILTIN_SKILL_TIMESTAMP`, `BUILTIN_SKILLS`/`BUILTIN_SKILL_MAP`/`BUILTIN_SKILL_IDS` exports, `getBuiltinSkill()`, `renderSkillLibraryIndex()`. - `tool-registry.ts`: `skill` tool entry (16th); count comment updated. Derived exports (`WORKSPACE_TOOL_NAMES`, etc.) pick it up automatically. The `app_data` description now states that skills are not app_data actions (the index is already in context, and the `skill` tool loads one by id) — that description is where the model forms the "skills are app data" belief. - `workspace-agent.service.ts`: `renderToolInventory()` replaces the Command-families block in the system prompt; `<pacing>` block replaces `${MARI_GUIDED_SEQUENCES}` and the lorebook/preset authoring guides in the protocol prompt (behavioral rules kept); `buildSkillsPrompt()` now emits the two-layer `<skill_library>` index + `<user_skills>`; new `case "skill"` dispatch via `commandSkill()` (service-first, then shipped constant; `<skill id name builtin>` XML output); `workspaceCommandValidationIssue()` gains a `case "skill"` so skill calls clear the validation gate (they previously failed with "Unsupported workspace command: skill" before reaching the dispatcher); a `commandSkill()` miss ("Skill \"X\" not found.") now points at the in-context skill index so a guessed id is self-correcting. - `packages/server/src/services/mari-db/mari-db.service.ts`: `executeAction` returns a self-correcting error for `skill*` app_data actions (models sometimes route a skill fetch here instead of the `skill` tool), pointing at the tool and the in-context `<skill_library>` index instead of the generic unsupported-action dead end. - `scripts/regressions/mari-skill-tool.regression.ts` (new): pins the skill-tool validation gate (valid id dispatches to the wrapper, missing id rejects, unknown id reaches `commandSkill` with a self-correcting miss) and the app_data skill routing (runtime: `skill` and `skill.get` actions get the self-correcting error, not the generic dead end). - `workspace-skills.service.ts`: `list()` merges the built-in library (materialized file wins; shipped constant synthesized with pinned timestamps); new `getById()`; `update()` materializes a built-in on first edit; `delete()` of an unedited built-in is a no-op (Restore Default = remove the override); `builtin` flag only on built-ins. - `packages/shared/.../professor-mari-workspace.ts`: `"skill"` in the tool-name union; `builtin?: boolean` on the skill summary. - Client `HomeProfessorMariChat.tsx`: "Built-in" badge next to built-in names; delete button becomes "Restore Default" with `RotateCcw` for built-ins (enabled only once the built-in has been edited). 2 new en.json keys. Plus the active-skill timeline chip (`getSkillToolPresentation` + a `skill` branch in `inferToolPresentation`). - `professor-mari-preset-variables.regression.ts`: check 1 now pins the `{{variableName}}` guidance in the `create-preset`/`edit-preset` skill docs; check 2 (protocol prompt `preset.create` example) unchanged. - `CHANGELOG.md`: [Unreleased] entry. ## Validation - [x] `pnpm check` passes locally (TypeScript + ESLint + format + localization + build) - [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` Additional automated validation run locally: - `pnpm regression:prompt`: 1/1 passed - `pnpm regression:node` (full suite): 544/545 passed. The one failure, `log-worker-ready`, is an unrelated log-worker harness flake ("unsettled top-level await" on `becomesReady`, no reference to mari/skills/registry in the test); it passes when re-run standalone. - Targeted regression lanes: `professor-mari` 9/9, `professor-mari-preset-variables` 1/1, `mari-package-service` 1/1, `mari/decision-authoring` 1/1, `mari-skill-tool` 1/1, `open-issues` 1/1, `capability-tool-runtime` 1/1, `game-mode-dice-tool` 1/1, `multiplayer-generation-policy` 1/1 — all passed; full `mari` filter re-run 32/32 after the app_data routing change - `pnpm version:check`: version files in sync for 2.5.0 - Temporary prompt-shape + skills-lifecycle sanity script (removed after run): 16-tool registry shape, system-prompt `<tool_inventory>` (16 lines incl. `skill`), protocol-prompt `<pacing>` + `|skill` schema union, and the built-in lifecycle (fresh list = 16 pinned built-ins → edit materializes file → `updatedAt > createdAt` → delete restores shipped text → unedited delete is a no-op → user-skill payloads carry no `builtin` key) — all passed ### Manual verification notes - Manually verify in Home → Professor Mari → Skills panel: the 16 built-ins show a "Built-in" badge; editing one and saving persists it and enables the "Restore Default" button; clicking it removes the local copy and the shipped text returns; a user-created skill still shows the plain delete button. - Manually verify in a Mari chat: a multi-step task (e.g. "create a lorebook with 3 entries") runs at a 1–3 commands-per-response pace and verifies each step; the model can fetch skill content by id (ask it to load `create-lorebook`). ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [x] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [x] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) UI change is the Skills panel badge + Restore Default button (screenshot to be added after manual browser verification). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:44 +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#7708
No description provided.