Files
scrollsmith/README.md
T
keligrubb a6327fe573
PR / lint (pull_request) Successful in 14s
PR / test-coverage (pull_request) Successful in 31s
Improve LLM client immutability and CI model defaults.
Replace mutable Ollama model export with a const fallback and initializeModel return value, resolving the model from the environment after optional API discovery. Use a for-of loop over attempt indices instead of let in the retry path.

Continue PDF generation when map image generation or upscaling fails, and avoid mutating request headers in place.

Document Open WebUI-style URLs in the README, pin OLLAMA_MODEL in the Gitea release workflow, and adjust integration and unit tests for the new initialization behavior.
2026-04-14 22:42:21 -04:00

3.0 KiB
Raw Blame History

Scrollsmith

status-badge

Scrollsmith is a Node.js tool for generating Dungeons & Dragons one-page dungeon PDFs automatically. It calls an LLM (Open WebUI /api/chat/completions or Ollama /api/generate, inferred from OLLAMA_API_URL), proofreads and refines the result, then builds a structured PDF with maps, rooms, encounters, treasure, and NPCs.


Features

  • Three-pass dungeon generation:
    1. Draft: initial dungeon ideas
    2. Refine: proofread, add flavor, fill in vague details
    3. JSON conversion: output strictly valid JSON for PDF generation
  • Automatically generates a PDF named after the dungeon title
  • PDF layout includes three columns: map & hooks, rooms, encounters & treasure & NPCs
  • Open WebUI or Ollama

Requirements

  • Node.js 22+
  • LLM endpoint (see below)
  • Gitea Releases (optional) for PDF uploads
  • .env file with:
OLLAMA_API_URL=https://your-openwebui-host/api/chat/completions
OLLAMA_API_KEY=your_api_key_here
OLLAMA_MODEL=qwen3.5-122b-a10b
COMFYUI_URL=http://192.168.1.124:8188

Installation

git clone https://github.com/yourusername/scrollsmith.git
cd scrollsmith
npm install

API Configuration

The client automatically infers the API type from the endpoint URL, making it flexible for different deployment scenarios.

Direct Ollama API

For direct Ollama API calls, set:

OLLAMA_API_URL=http://localhost:11434/api/generate

Open WebUI API

For Open WebUI API calls, set:

OLLAMA_API_URL=https://your-openwebui-host/api/chat/completions
OLLAMA_API_KEY=your_open_webui_api_key
OLLAMA_MODEL=qwen3.5-122b-a10b

Note: The API type is inferred from the URL (/api/chat/completions vs /api/generate); no OLLAMA_API_TYPE variable.


Usage

  1. Configure .env and ensure the LLM endpoint is reachable.
  2. Run:
npm start
  1. A PDF will be generated automatically. The filename matches the dungeon title.

Optional: update the map path in index.js if you have a local dungeon map.


Project structure

  • index.js Entry point: env, model init, dungeon + image + PDF.
  • src/ Application modules:
    • dungeonGenerator.js LLM-backed dungeon content generation and validation.
    • dungeonTemplate.js HTML template and layout for the PDF.
    • ollamaClient.js Ollama/Open WebUI API client and text cleaning.
    • imageGenerator.js Map image generation (Ollama + optional ComfyUI).
    • generatePDF.js Puppeteer-based PDF generation from the template.
  • test/ Unit tests (test/unit/) and integration tests (test/integration/).

Example Output

  • the-tomb-of-shadows.pdf

  • Three-column layout:

    • Column 1: Map, Adventure Hooks, Rumors
    • Column 2: Rooms
    • Column 3: Encounters, Treasure, NPCs

Notes

  • Open WebUI needs a valid OLLAMA_API_KEY when the server requires it.
  • Dungeon generation can take a few minutes depending on your LLM response time.

License

PROPRIETARY