feat: one-click NPC/creature backstory + stat block flesh-out (#130) #197
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/130-npc-fleshout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #130. Adds two one-click GM actions on
npc/creaturewiki entries, reusing the existing LLM draft-review rail. Follows the GM-locked 2026-07-15 decisions.Backend (
c23fb42)LoreEntryDraftgains an explicitmodeenum (rephrase|merge|expand_backstory|generate_statblock, defaultrephrase— existing flows untouched) + acurrent_sidebar_fieldsJSONB staging column. Migratione8f9a0b1c2d3(round-trips).audio_service): backstory is append-only (returns the full body with existing prose verbatim + a delineated## Backstorysection); stat block runs in JSON mode →{markdown, sidebar_fields}and is generated from the current backstory for coherence.run_lore_entry_draft_generationbranches onmode; stat-block stages markdown ontocurrent_bodyand structured rows ontocurrent_sidebar_fields, each defaulted tovisibility="gm"(hidden from players).modediscriminator, gated to npc/creature (400 otherwise; unknown mode 422). Approve appends staged rows onto the entry'ssidebar_fields(never dropping existing) and snapshots aLoreEntryVersion.current_sidebar_fields— so the GM can edit values and flip each row's player-visibility in review before approving (re-normalised, visibility clamped/defaulted togm). (This closed a gap in the first pass — without it the review UI couldn't persist the required per-row toggle.)Frontend (
<head>)WikiArticle: "Generate backstory" / "Generate stat block" header actions, gated on GM + npc/creature + no existing draft; a mode-aware start modal (optional level/role/tone cue); navigates to review. One-draft-at-a-time + type errors surfaced inline.WikiDraftReview: a prominent "Proposed stat block" section — per-row label/value + a visibility select defaulting to GM-only, with a "hidden from players by default" note. Edits persist via the existing debounced autosave PATCH and flush before approve/iterate. Non-stat-block drafts render exactly as before.Tests
test_npc_fleshout.py) — the npc/creature gate, mode defaulting (rephrase/merge unchanged), worker staging (gm rows + append-only body), approve merge + version snapshot, failure paths, and the PATCH visibility-toggle. Full suite 516 pass; migration round-trip verified.Notes
bot/changes → noBOT_CONTRACT_VERSIONconcern. Stat-schema-aware / game-aware generation remains out of scope (free-textgame_systemonly), per the issue.🤖 Generated with Claude Code
Two GM actions on npc/creature wiki entries, reusing the existing LLM draft-review rail (generating→ready→failed, review/iterate/approve→version snapshot): - LoreEntryDraft gains an explicit `mode` enum (rephrase|merge| expand_backstory|generate_statblock; default rephrase so existing flows are unchanged) and a `current_sidebar_fields` JSONB staging column; migration e8f9a0b1c2d3 (round-trips). - audio_service: expand_lore_entry_backstory (append-only — returns full body with existing prose verbatim + a delineated ## Backstory section) and generate_lore_entry_statblock (json_mode → {markdown, sidebar_fields}, generated FROM the current backstory for coherence). - run_lore_entry_draft_generation branches on mode; statblock stages markdown onto current_body and structured rows onto current_sidebar_fields, each defaulted to visibility="gm" (hidden from players). - POST drafts gains a `mode` discriminator, gated to npc/creature (400 otherwise; unknown mode 422). approve appends staged rows onto the entry's sidebar_fields (never dropping existing) and snapshots a version. - PATCH drafts now accepts current_sidebar_fields so the GM can edit values and flip each row's player-visibility in review before approving (re-normalised, visibility clamped/defaulted to gm). Tests: +14 (test_npc_fleshout.py) — gate, mode defaulting, worker staging (gm rows + append-only body), approve merge + version snapshot, failure paths, and the PATCH visibility-toggle. Full suite 515 pass (pre-PATCH); migration round-trip verified. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>