Phase 13: grounding context + deterministic pattern detection

- src/lib/assistant/context.ts: buildCampaignContext() assembles a system-aware
  snapshot led by an explicit systemConstraint (anti cross-system hallucination),
  party, recent encounters with computed difficulty, quest/note summaries.
  pickCreatureCandidates() pulls level/CR-appropriate creatures from the correct
  bestiary so LLM tips are grounded in real data.
- src/lib/assistant/patterns.ts: difficultyTendency() + detectThemes() classify
  whether the DM's encounters skew too easy/hard, rating each fight against its
  party-level snapshot.
- Encounter schema gains optional partyLevelsSnapshot + outcome (Dexie v7, additive).
  Combat tracker snapshots PC levels at start and rates difficulty against them.

17 assistant unit tests (context + patterns).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 09:08:14 +02:00
parent 7fd5fcd9af
commit f84e429ca4
8 changed files with 367 additions and 4 deletions
+4
View File
@@ -70,6 +70,10 @@ export class TtrpgDatabase extends Dexie {
// v6 — Phase 9 homebrew content.
this.version(6).stores({ homebrew: 'id, campaignId, [campaignId+kind]' });
// v7 — Phase 13 assistant: encounters gain optional partyLevelsSnapshot +
// outcome. Both optional, so existing rows stay valid; no backfill needed.
this.version(7).stores({});
}
}