[PR #1390] [MERGED] Restore character field prompt macros #5059

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1390
Author: @Xelvanis
Created: 5/27/2026
Status: ✅ Merged
Merged: 5/27/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/char-field-prompt-macros


📝 Commits (2)

  • 0a1b9dc Restore character field prompt macros
  • 1ce13c5 Bound conditional character field recursion

📊 Changes

9 files changed (+423 additions, -39 deletions)

View changed files

📝 src/engine/generation/prompt-assembly.test.ts (+57 -0)
📝 src/engine/generation/prompt-assembly.ts (+4 -0)
📝 src/engine/shared/macros/macro-engine.test.ts (+150 -1)
📝 src/engine/shared/macros/macro-engine.ts (+166 -38)
📝 src/features/catalog/agents/components/RegexScriptEditor.tsx (+2 -0)
📝 src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts (+2 -0)
📝 src/features/runtime/visuals/types.ts (+2 -0)
➕ src/shared/lib/chat-macros.test.ts (+23 -0)
📝 src/shared/lib/chat-macros.ts (+17 -0)

📄 Description

Linked issue

Closes #1335

Why this change

  • The refactor macro engine did not expose {{charSysInfo}} or {{charPostHistory}}, leaving legacy character system and post-history prompt fields unavailable in prompt/display macro expansion.
  • Nested character-field macros also needed bounded resolution that preserves valid terminal values while still stopping recursive cycles.

What changed

  • Added {{charSysInfo}} and {{charPostHistory}} to the shared macro engine, supported macro list, active-character context, and grouped character expansion.
  • Plumbed character systemPrompt and postHistoryInstructions through prompt assembly, shared chat macro helpers, chat surface character maps, runtime visual character maps, and regex script live-test context.
  • Added regression coverage for direct, nested, grouped, recursive, and lazy character-field macro resolution.

Refactor impact

Primary owner:

engine generation / shared macro engine

Impact areas reviewed:

  • Engine prompt assembly character profile context
  • Shared chat macro context used by mode chat/display surfaces
  • Runtime visual character map typing
  • Regex script editor macro live-test sample context
  • Macro reference/help list through SUPPORTED_MACROS

Boundary notes:

  • Engine macro behavior remains React/Tauri-free.
  • Feature-layer changes only pass existing character fields into macro context.
  • No raw Tauri, raw HTTP, remote runtime, storage, or Rust capability boundary changes.

Pressure points touched:

  • Shared mode UI character data mapping
  • Runtime visual character map shape
  • Regex script live-test macro context

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

Agent-run local checks:

  • pnpm vitest run src/engine/shared/macros/macro-engine.test.ts
  • pnpm vitest run src/engine/shared/macros/macro-engine.test.ts src/engine/generation/prompt-assembly.test.ts src/shared/lib/chat-macros.test.ts
  • pnpm typecheck
  • pnpm check:architecture
  • git diff --check
  • pnpm test
  • pnpm lint
  • pnpm build
  • git diff --cached --check

No native Tauri/manual prompt-preview QA was run; this is the remaining end-to-end app verification gap.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No changelog file exists on this branch, so no changelog update was made.

UI evidence

Not applicable: this does not change visible layout. The only UI-adjacent change updates macro live-test sample context.

Summary by CodeRabbit

  • New Features

    • Added two new character macros: {{charSysInfo}} for character system prompts and {{charPostHistory}} for character post-history instructions, enabling enhanced character-based prompt customization.
  • Tests

    • Extended test coverage for the new character instruction macros, validating proper resolution, nested macro expansion, recursion handling, and conditional block support.

Review Change Stack


🔄 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/1390 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/27/2026 **Status:** ✅ Merged **Merged:** 5/27/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/char-field-prompt-macros` --- ### 📝 Commits (2) - [`0a1b9dc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0a1b9dcbeebadf27b459f114469e17f772f812dd) Restore character field prompt macros - [`1ce13c5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1ce13c5c0eee08f44e8cd19f481f101018f19dc5) Bound conditional character field recursion ### 📊 Changes **9 files changed** (+423 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/prompt-assembly.test.ts` (+57 -0) 📝 `src/engine/generation/prompt-assembly.ts` (+4 -0) 📝 `src/engine/shared/macros/macro-engine.test.ts` (+150 -1) 📝 `src/engine/shared/macros/macro-engine.ts` (+166 -38) 📝 `src/features/catalog/agents/components/RegexScriptEditor.tsx` (+2 -0) 📝 `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts` (+2 -0) 📝 `src/features/runtime/visuals/types.ts` (+2 -0) ➕ `src/shared/lib/chat-macros.test.ts` (+23 -0) 📝 `src/shared/lib/chat-macros.ts` (+17 -0) </details> ### 📄 Description ## Linked issue Closes #1335 ## Why this change - The refactor macro engine did not expose `{{charSysInfo}}` or `{{charPostHistory}}`, leaving legacy character system and post-history prompt fields unavailable in prompt/display macro expansion. - Nested character-field macros also needed bounded resolution that preserves valid terminal values while still stopping recursive cycles. ## What changed - Added `{{charSysInfo}}` and `{{charPostHistory}}` to the shared macro engine, supported macro list, active-character context, and grouped character expansion. - Plumbed character `systemPrompt` and `postHistoryInstructions` through prompt assembly, shared chat macro helpers, chat surface character maps, runtime visual character maps, and regex script live-test context. - Added regression coverage for direct, nested, grouped, recursive, and lazy character-field macro resolution. ## Refactor impact Primary owner: engine generation / shared macro engine Impact areas reviewed: - Engine prompt assembly character profile context - Shared chat macro context used by mode chat/display surfaces - Runtime visual character map typing - Regex script editor macro live-test sample context - Macro reference/help list through `SUPPORTED_MACROS` Boundary notes: - Engine macro behavior remains React/Tauri-free. - Feature-layer changes only pass existing character fields into macro context. - No raw Tauri, raw HTTP, remote runtime, storage, or Rust capability boundary changes. Pressure points touched: - Shared mode UI character data mapping - Runtime visual character map shape - Regex script live-test macro context ## Validation - [x] `pnpm check` passes locally - [x] `pnpm typecheck` passes locally - [x] `pnpm build` passes locally - [x] `pnpm check:architecture` passes locally - [x] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes Agent-run local checks: - `pnpm vitest run src/engine/shared/macros/macro-engine.test.ts` - `pnpm vitest run src/engine/shared/macros/macro-engine.test.ts src/engine/generation/prompt-assembly.test.ts src/shared/lib/chat-macros.test.ts` - `pnpm typecheck` - `pnpm check:architecture` - `git diff --check` - `pnpm test` - `pnpm lint` - `pnpm build` - `git diff --cached --check` No native Tauri/manual prompt-preview QA was run; this is the remaining end-to-end app verification gap. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims No changelog file exists on this branch, so no changelog update was made. ## UI evidence Not applicable: this does not change visible layout. The only UI-adjacent change updates macro live-test sample context. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added two new character macros: `{{charSysInfo}}` for character system prompts and `{{charPostHistory}}` for character post-history instructions, enabling enhanced character-based prompt customization. * **Tests** * Extended test coverage for the new character instruction macros, validating proper resolution, nested macro expansion, recursion handling, and conditional block support. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1390?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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:12:51 +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#5059
No description provided.