fix: use openclaw config command for configuration management

- Use 'openclaw config get/set --json' instead of direct file manipulation
- Correctly remove plugin path from OpenClaw config during uninstall
- Remove pass_mgr binary during uninstall
This commit is contained in:
zhi
2026-03-05 11:25:05 +00:00
parent 3a495f8d64
commit 62044ab948

View File

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