diff --git a/README.md b/README.md index edc3193..83bc957 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # hooks-transforms -Webhook payload transforms for OpenClaw skill deployment. Not a skill — a utility module. - -## skill-install - -Processes `skill-update` webhook payload and generates installation instructions. +Webhook payload transforms for OpenClaw. Clone directly into `~/.openclaw/hooks/transforms/`. ```bash -bun run scripts/run.ts skill-install '{"skills":[{"repo_url":"http://...","skill_slug":"my-skill"}]}' +git clone ~/.openclaw/hooks/transforms ``` + +## Files + +- `skill-install.ts` — Transform for `skill.allowlist.updated` webhook events diff --git a/package.json b/package.json deleted file mode 100644 index 548f3ec..0000000 --- a/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "hooks-transforms", - "version": "0.2.0", - "description": "Webhook payload transforms for OpenClaw skill deployment", - "type": "module", - "scripts": { - "run": "bun run scripts/run.ts" - } -} diff --git a/scripts/run.ts b/scripts/run.ts deleted file mode 100644 index 120cafd..0000000 --- a/scripts/run.ts +++ /dev/null @@ -1,13 +0,0 @@ -#!/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"}]}' -*/ - -run(command, commandArgs); diff --git a/src/index.ts b/skill-install.ts similarity index 79% rename from src/index.ts rename to skill-install.ts index 09571e7..8d8feda 100644 --- a/src/index.ts +++ b/skill-install.ts @@ -1,11 +1,13 @@ /** - * Webhook payload transforms for OpenClaw skill deployment. + * Transform for skill-update webhook. * - * Pure functions — no auth, no network calls, no external dependencies. + * 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 */ -export type Command = 'skill-install'; - interface SkillEntry { skill_id?: string; skill_slug?: string; @@ -16,15 +18,6 @@ interface SkillEntry { commit_sha?: string; } -export function run(command: Command, args: string[]) { - if (command === 'skill-install') { - const payload = args[0] ? JSON.parse(args[0]) : {}; - const result = transformSkillInstall(payload); - console.log(result.message); - return result; - } -} - export function transformSkillInstall(payload: Record) { const body = (payload.payload ?? payload) as Record; const skills = body.skills as SkillEntry[] | undefined; @@ -50,7 +43,6 @@ export function transformSkillInstall(payload: Record) { const dirName = skill_slug ?? repo_url.split("/").pop()?.replace(/\.git$/, "") ?? "unknown-skill"; const installPath = `~/clawd/skills/${dirName}`; - const subpath = repo_subpath ? `/${repo_subpath}` : ""; const skillDir = repo_subpath ? `${installPath}/${repo_subpath}` : installPath; lines.push(