Files
scrollsmith/README.md
T
keligrubb 7ea9f93dc8
Release / generate-dungeon (push) Failing after 2m30s
Release / upload-to-gitea-release (push) Has been skipped
Improve LLM client immutability and CI model defaults. (#9)
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.

Reviewed-on: #9
Co-authored-by: keligrubb <keligrubb324@gmail.com>
Co-committed-by: keligrubb <keligrubb324@gmail.com>
2026-04-15 02:45:25 +00:00

117 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Scrollsmith
[![status-badge](https://ci.keligrubb.com/api/badges/2/status.svg)](https://ci.keligrubb.com/repos/2)
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:
```env
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
```bash
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:
```env
OLLAMA_API_URL=http://localhost:11434/api/generate
```
### Open WebUI API
For Open WebUI API calls, set:
```env
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:
```bash
npm start
```
3. 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