From 00108c357b8e8baa87c116fd279da2f9e0673364 Mon Sep 17 00:00:00 2001 From: orion Date: Tue, 10 Mar 2026 18:25:54 +0000 Subject: [PATCH] Add OpenClaw manifest and configure install --- install.mjs | 46 +++++++++++++++++++++++++++++++++---- package.json | 2 +- plugin/openclaw.plugin.json | 13 +++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 plugin/openclaw.plugin.json diff --git a/install.mjs b/install.mjs index 04cee3b..3eefded 100644 --- a/install.mjs +++ b/install.mjs @@ -73,7 +73,7 @@ function install() { console.log(''); // 1. Build - log('[1/3] Building...', 'cyan'); + log('[1/4] Building...', 'cyan'); execSync('npm install', { cwd: __dirname, stdio: 'inherit' }); execSync('npm run build', { cwd: __dirname, stdio: 'inherit' }); @@ -84,7 +84,7 @@ function install() { logOk('Build complete'); // 2. Copy to plugins dir - log('[2/3] Installing...', 'cyan'); + log('[2/4] Installing...', 'cyan'); const openclawPath = resolveOpenclawPath(); const destDir = join(openclawPath, 'plugins', PLUGIN_NAME); @@ -94,8 +94,29 @@ function install() { copyDir(SRC_DIST_DIR, destDir); logOk(`Plugin files → ${destDir}`); - // 3. Summary - log('[3/3] Done!', 'cyan'); + // 3. Configure OpenClaw + log('[3/4] Configuring OpenClaw...', 'cyan'); + try { + const pluginPath = destDir; + const allow = ensureArray(getConfigValue('plugins.allow')); + const loadPaths = ensureArray(getConfigValue('plugins.load.paths')); + + if (!allow.includes(PLUGIN_NAME)) allow.push(PLUGIN_NAME); + if (!loadPaths.includes(pluginPath)) loadPaths.push(pluginPath); + + execSync(`openclaw config set plugins.allow '${JSON.stringify(allow)}'`); + execSync(`openclaw config set plugins.load.paths '${JSON.stringify(loadPaths)}'`); + execSync(`openclaw config set plugins.entries.${PLUGIN_NAME}.enabled true`); + execSync(`openclaw config set plugins.entries.${PLUGIN_NAME}.config '{"enabled": true}'`); + + logOk('OpenClaw config updated'); + } catch (err) { + logErr('Failed to update OpenClaw config via `openclaw config set`'); + throw err; + } + + // 4. Summary + log('[4/4] Done!', 'cyan'); console.log(''); log('✓ Yonexus installed successfully!', 'green'); console.log(''); @@ -104,6 +125,23 @@ function install() { console.log(''); } +function getConfigValue(path) { + try { + const out = execSync(`openclaw config get ${path}`, { encoding: 'utf8' }).trim(); + if (!out || out === 'undefined' || out === 'null') return undefined; + try { return JSON.parse(out); } catch { return out; } + } catch { + return undefined; + } +} + +function ensureArray(value) { + if (Array.isArray(value)) return value; + if (value === undefined || value === null || value === '') return []; + return [value]; +} + + // ── Uninstall ─────────────────────────────────────────────────────────── function uninstall() { diff --git a/package.json b/package.json index 49279e3..fd9b696 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "dist/yonexus/index.js", "types": "dist/yonexus/index.d.ts", "scripts": { - "build": "tsc -p tsconfig.json && cp plugin.json dist/yonexus/plugin.json", + "build": "tsc -p tsconfig.json && cp plugin.json dist/yonexus/plugin.json && cp plugin/openclaw.plugin.json dist/yonexus/openclaw.plugin.json", "clean": "rm -rf dist", "prepare": "npm run clean && npm run build", "test:smoke": "tsx tests/smoke.ts", diff --git a/plugin/openclaw.plugin.json b/plugin/openclaw.plugin.json new file mode 100644 index 0000000..d87850f --- /dev/null +++ b/plugin/openclaw.plugin.json @@ -0,0 +1,13 @@ +{ + "id": "yonexus", + "name": "Yonexus", + "version": "0.2.0", + "description": "Organization hierarchy, agent identity management, query DSL, and scope memory for OpenClaw", + "configSchema": { + "type": "object", + "additionalProperties": true, + "properties": { + "enabled": { "type": "boolean", "default": true } + } + } +}