refactor: flatten to match ~/.openclaw/hooks/transforms/ layout
Repo root is now directly clonable into ~/.openclaw/hooks/transforms/. skill-install.ts at root, no src/scripts/package.json wrapper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9814f4b15c
commit
62959edc91
12
README.md
12
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 <repo-url> ~/.openclaw/hooks/transforms
|
||||
```
|
||||
|
||||
## Files
|
||||
|
||||
- `skill-install.ts` — Transform for `skill.allowlist.updated` webhook events
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
@ -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<string, unknown>) {
|
||||
const body = (payload.payload ?? payload) as Record<string, unknown>;
|
||||
const skills = body.skills as SkillEntry[] | undefined;
|
||||
|
|
@ -50,7 +43,6 @@ export function transformSkillInstall(payload: Record<string, unknown>) {
|
|||
|
||||
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(
|
||||
Loading…
Reference in New Issue