AI-Text (ghost-text, correct, translate, rewrite)
Server side behind the AiTextField/AiTextArea widgets
(kumiko-framework/renderer-web). Mounts the real ai-text feature — no
extra business logic here, the feature already is the complete API surface
the widgets call.
What it shows
Section titled “What it shows”- One handler, four modes —
ai-text:query:runtakes a discriminated union payload (complete|correct|translate|rewrite); the widget picks the mode, the server picks the prompt. - Mounting the real feature — this recipe requires
ai-textand an LLM provider plugin forai-foundation(a mock in the integration test, a real provider — Anthropic, OpenAI-compatible — in production). - Cap + audit come for free —
ai-textenforces a per-tenant monthly request cap and writes a user-attributed audit row per call; nothing extra to wire up in a consuming app.
Wiring
Section titled “Wiring”ai-text requires ai-foundation (provider host) and cap-counter. Mount
an LLM provider plugin (ai-provider-anthropic, ai-provider-openai-compat,
or a mock in tests) alongside. The integration test under src/__tests__/
boots that exact stack against real Postgres + Redis and scripts the
provider — full exhaustive coverage (cap-exceeded, refusal, audit
attribution) lives in packages/ai-text/src/__tests__/; this recipe just
proves the sample composition mounts and runs.
bun --env-file=../.env test --config=bunfig.integration.toml samples/recipes/ai-textSource code
Section titled “Source code”The feature entry point — embedded straight from the source file, so the code here is exactly what runs. Multi-file samples keep their remaining files next to it on GitHub (link below):
// AI-Text Sample// Shows how an app mounts the real `ai-text` feature (kumiko-enterprise/// packages/ai-text) — the server side behind the AiTextField/AiTextArea// widgets (kumiko-framework/renderer-web). No extra business logic here:// `ai-text` already is the complete API surface the widgets call// (`ai-text:query:run`, discriminated on mode: complete/correct/translate/// rewrite). An app just requires it alongside a provider plugin for// ai-foundation (see the integration test for the mock-provider wiring).
import { aiTextFeature } from "@cosmicdriftgamestudio/kumiko-ai-text";
export { aiTextFeature };Enterprise recipe — samples/recipes/ai-text/src/feature.ts in the private kumiko-enterprise workspace.