#!/usr/bin/env node
import {c as c$1}from'./chunk-4TXOVRWD.js';import*as o from'fs';import*as l from'path';var f="<!-- HORIZON:START -->",c="<!-- HORIZON:END -->";function m(s,r,p={}){let e=[];if(e.push("# Project Context (via Paradigm)"),e.push(""),r&&(e.push(`Project: ${r}`),e.push("")),s["agent-guidelines"]?.overview&&(e.push(s["agent-guidelines"].overview),e.push("")),e.push("This project uses Paradigm for structured AI context:"),e.push("- `.purpose` files define features, components, and context"),e.push("- `portal.yaml` files define authorization topology"),e.push("- `.premise` files aggregate the project symbol graph"),e.push(""),s["agent-guidelines"]?.["how-to-use"]?.length){e.push("## How to Use Paradigm"),e.push("");for(let t of s["agent-guidelines"]["how-to-use"])e.push(`- ${t}`);e.push("");}e.push("## Symbol System"),e.push(""),e.push("Use these prefixes to reference project elements:"),e.push(""),e.push("| Symbol | Name | Owner | Examples |"),e.push("|--------|------|-------|----------|");let u=s["symbol-system"];if(u)for(let[t,n]of Object.entries(u)){let i=n.examples?.slice(0,2).join(", ")||"";e.push(`| \`${t}\` | ${n.name} | ${n.owner} | ${i} |`);}if(e.push(""),e.push("### Symbol Details"),e.push(""),u)for(let[t,n]of Object.entries(u))e.push(`- **\`${t}\` ${n.name}** (${n.owner}): ${n.description}`);if(e.push(""),s.states&&Object.keys(s.states).length>0){e.push("## Defined States"),e.push("");for(let[t,n]of Object.entries(s.states))if(typeof n=="object"&&n!==null)for(let[i,a]of Object.entries(n)){let h=y(a);e.push(`- \`%${t}.${i}\` - ${h}`);}e.push("");}if(s["agent-guidelines"]?.["update-rules"]?.length){e.push("## When to Update Paradigm Files"),e.push("");for(let t of s["agent-guidelines"]["update-rules"])e.push(`- ${t}`);e.push("");}if(s.conventions?.length){e.push("## Conventions"),e.push("");for(let t of s.conventions)e.push(`- ${t}`);e.push("");}if(e.push("## Paradigm Commands"),e.push(""),e.push("| Command | Description |"),e.push("|---------|-------------|"),e.push("| `paradigm init` | Initialize Paradigm in a project |"),e.push("| `paradigm status` | Show project symbol status |"),e.push("| `paradigm visualize` | Open the Dreamscape visualizer |"),e.push("| `paradigm purpose validate` | Validate .purpose files |"),e.push("| `paradigm gate validate` | Validate portal.yaml files |"),e.push("| `paradigm premise aggregate` | Aggregate all symbols |"),e.push("| `paradigm cursorrules` | Regenerate this .cursorrules file |"),e.push(""),s["purpose-required"]?.length){e.push("## Purpose File Locations"),e.push(""),e.push("`.purpose` files should exist in:");for(let t of s["purpose-required"])e.push(`- \`${t.pattern}\` (depth: ${t.depth})`);e.push("");}return p.withScan&&(e.push(""),e.push(c$1({projectName:r,customInstructions:p.scanInstructions})),e.push("")),e.push("---"),e.push("*Generated by Paradigm. Update `.paradigm` config and run `paradigm cursorrules` to regenerate.*"),e.join(`
`)}function y(s){if(typeof s=="boolean")return "Boolean state";if(typeof s=="object"&&s!==null){let r=s;if(r.description)return String(r.description);if(r.type)return r.type==="enum"&&Array.isArray(r.values)?`${r.type} (${r.values.join(", ")})`:String(r.type)}return "State"}function b(s,r,p,e,u={}){if(p==="skip")return {success:true,path:"",message:"Skipped .cursorrules generation"};let t=l.join(s,".cursorrules"),n=m(r,e,u);if(p==="append"&&o.existsSync(t)){let i=o.readFileSync(t,"utf8"),a=i.indexOf(f),h=i.indexOf(c),d=`
${f}
${n}
${c}
`;return a!==-1&&h!==-1?i=i.substring(0,a)+d+i.substring(h+c.length):i=i.trimEnd()+`
`+d,o.writeFileSync(t,i,"utf8"),{success:true,path:t,message:"Updated .cursorrules with Paradigm section"}}else return o.writeFileSync(t,n,"utf8"),{success:true,path:t,message:"Created .cursorrules"}}function S(s){return o.existsSync(l.join(s,".cursorrules"))}function $(s){return o.existsSync(l.join(s,".paradigm"))}export{m as a,b,S as c,$ as d};