# Mage Script Package

This package contains the TypeScript source for the `mage` TUI script.

- Source lives in `src/index.ts`
- The build emits `../../mage.js`, which lands in `scripts/mage.js`
- `tsconfig.json` includes the shared `crates/holtburger-scripting/holtburger.d.ts` directly for local typing and editor support
- `npm run lint` checks the package with ESLint
- `npm run format` rewrites the package with Prettier
- `npm run data:build` regenerates `../../mage.data.json` and `../../mage.data.bin`; the JSON comes from a minimal spell export generated by `dat-tool`, and the binary resist table comes from `weenie-resists`
- `npm run build` type-checks first, then bundles directly with esbuild
- `npm run watch` keeps rebuilding on source changes

The script also reads local user preferences from `.config/mage.config.json`. The supported settings are `preferredSpells` and `bannedSpells`, ordered lists of spell IDs or spell key names. Preferred spells are ranked ahead of other valid candidates, and banned spells are removed from the runtime spell database before spell selection runs.

Run `npm install` once inside this directory, then use `npm run build`.
