74 lines
2.8 KiB
TypeScript
74 lines
2.8 KiB
TypeScript
import { mkdirSync, writeFileSync } from "node:fs";
|
|
import { homedir } from "node:os";
|
|
import { dirname, join } from "node:path";
|
|
|
|
import skillMain from "../../skills/hose-use/SKILL.md" with { type: "text" };
|
|
import agentOpenAi from "../../skills/hose-use/agents/openai.yaml" with { type: "text" };
|
|
import refAuth from "../../skills/hose-use/references/auth.md" with { type: "text" };
|
|
import refBill from "../../skills/hose-use/references/bill.md" with { type: "text" };
|
|
import refWorkflow from "../../skills/hose-use/references/workflow.md" with { type: "text" };
|
|
import refService from "../../skills/hose-use/references/service.md" with { type: "text" };
|
|
import refContact from "../../skills/hose-use/references/contact.md" with { type: "text" };
|
|
import refTask from "../../skills/hose-use/references/task.md" with { type: "text" };
|
|
import refMessage from "../../skills/hose-use/references/message.md" with { type: "text" };
|
|
import refDimension from "../../skills/hose-use/references/dimension.md" with { type: "text" };
|
|
import refRole from "../../skills/hose-use/references/role.md" with { type: "text" };
|
|
import refApproval from "../../skills/hose-use/references/approval.md" with { type: "text" };
|
|
|
|
export const EMBEDDED_SKILL_FILES: Record<string, string> = {
|
|
"SKILL.md": skillMain,
|
|
"agents/openai.yaml": agentOpenAi,
|
|
"references/auth.md": refAuth,
|
|
"references/approval.md": refApproval,
|
|
"references/bill.md": refBill,
|
|
"references/contact.md": refContact,
|
|
"references/task.md": refTask,
|
|
"references/message.md": refMessage,
|
|
"references/dimension.md": refDimension,
|
|
"references/role.md": refRole,
|
|
"references/workflow.md": refWorkflow,
|
|
"references/service.md": refService,
|
|
};
|
|
|
|
export function getSkillContent(): string {
|
|
return EMBEDDED_SKILL_FILES["SKILL.md"] || "";
|
|
}
|
|
|
|
export function getDefaultGlobalSkillDir(): string {
|
|
return join(homedir(), ".agents", "skills", "hose-use");
|
|
}
|
|
|
|
export function getAgentSkillCandidates(): string[] {
|
|
return [
|
|
join(homedir(), ".agents", "skills", "hose-use"),
|
|
join(homedir(), ".gemini", "antigravity", "skills", "hose-use"),
|
|
join(homedir(), ".codex", "skills", "hose-use"),
|
|
];
|
|
}
|
|
|
|
export function installSkillFiles(targetDir: string = getDefaultGlobalSkillDir()): {
|
|
targetDir: string;
|
|
files: string[];
|
|
} {
|
|
mkdirSync(targetDir, { recursive: true });
|
|
const installed: string[] = [];
|
|
|
|
for (const [relPath, content] of Object.entries(EMBEDDED_SKILL_FILES)) {
|
|
const fullPath = join(targetDir, relPath);
|
|
mkdirSync(dirname(fullPath), { recursive: true });
|
|
writeFileSync(fullPath, content, "utf8");
|
|
installed.push(relPath);
|
|
}
|
|
|
|
return {
|
|
targetDir,
|
|
files: installed,
|
|
};
|
|
}
|
|
|
|
export function syncGlobalSkillIfPresent(): { synced: boolean; targetDir?: string } {
|
|
const globalDir = getDefaultGlobalSkillDir();
|
|
installSkillFiles(globalDir);
|
|
return { synced: true, targetDir: globalDir };
|
|
}
|