Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
|
|
@ -0,0 +1,17 @@
|
||||||
|
name: register-skill-release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
register:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: http://192.168.0.108:3030/agent-skills/shared-actions/register-skill@main
|
||||||
|
with:
|
||||||
|
client_key: ${{ secrets.CLIENT_KEY }}
|
||||||
11
README.md
11
README.md
|
|
@ -1,11 +0,0 @@
|
||||||
# hooks-transforms
|
|
||||||
|
|
||||||
Webhook payload transforms for OpenClaw. Clone directly into `~/.openclaw/hooks/transforms/`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone <repo-url> ~/.openclaw/hooks/transforms
|
|
||||||
```
|
|
||||||
|
|
||||||
## Files
|
|
||||||
|
|
||||||
- `skill-install.ts` — Transform for `skill.allowlist.updated` webhook events
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
name: hooks-transforms
|
||||||
|
description: "OpenClaw hooks transform modules for webhook payload processing"
|
||||||
|
---
|
||||||
|
> Auth (CLIENT_KEY) is loaded automatically from `~/.openclaw/.env`.
|
||||||
|
|
||||||
|
## Transforms
|
||||||
|
|
||||||
|
### skill-install
|
||||||
|
|
||||||
|
Transform for `skill-update` webhook events. Processes payload containing skill git repos and generates installation instructions.
|
||||||
|
|
||||||
|
**Expected payload:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"skills": [
|
||||||
|
{
|
||||||
|
"repo_url": "http://...",
|
||||||
|
"skill_slug": "my-skill",
|
||||||
|
"git_ref": "v1.0.0",
|
||||||
|
"repo_subpath": "optional/subpath"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 1,
|
||||||
|
"workspaces": {
|
||||||
|
"": {
|
||||||
|
"name": "hooks-transforms",
|
||||||
|
"dependencies": {
|
||||||
|
"@clawd/auth-runtime": "git+http://192.168.0.108:3030/agent-skills/auth-runtime.git",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@clawd/auth-runtime": ["@clawd/auth-runtime@git+http://192.168.0.108:3030/agent-skills/auth-runtime.git#70cf86889eecbe9c4649bb072cd971c3a560e889", {}, "70cf86889eecbe9c4649bb072cd971c3a560e889"],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "hooks-transforms",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"run": "bun run scripts/run.ts",
|
||||||
|
"build": "bun build scripts/run.ts --outfile dist/run.js --target bun"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@clawd/auth-runtime": "git+http://192.168.0.108:3030/agent-skills/auth-runtime.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env bun
|
||||||
|
import { run } from "../src/index.ts";
|
||||||
|
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const command = args[0] as "skill-install";
|
||||||
|
const commandArgs = args.slice(1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Usage:
|
||||||
|
bun run scripts/run.ts skill-install '{"skills":[{"repo_url":"http://...","skill_slug":"my-skill"}]}'
|
||||||
|
*/
|
||||||
|
|
||||||
|
await run(command, commandArgs, false);
|
||||||
|
|
@ -1,12 +1,6 @@
|
||||||
/**
|
import { createEnvConfig, requestApiWithAutoRefresh } from '@clawd/auth-runtime';
|
||||||
* Transform for skill-update webhook.
|
|
||||||
*
|
export type Command = 'skill-install';
|
||||||
* Expected payload (skill.allowlist.updated event):
|
|
||||||
* skills[].repo_url (required) — git clone URL
|
|
||||||
* skills[].skill_slug (required) — used as directory name under ~/clawd/skills/
|
|
||||||
* skills[].git_ref (optional) — branch/tag to checkout
|
|
||||||
* skills[].repo_subpath (optional) — subdirectory within the repo containing the skill
|
|
||||||
*/
|
|
||||||
|
|
||||||
interface SkillEntry {
|
interface SkillEntry {
|
||||||
skill_id?: string;
|
skill_id?: string;
|
||||||
|
|
@ -18,7 +12,18 @@ interface SkillEntry {
|
||||||
commit_sha?: string;
|
commit_sha?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformSkillInstall(payload: Record<string, unknown>) {
|
export async function run(command: Command, args: string[], dryRun: boolean) {
|
||||||
|
const config = createEnvConfig();
|
||||||
|
|
||||||
|
if (command === 'skill-install') {
|
||||||
|
const payload = args[0] ? JSON.parse(args[0]) : {};
|
||||||
|
const result = transformSkillInstall(payload);
|
||||||
|
console.log(result.message);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function transformSkillInstall(payload: Record<string, unknown>) {
|
||||||
const body = (payload.payload ?? payload) as Record<string, unknown>;
|
const body = (payload.payload ?? payload) as Record<string, unknown>;
|
||||||
const skills = body.skills as SkillEntry[] | undefined;
|
const skills = body.skills as SkillEntry[] | undefined;
|
||||||
|
|
||||||
|
|
@ -43,6 +48,8 @@ export function transformSkillInstall(payload: Record<string, unknown>) {
|
||||||
|
|
||||||
const dirName = skill_slug ?? repo_url.split("/").pop()?.replace(/\.git$/, "") ?? "unknown-skill";
|
const dirName = skill_slug ?? repo_url.split("/").pop()?.replace(/\.git$/, "") ?? "unknown-skill";
|
||||||
const installPath = `~/clawd/skills/${dirName}`;
|
const installPath = `~/clawd/skills/${dirName}`;
|
||||||
|
const refFlag = git_ref ? ` --branch ${git_ref}` : "";
|
||||||
|
const subpath = repo_subpath ? `/${repo_subpath}` : "";
|
||||||
const skillDir = repo_subpath ? `${installPath}/${repo_subpath}` : installPath;
|
const skillDir = repo_subpath ? `${installPath}/${repo_subpath}` : installPath;
|
||||||
|
|
||||||
lines.push(
|
lines.push(
|
||||||
|
|
@ -55,7 +62,7 @@ export function transformSkillInstall(payload: Record<string, unknown>) {
|
||||||
` Otherwise: git clone ${repo_url} ${installPath} && cd ${installPath} && git checkout ${git_ref ?? "HEAD"}`,
|
` Otherwise: git clone ${repo_url} ${installPath} && cd ${installPath} && git checkout ${git_ref ?? "HEAD"}`,
|
||||||
` 2. cd ${skillDir}`,
|
` 2. cd ${skillDir}`,
|
||||||
` 3. If install.sh exists: bash install.sh`,
|
` 3. If install.sh exists: bash install.sh`,
|
||||||
` Otherwise: npm install (if package.json exists) or skip`,
|
` Otherwise: bun install`,
|
||||||
` 4. Reply with one line: installed/updated + skill name + version.`,
|
` 4. Reply with one line: installed/updated + skill name + version.`,
|
||||||
``,
|
``,
|
||||||
);
|
);
|
||||||
Loading…
Reference in New Issue