feat(mods): compose shared tech tree insertions

Accept manifest declarations for inserting vehicles into an existing research link. Compose shared links in mod load order after ordinary overlays and write matching shop and economy prerequisites. Validate anchors, rank order, and cycles, and document the manifest field.

Verified type checks, a 2.61.0.64 build with shared, folded, and cross-column insertions, load-order and disable readback, and the local server health endpoint. In-game acceptance remains pending.
This commit is contained in:
N0VAN0M4LY committed 2026-12-05 18:36:50 +08:00
1 parent 0843fde6ff
commit f86ab99c17
11 files changed
+313 -10

No files matched your search

+3 -1
View File
@@ -109,7 +109,8 @@ export function inspectModContent(rootDir: string, manifest: ModManifest): ModCo
: undefined;
const badges = computeRiskBadges({
hasData: serverTuningFiles.length > 0 || packOperations.length > 0 || hasClientAddon || clientFiles.length > 0 || configBlkPatch !== undefined,
hasData: serverTuningFiles.length > 0 || packOperations.length > 0 || hasClientAddon || clientFiles.length > 0
|| configBlkPatch !== undefined || !!manifest.techTreeInsertions?.length,
hasGui: guiPatchDirs.length > 0,
hasScript: serverEntry !== undefined,
hasExe: exePatchDirs.length > 0,
@@ -270,6 +271,7 @@ export function touchedClientPacks(mods: readonly DiscoveredMod[]): ModdableClie
const set = new Set<ModdableClientPack>();
for (const mod of mods) {
for (const op of mod.content.packOperations) set.add(op.pack);
if (mod.manifest.techTreeInsertions?.length) set.add('char.vromfs.bin');
if (mod.content.guiPatchDirs.length > 0) set.add('gui.vromfs.bin');
if (mod.content.hasClientAddon) set.add('aces.vromfs.bin');
}
+1
View File
@@ -22,6 +22,7 @@ export {
type ModPreset,
type ModRiskBadge,
type ModServerConfig,
type ModTechTreeInsertion,
type ModdableClientPack,
type PackFileAction,
type ResolvedModLoadOrder,
+25 -1
View File
@@ -4,7 +4,7 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { parseJsonc } from '@wto/jsonc';
import { MOD_FORMAT_VERSION, type LocalizedText, type ModManifest, type ModServerConfig } from './types.ts';
import { MOD_FORMAT_VERSION, type LocalizedText, type ModManifest, type ModServerConfig, type ModTechTreeInsertion } from './types.ts';
export const MOD_MANIFEST_FILE = 'mod.jsonc';
@@ -22,9 +22,11 @@ const ALLOWED_ROOT_KEYS = new Set([
'conflicts',
'load_after',
'load_before',
'tech_tree_insertions',
'server',
]);
const ALLOWED_SERVER_KEYS = new Set(['entry', 'tuning']);
const TECH_TREE_INSERTION_KEYS = new Set(['vehicle', 'after', 'before']);
export class ModManifestError extends Error {
override name = 'ModManifestError';
@@ -62,6 +64,7 @@ export function parseModManifest(raw: unknown, where = MOD_MANIFEST_FILE): ModMa
const conflicts = optionalIdList(obj.conflicts, `${where} "conflicts"`, id);
const loadAfter = optionalIdList(obj.load_after, `${where} "load_after"`, id);
const loadBefore = optionalIdList(obj.load_before, `${where} "load_before"`, id);
const techTreeInsertions = parseTechTreeInsertions(obj.tech_tree_insertions, `${where} "tech_tree_insertions"`);
const server = obj.server === undefined ? undefined : parseServerConfig(obj.server, `${where} "server"`);
return {
@@ -77,10 +80,31 @@ export function parseModManifest(raw: unknown, where = MOD_MANIFEST_FILE): ModMa
conflicts,
loadAfter,
loadBefore,
...(techTreeInsertions.length > 0 ? { techTreeInsertions } : {}),
...(server !== undefined ? { server } : {}),
};
}
function parseTechTreeInsertions(raw: unknown, where: string): ModTechTreeInsertion[] {
if (raw === undefined) return [];
if (!Array.isArray(raw)) throw new ModManifestError(`${where}: expected an array`);
const seen = new Set<string>();
return raw.map((item, index) => {
const location = `${where}[${index}]`;
const value = expectObject(item, location);
rejectUnknownKeys(value, TECH_TREE_INSERTION_KEYS, location);
const vehicle = expectString(value.vehicle, `${location}.vehicle`);
const after = expectString(value.after, `${location}.after`);
const before = expectString(value.before, `${location}.before`);
if (new Set([vehicle, after, before]).size !== 3) {
throw new ModManifestError(`${location}: vehicle, after, and before must be different vehicles`);
}
if (seen.has(vehicle)) throw new ModManifestError(`${location}: duplicate insertion for "${vehicle}"`);
seen.add(vehicle);
return { vehicle, after, before };
});
}
function parseServerConfig(raw: unknown, where: string): ModServerConfig {
const obj = expectObject(raw, where);
rejectUnknownKeys(obj, ALLOWED_SERVER_KEYS, where);
+7
View File
@@ -33,6 +33,12 @@ export interface ModServerConfig {
readonly tuning?: string;
}
export interface ModTechTreeInsertion {
readonly vehicle: string;
readonly after: string;
readonly before: string;
}
export interface ModManifest {
readonly format: 1;
readonly id: string;
@@ -46,6 +52,7 @@ export interface ModManifest {
readonly conflicts: readonly string[];
readonly loadAfter: readonly string[];
readonly loadBefore: readonly string[];
readonly techTreeInsertions?: readonly ModTechTreeInsertion[];
readonly server?: ModServerConfig;
}