diff --git a/install.mjs b/install.mjs index a1ebfa4..62f85ae 100755 --- a/install.mjs +++ b/install.mjs @@ -458,33 +458,28 @@ async function configure(env) { // Update OpenClaw plugins.load.paths configuration log('\n Updating OpenClaw plugin configuration...', 'blue'); - const openclawConfigPath = join(installDir, 'config.json'); try { - let config = {}; + const skillsPath = join(installDir, 'skills', 'paddedcell'); - // Load existing config if present - if (existsSync(openclawConfigPath)) { - const configContent = readFileSync(openclawConfigPath, 'utf8'); - config = JSON.parse(configContent); - } - - // Ensure plugins.load.paths exists - if (!config.plugins) { - config.plugins = {}; - } - if (!config.plugins.load) { - config.plugins.load = {}; - } - if (!config.plugins.load.paths) { - config.plugins.load.paths = []; + // Get current plugins.load.paths using openclaw config + let currentPaths = []; + try { + const result = execSync('openclaw config get plugins.load.paths --json 2>/dev/null || echo "[]"', { + encoding: 'utf8', + cwd: __dirname + }).trim(); + currentPaths = JSON.parse(result); + } catch { + currentPaths = []; } // Add paddedcell skills path if not already present - const skillsPath = join(installDir, 'skills', 'paddedcell'); - if (!config.plugins.load.paths.includes(skillsPath)) { - config.plugins.load.paths.push(skillsPath); - writeFileSync(openclawConfigPath, JSON.stringify(config, null, 2)); + if (!currentPaths.includes(skillsPath)) { + currentPaths.push(skillsPath); + execSync(`openclaw config set plugins.load.paths --json '${JSON.stringify(currentPaths)}'`, { + cwd: __dirname + }); logSuccess(`Added plugin path to OpenClaw config: ${skillsPath}`); } else { log(' Plugin path already in OpenClaw config', 'green'); @@ -492,7 +487,7 @@ async function configure(env) { } catch (err) { logWarning(`Failed to update OpenClaw config: ${err.message}`); log(' Please manually add the following to your OpenClaw config:', 'yellow'); - log(` plugins.load.paths: ["${join(installDir, 'skills', 'paddedcell')}"]`, 'cyan'); + log(` openclaw config set plugins.load.paths --json '["${join(installDir, 'skills', 'paddedcell')}"]'`, 'cyan'); } } @@ -664,6 +659,38 @@ async function uninstall(env) { } } + // Remove plugin path from OpenClaw config + log('\n Removing plugin path from OpenClaw config...', 'blue'); + try { + const skillsPath = join(installDir, 'skills', 'paddedcell'); + + // Get current plugins.load.paths + let currentPaths = []; + try { + const result = execSync('openclaw config get plugins.load.paths --json 2>/dev/null || echo "[]"', { + encoding: 'utf8', + cwd: __dirname + }).trim(); + currentPaths = JSON.parse(result); + } catch { + currentPaths = []; + } + + // Remove paddedcell skills path + const index = currentPaths.indexOf(skillsPath); + if (index > -1) { + currentPaths.splice(index, 1); + execSync(`openclaw config set plugins.load.paths --json '${JSON.stringify(currentPaths)}'`, { + cwd: __dirname + }); + logSuccess(`Removed plugin path from OpenClaw config`); + } else { + log(' Plugin path not found in OpenClaw config', 'yellow'); + } + } catch (err) { + logWarning(`Failed to update OpenClaw config: ${err.message}`); + } + // Check for admin key directory const adminKeyDir = join(homedir(), '.pass_mgr'); if (existsSync(adminKeyDir)) {