#!/usr/bin/env bun // consulting-report skill tool: launch the Next.js dev server for live preview. // // Usage: // pal cli skill run consulting-report dev import { spawnSync } from "node:child_process"; import { constants as fsConstants } from "node:fs"; import { access } from "node:fs/promises"; import { join, resolve } from "node:path"; async function exists(p: string): Promise { try { await access(p, fsConstants.F_OK); return true; } catch { return false; } } async function dev(reportDir: string): Promise { const dir = resolve(reportDir); const pkg = join(dir, "package.json"); if (!(await exists(pkg))) { throw new Error(`not a scaffolded report (missing package.json): ${dir}`); } const result = spawnSync("bun", ["run", "dev"], { cwd: dir, stdio: "inherit", shell: true, }); return result.status ?? 1; } async function run(argv: string[] = process.argv.slice(2)): Promise { if (argv.length === 0) { console.error("usage: dev.ts "); process.exit(1); } const status = await dev(argv[0]); process.exit(status); } if (import.meta.main) { await run(); }