#!/usr/bin/env node
import {a,c}from'./chunk-7YTAA6XA.js';import'./chunk-XHJ27CER.js';import r from'chalk';import*as e from'fs';import*as i from'path';import*as k from'js-yaml';var D=".paradigm/assessments";async function j(_){let y=process.cwd(),a$1=i.join(y,D,"arcs"),f=!!_.dryRun;if(!e.existsSync(a$1)){console.log(r.yellow(`
  No assessments found at .paradigm/assessments/arcs/
`));return}let $=e.readdirSync(a$1).filter(o=>e.statSync(i.join(a$1,o)).isDirectory()),l=0,d=0,t=[];for(let o of $){let c$1=i.join(a$1,o,"entries");if(!e.existsSync(c$1))continue;let S=e.readdirSync(c$1).filter(n=>n.endsWith(".yaml")&&!n.endsWith(".migrated"));for(let n of S){let m=i.join(c$1,n);try{let g=e.readFileSync(m,"utf8"),s=k.load(g),w=[`arc:${s.arc_id}`,`assessment:${s.type}`,...s.tags||[],"migrated-from-assessment"],A={id:"",type:s.type,timestamp:s.date,author:s.author,title:s.title,summary:s.summary,body:s.body,symbols_touched:s.symbols||[],tags:w,linked_lore:s.linked_lore,linked_tasks:s.linked_tasks,linked_commits:s.linked_commits},p={...a(A),id:""};f?console.log(r.gray(`  [dry-run] Would migrate: ${s.id} \u2192 lore (arc:${s.arc_id})`)):(await c(y,p),e.renameSync(m,m.replace(".yaml",".migrated")),console.log(r.green(`  Migrated: ${s.id} \u2192 ${p.id} (arc:${s.arc_id})`))),l++,t.includes(s.arc_id)||t.push(s.arc_id);}catch(g){console.error(r.red(`  Failed to migrate ${n}: ${g}`)),d++;}}}console.log(),console.log(f?r.yellow(`  Dry run complete: ${l} entries would be migrated from ${t.length} arcs`):r.green(`  Migration complete: ${l} entries migrated from ${t.length} arcs`)),d>0&&console.log(r.yellow(`  ${d} entries skipped due to errors`)),console.log(r.gray(`  Arcs preserved as tags: ${t.map(o=>`arc:${o}`).join(", ")}`)),console.log();}export{j as loreMigrateAssessmentsCommand};