Initial commit

This commit is contained in:
agent-skills 2026-03-14 03:25:50 +00:00
commit bd0c3ffe32
6 changed files with 142 additions and 0 deletions

View File

@ -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 }}

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
node_modules/
dist/
.env.local
*.skill

26
SKILL.md Normal file
View File

@ -0,0 +1,26 @@
---
name: my-skill
description: "TODO: describe what this skill does and when to use it."
---
# my-skill
TODO: one-line description.
> Auth (CLIENT_KEY) is loaded automatically from `~/.openclaw/.env`.
## Run
```bash
bun scripts/run.ts <command> [args] [--dry-run]
```
## Commands
| Command | Description |
|---------|-------------|
| `run <arg>` | TODO: describe |
## Output
Returns JSON: `{ "status": "success" | "failed", "data": ... }`

12
package.json Normal file
View File

@ -0,0 +1,12 @@
{
"name": "my-skill",
"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"
}
}

41
scripts/run.ts Normal file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bun
import type { Command } from '../src/index.ts';
import { run } from '../src/index.ts';
function printUsage(): void {
console.error(`Usage:
bun scripts/run.ts [--api-base=<url>] <command> [args...] [--dry-run]
Commands:
run <arg>
Config: ~/.openclaw/.env (CLIENT_KEY, API_BASE)
`);
}
async function main(): Promise<void> {
const positionals: string[] = [];
let dryRun = false;
for (const arg of process.argv.slice(2)) {
if (arg === '--dry-run') {
dryRun = true;
} else if (arg.startsWith('--api-base=')) {
process.env.API_BASE = arg.slice('--api-base='.length).trim();
} else if (arg === '-h' || arg === '--help') {
printUsage(); process.exit(0);
} else {
positionals.push(arg);
}
}
if (positionals.length < 1) { printUsage(); process.exit(1); }
const result = await run(positionals[0] as Command, positionals.slice(1), dryRun);
console.log(JSON.stringify(result, null, 2));
}
main().catch((err) => {
console.error(JSON.stringify({ status: 'failed', error: err instanceof Error ? err.message : String(err) }, null, 2));
process.exit(1);
});

42
src/index.ts Normal file
View File

@ -0,0 +1,42 @@
import {
createEnvConfig,
requestApiWithAutoRefresh,
type ApiResponse,
} from '@clawd/auth-runtime';
export type Command = 'run'; // TODO: add your commands
export interface RunResult {
status: 'success' | 'failed';
command: Command;
dryRun: boolean;
data?: unknown;
error?: string;
}
export async function run(
command: Command,
args: string[],
dryRun: boolean,
): Promise<RunResult> {
const config = createEnvConfig();
const apiBase = (process.env.API_BASE ?? 'https://api-gw-test.yuanwei-lnc.com').replace(/\/$/, '');
if (command === 'run') {
const response: ApiResponse = await requestApiWithAutoRefresh(
'POST',
`${apiBase}/your/endpoint`,
dryRun,
config,
JSON.stringify({ param: args[0] }),
);
if (response.status < 200 || response.status >= 300) {
return { status: 'failed', command, dryRun, error: `HTTP ${response.status}: ${response.body}` };
}
return { status: 'success', command, dryRun, data: JSON.parse(response.body) };
}
return { status: 'failed', command, dryRun, error: `unknown command: ${command}` };
}