#!/usr/bin/env node
import {a as a$1}from'./chunk-LKAT7IAK.js';import'./chunk-XHJ27CER.js';import*as a from'fs';import*as h from'path';import o from'chalk';var E=`# Echoes - Error to Symbol Mapping
# When errors occur, they echo back to their source symbol.
# Run \`paradigm echo ERROR_CODE\` to look up context.

version: "1.0"

errors:
  # Example error mapping
  AUTH_REQUIRED:
    symbol: "^authenticated"
    location: "src/middleware/auth.ts"
    ripple:
      - "@checkout"
      - "@profile"
      - "@settings"
    resolution: "Ensure user token is passed in request headers"

  # Add your error mappings below
  # ERROR_CODE:
  #   symbol: "^portal-name"       # or signal: "!signal-name"
  #   location: "path/to/file.ts"
  #   ripple:
  #     - "@feature1"
  #     - "@feature2"
  #   resolution: "How to fix this error"
`;function b(t){let g={version:"1.0",errors:{}},p=t.split(`
`),c=null,n={},r=false;for(let l of p){if(l.trim().startsWith("#")||l.trim()==="")continue;let i=l.match(/^version:\s*"?([^"]+)"?/);if(i){g.version=i[1];continue}if(l.match(/^errors:\s*$/))continue;let e=l.match(/^  ([A-Z_][A-Z0-9_]*):\s*$/);if(e){c&&Object.keys(n).length>0&&(g.errors[c]=n),c=e[1],n={},r=false;continue}if(c){let s=l.match(/^\s{4}symbol:\s*"?([^"]+)"?/);if(s){n.symbol=s[1],r=false;continue}let f=l.match(/^\s{4}signal:\s*"?([^"]+)"?/);if(f){n.signal=f[1],r=false;continue}let u=l.match(/^\s{4}location:\s*"?([^"]+)"?/);if(u){n.location=u[1],r=false;continue}let y=l.match(/^\s{4}resolution:\s*"?([^"]+)"?/);if(y){n.resolution=y[1],r=false;continue}if(l.match(/^\s{4}ripple:\s*$/)){n.ripple=[],r=true;continue}if(r){let d=l.match(/^\s{6}-\s*"?([^"]+)"?/);if(d){n.ripple||(n.ripple=[]),n.ripple.push(d[1]);continue}}}}return c&&Object.keys(n).length>0&&(g.errors[c]=n),g}async function $(t,g,p={}){let c=process.cwd(),n=g?h.resolve(c,g):c,r=h.join(n,".paradigm","echoes.yaml");if(a$1.command("echo").debug("Looking up error code",{errorCode:t}),!a.existsSync(r)){if(p.json){console.log(JSON.stringify({found:false,error:"No echoes.yaml found"},null,2));return}a$1.command("echo").warn("No echoes.yaml found"),console.log(o.yellow(`
\u{1F4E2} No echoes.yaml found.
`)),console.log(o.gray("  Run `paradigm echo --init` to create one.\n"));return}let l=a.readFileSync(r,"utf8"),i=b(l);a$1.component("echoes-parser").debug("Echoes file parsed",{count:Object.keys(i.errors).length});let e=i.errors[t.toUpperCase()];if(!e){if(a$1.command("echo").warn("Error code not found",{errorCode:t}),p.json){console.log(JSON.stringify({found:false,errorCode:t.toUpperCase(),available:Object.keys(i.errors)},null,2));return}console.log(o.yellow(`
\u{1F4E2} No echo found for: ${t}
`));let s=Object.keys(i.errors);if(s.length>0){console.log(o.gray("  Available error codes:"));for(let f of s.slice(0,10)){let u=i.errors[f],y=u.symbol||u.signal||"";console.log(o.gray(`    ${f} \u2192 ${y}`));}s.length>10&&console.log(o.gray(`    ... and ${s.length-10} more`));}console.log("");return}if(a$1.command("echo").success("Error code found",{errorCode:t,hasSymbol:!!e.symbol,hasResolution:!!e.resolution}),p.json){console.log(JSON.stringify({found:true,errorCode:t.toUpperCase(),...e},null,2));return}console.log(o.blue(`
\u{1F4E2} Echo: ${o.cyan(t)}
`)),console.log(o.gray("\u2500".repeat(50))),e.symbol&&console.log(`  Symbol:     ${o.red(e.symbol)}`),e.signal&&console.log(`  Signal:     ${o.yellow(e.signal)}`),e.location&&console.log(`  Location:   ${o.gray(e.location)}`),e.ripple&&e.ripple.length>0&&console.log(`  Ripple:     ${e.ripple.map(s=>s.startsWith("@")?o.blue(s):s.startsWith("#")?o.green(s):s.startsWith("^")?o.red(s):o.gray(s)).join(", ")}`),console.log(""),e.resolution&&(console.log(o.white("Resolution:")),console.log(o.gray("\u2500".repeat(50))),console.log(o.green(`  ${e.resolution}`)),console.log("")),console.log(o.gray("Tip: Run `paradigm ripple "+(e.symbol||e.signal||"")+"` for full impact analysis.\n"));}async function w(t,g={}){let p=process.cwd(),c=t?h.resolve(p,t):p,n=h.join(c,".paradigm"),r=h.join(n,"echoes.yaml");if(a.existsSync(n)||a.mkdirSync(n,{recursive:true}),a.existsSync(r)&&!g.quiet){console.log(o.yellow(`
\u26A0\uFE0F  echoes.yaml already exists.
`)),console.log(o.gray(`  Path: ${r}
`));return}a.writeFileSync(r,E,"utf8"),g.quiet||(console.log(o.green(`
\u2713 Created .paradigm/echoes.yaml
`)),console.log(o.gray("  Edit this file to add error-to-symbol mappings.")),console.log(o.gray("  Then use `paradigm echo ERROR_CODE` to look them up.\n")));}async function S(t,g={}){let p=process.cwd(),c=t?h.resolve(p,t):p,n=h.join(c,".paradigm","echoes.yaml");if(!a.existsSync(n)){console.log(o.yellow(`
\u{1F4E2} No echoes.yaml found.
`)),console.log(o.gray("  Run `paradigm echo --init` to create one.\n"));return}let r=a.readFileSync(n,"utf8"),l=b(r);console.log(o.blue(`
\u{1F4E2} All Echoes
`)),console.log(o.gray("\u2500".repeat(50)));let i=Object.keys(l.errors);if(i.length===0){console.log(o.gray(`  No error mappings defined yet.
`));return}for(let e of i){let s=l.errors[e],f=s.symbol||s.signal||"",u=s.location?o.gray(` @ ${s.location}`):"";console.log(`  ${o.cyan(e.padEnd(20))} \u2192 ${f}${u}`);}console.log(o.gray(`
  Total: ${i.length} error mappings
`));}export{$ as echoCommand,w as echoInitCommand,S as echoListCommand};