[repo] Workspace: Scaffold Phase 0 with schema, engine, content, ui and the PWA shell
pnpm + turbo workspace with the commands from CLAUDE.md §3. The contracts from §6 as JSON Schemas with generated types; localDay as the one place a day is computed; the forbidden-word list shared by lint:copy and the library validator, with 13 negative fixtures; a Svelte 5 PWA shell built under /Rosea/ with a meta CSP. E2E and offline suites run against the built bundle; the offline one closes the server rather than emulating. Analysis: .agents/features/phase0-workspace.md
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* The one list of words and names that never reach a player (CLAUDE.md §5.6
|
||||
* rules 3 and 4). `lint:copy` and the library validator both read it, so the two
|
||||
* can never disagree.
|
||||
*
|
||||
* Matching is whole-word and case-insensitive, with inflections spelled out.
|
||||
* A stem match (`heal*`) would also catch *health*, and a rose can be healthy.
|
||||
*
|
||||
* `treat` is banned outright, including the fox's food: he eats *berries*.
|
||||
* `patient` is banned too. Patience is the cure Gandalf's spirit offers, so the
|
||||
* product may say *patience* and *patiently* but never *patient*.
|
||||
*/
|
||||
|
||||
export type ForbiddenCategory = 'medical' | 'unnamed-state' | 'little-prince' | 'tolkien';
|
||||
|
||||
export interface ForbiddenTerm {
|
||||
readonly term: string;
|
||||
readonly category: ForbiddenCategory;
|
||||
readonly why: string;
|
||||
}
|
||||
|
||||
const MEDICAL =
|
||||
'A medical claim pulls the product toward EU medical-device rules (CLAUDE.md §5.6 rule 3). Rosea comforts; it does not treat.';
|
||||
const UNNAMED =
|
||||
'The game never names the state for the player (CLAUDE.md §5.6 rule 4). It lets them feel seen instead.';
|
||||
const PRINCE = 'Nothing from The Little Prince by name or quote: one idea is borrowed, never its text (CLAUDE.md §5.6 rule 3).';
|
||||
const TOLKIEN = "Gandalf's spirit, never a name or a quote from Tolkien's works (CLAUDE.md §5.6 rule 3).";
|
||||
|
||||
const terms = (category: ForbiddenCategory, why: string, list: readonly string[]): ForbiddenTerm[] =>
|
||||
list.map((term) => ({ term, category, why }));
|
||||
|
||||
export const FORBIDDEN: readonly ForbiddenTerm[] = [
|
||||
...terms('medical', MEDICAL, [
|
||||
'therapy', 'therapies', 'therapist', 'therapists', 'therapeutic', 'therapeutically',
|
||||
'treat', 'treats', 'treated', 'treating', 'treatment', 'treatments',
|
||||
'heal', 'heals', 'healed', 'healing', 'healer', 'healers',
|
||||
'cure', 'cures', 'cured', 'curing', 'curative',
|
||||
'diagnose', 'diagnoses', 'diagnosed', 'diagnosing', 'diagnosis', 'diagnostic',
|
||||
'symptom', 'symptoms', 'symptomatic',
|
||||
'patient', 'patients',
|
||||
'disorder', 'disorders'
|
||||
]),
|
||||
...terms('unnamed-state', UNNAMED, ['lonely', 'lonelier', 'loneliest', 'loneliness']),
|
||||
...terms('little-prince', PRINCE, [
|
||||
'Little Prince', 'Petit Prince', 'Malý princ', 'Saint-Exupéry', 'Saint-Exupery', 'Exupéry', 'Exupery', 'B-612', 'B612'
|
||||
]),
|
||||
...terms('tolkien', TOLKIEN, [
|
||||
'Tolkien', 'Gandalf', 'Mithrandir', 'Frodo', 'Bilbo', 'Samwise', 'Aragorn', 'Galadriel', 'Sauron',
|
||||
'Mordor', 'Rivendell', 'Middle-earth', 'Middle earth', 'hobbit', 'hobbits', 'Lothlórien', 'Lothlorien'
|
||||
])
|
||||
];
|
||||
|
||||
export interface ForbiddenHit {
|
||||
readonly term: string;
|
||||
readonly category: ForbiddenCategory;
|
||||
readonly why: string;
|
||||
/** Index into the scanned text. */
|
||||
readonly index: number;
|
||||
}
|
||||
|
||||
const escape = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&').replace(/[\s-]+/g, '[\\s\\u00a0-]+');
|
||||
|
||||
// Letters and digits on either side mean it is part of a longer word: *treaty*
|
||||
// does not contain *treat*. Hyphens and apostrophes are boundaries, so
|
||||
// *self-healing* is caught.
|
||||
const PATTERNS = FORBIDDEN.map((entry) => ({
|
||||
entry,
|
||||
regex: new RegExp(`(?<![\\p{L}\\p{N}])${escape(entry.term)}(?![\\p{L}\\p{N}])`, 'giu')
|
||||
}));
|
||||
|
||||
/** Every forbidden term in `text`, in order of appearance. */
|
||||
export function findForbidden(text: string): ForbiddenHit[] {
|
||||
const hits: ForbiddenHit[] = [];
|
||||
for (const { entry, regex } of PATTERNS) {
|
||||
regex.lastIndex = 0;
|
||||
for (let m = regex.exec(text); m !== null; m = regex.exec(text)) {
|
||||
hits.push({ ...entry, index: m.index });
|
||||
}
|
||||
}
|
||||
return hits.sort((a, b) => a.index - b.index);
|
||||
}
|
||||
Reference in New Issue
Block a user