Files
History/server/abilities/index.ts
T
kamilkrzywda 283f9e0306
CI / build + unit + e2e (pull_request) Successful in 2m20s
feat: #80 + #81 alliances & space program — 13th & 14th abilities (v0.45.0)
#80: TurnResult.alliances — form/break durable mutual-defense pacts (GameState.alliances; pair relation → ally/neutral, an active war overrides).
#81: TurnResult.space — launch/deorbit satellites (GameState.satellites; +1 stability per active satellite per turn).
Both appended last to the ABILITIES registry (entries 13 & 14, after contested); durable in SQLite via the stateFields loop, mirrored to regionStats, stats re-derived. System + user prompt goldens updated; 738 unit tests passing.
2026-10-17 16:54:28 +00:00

212 lines
7.6 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 { alliances } from './alliances';
import { space } from './space';
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,
alliances,
space,
];
// ── 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';
// ── alliances (mutual-defense treaties) ──────────────────────────────────────
export {
validateAlliancesOps,
applyAlliances,
freshAllianceId,
} from './alliances';
// ── space (satellites) ───────────────────────────────────────────────────────
export {
validateSpaceOps,
applySpaceControl,
applySatelliteBonuses,
SATELLITE_STABILITY_BONUS,
SATELLITE_TYPES,
isSatelliteType,
freshSatelliteId,
} from './space';