Imported from jonasyr/-german-logic-puzzle-generator (
AGENTS.md). Install upstream withnpx skills add jonasyr/-german-logic-puzzle-generator. Copyright stays with the author.
AI Coding Agent Guide
Welcome to the Logic Puzzle Generator repository! This document contains essential instructions and context for AI coding agents operating on this codebase.
1. Core Documentation & Terms of Use
- Primary Source of Truth: Always read
README.mdbefore designing, modifying, or extending features. It documents the complete public API surface, core concepts (Nominal vs. Ordinal categories, clue types, proof chains, red herrings, difficulty estimation), and architectural guidelines. - AI Disclosure & Liability: Refer to the AI Disclosure & Liability Policy in
README.md. Any generated code, algorithms, or modifications must adhere to MIT license requirements and maintain strict solvability and determinism guarantees.
2. Codebase Architecture
The core engine is located under src/:
| File / Directory | Description |
|---|---|
src/types.ts |
Fundamental types: CategoryConfig, CategoryType, ClueType, TargetFact, ProofStep, RedHerringOptions, etc. |
src/engine/Generator.ts |
Core puzzle generator, heuristic scoring, forward search, backtracking, and red herring synthesis. |
src/engine/Solver.ts |
Forward-chaining deduction engine, clue applicators, and contradiction checker. |
src/engine/LogicGrid.ts |
Possibility matrix representation and elimination tracking. |
src/engine/GenerativeSession.ts |
Stateful session manager for interactive, step-by-step puzzle creation and live proof-chain editing. |
src/engine/Clue.ts |
Class hierarchy for all clue variants (Binary, Ordinal, Superlative, Unary, Between, Adjacency, Cross-Ordinal, Disjunction, Arithmetic). |
src/engine/determinism.ts |
Seeded PRNG helpers, engine-agnostic stable sort, and Fisher-Yates shuffle. |
src/index.ts |
Public package export barrel. |
src/germanBooklet.ts |
Configurable German booklet generator (themes, difficulty, seeds, palette) with per-puzzle verification. |
src/german.ts |
German clue formatter driven by a GermanClueLanguage wording object. |
tools/generate_german_pdf.py |
ReportLab renderer for the printable booklet (dynamic grid, dynamic solution table, palette from JSON). |
server/index.ts |
Dependency-free HTTP server: static web app plus /api/options, /api/booklet, /api/pdf. |
webapp/ |
Vanilla HTML/CSS/JS front end (start → settings → preview/PDF → play). |
webapp/playLogic.js |
Pure scoring rules of the interactive grid, shared with the test suite. |
3. Engineering & Quality Standards
- Determinism: The engine is strictly deterministic across platforms (Node, V8, React Native Hermes, browsers). Never use
Math.random()or unseeded sorting. Always use the seeded PRNG (mulberry32) and helpers fromdeterminism.ts. - Backward Compatibility: Any new feature (e.g., Red Herrings) must be opt-in and default to 0 / disabled, ensuring existing API consumers experience zero behavioral regressions.
- Comprehensive Testing:
- Tests live in
test/. - Run
npm testbefore submitting any change. - Every new feature, option, or bugfix must be covered with unit tests, boundary tests, and regression tests.
- Tests live in
- Build & Type Checking:
- Run
npm run buildto verify TypeScript compilation (tsc) and definition emission.
- Run
4. Release & Deployment Workflows
Releases and site deployments are automated via GitHub Actions in .github/workflows/:
-
NPM Package Release (
.github/workflows/npm-publish.yml):- Triggered on push to the
mainbranch. - Inspects
package.json. If theversionfield has been incremented (e.g.,1.3.8->1.4.0), the workflow runs tests, builds the distribution, and automatically publishes the new package version to NPM. - How to release: Bump the
"version"field inpackage.json, commit, and push tomain.
- Triggered on push to the
-
Interactive Demo Site Deployment (
.github/workflows/deploy-site.yml):- Triggered on push to
mainwhen changes touchsrc/**orsite/**. - Automatically builds the web application in
site/and deploys the latest version to GitHub Pages (gh-pagesbranch).
- Triggered on push to