Skip to content

API and Development

Roi Horowitz edited this page Aug 24, 2026 · 1 revision

API and Development

Module API

Commanderer's public API is available after Foundry's ready hook:

const commander = game.actors.get("ACTOR_ID");
const api = game.modules.get("pf2e-commanderer").api;

api.open(commander);
api.execute(commander.items.get("TACTIC_ITEM_ID"), commander);

api.open(actor)

Opens or focuses the Commander panel for the supplied actor. Caller should provide a PF2e Commander actor the current user may observe and control.

api.execute(tactic, actor)

Starts the normal tactic-issuing workflow for an embedded tactic item. Normal ownership, preparation, frequency, banner, audience, and readiness checks still apply.

Local setup

npm ci

Module uses native JavaScript ES modules. Foundry loads scripts/main.js from module.json.

Validation

npm run check
npm run lint
npm test

npm run prepublishOnly runs syntax checks, full test suite, and ESLint together.

Husky hooks run:

  • ESLint before commits;
  • full test suite before pushes.

Architecture

Area Responsibility
scripts/domain Pure tactic, movement, readiness, banner-placement, and selection rules
scripts/foundry PF2e documents, actions, effects, dialogs, sockets, banner state, and movement integration
scripts/canvas Banner marker, burst, and movement guidance rendering
scripts/ui Commander panel, Token HUD, tactic and invocation view models
scripts/engine.js Tactic issue, chat order, response, and aftermath orchestration
templates Foundry ApplicationV2 and chat-card markup
styles Module panel, dialog, HUD, canvas, and chat presentation
tests Node tests for domain behavior and Foundry integration contracts

Release workflow

GitHub Actions runs on pushes, pull requests, and releases:

  1. install dependencies;
  2. validate manifest metadata;
  3. check JavaScript syntax;
  4. run ESLint;
  5. run tests;
  6. stamp release manifest URLs;
  7. build module.zip;
  8. attach module.json and module.zip to the GitHub release;
  9. publish stable versions to Foundry when FVTT_API_TOKEN is configured.

Release tag must exactly match module.json version.

Reporting problems

Open a GitHub issue with:

  • Foundry and PF2e versions;
  • Commanderer version;
  • tactic and banner state;
  • which user owned each involved actor;
  • console error and reproduction steps;
  • screenshot when UI or canvas state matters.

Clone this wiki locally