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
This commit is contained in:
zhi
2026-03-05 12:10:04 +00:00
parent c366958a37
commit 888ed0e51a

View File

@@ -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');