feat: add getExtensionManifest() to extensions.js and expose via getContext() (#5442) Returns a structuredClone of the loaded manifest for the given extension name. Accepts either the short name or full internal key (third-party/...). Returns null if the extension is not registered.

a7f144f28b43490cac66b3e618d557d8bc991358

Wolfsblvt <wolfsblvt@gmail.com>

Signed
2 files changed, +17 -0Ignore whitespace
public/scripts/extensions.js+15 -0
@@ -474,6 +474,21 @@ export function findExtension(name) {
474474}
475475
476476/**
477+ * Returns a deep clone of the manifest for the given extension name.
478+ * Accepts either the short name (e.g. `SillyTavern-MyExtension`) or the full internal key
479+ * (e.g. `third-party/SillyTavern-MyExtension`). Returns null if the extension is not found.
480+ * @param {string} name - Extension name or internal key
481+ * @returns {object|null} Cloned manifest object, or null if not found
482+ */
483+export function getExtensionManifest(name) {
484+ const found = extensionNames.find(extName =>
485+ equalsIgnoreCaseAndAccents(extName, name) || equalsIgnoreCaseAndAccents(extName, `third-party/${name}`),
486+ );
487+ const manifest = found ? manifests[found] : null;
488+ return manifest ? structuredClone(manifest) : null;
489+}
490+
491+/**
477492 * Loads manifest.json files for extensions.
478493 * @param {string[]} names Array of extension names
479494 * @returns {Promise<Record<string, object>>} Object with extension names as keys and their manifests as values
public/scripts/st-context.js+2 -0
@@ -71,6 +71,7 @@ import {
7171} from '../script.js';
7272import {
7373 extension_settings,
74+ getExtensionManifest,
7475 ModuleWorkerWrapper,
7576 openThirdPartyExtensionMenu,
7677 renderExtensionTemplate,
@@ -290,6 +291,7 @@ export function getContext() {
290291 getReasoningTemplateByName,
291292 unshallowCharacter,
292293 unshallowGroupMembers,
294+ getExtensionManifest,
293295 openThirdPartyExtensionMenu,
294296 symbols: {
295297 ignore: IGNORE_SYMBOL,