import { existsSync, mkdirSync, writeFileSync } from "node:fs"; import { homedir } from "node:os"; import { dirname, join } from "node:path"; import skillMain from "../../skills/seal-home/SKILL.md" with { type: "text" }; import agentOpenAi from "../../skills/seal-home/agents/openai.yaml" with { type: "text" }; import refRuleLightweight from "../../skills/seal-home/references/rule-lightweight.md" with { type: "text" }; import refApprovalBadCases from "../../skills/seal-home/references/approval-bad-cases.md" with { type: "text" }; import refCli from "../../skills/seal-home/references/cli.md" with { type: "text" }; import refApprovalRunLightweight from "../../skills/seal-home/references/approval-run-lightweight.md" with { type: "text" }; import refApprovalAttachmentTrace from "../../skills/seal-home/references/approval-attachment-trace.md" with { type: "text" }; import refCustomerFeedbackRuleRemediation from "../../skills/seal-home/references/customer-feedback-rule-remediation.md" with { type: "text" }; import refHoseEnterpriseAuth from "../../skills/seal-home/references/hose-enterprise-auth.md" with { type: "text" }; export const EMBEDDED_SKILL_FILES: Record = { "SKILL.md": skillMain, "agents/openai.yaml": agentOpenAi, "references/rule-lightweight.md": refRuleLightweight, "references/approval-bad-cases.md": refApprovalBadCases, "references/cli.md": refCli, "references/approval-run-lightweight.md": refApprovalRunLightweight, "references/approval-attachment-trace.md": refApprovalAttachmentTrace, "references/customer-feedback-rule-remediation.md": refCustomerFeedbackRuleRemediation, "references/hose-enterprise-auth.md": refHoseEnterpriseAuth }; export function getSkillContent(): string { return EMBEDDED_SKILL_FILES["SKILL.md"] || ""; } export function getDefaultGlobalSkillDir(): string { return join(homedir(), ".agents", "skills", "seal-home"); } 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(); if (existsSync(globalDir)) { installSkillFiles(globalDir); return { synced: true, targetDir: globalDir }; } return { synced: false }; }