From 3a495f8d6492560c4654f9e71de715d272c89b92 Mon Sep 17 00:00:00 2001 From: zhi Date: Thu, 5 Mar 2026 11:21:22 +0000 Subject: [PATCH] fix: create OpenClaw config if not exists and simplify install summary - Create ~/.openclaw/config.json if it doesn't exist - Automatically add plugin path to config - Simplify post-install steps (remove redundant 'add to profile' step) --- install.mjs | 66 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/install.mjs b/install.mjs index 9f3061f..a1ebfa4 100755 --- a/install.mjs +++ b/install.mjs @@ -460,36 +460,37 @@ async function configure(env) { log('\n Updating OpenClaw plugin configuration...', 'blue'); const openclawConfigPath = join(installDir, 'config.json'); - if (existsSync(openclawConfigPath)) { - try { + try { + let config = {}; + + // Load existing config if present + if (existsSync(openclawConfigPath)) { const configContent = readFileSync(openclawConfigPath, 'utf8'); - const 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 = []; - } - - // 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)); - logSuccess(`Added plugin path to OpenClaw config: ${skillsPath}`); - } else { - log(' Plugin path already in OpenClaw config', 'green'); - } - } catch (err) { - logWarning(`Failed to update OpenClaw config: ${err.message}`); + config = JSON.parse(configContent); } - } else { - logWarning(`OpenClaw config not found at ${openclawConfigPath}`); + + // 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 = []; + } + + // 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)); + logSuccess(`Added plugin path to OpenClaw config: ${skillsPath}`); + } else { + log(' Plugin path already in OpenClaw config', 'green'); + } + } 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'); } @@ -585,16 +586,13 @@ function printSummary(env) { log('Next steps:', 'blue'); console.log(''); - log('1. Add to your shell profile (~/.bashrc, ~/.zshrc):', 'yellow'); + log('1. Reload your shell or run:', 'yellow'); log(` source ${join(installDir, 'paddedcell.env')}`, 'cyan'); console.log(''); - log('2. Reload your shell or run:', 'yellow'); - log(` source ${join(installDir, 'paddedcell.env')}`, 'cyan'); - console.log(''); - log('3. Initialize pass_mgr (required before first use):', 'yellow'); + log('2. Initialize pass_mgr (required before first use):', 'yellow'); log(' pass_mgr admin init', 'cyan'); console.log(''); - log('4. Test pass_mgr:', 'yellow'); + log('3. Test pass_mgr:', 'yellow'); log(' pass_mgr set test_key mypass # Set a test password', 'cyan'); log(' pass_mgr get test_key # Retrieve password', 'cyan'); }