loki-mode 6.64.0 → 6.64.2
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/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/loki +43 -11
- package/autonomy/run.sh +61 -21
- package/dashboard/__init__.py +1 -1
- package/dashboard/server.py +59 -2
- package/docs/INSTALLATION.md +1 -1
- package/mcp/__init__.py +1 -1
- package/package.json +1 -1
- package/web-app/dist/assets/{Badge-8l0OZCRe.js → Badge-CecAeNGh.js} +1 -1
- package/web-app/dist/assets/{Button-6k_tnJgc.js → Button-BAwZY3QB.js} +1 -1
- package/web-app/dist/assets/{Card-DwkzVihG.js → Card-3YIYrz1X.js} +1 -1
- package/web-app/dist/assets/{HomePage-C0-_6Avk.js → HomePage-DYS0zqqT.js} +1 -1
- package/web-app/dist/assets/{LoginPage-BlJm-Tzr.js → LoginPage-D5Jj_Q44.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-CsRjjzWq.js → NotFoundPage-DLG6ORdp.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-DQG_ZYM7.js → ProjectPage-D-ZyzZUT.js} +12 -12
- package/web-app/dist/assets/{ProjectsPage-BAQOc1tx.js → ProjectsPage-CMacaz1V.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-DiKaBtvg.js → SettingsPage-B9XKC6ge.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-CyxNji74.js → TemplatesPage-Bq8ASiy4.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-BLPNvDc5.js → TerminalOutput-rQ65EXIP.js} +1 -1
- package/web-app/dist/assets/{arrow-left-dP_J0CkC.js → arrow-left-BcsRbWot.js} +1 -1
- package/web-app/dist/assets/{clock-CGZn7bQ1.js → clock-DUeIWW98.js} +1 -1
- package/web-app/dist/assets/{external-link-ypPFWwc1.js → external-link-lxSyZieU.js} +1 -1
- package/web-app/dist/assets/{index-tGQw_JnU.js → index-Cyfnu-vw.js} +2 -2
- package/web-app/dist/index.html +1 -1
- package/web-app/server.py +133 -45
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as p,u as C,r as a,a as j,j as e}from"./index-
|
|
1
|
+
import{c as p,u as C,r as a,a as j,j as e}from"./index-Cyfnu-vw.js";import{B as b,P as y,F,T as S}from"./Button-BAwZY3QB.js";import{C as P}from"./Card-3YIYrz1X.js";import{u as _,B}from"./Badge-CecAeNGh.js";import{E as z}from"./external-link-lxSyZieU.js";import"./clock-DUeIWW98.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,a,j as e}from"./index-
|
|
1
|
+
import{r as t,a,j as e}from"./index-Cyfnu-vw.js";import{C as l}from"./Card-3YIYrz1X.js";import{E as c}from"./external-link-lxSyZieU.js";const h=[{id:"claude",name:"Claude",description:"Anthropic Claude Code -- full features"},{id:"codex",name:"Codex",description:"OpenAI Codex CLI -- degraded mode"},{id:"gemini",name:"Gemini",description:"Google Gemini CLI -- degraded mode"}];function p(){const[i,n]=t.useState("claude"),[o,r]=t.useState(!1),[d,x]=t.useState("");t.useEffect(()=>{a.getCurrentProvider().then(s=>n(s.provider)).catch(()=>{}),a.getStatus().then(s=>x(s.version||"")).catch(()=>{})},[]);const m=async s=>{n(s),r(!0);try{await a.setProvider(s)}catch{}finally{r(!1)}};return e.jsxs("div",{className:"max-w-[800px] mx-auto px-6 py-8",children:[e.jsx("h1",{className:"font-heading text-h1 text-[#36342E] mb-8",children:"Settings"}),e.jsxs("section",{className:"mb-10",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#36342E] uppercase tracking-wide mb-4",children:"Provider"}),e.jsx("div",{className:"flex flex-col gap-3",children:h.map(s=>e.jsx(l,{hover:!0,onClick:()=>m(s.id),className:i===s.id?"ring-2 ring-[#553DE9] border-[#553DE9]":"",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center flex-shrink-0 ${i===s.id?"border-[#553DE9]":"border-[#ECEAE3]"}`,children:i===s.id&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-[#553DE9]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[#36342E]",children:s.name}),e.jsx("p",{className:"text-xs text-[#6B6960]",children:s.description})]})]})},s.id))}),o&&e.jsx("p",{className:"text-xs text-[#6B6960] mt-2",children:"Saving..."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-sm font-semibold text-[#36342E] uppercase tracking-wide mb-4",children:"About"}),e.jsx(l,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[d&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[#6B6960]",children:"Version"}),e.jsxs("span",{className:"text-sm font-medium text-[#36342E]",children:["v",d]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[#6B6960]",children:"Documentation"}),e.jsxs("a",{href:"https://www.autonomi.dev/docs",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-[#553DE9] hover:underline",children:["autonomi.dev/docs ",e.jsx(c,{size:12})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[#6B6960]",children:"GitHub"}),e.jsxs("a",{href:"https://github.com/asklokesh/loki-mode",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-[#553DE9] hover:underline",children:["asklokesh/loki-mode ",e.jsx(c,{size:12})]})]})]})})]})]})}export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as c,r,a as x,j as t}from"./index-
|
|
1
|
+
import{u as c,r,a as x,j as t}from"./index-Cyfnu-vw.js";import{C as p}from"./Card-3YIYrz1X.js";import{u as d,B as h}from"./Badge-CecAeNGh.js";import"./clock-DUeIWW98.js";const g=[{key:"all",label:"All"},{key:"website",label:"Website"},{key:"api",label:"API"},{key:"cli",label:"CLI"},{key:"bot",label:"Bot"},{key:"data",label:"Data"},{key:"other",label:"Other"}];function u(l){return l.replace(/\.md$/i,"").replace(/[-_]/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function k(){const l=c(),[a,o]=r.useState("all"),n=r.useCallback(()=>x.getTemplates(),[]),{data:s}=d(n,6e4,!0),i=r.useMemo(()=>s?a==="all"?s:s.filter(e=>(e.category||"other")===a):[],[s,a]),m=e=>{sessionStorage.setItem("pl_template",e),l("/")};return t.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[t.jsx("h1",{className:"font-heading text-h1 text-[#36342E] mb-6",children:"Templates"}),t.jsx("div",{className:"flex items-center gap-1 mb-6",role:"tablist",children:g.map(e=>t.jsx("button",{role:"tab","aria-selected":a===e.key,onClick:()=>o(e.key),className:`px-3 py-1.5 text-xs font-semibold rounded-[3px] transition-colors ${a===e.key?"bg-[#553DE9] text-white":"text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0]"}`,children:e.label},e.key))}),s?i.length===0?t.jsx("p",{className:"text-sm text-[#6B6960] py-12 text-center",children:"No templates in this category."}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(e=>t.jsxs(p,{hover:!0,onClick:()=>m(e.filename),children:[t.jsx("div",{className:"mb-2",children:t.jsx(h,{status:"version",children:e.category||"other"})}),t.jsx("h3",{className:"text-sm font-medium text-[#36342E] mb-1",children:u(e.name)}),t.jsx("p",{className:"text-xs text-[#6B6960]",children:e.filename})]},e.filename))}):t.jsx("p",{className:"text-sm text-[#6B6960]",children:"Loading templates..."})]})}export{k as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-DYS0zqqT.js","assets/Badge-CecAeNGh.js","assets/clock-DUeIWW98.js","assets/TerminalOutput-rQ65EXIP.js","assets/ProjectPage-D-ZyzZUT.js","assets/Button-BAwZY3QB.js","assets/arrow-left-BcsRbWot.js","assets/external-link-lxSyZieU.js","assets/ProjectPage-9CEnUXvW.css","assets/ProjectsPage-CMacaz1V.js","assets/Card-3YIYrz1X.js","assets/TemplatesPage-Bq8ASiy4.js","assets/SettingsPage-B9XKC6ge.js","assets/NotFoundPage-DLG6ORdp.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var S0=Object.defineProperty;var b0=(i,f,r)=>f in i?S0(i,f,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[f]=r;var Bn=(i,f,r)=>b0(i,typeof f!="symbol"?f+"":f,r);(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))o(d);new MutationObserver(d=>{for(const h of d)if(h.type==="childList")for(const g of h.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&o(g)}).observe(document,{childList:!0,subtree:!0});function r(d){const h={};return d.integrity&&(h.integrity=d.integrity),d.referrerPolicy&&(h.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?h.credentials="include":d.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function o(d){if(d.ep)return;d.ep=!0;const h=r(d);fetch(d.href,h)}})();function E0(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Bf={exports:{}},Ln={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -183,4 +183,4 @@ Please change the parent <Route path="${B}"> to <Route path="${B==="/"?"*":`${B}
|
|
|
183
183
|
*
|
|
184
184
|
* This source code is licensed under the ISC license.
|
|
185
185
|
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const k1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Kh=Jt("x",k1),Jh=`${window.location.origin}/api`,W1=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;function F1(){const i={"Content-Type":"application/json"};try{const f=localStorage.getItem("pl_auth_token");f&&(i.Authorization=`Bearer ${f}`)}catch{}return i}async function $(i,f){const r=await fetch(`${Jh}${i}`,{...f,headers:{...F1(),...f==null?void 0:f.headers}});if(!r.ok){const o=await r.text().catch(()=>"");throw new Error(`API error ${r.status}: ${r.statusText}${o?` - ${o}`:""}`)}return r.json()}const qa={startSession:i=>$("/session/start",{method:"POST",body:JSON.stringify(i)}),stopSession:()=>$("/session/stop",{method:"POST"}),pauseSession:()=>$("/session/pause",{method:"POST"}),resumeSession:()=>$("/session/resume",{method:"POST"}),getPrdPrefill:()=>$("/session/prd-prefill"),getStatus:()=>$("/session/status"),getAgents:()=>$("/session/agents"),getLogs:(i=200)=>$(`/session/logs?lines=${i}`),getMemorySummary:()=>$("/session/memory"),getChecklist:()=>$("/session/checklist"),getFiles:()=>$("/session/files"),getFileContent:i=>$(`/session/files/content?path=${encodeURIComponent(i)}`),getSessionFileContent:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/file?path=${encodeURIComponent(f)}`),getTemplates:()=>$("/templates"),getTemplateContent:i=>$(`/templates/${encodeURIComponent(i)}`),planSession:(i,f)=>$("/session/plan",{method:"POST",body:JSON.stringify({prd:i,provider:f})}),generateReport:(i="markdown")=>$("/session/report",{method:"POST",body:JSON.stringify({format:i})}),shareSession:()=>$("/session/share",{method:"POST"}),getCurrentProvider:()=>$("/provider/current"),setProvider:i=>$("/provider/set",{method:"POST",body:JSON.stringify({provider:i})}),getMetrics:()=>$("/session/metrics"),getSessionsHistory:()=>$("/sessions/history"),getSessionDetail:i=>$(`/sessions/${encodeURIComponent(i)}`),deleteSession:i=>$(`/sessions/${encodeURIComponent(i)}`,{method:"DELETE"}),onboardRepo:i=>$("/session/onboard",{method:"POST",body:JSON.stringify({path:i})}),saveSessionFile:(i,f,r)=>$(`/sessions/${encodeURIComponent(i)}/file`,{method:"PUT",body:JSON.stringify({path:f,content:r})}),createSessionFile:(i,f,r="")=>$(`/sessions/${encodeURIComponent(i)}/file`,{method:"POST",body:JSON.stringify({path:f,content:r})}),deleteSessionFile:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/file`,{method:"DELETE",body:JSON.stringify({path:f})}),createSessionDirectory:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/directory`,{method:"POST",body:JSON.stringify({path:f})}),reviewProject:i=>$(`/sessions/${encodeURIComponent(i)}/review`,{method:"POST"}),testProject:i=>$(`/sessions/${encodeURIComponent(i)}/test`,{method:"POST"}),explainProject:i=>$(`/sessions/${encodeURIComponent(i)}/explain`,{method:"POST"}),exportProject:i=>$(`/sessions/${encodeURIComponent(i)}/export`,{method:"POST"}),fixProject:i=>$(`/sessions/${encodeURIComponent(i)}/fix`,{method:"POST"}),chatMessage:(i,f,r="quick")=>$(`/sessions/${encodeURIComponent(i)}/chat`,{method:"POST",body:JSON.stringify({message:f,mode:r})}),chatStart:(i,f,r="quick")=>$(`/sessions/${encodeURIComponent(i)}/chat`,{method:"POST",body:JSON.stringify({message:f,mode:r})}),chatPoll:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/chat/${encodeURIComponent(f)}`),chatStreamUrl:(i,f)=>`${Jh}/sessions/${encodeURIComponent(i)}/chat/${encodeURIComponent(f)}/stream`,chatCancel:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/chat/${encodeURIComponent(f)}/cancel`,{method:"POST"}),getPreviewInfo:i=>$(`/sessions/${encodeURIComponent(i)}/preview-info`),devserver:{start:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/devserver/start`,{method:"POST",body:JSON.stringify({command:f||null})}),stop:i=>$(`/sessions/${encodeURIComponent(i)}/devserver/stop`,{method:"POST"}),status:i=>$(`/sessions/${encodeURIComponent(i)}/devserver/status`)},getSecrets:()=>$("/secrets"),setSecret:(i,f)=>$("/secrets",{method:"POST",body:JSON.stringify({key:i,value:f})}),deleteSecret:i=>$(`/secrets/${encodeURIComponent(i)}`,{method:"DELETE"}),getServices:i=>$(`/sessions/${encodeURIComponent(i)}/services`),getServiceLogs:(i,f,r=50)=>$(`/sessions/${encodeURIComponent(i)}/devserver/logs${f?`?service=${encodeURIComponent(f)}&tail=${r}`:`?tail=${r}`}`),restartService:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/devserver/restart-service`,{method:"POST",body:JSON.stringify({service:f})}),getMe:()=>$("/auth/me"),getGitHubAuthUrl:()=>$("/auth/github/url"),getGoogleAuthUrl:()=>$("/auth/google/url"),githubCallback:(i,f)=>$("/auth/github/callback",{method:"POST",body:JSON.stringify({code:i,state:f})}),googleCallback:(i,f,r)=>$("/auth/google/callback",{method:"POST",body:JSON.stringify({code:i,state:f,redirect_uri:r||`${window.location.origin}${window.location.pathname}`})})};class I1{constructor(f){Bn(this,"ws",null);Bn(this,"listeners",new Map);Bn(this,"reconnectTimer",null);Bn(this,"url");this.url=f||W1}connect(){var f;((f=this.ws)==null?void 0:f.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.emit("connected",{message:"WebSocket connected"})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.emit(o.type,o.data||o)}catch{}},this.ws.onclose=()=>{this.emit("disconnected",{}),this.scheduleReconnect()},this.ws.onerror=()=>{var r;(r=this.ws)==null||r.close()})}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},3e3))}on(f,r){return this.listeners.has(f)||this.listeners.set(f,new Set),this.listeners.get(f).add(r),()=>{var o;return(o=this.listeners.get(f))==null?void 0:o.delete(r)}}emit(f,r){var o,d;(o=this.listeners.get(f))==null||o.forEach(h=>h(r)),(d=this.listeners.get("*"))==null||d.forEach(h=>h({type:f,data:r}))}send(f){var r;((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(f))}disconnect(){var f;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(f=this.ws)==null||f.close(),this.ws=null}}const Vf="pl_auth_token",$h=E.createContext({user:null,loading:!0,login:()=>{},logout:()=>{},isLocalMode:!0});function P1(i,f,r){f(!1),r({email:i.sub||i.email||"",name:i.name||"",avatar_url:i.avatar||"",authenticated:!0})}function tg({children:i}){const[f,r]=E.useState(null),[o,d]=E.useState(!0),[h,g]=E.useState(!0),_=Ff(),S=je();E.useEffect(()=>{let j=!1;async function w(){const Z=new URLSearchParams(window.location.search),Y=Z.get("token"),G=Z.get("code");if(Y)localStorage.setItem(Vf,Y),window.history.replaceState({},"",window.location.pathname);else if(G)try{const B=sessionStorage.getItem("pl_oauth_provider")||"github",F=sessionStorage.getItem("pl_oauth_state")||"";sessionStorage.removeItem("pl_oauth_state"),sessionStorage.removeItem("pl_oauth_provider");let K;if(B==="google"?K=await qa.googleCallback(G,F):K=await qa.githubCallback(G,F),!j){localStorage.setItem(Vf,K.token),window.history.replaceState({},"",window.location.pathname),g(!1),r({email:K.user.email,name:K.user.name,avatar_url:K.user.avatar_url,authenticated:!0}),d(!1);return}}catch{window.history.replaceState({},"",window.location.pathname)}try{const B=await qa.getMe();if(j)return;B.local_mode?(g(!0),r(null)):B.authenticated?P1(B,g,r):(g(!1),r(null))}catch{if(j)return;g(!0),r(null)}finally{j||d(!1)}}return w(),()=>{j=!0}},[]);const y=E.useCallback(j=>{j==="github"?qa.getGitHubAuthUrl().then(w=>{try{const Y=new URL(w.url).searchParams.get("state");Y&&(sessionStorage.setItem("pl_oauth_state",Y),sessionStorage.setItem("pl_oauth_provider","github"))}catch{}window.location.href=w.url}).catch(()=>{}):j==="google"&&qa.getGoogleAuthUrl().then(w=>{try{const Y=new URL(w.url).searchParams.get("state");Y&&(sessionStorage.setItem("pl_oauth_state",Y),sessionStorage.setItem("pl_oauth_provider","google"))}catch{}window.location.href=w.url}).catch(()=>{})},[]),C=E.useCallback(()=>{localStorage.removeItem(Vf),r(null),S.pathname!=="/login"&&_("/login",{replace:!0})},[_,S.pathname]),z=E.useMemo(()=>({user:f,loading:o,login:y,logout:C,isLocalMode:h}),[f,o,y,C,h]);return O.jsx($h.Provider,{value:z,children:i})}function kh(){return E.useContext($h)}const Th="pl_sidebar_collapsed",eg=[{to:"/",label:"Home",icon:N1},{to:"/projects",label:"Projects",icon:C1},{to:"/templates",label:"Templates",icon:D1}],lg=[{to:"/settings",label:"Settings",icon:Vh}];function ag(){const[i,f]=E.useState(typeof window<"u"?window.innerWidth<768:!1);return E.useEffect(()=>{const r=()=>f(window.innerWidth<768);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),i}function ng({wsConnected:i,version:f}){const r=ag(),o=je(),[d,h]=E.useState(!1),[g,_]=E.useState(()=>{try{return localStorage.getItem(Th)==="1"}catch{return!1}});E.useEffect(()=>{try{localStorage.setItem(Th,g?"1":"0")}catch{}},[g]),E.useEffect(()=>{r&&h(!1)},[o.pathname,r]);const S=r?d:!g,y=S?240:64,C=j=>["flex items-center gap-3 px-3 py-2 text-sm transition-colors rounded-[5px]",!S&&"justify-center",j?"bg-[#553DE9]/8 text-[#553DE9] font-medium border-l-2 border-[#553DE9]":"text-[#36342E] hover:bg-[#F8F4F0]"].filter(Boolean).join(" "),z=O.jsxs("aside",{className:"flex flex-col h-full border-r border-[#ECEAE3] bg-white transition-[width] duration-200",style:{width:y,minWidth:y},children:[O.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-b border-[#ECEAE3]",children:[S&&O.jsxs("div",{className:"flex flex-col",children:[O.jsx("span",{className:"font-heading text-lg font-bold leading-tight text-[#36342E]",children:"Purple Lab"}),O.jsx("span",{className:"text-xs text-[#6B6960]",children:"Powered by Loki"})]}),r?O.jsx("button",{type:"button","aria-label":d?"Close menu":"Open menu",title:d?"Close menu":"Open menu",onClick:()=>h(!d),className:"inline-flex items-center justify-center w-7 h-7 rounded-[3px] text-[#939084] hover:bg-[#F8F4F0] transition-colors",children:d?O.jsx(Kh,{size:16}):O.jsx(L1,{size:16})}):O.jsx("button",{type:"button","aria-label":g?"Expand sidebar":"Collapse sidebar",title:g?"Expand sidebar":"Collapse sidebar",onClick:()=>_(!g),className:"inline-flex items-center justify-center w-7 h-7 rounded-[3px] text-[#939084] hover:bg-[#F8F4F0] transition-colors",children:g?O.jsx(V1,{size:16}):O.jsx(Q1,{size:16})})]}),O.jsxs("nav",{className:"flex-1 px-2 py-3 flex flex-col gap-1","aria-label":"Main navigation",children:[eg.map(j=>O.jsxs(di,{to:j.to,end:j.to==="/",className:({isActive:w})=>C(w),title:S?void 0:j.label,children:[O.jsx(j.icon,{size:18}),S&&O.jsx("span",{children:j.label})]},j.to)),O.jsx("div",{className:"my-2 border-t border-[#ECEAE3]"}),lg.map(j=>O.jsxs(di,{to:j.to,className:({isActive:w})=>C(w),title:S?void 0:j.label,children:[O.jsx(j.icon,{size:18}),S&&O.jsx("span",{children:j.label})]},j.to))]}),O.jsxs("div",{className:"px-3 py-3 border-t border-[#ECEAE3] flex flex-col gap-2",children:[O.jsx(ug,{collapsed:!S}),O.jsxs("div",{className:["flex items-center gap-2 text-xs",!S&&"justify-center"].filter(Boolean).join(" "),children:[O.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${i?"bg-[#1FC5A8]":"bg-[#C45B5B]"}`}),S&&O.jsx("span",{className:"text-[#6B6960]",children:i?"Connected":"Disconnected"})]}),S&&f&&O.jsxs("span",{className:"text-xs text-[#6B6960]",children:["v",f]}),O.jsxs("a",{href:"https://www.autonomi.dev/docs",target:"_blank",rel:"noopener noreferrer",className:["flex items-center gap-2 text-xs text-[#6B6960] hover:text-[#36342E] transition-colors",!S&&"justify-center"].filter(Boolean).join(" "),title:S?void 0:"Documentation",children:[O.jsx(E1,{size:14}),S&&O.jsx("span",{children:"Docs"})]})]})]});return r&&d?O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"fixed inset-0 z-40 bg-ink/20",onClick:()=>h(!1)}),O.jsx("div",{className:"fixed inset-y-0 left-0 z-50",children:z})]}):z}function ug({collapsed:i}){const{user:f,logout:r,isLocalMode:o}=kh(),[d,h]=E.useState(!1),g=E.useRef(null);return E.useEffect(()=>{function _(S){g.current&&!g.current.contains(S.target)&&h(!1)}if(d)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[d]),o||!f?O.jsxs("div",{className:["flex items-center gap-2 text-xs",i&&"justify-center"].filter(Boolean).join(" "),title:i?"Local Mode":void 0,children:[O.jsx(G1,{size:14,className:"text-[#939084] flex-shrink-0"}),!i&&O.jsx("span",{className:"text-[#939084]",children:"Local Mode"})]}):O.jsxs("div",{className:"relative",ref:g,"data-testid":"user-section",children:[O.jsxs("button",{type:"button",onClick:()=>h(!d),className:["flex items-center gap-2 w-full text-left text-xs rounded-[3px] py-1 px-1 hover:bg-[#F8F4F0] transition-colors",i&&"justify-center"].filter(Boolean).join(" "),title:i?f.name||f.email:void 0,children:[f.avatar_url?O.jsx("img",{src:f.avatar_url,alt:"",className:"w-5 h-5 rounded-full flex-shrink-0"}):O.jsx("div",{className:"w-5 h-5 rounded-full bg-[#553DE9] flex items-center justify-center text-white text-[10px] font-bold flex-shrink-0",children:(f.name||f.email||"?")[0].toUpperCase()}),!i&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"text-[#36342E] truncate flex-1",children:f.name||f.email}),O.jsx(T1,{size:12,className:`text-[#939084] transition-transform ${d?"":"rotate-180"}`})]})]}),d&&O.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-48 bg-white border border-[#ECEAE3] rounded-lg shadow-lg py-1 z-50",children:[O.jsxs("div",{className:"px-3 py-2 border-b border-[#ECEAE3]",children:[O.jsx("p",{className:"text-xs font-medium text-[#36342E] truncate",children:f.name}),O.jsx("p",{className:"text-xs text-[#939084] truncate",children:f.email})]}),O.jsxs(di,{to:"/settings",onClick:()=>h(!1),className:"flex items-center gap-2 px-3 py-2 text-xs text-[#36342E] hover:bg-[#F8F4F0] transition-colors",children:[O.jsx(Vh,{size:14}),"Settings"]}),O.jsxs("button",{type:"button",onClick:()=>{h(!1),r()},className:"flex items-center gap-2 px-3 py-2 text-xs text-[#C45B5B] hover:bg-[#F8F4F0] transition-colors w-full text-left",children:[O.jsx(H1,{size:14}),"Sign out"]})]})]})}const zh="pl_onboarding_complete",wn=[{icon:R1,title:"Write your PRD",description:"Describe what you want to build, or choose a template to get started quickly."},{icon:$1,title:"Use the terminal",description:"Run commands directly in the integrated terminal to install dependencies or debug."},{icon:_1,title:"Preview in real-time",description:"Switch to the Preview tab to see your app running with live reload."},{icon:Y1,title:"Iterate with AI Chat",description:"Ask the AI to modify, fix, or explain your code in the chat panel."}];function ig(){const[i,f]=E.useState(!1),[r,o]=E.useState(0);E.useEffect(()=>{try{localStorage.getItem(zh)!=="1"&&f(!0)}catch{}},[]);const d=()=>{f(!1);try{localStorage.setItem(zh,"1")}catch{}},h=()=>{r<wn.length-1?o(r+1):d()};if(!i)return null;const g=wn[r],_=g.icon;return O.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/30",children:O.jsxs("div",{className:"bg-card rounded-card shadow-card-hover border border-border w-full max-w-sm mx-4",children:[O.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-2",children:[O.jsxs("span",{className:"text-[11px] font-mono text-muted-accessible",children:[r+1," / ",wn.length]}),O.jsx("button",{onClick:d,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",title:"Skip onboarding",children:O.jsx(Kh,{size:14})})]}),O.jsxs("div",{className:"px-5 pb-4 text-center",children:[O.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-4",children:O.jsx(_,{size:24,className:"text-primary"})}),O.jsx("h3",{className:"text-sm font-heading font-bold text-ink mb-1",children:g.title}),O.jsx("p",{className:"text-xs text-muted-accessible leading-relaxed",children:g.description})]}),O.jsx("div",{className:"flex items-center justify-center gap-1.5 pb-4",children:wn.map((S,y)=>O.jsx("div",{className:`w-1.5 h-1.5 rounded-full transition-colors ${y===r?"bg-primary":"bg-border"}`},y))}),O.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border",children:[O.jsx("button",{onClick:d,className:"text-xs text-muted hover:text-ink transition-colors",children:"Skip"}),O.jsx("button",{onClick:h,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:r<wn.length-1?O.jsxs(O.Fragment,{children:["Next",O.jsx(S1,{size:12})]}):"Get Started"})]})]})})}function cg(i){const[f,r]=E.useState(!1),o=E.useRef(null),d=E.useRef(i);E.useEffect(()=>{d.current=i},[i]),E.useEffect(()=>{const g=new I1;return o.current=g,g.on("connected",()=>r(!0)),g.on("disconnected",()=>{r(!1),d.current&&d.current(null)}),g.on("state_update",_=>{d.current&&_&&typeof _=="object"&&d.current(_)}),g.connect(),()=>{g.disconnect(),o.current=null}},[]);const h=E.useCallback((g,_)=>{var S;return((S=o.current)==null?void 0:S.on(g,_))||(()=>{})},[]);return{connected:f,subscribe:h}}function fg(){const[i,f]=E.useState(""),{connected:r}=cg(()=>{});return E.useEffect(()=>{qa.getStatus().then(o=>{f(o.version||"")}).catch(()=>{})},[]),O.jsxs("div",{className:"flex h-screen bg-[#FAF9F6]",children:[O.jsx(ig,{}),O.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:top-2 focus:left-2 focus:px-4 focus:py-2 focus:bg-white focus:text-[#553DE9] focus:rounded-[3px] focus:shadow-card",children:"Skip to main content"}),O.jsx(ng,{wsConnected:r,version:i}),O.jsx("main",{id:"main-content",className:"flex-1 overflow-auto",children:O.jsx(Mv,{})})]})}function _h({children:i}){const{user:f,loading:r,isLocalMode:o}=kh();return r?O.jsx("div",{className:"h-screen bg-[#FAF9F6] flex items-center justify-center text-[#6B6960] text-sm",children:"Loading..."}):o?O.jsx(O.Fragment,{children:i}):f?O.jsx(O.Fragment,{children:i}):O.jsx(Cv,{to:"/login",replace:!0})}function hi({variant:i="text",width:f,height:r,className:o=""}){const d="animate-pulse bg-[#ECEAE3]/60 rounded";if(i==="circle"){const h=f||"2rem";return O.jsx("div",{className:`${d} rounded-full flex-shrink-0 ${o}`,style:{width:h,height:h}})}return i==="block"?O.jsx("div",{className:`${d} rounded-btn ${o}`,style:{width:f||"100%",height:r||"4rem"}}):O.jsx("div",{className:`${d} rounded-btn ${o}`,style:{width:f||"100%",height:r||"0.75rem"}})}function bg(){return O.jsx("div",{className:"p-4 space-y-3",children:[...Array(12)].map((i,f)=>O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsx(hi,{variant:"text",width:"1.5rem",height:"10px",className:"flex-shrink-0 opacity-40"}),O.jsx(hi,{variant:"text",width:`${20+Math.random()*60}%`,height:"10px"})]},f))})}typeof window<"u"&&window.addEventListener("beforeunload",i=>{delete i.returnValue});const og=E.lazy(()=>Pl(()=>import("./HomePage-C0-_6Avk.js"),__vite__mapDeps([0,1,2,3]))),sg=E.lazy(()=>Pl(()=>import("./ProjectPage-DQG_ZYM7.js"),__vite__mapDeps([4,3,5,2,6,7,8]))),rg=E.lazy(()=>Pl(()=>import("./ProjectsPage-BAQOc1tx.js"),__vite__mapDeps([9,5,10,1,2,7]))),dg=E.lazy(()=>Pl(()=>import("./TemplatesPage-CyxNji74.js"),__vite__mapDeps([11,10,1,2]))),hg=E.lazy(()=>Pl(()=>import("./SettingsPage-DiKaBtvg.js"),__vite__mapDeps([12,10,7]))),mg=E.lazy(()=>Pl(()=>import("./LoginPage-BlJm-Tzr.js"),[])),yg=E.lazy(()=>Pl(()=>import("./NotFoundPage-CsRjjzWq.js"),__vite__mapDeps([13,6])));function Il(){return O.jsxs("div",{className:"h-screen bg-[#FAF9F6] flex flex-col items-center justify-center gap-3",children:[O.jsx(hi,{variant:"block",width:"200px",height:"24px"}),O.jsx(hi,{variant:"text",width:"140px",height:"12px",className:"opacity-50"})]})}function vg(){return O.jsx(tg,{children:O.jsxs(Uv,{children:[O.jsx(il,{path:"/login",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(mg,{})})}),O.jsx(il,{path:"/project/:sessionId",element:O.jsx(_h,{children:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(sg,{})})})}),O.jsxs(il,{element:O.jsx(_h,{children:O.jsx(fg,{})}),children:[O.jsx(il,{path:"/",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(og,{})})}),O.jsx(il,{path:"/projects",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(rg,{})})}),O.jsx(il,{path:"/templates",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(dg,{})})}),O.jsx(il,{path:"/settings",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(hg,{})})}),O.jsx(il,{path:"*",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(yg,{})})})]})]})})}N0.createRoot(document.getElementById("root")).render(O.jsx(E.StrictMode,{children:O.jsx(l1,{children:O.jsx(vg,{})})}));export{S1 as A,E1 as B,_1 as E,R1 as F,N1 as H,Xh as L,Y1 as M,Vh as S,$1 as T,pg as W,Kh as X,qa as a,cg as b,Jt as c,bg as d,hi as e,Sg as f,kh as g,O as j,E as r,Ff as u};
|
|
186
|
+
*/const k1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Kh=Jt("x",k1),Jh=`${window.location.origin}/api`,W1=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;function F1(){const i={"Content-Type":"application/json"};try{const f=localStorage.getItem("pl_auth_token");f&&(i.Authorization=`Bearer ${f}`)}catch{}return i}async function $(i,f){const r=await fetch(`${Jh}${i}`,{...f,headers:{...F1(),...f==null?void 0:f.headers}});if(!r.ok){const o=await r.text().catch(()=>"");throw new Error(`API error ${r.status}: ${r.statusText}${o?` - ${o}`:""}`)}return r.json()}const qa={startSession:i=>$("/session/start",{method:"POST",body:JSON.stringify(i)}),stopSession:()=>$("/session/stop",{method:"POST"}),pauseSession:()=>$("/session/pause",{method:"POST"}),resumeSession:()=>$("/session/resume",{method:"POST"}),getPrdPrefill:()=>$("/session/prd-prefill"),getStatus:()=>$("/session/status"),getAgents:()=>$("/session/agents"),getLogs:(i=200)=>$(`/session/logs?lines=${i}`),getMemorySummary:()=>$("/session/memory"),getChecklist:()=>$("/session/checklist"),getFiles:()=>$("/session/files"),getFileContent:i=>$(`/session/files/content?path=${encodeURIComponent(i)}`),getSessionFileContent:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/file?path=${encodeURIComponent(f)}`),getTemplates:()=>$("/templates"),getTemplateContent:i=>$(`/templates/${encodeURIComponent(i)}`),planSession:(i,f)=>$("/session/plan",{method:"POST",body:JSON.stringify({prd:i,provider:f})}),generateReport:(i="markdown")=>$("/session/report",{method:"POST",body:JSON.stringify({format:i})}),shareSession:()=>$("/session/share",{method:"POST"}),getCurrentProvider:()=>$("/provider/current"),setProvider:i=>$("/provider/set",{method:"POST",body:JSON.stringify({provider:i})}),getMetrics:()=>$("/session/metrics"),getSessionsHistory:()=>$("/sessions/history"),getSessionDetail:i=>$(`/sessions/${encodeURIComponent(i)}`),deleteSession:i=>$(`/sessions/${encodeURIComponent(i)}`,{method:"DELETE"}),onboardRepo:i=>$("/session/onboard",{method:"POST",body:JSON.stringify({path:i})}),saveSessionFile:(i,f,r)=>$(`/sessions/${encodeURIComponent(i)}/file`,{method:"PUT",body:JSON.stringify({path:f,content:r})}),createSessionFile:(i,f,r="")=>$(`/sessions/${encodeURIComponent(i)}/file`,{method:"POST",body:JSON.stringify({path:f,content:r})}),deleteSessionFile:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/file`,{method:"DELETE",body:JSON.stringify({path:f})}),createSessionDirectory:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/directory`,{method:"POST",body:JSON.stringify({path:f})}),reviewProject:i=>$(`/sessions/${encodeURIComponent(i)}/review`,{method:"POST"}),testProject:i=>$(`/sessions/${encodeURIComponent(i)}/test`,{method:"POST"}),explainProject:i=>$(`/sessions/${encodeURIComponent(i)}/explain`,{method:"POST"}),exportProject:i=>$(`/sessions/${encodeURIComponent(i)}/export`,{method:"POST"}),fixProject:i=>$(`/sessions/${encodeURIComponent(i)}/fix`,{method:"POST"}),chatMessage:(i,f,r="quick")=>$(`/sessions/${encodeURIComponent(i)}/chat`,{method:"POST",body:JSON.stringify({message:f,mode:r})}),chatStart:(i,f,r="quick")=>$(`/sessions/${encodeURIComponent(i)}/chat`,{method:"POST",body:JSON.stringify({message:f,mode:r})}),chatPoll:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/chat/${encodeURIComponent(f)}`),chatStreamUrl:(i,f)=>`${Jh}/sessions/${encodeURIComponent(i)}/chat/${encodeURIComponent(f)}/stream`,chatCancel:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/chat/${encodeURIComponent(f)}/cancel`,{method:"POST"}),getPreviewInfo:i=>$(`/sessions/${encodeURIComponent(i)}/preview-info`),devserver:{start:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/devserver/start`,{method:"POST",body:JSON.stringify({command:f||null})}),stop:i=>$(`/sessions/${encodeURIComponent(i)}/devserver/stop`,{method:"POST"}),status:i=>$(`/sessions/${encodeURIComponent(i)}/devserver/status`)},getSecrets:()=>$("/secrets"),setSecret:(i,f)=>$("/secrets",{method:"POST",body:JSON.stringify({key:i,value:f})}),deleteSecret:i=>$(`/secrets/${encodeURIComponent(i)}`,{method:"DELETE"}),getServices:i=>$(`/sessions/${encodeURIComponent(i)}/services`),getServiceLogs:(i,f,r=50)=>$(`/sessions/${encodeURIComponent(i)}/devserver/logs${f?`?service=${encodeURIComponent(f)}&tail=${r}`:`?tail=${r}`}`),restartService:(i,f)=>$(`/sessions/${encodeURIComponent(i)}/devserver/restart-service`,{method:"POST",body:JSON.stringify({service:f})}),getMe:()=>$("/auth/me"),getGitHubAuthUrl:()=>$("/auth/github/url"),getGoogleAuthUrl:()=>$("/auth/google/url"),githubCallback:(i,f)=>$("/auth/github/callback",{method:"POST",body:JSON.stringify({code:i,state:f})}),googleCallback:(i,f,r)=>$("/auth/google/callback",{method:"POST",body:JSON.stringify({code:i,state:f,redirect_uri:r||`${window.location.origin}${window.location.pathname}`})})};class I1{constructor(f){Bn(this,"ws",null);Bn(this,"listeners",new Map);Bn(this,"reconnectTimer",null);Bn(this,"url");this.url=f||W1}connect(){var f;((f=this.ws)==null?void 0:f.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.emit("connected",{message:"WebSocket connected"})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.emit(o.type,o.data||o)}catch{}},this.ws.onclose=()=>{this.emit("disconnected",{}),this.scheduleReconnect()},this.ws.onerror=()=>{var r;(r=this.ws)==null||r.close()})}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},3e3))}on(f,r){return this.listeners.has(f)||this.listeners.set(f,new Set),this.listeners.get(f).add(r),()=>{var o;return(o=this.listeners.get(f))==null?void 0:o.delete(r)}}emit(f,r){var o,d;(o=this.listeners.get(f))==null||o.forEach(h=>h(r)),(d=this.listeners.get("*"))==null||d.forEach(h=>h({type:f,data:r}))}send(f){var r;((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(f))}disconnect(){var f;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(f=this.ws)==null||f.close(),this.ws=null}}const Vf="pl_auth_token",$h=E.createContext({user:null,loading:!0,login:()=>{},logout:()=>{},isLocalMode:!0});function P1(i,f,r){f(!1),r({email:i.sub||i.email||"",name:i.name||"",avatar_url:i.avatar||"",authenticated:!0})}function tg({children:i}){const[f,r]=E.useState(null),[o,d]=E.useState(!0),[h,g]=E.useState(!0),_=Ff(),S=je();E.useEffect(()=>{let j=!1;async function w(){const Z=new URLSearchParams(window.location.search),Y=Z.get("token"),G=Z.get("code");if(Y)localStorage.setItem(Vf,Y),window.history.replaceState({},"",window.location.pathname);else if(G)try{const B=sessionStorage.getItem("pl_oauth_provider")||"github",F=sessionStorage.getItem("pl_oauth_state")||"";sessionStorage.removeItem("pl_oauth_state"),sessionStorage.removeItem("pl_oauth_provider");let K;if(B==="google"?K=await qa.googleCallback(G,F):K=await qa.githubCallback(G,F),!j){localStorage.setItem(Vf,K.token),window.history.replaceState({},"",window.location.pathname),g(!1),r({email:K.user.email,name:K.user.name,avatar_url:K.user.avatar_url,authenticated:!0}),d(!1);return}}catch{window.history.replaceState({},"",window.location.pathname)}try{const B=await qa.getMe();if(j)return;B.local_mode?(g(!0),r(null)):B.authenticated?P1(B,g,r):(g(!1),r(null))}catch{if(j)return;g(!0),r(null)}finally{j||d(!1)}}return w(),()=>{j=!0}},[]);const y=E.useCallback(j=>{j==="github"?qa.getGitHubAuthUrl().then(w=>{try{const Y=new URL(w.url).searchParams.get("state");Y&&(sessionStorage.setItem("pl_oauth_state",Y),sessionStorage.setItem("pl_oauth_provider","github"))}catch{}window.location.href=w.url}).catch(()=>{}):j==="google"&&qa.getGoogleAuthUrl().then(w=>{try{const Y=new URL(w.url).searchParams.get("state");Y&&(sessionStorage.setItem("pl_oauth_state",Y),sessionStorage.setItem("pl_oauth_provider","google"))}catch{}window.location.href=w.url}).catch(()=>{})},[]),C=E.useCallback(()=>{localStorage.removeItem(Vf),r(null),S.pathname!=="/login"&&_("/login",{replace:!0})},[_,S.pathname]),z=E.useMemo(()=>({user:f,loading:o,login:y,logout:C,isLocalMode:h}),[f,o,y,C,h]);return O.jsx($h.Provider,{value:z,children:i})}function kh(){return E.useContext($h)}const Th="pl_sidebar_collapsed",eg=[{to:"/",label:"Home",icon:N1},{to:"/projects",label:"Projects",icon:C1},{to:"/templates",label:"Templates",icon:D1}],lg=[{to:"/settings",label:"Settings",icon:Vh}];function ag(){const[i,f]=E.useState(typeof window<"u"?window.innerWidth<768:!1);return E.useEffect(()=>{const r=()=>f(window.innerWidth<768);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),i}function ng({wsConnected:i,version:f}){const r=ag(),o=je(),[d,h]=E.useState(!1),[g,_]=E.useState(()=>{try{return localStorage.getItem(Th)==="1"}catch{return!1}});E.useEffect(()=>{try{localStorage.setItem(Th,g?"1":"0")}catch{}},[g]),E.useEffect(()=>{r&&h(!1)},[o.pathname,r]);const S=r?d:!g,y=S?240:64,C=j=>["flex items-center gap-3 px-3 py-2 text-sm transition-colors rounded-[5px]",!S&&"justify-center",j?"bg-[#553DE9]/8 text-[#553DE9] font-medium border-l-2 border-[#553DE9]":"text-[#36342E] hover:bg-[#F8F4F0]"].filter(Boolean).join(" "),z=O.jsxs("aside",{className:"flex flex-col h-full border-r border-[#ECEAE3] bg-white transition-[width] duration-200",style:{width:y,minWidth:y},children:[O.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-b border-[#ECEAE3]",children:[S&&O.jsxs("div",{className:"flex flex-col",children:[O.jsx("span",{className:"font-heading text-lg font-bold leading-tight text-[#36342E]",children:"Purple Lab"}),O.jsx("span",{className:"text-xs text-[#6B6960]",children:"Powered by Loki"})]}),r?O.jsx("button",{type:"button","aria-label":d?"Close menu":"Open menu",title:d?"Close menu":"Open menu",onClick:()=>h(!d),className:"inline-flex items-center justify-center w-7 h-7 rounded-[3px] text-[#939084] hover:bg-[#F8F4F0] transition-colors",children:d?O.jsx(Kh,{size:16}):O.jsx(L1,{size:16})}):O.jsx("button",{type:"button","aria-label":g?"Expand sidebar":"Collapse sidebar",title:g?"Expand sidebar":"Collapse sidebar",onClick:()=>_(!g),className:"inline-flex items-center justify-center w-7 h-7 rounded-[3px] text-[#939084] hover:bg-[#F8F4F0] transition-colors",children:g?O.jsx(V1,{size:16}):O.jsx(Q1,{size:16})})]}),O.jsxs("nav",{className:"flex-1 px-2 py-3 flex flex-col gap-1","aria-label":"Main navigation",children:[eg.map(j=>O.jsxs(di,{to:j.to,end:j.to==="/",className:({isActive:w})=>C(w),title:S?void 0:j.label,children:[O.jsx(j.icon,{size:18}),S&&O.jsx("span",{children:j.label})]},j.to)),O.jsx("div",{className:"my-2 border-t border-[#ECEAE3]"}),lg.map(j=>O.jsxs(di,{to:j.to,className:({isActive:w})=>C(w),title:S?void 0:j.label,children:[O.jsx(j.icon,{size:18}),S&&O.jsx("span",{children:j.label})]},j.to))]}),O.jsxs("div",{className:"px-3 py-3 border-t border-[#ECEAE3] flex flex-col gap-2",children:[O.jsx(ug,{collapsed:!S}),O.jsxs("div",{className:["flex items-center gap-2 text-xs",!S&&"justify-center"].filter(Boolean).join(" "),children:[O.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${i?"bg-[#1FC5A8]":"bg-[#C45B5B]"}`}),S&&O.jsx("span",{className:"text-[#6B6960]",children:i?"Connected":"Disconnected"})]}),S&&f&&O.jsxs("span",{className:"text-xs text-[#6B6960]",children:["v",f]}),O.jsxs("a",{href:"https://www.autonomi.dev/docs",target:"_blank",rel:"noopener noreferrer",className:["flex items-center gap-2 text-xs text-[#6B6960] hover:text-[#36342E] transition-colors",!S&&"justify-center"].filter(Boolean).join(" "),title:S?void 0:"Documentation",children:[O.jsx(E1,{size:14}),S&&O.jsx("span",{children:"Docs"})]})]})]});return r&&d?O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"fixed inset-0 z-40 bg-ink/20",onClick:()=>h(!1)}),O.jsx("div",{className:"fixed inset-y-0 left-0 z-50",children:z})]}):z}function ug({collapsed:i}){const{user:f,logout:r,isLocalMode:o}=kh(),[d,h]=E.useState(!1),g=E.useRef(null);return E.useEffect(()=>{function _(S){g.current&&!g.current.contains(S.target)&&h(!1)}if(d)return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[d]),o||!f?O.jsxs("div",{className:["flex items-center gap-2 text-xs",i&&"justify-center"].filter(Boolean).join(" "),title:i?"Local Mode":void 0,children:[O.jsx(G1,{size:14,className:"text-[#939084] flex-shrink-0"}),!i&&O.jsx("span",{className:"text-[#939084]",children:"Local Mode"})]}):O.jsxs("div",{className:"relative",ref:g,"data-testid":"user-section",children:[O.jsxs("button",{type:"button",onClick:()=>h(!d),className:["flex items-center gap-2 w-full text-left text-xs rounded-[3px] py-1 px-1 hover:bg-[#F8F4F0] transition-colors",i&&"justify-center"].filter(Boolean).join(" "),title:i?f.name||f.email:void 0,children:[f.avatar_url?O.jsx("img",{src:f.avatar_url,alt:"",className:"w-5 h-5 rounded-full flex-shrink-0"}):O.jsx("div",{className:"w-5 h-5 rounded-full bg-[#553DE9] flex items-center justify-center text-white text-[10px] font-bold flex-shrink-0",children:(f.name||f.email||"?")[0].toUpperCase()}),!i&&O.jsxs(O.Fragment,{children:[O.jsx("span",{className:"text-[#36342E] truncate flex-1",children:f.name||f.email}),O.jsx(T1,{size:12,className:`text-[#939084] transition-transform ${d?"":"rotate-180"}`})]})]}),d&&O.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-48 bg-white border border-[#ECEAE3] rounded-lg shadow-lg py-1 z-50",children:[O.jsxs("div",{className:"px-3 py-2 border-b border-[#ECEAE3]",children:[O.jsx("p",{className:"text-xs font-medium text-[#36342E] truncate",children:f.name}),O.jsx("p",{className:"text-xs text-[#939084] truncate",children:f.email})]}),O.jsxs(di,{to:"/settings",onClick:()=>h(!1),className:"flex items-center gap-2 px-3 py-2 text-xs text-[#36342E] hover:bg-[#F8F4F0] transition-colors",children:[O.jsx(Vh,{size:14}),"Settings"]}),O.jsxs("button",{type:"button",onClick:()=>{h(!1),r()},className:"flex items-center gap-2 px-3 py-2 text-xs text-[#C45B5B] hover:bg-[#F8F4F0] transition-colors w-full text-left",children:[O.jsx(H1,{size:14}),"Sign out"]})]})]})}const zh="pl_onboarding_complete",wn=[{icon:R1,title:"Write your PRD",description:"Describe what you want to build, or choose a template to get started quickly."},{icon:$1,title:"Use the terminal",description:"Run commands directly in the integrated terminal to install dependencies or debug."},{icon:_1,title:"Preview in real-time",description:"Switch to the Preview tab to see your app running with live reload."},{icon:Y1,title:"Iterate with AI Chat",description:"Ask the AI to modify, fix, or explain your code in the chat panel."}];function ig(){const[i,f]=E.useState(!1),[r,o]=E.useState(0);E.useEffect(()=>{try{localStorage.getItem(zh)!=="1"&&f(!0)}catch{}},[]);const d=()=>{f(!1);try{localStorage.setItem(zh,"1")}catch{}},h=()=>{r<wn.length-1?o(r+1):d()};if(!i)return null;const g=wn[r],_=g.icon;return O.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/30",children:O.jsxs("div",{className:"bg-card rounded-card shadow-card-hover border border-border w-full max-w-sm mx-4",children:[O.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-2",children:[O.jsxs("span",{className:"text-[11px] font-mono text-muted-accessible",children:[r+1," / ",wn.length]}),O.jsx("button",{onClick:d,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",title:"Skip onboarding",children:O.jsx(Kh,{size:14})})]}),O.jsxs("div",{className:"px-5 pb-4 text-center",children:[O.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-4",children:O.jsx(_,{size:24,className:"text-primary"})}),O.jsx("h3",{className:"text-sm font-heading font-bold text-ink mb-1",children:g.title}),O.jsx("p",{className:"text-xs text-muted-accessible leading-relaxed",children:g.description})]}),O.jsx("div",{className:"flex items-center justify-center gap-1.5 pb-4",children:wn.map((S,y)=>O.jsx("div",{className:`w-1.5 h-1.5 rounded-full transition-colors ${y===r?"bg-primary":"bg-border"}`},y))}),O.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border",children:[O.jsx("button",{onClick:d,className:"text-xs text-muted hover:text-ink transition-colors",children:"Skip"}),O.jsx("button",{onClick:h,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:r<wn.length-1?O.jsxs(O.Fragment,{children:["Next",O.jsx(S1,{size:12})]}):"Get Started"})]})]})})}function cg(i){const[f,r]=E.useState(!1),o=E.useRef(null),d=E.useRef(i);E.useEffect(()=>{d.current=i},[i]),E.useEffect(()=>{const g=new I1;return o.current=g,g.on("connected",()=>r(!0)),g.on("disconnected",()=>{r(!1),d.current&&d.current(null)}),g.on("state_update",_=>{d.current&&_&&typeof _=="object"&&d.current(_)}),g.connect(),()=>{g.disconnect(),o.current=null}},[]);const h=E.useCallback((g,_)=>{var S;return((S=o.current)==null?void 0:S.on(g,_))||(()=>{})},[]);return{connected:f,subscribe:h}}function fg(){const[i,f]=E.useState(""),{connected:r}=cg(()=>{});return E.useEffect(()=>{qa.getStatus().then(o=>{f(o.version||"")}).catch(()=>{})},[]),O.jsxs("div",{className:"flex h-screen bg-[#FAF9F6]",children:[O.jsx(ig,{}),O.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:top-2 focus:left-2 focus:px-4 focus:py-2 focus:bg-white focus:text-[#553DE9] focus:rounded-[3px] focus:shadow-card",children:"Skip to main content"}),O.jsx(ng,{wsConnected:r,version:i}),O.jsx("main",{id:"main-content",className:"flex-1 overflow-auto",children:O.jsx(Mv,{})})]})}function _h({children:i}){const{user:f,loading:r,isLocalMode:o}=kh();return r?O.jsx("div",{className:"h-screen bg-[#FAF9F6] flex items-center justify-center text-[#6B6960] text-sm",children:"Loading..."}):o?O.jsx(O.Fragment,{children:i}):f?O.jsx(O.Fragment,{children:i}):O.jsx(Cv,{to:"/login",replace:!0})}function hi({variant:i="text",width:f,height:r,className:o=""}){const d="animate-pulse bg-[#ECEAE3]/60 rounded";if(i==="circle"){const h=f||"2rem";return O.jsx("div",{className:`${d} rounded-full flex-shrink-0 ${o}`,style:{width:h,height:h}})}return i==="block"?O.jsx("div",{className:`${d} rounded-btn ${o}`,style:{width:f||"100%",height:r||"4rem"}}):O.jsx("div",{className:`${d} rounded-btn ${o}`,style:{width:f||"100%",height:r||"0.75rem"}})}function bg(){return O.jsx("div",{className:"p-4 space-y-3",children:[...Array(12)].map((i,f)=>O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsx(hi,{variant:"text",width:"1.5rem",height:"10px",className:"flex-shrink-0 opacity-40"}),O.jsx(hi,{variant:"text",width:`${20+Math.random()*60}%`,height:"10px"})]},f))})}typeof window<"u"&&window.addEventListener("beforeunload",i=>{delete i.returnValue});const og=E.lazy(()=>Pl(()=>import("./HomePage-DYS0zqqT.js"),__vite__mapDeps([0,1,2,3]))),sg=E.lazy(()=>Pl(()=>import("./ProjectPage-D-ZyzZUT.js"),__vite__mapDeps([4,3,5,2,6,7,8]))),rg=E.lazy(()=>Pl(()=>import("./ProjectsPage-CMacaz1V.js"),__vite__mapDeps([9,5,10,1,2,7]))),dg=E.lazy(()=>Pl(()=>import("./TemplatesPage-Bq8ASiy4.js"),__vite__mapDeps([11,10,1,2]))),hg=E.lazy(()=>Pl(()=>import("./SettingsPage-B9XKC6ge.js"),__vite__mapDeps([12,10,7]))),mg=E.lazy(()=>Pl(()=>import("./LoginPage-D5Jj_Q44.js"),[])),yg=E.lazy(()=>Pl(()=>import("./NotFoundPage-DLG6ORdp.js"),__vite__mapDeps([13,6])));function Il(){return O.jsxs("div",{className:"h-screen bg-[#FAF9F6] flex flex-col items-center justify-center gap-3",children:[O.jsx(hi,{variant:"block",width:"200px",height:"24px"}),O.jsx(hi,{variant:"text",width:"140px",height:"12px",className:"opacity-50"})]})}function vg(){return O.jsx(tg,{children:O.jsxs(Uv,{children:[O.jsx(il,{path:"/login",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(mg,{})})}),O.jsx(il,{path:"/project/:sessionId",element:O.jsx(_h,{children:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(sg,{})})})}),O.jsxs(il,{element:O.jsx(_h,{children:O.jsx(fg,{})}),children:[O.jsx(il,{path:"/",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(og,{})})}),O.jsx(il,{path:"/projects",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(rg,{})})}),O.jsx(il,{path:"/templates",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(dg,{})})}),O.jsx(il,{path:"/settings",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(hg,{})})}),O.jsx(il,{path:"*",element:O.jsx(E.Suspense,{fallback:O.jsx(Il,{}),children:O.jsx(yg,{})})})]})]})})}N0.createRoot(document.getElementById("root")).render(O.jsx(E.StrictMode,{children:O.jsx(l1,{children:O.jsx(vg,{})})}));export{S1 as A,E1 as B,_1 as E,R1 as F,N1 as H,Xh as L,Y1 as M,Vh as S,$1 as T,pg as W,Kh as X,qa as a,cg as b,Jt as c,bg as d,hi as e,Sg as f,kh as g,O as j,E as r,Ff as u};
|
package/web-app/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
9
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
10
|
<link href="https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-Cyfnu-vw.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-CQcaFLVo.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body class="bg-background text-ink font-sans antialiased">
|
package/web-app/server.py
CHANGED
|
@@ -641,8 +641,11 @@ class DevServerManager:
|
|
|
641
641
|
p_str = str(p)
|
|
642
642
|
if ":" in p_str:
|
|
643
643
|
parts = p_str.split(":")
|
|
644
|
-
|
|
645
|
-
|
|
644
|
+
try:
|
|
645
|
+
host_port = int(parts[-2].split("-")[0])
|
|
646
|
+
svc_ports.append(host_port)
|
|
647
|
+
except (ValueError, IndexError):
|
|
648
|
+
continue
|
|
646
649
|
services_info.append({
|
|
647
650
|
"name": svc_name,
|
|
648
651
|
"ports": svc_ports,
|
|
@@ -1347,21 +1350,30 @@ class DevServerManager:
|
|
|
1347
1350
|
info["auto_fix_status"] = "circuit breaker open (3 failures in 5 min)"
|
|
1348
1351
|
logger.warning("Auto-fix circuit breaker open for session %s", session_id)
|
|
1349
1352
|
elif attempts < 3:
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1353
|
+
# BUG-V63-009: Prevent dual monitors from racing to auto-fix
|
|
1354
|
+
if not info.get("_auto_fixing"):
|
|
1355
|
+
info["_auto_fixing"] = True
|
|
1356
|
+
info["auto_fix_attempts"] = attempts + 1
|
|
1357
|
+
timestamps.append(now)
|
|
1358
|
+
info["auto_fix_timestamps"] = timestamps
|
|
1359
|
+
backoff_seconds = 5 * (3 ** attempts)
|
|
1360
|
+
error_context = "\n".join(info.get("output_lines", [])[-30:])
|
|
1361
|
+
|
|
1362
|
+
async def _delayed_auto_fix():
|
|
1363
|
+
try:
|
|
1364
|
+
await asyncio.sleep(backoff_seconds)
|
|
1365
|
+
await self._auto_fix(session_id, error_context)
|
|
1366
|
+
finally:
|
|
1367
|
+
_info = self.servers.get(session_id)
|
|
1368
|
+
if _info:
|
|
1369
|
+
_info["_auto_fixing"] = False
|
|
1355
1370
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
info["_auto_fix_task"] = task
|
|
1363
|
-
except Exception:
|
|
1364
|
-
logger.warning("Failed to schedule auto-fix for session %s", session_id, exc_info=True)
|
|
1371
|
+
try:
|
|
1372
|
+
task = asyncio.ensure_future(_delayed_auto_fix())
|
|
1373
|
+
info["_auto_fix_task"] = task
|
|
1374
|
+
except Exception:
|
|
1375
|
+
info["_auto_fixing"] = False
|
|
1376
|
+
logger.warning("Failed to schedule auto-fix for session %s", session_id, exc_info=True)
|
|
1365
1377
|
|
|
1366
1378
|
async def _monitor_backend_output(self, session_id: str) -> None:
|
|
1367
1379
|
"""Background task: read backend dev server stdout for multi-service setups."""
|
|
@@ -1442,8 +1454,9 @@ class DevServerManager:
|
|
|
1442
1454
|
except Exception:
|
|
1443
1455
|
logger.debug("Docker context gathering for auto-fix failed", exc_info=True)
|
|
1444
1456
|
|
|
1445
|
-
# Save original command before stop() removes the info dict
|
|
1457
|
+
# Save original command and multi_service flag before stop() removes the info dict
|
|
1446
1458
|
cmd = info.get("original_command")
|
|
1459
|
+
is_multi_service = info.get("multi_service", False)
|
|
1447
1460
|
|
|
1448
1461
|
try:
|
|
1449
1462
|
auto_fix_env = {**os.environ}
|
|
@@ -1465,7 +1478,12 @@ class DevServerManager:
|
|
|
1465
1478
|
# Restart the dev server
|
|
1466
1479
|
await self.stop(session_id)
|
|
1467
1480
|
await asyncio.sleep(1)
|
|
1468
|
-
|
|
1481
|
+
# BUG-V63-008: For multi-service sessions, omit command= to re-enter
|
|
1482
|
+
# the multi-service detection path in start()
|
|
1483
|
+
if is_multi_service:
|
|
1484
|
+
await self.start(session_id, str(target))
|
|
1485
|
+
else:
|
|
1486
|
+
await self.start(session_id, str(target), command=cmd)
|
|
1469
1487
|
# Transfer circuit breaker state to the new info dict
|
|
1470
1488
|
new_info = self.servers.get(session_id)
|
|
1471
1489
|
if new_info:
|
|
@@ -1513,6 +1531,11 @@ class DevServerManager:
|
|
|
1513
1531
|
if fix_task and not fix_task.done():
|
|
1514
1532
|
fix_task.cancel()
|
|
1515
1533
|
|
|
1534
|
+
# Cancel any tracked Docker service fix tasks (BUG-V64-003)
|
|
1535
|
+
for task in info.get("_fix_tasks", {}).values():
|
|
1536
|
+
if not task.done():
|
|
1537
|
+
task.cancel()
|
|
1538
|
+
|
|
1516
1539
|
# For Docker containers, run docker compose down
|
|
1517
1540
|
if info.get("framework") == "docker":
|
|
1518
1541
|
try:
|
|
@@ -1668,8 +1691,15 @@ class DevServerManager:
|
|
|
1668
1691
|
project_dir = Path(info.get("project_dir", "."))
|
|
1669
1692
|
info["docker_service_health"] = {}
|
|
1670
1693
|
|
|
1671
|
-
while
|
|
1694
|
+
while True:
|
|
1695
|
+
info = self.servers.get(session_id)
|
|
1696
|
+
if not info or not info.get("process") or info["process"].poll() is not None:
|
|
1697
|
+
break
|
|
1672
1698
|
await asyncio.sleep(10)
|
|
1699
|
+
# Re-check after sleep in case server was stopped
|
|
1700
|
+
info = self.servers.get(session_id)
|
|
1701
|
+
if not info or not info.get("process") or info["process"].poll() is not None:
|
|
1702
|
+
break
|
|
1673
1703
|
|
|
1674
1704
|
try:
|
|
1675
1705
|
docker_ctx = await _gather_docker_context(project_dir)
|
|
@@ -1702,6 +1732,20 @@ class DevServerManager:
|
|
|
1702
1732
|
recent_fixes = [t for t in svc_health["fix_timestamps"] if now - t < 600]
|
|
1703
1733
|
|
|
1704
1734
|
if len(recent_fixes) < 3:
|
|
1735
|
+
# BUG-V63-009: Prevent dual monitors from racing to auto-fix
|
|
1736
|
+
if info.get("_auto_fixing"):
|
|
1737
|
+
svc_health["fix_status"] = "fix_in_progress"
|
|
1738
|
+
info["docker_service_health"][name] = svc_health
|
|
1739
|
+
continue
|
|
1740
|
+
|
|
1741
|
+
# BUG-V64-004: Skip if a fix task is already running for this service
|
|
1742
|
+
existing_task = info.get("_fix_tasks", {}).get(name)
|
|
1743
|
+
if existing_task and not existing_task.done():
|
|
1744
|
+
svc_health["fix_status"] = "fix_in_progress"
|
|
1745
|
+
info["docker_service_health"][name] = svc_health
|
|
1746
|
+
continue # Skip, previous fix still running
|
|
1747
|
+
|
|
1748
|
+
info["_auto_fixing"] = True
|
|
1705
1749
|
svc_logs = docker_ctx.get("service_logs", {}).get(name, "")
|
|
1706
1750
|
diagnoses = _diagnose_errors(svc_logs)
|
|
1707
1751
|
diag_text = "\n".join(f"- {d['diagnosis']}: {d['suggestion']}" for d in diagnoses)
|
|
@@ -1716,8 +1760,11 @@ class DevServerManager:
|
|
|
1716
1760
|
svc_health["fix_timestamps"] = recent_fixes + [now]
|
|
1717
1761
|
svc_health["fix_status"] = "fixing"
|
|
1718
1762
|
|
|
1719
|
-
#
|
|
1720
|
-
|
|
1763
|
+
# BUG-V64-003: Track fix tasks so they can be cancelled on stop
|
|
1764
|
+
if "_fix_tasks" not in info:
|
|
1765
|
+
info["_fix_tasks"] = {}
|
|
1766
|
+
task = asyncio.ensure_future(self._auto_fix_service(session_id, name, fix_prompt))
|
|
1767
|
+
info["_fix_tasks"][name] = task
|
|
1721
1768
|
else:
|
|
1722
1769
|
svc_health["fix_status"] = "circuit_breaker_open"
|
|
1723
1770
|
|
|
@@ -1743,6 +1790,7 @@ class DevServerManager:
|
|
|
1743
1790
|
project_dir = info.get("project_dir", ".")
|
|
1744
1791
|
loki = _find_loki_cli()
|
|
1745
1792
|
if not loki:
|
|
1793
|
+
info["_auto_fixing"] = False
|
|
1746
1794
|
return
|
|
1747
1795
|
|
|
1748
1796
|
try:
|
|
@@ -1760,12 +1808,21 @@ class DevServerManager:
|
|
|
1760
1808
|
capture_output=True, cwd=project_dir, timeout=30
|
|
1761
1809
|
)
|
|
1762
1810
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1811
|
+
# BUG-V64-005: Re-fetch from live info dict to avoid writing to detached dict
|
|
1812
|
+
info = self.servers.get(session_id)
|
|
1813
|
+
if info and "docker_service_health" in info and service_name in info["docker_service_health"]:
|
|
1814
|
+
info["docker_service_health"][service_name]["fix_status"] = "fixed" if proc.returncode == 0 else "fix_failed"
|
|
1765
1815
|
except Exception as exc:
|
|
1766
1816
|
logger.error("Auto-fix for service '%s' failed: %s", service_name, exc)
|
|
1767
|
-
|
|
1768
|
-
|
|
1817
|
+
# BUG-V64-005: Re-fetch from live info dict
|
|
1818
|
+
info = self.servers.get(session_id)
|
|
1819
|
+
if info and "docker_service_health" in info and service_name in info["docker_service_health"]:
|
|
1820
|
+
info["docker_service_health"][service_name]["fix_status"] = "fix_failed"
|
|
1821
|
+
finally:
|
|
1822
|
+
# BUG-V63-009: Clear the auto-fixing lock
|
|
1823
|
+
info = self.servers.get(session_id)
|
|
1824
|
+
if info:
|
|
1825
|
+
info["_auto_fixing"] = False
|
|
1769
1826
|
|
|
1770
1827
|
async def stop_all(self) -> None:
|
|
1771
1828
|
"""Stop all dev servers (used on shutdown)."""
|
|
@@ -1781,8 +1838,17 @@ dev_server_manager = DevServerManager()
|
|
|
1781
1838
|
# ---------------------------------------------------------------------------
|
|
1782
1839
|
|
|
1783
1840
|
|
|
1841
|
+
_docker_context_cache: dict[str, tuple[float, dict]] = {}
|
|
1842
|
+
|
|
1843
|
+
|
|
1784
1844
|
async def _gather_docker_context(project_dir: Path) -> dict:
|
|
1785
1845
|
"""Gather Docker Compose service status, logs, and project context."""
|
|
1846
|
+
cache_key = str(project_dir)
|
|
1847
|
+
now = time.time()
|
|
1848
|
+
cached = _docker_context_cache.get(cache_key)
|
|
1849
|
+
if cached and now - cached[0] < 30:
|
|
1850
|
+
return cached[1]
|
|
1851
|
+
|
|
1786
1852
|
loop = asyncio.get_running_loop()
|
|
1787
1853
|
result: dict = {"service_status": [], "failing_services": [], "service_logs": {},
|
|
1788
1854
|
"project_structure": "", "env_keys": []}
|
|
@@ -1793,22 +1859,37 @@ async def _gather_docker_context(project_dir: Path) -> dict:
|
|
|
1793
1859
|
["docker", "compose", "ps", "--format", "json"],
|
|
1794
1860
|
capture_output=True, text=True, cwd=str(project_dir), timeout=10
|
|
1795
1861
|
))
|
|
1796
|
-
if ps_proc.returncode == 0:
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1862
|
+
if ps_proc.returncode == 0 and ps_proc.stdout.strip():
|
|
1863
|
+
raw = ps_proc.stdout.strip()
|
|
1864
|
+
# Handle both NDJSON (one object per line) and JSON array formats
|
|
1865
|
+
# Docker Compose v2.21+ returns a JSON array instead of NDJSON
|
|
1866
|
+
services_data: list = []
|
|
1867
|
+
try:
|
|
1868
|
+
parsed = json.loads(raw)
|
|
1869
|
+
if isinstance(parsed, list):
|
|
1870
|
+
services_data = parsed
|
|
1871
|
+
else:
|
|
1872
|
+
services_data = [parsed]
|
|
1873
|
+
except json.JSONDecodeError:
|
|
1874
|
+
# NDJSON format - one JSON object per line
|
|
1875
|
+
for line in raw.split("\n"):
|
|
1876
|
+
if line.strip():
|
|
1877
|
+
try:
|
|
1878
|
+
services_data.append(json.loads(line))
|
|
1879
|
+
except json.JSONDecodeError:
|
|
1880
|
+
pass
|
|
1881
|
+
for svc in services_data:
|
|
1882
|
+
if not isinstance(svc, dict):
|
|
1883
|
+
continue
|
|
1884
|
+
status_entry = {
|
|
1885
|
+
"name": svc.get("Service", svc.get("Name", "unknown")),
|
|
1886
|
+
"state": svc.get("State", "unknown"),
|
|
1887
|
+
"status": svc.get("Status", ""),
|
|
1888
|
+
"exit_code": svc.get("ExitCode", 0),
|
|
1889
|
+
}
|
|
1890
|
+
result["service_status"].append(status_entry)
|
|
1891
|
+
if status_entry["state"] in ("exited", "dead", "restarting"):
|
|
1892
|
+
result["failing_services"].append(status_entry["name"])
|
|
1812
1893
|
except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
|
|
1813
1894
|
pass
|
|
1814
1895
|
|
|
@@ -1839,11 +1920,11 @@ async def _gather_docker_context(project_dir: Path) -> dict:
|
|
|
1839
1920
|
# Project structure
|
|
1840
1921
|
try:
|
|
1841
1922
|
ls_proc = await loop.run_in_executor(None, lambda: subprocess.run(
|
|
1842
|
-
["find", ".", "-maxdepth", "2", "-type", "f",
|
|
1923
|
+
["find", ".", "-maxdepth", "2", "-type", "f", "(",
|
|
1843
1924
|
"-name", "*.py", "-o", "-name", "*.ts",
|
|
1844
1925
|
"-o", "-name", "*.tsx", "-o", "-name", "*.js", "-o", "-name", "package.json",
|
|
1845
1926
|
"-o", "-name", "requirements.txt", "-o", "-name", "Dockerfile",
|
|
1846
|
-
"-o", "-name", "docker-compose.yml", "-o", "-name", "*.env"],
|
|
1927
|
+
"-o", "-name", "docker-compose.yml", "-o", "-name", "*.env", ")"],
|
|
1847
1928
|
capture_output=True, text=True, cwd=str(project_dir), timeout=5
|
|
1848
1929
|
))
|
|
1849
1930
|
result["project_structure"] = ls_proc.stdout[:2000] if ls_proc.stdout else ""
|
|
@@ -1861,6 +1942,7 @@ async def _gather_docker_context(project_dir: Path) -> dict:
|
|
|
1861
1942
|
except OSError:
|
|
1862
1943
|
pass
|
|
1863
1944
|
|
|
1945
|
+
_docker_context_cache[cache_key] = (time.time(), result)
|
|
1864
1946
|
return result
|
|
1865
1947
|
|
|
1866
1948
|
|
|
@@ -3979,7 +4061,10 @@ async def get_preview_info(session_id: str) -> JSONResponse:
|
|
|
3979
4061
|
p_str = str(p)
|
|
3980
4062
|
if ":" in p_str:
|
|
3981
4063
|
parts = p_str.split(":")
|
|
3982
|
-
|
|
4064
|
+
try:
|
|
4065
|
+
svc_ports.append(int(parts[-2].split("-")[0]))
|
|
4066
|
+
except (ValueError, IndexError):
|
|
4067
|
+
continue
|
|
3983
4068
|
compose_services.append({
|
|
3984
4069
|
"name": svc_name,
|
|
3985
4070
|
"ports": svc_ports,
|
|
@@ -4251,7 +4336,10 @@ async def get_session_services(session_id: str) -> JSONResponse:
|
|
|
4251
4336
|
p_str = str(p)
|
|
4252
4337
|
if ":" in p_str:
|
|
4253
4338
|
parts = p_str.split(":")
|
|
4254
|
-
|
|
4339
|
+
try:
|
|
4340
|
+
svc_ports.append(int(parts[-2].split("-")[0]))
|
|
4341
|
+
except (ValueError, IndexError):
|
|
4342
|
+
continue
|
|
4255
4343
|
services_info.append({
|
|
4256
4344
|
"name": svc_name,
|
|
4257
4345
|
"ports": svc_ports,
|