Files
History/server/abilities/index.ts
T
kamilkrzywda 5477336537
CI / build + unit + e2e (pull_request) Successful in 2m10s
feat: #66 contested regions / frontlines — 12th ability (v0.44.0)
A third region state (contested frontline): a region in no nation's territory and not in unowned, opened/resolved by the LLM, tied to an active war. Sole-ownership invariant preserved. Durable GameState.contested; contested-inert stub; map legend stays at 7.
2026-10-16 15:21:45 +00:00

188 lines
6.9 KiB
TypeScript

// The ordered LLM-ability registry.
//
// `ABILITIES` is the single source of truth for the 12 per-feature LLM abilities.
// The engine iterates it in this order:
// takeovers → wars → hybrid → economy → industry → nuclear → leaders → ideology → disasters → migration → sea → contested
// for (a) the system-prompt schema lines + constraint bullets, (b) the per-ability
// validate calls inside validateTurnResult, (c) the payload fields in buildUserPrompt,
// (d) the ordered apply block inside applyTurnResult, (e) the isMeaningful check,
// (f) the runTurn unclear-fallback defaults, (g) the stub's deterministic fields, and
// (h) the db.ts state-field migrations.
//
// Each ability file defines its own `Ability<K>` const (the schema line, constraint
// bullet, validator, applier, meaningfulness predicate, stub default, and user-payload
// field). This module assembles them into the ordered `ABILITIES` array and re-exports
// every public name the engine (and its tests) need.
import { takeovers } from './takeovers';
import { wars } from './wars';
import { hybrid } from './hybrid';
import { economy } from './economy';
import { industry } from './industry';
import { nuclear } from './nuclear';
import { leaders } from './leaders';
import { ideology } from './ideology';
import { disasters } from './disasters';
import { migration } from './migration';
import { sea } from './sea';
import { contested } from './contested';
import type { Ability, AbilityField } from './types';
/**
* The 12 per-feature LLM abilities in their canonical apply order.
* The order matters: it determines the order of the schema lines in the
* system prompt, the order of the validate calls, the order of the apply
* steps, and the order of the payload fields in the user prompt. New
* abilities are APPENDED last — never reorder existing entries (their order
* is pinned by the goldens and the stub's byte-identical output).
*/
export const ABILITIES: readonly Ability<AbilityField>[] = [
takeovers,
wars,
hybrid,
economy,
industry,
nuclear,
leaders,
ideology,
disasters,
migration,
sea,
contested,
];
// ── type re-exports ────────────────────────────────────────────────────────────
export type {
Ability,
AbilityCtx,
UserPromptCtx,
AbilityField,
} from './types';
// ── shared helpers ─────────────────────────────────────────────────────────────
export {
resolveNationRef,
resolveRegionKey,
freshNationId,
freshWarId,
NEW_NATION_STATS,
} from './shared';
// ── war helpers ────────────────────────────────────────────────────────────────
export {
activeWarPairs,
atWar,
syncWarRelations,
} from './apply-helpers';
// ── takeovers ──────────────────────────────────────────────────────────────────
export {
validateTakeovers,
applyTakeover,
} from './takeovers';
// ── wars ───────────────────────────────────────────────────────────────────────
export {
validateWarOps,
applyWars,
} from './wars';
// ── hybrid ─────────────────────────────────────────────────────────────────────
export {
validateHybridOps,
isHybridOpType,
HYBRID_STAT_EFFECT,
shiftRelationTowardHostile,
applyHybridOp,
} from './hybrid';
// ── economy ────────────────────────────────────────────────────────────────────
export {
validateEconomyOps,
applyEconomyEffects,
} from './economy';
// ── industry ───────────────────────────────────────────────────────────────────
export {
validateIndustryOps,
isIndustryType,
applyIndustryEffects,
} from './industry';
// ── nuclear ────────────────────────────────────────────────────────────────────
export {
validateNuclearOps,
applyNuclearOps,
} from './nuclear';
// ── leaders ────────────────────────────────────────────────────────────────────
export {
validateLeaderOps,
} from './leaders';
// ── ideology ───────────────────────────────────────────────────────────────────
export {
validateIdeologyOps,
} from './ideology';
// ── disasters ────────────────────────────────────────────────────────────────
export {
validateDisasterEvents,
applyDisasterEvent,
isDisasterType,
isDisasterSeverity,
DISASTER_TYPES,
DISASTER_SEVERITIES,
DISASTER_EFFECTS,
} from './disasters';
// ── migration ────────────────────────────────────────────────────────────────
export {
validateMigrationOps,
applyMigrationOp,
shiftRelationTowardPositive,
isMigrationKind,
isMigrationScale,
MIGRATION_KINDS,
MIGRATION_SCALES,
MIGRATION_SOURCE_EFFECTS,
MIGRATION_DESTINATION_EFFECTS,
LARGE_INFLUX_STABILITY_DIP,
} from './migration';
// ── sea ──────────────────────────────────────────────────────────────────────
export {
validateSeaOps,
applySeaControl,
applySeaZoneBonuses,
SEA_ZONE_BONUS,
SEA_ZONES,
SEA_ZONE_IDS,
isSeaZoneId,
seaZoneName,
} from './sea';
// ── contested (frontlines) ───────────────────────────────────────────────────
export {
validateContestedOps,
applyContested,
CONTESTED_FILL,
CONTESTED_STROKE,
contestedTooltipLabel,
} from './contested';