hoi4-agent-tools 4.20.3 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +2 -0
- package/dist/bin/setup.js +1 -0
- package/dist/bin/stdio.js +1 -0
- package/dist/hoi4_agent_tools/characters/write-operations.js +2 -2
- package/dist/hoi4_agent_tools/characters/write-plan.js +21 -205
- package/dist/hoi4_agent_tools/common-write/documented-lists.js +62 -0
- package/dist/hoi4_agent_tools/common-write/limits.js +35 -0
- package/dist/hoi4_agent_tools/common-write/paths.js +17 -0
- package/dist/hoi4_agent_tools/common-write/write-job-operations.js +42 -0
- package/dist/hoi4_agent_tools/common-write/write-operations.js +360 -0
- package/dist/hoi4_agent_tools/common-write/write-plan.js +34 -0
- package/dist/hoi4_agent_tools/core/artifacts-engine.js +272 -0
- package/dist/hoi4_agent_tools/core/configuration.js +6 -0
- package/dist/hoi4_agent_tools/core/domain-tools.js +8 -0
- package/dist/hoi4_agent_tools/core/engine.js +67 -21
- package/dist/hoi4_agent_tools/core/idle-cache-lifetime.js +7 -0
- package/dist/hoi4_agent_tools/core/job-controls.js +12 -2
- package/dist/hoi4_agent_tools/core/job-executor.js +8 -7
- package/dist/hoi4_agent_tools/core/job-operation-registration.js +4 -0
- package/dist/hoi4_agent_tools/core/job-store.js +97 -5
- package/dist/hoi4_agent_tools/core/job-worker-host.js +2 -2
- package/dist/hoi4_agent_tools/core/operation-result.js +118 -33
- package/dist/hoi4_agent_tools/core/operation-tasks.js +4 -2
- package/dist/hoi4_agent_tools/core/transactions.js +6 -0
- package/dist/hoi4_agent_tools/core/workspace.js +25 -2
- package/dist/hoi4_agent_tools/country/job-operations.js +42 -0
- package/dist/hoi4_agent_tools/country/write-operations.js +646 -0
- package/dist/hoi4_agent_tools/country/write-plan.js +28 -0
- package/dist/hoi4_agent_tools/decision/write-operations.js +7 -8
- package/dist/hoi4_agent_tools/decision/write-plan.js +25 -245
- package/dist/hoi4_agent_tools/doctrine/write-operations.js +2 -2
- package/dist/hoi4_agent_tools/doctrine/write-plan.js +21 -180
- package/dist/hoi4_agent_tools/event/graph.js +3 -3
- package/dist/hoi4_agent_tools/event/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/event/write-job-operations.js +2 -2
- package/dist/hoi4_agent_tools/event/write-operations.js +9 -10
- package/dist/hoi4_agent_tools/event/write-plan.js +28 -278
- package/dist/hoi4_agent_tools/focus/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/gui/assets.js +3 -13
- package/dist/hoi4_agent_tools/gui/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/gui/layout.js +2 -4
- package/dist/hoi4_agent_tools/gui/renderer.js +2 -1
- package/dist/hoi4_agent_tools/gui/source-graph.js +16 -0
- package/dist/hoi4_agent_tools/gui/studio.js +31 -0
- package/dist/hoi4_agent_tools/ideas/write-operations.js +7 -8
- package/dist/hoi4_agent_tools/ideas/write-plan.js +24 -304
- package/dist/hoi4_agent_tools/map/engine-validation.js +230 -0
- package/dist/hoi4_agent_tools/map/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/map/landmass-source.js +42 -0
- package/dist/hoi4_agent_tools/map/landmass.js +190 -0
- package/dist/hoi4_agent_tools/map/model.js +17 -3
- package/dist/hoi4_agent_tools/map/operations.js +20 -6
- package/dist/hoi4_agent_tools/map/references.js +6 -3
- package/dist/hoi4_agent_tools/map/service.js +88 -8
- package/dist/hoi4_agent_tools/map/validation.js +12 -18
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +1 -1
- package/dist/hoi4_agent_tools/mcp/server/create.js +4 -0
- package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +4 -0
- package/dist/hoi4_agent_tools/mcp/tools/common-write.js +21 -0
- package/dist/hoi4_agent_tools/mcp/tools/country-write.js +21 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js +1 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.js +2 -0
- package/dist/hoi4_agent_tools/mcp/transports/negotiated-stdio.js +24 -16
- package/dist/hoi4_agent_tools/probability/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/runtime.js +83 -3
- package/dist/hoi4_agent_tools/schemas/character-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/common-write.js +74 -0
- package/dist/hoi4_agent_tools/schemas/country-write.js +206 -0
- package/dist/hoi4_agent_tools/schemas/decision-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/doctrine-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/event-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/idea-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/landmass.js +129 -0
- package/dist/hoi4_agent_tools/schemas/localisation-write.js +10 -1
- package/dist/hoi4_agent_tools/schemas/map-requests.js +1 -1
- package/dist/hoi4_agent_tools/schemas/map.js +2 -0
- package/dist/hoi4_agent_tools/schemas/tech-write.js +5 -1
- package/dist/hoi4_agent_tools/script-write/engine-plan.js +45 -0
- package/dist/hoi4_agent_tools/technology/engine-graph.js +156 -0
- package/dist/hoi4_agent_tools/technology/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/technology/operations.js +1 -2
- package/dist/hoi4_agent_tools/technology/service.js +30 -59
- package/dist/hoi4_agent_tools/technology/write-job-operations.js +2 -2
- package/dist/hoi4_agent_tools/technology/write-operations.js +2 -2
- package/dist/hoi4_agent_tools/technology/write-plan.js +21 -207
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +11 -10
- package/docs/jobs.md +2 -2
- package/docs/setup.md +1 -0
- package/docs/tools.md +16 -2
- package/docs/troubleshooting.md +11 -11
- package/engine/bin/darwin-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-x64/hoi4-engine +0 -0
- package/engine/bin/manifest.json +8 -8
- package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
- package/npm-shrinkwrap.json +43 -19
- package/package.json +2 -2
- package/schemas/configuration.schema.json +143 -134
- package/schemas/continuous-focus-palette.schema.json +1 -1
- package/schemas/custom-weighted-pool.schema.json +1 -1
- package/schemas/decision-inspect-input.schema.json +1 -1
- package/schemas/error-log-input.schema.json +1 -1
- package/schemas/event-feature-manifest.schema.json +1 -1
- package/schemas/focus-plan.schema.json +1 -1
- package/schemas/focus-planning-sidecar.schema.json +1 -1
- package/schemas/geography-model.schema.json +1 -1
- package/schemas/gui-animation-source.schema.json +1 -1
- package/schemas/gui-helper.schema.json +1 -1
- package/schemas/gui-scenario.schema.json +1 -1
- package/schemas/helper-expansion-request.schema.json +1 -1
- package/schemas/helper-expansion-summary.schema.json +1 -1
- package/schemas/impact-inspect-input.schema.json +1 -1
- package/schemas/map-operation.schema.json +354 -1
- package/schemas/mechanic-test-input.schema.json +1 -1
- package/schemas/mod-index-input.schema.json +1 -1
- package/schemas/operation-result.schema.json +1 -1
- package/schemas/package-check-input.schema.json +1 -1
- package/schemas/package-manifest.schema.json +1 -1
- package/schemas/probability-analysis-result.schema.json +1 -1
- package/schemas/probability-compare-input.schema.json +1 -1
- package/schemas/probability-evaluate-input.schema.json +1 -1
- package/schemas/probability-inspect-input.schema.json +1 -1
- package/schemas/probability-render-input.schema.json +1 -1
- package/schemas/probability-scenario-set.schema.json +1 -1
- package/schemas/probability-sequence-input.schema.json +1 -1
- package/schemas/probability-simulate-input.schema.json +1 -1
- package/schemas/probability-sweep-input.schema.json +1 -1
- package/schemas/reference-context-input.schema.json +1 -1
- package/schemas/reference-read-input.schema.json +1 -1
- package/schemas/reference-search-input.schema.json +1 -1
- package/schemas/reference-sheets.schema.json +1 -1
- package/schemas/scenario-suite.schema.json +1 -1
- package/schemas/scenario-test-input.schema.json +1 -1
- package/schemas/script-validate-input.schema.json +1 -1
- package/schemas/shared-scenario.schema.json +1 -1
- package/schemas/source-lookup-input.schema.json +1 -1
- package/server.json +2 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { analysisTaskTools } from '../tools/analysis.js';
|
|
2
2
|
import { characterWriteTaskTools } from '../tools/character-write.js';
|
|
3
|
+
import { commonWriteTaskTools } from '../tools/common-write.js';
|
|
4
|
+
import { countryWriteTaskTools } from '../tools/country-write.js';
|
|
3
5
|
import { decisionWriteTaskTools } from '../tools/decision-write.js';
|
|
4
6
|
import { doctrineWriteTaskTools } from '../tools/doctrine-write.js';
|
|
5
7
|
import { techWriteTaskTools } from '../tools/tech-write.js';
|
|
@@ -19,10 +21,12 @@ export const taskToolCatalog = [
|
|
|
19
21
|
...localisationTaskTools,
|
|
20
22
|
...ideaWriteTaskTools,
|
|
21
23
|
...characterWriteTaskTools,
|
|
24
|
+
...countryWriteTaskTools,
|
|
22
25
|
...eventWriteTaskTools,
|
|
23
26
|
...decisionWriteTaskTools,
|
|
24
27
|
...techWriteTaskTools,
|
|
25
28
|
...doctrineWriteTaskTools,
|
|
29
|
+
...commonWriteTaskTools,
|
|
26
30
|
...eventTaskTools,
|
|
27
31
|
...analysisTaskTools,
|
|
28
32
|
...technologyTaskTools,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { strictOperationResultSchema } from '../server/result.js';
|
|
2
|
+
import { commonWriteDataSchema, commonWriteRequestSchema } from '../../schemas/common-write.js';
|
|
3
|
+
import { registerLegacyTaskTools } from '../server/legacy-task-tools.js';
|
|
4
|
+
export const commonWriteTaskTools = [
|
|
5
|
+
{
|
|
6
|
+
name: 'hoi4.common_write',
|
|
7
|
+
title: 'Add, replace or remove a balance of power, AI strategy, AI strategy plan or on_action',
|
|
8
|
+
description: 'Add, replace or remove one definition in a mod common file, touching only that block: kind bop, ai_strategy, ai_strategy_plan or on_action. body is raw script, the text between the braces; it must parse and is written as given. on_action add appends to the key; blockIndex picks one child block. apply false returns the diff. A bop whose ranges do not cover -1 to 1 once is refused. Example: {"kind":"ai_strategy","operation":"remove","id":"my_strategy"}',
|
|
9
|
+
inputSchema: commonWriteRequestSchema,
|
|
10
|
+
outputSchema: strictOperationResultSchema(commonWriteDataSchema),
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
destructiveHint: true,
|
|
14
|
+
idempotentHint: false,
|
|
15
|
+
openWorldHint: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
export function registerCommonWriteTools(server, _engine, _context) {
|
|
20
|
+
registerLegacyTaskTools(server, commonWriteTaskTools);
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { strictOperationResultSchema } from '../server/result.js';
|
|
2
|
+
import { countryWriteDataSchema, countryWriteRequestSchema } from '../../schemas/country-write.js';
|
|
3
|
+
import { registerLegacyTaskTools } from '../server/legacy-task-tools.js';
|
|
4
|
+
export const countryWriteTaskTools = [
|
|
5
|
+
{
|
|
6
|
+
name: 'hoi4.country_write',
|
|
7
|
+
title: 'Add, update or remove a country',
|
|
8
|
+
description: 'Add, update or remove one mod country in one write: tag line, country file, colors.txt, history, localisation names and an optional bookmark entry. add needs name, graphicalCulture, color and history; update changes only what is given; remove refuses while mod files name the tag. Warns about missing flags or text. apply false returns diffs. Example: {"operation":"update","tag":"ABC","history":{"capital":5,"stability":0.6},"apply":false}',
|
|
9
|
+
inputSchema: countryWriteRequestSchema,
|
|
10
|
+
outputSchema: strictOperationResultSchema(countryWriteDataSchema),
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
destructiveHint: true,
|
|
14
|
+
idempotentHint: false,
|
|
15
|
+
openWorldHint: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
export function registerCountryWriteTools(server, _engine, _context) {
|
|
20
|
+
registerLegacyTaskTools(server, countryWriteTaskTools);
|
|
21
|
+
}
|
|
@@ -270,7 +270,7 @@ export const mapTaskTools = [
|
|
|
270
270
|
{
|
|
271
271
|
name: 'hoi4.map_rewrite',
|
|
272
272
|
title: 'Build a world or edit the map',
|
|
273
|
-
description: 'Build a world from a reference image or
|
|
273
|
+
description: 'Build a world from a reference image or geography model (geography, geographyPath), add an island to the map (add_landmass), or edit provinces, states, regions and supply. Example: {"preview":true,"operations":[{"kind":"create_world","reference":{"imagePath":"references/world.png"}}]}. Preview first to check coastlines, terrain, countries or a model overlay and report; omit preview to write the map and start scenario (biome or climate models are blocked for now). Returns counts, diagnostics, linked PNGs.',
|
|
274
274
|
inputSchema: mapRewriteRequestSchema,
|
|
275
275
|
outputSchema: mapPlanOutputSchema,
|
|
276
276
|
annotations: {
|
|
@@ -20,10 +20,12 @@ const WRITE_SCOPED_TOOLS = new Set([
|
|
|
20
20
|
'hoi4.localisation_write',
|
|
21
21
|
'hoi4.idea_write',
|
|
22
22
|
'hoi4.character_write',
|
|
23
|
+
'hoi4.country_write',
|
|
23
24
|
'hoi4.event_write',
|
|
24
25
|
'hoi4.decision_write',
|
|
25
26
|
'hoi4.tech_write',
|
|
26
27
|
'hoi4.doctrine_write',
|
|
28
|
+
'hoi4.common_write',
|
|
27
29
|
]);
|
|
28
30
|
const MCP_ALLOWED_METHODS = 'GET, POST, DELETE';
|
|
29
31
|
const SINGLETON_SECURITY_HEADERS = new Set([
|
|
@@ -6,9 +6,10 @@ import { BoundedStdioServerTransport, STDIO_MAX_FRAME_BYTES } from './bounded-st
|
|
|
6
6
|
import { FinalProtocolTransport } from './protocol-gate.js';
|
|
7
7
|
const MAX_QUEUED_MESSAGES = 128;
|
|
8
8
|
/**
|
|
9
|
-
* Requests that only describe the server. They are answered
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Requests that only describe the server. They are answered at once and start nothing: an idle
|
|
10
|
+
* server loads no workspace. The first other message starts the engine's startup (`recovered()`)
|
|
11
|
+
* and waits for it, with every later one in arrival order, so no request reads or writes a
|
|
12
|
+
* workspace that is not loaded yet.
|
|
12
13
|
*/
|
|
13
14
|
const ANSWERED_BEFORE_RECOVERY = new Set([
|
|
14
15
|
'initialize',
|
|
@@ -141,7 +142,7 @@ export async function serveNegotiatedStdio(engine, options) {
|
|
|
141
142
|
}
|
|
142
143
|
pinned.receive(message);
|
|
143
144
|
};
|
|
144
|
-
// Startup
|
|
145
|
+
// Startup: `held` until it ends, then `open`; `closed` drops every later message.
|
|
145
146
|
let recovery = 'held';
|
|
146
147
|
let heldBytes = 0;
|
|
147
148
|
const held = [];
|
|
@@ -151,19 +152,25 @@ export async function serveNegotiatedStdio(engine, options) {
|
|
|
151
152
|
heldBytes = 0;
|
|
152
153
|
void physical.close();
|
|
153
154
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
recovery = 'open';
|
|
158
|
-
heldBytes = 0;
|
|
159
|
-
for (const message of held.splice(0))
|
|
160
|
-
deliver(message);
|
|
161
|
-
}, (error) => {
|
|
162
|
-
if (recovery === 'closed')
|
|
155
|
+
let started = false;
|
|
156
|
+
const start = () => {
|
|
157
|
+
if (started)
|
|
163
158
|
return;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
159
|
+
started = true;
|
|
160
|
+
engine.recovered().then(() => {
|
|
161
|
+
if (recovery === 'closed')
|
|
162
|
+
return;
|
|
163
|
+
recovery = 'open';
|
|
164
|
+
heldBytes = 0;
|
|
165
|
+
for (const message of held.splice(0))
|
|
166
|
+
deliver(message);
|
|
167
|
+
}, (error) => {
|
|
168
|
+
if (recovery === 'closed')
|
|
169
|
+
return;
|
|
170
|
+
options.onFailure(error);
|
|
171
|
+
closeHeld();
|
|
172
|
+
});
|
|
173
|
+
};
|
|
167
174
|
physical.onmessage = (message) => {
|
|
168
175
|
observer?.received(message);
|
|
169
176
|
if (recovery === 'closed')
|
|
@@ -174,6 +181,7 @@ export async function serveNegotiatedStdio(engine, options) {
|
|
|
174
181
|
deliver(message);
|
|
175
182
|
return;
|
|
176
183
|
}
|
|
184
|
+
start();
|
|
177
185
|
const bytes = Buffer.byteLength(JSON.stringify(message)) + 1;
|
|
178
186
|
if (held.length >= MAX_QUEUED_MESSAGES || bytes > STDIO_MAX_FRAME_BYTES - heldBytes) {
|
|
179
187
|
reportError(new Error('Requests held during startup recovery exceeded their bounded limit'));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
-
import {
|
|
2
|
+
import { idleCacheLifetime } from '../core/idle-cache-lifetime.js';
|
|
3
3
|
import { errorResult, toolResult } from '../core/operation-result.js';
|
|
4
4
|
import { ServiceError } from '../core/result.js';
|
|
5
5
|
import { probabilityAnalyzeRequestSchema, probabilityInspectRequestSchema, } from '../schemas/probability-requests.js';
|
|
@@ -9,7 +9,7 @@ const wireResult = z.record(z.string(), z.json());
|
|
|
9
9
|
/** Registers probability operations without invoking transport handlers. */
|
|
10
10
|
export function registerProbabilityJobs(operations, engine) {
|
|
11
11
|
const analyzer = new ProbabilityAnalyzer(engine);
|
|
12
|
-
const lifetime =
|
|
12
|
+
const lifetime = idleCacheLifetime(engine, () => analyzer.clearCaches());
|
|
13
13
|
function register(name, schema, normalize, execute, message) {
|
|
14
14
|
operations.registerRead(name, schema, async (input, context) => {
|
|
15
15
|
const release = lifetime.begin();
|
|
@@ -5,7 +5,7 @@ import { loadConfiguration, serverConfigurationSchema, } from './core/configurat
|
|
|
5
5
|
import { canonicalJson } from './core/canonical.js';
|
|
6
6
|
import { CoreEngine } from './core/engine.js';
|
|
7
7
|
import { ServiceError } from './core/result.js';
|
|
8
|
-
import { WorkspaceResolver } from './core/workspace.js';
|
|
8
|
+
import { WorkspaceResolver, canonicalPath, isWithin } from './core/workspace.js';
|
|
9
9
|
import { CONFIG_VERSION } from './version.js';
|
|
10
10
|
import { sweepTemporaryDirectories } from './core/temporary-directories.js';
|
|
11
11
|
import { PROFILES_ENV, parseProfilesEnv, } from './mcp/server/tool-profiles.js';
|
|
@@ -231,6 +231,82 @@ export async function automaticConfiguration(start = process.cwd(), options = {}
|
|
|
231
231
|
],
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Serve the working folder as one extra mod workspace when it is itself a mod (it has a
|
|
236
|
+
* `descriptor.mod` and passes the mod detection) and no workspace already serves it
|
|
237
|
+
* (maintainer decision D-176). Configured workspaces and their storage stay exactly as they are,
|
|
238
|
+
* the configuration on disk is never written, and a working folder that is not a mod changes
|
|
239
|
+
* nothing. Only the extra workspace gets storage of its own, outside the mod.
|
|
240
|
+
*
|
|
241
|
+
* Skipped, because the server's own checks would refuse the overlap and fail to start: a folder
|
|
242
|
+
* that contains a configured workspace or mod root (a mod root that is itself the mod included).
|
|
243
|
+
* A folder inside a configured workspace, or inside a direct child of a mod root, is already
|
|
244
|
+
* served by that workspace.
|
|
245
|
+
*/
|
|
246
|
+
export async function withWorkingFolderMod(configuration, start = process.cwd()) {
|
|
247
|
+
const folder = path.resolve(start);
|
|
248
|
+
if (!(await isFile(path.join(folder, 'descriptor.mod'))) ||
|
|
249
|
+
(await isLikelyGameRoot(folder)) ||
|
|
250
|
+
!(await isLikelyModRoot(folder)))
|
|
251
|
+
return configuration;
|
|
252
|
+
const canonicalOrLexical = async (value) => canonicalPath(value).catch(() => path.resolve(value));
|
|
253
|
+
try {
|
|
254
|
+
const canonical = await canonicalPath(folder);
|
|
255
|
+
for (const workspace of configuration.workspaces) {
|
|
256
|
+
const root = await canonicalOrLexical(workspace.root);
|
|
257
|
+
if (isWithin(canonical, root) && !isWithin(root, canonical))
|
|
258
|
+
reportWorkingFolderNote('working_folder_mod_skipped', 'The working folder is a mod that contains a configured workspace, so it is not served as an extra workspace.');
|
|
259
|
+
if (isWithin(root, canonical) || isWithin(canonical, root))
|
|
260
|
+
return configuration;
|
|
261
|
+
}
|
|
262
|
+
for (const modRoot of configuration.modRoots) {
|
|
263
|
+
const root = await canonicalOrLexical(modRoot);
|
|
264
|
+
if (isWithin(canonical, root)) {
|
|
265
|
+
reportWorkingFolderNote('working_folder_mod_skipped', 'The working folder is a mod that is, or contains, a configured mod root, so it is not served as an extra workspace. Point modRoots at its parent folder, or pass workspaceId.');
|
|
266
|
+
return configuration;
|
|
267
|
+
}
|
|
268
|
+
if (!isWithin(root, canonical))
|
|
269
|
+
continue;
|
|
270
|
+
// Discovery serves every real, non-hidden folder directly below a mod root.
|
|
271
|
+
const child = path.relative(root, canonical).split(path.sep)[0] ?? '';
|
|
272
|
+
const status = await lstat(path.join(root, child)).catch(() => undefined);
|
|
273
|
+
if (!child.startsWith('.') && status?.isDirectory() === true && !status.isSymbolicLink())
|
|
274
|
+
return configuration;
|
|
275
|
+
}
|
|
276
|
+
const storage = automaticStorageRoots();
|
|
277
|
+
const baseId = automaticWorkspaceId(canonical);
|
|
278
|
+
const taken = new Set(configuration.workspaces.map((workspace) => workspace.id));
|
|
279
|
+
let id = baseId;
|
|
280
|
+
for (let suffix = 2; taken.has(id); suffix += 1)
|
|
281
|
+
id = `${baseId}_${suffix}`;
|
|
282
|
+
// Storage stays the default: <mod>/.hoi4-agent without a configured storage root, as for a
|
|
283
|
+
// configured workspace, or under the configured storage root. No global setting changes.
|
|
284
|
+
return serverConfigurationSchema.parse({
|
|
285
|
+
...configuration,
|
|
286
|
+
// Only a configuration with neither workspaces nor mod roots lacks a state root, so no
|
|
287
|
+
// existing mod (configured or discovered) has its storage moved by this.
|
|
288
|
+
...(configuration.serverStateRoot === undefined &&
|
|
289
|
+
configuration.workspaces.length === 0 &&
|
|
290
|
+
configuration.modRoots.length === 0
|
|
291
|
+
? { serverStateRoot: storage.serverStateRoot }
|
|
292
|
+
: {}),
|
|
293
|
+
workspaces: [
|
|
294
|
+
...configuration.workspaces,
|
|
295
|
+
{ id, name: path.basename(canonical), root: canonical },
|
|
296
|
+
],
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
// The registration limit, a configuration that needs a state root, or an unreadable folder:
|
|
301
|
+
// serve what is configured, and say so.
|
|
302
|
+
reportWorkingFolderNote('working_folder_mod_not_added', 'The working folder is a mod but could not be added as an extra workspace (registration limit reached, no server state root, or unreadable folder); only the configured workspaces are served.');
|
|
303
|
+
return configuration;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/** A note on stderr (never stdout) about the working-folder mod, without host paths. */
|
|
307
|
+
function reportWorkingFolderNote(event, message) {
|
|
308
|
+
process.stderr.write(`${canonicalJson({ level: 'warn', event, message })}\n`);
|
|
309
|
+
}
|
|
234
310
|
async function configurationExists(configPath) {
|
|
235
311
|
try {
|
|
236
312
|
return (await stat(configPath)).isFile();
|
|
@@ -305,6 +381,8 @@ export async function createEngine(configPath = configurationPath(), options = {
|
|
|
305
381
|
// The command-line servers read a fetched docs pack from the user's data folder by default.
|
|
306
382
|
if (configuration.docsRoot === undefined)
|
|
307
383
|
configuration = { ...configuration, docsRoot: defaultDocsRoot() };
|
|
384
|
+
if (options.workingFolderMod === true && startupError === undefined)
|
|
385
|
+
configuration = await withWorkingFolderMod(configuration);
|
|
308
386
|
if (!background) {
|
|
309
387
|
const resolver = await WorkspaceResolver.create(configuration);
|
|
310
388
|
await sweepTemporaryDirectoriesOf(resolver);
|
|
@@ -334,6 +412,10 @@ export async function createEngine(configPath = configurationPath(), options = {
|
|
|
334
412
|
reportStartupFailure(startupError);
|
|
335
413
|
return engine;
|
|
336
414
|
}
|
|
415
|
+
// Neither the loading nor the recovery of a workspace starts until a request needs one: the
|
|
416
|
+
// transport asks `engine.recovered()` for the first such request, and each workspace
|
|
417
|
+
// recovers on its first use.
|
|
418
|
+
engine.recoverOnDemand();
|
|
337
419
|
engine.deferStartup(async () => {
|
|
338
420
|
try {
|
|
339
421
|
await resolver.populate();
|
|
@@ -343,8 +425,6 @@ export async function createEngine(configPath = configurationPath(), options = {
|
|
|
343
425
|
return;
|
|
344
426
|
}
|
|
345
427
|
await sweepTemporaryDirectoriesOf(resolver);
|
|
346
|
-
// A failed recovery is reported through `engine.recovered()`.
|
|
347
|
-
engine.initialize().catch(() => undefined);
|
|
348
428
|
});
|
|
349
429
|
return engine;
|
|
350
430
|
}
|
|
@@ -9,7 +9,11 @@ export const characterWriteRequestSchema = z
|
|
|
9
9
|
/** add only: create the file named by file when the mod has no such common/characters file. */
|
|
10
10
|
createFile: z.boolean().optional(),
|
|
11
11
|
/** The text between the character braces. Required by add and replace, refused by remove. */
|
|
12
|
-
body: z
|
|
12
|
+
body: z
|
|
13
|
+
.string()
|
|
14
|
+
.max(32_000)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Only the text between the character braces, not the whole character_id = {...} block.'),
|
|
13
17
|
/** The common/characters file. Omit it for replace and remove, and for an add when the mod has one characters file. */
|
|
14
18
|
file: workspaceRelativePathSchema.max(512).optional(),
|
|
15
19
|
apply: z
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { backgroundRequestKeySchema, workspaceIdSchema, workspaceRelativePathSchema, } from './common.js';
|
|
3
|
+
/** The kinds `hoi4.common_write` writes; each is one descriptor in the engine (`hoi4-script-write`, ADR 0089). */
|
|
4
|
+
export const COMMON_WRITE_KINDS = ['bop', 'ai_strategy', 'ai_strategy_plan', 'on_action'];
|
|
5
|
+
export const commonWriteRequestSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
workspaceId: workspaceIdSchema,
|
|
8
|
+
kind: z.enum(COMMON_WRITE_KINDS),
|
|
9
|
+
operation: z.enum(['add', 'replace', 'remove']),
|
|
10
|
+
/** The definition: a top-level key of the file, or the on_action name for kind on_action. */
|
|
11
|
+
id: z.string().regex(/^[A-Za-z_][A-Za-z0-9_.-]{0,255}$/u),
|
|
12
|
+
/** The text between the braces of the definition (for on_action, of the on_action key). Required by add and replace, refused by remove. Raw script: it must parse, and it is written byte for byte. */
|
|
13
|
+
body: z
|
|
14
|
+
.string()
|
|
15
|
+
.max(64_000)
|
|
16
|
+
.optional()
|
|
17
|
+
.describe('Only the text between the definition braces, not the whole id = {...} block.'),
|
|
18
|
+
/** on_action only: the child block of the on_action key that replace or remove acts on, counted from 0. */
|
|
19
|
+
blockIndex: z.number().int().min(0).max(10_000).optional(),
|
|
20
|
+
/** add only: create the file named by file when the mod has no such file. */
|
|
21
|
+
createFile: z.boolean().optional(),
|
|
22
|
+
/** The file under the kind's folder. Omit it to use the mod file that defines the id; add into a folder with one file also needs no name. */
|
|
23
|
+
file: workspaceRelativePathSchema.max(512).optional(),
|
|
24
|
+
apply: z
|
|
25
|
+
.boolean()
|
|
26
|
+
.default(false)
|
|
27
|
+
.describe('false returns the diff and writes nothing; true makes the same change.'),
|
|
28
|
+
requestKey: backgroundRequestKeySchema.optional(),
|
|
29
|
+
})
|
|
30
|
+
.strict();
|
|
31
|
+
export const commonWriteDataSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
operation: z.enum(['add', 'replace', 'remove']),
|
|
34
|
+
kind: z.enum(COMMON_WRITE_KINDS),
|
|
35
|
+
id: z.string().max(256),
|
|
36
|
+
path: z.string().max(1024),
|
|
37
|
+
applied: z.boolean(),
|
|
38
|
+
/** The unified diff of the file, cut at a line when it is long. */
|
|
39
|
+
diff: z.string().max(12_000),
|
|
40
|
+
diffTruncated: z.boolean(),
|
|
41
|
+
/** The other definitions of the file, checked to be byte for byte as they were. */
|
|
42
|
+
untouchedDefinitions: z.number().int().min(0),
|
|
43
|
+
/** What the kind's check found that does not stop the write. */
|
|
44
|
+
findings: z
|
|
45
|
+
.array(z
|
|
46
|
+
.object({
|
|
47
|
+
severity: z.enum(['warning']),
|
|
48
|
+
code: z.string().max(128),
|
|
49
|
+
message: z.string().max(1024),
|
|
50
|
+
})
|
|
51
|
+
.strict())
|
|
52
|
+
.max(50),
|
|
53
|
+
/** How many findings and undefined references were left out of the lists above to keep the answer short. */
|
|
54
|
+
omitted: z
|
|
55
|
+
.object({
|
|
56
|
+
findings: z.number().int().min(0),
|
|
57
|
+
diagnostics: z.number().int().min(0),
|
|
58
|
+
localisation: z.number().int().min(0),
|
|
59
|
+
sprites: z.number().int().min(0),
|
|
60
|
+
categories: z.number().int().min(0),
|
|
61
|
+
focuses: z.number().int().min(0),
|
|
62
|
+
})
|
|
63
|
+
.strict(),
|
|
64
|
+
/** What the definition refers to and the mod does not define. The write still happens. */
|
|
65
|
+
missing: z
|
|
66
|
+
.object({
|
|
67
|
+
localisation: z.array(z.string().max(256)).max(50),
|
|
68
|
+
sprites: z.array(z.string().max(256)).max(20),
|
|
69
|
+
categories: z.array(z.string().max(256)).max(5),
|
|
70
|
+
focuses: z.array(z.string().max(256)).max(100),
|
|
71
|
+
})
|
|
72
|
+
.strict(),
|
|
73
|
+
})
|
|
74
|
+
.strict();
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { backgroundRequestKeySchema, workspaceIdSchema, workspaceRelativePathSchema, } from './common.js';
|
|
3
|
+
/** A token the game reads as a bare word: ids, ideologies, cultures, technologies. */
|
|
4
|
+
const tokenSchema = z.string().regex(/^[A-Za-z0-9_.:@-]{1,256}$/u);
|
|
5
|
+
/** Text written between quotes: one line without a quote. */
|
|
6
|
+
const quotedSchema = z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(512)
|
|
10
|
+
.regex(/^[^"\r\n]+$/u);
|
|
11
|
+
/** A localised text: one line. */
|
|
12
|
+
const textSchema = z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(200)
|
|
16
|
+
.regex(/^[^\p{Cc}\p{Zl}\p{Zp}]+$/u);
|
|
17
|
+
const channelSchema = z.number().int().min(0).max(255);
|
|
18
|
+
const rgbSchema = z.object({ r: channelSchema, g: channelSchema, b: channelSchema }).strict();
|
|
19
|
+
export const countryIdeologyNameSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
ideology: tokenSchema,
|
|
22
|
+
/** `<TAG>_<ideology>`. */
|
|
23
|
+
name: textSchema.optional(),
|
|
24
|
+
/** `<TAG>_<ideology>_ADJ`. */
|
|
25
|
+
adjective: textSchema.optional(),
|
|
26
|
+
/** `<TAG>_<ideology>_DEF`. */
|
|
27
|
+
definition: textSchema.optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
export const countryHistorySchema = z
|
|
31
|
+
.object({
|
|
32
|
+
/** The capital state id. Required by add. */
|
|
33
|
+
capital: z.number().int().min(1).max(100_000).optional(),
|
|
34
|
+
/** The order of battle file of history/units, without .txt. */
|
|
35
|
+
oob: tokenSchema.optional(),
|
|
36
|
+
/** add only: the starting ideas (add_ideas). */
|
|
37
|
+
ideas: z.array(tokenSchema).min(1).max(50).optional(),
|
|
38
|
+
researchSlots: z.number().int().min(0).max(20).optional(),
|
|
39
|
+
stability: z.number().min(0).max(1).optional(),
|
|
40
|
+
warSupport: z.number().min(0).max(1).optional(),
|
|
41
|
+
/** set_technology, in order. Update replaces the block. */
|
|
42
|
+
technology: z
|
|
43
|
+
.array(z.object({ id: tokenSchema, level: z.number().int().min(0).max(10) }).strict())
|
|
44
|
+
.min(1)
|
|
45
|
+
.max(200)
|
|
46
|
+
.optional(),
|
|
47
|
+
/** set_politics. Required by add; update replaces the block. */
|
|
48
|
+
politics: z
|
|
49
|
+
.object({
|
|
50
|
+
rulingParty: tokenSchema,
|
|
51
|
+
lastElection: z
|
|
52
|
+
.string()
|
|
53
|
+
.regex(/^\d{1,5}\.\d{1,2}\.\d{1,2}$/u)
|
|
54
|
+
.optional(),
|
|
55
|
+
electionFrequency: z.number().int().min(1).max(1200).optional(),
|
|
56
|
+
electionsAllowed: z.boolean().optional(),
|
|
57
|
+
})
|
|
58
|
+
.strict()
|
|
59
|
+
.optional(),
|
|
60
|
+
/** set_popularities, in order, adding up to 100. Required by add; update replaces the block. */
|
|
61
|
+
popularities: z
|
|
62
|
+
.array(z.object({ ideology: tokenSchema, value: z.number().int().min(0).max(100) }).strict())
|
|
63
|
+
.min(1)
|
|
64
|
+
.max(20)
|
|
65
|
+
.optional(),
|
|
66
|
+
/** recruit_character lines; update adds the missing ones and removes none. */
|
|
67
|
+
recruitCharacters: z.array(tokenSchema).min(1).max(50).optional(),
|
|
68
|
+
})
|
|
69
|
+
.strict();
|
|
70
|
+
export const countryBookmarkSchema = z
|
|
71
|
+
.object({
|
|
72
|
+
/** The bookmark file under common/bookmarks. */
|
|
73
|
+
file: workspaceRelativePathSchema.max(512),
|
|
74
|
+
/** The bookmark's name key. */
|
|
75
|
+
name: quotedSchema.optional(),
|
|
76
|
+
/** The ideology the bookmark shows. Required to list the country. */
|
|
77
|
+
ideology: tokenSchema.optional(),
|
|
78
|
+
/** The localisation key of the country's bookmark text. */
|
|
79
|
+
history: quotedSchema.optional(),
|
|
80
|
+
/** major lists the country before "---"; minor after it, with minor = yes. */
|
|
81
|
+
role: z.enum(['major', 'minor']).optional(),
|
|
82
|
+
/** add only: create file as a new bookmark that starts with this country. */
|
|
83
|
+
create: z
|
|
84
|
+
.object({
|
|
85
|
+
desc: quotedSchema,
|
|
86
|
+
/** 1936.1.1.12 */
|
|
87
|
+
date: z.string().regex(/^\d{1,5}\.\d{1,2}\.\d{1,2}(?:\.\d{1,2})?$/u),
|
|
88
|
+
picture: quotedSchema,
|
|
89
|
+
default: z.boolean().optional(),
|
|
90
|
+
/** The "---" entry's text key, for the countries the list does not name. */
|
|
91
|
+
otherHistory: quotedSchema.optional(),
|
|
92
|
+
})
|
|
93
|
+
.strict()
|
|
94
|
+
.optional(),
|
|
95
|
+
})
|
|
96
|
+
.strict();
|
|
97
|
+
/**
|
|
98
|
+
* Published shapes: the nested fields are named in the descriptions, which keeps the tool listing
|
|
99
|
+
* inside the discovery budget. Every field is validated by the full schema behind each pipe.
|
|
100
|
+
*/
|
|
101
|
+
const compactHistorySchema = z
|
|
102
|
+
.looseObject({ capital: z.number().int().optional() })
|
|
103
|
+
.describe('capital (state id); politics {rulingParty, lastElection?, electionFrequency?, electionsAllowed?}; popularities [{ideology, value}] summing to 100; oob; ideas (add only); researchSlots; stability and warSupport (0-1); technology [{id, level}]; recruitCharacters [id]. add needs capital, politics and popularities; update replaces only what is given.')
|
|
104
|
+
.transform((value) => value)
|
|
105
|
+
.pipe(countryHistorySchema);
|
|
106
|
+
const compactBookmarkSchema = z
|
|
107
|
+
.looseObject({ file: z.string() })
|
|
108
|
+
.describe('file (common/bookmarks/*.txt); name (the bookmark name key); ideology; history (text key); role major|minor; create {desc, date 1936.1.1.12, picture, default?, otherHistory?} makes a new bookmark (add only). remove takes no bookmark: it clears the tag from every bookmark of the mod.')
|
|
109
|
+
.transform((value) => value)
|
|
110
|
+
.pipe(countryBookmarkSchema);
|
|
111
|
+
const compactIdeologyNamesSchema = z
|
|
112
|
+
.unknown()
|
|
113
|
+
.describe('[{ideology, name?, adjective?, definition?}]: <TAG>_<ideology>, _ADJ, _DEF.')
|
|
114
|
+
.pipe(z.array(countryIdeologyNameSchema).min(1).max(20));
|
|
115
|
+
export const countryWriteRequestSchema = z
|
|
116
|
+
.object({
|
|
117
|
+
workspaceId: workspaceIdSchema,
|
|
118
|
+
operation: z.enum(['add', 'update', 'remove']),
|
|
119
|
+
/** The country tag. A new tag is an upper-case letter and two upper-case letters or digits. */
|
|
120
|
+
tag: z.string().regex(/^[A-Z0-9]{3}$/u),
|
|
121
|
+
/** add: the country name; it names the files and, with no localisation given, its text. */
|
|
122
|
+
name: textSchema.optional(),
|
|
123
|
+
/** <TAG>_ADJ; defaults to name on add. */
|
|
124
|
+
adjective: textSchema.optional(),
|
|
125
|
+
/** <TAG>_DEF; defaults to name on add. */
|
|
126
|
+
definition: textSchema.optional(),
|
|
127
|
+
/** Per-ideology names (<TAG>_<ideology>, _ADJ, _DEF). */
|
|
128
|
+
ideologyNames: compactIdeologyNamesSchema.optional(),
|
|
129
|
+
/** add: the mod's common/country_tags file; needed when the mod has several or none. */
|
|
130
|
+
tagFile: workspaceRelativePathSchema.max(512).optional(),
|
|
131
|
+
/** Both graphical cultures: gfx (…_gfx) and twoD (…_2d). Required by add. */
|
|
132
|
+
graphicalCulture: z.object({ gfx: tokenSchema, twoD: tokenSchema }).strict().optional(),
|
|
133
|
+
/** The map colour. Required by add. */
|
|
134
|
+
color: rgbSchema.optional(),
|
|
135
|
+
/** The interface colour; defaults to color on add. */
|
|
136
|
+
colorUi: rgbSchema.optional(),
|
|
137
|
+
history: compactHistorySchema.optional(),
|
|
138
|
+
bookmark: compactBookmarkSchema.optional(),
|
|
139
|
+
apply: z
|
|
140
|
+
.boolean()
|
|
141
|
+
.default(false)
|
|
142
|
+
.describe('false returns the diff and writes nothing; true makes the same change.'),
|
|
143
|
+
requestKey: backgroundRequestKeySchema.optional(),
|
|
144
|
+
})
|
|
145
|
+
.strict()
|
|
146
|
+
.superRefine((value, context) => {
|
|
147
|
+
const issue = (path, message) => context.addIssue({ code: 'custom', path: [path], message });
|
|
148
|
+
if (value.operation === 'add') {
|
|
149
|
+
if (value.name === undefined)
|
|
150
|
+
issue('name', 'add needs the country name');
|
|
151
|
+
if (value.graphicalCulture === undefined)
|
|
152
|
+
issue('graphicalCulture', 'add needs both graphical cultures');
|
|
153
|
+
if (value.color === undefined)
|
|
154
|
+
issue('color', 'add needs the map colour');
|
|
155
|
+
if (value.history === undefined)
|
|
156
|
+
issue('history', 'add needs the history');
|
|
157
|
+
}
|
|
158
|
+
if (value.operation === 'remove')
|
|
159
|
+
for (const field of [
|
|
160
|
+
'name',
|
|
161
|
+
'adjective',
|
|
162
|
+
'definition',
|
|
163
|
+
'ideologyNames',
|
|
164
|
+
'graphicalCulture',
|
|
165
|
+
'color',
|
|
166
|
+
'colorUi',
|
|
167
|
+
'history',
|
|
168
|
+
'bookmark',
|
|
169
|
+
])
|
|
170
|
+
if (value[field] !== undefined)
|
|
171
|
+
issue(field, `remove takes no ${field}`);
|
|
172
|
+
if (value.operation !== 'add' && value.bookmark?.create !== undefined)
|
|
173
|
+
issue('bookmark', 'only add creates a bookmark');
|
|
174
|
+
if (value.operation !== 'add' && value.tagFile !== undefined)
|
|
175
|
+
issue('tagFile', 'only add chooses the tag file; update and remove find it');
|
|
176
|
+
});
|
|
177
|
+
const missingListSchema = z.array(z.string().max(512)).max(30);
|
|
178
|
+
export const countryWriteDataSchema = z
|
|
179
|
+
.object({
|
|
180
|
+
operation: z.enum(['add', 'update', 'remove']),
|
|
181
|
+
tag: z.string().max(3),
|
|
182
|
+
applied: z.boolean(),
|
|
183
|
+
files: z
|
|
184
|
+
.array(z
|
|
185
|
+
.object({
|
|
186
|
+
path: z.string().max(1024),
|
|
187
|
+
action: z.enum(['create', 'modify', 'delete']),
|
|
188
|
+
/** The unified diff of the file, cut at a line when it is long; empty for a deletion. */
|
|
189
|
+
diff: z.string().max(12_000),
|
|
190
|
+
diffTruncated: z.boolean(),
|
|
191
|
+
})
|
|
192
|
+
.strict())
|
|
193
|
+
.max(16),
|
|
194
|
+
/** What the country refers to and the mod does not have. The write still happens. */
|
|
195
|
+
missing: z
|
|
196
|
+
.object({
|
|
197
|
+
flags: missingListSchema,
|
|
198
|
+
localisation: missingListSchema,
|
|
199
|
+
characters: missingListSchema,
|
|
200
|
+
oob: missingListSchema,
|
|
201
|
+
})
|
|
202
|
+
.strict(),
|
|
203
|
+
/** Localisation keys of the country that remove leaves in place. */
|
|
204
|
+
localisationKept: missingListSchema,
|
|
205
|
+
})
|
|
206
|
+
.strict();
|
|
@@ -13,7 +13,11 @@ export const decisionWriteRequestSchema = z
|
|
|
13
13
|
/** add only: create the file named by file when the mod has no such common/decisions file. */
|
|
14
14
|
createFile: z.boolean().optional(),
|
|
15
15
|
/** The text between the decision braces. Required by add and replace, refused by remove. */
|
|
16
|
-
body: z
|
|
16
|
+
body: z
|
|
17
|
+
.string()
|
|
18
|
+
.max(32_000)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Only the text between the decision braces, not the whole decision_id = {...} block.'),
|
|
17
21
|
/** The common/decisions file. Omit it for replace and remove, and for an add into a category that one file defines. */
|
|
18
22
|
file: workspaceRelativePathSchema.max(512).optional(),
|
|
19
23
|
apply: z
|
|
@@ -12,7 +12,11 @@ export const doctrineWriteRequestSchema = z
|
|
|
12
12
|
/** add only: create the file named by file when the mod has no such doctrine file. */
|
|
13
13
|
createFile: z.boolean().optional(),
|
|
14
14
|
/** The text between the doctrine braces. Required by add and replace, refused by remove. */
|
|
15
|
-
body: z
|
|
15
|
+
body: z
|
|
16
|
+
.string()
|
|
17
|
+
.max(32_000)
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Only the text between the doctrine braces, not the whole doctrine_id = {...} block.'),
|
|
16
20
|
/** The doctrine file under common/doctrines/grand_doctrines, tracks or subdoctrines. Omit it for replace and remove, and for an add when the mod has one file of that kind. */
|
|
17
21
|
file: workspaceRelativePathSchema.max(512).optional(),
|
|
18
22
|
apply: z
|
|
@@ -22,7 +22,11 @@ export const eventWriteRequestSchema = z
|
|
|
22
22
|
/** add only: create the file named by file when the mod has no such events file. */
|
|
23
23
|
createFile: z.boolean().optional(),
|
|
24
24
|
/** The text between the event braces, without the id line. Required by add and replace, refused by remove. */
|
|
25
|
-
body: z
|
|
25
|
+
body: z
|
|
26
|
+
.string()
|
|
27
|
+
.max(32_000)
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('Only the text between the event braces (title, desc, option = {...}), without id; not a country_event = {...} block.'),
|
|
26
30
|
/** The events file. Omit it for replace and remove, and for an add when one file holds the namespace. */
|
|
27
31
|
file: workspaceRelativePathSchema.max(512).optional(),
|
|
28
32
|
apply: z
|
|
@@ -13,7 +13,11 @@ export const ideaWriteRequestSchema = z
|
|
|
13
13
|
/** add only: create the file named by file when the mod has no such common/ideas file. */
|
|
14
14
|
createFile: z.boolean().optional(),
|
|
15
15
|
/** The text between the idea braces. Required by add and replace, refused by remove. */
|
|
16
|
-
body: z
|
|
16
|
+
body: z
|
|
17
|
+
.string()
|
|
18
|
+
.max(32_000)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Only the text between the idea braces, not the whole idea_id = {...} block.'),
|
|
17
21
|
/** The common/ideas file. Omit it for replace and remove, and for an add into a category that one file defines. */
|
|
18
22
|
file: workspaceRelativePathSchema.max(512).optional(),
|
|
19
23
|
apply: z
|