mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 22:23:42 +00:00
refactor(agent): dedupe harness and command workflows
This commit is contained in:
50
src/agents/skills-install.download-test-utils.ts
Normal file
50
src/agents/skills-install.download-test-utils.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
export function setTempStateDir(workspaceDir: string): string {
|
||||
const stateDir = path.join(workspaceDir, "state");
|
||||
process.env.OPENCLAW_STATE_DIR = stateDir;
|
||||
return stateDir;
|
||||
}
|
||||
|
||||
export async function writeDownloadSkill(params: {
|
||||
workspaceDir: string;
|
||||
name: string;
|
||||
installId: string;
|
||||
url: string;
|
||||
archive: "tar.gz" | "tar.bz2" | "zip";
|
||||
stripComponents?: number;
|
||||
targetDir: string;
|
||||
}): Promise<string> {
|
||||
const skillDir = path.join(params.workspaceDir, "skills", params.name);
|
||||
await fs.mkdir(skillDir, { recursive: true });
|
||||
const meta = {
|
||||
openclaw: {
|
||||
install: [
|
||||
{
|
||||
id: params.installId,
|
||||
kind: "download",
|
||||
url: params.url,
|
||||
archive: params.archive,
|
||||
extract: true,
|
||||
stripComponents: params.stripComponents,
|
||||
targetDir: params.targetDir,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
await fs.writeFile(
|
||||
path.join(skillDir, "SKILL.md"),
|
||||
`---
|
||||
name: ${params.name}
|
||||
description: test skill
|
||||
metadata: ${JSON.stringify(meta)}
|
||||
---
|
||||
|
||||
# ${params.name}
|
||||
`,
|
||||
"utf-8",
|
||||
);
|
||||
await fs.writeFile(path.join(skillDir, "runner.js"), "export {};\n", "utf-8");
|
||||
return skillDir;
|
||||
}
|
||||
Reference in New Issue
Block a user