From 888ed0e51ac3d87157c65c1c9da9033a65a6b288 Mon Sep 17 00:00:00 2001 From: zhi Date: Thu, 5 Mar 2026 12:10:04 +0000 Subject: [PATCH] fix: install script creates openclaw.plugin.json and index.js - Add writeFileSync import - Create manifest file during install if not exists - Create index.js entry point during install if not exists --- install.mjs | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/install.mjs b/install.mjs index 0b93e03..7e8e4db 100755 --- a/install.mjs +++ b/install.mjs @@ -12,7 +12,7 @@ */ import { execSync } from 'child_process'; -import { existsSync, mkdirSync, copyFileSync, chmodSync } from 'fs'; +import { existsSync, mkdirSync, copyFileSync, writeFileSync, chmodSync } from 'fs'; import { dirname, join, resolve } from 'path'; import { fileURLToPath } from 'url'; import { homedir, platform } from 'os'; @@ -317,6 +317,67 @@ async function installComponents(env) { // Create bin directory mkdirSync(binDir, { recursive: true }); + // Create openclaw.plugin.json if not exists + const manifestPath = join(__dirname, 'openclaw.plugin.json'); + if (!existsSync(manifestPath)) { + const manifest = { + id: PLUGIN_NAME, + name: 'PaddedCell', + version: '0.1.0', + description: 'Secure password management, safe execution, and coordinated restart', + entry: './index.js', + configSchema: { + type: 'object', + properties: { + enabled: { type: 'boolean', default: true } + } + }, + tools: [ + { + name: 'pcexec', + entry: './pcexec/dist/index.js', + description: 'Safe exec with password sanitization' + }, + { + name: 'safe_restart', + entry: './safe-restart/dist/index.js', + description: 'Safe coordinated restart' + } + ] + }; + writeFileSync(manifestPath, JSON.stringify(manifest, null, 2)); + logSuccess('Created openclaw.plugin.json'); + } + + // Create index.js if not exists + const indexPath = join(__dirname, 'index.js'); + if (!existsSync(indexPath)) { + const indexContent = `// PaddedCell Plugin Entry Point +export const id = '${PLUGIN_NAME}'; +export const name = 'PaddedCell'; +export const version = '0.1.0'; + +// Export tools (will be loaded by OpenClaw) +export { pcexec } from './pcexec/dist/index.js'; +export { + safeRestart, + createSafeRestartTool, + StatusManager, + createApiServer, + startApiServer +} from './safe-restart/dist/index.js'; + +// Default export +export default { + id, + name, + version, +}; +`; + writeFileSync(indexPath, indexContent); + logSuccess('Created index.js'); + } + // Install pass_mgr binary log(' Installing pass_mgr binary...', 'blue'); const passMgrSource = join(__dirname, 'pass_mgr', 'dist', 'pass_mgr');