#!/usr/bin/env node const fs = require('fs'); const path = require('path'); const os = require('os'); function parseArgs(argv) { const args = { dryRun: false, list: false }; for (let i = 0; i < argv.length; i++) { const token = argv[i]; if (token === '--dry-run') args.dryRun = true; if (token === '--list') args.list = true; } return args; } function ensureDir(dirPath) { fs.mkdirSync(dirPath, { recursive: true }); } function copyRecursive(src, dest, dryRun) { const stat = fs.statSync(src); if (stat.isDirectory()) { ensureDir(dest); for (const name of fs.readdirSync(src)) { copyRecursive(path.join(src, name), path.join(dest, name), dryRun); } return; } ensureDir(path.dirname(dest)); if (!dryRun) fs.copyFileSync(src, dest); } function listSkills(skillsDir) { return fs.readdirSync(skillsDir) .filter(name => fs.existsSync(path.join(skillsDir, name, 'SKILL.md'))) .sort(); } function main() { const args = parseArgs(process.argv.slice(2)); const suiteRoot = __dirname; const skillsDir = path.join(suiteRoot, 'skills'); const skills = listSkills(skillsDir); const openclawRoot = path.join(os.homedir(), '.openclaw'); const targetSkillsRoot = path.join(openclawRoot, 'skills'); const targetWorkspaceRoot = path.join(openclawRoot, 'workspace', 'industry-trend-intelligence'); if (args.list) { console.log(skills.join('\n')); return; } console.log(`${args.dryRun ? '[DRY-RUN] ' : ''}Installing industry-trend-intelligence`); for (const skill of skills) { const src = path.join(skillsDir, skill); const dest = path.join(targetSkillsRoot, skill); console.log(`skill: ${skill} -> ${dest}`); copyRecursive(src, dest, args.dryRun); } const workspaceItems = [ 'README.md', 'deployment.md', 'openclaw-startup.md', 'skill-package-manifest.json', 'docs', 'memory-templates', 'scripts', 'install.js' ]; for (const item of workspaceItems) { const src = path.join(suiteRoot, item); if (!fs.existsSync(src)) continue; const dest = path.join(targetWorkspaceRoot, item); console.log(`workspace: ${item} -> ${dest}`); copyRecursive(src, dest, args.dryRun); } console.log(args.dryRun ? 'Dry run finished.' : 'Install finished. Restart OpenClaw to reload skills.'); } if (require.main === module) { try { main(); } catch (error) { console.error(error && error.stack ? error.stack : String(error)); process.exit(1); } }