fix(obsidian-kb): restore files and shorten description

This commit is contained in:
OpenClaw Agent
2026-02-07 05:32:26 +08:00
parent 8bce4ac23b
commit a0e43a5136
97 changed files with 1024 additions and 9216 deletions
-36
View File
@@ -1,36 +0,0 @@
#!/usr/bin/env node
import { Command } from "commander";
import ora from "ora";
import * as fs from "fs";
import * as path from "path";
import { generateWebhook } from "./index";
const program = new Command();
program
.name("ai-webhook")
.description("Generate webhook handlers with retry logic")
.version("1.0.0")
.argument("<event>", "Webhook event description (e.g. 'stripe payment succeeded')")
.option("-f, --framework <name>", "Framework: express, fastify, nextjs", "express")
.option("-o, --output <path>", "Output file path")
.action(async (event: string, options: { framework: string; output?: string }) => {
const spinner = ora("Generating webhook handler...").start();
try {
const result = await generateWebhook(event, options.framework);
spinner.succeed("Webhook handler generated!");
if (options.output) {
fs.writeFileSync(path.resolve(options.output), result, "utf-8");
console.log(` Written to ${options.output}`);
} else {
console.log("\n" + result);
}
} catch (err: any) {
spinner.fail(`Error: ${err.message}`);
process.exit(1);
}
});
program.parse();
-29
View File
@@ -1,29 +0,0 @@
import OpenAI from "openai";
const openai = new OpenAI();
export async function generateWebhook(eventDescription: string, framework: string = "express"): Promise<string> {
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{
role: "system",
content: `You generate production-ready webhook handler code.
Rules:
- Include signature verification
- Add exponential backoff retry logic
- Handle idempotency (dedup by event ID)
- Proper error handling and logging
- Type-safe where possible
- Framework: ${framework}
- Include both the handler and a retry utility
- Return ONLY the code, no explanations`
},
{ role: "user", content: `Generate a webhook handler for: ${eventDescription}` }
],
temperature: 0.3,
});
const result = response.choices[0].message.content?.trim() || "";
return result.replace(/^```[\w]*\n?/, "").replace(/\n?```$/, "");
}