diff --git a/package.json b/package.json index 6dca683..b1670a2 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "node": ">=20.0.0" }, "scripts": { - "build": "tsc --project tsconfig.json", + "build": "tsc --project tsconfig.json && node scripts/copy-prompts.js", "build:watch": "tsc --project tsconfig.json --watch", "dev": "tsx watch src/index.ts", "start": "node dist/index.js", diff --git a/scripts/copy-prompts.js b/scripts/copy-prompts.js new file mode 100644 index 0000000..0d03f16 --- /dev/null +++ b/scripts/copy-prompts.js @@ -0,0 +1,38 @@ +#!/usr/bin/env node +/** + * copy-prompts.js + * + * Copies Markdown prompt files from src/prompts/ → dist/prompts/. + * Run as part of the build pipeline after `tsc`. + * + * Why this exists: + * TypeScript's compiler only emits .js/.d.ts files — it ignores .md assets. + * PromptLoader resolves prompts from dist/prompts/ at runtime, so we must + * mirror the src/prompts/ tree into dist/ after every build. + * + * Usage: + * node scripts/copy-prompts.js + */ + +import { cpSync, mkdirSync } from 'fs'; +import { join, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const root = join(__dirname, '..'); +const src = join(root, 'src', 'prompts'); +const dest = join(root, 'dist', 'prompts'); + +mkdirSync(dest, { recursive: true }); + +cpSync(src, dest, { + recursive: true, + filter: (source) => { + // Only copy .md files and directories + return source.endsWith('.md') || !source.includes('.'); + }, +}); + +console.log(`✅ Prompts copied: ${src} → ${dest}`);