#!/usr/bin/env node
import{a as u}from"./chunk-RLNOQILG.js";import"./chunk-KGOUQS5A.js";var f={name:"ag-notebook",execute:async(s,o)=>{if(!o.bash)return{stdout:"",stderr:`Bash instance not found
`,exitCode:1};let i=s[0],a=s[1];if(!i||!a)return{stdout:"",stderr:`Usage: ag-notebook <read|edit|add> <path> [args]
`,exitCode:1};try{let n=o.fs.resolvePath(o.cwd,a);if(!await o.fs.exists(n))return{stdout:"",stderr:`File not found: ${a} (resolved to ${n})
`,exitCode:1};let r=JSON.parse(await o.fs.readFile(n,"utf8"));switch(i){case"read":{let e=`Notebook: ${a}

`;return r.cells.forEach((t,d)=>{e+=`--- Cell ${d} [${t.cell_type}] ---
`,e+=`${t.source.join("")}

`}),{stdout:e,stderr:"",exitCode:0}}case"edit":{let e=parseInt(s[2],10),t=s.slice(3).join(" ");return Number.isNaN(e)||!t?{stdout:"",stderr:`Usage: ag-notebook edit <path> <index> <content>
`,exitCode:1}:e<0||e>=r.cells.length?{stdout:"",stderr:`Invalid cell index
`,exitCode:1}:(r.cells[e].source=[t],await o.fs.writeFile(n,JSON.stringify(r,null,2)),{stdout:`Successfully updated cell ${e}.
`,stderr:"",exitCode:0})}case"add":{let e=s[2],t=s.slice(3).join(" ");if(!e||!t)return{stdout:"",stderr:`Usage: ag-notebook add <path> <code|markdown> <content>
`,exitCode:1};let d={cell_type:e,source:[t],metadata:Object.create(null)};return e==="code"&&(d.outputs=[],d.execution_count=null),r.cells.push(d),await o.fs.writeFile(n,JSON.stringify(r,null,2)),{stdout:`Successfully added new ${e} cell.
`,stderr:"",exitCode:0}}default:return{stdout:"",stderr:`Unknown subcommand: ${i}
`,exitCode:1}}}catch(n){return{stdout:"",stderr:`Error: ${u(n.message)}
`,exitCode:1}}}};export{f as agNotebookCommand};
