#!/usr/bin/env node
import {d,a,c as c$1,b}from'./chunk-W7C6FFMO.js';import'./chunk-4TXOVRWD.js';import {c,d as d$1,e as e$1}from'./chunk-JQKKVAAN.js';import'./chunk-XHJ27CER.js';import*as s from'fs';import*as o from'path';import e from'chalk';import j from'ora';async function D(d$2,a$1){let r=d$2?o.resolve(d$2):process.cwd(),t=o.basename(r),u=o.join(r,".paradigm"),i=j();if(!d(r))if(a$1.init){i.start("Creating .paradigm config...");let n=c(t);s.writeFileSync(u,d$1(n),"utf8"),i.succeed(e.green(".paradigm config created"));}else console.log(e.red(`
\u274C No .paradigm file found.`)),console.log(e.gray(`
Run with --init to create a default .paradigm config:`)),console.log(e.cyan(`  paradigm cursorrules --init
`)),process.exit(1);let c$2;try{let n=s.readFileSync(u,"utf8");c$2=e$1(n);}catch(n){let b=n;console.log(e.red(`
\u274C Failed to parse .paradigm: ${b.message}
`)),process.exit(1);}let S=s.existsSync(o.join(r,".paradigm","scan-index.json"))||s.existsSync(o.join(r,".paradigm-scan-index.json")),l=a$1.withScan||S;if(a$1.preview){let n=a(c$2,t,{withScan:l});console.log(e.blue(`
--- Preview of .cursorrules content ---
`)),console.log(n),console.log(e.blue(`
--- End preview ---
`));return}let f="create";a$1.append?f="append":!a$1.force&&c$1(r)&&(console.log(e.yellow(`
\u26A0\uFE0F  .cursorrules already exists.`)),console.log(e.gray(`Use --force to overwrite, or --append to add Paradigm section.
`)),process.exit(1)),i.start("Generating .cursorrules...");let g=b(r,c$2,f,t,{withScan:l});g.success?(i.succeed(e.green(g.message)),console.log(e.gray(`
  Path: ${g.path}`)),l&&console.log(e.gray("  Includes: Scan protocol")),console.log()):(i.fail(e.red("Failed to generate .cursorrules")),process.exit(1));}export{D as cursorrrulesCommand};