import{a as c,b as g}from"./chunk-74CEPOFO.js";var f={name:"ag-todo",summary:"manage project tasks and todos",usage:"ag-todo [add|list|update|rm] [args]",options:["    --help        display this help and exit"]},m={name:"ag-todo",async execute(e,n){if(g(e))return c(f);let u=e[0]||"list",i="/.ag-bash/todos.json",a=async()=>{if(!await n.fs.exists(i))return[];try{let t=await n.fs.readFile(i,"utf8");return JSON.parse(t)}catch{return[]}},r=async t=>{await n.fs.mkdir("/.ag-bash",{recursive:!0}),await n.fs.writeFile(i,JSON.stringify(t,null,2))};switch(u){case"list":{let t=await a();if(t.length===0)return{stdout:`No todos found.
`,stderr:"",exitCode:0};let o=`Project TODO List:
`;return t.forEach(d=>{let s=d.status==="done"?"[x]":d.status==="doing"?"[/]":"[ ]";o+=`${d.id.padEnd(4)} ${s} ${d.task}
`}),{stdout:o,stderr:"",exitCode:0}}case"add":{let t=e.slice(1).join(" ");if(!t)return{stdout:"",stderr:`ag-todo: missing task description
`,exitCode:1};let o=await a(),d={id:(o.length+1).toString(),task:t,status:"pending",createdAt:Date.now()};return o.push(d),await r(o),{stdout:`Added todo ${d.id}
`,stderr:"",exitCode:0}}case"update":{let t=e[1],o=e[2];if(!t||!["pending","doing","done"].includes(o))return{stdout:"",stderr:`Usage: ag-todo update <id> <pending|doing|done>
`,exitCode:1};let d=await a(),s=d.find(l=>l.id===t);return s?(s.status=o,await r(d),{stdout:`Updated todo ${t} status to ${o}
`,stderr:"",exitCode:0}):{stdout:"",stderr:`ag-todo: todo ${t} not found
`,exitCode:1}}case"rm":{let t=e[1];if(!t)return{stdout:"",stderr:`Usage: ag-todo rm <id>
`,exitCode:1};let o=await a(),d=o.length;return o=o.filter(s=>s.id!==t),o.length===d?{stdout:"",stderr:`ag-todo: todo ${t} not found
`,exitCode:1}:(await r(o),{stdout:`Removed todo ${t}
`,stderr:"",exitCode:0})}default:return{stdout:"",stderr:`ag-todo: unknown subcommand: ${u}
`,exitCode:1}}}};export{m as a};
