Standard module registry, dependency checker, and zero-collision discovery contract for AI Dungeon scripts and interactive fiction.
AID-Modules establishes an open standard for modular AI Dungeon scripting. It solves the friction of multi-creator adventures by providing transparent module registration, SemVer dependency checking, runtime discovery, the 3 Golden Rules of zero-collision scripting, and collision-proof in-game /aid-modules diagnostics.
AI Dungeon's Script Management Run Order allows creators and players to stack multiple independent scripts sequentially (Script 1 β Script 2 β Script 3). However, until now:
- No Standard Module Discovery: Scripts could not determine what other libraries were loaded in the scene.
- Command Collisions & Downstream Starvation: Scripts capturing generic commands (
/help,/reset,/diag) starved downstream scripts of player inputs. - Brittle Dependency Failures: If Script B depended on Script A, missing scripts produced cryptic
ReferenceErrorcrashes rather than clean, user-friendly guidance. - No Lineage Traceability: When players encountered bugs in multi-mod adventures, authors had no way to verify which script versions were active.
- Namespace Collisions: Different creators invented conflicting globals (
state.modules,globalThis.MODS,window.plugins).
AID-Modules, the AMS v1.2.0 Specification, and the CSCP v1.2.0 Specification provide a complete, zero-dependency, open standard to unite the ecosystem.
AID-Modules operates on a dual-layer discovery pattern:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β globalThis.AID_MODULES (Plain Object Dictionary) β
β - 100% backward-compatible direct storage β
β - Any script can write without importing an external library β
βββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β²
β (Syncs & Adopts)
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β globalThis.AID (Registry Manager & API) β
β - AID.register(spec) - Validates spec & handles SemVer upgradesβ
β - AID.get(name) - Retrieves module records & exports β
β - AID.has(name, range) - SemVer range checks (>=, ^, ~) β
β - AID.require(name) - Safe dependency assertion with errors β
β - AID.report() - Formatted manifest for /aid-modules command β
β - AID.slashCommand() - Binds /aid-modules to aid-getopt routers β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Open your scenario on AI Dungeon.
- In Details β Player presentation, toggle Mark as Script to ON.
- In Scripts β Library, copy and paste the contents of
library-aid-modules.js. - Add
src/input.js,src/context.js, andsrc/output.jsto your Input, Context, and Output script tabs. - Place AID-Modules in Slot 1 (the very TOP) of your scenario's RUN ORDER. Downstream scripts automatically discover and coordinate with it!
- Slot 1:
AID-Modules(v1.2.0) β CSCP v1.2 bus, Turn Arbitration, &[Disabled]badge reconciler - Slots 2 & 3 (either order):
Entity Cards(v3.0.0) +Inner Entity (Minds)(v3.0.0)
Note
AID-Getopt is no longer loaded as a Script Manager slot. Both Entity Cards and Inner Entity bundle aid-getopt v1.2.0 (ungetopt) internally, and AID-Modules handles /aid-modules natively. AID-Getopt remains available strictly as a developer library for creators writing custom slash commands.
If you are publishing a standalone script (like a dice roller or card engine) and want to be compliant without requiring users to install an extra script:
// Register your module onto globalThis.AID_MODULES:
(globalThis.AID_MODULES ??= {})["my-dice"] = {
name: "my-dice",
version: "1.0.0",
gitHash: "a1b2c3d",
buildTime: "2026-11-06 20:00 UTC",
author: "YourName",
description: "Polyhedral dice roller for fantasy combat",
exports: { roll: (d) => Math.floor(Math.random() * d) + 1 },
diag: () => "my-dice v1.0.0 (a1b2c3d)"
};
// If the full AID manager is active, tell it to adopt:
if (typeof globalThis.AID?.register === "function") {
globalThis.AID.register(globalThis.AID_MODULES["my-dice"]);
}Registers a module following the AMS v1.2.0 Specification. If a newer version is already registered, older registrations are safely ignored.
AID.register({
name: "aid-getopt",
version: "1.2.0",
gitHash: "1f4e6c1",
author: "Randy Viosca",
description: "POSIX/GNU CLI flag parser (bundled library)",
exports: AIDGetopt,
diag: () => `AID-Getopt v1.2.0 (1f4e6c1)`
});Checks if a module is registered, with optional SemVer matching (>=1.0.0, ^1.0.0, ~1.0.0).
if (AID.has("aid-getopt", ">=1.2.0")) {
console.log("AID-Getopt is available!");
}Returns the module's public exports. Throws a descriptive, user-friendly error if missing or if the version does not satisfy the range.
const getopt = AID.require("aid-getopt", "^1.2.0");Retrieves the full module metadata record (or null if not found).
Returns an array of all registered module records.
Generates a formatted summary report for in-game display or diagnostics.
console.log(AID.report({ verbose: true }));==================================================================
π¦ Active AI Dungeon Modules (3 loaded)
==================================================================
β’ aid-modules v1.2.0
Standard module registry and CSCP coordinator for AI Dungeon
β’ entity-cards v3.0.0
Named Entity Recognition Story Cards for characters & lore
β’ inner-entity v3.0.0
Autonomous character minds and reflections [minds]
==================================================================
Automatically binds a collision-proof /aid-modules (alias /aid-module) slash command to an aid-getopt command router!
- AI Dungeon Module Specification (AMS v1.2.0): Module records, SemVer dependency checking, the 3 Golden Rules of zero-collision scripting, and intra-VM registries.
- Cross-Slot Coordination Protocol Specification (CSCP v1.2.0): Inter-VM steganographic data bus, 16-Variation-Selector StoryCard DLL hydration, capability negotiation, turn arbitration, and multi-script waterfall coordination.
AID-Modules includes automated test coverage verifying registration, SemVer ranges, upgrade precedence, dictionary backward compatibility, and /aid-modules command integration:
npm test==================================================================
TEST SUITE: AID-Modules (Standard Module Registry)
==================================================================
β Module registration, retrieval, and exports verified
β SemVer range matching (>=, ^, ~, <) verified
β Upgrade precedence (newer version wins, older ignored) verified
β 100% backward compatibility with globalThis.AID_MODULES dictionary verified
β AID.require() returns exports and provides clear error messages for missing dependencies
β AID.report() formats clean multiline manifest
β Event bus ('register' / 'unregister') verified
β In-game /aid-modules & /aid-module slash commands integrated with aid-getopt
==================================================================
π ALL AID-Modules TESTS PASSED (100% SUCCESS)
==================================================================
MIT Β© Randy Viosca (@Random_Variable)
