Each per-feature LLM ability is now a self-contained module in server/abilities/ with its own Ability<K> const (schema line, constraint bullet, validator, applier, isMeaningful, stub default, user-payload field). The ordered ABILITIES registry (index.ts) assembles them in the canonical order: takeovers → wars → hybrid → economy → industry → nuclear → leaders → ideology. All function bodies are moved VERBATIM from engine.ts. The engine is untouched in this commit — P4 will rewire it to use the registry.
128 lines
5.0 KiB
TypeScript
128 lines
5.0 KiB
TypeScript
// The ordered LLM-ability registry.
|
|
//
|
|
// `ABILITIES` is the single source of truth for the 8 per-feature LLM abilities.
|
|
// The engine iterates it in this order:
|
|
// takeovers → wars → hybrid → economy → industry → nuclear → leaders → ideology
|
|
// 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 type { Ability, AbilityField } from './types';
|
|
|
|
/**
|
|
* The 8 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.
|
|
*/
|
|
export const ABILITIES: readonly Ability<AbilityField>[] = [
|
|
takeovers,
|
|
wars,
|
|
hybrid,
|
|
economy,
|
|
industry,
|
|
nuclear,
|
|
leaders,
|
|
ideology,
|
|
];
|
|
|
|
// ── 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';
|