Skip to content

Remove Anuva Prompts Implementation Plan

Created: 2026-05-19 04:37 UTC

Goal

Remove all runtime and schema dependency on anuva_prompts. Presentation creation, presentation edits, generated image fallback logic, and adjacent RAG refinement actions must use Mastra workflows, agents, tools, or code-native inline prompt builders instead of Payload prompt records.

Non-Goals

  • Do not rebuild the full Presentation Video workflow beyond the prompt-removal work.
  • Do not preserve admin-configurable prompt editing for Presentation Video.
  • Do not migrate historical anuva_prompts content into a new prompt product.
  • Do not change billing, coin conversion, provider pricing, or render semantics except where needed to preserve existing metering metadata.
  • Do not remove stale docs under docs/_stale.

Current Behavior

  • src/app/(frontend)/app/presentation/actions.ts still imports formatRagContext, renderPromptTemplate, resolvePrompt, and resolveVideoUseCaseId from src/lib/anuvax-prompts.
  • generatePresentationVideoScenesWithWorkflow already calls Mastra presentationVideoWorkflow, but generatePresentationDescription, older voiceover/config paths, and per-scene voiceover/caption/image assistants still resolve prompt documents.
  • src/app/(frontend)/app/rag/actions.ts resolves ragImageUserContextEdit and ragVideoSectionEdit prompts from anuva_prompts.
  • scripts/presentation-worker.ts falls back to anuva_prompts for generated scene image prompts.
  • scripts/seed.ts seeds prompt records, src/collections/anuvax/index.ts registers AnuvaPrompts, generated types expose anuva_prompts, and migrations include the table/enums.

Target Behavior

  • Presentation creation has one canonical route through Mastra presentationVideoWorkflow; deprecated action exports may remain only as wrappers or compatibility helpers with no anuva_prompts dependency.
  • Per-scene voiceover, caption, and image assistant actions call Mastra editAgent, visualAgent, workflow steps, tools, or code-native prompt builders while preserving return shapes, stale preview markers, dirty compiler state, and metering.
  • RAG image/video refinement actions use RAG-specific code-native prompt builders or Mastra tools and preserve user_facing_description, asset_query, t0, and t1 behavior.
  • The presentation worker uses scene/job visualGenerationPrompt first and a code-native generated-image fallback if needed.
  • The anuva_prompts collection, seed data, generated types, and database table/enums are removed.
flowchart TD
  ui["Presentation UI"] --> action["Server actions"]
  action --> workflow["presentationVideoWorkflow"]
  action --> edit["editAgent / visualAgent helpers"]
  ragUi["RAG Library actions"] --> ragPrompts["RAG code prompt builders"]
  worker["presentation-worker"] --> imagePrompt["scene/job prompt or code fallback"]
  workflow --> payload["Presentation scenes, compilations, jobs"]
  legacy["anuva_prompts + src/lib/anuvax-prompts"]:::removed -. removed .-> action
  legacy -. removed .-> ragUi
  legacy -. removed .-> worker
  classDef removed fill:#f7d7d7,stroke:#a33,color:#111

Affected Files And Modules

  • Presentation actions: src/app/(frontend)/app/presentation/actions.ts.
  • RAG actions: src/app/(frontend)/app/rag/actions.ts.
  • Mastra prompt ownership: src/mastra/agents/*, src/mastra/workflows/presentationvideo.workflow.ts, src/mastra/workflows/sub/*, src/mastra/tools/presentation, src/mastra/tools/rag, src/mastra/tools/media.
  • Legacy helper removal: src/lib/anuvax-prompts/render.ts, src/lib/anuvax-prompts/resolve.ts.
  • Payload schema/data: src/collections/anuvax/index.ts, src/payload-types.ts, src/migrations/index.ts, new drop migration, scripts/seed.ts.
  • Worker/tests: scripts/presentation-worker.ts, tests/integration/helpers/presentation-harness.ts, tests/integration/helpers/mock-runtime.ts, targeted presentation/RAG tests.

Affected Docs

  • Update docs/core/PresentationVideoWorkflow.md, docs/core/MastraAgentsAndTools.md, docs/core/PayloadDataModel.md.
  • Update docs/state/CollectionMap.md, docs/state/ServerActionsMap.md, docs/state/WorkflowMap.md, and docs/state/KnownGaps.md where they mention prompt-backed behavior.
  • Keep docs/web/mkdocs.yml nav unchanged unless doc paths change; the change folder already has an Implementation Plan entry.
  • Add or revise Mermaid diagrams in changed core/state docs when flows or relationships change.

Data And Schema Impact

  • Remove AnuvaPrompts from AnuvaxCollections.
  • Regenerate src/payload-types.ts and Payload import map after schema changes.
  • Add migration 20260519_000001_drop_anuva_prompts or generated equivalent that drops anuva_prompts, related lock-document relation column/index/FK, and enum_anuva_prompts_* types.
  • Remove prompt seeding from scripts/seed.ts; no compatibility migration for prompt contents is required.
  • Verify no remaining relationTo: 'anuva_prompts', type references, or collection lookups remain outside historical migrations.

Ordered Tasks

  • [x] 1. Confirm current usage with rg for anuva_prompts, AnuvaPrompts, anuvax-prompts, resolvePrompt, renderPromptTemplate, formatRagContext, and resolveVideoUseCaseId.
  • [x] 2. Verify Mastra APIs and model/provider constants using local Mastra docs and node .agents/skills/mastra/scripts/provider-registry.mjs --provider openai before editing agents or workflow calls.
  • [x] 3. Add code-native prompt builders near the owning domain: presentation/edit/image builders under Mastra presentation/media tooling, RAG refinement builders under Mastra RAG tooling or local RAG action helpers.
  • [x] 4. Update presentation actions so creation uses generatePresentationVideoScenesWithWorkflow / presentationVideoWorkflow; deprecated exports keep stable return shapes but do not read prompt documents.
  • [x] 5. Move per-scene voiceover, caption, and image regeneration to editAgent/visualAgent or equivalent Mastra-backed helpers while preserving dirty state, stale preview updates, media writes, and AI interaction metadata.
  • [x] 6. Update RAG refinement actions to use inline prompt builders and existing JSON parsing/normalization.
  • [x] 7. Update scripts/presentation-worker.ts to remove prompt lookup fallback and use scene/job prompts or a code-native generated-image fallback.
  • [x] 8. Remove src/lib/anuvax-prompts, delete prompt seed data, remove AnuvaPrompts collection registration, regenerate Payload types/import map, and create the drop migration.
  • [x] 9. Update integration mocks and tests so they no longer mock legacy prompt helpers; add coverage for no prompt lookup on presentation, edit, worker, and RAG paths.
  • [x] 10. Update core/state docs and confirm docs parity checklist.

Verification Plan

  • Run pnpm lint.
  • Run pnpm typecheck.
  • Run pnpm test:int.
  • Run pnpm test:e2e because route-level presentation creation behavior is affected.
  • Run pnpm generate:types and pnpm generate:importmap after Payload schema changes.
  • Search again for active references: rg -n "anuva_prompts|AnuvaPrompts|anuvax-prompts|resolvePrompt|renderPromptTemplate" src scripts tests docs --glob '!docs/_stale/**'.
  • Inspect the generated migration to ensure it drops the prompt table, lock relation artifacts, and enum types without affecting unrelated collections.

Docs Parity Checklist

  • [x] Presentation workflow docs describe Mastra workflow and code-owned prompt builders as the source of generation behavior.
  • [x] Mastra docs list any new helpers, tools, workflow steps, or agent responsibilities.
  • [x] Payload data model and collection map no longer list anuva_prompts.
  • [x] Server actions map no longer describes prompt-backed presentation or RAG refinements.
  • [x] Workflow map reflects per-scene edit/image regeneration ownership if new Mastra paths are added.
  • [x] Known gaps is updated to remove or narrow the prompt-registry gap.

Acceptance Criteria

  • No active runtime code outside historical migrations references anuva_prompts or src/lib/anuvax-prompts.
  • Presentation creation from the UI routes through presentationVideoWorkflow and still returns the expected compile/generation result.
  • Per-scene voiceover, caption, and image actions work without Payload prompt records and preserve existing UI-facing return shapes.
  • RAG image/video refinement works without Payload prompt records and preserves normalized JSON output behavior.
  • Payload admin no longer exposes anuva_prompts; generated types no longer include AnuvaPrompt or anuva_prompts.
  • Seed, worker, tests, and docs are consistent with code-owned prompts.
  • Required verification commands pass, or any failures are documented with clear cause and follow-up.