Skip to content

About

Standard module registry, dependency checker, and discovery contract for AI Dungeon scripts and interactive fiction

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

31 Commits

Folders and files

Repository files navigation

AID-Modules πŸ“¦

aid-modules Hero Banner

Node.js CI License: MIT Zero Dependencies Specification: AMS v1.2.0 Protocol: CSCP v1.2.0

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.


🌟 Why AID-Modules?

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:

  1. No Standard Module Discovery: Scripts could not determine what other libraries were loaded in the scene.
  2. Command Collisions & Downstream Starvation: Scripts capturing generic commands (/help, /reset, /diag) starved downstream scripts of player inputs.
  3. Brittle Dependency Failures: If Script B depended on Script A, missing scripts produced cryptic ReferenceError crashes rather than clean, user-friendly guidance.
  4. No Lineage Traceability: When players encountered bugs in multi-mod adventures, authors had no way to verify which script versions were active.
  5. 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.


πŸ—οΈ Architecture

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    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Installation & Usage in AI Dungeon

Method 1: As a Standalone Script in Your Run Order (Recommended)

  1. Open your scenario on AI Dungeon.
  2. In Details βž” Player presentation, toggle Mark as Script to ON.
  3. In Scripts βž” Library, copy and paste the contents of library-aid-modules.js.
  4. Add src/input.js, src/context.js, and src/output.js to your Input, Context, and Output script tabs.
  5. Place AID-Modules in Slot 1 (the very TOP) of your scenario's RUN ORDER. Downstream scripts automatically discover and coordinate with it!

Recommended Multi-Slot Stack (No AID-Getopt Slot Needed)

  • 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.

Method 2: Self-Bootstrapping (Bundled in Your Script)

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"]);
}

πŸ“– API Reference

AID.register(moduleSpec)

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)`
});

AID.has(name, [semverRange])

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!");
}

AID.require(name, [semverRange])

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");

AID.get(name)

Retrieves the full module metadata record (or null if not found).

AID.list()

Returns an array of all registered module records.

AID.report([options])

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]
==================================================================

AID.slashCommand(app)

Automatically binds a collision-proof /aid-modules (alias /aid-module) slash command to an aid-getopt command router!


πŸ“œ Specifications


πŸ§ͺ Testing

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)
==================================================================

πŸ“„ License

MIT Β© Randy Viosca (@Random_Variable)

About

Standard module registry, dependency checker, and discovery contract for AI Dungeon scripts and interactive fiction

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages