#!/usr/bin/env node
import{a as c}from"./chunk-RLNOQILG.js";import"./chunk-KGOUQS5A.js";var g={name:"git",async execute(o,m){let e=m.fs,r;try{r=await import("./isomorphic-git-6IFRDB3E.js")}catch{return{exitCode:1,stdout:"",stderr:`Error: isomorphic-git not installed. Run 'pnpm add isomorphic-git' to enable native git.
`}}let n=o[0];if(!n)return{exitCode:1,stdout:"",stderr:`usage: git <command> [<args>]
`};let a={promises:{readFile:t=>e.readFileBuffer(t),writeFile:(t,i)=>e.writeFile(t,i),mkdir:t=>e.mkdir(t,{recursive:!0}),rmdir:t=>e.rm(t,{recursive:!0}),unlink:t=>e.rm(t),readdir:t=>e.readdir(t),stat:t=>e.stat(t),lstat:t=>e.lstat(t)}};try{let t=m.cwd||"/";switch(n){case"init":return await r.init({fs:a,dir:t}),{exitCode:0,stdout:`Initialized empty Git repository in ${t}
`,stderr:""};case"add":{let i=o[1];if(!i)throw new Error("Nothing specified, nothing added.");return await r.add({fs:a,dir:t,filepath:i}),{exitCode:0,stdout:"",stderr:""}}case"commit":{let i=o.indexOf("-m"),d=i!==-1?o[i+1]:"Commit from Ag-Bash";return{exitCode:0,stdout:`[main ${(await r.commit({fs:a,dir:t,message:d,author:{name:"Ag-Bash Agent",email:"agent@ag-bash.local"}})).slice(0,7)}] ${d}
`,stderr:""}}case"log":return{exitCode:0,stdout:(await r.log({fs:a,dir:t})).map(s=>`commit ${s.oid}
Author: ${s.commit.author.name}
Date: ${new Date(s.commit.author.timestamp*1e3).toLocaleString()}

    ${s.commit.message}
`).join(`
`),stderr:""};default:return{exitCode:1,stdout:"",stderr:`git: '${n}' is not yet implemented in Ag-Bash native git.
`}}}catch(t){return{exitCode:1,stdout:"",stderr:`fatal: ${c(t.message)}
`}}}};export{g as gitCommand};
