#!/usr/bin/env node
import {d}from'./chunk-DOCDDDTD.js';import'./chunk-JQKKVAAN.js';import {a as a$1}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as a from'fs';import*as c from'path';import*as j from'js-yaml';import p from'chalk';import $ from'ora';async function x(y){let r=process.cwd(),e=$();console.log(p.blue(`
  Paradigm Sync LLMs
`)),e.start("Loading .paradigm/ configuration...");let i=d(r);i||(e.fail("No .paradigm/ directory found"),console.log(p.gray("\nRun `paradigm init` to initialize Paradigm in this project.\n")),a$1.command("sync-llms").error("Missing .paradigm/ directory"),process.exit(1)),e.succeed(`Loaded configuration for ${p.cyan(i.projectName)}`),a$1.command("sync-llms").debug("Configuration loaded",{projectName:i.projectName}),e.start("Reading navigator.yaml...");let g=null,h=c.join(r,".paradigm","navigator.yaml");if(a.existsSync(h))try{let n=a.readFileSync(h,"utf8");g=j.load(n),e.succeed("Loaded navigator.yaml");}catch{e.warn("Could not parse navigator.yaml, skipping key files section"),a$1.command("sync-llms").warn("Failed to parse navigator.yaml");}else e.info("No navigator.yaml found, skipping key files section");let o=null,f=c.join(r,".paradigm","flows.yaml");if(a.existsSync(f))try{let n=a.readFileSync(f,"utf8");o=j.load(n);}catch{a$1.command("sync-llms").warn("Failed to parse flows.yaml");}let d$1=null,m=c.join(r,"portal.yaml");if(a.existsSync(m))try{let n=a.readFileSync(m,"utf8");d$1=j.load(n);}catch{a$1.command("sync-llms").warn("Failed to parse portal.yaml");}e.start("Generating llms.txt...");let w=b(i,g,o,d$1),t=y.output?c.resolve(r,y.output):c.join(r,"llms.txt");try{a.writeFileSync(t,w,"utf8"),e.succeed(p.green("Generated llms.txt")),console.log(p.gray(`
  Path: ${c.relative(r,t)}`)),console.log(""),a$1.command("sync-llms").success("llms.txt generated",{path:t});}catch(n){e.fail(p.red("Failed to write llms.txt")),a$1.command("sync-llms").error("Write failed",{error:n.message}),process.exit(1);}}function b(y,r,e,i){let{config:g,projectName:h}=y,o=[];o.push(`# ${g.project||h}`);let f=g["agent-guidelines"]?.overview?.trim();f&&o.push(`> ${f.replace(/\n/g,`
> `)}`);let d=g["symbol-system"];if(d){let t=["## Symbols",""];t.push("| Prefix | Name | Description |"),t.push("|--------|------|-------------|");for(let[n,s]of Object.entries(d))["#","$","^","!","~"].includes(n)&&t.push(`| \`${n}\` | ${s.name} | ${s.description} |`);o.push(t.join(`
`));}if(r?.key_files){let t=["## Key Files",""];for(let[n,s]of Object.entries(r.key_files))if(s&&s.length>0){t.push(`### ${n.charAt(0).toUpperCase()+n.slice(1)}`),t.push("");for(let u of s)t.push(`- \`${u}\``);t.push("");}t.length>2&&o.push(t.join(`
`).trimEnd());}if(e?.flows&&Object.keys(e.flows).length>0){let t=["## Flows",""];for(let[n,s]of Object.entries(e.flows)){let u=s.name||s.description||n,F=s.trigger?` (trigger: \`${s.trigger}\`)`:"";t.push(`- **$${n}**: ${u}${F}`);}o.push(t.join(`
`));}if(i?.gates&&Object.keys(i.gates).length>0){let t=["## Gates",""];t.push("| Gate | Description |"),t.push("|------|-------------|");for(let[n,s]of Object.entries(i.gates)){let u=s.description||"";t.push(`| \`^${n}\` | ${u} |`);}if(i.routes&&Object.keys(i.routes).length>0){t.push(""),t.push("### Protected Routes"),t.push("");for(let[n,s]of Object.entries(i.routes))t.push(`- \`${n}\`: ${s.join(", ")}`);}o.push(t.join(`
`));}let m=g.conventions;if(m&&m.length>0){let t=["## Conventions",""];for(let n of m)t.push(`- ${n}`);o.push(t.join(`
`));}let w=["## Further Reading","","- `.paradigm/specs/` - Detailed specifications","- `.paradigm/docs/` - Commands, patterns, troubleshooting","- `CLAUDE.md` - AI agent instructions (Claude Code)","- `AGENTS.md` - Universal agent instructions"];return o.push(w.join(`
`)),o.join(`

`)+`
`}export{x as syncLlmsCommand};