// packages/skill 의 내용을 CLI 배포물 안(dist/skill)으로 복사한다. // 스킬 본문이 npm 패키지에 함께 실려야 npx 한 번으로 설치가 끝난다. import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; const here = path.dirname(fileURLToPath(import.meta.url)); const src = path.resolve(here, "../../skill"); const dest = path.resolve(here, "../dist/skill"); async function copyDir(from, to) { await fs.mkdir(to, { recursive: true }); for (const e of await fs.readdir(from, { withFileTypes: true })) { if (e.name === "node_modules" || e.name === "package.json") continue; const s = path.join(from, e.name); const d = path.join(to, e.name); if (e.isDirectory()) await copyDir(s, d); else await fs.copyFile(s, d); } } await fs.rm(dest, { recursive: true, force: true }); await copyDir(src, dest); // 스킬 버전은 CLI 버전과 항상 같다(changesets fixed 그룹) — 여기서 스탬프를 찍어 런타임 조회를 없앤다 const pkg = JSON.parse(await fs.readFile(path.resolve(here, "../package.json"), "utf8")); await fs.writeFile(path.join(dest, ".designpaca_version"), `${pkg.version}\n`, "utf8"); const count = (await fs.readdir(dest, { recursive: true })).length; console.log(`스킬 번들 완료: ${count}개 항목 → dist/skill`);