Skip to content

Commit f3795eb

Browse files
committed
fix(install): register plugin in slots, entries and installs of openclaw.json
The install scripts previously only wrote plugins.allow and plugins.enabled, missing the slots, entries and installs registration. This caused OpenClaw gateway to not auto-load the plugin on restart. Now the scripts write: - plugins.slots.memory = pluginId - plugins.entries[pluginId].enabled = true (preserving existing config) - plugins.installs[pluginId] with full npm resolution metadata - Clean up stale contextEngine slot from previous versions Made-with: Cursor
1 parent 121695d commit f3795eb

2 files changed

Lines changed: 86 additions & 10 deletions

File tree

apps/memos-local-openclaw/install.ps1

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,21 @@ function Update-OpenClawConfig {
148148
param(
149149
[string]$OpenClawHome,
150150
[string]$ConfigPath,
151-
[string]$PluginId
151+
[string]$PluginId,
152+
[string]$InstallPath,
153+
[string]$Spec
152154
)
153155

154156
Write-Info "Updating OpenClaw config..."
155157
New-Item -ItemType Directory -Path $OpenClawHome -Force | Out-Null
156158
$nodeScript = @'
157159
const fs = require("fs");
160+
const path = require("path");
158161
159162
const configPath = process.argv[2];
160163
const pluginId = process.argv[3];
164+
const installPath = process.argv[4];
165+
const spec = process.argv[5];
161166
162167
let config = {};
163168
if (fs.existsSync(configPath)) {
@@ -187,14 +192,48 @@ if (!config.plugins.allow.includes(pluginId)) {
187192
// Clean up stale contextEngine slot from previous versions
188193
if (config.plugins.slots && config.plugins.slots.contextEngine) {
189194
delete config.plugins.slots.contextEngine;
190-
if (Object.keys(config.plugins.slots).length === 0) {
191-
delete config.plugins.slots;
192-
}
193195
}
194196
197+
// Register plugin in memory slot
198+
if (!config.plugins.slots || typeof config.plugins.slots !== "object") {
199+
config.plugins.slots = {};
200+
}
201+
config.plugins.slots.memory = pluginId;
202+
203+
// Ensure plugin entry is enabled (preserve existing config if present)
204+
if (!config.plugins.entries || typeof config.plugins.entries !== "object") {
205+
config.plugins.entries = {};
206+
}
207+
if (!config.plugins.entries[pluginId] || typeof config.plugins.entries[pluginId] !== "object") {
208+
config.plugins.entries[pluginId] = {};
209+
}
210+
config.plugins.entries[pluginId].enabled = true;
211+
212+
// Register plugin in installs so gateway auto-loads it on restart
213+
if (!config.plugins.installs || typeof config.plugins.installs !== "object") {
214+
config.plugins.installs = {};
215+
}
216+
const pkgJsonPath = path.join(installPath, "package.json");
217+
let resolvedName, resolvedVersion;
218+
if (fs.existsSync(pkgJsonPath)) {
219+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
220+
resolvedName = pkg.name;
221+
resolvedVersion = pkg.version;
222+
}
223+
config.plugins.installs[pluginId] = {
224+
source: "npm",
225+
spec,
226+
installPath,
227+
...(resolvedVersion ? { version: resolvedVersion } : {}),
228+
...(resolvedName ? { resolvedName } : {}),
229+
...(resolvedVersion ? { resolvedVersion } : {}),
230+
...(resolvedName && resolvedVersion ? { resolvedSpec: `${resolvedName}@${resolvedVersion}` } : {}),
231+
installedAt: new Date().toISOString(),
232+
};
233+
195234
fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
196235
'@
197-
$nodeScript | & node - $ConfigPath $PluginId
236+
$nodeScript | & node - $ConfigPath $PluginId $InstallPath $Spec
198237
Write-Success "OpenClaw config updated: $ConfigPath"
199238
}
200239

@@ -320,7 +359,7 @@ if (-not (Test-Path $ExtensionDir)) {
320359
exit 1
321360
}
322361

323-
Update-OpenClawConfig -OpenClawHome $OpenClawHome -ConfigPath $OpenClawConfigPath -PluginId $PluginId
362+
Update-OpenClawConfig -OpenClawHome $OpenClawHome -ConfigPath $OpenClawConfigPath -PluginId $PluginId -InstallPath $ExtensionDir -Spec $PackageSpec
324363

325364
Write-Success "Restarting OpenClaw Gateway..."
326365
& npx openclaw gateway run --port $Port --force

apps/memos-local-openclaw/install.sh

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,14 @@ OPENCLAW_CONFIG_PATH="${OPENCLAW_HOME}/openclaw.json"
215215
update_openclaw_config() {
216216
info "Update OpenClaw config, 更新 OpenClaw 配置..."
217217
mkdir -p "${OPENCLAW_HOME}"
218-
node - "${OPENCLAW_CONFIG_PATH}" "${PLUGIN_ID}" <<'NODE'
218+
node - "${OPENCLAW_CONFIG_PATH}" "${PLUGIN_ID}" "${EXTENSION_DIR}" "${PACKAGE_SPEC}" <<'NODE'
219219
const fs = require('fs');
220+
const path = require('path');
220221
221222
const configPath = process.argv[2];
222223
const pluginId = process.argv[3];
224+
const installPath = process.argv[4];
225+
const spec = process.argv[5];
223226
224227
let config = {};
225228
if (fs.existsSync(configPath)) {
@@ -249,11 +252,45 @@ if (!config.plugins.allow.includes(pluginId)) {
249252
// Clean up stale contextEngine slot from previous versions
250253
if (config.plugins.slots && config.plugins.slots.contextEngine) {
251254
delete config.plugins.slots.contextEngine;
252-
if (Object.keys(config.plugins.slots).length === 0) {
253-
delete config.plugins.slots;
254-
}
255255
}
256256
257+
// Register plugin in memory slot
258+
if (!config.plugins.slots || typeof config.plugins.slots !== 'object') {
259+
config.plugins.slots = {};
260+
}
261+
config.plugins.slots.memory = pluginId;
262+
263+
// Ensure plugin entry is enabled (preserve existing config if present)
264+
if (!config.plugins.entries || typeof config.plugins.entries !== 'object') {
265+
config.plugins.entries = {};
266+
}
267+
if (!config.plugins.entries[pluginId] || typeof config.plugins.entries[pluginId] !== 'object') {
268+
config.plugins.entries[pluginId] = {};
269+
}
270+
config.plugins.entries[pluginId].enabled = true;
271+
272+
// Register plugin in installs so gateway auto-loads it on restart
273+
if (!config.plugins.installs || typeof config.plugins.installs !== 'object') {
274+
config.plugins.installs = {};
275+
}
276+
const pkgJsonPath = path.join(installPath, 'package.json');
277+
let resolvedName, resolvedVersion;
278+
if (fs.existsSync(pkgJsonPath)) {
279+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
280+
resolvedName = pkg.name;
281+
resolvedVersion = pkg.version;
282+
}
283+
config.plugins.installs[pluginId] = {
284+
source: 'npm',
285+
spec,
286+
installPath,
287+
...(resolvedVersion ? { version: resolvedVersion } : {}),
288+
...(resolvedName ? { resolvedName } : {}),
289+
...(resolvedVersion ? { resolvedVersion } : {}),
290+
...(resolvedName && resolvedVersion ? { resolvedSpec: `${resolvedName}@${resolvedVersion}` } : {}),
291+
installedAt: new Date().toISOString(),
292+
};
293+
257294
fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
258295
NODE
259296
success "OpenClaw config updated, OpenClaw 配置已更新: ${OPENCLAW_CONFIG_PATH}"

0 commit comments

Comments
 (0)