Switch PF2e data source from Pf2eTools to Foundry VTT PF2e
All checks were successful
CI / check (push) Successful in 2m25s
CI / build-image (push) Successful in 23s

Replace the stagnant Pf2eTools bestiary with Foundry VTT PF2e system
data (github.com/foundryvtt/pf2e, v13-dev branch). This gives us 4,355
remaster-era creatures across 49 sources including Monster Core 1+2 and
all adventure paths.

Changes:
- Rewrite index generation script to walk Foundry pack directories
- Rewrite PF2e normalization adapter for Foundry JSON shape (system.*
  fields, items[] for attacks/abilities/spells)
- Add stripFoundryTags utility for Foundry HTML + enrichment syntax
- Implement multi-file source fetching (one request per creature file)
- Add spellcasting section to PF2e stat block (ranked spells + cantrips)
- Add saveConditional and hpDetails to PF2e domain type and stat block
- Add size and rarity to PF2e trait tags
- Filter redundant glossary abilities (healing when in hp.details,
  spell mechanic reminders, allSaves duplicates)
- Add PF2e stat block component tests (22 tests)
- Bump IndexedDB cache version to 5 for clean migration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-04-08 21:05:00 +02:00
parent 0c235112ee
commit 1c107a500b
20 changed files with 1872 additions and 25871 deletions

View File

@@ -8,7 +8,7 @@
## Overview
The Bestiary feature provides creature search across pre-indexed creature libraries: 3,312+ D&D creatures from 102+ sources and ~2,700+ Pathfinder 2e creatures from 79 Pf2eTools sources. The active game system setting (see `specs/003-combatant-state/spec.md`, FR-096) determines which index the search operates against. Stat block display, source management, and creature pre-fill all adapt to the active game system.
The Bestiary feature provides creature search across pre-indexed creature libraries: 3,312+ D&D creatures from 102+ sources and 2,500+ Pathfinder 2e creatures from the Foundry VTT PF2e system (remaster-era content: Monster Core, Monster Core 2, and post-remaster books). The active game system setting (see `specs/003-combatant-state/spec.md`, FR-096) determines which index the search operates against. Stat block display, source management, and creature pre-fill all adapt to the active game system.
The feature also includes full creature reference via stat block display during combat, source data management via on-demand fetch or file upload, and a dual-panel UX with collapse/expand and pin capabilities. Creatures can be added individually or in batch from a search dropdown, with stats pre-filled from the index.
@@ -113,8 +113,8 @@ As a DM using the app on different devices, I want the layout to adapt between s
- **FR-064**: PF2e stat blocks MUST display level in place of challenge rating. Level MUST appear in the stat block header.
- **FR-065**: PF2e stat blocks MUST display three saving throws (Fortitude, Reflex, Will) instead of D&D's six ability-based saves.
- **FR-066**: PF2e stat blocks MUST display ability modifiers directly (e.g., "Str +4") rather than ability scores with derived modifiers.
- **FR-067**: PF2e stat blocks MUST organize abilities into three sections: top (above defenses), mid (reactions and auras), and bot (active abilities), matching the Pf2eTools source structure.
- **FR-068**: PF2e stat blocks MUST strip Pf2eTools markup tags (e.g., `{@damage 1d8+7}`, `{@condition frightened}`) and render them as plain readable text, using the same tag-stripping approach as D&D (FR-019).
- **FR-067**: PF2e stat blocks MUST organize abilities into three sections: top (above defenses), mid (reactions and auras), and bot (active abilities), matching the Foundry VTT PF2e item categorization.
- **FR-068**: PF2e stat blocks MUST strip HTML tags from Foundry VTT ability descriptions and render them as plain readable text. The HTML-to-text conversion serves the same role as the D&D tag-stripping approach (FR-019).
- **FR-062**: Bestiary-linked combatant rows MUST display a small book icon (Lucide `BookOpen`) as the dedicated stat block trigger. The icon MUST have a tooltip ("View stat block") and an `aria-label="View stat block"` for accessibility. The book icon is the only way to manually open a stat block from the tracker — clicking the combatant name always enters inline rename mode. Non-bestiary combatant rows MUST NOT display the book icon.
### Acceptance Scenarios
@@ -176,7 +176,7 @@ A DM wants to see which sources are cached, find a specific source, clear a spec
- **FR-034**: An import button (Lucide Import icon) in the top bar MUST open the stat block side panel with the bulk import prompt.
- **FR-035**: The bulk import prompt MUST show a descriptive text explaining the operation, including approximate data volume (~12.5 MB) and the dynamic number of sources derived from the bestiary index at runtime.
- **FR-036**: The system MUST pre-fill a base URL that the user can edit.
- **FR-037**: The system MUST construct individual fetch URLs by appending the appropriate filename pattern to the base URL: `bestiary-{sourceCode}.json` for D&D sources, `creatures-{sourceCode}.json` for PF2e sources (matching the Pf2eTools naming convention).
- **FR-037**: The system MUST construct individual fetch URLs by appending the appropriate filename pattern to the base URL: `bestiary-{sourceCode}.json` for D&D sources, and the Foundry VTT PF2e per-creature file pattern for PF2e sources.
- **FR-038**: All fetch requests during bulk import MUST fire concurrently (browser handles connection pooling).
- **FR-039**: Already-cached sources MUST be skipped during bulk import.
- **FR-040**: The system MUST show a text counter ("Loading sources... N/T") and progress bar during bulk import.
@@ -189,10 +189,14 @@ A DM wants to see which sources are cached, find a specific source, clear a spec
- **FR-047**: The app MUST provide a management UI showing cached sources with a filter input for searching by display name and options to clear individual sources or all cached data.
- **FR-048**: The normalization adapter and tag-stripping utility MUST remain the canonical pipeline for all fetched and uploaded data.
- **FR-049**: The distributed app bundle MUST contain zero copyrighted prose content — only mechanical facts and creature names in the search index.
- **FR-069**: The system MUST use a separate normalization pipeline for PF2e source data, mapping the Pf2eTools JSON structure to the PF2e creature type. Both pipelines (D&D and PF2e) MUST use the canonical tag-stripping utility.
- **FR-069**: The system MUST use a separate normalization pipeline for PF2e source data, mapping the Foundry VTT PF2e JSON structure (`system.*` fields and `items[]` array) to the PF2e creature type. Both pipelines (D&D and PF2e) MUST use the canonical tag-stripping utility (HTML-to-text for PF2e, markup-to-text for D&D).
- **FR-070**: The source cache MUST be scoped by game system. D&D and PF2e sources MUST NOT collide in IndexedDB (e.g., both may have a source code "B1" but they are different sources).
- **FR-071**: The bulk import prompt MUST adapt to the active game system: showing the correct source count, base URL (Pf2eTools for PF2e, 5etools for D&D), and approximate data volume for the active system.
- **FR-071**: The bulk import prompt MUST adapt to the active game system: showing the correct source count, base URL (Foundry VTT PF2e repo for PF2e, 5etools for D&D), and approximate data volume for the active system.
- **FR-072**: The source management UI MUST show only sources for the active game system.
- **FR-073**: The PF2e index generation script MUST read Foundry VTT PF2e one-file-per-creature JSON from the `packs/pf2e/` directory structure.
- **FR-074**: The PF2e index MUST exclude legacy/pre-remaster creatures based on the `publication.remaster` field — only remaster-era content is included by default.
- **FR-075**: PF2e creature abilities MUST have complete descriptive text in stat blocks. Stubs, generic feat references, and unresolved copy entries are not acceptable.
- **FR-076**: The PF2e index SHOULD carry per-creature license tagging (ORC/OGL) derived from the Foundry VTT source data.
### Acceptance Scenarios
@@ -215,7 +219,7 @@ A DM wants to see which sources are cached, find a specific source, clear a spec
17. **Given** the source management UI is open, **When** the DM clears a single source, **Then** that source's data is removed; stat blocks for its creatures require re-fetching, while other cached sources remain.
18. **Given** the source management UI is open, **When** the DM clears all cached data, **Then** all source data is removed and all stat blocks require re-fetching.
19. **Given** many sources are cached, **When** the DM types a partial name in the filter input, **Then** only sources whose display name matches (case-insensitive) are shown.
20. **Given** the game system is Pathfinder 2e, **When** the user clicks the import button, **Then** the bulk import prompt shows the PF2e source count (~79), a Pf2eTools-based URL, and a PF2e-appropriate data volume estimate.
20. **Given** the game system is Pathfinder 2e, **When** the user clicks the import button, **Then** the bulk import prompt shows the PF2e source count, a Foundry VTT PF2e-based URL, and a PF2e-appropriate data volume estimate.
21. **Given** the game system is Pathfinder 2e and a PF2e source is cached, **When** the user opens a PF2e creature's stat block from that source, **Then** the PF2e stat block renders correctly from cached data.
### Edge Cases
@@ -306,7 +310,7 @@ As a DM with a creature pinned, I want to collapse the right (browse) panel inde
## Success Criteria *(mandatory)*
- **SC-001**: All indexed creatures for the active game system (3,312+ D&D or ~2,700+ PF2e) are searchable immediately on app load, with search results appearing within 100ms of typing.
- **SC-001**: All indexed creatures for the active game system (3,312+ D&D or 2,500+ PF2e) are searchable immediately on app load, with search results appearing within 100ms of typing.
- **SC-002**: Adding a creature from search to the encounter completes without any network request and within 200ms.
- **SC-003**: After a source is cached, stat blocks for any creature from that source display within 200ms with no additional prompt.
- **SC-004**: The distributed app bundle contains zero copyrighted prose content — only mechanical facts and creature names in the search index.
@@ -323,7 +327,7 @@ As a DM with a creature pinned, I want to collapse the right (browse) panel inde
- **SC-015**: Users can pin a creature and browse a different creature's stat block simultaneously, without any additional navigation steps.
- **SC-016**: The pinned panel is never visible on screens narrower than the dual-panel breakpoint, ensuring mobile usability is not degraded.
- **SC-017**: All collapse/expand and pin/unpin interactions are discoverable through visible button controls without requiring documentation or tooltips.
- **SC-018**: All ~2,700+ PF2e indexed creatures are searchable when PF2e is the active game system, with search results appearing within 100ms of typing.
- **SC-018**: All 2,500+ PF2e indexed creatures (remaster-era content from Foundry VTT PF2e) are searchable when PF2e is the active game system, with search results appearing within 100ms of typing.
- **SC-019**: PF2e stat blocks render the correct layout (level, three saves, ability modifiers, ability sections) for all PF2e creatures — no D&D-specific fields (CR, ability scores, legendary actions) are shown.
- **SC-020**: Switching game system immediately changes which creatures appear in search — no page reload required.
- **SC-021**: Both D&D and PF2e search indexes ship bundled with the app; no network fetch is required to search creatures in either system.