import path from "node:path"; import { exists } from "../fsx.ts"; import type { FileAction, TargetAdapter, TargetContext } from "../types.ts"; import { anyExists, referenceActions, rewriteRefPaths } from "./common.ts"; /** 본문과 references 가 함께 놓이는 루트 (본문 경로 재작성 기준) */ const REF_PREFIX = ".cursor/rules/designpaca"; /** * Cursor — .cursor/rules/designpaca.mdc. * .mdc 프론트매터는 SKILL.md 와 필드가 다르다(description/globs/alwaysApply)므로 변환한다. * * Windsurf 는 이 파일을 읽지 않는다(.windsurf/rules/*.md 를 쓴다) — 별도 어댑터로 분리했다. */ export const cursor: TargetAdapter = { id: "cursor", label: "Cursor", hint: ".cursor/rules/designpaca.mdc — 프로젝트 단위", // Cursor 의 전역 규칙은 파일이 아니라 앱 설정(User Rules)이라 프로젝트 범위만 지원한다 scopes: ["project"], async detect(ctx: TargetContext) { return anyExists([path.join(ctx.cwd, ".cursor"), path.join(ctx.home, ".cursor")]); }, async plan(ctx: TargetContext) { const rulesDir = path.join(ctx.cwd, ".cursor", "rules"); const mdc = path.join(rulesDir, "designpaca.mdc"); const refRoot = path.join(rulesDir, "designpaca"); const header = [ "---", `description: ${ctx.skill.description}`, "globs:", "alwaysApply: false", "---", "", ].join("\n"); const actions: FileAction[] = [ { kind: "write", path: mdc, content: header + rewriteRefPaths(ctx.skill.body, REF_PREFIX), }, ...referenceActions(refRoot, ctx.skill), ]; return { target: this.id, scope: ctx.scope, root: rulesDir, actions, alreadyInstalled: await exists(mdc), }; }, };