coder-config 0.45.4 → 0.45.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coder-config",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.5",
|
|
4
4
|
"description": "Configuration manager for AI coding tools - Claude Code, Gemini CLI, Codex CLI, Antigravity. Manage MCPs, rules, permissions, memory, and workstreams.",
|
|
5
5
|
"author": "regression.io",
|
|
6
6
|
"main": "config-loader.js",
|
|
@@ -3003,7 +3003,7 @@ ${Mr.plan}
|
|
|
3003
3003
|
|
|
3004
3004
|
`),Mr.iterationHistory&&(Zr+=`=== Recent Iterations ===
|
|
3005
3005
|
${Mr.iterationHistory}
|
|
3006
|
-
`),Mr.transcript=Zr;const qn=await ue.tuneLoopPrompt(Qr,Le.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,Mr);qn.success?(await ue.updateLoop(Le.id,{task:{original:qn.tunedPrompt}}),Y.success("Prompt tuned and loop updated"),we(!1),await Pt(Le.id),Cr()):Y.error(qn.error||"Failed to tune prompt")}catch(Qr){Y.error(Qr.message)}finally{$(!1),Ke(null)}},Wo=async()=>{Le&&(we(!1),await gr(Le.id),Ke(null))},ee=async te=>{try{O(!0);const Me=await ue.createLoop(te,{workstreamId:q||null,projectPath:(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:parseInt(G,10)||50,completionPromise:K||"DONE"});Me.success?(Y.success("Loop created"),C(!1),H(""),z(""),J(De),F(dt),Q(!1),Cr()):Y.error(Me.error||"Failed to create loop")}catch(Me){Y.error(Me.message)}finally{O(!1)}},Ie=async te=>{if(Us.needsInstall){Lt(te),tr("start"),As(!0);return}await He(te)},He=async te=>{try{const Me=await ue.startLoop(te);Me.success&&Me.loop?(Y.success("Loop started - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to start loop")}catch(Me){Y.error(Me.message)}},Ot=async()=>{try{Vt(!0);const te=await ue.installRalphLoopPlugin();te.success?(Y.success("ralph-loop plugin installed"),fs({installed:!0,scope:"user",needsInstall:!1}),As(!1),nt&&(ir==="resume"?await Pt(nt):await He(nt),Lt(null),tr(null))):Y.error(te.error||"Failed to install plugin")}catch(te){Y.error(te.message)}finally{Vt(!1)}},or=()=>{As(!1),Lt(null),tr(null)},jt=_.useCallback(async(te,Me)=>{var At,Sr,Qr,pt,Rr,Mr,Zr,qn,so,yi,bi,Yn,no,Wc;if(ut)try{const ft=(await ue.getLoop(ut.id)).loop;if(ft.taskComplete||ft.status==="completed")Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(At=ft.task)==null?void 0:At.original,status:"completed",iterations:((Sr=ft.iterations)==null?void 0:Sr.current)||0,maxIterations:((Qr=ft.iterations)==null?void 0:Qr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:ft.completedAt||new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(ft.status==="paused")Y.info(`Loop paused: ${ft.pauseReason||"user requested"}`),an({id:ft.id,name:ft.name,task:(pt=ft.task)==null?void 0:pt.original,status:"paused",pauseReason:ft.pauseReason,iterations:((Rr=ft.iterations)==null?void 0:Rr.current)||0,maxIterations:((Mr=ft.iterations)==null?void 0:Mr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0);else if(te===0&&!Me)await ue.completeLoop(ft.id),Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(Zr=ft.task)==null?void 0:Zr.original,status:"completed",iterations:((qn=ft.iterations)==null?void 0:qn.current)||0,maxIterations:((so=ft.iterations)==null?void 0:so.max)||50,phase:"execute",startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(((yi=ft.iterations)==null?void 0:yi.current)>=((bi=ft.iterations)==null?void 0:bi.max))Y.warning("Loop reached max iterations"),await ue.pauseLoop(ft.id);else{const Yo=Me?`Signal: ${Me}`:`Exit code: ${te}`;an({id:ft.id,name:ft.name,task:(Yn=ft.task)==null?void 0:Yn.original,status:"paused",pauseReason:Yo,iterations:((no=ft.iterations)==null?void 0:no.current)||0,maxIterations:((Wc=ft.iterations)==null?void 0:Wc.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0)}Cr()}catch(Vc){console.error("Failed to check loop status:",Vc)}},[ut]),Wt=async te=>{try{const Me=await ue.pauseLoop(te);Me.success?(Y.success("Loop paused"),Cr()):Y.error(Me.error||"Failed to pause loop")}catch(Me){Y.error(Me.message)}},gr=async te=>{if(Us.needsInstall){Lt(te),tr("resume"),As(!0);return}await Pt(te)},Pt=async te=>{try{const Me=await ue.resumeLoop(te);Me.success&&Me.loop?(Y.success("Loop resumed - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to resume loop")}catch(Me){Y.error(Me.message)}},gs=async te=>{if(confirm("Cancel this loop?"))try{const Me=await ue.cancelLoop(te);Me.success?(Y.success("Loop cancelled"),Cr()):Y.error(Me.error||"Failed to cancel loop")}catch(Me){Y.error(Me.message)}},Sn=async te=>{if(confirm("Delete this loop and all its data?"))try{const Me=await ue.deleteLoop(te);Me.success?(Y.success("Loop deleted"),Cr()):Y.error(Me.error||"Failed to delete loop")}catch(Me){Y.error(Me.message)}},kn=te=>{var Me,At;L(te),Ye(te.name||""),ke(((Me=te.task)==null?void 0:Me.original)||""),Oe(((At=te.iterations)==null?void 0:At.max)||50),_e(te.completionPromise||"DONE"),ve(te.workstreamId||""),M(!0)},Kn=async()=>{if(I)try{O(!0);const te={name:Je,task:{original:ot},iterations:{max:parseInt(be,10)},completionPromise:Ee,workstreamId:oe||null},Me=await ue.updateLoop(I.id,te);Me.success?(Y.success("Loop updated"),M(!1),L(null),Cr()):Y.error(Me.error||"Failed to update loop")}catch(te){Y.error(te.message)}finally{O(!1)}},Vo=async te=>{var Me,At;try{O(!0);const Sr=await ue.createLoop(((Me=te.task)==null?void 0:Me.original)||"",{name:`${te.name} (copy)`,workstreamId:te.workstreamId||null,projectPath:te.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:((At=te.iterations)==null?void 0:At.max)||50,completionPromise:te.completionPromise||"DONE"});Sr.success?(Y.success("Loop copied"),Cr()):Y.error(Sr.error||"Failed to copy loop")}catch(Sr){Y.error(Sr.message)}finally{O(!1)}},Zi=async te=>{try{const Me=await ue.approveLoop(te);Me.success?(Y.success("Plan approved"),Cr()):Y.error(Me.error||"Failed to approve plan")}catch(Me){Y.error(Me.message)}},Uo=async()=>{try{O(!0);const te=await ue.updateLoopConfig({maxIterations:parseInt(De,10),autoApprovePlan:ze,completionPromise:dt});te.success?(Y.success("Configuration saved"),y(!1),Ji()):Y.error(te.error||"Failed to save configuration")}catch(te){Y.error(te.message)}finally{O(!1)}},Nh=async()=>{try{Hr(!0);const te=await ue.installLoopHooks();te.success?(Y.success("Hooks installed successfully"),Qi()):Y.error(te.error||"Failed to install hooks")}catch(te){Y.error(te.message)}finally{Hr(!1)}},zc=async te=>{try{const Me=await ue.getLoop(te.id);T({...Me.loop,clarifications:Me.clarifications,plan:Me.plan}),E(!0)}catch{Y.error("Failed to load loop details")}},nl=te=>{navigator.clipboard.writeText(te),Y.success("Copied to clipboard")},eo=te=>te?new Date(te).toLocaleString():"-",il=te=>te.iterations?Math.min(100,te.iterations.current/te.iterations.max*100):0,to=((ol=Ht.stopHook)==null?void 0:ol.registered)&&((al=Ht.prepromptHook)==null?void 0:al.registered),Hc=te=>{if(!te)return null;const Me=f.find(At=>At.id===te);return(Me==null?void 0:Me.name)||te},Go=x?t.filter(te=>te.workstreamId===x):t,Nt=(te,Me=!1)=>{var pt,Rr;const At=((pt=te.task)==null?void 0:pt.original)||"";if((Rr=te.iterations)!=null&&Rr.max,te.completionPromise,Me){const Mr=At.replace(/\n+/g," ").substring(0,100),Zr=At.length>100?"...":"";return`claude --dangerously-skip-permissions "${Mr.replace(/"/g,'\\"')}${Zr}"`}return{startCmd:"claude --dangerously-skip-permissions",skillCmd:At}};return r.jsxs("div",{className:"p-6 space-y-6 max-w-6xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r.jsx(cc,{className:"w-6 h-6"}),"Ralph Loops"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops using the official ralph-loop plugin"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Rg,{className:"w-4 h-4 text-muted-foreground"}),r.jsxs("select",{className:"text-sm border rounded px-2 py-1 bg-background",value:x,onChange:te=>w(te.target.value),children:[r.jsx("option",{value:"",children:"All workstreams"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>{Bo(),b(!0)},children:[r.jsx(Su,{className:"w-4 h-4 mr-1"}),"History"]})}),r.jsx(Mt,{children:"View completed loops"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[r.jsx(sn,{className:"w-4 h-4 mr-1"}),"Config"]})}),r.jsx(Mt,{children:"Configure loop defaults"})]})}),r.jsxs(re,{onClick:()=>C(!0),children:[r.jsx(Rt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!to&&r.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx($s,{className:"w-5 h-5 text-yellow-600"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:"Hooks not installed"}),r.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"Install the Ralph Loop hooks to enable automatic loop continuation"})]})]}),r.jsxs(re,{variant:"outline",size:"sm",onClick:Nh,disabled:hr,children:[hr?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),n?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Ze,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):Go.length===0?r.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[r.jsx(cc,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"text-lg font-medium",children:x?"No loops in this workstream":"No loops yet"}),r.jsx("p",{className:"text-sm mt-1",children:"Create a loop to start autonomous development"})]}):r.jsx("div",{className:"space-y-3",children:Go.map(te=>{var Me,At,Sr,Qr,pt;return r.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[r.jsxs("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>u(c===te.id?null:te.id),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[c===te.id?r.jsx(Er,{className:"w-4 h-4 text-muted-foreground"}):r.jsx(us,{className:"w-4 h-4 text-muted-foreground"}),Ca[te.status]||Ca.pending,r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium",children:te.name}),r.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Me=te.task)==null?void 0:Me.original)||"No task"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[te.workstreamId&&r.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200 flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3"}),Hc(te.workstreamId)]}),r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${g_[te.phase]||"bg-gray-100 dark:bg-gray-800"}`,children:te.phase}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:[((At=te.iterations)==null?void 0:At.current)||0,"/",((Sr=te.iterations)==null?void 0:Sr.max)||50]}),r.jsxs("div",{className:"flex items-center gap-1",onClick:Rr=>Rr.stopPropagation(),children:[te.status==="pending"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Ie(te.id),children:r.jsx(aS,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Start loop"})]})}),te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Wt(te.id),children:r.jsx(xp,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Pause loop"})]})}),te.status==="paused"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Resume loop"})]})}),(te.status==="cancelled"||te.status==="failed")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Restart loop"})]})}),te.phase==="plan"&&te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Zi(te.id),children:r.jsx($t,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Approve plan"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>kn(te),children:r.jsx(qu,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Edit loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Vo(te),children:r.jsx($a,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Duplicate loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>zc(te),children:r.jsx(Ag,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"View details"})]})}),(te.status==="running"||te.status==="paused")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>gs(te.id),children:r.jsx(Ta,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Cancel loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Sn(te.id),children:r.jsx(js,{className:"w-4 h-4 text-red-500"})})}),r.jsx(Mt,{children:"Delete loop"})]})})]})]})]}),r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Iterations"}),r.jsxs("span",{children:[((Qr=te.iterations)==null?void 0:Qr.current)||0," / ",((pt=te.iterations)==null?void 0:pt.max)||50]})]}),r.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-blue-500 transition-all",style:{width:`${il(te)}%`}})})]})]}),c===te.id&&r.jsxs("div",{className:"border-t p-4 bg-muted/30 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"ID:"}),r.jsx("span",{className:"ml-2 font-mono",children:te.id}),r.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>nl(te.id),children:r.jsx($a,{className:"w-3 h-3"})})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Status:"}),r.jsxs("span",{className:"ml-2",children:[te.status,te.pauseReason?` (${te.pauseReason})`:""]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Created:"}),r.jsx("span",{className:"ml-2",children:eo(te.createdAt)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),r.jsx("span",{className:"ml-2",children:eo(te.updatedAt)})]}),te.workstreamId&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3 text-purple-500"}),Hc(te.workstreamId)]})]})]}),r.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(qt,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Run this loop (uses official ralph-loop plugin):"})]}),r.jsx("code",{className:"text-xs bg-background p-2 rounded block whitespace-pre-wrap",children:Nt(te,!0)})]})]})]},te.id)})}),r.jsx(wt,{open:j,onOpenChange:C,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Create New Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:zo,disabled:V||!B.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution - adds clear completion signals, verification steps, and acceptance criteria."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:B,onChange:te=>{H(te.target.value),Q(!1)},rows:4}),r.jsxs("div",{className:"flex items-center justify-between mt-1",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Be specific about the goal. The loop will continue until this task is completed."}),ie&&r.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[r.jsx(Yt,{className:"w-3 h-3"}),"AI-tuned"]})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Project"}),r.jsx("div",{className:"text-sm p-2 bg-muted rounded-md",children:e?r.jsx("span",{className:"font-mono",children:e.name||e.path||e.dir}):r.jsx("span",{className:"text-muted-foreground",children:"No project selected - loop will run in server directory"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:G,onChange:te=>J(te.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Safety limit for the loop"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:K,onChange:te=>F(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Text that signals completion"})]})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream (optional)"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:q,onChange:te=>z(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),r.jsxs(re,{onClick:$o,disabled:R||!B.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),r.jsx(wt,{open:N,onOpenChange:M,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Edit Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Name"}),r.jsx(ct,{placeholder:"Loop name",value:Je,onChange:te=>Ye(te.target.value)})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:async()=>{if(!ot.trim()){Y.error("Enter a task description first");return}try{$(!0),ce(ot),ye("edit");const te=await ue.tuneLoopPrompt(ot,(I==null?void 0:I.projectPath)||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);te.success?(X(te.tunedPrompt),de(!0)):Y.error(te.error||"Failed to tune prompt")}catch(te){Y.error(te.message)}finally{$(!1)}},disabled:V||!ot.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:ot,onChange:te=>ke(te.target.value),rows:4})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:be,onChange:te=>Oe(te.target.value),min:1,max:1e3})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:Ee,onChange:te=>_e(te.target.value),placeholder:"DONE"})]})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:oe,onChange:te=>ve(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),I&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[r.jsxs("span",{children:["ID: ",I.id]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Status: ",I.status]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Phase: ",I.phase]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),r.jsxs(re,{onClick:Kn,disabled:R||!ot.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save Changes"]})]})]})}),r.jsx(wt,{open:v,onOpenChange:y,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Loop Configuration"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:De,onChange:te=>Be(te.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause after this many iterations"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Default Completion Promise"}),r.jsx(ct,{value:dt,onChange:te=>er(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Default text that signals loop completion (used with official ralph-loop plugin)"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:ze,onChange:te=>St(te.target.checked),className:"rounded"}),r.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),r.jsxs(re,{onClick:Uo,disabled:R,children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),r.jsx(wt,{open:g,onOpenChange:b,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Loop History"})}),r.jsx("div",{className:"space-y-3 py-4",children:wr.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):wr.slice().reverse().map(te=>r.jsxs("div",{className:"border rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[Ca[te.status]||Ca.completed,r.jsx("span",{className:"font-medium",children:te.name})]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:eo(te.completedAt)})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:te.task}),r.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:r.jsxs("span",{children:["Iterations: ",te.totalIterations]})})]},te.id))})]})}),r.jsx(wt,{open:k,onOpenChange:E,children:r.jsxs(xt,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:(P==null?void 0:P.name)||"Loop Details"})}),P&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Phase"}),r.jsx("span",{className:`text-sm px-2 py-0.5 rounded-full ${g_[P.phase]||""}`,children:P.phase})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),r.jsxs("div",{className:"flex items-center gap-1",children:[Ca[P.status],r.jsx("span",{children:P.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Progress"}),r.jsxs("span",{children:[((Ko=P.iterations)==null?void 0:Ko.current)||0," / ",((ll=P.iterations)==null?void 0:ll.max)||50]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Task"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm",children:(cl=P.task)==null?void 0:cl.original})]}),P.clarifications&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Clarifications"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-40 overflow-y-auto",children:P.clarifications})]}),P.plan&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Plan"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-60 overflow-y-auto font-mono",children:P.plan})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Max Iterations"}),r.jsx("div",{className:"bg-muted p-2 rounded text-sm",children:((dl=P.iterations)==null?void 0:dl.max)||50})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Completion Promise"}),r.jsxs("div",{className:"bg-muted p-2 rounded text-sm font-mono",children:["<promise>",P.completionPromise||"DONE","</promise>"]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command (uses official ralph-loop plugin)"}),r.jsx("code",{className:"text-xs bg-muted p-3 rounded block whitespace-pre-wrap",children:Nt(P,!0)})]})]})]})}),r.jsx(wt,{open:Ps,onOpenChange:As,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-5 h-5"}),"Install ralph-loop Plugin"]})}),r.jsxs("div",{className:"py-4",children:[r.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["The ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"ralph-loop"})," plugin is required to run loops. This plugin provides the ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"/ralph-loop"})," command that enables autonomous iteration."]}),Us.scope==="project"&&r.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded p-3 mb-4",children:r.jsxs("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:["Plugin is currently installed only for project: ",r.jsx("br",{}),r.jsx("code",{className:"text-xs",children:Us.projectPath})]})}),r.jsx("p",{className:"text-sm",children:"Install the plugin globally (user scope) to use loops from any project?"})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:or,disabled:ms,children:"Cancel"}),r.jsx(re,{onClick:Ot,disabled:ms,children:ms?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}),"Installing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ui,{className:"w-4 h-4 mr-1"}),"Install Plugin"]})})]})]})}),r.jsx(Lj,{open:rr,onOpenChange:te=>{Wr(te),te||(fr(null),Cr())},title:ut?`Loop: ${ut.name}`:"Running Loop",description:ut?((ro=(qo=ut.task)==null?void 0:qo.original)==null?void 0:ro.substring(0,100))+(((dn=(cn=ut.task)==null?void 0:cn.original)==null?void 0:dn.length)>100?"...":""):"",cwd:ut==null?void 0:ut.projectPath,initialCommand:ut?Nt(ut).startCmd:"",delayedCommand:ut?Nt(ut).skillCmd:"",delayedCommandDelay:5e3,env:ut?{CODER_LOOP_ID:ut.id,...ut.workstreamId&&{CODER_WORKSTREAM:ut.workstreamId}}:{},onExit:jt,headerExtra:r.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[r.jsx("input",{type:"checkbox",checked:Xr,onChange:te=>Jr(te.target.checked),className:"rounded"}),"Auto-close when done"]})}),r.jsx(wt,{open:se,onOpenChange:de,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(os,{className:"w-5 h-5 text-purple-500"}),"AI-Tuned Prompt"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2 text-muted-foreground",children:"Original Prompt"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-32 overflow-y-auto",children:W})]}),r.jsxs("div",{children:[r.jsxs("h4",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[r.jsx(Yt,{className:"w-4 h-4 text-purple-500"}),"Tuned Prompt"]}),r.jsx(Ct,{value:pe,onChange:te=>X(te.target.value),rows:10,className:"font-mono text-sm"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"You can edit the tuned prompt before accepting it."})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:Ho,children:"Keep Original"}),r.jsxs(re,{onClick:ln,children:[r.jsx($t,{className:"w-4 h-4 mr-1"}),"Use Tuned Prompt"]})]})]})}),r.jsx(wt,{open:le,onOpenChange:we,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(Kd,{className:"w-5 h-5"}),"Resume Loop"]})}),r.jsx("div",{className:"py-4",children:Le&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-sm mb-4",children:["This loop ",Le.status==="failed"?"failed":Le.status==="cancelled"?"was cancelled":"was paused",Le.pauseReason&&`: ${Le.pauseReason}`]}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Would you like to tune the prompt with AI before resuming? This can help add guardrails based on what went wrong."}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm max-h-32 overflow-y-auto",children:(un=Le.task)==null?void 0:un.original})]})}),r.jsxs(kt,{className:"flex-col sm:flex-row gap-2",children:[r.jsx(re,{variant:"outline",onClick:()=>{we(!1),Ke(null)},children:"Cancel"}),r.jsx(re,{variant:"secondary",onClick:Wo,children:"Resume As-Is"}),r.jsxs(re,{onClick:Ut,disabled:V,children:[V?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):r.jsx(os,{className:"w-4 h-4 mr-1"}),"Tune & Resume"]})]})]})}),r.jsx(wt,{open:sl,onOpenChange:ps,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[(Qe==null?void 0:Qe.status)==="completed"&&r.jsxs(r.Fragment,{children:[r.jsx(No,{className:"w-5 h-5 text-green-600"})," Loop Completed"]}),(Qe==null?void 0:Qe.status)==="paused"&&r.jsxs(r.Fragment,{children:[r.jsx(xp,{className:"w-5 h-5 text-yellow-500"})," Loop Paused"]}),(Qe==null?void 0:Qe.status)==="failed"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-red-500"})," Loop Failed"]}),(Qe==null?void 0:Qe.status)==="cancelled"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-gray-500"})," Loop Cancelled"]})]})}),Qe&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Task"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.task})]}),Qe.pauseReason&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Reason"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.pauseReason})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),r.jsxs("div",{className:"font-medium flex items-center gap-1",children:[Ca[Qe.status],r.jsx("span",{className:"capitalize",children:Qe.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Iterations"}),r.jsxs("div",{className:"font-medium",children:[Qe.iterations," / ",Qe.maxIterations]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Duration"}),r.jsx("div",{className:"font-medium",children:Qe.duration!=null?Qe.duration<60?`${Qe.duration}s`:Qe.duration<3600?`${Math.floor(Qe.duration/60)}m ${Qe.duration%60}s`:`${Math.floor(Qe.duration/3600)}h ${Math.floor(Qe.duration%3600/60)}m`:"-"})]})]}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:[Qe.status==="completed"?"Completed":"Stopped"," at ",eo(Qe.completedAt)]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>ps(!1),children:"Close"}),((Qe==null?void 0:Qe.status)==="paused"||(Qe==null?void 0:Qe.status)==="failed"||(Qe==null?void 0:Qe.status)==="cancelled")&&r.jsxs(re,{onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&vi(te)}},children:[r.jsx(Kd,{className:"w-4 h-4 mr-1"}),(Qe==null?void 0:Qe.status)==="paused"?"Resume":"Restart"]}),r.jsx(re,{variant:"secondary",onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&zc(te)}},children:"View Details"})]})]})})]})}function pW(e,t=[]){let s=[];function n(c,u){const l=_.createContext(u);l.displayName=c+"Context";const d=s.length;s=[...s,u];const f=h=>{var y;const{scope:x,children:w,...j}=h,C=((y=x==null?void 0:x[e])==null?void 0:y[d])||l,v=_.useMemo(()=>j,Object.values(j));return r.jsx(C.Provider,{value:v,children:w})};f.displayName=c+"Provider";function m(h,x){var C;const w=((C=x==null?void 0:x[e])==null?void 0:C[d])||l,j=_.useContext(w);if(j)return j;if(u!==void 0)return u;throw new Error(`\`${h}\` must be used within \`${c}\``)}return[f,m]}const o=()=>{const c=s.map(u=>_.createContext(u));return function(l){const d=(l==null?void 0:l[e])||c;return _.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return o.scopeName=e,[n,gW(o,...t)]}function gW(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const u=n.reduce((l,{useScope:d,scopeName:f})=>{const h=d(c)[`__scope${f}`];return{...l,...h}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])}};return s.scopeName=t.scopeName,s}var xW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],v2=xW.reduce((e,t)=>{const s=Yu(`Primitive.${t}`),n=_.forwardRef((o,c)=>{const{asChild:u,...l}=o,d=u?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...l,ref:c})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Wx="Progress",Vx=100,[vW]=pW(Wx),[yW,bW]=vW(Wx),y2=_.forwardRef((e,t)=>{const{__scopeProgress:s,value:n=null,max:o,getValueLabel:c=wW,...u}=e;(o||o===0)&&!x_(o)&&console.error(_W(`${o}`,"Progress"));const l=x_(o)?o:Vx;n!==null&&!v_(n,l)&&console.error(CW(`${n}`,"Progress"));const d=v_(n,l)?n:null,f=Bu(d)?c(d,l):void 0;return r.jsx(yW,{scope:s,value:d,max:l,children:r.jsx(v2.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Bu(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":_2(d,l),"data-value":d??void 0,"data-max":l,...u,ref:t})})});y2.displayName=Wx;var b2="ProgressIndicator",w2=_.forwardRef((e,t)=>{const{__scopeProgress:s,...n}=e,o=bW(b2,s);return r.jsx(v2.div,{"data-state":_2(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...n,ref:t})});w2.displayName=b2;function wW(e,t){return`${Math.round(e/t*100)}%`}function _2(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Bu(e){return typeof e=="number"}function x_(e){return Bu(e)&&!isNaN(e)&&e>0}function v_(e,t){return Bu(e)&&!isNaN(e)&&e<=t&&e>=0}function _W(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Vx}\`.`}function CW(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
3006
|
+
`),Mr.transcript=Zr;const qn=await ue.tuneLoopPrompt(Qr,Le.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,Mr);qn.success?(await ue.updateLoop(Le.id,{task:{original:qn.tunedPrompt}}),Y.success("Prompt tuned and loop updated"),we(!1),await Pt(Le.id),Cr()):Y.error(qn.error||"Failed to tune prompt")}catch(Qr){Y.error(Qr.message)}finally{$(!1),Ke(null)}},Wo=async()=>{Le&&(we(!1),await gr(Le.id),Ke(null))},ee=async te=>{try{O(!0);const Me=await ue.createLoop(te,{workstreamId:q||null,projectPath:(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:parseInt(G,10)||50,completionPromise:K||"DONE"});Me.success?(Y.success("Loop created"),C(!1),H(""),z(""),J(De),F(dt),Q(!1),Cr()):Y.error(Me.error||"Failed to create loop")}catch(Me){Y.error(Me.message)}finally{O(!1)}},Ie=async te=>{if(Us.needsInstall){Lt(te),tr("start"),As(!0);return}await He(te)},He=async te=>{try{const Me=await ue.startLoop(te);Me.success&&Me.loop?(Y.success("Loop started - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to start loop")}catch(Me){Y.error(Me.message)}},Ot=async()=>{try{Vt(!0);const te=await ue.installRalphLoopPlugin();te.success?(Y.success("ralph-loop plugin installed"),fs({installed:!0,scope:"user",needsInstall:!1}),As(!1),nt&&(ir==="resume"?await Pt(nt):await He(nt),Lt(null),tr(null))):Y.error(te.error||"Failed to install plugin")}catch(te){Y.error(te.message)}finally{Vt(!1)}},or=()=>{As(!1),Lt(null),tr(null)},jt=_.useCallback(async(te,Me)=>{var At,Sr,Qr,pt,Rr,Mr,Zr,qn,so,yi,bi,Yn,no,Wc;if(ut)try{const ft=(await ue.getLoop(ut.id)).loop;if(ft.taskComplete||ft.status==="completed")Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(At=ft.task)==null?void 0:At.original,status:"completed",iterations:((Sr=ft.iterations)==null?void 0:Sr.current)||0,maxIterations:((Qr=ft.iterations)==null?void 0:Qr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:ft.completedAt||new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(ft.status==="paused")Y.info(`Loop paused: ${ft.pauseReason||"user requested"}`),an({id:ft.id,name:ft.name,task:(pt=ft.task)==null?void 0:pt.original,status:"paused",pauseReason:ft.pauseReason,iterations:((Rr=ft.iterations)==null?void 0:Rr.current)||0,maxIterations:((Mr=ft.iterations)==null?void 0:Mr.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0);else if(te===0&&!Me)await ue.completeLoop(ft.id),Y.success("Loop completed successfully!"),an({id:ft.id,name:ft.name,task:(Zr=ft.task)==null?void 0:Zr.original,status:"completed",iterations:((qn=ft.iterations)==null?void 0:qn.current)||0,maxIterations:((so=ft.iterations)==null?void 0:so.max)||50,phase:"execute",startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0),Wr(!1),fr(null);else if(((yi=ft.iterations)==null?void 0:yi.current)>=((bi=ft.iterations)==null?void 0:bi.max))Y.warning("Loop reached max iterations"),await ue.pauseLoop(ft.id);else{const Yo=Me?`Signal: ${Me}`:`Exit code: ${te}`;an({id:ft.id,name:ft.name,task:(Yn=ft.task)==null?void 0:Yn.original,status:"paused",pauseReason:Yo,iterations:((no=ft.iterations)==null?void 0:no.current)||0,maxIterations:((Wc=ft.iterations)==null?void 0:Wc.max)||50,phase:ft.phase,startedAt:ft.startedAt,completedAt:new Date().toISOString()}),ps(!0)}Cr()}catch(Vc){console.error("Failed to check loop status:",Vc)}},[ut]),Wt=async te=>{try{const Me=await ue.pauseLoop(te);Me.success?(Y.success("Loop paused"),Cr()):Y.error(Me.error||"Failed to pause loop")}catch(Me){Y.error(Me.message)}},gr=async te=>{if(Us.needsInstall){Lt(te),tr("resume"),As(!0);return}await Pt(te)},Pt=async te=>{try{const Me=await ue.resumeLoop(te);Me.success&&Me.loop?(Y.success("Loop resumed - launching Claude Code"),fr(Me.loop),Wr(!0),Cr()):Y.error(Me.error||"Failed to resume loop")}catch(Me){Y.error(Me.message)}},gs=async te=>{if(confirm("Cancel this loop?"))try{const Me=await ue.cancelLoop(te);Me.success?(Y.success("Loop cancelled"),Cr()):Y.error(Me.error||"Failed to cancel loop")}catch(Me){Y.error(Me.message)}},Sn=async te=>{if(confirm("Delete this loop and all its data?"))try{const Me=await ue.deleteLoop(te);Me.success?(Y.success("Loop deleted"),Cr()):Y.error(Me.error||"Failed to delete loop")}catch(Me){Y.error(Me.message)}},kn=te=>{var Me,At;L(te),Ye(te.name||""),ke(((Me=te.task)==null?void 0:Me.original)||""),Oe(((At=te.iterations)==null?void 0:At.max)||50),_e(te.completionPromise||"DONE"),ve(te.workstreamId||""),M(!0)},Kn=async()=>{if(I)try{O(!0);const te={name:Je,task:{original:ot},iterations:{max:parseInt(be,10)},completionPromise:Ee,workstreamId:oe||null},Me=await ue.updateLoop(I.id,te);Me.success?(Y.success("Loop updated"),M(!1),L(null),Cr()):Y.error(Me.error||"Failed to update loop")}catch(te){Y.error(te.message)}finally{O(!1)}},Vo=async te=>{var Me,At;try{O(!0);const Sr=await ue.createLoop(((Me=te.task)==null?void 0:Me.original)||"",{name:`${te.name} (copy)`,workstreamId:te.workstreamId||null,projectPath:te.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:((At=te.iterations)==null?void 0:At.max)||50,completionPromise:te.completionPromise||"DONE"});Sr.success?(Y.success("Loop copied"),Cr()):Y.error(Sr.error||"Failed to copy loop")}catch(Sr){Y.error(Sr.message)}finally{O(!1)}},Zi=async te=>{try{const Me=await ue.approveLoop(te);Me.success?(Y.success("Plan approved"),Cr()):Y.error(Me.error||"Failed to approve plan")}catch(Me){Y.error(Me.message)}},Uo=async()=>{try{O(!0);const te=await ue.updateLoopConfig({maxIterations:parseInt(De,10),autoApprovePlan:ze,completionPromise:dt});te.success?(Y.success("Configuration saved"),y(!1),Ji()):Y.error(te.error||"Failed to save configuration")}catch(te){Y.error(te.message)}finally{O(!1)}},Nh=async()=>{try{Hr(!0);const te=await ue.installLoopHooks();te.success?(Y.success("Hooks installed successfully"),Qi()):Y.error(te.error||"Failed to install hooks")}catch(te){Y.error(te.message)}finally{Hr(!1)}},zc=async te=>{try{const Me=await ue.getLoop(te.id);T({...Me.loop,clarifications:Me.clarifications,plan:Me.plan}),E(!0)}catch{Y.error("Failed to load loop details")}},nl=te=>{navigator.clipboard.writeText(te),Y.success("Copied to clipboard")},eo=te=>te?new Date(te).toLocaleString():"-",il=te=>te.iterations?Math.min(100,te.iterations.current/te.iterations.max*100):0,to=((ol=Ht.stopHook)==null?void 0:ol.registered)&&((al=Ht.prepromptHook)==null?void 0:al.registered),Hc=te=>{if(!te)return null;const Me=f.find(At=>At.id===te);return(Me==null?void 0:Me.name)||te},Go=x?t.filter(te=>te.workstreamId===x):t,Nt=(te,Me=!1)=>{var pt,Rr;const At=((pt=te.task)==null?void 0:pt.original)||"";if((Rr=te.iterations)!=null&&Rr.max,te.completionPromise,Me){const Mr=At.replace(/\n+/g," ").substring(0,100),Zr=At.length>100?"...":"";return`claude --dangerously-skip-permissions "${Mr.replace(/"/g,'\\"')}${Zr}"`}return{startCmd:"claude --dangerously-skip-permissions",skillCmd:At}};return r.jsxs("div",{className:"p-6 space-y-6 max-w-6xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r.jsx(cc,{className:"w-6 h-6"}),"Ralph Loops"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops with iteration tracking and safety controls"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Rg,{className:"w-4 h-4 text-muted-foreground"}),r.jsxs("select",{className:"text-sm border rounded px-2 py-1 bg-background",value:x,onChange:te=>w(te.target.value),children:[r.jsx("option",{value:"",children:"All workstreams"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>{Bo(),b(!0)},children:[r.jsx(Su,{className:"w-4 h-4 mr-1"}),"History"]})}),r.jsx(Mt,{children:"View completed loops"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[r.jsx(sn,{className:"w-4 h-4 mr-1"}),"Config"]})}),r.jsx(Mt,{children:"Configure loop defaults"})]})}),r.jsxs(re,{onClick:()=>C(!0),children:[r.jsx(Rt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!to&&r.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx($s,{className:"w-5 h-5 text-yellow-600"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:"Hooks not installed"}),r.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"Install the Ralph Loop hooks to enable automatic loop continuation"})]})]}),r.jsxs(re,{variant:"outline",size:"sm",onClick:Nh,disabled:hr,children:[hr?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),n?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Ze,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):Go.length===0?r.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[r.jsx(cc,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"text-lg font-medium",children:x?"No loops in this workstream":"No loops yet"}),r.jsx("p",{className:"text-sm mt-1",children:"Create a loop to start autonomous development"})]}):r.jsx("div",{className:"space-y-3",children:Go.map(te=>{var Me,At,Sr,Qr,pt;return r.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[r.jsxs("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>u(c===te.id?null:te.id),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[c===te.id?r.jsx(Er,{className:"w-4 h-4 text-muted-foreground"}):r.jsx(us,{className:"w-4 h-4 text-muted-foreground"}),Ca[te.status]||Ca.pending,r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium",children:te.name}),r.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Me=te.task)==null?void 0:Me.original)||"No task"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[te.workstreamId&&r.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200 flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3"}),Hc(te.workstreamId)]}),r.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${g_[te.phase]||"bg-gray-100 dark:bg-gray-800"}`,children:te.phase}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:[((At=te.iterations)==null?void 0:At.current)||0,"/",((Sr=te.iterations)==null?void 0:Sr.max)||50]}),r.jsxs("div",{className:"flex items-center gap-1",onClick:Rr=>Rr.stopPropagation(),children:[te.status==="pending"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Ie(te.id),children:r.jsx(aS,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Start loop"})]})}),te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Wt(te.id),children:r.jsx(xp,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Pause loop"})]})}),te.status==="paused"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Resume loop"})]})}),(te.status==="cancelled"||te.status==="failed")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>vi(te),children:r.jsx(Kd,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Restart loop"})]})}),te.phase==="plan"&&te.status==="running"&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Zi(te.id),children:r.jsx($t,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Approve plan"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>kn(te),children:r.jsx(qu,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Edit loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Vo(te),children:r.jsx($a,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Duplicate loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>zc(te),children:r.jsx(Ag,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"View details"})]})}),(te.status==="running"||te.status==="paused")&&r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>gs(te.id),children:r.jsx(Ta,{className:"w-4 h-4"})})}),r.jsx(Mt,{children:"Cancel loop"})]})}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(re,{variant:"ghost",size:"sm",onClick:()=>Sn(te.id),children:r.jsx(js,{className:"w-4 h-4 text-red-500"})})}),r.jsx(Mt,{children:"Delete loop"})]})})]})]})]}),r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[r.jsx("span",{children:"Iterations"}),r.jsxs("span",{children:[((Qr=te.iterations)==null?void 0:Qr.current)||0," / ",((pt=te.iterations)==null?void 0:pt.max)||50]})]}),r.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-blue-500 transition-all",style:{width:`${il(te)}%`}})})]})]}),c===te.id&&r.jsxs("div",{className:"border-t p-4 bg-muted/30 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"ID:"}),r.jsx("span",{className:"ml-2 font-mono",children:te.id}),r.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>nl(te.id),children:r.jsx($a,{className:"w-3 h-3"})})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Status:"}),r.jsxs("span",{className:"ml-2",children:[te.status,te.pauseReason?` (${te.pauseReason})`:""]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Created:"}),r.jsx("span",{className:"ml-2",children:eo(te.createdAt)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),r.jsx("span",{className:"ml-2",children:eo(te.updatedAt)})]}),te.workstreamId&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),r.jsxs("span",{className:"ml-2 inline-flex items-center gap-1",children:[r.jsx(Rn,{className:"w-3 h-3 text-purple-500"}),Hc(te.workstreamId)]})]})]}),r.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(qt,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Run this loop (uses official ralph-loop plugin):"})]}),r.jsx("code",{className:"text-xs bg-background p-2 rounded block whitespace-pre-wrap",children:Nt(te,!0)})]})]})]},te.id)})}),r.jsx(wt,{open:j,onOpenChange:C,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Create New Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:zo,disabled:V||!B.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution - adds clear completion signals, verification steps, and acceptance criteria."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:B,onChange:te=>{H(te.target.value),Q(!1)},rows:4}),r.jsxs("div",{className:"flex items-center justify-between mt-1",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Be specific about the goal. The loop will continue until this task is completed."}),ie&&r.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[r.jsx(Yt,{className:"w-3 h-3"}),"AI-tuned"]})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Project"}),r.jsx("div",{className:"text-sm p-2 bg-muted rounded-md",children:e?r.jsx("span",{className:"font-mono",children:e.name||e.path||e.dir}):r.jsx("span",{className:"text-muted-foreground",children:"No project selected - loop will run in server directory"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:G,onChange:te=>J(te.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Safety limit for the loop"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:K,onChange:te=>F(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Text that signals completion"})]})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream (optional)"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:q,onChange:te=>z(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),r.jsxs(re,{onClick:$o,disabled:R||!B.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),r.jsx(wt,{open:N,onOpenChange:M,children:r.jsxs(xt,{className:"sm:max-w-lg",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Edit Loop"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Name"}),r.jsx(ct,{placeholder:"Loop name",value:Je,onChange:te=>Ye(te.target.value)})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),r.jsx(cr,{children:r.jsxs(Ft,{children:[r.jsx(Bt,{asChild:!0,children:r.jsxs(re,{variant:"outline",size:"sm",onClick:async()=>{if(!ot.trim()){Y.error("Enter a task description first");return}try{$(!0),ce(ot),ye("edit");const te=await ue.tuneLoopPrompt(ot,(I==null?void 0:I.projectPath)||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);te.success?(X(te.tunedPrompt),de(!0)):Y.error(te.error||"Failed to tune prompt")}catch(te){Y.error(te.message)}finally{$(!1)}},disabled:V||!ot.trim(),className:"h-7 text-xs",children:[V?r.jsx(Ze,{className:"w-3 h-3 animate-spin mr-1"}):r.jsx(os,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),r.jsx(Mt,{children:r.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution."})})]})})]}),r.jsx(Ct,{placeholder:"Describe what you want Claude to accomplish...",value:ot,onChange:te=>ke(te.target.value),rows:4})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:be,onChange:te=>Oe(te.target.value),min:1,max:1e3})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),r.jsx(ct,{value:Ee,onChange:te=>_e(te.target.value),placeholder:"DONE"})]})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream"}),r.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:oe,onChange:te=>ve(te.target.value),children:[r.jsx("option",{value:"",children:"No workstream"}),f.map(te=>r.jsx("option",{value:te.id,children:te.name},te.id))]})]}),I&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[r.jsxs("span",{children:["ID: ",I.id]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Status: ",I.status]}),r.jsx("span",{className:"mx-2",children:"|"}),r.jsxs("span",{children:["Phase: ",I.phase]})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),r.jsxs(re,{onClick:Kn,disabled:R||!ot.trim(),children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save Changes"]})]})]})}),r.jsx(wt,{open:v,onOpenChange:y,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Loop Configuration"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),r.jsx(ct,{type:"number",value:De,onChange:te=>Be(te.target.value),min:1,max:1e3}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause after this many iterations"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Default Completion Promise"}),r.jsx(ct,{value:dt,onChange:te=>er(te.target.value),placeholder:"DONE"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Default text that signals loop completion (used with official ralph-loop plugin)"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:ze,onChange:te=>St(te.target.checked),className:"rounded"}),r.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),r.jsxs(re,{onClick:Uo,disabled:R,children:[R?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),r.jsx(wt,{open:g,onOpenChange:b,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:"Loop History"})}),r.jsx("div",{className:"space-y-3 py-4",children:wr.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):wr.slice().reverse().map(te=>r.jsxs("div",{className:"border rounded-lg p-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[Ca[te.status]||Ca.completed,r.jsx("span",{className:"font-medium",children:te.name})]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:eo(te.completedAt)})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:te.task}),r.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:r.jsxs("span",{children:["Iterations: ",te.totalIterations]})})]},te.id))})]})}),r.jsx(wt,{open:k,onOpenChange:E,children:r.jsxs(xt,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsx(yt,{children:(P==null?void 0:P.name)||"Loop Details"})}),P&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Phase"}),r.jsx("span",{className:`text-sm px-2 py-0.5 rounded-full ${g_[P.phase]||""}`,children:P.phase})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),r.jsxs("div",{className:"flex items-center gap-1",children:[Ca[P.status],r.jsx("span",{children:P.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Progress"}),r.jsxs("span",{children:[((Ko=P.iterations)==null?void 0:Ko.current)||0," / ",((ll=P.iterations)==null?void 0:ll.max)||50]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Task"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm",children:(cl=P.task)==null?void 0:cl.original})]}),P.clarifications&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Clarifications"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-40 overflow-y-auto",children:P.clarifications})]}),P.plan&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Plan"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-60 overflow-y-auto font-mono",children:P.plan})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Max Iterations"}),r.jsx("div",{className:"bg-muted p-2 rounded text-sm",children:((dl=P.iterations)==null?void 0:dl.max)||50})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Completion Promise"}),r.jsxs("div",{className:"bg-muted p-2 rounded text-sm font-mono",children:["<promise>",P.completionPromise||"DONE","</promise>"]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command (uses official ralph-loop plugin)"}),r.jsx("code",{className:"text-xs bg-muted p-3 rounded block whitespace-pre-wrap",children:Nt(P,!0)})]})]})]})}),r.jsx(wt,{open:Ps,onOpenChange:As,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-5 h-5"}),"Install ralph-loop Plugin"]})}),r.jsxs("div",{className:"py-4",children:[r.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["The ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"ralph-loop"})," plugin is required to run loops. This plugin provides the ",r.jsx("code",{className:"bg-muted px-1 rounded",children:"/ralph-loop"})," command that enables autonomous iteration."]}),Us.scope==="project"&&r.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded p-3 mb-4",children:r.jsxs("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:["Plugin is currently installed only for project: ",r.jsx("br",{}),r.jsx("code",{className:"text-xs",children:Us.projectPath})]})}),r.jsx("p",{className:"text-sm",children:"Install the plugin globally (user scope) to use loops from any project?"})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:or,disabled:ms,children:"Cancel"}),r.jsx(re,{onClick:Ot,disabled:ms,children:ms?r.jsxs(r.Fragment,{children:[r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}),"Installing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ui,{className:"w-4 h-4 mr-1"}),"Install Plugin"]})})]})]})}),r.jsx(Lj,{open:rr,onOpenChange:te=>{Wr(te),te||(fr(null),Cr())},title:ut?`Loop: ${ut.name}`:"Running Loop",description:ut?((ro=(qo=ut.task)==null?void 0:qo.original)==null?void 0:ro.substring(0,100))+(((dn=(cn=ut.task)==null?void 0:cn.original)==null?void 0:dn.length)>100?"...":""):"",cwd:ut==null?void 0:ut.projectPath,initialCommand:ut?Nt(ut).startCmd:"",delayedCommand:ut?Nt(ut).skillCmd:"",delayedCommandDelay:5e3,env:ut?{CODER_LOOP_ID:ut.id,...ut.workstreamId&&{CODER_WORKSTREAM:ut.workstreamId}}:{},onExit:jt,headerExtra:r.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[r.jsx("input",{type:"checkbox",checked:Xr,onChange:te=>Jr(te.target.checked),className:"rounded"}),"Auto-close when done"]})}),r.jsx(wt,{open:se,onOpenChange:de,children:r.jsxs(xt,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(os,{className:"w-5 h-5 text-purple-500"}),"AI-Tuned Prompt"]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2 text-muted-foreground",children:"Original Prompt"}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-32 overflow-y-auto",children:W})]}),r.jsxs("div",{children:[r.jsxs("h4",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[r.jsx(Yt,{className:"w-4 h-4 text-purple-500"}),"Tuned Prompt"]}),r.jsx(Ct,{value:pe,onChange:te=>X(te.target.value),rows:10,className:"font-mono text-sm"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"You can edit the tuned prompt before accepting it."})]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:Ho,children:"Keep Original"}),r.jsxs(re,{onClick:ln,children:[r.jsx($t,{className:"w-4 h-4 mr-1"}),"Use Tuned Prompt"]})]})]})}),r.jsx(wt,{open:le,onOpenChange:we,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[r.jsx(Kd,{className:"w-5 h-5"}),"Resume Loop"]})}),r.jsx("div",{className:"py-4",children:Le&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-sm mb-4",children:["This loop ",Le.status==="failed"?"failed":Le.status==="cancelled"?"was cancelled":"was paused",Le.pauseReason&&`: ${Le.pauseReason}`]}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Would you like to tune the prompt with AI before resuming? This can help add guardrails based on what went wrong."}),r.jsx("div",{className:"bg-muted p-3 rounded text-sm max-h-32 overflow-y-auto",children:(un=Le.task)==null?void 0:un.original})]})}),r.jsxs(kt,{className:"flex-col sm:flex-row gap-2",children:[r.jsx(re,{variant:"outline",onClick:()=>{we(!1),Ke(null)},children:"Cancel"}),r.jsx(re,{variant:"secondary",onClick:Wo,children:"Resume As-Is"}),r.jsxs(re,{onClick:Ut,disabled:V,children:[V?r.jsx(Ze,{className:"w-4 h-4 animate-spin mr-1"}):r.jsx(os,{className:"w-4 h-4 mr-1"}),"Tune & Resume"]})]})]})}),r.jsx(wt,{open:sl,onOpenChange:ps,children:r.jsxs(xt,{className:"sm:max-w-md",children:[r.jsx(vt,{children:r.jsxs(yt,{className:"flex items-center gap-2",children:[(Qe==null?void 0:Qe.status)==="completed"&&r.jsxs(r.Fragment,{children:[r.jsx(No,{className:"w-5 h-5 text-green-600"})," Loop Completed"]}),(Qe==null?void 0:Qe.status)==="paused"&&r.jsxs(r.Fragment,{children:[r.jsx(xp,{className:"w-5 h-5 text-yellow-500"})," Loop Paused"]}),(Qe==null?void 0:Qe.status)==="failed"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-red-500"})," Loop Failed"]}),(Qe==null?void 0:Qe.status)==="cancelled"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"w-5 h-5 text-gray-500"})," Loop Cancelled"]})]})}),Qe&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Task"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.task})]}),Qe.pauseReason&&r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-1",children:"Reason"}),r.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:Qe.pauseReason})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),r.jsxs("div",{className:"font-medium flex items-center gap-1",children:[Ca[Qe.status],r.jsx("span",{className:"capitalize",children:Qe.status})]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Iterations"}),r.jsxs("div",{className:"font-medium",children:[Qe.iterations," / ",Qe.maxIterations]})]}),r.jsxs("div",{className:"border rounded p-3",children:[r.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Duration"}),r.jsx("div",{className:"font-medium",children:Qe.duration!=null?Qe.duration<60?`${Qe.duration}s`:Qe.duration<3600?`${Math.floor(Qe.duration/60)}m ${Qe.duration%60}s`:`${Math.floor(Qe.duration/3600)}h ${Math.floor(Qe.duration%3600/60)}m`:"-"})]})]}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:[Qe.status==="completed"?"Completed":"Stopped"," at ",eo(Qe.completedAt)]})]}),r.jsxs(kt,{children:[r.jsx(re,{variant:"outline",onClick:()=>ps(!1),children:"Close"}),((Qe==null?void 0:Qe.status)==="paused"||(Qe==null?void 0:Qe.status)==="failed"||(Qe==null?void 0:Qe.status)==="cancelled")&&r.jsxs(re,{onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&vi(te)}},children:[r.jsx(Kd,{className:"w-4 h-4 mr-1"}),(Qe==null?void 0:Qe.status)==="paused"?"Resume":"Restart"]}),r.jsx(re,{variant:"secondary",onClick:()=>{if(ps(!1),Qe!=null&&Qe.id){const te=t.find(Me=>Me.id===Qe.id);te&&zc(te)}},children:"View Details"})]})]})})]})}function pW(e,t=[]){let s=[];function n(c,u){const l=_.createContext(u);l.displayName=c+"Context";const d=s.length;s=[...s,u];const f=h=>{var y;const{scope:x,children:w,...j}=h,C=((y=x==null?void 0:x[e])==null?void 0:y[d])||l,v=_.useMemo(()=>j,Object.values(j));return r.jsx(C.Provider,{value:v,children:w})};f.displayName=c+"Provider";function m(h,x){var C;const w=((C=x==null?void 0:x[e])==null?void 0:C[d])||l,j=_.useContext(w);if(j)return j;if(u!==void 0)return u;throw new Error(`\`${h}\` must be used within \`${c}\``)}return[f,m]}const o=()=>{const c=s.map(u=>_.createContext(u));return function(l){const d=(l==null?void 0:l[e])||c;return _.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return o.scopeName=e,[n,gW(o,...t)]}function gW(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const u=n.reduce((l,{useScope:d,scopeName:f})=>{const h=d(c)[`__scope${f}`];return{...l,...h}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])}};return s.scopeName=t.scopeName,s}var xW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],v2=xW.reduce((e,t)=>{const s=Yu(`Primitive.${t}`),n=_.forwardRef((o,c)=>{const{asChild:u,...l}=o,d=u?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...l,ref:c})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Wx="Progress",Vx=100,[vW]=pW(Wx),[yW,bW]=vW(Wx),y2=_.forwardRef((e,t)=>{const{__scopeProgress:s,value:n=null,max:o,getValueLabel:c=wW,...u}=e;(o||o===0)&&!x_(o)&&console.error(_W(`${o}`,"Progress"));const l=x_(o)?o:Vx;n!==null&&!v_(n,l)&&console.error(CW(`${n}`,"Progress"));const d=v_(n,l)?n:null,f=Bu(d)?c(d,l):void 0;return r.jsx(yW,{scope:s,value:d,max:l,children:r.jsx(v2.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Bu(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":_2(d,l),"data-value":d??void 0,"data-max":l,...u,ref:t})})});y2.displayName=Wx;var b2="ProgressIndicator",w2=_.forwardRef((e,t)=>{const{__scopeProgress:s,...n}=e,o=bW(b2,s);return r.jsx(v2.div,{"data-state":_2(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...n,ref:t})});w2.displayName=b2;function wW(e,t){return`${Math.round(e/t*100)}%`}function _2(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Bu(e){return typeof e=="number"}function x_(e){return Bu(e)&&!isNaN(e)&&e>0}function v_(e,t){return Bu(e)&&!isNaN(e)&&e<=t&&e>=0}function _W(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Vx}\`.`}function CW(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
3007
3007
|
- a positive number
|
|
3008
3008
|
- less than the value passed to \`max\` (or ${Vx} if no \`max\` prop is set)
|
|
3009
3009
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
package/ui/dist/index.html
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
<!-- PWA Manifest -->
|
|
21
21
|
<link rel="manifest" href="/manifest.json">
|
|
22
|
-
<script type="module" crossorigin src="/assets/index-
|
|
22
|
+
<script type="module" crossorigin src="/assets/index-BgxtqcxY.js"></script>
|
|
23
23
|
<link rel="stylesheet" crossorigin href="/assets/index-ChBU02w_.css">
|
|
24
24
|
</head>
|
|
25
25
|
<body>
|