"use strict";(()=>{var e={};e.id=1746,e.ids=[1746],e.modules={85890:e=>{e.exports=require("better-sqlite3")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},84770:e=>{e.exports=require("crypto")},92048:e=>{e.exports=require("fs")},20629:e=>{e.exports=require("fs/promises")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},5517:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>C,patchFetch:()=>v,requestAsyncStorage:()=>w,routeModule:()=>g,serverHooks:()=>y,staticGenerationAsyncStorage:()=>h});var a={};r.r(a),r.d(a,{GET:()=>x});var o=r(49303),i=r(88716),s=r(60670),n=r(87070),u=r(97425),d=r(75748),l=r(98636),c=r(20629),p=r.n(c),m=r(55315),f=r.n(m);async function x(e,{params:t}){try{let r=(0,u.n)();if(!(0,d.gU)(r,t.id))return n.NextResponse.json({error:`Worktree '${t.id}' not found`},{status:404});let a=e.nextUrl?.searchParams,o=a?.get("cliTool")||"all",i=await (0,l.e7)(t.id,o),s=(await Promise.all(i.map(async e=>{let t=f().basename(e),r=await p().stat(e),a=e.split(f().sep),o=a[a.length-2];return{filename:t,cliToolId:o,size:r.size,modifiedAt:r.mtime.toISOString()}}))).map(e=>e.filename);return n.NextResponse.json(s,{status:200})}catch(e){return console.error("Error fetching log files:",e),n.NextResponse.json({error:"Failed to fetch log files"},{status:500})}}let g=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/worktrees/[id]/logs/route",pathname:"/api/worktrees/[id]/logs",filename:"route",bundlePath:"app/api/worktrees/[id]/logs/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/logs/route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:w,staticGenerationAsyncStorage:h,serverHooks:y}=g,C="/api/worktrees/[id]/logs/route";function v(){return(0,s.patchFetch)({serverHooks:y,staticGenerationAsyncStorage:h})}},98636:(e,t,r)=>{r.d(t,{e7:()=>p,xN:()=>c});var a=r(20629),o=r.n(a),i=r(55315),s=r.n(i),n=r(73853);let u=(0,r(93346).Hb)("CM_LOG_DIR")||s().join(process.cwd(),"data","logs");function d(e="claude"){return s().join(u,e)}async function l(e="claude"){let t=d(e);try{await o().access(t)}catch{await o().mkdir(t,{recursive:!0})}}async function c(e,t,r,a="claude"){await l(a);let i=function(e,t="claude"){let r=(0,n.WU)(new Date,"yyyy-MM-dd"),a=`${e}-${r}.md`,o=d(t);return s().join(o,a)}(e,a),u=(0,n.WU)(new Date,"yyyy-MM-dd HH:mm:ss"),c="";try{c=await o().readFile(i,"utf-8")}catch{let t="claude"===a?"Claude Code":"codex"===a?"Codex CLI":"Gemini CLI";c=`# ${t} Conversation Log: ${e}

Created: ${u}

---

`}return c+=`## Conversation at ${u}

### User

${t}

### ${"claude"===a?"Claude":"codex"===a?"Codex":"Gemini"}

${r}

---

`,await o().writeFile(i,c,"utf-8"),i}async function p(e,t="all"){let r=[];for(let a of"all"===t?["claude","codex","gemini"]:[t]){await l(a);let t=d(a);try{let a=(await o().readdir(t)).filter(t=>t.startsWith(`${e}-`)&&t.endsWith(".md")).map(e=>s().join(t,e));r.push(...a)}catch{}}return r.sort().reverse()}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972,3853,7425],()=>r(5517));module.exports=a})();