Spaces:
Configuration error

File size: 2,047 Bytes
023064b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
 * Sync Version Script
 * Automatically synchronizes the version from package.json to:
 * - openclaw.plugin.json
 * - skills/generate-script/SKILL.md (frontmatter)
 * - skills/cli-operations/SKILL.md (frontmatter)
 */

const fs = require('fs');
const path = require('path');

const rootDir = path.join(__dirname, '..');
const pkgPath = path.join(rootDir, 'package.json');
const pluginPath = path.join(rootDir, 'openclaw.plugin.json');
const skillsDir = path.join(rootDir, 'skills');

if (!fs.existsSync(pkgPath)) {
    console.error('package.json not found');
    process.exit(1);
}

const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
const version = pkg.version;

console.log(`Syncing version ${version} to all metadata files...`);

// 1. Sync to openclaw.plugin.json
if (fs.existsSync(pluginPath)) {
    const plugin = JSON.parse(fs.readFileSync(pluginPath, 'utf8'));
    plugin.version = version;
    fs.writeFileSync(pluginPath, JSON.stringify(plugin, null, 2) + '\n');
    console.log('✓ Updated openclaw.plugin.json');
}

// 2. Sync to SKILL.md files
function updateSkillVersion(skillName, baseDirName) {
    const skillPath = path.join(rootDir, baseDirName, skillName, 'SKILL.md');
    if (fs.existsSync(skillPath)) {
        let content = fs.readFileSync(skillPath, 'utf8');
        // Match version: x.x.x in YAML frontmatter
        const updatedContent = content.replace(/^version:.*$/m, `version: ${version}`);
        if (content !== updatedContent) {
            fs.writeFileSync(skillPath, updatedContent);
            console.log(`✓ Updated ${baseDirName}/${skillName}/SKILL.md`);
        } else {
            console.log(`- ${baseDirName}/${skillName}/SKILL.md is already up to date`);
        }
    } else {
        console.warn(`! Skill not found: ${skillPath}`);
    }
}

updateSkillVersion('generate-script', 'skills');
updateSkillVersion('cli-operations', 'skills');
updateSkillVersion('generate-script', '.agent/skills');
updateSkillVersion('cli-operations', '.agent/skills');

console.log('Sync complete!');