49c8def037
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
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
/**
|
|
* The core of `pnpm lint:copy` (CLAUDE.md §5.6, §7): what a player could read in
|
|
* a file, and what is wrong with it. The script walks files; this decides.
|
|
*/
|
|
import { findForbidden } from './forbidden.js';
|
|
|
|
export interface CopyProblem {
|
|
readonly line: number;
|
|
readonly message: string;
|
|
}
|
|
|
|
/**
|
|
* Removes comments, keeping line numbers. Comments are where the rules are
|
|
* explained, and a rule must be nameable in the file that enforces it.
|
|
* `//` after a `:` is a URL, not a comment.
|
|
*/
|
|
export function stripComments(source: string): string {
|
|
const blank = (m: string): string => m.replace(/[^\n]/g, ' ');
|
|
return source
|
|
.replace(/<!--[\s\S]*?-->/g, blank)
|
|
.replace(/\/\*[\s\S]*?\*\//g, blank)
|
|
.replace(/(?<![:\\])\/\/[^\n]*/g, blank);
|
|
}
|
|
|
|
// *Domi* is the ecosystem's word and never stands alone (CLAUDE.md preamble).
|
|
const DOMI_ALONE = /(?<!(?:Rosea|Panda|Amicitia)[\s\u00a0])\bDomi\b/g;
|
|
|
|
/** Problems in one file's player-visible text. */
|
|
export function lintCopy(source: string): CopyProblem[] {
|
|
const text = stripComments(source);
|
|
const lineOf = (index: number): number => text.slice(0, index).split('\n').length;
|
|
const problems: CopyProblem[] = [];
|
|
|
|
for (const hit of findForbidden(text)) {
|
|
problems.push({ line: lineOf(hit.index), message: `'${hit.term}' (${hit.category}): ${hit.why}` });
|
|
}
|
|
|
|
for (const m of text.matchAll(DOMI_ALONE)) {
|
|
problems.push({
|
|
line: lineOf(m.index),
|
|
message: "'Domi' on its own: the product is always Rosea Domi, and Domi never appears alone"
|
|
});
|
|
}
|
|
|
|
return problems.sort((a, b) => a.line - b.line);
|
|
}
|