From 9814f4b15c5cdf43f8787e3476a6bfe81aa3a2be Mon Sep 17 00:00:00 2001 From: ywkj Date: Fri, 20 Mar 2026 07:03:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20strip=20skill=20artifacts=20?= =?UTF-8?q?=E2=80=94=20this=20is=20a=20utility,=20not=20a=20skill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove SKILL.md, register-skill workflow, bun.lock - Remove @clawd/auth-runtime dependency (not needed for pure transforms) - Remove build script (no bundling needed) - Add README.md Co-Authored-By: Claude Opus 4.6 --- .forgejo/workflows/register-skill-release.yml | 17 ------------- README.md | 11 ++++++++ SKILL.md | 25 ------------------- bun.lock | 15 ----------- package.json | 9 +++---- scripts/run.ts | 2 +- src/index.ts | 15 +++++------ 7 files changed, 23 insertions(+), 71 deletions(-) delete mode 100644 .forgejo/workflows/register-skill-release.yml create mode 100644 README.md delete mode 100644 SKILL.md delete mode 100644 bun.lock diff --git a/.forgejo/workflows/register-skill-release.yml b/.forgejo/workflows/register-skill-release.yml deleted file mode 100644 index c01abb1..0000000 --- a/.forgejo/workflows/register-skill-release.yml +++ /dev/null @@ -1,17 +0,0 @@ -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 }} diff --git a/README.md b/README.md new file mode 100644 index 0000000..edc3193 --- /dev/null +++ b/README.md @@ -0,0 +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. + +```bash +bun run scripts/run.ts skill-install '{"skills":[{"repo_url":"http://...","skill_slug":"my-skill"}]}' +``` diff --git a/SKILL.md b/SKILL.md deleted file mode 100644 index a2170ae..0000000 --- a/SKILL.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -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" - } - ] -} -``` diff --git a/bun.lock b/bun.lock deleted file mode 100644 index b0cc2e6..0000000 --- a/bun.lock +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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"], - } -} diff --git a/package.json b/package.json index eb74894..548f3ec 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,9 @@ { "name": "hooks-transforms", - "version": "0.1.0", + "version": "0.2.0", + "description": "Webhook payload transforms for OpenClaw skill deployment", "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" + "run": "bun run scripts/run.ts" } } diff --git a/scripts/run.ts b/scripts/run.ts index 224f10f..120cafd 100644 --- a/scripts/run.ts +++ b/scripts/run.ts @@ -10,4 +10,4 @@ Usage: bun run scripts/run.ts skill-install '{"skills":[{"repo_url":"http://...","skill_slug":"my-skill"}]}' */ -await run(command, commandArgs, false); +run(command, commandArgs); diff --git a/src/index.ts b/src/index.ts index e08a1a1..09571e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,8 @@ -import { createEnvConfig, requestApiWithAutoRefresh } from '@clawd/auth-runtime'; +/** + * Webhook payload transforms for OpenClaw skill deployment. + * + * Pure functions — no auth, no network calls, no external dependencies. + */ export type Command = 'skill-install'; @@ -12,9 +16,7 @@ interface SkillEntry { commit_sha?: string; } -export async function run(command: Command, args: string[], dryRun: boolean) { - const config = createEnvConfig(); - +export function run(command: Command, args: string[]) { if (command === 'skill-install') { const payload = args[0] ? JSON.parse(args[0]) : {}; const result = transformSkillInstall(payload); @@ -23,7 +25,7 @@ export async function run(command: Command, args: string[], dryRun: boolean) { } } -function transformSkillInstall(payload: Record) { +export function transformSkillInstall(payload: Record) { const body = (payload.payload ?? payload) as Record; const skills = body.skills as SkillEntry[] | undefined; @@ -48,7 +50,6 @@ function transformSkillInstall(payload: Record) { const dirName = skill_slug ?? repo_url.split("/").pop()?.replace(/\.git$/, "") ?? "unknown-skill"; 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; @@ -62,7 +63,7 @@ function transformSkillInstall(payload: Record) { ` Otherwise: git clone ${repo_url} ${installPath} && cd ${installPath} && git checkout ${git_ref ?? "HEAD"}`, ` 2. cd ${skillDir}`, ` 3. If install.sh exists: bash install.sh`, - ` Otherwise: bun install`, + ` Otherwise: npm install (if package.json exists) or skip`, ` 4. Reply with one line: installed/updated + skill name + version.`, ``, );