| 1 | /** |
| 2 | * Central entry point for the new macro system. |
| 3 | * |
| 4 | * Exposes the MacroEngine / MacroRegistry singletons and provides a |
| 5 | * single registerMacros() function that wires up all built-in macro |
| 6 | * definition sets (core, env, state, chat, time, variables, instruct). |
| 7 | */ |
| 8 | |
| 9 | // Engine singletons and enums |
| 10 | import { MacroEngine } from './engine/MacroEngine.js'; |
| 11 | import { MacroRegistry, MacroCategory, MacroValueType } from './engine/MacroRegistry.js'; |
| 12 | import { MacroLexer } from './engine/MacroLexer.js'; |
| 13 | import { MacroParser } from './engine/MacroParser.js'; |
| 14 | import { MacroCstWalker } from './engine/MacroCstWalker.js'; |
| 15 | import { MacroEnvBuilder } from './engine/MacroEnvBuilder.js'; |
| 16 | |
| 17 | // Macro definition groups |
| 18 | import { registerCoreMacros } from './definitions/core-macros.js'; |
| 19 | import { registerEnvMacros } from './definitions/env-macros.js'; |
| 20 | import { registerStateMacros } from './definitions/state-macros.js'; |
| 21 | import { registerChatMacros } from './definitions/chat-macros.js'; |
| 22 | import { registerTimeMacros } from './definitions/time-macros.js'; |
| 23 | import { registerVariableMacros } from './definitions/variable-macros.js'; |
| 24 | import { registerInstructMacros } from './definitions/instruct-macros.js'; |
| 25 | |
| 26 | // Re-export the category enum for external use |
| 27 | export { MacroCategory, MacroValueType }; |
| 28 | |
| 29 | // Re-export most-used jsdoc definitions |
| 30 | /** @typedef {import('./engine/MacroRegistry.js').MacroDefinitionOptions} MacroDefinitionOptions */ |
| 31 | /** @typedef {import('./engine/MacroRegistry.js').MacroDefinition} MacroDefinition */ |
| 32 | /** @typedef {import('./engine/MacroRegistry.js').MacroUnnamedArgDef} MacroUnnamedArgDef */ |
| 33 | /** @typedef {import('./engine/MacroRegistry.js').MacroListSpec} MacroListSpec */ |
| 34 | /** @typedef {import('./engine/MacroRegistry.js').MacroHandler} MacroHandler */ |
| 35 | /** @typedef {import('./engine/MacroRegistry.js').MacroExecutionContext} MacroExecutionContext */ |
| 36 | |
| 37 | /** @typedef {import('chevrotain').CstNode} CstNode */ |
| 38 | /** @typedef {import('./engine/MacroEnv.types.js').MacroEnv} MacroEnv */ |
| 39 | /** @typedef {import('./engine/MacroEnv.types.js').MacroEnvNames} MacroEnvNames */ |
| 40 | /** @typedef {import('./engine/MacroEnv.types.js').MacroEnvCharacter} MacroEnvCharacter */ |
| 41 | /** @typedef {import('./engine/MacroEnv.types.js').MacroEnvSystem} MacroEnvSystem */ |
| 42 | /** @typedef {import('./engine/MacroEnv.types.js').MacroEnvFunctions} MacroEnvFunctions */ |
| 43 | |
| 44 | export const macros = { |
| 45 | // engine singletons |
| 46 | engine: MacroEngine, |
| 47 | registry: MacroRegistry, |
| 48 | envBuilder: MacroEnvBuilder, |
| 49 | lexer: MacroLexer, |
| 50 | parser: MacroParser, |
| 51 | cstWalker: MacroCstWalker, |
| 52 | |
| 53 | // enums |
| 54 | category: MacroCategory, |
| 55 | |
| 56 | // shorthand functions |
| 57 | register: MacroRegistry.registerMacro.bind(MacroRegistry), |
| 58 | registerAlias: MacroRegistry.registerMacroAlias.bind(MacroRegistry), |
| 59 | }; |
| 60 | |
| 61 | /** |
| 62 | * Registers all built-in macros in a well-defined order. |
| 63 | * Intended to be called once during app initialization. |
| 64 | */ |
| 65 | export function initRegisterMacros() { |
| 66 | // Core utilities and generic helpers |
| 67 | registerCoreMacros(); |
| 68 | |
| 69 | // Env / character / system / extras |
| 70 | registerEnvMacros(); |
| 71 | |
| 72 | // Runtime state tracking (eventSource etc.) |
| 73 | registerStateMacros(); |
| 74 | |
| 75 | // Chat/history inspection macros |
| 76 | registerChatMacros(); |
| 77 | |
| 78 | // Time / date / durations |
| 79 | registerTimeMacros(); |
| 80 | |
| 81 | // Variable and instruct macros |
| 82 | registerVariableMacros(); |
| 83 | registerInstructMacros(); |
| 84 | } |