mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 09:50:23 +00:00
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { createSyntheticSourceInfo, type Skill } from "./skills/skill-contract.js";
|
|
|
|
export async function writeSkill(params: {
|
|
dir: string;
|
|
name: string;
|
|
description: string;
|
|
body?: string;
|
|
}) {
|
|
const { dir, name, description, body } = params;
|
|
await fs.mkdir(dir, { recursive: true });
|
|
await fs.writeFile(
|
|
path.join(dir, "SKILL.md"),
|
|
`---
|
|
name: ${name}
|
|
description: ${description}
|
|
---
|
|
|
|
${body ?? `# ${name}\n`}
|
|
`,
|
|
"utf-8",
|
|
);
|
|
}
|
|
|
|
export function createCanonicalFixtureSkill(params: {
|
|
name: string;
|
|
description: string;
|
|
filePath: string;
|
|
baseDir: string;
|
|
source: string;
|
|
disableModelInvocation?: boolean;
|
|
}): Skill {
|
|
return {
|
|
name: params.name,
|
|
description: params.description,
|
|
filePath: params.filePath,
|
|
baseDir: params.baseDir,
|
|
source: params.source,
|
|
sourceInfo: createSyntheticSourceInfo(params.filePath, {
|
|
source: params.source,
|
|
baseDir: params.baseDir,
|
|
scope: "project",
|
|
origin: "top-level",
|
|
}),
|
|
disableModelInvocation: params.disableModelInvocation ?? false,
|
|
};
|
|
}
|