From 4b1e7f68acbc89cfc81dd2edfcf72a9504d0b06e Mon Sep 17 00:00:00 2001 From: Patoo <262265744+patoo0x@users.noreply.github.com> Date: Fri, 20 Mar 2026 12:45:27 -0400 Subject: [PATCH] fix(build): copy prompt .md assets to dist after tsc (ENG-232) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TypeScript compiler does not copy non-.ts assets. PromptLoader resolves prompts from dist/prompts/ at runtime — without this copy step, the directory was missing after a clean build, causing prompt load failures. Fix: - Add scripts/copy-prompts.js: mirrors src/prompts/ → dist/prompts/ - Wire into build script: 'tsc && node scripts/copy-prompts.js' Result: single canonical dist/prompts/ path, no duplication, build verified clean (11 .md files copied across 3 subdirs). Closes lnflash/pulse#39 Resolves ENG-232 --- package.json | 2 +- scripts/copy-prompts.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 scripts/copy-prompts.js 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}`);