feat: add Renovate regex manager and postUpgradeTasks for skill auto-sync
This commit is contained in:
1 parent
c9891ba184
commit
f840ed2cf7
4 files changed
+92
-2
No files matched your search
+4
-2
@@ -7,14 +7,16 @@
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"plugin:build": "npm run build && openclaw plugins build --entry ./dist/index.js",
|
||||
"plugin:validate": "npm run build && openclaw plugins validate --entry ./dist/index.js",
|
||||
"test": "vitest run --config ./vitest.config.ts"
|
||||
"test": "vitest run --config ./vitest.config.ts",
|
||||
"sync:skills": "node scripts/sync-skills.mjs"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"skills",
|
||||
"openclaw.plugin.json",
|
||||
"README.md"
|
||||
"README.md",
|
||||
"skills.json"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"openclaw": ">=2026.5.17"
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
],
|
||||
"customManagers": [
|
||||
{
|
||||
"customType": "regex",
|
||||
"managerFilePatterns": [
|
||||
"skills\\.json$"
|
||||
],
|
||||
"matchStrings": [
|
||||
"\"//\":\\s*\"renovate:\\s*datasource=(?<datasource>[a-z-]+)\\s+depName=(?<depName>[^\\s]+)\",\\s*\"version\":\\s*\"(?<currentValue>[^\"]+)\""
|
||||
]
|
||||
}
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchDatasources": [
|
||||
"github-releases"
|
||||
],
|
||||
"matchPackageNames": [
|
||||
"bitwarden/agent-access"
|
||||
],
|
||||
"postUpgradeTasks": {
|
||||
"commands": [
|
||||
"node scripts/sync-skills.mjs"
|
||||
],
|
||||
"fileFilters": [
|
||||
"skills/**",
|
||||
"skills.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = path.resolve(__dirname, "..");
|
||||
const configPath = path.join(rootDir, "skills.json");
|
||||
|
||||
async function main() {
|
||||
const raw = await fs.readFile(configPath, "utf-8");
|
||||
const config = JSON.parse(raw);
|
||||
|
||||
console.log(`[sync-skills] Found ${Object.keys(config.skills).length} skill definitions`);
|
||||
|
||||
for (const [name, def] of Object.entries(config.skills)) {
|
||||
const { version, url, destination } = def;
|
||||
const targetUrl = url.replace("{version}", version);
|
||||
const destPath = path.join(rootDir, destination);
|
||||
|
||||
console.log(`[sync-skills] Syncing ${name} (${version}) from ${targetUrl}...`);
|
||||
const res = await fetch(targetUrl);
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to fetch ${targetUrl}: HTTP ${res.status} ${res.statusText}`);
|
||||
}
|
||||
|
||||
const content = await res.text();
|
||||
if (!content.trim()) {
|
||||
throw new Error(`Fetched empty content for ${name}`);
|
||||
}
|
||||
|
||||
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
||||
await fs.writeFile(destPath, content, "utf-8");
|
||||
console.log(`[sync-skills] ✓ Updated ${destination} (${content.length} bytes)`);
|
||||
}
|
||||
|
||||
console.log("[sync-skills] All skills synced successfully.");
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error("[sync-skills] Error:", err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"skills": {
|
||||
"agent-access": {
|
||||
"//": "renovate: datasource=github-releases depName=bitwarden/agent-access",
|
||||
"version": "v0.11.0",
|
||||
"url": "https://raw.githubusercontent.com/bitwarden/agent-access/{version}/examples/skills/agent-access/SKILL.md",
|
||||
"destination": "skills/agent-access/SKILL.md"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user